@plasmicapp/react-web 0.2.112 → 0.2.113

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 (95) hide show
  1. package/LICENSE.md +21 -0
  2. package/dist/all.d.ts +36 -16
  3. package/dist/common.d.ts +3 -3
  4. package/dist/index-common.d.ts +3 -2
  5. package/dist/react-web.cjs.development.js +52 -31
  6. package/dist/react-web.cjs.development.js.map +1 -1
  7. package/dist/react-web.cjs.production.min.js +1 -1
  8. package/dist/react-web.cjs.production.min.js.map +1 -1
  9. package/dist/react-web.esm.js +41 -31
  10. package/dist/react-web.esm.js.map +1 -1
  11. package/dist/render/ssr.d.ts +1 -0
  12. package/package.json +4 -3
  13. package/skinny/dist/{collection-utils-57c273dc.js → collection-utils-43f97262.js} +14 -13
  14. package/skinny/dist/collection-utils-43f97262.js.map +1 -0
  15. package/skinny/dist/{common-182a0b0c.js → common-9ebe374e.js} +1 -1
  16. package/skinny/dist/common-9ebe374e.js.map +1 -0
  17. package/skinny/dist/common.d.ts +3 -3
  18. package/skinny/dist/index-common.d.ts +3 -2
  19. package/skinny/dist/index.js +40 -42
  20. package/skinny/dist/index.js.map +1 -1
  21. package/skinny/dist/plume/button/index.js +7 -7
  22. package/skinny/dist/plume/button/index.js.map +1 -1
  23. package/skinny/dist/plume/checkbox/index.js +17 -17
  24. package/skinny/dist/plume/checkbox/index.js.map +1 -1
  25. package/skinny/dist/plume/menu/index.js +38 -39
  26. package/skinny/dist/plume/menu/index.js.map +1 -1
  27. package/skinny/dist/plume/menu-button/index.js +22 -22
  28. package/skinny/dist/plume/menu-button/index.js.map +1 -1
  29. package/skinny/dist/plume/select/index.js +41 -43
  30. package/skinny/dist/plume/select/index.js.map +1 -1
  31. package/skinny/dist/plume/switch/index.js +16 -16
  32. package/skinny/dist/plume/switch/index.js.map +1 -1
  33. package/skinny/dist/plume/text-input/index.js +10 -10
  34. package/skinny/dist/plume/text-input/index.js.map +1 -1
  35. package/skinny/dist/plume/triggered-overlay/index.js +14 -14
  36. package/skinny/dist/plume/triggered-overlay/index.js.map +1 -1
  37. package/skinny/dist/{plume-utils-d2476af1.js → plume-utils-d9811bf3.js} +2 -2
  38. package/skinny/dist/{plume-utils-27cd384f.js.map → plume-utils-d9811bf3.js.map} +1 -1
  39. package/skinny/dist/{props-utils-cac0cccf.js → props-utils-228208e6.js} +2 -2
  40. package/skinny/dist/{props-utils-7c02c0a8.js.map → props-utils-228208e6.js.map} +1 -1
  41. package/skinny/dist/{react-utils-35cb2a4e.js → react-utils-7bc53870.js} +6 -6
  42. package/skinny/dist/{react-utils-35cb2a4e.js.map → react-utils-7bc53870.js.map} +1 -1
  43. package/skinny/dist/render/PlasmicHead/index.js +6 -6
  44. package/skinny/dist/render/PlasmicImg/index.js +27 -27
  45. package/skinny/dist/render/PlasmicImg/index.js.map +1 -1
  46. package/skinny/dist/render/ssr.d.ts +1 -0
  47. package/skinny/dist/{ssr-d3321868.js → ssr-b16a1854.js} +10 -9
  48. package/skinny/dist/ssr-b16a1854.js.map +1 -0
  49. package/skinny/dist/collection-utils-2745acd4.js +0 -238
  50. package/skinny/dist/collection-utils-2745acd4.js.map +0 -1
  51. package/skinny/dist/collection-utils-42de4441.js +0 -244
  52. package/skinny/dist/collection-utils-42de4441.js.map +0 -1
  53. package/skinny/dist/collection-utils-57c273dc.js.map +0 -1
  54. package/skinny/dist/collection-utils-bf37b8fb.js +0 -238
  55. package/skinny/dist/collection-utils-bf37b8fb.js.map +0 -1
  56. package/skinny/dist/common-182a0b0c.js.map +0 -1
  57. package/skinny/dist/common-98719219.js +0 -68
  58. package/skinny/dist/common-98719219.js.map +0 -1
  59. package/skinny/dist/common-9efbae57.js +0 -201
  60. package/skinny/dist/common-9efbae57.js.map +0 -1
  61. package/skinny/dist/context-4ca6f5cd.js +0 -6
  62. package/skinny/dist/context-4ca6f5cd.js.map +0 -1
  63. package/skinny/dist/plume-utils-1e225de5.js +0 -25
  64. package/skinny/dist/plume-utils-1e225de5.js.map +0 -1
  65. package/skinny/dist/plume-utils-27cd384f.js +0 -35
  66. package/skinny/dist/plume-utils-623b91cc.js +0 -35
  67. package/skinny/dist/plume-utils-623b91cc.js.map +0 -1
  68. package/skinny/dist/plume-utils-d2476af1.js.map +0 -1
  69. package/skinny/dist/props-utils-7c02c0a8.js +0 -8
  70. package/skinny/dist/props-utils-b2ad4997.js +0 -8
  71. package/skinny/dist/props-utils-b2ad4997.js.map +0 -1
  72. package/skinny/dist/props-utils-c60d3105.js +0 -8
  73. package/skinny/dist/props-utils-c60d3105.js.map +0 -1
  74. package/skinny/dist/props-utils-cac0cccf.js.map +0 -1
  75. package/skinny/dist/react-utils-6050fadc.js +0 -201
  76. package/skinny/dist/react-utils-6050fadc.js.map +0 -1
  77. package/skinny/dist/react-utils-7c01e440.js +0 -172
  78. package/skinny/dist/react-utils-7c01e440.js.map +0 -1
  79. package/skinny/dist/react-utils-b5dc6320.js +0 -155
  80. package/skinny/dist/react-utils-b5dc6320.js.map +0 -1
  81. package/skinny/dist/render/PlasmicHead.d.ts +0 -35
  82. package/skinny/dist/ssr-68913b60.js +0 -107
  83. package/skinny/dist/ssr-68913b60.js.map +0 -1
  84. package/skinny/dist/ssr-9ebd98ed.js +0 -158
  85. package/skinny/dist/ssr-9ebd98ed.js.map +0 -1
  86. package/skinny/dist/ssr-d3321868.js.map +0 -1
  87. package/skinny/dist/ssr-f4053cdd.js +0 -110
  88. package/skinny/dist/ssr-f4053cdd.js.map +0 -1
  89. package/skinny/dist/ssr-fbf922f6.js +0 -108
  90. package/skinny/dist/ssr-fbf922f6.js.map +0 -1
  91. package/skinny/dist/states/valtio copy.d.ts +0 -15
  92. package/skinny/dist/stories/UseDollarState.test.d.ts +0 -11
  93. package/skinny/dist/stories/UseDollarState2.stories.d.ts +0 -7
  94. package/skinny/dist/tslib.es6-d26ffe68.js +0 -132
  95. package/skinny/dist/tslib.es6-d26ffe68.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../src/plume/select/context.tsx","../../../../src/plume/select/select.tsx","../../../../src/plume/select/select-option.tsx","../../../../src/plume/select/select-option-group.tsx"],"sourcesContent":["import * as React from \"react\";\nimport type { ListState } from \"@react-stately/list\";\n\nexport const SelectContext = React.createContext<ListState<any> | undefined>(\n undefined\n);\n","import { Placement } from \"@react-types/overlays\";\nimport { AriaSelectProps } from \"@react-types/select\";\nimport {\n AriaLabelingProps,\n DOMProps,\n FocusableDOMProps,\n FocusableProps,\n InputBase,\n} from \"@react-types/shared\";\nimport * as React from \"react\";\nimport {\n HiddenSelect,\n useSelect as useAriaSelect,\n} from \"@react-aria/select\";\nimport {\n useListBox\n} from \"@react-aria/listbox\";\nimport {\n usePress\n} from \"@react-aria/interactions\";\nimport {\n SelectState as AriaSelectState,\n useSelectState as useAriaSelectState,\n} from \"@react-stately/select\";\nimport { pick } from \"../../common\";\nimport { mergeProps } from \"../../react-utils\";\nimport { Overrides } from \"../../render/elements\";\nimport { useEnsureSSRProvider } from \"../../render/ssr\";\nimport {\n getChildProp,\n renderAsCollectionChild,\n renderCollectionNode,\n useDerivedItemsFromChildren,\n} from \"../collection-utils\";\nimport {\n AnyPlasmicClass,\n mergeVariantToggles,\n noOutline,\n PlasmicClassArgs,\n PlasmicClassOverrides,\n PlasmicClassVariants,\n VariantDef,\n} from \"../plume-utils\";\nimport { getStyleProps, StyleProps } from \"../props-utils\";\nimport {\n TriggeredOverlayContext,\n TriggeredOverlayContextValue,\n} from \"../triggered-overlay/context\";\nimport { SelectContext } from \"./context\";\nimport { BaseSelectOptionProps } from \"./select-option\";\nimport { BaseSelectOptionGroupProps } from \"./select-option-group\";\n\nexport interface BaseSelectProps\n extends DOMProps,\n AriaLabelingProps,\n FocusableDOMProps,\n InputBase,\n FocusableProps,\n StyleProps {\n /**\n * Key of the currently selected value\n */\n value?: string | null;\n\n /**\n * Event handler fired when currently selected value changes\n */\n onChange?: (value: string | null) => void;\n\n /**\n * Uncontrolled key of the default selected value\n */\n defaultValue?: string;\n\n /**\n * List of Select.Options\n */\n children?: React.ReactNode;\n\n /**\n * Whether the Select is currently open\n */\n isOpen?: boolean;\n\n /**\n * Event handler fired when Select's open state changes\n */\n onOpenChange?: (isOpen: boolean) => void;\n\n /**\n * Uncontrolled default open state\n */\n defaultOpen?: boolean;\n\n /**\n * Form name of the select element\n */\n name?: string;\n\n /**\n * By default, Select will render whatever is in Select.Option as the\n * content in the trigger button when it is selected. You can override\n * what content by passing in `selectedContent` here.\n */\n selectedContent?: React.ReactNode;\n\n /**\n * Desired placement location of the Select dropdown\n */\n placement?: Placement;\n\n /**\n * If true, menu width will always match the trigger button width.\n * If false, then menu width will have min-width matching the\n * trigger button width.\n */\n menuMatchTriggerWidth?: boolean;\n\n /**\n * If set, menu width will be exactly this width, overriding\n * menuMatchTriggerWidth.\n */\n menuWidth?: number;\n\n /**\n * Content to display when nothing is selected.\n */\n placeholder?: React.ReactNode;\n}\n\nconst COLLECTION_OPTS = {\n itemPlumeType: \"select-option\",\n sectionPlumeType: \"select-option-group\",\n};\n\ntype AriaOptionType = React.ReactElement<BaseSelectOptionProps>;\ntype AriaGroupType = React.ReactElement<BaseSelectOptionGroupProps>;\ntype AriaSelectItemType = AriaOptionType | AriaGroupType;\n\n/**\n * Converts props in our BaseSelectProps into props that react-aria's\n * useSelect() understands.\n *\n * Because we're not exposing the Collections API (see ./index.tsx),\n * we are converting our own API into props for useSelect.\n *\n * Specifically, in Plume's API,\n * - `children` flattens to a list of ReactElements of type Select.Option\n * or Select.OptionGroup\n *\n * and we map it this way to the Collections API:\n * - `items` is a list of those flattened ReactElements from `children`!\n * - `children`, as a render prop, is supposed to take one of the `items`\n * and return a `Section` or `Item` element. We take an Option/OptionGroup\n * element, and use its props to render the appropriate `Section` or\n * `Item`. The \"trick\" here is that we then stuff the Option element as\n * `Item.children`, and the OptionGroup element as `Section.title`.\n *\n * When the Collections API does its work deriving `Node`s, the corresponding\n * Option/OptionGroup ReactElements will end up as `Node.rendered`.\n *\n * Then, when we are actually rendering the content of the dropdown, we\n * iterate through each collected `Node`, and renders\n * React.cloneElement(Node.rendered, {_node: node}). This \"secretly\" passes\n * the derived collection `Node` as a prop to Option and OptionGroup, and they\n * can make use of the derived `Node.key` etc in their rendering functions.\n *\n * One thing to note here is that we never \"rendered\" the Option/OptionGroup\n * React elements that the user constructed; instead, we just looked at the\n * props used on those elements, and passed those onto the Collections API.\n * What gets rendered to the screen is the cloned version of these elements\n * with the secret derived `_node` prop. That means Option and OptionGroup\n * render functions can assume that _node is passed in.\n */\nfunction useAriaSelectProps(props: BaseSelectProps) {\n let {\n value,\n defaultValue,\n children,\n onChange,\n placement,\n menuMatchTriggerWidth,\n menuWidth,\n ...rest\n } = props;\n\n const { items, disabledKeys } = useDerivedItemsFromChildren(children, {\n ...COLLECTION_OPTS,\n invalidChildError: `Can only use Select.Option and Select.OptionGroup as children to Select`,\n requireItemValue: true,\n });\n\n const collectionChildRenderer = React.useCallback(\n (child) => renderAsCollectionChild(child, COLLECTION_OPTS),\n []\n );\n\n const onSelectionChange = React.useMemo(() => {\n if (onChange) {\n return (val: string | null) =>\n onChange!(\n (val == null || val === \"null\" ? null : val) as string | null\n );\n } else {\n return undefined;\n }\n }, [onChange]);\n\n return {\n ariaProps: {\n ...rest,\n children: collectionChildRenderer,\n onSelectionChange,\n items,\n disabledKeys,\n defaultSelectedKey: defaultValue,\n\n // react-aria is picky about selectedKey; if it is null, it means \"no selection\";\n // if it is undefined, it means \"uncontrolled\". So here, if the user passes in a\n // value prop, then we make sure selectedKey will be null and not undefined, so\n // we don't accidentally enter uncontrolled mode.\n ...(\"value\" in props && { selectedKey: value ?? null }),\n } as AriaSelectProps<AriaSelectItemType>,\n };\n}\n\nexport type SelectRef = React.Ref<SelectRefValue>;\n\nexport interface SelectRefValue extends SelectState {\n getTrigger: () => HTMLElement | null;\n getRoot: () => HTMLElement | null;\n focus: () => void;\n blur: () => void;\n}\n\ninterface SelectConfig<C extends AnyPlasmicClass> {\n placeholderVariant?: VariantDef<PlasmicClassVariants<C>>;\n isOpenVariant: VariantDef<PlasmicClassVariants<C>>;\n isDisabledVariant?: VariantDef<PlasmicClassVariants<C>>;\n\n triggerContentSlot: keyof PlasmicClassArgs<C>;\n optionsSlot: keyof PlasmicClassArgs<C>;\n placeholderSlot: keyof PlasmicClassArgs<C>;\n\n root: keyof PlasmicClassOverrides<C>;\n trigger: keyof PlasmicClassOverrides<C>;\n overlay: keyof PlasmicClassOverrides<C>;\n optionsContainer: keyof PlasmicClassOverrides<C>;\n}\n\ninterface SelectState {\n open: () => void;\n close: () => void;\n isOpen: () => boolean;\n getSelectedValue: () => string | null;\n setSelectedValue: (value: string | null) => void;\n}\n\nexport function useSelect<P extends BaseSelectProps, C extends AnyPlasmicClass>(\n plasmicClass: C,\n props: P,\n config: SelectConfig<C>,\n ref: React.Ref<SelectRefValue> = null\n) {\n useEnsureSSRProvider();\n const { ariaProps } = useAriaSelectProps(props);\n const { placement } = props;\n const state = useAriaSelectState<AriaSelectItemType>(ariaProps);\n const triggerRef = React.useRef<HTMLButtonElement>(null);\n const rootRef = React.useRef<HTMLElement>(null);\n\n const {\n isDisabled,\n name,\n menuWidth,\n menuMatchTriggerWidth,\n autoFocus,\n placeholder,\n selectedContent,\n } = props;\n\n const { triggerProps: triggerPressProps, menuProps } = useAriaSelect(\n ariaProps,\n state,\n triggerRef\n );\n\n const { pressProps: triggerProps } = usePress({\n ...triggerPressProps,\n isDisabled,\n });\n\n const triggerContent = state.selectedItem\n ? selectedContent ?? getChildProp(state.selectedItem.value, \"children\")\n : null;\n\n const variants = {\n ...pick(props, ...plasmicClass.internalVariantProps),\n ...mergeVariantToggles(\n { def: config.isOpenVariant, active: state.isOpen },\n { def: config.placeholderVariant, active: !state.selectedItem },\n { def: config.isDisabledVariant, active: isDisabled }\n ),\n };\n\n const triggerContext: TriggeredOverlayContextValue = React.useMemo(\n () => ({\n triggerRef,\n state,\n placement,\n overlayMatchTriggerWidth: menuMatchTriggerWidth,\n overlayMinTriggerWidth: true,\n overlayWidth: menuWidth,\n }),\n [triggerRef, state, placement, menuMatchTriggerWidth, menuWidth]\n );\n\n const overrides: Overrides = {\n [config.root]: {\n props: mergeProps(getStyleProps(props), {\n ref: rootRef,\n }),\n wrapChildren: (children) => (\n <>\n <HiddenSelect\n state={state}\n triggerRef={triggerRef}\n name={name}\n isDisabled={isDisabled}\n />\n {children}\n </>\n ),\n },\n [config.trigger]: {\n props: mergeProps(triggerProps, {\n ref: triggerRef,\n autoFocus,\n disabled: !!isDisabled,\n // Don't trigger form submission!\n type: \"button\",\n }),\n },\n [config.overlay]: {\n wrap: (content) => (\n <TriggeredOverlayContext.Provider value={triggerContext}>\n {content}\n </TriggeredOverlayContext.Provider>\n ),\n },\n [config.optionsContainer]: {\n wrap: (content) => (\n <ListBoxWrapper state={state} menuProps={menuProps}>\n {content as React.ReactElement}\n </ListBoxWrapper>\n ),\n },\n };\n\n const args = {\n ...pick(props, ...plasmicClass.internalArgProps),\n [config.triggerContentSlot]: triggerContent,\n [config.placeholderSlot]: placeholder,\n [config.optionsSlot]: (\n <SelectContext.Provider value={state}>\n {Array.from(state.collection).map((node) => renderCollectionNode(node))}\n </SelectContext.Provider>\n ),\n };\n\n const plumeState: SelectState = React.useMemo(\n () => ({\n open: () => state.open(),\n close: () => state.close(),\n isOpen: () => state.isOpen,\n getSelectedValue: () =>\n state.selectedKey ? `${state.selectedKey}` : null,\n setSelectedValue: (key) => state.setSelectedKey(key as any),\n }),\n [state]\n );\n\n React.useImperativeHandle(\n ref,\n () => ({\n getRoot: () => rootRef.current,\n getTrigger: () => triggerRef.current,\n focus: () => triggerRef.current?.focus(),\n blur: () => triggerRef.current?.blur(),\n open: () => plumeState.open(),\n close: () => plumeState.close(),\n isOpen: () => plumeState.isOpen(),\n getSelectedValue: () => plumeState.getSelectedValue(),\n setSelectedValue: (key) => plumeState.setSelectedValue(key),\n }),\n [rootRef, triggerRef, plumeState]\n );\n\n return {\n plasmicProps: {\n variants: variants as PlasmicClassVariants<C>,\n args: args as PlasmicClassArgs<C>,\n overrides: overrides as PlasmicClassOverrides<C>,\n },\n state: plumeState,\n };\n}\n\nfunction ListBoxWrapper(props: {\n state: AriaSelectState<any>;\n menuProps: React.HTMLAttributes<Element>;\n children: React.ReactElement;\n}) {\n const { state, menuProps, children } = props;\n\n const ref = React.useRef<HTMLElement>(null);\n\n const { listBoxProps } = useListBox(\n {\n ...menuProps,\n isVirtualized: false,\n autoFocus: state.focusStrategy || true,\n disallowEmptySelection: true,\n },\n state,\n ref\n );\n\n return React.cloneElement(\n children,\n mergeProps(children.props, listBoxProps, { style: noOutline(), ref })\n );\n}\n","import { Node } from \"@react-types/shared\";\nimport * as React from \"react\";\nimport { useOption as useAriaOption } from \"@react-aria/listbox\";\nimport { pick } from \"../../common\";\nimport { mergeProps, mergeRefs } from \"../../react-utils\";\nimport { Overrides } from \"../../render/elements\";\nimport { ItemLikeProps } from \"../collection-utils\";\nimport {\n AnyPlasmicClass,\n mergeVariantToggles,\n noOutline,\n PlasmicClassArgs,\n PlasmicClassOverrides,\n PlasmicClassVariants,\n PLUME_STRICT_MODE,\n VariantDef,\n} from \"../plume-utils\";\nimport {\n getDefaultPlasmicProps,\n getStyleProps,\n StyleProps,\n} from \"../props-utils\";\nimport { SelectContext } from \"./context\";\n\nexport interface BaseSelectOptionProps extends ItemLikeProps, StyleProps {}\n\ninterface SelectOptionConfig<C extends AnyPlasmicClass> {\n isSelectedVariant: VariantDef<PlasmicClassVariants<C>>;\n isDisabledVariant?: VariantDef<PlasmicClassVariants<C>>;\n isHighlightedVariant?: VariantDef<PlasmicClassVariants<C>>;\n\n labelSlot: keyof PlasmicClassArgs<C>;\n\n root: keyof PlasmicClassOverrides<C>;\n labelContainer: keyof PlasmicClassOverrides<C>;\n}\n\nexport type SelectOptionRef = React.Ref<HTMLElement>;\n\nexport function useSelectOption<\n P extends BaseSelectOptionProps,\n C extends AnyPlasmicClass\n>(\n plasmicClass: C,\n props: P,\n config: SelectOptionConfig<C>,\n outerRef: SelectOptionRef = null\n) {\n const state = React.useContext(SelectContext);\n\n if (!state) {\n // If no context, then we are being incorrectly used. Complain or just don't\n // bother installing any hooks. It's okay to violate rules of hooks here\n // because this instance won't suddenly be used correctly in another render.\n if (PLUME_STRICT_MODE) {\n throw new Error(\n \"You can only use a Select.Option within a Select component.\"\n );\n }\n\n return getDefaultPlasmicProps(plasmicClass, props);\n }\n\n const { children } = props;\n\n const rootRef = React.useRef<HTMLElement>(null);\n const onRef = mergeRefs(rootRef, outerRef);\n\n // We pass in the Node secretly as an undocumented prop from <Select />\n const node = (props as any)._node as Node<\n React.ReactElement<BaseSelectOptionProps>\n >;\n\n const isSelected = state.selectionManager.isSelected(node.key);\n const isDisabled = state.disabledKeys.has(node.key);\n const isHighlighted =\n state.selectionManager.isFocused &&\n state.selectionManager.focusedKey === node.key;\n\n const { optionProps, labelProps } = useAriaOption(\n {\n isSelected,\n isDisabled,\n \"aria-label\": node && node[\"aria-label\"],\n key: node.key,\n shouldSelectOnPressUp: true,\n shouldFocusOnHover: true,\n isVirtualized: false,\n },\n state,\n rootRef\n );\n\n const variants = {\n ...pick(props, ...plasmicClass.internalVariantProps),\n ...mergeVariantToggles(\n { def: config.isSelectedVariant, active: isSelected },\n { def: config.isDisabledVariant, active: isDisabled },\n { def: config.isHighlightedVariant, active: isHighlighted }\n ),\n };\n\n const args = {\n ...pick(props, ...plasmicClass.internalArgProps),\n [config.labelSlot]: children,\n };\n\n const overrides: Overrides = {\n [config.root]: {\n props: mergeProps(optionProps, getStyleProps(props), {\n ref: onRef,\n style: noOutline(),\n }),\n },\n [config.labelContainer]: {\n props: labelProps,\n },\n };\n\n return {\n plasmicProps: {\n variants: variants as PlasmicClassVariants<C>,\n args: args as PlasmicClassArgs<C>,\n overrides: overrides as PlasmicClassOverrides<C>,\n },\n };\n}\n","import { Node } from \"@react-types/shared\";\nimport * as React from \"react\";\nimport { useListBoxSection } from \"@react-aria/listbox\";\nimport { useSeparator } from \"@react-aria/separator\";\nimport { pick } from \"../../common\";\nimport { Overrides } from \"../../render/elements\";\nimport { renderCollectionNode, SectionLikeProps } from \"../collection-utils\";\nimport {\n AnyPlasmicClass,\n mergeVariantToggles,\n PlasmicClassArgs,\n PlasmicClassOverrides,\n PlasmicClassVariants,\n PLUME_STRICT_MODE,\n} from \"../plume-utils\";\nimport {\n getDefaultPlasmicProps,\n getStyleProps,\n StyleProps,\n} from \"../props-utils\";\nimport { SelectContext } from \"./context\";\n\nexport interface BaseSelectOptionGroupProps\n extends SectionLikeProps,\n StyleProps {}\n\ninterface SelectOptionGroupConfig<C extends AnyPlasmicClass> {\n noTitleVariant: PlasmicClassVariants<C>;\n isFirstVariant: PlasmicClassVariants<C>;\n\n optionsSlot: keyof PlasmicClassArgs<C>;\n titleSlot: keyof PlasmicClassArgs<C>;\n\n root: keyof PlasmicClassOverrides<C>;\n separator: keyof PlasmicClassOverrides<C>;\n titleContainer: keyof PlasmicClassOverrides<C>;\n optionsContainer: keyof PlasmicClassOverrides<C>;\n}\n\nexport function useSelectOptionGroup<\n P extends BaseSelectOptionGroupProps,\n C extends AnyPlasmicClass\n>(plasmicClass: C, props: P, config: SelectOptionGroupConfig<C>) {\n const state = React.useContext(SelectContext);\n\n // `node` should exist if the OptionGroup was instantiated properly\n // within a Select\n const node = (props as any)._node as\n | Node<React.ReactElement<BaseSelectOptionGroupProps>>\n | undefined;\n\n if (!state || !node) {\n if (PLUME_STRICT_MODE) {\n throw new Error(\n \"You can only use a Select.OptionGroup within a Select component.\"\n );\n }\n return getDefaultPlasmicProps(plasmicClass, props);\n }\n\n const { headingProps, groupProps } = useListBoxSection({\n heading: props.title,\n \"aria-label\": props[\"aria-label\"],\n });\n\n const { separatorProps } = useSeparator({\n elementType: \"li\",\n });\n\n const variants = {\n ...pick(props, ...plasmicClass.internalVariantProps),\n ...mergeVariantToggles(\n { def: config.noTitleVariant, active: !props.title },\n {\n def: config.isFirstVariant,\n active: state.collection.getFirstKey() === node.key,\n }\n ),\n };\n\n const args = {\n ...pick(props, ...plasmicClass.internalArgProps),\n [config.titleSlot]: props.title,\n [config.optionsSlot]: Array.from(node.childNodes).map((childNode) =>\n renderCollectionNode(childNode)\n ),\n };\n\n const overrides: Overrides = {\n [config.root]: {\n props: getStyleProps(props),\n },\n [config.separator]: {\n props: {\n ...separatorProps,\n },\n },\n [config.titleContainer]: {\n props: {\n role: \"presentation\",\n ...headingProps,\n },\n ...(!props.title && {\n render: () => null,\n }),\n },\n [config.optionsContainer]: {\n props: {\n ...groupProps,\n },\n },\n };\n\n return {\n plasmicProps: {\n variants: variants as PlasmicClassVariants<C>,\n args: args as PlasmicClassArgs<C>,\n overrides: overrides as PlasmicClassOverrides<C>,\n },\n };\n}\n"],"names":["useAriaSelectState","useAriaSelect","useAriaOption"],"mappings":";;;;;;;;;;;;;;;;;;;IAGa,aAAa,GAAG,KAAK,CAAC,aAAa,CAC9C,SAAS;;AC8HX,IAAM,eAAe,GAAG;IACtB,aAAa,EAAE,eAAe;IAC9B,gBAAgB,EAAE,qBAAqB;CACxC,CAAC;AAMF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,SAAS,kBAAkB,CAAC,KAAsB;QAE9C,KAAK,GAQH,KAAK,MARF,EACL,YAAY,GAOV,KAAK,aAPK,EACZ,QAAQ,GAMN,KAAK,SANC,EACR,QAAQ,GAKN,KAAK,SALC,EAKN,KAAK,UAJE,EAIP,KAAK,sBAHc,EAGnB,KAAK,UAFE,MACN,IAAI,UACL,KAAK,EATL,oGASH,EAAS;IAEJ,IAAA,KAA0B,2BAA2B,CAAC,QAAQ,wBAC/D,eAAe,KAClB,iBAAiB,EAAE,yEAAyE,EAC5F,gBAAgB,EAAE,IAAI,IACtB,EAJM,KAAK,WAAA,EAAE,YAAY,kBAIzB,CAAC;IAEH,IAAM,uBAAuB,GAAG,KAAK,CAAC,WAAW,CAC/C,UAAC,KAAK,IAAK,OAAA,uBAAuB,CAAC,KAAK,EAAE,eAAe,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AAI,IAAG;YACb,KAAK,EAAE,aAAa,CAAC,KAAK,CAAC;SAC5B;QACD,GAAC,MAAM,CAAC,SAAS,IAAG;YAClB,KAAK,eACA,cAAc,CAClB;SACF;QACD,GAAC,MAAM,CAAC,cAAc,eACpB,KAAK,aACH,IAAI,EAAE,cAAc,IACjB,YAAY,MAEb,CAAC,KAAK,CAAC,KAAK,IAAI;YAClB,MAAM,EAAE,cAAM,OAAA,IAAI,GAAA;SACnB,EACF;QACD,GAAC,MAAM,CAAC,gBAAgB,IAAG;YACzB,KAAK,eACA,UAAU,CACd;SACF;WACF,CAAC;IAEF,OAAO;QACL,YAAY,EAAE;YACZ,QAAQ,EAAE,QAAmC;YAC7C,IAAI,EAAE,IAA2B;YACjC,SAAS,EAAE,SAAqC;SACjD;KACF,CAAC;AACJ;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../src/plume/select/context.tsx","../../../../src/plume/select/select.tsx","../../../../src/plume/select/select-option.tsx","../../../../src/plume/select/select-option-group.tsx"],"sourcesContent":["import * as React from \"react\";\nimport type { ListState } from \"@react-stately/list\";\n\nexport const SelectContext = React.createContext<ListState<any> | undefined>(\n undefined\n);\n","import { Placement } from \"@react-types/overlays\";\nimport { AriaSelectProps } from \"@react-types/select\";\nimport {\n AriaLabelingProps,\n DOMProps,\n FocusableDOMProps,\n FocusableProps,\n InputBase,\n} from \"@react-types/shared\";\nimport * as React from \"react\";\nimport {\n HiddenSelect,\n useSelect as useAriaSelect,\n} from \"@react-aria/select\";\nimport {\n useListBox\n} from \"@react-aria/listbox\";\nimport {\n usePress\n} from \"@react-aria/interactions\";\nimport {\n SelectState as AriaSelectState,\n useSelectState as useAriaSelectState,\n} from \"@react-stately/select\";\nimport { pick } from \"../../common\";\nimport { mergeProps } from \"../../react-utils\";\nimport { Overrides } from \"../../render/elements\";\nimport { useEnsureSSRProvider } from \"../../render/ssr\";\nimport {\n getChildProp,\n renderAsCollectionChild,\n renderCollectionNode,\n useDerivedItemsFromChildren,\n} from \"../collection-utils\";\nimport {\n AnyPlasmicClass,\n mergeVariantToggles,\n noOutline,\n PlasmicClassArgs,\n PlasmicClassOverrides,\n PlasmicClassVariants,\n VariantDef,\n} from \"../plume-utils\";\nimport { getStyleProps, StyleProps } from \"../props-utils\";\nimport {\n TriggeredOverlayContext,\n TriggeredOverlayContextValue,\n} from \"../triggered-overlay/context\";\nimport { SelectContext } from \"./context\";\nimport { BaseSelectOptionProps } from \"./select-option\";\nimport { BaseSelectOptionGroupProps } from \"./select-option-group\";\n\nexport interface BaseSelectProps\n extends DOMProps,\n AriaLabelingProps,\n FocusableDOMProps,\n InputBase,\n FocusableProps,\n StyleProps {\n /**\n * Key of the currently selected value\n */\n value?: string | null;\n\n /**\n * Event handler fired when currently selected value changes\n */\n onChange?: (value: string | null) => void;\n\n /**\n * Uncontrolled key of the default selected value\n */\n defaultValue?: string;\n\n /**\n * List of Select.Options\n */\n children?: React.ReactNode;\n\n /**\n * Whether the Select is currently open\n */\n isOpen?: boolean;\n\n /**\n * Event handler fired when Select's open state changes\n */\n onOpenChange?: (isOpen: boolean) => void;\n\n /**\n * Uncontrolled default open state\n */\n defaultOpen?: boolean;\n\n /**\n * Form name of the select element\n */\n name?: string;\n\n /**\n * By default, Select will render whatever is in Select.Option as the\n * content in the trigger button when it is selected. You can override\n * what content by passing in `selectedContent` here.\n */\n selectedContent?: React.ReactNode;\n\n /**\n * Desired placement location of the Select dropdown\n */\n placement?: Placement;\n\n /**\n * If true, menu width will always match the trigger button width.\n * If false, then menu width will have min-width matching the\n * trigger button width.\n */\n menuMatchTriggerWidth?: boolean;\n\n /**\n * If set, menu width will be exactly this width, overriding\n * menuMatchTriggerWidth.\n */\n menuWidth?: number;\n\n /**\n * Content to display when nothing is selected.\n */\n placeholder?: React.ReactNode;\n}\n\nconst COLLECTION_OPTS = {\n itemPlumeType: \"select-option\",\n sectionPlumeType: \"select-option-group\",\n};\n\ntype AriaOptionType = React.ReactElement<BaseSelectOptionProps>;\ntype AriaGroupType = React.ReactElement<BaseSelectOptionGroupProps>;\ntype AriaSelectItemType = AriaOptionType | AriaGroupType;\n\n/**\n * Converts props in our BaseSelectProps into props that react-aria's\n * useSelect() understands.\n *\n * Because we're not exposing the Collections API (see ./index.tsx),\n * we are converting our own API into props for useSelect.\n *\n * Specifically, in Plume's API,\n * - `children` flattens to a list of ReactElements of type Select.Option\n * or Select.OptionGroup\n *\n * and we map it this way to the Collections API:\n * - `items` is a list of those flattened ReactElements from `children`!\n * - `children`, as a render prop, is supposed to take one of the `items`\n * and return a `Section` or `Item` element. We take an Option/OptionGroup\n * element, and use its props to render the appropriate `Section` or\n * `Item`. The \"trick\" here is that we then stuff the Option element as\n * `Item.children`, and the OptionGroup element as `Section.title`.\n *\n * When the Collections API does its work deriving `Node`s, the corresponding\n * Option/OptionGroup ReactElements will end up as `Node.rendered`.\n *\n * Then, when we are actually rendering the content of the dropdown, we\n * iterate through each collected `Node`, and renders\n * React.cloneElement(Node.rendered, {_node: node}). This \"secretly\" passes\n * the derived collection `Node` as a prop to Option and OptionGroup, and they\n * can make use of the derived `Node.key` etc in their rendering functions.\n *\n * One thing to note here is that we never \"rendered\" the Option/OptionGroup\n * React elements that the user constructed; instead, we just looked at the\n * props used on those elements, and passed those onto the Collections API.\n * What gets rendered to the screen is the cloned version of these elements\n * with the secret derived `_node` prop. That means Option and OptionGroup\n * render functions can assume that _node is passed in.\n */\nfunction useAriaSelectProps(props: BaseSelectProps) {\n let {\n value,\n defaultValue,\n children,\n onChange,\n placement,\n menuMatchTriggerWidth,\n menuWidth,\n ...rest\n } = props;\n\n const { items, disabledKeys } = useDerivedItemsFromChildren(children, {\n ...COLLECTION_OPTS,\n invalidChildError: `Can only use Select.Option and Select.OptionGroup as children to Select`,\n requireItemValue: true,\n });\n\n const collectionChildRenderer = React.useCallback(\n (child) => renderAsCollectionChild(child, COLLECTION_OPTS),\n []\n );\n\n const onSelectionChange = React.useMemo(() => {\n if (onChange) {\n return (val: string | null) =>\n onChange!(\n (val == null || val === \"null\" ? null : val) as string | null\n );\n } else {\n return undefined;\n }\n }, [onChange]);\n\n return {\n ariaProps: {\n ...rest,\n children: collectionChildRenderer,\n onSelectionChange,\n items,\n disabledKeys,\n defaultSelectedKey: defaultValue,\n\n // react-aria is picky about selectedKey; if it is null, it means \"no selection\";\n // if it is undefined, it means \"uncontrolled\". So here, if the user passes in a\n // value prop, then we make sure selectedKey will be null and not undefined, so\n // we don't accidentally enter uncontrolled mode.\n ...(\"value\" in props && { selectedKey: value ?? null }),\n } as AriaSelectProps<AriaSelectItemType>,\n };\n}\n\nexport type SelectRef = React.Ref<SelectRefValue>;\n\nexport interface SelectRefValue extends SelectState {\n getTrigger: () => HTMLElement | null;\n getRoot: () => HTMLElement | null;\n focus: () => void;\n blur: () => void;\n}\n\ninterface SelectConfig<C extends AnyPlasmicClass> {\n placeholderVariant?: VariantDef<PlasmicClassVariants<C>>;\n isOpenVariant: VariantDef<PlasmicClassVariants<C>>;\n isDisabledVariant?: VariantDef<PlasmicClassVariants<C>>;\n\n triggerContentSlot: keyof PlasmicClassArgs<C>;\n optionsSlot: keyof PlasmicClassArgs<C>;\n placeholderSlot: keyof PlasmicClassArgs<C>;\n\n root: keyof PlasmicClassOverrides<C>;\n trigger: keyof PlasmicClassOverrides<C>;\n overlay: keyof PlasmicClassOverrides<C>;\n optionsContainer: keyof PlasmicClassOverrides<C>;\n}\n\ninterface SelectState {\n open: () => void;\n close: () => void;\n isOpen: () => boolean;\n getSelectedValue: () => string | null;\n setSelectedValue: (value: string | null) => void;\n}\n\nexport function useSelect<P extends BaseSelectProps, C extends AnyPlasmicClass>(\n plasmicClass: C,\n props: P,\n config: SelectConfig<C>,\n ref: React.Ref<SelectRefValue> = null\n) {\n useEnsureSSRProvider();\n const { ariaProps } = useAriaSelectProps(props);\n const { placement } = props;\n const state = useAriaSelectState<AriaSelectItemType>(ariaProps);\n const triggerRef = React.useRef<HTMLButtonElement>(null);\n const rootRef = React.useRef<HTMLElement>(null);\n\n const {\n isDisabled,\n name,\n menuWidth,\n menuMatchTriggerWidth,\n autoFocus,\n placeholder,\n selectedContent,\n } = props;\n\n const { triggerProps: triggerPressProps, menuProps } = useAriaSelect(\n ariaProps,\n state,\n triggerRef\n );\n\n const { pressProps: triggerProps } = usePress({\n ...triggerPressProps,\n isDisabled,\n });\n\n const triggerContent = state.selectedItem\n ? selectedContent ?? getChildProp(state.selectedItem.value, \"children\")\n : null;\n\n const variants = {\n ...pick(props, ...plasmicClass.internalVariantProps),\n ...mergeVariantToggles(\n { def: config.isOpenVariant, active: state.isOpen },\n { def: config.placeholderVariant, active: !state.selectedItem },\n { def: config.isDisabledVariant, active: isDisabled }\n ),\n };\n\n const triggerContext: TriggeredOverlayContextValue = React.useMemo(\n () => ({\n triggerRef,\n state,\n placement,\n overlayMatchTriggerWidth: menuMatchTriggerWidth,\n overlayMinTriggerWidth: true,\n overlayWidth: menuWidth,\n }),\n [triggerRef, state, placement, menuMatchTriggerWidth, menuWidth]\n );\n\n const overrides: Overrides = {\n [config.root]: {\n props: mergeProps(getStyleProps(props), {\n ref: rootRef,\n }),\n wrapChildren: (children) => (\n <>\n <HiddenSelect\n state={state}\n triggerRef={triggerRef}\n name={name}\n isDisabled={isDisabled}\n />\n {children}\n </>\n ),\n },\n [config.trigger]: {\n props: mergeProps(triggerProps, {\n ref: triggerRef,\n autoFocus,\n disabled: !!isDisabled,\n // Don't trigger form submission!\n type: \"button\",\n }),\n },\n [config.overlay]: {\n wrap: (content) => (\n <TriggeredOverlayContext.Provider value={triggerContext}>\n {content}\n </TriggeredOverlayContext.Provider>\n ),\n },\n [config.optionsContainer]: {\n wrap: (content) => (\n <ListBoxWrapper state={state} menuProps={menuProps}>\n {content as React.ReactElement}\n </ListBoxWrapper>\n ),\n },\n };\n\n const args = {\n ...pick(props, ...plasmicClass.internalArgProps),\n [config.triggerContentSlot]: triggerContent,\n [config.placeholderSlot]: placeholder,\n [config.optionsSlot]: (\n <SelectContext.Provider value={state}>\n {Array.from(state.collection).map((node) => renderCollectionNode(node))}\n </SelectContext.Provider>\n ),\n };\n\n const plumeState: SelectState = React.useMemo(\n () => ({\n open: () => state.open(),\n close: () => state.close(),\n isOpen: () => state.isOpen,\n getSelectedValue: () =>\n state.selectedKey ? `${state.selectedKey}` : null,\n setSelectedValue: (key) => state.setSelectedKey(key as any),\n }),\n [state]\n );\n\n React.useImperativeHandle(\n ref,\n () => ({\n getRoot: () => rootRef.current,\n getTrigger: () => triggerRef.current,\n focus: () => triggerRef.current?.focus(),\n blur: () => triggerRef.current?.blur(),\n open: () => plumeState.open(),\n close: () => plumeState.close(),\n isOpen: () => plumeState.isOpen(),\n getSelectedValue: () => plumeState.getSelectedValue(),\n setSelectedValue: (key) => plumeState.setSelectedValue(key),\n }),\n [rootRef, triggerRef, plumeState]\n );\n\n return {\n plasmicProps: {\n variants: variants as PlasmicClassVariants<C>,\n args: args as PlasmicClassArgs<C>,\n overrides: overrides as PlasmicClassOverrides<C>,\n },\n state: plumeState,\n };\n}\n\nfunction ListBoxWrapper(props: {\n state: AriaSelectState<any>;\n menuProps: React.HTMLAttributes<Element>;\n children: React.ReactElement;\n}) {\n const { state, menuProps, children } = props;\n\n const ref = React.useRef<HTMLElement>(null);\n\n const { listBoxProps } = useListBox(\n {\n ...menuProps,\n isVirtualized: false,\n autoFocus: state.focusStrategy || true,\n disallowEmptySelection: true,\n },\n state,\n ref\n );\n\n return React.cloneElement(\n children,\n mergeProps(children.props, listBoxProps, { style: noOutline(), ref })\n );\n}\n","import { Node } from \"@react-types/shared\";\nimport * as React from \"react\";\nimport { useOption as useAriaOption } from \"@react-aria/listbox\";\nimport { pick } from \"../../common\";\nimport { mergeProps, mergeRefs } from \"../../react-utils\";\nimport { Overrides } from \"../../render/elements\";\nimport { ItemLikeProps } from \"../collection-utils\";\nimport {\n AnyPlasmicClass,\n mergeVariantToggles,\n noOutline,\n PlasmicClassArgs,\n PlasmicClassOverrides,\n PlasmicClassVariants,\n PLUME_STRICT_MODE,\n VariantDef,\n} from \"../plume-utils\";\nimport {\n getDefaultPlasmicProps,\n getStyleProps,\n StyleProps,\n} from \"../props-utils\";\nimport { SelectContext } from \"./context\";\n\nexport interface BaseSelectOptionProps extends ItemLikeProps, StyleProps {}\n\ninterface SelectOptionConfig<C extends AnyPlasmicClass> {\n isSelectedVariant: VariantDef<PlasmicClassVariants<C>>;\n isDisabledVariant?: VariantDef<PlasmicClassVariants<C>>;\n isHighlightedVariant?: VariantDef<PlasmicClassVariants<C>>;\n\n labelSlot: keyof PlasmicClassArgs<C>;\n\n root: keyof PlasmicClassOverrides<C>;\n labelContainer: keyof PlasmicClassOverrides<C>;\n}\n\nexport type SelectOptionRef = React.Ref<HTMLElement>;\n\nexport function useSelectOption<\n P extends BaseSelectOptionProps,\n C extends AnyPlasmicClass\n>(\n plasmicClass: C,\n props: P,\n config: SelectOptionConfig<C>,\n outerRef: SelectOptionRef = null\n) {\n const state = React.useContext(SelectContext);\n\n if (!state) {\n // If no context, then we are being incorrectly used. Complain or just don't\n // bother installing any hooks. It's okay to violate rules of hooks here\n // because this instance won't suddenly be used correctly in another render.\n if (PLUME_STRICT_MODE) {\n throw new Error(\n \"You can only use a Select.Option within a Select component.\"\n );\n }\n\n return getDefaultPlasmicProps(plasmicClass, props);\n }\n\n const { children } = props;\n\n const rootRef = React.useRef<HTMLElement>(null);\n const onRef = mergeRefs(rootRef, outerRef);\n\n // We pass in the Node secretly as an undocumented prop from <Select />\n const node = (props as any)._node as Node<\n React.ReactElement<BaseSelectOptionProps>\n >;\n\n const isSelected = state.selectionManager.isSelected(node.key);\n const isDisabled = state.disabledKeys.has(node.key);\n const isHighlighted =\n state.selectionManager.isFocused &&\n state.selectionManager.focusedKey === node.key;\n\n const { optionProps, labelProps } = useAriaOption(\n {\n isSelected,\n isDisabled,\n \"aria-label\": node && node[\"aria-label\"],\n key: node.key,\n shouldSelectOnPressUp: true,\n shouldFocusOnHover: true,\n isVirtualized: false,\n },\n state,\n rootRef\n );\n\n const variants = {\n ...pick(props, ...plasmicClass.internalVariantProps),\n ...mergeVariantToggles(\n { def: config.isSelectedVariant, active: isSelected },\n { def: config.isDisabledVariant, active: isDisabled },\n { def: config.isHighlightedVariant, active: isHighlighted }\n ),\n };\n\n const args = {\n ...pick(props, ...plasmicClass.internalArgProps),\n [config.labelSlot]: children,\n };\n\n const overrides: Overrides = {\n [config.root]: {\n props: mergeProps(optionProps, getStyleProps(props), {\n ref: onRef,\n style: noOutline(),\n }),\n },\n [config.labelContainer]: {\n props: labelProps,\n },\n };\n\n return {\n plasmicProps: {\n variants: variants as PlasmicClassVariants<C>,\n args: args as PlasmicClassArgs<C>,\n overrides: overrides as PlasmicClassOverrides<C>,\n },\n };\n}\n","import { Node } from \"@react-types/shared\";\nimport * as React from \"react\";\nimport { useListBoxSection } from \"@react-aria/listbox\";\nimport { useSeparator } from \"@react-aria/separator\";\nimport { pick } from \"../../common\";\nimport { Overrides } from \"../../render/elements\";\nimport { renderCollectionNode, SectionLikeProps } from \"../collection-utils\";\nimport {\n AnyPlasmicClass,\n mergeVariantToggles,\n PlasmicClassArgs,\n PlasmicClassOverrides,\n PlasmicClassVariants,\n PLUME_STRICT_MODE,\n} from \"../plume-utils\";\nimport {\n getDefaultPlasmicProps,\n getStyleProps,\n StyleProps,\n} from \"../props-utils\";\nimport { SelectContext } from \"./context\";\n\nexport interface BaseSelectOptionGroupProps\n extends SectionLikeProps,\n StyleProps {}\n\ninterface SelectOptionGroupConfig<C extends AnyPlasmicClass> {\n noTitleVariant: PlasmicClassVariants<C>;\n isFirstVariant: PlasmicClassVariants<C>;\n\n optionsSlot: keyof PlasmicClassArgs<C>;\n titleSlot: keyof PlasmicClassArgs<C>;\n\n root: keyof PlasmicClassOverrides<C>;\n separator: keyof PlasmicClassOverrides<C>;\n titleContainer: keyof PlasmicClassOverrides<C>;\n optionsContainer: keyof PlasmicClassOverrides<C>;\n}\n\nexport function useSelectOptionGroup<\n P extends BaseSelectOptionGroupProps,\n C extends AnyPlasmicClass\n>(plasmicClass: C, props: P, config: SelectOptionGroupConfig<C>) {\n const state = React.useContext(SelectContext);\n\n // `node` should exist if the OptionGroup was instantiated properly\n // within a Select\n const node = (props as any)._node as\n | Node<React.ReactElement<BaseSelectOptionGroupProps>>\n | undefined;\n\n if (!state || !node) {\n if (PLUME_STRICT_MODE) {\n throw new Error(\n \"You can only use a Select.OptionGroup within a Select component.\"\n );\n }\n return getDefaultPlasmicProps(plasmicClass, props);\n }\n\n const { headingProps, groupProps } = useListBoxSection({\n heading: props.title,\n \"aria-label\": props[\"aria-label\"],\n });\n\n const { separatorProps } = useSeparator({\n elementType: \"li\",\n });\n\n const variants = {\n ...pick(props, ...plasmicClass.internalVariantProps),\n ...mergeVariantToggles(\n { def: config.noTitleVariant, active: !props.title },\n {\n def: config.isFirstVariant,\n active: state.collection.getFirstKey() === node.key,\n }\n ),\n };\n\n const args = {\n ...pick(props, ...plasmicClass.internalArgProps),\n [config.titleSlot]: props.title,\n [config.optionsSlot]: Array.from(node.childNodes).map((childNode) =>\n renderCollectionNode(childNode)\n ),\n };\n\n const overrides: Overrides = {\n [config.root]: {\n props: getStyleProps(props),\n },\n [config.separator]: {\n props: {\n ...separatorProps,\n },\n },\n [config.titleContainer]: {\n props: {\n role: \"presentation\",\n ...headingProps,\n },\n ...(!props.title && {\n render: () => null,\n }),\n },\n [config.optionsContainer]: {\n props: {\n ...groupProps,\n },\n },\n };\n\n return {\n plasmicProps: {\n variants: variants as PlasmicClassVariants<C>,\n args: args as PlasmicClassArgs<C>,\n overrides: overrides as PlasmicClassOverrides<C>,\n },\n };\n}\n"],"names":["useAriaSelectState","useAriaSelect","useAriaOption"],"mappings":";;;;;;;;;;;;;;;;;;;IAGa,aAAa,GAAG,KAAK,CAAC,aAAa,CAC9C,SAAS;;AC8HX,IAAM,eAAe,GAAG;IACtB,aAAa,EAAE,eAAe;IAC9B,gBAAgB,EAAE,qBAAqB;CACxC,CAAC;AAMF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,cAAc,EAAE,MAAM,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,EACpD;QACE,GAAG,EAAE,MAAM,CAAC,cAAc;QAC1B,MAAM,EAAE,KAAK,CAAC,UAAU,CAAC,WAAW,EAAE,KAAK,IAAI,CAAC,GAAG;KACpD,CACF,CACF,CAAC;IAEF,IAAM,IAAI,yBACL,IAAI,8BAAC,KAAK,UAAK,YAAY,CAAC,gBAAgB,0BAC9C,MAAM,CAAC,SAAS,IAAG,KAAK,CAAC,KAAK,KAC9B,MAAM,CAAC,WAAW,IAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,UAAC,SAAS;QAC9D,OAAA,oBAAoB,CAAC,SAAS,CAAC;KAAA,CAChC,MACF,CAAC;IAEF,IAAM,SAAS;QACb,GAAC,MAAM,CAAC,IAAI,IAAG;YACb,KAAK,EAAE,aAAa,CAAC,KAAK,CAAC;SAC5B;QACD,GAAC,MAAM,CAAC,SAAS,IAAG;YAClB,KAAK,eACA,cAAc,CAClB;SACF;QACD,GAAC,MAAM,CAAC,cAAc,eACpB,KAAK,aACH,IAAI,EAAE,cAAc,IACjB,YAAY,MAEb,CAAC,KAAK,CAAC,KAAK,IAAI;YAClB,MAAM,EAAE,cAAM,OAAA,IAAI,GAAA;SACnB,EACF;QACD,GAAC,MAAM,CAAC,gBAAgB,IAAG;YACzB,KAAK,eACA,UAAU,CACd;SACF;WACF,CAAC;IAEF,OAAO;QACL,YAAY,EAAE;YACZ,QAAQ,EAAE,QAAmC;YAC7C,IAAI,EAAE,IAA2B;YACjC,SAAS,EAAE,SAAqC;SACjD;KACF,CAAC;AACJ;;;;"}
@@ -1,12 +1,12 @@
1
- import { a as __assign, p as pick, b as __spreadArray, c as __read } from '../../common-182a0b0c.js';
1
+ import { a as __assign, p as pick, b as __spreadArray, c as __read } from '../../common-9ebe374e.js';
2
2
  import * as React from 'react';
3
3
  import { useSwitch as useSwitch$1 } from '@react-aria/switch';
4
4
  import { VisuallyHidden } from '@react-aria/visually-hidden';
5
5
  import { useToggleState } from '@react-stately/toggle';
6
- import { m as mergeProps } from '../../react-utils-35cb2a4e.js';
7
- import { a as useEnsureSSRProvider } from '../../ssr-d3321868.js';
8
- import { m as mergeVariantToggles } from '../../plume-utils-623b91cc.js';
9
- import { g as getStyleProps } from '../../props-utils-b2ad4997.js';
6
+ import { m as mergeProps } from '../../react-utils-7bc53870.js';
7
+ import { a as useEnsureSSRProvider } from '../../ssr-b16a1854.js';
8
+ import { m as mergeVariantToggles } from '../../plume-utils-d9811bf3.js';
9
+ import { g as getStyleProps } from '../../props-utils-228208e6.js';
10
10
  import 'classnames';
11
11
  import '@plasmicapp/data-sources-context';
12
12
  import '@react-aria/ssr';
@@ -28,45 +28,45 @@ function useSwitch(plasmicClass, props, config, ref) {
28
28
  var ariaProps = asAriaSwitchProps(props);
29
29
  var state = useToggleState(ariaProps);
30
30
  var inputProps = useSwitch$1(ariaProps, state, inputRef).inputProps;
31
- var variants = __assign(__assign({}, pick.apply(void 0, __spreadArray([props], __read(plasmicClass.internalVariantProps)))), mergeVariantToggles({
31
+ var variants = __assign(__assign({}, pick.apply(void 0, __spreadArray([props], __read(plasmicClass.internalVariantProps), false))), mergeVariantToggles({
32
32
  def: config.isDisabledVariant,
33
- active: isDisabled,
33
+ active: isDisabled
34
34
  }, {
35
35
  def: config.isCheckedVariant,
36
- active: state.isSelected,
36
+ active: state.isSelected
37
37
  }, {
38
38
  def: config.noLabelVariant,
39
- active: !children,
39
+ active: !children
40
40
  }));
41
41
  var overrides = (_a = {},
42
42
  _a[config.root] = {
43
43
  as: "label",
44
44
  props: mergeProps(getStyleProps(props), {
45
- ref: rootRef,
45
+ ref: rootRef
46
46
  }),
47
47
  wrapChildren: function (children) { return (React.createElement(React.Fragment, null,
48
48
  React.createElement(VisuallyHidden, { isFocusable: true },
49
49
  React.createElement("input", __assign({}, inputProps, { ref: inputRef }))),
50
- children)); },
50
+ children)); }
51
51
  },
52
52
  _a);
53
- var args = __assign(__assign({}, pick.apply(void 0, __spreadArray([props], __read(plasmicClass.internalArgProps)))), (config.labelSlot ? (_b = {}, _b[config.labelSlot] = children, _b) : {}));
53
+ var args = __assign(__assign({}, pick.apply(void 0, __spreadArray([props], __read(plasmicClass.internalArgProps), false))), (config.labelSlot ? (_b = {}, _b[config.labelSlot] = children, _b) : {}));
54
54
  var plumeState = React.useMemo(function () { return ({
55
- setChecked: function (checked) { return state.setSelected(checked); },
55
+ setChecked: function (checked) { return state.setSelected(checked); }
56
56
  }); }, [state]);
57
57
  React.useImperativeHandle(ref, function () { return ({
58
58
  getRoot: function () { return rootRef.current; },
59
59
  focus: function () { var _a; return (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus(); },
60
60
  blur: function () { var _a; return (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.blur(); },
61
- setChecked: function (checked) { return plumeState.setChecked(checked); },
61
+ setChecked: function (checked) { return plumeState.setChecked(checked); }
62
62
  }); }, [rootRef, inputRef, plumeState]);
63
63
  return {
64
64
  plasmicProps: {
65
65
  variants: variants,
66
66
  overrides: overrides,
67
- args: args,
67
+ args: args
68
68
  },
69
- state: plumeState,
69
+ state: plumeState
70
70
  };
71
71
  }
72
72
 
@@ -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,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,CAAC;AACnB,CAAC;SAUe,SAAS,CACvB,YAAe,EACf,KAAQ,EACR,MAAuB,EACvB,GAAqB;;IAArB,oBAAA,EAAA,UAAqB;IAEb,IAAA,QAAQ,GAAiB,KAAK,SAAtB,EAAE,UAAU,GAAK,KAAK,WAAV,CAAW;IACvC,oBAAoB,EAAE,CAAC;IACvB,IAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAmB,IAAI,CAAC,CAAC;IACtD,IAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAc,IAAI,CAAC,CAAC;IAChD,IAAM,SAAS,GAAG,iB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BAAmB,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;;;;"}
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,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,CAAC;AACnB,CAAC;SAUe,SAAS,CACvB,YAAe,EACf,KAAQ,EACR,MAAuB,EACvB,GAAqB;;IAArB,oBAAA,EAAA,UAAqB;IAEb,IAAA,QAAQ,GAAiB,KAAK,SAAtB,EAAE,UAAU,GAAK,KAAK,WAAV,CAAW;IACvC,oBAAoB,EAAE,CAAC;IACvB,IAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAmB,IAAI,CAAC,CAAC;IACtD,IAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAc,IAAI,CAAC,CAAC;IAChD,IAAM,SAAS,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAC;IAC3C,IAAM,KAAK,GAAG,cAAc,CAAC,SAAS,CAAC,CAAC;IAChC,IAAA,UAAU,GAAKA,WAAa,CAAC,SAAS,EAAE,KAAK,EAAE,QAAQ,CAAC,WAA9C,CAA+C;IACjE,IAAM,QAAQ,yBACT,IAAI,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AA,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;;;;"}
@@ -1,6 +1,6 @@
1
- import { _ as __rest, a as __assign, p as pick, b as __spreadArray, c as __read, o as omit } from '../../common-182a0b0c.js';
1
+ import { _ as __rest, a as __assign, p as pick, b as __spreadArray, c as __read, o as omit } from '../../common-9ebe374e.js';
2
2
  import * as React from 'react';
3
- import { m as mergeVariantToggles } from '../../plume-utils-623b91cc.js';
3
+ import { m as mergeVariantToggles } from '../../plume-utils-d9811bf3.js';
4
4
 
5
5
  function useTextInput(plasmicClass, props, config, ref) {
6
6
  var _a, _b, _c;
@@ -22,28 +22,28 @@ function useTextInput(plasmicClass, props, config, ref) {
22
22
  },
23
23
  getInput: function () {
24
24
  return inputRef.current;
25
- },
25
+ }
26
26
  }); }, [rootRef, inputRef]);
27
- var variants = __assign(__assign({}, pick.apply(void 0, __spreadArray([props], __read(plasmicClass.internalVariantProps)))), mergeVariantToggles({ def: config.showStartIconVariant, active: showStartIcon }, { def: config.showEndIconVariant, active: showEndIcon }, { def: config.isDisabledVariant, active: isDisabled }));
28
- var args = __assign(__assign(__assign({}, pick.apply(void 0, __spreadArray([props], __read(plasmicClass.internalArgProps)))), (config.startIconSlot && (_a = {}, _a[config.startIconSlot] = startIcon, _a))), (config.endIconSlot && (_b = {}, _b[config.endIconSlot] = endIcon, _b)));
27
+ var variants = __assign(__assign({}, pick.apply(void 0, __spreadArray([props], __read(plasmicClass.internalVariantProps), false))), mergeVariantToggles({ def: config.showStartIconVariant, active: showStartIcon }, { def: config.showEndIconVariant, active: showEndIcon }, { def: config.isDisabledVariant, active: isDisabled }));
28
+ var args = __assign(__assign(__assign({}, pick.apply(void 0, __spreadArray([props], __read(plasmicClass.internalArgProps), false))), (config.startIconSlot && (_a = {}, _a[config.startIconSlot] = startIcon, _a))), (config.endIconSlot && (_b = {}, _b[config.endIconSlot] = endIcon, _b)));
29
29
  var overrides = (_c = {},
30
30
  _c[config.root] = {
31
31
  props: {
32
32
  ref: rootRef,
33
33
  className: className,
34
- style: style,
35
- },
34
+ style: style
35
+ }
36
36
  },
37
37
  _c[config.input] = {
38
- props: __assign(__assign({}, omit.apply(void 0, __spreadArray(__spreadArray([rest], __read(plasmicClass.internalArgProps.filter(function (prop) { return prop !== "required"; }))), __read(plasmicClass.internalVariantProps)))), { disabled: isDisabled, ref: inputRef, className: inputClassName, style: inputStyle }),
38
+ props: __assign(__assign({}, omit.apply(void 0, __spreadArray(__spreadArray([rest], __read(plasmicClass.internalArgProps.filter(function (prop) { return prop !== "required"; })), false), __read(plasmicClass.internalVariantProps), false))), { disabled: isDisabled, ref: inputRef, className: inputClassName, style: inputStyle })
39
39
  },
40
40
  _c);
41
41
  return {
42
42
  plasmicProps: {
43
43
  variants: variants,
44
44
  args: args,
45
- overrides: overrides,
46
- },
45
+ overrides: overrides
46
+ }
47
47
  };
48
48
  }
49
49
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../src/plume/text-input/index.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { omit, pick } from \"../../common\";\nimport { Overrides } from \"../../render/elements\";\nimport {\n AnyPlasmicClass,\n mergeVariantToggles,\n PlasmicClassArgs,\n PlasmicClassOverrides,\n PlasmicClassVariants,\n VariantDef,\n} from \"../plume-utils\";\n\nexport interface BaseTextInputProps\n extends Omit<React.ComponentProps<\"input\">, \"type\" | \"disabled\"> {\n showStartIcon?: boolean;\n showEndIcon?: boolean;\n startIcon?: React.ReactNode;\n endIcon?: React.ReactNode;\n isDisabled?: boolean;\n type?: \"text\" | \"password\" | \"email\" | \"url\" | string;\n inputClassName?: string;\n inputStyle?: React.CSSProperties;\n}\n\nexport interface TextInputRefValue {\n focus: () => void;\n blur: () => void;\n getRoot: () => HTMLElement | null;\n getInput: () => HTMLInputElement | null;\n}\n\nexport type TextInputRef = React.Ref<TextInputRefValue>;\n\ninterface TextInputConfig<C extends AnyPlasmicClass> {\n showStartIconVariant: VariantDef<PlasmicClassVariants<C>>;\n showEndIconVariant?: VariantDef<PlasmicClassVariants<C>>;\n isDisabledVariant?: VariantDef<PlasmicClassVariants<C>>;\n startIconSlot?: keyof PlasmicClassArgs<C>;\n endIconSlot?: keyof PlasmicClassArgs<C>;\n root: keyof PlasmicClassOverrides<C>;\n input: keyof PlasmicClassOverrides<C>;\n}\n\nexport function useTextInput<\n P extends BaseTextInputProps,\n C extends AnyPlasmicClass\n>(\n plasmicClass: C,\n props: P,\n config: TextInputConfig<C>,\n ref: TextInputRef = null\n) {\n const {\n isDisabled,\n startIcon,\n endIcon,\n showStartIcon,\n showEndIcon,\n className,\n style,\n inputClassName,\n inputStyle,\n ...rest\n } = props;\n const rootRef = React.useRef<HTMLElement>(null);\n const inputRef = React.useRef<HTMLInputElement>(null);\n\n React.useImperativeHandle(\n ref,\n () => ({\n focus() {\n inputRef.current?.focus();\n },\n blur() {\n inputRef.current?.blur();\n },\n getRoot() {\n return rootRef.current;\n },\n getInput() {\n return inputRef.current;\n },\n }),\n [rootRef, inputRef]\n );\n\n const variants = {\n ...pick(props, ...plasmicClass.internalVariantProps),\n ...mergeVariantToggles(\n { def: config.showStartIconVariant, active: showStartIcon },\n { def: config.showEndIconVariant, active: showEndIcon },\n { def: config.isDisabledVariant, active: isDisabled }\n ),\n };\n\n const args = {\n ...pick(props, ...plasmicClass.internalArgProps),\n ...(config.startIconSlot && { [config.startIconSlot]: startIcon }),\n ...(config.endIconSlot && { [config.endIconSlot]: endIcon }),\n };\n\n const overrides: Overrides = {\n [config.root]: {\n props: {\n ref: rootRef,\n className,\n style,\n },\n },\n [config.input]: {\n props: {\n ...omit(\n rest as any,\n // We need to remove `required` from the list of internalArgProps to\n // be omitted in the props being passed through because Plume pkg\n // <= 19.1.1 had a bug: input[required] was not linked to the\n // `required` arg as it should.\n ...plasmicClass.internalArgProps.filter(\n (prop) => prop !== \"required\"\n ),\n ...plasmicClass.internalVariantProps\n ),\n disabled: isDisabled,\n ref: inputRef,\n className: inputClassName,\n style: inputStyle,\n },\n },\n };\n\n return {\n plasmicProps: {\n variants: variants as PlasmicClassVariants<C>,\n args: args as PlasmicClassArgs<C>,\n overrides: overrides as PlasmicClassOverrides<C>,\n },\n };\n}\n"],"names":[],"mappings":";;;;SA2CgB,YAAY,CAI1B,YAAe,EACf,KAAQ,EACR,MAA0B,EAC1B,GAAwB;;IAAxB,oBAAA,EAAA,UAAwB;IAGtB,IAAA,UAAU,GAUR,KAAK,WAVG,EACV,SAAS,GASP,KAAK,UATE,EACT,OAAO,GAQL,KAAK,QARA,EACP,aAAa,GAOX,KAAK,cAPM,EACb,WAAW,GAMT,KAAK,YANI,EACX,SAAS,GAKP,KAAK,UALE,EACT,KAAK,GAIH,KAAK,MAJF,EACL,cAAc,GAGZ,KAAK,eAHO,EACd,UAAU,GAER,KAAK,WAFG,EACP,IAAI,UACL,KAAK,EAXH,4HAWL,CADQ,CACC;IACV,IAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAc,IAAI,CAAC,CAAC;IAChD,IAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAmB,IAAI,CAAC,CAAC;IAEtD,KAAK,CAAC,mBAAmB,CACvB,GAAG,EACH,cAAM,QAAC;QACL,KAAK;;YACH,MAAA,QAAQ,CAAC,OAAO,0CAAE,KAAK,EAAE,CAAC;SAC3B;QACD,IAAI;;YACF,MAAA,QAAQ,CAAC,OAAO,0CAAE,IAAI,EAAE,CAAC;SAC1B;QACD,OAAO;YACL,OAAO,OAAO,CA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jC,SAAS,EAAE,SAAqC;SACjD;KACF,CAAC;AACJ;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../src/plume/text-input/index.tsx"],"sourcesContent":["import * as React from \"react\";\nimport { omit, pick } from \"../../common\";\nimport { Overrides } from \"../../render/elements\";\nimport {\n AnyPlasmicClass,\n mergeVariantToggles,\n PlasmicClassArgs,\n PlasmicClassOverrides,\n PlasmicClassVariants,\n VariantDef,\n} from \"../plume-utils\";\n\nexport interface BaseTextInputProps\n extends Omit<React.ComponentProps<\"input\">, \"type\" | \"disabled\"> {\n showStartIcon?: boolean;\n showEndIcon?: boolean;\n startIcon?: React.ReactNode;\n endIcon?: React.ReactNode;\n isDisabled?: boolean;\n type?: \"text\" | \"password\" | \"email\" | \"url\" | string;\n inputClassName?: string;\n inputStyle?: React.CSSProperties;\n}\n\nexport interface TextInputRefValue {\n focus: () => void;\n blur: () => void;\n getRoot: () => HTMLElement | null;\n getInput: () => HTMLInputElement | null;\n}\n\nexport type TextInputRef = React.Ref<TextInputRefValue>;\n\ninterface TextInputConfig<C extends AnyPlasmicClass> {\n showStartIconVariant: VariantDef<PlasmicClassVariants<C>>;\n showEndIconVariant?: VariantDef<PlasmicClassVariants<C>>;\n isDisabledVariant?: VariantDef<PlasmicClassVariants<C>>;\n startIconSlot?: keyof PlasmicClassArgs<C>;\n endIconSlot?: keyof PlasmicClassArgs<C>;\n root: keyof PlasmicClassOverrides<C>;\n input: keyof PlasmicClassOverrides<C>;\n}\n\nexport function useTextInput<\n P extends BaseTextInputProps,\n C extends AnyPlasmicClass\n>(\n plasmicClass: C,\n props: P,\n config: TextInputConfig<C>,\n ref: TextInputRef = null\n) {\n const {\n isDisabled,\n startIcon,\n endIcon,\n showStartIcon,\n showEndIcon,\n className,\n style,\n inputClassName,\n inputStyle,\n ...rest\n } = props;\n const rootRef = React.useRef<HTMLElement>(null);\n const inputRef = React.useRef<HTMLInputElement>(null);\n\n React.useImperativeHandle(\n ref,\n () => ({\n focus() {\n inputRef.current?.focus();\n },\n blur() {\n inputRef.current?.blur();\n },\n getRoot() {\n return rootRef.current;\n },\n getInput() {\n return inputRef.current;\n },\n }),\n [rootRef, inputRef]\n );\n\n const variants = {\n ...pick(props, ...plasmicClass.internalVariantProps),\n ...mergeVariantToggles(\n { def: config.showStartIconVariant, active: showStartIcon },\n { def: config.showEndIconVariant, active: showEndIcon },\n { def: config.isDisabledVariant, active: isDisabled }\n ),\n };\n\n const args = {\n ...pick(props, ...plasmicClass.internalArgProps),\n ...(config.startIconSlot && { [config.startIconSlot]: startIcon }),\n ...(config.endIconSlot && { [config.endIconSlot]: endIcon }),\n };\n\n const overrides: Overrides = {\n [config.root]: {\n props: {\n ref: rootRef,\n className,\n style,\n },\n },\n [config.input]: {\n props: {\n ...omit(\n rest as any,\n // We need to remove `required` from the list of internalArgProps to\n // be omitted in the props being passed through because Plume pkg\n // <= 19.1.1 had a bug: input[required] was not linked to the\n // `required` arg as it should.\n ...plasmicClass.internalArgProps.filter(\n (prop) => prop !== \"required\"\n ),\n ...plasmicClass.internalVariantProps\n ),\n disabled: isDisabled,\n ref: inputRef,\n className: inputClassName,\n style: inputStyle,\n },\n },\n };\n\n return {\n plasmicProps: {\n variants: variants as PlasmicClassVariants<C>,\n args: args as PlasmicClassArgs<C>,\n overrides: overrides as PlasmicClassOverrides<C>,\n },\n };\n}\n"],"names":[],"mappings":";;;;SA2CgB,YAAY,CAI1B,YAAe,EACf,KAAQ,EACR,MAA0B,EAC1B,GAAwB;;IAAxB,oBAAA,EAAA,UAAwB;IAGtB,IAAA,UAAU,GAUR,KAAK,WAVG,EACV,SAAS,GASP,KAAK,UATE,EACT,OAAO,GAQL,KAAK,QARA,EACP,aAAa,GAOX,KAAK,cAPM,EACb,WAAW,GAMT,KAAK,YANI,EACX,SAAS,GAKP,KAAK,UALE,EACT,KAAK,GAIH,KAAK,MAJF,EACL,cAAc,GAGZ,KAAK,eAHO,EACd,UAAU,GAER,KAAK,WAFG,EACP,IAAI,UACL,KA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D,GAAC,MAAM,CAAC,KAAK,IAAG;YACd,KAAK,wBACA,IAAI,4CACL,IAAW,UAKR,YAAY,CAAC,gBAAgB,CAAC,MAAM,CACrC,UAAC,IAAI,IAAK,OAAA,IAAI,KAAK,UAAU,GAAA,CAC9B,kBACE,YAAY,CAAC,oBAAoB,eAEtC,QAAQ,EAAE,UAAU,EACpB,GAAG,EAAE,QAAQ,EACb,SAAS,EAAE,cAAc,EACzB,KAAK,EAAE,UAAU,GAClB;SACF;WACF,CAAC;IAEF,OAAO;QACL,YAAY,EAAE;YACZ,QAAQ,EAAE,QAAmC;YAC7C,IAAI,EAAE,IAA2B;YACjC,SAAS,EAAE,SAAqC;SACjD;KACF,CAAC;AACJ;;;;"}
@@ -1,11 +1,11 @@
1
- import { c as __read, a as __assign, p as pick, b as __spreadArray } from '../../common-182a0b0c.js';
1
+ import { c as __read, a as __assign, p as pick, b as __spreadArray } from '../../common-9ebe374e.js';
2
2
  import * as React from 'react';
3
3
  import { useOverlay, useOverlayPosition, DismissButton } from '@react-aria/overlays';
4
4
  import { FocusScope } from '@react-aria/focus';
5
5
  import * as ReactDOM from 'react-dom';
6
- import { d as mergeRefs, u as useIsomorphicLayoutEffect, m as mergeProps } from '../../react-utils-35cb2a4e.js';
7
- import { m as mergeVariantToggles } from '../../plume-utils-623b91cc.js';
8
- import { g as getStyleProps } from '../../props-utils-b2ad4997.js';
6
+ import { d as mergeRefs, u as useIsomorphicLayoutEffect, m as mergeProps } from '../../react-utils-7bc53870.js';
7
+ import { m as mergeVariantToggles } from '../../plume-utils-d9811bf3.js';
8
+ import { g as getStyleProps } from '../../props-utils-228208e6.js';
9
9
  import { T as TriggeredOverlayContext } from '../../context-034b8d25.js';
10
10
  export { T as TriggeredOverlayContext } from '../../context-034b8d25.js';
11
11
  import 'classnames';
@@ -48,7 +48,7 @@ function useTriggeredOverlay(plasmicClass, props, config, outerRef, isDismissabl
48
48
  isOpen: state.isOpen,
49
49
  onClose: state.close,
50
50
  isDismissable: isDismissable,
51
- shouldCloseOnBlur: true,
51
+ shouldCloseOnBlur: true
52
52
  }, overlayRef).overlayProps;
53
53
  var _d = useOverlayPosition({
54
54
  targetRef: triggerRef,
@@ -57,7 +57,7 @@ function useTriggeredOverlay(plasmicClass, props, config, outerRef, isDismissabl
57
57
  shouldFlip: true,
58
58
  isOpen: state.isOpen,
59
59
  onClose: state.close,
60
- containerPadding: 0,
60
+ containerPadding: 0
61
61
  }), overlayPositionProps = _d.overlayProps, updatePosition = _d.updatePosition, placementAxis = _d.placement;
62
62
  useIsomorphicLayoutEffect(function () {
63
63
  if (state.isOpen) {
@@ -74,17 +74,17 @@ function useTriggeredOverlay(plasmicClass, props, config, outerRef, isDismissabl
74
74
  bottom: "auto",
75
75
  position: "absolute",
76
76
  width: overlayWidth !== null && overlayWidth !== void 0 ? overlayWidth : (overlayMatchTriggerWidth ? triggerWidth : "auto"),
77
- minWidth: overlayMinTriggerWidth ? triggerWidth : "auto",
78
- },
77
+ minWidth: overlayMinTriggerWidth ? triggerWidth : "auto"
78
+ }
79
79
  }, overlayAriaProps, overlayPositionProps);
80
- var variants = __assign(__assign({}, pick.apply(void 0, __spreadArray([props], __read(plasmicClass.internalVariantProps)))), mergeVariantToggles({ def: config.isPlacedTopVariant, active: placementAxis === "top" }, { def: config.isPlacedBottomVariant, active: placementAxis === "bottom" }, { def: config.isPlacedLeftVariant, active: placementAxis === "left" }, { def: config.isPlacedRightVariant, active: placementAxis === "right" }));
81
- var args = __assign(__assign({}, pick.apply(void 0, __spreadArray([props], __read(plasmicClass.internalArgProps)))), (_a = {}, _a[config.contentSlot] = (React.createElement(FocusScope, { restoreFocus: true },
80
+ var variants = __assign(__assign({}, pick.apply(void 0, __spreadArray([props], __read(plasmicClass.internalVariantProps), false))), mergeVariantToggles({ def: config.isPlacedTopVariant, active: placementAxis === "top" }, { def: config.isPlacedBottomVariant, active: placementAxis === "bottom" }, { def: config.isPlacedLeftVariant, active: placementAxis === "left" }, { def: config.isPlacedRightVariant, active: placementAxis === "right" }));
81
+ var args = __assign(__assign({}, pick.apply(void 0, __spreadArray([props], __read(plasmicClass.internalArgProps), false))), (_a = {}, _a[config.contentSlot] = (React.createElement(FocusScope, { restoreFocus: true },
82
82
  React.createElement(DismissButton, { onDismiss: state.close }),
83
83
  children)), _a));
84
84
  var overrides = (_b = {},
85
85
  _b[config.root] = {
86
86
  props: mergeProps(overlayProps, getStyleProps(props), {
87
- ref: onOverlayRef,
87
+ ref: onOverlayRef
88
88
  }),
89
89
  wrap: function (root) {
90
90
  if (typeof document !== "undefined") {
@@ -95,15 +95,15 @@ function useTriggeredOverlay(plasmicClass, props, config, outerRef, isDismissabl
95
95
  // bother with a portal in that case.
96
96
  return root;
97
97
  }
98
- },
98
+ }
99
99
  },
100
100
  _b);
101
101
  return {
102
102
  plasmicProps: {
103
103
  variants: variants,
104
104
  args: args,
105
- overrides: overrides,
106
- },
105
+ overrides: overrides
106
+ }
107
107
  };
108
108
  }
109
109
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../src/plume/triggered-overlay/triggered-overlay.tsx"],"sourcesContent":["import { DOMProps } from \"@react-types/shared\";\nimport * as React from \"react\";\nimport {\n DismissButton,\n useOverlay,\n useOverlayPosition,\n} from \"@react-aria/overlays\";\nimport { FocusScope } from \"@react-aria/focus\";\nimport * as ReactDOM from \"react-dom\";\nimport { pick } from \"../../common\";\nimport {\n mergeProps,\n mergeRefs,\n useIsomorphicLayoutEffect,\n} from \"../../react-utils\";\nimport { Overrides } from \"../../render/elements\";\nimport {\n AnyPlasmicClass,\n mergeVariantToggles,\n PlasmicClassArgs,\n PlasmicClassOverrides,\n PlasmicClassVariants,\n PLUME_STRICT_MODE,\n VariantDef,\n} from \"../plume-utils\";\nimport {\n getDefaultPlasmicProps,\n getStyleProps,\n StyleProps,\n} from \"../props-utils\";\nimport { TriggeredOverlayContext } from \"./context\";\n\nexport interface BaseTriggeredOverlayProps extends StyleProps, DOMProps {\n children?: React.ReactNode;\n}\n\nexport interface TriggeredOverlayConfig<C extends AnyPlasmicClass> {\n isPlacedTopVariant?: VariantDef<PlasmicClassVariants<C>>;\n isPlacedBottomVariant?: VariantDef<PlasmicClassVariants<C>>;\n isPlacedLeftVariant?: VariantDef<PlasmicClassVariants<C>>;\n isPlacedRightVariant?: VariantDef<PlasmicClassVariants<C>>;\n\n contentSlot: keyof PlasmicClassArgs<C>;\n root: keyof PlasmicClassOverrides<C>;\n contentContainer: keyof PlasmicClassOverrides<C>;\n}\n\nexport type TriggeredOverlayRef = React.Ref<HTMLElement>;\n\nexport function useTriggeredOverlay<\n P extends BaseTriggeredOverlayProps,\n C extends AnyPlasmicClass\n>(\n plasmicClass: C,\n props: P,\n config: TriggeredOverlayConfig<C>,\n outerRef: TriggeredOverlayRef = null,\n isDismissable = true\n) {\n const overlayRef = React.useRef<HTMLElement>(null);\n const onOverlayRef = mergeRefs(overlayRef, outerRef);\n\n const context = React.useContext(TriggeredOverlayContext);\n\n if (!context) {\n // If no context, then we are not being correctly used. Either complain, or\n // exit early. It's okay to exit early and break the rules of React hooks\n // because we won't suddenly have the appropriate context anyway for this instance.\n if (PLUME_STRICT_MODE) {\n throw new Error(\n \"You can only use a triggered overlay with a TriggeredOverlayContext\"\n );\n }\n return getDefaultPlasmicProps(plasmicClass, props);\n }\n\n const { children } = props;\n const {\n triggerRef,\n placement,\n overlayMatchTriggerWidth,\n overlayMinTriggerWidth,\n overlayWidth,\n state,\n } = context;\n\n // Measure the width of the trigger to inform the width of the menu (below).\n const [isRendered, setRendered] = React.useState(false);\n const triggerWidth =\n triggerRef.current && (overlayMatchTriggerWidth || overlayMinTriggerWidth)\n ? triggerRef.current.offsetWidth\n : undefined;\n\n useIsomorphicLayoutEffect(() => {\n if (\n !isRendered &&\n triggerRef.current &&\n (overlayMatchTriggerWidth || overlayMinTriggerWidth)\n ) {\n setRendered(true);\n }\n }, [\n triggerRef,\n isRendered,\n overlayMatchTriggerWidth,\n overlayMinTriggerWidth,\n ]);\n\n const { overlayProps: overlayAriaProps } = useOverlay(\n {\n isOpen: state.isOpen,\n onClose: state.close,\n isDismissable,\n shouldCloseOnBlur: true,\n },\n overlayRef\n );\n\n const {\n overlayProps: overlayPositionProps,\n updatePosition,\n placement: placementAxis,\n } = useOverlayPosition({\n targetRef: triggerRef,\n overlayRef,\n placement: placement ?? \"bottom left\",\n shouldFlip: true,\n isOpen: state.isOpen,\n onClose: state.close,\n containerPadding: 0,\n });\n\n useIsomorphicLayoutEffect(() => {\n if (state.isOpen) {\n requestAnimationFrame(() => {\n updatePosition();\n });\n }\n }, [state.isOpen, updatePosition]);\n\n const overlayProps = mergeProps(\n {\n style: {\n left: \"auto\",\n right: \"auto\",\n top: \"auto\",\n bottom: \"auto\",\n position: \"absolute\",\n width:\n overlayWidth ?? (overlayMatchTriggerWidth ? triggerWidth : \"auto\"),\n minWidth: overlayMinTriggerWidth ? triggerWidth : \"auto\",\n },\n },\n overlayAriaProps,\n overlayPositionProps\n );\n\n const variants = {\n ...pick(props, ...plasmicClass.internalVariantProps),\n ...mergeVariantToggles(\n { def: config.isPlacedTopVariant, active: placementAxis === \"top\" },\n { def: config.isPlacedBottomVariant, active: placementAxis === \"bottom\" },\n { def: config.isPlacedLeftVariant, active: placementAxis === \"left\" },\n { def: config.isPlacedRightVariant, active: placementAxis === \"right\" }\n ),\n };\n\n const args = {\n ...pick(props, ...plasmicClass.internalArgProps),\n [config.contentSlot]: (\n <FocusScope restoreFocus>\n <DismissButton onDismiss={state.close} />\n {children}\n {/* We don't use the DismissButton at the end because it ends up taking up 1px space :-/ */}\n {/* <DismissButton onDismiss={state.close} /> */}\n </FocusScope>\n ),\n };\n\n const overrides: Overrides = {\n [config.root]: {\n props: mergeProps(overlayProps, getStyleProps(props), {\n ref: onOverlayRef,\n }),\n wrap: (root) => {\n if (typeof document !== \"undefined\") {\n return ReactDOM.createPortal(root, document.body);\n } else {\n // Possibly being invoked on the server during SSR; no need to\n // bother with a portal in that case.\n return root;\n }\n },\n },\n };\n\n return {\n plasmicProps: {\n variants: variants as PlasmicClassVariants<C>,\n args: args as PlasmicClassArgs<C>,\n overrides: overrides as PlasmicClassOverrides<C>,\n },\n };\n}\n"],"names":[],"mappings":";;;;;;;;;;;;SAiDgB,mBAAmB,CAIjC,YAAe,EACf,KAAQ,EACR,MAAiC,EACjC,QAAoC,EACpC,aAAoB;;IADpB,yBAAA,EAAA,eAAoC;IACpC,8BAAA,EAAA,oBAAoB;IAEpB,IAAM,UAAU,GAAG,KAAK,CAAC,MAAM,CAAc,IAAI,CAAC,CAAC;IACnD,IAAM,YAAY,GAAG,SAAS,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;IAErD,IAAM,OAAO,GAAG,KAAK,CAAC,UAAU,CAAC,uBAAuB,CAAC,CAAC;IAE1D,IAAI,CAAC,OAAO,EAAE;;;;QAIW;YACrB,MAAM,IAAI,KAAK,CACb,qEAAqE,CACtE,CAAC;SACH;KAEF;IAEO,IAAA,QAAQ,GAAK,KAAK,SAAV,CAAW;IAEzB,IAAA,UAAU,GAMR,OAAO,WANC,EACV,SAAS,GAKP,OAAO,UALA,EACT,wBAAwB,GAItB,OAAO,yBAJe,EACxB,sBAAsB,GAGpB,OAAO,uBAHa,EACtB,YAAY,GAEV,OAAO,aAFG,EACZ,KAAK,GACH,OAAO,MADJ,CACK;;IAGN,IAAA,KAAA,OAA4B,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAA,EAAhD,UAAU,QAAA,EAAE,WAAW,QAAyB,CAAC;IACxD,IAAM,YAAY,GAChB,UAAU,CAAC,OAAO,KAAK,wBAAwB,IAAI,sBAAsB,CAAC;UACtE,UAAU,CAAC,OAAO,CAAC,WAAW;UAC9B,SAAS,CAAC;IAEhB,yBAAyB,CAAC;QACxB,IACE,CAAC,UAAU;YACX,UAAU,CAAC,OAAO;aACjB,wBAAwB,IAAI,sBAAsB,CAAC,EACpD;YACA,WAAW,CAAC,IAAI,CAAC,CAAC;SACnB;KACF,EAAE;QACD,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,EAAE,GAAG,EAAE,MAAM,CAAC,kBAAkB,EAAE,MAAM,EAAE,aAAa,KAAK,KAAK,EAAE,EACnE,EAAE,GAAG,EAAE,MAAM,CAAC,qBAAqB,EAAE,MAAM,EAAE,aAAa,KAAK,QAAQ,EAAE,EACzE,EAAE,GAAG,EAAE,MAAM,CAAC,mBAAmB,EAAE,MAAM,EAAE,aAAa,KAAK,MAAM,EAAE,EACrE,EAAE,GAAG,EAAE,MAAM,CAAC,oBAAoB,EAAE,MAAM,EAAE,aAAa,KAAK,OAAO,EAAE,CACxE,CACF,CAAC;IAEF,IAAM,IAAI,yBACL,IAAI,8BAAC,KAAK,UAAK,YAAY,CAAC,gBAAgB,mBAC9C,MAAM,CAAC,WAAW,KACjB,oBAAC,UAAU,IAAC,YAAY;QACtB,oBAAC,aAAa,IAAC,SAAS,EAAE,KAAK,CAAC,KAAK,GAAI;QACxC,QAAQ,CAGE,CACd,MACF,CAAC;IAEF,IAAM,SAAS;QACb,GAAC,MAAM,CAAC,IAAI,IAAG;YACb,KAAK,EAAE,UAAU,CAAC,YAAY,EAAE,aAAa,CAAC,KAAK,CAAC,EAAE;gBACpD,GAAG,EAAE,YAAY;aAClB,CAAC;YACF,IAAI,EAAE,UAAC,IAAI;gBACT,IAAI,OAAO,QAAQ,KAAK,WAAW,EAAE;oBACnC,OAAO,QAAQ,CAAC,YAAY,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;iBACnD;qBAAM;;;oBAGL,OAAO,IAAI,CAAC;iBACb;aACF;SACF;WACF,CAAC;IAEF,OAAO;QACL,YAAY,EAAE;YACZ,QAAQ,EAAE,QAAmC;YAC7C,IAAI,EAAE,IAA2B;YACjC,SAAS,EAAE,SAAqC;SACjD;KACF,CAAC;AACJ;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../src/plume/triggered-overlay/triggered-overlay.tsx"],"sourcesContent":["import { DOMProps } from \"@react-types/shared\";\nimport * as React from \"react\";\nimport {\n DismissButton,\n useOverlay,\n useOverlayPosition,\n} from \"@react-aria/overlays\";\nimport { FocusScope } from \"@react-aria/focus\";\nimport * as ReactDOM from \"react-dom\";\nimport { pick } from \"../../common\";\nimport {\n mergeProps,\n mergeRefs,\n useIsomorphicLayoutEffect,\n} from \"../../react-utils\";\nimport { Overrides } from \"../../render/elements\";\nimport {\n AnyPlasmicClass,\n mergeVariantToggles,\n PlasmicClassArgs,\n PlasmicClassOverrides,\n PlasmicClassVariants,\n PLUME_STRICT_MODE,\n VariantDef,\n} from \"../plume-utils\";\nimport {\n getDefaultPlasmicProps,\n getStyleProps,\n StyleProps,\n} from \"../props-utils\";\nimport { TriggeredOverlayContext } from \"./context\";\n\nexport interface BaseTriggeredOverlayProps extends StyleProps, DOMProps {\n children?: React.ReactNode;\n}\n\nexport interface TriggeredOverlayConfig<C extends AnyPlasmicClass> {\n isPlacedTopVariant?: VariantDef<PlasmicClassVariants<C>>;\n isPlacedBottomVariant?: VariantDef<PlasmicClassVariants<C>>;\n isPlacedLeftVariant?: VariantDef<PlasmicClassVariants<C>>;\n isPlacedRightVariant?: VariantDef<PlasmicClassVariants<C>>;\n\n contentSlot: keyof PlasmicClassArgs<C>;\n root: keyof PlasmicClassOverrides<C>;\n contentContainer: keyof PlasmicClassOverrides<C>;\n}\n\nexport type TriggeredOverlayRef = React.Ref<HTMLElement>;\n\nexport function useTriggeredOverlay<\n P extends BaseTriggeredOverlayProps,\n C extends AnyPlasmicClass\n>(\n plasmicClass: C,\n props: P,\n config: TriggeredOverlayConfig<C>,\n outerRef: TriggeredOverlayRef = null,\n isDismissable = true\n) {\n const overlayRef = React.useRef<HTMLElement>(null);\n const onOverlayRef = mergeRefs(overlayRef, outerRef);\n\n const context = React.useContext(TriggeredOverlayContext);\n\n if (!context) {\n // If no context, then we are not being correctly used. Either complain, or\n // exit early. It's okay to exit early and break the rules of React hooks\n // because we won't suddenly have the appropriate context anyway for this instance.\n if (PLUME_STRICT_MODE) {\n throw new Error(\n \"You can only use a triggered overlay with a TriggeredOverlayContext\"\n );\n }\n return getDefaultPlasmicProps(plasmicClass, props);\n }\n\n const { children } = props;\n const {\n triggerRef,\n placement,\n overlayMatchTriggerWidth,\n overlayMinTriggerWidth,\n overlayWidth,\n state,\n } = context;\n\n // Measure the width of the trigger to inform the width of the menu (below).\n const [isRendered, setRendered] = React.useState(false);\n const triggerWidth =\n triggerRef.current && (overlayMatchTriggerWidth || overlayMinTriggerWidth)\n ? triggerRef.current.offsetWidth\n : undefined;\n\n useIsomorphicLayoutEffect(() => {\n if (\n !isRendered &&\n triggerRef.current &&\n (overlayMatchTriggerWidth || overlayMinTriggerWidth)\n ) {\n setRendered(true);\n }\n }, [\n triggerRef,\n isRendered,\n overlayMatchTriggerWidth,\n overlayMinTriggerWidth,\n ]);\n\n const { overlayProps: overlayAriaProps } = useOverlay(\n {\n isOpen: state.isOpen,\n onClose: state.close,\n isDismissable,\n shouldCloseOnBlur: true,\n },\n overlayRef\n );\n\n const {\n overlayProps: overlayPositionProps,\n updatePosition,\n placement: placementAxis,\n } = useOverlayPosition({\n targetRef: triggerRef,\n overlayRef,\n placement: placement ?? \"bottom left\",\n shouldFlip: true,\n isOpen: state.isOpen,\n onClose: state.close,\n containerPadding: 0,\n });\n\n useIsomorphicLayoutEffect(() => {\n if (state.isOpen) {\n requestAnimationFrame(() => {\n updatePosition();\n });\n }\n }, [state.isOpen, updatePosition]);\n\n const overlayProps = mergeProps(\n {\n style: {\n left: \"auto\",\n right: \"auto\",\n top: \"auto\",\n bottom: \"auto\",\n position: \"absolute\",\n width:\n overlayWidth ?? (overlayMatchTriggerWidth ? triggerWidth : \"auto\"),\n minWidth: overlayMinTriggerWidth ? triggerWidth : \"auto\",\n },\n },\n overlayAriaProps,\n overlayPositionProps\n );\n\n const variants = {\n ...pick(props, ...plasmicClass.internalVariantProps),\n ...mergeVariantToggles(\n { def: config.isPlacedTopVariant, active: placementAxis === \"top\" },\n { def: config.isPlacedBottomVariant, active: placementAxis === \"bottom\" },\n { def: config.isPlacedLeftVariant, active: placementAxis === \"left\" },\n { def: config.isPlacedRightVariant, active: placementAxis === \"right\" }\n ),\n };\n\n const args = {\n ...pick(props, ...plasmicClass.internalArgProps),\n [config.contentSlot]: (\n <FocusScope restoreFocus>\n <DismissButton onDismiss={state.close} />\n {children}\n {/* We don't use the DismissButton at the end because it ends up taking up 1px space :-/ */}\n {/* <DismissButton onDismiss={state.close} /> */}\n </FocusScope>\n ),\n };\n\n const overrides: Overrides = {\n [config.root]: {\n props: mergeProps(overlayProps, getStyleProps(props), {\n ref: onOverlayRef,\n }),\n wrap: (root) => {\n if (typeof document !== \"undefined\") {\n return ReactDOM.createPortal(root, document.body);\n } else {\n // Possibly being invoked on the server during SSR; no need to\n // bother with a portal in that case.\n return root;\n }\n },\n },\n };\n\n return {\n plasmicProps: {\n variants: variants as PlasmicClassVariants<C>,\n args: args as PlasmicClassArgs<C>,\n overrides: overrides as PlasmicClassOverrides<C>,\n },\n };\n}\n"],"names":[],"mappings":";;;;;;;;;;;;SAiDgB,mBAAmB,CAIjC,YAAe,EACf,KAAQ,EACR,MAAiC,EACjC,QAAoC,EACpC,aAAoB;;IADpB,yBAAA,EAAA,eAAoC;IACpC,8BAAA,EAAA,oBAAoB;IAEpB,IAAM,UAAU,GAAG,KAAK,CAAC,MAAM,CAAc,IAAI,CAAC,CAAC;IACnD,IAAM,YAAY,GAAG,SAAS,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;IAErD,IAAM,OAAO,GAAG,KAAK,CAAC,UAAU,CAAC,uBAAuB,CAAC,CAAC;IAE1D,IAAI,CAAC,OAAO,EAAE;;;;QAIW;YACrB,MAAM,IAAI,KAAK,CACb,qEAAqE,CACtE,CAAC;SACH;KAEF;IAEO,IAAA,QAAQ,GAAK,KAAK,SAAV,CAAW;IAEzB,IAAA,UAAU,GAMR,OAAO,WANC,EACV,SAAS,GAKP,OAAO,UALA,EACT,wBAAwB,GAItB,OAAO,yBAJe,EACxB,sBAAsB,GAGpB,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;YACF,IAAI,EAAE,UAAC,IAAI;gBACT,IAAI,OAAO,QAAQ,KAAK,WAAW,EAAE;oBACnC,OAAO,QAAQ,CAAC,YAAY,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;iBACnD;qBAAM;;;oBAGL,OAAO,IAAI,CAAC;iBACb;aACF;SACF;WACF,CAAC;IAEF,OAAO;QACL,YAAY,EAAE;YACZ,QAAQ,EAAE,QAAmC;YAC7C,IAAI,EAAE,IAA2B;YACjC,SAAS,EAAE,SAAqC;SACjD;KACF,CAAC;AACJ;;;;"}
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { m as mapValues, g as groupBy } from './common-9efbae57.js';
2
+ import { m as mapValues, g as groupBy } from './common-9ebe374e.js';
3
3
 
4
4
  var PLUME_STRICT_MODE = true;
5
5
  function mergeVariantToggles() {
@@ -32,4 +32,4 @@ function getPlumeType(child) {
32
32
  }
33
33
 
34
34
  export { PLUME_STRICT_MODE as P, getPlumeType as g, mergeVariantToggles as m, noOutline as n };
35
- //# sourceMappingURL=plume-utils-d2476af1.js.map
35
+ //# sourceMappingURL=plume-utils-d9811bf3.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"plume-utils-27cd384f.js","sources":["../../src/plume/plume-utils.ts"],"sourcesContent":["import * as React from \"react\";\nimport { groupBy, mapValues } from \"../common\";\nimport { SingleChoiceArg } from \"../render/elements\";\n\nexport let PLUME_STRICT_MODE = true;\n\nexport function setPlumeStrictMode(mode: boolean) {\n PLUME_STRICT_MODE = mode;\n}\n\ntype VariantArgChoices<T> = T extends (infer M)[]\n ? M\n : T extends SingleChoiceArg<infer M>\n ? M\n : never;\ntype VariantArgsChoices<V> = { [k in keyof V]-?: VariantArgChoices<V[k]> };\ntype DictValues<V extends Record<string, any>> = V[keyof V];\ntype DictTuples<V extends Record<string, any>> = DictValues<\n { [K in keyof V]: [K, V[K]] }\n>;\nexport type VariantDefTuple<V> = DictTuples<VariantArgsChoices<V>>;\n\ntype DistributeTuple<T> = T extends [infer T1, infer T2]\n ? { group: T1; variant: T2 }\n : never;\n\nexport type VariantDef<V> = DistributeTuple<VariantDefTuple<V>>;\n\nexport type PlasmicClass<\n V extends Record<string, any>,\n A extends Record<string, any>,\n O extends Record<string, any>\n> = {\n (props: { variants?: V; args?: A; overrides?: O }): React.ReactElement | null;\n internalVariantProps: (keyof V)[];\n internalArgProps: (keyof A)[];\n};\n\nexport type AnyPlasmicClass = PlasmicClass<any, any, any>;\n\nexport type PlasmicClassVariants<\n C extends AnyPlasmicClass\n> = C extends PlasmicClass<infer V, any, any> ? V : unknown;\nexport type PlasmicClassArgs<\n C extends AnyPlasmicClass\n> = C extends PlasmicClass<any, infer A, any> ? A : unknown;\nexport type PlasmicClassOverrides<\n C extends AnyPlasmicClass\n> = C extends PlasmicClass<any, any, infer O> ? O : unknown;\n\ntype BooleanLike = boolean | undefined | null;\n\nexport function mergeVariantToggles<V>(\n ...toggles: { def?: VariantDef<V>; active: BooleanLike }[]\n) {\n const definedToggles = toggles.filter((x) => !!x.def) as {\n def: VariantDef<V>;\n active: BooleanLike;\n }[];\n const grouped = groupBy(definedToggles, ({ def }) => def.group as string);\n return mapValues(grouped, (subToggles) => {\n return Object.fromEntries(\n subToggles.map(({ def, active }) => [def.variant, !!active])\n );\n });\n}\n\nexport function noOutline() {\n return { outline: \"none\" };\n}\n\nexport function getPlumeType(child: React.ReactChild): string | undefined {\n if (!React.isValidElement(child)) {\n return undefined;\n }\n const childType = child.type as any;\n return (childType.__plumeType || childType.getPlumeType?.(child.props)) as\n | string\n | undefined;\n}\n"],"names":[],"mappings":";;;IAIW,iBAAiB,GAAG,KAAK;SAgDpB,mBAAmB;IACjC,iBAA0D;SAA1D,UAA0D,EAA1D,qBAA0D,EAA1D,IAA0D;QAA1D,4BAA0D;;IAE1D,IAAM,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,UAAC,CAAC,IAAK,OAAA,CAAC,CAAC,CAAC,CAAC,GAAG,GAAA,CAGjD,CAAC;IACJ,IAAM,OAAO,GAAG,OAAO,CAAC,cAAc,EAAE,UAAC,EAAO;YAAL,GAAG,SAAA;QAAO,OAAA,GAAG,CAAC,KAAe;KAAA,CAAC,CAAC;IAC1E,OAAO,SAAS,CAAC,OAAO,EAAE,UAAC,UAAU;QACnC,OAAO,MAAM,CAAC,WAAW,CACvB,UAAU,CAAC,GAAG,CAAC,UAAC,EAAe;gBAAb,GAAG,SAAA,EAAE,MAAM,YAAA;YAAO,OAAA,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC;SAAA,CAAC,CAC7D,CAAC;KACH,CAAC,CAAC;AACL,CAAC;SAEe,SAAS;IACvB,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;AAC7B,CAAC;SAEe,YAAY,CAAC,KAAuB;;IAClD,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE;QAChC,OAAO,SAAS,CAAC;KAClB;IACD,IAAM,SAAS,GAAG,KAAK,CAAC,IAAW,CAAC;IACpC,QAAQ,SAAS,CAAC,WAAW,KAAI,MAAA,SAAS,CAAC,YAAY,+CAAtB,SAAS,EAAgB,KAAK,CAAC,KAAK,CAAC,CAAA,EAExD;AAChB;;;;"}
1
+ {"version":3,"file":"plume-utils-d9811bf3.js","sources":["../../src/plume/plume-utils.ts"],"sourcesContent":["import * as React from \"react\";\nimport { groupBy, mapValues } from \"../common\";\nimport { SingleChoiceArg } from \"../render/elements\";\n\nexport let PLUME_STRICT_MODE = true;\n\nexport function setPlumeStrictMode(mode: boolean) {\n PLUME_STRICT_MODE = mode;\n}\n\ntype VariantArgChoices<T> = T extends (infer M)[]\n ? M\n : T extends SingleChoiceArg<infer M>\n ? M\n : never;\ntype VariantArgsChoices<V> = { [k in keyof V]-?: VariantArgChoices<V[k]> };\ntype DictValues<V extends Record<string, any>> = V[keyof V];\ntype DictTuples<V extends Record<string, any>> = DictValues<\n { [K in keyof V]: [K, V[K]] }\n>;\nexport type VariantDefTuple<V> = DictTuples<VariantArgsChoices<V>>;\n\ntype DistributeTuple<T> = T extends [infer T1, infer T2]\n ? { group: T1; variant: T2 }\n : never;\n\nexport type VariantDef<V> = DistributeTuple<VariantDefTuple<V>>;\n\nexport type PlasmicClass<\n V extends Record<string, any>,\n A extends Record<string, any>,\n O extends Record<string, any>\n> = {\n (props: { variants?: V; args?: A; overrides?: O }): React.ReactElement | null;\n internalVariantProps: (keyof V)[];\n internalArgProps: (keyof A)[];\n};\n\nexport type AnyPlasmicClass = PlasmicClass<any, any, any>;\n\nexport type PlasmicClassVariants<\n C extends AnyPlasmicClass\n> = C extends PlasmicClass<infer V, any, any> ? V : unknown;\nexport type PlasmicClassArgs<\n C extends AnyPlasmicClass\n> = C extends PlasmicClass<any, infer A, any> ? A : unknown;\nexport type PlasmicClassOverrides<\n C extends AnyPlasmicClass\n> = C extends PlasmicClass<any, any, infer O> ? O : unknown;\n\ntype BooleanLike = boolean | undefined | null;\n\nexport function mergeVariantToggles<V>(\n ...toggles: { def?: VariantDef<V>; active: BooleanLike }[]\n) {\n const definedToggles = toggles.filter((x) => !!x.def) as {\n def: VariantDef<V>;\n active: BooleanLike;\n }[];\n const grouped = groupBy(definedToggles, ({ def }) => def.group as string);\n return mapValues(grouped, (subToggles) => {\n return Object.fromEntries(\n subToggles.map(({ def, active }) => [def.variant, !!active])\n );\n });\n}\n\nexport function noOutline() {\n return { outline: \"none\" };\n}\n\nexport function getPlumeType(child: React.ReactChild): string | undefined {\n if (!React.isValidElement(child)) {\n return undefined;\n }\n const childType = child.type as any;\n return (childType.__plumeType || childType.getPlumeType?.(child.props)) as\n | string\n | undefined;\n}\n"],"names":[],"mappings":";;;IAIW,iBAAiB,GAAG,KAAK;SAgDpB,mBAAmB;IACjC,iBAA0D;SAA1D,UAA0D,EAA1D,qBAA0D,EAA1D,IAA0D;QAA1D,4BAA0D;;IAE1D,IAAM,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC,UAAC,CAAC,IAAK,OAAA,CAAC,CAAC,CAAC,CAAC,GAAG,GAAA,CAGjD,CAAC;IACJ,IAAM,OAAO,GAAG,OAAO,CAAC,cAAc,EAAE,UAAC,EAAO;YAAL,GAAG,SAAA;QAAO,OAAA,GAAG,CAAC,KAAe;KAAA,CAAC,CAAC;IAC1E,OAAO,SAAS,CAAC,OAAO,EAAE,UAAC,UAAU;QACnC,OAAO,MAAM,CAAC,WAAW,CACvB,UAAU,CAAC,GAAG,CAAC,UAAC,EAAe;gBAAb,GAAG,SAAA,EAAE,MAAM,YAAA;YAAO,OAAA,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC;SAAA,CAAC,CAC7D,CAAC;KACH,CAAC,CAAC;AACL,CAAC;SAEe,SAAS;IACvB,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;AAC7B,CAAC;SAEe,YAAY,CAAC,KAAuB;;IAClD,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE;QAChC,OAAO,SAAS,CAAC;KAClB;IACD,IAAM,SAAS,GAAG,KAAK,CAAC,IAAW,CAAC;IACpC,QAAQ,SAAS,CAAC,WAAW,KAAI,MAAA,SAAS,CAAC,YAAY,0DAAG,KAAK,CAAC,KAAK,CAAC,CAAA,EAExD;AAChB;;;;"}
@@ -1,8 +1,8 @@
1
- import { p as pick } from './common-9efbae57.js';
1
+ import { p as pick } from './common-9ebe374e.js';
2
2
 
3
3
  function getStyleProps(props) {
4
4
  return pick(props, "className", "style");
5
5
  }
6
6
 
7
7
  export { getStyleProps as g };
8
- //# sourceMappingURL=props-utils-cac0cccf.js.map
8
+ //# sourceMappingURL=props-utils-228208e6.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"props-utils-7c02c0a8.js","sources":["../../src/plume/props-utils.ts"],"sourcesContent":["import * as React from \"react\";\nimport { pick, pickBy } from \"../common\";\nimport {\n AnyPlasmicClass,\n PlasmicClassArgs,\n PlasmicClassOverrides,\n PlasmicClassVariants,\n} from \"./plume-utils\";\n\nexport interface StyleProps {\n className?: string;\n style?: React.CSSProperties;\n}\n\nexport function getStyleProps<P extends StyleProps>(props: P): StyleProps {\n return pick(props, \"className\", \"style\");\n}\n\nexport function getDefaultPlasmicProps<C extends AnyPlasmicClass>(\n plasmicClass: C,\n props: Record<string, any>\n) {\n return {\n plasmicProps: {\n variants: pick(\n props,\n ...plasmicClass.internalVariantProps\n ) as PlasmicClassVariants<C>,\n args: pick(\n props,\n ...plasmicClass.internalArgProps\n ) as PlasmicClassArgs<C>,\n overrides: {} as PlasmicClassOverrides<C>,\n },\n };\n}\n\nconst RE_DATA_PROP = /^(data-.*)$/;\n\nexport function getDataProps(props: Record<string, any>) {\n return pickBy(props, (k) => RE_DATA_PROP.test(k));\n}\n"],"names":[],"mappings":";;SAcgB,aAAa,CAAuB,KAAQ;IAC1D,OAAO,IAAI,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;AAC3C;;;;"}
1
+ {"version":3,"file":"props-utils-228208e6.js","sources":["../../src/plume/props-utils.ts"],"sourcesContent":["import * as React from \"react\";\nimport { pick, pickBy } from \"../common\";\nimport {\n AnyPlasmicClass,\n PlasmicClassArgs,\n PlasmicClassOverrides,\n PlasmicClassVariants,\n} from \"./plume-utils\";\n\nexport interface StyleProps {\n className?: string;\n style?: React.CSSProperties;\n}\n\nexport function getStyleProps<P extends StyleProps>(props: P): StyleProps {\n return pick(props, \"className\", \"style\");\n}\n\nexport function getDefaultPlasmicProps<C extends AnyPlasmicClass>(\n plasmicClass: C,\n props: Record<string, any>\n) {\n return {\n plasmicProps: {\n variants: pick(\n props,\n ...plasmicClass.internalVariantProps\n ) as PlasmicClassVariants<C>,\n args: pick(\n props,\n ...plasmicClass.internalArgProps\n ) as PlasmicClassArgs<C>,\n overrides: {} as PlasmicClassOverrides<C>,\n },\n };\n}\n\nconst RE_DATA_PROP = /^(data-.*)$/;\n\nexport function getDataProps(props: Record<string, any>) {\n return pickBy(props, (k) => RE_DATA_PROP.test(k));\n}\n"],"names":[],"mappings":";;SAcgB,aAAa,CAAuB,KAAQ;IAC1D,OAAO,IAAI,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;AAC3C;;;;"}
@@ -1,4 +1,4 @@
1
- import { d as __values, b as __spreadArray, c as __read, a as __assign } from './common-182a0b0c.js';
1
+ import { d as __values, b as __spreadArray, c as __read, a as __assign } from './common-9ebe374e.js';
2
2
  import classNames from 'classnames';
3
3
  import React__default from 'react';
4
4
 
@@ -10,7 +10,7 @@ var useIsomorphicLayoutEffect = isBrowser
10
10
  function createElementWithChildren(elementType, props, children) {
11
11
  if (Array.isArray(children)) {
12
12
  return React__default.createElement.apply(React__default, __spreadArray([elementType,
13
- props], __read(children)));
13
+ props], __read(children), false));
14
14
  }
15
15
  else if (children || "children" in props) {
16
16
  // Only call React.createElement with `children` if there are actual children,
@@ -32,7 +32,7 @@ function ensureNotArray(children) {
32
32
  return children[0];
33
33
  }
34
34
  else {
35
- return React__default.createElement.apply(React__default, __spreadArray([React__default.Fragment, {}], __read(children)));
35
+ return React__default.createElement.apply(React__default, __spreadArray([React__default.Fragment, {}], __read(children), false));
36
36
  }
37
37
  }
38
38
  else {
@@ -173,10 +173,10 @@ function mergePropVals(name, val1, val2) {
173
173
  }
174
174
  var res;
175
175
  if (typeof val1 === "function") {
176
- res = val1.apply(void 0, __spreadArray([], __read(args)));
176
+ res = val1.apply(void 0, __spreadArray([], __read(args), false));
177
177
  }
178
178
  if (typeof val2 === "function") {
179
- res = val2.apply(void 0, __spreadArray([], __read(args)));
179
+ res = val2.apply(void 0, __spreadArray([], __read(args), false));
180
180
  }
181
181
  return res;
182
182
  };
@@ -198,4 +198,4 @@ function getElementTypeName(element) {
198
198
  }
199
199
 
200
200
  export { NONE as N, mergePropVals as a, isBrowser as b, createElementWithChildren as c, mergeRefs as d, ensureNotArray as e, getElementTypeName as g, isReactNode as i, mergeProps as m, toChildArray as t, useIsomorphicLayoutEffect as u };
201
- //# sourceMappingURL=react-utils-35cb2a4e.js.map
201
+ //# sourceMappingURL=react-utils-7bc53870.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"react-utils-35cb2a4e.js","sources":["../../src/react-utils.tsx"],"sourcesContent":["import classNames from \"classnames\";\nimport React from \"react\";\n\nexport const isBrowser = typeof window !== \"undefined\";\nexport const NONE = Symbol(\"NONE\");\n\nexport const useIsomorphicLayoutEffect = isBrowser\n ? React.useLayoutEffect\n : React.useEffect;\n\nexport function createElementWithChildren(\n elementType: any,\n props: any,\n children: React.ReactNode\n) {\n if (Array.isArray(children)) {\n return React.createElement(\n elementType,\n props,\n ...children\n ) as React.ReactElement;\n } else if (children || \"children\" in props) {\n // Only call React.createElement with `children` if there are actual children,\n // or if there was an explicit (albeit undefined) children passed via\n // props. Otherwise, if you pass `undefined` as the children argument\n // to React.createElement, the created element will have prop {children: undefined}.\n // If the `root` is an PlasmicGeneratedComponent, and these props with {children: undefined}\n // are used, then it will be taken as a `children` override, and will thus blank out\n // everything under the root node.\n return React.createElement(elementType, props, children);\n } else {\n return React.createElement(elementType, props);\n }\n}\n\nexport function ensureNotArray(children: React.ReactNode) {\n if (Array.isArray(children)) {\n if (children.length === 1) {\n return children[0];\n } else {\n return React.createElement(React.Fragment, {}, ...children);\n }\n } else {\n return children;\n }\n}\n\n/**\n * Flattens ReactNode into an array of ReactChild, but does NOT replace\n * missing keys with array index, as React.Children.toArray() does.\n */\nexport function toChildArray(children: React.ReactNode): React.ReactChild[] {\n if (isReactChild(children)) {\n return [children];\n } else if (Array.isArray(children)) {\n return children.flatMap(toChildArray);\n } else {\n return [];\n }\n}\n\nexport function isReactText(child: React.ReactNode): child is React.ReactText {\n return typeof child === \"string\" || typeof child === \"number\";\n}\n\nexport function isReactChild(\n child: React.ReactNode\n): child is React.ReactChild {\n return React.isValidElement(child) || isReactText(child);\n}\n\nexport function isReactFragment(\n child: React.ReactNode\n): child is React.ReactElement {\n return React.isValidElement(child) && child.type === React.Fragment;\n}\n\nexport function isReactNode(x: any) {\n return (\n typeof x === \"string\" || typeof x === \"number\" || React.isValidElement(x)\n );\n}\n\n// From https://stackoverflow.com/questions/54775790/forcing-excess-property-checking-on-variable-passed-to-typescript-function\n// We also wrap the error message in a Partial<> because otherwise Jetbrains IDEs will autocomplete the component with all the string methods as props - see https://github.com/plasmicapp/plasmic/issues/16.\nexport type StrictProps<T, TExpected> = Exclude<\n keyof T,\n keyof TExpected\n> extends never\n ? {}\n : Partial<\"Unexpected extraneous props\">;\n\nexport type HTMLElementRefOf<T extends keyof JSX.IntrinsicElements> = Exclude<\n React.ComponentProps<T>[\"ref\"],\n string\n>;\n\nexport function mergeProps(\n props: Record<string, any>,\n ...restProps: Record<string, any>[]\n): Record<string, any> {\n if (restProps.every((rest) => Object.keys(rest).length === 0)) {\n return props;\n }\n\n const result = { ...props };\n\n for (const rest of restProps) {\n for (const key of Object.keys(rest)) {\n result[key] = mergePropVals(key, result[key], rest[key]);\n }\n }\n\n return result;\n}\n\nfunction updateRef<T>(ref: React.Ref<T> | undefined, value: T | null) {\n if (!ref) {\n return;\n }\n\n if (typeof ref === \"function\") {\n ref(value);\n } else {\n if (!Object.isFrozen(ref)) {\n (ref as React.MutableRefObject<T | null>).current = value;\n }\n }\n}\n\nexport function mergeRefs<T>(...refs: (React.Ref<T> | undefined)[]) {\n return (value: T) => {\n for (const ref of refs) {\n updateRef(ref, value);\n }\n };\n}\n\nexport function mergePropVals(name: string, val1: any, val2: any): any {\n if (val1 === NONE || val2 === NONE) {\n // The NONE sentinel always skips all merging and returns null\n return null;\n } else if (val1 == null) {\n // If either of them is nil, prefer the other\n return val2;\n } else if (val2 == null) {\n return val1;\n } else if (name === \"className\") {\n // Special case for className -- always combine both class names\n return classNames(val1, val2);\n } else if (name === \"style\") {\n // Special case for style -- always shallow-merge style dicts\n return { ...val1, ...val2 };\n } else if (name === \"ref\") {\n // Special case for ref\n return mergeRefs(val1, val2);\n } else if (typeof val1 !== typeof val2) {\n // If the type of the two values are different, then no way to merge them.\n // Prefer val2.\n return val2;\n } else if (name.startsWith(\"on\") && typeof val1 === \"function\") {\n // Special case for event handlers -- always call both handlers\n return (...args: any[]) => {\n let res: any;\n if (typeof val1 === \"function\") {\n res = val1(...args);\n }\n if (typeof val2 === \"function\") {\n res = val2(...args);\n }\n return res;\n };\n } else {\n // For all else, prefer val2\n return val2;\n }\n}\n\nexport function getElementTypeName(element: React.ReactElement) {\n if (typeof element.type === \"string\") {\n return element.type;\n } else {\n const comp = element.type as any;\n return comp.displayName ?? comp.name ?? comp.render?.name ?? \"Component\";\n }\n}\n"],"names":["React"],"mappings":";;;;IAGa,SAAS,GAAG,OAAO,MAAM,KAAK,YAAY;IAC1C,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE;IAEtB,yBAAyB,GAAG,SAAS;MAC9CA,cAAK,CAAC,eAAe;MACrBA,cAAK,CAAC,UAAU;SAEJ,yBAAyB,CACvC,WAAgB,EAChB,KAAU,EACV,QAAyB;IAEzB,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;QAC3B,OAAOA,cAAK,CAAC,aAAa,OAAnBA,cAAK,iBACV,WAAW;YACX,KAAK,UACF,QAAQ,GACU,CAAC;KACzB;SAAM,IAAI,QAAQ,IAAI,UAAU,IAAI,KAAK,EAAE;;;;;;;;QAQ1C,OAAOA,cAAK,CAAC,aAAa,CAAC,WAAW,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;KAC1D;SAAM;QACL,OAAOA,cAAK,CAAC,aAAa,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;KAChD;AACH,CAAC;SAEe,cAAc,CAAC,QAAyB;IACtD,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;QAC3B,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE;YACzB,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC;SACpB;aAAM;YACL,OAAOA,cAAK,CAAC,aAAa,OA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,CAAC,CAAC;KAC/B;SAAM,IAAI,IAAI,KAAK,OAAO,EAAE;;QAE3B,6BAAY,IAAI,GAAK,IAAI,EAAG;KAC7B;SAAM,IAAI,IAAI,KAAK,KAAK,EAAE;;QAEzB,OAAO,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;KAC9B;SAAM,IAAI,OAAO,IAAI,KAAK,OAAO,IAAI,EAAE;;;QAGtC,OAAO,IAAI,CAAC;KACb;SAAM,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,OAAO,IAAI,KAAK,UAAU,EAAE;;QAE9D,OAAO;YAAC,cAAc;iBAAd,UAAc,EAAd,qBAAc,EAAd,IAAc;gBAAd,yBAAc;;YACpB,IAAI,GAAQ,CAAC;YACb,IAAI,OAAO,IAAI,KAAK,UAAU,EAAE;gBAC9B,GAAG,GAAG,IAAI,wCAAI,IAAI,GAAC,CAAC;aACrB;YACD,IAAI,OAAO,IAAI,KAAK,UAAU,EAAE;gBAC9B,GAAG,GAAG,IAAI,wCAAI,IAAI,GAAC,CAAC;aACrB;YACD,OAAO,GAAG,CAAC;SACZ,CAAC;KACH;SAAM;;QAEL,OAAO,IAAI,CAAC;KACb;AACH,CAAC;SAEe,kBAAkB,CAAC,OAA2B;;IAC5D,IAAI,OAAO,OAAO,CAAC,IAAI,KAAK,QAAQ,EAAE;QACpC,OAAO,OAAO,CAAC,IAAI,CAAC;KACrB;SAAM;QACL,IAAM,IAAI,GAAG,OAAO,CAAC,IAAW,CAAC;QACjC,OAAO,MAAA,MAAA,MAAA,IAAI,CAAC,WAAW,mCAAI,IAAI,CAAC,IAAI,mCAAI,MAAA,IAAI,CAAC,MAAM,0CAAE,IAAI,mCAAI,WAAW,CAAC;KAC1E;AACH;;;;"}
1
+ {"version":3,"file":"react-utils-7bc53870.js","sources":["../../src/react-utils.tsx"],"sourcesContent":["import classNames from \"classnames\";\nimport React from \"react\";\n\nexport const isBrowser = typeof window !== \"undefined\";\nexport const NONE = Symbol(\"NONE\");\n\nexport const useIsomorphicLayoutEffect = isBrowser\n ? React.useLayoutEffect\n : React.useEffect;\n\nexport function createElementWithChildren(\n elementType: any,\n props: any,\n children: React.ReactNode\n) {\n if (Array.isArray(children)) {\n return React.createElement(\n elementType,\n props,\n ...children\n ) as React.ReactElement;\n } else if (children || \"children\" in props) {\n // Only call React.createElement with `children` if there are actual children,\n // or if there was an explicit (albeit undefined) children passed via\n // props. Otherwise, if you pass `undefined` as the children argument\n // to React.createElement, the created element will have prop {children: undefined}.\n // If the `root` is an PlasmicGeneratedComponent, and these props with {children: undefined}\n // are used, then it will be taken as a `children` override, and will thus blank out\n // everything under the root node.\n return React.createElement(elementType, props, children);\n } else {\n return React.createElement(elementType, props);\n }\n}\n\nexport function ensureNotArray(children: React.ReactNode) {\n if (Array.isArray(children)) {\n if (children.length === 1) {\n return children[0];\n } else {\n return React.createElement(React.Fragment, {}, ...children);\n }\n } else {\n return children;\n }\n}\n\n/**\n * Flattens ReactNode into an array of ReactChild, but does NOT replace\n * missing keys with array index, as React.Children.toArray() does.\n */\nexport function toChildArray(children: React.ReactNode): React.ReactChild[] {\n if (isReactChild(children)) {\n return [children];\n } else if (Array.isArray(children)) {\n return children.flatMap(toChildArray);\n } else {\n return [];\n }\n}\n\nexport function isReactText(child: React.ReactNode): child is React.ReactText {\n return typeof child === \"string\" || typeof child === \"number\";\n}\n\nexport function isReactChild(\n child: React.ReactNode\n): child is React.ReactChild {\n return React.isValidElement(child) || isReactText(child);\n}\n\nexport function isReactFragment(\n child: React.ReactNode\n): child is React.ReactElement {\n return React.isValidElement(child) && child.type === React.Fragment;\n}\n\nexport function isReactNode(x: any) {\n return (\n typeof x === \"string\" || typeof x === \"number\" || React.isValidElement(x)\n );\n}\n\n// From https://stackoverflow.com/questions/54775790/forcing-excess-property-checking-on-variable-passed-to-typescript-function\n// We also wrap the error message in a Partial<> because otherwise Jetbrains IDEs will autocomplete the component with all the string methods as props - see https://github.com/plasmicapp/plasmic/issues/16.\nexport type StrictProps<T, TExpected> = Exclude<\n keyof T,\n keyof TExpected\n> extends never\n ? {}\n : Partial<\"Unexpected extraneous props\">;\n\nexport type HTMLElementRefOf<T extends keyof JSX.IntrinsicElements> = Exclude<\n React.ComponentProps<T>[\"ref\"],\n string\n>;\n\nexport function mergeProps(\n props: Record<string, any>,\n ...restProps: Record<string, any>[]\n): Record<string, any> {\n if (restProps.every((rest) => Object.keys(rest).length === 0)) {\n return props;\n }\n\n const result = { ...props };\n\n for (const rest of restProps) {\n for (const key of Object.keys(rest)) {\n result[key] = mergePropVals(key, result[key], rest[key]);\n }\n }\n\n return result;\n}\n\nfunction updateRef<T>(ref: React.Ref<T> | undefined, value: T | null) {\n if (!ref) {\n return;\n }\n\n if (typeof ref === \"function\") {\n ref(value);\n } else {\n if (!Object.isFrozen(ref)) {\n (ref as React.MutableRefObject<T | null>).current = value;\n }\n }\n}\n\nexport function mergeRefs<T>(...refs: (React.Ref<T> | undefined)[]) {\n return (value: T) => {\n for (const ref of refs) {\n updateRef(ref, value);\n }\n };\n}\n\nexport function mergePropVals(name: string, val1: any, val2: any): any {\n if (val1 === NONE || val2 === NONE) {\n // The NONE sentinel always skips all merging and returns null\n return null;\n } else if (val1 == null) {\n // If either of them is nil, prefer the other\n return val2;\n } else if (val2 == null) {\n return val1;\n } else if (name === \"className\") {\n // Special case for className -- always combine both class names\n return classNames(val1, val2);\n } else if (name === \"style\") {\n // Special case for style -- always shallow-merge style dicts\n return { ...val1, ...val2 };\n } else if (name === \"ref\") {\n // Special case for ref\n return mergeRefs(val1, val2);\n } else if (typeof val1 !== typeof val2) {\n // If the type of the two values are different, then no way to merge them.\n // Prefer val2.\n return val2;\n } else if (name.startsWith(\"on\") && typeof val1 === \"function\") {\n // Special case for event handlers -- always call both handlers\n return (...args: any[]) => {\n let res: any;\n if (typeof val1 === \"function\") {\n res = val1(...args);\n }\n if (typeof val2 === \"function\") {\n res = val2(...args);\n }\n return res;\n };\n } else {\n // For all else, prefer val2\n return val2;\n }\n}\n\nexport function getElementTypeName(element: React.ReactElement) {\n if (typeof element.type === \"string\") {\n return element.type;\n } else {\n const comp = element.type as any;\n return comp.displayName ?? comp.name ?? comp.render?.name ?? \"Component\";\n }\n}\n"],"names":["React"],"mappings":";;;;IAGa,SAAS,GAAG,OAAO,MAAM,KAAK,YAAY;IAC1C,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE;IAEtB,yBAAyB,GAAG,SAAS;MAC9CA,cAAK,CAAC,eAAe;MACrBA,cAAK,CAAC,UAAU;SAEJ,yBAAyB,CACvC,WAAgB,EAChB,KAAU,EACV,QAAyB;IAEzB,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;QAC3B,OAAOA,cAAK,CAAC,aAAa,OAAnBA,cAAK,iBACV,WAAW;YACX,KAAK,UACF,QAAQ,UACU,CAAC;KACzB;SAAM,IAAI,QAAQ,IAAI,UAAU,IAAI,KAAK,EAAE;;;;;;;;QAQ1C,OAAOA,cAAK,CAAC,aAAa,CAAC,WAAW,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;KAC1D;SAAM;QACL,OAAOA,cAAK,CAAC,aAAa,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;KAChD;AACH,CAAC;SAEe,cAAc,CAAC,QAAyB;IACtD,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;QAC3B,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE;YACzB,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC;SACpB;aAAM;YACL,OAAOA,cAAK,CAAC,aAAa,OAAnBA,cAAK,iBAAeA,cAAK,CAAC,QAAQ,EAAE,EAAE,UAAK,QAAQ,WAAE;SAC7D;KACF;SAAM;QACL,OAAO,QAAQ,CAAC;KACjB;AACH,CAAC;AAED;;;;SAIgB,YAAY,CAAC,QAAyB;IACpD,IAAI,YAAY,CAAC,QAAQ,CAAC,EAAE;QAC1B,OAAO,CAAC,QAAQ,CAAC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