@itilite/lumina-ui 1.2.0 → 1.2.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.
@@ -0,0 +1,283 @@
1
+ import {
2
+ __objRest,
3
+ __spreadProps,
4
+ __spreadValues
5
+ } from "./chunk-FWCSY2DS.mjs";
6
+
7
+ // src/atom/Table/Table.tsx
8
+ import * as React from "react";
9
+ import { Table as AntTable } from "antd";
10
+ import clsx from "clsx";
11
+
12
+ // src/atom/Table/Table.module.scss
13
+ var Table_module_default = { "tableWrapper": "Table-module__tableWrapper___3cqiD", "isAccordion": "Table-module__isAccordion___-uIs6", "isToolbar": "Table-module__isToolbar___LdS-m", "hasCustomHeaderCell": "Table-module__hasCustomHeaderCell___AtCk8", "table": "Table-module__table___5d7g0", "ant-table-selection-column": "Table-module__ant-table-selection-column___H9vtu", "hasCustomBodyCell": "Table-module__hasCustomBodyCell___sf8j8", "firstRow": "Table-module__firstRow___Xq-Hi", "lastRow": "Table-module__lastRow___ahv4g", "showHoverEffect": "Table-module__showHoverEffect___IyKyO", "columnHeader": "Table-module__columnHeader___Unr6d", "columnHeaderLeft": "Table-module__columnHeaderLeft___mp7pK", "columnHeaderSortArea": "Table-module__columnHeaderSortArea___jrIYo", "columnHeaderLabel": "Table-module__columnHeaderLabel___A-mRu", "columnHeaderSortIcon": "Table-module__columnHeaderSortIcon___mWVZN", "columnHeaderSortIconActive": "Table-module__columnHeaderSortIconActive___wHAqC", "tableHeaderCellSorted": "Table-module__tableHeaderCellSorted___bfeqH", "columnHeaderFilterWrapper": "Table-module__columnHeaderFilterWrapper___DnSve", "columnHeaderFilterBtn": "Table-module__columnHeaderFilterBtn___NR7DY", "columnHeaderFilterBtnActive": "Table-module__columnHeaderFilterBtnActive___JdO11", "columnHeaderFilterBadge": "Table-module__columnHeaderFilterBadge___-Q2T2", "columnHeaderFilterDropdown": "Table-module__columnHeaderFilterDropdown___M-fD4" };
14
+
15
+ // src/atom/Table/Table.tsx
16
+ import { jsx, jsxs } from "react/jsx-runtime";
17
+ function buildPagination(pagination, overrides = {}) {
18
+ var _a, _b, _c, _d;
19
+ if (pagination === false) {
20
+ return false;
21
+ }
22
+ const defaults = {
23
+ showSizeChanger: true,
24
+ pageSizeOptions: ["10", "25", "50"],
25
+ locale: { items_per_page: "" },
26
+ // Removes "/ page" text
27
+ showTotal: (total, range) => `${range[0]}\u2013${range[1]} of ${total} items`
28
+ };
29
+ const baseConfig = pagination === true || pagination === void 0 ? defaults : __spreadValues(__spreadValues({}, defaults), pagination);
30
+ return __spreadProps(__spreadValues({}, baseConfig), {
31
+ total: (_a = overrides.total) != null ? _a : baseConfig.total,
32
+ current: (_b = overrides.current) != null ? _b : baseConfig.current,
33
+ pageSize: (_c = overrides.pageSize) != null ? _c : baseConfig.pageSize,
34
+ onChange: (_d = overrides.onChange) != null ? _d : baseConfig.onChange
35
+ });
36
+ }
37
+ function nextSortOrder(current) {
38
+ if (current === void 0) return "ascend";
39
+ if (current === "ascend") return "descend";
40
+ return void 0;
41
+ }
42
+ function ColumnHeader({
43
+ label,
44
+ sortable = false,
45
+ sortOrder,
46
+ onSortChange,
47
+ sortIcon,
48
+ filterCount = 0,
49
+ filterIcon,
50
+ filterContent,
51
+ className = ""
52
+ }) {
53
+ const [filterOpen, setFilterOpen] = React.useState(false);
54
+ const wrapperRef = React.useRef(null);
55
+ const filterActive = filterCount > 0;
56
+ const hasFilter = filterContent !== void 0 && filterIcon !== void 0;
57
+ const hasSort = sortable && sortIcon !== void 0;
58
+ React.useEffect(() => {
59
+ if (!filterOpen) return;
60
+ const onOutside = (e) => {
61
+ if (wrapperRef.current && !wrapperRef.current.contains(e.target)) {
62
+ setFilterOpen(false);
63
+ }
64
+ };
65
+ document.addEventListener("mousedown", onOutside);
66
+ return () => document.removeEventListener("mousedown", onOutside);
67
+ }, [filterOpen]);
68
+ return /* @__PURE__ */ jsxs("div", { className: Table_module_default.columnHeader, ref: wrapperRef, children: [
69
+ /* @__PURE__ */ jsx("div", { className: Table_module_default.columnHeaderLeft, children: hasSort ? /* @__PURE__ */ jsxs(
70
+ "button",
71
+ {
72
+ type: "button",
73
+ className: Table_module_default.columnHeaderSortArea,
74
+ onClick: () => onSortChange == null ? void 0 : onSortChange(nextSortOrder(sortOrder)),
75
+ "aria-label": typeof label === "string" ? `Sort by ${label}` : "Sort",
76
+ children: [
77
+ /* @__PURE__ */ jsx("span", { className: clsx(Table_module_default.columnHeaderLabel, className), children: label }),
78
+ /* @__PURE__ */ jsx(
79
+ "span",
80
+ {
81
+ className: clsx(Table_module_default.columnHeaderSortIcon, {
82
+ [Table_module_default.columnHeaderSortIconActive]: sortOrder !== void 0
83
+ }),
84
+ children: sortIcon
85
+ }
86
+ )
87
+ ]
88
+ }
89
+ ) : /* @__PURE__ */ jsx("span", { className: clsx(Table_module_default.columnHeaderLabel, className), children: label }) }),
90
+ hasFilter && /* @__PURE__ */ jsxs("div", { className: Table_module_default.columnHeaderFilterWrapper, children: [
91
+ /* @__PURE__ */ jsxs(
92
+ "button",
93
+ {
94
+ type: "button",
95
+ className: clsx(Table_module_default.columnHeaderFilterBtn, {
96
+ [Table_module_default.columnHeaderFilterBtnActive]: filterActive
97
+ }),
98
+ onClick: () => setFilterOpen((v) => !v),
99
+ "aria-label": typeof label === "string" ? `Filter ${label}` : "Filter",
100
+ "aria-expanded": filterOpen,
101
+ "aria-haspopup": "dialog",
102
+ children: [
103
+ filterIcon,
104
+ filterActive && /* @__PURE__ */ jsx("span", { className: Table_module_default.columnHeaderFilterBadge, children: filterCount })
105
+ ]
106
+ }
107
+ ),
108
+ filterOpen && /* @__PURE__ */ jsx("div", { className: Table_module_default.columnHeaderFilterDropdown, role: "dialog", children: filterContent })
109
+ ] })
110
+ ] });
111
+ }
112
+ function processColumns(columns, headerCellClassName, bodyCellClassName) {
113
+ if (!columns) return void 0;
114
+ return columns.map((col) => {
115
+ const _a = col, { headerProps, title, onHeaderCell, onCell } = _a, rest = __objRest(_a, ["headerProps", "title", "onHeaderCell", "onCell"]);
116
+ const resolvedOnHeaderCell = (column) => {
117
+ var _a2;
118
+ const base = (_a2 = onHeaderCell == null ? void 0 : onHeaderCell(column)) != null ? _a2 : {};
119
+ return __spreadProps(__spreadValues({}, base), {
120
+ className: clsx(base.className, headerCellClassName)
121
+ });
122
+ };
123
+ const resolvedOnCell = (record, rowIndex) => {
124
+ var _a2;
125
+ const base = (_a2 = onCell == null ? void 0 : onCell(record, rowIndex)) != null ? _a2 : {};
126
+ return __spreadProps(__spreadValues({}, base), {
127
+ className: clsx(base.className, bodyCellClassName)
128
+ });
129
+ };
130
+ const processedTitle = headerProps ? /* @__PURE__ */ jsx(ColumnHeader, __spreadValues({ label: title }, headerProps)) : title;
131
+ return __spreadProps(__spreadValues({}, rest), {
132
+ title: processedTitle,
133
+ onHeaderCell: resolvedOnHeaderCell,
134
+ onCell: resolvedOnCell
135
+ });
136
+ });
137
+ }
138
+ function Table(props) {
139
+ var _b;
140
+ const _a = props, {
141
+ size = "middle",
142
+ variant = "default",
143
+ isAccordion = false,
144
+ isToolbar = false,
145
+ className = "",
146
+ pagination,
147
+ loading,
148
+ total,
149
+ current,
150
+ pageSize,
151
+ onPaginationChange,
152
+ columns,
153
+ rowSelection,
154
+ rowKey = "key",
155
+ onRow,
156
+ dataSource,
157
+ emptyState,
158
+ hideHeader,
159
+ loadingIndicator,
160
+ style,
161
+ headerCellClassName,
162
+ bodyCellClassName,
163
+ rowClassName
164
+ } = _a, rest = __objRest(_a, [
165
+ "size",
166
+ "variant",
167
+ "isAccordion",
168
+ "isToolbar",
169
+ "className",
170
+ "pagination",
171
+ "loading",
172
+ "total",
173
+ "current",
174
+ "pageSize",
175
+ "onPaginationChange",
176
+ "columns",
177
+ "rowSelection",
178
+ "rowKey",
179
+ "onRow",
180
+ "dataSource",
181
+ "emptyState",
182
+ "hideHeader",
183
+ "loadingIndicator",
184
+ "style",
185
+ "headerCellClassName",
186
+ "bodyCellClassName",
187
+ "rowClassName"
188
+ ]);
189
+ const resolvedPagination = buildPagination(pagination, {
190
+ total,
191
+ current,
192
+ pageSize,
193
+ onChange: onPaginationChange
194
+ });
195
+ const processedColumns = React.useMemo(
196
+ () => processColumns(columns, headerCellClassName, bodyCellClassName),
197
+ [columns, headerCellClassName, bodyCellClassName]
198
+ );
199
+ const resolvedRowSelection = React.useMemo(() => {
200
+ if (!rowSelection) return void 0;
201
+ return __spreadValues({
202
+ columnWidth: 48
203
+ }, rowSelection);
204
+ }, [rowSelection]);
205
+ const resolvedOnRow = React.useMemo(() => {
206
+ const onChange = resolvedRowSelection == null ? void 0 : resolvedRowSelection.onChange;
207
+ if (variant !== "selectable" || !onChange) return onRow;
208
+ return (record, index) => {
209
+ var _a2;
210
+ const base = (_a2 = onRow == null ? void 0 : onRow(record, index)) != null ? _a2 : {};
211
+ const getKey = (r, i) => typeof rowKey === "function" ? rowKey(r, i) : r[rowKey];
212
+ return __spreadProps(__spreadValues({}, base), {
213
+ style: __spreadValues({ cursor: "pointer" }, base.style),
214
+ onClick: (e) => {
215
+ var _a3, _b2;
216
+ (_a3 = base.onClick) == null ? void 0 : _a3.call(base, e);
217
+ const key = getKey(record, index);
218
+ const current2 = (_b2 = resolvedRowSelection.selectedRowKeys) != null ? _b2 : [];
219
+ const isSelected = current2.some((k) => k === key);
220
+ const newKeys = isSelected ? current2.filter((k) => k !== key) : [...current2, key];
221
+ const newRows = (dataSource != null ? dataSource : []).filter(
222
+ (r, idx) => newKeys.some((k) => k === getKey(r, idx))
223
+ );
224
+ onChange(newKeys, newRows, { type: "single" });
225
+ }
226
+ });
227
+ };
228
+ }, [variant, resolvedRowSelection, rowKey, onRow, dataSource]);
229
+ return /* @__PURE__ */ jsx(
230
+ "div",
231
+ {
232
+ className: clsx(
233
+ Table_module_default.tableWrapper,
234
+ Table_module_default.showHoverEffect,
235
+ {
236
+ [Table_module_default.isAccordion]: isAccordion,
237
+ [Table_module_default.isToolbar]: isToolbar,
238
+ [Table_module_default.hasCustomHeaderCell]: !!headerCellClassName,
239
+ [Table_module_default.hasCustomBodyCell]: !!bodyCellClassName
240
+ },
241
+ className
242
+ ),
243
+ style,
244
+ "data-testid": "lumina-table",
245
+ children: /* @__PURE__ */ jsx(
246
+ AntTable,
247
+ __spreadProps(__spreadValues({
248
+ className: Table_module_default.table,
249
+ size,
250
+ pagination: resolvedPagination,
251
+ columns: processedColumns,
252
+ rowSelection: resolvedRowSelection,
253
+ rowKey,
254
+ onRow: resolvedOnRow,
255
+ dataSource,
256
+ showHeader: !hideHeader,
257
+ locale: {
258
+ emptyText: loading && loadingIndicator ? loadingIndicator : loading ? " " : emptyState
259
+ }
260
+ }, rest), {
261
+ loading: loadingIndicator ? { spinning: !!loading && ((_b = dataSource == null ? void 0 : dataSource.length) != null ? _b : 0) > 0, indicator: loadingIndicator } : loading,
262
+ rowClassName: (record, index) => {
263
+ var _a2;
264
+ return clsx(
265
+ {
266
+ [Table_module_default.firstRow]: index === 0,
267
+ [Table_module_default.lastRow]: index === ((_a2 = dataSource == null ? void 0 : dataSource.length) != null ? _a2 : 0) - 1
268
+ },
269
+ typeof rowClassName === "function" ? rowClassName(record, index) : rowClassName
270
+ );
271
+ }
272
+ })
273
+ )
274
+ }
275
+ );
276
+ }
277
+ Table.displayName = "Table";
278
+ var Table_default = Table;
279
+
280
+ export {
281
+ Table,
282
+ Table_default
283
+ };
@@ -0,0 +1,301 @@
1
+ import {
2
+ __objRest,
3
+ __spreadProps,
4
+ __spreadValues
5
+ } from "./chunk-FWCSY2DS.mjs";
6
+
7
+ // src/atom/Table/Table.tsx
8
+ import * as React from "react";
9
+ import { Table as AntTable } from "antd";
10
+ import clsx from "clsx";
11
+
12
+ // src/atom/Table/Table.module.scss
13
+ var Table_module_default = { "tableWrapper": "Table-module__tableWrapper___3cqiD", "isAccordion": "Table-module__isAccordion___-uIs6", "isToolbar": "Table-module__isToolbar___LdS-m", "hasCustomHeaderCell": "Table-module__hasCustomHeaderCell___AtCk8", "table": "Table-module__table___5d7g0", "ant-table-selection-column": "Table-module__ant-table-selection-column___H9vtu", "hasCustomBodyCell": "Table-module__hasCustomBodyCell___sf8j8", "firstRow": "Table-module__firstRow___Xq-Hi", "lastRow": "Table-module__lastRow___ahv4g", "showHoverEffect": "Table-module__showHoverEffect___IyKyO", "columnHeader": "Table-module__columnHeader___Unr6d", "columnHeaderLeft": "Table-module__columnHeaderLeft___mp7pK", "columnHeaderSortArea": "Table-module__columnHeaderSortArea___jrIYo", "columnHeaderLabel": "Table-module__columnHeaderLabel___A-mRu", "columnHeaderSortIcon": "Table-module__columnHeaderSortIcon___mWVZN", "columnHeaderSortIconActive": "Table-module__columnHeaderSortIconActive___wHAqC", "tableHeaderCellSorted": "Table-module__tableHeaderCellSorted___bfeqH", "columnHeaderFilterWrapper": "Table-module__columnHeaderFilterWrapper___DnSve", "columnHeaderFilterBtn": "Table-module__columnHeaderFilterBtn___NR7DY", "columnHeaderFilterBtnActive": "Table-module__columnHeaderFilterBtnActive___JdO11", "columnHeaderFilterBadge": "Table-module__columnHeaderFilterBadge___-Q2T2", "columnHeaderFilterDropdown": "Table-module__columnHeaderFilterDropdown___M-fD4" };
14
+
15
+ // src/atom/Table/Table.tsx
16
+ import { jsx, jsxs } from "react/jsx-runtime";
17
+ function buildPagination(pagination, overrides = {}) {
18
+ var _a, _b, _c, _d;
19
+ if (pagination === false) {
20
+ return false;
21
+ }
22
+ const defaults = {
23
+ showSizeChanger: true,
24
+ pageSizeOptions: ["10", "25", "50"],
25
+ locale: { items_per_page: "" },
26
+ // Removes "/ page" text
27
+ showTotal: (total, range) => `${range[0]}\u2013${range[1]} of ${total} items`
28
+ };
29
+ const baseConfig = pagination === true || pagination === void 0 ? defaults : __spreadValues(__spreadValues({}, defaults), pagination);
30
+ return __spreadProps(__spreadValues({}, baseConfig), {
31
+ total: (_a = overrides.total) != null ? _a : baseConfig.total,
32
+ current: (_b = overrides.current) != null ? _b : baseConfig.current,
33
+ pageSize: (_c = overrides.pageSize) != null ? _c : baseConfig.pageSize,
34
+ onChange: (_d = overrides.onChange) != null ? _d : baseConfig.onChange
35
+ });
36
+ }
37
+ var DefaultSortIcon = () => /* @__PURE__ */ jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: "14", height: "14", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M8 9l4-4 4 4m0 6l-4 4-4-4" }) });
38
+ var AscendSortIcon = () => /* @__PURE__ */ jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: "14", height: "14", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M5 15l7-7 7 7" }) });
39
+ var DescendSortIcon = () => /* @__PURE__ */ jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: "14", height: "14", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", strokeWidth: "2", children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M19 9l-7 7-7-7" }) });
40
+ function nextSortOrder(current) {
41
+ if (current === void 0) return "ascend";
42
+ if (current === "ascend") return "descend";
43
+ return void 0;
44
+ }
45
+ function ColumnHeader({
46
+ label,
47
+ sortable = false,
48
+ sortOrder,
49
+ onSortChange,
50
+ sortIcon,
51
+ filterCount = 0,
52
+ filterIcon,
53
+ filterContent,
54
+ className = ""
55
+ }) {
56
+ const [filterOpen, setFilterOpen] = React.useState(false);
57
+ const wrapperRef = React.useRef(null);
58
+ const filterActive = filterCount > 0;
59
+ const hasFilter = filterContent !== void 0 && filterIcon !== void 0;
60
+ const hasSort = sortable;
61
+ React.useEffect(() => {
62
+ if (!filterOpen) return;
63
+ const onOutside = (e) => {
64
+ if (wrapperRef.current && !wrapperRef.current.contains(e.target)) {
65
+ setFilterOpen(false);
66
+ }
67
+ };
68
+ document.addEventListener("mousedown", onOutside);
69
+ return () => document.removeEventListener("mousedown", onOutside);
70
+ }, [filterOpen]);
71
+ const renderSortIcon = () => {
72
+ if (!sortable) return null;
73
+ if (sortOrder === "ascend") {
74
+ return /* @__PURE__ */ jsx(AscendSortIcon, {});
75
+ }
76
+ if (sortOrder === "descend") {
77
+ return /* @__PURE__ */ jsx(DescendSortIcon, {});
78
+ }
79
+ return sortIcon || /* @__PURE__ */ jsx(DefaultSortIcon, {});
80
+ };
81
+ return /* @__PURE__ */ jsxs("div", { className: Table_module_default.columnHeader, ref: wrapperRef, children: [
82
+ /* @__PURE__ */ jsx("div", { className: Table_module_default.columnHeaderLeft, children: hasSort ? /* @__PURE__ */ jsxs(
83
+ "button",
84
+ {
85
+ type: "button",
86
+ className: Table_module_default.columnHeaderSortArea,
87
+ onClick: () => onSortChange == null ? void 0 : onSortChange(nextSortOrder(sortOrder)),
88
+ "aria-label": typeof label === "string" ? `Sort by ${label}` : "Sort",
89
+ children: [
90
+ /* @__PURE__ */ jsx("span", { className: clsx(Table_module_default.columnHeaderLabel, className), children: label }),
91
+ /* @__PURE__ */ jsx(
92
+ "span",
93
+ {
94
+ className: clsx(Table_module_default.columnHeaderSortIcon, {
95
+ [Table_module_default.columnHeaderSortIconActive]: sortOrder !== void 0
96
+ }),
97
+ children: renderSortIcon()
98
+ }
99
+ )
100
+ ]
101
+ }
102
+ ) : /* @__PURE__ */ jsx("span", { className: clsx(Table_module_default.columnHeaderLabel, className), children: label }) }),
103
+ hasFilter && /* @__PURE__ */ jsxs("div", { className: Table_module_default.columnHeaderFilterWrapper, children: [
104
+ /* @__PURE__ */ jsxs(
105
+ "button",
106
+ {
107
+ type: "button",
108
+ className: clsx(Table_module_default.columnHeaderFilterBtn, {
109
+ [Table_module_default.columnHeaderFilterBtnActive]: filterActive
110
+ }),
111
+ onClick: () => setFilterOpen((v) => !v),
112
+ "aria-label": typeof label === "string" ? `Filter ${label}` : "Filter",
113
+ "aria-expanded": filterOpen,
114
+ "aria-haspopup": "dialog",
115
+ children: [
116
+ filterIcon,
117
+ filterActive && /* @__PURE__ */ jsx("span", { className: Table_module_default.columnHeaderFilterBadge, children: filterCount })
118
+ ]
119
+ }
120
+ ),
121
+ filterOpen && /* @__PURE__ */ jsx("div", { className: Table_module_default.columnHeaderFilterDropdown, role: "dialog", children: filterContent })
122
+ ] })
123
+ ] });
124
+ }
125
+ function processColumns(columns, headerCellClassName, bodyCellClassName) {
126
+ if (!columns) return void 0;
127
+ return columns.map((col) => {
128
+ const _a = col, { headerProps, title, onHeaderCell, onCell } = _a, rest = __objRest(_a, ["headerProps", "title", "onHeaderCell", "onCell"]);
129
+ const resolvedOnHeaderCell = (column) => {
130
+ var _a2;
131
+ const base = (_a2 = onHeaderCell == null ? void 0 : onHeaderCell(column)) != null ? _a2 : {};
132
+ const isSorted = (headerProps == null ? void 0 : headerProps.sortable) && ((headerProps == null ? void 0 : headerProps.sortOrder) === "ascend" || (headerProps == null ? void 0 : headerProps.sortOrder) === "descend");
133
+ return __spreadProps(__spreadValues({}, base), {
134
+ className: clsx(
135
+ base.className,
136
+ headerCellClassName,
137
+ isSorted && Table_module_default.tableHeaderCellSorted
138
+ )
139
+ });
140
+ };
141
+ const resolvedOnCell = (record, rowIndex) => {
142
+ var _a2;
143
+ const base = (_a2 = onCell == null ? void 0 : onCell(record, rowIndex)) != null ? _a2 : {};
144
+ return __spreadProps(__spreadValues({}, base), {
145
+ className: clsx(base.className, bodyCellClassName)
146
+ });
147
+ };
148
+ const processedTitle = headerProps ? /* @__PURE__ */ jsx(ColumnHeader, __spreadValues({ label: title }, headerProps)) : title;
149
+ return __spreadProps(__spreadValues({}, rest), {
150
+ title: processedTitle,
151
+ onHeaderCell: resolvedOnHeaderCell,
152
+ onCell: resolvedOnCell
153
+ });
154
+ });
155
+ }
156
+ function Table(props) {
157
+ var _b;
158
+ const _a = props, {
159
+ size = "middle",
160
+ variant = "default",
161
+ isAccordion = false,
162
+ isToolbar = false,
163
+ className = "",
164
+ pagination,
165
+ loading,
166
+ total,
167
+ current,
168
+ pageSize,
169
+ onPaginationChange,
170
+ columns,
171
+ rowSelection,
172
+ rowKey = "key",
173
+ onRow,
174
+ dataSource,
175
+ emptyState,
176
+ hideHeader,
177
+ loadingIndicator,
178
+ style,
179
+ headerCellClassName,
180
+ bodyCellClassName,
181
+ rowClassName
182
+ } = _a, rest = __objRest(_a, [
183
+ "size",
184
+ "variant",
185
+ "isAccordion",
186
+ "isToolbar",
187
+ "className",
188
+ "pagination",
189
+ "loading",
190
+ "total",
191
+ "current",
192
+ "pageSize",
193
+ "onPaginationChange",
194
+ "columns",
195
+ "rowSelection",
196
+ "rowKey",
197
+ "onRow",
198
+ "dataSource",
199
+ "emptyState",
200
+ "hideHeader",
201
+ "loadingIndicator",
202
+ "style",
203
+ "headerCellClassName",
204
+ "bodyCellClassName",
205
+ "rowClassName"
206
+ ]);
207
+ const resolvedPagination = buildPagination(pagination, {
208
+ total,
209
+ current,
210
+ pageSize,
211
+ onChange: onPaginationChange
212
+ });
213
+ const processedColumns = React.useMemo(
214
+ () => processColumns(columns, headerCellClassName, bodyCellClassName),
215
+ [columns, headerCellClassName, bodyCellClassName]
216
+ );
217
+ const resolvedRowSelection = React.useMemo(() => {
218
+ if (!rowSelection) return void 0;
219
+ return __spreadValues({
220
+ columnWidth: 48
221
+ }, rowSelection);
222
+ }, [rowSelection]);
223
+ const resolvedOnRow = React.useMemo(() => {
224
+ const onChange = resolvedRowSelection == null ? void 0 : resolvedRowSelection.onChange;
225
+ if (variant !== "selectable" || !onChange) return onRow;
226
+ return (record, index) => {
227
+ var _a2;
228
+ const base = (_a2 = onRow == null ? void 0 : onRow(record, index)) != null ? _a2 : {};
229
+ const getKey = (r, i) => typeof rowKey === "function" ? rowKey(r, i) : r[rowKey];
230
+ return __spreadProps(__spreadValues({}, base), {
231
+ style: __spreadValues({ cursor: "pointer" }, base.style),
232
+ onClick: (e) => {
233
+ var _a3, _b2;
234
+ (_a3 = base.onClick) == null ? void 0 : _a3.call(base, e);
235
+ const key = getKey(record, index);
236
+ const current2 = (_b2 = resolvedRowSelection.selectedRowKeys) != null ? _b2 : [];
237
+ const isSelected = current2.some((k) => k === key);
238
+ const newKeys = isSelected ? current2.filter((k) => k !== key) : [...current2, key];
239
+ const newRows = (dataSource != null ? dataSource : []).filter(
240
+ (r, idx) => newKeys.some((k) => k === getKey(r, idx))
241
+ );
242
+ onChange(newKeys, newRows, { type: "single" });
243
+ }
244
+ });
245
+ };
246
+ }, [variant, resolvedRowSelection, rowKey, onRow, dataSource]);
247
+ return /* @__PURE__ */ jsx(
248
+ "div",
249
+ {
250
+ className: clsx(
251
+ Table_module_default.tableWrapper,
252
+ Table_module_default.showHoverEffect,
253
+ {
254
+ [Table_module_default.isAccordion]: isAccordion,
255
+ [Table_module_default.isToolbar]: isToolbar,
256
+ [Table_module_default.hasCustomHeaderCell]: !!headerCellClassName,
257
+ [Table_module_default.hasCustomBodyCell]: !!bodyCellClassName
258
+ },
259
+ className
260
+ ),
261
+ style,
262
+ "data-testid": "lumina-table",
263
+ children: /* @__PURE__ */ jsx(
264
+ AntTable,
265
+ __spreadProps(__spreadValues({
266
+ className: Table_module_default.table,
267
+ size,
268
+ pagination: resolvedPagination,
269
+ columns: processedColumns,
270
+ rowSelection: resolvedRowSelection,
271
+ rowKey,
272
+ onRow: resolvedOnRow,
273
+ dataSource,
274
+ showHeader: !hideHeader,
275
+ locale: {
276
+ emptyText: loading && loadingIndicator ? loadingIndicator : loading ? " " : emptyState
277
+ }
278
+ }, rest), {
279
+ loading: loadingIndicator ? { spinning: !!loading && ((_b = dataSource == null ? void 0 : dataSource.length) != null ? _b : 0) > 0, indicator: loadingIndicator } : loading,
280
+ rowClassName: (record, index) => {
281
+ var _a2;
282
+ return clsx(
283
+ {
284
+ [Table_module_default.firstRow]: index === 0,
285
+ [Table_module_default.lastRow]: index === ((_a2 = dataSource == null ? void 0 : dataSource.length) != null ? _a2 : 0) - 1
286
+ },
287
+ typeof rowClassName === "function" ? rowClassName(record, index) : rowClassName
288
+ );
289
+ }
290
+ })
291
+ )
292
+ }
293
+ );
294
+ }
295
+ Table.displayName = "Table";
296
+ var Table_default = Table;
297
+
298
+ export {
299
+ Table,
300
+ Table_default
301
+ };