@pandacss/studio 0.8.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.
Files changed (39) hide show
  1. package/dist/studio.js +49 -47
  2. package/dist/studio.mjs +49 -47
  3. package/package.json +15 -15
  4. package/styled-system/css/conditions.mjs +5 -116
  5. package/styled-system/css/css.mjs +19 -379
  6. package/styled-system/css/index.d.ts +2 -1
  7. package/styled-system/css/index.mjs +1 -0
  8. package/styled-system/css/sva.d.ts +4 -0
  9. package/styled-system/css/sva.mjs +20 -0
  10. package/styled-system/helpers.mjs +59 -21
  11. package/styled-system/jsx/aspect-ratio.mjs +1 -1
  12. package/styled-system/jsx/box.mjs +1 -1
  13. package/styled-system/jsx/center.mjs +1 -1
  14. package/styled-system/jsx/circle.mjs +1 -1
  15. package/styled-system/jsx/container.mjs +1 -1
  16. package/styled-system/jsx/divider.mjs +1 -1
  17. package/styled-system/jsx/factory.mjs +2 -2
  18. package/styled-system/jsx/flex.mjs +1 -1
  19. package/styled-system/jsx/float.mjs +1 -1
  20. package/styled-system/jsx/grid-item.mjs +1 -1
  21. package/styled-system/jsx/grid.mjs +1 -1
  22. package/styled-system/jsx/hstack.mjs +1 -1
  23. package/styled-system/jsx/is-valid-prop.mjs +8 -1018
  24. package/styled-system/jsx/link-box.mjs +1 -1
  25. package/styled-system/jsx/link-overlay.mjs +1 -1
  26. package/styled-system/jsx/spacer.mjs +1 -1
  27. package/styled-system/jsx/square.mjs +1 -1
  28. package/styled-system/jsx/stack.mjs +1 -1
  29. package/styled-system/jsx/styled-link.mjs +1 -1
  30. package/styled-system/jsx/vstack.mjs +1 -1
  31. package/styled-system/jsx/wrap.mjs +1 -1
  32. package/styled-system/tokens/index.css +1 -1
  33. package/styled-system/tokens/index.mjs +1 -1
  34. package/styled-system/types/global.d.ts +3 -2
  35. package/styled-system/types/pattern.d.ts +8 -1
  36. package/styled-system/types/prop-type.d.ts +5 -0
  37. package/styled-system/types/recipe.d.ts +66 -4
  38. package/styled-system/types/style-props.d.ts +3 -72
  39. package/styled-system/types/system-types.d.ts +3 -4
@@ -3,18 +3,6 @@ function isObject(value) {
3
3
  return typeof value === 'object' && value != null && !Array.isArray(value)
4
4
  }
5
5
 
6
- // src/astish.ts
7
- var newRule = /(?:([\u0080-\uFFFF\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(}\s*)/g
8
- var ruleClean = /\/\*[^]*?\*\/|\s\s+|\n/g
9
- var astish = (val, tree = [{}]) => {
10
- const block = newRule.exec((val ?? '').replace(ruleClean, ''))
11
- if (!block) return tree[0]
12
- if (block[4]) tree.shift()
13
- else if (block[3]) tree.unshift((tree[0][block[3]] = tree[0][block[3]] || {}))
14
- else tree[0][block[1]] = block[2]
15
- return astish(val, tree)
16
- }
17
-
18
6
  // src/compact.ts
19
7
  function compact(value) {
20
8
  return Object.fromEntries(Object.entries(value ?? {}).filter(([_, value2]) => value2 !== void 0))
@@ -214,15 +202,53 @@ var hypenateProperty = memo((property) => {
214
202
  return property.replace(wordRegex, '-$1').replace(msRegex, '-ms-').toLowerCase()
215
203
  })
216
204
 
217
- // src/normalize-html.ts
218
- var htmlProps = ['htmlSize', 'htmlTranslate', 'htmlWidth', 'htmlHeight']
219
- function convert(key) {
220
- return htmlProps.includes(key) ? key.replace('html', '').toLowerCase() : key
205
+ // src/slot.ts
206
+ var assign = (obj, path, value) => {
207
+ const last = path.pop()
208
+ const target = path.reduce((acc, key) => {
209
+ if (acc[key] == null) acc[key] = {}
210
+ return acc[key]
211
+ }, obj)
212
+ if (last != null) target[last] = value
221
213
  }
222
- function normalizeHTMLProps(props) {
223
- return Object.fromEntries(Object.entries(props).map(([key, value]) => [convert(key), value]))
214
+ var getSlotRecipes = (recipe) => {
215
+ const parts = recipe.slots
216
+ .map((slot) => [
217
+ slot,
218
+ // setup base recipe
219
+ {
220
+ // create class-base on BEM
221
+ className: [recipe.className ?? '', slot].join('__'),
222
+ base: {},
223
+ variants: {},
224
+ defaultVariants: recipe.defaultVariants ?? {},
225
+ compoundVariants: [],
226
+ },
227
+ ])
228
+ .map(([slot, cva]) => {
229
+ const base = recipe.base[slot]
230
+ if (base) cva.base = base
231
+ walkObject(
232
+ recipe.variants ?? {},
233
+ (variant, path) => {
234
+ if (!variant[slot]) return
235
+ assign(cva, ['variants', ...path], variant[slot])
236
+ },
237
+ {
238
+ stop: (_value, path) => path.includes(slot),
239
+ },
240
+ )
241
+ if (recipe.compoundVariants) {
242
+ cva.compoundVariants = getSlotCompoundVariant(recipe.compoundVariants, slot)
243
+ }
244
+ return [slot, cva]
245
+ })
246
+ return Object.fromEntries(parts)
224
247
  }
225
- normalizeHTMLProps.keys = htmlProps
248
+ var getSlotCompoundVariant = (compoundVariants, slotName) =>
249
+ compoundVariants
250
+ .filter((compoundVariant) => compoundVariant.css[slotName])
251
+ .map((compoundVariant) => ({ ...compoundVariant, css: compoundVariant.css[slotName] }))
226
252
 
227
253
  // src/split-props.ts
228
254
  function splitProps(props, ...keys) {
@@ -243,23 +269,35 @@ function splitProps(props, ...keys) {
243
269
  return keys.map(fn).concat(split(dKeys))
244
270
  }
245
271
  export {
246
- astish,
247
272
  compact,
248
273
  createCss,
249
274
  createMergeCss,
250
275
  filterBaseConditions,
276
+ getSlotCompoundVariant,
277
+ getSlotRecipes,
251
278
  hypenateProperty,
252
279
  isBaseCondition,
253
280
  isObject,
254
281
  mapObject,
282
+ memo,
255
283
  mergeProps,
256
- normalizeHTMLProps,
257
284
  splitProps,
258
285
  toHash,
259
286
  walkObject,
260
287
  withoutSpace,
261
288
  }
262
289
 
290
+ // src/normalize-html.ts
291
+ var htmlProps = ['htmlSize', 'htmlTranslate', 'htmlWidth', 'htmlHeight']
292
+ function convert(key) {
293
+ return htmlProps.includes(key) ? key.replace('html', '').toLowerCase() : key
294
+ }
295
+ function normalizeHTMLProps(props) {
296
+ return Object.fromEntries(Object.entries(props).map(([key, value]) => [convert(key), value]))
297
+ }
298
+ normalizeHTMLProps.keys = htmlProps
299
+ export { normalizeHTMLProps }
300
+
263
301
  export function __spreadValues(a, b) {
264
302
  return { ...a, ...b }
265
303
  }
@@ -2,7 +2,7 @@ import { createElement, forwardRef } from 'react'
2
2
  import { panda } from './factory.mjs'
3
3
  import { getAspectRatioStyle } from '../patterns/aspect-ratio.mjs'
4
4
 
5
- export const AspectRatio = forwardRef(function AspectRatio(props, ref) {
5
+ export const AspectRatio = /* @__PURE__ */ forwardRef(function AspectRatio(props, ref) {
6
6
  const { ratio, ...restProps } = props
7
7
  const styleProps = getAspectRatioStyle({ ratio })
8
8
  return createElement(panda.div, { ref, ...styleProps, ...restProps })
@@ -2,7 +2,7 @@ import { createElement, forwardRef } from 'react'
2
2
  import { panda } from './factory.mjs'
3
3
  import { getBoxStyle } from '../patterns/box.mjs'
4
4
 
5
- export const Box = forwardRef(function Box(props, ref) {
5
+ export const Box = /* @__PURE__ */ forwardRef(function Box(props, ref) {
6
6
  const styleProps = getBoxStyle()
7
7
  return createElement(panda.div, { ref, ...styleProps, ...props })
8
8
  })
@@ -2,7 +2,7 @@ import { createElement, forwardRef } from 'react'
2
2
  import { panda } from './factory.mjs'
3
3
  import { getCenterStyle } from '../patterns/center.mjs'
4
4
 
5
- export const Center = forwardRef(function Center(props, ref) {
5
+ export const Center = /* @__PURE__ */ forwardRef(function Center(props, ref) {
6
6
  const { inline, ...restProps } = props
7
7
  const styleProps = getCenterStyle({ inline })
8
8
  return createElement(panda.div, { ref, ...styleProps, ...restProps })
@@ -2,7 +2,7 @@ import { createElement, forwardRef } from 'react'
2
2
  import { panda } from './factory.mjs'
3
3
  import { getCircleStyle } from '../patterns/circle.mjs'
4
4
 
5
- export const Circle = forwardRef(function Circle(props, ref) {
5
+ export const Circle = /* @__PURE__ */ forwardRef(function Circle(props, ref) {
6
6
  const { size, ...restProps } = props
7
7
  const styleProps = getCircleStyle({ size })
8
8
  return createElement(panda.div, { ref, ...styleProps, ...restProps })
@@ -2,7 +2,7 @@ import { createElement, forwardRef } from 'react'
2
2
  import { panda } from './factory.mjs'
3
3
  import { getContainerStyle } from '../patterns/container.mjs'
4
4
 
5
- export const Container = forwardRef(function Container(props, ref) {
5
+ export const Container = /* @__PURE__ */ forwardRef(function Container(props, ref) {
6
6
  const styleProps = getContainerStyle()
7
7
  return createElement(panda.div, { ref, ...styleProps, ...props })
8
8
  })
@@ -2,7 +2,7 @@ import { createElement, forwardRef } from 'react'
2
2
  import { panda } from './factory.mjs'
3
3
  import { getDividerStyle } from '../patterns/divider.mjs'
4
4
 
5
- export const Divider = forwardRef(function Divider(props, ref) {
5
+ export const Divider = /* @__PURE__ */ forwardRef(function Divider(props, ref) {
6
6
  const { orientation, thickness, color, ...restProps } = props
7
7
  const styleProps = getDividerStyle({ orientation, thickness, color })
8
8
  return createElement(panda.div, { ref, ...styleProps, ...restProps })
@@ -6,7 +6,7 @@ import { isCssProperty } from './is-valid-prop.mjs'
6
6
  function styledFn(Dynamic, configOrCva = {}) {
7
7
  const cvaFn = configOrCva.__cva__ || configOrCva.__recipe__ ? configOrCva : cva(configOrCva)
8
8
 
9
- const PandaComponent = forwardRef(function PandaComponent(props, ref) {
9
+ const PandaComponent = /* @__PURE__ */ forwardRef(function PandaComponent(props, ref) {
10
10
  const { as: Element = Dynamic, ...restProps } = props
11
11
 
12
12
  const [variantProps, styleProps, htmlProps, elementProps] = useMemo(() => {
@@ -56,4 +56,4 @@ function createJsxFactory() {
56
56
  })
57
57
  }
58
58
 
59
- export const panda = createJsxFactory()
59
+ export const panda = /* @__PURE__ */ createJsxFactory()
@@ -2,7 +2,7 @@ import { createElement, forwardRef } from 'react'
2
2
  import { panda } from './factory.mjs'
3
3
  import { getFlexStyle } from '../patterns/flex.mjs'
4
4
 
5
- export const Flex = forwardRef(function Flex(props, ref) {
5
+ export const Flex = /* @__PURE__ */ forwardRef(function Flex(props, ref) {
6
6
  const { align, justify, direction, wrap, basis, grow, shrink, ...restProps } = props
7
7
  const styleProps = getFlexStyle({ align, justify, direction, wrap, basis, grow, shrink })
8
8
  return createElement(panda.div, { ref, ...styleProps, ...restProps })
@@ -2,7 +2,7 @@ import { createElement, forwardRef } from 'react'
2
2
  import { panda } from './factory.mjs'
3
3
  import { getFloatStyle } from '../patterns/float.mjs'
4
4
 
5
- export const Float = forwardRef(function Float(props, ref) {
5
+ export const Float = /* @__PURE__ */ forwardRef(function Float(props, ref) {
6
6
  const { offsetX, offsetY, offset, placement, ...restProps } = props
7
7
  const styleProps = getFloatStyle({ offsetX, offsetY, offset, placement })
8
8
  return createElement(panda.div, { ref, ...styleProps, ...restProps })
@@ -2,7 +2,7 @@ import { createElement, forwardRef } from 'react'
2
2
  import { panda } from './factory.mjs'
3
3
  import { getGridItemStyle } from '../patterns/grid-item.mjs'
4
4
 
5
- export const GridItem = forwardRef(function GridItem(props, ref) {
5
+ export const GridItem = /* @__PURE__ */ forwardRef(function GridItem(props, ref) {
6
6
  const { colSpan, rowSpan, colStart, rowStart, colEnd, rowEnd, ...restProps } = props
7
7
  const styleProps = getGridItemStyle({ colSpan, rowSpan, colStart, rowStart, colEnd, rowEnd })
8
8
  return createElement(panda.div, { ref, ...styleProps, ...restProps })
@@ -2,7 +2,7 @@ import { createElement, forwardRef } from 'react'
2
2
  import { panda } from './factory.mjs'
3
3
  import { getGridStyle } from '../patterns/grid.mjs'
4
4
 
5
- export const Grid = forwardRef(function Grid(props, ref) {
5
+ export const Grid = /* @__PURE__ */ forwardRef(function Grid(props, ref) {
6
6
  const { gap, columnGap, rowGap, columns, minChildWidth, ...restProps } = props
7
7
  const styleProps = getGridStyle({ gap, columnGap, rowGap, columns, minChildWidth })
8
8
  return createElement(panda.div, { ref, ...styleProps, ...restProps })
@@ -2,7 +2,7 @@ import { createElement, forwardRef } from 'react'
2
2
  import { panda } from './factory.mjs'
3
3
  import { getHstackStyle } from '../patterns/hstack.mjs'
4
4
 
5
- export const HStack = forwardRef(function HStack(props, ref) {
5
+ export const HStack = /* @__PURE__ */ forwardRef(function HStack(props, ref) {
6
6
  const { justify, gap, ...restProps } = props
7
7
  const styleProps = getHstackStyle({ justify, gap })
8
8
  return createElement(panda.div, { ref, ...styleProps, ...restProps })