@plasmicapp/react-web 0.2.116 → 0.2.118

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../src/plume/switch/index.tsx"],"sourcesContent":["import { AriaSwitchProps } from \"@react-types/switch\";\nimport * as React from \"react\";\nimport { useSwitch as useAriaSwitch } from \"@react-aria/switch\";\nimport { VisuallyHidden } from \"@react-aria/visually-hidden\";\nimport { useToggleState } from \"@react-stately/toggle\";\nimport { pick } from \"../../common\";\nimport { mergeProps } from \"../../react-utils\";\nimport { Overrides } from \"../../render/elements\";\nimport { useEnsureSSRProvider } from \"../../render/ssr\";\nimport {\n AnyPlasmicClass,\n mergeVariantToggles,\n PlasmicClassArgs,\n PlasmicClassOverrides,\n PlasmicClassVariants,\n VariantDef,\n} from \"../plume-utils\";\nimport { getStyleProps, StyleProps } from \"../props-utils\";\n\nexport type SwitchRef = React.Ref<SwitchRefValue>;\nexport interface SwitchRefValue extends SwitchState {\n getRoot: () => HTMLElement | null;\n focus: () => void;\n blur: () => void;\n}\n\ninterface SwitchState {\n setChecked: (checked: boolean) => void;\n}\n\nexport interface SwitchProps\n extends Omit<AriaSwitchProps, \"isSelected\" | \"defaultSelected\">,\n StyleProps {\n /**\n * Whether the Switch is checked or not; controlled\n */\n isChecked?: boolean;\n\n /**\n * Whether the Switch is checked by default; uncontrolled\n */\n defaultChecked?: boolean;\n}\n\nfunction asAriaSwitchProps(props: SwitchProps) {\n const ariaProps = {\n ...props,\n isSelected: props.isChecked,\n defaultSelected: props.defaultChecked,\n };\n delete ariaProps[\"isChecked\"];\n delete ariaProps[\"defaultChecked\"];\n return ariaProps;\n}\n\ninterface SwitchConfig<C extends AnyPlasmicClass> {\n isCheckedVariant: VariantDef<PlasmicClassVariants<C>>;\n isDisabledVariant?: VariantDef<PlasmicClassVariants<C>>;\n noLabelVariant?: VariantDef<PlasmicClassVariants<C>>;\n labelSlot?: keyof PlasmicClassArgs<C>;\n root: keyof PlasmicClassOverrides<C>;\n}\n\nexport function useSwitch<P extends SwitchProps, C extends AnyPlasmicClass>(\n plasmicClass: C,\n props: P,\n config: SwitchConfig<C>,\n ref: SwitchRef = null\n) {\n const { children, isDisabled } = props;\n useEnsureSSRProvider();\n const inputRef = React.useRef<HTMLInputElement>(null);\n const rootRef = React.useRef<HTMLElement>(null);\n const ariaProps = asAriaSwitchProps(props);\n const state = useToggleState(ariaProps);\n const { inputProps } = useAriaSwitch(ariaProps, state, inputRef);\n const variants = {\n ...pick(props, ...plasmicClass.internalVariantProps),\n ...mergeVariantToggles(\n {\n def: config.isDisabledVariant,\n active: isDisabled,\n },\n {\n def: config.isCheckedVariant,\n active: state.isSelected,\n },\n {\n def: config.noLabelVariant,\n active: !children,\n }\n ),\n };\n const overrides: Overrides = {\n [config.root]: {\n as: \"label\",\n props: mergeProps(getStyleProps(props), {\n ref: rootRef,\n }),\n wrapChildren: (children) => (\n <>\n <VisuallyHidden isFocusable>\n <input {...inputProps} ref={inputRef} />\n </VisuallyHidden>\n {children}\n </>\n ),\n },\n };\n const args = {\n ...pick(props, ...plasmicClass.internalArgProps),\n ...(config.labelSlot ? { [config.labelSlot]: children } : {}),\n };\n\n const plumeState: SwitchState = React.useMemo(\n () => ({\n setChecked: (checked: boolean) => state.setSelected(checked),\n }),\n [state]\n );\n\n React.useImperativeHandle(\n ref,\n () => ({\n getRoot: () => rootRef.current,\n focus: () => inputRef.current?.focus(),\n blur: () => inputRef.current?.blur(),\n setChecked: (checked) => plumeState.setChecked(checked),\n }),\n [rootRef, inputRef, plumeState]\n );\n\n return {\n plasmicProps: {\n variants: variants as PlasmicClassVariants<C>,\n overrides: overrides as PlasmicClassOverrides<C>,\n args: args as PlasmicClassArgs<C>,\n },\n state: plumeState,\n };\n}\n"],"names":["useAriaSwitch"],"mappings":";;;;;;;;;;;;;;AA4CA,SAAS,iBAAiB,CAAC,KAAkB;IAC3C,IAAM,SAAS,y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ch } from \"@react-aria/switch\";\nimport { VisuallyHidden } from \"@react-aria/visually-hidden\";\nimport { useToggleState } from \"@react-stately/toggle\";\nimport { AriaSwitchProps } from \"@react-types/switch\";\nimport * as React from \"react\";\nimport { pick } from \"../../common\";\nimport { mergeProps } from \"../../react-utils\";\nimport { Overrides } from \"../../render/elements\";\nimport { useEnsureSSRProvider } from \"../../render/ssr\";\nimport {\n AnyPlasmicClass,\n mergeVariantToggles,\n PlasmicClassArgs,\n PlasmicClassOverrides,\n PlasmicClassVariants,\n VariantDef,\n} from \"../plume-utils\";\nimport { getStyleProps, StyleProps } from \"../props-utils\";\n\nexport type SwitchRef = React.Ref<SwitchRefValue>;\nexport interface SwitchRefValue extends SwitchState {\n getRoot: () => HTMLElement | null;\n focus: () => void;\n blur: () => void;\n}\n\ninterface SwitchState {\n setChecked: (checked: boolean) => void;\n}\n\nexport interface SwitchProps\n extends Omit<AriaSwitchProps, \"isSelected\" | \"defaultSelected\">,\n StyleProps {\n /**\n * Whether the Switch is checked or not; controlled\n */\n isChecked?: boolean;\n\n /**\n * Whether the Switch is checked by default; uncontrolled\n */\n defaultChecked?: boolean;\n}\n\nfunction asAriaSwitchProps(props: SwitchProps) {\n const ariaProps = {\n ...props,\n isSelected: props.isChecked,\n defaultSelected: props.defaultChecked,\n };\n delete ariaProps[\"isChecked\"];\n delete ariaProps[\"defaultChecked\"];\n return ariaProps;\n}\n\ninterface SwitchConfig<C extends AnyPlasmicClass> {\n isCheckedVariant: VariantDef<PlasmicClassVariants<C>>;\n isDisabledVariant?: VariantDef<PlasmicClassVariants<C>>;\n noLabelVariant?: VariantDef<PlasmicClassVariants<C>>;\n labelSlot?: keyof PlasmicClassArgs<C>;\n root: keyof PlasmicClassOverrides<C>;\n}\n\nexport function useSwitch<P extends SwitchProps, C extends AnyPlasmicClass>(\n plasmicClass: C,\n props: P,\n config: SwitchConfig<C>,\n ref: SwitchRef = null\n) {\n const { children, isDisabled } = props;\n useEnsureSSRProvider();\n const inputRef = React.useRef<HTMLInputElement>(null);\n const rootRef = React.useRef<HTMLElement>(null);\n const ariaProps = asAriaSwitchProps(props);\n const state = useToggleState(ariaProps);\n const { inputProps } = useAriaSwitch(ariaProps, state, inputRef);\n const variants = {\n ...pick(props, ...plasmicClass.internalVariantProps),\n ...mergeVariantToggles(\n {\n def: config.isDisabledVariant,\n active: isDisabled,\n },\n {\n def: config.isCheckedVariant,\n active: state.isSelected,\n },\n {\n def: config.noLabelVariant,\n active: !children,\n }\n ),\n };\n const overrides: Overrides = {\n [config.root]: {\n as: \"label\",\n props: mergeProps(getStyleProps(props), {\n ref: rootRef,\n }),\n wrapChildren: (children: React.ReactNode) => (\n <>\n <VisuallyHidden>\n <input {...inputProps} ref={inputRef} />\n </VisuallyHidden>\n {children}\n </>\n ),\n },\n };\n const args = {\n ...pick(props, ...plasmicClass.internalArgProps),\n ...(config.labelSlot ? { [config.labelSlot]: children } : {}),\n };\n\n const plumeState: SwitchState = React.useMemo(\n () => ({\n setChecked: (checked: boolean) => state.setSelected(checked),\n }),\n [state]\n );\n\n React.useImperativeHandle(\n ref,\n () => ({\n getRoot: () => rootRef.current,\n focus: () => inputRef.current?.focus(),\n blur: () => inputRef.current?.blur(),\n setChecked: (checked) => plumeState.setChecked(checked),\n }),\n [rootRef, inputRef, plumeState]\n );\n\n return {\n plasmicProps: {\n variants: variants as PlasmicClassVariants<C>,\n overrides: overrides as PlasmicClassOverrides<C>,\n args: args as PlasmicClassArgs<C>,\n },\n state: plumeState,\n };\n}\n"],"names":["useAriaSwitch"],"mappings":";;;;;;;;;;;;;;AA4CA,SAAS,iBAAiB,CAAC,KAAkB;IAC3C,IAAM,SAAS,yBACV,KAAK,KACR,UAAU,EAAE,KAAK,CAAC,SAAS,EAC3B,eAAe,EAAE,KAAK,CAAC,cAAc,GACtC,CAAC;IACF,OAAO,SAAS,CAAC,WAAW,CAAC,CAAC;IAC9B,OAAO,SAAS,CAAC,gBAAgB,CAAC,CAAC;IACnC,OAAO,SAAS,CA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L,IAAI,8BAAC,KAAK,UAAK,YAAY,CAAC,gBAAgB,cAC3C,MAAM,CAAC,SAAS,aAAK,GAAC,MAAM,CAAC,SAAS,IAAG,QAAQ,QAAK,EAAE,EAC7D,CAAC;IAEF,IAAM,UAAU,GAAgB,KAAK,CAAC,OAAO,CAC3C,cAAM,QAAC;QACL,UAAU,EAAE,UAAC,OAAgB,IAAK,OAAA,KAAK,CAAC,WAAW,CAAC,OAAO,CAAC,GAAA;KAC7D,IAAC,EACF,CAAC,KAAK,CAAC,CACR,CAAC;IAEF,KAAK,CAAC,mBAAmB,CACvB,GAAG,EACH,cAAM,QAAC;QACL,OAAO,EAAE,cAAM,OAAA,OAAO,CAAC,OAAO,GAAA;QAC9B,KAAK,EAAE,sBAAM,OAAA,MAAA,QAAQ,CAAC,OAAO,0CAAE,KAAK,EAAE,CAAA,EAAA;QACtC,IAAI,EAAE,sBAAM,OAAA,MAAA,QAAQ,CAAC,OAAO,0CAAE,IAAI,EAAE,CAAA,EAAA;QACpC,UAAU,EAAE,UAAC,OAAO,IAAK,OAAA,UAAU,CAAC,UAAU,CAAC,OAAO,CAAC,GAAA;KACxD,IAAC,EACF,CAAC,OAAO,EAAE,QAAQ,EAAE,UAAU,CAAC,CAChC,CAAC;IAEF,OAAO;QACL,YAAY,EAAE;YACZ,QAAQ,EAAE,QAAmC;YAC7C,SAAS,EAAE,SAAqC;YAChD,IAAI,EAAE,IAA2B;SAClC;QACD,KAAK,EAAE,UAAU;KAClB,CAAC;AACJ;;;;"}
@@ -10,6 +10,7 @@ export interface $StateSpec<T> {
10
10
  type: "private" | "readonly" | "writable";
11
11
  valueProp?: string;
12
12
  onChangeProp?: string;
13
+ isArray?: boolean;
13
14
  }
14
15
  export declare function useDollarState(specs: $StateSpec<any>[], props: Record<string, any>): any;
15
16
  export default useDollarState;
@@ -50,3 +50,6 @@ export declare const FormBuilder: Story<{
50
50
  export declare const FormBuilderImplicitStates: Story<{
51
51
  people: Person[];
52
52
  }>;
53
+ export declare const VariableCellIsArray: Story<{
54
+ people: Person[];
55
+ }>;