@plasmicpkgs/react-aria 0.0.120 → 0.0.122
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/OptionsItemIdManager.d.ts +18 -0
- package/dist/react-aria.esm.js +151 -184
- package/dist/react-aria.esm.js.map +1 -1
- package/dist/react-aria.js +150 -183
- package/dist/react-aria.js.map +1 -1
- package/dist/registerCheckboxGroup.d.ts +2 -5
- package/dist/registerComboBox.d.ts +2 -5
- package/dist/registerListBox.d.ts +2 -3
- package/dist/registerRadioGroup.d.ts +2 -5
- package/dist/registerSelect.d.ts +2 -5
- package/dist/utils.d.ts +3 -0
- package/package.json +2 -2
- package/skinny/OptionsItemIdManager-904d6cea.esm.js +105 -0
- package/skinny/OptionsItemIdManager-904d6cea.esm.js.map +1 -0
- package/skinny/OptionsItemIdManager-ab379c9b.cjs.js +108 -0
- package/skinny/OptionsItemIdManager-ab379c9b.cjs.js.map +1 -0
- package/skinny/OptionsItemIdManager.d.ts +18 -0
- package/skinny/{common-616eb178.esm.js → common-a8047588.esm.js} +2 -2
- package/skinny/{common-616eb178.esm.js.map → common-a8047588.esm.js.map} +1 -1
- package/skinny/{common-45acb83c.cjs.js → common-abd18d7f.cjs.js} +2 -2
- package/skinny/{common-45acb83c.cjs.js.map → common-abd18d7f.cjs.js.map} +1 -1
- package/skinny/registerButton.cjs.js +2 -2
- package/skinny/registerButton.esm.js +2 -2
- package/skinny/registerCheckbox.cjs.js +8 -30
- package/skinny/registerCheckbox.cjs.js.map +1 -1
- package/skinny/registerCheckbox.esm.js +9 -31
- package/skinny/registerCheckbox.esm.js.map +1 -1
- package/skinny/registerCheckboxGroup.cjs.js +13 -16
- package/skinny/registerCheckboxGroup.cjs.js.map +1 -1
- package/skinny/registerCheckboxGroup.d.ts +2 -5
- package/skinny/registerCheckboxGroup.esm.js +14 -17
- package/skinny/registerCheckboxGroup.esm.js.map +1 -1
- package/skinny/registerComboBox.cjs.js +10 -9
- package/skinny/registerComboBox.cjs.js.map +1 -1
- package/skinny/registerComboBox.d.ts +2 -5
- package/skinny/registerComboBox.esm.js +11 -10
- package/skinny/registerComboBox.esm.js.map +1 -1
- package/skinny/registerDescription.cjs.js +2 -2
- package/skinny/registerDescription.esm.js +2 -2
- package/skinny/registerDialog.cjs.js +2 -2
- package/skinny/registerDialog.esm.js +2 -2
- package/skinny/registerDialogTrigger.cjs.js +2 -2
- package/skinny/registerDialogTrigger.esm.js +2 -2
- package/skinny/registerFieldError.cjs.js +1 -1
- package/skinny/registerFieldError.esm.js +1 -1
- package/skinny/registerForm.cjs.js +1 -1
- package/skinny/registerForm.esm.js +1 -1
- package/skinny/registerHeading.cjs.js +2 -2
- package/skinny/registerHeading.esm.js +2 -2
- package/skinny/registerInput.cjs.js +2 -2
- package/skinny/registerInput.esm.js +2 -2
- package/skinny/registerLabel.cjs.js +2 -2
- package/skinny/registerLabel.esm.js +2 -2
- package/skinny/{registerListBox-0f6ebcf0.esm.js → registerListBox-5f3e4b36.esm.js} +6 -17
- package/skinny/registerListBox-5f3e4b36.esm.js.map +1 -0
- package/skinny/{registerListBox-040b0374.cjs.js → registerListBox-c33bc9d2.cjs.js} +5 -16
- package/skinny/registerListBox-c33bc9d2.cjs.js.map +1 -0
- package/skinny/registerListBox.cjs.js +4 -4
- package/skinny/registerListBox.d.ts +2 -3
- package/skinny/registerListBox.esm.js +4 -4
- package/skinny/registerListBoxItem.cjs.js +8 -29
- package/skinny/registerListBoxItem.cjs.js.map +1 -1
- package/skinny/registerListBoxItem.esm.js +9 -30
- package/skinny/registerListBoxItem.esm.js.map +1 -1
- package/skinny/registerModal.cjs.js +2 -2
- package/skinny/registerModal.esm.js +2 -2
- package/skinny/registerOverlayArrow.cjs.js +2 -2
- package/skinny/registerOverlayArrow.esm.js +2 -2
- package/skinny/registerPopover.cjs.js +2 -2
- package/skinny/registerPopover.esm.js +2 -2
- package/skinny/registerRadio.cjs.js +8 -29
- package/skinny/registerRadio.cjs.js.map +1 -1
- package/skinny/registerRadio.esm.js +9 -30
- package/skinny/registerRadio.esm.js.map +1 -1
- package/skinny/registerRadioGroup.cjs.js +13 -16
- package/skinny/registerRadioGroup.cjs.js.map +1 -1
- package/skinny/registerRadioGroup.d.ts +2 -5
- package/skinny/registerRadioGroup.esm.js +14 -17
- package/skinny/registerRadioGroup.esm.js.map +1 -1
- package/skinny/registerSection.cjs.js +4 -4
- package/skinny/registerSection.esm.js +4 -4
- package/skinny/registerSelect.cjs.js +10 -9
- package/skinny/registerSelect.cjs.js.map +1 -1
- package/skinny/registerSelect.d.ts +2 -5
- package/skinny/registerSelect.esm.js +11 -10
- package/skinny/registerSelect.esm.js.map +1 -1
- package/skinny/registerSlider.cjs.js +2 -2
- package/skinny/registerSlider.esm.js +2 -2
- package/skinny/registerSliderOutput.cjs.js +2 -2
- package/skinny/registerSliderOutput.esm.js +2 -2
- package/skinny/registerSliderThumb.cjs.js +2 -2
- package/skinny/registerSliderThumb.esm.js +2 -2
- package/skinny/registerSliderTrack.cjs.js +2 -2
- package/skinny/registerSliderTrack.esm.js +2 -2
- package/skinny/registerSwitch.cjs.js +2 -2
- package/skinny/registerSwitch.esm.js +2 -2
- package/skinny/registerText.cjs.js +2 -2
- package/skinny/registerText.esm.js +2 -2
- package/skinny/registerTextArea.cjs.js +2 -2
- package/skinny/registerTextArea.esm.js +2 -2
- package/skinny/registerTextField.cjs.js +2 -2
- package/skinny/registerTextField.esm.js +2 -2
- package/skinny/registerTooltip.cjs.js +2 -2
- package/skinny/registerTooltip.esm.js +2 -2
- package/skinny/{utils-fc1ddd7c.cjs.js → utils-2e03b499.cjs.js} +2 -2
- package/skinny/utils-2e03b499.cjs.js.map +1 -0
- package/skinny/{utils-fd88ad47.esm.js → utils-d0ca1a25.esm.js} +2 -2
- package/skinny/utils-d0ca1a25.esm.js.map +1 -0
- package/skinny/utils.d.ts +3 -0
- package/skinny/OptionsItemIdManager-832b8cfe.esm.js +0 -54
- package/skinny/OptionsItemIdManager-832b8cfe.esm.js.map +0 -1
- package/skinny/OptionsItemIdManager-a89a28b9.cjs.js +0 -56
- package/skinny/OptionsItemIdManager-a89a28b9.cjs.js.map +0 -1
- package/skinny/registerListBox-040b0374.cjs.js.map +0 -1
- package/skinny/registerListBox-0f6ebcf0.esm.js.map +0 -1
- package/skinny/utils-fc1ddd7c.cjs.js.map +0 -1
- package/skinny/utils-fd88ad47.esm.js.map +0 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
type Observer = (ids: string[]) => void;
|
|
2
|
+
/** Ensures option item IDs are unique. */
|
|
2
3
|
export declare class OptionsItemIdManager {
|
|
3
4
|
private readonly _ids;
|
|
4
5
|
private readonly _observers;
|
|
@@ -7,7 +8,24 @@ export declare class OptionsItemIdManager {
|
|
|
7
8
|
register(id?: unknown): string;
|
|
8
9
|
unregister(id: string): void;
|
|
9
10
|
subscribe(observer: Observer): void;
|
|
11
|
+
unsubscribe(observer: Observer): void;
|
|
10
12
|
notify(): void;
|
|
11
13
|
get ids(): string[];
|
|
12
14
|
}
|
|
15
|
+
/** Gets a unique option item ID. If the requested ID is already taken, returns a unique ID based on the requested ID. */
|
|
16
|
+
export declare const useOptionsItemId: (requestedId?: string, idManager?: OptionsItemIdManager) => {
|
|
17
|
+
registeredId: string;
|
|
18
|
+
idError: string | undefined;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Hook that creates and returns an OptionsItemIdManager instance to manage unique IDs.
|
|
22
|
+
*
|
|
23
|
+
* This hook is useful for components that need to track and manage a collection of unique IDs,
|
|
24
|
+
* such as select options, radio groups, checkbox groups, etc. It handles the registration and
|
|
25
|
+
* unregistration of IDs, ensuring uniqueness and providing notifications when the collection changes.
|
|
26
|
+
*
|
|
27
|
+
* @param callback - A function that will be called with the current IDs when they change.
|
|
28
|
+
* @param existing - An existing OptionsItemIdManager instance to use. If not provided, a new instance will be created.
|
|
29
|
+
*/
|
|
30
|
+
export declare function useIdManager(callback: (ids: string[]) => void, existing?: OptionsItemIdManager): OptionsItemIdManager;
|
|
13
31
|
export {};
|
package/dist/react-aria.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { usePlasmicCanvasContext, usePlasmicCanvasComponentInfo, usePlasmicLink } from '@plasmicapp/host';
|
|
2
|
-
import React, { useEffect, useState, useMemo, useCallback, forwardRef, useImperativeHandle, Component, useRef, useId } from 'react';
|
|
2
|
+
import React, { useEffect, useState, useLayoutEffect, useMemo, useCallback, forwardRef, useImperativeHandle, Component, useRef, useId } from 'react';
|
|
3
3
|
import { mergeProps, useLink, useHover, useFocusRing, useButton, useFocusWithin } from 'react-aria';
|
|
4
4
|
import { Button, Checkbox, Text, Label, CheckboxGroup, useContextProps, InputContext, ListBoxItem, ListBox, Section, Header, PopoverContext, Popover, ComboBox, ComboBoxStateContext, Dialog, ModalOverlay, Modal, DialogTrigger, Heading, TooltipTriggerStateContext, OverlayArrow, Radio, RadioGroup, Select, SelectStateContext, SelectValue, SliderOutput, SliderThumb, Slider, SliderTrack, Switch, TextAreaContext, TextField, Provider, Tooltip } from 'react-aria-components';
|
|
5
5
|
import registerComponent from '@plasmicapp/host/registerComponent';
|
|
@@ -70,7 +70,7 @@ function useAutoOpen({
|
|
|
70
70
|
} else {
|
|
71
71
|
close == null ? void 0 : close();
|
|
72
72
|
}
|
|
73
|
-
}, [isSelected, inPlasmicCanvas]);
|
|
73
|
+
}, [isSelected, inPlasmicCanvas, open, close]);
|
|
74
74
|
}
|
|
75
75
|
function registerComponentHelper(loader, component, meta, overrides) {
|
|
76
76
|
if (overrides) {
|
|
@@ -846,6 +846,107 @@ const PlasmicListBoxContext = React.createContext(void 0);
|
|
|
846
846
|
React.createContext(void 0);
|
|
847
847
|
const PlasmicInputContext = React.createContext(void 0);
|
|
848
848
|
|
|
849
|
+
class OptionsItemIdManager {
|
|
850
|
+
constructor() {
|
|
851
|
+
this._ids = /* @__PURE__ */ new Set();
|
|
852
|
+
this._observers = /* @__PURE__ */ new Set();
|
|
853
|
+
}
|
|
854
|
+
generateDuplicateId(id, count = 1) {
|
|
855
|
+
const dupId = `${id} duplicate(${count})`;
|
|
856
|
+
if (this._ids.has(dupId)) {
|
|
857
|
+
return this.generateDuplicateId(id, count + 1);
|
|
858
|
+
} else {
|
|
859
|
+
return dupId;
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
generateMissingId(count = 1) {
|
|
863
|
+
const missingId = `missing(${count})`;
|
|
864
|
+
if (this._ids.has(missingId)) {
|
|
865
|
+
return this.generateMissingId(count + 1);
|
|
866
|
+
} else {
|
|
867
|
+
return missingId;
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
register(id) {
|
|
871
|
+
const idStr = id === void 0 ? void 0 : String(id).trim();
|
|
872
|
+
let newId;
|
|
873
|
+
if (!idStr) {
|
|
874
|
+
newId = this.generateMissingId();
|
|
875
|
+
} else if (this._ids.has(idStr)) {
|
|
876
|
+
newId = this.generateDuplicateId(idStr);
|
|
877
|
+
} else {
|
|
878
|
+
newId = idStr;
|
|
879
|
+
}
|
|
880
|
+
this._ids.add(newId);
|
|
881
|
+
this.notify();
|
|
882
|
+
return newId;
|
|
883
|
+
}
|
|
884
|
+
unregister(id) {
|
|
885
|
+
this._ids.delete(id);
|
|
886
|
+
this.notify();
|
|
887
|
+
}
|
|
888
|
+
subscribe(observer) {
|
|
889
|
+
this._observers.add(observer);
|
|
890
|
+
observer(this.ids);
|
|
891
|
+
}
|
|
892
|
+
unsubscribe(observer) {
|
|
893
|
+
this._observers.delete(observer);
|
|
894
|
+
}
|
|
895
|
+
// Notify all observers about an event.
|
|
896
|
+
notify() {
|
|
897
|
+
this._observers.forEach((observer) => observer(this.ids));
|
|
898
|
+
}
|
|
899
|
+
get ids() {
|
|
900
|
+
return Array.from(this._ids);
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
const useOptionsItemId = (requestedId, idManager) => {
|
|
904
|
+
const [registeredId, setRegisteredId] = useState("");
|
|
905
|
+
useLayoutEffect(() => {
|
|
906
|
+
if (!idManager) {
|
|
907
|
+
return;
|
|
908
|
+
}
|
|
909
|
+
const localId = idManager.register(requestedId);
|
|
910
|
+
setRegisteredId(localId);
|
|
911
|
+
return () => {
|
|
912
|
+
if (localId) {
|
|
913
|
+
idManager.unregister(localId);
|
|
914
|
+
}
|
|
915
|
+
};
|
|
916
|
+
}, [requestedId, idManager]);
|
|
917
|
+
return {
|
|
918
|
+
registeredId,
|
|
919
|
+
idError: (() => {
|
|
920
|
+
if (requestedId === void 0) {
|
|
921
|
+
return "Value must be defined";
|
|
922
|
+
}
|
|
923
|
+
if (typeof requestedId !== "string") {
|
|
924
|
+
return "Value must be a string";
|
|
925
|
+
}
|
|
926
|
+
if (!requestedId.trim()) {
|
|
927
|
+
return "Value must be defined";
|
|
928
|
+
}
|
|
929
|
+
if (idManager && requestedId != registeredId) {
|
|
930
|
+
return "Value must be unique";
|
|
931
|
+
}
|
|
932
|
+
return void 0;
|
|
933
|
+
})()
|
|
934
|
+
};
|
|
935
|
+
};
|
|
936
|
+
function useIdManager(callback, existing) {
|
|
937
|
+
const idManager = useMemo(
|
|
938
|
+
() => existing != null ? existing : new OptionsItemIdManager(),
|
|
939
|
+
[existing]
|
|
940
|
+
);
|
|
941
|
+
useEffect(() => {
|
|
942
|
+
idManager.subscribe(callback);
|
|
943
|
+
return () => {
|
|
944
|
+
idManager.unsubscribe(callback);
|
|
945
|
+
};
|
|
946
|
+
}, [idManager, callback]);
|
|
947
|
+
return idManager;
|
|
948
|
+
}
|
|
949
|
+
|
|
849
950
|
var __defProp$p = Object.defineProperty;
|
|
850
951
|
var __defProps$l = Object.defineProperties;
|
|
851
952
|
var __getOwnPropDescs$l = Object.getOwnPropertyDescriptors;
|
|
@@ -902,36 +1003,13 @@ function BaseCheckbox(props) {
|
|
|
902
1003
|
"value"
|
|
903
1004
|
]);
|
|
904
1005
|
const contextProps = React.useContext(PlasmicCheckboxGroupContext);
|
|
905
|
-
const
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
return;
|
|
910
|
-
}
|
|
911
|
-
const localId = contextProps.idManager.register(value);
|
|
912
|
-
setRegisteredId(localId);
|
|
913
|
-
return () => {
|
|
914
|
-
contextProps.idManager.unregister(localId);
|
|
915
|
-
setRegisteredId(void 0);
|
|
916
|
-
};
|
|
917
|
-
}, [value, contextProps == null ? void 0 : contextProps.idManager]);
|
|
1006
|
+
const { registeredId, idError } = useOptionsItemId(
|
|
1007
|
+
value,
|
|
1008
|
+
contextProps == null ? void 0 : contextProps.idManager
|
|
1009
|
+
);
|
|
918
1010
|
setControlContextData == null ? void 0 : setControlContextData({
|
|
919
1011
|
parent: contextProps,
|
|
920
|
-
idError
|
|
921
|
-
if (value === void 0) {
|
|
922
|
-
return "Value must be defined";
|
|
923
|
-
}
|
|
924
|
-
if (typeof value !== "string") {
|
|
925
|
-
return "Value must be a string";
|
|
926
|
-
}
|
|
927
|
-
if (!value.trim()) {
|
|
928
|
-
return "Value must be defined";
|
|
929
|
-
}
|
|
930
|
-
if (!isStandalone && value != registeredId) {
|
|
931
|
-
return "Value must be unique";
|
|
932
|
-
}
|
|
933
|
-
return void 0;
|
|
934
|
-
})()
|
|
1012
|
+
idError
|
|
935
1013
|
});
|
|
936
1014
|
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
|
|
937
1015
|
Checkbox,
|
|
@@ -1097,58 +1175,6 @@ function registerCheckbox(loader, overrides) {
|
|
|
1097
1175
|
);
|
|
1098
1176
|
}
|
|
1099
1177
|
|
|
1100
|
-
class OptionsItemIdManager {
|
|
1101
|
-
constructor() {
|
|
1102
|
-
this._ids = /* @__PURE__ */ new Set();
|
|
1103
|
-
this._observers = /* @__PURE__ */ new Set();
|
|
1104
|
-
}
|
|
1105
|
-
generateDuplicateId(id, count = 1) {
|
|
1106
|
-
const dupId = `${id} duplicate(${count})`;
|
|
1107
|
-
if (this._ids.has(dupId)) {
|
|
1108
|
-
return this.generateDuplicateId(id, count + 1);
|
|
1109
|
-
} else {
|
|
1110
|
-
return dupId;
|
|
1111
|
-
}
|
|
1112
|
-
}
|
|
1113
|
-
generateMissingId(count = 1) {
|
|
1114
|
-
const missingId = `missing(${count})`;
|
|
1115
|
-
if (this._ids.has(missingId)) {
|
|
1116
|
-
return this.generateMissingId(count + 1);
|
|
1117
|
-
} else {
|
|
1118
|
-
return missingId;
|
|
1119
|
-
}
|
|
1120
|
-
}
|
|
1121
|
-
register(id) {
|
|
1122
|
-
const idStr = id === void 0 ? void 0 : String(id).trim();
|
|
1123
|
-
let newId;
|
|
1124
|
-
if (!idStr) {
|
|
1125
|
-
newId = this.generateMissingId();
|
|
1126
|
-
} else if (this._ids.has(idStr)) {
|
|
1127
|
-
newId = this.generateDuplicateId(idStr);
|
|
1128
|
-
} else {
|
|
1129
|
-
newId = idStr;
|
|
1130
|
-
}
|
|
1131
|
-
this._ids.add(newId);
|
|
1132
|
-
this.notify();
|
|
1133
|
-
return newId;
|
|
1134
|
-
}
|
|
1135
|
-
unregister(id) {
|
|
1136
|
-
this._ids.delete(id);
|
|
1137
|
-
this.notify();
|
|
1138
|
-
}
|
|
1139
|
-
subscribe(observer) {
|
|
1140
|
-
this._observers.add(observer);
|
|
1141
|
-
observer(this.ids);
|
|
1142
|
-
}
|
|
1143
|
-
// Notify all observers about an event.
|
|
1144
|
-
notify() {
|
|
1145
|
-
this._observers.forEach((observer) => observer(this.ids));
|
|
1146
|
-
}
|
|
1147
|
-
get ids() {
|
|
1148
|
-
return Array.from(this._ids);
|
|
1149
|
-
}
|
|
1150
|
-
}
|
|
1151
|
-
|
|
1152
1178
|
var __defProp$o = Object.defineProperty;
|
|
1153
1179
|
var __defProps$k = Object.defineProperties;
|
|
1154
1180
|
var __getOwnPropDescs$k = Object.getOwnPropertyDescriptors;
|
|
@@ -1366,18 +1392,15 @@ const { variants: variants$f, withObservedValues: withObservedValues$c } = pickA
|
|
|
1366
1392
|
);
|
|
1367
1393
|
function BaseCheckboxGroup(props) {
|
|
1368
1394
|
const _a = props, { children, plasmicUpdateVariant, setControlContextData } = _a, rest = __objRest$j(_a, ["children", "plasmicUpdateVariant", "setControlContextData"]);
|
|
1369
|
-
const
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
}
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
setIds(_ids);
|
|
1379
|
-
});
|
|
1380
|
-
}, [idManager]);
|
|
1395
|
+
const updateIds = useCallback(
|
|
1396
|
+
(ids) => {
|
|
1397
|
+
setControlContextData == null ? void 0 : setControlContextData({
|
|
1398
|
+
itemIds: ids
|
|
1399
|
+
});
|
|
1400
|
+
},
|
|
1401
|
+
[setControlContextData]
|
|
1402
|
+
);
|
|
1403
|
+
const idManager = useIdManager(updateIds);
|
|
1381
1404
|
return (
|
|
1382
1405
|
// PlasmicCheckboxGroupContext is used by BaseCheckbox
|
|
1383
1406
|
/* @__PURE__ */ React.createElement(PlasmicCheckboxGroupContext.Provider, { value: __spreadProps$h(__spreadValues$l({}, rest), { idManager }) }, /* @__PURE__ */ React.createElement(CheckboxGroup, __spreadProps$h(__spreadValues$l({}, rest), { style: COMMON_STYLES }), ({ isDisabled, isReadOnly }) => withObservedValues$c(
|
|
@@ -1482,7 +1505,7 @@ function registerCheckboxGroup(loader, overrides) {
|
|
|
1482
1505
|
editOnly: true,
|
|
1483
1506
|
uncontrolledProp: "defaultValue",
|
|
1484
1507
|
description: "The current value",
|
|
1485
|
-
options: (_props, ctx) => (ctx == null ? void 0 : ctx.
|
|
1508
|
+
options: (_props, ctx) => (ctx == null ? void 0 : ctx.itemIds) ? Array.from(ctx.itemIds) : [],
|
|
1486
1509
|
multiSelect: true
|
|
1487
1510
|
},
|
|
1488
1511
|
isInvalid: {
|
|
@@ -1740,34 +1763,12 @@ function BaseListBoxItem(props) {
|
|
|
1740
1763
|
const _a = props, { children, setControlContextData, plasmicUpdateVariant, id } = _a, rest = __objRest$h(_a, ["children", "setControlContextData", "plasmicUpdateVariant", "id"]);
|
|
1741
1764
|
const listboxContext = React.useContext(PlasmicListBoxContext);
|
|
1742
1765
|
const isStandalone = !listboxContext;
|
|
1743
|
-
const
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
}
|
|
1748
|
-
const localId = listboxContext.idManager.register(id);
|
|
1749
|
-
setRegisteredId(localId);
|
|
1750
|
-
return () => {
|
|
1751
|
-
listboxContext.idManager.unregister(localId);
|
|
1752
|
-
setRegisteredId(void 0);
|
|
1753
|
-
};
|
|
1754
|
-
}, [id]);
|
|
1766
|
+
const { registeredId, idError } = useOptionsItemId(
|
|
1767
|
+
id,
|
|
1768
|
+
listboxContext == null ? void 0 : listboxContext.idManager
|
|
1769
|
+
);
|
|
1755
1770
|
setControlContextData == null ? void 0 : setControlContextData({
|
|
1756
|
-
idError
|
|
1757
|
-
if (id === void 0) {
|
|
1758
|
-
return "ID must be defined";
|
|
1759
|
-
}
|
|
1760
|
-
if (typeof id !== "string") {
|
|
1761
|
-
return "ID must be a string";
|
|
1762
|
-
}
|
|
1763
|
-
if (!id.trim()) {
|
|
1764
|
-
return "ID must be defined";
|
|
1765
|
-
}
|
|
1766
|
-
if (!isStandalone && id != registeredId) {
|
|
1767
|
-
return "ID must be unique";
|
|
1768
|
-
}
|
|
1769
|
-
return void 0;
|
|
1770
|
-
})()
|
|
1771
|
+
idError
|
|
1771
1772
|
});
|
|
1772
1773
|
const listboxItem = /* @__PURE__ */ React.createElement(
|
|
1773
1774
|
ListBoxItem,
|
|
@@ -2021,24 +2022,13 @@ function BaseListBox(props) {
|
|
|
2021
2022
|
const context = React.useContext(PlasmicListBoxContext);
|
|
2022
2023
|
const isStandalone = !context;
|
|
2023
2024
|
const [ids, setIds] = useState([]);
|
|
2024
|
-
const idManager =
|
|
2025
|
-
() => {
|
|
2026
|
-
var _a2;
|
|
2027
|
-
return (_a2 = context == null ? void 0 : context.idManager) != null ? _a2 : new OptionsItemIdManager();
|
|
2028
|
-
},
|
|
2029
|
-
[]
|
|
2030
|
-
);
|
|
2025
|
+
const idManager = useIdManager(setIds, context == null ? void 0 : context.idManager);
|
|
2031
2026
|
useEffect(() => {
|
|
2032
2027
|
setControlContextData == null ? void 0 : setControlContextData({
|
|
2033
2028
|
itemIds: ids,
|
|
2034
2029
|
isStandalone
|
|
2035
2030
|
});
|
|
2036
2031
|
}, [ids, isStandalone, setControlContextData]);
|
|
2037
|
-
useEffect(() => {
|
|
2038
|
-
idManager.subscribe((_ids) => {
|
|
2039
|
-
setIds(_ids);
|
|
2040
|
-
});
|
|
2041
|
-
}, []);
|
|
2042
2032
|
const classNameProp = useCallback(
|
|
2043
2033
|
({ isFocusVisible, isFocused }) => {
|
|
2044
2034
|
plasmicUpdateVariant == null ? void 0 : plasmicUpdateVariant({
|
|
@@ -2472,14 +2462,15 @@ function BaseComboBox(props) {
|
|
|
2472
2462
|
},
|
|
2473
2463
|
[className, plasmicUpdateVariant]
|
|
2474
2464
|
);
|
|
2475
|
-
const
|
|
2476
|
-
|
|
2477
|
-
idManager.subscribe((ids) => {
|
|
2465
|
+
const updateIds = useCallback(
|
|
2466
|
+
(ids) => {
|
|
2478
2467
|
setControlContextData == null ? void 0 : setControlContextData({
|
|
2479
2468
|
itemIds: ids
|
|
2480
2469
|
});
|
|
2481
|
-
}
|
|
2482
|
-
|
|
2470
|
+
},
|
|
2471
|
+
[setControlContextData]
|
|
2472
|
+
);
|
|
2473
|
+
const idManager = useIdManager(updateIds);
|
|
2483
2474
|
return /* @__PURE__ */ React.createElement(ComboBox, __spreadProps$d(__spreadValues$f({ className: classNameProp }, rest), { style: COMMON_STYLES }), /* @__PURE__ */ React.createElement(PlasmicPopoverTriggerContext.Provider, { value: true }, /* @__PURE__ */ React.createElement(
|
|
2484
2475
|
PlasmicListBoxContext.Provider,
|
|
2485
2476
|
{
|
|
@@ -3207,35 +3198,13 @@ function BaseRadio(props) {
|
|
|
3207
3198
|
]);
|
|
3208
3199
|
const contextProps = React.useContext(PlasmicRadioGroupContext);
|
|
3209
3200
|
const isStandalone = !contextProps;
|
|
3210
|
-
const
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
}
|
|
3215
|
-
const localId = contextProps.idManager.register(value);
|
|
3216
|
-
setRegisteredId(localId);
|
|
3217
|
-
return () => {
|
|
3218
|
-
contextProps.idManager.unregister(localId);
|
|
3219
|
-
setRegisteredId("");
|
|
3220
|
-
};
|
|
3221
|
-
}, [value, contextProps == null ? void 0 : contextProps.idManager]);
|
|
3201
|
+
const { registeredId, idError } = useOptionsItemId(
|
|
3202
|
+
value,
|
|
3203
|
+
contextProps == null ? void 0 : contextProps.idManager
|
|
3204
|
+
);
|
|
3222
3205
|
setControlContextData == null ? void 0 : setControlContextData({
|
|
3223
3206
|
parent: contextProps,
|
|
3224
|
-
idError
|
|
3225
|
-
if (value === void 0) {
|
|
3226
|
-
return "Value must be defined";
|
|
3227
|
-
}
|
|
3228
|
-
if (typeof value !== "string") {
|
|
3229
|
-
return "Value must be a string";
|
|
3230
|
-
}
|
|
3231
|
-
if (!value.trim()) {
|
|
3232
|
-
return "Value must be defined";
|
|
3233
|
-
}
|
|
3234
|
-
if (!isStandalone && value != registeredId) {
|
|
3235
|
-
return "Value must be unique";
|
|
3236
|
-
}
|
|
3237
|
-
return void 0;
|
|
3238
|
-
})()
|
|
3207
|
+
idError
|
|
3239
3208
|
});
|
|
3240
3209
|
const radio = /* @__PURE__ */ React.createElement(
|
|
3241
3210
|
Radio,
|
|
@@ -3375,18 +3344,15 @@ const RADIO_GROUP_VARIANTS = ["disabled", "readonly"];
|
|
|
3375
3344
|
const { variants: variants$8, withObservedValues: withObservedValues$7 } = pickAriaComponentVariants(RADIO_GROUP_VARIANTS);
|
|
3376
3345
|
function BaseRadioGroup(props) {
|
|
3377
3346
|
const _a = props, { children, plasmicUpdateVariant, setControlContextData } = _a, rest = __objRest$8(_a, ["children", "plasmicUpdateVariant", "setControlContextData"]);
|
|
3378
|
-
const
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
}
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
setIds(_ids);
|
|
3388
|
-
});
|
|
3389
|
-
}, [idManager]);
|
|
3347
|
+
const updateIds = useCallback(
|
|
3348
|
+
(ids) => {
|
|
3349
|
+
setControlContextData == null ? void 0 : setControlContextData({
|
|
3350
|
+
itemIds: ids
|
|
3351
|
+
});
|
|
3352
|
+
},
|
|
3353
|
+
[setControlContextData]
|
|
3354
|
+
);
|
|
3355
|
+
const idManager = useIdManager(updateIds);
|
|
3390
3356
|
return (
|
|
3391
3357
|
// PlasmicRadioGroupContext is used by BaseRadio
|
|
3392
3358
|
/* @__PURE__ */ React.createElement(PlasmicRadioGroupContext.Provider, { value: __spreadProps$8(__spreadValues$9({}, props), { idManager }) }, /* @__PURE__ */ React.createElement(RadioGroup, __spreadProps$8(__spreadValues$9({}, rest), { style: COMMON_STYLES }), ({ isDisabled, isReadOnly }) => withObservedValues$7(
|
|
@@ -3488,7 +3454,7 @@ function registerRadioGroup(loader, overrides) {
|
|
|
3488
3454
|
displayName: "Initial value",
|
|
3489
3455
|
uncontrolledProp: "defaultValue",
|
|
3490
3456
|
description: "The current value",
|
|
3491
|
-
options: (_props, ctx) => (ctx == null ? void 0 : ctx.
|
|
3457
|
+
options: (_props, ctx) => (ctx == null ? void 0 : ctx.itemIds) ? Array.from(ctx.itemIds) : [],
|
|
3492
3458
|
multiSelect: false
|
|
3493
3459
|
},
|
|
3494
3460
|
isInvalid: {
|
|
@@ -3583,14 +3549,15 @@ function BaseSelect(props) {
|
|
|
3583
3549
|
defaultSelectedKey,
|
|
3584
3550
|
"aria-label": ariaLabel
|
|
3585
3551
|
} = props;
|
|
3586
|
-
const
|
|
3587
|
-
|
|
3588
|
-
idManager.subscribe((ids) => {
|
|
3552
|
+
const updateIds = useCallback(
|
|
3553
|
+
(ids) => {
|
|
3589
3554
|
setControlContextData == null ? void 0 : setControlContextData({
|
|
3590
3555
|
itemIds: ids
|
|
3591
3556
|
});
|
|
3592
|
-
}
|
|
3593
|
-
|
|
3557
|
+
},
|
|
3558
|
+
[setControlContextData]
|
|
3559
|
+
);
|
|
3560
|
+
const idManager = useIdManager(updateIds);
|
|
3594
3561
|
const classNameProp = useCallback(
|
|
3595
3562
|
({
|
|
3596
3563
|
isDisabled: isDisabled2,
|