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