From ce3602a52335071b241834ea79f5e0e2ca23545b Mon Sep 17 00:00:00 2001 From: Wicaksana Pratama Date: Mon, 17 Apr 2023 03:25:15 +0700 Subject: [PATCH 1/3] fix(types): playground/tsconfig to extend from playground's build (.nuxt/tsconfig.json) --- playground/tsconfig.json | 121 +-------------------------------------- 1 file changed, 3 insertions(+), 118 deletions(-) diff --git a/playground/tsconfig.json b/playground/tsconfig.json index 8e1f3abe..28b66c52 100644 --- a/playground/tsconfig.json +++ b/playground/tsconfig.json @@ -1,119 +1,4 @@ { - "compilerOptions": { - "jsx": "preserve", - "target": "ESNext", - "module": "ESNext", - "moduleResolution": "Node", - "skipLibCheck": true, - "strict": true, - "allowJs": true, - "noEmit": true, - "resolveJsonModule": true, - "allowSyntheticDefaultImports": true, - "types": [ - "node" - ], - "baseUrl": ".", - "paths": { - "~~": [ - "." - ], - "~~/*": [ - "./*" - ], - "@@": [ - "." - ], - "@@/*": [ - "./*" - ], - "~": [ - "." - ], - "~/*": [ - "./*" - ], - "@": [ - "." - ], - "@/*": [ - "./*" - ], - "assets": [ - "assets" - ], - "public": [ - "public" - ], - "public/*": [ - "public/*" - ], - "pinceau/runtime": [ - "../src/runtime" - ], - "pinceau": [ - "../src/index" - ], - "#app": [ - "./node_modules/.pnpm/nuxt@3.0.0/node_modules/nuxt/dist/app" - ], - "#app/*": [ - "./node_modules/.pnpm/nuxt@3.0.0/node_modules/nuxt/dist/app/*" - ], - "vue-demi": [ - "./node_modules/.pnpm/nuxt@3.0.0/node_modules/nuxt/dist/app/compat/vue-demi" - ], - "#color-mode-options": [ - "./.nuxt/color-mode-options" - ], - "#nuxt-component-meta": [ - "./.nuxt/component-meta.mjs" - ], - "#nuxt-component-meta/types": [ - "./.nuxt/component-meta.d.ts" - ], - "#head": [ - "./node_modules/.pnpm/nuxt@3.0.0/node_modules/nuxt/dist/head/runtime" - ], - "#head/*": [ - "./node_modules/.pnpm/nuxt@3.0.0/node_modules/nuxt/dist/head/runtime/*" - ], - "#imports": [ - "./.nuxt/imports" - ], - "#build": [ - "./.nuxt" - ], - "#build/*": [ - "./.nuxt/*" - ], - "#pinceau/utils": [ - "/Users/yaelguilloux/Code/sandbox/pinceau/playground/.nuxt/pinceau/utils.ts" - ], - "#pinceau/theme": [ - "/Users/yaelguilloux/Code/sandbox/pinceau/playground/.nuxt/pinceau/index.ts" - ], - "#pinceau/schema": [ - "/Users/yaelguilloux/Code/sandbox/pinceau/playground/.nuxt/pinceau/schema.ts" - ], - "#pinceau/definitions": [ - "/Users/yaelguilloux/Code/sandbox/pinceau/playground/.nuxt/pinceau/schema.ts" - ], - "#components": [ - "./.nuxt/components" - ] - } - }, - "include": [ - "./.nuxt/nuxt.d.ts", - "../**/*" - ], - "exclude": [ - "./dist" - ], - "vueCompilerOptions": { - "plugins": [ - "../dist/volar.cjs" - ] - } -} + // https://nuxt.com/docs/guide/concepts/typescript + "extends": "./.nuxt/tsconfig.json" +} \ No newline at end of file From 171155a55ae5bfd1a9338a9691205a4eee745e4e Mon Sep 17 00:00:00 2001 From: Wicaksana Pratama Date: Mon, 17 Apr 2023 04:42:36 +0700 Subject: [PATCH 2/3] fix(types): PinceauMediaQueries not giving correct suggestion --- src/types/theme.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/types/theme.ts b/src/types/theme.ts index 0eb56166..490c0f8d 100644 --- a/src/types/theme.ts +++ b/src/types/theme.ts @@ -7,4 +7,4 @@ export type PinceauTokensPaths = GeneratedPinceauPaths export type PinceauUtils = GeneratedPinceauUtils -export type PinceauMediaQueries = 'dark' | 'light' | 'initial' | (keyof PinceauTheme['media'] extends string ? keyof PinceauTheme['media'] : never) +export type PinceauMediaQueries = 'dark' | 'light' | 'initial' | keyof Pick['media'] From 10b96d1dd59eb778afc5ef3c6db475bf215a615a Mon Sep 17 00:00:00 2001 From: Wicaksana Pratama Date: Mon, 17 Apr 2023 04:44:34 +0700 Subject: [PATCH 3/3] fix(types): css() not giving correct suggestion, variants default option not accepting correct value Fix #85 --- src/runtime/plugin.ts | 2 +- src/types/css.ts | 2 +- src/types/variants.ts | 46 +++++++++++++------------------------------ 3 files changed, 16 insertions(+), 34 deletions(-) diff --git a/src/runtime/plugin.ts b/src/runtime/plugin.ts index 52717d39..cf783e87 100644 --- a/src/runtime/plugin.ts +++ b/src/runtime/plugin.ts @@ -46,7 +46,7 @@ export const plugin: Plugin = { */ function usePinceauRuntime( props: any = {}, - variants: Variants, + variants: Variants, computedStyles: { [key: string]: ComputedRef }, ) { // Current component instance diff --git a/src/types/css.ts b/src/types/css.ts index dda8fbcb..1e0cdb2a 100644 --- a/src/types/css.ts +++ b/src/types/css.ts @@ -45,7 +45,7 @@ export type CSSFunctionType< UtilsProperties = PinceauUtils, > = { - variants?: Variants + variants?: Variants } & { diff --git a/src/types/variants.ts b/src/types/variants.ts index 53df7926..0ce4ddad 100644 --- a/src/types/variants.ts +++ b/src/types/variants.ts @@ -1,34 +1,16 @@ -import type { CSSProperties } from './css' -import type { PinceauMediaQueries } from './theme' +import type { CSSProperties } from './css'; -export interface VariantOptions { - type?: string - required?: boolean - default?: T | { [key in PinceauMediaQueries]?: T } - mediaPrefix?: boolean -} +export type Variant = { + [K in keyof T]: { + [key: string]: string | (CSSProperties & { $class?: string }); + } & { + options?: { + default?: T[K]; + required?: boolean; + mediaPrefix?: boolean; + readonly type?: T[K]; + }; + }; +}; -export interface BooleanVariant { - true?: CSSProperties - false?: CSSProperties - [key: string]: CSSProperties -} - -export interface EnumVariant { - [key: string]: CSSProperties -} - -export interface ClassVariant { - [key: string]: string | (CSSProperties & { $class?: string }) -} - -export type Variant = - (BooleanVariant | EnumVariant | ClassVariant) - & - { - options?: VariantOptions - } - -export interface Variants { - [key: string]: Variant -} +export type Variants = T extends Record ? Variant : any;