@plasmicpkgs/react-aria 0.0.68 → 0.0.69
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/react-aria.esm.js +18 -18
- package/dist/react-aria.esm.js.map +1 -1
- package/dist/react-aria.js +18 -18
- package/dist/react-aria.js.map +1 -1
- package/dist/registerListBox.d.ts +1 -1
- package/dist/registerSection.d.ts +0 -2
- package/package.json +2 -2
- package/skinny/registerComboBox.cjs.js +7 -7
- package/skinny/registerComboBox.cjs.js.map +1 -1
- package/skinny/registerComboBox.esm.js +7 -7
- package/skinny/registerComboBox.esm.js.map +1 -1
- package/skinny/{registerListBox-62e01fbb.cjs.js → registerListBox-44b5ecda.cjs.js} +7 -7
- package/skinny/registerListBox-44b5ecda.cjs.js.map +1 -0
- package/skinny/{registerListBox-5425b5fe.esm.js → registerListBox-5d740ec8.esm.js} +7 -7
- package/skinny/registerListBox-5d740ec8.esm.js.map +1 -0
- package/skinny/registerListBox.cjs.js +1 -1
- package/skinny/registerListBox.d.ts +1 -1
- package/skinny/registerListBox.esm.js +1 -1
- package/skinny/registerListBoxItem.cjs.js +1 -1
- package/skinny/registerListBoxItem.cjs.js.map +1 -1
- package/skinny/registerListBoxItem.esm.js +1 -1
- package/skinny/registerListBoxItem.esm.js.map +1 -1
- package/skinny/registerSection.cjs.js.map +1 -1
- package/skinny/registerSection.d.ts +0 -2
- package/skinny/registerSection.esm.js.map +1 -1
- package/skinny/registerSelect.cjs.js +6 -6
- package/skinny/registerSelect.cjs.js.map +1 -1
- package/skinny/registerSelect.esm.js +6 -6
- package/skinny/registerSelect.esm.js.map +1 -1
- package/skinny/registerListBox-5425b5fe.esm.js.map +0 -1
- package/skinny/registerListBox-62e01fbb.cjs.js.map +0 -1
|
@@ -12,7 +12,7 @@ export interface BaseListBoxProps extends Omit<React.ComponentProps<typeof ListB
|
|
|
12
12
|
}
|
|
13
13
|
export declare const listboxHelpers: {
|
|
14
14
|
states: {
|
|
15
|
-
|
|
15
|
+
selectedValue: {
|
|
16
16
|
onChangeArgsToValue: (value: Set<Key> | string[] | string) => Key;
|
|
17
17
|
};
|
|
18
18
|
};
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { Key } from "react-aria-components";
|
|
3
2
|
import { CodeComponentMetaOverrides, Registerable, Styleable } from "./utils";
|
|
4
3
|
export interface BaseSectionProps extends Styleable {
|
|
5
4
|
items: React.ReactNode;
|
|
6
5
|
header: React.ReactNode;
|
|
7
|
-
key?: Key;
|
|
8
6
|
}
|
|
9
7
|
export declare function BaseSection(props: BaseSectionProps): React.JSX.Element;
|
|
10
8
|
export declare function registerSection(loader?: Registerable, overrides?: CodeComponentMetaOverrides<typeof BaseSection>): import("@plasmicapp/host").CodeComponentMeta<BaseSectionProps>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plasmicpkgs/react-aria",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.69",
|
|
4
4
|
"description": "Plasmic registration calls for react-aria based components",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -74,5 +74,5 @@
|
|
|
74
74
|
"publishConfig": {
|
|
75
75
|
"access": "public"
|
|
76
76
|
},
|
|
77
|
-
"gitHead": "
|
|
77
|
+
"gitHead": "4f66ee3e28b4aadf586d6cadf990d8302b3c4c2d"
|
|
78
78
|
}
|
|
@@ -5,7 +5,7 @@ var React = require('react');
|
|
|
5
5
|
var reactAriaComponents = require('react-aria-components');
|
|
6
6
|
var common = require('./common-2e984ab4.cjs.js');
|
|
7
7
|
var contexts = require('./contexts-baa37b74.cjs.js');
|
|
8
|
-
var registerListBox = require('./registerListBox-
|
|
8
|
+
var registerListBox = require('./registerListBox-44b5ecda.cjs.js');
|
|
9
9
|
var registerButton = require('./registerButton.cjs.js');
|
|
10
10
|
var registerInput = require('./registerInput.cjs.js');
|
|
11
11
|
var registerLabel = require('./registerLabel.cjs.js');
|
|
@@ -113,17 +113,17 @@ function registerComboBox(loader) {
|
|
|
113
113
|
])), {
|
|
114
114
|
selectedKey: {
|
|
115
115
|
type: "choice",
|
|
116
|
-
description: "The selected keys of the listbox",
|
|
117
116
|
editOnly: true,
|
|
118
117
|
uncontrolledProp: "defaultSelectedKey",
|
|
119
|
-
displayName: "Initial selected
|
|
118
|
+
displayName: "Initial selected item",
|
|
120
119
|
options: (_props, ctx) => (ctx == null ? void 0 : ctx.itemIds) ? Array.from(ctx.itemIds) : [],
|
|
121
|
-
// React Aria ComboBox do not support multiple
|
|
120
|
+
// React Aria ComboBox do not support multiple selections yet
|
|
122
121
|
multiSelect: false
|
|
123
122
|
},
|
|
124
123
|
disabledKeys: {
|
|
125
124
|
type: "choice",
|
|
126
|
-
|
|
125
|
+
displayName: "Disabled values",
|
|
126
|
+
description: "The items that are disabled. These items cannot be selected, focused, or otherwise interacted with.",
|
|
127
127
|
options: (_props, ctx) => (ctx == null ? void 0 : ctx.itemIds) ? Array.from(ctx.itemIds) : [],
|
|
128
128
|
multiSelect: true,
|
|
129
129
|
advanced: true
|
|
@@ -136,7 +136,7 @@ function registerComboBox(loader) {
|
|
|
136
136
|
},
|
|
137
137
|
onSelectionChange: {
|
|
138
138
|
type: "eventHandler",
|
|
139
|
-
argTypes: [{ name: "
|
|
139
|
+
argTypes: [{ name: "selectedValue", type: "string" }]
|
|
140
140
|
},
|
|
141
141
|
onOpenChange: {
|
|
142
142
|
type: "eventHandler",
|
|
@@ -222,7 +222,7 @@ function registerComboBox(loader) {
|
|
|
222
222
|
}
|
|
223
223
|
}),
|
|
224
224
|
states: {
|
|
225
|
-
|
|
225
|
+
selectedValue: {
|
|
226
226
|
type: "writable",
|
|
227
227
|
valueProp: "selectedKey",
|
|
228
228
|
onChangeProp: "onSelectionChange",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registerComboBox.cjs.js","sources":["../src/registerComboBox.tsx"],"sourcesContent":["import {\n usePlasmicCanvasComponentInfo,\n usePlasmicCanvasContext,\n} from \"@plasmicapp/host\";\nimport React, { useEffect, useMemo } from \"react\";\nimport {\n ComboBox,\n ComboBoxProps,\n ComboBoxStateContext,\n} from \"react-aria-components\";\nimport { getCommonProps } from \"./common\";\nimport {\n PlasmicInputContext,\n PlasmicListBoxContext,\n PlasmicPopoverContext,\n} from \"./contexts\";\nimport { ListBoxItemIdManager } from \"./ListBoxItemIdManager\";\nimport { BUTTON_COMPONENT_NAME } from \"./registerButton\";\nimport { INPUT_COMPONENT_NAME } from \"./registerInput\";\nimport { LABEL_COMPONENT_NAME } from \"./registerLabel\";\nimport { LIST_BOX_COMPONENT_NAME } from \"./registerListBox\";\nimport { POPOVER_COMPONENT_NAME } from \"./registerPopover\";\nimport {\n HasControlContextData,\n makeComponentName,\n Registerable,\n registerComponentHelper,\n} from \"./utils\";\n\nconst COMBOBOX_NAME = makeComponentName(\"combobox\");\n\nexport interface BaseComboboxControlContextData {\n itemIds: string[];\n}\n\nexport interface BaseComboboxProps\n extends ComboBoxProps<{}>,\n HasControlContextData<BaseComboboxControlContextData> {\n placeholder?: string;\n children?: React.ReactNode;\n isOpen?: boolean;\n}\n\n/**\n * This React Hook is used to help with auto-opening the combobox when the canvas component is selected.\n * Currently, there is a bug in react-aria combobox (https://github.com/adobe/react-spectrum/issues/7149) where, when the combobox's popover is auto-opened, it is unable to render any listbox items.\n * Setting popover's open state to true in not enough unless, unless it has previously been opened via user interaction with combobox.\n * Also, <Combobox> does not support an `isOpen` prop either.\n *\n * So, we use this custom hook to access the combobox's internal state via ComboBoxStateContext and change the `open` state manually via tha available `open` method.\n * */\nfunction ComboboxAutoOpen(props: any) {\n const isEditMode = !!usePlasmicCanvasContext();\n const { isSelected } = usePlasmicCanvasComponentInfo(props) ?? {};\n const { open, close } = React.useContext(ComboBoxStateContext) ?? {};\n\n useEffect(() => {\n if (!isEditMode) {\n return;\n }\n if (isSelected) {\n open?.(undefined, \"manual\");\n } else {\n close?.();\n }\n // Not putting open and close in the useEffect dependencies array, because it causes a re-render loop.\n }, [isSelected, isEditMode]);\n\n return null;\n}\n\nexport function BaseComboBox(props: BaseComboboxProps) {\n const { children, setControlContextData, isOpen, ...rest } = props;\n\n const idManager = useMemo(() => new ListBoxItemIdManager(), []);\n\n useEffect(() => {\n idManager.subscribe((ids: string[]) => {\n setControlContextData?.({\n itemIds: ids,\n });\n });\n }, []);\n\n return (\n <ComboBox {...rest}>\n <PlasmicPopoverContext.Provider\n value={{ isOpen, defaultShouldFlip: false }}\n >\n <PlasmicListBoxContext.Provider\n value={{\n idManager,\n }}\n >\n <PlasmicInputContext.Provider value={{ isUncontrolled: true }}>\n <ComboboxAutoOpen {...props} />\n {children}\n </PlasmicInputContext.Provider>\n </PlasmicListBoxContext.Provider>\n </PlasmicPopoverContext.Provider>\n </ComboBox>\n );\n}\n\nexport function registerComboBox(loader?: Registerable) {\n registerComponentHelper(loader, BaseComboBox, {\n name: COMBOBOX_NAME,\n displayName: \"Aria ComboBox\",\n importPath: \"@plasmicpkgs/react-aria/skinny/registerComboBox\",\n importName: \"BaseComboBox\",\n props: {\n ...getCommonProps<BaseComboboxProps>(\"ComboBox\", [\n \"name\",\n \"aria-label\",\n \"placeholder\",\n \"isDisabled\",\n ]),\n selectedKey: {\n type: \"choice\",\n description: \"The selected keys of the listbox\",\n editOnly: true,\n uncontrolledProp: \"defaultSelectedKey\",\n displayName: \"Initial selected key\",\n options: (_props, ctx) => (ctx?.itemIds ? Array.from(ctx.itemIds) : []),\n // React Aria ComboBox do not support multiple comboBoxions yet\n multiSelect: false,\n },\n disabledKeys: {\n type: \"choice\",\n description:\n \"The item keys that are disabled. These items cannot be selected, focused, or otherwise interacted with.\",\n options: (_props, ctx) => (ctx?.itemIds ? Array.from(ctx.itemIds) : []),\n multiSelect: true,\n advanced: true,\n },\n isOpen: {\n type: \"boolean\",\n defaultValue: false,\n // It doesn't make sense to make isOpen prop editable (it's controlled by user interaction and always closed by default), so we keep this prop hidden. We have listed the prop here in the meta only so we can expose a writeable state for it.\n hidden: () => true,\n },\n onSelectionChange: {\n type: \"eventHandler\",\n argTypes: [{ name: \"selectedKey\", type: \"string\" }],\n },\n onOpenChange: {\n type: \"eventHandler\",\n argTypes: [{ name: \"isOpen\", type: \"boolean\" }],\n },\n\n children: {\n type: \"slot\",\n defaultValue: [\n {\n type: \"vbox\",\n styles: {\n justifyContent: \"flex-start\",\n alignItems: \"flex-start\",\n width: \"300px\",\n padding: 0,\n },\n children: [\n {\n type: \"component\",\n name: LABEL_COMPONENT_NAME,\n props: {\n children: {\n type: \"text\",\n value: \"Label\",\n },\n },\n },\n {\n type: \"hbox\",\n children: [\n {\n type: \"component\",\n name: INPUT_COMPONENT_NAME,\n styles: {\n width: \"100%\",\n },\n },\n {\n type: \"component\",\n name: BUTTON_COMPONENT_NAME,\n props: {\n children: {\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 width: \"15px\",\n transform: \"rotate(180deg)\",\n },\n },\n },\n },\n ],\n },\n {\n type: \"component\",\n name: POPOVER_COMPONENT_NAME,\n styles: {\n backgroundColor: \"white\",\n padding: \"10px\",\n overflow: \"scroll\",\n },\n props: {\n offset: 0,\n children: [\n {\n type: \"component\",\n name: LIST_BOX_COMPONENT_NAME,\n props: {\n selectionMode: \"single\",\n },\n styles: {\n borderWidth: 0,\n width: \"stretch\",\n },\n },\n ],\n },\n },\n ],\n },\n ],\n },\n },\n states: {\n selectedKey: {\n type: \"writable\",\n valueProp: \"selectedKey\",\n onChangeProp: \"onSelectionChange\",\n variableType: \"text\",\n },\n isOpen: {\n type: \"writable\",\n valueProp: \"isOpen\",\n onChangeProp: \"onOpenChange\",\n variableType: \"boolean\",\n },\n },\n trapsFocus: true,\n });\n}\n"],"names":["makeComponentName","usePlasmicCanvasContext","ComboBoxStateContext","useEffect","useMemo","ListBoxItemIdManager","React","ComboBox","PlasmicPopoverContext","PlasmicListBoxContext","PlasmicInputContext","registerComponentHelper","getCommonProps","LABEL_COMPONENT_NAME","INPUT_COMPONENT_NAME","BUTTON_COMPONENT_NAME","POPOVER_COMPONENT_NAME","LIST_BOX_COMPONENT_NAME"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,MAAM,aAAA,GAAgBA,wBAAkB,UAAU,CAAA,CAAA;AAsBlD,SAAS,iBAAiB,KAAY,EAAA;AAnDtC,EAAA,IAAA,EAAA,EAAA,EAAA,CAAA;AAoDE,EAAM,MAAA,UAAA,GAAa,CAAC,CAACC,4BAAwB,EAAA,CAAA;AAC7C,EAAA,MAAM,EAAE,UAAW,EAAA,GAAA,CAAI,wCAA8B,KAAK,CAAA,KAAnC,YAAwC,EAAC,CAAA;AAChE,EAAM,MAAA,EAAE,MAAM,KAAM,EAAA,GAAA,CAAI,4BAAM,UAAW,CAAAC,wCAAoB,CAArC,KAAA,IAAA,GAAA,EAAA,GAA0C,EAAC,CAAA;AAEnE,EAAAC,eAAA,CAAU,MAAM;AACd,IAAA,IAAI,CAAC,UAAY,EAAA;AACf,MAAA,OAAA;AAAA,KACF;AACA,IAAA,IAAI,UAAY,EAAA;AACd,MAAA,IAAA,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,IAAA,CAAO,KAAW,CAAA,EAAA,QAAA,CAAA,CAAA;AAAA,KACb,MAAA;AACL,MAAA,KAAA,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,KAAA,EAAA,CAAA;AAAA,KACF;AAAA,GAEC,EAAA,CAAC,UAAY,EAAA,UAAU,CAAC,CAAA,CAAA;AAE3B,EAAO,OAAA,IAAA,CAAA;AACT,CAAA;AAEO,SAAS,aAAa,KAA0B,EAAA;AACrD,EAA6D,MAAA,EAAA,GAAA,KAAA,EAArD,EAAU,QAAA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;AAAA,uBACF;AAAA,qBACF;AAAA,mBACF;AAAA,iBACF;AAAA,eACF;AAAA,cACA;AAAA,gBACE,IAAM,EAAA,WAAA;AAAA,gBACN,IAAM,EAAAC,sCAAA;AAAA,gBACN,MAAQ,EAAA;AAAA,kBACN,eAAiB,EAAA,OAAA;AAAA,kBACjB,OAAS,EAAA,MAAA;AAAA,kBACT,QAAU,EAAA,QAAA;AAAA,iBACZ;AAAA,gBACA,KAAO,EAAA;AAAA,kBACL,MAAQ,EAAA,CAAA;AAAA,kBACR,QAAU,EAAA;AAAA,oBACR;AAAA,sBACE,IAAM,EAAA,WAAA;AAAA,sBACN,IAAM,EAAAC,uCAAA;AAAA,sBACN,KAAO,EAAA;AAAA,wBACL,aAAe,EAAA,QAAA;AAAA,uBACjB;AAAA,sBACA,MAAQ,EAAA;AAAA,wBACN,WAAa,EAAA,CAAA;AAAA,wBACb,KAAO,EAAA,SAAA;AAAA,uBACT;AAAA,qBACF;AAAA,mBACF;AAAA,iBACF;AAAA,eACF;AAAA,aACF;AAAA,WACF;AAAA,SACF;AAAA,OACF;AAAA,KACF,CAAA;AAAA,IACA,MAAQ,EAAA;AAAA,MACN,WAAa,EAAA;AAAA,QACX,IAAM,EAAA,UAAA;AAAA,QACN,SAAW,EAAA,aAAA;AAAA,QACX,YAAc,EAAA,mBAAA;AAAA,QACd,YAAc,EAAA,MAAA;AAAA,OAChB;AAAA,MACA,MAAQ,EAAA;AAAA,QACN,IAAM,EAAA,UAAA;AAAA,QACN,SAAW,EAAA,QAAA;AAAA,QACX,YAAc,EAAA,cAAA;AAAA,QACd,YAAc,EAAA,SAAA;AAAA,OAChB;AAAA,KACF;AAAA,IACA,UAAY,EAAA,IAAA;AAAA,GACb,CAAA,CAAA;AACH;;;;;"}
|
|
1
|
+
{"version":3,"file":"registerComboBox.cjs.js","sources":["../src/registerComboBox.tsx"],"sourcesContent":["import {\n usePlasmicCanvasComponentInfo,\n usePlasmicCanvasContext,\n} from \"@plasmicapp/host\";\nimport React, { useEffect, useMemo } from \"react\";\nimport {\n ComboBox,\n ComboBoxProps,\n ComboBoxStateContext,\n} from \"react-aria-components\";\nimport { getCommonProps } from \"./common\";\nimport {\n PlasmicInputContext,\n PlasmicListBoxContext,\n PlasmicPopoverContext,\n} from \"./contexts\";\nimport { ListBoxItemIdManager } from \"./ListBoxItemIdManager\";\nimport { BUTTON_COMPONENT_NAME } from \"./registerButton\";\nimport { INPUT_COMPONENT_NAME } from \"./registerInput\";\nimport { LABEL_COMPONENT_NAME } from \"./registerLabel\";\nimport { LIST_BOX_COMPONENT_NAME } from \"./registerListBox\";\nimport { POPOVER_COMPONENT_NAME } from \"./registerPopover\";\nimport {\n HasControlContextData,\n makeComponentName,\n Registerable,\n registerComponentHelper,\n} from \"./utils\";\n\nconst COMBOBOX_NAME = makeComponentName(\"combobox\");\n\nexport interface BaseComboboxControlContextData {\n itemIds: string[];\n}\n\nexport interface BaseComboboxProps\n extends ComboBoxProps<{}>,\n HasControlContextData<BaseComboboxControlContextData> {\n placeholder?: string;\n children?: React.ReactNode;\n isOpen?: boolean;\n}\n\n/**\n * This React Hook is used to help with auto-opening the combobox when the canvas component is selected.\n * Currently, there is a bug in react-aria combobox (https://github.com/adobe/react-spectrum/issues/7149) where, when the combobox's popover is auto-opened, it is unable to render any listbox items.\n * Setting popover's open state to true in not enough unless, unless it has previously been opened via user interaction with combobox.\n * Also, <Combobox> does not support an `isOpen` prop either.\n *\n * So, we use this custom hook to access the combobox's internal state via ComboBoxStateContext and change the `open` state manually via tha available `open` method.\n * */\nfunction ComboboxAutoOpen(props: any) {\n const isEditMode = !!usePlasmicCanvasContext();\n const { isSelected } = usePlasmicCanvasComponentInfo(props) ?? {};\n const { open, close } = React.useContext(ComboBoxStateContext) ?? {};\n\n useEffect(() => {\n if (!isEditMode) {\n return;\n }\n if (isSelected) {\n open?.(undefined, \"manual\");\n } else {\n close?.();\n }\n // Not putting open and close in the useEffect dependencies array, because it causes a re-render loop.\n }, [isSelected, isEditMode]);\n\n return null;\n}\n\nexport function BaseComboBox(props: BaseComboboxProps) {\n const { children, setControlContextData, isOpen, ...rest } = props;\n\n const idManager = useMemo(() => new ListBoxItemIdManager(), []);\n\n useEffect(() => {\n idManager.subscribe((ids: string[]) => {\n setControlContextData?.({\n itemIds: ids,\n });\n });\n }, []);\n\n return (\n <ComboBox {...rest}>\n <PlasmicPopoverContext.Provider\n value={{ isOpen, defaultShouldFlip: false }}\n >\n <PlasmicListBoxContext.Provider\n value={{\n idManager,\n }}\n >\n <PlasmicInputContext.Provider value={{ isUncontrolled: true }}>\n <ComboboxAutoOpen {...props} />\n {children}\n </PlasmicInputContext.Provider>\n </PlasmicListBoxContext.Provider>\n </PlasmicPopoverContext.Provider>\n </ComboBox>\n );\n}\n\nexport function registerComboBox(loader?: Registerable) {\n registerComponentHelper(loader, BaseComboBox, {\n name: COMBOBOX_NAME,\n displayName: \"Aria ComboBox\",\n importPath: \"@plasmicpkgs/react-aria/skinny/registerComboBox\",\n importName: \"BaseComboBox\",\n props: {\n ...getCommonProps<BaseComboboxProps>(\"ComboBox\", [\n \"name\",\n \"aria-label\",\n \"placeholder\",\n \"isDisabled\",\n ]),\n selectedKey: {\n type: \"choice\",\n editOnly: true,\n uncontrolledProp: \"defaultSelectedKey\",\n displayName: \"Initial selected item\",\n options: (_props, ctx) => (ctx?.itemIds ? Array.from(ctx.itemIds) : []),\n // React Aria ComboBox do not support multiple selections yet\n multiSelect: false,\n },\n disabledKeys: {\n type: \"choice\",\n displayName: \"Disabled values\",\n description:\n \"The items that are disabled. These items cannot be selected, focused, or otherwise interacted with.\",\n options: (_props, ctx) => (ctx?.itemIds ? Array.from(ctx.itemIds) : []),\n multiSelect: true,\n advanced: true,\n },\n isOpen: {\n type: \"boolean\",\n defaultValue: false,\n // It doesn't make sense to make isOpen prop editable (it's controlled by user interaction and always closed by default), so we keep this prop hidden. We have listed the prop here in the meta only so we can expose a writeable state for it.\n hidden: () => true,\n },\n onSelectionChange: {\n type: \"eventHandler\",\n argTypes: [{ name: \"selectedValue\", type: \"string\" }],\n },\n onOpenChange: {\n type: \"eventHandler\",\n argTypes: [{ name: \"isOpen\", type: \"boolean\" }],\n },\n\n children: {\n type: \"slot\",\n defaultValue: [\n {\n type: \"vbox\",\n styles: {\n justifyContent: \"flex-start\",\n alignItems: \"flex-start\",\n width: \"300px\",\n padding: 0,\n },\n children: [\n {\n type: \"component\",\n name: LABEL_COMPONENT_NAME,\n props: {\n children: {\n type: \"text\",\n value: \"Label\",\n },\n },\n },\n {\n type: \"hbox\",\n children: [\n {\n type: \"component\",\n name: INPUT_COMPONENT_NAME,\n styles: {\n width: \"100%\",\n },\n },\n {\n type: \"component\",\n name: BUTTON_COMPONENT_NAME,\n props: {\n children: {\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 width: \"15px\",\n transform: \"rotate(180deg)\",\n },\n },\n },\n },\n ],\n },\n {\n type: \"component\",\n name: POPOVER_COMPONENT_NAME,\n styles: {\n backgroundColor: \"white\",\n padding: \"10px\",\n overflow: \"scroll\",\n },\n props: {\n offset: 0,\n children: [\n {\n type: \"component\",\n name: LIST_BOX_COMPONENT_NAME,\n props: {\n selectionMode: \"single\",\n },\n styles: {\n borderWidth: 0,\n width: \"stretch\",\n },\n },\n ],\n },\n },\n ],\n },\n ],\n },\n },\n states: {\n selectedValue: {\n type: \"writable\",\n valueProp: \"selectedKey\",\n onChangeProp: \"onSelectionChange\",\n variableType: \"text\",\n },\n isOpen: {\n type: \"writable\",\n valueProp: \"isOpen\",\n onChangeProp: \"onOpenChange\",\n variableType: \"boolean\",\n },\n },\n trapsFocus: true,\n });\n}\n"],"names":["makeComponentName","usePlasmicCanvasContext","ComboBoxStateContext","useEffect","useMemo","ListBoxItemIdManager","React","ComboBox","PlasmicPopoverContext","PlasmicListBoxContext","PlasmicInputContext","registerComponentHelper","getCommonProps","LABEL_COMPON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sCAAA;AAAA,gBACN,MAAQ,EAAA;AAAA,kBACN,eAAiB,EAAA,OAAA;AAAA,kBACjB,OAAS,EAAA,MAAA;AAAA,kBACT,QAAU,EAAA,QAAA;AAAA,iBACZ;AAAA,gBACA,KAAO,EAAA;AAAA,kBACL,MAAQ,EAAA,CAAA;AAAA,kBACR,QAAU,EAAA;AAAA,oBACR;AAAA,sBACE,IAAM,EAAA,WAAA;AAAA,sBACN,IAAM,EAAAC,uCAAA;AAAA,sBACN,KAAO,EAAA;AAAA,wBACL,aAAe,EAAA,QAAA;AAAA,uBACjB;AAAA,sBACA,MAAQ,EAAA;AAAA,wBACN,WAAa,EAAA,CAAA;AAAA,wBACb,KAAO,EAAA,SAAA;AAAA,uBACT;AAAA,qBACF;AAAA,mBACF;AAAA,iBACF;AAAA,eACF;AAAA,aACF;AAAA,WACF;AAAA,SACF;AAAA,OACF;AAAA,KACF,CAAA;AAAA,IACA,MAAQ,EAAA;AAAA,MACN,aAAe,EAAA;AAAA,QACb,IAAM,EAAA,UAAA;AAAA,QACN,SAAW,EAAA,aAAA;AAAA,QACX,YAAc,EAAA,mBAAA;AAAA,QACd,YAAc,EAAA,MAAA;AAAA,OAChB;AAAA,MACA,MAAQ,EAAA;AAAA,QACN,IAAM,EAAA,UAAA;AAAA,QACN,SAAW,EAAA,QAAA;AAAA,QACX,YAAc,EAAA,cAAA;AAAA,QACd,YAAc,EAAA,SAAA;AAAA,OAChB;AAAA,KACF;AAAA,IACA,UAAY,EAAA,IAAA;AAAA,GACb,CAAA,CAAA;AACH;;;;;"}
|
|
@@ -3,7 +3,7 @@ import React, { useMemo, useEffect } from 'react';
|
|
|
3
3
|
import { ComboBox, ComboBoxStateContext } from 'react-aria-components';
|
|
4
4
|
import { g as getCommonProps } from './common-0c4336fe.esm.js';
|
|
5
5
|
import { a as PlasmicPopoverContext, b as PlasmicListBoxContext, c as PlasmicInputContext } from './contexts-081d65a0.esm.js';
|
|
6
|
-
import { L as ListBoxItemIdManager, a as LIST_BOX_COMPONENT_NAME } from './registerListBox-
|
|
6
|
+
import { L as ListBoxItemIdManager, a as LIST_BOX_COMPONENT_NAME } from './registerListBox-5d740ec8.esm.js';
|
|
7
7
|
import { BUTTON_COMPONENT_NAME } from './registerButton.esm.js';
|
|
8
8
|
import { INPUT_COMPONENT_NAME } from './registerInput.esm.js';
|
|
9
9
|
import { LABEL_COMPONENT_NAME } from './registerLabel.esm.js';
|
|
@@ -107,17 +107,17 @@ function registerComboBox(loader) {
|
|
|
107
107
|
])), {
|
|
108
108
|
selectedKey: {
|
|
109
109
|
type: "choice",
|
|
110
|
-
description: "The selected keys of the listbox",
|
|
111
110
|
editOnly: true,
|
|
112
111
|
uncontrolledProp: "defaultSelectedKey",
|
|
113
|
-
displayName: "Initial selected
|
|
112
|
+
displayName: "Initial selected item",
|
|
114
113
|
options: (_props, ctx) => (ctx == null ? void 0 : ctx.itemIds) ? Array.from(ctx.itemIds) : [],
|
|
115
|
-
// React Aria ComboBox do not support multiple
|
|
114
|
+
// React Aria ComboBox do not support multiple selections yet
|
|
116
115
|
multiSelect: false
|
|
117
116
|
},
|
|
118
117
|
disabledKeys: {
|
|
119
118
|
type: "choice",
|
|
120
|
-
|
|
119
|
+
displayName: "Disabled values",
|
|
120
|
+
description: "The items that are disabled. These items cannot be selected, focused, or otherwise interacted with.",
|
|
121
121
|
options: (_props, ctx) => (ctx == null ? void 0 : ctx.itemIds) ? Array.from(ctx.itemIds) : [],
|
|
122
122
|
multiSelect: true,
|
|
123
123
|
advanced: true
|
|
@@ -130,7 +130,7 @@ function registerComboBox(loader) {
|
|
|
130
130
|
},
|
|
131
131
|
onSelectionChange: {
|
|
132
132
|
type: "eventHandler",
|
|
133
|
-
argTypes: [{ name: "
|
|
133
|
+
argTypes: [{ name: "selectedValue", type: "string" }]
|
|
134
134
|
},
|
|
135
135
|
onOpenChange: {
|
|
136
136
|
type: "eventHandler",
|
|
@@ -216,7 +216,7 @@ function registerComboBox(loader) {
|
|
|
216
216
|
}
|
|
217
217
|
}),
|
|
218
218
|
states: {
|
|
219
|
-
|
|
219
|
+
selectedValue: {
|
|
220
220
|
type: "writable",
|
|
221
221
|
valueProp: "selectedKey",
|
|
222
222
|
onChangeProp: "onSelectionChange",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registerComboBox.esm.js","sources":["../src/registerComboBox.tsx"],"sourcesContent":["import {\n usePlasmicCanvasComponentInfo,\n usePlasmicCanvasContext,\n} from \"@plasmicapp/host\";\nimport React, { useEffect, useMemo } from \"react\";\nimport {\n ComboBox,\n ComboBoxProps,\n ComboBoxStateContext,\n} from \"react-aria-components\";\nimport { getCommonProps } from \"./common\";\nimport {\n PlasmicInputContext,\n PlasmicListBoxContext,\n PlasmicPopoverContext,\n} from \"./contexts\";\nimport { ListBoxItemIdManager } from \"./ListBoxItemIdManager\";\nimport { BUTTON_COMPONENT_NAME } from \"./registerButton\";\nimport { INPUT_COMPONENT_NAME } from \"./registerInput\";\nimport { LABEL_COMPONENT_NAME } from \"./registerLabel\";\nimport { LIST_BOX_COMPONENT_NAME } from \"./registerListBox\";\nimport { POPOVER_COMPONENT_NAME } from \"./registerPopover\";\nimport {\n HasControlContextData,\n makeComponentName,\n Registerable,\n registerComponentHelper,\n} from \"./utils\";\n\nconst COMBOBOX_NAME = makeComponentName(\"combobox\");\n\nexport interface BaseComboboxControlContextData {\n itemIds: string[];\n}\n\nexport interface BaseComboboxProps\n extends ComboBoxProps<{}>,\n HasControlContextData<BaseComboboxControlContextData> {\n placeholder?: string;\n children?: React.ReactNode;\n isOpen?: boolean;\n}\n\n/**\n * This React Hook is used to help with auto-opening the combobox when the canvas component is selected.\n * Currently, there is a bug in react-aria combobox (https://github.com/adobe/react-spectrum/issues/7149) where, when the combobox's popover is auto-opened, it is unable to render any listbox items.\n * Setting popover's open state to true in not enough unless, unless it has previously been opened via user interaction with combobox.\n * Also, <Combobox> does not support an `isOpen` prop either.\n *\n * So, we use this custom hook to access the combobox's internal state via ComboBoxStateContext and change the `open` state manually via tha available `open` method.\n * */\nfunction ComboboxAutoOpen(props: any) {\n const isEditMode = !!usePlasmicCanvasContext();\n const { isSelected } = usePlasmicCanvasComponentInfo(props) ?? {};\n const { open, close } = React.useContext(ComboBoxStateContext) ?? {};\n\n useEffect(() => {\n if (!isEditMode) {\n return;\n }\n if (isSelected) {\n open?.(undefined, \"manual\");\n } else {\n close?.();\n }\n // Not putting open and close in the useEffect dependencies array, because it causes a re-render loop.\n }, [isSelected, isEditMode]);\n\n return null;\n}\n\nexport function BaseComboBox(props: BaseComboboxProps) {\n const { children, setControlContextData, isOpen, ...rest } = props;\n\n const idManager = useMemo(() => new ListBoxItemIdManager(), []);\n\n useEffect(() => {\n idManager.subscribe((ids: string[]) => {\n setControlContextData?.({\n itemIds: ids,\n });\n });\n }, []);\n\n return (\n <ComboBox {...rest}>\n <PlasmicPopoverContext.Provider\n value={{ isOpen, defaultShouldFlip: false }}\n >\n <PlasmicListBoxContext.Provider\n value={{\n idManager,\n }}\n >\n <PlasmicInputContext.Provider value={{ isUncontrolled: true }}>\n <ComboboxAutoOpen {...props} />\n {children}\n </PlasmicInputContext.Provider>\n </PlasmicListBoxContext.Provider>\n </PlasmicPopoverContext.Provider>\n </ComboBox>\n );\n}\n\nexport function registerComboBox(loader?: Registerable) {\n registerComponentHelper(loader, BaseComboBox, {\n name: COMBOBOX_NAME,\n displayName: \"Aria ComboBox\",\n importPath: \"@plasmicpkgs/react-aria/skinny/registerComboBox\",\n importName: \"BaseComboBox\",\n props: {\n ...getCommonProps<BaseComboboxProps>(\"ComboBox\", [\n \"name\",\n \"aria-label\",\n \"placeholder\",\n \"isDisabled\",\n ]),\n selectedKey: {\n type: \"choice\",\n description: \"The selected keys of the listbox\",\n editOnly: true,\n uncontrolledProp: \"defaultSelectedKey\",\n displayName: \"Initial selected key\",\n options: (_props, ctx) => (ctx?.itemIds ? Array.from(ctx.itemIds) : []),\n // React Aria ComboBox do not support multiple comboBoxions yet\n multiSelect: false,\n },\n disabledKeys: {\n type: \"choice\",\n description:\n \"The item keys that are disabled. These items cannot be selected, focused, or otherwise interacted with.\",\n options: (_props, ctx) => (ctx?.itemIds ? Array.from(ctx.itemIds) : []),\n multiSelect: true,\n advanced: true,\n },\n isOpen: {\n type: \"boolean\",\n defaultValue: false,\n // It doesn't make sense to make isOpen prop editable (it's controlled by user interaction and always closed by default), so we keep this prop hidden. We have listed the prop here in the meta only so we can expose a writeable state for it.\n hidden: () => true,\n },\n onSelectionChange: {\n type: \"eventHandler\",\n argTypes: [{ name: \"selectedKey\", type: \"string\" }],\n },\n onOpenChange: {\n type: \"eventHandler\",\n argTypes: [{ name: \"isOpen\", type: \"boolean\" }],\n },\n\n children: {\n type: \"slot\",\n defaultValue: [\n {\n type: \"vbox\",\n styles: {\n justifyContent: \"flex-start\",\n alignItems: \"flex-start\",\n width: \"300px\",\n padding: 0,\n },\n children: [\n {\n type: \"component\",\n name: LABEL_COMPONENT_NAME,\n props: {\n children: {\n type: \"text\",\n value: \"Label\",\n },\n },\n },\n {\n type: \"hbox\",\n children: [\n {\n type: \"component\",\n name: INPUT_COMPONENT_NAME,\n styles: {\n width: \"100%\",\n },\n },\n {\n type: \"component\",\n name: BUTTON_COMPONENT_NAME,\n props: {\n children: {\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 width: \"15px\",\n transform: \"rotate(180deg)\",\n },\n },\n },\n },\n ],\n },\n {\n type: \"component\",\n name: POPOVER_COMPONENT_NAME,\n styles: {\n backgroundColor: \"white\",\n padding: \"10px\",\n overflow: \"scroll\",\n },\n props: {\n offset: 0,\n children: [\n {\n type: \"component\",\n name: LIST_BOX_COMPONENT_NAME,\n props: {\n selectionMode: \"single\",\n },\n styles: {\n borderWidth: 0,\n width: \"stretch\",\n },\n },\n ],\n },\n },\n ],\n },\n ],\n },\n },\n states: {\n selectedKey: {\n type: \"writable\",\n valueProp: \"selectedKey\",\n onChangeProp: \"onSelectionChange\",\n variableType: \"text\",\n },\n isOpen: {\n type: \"writable\",\n valueProp: \"isOpen\",\n onChangeProp: \"onOpenChange\",\n variableType: \"boolean\",\n },\n },\n trapsFocus: true,\n });\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,MAAM,aAAA,GAAgB,kBAAkB,UAAU,CAAA,CAAA;AAsBlD,SAAS,iBAAiB,KAAY,EAAA;AAnDtC,EAAA,IAAA,EAAA,EAAA,EAAA,CAAA;AAoDE,EAAM,MAAA,UAAA,GAAa,CAAC,CAAC,uBAAwB,EAAA,CAAA;AAC7C,EAAA,MAAM,EAAE,UAAW,EAAA,GAAA,CAAI,mCAA8B,KAAK,CAAA,KAAnC,YAAwC,EAAC,CAAA;AAChE,EAAM,MAAA,EAAE,MAAM,KAAM,EAAA,GAAA,CAAI,WAAM,UAAW,CAAA,oBAAoB,CAArC,KAAA,IAAA,GAAA,EAAA,GAA0C,EAAC,CAAA;AAEnE,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,IAAI,CAAC,UAAY,EAAA;AACf,MAAA,OAAA;AAAA,KACF;AACA,IAAA,IAAI,UAAY,EAAA;AACd,MAAA,IAAA,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,IAAA,CAAO,KAAW,CAAA,EAAA,QAAA,CAAA,CAAA;AAAA,KACb,MAAA;AACL,MAAA,KAAA,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,KAAA,EAAA,CAAA;AAAA,KACF;AAAA,GAEC,EAAA,CAAC,UAAY,EAAA,UAAU,CAAC,CAAA,CAAA;AAE3B,EAAO,OAAA,IAAA,CAAA;AACT,CAAA;AAEO,SAAS,aAAa,KAA0B,EAAA;AACrD,EAA6D,MAAA,EAAA,GAAA,KAAA,EAArD,EAAU,QAAA,EAAA,qBAAA,EAAuB,MAxE3C,EAAA,GAwE+D,IAAT,IAAS,G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,IAAM,EAAA,WAAA;AAAA,gBACN,IAAM,EAAA,sBAAA;AAAA,gBACN,MAAQ,EAAA;AAAA,kBACN,eAAiB,EAAA,OAAA;AAAA,kBACjB,OAAS,EAAA,MAAA;AAAA,kBACT,QAAU,EAAA,QAAA;AAAA,iBACZ;AAAA,gBACA,KAAO,EAAA;AAAA,kBACL,MAAQ,EAAA,CAAA;AAAA,kBACR,QAAU,EAAA;AAAA,oBACR;AAAA,sBACE,IAAM,EAAA,WAAA;AAAA,sBACN,IAAM,EAAA,uBAAA;AAAA,sBACN,KAAO,EAAA;AAAA,wBACL,aAAe,EAAA,QAAA;AAAA,uBACjB;AAAA,sBACA,MAAQ,EAAA;AAAA,wBACN,WAAa,EAAA,CAAA;AAAA,wBACb,KAAO,EAAA,SAAA;AAAA,uBACT;AAAA,qBACF;AAAA,mBACF;AAAA,iBACF;AAAA,eACF;AAAA,aACF;AAAA,WACF;AAAA,SACF;AAAA,OACF;AAAA,KACF,CAAA;AAAA,IACA,MAAQ,EAAA;AAAA,MACN,WAAa,EAAA;AAAA,QACX,IAAM,EAAA,UAAA;AAAA,QACN,SAAW,EAAA,aAAA;AAAA,QACX,YAAc,EAAA,mBAAA;AAAA,QACd,YAAc,EAAA,MAAA;AAAA,OAChB;AAAA,MACA,MAAQ,EAAA;AAAA,QACN,IAAM,EAAA,UAAA;AAAA,QACN,SAAW,EAAA,QAAA;AAAA,QACX,YAAc,EAAA,cAAA;AAAA,QACd,YAAc,EAAA,SAAA;AAAA,OAChB;AAAA,KACF;AAAA,IACA,UAAY,EAAA,IAAA;AAAA,GACb,CAAA,CAAA;AACH;;;;"}
|
|
1
|
+
{"version":3,"file":"registerComboBox.esm.js","sources":["../src/registerComboBox.tsx"],"sourcesContent":["import {\n usePlasmicCanvasComponentInfo,\n usePlasmicCanvasContext,\n} from \"@plasmicapp/host\";\nimport React, { useEffect, useMemo } from \"react\";\nimport {\n ComboBox,\n ComboBoxProps,\n ComboBoxStateContext,\n} from \"react-aria-components\";\nimport { getCommonProps } from \"./common\";\nimport {\n PlasmicInputContext,\n PlasmicListBoxContext,\n PlasmicPopoverContext,\n} from \"./contexts\";\nimport { ListBoxItemIdManager } from \"./ListBoxItemIdManager\";\nimport { BUTTON_COMPONENT_NAME } from \"./registerButton\";\nimport { INPUT_COMPONENT_NAME } from \"./registerInput\";\nimport { LABEL_COMPONENT_NAME } from \"./registerLabel\";\nimport { LIST_BOX_COMPONENT_NAME } from \"./registerListBox\";\nimport { POPOVER_COMPONENT_NAME } from \"./registerPopover\";\nimport {\n HasControlContextData,\n makeComponentName,\n Registerable,\n registerComponentHelper,\n} from \"./utils\";\n\nconst COMBOBOX_NAME = makeComponentName(\"combobox\");\n\nexport interface BaseComboboxControlContextData {\n itemIds: string[];\n}\n\nexport interface BaseComboboxProps\n extends ComboBoxProps<{}>,\n HasControlContextData<BaseComboboxControlContextData> {\n placeholder?: string;\n children?: React.ReactNode;\n isOpen?: boolean;\n}\n\n/**\n * This React Hook is used to help with auto-opening the combobox when the canvas component is selected.\n * Currently, there is a bug in react-aria combobox (https://github.com/adobe/react-spectrum/issues/7149) where, when the combobox's popover is auto-opened, it is unable to render any listbox items.\n * Setting popover's open state to true in not enough unless, unless it has previously been opened via user interaction with combobox.\n * Also, <Combobox> does not support an `isOpen` prop either.\n *\n * So, we use this custom hook to access the combobox's internal state via ComboBoxStateContext and change the `open` state manually via tha available `open` method.\n * */\nfunction ComboboxAutoOpen(props: any) {\n const isEditMode = !!usePlasmicCanvasContext();\n const { isSelected } = usePlasmicCanvasComponentInfo(props) ?? {};\n const { open, close } = React.useContext(ComboBoxStateContext) ?? {};\n\n useEffect(() => {\n if (!isEditMode) {\n return;\n }\n if (isSelected) {\n open?.(undefined, \"manual\");\n } else {\n close?.();\n }\n // Not putting open and close in the useEffect dependencies array, because it causes a re-render loop.\n }, [isSelected, isEditMode]);\n\n return null;\n}\n\nexport function BaseComboBox(props: BaseComboboxProps) {\n const { children, setControlContextData, isOpen, ...rest } = props;\n\n const idManager = useMemo(() => new ListBoxItemIdManager(), []);\n\n useEffect(() => {\n idManager.subscribe((ids: string[]) => {\n setControlContextData?.({\n itemIds: ids,\n });\n });\n }, []);\n\n return (\n <ComboBox {...rest}>\n <PlasmicPopoverContext.Provider\n value={{ isOpen, defaultShouldFlip: false }}\n >\n <PlasmicListBoxContext.Provider\n value={{\n idManager,\n }}\n >\n <PlasmicInputContext.Provider value={{ isUncontrolled: true }}>\n <ComboboxAutoOpen {...props} />\n {children}\n </PlasmicInputContext.Provider>\n </PlasmicListBoxContext.Provider>\n </PlasmicPopoverContext.Provider>\n </ComboBox>\n );\n}\n\nexport function registerComboBox(loader?: Registerable) {\n registerComponentHelper(loader, BaseComboBox, {\n name: COMBOBOX_NAME,\n displayName: \"Aria ComboBox\",\n importPath: \"@plasmicpkgs/react-aria/skinny/registerComboBox\",\n importName: \"BaseComboBox\",\n props: {\n ...getCommonProps<BaseComboboxProps>(\"ComboBox\", [\n \"name\",\n \"aria-label\",\n \"placeholder\",\n \"isDisabled\",\n ]),\n selectedKey: {\n type: \"choice\",\n editOnly: true,\n uncontrolledProp: \"defaultSelectedKey\",\n displayName: \"Initial selected item\",\n options: (_props, ctx) => (ctx?.itemIds ? Array.from(ctx.itemIds) : []),\n // React Aria ComboBox do not support multiple selections yet\n multiSelect: false,\n },\n disabledKeys: {\n type: \"choice\",\n displayName: \"Disabled values\",\n description:\n \"The items that are disabled. These items cannot be selected, focused, or otherwise interacted with.\",\n options: (_props, ctx) => (ctx?.itemIds ? Array.from(ctx.itemIds) : []),\n multiSelect: true,\n advanced: true,\n },\n isOpen: {\n type: \"boolean\",\n defaultValue: false,\n // It doesn't make sense to make isOpen prop editable (it's controlled by user interaction and always closed by default), so we keep this prop hidden. We have listed the prop here in the meta only so we can expose a writeable state for it.\n hidden: () => true,\n },\n onSelectionChange: {\n type: \"eventHandler\",\n argTypes: [{ name: \"selectedValue\", type: \"string\" }],\n },\n onOpenChange: {\n type: \"eventHandler\",\n argTypes: [{ name: \"isOpen\", type: \"boolean\" }],\n },\n\n children: {\n type: \"slot\",\n defaultValue: [\n {\n type: \"vbox\",\n styles: {\n justifyContent: \"flex-start\",\n alignItems: \"flex-start\",\n width: \"300px\",\n padding: 0,\n },\n children: [\n {\n type: \"component\",\n name: LABEL_COMPONENT_NAME,\n props: {\n children: {\n type: \"text\",\n value: \"Label\",\n },\n },\n },\n {\n type: \"hbox\",\n children: [\n {\n type: \"component\",\n name: INPUT_COMPONENT_NAME,\n styles: {\n width: \"100%\",\n },\n },\n {\n type: \"component\",\n name: BUTTON_COMPONENT_NAME,\n props: {\n children: {\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 width: \"15px\",\n transform: \"rotate(180deg)\",\n },\n },\n },\n },\n ],\n },\n {\n type: \"component\",\n name: POPOVER_COMPONENT_NAME,\n styles: {\n backgroundColor: \"white\",\n padding: \"10px\",\n overflow: \"scroll\",\n },\n props: {\n offset: 0,\n children: [\n {\n type: \"component\",\n name: LIST_BOX_COMPONENT_NAME,\n props: {\n selectionMode: \"single\",\n },\n styles: {\n borderWidth: 0,\n width: \"stretch\",\n },\n },\n ],\n },\n },\n ],\n },\n ],\n },\n },\n states: {\n selectedValue: {\n type: \"writable\",\n valueProp: \"selectedKey\",\n onChangeProp: \"onSelectionChange\",\n variableType: \"text\",\n },\n isOpen: {\n type: \"writable\",\n valueProp: \"isOpen\",\n onChangeProp: \"onOpenChange\",\n variableType: \"boolean\",\n },\n },\n trapsFocus: true,\n });\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,MAAM,aAAA,GAAgB,kBAAkB,UAAU,CAAA,CAAA;AAsBlD,SAAS,iBAAiB,KAAY,EAAA;AAnDtC,EAAA,IAAA,EAAA,EAAA,EAAA,CAAA;AAoDE,EAAM,MAAA,UAAA,GAAa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AAA,sBACA,MAAQ,EAAA;AAAA,wBACN,WAAa,EAAA,CAAA;AAAA,wBACb,KAAO,EAAA,SAAA;AAAA,uBACT;AAAA,qBACF;AAAA,mBACF;AAAA,iBACF;AAAA,eACF;AAAA,aACF;AAAA,WACF;AAAA,SACF;AAAA,OACF;AAAA,KACF,CAAA;AAAA,IACA,MAAQ,EAAA;AAAA,MACN,aAAe,EAAA;AAAA,QACb,IAAM,EAAA,UAAA;AAAA,QACN,SAAW,EAAA,aAAA;AAAA,QACX,YAAc,EAAA,mBAAA;AAAA,QACd,YAAc,EAAA,MAAA;AAAA,OAChB;AAAA,MACA,MAAQ,EAAA;AAAA,QACN,IAAM,EAAA,UAAA;AAAA,QACN,SAAW,EAAA,QAAA;AAAA,QACX,YAAc,EAAA,cAAA;AAAA,QACd,YAAc,EAAA,SAAA;AAAA,OAChB;AAAA,KACF;AAAA,IACA,UAAY,EAAA,IAAA;AAAA,GACb,CAAA,CAAA;AACH;;;;"}
|
|
@@ -93,7 +93,7 @@ var __objRest = (source, exclude) => {
|
|
|
93
93
|
};
|
|
94
94
|
const listboxHelpers = {
|
|
95
95
|
states: {
|
|
96
|
-
|
|
96
|
+
selectedValue: {
|
|
97
97
|
onChangeArgsToValue: (value) => {
|
|
98
98
|
return Array.from(value)[0];
|
|
99
99
|
}
|
|
@@ -292,10 +292,9 @@ function registerListBox(loader, overrides) {
|
|
|
292
292
|
},
|
|
293
293
|
selectedKeys: {
|
|
294
294
|
type: "choice",
|
|
295
|
-
description: "The selected keys of the listbox",
|
|
296
295
|
editOnly: true,
|
|
297
296
|
uncontrolledProp: "defaultSelectedKeys",
|
|
298
|
-
displayName: "Initial selected
|
|
297
|
+
displayName: "Initial selected item",
|
|
299
298
|
options: (_props, ctx) => (ctx == null ? void 0 : ctx.itemIds) ? Array.from(ctx.itemIds) : [],
|
|
300
299
|
hidden: (props, ctx) => !(ctx == null ? void 0 : ctx.isStandalone) || props.selectionMode === "none",
|
|
301
300
|
// We do not support multiple selections yet (Because React Aria select and combobox only support single selections).
|
|
@@ -303,16 +302,17 @@ function registerListBox(loader, overrides) {
|
|
|
303
302
|
},
|
|
304
303
|
onSelectionChange: {
|
|
305
304
|
type: "eventHandler",
|
|
306
|
-
argTypes: [{ name: "
|
|
305
|
+
argTypes: [{ name: "selectedValues", type: "object" }]
|
|
307
306
|
}
|
|
308
307
|
},
|
|
309
308
|
states: {
|
|
310
|
-
|
|
309
|
+
selectedValue: __spreadValues({
|
|
311
310
|
type: "writable",
|
|
312
311
|
valueProp: "selectedKeys",
|
|
312
|
+
hidden: (props, ctx) => !(ctx == null ? void 0 : ctx.isStandalone) || props.selectionMode === "none",
|
|
313
313
|
onChangeProp: "onSelectionChange",
|
|
314
314
|
variableType: "text"
|
|
315
|
-
}, listboxHelpers.states.
|
|
315
|
+
}, listboxHelpers.states.selectedValue)
|
|
316
316
|
},
|
|
317
317
|
componentHelpers: {
|
|
318
318
|
helpers: listboxHelpers,
|
|
@@ -330,4 +330,4 @@ exports.LIST_BOX_COMPONENT_NAME = LIST_BOX_COMPONENT_NAME;
|
|
|
330
330
|
exports.ListBoxItemIdManager = ListBoxItemIdManager;
|
|
331
331
|
exports.listboxHelpers = listboxHelpers;
|
|
332
332
|
exports.registerListBox = registerListBox;
|
|
333
|
-
//# sourceMappingURL=registerListBox-
|
|
333
|
+
//# sourceMappingURL=registerListBox-44b5ecda.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registerListBox-44b5ecda.cjs.js","sources":["../src/ListBoxItemIdManager.ts","../src/registerListBox.tsx"],"sourcesContent":["type Observer = (ids: string[]) => void;\n\nexport class ListBoxItemIdManager {\n private readonly _ids: Set<string> = new Set();\n private readonly _observers: Set<Observer> = new Set();\n\n private generateDuplicateId(id: string, count = 1): string {\n const dupId = `${id} duplicate(${count})`;\n if (this._ids.has(dupId)) {\n return this.generateDuplicateId(id, count + 1);\n } else {\n return dupId;\n }\n }\n\n private generateMissingId(count = 1): string {\n const missingId = `missing(${count})`;\n if (this._ids.has(missingId)) {\n return this.generateMissingId(count + 1);\n } else {\n return missingId;\n }\n }\n\n register(id?: unknown): string {\n const idStr = id === undefined ? undefined : String(id).trim();\n let newId: string;\n\n if (!idStr) {\n // No id is provided, so generate one\n newId = this.generateMissingId();\n } else if (this._ids.has(idStr)) {\n // The provided id is already registered with another uuid (i.e. it's not unique), so just generate a new one\n newId = this.generateDuplicateId(idStr);\n } else {\n // The provided id is not already registered, so use it\n newId = idStr;\n }\n\n this._ids.add(newId);\n this.notify();\n return newId;\n }\n\n unregister(id: string) {\n this._ids.delete(id);\n this.notify();\n }\n\n subscribe(observer: Observer) {\n this._observers.add(observer);\n observer(this.ids);\n }\n\n // Notify all observers about an event.\n notify() {\n this._observers.forEach((observer) => observer(this.ids));\n }\n\n get ids(): string[] {\n return Array.from(this._ids);\n }\n}\n","import React, { useEffect, useMemo, useState } from \"react\";\nimport { Key, ListBox } from \"react-aria-components\";\nimport { PlasmicListBoxContext } from \"./contexts\";\nimport { ListBoxItemIdManager } from \"./ListBoxItemIdManager\";\nimport {\n makeDefaultListBoxItemChildren,\n registerListBoxItem,\n} from \"./registerListBoxItem\";\nimport { registerSection } from \"./registerSection\";\nimport {\n CodeComponentMetaOverrides,\n HasControlContextData,\n makeComponentName,\n Registerable,\n registerComponentHelper,\n} from \"./utils\";\n\nexport interface BaseListBoxControlContextData {\n itemIds: string[];\n isStandalone: boolean;\n}\n\nexport interface BaseListBoxProps\n extends Omit<\n React.ComponentProps<typeof ListBox>,\n \"selectedKeys\" | \"defaultSelectedKeys\"\n >,\n HasControlContextData<BaseListBoxControlContextData> {\n children?: React.ReactNode;\n selectedKeys?: string | string[] | undefined;\n defaultSelectedKeys?: string | string[] | undefined;\n}\n\nexport const listboxHelpers = {\n states: {\n selectedValue: {\n onChangeArgsToValue: (value: Set<Key> | string[] | string) => {\n // only single selection is supported\n return Array.from(value)[0];\n },\n },\n },\n};\n\nfunction normalizeSelectedKeys(selectedKeys: string | string[] | undefined) {\n // Listbox expects it to be of type \"all\" | Iterable\n return typeof selectedKeys === \"string\" && selectedKeys !== \"all\"\n ? [selectedKeys]\n : selectedKeys;\n}\n\nexport function BaseListBox(props: BaseListBoxProps) {\n const {\n setControlContextData: setControlContextData,\n children,\n selectedKeys,\n defaultSelectedKeys,\n ...rest\n } = props;\n const context = React.useContext(PlasmicListBoxContext);\n const isStandalone = !context;\n const [ids, setIds] = useState<string[]>([]);\n\n const idManager = useMemo(\n () => context?.idManager ?? new ListBoxItemIdManager(),\n []\n );\n\n useEffect(() => {\n setControlContextData?.({\n itemIds: ids,\n isStandalone,\n });\n }, [ids, isStandalone, setControlContextData]);\n\n useEffect(() => {\n idManager.subscribe((_ids: string[]) => {\n setIds(_ids);\n });\n }, []);\n\n const listbox = (\n <ListBox\n selectedKeys={normalizeSelectedKeys(selectedKeys)}\n defaultSelectedKeys={normalizeSelectedKeys(defaultSelectedKeys)}\n {...rest}\n >\n {children}\n </ListBox>\n );\n\n if (isStandalone) {\n return (\n <PlasmicListBoxContext.Provider\n value={{\n idManager,\n }}\n >\n {listbox}\n </PlasmicListBoxContext.Provider>\n );\n }\n\n return listbox;\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 props: {\n items: {\n type: \"slot\",\n defaultValue: [\n {\n type: \"component\",\n name: listBoxItemMeta.name,\n props: {\n id: \"section-1-1\",\n textValue: \"Section1-Item 1\",\n children: [\n makeDefaultListBoxItemChildren(\n \"Item 1\",\n \"Add dynamic values to make it more interesting\"\n ),\n ],\n },\n },\n {\n type: \"component\",\n name: listBoxItemMeta.name,\n props: {\n id: \"section-1-2\",\n textValue: \"Section1-Item 2\",\n children: [\n makeDefaultListBoxItemChildren(\n \"Item 2\",\n \"Add dynamic values to make it more interesting\"\n ),\n ],\n },\n },\n {\n type: \"component\",\n name: listBoxItemMeta.name,\n props: {\n id: \"section-1-3\",\n textValue: \"Section1-Item 3\",\n children: [\n makeDefaultListBoxItemChildren(\n \"Item 3\",\n \"Add dynamic values to make it more interesting\"\n ),\n ],\n },\n },\n ],\n },\n },\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 children: {\n type: \"slot\",\n displayName: \"List Items\",\n allowedComponents: [listBoxItemMeta.name, sectionMeta.name],\n allowRootWrapper: true,\n defaultValue: [\n {\n type: \"component\",\n name: listBoxItemMeta.name,\n props: {\n id: \"1\",\n textValue: \"Item 1\",\n children: [\n makeDefaultListBoxItemChildren(\n \"Item 1\",\n \"Add dynamic values to make it more interesting\"\n ),\n ],\n },\n },\n {\n type: \"component\",\n name: listBoxItemMeta.name,\n props: {\n id: \"2\",\n textValue: \"Item 2\",\n children: [\n makeDefaultListBoxItemChildren(\n \"Item 2\",\n \"Add dynamic values to make it more interesting\"\n ),\n ],\n },\n },\n {\n type: \"component\",\n name: listBoxItemMeta.name,\n props: {\n id: \"3\",\n textValue: \"Item 3\",\n children: [\n makeDefaultListBoxItemChildren(\n \"Item 3\",\n \"Add dynamic values to make it more interesting\"\n ),\n ],\n },\n },\n {\n type: \"component\",\n name: sectionMeta.name,\n },\n ],\n },\n selectionMode: {\n type: \"choice\",\n description: \"The selection mode of the listbox\",\n options: [\"none\", \"single\"],\n defaultValue: \"none\",\n hidden: (_props, ctx) => !ctx?.isStandalone,\n },\n selectedKeys: {\n type: \"choice\",\n editOnly: true,\n uncontrolledProp: \"defaultSelectedKeys\",\n displayName: \"Initial selected item\",\n options: (_props, ctx) =>\n ctx?.itemIds ? Array.from(ctx.itemIds) : [],\n hidden: (props, ctx) =>\n !ctx?.isStandalone || props.selectionMode === \"none\",\n // We do not support multiple selections yet (Because React Aria select and combobox only support single selections).\n multiSelect: false,\n },\n onSelectionChange: {\n type: \"eventHandler\",\n argTypes: [{ name: \"selectedValues\", type: \"object\" }],\n },\n },\n states: {\n selectedValue: {\n type: \"writable\",\n valueProp: \"selectedKeys\",\n hidden: (props, ctx) =>\n !ctx?.isStandalone || props.selectionMode === \"none\",\n onChangeProp: \"onSelectionChange\",\n variableType: \"text\",\n ...listboxHelpers.states.selectedValue,\n },\n },\n componentHelpers: {\n helpers: listboxHelpers,\n importName: \"listboxHelpers\",\n importPath: \"@plasmicpkgs/react-aria/skinny/registerListBox\",\n },\n trapsFocus: true,\n },\n overrides\n );\n}\n"],"names":["React","PlasmicListBoxContext","useState","useMemo","_a","useEffect","ListBox","makeComponentName","registerListBoxItem","registerSection","makeDefaultListBoxItemChildren","registerComponentHelper"],"mappings":";;;;;;;;;;;;;AAEO,MAAM,oBAAqB,CAAA;AAAA,EAA3B,WAAA,GAAA;AACL,IAAiB,IAAA,CAAA,IAAA,uBAAwB,GAAI,EAAA,CAAA;AAC7C,IAAiB,IAAA,CAAA,UAAA,uBAAgC,GAAI,EAAA,CAAA;AAAA,GAAA;AAAA,EAE7C,mBAAA,CAAoB,EAAY,EAAA,KAAA,GAAQ,CAAW,EAAA;AACzD,IAAM,MAAA,KAAA,GAAQ,GAAG,EAAgB,CAAA,WAAA,EAAA,KAAA,CAAA,CAAA,CAAA,CAAA;AACjC,IAAA,IAAI,IAAK,CAAA,IAAA,CAAK,GAAI,CAAA,KAAK,CAAG,EAAA;AACxB,MAAA,OAAO,IAAK,CAAA,mBAAA,CAAoB,EAAI,EAAA,KAAA,GAAQ,CAAC,CAAA,CAAA;AAAA,KACxC,MAAA;AACL,MAAO,OAAA,KAAA,CAAA;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,KAAA;AAAA,SACf;AAAA,QACA,iBAAmB,EAAA;AAAA,UACjB,IAAM,EAAA,cAAA;AAAA,UACN,UAAU,CAAC,EAAE,MAAM,gBAAkB,EAAA,IAAA,EAAM,UAAU,CAAA;AAAA,SACvD;AAAA,OACF;AAAA,MACA,MAAQ,EAAA;AAAA,QACN,aAAe,EAAA,cAAA,CAAA;AAAA,UACb,IAAM,EAAA,UAAA;AAAA,UACN,SAAW,EAAA,cAAA;AAAA,UACX,MAAA,EAAQ,CAAC,KAAO,EAAA,GAAA,KACd,EAAC,GAAK,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,GAAA,CAAA,YAAA,CAAA,IAAgB,MAAM,aAAkB,KAAA,MAAA;AAAA,UAChD,YAAc,EAAA,mBAAA;AAAA,UACd,YAAc,EAAA,MAAA;AAAA,SAAA,EACX,eAAe,MAAO,CAAA,aAAA,CAAA;AAAA,OAE7B;AAAA,MACA,gBAAkB,EAAA;AAAA,QAChB,OAAS,EAAA,cAAA;AAAA,QACT,UAAY,EAAA,gBAAA;AAAA,QACZ,UAAY,EAAA,gDAAA;AAAA,OACd;AAAA,MACA,UAAY,EAAA,IAAA;AAAA,KACd;AAAA,IACA,SAAA;AAAA,GACF,CAAA;AACF;;;;;;;;"}
|
|
@@ -87,7 +87,7 @@ var __objRest = (source, exclude) => {
|
|
|
87
87
|
};
|
|
88
88
|
const listboxHelpers = {
|
|
89
89
|
states: {
|
|
90
|
-
|
|
90
|
+
selectedValue: {
|
|
91
91
|
onChangeArgsToValue: (value) => {
|
|
92
92
|
return Array.from(value)[0];
|
|
93
93
|
}
|
|
@@ -286,10 +286,9 @@ function registerListBox(loader, overrides) {
|
|
|
286
286
|
},
|
|
287
287
|
selectedKeys: {
|
|
288
288
|
type: "choice",
|
|
289
|
-
description: "The selected keys of the listbox",
|
|
290
289
|
editOnly: true,
|
|
291
290
|
uncontrolledProp: "defaultSelectedKeys",
|
|
292
|
-
displayName: "Initial selected
|
|
291
|
+
displayName: "Initial selected item",
|
|
293
292
|
options: (_props, ctx) => (ctx == null ? void 0 : ctx.itemIds) ? Array.from(ctx.itemIds) : [],
|
|
294
293
|
hidden: (props, ctx) => !(ctx == null ? void 0 : ctx.isStandalone) || props.selectionMode === "none",
|
|
295
294
|
// We do not support multiple selections yet (Because React Aria select and combobox only support single selections).
|
|
@@ -297,16 +296,17 @@ function registerListBox(loader, overrides) {
|
|
|
297
296
|
},
|
|
298
297
|
onSelectionChange: {
|
|
299
298
|
type: "eventHandler",
|
|
300
|
-
argTypes: [{ name: "
|
|
299
|
+
argTypes: [{ name: "selectedValues", type: "object" }]
|
|
301
300
|
}
|
|
302
301
|
},
|
|
303
302
|
states: {
|
|
304
|
-
|
|
303
|
+
selectedValue: __spreadValues({
|
|
305
304
|
type: "writable",
|
|
306
305
|
valueProp: "selectedKeys",
|
|
306
|
+
hidden: (props, ctx) => !(ctx == null ? void 0 : ctx.isStandalone) || props.selectionMode === "none",
|
|
307
307
|
onChangeProp: "onSelectionChange",
|
|
308
308
|
variableType: "text"
|
|
309
|
-
}, listboxHelpers.states.
|
|
309
|
+
}, listboxHelpers.states.selectedValue)
|
|
310
310
|
},
|
|
311
311
|
componentHelpers: {
|
|
312
312
|
helpers: listboxHelpers,
|
|
@@ -320,4 +320,4 @@ function registerListBox(loader, overrides) {
|
|
|
320
320
|
}
|
|
321
321
|
|
|
322
322
|
export { BaseListBox as B, ListBoxItemIdManager as L, LIST_BOX_COMPONENT_NAME as a, listboxHelpers as l, registerListBox as r };
|
|
323
|
-
//# sourceMappingURL=registerListBox-
|
|
323
|
+
//# sourceMappingURL=registerListBox-5d740ec8.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registerListBox-5d740ec8.esm.js","sources":["../src/ListBoxItemIdManager.ts","../src/registerListBox.tsx"],"sourcesContent":["type Observer = (ids: string[]) => void;\n\nexport class ListBoxItemIdManager {\n private readonly _ids: Set<string> = new Set();\n private readonly _observers: Set<Observer> = new Set();\n\n private generateDuplicateId(id: string, count = 1): string {\n const dupId = `${id} duplicate(${count})`;\n if (this._ids.has(dupId)) {\n return this.generateDuplicateId(id, count + 1);\n } else {\n return dupId;\n }\n }\n\n private generateMissingId(count = 1): string {\n const missingId = `missing(${count})`;\n if (this._ids.has(missingId)) {\n return this.generateMissingId(count + 1);\n } else {\n return missingId;\n }\n }\n\n register(id?: unknown): string {\n const idStr = id === undefined ? undefined : String(id).trim();\n let newId: string;\n\n if (!idStr) {\n // No id is provided, so generate one\n newId = this.generateMissingId();\n } else if (this._ids.has(idStr)) {\n // The provided id is already registered with another uuid (i.e. it's not unique), so just generate a new one\n newId = this.generateDuplicateId(idStr);\n } else {\n // The provided id is not already registered, so use it\n newId = idStr;\n }\n\n this._ids.add(newId);\n this.notify();\n return newId;\n }\n\n unregister(id: string) {\n this._ids.delete(id);\n this.notify();\n }\n\n subscribe(observer: Observer) {\n this._observers.add(observer);\n observer(this.ids);\n }\n\n // Notify all observers about an event.\n notify() {\n this._observers.forEach((observer) => observer(this.ids));\n }\n\n get ids(): string[] {\n return Array.from(this._ids);\n }\n}\n","import React, { useEffect, useMemo, useState } from \"react\";\nimport { Key, ListBox } from \"react-aria-components\";\nimport { PlasmicListBoxContext } from \"./contexts\";\nimport { ListBoxItemIdManager } from \"./ListBoxItemIdManager\";\nimport {\n makeDefaultListBoxItemChildren,\n registerListBoxItem,\n} from \"./registerListBoxItem\";\nimport { registerSection } from \"./registerSection\";\nimport {\n CodeComponentMetaOverrides,\n HasControlContextData,\n makeComponentName,\n Registerable,\n registerComponentHelper,\n} from \"./utils\";\n\nexport interface BaseListBoxControlContextData {\n itemIds: string[];\n isStandalone: boolean;\n}\n\nexport interface BaseListBoxProps\n extends Omit<\n React.ComponentProps<typeof ListBox>,\n \"selectedKeys\" | \"defaultSelectedKeys\"\n >,\n HasControlContextData<BaseListBoxControlContextData> {\n children?: React.ReactNode;\n selectedKeys?: string | string[] | undefined;\n defaultSelectedKeys?: string | string[] | undefined;\n}\n\nexport const listboxHelpers = {\n states: {\n selectedValue: {\n onChangeArgsToValue: (value: Set<Key> | string[] | string) => {\n // only single selection is supported\n return Array.from(value)[0];\n },\n },\n },\n};\n\nfunction normalizeSelectedKeys(selectedKeys: string | string[] | undefined) {\n // Listbox expects it to be of type \"all\" | Iterable\n return typeof selectedKeys === \"string\" && selectedKeys !== \"all\"\n ? [selectedKeys]\n : selectedKeys;\n}\n\nexport function BaseListBox(props: BaseListBoxProps) {\n const {\n setControlContextData: setControlContextData,\n children,\n selectedKeys,\n defaultSelectedKeys,\n ...rest\n } = props;\n const context = React.useContext(PlasmicListBoxContext);\n const isStandalone = !context;\n const [ids, setIds] = useState<string[]>([]);\n\n const idManager = useMemo(\n () => context?.idManager ?? new ListBoxItemIdManager(),\n []\n );\n\n useEffect(() => {\n setControlContextData?.({\n itemIds: ids,\n isStandalone,\n });\n }, [ids, isStandalone, setControlContextData]);\n\n useEffect(() => {\n idManager.subscribe((_ids: string[]) => {\n setIds(_ids);\n });\n }, []);\n\n const listbox = (\n <ListBox\n selectedKeys={normalizeSelectedKeys(selectedKeys)}\n defaultSelectedKeys={normalizeSelectedKeys(defaultSelectedKeys)}\n {...rest}\n >\n {children}\n </ListBox>\n );\n\n if (isStandalone) {\n return (\n <PlasmicListBoxContext.Provider\n value={{\n idManager,\n }}\n >\n {listbox}\n </PlasmicListBoxContext.Provider>\n );\n }\n\n return listbox;\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 props: {\n items: {\n type: \"slot\",\n defaultValue: [\n {\n type: \"component\",\n name: listBoxItemMeta.name,\n props: {\n id: \"section-1-1\",\n textValue: \"Section1-Item 1\",\n children: [\n makeDefaultListBoxItemChildren(\n \"Item 1\",\n \"Add dynamic values to make it more interesting\"\n ),\n ],\n },\n },\n {\n type: \"component\",\n name: listBoxItemMeta.name,\n props: {\n id: \"section-1-2\",\n textValue: \"Section1-Item 2\",\n children: [\n makeDefaultListBoxItemChildren(\n \"Item 2\",\n \"Add dynamic values to make it more interesting\"\n ),\n ],\n },\n },\n {\n type: \"component\",\n name: listBoxItemMeta.name,\n props: {\n id: \"section-1-3\",\n textValue: \"Section1-Item 3\",\n children: [\n makeDefaultListBoxItemChildren(\n \"Item 3\",\n \"Add dynamic values to make it more interesting\"\n ),\n ],\n },\n },\n ],\n },\n },\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 children: {\n type: \"slot\",\n displayName: \"List Items\",\n allowedComponents: [listBoxItemMeta.name, sectionMeta.name],\n allowRootWrapper: true,\n defaultValue: [\n {\n type: \"component\",\n name: listBoxItemMeta.name,\n props: {\n id: \"1\",\n textValue: \"Item 1\",\n children: [\n makeDefaultListBoxItemChildren(\n \"Item 1\",\n \"Add dynamic values to make it more interesting\"\n ),\n ],\n },\n },\n {\n type: \"component\",\n name: listBoxItemMeta.name,\n props: {\n id: \"2\",\n textValue: \"Item 2\",\n children: [\n makeDefaultListBoxItemChildren(\n \"Item 2\",\n \"Add dynamic values to make it more interesting\"\n ),\n ],\n },\n },\n {\n type: \"component\",\n name: listBoxItemMeta.name,\n props: {\n id: \"3\",\n textValue: \"Item 3\",\n children: [\n makeDefaultListBoxItemChildren(\n \"Item 3\",\n \"Add dynamic values to make it more interesting\"\n ),\n ],\n },\n },\n {\n type: \"component\",\n name: sectionMeta.name,\n },\n ],\n },\n selectionMode: {\n type: \"choice\",\n description: \"The selection mode of the listbox\",\n options: [\"none\", \"single\"],\n defaultValue: \"none\",\n hidden: (_props, ctx) => !ctx?.isStandalone,\n },\n selectedKeys: {\n type: \"choice\",\n editOnly: true,\n uncontrolledProp: \"defaultSelectedKeys\",\n displayName: \"Initial selected item\",\n options: (_props, ctx) =>\n ctx?.itemIds ? Array.from(ctx.itemIds) : [],\n hidden: (props, ctx) =>\n !ctx?.isStandalone || props.selectionMode === \"none\",\n // We do not support multiple selections yet (Because React Aria select and combobox only support single selections).\n multiSelect: false,\n },\n onSelectionChange: {\n type: \"eventHandler\",\n argTypes: [{ name: \"selectedValues\", type: \"object\" }],\n },\n },\n states: {\n selectedValue: {\n type: \"writable\",\n valueProp: \"selectedKeys\",\n hidden: (props, ctx) =>\n !ctx?.isStandalone || props.selectionMode === \"none\",\n onChangeProp: \"onSelectionChange\",\n variableType: \"text\",\n ...listboxHelpers.states.selectedValue,\n },\n },\n componentHelpers: {\n helpers: listboxHelpers,\n importName: \"listboxHelpers\",\n importPath: \"@plasmicpkgs/react-aria/skinny/registerListBox\",\n },\n trapsFocus: true,\n },\n overrides\n );\n}\n"],"names":["_a"],"mappings":";;;;;;;AAEO,MAAM,oBAAqB,CAAA;AAAA,EAA3B,WAAA,GAAA;AACL,IAAiB,IAAA,CAAA,IAAA,uBAAwB,GAAI,EAAA,CAAA;AAC7C,IAAiB,IAAA,CAAA,UAAA,uBAAgC,GAAI,EAAA,CAAA;AAAA,GAAA;AAAA,EAE7C,mBAAA,CAAoB,EAAY,EAAA,KAAA,GAAQ,CAAW,EAAA;AACzD,IAAM,MAAA,KAAA,GAAQ,GAAG,EAAgB,CAAA,WAAA,EAAA,KAAA,CAAA,CAAA,CAAA,CAAA;AACjC,IAAA,IAAI,IAAK,CAAA,IAAA,CAAK,GAAI,CAAA,KAAK,CAAG,EAAA;AACxB,MAAA,OAAO,IAAK,CAAA,mBAAA,CAAoB,EAAI,EAAA,KAAA,GAAQ,CAAC,CAAA,CAAA;A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,UAEhD,WAAa,EAAA,KAAA;AAAA,SACf;AAAA,QACA,iBAAmB,EAAA;AAAA,UACjB,IAAM,EAAA,cAAA;AAAA,UACN,UAAU,CAAC,EAAE,MAAM,gBAAkB,EAAA,IAAA,EAAM,UAAU,CAAA;AAAA,SACvD;AAAA,OACF;AAAA,MACA,MAAQ,EAAA;AAAA,QACN,aAAe,EAAA,cAAA,CAAA;AAAA,UACb,IAAM,EAAA,UAAA;AAAA,UACN,SAAW,EAAA,cAAA;AAAA,UACX,MAAA,EAAQ,CAAC,KAAO,EAAA,GAAA,KACd,EAAC,GAAK,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,GAAA,CAAA,YAAA,CAAA,IAAgB,MAAM,aAAkB,KAAA,MAAA;AAAA,UAChD,YAAc,EAAA,mBAAA;AAAA,UACd,YAAc,EAAA,MAAA;AAAA,SAAA,EACX,eAAe,MAAO,CAAA,aAAA,CAAA;AAAA,OAE7B;AAAA,MACA,gBAAkB,EAAA;AAAA,QAChB,OAAS,EAAA,cAAA;AAAA,QACT,UAAY,EAAA,gBAAA;AAAA,QACZ,UAAY,EAAA,gDAAA;AAAA,OACd;AAAA,MACA,UAAY,EAAA,IAAA;AAAA,KACd;AAAA,IACA,SAAA;AAAA,GACF,CAAA;AACF;;;;"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
require('react');
|
|
4
4
|
require('react-aria-components');
|
|
5
5
|
require('./contexts-baa37b74.cjs.js');
|
|
6
|
-
var registerListBox = require('./registerListBox-
|
|
6
|
+
var registerListBox = require('./registerListBox-44b5ecda.cjs.js');
|
|
7
7
|
require('./registerListBoxItem.cjs.js');
|
|
8
8
|
require('./registerSection.cjs.js');
|
|
9
9
|
require('./utils-8dbb4d1f.cjs.js');
|
|
@@ -12,7 +12,7 @@ export interface BaseListBoxProps extends Omit<React.ComponentProps<typeof ListB
|
|
|
12
12
|
}
|
|
13
13
|
export declare const listboxHelpers: {
|
|
14
14
|
states: {
|
|
15
|
-
|
|
15
|
+
selectedValue: {
|
|
16
16
|
onChangeArgsToValue: (value: Set<Key> | string[] | string) => Key;
|
|
17
17
|
};
|
|
18
18
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import 'react';
|
|
2
2
|
import 'react-aria-components';
|
|
3
3
|
import './contexts-081d65a0.esm.js';
|
|
4
|
-
export { B as BaseListBox, a as LIST_BOX_COMPONENT_NAME, l as listboxHelpers, r as registerListBox } from './registerListBox-
|
|
4
|
+
export { B as BaseListBox, a as LIST_BOX_COMPONENT_NAME, l as listboxHelpers, r as registerListBox } from './registerListBox-5d740ec8.esm.js';
|
|
5
5
|
import './registerListBoxItem.esm.js';
|
|
6
6
|
import './registerSection.esm.js';
|
|
7
7
|
import './utils-c7662a47.esm.js';
|
|
@@ -159,7 +159,7 @@ function registerListBoxItem(loader, overrides) {
|
|
|
159
159
|
props: {
|
|
160
160
|
id: {
|
|
161
161
|
type: "string",
|
|
162
|
-
description: "A unique
|
|
162
|
+
description: "A unique value for tracking the selected item in state",
|
|
163
163
|
required: true,
|
|
164
164
|
displayName: "Value",
|
|
165
165
|
validator: (_value, _props, ctx) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registerListBoxItem.cjs.js","sources":["../src/registerListBoxItem.tsx"],"sourcesContent":["import { PlasmicElement } from \"@plasmicapp/host\";\nimport React, { useEffect, useState } from \"react\";\nimport { ListBox, ListBoxItem } from \"react-aria-components\";\nimport { PlasmicListBoxContext } from \"./contexts\";\nimport { DESCRIPTION_COMPONENT_NAME } from \"./registerDescription\";\nimport { TEXT_COMPONENT_NAME } from \"./registerText\";\nimport {\n CodeComponentMetaOverrides,\n HasControlContextData,\n makeComponentName,\n Registerable,\n registerComponentHelper,\n} from \"./utils\";\nimport { pickAriaComponentVariants, WithVariants } from \"./variant-utils\";\n\nconst LIST_BOX_ITEM_VARIANTS = [\n \"hovered\" as const,\n \"pressed\" as const,\n \"focused\" as const,\n \"focusVisible\" as const,\n \"selected\" as const,\n \"disabled\" as const,\n];\n\nconst { variants, withObservedValues } = pickAriaComponentVariants(\n LIST_BOX_ITEM_VARIANTS\n);\n\nexport interface BaseListBoxControlContextData {\n idError?: string;\n}\n\nexport interface BaseListBoxItemProps\n extends React.ComponentProps<typeof ListBoxItem>,\n HasControlContextData<BaseListBoxControlContextData>,\n WithVariants<typeof LIST_BOX_ITEM_VARIANTS> {\n id?: string;\n children?: React.ReactNode;\n}\n\nexport function BaseListBoxItem(props: BaseListBoxItemProps) {\n const { children, setControlContextData, plasmicUpdateVariant, id, ...rest } =\n props;\n const listboxContext = React.useContext(PlasmicListBoxContext);\n const isStandalone = !listboxContext;\n /**\n * Ids of each listboxitem inside a listbox have to be unique. Otherwise, the items won't show up in the listbox.\n * This is particularly important to ensure, because the most common use case would be to apply Repeat Element to the listbox item.\n * The ids of each repeated item will initially be the same (until the user changes the id prop of the listboxitem).\n *\n * The registerId, therefore, is the unique id of the listboxitem.\n * It is the id registered with the listbox context, so that it can auto-generate a unique id if it identifies a duplicate.\n */\n const [registeredId, setRegisteredId] = useState<string | undefined>();\n\n useEffect(() => {\n if (!listboxContext) {\n return;\n }\n\n const localId = listboxContext.idManager.register(id);\n setRegisteredId(localId);\n\n return () => {\n listboxContext.idManager.unregister(localId);\n setRegisteredId(undefined);\n };\n }, [id]);\n\n setControlContextData?.({\n idError: (() => {\n if (id === undefined) {\n return \"ID must be defined\";\n }\n if (typeof id !== \"string\") {\n return \"ID must be a string\";\n }\n if (!id.trim()) {\n return \"ID must be defined\";\n }\n if (!isStandalone && id != registeredId) {\n return \"ID must be unique\";\n }\n return undefined;\n })(),\n });\n\n const listboxItem = (\n <ListBoxItem key={registeredId} id={registeredId} {...rest}>\n {({\n isHovered,\n isPressed,\n isFocused,\n isFocusVisible,\n isSelected,\n isDisabled,\n }) =>\n withObservedValues(\n children,\n {\n hovered: isHovered,\n pressed: isPressed,\n focused: isFocused,\n focusVisible: isFocusVisible,\n selected: isSelected,\n disabled: isDisabled,\n },\n plasmicUpdateVariant\n )\n }\n </ListBoxItem>\n );\n\n if (isStandalone) {\n // selection mode needs to be single/multiple to be able to trigger hover state on it.\n return <ListBox selectionMode=\"single\">{listboxItem}</ListBox>;\n }\n\n return listboxItem;\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 variants,\n props: {\n id: {\n type: \"string\",\n description: \"A unique
|
|
1
|
+
{"version":3,"file":"registerListBoxItem.cjs.js","sources":["../src/registerListBoxItem.tsx"],"sourcesContent":["import { PlasmicElement } from \"@plasmicapp/host\";\nimport React, { useEffect, useState } from \"react\";\nimport { ListBox, ListBoxItem } from \"react-aria-components\";\nimport { PlasmicListBoxContext } from \"./contexts\";\nimport { DESCRIPTION_COMPONENT_NAME } from \"./registerDescription\";\nimport { TEXT_COMPONENT_NAME } from \"./registerText\";\nimport {\n CodeComponentMetaOverrides,\n HasControlContextData,\n makeComponentName,\n Registerable,\n registerComponentHelper,\n} from \"./utils\";\nimport { pickAriaComponentVariants, WithVariants } from \"./variant-utils\";\n\nconst LIST_BOX_ITEM_VARIANTS = [\n \"hovered\" as const,\n \"pressed\" as const,\n \"focused\" as const,\n \"focusVisible\" as const,\n \"selected\" as const,\n \"disabled\" as const,\n];\n\nconst { variants, withObservedValues } = pickAriaComponentVariants(\n LIST_BOX_ITEM_VARIANTS\n);\n\nexport interface BaseListBoxControlContextData {\n idError?: string;\n}\n\nexport interface BaseListBoxItemProps\n extends React.ComponentProps<typeof ListBoxItem>,\n HasControlContextData<BaseListBoxControlContextData>,\n WithVariants<typeof LIST_BOX_ITEM_VARIANTS> {\n id?: string;\n children?: React.ReactNode;\n}\n\nexport function BaseListBoxItem(props: BaseListBoxItemProps) {\n const { children, setControlContextData, plasmicUpdateVariant, id, ...rest } =\n props;\n const listboxContext = React.useContext(PlasmicListBoxContext);\n const isStandalone = !listboxContext;\n /**\n * Ids of each listboxitem inside a listbox have to be unique. Otherwise, the items won't show up in the listbox.\n * This is particularly important to ensure, because the most common use case would be to apply Repeat Element to the listbox item.\n * The ids of each repeated item will initially be the same (until the user changes the id prop of the listboxitem).\n *\n * The registerId, therefore, is the unique id of the listboxitem.\n * It is the id registered with the listbox context, so that it can auto-generate a unique id if it identifies a duplicate.\n */\n const [registeredId, setRegisteredId] = useState<string | undefined>();\n\n useEffect(() => {\n if (!listboxContext) {\n return;\n }\n\n const localId = listboxContext.idManager.register(id);\n setRegisteredId(localId);\n\n return () => {\n listboxContext.idManager.unregister(localId);\n setRegisteredId(undefined);\n };\n }, [id]);\n\n setControlContextData?.({\n idError: (() => {\n if (id === undefined) {\n return \"ID must be defined\";\n }\n if (typeof id !== \"string\") {\n return \"ID must be a string\";\n }\n if (!id.trim()) {\n return \"ID must be defined\";\n }\n if (!isStandalone && id != registeredId) {\n return \"ID must be unique\";\n }\n return undefined;\n })(),\n });\n\n const listboxItem = (\n <ListBoxItem key={registeredId} id={registeredId} {...rest}>\n {({\n isHovered,\n isPressed,\n isFocused,\n isFocusVisible,\n isSelected,\n isDisabled,\n }) =>\n withObservedValues(\n children,\n {\n hovered: isHovered,\n pressed: isPressed,\n focused: isFocused,\n focusVisible: isFocusVisible,\n selected: isSelected,\n disabled: isDisabled,\n },\n plasmicUpdateVariant\n )\n }\n </ListBoxItem>\n );\n\n if (isStandalone) {\n // selection mode needs to be single/multiple to be able to trigger hover state on it.\n return <ListBox selectionMode=\"single\">{listboxItem}</ListBox>;\n }\n\n return listboxItem;\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 variants,\n props: {\n id: {\n type: \"string\",\n description: \"A unique value for tracking the selected item in state\",\n required: true,\n displayName: \"Value\",\n validator: (_value, _props, ctx) => {\n if (ctx?.idError) {\n return ctx.idError;\n }\n return true;\n },\n },\n textValue: {\n type: \"string\",\n displayName: \"Label\",\n description:\n \"A user-friendly text representation of the item's contents, used for features like typeahead.\",\n },\n children: {\n type: \"slot\",\n mergeWithParent: true,\n defaultValue: makeDefaultListBoxItemChildren(\"Item\"),\n },\n },\n trapsFocus: true,\n },\n overrides\n );\n}\n"],"names":["pickAriaComponentVariants","React","PlasmicListBoxContext","useState","useEffect","ListBoxItem","ListBox","TEXT_COMPONENT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AAA,UACN,WAAa,EAAA,wDAAA;AAAA,UACb,QAAU,EAAA,IAAA;AAAA,UACV,WAAa,EAAA,OAAA;AAAA,UACb,SAAW,EAAA,CAAC,MAAQ,EAAA,MAAA,EAAQ,GAAQ,KAAA;AAClC,YAAA,IAAI,2BAAK,OAAS,EAAA;AAChB,cAAA,OAAO,GAAI,CAAA,OAAA,CAAA;AAAA,aACb;AACA,YAAO,OAAA,IAAA,CAAA;AAAA,WACT;AAAA,SACF;AAAA,QACA,SAAW,EAAA;AAAA,UACT,IAAM,EAAA,QAAA;AAAA,UACN,WAAa,EAAA,OAAA;AAAA,UACb,WACE,EAAA,+FAAA;AAAA,SACJ;AAAA,QACA,QAAU,EAAA;AAAA,UACR,IAAM,EAAA,MAAA;AAAA,UACN,eAAiB,EAAA,IAAA;AAAA,UACjB,YAAA,EAAc,+BAA+B,MAAM,CAAA;AAAA,SACrD;AAAA,OACF;AAAA,MACA,UAAY,EAAA,IAAA;AAAA,KACd;AAAA,IACA,SAAA;AAAA,GACF,CAAA;AACF;;;;;;"}
|
|
@@ -153,7 +153,7 @@ function registerListBoxItem(loader, overrides) {
|
|
|
153
153
|
props: {
|
|
154
154
|
id: {
|
|
155
155
|
type: "string",
|
|
156
|
-
description: "A unique
|
|
156
|
+
description: "A unique value for tracking the selected item in state",
|
|
157
157
|
required: true,
|
|
158
158
|
displayName: "Value",
|
|
159
159
|
validator: (_value, _props, ctx) => {
|