laif-ds 0.1.82 → 0.1.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.
@@ -1,31 +1,31 @@
1
1
  "use client";
2
2
  import { jsx as n, jsxs as h } from "react/jsx-runtime";
3
3
  import { useReactTable as ce, flexRender as $ } from "../../node_modules/@tanstack/react-table/build/lib/index.js";
4
- import { useState as m, useRef as G, useMemo as se, useEffect as R } from "react";
4
+ import { useRef as G, useState as m, useMemo as se, useEffect as R } from "react";
5
5
  import { cn as re } from "../../lib/utils.js";
6
6
  import { createCustomFilterFns as de, ELogicalFilterOperator as me, debounce as ue, createMultiValueFilterFn as fe, updatePageSizeFromContainer as he } from "./data-table.service.js";
7
- import { Pagination as pe, PaginationContent as xe, PaginationItem as w, PaginationFirst as Ce, PaginationPrevious as be, PaginationLink as we, PaginationNext as Pe, PaginationLast as Se } from "./pagination.js";
7
+ import { Pagination as pe, PaginationContent as xe, PaginationItem as b, PaginationFirst as we, PaginationPrevious as Ce, PaginationLink as be, PaginationNext as Pe, PaginationLast as Se } from "./pagination.js";
8
8
  import { Checkbox as E } from "./checkbox.js";
9
9
  import { Input as Ie } from "./input.js";
10
10
  import { ScrollArea as W, ScrollBar as F } from "./scroll-area.js";
11
11
  import { AppMultipleSelectDropdown as Re } from "./app-multiple-select-dropdown.js";
12
- import { Table as ze, TableHeader as Ne, TableRow as z, TableHead as Me, TableBody as ye, TableCell as H } from "./table.js";
12
+ import { Table as Ne, TableHeader as Me, TableRow as N, TableHead as ze, TableBody as ye, TableCell as H } from "./table.js";
13
13
  import { Skeleton as ke } from "./skeleton.js";
14
- import { getPaginationRowModel as Fe, getFilteredRowModel as He, getSortedRowModel as De, getCoreRowModel as ve } from "../../node_modules/@tanstack/table-core/build/lib/index.js";
14
+ import { getPaginationRowModel as Fe, getFilteredRowModel as He, getSortedRowModel as De, getCoreRowModel as Ve } from "../../node_modules/@tanstack/table-core/build/lib/index.js";
15
15
  function Ue({
16
16
  columns: P,
17
17
  data: D,
18
- loading: J = !1,
19
- emptyComponent: _,
18
+ loading: _ = !1,
19
+ emptyComponent: J,
20
20
  className: K,
21
21
  rowSelection: q = {},
22
- onRowSelectionChange: v,
22
+ onRowSelectionChange: V,
23
23
  checkable: S = !1,
24
- onCheckedRowsChange: N,
24
+ onCheckedRowsChange: M,
25
25
  notFoundMessage: Q = "Nessun risultato trovato.",
26
26
  searchBar: u = void 0,
27
27
  dropdownFilters: d = void 0,
28
- totalItems: M = void 0,
28
+ totalItems: z = void 0,
29
29
  datatableSizes: p = {
30
30
  rowHeight: 32.5,
31
31
  // default table row height in pixels
@@ -38,10 +38,10 @@ function Ue({
38
38
  serverOptions: r = void 0,
39
39
  setServerOptions: g = void 0
40
40
  }) {
41
- const [U, X] = m([]), [Y, Z] = m([]), [B, O] = m({}), [b, ee] = m(""), [te, ne] = m({}), V = v ? q : te, ie = v || ne, [I, le] = m({}), c = !!r, [C, y] = m({
41
+ const y = G(null), v = G(void 0), [U, X] = m([]), [Y, Z] = m([]), [B, O] = m({}), [C, ee] = m(""), [w, k] = m({
42
42
  pageIndex: 0,
43
43
  pageSize: 10
44
- }), [ae, j] = m(0), k = G(null), L = G(void 0), oe = se(() => S ? [
44
+ }), [te, j] = m(0), [ne, ie] = m({}), L = V ? q : ne, le = V || ie, [I, ae] = m({}), c = !!r, oe = se(() => S ? [
45
45
  {
46
46
  id: "select",
47
47
  header: ({ table: e }) => /* @__PURE__ */ n(
@@ -75,15 +75,15 @@ function Ue({
75
75
  }), ge = {
76
76
  data: D,
77
77
  columns: oe,
78
- getCoreRowModel: ve(),
78
+ getCoreRowModel: Ve(),
79
79
  onSortingChange: X,
80
80
  getSortedRowModel: De(),
81
81
  onColumnVisibilityChange: O,
82
- onRowSelectionChange: ie,
82
+ onRowSelectionChange: le,
83
83
  getFilteredRowModel: He(),
84
- globalFilterFn: (e, t, l) => c || !l ? !0 : u?.columns.some((a) => {
85
- const o = e.getValue(a);
86
- return String(o).toLowerCase().includes(l.toLowerCase());
84
+ globalFilterFn: (e, t, l) => c || !l ? !0 : u?.columns.some((o) => {
85
+ const a = e.getValue(o);
86
+ return String(a).toLowerCase().includes(l.toLowerCase());
87
87
  }) ?? !1,
88
88
  filterFns: {
89
89
  multiValue: (e, t, l) => fe(
@@ -96,46 +96,46 @@ function Ue({
96
96
  ...de(d ?? [], r)
97
97
  },
98
98
  onPaginationChange: (e) => {
99
- c ? typeof e == "object" && g && g((t) => ({
99
+ c ? typeof e == "object" && g && g?.((t) => ({
100
100
  ...t,
101
101
  pagination: {
102
- pageIndex: e.pageIndex,
103
- pageSize: e.pageSize
102
+ ...t.pagination,
103
+ pageIndex: e.pageIndex
104
104
  }
105
- })) : y(e);
105
+ })) : k(e);
106
106
  },
107
107
  getPaginationRowModel: Fe(),
108
108
  manualPagination: c,
109
- pageCount: ae,
109
+ pageCount: te,
110
110
  state: {
111
111
  sorting: U,
112
112
  columnFilters: Y,
113
113
  columnVisibility: B,
114
- rowSelection: V,
115
- globalFilter: b,
116
- pagination: r?.pagination ?? C
114
+ rowSelection: L,
115
+ globalFilter: C,
116
+ pagination: r?.pagination ?? w
117
117
  }
118
118
  }, i = ce(ge);
119
119
  R(() => {
120
120
  let e;
121
- if (u && b && (e || (e = {}), e.searchbarFilters = {
122
- value: b,
121
+ if (u && C && (e || (e = {}), e.searchbarFilters = {
122
+ value: C,
123
123
  columns: u.columns
124
124
  }), d && Object.keys(I).length > 0) {
125
- const o = {};
125
+ const a = {};
126
126
  for (const s of d) {
127
127
  const f = I[s.column];
128
- f && f.length > 0 && (o[s.column] = {
128
+ f && f.length > 0 && (a[s.column] = {
129
129
  column: s.column,
130
130
  value: f,
131
131
  logic: s.innerFiltersMode || me.OR
132
132
  });
133
133
  }
134
- Object.keys(o).length > 0 && (e || (e = {}), e.dropdownFilters = o);
134
+ Object.keys(a).length > 0 && (e || (e = {}), e.dropdownFilters = a);
135
135
  }
136
- const t = L.current, l = e;
137
- JSON.stringify(t ?? {}) !== JSON.stringify(l ?? {}) && g && (L.current = l, g((o) => ({
138
- ...o,
136
+ const t = v.current, l = e;
137
+ JSON.stringify(t ?? {}) !== JSON.stringify(l ?? {}) && g && (v.current = l, g((a) => ({
138
+ ...a,
139
139
  pagination: {
140
140
  pageIndex: 0,
141
141
  pageSize: r?.pagination.pageSize ?? 10
@@ -146,7 +146,7 @@ function Ue({
146
146
  d,
147
147
  I,
148
148
  u,
149
- b,
149
+ C,
150
150
  r,
151
151
  g
152
152
  ]);
@@ -155,47 +155,50 @@ function Ue({
155
155
  if (c)
156
156
  j(
157
157
  Math.ceil(
158
- (M ?? 0) / (r.pagination?.pageSize || C.pageSize || 10)
158
+ (z ?? 0) / (r.pagination?.pageSize || w.pageSize || 10)
159
159
  )
160
160
  );
161
161
  else {
162
162
  const e = T.rows.length;
163
- j(Math.ceil(e / C.pageSize));
163
+ j(Math.ceil(e / w.pageSize));
164
164
  }
165
165
  }, [
166
166
  c,
167
- M,
168
- r?.pagination,
167
+ z,
168
+ r?.pagination.pageSize,
169
+ r?.pagination.pageIndex,
169
170
  i,
170
171
  T,
171
- C.pageSize
172
+ w.pageSize
172
173
  ]), R(() => {
173
174
  const e = ue(() => {
174
- const t = k.current;
175
+ const t = y.current;
175
176
  t && he(t, {
176
177
  rowHeight: p.rowHeight,
177
178
  headerHeight: p.headerHeight,
178
179
  containerHeight: p.containerHeight,
179
- onPageChange: c ? (l, a) => {
180
- g?.((o) => ({
181
- ...o,
182
- pagination: { pageIndex: l, pageSize: a }
180
+ onPageChange: c ? (l, o) => {
181
+ g?.((a) => ({
182
+ ...a,
183
+ pagination: {
184
+ ...a.pagination,
185
+ pageIndex: l
186
+ }
183
187
  }));
184
- } : (l, a) => {
185
- y({ pageIndex: l, pageSize: a });
188
+ } : (l, o) => {
189
+ k({ pageIndex: l, pageSize: o });
186
190
  },
187
191
  setPagination: (l) => {
188
- const a = typeof l == "function" ? l({ pageIndex: 0, pageSize: 10 }) : l;
189
- c ? g?.((o) => ({
190
- ...o,
192
+ const o = typeof l == "function" ? l({ pageIndex: 0, pageSize: 10 }) : l;
193
+ c ? g?.((a) => ({
194
+ ...a,
191
195
  pagination: {
192
- ...o.pagination,
193
- pageIndex: a.pageIndex,
194
- pageSize: a.pageSize
196
+ ...a.pagination,
197
+ pageIndex: o.pageIndex
195
198
  }
196
- })) : y({
197
- pageIndex: a.pageIndex,
198
- pageSize: a.pageSize
199
+ })) : k({
200
+ pageIndex: o.pageIndex,
201
+ pageSize: o.pageSize
199
202
  });
200
203
  }
201
204
  });
@@ -208,15 +211,15 @@ function Ue({
208
211
  p.containerHeight,
209
212
  p.headerHeight,
210
213
  p.rowHeight,
211
- k,
214
+ y,
212
215
  g
213
216
  // should be stable, but include for clarity
214
217
  ]), R(() => {
215
- if (N && S) {
218
+ if (M && S) {
216
219
  const e = i.getFilteredSelectedRowModel().rows.map((t) => t.original);
217
- N(e);
220
+ M(e);
218
221
  }
219
- }, [i, N, S, V]), /* @__PURE__ */ h(
222
+ }, [i, M, S, L]), /* @__PURE__ */ h(
220
223
  "div",
221
224
  {
222
225
  className: re(
@@ -230,7 +233,7 @@ function Ue({
230
233
  {
231
234
  iconLeft: "Search",
232
235
  placeholder: u.placeholder ?? "Cerca...",
233
- value: b,
236
+ value: C,
234
237
  onChange: (e) => {
235
238
  ee(e.target.value);
236
239
  },
@@ -249,17 +252,17 @@ function Ue({
249
252
  value: l,
250
253
  placeholder: e.placeholder,
251
254
  label: e.label,
252
- onChange: (a) => {
253
- le((o) => ({
254
- ...o,
255
- [e.column]: a
256
- })), Z((o) => {
257
- const s = o.filter(
255
+ onChange: (o) => {
256
+ ae((a) => ({
257
+ ...a,
258
+ [e.column]: o
259
+ })), Z((a) => {
260
+ const s = a.filter(
258
261
  (f) => f.id !== e.column
259
262
  );
260
- return a.length === 0 ? s : [
263
+ return o.length === 0 ? s : [
261
264
  ...s,
262
- { id: e.column, value: a }
265
+ { id: e.column, value: o }
263
266
  ];
264
267
  });
265
268
  }
@@ -273,13 +276,13 @@ function Ue({
273
276
  "div",
274
277
  {
275
278
  className: "flex max-h-full min-h-0 max-w-full min-w-0 flex-1",
276
- ref: k,
279
+ ref: y,
277
280
  children: /* @__PURE__ */ h(W, { className: "border-d-border h-full min-h-0 w-full rounded-md border", children: [
278
281
  /* @__PURE__ */ n(F, { orientation: "horizontal" }),
279
282
  /* @__PURE__ */ n(F, { orientation: "vertical" }),
280
- /* @__PURE__ */ h(ze, { children: [
281
- /* @__PURE__ */ n(Ne, { children: i.getHeaderGroups().map((e) => /* @__PURE__ */ n(z, { children: e.headers.map((t) => /* @__PURE__ */ n(
282
- Me,
283
+ /* @__PURE__ */ h(Ne, { children: [
284
+ /* @__PURE__ */ n(Me, { children: i.getHeaderGroups().map((e) => /* @__PURE__ */ n(N, { children: e.headers.map((t) => /* @__PURE__ */ n(
285
+ ze,
283
286
  {
284
287
  className: `bg-d-secondary sticky top-0 z-10 ${t.column.columnDef.sticky ? "left-0" : ""}`,
285
288
  children: t.isPlaceholder ? null : $(
@@ -289,15 +292,15 @@ function Ue({
289
292
  },
290
293
  t.id
291
294
  )) }, e.id)) }),
292
- /* @__PURE__ */ n(ye, { children: J ? Array.from({ length: D.length || 8 }).map((e, t) => /* @__PURE__ */ n(z, { children: i.getHeaderGroups()[0].headers.map((l, a) => /* @__PURE__ */ n(
295
+ /* @__PURE__ */ n(ye, { children: _ ? Array.from({ length: D.length || 8 }).map((e, t) => /* @__PURE__ */ n(N, { children: i.getHeaderGroups()[0].headers.map((l, o) => /* @__PURE__ */ n(
293
296
  H,
294
297
  {
295
298
  className: `w-full ${l.column.columnDef.sticky ? "bg-d-background sticky left-0 z-10" : ""}`,
296
299
  children: /* @__PURE__ */ n(ke, { className: "h-6 w-full" })
297
300
  },
298
- `skeleton-cell-${t}-${a}`
301
+ `skeleton-cell-${t}-${o}`
299
302
  )) }, `skeleton-row-${t}`)) : i.getRowModel().rows?.length ? i.getRowModel().rows.map((e) => /* @__PURE__ */ n(
300
- z,
303
+ N,
301
304
  {
302
305
  "data-state": e.getIsSelected() && "selected",
303
306
  children: e.getVisibleCells().map((t) => /* @__PURE__ */ n(
@@ -313,12 +316,12 @@ function Ue({
313
316
  ))
314
317
  },
315
318
  e.id
316
- )) : /* @__PURE__ */ n(z, { children: /* @__PURE__ */ n(
319
+ )) : /* @__PURE__ */ n(N, { children: /* @__PURE__ */ n(
317
320
  H,
318
321
  {
319
322
  colSpan: P.length,
320
323
  className: "pt-4 text-center",
321
- children: _ || Q
324
+ children: J || Q
322
325
  }
323
326
  ) }) })
324
327
  ] })
@@ -327,12 +330,12 @@ function Ue({
327
330
  ),
328
331
  /* @__PURE__ */ h(pe, { className: "h-9", children: [
329
332
  /* @__PURE__ */ n("div", { className: "flex h-full flex-1 items-center align-middle", children: /* @__PURE__ */ n("div", { className: "text-d-foreground hidden text-sm md:flex", children: Math.min(
330
- r?.pagination?.pageSize ?? C.pageSize,
333
+ r?.pagination?.pageSize ?? w.pageSize,
331
334
  i.getFilteredRowModel().rows.length ?? 9999
332
- ) + " / " + (r ? M ?? "missing totalItems" : i.getFilteredRowModel().rows.length) + " " + (x?.rows ?? "Righe") }) }),
335
+ ) + " / " + (r ? z ?? "missing totalItems" : i.getFilteredRowModel().rows.length) + " " + (x?.rows ?? "Righe") }) }),
333
336
  /* @__PURE__ */ h(xe, { children: [
334
- /* @__PURE__ */ n(w, { children: /* @__PURE__ */ n(
335
- Ce,
337
+ /* @__PURE__ */ n(b, { children: /* @__PURE__ */ n(
338
+ we,
336
339
  {
337
340
  size: "sm",
338
341
  isDisabled: !i.getCanPreviousPage(),
@@ -349,8 +352,8 @@ function Ue({
349
352
  "aria-label": "Go to first page"
350
353
  }
351
354
  ) }),
352
- /* @__PURE__ */ n(w, { children: /* @__PURE__ */ n(
353
- be,
355
+ /* @__PURE__ */ n(b, { children: /* @__PURE__ */ n(
356
+ Ce,
354
357
  {
355
358
  size: "sm",
356
359
  isDisabled: !i.getCanPreviousPage(),
@@ -358,7 +361,7 @@ function Ue({
358
361
  onClick: () => {
359
362
  if (i.getCanPreviousPage())
360
363
  if (c) {
361
- const e = r?.pagination.pageIndex ?? C.pageIndex, t = Math.max(e - 1, 0);
364
+ const e = r?.pagination.pageIndex ?? w.pageIndex, t = Math.max(e - 1, 0);
362
365
  g?.((l) => ({
363
366
  ...l,
364
367
  pagination: {
@@ -373,12 +376,12 @@ function Ue({
373
376
  ) }),
374
377
  (() => {
375
378
  const e = i.getState().pagination.pageIndex, t = i.getPageCount(), l = 5;
376
- let a = Math.max(
379
+ let o = Math.max(
377
380
  0,
378
381
  e - Math.floor(l / 2)
379
- ), o = a + l;
380
- return o > t && (o = t, a = Math.max(0, o - l)), i.getPageOptions().slice(a, o).map((s, f) => /* @__PURE__ */ n(w, { children: /* @__PURE__ */ n(
381
- we,
382
+ ), a = o + l;
383
+ return a > t && (a = t, o = Math.max(0, a - l)), i.getPageOptions().slice(o, a).map((s, f) => /* @__PURE__ */ n(b, { children: /* @__PURE__ */ n(
384
+ be,
382
385
  {
383
386
  size: "icon",
384
387
  isActive: e === s,
@@ -399,7 +402,7 @@ function Ue({
399
402
  }
400
403
  ) }, f));
401
404
  })(),
402
- /* @__PURE__ */ n(w, { children: /* @__PURE__ */ n(
405
+ /* @__PURE__ */ n(b, { children: /* @__PURE__ */ n(
403
406
  Pe,
404
407
  {
405
408
  size: "sm",
@@ -416,7 +419,7 @@ function Ue({
416
419
  }
417
420
  }
418
421
  ) }),
419
- /* @__PURE__ */ n(w, { children: /* @__PURE__ */ n(
422
+ /* @__PURE__ */ n(b, { children: /* @__PURE__ */ n(
420
423
  Se,
421
424
  {
422
425
  size: "sm",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "laif-ds",
3
3
  "private": false,
4
- "version": "0.1.82",
4
+ "version": "0.1.83",
5
5
  "type": "module",
6
6
  "main": "dist/index.es.js",
7
7
  "module": "dist/index.es.js",