@payfit/unity-components 1.1.0 → 1.2.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/esm/adapters/standardSchemaAdapter.d.ts +7 -0
- package/dist/esm/adapters/standardSchemaAdapter.js +20 -0
- package/dist/esm/adapters/zodAdapter.d.ts +13 -0
- package/dist/esm/adapters/zodAdapter.js +74 -0
- package/dist/esm/components/action-bar/ActionBar.js +62 -64
- package/dist/esm/components/actionable/Actionable.d.ts +50 -3
- package/dist/esm/components/actionable/Actionable.js +49 -39
- package/dist/esm/components/app-menu/parts/AppMenuFooter.js +63 -63
- package/dist/esm/components/autocomplete/parts/AutocompleteClearButton.js +5 -5
- package/dist/esm/components/bottom-sheet/parts/BottomSheetDragIndicator.js +30 -31
- package/dist/esm/components/checkbox-field/CheckboxField.d.ts +2 -2
- package/dist/esm/components/checkbox-field/CheckboxField.js +18 -17
- package/dist/esm/components/checkbox-group-field/CheckboxGroupField.d.ts +2 -2
- package/dist/esm/components/checkbox-group-field/CheckboxGroupField.js +4 -1
- package/dist/esm/components/code/Code.d.ts +37 -0
- package/dist/esm/components/code/Code.js +39 -0
- package/dist/esm/components/code/copyToClipboard.d.ts +1 -0
- package/dist/esm/components/code/copyToClipboard.js +10 -0
- package/dist/esm/components/collapsible/Collapsible.d.ts +1 -1
- package/dist/esm/components/collapsible/Collapsible.js +14 -13
- package/dist/esm/components/collapsible/parts/CollapsibleTitle.js +7 -7
- package/dist/esm/components/data-table/DataTable.d.ts +76 -10
- package/dist/esm/components/data-table/DataTable.js +81 -78
- package/dist/esm/components/data-table/parts/ColumnSortHeader.js +13 -13
- package/dist/esm/components/data-table/parts/DataTableBulkActions.js +20 -20
- package/dist/esm/components/date-calendar/DateCalendar.js +52 -52
- package/dist/esm/components/date-calendar/parts/DateSegmentSelect.js +30 -33
- package/dist/esm/components/date-picker/DatePicker.js +64 -64
- package/dist/esm/components/date-picker/parts/DateInput.js +33 -33
- package/dist/esm/components/date-picker-field/DatePickerField.d.ts +2 -2
- package/dist/esm/components/dialog/parts/DialogActions/DialogButton.js +12 -12
- package/dist/esm/components/error-state/ErrorState.d.ts +196 -0
- package/dist/esm/components/error-state/ErrorState.js +153 -0
- package/dist/esm/components/error-state/initConfig.d.ts +16 -0
- package/dist/esm/components/error-state/initConfig.js +149 -0
- package/dist/esm/components/error-state/parts/Collapsible.d.ts +59 -0
- package/dist/esm/components/error-state/parts/Collapsible.js +67 -0
- package/dist/esm/components/form/Form.d.ts +15 -9
- package/dist/esm/components/form/Form.js +53 -50
- package/dist/esm/components/form-field/FormField.js +24 -23
- package/dist/esm/components/form-field/utils/isFieldRequired.d.ts +4 -4
- package/dist/esm/components/form-field/utils/isFieldRequired.js +5 -20
- package/dist/esm/components/funnel-layout/FunnelLayout.d.ts +1 -1
- package/dist/esm/components/funnel-layout/FunnelLayout.js +61 -110
- package/dist/esm/components/funnel-layout/parts/FunnelPage.js +8 -9
- package/dist/esm/components/funnel-layout/parts/FunnelPageActions.js +24 -24
- package/dist/esm/components/funnel-layout/parts/FunnelPageFooter.js +6 -7
- package/dist/esm/components/funnel-layout/parts/FunnelPageHeader.d.ts +2 -2
- package/dist/esm/components/funnel-layout/parts/FunnelSidebar.d.ts +2 -2
- package/dist/esm/components/funnel-layout/parts/FunnelSidebar.js +9 -10
- package/dist/esm/components/funnel-layout/parts/FunnelTopBar.js +0 -1
- package/dist/esm/components/input/Input.js +28 -28
- package/dist/esm/components/label/Label.js +19 -19
- package/dist/esm/components/multi-select/MultiSelect.js +94 -94
- package/dist/esm/components/multi-select/hooks/use-multiselection-state.js +32 -32
- package/dist/esm/components/multi-select/parts/MultiSelectButton.js +38 -38
- package/dist/esm/components/multi-select/parts/MultiSelectPopover.js +16 -16
- package/dist/esm/components/multi-select-field/MultiSelectField.d.ts +2 -2
- package/dist/esm/components/multi-select-field/MultiSelectField.js +53 -53
- package/dist/esm/components/nav/parts/NavGroup.js +21 -21
- package/dist/esm/components/number-field/NumberField.d.ts +3 -3
- package/dist/esm/components/number-input/NumberInput.js +58 -58
- package/dist/esm/components/pagination/Pagination.js +97 -101
- package/dist/esm/components/pagination/parts/PaginationJumpDialog.js +39 -40
- package/dist/esm/components/popover/parts/PopoverHeader.js +8 -8
- package/dist/esm/components/radio-button-group/parts/RadioButton.js +11 -11
- package/dist/esm/components/select-field/SelectField.d.ts +2 -2
- package/dist/esm/components/select-field/SelectField.js +4 -1
- package/dist/esm/components/selectable-button-group/SelectableButtonGroup.js +22 -23
- package/dist/esm/components/selectable-button-group-field/SelectableButtonGroupField.d.ts +2 -2
- package/dist/esm/components/side-panel/parts/SidePanelDragIndicator.js +30 -31
- package/dist/esm/components/skip-links/SkipLinks.js +50 -43
- package/dist/esm/components/table/Table.js +79 -76
- package/dist/esm/components/table/parts/TableBody.js +6 -6
- package/dist/esm/components/table/parts/TableCell.js +25 -25
- package/dist/esm/components/table/parts/TableColumnHeader.js +38 -38
- package/dist/esm/components/table/parts/TablePagination.js +61 -59
- package/dist/esm/components/table/parts/TableRow.js +16 -16
- package/dist/esm/components/tabs/parts/TabList.js +50 -54
- package/dist/esm/components/task-menu/parts/Content.js +24 -24
- package/dist/esm/components/task-menu/parts/Header.js +24 -24
- package/dist/esm/components/task-menu/parts/SubTask.js +74 -74
- package/dist/esm/components/task-menu/parts/Task.js +69 -69
- package/dist/esm/components/task-menu/parts/TaskGroup.js +45 -45
- package/dist/esm/components/text-area/TextArea.js +30 -31
- package/dist/esm/components/text-field/TextField.d.ts +2 -2
- package/dist/esm/components/toggle-switch-field/ToggleSwitchField.d.ts +2 -2
- package/dist/esm/components/toggle-switch-field/ToggleSwitchField.js +4 -1
- package/dist/esm/components/toggle-switch-group/ToggleSwitchGroup.js +74 -74
- package/dist/esm/components/toggle-switch-group-field/ToggleSwitchGroupField.d.ts +2 -2
- package/dist/esm/components/toggle-switch-group-field/ToggleSwitchGroupField.js +36 -32
- package/dist/esm/hooks/use-form.d.ts +5 -5
- package/dist/esm/hooks/use-form.types.d.ts +2 -2
- package/dist/esm/hooks/use-resizable.js +13 -14
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +22 -19
- package/dist/esm/types/schema.d.ts +8 -0
- package/dist/esm/utils/createSchemaAdapter.d.ts +7 -0
- package/dist/esm/utils/createSchemaAdapter.js +13 -0
- package/dist/esm/utils/platform.js +2 -3
- package/i18n/en-GB.json +16 -0
- package/i18n/es-ES.json +16 -0
- package/i18n/fr-FR.json +16 -0
- package/package.json +25 -19
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as i, jsxs as q } from "react/jsx-runtime";
|
|
2
2
|
import { forwardRef as Se, useMemo as S, useCallback as d } from "react";
|
|
3
3
|
import { ComboboxProvider as pe, SelectProvider as z } from "@ariakit/react";
|
|
4
4
|
import { useComboboxFilter as he } from "./hooks/use-combobox-filter.js";
|
|
5
|
-
import { useMultiSelectionState as
|
|
5
|
+
import { useMultiSelectionState as Ve } from "./hooks/use-multiselection-state.js";
|
|
6
6
|
import { MultiSelectContext as J } from "./Multiselect.context.js";
|
|
7
7
|
import { MultiSelectButton as U } from "./parts/MultiSelectButton.js";
|
|
8
8
|
import { MultiSelectPopover as W } from "./parts/MultiSelectPopover.js";
|
|
9
9
|
function X(t) {
|
|
10
10
|
return t instanceof Map;
|
|
11
11
|
}
|
|
12
|
-
function
|
|
12
|
+
function ge(t) {
|
|
13
13
|
return !Object.prototype.hasOwnProperty.call(t, "items");
|
|
14
14
|
}
|
|
15
15
|
function a(t) {
|
|
@@ -24,59 +24,59 @@ function Z(t) {
|
|
|
24
24
|
function Y(t) {
|
|
25
25
|
return new Set(Z(t));
|
|
26
26
|
}
|
|
27
|
-
const $ = (t,
|
|
28
|
-
const
|
|
27
|
+
const $ = (t, P) => {
|
|
28
|
+
const n = ge(t), A = (e) => {
|
|
29
29
|
if (Object.hasOwnProperty.call(e, "value"))
|
|
30
30
|
return e.value;
|
|
31
31
|
if (Object.prototype.hasOwnProperty.call(e, "id"))
|
|
32
32
|
return e.id;
|
|
33
33
|
if (typeof e == "string")
|
|
34
34
|
return e;
|
|
35
|
-
const
|
|
36
|
-
return e[
|
|
37
|
-
}, ee =
|
|
38
|
-
() =>
|
|
39
|
-
[
|
|
40
|
-
),
|
|
35
|
+
const r = Object.keys(e)[0];
|
|
36
|
+
return e[r];
|
|
37
|
+
}, ee = n ? (e) => Array.from(e).map(String).join(", ") : (e) => Array.from(e).map((r) => A(r)).join(", "), m = t, w = t, c = S(
|
|
38
|
+
() => n ? void 0 : m.items,
|
|
39
|
+
[n, m.items]
|
|
40
|
+
), s = n ? void 0 : m.getItemValue ?? A, { children: V } = n ? w : m, te = n ? void 0 : m.searchOptions, { children: C } = w, {
|
|
41
41
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
42
|
-
children:
|
|
42
|
+
children: be,
|
|
43
43
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
44
|
-
getItemValue:
|
|
45
|
-
value:
|
|
44
|
+
getItemValue: Ke,
|
|
45
|
+
value: g,
|
|
46
46
|
defaultValue: f,
|
|
47
|
-
onChange:
|
|
48
|
-
onBlur:
|
|
49
|
-
isDisabled:
|
|
50
|
-
isInvalid:
|
|
51
|
-
isLoading:
|
|
52
|
-
isReadOnly:
|
|
47
|
+
onChange: v,
|
|
48
|
+
onBlur: O,
|
|
49
|
+
isDisabled: M,
|
|
50
|
+
isInvalid: x,
|
|
51
|
+
isLoading: j,
|
|
52
|
+
isReadOnly: D,
|
|
53
53
|
isSearchable: h,
|
|
54
54
|
placeholder: R,
|
|
55
55
|
onClearButtonPress: F,
|
|
56
56
|
renderValue: re,
|
|
57
57
|
maxVisibleItems: N = 7,
|
|
58
58
|
...B
|
|
59
|
-
} = t, ne = re ?? ee, y = d(() =>
|
|
59
|
+
} = t, ne = re ?? ee, y = d(() => n || !c ? [] : X(c) ? Array.from(c.values()).flat() : Array.from(c), [c, n]), oe = d(() => {
|
|
60
60
|
if ("value" in t)
|
|
61
|
-
return
|
|
62
|
-
}, [t,
|
|
61
|
+
return g ? Y(g) : /* @__PURE__ */ new Set();
|
|
62
|
+
}, [t, g]), le = d(() => f ? Y(f) : /* @__PURE__ */ new Set(), [f]), ae = d(
|
|
63
63
|
(e) => {
|
|
64
|
-
if (!
|
|
65
|
-
const
|
|
64
|
+
if (!v) return;
|
|
65
|
+
const r = new Set(
|
|
66
66
|
Array.from(e).map((l) => p(l))
|
|
67
67
|
);
|
|
68
|
-
|
|
68
|
+
v(r);
|
|
69
69
|
},
|
|
70
|
-
[
|
|
70
|
+
[v]
|
|
71
71
|
), {
|
|
72
|
-
selectedKeys:
|
|
72
|
+
selectedKeys: u,
|
|
73
73
|
selectKey: L,
|
|
74
74
|
unselectKey: T
|
|
75
|
-
} =
|
|
75
|
+
} = Ve({
|
|
76
76
|
selectedKeys: oe(),
|
|
77
|
-
defaultSelectedKeys:
|
|
78
|
-
onSelectionChange:
|
|
79
|
-
}),
|
|
77
|
+
defaultSelectedKeys: le(),
|
|
78
|
+
onSelectionChange: ae
|
|
79
|
+
}), se = d(
|
|
80
80
|
(e) => {
|
|
81
81
|
L(a(e));
|
|
82
82
|
},
|
|
@@ -86,78 +86,78 @@ const $ = (t, g) => {
|
|
|
86
86
|
T(a(e));
|
|
87
87
|
},
|
|
88
88
|
[T]
|
|
89
|
-
), { setSearchQuery:
|
|
89
|
+
), { setSearchQuery: ue, matchingItems: I } = he({
|
|
90
90
|
items: y(),
|
|
91
|
-
extractSearchableText: (e) =>
|
|
91
|
+
extractSearchableText: (e) => n ? [""] : [
|
|
92
92
|
a(
|
|
93
|
-
(
|
|
93
|
+
s?.(e) || ""
|
|
94
94
|
)
|
|
95
95
|
],
|
|
96
96
|
enabled: h,
|
|
97
97
|
searchOptions: te
|
|
98
|
-
}),
|
|
99
|
-
if (
|
|
98
|
+
}), ie = () => {
|
|
99
|
+
if (n) return Array.from(u);
|
|
100
100
|
const e = y();
|
|
101
|
-
return Array.from(
|
|
101
|
+
return Array.from(u).map((r) => {
|
|
102
102
|
const l = e.find(
|
|
103
|
-
(
|
|
104
|
-
(
|
|
105
|
-
) ===
|
|
103
|
+
(o) => a(
|
|
104
|
+
s?.(o) || ""
|
|
105
|
+
) === r
|
|
106
106
|
);
|
|
107
|
-
return l &&
|
|
107
|
+
return l && s ? s(l) : p(r);
|
|
108
108
|
});
|
|
109
109
|
}, de = () => {
|
|
110
|
-
if (
|
|
110
|
+
if (n)
|
|
111
111
|
return new Set(
|
|
112
|
-
Array.from(
|
|
112
|
+
Array.from(u).map((l) => p(l))
|
|
113
113
|
);
|
|
114
|
-
const e = y(),
|
|
115
|
-
return Array.from(
|
|
116
|
-
const
|
|
117
|
-
(
|
|
118
|
-
(
|
|
114
|
+
const e = y(), r = /* @__PURE__ */ new Set();
|
|
115
|
+
return Array.from(u).forEach((l) => {
|
|
116
|
+
const o = e.find(
|
|
117
|
+
(K) => a(
|
|
118
|
+
s?.(K) || ""
|
|
119
119
|
) === l
|
|
120
120
|
);
|
|
121
|
-
|
|
122
|
-
}),
|
|
121
|
+
o && r.add(o);
|
|
122
|
+
}), r;
|
|
123
123
|
}, fe = () => {
|
|
124
124
|
if (f)
|
|
125
125
|
return Z(f);
|
|
126
|
-
},
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
126
|
+
}, b = S(ie, [
|
|
127
|
+
u,
|
|
128
|
+
n,
|
|
129
|
+
s,
|
|
130
130
|
y
|
|
131
131
|
]), _ = S(de, [
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
132
|
+
u,
|
|
133
|
+
n,
|
|
134
|
+
s,
|
|
135
135
|
y
|
|
136
136
|
]), G = S(fe, [f]), k = (e) => {
|
|
137
|
-
const
|
|
138
|
-
|
|
137
|
+
const r = new Set(e), l = new Set(
|
|
138
|
+
b.map((o) => a(o))
|
|
139
139
|
);
|
|
140
|
-
for (const
|
|
141
|
-
l.has(
|
|
142
|
-
for (const
|
|
143
|
-
|
|
144
|
-
}, E = d(() =>
|
|
145
|
-
const l =
|
|
146
|
-
(
|
|
147
|
-
const me = (
|
|
140
|
+
for (const o of r)
|
|
141
|
+
l.has(o) || se(p(o));
|
|
142
|
+
for (const o of l)
|
|
143
|
+
r.has(o) || ce(p(o));
|
|
144
|
+
}, E = d(() => n ? C : c ? X(c) ? Array.from(c.entries()).map(([e, r]) => {
|
|
145
|
+
const l = r.filter(
|
|
146
|
+
(o) => I.some((K) => {
|
|
147
|
+
const me = s?.(o) || "", ye = s?.(K) || "";
|
|
148
148
|
return a(ye) === a(me);
|
|
149
149
|
})
|
|
150
150
|
);
|
|
151
|
-
return
|
|
152
|
-
}) :
|
|
153
|
-
(e) =>
|
|
151
|
+
return V(e, l);
|
|
152
|
+
}) : I.map(
|
|
153
|
+
(e) => V(
|
|
154
154
|
e
|
|
155
155
|
)
|
|
156
|
-
) : null, [
|
|
157
|
-
return h ? /* @__PURE__ */
|
|
156
|
+
) : null, [V, c, I, C, s, n]), H = S(() => E(), [E]), Q = ne;
|
|
157
|
+
return h ? /* @__PURE__ */ i(pe, { resetValueOnHide: !0, setValue: ue, children: /* @__PURE__ */ i(
|
|
158
158
|
z,
|
|
159
159
|
{
|
|
160
|
-
value:
|
|
160
|
+
value: b.map(
|
|
161
161
|
(e) => a(e)
|
|
162
162
|
),
|
|
163
163
|
defaultValue: G,
|
|
@@ -166,32 +166,32 @@ const $ = (t, g) => {
|
|
|
166
166
|
children: /* @__PURE__ */ q(
|
|
167
167
|
J.Provider,
|
|
168
168
|
{
|
|
169
|
-
value: { isSearchable: h, maxVisibleItems: N, selectedKeys:
|
|
169
|
+
value: { isSearchable: h, maxVisibleItems: N, selectedKeys: u },
|
|
170
170
|
children: [
|
|
171
|
-
/* @__PURE__ */
|
|
171
|
+
/* @__PURE__ */ i(
|
|
172
172
|
U,
|
|
173
173
|
{
|
|
174
|
-
ref:
|
|
174
|
+
ref: P,
|
|
175
175
|
placeholder: R,
|
|
176
|
-
isDisabled:
|
|
177
|
-
isReadOnly:
|
|
178
|
-
isLoading:
|
|
179
|
-
isInvalid:
|
|
176
|
+
isDisabled: M,
|
|
177
|
+
isReadOnly: D,
|
|
178
|
+
isLoading: j,
|
|
179
|
+
isInvalid: x,
|
|
180
180
|
renderValue: Q,
|
|
181
181
|
selectedItems: _,
|
|
182
182
|
onClearButtonPress: F,
|
|
183
183
|
...B
|
|
184
184
|
}
|
|
185
185
|
),
|
|
186
|
-
/* @__PURE__ */
|
|
186
|
+
/* @__PURE__ */ i(W, { onBlur: O, children: H })
|
|
187
187
|
]
|
|
188
188
|
}
|
|
189
189
|
)
|
|
190
190
|
}
|
|
191
|
-
) }) : /* @__PURE__ */
|
|
191
|
+
) }) : /* @__PURE__ */ i(
|
|
192
192
|
z,
|
|
193
193
|
{
|
|
194
|
-
value:
|
|
194
|
+
value: b.map(
|
|
195
195
|
(e) => a(e)
|
|
196
196
|
),
|
|
197
197
|
defaultValue: G,
|
|
@@ -200,24 +200,24 @@ const $ = (t, g) => {
|
|
|
200
200
|
children: /* @__PURE__ */ q(
|
|
201
201
|
J.Provider,
|
|
202
202
|
{
|
|
203
|
-
value: { isSearchable: h, maxVisibleItems: N, selectedKeys:
|
|
203
|
+
value: { isSearchable: h, maxVisibleItems: N, selectedKeys: u },
|
|
204
204
|
children: [
|
|
205
|
-
/* @__PURE__ */
|
|
205
|
+
/* @__PURE__ */ i(
|
|
206
206
|
U,
|
|
207
207
|
{
|
|
208
|
-
ref:
|
|
208
|
+
ref: P,
|
|
209
209
|
placeholder: R,
|
|
210
|
-
isDisabled:
|
|
211
|
-
isReadOnly:
|
|
212
|
-
isLoading:
|
|
213
|
-
isInvalid:
|
|
210
|
+
isDisabled: M,
|
|
211
|
+
isReadOnly: D,
|
|
212
|
+
isLoading: j,
|
|
213
|
+
isInvalid: x,
|
|
214
214
|
renderValue: Q,
|
|
215
215
|
selectedItems: _,
|
|
216
216
|
onClearButtonPress: F,
|
|
217
217
|
...B
|
|
218
218
|
}
|
|
219
219
|
),
|
|
220
|
-
/* @__PURE__ */
|
|
220
|
+
/* @__PURE__ */ i(W, { onBlur: O, children: H })
|
|
221
221
|
]
|
|
222
222
|
}
|
|
223
223
|
)
|
|
@@ -225,9 +225,9 @@ const $ = (t, g) => {
|
|
|
225
225
|
);
|
|
226
226
|
};
|
|
227
227
|
$.displayName = "MultiSelect";
|
|
228
|
-
const
|
|
228
|
+
const De = Se(
|
|
229
229
|
$
|
|
230
230
|
);
|
|
231
231
|
export {
|
|
232
|
-
|
|
232
|
+
De as MultiSelect
|
|
233
233
|
};
|
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
import { useState as
|
|
2
|
-
function
|
|
3
|
-
selectedKeys:
|
|
4
|
-
defaultSelectedKeys:
|
|
5
|
-
onSelectionChange:
|
|
1
|
+
import { useState as w } from "react";
|
|
2
|
+
function a({
|
|
3
|
+
selectedKeys: c,
|
|
4
|
+
defaultSelectedKeys: K,
|
|
5
|
+
onSelectionChange: d
|
|
6
6
|
}) {
|
|
7
|
-
const [
|
|
8
|
-
() =>
|
|
9
|
-
),
|
|
7
|
+
const [u, r] = w(
|
|
8
|
+
() => K ?? /* @__PURE__ */ new Set()
|
|
9
|
+
), n = c !== void 0, l = n ? c : u;
|
|
10
10
|
return {
|
|
11
|
-
selectedKeys:
|
|
12
|
-
isSelected: (
|
|
13
|
-
selectKey: (
|
|
14
|
-
if (
|
|
15
|
-
const
|
|
16
|
-
|
|
11
|
+
selectedKeys: l,
|
|
12
|
+
isSelected: (t) => l.has(t),
|
|
13
|
+
selectKey: (t) => {
|
|
14
|
+
if (n && d) {
|
|
15
|
+
const e = new Set(l);
|
|
16
|
+
e.add(t), d(e);
|
|
17
17
|
} else
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
return
|
|
18
|
+
r((e) => {
|
|
19
|
+
const s = new Set(e);
|
|
20
|
+
return s.add(t), d?.(s), s;
|
|
21
21
|
});
|
|
22
22
|
},
|
|
23
|
-
unselectKey: (
|
|
24
|
-
if (
|
|
25
|
-
const
|
|
26
|
-
|
|
23
|
+
unselectKey: (t) => {
|
|
24
|
+
if (n && d) {
|
|
25
|
+
const e = new Set(l);
|
|
26
|
+
e.delete(t), d(e);
|
|
27
27
|
} else
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
return
|
|
28
|
+
r((e) => {
|
|
29
|
+
const s = new Set(e);
|
|
30
|
+
return s.delete(t), d?.(s), s;
|
|
31
31
|
});
|
|
32
32
|
},
|
|
33
|
-
toggleKey: (
|
|
34
|
-
if (
|
|
35
|
-
const
|
|
36
|
-
|
|
33
|
+
toggleKey: (t) => {
|
|
34
|
+
if (n && d) {
|
|
35
|
+
const e = new Set(l);
|
|
36
|
+
e.has(t) ? e.delete(t) : e.add(t), d(e);
|
|
37
37
|
} else
|
|
38
|
-
|
|
39
|
-
const
|
|
40
|
-
return
|
|
38
|
+
r((e) => {
|
|
39
|
+
const s = new Set(e);
|
|
40
|
+
return s.has(t) ? s.delete(t) : s.add(t), d?.(s), s;
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
45
|
export {
|
|
46
|
-
|
|
46
|
+
a as useMultiSelectionState
|
|
47
47
|
};
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as i, jsx as e } from "react/jsx-runtime";
|
|
2
2
|
import { memo as j, forwardRef as E, useContext as k, useMemo as A } from "react";
|
|
3
3
|
import { useSelectContext as D, useStoreState as K, Select as $ } from "@ariakit/react";
|
|
4
4
|
import { uyTv as L } from "@payfit/unity-themes";
|
|
5
|
-
import { useId as
|
|
6
|
-
import { useIntl as
|
|
7
|
-
import { Badge as
|
|
8
|
-
import { CircularIconButton as
|
|
9
|
-
import { Icon as
|
|
10
|
-
import { Spinner as
|
|
11
|
-
import { MultiSelectContext as
|
|
12
|
-
const
|
|
5
|
+
import { useId as P } from "react-aria";
|
|
6
|
+
import { useIntl as R } from "react-intl";
|
|
7
|
+
import { Badge as T } from "../../badge/Badge.js";
|
|
8
|
+
import { CircularIconButton as U } from "../../icon-button/CircularIconButton.js";
|
|
9
|
+
import { Icon as b } from "../../icon/Icon.js";
|
|
10
|
+
import { Spinner as W } from "../../spinner/Spinner.js";
|
|
11
|
+
import { MultiSelectContext as q } from "../Multiselect.context.js";
|
|
12
|
+
const F = L({
|
|
13
13
|
slots: {
|
|
14
14
|
base: "uy:h-500 uy:flex uy:items-center uy:justify-between uy:py-100 uy:px-150 uy:w-full uy:border uy:border-solid uy:rounded-75 uy:focus-within:outline-none uy:focus-within:ring-2 uy:focus-within:ring-utility-focus-ring uy:focus-within:ring-offset-2 uy:active:not([disabled]):border-border-form-active uy:pointer-events-auto!",
|
|
15
15
|
inputValue: "uy:flex-1 uy:typography-body uy:text-content-form-enabled uy:text-left uy:line-clamp-1",
|
|
@@ -61,46 +61,46 @@ const G = L({
|
|
|
61
61
|
}
|
|
62
62
|
]
|
|
63
63
|
});
|
|
64
|
-
function
|
|
64
|
+
function G({
|
|
65
65
|
isDisabled: r,
|
|
66
66
|
isReadOnly: t,
|
|
67
|
-
isLoading:
|
|
67
|
+
isLoading: c,
|
|
68
68
|
isInvalid: n,
|
|
69
69
|
placeholder: u,
|
|
70
|
-
selectedItems:
|
|
71
|
-
renderValue:
|
|
72
|
-
onClearButtonPress:
|
|
70
|
+
selectedItems: x,
|
|
71
|
+
renderValue: d,
|
|
72
|
+
onClearButtonPress: g,
|
|
73
73
|
...w
|
|
74
74
|
}, h) {
|
|
75
|
-
const
|
|
75
|
+
const m = P(), s = R(), S = D(), C = K(S, "open"), f = k(q), a = f.maxVisibleItems ?? 0, l = f.selectedKeys ?? /* @__PURE__ */ new Set(), o = Array.from(x), { base: M, inputValue: v, state: I, suffix: B } = F({
|
|
76
76
|
isDisabled: !!r,
|
|
77
77
|
isReadOnly: !!t,
|
|
78
78
|
isInvalid: !!n,
|
|
79
79
|
isEmpty: l.size === 0
|
|
80
|
-
}),
|
|
80
|
+
}), y = Math.max(
|
|
81
81
|
o.length - a,
|
|
82
82
|
0
|
|
83
|
-
),
|
|
83
|
+
), V = l.size > 0 && !r && !t && !c, N = A(() => {
|
|
84
84
|
if (o.length === 0) return u;
|
|
85
85
|
const O = o.slice(0, a), z = new Set(O);
|
|
86
|
-
return
|
|
87
|
-
}, [o, a,
|
|
88
|
-
return /* @__PURE__ */
|
|
86
|
+
return d(z);
|
|
87
|
+
}, [o, a, d, u]);
|
|
88
|
+
return /* @__PURE__ */ i(
|
|
89
89
|
$,
|
|
90
90
|
{
|
|
91
91
|
...w,
|
|
92
92
|
ref: h,
|
|
93
|
-
className:
|
|
93
|
+
className: M(),
|
|
94
94
|
disabled: r || t,
|
|
95
95
|
"aria-invalid": n,
|
|
96
96
|
"aria-readonly": t,
|
|
97
|
-
"aria-labelledby": `${
|
|
97
|
+
"aria-labelledby": `${m}-select-button-label`,
|
|
98
98
|
"data-dd-privacy": "mask",
|
|
99
99
|
children: [
|
|
100
|
-
/* @__PURE__ */ e("span", { id: `${
|
|
101
|
-
/* @__PURE__ */
|
|
102
|
-
|
|
103
|
-
|
|
100
|
+
/* @__PURE__ */ e("span", { id: `${m}-select-button-label`, className: v(), children: l.size > 0 ? N : u }),
|
|
101
|
+
/* @__PURE__ */ i("div", { className: I(), children: [
|
|
102
|
+
c && /* @__PURE__ */ e(
|
|
103
|
+
W,
|
|
104
104
|
{
|
|
105
105
|
color: "inherit",
|
|
106
106
|
size: "small",
|
|
@@ -111,7 +111,7 @@ function H({
|
|
|
111
111
|
}
|
|
112
112
|
),
|
|
113
113
|
n && /* @__PURE__ */ e(
|
|
114
|
-
|
|
114
|
+
b,
|
|
115
115
|
{
|
|
116
116
|
src: "WarningCircleOutlined",
|
|
117
117
|
color: "content.form.invalid",
|
|
@@ -121,12 +121,12 @@ function H({
|
|
|
121
121
|
})
|
|
122
122
|
}
|
|
123
123
|
),
|
|
124
|
-
|
|
124
|
+
y > 0 && /* @__PURE__ */ i(T, { variant: "numeric", children: [
|
|
125
125
|
"+",
|
|
126
|
-
|
|
126
|
+
y
|
|
127
127
|
] }),
|
|
128
|
-
|
|
129
|
-
|
|
128
|
+
V && /* @__PURE__ */ e(
|
|
129
|
+
U,
|
|
130
130
|
{
|
|
131
131
|
title: s.formatMessage({
|
|
132
132
|
id: "unity:component:common:clear:title",
|
|
@@ -135,17 +135,17 @@ function H({
|
|
|
135
135
|
className: "uy:text-content-neutral-enabled",
|
|
136
136
|
icon: "CloseOutlined",
|
|
137
137
|
onPress: () => {
|
|
138
|
-
|
|
138
|
+
g?.();
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
141
|
)
|
|
142
142
|
] }),
|
|
143
143
|
/* @__PURE__ */ e(
|
|
144
|
-
|
|
144
|
+
b,
|
|
145
145
|
{
|
|
146
146
|
color: "content.neutral.low",
|
|
147
|
-
className:
|
|
148
|
-
src:
|
|
147
|
+
className: B(),
|
|
148
|
+
src: C ? "CaretUpOutlined" : "CaretDownOutlined",
|
|
149
149
|
role: "presentation"
|
|
150
150
|
}
|
|
151
151
|
)
|
|
@@ -153,9 +153,9 @@ function H({
|
|
|
153
153
|
}
|
|
154
154
|
);
|
|
155
155
|
}
|
|
156
|
-
const
|
|
157
|
-
|
|
158
|
-
const ne =
|
|
156
|
+
const p = j(E(G));
|
|
157
|
+
p.displayName = "MultiselectButton";
|
|
158
|
+
const ne = p;
|
|
159
159
|
export {
|
|
160
160
|
ne as MultiSelectButton
|
|
161
161
|
};
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { jsx as e, jsxs as
|
|
1
|
+
import { jsx as e, jsxs as o, Fragment as m } from "react/jsx-runtime";
|
|
2
2
|
import { memo as b, useContext as f } from "react";
|
|
3
3
|
import { SelectPopover as h, Combobox as v, ComboboxList as x } from "@ariakit/react";
|
|
4
|
-
import { uyTv as
|
|
4
|
+
import { uyTv as t } from "@payfit/unity-themes";
|
|
5
5
|
import { Icon as g } from "../../icon/Icon.js";
|
|
6
6
|
import { MultiSelectContext as w } from "../Multiselect.context.js";
|
|
7
|
-
const S =
|
|
7
|
+
const S = t({
|
|
8
8
|
slots: {
|
|
9
9
|
base: "uy:shadow-floating uy:absolute uy:top-full uy:left-0 uy:z-50 uy:w-full uy:rounded-75 uy:border uy:border-solid uy:border-border-neutral uy:bg-surface-neutral uy:overflow-auto uy:max-h-[min(var(--popover-available-height,300px),300px)] uy:outline-none",
|
|
10
10
|
list: "uy:p-100"
|
|
11
11
|
}
|
|
12
|
-
}), N =
|
|
12
|
+
}), N = t({
|
|
13
13
|
slots: {
|
|
14
14
|
wrapper: "uy:sticky uy:top-0 uy:bg-surface-neutral uy:pt-100 uy:px-100",
|
|
15
15
|
base: "uy:flex uy:w-full uy:gap-100 uy:h-500 uy:border uy:border-solid uy:rounded-75 uy:py-100 uy:border-border-form-enabled uy:bg-surface-form-enabled uy:px-150 uy:typography-body uy:focus-within:outline-none uy:focus-within:ring-2 uy:focus-within:ring-utility-focus-ring uy:focus-within:ring-offset-2 uy:active:border-border-form-active",
|
|
@@ -18,22 +18,22 @@ const S = i({
|
|
|
18
18
|
}
|
|
19
19
|
});
|
|
20
20
|
function C({
|
|
21
|
-
children:
|
|
22
|
-
...
|
|
21
|
+
children: r,
|
|
22
|
+
...l
|
|
23
23
|
}) {
|
|
24
|
-
const
|
|
24
|
+
const i = f(w), { base: s, list: u } = S(), { base: n, input: a, wrapper: y, divider: c } = N(), { onBlur: d, ...p } = l;
|
|
25
25
|
return /* @__PURE__ */ e(
|
|
26
26
|
h,
|
|
27
27
|
{
|
|
28
28
|
portal: !0,
|
|
29
29
|
sameWidth: !0,
|
|
30
30
|
unmountOnHide: !0,
|
|
31
|
-
className:
|
|
32
|
-
onClose: () =>
|
|
31
|
+
className: s(),
|
|
32
|
+
onClose: () => d?.(),
|
|
33
33
|
...p,
|
|
34
|
-
children:
|
|
35
|
-
/* @__PURE__ */
|
|
36
|
-
/* @__PURE__ */
|
|
34
|
+
children: i.isSearchable ? /* @__PURE__ */ o(m, { children: [
|
|
35
|
+
/* @__PURE__ */ o("div", { className: y(), children: [
|
|
36
|
+
/* @__PURE__ */ o("div", { className: n(), children: [
|
|
37
37
|
/* @__PURE__ */ e(
|
|
38
38
|
g,
|
|
39
39
|
{
|
|
@@ -47,14 +47,14 @@ function C({
|
|
|
47
47
|
{
|
|
48
48
|
autoSelect: !0,
|
|
49
49
|
placeholder: "Search...",
|
|
50
|
-
className:
|
|
50
|
+
className: a()
|
|
51
51
|
}
|
|
52
52
|
)
|
|
53
53
|
] }),
|
|
54
|
-
/* @__PURE__ */ e("hr", { className:
|
|
54
|
+
/* @__PURE__ */ e("hr", { className: c() })
|
|
55
55
|
] }),
|
|
56
|
-
/* @__PURE__ */ e(x, { className: u(), children:
|
|
57
|
-
] }) : /* @__PURE__ */ e("div", { className: u(), children:
|
|
56
|
+
/* @__PURE__ */ e(x, { className: u(), children: r })
|
|
57
|
+
] }) : /* @__PURE__ */ e("div", { className: u(), children: r })
|
|
58
58
|
}
|
|
59
59
|
);
|
|
60
60
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
1
2
|
import { ForwardedRef, ReactNode } from 'react';
|
|
2
3
|
import { FieldPath, FieldValues } from 'react-hook-form';
|
|
3
|
-
import { infer as ZodInfer } from 'zod';
|
|
4
4
|
import { Schema } from '../../hooks/use-form.types.js';
|
|
5
5
|
import { LabelProps } from '../label/Label.js';
|
|
6
6
|
import { MultiSelectProps } from '../multi-select/Multiselect.types.js';
|
|
@@ -51,7 +51,7 @@ export type MultiSelectFieldProps<TFieldValues extends FieldValues = FieldValues
|
|
|
51
51
|
* [API & Docs](https://unity-components.payfit.io/?path=/docs/forms-multiselectfield--docs) • [Design Guidelines](https://www.payfit.design/24f360409/p/928776-multiselect)
|
|
52
52
|
*/
|
|
53
53
|
export declare const MultiSelectField: {
|
|
54
|
-
<TSchema extends Schema, TItem = unknown>(props: MultiSelectFieldProps<
|
|
54
|
+
<TSchema extends Schema, TItem = unknown>(props: MultiSelectFieldProps<StandardSchemaV1.InferOutput<TSchema>, FieldPath<StandardSchemaV1.InferOutput<TSchema>>, TItem, keyof TItem, TItem[keyof TItem] & Key> & {
|
|
55
55
|
ref?: ForwardedRef<HTMLButtonElement>;
|
|
56
56
|
}): React.JSX.Element;
|
|
57
57
|
displayName?: string;
|