@pandacss/studio 0.0.0-dev-20230731203720 → 0.0.0-dev-20230801084843
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/package.json +8 -8
- package/styled-system/css/conditions.mjs +2 -2
- package/styled-system/css/index.d.ts +2 -1
- package/styled-system/css/index.mjs +1 -0
- package/styled-system/css/sva.d.ts +4 -0
- package/styled-system/css/sva.mjs +20 -0
- package/styled-system/helpers.mjs +50 -0
- package/styled-system/types/global.d.ts +3 -2
- package/styled-system/types/recipe.d.ts +62 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pandacss/studio",
|
|
3
|
-
"version": "0.0.0-dev-
|
|
3
|
+
"version": "0.0.0-dev-20230801084843",
|
|
4
4
|
"description": "The automated token documentation for Panda CSS",
|
|
5
5
|
"main": "dist/studio.js",
|
|
6
6
|
"module": "dist/studio.mjs",
|
|
@@ -33,19 +33,19 @@
|
|
|
33
33
|
"react": "18.2.0",
|
|
34
34
|
"react-dom": "18.2.0",
|
|
35
35
|
"vite": "4.4.2",
|
|
36
|
-
"@pandacss/types": "0.0.0-dev-
|
|
37
|
-
"@pandacss/config": "0.0.0-dev-
|
|
38
|
-
"@pandacss/shared": "0.0.0-dev-
|
|
39
|
-
"@pandacss/token-dictionary": "0.0.0-dev-
|
|
40
|
-
"@pandacss/logger": "0.0.0-dev-
|
|
41
|
-
"@pandacss/node": "0.0.0-dev-
|
|
36
|
+
"@pandacss/types": "0.0.0-dev-20230801084843",
|
|
37
|
+
"@pandacss/config": "0.0.0-dev-20230801084843",
|
|
38
|
+
"@pandacss/shared": "0.0.0-dev-20230801084843",
|
|
39
|
+
"@pandacss/token-dictionary": "0.0.0-dev-20230801084843",
|
|
40
|
+
"@pandacss/logger": "0.0.0-dev-20230801084843",
|
|
41
|
+
"@pandacss/node": "0.0.0-dev-20230801084843"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@types/react": "18.2.14",
|
|
45
45
|
"@types/react-dom": "18.2.6",
|
|
46
46
|
"@vitejs/plugin-react": "4.0.3",
|
|
47
47
|
"execa": "7.1.1",
|
|
48
|
-
"@pandacss/dev": "0.0.0-dev-
|
|
48
|
+
"@pandacss/dev": "0.0.0-dev-20230801084843"
|
|
49
49
|
},
|
|
50
50
|
"scripts": {
|
|
51
51
|
"codegen": "panda",
|
|
@@ -120,7 +120,7 @@ export function isCondition(value) {
|
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
const underscoreRegex = /^_/
|
|
123
|
-
const
|
|
123
|
+
const conditionsSelectorRegex = /&|@/
|
|
124
124
|
|
|
125
125
|
export function finalizeConditions(paths) {
|
|
126
126
|
return paths.map((path) => {
|
|
@@ -128,7 +128,7 @@ export function finalizeConditions(paths) {
|
|
|
128
128
|
return path.replace(underscoreRegex, '')
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
-
if (
|
|
131
|
+
if (conditionsSelectorRegex.test(path)) {
|
|
132
132
|
return `[${withoutSpace(path.trim())}]`
|
|
133
133
|
}
|
|
134
134
|
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { getSlotRecipes } from '../helpers.mjs'
|
|
2
|
+
import { cva } from './cva.mjs'
|
|
3
|
+
|
|
4
|
+
export function sva(config) {
|
|
5
|
+
const slots = Object.entries(getSlotRecipes(config)).map(([slot, slotCva]) => [slot, cva(slotCva)])
|
|
6
|
+
|
|
7
|
+
function svaFn(props) {
|
|
8
|
+
const result = slots.map(([slot, cvaFn]) => [slot, cvaFn(props)])
|
|
9
|
+
return Object.fromEntries(result)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const [, firstCva] = slots[0]
|
|
13
|
+
|
|
14
|
+
return Object.assign(svaFn, {
|
|
15
|
+
__cva__: false,
|
|
16
|
+
variantMap: firstCva.variantMap,
|
|
17
|
+
variantKeys: firstCva.variantKeys,
|
|
18
|
+
splitVariantProps: firstCva.splitVariantProps,
|
|
19
|
+
})
|
|
20
|
+
}
|
|
@@ -224,6 +224,54 @@ function normalizeHTMLProps(props) {
|
|
|
224
224
|
}
|
|
225
225
|
normalizeHTMLProps.keys = htmlProps
|
|
226
226
|
|
|
227
|
+
// src/slot.ts
|
|
228
|
+
var assign = (obj, path, value) => {
|
|
229
|
+
const last = path.pop()
|
|
230
|
+
const target = path.reduce((acc, key) => {
|
|
231
|
+
if (acc[key] == null) acc[key] = {}
|
|
232
|
+
return acc[key]
|
|
233
|
+
}, obj)
|
|
234
|
+
if (last != null) target[last] = value
|
|
235
|
+
}
|
|
236
|
+
var getSlotRecipes = (recipe) => {
|
|
237
|
+
const parts = recipe.slots
|
|
238
|
+
.map((slot) => [
|
|
239
|
+
slot,
|
|
240
|
+
// setup base recipe
|
|
241
|
+
{
|
|
242
|
+
// create class-base on BEM
|
|
243
|
+
className: [recipe.className ?? '', slot].join('__'),
|
|
244
|
+
base: {},
|
|
245
|
+
variants: {},
|
|
246
|
+
defaultVariants: recipe.defaultVariants ?? {},
|
|
247
|
+
compoundVariants: [],
|
|
248
|
+
},
|
|
249
|
+
])
|
|
250
|
+
.map(([slot, cva]) => {
|
|
251
|
+
const base = recipe.base[slot]
|
|
252
|
+
if (base) cva.base = base
|
|
253
|
+
walkObject(
|
|
254
|
+
recipe.variants ?? {},
|
|
255
|
+
(variant, path) => {
|
|
256
|
+
if (!variant[slot]) return
|
|
257
|
+
assign(cva, ['variants', ...path], variant[slot])
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
stop: (_value, path) => path.includes(slot),
|
|
261
|
+
},
|
|
262
|
+
)
|
|
263
|
+
if (recipe.compoundVariants) {
|
|
264
|
+
cva.compoundVariants = getSlotCompoundVariant(recipe.compoundVariants, slot)
|
|
265
|
+
}
|
|
266
|
+
return [slot, cva]
|
|
267
|
+
})
|
|
268
|
+
return Object.fromEntries(parts)
|
|
269
|
+
}
|
|
270
|
+
var getSlotCompoundVariant = (compoundVariants, slotName) =>
|
|
271
|
+
compoundVariants
|
|
272
|
+
.filter((compoundVariant) => compoundVariant.css[slotName])
|
|
273
|
+
.map((compoundVariant) => ({ ...compoundVariant, css: compoundVariant.css[slotName] }))
|
|
274
|
+
|
|
227
275
|
// src/split-props.ts
|
|
228
276
|
function splitProps(props, ...keys) {
|
|
229
277
|
const descriptors = Object.getOwnPropertyDescriptors(props)
|
|
@@ -248,6 +296,8 @@ export {
|
|
|
248
296
|
createCss,
|
|
249
297
|
createMergeCss,
|
|
250
298
|
filterBaseConditions,
|
|
299
|
+
getSlotCompoundVariant,
|
|
300
|
+
getSlotRecipes,
|
|
251
301
|
hypenateProperty,
|
|
252
302
|
isBaseCondition,
|
|
253
303
|
isObject,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
|
-
import type { RecipeVariantRecord, RecipeConfig } from './recipe'
|
|
2
|
+
import type { RecipeVariantRecord, RecipeConfig, SlotRecipeVariantRecord, SlotRecipeConfig } from './recipe'
|
|
3
3
|
import type { Parts } from './parts'
|
|
4
4
|
import type { PatternConfig, PatternProperties } from './pattern'
|
|
5
5
|
import type { GlobalStyleObject, SystemStyleObject } from './system-types'
|
|
@@ -7,10 +7,11 @@ import type { CompositionStyles } from './composition'
|
|
|
7
7
|
|
|
8
8
|
declare module '@pandacss/dev' {
|
|
9
9
|
export function defineRecipe<V extends RecipeVariantRecord>(config: RecipeConfig<V>): RecipeConfig
|
|
10
|
+
export function defineSlotRecipe<S extends string, V extends SlotRecipeVariantRecord<S>>(config: SlotRecipeConfig<S, V>): SlotRecipeConfig
|
|
10
11
|
export function defineStyles(definition: SystemStyleObject): SystemStyleObject
|
|
11
12
|
export function defineGlobalStyles(definition: GlobalStyleObject): GlobalStyleObject
|
|
12
13
|
export function defineTextStyles(definition: CompositionStyles['textStyles']): CompositionStyles['textStyles']
|
|
13
14
|
export function defineLayerStyles(definition: CompositionStyles['layerStyles']): CompositionStyles['layerStyles']
|
|
14
15
|
export function definePattern<T extends PatternProperties>(config: PatternConfig<T>): PatternConfig
|
|
15
|
-
export function defineParts<T extends Parts>(parts: T): (config: Partial<Record<keyof T, SystemStyleObject>>) => Partial<Record<keyof T, SystemStyleObject
|
|
16
|
+
export function defineParts<T extends Parts>(parts: T): (config: Partial<Record<keyof T, SystemStyleObject>>) => Partial<Record<keyof T, SystemStyleObject>>
|
|
16
17
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
2
|
import type { SystemStyleObject } from './system-types'
|
|
3
3
|
|
|
4
|
-
type Pretty<T> =
|
|
4
|
+
type Pretty<T> = { [K in keyof T]: T[K] } & {}
|
|
5
5
|
|
|
6
6
|
type StringToBoolean<T> = T extends 'true' | 'false' ? boolean : T
|
|
7
7
|
|
|
@@ -21,6 +21,10 @@ type RecipeVariantMap<T extends RecipeVariantRecord> = {
|
|
|
21
21
|
[K in keyof T]: Array<keyof T[K]>
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
/* -----------------------------------------------------------------------------
|
|
25
|
+
* Recipe / Standard
|
|
26
|
+
* -----------------------------------------------------------------------------*/
|
|
27
|
+
|
|
24
28
|
export type RecipeRuntimeFn<T extends RecipeVariantRecord> = RecipeVariantFn<T> & {
|
|
25
29
|
__type: RecipeSelection<T>
|
|
26
30
|
variantKeys: (keyof T)[]
|
|
@@ -59,7 +63,7 @@ export type RecipeDefinition<T extends RecipeVariantRecord> = {
|
|
|
59
63
|
|
|
60
64
|
export type RecipeCreatorFn = <T extends RecipeVariantRecord>(config: RecipeDefinition<T>) => RecipeRuntimeFn<T>
|
|
61
65
|
|
|
62
|
-
|
|
66
|
+
type RecipeConfigMeta = {
|
|
63
67
|
/**
|
|
64
68
|
* The name of the recipe.
|
|
65
69
|
*/
|
|
@@ -76,3 +80,59 @@ export type RecipeConfig<T extends RecipeVariantRecord = RecipeVariantRecord> =
|
|
|
76
80
|
*/
|
|
77
81
|
jsx?: Array<string | RegExp>
|
|
78
82
|
}
|
|
83
|
+
|
|
84
|
+
export type RecipeConfig<T extends RecipeVariantRecord = RecipeVariantRecord> = RecipeDefinition<T> & RecipeConfigMeta
|
|
85
|
+
|
|
86
|
+
/* -----------------------------------------------------------------------------
|
|
87
|
+
* Recipe / Slot
|
|
88
|
+
* -----------------------------------------------------------------------------*/
|
|
89
|
+
|
|
90
|
+
type SlotRecord<S extends string, T> = Partial<Record<S, T>>
|
|
91
|
+
|
|
92
|
+
export type SlotRecipeVariantRecord<S extends string> = Record<any, Record<any, SlotRecord<S, SystemStyleObject>>>
|
|
93
|
+
|
|
94
|
+
export type SlotRecipeVariantFn<S extends string, T extends RecipeVariantRecord> = (
|
|
95
|
+
props?: RecipeSelection<T>,
|
|
96
|
+
) => SlotRecord<S, string>
|
|
97
|
+
|
|
98
|
+
export type SlotRecipeRuntimeFn<S extends string, T extends SlotRecipeVariantRecord<S>> = SlotRecipeVariantFn<S, T> & {
|
|
99
|
+
variantKeys: (keyof T)[]
|
|
100
|
+
variantMap: RecipeVariantMap<T>
|
|
101
|
+
splitVariantProps<Props extends RecipeSelection<T>>(props: Props): [RecipeSelection<T>, Pretty<Omit<Props, keyof T>>]
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export type SlotRecipeCompoundVariant<S extends string, T extends RecipeVariantRecord> = RecipeCompoundSelection<T> & {
|
|
105
|
+
css: SlotRecord<S, SystemStyleObject>
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export type SlotRecipeDefinition<S extends string, T extends SlotRecipeVariantRecord<S>> = {
|
|
109
|
+
/**
|
|
110
|
+
* The parts/slots of the recipe.
|
|
111
|
+
*/
|
|
112
|
+
slots: S[] | Readonly<S[]>
|
|
113
|
+
/**
|
|
114
|
+
* The base styles of the recipe.
|
|
115
|
+
*/
|
|
116
|
+
base?: SlotRecord<S, SystemStyleObject>
|
|
117
|
+
/**
|
|
118
|
+
* The multi-variant styles of the recipe.
|
|
119
|
+
*/
|
|
120
|
+
variants?: T | SlotRecipeVariantRecord<S>
|
|
121
|
+
/**
|
|
122
|
+
* The default variants of the recipe.
|
|
123
|
+
*/
|
|
124
|
+
defaultVariants?: RecipeSelection<T>
|
|
125
|
+
/**
|
|
126
|
+
* The styles to apply when a combination of variants is selected.
|
|
127
|
+
*/
|
|
128
|
+
compoundVariants?: Array<SlotRecipeCompoundVariant<S, T>>
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export type SlotRecipeCreatorFn = <S extends string, T extends SlotRecipeVariantRecord<S>>(
|
|
132
|
+
config: SlotRecipeDefinition<S, T>,
|
|
133
|
+
) => SlotRecipeRuntimeFn<S, T>
|
|
134
|
+
|
|
135
|
+
export type SlotRecipeConfig<
|
|
136
|
+
S extends string = string,
|
|
137
|
+
T extends SlotRecipeVariantRecord<S> = SlotRecipeVariantRecord<S>,
|
|
138
|
+
> = SlotRecipeDefinition<S, T> & RecipeConfigMeta
|