@payfit/unity-components 2.46.39 → 2.46.40
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/esm/components/multi-select/MultiSelect.d.ts +6 -1
- package/dist/esm/components/multi-select/MultiSelect.js +286 -238
- package/dist/esm/components/multi-select/Multiselect.context.d.ts +1 -1
- package/dist/esm/components/multi-select/MultiselectTypes.d.ts +5 -4
- package/dist/esm/components/multi-select/parts/MultiSelectOptGroup.d.ts +20 -13
- package/dist/esm/components/multi-select/parts/MultiSelectOptGroup.js +33 -22
- package/dist/esm/components/multi-select/parts/MultiSelectOption.d.ts +6 -3
- package/dist/esm/components/multi-select/parts/MultiSelectOption.js +51 -59
- package/dist/esm/components/multi-select/utils/selection-adapter.d.ts +5 -0
- package/dist/esm/components/multi-select/utils/selection-adapter.js +18 -0
- package/dist/esm/components/phone-number/PhoneNumberInput.js +38 -36
- package/dist/esm/components/select/Select.js +47 -44
- package/package.json +9 -9
- package/dist/esm/components/multi-select/hooks/use-combobox-filter.d.ts +0 -12
- package/dist/esm/components/multi-select/hooks/use-combobox-filter.js +0 -22
- package/dist/esm/components/multi-select/hooks/use-multiselection-state.d.ts +0 -14
- package/dist/esm/components/multi-select/hooks/use-multiselection-state.js +0 -47
- package/dist/esm/components/multi-select/parts/MultiSelectButton.d.ts +0 -18
- package/dist/esm/components/multi-select/parts/MultiSelectButton.js +0 -174
- package/dist/esm/components/multi-select/parts/MultiSelectPopover.d.ts +0 -7
- package/dist/esm/components/multi-select/parts/MultiSelectPopover.js +0 -65
- package/dist/esm/components/select/parts/SearchInput.d.ts +0 -5
- package/dist/esm/components/select/parts/SearchInput.js +0 -59
|
@@ -4,6 +4,11 @@ import { MultiSelectComponent } from './MultiselectTypes.js';
|
|
|
4
4
|
* The component provides two different APIs:
|
|
5
5
|
* 1. Static API - For simple cases where options are defined as direct children and use primitive values as keys (strings or numbers)
|
|
6
6
|
* 2. Dynamic API - For data-driven cases where options are generated from a dynamic collection with typed objects
|
|
7
|
+
*
|
|
8
|
+
* Selection is backed by React Aria and exposed as a Set of option keys. For dynamic options,
|
|
9
|
+
* the selected keys are resolved back to their original items before calling `renderValue`.
|
|
10
|
+
* Searchable multiselects use each option's `textValue` when provided, then fall back to
|
|
11
|
+
* string children for filtering and typeahead.
|
|
7
12
|
* @example
|
|
8
13
|
* ```tsx
|
|
9
14
|
* import { MultiSelect, MultiSelectOption, MultiSelectOptGroup } from '@payfit/unity-components'
|
|
@@ -44,7 +49,7 @@ import { MultiSelectComponent } from './MultiselectTypes.js';
|
|
|
44
49
|
* }
|
|
45
50
|
* >
|
|
46
51
|
* {(item) => (
|
|
47
|
-
* <MultiSelectOption value={item.id}>
|
|
52
|
+
* <MultiSelectOption value={item.id} textValue={item.name}>
|
|
48
53
|
* {item.name}
|
|
49
54
|
* </MultiSelectOption>
|
|
50
55
|
* )}
|
|
@@ -1,256 +1,304 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
1
|
+
import { jsx as r, jsxs as i } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as he, useRef as U, useState as W, useMemo as h, useCallback as l } from "react";
|
|
3
|
+
import { reactAriaValueToSet as ve, setToReactAriaDefaultValue as xe, setToReactAriaValue as Se } from "./utils/selection-adapter.js";
|
|
4
|
+
import { uyTv as we } from "@payfit/unity-themes";
|
|
5
|
+
import { useFilter as Ve, Autocomplete as Ce } from "react-aria-components/Autocomplete";
|
|
6
|
+
import { Button as Ie, ButtonContext as Me } from "react-aria-components/Button";
|
|
7
|
+
import { ListBox as q } from "react-aria-components/ListBox";
|
|
8
|
+
import { Popover as Oe } from "react-aria-components/Popover";
|
|
9
|
+
import { Select as Ne } from "react-aria-components/Select";
|
|
10
|
+
import { Separator as Pe } from "react-aria-components/Separator";
|
|
11
|
+
import { useIntl as Ae } from "react-intl";
|
|
12
|
+
import { Badge as Re } from "../badge/Badge.js";
|
|
13
|
+
import { CircularIconButton as Be } from "../icon-button/CircularIconButton.js";
|
|
14
|
+
import { Icon as H } from "../icon/Icon.js";
|
|
15
|
+
import { Search as De } from "../search/Search.js";
|
|
16
|
+
import { Spinner as je } from "../spinner/Spinner.js";
|
|
17
|
+
import { MultiSelectContext as Ee } from "./Multiselect.context.js";
|
|
18
|
+
const ze = we({
|
|
19
|
+
slots: {
|
|
20
|
+
root: "uy:relative uy:flex uy:flex-col uy:gap-100 uy:w-full",
|
|
21
|
+
trigger: "uy:relative uy:h-5.5 uy:sm:h-500 uy:flex uy:items-center uy:justify-between uy:py-125 uy:sm:py-100 uy:px-150 uy:w-full uy:border uy:border-solid uy:rounded-100 uy:sm:rounded-75 uy:focus-visible:outline-none uy:focus-visible:ring-2 uy:focus-visible:ring-utility-focus-ring uy:focus-visible:ring-offset-2 uy:active:not([disabled]):border-border-form-active uy:pointer-events-auto!",
|
|
22
|
+
inputValue: "uy:flex-1 uy:typography-body uy:text-left uy:line-clamp-1",
|
|
23
|
+
state: "uy:grow-0 uy:outline-none uy:typography-body uy:placeholder:text-content-neutral-lowest uy:inline-flex uy:gap-50 uy:items-center uy:px-100",
|
|
24
|
+
suffix: "uy:text-content-neutral-lowest",
|
|
25
|
+
clearButton: "uy:absolute uy:right-[36px] uy:top-1/2 uy:z-10 uy:-translate-y-1/2",
|
|
26
|
+
popover: "uy:shadow-300 uy:absolute uy:top-full uy:left-0 uy:z-50 uy:w-[var(--trigger-width)] uy:rounded-100 uy:sm:rounded-75 uy:border uy:border-solid uy:border-border-neutral uy:bg-surface-neutral uy:overflow-y-auto uy:overflow-x-hidden uy:max-h-[min(var(--popover-available-height,300px),300px)] uy:outline-none",
|
|
27
|
+
list: "uy:p-100 uy:overflow-y-auto uy:overflow-x-hidden"
|
|
28
|
+
},
|
|
29
|
+
variants: {
|
|
30
|
+
isDisabled: {
|
|
31
|
+
true: {
|
|
32
|
+
trigger: "uy:bg-surface-form-disabled uy:cursor-not-allowed uy:border-border-form-disabled uy:text-content-form-disabled",
|
|
33
|
+
inputValue: "uy:text-content-form-disabled!",
|
|
34
|
+
state: "uy:text-content-form-disabled",
|
|
35
|
+
suffix: "uy:text-content-form-disabled"
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
isReadOnly: {
|
|
39
|
+
true: {
|
|
40
|
+
trigger: "uy:bg-surface-form-disabled uy:cursor-not-allowed uy:border-border-form-disabled",
|
|
41
|
+
inputValue: "uy:text-content-form-disabled",
|
|
42
|
+
state: "uy:text-content-form-disabled",
|
|
43
|
+
suffix: "uy:text-content-form-disabled"
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
isInvalid: {
|
|
47
|
+
true: {
|
|
48
|
+
trigger: "uy:bg-surface-form-error uy:border-border-form-error",
|
|
49
|
+
inputValue: "uy:text-content-form-error",
|
|
50
|
+
state: "uy:text-content-form-error"
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
isEmpty: {
|
|
54
|
+
true: {
|
|
55
|
+
inputValue: "uy:text-content-neutral-lowest"
|
|
56
|
+
},
|
|
57
|
+
false: {
|
|
58
|
+
inputValue: "uy:text-content-form-enabled"
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
compoundVariants: [
|
|
63
|
+
{
|
|
64
|
+
isInvalid: !1,
|
|
65
|
+
isDisabled: !1,
|
|
66
|
+
isReadOnly: !1,
|
|
67
|
+
className: {
|
|
68
|
+
trigger: "uy:border-border-form-enabled uy:bg-surface-form-enabled",
|
|
69
|
+
inputValue: "uy:text-content-form-enabled uy:bg-surface-form-enabled",
|
|
70
|
+
state: "uy:text-content-neutral-disabled"
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
isEmpty: !0,
|
|
75
|
+
isDisabled: !1,
|
|
76
|
+
isReadOnly: !1,
|
|
77
|
+
isInvalid: !1,
|
|
78
|
+
className: {
|
|
79
|
+
inputValue: "uy:text-content-neutral-lowest"
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
]
|
|
83
|
+
});
|
|
84
|
+
function J(e) {
|
|
85
|
+
return e instanceof Map;
|
|
23
86
|
}
|
|
24
|
-
function
|
|
25
|
-
return
|
|
87
|
+
function ke(e) {
|
|
88
|
+
return !Object.prototype.hasOwnProperty.call(e, "items");
|
|
26
89
|
}
|
|
27
|
-
function
|
|
28
|
-
|
|
29
|
-
ref: C,
|
|
30
|
-
content: r,
|
|
31
|
-
typedRenderValue: A,
|
|
32
|
-
selectedItemsForDisplay: O
|
|
33
|
-
}) {
|
|
34
|
-
const K = ye(), P = pe(K, "open"), u = me(!1), {
|
|
35
|
-
placeholder: M,
|
|
36
|
-
isDisabled: c,
|
|
37
|
-
isReadOnly: y,
|
|
38
|
-
isLoading: p,
|
|
39
|
-
isInvalid: w,
|
|
40
|
-
onClearButtonPress: x,
|
|
41
|
-
onBlur: n,
|
|
42
|
-
onFocus: R,
|
|
43
|
-
...j
|
|
44
|
-
} = t, h = i(() => {
|
|
45
|
-
P || !u.current && n && (u.current = !0, n());
|
|
46
|
-
}, [P, n]), d = i(() => {
|
|
47
|
-
u.current = !1, R?.();
|
|
48
|
-
}, [R]), V = i(() => {
|
|
49
|
-
setTimeout(() => {
|
|
50
|
-
const S = document.activeElement, g = K?.getState().contentElement;
|
|
51
|
-
g && S !== g && !g.contains(S) && !u.current && n && (u.current = !0, n());
|
|
52
|
-
}, 0);
|
|
53
|
-
}, [n, K]);
|
|
54
|
-
return /* @__PURE__ */ ie(fe, { children: [
|
|
55
|
-
/* @__PURE__ */ f(
|
|
56
|
-
ge,
|
|
57
|
-
{
|
|
58
|
-
ref: C,
|
|
59
|
-
placeholder: M,
|
|
60
|
-
isDisabled: c,
|
|
61
|
-
isReadOnly: y,
|
|
62
|
-
isLoading: p,
|
|
63
|
-
isInvalid: w,
|
|
64
|
-
renderValue: A,
|
|
65
|
-
selectedItems: O,
|
|
66
|
-
onClearButtonPress: x,
|
|
67
|
-
onBlur: h,
|
|
68
|
-
onFocus: d,
|
|
69
|
-
...j
|
|
70
|
-
}
|
|
71
|
-
),
|
|
72
|
-
/* @__PURE__ */ f(ve, { onBlur: V, children: r })
|
|
73
|
-
] });
|
|
90
|
+
function Q(e) {
|
|
91
|
+
return typeof e == "object" && e !== null && "value" in e && (typeof e.value == "string" || typeof e.value == "number") ? e.value : typeof e == "object" && e !== null && "id" in e && (typeof e.id == "string" || typeof e.id == "number") ? e.id : typeof e == "string" || typeof e == "number" ? e : String(e);
|
|
74
92
|
}
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
isSearchable:
|
|
91
|
-
renderValue:
|
|
92
|
-
maxVisibleItems:
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}, [
|
|
97
|
-
(
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
93
|
+
const Le = (e) => Array.from(e).map(String).join(", "), Te = (e) => Array.from(e).map((v) => Q(v)).join(", ");
|
|
94
|
+
function Fe(e, v) {
|
|
95
|
+
const d = Ae(), X = U(null), Y = U(null), [Z, C] = W(!1), o = ke(e), I = e, M = e, {
|
|
96
|
+
placeholder: c,
|
|
97
|
+
isDisabled: f,
|
|
98
|
+
isReadOnly: u,
|
|
99
|
+
isLoading: O,
|
|
100
|
+
isInvalid: y,
|
|
101
|
+
onClearButtonPress: N,
|
|
102
|
+
onBlur: _,
|
|
103
|
+
onFocus: $,
|
|
104
|
+
onChange: P,
|
|
105
|
+
onOpenChange: A,
|
|
106
|
+
value: x,
|
|
107
|
+
defaultValue: R,
|
|
108
|
+
isSearchable: B,
|
|
109
|
+
renderValue: ee,
|
|
110
|
+
maxVisibleItems: m = 7,
|
|
111
|
+
children: S,
|
|
112
|
+
searchOptions: te,
|
|
113
|
+
...re
|
|
114
|
+
} = e, [D, oe] = W(() => new Set(R ?? [])), n = o ? void 0 : I.items, w = o ? void 0 : I.getItemValue, p = x !== void 0, a = h(
|
|
115
|
+
() => p ? new Set(x) : D,
|
|
116
|
+
[p, x, D]
|
|
117
|
+
), j = ee ?? (o ? Le : Te), E = l(
|
|
118
|
+
(t) => o || !w ? Q(t) : w(t),
|
|
119
|
+
[w, o]
|
|
120
|
+
), z = l(() => o || !n ? [] : J(n) ? Array.from(n.values()).flat() : Array.from(n), [n, o]), ne = h(() => {
|
|
121
|
+
if (o)
|
|
122
|
+
return new Set(a);
|
|
123
|
+
const t = z(), s = /* @__PURE__ */ new Set();
|
|
124
|
+
return a.forEach((V) => {
|
|
125
|
+
const K = t.find((ge) => E(ge) === V);
|
|
126
|
+
K && s.add(K);
|
|
127
|
+
}), s;
|
|
128
|
+
}, [z, o, E, a]), b = Array.from(ne), k = Math.max(
|
|
129
|
+
b.length - m,
|
|
130
|
+
0
|
|
131
|
+
), L = a.size > 0 && !f && !u && !O, {
|
|
132
|
+
root: ae,
|
|
133
|
+
trigger: le,
|
|
134
|
+
inputValue: se,
|
|
135
|
+
state: ue,
|
|
136
|
+
suffix: ie,
|
|
137
|
+
clearButton: de,
|
|
138
|
+
popover: ce,
|
|
139
|
+
list: T
|
|
140
|
+
} = ze({
|
|
141
|
+
isDisabled: !!f,
|
|
142
|
+
isReadOnly: !!u,
|
|
143
|
+
isInvalid: !!y,
|
|
144
|
+
isEmpty: a.size === 0
|
|
145
|
+
}), fe = h(() => {
|
|
146
|
+
if (b.length === 0) return c;
|
|
147
|
+
const t = b.slice(0, m), s = new Set(t);
|
|
148
|
+
return j(
|
|
149
|
+
s
|
|
150
|
+
);
|
|
151
|
+
}, [m, c, j, b]), g = l(
|
|
152
|
+
(t) => {
|
|
153
|
+
p || oe(t), P?.(t);
|
|
103
154
|
},
|
|
104
|
-
[
|
|
105
|
-
),
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
unselectKey: T
|
|
109
|
-
} = Ve({
|
|
110
|
-
selectedKeys: Z(),
|
|
111
|
-
defaultSelectedKeys: $(),
|
|
112
|
-
onSelectionChange: ee
|
|
113
|
-
}), te = i(
|
|
114
|
-
(e) => {
|
|
115
|
-
E(a(e));
|
|
155
|
+
[p, P]
|
|
156
|
+
), ye = l(
|
|
157
|
+
(t) => {
|
|
158
|
+
g(ve(t));
|
|
116
159
|
},
|
|
117
|
-
[
|
|
118
|
-
),
|
|
119
|
-
(
|
|
120
|
-
|
|
160
|
+
[g]
|
|
161
|
+
), me = l(() => {
|
|
162
|
+
g(/* @__PURE__ */ new Set()), N?.();
|
|
163
|
+
}, [N, g]), pe = l(
|
|
164
|
+
(t) => {
|
|
165
|
+
C(t), A?.(t);
|
|
121
166
|
},
|
|
122
|
-
[
|
|
123
|
-
),
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
return Array.from(m).map((o) => {
|
|
132
|
-
const s = e.find(
|
|
133
|
-
(l) => a(n(l)) === o
|
|
134
|
-
);
|
|
135
|
-
return s ? n(s) : b(o);
|
|
136
|
-
});
|
|
137
|
-
}, le = () => {
|
|
138
|
-
if (r)
|
|
139
|
-
return new Set(
|
|
140
|
-
Array.from(m).map((s) => b(s))
|
|
141
|
-
);
|
|
142
|
-
const e = v(), o = /* @__PURE__ */ new Set();
|
|
143
|
-
return Array.from(m).forEach((s) => {
|
|
144
|
-
const l = e.find(
|
|
145
|
-
(D) => a(n(D)) === s
|
|
146
|
-
);
|
|
147
|
-
l && o.add(l);
|
|
148
|
-
}), o;
|
|
149
|
-
}, se = () => {
|
|
150
|
-
if (d)
|
|
151
|
-
return X(d);
|
|
152
|
-
}, B = I(oe, [
|
|
153
|
-
m,
|
|
154
|
-
r,
|
|
155
|
-
n,
|
|
156
|
-
v
|
|
157
|
-
]), G = I(le, [
|
|
158
|
-
m,
|
|
159
|
-
r,
|
|
160
|
-
n,
|
|
161
|
-
v
|
|
162
|
-
]), L = I(se, [d]), _ = (e) => {
|
|
163
|
-
const o = new Set(e), s = new Set(B.map((l) => a(l)));
|
|
164
|
-
for (const l of o)
|
|
165
|
-
s.has(l) || te(b(l));
|
|
166
|
-
for (const l of s)
|
|
167
|
-
o.has(l) || re(b(l));
|
|
168
|
-
}, H = i(() => {
|
|
169
|
-
if (r)
|
|
170
|
-
return x;
|
|
171
|
-
if (!c) return null;
|
|
172
|
-
if (J(c)) {
|
|
173
|
-
const e = c;
|
|
174
|
-
return Array.from(e.entries()).map(
|
|
175
|
-
([o, s]) => {
|
|
176
|
-
const l = s.filter(
|
|
177
|
-
(D) => F.some((ue) => {
|
|
178
|
-
const ce = n(D), ae = n(ue);
|
|
179
|
-
return a(ae) === a(ce);
|
|
180
|
-
})
|
|
181
|
-
);
|
|
182
|
-
return p(o, l);
|
|
183
|
-
}
|
|
167
|
+
[C, A]
|
|
168
|
+
), F = l(() => {
|
|
169
|
+
if (o)
|
|
170
|
+
return M.children;
|
|
171
|
+
if (!n) return null;
|
|
172
|
+
if (J(n)) {
|
|
173
|
+
const t = n;
|
|
174
|
+
return Array.from(t.entries()).map(
|
|
175
|
+
([s, V]) => S(s, V)
|
|
184
176
|
);
|
|
185
177
|
}
|
|
186
|
-
return
|
|
187
|
-
(
|
|
178
|
+
return Array.from(n).map(
|
|
179
|
+
(t) => S(t)
|
|
188
180
|
);
|
|
189
|
-
}, [
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
F,
|
|
193
|
-
x,
|
|
194
|
-
n,
|
|
195
|
-
r
|
|
196
|
-
]), Q = I(() => H(), [H]), k = Y;
|
|
197
|
-
return S ? /* @__PURE__ */ f(Se, { resetValueOnHide: !0, setValue: ne, children: /* @__PURE__ */ f(
|
|
198
|
-
q,
|
|
181
|
+
}, [S, n, o, M.children]), G = h(() => F(), [F]), { contains: be } = Ve(te ?? { sensitivity: "base" });
|
|
182
|
+
return /* @__PURE__ */ r(
|
|
183
|
+
Ne,
|
|
199
184
|
{
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
),
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
185
|
+
...re,
|
|
186
|
+
ref: X,
|
|
187
|
+
className: ae(),
|
|
188
|
+
isDisabled: f || u,
|
|
189
|
+
isInvalid: y,
|
|
190
|
+
onBlur: _,
|
|
191
|
+
onChange: ye,
|
|
192
|
+
onFocus: $,
|
|
193
|
+
onOpenChange: pe,
|
|
194
|
+
placeholder: c,
|
|
195
|
+
selectionMode: "multiple",
|
|
196
|
+
shouldCloseOnSelect: !1,
|
|
197
|
+
value: Se(a),
|
|
198
|
+
defaultValue: xe(R),
|
|
199
|
+
allowsEmptyCollection: !0,
|
|
200
|
+
children: /* @__PURE__ */ i(
|
|
201
|
+
Ee.Provider,
|
|
208
202
|
{
|
|
209
|
-
value: { isSearchable:
|
|
210
|
-
children:
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
203
|
+
value: { isSearchable: B, maxVisibleItems: m, selectedKeys: a },
|
|
204
|
+
children: [
|
|
205
|
+
/* @__PURE__ */ i(
|
|
206
|
+
Ie,
|
|
207
|
+
{
|
|
208
|
+
ref: v,
|
|
209
|
+
className: le(),
|
|
210
|
+
"data-dd-privacy": "mask",
|
|
211
|
+
isDisabled: f || u,
|
|
212
|
+
"aria-invalid": y,
|
|
213
|
+
"aria-readonly": u,
|
|
214
|
+
children: [
|
|
215
|
+
/* @__PURE__ */ r("span", { className: se(), translate: "no", children: a.size > 0 ? fe : c }),
|
|
216
|
+
/* @__PURE__ */ i("span", { className: ue(), children: [
|
|
217
|
+
O && /* @__PURE__ */ r(
|
|
218
|
+
je,
|
|
219
|
+
{
|
|
220
|
+
color: "inherit",
|
|
221
|
+
size: "small",
|
|
222
|
+
label: d.formatMessage({
|
|
223
|
+
id: "unity:component:form-field:form-input:spinner:label",
|
|
224
|
+
defaultMessage: "Loading"
|
|
225
|
+
})
|
|
226
|
+
}
|
|
227
|
+
),
|
|
228
|
+
y && /* @__PURE__ */ r(
|
|
229
|
+
H,
|
|
230
|
+
{
|
|
231
|
+
src: "WarningCircleOutlined",
|
|
232
|
+
color: "content.form.invalid",
|
|
233
|
+
alt: d.formatMessage({
|
|
234
|
+
id: "unity:component:form-field:form-input:error:alt",
|
|
235
|
+
defaultMessage: "Error"
|
|
236
|
+
})
|
|
237
|
+
}
|
|
238
|
+
),
|
|
239
|
+
k > 0 && /* @__PURE__ */ i(Re, { variant: "numeric", children: [
|
|
240
|
+
"+",
|
|
241
|
+
k
|
|
242
|
+
] }),
|
|
243
|
+
L && /* @__PURE__ */ r("span", { className: "uy:w-300 uy:shrink-0", "aria-hidden": !0 })
|
|
244
|
+
] }),
|
|
245
|
+
/* @__PURE__ */ r(
|
|
246
|
+
H,
|
|
247
|
+
{
|
|
248
|
+
className: ie(),
|
|
249
|
+
src: Z ? "CaretUpOutlined" : "CaretDownOutlined",
|
|
250
|
+
role: "presentation"
|
|
251
|
+
}
|
|
252
|
+
)
|
|
253
|
+
]
|
|
254
|
+
}
|
|
255
|
+
),
|
|
256
|
+
L && /* @__PURE__ */ r(Me.Provider, { value: null, children: /* @__PURE__ */ r(
|
|
257
|
+
Be,
|
|
258
|
+
{
|
|
259
|
+
title: d.formatMessage({
|
|
260
|
+
id: "unity:component:common:clear:title",
|
|
261
|
+
defaultMessage: "Clear"
|
|
262
|
+
}),
|
|
263
|
+
className: de(),
|
|
264
|
+
icon: "CloseOutlined",
|
|
265
|
+
onPress: me,
|
|
266
|
+
asElement: "button"
|
|
267
|
+
}
|
|
268
|
+
) }),
|
|
269
|
+
/* @__PURE__ */ r(
|
|
270
|
+
Oe,
|
|
271
|
+
{
|
|
272
|
+
ref: Y,
|
|
273
|
+
offset: 1,
|
|
274
|
+
containerPadding: 8,
|
|
275
|
+
className: ce(),
|
|
276
|
+
children: B ? /* @__PURE__ */ i(Ce, { filter: be, children: [
|
|
277
|
+
/* @__PURE__ */ r("div", { className: "uy:m-100", children: /* @__PURE__ */ r(
|
|
278
|
+
De,
|
|
279
|
+
{
|
|
280
|
+
label: d.formatMessage({
|
|
281
|
+
id: "unity:component:select:search:label",
|
|
282
|
+
defaultMessage: "Search options"
|
|
283
|
+
}),
|
|
284
|
+
"data-dd-privacy": "mask"
|
|
285
|
+
}
|
|
286
|
+
) }),
|
|
287
|
+
/* @__PURE__ */ r(Pe, { className: "uy:mx-100 uy:border-t uy:border-border-neutral uy:border-solid" }),
|
|
288
|
+
/* @__PURE__ */ r(q, { className: T(), children: G })
|
|
289
|
+
] }) : /* @__PURE__ */ r(q, { className: T(), children: G })
|
|
290
|
+
}
|
|
291
|
+
)
|
|
292
|
+
]
|
|
246
293
|
}
|
|
247
294
|
)
|
|
248
295
|
}
|
|
249
296
|
);
|
|
250
|
-
}
|
|
251
|
-
|
|
297
|
+
}
|
|
298
|
+
const Ge = he(
|
|
299
|
+
Fe
|
|
252
300
|
);
|
|
253
|
-
|
|
301
|
+
Ge.displayName = "MultiSelect";
|
|
254
302
|
export {
|
|
255
|
-
|
|
303
|
+
Ge as MultiSelect
|
|
256
304
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
interface MultiSelectContextType {
|
|
2
2
|
isSearchable?: boolean;
|
|
3
3
|
maxVisibleItems?: number;
|
|
4
|
-
selectedKeys?: Set<string>;
|
|
4
|
+
selectedKeys?: Set<string | number>;
|
|
5
5
|
}
|
|
6
6
|
export declare const MultiSelectContext: import('react').Context<MultiSelectContextType>;
|
|
7
7
|
export {};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { UseComboboxFilterProps } from './hooks/use-combobox-filter.js';
|
|
2
1
|
type Key = string | number;
|
|
3
2
|
/**
|
|
4
3
|
* Common props shared by all MultiSelect variants.
|
|
@@ -26,6 +25,8 @@ export interface MultiSelectBaseProps {
|
|
|
26
25
|
onFocus?: () => void;
|
|
27
26
|
/** Callback when the select is blurred */
|
|
28
27
|
onBlur?: () => void;
|
|
28
|
+
/** Callback triggered when the select popover changes its open state */
|
|
29
|
+
onOpenChange?: (isOpen: boolean) => void;
|
|
29
30
|
/** The ID of the element that labels this select when no visible label is provided */
|
|
30
31
|
'aria-labelledby'?: string;
|
|
31
32
|
/** The ID of the element that labels this select when no visible label is provided */
|
|
@@ -49,7 +50,7 @@ export interface FlatSelectProps<TItems extends Set<unknown>> extends MultiSelec
|
|
|
49
50
|
renderValue?: (value: Set<TItems extends Set<infer U> ? U : never>) => string;
|
|
50
51
|
/** Children must be a render function that returns Option components */ children: (item: TItems extends Set<infer U> ? U : never) => React.JSX.Element;
|
|
51
52
|
/** Options for filtering the items */
|
|
52
|
-
searchOptions?:
|
|
53
|
+
searchOptions?: Intl.CollatorOptions;
|
|
53
54
|
}
|
|
54
55
|
/**
|
|
55
56
|
* Props for grouped dynamic items MultiSelect.
|
|
@@ -71,7 +72,7 @@ export interface GroupedSelectProps<TItems extends Map<string, unknown[]>> exten
|
|
|
71
72
|
/** Children must be a render function that returns OptGroup components */
|
|
72
73
|
children: (groupKey: string, items: TItems extends Map<string, Array<infer U>> ? U[] : never) => React.JSX.Element;
|
|
73
74
|
/** Options for filtering the items */
|
|
74
|
-
searchOptions?:
|
|
75
|
+
searchOptions?: Intl.CollatorOptions;
|
|
75
76
|
}
|
|
76
77
|
/**
|
|
77
78
|
* Props for static MultiSelect API (all items are defined via React children).
|
|
@@ -92,7 +93,7 @@ export interface StaticItemsProps<TItem = Key> extends MultiSelectBaseProps {
|
|
|
92
93
|
/** Children must be Option components */
|
|
93
94
|
children: React.ReactNode;
|
|
94
95
|
/** Options for filtering the items */
|
|
95
|
-
searchOptions?:
|
|
96
|
+
searchOptions?: Intl.CollatorOptions;
|
|
96
97
|
}
|
|
97
98
|
/**
|
|
98
99
|
* Helper type to simplify usage for dynamic MultiSelect props.
|