@pandacss/studio 1.3.0 → 1.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pandacss/studio",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "description": "The automated token documentation for Panda CSS",
5
5
  "main": "dist/studio.js",
6
6
  "module": "dist/studio.mjs",
@@ -48,12 +48,12 @@
48
48
  "react": "19.1.1",
49
49
  "react-dom": "19.1.1",
50
50
  "vite": "7.0.6",
51
- "@pandacss/config": "1.3.0",
52
- "@pandacss/logger": "1.3.0",
53
- "@pandacss/shared": "1.3.0",
54
- "@pandacss/token-dictionary": "1.3.0",
55
- "@pandacss/types": "1.3.0",
56
- "@pandacss/astro-plugin-studio": "1.3.0"
51
+ "@pandacss/config": "1.3.1",
52
+ "@pandacss/logger": "1.3.1",
53
+ "@pandacss/shared": "1.3.1",
54
+ "@pandacss/token-dictionary": "1.3.1",
55
+ "@pandacss/types": "1.3.1",
56
+ "@pandacss/astro-plugin-studio": "1.3.1"
57
57
  },
58
58
  "devDependencies": {
59
59
  "@types/react": "18.2.55",
@@ -1,11 +1,11 @@
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 } from '../types/jsx';
5
- import type { ComponentType, ElementType, ComponentPropsWithoutRef, ElementRef, Ref } from 'react'
4
+ import type { JsxFactoryOptions, ComponentProps } from '../types/jsx';
5
+ import type { ComponentType, ElementType } from 'react'
6
6
 
7
7
  interface UnstyledProps {
8
- unstyled?: boolean
8
+ unstyled?: boolean | undefined
9
9
  }
10
10
 
11
11
  type SvaFn<S extends string = any> = SlotRecipeRuntimeFn<S, any>
@@ -18,29 +18,36 @@ type SlotRecipe = SvaFn | SlotRecipeFn
18
18
 
19
19
  type InferSlot<R extends SlotRecipe> = R extends SlotRecipeFn ? R['__slot'] : R extends SvaFn<infer S> ? S : never
20
20
 
21
- type ComponentProps<T extends ElementType> = Omit<ComponentPropsWithoutRef<T>, 'ref'> & {
22
- ref?: Ref<ElementRef<T>>
21
+ interface WithProviderOptions<P = {}> {
22
+ defaultProps?: Partial<P> | undefined
23
23
  }
24
24
 
25
25
  type StyleContextProvider<T extends ElementType, R extends SlotRecipe> = ComponentType<
26
26
  JsxHTMLProps<ComponentProps<T> & UnstyledProps, Assign<RecipeVariantProps<R>, JsxStyleProps>>
27
27
  >
28
28
 
29
+ type StyleContextRootProvider<T extends ElementType, R extends SlotRecipe> = ComponentType<
30
+ ComponentProps<T> & UnstyledProps & RecipeVariantProps<R>
31
+ >
32
+
29
33
  type StyleContextConsumer<T extends ElementType> = ComponentType<
30
34
  JsxHTMLProps<ComponentProps<T> & UnstyledProps, JsxStyleProps>
31
35
  >
32
36
 
33
37
  export interface StyleContext<R extends SlotRecipe> {
34
- withRootProvider: <T extends ElementType>(Component: T) => StyleContextProvider<T, R>
38
+ withRootProvider: <T extends ElementType>(
39
+ Component: T,
40
+ options?: WithProviderOptions<ComponentProps<T>> | undefined
41
+ ) => StyleContextRootProvider<T, R>
35
42
  withProvider: <T extends ElementType>(
36
43
  Component: T,
37
44
  slot: InferSlot<R>,
38
- options?: JsxFactoryOptions<ComponentProps<T>>
45
+ options?: JsxFactoryOptions<ComponentProps<T>> | undefined
39
46
  ) => StyleContextProvider<T, R>
40
47
  withContext: <T extends ElementType>(
41
48
  Component: T,
42
49
  slot: InferSlot<R>,
43
- options?: JsxFactoryOptions<ComponentProps<T>>
50
+ options?: JsxFactoryOptions<ComponentProps<T>> | undefined
44
51
  ) => StyleContextConsumer<T>
45
52
  }
46
53
 
@@ -19,16 +19,20 @@ export function createStyleContext(recipe) {
19
19
  return { ...slotStyles, ...restProps }
20
20
  }
21
21
 
22
- const withRootProvider = (Component) => {
22
+ const withRootProvider = (Component, options) => {
23
23
  const WithRootProvider = (props) => {
24
24
  const [variantProps, otherProps] = svaFn.splitVariantProps(props)
25
25
 
26
26
  const slotStyles = isConfigRecipe ? svaFn(variantProps) : svaFn.raw(variantProps)
27
27
  slotStyles._classNameMap = svaFn.classNameMap
28
28
 
29
+ const mergedProps = options?.defaultProps
30
+ ? { ...options.defaultProps, ...otherProps }
31
+ : otherProps
32
+
29
33
  return createElement(StyleContext.Provider, {
30
34
  value: slotStyles,
31
- children: createElement(Component, otherProps)
35
+ children: createElement(Component, mergedProps)
32
36
  })
33
37
  }
34
38
 
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable */
2
- import type { ComponentPropsWithoutRef, ElementType, ElementRef, JSX, Ref } from 'react'
2
+ import type { ElementType, JSX, ComponentPropsWithRef, ComponentType, Component } from 'react'
3
3
  import type { RecipeDefinition, RecipeSelection, RecipeVariantRecord } from './recipe';
4
4
  import type { Assign, DistributiveOmit, DistributiveUnion, JsxHTMLProps, JsxStyleProps, Pretty } from './system-types';
5
5
 
@@ -21,9 +21,9 @@ export interface AsProps {
21
21
  as?: ElementType | undefined
22
22
  }
23
23
 
24
- export type ComponentProps<T extends ElementType> = DistributiveOmit<ComponentPropsWithoutRef<T>, 'ref'> & {
25
- ref?: Ref<ElementRef<T>>
26
- }
24
+ export type ComponentProps<T extends ElementType> = T extends ComponentType<infer P> | Component<infer P>
25
+ ? JSX.LibraryManagedAttributes<T, P>
26
+ : ComponentPropsWithRef<T>
27
27
 
28
28
  export interface PandaComponent<T extends ElementType, P extends Dict = {}> {
29
29
  (props: JsxHTMLProps<ComponentProps<T> & UnstyledProps & AsProps, Assign<JsxStyleProps, P>>): JSX.Element
@@ -34,7 +34,7 @@ interface RecipeFn {
34
34
  __type: any
35
35
  }
36
36
 
37
- interface JsxFactoryOptions<TProps extends Dict> {
37
+ export interface JsxFactoryOptions<TProps extends Dict> {
38
38
  dataAttr?: boolean
39
39
  defaultProps?: Partial<TProps>
40
40
  shouldForwardProp?: (prop: string, variantKeys: string[]) => boolean