@sito/dashboard 0.0.81 → 0.0.83
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/README.md +1 -0
- package/dist/{Dropdown-C5blCAyI.cjs → Dropdown-CE03Yftt.cjs} +1 -1
- package/dist/{Dropdown-WnR9AjVf.js → Dropdown-DQLnDEAD.js} +1 -1
- package/dist/Dropdown.cjs +1 -1
- package/dist/Dropdown.js +1 -1
- package/dist/Form.cjs +1 -1
- package/dist/Form.js +1 -1
- package/dist/SelectInput-DwiR4IIb.js +624 -0
- package/dist/SelectInput-ckBfPXet.cjs +1 -0
- package/dist/Table-D4bB7JS0.cjs +1 -0
- package/dist/{Table-C78wkUId.js → Table-Dimg0OqF.js} +64 -63
- package/dist/Table.cjs +1 -1
- package/dist/Table.js +1 -1
- package/dist/components/Actions/Action.d.ts +1 -0
- package/dist/components/Actions/types.d.ts +1 -0
- package/dist/components/Form/AutocompleteInput/types.d.ts +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.css +1 -1
- package/dist/index.js +3 -3
- package/package.json +2 -2
- package/dist/SelectInput-BrKnfhB0.cjs +0 -1
- package/dist/SelectInput-D09muy0T.js +0 -584
- package/dist/Table-CTAvN4dV.cjs +0 -1
|
@@ -1,584 +0,0 @@
|
|
|
1
|
-
import "./SelectInput.css";
|
|
2
|
-
import { jsxs as D, jsx as a, Fragment as ae } from "react/jsx-runtime";
|
|
3
|
-
import { c as d } from "./classNames-DDRjbGA1.js";
|
|
4
|
-
import { forwardRef as j, useState as O, useEffect as K, useMemo as z, useRef as M, useCallback as S, useLayoutEffect as le } from "react";
|
|
5
|
-
import { C as G } from "./Chip-6bEZ7uwv.js";
|
|
6
|
-
import { I as se } from "./IconButton-CqPk_OXG.js";
|
|
7
|
-
import { C as ie } from "./Close-rKC9AcNX.js";
|
|
8
|
-
const ge = j(function(l, C) {
|
|
9
|
-
const {
|
|
10
|
-
state: y,
|
|
11
|
-
value: t,
|
|
12
|
-
onChange: r,
|
|
13
|
-
options: x = [],
|
|
14
|
-
name: I = "",
|
|
15
|
-
id: A = "",
|
|
16
|
-
label: v = "",
|
|
17
|
-
containerClassName: E = "",
|
|
18
|
-
inputContainerClassName: w = "",
|
|
19
|
-
helperText: L = "",
|
|
20
|
-
placeholder: R = "",
|
|
21
|
-
multiple: m = !1,
|
|
22
|
-
required: T = !1,
|
|
23
|
-
"aria-required": o = !1,
|
|
24
|
-
...F
|
|
25
|
-
} = l, U = o === !0 || String(o).toLowerCase() === "true", P = !!(T || U), B = m && Array.isArray(t) && t.length > 0, H = P && !B, [b, h] = O("");
|
|
26
|
-
K(() => {
|
|
27
|
-
if (!m && t && !Array.isArray(t)) {
|
|
28
|
-
h(String(t.value ?? t.name ?? ""));
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
h("");
|
|
32
|
-
}, [m, t]);
|
|
33
|
-
const [u, f] = O(!1), [g, i] = O(-1), p = z(
|
|
34
|
-
() => x.filter((e) => {
|
|
35
|
-
const s = String(e.value ?? e.name).toLowerCase().includes(b?.toLowerCase());
|
|
36
|
-
return Array.isArray(t) && t.length ? s && !t.some((N) => N.id === e.id) : t && !Array.isArray(t) ? s && t.id !== e.id : s;
|
|
37
|
-
}),
|
|
38
|
-
[x, t, b]
|
|
39
|
-
);
|
|
40
|
-
K(() => {
|
|
41
|
-
if (!u || !p.length) {
|
|
42
|
-
i(-1);
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
i(0);
|
|
46
|
-
}, [u, p]);
|
|
47
|
-
const q = M(null), V = M(null), [W, $] = O(!1), n = M(null);
|
|
48
|
-
K(() => {
|
|
49
|
-
const e = (N) => {
|
|
50
|
-
q.current && !q.current.contains(N.target) && f(!1);
|
|
51
|
-
}, s = (N) => {
|
|
52
|
-
N.key === "Escape" && f(!1);
|
|
53
|
-
};
|
|
54
|
-
return document.addEventListener("mousedown", e), document.addEventListener("keydown", s), () => {
|
|
55
|
-
document.removeEventListener("mousedown", e), document.removeEventListener("keydown", s);
|
|
56
|
-
};
|
|
57
|
-
}, []);
|
|
58
|
-
const c = S((e) => {
|
|
59
|
-
h(e.target.value);
|
|
60
|
-
}, []), k = S(
|
|
61
|
-
(e) => {
|
|
62
|
-
e ? m ? (h(""), Array.isArray(t) && t.length ? r([...t, e]) : r([e])) : (h(String(e.name ?? e.value ?? "")), r(e)) : r(null), f(!1);
|
|
63
|
-
},
|
|
64
|
-
[m, r, t]
|
|
65
|
-
), X = S(
|
|
66
|
-
(e) => {
|
|
67
|
-
if (!p.length) {
|
|
68
|
-
e.key === "Escape" && f(!1);
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
if (e.key === "ArrowDown" || e.key === "ArrowUp") {
|
|
72
|
-
if (e.preventDefault(), !u) {
|
|
73
|
-
f(!0), i(0);
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
i((s) => {
|
|
77
|
-
const N = s >= 0 ? s : 0;
|
|
78
|
-
return e.key === "ArrowDown" ? (N + 1 + p.length) % p.length : (N - 1 + p.length) % p.length;
|
|
79
|
-
});
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
if (e.key === "Enter" && u) {
|
|
83
|
-
e.preventDefault();
|
|
84
|
-
const s = g >= 0 ? g : 0;
|
|
85
|
-
k(p[s]);
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
e.key === "Escape" && u && (e.preventDefault(), f(!1));
|
|
89
|
-
},
|
|
90
|
-
[
|
|
91
|
-
k,
|
|
92
|
-
g,
|
|
93
|
-
u,
|
|
94
|
-
p
|
|
95
|
-
]
|
|
96
|
-
), _ = S(
|
|
97
|
-
(e) => {
|
|
98
|
-
if (!Array.isArray(t)) {
|
|
99
|
-
r(null);
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
const s = t.filter((N, re) => re !== e);
|
|
103
|
-
s.length ? r(s) : r(null);
|
|
104
|
-
},
|
|
105
|
-
[r, t]
|
|
106
|
-
), ne = S(() => {
|
|
107
|
-
Array.isArray(t) && r([t[0]]);
|
|
108
|
-
}, [r, t]);
|
|
109
|
-
return le(() => {
|
|
110
|
-
const e = n.current?.offsetWidth ?? 0, s = q.current?.offsetWidth ?? 0;
|
|
111
|
-
$(e > s * 0.4);
|
|
112
|
-
}, [t]), /* @__PURE__ */ D(
|
|
113
|
-
"div",
|
|
114
|
-
{
|
|
115
|
-
className: d("autocomplete-input-container", E),
|
|
116
|
-
ref: q,
|
|
117
|
-
children: [
|
|
118
|
-
/* @__PURE__ */ D("div", { className: "autocomplete-value-input-container", children: [
|
|
119
|
-
/* @__PURE__ */ a(
|
|
120
|
-
te,
|
|
121
|
-
{
|
|
122
|
-
state: y,
|
|
123
|
-
name: I,
|
|
124
|
-
id: A,
|
|
125
|
-
value: b,
|
|
126
|
-
onChange: c,
|
|
127
|
-
placeholder: R,
|
|
128
|
-
helperText: L,
|
|
129
|
-
onFocus: () => f(!0),
|
|
130
|
-
onKeyDown: X,
|
|
131
|
-
label: v,
|
|
132
|
-
containerClassName: d(
|
|
133
|
-
"autocomplete-text-input",
|
|
134
|
-
w
|
|
135
|
-
),
|
|
136
|
-
required: H,
|
|
137
|
-
"aria-required": P,
|
|
138
|
-
ref: C ?? V,
|
|
139
|
-
...F,
|
|
140
|
-
children: !m && t && !Array.isArray(t) && (t.value || t.name) && /* @__PURE__ */ a(
|
|
141
|
-
se,
|
|
142
|
-
{
|
|
143
|
-
icon: /* @__PURE__ */ a(ie, {}),
|
|
144
|
-
className: "autocomplete-delete-button",
|
|
145
|
-
onClick: (e) => {
|
|
146
|
-
k(), e.stopPropagation();
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
)
|
|
150
|
-
}
|
|
151
|
-
),
|
|
152
|
-
m && Array.isArray(t) && t.length ? /* @__PURE__ */ a("ul", { ref: n, className: "autocomplete-value-container", children: W ? /* @__PURE__ */ D(ae, { children: [
|
|
153
|
-
/* @__PURE__ */ a("li", { children: /* @__PURE__ */ a(
|
|
154
|
-
G,
|
|
155
|
-
{
|
|
156
|
-
text: t[0]?.value ?? t[0]?.name,
|
|
157
|
-
onDelete: (e) => {
|
|
158
|
-
_(0), e.stopPropagation();
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
) }),
|
|
162
|
-
t.length > 1 && /* @__PURE__ */ a("li", { children: /* @__PURE__ */ a(
|
|
163
|
-
G,
|
|
164
|
-
{
|
|
165
|
-
text: `+${t.length - 1}`,
|
|
166
|
-
onDelete: (e) => {
|
|
167
|
-
ne(), e.stopPropagation();
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
) })
|
|
171
|
-
] }) : t.map((e, s) => /* @__PURE__ */ a("li", { children: /* @__PURE__ */ a(
|
|
172
|
-
G,
|
|
173
|
-
{
|
|
174
|
-
text: String(e.value ?? e.name),
|
|
175
|
-
onDelete: (N) => {
|
|
176
|
-
_(s), N.stopPropagation();
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
) }, e.id ?? e.value ?? e.name)) }) : null
|
|
180
|
-
] }),
|
|
181
|
-
u && /* @__PURE__ */ a(
|
|
182
|
-
"ul",
|
|
183
|
-
{
|
|
184
|
-
className: "autocomplete-suggestions-container",
|
|
185
|
-
style: { width: q.current?.offsetWidth },
|
|
186
|
-
children: p.map((e) => /* @__PURE__ */ a(
|
|
187
|
-
"li",
|
|
188
|
-
{
|
|
189
|
-
className: d(
|
|
190
|
-
"autocomplete-suggestion-item",
|
|
191
|
-
e.id === p[g]?.id ? "highlighted" : ""
|
|
192
|
-
),
|
|
193
|
-
onMouseEnter: () => i(
|
|
194
|
-
p.findIndex((s) => s.id === e.id)
|
|
195
|
-
),
|
|
196
|
-
onClick: (s) => {
|
|
197
|
-
k(e), s.stopPropagation();
|
|
198
|
-
},
|
|
199
|
-
children: e.value ?? e.name
|
|
200
|
-
},
|
|
201
|
-
e.id ?? e.value ?? e.name
|
|
202
|
-
))
|
|
203
|
-
}
|
|
204
|
-
)
|
|
205
|
-
]
|
|
206
|
-
}
|
|
207
|
-
);
|
|
208
|
-
});
|
|
209
|
-
var Y = /* @__PURE__ */ ((l) => (l.error = "error", l.good = "good", l.default = "default", l))(Y || {});
|
|
210
|
-
const J = (l) => {
|
|
211
|
-
switch (l) {
|
|
212
|
-
case "error":
|
|
213
|
-
return "input-error";
|
|
214
|
-
case "good":
|
|
215
|
-
return "input-good";
|
|
216
|
-
default:
|
|
217
|
-
return "input-normal";
|
|
218
|
-
}
|
|
219
|
-
}, Q = (l) => {
|
|
220
|
-
switch (l) {
|
|
221
|
-
case "error":
|
|
222
|
-
return "input-label-error";
|
|
223
|
-
case "good":
|
|
224
|
-
return "input-label-good";
|
|
225
|
-
default:
|
|
226
|
-
return "input-label-normal";
|
|
227
|
-
}
|
|
228
|
-
}, ee = (l) => {
|
|
229
|
-
switch (l) {
|
|
230
|
-
case "error":
|
|
231
|
-
return "input-helper-text-error";
|
|
232
|
-
case "good":
|
|
233
|
-
return "input-helper-text-good";
|
|
234
|
-
default:
|
|
235
|
-
return "input-helper-text-normal";
|
|
236
|
-
}
|
|
237
|
-
}, Ce = j(function(l, C) {
|
|
238
|
-
const {
|
|
239
|
-
checked: y,
|
|
240
|
-
onChange: t,
|
|
241
|
-
name: r = "",
|
|
242
|
-
id: x = "",
|
|
243
|
-
label: I = "",
|
|
244
|
-
state: A = Y.default,
|
|
245
|
-
containerClassName: v = "",
|
|
246
|
-
inputClassName: E = "",
|
|
247
|
-
labelClassName: w = "",
|
|
248
|
-
...L
|
|
249
|
-
} = l;
|
|
250
|
-
return /* @__PURE__ */ D("label", { className: d("input-check-container", v), children: [
|
|
251
|
-
/* @__PURE__ */ a(
|
|
252
|
-
"input",
|
|
253
|
-
{
|
|
254
|
-
id: x,
|
|
255
|
-
ref: C,
|
|
256
|
-
name: r,
|
|
257
|
-
type: "checkbox",
|
|
258
|
-
checked: y,
|
|
259
|
-
onChange: t,
|
|
260
|
-
className: d(
|
|
261
|
-
"input-check",
|
|
262
|
-
J(A),
|
|
263
|
-
E
|
|
264
|
-
),
|
|
265
|
-
...L
|
|
266
|
-
}
|
|
267
|
-
),
|
|
268
|
-
/* @__PURE__ */ a(
|
|
269
|
-
"span",
|
|
270
|
-
{
|
|
271
|
-
className: d(
|
|
272
|
-
"input-check-label",
|
|
273
|
-
Q(A),
|
|
274
|
-
w
|
|
275
|
-
),
|
|
276
|
-
children: I
|
|
277
|
-
}
|
|
278
|
-
)
|
|
279
|
-
] });
|
|
280
|
-
}), Z = (l) => l == null ? !1 : Array.isArray(l) ? l.length > 0 : `${l}`.length > 0, oe = /* @__PURE__ */ new Set([
|
|
281
|
-
"date",
|
|
282
|
-
"datetime-local",
|
|
283
|
-
"time",
|
|
284
|
-
"month",
|
|
285
|
-
"week",
|
|
286
|
-
"range",
|
|
287
|
-
"color",
|
|
288
|
-
"file"
|
|
289
|
-
]), te = j(function(l, C) {
|
|
290
|
-
const {
|
|
291
|
-
children: y,
|
|
292
|
-
state: t = Y.default,
|
|
293
|
-
label: r = "",
|
|
294
|
-
containerClassName: x = "",
|
|
295
|
-
inputClassName: I = "",
|
|
296
|
-
labelClassName: A = "",
|
|
297
|
-
helperText: v = "",
|
|
298
|
-
helperTextClassName: E = "",
|
|
299
|
-
value: w,
|
|
300
|
-
defaultValue: L,
|
|
301
|
-
onChange: R,
|
|
302
|
-
onFocus: m,
|
|
303
|
-
onBlur: T,
|
|
304
|
-
...o
|
|
305
|
-
} = l, F = w !== void 0, [U, P] = O(
|
|
306
|
-
() => Z(L)
|
|
307
|
-
), B = F ? Z(w) : U, H = oe.has(
|
|
308
|
-
o.type ?? ""
|
|
309
|
-
), b = !!o.placeholder || H, h = o["aria-required"] === !0 || String(o["aria-required"]).toLowerCase() === "true", u = !!(o.required || h), f = (g) => {
|
|
310
|
-
F || P(g.currentTarget.value.length > 0), R?.(g);
|
|
311
|
-
};
|
|
312
|
-
return /* @__PURE__ */ D("div", { className: d("text-input-container", x), children: [
|
|
313
|
-
/* @__PURE__ */ D("div", { className: "text-input-field", children: [
|
|
314
|
-
/* @__PURE__ */ a(
|
|
315
|
-
"input",
|
|
316
|
-
{
|
|
317
|
-
ref: C,
|
|
318
|
-
defaultValue: L,
|
|
319
|
-
onChange: f,
|
|
320
|
-
onFocus: m,
|
|
321
|
-
onBlur: T,
|
|
322
|
-
...F ? { value: w } : {},
|
|
323
|
-
className: d(
|
|
324
|
-
"text-input",
|
|
325
|
-
J(t),
|
|
326
|
-
I,
|
|
327
|
-
B ? "has-value" : "",
|
|
328
|
-
o.placeholder ? "has-placeholder" : "",
|
|
329
|
-
b ? "keep-label-up" : ""
|
|
330
|
-
),
|
|
331
|
-
...o
|
|
332
|
-
}
|
|
333
|
-
),
|
|
334
|
-
!!r && /* @__PURE__ */ D(
|
|
335
|
-
"label",
|
|
336
|
-
{
|
|
337
|
-
htmlFor: o.id,
|
|
338
|
-
className: d(
|
|
339
|
-
"text-input-label",
|
|
340
|
-
Q(t),
|
|
341
|
-
A
|
|
342
|
-
),
|
|
343
|
-
children: [
|
|
344
|
-
r,
|
|
345
|
-
u ? " *" : ""
|
|
346
|
-
]
|
|
347
|
-
}
|
|
348
|
-
),
|
|
349
|
-
y
|
|
350
|
-
] }),
|
|
351
|
-
!!v && /* @__PURE__ */ a(
|
|
352
|
-
"p",
|
|
353
|
-
{
|
|
354
|
-
className: d(
|
|
355
|
-
"text-input-helper-text",
|
|
356
|
-
ee(t),
|
|
357
|
-
E
|
|
358
|
-
),
|
|
359
|
-
children: v
|
|
360
|
-
}
|
|
361
|
-
)
|
|
362
|
-
] });
|
|
363
|
-
}), ye = j(function(l, C) {
|
|
364
|
-
const {
|
|
365
|
-
value: y,
|
|
366
|
-
onChange: t,
|
|
367
|
-
options: r,
|
|
368
|
-
containerClassName: x = "",
|
|
369
|
-
inputClassName: I = "",
|
|
370
|
-
labelClassName: A = "",
|
|
371
|
-
helperText: v = "",
|
|
372
|
-
helperTextClassName: E = "",
|
|
373
|
-
label: w = "",
|
|
374
|
-
placeholder: L = "",
|
|
375
|
-
name: R = "",
|
|
376
|
-
id: m = "",
|
|
377
|
-
state: T = Y.default,
|
|
378
|
-
native: o = !0,
|
|
379
|
-
disabled: F,
|
|
380
|
-
required: U,
|
|
381
|
-
autoFocus: P,
|
|
382
|
-
children: B,
|
|
383
|
-
...H
|
|
384
|
-
} = l, b = M(null), [h, u] = O(!1), [f, g] = O(-1), i = z(
|
|
385
|
-
() => r.findIndex(
|
|
386
|
-
(n) => String(n.id) === String(y ?? r[0]?.id ?? "")
|
|
387
|
-
),
|
|
388
|
-
[r, y]
|
|
389
|
-
), p = z(
|
|
390
|
-
() => i >= 0 ? r[i] : void 0,
|
|
391
|
-
[r, i]
|
|
392
|
-
);
|
|
393
|
-
K(() => {
|
|
394
|
-
if (!(o || !h)) {
|
|
395
|
-
if (!r.length) {
|
|
396
|
-
g(-1);
|
|
397
|
-
return;
|
|
398
|
-
}
|
|
399
|
-
g(i >= 0 ? i : 0);
|
|
400
|
-
}
|
|
401
|
-
}, [o, r.length, i, h]), K(() => {
|
|
402
|
-
if (o) return;
|
|
403
|
-
const n = (c) => {
|
|
404
|
-
b.current && !b.current.contains(c.target) && u(!1);
|
|
405
|
-
};
|
|
406
|
-
return document.addEventListener("mousedown", n), () => {
|
|
407
|
-
document.removeEventListener("mousedown", n);
|
|
408
|
-
};
|
|
409
|
-
}, [o]);
|
|
410
|
-
const q = S(
|
|
411
|
-
(n) => {
|
|
412
|
-
C && (typeof C == "function" ? C(n) : C.current = n);
|
|
413
|
-
},
|
|
414
|
-
[C]
|
|
415
|
-
), V = S(
|
|
416
|
-
(n) => {
|
|
417
|
-
if (!t) return;
|
|
418
|
-
const c = {
|
|
419
|
-
target: { value: String(n) },
|
|
420
|
-
currentTarget: { value: String(n) }
|
|
421
|
-
};
|
|
422
|
-
t(c);
|
|
423
|
-
},
|
|
424
|
-
[t]
|
|
425
|
-
), W = S(
|
|
426
|
-
(n) => {
|
|
427
|
-
const c = r[n];
|
|
428
|
-
c && (V(c.id), u(!1));
|
|
429
|
-
},
|
|
430
|
-
[V, r]
|
|
431
|
-
), $ = S(
|
|
432
|
-
(n) => {
|
|
433
|
-
if (r.length) {
|
|
434
|
-
if (n.key === "ArrowDown" || n.key === "ArrowUp") {
|
|
435
|
-
if (n.preventDefault(), !h) {
|
|
436
|
-
u(!0);
|
|
437
|
-
const c = i >= 0 ? i : 0;
|
|
438
|
-
g(c);
|
|
439
|
-
return;
|
|
440
|
-
}
|
|
441
|
-
g((c) => {
|
|
442
|
-
const k = c >= 0 ? c : i;
|
|
443
|
-
return n.key === "ArrowDown" ? (k + 1 + r.length) % r.length : (k - 1 + r.length) % r.length;
|
|
444
|
-
});
|
|
445
|
-
return;
|
|
446
|
-
}
|
|
447
|
-
if (n.key === "Enter") {
|
|
448
|
-
if (!h) {
|
|
449
|
-
n.preventDefault(), u(!0), g(i >= 0 ? i : 0);
|
|
450
|
-
return;
|
|
451
|
-
}
|
|
452
|
-
n.preventDefault(), W(f >= 0 ? f : 0);
|
|
453
|
-
return;
|
|
454
|
-
}
|
|
455
|
-
n.key === "Escape" && h && (n.preventDefault(), u(!1));
|
|
456
|
-
}
|
|
457
|
-
},
|
|
458
|
-
[f, r, W, i, h]
|
|
459
|
-
);
|
|
460
|
-
return o ? /* @__PURE__ */ D("div", { className: d("select-input-container", x), children: [
|
|
461
|
-
/* @__PURE__ */ a(
|
|
462
|
-
"select",
|
|
463
|
-
{
|
|
464
|
-
...H,
|
|
465
|
-
id: m,
|
|
466
|
-
ref: q,
|
|
467
|
-
name: R,
|
|
468
|
-
value: y,
|
|
469
|
-
onChange: t,
|
|
470
|
-
className: d(
|
|
471
|
-
"select-input",
|
|
472
|
-
J(T),
|
|
473
|
-
"peer",
|
|
474
|
-
I
|
|
475
|
-
),
|
|
476
|
-
children: r?.map((n) => /* @__PURE__ */ a("option", { value: n.id, children: n.value ?? n.name ?? n.id }, n.id))
|
|
477
|
-
}
|
|
478
|
-
),
|
|
479
|
-
/* @__PURE__ */ a(
|
|
480
|
-
"label",
|
|
481
|
-
{
|
|
482
|
-
htmlFor: m,
|
|
483
|
-
className: d(
|
|
484
|
-
"select-input-label",
|
|
485
|
-
Q(T),
|
|
486
|
-
A
|
|
487
|
-
),
|
|
488
|
-
children: w
|
|
489
|
-
}
|
|
490
|
-
),
|
|
491
|
-
B,
|
|
492
|
-
v && /* @__PURE__ */ a(
|
|
493
|
-
"p",
|
|
494
|
-
{
|
|
495
|
-
className: d(
|
|
496
|
-
"select-input-helper-text",
|
|
497
|
-
ee(T),
|
|
498
|
-
E
|
|
499
|
-
),
|
|
500
|
-
children: v
|
|
501
|
-
}
|
|
502
|
-
)
|
|
503
|
-
] }) : /* @__PURE__ */ D(
|
|
504
|
-
"div",
|
|
505
|
-
{
|
|
506
|
-
ref: b,
|
|
507
|
-
className: d("select-input-container", x),
|
|
508
|
-
children: [
|
|
509
|
-
/* @__PURE__ */ a(
|
|
510
|
-
"select",
|
|
511
|
-
{
|
|
512
|
-
...H,
|
|
513
|
-
ref: q,
|
|
514
|
-
name: R,
|
|
515
|
-
id: m,
|
|
516
|
-
value: y,
|
|
517
|
-
onChange: t,
|
|
518
|
-
className: "select-input-native-hidden",
|
|
519
|
-
tabIndex: -1,
|
|
520
|
-
"aria-hidden": !0,
|
|
521
|
-
children: r?.map((n) => /* @__PURE__ */ a("option", { value: n.id, children: n.value ?? n.name ?? n.id }, n.id))
|
|
522
|
-
}
|
|
523
|
-
),
|
|
524
|
-
/* @__PURE__ */ a(
|
|
525
|
-
te,
|
|
526
|
-
{
|
|
527
|
-
id: m,
|
|
528
|
-
name: R,
|
|
529
|
-
state: T,
|
|
530
|
-
value: String(p?.value ?? p?.name ?? ""),
|
|
531
|
-
readOnly: !0,
|
|
532
|
-
label: w,
|
|
533
|
-
helperText: v,
|
|
534
|
-
containerClassName: "select-input-text-container",
|
|
535
|
-
inputClassName: d("select-input-text", I),
|
|
536
|
-
labelClassName: A,
|
|
537
|
-
helperTextClassName: E,
|
|
538
|
-
placeholder: L,
|
|
539
|
-
disabled: F,
|
|
540
|
-
required: U,
|
|
541
|
-
autoFocus: P,
|
|
542
|
-
onClick: () => u((n) => !n),
|
|
543
|
-
onKeyDown: $,
|
|
544
|
-
onFocus: () => u(!0),
|
|
545
|
-
role: "combobox",
|
|
546
|
-
"aria-expanded": h,
|
|
547
|
-
"aria-haspopup": "listbox",
|
|
548
|
-
children: B
|
|
549
|
-
}
|
|
550
|
-
),
|
|
551
|
-
h && /* @__PURE__ */ a("ul", { className: "select-input-options-container", role: "listbox", children: r.map((n, c) => {
|
|
552
|
-
const k = String(n.id) === String(y);
|
|
553
|
-
return /* @__PURE__ */ a(
|
|
554
|
-
"li",
|
|
555
|
-
{
|
|
556
|
-
role: "option",
|
|
557
|
-
"aria-selected": k,
|
|
558
|
-
className: d(
|
|
559
|
-
"select-input-option-item",
|
|
560
|
-
c === f ? "highlighted" : ""
|
|
561
|
-
),
|
|
562
|
-
onMouseEnter: () => g(c),
|
|
563
|
-
onClick: (_) => {
|
|
564
|
-
W(c), _.stopPropagation();
|
|
565
|
-
},
|
|
566
|
-
children: n.value ?? n.name ?? n.id
|
|
567
|
-
},
|
|
568
|
-
n.id
|
|
569
|
-
);
|
|
570
|
-
}) })
|
|
571
|
-
]
|
|
572
|
-
}
|
|
573
|
-
);
|
|
574
|
-
});
|
|
575
|
-
export {
|
|
576
|
-
ge as A,
|
|
577
|
-
Ce as C,
|
|
578
|
-
ye as S,
|
|
579
|
-
te as T,
|
|
580
|
-
Y as a,
|
|
581
|
-
ee as h,
|
|
582
|
-
J as i,
|
|
583
|
-
Q as l
|
|
584
|
-
};
|
package/dist/Table-CTAvN4dV.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var Ie=require("./Table.css");const e=require("react/jsx-runtime"),A=require("./classNames-DHAzUjfZ.cjs"),r=require("react"),k=require("./FiltersProvider-CnrF3xWV.cjs"),I=require("./TableColumns-BjTNomZf.cjs"),B=require("./SelectInput-BrKnfhB0.cjs"),_=require("./TableOptionsProvider-bPNtpa4V.cjs"),E=require("./TranslationProvider-BmV4WUQy.cjs"),z=require("./IconButton-DVZCHIHB.cjs"),je=require("./Badge-DSSlox-y.cjs"),H=require("./lib.cjs"),J=require("./Button-BxyXUUMe.cjs"),X=require("./Chip-N4r2Xf9l.cjs"),Z=require("./Tooltip-B7LXJBLs.cjs"),ge=require("./query-81BrXp3i.cjs"),Ce=require("./Dropdown-C5blCAyI.cjs"),Ne=require("./Loading-C70yH2dC.cjs");function K(s){const{id:t,icon:a,tooltip:n,onClick:l,children:i,hidden:p=!1,disabled:c=!1,showText:u=!1,showTooltips:o=!0,className:m=""}=s;return p?null:e.jsxs("button",{type:"button",id:t,className:A.classNames("action",u?"text-action":"icon-action",m),disabled:c,"aria-label":n,onClick:d=>{d.stopPropagation(),l?.()},"aria-disabled":c,"data-tooltip-id":"tooltip","data-tooltip-content":o?n:"",children:[a," ",u&&n,i]})}function ee(s){const{actions:t=[],className:a="",itemClassName:n="",actionClassName:l="",showTooltips:i=!0,showActionTexts:p=!1}=s;return e.jsx("ul",{className:A.classNames("actions-container",a),children:t.map(c=>e.jsx("li",{className:A.classNames("actions-container-item",n),children:e.jsx(K,{showTooltips:i,showText:p,className:l,...c})},c.id))})}const te=s=>{const{actions:t=[],className:a=""}=s,{t:n}=E.useTranslation(),[l,i]=r.useState(!1),[p,c]=r.useState(null);return e.jsxs("div",{className:A.classNames("actions-dropdown",a),children:[e.jsx(z.IconButton,{icon:e.jsx(I.Ellipsis,{}),onClick:u=>{u.stopPropagation(),c(u.currentTarget),i(o=>!o)},onMouseDown:u=>u.stopPropagation(),className:"actions-dropdown-trigger","aria-label":n("_accessibility:buttons.openActions"),name:n("_accessibility:buttons.openActions"),"data-tooltip-id":"tooltip","data-tooltip-content":n("_accessibility:buttons.openActions")}),e.jsx(Ce.Dropdown,{open:l,onClose:()=>i(!1),anchorEl:p,children:e.jsx(ee,{showActionTexts:!0,actions:t,itemClassName:"w-full",actionClassName:"action-dropdown-item",className:"actions-dropdown-list",showTooltips:!1})})]})};function Q(s,t=[]){return[...s].sort((a,n)=>(n.pos??0)-(a.pos??0)).filter(a=>a.display!=="none"&&!t.includes(a.key))}function se(s){const{t}=E.useTranslation(),{entity:a="",columns:n=[],hasAction:l=!0,onSortCallback:i,selectionState:p,onToggleAllRows:c}=s,u=r.useRef(null);r.useEffect(()=>{u.current&&(u.current.indeterminate=!!(p?.hasSomeSelected&&!p?.allSelected))},[p]);const{onSort:o,sortingOrder:m,sortingBy:d,hiddenColumns:C}=_.useTableOptions(),x=r.useMemo(()=>Q(n,C).map(b=>({id:b.key,label:b.label,renderHead:b.renderHead,className:b.className??"",sortable:b.sortable??!0,sortOptions:b.sortOptions})),[n,a,t,C]);return e.jsx("thead",{className:"table-headers-row",children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",className:"table-headers-column table-headers-checkbox",children:c?e.jsx("input",{type:"checkbox",ref:u,checked:p?.allSelected??!1,onChange:c,"aria-label":t("_accessibility:components.table.selectAllRows")}):null}),l&&e.jsx("th",{scope:"col",className:"table-headers-action",children:e.jsx("span",{children:t("_accessibility:labels.actions")})}),x.map(b=>e.jsx("th",{scope:"col",className:A.classNames("table-headers-column",b.className),children:e.jsxs(J.Button,{disabled:!b.sortable,onClick:()=>o(b.id,i),className:"table-headers-cell",children:[b.renderHead?b.renderHead():e.jsx("span",{className:"table-headers-label",children:b.label}),b.sortable&&d===b.id&&e.jsx("span",{children:m===ge.SortOrder.ASC?b.sortOptions?.icons?.asc??e.jsx(I.ChevronUp,{className:b.sortOptions?.icons?.className??"table-headers-sort-indicator"}):b.sortOptions?.icons?.desc??e.jsx(I.ChevronDown,{className:b.sortOptions?.icons?.className??"table-headers-sort-indicator"})})]})},b.id))]})})}function ne(s){const{columns:t}=s,{hiddenColumns:a,toggleColumn:n}=_.useTableOptions(),{t:l}=E.useTranslation(),[i,p]=r.useState(!1),c=r.useRef(null),u=r.useMemo(()=>Q(t.filter(d=>d.hideable!==!1&&d.display!=="none"),[]),[t]),o=r.useCallback(()=>{p(d=>!d)},[]),m=r.useCallback(d=>{n(d)},[n]);return u.length===0?null:e.jsxs("div",{className:"column-visibility-menu",ref:c,children:[e.jsx(z.IconButton,{icon:e.jsx(I.TableColumns,{className:"column-visibility-icon"}),className:"normal column-visibility-trigger","aria-haspopup":"true","aria-expanded":i,onClick:o,children:e.jsx("span",{className:"table-header-sr",children:l("_accessibility:buttons.columns")})}),i&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"column-visibility-backdrop",onClick:()=>p(!1)}),e.jsx("div",{className:"column-visibility-dropdown",role:"menu",children:u.map(d=>e.jsx(B.CheckInput,{checked:!a.includes(d.key),onChange:()=>m(d.key),label:d.label??d.key,containerClassName:"column-visibility-item"},d.key))})]})]})}const le=s=>{const{items:t,text:a,id:n,onClearFilter:l}=s;return e.jsx(X.Chip,{text:`${a}: ${t.map(i=>i.value??i.name).join(", ")}`,onDelete:()=>l(n)})},ae=s=>{const{end:t,start:a,text:n,id:l,onClearFilter:i}=s,p=c=>c!==null&&typeof c<"u"&&c!=="";return e.jsx(X.Chip,{text:`${n}: ${p(a)?a:"♾️"} - ${p(t)?t:"♾️"}`,onDelete:()=>i(l)})},ye=s=>typeof s=="object"&&s!==null&&!Array.isArray(s)&&("start"in s||"end"in s),ie=s=>{const{filtersDefinition:t}=s,a=r.useMemo(()=>{const c={};return t.forEach(u=>{c[u.propertyName]=u.label??u.propertyName}),c},[t]),{filters:n,clearFilters:l}=_.useTableOptions(),i=r.useMemo(()=>Object.keys(n),[n]),p=r.useCallback(c=>{const u=n[c];return ye(u)?e.jsx(ae,{id:c,text:a[c],start:u.start,end:u.end,onClearFilter:l}):Array.isArray(u)?e.jsx(le,{id:c,text:a[c],items:u,onClearFilter:l}):e.jsx(X.Chip,{text:`${a[c]}: ${u?.value??u?.name??u}`,onDelete:()=>l(c)})},[n,a,l]);return e.jsx("ul",{className:"active-filters-main",children:i?.map(c=>e.jsx("li",{children:p(c)},c))})};function ve(s){const{propertyName:t,label:a,placeholder:n,options:l,multiple:i=!0}=s,{currentFilters:p,setCurrentFilters:c}=k.useFilters(),u=r.useMemo(()=>{const m=p[t]?.value;return typeof m>"u"?null:m},[p,t]),o=r.useCallback(m=>{c({type:k.FiltersActions.update,toUpdate:{[t]:{value:m}}})},[t,c]);return e.jsx(B.AutocompleteInput,{value:u,label:a,options:l,multiple:i,helperTextClassName:"hidden",containerClassName:"options-widget-container",onChange:o,placeholder:n})}const we=s=>{const{propertyName:t,label:a}=s,{currentFilters:n,setCurrentFilters:l}=k.useFilters(),i=r.useMemo(()=>n[t]?.value??"",[n]),p=r.useCallback(c=>{l({type:k.FiltersActions.update,toUpdate:{[t]:{value:c.target.checked}}})},[]);return e.jsx(B.CheckInput,{label:a,checked:i??!1,onChange:p})};function Te(s){const{propertyName:t,options:a,label:n,placeholder:l}=s,{currentFilters:i,setCurrentFilters:p}=k.useFilters(),c=r.useMemo(()=>{const o=i[t]?.value;if(o===null||typeof o>"u")return a[0]?.id??"";if(typeof o=="object"&&!Array.isArray(o)){const m=o;return m.id??m.value??""}return o},[i,a,t]),u=r.useCallback(o=>{const m=a.find(d=>String(d.id)===o.target.value);p({type:k.FiltersActions.update,toUpdate:{[t]:{value:m?.id??o.target.value}}})},[a,t,p]);return e.jsx(B.SelectInput,{value:c,label:n,options:a,helperTextClassName:"hidden",containerClassName:"options-widget-container",onChange:u,placeholder:l})}const Se=s=>{const{propertyName:t,label:a,placeholder:n}=s,{currentFilters:l,setCurrentFilters:i}=k.useFilters(),p=r.useMemo(()=>l[t]?.value??"",[l]),c=r.useCallback(u=>{i({type:k.FiltersActions.update,toUpdate:{[t]:{value:u.target.value}}})},[]);return e.jsx(B.TextInput,{value:p??"",label:a,onChange:c,containerClassName:"input-widget-container",helperTextClassName:"",placeholder:n})},Y=s=>{const{propertyName:t,label:a,inputType:n}=s,{t:l}=E.useTranslation(),{currentFilters:i,setCurrentFilters:p}=k.useFilters(),c=r.useRef(null),u=r.useRef(null),o=r.useCallback(d=>{p({type:k.FiltersActions.update,toUpdate:{[t]:{value:{end:u?.current?.value??null,start:d.target.value}}}})},[]),m=r.useCallback(d=>{p({type:k.FiltersActions.update,toUpdate:{[t]:{value:{start:c?.current?.value??null,end:d.target.value}}}})},[]);return e.jsxs("div",{className:"range-widget-container",children:[e.jsx("p",{className:"text-input-label input-widget-label input-label-normal",children:a}),e.jsxs("div",{className:"range-widget-row",children:[e.jsx(B.TextInput,{value:i[t]?.value?.start??"",placeholder:l("_accessibility:components.table.filters.range.start"),type:n,ref:c,onChange:o,containerClassName:"input-widget-container",helperTextClassName:""}),e.jsx(B.TextInput,{value:i[t]?.value?.end??"",placeholder:l("_accessibility:components.table.filters.range.end"),type:n,ref:u,onChange:m,containerClassName:"input-widget-container",helperTextClassName:""})]})]})},re=s=>{switch(s.type){case H.FilterTypes.text:return e.jsx(Se,{...s});case H.FilterTypes.number:return e.jsx(Y,{...s,inputType:"number"});case H.FilterTypes.date:return e.jsx(Y,{...s,inputType:"date"});case H.FilterTypes.select:return e.jsx(Te,{...s});case H.FilterTypes.autocomplete:return e.jsx(ve,{...s});case H.FilterTypes.check:return e.jsx(we,{...s})}return e.jsx(e.Fragment,{})},oe=s=>{const{filters:t=[],show:a,handleShow:n}=s,{onFilterApply:l}=_.useTableOptions(),{currentFilters:i,setCurrentFilters:p}=k.useFilters(),{t:c}=E.useTranslation(),u=r.useRef(null);return r.useEffect(()=>{const o=({target:d})=>{u.current&&(d?.closest(".filter-dropdown-trigger")||!a||u.current.contains(d)||n(!1))},m=({code:d})=>{!a||d!=="Escape"||n(!1)};return document.addEventListener("click",o),document.addEventListener("keydown",m),()=>{document.removeEventListener("click",o),document.removeEventListener("keydown",m)}},[n,a]),e.jsx("div",{className:A.classNames("filter-dropdown-backdrop",a?"opened":"closed"),children:e.jsxs("div",{className:"filter-popup",ref:u,children:[e.jsx("div",{className:"filter-title",children:c("_accessibility:buttons.filters")}),e.jsx("ul",{className:"filter-container",children:t.map(o=>e.jsx("li",{className:"filter-container-item",children:re(o)},o.propertyName))}),e.jsx("div",{className:"filter-footer",children:e.jsxs("ul",{className:"filter-buttons-row",children:[e.jsx("li",{children:e.jsx(J.Button,{type:"button",variant:"submit",onClick:()=>p({type:k.FiltersActions.reset,filters:t}),className:"filter-dropdown-button filter-dropdown-cancel",children:c("_accessibility:buttons.clear")})}),e.jsx("li",{children:e.jsx(J.Button,{type:"button",variant:"submit",color:"primary",className:"filter-dropdown-button filter-dropdown-submit",onClick:()=>{n(!1),l(i)},children:c("_accessibility:buttons.applyFilters")})})]})})]})})},ce=()=>{const{t:s}=E.useTranslation(),{total:t,pageSize:a,pageSizes:n,currentPage:l}=_.useTableOptions(),i=(l+1)*a>t?t:(l+1)*a;return e.jsxs("div",{className:"table-navigation-sizes",children:[n[0]<t&&e.jsx(e.Fragment,{children:e.jsxs("p",{children:[l*a+1," - ",i," ",s("_accessibility:components.table.of")]})}),e.jsx("p",{children:t})]})};function ke(){const{t:s}=E.useTranslation(),{total:t,pageSize:a,currentPage:n,setCurrentPage:l}=_.useTableOptions(),i=r.useMemo(()=>{const p=Math.ceil(t/a);return Array.from({length:p},(c,u)=>({id:u,value:u+1}))},[t,a]);return e.jsxs("div",{className:"jump-to-page",children:[e.jsx("p",{children:s("_accessibility:components.table.jumpToPage")}),e.jsx(B.SelectInput,{value:n,options:i,inputClassName:"jump-to-page-input",containerClassName:"jump-to-page-input-container",helperTextClassName:"hidden",onChange:p=>l(Number(p.target.value))})]})}const ue=()=>{const{t:s}=E.useTranslation(),{total:t,pageSize:a,currentPage:n,setCurrentPage:l}=_.useTableOptions(),i=Math.ceil(t/a),p=n<i-1;return e.jsxs("div",{className:"table-navigation-pages",children:[e.jsx(z.IconButton,{icon:e.jsx(I.ChevronLeft,{className:"table-navigation-icon"}),className:"table-navigation-buttons",disabled:n===0,"aria-label":s("_accessibility:buttons.previous"),name:s("_accessibility:buttons.previous"),onClick:()=>l(n-1)}),e.jsx(z.IconButton,{icon:e.jsx(I.ChevronRight,{className:"table-navigation-icon"}),disabled:!p,className:"table-navigation-buttons",name:s("_accessibility:buttons.next"),"aria-label":s("_accessibility:buttons.next"),onClick:()=>{p&&l(n+1)}})]})};function de(){const{t:s}=E.useTranslation(),{pageSizes:t,pageSize:a,setPageSize:n}=_.useTableOptions(),l=r.useMemo(()=>t?.map(i=>({id:i,value:i})),[t]);return e.jsxs("div",{className:"page-size",children:[e.jsx("p",{children:s("_accessibility:components.table.pageSizes")}),e.jsx(B.SelectInput,{value:a,options:l,inputClassName:"page-size-input",containerClassName:"page-size-input-container",helperTextClassName:"hidden",onChange:i=>n(Number(i.target.value))})]})}function pe(){return e.jsxs("div",{className:"table-footer",children:[e.jsx(ke,{}),e.jsx(de,{}),e.jsx(ce,{}),e.jsx(ue,{})]})}const Re=s=>s,me=s=>{const{t}=E.useTranslation(),{hiddenColumns:a}=_.useTableOptions(),{columns:n,softDeleteProperty:l="deletedAt",data:i,actions:p,selectedRows:c,expandedRows:u=[],onRowSelectionChange:o,onRowExpand:m}=s,d=r.useMemo(()=>Q(n,a),[n,a]),C=r.useMemo(()=>new Map(u.map(x=>[x.rowId,x])),[u]);return i?.map(x=>{const b=c.has(x.id),y=C.get(x.id),R=!!y,P=d.length+1+(p?1:0);return e.jsxs(r.Fragment,{children:[e.jsxs("tr",{className:A.classNames("table-row",m?"expandable":"",x[l]?"deleted-class":"",b?"selected":"",R?"expanded":""),onClick:()=>m?.(x),children:[e.jsx("td",{className:"table-row-cell table-row-checkbox",children:e.jsx("input",{type:"checkbox",checked:b,onClick:v=>v.stopPropagation(),onChange:()=>o(x),"aria-label":t("_accessibility:components.table.selectRow")})}),p?e.jsx("td",{className:"w-px",children:e.jsx("div",{className:"table-row-cell-action",children:(()=>{const v=p(x).filter(g=>!g.hidden),j=v.filter(g=>g.sticky),w=v.filter(g=>!g.sticky);return e.jsxs(e.Fragment,{children:[j.map(g=>e.jsx(Z.Tooltip,{content:g.tooltip,children:e.jsx(K,{...g,onClick:()=>g.onClick(x),className:"row-table-action"})},g.id)),w.length>0&&e.jsx(te,{actions:w})]})})()})}):null,d?.map((v,j)=>{const w=x[v.key],g=v.renderBody?v.renderBody(w,x):Re(w);return e.jsx("td",{className:A.classNames("table-row-cell",j===0?"basic":"",v.className??""),children:m&&j===0?e.jsxs("div",{className:"table-row-expand-content",children:[e.jsx("span",{className:"table-row-expand-indicator","aria-hidden":!0,"data-state":R?"expanded":"collapsed",children:R?e.jsx(I.ChevronUp,{className:"table-row-expand-chevron"}):e.jsx(I.ChevronDown,{className:"table-row-expand-chevron"})}),e.jsx("div",{className:"table-row-expand-value",children:g})]}):g},v.key)})]}),R&&y?.content!==null&&typeof y?.content<"u"&&e.jsx("tr",{className:"table-row-expanded",children:e.jsx("td",{className:"table-row-expanded-cell",colSpan:P,children:e.jsx("div",{className:A.classNames("table-row-expanded-content",y.isVisible?"open":"closed"),children:e.jsx("div",{className:"table-row-expanded-inner",children:y.content})})})})]},x.id)})};function he(){const{t:s}=E.useTranslation();return e.jsx("div",{className:"table-empty",children:e.jsx("p",{children:s("_accessibility:components.table.empty")})})}const be=s=>{const{columns:t,title:a,isLoading:n,toolbar:l,filterOptions:i,canHideColumns:p=!1,canReset:c=!1}=s,{countOfFilters:u,resetTableOptions:o}=_.useTableOptions(),{t:m}=E.useTranslation(),d=r.useMemo(()=>t?[...t].sort((j,w)=>(w.pos??0)-(j.pos??0)).filter(j=>!!j.filterOptions).map(j=>({...j.filterOptions,label:j.filterOptions?.label??j.label,propertyName:j.key})):[],[t]),[C,x]=r.useState(!1),b=r.useCallback(j=>{i?.dropdown?.setOpened?i.dropdown.setOpened(j??!1):x(j??!1)},[i]),y=r.useMemo(()=>i?.dropdown?.opened??C,[i,C]),R=d.length>0,P=R&&i?.button?.hide!==!0,v=R&&y;return e.jsxs("div",{className:A.classNames("table-header",v?"showing-filters":""),children:[e.jsxs("div",{children:[a&&e.jsx("h1",{className:"table-header-title",children:a}),n?null:e.jsxs("div",{className:"table-header-content",children:[l,p&&t&&e.jsx(ne,{columns:t}),c&&e.jsx(z.IconButton,{icon:e.jsx(I.BarsStaggered,{className:"reset-table-icon"}),className:"normal",onClick:o,children:e.jsx("span",{className:"table-header-sr",children:m("_accessibility:buttons.reset")})}),P&&e.jsxs(z.IconButton,{icon:i?.button?.icon??e.jsx(I.Filters,{className:"filter-dropdown-trigger-icon"}),className:"filter-dropdown-button normal filter-dropdown-trigger","aria-haspopup":"true",onClick:()=>b(!y),"aria-expanded":y,children:[e.jsx(je.Badge,{count:u,className:A.classNames(u>0?"show":"hide")}),e.jsx("span",{className:"table-header-sr",children:m("_accessibility:buttons.filters")}),e.jsx("wbr",{})]})]})]}),R&&e.jsx(oe,{filters:d,show:v,handleShow:b,options:i}),e.jsx(ie,{filtersDefinition:d})]})};function xe({count:s,multiActions:t,onActionClick:a}){const{t:n}=E.useTranslation();return e.jsxs("div",{className:"table-selection-bar",children:[e.jsx("p",{className:"table-selection-bar-count",children:n("_accessibility:components.table.selectedCount",{count:s})}),t.length>0&&e.jsx("div",{className:"table-selection-bar-actions",children:t.map(l=>e.jsx(Z.Tooltip,{content:l.tooltip,children:e.jsx(z.IconButton,{icon:l.icon,className:"multi-table-action",onClick:()=>a(l),disabled:l.disabled,"aria-label":l.tooltip})},l.id))})]})}const G=220;function Fe({data:s,allowMultipleExpandedRows:t,controlledExpandedRowId:a,onExpandedRowChange:n,onRowExpand:l,findRowById:i}){const[p,c]=r.useState(null),[u,o]=r.useState(null),[m,d]=r.useState(null),[C,x]=r.useState(null),[b,y]=r.useState(!1),[R,P]=r.useState(new Set),[v,j]=r.useState([]),w=r.useRef(null),g=r.useRef(null),D=r.useRef(new Map),M=typeof a<"u",O=t&&!M,T=M?a??null:p,L=r.useCallback(()=>{g.current&&(clearTimeout(g.current),g.current=null)},[]),F=r.useCallback(h=>{if(typeof h<"u"){const f=D.current.get(h);if(!f)return;clearTimeout(f),D.current.delete(h);return}D.current.forEach(f=>clearTimeout(f)),D.current.clear()},[]),U=r.useCallback(h=>{F(h),j(f=>f.some(S=>S.rowId===h)?f.map(S=>S.rowId===h?{...S,isVisible:!1}:S):f),D.current.set(h,setTimeout(()=>{j(f=>f.filter(N=>N.rowId!==h)),D.current.delete(h)},G))},[F]),W=r.useCallback((h,f)=>{F(h),j(N=>N.some(q=>q.rowId===h)?N.map(q=>q.rowId===h?{...q,content:f,isVisible:!1}:q):[...N,{rowId:h,content:f,isVisible:!1}]),requestAnimationFrame(()=>{j(N=>N.map(S=>S.rowId===h?{...S,isVisible:!0}:S))})},[F]);r.useEffect(()=>{if(!O)return;const h=new Set(s.map(f=>f.id));P(f=>{const N=new Set;return f.forEach(S=>{if(h.has(S)){N.add(S);return}F(S)}),N}),j(f=>(f.forEach(N=>{h.has(N.rowId)||F(N.rowId)}),f.filter(N=>h.has(N.rowId))))},[s,O,F]),r.useEffect(()=>{if(O)return;if(T===null){o(null),M&&(w.current=null);return}i(T)||(M||c(null),o(null),M&&(w.current=null))},[s,T,i,M,O]),r.useEffect(()=>{if(!O){if(L(),T===null||u===null){if(m===null){y(!1),x(null);return}y(!1),g.current=setTimeout(()=>{d(null),x(null),g.current=null},G);return}if(m===null){d(T),x(u),requestAnimationFrame(()=>y(!0));return}if(m===T){x(u),requestAnimationFrame(()=>y(!0));return}y(!1),g.current=setTimeout(()=>{d(T),x(u),requestAnimationFrame(()=>y(!0)),g.current=null},G)}},[L,u,T,O,m]),r.useEffect(()=>()=>{L(),F()},[L,F]),r.useEffect(()=>{if(!M)return;if(T===null){o(null),w.current=null;return}const h=i(T);if(!h){o(null),w.current=null;return}const f=w.current;o(l?.(h,f)??null),w.current=h},[T,i,M,l]);const fe=r.useCallback(h=>{if(O){if(R.has(h.id)){P($=>{const V=new Set($);return V.delete(h.id),V}),U(h.id),n?.(null,h);return}P($=>{const V=new Set($);return V.add(h.id),V});const q=l?.(h,null)??null;q!==null&&typeof q<"u"?W(h.id,q):(F(h.id),j($=>$.filter(V=>V.rowId!==h.id))),n?.(h,null);return}const f=T===h.id,N=f?h:i(T);if(M){n?.(f?null:h,N);return}if(f){c(null),o(null),n?.(null,h);return}c(h.id),o(l?.(h,N)??null),n?.(h,N)},[T,U,F,W,i,R,M,O,n,l]);return{expandedRowsToRender:r.useMemo(()=>O?v:m===null||C===null||typeof C>"u"?[]:[{rowId:m,content:C,isVisible:b}],[b,O,C,m,v]),onRowExpandChange:fe}}function Ae({actions:s,selectedRowsData:t}){const a=r.useMemo(()=>!s||!t.length?[]:t.reduce((l,i,p)=>{const c=s(i).filter(o=>o.multiple&&!o.hidden);if(p===0)return c;const u=new Map(l.map(o=>[o.id,o]));return c.reduce((o,m)=>{const d=u.get(m.id);return d&&o.push({...d,...m,disabled:m.disabled||d.disabled}),o},[])},[]),[s,t]),n=r.useCallback(l=>{if(t.length){if(l.onMultipleClick){l.onMultipleClick(t);return}t.forEach(i=>l.onClick(i))}},[t]);return{multiActions:a,handleMultipleActionClick:n}}function Ee({data:s,onRowSelect:t,onSelectedRowsChange:a}){const[n,l]=r.useState(new Set),i=r.useMemo(()=>s?.filter(o=>n.has(o.id))??[],[s,n]);r.useEffect(()=>{if(!s?.length){l(new Set);return}l(o=>{const m=new Set,d=new Set(s.map(C=>C.id));return o.forEach(C=>{d.has(C)&&m.add(C)}),m})},[s]),r.useEffect(()=>{a&&a(i)},[i,a]);const p=r.useCallback(o=>{l(m=>{const d=new Set(m);return d.has(o.id)?(d.delete(o.id),t?.(o,!1)):(d.add(o.id),t?.(o,!0)),d})},[t]),c=r.useCallback(()=>{l(o=>{const m=new Set(o),d=s??[],C=d.every(x=>m.has(x.id));return d.forEach(x=>{const b=m.has(x.id);C?b&&(m.delete(x.id),t?.(x,!1)):b||(m.add(x.id),t?.(x,!0))}),m})},[s,t]),u=r.useMemo(()=>{if(!s?.length)return{allSelected:!1,hasSomeSelected:!1};const o=s.every(d=>n.has(d.id)),m=s.some(d=>n.has(d.id));return{allSelected:o,hasSomeSelected:m}},[s,n]);return{selectedRows:n,selectedRowsData:i,selectionState:u,onRowSelectionChange:p,onToggleAllRows:c}}function Me(s){const{data:t,onSort:a,entity:n="",isLoading:l=!1,actions:i,columns:p=[],contentClassName:c="",className:u="",softDeleteProperty:o="deletedAt",onRowSelect:m,onSelectedRowsChange:d,allowMultipleExpandedRows:C=!1,expandedRowId:x,onExpandedRowChange:b,onRowExpand:y,...R}=s,P=r.useMemo(()=>!t?.length,[t]),v=r.useCallback(U=>U===null?null:t.find(W=>W.id===U)??null,[t]),{selectedRows:j,selectedRowsData:w,selectionState:g,onRowSelectionChange:D,onToggleAllRows:M}=Ee({data:t,onRowSelect:m,onSelectedRowsChange:d}),{expandedRowsToRender:O,onRowExpandChange:T}=Fe({data:t,allowMultipleExpandedRows:C,controlledExpandedRowId:x,onExpandedRowChange:b,onRowExpand:y,findRowById:v}),{multiActions:L,handleMultipleActionClick:F}=Ae({actions:i,selectedRowsData:w});return e.jsx(k.FiltersProvider,{children:e.jsxs("div",{className:A.classNames("table-main",u),children:[e.jsx(be,{columns:p,isLoading:l,...R}),l?e.jsx(Ne.Loading,{className:"table-loading"}):e.jsx(e.Fragment,{children:P?e.jsx(he,{}):e.jsxs(e.Fragment,{children:[!!w.length&&e.jsx(xe,{count:w.length,multiActions:L,onActionClick:F}),e.jsx("div",{className:A.classNames("table-body",c),children:e.jsxs("table",{className:"table-content",children:[e.jsx(se,{entity:n,columns:p,onSortCallback:a,hasAction:!!i,selectionState:g,onToggleAllRows:M}),e.jsx("tbody",{children:e.jsx(me,{data:t,actions:i,columns:p,softDeleteProperty:o,selectedRows:j,expandedRows:O,onRowSelectionChange:D,onRowExpand:y?T:void 0})})]})}),e.jsx(pe,{})]})})]})})}exports.Action=K;exports.Actions=ee;exports.ActionsDropdown=te;exports.ActiveFilters=ie;exports.ArrayChip=le;exports.ColumnVisibilityMenu=ne;exports.Columns=se;exports.CountOfTotal=ce;exports.FilterDropdown=oe;exports.Footer=pe;exports.Navigation=ue;exports.PageSize=de;exports.RangeChip=ae;exports.Rows=me;exports.Table=Me;exports.TableEmpty=he;exports.TableHeader=be;exports.TableSelectionBar=xe;exports.renderFilterComponent=re;
|