@plasmicpkgs/react-aria 0.0.88 → 0.0.90
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/{ListBoxItemIdManager.d.ts → OptionsItemIdManager.d.ts} +1 -1
- package/dist/contexts.d.ts +8 -4
- package/dist/react-aria.esm.js +187 -76
- package/dist/react-aria.esm.js.map +1 -1
- package/dist/react-aria.js +186 -75
- package/dist/react-aria.js.map +1 -1
- package/dist/registerCheckbox.d.ts +5 -2
- package/dist/registerCheckboxGroup.d.ts +5 -2
- package/dist/registerRadio.d.ts +5 -2
- package/dist/registerRadioGroup.d.ts +5 -2
- package/package.json +3 -3
- package/skinny/OptionsItemIdManager-832b8cfe.esm.js +54 -0
- package/skinny/OptionsItemIdManager-832b8cfe.esm.js.map +1 -0
- package/skinny/OptionsItemIdManager-a89a28b9.cjs.js +56 -0
- package/skinny/OptionsItemIdManager-a89a28b9.cjs.js.map +1 -0
- package/skinny/{ListBoxItemIdManager.d.ts → OptionsItemIdManager.d.ts} +1 -1
- package/skinny/{common-7ecf439d.esm.js → common-d75204cf.esm.js} +2 -2
- package/skinny/{common-7ecf439d.esm.js.map → common-d75204cf.esm.js.map} +1 -1
- package/skinny/contexts-5cb81c2f.esm.js.map +1 -1
- package/skinny/contexts-6d0cb2b1.cjs.js.map +1 -1
- package/skinny/contexts.d.ts +8 -4
- package/skinny/registerButton.esm.js +2 -2
- package/skinny/registerCheckbox.cjs.js +48 -4
- package/skinny/registerCheckbox.cjs.js.map +1 -1
- package/skinny/registerCheckbox.d.ts +5 -2
- package/skinny/registerCheckbox.esm.js +51 -7
- package/skinny/registerCheckbox.esm.js.map +1 -1
- package/skinny/registerCheckboxGroup.cjs.js +19 -8
- package/skinny/registerCheckboxGroup.cjs.js.map +1 -1
- package/skinny/registerCheckboxGroup.d.ts +5 -2
- package/skinny/registerCheckboxGroup.esm.js +22 -11
- package/skinny/registerCheckboxGroup.esm.js.map +1 -1
- package/skinny/registerComboBox.cjs.js +4 -3
- package/skinny/registerComboBox.cjs.js.map +1 -1
- package/skinny/registerComboBox.esm.js +6 -5
- package/skinny/registerComboBox.esm.js.map +1 -1
- package/skinny/registerDescription.esm.js +1 -1
- package/skinny/registerDialogTrigger.esm.js +2 -2
- package/skinny/registerFieldError.esm.js +1 -1
- package/skinny/registerForm.esm.js +1 -1
- package/skinny/registerHeading.esm.js +1 -1
- package/skinny/registerInput.esm.js +2 -2
- package/skinny/registerLabel.esm.js +1 -1
- package/skinny/{registerListBox-7d927361.cjs.js → registerListBox-25f29573.cjs.js} +3 -55
- package/skinny/registerListBox-25f29573.cjs.js.map +1 -0
- package/skinny/{registerListBox-4d5f98f9.esm.js → registerListBox-b6e4aabc.esm.js} +5 -56
- package/skinny/registerListBox-b6e4aabc.esm.js.map +1 -0
- package/skinny/registerListBox.cjs.js +2 -1
- package/skinny/registerListBox.cjs.js.map +1 -1
- package/skinny/registerListBox.esm.js +3 -2
- package/skinny/registerListBox.esm.js.map +1 -1
- package/skinny/registerListBoxItem.esm.js +1 -1
- package/skinny/registerModal.esm.js +2 -2
- package/skinny/registerOverlayArrow.esm.js +2 -2
- package/skinny/registerPopover.esm.js +2 -2
- package/skinny/registerRadio.cjs.js +47 -4
- package/skinny/registerRadio.cjs.js.map +1 -1
- package/skinny/registerRadio.d.ts +5 -2
- package/skinny/registerRadio.esm.js +50 -7
- package/skinny/registerRadio.esm.js.map +1 -1
- package/skinny/registerRadioGroup.cjs.js +19 -4
- package/skinny/registerRadioGroup.cjs.js.map +1 -1
- package/skinny/registerRadioGroup.d.ts +5 -2
- package/skinny/registerRadioGroup.esm.js +22 -7
- package/skinny/registerRadioGroup.esm.js.map +1 -1
- package/skinny/registerSection.cjs.js +2 -1
- package/skinny/registerSection.cjs.js.map +1 -1
- package/skinny/registerSection.esm.js +3 -2
- package/skinny/registerSection.esm.js.map +1 -1
- package/skinny/registerSelect.cjs.js +4 -3
- package/skinny/registerSelect.cjs.js.map +1 -1
- package/skinny/registerSelect.esm.js +6 -5
- package/skinny/registerSelect.esm.js.map +1 -1
- package/skinny/registerSlider.esm.js +2 -2
- package/skinny/registerSliderOutput.esm.js +1 -1
- package/skinny/registerSliderThumb.esm.js +2 -2
- package/skinny/registerSliderTrack.esm.js +1 -1
- package/skinny/registerSwitch.esm.js +2 -2
- package/skinny/registerText.esm.js +1 -1
- package/skinny/registerTextArea.esm.js +2 -2
- package/skinny/registerTextField.esm.js +2 -2
- package/skinny/registerTooltip.esm.js +2 -2
- package/skinny/{utils-41b3d43b.esm.js → utils-bcdc928e.esm.js} +2 -2
- package/skinny/{utils-41b3d43b.esm.js.map → utils-bcdc928e.esm.js.map} +1 -1
- package/skinny/registerListBox-4d5f98f9.esm.js.map +0 -1
- package/skinny/registerListBox-7d927361.cjs.js.map +0 -1
package/dist/contexts.d.ts
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { OptionsItemIdManager } from "./OptionsItemIdManager";
|
|
3
3
|
import { BaseSlider } from "./registerSlider";
|
|
4
4
|
export declare const PlasmicTextFieldContext: React.Context<import("./registerTextField").BaseTextFieldProps | undefined>;
|
|
5
|
-
export declare const PlasmicCheckboxGroupContext: React.Context<import("./registerCheckboxGroup").BaseCheckboxGroupProps
|
|
6
|
-
|
|
5
|
+
export declare const PlasmicCheckboxGroupContext: React.Context<(import("./registerCheckboxGroup").BaseCheckboxGroupProps & {
|
|
6
|
+
idManager: OptionsItemIdManager;
|
|
7
|
+
}) | undefined>;
|
|
8
|
+
export declare const PlasmicRadioGroupContext: React.Context<(import("./registerRadioGroup").BaseRadioGroupProps & {
|
|
9
|
+
idManager: OptionsItemIdManager;
|
|
10
|
+
}) | undefined>;
|
|
7
11
|
export declare const PlasmicDialogTriggerContext: React.Context<import("./registerDialogTrigger").BaseDialogTriggerProps | undefined>;
|
|
8
12
|
export type PlasmicSliderContextType<T extends number | number[]> = React.ComponentProps<typeof BaseSlider<T>> | undefined;
|
|
9
13
|
export declare const PlasmicSliderContext: React.Context<PlasmicSliderContextType<number | number[]>>;
|
|
10
14
|
export declare const PlasmicLabelContext: React.Context<import("react-aria-components").LabelProps | undefined>;
|
|
11
15
|
export declare const PlasmicPopoverTriggerContext: React.Context<boolean | undefined>;
|
|
12
16
|
export declare const PlasmicListBoxContext: React.Context<{
|
|
13
|
-
idManager:
|
|
17
|
+
idManager: OptionsItemIdManager;
|
|
14
18
|
} | undefined>;
|
|
15
19
|
export declare const PlasmicSectionContext: React.Context<import("./registerSection").BaseSectionProps | undefined>;
|
|
16
20
|
export declare const PlasmicInputContext: React.Context<import("./registerInput").BaseInputProps | undefined>;
|
package/dist/react-aria.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useEffect,
|
|
1
|
+
import React, { useEffect, useState, useMemo, useCallback, forwardRef, useImperativeHandle, Component } from 'react';
|
|
2
2
|
import { mergeProps, useFocusable } from 'react-aria';
|
|
3
3
|
import { Button, Checkbox, Text, Label, CheckboxGroup, Input, ListBoxItem, ListBox, Section, Header, PopoverContext, Popover, ComboBox, ComboBoxStateContext, Heading, ModalOverlay, Modal, Dialog, DialogTrigger, TooltipContext, OverlayArrow, Radio, RadioGroup, Select, SelectStateContext, SelectValue, SliderOutput, SliderThumb, Slider, SliderTrack, Switch, TextArea, TextField, TooltipTrigger, Tooltip } from 'react-aria-components';
|
|
4
4
|
import { usePlasmicCanvasContext, usePlasmicCanvasComponentInfo } from '@plasmicapp/host';
|
|
@@ -777,12 +777,50 @@ const CHECKBOX_VARIANTS = [
|
|
|
777
777
|
];
|
|
778
778
|
const { variants: variants$g, withObservedValues: withObservedValues$d } = pickAriaComponentVariants(CHECKBOX_VARIANTS);
|
|
779
779
|
function BaseCheckbox(props) {
|
|
780
|
-
const _a = props, {
|
|
780
|
+
const _a = props, {
|
|
781
|
+
children,
|
|
782
|
+
plasmicUpdateVariant,
|
|
783
|
+
setControlContextData,
|
|
784
|
+
value
|
|
785
|
+
} = _a, rest = __objRest$l(_a, [
|
|
786
|
+
"children",
|
|
787
|
+
"plasmicUpdateVariant",
|
|
788
|
+
"setControlContextData",
|
|
789
|
+
"value"
|
|
790
|
+
]);
|
|
781
791
|
const contextProps = React.useContext(PlasmicCheckboxGroupContext);
|
|
792
|
+
const isStandalone = !contextProps;
|
|
793
|
+
const [registeredId, setRegisteredId] = useState();
|
|
794
|
+
useEffect(() => {
|
|
795
|
+
if (!(contextProps == null ? void 0 : contextProps.idManager)) {
|
|
796
|
+
return;
|
|
797
|
+
}
|
|
798
|
+
const localId = contextProps.idManager.register(value);
|
|
799
|
+
setRegisteredId(localId);
|
|
800
|
+
return () => {
|
|
801
|
+
contextProps.idManager.unregister(localId);
|
|
802
|
+
setRegisteredId(void 0);
|
|
803
|
+
};
|
|
804
|
+
}, [value, contextProps == null ? void 0 : contextProps.idManager]);
|
|
782
805
|
setControlContextData == null ? void 0 : setControlContextData({
|
|
783
|
-
parent: contextProps
|
|
806
|
+
parent: contextProps,
|
|
807
|
+
idError: (() => {
|
|
808
|
+
if (value === void 0) {
|
|
809
|
+
return "Value must be defined";
|
|
810
|
+
}
|
|
811
|
+
if (typeof value !== "string") {
|
|
812
|
+
return "Value must be a string";
|
|
813
|
+
}
|
|
814
|
+
if (!value.trim()) {
|
|
815
|
+
return "Value must be defined";
|
|
816
|
+
}
|
|
817
|
+
if (!isStandalone && value != registeredId) {
|
|
818
|
+
return "Value must be unique";
|
|
819
|
+
}
|
|
820
|
+
return void 0;
|
|
821
|
+
})()
|
|
784
822
|
});
|
|
785
|
-
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Checkbox, __spreadValues$o({}, rest), ({
|
|
823
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(Checkbox, __spreadProps$f(__spreadValues$o({}, rest), { value: registeredId, key: registeredId }), ({
|
|
786
824
|
isHovered,
|
|
787
825
|
isPressed,
|
|
788
826
|
isFocused,
|
|
@@ -882,7 +920,13 @@ function registerCheckbox(loader, overrides) {
|
|
|
882
920
|
value: {
|
|
883
921
|
type: "string",
|
|
884
922
|
description: 'The value of the checkbox in "selected" state, used when submitting an HTML form.',
|
|
885
|
-
defaultValueHint: "on"
|
|
923
|
+
defaultValueHint: "on",
|
|
924
|
+
validator: (_value, _props, ctx) => {
|
|
925
|
+
if (ctx == null ? void 0 : ctx.idError) {
|
|
926
|
+
return ctx.idError;
|
|
927
|
+
}
|
|
928
|
+
return true;
|
|
929
|
+
}
|
|
886
930
|
},
|
|
887
931
|
isSelected: {
|
|
888
932
|
type: "boolean",
|
|
@@ -931,6 +975,58 @@ function registerCheckbox(loader, overrides) {
|
|
|
931
975
|
);
|
|
932
976
|
}
|
|
933
977
|
|
|
978
|
+
class OptionsItemIdManager {
|
|
979
|
+
constructor() {
|
|
980
|
+
this._ids = /* @__PURE__ */ new Set();
|
|
981
|
+
this._observers = /* @__PURE__ */ new Set();
|
|
982
|
+
}
|
|
983
|
+
generateDuplicateId(id, count = 1) {
|
|
984
|
+
const dupId = `${id} duplicate(${count})`;
|
|
985
|
+
if (this._ids.has(dupId)) {
|
|
986
|
+
return this.generateDuplicateId(id, count + 1);
|
|
987
|
+
} else {
|
|
988
|
+
return dupId;
|
|
989
|
+
}
|
|
990
|
+
}
|
|
991
|
+
generateMissingId(count = 1) {
|
|
992
|
+
const missingId = `missing(${count})`;
|
|
993
|
+
if (this._ids.has(missingId)) {
|
|
994
|
+
return this.generateMissingId(count + 1);
|
|
995
|
+
} else {
|
|
996
|
+
return missingId;
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
register(id) {
|
|
1000
|
+
const idStr = id === void 0 ? void 0 : String(id).trim();
|
|
1001
|
+
let newId;
|
|
1002
|
+
if (!idStr) {
|
|
1003
|
+
newId = this.generateMissingId();
|
|
1004
|
+
} else if (this._ids.has(idStr)) {
|
|
1005
|
+
newId = this.generateDuplicateId(idStr);
|
|
1006
|
+
} else {
|
|
1007
|
+
newId = idStr;
|
|
1008
|
+
}
|
|
1009
|
+
this._ids.add(newId);
|
|
1010
|
+
this.notify();
|
|
1011
|
+
return newId;
|
|
1012
|
+
}
|
|
1013
|
+
unregister(id) {
|
|
1014
|
+
this._ids.delete(id);
|
|
1015
|
+
this.notify();
|
|
1016
|
+
}
|
|
1017
|
+
subscribe(observer) {
|
|
1018
|
+
this._observers.add(observer);
|
|
1019
|
+
observer(this.ids);
|
|
1020
|
+
}
|
|
1021
|
+
// Notify all observers about an event.
|
|
1022
|
+
notify() {
|
|
1023
|
+
this._observers.forEach((observer) => observer(this.ids));
|
|
1024
|
+
}
|
|
1025
|
+
get ids() {
|
|
1026
|
+
return Array.from(this._ids);
|
|
1027
|
+
}
|
|
1028
|
+
}
|
|
1029
|
+
|
|
934
1030
|
var __defProp$n = Object.defineProperty;
|
|
935
1031
|
var __defProps$e = Object.defineProperties;
|
|
936
1032
|
var __getOwnPropDescs$e = Object.getOwnPropertyDescriptors;
|
|
@@ -1132,8 +1228,20 @@ const { variants: variants$f, withObservedValues: withObservedValues$c } = pickA
|
|
|
1132
1228
|
CHECKBOX_GROUP_VARIANTS
|
|
1133
1229
|
);
|
|
1134
1230
|
function BaseCheckboxGroup(props) {
|
|
1135
|
-
const _a = props, { children, plasmicUpdateVariant } = _a, rest = __objRest$i(_a, ["children", "plasmicUpdateVariant"]);
|
|
1136
|
-
|
|
1231
|
+
const _a = props, { children, plasmicUpdateVariant, setControlContextData } = _a, rest = __objRest$i(_a, ["children", "plasmicUpdateVariant", "setControlContextData"]);
|
|
1232
|
+
const [ids, setIds] = useState([]);
|
|
1233
|
+
const idManager = useMemo(() => new OptionsItemIdManager(), []);
|
|
1234
|
+
useEffect(() => {
|
|
1235
|
+
setControlContextData == null ? void 0 : setControlContextData({
|
|
1236
|
+
values: ids
|
|
1237
|
+
});
|
|
1238
|
+
}, [ids, setControlContextData]);
|
|
1239
|
+
useEffect(() => {
|
|
1240
|
+
idManager.subscribe((_ids) => {
|
|
1241
|
+
setIds(_ids);
|
|
1242
|
+
});
|
|
1243
|
+
}, [idManager]);
|
|
1244
|
+
return /* @__PURE__ */ React.createElement(PlasmicCheckboxGroupContext.Provider, { value: __spreadProps$b(__spreadValues$k({}, rest), { idManager }) }, /* @__PURE__ */ React.createElement(CheckboxGroup, __spreadValues$k({}, rest), ({ isDisabled, isReadOnly }) => withObservedValues$c(
|
|
1137
1245
|
children,
|
|
1138
1246
|
{
|
|
1139
1247
|
disabled: isDisabled,
|
|
@@ -1144,10 +1252,6 @@ function BaseCheckboxGroup(props) {
|
|
|
1144
1252
|
}
|
|
1145
1253
|
const componentName = makeComponentName("checkboxGroup");
|
|
1146
1254
|
function registerCheckboxGroup(loader, overrides) {
|
|
1147
|
-
makeChildComponentName(
|
|
1148
|
-
overrides == null ? void 0 : overrides.parentComponentName,
|
|
1149
|
-
componentName
|
|
1150
|
-
);
|
|
1151
1255
|
registerComponentHelper(
|
|
1152
1256
|
loader,
|
|
1153
1257
|
BaseCheckboxGroup,
|
|
@@ -1234,10 +1338,12 @@ function registerCheckboxGroup(loader, overrides) {
|
|
|
1234
1338
|
]
|
|
1235
1339
|
},
|
|
1236
1340
|
value: {
|
|
1237
|
-
type: "
|
|
1341
|
+
type: "choice",
|
|
1238
1342
|
editOnly: true,
|
|
1239
1343
|
uncontrolledProp: "defaultValue",
|
|
1240
|
-
description: "The current value"
|
|
1344
|
+
description: "The current value",
|
|
1345
|
+
options: (_props, ctx) => (ctx == null ? void 0 : ctx.values) ? Array.from(ctx.values) : [],
|
|
1346
|
+
multiSelect: true
|
|
1241
1347
|
},
|
|
1242
1348
|
isInvalid: {
|
|
1243
1349
|
displayName: "Invalid",
|
|
@@ -1270,58 +1376,6 @@ function registerCheckboxGroup(loader, overrides) {
|
|
|
1270
1376
|
);
|
|
1271
1377
|
}
|
|
1272
1378
|
|
|
1273
|
-
class ListBoxItemIdManager {
|
|
1274
|
-
constructor() {
|
|
1275
|
-
this._ids = /* @__PURE__ */ new Set();
|
|
1276
|
-
this._observers = /* @__PURE__ */ new Set();
|
|
1277
|
-
}
|
|
1278
|
-
generateDuplicateId(id, count = 1) {
|
|
1279
|
-
const dupId = `${id} duplicate(${count})`;
|
|
1280
|
-
if (this._ids.has(dupId)) {
|
|
1281
|
-
return this.generateDuplicateId(id, count + 1);
|
|
1282
|
-
} else {
|
|
1283
|
-
return dupId;
|
|
1284
|
-
}
|
|
1285
|
-
}
|
|
1286
|
-
generateMissingId(count = 1) {
|
|
1287
|
-
const missingId = `missing(${count})`;
|
|
1288
|
-
if (this._ids.has(missingId)) {
|
|
1289
|
-
return this.generateMissingId(count + 1);
|
|
1290
|
-
} else {
|
|
1291
|
-
return missingId;
|
|
1292
|
-
}
|
|
1293
|
-
}
|
|
1294
|
-
register(id) {
|
|
1295
|
-
const idStr = id === void 0 ? void 0 : String(id).trim();
|
|
1296
|
-
let newId;
|
|
1297
|
-
if (!idStr) {
|
|
1298
|
-
newId = this.generateMissingId();
|
|
1299
|
-
} else if (this._ids.has(idStr)) {
|
|
1300
|
-
newId = this.generateDuplicateId(idStr);
|
|
1301
|
-
} else {
|
|
1302
|
-
newId = idStr;
|
|
1303
|
-
}
|
|
1304
|
-
this._ids.add(newId);
|
|
1305
|
-
this.notify();
|
|
1306
|
-
return newId;
|
|
1307
|
-
}
|
|
1308
|
-
unregister(id) {
|
|
1309
|
-
this._ids.delete(id);
|
|
1310
|
-
this.notify();
|
|
1311
|
-
}
|
|
1312
|
-
subscribe(observer) {
|
|
1313
|
-
this._observers.add(observer);
|
|
1314
|
-
observer(this.ids);
|
|
1315
|
-
}
|
|
1316
|
-
// Notify all observers about an event.
|
|
1317
|
-
notify() {
|
|
1318
|
-
this._observers.forEach((observer) => observer(this.ids));
|
|
1319
|
-
}
|
|
1320
|
-
get ids() {
|
|
1321
|
-
return Array.from(this._ids);
|
|
1322
|
-
}
|
|
1323
|
-
}
|
|
1324
|
-
|
|
1325
1379
|
var __defProp$j = Object.defineProperty;
|
|
1326
1380
|
var __getOwnPropSymbols$j = Object.getOwnPropertySymbols;
|
|
1327
1381
|
var __hasOwnProp$j = Object.prototype.hasOwnProperty;
|
|
@@ -1790,7 +1844,7 @@ function BaseListBox(props) {
|
|
|
1790
1844
|
const idManager = useMemo(
|
|
1791
1845
|
() => {
|
|
1792
1846
|
var _a2;
|
|
1793
|
-
return (_a2 = context == null ? void 0 : context.idManager) != null ? _a2 : new
|
|
1847
|
+
return (_a2 = context == null ? void 0 : context.idManager) != null ? _a2 : new OptionsItemIdManager();
|
|
1794
1848
|
},
|
|
1795
1849
|
[]
|
|
1796
1850
|
);
|
|
@@ -2237,7 +2291,7 @@ function BaseComboBox(props) {
|
|
|
2237
2291
|
},
|
|
2238
2292
|
[className, plasmicUpdateVariant]
|
|
2239
2293
|
);
|
|
2240
|
-
const idManager = useMemo(() => new
|
|
2294
|
+
const idManager = useMemo(() => new OptionsItemIdManager(), []);
|
|
2241
2295
|
useEffect(() => {
|
|
2242
2296
|
idManager.subscribe((ids) => {
|
|
2243
2297
|
setControlContextData == null ? void 0 : setControlContextData({
|
|
@@ -2862,13 +2916,50 @@ const RADIO_VARIANTS = [
|
|
|
2862
2916
|
];
|
|
2863
2917
|
const { variants: variants$9, withObservedValues: withObservedValues$8 } = pickAriaComponentVariants(RADIO_VARIANTS);
|
|
2864
2918
|
function BaseRadio(props) {
|
|
2865
|
-
const _a = props, {
|
|
2919
|
+
const _a = props, {
|
|
2920
|
+
children,
|
|
2921
|
+
setControlContextData,
|
|
2922
|
+
plasmicUpdateVariant,
|
|
2923
|
+
value
|
|
2924
|
+
} = _a, rest = __objRest$8(_a, [
|
|
2925
|
+
"children",
|
|
2926
|
+
"setControlContextData",
|
|
2927
|
+
"plasmicUpdateVariant",
|
|
2928
|
+
"value"
|
|
2929
|
+
]);
|
|
2866
2930
|
const contextProps = React.useContext(PlasmicRadioGroupContext);
|
|
2867
2931
|
const isStandalone = !contextProps;
|
|
2932
|
+
const [registeredId, setRegisteredId] = useState("");
|
|
2933
|
+
useEffect(() => {
|
|
2934
|
+
if (!(contextProps == null ? void 0 : contextProps.idManager)) {
|
|
2935
|
+
return;
|
|
2936
|
+
}
|
|
2937
|
+
const localId = contextProps.idManager.register(value);
|
|
2938
|
+
setRegisteredId(localId);
|
|
2939
|
+
return () => {
|
|
2940
|
+
contextProps.idManager.unregister(localId);
|
|
2941
|
+
setRegisteredId("");
|
|
2942
|
+
};
|
|
2943
|
+
}, [value, contextProps == null ? void 0 : contextProps.idManager]);
|
|
2868
2944
|
setControlContextData == null ? void 0 : setControlContextData({
|
|
2869
|
-
parent: contextProps
|
|
2945
|
+
parent: contextProps,
|
|
2946
|
+
idError: (() => {
|
|
2947
|
+
if (value === void 0) {
|
|
2948
|
+
return "Value must be defined";
|
|
2949
|
+
}
|
|
2950
|
+
if (typeof value !== "string") {
|
|
2951
|
+
return "Value must be a string";
|
|
2952
|
+
}
|
|
2953
|
+
if (!value.trim()) {
|
|
2954
|
+
return "Value must be defined";
|
|
2955
|
+
}
|
|
2956
|
+
if (!isStandalone && value != registeredId) {
|
|
2957
|
+
return "Value must be unique";
|
|
2958
|
+
}
|
|
2959
|
+
return void 0;
|
|
2960
|
+
})()
|
|
2870
2961
|
});
|
|
2871
|
-
const radio = /* @__PURE__ */ React.createElement(Radio, __spreadValues$a({}, rest), ({
|
|
2962
|
+
const radio = /* @__PURE__ */ React.createElement(Radio, __spreadProps$7(__spreadValues$a({}, rest), { value: registeredId, key: registeredId }), ({
|
|
2872
2963
|
isHovered,
|
|
2873
2964
|
isPressed,
|
|
2874
2965
|
isFocused,
|
|
@@ -2948,7 +3039,13 @@ function registerRadio(loader, overrides) {
|
|
|
2948
3039
|
},
|
|
2949
3040
|
value: {
|
|
2950
3041
|
type: "string",
|
|
2951
|
-
description: "The value of the input element, used when submitting an HTML form."
|
|
3042
|
+
description: "The value of the input element, used when submitting an HTML form.",
|
|
3043
|
+
validator: (_value, _props, ctx) => {
|
|
3044
|
+
if (ctx == null ? void 0 : ctx.idError) {
|
|
3045
|
+
return ctx.idError;
|
|
3046
|
+
}
|
|
3047
|
+
return true;
|
|
3048
|
+
}
|
|
2952
3049
|
}
|
|
2953
3050
|
}),
|
|
2954
3051
|
trapsFocus: true
|
|
@@ -2991,8 +3088,20 @@ var __objRest$7 = (source, exclude) => {
|
|
|
2991
3088
|
const RADIO_GROUP_VARIANTS = ["disabled", "readonly"];
|
|
2992
3089
|
const { variants: variants$8, withObservedValues: withObservedValues$7 } = pickAriaComponentVariants(RADIO_GROUP_VARIANTS);
|
|
2993
3090
|
function BaseRadioGroup(props) {
|
|
2994
|
-
const _a = props, { children, plasmicUpdateVariant } = _a, rest = __objRest$7(_a, ["children", "plasmicUpdateVariant"]);
|
|
2995
|
-
|
|
3091
|
+
const _a = props, { children, plasmicUpdateVariant, setControlContextData } = _a, rest = __objRest$7(_a, ["children", "plasmicUpdateVariant", "setControlContextData"]);
|
|
3092
|
+
const [ids, setIds] = useState([]);
|
|
3093
|
+
const idManager = useMemo(() => new OptionsItemIdManager(), []);
|
|
3094
|
+
useEffect(() => {
|
|
3095
|
+
setControlContextData == null ? void 0 : setControlContextData({
|
|
3096
|
+
values: ids
|
|
3097
|
+
});
|
|
3098
|
+
}, [ids, setControlContextData]);
|
|
3099
|
+
useEffect(() => {
|
|
3100
|
+
idManager.subscribe((_ids) => {
|
|
3101
|
+
setIds(_ids);
|
|
3102
|
+
});
|
|
3103
|
+
}, [idManager]);
|
|
3104
|
+
return /* @__PURE__ */ React.createElement(PlasmicRadioGroupContext.Provider, { value: __spreadProps$6(__spreadValues$9({}, props), { idManager }) }, /* @__PURE__ */ React.createElement(RadioGroup, __spreadValues$9({}, rest), ({ isDisabled, isReadOnly }) => withObservedValues$7(
|
|
2996
3105
|
children,
|
|
2997
3106
|
{
|
|
2998
3107
|
disabled: isDisabled,
|
|
@@ -3085,11 +3194,13 @@ function registerRadioGroup(loader, overrides) {
|
|
|
3085
3194
|
]
|
|
3086
3195
|
},
|
|
3087
3196
|
value: {
|
|
3088
|
-
type: "
|
|
3197
|
+
type: "choice",
|
|
3089
3198
|
editOnly: true,
|
|
3090
3199
|
displayName: "Initial value",
|
|
3091
3200
|
uncontrolledProp: "defaultValue",
|
|
3092
|
-
description: "The current value"
|
|
3201
|
+
description: "The current value",
|
|
3202
|
+
options: (_props, ctx) => (ctx == null ? void 0 : ctx.values) ? Array.from(ctx.values) : [],
|
|
3203
|
+
multiSelect: false
|
|
3093
3204
|
},
|
|
3094
3205
|
isInvalid: {
|
|
3095
3206
|
displayName: "Invalid",
|
|
@@ -3184,7 +3295,7 @@ function BaseSelect(props) {
|
|
|
3184
3295
|
plasmicUpdateVariant,
|
|
3185
3296
|
"aria-label": ariaLabel
|
|
3186
3297
|
} = props;
|
|
3187
|
-
const idManager = useMemo(() => new
|
|
3298
|
+
const idManager = useMemo(() => new OptionsItemIdManager(), []);
|
|
3188
3299
|
useEffect(() => {
|
|
3189
3300
|
idManager.subscribe((ids) => {
|
|
3190
3301
|
setControlContextData == null ? void 0 : setControlContextData({
|