@pandacss/types 0.0.0-dev-20221121152823

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.
@@ -0,0 +1,39 @@
1
+ interface UtilityProperties {
2
+ /**
3
+ * The css properties to generate utilities for.
4
+ * @example ['margin', 'padding']
5
+ */
6
+ properties: string[]
7
+ /**
8
+ * The css conditions to generate utilities for.
9
+ * @example ['hover', 'focus']
10
+ */
11
+ conditions?: string[]
12
+ /**
13
+ * The values to generate utilities for.
14
+ * @example ['2', '40px']
15
+ */
16
+ values?: string[]
17
+ }
18
+
19
+ interface RecipeProperties {
20
+ conditions: string[]
21
+ [variant: string]: string[]
22
+ }
23
+
24
+ export type ClassGeneratorOptions = {
25
+ /**
26
+ * The output path for the generated css file.
27
+ */
28
+ outfile?: string
29
+ /**
30
+ * The css utility classes to generate.
31
+ */
32
+ css?: UtilityProperties[]
33
+ /**
34
+ * The css recipes to generate.
35
+ */
36
+ recipes?: {
37
+ [recipe: string]: RecipeProperties[]
38
+ }
39
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ export type * from './conditions'
2
+ export type * from './config'
3
+ export type * from './utility'
4
+ export type * from './panda-csstype'
5
+ export type * from './pattern'
6
+ export type * from './recipe'
7
+ export type * from './composition'
8
+ export type * from './tokens'
9
+ export type * from './shared'
@@ -0,0 +1,95 @@
1
+ import type { PropertiesFallback, SimplePseudos } from './csstype'
2
+
3
+ type Loose<T = string> = T & { __type?: never }
4
+
5
+ type ContainerProperties = {
6
+ container?: string
7
+ containerType?: 'size' | 'inline-size' | Loose
8
+ containerName?: string
9
+ }
10
+
11
+ export type Properties = PropertiesFallback<Loose<string> | Loose<number>> & ContainerProperties
12
+
13
+ export type CssProperty = keyof Properties
14
+
15
+ type Pseudo = `&${SimplePseudos}`
16
+
17
+ export type CssProperties = Properties & {
18
+ [property: string]: string | number | Record<string, any> | undefined
19
+ }
20
+
21
+ export type Keyframes = {
22
+ [time: string]: CssProperties
23
+ }
24
+
25
+ type TCondition = Record<string, string>
26
+
27
+ export type PandaConditionalValue<Condition extends TCondition, Value> =
28
+ | Value
29
+ | {
30
+ [Key in keyof Condition]?: PandaConditionalValue<Condition, Value>
31
+ }
32
+
33
+ type NeverType = { __type?: 'never' }
34
+
35
+ type Union<
36
+ Key extends string,
37
+ CssProperties extends Record<Key, any>,
38
+ UserProperties,
39
+ > = UserProperties extends NeverType
40
+ ? CssProperties[Key] | Loose
41
+ : Key extends keyof UserProperties
42
+ ? CssProperties[Key] | UserProperties[Key]
43
+ : CssProperties[Key]
44
+
45
+ type Strict<
46
+ Key extends string,
47
+ CssProperties extends Record<Key, any>,
48
+ UserProperties,
49
+ > = Key extends keyof UserProperties ? UserProperties[Key] : CssProperties[Key]
50
+
51
+ export type ConditionCssProperties<
52
+ Conditions extends TCondition = TCondition,
53
+ UserProperties extends Record<string, any> = NeverType,
54
+ StrictValue extends boolean = false,
55
+ > = {
56
+ [Key in keyof Properties]?: PandaConditionalValue<
57
+ Conditions,
58
+ true extends StrictValue ? Strict<Key, Properties, UserProperties> : Union<Key, Properties, UserProperties>
59
+ >
60
+ } & {
61
+ [Key in keyof Omit<UserProperties, keyof Properties>]?: PandaConditionalValue<Conditions, UserProperties[Key]>
62
+ } & {
63
+ [Key in keyof Conditions]?: ConditionCssProperties<Omit<Conditions, Key>, UserProperties, StrictValue>
64
+ }
65
+
66
+ type NestedCss<T> = T & {
67
+ [key in Pseudo | Loose]?: NestedCss<T> | Loose<string> | Loose<number> | boolean
68
+ }
69
+
70
+ export type GroupedCss<T> = {
71
+ selectors?: {
72
+ [key in Pseudo | Loose]?: T
73
+ }
74
+ '@media'?: {
75
+ [query: string]: T
76
+ }
77
+ '@container'?: {
78
+ [query: string]: T
79
+ }
80
+ }
81
+
82
+ export type PandaCssObject<
83
+ Conditions extends TCondition,
84
+ UserProperties extends Record<string, any> = NeverType,
85
+ Strict extends boolean = false,
86
+ > = NestedCss<ConditionCssProperties<Conditions, UserProperties, Strict>> &
87
+ GroupedCss<ConditionCssProperties<Conditions, UserProperties, Strict>>
88
+
89
+ export type GlobalCss<
90
+ Conditions extends TCondition,
91
+ UserProperties extends Record<string, any> = NeverType,
92
+ Strict extends boolean = false,
93
+ > = Record<string, NestedCss<ConditionCssProperties<Conditions, UserProperties, Strict>>>
94
+
95
+ export {}
@@ -0,0 +1,38 @@
1
+ import type { CssProperty, ConditionCssProperties } from './panda-csstype'
2
+ import type { TokenCategory } from './tokens'
3
+
4
+ export type PatternProperty =
5
+ | { type: 'property'; value: CssProperty }
6
+ | { type: 'enum'; value: string[] }
7
+ | { type: 'token'; value: TokenCategory; property?: CssProperty }
8
+ | { type: 'string' | 'boolean' | 'number' }
9
+
10
+ type Value = string | { [key: string]: Value }
11
+
12
+ export type TransformHelpers = {
13
+ map: (value: Value, fn: (value: string) => string | undefined) => any
14
+ }
15
+
16
+ export type PatternConfig = {
17
+ /**
18
+ * The description of the pattern. This will be used in the JSDoc comment.
19
+ */
20
+ description?: string
21
+ /**
22
+ * The properties of the pattern.
23
+ */
24
+ properties: Record<string, PatternProperty>
25
+ /**
26
+ * The css object this pattern will generate.
27
+ */
28
+ transform?: (props: Record<string, Value>, helpers: TransformHelpers) => ConditionCssProperties
29
+ /**
30
+ * The jsx element name this pattern will generate.
31
+ */
32
+ jsx?: string
33
+ /**
34
+ * Whether to only generate types for the specified properties.
35
+ * This will disallow css properties
36
+ */
37
+ strict?: boolean
38
+ }
@@ -0,0 +1,30 @@
1
+ import type { CssProperties, WithNesting } from './panda-csstype'
2
+
3
+ export type RecipeVariant = Record<string, WithNesting<CssProperties>>
4
+
5
+ type TRecipe = Record<string, RecipeVariant>
6
+
7
+ export type RecipeConfig<Variants extends TRecipe = TRecipe> = {
8
+ /**
9
+ * The name of the recipe.
10
+ */
11
+ name: string
12
+ /**
13
+ * The base styles of the recipe.
14
+ */
15
+ base?: WithNesting<CssProperties>
16
+ /**
17
+ * The multi-variant styles of the recipe.
18
+ */
19
+ variants?: Variants
20
+ /**
21
+ * The default variants of the recipe.
22
+ */
23
+ defaultVariants?: {
24
+ [K in keyof Variants]?: keyof Variants[K]
25
+ }
26
+ /**
27
+ * The description of the recipe. This will be used in the JSDoc comment.
28
+ */
29
+ description?: string
30
+ }
@@ -0,0 +1,33 @@
1
+ export type Loose = string & Record<never, never>
2
+
3
+ type Str<T> = T extends number ? `${T}` : T
4
+
5
+ type PathsToStringProps<T> = T extends string
6
+ ? []
7
+ : {
8
+ [Key in Extract<keyof T, string | number>]: [Str<Key>, ...PathsToStringProps<T[Key]>]
9
+ }[Extract<keyof T, string | number>]
10
+
11
+ type Join<Paths extends string[], Delimiter extends string> = Paths extends []
12
+ ? never
13
+ : Paths extends [infer Property]
14
+ ? Property
15
+ : Paths extends [infer Property, ...infer Rest]
16
+ ? Property extends string
17
+ ? `${Property}${Delimiter}${Join<Extract<Rest, string[]>, Delimiter>}`
18
+ : never
19
+ : string
20
+
21
+ type TDotPath = Record<string, any> | string
22
+
23
+ export type DotPath<T extends TDotPath> = Join<PathsToStringProps<T>, '.'>
24
+
25
+ export type Primitive = string | number | boolean | null | undefined
26
+
27
+ export type Entry<T> = [keyof T, T[keyof T]]
28
+
29
+ export type Dict<T = any> = Record<string, T>
30
+
31
+ export type RequiredBy<T, K extends keyof T> = Partial<Omit<T, K>> & Required<Pick<T, K>>
32
+
33
+ export type AnyFunction = (...args: any[]) => any
@@ -0,0 +1,78 @@
1
+ export type TokenStatus = 'deprecated' | 'experimental' | 'new'
2
+
3
+ export type Token<V = any> = {
4
+ value: V
5
+ description?: string
6
+ type?: string
7
+ extensions?: {
8
+ status?: TokenStatus
9
+ [key: string]: any
10
+ }
11
+ }
12
+
13
+ export type SemanticToken<V = string, C extends string = string> = {
14
+ description?: string
15
+ type?: string
16
+ value: V | Record<C, V>
17
+ extensions?: {
18
+ [key: string]: any
19
+ }
20
+ }
21
+
22
+ type Border = {
23
+ color: string
24
+ width: string | number
25
+ style: string
26
+ }
27
+
28
+ type Shadow = {
29
+ offsetX: number
30
+ offsetY: number
31
+ blur: number
32
+ spread: number
33
+ color: string
34
+ inset?: boolean
35
+ }
36
+
37
+ type Gradient = {
38
+ type: 'linear' | 'radial'
39
+ placement: string | number
40
+ stops: Array<{
41
+ color: string
42
+ position: number
43
+ }>
44
+ }
45
+
46
+ type Nested<T> = { [key: string]: T | Nested<T> }
47
+
48
+ export type TokenValues = {
49
+ zIndex: number
50
+ opacity: number
51
+ colors: string
52
+ fonts: string | string[]
53
+ fontSizes: string
54
+ fontWeights: string | number
55
+ lineHeights: string | number
56
+ letterSpacings: string
57
+ sizes: string
58
+ largeSizes: string
59
+ shadows: Shadow | Shadow[] | string | string[]
60
+ spacing: string | number
61
+ radii: string
62
+ borders: string | Border
63
+ durations: string
64
+ easings: string | number[]
65
+ animations: string
66
+ blurs: string
67
+ gradients: string | Gradient
68
+ }
69
+
70
+ export type Tokens = {
71
+ [key in keyof TokenValues]?: Nested<Token<TokenValues[key]>>
72
+ }
73
+
74
+ export type SemanticTokens<C extends string = string> = {
75
+ [key in keyof TokenValues]?: Nested<SemanticToken<TokenValues[key], C>>
76
+ }
77
+
78
+ export type TokenCategory = keyof TokenValues
@@ -0,0 +1,53 @@
1
+ import type { Properties } from './panda-csstype'
2
+
3
+ type ClassNameFn = (value: string, prop: string) => string
4
+
5
+ export type PropertyClassName = string | ClassNameFn
6
+
7
+ type Getter = (path: string) => any
8
+
9
+ type ThemeFn = (token: Getter) => Record<string, string>
10
+
11
+ type CssObject =
12
+ | Properties
13
+ | {
14
+ [selector: string]: string | number | null | undefined | Properties
15
+ }
16
+
17
+ export type PropertyValues = string | string[] | { type: string } | Record<string, string> | ThemeFn
18
+
19
+ export type PropertyTransform<T = CssObject> = (value: any, token: Getter) => T
20
+
21
+ export type PropertyConfig = {
22
+ /**
23
+ * @internal
24
+ * The cascade layer to which the property belongs
25
+ */
26
+ layer?: string
27
+ /**
28
+ * The classname this property will generate.
29
+ */
30
+ className?: string
31
+ /**
32
+ * The css style object this property will generate.
33
+ */
34
+ transform?: PropertyTransform
35
+ /**
36
+ * The possible values this property can have.
37
+ */
38
+ values?: PropertyValues
39
+ /**
40
+ * The css property this utility maps to.
41
+ */
42
+ property?: keyof Properties
43
+ /**
44
+ * The shorthand of the property.
45
+ */
46
+ shorthand?: string
47
+ }
48
+
49
+ export type UtilityConfig = {
50
+ [property in keyof Properties]?: PropertyConfig
51
+ } & {
52
+ [key: string]: PropertyConfig
53
+ }