@plasmicpkgs/react-aria 0.0.83 → 0.0.85
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 +123 -120
- package/dist/react-aria.esm.js.map +1 -1
- package/dist/react-aria.js +122 -119
- package/dist/react-aria.js.map +1 -1
- package/dist/registerInput.d.ts +3 -2
- package/dist/registerListBox.d.ts +5 -1
- package/dist/registerSelect.d.ts +1 -1
- package/dist/registerTextArea.d.ts +3 -2
- package/package.json +2 -2
- package/skinny/registerButton.cjs.js +1 -1
- package/skinny/registerButton.esm.js +1 -1
- package/skinny/registerCheckbox.cjs.js +1 -1
- package/skinny/registerCheckbox.esm.js +1 -1
- package/skinny/registerCheckboxGroup.cjs.js +1 -1
- package/skinny/registerCheckboxGroup.esm.js +1 -1
- package/skinny/registerComboBox.cjs.js +20 -25
- package/skinny/registerComboBox.cjs.js.map +1 -1
- package/skinny/registerComboBox.esm.js +21 -26
- package/skinny/registerComboBox.esm.js.map +1 -1
- package/skinny/registerDialogTrigger.cjs.js +1 -1
- package/skinny/registerDialogTrigger.esm.js +1 -1
- package/skinny/registerInput.cjs.js +27 -44
- package/skinny/registerInput.cjs.js.map +1 -1
- package/skinny/registerInput.d.ts +3 -2
- package/skinny/registerInput.esm.js +28 -45
- package/skinny/registerInput.esm.js.map +1 -1
- package/skinny/{registerListBox-b47231d8.cjs.js → registerListBox-44088cfc.cjs.js} +23 -4
- package/skinny/registerListBox-44088cfc.cjs.js.map +1 -0
- package/skinny/{registerListBox-d5efc5da.esm.js → registerListBox-da15518f.esm.js} +24 -5
- package/skinny/registerListBox-da15518f.esm.js.map +1 -0
- package/skinny/registerListBox.cjs.js +2 -2
- package/skinny/registerListBox.d.ts +5 -1
- package/skinny/registerListBox.esm.js +2 -2
- package/skinny/registerListBoxItem.cjs.js +1 -1
- package/skinny/registerListBoxItem.esm.js +1 -1
- package/skinny/registerPopover.cjs.js +1 -1
- package/skinny/registerPopover.esm.js +1 -1
- package/skinny/registerRadio.cjs.js +1 -1
- package/skinny/registerRadio.esm.js +1 -1
- package/skinny/registerRadioGroup.cjs.js +1 -1
- package/skinny/registerRadioGroup.esm.js +1 -1
- package/skinny/registerSection.cjs.js +2 -2
- package/skinny/registerSection.esm.js +2 -2
- package/skinny/registerSelect.cjs.js +23 -9
- package/skinny/registerSelect.cjs.js.map +1 -1
- package/skinny/registerSelect.d.ts +1 -1
- package/skinny/registerSelect.esm.js +24 -10
- package/skinny/registerSelect.esm.js.map +1 -1
- package/skinny/registerSlider.cjs.js +1 -1
- package/skinny/registerSlider.esm.js +1 -1
- package/skinny/registerSliderOutput.cjs.js +1 -1
- package/skinny/registerSliderOutput.esm.js +1 -1
- package/skinny/registerSliderThumb.cjs.js +1 -1
- package/skinny/registerSliderThumb.esm.js +1 -1
- package/skinny/registerSliderTrack.cjs.js +1 -1
- package/skinny/registerSliderTrack.esm.js +1 -1
- package/skinny/registerSwitch.cjs.js +1 -1
- package/skinny/registerSwitch.esm.js +1 -1
- package/skinny/registerTextArea.cjs.js +23 -30
- package/skinny/registerTextArea.cjs.js.map +1 -1
- package/skinny/registerTextArea.d.ts +3 -2
- package/skinny/registerTextArea.esm.js +24 -31
- package/skinny/registerTextArea.esm.js.map +1 -1
- package/skinny/registerTextField.cjs.js +1 -1
- package/skinny/registerTextField.esm.js +1 -1
- package/skinny/registerTooltip.cjs.js +1 -1
- package/skinny/registerTooltip.esm.js +1 -1
- package/skinny/{variant-utils-8cb38f8f.cjs.js → variant-utils-0ad70db8.cjs.js} +5 -5
- package/skinny/{variant-utils-8cb38f8f.cjs.js.map → variant-utils-0ad70db8.cjs.js.map} +1 -1
- package/skinny/{variant-utils-7c2ea202.esm.js → variant-utils-4405ebb0.esm.js} +5 -5
- package/skinny/{variant-utils-7c2ea202.esm.js.map → variant-utils-4405ebb0.esm.js.map} +1 -1
- package/skinny/registerListBox-b47231d8.cjs.js.map +0 -1
- package/skinny/registerListBox-d5efc5da.esm.js.map +0 -1
package/dist/registerInput.d.ts
CHANGED
|
@@ -2,10 +2,11 @@ import React, { ChangeEvent } from "react";
|
|
|
2
2
|
import type { InputProps } from "react-aria-components";
|
|
3
3
|
import { CodeComponentMetaOverrides, HasControlContextData, Registerable } from "./utils";
|
|
4
4
|
import { WithVariants } from "./variant-utils";
|
|
5
|
-
declare const INPUT_VARIANTS: ("disabled" | "hovered" | "focused")[];
|
|
6
|
-
export interface BaseInputProps extends Omit<InputProps, "autoComplete">, HasControlContextData, WithVariants<typeof INPUT_VARIANTS> {
|
|
5
|
+
declare const INPUT_VARIANTS: ("disabled" | "hovered" | "focused" | "focusVisible")[];
|
|
6
|
+
export interface BaseInputProps extends Omit<InputProps, "autoComplete" | "className">, HasControlContextData, WithVariants<typeof INPUT_VARIANTS> {
|
|
7
7
|
autoComplete?: string[];
|
|
8
8
|
isUncontrolled?: boolean;
|
|
9
|
+
className?: string;
|
|
9
10
|
}
|
|
10
11
|
export declare const inputHelpers: {
|
|
11
12
|
states: {
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Key, ListBox } from "react-aria-components";
|
|
3
3
|
import { CodeComponentMetaOverrides, HasControlContextData, Registerable } from "./utils";
|
|
4
|
+
import { WithVariants } from "./variant-utils";
|
|
4
5
|
export interface BaseListBoxControlContextData {
|
|
5
6
|
itemIds: string[];
|
|
6
7
|
isStandalone: boolean;
|
|
7
8
|
}
|
|
8
|
-
|
|
9
|
+
declare const LISTBOX_VARIANTS: ("focused" | "focusVisible")[];
|
|
10
|
+
export interface BaseListBoxProps extends Omit<React.ComponentProps<typeof ListBox>, "selectedKeys" | "defaultSelectedKeys" | "className">, HasControlContextData<BaseListBoxControlContextData>, WithVariants<typeof LISTBOX_VARIANTS> {
|
|
9
11
|
children?: React.ReactNode;
|
|
10
12
|
selectedKeys?: string | string[] | undefined;
|
|
11
13
|
defaultSelectedKeys?: string | string[] | undefined;
|
|
14
|
+
className?: string;
|
|
12
15
|
}
|
|
13
16
|
export declare const listboxHelpers: {
|
|
14
17
|
states: {
|
|
@@ -20,3 +23,4 @@ export declare const listboxHelpers: {
|
|
|
20
23
|
export declare function BaseListBox(props: BaseListBoxProps): React.JSX.Element;
|
|
21
24
|
export declare const LIST_BOX_COMPONENT_NAME: string;
|
|
22
25
|
export declare function registerListBox(loader?: Registerable, overrides?: CodeComponentMetaOverrides<typeof BaseListBox>): void;
|
|
26
|
+
export {};
|
package/dist/registerSelect.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export declare const BaseSelectValue: (props: BaseSelectValueProps) => React.JSX
|
|
|
9
9
|
export interface BaseSelectControlContextData {
|
|
10
10
|
itemIds: string[];
|
|
11
11
|
}
|
|
12
|
-
declare const SELECT_VARIANTS: "disabled"[];
|
|
12
|
+
declare const SELECT_VARIANTS: ("disabled" | "focused" | "focusVisible")[];
|
|
13
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
|
|
14
14
|
WithVariants<typeof SELECT_VARIANTS>, HasControlContextData<BaseSelectControlContextData> {
|
|
15
15
|
children?: React.ReactNode;
|
|
@@ -2,8 +2,9 @@ import React, { ChangeEvent } from "react";
|
|
|
2
2
|
import type { TextAreaProps } from "react-aria-components";
|
|
3
3
|
import { CodeComponentMetaOverrides, HasControlContextData, Registerable } from "./utils";
|
|
4
4
|
import { WithVariants } from "./variant-utils";
|
|
5
|
-
declare const TEXTAREA_VARIANTS: ("disabled" | "hovered" | "focused")[];
|
|
6
|
-
export interface BaseTextAreaProps extends TextAreaProps, HasControlContextData, WithVariants<typeof TEXTAREA_VARIANTS> {
|
|
5
|
+
declare const TEXTAREA_VARIANTS: ("disabled" | "hovered" | "focused" | "focusVisible")[];
|
|
6
|
+
export interface BaseTextAreaProps extends Omit<TextAreaProps, "className">, HasControlContextData, WithVariants<typeof TEXTAREA_VARIANTS> {
|
|
7
|
+
className?: string;
|
|
7
8
|
}
|
|
8
9
|
export declare const inputHelpers: {
|
|
9
10
|
states: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plasmicpkgs/react-aria",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.85",
|
|
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": "8c4c85671384c588a57b5dc182774558458b453c"
|
|
78
78
|
}
|
|
@@ -5,7 +5,7 @@ var reactAria = require('react-aria');
|
|
|
5
5
|
var reactAriaComponents = require('react-aria-components');
|
|
6
6
|
var common = require('./common-1e5dba7d.cjs.js');
|
|
7
7
|
var utils = require('./utils-d1c8094f.cjs.js');
|
|
8
|
-
var variantUtils = require('./variant-utils-
|
|
8
|
+
var variantUtils = require('./variant-utils-0ad70db8.cjs.js');
|
|
9
9
|
require('@plasmicapp/host');
|
|
10
10
|
require('@plasmicapp/host/registerComponent');
|
|
11
11
|
|
|
@@ -3,7 +3,7 @@ import { mergeProps } from 'react-aria';
|
|
|
3
3
|
import { Button } from 'react-aria-components';
|
|
4
4
|
import { g as getCommonProps } from './common-a8f4a4b1.esm.js';
|
|
5
5
|
import { a as makeComponentName, r as registerComponentHelper } from './utils-41b3d43b.esm.js';
|
|
6
|
-
import { p as pickAriaComponentVariants } from './variant-utils-
|
|
6
|
+
import { p as pickAriaComponentVariants } from './variant-utils-4405ebb0.esm.js';
|
|
7
7
|
import '@plasmicapp/host';
|
|
8
8
|
import '@plasmicapp/host/registerComponent';
|
|
9
9
|
|
|
@@ -5,7 +5,7 @@ var reactAriaComponents = require('react-aria-components');
|
|
|
5
5
|
var common = require('./common-1e5dba7d.cjs.js');
|
|
6
6
|
var contexts = require('./contexts-6d0cb2b1.cjs.js');
|
|
7
7
|
var utils = require('./utils-d1c8094f.cjs.js');
|
|
8
|
-
var variantUtils = require('./variant-utils-
|
|
8
|
+
var variantUtils = require('./variant-utils-0ad70db8.cjs.js');
|
|
9
9
|
require('@plasmicapp/host');
|
|
10
10
|
require('@plasmicapp/host/registerComponent');
|
|
11
11
|
|
|
@@ -3,7 +3,7 @@ import { Checkbox } from 'react-aria-components';
|
|
|
3
3
|
import { g as getCommonProps, h as hasParent } from './common-a8f4a4b1.esm.js';
|
|
4
4
|
import { P as PlasmicCheckboxGroupContext } from './contexts-5cb81c2f.esm.js';
|
|
5
5
|
import { a as makeComponentName, r as registerComponentHelper } from './utils-41b3d43b.esm.js';
|
|
6
|
-
import { p as pickAriaComponentVariants } from './variant-utils-
|
|
6
|
+
import { p as pickAriaComponentVariants } from './variant-utils-4405ebb0.esm.js';
|
|
7
7
|
import '@plasmicapp/host';
|
|
8
8
|
import '@plasmicapp/host/registerComponent';
|
|
9
9
|
|
|
@@ -8,7 +8,7 @@ var registerCheckbox = require('./registerCheckbox.cjs.js');
|
|
|
8
8
|
var registerDescription = require('./registerDescription.cjs.js');
|
|
9
9
|
var registerLabel = require('./registerLabel.cjs.js');
|
|
10
10
|
var utils = require('./utils-d1c8094f.cjs.js');
|
|
11
|
-
var variantUtils = require('./variant-utils-
|
|
11
|
+
var variantUtils = require('./variant-utils-0ad70db8.cjs.js');
|
|
12
12
|
require('./registerText.cjs.js');
|
|
13
13
|
require('@plasmicapp/host');
|
|
14
14
|
require('@plasmicapp/host/registerComponent');
|
|
@@ -6,7 +6,7 @@ import { CHECKBOX_COMPONENT_NAME, makeDefaultCheckboxChildren } from './register
|
|
|
6
6
|
import { DESCRIPTION_COMPONENT_NAME } from './registerDescription.esm.js';
|
|
7
7
|
import { LABEL_COMPONENT_NAME } from './registerLabel.esm.js';
|
|
8
8
|
import { m as makeChildComponentName, r as registerComponentHelper, a as makeComponentName } from './utils-41b3d43b.esm.js';
|
|
9
|
-
import { p as pickAriaComponentVariants } from './variant-utils-
|
|
9
|
+
import { p as pickAriaComponentVariants } from './variant-utils-4405ebb0.esm.js';
|
|
10
10
|
import './registerText.esm.js';
|
|
11
11
|
import '@plasmicapp/host';
|
|
12
12
|
import '@plasmicapp/host/registerComponent';
|
|
@@ -4,13 +4,13 @@ var React = require('react');
|
|
|
4
4
|
var reactAriaComponents = require('react-aria-components');
|
|
5
5
|
var common = require('./common-1e5dba7d.cjs.js');
|
|
6
6
|
var contexts = require('./contexts-6d0cb2b1.cjs.js');
|
|
7
|
-
var registerSection = require('./registerListBox-
|
|
7
|
+
var registerSection = require('./registerListBox-44088cfc.cjs.js');
|
|
8
8
|
var registerButton = require('./registerButton.cjs.js');
|
|
9
9
|
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-d1c8094f.cjs.js');
|
|
13
|
-
var variantUtils = require('./variant-utils-
|
|
13
|
+
var variantUtils = require('./variant-utils-0ad70db8.cjs.js');
|
|
14
14
|
require('./registerListBoxItem.cjs.js');
|
|
15
15
|
require('./registerDescription.cjs.js');
|
|
16
16
|
require('./registerText.cjs.js');
|
|
@@ -69,16 +69,23 @@ function BaseComboBox(props) {
|
|
|
69
69
|
setControlContextData,
|
|
70
70
|
plasmicUpdateVariant,
|
|
71
71
|
className,
|
|
72
|
-
isDisabled,
|
|
73
72
|
isOpen: _isOpen
|
|
74
73
|
} = _a, rest = __objRest(_a, [
|
|
75
74
|
"children",
|
|
76
75
|
"setControlContextData",
|
|
77
76
|
"plasmicUpdateVariant",
|
|
78
77
|
"className",
|
|
79
|
-
"isDisabled",
|
|
80
78
|
"isOpen"
|
|
81
79
|
]);
|
|
80
|
+
const classNameProp = React.useCallback(
|
|
81
|
+
({ isDisabled }) => {
|
|
82
|
+
plasmicUpdateVariant == null ? void 0 : plasmicUpdateVariant({
|
|
83
|
+
disabled: isDisabled
|
|
84
|
+
});
|
|
85
|
+
return className != null ? className : "";
|
|
86
|
+
},
|
|
87
|
+
[className, plasmicUpdateVariant]
|
|
88
|
+
);
|
|
82
89
|
const idManager = React.useMemo(() => new registerSection.ListBoxItemIdManager(), []);
|
|
83
90
|
React.useEffect(() => {
|
|
84
91
|
idManager.subscribe((ids) => {
|
|
@@ -87,27 +94,15 @@ function BaseComboBox(props) {
|
|
|
87
94
|
});
|
|
88
95
|
});
|
|
89
96
|
}, []);
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
__spreadValues({
|
|
98
|
-
|
|
99
|
-
className
|
|
100
|
-
}, rest),
|
|
101
|
-
/* @__PURE__ */ React__default.default.createElement(contexts.PlasmicPopoverTriggerContext.Provider, { value: true }, /* @__PURE__ */ React__default.default.createElement(
|
|
102
|
-
contexts.PlasmicListBoxContext.Provider,
|
|
103
|
-
{
|
|
104
|
-
value: {
|
|
105
|
-
idManager
|
|
106
|
-
}
|
|
107
|
-
},
|
|
108
|
-
/* @__PURE__ */ React__default.default.createElement(contexts.PlasmicInputContext.Provider, { value: { isUncontrolled: true } }, /* @__PURE__ */ React__default.default.createElement(ComboboxAutoOpen, __spreadValues({}, props)), children)
|
|
109
|
-
))
|
|
110
|
-
);
|
|
97
|
+
return /* @__PURE__ */ React__default.default.createElement(reactAriaComponents.ComboBox, __spreadValues({ className: classNameProp }, rest), /* @__PURE__ */ React__default.default.createElement(contexts.PlasmicPopoverTriggerContext.Provider, { value: true }, /* @__PURE__ */ React__default.default.createElement(
|
|
98
|
+
contexts.PlasmicListBoxContext.Provider,
|
|
99
|
+
{
|
|
100
|
+
value: {
|
|
101
|
+
idManager
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
/* @__PURE__ */ React__default.default.createElement(contexts.PlasmicInputContext.Provider, { value: { isUncontrolled: true } }, /* @__PURE__ */ React__default.default.createElement(ComboboxAutoOpen, __spreadValues({}, props)), children)
|
|
105
|
+
)));
|
|
111
106
|
}
|
|
112
107
|
function registerComboBox(loader) {
|
|
113
108
|
utils.registerComponentHelper(loader, BaseComboBox, {
|
|
@@ -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 PlasmicPopoverTriggerContext,\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 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 <PlasmicPopoverTriggerContext.Provider value={true}>\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 </PlasmicPopoverTriggerContext.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 \"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 styles: {\n padding: 0,\n },\n children: [\n {\n type: \"component\",\n name: INPUT_COMPONENT_NAME,\n styles: {\n width: \"100%\",\n borderRightWidth: 0,\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 display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n padding: 0,\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 width: \"unset\",\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","PlasmicPopoverTriggerContext","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,CAAA,CAAA;AAsB7C,SAAS,iBAAiB,KAAY,EAAA;AA1DtC,EAAA,IAAA,EAAA,CAAA;AA2DE,EAAM,MAAA,EAAE,MAAM,KAAM,EAAA,GAAA,CAAI,4BAAM,UAAW,CAAAC,wCAAoB,C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A,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;;;;;"}
|
|
1
|
+
{"version":3,"file":"registerComboBox.cjs.js","sources":["../src/registerComboBox.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useMemo } from \"react\";\nimport {\n ComboBox,\n ComboBoxProps,\n ComboBoxRenderProps,\n ComboBoxStateContext,\n} from \"react-aria-components\";\nimport { getCommonProps } from \"./common\";\nimport {\n PlasmicInputContext,\n PlasmicListBoxContext,\n PlasmicPopoverTriggerContext,\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 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 isOpen: _isOpen, // uncontrolled if not selected in canvas/edit mode\n ...rest\n } = props;\n\n const classNameProp = useCallback(\n ({ isDisabled }: ComboBoxRenderProps) => {\n plasmicUpdateVariant?.({\n disabled: isDisabled,\n });\n return className ?? \"\";\n },\n [className, plasmicUpdateVariant]\n );\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 className={classNameProp} {...rest}>\n <PlasmicPopoverTriggerContext.Provider value={true}>\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 </PlasmicPopoverTriggerContext.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 \"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 styles: {\n padding: 0,\n },\n children: [\n {\n type: \"component\",\n name: INPUT_COMPONENT_NAME,\n styles: {\n width: \"100%\",\n borderRightWidth: 0,\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 display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n padding: 0,\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 width: \"unset\",\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","useCallback","useMemo","ListBoxItemIdManager","useEffect","React","ComboBox","PlasmicPopoverTriggerContext","PlasmicListBoxContext","PlasmicInputContext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,YAAc,EAAA,SAAA;AAAA,OAChB;AAAA,KACF;AAAA,IACA,UAAY,EAAA,IAAA;AAAA,GACb,CAAA,CAAA;AACH;;;;;"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import React, { useMemo, useEffect } from 'react';
|
|
1
|
+
import React, { useCallback, useMemo, useEffect } from 'react';
|
|
2
2
|
import { ComboBox, ComboBoxStateContext } from 'react-aria-components';
|
|
3
3
|
import { g as getCommonProps } from './common-a8f4a4b1.esm.js';
|
|
4
4
|
import { a as PlasmicPopoverTriggerContext, b as PlasmicListBoxContext, c as PlasmicInputContext } from './contexts-5cb81c2f.esm.js';
|
|
5
|
-
import { L as ListBoxItemIdManager, a as LIST_BOX_COMPONENT_NAME } from './registerListBox-
|
|
5
|
+
import { L as ListBoxItemIdManager, a as LIST_BOX_COMPONENT_NAME } from './registerListBox-da15518f.esm.js';
|
|
6
6
|
import { BUTTON_COMPONENT_NAME } from './registerButton.esm.js';
|
|
7
7
|
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-41b3d43b.esm.js';
|
|
11
|
-
import { p as pickAriaComponentVariants } from './variant-utils-
|
|
11
|
+
import { p as pickAriaComponentVariants } from './variant-utils-4405ebb0.esm.js';
|
|
12
12
|
import './registerListBoxItem.esm.js';
|
|
13
13
|
import './registerDescription.esm.js';
|
|
14
14
|
import './registerText.esm.js';
|
|
@@ -63,16 +63,23 @@ function BaseComboBox(props) {
|
|
|
63
63
|
setControlContextData,
|
|
64
64
|
plasmicUpdateVariant,
|
|
65
65
|
className,
|
|
66
|
-
isDisabled,
|
|
67
66
|
isOpen: _isOpen
|
|
68
67
|
} = _a, rest = __objRest(_a, [
|
|
69
68
|
"children",
|
|
70
69
|
"setControlContextData",
|
|
71
70
|
"plasmicUpdateVariant",
|
|
72
71
|
"className",
|
|
73
|
-
"isDisabled",
|
|
74
72
|
"isOpen"
|
|
75
73
|
]);
|
|
74
|
+
const classNameProp = useCallback(
|
|
75
|
+
({ isDisabled }) => {
|
|
76
|
+
plasmicUpdateVariant == null ? void 0 : plasmicUpdateVariant({
|
|
77
|
+
disabled: isDisabled
|
|
78
|
+
});
|
|
79
|
+
return className != null ? className : "";
|
|
80
|
+
},
|
|
81
|
+
[className, plasmicUpdateVariant]
|
|
82
|
+
);
|
|
76
83
|
const idManager = useMemo(() => new ListBoxItemIdManager(), []);
|
|
77
84
|
useEffect(() => {
|
|
78
85
|
idManager.subscribe((ids) => {
|
|
@@ -81,27 +88,15 @@ function BaseComboBox(props) {
|
|
|
81
88
|
});
|
|
82
89
|
});
|
|
83
90
|
}, []);
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
__spreadValues({
|
|
92
|
-
|
|
93
|
-
className
|
|
94
|
-
}, rest),
|
|
95
|
-
/* @__PURE__ */ React.createElement(PlasmicPopoverTriggerContext.Provider, { value: true }, /* @__PURE__ */ React.createElement(
|
|
96
|
-
PlasmicListBoxContext.Provider,
|
|
97
|
-
{
|
|
98
|
-
value: {
|
|
99
|
-
idManager
|
|
100
|
-
}
|
|
101
|
-
},
|
|
102
|
-
/* @__PURE__ */ React.createElement(PlasmicInputContext.Provider, { value: { isUncontrolled: true } }, /* @__PURE__ */ React.createElement(ComboboxAutoOpen, __spreadValues({}, props)), children)
|
|
103
|
-
))
|
|
104
|
-
);
|
|
91
|
+
return /* @__PURE__ */ React.createElement(ComboBox, __spreadValues({ className: classNameProp }, rest), /* @__PURE__ */ React.createElement(PlasmicPopoverTriggerContext.Provider, { value: true }, /* @__PURE__ */ React.createElement(
|
|
92
|
+
PlasmicListBoxContext.Provider,
|
|
93
|
+
{
|
|
94
|
+
value: {
|
|
95
|
+
idManager
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
/* @__PURE__ */ React.createElement(PlasmicInputContext.Provider, { value: { isUncontrolled: true } }, /* @__PURE__ */ React.createElement(ComboboxAutoOpen, __spreadValues({}, props)), children)
|
|
99
|
+
)));
|
|
105
100
|
}
|
|
106
101
|
function registerComboBox(loader) {
|
|
107
102
|
registerComponentHelper(loader, BaseComboBox, {
|
|
@@ -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 PlasmicPopoverTriggerContext,\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 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 <PlasmicPopoverTriggerContext.Provider value={true}>\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 </PlasmicPopoverTriggerContext.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 \"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 styles: {\n padding: 0,\n },\n children: [\n {\n type: \"component\",\n name: INPUT_COMPONENT_NAME,\n styles: {\n width: \"100%\",\n borderRightWidth: 0,\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 display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n padding: 0,\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 width: \"unset\",\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;AAsB7C,SAAS,iBAAiB,KAAY,EAAA;AA1DtC,EAAA,IAAA,EAAA,CAAA;AA2DE,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;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AA,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
|
+
{"version":3,"file":"registerComboBox.esm.js","sources":["../src/registerComboBox.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useMemo } from \"react\";\nimport {\n ComboBox,\n ComboBoxProps,\n ComboBoxRenderProps,\n ComboBoxStateContext,\n} from \"react-aria-components\";\nimport { getCommonProps } from \"./common\";\nimport {\n PlasmicInputContext,\n PlasmicListBoxContext,\n PlasmicPopoverTriggerContext,\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 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 isOpen: _isOpen, // uncontrolled if not selected in canvas/edit mode\n ...rest\n } = props;\n\n const classNameProp = useCallback(\n ({ isDisabled }: ComboBoxRenderProps) => {\n plasmicUpdateVariant?.({\n disabled: isDisabled,\n });\n return className ?? \"\";\n },\n [className, plasmicUpdateVariant]\n );\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 className={classNameProp} {...rest}>\n <PlasmicPopoverTriggerContext.Provider value={true}>\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 </PlasmicPopoverTriggerContext.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 \"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 styles: {\n padding: 0,\n },\n children: [\n {\n type: \"component\",\n name: INPUT_COMPONENT_NAME,\n styles: {\n width: \"100%\",\n borderRightWidth: 0,\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 display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n padding: 0,\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 width: \"unset\",\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,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;AAsB7C,SAAS,iBAAiB,KAAY,EAAA;AA3DtC,EAAA,IAAA,EAAA,CAAA;AA4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A,OAAA;AAAA,iBACT;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,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;;;;"}
|
|
@@ -9,7 +9,7 @@ var registerModal = require('./registerModal.cjs.js');
|
|
|
9
9
|
var utils = require('./utils-d1c8094f.cjs.js');
|
|
10
10
|
require('react-aria');
|
|
11
11
|
require('./common-1e5dba7d.cjs.js');
|
|
12
|
-
require('./variant-utils-
|
|
12
|
+
require('./variant-utils-0ad70db8.cjs.js');
|
|
13
13
|
require('./registerHeading.cjs.js');
|
|
14
14
|
require('@plasmicapp/host/registerComponent');
|
|
15
15
|
|
|
@@ -7,7 +7,7 @@ import { MODAL_COMPONENT_NAME } from './registerModal.esm.js';
|
|
|
7
7
|
import { r as registerComponentHelper, a as makeComponentName } from './utils-41b3d43b.esm.js';
|
|
8
8
|
import 'react-aria';
|
|
9
9
|
import './common-a8f4a4b1.esm.js';
|
|
10
|
-
import './variant-utils-
|
|
10
|
+
import './variant-utils-4405ebb0.esm.js';
|
|
11
11
|
import './registerHeading.esm.js';
|
|
12
12
|
import '@plasmicapp/host/registerComponent';
|
|
13
13
|
|
|
@@ -6,7 +6,7 @@ var reactAriaComponents = require('react-aria-components');
|
|
|
6
6
|
var common = require('./common-1e5dba7d.cjs.js');
|
|
7
7
|
var contexts = require('./contexts-6d0cb2b1.cjs.js');
|
|
8
8
|
var utils = require('./utils-d1c8094f.cjs.js');
|
|
9
|
-
var variantUtils = require('./variant-utils-
|
|
9
|
+
var variantUtils = require('./variant-utils-0ad70db8.cjs.js');
|
|
10
10
|
require('@plasmicapp/host');
|
|
11
11
|
require('@plasmicapp/host/registerComponent');
|
|
12
12
|
|
|
@@ -44,6 +44,7 @@ var __objRest = (source, exclude) => {
|
|
|
44
44
|
};
|
|
45
45
|
const INPUT_VARIANTS = [
|
|
46
46
|
"focused",
|
|
47
|
+
"focusVisible",
|
|
47
48
|
"hovered",
|
|
48
49
|
"disabled"
|
|
49
50
|
];
|
|
@@ -58,65 +59,47 @@ const inputHelpers = {
|
|
|
58
59
|
}
|
|
59
60
|
};
|
|
60
61
|
function BaseInput(props) {
|
|
61
|
-
var _b;
|
|
62
62
|
const _a = props, {
|
|
63
63
|
plasmicUpdateVariant,
|
|
64
64
|
setControlContextData,
|
|
65
|
-
disabled,
|
|
66
65
|
autoComplete,
|
|
67
|
-
value
|
|
66
|
+
value,
|
|
67
|
+
className
|
|
68
68
|
} = _a, rest = __objRest(_a, [
|
|
69
69
|
"plasmicUpdateVariant",
|
|
70
70
|
"setControlContextData",
|
|
71
|
-
"disabled",
|
|
72
71
|
"autoComplete",
|
|
73
|
-
"value"
|
|
72
|
+
"value",
|
|
73
|
+
"className"
|
|
74
74
|
]);
|
|
75
75
|
const textFieldContext = React__default.default.useContext(contexts.PlasmicTextFieldContext);
|
|
76
76
|
const context = React__default.default.useContext(contexts.PlasmicInputContext);
|
|
77
77
|
setControlContextData == null ? void 0 : setControlContextData({
|
|
78
78
|
parent: textFieldContext
|
|
79
79
|
});
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
80
|
+
const classNameProp = React.useCallback(
|
|
81
|
+
({
|
|
82
|
+
isDisabled,
|
|
83
|
+
isFocusVisible,
|
|
84
|
+
isFocused,
|
|
85
|
+
isHovered
|
|
86
|
+
}) => {
|
|
87
|
+
plasmicUpdateVariant == null ? void 0 : plasmicUpdateVariant({
|
|
88
|
+
disabled: isDisabled,
|
|
89
|
+
focused: isFocused,
|
|
90
|
+
focusVisible: isFocusVisible,
|
|
91
|
+
hovered: isHovered
|
|
92
|
+
});
|
|
93
|
+
return className != null ? className : "";
|
|
84
94
|
},
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* While react-aria internally does the merging of the disabled prop,
|
|
88
|
-
* we need to explicity do it here, because react-aria does it behind the scenes,
|
|
89
|
-
* whereas we need the calculated value of the disabled prop to be able to update the "disabled" CC variant.
|
|
90
|
-
* */
|
|
91
|
-
disabled: (_b = textFieldContext == null ? void 0 : textFieldContext.isDisabled) != null ? _b : disabled
|
|
92
|
-
}
|
|
93
|
-
);
|
|
94
|
-
React.useEffect(() => {
|
|
95
|
-
plasmicUpdateVariant == null ? void 0 : plasmicUpdateVariant({
|
|
96
|
-
disabled: mergedProps.disabled
|
|
97
|
-
});
|
|
98
|
-
}, [mergedProps.disabled, plasmicUpdateVariant]);
|
|
99
|
-
return /* @__PURE__ */ React__default.default.createElement(
|
|
100
|
-
reactAriaComponents.Input,
|
|
101
|
-
__spreadValues({
|
|
102
|
-
autoComplete: common.resolveAutoComplete(autoComplete),
|
|
103
|
-
onHoverChange: (isHovered) => {
|
|
104
|
-
plasmicUpdateVariant == null ? void 0 : plasmicUpdateVariant({
|
|
105
|
-
hovered: isHovered
|
|
106
|
-
});
|
|
107
|
-
},
|
|
108
|
-
onFocus: () => {
|
|
109
|
-
plasmicUpdateVariant == null ? void 0 : plasmicUpdateVariant({
|
|
110
|
-
focused: true
|
|
111
|
-
});
|
|
112
|
-
},
|
|
113
|
-
onBlur: () => {
|
|
114
|
-
plasmicUpdateVariant == null ? void 0 : plasmicUpdateVariant({
|
|
115
|
-
focused: false
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
}, mergedProps)
|
|
95
|
+
[className, plasmicUpdateVariant]
|
|
119
96
|
);
|
|
97
|
+
const mergedProps = reactAria.mergeProps(rest, {
|
|
98
|
+
value: (context == null ? void 0 : context.isUncontrolled) ? void 0 : value,
|
|
99
|
+
autoComplete: common.resolveAutoComplete(autoComplete),
|
|
100
|
+
className: classNameProp
|
|
101
|
+
});
|
|
102
|
+
return /* @__PURE__ */ React__default.default.createElement(reactAriaComponents.Input, __spreadValues({}, mergedProps));
|
|
120
103
|
}
|
|
121
104
|
const INPUT_COMPONENT_NAME = utils.makeComponentName("input");
|
|
122
105
|
function registerInput(loader, overrides) {
|