@devalok/shilp-sutra 0.15.0 → 0.16.1

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,43 +1,45 @@
1
1
  "use client";
2
- import { jsxs as r, jsx as l } from "react/jsx-runtime";
3
- import Ne, { useState as d, useRef as J, useEffect as Q, useCallback as ve } from "react";
4
- import { useReactTable as De, getExpandedRowModel as Ie, getPaginationRowModel as Re, getFilteredRowModel as Fe, getSortedRowModel as Pe, getCoreRowModel as ke, flexRender as M } from "@tanstack/react-table";
5
- import { useVirtualizer as Ee } from "@tanstack/react-virtual";
6
- import { IconArrowUp as ze, IconArrowDown as Me, IconArrowsSort as Te, IconSearch as Ve, IconChevronLeft as $e, IconChevronRight as L } from "@tabler/icons-react";
7
- import { Table as He, TableHeader as je, TableRow as y, TableHead as U, TableBody as T, TableCell as V } from "./table.js";
8
- import { C as q } from "../_chunks/checkbox.js";
9
- import { c as i } from "../_chunks/utils.js";
10
- import { DataTableToolbar as _e } from "./data-table-toolbar.js";
11
- const Ae = {
2
+ import { jsxs as d, jsx as n } from "react/jsx-runtime";
3
+ import Pe, { useState as u, useRef as B, useEffect as D, useCallback as V, useMemo as et } from "react";
4
+ import { useReactTable as tt, getExpandedRowModel as lt, getPaginationRowModel as nt, getFilteredRowModel as ot, getSortedRowModel as st, getCoreRowModel as at, flexRender as ee } from "@tanstack/react-table";
5
+ import { useVirtualizer as rt } from "@tanstack/react-virtual";
6
+ import { IconArrowUp as ct, IconArrowDown as dt, IconArrowsSort as it, IconSearch as ut, IconChevronLeft as mt, IconChevronRight as ye, IconX as ft } from "@tabler/icons-react";
7
+ import { Table as gt, TableHeader as ht, TableRow as z, TableHead as Se, TableBody as H, TableCell as O } from "./table.js";
8
+ import { B as pt } from "../_chunks/button.js";
9
+ import { C as Ce } from "../_chunks/checkbox.js";
10
+ import { Skeleton as Ne } from "./skeleton.js";
11
+ import { c as a } from "../_chunks/utils.js";
12
+ import { DataTableToolbar as bt } from "./data-table-toolbar.js";
13
+ const xt = {
12
14
  compact: "py-ds-02",
13
15
  standard: "py-ds-05",
14
16
  comfortable: "py-ds-07"
15
17
  };
16
- function Be({
17
- initialValue: v,
18
- onSave: S,
19
- onCancel: D
18
+ function yt({
19
+ initialValue: A,
20
+ onSave: m,
21
+ onCancel: K
20
22
  }) {
21
- const [x, h] = d(v), c = J(null);
22
- Q(() => {
23
- var s, C;
24
- (s = c.current) == null || s.focus(), (C = c.current) == null || C.select();
23
+ const [I, S] = u(A), h = B(null);
24
+ D(() => {
25
+ var i, E;
26
+ (i = h.current) == null || i.focus(), (E = h.current) == null || E.select();
25
27
  }, []);
26
- const u = ve(() => {
27
- S(x);
28
- }, [S, x]);
29
- return /* @__PURE__ */ l(
28
+ const p = V(() => {
29
+ m(I);
30
+ }, [m, I]);
31
+ return /* @__PURE__ */ n(
30
32
  "input",
31
33
  {
32
- ref: c,
34
+ ref: h,
33
35
  type: "text",
34
- value: x,
35
- onChange: (s) => h(s.target.value),
36
- onBlur: u,
37
- onKeyDown: (s) => {
38
- s.key === "Enter" ? (s.preventDefault(), u()) : s.key === "Escape" && (s.preventDefault(), D());
36
+ value: I,
37
+ onChange: (i) => S(i.target.value),
38
+ onBlur: p,
39
+ onKeyDown: (i) => {
40
+ i.key === "Enter" ? (i.preventDefault(), p()) : i.key === "Escape" && (i.preventDefault(), K());
39
41
  },
40
- className: i(
42
+ className: a(
41
43
  "h-ds-xs-plus w-full rounded-ds-md",
42
44
  "border border-border-interactive bg-field",
43
45
  "px-ds-02 text-ds-sm",
@@ -48,40 +50,97 @@ function Be({
48
50
  }
49
51
  );
50
52
  }
51
- function Ge({
52
- columns: v,
53
- data: S,
54
- className: D,
55
- noResultsText: x,
56
- sortable: h = !1,
57
- filterable: c = !1,
58
- globalFilter: u = !1,
59
- paginated: s = !1,
60
- pageSize: C,
61
- pageSizeOptions: W,
62
- selectable: I = !1,
63
- onSelectionChange: R,
64
- toolbar: $ = !1,
65
- density: X = "standard",
66
- columnPinning: p,
67
- editable: Z = !1,
68
- onCellEdit: F,
69
- expandable: w = !1,
70
- renderExpanded: H,
71
- virtualRows: m = !1,
72
- virtualRowHeight: ee = 48,
73
- maxHeight: te = 600
53
+ const St = 'button, a, input, select, textarea, [role="checkbox"]';
54
+ function Ct({
55
+ columns: A,
56
+ data: m,
57
+ className: K,
58
+ noResultsText: I,
59
+ sortable: S = !1,
60
+ filterable: h = !1,
61
+ globalFilter: p = !1,
62
+ paginated: i = !1,
63
+ pageSize: E,
64
+ pageSizeOptions: we,
65
+ selectable: C = !1,
66
+ onSelectionChange: G,
67
+ toolbar: te = !1,
68
+ density: ke = "standard",
69
+ columnPinning: N,
70
+ editable: Re = !1,
71
+ onCellEdit: L,
72
+ expandable: j = !1,
73
+ renderExpanded: le,
74
+ virtualRows: b = !1,
75
+ virtualRowHeight: ze = 48,
76
+ maxHeight: De = 600,
77
+ onSort: T,
78
+ emptyState: ne,
79
+ loading: Ie = !1,
80
+ selectedIds: Y,
81
+ selectableFilter: oe,
82
+ getRowId: g,
83
+ pagination: o,
84
+ singleExpand: U = !1,
85
+ stickyHeader: Ee = !1,
86
+ onRowClick: F,
87
+ bulkActions: $
74
88
  }) {
75
- const [le, ne] = d([]), [oe, ae] = d([]), [P, k] = d(""), [se, re] = d({
76
- pageIndex: 0,
77
- pageSize: C ?? 10
78
- }), [j, de] = d({}), [ie, ce] = d({}), [_, ue] = d({
79
- left: (p == null ? void 0 : p.left) ?? [],
80
- right: (p == null ? void 0 : p.right) ?? []
81
- }), [A, me] = d(X), [b, E] = d(null), [ge, fe] = d({}), B = J(null), pe = {
89
+ const [Te, se] = u([]), [Fe, Me] = u([]), [W, X] = u(""), [Ve, q] = u({
90
+ pageIndex: o ? o.page - 1 : 0,
91
+ pageSize: (o == null ? void 0 : o.pageSize) ?? E ?? 10
92
+ }), [x, ae] = u({}), [je, $e] = u({}), [re, _e] = u({
93
+ left: (N == null ? void 0 : N.left) ?? [],
94
+ right: (N == null ? void 0 : N.right) ?? []
95
+ }), [ce, He] = u(ke), [w, J] = u(null), [Oe, de] = u({}), ie = B(null);
96
+ D(() => {
97
+ if (Y) {
98
+ const e = {};
99
+ Y.forEach((t) => {
100
+ e[t] = !0;
101
+ }), ae(e);
102
+ }
103
+ }, [Y]), D(() => {
104
+ o && q((e) => ({
105
+ ...e,
106
+ pageIndex: o.page - 1,
107
+ pageSize: o.pageSize
108
+ }));
109
+ }, [o == null ? void 0 : o.page, o == null ? void 0 : o.pageSize]);
110
+ const Be = V(
111
+ (e) => {
112
+ se((t) => {
113
+ const l = typeof e == "function" ? e(t) : e;
114
+ return T && (l.length === 0 && t.length > 0 ? T(t[0].id, !1) : l.length > 0 && T(l[0].id, l[0].desc ? "desc" : "asc")), l;
115
+ });
116
+ },
117
+ [T]
118
+ ), Ae = V(
119
+ (e) => {
120
+ de((t) => {
121
+ const l = typeof e == "function" ? e(t) : e;
122
+ if (!U || l === !0 || typeof l != "object") return l;
123
+ const s = typeof t == "object" ? Object.keys(t).filter((f) => t[f]) : [], R = Object.keys(l).filter((f) => l[f]).filter((f) => !s.includes(f));
124
+ return R.length > 0 ? { [R[R.length - 1]]: !0 } : l;
125
+ });
126
+ },
127
+ [U]
128
+ ), Q = B(o == null ? void 0 : o.onPageChange);
129
+ D(() => {
130
+ Q.current = o == null ? void 0 : o.onPageChange;
131
+ }, [o == null ? void 0 : o.onPageChange]);
132
+ const Ke = V(
133
+ (e) => {
134
+ q((t) => {
135
+ const l = typeof e == "function" ? e(t) : e;
136
+ return Q.current && l.pageIndex !== t.pageIndex && Q.current(l.pageIndex + 1), l;
137
+ });
138
+ },
139
+ []
140
+ ), Ge = {
82
141
  id: "_select",
83
- header: ({ table: e }) => /* @__PURE__ */ l(
84
- q,
142
+ header: ({ table: e }) => /* @__PURE__ */ n(
143
+ Ce,
85
144
  {
86
145
  checked: e.getIsAllPageRowsSelected(),
87
146
  indeterminate: e.getIsSomePageRowsSelected(),
@@ -89,10 +148,11 @@ function Ge({
89
148
  "aria-label": "Select all rows"
90
149
  }
91
150
  ),
92
- cell: ({ row: e }) => /* @__PURE__ */ l(
93
- q,
151
+ cell: ({ row: e }) => /* @__PURE__ */ n(
152
+ Ce,
94
153
  {
95
154
  checked: e.getIsSelected(),
155
+ disabled: !e.getCanSelect(),
96
156
  onCheckedChange: (t) => e.toggleSelected(!!t),
97
157
  "aria-label": "Select row"
98
158
  }
@@ -100,21 +160,21 @@ function Ge({
100
160
  enableSorting: !1,
101
161
  enableColumnFilter: !1,
102
162
  enableHiding: !1
103
- }, be = {
163
+ }, Le = {
104
164
  id: "_expand",
105
165
  header: () => null,
106
- cell: ({ row: e }) => /* @__PURE__ */ l(
166
+ cell: ({ row: e }) => /* @__PURE__ */ n(
107
167
  "button",
108
168
  {
109
169
  type: "button",
110
170
  onClick: () => e.toggleExpanded(),
111
171
  "aria-label": e.getIsExpanded() ? "Collapse row" : "Expand row",
112
172
  className: "flex items-center justify-center p-ds-01 rounded-ds-sm hover:bg-layer-02 transition-colors",
113
- children: /* @__PURE__ */ l(
114
- L,
173
+ children: /* @__PURE__ */ n(
174
+ ye,
115
175
  {
116
176
  size: 16,
117
- className: i(
177
+ className: a(
118
178
  "transition-transform duration-moderate-02",
119
179
  e.getIsExpanded() && "rotate-90"
120
180
  ),
@@ -126,280 +186,336 @@ function Ge({
126
186
  enableSorting: !1,
127
187
  enableColumnFilter: !1,
128
188
  enableHiding: !1
129
- }, z = [
130
- ...I ? [pe] : [],
131
- ...w ? [be] : [],
132
- ...v
133
- ], g = {
134
- columnVisibility: ie,
135
- columnPinning: _
189
+ }, k = [
190
+ ...C ? [Ge] : [],
191
+ ...j ? [Le] : [],
192
+ ...A
193
+ ], M = !!o, Z = i || M, y = {
194
+ columnVisibility: je,
195
+ columnPinning: re
136
196
  };
137
- h && (g.sorting = le), (c || u) && (g.columnFilters = oe, g.globalFilter = P), s && (g.pagination = se), I && (g.rowSelection = j), w && (g.expanded = ge);
138
- const n = De({
139
- data: S,
140
- columns: z,
141
- state: g,
142
- onColumnVisibilityChange: ce,
143
- onColumnPinningChange: ue,
144
- getCoreRowModel: ke(),
145
- ...h && {
146
- onSortingChange: ne,
147
- getSortedRowModel: Pe()
197
+ S && (y.sorting = Te), (h || p) && (y.columnFilters = Fe, y.globalFilter = W), Z && (y.pagination = Ve), C && (y.rowSelection = x), j && (y.expanded = Oe);
198
+ const ue = S && !!T, r = tt({
199
+ data: m,
200
+ columns: k,
201
+ state: y,
202
+ onColumnVisibilityChange: $e,
203
+ onColumnPinningChange: _e,
204
+ getCoreRowModel: at(),
205
+ ...S && {
206
+ onSortingChange: ue ? Be : se,
207
+ ...ue ? { manualSorting: !0 } : { getSortedRowModel: st() }
208
+ },
209
+ ...(h || p) && {
210
+ onColumnFiltersChange: Me,
211
+ onGlobalFilterChange: X,
212
+ getFilteredRowModel: ot()
148
213
  },
149
- ...(c || u) && {
150
- onColumnFiltersChange: ae,
151
- onGlobalFilterChange: k,
152
- getFilteredRowModel: Fe()
214
+ ...Z && {
215
+ onPaginationChange: M ? Ke : q,
216
+ ...M ? {
217
+ manualPagination: !0,
218
+ pageCount: Math.ceil(
219
+ o.total / o.pageSize
220
+ )
221
+ } : { getPaginationRowModel: nt() }
153
222
  },
154
- ...s && {
155
- onPaginationChange: re,
156
- getPaginationRowModel: Re()
223
+ ...C && {
224
+ onRowSelectionChange: ae,
225
+ enableRowSelection: oe ? (e) => oe(e.original) : !0
157
226
  },
158
- ...I && {
159
- onRowSelectionChange: de,
160
- enableRowSelection: !0
227
+ ...j && {
228
+ onExpandedChange: U ? Ae : de,
229
+ getExpandedRowModel: lt()
161
230
  },
162
- ...w && {
163
- onExpandedChange: fe,
164
- getExpandedRowModel: Ie()
165
- }
166
- });
167
- Q(() => {
168
- if (R) {
169
- const e = n.getFilteredSelectedRowModel().rows.map((t) => t.original);
170
- R(e);
231
+ ...g && {
232
+ getRowId: (e) => g(e)
171
233
  }
172
- }, [j, R, n]);
173
- function G(e) {
174
- const { left: t = [], right: a = [] } = _, o = t.indexOf(e), f = a.indexOf(e);
175
- return o !== -1 ? {
234
+ }), v = B(G);
235
+ D(() => {
236
+ v.current = G;
237
+ }, [G]), D(() => {
238
+ if (!v.current) return;
239
+ const e = Object.keys(x).filter((l) => x[l]), t = m.filter((l, s) => {
240
+ const c = g ? g(m[s]) : String(s);
241
+ return e.includes(c);
242
+ });
243
+ v.current(t);
244
+ }, [x, m, g]);
245
+ function me(e) {
246
+ const { left: t = [], right: l = [] } = re, s = t.indexOf(e), c = l.indexOf(e);
247
+ return s !== -1 ? {
176
248
  className: "sticky bg-layer-01 z-raised",
177
249
  style: { left: 0 }
178
- } : f !== -1 ? {
250
+ } : c !== -1 ? {
179
251
  className: "sticky bg-layer-01 z-raised",
180
252
  style: { right: 0 }
181
253
  } : { className: "", style: {} };
182
254
  }
183
- function xe(e) {
184
- if (!Z || e === "_select" || e === "_expand") return !1;
185
- const t = n.getColumn(e);
255
+ function Ye(e) {
256
+ if (!Re || e === "_select" || e === "_expand") return !1;
257
+ const t = r.getColumn(e);
186
258
  if (!t) return !1;
187
- const a = t.columnDef.meta;
188
- return (a == null ? void 0 : a.enableEditing) !== !1;
259
+ const l = t.columnDef.meta;
260
+ return (l == null ? void 0 : l.enableEditing) !== !1;
189
261
  }
190
- const he = Ae[A], N = n.getRowModel().rows, O = Ee({
191
- count: m ? N.length : 0,
192
- getScrollElement: () => B.current,
193
- estimateSize: () => ee,
262
+ const fe = xt[ce], _ = r.getRowModel().rows, ge = rt({
263
+ count: b ? _.length : 0,
264
+ getScrollElement: () => ie.current,
265
+ estimateSize: () => ze,
194
266
  overscan: 10
195
- });
196
- function Y(e, t) {
197
- const a = e.getVisibleCells();
198
- return /* @__PURE__ */ l(
199
- y,
267
+ }), Ue = (o == null ? void 0 : o.pageSize) ?? E ?? 5, We = k.length, Xe = V(
268
+ (e, t) => {
269
+ !F || t.target.closest(St) || F(e);
270
+ },
271
+ [F]
272
+ );
273
+ function he(e, t) {
274
+ const l = e.getVisibleCells();
275
+ return /* @__PURE__ */ n(
276
+ z,
200
277
  {
201
278
  "data-state": e.getIsSelected() && "selected",
202
279
  style: t,
203
- className: m ? "absolute w-full flex" : void 0,
204
- children: a.map((o) => {
205
- const f = G(o.column.id), Ce = (b == null ? void 0 : b.rowIndex) === e.index && (b == null ? void 0 : b.columnId) === o.column.id;
206
- return /* @__PURE__ */ l(
207
- V,
280
+ className: a(
281
+ b ? "absolute w-full flex" : void 0,
282
+ F && "cursor-pointer"
283
+ ),
284
+ onClick: F ? (s) => Xe(e.original, s) : void 0,
285
+ children: l.map((s) => {
286
+ const c = me(s.column.id), R = (w == null ? void 0 : w.rowIndex) === e.index && (w == null ? void 0 : w.columnId) === s.column.id;
287
+ return /* @__PURE__ */ n(
288
+ O,
208
289
  {
209
- className: i(
210
- he,
211
- f.className,
212
- m && "flex-1"
290
+ className: a(
291
+ fe,
292
+ c.className,
293
+ b && "flex-1"
213
294
  ),
214
- style: f.style,
295
+ style: c.style,
215
296
  onDoubleClick: () => {
216
- xe(o.column.id) && E({
297
+ Ye(s.column.id) && J({
217
298
  rowIndex: e.index,
218
- columnId: o.column.id
299
+ columnId: s.column.id
219
300
  });
220
301
  },
221
- children: Ce ? /* @__PURE__ */ l(
222
- Be,
302
+ children: R ? /* @__PURE__ */ n(
303
+ yt,
223
304
  {
224
- initialValue: String(o.getValue() ?? ""),
225
- onSave: (we) => {
226
- F == null || F(e.index, o.column.id, we), E(null);
305
+ initialValue: String(s.getValue() ?? ""),
306
+ onSave: (f) => {
307
+ L == null || L(e.index, s.column.id, f), J(null);
227
308
  },
228
- onCancel: () => E(null)
309
+ onCancel: () => J(null)
229
310
  }
230
- ) : M(o.column.columnDef.cell, o.getContext())
311
+ ) : ee(s.column.columnDef.cell, s.getContext())
231
312
  },
232
- o.id
313
+ s.id
233
314
  );
234
315
  })
235
316
  },
236
317
  e.id
237
318
  );
238
319
  }
239
- function ye(e, t) {
240
- return !w || !e.getIsExpanded() || !H ? null : /* @__PURE__ */ l(
241
- y,
320
+ function qe(e, t) {
321
+ return !j || !e.getIsExpanded() || !le ? null : /* @__PURE__ */ n(
322
+ z,
242
323
  {
243
324
  style: t,
244
- className: m ? "absolute w-full flex" : void 0,
245
- children: /* @__PURE__ */ l(
246
- V,
325
+ className: b ? "absolute w-full flex" : void 0,
326
+ children: /* @__PURE__ */ n(
327
+ O,
247
328
  {
248
- colSpan: z.length,
249
- className: i(
329
+ colSpan: k.length,
330
+ className: a(
250
331
  "bg-layer-02 p-ds-05",
251
- m && "flex-1"
332
+ b && "flex-1"
252
333
  ),
253
- children: H(e.original)
334
+ children: le(e.original)
254
335
  }
255
336
  )
256
337
  },
257
338
  `${e.id}-expanded`
258
339
  );
259
340
  }
260
- function Se() {
261
- if (!N.length)
262
- return /* @__PURE__ */ l(T, { children: /* @__PURE__ */ l(y, { children: /* @__PURE__ */ l(
263
- V,
341
+ function Je() {
342
+ const e = ["w-3/4", "w-1/2", "w-2/3", "w-full"];
343
+ return /* @__PURE__ */ n(H, { children: Array.from({ length: Ue }, (t, l) => /* @__PURE__ */ n(z, { children: Array.from({ length: We }, (s, c) => {
344
+ var be, xe;
345
+ const f = (((be = k[c]) == null ? void 0 : be.id) ?? ((xe = k[c]) == null ? void 0 : xe.header)) === "_select";
346
+ return /* @__PURE__ */ n(
347
+ O,
264
348
  {
265
- colSpan: z.length,
266
- className: "h-24 text-center text-text-tertiary",
267
- children: x || "No results."
349
+ className: fe,
350
+ children: f ? /* @__PURE__ */ n(Ne, { variant: "text", className: "h-4 w-4", animation: "pulse" }) : /* @__PURE__ */ n(Ne, { variant: "text", className: a("h-4", e[c % e.length]), animation: "pulse" })
351
+ },
352
+ `skeleton-${l}-${c}`
353
+ );
354
+ }) }, `skeleton-${l}`)) });
355
+ }
356
+ function Qe() {
357
+ if (Ie)
358
+ return Je();
359
+ if (!_.length)
360
+ return /* @__PURE__ */ n(H, { children: /* @__PURE__ */ n(z, { children: /* @__PURE__ */ n(
361
+ O,
362
+ {
363
+ colSpan: k.length,
364
+ className: a(
365
+ "h-24 text-center",
366
+ !ne && "text-text-tertiary"
367
+ ),
368
+ children: ne || I || "No results."
268
369
  }
269
370
  ) }) });
270
- if (m) {
271
- const e = O.getVirtualItems(), t = O.getTotalSize();
272
- return /* @__PURE__ */ l(
273
- T,
371
+ if (b) {
372
+ const e = ge.getVirtualItems(), t = ge.getTotalSize();
373
+ return /* @__PURE__ */ n(
374
+ H,
274
375
  {
275
376
  style: {
276
377
  height: `${t}px`,
277
378
  position: "relative"
278
379
  },
279
- children: e.map((a) => {
280
- const o = N[a.index];
281
- return Y(o, {
380
+ children: e.map((l) => {
381
+ const s = _[l.index];
382
+ return he(s, {
282
383
  position: "absolute",
283
384
  top: 0,
284
385
  left: 0,
285
386
  width: "100%",
286
- height: `${a.size}px`,
287
- transform: `translateY(${a.start}px)`
387
+ height: `${l.size}px`,
388
+ transform: `translateY(${l.start}px)`
288
389
  });
289
390
  })
290
391
  }
291
392
  );
292
393
  }
293
- return /* @__PURE__ */ l(T, { children: N.map((e) => /* @__PURE__ */ r(Ne.Fragment, { children: [
294
- Y(e),
295
- ye(e)
394
+ return /* @__PURE__ */ n(H, { children: _.map((e) => /* @__PURE__ */ d(Pe.Fragment, { children: [
395
+ he(e),
396
+ qe(e)
296
397
  ] }, e.id)) });
297
398
  }
298
- const K = /* @__PURE__ */ r(He, { children: [
299
- /* @__PURE__ */ r(je, { children: [
300
- n.getHeaderGroups().map((e) => /* @__PURE__ */ l(y, { children: e.headers.map((t) => {
301
- const a = h && t.column.getCanSort(), o = t.column.getIsSorted(), f = G(t.column.id);
302
- return /* @__PURE__ */ l(
303
- U,
304
- {
305
- className: f.className,
306
- style: f.style,
307
- children: t.isPlaceholder ? null : a ? /* @__PURE__ */ r(
308
- "button",
399
+ const P = et(() => {
400
+ if (!$ || !C) return [];
401
+ const e = Object.keys(x).filter((t) => x[t]);
402
+ return m.filter((t, l) => {
403
+ const s = g ? g(m[l]) : String(l);
404
+ return e.includes(s);
405
+ });
406
+ }, [$, C, x, m, g]), Ze = P.length > 0, ve = M ? o.total : r.getFilteredRowModel().rows.length, pe = /* @__PURE__ */ d(gt, { children: [
407
+ /* @__PURE__ */ d(
408
+ ht,
409
+ {
410
+ className: a(
411
+ Ee && "sticky top-0 z-10 bg-surface"
412
+ ),
413
+ children: [
414
+ r.getHeaderGroups().map((e) => /* @__PURE__ */ n(z, { children: e.headers.map((t) => {
415
+ const l = S && t.column.getCanSort(), s = t.column.getIsSorted(), c = me(t.column.id);
416
+ return /* @__PURE__ */ n(
417
+ Se,
309
418
  {
310
- type: "button",
311
- className: i(
312
- "flex items-center gap-ds-01 font-medium",
313
- "cursor-pointer select-none",
314
- "-ml-ds-01 rounded-ds-sm px-ds-01 py-ds-01",
315
- "hover:bg-layer-02 transition-colors"
316
- ),
317
- onClick: t.column.getToggleSortingHandler(),
318
- "aria-label": `Sort by ${typeof t.column.columnDef.header == "string" ? t.column.columnDef.header : t.column.id}`,
319
- children: [
320
- M(
321
- t.column.columnDef.header,
322
- t.getContext()
323
- ),
324
- o === "asc" ? /* @__PURE__ */ l(
325
- ze,
326
- {
327
- className: "h-ico-sm w-ico-sm text-text-secondary",
328
- "aria-hidden": "true"
329
- }
330
- ) : o === "desc" ? /* @__PURE__ */ l(
331
- Me,
332
- {
333
- className: "h-ico-sm w-ico-sm text-text-secondary",
334
- "aria-hidden": "true"
335
- }
336
- ) : /* @__PURE__ */ l(
337
- Te,
338
- {
339
- className: "h-ico-sm w-ico-sm text-text-tertiary",
340
- "aria-hidden": "true"
341
- }
342
- )
343
- ]
344
- }
345
- ) : M(
346
- t.column.columnDef.header,
347
- t.getContext()
348
- )
349
- },
350
- t.id
351
- );
352
- }) }, e.id)),
353
- c && n.getHeaderGroups().map((e) => /* @__PURE__ */ l(y, { children: e.headers.map((t) => /* @__PURE__ */ l(U, { className: "py-ds-01", children: t.isPlaceholder || t.column.columnDef.enableColumnFilter === !1 ? null : /* @__PURE__ */ l(
354
- "input",
355
- {
356
- type: "text",
357
- value: t.column.getFilterValue() ?? "",
358
- onChange: (a) => t.column.setFilterValue(a.target.value),
359
- placeholder: `Filter ${typeof t.column.columnDef.header == "string" ? t.column.columnDef.header : ""}...`,
360
- "aria-label": `Filter ${typeof t.column.columnDef.header == "string" ? t.column.columnDef.header : t.column.id}`,
361
- className: i(
362
- "h-ds-xs-plus w-full rounded-ds-md",
363
- "border border-border bg-field",
364
- "px-ds-02 text-ds-sm",
365
- "text-text-primary placeholder:text-text-placeholder",
366
- "outline-none focus:border-[var(--color-border-focus)]"
367
- )
368
- }
369
- ) }, `${t.id}-filter`)) }, `${e.id}-filters`))
370
- ] }),
371
- Se()
419
+ className: c.className,
420
+ style: c.style,
421
+ children: t.isPlaceholder ? null : l ? /* @__PURE__ */ d(
422
+ "button",
423
+ {
424
+ type: "button",
425
+ className: a(
426
+ "flex items-center gap-ds-01 font-medium",
427
+ "cursor-pointer select-none",
428
+ "-ml-ds-01 rounded-ds-sm px-ds-01 py-ds-01",
429
+ "hover:bg-layer-02 transition-colors"
430
+ ),
431
+ onClick: t.column.getToggleSortingHandler(),
432
+ "aria-label": `Sort by ${typeof t.column.columnDef.header == "string" ? t.column.columnDef.header : t.column.id}`,
433
+ children: [
434
+ ee(
435
+ t.column.columnDef.header,
436
+ t.getContext()
437
+ ),
438
+ s === "asc" ? /* @__PURE__ */ n(
439
+ ct,
440
+ {
441
+ className: "h-ico-sm w-ico-sm text-text-secondary",
442
+ "aria-hidden": "true"
443
+ }
444
+ ) : s === "desc" ? /* @__PURE__ */ n(
445
+ dt,
446
+ {
447
+ className: "h-ico-sm w-ico-sm text-text-secondary",
448
+ "aria-hidden": "true"
449
+ }
450
+ ) : /* @__PURE__ */ n(
451
+ it,
452
+ {
453
+ className: "h-ico-sm w-ico-sm text-text-tertiary",
454
+ "aria-hidden": "true"
455
+ }
456
+ )
457
+ ]
458
+ }
459
+ ) : ee(
460
+ t.column.columnDef.header,
461
+ t.getContext()
462
+ )
463
+ },
464
+ t.id
465
+ );
466
+ }) }, e.id)),
467
+ h && r.getHeaderGroups().map((e) => /* @__PURE__ */ n(z, { children: e.headers.map((t) => /* @__PURE__ */ n(Se, { className: "py-ds-01", children: t.isPlaceholder || t.column.columnDef.enableColumnFilter === !1 ? null : /* @__PURE__ */ n(
468
+ "input",
469
+ {
470
+ type: "text",
471
+ value: t.column.getFilterValue() ?? "",
472
+ onChange: (l) => t.column.setFilterValue(l.target.value),
473
+ placeholder: `Filter ${typeof t.column.columnDef.header == "string" ? t.column.columnDef.header : ""}...`,
474
+ "aria-label": `Filter ${typeof t.column.columnDef.header == "string" ? t.column.columnDef.header : t.column.id}`,
475
+ className: a(
476
+ "h-ds-xs-plus w-full rounded-ds-md",
477
+ "border border-border bg-field",
478
+ "px-ds-02 text-ds-sm",
479
+ "text-text-primary placeholder:text-text-placeholder",
480
+ "outline-none focus:border-[var(--color-border-focus)]"
481
+ )
482
+ }
483
+ ) }, `${t.id}-filter`)) }, `${e.id}-filters`))
484
+ ]
485
+ }
486
+ ),
487
+ Qe()
372
488
  ] });
373
- return /* @__PURE__ */ r("div", { className: i(D), children: [
374
- $ && /* @__PURE__ */ l(
375
- _e,
489
+ return /* @__PURE__ */ d("div", { className: a(K), children: [
490
+ te && /* @__PURE__ */ n(
491
+ bt,
376
492
  {
377
- table: n,
378
- globalFilter: u,
379
- globalFilterValue: P,
380
- onGlobalFilterChange: k,
381
- density: A,
382
- onDensityChange: me
493
+ table: r,
494
+ globalFilter: p,
495
+ globalFilterValue: W,
496
+ onGlobalFilterChange: X,
497
+ density: ce,
498
+ onDensityChange: He
383
499
  }
384
500
  ),
385
- u && !$ && /* @__PURE__ */ r("div", { className: "flex items-center gap-ds-03 pb-ds-04 border-b border-border-subtle mb-ds-04", children: [
386
- /* @__PURE__ */ l(
387
- Ve,
501
+ p && !te && /* @__PURE__ */ d("div", { className: "flex items-center gap-ds-03 pb-ds-04 border-b border-border-subtle mb-ds-04", children: [
502
+ /* @__PURE__ */ n(
503
+ ut,
388
504
  {
389
505
  size: 16,
390
506
  className: "text-icon-secondary",
391
507
  "aria-hidden": "true"
392
508
  }
393
509
  ),
394
- /* @__PURE__ */ l(
510
+ /* @__PURE__ */ n(
395
511
  "input",
396
512
  {
397
513
  type: "text",
398
- value: P,
399
- onChange: (e) => k(e.target.value),
514
+ value: W,
515
+ onChange: (e) => X(e.target.value),
400
516
  placeholder: "Search all columns...",
401
517
  "aria-label": "Search all columns",
402
- className: i(
518
+ className: a(
403
519
  "flex-1 bg-transparent text-ds-md",
404
520
  "text-text-primary placeholder:text-text-placeholder",
405
521
  "outline-none"
@@ -407,86 +523,131 @@ function Ge({
407
523
  }
408
524
  )
409
525
  ] }),
410
- m ? /* @__PURE__ */ l(
526
+ b ? /* @__PURE__ */ n(
411
527
  "div",
412
528
  {
413
- ref: B,
414
- style: { maxHeight: `${te}px`, overflowY: "auto" },
415
- children: K
529
+ ref: ie,
530
+ style: { maxHeight: `${De}px`, overflowY: "auto" },
531
+ children: pe
416
532
  }
417
- ) : K,
418
- s && /* @__PURE__ */ r("div", { className: "flex items-center justify-between px-ds-03 py-ds-04 border-t border-border-subtle", children: [
419
- /* @__PURE__ */ r("span", { className: "text-ds-sm text-text-secondary", children: [
420
- n.getFilteredRowModel().rows.length,
533
+ ) : pe,
534
+ Z && /* @__PURE__ */ d("div", { className: "flex items-center justify-between px-ds-03 py-ds-04 border-t border-border-subtle", children: [
535
+ /* @__PURE__ */ d("span", { className: "text-ds-sm text-text-secondary", children: [
536
+ ve,
421
537
  " total rows"
422
538
  ] }),
423
- /* @__PURE__ */ r("div", { className: "flex items-center gap-ds-03", children: [
424
- /* @__PURE__ */ l(
539
+ /* @__PURE__ */ d("div", { className: "flex items-center gap-ds-03", children: [
540
+ !M && /* @__PURE__ */ n(
425
541
  "select",
426
542
  {
427
- value: n.getState().pagination.pageSize,
543
+ value: r.getState().pagination.pageSize,
428
544
  onChange: (e) => {
429
- n.setPageSize(Number(e.target.value));
545
+ r.setPageSize(Number(e.target.value));
430
546
  },
431
547
  "aria-label": "Rows per page",
432
- className: i(
548
+ className: a(
433
549
  "h-ds-sm rounded-ds-md",
434
550
  "border border-border bg-field",
435
551
  "px-ds-03 text-ds-sm",
436
552
  "text-text-primary"
437
553
  ),
438
- children: (W ?? [10, 20, 50, 100]).map((e) => /* @__PURE__ */ r("option", { value: e, children: [
554
+ children: (we ?? [10, 20, 50, 100]).map((e) => /* @__PURE__ */ d("option", { value: e, children: [
439
555
  e,
440
556
  " rows"
441
557
  ] }, e))
442
558
  }
443
559
  ),
444
- /* @__PURE__ */ l(
560
+ /* @__PURE__ */ n(
445
561
  "button",
446
562
  {
447
563
  type: "button",
448
- disabled: !n.getCanPreviousPage(),
449
- onClick: () => n.previousPage(),
564
+ disabled: !r.getCanPreviousPage(),
565
+ onClick: () => r.previousPage(),
450
566
  "aria-label": "Previous page",
451
- className: i(
567
+ className: a(
452
568
  "h-ds-sm w-ds-sm flex items-center justify-center",
453
569
  "rounded-ds-md border border-border",
454
570
  "enabled:hover:bg-layer-02",
455
571
  "disabled:opacity-[0.38] disabled:cursor-not-allowed",
456
572
  "transition-colors"
457
573
  ),
458
- children: /* @__PURE__ */ l($e, { size: 16, "aria-hidden": "true" })
574
+ children: /* @__PURE__ */ n(mt, { size: 16, "aria-hidden": "true" })
459
575
  }
460
576
  ),
461
- /* @__PURE__ */ r("span", { className: "text-ds-sm text-text-secondary", children: [
577
+ /* @__PURE__ */ d("span", { className: "text-ds-sm text-text-secondary", children: [
462
578
  "Page ",
463
- n.getState().pagination.pageIndex + 1,
579
+ r.getState().pagination.pageIndex + 1,
464
580
  " of",
465
581
  " ",
466
- n.getPageCount()
582
+ r.getPageCount()
467
583
  ] }),
468
- /* @__PURE__ */ l(
584
+ /* @__PURE__ */ n(
469
585
  "button",
470
586
  {
471
587
  type: "button",
472
- disabled: !n.getCanNextPage(),
473
- onClick: () => n.nextPage(),
588
+ disabled: !r.getCanNextPage(),
589
+ onClick: () => r.nextPage(),
474
590
  "aria-label": "Next page",
475
- className: i(
591
+ className: a(
476
592
  "h-ds-sm w-ds-sm flex items-center justify-center",
477
593
  "rounded-ds-md border border-border",
478
594
  "enabled:hover:bg-layer-02",
479
595
  "disabled:opacity-[0.38] disabled:cursor-not-allowed",
480
596
  "transition-colors"
481
597
  ),
482
- children: /* @__PURE__ */ l(L, { size: 16, "aria-hidden": "true" })
598
+ children: /* @__PURE__ */ n(ye, { size: 16, "aria-hidden": "true" })
483
599
  }
484
600
  )
485
601
  ] })
486
- ] })
602
+ ] }),
603
+ $ && C && Ze && /* @__PURE__ */ d(
604
+ "div",
605
+ {
606
+ className: a(
607
+ "fixed bottom-6 left-1/2 -translate-x-1/2 z-50",
608
+ "flex items-center gap-ds-04 px-ds-05 py-ds-03",
609
+ "rounded-ds-lg border border-border bg-surface shadow-lg",
610
+ "animate-in slide-in-from-bottom-2"
611
+ ),
612
+ role: "toolbar",
613
+ "aria-label": "Bulk actions",
614
+ children: [
615
+ /* @__PURE__ */ d("span", { className: "text-ds-sm font-medium text-text-primary whitespace-nowrap", children: [
616
+ P.length,
617
+ " selected"
618
+ ] }),
619
+ /* @__PURE__ */ n("div", { className: "h-5 w-px bg-border", "aria-hidden": "true" }),
620
+ $.map((e) => /* @__PURE__ */ n(
621
+ pt,
622
+ {
623
+ size: "sm",
624
+ variant: e.color === "error" ? "destructive" : "outline",
625
+ disabled: e.disabled,
626
+ onClick: () => e.onClick(P),
627
+ children: e.label
628
+ },
629
+ e.label
630
+ )),
631
+ /* @__PURE__ */ n(
632
+ "button",
633
+ {
634
+ type: "button",
635
+ onClick: () => r.resetRowSelection(),
636
+ "aria-label": "Clear selection",
637
+ className: a(
638
+ "flex items-center justify-center p-ds-01",
639
+ "rounded-ds-sm hover:bg-layer-02 transition-colors",
640
+ "text-text-secondary hover:text-text-primary"
641
+ ),
642
+ children: /* @__PURE__ */ n(ft, { size: 16, "aria-hidden": "true" })
643
+ }
644
+ )
645
+ ]
646
+ }
647
+ )
487
648
  ] });
488
649
  }
489
- Ge.displayName = "DataTable";
650
+ Ct.displayName = "DataTable";
490
651
  export {
491
- Ge as DataTable
652
+ Ct as DataTable
492
653
  };