@deepnoid/ui 0.1.135 → 0.1.137

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,10 +1,7 @@
1
1
  "use client";
2
- import {
3
- skeleton_default
4
- } from "./chunk-6PN3DGOE.mjs";
5
2
  import {
6
3
  pagination_default
7
- } from "./chunk-4URRLVNR.mjs";
4
+ } from "./chunk-4JOD47VZ.mjs";
8
5
  import {
9
6
  scrollArea_default
10
7
  } from "./chunk-M37VBNB3.mjs";
@@ -29,7 +26,7 @@ import {
29
26
  import { tv } from "tailwind-variants";
30
27
 
31
28
  // src/components/table/table-body.tsx
32
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
29
+ import { jsx, jsxs } from "react/jsx-runtime";
33
30
  var TableBody = ({
34
31
  slots,
35
32
  rows,
@@ -42,13 +39,9 @@ var TableBody = ({
42
39
  onRowClick,
43
40
  isLoading = false,
44
41
  emptyContent,
45
- skeletonRow,
46
42
  classNames,
47
43
  className
48
44
  }) => {
49
- const renderTdSkeleton = (key, column) => {
50
- return /* @__PURE__ */ jsx("td", { className: slots.td({ class: classNames == null ? void 0 : classNames.td }), style: column ? getCellStyle(column) : {}, children: /* @__PURE__ */ jsx(skeleton_default, { color, className: "h-full w-full", rounded: "lg", speed: "fast" }) }, key);
51
- };
52
45
  const renderCheckboxCell = (rowId, rowIndex) => /* @__PURE__ */ jsx(
53
46
  "td",
54
47
  {
@@ -58,10 +51,6 @@ var TableBody = ({
58
51
  },
59
52
  `checkbox-${rowId}-${rowIndex}`
60
53
  );
61
- const renderSkeletonRow = (rowIndex) => /* @__PURE__ */ jsxs("tr", { className: slots.tr({ class: classNames == null ? void 0 : classNames.tr }), children: [
62
- columns.map((column, colIdx) => renderTdSkeleton(`skeleton-${rowIndex}-${colIdx}`, column)),
63
- rowCheckbox && renderTdSkeleton(`skeleton-checkbox-${rowIndex}`)
64
- ] }, `skeleton-${rowIndex}`);
65
54
  const renderEmptyRow = () => /* @__PURE__ */ jsx("tr", { className: slots.tr({ class: classNames == null ? void 0 : classNames.tr }), children: /* @__PURE__ */ jsx("td", { colSpan: columns.length + (rowCheckbox ? 1 : 0), className: slots.empty({ class: classNames == null ? void 0 : classNames.empty }), children: emptyContent }) });
66
55
  const renderDataRow = (row, rowIndex) => /* @__PURE__ */ jsxs(
67
56
  "tr",
@@ -89,12 +78,18 @@ var TableBody = ({
89
78
  },
90
79
  `${row.id}-${rowIndex}`
91
80
  );
92
- const renderRows = () => {
93
- if (isLoading) return skeletonRow ? Array.from({ length: skeletonRow }, (_, idx) => renderSkeletonRow(idx)) : /* @__PURE__ */ jsx(Fragment, {});
94
- if (!rows.length && emptyContent) return renderEmptyRow();
95
- return rows.map((row, index) => renderDataRow(row, index));
96
- };
97
- return /* @__PURE__ */ jsx("tbody", { className: clsx(slots.tbody({ class: classNames == null ? void 0 : classNames.tbody }), className), children: renderRows() });
81
+ return /* @__PURE__ */ jsx(
82
+ "tbody",
83
+ {
84
+ className: clsx(
85
+ slots.tbody({ class: classNames == null ? void 0 : classNames.tbody }),
86
+ className,
87
+ "transition-all duration-200 ease-in-out",
88
+ isLoading && slots.tbodyLoading({ class: classNames == null ? void 0 : classNames.tbodyLoading })
89
+ ),
90
+ children: !rows.length && emptyContent ? renderEmptyRow() : rows.map((row, index) => renderDataRow(row, index))
91
+ }
92
+ );
98
93
  };
99
94
  var table_body_default = TableBody;
100
95
 
@@ -115,13 +110,13 @@ var Table = forwardRef((originalProps, ref) => {
115
110
  variant,
116
111
  color,
117
112
  size,
118
- skeletonRow,
113
+ checkedRows,
119
114
  onCheckedRowsChange,
120
115
  onRowClick
121
116
  } = { ...props, ...variantProps };
122
117
  const { page = 1, perPage = 15 } = pagination || {};
123
- const showPagination = pagination && totalData > 0 && !isLoading;
124
- const [checkedRows, setCheckedRows] = useState(/* @__PURE__ */ new Set());
118
+ const showPagination = pagination && totalData > 0;
119
+ const [checkedRowIds, setCheckedRowIds] = useState(new Set(checkedRows == null ? void 0 : checkedRows.map((row) => row.id)));
125
120
  const tableMinWidth = useMemo(() => {
126
121
  const columnsWidth = columns.reduce((total, column) => {
127
122
  if (column.width) return total + column.width;
@@ -132,30 +127,30 @@ var Table = forwardRef((originalProps, ref) => {
132
127
  return columnsWidth + checkboxWidth;
133
128
  }, [columns, rowCheckbox]);
134
129
  useEffect(() => {
135
- onCheckedRowsChange == null ? void 0 : onCheckedRowsChange(getCheckedRowData(checkedRows));
136
- }, [checkedRows]);
130
+ onCheckedRowsChange == null ? void 0 : onCheckedRowsChange(getCheckedRowData(checkedRowIds));
131
+ }, [checkedRowIds]);
137
132
  useEffect(() => {
138
133
  const currentRowIds = new Set(rows.map((row) => row.id));
139
- const checkedRowIds = Array.from(checkedRows);
140
- const hasValidCheckedRows = checkedRowIds.every((id) => currentRowIds.has(id));
134
+ const ids = Array.from(checkedRowIds);
135
+ const hasValidCheckedRows = ids.every((id) => currentRowIds.has(id));
141
136
  if (!hasValidCheckedRows) {
142
- setCheckedRows(/* @__PURE__ */ new Set());
137
+ setCheckedRowIds(new Set(checkedRows == null ? void 0 : checkedRows.map((row) => row.id)));
143
138
  }
144
139
  }, [rows.map((row) => row.id).join(",")]);
145
140
  useImperativeHandle(
146
141
  ref,
147
142
  () => ({
148
- checkedRows,
149
- setCheckedRows
143
+ checkedRowIds,
144
+ setCheckedRowIds
150
145
  }),
151
- [checkedRows]
146
+ [checkedRowIds]
152
147
  );
153
148
  const handleAllRowCheck = (checked) => {
154
149
  const updated = checked ? new Set(rows.map((row) => row.id)) : /* @__PURE__ */ new Set();
155
- setCheckedRows(updated);
150
+ setCheckedRowIds(updated);
156
151
  };
157
152
  const handleRowCheck = (id, checked) => {
158
- setCheckedRows((prev) => {
153
+ setCheckedRowIds((prev) => {
159
154
  const updated = new Set(prev);
160
155
  checked ? updated.add(id) : updated.delete(id);
161
156
  return updated;
@@ -191,9 +186,8 @@ var Table = forwardRef((originalProps, ref) => {
191
186
  size,
192
187
  color,
193
188
  rowCheckbox,
194
- hasCheckedRows: rows.length > 0 && rows.every((row) => checkedRows.has(row.id)),
189
+ hasCheckedRows: rows.length > 0 && rows.every((row) => checkedRowIds.has(row.id)),
195
190
  onCheckAll: handleAllRowCheck,
196
- isLoading,
197
191
  classNames,
198
192
  slots
199
193
  }
@@ -207,17 +201,12 @@ var Table = forwardRef((originalProps, ref) => {
207
201
  size,
208
202
  color,
209
203
  rowCheckbox,
210
- checkedRows,
204
+ checkedRows: checkedRowIds,
211
205
  onCheckRow: handleRowCheck,
212
206
  onRowClick: handleRowClick,
213
207
  isLoading,
214
208
  emptyContent,
215
- skeletonRow,
216
- className: clsx(
217
- "transition-all duration-150 ease-out",
218
- isLoading ? "-translate-y-2 opacity-0" : "translate-y-0 opacity-100",
219
- classNames
220
- )
209
+ classNames
221
210
  }
222
211
  )
223
212
  ]
@@ -277,7 +266,8 @@ var tableStyle = tv({
277
266
  "[&>*]:z-1",
278
267
  "[&>*]:relative",
279
268
  "align-middle"
280
- ]
269
+ ],
270
+ tbodyLoading: []
281
271
  },
282
272
  variants: {
283
273
  variant: {
@@ -485,7 +475,6 @@ var TableHead = ({
485
475
  size,
486
476
  rowCheckbox = false,
487
477
  hasCheckedRows,
488
- isLoading = false,
489
478
  classNames,
490
479
  onCheckAll
491
480
  }) => {
@@ -505,13 +494,7 @@ var TableHead = ({
505
494
  },
506
495
  key
507
496
  );
508
- const renderSkeletonRow = () => /* @__PURE__ */ jsx3("thead", { className: slots.thead({ class: classNames == null ? void 0 : classNames.thead }), children: /* @__PURE__ */ jsxs3("tr", { className: clsx(slots.tr({ class: classNames == null ? void 0 : classNames.tr }), "[&>th]:border-0"), children: [
509
- columns.map(
510
- (column, idx) => renderTh(/* @__PURE__ */ jsx3(skeleton_default, { color, rounded: "lg", speed: "fast" }), `skeleton-${idx}`, column)
511
- ),
512
- rowCheckbox && renderTh(/* @__PURE__ */ jsx3(skeleton_default, { color, rounded: "lg", speed: "fast" }), "checkbox-skeleton", void 0, true)
513
- ] }) });
514
- const renderContentRow = () => /* @__PURE__ */ jsx3("thead", { className: slots.thead({ class: classNames == null ? void 0 : classNames.thead }), children: /* @__PURE__ */ jsxs3("tr", { className: slots.tr({ class: classNames == null ? void 0 : classNames.tr }), children: [
497
+ return /* @__PURE__ */ jsx3("thead", { className: slots.thead({ class: classNames == null ? void 0 : classNames.thead }), children: /* @__PURE__ */ jsxs3("tr", { className: slots.tr({ class: classNames == null ? void 0 : classNames.tr }), children: [
515
498
  columns.map((column, idx) => renderTh(column.headerName, `${column.field}-${idx}`, column)),
516
499
  rowCheckbox && renderTh(
517
500
  /* @__PURE__ */ jsx3("div", { "data-checkbox": true, children: /* @__PURE__ */ jsx3(
@@ -527,7 +510,6 @@ var TableHead = ({
527
510
  true
528
511
  )
529
512
  ] }) });
530
- return isLoading ? renderSkeletonRow() : renderContentRow();
531
513
  };
532
514
  var table_head_default = TableHead;
533
515
 
@@ -30,7 +30,7 @@ var Pagination = forwardRef((originalProps, ref) => {
30
30
  totalPage,
31
31
  showPageNumber = true,
32
32
  showPageLabel,
33
- showFirstLastButtons,
33
+ showFirstLastButtons = true,
34
34
  handleChangePage,
35
35
  variant,
36
36
  size
@@ -5535,7 +5535,7 @@ var Pagination = (0, import_react3.forwardRef)((originalProps, ref) => {
5535
5535
  totalPage,
5536
5536
  showPageNumber = true,
5537
5537
  showPageLabel,
5538
- showFirstLastButtons,
5538
+ showFirstLastButtons = true,
5539
5539
  handleChangePage,
5540
5540
  variant,
5541
5541
  size
@@ -2,7 +2,7 @@
2
2
  import "../../chunk-7B7LRG5J.mjs";
3
3
  import {
4
4
  pagination_default
5
- } from "../../chunk-4URRLVNR.mjs";
5
+ } from "../../chunk-4JOD47VZ.mjs";
6
6
  import "../../chunk-F3HENRVM.mjs";
7
7
  import "../../chunk-2GCSFWHD.mjs";
8
8
  import "../../chunk-GL4E6YGW.mjs";
@@ -5533,7 +5533,7 @@ var Pagination = (0, import_react3.forwardRef)((originalProps, ref) => {
5533
5533
  totalPage,
5534
5534
  showPageNumber = true,
5535
5535
  showPageLabel,
5536
- showFirstLastButtons,
5536
+ showFirstLastButtons = true,
5537
5537
  handleChangePage,
5538
5538
  variant,
5539
5539
  size
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import {
3
3
  pagination_default
4
- } from "../../chunk-4URRLVNR.mjs";
4
+ } from "../../chunk-4JOD47VZ.mjs";
5
5
  import "../../chunk-F3HENRVM.mjs";
6
6
  import "../../chunk-2GCSFWHD.mjs";
7
7
  import "../../chunk-GL4E6YGW.mjs";