@itilite/lumina-ui 1.2.2 → 1.2.21

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.
Files changed (91) hide show
  1. package/dist/atom/AdvancedDateRangePicker/AdvancedDateRangePicker.mjs +1 -1
  2. package/dist/atom/Switch/Switch.d.mts +1 -1
  3. package/dist/atom/Switch/Switch.d.ts +1 -1
  4. package/dist/atom/Switch/Switch.js +2 -2
  5. package/dist/atom/Switch/Switch.mjs +1 -1
  6. package/dist/{chunk-TMSPSGSS.mjs → chunk-IIJUGDEJ.mjs} +3 -3
  7. package/dist/{chunk-E27NPVR4.mjs → chunk-LTP5I3GX.mjs} +3 -3
  8. package/dist/chunk-O6PQFAXN.mjs +47 -0
  9. package/dist/index.js +2 -2
  10. package/dist/index.mjs +6 -6
  11. package/dist/styles.css +847 -824
  12. package/package.json +28 -27
  13. package/dist/AdvancedDateRangePicker-D7xn4So6.d.mts +0 -59
  14. package/dist/AdvancedDateRangePicker-D7xn4So6.d.ts +0 -59
  15. package/dist/AdvancedDateRangePicker-D9Sdk4rK.d.mts +0 -64
  16. package/dist/AdvancedDateRangePicker-D9Sdk4rK.d.ts +0 -64
  17. package/dist/AdvancedDateRangePicker-DGg-rucL.d.mts +0 -62
  18. package/dist/AdvancedDateRangePicker-DGg-rucL.d.ts +0 -62
  19. package/dist/AdvancedDateRangePicker-Di3rHxqf.d.mts +0 -64
  20. package/dist/AdvancedDateRangePicker-Di3rHxqf.d.ts +0 -64
  21. package/dist/AdvancedDateRangePicker-Dxug2Mcf.d.mts +0 -60
  22. package/dist/AdvancedDateRangePicker-Dxug2Mcf.d.ts +0 -60
  23. package/dist/AdvancedDateRangePicker-ozItnkhp.d.mts +0 -57
  24. package/dist/AdvancedDateRangePicker-ozItnkhp.d.ts +0 -57
  25. package/dist/Table-BOq-_9Nr.d.mts +0 -121
  26. package/dist/Table-BOq-_9Nr.d.ts +0 -121
  27. package/dist/Table-BxaCiQmh.d.mts +0 -82
  28. package/dist/Table-BxaCiQmh.d.ts +0 -82
  29. package/dist/Table-CnzP9dkc.d.mts +0 -82
  30. package/dist/Table-CnzP9dkc.d.ts +0 -82
  31. package/dist/Table-DNvoh2P8.d.mts +0 -127
  32. package/dist/Table-DNvoh2P8.d.ts +0 -127
  33. package/dist/Table-DSFYzrpU.d.mts +0 -129
  34. package/dist/Table-DSFYzrpU.d.ts +0 -129
  35. package/dist/Table-DmfNNnuD.d.mts +0 -86
  36. package/dist/Table-DmfNNnuD.d.ts +0 -86
  37. package/dist/Table-DoCPt3ri.d.mts +0 -129
  38. package/dist/Table-DoCPt3ri.d.ts +0 -129
  39. package/dist/chunk-27LRL4RO.mjs +0 -428
  40. package/dist/chunk-2IT3XM7C.mjs +0 -473
  41. package/dist/chunk-3HXZIFV6.mjs +0 -438
  42. package/dist/chunk-4JX54OKI.mjs +0 -627
  43. package/dist/chunk-53O7JM5I.mjs +0 -424
  44. package/dist/chunk-5JXIJTAS.mjs +0 -448
  45. package/dist/chunk-5OUMKJWI.mjs +0 -301
  46. package/dist/chunk-5PMUTA6S.mjs +0 -303
  47. package/dist/chunk-5PQ43JFX.mjs +0 -440
  48. package/dist/chunk-62VAYFZA.mjs +0 -437
  49. package/dist/chunk-6ON32H2N.mjs +0 -431
  50. package/dist/chunk-6RIZXTFP.mjs +0 -290
  51. package/dist/chunk-6XIT27XY.mjs +0 -269
  52. package/dist/chunk-772C454L.mjs +0 -438
  53. package/dist/chunk-7L267Y4P.mjs +0 -429
  54. package/dist/chunk-7WSVCE2C.mjs +0 -269
  55. package/dist/chunk-ANJI6SPV.mjs +0 -283
  56. package/dist/chunk-BFFLWW7N.mjs +0 -250
  57. package/dist/chunk-C5VYFNVC.mjs +0 -441
  58. package/dist/chunk-CDYPIUWU.mjs +0 -681
  59. package/dist/chunk-DL7BZMGE.mjs +0 -295
  60. package/dist/chunk-DXPVJNGY.mjs +0 -284
  61. package/dist/chunk-FTL3PFC2.mjs +0 -438
  62. package/dist/chunk-G4P6XGQX.mjs +0 -278
  63. package/dist/chunk-GGWY2SYX.mjs +0 -452
  64. package/dist/chunk-GZ4P7OL3.mjs +0 -429
  65. package/dist/chunk-I6GLPWHS.mjs +0 -278
  66. package/dist/chunk-IPVJEGDI.mjs +0 -476
  67. package/dist/chunk-J4YYP4IZ.mjs +0 -0
  68. package/dist/chunk-J5JDQ4R6.mjs +0 -278
  69. package/dist/chunk-K2A4TWA3.mjs +0 -430
  70. package/dist/chunk-L3L42SIL.mjs +0 -429
  71. package/dist/chunk-LRNKIRH3.mjs +0 -289
  72. package/dist/chunk-MA23J4WQ.mjs +0 -430
  73. package/dist/chunk-N4DPPZVJ.mjs +0 -269
  74. package/dist/chunk-PQ3B2FEB.mjs +0 -249
  75. package/dist/chunk-QQA7KWAJ.mjs +0 -477
  76. package/dist/chunk-QRGHJP7U.mjs +0 -437
  77. package/dist/chunk-QU73KNTT.mjs +0 -452
  78. package/dist/chunk-RC6IGURJ.mjs +0 -428
  79. package/dist/chunk-SKPCOHON.mjs +0 -473
  80. package/dist/chunk-SRKN7WS7.mjs +0 -448
  81. package/dist/chunk-T43CWNOG.mjs +0 -283
  82. package/dist/chunk-TE5EOIIW.mjs +0 -301
  83. package/dist/chunk-TQDZWJZP.mjs +0 -269
  84. package/dist/chunk-UAGSPM3T.mjs +0 -288
  85. package/dist/chunk-UC4NTBDH.mjs +0 -439
  86. package/dist/chunk-UPSQTJJ4.mjs +0 -294
  87. package/dist/chunk-V3CHJHUX.mjs +0 -424
  88. package/dist/chunk-X3NDICAU.mjs +0 -284
  89. package/dist/chunk-XECXKSTC.mjs +0 -453
  90. package/dist/chunk-XIVTXS3Y.mjs +0 -439
  91. package/dist/chunk-ZGV6QMVM.mjs +0 -437
@@ -1,301 +0,0 @@
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", "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
- };
@@ -1,303 +0,0 @@
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
- sortAscendIcon,
52
- sortDescendIcon,
53
- filterCount = 0,
54
- filterIcon,
55
- filterContent,
56
- className = ""
57
- }) {
58
- const [filterOpen, setFilterOpen] = React.useState(false);
59
- const wrapperRef = React.useRef(null);
60
- const filterActive = filterCount > 0;
61
- const hasFilter = filterContent !== void 0 && filterIcon !== void 0;
62
- const hasSort = sortable;
63
- React.useEffect(() => {
64
- if (!filterOpen) return;
65
- const onOutside = (e) => {
66
- if (wrapperRef.current && !wrapperRef.current.contains(e.target)) {
67
- setFilterOpen(false);
68
- }
69
- };
70
- document.addEventListener("mousedown", onOutside);
71
- return () => document.removeEventListener("mousedown", onOutside);
72
- }, [filterOpen]);
73
- const renderSortIcon = () => {
74
- if (!sortable) return null;
75
- if (sortOrder === "ascend") {
76
- return sortAscendIcon || /* @__PURE__ */ jsx(AscendSortIcon, {});
77
- }
78
- if (sortOrder === "descend") {
79
- return sortDescendIcon || /* @__PURE__ */ jsx(DescendSortIcon, {});
80
- }
81
- return sortIcon || /* @__PURE__ */ jsx(DefaultSortIcon, {});
82
- };
83
- return /* @__PURE__ */ jsxs("div", { className: Table_module_default.columnHeader, ref: wrapperRef, children: [
84
- /* @__PURE__ */ jsx("div", { className: Table_module_default.columnHeaderLeft, children: hasSort ? /* @__PURE__ */ jsxs(
85
- "button",
86
- {
87
- type: "button",
88
- className: Table_module_default.columnHeaderSortArea,
89
- onClick: () => onSortChange == null ? void 0 : onSortChange(nextSortOrder(sortOrder)),
90
- "aria-label": typeof label === "string" ? `Sort by ${label}` : "Sort",
91
- children: [
92
- /* @__PURE__ */ jsx("span", { className: clsx(Table_module_default.columnHeaderLabel, className), children: label }),
93
- /* @__PURE__ */ jsx(
94
- "span",
95
- {
96
- className: clsx(Table_module_default.columnHeaderSortIcon, {
97
- [Table_module_default.columnHeaderSortIconActive]: sortOrder !== void 0
98
- }),
99
- children: renderSortIcon()
100
- }
101
- )
102
- ]
103
- }
104
- ) : /* @__PURE__ */ jsx("span", { className: clsx(Table_module_default.columnHeaderLabel, className), children: label }) }),
105
- hasFilter && /* @__PURE__ */ jsxs("div", { className: Table_module_default.columnHeaderFilterWrapper, children: [
106
- /* @__PURE__ */ jsxs(
107
- "button",
108
- {
109
- type: "button",
110
- className: clsx(Table_module_default.columnHeaderFilterBtn, {
111
- [Table_module_default.columnHeaderFilterBtnActive]: filterActive
112
- }),
113
- onClick: () => setFilterOpen((v) => !v),
114
- "aria-label": typeof label === "string" ? `Filter ${label}` : "Filter",
115
- "aria-expanded": filterOpen,
116
- "aria-haspopup": "dialog",
117
- children: [
118
- filterIcon,
119
- filterActive && /* @__PURE__ */ jsx("span", { className: Table_module_default.columnHeaderFilterBadge, children: filterCount })
120
- ]
121
- }
122
- ),
123
- filterOpen && /* @__PURE__ */ jsx("div", { className: Table_module_default.columnHeaderFilterDropdown, role: "dialog", children: filterContent })
124
- ] })
125
- ] });
126
- }
127
- function processColumns(columns, headerCellClassName, bodyCellClassName) {
128
- if (!columns) return void 0;
129
- return columns.map((col) => {
130
- const _a = col, { headerProps, title, onHeaderCell, onCell } = _a, rest = __objRest(_a, ["headerProps", "title", "onHeaderCell", "onCell"]);
131
- const resolvedOnHeaderCell = (column) => {
132
- var _a2;
133
- const base = (_a2 = onHeaderCell == null ? void 0 : onHeaderCell(column)) != null ? _a2 : {};
134
- const isSorted = (headerProps == null ? void 0 : headerProps.sortable) && ((headerProps == null ? void 0 : headerProps.sortOrder) === "ascend" || (headerProps == null ? void 0 : headerProps.sortOrder) === "descend");
135
- return __spreadProps(__spreadValues({}, base), {
136
- className: clsx(
137
- base.className,
138
- headerCellClassName,
139
- isSorted && Table_module_default.tableHeaderCellSorted
140
- )
141
- });
142
- };
143
- const resolvedOnCell = (record, rowIndex) => {
144
- var _a2;
145
- const base = (_a2 = onCell == null ? void 0 : onCell(record, rowIndex)) != null ? _a2 : {};
146
- return __spreadProps(__spreadValues({}, base), {
147
- className: clsx(base.className, bodyCellClassName)
148
- });
149
- };
150
- const processedTitle = headerProps ? /* @__PURE__ */ jsx(ColumnHeader, __spreadValues({ label: title }, headerProps)) : title;
151
- return __spreadProps(__spreadValues({}, rest), {
152
- title: processedTitle,
153
- onHeaderCell: resolvedOnHeaderCell,
154
- onCell: resolvedOnCell
155
- });
156
- });
157
- }
158
- function Table(props) {
159
- var _b;
160
- const _a = props, {
161
- size = "middle",
162
- variant = "default",
163
- isAccordion = false,
164
- isToolbar = false,
165
- className = "",
166
- pagination,
167
- loading,
168
- total,
169
- current,
170
- pageSize,
171
- onPaginationChange,
172
- columns,
173
- rowSelection,
174
- rowKey = "key",
175
- onRow,
176
- dataSource,
177
- emptyState,
178
- hideHeader,
179
- loadingIndicator,
180
- style,
181
- headerCellClassName,
182
- bodyCellClassName,
183
- rowClassName
184
- } = _a, rest = __objRest(_a, [
185
- "size",
186
- "variant",
187
- "isAccordion",
188
- "isToolbar",
189
- "className",
190
- "pagination",
191
- "loading",
192
- "total",
193
- "current",
194
- "pageSize",
195
- "onPaginationChange",
196
- "columns",
197
- "rowSelection",
198
- "rowKey",
199
- "onRow",
200
- "dataSource",
201
- "emptyState",
202
- "hideHeader",
203
- "loadingIndicator",
204
- "style",
205
- "headerCellClassName",
206
- "bodyCellClassName",
207
- "rowClassName"
208
- ]);
209
- const resolvedPagination = buildPagination(pagination, {
210
- total,
211
- current,
212
- pageSize,
213
- onChange: onPaginationChange
214
- });
215
- const processedColumns = React.useMemo(
216
- () => processColumns(columns, headerCellClassName, bodyCellClassName),
217
- [columns, headerCellClassName, bodyCellClassName]
218
- );
219
- const resolvedRowSelection = React.useMemo(() => {
220
- if (!rowSelection) return void 0;
221
- return __spreadValues({
222
- columnWidth: 48
223
- }, rowSelection);
224
- }, [rowSelection]);
225
- const resolvedOnRow = React.useMemo(() => {
226
- const onChange = resolvedRowSelection == null ? void 0 : resolvedRowSelection.onChange;
227
- if (variant !== "selectable" || !onChange) return onRow;
228
- return (record, index) => {
229
- var _a2;
230
- const base = (_a2 = onRow == null ? void 0 : onRow(record, index)) != null ? _a2 : {};
231
- const getKey = (r, i) => typeof rowKey === "function" ? rowKey(r, i) : r[rowKey];
232
- return __spreadProps(__spreadValues({}, base), {
233
- style: __spreadValues({ cursor: "pointer" }, base.style),
234
- onClick: (e) => {
235
- var _a3, _b2;
236
- (_a3 = base.onClick) == null ? void 0 : _a3.call(base, e);
237
- const key = getKey(record, index);
238
- const current2 = (_b2 = resolvedRowSelection.selectedRowKeys) != null ? _b2 : [];
239
- const isSelected = current2.some((k) => k === key);
240
- const newKeys = isSelected ? current2.filter((k) => k !== key) : [...current2, key];
241
- const newRows = (dataSource != null ? dataSource : []).filter(
242
- (r, idx) => newKeys.some((k) => k === getKey(r, idx))
243
- );
244
- onChange(newKeys, newRows, { type: "single" });
245
- }
246
- });
247
- };
248
- }, [variant, resolvedRowSelection, rowKey, onRow, dataSource]);
249
- return /* @__PURE__ */ jsx(
250
- "div",
251
- {
252
- className: clsx(
253
- Table_module_default.tableWrapper,
254
- Table_module_default.showHoverEffect,
255
- {
256
- [Table_module_default.isAccordion]: isAccordion,
257
- [Table_module_default.isToolbar]: isToolbar,
258
- [Table_module_default.hasCustomHeaderCell]: !!headerCellClassName,
259
- [Table_module_default.hasCustomBodyCell]: !!bodyCellClassName
260
- },
261
- className
262
- ),
263
- style,
264
- "data-testid": "lumina-table",
265
- children: /* @__PURE__ */ jsx(
266
- AntTable,
267
- __spreadProps(__spreadValues({
268
- className: Table_module_default.table,
269
- size,
270
- pagination: resolvedPagination,
271
- columns: processedColumns,
272
- rowSelection: resolvedRowSelection,
273
- rowKey,
274
- onRow: resolvedOnRow,
275
- dataSource,
276
- showHeader: !hideHeader,
277
- locale: {
278
- emptyText: loading && loadingIndicator ? loadingIndicator : loading ? " " : emptyState
279
- }
280
- }, rest), {
281
- loading: loadingIndicator ? { spinning: !!loading && ((_b = dataSource == null ? void 0 : dataSource.length) != null ? _b : 0) > 0, indicator: loadingIndicator } : loading,
282
- rowClassName: (record, index) => {
283
- var _a2;
284
- return clsx(
285
- {
286
- [Table_module_default.firstRow]: index === 0,
287
- [Table_module_default.lastRow]: index === ((_a2 = dataSource == null ? void 0 : dataSource.length) != null ? _a2 : 0) - 1
288
- },
289
- typeof rowClassName === "function" ? rowClassName(record, index) : rowClassName
290
- );
291
- }
292
- })
293
- )
294
- }
295
- );
296
- }
297
- Table.displayName = "Table";
298
- var Table_default = Table;
299
-
300
- export {
301
- Table,
302
- Table_default
303
- };