@selectwin/kit 0.1.213 → 0.1.214
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/SelectFilterBar.js +141 -132
- package/dist/internal/listChrome.js +54 -49
- package/dist/internal/optionList.d.ts +3 -0
- package/dist/internal/optionList.js +29 -0
- package/package.json +1 -1
package/dist/SelectFilterBar.js
CHANGED
|
@@ -3,137 +3,142 @@ import { useSelectMessages as a } from "./SelectLocale.js";
|
|
|
3
3
|
import { SelectField as o } from "./SelectField.js";
|
|
4
4
|
import { SelectPopover as s } from "./SelectPopover.js";
|
|
5
5
|
import { SelectSearchInput as c } from "./SelectSearchInput.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
6
|
+
import { moveInOptions as l, useOptionListFocus as u } from "./internal/optionList.js";
|
|
7
|
+
import { SelectDateField as d } from "./SelectDateField.js";
|
|
8
|
+
import { formatDateValue as f } from "./internal/dateValue.js";
|
|
9
|
+
import { forwardRef as p, useEffect as m, useRef as h, useState as g } from "react";
|
|
10
|
+
import { jsx as _, jsxs as v } from "react/jsx-runtime";
|
|
10
11
|
//#region src/SelectFilterBar.tsx
|
|
11
|
-
function
|
|
12
|
+
function y(e) {
|
|
12
13
|
return (e ?? "").split(",").map((e) => e.trim()).filter(Boolean);
|
|
13
14
|
}
|
|
14
|
-
function
|
|
15
|
+
function b(e, t) {
|
|
15
16
|
let n = new Set(e);
|
|
16
17
|
return (t ? t.map((e) => e.value).filter((e) => n.has(e)) : [...n]).join(",");
|
|
17
18
|
}
|
|
18
|
-
function
|
|
19
|
+
function x(e, t) {
|
|
19
20
|
var n;
|
|
20
21
|
if (e.type === "select") return ((n = e.options) == null || (n = n.find((e) => e.value === t)) == null ? void 0 : n.label) ?? t;
|
|
21
22
|
if (e.type === "multiselect") {
|
|
22
|
-
let n =
|
|
23
|
+
let n = y(t).map((t) => {
|
|
23
24
|
var n;
|
|
24
25
|
return ((n = e.options) == null || (n = n.find((e) => e.value === t)) == null ? void 0 : n.label) ?? t;
|
|
25
26
|
});
|
|
26
27
|
return n.length > 2 ? `${n[0]} +${n.length - 1}` : n.join(", ");
|
|
27
28
|
}
|
|
28
|
-
return e.type === "date" ?
|
|
29
|
+
return e.type === "date" ? f(t) ?? t : t;
|
|
29
30
|
}
|
|
30
|
-
function
|
|
31
|
-
let
|
|
32
|
-
f(() => {
|
|
33
|
-
|
|
34
|
-
}, [
|
|
35
|
-
let
|
|
36
|
-
return /* @__PURE__ */
|
|
37
|
-
active:
|
|
38
|
-
onClose:
|
|
31
|
+
function S({ filter: n, value: r, onChange: i, open: f, onToggle: p, onClose: S, disabled: C }) {
|
|
32
|
+
let w = a(), [T, E] = g(""), D = h(null);
|
|
33
|
+
u(f && (n.type === "select" || n.type === "multiselect"), D), m(() => {
|
|
34
|
+
f || E("");
|
|
35
|
+
}, [f]);
|
|
36
|
+
let O = r.trim() !== "", k = O ? x(n, r) : null, A = O && !!n.error, j = n.options ?? [], M = j.length > 7, N = M ? j.filter((e) => e.label.toLowerCase().includes(T.trim().toLowerCase())) : j;
|
|
37
|
+
return /* @__PURE__ */ v(s, {
|
|
38
|
+
active: f,
|
|
39
|
+
onClose: S,
|
|
39
40
|
placement: "bottom-start",
|
|
40
|
-
activator: /* @__PURE__ */
|
|
41
|
+
activator: /* @__PURE__ */ v("button", {
|
|
41
42
|
type: "button",
|
|
42
|
-
className: `select-facet${
|
|
43
|
-
onClick:
|
|
44
|
-
disabled:
|
|
45
|
-
"aria-expanded":
|
|
46
|
-
"aria-invalid":
|
|
47
|
-
title:
|
|
48
|
-
children: [/* @__PURE__ */
|
|
43
|
+
className: `select-facet${O ? " is-active" : ""}${A ? " is-error" : ""}`,
|
|
44
|
+
onClick: p,
|
|
45
|
+
disabled: C,
|
|
46
|
+
"aria-expanded": f,
|
|
47
|
+
"aria-invalid": A || void 0,
|
|
48
|
+
title: A ? n.error : void 0,
|
|
49
|
+
children: [/* @__PURE__ */ _("span", {
|
|
49
50
|
className: "select-facet__label",
|
|
50
|
-
children:
|
|
51
|
-
}), /* @__PURE__ */
|
|
52
|
-
className: `select-facet__caret${
|
|
51
|
+
children: k == null ? n.label : `${n.label}: ${k}`
|
|
52
|
+
}), /* @__PURE__ */ _("span", {
|
|
53
|
+
className: `select-facet__caret${f ? " is-open" : ""}`,
|
|
53
54
|
"aria-hidden": "true",
|
|
54
|
-
children: /* @__PURE__ */
|
|
55
|
+
children: /* @__PURE__ */ _(t, {})
|
|
55
56
|
})]
|
|
56
57
|
}),
|
|
57
58
|
children: [
|
|
58
|
-
n.type === "multiselect" ? /* @__PURE__ */
|
|
59
|
+
n.type === "multiselect" ? /* @__PURE__ */ v("div", {
|
|
59
60
|
className: "select-facet__panel",
|
|
60
|
-
|
|
61
|
+
ref: D,
|
|
62
|
+
onKeyDown: l,
|
|
63
|
+
children: [M && /* @__PURE__ */ _("div", {
|
|
61
64
|
className: "select-facet__search",
|
|
62
|
-
children: /* @__PURE__ */
|
|
63
|
-
value:
|
|
64
|
-
onChange:
|
|
65
|
-
placeholder:
|
|
65
|
+
children: /* @__PURE__ */ _(c, {
|
|
66
|
+
value: T,
|
|
67
|
+
onChange: E,
|
|
68
|
+
placeholder: w.filterBar.searchOption
|
|
66
69
|
})
|
|
67
|
-
}), /* @__PURE__ */
|
|
70
|
+
}), /* @__PURE__ */ _("div", {
|
|
68
71
|
className: "select-facet__options",
|
|
69
72
|
role: "listbox",
|
|
70
73
|
"aria-multiselectable": "true",
|
|
71
|
-
children:
|
|
74
|
+
children: N.length === 0 ? /* @__PURE__ */ _("div", {
|
|
72
75
|
className: "select-facet__empty",
|
|
73
|
-
children:
|
|
74
|
-
}) :
|
|
75
|
-
let n =
|
|
76
|
-
return /* @__PURE__ */
|
|
76
|
+
children: w.common.nothingFound
|
|
77
|
+
}) : N.map((t) => {
|
|
78
|
+
let n = y(r), a = n.includes(t.value);
|
|
79
|
+
return /* @__PURE__ */ v("button", {
|
|
77
80
|
type: "button",
|
|
78
81
|
role: "option",
|
|
79
82
|
"aria-selected": a,
|
|
80
83
|
className: "select-facet__opt",
|
|
81
|
-
onClick: () => i(
|
|
82
|
-
children: [/* @__PURE__ */
|
|
84
|
+
onClick: () => i(b(a ? n.filter((e) => e !== t.value) : [...n, t.value], j)),
|
|
85
|
+
children: [/* @__PURE__ */ _("span", { children: t.label }), a && /* @__PURE__ */ _("span", {
|
|
83
86
|
className: "select-facet__check",
|
|
84
87
|
"aria-hidden": "true",
|
|
85
|
-
children: /* @__PURE__ */
|
|
88
|
+
children: /* @__PURE__ */ _(e, {})
|
|
86
89
|
})]
|
|
87
90
|
}, t.value);
|
|
88
91
|
})
|
|
89
92
|
})]
|
|
90
|
-
}) : n.type === "select" ? /* @__PURE__ */
|
|
93
|
+
}) : n.type === "select" ? /* @__PURE__ */ v("div", {
|
|
91
94
|
className: "select-facet__panel",
|
|
92
|
-
|
|
95
|
+
ref: D,
|
|
96
|
+
onKeyDown: l,
|
|
97
|
+
children: [M && /* @__PURE__ */ _("div", {
|
|
93
98
|
className: "select-facet__search",
|
|
94
|
-
children: /* @__PURE__ */
|
|
95
|
-
value:
|
|
96
|
-
onChange:
|
|
97
|
-
placeholder:
|
|
99
|
+
children: /* @__PURE__ */ _(c, {
|
|
100
|
+
value: T,
|
|
101
|
+
onChange: E,
|
|
102
|
+
placeholder: w.filterBar.searchOption
|
|
98
103
|
})
|
|
99
|
-
}), /* @__PURE__ */
|
|
104
|
+
}), /* @__PURE__ */ _("div", {
|
|
100
105
|
className: "select-facet__options",
|
|
101
106
|
role: "listbox",
|
|
102
|
-
children:
|
|
107
|
+
children: N.length === 0 ? /* @__PURE__ */ _("div", {
|
|
103
108
|
className: "select-facet__empty",
|
|
104
|
-
children:
|
|
105
|
-
}) :
|
|
109
|
+
children: w.common.nothingFound
|
|
110
|
+
}) : N.map((t) => {
|
|
106
111
|
let n = r === t.value;
|
|
107
|
-
return /* @__PURE__ */
|
|
112
|
+
return /* @__PURE__ */ v("button", {
|
|
108
113
|
type: "button",
|
|
109
114
|
role: "option",
|
|
110
115
|
"aria-selected": n,
|
|
111
116
|
className: `select-facet__opt${n ? " is-selected" : ""}`,
|
|
112
117
|
onClick: () => {
|
|
113
|
-
i(n ? "" : t.value),
|
|
118
|
+
i(n ? "" : t.value), S();
|
|
114
119
|
},
|
|
115
|
-
children: [/* @__PURE__ */
|
|
120
|
+
children: [/* @__PURE__ */ _("span", { children: t.label }), n && /* @__PURE__ */ _("span", {
|
|
116
121
|
className: "select-facet__check",
|
|
117
122
|
"aria-hidden": "true",
|
|
118
|
-
children: /* @__PURE__ */
|
|
123
|
+
children: /* @__PURE__ */ _(e, {})
|
|
119
124
|
})]
|
|
120
125
|
}, t.value);
|
|
121
126
|
})
|
|
122
127
|
})]
|
|
123
|
-
}) : n.type === "date" ? /* @__PURE__ */
|
|
128
|
+
}) : n.type === "date" ? /* @__PURE__ */ _("div", {
|
|
124
129
|
className: "select-facet__field",
|
|
125
|
-
children: /* @__PURE__ */
|
|
130
|
+
children: /* @__PURE__ */ _(d, {
|
|
126
131
|
value: r,
|
|
127
132
|
onChange: i,
|
|
128
133
|
placeholder: n.placeholder,
|
|
129
134
|
clearable: !1
|
|
130
135
|
})
|
|
131
|
-
}) : /* @__PURE__ */
|
|
136
|
+
}) : /* @__PURE__ */ _("div", {
|
|
132
137
|
className: "select-facet__field",
|
|
133
138
|
onKeyDown: (e) => {
|
|
134
|
-
e.key === "Enter" && (e.preventDefault(),
|
|
139
|
+
e.key === "Enter" && (e.preventDefault(), S());
|
|
135
140
|
},
|
|
136
|
-
children: /* @__PURE__ */
|
|
141
|
+
children: /* @__PURE__ */ _(o, {
|
|
137
142
|
type: "text",
|
|
138
143
|
value: r,
|
|
139
144
|
onChange: i,
|
|
@@ -141,152 +146,156 @@ function y({ filter: n, value: r, onChange: i, open: u, onToggle: d, onClose: y,
|
|
|
141
146
|
autoFocus: !0
|
|
142
147
|
})
|
|
143
148
|
}),
|
|
144
|
-
|
|
149
|
+
A && /* @__PURE__ */ _("div", {
|
|
145
150
|
className: "select-facet__error",
|
|
146
151
|
role: "alert",
|
|
147
152
|
children: n.error
|
|
148
153
|
}),
|
|
149
|
-
|
|
154
|
+
O && /* @__PURE__ */ _("div", {
|
|
150
155
|
className: "select-facet__foot",
|
|
151
|
-
children: /* @__PURE__ */
|
|
156
|
+
children: /* @__PURE__ */ _("button", {
|
|
152
157
|
type: "button",
|
|
153
158
|
className: "select-facet__clear",
|
|
154
159
|
onClick: () => {
|
|
155
|
-
i(""),
|
|
160
|
+
i(""), S();
|
|
156
161
|
},
|
|
157
|
-
children:
|
|
162
|
+
children: w.filterBar.clear
|
|
158
163
|
})
|
|
159
164
|
})
|
|
160
165
|
]
|
|
161
166
|
});
|
|
162
167
|
}
|
|
163
|
-
var
|
|
164
|
-
let
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
+
var C = p(function({ filters: e, values: t, onChange: o, onClearAll: c, search: d, leading: f, disabled: p, className: m, ...y }, b) {
|
|
169
|
+
let C = a(), [w, T] = g([]), [E, D] = g(null), [O, k] = g(!1), A = h(null);
|
|
170
|
+
u(O, A);
|
|
171
|
+
let j = (e) => (t[e.key] ?? "").trim() !== "", M = (e) => !!e.pinned || j(e) || w.includes(e.key), N = e.filter(M), P = e.filter((e) => !M(e)), F = e.filter(j), I = () => {
|
|
172
|
+
T([]), D(null), c();
|
|
173
|
+
}, L = (e) => {
|
|
174
|
+
T((t) => t.includes(e) ? t : [...t, e]), k(!1), D(e);
|
|
168
175
|
};
|
|
169
|
-
return /* @__PURE__ */
|
|
170
|
-
ref:
|
|
171
|
-
...
|
|
172
|
-
className: `select-filterbar${
|
|
176
|
+
return /* @__PURE__ */ v("div", {
|
|
177
|
+
ref: b,
|
|
178
|
+
...y,
|
|
179
|
+
className: `select-filterbar${m ? " " + m : ""}`,
|
|
173
180
|
children: [
|
|
174
|
-
/* @__PURE__ */
|
|
181
|
+
/* @__PURE__ */ v("div", {
|
|
175
182
|
className: "select-filterbar__row",
|
|
176
183
|
children: [
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
className: `select-filterbar__query${
|
|
184
|
+
f,
|
|
185
|
+
d && /* @__PURE__ */ v("div", {
|
|
186
|
+
className: `select-filterbar__query${d.error ? " select-filterbar__query--error" : ""}`,
|
|
180
187
|
children: [
|
|
181
|
-
/* @__PURE__ */
|
|
188
|
+
/* @__PURE__ */ _("span", {
|
|
182
189
|
className: "select-filterbar__query-icon",
|
|
183
190
|
"aria-hidden": "true",
|
|
184
|
-
children: /* @__PURE__ */
|
|
191
|
+
children: /* @__PURE__ */ _(i, {})
|
|
185
192
|
}),
|
|
186
|
-
/* @__PURE__ */
|
|
193
|
+
/* @__PURE__ */ _("input", {
|
|
187
194
|
className: "select-filterbar__query-input",
|
|
188
195
|
type: "search",
|
|
189
|
-
value:
|
|
190
|
-
placeholder:
|
|
191
|
-
onChange: (e) =>
|
|
192
|
-
onKeyDown:
|
|
196
|
+
value: d.value,
|
|
197
|
+
placeholder: d.placeholder ?? C.common.searchPlaceholder,
|
|
198
|
+
onChange: (e) => d.onChange(e.target.value),
|
|
199
|
+
onKeyDown: d.onSubmit ? (e) => {
|
|
193
200
|
if (e.key === "Enter") {
|
|
194
201
|
var t;
|
|
195
|
-
e.preventDefault(), (t =
|
|
202
|
+
e.preventDefault(), (t = d.onSubmit) == null || t.call(d);
|
|
196
203
|
}
|
|
197
204
|
} : void 0,
|
|
198
|
-
"aria-label":
|
|
199
|
-
"aria-invalid":
|
|
200
|
-
disabled:
|
|
205
|
+
"aria-label": d.ariaLabel ?? d.placeholder ?? C.common.search,
|
|
206
|
+
"aria-invalid": d.error ? !0 : void 0,
|
|
207
|
+
disabled: p
|
|
201
208
|
}),
|
|
202
|
-
|
|
209
|
+
d.value && /* @__PURE__ */ _("button", {
|
|
203
210
|
type: "button",
|
|
204
211
|
className: "select-filterbar__query-clear",
|
|
205
|
-
"aria-label":
|
|
206
|
-
onClick: () =>
|
|
207
|
-
children: /* @__PURE__ */
|
|
212
|
+
"aria-label": C.filterBar.clearSearch,
|
|
213
|
+
onClick: () => d.onChange(""),
|
|
214
|
+
children: /* @__PURE__ */ _(n, {})
|
|
208
215
|
}),
|
|
209
|
-
|
|
216
|
+
d.onSubmit && /* @__PURE__ */ _("button", {
|
|
210
217
|
type: "button",
|
|
211
218
|
className: "select-filterbar__query-submit",
|
|
212
|
-
onClick:
|
|
213
|
-
disabled:
|
|
214
|
-
children:
|
|
219
|
+
onClick: d.onSubmit,
|
|
220
|
+
disabled: p,
|
|
221
|
+
children: d.submitLabel ?? C.common.search
|
|
215
222
|
})
|
|
216
223
|
]
|
|
217
224
|
}),
|
|
218
|
-
|
|
225
|
+
N.map((e) => /* @__PURE__ */ _(S, {
|
|
219
226
|
filter: e,
|
|
220
227
|
value: t[e.key] ?? "",
|
|
221
228
|
onChange: (t) => o(e.key, t),
|
|
222
|
-
open:
|
|
223
|
-
onToggle: () =>
|
|
224
|
-
onClose: () =>
|
|
225
|
-
disabled:
|
|
229
|
+
open: E === e.key,
|
|
230
|
+
onToggle: () => D((t) => t === e.key ? null : e.key),
|
|
231
|
+
onClose: () => D((t) => t === e.key ? null : t),
|
|
232
|
+
disabled: p
|
|
226
233
|
}, e.key)),
|
|
227
|
-
|
|
228
|
-
active:
|
|
229
|
-
onClose: () =>
|
|
234
|
+
P.length > 0 && /* @__PURE__ */ _(s, {
|
|
235
|
+
active: O,
|
|
236
|
+
onClose: () => k(!1),
|
|
230
237
|
placement: "bottom-start",
|
|
231
|
-
activator: /* @__PURE__ */
|
|
238
|
+
activator: /* @__PURE__ */ v("button", {
|
|
232
239
|
type: "button",
|
|
233
240
|
className: "select-facet select-facet--more",
|
|
234
|
-
onClick: () =>
|
|
235
|
-
disabled:
|
|
236
|
-
"aria-expanded":
|
|
237
|
-
children: [/* @__PURE__ */
|
|
241
|
+
onClick: () => k((e) => !e),
|
|
242
|
+
disabled: p,
|
|
243
|
+
"aria-expanded": O,
|
|
244
|
+
children: [/* @__PURE__ */ _("span", {
|
|
238
245
|
className: "select-facet__addicon",
|
|
239
246
|
"aria-hidden": "true",
|
|
240
|
-
children: /* @__PURE__ */
|
|
241
|
-
}),
|
|
247
|
+
children: /* @__PURE__ */ _(r, {})
|
|
248
|
+
}), C.filterBar.moreFilters]
|
|
242
249
|
}),
|
|
243
|
-
children: /* @__PURE__ */
|
|
250
|
+
children: /* @__PURE__ */ _("div", {
|
|
244
251
|
className: "select-facet__options",
|
|
245
252
|
role: "menu",
|
|
246
|
-
|
|
253
|
+
ref: A,
|
|
254
|
+
onKeyDown: l,
|
|
255
|
+
children: P.map((e) => /* @__PURE__ */ _("button", {
|
|
247
256
|
type: "button",
|
|
248
257
|
role: "menuitem",
|
|
249
258
|
className: "select-facet__opt",
|
|
250
|
-
onClick: () =>
|
|
251
|
-
children: /* @__PURE__ */
|
|
259
|
+
onClick: () => L(e.key),
|
|
260
|
+
children: /* @__PURE__ */ _("span", { children: e.label })
|
|
252
261
|
}, e.key))
|
|
253
262
|
})
|
|
254
263
|
})
|
|
255
264
|
]
|
|
256
265
|
}),
|
|
257
|
-
|
|
266
|
+
d != null && d.error ? /* @__PURE__ */ _("p", {
|
|
258
267
|
className: "select-filterbar__query-error",
|
|
259
268
|
role: "alert",
|
|
260
|
-
children:
|
|
269
|
+
children: d.error
|
|
261
270
|
}) : null,
|
|
262
|
-
|
|
271
|
+
F.length > 0 && /* @__PURE__ */ v("div", {
|
|
263
272
|
className: "select-filterbar__applied",
|
|
264
|
-
children: [
|
|
273
|
+
children: [F.map((e) => /* @__PURE__ */ v("span", {
|
|
265
274
|
className: `select-filterbar__tag${e.error ? " is-error" : ""}`,
|
|
266
275
|
title: e.error || void 0,
|
|
267
276
|
children: [
|
|
268
277
|
e.label,
|
|
269
278
|
": ",
|
|
270
|
-
|
|
271
|
-
/* @__PURE__ */
|
|
279
|
+
x(e, t[e.key] ?? ""),
|
|
280
|
+
/* @__PURE__ */ _("button", {
|
|
272
281
|
type: "button",
|
|
273
282
|
className: "select-filterbar__tagx",
|
|
274
|
-
"aria-label":
|
|
283
|
+
"aria-label": C.filterBar.removeFilter(e.label),
|
|
275
284
|
onClick: () => o(e.key, ""),
|
|
276
|
-
children: /* @__PURE__ */
|
|
285
|
+
children: /* @__PURE__ */ _(n, {})
|
|
277
286
|
})
|
|
278
287
|
]
|
|
279
|
-
}, e.key)), /* @__PURE__ */
|
|
288
|
+
}, e.key)), /* @__PURE__ */ _("button", {
|
|
280
289
|
type: "button",
|
|
281
290
|
className: "select-filterbar__clear",
|
|
282
|
-
onClick:
|
|
283
|
-
children:
|
|
291
|
+
onClick: I,
|
|
292
|
+
children: C.filterBar.clearAll
|
|
284
293
|
})]
|
|
285
294
|
})
|
|
286
295
|
]
|
|
287
296
|
});
|
|
288
297
|
});
|
|
289
298
|
//#endregion
|
|
290
|
-
export {
|
|
299
|
+
export { C as SelectFilterBar, b as joinFilterValues, y as splitFilterValues };
|
|
291
300
|
|
|
292
301
|
//# sourceMappingURL=SelectFilterBar.js.map
|
|
@@ -2,11 +2,12 @@ import { CheckIcon as e, ChevronDownIcon as t } from "../icons.js";
|
|
|
2
2
|
import { formatSelectNumber as n, useSelectLocale as r, useSelectMessages as i } from "../SelectLocale.js";
|
|
3
3
|
import { SelectInfoTip as a } from "../SelectInfoTip.js";
|
|
4
4
|
import { SelectPopover as o } from "../SelectPopover.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
5
|
+
import { moveInOptions as s, useOptionListFocus as c } from "./optionList.js";
|
|
6
|
+
import { SelectPagination as l } from "../SelectPagination.js";
|
|
7
|
+
import { useRef as u, useState as d } from "react";
|
|
8
|
+
import { Fragment as f, jsx as p, jsxs as m } from "react/jsx-runtime";
|
|
8
9
|
//#region src/internal/listChrome.tsx
|
|
9
|
-
function
|
|
10
|
+
function h({ title: e, description: t, action: n, filters: r, tools: i }) {
|
|
10
11
|
let a = r != null, o = a ? null : i, s = e != null || t != null;
|
|
11
12
|
return {
|
|
12
13
|
hasFilters: a,
|
|
@@ -15,61 +16,61 @@ function f({ title: e, description: t, action: n, filters: r, tools: i }) {
|
|
|
15
16
|
hasTitleRow: s || n != null || o != null
|
|
16
17
|
};
|
|
17
18
|
}
|
|
18
|
-
function
|
|
19
|
-
let { hasFilters:
|
|
19
|
+
function g({ title: e, help: n, description: r, action: i, filters: o, tools: s, toggle: c }) {
|
|
20
|
+
let { hasFilters: l, inlineTools: u, hasIdentity: d, hasTitleRow: g } = h({
|
|
20
21
|
title: e,
|
|
21
22
|
description: r,
|
|
22
23
|
action: i,
|
|
23
24
|
filters: o,
|
|
24
25
|
tools: s
|
|
25
26
|
});
|
|
26
|
-
return /* @__PURE__ */
|
|
27
|
+
return /* @__PURE__ */ m(f, { children: [g && /* @__PURE__ */ m("div", {
|
|
27
28
|
className: "select-table__title",
|
|
28
|
-
children: [c ? /* @__PURE__ */
|
|
29
|
+
children: [c ? /* @__PURE__ */ m("button", {
|
|
29
30
|
type: "button",
|
|
30
31
|
className: "select-table__toggle",
|
|
31
32
|
"aria-expanded": c.open,
|
|
32
33
|
"aria-controls": c.controls,
|
|
33
34
|
onClick: c.onToggle,
|
|
34
|
-
children: [/* @__PURE__ */
|
|
35
|
+
children: [/* @__PURE__ */ m("span", {
|
|
35
36
|
className: "select-table__heading",
|
|
36
|
-
children: [e != null && /* @__PURE__ */
|
|
37
|
+
children: [e != null && /* @__PURE__ */ p("span", {
|
|
37
38
|
className: "select-table__titletext",
|
|
38
39
|
children: e
|
|
39
|
-
}), r != null && /* @__PURE__ */
|
|
40
|
+
}), r != null && /* @__PURE__ */ p("span", {
|
|
40
41
|
className: "select-table__desc",
|
|
41
42
|
children: r
|
|
42
43
|
})]
|
|
43
|
-
}), /* @__PURE__ */
|
|
44
|
+
}), /* @__PURE__ */ p("span", {
|
|
44
45
|
className: "select-table__chevron",
|
|
45
46
|
"aria-hidden": "true",
|
|
46
|
-
children: /* @__PURE__ */
|
|
47
|
+
children: /* @__PURE__ */ p(t, {})
|
|
47
48
|
})]
|
|
48
|
-
}) :
|
|
49
|
+
}) : d && /* @__PURE__ */ m("div", {
|
|
49
50
|
className: "select-table__heading",
|
|
50
|
-
children: [e != null && /* @__PURE__ */
|
|
51
|
+
children: [e != null && /* @__PURE__ */ m("h3", {
|
|
51
52
|
className: `select-table__titletext${n == null ? "" : " select-table__titletext--help"}`,
|
|
52
|
-
children: [e, n != null && /* @__PURE__ */
|
|
53
|
-
}), r != null && /* @__PURE__ */
|
|
53
|
+
children: [e, n != null && /* @__PURE__ */ p(a, { content: n })]
|
|
54
|
+
}), r != null && /* @__PURE__ */ p("p", {
|
|
54
55
|
className: "select-table__desc",
|
|
55
56
|
children: r
|
|
56
57
|
})]
|
|
57
|
-
}), (i != null ||
|
|
58
|
+
}), (i != null || u != null) && /* @__PURE__ */ m("div", {
|
|
58
59
|
className: "select-table__actions",
|
|
59
|
-
children: [i,
|
|
60
|
+
children: [i, u]
|
|
60
61
|
})]
|
|
61
|
-
}),
|
|
62
|
+
}), l && /* @__PURE__ */ m("div", {
|
|
62
63
|
className: "select-table__toolbar",
|
|
63
|
-
children: [/* @__PURE__ */
|
|
64
|
+
children: [/* @__PURE__ */ p("div", {
|
|
64
65
|
className: "select-table__filters",
|
|
65
66
|
children: o
|
|
66
|
-
}), s != null && /* @__PURE__ */
|
|
67
|
+
}), s != null && /* @__PURE__ */ p("div", {
|
|
67
68
|
className: "select-table__tools",
|
|
68
69
|
children: s
|
|
69
70
|
})]
|
|
70
71
|
})] });
|
|
71
72
|
}
|
|
72
|
-
function
|
|
73
|
+
function _(e, t, n) {
|
|
73
74
|
if (!e || e.length === 0) return [];
|
|
74
75
|
let r = [...e].sort((e, t) => e - t);
|
|
75
76
|
if (t == null) return r;
|
|
@@ -78,59 +79,63 @@ function m(e, t, n) {
|
|
|
78
79
|
for (let e of r) if (i.push(e), e >= t) break;
|
|
79
80
|
return n != null && r.includes(n) && !i.includes(n) && (i.push(n), i.sort((e, t) => e - t)), i;
|
|
80
81
|
}
|
|
81
|
-
function
|
|
82
|
-
let
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
82
|
+
function v({ pagination: a, className: f }) {
|
|
83
|
+
let h = i().pagination, g = r(), [v, y] = d(!1), b = u(null);
|
|
84
|
+
c(v, b);
|
|
85
|
+
let x = _(a.pageSizeOptions, a.total, a.pageSize), S = x.length > 1 && a.onPageSizeChange != null;
|
|
86
|
+
return !S && !a.hasPrevious && !a.hasNext ? null : /* @__PURE__ */ m("div", {
|
|
87
|
+
className: `select-datatable__pagination${f ? " " + f : ""}`,
|
|
88
|
+
children: [S && a.onPageSizeChange && /* @__PURE__ */ p("div", {
|
|
86
89
|
className: "select-datatable__pagesize",
|
|
87
|
-
children: /* @__PURE__ */
|
|
88
|
-
active:
|
|
89
|
-
onClose: () =>
|
|
90
|
+
children: /* @__PURE__ */ p(o, {
|
|
91
|
+
active: v,
|
|
92
|
+
onClose: () => y(!1),
|
|
90
93
|
placement: "top-start",
|
|
91
94
|
role: "listbox",
|
|
92
|
-
activator: /* @__PURE__ */
|
|
95
|
+
activator: /* @__PURE__ */ m("button", {
|
|
93
96
|
type: "button",
|
|
94
|
-
className: `select-facet${
|
|
95
|
-
onClick: () =>
|
|
96
|
-
"aria-expanded":
|
|
97
|
+
className: `select-facet${v ? " is-active" : ""}`,
|
|
98
|
+
onClick: () => y((e) => !e),
|
|
99
|
+
"aria-expanded": v,
|
|
97
100
|
"aria-haspopup": "listbox",
|
|
98
|
-
children: [/* @__PURE__ */
|
|
101
|
+
children: [/* @__PURE__ */ p("span", {
|
|
99
102
|
className: "select-facet__label",
|
|
100
|
-
children:
|
|
101
|
-
}), /* @__PURE__ */
|
|
102
|
-
className: `select-facet__caret${
|
|
103
|
+
children: h.perPage(a.pageSize == null ? "—" : n(a.pageSize, g))
|
|
104
|
+
}), /* @__PURE__ */ p("span", {
|
|
105
|
+
className: `select-facet__caret${v ? " is-open" : ""}`,
|
|
103
106
|
"aria-hidden": "true",
|
|
104
|
-
children: /* @__PURE__ */
|
|
107
|
+
children: /* @__PURE__ */ p(t, {})
|
|
105
108
|
})]
|
|
106
109
|
}),
|
|
107
|
-
children: /* @__PURE__ */
|
|
110
|
+
children: /* @__PURE__ */ p("div", {
|
|
108
111
|
className: "select-facet__panel",
|
|
109
|
-
|
|
112
|
+
ref: b,
|
|
113
|
+
onKeyDown: s,
|
|
114
|
+
children: /* @__PURE__ */ p("div", {
|
|
110
115
|
className: "select-facet__options",
|
|
111
116
|
role: "listbox",
|
|
112
|
-
children:
|
|
117
|
+
children: x.map((t) => {
|
|
113
118
|
let r = t === a.pageSize;
|
|
114
|
-
return /* @__PURE__ */
|
|
119
|
+
return /* @__PURE__ */ m("button", {
|
|
115
120
|
type: "button",
|
|
116
121
|
role: "option",
|
|
117
122
|
"aria-selected": r,
|
|
118
123
|
className: `select-facet__opt${r ? " is-selected" : ""}`,
|
|
119
124
|
onClick: () => {
|
|
120
125
|
var e;
|
|
121
|
-
(e = a.onPageSizeChange) == null || e.call(a, t),
|
|
126
|
+
(e = a.onPageSizeChange) == null || e.call(a, t), y(!1);
|
|
122
127
|
},
|
|
123
|
-
children: [/* @__PURE__ */
|
|
128
|
+
children: [/* @__PURE__ */ p("span", { children: h.perPage(n(t, g)) }), r && /* @__PURE__ */ p("span", {
|
|
124
129
|
className: "select-facet__check",
|
|
125
130
|
"aria-hidden": "true",
|
|
126
|
-
children: /* @__PURE__ */
|
|
131
|
+
children: /* @__PURE__ */ p(e, {})
|
|
127
132
|
})]
|
|
128
133
|
}, t);
|
|
129
134
|
})
|
|
130
135
|
})
|
|
131
136
|
})
|
|
132
137
|
})
|
|
133
|
-
}), /* @__PURE__ */
|
|
138
|
+
}), /* @__PURE__ */ p(l, {
|
|
134
139
|
page: a.page ?? 1,
|
|
135
140
|
pageCount: a.pageCount,
|
|
136
141
|
total: a.total,
|
|
@@ -146,6 +151,6 @@ function h({ pagination: a, className: l }) {
|
|
|
146
151
|
});
|
|
147
152
|
}
|
|
148
153
|
//#endregion
|
|
149
|
-
export {
|
|
154
|
+
export { g as SelectListChrome, v as SelectListFooter, h as listChromeShape, _ as usablePageSizes };
|
|
150
155
|
|
|
151
156
|
//# sourceMappingURL=listChrome.js.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { useEffect as e } from "react";
|
|
2
|
+
//#region src/internal/optionList.ts
|
|
3
|
+
var t = "[role=\"option\"]:not(:disabled), [role=\"menuitem\"]:not(:disabled)";
|
|
4
|
+
function n(n, r) {
|
|
5
|
+
e(() => {
|
|
6
|
+
if (!n) return;
|
|
7
|
+
let e = r.current;
|
|
8
|
+
if (!e) return;
|
|
9
|
+
let i = e.querySelector("input:not(:disabled)") ?? e.querySelector("[aria-selected=\"true\"]:not(:disabled)") ?? e.querySelector(t);
|
|
10
|
+
i == null || i.focus({ preventScroll: !0 });
|
|
11
|
+
}, [n, r]);
|
|
12
|
+
}
|
|
13
|
+
function r(e) {
|
|
14
|
+
if (![
|
|
15
|
+
"ArrowDown",
|
|
16
|
+
"ArrowUp",
|
|
17
|
+
"Home",
|
|
18
|
+
"End"
|
|
19
|
+
].includes(e.key) || (e.key === "Home" || e.key === "End") && e.target instanceof HTMLInputElement) return;
|
|
20
|
+
let n = [...e.currentTarget.querySelectorAll(t)];
|
|
21
|
+
if (!n.length) return;
|
|
22
|
+
e.preventDefault();
|
|
23
|
+
let r = n.indexOf(document.activeElement);
|
|
24
|
+
n[e.key === "Home" ? 0 : e.key === "End" ? n.length - 1 : e.key === "ArrowDown" ? (r + 1) % n.length : r <= 0 ? n.length - 1 : r - 1].focus();
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
export { r as moveInOptions, n as useOptionListFocus };
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=optionList.js.map
|
package/package.json
CHANGED