laif-ds 0.2.42 → 0.2.43

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