@plasmicpkgs/react-aria 0.0.35 → 0.0.36
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/.tsbuildinfo +1 -1
- package/dist/contexts.d.ts +2 -1
- package/dist/react-aria.esm.js +53 -26
- package/dist/react-aria.esm.js.map +1 -1
- package/dist/react-aria.js +51 -24
- package/dist/react-aria.js.map +1 -1
- package/dist/registerPopover.d.ts +6 -1
- package/dist/utils.d.ts +1 -0
- package/package.json +2 -2
- package/skinny/contexts-9475faad.esm.js.map +1 -1
- package/skinny/contexts-b21f6b12.cjs.js.map +1 -1
- package/skinny/contexts.d.ts +2 -1
- package/skinny/registerButton.cjs.js +1 -1
- package/skinny/registerButton.esm.js +1 -1
- package/skinny/registerCheckbox.cjs.js +1 -1
- package/skinny/registerCheckbox.esm.js +1 -1
- package/skinny/registerCheckboxGroup.cjs.js +1 -1
- package/skinny/registerCheckboxGroup.esm.js +1 -1
- package/skinny/registerComboBox.cjs.js +4 -2
- package/skinny/registerComboBox.cjs.js.map +1 -1
- package/skinny/registerComboBox.esm.js +4 -2
- package/skinny/registerComboBox.esm.js.map +1 -1
- package/skinny/registerDescription.cjs.js +1 -1
- package/skinny/registerDescription.esm.js +1 -1
- package/skinny/registerDialogTrigger.cjs.js +1 -1
- package/skinny/registerDialogTrigger.esm.js +1 -1
- package/skinny/registerFieldError.cjs.js +1 -1
- package/skinny/registerFieldError.esm.js +1 -1
- package/skinny/registerForm.cjs.js +1 -1
- package/skinny/registerForm.esm.js +1 -1
- package/skinny/registerHeader.cjs.js +1 -1
- package/skinny/registerHeader.esm.js +1 -1
- package/skinny/registerInput.cjs.js +1 -1
- package/skinny/registerInput.esm.js +1 -1
- package/skinny/registerLabel.cjs.js +1 -1
- package/skinny/registerLabel.esm.js +1 -1
- package/skinny/{registerListBox-1effa43d.esm.js → registerListBox-cbc7beea.esm.js} +2 -2
- package/skinny/{registerListBox-1effa43d.esm.js.map → registerListBox-cbc7beea.esm.js.map} +1 -1
- package/skinny/{registerListBox-837b90d8.cjs.js → registerListBox-e98e849f.cjs.js} +2 -2
- package/skinny/{registerListBox-837b90d8.cjs.js.map → registerListBox-e98e849f.cjs.js.map} +1 -1
- package/skinny/registerListBox.cjs.js +3 -2
- package/skinny/registerListBox.cjs.js.map +1 -1
- package/skinny/registerListBox.esm.js +3 -2
- package/skinny/registerListBox.esm.js.map +1 -1
- package/skinny/registerListBoxItem.cjs.js +4 -2
- package/skinny/registerListBoxItem.cjs.js.map +1 -1
- package/skinny/registerListBoxItem.esm.js +5 -3
- package/skinny/registerListBoxItem.esm.js.map +1 -1
- package/skinny/registerModal.cjs.js +1 -1
- package/skinny/registerModal.esm.js +1 -1
- package/skinny/registerPopover.cjs.js +30 -6
- package/skinny/registerPopover.cjs.js.map +1 -1
- package/skinny/registerPopover.d.ts +6 -1
- package/skinny/registerPopover.esm.js +31 -7
- package/skinny/registerPopover.esm.js.map +1 -1
- package/skinny/registerRadio.cjs.js +1 -1
- package/skinny/registerRadio.esm.js +1 -1
- package/skinny/registerRadioGroup.cjs.js +1 -1
- package/skinny/registerRadioGroup.esm.js +1 -1
- package/skinny/registerSection.cjs.js +1 -1
- package/skinny/registerSection.esm.js +1 -1
- package/skinny/registerSelect.cjs.js +5 -4
- package/skinny/registerSelect.cjs.js.map +1 -1
- package/skinny/registerSelect.esm.js +5 -4
- package/skinny/registerSelect.esm.js.map +1 -1
- package/skinny/{registerSlider-abe2fcd9.cjs.js → registerSlider-22197722.cjs.js} +2 -2
- package/skinny/{registerSlider-abe2fcd9.cjs.js.map → registerSlider-22197722.cjs.js.map} +1 -1
- package/skinny/{registerSlider-b37e26ac.esm.js → registerSlider-3045cc63.esm.js} +2 -2
- package/skinny/{registerSlider-b37e26ac.esm.js.map → registerSlider-3045cc63.esm.js.map} +1 -1
- package/skinny/registerSlider.cjs.js +2 -2
- package/skinny/registerSlider.esm.js +2 -2
- package/skinny/registerSliderOutput.cjs.js +1 -1
- package/skinny/registerSliderOutput.esm.js +1 -1
- package/skinny/registerSliderThumb.cjs.js +1 -1
- package/skinny/registerSliderThumb.esm.js +1 -1
- package/skinny/registerSliderTrack.cjs.js +2 -2
- package/skinny/registerSliderTrack.esm.js +2 -2
- package/skinny/registerSwitch.cjs.js +1 -1
- package/skinny/registerSwitch.esm.js +1 -1
- package/skinny/registerText.cjs.js +1 -1
- package/skinny/registerText.esm.js +1 -1
- package/skinny/registerTextArea.cjs.js +1 -1
- package/skinny/registerTextArea.esm.js +1 -1
- package/skinny/registerTextField.cjs.js +1 -1
- package/skinny/registerTextField.esm.js +1 -1
- package/skinny/registerTooltip.cjs.js +1 -1
- package/skinny/registerTooltip.esm.js +1 -1
- package/skinny/{utils-5051df41.esm.js → utils-a1785802.esm.js} +5 -2
- package/skinny/{utils-5051df41.esm.js.map → utils-a1785802.esm.js.map} +1 -1
- package/skinny/{utils-745db876.cjs.js → utils-d3708034.cjs.js} +5 -1
- package/skinny/{utils-745db876.cjs.js.map → utils-d3708034.cjs.js.map} +1 -1
- package/skinny/utils.d.ts +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registerListBox-1effa43d.esm.js","sources":["../src/option-utils.ts","../src/registerListBox.tsx"],"sourcesContent":["import type { ArrayType, ChoiceType } from \"@plasmicapp/host/registerComponent\";\nimport React from \"react\";\n\nexport interface ObjectSectionType<T extends object> {\n label?: string;\n items?: ObjectItemType<T>[];\n}\ninterface FlexSectionType<T extends object> {\n label?: string;\n items?: FlexItemType<T>[];\n}\n\nexport type ObjectItemType<T extends object> = StrictOptionType | T;\ntype FlexItemType<T extends object> = ObjectItemType<T> | string;\n\nexport type FlexOptionType<T extends object> =\n | FlexItemType<T>\n | FlexSectionType<T>;\n\nexport type ObjectOptionType<T extends object> =\n | ObjectSectionType<T>\n | ObjectItemType<T>;\n\nexport interface HasOptions<T extends object> {\n options?: FlexOptionType<T>[];\n optionInfo?: (option: FlexOptionType<T>) => StrictOptionType;\n}\n\nexport interface StrictItemType {\n type?: \"option\";\n id: string;\n label?: string;\n isDisabled?: boolean;\n}\n\nexport interface StrictSectionType {\n type: \"option-group\";\n label?: string;\n items?: StrictItemType[];\n key: string;\n}\n\nexport type StrictOptionType = StrictItemType | StrictSectionType;\n\nexport function useStrictOptions<T extends object>(props: HasOptions<T>) {\n const { options, optionInfo } = props;\n return React.useMemo(() => {\n return deriveStrictOptions({ options, optionInfo });\n }, [options, optionInfo]);\n}\n\nexport function deriveStrictOptions<T extends object>(props: HasOptions<T>) {\n const { options, optionInfo } = props;\n let sectionCount = 0;\n\n const makeStrict = (op: FlexOptionType<T>): StrictOptionType | undefined => {\n if (!op) {\n return undefined;\n } else if (typeof op === \"string\" || typeof op === \"number\") {\n const item = {\n id: op,\n };\n return item;\n } else if (optionInfo) {\n const info = optionInfo(op);\n if (info.type === \"option-group\") {\n const section: StrictSectionType = {\n type: \"option-group\",\n items: info.items\n ?.map?.((item) => makeStrict(item) as StrictItemType)\n ?.filter((x) => !!x),\n label: info.label,\n key: `option-group-${sectionCount}`,\n };\n sectionCount += 1;\n return section;\n } else {\n let item = info;\n if (!(\"id\" in item)) {\n item = {\n type: \"option\",\n id: JSON.stringify(item),\n };\n }\n return item;\n }\n } else if (typeof op === \"object\") {\n if (\"items\" in op) {\n const section: StrictSectionType = {\n type: \"option-group\",\n items: op.items\n ?.map?.((item) => makeStrict(item) as StrictItemType)\n ?.filter((x) => !!x),\n label: op.label,\n key: `option-group-${sectionCount}`,\n };\n sectionCount += 1;\n return section;\n } else {\n let item = op;\n if (!(\"id\" in item)) {\n item = {\n type: \"option\",\n id: JSON.stringify(item),\n };\n }\n return item;\n }\n } else {\n return undefined;\n }\n };\n\n const strictOptions = options\n ?.map(makeStrict)\n ?.filter((x): x is StrictOptionType => !!x);\n\n const optionText = (op: StrictItemType) => {\n return op.label ?? op.id;\n };\n\n return { options: strictOptions, optionText };\n}\n\nexport function flattenOptions(\n options: (StrictItemType | StrictSectionType)[] | undefined\n): StrictItemType[] {\n if (!options) {\n return [];\n } else {\n return options.flatMap((op) =>\n op.type === \"option-group\" ? op.items ?? [] : op\n );\n }\n}\n\nexport function makeOptionsPropType() {\n const type: ArrayType<HasOptions<any>> = {\n type: \"array\",\n itemType: {\n type: \"object\",\n nameFunc: (item: any) => item.label || item.id,\n fields: {\n type: {\n type: \"choice\",\n options: [\n { value: \"option\", label: \"Option\" },\n { value: \"option-group\", label: \"Option Group\" },\n ],\n defaultValue: \"option\",\n },\n id: {\n type: \"string\",\n hidden: (_ps: any, _ctx: any, { item }: any) =>\n item.type !== \"option\",\n },\n label: \"string\",\n items: {\n type: \"array\",\n displayName: \"Options\",\n hidden: (_ps: any, _ctx: any, { item }: any) => {\n return item.type !== \"option-group\";\n },\n itemType: {\n type: \"object\",\n nameFunc: (item: any) => item.label || item.id,\n fields: {\n id: \"string\",\n label: \"string\",\n },\n },\n },\n },\n },\n defaultValue: [\n {\n id: \"option1\",\n label: \"Option 1\",\n type: \"option\",\n },\n {\n id: \"option2\",\n label: \"Option 2\",\n type: \"option\",\n },\n {\n label: \"Section 1\",\n type: \"option-group\",\n items: [\n {\n id: \"section-1-1\",\n label: \"Section item 1\",\n type: \"option\",\n },\n {\n id: \"section-1-2\",\n label: \"Section item 2\",\n type: \"option\",\n },\n ],\n },\n ],\n };\n return type;\n}\n\nexport function makeValuePropType() {\n const type: ChoiceType<HasOptions<any>> = {\n type: \"choice\",\n options: (ps: HasOptions<any>) => {\n const { options, optionText } = deriveStrictOptions(ps);\n return flattenOptions(options).map((op) => ({\n value: op.id,\n label: optionText(op),\n }));\n },\n };\n return type;\n}\n","import { mergeProps } from \"@react-aria/utils\";\nimport React from \"react\";\nimport { ListBox } from \"react-aria-components\";\nimport {\n PlasmicItemContext,\n PlasmicListBoxContext,\n PlasmicSectionContext,\n} from \"./contexts\";\nimport {\n HasOptions,\n makeOptionsPropType,\n StrictOptionType,\n useStrictOptions,\n} from \"./option-utils\";\nimport {\n makeDefaultListBoxItemChildren,\n registerListBoxItem,\n} from \"./registerListBoxItem\";\nimport { registerSection } from \"./registerSection\";\nimport {\n BaseControlContextData,\n CodeComponentMetaOverrides,\n makeComponentName,\n Registerable,\n registerComponentHelper,\n} from \"./utils\";\n\nexport interface BaseListBoxProps\n extends React.ComponentProps<typeof ListBox>,\n HasOptions<any> {\n renderItem?: (item: any) => React.ReactNode;\n renderSection?: (section: any) => React.ReactNode;\n getItemType?: (thing: any) => \"item\" | \"section\";\n setControlContextData?: (ctxData: BaseControlContextData) => void;\n}\n\nexport function BaseListBox(props: BaseListBoxProps) {\n const contextProps = React.useContext(PlasmicListBoxContext);\n const isStandalone: boolean = !contextProps;\n const { options: _rawOptions, ...rest } = props;\n const { options } = useStrictOptions(props);\n const { renderItem, renderSection, ...mergedProps } = mergeProps(\n contextProps,\n rest,\n isStandalone ? { items: options } : {}\n );\n\n // Tell the prop control about whether the listbox is standalone or not, so it can hide/show the items prop\n props.setControlContextData?.({\n isStandalone,\n });\n\n return (\n <ListBox {...mergedProps}>\n {(item: StrictOptionType) => {\n if (item.type === \"option-group\") {\n return (\n <>\n <PlasmicSectionContext.Provider\n value={{\n renderItem,\n key: item.key ?? item.label,\n section: item,\n }}\n >\n {renderSection?.(item)}\n </PlasmicSectionContext.Provider>\n </>\n );\n } else {\n return (\n <PlasmicItemContext.Provider value={item}>\n {renderItem?.(item)}\n </PlasmicItemContext.Provider>\n );\n }\n }}\n </ListBox>\n );\n}\n\nexport const LIST_BOX_COMPONENT_NAME = makeComponentName(\"listbox\");\n\nexport function registerListBox(\n loader?: Registerable,\n overrides?: CodeComponentMetaOverrides<typeof BaseListBox>\n) {\n const listBoxItemMeta = registerListBoxItem(loader, {\n parentComponentName: LIST_BOX_COMPONENT_NAME,\n });\n const sectionMeta = registerSection(loader, {\n parentComponentName: LIST_BOX_COMPONENT_NAME,\n });\n\n registerComponentHelper(\n loader,\n BaseListBox,\n {\n name: LIST_BOX_COMPONENT_NAME,\n displayName: \"Aria ListBox\",\n importPath: \"@plasmicpkgs/react-aria/skinny/registerListBox\",\n importName: \"BaseListBox\",\n defaultStyles: {\n width: \"250px\",\n borderWidth: \"1px\",\n borderStyle: \"solid\",\n borderColor: \"black\",\n },\n props: {\n options: {\n ...makeOptionsPropType(),\n displayName: \"Items\",\n hidden: (_ps: BaseListBoxProps, ctx: BaseControlContextData | null) =>\n !ctx?.isStandalone,\n },\n renderItem: {\n type: \"slot\",\n displayName: \"Render Item\",\n renderPropParams: [\"itemProps\"],\n defaultValue: {\n type: \"component\",\n name: listBoxItemMeta.name,\n props: {\n children: makeDefaultListBoxItemChildren(\n \"Item (itemProps.label)\",\n \"Connect with `itemProps` in the data picker to display list box items\"\n ),\n },\n },\n },\n renderSection: {\n type: \"slot\",\n displayName: \"Render Section\",\n renderPropParams: [\"sectionProps\"],\n defaultValue: {\n type: \"component\",\n name: sectionMeta.name,\n styles: {\n backgroundColor: \"#F4FAFF\",\n },\n },\n },\n },\n },\n overrides\n );\n}\n"],"names":["_a"],"mappings":";;;;;;;;AA4CO,SAAS,iBAAmC,KAAsB,EAAA;AACvE,EAAM,MAAA,EAAE,OAAS,EAAA,UAAA,EAAe,GAAA,KAAA,CAAA;AAChC,EAAO,OAAA,KAAA,CAAM,QAAQ,MAAM;AACzB,IAAA,OAAO,mBAAoB,CAAA,EAAE,OAAS,EAAA,UAAA,EAAY,CAAA,CAAA;AAAA,GACjD,EAAA,CAAC,OAAS,EAAA,UAAU,CAAC,CAAA,CAAA;AAC1B,CAAA;AAEO,SAAS,oBAAsC,KAAsB,EAAA;AAnD5E,EAAA,IAAA,EAAA,CAAA;AAoDE,EAAM,MAAA,EAAE,OAAS,EAAA,UAAA,EAAe,GAAA,KAAA,CAAA;AAChC,EAAA,IAAI,YAAe,GAAA,CAAA,CAAA;AAEnB,EAAM,MAAA,UAAA,GAAa,CAAC,EAAwD,KAAA;AAvD9E,IAAA,IAAAA,GAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,CAA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erListBox-cbc7beea.esm.js","sources":["../src/option-utils.ts","../src/registerListBox.tsx"],"sourcesContent":["import type { ArrayType, ChoiceType } from \"@plasmicapp/host/registerComponent\";\nimport React from \"react\";\n\nexport interface ObjectSectionType<T extends object> {\n label?: string;\n items?: ObjectItemType<T>[];\n}\ninterface FlexSectionType<T extends object> {\n label?: string;\n items?: FlexItemType<T>[];\n}\n\nexport type ObjectItemType<T extends object> = StrictOptionType | T;\ntype FlexItemType<T extends object> = ObjectItemType<T> | string;\n\nexport type FlexOptionType<T extends object> =\n | FlexItemType<T>\n | FlexSectionType<T>;\n\nexport type ObjectOptionType<T extends object> =\n | ObjectSectionType<T>\n | ObjectItemType<T>;\n\nexport interface HasOptions<T extends object> {\n options?: FlexOptionType<T>[];\n optionInfo?: (option: FlexOptionType<T>) => StrictOptionType;\n}\n\nexport interface StrictItemType {\n type?: \"option\";\n id: string;\n label?: string;\n isDisabled?: boolean;\n}\n\nexport interface StrictSectionType {\n type: \"option-group\";\n label?: string;\n items?: StrictItemType[];\n key: string;\n}\n\nexport type StrictOptionType = StrictItemType | StrictSectionType;\n\nexport function useStrictOptions<T extends object>(props: HasOptions<T>) {\n const { options, optionInfo } = props;\n return React.useMemo(() => {\n return deriveStrictOptions({ options, optionInfo });\n }, [options, optionInfo]);\n}\n\nexport function deriveStrictOptions<T extends object>(props: HasOptions<T>) {\n const { options, optionInfo } = props;\n let sectionCount = 0;\n\n const makeStrict = (op: FlexOptionType<T>): StrictOptionType | undefined => {\n if (!op) {\n return undefined;\n } else if (typeof op === \"string\" || typeof op === \"number\") {\n const item = {\n id: op,\n };\n return item;\n } else if (optionInfo) {\n const info = optionInfo(op);\n if (info.type === \"option-group\") {\n const section: StrictSectionType = {\n type: \"option-group\",\n items: info.items\n ?.map?.((item) => makeStrict(item) as StrictItemType)\n ?.filter((x) => !!x),\n label: info.label,\n key: `option-group-${sectionCount}`,\n };\n sectionCount += 1;\n return section;\n } else {\n let item = info;\n if (!(\"id\" in item)) {\n item = {\n type: \"option\",\n id: JSON.stringify(item),\n };\n }\n return item;\n }\n } else if (typeof op === \"object\") {\n if (\"items\" in op) {\n const section: StrictSectionType = {\n type: \"option-group\",\n items: op.items\n ?.map?.((item) => makeStrict(item) as StrictItemType)\n ?.filter((x) => !!x),\n label: op.label,\n key: `option-group-${sectionCount}`,\n };\n sectionCount += 1;\n return section;\n } else {\n let item = op;\n if (!(\"id\" in item)) {\n item = {\n type: \"option\",\n id: JSON.stringify(item),\n };\n }\n return item;\n }\n } else {\n return undefined;\n }\n };\n\n const strictOptions = options\n ?.map(makeStrict)\n ?.filter((x): x is StrictOptionType => !!x);\n\n const optionText = (op: StrictItemType) => {\n return op.label ?? op.id;\n };\n\n return { options: strictOptions, optionText };\n}\n\nexport function flattenOptions(\n options: (StrictItemType | StrictSectionType)[] | undefined\n): StrictItemType[] {\n if (!options) {\n return [];\n } else {\n return options.flatMap((op) =>\n op.type === \"option-group\" ? op.items ?? [] : op\n );\n }\n}\n\nexport function makeOptionsPropType() {\n const type: ArrayType<HasOptions<any>> = {\n type: \"array\",\n itemType: {\n type: \"object\",\n nameFunc: (item: any) => item.label || item.id,\n fields: {\n type: {\n type: \"choice\",\n options: [\n { value: \"option\", label: \"Option\" },\n { value: \"option-group\", label: \"Option Group\" },\n ],\n defaultValue: \"option\",\n },\n id: {\n type: \"string\",\n hidden: (_ps: any, _ctx: any, { item }: any) =>\n item.type !== \"option\",\n },\n label: \"string\",\n items: {\n type: \"array\",\n displayName: \"Options\",\n hidden: (_ps: any, _ctx: any, { item }: any) => {\n return item.type !== \"option-group\";\n },\n itemType: {\n type: \"object\",\n nameFunc: (item: any) => item.label || item.id,\n fields: {\n id: \"string\",\n label: \"string\",\n },\n },\n },\n },\n },\n defaultValue: [\n {\n id: \"option1\",\n label: \"Option 1\",\n type: \"option\",\n },\n {\n id: \"option2\",\n label: \"Option 2\",\n type: \"option\",\n },\n {\n label: \"Section 1\",\n type: \"option-group\",\n items: [\n {\n id: \"section-1-1\",\n label: \"Section item 1\",\n type: \"option\",\n },\n {\n id: \"section-1-2\",\n label: \"Section item 2\",\n type: \"option\",\n },\n ],\n },\n ],\n };\n return type;\n}\n\nexport function makeValuePropType() {\n const type: ChoiceType<HasOptions<any>> = {\n type: \"choice\",\n options: (ps: HasOptions<any>) => {\n const { options, optionText } = deriveStrictOptions(ps);\n return flattenOptions(options).map((op) => ({\n value: op.id,\n label: optionText(op),\n }));\n },\n };\n return type;\n}\n","import { mergeProps } from \"@react-aria/utils\";\nimport React from \"react\";\nimport { ListBox } from \"react-aria-components\";\nimport {\n PlasmicItemContext,\n PlasmicListBoxContext,\n PlasmicSectionContext,\n} from \"./contexts\";\nimport {\n HasOptions,\n makeOptionsPropType,\n StrictOptionType,\n useStrictOptions,\n} from \"./option-utils\";\nimport {\n makeDefaultListBoxItemChildren,\n registerListBoxItem,\n} from \"./registerListBoxItem\";\nimport { registerSection } from \"./registerSection\";\nimport {\n BaseControlContextData,\n CodeComponentMetaOverrides,\n makeComponentName,\n Registerable,\n registerComponentHelper,\n} from \"./utils\";\n\nexport interface BaseListBoxProps\n extends React.ComponentProps<typeof ListBox>,\n HasOptions<any> {\n renderItem?: (item: any) => React.ReactNode;\n renderSection?: (section: any) => React.ReactNode;\n getItemType?: (thing: any) => \"item\" | \"section\";\n setControlContextData?: (ctxData: BaseControlContextData) => void;\n}\n\nexport function BaseListBox(props: BaseListBoxProps) {\n const contextProps = React.useContext(PlasmicListBoxContext);\n const isStandalone: boolean = !contextProps;\n const { options: _rawOptions, ...rest } = props;\n const { options } = useStrictOptions(props);\n const { renderItem, renderSection, ...mergedProps } = mergeProps(\n contextProps,\n rest,\n isStandalone ? { items: options } : {}\n );\n\n // Tell the prop control about whether the listbox is standalone or not, so it can hide/show the items prop\n props.setControlContextData?.({\n isStandalone,\n });\n\n return (\n <ListBox {...mergedProps}>\n {(item: StrictOptionType) => {\n if (item.type === \"option-group\") {\n return (\n <>\n <PlasmicSectionContext.Provider\n value={{\n renderItem,\n key: item.key ?? item.label,\n section: item,\n }}\n >\n {renderSection?.(item)}\n </PlasmicSectionContext.Provider>\n </>\n );\n } else {\n return (\n <PlasmicItemContext.Provider value={item}>\n {renderItem?.(item)}\n </PlasmicItemContext.Provider>\n );\n }\n }}\n </ListBox>\n );\n}\n\nexport const LIST_BOX_COMPONENT_NAME = makeComponentName(\"listbox\");\n\nexport function registerListBox(\n loader?: Registerable,\n overrides?: CodeComponentMetaOverrides<typeof BaseListBox>\n) {\n const listBoxItemMeta = registerListBoxItem(loader, {\n parentComponentName: LIST_BOX_COMPONENT_NAME,\n });\n const sectionMeta = registerSection(loader, {\n parentComponentName: LIST_BOX_COMPONENT_NAME,\n });\n\n registerComponentHelper(\n loader,\n BaseListBox,\n {\n name: LIST_BOX_COMPONENT_NAME,\n displayName: \"Aria ListBox\",\n importPath: \"@plasmicpkgs/react-aria/skinny/registerListBox\",\n importName: \"BaseListBox\",\n defaultStyles: {\n width: \"250px\",\n borderWidth: \"1px\",\n borderStyle: \"solid\",\n borderColor: \"black\",\n },\n props: {\n options: {\n ...makeOptionsPropType(),\n displayName: \"Items\",\n hidden: (_ps: BaseListBoxProps, ctx: BaseControlContextData | null) =>\n !ctx?.isStandalone,\n },\n renderItem: {\n type: \"slot\",\n displayName: \"Render Item\",\n renderPropParams: [\"itemProps\"],\n defaultValue: {\n type: \"component\",\n name: listBoxItemMeta.name,\n props: {\n children: makeDefaultListBoxItemChildren(\n \"Item (itemProps.label)\",\n \"Connect with `itemProps` in the data picker to display list box items\"\n ),\n },\n },\n },\n renderSection: {\n type: \"slot\",\n displayName: \"Render Section\",\n renderPropParams: [\"sectionProps\"],\n defaultValue: {\n type: \"component\",\n name: sectionMeta.name,\n styles: {\n backgroundColor: \"#F4FAFF\",\n },\n },\n },\n },\n },\n overrides\n );\n}\n"],"names":["_a"],"mappings":";;;;;;;;AA4CO,SAAS,iBAAmC,KAAsB,EAAA;AACvE,EAAM,MAAA,EAAE,OAAS,EAAA,UAAA,EAAe,GAAA,KAA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AO,EAAA;AAAA,cACL,QAAU,EAAA,8BAAA;AAAA,gBACR,wBAAA;AAAA,gBACA,uEAAA;AAAA,eACF;AAAA,aACF;AAAA,WACF;AAAA,SACF;AAAA,QACA,aAAe,EAAA;AAAA,UACb,IAAM,EAAA,MAAA;AAAA,UACN,WAAa,EAAA,gBAAA;AAAA,UACb,gBAAA,EAAkB,CAAC,cAAc,CAAA;AAAA,UACjC,YAAc,EAAA;AAAA,YACZ,IAAM,EAAA,WAAA;AAAA,YACN,MAAM,WAAY,CAAA,IAAA;AAAA,YAClB,MAAQ,EAAA;AAAA,cACN,eAAiB,EAAA,SAAA;AAAA,aACnB;AAAA,WACF;AAAA,SACF;AAAA,OACF;AAAA,KACF;AAAA,IACA,SAAA;AAAA,GACF,CAAA;AACF;;;;"}
|
|
@@ -6,7 +6,7 @@ var reactAriaComponents = require('react-aria-components');
|
|
|
6
6
|
var contexts = require('./contexts-b21f6b12.cjs.js');
|
|
7
7
|
var registerListBoxItem = require('./registerListBoxItem.cjs.js');
|
|
8
8
|
var registerSection = require('./registerSection.cjs.js');
|
|
9
|
-
var utils$1 = require('./utils-
|
|
9
|
+
var utils$1 = require('./utils-d3708034.cjs.js');
|
|
10
10
|
|
|
11
11
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
12
|
|
|
@@ -308,4 +308,4 @@ exports.makeOptionsPropType = makeOptionsPropType;
|
|
|
308
308
|
exports.makeValuePropType = makeValuePropType;
|
|
309
309
|
exports.registerListBox = registerListBox;
|
|
310
310
|
exports.useStrictOptions = useStrictOptions;
|
|
311
|
-
//# sourceMappingURL=registerListBox-
|
|
311
|
+
//# sourceMappingURL=registerListBox-e98e849f.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registerListBox-837b90d8.cjs.js","sources":["../src/option-utils.ts","../src/registerListBox.tsx"],"sourcesContent":["import type { ArrayType, ChoiceType } from \"@plasmicapp/host/registerComponent\";\nimport React from \"react\";\n\nexport interface ObjectSectionType<T extends object> {\n label?: string;\n items?: ObjectItemType<T>[];\n}\ninterface FlexSectionType<T extends object> {\n label?: string;\n items?: FlexItemType<T>[];\n}\n\nexport type ObjectItemType<T extends object> = StrictOptionType | T;\ntype FlexItemType<T extends object> = ObjectItemType<T> | string;\n\nexport type FlexOptionType<T extends object> =\n | FlexItemType<T>\n | FlexSectionType<T>;\n\nexport type ObjectOptionType<T extends object> =\n | ObjectSectionType<T>\n | ObjectItemType<T>;\n\nexport interface HasOptions<T extends object> {\n options?: FlexOptionType<T>[];\n optionInfo?: (option: FlexOptionType<T>) => StrictOptionType;\n}\n\nexport interface StrictItemType {\n type?: \"option\";\n id: string;\n label?: string;\n isDisabled?: boolean;\n}\n\nexport interface StrictSectionType {\n type: \"option-group\";\n label?: string;\n items?: StrictItemType[];\n key: string;\n}\n\nexport type StrictOptionType = StrictItemType | StrictSectionType;\n\nexport function useStrictOptions<T extends object>(props: HasOptions<T>) {\n const { options, optionInfo } = props;\n return React.useMemo(() => {\n return deriveStrictOptions({ options, optionInfo });\n }, [options, optionInfo]);\n}\n\nexport function deriveStrictOptions<T extends object>(props: HasOptions<T>) {\n const { options, optionInfo } = props;\n let sectionCount = 0;\n\n const makeStrict = (op: FlexOptionType<T>): StrictOptionType | undefined => {\n if (!op) {\n return undefined;\n } else if (typeof op === \"string\" || typeof op === \"number\") {\n const item = {\n id: op,\n };\n return item;\n } else if (optionInfo) {\n const info = optionInfo(op);\n if (info.type === \"option-group\") {\n const section: StrictSectionType = {\n type: \"option-group\",\n items: info.items\n ?.map?.((item) => makeStrict(item) as StrictItemType)\n ?.filter((x) => !!x),\n label: info.label,\n key: `option-group-${sectionCount}`,\n };\n sectionCount += 1;\n return section;\n } else {\n let item = info;\n if (!(\"id\" in item)) {\n item = {\n type: \"option\",\n id: JSON.stringify(item),\n };\n }\n return item;\n }\n } else if (typeof op === \"object\") {\n if (\"items\" in op) {\n const section: StrictSectionType = {\n type: \"option-group\",\n items: op.items\n ?.map?.((item) => makeStrict(item) as StrictItemType)\n ?.filter((x) => !!x),\n label: op.label,\n key: `option-group-${sectionCount}`,\n };\n sectionCount += 1;\n return section;\n } else {\n let item = op;\n if (!(\"id\" in item)) {\n item = {\n type: \"option\",\n id: JSON.stringify(item),\n };\n }\n return item;\n }\n } else {\n return undefined;\n }\n };\n\n const strictOptions = options\n ?.map(makeStrict)\n ?.filter((x): x is StrictOptionType => !!x);\n\n const optionText = (op: StrictItemType) => {\n return op.label ?? op.id;\n };\n\n return { options: strictOptions, optionText };\n}\n\nexport function flattenOptions(\n options: (StrictItemType | StrictSectionType)[] | undefined\n): StrictItemType[] {\n if (!options) {\n return [];\n } else {\n return options.flatMap((op) =>\n op.type === \"option-group\" ? op.items ?? [] : op\n );\n }\n}\n\nexport function makeOptionsPropType() {\n const type: ArrayType<HasOptions<any>> = {\n type: \"array\",\n itemType: {\n type: \"object\",\n nameFunc: (item: any) => item.label || item.id,\n fields: {\n type: {\n type: \"choice\",\n options: [\n { value: \"option\", label: \"Option\" },\n { value: \"option-group\", label: \"Option Group\" },\n ],\n defaultValue: \"option\",\n },\n id: {\n type: \"string\",\n hidden: (_ps: any, _ctx: any, { item }: any) =>\n item.type !== \"option\",\n },\n label: \"string\",\n items: {\n type: \"array\",\n displayName: \"Options\",\n hidden: (_ps: any, _ctx: any, { item }: any) => {\n return item.type !== \"option-group\";\n },\n itemType: {\n type: \"object\",\n nameFunc: (item: any) => item.label || item.id,\n fields: {\n id: \"string\",\n label: \"string\",\n },\n },\n },\n },\n },\n defaultValue: [\n {\n id: \"option1\",\n label: \"Option 1\",\n type: \"option\",\n },\n {\n id: \"option2\",\n label: \"Option 2\",\n type: \"option\",\n },\n {\n label: \"Section 1\",\n type: \"option-group\",\n items: [\n {\n id: \"section-1-1\",\n label: \"Section item 1\",\n type: \"option\",\n },\n {\n id: \"section-1-2\",\n label: \"Section item 2\",\n type: \"option\",\n },\n ],\n },\n ],\n };\n return type;\n}\n\nexport function makeValuePropType() {\n const type: ChoiceType<HasOptions<any>> = {\n type: \"choice\",\n options: (ps: HasOptions<any>) => {\n const { options, optionText } = deriveStrictOptions(ps);\n return flattenOptions(options).map((op) => ({\n value: op.id,\n label: optionText(op),\n }));\n },\n };\n return type;\n}\n","import { mergeProps } from \"@react-aria/utils\";\nimport React from \"react\";\nimport { ListBox } from \"react-aria-components\";\nimport {\n PlasmicItemContext,\n PlasmicListBoxContext,\n PlasmicSectionContext,\n} from \"./contexts\";\nimport {\n HasOptions,\n makeOptionsPropType,\n StrictOptionType,\n useStrictOptions,\n} from \"./option-utils\";\nimport {\n makeDefaultListBoxItemChildren,\n registerListBoxItem,\n} from \"./registerListBoxItem\";\nimport { registerSection } from \"./registerSection\";\nimport {\n BaseControlContextData,\n CodeComponentMetaOverrides,\n makeComponentName,\n Registerable,\n registerComponentHelper,\n} from \"./utils\";\n\nexport interface BaseListBoxProps\n extends React.ComponentProps<typeof ListBox>,\n HasOptions<any> {\n renderItem?: (item: any) => React.ReactNode;\n renderSection?: (section: any) => React.ReactNode;\n getItemType?: (thing: any) => \"item\" | \"section\";\n setControlContextData?: (ctxData: BaseControlContextData) => void;\n}\n\nexport function BaseListBox(props: BaseListBoxProps) {\n const contextProps = React.useContext(PlasmicListBoxContext);\n const isStandalone: boolean = !contextProps;\n const { options: _rawOptions, ...rest } = props;\n const { options } = useStrictOptions(props);\n const { renderItem, renderSection, ...mergedProps } = mergeProps(\n contextProps,\n rest,\n isStandalone ? { items: options } : {}\n );\n\n // Tell the prop control about whether the listbox is standalone or not, so it can hide/show the items prop\n props.setControlContextData?.({\n isStandalone,\n });\n\n return (\n <ListBox {...mergedProps}>\n {(item: StrictOptionType) => {\n if (item.type === \"option-group\") {\n return (\n <>\n <PlasmicSectionContext.Provider\n value={{\n renderItem,\n key: item.key ?? item.label,\n section: item,\n }}\n >\n {renderSection?.(item)}\n </PlasmicSectionContext.Provider>\n </>\n );\n } else {\n return (\n <PlasmicItemContext.Provider value={item}>\n {renderItem?.(item)}\n </PlasmicItemContext.Provider>\n );\n }\n }}\n </ListBox>\n );\n}\n\nexport const LIST_BOX_COMPONENT_NAME = makeComponentName(\"listbox\");\n\nexport function registerListBox(\n loader?: Registerable,\n overrides?: CodeComponentMetaOverrides<typeof BaseListBox>\n) {\n const listBoxItemMeta = registerListBoxItem(loader, {\n parentComponentName: LIST_BOX_COMPONENT_NAME,\n });\n const sectionMeta = registerSection(loader, {\n parentComponentName: LIST_BOX_COMPONENT_NAME,\n });\n\n registerComponentHelper(\n loader,\n BaseListBox,\n {\n name: LIST_BOX_COMPONENT_NAME,\n displayName: \"Aria ListBox\",\n importPath: \"@plasmicpkgs/react-aria/skinny/registerListBox\",\n importName: \"BaseListBox\",\n defaultStyles: {\n width: \"250px\",\n borderWidth: \"1px\",\n borderStyle: \"solid\",\n borderColor: \"black\",\n },\n props: {\n options: {\n ...makeOptionsPropType(),\n displayName: \"Items\",\n hidden: (_ps: BaseListBoxProps, ctx: BaseControlContextData | null) =>\n !ctx?.isStandalone,\n },\n renderItem: {\n type: \"slot\",\n displayName: \"Render Item\",\n renderPropParams: [\"itemProps\"],\n defaultValue: {\n type: \"component\",\n name: listBoxItemMeta.name,\n props: {\n children: makeDefaultListBoxItemChildren(\n \"Item (itemProps.label)\",\n \"Connect with `itemProps` in the data picker to display list box items\"\n ),\n },\n },\n },\n renderSection: {\n type: \"slot\",\n displayName: \"Render Section\",\n renderPropParams: [\"sectionProps\"],\n defaultValue: {\n type: \"component\",\n name: sectionMeta.name,\n styles: {\n backgroundColor: \"#F4FAFF\",\n },\n },\n },\n },\n },\n overrides\n );\n}\n"],"names":["React","_a","PlasmicListBoxContext","mergeProps","ListBox","PlasmicSectionContext","PlasmicItemContext","makeComponentName","registerListBoxItem","registerSection","registerComponentHelper","makeDefaultListBoxItemChildren"],"mappings":";;;;;;;;;;;;;;AA4CO,SAAS,iBAAmC,KAAsB,EAAA;AACvE,EAAM,MAAA,EAAE,OAAS,EAAA,UAAA,EAAe,GAAA,KAAA,CAAA;A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A;AAAA,YACtB,KAAO,EAAA;AAAA,cACL,QAAU,EAAAC,kDAAA;AAAA,gBACR,wBAAA;AAAA,gBACA,uEAAA;AAAA,eACF;AAAA,aACF;AAAA,WACF;AAAA,SACF;AAAA,QACA,aAAe,EAAA;AAAA,UACb,IAAM,EAAA,MAAA;AAAA,UACN,WAAa,EAAA,gBAAA;AAAA,UACb,gBAAA,EAAkB,CAAC,cAAc,CAAA;AAAA,UACjC,YAAc,EAAA;AAAA,YACZ,IAAM,EAAA,WAAA;AAAA,YACN,MAAM,WAAY,CAAA,IAAA;AAAA,YAClB,MAAQ,EAAA;AAAA,cACN,eAAiB,EAAA,SAAA;AAAA,aACnB;AAAA,WACF;AAAA,SACF;AAAA,OACF;AAAA,KACF;AAAA,IACA,SAAA;AAAA,GACF,CAAA;AACF;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"registerListBox-e98e849f.cjs.js","sources":["../src/option-utils.ts","../src/registerListBox.tsx"],"sourcesContent":["import type { ArrayType, ChoiceType } from \"@plasmicapp/host/registerComponent\";\nimport React from \"react\";\n\nexport interface ObjectSectionType<T extends object> {\n label?: string;\n items?: ObjectItemType<T>[];\n}\ninterface FlexSectionType<T extends object> {\n label?: string;\n items?: FlexItemType<T>[];\n}\n\nexport type ObjectItemType<T extends object> = StrictOptionType | T;\ntype FlexItemType<T extends object> = ObjectItemType<T> | string;\n\nexport type FlexOptionType<T extends object> =\n | FlexItemType<T>\n | FlexSectionType<T>;\n\nexport type ObjectOptionType<T extends object> =\n | ObjectSectionType<T>\n | ObjectItemType<T>;\n\nexport interface HasOptions<T extends object> {\n options?: FlexOptionType<T>[];\n optionInfo?: (option: FlexOptionType<T>) => StrictOptionType;\n}\n\nexport interface StrictItemType {\n type?: \"option\";\n id: string;\n label?: string;\n isDisabled?: boolean;\n}\n\nexport interface StrictSectionType {\n type: \"option-group\";\n label?: string;\n items?: StrictItemType[];\n key: string;\n}\n\nexport type StrictOptionType = StrictItemType | StrictSectionType;\n\nexport function useStrictOptions<T extends object>(props: HasOptions<T>) {\n const { options, optionInfo } = props;\n return React.useMemo(() => {\n return deriveStrictOptions({ options, optionInfo });\n }, [options, optionInfo]);\n}\n\nexport function deriveStrictOptions<T extends object>(props: HasOptions<T>) {\n const { options, optionInfo } = props;\n let sectionCount = 0;\n\n const makeStrict = (op: FlexOptionType<T>): StrictOptionType | undefined => {\n if (!op) {\n return undefined;\n } else if (typeof op === \"string\" || typeof op === \"number\") {\n const item = {\n id: op,\n };\n return item;\n } else if (optionInfo) {\n const info = optionInfo(op);\n if (info.type === \"option-group\") {\n const section: StrictSectionType = {\n type: \"option-group\",\n items: info.items\n ?.map?.((item) => makeStrict(item) as StrictItemType)\n ?.filter((x) => !!x),\n label: info.label,\n key: `option-group-${sectionCount}`,\n };\n sectionCount += 1;\n return section;\n } else {\n let item = info;\n if (!(\"id\" in item)) {\n item = {\n type: \"option\",\n id: JSON.stringify(item),\n };\n }\n return item;\n }\n } else if (typeof op === \"object\") {\n if (\"items\" in op) {\n const section: StrictSectionType = {\n type: \"option-group\",\n items: op.items\n ?.map?.((item) => makeStrict(item) as StrictItemType)\n ?.filter((x) => !!x),\n label: op.label,\n key: `option-group-${sectionCount}`,\n };\n sectionCount += 1;\n return section;\n } else {\n let item = op;\n if (!(\"id\" in item)) {\n item = {\n type: \"option\",\n id: JSON.stringify(item),\n };\n }\n return item;\n }\n } else {\n return undefined;\n }\n };\n\n const strictOptions = options\n ?.map(makeStrict)\n ?.filter((x): x is StrictOptionType => !!x);\n\n const optionText = (op: StrictItemType) => {\n return op.label ?? op.id;\n };\n\n return { options: strictOptions, optionText };\n}\n\nexport function flattenOptions(\n options: (StrictItemType | StrictSectionType)[] | undefined\n): StrictItemType[] {\n if (!options) {\n return [];\n } else {\n return options.flatMap((op) =>\n op.type === \"option-group\" ? op.items ?? [] : op\n );\n }\n}\n\nexport function makeOptionsPropType() {\n const type: ArrayType<HasOptions<any>> = {\n type: \"array\",\n itemType: {\n type: \"object\",\n nameFunc: (item: any) => item.label || item.id,\n fields: {\n type: {\n type: \"choice\",\n options: [\n { value: \"option\", label: \"Option\" },\n { value: \"option-group\", label: \"Option Group\" },\n ],\n defaultValue: \"option\",\n },\n id: {\n type: \"string\",\n hidden: (_ps: any, _ctx: any, { item }: any) =>\n item.type !== \"option\",\n },\n label: \"string\",\n items: {\n type: \"array\",\n displayName: \"Options\",\n hidden: (_ps: any, _ctx: any, { item }: any) => {\n return item.type !== \"option-group\";\n },\n itemType: {\n type: \"object\",\n nameFunc: (item: any) => item.label || item.id,\n fields: {\n id: \"string\",\n label: \"string\",\n },\n },\n },\n },\n },\n defaultValue: [\n {\n id: \"option1\",\n label: \"Option 1\",\n type: \"option\",\n },\n {\n id: \"option2\",\n label: \"Option 2\",\n type: \"option\",\n },\n {\n label: \"Section 1\",\n type: \"option-group\",\n items: [\n {\n id: \"section-1-1\",\n label: \"Section item 1\",\n type: \"option\",\n },\n {\n id: \"section-1-2\",\n label: \"Section item 2\",\n type: \"option\",\n },\n ],\n },\n ],\n };\n return type;\n}\n\nexport function makeValuePropType() {\n const type: ChoiceType<HasOptions<any>> = {\n type: \"choice\",\n options: (ps: HasOptions<any>) => {\n const { options, optionText } = deriveStrictOptions(ps);\n return flattenOptions(options).map((op) => ({\n value: op.id,\n label: optionText(op),\n }));\n },\n };\n return type;\n}\n","import { mergeProps } from \"@react-aria/utils\";\nimport React from \"react\";\nimport { ListBox } from \"react-aria-components\";\nimport {\n PlasmicItemContext,\n PlasmicListBoxContext,\n PlasmicSectionContext,\n} from \"./contexts\";\nimport {\n HasOptions,\n makeOptionsPropType,\n StrictOptionType,\n useStrictOptions,\n} from \"./option-utils\";\nimport {\n makeDefaultListBoxItemChildren,\n registerListBoxItem,\n} from \"./registerListBoxItem\";\nimport { registerSection } from \"./registerSection\";\nimport {\n BaseControlContextData,\n CodeComponentMetaOverrides,\n makeComponentName,\n Registerable,\n registerComponentHelper,\n} from \"./utils\";\n\nexport interface BaseListBoxProps\n extends React.ComponentProps<typeof ListBox>,\n HasOptions<any> {\n renderItem?: (item: any) => React.ReactNode;\n renderSection?: (section: any) => React.ReactNode;\n getItemType?: (thing: any) => \"item\" | \"section\";\n setControlContextData?: (ctxData: BaseControlContextData) => void;\n}\n\nexport function BaseListBox(props: BaseListBoxProps) {\n const contextProps = React.useContext(PlasmicListBoxContext);\n const isStandalone: boolean = !contextProps;\n const { options: _rawOptions, ...rest } = props;\n const { options } = useStrictOptions(props);\n const { renderItem, renderSection, ...mergedProps } = mergeProps(\n contextProps,\n rest,\n isStandalone ? { items: options } : {}\n );\n\n // Tell the prop control about whether the listbox is standalone or not, so it can hide/show the items prop\n props.setControlContextData?.({\n isStandalone,\n });\n\n return (\n <ListBox {...mergedProps}>\n {(item: StrictOptionType) => {\n if (item.type === \"option-group\") {\n return (\n <>\n <PlasmicSectionContext.Provider\n value={{\n renderItem,\n key: item.key ?? item.label,\n section: item,\n }}\n >\n {renderSection?.(item)}\n </PlasmicSectionContext.Provider>\n </>\n );\n } else {\n return (\n <PlasmicItemContext.Provider value={item}>\n {renderItem?.(item)}\n </PlasmicItemContext.Provider>\n );\n }\n }}\n </ListBox>\n );\n}\n\nexport const LIST_BOX_COMPONENT_NAME = makeComponentName(\"listbox\");\n\nexport function registerListBox(\n loader?: Registerable,\n overrides?: CodeComponentMetaOverrides<typeof BaseListBox>\n) {\n const listBoxItemMeta = registerListBoxItem(loader, {\n parentComponentName: LIST_BOX_COMPONENT_NAME,\n });\n const sectionMeta = registerSection(loader, {\n parentComponentName: LIST_BOX_COMPONENT_NAME,\n });\n\n registerComponentHelper(\n loader,\n BaseListBox,\n {\n name: LIST_BOX_COMPONENT_NAME,\n displayName: \"Aria ListBox\",\n importPath: \"@plasmicpkgs/react-aria/skinny/registerListBox\",\n importName: \"BaseListBox\",\n defaultStyles: {\n width: \"250px\",\n borderWidth: \"1px\",\n borderStyle: \"solid\",\n borderColor: \"black\",\n },\n props: {\n options: {\n ...makeOptionsPropType(),\n displayName: \"Items\",\n hidden: (_ps: BaseListBoxProps, ctx: BaseControlContextData | null) =>\n !ctx?.isStandalone,\n },\n renderItem: {\n type: \"slot\",\n displayName: \"Render Item\",\n renderPropParams: [\"itemProps\"],\n defaultValue: {\n type: \"component\",\n name: listBoxItemMeta.name,\n props: {\n children: makeDefaultListBoxItemChildren(\n \"Item (itemProps.label)\",\n \"Connect with `itemProps` in the data picker to display list box items\"\n ),\n },\n },\n },\n renderSection: {\n type: \"slot\",\n displayName: \"Render Section\",\n renderPropParams: [\"sectionProps\"],\n defaultValue: {\n type: \"component\",\n name: sectionMeta.name,\n styles: {\n backgroundColor: \"#F4FAFF\",\n },\n },\n },\n },\n },\n overrides\n );\n}\n"],"names":["React","_a","PlasmicListBoxContext","mergeProps","ListBox","PlasmicSectionContext","PlasmicItemContext","makeComponentName","registerListBoxItem","registerSection","registerComponentHelper","makeDefaultListBoxItemChildren"],"mappings":";;;;;;;;;;;;;;AA4CO,SAAS,iBAAmC,KAAsB,EAAA;AACvE,EAAM,MAAA,EAAE,OAAS,EAAA,UAAA,EAAe,GAAA,KAAA,CAAA;AAChC,EAAO,OAAAA,sBAAA,CAAM,QAAQ,MAAM;AACzB,IAAA,OAAO,mBAAoB,CAAA,EAAE,OAAS,EAAA,UAAA,EAAY,CAAA,CAAA;AAAA,GACjD,EAAA,CAAC,OAAS,EAAA,UAAU,CAAC,CAAA,CAAA;AAC1B,CAAA;AAEO,SAAS,oBAAsC,KAAsB,EAAA;AAnD5E,EAAA,IAAA,EAAA,CAAA;AAoDE,EAAM,MAAA,EAAE,OAAS,EAAA,UAAA,EAAe,GAAA,KAAA,CAAA;AAChC,EAAA,IAAI,YAAe,GAAA,CAAA,CAAA;AAEnB,EAAM,MAAA,UAAA,GAAa,CAAC,EAAwD,KAAA;AAvD9E,IAAA,IAAAC,GAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,CAAA;AAwDI,IAAA,IAAI,CAAC,EAAI,EAAA;AACP,MAAO,O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
4
4
|
require('react');
|
|
5
5
|
require('react-aria-components');
|
|
6
6
|
require('./contexts-b21f6b12.cjs.js');
|
|
7
|
-
var registerListBox = require('./registerListBox-
|
|
7
|
+
var registerListBox = require('./registerListBox-e98e849f.cjs.js');
|
|
8
8
|
require('./registerListBoxItem.cjs.js');
|
|
9
9
|
require('./registerSection.cjs.js');
|
|
10
|
-
require('./utils-
|
|
10
|
+
require('./utils-d3708034.cjs.js');
|
|
11
|
+
require('./ErrorBoundary-e9b86248.cjs.js');
|
|
11
12
|
require('./registerDescription.cjs.js');
|
|
12
13
|
require('./registerText.cjs.js');
|
|
13
14
|
require('@plasmicapp/host/registerComponent');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registerListBox.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"registerListBox.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -2,10 +2,11 @@ import '@react-aria/utils';
|
|
|
2
2
|
import 'react';
|
|
3
3
|
import 'react-aria-components';
|
|
4
4
|
import './contexts-9475faad.esm.js';
|
|
5
|
-
export { B as BaseListBox, L as LIST_BOX_COMPONENT_NAME, r as registerListBox } from './registerListBox-
|
|
5
|
+
export { B as BaseListBox, L as LIST_BOX_COMPONENT_NAME, r as registerListBox } from './registerListBox-cbc7beea.esm.js';
|
|
6
6
|
import './registerListBoxItem.esm.js';
|
|
7
7
|
import './registerSection.esm.js';
|
|
8
|
-
import './utils-
|
|
8
|
+
import './utils-a1785802.esm.js';
|
|
9
|
+
import './ErrorBoundary-c6b111d3.esm.js';
|
|
9
10
|
import './registerDescription.esm.js';
|
|
10
11
|
import './registerText.esm.js';
|
|
11
12
|
import '@plasmicapp/host/registerComponent';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registerListBox.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"registerListBox.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;"}
|
|
@@ -4,9 +4,10 @@ var utils = require('@react-aria/utils');
|
|
|
4
4
|
var React = require('react');
|
|
5
5
|
var reactAriaComponents = require('react-aria-components');
|
|
6
6
|
var contexts = require('./contexts-b21f6b12.cjs.js');
|
|
7
|
+
var ErrorBoundary = require('./ErrorBoundary-e9b86248.cjs.js');
|
|
7
8
|
var registerDescription = require('./registerDescription.cjs.js');
|
|
8
9
|
var registerText = require('./registerText.cjs.js');
|
|
9
|
-
var utils$1 = require('./utils-
|
|
10
|
+
var utils$1 = require('./utils-d3708034.cjs.js');
|
|
10
11
|
require('@plasmicapp/host/registerComponent');
|
|
11
12
|
|
|
12
13
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -35,7 +36,8 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
35
36
|
function BaseListBoxItem(props) {
|
|
36
37
|
const contextProps = React__default.default.useContext(contexts.PlasmicItemContext);
|
|
37
38
|
const mergedProps = utils.mergeProps(contextProps, props);
|
|
38
|
-
|
|
39
|
+
const listboxItem = /* @__PURE__ */ React__default.default.createElement(reactAriaComponents.ListBoxItem, __spreadProps(__spreadValues({}, mergedProps), { textValue: contextProps == null ? void 0 : contextProps.label }), mergedProps.children);
|
|
40
|
+
return /* @__PURE__ */ React__default.default.createElement(ErrorBoundary.ErrorBoundary, { fallback: /* @__PURE__ */ React__default.default.createElement(reactAriaComponents.ListBox, null, listboxItem) }, listboxItem);
|
|
39
41
|
}
|
|
40
42
|
const makeDefaultListBoxItemChildren = (label, description) => ({
|
|
41
43
|
type: "vbox",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registerListBoxItem.cjs.js","sources":["../src/registerListBoxItem.tsx"],"sourcesContent":["import { PlasmicElement } from \"@plasmicapp/host\";\nimport { mergeProps } from \"@react-aria/utils\";\nimport React from \"react\";\nimport { ListBoxItem } from \"react-aria-components\";\nimport { PlasmicItemContext } from \"./contexts\";\nimport { DESCRIPTION_COMPONENT_NAME } from \"./registerDescription\";\nimport { TEXT_COMPONENT_NAME } from \"./registerText\";\nimport {\n CodeComponentMetaOverrides,\n makeComponentName,\n Registerable,\n registerComponentHelper,\n} from \"./utils\";\n\nexport function BaseListBoxItem(\n props: React.ComponentProps<typeof ListBoxItem>\n) {\n const contextProps = React.useContext(PlasmicItemContext);\n const mergedProps = mergeProps(contextProps, props);\n\n
|
|
1
|
+
{"version":3,"file":"registerListBoxItem.cjs.js","sources":["../src/registerListBoxItem.tsx"],"sourcesContent":["import { PlasmicElement } from \"@plasmicapp/host\";\nimport { mergeProps } from \"@react-aria/utils\";\nimport React from \"react\";\nimport { ListBox, ListBoxItem } from \"react-aria-components\";\nimport { PlasmicItemContext } from \"./contexts\";\nimport ErrorBoundary from \"./ErrorBoundary\";\nimport { DESCRIPTION_COMPONENT_NAME } from \"./registerDescription\";\nimport { TEXT_COMPONENT_NAME } from \"./registerText\";\nimport {\n CodeComponentMetaOverrides,\n makeComponentName,\n Registerable,\n registerComponentHelper,\n} from \"./utils\";\n\nexport function BaseListBoxItem(\n props: React.ComponentProps<typeof ListBoxItem>\n) {\n const contextProps = React.useContext(PlasmicItemContext);\n const mergedProps = mergeProps(contextProps, props);\n\n const listboxItem = (\n <ListBoxItem {...mergedProps} textValue={contextProps?.label}>\n {mergedProps.children as React.ReactNode}\n </ListBoxItem>\n );\n return (\n <ErrorBoundary fallback={<ListBox>{listboxItem}</ListBox>}>\n {listboxItem}\n </ErrorBoundary>\n );\n}\n\nexport const makeDefaultListBoxItemChildren = (\n label: string,\n description?: string\n): PlasmicElement => ({\n type: \"vbox\",\n styles: {\n display: \"flex\",\n alignItems: \"flex-start\",\n gap: \"2px\",\n },\n children: [\n {\n type: \"component\",\n name: TEXT_COMPONENT_NAME,\n props: {\n slot: \"label\",\n children: {\n type: \"text\",\n styles: {\n fontWeight: 500,\n },\n value: label,\n },\n },\n },\n {\n type: \"component\",\n name: DESCRIPTION_COMPONENT_NAME,\n props: {\n children: {\n type: \"text\",\n styles: {\n color: \"#838383\",\n },\n value: description ?? `Some description for ${label}...`,\n },\n },\n },\n ],\n});\n\nexport function registerListBoxItem(\n loader?: Registerable,\n overrides?: CodeComponentMetaOverrides<typeof BaseListBoxItem>\n) {\n return registerComponentHelper(\n loader,\n BaseListBoxItem,\n {\n name: makeComponentName(\"item\"),\n displayName: \"Aria ListBoxItem\",\n importPath: \"@plasmicpkgs/react-aria/skinny/registerListBoxItem\",\n importName: \"BaseListBoxItem\",\n props: {\n children: {\n type: \"slot\",\n defaultValue: makeDefaultListBoxItemChildren(\"Item\"),\n },\n },\n },\n overrides\n );\n}\n"],"names":["React","PlasmicItemContext","mergeProps","ListBoxItem","ErrorBoundary","ListBox","TEXT_COMPONENT_NAME","DESCRIPTION_COMPONENT_NAME","registerComponentHelper","makeComponentName"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeO,SAAS,gBACd,KACA,EAAA;AACA,EAAM,MAAA,YAAA,GAAeA,sBAAM,CAAA,UAAA,CAAWC,2BAAkB,CAAA,CAAA;AACxD,EAAM,MAAA,WAAA,GAAcC,gBAAW,CAAA,YAAA,EAAc,KAAK,CAAA,CAAA;AAElD,EAAM,MAAA,WAAA,wDACHC,+BAAgB,EAAA,aAAA,CAAA,cAAA,CAAA,EAAA,EAAA,WAAA,CAAA,EAAhB,EAA6B,SAAW,EAAA,YAAA,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,YAAA,CAAc,KACpD,EAAA,CAAA,EAAA,WAAA,CAAY,QACf,CAAA,CAAA;AAEF,EAAA,4DACGC,2BAAc,EAAA,EAAA,QAAA,uDAAWC,2BAAS,EAAA,IAAA,EAAA,WAAY,KAC5C,WACH,CAAA,CAAA;AAEJ,CAAA;AAEa,MAAA,8BAAA,GAAiC,CAC5C,KAAA,EACA,WACoB,MAAA;AAAA,EACpB,IAAM,EAAA,MA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F;;;;;;"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { mergeProps } from '@react-aria/utils';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import { ListBoxItem } from 'react-aria-components';
|
|
3
|
+
import { ListBoxItem, ListBox } from 'react-aria-components';
|
|
4
4
|
import { f as PlasmicItemContext } from './contexts-9475faad.esm.js';
|
|
5
|
+
import { E as ErrorBoundary } from './ErrorBoundary-c6b111d3.esm.js';
|
|
5
6
|
import { DESCRIPTION_COMPONENT_NAME } from './registerDescription.esm.js';
|
|
6
7
|
import { TEXT_COMPONENT_NAME } from './registerText.esm.js';
|
|
7
|
-
import { r as registerComponentHelper, a as makeComponentName } from './utils-
|
|
8
|
+
import { r as registerComponentHelper, a as makeComponentName } from './utils-a1785802.esm.js';
|
|
8
9
|
import '@plasmicapp/host/registerComponent';
|
|
9
10
|
|
|
10
11
|
var __defProp = Object.defineProperty;
|
|
@@ -29,7 +30,8 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
29
30
|
function BaseListBoxItem(props) {
|
|
30
31
|
const contextProps = React.useContext(PlasmicItemContext);
|
|
31
32
|
const mergedProps = mergeProps(contextProps, props);
|
|
32
|
-
|
|
33
|
+
const listboxItem = /* @__PURE__ */ React.createElement(ListBoxItem, __spreadProps(__spreadValues({}, mergedProps), { textValue: contextProps == null ? void 0 : contextProps.label }), mergedProps.children);
|
|
34
|
+
return /* @__PURE__ */ React.createElement(ErrorBoundary, { fallback: /* @__PURE__ */ React.createElement(ListBox, null, listboxItem) }, listboxItem);
|
|
33
35
|
}
|
|
34
36
|
const makeDefaultListBoxItemChildren = (label, description) => ({
|
|
35
37
|
type: "vbox",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registerListBoxItem.esm.js","sources":["../src/registerListBoxItem.tsx"],"sourcesContent":["import { PlasmicElement } from \"@plasmicapp/host\";\nimport { mergeProps } from \"@react-aria/utils\";\nimport React from \"react\";\nimport { ListBoxItem } from \"react-aria-components\";\nimport { PlasmicItemContext } from \"./contexts\";\nimport { DESCRIPTION_COMPONENT_NAME } from \"./registerDescription\";\nimport { TEXT_COMPONENT_NAME } from \"./registerText\";\nimport {\n CodeComponentMetaOverrides,\n makeComponentName,\n Registerable,\n registerComponentHelper,\n} from \"./utils\";\n\nexport function BaseListBoxItem(\n props: React.ComponentProps<typeof ListBoxItem>\n) {\n const contextProps = React.useContext(PlasmicItemContext);\n const mergedProps = mergeProps(contextProps, props);\n\n
|
|
1
|
+
{"version":3,"file":"registerListBoxItem.esm.js","sources":["../src/registerListBoxItem.tsx"],"sourcesContent":["import { PlasmicElement } from \"@plasmicapp/host\";\nimport { mergeProps } from \"@react-aria/utils\";\nimport React from \"react\";\nimport { ListBox, ListBoxItem } from \"react-aria-components\";\nimport { PlasmicItemContext } from \"./contexts\";\nimport ErrorBoundary from \"./ErrorBoundary\";\nimport { DESCRIPTION_COMPONENT_NAME } from \"./registerDescription\";\nimport { TEXT_COMPONENT_NAME } from \"./registerText\";\nimport {\n CodeComponentMetaOverrides,\n makeComponentName,\n Registerable,\n registerComponentHelper,\n} from \"./utils\";\n\nexport function BaseListBoxItem(\n props: React.ComponentProps<typeof ListBoxItem>\n) {\n const contextProps = React.useContext(PlasmicItemContext);\n const mergedProps = mergeProps(contextProps, props);\n\n const listboxItem = (\n <ListBoxItem {...mergedProps} textValue={contextProps?.label}>\n {mergedProps.children as React.ReactNode}\n </ListBoxItem>\n );\n return (\n <ErrorBoundary fallback={<ListBox>{listboxItem}</ListBox>}>\n {listboxItem}\n </ErrorBoundary>\n );\n}\n\nexport const makeDefaultListBoxItemChildren = (\n label: string,\n description?: string\n): PlasmicElement => ({\n type: \"vbox\",\n styles: {\n display: \"flex\",\n alignItems: \"flex-start\",\n gap: \"2px\",\n },\n children: [\n {\n type: \"component\",\n name: TEXT_COMPONENT_NAME,\n props: {\n slot: \"label\",\n children: {\n type: \"text\",\n styles: {\n fontWeight: 500,\n },\n value: label,\n },\n },\n },\n {\n type: \"component\",\n name: DESCRIPTION_COMPONENT_NAME,\n props: {\n children: {\n type: \"text\",\n styles: {\n color: \"#838383\",\n },\n value: description ?? `Some description for ${label}...`,\n },\n },\n },\n ],\n});\n\nexport function registerListBoxItem(\n loader?: Registerable,\n overrides?: CodeComponentMetaOverrides<typeof BaseListBoxItem>\n) {\n return registerComponentHelper(\n loader,\n BaseListBoxItem,\n {\n name: makeComponentName(\"item\"),\n displayName: \"Aria ListBoxItem\",\n importPath: \"@plasmicpkgs/react-aria/skinny/registerListBoxItem\",\n importName: \"BaseListBoxItem\",\n props: {\n children: {\n type: \"slot\",\n defaultValue: makeDefaultListBoxItemChildren(\"Item\"),\n },\n },\n },\n overrides\n );\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeO,SAAS,gBACd,KACA,EAAA;AACA,EAAM,MAAA,YAAA,GAAe,KAAM,CAAA,UAAA,CAAW,kBAAkB,CAAA,CAAA;AACxD,EAAM,MAAA,WAAA,GAAc,UAAW,CAAA,YAAA,EAAc,KAAK,CAAA,CAAA;AAElD,EAAM,MAAA,WAAA,uCACH,WAAgB,EAAA,aAAA,CAAA,cAAA,CAAA,EAAA,EAAA,WAAA,CAAA,EAAhB,EAA6B,SAAW,EAAA,YAAA,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,YAAA,CAAc,KACpD,EAAA,CAAA,EAAA,WAAA,CAAY,QACf,CAAA,CAAA;AAEF,EAAA,2CACG,aAAc,EAAA,EAAA,QAAA,sCAAW,OAAS,EAAA,IAAA,EAAA,WAAY,KAC5C,WACH,CAAA,CAAA;AAEJ,CAAA;AAEa,MAAA,8BAAA,GAAiC,CAC5C,KAAA,EACA,WACoB,MAAA;AAAA,EACpB,IAAM,EAAA,MAAA;AAAA,EACN,MAAQ,EAAA;AAAA,IACN,OAAS,EAAA,MAAA;AAAA,IACT,UAAY,EAAA,YAAA;AAAA,IACZ,GAAK,EAAA,KAAA;AAAA,GACP;AAAA,EACA,QAAU,EAAA;AAAA,IACR;AAAA,MACE,IAAM,EAAA,WAAA;AAAA,MACN,IAAM,EAAA,mBAAA;AAAA,MACN,KAAO,EAAA;AAAA,QACL,IAAM,EAAA,OAAA;AAAA,QACN,QAAU,EAAA;AAAA,UACR,IAAM,EAAA,MAAA;AAAA,UACN,MAAQ,EAAA;AAAA,YACN,UAAY,EAAA,GAAA;AAAA,WACd;AAAA,UACA,KAAO,EAAA,KAAA;AAAA,SACT;AAAA,OACF;AAAA,KACF;AAAA,IACA;AAAA,MACE,IAAM,EAAA,WAAA;AAAA,MACN,IAAM,EAAA,0BAAA;AAAA,MACN,KAAO,EAAA;AAAA,QACL,QAAU,EAAA;AAAA,UACR,IAAM,EAAA,MAAA;AAAA,UACN,MAAQ,EAAA;AAAA,YACN,KAAO,EAAA,SAAA;AAAA,WACT;AAAA,UACA,KAAA,EAAO,oCAAe,CAAwB,qBAAA,EAAA,KAAA,CAAA,GAAA,CAAA;AAAA,SAChD;AAAA,OACF;AAAA,KACF;AAAA,GACF;AACF,CAAA,EAAA;AAEgB,SAAA,mBAAA,CACd,QACA,SACA,EAAA;AACA,EAAO,OAAA,uBAAA;AAAA,IACL,MAAA;AAAA,IACA,eAAA;AAAA,IACA;AAAA,MACE,IAAA,EAAM,kBAAkB,MAAM,CAAA;AAAA,MAC9B,WAAa,EAAA,kBAAA;AAAA,MACb,UAAY,EAAA,oDAAA;AAAA,MACZ,UAAY,EAAA,iBAAA;AAAA,MACZ,KAAO,EAAA;AAAA,QACL,QAAU,EAAA;AAAA,UACR,IAAM,EAAA,MAAA;AAAA,UACN,YAAA,EAAc,+BAA+B,MAAM,CAAA;AAAA,SACrD;AAAA,OACF;AAAA,KACF;AAAA,IACA,SAAA;AAAA,GACF,CAAA;AACF;;;;"}
|
|
@@ -5,7 +5,7 @@ var React = require('react');
|
|
|
5
5
|
var reactAria = require('react-aria');
|
|
6
6
|
var reactAriaComponents = require('react-aria-components');
|
|
7
7
|
var contexts = require('./contexts-b21f6b12.cjs.js');
|
|
8
|
-
var utils = require('./utils-
|
|
8
|
+
var utils = require('./utils-d3708034.cjs.js');
|
|
9
9
|
require('@plasmicapp/host/registerComponent');
|
|
10
10
|
|
|
11
11
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -3,7 +3,7 @@ import React, { forwardRef, useImperativeHandle } from 'react';
|
|
|
3
3
|
import { mergeProps } from 'react-aria';
|
|
4
4
|
import { Heading, ModalOverlay, Modal, Dialog } from 'react-aria-components';
|
|
5
5
|
import { c as PlasmicDialogTriggerContext } from './contexts-9475faad.esm.js';
|
|
6
|
-
import { a as makeComponentName, r as registerComponentHelper } from './utils-
|
|
6
|
+
import { a as makeComponentName, r as registerComponentHelper } from './utils-a1785802.esm.js';
|
|
7
7
|
import '@plasmicapp/host/registerComponent';
|
|
8
8
|
|
|
9
9
|
var __defProp = Object.defineProperty;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var host = require('@plasmicapp/host');
|
|
3
4
|
var utils = require('@react-aria/utils');
|
|
4
5
|
var React = require('react');
|
|
5
6
|
var reactAriaComponents = require('react-aria-components');
|
|
6
7
|
var contexts = require('./contexts-b21f6b12.cjs.js');
|
|
7
|
-
var utils$1 = require('./utils-
|
|
8
|
+
var utils$1 = require('./utils-d3708034.cjs.js');
|
|
8
9
|
require('@plasmicapp/host/registerComponent');
|
|
9
10
|
|
|
10
11
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -39,20 +40,37 @@ var __objRest = (source, exclude) => {
|
|
|
39
40
|
}
|
|
40
41
|
return target;
|
|
41
42
|
};
|
|
43
|
+
const SHOULD_FLIP_INSIDE_SELECT = false;
|
|
42
44
|
function BasePopover(props) {
|
|
43
|
-
const _a = props, { resetClassName } = _a, restProps = __objRest(_a, ["resetClassName"]);
|
|
45
|
+
const _a = props, { resetClassName, setControlContextData } = _a, restProps = __objRest(_a, ["resetClassName", "setControlContextData"]);
|
|
44
46
|
const isStandalone = !React__default.default.useContext(reactAriaComponents.PopoverContext);
|
|
45
47
|
const contextProps = React__default.default.useContext(contexts.PlasmicPopoverContext);
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
const isInsideSelect = !!React__default.default.useContext(reactAriaComponents.SelectContext);
|
|
49
|
+
const mergedProps = utils.mergeProps(
|
|
50
|
+
contextProps,
|
|
51
|
+
restProps,
|
|
52
|
+
{
|
|
53
|
+
className: `${resetClassName}`
|
|
54
|
+
},
|
|
55
|
+
isInsideSelect && !utils$1.isDefined(restProps.shouldFlip) ? { shouldFlip: SHOULD_FLIP_INSIDE_SELECT } : void 0
|
|
56
|
+
);
|
|
57
|
+
const isEditMode = !!host.usePlasmicCanvasContext();
|
|
49
58
|
const triggerRef = React__default.default.useRef(null);
|
|
50
59
|
const standaloneProps = isStandalone ? {
|
|
51
60
|
triggerRef,
|
|
52
61
|
isNonModal: true,
|
|
53
62
|
isOpen: true
|
|
54
63
|
} : {};
|
|
55
|
-
|
|
64
|
+
setControlContextData == null ? void 0 : setControlContextData({
|
|
65
|
+
isStandalone,
|
|
66
|
+
isInsideSelect
|
|
67
|
+
});
|
|
68
|
+
return /* @__PURE__ */ React__default.default.createElement(React__default.default.Fragment, null, isStandalone && /* @__PURE__ */ React__default.default.createElement("div", { ref: triggerRef }), /* @__PURE__ */ React__default.default.createElement(
|
|
69
|
+
reactAriaComponents.Popover,
|
|
70
|
+
__spreadValues(__spreadValues({
|
|
71
|
+
isNonModal: isEditMode ? true : void 0
|
|
72
|
+
}, mergedProps), standaloneProps)
|
|
73
|
+
));
|
|
56
74
|
}
|
|
57
75
|
const POPOVER_COMPONENT_NAME = utils$1.makeComponentName("popover");
|
|
58
76
|
const POPOVER_ARROW_IMG = {
|
|
@@ -123,9 +141,15 @@ function registerPopover(loader, overrides) {
|
|
|
123
141
|
description: "Additional offset applied vertically between the popover and its trigger",
|
|
124
142
|
defaultValueHint: 0
|
|
125
143
|
},
|
|
144
|
+
shouldFlip: {
|
|
145
|
+
type: "boolean",
|
|
146
|
+
description: "Whether the element should flip its orientation (e.g. top to bottom or left to right) when there is insufficient room for it to render completely.",
|
|
147
|
+
defaultValueHint: (_ps, ctx) => (ctx == null ? void 0 : ctx.isInsideSelect) ? SHOULD_FLIP_INSIDE_SELECT : true
|
|
148
|
+
},
|
|
126
149
|
placement: {
|
|
127
150
|
type: "choice",
|
|
128
151
|
description: "Default placement of the popover relative to the trigger, if there is enough space",
|
|
152
|
+
defaultValueHint: "bottom",
|
|
129
153
|
options: [
|
|
130
154
|
"bottom",
|
|
131
155
|
"bottom left",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registerPopover.cjs.js","sources":["../src/registerPopover.tsx"],"sourcesContent":["import { PlasmicElement } from \"@plasmicapp/host\";\nimport { mergeProps } from \"@react-aria/utils\";\nimport React from \"react\";\nimport { Popover, PopoverContext } from \"react-aria-components\";\nimport { PlasmicPopoverContext } from \"./contexts\";\nimport {\n CodeComponentMetaOverrides,\n Registerable,\n makeComponentName,\n registerComponentHelper,\n} from \"./utils\";\n\nexport interface BasePopoverProps extends React.ComponentProps<typeof Popover> {\n className?: string;\n resetClassName?: string;\n}\n\nexport function BasePopover(props: BasePopoverProps) {\n const { resetClassName, ...restProps } = props;\n const isStandalone = !React.useContext(PopoverContext);\n const contextProps = React.useContext(PlasmicPopoverContext);\n const mergedProps = mergeProps(contextProps
|
|
1
|
+
{"version":3,"file":"registerPopover.cjs.js","sources":["../src/registerPopover.tsx"],"sourcesContent":["import { PlasmicElement, usePlasmicCanvasContext } from \"@plasmicapp/host\";\nimport { mergeProps } from \"@react-aria/utils\";\nimport React from \"react\";\nimport { Popover, PopoverContext, SelectContext } from \"react-aria-components\";\nimport { PlasmicPopoverContext } from \"./contexts\";\nimport {\n BaseControlContextData,\n CodeComponentMetaOverrides,\n Registerable,\n isDefined,\n makeComponentName,\n registerComponentHelper,\n} from \"./utils\";\n\ninterface PopoverControlContextData extends BaseControlContextData {\n isInsideSelect: boolean;\n}\n\nexport interface BasePopoverProps extends React.ComponentProps<typeof Popover> {\n className?: string;\n resetClassName?: string;\n setControlContextData?: (ctxData: PopoverControlContextData) => void;\n}\n\nconst SHOULD_FLIP_INSIDE_SELECT = false;\n\nexport function BasePopover(props: BasePopoverProps) {\n const { resetClassName, setControlContextData, ...restProps } = props;\n const isStandalone = !React.useContext(PopoverContext);\n const contextProps = React.useContext(PlasmicPopoverContext);\n const isInsideSelect = !!React.useContext(SelectContext);\n\n const mergedProps = mergeProps(\n contextProps,\n restProps,\n {\n className: `${resetClassName}`,\n },\n isInsideSelect &&\n !isDefined<BasePopoverProps[\"shouldFlip\"]>(restProps.shouldFlip)\n ? { shouldFlip: SHOULD_FLIP_INSIDE_SELECT }\n : undefined\n );\n\n const isEditMode = !!usePlasmicCanvasContext();\n\n const triggerRef = React.useRef<any>(null);\n\n const standaloneProps = isStandalone\n ? {\n triggerRef,\n isNonModal: true,\n isOpen: true,\n }\n : {};\n\n setControlContextData?.({\n isStandalone,\n isInsideSelect,\n });\n\n return (\n <>\n {isStandalone && <div ref={triggerRef} />}\n <Popover\n isNonModal={isEditMode ? true : undefined}\n {...mergedProps}\n {...standaloneProps}\n />\n </>\n );\n}\n\nexport const POPOVER_COMPONENT_NAME = makeComponentName(\"popover\");\nexport const POPOVER_ARROW_IMG: PlasmicElement = {\n type: \"img\",\n // TODO: Replace with the image of an arrow pointing up, like: https://icon-sets.iconify.design/mdi/triangle/\n src: \"https://static1.plasmic.app/arrow-up.svg\",\n styles: {\n position: \"absolute\",\n top: \"-14px\",\n // center the arrow horizontally on the popover\n left: \"50%\",\n transform: \"translateX(-50%)\",\n width: \"15px\",\n },\n};\n\nexport function registerPopover(\n loader?: Registerable,\n overrides?: CodeComponentMetaOverrides<typeof BasePopover>\n) {\n registerComponentHelper(\n loader,\n BasePopover,\n {\n name: POPOVER_COMPONENT_NAME,\n displayName: \"Aria Popover\",\n importPath: \"@plasmicpkgs/react-aria/skinny/registerPopover\",\n importName: \"BasePopover\",\n defaultStyles: {\n borderWidth: \"1px\",\n borderStyle: \"solid\",\n borderColor: \"black\",\n padding: \"20px\",\n width: \"300px\",\n backgroundColor: \"#FDE3C3\",\n },\n props: {\n children: {\n type: \"slot\",\n defaultValue: [\n POPOVER_ARROW_IMG,\n {\n type: \"vbox\",\n styles: {\n width: \"stretch\",\n padding: 0,\n gap: \"10px\",\n },\n children: [\n {\n type: \"text\",\n value: \"This is a Popover!\",\n },\n {\n type: \"text\",\n value: \"You can put anything you can imagine here!\",\n styles: {\n fontWeight: 500,\n },\n },\n {\n type: \"text\",\n value:\n \"Use it in a `Aria Dialog Trigger` component to trigger it on a button click!\",\n },\n ],\n },\n ],\n },\n offset: {\n type: \"number\",\n displayName: \"Offset\",\n description:\n \"Additional offset applied vertically between the popover and its trigger\",\n defaultValueHint: 0,\n },\n shouldFlip: {\n type: \"boolean\",\n description:\n \"Whether the element should flip its orientation (e.g. top to bottom or left to right) when there is insufficient room for it to render completely.\",\n defaultValueHint: (\n _ps: BasePopoverProps,\n ctx: PopoverControlContextData | null\n ) => (ctx?.isInsideSelect ? SHOULD_FLIP_INSIDE_SELECT : true),\n },\n placement: {\n type: \"choice\",\n description:\n \"Default placement of the popover relative to the trigger, if there is enough space\",\n defaultValueHint: \"bottom\",\n options: [\n \"bottom\",\n \"bottom left\",\n \"bottom right\",\n \"top\",\n \"top left\",\n \"top right\",\n ],\n },\n resetClassName: {\n type: \"themeResetClass\",\n },\n },\n styleSections: true,\n },\n overrides\n );\n}\n"],"names":["React","PopoverContext","PlasmicPopoverContext","SelectContext","mergeProps","isDefined","usePlasmicCanvasContext","Popover","makeComponentName","registerComponentHelper"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwBA,MAAM,yBAA4B,GAAA,KAAA,CAAA;AAE3B,SAAS,YAAY,KAAyB,EAAA;AACnD,EAAgE,MAAA,EAAA,GAAA,KAAA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plasmicapp/host";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import { Popover } from "react-aria-components";
|
|
4
|
-
import { CodeComponentMetaOverrides, Registerable } from "./utils";
|
|
4
|
+
import { BaseControlContextData, CodeComponentMetaOverrides, Registerable } from "./utils";
|
|
5
|
+
interface PopoverControlContextData extends BaseControlContextData {
|
|
6
|
+
isInsideSelect: boolean;
|
|
7
|
+
}
|
|
5
8
|
export interface BasePopoverProps extends React.ComponentProps<typeof Popover> {
|
|
6
9
|
className?: string;
|
|
7
10
|
resetClassName?: string;
|
|
11
|
+
setControlContextData?: (ctxData: PopoverControlContextData) => void;
|
|
8
12
|
}
|
|
9
13
|
export declare function BasePopover(props: BasePopoverProps): React.JSX.Element;
|
|
10
14
|
export declare const POPOVER_COMPONENT_NAME: string;
|
|
11
15
|
export declare const POPOVER_ARROW_IMG: PlasmicElement;
|
|
12
16
|
export declare function registerPopover(loader?: Registerable, overrides?: CodeComponentMetaOverrides<typeof BasePopover>): void;
|
|
17
|
+
export {};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { usePlasmicCanvasContext } from '@plasmicapp/host';
|
|
1
2
|
import { mergeProps } from '@react-aria/utils';
|
|
2
3
|
import React from 'react';
|
|
3
|
-
import { PopoverContext, Popover } from 'react-aria-components';
|
|
4
|
+
import { PopoverContext, SelectContext, Popover } from 'react-aria-components';
|
|
4
5
|
import { g as PlasmicPopoverContext } from './contexts-9475faad.esm.js';
|
|
5
|
-
import { a as makeComponentName, r as registerComponentHelper } from './utils-
|
|
6
|
+
import { i as isDefined, a as makeComponentName, r as registerComponentHelper } from './utils-a1785802.esm.js';
|
|
6
7
|
import '@plasmicapp/host/registerComponent';
|
|
7
8
|
|
|
8
9
|
var __defProp = Object.defineProperty;
|
|
@@ -33,20 +34,37 @@ var __objRest = (source, exclude) => {
|
|
|
33
34
|
}
|
|
34
35
|
return target;
|
|
35
36
|
};
|
|
37
|
+
const SHOULD_FLIP_INSIDE_SELECT = false;
|
|
36
38
|
function BasePopover(props) {
|
|
37
|
-
const _a = props, { resetClassName } = _a, restProps = __objRest(_a, ["resetClassName"]);
|
|
39
|
+
const _a = props, { resetClassName, setControlContextData } = _a, restProps = __objRest(_a, ["resetClassName", "setControlContextData"]);
|
|
38
40
|
const isStandalone = !React.useContext(PopoverContext);
|
|
39
41
|
const contextProps = React.useContext(PlasmicPopoverContext);
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
const isInsideSelect = !!React.useContext(SelectContext);
|
|
43
|
+
const mergedProps = mergeProps(
|
|
44
|
+
contextProps,
|
|
45
|
+
restProps,
|
|
46
|
+
{
|
|
47
|
+
className: `${resetClassName}`
|
|
48
|
+
},
|
|
49
|
+
isInsideSelect && !isDefined(restProps.shouldFlip) ? { shouldFlip: SHOULD_FLIP_INSIDE_SELECT } : void 0
|
|
50
|
+
);
|
|
51
|
+
const isEditMode = !!usePlasmicCanvasContext();
|
|
43
52
|
const triggerRef = React.useRef(null);
|
|
44
53
|
const standaloneProps = isStandalone ? {
|
|
45
54
|
triggerRef,
|
|
46
55
|
isNonModal: true,
|
|
47
56
|
isOpen: true
|
|
48
57
|
} : {};
|
|
49
|
-
|
|
58
|
+
setControlContextData == null ? void 0 : setControlContextData({
|
|
59
|
+
isStandalone,
|
|
60
|
+
isInsideSelect
|
|
61
|
+
});
|
|
62
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, isStandalone && /* @__PURE__ */ React.createElement("div", { ref: triggerRef }), /* @__PURE__ */ React.createElement(
|
|
63
|
+
Popover,
|
|
64
|
+
__spreadValues(__spreadValues({
|
|
65
|
+
isNonModal: isEditMode ? true : void 0
|
|
66
|
+
}, mergedProps), standaloneProps)
|
|
67
|
+
));
|
|
50
68
|
}
|
|
51
69
|
const POPOVER_COMPONENT_NAME = makeComponentName("popover");
|
|
52
70
|
const POPOVER_ARROW_IMG = {
|
|
@@ -117,9 +135,15 @@ function registerPopover(loader, overrides) {
|
|
|
117
135
|
description: "Additional offset applied vertically between the popover and its trigger",
|
|
118
136
|
defaultValueHint: 0
|
|
119
137
|
},
|
|
138
|
+
shouldFlip: {
|
|
139
|
+
type: "boolean",
|
|
140
|
+
description: "Whether the element should flip its orientation (e.g. top to bottom or left to right) when there is insufficient room for it to render completely.",
|
|
141
|
+
defaultValueHint: (_ps, ctx) => (ctx == null ? void 0 : ctx.isInsideSelect) ? SHOULD_FLIP_INSIDE_SELECT : true
|
|
142
|
+
},
|
|
120
143
|
placement: {
|
|
121
144
|
type: "choice",
|
|
122
145
|
description: "Default placement of the popover relative to the trigger, if there is enough space",
|
|
146
|
+
defaultValueHint: "bottom",
|
|
123
147
|
options: [
|
|
124
148
|
"bottom",
|
|
125
149
|
"bottom left",
|