@pandacss/studio 1.4.3 → 1.5.1

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/studio.mjs CHANGED
@@ -1,4 +1,4 @@
1
- // ../../node_modules/.pnpm/tsup@8.5.0_@swc+core@1.13.5_jiti@2.4.2_postcss@8.5.6_tsx@4.20.6_typescript@5.8.3_yaml@2.7.0/node_modules/tsup/assets/esm_shims.js
1
+ // ../../node_modules/.pnpm/tsup@8.5.1_@swc+core@1.15.1_@swc+helpers@0.5.17__jiti@2.6.1_postcss@8.5.6_tsx@4.20.6_typescript@5.9.3_yaml@2.8.1/node_modules/tsup/assets/esm_shims.js
2
2
  import path from "path";
3
3
  import { fileURLToPath } from "url";
4
4
  var getFilename = () => fileURLToPath(import.meta.url);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pandacss/studio",
3
- "version": "1.4.3",
3
+ "version": "1.5.1",
4
4
  "description": "The automated token documentation for Panda CSS",
5
5
  "main": "dist/studio.js",
6
6
  "module": "dist/studio.mjs",
@@ -44,16 +44,16 @@
44
44
  "license": "MIT",
45
45
  "dependencies": {
46
46
  "@astrojs/react": "4.3.0",
47
- "astro": "5.5.5",
47
+ "astro": "5.15.6",
48
48
  "react": "19.1.1",
49
49
  "react-dom": "19.1.1",
50
- "vite": "7.0.6",
51
- "@pandacss/config": "1.4.3",
52
- "@pandacss/logger": "1.4.3",
53
- "@pandacss/shared": "1.4.3",
54
- "@pandacss/token-dictionary": "1.4.3",
55
- "@pandacss/types": "1.4.3",
56
- "@pandacss/astro-plugin-studio": "1.4.3"
50
+ "vite": "7.2.2",
51
+ "@pandacss/config": "1.5.1",
52
+ "@pandacss/logger": "1.5.1",
53
+ "@pandacss/shared": "1.5.1",
54
+ "@pandacss/token-dictionary": "1.5.1",
55
+ "@pandacss/types": "1.5.1",
56
+ "@pandacss/astro-plugin-studio": "1.5.1"
57
57
  },
58
58
  "devDependencies": {
59
59
  "@types/react": "19.2.2",
@@ -1,7 +1,7 @@
1
1
  /* eslint-disable */
2
2
  import type { SlotRecipeRuntimeFn, RecipeVariantProps } from '../types/recipe';
3
3
  import type { JsxHTMLProps, JsxStyleProps, Assign } from '../types/system-types';
4
- import type { JsxFactoryOptions, ComponentProps } from '../types/jsx';
4
+ import type { JsxFactoryOptions, ComponentProps, DataAttrs, AsProps } from '../types/jsx';
5
5
  import type { ComponentType, ElementType } from 'react'
6
6
 
7
7
  interface UnstyledProps {
@@ -19,11 +19,11 @@ type SlotRecipe = SvaFn | SlotRecipeFn
19
19
  type InferSlot<R extends SlotRecipe> = R extends SlotRecipeFn ? R['__slot'] : R extends SvaFn<infer S> ? S : never
20
20
 
21
21
  interface WithProviderOptions<P = {}> {
22
- defaultProps?: Partial<P> | undefined
22
+ defaultProps?: (Partial<P> & DataAttrs) | undefined
23
23
  }
24
24
 
25
25
  type StyleContextProvider<T extends ElementType, R extends SlotRecipe> = ComponentType<
26
- JsxHTMLProps<ComponentProps<T> & UnstyledProps, Assign<RecipeVariantProps<R>, JsxStyleProps>>
26
+ JsxHTMLProps<ComponentProps<T> & UnstyledProps & AsProps, Assign<RecipeVariantProps<R>, JsxStyleProps>>
27
27
  >
28
28
 
29
29
  type StyleContextRootProvider<T extends ElementType, R extends SlotRecipe> = ComponentType<
@@ -31,7 +31,7 @@ type StyleContextRootProvider<T extends ElementType, R extends SlotRecipe> = Com
31
31
  >
32
32
 
33
33
  type StyleContextConsumer<T extends ElementType> = ComponentType<
34
- JsxHTMLProps<ComponentProps<T> & UnstyledProps, JsxStyleProps>
34
+ JsxHTMLProps<ComponentProps<T> & UnstyledProps & AsProps, JsxStyleProps>
35
35
  >
36
36
 
37
37
  export interface StyleContext<R extends SlotRecipe> {
@@ -5,9 +5,29 @@ import { panda } from './factory.mjs';
5
5
  import { getDisplayName } from './factory-helper.mjs';
6
6
  import { createContext, useContext, createElement, forwardRef } from 'react'
7
7
 
8
+ function createSafeContext(contextName) {
9
+ const Context = createContext(undefined)
10
+ const useStyleContext = (componentName, slot) => {
11
+ const context = useContext(Context)
12
+ if (context === undefined) {
13
+ const componentInfo = componentName ? `Component "${componentName}"` : 'A component'
14
+ const slotInfo = slot ? ` (slot: "${slot}")` : ''
15
+
16
+ throw new Error(
17
+ `${componentInfo}${slotInfo} cannot access ${contextName} because it's missing its Provider.`
18
+ )
19
+ }
20
+ return context
21
+ }
22
+ return [Context, useStyleContext]
23
+ }
24
+
8
25
  export function createStyleContext(recipe) {
9
- const StyleContext = createContext({})
10
26
  const isConfigRecipe = '__recipe__' in recipe
27
+ const recipeName = isConfigRecipe && recipe.__name__ ? recipe.__name__ : undefined
28
+ const contextName = recipeName ? `createStyleContext("${recipeName}")` : 'createStyleContext'
29
+
30
+ const [StyleContext, useStyleContext] = createSafeContext(contextName)
11
31
  const svaFn = isConfigRecipe ? recipe : sva(recipe.config)
12
32
 
13
33
  const getResolvedProps = (props, slotStyles) => {
@@ -71,9 +91,10 @@ export function createStyleContext(recipe) {
71
91
 
72
92
  const withContext = (Component, slot, options) => {
73
93
  const StyledComponent = panda(Component, {}, options)
94
+ const componentName = getDisplayName(Component)
74
95
 
75
96
  const WithContext = forwardRef((props, ref) => {
76
- const slotStyles = useContext(StyleContext)
97
+ const slotStyles = useStyleContext(componentName, slot)
77
98
 
78
99
  const propsWithClass = { ...props, className: props.className ?? options?.defaultProps?.className }
79
100
  const resolvedProps = getResolvedProps(propsWithClass, slotStyles[slot])
@@ -84,7 +105,6 @@ export function createStyleContext(recipe) {
84
105
  })
85
106
  })
86
107
 
87
- const componentName = getDisplayName(Component)
88
108
  WithContext.displayName = `withContext(${componentName})`
89
109
 
90
110
  return WithContext
@@ -7,6 +7,8 @@ interface Dict {
7
7
  [k: string]: unknown
8
8
  }
9
9
 
10
+ export type DataAttrs = Record<`data-${string}`, unknown>
11
+
10
12
  export interface UnstyledProps {
11
13
  /**
12
14
  * Whether to remove recipe styles
@@ -36,7 +38,7 @@ interface RecipeFn {
36
38
 
37
39
  export interface JsxFactoryOptions<TProps extends Dict> {
38
40
  dataAttr?: boolean
39
- defaultProps?: Partial<TProps>
41
+ defaultProps?: Partial<TProps> & DataAttrs
40
42
  shouldForwardProp?: (prop: string, variantKeys: string[]) => boolean
41
43
  forwardProps?: string[]
42
44
  }