@wix/editor-react-components 1.2765.0 → 1.2767.0
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/site/components/AccordionComponent/component.js +80 -3
- package/dist/site/components/AudioPlayer/manifest.js +1 -1
- package/dist/site/components/Checkbox/component.js +1 -2
- package/dist/site/components/CheckboxGroup/component.js +1 -2
- package/dist/site/components/DatePicker/component.js +2 -4
- package/dist/site/components/Dropdown/Dropdown.d.ts +1 -1
- package/dist/site/components/Dropdown/Dropdown.types.d.ts +22 -89
- package/dist/site/components/Dropdown/component.js +205 -873
- package/dist/site/components/Dropdown/constants.d.ts +26 -168
- package/dist/site/components/Dropdown/css.css +52 -462
- package/dist/site/components/Dropdown/manifest.js +338 -441
- package/dist/site/components/Line/manifest.js +39 -3
- package/dist/site/components/RadioButtons/component.js +1 -2
- package/dist/site/components/TextBox/component.js +1 -2
- package/dist/site/components/TimePicker/component.js +2 -4
- package/dist/site/components/chunks/DismissSmall.js +7727 -1
- package/dist/site/components/chunks/RequiredIndicator.js +4 -0
- package/dist/site/components/chunks/constants36.js +31 -148
- package/dist/site/components/chunks/index11.js +0 -66
- package/dist/site/components/chunks/isObjectLike.js +15 -5
- package/dist/site/components/chunks/manifestSdkMixins.js +1 -14
- package/dist/site/components/chunks/types.impl.js +26 -1
- package/package.json +3 -3
- package/dist/site/components/Dropdown/component.preview.d.ts +0 -9
- package/dist/site/components/Dropdown/components/DropdownChips.d.ts +0 -8
- package/dist/site/components/Dropdown/components/DropdownList.d.ts +0 -20
- package/dist/site/components/Dropdown/components/DropdownTrigger.d.ts +0 -22
- package/dist/site/components/Dropdown/dropdownUtils.d.ts +0 -22
- package/dist/site/components/Dropdown/hooks/useChipOverflow.d.ts +0 -9
- package/dist/site/components/Dropdown/hooks/useDropdownQuery.d.ts +0 -15
- package/dist/site/components/Dropdown/hooks/useDropdownSelection.d.ts +0 -16
- package/dist/site/components/chunks/InfoCircleSmall.js +0 -7
- package/dist/site/components/chunks/Tooltip.js +0 -7728
- package/dist/site/components/chunks/_baseSlice.js +0 -43
- package/dist/site/components/chunks/isArray.js +0 -12
- package/dist/site/components/chunks/isArrayLike.js +0 -88
|
@@ -1,914 +1,246 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import { useState, useCallback, useLayoutEffect, useEffect, useRef } from "react";
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
4
3
|
import { c as clsx } from "../chunks/clsx.js";
|
|
5
|
-
import {
|
|
4
|
+
import { F as Field, C as Combobox } from "../chunks/index11.js";
|
|
6
5
|
import { useService } from "@wix/services-manager-react";
|
|
7
6
|
import { E as EnvironmentDefinition } from "../chunks/index2.js";
|
|
8
7
|
import { T as TranslationsDefinition } from "../chunks/index4.js";
|
|
9
|
-
import { f as formatClassNames } from "../chunks/classNames.js";
|
|
10
8
|
import { a as getDataAttributes } from "../chunks/dataUtils.js";
|
|
11
|
-
import { u as useValidatedField, R as RequiredIndicator } from "../chunks/RequiredIndicator.js";
|
|
12
9
|
import { d as directionStyles } from "../chunks/direction.module.js";
|
|
13
10
|
import { p as presetWrapperStyles } from "../chunks/presetWrapper.module.js";
|
|
14
11
|
import { a as accessibilityStyles } from "../chunks/accessibility.module.js";
|
|
15
|
-
import { A as
|
|
16
|
-
import { u as useResizeObserver } from "../chunks/useResizeObserver.js";
|
|
17
|
-
import { D as DismissSmall_default } from "../chunks/DismissSmall.js";
|
|
18
|
-
import { g as getDefaultExportFromCjs } from "../chunks/_commonjsHelpers.js";
|
|
19
|
-
import { r as requireIsSymbol, a as require_baseSlice } from "../chunks/_baseSlice.js";
|
|
20
|
-
import { r as requireIsObject, a as requireEq, b as requireIsArrayLike, c as require_isIndex } from "../chunks/isArrayLike.js";
|
|
21
|
-
const ConfirmSmall = ({ size, ...props }) => /* @__PURE__ */ React.createElement("svg", { viewBox: "0 0 18 18", fill: "currentColor", width: size || "18", height: size || "18", ...props }, /* @__PURE__ */ React.createElement("path", { d: "M11.9393398,6 C12.232233,5.70710678 12.7071068,5.70710678 13,6 C13.2928932,6.29289322 13.2928932,6.76776695 13,7.06066017 L7.5,12.5606602 L5,10.0606602 C4.70710678,9.76776695 4.70710678,9.29289322 5,9 C5.29289322,8.70710678 5.76776695,8.70710678 6.06066017,9 L7.5,10.4393398 L11.9393398,6 Z" }));
|
|
22
|
-
ConfirmSmall.displayName = "ConfirmSmall";
|
|
23
|
-
var ConfirmSmall_default = ConfirmSmall;
|
|
24
|
-
var _trimmedEndIndex;
|
|
25
|
-
var hasRequired_trimmedEndIndex;
|
|
26
|
-
function require_trimmedEndIndex() {
|
|
27
|
-
if (hasRequired_trimmedEndIndex) return _trimmedEndIndex;
|
|
28
|
-
hasRequired_trimmedEndIndex = 1;
|
|
29
|
-
var reWhitespace = /\s/;
|
|
30
|
-
function trimmedEndIndex(string) {
|
|
31
|
-
var index = string.length;
|
|
32
|
-
while (index-- && reWhitespace.test(string.charAt(index))) {
|
|
33
|
-
}
|
|
34
|
-
return index;
|
|
35
|
-
}
|
|
36
|
-
_trimmedEndIndex = trimmedEndIndex;
|
|
37
|
-
return _trimmedEndIndex;
|
|
38
|
-
}
|
|
39
|
-
var _baseTrim;
|
|
40
|
-
var hasRequired_baseTrim;
|
|
41
|
-
function require_baseTrim() {
|
|
42
|
-
if (hasRequired_baseTrim) return _baseTrim;
|
|
43
|
-
hasRequired_baseTrim = 1;
|
|
44
|
-
var trimmedEndIndex = require_trimmedEndIndex();
|
|
45
|
-
var reTrimStart = /^\s+/;
|
|
46
|
-
function baseTrim(string) {
|
|
47
|
-
return string ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, "") : string;
|
|
48
|
-
}
|
|
49
|
-
_baseTrim = baseTrim;
|
|
50
|
-
return _baseTrim;
|
|
51
|
-
}
|
|
52
|
-
var toNumber_1;
|
|
53
|
-
var hasRequiredToNumber;
|
|
54
|
-
function requireToNumber() {
|
|
55
|
-
if (hasRequiredToNumber) return toNumber_1;
|
|
56
|
-
hasRequiredToNumber = 1;
|
|
57
|
-
var baseTrim = require_baseTrim(), isObject = requireIsObject(), isSymbol = requireIsSymbol();
|
|
58
|
-
var NAN = 0 / 0;
|
|
59
|
-
var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
|
|
60
|
-
var reIsBinary = /^0b[01]+$/i;
|
|
61
|
-
var reIsOctal = /^0o[0-7]+$/i;
|
|
62
|
-
var freeParseInt = parseInt;
|
|
63
|
-
function toNumber(value2) {
|
|
64
|
-
if (typeof value2 == "number") {
|
|
65
|
-
return value2;
|
|
66
|
-
}
|
|
67
|
-
if (isSymbol(value2)) {
|
|
68
|
-
return NAN;
|
|
69
|
-
}
|
|
70
|
-
if (isObject(value2)) {
|
|
71
|
-
var other = typeof value2.valueOf == "function" ? value2.valueOf() : value2;
|
|
72
|
-
value2 = isObject(other) ? other + "" : other;
|
|
73
|
-
}
|
|
74
|
-
if (typeof value2 != "string") {
|
|
75
|
-
return value2 === 0 ? value2 : +value2;
|
|
76
|
-
}
|
|
77
|
-
value2 = baseTrim(value2);
|
|
78
|
-
var isBinary = reIsBinary.test(value2);
|
|
79
|
-
return isBinary || reIsOctal.test(value2) ? freeParseInt(value2.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value2) ? NAN : +value2;
|
|
80
|
-
}
|
|
81
|
-
toNumber_1 = toNumber;
|
|
82
|
-
return toNumber_1;
|
|
83
|
-
}
|
|
84
|
-
var toFinite_1;
|
|
85
|
-
var hasRequiredToFinite;
|
|
86
|
-
function requireToFinite() {
|
|
87
|
-
if (hasRequiredToFinite) return toFinite_1;
|
|
88
|
-
hasRequiredToFinite = 1;
|
|
89
|
-
var toNumber = requireToNumber();
|
|
90
|
-
var INFINITY = 1 / 0, MAX_INTEGER = 17976931348623157e292;
|
|
91
|
-
function toFinite(value2) {
|
|
92
|
-
if (!value2) {
|
|
93
|
-
return value2 === 0 ? value2 : 0;
|
|
94
|
-
}
|
|
95
|
-
value2 = toNumber(value2);
|
|
96
|
-
if (value2 === INFINITY || value2 === -INFINITY) {
|
|
97
|
-
var sign = value2 < 0 ? -1 : 1;
|
|
98
|
-
return sign * MAX_INTEGER;
|
|
99
|
-
}
|
|
100
|
-
return value2 === value2 ? value2 : 0;
|
|
101
|
-
}
|
|
102
|
-
toFinite_1 = toFinite;
|
|
103
|
-
return toFinite_1;
|
|
104
|
-
}
|
|
105
|
-
var toInteger_1;
|
|
106
|
-
var hasRequiredToInteger;
|
|
107
|
-
function requireToInteger() {
|
|
108
|
-
if (hasRequiredToInteger) return toInteger_1;
|
|
109
|
-
hasRequiredToInteger = 1;
|
|
110
|
-
var toFinite = requireToFinite();
|
|
111
|
-
function toInteger(value2) {
|
|
112
|
-
var result = toFinite(value2), remainder = result % 1;
|
|
113
|
-
return result === result ? remainder ? result - remainder : result : 0;
|
|
114
|
-
}
|
|
115
|
-
toInteger_1 = toInteger;
|
|
116
|
-
return toInteger_1;
|
|
117
|
-
}
|
|
118
|
-
var _isIterateeCall;
|
|
119
|
-
var hasRequired_isIterateeCall;
|
|
120
|
-
function require_isIterateeCall() {
|
|
121
|
-
if (hasRequired_isIterateeCall) return _isIterateeCall;
|
|
122
|
-
hasRequired_isIterateeCall = 1;
|
|
123
|
-
var eq = requireEq(), isArrayLike = requireIsArrayLike(), isIndex = require_isIndex(), isObject = requireIsObject();
|
|
124
|
-
function isIterateeCall(value2, index, object) {
|
|
125
|
-
if (!isObject(object)) {
|
|
126
|
-
return false;
|
|
127
|
-
}
|
|
128
|
-
var type = typeof index;
|
|
129
|
-
if (type == "number" ? isArrayLike(object) && isIndex(index, object.length) : type == "string" && index in object) {
|
|
130
|
-
return eq(object[index], value2);
|
|
131
|
-
}
|
|
132
|
-
return false;
|
|
133
|
-
}
|
|
134
|
-
_isIterateeCall = isIterateeCall;
|
|
135
|
-
return _isIterateeCall;
|
|
136
|
-
}
|
|
137
|
-
var chunk_1;
|
|
138
|
-
var hasRequiredChunk;
|
|
139
|
-
function requireChunk() {
|
|
140
|
-
if (hasRequiredChunk) return chunk_1;
|
|
141
|
-
hasRequiredChunk = 1;
|
|
142
|
-
var baseSlice = require_baseSlice(), isIterateeCall = require_isIterateeCall(), toInteger = requireToInteger();
|
|
143
|
-
var nativeCeil = Math.ceil, nativeMax = Math.max;
|
|
144
|
-
function chunk2(array, size, guard) {
|
|
145
|
-
if (guard ? isIterateeCall(array, size, guard) : size === void 0) {
|
|
146
|
-
size = 1;
|
|
147
|
-
} else {
|
|
148
|
-
size = nativeMax(toInteger(size), 0);
|
|
149
|
-
}
|
|
150
|
-
var length = array == null ? 0 : array.length;
|
|
151
|
-
if (!length || size < 1) {
|
|
152
|
-
return [];
|
|
153
|
-
}
|
|
154
|
-
var index = 0, resIndex = 0, result = Array(nativeCeil(length / size));
|
|
155
|
-
while (index < length) {
|
|
156
|
-
result[resIndex++] = baseSlice(array, index, index += size);
|
|
157
|
-
}
|
|
158
|
-
return result;
|
|
159
|
-
}
|
|
160
|
-
chunk_1 = chunk2;
|
|
161
|
-
return chunk_1;
|
|
162
|
-
}
|
|
163
|
-
var chunkExports = requireChunk();
|
|
164
|
-
const chunk = /* @__PURE__ */ getDefaultExportFromCjs(chunkExports);
|
|
12
|
+
import { A as AriaLabels, T as TestIds, e as editorElementClassNames, D as DesignStates } from "../chunks/constants36.js";
|
|
165
13
|
const root = "root__WnTks";
|
|
166
|
-
const
|
|
14
|
+
const input = "input__pbp9w";
|
|
167
15
|
const option = "option__QJeiF";
|
|
168
|
-
const
|
|
16
|
+
const optionLabel = "optionLabel__pBY1S";
|
|
169
17
|
const select = "select__Lo-N7";
|
|
170
18
|
const errorMessage = "errorMessage__iMuAa";
|
|
171
19
|
const label = "label__Q7fZH";
|
|
172
|
-
const
|
|
173
|
-
const clear = "clear__isa6G";
|
|
174
|
-
const chips = "chips__LvQLW";
|
|
175
|
-
const chipsOverflow = "chipsOverflow__mUTan";
|
|
176
|
-
const chip = "chip__Fr--t";
|
|
177
|
-
const chipLabel = "chipLabel__gL-DJ";
|
|
178
|
-
const chipShrink = "chipShrink__kDlpE";
|
|
179
|
-
const chipRemove = "chipRemove__sBxpf";
|
|
180
|
-
const itemIndicator = "itemIndicator__-IS1X";
|
|
181
|
-
const empty = "empty__dKQbw";
|
|
20
|
+
const helperText = "helperText__M9s0b";
|
|
182
21
|
const positioner = "positioner__YS--m";
|
|
183
22
|
const popup = "popup__GQi1e";
|
|
184
23
|
const list = "list__DruZL";
|
|
185
|
-
const gridRow = "gridRow__9DEae";
|
|
186
|
-
const inlineList = "inlineList__eJvV9";
|
|
187
24
|
const value = "value__pqgtJ";
|
|
25
|
+
const placeholder = "placeholder__qfcAb";
|
|
188
26
|
const arrow = "arrow__Q2E2Y";
|
|
189
|
-
const applyButton = "applyButton__GsIJM";
|
|
190
27
|
const styles = {
|
|
191
28
|
root,
|
|
192
|
-
|
|
29
|
+
input,
|
|
193
30
|
option,
|
|
194
|
-
|
|
31
|
+
optionLabel,
|
|
195
32
|
select,
|
|
196
33
|
errorMessage,
|
|
197
34
|
label,
|
|
198
|
-
|
|
199
|
-
clear,
|
|
200
|
-
chips,
|
|
201
|
-
chipsOverflow,
|
|
202
|
-
chip,
|
|
203
|
-
chipLabel,
|
|
204
|
-
chipShrink,
|
|
205
|
-
chipRemove,
|
|
206
|
-
itemIndicator,
|
|
207
|
-
empty,
|
|
35
|
+
helperText,
|
|
208
36
|
positioner,
|
|
209
37
|
popup,
|
|
210
38
|
list,
|
|
211
|
-
gridRow,
|
|
212
|
-
inlineList,
|
|
213
39
|
value,
|
|
214
|
-
arrow,
|
|
215
|
-
applyButton
|
|
216
|
-
};
|
|
217
|
-
const readOptionValue = (item) => {
|
|
218
|
-
if (typeof item === "string") {
|
|
219
|
-
return item;
|
|
220
|
-
}
|
|
221
|
-
if (item && typeof item === "object" && typeof item.value === "string") {
|
|
222
|
-
return item.value;
|
|
223
|
-
}
|
|
224
|
-
return null;
|
|
225
|
-
};
|
|
226
|
-
const toOptionItems = (options) => options.filter((option2) => ((option2 == null ? void 0 : option2.label) ?? "").trim() !== "").map((option2, index) => {
|
|
227
|
-
const label2 = (option2 == null ? void 0 : option2.label) ?? "";
|
|
228
|
-
const value2 = (option2 == null ? void 0 : option2.value) ?? "";
|
|
229
|
-
return { key: `option-${index}`, value: value2 || label2, label: label2 };
|
|
230
|
-
});
|
|
231
|
-
const readSelectedValues = (rawValue, isMultiple) => {
|
|
232
|
-
let list2;
|
|
233
|
-
if (!isMultiple) {
|
|
234
|
-
list2 = [rawValue];
|
|
235
|
-
} else {
|
|
236
|
-
list2 = Array.isArray(rawValue) ? rawValue : [];
|
|
237
|
-
}
|
|
238
|
-
return list2.map(readOptionValue).filter((value2) => value2 !== null && value2 !== ALL_VALUE);
|
|
239
|
-
};
|
|
240
|
-
const createFilterItem = (params) => (item, typed) => {
|
|
241
|
-
const { customFilter, isSearchable, isMultiple, inline } = params;
|
|
242
|
-
const q = typed.trim();
|
|
243
|
-
if (q.length === 0) {
|
|
244
|
-
return !(isSearchable && !isMultiple && !inline);
|
|
245
|
-
}
|
|
246
|
-
return customFilter ? customFilter({ value: item.value, label: item.label }, q) : item.label.toLowerCase().includes(q.toLowerCase());
|
|
247
|
-
};
|
|
248
|
-
const emitChange = (onChange, value2) => {
|
|
249
|
-
onChange(value2);
|
|
250
|
-
};
|
|
251
|
-
const emitInput = (onInput, value2) => {
|
|
252
|
-
onInput(value2);
|
|
253
|
-
};
|
|
254
|
-
const useDropdownSelection = (params) => {
|
|
255
|
-
const { optionItems, selectedValues, isMultiple, isApplyMode, onChange } = params;
|
|
256
|
-
const itemForKey = (key) => optionItems.find((item) => item.key === key);
|
|
257
|
-
const valueForKey = (key) => {
|
|
258
|
-
var _a;
|
|
259
|
-
return ((_a = itemForKey(key)) == null ? void 0 : _a.value) ?? ALL_VALUE;
|
|
260
|
-
};
|
|
261
|
-
const labelForKey = (key) => {
|
|
262
|
-
var _a;
|
|
263
|
-
return ((_a = itemForKey(key)) == null ? void 0 : _a.label) ?? "";
|
|
264
|
-
};
|
|
265
|
-
const keysForValues = (values) => values.map((value2) => {
|
|
266
|
-
var _a;
|
|
267
|
-
return (_a = optionItems.find((item) => item.value === value2)) == null ? void 0 : _a.key;
|
|
268
|
-
}).filter((key) => Boolean(key));
|
|
269
|
-
const [selectedKeys, setSelectedKeys] = useState(
|
|
270
|
-
keysForValues(selectedValues)
|
|
271
|
-
);
|
|
272
|
-
const valuesSignature = JSON.stringify(selectedValues);
|
|
273
|
-
const optionsSignature = JSON.stringify(optionItems.map((item) => item.value));
|
|
274
|
-
const syncSignature = `${valuesSignature}::${optionsSignature}`;
|
|
275
|
-
const [prevSyncSignature, setPrevSyncSignature] = useState(syncSignature);
|
|
276
|
-
if (prevSyncSignature !== syncSignature) {
|
|
277
|
-
setPrevSyncSignature(syncSignature);
|
|
278
|
-
setSelectedKeys(keysForValues(selectedValues));
|
|
279
|
-
}
|
|
280
|
-
const selectedItems = selectedKeys.map((key) => itemForKey(key)).filter((item) => Boolean(item));
|
|
281
|
-
const selectedKey = selectedKeys[0] ?? null;
|
|
282
|
-
const selectedOptionLabel = selectedKey ? labelForKey(selectedKey) : "";
|
|
283
|
-
const commitValue = (keys) => {
|
|
284
|
-
const values = keys.map((key) => valueForKey(key)).filter((value2) => value2 !== ALL_VALUE);
|
|
285
|
-
const next = isMultiple ? values : values[0] ?? ALL_VALUE;
|
|
286
|
-
emitChange(onChange, next);
|
|
287
|
-
};
|
|
288
|
-
const handleSelectionChange = (keys) => {
|
|
289
|
-
setSelectedKeys(keys);
|
|
290
|
-
if (!isApplyMode) {
|
|
291
|
-
commitValue(keys);
|
|
292
|
-
}
|
|
293
|
-
};
|
|
294
|
-
const handleApply = () => commitValue(selectedKeys);
|
|
295
|
-
return {
|
|
296
|
-
selectedKeys,
|
|
297
|
-
selectedItems,
|
|
298
|
-
selectedKey,
|
|
299
|
-
selectedOptionLabel,
|
|
300
|
-
handleSelectionChange,
|
|
301
|
-
handleApply
|
|
302
|
-
};
|
|
303
|
-
};
|
|
304
|
-
const useDropdownQuery = (params) => {
|
|
305
|
-
const {
|
|
306
|
-
boundInputValue,
|
|
307
|
-
boundOpen,
|
|
308
|
-
isMultiple,
|
|
309
|
-
selectedKey,
|
|
310
|
-
selectedOptionLabel,
|
|
311
|
-
onInput
|
|
312
|
-
} = params;
|
|
313
|
-
const [inputValue, setInputValue] = useState(
|
|
314
|
-
boundInputValue ?? (isMultiple ? "" : selectedOptionLabel)
|
|
315
|
-
);
|
|
316
|
-
const [prevBoundInputValue, setPrevBoundInputValue] = useState(boundInputValue);
|
|
317
|
-
if (boundInputValue !== prevBoundInputValue) {
|
|
318
|
-
setPrevBoundInputValue(boundInputValue);
|
|
319
|
-
if (boundInputValue !== void 0 && boundInputValue !== inputValue) {
|
|
320
|
-
setInputValue(boundInputValue);
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
const [prevSelectedKey, setPrevSelectedKey] = useState(selectedKey);
|
|
324
|
-
if (!isMultiple && prevSelectedKey !== selectedKey) {
|
|
325
|
-
setPrevSelectedKey(selectedKey);
|
|
326
|
-
if (boundInputValue === void 0) {
|
|
327
|
-
setInputValue(selectedOptionLabel);
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
const handleInputValueChange = (next) => {
|
|
331
|
-
setInputValue(next);
|
|
332
|
-
emitInput(onInput, next);
|
|
333
|
-
};
|
|
334
|
-
const [isOpen, setIsOpen] = useState(boundOpen ?? false);
|
|
335
|
-
const [prevBoundOpen, setPrevBoundOpen] = useState(boundOpen);
|
|
336
|
-
if (boundOpen !== prevBoundOpen) {
|
|
337
|
-
setPrevBoundOpen(boundOpen);
|
|
338
|
-
if (typeof boundOpen === "boolean" && boundOpen !== isOpen) {
|
|
339
|
-
setIsOpen(boundOpen);
|
|
340
|
-
}
|
|
341
|
-
}
|
|
342
|
-
return {
|
|
343
|
-
inputValue,
|
|
344
|
-
handleInputValueChange,
|
|
345
|
-
hasQuery: inputValue.trim().length > 0,
|
|
346
|
-
isOpen,
|
|
347
|
-
setIsOpen
|
|
348
|
-
};
|
|
349
|
-
};
|
|
350
|
-
const useIsomorphicLayoutEffect = typeof window !== "undefined" ? useLayoutEffect : useEffect;
|
|
351
|
-
const COUNTER_RESERVE = 52;
|
|
352
|
-
const MIN_PARTIAL = 48;
|
|
353
|
-
const GAP = 4;
|
|
354
|
-
const useChipOverflow = (ref, count) => {
|
|
355
|
-
const [visible, setVisible] = useState(count);
|
|
356
|
-
useIsomorphicLayoutEffect(() => {
|
|
357
|
-
setVisible(count);
|
|
358
|
-
}, [count]);
|
|
359
|
-
useIsomorphicLayoutEffect(() => {
|
|
360
|
-
const el = ref.current;
|
|
361
|
-
if (!el || visible !== count) {
|
|
362
|
-
return;
|
|
363
|
-
}
|
|
364
|
-
const available = el.clientWidth;
|
|
365
|
-
if (available === 0) {
|
|
366
|
-
return;
|
|
367
|
-
}
|
|
368
|
-
const chips2 = Array.from(el.querySelectorAll("[data-chip]"));
|
|
369
|
-
let used = 0;
|
|
370
|
-
let fit = 0;
|
|
371
|
-
for (let index = 0; index < chips2.length; index += 1) {
|
|
372
|
-
const width = chips2[index].offsetWidth + (index > 0 ? GAP : 0);
|
|
373
|
-
const reserve = index < count - 1 ? COUNTER_RESERVE : 0;
|
|
374
|
-
if (used + width + reserve > available) {
|
|
375
|
-
break;
|
|
376
|
-
}
|
|
377
|
-
used += width;
|
|
378
|
-
fit += 1;
|
|
379
|
-
}
|
|
380
|
-
let show = fit;
|
|
381
|
-
if (fit < count) {
|
|
382
|
-
const reserve = fit + 1 < count ? COUNTER_RESERVE : 0;
|
|
383
|
-
if (available - used - GAP - reserve >= MIN_PARTIAL) {
|
|
384
|
-
show = fit + 1;
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
const next = count > 0 ? Math.max(1, show) : show;
|
|
388
|
-
if (next !== count) {
|
|
389
|
-
setVisible(next);
|
|
390
|
-
}
|
|
391
|
-
}, [ref, visible, count]);
|
|
392
|
-
const handleResize = useCallback(() => setVisible(count), [count]);
|
|
393
|
-
useResizeObserver({ ref, callback: handleResize });
|
|
394
|
-
return visible;
|
|
395
|
-
};
|
|
396
|
-
const DropdownChips = ({
|
|
397
|
-
items,
|
|
398
|
-
inputControl,
|
|
399
|
-
removeItemLabel,
|
|
400
|
-
chipClassName
|
|
401
|
-
}) => {
|
|
402
|
-
const chipsRef = useRef(null);
|
|
403
|
-
const visible = useChipOverflow(chipsRef, items.length);
|
|
404
|
-
const hidden = items.length - visible;
|
|
405
|
-
return /* @__PURE__ */ jsxs(
|
|
406
|
-
Combobox.Chips,
|
|
407
|
-
{
|
|
408
|
-
ref: chipsRef,
|
|
409
|
-
className: clsx(
|
|
410
|
-
styles.chips,
|
|
411
|
-
formatClassNames(semanticClassNames.chips)
|
|
412
|
-
),
|
|
413
|
-
children: [
|
|
414
|
-
items.slice(0, visible).map((item, index) => /* @__PURE__ */ jsxs(
|
|
415
|
-
Combobox.Chip,
|
|
416
|
-
{
|
|
417
|
-
"data-chip": "",
|
|
418
|
-
className: clsx(
|
|
419
|
-
styles.chip,
|
|
420
|
-
selectors.chip,
|
|
421
|
-
formatClassNames(semanticClassNames.chip),
|
|
422
|
-
index === visible - 1 && styles.chipShrink,
|
|
423
|
-
chipClassName
|
|
424
|
-
),
|
|
425
|
-
children: [
|
|
426
|
-
/* @__PURE__ */ jsx("span", { className: styles.chipLabel, children: item.label }),
|
|
427
|
-
/* @__PURE__ */ jsx(
|
|
428
|
-
Combobox.ChipRemove,
|
|
429
|
-
{
|
|
430
|
-
className: styles.chipRemove,
|
|
431
|
-
"aria-label": removeItemLabel,
|
|
432
|
-
children: /* @__PURE__ */ jsx(DismissSmall_default, { "aria-hidden": "true" })
|
|
433
|
-
}
|
|
434
|
-
)
|
|
435
|
-
]
|
|
436
|
-
},
|
|
437
|
-
item.key
|
|
438
|
-
)),
|
|
439
|
-
hidden > 0 && /* @__PURE__ */ jsxs("span", { className: styles.chipsOverflow, children: [
|
|
440
|
-
"+",
|
|
441
|
-
hidden
|
|
442
|
-
] }),
|
|
443
|
-
inputControl
|
|
444
|
-
]
|
|
445
|
-
}
|
|
446
|
-
);
|
|
447
|
-
};
|
|
448
|
-
const DropdownTrigger = ({
|
|
449
|
-
isMultiple,
|
|
450
|
-
isSearchable,
|
|
451
|
-
clearable,
|
|
452
|
-
selectedLabel,
|
|
453
|
-
selectedItems,
|
|
454
40
|
placeholder,
|
|
455
|
-
|
|
456
|
-
labelId,
|
|
457
|
-
clearLabel,
|
|
458
|
-
removeItemLabel,
|
|
459
|
-
describedById,
|
|
460
|
-
isInvalid,
|
|
461
|
-
onFocus,
|
|
462
|
-
onBlur,
|
|
463
|
-
elementProps
|
|
464
|
-
}) => {
|
|
465
|
-
var _a, _b, _c, _d;
|
|
466
|
-
const triggerClassName = clsx(
|
|
467
|
-
styles.trigger,
|
|
468
|
-
selectors.trigger,
|
|
469
|
-
formatClassNames(semanticClassNames.trigger),
|
|
470
|
-
(_a = elementProps == null ? void 0 : elementProps.trigger) == null ? void 0 : _a.className
|
|
471
|
-
);
|
|
472
|
-
const inputGroupClassName = clsx(
|
|
473
|
-
styles.trigger,
|
|
474
|
-
selectors.input,
|
|
475
|
-
formatClassNames(semanticClassNames.input),
|
|
476
|
-
(_b = elementProps == null ? void 0 : elementProps.input) == null ? void 0 : _b.className
|
|
477
|
-
);
|
|
478
|
-
const clearControl = clearable ? /* @__PURE__ */ jsx(
|
|
479
|
-
Combobox.Clear,
|
|
480
|
-
{
|
|
481
|
-
className: clsx(
|
|
482
|
-
styles.clear,
|
|
483
|
-
selectors.clear,
|
|
484
|
-
formatClassNames(semanticClassNames.clear),
|
|
485
|
-
(_c = elementProps == null ? void 0 : elementProps.clearButton) == null ? void 0 : _c.className
|
|
486
|
-
),
|
|
487
|
-
"aria-label": clearLabel,
|
|
488
|
-
"data-testid": TestIds.clear,
|
|
489
|
-
children: /* @__PURE__ */ jsx(DismissSmall_default, { "aria-hidden": "true" })
|
|
490
|
-
}
|
|
491
|
-
) : null;
|
|
492
|
-
const inputControl = /* @__PURE__ */ jsx(
|
|
493
|
-
Combobox.Input,
|
|
494
|
-
{
|
|
495
|
-
className: styles.value,
|
|
496
|
-
"data-testid": TestIds.trigger,
|
|
497
|
-
readOnly: !isSearchable,
|
|
498
|
-
placeholder: isMultiple && selectedItems.length > 0 ? "" : placeholder,
|
|
499
|
-
"aria-label": ariaLabel,
|
|
500
|
-
"aria-labelledby": labelId,
|
|
501
|
-
"aria-describedby": describedById,
|
|
502
|
-
"aria-invalid": isInvalid || void 0,
|
|
503
|
-
onFocus,
|
|
504
|
-
onBlur
|
|
505
|
-
}
|
|
506
|
-
);
|
|
507
|
-
if (isMultiple) {
|
|
508
|
-
return /* @__PURE__ */ jsxs(Combobox.InputGroup, { className: inputGroupClassName, children: [
|
|
509
|
-
/* @__PURE__ */ jsx(
|
|
510
|
-
DropdownChips,
|
|
511
|
-
{
|
|
512
|
-
items: selectedItems,
|
|
513
|
-
inputControl,
|
|
514
|
-
removeItemLabel,
|
|
515
|
-
chipClassName: (_d = elementProps == null ? void 0 : elementProps.chip) == null ? void 0 : _d.className
|
|
516
|
-
}
|
|
517
|
-
),
|
|
518
|
-
clearControl
|
|
519
|
-
] });
|
|
520
|
-
}
|
|
521
|
-
if (isSearchable) {
|
|
522
|
-
return /* @__PURE__ */ jsxs(Combobox.InputGroup, { className: inputGroupClassName, children: [
|
|
523
|
-
inputControl,
|
|
524
|
-
clearControl
|
|
525
|
-
] });
|
|
526
|
-
}
|
|
527
|
-
return /* @__PURE__ */ jsxs(
|
|
528
|
-
Combobox.Trigger,
|
|
529
|
-
{
|
|
530
|
-
className: triggerClassName,
|
|
531
|
-
"data-testid": TestIds.trigger,
|
|
532
|
-
"aria-label": ariaLabel,
|
|
533
|
-
"aria-labelledby": labelId,
|
|
534
|
-
"aria-describedby": describedById,
|
|
535
|
-
"aria-invalid": isInvalid || void 0,
|
|
536
|
-
onFocus,
|
|
537
|
-
onBlur,
|
|
538
|
-
children: [
|
|
539
|
-
/* @__PURE__ */ jsx(Combobox.Value, { children: () => /* @__PURE__ */ jsx("span", { className: styles.value, children: selectedLabel }) }),
|
|
540
|
-
/* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: styles.arrow })
|
|
541
|
-
]
|
|
542
|
-
}
|
|
543
|
-
);
|
|
544
|
-
};
|
|
545
|
-
const DropdownList = ({
|
|
546
|
-
optionItems,
|
|
547
|
-
filterItem,
|
|
548
|
-
inputValue,
|
|
549
|
-
limit,
|
|
550
|
-
isGrid,
|
|
551
|
-
isSearchable,
|
|
552
|
-
columns,
|
|
553
|
-
inline,
|
|
554
|
-
isMultiple,
|
|
555
|
-
hasInput,
|
|
556
|
-
hasQuery,
|
|
557
|
-
popoverContainer,
|
|
558
|
-
elementProps
|
|
559
|
-
}) => {
|
|
560
|
-
var _a, _b;
|
|
561
|
-
const listClassName = clsx(
|
|
562
|
-
selectors.list,
|
|
563
|
-
formatClassNames(semanticClassNames.listbox),
|
|
564
|
-
(_a = elementProps == null ? void 0 : elementProps.list) == null ? void 0 : _a.className
|
|
565
|
-
);
|
|
566
|
-
const optionClassName = clsx(
|
|
567
|
-
styles.option,
|
|
568
|
-
selectors.option,
|
|
569
|
-
formatClassNames(semanticClassNames.option),
|
|
570
|
-
(_b = elementProps == null ? void 0 : elementProps.option) == null ? void 0 : _b.className
|
|
571
|
-
);
|
|
572
|
-
const renderItem = (item) => /* @__PURE__ */ jsxs(Combobox.Item, { value: item, className: optionClassName, children: [
|
|
573
|
-
item.label,
|
|
574
|
-
isMultiple && /* @__PURE__ */ jsx(Combobox.ItemIndicator, { className: styles.itemIndicator, children: /* @__PURE__ */ jsx(ConfirmSmall_default, { "aria-hidden": "true" }) })
|
|
575
|
-
] }, item.key);
|
|
576
|
-
const gridItems = optionItems.filter(
|
|
577
|
-
(item) => filterItem(item, isSearchable ? inputValue : "")
|
|
578
|
-
);
|
|
579
|
-
const gridVisible = limit > 0 ? gridItems.slice(0, limit) : gridItems;
|
|
580
|
-
const gridStyle = { "--columns": columns };
|
|
581
|
-
const listChildren = isGrid ? chunk(gridVisible, columns).map((row, rowIndex) => /* @__PURE__ */ jsx(Combobox.Row, { className: styles.gridRow, children: row.map(renderItem) }, `row-${rowIndex}`)) : renderItem;
|
|
582
|
-
let emptyState = null;
|
|
583
|
-
if (isGrid) {
|
|
584
|
-
emptyState = hasQuery && gridVisible.length === 0 ? /* @__PURE__ */ jsx("div", { className: styles.empty, children: defaultValues.noResultsText }) : null;
|
|
585
|
-
} else if (hasInput) {
|
|
586
|
-
emptyState = /* @__PURE__ */ jsx(Combobox.Empty, { className: styles.empty, children: hasQuery ? defaultValues.noResultsText : null });
|
|
587
|
-
}
|
|
588
|
-
if (inline) {
|
|
589
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
590
|
-
/* @__PURE__ */ jsx(
|
|
591
|
-
Combobox.List,
|
|
592
|
-
{
|
|
593
|
-
className: clsx(styles.inlineList, listClassName),
|
|
594
|
-
"data-testid": TestIds.listbox,
|
|
595
|
-
style: isGrid ? gridStyle : void 0,
|
|
596
|
-
children: listChildren
|
|
597
|
-
}
|
|
598
|
-
),
|
|
599
|
-
emptyState
|
|
600
|
-
] });
|
|
601
|
-
}
|
|
602
|
-
return /* @__PURE__ */ jsx(Combobox.Portal, { container: popoverContainer ?? void 0, children: /* @__PURE__ */ jsx(Combobox.Positioner, { className: styles.positioner, sideOffset: 4, children: /* @__PURE__ */ jsxs(
|
|
603
|
-
Combobox.Popup,
|
|
604
|
-
{
|
|
605
|
-
className: clsx(styles.popup, listClassName),
|
|
606
|
-
"data-testid": TestIds.listbox,
|
|
607
|
-
children: [
|
|
608
|
-
/* @__PURE__ */ jsx(
|
|
609
|
-
Combobox.List,
|
|
610
|
-
{
|
|
611
|
-
className: styles.list,
|
|
612
|
-
style: isGrid ? gridStyle : void 0,
|
|
613
|
-
children: listChildren
|
|
614
|
-
}
|
|
615
|
-
),
|
|
616
|
-
emptyState
|
|
617
|
-
]
|
|
618
|
-
}
|
|
619
|
-
) }) });
|
|
41
|
+
arrow
|
|
620
42
|
};
|
|
621
|
-
const
|
|
622
|
-
|
|
623
|
-
function Dropdown(
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
onInput = noop,
|
|
646
|
-
onFocus = noop,
|
|
647
|
-
onBlur = noop,
|
|
648
|
-
wix,
|
|
649
|
-
elementProps
|
|
650
|
-
} = props;
|
|
651
|
-
const label2 = props.label ?? defaultValues.label;
|
|
652
|
-
const placeholder = props.placeholder ?? defaultValues.placeholder;
|
|
653
|
-
const description2 = props.description ?? defaultValues.description;
|
|
654
|
-
const isMultiple = props.multiple === true;
|
|
655
|
-
const required = props.required === true;
|
|
656
|
-
const isDisabled = props.isDisabled === true;
|
|
657
|
-
const limit = typeof props.limit === "number" ? props.limit : defaultValues.limit;
|
|
658
|
-
const customFilter = typeof props.filter === "function" ? props.filter : void 0;
|
|
659
|
-
const options = Array.isArray(props.options) ? props.options : [];
|
|
660
|
-
const presetsWrapperProps = (wix == null ? void 0 : wix.presetsWrapperProps) || {};
|
|
661
|
-
const isSearchable = searchable === true;
|
|
662
|
-
const isGrid = props.grid === true;
|
|
663
|
-
const columns = Math.max(
|
|
664
|
-
1,
|
|
665
|
-
typeof props.columns === "number" ? Math.floor(props.columns) : defaultValues.columns
|
|
666
|
-
);
|
|
667
|
-
const isApplyMode = triggerMode === TriggerModeValues.OnApply;
|
|
43
|
+
const itemToStringLabel = (item) => (item == null ? void 0 : item.label) ?? "";
|
|
44
|
+
const itemToStringValue = (item) => (item == null ? void 0 : item.value) ?? "";
|
|
45
|
+
function Dropdown({
|
|
46
|
+
a11y,
|
|
47
|
+
className,
|
|
48
|
+
direction,
|
|
49
|
+
disabled,
|
|
50
|
+
elementProps,
|
|
51
|
+
errorMessage: errorMessage2,
|
|
52
|
+
helperText: helperText2,
|
|
53
|
+
id,
|
|
54
|
+
label: label2,
|
|
55
|
+
onValueChange,
|
|
56
|
+
options,
|
|
57
|
+
placeholder: placeholder2,
|
|
58
|
+
previewError,
|
|
59
|
+
previewList,
|
|
60
|
+
readOnly,
|
|
61
|
+
value: value2,
|
|
62
|
+
wix,
|
|
63
|
+
...rest
|
|
64
|
+
}) {
|
|
65
|
+
var _a, _b, _c, _d, _e;
|
|
66
|
+
const [open, setOpen] = useState(false);
|
|
668
67
|
const [popoverContainer, setPopoverContainer] = useState(null);
|
|
669
|
-
const
|
|
670
|
-
const
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
const selectedValues = readSelectedValues(sourceValue, isMultiple);
|
|
676
|
-
const {
|
|
677
|
-
selectedItems,
|
|
678
|
-
selectedKey,
|
|
679
|
-
selectedOptionLabel,
|
|
680
|
-
handleSelectionChange,
|
|
681
|
-
handleApply
|
|
682
|
-
} = useDropdownSelection({
|
|
683
|
-
optionItems,
|
|
684
|
-
selectedValues,
|
|
685
|
-
isMultiple,
|
|
686
|
-
isApplyMode,
|
|
687
|
-
onChange
|
|
688
|
-
});
|
|
689
|
-
const selectedLabel = selectedOptionLabel || placeholder;
|
|
690
|
-
const { inputValue, handleInputValueChange, hasQuery, isOpen, setIsOpen } = useDropdownQuery({
|
|
691
|
-
boundInputValue: typeof props.inputValue === "string" ? props.inputValue : void 0,
|
|
692
|
-
boundOpen: typeof props.open === "boolean" ? props.open : void 0,
|
|
693
|
-
isMultiple,
|
|
694
|
-
selectedKey,
|
|
695
|
-
selectedOptionLabel,
|
|
696
|
-
onInput
|
|
697
|
-
});
|
|
698
|
-
const filterItem = createFilterItem({
|
|
699
|
-
customFilter,
|
|
700
|
-
isSearchable,
|
|
701
|
-
isMultiple,
|
|
702
|
-
inline
|
|
703
|
-
});
|
|
704
|
-
const t = translate(ARIA_LABEL_NAMESPACE);
|
|
705
|
-
const ariaLabel = (a11y == null ? void 0 : a11y.ariaLabel) || (label2 ? void 0 : t(AriaLabels.root.key) || AriaLabels.root.default);
|
|
706
|
-
const clearLabel = t(AriaLabels.clear.key) || AriaLabels.clear.default;
|
|
707
|
-
const removeItemLabel = t(AriaLabels.removeItem.key) || AriaLabels.removeItem.default;
|
|
708
|
-
const selectedItemValues = selectedItems.map((item) => item.value).filter((value2) => value2 !== "");
|
|
709
|
-
const currentValue = isMultiple ? selectedItemValues : selectedItemValues[0] ?? "";
|
|
710
|
-
const intrinsic = required && selectedItemValues.length === 0 ? { valid: false, validationMessage: VALUE_MISSING_MESSAGE } : { valid: true, validationMessage: "" };
|
|
711
|
-
const {
|
|
712
|
-
validity,
|
|
713
|
-
showValidityIndication: showIndication,
|
|
714
|
-
handleBlur: validateOnBlur
|
|
715
|
-
} = useValidatedField({
|
|
716
|
-
value: currentValue,
|
|
717
|
-
valueKey: JSON.stringify(selectedItemValues),
|
|
718
|
-
intrinsic,
|
|
719
|
-
fieldValidity: props.fieldValidity,
|
|
720
|
-
showValidityIndication: props.showValidityIndication,
|
|
721
|
-
onValidate: props.onValidate,
|
|
722
|
-
onValidityChange: props.onValidityChange
|
|
723
|
-
});
|
|
724
|
-
const isInvalid = showIndication && !validity.valid;
|
|
725
|
-
const handleBlur = (event) => {
|
|
726
|
-
onBlur(event);
|
|
727
|
-
validateOnBlur();
|
|
68
|
+
const selectedOption = typeof value2 === "undefined" ? void 0 : options == null ? void 0 : options.find((option2) => option2.value === value2);
|
|
69
|
+
const handleSelectionChange = (option2) => {
|
|
70
|
+
if (option2 === null) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
onValueChange == null ? void 0 : onValueChange(option2.value);
|
|
728
74
|
};
|
|
729
|
-
const
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
!direction && directionStyles.fallbackDirection
|
|
735
|
-
);
|
|
736
|
-
const descriptionId = description2 ? `${id}-description` : void 0;
|
|
75
|
+
const invalid = typeof errorMessage2 !== "undefined" && errorMessage2 !== "";
|
|
76
|
+
const inErrorState = invalid || Boolean(previewError);
|
|
77
|
+
const { language } = useService(EnvironmentDefinition);
|
|
78
|
+
const { translate } = useService(TranslationsDefinition);
|
|
79
|
+
const ariaLabel = (a11y == null ? void 0 : a11y.ariaLabel) || (label2 ? void 0 : translate("ariaLabels")(AriaLabels.root.key) || AriaLabels.root.default);
|
|
737
80
|
const comboboxId = `${id}-combobox`;
|
|
738
|
-
const
|
|
739
|
-
const
|
|
740
|
-
const
|
|
741
|
-
const
|
|
742
|
-
|
|
743
|
-
const triggerRegion = /* @__PURE__ */ jsx(
|
|
744
|
-
DropdownTrigger,
|
|
745
|
-
{
|
|
746
|
-
isMultiple,
|
|
747
|
-
isSearchable,
|
|
748
|
-
clearable,
|
|
749
|
-
selectedLabel,
|
|
750
|
-
selectedItems,
|
|
751
|
-
placeholder,
|
|
752
|
-
ariaLabel,
|
|
753
|
-
labelId: customAccessibleNameId ?? (ariaLabel ? void 0 : labelId),
|
|
754
|
-
clearLabel,
|
|
755
|
-
removeItemLabel,
|
|
756
|
-
describedById: descriptionId,
|
|
757
|
-
isInvalid,
|
|
758
|
-
onFocus,
|
|
759
|
-
onBlur: handleBlur,
|
|
760
|
-
elementProps
|
|
761
|
-
}
|
|
762
|
-
);
|
|
763
|
-
const list2 = /* @__PURE__ */ jsx(
|
|
764
|
-
DropdownList,
|
|
765
|
-
{
|
|
766
|
-
optionItems,
|
|
767
|
-
filterItem,
|
|
768
|
-
inputValue,
|
|
769
|
-
limit,
|
|
770
|
-
isGrid,
|
|
771
|
-
isSearchable,
|
|
772
|
-
columns,
|
|
773
|
-
inline,
|
|
774
|
-
isMultiple,
|
|
775
|
-
hasInput,
|
|
776
|
-
hasQuery,
|
|
777
|
-
popoverContainer,
|
|
778
|
-
elementProps
|
|
779
|
-
}
|
|
780
|
-
);
|
|
781
|
-
const field = /* @__PURE__ */ jsxs(
|
|
782
|
-
Combobox.Root,
|
|
783
|
-
{
|
|
784
|
-
id: comboboxId,
|
|
785
|
-
multiple: isMultiple,
|
|
786
|
-
value: isMultiple ? selectedItems : selectedItems[0] ?? null,
|
|
787
|
-
onValueChange: (next) => {
|
|
788
|
-
let nextItems;
|
|
789
|
-
if (isMultiple) {
|
|
790
|
-
nextItems = next ?? [];
|
|
791
|
-
} else {
|
|
792
|
-
nextItems = next ? [next] : [];
|
|
793
|
-
}
|
|
794
|
-
handleSelectionChange(nextItems.map((item) => item.key));
|
|
795
|
-
},
|
|
796
|
-
itemToStringLabel: (item) => (item == null ? void 0 : item.label) ?? "",
|
|
797
|
-
itemToStringValue: (item) => (item == null ? void 0 : item.value) ?? "",
|
|
798
|
-
isItemEqualToValue: (a, b) => (a == null ? void 0 : a.key) === (b == null ? void 0 : b.key),
|
|
799
|
-
disabled: isControlDisabled,
|
|
800
|
-
required,
|
|
801
|
-
readOnly,
|
|
802
|
-
name: fieldName,
|
|
803
|
-
inline,
|
|
804
|
-
autoHighlight: isSearchable && autoHighlight,
|
|
805
|
-
openOnInputClick: hasInput && openOnInputClick,
|
|
806
|
-
...isGrid ? { grid: true } : {
|
|
807
|
-
items: optionItems,
|
|
808
|
-
filter: filterItem,
|
|
809
|
-
limit: limit > 0 ? limit : void 0
|
|
810
|
-
},
|
|
811
|
-
...inline ? {} : { open: popupOpen, onOpenChange: setIsOpen },
|
|
812
|
-
...isSearchable ? { inputValue, onInputValueChange: handleInputValueChange } : {},
|
|
813
|
-
children: [
|
|
814
|
-
customAccessibleNameId && /* @__PURE__ */ jsx(
|
|
815
|
-
"span",
|
|
816
|
-
{
|
|
817
|
-
id: customAccessibleNameId,
|
|
818
|
-
className: accessibilityStyles.visuallyHidden,
|
|
819
|
-
children: ariaLabel
|
|
820
|
-
}
|
|
821
|
-
),
|
|
822
|
-
label2 && /* @__PURE__ */ jsxs(
|
|
823
|
-
Combobox.Label,
|
|
824
|
-
{
|
|
825
|
-
className: clsx(
|
|
826
|
-
styles.label,
|
|
827
|
-
selectors.label,
|
|
828
|
-
formatClassNames(semanticClassNames.label),
|
|
829
|
-
(_a = elementProps == null ? void 0 : elementProps.label) == null ? void 0 : _a.className
|
|
830
|
-
),
|
|
831
|
-
"data-testid": TestIds.label,
|
|
832
|
-
children: [
|
|
833
|
-
label2,
|
|
834
|
-
required && /* @__PURE__ */ jsx(
|
|
835
|
-
RequiredIndicator,
|
|
836
|
-
{
|
|
837
|
-
className: formatClassNames(semanticClassNames.requiredIndicator),
|
|
838
|
-
"data-testid": TestIds.requiredIndicator
|
|
839
|
-
}
|
|
840
|
-
)
|
|
841
|
-
]
|
|
842
|
-
}
|
|
843
|
-
),
|
|
844
|
-
triggerRegion,
|
|
845
|
-
list2
|
|
846
|
-
]
|
|
847
|
-
}
|
|
848
|
-
);
|
|
849
|
-
return /* @__PURE__ */ jsx("div", { className: presetWrapperStyles.presetWrapper, ...presetsWrapperProps, children: /* @__PURE__ */ jsxs(
|
|
81
|
+
const helperTextId = helperText2 ? `${id}-helper-text` : void 0;
|
|
82
|
+
const errorMessageId = inErrorState ? `${id}-error-message` : void 0;
|
|
83
|
+
const describedBy = [helperTextId, errorMessageId].filter(Boolean).join(" ") || void 0;
|
|
84
|
+
const accessibleNameId = label2 && ariaLabel ? `${id}-accessible-name` : void 0;
|
|
85
|
+
return /* @__PURE__ */ jsx(
|
|
850
86
|
"div",
|
|
851
87
|
{
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
88
|
+
className: presetWrapperStyles.presetWrapper,
|
|
89
|
+
...wix == null ? void 0 : wix.presetsWrapperProps,
|
|
90
|
+
children: /* @__PURE__ */ jsx(
|
|
91
|
+
"div",
|
|
92
|
+
{
|
|
93
|
+
id,
|
|
94
|
+
ref: setPopoverContainer,
|
|
95
|
+
className: clsx(
|
|
96
|
+
className,
|
|
97
|
+
styles.root,
|
|
98
|
+
editorElementClassNames.root,
|
|
99
|
+
!direction && directionStyles.fallbackDirection
|
|
100
|
+
),
|
|
101
|
+
"data-testid": TestIds.root,
|
|
102
|
+
dir: direction,
|
|
103
|
+
lang: language,
|
|
104
|
+
...getDataAttributes(rest),
|
|
105
|
+
children: /* @__PURE__ */ jsxs(Field.Root, { className: styles.select, invalid: inErrorState, children: [
|
|
106
|
+
/* @__PURE__ */ jsxs(
|
|
107
|
+
Combobox.Root,
|
|
108
|
+
{
|
|
109
|
+
disabled: disabled || !(options == null ? void 0 : options.length),
|
|
110
|
+
id: comboboxId,
|
|
111
|
+
items: options,
|
|
112
|
+
itemToStringLabel,
|
|
113
|
+
itemToStringValue,
|
|
114
|
+
onOpenChange: setOpen,
|
|
115
|
+
onValueChange: handleSelectionChange,
|
|
116
|
+
open: previewList || open,
|
|
117
|
+
readOnly,
|
|
118
|
+
value: selectedOption ?? null,
|
|
119
|
+
children: [
|
|
120
|
+
accessibleNameId && /* @__PURE__ */ jsx(
|
|
121
|
+
"span",
|
|
122
|
+
{
|
|
123
|
+
id: accessibleNameId,
|
|
124
|
+
className: accessibilityStyles.visuallyHidden,
|
|
125
|
+
children: ariaLabel
|
|
126
|
+
}
|
|
127
|
+
),
|
|
128
|
+
label2 && /* @__PURE__ */ jsx(
|
|
129
|
+
Combobox.Label,
|
|
130
|
+
{
|
|
131
|
+
className: clsx(
|
|
132
|
+
styles.label,
|
|
133
|
+
editorElementClassNames.label,
|
|
134
|
+
(_a = elementProps == null ? void 0 : elementProps.label) == null ? void 0 : _a.className
|
|
135
|
+
),
|
|
136
|
+
"data-testid": TestIds.label,
|
|
137
|
+
children: label2
|
|
138
|
+
}
|
|
139
|
+
),
|
|
140
|
+
/* @__PURE__ */ jsxs(
|
|
141
|
+
Combobox.Trigger,
|
|
142
|
+
{
|
|
143
|
+
...accessibleNameId ? { "aria-labelledby": accessibleNameId } : {},
|
|
144
|
+
"aria-describedby": describedBy,
|
|
145
|
+
"aria-haspopup": "listbox",
|
|
146
|
+
"aria-invalid": inErrorState || void 0,
|
|
147
|
+
"aria-label": ariaLabel,
|
|
148
|
+
className: clsx(
|
|
149
|
+
styles.input,
|
|
150
|
+
editorElementClassNames.input,
|
|
151
|
+
(_b = elementProps == null ? void 0 : elementProps.input) == null ? void 0 : _b.className,
|
|
152
|
+
// No native pseudo-class exists for "invalid" here (see the
|
|
153
|
+
// manifest's `input.states.error` comment) — applied for
|
|
154
|
+
// real so the live export (scoped to this same class) has a
|
|
155
|
+
// real selector to bind to, not just the editor's own
|
|
156
|
+
// design-preview injection. Same pattern as Option's
|
|
157
|
+
// `selected` state below.
|
|
158
|
+
inErrorState ? DesignStates.input.error.className : void 0
|
|
159
|
+
),
|
|
160
|
+
"data-testid": TestIds.input,
|
|
161
|
+
children: [
|
|
162
|
+
/* @__PURE__ */ jsx(Combobox.Value, { children: /* @__PURE__ */ jsx(
|
|
163
|
+
"span",
|
|
164
|
+
{
|
|
165
|
+
className: clsx(
|
|
166
|
+
styles.value,
|
|
167
|
+
!selectedOption && styles.placeholder
|
|
168
|
+
),
|
|
169
|
+
children: selectedOption ? selectedOption.label : placeholder2
|
|
170
|
+
}
|
|
171
|
+
) }),
|
|
172
|
+
/* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: styles.arrow })
|
|
173
|
+
]
|
|
174
|
+
}
|
|
886
175
|
),
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
176
|
+
/* @__PURE__ */ jsx(Combobox.Portal, { container: popoverContainer, children: /* @__PURE__ */ jsx(Combobox.Positioner, { className: styles.positioner, sideOffset: 4, children: /* @__PURE__ */ jsx(
|
|
177
|
+
Combobox.Popup,
|
|
178
|
+
{
|
|
179
|
+
className: clsx(
|
|
180
|
+
styles.popup,
|
|
181
|
+
editorElementClassNames.list,
|
|
182
|
+
(_c = elementProps == null ? void 0 : elementProps.list) == null ? void 0 : _c.className
|
|
183
|
+
),
|
|
184
|
+
"data-testid": TestIds.list,
|
|
185
|
+
children: /* @__PURE__ */ jsx(Combobox.List, { className: styles.list, children: options == null ? void 0 : options.map((option2, index) => {
|
|
186
|
+
var _a2;
|
|
187
|
+
return /* @__PURE__ */ jsx(
|
|
188
|
+
Combobox.Item,
|
|
189
|
+
{
|
|
190
|
+
className: clsx(
|
|
191
|
+
styles.option,
|
|
192
|
+
editorElementClassNames.option,
|
|
193
|
+
(_a2 = elementProps == null ? void 0 : elementProps.option) == null ? void 0 : _a2.className,
|
|
194
|
+
// No native pseudo-class exists for "selected" (see
|
|
195
|
+
// the manifest's `option.states.selected` comment)
|
|
196
|
+
// — applied for real here so the panel's per-state
|
|
197
|
+
// export has a real selector to bind to, not just
|
|
198
|
+
// the editor's own design-preview injection.
|
|
199
|
+
option2 === selectedOption ? DesignStates.option.selected.className : void 0
|
|
200
|
+
),
|
|
201
|
+
value: option2,
|
|
202
|
+
children: /* @__PURE__ */ jsx("span", { className: styles.optionLabel, children: option2.label })
|
|
203
|
+
},
|
|
204
|
+
`option-${index}`
|
|
205
|
+
);
|
|
206
|
+
}) })
|
|
207
|
+
}
|
|
208
|
+
) }) })
|
|
209
|
+
]
|
|
210
|
+
}
|
|
902
211
|
),
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
212
|
+
helperText2 && /* @__PURE__ */ jsx(
|
|
213
|
+
"p",
|
|
214
|
+
{
|
|
215
|
+
className: clsx(
|
|
216
|
+
styles.helperText,
|
|
217
|
+
editorElementClassNames.helperText,
|
|
218
|
+
(_d = elementProps == null ? void 0 : elementProps.helperText) == null ? void 0 : _d.className
|
|
219
|
+
),
|
|
220
|
+
"data-testid": TestIds.helperText,
|
|
221
|
+
id: helperTextId,
|
|
222
|
+
children: helperText2
|
|
223
|
+
}
|
|
224
|
+
),
|
|
225
|
+
inErrorState && /* @__PURE__ */ jsx(
|
|
226
|
+
Field.Error,
|
|
227
|
+
{
|
|
228
|
+
className: clsx(
|
|
229
|
+
styles.errorMessage,
|
|
230
|
+
editorElementClassNames.errorMessage,
|
|
231
|
+
(_e = elementProps == null ? void 0 : elementProps.errorMessage) == null ? void 0 : _e.className
|
|
232
|
+
),
|
|
233
|
+
"data-testid": TestIds.errorMessage,
|
|
234
|
+
id: errorMessageId,
|
|
235
|
+
match: true,
|
|
236
|
+
children: errorMessage2
|
|
237
|
+
}
|
|
238
|
+
)
|
|
239
|
+
] })
|
|
240
|
+
}
|
|
241
|
+
)
|
|
910
242
|
}
|
|
911
|
-
)
|
|
243
|
+
);
|
|
912
244
|
}
|
|
913
245
|
export {
|
|
914
246
|
Dropdown as default
|