@plasmicpkgs/react-aria 0.0.73 → 0.0.74
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 +40 -10
- package/dist/react-aria.esm.js.map +1 -1
- package/dist/react-aria.js +40 -10
- package/dist/react-aria.js.map +1 -1
- package/dist/registerComboBox.d.ts +5 -1
- package/dist/registerSelect.d.ts +5 -1
- package/package.json +2 -2
- package/skinny/registerComboBox.cjs.js +31 -10
- package/skinny/registerComboBox.cjs.js.map +1 -1
- package/skinny/registerComboBox.d.ts +5 -1
- package/skinny/registerComboBox.esm.js +31 -10
- package/skinny/registerComboBox.esm.js.map +1 -1
- package/skinny/registerSelect.cjs.js +11 -2
- package/skinny/registerSelect.cjs.js.map +1 -1
- package/skinny/registerSelect.d.ts +5 -1
- package/skinny/registerSelect.esm.js +11 -2
- package/skinny/registerSelect.esm.js.map +1 -1
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { ComboBoxProps } from "react-aria-components";
|
|
3
3
|
import { HasControlContextData, Registerable } from "./utils";
|
|
4
|
+
import { WithVariants } from "./variant-utils";
|
|
4
5
|
export interface BaseComboboxControlContextData {
|
|
5
6
|
itemIds: string[];
|
|
6
7
|
}
|
|
7
|
-
|
|
8
|
+
declare const COMBOBOX_VARIANTS: "disabled"[];
|
|
9
|
+
export interface BaseComboboxProps extends ComboBoxProps<{}>, WithVariants<typeof COMBOBOX_VARIANTS>, HasControlContextData<BaseComboboxControlContextData> {
|
|
8
10
|
placeholder?: string;
|
|
9
11
|
children?: React.ReactNode;
|
|
10
12
|
isOpen?: boolean;
|
|
13
|
+
className?: string;
|
|
11
14
|
}
|
|
12
15
|
export declare function BaseComboBox(props: BaseComboboxProps): React.JSX.Element;
|
|
13
16
|
export declare function registerComboBox(loader?: Registerable): void;
|
|
17
|
+
export {};
|
package/dist/registerSelect.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { SelectProps, SelectValue } from "react-aria-components";
|
|
3
3
|
import { HasControlContextData, Registerable } from "./utils";
|
|
4
|
+
import { WithVariants } from "./variant-utils";
|
|
4
5
|
export interface BaseSelectValueProps extends React.ComponentProps<typeof SelectValue> {
|
|
5
6
|
customize?: boolean;
|
|
6
7
|
}
|
|
@@ -8,9 +9,12 @@ export declare const BaseSelectValue: (props: BaseSelectValueProps) => React.JSX
|
|
|
8
9
|
export interface BaseSelectControlContextData {
|
|
9
10
|
itemIds: string[];
|
|
10
11
|
}
|
|
12
|
+
declare const SELECT_VARIANTS: "disabled"[];
|
|
11
13
|
export interface BaseSelectProps extends SelectProps<{}>, // NOTE: We don't need generic type here since we don't use items prop (that needs it). We just need to make the type checker happy
|
|
12
|
-
HasControlContextData<BaseSelectControlContextData> {
|
|
14
|
+
WithVariants<typeof SELECT_VARIANTS>, HasControlContextData<BaseSelectControlContextData> {
|
|
13
15
|
children?: React.ReactNode;
|
|
16
|
+
className?: string;
|
|
14
17
|
}
|
|
15
18
|
export declare function BaseSelect(props: BaseSelectProps): React.JSX.Element;
|
|
16
19
|
export declare function registerSelect(loader?: Registerable): void;
|
|
20
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plasmicpkgs/react-aria",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.74",
|
|
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": "3a248a950c32eb08cda291945b8a39e961ffb820"
|
|
78
78
|
}
|
|
@@ -10,10 +10,10 @@ var registerInput = require('./registerInput.cjs.js');
|
|
|
10
10
|
var registerLabel = require('./registerLabel.cjs.js');
|
|
11
11
|
var registerPopover = require('./registerPopover.cjs.js');
|
|
12
12
|
var utils = require('./utils-3e796b18.cjs.js');
|
|
13
|
+
var variantUtils = require('./variant-utils-8cb38f8f.cjs.js');
|
|
13
14
|
require('./registerListBoxItem.cjs.js');
|
|
14
15
|
require('./registerDescription.cjs.js');
|
|
15
16
|
require('./registerText.cjs.js');
|
|
16
|
-
require('./variant-utils-8cb38f8f.cjs.js');
|
|
17
17
|
require('./registerSection.cjs.js');
|
|
18
18
|
require('@react-aria/utils');
|
|
19
19
|
require('react-aria');
|
|
@@ -56,6 +56,8 @@ var __objRest = (source, exclude) => {
|
|
|
56
56
|
return target;
|
|
57
57
|
};
|
|
58
58
|
const COMBOBOX_NAME = utils.makeComponentName("combobox");
|
|
59
|
+
const COMBOBOX_VARIANTS = ["disabled"];
|
|
60
|
+
const { variants: COMBOBOX_VARIANTS_DATA } = variantUtils.pickAriaComponentVariants(COMBOBOX_VARIANTS);
|
|
59
61
|
function ComboboxAutoOpen(props) {
|
|
60
62
|
var _a;
|
|
61
63
|
const { open, close } = (_a = React__default.default.useContext(reactAriaComponents.ComboBoxStateContext)) != null ? _a : {};
|
|
@@ -66,10 +68,16 @@ function BaseComboBox(props) {
|
|
|
66
68
|
const _a = props, {
|
|
67
69
|
children,
|
|
68
70
|
setControlContextData,
|
|
71
|
+
plasmicUpdateVariant,
|
|
72
|
+
className,
|
|
73
|
+
isDisabled,
|
|
69
74
|
isOpen: _isOpen
|
|
70
75
|
} = _a, rest = __objRest(_a, [
|
|
71
76
|
"children",
|
|
72
77
|
"setControlContextData",
|
|
78
|
+
"plasmicUpdateVariant",
|
|
79
|
+
"className",
|
|
80
|
+
"isDisabled",
|
|
73
81
|
"isOpen"
|
|
74
82
|
]);
|
|
75
83
|
const idManager = React.useMemo(() => new registerListBox.ListBoxItemIdManager(), []);
|
|
@@ -80,15 +88,27 @@ function BaseComboBox(props) {
|
|
|
80
88
|
});
|
|
81
89
|
});
|
|
82
90
|
}, []);
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
91
|
+
React.useEffect(() => {
|
|
92
|
+
plasmicUpdateVariant == null ? void 0 : plasmicUpdateVariant({
|
|
93
|
+
disabled: isDisabled
|
|
94
|
+
});
|
|
95
|
+
}, [isDisabled, plasmicUpdateVariant]);
|
|
96
|
+
return /* @__PURE__ */ React__default.default.createElement(
|
|
97
|
+
reactAriaComponents.ComboBox,
|
|
98
|
+
__spreadValues({
|
|
99
|
+
isDisabled,
|
|
100
|
+
className
|
|
101
|
+
}, rest),
|
|
102
|
+
/* @__PURE__ */ React__default.default.createElement(contexts.PlasmicPopoverContext.Provider, { value: {} }, /* @__PURE__ */ React__default.default.createElement(
|
|
103
|
+
contexts.PlasmicListBoxContext.Provider,
|
|
104
|
+
{
|
|
105
|
+
value: {
|
|
106
|
+
idManager
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
/* @__PURE__ */ React__default.default.createElement(contexts.PlasmicInputContext.Provider, { value: { isUncontrolled: true } }, /* @__PURE__ */ React__default.default.createElement(ComboboxAutoOpen, __spreadValues({}, props)), children)
|
|
110
|
+
))
|
|
111
|
+
);
|
|
92
112
|
}
|
|
93
113
|
function registerComboBox(loader) {
|
|
94
114
|
utils.registerComponentHelper(loader, BaseComboBox, {
|
|
@@ -96,6 +116,7 @@ function registerComboBox(loader) {
|
|
|
96
116
|
displayName: "Aria ComboBox",
|
|
97
117
|
importPath: "@plasmicpkgs/react-aria/skinny/registerComboBox",
|
|
98
118
|
importName: "BaseComboBox",
|
|
119
|
+
variants: COMBOBOX_VARIANTS_DATA,
|
|
99
120
|
props: __spreadProps(__spreadValues({}, common.getCommonProps("ComboBox", [
|
|
100
121
|
"name",
|
|
101
122
|
"aria-label",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registerComboBox.cjs.js","sources":["../src/registerComboBox.tsx"],"sourcesContent":["import 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 useAutoOpen,\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\n Note: It cannot be used as a hook like useAutoOpen() within the BaseSelect component\n because it needs access to SelectStateContext, which is only created in the BaseSelect component's render function.\n */\nfunction ComboboxAutoOpen(props: any) {\n const { open, close } = React.useContext(ComboBoxStateContext) ?? {};\n\n useAutoOpen({ props, open, close });\n\n return null;\n}\n\nexport function BaseComboBox(props: BaseComboboxProps) {\n const {\n children,\n setControlContextData,\n isOpen: _isOpen, // uncontrolled if not selected in canvas/edit mode\n ...rest\n } = 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 value={{}}>\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","ComboBoxStateContext","useAutoOpen","useMemo","ListBoxItemIdManager","useEffect","React","ComboBox","PlasmicPopoverContext","PlasmicListBoxContext","PlasmicInputContext","registerComponentHelper","getCommonProps","LABEL_COMPONENT_NAME","INPUT_COMPONENT_NAME","BUTTON_CO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AA,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;;;;;"}
|
|
1
|
+
{"version":3,"file":"registerComboBox.cjs.js","sources":["../src/registerComboBox.tsx"],"sourcesContent":["import 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 useAutoOpen,\n} from \"./utils\";\nimport { pickAriaComponentVariants, WithVariants } from \"./variant-utils\";\n\nconst COMBOBOX_NAME = makeComponentName(\"combobox\");\n\nexport interface BaseComboboxControlContextData {\n itemIds: string[];\n}\n\nconst COMBOBOX_VARIANTS = [\"disabled\" as const];\n\nconst { variants: COMBOBOX_VARIANTS_DATA } =\n pickAriaComponentVariants(COMBOBOX_VARIANTS);\n\nexport interface BaseComboboxProps\n extends ComboBoxProps<{}>,\n WithVariants<typeof COMBOBOX_VARIANTS>,\n HasControlContextData<BaseComboboxControlContextData> {\n placeholder?: string;\n children?: React.ReactNode;\n isOpen?: boolean;\n className?: string;\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\n Note: It cannot be used as a hook like useAutoOpen() within the BaseSelect component\n because it needs access to SelectStateContext, which is only created in the BaseSelect component's render function.\n */\nfunction ComboboxAutoOpen(props: any) {\n const { open, close } = React.useContext(ComboBoxStateContext) ?? {};\n\n useAutoOpen({ props, open, close });\n\n return null;\n}\n\nexport function BaseComboBox(props: BaseComboboxProps) {\n const {\n children,\n setControlContextData,\n plasmicUpdateVariant,\n className,\n isDisabled,\n isOpen: _isOpen, // uncontrolled if not selected in canvas/edit mode\n ...rest\n } = 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 // NOTE: Aria <Combobox> does not support render props, neither does it provide an onDisabledChange event, so we have to manually update the disabled state.\n useEffect(() => {\n plasmicUpdateVariant?.({\n disabled: isDisabled,\n });\n }, [isDisabled, plasmicUpdateVariant]);\n\n return (\n <ComboBox\n isDisabled={isDisabled}\n // Not calling plasmicUpdateVariant within className callback (which has access to render props) because it would then run on every render\n className={className}\n {...rest}\n >\n <PlasmicPopoverContext.Provider value={{}}>\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 variants: COMBOBOX_VARIANTS_DATA,\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","pickAriaComponentVariants","ComboBoxStateContext","useAutoOpen","useMemo","ListBoxItemIdManager","useEffect","React","ComboBox","PlasmicPopoverContext","PlasmicListBoxContext","PlasmicInputContext","registerComponentHelper","getCommonProps","LABEL_COMPONENT_NAME","INPUT_COMPONENT_NAME","BUTTON_COMPONENT_NAME","POPOVER_COMPONENT_NAME","LIST_BOX_COMPONENT_NAME"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,MAAM,aAAA,GAAgBA,wBAAkB,UAAU,CAAA,CAAA;AAMlD,MAAM,iBAAA,GAAoB,CAAC,UAAmB,CAAA,CAAA;AAE9C,MAAM,EAAE,QAAA,EAAU,sBAAuB,EAAA,GACvCC,uCAA0B,iBAAiB,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A;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;;;;;"}
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { ComboBoxProps } from "react-aria-components";
|
|
3
3
|
import { HasControlContextData, Registerable } from "./utils";
|
|
4
|
+
import { WithVariants } from "./variant-utils";
|
|
4
5
|
export interface BaseComboboxControlContextData {
|
|
5
6
|
itemIds: string[];
|
|
6
7
|
}
|
|
7
|
-
|
|
8
|
+
declare const COMBOBOX_VARIANTS: "disabled"[];
|
|
9
|
+
export interface BaseComboboxProps extends ComboBoxProps<{}>, WithVariants<typeof COMBOBOX_VARIANTS>, HasControlContextData<BaseComboboxControlContextData> {
|
|
8
10
|
placeholder?: string;
|
|
9
11
|
children?: React.ReactNode;
|
|
10
12
|
isOpen?: boolean;
|
|
13
|
+
className?: string;
|
|
11
14
|
}
|
|
12
15
|
export declare function BaseComboBox(props: BaseComboboxProps): React.JSX.Element;
|
|
13
16
|
export declare function registerComboBox(loader?: Registerable): void;
|
|
17
|
+
export {};
|
|
@@ -8,10 +8,10 @@ import { INPUT_COMPONENT_NAME } from './registerInput.esm.js';
|
|
|
8
8
|
import { LABEL_COMPONENT_NAME } from './registerLabel.esm.js';
|
|
9
9
|
import { POPOVER_COMPONENT_NAME } from './registerPopover.esm.js';
|
|
10
10
|
import { r as registerComponentHelper, a as makeComponentName, u as useAutoOpen } from './utils-25448fbd.esm.js';
|
|
11
|
+
import { p as pickAriaComponentVariants } from './variant-utils-7c2ea202.esm.js';
|
|
11
12
|
import './registerListBoxItem.esm.js';
|
|
12
13
|
import './registerDescription.esm.js';
|
|
13
14
|
import './registerText.esm.js';
|
|
14
|
-
import './variant-utils-7c2ea202.esm.js';
|
|
15
15
|
import './registerSection.esm.js';
|
|
16
16
|
import '@react-aria/utils';
|
|
17
17
|
import 'react-aria';
|
|
@@ -50,6 +50,8 @@ var __objRest = (source, exclude) => {
|
|
|
50
50
|
return target;
|
|
51
51
|
};
|
|
52
52
|
const COMBOBOX_NAME = makeComponentName("combobox");
|
|
53
|
+
const COMBOBOX_VARIANTS = ["disabled"];
|
|
54
|
+
const { variants: COMBOBOX_VARIANTS_DATA } = pickAriaComponentVariants(COMBOBOX_VARIANTS);
|
|
53
55
|
function ComboboxAutoOpen(props) {
|
|
54
56
|
var _a;
|
|
55
57
|
const { open, close } = (_a = React.useContext(ComboBoxStateContext)) != null ? _a : {};
|
|
@@ -60,10 +62,16 @@ function BaseComboBox(props) {
|
|
|
60
62
|
const _a = props, {
|
|
61
63
|
children,
|
|
62
64
|
setControlContextData,
|
|
65
|
+
plasmicUpdateVariant,
|
|
66
|
+
className,
|
|
67
|
+
isDisabled,
|
|
63
68
|
isOpen: _isOpen
|
|
64
69
|
} = _a, rest = __objRest(_a, [
|
|
65
70
|
"children",
|
|
66
71
|
"setControlContextData",
|
|
72
|
+
"plasmicUpdateVariant",
|
|
73
|
+
"className",
|
|
74
|
+
"isDisabled",
|
|
67
75
|
"isOpen"
|
|
68
76
|
]);
|
|
69
77
|
const idManager = useMemo(() => new ListBoxItemIdManager(), []);
|
|
@@ -74,15 +82,27 @@ function BaseComboBox(props) {
|
|
|
74
82
|
});
|
|
75
83
|
});
|
|
76
84
|
}, []);
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
85
|
+
useEffect(() => {
|
|
86
|
+
plasmicUpdateVariant == null ? void 0 : plasmicUpdateVariant({
|
|
87
|
+
disabled: isDisabled
|
|
88
|
+
});
|
|
89
|
+
}, [isDisabled, plasmicUpdateVariant]);
|
|
90
|
+
return /* @__PURE__ */ React.createElement(
|
|
91
|
+
ComboBox,
|
|
92
|
+
__spreadValues({
|
|
93
|
+
isDisabled,
|
|
94
|
+
className
|
|
95
|
+
}, rest),
|
|
96
|
+
/* @__PURE__ */ React.createElement(PlasmicPopoverContext.Provider, { value: {} }, /* @__PURE__ */ React.createElement(
|
|
97
|
+
PlasmicListBoxContext.Provider,
|
|
98
|
+
{
|
|
99
|
+
value: {
|
|
100
|
+
idManager
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
/* @__PURE__ */ React.createElement(PlasmicInputContext.Provider, { value: { isUncontrolled: true } }, /* @__PURE__ */ React.createElement(ComboboxAutoOpen, __spreadValues({}, props)), children)
|
|
104
|
+
))
|
|
105
|
+
);
|
|
86
106
|
}
|
|
87
107
|
function registerComboBox(loader) {
|
|
88
108
|
registerComponentHelper(loader, BaseComboBox, {
|
|
@@ -90,6 +110,7 @@ function registerComboBox(loader) {
|
|
|
90
110
|
displayName: "Aria ComboBox",
|
|
91
111
|
importPath: "@plasmicpkgs/react-aria/skinny/registerComboBox",
|
|
92
112
|
importName: "BaseComboBox",
|
|
113
|
+
variants: COMBOBOX_VARIANTS_DATA,
|
|
93
114
|
props: __spreadProps(__spreadValues({}, getCommonProps("ComboBox", [
|
|
94
115
|
"name",
|
|
95
116
|
"aria-label",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registerComboBox.esm.js","sources":["../src/registerComboBox.tsx"],"sourcesContent":["import 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 useAutoOpen,\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\n Note: It cannot be used as a hook like useAutoOpen() within the BaseSelect component\n because it needs access to SelectStateContext, which is only created in the BaseSelect component's render function.\n */\nfunction ComboboxAutoOpen(props: any) {\n const { open, close } = React.useContext(ComboBoxStateContext) ?? {};\n\n useAutoOpen({ props, open, close });\n\n return null;\n}\n\nexport function BaseComboBox(props: BaseComboboxProps) {\n const {\n children,\n setControlContextData,\n isOpen: _isOpen, // uncontrolled if not selected in canvas/edit mode\n ...rest\n } = 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 value={{}}>\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAM,aAAA,GAAgB,kBAAkB,UAAU,CAAA,CAAA;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,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 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 useAutoOpen,\n} from \"./utils\";\nimport { pickAriaComponentVariants, WithVariants } from \"./variant-utils\";\n\nconst COMBOBOX_NAME = makeComponentName(\"combobox\");\n\nexport interface BaseComboboxControlContextData {\n itemIds: string[];\n}\n\nconst COMBOBOX_VARIANTS = [\"disabled\" as const];\n\nconst { variants: COMBOBOX_VARIANTS_DATA } =\n pickAriaComponentVariants(COMBOBOX_VARIANTS);\n\nexport interface BaseComboboxProps\n extends ComboBoxProps<{}>,\n WithVariants<typeof COMBOBOX_VARIANTS>,\n HasControlContextData<BaseComboboxControlContextData> {\n placeholder?: string;\n children?: React.ReactNode;\n isOpen?: boolean;\n className?: string;\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\n Note: It cannot be used as a hook like useAutoOpen() within the BaseSelect component\n because it needs access to SelectStateContext, which is only created in the BaseSelect component's render function.\n */\nfunction ComboboxAutoOpen(props: any) {\n const { open, close } = React.useContext(ComboBoxStateContext) ?? {};\n\n useAutoOpen({ props, open, close });\n\n return null;\n}\n\nexport function BaseComboBox(props: BaseComboboxProps) {\n const {\n children,\n setControlContextData,\n plasmicUpdateVariant,\n className,\n isDisabled,\n isOpen: _isOpen, // uncontrolled if not selected in canvas/edit mode\n ...rest\n } = 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 // NOTE: Aria <Combobox> does not support render props, neither does it provide an onDisabledChange event, so we have to manually update the disabled state.\n useEffect(() => {\n plasmicUpdateVariant?.({\n disabled: isDisabled,\n });\n }, [isDisabled, plasmicUpdateVariant]);\n\n return (\n <ComboBox\n isDisabled={isDisabled}\n // Not calling plasmicUpdateVariant within className callback (which has access to render props) because it would then run on every render\n className={className}\n {...rest}\n >\n <PlasmicPopoverContext.Provider value={{}}>\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 variants: COMBOBOX_VARIANTS_DATA,\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,MAAM,aAAA,GAAgB,kBAAkB,UAAU,CAAA,CAAA;AAMlD,MAAM,iBAAA,GAAoB,CAAC,UAAmB,CAAA,CAAA;AAE9C,MAAM,EAAE,QAAA,EAAU,sBAAuB,EAAA,GACvC,0BAA0B,iBAAiB,CAAA,CAAA;AAuB7C,SAAS,iBAAiB,KAAY,EAAA;AA3DtC,EAAA,IAAA,EAAA,CAAA;AA4DE,EAAM,MAAA,EAAE,MAAM,KAAM,EAAA,GAAA,CAAI,WAAM,UAAW,CAAA,oBAAoB,CAArC,KAAA,IAAA,GAAA,EAAA,GAA0C,EAAC,CAAA;AAEnE,EAAA,WAAA,CAAY,EAAE,KAAA,EAAO,IAAM,EAAA,KAAA,EAAO,CAAA,CAAA;AAElC,EAAO,OAAA,IAAA,CAAA;AACT,CAAA;AAEO,SAAS,aAAa,KAA0B,EAAA;AACrD,EAAA,MAQI,EAPF,GAAA,KAAA,EAAA;AAAA,IAAA,QAAA;AAAA,IACA,qBAAA;AAAA,IACA,oBAAA;AAAA,IACA,SAA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AA,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;;;;"}
|
|
@@ -9,10 +9,10 @@ var registerButton = require('./registerButton.cjs.js');
|
|
|
9
9
|
var registerLabel = require('./registerLabel.cjs.js');
|
|
10
10
|
var registerPopover = require('./registerPopover.cjs.js');
|
|
11
11
|
var utils = require('./utils-3e796b18.cjs.js');
|
|
12
|
+
var variantUtils = require('./variant-utils-8cb38f8f.cjs.js');
|
|
12
13
|
require('./registerListBoxItem.cjs.js');
|
|
13
14
|
require('./registerDescription.cjs.js');
|
|
14
15
|
require('./registerText.cjs.js');
|
|
15
|
-
require('./variant-utils-8cb38f8f.cjs.js');
|
|
16
16
|
require('./registerSection.cjs.js');
|
|
17
17
|
require('@react-aria/utils');
|
|
18
18
|
require('@plasmicapp/host');
|
|
@@ -53,6 +53,8 @@ const BaseSelectValue = (props) => {
|
|
|
53
53
|
return /* @__PURE__ */ React__default.default.createElement(reactAriaComponents.SelectValue, { className }, ({ isPlaceholder, selectedText }) => /* @__PURE__ */ React__default.default.createElement(React__default.default.Fragment, null, isPlaceholder ? placeholder : selectedText));
|
|
54
54
|
};
|
|
55
55
|
const SELECT_NAME = utils.makeComponentName("select");
|
|
56
|
+
const SELECT_VARIANTS = ["disabled"];
|
|
57
|
+
const { variants: SELECT_VARIANTS_DATA } = variantUtils.pickAriaComponentVariants(SELECT_VARIANTS);
|
|
56
58
|
function BaseSelect(props) {
|
|
57
59
|
const {
|
|
58
60
|
selectedKey,
|
|
@@ -66,9 +68,10 @@ function BaseSelect(props) {
|
|
|
66
68
|
disabledKeys,
|
|
67
69
|
name,
|
|
68
70
|
setControlContextData,
|
|
71
|
+
plasmicUpdateVariant,
|
|
69
72
|
"aria-label": ariaLabel
|
|
70
73
|
} = props;
|
|
71
|
-
|
|
74
|
+
const idManager = React.useMemo(() => new registerListBox.ListBoxItemIdManager(), []);
|
|
72
75
|
React.useEffect(() => {
|
|
73
76
|
idManager.subscribe((ids) => {
|
|
74
77
|
setControlContextData == null ? void 0 : setControlContextData({
|
|
@@ -76,6 +79,11 @@ function BaseSelect(props) {
|
|
|
76
79
|
});
|
|
77
80
|
});
|
|
78
81
|
}, []);
|
|
82
|
+
React.useEffect(() => {
|
|
83
|
+
plasmicUpdateVariant == null ? void 0 : plasmicUpdateVariant({
|
|
84
|
+
disabled: isDisabled
|
|
85
|
+
});
|
|
86
|
+
}, [isDisabled, plasmicUpdateVariant]);
|
|
79
87
|
return /* @__PURE__ */ React__default.default.createElement(
|
|
80
88
|
reactAriaComponents.Select,
|
|
81
89
|
__spreadValues({
|
|
@@ -132,6 +140,7 @@ function registerSelect(loader) {
|
|
|
132
140
|
displayName: "Aria Select",
|
|
133
141
|
importPath: "@plasmicpkgs/react-aria/skinny/registerSelect",
|
|
134
142
|
importName: "BaseSelect",
|
|
143
|
+
variants: SELECT_VARIANTS_DATA,
|
|
135
144
|
props: __spreadProps(__spreadValues({}, common.getCommonProps("Select", [
|
|
136
145
|
"name",
|
|
137
146
|
"aria-label",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registerSelect.cjs.js","sources":["../src/registerSelect.tsx"],"sourcesContent":["import React, { useEffect, useMemo } from \"react\";\nimport {\n Select,\n SelectProps,\n SelectStateContext,\n SelectValue,\n} from \"react-aria-components\";\nimport { getCommonProps } from \"./common\";\nimport { PlasmicListBoxContext, PlasmicPopoverContext } from \"./contexts\";\nimport { ListBoxItemIdManager } from \"./ListBoxItemIdManager\";\nimport { BUTTON_COMPONENT_NAME } from \"./registerButton\";\nimport { LABEL_COMPONENT_NAME } from \"./registerLabel\";\nimport { LIST_BOX_COMPONENT_NAME } from \"./registerListBox\";\nimport { POPOVER_COMPONENT_NAME } from \"./registerPopover\";\nimport {\n extractPlasmicDataProps,\n HasControlContextData,\n makeComponentName,\n Registerable,\n registerComponentHelper,\n useAutoOpen,\n} from \"./utils\";\n\n// It cannot be used as a hook like useAutoOpen() within the BaseSelect component\n// because it needs access to SelectStateContext, which is only created in the BaseSelect component's render function.\nfunction SelectAutoOpen(props: any) {\n const { open, close } = React.useContext(SelectStateContext) ?? {};\n useAutoOpen({ props, open, close });\n\n return null;\n}\n\nexport interface BaseSelectValueProps\n extends React.ComponentProps<typeof SelectValue> {\n customize?: boolean;\n}\n\nexport const BaseSelectValue = (props: BaseSelectValueProps) => {\n const { children, customize, className } = props;\n const placeholder = customize ? children : \"Select an item\";\n return (\n <SelectValue className={className}>\n {({ isPlaceholder, selectedText }) => (\n <>{isPlaceholder ? placeholder : selectedText}</>\n )}\n </SelectValue>\n );\n};\n\nconst SELECT_NAME = makeComponentName(\"select\");\n\nexport interface BaseSelectControlContextData {\n itemIds: string[];\n}\n\nexport interface BaseSelectProps\n extends SelectProps<{}>, // NOTE: We don't need generic type here since we don't use items prop (that needs it). We just need to make the type checker happy\n HasControlContextData<BaseSelectControlContextData> {\n children?: React.ReactNode;\n}\n\nexport function BaseSelect(props: BaseSelectProps) {\n const {\n selectedKey,\n onSelectionChange,\n placeholder,\n onOpenChange,\n isDisabled,\n className,\n style,\n children,\n disabledKeys,\n name,\n setControlContextData,\n \"aria-label\": ariaLabel,\n } = props;\n\n let idManager = useMemo(() => new ListBoxItemIdManager(), []);\n\n useEffect(() => {\n idManager.subscribe((ids: string[]) => {\n setControlContextData?.({\n itemIds: ids,\n });\n });\n }, []);\n\n return (\n <Select\n placeholder={placeholder}\n selectedKey={selectedKey}\n onSelectionChange={onSelectionChange}\n onOpenChange={onOpenChange}\n isDisabled={isDisabled}\n className={className}\n style={style}\n name={name}\n disabledKeys={disabledKeys}\n aria-label={ariaLabel}\n {...extractPlasmicDataProps(props)}\n >\n <SelectAutoOpen {...props} />\n <PlasmicPopoverContext.Provider value={{}}>\n <PlasmicListBoxContext.Provider\n value={{\n idManager,\n }}\n >\n {children}\n </PlasmicListBoxContext.Provider>\n </PlasmicPopoverContext.Provider>\n </Select>\n );\n}\n\nexport function registerSelect(loader?: Registerable) {\n const selectValueMeta = registerComponentHelper(loader, BaseSelectValue, {\n name: makeComponentName(\"select-value\"),\n displayName: \"Aria Selected Value\",\n importPath: \"@plasmicpkgs/react-aria/skinny/registerSelect\",\n importName: \"BaseSelectValue\",\n parentComponentName: SELECT_NAME,\n props: {\n customize: {\n type: \"boolean\",\n description: \"Whether to customize the selected value display\",\n },\n children: {\n type: \"slot\",\n defaultValue: [\n {\n type: \"text\",\n value: \"Selected value...\",\n },\n ],\n hidden: (props) => !props.customize,\n },\n },\n trapsFocus: true,\n });\n\n registerComponentHelper(loader, BaseSelect, {\n name: SELECT_NAME,\n displayName: \"Aria Select\",\n importPath: \"@plasmicpkgs/react-aria/skinny/registerSelect\",\n importName: \"BaseSelect\",\n props: {\n ...getCommonProps<BaseSelectProps>(\"Select\", [\n \"name\",\n \"aria-label\",\n \"placeholder\",\n \"isDisabled\",\n \"autoFocus\",\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 Select do not support multiple selections yet\n multiSelect: false,\n },\n onSelectionChange: {\n type: \"eventHandler\",\n argTypes: [{ name: \"selectedValue\", type: \"string\" }],\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 onOpenChange: {\n type: \"eventHandler\",\n argTypes: [{ name: \"isOpen\", type: \"boolean\" }],\n },\n children: {\n type: \"slot\",\n mergeWithParent: true,\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: \"component\",\n name: BUTTON_COMPONENT_NAME,\n styles: {\n width: \"100%\",\n },\n props: {\n children: {\n type: \"hbox\",\n styles: {\n width: \"stretch\",\n justifyContent: \"space-between\",\n alignItems: \"center\",\n padding: \"2px 5px\",\n },\n children: [\n {\n type: \"component\",\n name: selectValueMeta.name,\n },\n {\n type: \"img\",\n src: \"https://static1.plasmic.app/arrow-up.svg\",\n styles: {\n height: \"20px\",\n width: \"20px\",\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 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":["SelectStateContext","useAutoOpen","React","SelectValue","makeComponentName","useMemo","ListBoxItemIdManager","useEffect","Select","extractPlasmicDataProps","PlasmicPopoverContext","PlasmicListBoxContext","registerComponentHelper","getCommonProps","LABEL_COMPONENT_NAME","BUTTON_COMPONENT_NAME","POPOVER_COMPONENT_NAME","LIST_BOX_COMPONENT_NAME"],"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A,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;;;;;;"}
|
|
1
|
+
{"version":3,"file":"registerSelect.cjs.js","sources":["../src/registerSelect.tsx"],"sourcesContent":["import React, { useEffect, useMemo } from \"react\";\nimport {\n Select,\n SelectProps,\n SelectStateContext,\n SelectValue,\n} from \"react-aria-components\";\nimport { getCommonProps } from \"./common\";\nimport { PlasmicListBoxContext, PlasmicPopoverContext } from \"./contexts\";\nimport { ListBoxItemIdManager } from \"./ListBoxItemIdManager\";\nimport { BUTTON_COMPONENT_NAME } from \"./registerButton\";\nimport { LABEL_COMPONENT_NAME } from \"./registerLabel\";\nimport { LIST_BOX_COMPONENT_NAME } from \"./registerListBox\";\nimport { POPOVER_COMPONENT_NAME } from \"./registerPopover\";\nimport {\n extractPlasmicDataProps,\n HasControlContextData,\n makeComponentName,\n Registerable,\n registerComponentHelper,\n useAutoOpen,\n} from \"./utils\";\nimport { pickAriaComponentVariants, WithVariants } from \"./variant-utils\";\n\n// It cannot be used as a hook like useAutoOpen() within the BaseSelect component\n// because it needs access to SelectStateContext, which is only created in the BaseSelect component's render function.\nfunction SelectAutoOpen(props: any) {\n const { open, close } = React.useContext(SelectStateContext) ?? {};\n useAutoOpen({ props, open, close });\n\n return null;\n}\n\nexport interface BaseSelectValueProps\n extends React.ComponentProps<typeof SelectValue> {\n customize?: boolean;\n}\n\nexport const BaseSelectValue = (props: BaseSelectValueProps) => {\n const { children, customize, className } = props;\n const placeholder = customize ? children : \"Select an item\";\n return (\n <SelectValue className={className}>\n {({ isPlaceholder, selectedText }) => (\n <>{isPlaceholder ? placeholder : selectedText}</>\n )}\n </SelectValue>\n );\n};\n\nconst SELECT_NAME = makeComponentName(\"select\");\n\nexport interface BaseSelectControlContextData {\n itemIds: string[];\n}\n\nconst SELECT_VARIANTS = [\"disabled\" as const];\n\nconst { variants: SELECT_VARIANTS_DATA } =\n pickAriaComponentVariants(SELECT_VARIANTS);\n\nexport interface BaseSelectProps\n extends SelectProps<{}>, // NOTE: We don't need generic type here since we don't use items prop (that needs it). We just need to make the type checker happy\n WithVariants<typeof SELECT_VARIANTS>,\n HasControlContextData<BaseSelectControlContextData> {\n children?: React.ReactNode;\n className?: string;\n}\n\nexport function BaseSelect(props: BaseSelectProps) {\n const {\n selectedKey,\n onSelectionChange,\n placeholder,\n onOpenChange,\n isDisabled,\n className,\n style,\n children,\n disabledKeys,\n name,\n setControlContextData,\n plasmicUpdateVariant,\n \"aria-label\": ariaLabel,\n } = 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 // NOTE: Aria <Select> does not support render props, neither does it provide an onDisabledChange event, so we have to manually update the disabled state.\n useEffect(() => {\n plasmicUpdateVariant?.({\n disabled: isDisabled,\n });\n }, [isDisabled, plasmicUpdateVariant]);\n\n return (\n <Select\n placeholder={placeholder}\n selectedKey={selectedKey}\n onSelectionChange={onSelectionChange}\n onOpenChange={onOpenChange}\n isDisabled={isDisabled}\n // Not calling plasmicUpdateVariant within className callback (which has access to render props) because it would then run on every render\n className={className}\n style={style}\n name={name}\n disabledKeys={disabledKeys}\n aria-label={ariaLabel}\n {...extractPlasmicDataProps(props)}\n >\n <SelectAutoOpen {...props} />\n <PlasmicPopoverContext.Provider value={{}}>\n <PlasmicListBoxContext.Provider\n value={{\n idManager,\n }}\n >\n {children}\n </PlasmicListBoxContext.Provider>\n </PlasmicPopoverContext.Provider>\n </Select>\n );\n}\n\nexport function registerSelect(loader?: Registerable) {\n const selectValueMeta = registerComponentHelper(loader, BaseSelectValue, {\n name: makeComponentName(\"select-value\"),\n displayName: \"Aria Selected Value\",\n importPath: \"@plasmicpkgs/react-aria/skinny/registerSelect\",\n importName: \"BaseSelectValue\",\n parentComponentName: SELECT_NAME,\n props: {\n customize: {\n type: \"boolean\",\n description: \"Whether to customize the selected value display\",\n },\n children: {\n type: \"slot\",\n defaultValue: [\n {\n type: \"text\",\n value: \"Selected value...\",\n },\n ],\n hidden: (props) => !props.customize,\n },\n },\n trapsFocus: true,\n });\n\n registerComponentHelper(loader, BaseSelect, {\n name: SELECT_NAME,\n displayName: \"Aria Select\",\n importPath: \"@plasmicpkgs/react-aria/skinny/registerSelect\",\n importName: \"BaseSelect\",\n variants: SELECT_VARIANTS_DATA,\n props: {\n ...getCommonProps<BaseSelectProps>(\"Select\", [\n \"name\",\n \"aria-label\",\n \"placeholder\",\n \"isDisabled\",\n \"autoFocus\",\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 Select do not support multiple selections yet\n multiSelect: false,\n },\n onSelectionChange: {\n type: \"eventHandler\",\n argTypes: [{ name: \"selectedValue\", type: \"string\" }],\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 onOpenChange: {\n type: \"eventHandler\",\n argTypes: [{ name: \"isOpen\", type: \"boolean\" }],\n },\n children: {\n type: \"slot\",\n mergeWithParent: true,\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: \"component\",\n name: BUTTON_COMPONENT_NAME,\n styles: {\n width: \"100%\",\n },\n props: {\n children: {\n type: \"hbox\",\n styles: {\n width: \"stretch\",\n justifyContent: \"space-between\",\n alignItems: \"center\",\n padding: \"2px 5px\",\n },\n children: [\n {\n type: \"component\",\n name: selectValueMeta.name,\n },\n {\n type: \"img\",\n src: \"https://static1.plasmic.app/arrow-up.svg\",\n styles: {\n height: \"20px\",\n width: \"20px\",\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 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":["SelectStateContext","useAutoOpen","React","SelectValue","makeComponentName","pickAriaComponentVariants","useMemo","ListBoxItemIdManager","useEffect","Select","extractPlasmicDataProps","PlasmicPopoverContext","PlasmicListBoxContext","registerComponentHelper","getCommonProps","LABEL_COMPONENT_NAME","BUTTON_COMPONENT_NAME","POPOVER_COMPONENT_NAME","LIST_BOX_COMPONENT_NAME"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,SAAS,eAAe,KAAY,EAAA;AA1BpC,EAAA,IAAA,EAAA,CAAA;AA2BE,EAAM,MAAA,EAAE,MAAM,KAAM,EAAA,GAAA,CAAI,4BAAM,UAAW,CAAAA,sCAAkB,CAAnC,KAAA,IAAA,GAAA,EAAA,GAAwC,EAAC,CAAA;AACjE,EAAAC,iBAAA,CAAY,EAAE,KAAA,EAAO,IAAM,EAAA,KAAA,EAAO,CAAA,CAAA;AAElC,EAAO,OAAA,IAAA,CAAA;AACT,CAAA;AAOa,MAAA,eAAA,GAAkB,CAAC,KAAgC,KAAA;AAC9D,EAAA,MAAM,EAAE,QAAA,EAAU,SAAW,EAAA,SAAA,EAAc,GAAA,KAAA,CAAA;AAC3C,EAAM,MAAA,WAAA,GAAc,YAAY,QAAW,GAAA,gBAAA,CAAA;AAC3C,EAAA,uBACGC,sBAAA,CAAA,aAAA,CAAAC,+BAAA,EAAA,EAAY,SACV,EAAA,EAAA,CAAC,EAAE,aAAA,EAAe,YAAa,EAAA,qBAC3BD,sBAAA,CAAA,aAAA,CAAAA,sBAAA,CAAA,QAAA,EAAA,IAAA,EAAA,aAAA,GAAgB,WAAc,GAAA,YAAa,CAElD,CAAA,CAAA;AAEJ,EAAA;AAEA,MAAM,WAAA,GAAcE,wBAAkB,QAAQ,CAAA,CAAA;AAM9C,MAAM,eAAA,GAAkB,CAAC,UAAmB,CAAA,CAAA;AAE5C,MAAM,EAAE,QAAA,EAAU,oBAAqB,EAAA,GACrCC,uCAA0B,eAAe,CAAA,CAAA;AAUpC,SAAS,WAAW,K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-aria-components";
|
|
3
3
|
import { HasControlContextData, Registerable } from "./utils";
|
|
4
|
+
import { WithVariants } from "./variant-utils";
|
|
4
5
|
export interface BaseSelectValueProps extends React.ComponentProps<typeof SelectValue> {
|
|
5
6
|
customize?: boolean;
|
|
6
7
|
}
|
|
@@ -8,9 +9,12 @@ export declare const BaseSelectValue: (props: BaseSelectValueProps) => React.JSX
|
|
|
8
9
|
export interface BaseSelectControlContextData {
|
|
9
10
|
itemIds: string[];
|
|
10
11
|
}
|
|
12
|
+
declare const SELECT_VARIANTS: "disabled"[];
|
|
11
13
|
export interface BaseSelectProps extends SelectProps<{}>, // NOTE: We don't need generic type here since we don't use items prop (that needs it). We just need to make the type checker happy
|
|
12
|
-
HasControlContextData<BaseSelectControlContextData> {
|
|
14
|
+
WithVariants<typeof SELECT_VARIANTS>, HasControlContextData<BaseSelectControlContextData> {
|
|
13
15
|
children?: React.ReactNode;
|
|
16
|
+
className?: string;
|
|
14
17
|
}
|
|
15
18
|
export declare function BaseSelect(props: BaseSelectProps): React.JSX.Element;
|
|
16
19
|
export declare function registerSelect(loader?: Registerable): void;
|
|
20
|
+
export {};
|
|
@@ -7,10 +7,10 @@ import { BUTTON_COMPONENT_NAME } from './registerButton.esm.js';
|
|
|
7
7
|
import { LABEL_COMPONENT_NAME } from './registerLabel.esm.js';
|
|
8
8
|
import { POPOVER_COMPONENT_NAME } from './registerPopover.esm.js';
|
|
9
9
|
import { e as extractPlasmicDataProps, r as registerComponentHelper, u as useAutoOpen, a as makeComponentName } from './utils-25448fbd.esm.js';
|
|
10
|
+
import { p as pickAriaComponentVariants } from './variant-utils-7c2ea202.esm.js';
|
|
10
11
|
import './registerListBoxItem.esm.js';
|
|
11
12
|
import './registerDescription.esm.js';
|
|
12
13
|
import './registerText.esm.js';
|
|
13
|
-
import './variant-utils-7c2ea202.esm.js';
|
|
14
14
|
import './registerSection.esm.js';
|
|
15
15
|
import '@react-aria/utils';
|
|
16
16
|
import '@plasmicapp/host';
|
|
@@ -47,6 +47,8 @@ const BaseSelectValue = (props) => {
|
|
|
47
47
|
return /* @__PURE__ */ React.createElement(SelectValue, { className }, ({ isPlaceholder, selectedText }) => /* @__PURE__ */ React.createElement(React.Fragment, null, isPlaceholder ? placeholder : selectedText));
|
|
48
48
|
};
|
|
49
49
|
const SELECT_NAME = makeComponentName("select");
|
|
50
|
+
const SELECT_VARIANTS = ["disabled"];
|
|
51
|
+
const { variants: SELECT_VARIANTS_DATA } = pickAriaComponentVariants(SELECT_VARIANTS);
|
|
50
52
|
function BaseSelect(props) {
|
|
51
53
|
const {
|
|
52
54
|
selectedKey,
|
|
@@ -60,9 +62,10 @@ function BaseSelect(props) {
|
|
|
60
62
|
disabledKeys,
|
|
61
63
|
name,
|
|
62
64
|
setControlContextData,
|
|
65
|
+
plasmicUpdateVariant,
|
|
63
66
|
"aria-label": ariaLabel
|
|
64
67
|
} = props;
|
|
65
|
-
|
|
68
|
+
const idManager = useMemo(() => new ListBoxItemIdManager(), []);
|
|
66
69
|
useEffect(() => {
|
|
67
70
|
idManager.subscribe((ids) => {
|
|
68
71
|
setControlContextData == null ? void 0 : setControlContextData({
|
|
@@ -70,6 +73,11 @@ function BaseSelect(props) {
|
|
|
70
73
|
});
|
|
71
74
|
});
|
|
72
75
|
}, []);
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
plasmicUpdateVariant == null ? void 0 : plasmicUpdateVariant({
|
|
78
|
+
disabled: isDisabled
|
|
79
|
+
});
|
|
80
|
+
}, [isDisabled, plasmicUpdateVariant]);
|
|
73
81
|
return /* @__PURE__ */ React.createElement(
|
|
74
82
|
Select,
|
|
75
83
|
__spreadValues({
|
|
@@ -126,6 +134,7 @@ function registerSelect(loader) {
|
|
|
126
134
|
displayName: "Aria Select",
|
|
127
135
|
importPath: "@plasmicpkgs/react-aria/skinny/registerSelect",
|
|
128
136
|
importName: "BaseSelect",
|
|
137
|
+
variants: SELECT_VARIANTS_DATA,
|
|
129
138
|
props: __spreadProps(__spreadValues({}, getCommonProps("Select", [
|
|
130
139
|
"name",
|
|
131
140
|
"aria-label",
|