@pandacss/types 0.0.0-dev-20230119005608 → 0.0.0-dev-20230119102953

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/index.d.ts CHANGED
@@ -3,7 +3,7 @@ export type { Config, UserConfig } from './config'
3
3
  export type { PropertyConfig, PropertyTransform, PropertyValues, UtilityConfig } from './utility'
4
4
  export type { SystemStyleObject, CssKeyframes, GlobalStyleObject } from './system-types'
5
5
  export type { PatternConfig, PatternProperty, PatternHelpers } from './pattern'
6
- export type { RecipeConfig, RecipeVariant } from './recipe'
6
+ export type { RecipeConfig, RecipeVariantRecord } from './recipe'
7
7
  export type { TextStyles, LayerStyles, CompositionStyles } from './composition'
8
8
  export type { Token, TokenCategory, TokenDataTypes, Tokens, SemanticToken, SemanticTokens } from './tokens'
9
9
  export type { Dict, RequiredBy, AnyFunction } from './shared'
package/dist/recipe.d.ts CHANGED
@@ -1,20 +1,24 @@
1
1
  import type { SystemStyleObject } from './system-types'
2
2
 
3
- export type RecipeVariant = {
4
- [variant: string]: SystemStyleObject
3
+ type StringToBoolean<T> = T extends 'true' | 'false' ? boolean : T
4
+
5
+ export type RecipeVariantRecord = Record<string, Record<string, SystemStyleObject>>
6
+
7
+ export type RecipeSelection<T extends RecipeVariantRecord> = {
8
+ [K in keyof T]?: StringToBoolean<keyof T[K]>
5
9
  }
6
10
 
7
- type TVariants = Record<string, RecipeVariant>
11
+ export type RecipeVariantFn<T extends RecipeVariantRecord> = (props?: RecipeSelection<T>) => string
8
12
 
9
- export type RecipeConfig<Variants extends TVariants = TVariants> = {
10
- /**
11
- * The name of the recipe.
12
- */
13
- name: string
14
- /**
15
- * The jsx elements to track for this recipe.
16
- */
17
- jsx?: string
13
+ export type RecipeVariantProps<T extends RecipeVariantFn<RecipeVariantRecord>> = Parameters<T>[0]
14
+
15
+ export type RecipeRuntimeFn<T extends RecipeVariantRecord> = RecipeVariantFn<T> & {
16
+ variants: (keyof T)[]
17
+ resolve: (props: RecipeSelection<T>) => SystemStyleObject
18
+ config: RecipeConfig<T>
19
+ }
20
+
21
+ export type RecipeDefinition<T extends RecipeVariantRecord> = {
18
22
  /**
19
23
  * The base styles of the recipe.
20
24
  */
@@ -22,15 +26,26 @@ export type RecipeConfig<Variants extends TVariants = TVariants> = {
22
26
  /**
23
27
  * The multi-variant styles of the recipe.
24
28
  */
25
- variants?: Variants
29
+ variants?: T | RecipeVariantRecord
26
30
  /**
27
31
  * The default variants of the recipe.
28
32
  */
29
- defaultVariants?: {
30
- [K in keyof Variants]?: keyof Variants[K]
31
- }
33
+ defaultVariants?: RecipeSelection<T>
34
+ }
35
+
36
+ export type RecipeCreatorFn = <T extends RecipeVariantRecord>(config: RecipeDefinition<T>) => RecipeRuntimeFn<T>
37
+
38
+ export type RecipeConfig<T extends RecipeVariantRecord = RecipeVariantRecord> = RecipeDefinition<T> & {
39
+ /**
40
+ * The name of the recipe.
41
+ */
42
+ name: string
32
43
  /**
33
44
  * The description of the recipe. This will be used in the JSDoc comment.
34
45
  */
35
46
  description?: string
47
+ /**
48
+ * The jsx elements to track for this recipe.
49
+ */
50
+ jsx?: string
36
51
  }
@@ -66,5 +66,4 @@ export type CompositionStyleObject<Property extends string> = Nested<{
66
66
  export type JsxStyleProps = SystemProperties &
67
67
  MinimalNested<SystemStyleObject> & {
68
68
  css?: SystemStyleObject
69
- sx?: SystemStyleObject
70
69
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pandacss/types",
3
- "version": "0.0.0-dev-20230119005608",
3
+ "version": "0.0.0-dev-20230119102953",
4
4
  "description": "The types for css panda",
5
5
  "main": "dist/index.d.ts",
6
6
  "author": "Segun Adebayo <joseshegs@gmail.com>",