@pandacss/types 0.9.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/config.d.ts CHANGED
@@ -126,6 +126,30 @@ type JsxOptions = {
126
126
  * ```
127
127
  */
128
128
  jsxFactory?: string
129
+ /**
130
+ * The style props allowed on generated JSX components
131
+ * - When set to 'all', all style props are allowed.
132
+ * - When set to 'minimal', only the `css` prop is allowed.
133
+ * - When set to 'none', no style props are allowed and therefore the jsxFactory will not be importable.
134
+ *
135
+ * @default 'all'
136
+ *
137
+ * @example with 'all':
138
+ * ```jsx
139
+ * <styled.button marginTop="40px">Click me</styled.button>
140
+ * ```
141
+ *
142
+ * @example with 'minimal':
143
+ * ```jsx
144
+ * <styled.button css={{ marginTop: "40px" }}>Click me</styled.button>
145
+ * ```
146
+ *
147
+ * @example with 'none':
148
+ * ```jsx
149
+ * <button className={css({ marginTop: "40px" })}>Click me</button>
150
+ * ```
151
+ */
152
+ jsxStyleProps?: 'all' | 'minimal' | 'none'
129
153
  }
130
154
 
131
155
  type CssgenOptions = {
@@ -198,7 +222,7 @@ type CodegenOptions = {
198
222
  */
199
223
  gitignore?: boolean
200
224
  /**
201
- * Whether to generate disabled shorthand properties
225
+ * Whether to allow shorthand properties
202
226
  * @default 'true'
203
227
  */
204
228
  shorthands?: boolean
package/dist/index.d.ts CHANGED
@@ -14,7 +14,7 @@ export type { ConfigResultWithHooks, PandaHooks, PandaHookable } from './hooks'
14
14
  export type { ParserResultType, ResultItem } from './parser'
15
15
  export type { Part, Parts } from './parts'
16
16
  export type { PatternConfig, PatternHelpers, PatternProperty } from './pattern'
17
- export type { RecipeConfig, RecipeVariantRecord } from './recipe'
17
+ export type { RecipeConfig, RecipeVariantRecord, SlotRecipeConfig, SlotRecipeVariantRecord } from './recipe'
18
18
  export type { Runtime } from './runtime'
19
19
  export type { AnyFunction, Artifact, Dict, RequiredBy } from './shared'
20
20
  export type { StaticCssOptions } from './static-css'
package/dist/parser.d.ts CHANGED
@@ -3,7 +3,7 @@ import type { BoxNodeMap, BoxNodeLiteral, Unboxed } from '@pandacss/extractor'
3
3
  export type ResultItem = {
4
4
  name?: string
5
5
  data: Array<Unboxed['raw']>
6
- type?: 'object' | 'cva' | 'pattern' | 'recipe' | 'jsx-factory' | 'jsx-pattern' | 'jsx-recipe' | 'jsx'
6
+ type?: 'object' | 'cva' | 'sva' | 'pattern' | 'recipe' | 'jsx-factory' | 'jsx-pattern' | 'jsx-recipe' | 'jsx'
7
7
  box: BoxNodeMap | BoxNodeLiteral
8
8
  }
9
9
 
@@ -11,10 +11,12 @@ export type ParserResultType = {
11
11
  jsx: Set<ResultItem>
12
12
  css: Set<ResultItem>
13
13
  cva: Set<ResultItem>
14
+ sva: Set<ResultItem>
14
15
  recipe: Map<string, Set<ResultItem>>
15
16
  pattern: Map<string, Set<ResultItem>>
16
17
  filePath: string | undefined
17
18
  set: (name: 'cva' | 'css', result: ResultItem) => void
19
+ setSva: (result: ResultItem) => void
18
20
  setCva: (result: ResultItem) => void
19
21
  setJsx: (result: ResultItem) => void
20
22
  setRecipe: (name: string, result: ResultItem) => void
@@ -23,6 +25,7 @@ export type ParserResultType = {
23
25
  setFilePath: (filePath: string) => ParserResultType
24
26
  toArray: () => Array<ResultItem>
25
27
  toJSON: () => {
28
+ sva: Array<ResultItem>
26
29
  css: Array<ResultItem>
27
30
  cva: Array<ResultItem>
28
31
  recipe: Record<string, ResultItem[]>
package/dist/recipe.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { SystemStyleObject } from './system-types'
2
2
 
3
- type Pretty<T> = T extends infer U ? { [K in keyof U]: U[K] } : never
3
+ type Pretty<T> = { [K in keyof T]: T[K] } & {}
4
4
 
5
5
  type StringToBoolean<T> = T extends 'true' | 'false' ? boolean : T
6
6
 
@@ -14,12 +14,18 @@ export type RecipeSelection<T extends RecipeVariantRecord> = keyof any extends k
14
14
 
15
15
  export type RecipeVariantFn<T extends RecipeVariantRecord> = (props?: RecipeSelection<T>) => string
16
16
 
17
- export type RecipeVariantProps<T extends RecipeVariantFn<RecipeVariantRecord>> = Pretty<Parameters<T>[0]>
17
+ export type RecipeVariantProps<
18
+ T extends RecipeVariantFn<RecipeVariantRecord> | SlotRecipeVariantFn<string, SlotRecipeVariantRecord<string>>,
19
+ > = Pretty<Parameters<T>[0]>
18
20
 
19
21
  type RecipeVariantMap<T extends RecipeVariantRecord> = {
20
22
  [K in keyof T]: Array<keyof T[K]>
21
23
  }
22
24
 
25
+ /* -----------------------------------------------------------------------------
26
+ * Recipe / Standard
27
+ * -----------------------------------------------------------------------------*/
28
+
23
29
  export type RecipeRuntimeFn<T extends RecipeVariantRecord> = RecipeVariantFn<T> & {
24
30
  __type: RecipeSelection<T>
25
31
  variantKeys: (keyof T)[]
@@ -58,7 +64,7 @@ export type RecipeDefinition<T extends RecipeVariantRecord> = {
58
64
 
59
65
  export type RecipeCreatorFn = <T extends RecipeVariantRecord>(config: RecipeDefinition<T>) => RecipeRuntimeFn<T>
60
66
 
61
- export type RecipeConfig<T extends RecipeVariantRecord = RecipeVariantRecord> = RecipeDefinition<T> & {
67
+ type RecipeConfigMeta = {
62
68
  /**
63
69
  * The name of the recipe.
64
70
  */
@@ -75,3 +81,59 @@ export type RecipeConfig<T extends RecipeVariantRecord = RecipeVariantRecord> =
75
81
  */
76
82
  jsx?: Array<string | RegExp>
77
83
  }
84
+
85
+ export type RecipeConfig<T extends RecipeVariantRecord = RecipeVariantRecord> = RecipeDefinition<T> & RecipeConfigMeta
86
+
87
+ /* -----------------------------------------------------------------------------
88
+ * Recipe / Slot
89
+ * -----------------------------------------------------------------------------*/
90
+
91
+ type SlotRecord<S extends string, T> = Partial<Record<S, T>>
92
+
93
+ export type SlotRecipeVariantRecord<S extends string> = Record<any, Record<any, SlotRecord<S, SystemStyleObject>>>
94
+
95
+ export type SlotRecipeVariantFn<S extends string, T extends RecipeVariantRecord> = (
96
+ props?: RecipeSelection<T>,
97
+ ) => SlotRecord<S, string>
98
+
99
+ export type SlotRecipeRuntimeFn<S extends string, T extends SlotRecipeVariantRecord<S>> = SlotRecipeVariantFn<S, T> & {
100
+ variantKeys: (keyof T)[]
101
+ variantMap: RecipeVariantMap<T>
102
+ splitVariantProps<Props extends RecipeSelection<T>>(props: Props): [RecipeSelection<T>, Pretty<Omit<Props, keyof T>>]
103
+ }
104
+
105
+ export type SlotRecipeCompoundVariant<S extends string, T extends RecipeVariantRecord> = RecipeCompoundSelection<T> & {
106
+ css: SlotRecord<S, SystemStyleObject>
107
+ }
108
+
109
+ export type SlotRecipeDefinition<S extends string, T extends SlotRecipeVariantRecord<S>> = {
110
+ /**
111
+ * The parts/slots of the recipe.
112
+ */
113
+ slots: S[] | Readonly<S[]>
114
+ /**
115
+ * The base styles of the recipe.
116
+ */
117
+ base?: SlotRecord<S, SystemStyleObject>
118
+ /**
119
+ * The multi-variant styles of the recipe.
120
+ */
121
+ variants?: T | SlotRecipeVariantRecord<S>
122
+ /**
123
+ * The default variants of the recipe.
124
+ */
125
+ defaultVariants?: RecipeSelection<T>
126
+ /**
127
+ * The styles to apply when a combination of variants is selected.
128
+ */
129
+ compoundVariants?: Array<SlotRecipeCompoundVariant<S, T>>
130
+ }
131
+
132
+ export type SlotRecipeCreatorFn = <S extends string, T extends SlotRecipeVariantRecord<S>>(
133
+ config: SlotRecipeDefinition<S, T>,
134
+ ) => SlotRecipeRuntimeFn<S, T>
135
+
136
+ export type SlotRecipeConfig<
137
+ S extends string = string,
138
+ T extends SlotRecipeVariantRecord<S> = SlotRecipeVariantRecord<S>,
139
+ > = SlotRecipeDefinition<S, T> & RecipeConfigMeta
@@ -50,11 +50,10 @@ export type CompositionStyleObject<Property extends string> = Nested<{
50
50
  /* -----------------------------------------------------------------------------
51
51
  * Jsx style props
52
52
  * -----------------------------------------------------------------------------*/
53
+ type WithCss = { css?: SystemStyleObject }
54
+ type StyleProps = SystemProperties & MinimalNested<SystemStyleObject>
53
55
 
54
- export type JsxStyleProps = SystemProperties &
55
- MinimalNested<SystemStyleObject> & {
56
- css?: SystemStyleObject
57
- }
56
+ export type JsxStyleProps = StyleProps & WithCss
58
57
 
59
58
  export type Assign<T, U> = Omit<T, keyof U> & U
60
59
 
package/dist/theme.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { LayerStyles, TextStyles } from './composition'
2
- import type { RecipeConfig } from './recipe'
2
+ import type { RecipeConfig, SlotRecipeConfig } from './recipe'
3
3
  import type { CssKeyframes } from './system-types'
4
4
  import type { SemanticTokens, Tokens } from './tokens'
5
5
 
@@ -33,4 +33,8 @@ export type Theme = {
33
33
  * Useful for defining component styles.
34
34
  */
35
35
  recipes?: Record<string, RecipeConfig>
36
+ /**
37
+ * Multi-variant style definitions for component slots.
38
+ */
39
+ slotRecipes?: Record<string, SlotRecipeConfig>
36
40
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pandacss/types",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "description": "The types for css panda",
5
5
  "main": "dist/index.d.ts",
6
6
  "author": "Segun Adebayo <joseshegs@gmail.com>",
@@ -15,9 +15,10 @@
15
15
  "chokidar-cli": "^3.0.0",
16
16
  "csstype": "3.1.2",
17
17
  "hookable": "5.5.3",
18
+ "ncp": "^2.0.0",
18
19
  "pkg-types": "1.0.3",
19
- "@pandacss/extractor": "0.9.0",
20
- "@pandacss/token-dictionary": "0.9.0"
20
+ "@pandacss/extractor": "0.10.0",
21
+ "@pandacss/token-dictionary": "0.10.0"
21
22
  },
22
23
  "scripts": {
23
24
  "build": "tsx scripts/build.ts",