@moda/om 21.6.9 → 21.6.11
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/index.cjs.js +126 -70
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +125 -71
- package/dist/index.esm.js.map +1 -1
- package/dist/src/components/Field/FormControlContext.d.ts +6 -0
- package/dist/src/components/Field/index.d.ts +1 -0
- package/dist/src/components/Select/SelectLabel.d.ts +1 -1
- package/dist/src/components/Select/SelectOption.d.ts +1 -0
- package/dist/src/components/Select/useSelect.d.ts +1 -0
- package/dist/styles.css +1 -1
- package/package.json +1 -1
- package/src/components/Field/Field.tsx +46 -41
- package/src/components/Field/FormControlContext.tsx +11 -0
- package/src/components/Field/index.ts +1 -0
- package/src/components/Select/MultiSelect.tsx +20 -2
- package/src/components/Select/Select.scss +4 -0
- package/src/components/Select/Select.test.tsx +24 -10
- package/src/components/Select/Select.tsx +28 -6
- package/src/components/Select/SelectLabel.tsx +7 -2
- package/src/components/Select/SelectOption.tsx +4 -1
- package/src/components/Select/SelectOptions.tsx +7 -2
- package/src/components/Select/useSelect.ts +7 -4
package/dist/index.cjs.js
CHANGED
|
@@ -3039,9 +3039,11 @@ var FocusLock = /*#__PURE__*/React.forwardRef(function FocusLockUI(props, parent
|
|
|
3039
3039
|
observed: observed,
|
|
3040
3040
|
shards: shards,
|
|
3041
3041
|
enabled: !disabled,
|
|
3042
|
-
active
|
|
3042
|
+
get active() {
|
|
3043
|
+
return isActive.current;
|
|
3044
|
+
}
|
|
3043
3045
|
};
|
|
3044
|
-
}, [disabled, isActive
|
|
3046
|
+
}, [disabled, isActive, shards, observed]);
|
|
3045
3047
|
return /*#__PURE__*/React.createElement(React.Fragment, null, hasLeadingGuards && [/*#__PURE__*/
|
|
3046
3048
|
React.createElement("div", {
|
|
3047
3049
|
key: "guard-first",
|
|
@@ -3114,6 +3116,8 @@ var extractRef$2 = function extractRef(ref) {
|
|
|
3114
3116
|
var effectCar = createSidecarMedium();
|
|
3115
3117
|
var focusHiddenMarker = 'data-focus-on-hidden';
|
|
3116
3118
|
|
|
3119
|
+
__assign$a({}, RemoveScroll.classNames);
|
|
3120
|
+
|
|
3117
3121
|
var PREVENT_SCROLL = {
|
|
3118
3122
|
preventScroll: true
|
|
3119
3123
|
};
|
|
@@ -3121,18 +3125,21 @@ var FocusOn$1 = /*#__PURE__*/React__namespace.forwardRef(function (props, parent
|
|
|
3121
3125
|
var _a = React__namespace.useState(false),
|
|
3122
3126
|
lockProps = _a[0],
|
|
3123
3127
|
setLockProps = _a[1];
|
|
3128
|
+
var _b = React__namespace.useState(null),
|
|
3129
|
+
activeNode = _b[0],
|
|
3130
|
+
setActiveNode = _b[1];
|
|
3124
3131
|
var children = props.children,
|
|
3125
3132
|
autoFocus = props.autoFocus,
|
|
3126
3133
|
shards = props.shards,
|
|
3127
3134
|
crossFrame = props.crossFrame,
|
|
3128
|
-
|
|
3129
|
-
enabled =
|
|
3130
|
-
|
|
3131
|
-
scrollLock =
|
|
3132
|
-
|
|
3133
|
-
focusLock =
|
|
3134
|
-
|
|
3135
|
-
returnFocus =
|
|
3135
|
+
_c = props.enabled,
|
|
3136
|
+
enabled = _c === void 0 ? true : _c,
|
|
3137
|
+
_d = props.scrollLock,
|
|
3138
|
+
scrollLock = _d === void 0 ? true : _d,
|
|
3139
|
+
_e = props.focusLock,
|
|
3140
|
+
focusLock = _e === void 0 ? true : _e,
|
|
3141
|
+
_f = props.returnFocus,
|
|
3142
|
+
returnFocus = _f === void 0 ? true : _f,
|
|
3136
3143
|
inert = props.inert,
|
|
3137
3144
|
allowPinchZoom = props.allowPinchZoom,
|
|
3138
3145
|
sideCar = props.sideCar,
|
|
@@ -3144,10 +3151,7 @@ var FocusOn$1 = /*#__PURE__*/React__namespace.forwardRef(function (props, parent
|
|
|
3144
3151
|
gapMode = props.gapMode,
|
|
3145
3152
|
rest = __rest$a(props, ["children", "autoFocus", "shards", "crossFrame", "enabled", "scrollLock", "focusLock", "returnFocus", "inert", "allowPinchZoom", "sideCar", "className", "shouldIgnore", "preventScrollOnFocus", "style", "as", "gapMode"]);
|
|
3146
3153
|
var SideCar = sideCar;
|
|
3147
|
-
var
|
|
3148
|
-
onDeactivation = lockProps.onDeactivation,
|
|
3149
|
-
restProps = __rest$a(lockProps, ["onActivation", "onDeactivation"]);
|
|
3150
|
-
var appliedLockProps = __assign$a(__assign$a({}, restProps), {
|
|
3154
|
+
var appliedLockProps = __assign$a(__assign$a({}, lockProps), {
|
|
3151
3155
|
as: as,
|
|
3152
3156
|
style: style,
|
|
3153
3157
|
sideCar: sideCar,
|
|
@@ -3157,10 +3161,16 @@ var FocusOn$1 = /*#__PURE__*/React__namespace.forwardRef(function (props, parent
|
|
|
3157
3161
|
inert: inert,
|
|
3158
3162
|
enabled: enabled && scrollLock
|
|
3159
3163
|
});
|
|
3164
|
+
var onActivation = React__namespace.useCallback(function (node) {
|
|
3165
|
+
setActiveNode(node);
|
|
3166
|
+
}, []);
|
|
3167
|
+
var onDeactivation = React__namespace.useCallback(function () {
|
|
3168
|
+
setActiveNode(null);
|
|
3169
|
+
}, []);
|
|
3160
3170
|
return /*#__PURE__*/React__namespace.createElement(React__namespace.Fragment, null, /*#__PURE__*/React__namespace.createElement(FocusLock, {
|
|
3161
3171
|
ref: parentRef,
|
|
3162
3172
|
sideCar: sideCar,
|
|
3163
|
-
disabled: !(
|
|
3173
|
+
disabled: !(enabled && focusLock),
|
|
3164
3174
|
returnFocus: returnFocus,
|
|
3165
3175
|
autoFocus: autoFocus,
|
|
3166
3176
|
shards: shards,
|
|
@@ -3171,11 +3181,13 @@ var FocusOn$1 = /*#__PURE__*/React__namespace.forwardRef(function (props, parent
|
|
|
3171
3181
|
whiteList: shouldIgnore,
|
|
3172
3182
|
lockProps: appliedLockProps,
|
|
3173
3183
|
focusOptions: preventScrollOnFocus ? PREVENT_SCROLL : undefined,
|
|
3184
|
+
// // ts-expect-error TS2322 - ts v3 "glitch"
|
|
3174
3185
|
as: RemoveScroll
|
|
3175
3186
|
}, children), enabled && (/*#__PURE__*/React__namespace.createElement(SideCar, __assign$a({}, rest, {
|
|
3176
3187
|
sideCar: effectCar,
|
|
3177
3188
|
setLockProps: setLockProps,
|
|
3178
|
-
shards: shards
|
|
3189
|
+
shards: shards,
|
|
3190
|
+
activeNode: activeNode
|
|
3179
3191
|
}))));
|
|
3180
3192
|
});
|
|
3181
3193
|
|
|
@@ -5151,10 +5163,8 @@ function Effect(_a) {
|
|
|
5151
5163
|
shards = _a.shards,
|
|
5152
5164
|
onActivation = _a.onActivation,
|
|
5153
5165
|
onDeactivation = _a.onDeactivation,
|
|
5154
|
-
noIsolation = _a.noIsolation
|
|
5155
|
-
|
|
5156
|
-
activeNode = _b[0],
|
|
5157
|
-
setActiveNode = _b[1];
|
|
5166
|
+
noIsolation = _a.noIsolation,
|
|
5167
|
+
activeNode = _a.activeNode;
|
|
5158
5168
|
var lastEventTarget = React.useRef(null);
|
|
5159
5169
|
var mouseTouches = React.useRef(0);
|
|
5160
5170
|
React__namespace.useEffect(function () {
|
|
@@ -5197,6 +5207,7 @@ function Effect(_a) {
|
|
|
5197
5207
|
activeNode.ownerDocument.removeEventListener('touchend', onTouchEnd);
|
|
5198
5208
|
};
|
|
5199
5209
|
}
|
|
5210
|
+
return;
|
|
5200
5211
|
}, [activeNode, onClickOutside, onEscapeKey]);
|
|
5201
5212
|
React.useEffect(function () {
|
|
5202
5213
|
if (activeNode) {
|
|
@@ -5209,38 +5220,24 @@ function Effect(_a) {
|
|
|
5209
5220
|
}
|
|
5210
5221
|
};
|
|
5211
5222
|
}
|
|
5223
|
+
return;
|
|
5212
5224
|
}, [!!activeNode]);
|
|
5213
5225
|
React.useEffect(function () {
|
|
5214
|
-
|
|
5215
|
-
return
|
|
5216
|
-
}
|
|
5217
|
-
|
|
5218
|
-
|
|
5219
|
-
|
|
5220
|
-
_undo = hideOthers(__spreadArrays([node], (shards || []).map(extractRef)), node.ownerDocument.body, focusHiddenMarker);
|
|
5221
|
-
}
|
|
5222
|
-
setActiveNode(function () {
|
|
5223
|
-
return node;
|
|
5224
|
-
});
|
|
5225
|
-
};
|
|
5226
|
-
var onNodeDeactivation = function onNodeDeactivation() {
|
|
5227
|
-
_undo();
|
|
5228
|
-
if (!unmounted) {
|
|
5229
|
-
setActiveNode(null);
|
|
5230
|
-
}
|
|
5231
|
-
};
|
|
5226
|
+
if (noIsolation || !activeNode) {
|
|
5227
|
+
return;
|
|
5228
|
+
}
|
|
5229
|
+
return hideOthers(__spreadArrays([activeNode], (shards || []).map(extractRef)), activeNode.ownerDocument.body, focusHiddenMarker);
|
|
5230
|
+
}, [activeNode, noIsolation]);
|
|
5231
|
+
React.useEffect(function () {
|
|
5232
5232
|
setLockProps({
|
|
5233
5233
|
onMouseDown: function onMouseDown(e) {
|
|
5234
5234
|
lastEventTarget.current = e.target;
|
|
5235
5235
|
},
|
|
5236
5236
|
onTouchStart: function onTouchStart(e) {
|
|
5237
5237
|
lastEventTarget.current = e.target;
|
|
5238
|
-
}
|
|
5239
|
-
onActivation: onNodeActivation,
|
|
5240
|
-
onDeactivation: onNodeDeactivation
|
|
5238
|
+
}
|
|
5241
5239
|
});
|
|
5242
5240
|
return function () {
|
|
5243
|
-
unmounted = true;
|
|
5244
5241
|
setLockProps(false);
|
|
5245
5242
|
};
|
|
5246
5243
|
}, []);
|
|
@@ -10014,6 +10011,13 @@ var ChevronUp12 = function ChevronUp12(_a) {
|
|
|
10014
10011
|
};
|
|
10015
10012
|
ChevronUp12.displayName = 'ChevronUp12';
|
|
10016
10013
|
|
|
10014
|
+
var FormControlContext = /*#__PURE__*/React.createContext({
|
|
10015
|
+
displaysError: false
|
|
10016
|
+
});
|
|
10017
|
+
var useFormControlContext = function useFormControlContext() {
|
|
10018
|
+
return React.useContext(FormControlContext);
|
|
10019
|
+
};
|
|
10020
|
+
|
|
10017
10021
|
var dist$1 = {};
|
|
10018
10022
|
|
|
10019
10023
|
var mapCursorToMax = {};
|
|
@@ -10572,7 +10576,8 @@ function e(e, r$1) {
|
|
|
10572
10576
|
}
|
|
10573
10577
|
|
|
10574
10578
|
var SelectOption = function SelectOption(_ref) {
|
|
10575
|
-
var
|
|
10579
|
+
var id = _ref.id,
|
|
10580
|
+
active = _ref.active,
|
|
10576
10581
|
selected = _ref.selected,
|
|
10577
10582
|
option = _ref.option,
|
|
10578
10583
|
_ref$option = _ref.option,
|
|
@@ -10596,6 +10601,7 @@ var SelectOption = function SelectOption(_ref) {
|
|
|
10596
10601
|
}
|
|
10597
10602
|
}, [active, ref]);
|
|
10598
10603
|
return /*#__PURE__*/React.createElement("li", {
|
|
10604
|
+
id: id,
|
|
10599
10605
|
ref: ref,
|
|
10600
10606
|
className: classNames('SelectOption', className, {
|
|
10601
10607
|
'SelectOption--active': active,
|
|
@@ -10604,8 +10610,8 @@ var SelectOption = function SelectOption(_ref) {
|
|
|
10604
10610
|
}),
|
|
10605
10611
|
onClick: handleClick,
|
|
10606
10612
|
"data-test-id": dataTestId ? "".concat(dataTestId, "--").concat(label.replace(' ', '-')) : undefined,
|
|
10607
|
-
"aria-label": label,
|
|
10608
10613
|
"aria-selected": selected,
|
|
10614
|
+
"aria-disabled": disabled || undefined,
|
|
10609
10615
|
role: "option"
|
|
10610
10616
|
}, colorSwatch && /*#__PURE__*/React.createElement("div", {
|
|
10611
10617
|
className: "SelectOption__color-swatch",
|
|
@@ -10672,12 +10678,13 @@ var SelectOptions = function SelectOptions(_ref) {
|
|
|
10672
10678
|
return setSearchPhrase('');
|
|
10673
10679
|
}
|
|
10674
10680
|
}), /*#__PURE__*/React.createElement("ul", _extends$1({
|
|
10681
|
+
id: "Select__listbox--".concat(idRef),
|
|
10675
10682
|
className: "SelectOptions__list",
|
|
10676
10683
|
tabIndex: -1,
|
|
10677
10684
|
role: "listbox",
|
|
10678
10685
|
ref: ref,
|
|
10679
|
-
"aria-
|
|
10680
|
-
"aria-activedescendant": "SelectOption--".concat(activeOption
|
|
10686
|
+
"aria-label": "Options",
|
|
10687
|
+
"aria-activedescendant": activeOption ? "SelectOption--".concat(activeOption.value).concat(idRef ? "-".concat(idRef) : '') : undefined
|
|
10681
10688
|
}, rest), options.map(function (option) {
|
|
10682
10689
|
return /*#__PURE__*/React.createElement(SelectOption, {
|
|
10683
10690
|
id: "SelectOption--".concat(option.value).concat(idRef ? "-".concat(idRef) : ''),
|
|
@@ -10708,8 +10715,9 @@ var SelectLabel = function SelectLabel(_ref) {
|
|
|
10708
10715
|
label = _ref.label,
|
|
10709
10716
|
hasValue = _ref.hasValue;
|
|
10710
10717
|
if (!label) return null;
|
|
10711
|
-
return /*#__PURE__*/React.createElement("
|
|
10712
|
-
id: "Select__label--".concat(idRef)
|
|
10718
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
10719
|
+
id: "Select__label--".concat(idRef),
|
|
10720
|
+
className: "Select__label"
|
|
10713
10721
|
}, "".concat(label).concat(hasValue ? ': ' : ''));
|
|
10714
10722
|
};
|
|
10715
10723
|
|
|
@@ -10738,7 +10746,8 @@ var reducer = function reducer(state, action) {
|
|
|
10738
10746
|
});
|
|
10739
10747
|
case 'CLOSE':
|
|
10740
10748
|
return _objectSpread2(_objectSpread2({}, state), {}, {
|
|
10741
|
-
mode: Mode$1.Resting
|
|
10749
|
+
mode: Mode$1.Resting,
|
|
10750
|
+
focused: undefined
|
|
10742
10751
|
});
|
|
10743
10752
|
case 'SELECT':
|
|
10744
10753
|
return _objectSpread2(_objectSpread2({}, state), {}, {
|
|
@@ -10756,6 +10765,7 @@ var useSelect = function useSelect(_ref) {
|
|
|
10756
10765
|
var value = _ref.value,
|
|
10757
10766
|
defaultValue = _ref.defaultValue;
|
|
10758
10767
|
var selectRef = React.useRef(null);
|
|
10768
|
+
var buttonRef = React.useRef(null);
|
|
10759
10769
|
var initialValue = value !== null && value !== void 0 ? value : defaultValue;
|
|
10760
10770
|
var _useReducer = React.useReducer(reducer, {
|
|
10761
10771
|
value: initialValue,
|
|
@@ -10769,10 +10779,13 @@ var useSelect = function useSelect(_ref) {
|
|
|
10769
10779
|
switch (event.key) {
|
|
10770
10780
|
case 'Escape':
|
|
10771
10781
|
{
|
|
10782
|
+
var _buttonRef$current;
|
|
10772
10783
|
event.preventDefault();
|
|
10773
|
-
|
|
10784
|
+
dispatch({
|
|
10774
10785
|
type: 'CLOSE'
|
|
10775
10786
|
});
|
|
10787
|
+
(_buttonRef$current = buttonRef.current) === null || _buttonRef$current === void 0 || _buttonRef$current.focus();
|
|
10788
|
+
break;
|
|
10776
10789
|
}
|
|
10777
10790
|
}
|
|
10778
10791
|
}, []);
|
|
@@ -10802,13 +10815,14 @@ var useSelect = function useSelect(_ref) {
|
|
|
10802
10815
|
state: state,
|
|
10803
10816
|
dispatch: dispatch,
|
|
10804
10817
|
Mode: Mode$1,
|
|
10805
|
-
selectRef: selectRef
|
|
10818
|
+
selectRef: selectRef,
|
|
10819
|
+
buttonRef: buttonRef
|
|
10806
10820
|
};
|
|
10807
10821
|
};
|
|
10808
10822
|
|
|
10809
10823
|
var _excluded$j = ["allowAutoFill", "autoSelect", "className", "defaultValue", "disabled", "dropDirection", "error", "idRef", "label", "name", "onChange", "options", "placeholder", "searchable", "shiftIconLeftwards", "value", "dataTestId", "colorSwatch", "extraOption", "paddingRight", "smallMobileText"];
|
|
10810
10824
|
var Select = function Select(_ref) {
|
|
10811
|
-
var _ref2;
|
|
10825
|
+
var _ref2, _ref3;
|
|
10812
10826
|
var _ref$allowAutoFill = _ref.allowAutoFill,
|
|
10813
10827
|
allowAutoFill = _ref$allowAutoFill === void 0 ? false : _ref$allowAutoFill,
|
|
10814
10828
|
_ref$autoSelect = _ref.autoSelect,
|
|
@@ -10837,6 +10851,8 @@ var Select = function Select(_ref) {
|
|
|
10837
10851
|
_ref$smallMobileText = _ref.smallMobileText,
|
|
10838
10852
|
smallMobileText = _ref$smallMobileText === void 0 ? false : _ref$smallMobileText,
|
|
10839
10853
|
rest = _objectWithoutProperties(_ref, _excluded$j);
|
|
10854
|
+
var _useFormControlContex = useFormControlContext(),
|
|
10855
|
+
errorDisplayedByParent = _useFormControlContex.displaysError;
|
|
10840
10856
|
var _useSelect = useSelect({
|
|
10841
10857
|
value: value,
|
|
10842
10858
|
defaultValue: defaultValue
|
|
@@ -10844,7 +10860,8 @@ var Select = function Select(_ref) {
|
|
|
10844
10860
|
state = _useSelect.state,
|
|
10845
10861
|
dispatch = _useSelect.dispatch,
|
|
10846
10862
|
Mode = _useSelect.Mode,
|
|
10847
|
-
selectRef = _useSelect.selectRef
|
|
10863
|
+
selectRef = _useSelect.selectRef,
|
|
10864
|
+
buttonRef = _useSelect.buttonRef;
|
|
10848
10865
|
var handleSelect = React.useCallback(function (option) {
|
|
10849
10866
|
dispatch({
|
|
10850
10867
|
type: 'SELECT',
|
|
@@ -10903,8 +10920,9 @@ var Select = function Select(_ref) {
|
|
|
10903
10920
|
id: idRef,
|
|
10904
10921
|
name: name,
|
|
10905
10922
|
type: "hidden",
|
|
10906
|
-
value: state.value
|
|
10923
|
+
value: state.value || ''
|
|
10907
10924
|
}), /*#__PURE__*/React.createElement(Clickable, {
|
|
10925
|
+
ref: buttonRef,
|
|
10908
10926
|
id: idRef && "Select__value--".concat(idRef),
|
|
10909
10927
|
className: classNames('Select__value', _defineProperty$1(_defineProperty$1({}, "Select__value--padding-".concat(paddingRight), paddingRight != null), 'Select__value--small', smallMobileText)),
|
|
10910
10928
|
disabled: disabled,
|
|
@@ -10912,9 +10930,11 @@ var Select = function Select(_ref) {
|
|
|
10912
10930
|
"data-test-id": dataTestId,
|
|
10913
10931
|
"aria-haspopup": "listbox",
|
|
10914
10932
|
"aria-expanded": state.mode === Mode.Open,
|
|
10915
|
-
"aria-labelledby": "Select__label--".concat(idRef
|
|
10916
|
-
|
|
10917
|
-
|
|
10933
|
+
"aria-labelledby": label ? "Select__label--".concat(idRef).concat((_ref2 = focused !== null && focused !== void 0 ? focused : selected) !== null && _ref2 !== void 0 && _ref2.label ? " Select__valueText--".concat(idRef) : '') : undefined,
|
|
10934
|
+
"aria-label": !label ? placeholder || 'Select an option' : undefined,
|
|
10935
|
+
"aria-invalid": error ? true : undefined,
|
|
10936
|
+
"aria-controls": state.mode === Mode.Open ? "Select__listbox--".concat(idRef) : undefined,
|
|
10937
|
+
type: "button"
|
|
10918
10938
|
}, /*#__PURE__*/React.createElement(SelectLabel, {
|
|
10919
10939
|
idRef: idRef,
|
|
10920
10940
|
label: label || (selected === undefined ? placeholder : undefined),
|
|
@@ -10924,11 +10944,17 @@ var Select = function Select(_ref) {
|
|
|
10924
10944
|
style: {
|
|
10925
10945
|
backgroundColor: distExports$4.colors.all[colorSwatch]
|
|
10926
10946
|
}
|
|
10927
|
-
}),
|
|
10947
|
+
}), /*#__PURE__*/React.createElement("span", {
|
|
10948
|
+
id: "Select__valueText--".concat(idRef)
|
|
10949
|
+
}, (_ref3 = focused !== null && focused !== void 0 ? focused : selected) === null || _ref3 === void 0 ? void 0 : _ref3.label), /*#__PURE__*/React.createElement("span", {
|
|
10928
10950
|
className: classNames('Select__icon', {
|
|
10929
10951
|
'Select__icon--shifted': shiftIconLeftwards
|
|
10930
10952
|
})
|
|
10931
|
-
}, state.mode === Mode.Open ? /*#__PURE__*/React.createElement(ChevronUp12,
|
|
10953
|
+
}, state.mode === Mode.Open ? /*#__PURE__*/React.createElement(ChevronUp12, {
|
|
10954
|
+
"aria-hidden": "true"
|
|
10955
|
+
}) : /*#__PURE__*/React.createElement(ChevronDown12, {
|
|
10956
|
+
"aria-hidden": "true"
|
|
10957
|
+
}))), state.mode === Mode.Open && /*#__PURE__*/React.createElement(SelectOptions, {
|
|
10932
10958
|
idRef: idRef,
|
|
10933
10959
|
className: classNames('Select__options', {
|
|
10934
10960
|
'Select__options--up': dropDirection === 'up',
|
|
@@ -10946,11 +10972,16 @@ var Select = function Select(_ref) {
|
|
|
10946
10972
|
type: 'CLOSE'
|
|
10947
10973
|
});
|
|
10948
10974
|
}
|
|
10949
|
-
})),
|
|
10975
|
+
})), typeof error === 'string' && !errorDisplayedByParent && /*#__PURE__*/React.createElement("div", {
|
|
10976
|
+
role: "status",
|
|
10977
|
+
"aria-live": "polite",
|
|
10978
|
+
"aria-atomic": "true",
|
|
10979
|
+
className: "Select__live-region"
|
|
10980
|
+
}, error), allowAutoFill && /*#__PURE__*/React.createElement("input", {
|
|
10950
10981
|
className: "Select__hidden-field",
|
|
10951
10982
|
name: name,
|
|
10952
|
-
onChange: function onChange(
|
|
10953
|
-
var target =
|
|
10983
|
+
onChange: function onChange(_ref4) {
|
|
10984
|
+
var target = _ref4.target;
|
|
10954
10985
|
return handleAutofill(target.value);
|
|
10955
10986
|
},
|
|
10956
10987
|
value: value,
|
|
@@ -11039,6 +11070,18 @@ var MultiSelect = function MultiSelect(_ref) {
|
|
|
11039
11070
|
var values = React.useMemo(function () {
|
|
11040
11071
|
return Array.isArray(state.value) ? state.value : [];
|
|
11041
11072
|
}, [state.value]);
|
|
11073
|
+
var selectedLabels = React.useMemo(function () {
|
|
11074
|
+
return values.map(function (value) {
|
|
11075
|
+
var _options$find;
|
|
11076
|
+
return ((_options$find = options.find(function (option) {
|
|
11077
|
+
return option.value === value;
|
|
11078
|
+
})) === null || _options$find === void 0 ? void 0 : _options$find.label) || value;
|
|
11079
|
+
});
|
|
11080
|
+
}, [values, options]);
|
|
11081
|
+
var accessibleLabel = React.useMemo(function () {
|
|
11082
|
+
if (selectedLabels.length === 0) return 'Select options';
|
|
11083
|
+
return "Select options, ".concat(selectedLabels.length, " selected: ").concat(selectedLabels.join(', '));
|
|
11084
|
+
}, [selectedLabels]);
|
|
11042
11085
|
var handleSelect = React.useCallback(function (option) {
|
|
11043
11086
|
dispatch({
|
|
11044
11087
|
type: 'SELECT',
|
|
@@ -11083,19 +11126,24 @@ var MultiSelect = function MultiSelect(_ref) {
|
|
|
11083
11126
|
}, rest), /*#__PURE__*/React.createElement(Clickable, {
|
|
11084
11127
|
className: "MultiSelect__search",
|
|
11085
11128
|
disabled: disabled,
|
|
11086
|
-
onClick: handleToggle
|
|
11129
|
+
onClick: handleToggle,
|
|
11130
|
+
"aria-haspopup": "listbox",
|
|
11131
|
+
"aria-expanded": state.mode === Mode.Open,
|
|
11132
|
+
"aria-controls": state.mode === Mode.Open ? "Select__listbox--".concat(idRef) : undefined,
|
|
11133
|
+
"aria-label": accessibleLabel,
|
|
11134
|
+
type: "button"
|
|
11087
11135
|
}, /*#__PURE__*/React.createElement("div", {
|
|
11088
11136
|
className: "MultiSelect__selected-items"
|
|
11089
11137
|
}, values.map(function (value, index) {
|
|
11090
|
-
var _options$
|
|
11138
|
+
var _options$find2;
|
|
11091
11139
|
return /*#__PURE__*/React.createElement("span", {
|
|
11092
11140
|
className: "MultiSelect__selected-item",
|
|
11093
11141
|
key: index
|
|
11094
11142
|
}, /*#__PURE__*/React.createElement("span", {
|
|
11095
11143
|
className: "MultiSelect__selected-value"
|
|
11096
|
-
}, ((_options$
|
|
11144
|
+
}, ((_options$find2 = options.find(function (option) {
|
|
11097
11145
|
return option.value === value;
|
|
11098
|
-
})) === null || _options$
|
|
11146
|
+
})) === null || _options$find2 === void 0 ? void 0 : _options$find2.label) || value), /*#__PURE__*/React.createElement(Exit16, {
|
|
11099
11147
|
style: {
|
|
11100
11148
|
width: '8px',
|
|
11101
11149
|
height: '8px',
|
|
@@ -11119,8 +11167,7 @@ var MultiSelect = function MultiSelect(_ref) {
|
|
|
11119
11167
|
searchable: searchable,
|
|
11120
11168
|
options: options,
|
|
11121
11169
|
onSelect: handleSelect,
|
|
11122
|
-
onFocus: handleFocus
|
|
11123
|
-
autoFocus: false
|
|
11170
|
+
onFocus: handleFocus
|
|
11124
11171
|
}));
|
|
11125
11172
|
};
|
|
11126
11173
|
|
|
@@ -11132,7 +11179,14 @@ var Field = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
11132
11179
|
label = _ref.label,
|
|
11133
11180
|
placeholder = _ref.placeholder,
|
|
11134
11181
|
rest = _objectWithoutProperties(_ref, _excluded$h);
|
|
11135
|
-
|
|
11182
|
+
var fieldContextValue = React.useMemo(function () {
|
|
11183
|
+
return {
|
|
11184
|
+
displaysError: Boolean(error)
|
|
11185
|
+
};
|
|
11186
|
+
}, [error]);
|
|
11187
|
+
return /*#__PURE__*/React.createElement(FormControlContext.Provider, {
|
|
11188
|
+
value: fieldContextValue
|
|
11189
|
+
}, /*#__PURE__*/React.createElement("label", {
|
|
11136
11190
|
className: classNames('Field', className)
|
|
11137
11191
|
}, label && /*#__PURE__*/React.createElement("span", {
|
|
11138
11192
|
className: "Field__label"
|
|
@@ -11155,7 +11209,7 @@ var Field = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
11155
11209
|
className: "Field__icon"
|
|
11156
11210
|
}, /*#__PURE__*/React.createElement(Warning16, null)))), error && /*#__PURE__*/React.createElement("span", {
|
|
11157
11211
|
className: "Field__error"
|
|
11158
|
-
}, error));
|
|
11212
|
+
}, error)));
|
|
11159
11213
|
});
|
|
11160
11214
|
Field.displayName = 'Field';
|
|
11161
11215
|
|
|
@@ -12739,6 +12793,7 @@ exports.ExceedConstrain = ExceedConstrain;
|
|
|
12739
12793
|
exports.Expandable = Expandable;
|
|
12740
12794
|
exports.Field = Field;
|
|
12741
12795
|
exports.FocusOn = FocusOn;
|
|
12796
|
+
exports.FormControlContext = FormControlContext;
|
|
12742
12797
|
exports.Input = Field;
|
|
12743
12798
|
exports.Keyhole = Keyhole;
|
|
12744
12799
|
exports.Label = Label;
|
|
@@ -12798,5 +12853,6 @@ exports.tokens = tokens;
|
|
|
12798
12853
|
exports.useBreakpoint = useBreakpoint;
|
|
12799
12854
|
exports.useClickOutside = useClickOutside;
|
|
12800
12855
|
exports.useConfirm = useConfirm;
|
|
12856
|
+
exports.useFormControlContext = useFormControlContext;
|
|
12801
12857
|
exports.useKeyboardListNavigation = useKeyboardListNavigation;
|
|
12802
12858
|
exports.useUpdateEffect = useUpdateEffect;
|