@plasmicapp/react-web 0.2.105 → 0.2.108
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/all.d.ts +36 -2
- package/dist/index-common.d.ts +2 -1
- package/dist/plume/triggered-overlay/triggered-overlay.d.ts +1 -1
- package/dist/react-web.cjs.development.js +88 -3
- package/dist/react-web.cjs.development.js.map +1 -1
- package/dist/react-web.cjs.production.min.js +1 -1
- package/dist/react-web.cjs.production.min.js.map +1 -1
- package/dist/react-web.esm.js +88 -5
- package/dist/react-web.esm.js.map +1 -1
- package/dist/render/PlasmicHead/index.d.ts +35 -0
- package/dist/render/ssr.d.ts +2 -1
- package/package.json +1 -1
- package/skinny/dist/index-common.d.ts +2 -1
- package/skinny/dist/index.js +3 -2
- package/skinny/dist/index.js.map +1 -1
- package/skinny/dist/plume/checkbox/index.js +2 -1
- package/skinny/dist/plume/checkbox/index.js.map +1 -1
- package/skinny/dist/plume/menu/index.js +2 -1
- package/skinny/dist/plume/menu/index.js.map +1 -1
- package/skinny/dist/plume/menu-button/index.js +2 -1
- package/skinny/dist/plume/menu-button/index.js.map +1 -1
- package/skinny/dist/plume/select/index.js +2 -1
- package/skinny/dist/plume/select/index.js.map +1 -1
- package/skinny/dist/plume/switch/index.js +2 -1
- package/skinny/dist/plume/switch/index.js.map +1 -1
- package/skinny/dist/plume/triggered-overlay/index.js +3 -2
- package/skinny/dist/plume/triggered-overlay/index.js.map +1 -1
- package/skinny/dist/plume/triggered-overlay/triggered-overlay.d.ts +1 -1
- package/skinny/dist/render/PlasmicHead/index.d.ts +35 -0
- package/skinny/dist/render/PlasmicHead/index.js +53 -0
- package/skinny/dist/render/PlasmicHead/index.js.map +1 -0
- package/skinny/dist/render/PlasmicHead.d.ts +35 -0
- package/skinny/dist/render/ssr.d.ts +2 -1
- package/skinny/dist/{ssr-a8081074.js → ssr-14264281.js} +57 -7
- package/skinny/dist/ssr-14264281.js.map +1 -0
- package/skinny/dist/{ssr-902d1292.js → ssr-5141fc77.js} +62 -9
- package/skinny/dist/ssr-5141fc77.js.map +1 -0
- package/skinny/dist/ssr-579df58f.js +158 -0
- package/skinny/dist/ssr-579df58f.js.map +1 -0
- package/skinny/dist/{ssr-64e38713.js → ssr-84e27ffb.js} +5 -3
- package/skinny/dist/ssr-84e27ffb.js.map +1 -0
- package/skinny/dist/ssr-9ebd98ed.js +158 -0
- package/skinny/dist/ssr-9ebd98ed.js.map +1 -0
- package/skinny/dist/collection-utils-47e89cbe.js +0 -238
- package/skinny/dist/collection-utils-47e89cbe.js.map +0 -1
- package/skinny/dist/collection-utils-4dae6efa.js +0 -292
- package/skinny/dist/collection-utils-4dae6efa.js.map +0 -1
- package/skinny/dist/collection-utils-57ec40f9.js +0 -292
- package/skinny/dist/collection-utils-57ec40f9.js.map +0 -1
- package/skinny/dist/collection-utils-96cde83c.js +0 -238
- package/skinny/dist/collection-utils-96cde83c.js.map +0 -1
- package/skinny/dist/collection-utils-b0b8f30e.js +0 -291
- package/skinny/dist/collection-utils-b0b8f30e.js.map +0 -1
- package/skinny/dist/plume-utils-5c413fd1.js +0 -35
- package/skinny/dist/plume-utils-5c413fd1.js.map +0 -1
- package/skinny/dist/props-utils-4633caf6.js +0 -8
- package/skinny/dist/props-utils-4633caf6.js.map +0 -1
- package/skinny/dist/props-utils-5c0ad25a.js +0 -59
- package/skinny/dist/props-utils-5c0ad25a.js.map +0 -1
- package/skinny/dist/props-utils-754f655a.js +0 -39
- package/skinny/dist/props-utils-754f655a.js.map +0 -1
- package/skinny/dist/props-utils-c632595f.js +0 -59
- package/skinny/dist/props-utils-c632595f.js.map +0 -1
- package/skinny/dist/props-utils-fd5f444e.js +0 -59
- package/skinny/dist/props-utils-fd5f444e.js.map +0 -1
- package/skinny/dist/react-utils-118d8539.js +0 -190
- package/skinny/dist/react-utils-118d8539.js.map +0 -1
- package/skinny/dist/react-utils-2a2fd6c9.js +0 -339
- package/skinny/dist/react-utils-2a2fd6c9.js.map +0 -1
- package/skinny/dist/react-utils-2d70bbbe.js +0 -172
- package/skinny/dist/react-utils-2d70bbbe.js.map +0 -1
- package/skinny/dist/react-utils-675565b4.js +0 -334
- package/skinny/dist/react-utils-675565b4.js.map +0 -1
- package/skinny/dist/render/PlasmicImg.d.ts +0 -62
- package/skinny/dist/ssr-64e38713.js.map +0 -1
- package/skinny/dist/ssr-902d1292.js.map +0 -1
- package/skinny/dist/ssr-a8081074.js.map +0 -1
- package/skinny/dist/tslib.es6-00014098.js +0 -148
- package/skinny/dist/tslib.es6-00014098.js.map +0 -1
- package/skinny/dist/tslib.es6-73236e8e.js +0 -141
- package/skinny/dist/tslib.es6-73236e8e.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,G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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,mBAC9C,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
|
+
{"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,CAAC,GAAA,EAC1D,EAAE,CACH,CAAC;IAEF,IAAM,iBAAiB,GAAG,KAAK,CAAC,OAAO,CAAC;QACtC,IAAI,QAAQ,EAAE;YACZ,OAAO,UAAC,GAAkB;gBACxB,OAAA,QAAS,EACN,GAAG,IAAI,IAAI,IAAI,GAAG,KAAK,MAAM,GAAG,IAAI,GAAG,GAAG,EA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AK,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;;;;"}
|
|
@@ -4,11 +4,12 @@ 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
6
|
import { m as mergeProps } from '../../react-utils-35cb2a4e.js';
|
|
7
|
-
import { a as useEnsureSSRProvider } from '../../ssr-
|
|
7
|
+
import { a as useEnsureSSRProvider } from '../../ssr-84e27ffb.js';
|
|
8
8
|
import { m as mergeVariantToggles } from '../../plume-utils-623b91cc.js';
|
|
9
9
|
import { g as getStyleProps } from '../../props-utils-b2ad4997.js';
|
|
10
10
|
import 'classnames';
|
|
11
11
|
import '@react-aria/ssr';
|
|
12
|
+
import '../../render/PlasmicHead/index.js';
|
|
12
13
|
|
|
13
14
|
function asAriaSwitchProps(props) {
|
|
14
15
|
var ariaProps = __assign(__assign({}, props), { isSelected: props.isChecked, defaultSelected: props.defaultChecked });
|
|
@@ -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":"
|
|
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;I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A;QAC9B,KAAK,EAAE,sBAAM,OAAA,MAAA,QAAQ,CAAC,OAAO,0CAAE,KAAK,EAAE,CAAA,EAAA;QACtC,IAAI,EAAE,sBAAM,OAAA,MAAA,QAAQ,CAAC,OAAO,0CAAE,IAAI,EAAE,CAAA,EAAA;QACpC,UAAU,EAAE,UAAC,OAAO,IAAK,OAAA,UAAU,CAAC,UAAU,CAAC,OAAO,CAAC,GAAA;KACxD,IAAC,EACF,CAAC,OAAO,EAAE,QAAQ,EAAE,UAAU,CAAC,CAChC,CAAC;IAEF,OAAO;QACL,YAAY,EAAE;YACZ,QAAQ,EAAE,QAAmC;YAC7C,SAAS,EAAE,SAAqC;YAChD,IAAI,EAAE,IAA2B;SAClC;QACD,KAAK,EAAE,UAAU;KAClB,CAAC;AACJ;;;;"}
|
|
@@ -10,9 +10,10 @@ import { T as TriggeredOverlayContext } from '../../context-034b8d25.js';
|
|
|
10
10
|
export { T as TriggeredOverlayContext } from '../../context-034b8d25.js';
|
|
11
11
|
import 'classnames';
|
|
12
12
|
|
|
13
|
-
function useTriggeredOverlay(plasmicClass, props, config, outerRef) {
|
|
13
|
+
function useTriggeredOverlay(plasmicClass, props, config, outerRef, isDismissable) {
|
|
14
14
|
var _a, _b;
|
|
15
15
|
if (outerRef === void 0) { outerRef = null; }
|
|
16
|
+
if (isDismissable === void 0) { isDismissable = true; }
|
|
16
17
|
var overlayRef = React.useRef(null);
|
|
17
18
|
var onOverlayRef = mergeRefs(overlayRef, outerRef);
|
|
18
19
|
var context = React.useContext(TriggeredOverlayContext);
|
|
@@ -46,7 +47,7 @@ function useTriggeredOverlay(plasmicClass, props, config, outerRef) {
|
|
|
46
47
|
var overlayAriaProps = useOverlay({
|
|
47
48
|
isOpen: state.isOpen,
|
|
48
49
|
onClose: state.close,
|
|
49
|
-
isDismissable:
|
|
50
|
+
isDismissable: isDismissable,
|
|
50
51
|
shouldCloseOnBlur: true,
|
|
51
52
|
}, overlayRef).overlayProps;
|
|
52
53
|
var _d = useOverlayPosition({
|
|
@@ -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) {\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
|
|
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,CA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@@ export interface TriggeredOverlayConfig<C extends AnyPlasmicClass> {
|
|
|
15
15
|
contentContainer: keyof PlasmicClassOverrides<C>;
|
|
16
16
|
}
|
|
17
17
|
export declare type TriggeredOverlayRef = React.Ref<HTMLElement>;
|
|
18
|
-
export declare function useTriggeredOverlay<P extends BaseTriggeredOverlayProps, C extends AnyPlasmicClass>(plasmicClass: C, props: P, config: TriggeredOverlayConfig<C>, outerRef?: TriggeredOverlayRef): {
|
|
18
|
+
export declare function useTriggeredOverlay<P extends BaseTriggeredOverlayProps, C extends AnyPlasmicClass>(plasmicClass: C, props: P, config: TriggeredOverlayConfig<C>, outerRef?: TriggeredOverlayRef, isDismissable?: boolean): {
|
|
19
19
|
plasmicProps: {
|
|
20
20
|
variants: PlasmicClassVariants<C>;
|
|
21
21
|
args: PlasmicClassArgs<C>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export declare const PlasmicHeadContext: React.Context<React.ComponentType<any> | undefined>;
|
|
3
|
+
declare type PlasmicHeadProps = {
|
|
4
|
+
title?: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
image?: string;
|
|
7
|
+
canonical?: string;
|
|
8
|
+
};
|
|
9
|
+
export declare function PlasmicHead(props: PlasmicHeadProps): JSX.Element | null;
|
|
10
|
+
export declare const plasmicHeadMeta: {
|
|
11
|
+
name: string;
|
|
12
|
+
displayName: string;
|
|
13
|
+
description: string;
|
|
14
|
+
importName: string;
|
|
15
|
+
importPath: string;
|
|
16
|
+
props: {
|
|
17
|
+
title: {
|
|
18
|
+
type: string;
|
|
19
|
+
displayName: string;
|
|
20
|
+
};
|
|
21
|
+
description: {
|
|
22
|
+
type: string;
|
|
23
|
+
displayName: string;
|
|
24
|
+
};
|
|
25
|
+
image: {
|
|
26
|
+
type: string;
|
|
27
|
+
displayName: string;
|
|
28
|
+
};
|
|
29
|
+
canonical: {
|
|
30
|
+
type: string;
|
|
31
|
+
displayName: string;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
var PlasmicHeadContext = React.createContext(undefined);
|
|
4
|
+
function PlasmicHead(props) {
|
|
5
|
+
var Head = React.useContext(PlasmicHeadContext);
|
|
6
|
+
if (!Head) {
|
|
7
|
+
console.warn("Plasmic: Head meta tags are being ignored. To make them work, pass a Head component into PlasmicRootProvider.");
|
|
8
|
+
// TODO: Link to doc about Head.
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
return (React.createElement(Head, null,
|
|
12
|
+
props.image ? (React.createElement(React.Fragment, null,
|
|
13
|
+
React.createElement("meta", { name: "twitter:card", content: "summary_large_image" }),
|
|
14
|
+
React.createElement("meta", { key: "og:image", property: "og:image", content: props.image }),
|
|
15
|
+
React.createElement("meta", { key: "twitter:image", name: "twitter:image", content: props.image }))) : (React.createElement("meta", { name: "twitter:card", content: "summary" })),
|
|
16
|
+
props.title && (React.createElement(React.Fragment, null,
|
|
17
|
+
React.createElement("title", { key: "title" }, props.title),
|
|
18
|
+
React.createElement("meta", { key: "og:title", property: "og:title", content: props.title }),
|
|
19
|
+
React.createElement("meta", { key: "twitter:title", property: "twitter:title", content: props.title }))),
|
|
20
|
+
props.description && (React.createElement(React.Fragment, null,
|
|
21
|
+
React.createElement("meta", { key: "description", name: "description", content: props.description }),
|
|
22
|
+
React.createElement("meta", { key: "og:description", property: "og:description", content: props.description }),
|
|
23
|
+
React.createElement("meta", { key: "twitter:description", name: "twitter:description", content: props.description }))),
|
|
24
|
+
props.canonical && React.createElement("link", { ref: "canonical", href: props.canonical })));
|
|
25
|
+
}
|
|
26
|
+
var plasmicHeadMeta = {
|
|
27
|
+
name: "hostless-plasmic-head",
|
|
28
|
+
displayName: "Head",
|
|
29
|
+
description: "Used to add page metadata to HEAD tag",
|
|
30
|
+
importName: "PlasmicHead",
|
|
31
|
+
importPath: "@plasmicapp/react-web",
|
|
32
|
+
props: {
|
|
33
|
+
title: {
|
|
34
|
+
type: "string",
|
|
35
|
+
displayName: "Title",
|
|
36
|
+
},
|
|
37
|
+
description: {
|
|
38
|
+
type: "string",
|
|
39
|
+
displayName: "Description",
|
|
40
|
+
},
|
|
41
|
+
image: {
|
|
42
|
+
type: "imageUrl",
|
|
43
|
+
displayName: "Image",
|
|
44
|
+
},
|
|
45
|
+
canonical: {
|
|
46
|
+
type: "string",
|
|
47
|
+
displayName: "Canonical URL",
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export { PlasmicHead, PlasmicHeadContext, plasmicHeadMeta };
|
|
53
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/render/PlasmicHead/index.tsx"],"sourcesContent":["import * as React from \"react\";\n\nexport const PlasmicHeadContext = React.createContext<\n React.ComponentType<any> | undefined\n>(undefined);\n\ntype PlasmicHeadProps = {\n title?: string;\n description?: string;\n image?: string;\n canonical?: string;\n};\n\nexport function PlasmicHead(props: PlasmicHeadProps) {\n const Head = React.useContext(PlasmicHeadContext);\n if (!Head) {\n console.warn(\n `Plasmic: Head meta tags are being ignored. To make them work, pass a Head component into PlasmicRootProvider.`\n );\n // TODO: Link to doc about Head.\n return null;\n }\n\n return (\n <Head>\n {props.image ? (\n <>\n <meta name=\"twitter:card\" content=\"summary_large_image\" />\n <meta key=\"og:image\" property=\"og:image\" content={props.image} />\n <meta\n key=\"twitter:image\"\n name=\"twitter:image\"\n content={props.image}\n />\n </>\n ) : (\n <meta name=\"twitter:card\" content=\"summary\" />\n )}\n {props.title && (\n <>\n <title key=\"title\">{props.title}</title>\n <meta key=\"og:title\" property=\"og:title\" content={props.title} />\n <meta\n key=\"twitter:title\"\n property=\"twitter:title\"\n content={props.title}\n />\n </>\n )}\n {props.description && (\n <>\n <meta\n key=\"description\"\n name=\"description\"\n content={props.description}\n />\n <meta\n key=\"og:description\"\n property=\"og:description\"\n content={props.description}\n />\n <meta\n key=\"twitter:description\"\n name=\"twitter:description\"\n content={props.description}\n />\n </>\n )}\n {props.canonical && <link ref=\"canonical\" href={props.canonical} />}\n </Head>\n );\n}\n\nexport const plasmicHeadMeta = {\n name: \"hostless-plasmic-head\",\n displayName: \"Head\",\n description: \"Used to add page metadata to HEAD tag\",\n importName: \"PlasmicHead\",\n importPath: \"@plasmicapp/react-web\",\n props: {\n title: {\n type: \"string\",\n displayName: \"Title\",\n },\n description: {\n type: \"string\",\n displayName: \"Description\",\n },\n image: {\n type: \"imageUrl\",\n displayName: \"Image\",\n },\n canonical: {\n type: \"string\",\n displayName: \"Canonical URL\",\n },\n },\n};\n"],"names":[],"mappings":";;IAEa,kBAAkB,GAAG,KAAK,CAAC,aAAa,CAEnD,SAAS,EAAE;SASG,WAAW,CAAC,KAAuB;IACjD,IAAM,IAAI,GAAG,KAAK,CAAC,UAAU,CAAC,kBAAkB,CAAC,CAAC;IAClD,IAAI,CAAC,IAAI,EAAE;QACT,OAAO,CAAC,IAAI,CACV,+GAA+G,CAChH,CAAC;;QAEF,OAAO,IAAI,CAAC;KACb;IAED,QACE,oBAAC,IAAI;QACF,KAAK,CAAC,KAAK,IACV;YACE,8BAAM,IAAI,EAAC,cAAc,EAAC,OAAO,EAAC,qBAAqB,GAAG;YAC1D,8BAAM,GAAG,EAAC,UAAU,EAAC,QAAQ,EAAC,UAAU,EAAC,OAAO,EAAE,KAAK,CAAC,KAAK,GAAI;YACjE,8BACE,GAAG,EAAC,eAAe,EACnB,IAAI,EAAC,eAAe,EACpB,OAAO,EAAE,KAAK,CAAC,KAAK,GACpB,CACD,KAEH,8BAAM,IAAI,EAAC,cAAc,EAAC,OAAO,EAAC,SAAS,GAAG,CAC/C;QACA,KAAK,CAAC,KAAK,KACV;YACE,+BAAO,GAAG,EAAC,OAAO,IAAE,KAAK,CAAC,KAAK,CAAS;YACxC,8BAAM,GAAG,EAAC,UAAU,EAAC,QAAQ,EAAC,UAAU,EAAC,OAAO,EAAE,KAAK,CAAC,KAAK,GAAI;YACjE,8BACE,GAAG,EAAC,eAAe,EACnB,QAAQ,EAAC,eAAe,EACxB,OAAO,EAAE,KAAK,CAAC,KAAK,GACpB,CACD,CACJ;QACA,KAAK,CAAC,WAAW,KAChB;YACE,8BACE,GAAG,EAAC,aAAa,EACjB,IAAI,EAAC,aAAa,EAClB,OAAO,EAAE,KAAK,CAAC,WAAW,GAC1B;YACF,8BACE,GAAG,EAAC,gBAAgB,EACpB,QAAQ,EAAC,gBAAgB,EACzB,OAAO,EAAE,KAAK,CAAC,WAAW,GAC1B;YACF,8BACE,GAAG,EAAC,qBAAqB,EACzB,IAAI,EAAC,qBAAqB,EAC1B,OAAO,EAAE,KAAK,CAAC,WAAW,GAC1B,CACD,CACJ;QACA,KAAK,CAAC,SAAS,IAAI,8BAAM,GAAG,EAAC,WAAW,EAAC,IAAI,EAAE,KAAK,CAAC,SAAS,GAAI,CAC9D,EACP;AACJ,CAAC;IAEY,eAAe,GAAG;IAC7B,IAAI,EAAE,uBAAuB;IAC7B,WAAW,EAAE,MAAM;IACnB,WAAW,EAAE,uCAAuC;IACpD,UAAU,EAAE,aAAa;IACzB,UAAU,EAAE,uBAAuB;IACnC,KAAK,EAAE;QACL,KAAK,EAAE;YACL,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,OAAO;SACrB;QACD,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,aAAa;SAC3B;QACD,KAAK,EAAE;YACL,IAAI,EAAE,UAAU;YAChB,WAAW,EAAE,OAAO;SACrB;QACD,SAAS,EAAE;YACT,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,eAAe;SAC7B;KACF;;;;;"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export declare const PlasmicHeadContext: React.Context<React.ComponentType<any> | undefined>;
|
|
3
|
+
declare type PlasmicHeadProps = {
|
|
4
|
+
title?: string;
|
|
5
|
+
description?: string;
|
|
6
|
+
image?: string;
|
|
7
|
+
canonical?: string;
|
|
8
|
+
};
|
|
9
|
+
export declare function PlasmicHead(props: PlasmicHeadProps): JSX.Element | null;
|
|
10
|
+
export declare const plasmicHeadMeta: {
|
|
11
|
+
name: string;
|
|
12
|
+
displayName: string;
|
|
13
|
+
description: string;
|
|
14
|
+
importName: string;
|
|
15
|
+
importPath: string;
|
|
16
|
+
props: {
|
|
17
|
+
title: {
|
|
18
|
+
type: string;
|
|
19
|
+
displayName: string;
|
|
20
|
+
};
|
|
21
|
+
description: {
|
|
22
|
+
type: string;
|
|
23
|
+
displayName: string;
|
|
24
|
+
};
|
|
25
|
+
image: {
|
|
26
|
+
type: string;
|
|
27
|
+
displayName: string;
|
|
28
|
+
};
|
|
29
|
+
canonical: {
|
|
30
|
+
type: string;
|
|
31
|
+
displayName: string;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
1
|
import { useIsSSR as useAriaIsSSR } from "@react-aria/ssr";
|
|
2
|
+
import * as React from "react";
|
|
3
3
|
import { PlasmicTranslator } from "./translation";
|
|
4
4
|
export interface PlasmicRootContextValue {
|
|
5
5
|
platform?: "nextjs" | "gatsby";
|
|
@@ -8,6 +8,7 @@ export interface PlasmicRootProviderProps {
|
|
|
8
8
|
platform?: "nextjs" | "gatsby";
|
|
9
9
|
children?: React.ReactNode;
|
|
10
10
|
translator?: PlasmicTranslator;
|
|
11
|
+
Head?: React.ComponentType<any>;
|
|
11
12
|
}
|
|
12
13
|
export declare function PlasmicRootProvider(props: PlasmicRootProviderProps): JSX.Element;
|
|
13
14
|
export declare const useIsSSR: typeof useAriaIsSSR;
|
|
@@ -1,6 +1,55 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import React__default from 'react';
|
|
3
|
-
import { SSRProvider, useIsSSR as useIsSSR$1 } from 'react-aria';
|
|
3
|
+
import { SSRProvider, useIsSSR as useIsSSR$1 } from '@react-aria/ssr';
|
|
4
|
+
|
|
5
|
+
var PlasmicHeadContext = React.createContext(undefined);
|
|
6
|
+
function PlasmicHead(props) {
|
|
7
|
+
var Head = React.useContext(PlasmicHeadContext);
|
|
8
|
+
if (!Head) {
|
|
9
|
+
console.warn("Plasmic: Head meta tags are being ignored. To make them work, pass a Head component into PlasmicRootProvider.");
|
|
10
|
+
// TODO: Link to doc about Head.
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
return (React.createElement(Head, null,
|
|
14
|
+
props.image ? (React.createElement(React.Fragment, null,
|
|
15
|
+
React.createElement("meta", { name: "twitter:card", content: "summary_large_image" }),
|
|
16
|
+
React.createElement("meta", { key: "og:image", property: "og:image", content: props.image }),
|
|
17
|
+
React.createElement("meta", { key: "twitter:image", name: "twitter:image", content: props.image }))) : (React.createElement("meta", { name: "twitter:card", content: "summary" })),
|
|
18
|
+
props.title && (React.createElement(React.Fragment, null,
|
|
19
|
+
React.createElement("title", { key: "title" }, props.title),
|
|
20
|
+
React.createElement("meta", { key: "og:title", property: "og:title", content: props.title }),
|
|
21
|
+
React.createElement("meta", { key: "twitter:title", property: "twitter:title", content: props.title }))),
|
|
22
|
+
props.description && (React.createElement(React.Fragment, null,
|
|
23
|
+
React.createElement("meta", { key: "description", name: "description", content: props.description }),
|
|
24
|
+
React.createElement("meta", { key: "og:description", property: "og:description", content: props.description }),
|
|
25
|
+
React.createElement("meta", { key: "twitter:description", name: "twitter:description", content: props.description }))),
|
|
26
|
+
props.canonical && React.createElement("link", { ref: "canonical", href: props.canonical })));
|
|
27
|
+
}
|
|
28
|
+
var plasmicHeadMeta = {
|
|
29
|
+
name: "hostless-plasmic-head",
|
|
30
|
+
displayName: "Head",
|
|
31
|
+
description: "Used to add page metadata to HEAD tag",
|
|
32
|
+
importName: "PlasmicHead",
|
|
33
|
+
importPath: "@plasmicapp/react-web",
|
|
34
|
+
props: {
|
|
35
|
+
title: {
|
|
36
|
+
type: "string",
|
|
37
|
+
displayName: "Title",
|
|
38
|
+
},
|
|
39
|
+
description: {
|
|
40
|
+
type: "string",
|
|
41
|
+
displayName: "Description",
|
|
42
|
+
},
|
|
43
|
+
image: {
|
|
44
|
+
type: "imageUrl",
|
|
45
|
+
displayName: "Image",
|
|
46
|
+
},
|
|
47
|
+
canonical: {
|
|
48
|
+
type: "string",
|
|
49
|
+
displayName: "Canonical URL",
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
};
|
|
4
53
|
|
|
5
54
|
var PlasmicTranslatorContext = React__default.createContext(undefined);
|
|
6
55
|
function isIterable(val) {
|
|
@@ -39,15 +88,15 @@ function genTranslatableString(elt) {
|
|
|
39
88
|
if (React__default.isValidElement(node) && node.type === React__default.Fragment) {
|
|
40
89
|
return contents;
|
|
41
90
|
}
|
|
42
|
-
var componentId = componentsCount;
|
|
91
|
+
var componentId = componentsCount + 1;
|
|
43
92
|
componentsCount++;
|
|
44
|
-
components[
|
|
93
|
+
components[componentId] = React__default.isValidElement(node)
|
|
45
94
|
? React__default.cloneElement(node, {
|
|
46
95
|
key: componentId,
|
|
47
96
|
children: undefined,
|
|
48
97
|
})
|
|
49
98
|
: node;
|
|
50
|
-
return "<
|
|
99
|
+
return "<" + componentId + ">" + contents + "</" + componentId + ">";
|
|
51
100
|
};
|
|
52
101
|
var str = getText(elt);
|
|
53
102
|
return {
|
|
@@ -85,7 +134,8 @@ function PlasmicRootProvider(props) {
|
|
|
85
134
|
}); }, [platform]);
|
|
86
135
|
return (React.createElement(PlasmicRootContext.Provider, { value: context },
|
|
87
136
|
React.createElement(SSRProvider, null,
|
|
88
|
-
React.createElement(PlasmicTranslatorContext.Provider, { value: props.translator },
|
|
137
|
+
React.createElement(PlasmicTranslatorContext.Provider, { value: props.translator },
|
|
138
|
+
React.createElement(PlasmicHeadContext.Provider, { value: props.head }, children)))));
|
|
89
139
|
}
|
|
90
140
|
var useIsSSR = useIsSSR$1;
|
|
91
141
|
function useHasPlasmicRoot() {
|
|
@@ -104,5 +154,5 @@ function useEnsureSSRProvider() {
|
|
|
104
154
|
console.warn("Plasmic: To ensure your components work correctly with server-side rendering, please use PlasmicRootProvider at the root of your application. See https://docs.plasmic.app/learn/ssr");
|
|
105
155
|
}
|
|
106
156
|
|
|
107
|
-
export {
|
|
108
|
-
//# sourceMappingURL=ssr-
|
|
157
|
+
export { PlasmicHead as P, Trans as T, PlasmicRootProvider as a, useEnsureSSRProvider as b, genTranslatableString as g, plasmicHeadMeta as p, useIsSSR as u };
|
|
158
|
+
//# sourceMappingURL=ssr-14264281.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ssr-14264281.js","sources":["../../src/render/PlasmicHead.tsx","../../src/render/translation.tsx","../../src/render/ssr.tsx"],"sourcesContent":["import * as React from \"react\";\nimport type { ComponentMeta } from \"@plasmicapp/host/registerComponent\";\n\nexport const PlasmicHeadContext =\n React.createContext<React.ComponentType<any> | undefined>(undefined);\n\ntype PlasmicHeadProps = {\n title?: string;\n description?: string;\n image?: string;\n canonical?: string;\n};\n\nexport function PlasmicHead(props: PlasmicHeadProps) {\n const Head = React.useContext(PlasmicHeadContext);\n if (!Head) {\n console.warn(\n `Plasmic: Head meta tags are being ignored. To make them work, pass a Head component into PlasmicRootProvider.`\n );\n // TODO: Link to doc about Head.\n return null;\n }\n\n return (\n <Head>\n {props.image ? (\n <>\n <meta name=\"twitter:card\" content=\"summary_large_image\" />\n <meta key=\"og:image\" property=\"og:image\" content={props.image} />\n <meta\n key=\"twitter:image\"\n name=\"twitter:image\"\n content={props.image}\n />\n </>\n ) : (\n <meta name=\"twitter:card\" content=\"summary\" />\n )}\n {props.title && (\n <>\n <title key=\"title\">{props.title}</title>\n <meta key=\"og:title\" property=\"og:title\" content={props.title} />\n <meta\n key=\"twitter:title\"\n property=\"twitter:title\"\n content={props.title}\n />\n </>\n )}\n {props.description && (\n <>\n <meta\n key=\"description\"\n name=\"description\"\n content={props.description}\n />\n <meta\n key=\"og:description\"\n property=\"og:description\"\n content={props.description}\n />\n <meta\n key=\"twitter:description\"\n name=\"twitter:description\"\n content={props.description}\n />\n </>\n )}\n {props.canonical && <link ref=\"canonical\" href={props.canonical} />}\n </Head>\n );\n}\n\nexport const plasmicHeadMeta: ComponentMeta<PlasmicHeadProps> = {\n name: \"hostless-plasmic-head\",\n displayName: \"Head\",\n description: \"Used to add page metadata to HEAD tag\",\n importName: \"PlasmicHead\",\n importPath: \"@plasmicapp/react-web\",\n props: {\n title: {\n type: \"string\",\n displayName: \"Title\",\n },\n description: {\n type: \"string\",\n displayName: \"Description\",\n },\n image: {\n type: \"imageUrl\",\n displayName: \"Image\",\n },\n canonical: {\n type: \"string\",\n displayName: \"Canonical URL\",\n },\n },\n};\n","import React from \"react\";\n\nexport type PlasmicTranslator = (\n str: string,\n opts?: {\n components?: {\n [key: string]: React.ReactElement;\n };\n }\n) => React.ReactNode;\n\nexport const PlasmicTranslatorContext =\n React.createContext<PlasmicTranslator | undefined>(undefined);\n\nexport interface TransProps {\n children?: React.ReactNode;\n}\n\nfunction isIterable(val: any): val is Iterable<any> {\n return val != null && typeof val[Symbol.iterator] === \"function\";\n}\n\nexport function genTranslatableString(elt: React.ReactNode) {\n const components: {\n [key: string]: React.ReactElement;\n } = {};\n let componentsCount = 0;\n\n const getText = (node: React.ReactNode): string => {\n if (!node) {\n return \"\";\n }\n if (\n typeof node === \"number\" ||\n typeof node === \"boolean\" ||\n typeof node === \"string\"\n ) {\n return node.toString();\n }\n if (typeof node !== \"object\") {\n return \"\";\n }\n if (Array.isArray(node) || isIterable(node)) {\n return Array.from(node)\n .map((child) => getText(child))\n .filter((child) => !!child)\n .join(\"\");\n }\n const nodeChildren: React.ReactNode =\n (hasKey(node, \"props\") &&\n hasKey(node.props, \"children\") &&\n (node.props.children as React.ReactNode | undefined)) ||\n (hasKey(node, \"children\") && node.children) ||\n [];\n const contents = `${React.Children.toArray(nodeChildren)\n .map((child) => getText(child))\n .filter((child) => !!child)\n .join(\"\")}`;\n if (React.isValidElement(node) && node.type === React.Fragment) {\n return contents;\n }\n const componentId = componentsCount + 1;\n componentsCount++;\n components[componentId] = React.isValidElement(node)\n ? React.cloneElement(node as any, {\n key: componentId,\n children: undefined,\n })\n : (node as never);\n return `<${componentId}>${contents}</${componentId}>`;\n };\n\n const str = getText(elt);\n return {\n str,\n components,\n componentsCount,\n };\n}\n\nexport function Trans({ children }: TransProps) {\n const _t = React.useContext(PlasmicTranslatorContext);\n if (!_t) {\n warnNoTranslationFunctionAtMostOnce();\n return children;\n }\n\n const { str, components, componentsCount } = genTranslatableString(children);\n return _t(str, componentsCount > 0 ? { components } : undefined);\n}\n\nlet hasWarned = false;\nfunction warnNoTranslationFunctionAtMostOnce() {\n if (!hasWarned) {\n console.warn(\n \"Using Plasmic Translation but no translation function has been provided\"\n );\n hasWarned = true;\n }\n}\n\nfunction hasKey<K extends string>(v: any, key: K): v is Record<K, any> {\n return typeof v === \"object\" && v !== null && key in v;\n}\n","import * as React from \"react\";\nimport { SSRProvider, useIsSSR as useAriaIsSSR } from \"@react-aria/ssr\";\nimport { PlasmicTranslator, PlasmicTranslatorContext } from \"./translation\";\nimport { PlasmicHeadContext } from \"./PlasmicHead\";\n\nexport interface PlasmicRootContextValue {\n platform?: \"nextjs\" | \"gatsby\";\n}\n\nconst PlasmicRootContext =\n React.createContext<PlasmicRootContextValue | undefined>(undefined);\n\nexport interface PlasmicRootProviderProps {\n platform?: \"nextjs\" | \"gatsby\";\n children?: React.ReactNode;\n translator?: PlasmicTranslator;\n head?: React.ComponentType<any>;\n}\n\nexport function PlasmicRootProvider(props: PlasmicRootProviderProps) {\n const { platform, children } = props;\n const context = React.useMemo(\n () => ({\n platform,\n }),\n [platform]\n );\n return (\n <PlasmicRootContext.Provider value={context}>\n <SSRProvider>\n <PlasmicTranslatorContext.Provider value={props.translator}>\n <PlasmicHeadContext.Provider value={props.head}>\n {children}\n </PlasmicHeadContext.Provider>\n </PlasmicTranslatorContext.Provider>\n </SSRProvider>\n </PlasmicRootContext.Provider>\n );\n}\n\nexport const useIsSSR = useAriaIsSSR;\n\nexport function useHasPlasmicRoot() {\n return !!React.useContext(PlasmicRootContext);\n}\n\nlet hasWarnedSSR = false;\n/**\n * Warns the user if PlasmicRootProvider is not used\n */\nexport function useEnsureSSRProvider() {\n const hasRoot = useHasPlasmicRoot();\n if (hasRoot || hasWarnedSSR || process.env.NODE_ENV !== \"development\") {\n return;\n }\n\n hasWarnedSSR = true;\n console.warn(\n `Plasmic: To ensure your components work correctly with server-side rendering, please use PlasmicRootProvider at the root of your application. See https://docs.plasmic.app/learn/ssr`\n );\n}\n"],"names":["React","useAriaIsSSR"],"mappings":";;;;AAGO,IAAM,kBAAkB,GAC7B,KAAK,CAAC,aAAa,CAAuC,SAAS,CAAC,CAAC;SASvD,WAAW,CAAC,KAAuB;IACjD,IAAM,IAAI,GAAG,KAAK,CAAC,UAAU,CAAC,kBAAkB,CAAC,CAAC;IAClD,IAAI,CAAC,IAAI,EAAE;QACT,OAAO,CAAC,IAAI,CACV,+GAA+G,CAChH,CAAC;;QAEF,OAAO,IAAI,CAAC;KACb;IAED,QACE,oBAAC,IAAI;QACF,KAAK,CAAC,KAAK,IACV;YACE,8BAAM,IAAI,EAAC,cAAc,EAAC,OAAO,EAAC,qBAAqB,GAAG;YAC1D,8BAAM,GAAG,EAAC,UAAU,EAAC,QAAQ,EAAC,UAAU,EAAC,OAAO,EAAE,KAAK,CAAC,KAAK,GAAI;YACjE,8BACE,GAAG,EAAC,eAAe,EACnB,IAAI,EAAC,eAAe,EACpB,OAAO,EAAE,KAAK,CAAC,KAAK,GACpB,CACD,KAEH,8BAAM,IAAI,EAAC,cAAc,EAAC,OAAO,EAAC,SAAS,GAAG,CAC/C;QACA,KAAK,CAAC,KAAK,KACV;YACE,+BAAO,GAAG,EAAC,OAAO,IAAE,KAAK,CAAC,KAAK,CAAS;YACxC,8B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