@fluidattacks/design 9.1.1 → 9.1.2
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/components/inputs/fields/combobox/field/index.js +158 -156
- package/dist/components/inputs/fields/combobox/option/index.d.ts +1 -1
- package/dist/components/inputs/fields/combobox/option/index.js +85 -81
- package/dist/components/inputs/fields/combobox/types.d.ts +2 -0
- package/package.json +1 -1
|
@@ -1,74 +1,74 @@
|
|
|
1
|
-
import { jsx as t, jsxs as
|
|
2
|
-
import { useVirtualizer as
|
|
3
|
-
import { useState as v, useMemo as
|
|
4
|
-
import { useButton as
|
|
5
|
-
import { useComboBox as
|
|
6
|
-
import { useFilter as
|
|
7
|
-
import { useListBox as
|
|
8
|
-
import { useComboBoxState as
|
|
9
|
-
import { Item as
|
|
10
|
-
import { useTheme as
|
|
11
|
-
import { OutlineContainer as
|
|
12
|
-
import { StyledTextInputContainer as
|
|
1
|
+
import { jsx as t, jsxs as F } from "react/jsx-runtime";
|
|
2
|
+
import { useVirtualizer as We } from "../../../../../node_modules/@tanstack/react-virtual/dist/esm/index.js";
|
|
3
|
+
import { useState as v, useMemo as x, useRef as g, useCallback as y } from "react";
|
|
4
|
+
import { useButton as Ye } from "../../../../../node_modules/react-aria/dist/private/button/useButton.js";
|
|
5
|
+
import { useComboBox as qe } from "../../../../../node_modules/react-aria/dist/private/combobox/useComboBox.js";
|
|
6
|
+
import { useFilter as Je } from "../../../../../node_modules/react-aria/dist/private/i18n/useFilter.js";
|
|
7
|
+
import { useListBox as Pe } from "../../../../../node_modules/react-aria/dist/private/listbox/useListBox.js";
|
|
8
|
+
import { useComboBoxState as Qe } from "../../../../../node_modules/react-stately/dist/private/combobox/useComboBoxState.js";
|
|
9
|
+
import { Item as Xe } from "../../../../../node_modules/react-stately/dist/private/collections/Item.js";
|
|
10
|
+
import { useTheme as Ze } from "styled-components";
|
|
11
|
+
import { OutlineContainer as _e } from "../../../outline-container/index.js";
|
|
12
|
+
import { StyledTextInputContainer as eo } from "../../../styles.js";
|
|
13
13
|
import { Popover as de } from "../../../utils/popover/index.js";
|
|
14
|
-
import { Option as
|
|
15
|
-
import { StyledStatusMessage as
|
|
16
|
-
import { describeSelection as
|
|
14
|
+
import { Option as oo } from "../option/index.js";
|
|
15
|
+
import { StyledStatusMessage as to, ChevronIconButton as ro, StyledDropdown as he, StyledGroupHeader as no, StyledEmptyMessage as so } from "../styles.js";
|
|
16
|
+
import { describeSelection as lo, toSelection as me } from "../utils.js";
|
|
17
17
|
import { Icon as q } from "../../../../icon/index.js";
|
|
18
|
-
import { IconButton as
|
|
18
|
+
import { IconButton as ao } from "../../../../icon-button/index.js";
|
|
19
19
|
import "../../../../typography/heading/index.js";
|
|
20
20
|
import "../../../../typography/span/index.js";
|
|
21
21
|
import { Text as J } from "../../../../typography/text/index.js";
|
|
22
|
-
import { useClickOutside as
|
|
23
|
-
const
|
|
22
|
+
import { useClickOutside as co } from "../../../../../hooks/use-click-outside.js";
|
|
23
|
+
const ko = ({
|
|
24
24
|
field: u,
|
|
25
25
|
disabled: h = !1,
|
|
26
|
-
disabledKeys:
|
|
27
|
-
error:
|
|
26
|
+
disabledKeys: $,
|
|
27
|
+
error: ge,
|
|
28
28
|
helpLink: ye,
|
|
29
|
-
helpLinkText:
|
|
30
|
-
helpText:
|
|
29
|
+
helpLinkText: ve,
|
|
30
|
+
helpText: xe,
|
|
31
31
|
label: P,
|
|
32
|
-
loadingItems:
|
|
33
|
-
name:
|
|
32
|
+
loadingItems: $e,
|
|
33
|
+
name: l,
|
|
34
34
|
multiSelection: r = !1,
|
|
35
35
|
items: o,
|
|
36
36
|
onBlur: K,
|
|
37
37
|
onChange: f,
|
|
38
38
|
onClear: Q,
|
|
39
|
-
placeholder:
|
|
40
|
-
clearable:
|
|
39
|
+
placeholder: be,
|
|
40
|
+
clearable: we = !1,
|
|
41
41
|
emptyMessage: X,
|
|
42
42
|
statusMessage: Z,
|
|
43
|
-
required:
|
|
44
|
-
setValue:
|
|
45
|
-
tooltip:
|
|
46
|
-
value:
|
|
47
|
-
watch:
|
|
48
|
-
weight:
|
|
43
|
+
required: Se,
|
|
44
|
+
setValue: b,
|
|
45
|
+
tooltip: Be,
|
|
46
|
+
value: Ce,
|
|
47
|
+
watch: w,
|
|
48
|
+
weight: Ae
|
|
49
49
|
}) => {
|
|
50
|
-
const m =
|
|
51
|
-
|
|
50
|
+
const m = Ze(), k = h ? void 0 : ge, d = u?.value ?? Ce, [D, S] = v(() => r ? lo(
|
|
51
|
+
me(w?.(`${l}Options`)),
|
|
52
52
|
o.map((e) => e.value),
|
|
53
|
-
|
|
53
|
+
$ ?? [],
|
|
54
54
|
o.find((e) => e.value === "All")?.name
|
|
55
|
-
).text : o.find((e) => e.value === d)?.name ?? ""), [_,
|
|
55
|
+
).text : o.find((e) => e.value === d)?.name ?? ""), [_, G] = v(d), j = ($e === !1 || !d) && !r, M = x(
|
|
56
56
|
() => j ? o.find((e) => e.value === d)?.name ?? "" : "",
|
|
57
57
|
[j, d, o]
|
|
58
|
-
), [
|
|
59
|
-
j && (d !==
|
|
60
|
-
const [
|
|
61
|
-
const e = Y.current, s = Array.from(
|
|
58
|
+
), [Oe, ze] = v(d), [Ie, Re] = v(M);
|
|
59
|
+
j && (d !== Oe || M !== Ie) && (ze(d), Re(M), S(M), G(d ?? ""));
|
|
60
|
+
const [Fe, H] = v(o), [ee, B] = v(!1), { contains: N } = Je({ sensitivity: "base" }), U = g(null), W = g(null), C = g(null), A = g(null), oe = g(null), O = g(null), Y = g(/* @__PURE__ */ new Set()), ke = x(() => {
|
|
61
|
+
const e = Y.current, s = Array.from($ ?? []), c = o.some((n) => n.group !== void 0);
|
|
62
62
|
return o.toSorted((n, p) => {
|
|
63
63
|
if (n.value === "All") return -1;
|
|
64
64
|
if (p.value === "All") return 1;
|
|
65
65
|
const E = s.includes(n.value), L = s.includes(p.value);
|
|
66
|
-
if (
|
|
67
|
-
const
|
|
66
|
+
if (c) {
|
|
67
|
+
const I = n.group ?? "", R = p.group ?? "";
|
|
68
68
|
if (!n.group && p.group) return -1;
|
|
69
69
|
if (n.group && !p.group) return 1;
|
|
70
|
-
if (
|
|
71
|
-
return
|
|
70
|
+
if (I !== R)
|
|
71
|
+
return I.localeCompare(R);
|
|
72
72
|
if (E && !L) return 1;
|
|
73
73
|
if (!E && L) return -1;
|
|
74
74
|
if (r) {
|
|
@@ -81,124 +81,125 @@ const Fo = ({
|
|
|
81
81
|
if (E && !L) return 1;
|
|
82
82
|
if (!E && L) return -1;
|
|
83
83
|
if (r) {
|
|
84
|
-
const
|
|
85
|
-
return
|
|
84
|
+
const I = e.has(n.value), R = e.has(p.value);
|
|
85
|
+
return I && !R ? -1 : !I && R ? 1 : n.name.localeCompare(p.name);
|
|
86
86
|
}
|
|
87
87
|
return 0;
|
|
88
88
|
}).map(
|
|
89
|
-
(n) =>
|
|
90
|
-
|
|
89
|
+
(n) => N(n.name, D) || ee ? /* @__PURE__ */ t(
|
|
90
|
+
Xe,
|
|
91
91
|
{
|
|
92
92
|
"aria-label": n.value,
|
|
93
93
|
hrefLang: n.href,
|
|
94
|
-
textValue: n.
|
|
94
|
+
textValue: n.name,
|
|
95
95
|
children: n.name
|
|
96
96
|
},
|
|
97
97
|
n.value
|
|
98
98
|
) : null
|
|
99
99
|
);
|
|
100
|
-
}, [
|
|
100
|
+
}, [N, $, D, o, r, ee]), De = y(
|
|
101
101
|
(e) => {
|
|
102
102
|
const s = e.split(/,|\s/u).slice(-1)[0].trim();
|
|
103
|
-
|
|
104
|
-
const
|
|
105
|
-
return u && u.onChange(
|
|
103
|
+
S(r ? s : e), e === "" || e.endsWith(",") ? B(!0) : (B(!1), G((c) => {
|
|
104
|
+
const i = e === "" ? "" : c;
|
|
105
|
+
return u && u.onChange(i), f && f(e), i;
|
|
106
106
|
}), H(
|
|
107
107
|
o.filter(
|
|
108
|
-
(
|
|
108
|
+
(c) => N(c.name, r ? s : e)
|
|
109
109
|
)
|
|
110
110
|
));
|
|
111
111
|
},
|
|
112
|
-
[
|
|
113
|
-
), Ge =
|
|
112
|
+
[N, o, u, r, f]
|
|
113
|
+
), Ge = y(
|
|
114
114
|
(e) => {
|
|
115
|
-
|
|
115
|
+
S(o.find((s) => s.value === e)?.name ?? ""), G(e ? String(e) : ""), u && u.onChange(e), f && f(e ? String(e) : ""), H(o);
|
|
116
116
|
},
|
|
117
117
|
[o, u, f]
|
|
118
|
-
), te =
|
|
118
|
+
), te = y(
|
|
119
119
|
(e) => {
|
|
120
|
-
e.key === "Enter" && e.preventDefault(),
|
|
120
|
+
e.key === "Enter" && e.preventDefault(), B(!1);
|
|
121
121
|
},
|
|
122
122
|
[]
|
|
123
|
-
),
|
|
123
|
+
), Me = y(() => {
|
|
124
124
|
K && K(), u && u.onBlur();
|
|
125
|
-
}, [u, K]), Ne =
|
|
126
|
-
|
|
127
|
-
}, []), a =
|
|
125
|
+
}, [u, K]), Ne = y(() => {
|
|
126
|
+
B(!0);
|
|
127
|
+
}, []), a = Qe({
|
|
128
128
|
allowsCustomValue: r,
|
|
129
129
|
allowsEmptyCollection: !0,
|
|
130
|
-
disabledKeys:
|
|
131
|
-
inputValue:
|
|
132
|
-
items:
|
|
130
|
+
disabledKeys: $,
|
|
131
|
+
inputValue: D,
|
|
132
|
+
items: Fe,
|
|
133
133
|
menuTrigger: "focus",
|
|
134
134
|
shouldCloseOnBlur: !r,
|
|
135
135
|
selectedKey: _,
|
|
136
|
-
onBlur:
|
|
136
|
+
onBlur: Me,
|
|
137
137
|
onInputChange: De,
|
|
138
138
|
onKeyDown: te,
|
|
139
139
|
onKeyUp: Ne,
|
|
140
140
|
onOpenChange(e, s) {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
}
|
|
145
|
-
S(
|
|
141
|
+
e && r && w && (Y.current = new Set(
|
|
142
|
+
me(w(`${l}Options`)).filter(Boolean)
|
|
143
|
+
)), B(
|
|
146
144
|
e && (s === "manual" || s === "focus")
|
|
147
145
|
), e && s !== "focus" && requestAnimationFrame(() => {
|
|
148
146
|
U.current?.focus();
|
|
149
147
|
});
|
|
150
148
|
},
|
|
151
149
|
onSelectionChange: r ? void 0 : Ge,
|
|
152
|
-
children:
|
|
153
|
-
}),
|
|
154
|
-
|
|
155
|
-
}, [o, r,
|
|
150
|
+
children: ke
|
|
151
|
+
}), Te = y(() => {
|
|
152
|
+
S(""), G(null), H(o), a.setSelectedKey(null), a.setInputValue(""), f && f(""), r && b && (b(`${l}Options`, []), b(`${l}CheckAll`, "")), Q?.();
|
|
153
|
+
}, [o, r, l, Q, f, b, a]), {
|
|
156
154
|
buttonProps: Ve,
|
|
157
|
-
inputProps:
|
|
158
|
-
listBoxProps:
|
|
159
|
-
} =
|
|
155
|
+
inputProps: Ee,
|
|
156
|
+
listBoxProps: Le
|
|
157
|
+
} = qe(
|
|
160
158
|
{
|
|
161
|
-
inputValue:
|
|
159
|
+
inputValue: D,
|
|
162
160
|
buttonRef: W,
|
|
163
|
-
id:
|
|
161
|
+
id: l,
|
|
164
162
|
inputRef: U,
|
|
165
|
-
label: P ??
|
|
166
|
-
listBoxRef:
|
|
167
|
-
name:
|
|
168
|
-
placeholder:
|
|
169
|
-
popoverRef:
|
|
163
|
+
label: P ?? l,
|
|
164
|
+
listBoxRef: C,
|
|
165
|
+
name: l,
|
|
166
|
+
placeholder: be,
|
|
167
|
+
popoverRef: O
|
|
170
168
|
},
|
|
171
169
|
a
|
|
172
|
-
), { listBoxProps: re } =
|
|
170
|
+
), { listBoxProps: re } = Pe(Le, a, C), { buttonProps: Ke } = Ye(Ve, W), { width: ne } = A.current?.getBoundingClientRect() ?? {
|
|
173
171
|
width: 240
|
|
174
172
|
};
|
|
175
|
-
|
|
173
|
+
co(A, () => {
|
|
176
174
|
a.isOpen && !r && a.close();
|
|
177
|
-
}, [
|
|
178
|
-
const
|
|
175
|
+
}, [O]);
|
|
176
|
+
const z = Array.from(a.collection), se = r ? z.findLastIndex(
|
|
179
177
|
(e) => e.key === "All" || Y.current.has(String(e.key))
|
|
180
|
-
) : -1,
|
|
178
|
+
) : -1, je = x(() => o.map((e) => e.value), [o]), le = x(
|
|
181
179
|
() => new Map(o.map((e) => [e.value, e.group])),
|
|
182
180
|
[o]
|
|
183
|
-
),
|
|
184
|
-
(
|
|
185
|
-
|
|
186
|
-
|
|
181
|
+
), He = x(
|
|
182
|
+
() => new Map(o.map((e) => [e.value, e.tag])),
|
|
183
|
+
[o]
|
|
184
|
+
), T = x(() => z.reduce(
|
|
185
|
+
(e, s, c) => {
|
|
186
|
+
const i = le.get(String(s.key));
|
|
187
|
+
return i !== void 0 && i !== e.currentGroup ? (e.result.push({ type: "header", group: i }), e.currentGroup = i) : i === void 0 && e.currentGroup !== void 0 && (e.currentGroup = void 0), e.result.push({ type: "item", index: c }), e;
|
|
187
188
|
},
|
|
188
189
|
{ result: [], currentGroup: void 0 }
|
|
189
|
-
).result, [
|
|
190
|
-
count:
|
|
191
|
-
estimateSize: (e) =>
|
|
192
|
-
getScrollElement: () =>
|
|
190
|
+
).result, [z, le]), ae = We({
|
|
191
|
+
count: T.length,
|
|
192
|
+
estimateSize: (e) => T[e].type === "header" ? 44 : 28,
|
|
193
|
+
getScrollElement: () => C.current,
|
|
193
194
|
useFlushSync: !1
|
|
194
|
-
}),
|
|
195
|
+
}), ce = a.isOpen && !h, V = ce && !!Z, ie = ce && o.length === 0 && !!X, Ue = y(
|
|
195
196
|
(e) => {
|
|
196
197
|
e.preventDefault();
|
|
197
198
|
},
|
|
198
199
|
[]
|
|
199
|
-
), pe =
|
|
200
|
+
), pe = V ? (
|
|
200
201
|
// A listbox only owns options, so the row itself must stay presentational
|
|
201
|
-
/* @__PURE__ */ t(
|
|
202
|
+
/* @__PURE__ */ t(to, { onMouseDown: Ue, role: "presentation", children: /* @__PURE__ */ t("div", { "aria-live": "polite", role: "status", children: /* @__PURE__ */ t(
|
|
202
203
|
J,
|
|
203
204
|
{
|
|
204
205
|
color: m.palette.gray[400],
|
|
@@ -209,39 +210,39 @@ const Fo = ({
|
|
|
209
210
|
}
|
|
210
211
|
) }) })
|
|
211
212
|
) : null;
|
|
212
|
-
return /* @__PURE__ */
|
|
213
|
-
|
|
213
|
+
return /* @__PURE__ */ F(
|
|
214
|
+
_e,
|
|
214
215
|
{
|
|
215
216
|
containerRef: oe,
|
|
216
|
-
error:
|
|
217
|
+
error: k,
|
|
217
218
|
helpLink: ye,
|
|
218
|
-
helpLinkText:
|
|
219
|
-
helpText:
|
|
220
|
-
htmlFor:
|
|
221
|
-
id: `combobox-${
|
|
219
|
+
helpLinkText: ve,
|
|
220
|
+
helpText: xe,
|
|
221
|
+
htmlFor: l,
|
|
222
|
+
id: `combobox-${l}`,
|
|
222
223
|
label: P,
|
|
223
|
-
required:
|
|
224
|
-
tooltip:
|
|
225
|
-
weight:
|
|
224
|
+
required: Se,
|
|
225
|
+
tooltip: Be,
|
|
226
|
+
weight: Ae,
|
|
226
227
|
children: [
|
|
227
|
-
/* @__PURE__ */
|
|
228
|
-
|
|
228
|
+
/* @__PURE__ */ F(
|
|
229
|
+
eo,
|
|
229
230
|
{
|
|
230
|
-
className: `${h ? "disabled" : ""} ${
|
|
231
|
-
ref:
|
|
231
|
+
className: `${h ? "disabled" : ""} ${k ? "error" : ""}`,
|
|
232
|
+
ref: A,
|
|
232
233
|
children: [
|
|
233
234
|
/* @__PURE__ */ t(
|
|
234
235
|
"input",
|
|
235
236
|
{
|
|
236
|
-
...
|
|
237
|
-
"aria-invalid":
|
|
238
|
-
"aria-label":
|
|
237
|
+
...Ee,
|
|
238
|
+
"aria-invalid": k ? "true" : "false",
|
|
239
|
+
"aria-label": l,
|
|
239
240
|
disabled: h,
|
|
240
241
|
onKeyDown: te,
|
|
241
242
|
ref: U
|
|
242
243
|
}
|
|
243
244
|
),
|
|
244
|
-
|
|
245
|
+
k ? /* @__PURE__ */ t(
|
|
245
246
|
q,
|
|
246
247
|
{
|
|
247
248
|
icon: "exclamation-circle",
|
|
@@ -250,24 +251,24 @@ const Fo = ({
|
|
|
250
251
|
iconSize: "lg"
|
|
251
252
|
}
|
|
252
253
|
) : void 0,
|
|
253
|
-
|
|
254
|
-
|
|
254
|
+
we && !h && (r ? (w?.(`${l}Options`)?.length ?? 0) > 0 : _) ? /* @__PURE__ */ t(
|
|
255
|
+
ao,
|
|
255
256
|
{
|
|
256
257
|
icon: "xmark",
|
|
257
258
|
iconColor: m.palette.gray[400],
|
|
258
259
|
iconSize: "sm",
|
|
259
260
|
iconType: "fa-light",
|
|
260
|
-
onClick:
|
|
261
|
+
onClick: Te,
|
|
261
262
|
px: 0.125,
|
|
262
263
|
py: 0.125,
|
|
263
264
|
type: "reset",
|
|
264
265
|
variant: "ghost"
|
|
265
266
|
}
|
|
266
267
|
) : void 0,
|
|
267
|
-
/* @__PURE__ */
|
|
268
|
-
|
|
268
|
+
/* @__PURE__ */ F(
|
|
269
|
+
ro,
|
|
269
270
|
{
|
|
270
|
-
...
|
|
271
|
+
...Ke,
|
|
271
272
|
$variant: "ghost",
|
|
272
273
|
className: `action ${a.isOpen && !h ? "open" : "closed"}`,
|
|
273
274
|
disabled: h,
|
|
@@ -306,30 +307,30 @@ const Fo = ({
|
|
|
306
307
|
de,
|
|
307
308
|
{
|
|
308
309
|
className: "dropdown",
|
|
309
|
-
id: `popover-${
|
|
310
|
+
id: `popover-${l}`,
|
|
310
311
|
offset: 4,
|
|
311
312
|
placement: "bottom start",
|
|
312
|
-
popoverRef:
|
|
313
|
+
popoverRef: O,
|
|
313
314
|
state: a,
|
|
314
|
-
triggerRef:
|
|
315
|
-
children: /* @__PURE__ */
|
|
315
|
+
triggerRef: A,
|
|
316
|
+
children: /* @__PURE__ */ F(
|
|
316
317
|
he,
|
|
317
318
|
{
|
|
318
319
|
...re,
|
|
319
|
-
$hasStatus:
|
|
320
|
-
$multiSelection: r && !Array.from(
|
|
320
|
+
$hasStatus: V,
|
|
321
|
+
$multiSelection: r && !Array.from($ ?? []).includes("All"),
|
|
321
322
|
$width: ne,
|
|
322
|
-
ref:
|
|
323
|
+
ref: C,
|
|
323
324
|
children: [
|
|
324
325
|
/* @__PURE__ */ t(
|
|
325
326
|
"div",
|
|
326
327
|
{
|
|
327
328
|
style: {
|
|
328
|
-
height: `${
|
|
329
|
+
height: `${ae.getTotalSize()}px`,
|
|
329
330
|
position: "relative"
|
|
330
331
|
},
|
|
331
|
-
children:
|
|
332
|
-
const s =
|
|
332
|
+
children: ae.getVirtualItems().map((e) => {
|
|
333
|
+
const s = T[e.index];
|
|
333
334
|
if (s.type === "header")
|
|
334
335
|
return /* @__PURE__ */ t(
|
|
335
336
|
"div",
|
|
@@ -342,7 +343,7 @@ const Fo = ({
|
|
|
342
343
|
height: `${e.size}px`,
|
|
343
344
|
transform: `translateY(${e.start}px)`
|
|
344
345
|
},
|
|
345
|
-
children: /* @__PURE__ */ t(
|
|
346
|
+
children: /* @__PURE__ */ t(no, { children: /* @__PURE__ */ t(
|
|
346
347
|
J,
|
|
347
348
|
{
|
|
348
349
|
color: m.palette.gray[400],
|
|
@@ -354,7 +355,7 @@ const Fo = ({
|
|
|
354
355
|
},
|
|
355
356
|
`header-${e.index}`
|
|
356
357
|
);
|
|
357
|
-
const
|
|
358
|
+
const c = z[s.index], i = T[e.index + 1], n = c.key === "All" && i?.type === "header", p = r && s.index === se && se >= 0 && s.index < z.length - 1 && !n;
|
|
358
359
|
return /* @__PURE__ */ t(
|
|
359
360
|
"div",
|
|
360
361
|
{
|
|
@@ -368,22 +369,23 @@ const Fo = ({
|
|
|
368
369
|
borderBottom: p ? `1px solid ${m.palette.gray[200]}` : void 0
|
|
369
370
|
},
|
|
370
371
|
children: /* @__PURE__ */ t(
|
|
371
|
-
|
|
372
|
+
oo,
|
|
372
373
|
{
|
|
373
|
-
allItemKeys:
|
|
374
|
+
allItemKeys: je,
|
|
374
375
|
containerRef: oe,
|
|
375
|
-
item:
|
|
376
|
+
item: c,
|
|
376
377
|
multiSelection: r,
|
|
377
|
-
name:
|
|
378
|
-
popoverRef:
|
|
379
|
-
setInputValue:
|
|
380
|
-
setValue:
|
|
378
|
+
name: l,
|
|
379
|
+
popoverRef: O,
|
|
380
|
+
setInputValue: S,
|
|
381
|
+
setValue: b,
|
|
381
382
|
state: a,
|
|
382
|
-
|
|
383
|
+
tag: He.get(String(c.key)),
|
|
384
|
+
watch: w
|
|
383
385
|
}
|
|
384
386
|
)
|
|
385
387
|
},
|
|
386
|
-
|
|
388
|
+
c.key
|
|
387
389
|
);
|
|
388
390
|
})
|
|
389
391
|
}
|
|
@@ -393,26 +395,26 @@ const Fo = ({
|
|
|
393
395
|
}
|
|
394
396
|
)
|
|
395
397
|
}
|
|
396
|
-
) : !
|
|
398
|
+
) : !ie && !V ? null : /* @__PURE__ */ t(
|
|
397
399
|
de,
|
|
398
400
|
{
|
|
399
401
|
className: "dropdown",
|
|
400
|
-
id: `popover-${
|
|
402
|
+
id: `popover-${l}-empty`,
|
|
401
403
|
offset: 4,
|
|
402
404
|
placement: "bottom start",
|
|
403
|
-
popoverRef:
|
|
405
|
+
popoverRef: O,
|
|
404
406
|
state: a,
|
|
405
|
-
triggerRef:
|
|
406
|
-
children: /* @__PURE__ */
|
|
407
|
+
triggerRef: A,
|
|
408
|
+
children: /* @__PURE__ */ F(
|
|
407
409
|
he,
|
|
408
410
|
{
|
|
409
411
|
...re,
|
|
410
|
-
$hasStatus:
|
|
412
|
+
$hasStatus: V,
|
|
411
413
|
$multiSelection: !1,
|
|
412
414
|
$width: ne,
|
|
413
|
-
ref:
|
|
415
|
+
ref: C,
|
|
414
416
|
children: [
|
|
415
|
-
|
|
417
|
+
ie ? /* @__PURE__ */ t(so, { children: /* @__PURE__ */ t(
|
|
416
418
|
J,
|
|
417
419
|
{
|
|
418
420
|
color: m.palette.gray[400],
|
|
@@ -433,5 +435,5 @@ const Fo = ({
|
|
|
433
435
|
);
|
|
434
436
|
};
|
|
435
437
|
export {
|
|
436
|
-
|
|
438
|
+
ko as ComboBoxField
|
|
437
439
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { IOptionProps } from '../types';
|
|
2
|
-
declare const Option: <T extends object>({ allItemKeys, containerRef, item, multiSelection, name, popoverRef, setInputValue, setValue, state, watch, }: Readonly<IOptionProps<T>>) => JSX.Element;
|
|
2
|
+
declare const Option: <T extends object>({ allItemKeys, containerRef, item, multiSelection, name, popoverRef, setInputValue, setValue, state, tag, watch, }: Readonly<IOptionProps<T>>) => JSX.Element;
|
|
3
3
|
export { Option };
|
|
@@ -1,121 +1,125 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { useOption as
|
|
4
|
-
import { useTheme as
|
|
5
|
-
import { StyledOption as
|
|
6
|
-
import { describeSelection as
|
|
7
|
-
import { Checkbox as
|
|
8
|
-
import { Icon as
|
|
9
|
-
import { Link as
|
|
10
|
-
import { Tag as
|
|
1
|
+
import { jsx as l, jsxs as G } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as H, useMemo as f, useCallback as k } from "react";
|
|
3
|
+
import { useOption as J } from "../../../../../node_modules/react-aria/dist/private/listbox/useOption.js";
|
|
4
|
+
import { useTheme as Q } from "styled-components";
|
|
5
|
+
import { StyledOption as W } from "../styles.js";
|
|
6
|
+
import { describeSelection as X, toSelection as j } from "../utils.js";
|
|
7
|
+
import { Checkbox as u } from "../../../../checkbox/index.js";
|
|
8
|
+
import { Icon as Y } from "../../../../icon/index.js";
|
|
9
|
+
import { Link as Z } from "../../../../link/index.js";
|
|
10
|
+
import { Tag as _ } from "../../../../tag/index.js";
|
|
11
11
|
import "../../../../typography/heading/index.js";
|
|
12
12
|
import "../../../../typography/span/index.js";
|
|
13
|
-
import { Text as
|
|
14
|
-
import { useClickOutside as
|
|
15
|
-
import { openUrl as
|
|
16
|
-
const
|
|
17
|
-
allItemKeys:
|
|
18
|
-
containerRef:
|
|
13
|
+
import { Text as I } from "../../../../typography/text/index.js";
|
|
14
|
+
import { useClickOutside as V } from "../../../../../hooks/use-click-outside.js";
|
|
15
|
+
import { openUrl as oo } from "../../../../../utils/open-url.js";
|
|
16
|
+
const Co = ({
|
|
17
|
+
allItemKeys: a,
|
|
18
|
+
containerRef: D,
|
|
19
19
|
item: o,
|
|
20
|
-
multiSelection:
|
|
21
|
-
name:
|
|
22
|
-
popoverRef:
|
|
23
|
-
setInputValue:
|
|
20
|
+
multiSelection: s,
|
|
21
|
+
name: e,
|
|
22
|
+
popoverRef: w,
|
|
23
|
+
setInputValue: i,
|
|
24
24
|
setValue: n,
|
|
25
25
|
state: c,
|
|
26
|
-
|
|
26
|
+
tag: C,
|
|
27
|
+
watch: h
|
|
27
28
|
}) => {
|
|
28
|
-
const
|
|
29
|
-
(
|
|
30
|
-
), { optionProps:
|
|
29
|
+
const z = Q(), y = H(null), d = o.props.hrefLang, g = c.disabledKeys, A = a.filter(
|
|
30
|
+
(r) => !Array.from(g).includes(r) && r !== "All"
|
|
31
|
+
), { optionProps: F, isSelected: $, isFocused: q, isDisabled: O } = J(
|
|
31
32
|
{ key: o.key },
|
|
32
33
|
c,
|
|
33
|
-
|
|
34
|
-
),
|
|
34
|
+
y
|
|
35
|
+
), m = f(() => c.collection.getItem("All")?.rendered?.toString(), [c.collection]), B = [
|
|
35
36
|
$ ? "selected" : "",
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
].join(" "),
|
|
39
|
-
(
|
|
40
|
-
const { allSelected:
|
|
41
|
-
|
|
37
|
+
q ? "focused" : "",
|
|
38
|
+
O ? "disabled" : ""
|
|
39
|
+
].join(" "), b = k(
|
|
40
|
+
(r) => {
|
|
41
|
+
const { allSelected: t, text: p } = X(
|
|
42
|
+
r,
|
|
43
|
+
a,
|
|
42
44
|
g,
|
|
43
|
-
|
|
44
|
-
b
|
|
45
|
+
m
|
|
45
46
|
);
|
|
46
|
-
n?.(`${
|
|
47
|
+
n?.(`${e}CheckAll`, t ? p : ""), i(p);
|
|
47
48
|
},
|
|
48
|
-
[
|
|
49
|
-
),
|
|
50
|
-
(
|
|
51
|
-
if (
|
|
52
|
-
const
|
|
53
|
-
n?.(`${
|
|
49
|
+
[a, m, g, e, i, n]
|
|
50
|
+
), K = k(
|
|
51
|
+
(r) => {
|
|
52
|
+
if (r.target.checked) {
|
|
53
|
+
const t = [...A].sort();
|
|
54
|
+
n?.(`${e}Options`, t), n?.(`${e}CheckAll`, r.target.value), i(r.target.value);
|
|
54
55
|
} else
|
|
55
|
-
n?.(`${
|
|
56
|
+
n?.(`${e}Options`, []), n?.(`${e}CheckAll`, ""), i("");
|
|
56
57
|
},
|
|
57
|
-
[
|
|
58
|
-
),
|
|
59
|
-
(
|
|
60
|
-
const
|
|
61
|
-
n?.(`${
|
|
58
|
+
[A, e, i, n]
|
|
59
|
+
), M = k(
|
|
60
|
+
(r) => {
|
|
61
|
+
const t = r.target.value, p = j(h?.(`${e}Options`)), T = r.target.checked ? [...p, t] : p.filter((E) => E !== t);
|
|
62
|
+
n?.(`${e}Options`, T), b(T);
|
|
62
63
|
},
|
|
63
|
-
[
|
|
64
|
-
),
|
|
65
|
-
() =>
|
|
66
|
-
[
|
|
67
|
-
),
|
|
68
|
-
|
|
64
|
+
[e, n, h, b]
|
|
65
|
+
), S = h?.(`${e}Options`), v = f(
|
|
66
|
+
() => j(S),
|
|
67
|
+
[S]
|
|
68
|
+
), N = f(
|
|
69
|
+
() => v.includes(o.key.toString()),
|
|
70
|
+
[v, o.key]
|
|
71
|
+
), x = h?.(`${e}CheckAll`), P = f(() => !!x, [x]), R = o.key === "All" ? /* @__PURE__ */ l(
|
|
72
|
+
u,
|
|
69
73
|
{
|
|
70
|
-
checked:
|
|
74
|
+
checked: P,
|
|
71
75
|
label: o.rendered?.toString(),
|
|
72
|
-
name: `${
|
|
73
|
-
onChange:
|
|
76
|
+
name: `${e}CheckAll`,
|
|
77
|
+
onChange: K,
|
|
74
78
|
value: o.rendered?.toString()
|
|
75
79
|
}
|
|
76
|
-
) : /* @__PURE__ */
|
|
77
|
-
|
|
80
|
+
) : /* @__PURE__ */ l(
|
|
81
|
+
u,
|
|
78
82
|
{
|
|
79
|
-
checked:
|
|
83
|
+
checked: N,
|
|
80
84
|
label: o.rendered?.toString(),
|
|
81
|
-
name: `${
|
|
82
|
-
onChange:
|
|
85
|
+
name: `${e}Options`,
|
|
86
|
+
onChange: M,
|
|
83
87
|
value: o.key.toString()
|
|
84
88
|
}
|
|
85
|
-
),
|
|
86
|
-
|
|
89
|
+
), L = s && !O ? R : /* @__PURE__ */ l(
|
|
90
|
+
I,
|
|
87
91
|
{
|
|
88
|
-
color:
|
|
92
|
+
color: z.palette.gray[800],
|
|
89
93
|
size: "md",
|
|
90
94
|
textOverflow: "ellipsis",
|
|
91
95
|
whiteSpace: "nowrap",
|
|
92
96
|
children: o.rendered
|
|
93
97
|
}
|
|
94
|
-
),
|
|
95
|
-
(
|
|
96
|
-
|
|
98
|
+
), U = k(
|
|
99
|
+
(r) => {
|
|
100
|
+
r.preventDefault(), i(o.rendered?.toString() ?? ""), c.setSelectedKey(o.key), requestAnimationFrame(() => {
|
|
97
101
|
c.setOpen(!1);
|
|
98
|
-
}),
|
|
102
|
+
}), oo(d);
|
|
99
103
|
},
|
|
100
|
-
[
|
|
104
|
+
[d, o.key, o.rendered, c, i]
|
|
101
105
|
);
|
|
102
|
-
return
|
|
103
|
-
|
|
104
|
-
}, [
|
|
105
|
-
|
|
106
|
+
return V(w, () => {
|
|
107
|
+
s && c.close();
|
|
108
|
+
}, [D]), /* @__PURE__ */ G(
|
|
109
|
+
W,
|
|
106
110
|
{
|
|
107
|
-
...!
|
|
108
|
-
$multiSelection:
|
|
109
|
-
className:
|
|
110
|
-
ref:
|
|
111
|
+
...!s && !d ? F : {},
|
|
112
|
+
$multiSelection: s,
|
|
113
|
+
className: B,
|
|
114
|
+
ref: y,
|
|
111
115
|
children: [
|
|
112
|
-
|
|
113
|
-
$ && !
|
|
114
|
-
|
|
116
|
+
d ? /* @__PURE__ */ l(Z, { href: d, onClick: U, children: L }) : L,
|
|
117
|
+
$ && !O && !s ? /* @__PURE__ */ l(Y, { icon: "check", iconSize: "sm", iconType: "fa-light" }) : void 0,
|
|
118
|
+
C === void 0 ? void 0 : /* @__PURE__ */ l(_, { tagLabel: C, variant: "inactive" })
|
|
115
119
|
]
|
|
116
120
|
}
|
|
117
121
|
);
|
|
118
122
|
};
|
|
119
123
|
export {
|
|
120
|
-
|
|
124
|
+
Co as Option
|
|
121
125
|
};
|
|
@@ -28,6 +28,7 @@ interface IItem {
|
|
|
28
28
|
* @property { string } name - The name of the Select.
|
|
29
29
|
* @property { MutableRefObject } popoverRef - The ref of the options popover.
|
|
30
30
|
* @property { ComboBoxState<T> } state - The state of the ComboBox.
|
|
31
|
+
* @property { string } [tag] - Optional tag shown next to the option.
|
|
31
32
|
*/
|
|
32
33
|
interface IOptionProps<T> {
|
|
33
34
|
allItemKeys: string[];
|
|
@@ -39,6 +40,7 @@ interface IOptionProps<T> {
|
|
|
39
40
|
setInputValue: React.Dispatch<React.SetStateAction<string>>;
|
|
40
41
|
state: ComboBoxState<T>;
|
|
41
42
|
setValue?: UseFormSetValue<any>;
|
|
43
|
+
tag?: string;
|
|
42
44
|
watch?: UseFormWatch<any>;
|
|
43
45
|
}
|
|
44
46
|
/**
|
package/package.json
CHANGED