@pandacss/types 0.0.0-dev-20230109100037 → 0.0.0-dev-20230110150257

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.
@@ -1,7 +1,5 @@
1
+ import type { Recursive } from './shared'
1
2
  import type { CompositionStyleObject } from './system-types'
2
- import type { LiteralUnion, Recursive } from './shared'
3
-
4
- type Cond = Record<string, string>
5
3
 
6
4
  export type Token<Value = any> = {
7
5
  value: Value
@@ -12,7 +10,7 @@ export type Token<Value = any> = {
12
10
  * Text styles
13
11
  * -----------------------------------------------------------------------------*/
14
12
 
15
- type TextStyleProperty = LiteralUnion<
13
+ type TextStyleProperty =
16
14
  | 'fontSize'
17
15
  | 'fontSizeAdjust'
18
16
  | 'fontVariationSettings'
@@ -41,11 +39,10 @@ type TextStyleProperty = LiteralUnion<
41
39
  | 'textOrientation'
42
40
  | 'textOverflow'
43
41
  | 'textRendering'
44
- >
45
42
 
46
- export type TextStyle<Conditions extends Cond = {}> = CompositionStyleObject<Conditions, TextStyleProperty>
43
+ export type TextStyle = CompositionStyleObject<TextStyleProperty>
47
44
 
48
- export type TextStyles<T extends Cond = {}> = Recursive<Token<TextStyle<T>>>
45
+ export type TextStyles = Recursive<Token<TextStyle>>
49
46
 
50
47
  /* -----------------------------------------------------------------------------
51
48
  * Layer styles
@@ -69,7 +66,7 @@ type Radius =
69
66
  | `Start${'Start' | 'End'}`
70
67
  | `End${'Start' | 'End'}`
71
68
 
72
- type LayerStyleProperty = LiteralUnion<
69
+ type LayerStyleProperty =
73
70
  | 'background'
74
71
  | 'backgroundColor'
75
72
  | 'backgroundImage'
@@ -98,7 +95,12 @@ type LayerStyleProperty = LiteralUnion<
98
95
  | `border${Placement}Style`
99
96
  | 'padding'
100
97
  | `padding${Placement}`
101
- >
102
98
 
103
- export type LayerStyle<Conditions extends Cond = {}> = CompositionStyleObject<Conditions, LayerStyleProperty>
104
- export type LayerStyles<Conditions extends Cond = {}> = Recursive<Token<LayerStyle<Conditions>>>
99
+ export type LayerStyle = CompositionStyleObject<LayerStyleProperty>
100
+
101
+ export type LayerStyles = Recursive<Token<LayerStyle>>
102
+
103
+ export type CompositionStyles = {
104
+ textStyles: TextStyles
105
+ layerStyles: LayerStyles
106
+ }
@@ -1,3 +1,4 @@
1
+ import type { AnySelector, Selectors } from './selectors'
1
2
  import type { Dict, StringKeyOf } from './shared'
2
3
 
3
4
  export type ConditionType = 'at-rule' | 'parent-nesting' | 'self-nesting' | 'combinator-nesting'
@@ -11,15 +12,36 @@ export type ConditionDetails = {
11
12
 
12
13
  export type RawCondition = ConditionDetails & { raw: string }
13
14
 
15
+ export type ExtractConditions<Conditions extends Dict, Breakpoints extends Dict> =
16
+ | StringKeyOf<Breakpoints>
17
+ | StringKeyOf<Conditions>
18
+ | 'base'
19
+
20
+ /* -----------------------------------------------------------------------------
21
+ * Shadowed export (in CLI): DO NOT REMOVE
22
+ * -----------------------------------------------------------------------------*/
23
+
14
24
  export type Conditions = {
15
25
  [condition: string]: string
16
26
  }
17
27
 
18
- export type RecursiveCondition<T extends string, C extends string> =
19
- | T
20
- | { [K in C]?: RecursiveCondition<T, Exclude<C, K>> }
28
+ export type Condition = string
21
29
 
22
- export type ExtractConditions<Conditions extends Dict, Breakpoints extends Dict> =
23
- | StringKeyOf<Breakpoints>
24
- | StringKeyOf<Conditions>
25
- | 'base'
30
+ export type Conditional<V> =
31
+ | V
32
+ | Array<V | null>
33
+ | {
34
+ [K in keyof Conditions]?: Conditional<V>
35
+ }
36
+
37
+ export type ConditionalValue<T> = Conditional<T>
38
+
39
+ export type Nested<P> =
40
+ | (P & {
41
+ [K in Selectors]?: Nested<P>
42
+ } & {
43
+ [K in AnySelector]?: Nested<P>
44
+ })
45
+ | {
46
+ [K in Condition]?: Nested<P>
47
+ }
package/dist/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- export type { ConditionDetails, ConditionType, Conditions, RawCondition, RecursiveCondition } from './conditions'
1
+ export type { ConditionDetails, ConditionType, Conditions, RawCondition } from './conditions'
2
2
  export type { Config, UserConfig } from './config'
3
3
  export type { PropertyConfig, PropertyTransform, PropertyValues, UtilityConfig } from './utility'
4
- export type { StyleObject, CssKeyframes } from './system-types'
4
+ export type { SystemStyleObject, CssKeyframes } from './system-types'
5
5
  export type { PatternConfig, PatternProperty, PatternHelpers } from './pattern'
6
6
  export type { RecipeConfig, RecipeVariant } from './recipe'
7
- export type { TextStyles, LayerStyles } from './composition'
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'
10
10
  export type { Parts, Part } from './parts'
package/dist/pattern.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { NativeCssProperty, StyleObject } from './system-types'
1
+ import type { NativeCssProperty, SystemStyleObject } from './system-types'
2
2
  import type { TokenCategory } from './tokens'
3
3
 
4
4
  export type PatternProperty =
@@ -23,7 +23,7 @@ export type PatternConfig = {
23
23
  /**
24
24
  * The css object this pattern will generate.
25
25
  */
26
- transform?: (props: Record<string, any>, helpers: PatternHelpers) => StyleObject
26
+ transform?: (props: Record<string, any>, helpers: PatternHelpers) => SystemStyleObject
27
27
  /**
28
28
  * The jsx element name this pattern will generate.
29
29
  */
@@ -33,4 +33,9 @@ export type PatternConfig = {
33
33
  * This will disallow css properties
34
34
  */
35
35
  strict?: boolean
36
+ /**
37
+ * @experimental
38
+ * Disallow certain css properties for this pattern
39
+ */
40
+ blocklist?: NativeCssProperty[]
36
41
  }
@@ -0,0 +1,14 @@
1
+ import type { ConditionalValue } from './conditions'
2
+ import type { Properties as CSSProperties } from './csstype'
3
+
4
+ /* -----------------------------------------------------------------------------
5
+ * Shadowed export (in CLI): DO NOT REMOVE
6
+ * -----------------------------------------------------------------------------*/
7
+
8
+ export type PropertyTypes = {}
9
+
10
+ export type PropertyValue<K extends string> = K extends keyof PropertyTypes
11
+ ? ConditionalValue<PropertyTypes[K]>
12
+ : K extends keyof CSSProperties
13
+ ? ConditionalValue<CSSProperties[K]>
14
+ : never
package/dist/recipe.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import type { StyleObject } from './system-types'
1
+ import type { SystemStyleObject } from './system-types'
2
2
 
3
3
  export type RecipeVariant = {
4
- [variant: string]: StyleObject
4
+ [variant: string]: SystemStyleObject
5
5
  }
6
6
 
7
7
  type TVariants = Record<string, RecipeVariant>
@@ -18,7 +18,7 @@ export type RecipeConfig<Variants extends TVariants = TVariants> = {
18
18
  /**
19
19
  * The base styles of the recipe.
20
20
  */
21
- base?: StyleObject
21
+ base?: SystemStyleObject
22
22
  /**
23
23
  * The multi-variant styles of the recipe.
24
24
  */
@@ -0,0 +1,56 @@
1
+ import type { Pseudos } from './csstype'
2
+
3
+ type AriaAttributes =
4
+ | '[aria-disabled]'
5
+ | '[aria-hidden]'
6
+ | '[aria-invalid]'
7
+ | '[aria-readonly]'
8
+ | '[aria-required]'
9
+ | '[aria-selected]'
10
+ | '[aria-checked]'
11
+ | '[aria-expanded]'
12
+ | '[aria-pressed]'
13
+ | `[aria-current=${'page' | 'step' | 'location' | 'date' | 'time'}]`
14
+ | '[aria-invalid]'
15
+ | `[aria-sort=${'ascending' | 'descending'}]`
16
+
17
+ type DataAttributes =
18
+ | '[data-selected]'
19
+ | '[data-highlighted]'
20
+ | '[data-hover]'
21
+ | '[data-active]'
22
+ | '[data-checked]'
23
+ | '[data-disabled]'
24
+ | '[data-readonly]'
25
+ | '[data-focus]'
26
+ | '[data-focus-visible]'
27
+ | '[data-focus-visible-added]'
28
+ | '[data-invalid]'
29
+ | '[data-pressed]'
30
+ | '[data-expanded]'
31
+ | '[data-grabbed]'
32
+ | '[data-dragged]'
33
+ | '[data-orientation=horizontal]'
34
+ | '[data-orientation=vertical]'
35
+ | '[data-in-range]'
36
+ | '[data-out-of-range]'
37
+ | '[data-placeholder-shown]'
38
+ | `[data-part=${string}]`
39
+ | `[data-attr=${string}]`
40
+ | `[data-placement=${string}]`
41
+ | `[data-theme=${string}]`
42
+ | `[data-size=${string}]`
43
+ | `[data-state=${string}]`
44
+ | '[data-empty]'
45
+ | '[data-loading]'
46
+ | '[data-loaded]'
47
+ | '[data-enter]'
48
+ | '[data-entering]'
49
+ | '[data-exited]'
50
+ | '[data-exiting]'
51
+
52
+ type AttributeSelector = `&${Pseudos | DataAttributes | AriaAttributes}`
53
+ type ParentSelector = `${DataAttributes | AriaAttributes} &`
54
+
55
+ export type AnySelector = `${string}&` | `&${string}`
56
+ export type Selectors = AttributeSelector | ParentSelector
@@ -0,0 +1,15 @@
1
+ import type { PropertiesFallback } from './csstype'
2
+ import type { PropertyValue } from './prop-type'
3
+
4
+ type String = string & {}
5
+ type Number = number & {}
6
+
7
+ /* -----------------------------------------------------------------------------
8
+ * Shadowed export (in CLI): DO NOT REMOVE
9
+ * -----------------------------------------------------------------------------*/
10
+
11
+ type CssProperties = PropertiesFallback<String | Number>
12
+
13
+ export type SystemProperties = {
14
+ [K in keyof CssProperties]?: PropertyValue<K>
15
+ }
@@ -1,64 +1,10 @@
1
- import type * as CSS from './csstype'
1
+ import type { Conditional, ConditionalValue, Conditions, Nested } from './conditions'
2
+ import type { PropertiesFallback } from './csstype'
3
+ import type { SystemProperties } from './style-props'
2
4
 
3
- type Dict = Record<string, unknown>
4
5
  type String = string & {}
5
6
  type Number = number & {}
6
7
 
7
- type AriaAttributes =
8
- | '[aria-disabled]'
9
- | '[aria-hidden]'
10
- | '[aria-invalid]'
11
- | '[aria-readonly]'
12
- | '[aria-required]'
13
- | '[aria-selected]'
14
- | '[aria-checked]'
15
- | '[aria-expanded]'
16
- | '[aria-pressed]'
17
- | `[aria-current=${'page' | 'step' | 'location' | 'date' | 'time'}]`
18
- | '[aria-invalid]'
19
- | `[aria-sort=${'ascending' | 'descending'}]`
20
-
21
- type DataAttributes =
22
- | '[data-selected]'
23
- | '[data-highlighted]'
24
- | '[data-hover]'
25
- | '[data-active]'
26
- | '[data-checked]'
27
- | '[data-disabled]'
28
- | '[data-readonly]'
29
- | '[data-focus]'
30
- | '[data-focus-visible]'
31
- | '[data-focus-visible-added]'
32
- | '[data-invalid]'
33
- | '[data-pressed]'
34
- | '[data-expanded]'
35
- | '[data-grabbed]'
36
- | '[data-dragged]'
37
- | '[data-orientation=horizontal]'
38
- | '[data-orientation=vertical]'
39
- | '[data-in-range]'
40
- | '[data-out-of-range]'
41
- | '[data-placeholder-shown]'
42
- | `[data-part=${string}]`
43
- | `[data-attr=${string}]`
44
- | `[data-placement=${string}]`
45
- | `[data-theme=${string}]`
46
- | `[data-size=${string}]`
47
- | `[data-state=${string}]`
48
- | '[data-empty]'
49
- | '[data-loading]'
50
- | '[data-loaded]'
51
- | '[data-enter]'
52
- | '[data-entering]'
53
- | '[data-exited]'
54
- | '[data-exiting]'
55
-
56
- type AttributeSelector = `&${CSS.Pseudos | DataAttributes | AriaAttributes}`
57
- type ParentSelector = `${DataAttributes | AriaAttributes} &`
58
- type AnySelector = `${string}&` | `&${string}`
59
-
60
- type Selectors = AttributeSelector | ParentSelector
61
-
62
8
  type ContainerProperties = {
63
9
  container?: string
64
10
  containerType?: 'size' | 'inline-size' | String
@@ -73,7 +19,7 @@ type CssVarProperties = {
73
19
  [key in `--${string}`]?: string | number
74
20
  }
75
21
 
76
- export type NativeCssProperties = CSS.PropertiesFallback<String | Number> & ContainerProperties & CssVarProperties
22
+ export type NativeCssProperties = PropertiesFallback<String | Number> & ContainerProperties
77
23
 
78
24
  export type NativeCssProperty = keyof NativeCssProperties
79
25
 
@@ -89,102 +35,36 @@ export type CssKeyframes = {
89
35
  * Conditional css properties
90
36
  * -----------------------------------------------------------------------------*/
91
37
 
92
- type Cond = Record<string, string>
93
-
94
- export type Conditional<C extends Cond, V> =
95
- | V
96
- | Array<V | null>
97
- | {
98
- [K in keyof C]?: Conditional<C, V>
99
- }
100
-
101
- type Nested<C extends Cond, P> = P & {
102
- [K in Selectors | keyof C]?: Nested<C, P>
103
- } & {
104
- [K in AnySelector]?: Nested<C, P>
38
+ type MinimalNested<P> = {
39
+ [K in keyof Conditions]?: Nested<P>
105
40
  }
106
41
 
107
- type MinimalNested<C extends Cond, P> = P & {
108
- [K in keyof C]?: Nested<C, P>
42
+ type GenericProperties = {
43
+ [key: string]: ConditionalValue<String | Number | boolean>
109
44
  }
110
45
 
111
46
  /* -----------------------------------------------------------------------------
112
- * Mixed css properties (native + conditional + custom properties)
113
-
114
- C - condition record
115
- P - custom properties or utilities
116
- S - strict mode? true or false
47
+ * Native css props
117
48
  * -----------------------------------------------------------------------------*/
118
49
 
119
- type NativeCssValue<T> = T extends NativeCssProperty ? NativeCssProperties[T] : never
120
-
121
- type NativeProperties<Conditions extends Cond, PropTypes extends Dict, Overrides extends Dict> = {
122
- [K in Exclude<NativeCssProperty, keyof PropTypes | keyof Overrides>]?: Conditional<Conditions, NativeCssProperties[K]>
123
- }
50
+ export type NestedCssProperties = Nested<CssProperties>
124
51
 
125
- type CustomProperties<
126
- Conditions extends Cond,
127
- PropTypes extends Dict,
128
- StrictMode extends boolean,
129
- Overrides extends Dict,
130
- > = {
131
- [K in Exclude<keyof PropTypes, keyof Overrides>]?: Conditional<
132
- Conditions,
133
- true extends StrictMode ? PropTypes[K] : PropTypes[K] | NativeCssValue<K>
134
- >
135
- }
52
+ export type SystemStyleObject = Nested<SystemProperties | GenericProperties>
136
53
 
137
- type GenericProperties<Conditions extends Cond> = {
138
- [key: string]: Conditional<Conditions, boolean | String | Number | undefined>
54
+ export type GlobalStyleObject = {
55
+ [selector: string]: SystemStyleObject
139
56
  }
140
57
 
141
- type MinimalCss<Conditions extends Cond, PropTypes extends Dict, StrictMode extends boolean, Overrides extends Dict> =
142
- | Partial<Overrides> &
143
- NativeProperties<Conditions, PropTypes, Overrides> &
144
- CustomProperties<Conditions, PropTypes, StrictMode, Overrides>
145
-
146
- type Css<Conditions extends Cond, PropTypes extends Dict, StrictMode extends boolean, Overrides extends Dict> =
147
- | MinimalCss<Conditions, PropTypes, StrictMode, Overrides>
148
- | GenericProperties<Conditions>
58
+ export type CompositionStyleObject<Property extends string> = Nested<{
59
+ [K in Property]?: Conditional<K extends NativeCssProperty ? NativeCssProperties[K] : unknown>
60
+ }>
149
61
 
150
62
  /* -----------------------------------------------------------------------------
151
- * Exported types
63
+ * Jsx style props
152
64
  * -----------------------------------------------------------------------------*/
153
65
 
154
- export type NestedCssProperties = Nested<{}, CssProperties>
155
-
156
- export type StyleObject<
157
- Conditions extends Cond = {},
158
- PropTypes extends Dict = {},
159
- StrictMode extends boolean = false,
160
- Overrides extends Dict = {},
161
- > = Nested<Conditions, Css<Conditions, PropTypes, StrictMode, Overrides>>
162
-
163
- export type JsxStyleProps<
164
- Conditions extends Cond = {},
165
- PropTypes extends Dict = {},
166
- StrictMode extends boolean = false,
167
- Overrides extends Dict = {},
168
- > = MinimalNested<Conditions, MinimalCss<Conditions, PropTypes, StrictMode, Overrides>> & {
169
- css?: StyleObject<Conditions, PropTypes, StrictMode, Overrides>
170
- sx?: StyleObject<Conditions, PropTypes, StrictMode, Overrides>
171
- }
172
-
173
- export type GlobalStyleObject<
174
- Conditions extends Cond = {},
175
- PropTypes extends Dict = {},
176
- StrictMode extends boolean = false,
177
- Overrides extends Dict = {},
178
- > = {
179
- [selector: string]: StyleObject<Conditions, PropTypes, StrictMode, Overrides>
180
- }
181
-
182
- export type CompositionStyleObject<Conditions extends Cond, PropTypes> = Nested<
183
- Conditions,
184
- {
185
- [K in Extract<PropTypes, string>]?: Conditional<
186
- Conditions,
187
- K extends NativeCssProperty ? NativeCssProperties[K] : unknown
188
- >
66
+ export type JsxStyleProps = SystemProperties &
67
+ MinimalNested<SystemStyleObject> & {
68
+ css?: SystemStyleObject
69
+ sx?: SystemStyleObject
189
70
  }
190
- >
package/dist/tokens.d.ts CHANGED
@@ -24,10 +24,22 @@ export type SemanticToken<Value = string, Condition extends string = string> = T
24
24
  * Token data types
25
25
  * -----------------------------------------------------------------------------*/
26
26
 
27
+ type BorderStyle =
28
+ | 'dashed'
29
+ | 'dotted'
30
+ | 'double'
31
+ | 'groove'
32
+ | 'hidden'
33
+ | 'inset'
34
+ | 'none'
35
+ | 'outset'
36
+ | 'ridge'
37
+ | 'solid'
38
+
27
39
  type Border = {
28
40
  color: string
29
41
  width: string | number
30
- style: string
42
+ style: BorderStyle
31
43
  }
32
44
 
33
45
  type Shadow = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pandacss/types",
3
- "version": "0.0.0-dev-20230109100037",
3
+ "version": "0.0.0-dev-20230110150257",
4
4
  "description": "The types for css panda",
5
5
  "main": "dist/index.d.ts",
6
6
  "author": "Segun Adebayo <joseshegs@gmail.com>",