@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.esm.js
CHANGED
|
@@ -3019,9 +3019,11 @@ var FocusLock = /*#__PURE__*/forwardRef(function FocusLockUI(props, parentRef) {
|
|
|
3019
3019
|
observed: observed,
|
|
3020
3020
|
shards: shards,
|
|
3021
3021
|
enabled: !disabled,
|
|
3022
|
-
active
|
|
3022
|
+
get active() {
|
|
3023
|
+
return isActive.current;
|
|
3024
|
+
}
|
|
3023
3025
|
};
|
|
3024
|
-
}, [disabled, isActive
|
|
3026
|
+
}, [disabled, isActive, shards, observed]);
|
|
3025
3027
|
return /*#__PURE__*/React__default.createElement(Fragment, null, hasLeadingGuards && [/*#__PURE__*/
|
|
3026
3028
|
React__default.createElement("div", {
|
|
3027
3029
|
key: "guard-first",
|
|
@@ -3094,6 +3096,8 @@ var extractRef$2 = function extractRef(ref) {
|
|
|
3094
3096
|
var effectCar = createSidecarMedium();
|
|
3095
3097
|
var focusHiddenMarker = 'data-focus-on-hidden';
|
|
3096
3098
|
|
|
3099
|
+
__assign$a({}, RemoveScroll.classNames);
|
|
3100
|
+
|
|
3097
3101
|
var PREVENT_SCROLL = {
|
|
3098
3102
|
preventScroll: true
|
|
3099
3103
|
};
|
|
@@ -3101,18 +3105,21 @@ var FocusOn$1 = /*#__PURE__*/React.forwardRef(function (props, parentRef) {
|
|
|
3101
3105
|
var _a = React.useState(false),
|
|
3102
3106
|
lockProps = _a[0],
|
|
3103
3107
|
setLockProps = _a[1];
|
|
3108
|
+
var _b = React.useState(null),
|
|
3109
|
+
activeNode = _b[0],
|
|
3110
|
+
setActiveNode = _b[1];
|
|
3104
3111
|
var children = props.children,
|
|
3105
3112
|
autoFocus = props.autoFocus,
|
|
3106
3113
|
shards = props.shards,
|
|
3107
3114
|
crossFrame = props.crossFrame,
|
|
3108
|
-
|
|
3109
|
-
enabled =
|
|
3110
|
-
|
|
3111
|
-
scrollLock =
|
|
3112
|
-
|
|
3113
|
-
focusLock =
|
|
3114
|
-
|
|
3115
|
-
returnFocus =
|
|
3115
|
+
_c = props.enabled,
|
|
3116
|
+
enabled = _c === void 0 ? true : _c,
|
|
3117
|
+
_d = props.scrollLock,
|
|
3118
|
+
scrollLock = _d === void 0 ? true : _d,
|
|
3119
|
+
_e = props.focusLock,
|
|
3120
|
+
focusLock = _e === void 0 ? true : _e,
|
|
3121
|
+
_f = props.returnFocus,
|
|
3122
|
+
returnFocus = _f === void 0 ? true : _f,
|
|
3116
3123
|
inert = props.inert,
|
|
3117
3124
|
allowPinchZoom = props.allowPinchZoom,
|
|
3118
3125
|
sideCar = props.sideCar,
|
|
@@ -3124,10 +3131,7 @@ var FocusOn$1 = /*#__PURE__*/React.forwardRef(function (props, parentRef) {
|
|
|
3124
3131
|
gapMode = props.gapMode,
|
|
3125
3132
|
rest = __rest$a(props, ["children", "autoFocus", "shards", "crossFrame", "enabled", "scrollLock", "focusLock", "returnFocus", "inert", "allowPinchZoom", "sideCar", "className", "shouldIgnore", "preventScrollOnFocus", "style", "as", "gapMode"]);
|
|
3126
3133
|
var SideCar = sideCar;
|
|
3127
|
-
var
|
|
3128
|
-
onDeactivation = lockProps.onDeactivation,
|
|
3129
|
-
restProps = __rest$a(lockProps, ["onActivation", "onDeactivation"]);
|
|
3130
|
-
var appliedLockProps = __assign$a(__assign$a({}, restProps), {
|
|
3134
|
+
var appliedLockProps = __assign$a(__assign$a({}, lockProps), {
|
|
3131
3135
|
as: as,
|
|
3132
3136
|
style: style,
|
|
3133
3137
|
sideCar: sideCar,
|
|
@@ -3137,10 +3141,16 @@ var FocusOn$1 = /*#__PURE__*/React.forwardRef(function (props, parentRef) {
|
|
|
3137
3141
|
inert: inert,
|
|
3138
3142
|
enabled: enabled && scrollLock
|
|
3139
3143
|
});
|
|
3144
|
+
var onActivation = React.useCallback(function (node) {
|
|
3145
|
+
setActiveNode(node);
|
|
3146
|
+
}, []);
|
|
3147
|
+
var onDeactivation = React.useCallback(function () {
|
|
3148
|
+
setActiveNode(null);
|
|
3149
|
+
}, []);
|
|
3140
3150
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FocusLock, {
|
|
3141
3151
|
ref: parentRef,
|
|
3142
3152
|
sideCar: sideCar,
|
|
3143
|
-
disabled: !(
|
|
3153
|
+
disabled: !(enabled && focusLock),
|
|
3144
3154
|
returnFocus: returnFocus,
|
|
3145
3155
|
autoFocus: autoFocus,
|
|
3146
3156
|
shards: shards,
|
|
@@ -3151,11 +3161,13 @@ var FocusOn$1 = /*#__PURE__*/React.forwardRef(function (props, parentRef) {
|
|
|
3151
3161
|
whiteList: shouldIgnore,
|
|
3152
3162
|
lockProps: appliedLockProps,
|
|
3153
3163
|
focusOptions: preventScrollOnFocus ? PREVENT_SCROLL : undefined,
|
|
3164
|
+
// // ts-expect-error TS2322 - ts v3 "glitch"
|
|
3154
3165
|
as: RemoveScroll
|
|
3155
3166
|
}, children), enabled && (/*#__PURE__*/React.createElement(SideCar, __assign$a({}, rest, {
|
|
3156
3167
|
sideCar: effectCar,
|
|
3157
3168
|
setLockProps: setLockProps,
|
|
3158
|
-
shards: shards
|
|
3169
|
+
shards: shards,
|
|
3170
|
+
activeNode: activeNode
|
|
3159
3171
|
}))));
|
|
3160
3172
|
});
|
|
3161
3173
|
|
|
@@ -5131,10 +5143,8 @@ function Effect(_a) {
|
|
|
5131
5143
|
shards = _a.shards,
|
|
5132
5144
|
onActivation = _a.onActivation,
|
|
5133
5145
|
onDeactivation = _a.onDeactivation,
|
|
5134
|
-
noIsolation = _a.noIsolation
|
|
5135
|
-
|
|
5136
|
-
activeNode = _b[0],
|
|
5137
|
-
setActiveNode = _b[1];
|
|
5146
|
+
noIsolation = _a.noIsolation,
|
|
5147
|
+
activeNode = _a.activeNode;
|
|
5138
5148
|
var lastEventTarget = useRef(null);
|
|
5139
5149
|
var mouseTouches = useRef(0);
|
|
5140
5150
|
React.useEffect(function () {
|
|
@@ -5177,6 +5187,7 @@ function Effect(_a) {
|
|
|
5177
5187
|
activeNode.ownerDocument.removeEventListener('touchend', onTouchEnd);
|
|
5178
5188
|
};
|
|
5179
5189
|
}
|
|
5190
|
+
return;
|
|
5180
5191
|
}, [activeNode, onClickOutside, onEscapeKey]);
|
|
5181
5192
|
useEffect(function () {
|
|
5182
5193
|
if (activeNode) {
|
|
@@ -5189,38 +5200,24 @@ function Effect(_a) {
|
|
|
5189
5200
|
}
|
|
5190
5201
|
};
|
|
5191
5202
|
}
|
|
5203
|
+
return;
|
|
5192
5204
|
}, [!!activeNode]);
|
|
5193
5205
|
useEffect(function () {
|
|
5194
|
-
|
|
5195
|
-
return
|
|
5196
|
-
}
|
|
5197
|
-
|
|
5198
|
-
|
|
5199
|
-
|
|
5200
|
-
_undo = hideOthers(__spreadArrays([node], (shards || []).map(extractRef)), node.ownerDocument.body, focusHiddenMarker);
|
|
5201
|
-
}
|
|
5202
|
-
setActiveNode(function () {
|
|
5203
|
-
return node;
|
|
5204
|
-
});
|
|
5205
|
-
};
|
|
5206
|
-
var onNodeDeactivation = function onNodeDeactivation() {
|
|
5207
|
-
_undo();
|
|
5208
|
-
if (!unmounted) {
|
|
5209
|
-
setActiveNode(null);
|
|
5210
|
-
}
|
|
5211
|
-
};
|
|
5206
|
+
if (noIsolation || !activeNode) {
|
|
5207
|
+
return;
|
|
5208
|
+
}
|
|
5209
|
+
return hideOthers(__spreadArrays([activeNode], (shards || []).map(extractRef)), activeNode.ownerDocument.body, focusHiddenMarker);
|
|
5210
|
+
}, [activeNode, noIsolation]);
|
|
5211
|
+
useEffect(function () {
|
|
5212
5212
|
setLockProps({
|
|
5213
5213
|
onMouseDown: function onMouseDown(e) {
|
|
5214
5214
|
lastEventTarget.current = e.target;
|
|
5215
5215
|
},
|
|
5216
5216
|
onTouchStart: function onTouchStart(e) {
|
|
5217
5217
|
lastEventTarget.current = e.target;
|
|
5218
|
-
}
|
|
5219
|
-
onActivation: onNodeActivation,
|
|
5220
|
-
onDeactivation: onNodeDeactivation
|
|
5218
|
+
}
|
|
5221
5219
|
});
|
|
5222
5220
|
return function () {
|
|
5223
|
-
unmounted = true;
|
|
5224
5221
|
setLockProps(false);
|
|
5225
5222
|
};
|
|
5226
5223
|
}, []);
|
|
@@ -9994,6 +9991,13 @@ var ChevronUp12 = function ChevronUp12(_a) {
|
|
|
9994
9991
|
};
|
|
9995
9992
|
ChevronUp12.displayName = 'ChevronUp12';
|
|
9996
9993
|
|
|
9994
|
+
var FormControlContext = /*#__PURE__*/createContext({
|
|
9995
|
+
displaysError: false
|
|
9996
|
+
});
|
|
9997
|
+
var useFormControlContext = function useFormControlContext() {
|
|
9998
|
+
return useContext(FormControlContext);
|
|
9999
|
+
};
|
|
10000
|
+
|
|
9997
10001
|
var dist$1 = {};
|
|
9998
10002
|
|
|
9999
10003
|
var mapCursorToMax = {};
|
|
@@ -10552,7 +10556,8 @@ function e(e, r$1) {
|
|
|
10552
10556
|
}
|
|
10553
10557
|
|
|
10554
10558
|
var SelectOption = function SelectOption(_ref) {
|
|
10555
|
-
var
|
|
10559
|
+
var id = _ref.id,
|
|
10560
|
+
active = _ref.active,
|
|
10556
10561
|
selected = _ref.selected,
|
|
10557
10562
|
option = _ref.option,
|
|
10558
10563
|
_ref$option = _ref.option,
|
|
@@ -10576,6 +10581,7 @@ var SelectOption = function SelectOption(_ref) {
|
|
|
10576
10581
|
}
|
|
10577
10582
|
}, [active, ref]);
|
|
10578
10583
|
return /*#__PURE__*/React__default.createElement("li", {
|
|
10584
|
+
id: id,
|
|
10579
10585
|
ref: ref,
|
|
10580
10586
|
className: classNames('SelectOption', className, {
|
|
10581
10587
|
'SelectOption--active': active,
|
|
@@ -10584,8 +10590,8 @@ var SelectOption = function SelectOption(_ref) {
|
|
|
10584
10590
|
}),
|
|
10585
10591
|
onClick: handleClick,
|
|
10586
10592
|
"data-test-id": dataTestId ? "".concat(dataTestId, "--").concat(label.replace(' ', '-')) : undefined,
|
|
10587
|
-
"aria-label": label,
|
|
10588
10593
|
"aria-selected": selected,
|
|
10594
|
+
"aria-disabled": disabled || undefined,
|
|
10589
10595
|
role: "option"
|
|
10590
10596
|
}, colorSwatch && /*#__PURE__*/React__default.createElement("div", {
|
|
10591
10597
|
className: "SelectOption__color-swatch",
|
|
@@ -10652,12 +10658,13 @@ var SelectOptions = function SelectOptions(_ref) {
|
|
|
10652
10658
|
return setSearchPhrase('');
|
|
10653
10659
|
}
|
|
10654
10660
|
}), /*#__PURE__*/React__default.createElement("ul", _extends$1({
|
|
10661
|
+
id: "Select__listbox--".concat(idRef),
|
|
10655
10662
|
className: "SelectOptions__list",
|
|
10656
10663
|
tabIndex: -1,
|
|
10657
10664
|
role: "listbox",
|
|
10658
10665
|
ref: ref,
|
|
10659
|
-
"aria-
|
|
10660
|
-
"aria-activedescendant": "SelectOption--".concat(activeOption
|
|
10666
|
+
"aria-label": "Options",
|
|
10667
|
+
"aria-activedescendant": activeOption ? "SelectOption--".concat(activeOption.value).concat(idRef ? "-".concat(idRef) : '') : undefined
|
|
10661
10668
|
}, rest), options.map(function (option) {
|
|
10662
10669
|
return /*#__PURE__*/React__default.createElement(SelectOption, {
|
|
10663
10670
|
id: "SelectOption--".concat(option.value).concat(idRef ? "-".concat(idRef) : ''),
|
|
@@ -10688,8 +10695,9 @@ var SelectLabel = function SelectLabel(_ref) {
|
|
|
10688
10695
|
label = _ref.label,
|
|
10689
10696
|
hasValue = _ref.hasValue;
|
|
10690
10697
|
if (!label) return null;
|
|
10691
|
-
return /*#__PURE__*/React__default.createElement("
|
|
10692
|
-
id: "Select__label--".concat(idRef)
|
|
10698
|
+
return /*#__PURE__*/React__default.createElement("span", {
|
|
10699
|
+
id: "Select__label--".concat(idRef),
|
|
10700
|
+
className: "Select__label"
|
|
10693
10701
|
}, "".concat(label).concat(hasValue ? ': ' : ''));
|
|
10694
10702
|
};
|
|
10695
10703
|
|
|
@@ -10718,7 +10726,8 @@ var reducer = function reducer(state, action) {
|
|
|
10718
10726
|
});
|
|
10719
10727
|
case 'CLOSE':
|
|
10720
10728
|
return _objectSpread2(_objectSpread2({}, state), {}, {
|
|
10721
|
-
mode: Mode$1.Resting
|
|
10729
|
+
mode: Mode$1.Resting,
|
|
10730
|
+
focused: undefined
|
|
10722
10731
|
});
|
|
10723
10732
|
case 'SELECT':
|
|
10724
10733
|
return _objectSpread2(_objectSpread2({}, state), {}, {
|
|
@@ -10736,6 +10745,7 @@ var useSelect = function useSelect(_ref) {
|
|
|
10736
10745
|
var value = _ref.value,
|
|
10737
10746
|
defaultValue = _ref.defaultValue;
|
|
10738
10747
|
var selectRef = useRef(null);
|
|
10748
|
+
var buttonRef = useRef(null);
|
|
10739
10749
|
var initialValue = value !== null && value !== void 0 ? value : defaultValue;
|
|
10740
10750
|
var _useReducer = useReducer(reducer, {
|
|
10741
10751
|
value: initialValue,
|
|
@@ -10749,10 +10759,13 @@ var useSelect = function useSelect(_ref) {
|
|
|
10749
10759
|
switch (event.key) {
|
|
10750
10760
|
case 'Escape':
|
|
10751
10761
|
{
|
|
10762
|
+
var _buttonRef$current;
|
|
10752
10763
|
event.preventDefault();
|
|
10753
|
-
|
|
10764
|
+
dispatch({
|
|
10754
10765
|
type: 'CLOSE'
|
|
10755
10766
|
});
|
|
10767
|
+
(_buttonRef$current = buttonRef.current) === null || _buttonRef$current === void 0 || _buttonRef$current.focus();
|
|
10768
|
+
break;
|
|
10756
10769
|
}
|
|
10757
10770
|
}
|
|
10758
10771
|
}, []);
|
|
@@ -10782,13 +10795,14 @@ var useSelect = function useSelect(_ref) {
|
|
|
10782
10795
|
state: state,
|
|
10783
10796
|
dispatch: dispatch,
|
|
10784
10797
|
Mode: Mode$1,
|
|
10785
|
-
selectRef: selectRef
|
|
10798
|
+
selectRef: selectRef,
|
|
10799
|
+
buttonRef: buttonRef
|
|
10786
10800
|
};
|
|
10787
10801
|
};
|
|
10788
10802
|
|
|
10789
10803
|
var _excluded$j = ["allowAutoFill", "autoSelect", "className", "defaultValue", "disabled", "dropDirection", "error", "idRef", "label", "name", "onChange", "options", "placeholder", "searchable", "shiftIconLeftwards", "value", "dataTestId", "colorSwatch", "extraOption", "paddingRight", "smallMobileText"];
|
|
10790
10804
|
var Select = function Select(_ref) {
|
|
10791
|
-
var _ref2;
|
|
10805
|
+
var _ref2, _ref3;
|
|
10792
10806
|
var _ref$allowAutoFill = _ref.allowAutoFill,
|
|
10793
10807
|
allowAutoFill = _ref$allowAutoFill === void 0 ? false : _ref$allowAutoFill,
|
|
10794
10808
|
_ref$autoSelect = _ref.autoSelect,
|
|
@@ -10817,6 +10831,8 @@ var Select = function Select(_ref) {
|
|
|
10817
10831
|
_ref$smallMobileText = _ref.smallMobileText,
|
|
10818
10832
|
smallMobileText = _ref$smallMobileText === void 0 ? false : _ref$smallMobileText,
|
|
10819
10833
|
rest = _objectWithoutProperties(_ref, _excluded$j);
|
|
10834
|
+
var _useFormControlContex = useFormControlContext(),
|
|
10835
|
+
errorDisplayedByParent = _useFormControlContex.displaysError;
|
|
10820
10836
|
var _useSelect = useSelect({
|
|
10821
10837
|
value: value,
|
|
10822
10838
|
defaultValue: defaultValue
|
|
@@ -10824,7 +10840,8 @@ var Select = function Select(_ref) {
|
|
|
10824
10840
|
state = _useSelect.state,
|
|
10825
10841
|
dispatch = _useSelect.dispatch,
|
|
10826
10842
|
Mode = _useSelect.Mode,
|
|
10827
|
-
selectRef = _useSelect.selectRef
|
|
10843
|
+
selectRef = _useSelect.selectRef,
|
|
10844
|
+
buttonRef = _useSelect.buttonRef;
|
|
10828
10845
|
var handleSelect = useCallback(function (option) {
|
|
10829
10846
|
dispatch({
|
|
10830
10847
|
type: 'SELECT',
|
|
@@ -10883,8 +10900,9 @@ var Select = function Select(_ref) {
|
|
|
10883
10900
|
id: idRef,
|
|
10884
10901
|
name: name,
|
|
10885
10902
|
type: "hidden",
|
|
10886
|
-
value: state.value
|
|
10903
|
+
value: state.value || ''
|
|
10887
10904
|
}), /*#__PURE__*/React__default.createElement(Clickable, {
|
|
10905
|
+
ref: buttonRef,
|
|
10888
10906
|
id: idRef && "Select__value--".concat(idRef),
|
|
10889
10907
|
className: classNames('Select__value', _defineProperty$1(_defineProperty$1({}, "Select__value--padding-".concat(paddingRight), paddingRight != null), 'Select__value--small', smallMobileText)),
|
|
10890
10908
|
disabled: disabled,
|
|
@@ -10892,9 +10910,11 @@ var Select = function Select(_ref) {
|
|
|
10892
10910
|
"data-test-id": dataTestId,
|
|
10893
10911
|
"aria-haspopup": "listbox",
|
|
10894
10912
|
"aria-expanded": state.mode === Mode.Open,
|
|
10895
|
-
"aria-labelledby": "Select__label--".concat(idRef
|
|
10896
|
-
|
|
10897
|
-
|
|
10913
|
+
"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,
|
|
10914
|
+
"aria-label": !label ? placeholder || 'Select an option' : undefined,
|
|
10915
|
+
"aria-invalid": error ? true : undefined,
|
|
10916
|
+
"aria-controls": state.mode === Mode.Open ? "Select__listbox--".concat(idRef) : undefined,
|
|
10917
|
+
type: "button"
|
|
10898
10918
|
}, /*#__PURE__*/React__default.createElement(SelectLabel, {
|
|
10899
10919
|
idRef: idRef,
|
|
10900
10920
|
label: label || (selected === undefined ? placeholder : undefined),
|
|
@@ -10904,11 +10924,17 @@ var Select = function Select(_ref) {
|
|
|
10904
10924
|
style: {
|
|
10905
10925
|
backgroundColor: distExports$4.colors.all[colorSwatch]
|
|
10906
10926
|
}
|
|
10907
|
-
}),
|
|
10927
|
+
}), /*#__PURE__*/React__default.createElement("span", {
|
|
10928
|
+
id: "Select__valueText--".concat(idRef)
|
|
10929
|
+
}, (_ref3 = focused !== null && focused !== void 0 ? focused : selected) === null || _ref3 === void 0 ? void 0 : _ref3.label), /*#__PURE__*/React__default.createElement("span", {
|
|
10908
10930
|
className: classNames('Select__icon', {
|
|
10909
10931
|
'Select__icon--shifted': shiftIconLeftwards
|
|
10910
10932
|
})
|
|
10911
|
-
}, state.mode === Mode.Open ? /*#__PURE__*/React__default.createElement(ChevronUp12,
|
|
10933
|
+
}, state.mode === Mode.Open ? /*#__PURE__*/React__default.createElement(ChevronUp12, {
|
|
10934
|
+
"aria-hidden": "true"
|
|
10935
|
+
}) : /*#__PURE__*/React__default.createElement(ChevronDown12, {
|
|
10936
|
+
"aria-hidden": "true"
|
|
10937
|
+
}))), state.mode === Mode.Open && /*#__PURE__*/React__default.createElement(SelectOptions, {
|
|
10912
10938
|
idRef: idRef,
|
|
10913
10939
|
className: classNames('Select__options', {
|
|
10914
10940
|
'Select__options--up': dropDirection === 'up',
|
|
@@ -10926,11 +10952,16 @@ var Select = function Select(_ref) {
|
|
|
10926
10952
|
type: 'CLOSE'
|
|
10927
10953
|
});
|
|
10928
10954
|
}
|
|
10929
|
-
})),
|
|
10955
|
+
})), typeof error === 'string' && !errorDisplayedByParent && /*#__PURE__*/React__default.createElement("div", {
|
|
10956
|
+
role: "status",
|
|
10957
|
+
"aria-live": "polite",
|
|
10958
|
+
"aria-atomic": "true",
|
|
10959
|
+
className: "Select__live-region"
|
|
10960
|
+
}, error), allowAutoFill && /*#__PURE__*/React__default.createElement("input", {
|
|
10930
10961
|
className: "Select__hidden-field",
|
|
10931
10962
|
name: name,
|
|
10932
|
-
onChange: function onChange(
|
|
10933
|
-
var target =
|
|
10963
|
+
onChange: function onChange(_ref4) {
|
|
10964
|
+
var target = _ref4.target;
|
|
10934
10965
|
return handleAutofill(target.value);
|
|
10935
10966
|
},
|
|
10936
10967
|
value: value,
|
|
@@ -11019,6 +11050,18 @@ var MultiSelect = function MultiSelect(_ref) {
|
|
|
11019
11050
|
var values = useMemo(function () {
|
|
11020
11051
|
return Array.isArray(state.value) ? state.value : [];
|
|
11021
11052
|
}, [state.value]);
|
|
11053
|
+
var selectedLabels = useMemo(function () {
|
|
11054
|
+
return values.map(function (value) {
|
|
11055
|
+
var _options$find;
|
|
11056
|
+
return ((_options$find = options.find(function (option) {
|
|
11057
|
+
return option.value === value;
|
|
11058
|
+
})) === null || _options$find === void 0 ? void 0 : _options$find.label) || value;
|
|
11059
|
+
});
|
|
11060
|
+
}, [values, options]);
|
|
11061
|
+
var accessibleLabel = useMemo(function () {
|
|
11062
|
+
if (selectedLabels.length === 0) return 'Select options';
|
|
11063
|
+
return "Select options, ".concat(selectedLabels.length, " selected: ").concat(selectedLabels.join(', '));
|
|
11064
|
+
}, [selectedLabels]);
|
|
11022
11065
|
var handleSelect = useCallback(function (option) {
|
|
11023
11066
|
dispatch({
|
|
11024
11067
|
type: 'SELECT',
|
|
@@ -11063,19 +11106,24 @@ var MultiSelect = function MultiSelect(_ref) {
|
|
|
11063
11106
|
}, rest), /*#__PURE__*/React__default.createElement(Clickable, {
|
|
11064
11107
|
className: "MultiSelect__search",
|
|
11065
11108
|
disabled: disabled,
|
|
11066
|
-
onClick: handleToggle
|
|
11109
|
+
onClick: handleToggle,
|
|
11110
|
+
"aria-haspopup": "listbox",
|
|
11111
|
+
"aria-expanded": state.mode === Mode.Open,
|
|
11112
|
+
"aria-controls": state.mode === Mode.Open ? "Select__listbox--".concat(idRef) : undefined,
|
|
11113
|
+
"aria-label": accessibleLabel,
|
|
11114
|
+
type: "button"
|
|
11067
11115
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
11068
11116
|
className: "MultiSelect__selected-items"
|
|
11069
11117
|
}, values.map(function (value, index) {
|
|
11070
|
-
var _options$
|
|
11118
|
+
var _options$find2;
|
|
11071
11119
|
return /*#__PURE__*/React__default.createElement("span", {
|
|
11072
11120
|
className: "MultiSelect__selected-item",
|
|
11073
11121
|
key: index
|
|
11074
11122
|
}, /*#__PURE__*/React__default.createElement("span", {
|
|
11075
11123
|
className: "MultiSelect__selected-value"
|
|
11076
|
-
}, ((_options$
|
|
11124
|
+
}, ((_options$find2 = options.find(function (option) {
|
|
11077
11125
|
return option.value === value;
|
|
11078
|
-
})) === null || _options$
|
|
11126
|
+
})) === null || _options$find2 === void 0 ? void 0 : _options$find2.label) || value), /*#__PURE__*/React__default.createElement(Exit16, {
|
|
11079
11127
|
style: {
|
|
11080
11128
|
width: '8px',
|
|
11081
11129
|
height: '8px',
|
|
@@ -11099,8 +11147,7 @@ var MultiSelect = function MultiSelect(_ref) {
|
|
|
11099
11147
|
searchable: searchable,
|
|
11100
11148
|
options: options,
|
|
11101
11149
|
onSelect: handleSelect,
|
|
11102
|
-
onFocus: handleFocus
|
|
11103
|
-
autoFocus: false
|
|
11150
|
+
onFocus: handleFocus
|
|
11104
11151
|
}));
|
|
11105
11152
|
};
|
|
11106
11153
|
|
|
@@ -11112,7 +11159,14 @@ var Field = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
|
11112
11159
|
label = _ref.label,
|
|
11113
11160
|
placeholder = _ref.placeholder,
|
|
11114
11161
|
rest = _objectWithoutProperties(_ref, _excluded$h);
|
|
11115
|
-
|
|
11162
|
+
var fieldContextValue = useMemo(function () {
|
|
11163
|
+
return {
|
|
11164
|
+
displaysError: Boolean(error)
|
|
11165
|
+
};
|
|
11166
|
+
}, [error]);
|
|
11167
|
+
return /*#__PURE__*/React__default.createElement(FormControlContext.Provider, {
|
|
11168
|
+
value: fieldContextValue
|
|
11169
|
+
}, /*#__PURE__*/React__default.createElement("label", {
|
|
11116
11170
|
className: classNames('Field', className)
|
|
11117
11171
|
}, label && /*#__PURE__*/React__default.createElement("span", {
|
|
11118
11172
|
className: "Field__label"
|
|
@@ -11135,7 +11189,7 @@ var Field = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
|
|
|
11135
11189
|
className: "Field__icon"
|
|
11136
11190
|
}, /*#__PURE__*/React__default.createElement(Warning16, null)))), error && /*#__PURE__*/React__default.createElement("span", {
|
|
11137
11191
|
className: "Field__error"
|
|
11138
|
-
}, error));
|
|
11192
|
+
}, error)));
|
|
11139
11193
|
});
|
|
11140
11194
|
Field.displayName = 'Field';
|
|
11141
11195
|
|
|
@@ -12689,4 +12743,4 @@ var Utilities = {
|
|
|
12689
12743
|
States: States
|
|
12690
12744
|
};
|
|
12691
12745
|
|
|
12692
|
-
export { ArcWindow, AspectRatioBox, Badge, Bradley, Brancusi, Breadcrumb, Breadcrumbs, Breakpoint, BreakpointContext, BreakpointProvider, Button, Checkbox, Circle, Clickable, ColorSwatch, ConfirmProvider, Constrain, ControlLink, CreditCardNumberInput, DEFAULT_PRODUCT_ASPECT_HEIGHT, DEFAULT_PRODUCT_ASPECT_RATIO, DEFAULT_PRODUCT_ASPECT_WIDTH, DefinitionList, Dialog, Diamond, Divider, ExceedConstrain, Expandable, Field, FocusOn, Field as Input, Keyhole, Label, LineAboveDivider, Loading, LoadingBalls, LoadingItems1, LoadingItems2, LoadingItems3, LoadingItems4, LoadingItems5, LoadingItemsLavenderBlue1, LoadingItemsLavenderBlue2, LoadingItemsLavenderBlue3, LoadingItemsLavenderBlue4, LoadingItemsLavenderBlue5, LoadingShapes, LoadingShapesLavenderBlue, LoadingShapesPinkGreen, Mirror, Modal, ModalOverlay, MultiSelect, NoLineDivider, Oval, Overlay, POPOVER_MOUSEOUT_DELAY_MS, Paginator, PasswordInput, Popover, PromoBanner, RadioButton, SKU_COLORS, SearchInput, Select, SelectableButton, SlidingPane, Stack, Tab, TabList, TabPanel, TabPanels, Tabs, Tag, Text, TextInput, Textarea, Toast, Triangle, TwoLineDivider, UNMOUNT_DELAY_MS, Utilities, VerticalDivider, Window, discriminate, tokens, useBreakpoint, useClickOutside, useConfirm, useKeyboardListNavigation, useUpdateEffect };
|
|
12746
|
+
export { ArcWindow, AspectRatioBox, Badge, Bradley, Brancusi, Breadcrumb, Breadcrumbs, Breakpoint, BreakpointContext, BreakpointProvider, Button, Checkbox, Circle, Clickable, ColorSwatch, ConfirmProvider, Constrain, ControlLink, CreditCardNumberInput, DEFAULT_PRODUCT_ASPECT_HEIGHT, DEFAULT_PRODUCT_ASPECT_RATIO, DEFAULT_PRODUCT_ASPECT_WIDTH, DefinitionList, Dialog, Diamond, Divider, ExceedConstrain, Expandable, Field, FocusOn, FormControlContext, Field as Input, Keyhole, Label, LineAboveDivider, Loading, LoadingBalls, LoadingItems1, LoadingItems2, LoadingItems3, LoadingItems4, LoadingItems5, LoadingItemsLavenderBlue1, LoadingItemsLavenderBlue2, LoadingItemsLavenderBlue3, LoadingItemsLavenderBlue4, LoadingItemsLavenderBlue5, LoadingShapes, LoadingShapesLavenderBlue, LoadingShapesPinkGreen, Mirror, Modal, ModalOverlay, MultiSelect, NoLineDivider, Oval, Overlay, POPOVER_MOUSEOUT_DELAY_MS, Paginator, PasswordInput, Popover, PromoBanner, RadioButton, SKU_COLORS, SearchInput, Select, SelectableButton, SlidingPane, Stack, Tab, TabList, TabPanel, TabPanels, Tabs, Tag, Text, TextInput, Textarea, Toast, Triangle, TwoLineDivider, UNMOUNT_DELAY_MS, Utilities, VerticalDivider, Window, discriminate, tokens, useBreakpoint, useClickOutside, useConfirm, useFormControlContext, useKeyboardListNavigation, useUpdateEffect };
|