laif-ds 0.2.23 → 0.2.24

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.
Files changed (44) hide show
  1. package/dist/components/ui/alert-dialog.js +6 -6
  2. package/dist/components/ui/app-multiple-select-dropdown.js +34 -34
  3. package/dist/components/ui/app-select.js +127 -124
  4. package/dist/components/ui/badge.js +13 -12
  5. package/dist/components/ui/button.js +20 -18
  6. package/dist/components/ui/calendar.js +6 -6
  7. package/dist/components/ui/checkbox.js +9 -9
  8. package/dist/components/ui/confirmer.js +45 -19
  9. package/dist/components/ui/context-menu.js +4 -4
  10. package/dist/components/ui/input-otp.js +16 -16
  11. package/dist/components/ui/input-selector.js +19 -19
  12. package/dist/components/ui/input.js +19 -19
  13. package/dist/components/ui/menubar.js +1 -1
  14. package/dist/components/ui/pagination.js +90 -77
  15. package/dist/components/ui/radio-group.js +14 -14
  16. package/dist/components/ui/select.js +27 -27
  17. package/dist/components/ui/switch.js +8 -6
  18. package/dist/components/ui/table.js +16 -16
  19. package/dist/components/ui/tables/data-cross-table/data-cross-table.js +6 -6
  20. package/dist/components/ui/tables/data-table/components/data-table-actions.js +51 -0
  21. package/dist/components/ui/tables/data-table/components/data-table-advanced-filter.js +470 -0
  22. package/dist/components/ui/tables/data-table/components/data-table-body.js +340 -0
  23. package/dist/components/ui/tables/data-table/components/data-table-column-visibility.js +274 -0
  24. package/dist/components/ui/tables/data-table/components/data-table-filter-inputs.js +177 -0
  25. package/dist/components/ui/tables/data-table/components/data-table-filters.js +286 -0
  26. package/dist/components/ui/tables/data-table/components/data-table-pagination.js +131 -0
  27. package/dist/components/ui/tables/data-table/components/data-table-searchbar.js +112 -0
  28. package/dist/components/ui/tables/data-table/components/data-table-simple-filters.js +263 -0
  29. package/dist/components/ui/tables/data-table/components/data-table-sorting.js +128 -0
  30. package/dist/components/ui/tables/data-table/data-table-constants.js +58 -0
  31. package/dist/components/ui/tables/data-table/data-table-i18n.js +138 -0
  32. package/dist/components/ui/tables/data-table/data-table.js +549 -0
  33. package/dist/components/ui/tables/data-table/data-table.service.js +254 -0
  34. package/dist/components/ui/tabs.js +33 -33
  35. package/dist/components/ui/textarea.js +11 -11
  36. package/dist/components/ui/tooltip.js +10 -10
  37. package/dist/css-for-template.css +57 -0
  38. package/dist/index.d.ts +245 -75
  39. package/dist/index.js +64 -64
  40. package/dist/styles.css +1 -1
  41. package/dist/styles.v3.css +1 -1
  42. package/package.json +5 -3
  43. package/dist/components/ui/data-table.js +0 -461
  44. package/dist/components/ui/data-table.service.js +0 -62
@@ -0,0 +1,51 @@
1
+ "use client";
2
+ import { jsx as t, jsxs as i } from "react/jsx-runtime";
3
+ import { Button as n } from "../../../button.js";
4
+ import { Popover as r, PopoverTrigger as s, PopoverContent as a } from "../../../popover.js";
5
+ function x({
6
+ actions: l,
7
+ i18n: o
8
+ }) {
9
+ if (!l?.length) return null;
10
+ if (l.length === 1) {
11
+ const [e] = l;
12
+ return /* @__PURE__ */ t(
13
+ n,
14
+ {
15
+ size: "sm",
16
+ iconLeft: e.icon,
17
+ variant: "default",
18
+ onClick: e.onClick,
19
+ className: "h-6 max-h-6 text-xs",
20
+ children: e.label
21
+ }
22
+ );
23
+ }
24
+ return /* @__PURE__ */ i(r, { children: [
25
+ /* @__PURE__ */ t(s, { asChild: !0, children: /* @__PURE__ */ t(
26
+ n,
27
+ {
28
+ size: "sm",
29
+ iconRight: "ChevronDown",
30
+ variant: "default",
31
+ className: "h-6 max-h-6 !px-2 text-xs",
32
+ children: o.tableActions.actions
33
+ }
34
+ ) }),
35
+ /* @__PURE__ */ t(a, { side: "top", className: "flex w-auto flex-col p-2", children: l.map((e) => /* @__PURE__ */ t(
36
+ n,
37
+ {
38
+ variant: "ghost",
39
+ iconLeft: e.icon,
40
+ size: "sm",
41
+ onClick: e.onClick,
42
+ className: "justify-start text-xs",
43
+ children: e.label
44
+ },
45
+ e.label
46
+ )) })
47
+ ] });
48
+ }
49
+ export {
50
+ x as DataTableActionsComponent
51
+ };
@@ -0,0 +1,470 @@
1
+ "use client";
2
+ import { jsxs as m, jsx as o, Fragment as T } from "react/jsx-runtime";
3
+ import { useState as P } from "react";
4
+ import { AppSelect as O } from "../../../app-select.js";
5
+ import { Button as x } from "../../../button.js";
6
+ import { Popover as G, PopoverTrigger as L, PopoverContent as R } from "../../../popover.js";
7
+ import { errorSelectClass as y, getListMultiSelectFilterOptions as k, getListSingleSelectFilterOptions as V, getDateTimeFilterOptions as q, getDateFilterOptions as B, getBooleanFilterOptions as E, getNumberFilterOptions as M, getStringFilterOptions as $ } from "../data-table-constants.js";
8
+ import { FilterValueInput as H } from "./data-table-filter-inputs.js";
9
+ import { cn as J } from "../../../../../lib/utils.js";
10
+ function u() {
11
+ return Math.random().toString(36).substr(2, 9);
12
+ }
13
+ function A({
14
+ onDelete: s,
15
+ onDuplicate: e,
16
+ type: d,
17
+ i18n: i
18
+ }) {
19
+ return /* @__PURE__ */ m(G, { children: [
20
+ /* @__PURE__ */ o(L, { asChild: !0, children: /* @__PURE__ */ o(
21
+ x,
22
+ {
23
+ variant: "ghost",
24
+ iconLeft: "Ellipsis",
25
+ size: "sm",
26
+ className: "size-7"
27
+ }
28
+ ) }),
29
+ /* @__PURE__ */ m(R, { side: "right", className: "flex w-auto flex-col p-1", children: [
30
+ /* @__PURE__ */ o(
31
+ x,
32
+ {
33
+ className: "justify-start text-xs",
34
+ variant: "ghost-destructive",
35
+ iconLeft: "Trash2",
36
+ size: "sm",
37
+ onClick: s,
38
+ children: d === "condition" ? i.filters.deleteCondition : i.filters.deleteGroup
39
+ }
40
+ ),
41
+ /* @__PURE__ */ o(
42
+ x,
43
+ {
44
+ className: "justify-start text-xs",
45
+ variant: "ghost",
46
+ iconLeft: "Copy",
47
+ size: "sm",
48
+ onClick: e,
49
+ children: d === "condition" ? i.filters.duplicateCondition : i.filters.duplicateGroup
50
+ }
51
+ )
52
+ ] })
53
+ ] });
54
+ }
55
+ function S(s, e) {
56
+ switch (s) {
57
+ case "string":
58
+ return $(e);
59
+ case "number":
60
+ return M(e);
61
+ case "boolean":
62
+ return E(e);
63
+ case "date":
64
+ return B(e);
65
+ case "datetime":
66
+ return q(e);
67
+ case "list_single_select":
68
+ return V(e);
69
+ case "list_multi_select":
70
+ return k(e);
71
+ default:
72
+ return [];
73
+ }
74
+ }
75
+ function K({
76
+ condition: s,
77
+ columns: e,
78
+ onUpdate: d,
79
+ onRemove: i,
80
+ onDuplicate: w,
81
+ showLogicalOperator: h = !1,
82
+ logicalOperator: p = "AND",
83
+ onLogicalOperatorChange: n,
84
+ isFirstInGroup: g = !1,
85
+ isSecondInGroup: C = !1,
86
+ i18n: c
87
+ }) {
88
+ const v = e.find((r) => r.id === s.columnId), D = v ? S(
89
+ v.column.columnDef.meta?.type,
90
+ c
91
+ ) : [], F = () => {
92
+ if (!v) return null;
93
+ const r = v.column.columnDef.meta?.type, f = s.value === void 0 || typeof s.value == "string" && s.value === "" || r === "list_multi_select" && !Array.isArray(s.value);
94
+ return /* @__PURE__ */ o(
95
+ H,
96
+ {
97
+ columnType: r,
98
+ value: s.value,
99
+ onChange: (N) => d({ ...s, value: N }),
100
+ listOptions: v.column.columnDef.meta?.listOptions ?? [],
101
+ placeholder: c.filters.value,
102
+ operator: s.operator,
103
+ size: "sm",
104
+ className: r === "list_single_select" || r === "list_multi_select" ? "w-52" : "",
105
+ hasError: f
106
+ }
107
+ );
108
+ };
109
+ return /* @__PURE__ */ m("div", { className: "flex min-w-0 flex-1 items-center gap-2 rounded-md", children: [
110
+ /* @__PURE__ */ m("div", { className: "flex min-w-0 flex-1 items-center gap-2 overflow-x-auto overflow-y-clip", children: [
111
+ h && n && /* @__PURE__ */ o(T, { children: C ? /* @__PURE__ */ o(
112
+ O,
113
+ {
114
+ size: "sm",
115
+ className: `w-[72px] min-w-[72px] ${p === void 0 ? y : ""}`,
116
+ options: [
117
+ { value: "AND", label: c.filters.and },
118
+ { value: "OR", label: c.filters.or }
119
+ ],
120
+ value: p,
121
+ onValueChange: (r) => n(r)
122
+ }
123
+ ) : /* @__PURE__ */ o("span", { className: "text-muted-foreground w-[72px] min-w-[72px] text-right text-xs", children: p }) }),
124
+ g && /* @__PURE__ */ o("span", { className: "text-muted-foreground w-[72px] min-w-[72px] text-right text-xs", children: c.filters.where }),
125
+ /* @__PURE__ */ o(
126
+ O,
127
+ {
128
+ size: "sm",
129
+ placeholder: c.filters.column,
130
+ className: s.columnId === void 0 || s.columnId === "" ? y : "",
131
+ options: e.map((r) => ({
132
+ value: r.id,
133
+ label: r.column.columnDef.header?.toString() ?? ""
134
+ })),
135
+ value: s.columnId || void 0,
136
+ onValueChange: (r) => {
137
+ if (r) {
138
+ const f = e.find((N) => N.id === r);
139
+ if (f) {
140
+ const N = S(
141
+ f.column.columnDef.meta?.type,
142
+ c
143
+ )[0]?.value;
144
+ d({
145
+ ...s,
146
+ columnId: String(r),
147
+ columnLabel: f.column.columnDef.header?.toString() ?? "",
148
+ columnType: f.column.columnDef.meta?.type,
149
+ operator: String(N || "eq"),
150
+ value: void 0
151
+ });
152
+ }
153
+ }
154
+ }
155
+ }
156
+ ),
157
+ s.columnId && /* @__PURE__ */ o(
158
+ O,
159
+ {
160
+ size: "sm",
161
+ placeholder: c.filters.operator,
162
+ className: s.operator === void 0 ? y : "",
163
+ options: D,
164
+ value: s.operator || void 0,
165
+ onValueChange: (r) => {
166
+ r && d({
167
+ ...s,
168
+ operator: String(r)
169
+ });
170
+ }
171
+ }
172
+ ),
173
+ F()
174
+ ] }),
175
+ /* @__PURE__ */ o(
176
+ A,
177
+ {
178
+ type: "condition",
179
+ onDelete: i,
180
+ onDuplicate: w,
181
+ i18n: c
182
+ }
183
+ )
184
+ ] });
185
+ }
186
+ function _({
187
+ className: s,
188
+ group: e,
189
+ columns: d,
190
+ onUpdate: i,
191
+ isRoot: w = !1,
192
+ depth: h,
193
+ maxNestedDepth: p = 2,
194
+ i18n: n
195
+ }) {
196
+ const g = {
197
+ id: u(),
198
+ columnId: "",
199
+ columnLabel: "",
200
+ columnType: "string",
201
+ operator: "eq",
202
+ value: void 0
203
+ }, C = {
204
+ id: u(),
205
+ logicalOperator: "AND",
206
+ conditions: [
207
+ {
208
+ id: u(),
209
+ columnId: "",
210
+ columnLabel: "",
211
+ columnType: "string",
212
+ operator: "eq",
213
+ value: void 0
214
+ }
215
+ ],
216
+ groups: []
217
+ }, c = () => {
218
+ i({
219
+ ...e,
220
+ conditions: [...e.conditions, g]
221
+ });
222
+ }, v = () => {
223
+ i({
224
+ ...e,
225
+ groups: [...e.groups || [], C]
226
+ });
227
+ }, D = (l, t) => {
228
+ i({
229
+ ...e,
230
+ conditions: e.conditions.map(
231
+ (a) => a.id === l ? t : a
232
+ )
233
+ });
234
+ }, F = (l) => {
235
+ const t = e.conditions.findIndex((I) => I.id === l);
236
+ if (t === -1) return;
237
+ const b = {
238
+ ...e.conditions[t],
239
+ id: u()
240
+ };
241
+ i({
242
+ ...e,
243
+ conditions: [
244
+ ...e.conditions.slice(0, t + 1),
245
+ b,
246
+ ...e.conditions.slice(t + 1)
247
+ ]
248
+ });
249
+ }, r = (l) => {
250
+ i({
251
+ ...e,
252
+ conditions: e.conditions.filter((t) => t.id !== l)
253
+ });
254
+ }, f = (l, t) => {
255
+ i({
256
+ ...e,
257
+ groups: (e.groups || []).map(
258
+ (a) => a.id === l ? t : a
259
+ )
260
+ });
261
+ }, N = (l) => {
262
+ i({
263
+ ...e,
264
+ groups: (e.groups || []).filter((t) => t.id !== l)
265
+ });
266
+ }, z = (l) => ({
267
+ id: u(),
268
+ logicalOperator: l.logicalOperator,
269
+ conditions: l.conditions.map((t) => ({
270
+ ...t,
271
+ id: u()
272
+ })),
273
+ groups: (l.groups || []).map((t) => z(t))
274
+ }), j = (l) => {
275
+ const t = e.groups || [], a = t.findIndex((I) => I.id === l);
276
+ if (a === -1) return;
277
+ const b = z(t[a]);
278
+ i({
279
+ ...e,
280
+ groups: [...t.slice(0, a + 1), b, ...t.slice(a + 1)]
281
+ });
282
+ };
283
+ return /* @__PURE__ */ m(
284
+ "div",
285
+ {
286
+ className: J(
287
+ "min-w-0 space-y-2 overflow-auto",
288
+ w ? "" : "bg-d-foreground/5 border-d-foreground rounded border-l-2 p-2 pl-3",
289
+ s
290
+ ),
291
+ children: [
292
+ e.conditions.map((l, t) => /* @__PURE__ */ o(
293
+ K,
294
+ {
295
+ condition: l,
296
+ columns: d,
297
+ onUpdate: (a) => D(l.id, a),
298
+ onRemove: () => r(l.id),
299
+ onDuplicate: () => F(l.id),
300
+ showLogicalOperator: t > 0,
301
+ logicalOperator: e.logicalOperator,
302
+ onLogicalOperatorChange: (a) => i({ ...e, logicalOperator: a }),
303
+ isFirstInGroup: t === 0,
304
+ isSecondInGroup: t === 1,
305
+ i18n: n
306
+ },
307
+ l.id
308
+ )),
309
+ (e.groups || []).map((l, t) => /* @__PURE__ */ m(
310
+ "div",
311
+ {
312
+ className: "flex min-w-0 flex-1 flex-row gap-2",
313
+ children: [
314
+ t === 1 && e.conditions.length === 0 || t === 0 && e.conditions.length === 1 ? /* @__PURE__ */ o(
315
+ O,
316
+ {
317
+ className: `w-[72px] min-w-[72px] ${e.logicalOperator === void 0 ? y : ""}`,
318
+ size: "sm",
319
+ options: [
320
+ { value: "AND", label: n.filters.and },
321
+ { value: "OR", label: n.filters.or }
322
+ ],
323
+ value: e.logicalOperator,
324
+ onValueChange: (a) => i({
325
+ ...e,
326
+ logicalOperator: a
327
+ })
328
+ }
329
+ ) : t === 0 && e.conditions.length === 0 ? /* @__PURE__ */ o("span", { className: "text-muted-foreground w-[72px] text-right text-xs", children: n.filters.where }) : /* @__PURE__ */ o("span", { className: "text-muted-foreground w-[72px] text-right text-xs", children: e.logicalOperator }),
330
+ /* @__PURE__ */ o(
331
+ _,
332
+ {
333
+ className: "flex flex-1 flex-col",
334
+ group: l,
335
+ columns: d,
336
+ onUpdate: (a) => f(l.id, a),
337
+ depth: h + 1,
338
+ maxNestedDepth: p,
339
+ i18n: n
340
+ }
341
+ ),
342
+ /* @__PURE__ */ o(
343
+ A,
344
+ {
345
+ type: "group",
346
+ onDelete: () => N(l.id),
347
+ onDuplicate: () => j(l.id),
348
+ i18n: n
349
+ }
350
+ )
351
+ ]
352
+ },
353
+ l.id
354
+ )),
355
+ h < p ? /* @__PURE__ */ m(G, { children: [
356
+ /* @__PURE__ */ o(L, { asChild: !0, children: /* @__PURE__ */ o(
357
+ x,
358
+ {
359
+ variant: "ghost",
360
+ size: "sm",
361
+ className: "w-full justify-start text-xs",
362
+ iconLeft: "Plus",
363
+ iconRight: "ChevronDown",
364
+ children: n.filters.addFilterRule
365
+ }
366
+ ) }),
367
+ /* @__PURE__ */ m(R, { side: "top", className: "flex w-auto flex-col p-1", children: [
368
+ /* @__PURE__ */ o(
369
+ x,
370
+ {
371
+ variant: "ghost",
372
+ size: "sm",
373
+ className: "justify-start text-xs",
374
+ iconLeft: "Plus",
375
+ onClick: c,
376
+ children: n.filters.addFilterRule
377
+ }
378
+ ),
379
+ /* @__PURE__ */ o(
380
+ x,
381
+ {
382
+ variant: "ghost",
383
+ size: "sm",
384
+ className: "justify-start text-xs",
385
+ iconLeft: "CopyPlus",
386
+ onClick: v,
387
+ children: n.filters.addFilterGroup
388
+ }
389
+ )
390
+ ] })
391
+ ] }) : /* @__PURE__ */ o(
392
+ x,
393
+ {
394
+ variant: "ghost",
395
+ size: "sm",
396
+ className: "w-full justify-start text-xs",
397
+ iconLeft: "Plus",
398
+ onClick: c,
399
+ children: n.filters.addFilterRule
400
+ }
401
+ )
402
+ ]
403
+ }
404
+ );
405
+ }
406
+ function le({
407
+ columns: s,
408
+ onFilterChange: e,
409
+ initialFilter: d,
410
+ i18n: i
411
+ }) {
412
+ const [w, h] = P(
413
+ d || {
414
+ id: u(),
415
+ rootGroup: {
416
+ id: u(),
417
+ logicalOperator: "AND",
418
+ conditions: [],
419
+ groups: []
420
+ }
421
+ }
422
+ ), p = (g) => {
423
+ const C = {
424
+ ...w,
425
+ rootGroup: g
426
+ };
427
+ h(C), e(C);
428
+ }, n = () => {
429
+ const g = {
430
+ id: u(),
431
+ rootGroup: {
432
+ id: u(),
433
+ logicalOperator: "AND",
434
+ conditions: [],
435
+ groups: []
436
+ }
437
+ };
438
+ h(g), e(null);
439
+ };
440
+ return /* @__PURE__ */ m("div", { className: "flex max-h-[500px] min-w-0 flex-col gap-0.5 overflow-auto", children: [
441
+ /* @__PURE__ */ o(
442
+ _,
443
+ {
444
+ className: "flex flex-1 flex-col",
445
+ group: w.rootGroup,
446
+ columns: s,
447
+ onUpdate: p,
448
+ isRoot: !0,
449
+ depth: 0,
450
+ maxNestedDepth: 2,
451
+ i18n: i
452
+ }
453
+ ),
454
+ /* @__PURE__ */ o("div", { className: "border-d-border w-full border-b" }),
455
+ /* @__PURE__ */ o(
456
+ x,
457
+ {
458
+ variant: "ghost-destructive",
459
+ size: "sm",
460
+ onClick: n,
461
+ className: "w-full justify-start text-xs",
462
+ iconRight: "Trash2",
463
+ children: i.filters.deleteFilter
464
+ }
465
+ )
466
+ ] });
467
+ }
468
+ export {
469
+ le as DataTableAdvancedFilterComponent
470
+ };