@rockshin/tao-ui 0.0.35 → 0.0.37

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,23 +1,35 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
- import { createElement, useCallback, useEffect, useMemo, useRef, useState } from "react";
2
+ import { createElement, useEffect, useRef, useState } from "react";
3
+ import { c } from "react-compiler-runtime";
3
4
  import { useTaoConfig } from "../../provider/tao-provider.js";
4
5
  import { useBreakpoint } from "../../utils/breakpoint.js";
5
6
  import { cx } from "../../utils/semantic.js";
6
7
  import { Pagination } from "../pagination/pagination.js";
7
8
  import { TableFilterDropdown } from "./table-filter.js";
8
9
  import { SortIcon, TableLoadingSpinner } from "./table-icons.js";
9
- import { getCellValue, getColKey, getRowKey, nextSortOrder, resolveRowClassName, resolveRowStyle, resolveSemanticClassNames, resolveSemanticStyles } from "./table-model.js";
10
+ import { getCellValue, getColKey, getRowKey, resolveRowClassName, resolveRowStyle, resolveSemanticClassNames, resolveSemanticStyles } from "./table-model.js";
11
+ import { useTableData } from "./use-table-data.js";
10
12
  import "./table.css";
11
- function Table({ columns: columnsProp, dataSource, rowKey, loading = false, pagination: paginationProp, onChange, scroll, rowSelection, size, variant, headerBackground = true, emptyText = 'No Data', bordered = false, className, style, classNames, styles, rowClassName, rowStyle, onRow, onHeaderRow }) {
13
+ function Table(t0) {
14
+ const $ = c(62);
15
+ const { columns: columnsProp, dataSource, rowKey, loading: t1, pagination: paginationProp, onChange, scroll, rowSelection, size, variant, headerBackground: t2, emptyText: t3, bordered: t4, className, style, classNames, styles, rowClassName, rowStyle, onRow, onHeaderRow } = t0;
16
+ const loading = void 0 === t1 ? false : t1;
17
+ const headerBackground = void 0 === t2 ? true : t2;
18
+ const emptyText = void 0 === t3 ? "No Data" : t3;
19
+ const bordered = void 0 === t4 ? false : t4;
12
20
  const ctx = useTaoConfig();
13
21
  const resolvedSize = size ?? ctx.size;
14
22
  const screens = useBreakpoint();
15
- const columns = useMemo(()=>columnsProp.some((col_0)=>col_0.responsive) ? columnsProp.filter((col)=>!col.responsive || col.responsive.some((bp)=>screens[bp])) : columnsProp, [
16
- columnsProp,
17
- screens
18
- ]);
19
- const resolvedVariant = variant ?? ('outlined' === ctx.variant ? 'modern' : ctx.variant);
20
- const showBorder = 'outlined' === resolvedVariant || 'modern' === resolvedVariant || bordered && 'borderless' !== resolvedVariant;
23
+ let t5;
24
+ if ($[0] !== columnsProp || $[1] !== screens) {
25
+ t5 = columnsProp.some(_temp) ? columnsProp.filter((col)=>!col.responsive || col.responsive.some((bp)=>screens[bp])) : columnsProp;
26
+ $[0] = columnsProp;
27
+ $[1] = screens;
28
+ $[2] = t5;
29
+ } else t5 = $[2];
30
+ const columns = t5;
31
+ const resolvedVariant = variant ?? ("outlined" === ctx.variant ? "modern" : ctx.variant);
32
+ const showBorder = "outlined" === resolvedVariant || "modern" === resolvedVariant || bordered && "borderless" !== resolvedVariant;
21
33
  const semanticProps = {
22
34
  columns,
23
35
  dataSource,
@@ -43,319 +55,343 @@ function Table({ columns: columnsProp, dataSource, rowKey, loading = false, pagi
43
55
  };
44
56
  const resolvedClassNames = resolveSemanticClassNames(classNames, semanticProps);
45
57
  const resolvedStyles = resolveSemanticStyles(styles, semanticProps);
46
- const defaultSortCol = columns.find((c)=>c.defaultSortOrder);
47
- const [sortKey, setSortKey] = useState(defaultSortCol ? getColKey(defaultSortCol, columns.indexOf(defaultSortCol)) : null);
48
- const [sortOrder, setSortOrder] = useState(defaultSortCol?.defaultSortOrder ?? null);
49
- const [filterValues, setFilterValues] = useState(()=>{
50
- const init = {};
51
- for(let i = 0; i < columns.length; i++){
52
- const col_1 = columns[i];
53
- if (col_1.filters) {
54
- const key = getColKey(col_1, i);
55
- init[key] = col_1.filteredValue ?? [];
56
- }
57
- }
58
- return init;
59
- });
60
- const resolvedSort = useMemo(()=>{
61
- for(let i_0 = 0; i_0 < columns.length; i_0++){
62
- const col_2 = columns[i_0];
63
- const key_0 = getColKey(col_2, i_0);
64
- const order = void 0 !== col_2.sortOrder ? col_2.sortOrder : sortKey === key_0 ? sortOrder : null;
65
- if (order) return {
66
- key: key_0,
67
- order
68
- };
69
- }
70
- return {
71
- key: null,
72
- order: null
58
+ let t6;
59
+ if ($[3] !== columns || $[4] !== dataSource || $[5] !== onChange || $[6] !== paginationProp) {
60
+ t6 = {
61
+ columns,
62
+ dataSource,
63
+ pagination: paginationProp,
64
+ onChange
73
65
  };
74
- }, [
75
- columns,
76
- sortKey,
77
- sortOrder
78
- ]);
79
- const resolvedFilterValues = useMemo(()=>{
80
- const values = {
81
- ...filterValues
66
+ $[3] = columns;
67
+ $[4] = dataSource;
68
+ $[5] = onChange;
69
+ $[6] = paginationProp;
70
+ $[7] = t6;
71
+ } else t6 = $[7];
72
+ const tableData = useTableData(t6);
73
+ const paginatedData = tableData.rows;
74
+ const selectionColWidth = rowSelection?.columnWidth ?? 48;
75
+ const selectionType = rowSelection?.type ?? "checkbox";
76
+ const isSelectionControlled = rowSelection?.selectedRowKeys !== void 0;
77
+ let t7;
78
+ if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
79
+ t7 = [];
80
+ $[8] = t7;
81
+ } else t7 = $[8];
82
+ const [internalSelectedKeys, setInternalSelectedKeys] = useState(t7);
83
+ const selectedKeys = rowSelection?.selectedRowKeys ?? internalSelectedKeys;
84
+ let t8;
85
+ if ($[9] !== selectedKeys) {
86
+ t8 = new Set(selectedKeys);
87
+ $[9] = selectedKeys;
88
+ $[10] = t8;
89
+ } else t8 = $[10];
90
+ const selectedKeySet = t8;
91
+ let t9;
92
+ if ($[11] !== paginatedData || $[12] !== rowKey || $[13] !== rowSelection) {
93
+ let t10;
94
+ if ($[15] !== rowSelection) {
95
+ t10 = (record)=>!rowSelection?.getCheckboxProps?.(record)?.disabled;
96
+ $[15] = rowSelection;
97
+ $[16] = t10;
98
+ } else t10 = $[16];
99
+ let t11;
100
+ if ($[17] !== rowKey) {
101
+ t11 = (record_0)=>getRowKey(record_0, rowKey);
102
+ $[17] = rowKey;
103
+ $[18] = t11;
104
+ } else t11 = $[18];
105
+ t9 = paginatedData.filter(t10).map(t11);
106
+ $[11] = paginatedData;
107
+ $[12] = rowKey;
108
+ $[13] = rowSelection;
109
+ $[14] = t9;
110
+ } else t9 = $[14];
111
+ const selectablePageKeys = t9;
112
+ let t10;
113
+ if ($[19] !== dataSource || $[20] !== isSelectionControlled || $[21] !== rowKey || $[22] !== rowSelection || $[23] !== selectedKeySet || $[24] !== selectedKeys || $[25] !== selectionType) {
114
+ t10 = (key)=>{
115
+ let nextKeys;
116
+ nextKeys = "radio" === selectionType ? [
117
+ key
118
+ ] : selectedKeySet.has(key) ? selectedKeys.filter((k)=>k !== key) : [
119
+ ...selectedKeys,
120
+ key
121
+ ];
122
+ if (!isSelectionControlled) setInternalSelectedKeys(nextKeys);
123
+ if (!rowSelection?.onChange) return;
124
+ const nextKeySet = new Set(nextKeys);
125
+ const nextRows = dataSource.filter((r)=>nextKeySet.has(getRowKey(r, rowKey)));
126
+ rowSelection.onChange(nextKeys, nextRows);
82
127
  };
83
- for(let i_1 = 0; i_1 < columns.length; i_1++){
84
- const col_3 = columns[i_1];
85
- if (void 0 !== col_3.filteredValue) values[getColKey(col_3, i_1)] = col_3.filteredValue;
86
- }
87
- return values;
88
- }, [
89
- columns,
90
- filterValues
91
- ]);
92
- const hasPagination = false !== paginationProp;
93
- const paginationConfig = false === paginationProp ? void 0 : paginationProp;
94
- const [internalPage, setInternalPage] = useState(paginationConfig?.defaultCurrent ?? 1);
95
- const [internalPageSize, setInternalPageSize] = useState(paginationConfig?.defaultPageSize ?? paginationConfig?.pageSize ?? 10);
96
- const currentPage = paginationConfig?.current ?? internalPage;
97
- const pageSize = paginationConfig?.pageSize ?? internalPageSize;
98
- const buildSorterResult = useCallback((key_1, order_0)=>{
99
- if (!key_1 || !order_0) return {
100
- order: null
128
+ $[19] = dataSource;
129
+ $[20] = isSelectionControlled;
130
+ $[21] = rowKey;
131
+ $[22] = rowSelection;
132
+ $[23] = selectedKeySet;
133
+ $[24] = selectedKeys;
134
+ $[25] = selectionType;
135
+ $[26] = t10;
136
+ } else t10 = $[26];
137
+ const handleSelectRow = t10;
138
+ let t11;
139
+ if ($[27] !== dataSource || $[28] !== isSelectionControlled || $[29] !== rowKey || $[30] !== rowSelection || $[31] !== selectablePageKeys || $[32] !== selectedKeys) {
140
+ t11 = (checked)=>{
141
+ const nextKeySet_0 = new Set(selectedKeys);
142
+ for (const key_0 of selectablePageKeys)if (checked) nextKeySet_0.add(key_0);
143
+ else nextKeySet_0.delete(key_0);
144
+ const nextKeys_0 = [
145
+ ...nextKeySet_0
146
+ ];
147
+ if (!isSelectionControlled) setInternalSelectedKeys(nextKeys_0);
148
+ if (!rowSelection?.onChange) return;
149
+ const nextRows_0 = dataSource.filter((record_1)=>nextKeySet_0.has(getRowKey(record_1, rowKey)));
150
+ rowSelection.onChange(nextKeys_0, nextRows_0);
101
151
  };
102
- const colIdx = columns.findIndex((c_0, i_2)=>getColKey(c_0, i_2) === key_1);
103
- const col_4 = columns[colIdx];
104
- return {
105
- column: col_4,
106
- order: order_0,
107
- field: col_4?.dataIndex
152
+ $[27] = dataSource;
153
+ $[28] = isSelectionControlled;
154
+ $[29] = rowKey;
155
+ $[30] = rowSelection;
156
+ $[31] = selectablePageKeys;
157
+ $[32] = selectedKeys;
158
+ $[33] = t11;
159
+ } else t11 = $[33];
160
+ const handleSelectAll = t11;
161
+ const scrollRef = useRef(null);
162
+ const [scrollState, setScrollState] = useState("left");
163
+ let t12;
164
+ if ($[34] === Symbol.for("react.memo_cache_sentinel")) {
165
+ t12 = ()=>{
166
+ const el = scrollRef.current;
167
+ if (!el) return;
168
+ const { scrollLeft, scrollWidth, clientWidth } = el;
169
+ const atLeft = scrollLeft <= 1;
170
+ const atRight = scrollLeft + clientWidth >= scrollWidth - 1;
171
+ if (atLeft && atRight) setScrollState("both");
172
+ else if (atLeft) setScrollState("left");
173
+ else atRight ? setScrollState("right") : setScrollState("middle");
108
174
  };
109
- }, [
110
- columns
111
- ]);
112
- const buildFiltersRecord = useCallback((fv)=>{
113
- const result = {};
114
- for(let i_3 = 0; i_3 < columns.length; i_3++){
115
- const col_5 = columns[i_3];
116
- if (col_5.filters) {
117
- const key_2 = getColKey(col_5, i_3);
118
- const vals = fv[key_2];
119
- result[null == col_5.dataIndex ? key_2 : String(col_5.dataIndex)] = vals && vals.length > 0 ? vals : null;
120
- }
121
- }
122
- return result;
123
- }, [
124
- columns
125
- ]);
126
- const triggerChange = useCallback((page, ps, sk, so, fv_0)=>{
127
- onChange?.({
128
- current: page,
129
- pageSize: ps
130
- }, buildFiltersRecord(fv_0), buildSorterResult(sk, so));
131
- }, [
132
- onChange,
133
- buildFiltersRecord,
134
- buildSorterResult
135
- ]);
136
- const handleSort = useCallback((colKey, col_6)=>{
137
- if (void 0 !== col_6.sortOrder) return void triggerChange(currentPage, pageSize, colKey, nextSortOrder(col_6.sortOrder), resolvedFilterValues);
138
- const next = sortKey === colKey ? nextSortOrder(sortOrder) : 'ascend';
139
- const newKey = null === next ? null : colKey;
140
- setSortKey(newKey);
141
- setSortOrder(next);
142
- triggerChange(currentPage, pageSize, newKey, next, resolvedFilterValues);
143
- }, [
144
- sortKey,
145
- sortOrder,
146
- currentPage,
147
- pageSize,
148
- resolvedFilterValues,
149
- triggerChange
150
- ]);
151
- const handleFilter = useCallback((colKey_0, values_0)=>{
152
- const next_0 = {
153
- ...resolvedFilterValues,
154
- [colKey_0]: values_0
175
+ $[34] = t12;
176
+ } else t12 = $[34];
177
+ const handleScroll = t12;
178
+ let t13;
179
+ if ($[35] !== scroll?.x) {
180
+ t13 = ()=>{
181
+ if (!scroll?.x) return;
182
+ handleScroll();
155
183
  };
156
- setFilterValues(next_0);
157
- setInternalPage(1);
158
- triggerChange(1, pageSize, resolvedSort.key, resolvedSort.order, next_0);
159
- }, [
160
- resolvedFilterValues,
161
- pageSize,
162
- resolvedSort,
163
- triggerChange
164
- ]);
165
- const handlePageChange = useCallback((page_0, ps_0)=>{
166
- setInternalPage(page_0);
167
- setInternalPageSize(ps_0);
168
- triggerChange(page_0, ps_0, resolvedSort.key, resolvedSort.order, resolvedFilterValues);
169
- }, [
170
- resolvedSort,
171
- resolvedFilterValues,
172
- triggerChange
173
- ]);
174
- const processedData = useMemo(()=>{
175
- let data = [
176
- ...dataSource
177
- ];
178
- for(let i_4 = 0; i_4 < columns.length; i_4++){
179
- const col_7 = columns[i_4];
180
- if (!col_7.filters || !col_7.onFilter) continue;
181
- const key_3 = getColKey(col_7, i_4);
182
- const controlledValues = col_7.filteredValue;
183
- const activeVals = controlledValues ?? filterValues[key_3];
184
- if (activeVals && activeVals.length > 0) data = data.filter((record)=>activeVals.some((v)=>col_7.onFilter(v, record)));
185
- }
186
- const activeSortCol = columns.find((col_8, i_5)=>{
187
- const key_4 = getColKey(col_8, i_5);
188
- const order_1 = void 0 !== col_8.sortOrder ? col_8.sortOrder : sortKey === key_4 ? sortOrder : null;
189
- return null !== order_1 && 'function' == typeof col_8.sorter;
190
- });
191
- if (activeSortCol && 'function' == typeof activeSortCol.sorter) {
192
- const colIdx_0 = columns.indexOf(activeSortCol);
193
- const key_5 = getColKey(activeSortCol, colIdx_0);
194
- const order_2 = void 0 !== activeSortCol.sortOrder ? activeSortCol.sortOrder : sortKey === key_5 ? sortOrder : null;
195
- const sorterFn = activeSortCol.sorter;
196
- data.sort((a, b)=>{
197
- const result_0 = sorterFn(a, b);
198
- return 'descend' === order_2 ? -result_0 : result_0;
199
- });
200
- }
201
- return data;
202
- }, [
203
- dataSource,
204
- columns,
205
- filterValues,
206
- sortKey,
207
- sortOrder
208
- ]);
209
- const totalForPagination = paginationConfig?.total ?? processedData.length;
210
- const lastPage = Math.max(1, Math.ceil(totalForPagination / pageSize));
211
- const boundedPage = Math.min(Math.max(1, internalPage), lastPage);
212
- if (hasPagination && paginationConfig?.current === void 0 && boundedPage !== internalPage) setInternalPage(boundedPage);
213
- const paginatedData = useMemo(()=>{
214
- if (!hasPagination) return processedData;
215
- if (paginationConfig?.total !== void 0) return processedData;
216
- const start = (currentPage - 1) * pageSize;
217
- return processedData.slice(start, start + pageSize);
218
- }, [
219
- processedData,
220
- hasPagination,
221
- paginationConfig,
222
- currentPage,
223
- pageSize
224
- ]);
225
- const selectionColWidth = rowSelection?.columnWidth ?? 48;
226
- const selectionType = rowSelection?.type ?? 'checkbox';
227
- const isSelectionControlled = rowSelection?.selectedRowKeys !== void 0;
228
- const [internalSelectedKeys, setInternalSelectedKeys] = useState([]);
229
- const selectedKeys = rowSelection?.selectedRowKeys ?? internalSelectedKeys;
230
- const selectedKeySet = useMemo(()=>new Set(selectedKeys), [
231
- selectedKeys
232
- ]);
233
- const selectablePageKeys = useMemo(()=>paginatedData.filter((record_0)=>!rowSelection?.getCheckboxProps?.(record_0)?.disabled).map((record_1)=>getRowKey(record_1, rowKey)), [
234
- paginatedData,
235
- rowSelection,
236
- rowKey
237
- ]);
238
- const handleSelectRow = useCallback((key_6)=>{
239
- let nextKeys;
240
- nextKeys = 'radio' === selectionType ? [
241
- key_6
242
- ] : selectedKeySet.has(key_6) ? selectedKeys.filter((k)=>k !== key_6) : [
243
- ...selectedKeys,
244
- key_6
245
- ];
246
- if (!isSelectionControlled) setInternalSelectedKeys(nextKeys);
247
- if (!rowSelection?.onChange) return;
248
- const nextKeySet = new Set(nextKeys);
249
- const nextRows = dataSource.filter((r)=>nextKeySet.has(getRowKey(r, rowKey)));
250
- rowSelection.onChange(nextKeys, nextRows);
251
- }, [
252
- rowSelection,
253
- selectionType,
254
- isSelectionControlled,
255
- selectedKeys,
256
- selectedKeySet,
257
- dataSource,
258
- rowKey
259
- ]);
260
- const handleSelectAll = useCallback((checked)=>{
261
- const nextKeySet_0 = new Set(selectedKeys);
262
- for (const key_7 of selectablePageKeys)if (checked) nextKeySet_0.add(key_7);
263
- else nextKeySet_0.delete(key_7);
264
- const nextKeys_0 = [
265
- ...nextKeySet_0
184
+ $[35] = scroll?.x;
185
+ $[36] = t13;
186
+ } else t13 = $[36];
187
+ const t14 = scroll?.x;
188
+ let t15;
189
+ if ($[37] !== t14) {
190
+ t15 = [
191
+ t14,
192
+ handleScroll
266
193
  ];
267
- if (!isSelectionControlled) setInternalSelectedKeys(nextKeys_0);
268
- if (!rowSelection?.onChange) return;
269
- const nextRows_0 = dataSource.filter((record_2)=>nextKeySet_0.has(getRowKey(record_2, rowKey)));
270
- rowSelection.onChange(nextKeys_0, nextRows_0);
271
- }, [
272
- rowSelection,
273
- selectedKeys,
274
- selectablePageKeys,
275
- dataSource,
276
- rowKey,
277
- isSelectionControlled
278
- ]);
279
- const scrollRef = useRef(null);
280
- const [scrollState, setScrollState] = useState('left');
281
- const handleScroll = useCallback(()=>{
282
- const el = scrollRef.current;
283
- if (!el) return;
284
- const { scrollLeft, scrollWidth, clientWidth } = el;
285
- const atLeft = scrollLeft <= 1;
286
- const atRight = scrollLeft + clientWidth >= scrollWidth - 1;
287
- if (atLeft && atRight) setScrollState('both');
288
- else if (atLeft) setScrollState('left');
289
- else atRight ? setScrollState('right') : setScrollState('middle');
290
- }, []);
291
- useEffect(()=>{
292
- if (!scroll?.x) return;
293
- handleScroll();
294
- }, [
295
- scroll?.x,
296
- handleScroll
297
- ]);
298
- const allColumns = useMemo(()=>{
299
- const cols = [];
194
+ $[37] = t14;
195
+ $[38] = t15;
196
+ } else t15 = $[38];
197
+ useEffect(t13, t15);
198
+ let cols;
199
+ if ($[39] !== columns || $[40] !== rowSelection || $[41] !== selectionColWidth) {
200
+ cols = [];
300
201
  if (rowSelection) cols.push({
301
- _key: '__selection__',
202
+ _key: "__selection__",
302
203
  _index: -1,
303
204
  width: selectionColWidth,
304
- fixed: rowSelection.fixed ? 'left' : void 0
205
+ fixed: rowSelection.fixed ? "left" : void 0
305
206
  });
306
- columns.forEach((col_9, i_6)=>{
207
+ columns.forEach((col_1, i)=>{
307
208
  cols.push({
308
- ...col_9,
309
- _key: getColKey(col_9, i_6),
310
- _index: i_6
209
+ ...col_1,
210
+ _key: getColKey(col_1, i),
211
+ _index: i
311
212
  });
312
213
  });
313
- return cols;
314
- }, [
315
- columns,
316
- rowSelection,
317
- selectionColWidth
318
- ]);
319
- const stickyPositions = useMemo(()=>{
320
- if (!scroll?.x) return {};
321
- const positions = {};
322
- let leftOffset = 0;
323
- for (const col_10 of allColumns)if ('left' === col_10.fixed) {
324
- positions[col_10._key] = {
325
- left: leftOffset
326
- };
327
- leftOffset += 'number' == typeof col_10.width ? col_10.width : 0;
328
- }
329
- let rightOffset = 0;
330
- for(let i_7 = allColumns.length - 1; i_7 >= 0; i_7--){
331
- const col_11 = allColumns[i_7];
332
- if ('right' === col_11.fixed) {
333
- positions[col_11._key] = {
334
- right: rightOffset
214
+ $[39] = columns;
215
+ $[40] = rowSelection;
216
+ $[41] = selectionColWidth;
217
+ $[42] = cols;
218
+ } else cols = $[42];
219
+ const allColumns = cols;
220
+ let t16;
221
+ if ($[43] !== allColumns || $[44] !== scroll?.x) {
222
+ t16 = ()=>{
223
+ if (!scroll?.x) return {};
224
+ const positions = {};
225
+ let leftOffset = 0;
226
+ for (const col_2 of allColumns)if ("left" === col_2.fixed) {
227
+ positions[col_2._key] = {
228
+ left: leftOffset
335
229
  };
336
- rightOffset += 'number' == typeof col_11.width ? col_11.width : 0;
230
+ leftOffset += "number" == typeof col_2.width ? col_2.width : 0;
337
231
  }
338
- }
339
- return positions;
340
- }, [
341
- allColumns,
342
- scroll?.x
343
- ]);
344
- const getResolvedSortOrder = (col_12, colKey_1)=>{
345
- if (void 0 !== col_12.sortOrder) return col_12.sortOrder;
346
- return sortKey === colKey_1 ? sortOrder : null;
347
- };
232
+ let rightOffset = 0;
233
+ for(let i_0 = allColumns.length - 1; i_0 >= 0; i_0--){
234
+ const col_3 = allColumns[i_0];
235
+ if ("right" === col_3.fixed) {
236
+ positions[col_3._key] = {
237
+ right: rightOffset
238
+ };
239
+ rightOffset += "number" == typeof col_3.width ? col_3.width : 0;
240
+ }
241
+ }
242
+ return positions;
243
+ };
244
+ $[43] = allColumns;
245
+ $[44] = scroll?.x;
246
+ $[45] = t16;
247
+ } else t16 = $[45];
248
+ scroll?.x;
249
+ let t17;
250
+ if ($[46] !== t16) {
251
+ t17 = t16();
252
+ $[46] = t16;
253
+ $[47] = t17;
254
+ } else t17 = $[47];
255
+ const stickyPositions = t17;
348
256
  const tableStyle = scroll?.x ? {
349
- minWidth: 'number' == typeof scroll.x ? `${scroll.x}px` : scroll.x
257
+ minWidth: "number" == typeof scroll.x ? `${scroll.x}px` : scroll.x
350
258
  } : {};
351
- const selectedPageCount = selectablePageKeys.filter((key_8)=>selectedKeySet.has(key_8)).length;
259
+ let t18;
260
+ if ($[48] !== selectablePageKeys || $[49] !== selectedKeySet) {
261
+ let t19;
262
+ if ($[51] !== selectedKeySet) {
263
+ t19 = (key_1)=>selectedKeySet.has(key_1);
264
+ $[51] = selectedKeySet;
265
+ $[52] = t19;
266
+ } else t19 = $[52];
267
+ t18 = selectablePageKeys.filter(t19);
268
+ $[48] = selectablePageKeys;
269
+ $[49] = selectedKeySet;
270
+ $[50] = t18;
271
+ } else t18 = $[50];
272
+ const selectedPageCount = t18.length;
352
273
  const isAllSelected = selectablePageKeys.length > 0 && selectedPageCount === selectablePageKeys.length;
353
274
  const isIndeterminate = selectedPageCount > 0 && !isAllSelected;
275
+ let t19;
276
+ if ($[53] !== loading) {
277
+ t19 = loading && /*#__PURE__*/ jsx(TableLoadingSpinner, {});
278
+ $[53] = loading;
279
+ $[54] = t19;
280
+ } else t19 = $[54];
281
+ const headerRowProps = onHeaderRow?.(columns, 0) ?? {};
282
+ const t20 = "";
283
+ const t21 = 0 === paginatedData.length ? /*#__PURE__*/ jsx("tr", {
284
+ children: /*#__PURE__*/ jsx("td", {
285
+ "data-tao-table-cell": "",
286
+ "data-tao-table-empty": "",
287
+ colSpan: columns.length + (rowSelection ? 1 : 0),
288
+ className: resolvedClassNames.empty,
289
+ style: resolvedStyles.empty,
290
+ children: emptyText
291
+ })
292
+ }) : paginatedData.map((record_2, rowIdx)=>{
293
+ const key_2 = getRowKey(record_2, rowKey);
294
+ const isSelected = selectedKeySet.has(key_2);
295
+ const checkboxProps = rowSelection?.getCheckboxProps?.(record_2);
296
+ const rowProps = onRow?.(record_2, rowIdx) ?? {};
297
+ return /*#__PURE__*/ createElement("tr", {
298
+ ...rowProps,
299
+ key: key_2,
300
+ "data-tao-table-row": "",
301
+ "data-tao-selected": isSelected || void 0,
302
+ className: cx(resolvedClassNames["body.row"], resolveRowClassName(rowClassName, record_2, rowIdx), rowProps.className),
303
+ style: {
304
+ ...resolvedStyles["body.row"],
305
+ ...resolveRowStyle(rowStyle, record_2, rowIdx),
306
+ ...rowProps.style
307
+ },
308
+ children: [
309
+ rowSelection && /*#__PURE__*/ jsx("td", {
310
+ "data-tao-table-cell": "",
311
+ "data-tao-table-selection-cell": "",
312
+ "data-tao-fixed": "left",
313
+ className: resolvedClassNames["selection.cell"],
314
+ style: {
315
+ ...stickyPositions.__selection__ ? {
316
+ position: "sticky",
317
+ left: stickyPositions.__selection__.left,
318
+ zIndex: 1
319
+ } : {},
320
+ ...resolvedStyles["selection.cell"]
321
+ },
322
+ children: /*#__PURE__*/ jsx("input", {
323
+ type: "radio" === selectionType ? "radio" : "checkbox",
324
+ checked: isSelected,
325
+ "aria-label": `Select row ${String(key_2)}`,
326
+ disabled: checkboxProps?.disabled,
327
+ onChange: ()=>handleSelectRow(key_2),
328
+ "data-tao-table-checkbox": ""
329
+ })
330
+ }),
331
+ columns.map((col_5, colIdx)=>{
332
+ const colKey_0 = getColKey(col_5, colIdx);
333
+ const value = getCellValue(record_2, col_5.dataIndex);
334
+ const stickyPos_0 = stickyPositions[colKey_0];
335
+ const isFixed_0 = !!col_5.fixed && !!scroll?.x;
336
+ const cellProps = col_5.onCell?.(record_2, rowIdx) ?? {};
337
+ return /*#__PURE__*/ createElement("td", {
338
+ ...cellProps,
339
+ key: colKey_0,
340
+ "data-tao-table-cell": "",
341
+ "data-tao-align": col_5.align,
342
+ "data-tao-ellipsis": col_5.ellipsis || void 0,
343
+ "data-tao-fixed": isFixed_0 ? col_5.fixed : void 0,
344
+ className: cx(resolvedClassNames["body.cell"], cellProps.className),
345
+ style: {
346
+ ...resolvedStyles["body.cell"],
347
+ ...isFixed_0 && stickyPos_0 ? {
348
+ position: "sticky",
349
+ ...void 0 !== stickyPos_0.left ? {
350
+ left: stickyPos_0.left
351
+ } : {},
352
+ ...void 0 !== stickyPos_0.right ? {
353
+ right: stickyPos_0.right
354
+ } : {},
355
+ zIndex: 1
356
+ } : {},
357
+ ...cellProps.style
358
+ }
359
+ }, col_5.render ? col_5.render(value, record_2, rowIdx) : value);
360
+ })
361
+ ]
362
+ });
363
+ });
364
+ let t22;
365
+ if ($[55] !== t21) {
366
+ t22 = /*#__PURE__*/ jsx("tbody", {
367
+ "data-tao-table-tbody": t20,
368
+ children: t21
369
+ });
370
+ $[55] = t21;
371
+ $[56] = t22;
372
+ } else t22 = $[56];
373
+ let t23;
374
+ if ($[57] !== resolvedClassNames || $[58] !== resolvedSize || $[59] !== resolvedStyles || $[60] !== tableData.pagination) {
375
+ t23 = tableData.pagination && tableData.pagination.total > 0 && /*#__PURE__*/ jsx("div", {
376
+ "data-tao-table-pagination": "",
377
+ className: resolvedClassNames.pagination,
378
+ style: resolvedStyles.pagination,
379
+ children: /*#__PURE__*/ jsx(Pagination, {
380
+ ...tableData.pagination,
381
+ size: resolvedSize
382
+ })
383
+ });
384
+ $[57] = resolvedClassNames;
385
+ $[58] = resolvedSize;
386
+ $[59] = resolvedStyles;
387
+ $[60] = tableData.pagination;
388
+ $[61] = t23;
389
+ } else t23 = $[61];
354
390
  return /*#__PURE__*/ jsxs("div", {
355
391
  "data-tao-table-wrapper": "",
356
392
  "data-tao-size": resolvedSize,
357
393
  "data-tao-variant": resolvedVariant,
358
- "data-tao-header-bg": headerBackground ? void 0 : 'off',
394
+ "data-tao-header-bg": headerBackground ? void 0 : "off",
359
395
  "data-tao-bordered": showBorder || void 0,
360
396
  "data-tao-scroll-state": scroll?.x ? scrollState : void 0,
361
397
  className: cx(resolvedClassNames.root, className),
@@ -371,7 +407,7 @@ function Table({ columns: columnsProp, dataSource, rowKey, loading = false, pagi
371
407
  className: resolvedClassNames.scroll,
372
408
  style: resolvedStyles.scroll,
373
409
  children: [
374
- loading && /*#__PURE__*/ jsx(TableLoadingSpinner, {}),
410
+ t19,
375
411
  /*#__PURE__*/ jsxs("table", {
376
412
  "data-tao-table": "",
377
413
  className: resolvedClassNames.table,
@@ -382,218 +418,119 @@ function Table({ columns: columnsProp, dataSource, rowKey, loading = false, pagi
382
418
  children: [
383
419
  /*#__PURE__*/ jsx("thead", {
384
420
  "data-tao-table-thead": "",
385
- className: resolvedClassNames['header.wrapper'],
386
- style: resolvedStyles['header.wrapper'],
387
- children: (()=>{
388
- const headerRowProps = onHeaderRow?.(columns, 0) ?? {};
389
- return /*#__PURE__*/ jsxs("tr", {
390
- ...headerRowProps,
391
- className: cx(resolvedClassNames['header.row'], headerRowProps.className),
392
- style: {
393
- ...resolvedStyles['header.row'],
394
- ...headerRowProps.style
395
- },
396
- children: [
397
- rowSelection && /*#__PURE__*/ jsx("th", {
398
- "data-tao-table-cell": "",
399
- "data-tao-table-selection-cell": "",
400
- "data-tao-fixed": "left",
401
- className: resolvedClassNames['selection.cell'],
402
- style: {
403
- width: selectionColWidth,
404
- ...stickyPositions.__selection__ ? {
405
- position: 'sticky',
406
- left: stickyPositions.__selection__.left,
407
- zIndex: 2
408
- } : {},
409
- ...resolvedStyles['selection.cell']
421
+ className: resolvedClassNames["header.wrapper"],
422
+ style: resolvedStyles["header.wrapper"],
423
+ children: /*#__PURE__*/ jsxs("tr", {
424
+ ...headerRowProps,
425
+ className: cx(resolvedClassNames["header.row"], headerRowProps.className),
426
+ style: {
427
+ ...resolvedStyles["header.row"],
428
+ ...headerRowProps.style
429
+ },
430
+ children: [
431
+ rowSelection && /*#__PURE__*/ jsx("th", {
432
+ "data-tao-table-cell": "",
433
+ "data-tao-table-selection-cell": "",
434
+ "data-tao-fixed": "left",
435
+ className: resolvedClassNames["selection.cell"],
436
+ style: {
437
+ width: selectionColWidth,
438
+ ...stickyPositions.__selection__ ? {
439
+ position: "sticky",
440
+ left: stickyPositions.__selection__.left,
441
+ zIndex: 2
442
+ } : {},
443
+ ...resolvedStyles["selection.cell"]
444
+ },
445
+ children: "checkbox" === selectionType && /*#__PURE__*/ jsx("input", {
446
+ type: "checkbox",
447
+ "aria-label": "Select all rows",
448
+ checked: isAllSelected,
449
+ disabled: 0 === selectablePageKeys.length,
450
+ ref: (el_0)=>{
451
+ if (el_0) el_0.indeterminate = isIndeterminate;
410
452
  },
411
- children: 'checkbox' === selectionType && /*#__PURE__*/ jsx("input", {
412
- type: "checkbox",
413
- "aria-label": "Select all rows",
414
- checked: isAllSelected,
415
- disabled: 0 === selectablePageKeys.length,
416
- ref: (el_0)=>{
417
- if (el_0) el_0.indeterminate = isIndeterminate;
418
- },
419
- onChange: (e)=>handleSelectAll(e.target.checked),
420
- "data-tao-table-checkbox": ""
421
- })
422
- }),
423
- columns.map((col_13, i_8)=>{
424
- const colKey_2 = getColKey(col_13, i_8);
425
- const hasSorter = !!col_13.sorter;
426
- const hasFilter = !!(col_13.filters && col_13.filters.length > 0);
427
- const resolvedOrder = getResolvedSortOrder(col_13, colKey_2);
428
- const controlledFilterValues = col_13.filteredValue;
429
- const activeFilterValues = controlledFilterValues ?? filterValues[colKey_2] ?? [];
430
- const stickyPos = stickyPositions[colKey_2];
431
- const isFixed = !!col_13.fixed && !!scroll?.x;
432
- const headerCellProps = col_13.onHeaderCell?.(col_13) ?? {};
433
- return /*#__PURE__*/ createElement("th", {
434
- ...headerCellProps,
435
- key: colKey_2,
436
- "data-tao-table-cell": "",
437
- "data-tao-table-header": "",
438
- "data-tao-align": col_13.align,
439
- "data-tao-fixed": isFixed ? col_13.fixed : void 0,
440
- "aria-sort": hasSorter ? 'ascend' === resolvedOrder ? 'ascending' : 'descend' === resolvedOrder ? 'descending' : 'none' : void 0,
441
- className: cx(resolvedClassNames['header.cell'], headerCellProps.className),
442
- style: {
443
- ...resolvedStyles['header.cell'],
444
- width: col_13.width,
445
- ...isFixed && stickyPos ? {
446
- position: 'sticky',
447
- ...void 0 !== stickyPos.left ? {
448
- left: stickyPos.left
449
- } : {},
450
- ...void 0 !== stickyPos.right ? {
451
- right: stickyPos.right
452
- } : {},
453
- zIndex: 2
454
- } : {},
455
- ...headerCellProps.style
456
- }
457
- }, /*#__PURE__*/ jsxs("div", {
458
- "data-tao-table-header-content": "",
459
- className: resolvedClassNames['header.content'],
460
- style: resolvedStyles['header.content'],
461
- children: [
462
- hasSorter ? /*#__PURE__*/ jsxs("button", {
463
- type: "button",
464
- "data-tao-table-header-title": "",
465
- "data-tao-sortable": "",
466
- className: resolvedClassNames['header.title'],
467
- style: resolvedStyles['header.title'],
468
- onClick: ()=>handleSort(colKey_2, col_13),
469
- children: [
470
- col_13.title,
471
- /*#__PURE__*/ jsx(SortIcon, {
472
- order: resolvedOrder
473
- })
474
- ]
475
- }) : /*#__PURE__*/ jsx("span", {
476
- "data-tao-table-header-title": "",
477
- className: resolvedClassNames['header.title'],
478
- style: resolvedStyles['header.title'],
479
- children: col_13.title
480
- }),
481
- hasFilter && /*#__PURE__*/ jsx(TableFilterDropdown, {
482
- filters: col_13.filters,
483
- activeValues: activeFilterValues,
484
- onSelect: (vals_0)=>handleFilter(colKey_2, vals_0)
485
- })
486
- ]
487
- }));
453
+ onChange: (e)=>handleSelectAll(e.target.checked),
454
+ "data-tao-table-checkbox": ""
488
455
  })
489
- ]
490
- });
491
- })()
492
- }),
493
- /*#__PURE__*/ jsx("tbody", {
494
- "data-tao-table-tbody": "",
495
- children: 0 === paginatedData.length ? /*#__PURE__*/ jsx("tr", {
496
- children: /*#__PURE__*/ jsx("td", {
497
- "data-tao-table-cell": "",
498
- "data-tao-table-empty": "",
499
- colSpan: columns.length + (rowSelection ? 1 : 0),
500
- className: resolvedClassNames.empty,
501
- style: resolvedStyles.empty,
502
- children: emptyText
503
- })
504
- }) : paginatedData.map((record_3, rowIdx)=>{
505
- const key_9 = getRowKey(record_3, rowKey);
506
- const isSelected = selectedKeySet.has(key_9);
507
- const checkboxProps = rowSelection?.getCheckboxProps?.(record_3);
508
- const rowProps = onRow?.(record_3, rowIdx) ?? {};
509
- return /*#__PURE__*/ createElement("tr", {
510
- ...rowProps,
511
- key: key_9,
512
- "data-tao-table-row": "",
513
- "data-tao-selected": isSelected || void 0,
514
- className: cx(resolvedClassNames['body.row'], resolveRowClassName(rowClassName, record_3, rowIdx), rowProps.className),
515
- style: {
516
- ...resolvedStyles['body.row'],
517
- ...resolveRowStyle(rowStyle, record_3, rowIdx),
518
- ...rowProps.style
519
- },
520
- children: [
521
- rowSelection && /*#__PURE__*/ jsx("td", {
456
+ }),
457
+ columns.map((col_4, i_1)=>{
458
+ const colKey = getColKey(col_4, i_1);
459
+ const hasSorter = !!col_4.sorter;
460
+ const hasFilter = !!(col_4.filters && col_4.filters.length > 0);
461
+ const { sortOrder: resolvedOrder, filteredValue: activeFilterValues, onSort, onFilter } = tableData.getColumnState(i_1);
462
+ const stickyPos = stickyPositions[colKey];
463
+ const isFixed = !!col_4.fixed && !!scroll?.x;
464
+ const headerCellProps = col_4.onHeaderCell?.(col_4) ?? {};
465
+ return /*#__PURE__*/ createElement("th", {
466
+ ...headerCellProps,
467
+ key: colKey,
522
468
  "data-tao-table-cell": "",
523
- "data-tao-table-selection-cell": "",
524
- "data-tao-fixed": "left",
525
- className: resolvedClassNames['selection.cell'],
469
+ "data-tao-table-header": "",
470
+ "data-tao-align": col_4.align,
471
+ "data-tao-fixed": isFixed ? col_4.fixed : void 0,
472
+ "aria-sort": hasSorter ? "ascend" === resolvedOrder ? "ascending" : "descend" === resolvedOrder ? "descending" : "none" : void 0,
473
+ className: cx(resolvedClassNames["header.cell"], headerCellProps.className),
526
474
  style: {
527
- ...stickyPositions.__selection__ ? {
528
- position: 'sticky',
529
- left: stickyPositions.__selection__.left,
530
- zIndex: 1
531
- } : {},
532
- ...resolvedStyles['selection.cell']
533
- },
534
- children: /*#__PURE__*/ jsx("input", {
535
- type: 'radio' === selectionType ? 'radio' : 'checkbox',
536
- checked: isSelected,
537
- "aria-label": `Select row ${String(key_9)}`,
538
- disabled: checkboxProps?.disabled,
539
- onChange: ()=>handleSelectRow(key_9),
540
- "data-tao-table-checkbox": ""
541
- })
542
- }),
543
- columns.map((col_14, colIdx_1)=>{
544
- const colKey_3 = getColKey(col_14, colIdx_1);
545
- const value = getCellValue(record_3, col_14.dataIndex);
546
- const stickyPos_0 = stickyPositions[colKey_3];
547
- const isFixed_0 = !!col_14.fixed && !!scroll?.x;
548
- const cellProps = col_14.onCell?.(record_3, rowIdx) ?? {};
549
- return /*#__PURE__*/ createElement("td", {
550
- ...cellProps,
551
- key: colKey_3,
552
- "data-tao-table-cell": "",
553
- "data-tao-align": col_14.align,
554
- "data-tao-ellipsis": col_14.ellipsis || void 0,
555
- "data-tao-fixed": isFixed_0 ? col_14.fixed : void 0,
556
- className: cx(resolvedClassNames['body.cell'], cellProps.className),
557
- style: {
558
- ...resolvedStyles['body.cell'],
559
- ...isFixed_0 && stickyPos_0 ? {
560
- position: 'sticky',
561
- ...void 0 !== stickyPos_0.left ? {
562
- left: stickyPos_0.left
563
- } : {},
564
- ...void 0 !== stickyPos_0.right ? {
565
- right: stickyPos_0.right
566
- } : {},
567
- zIndex: 1
475
+ ...resolvedStyles["header.cell"],
476
+ width: col_4.width,
477
+ ...isFixed && stickyPos ? {
478
+ position: "sticky",
479
+ ...void 0 !== stickyPos.left ? {
480
+ left: stickyPos.left
568
481
  } : {},
569
- ...cellProps.style
570
- }
571
- }, col_14.render ? col_14.render(value, record_3, rowIdx) : value);
572
- })
573
- ]
574
- });
482
+ ...void 0 !== stickyPos.right ? {
483
+ right: stickyPos.right
484
+ } : {},
485
+ zIndex: 2
486
+ } : {},
487
+ ...headerCellProps.style
488
+ }
489
+ }, /*#__PURE__*/ jsxs("div", {
490
+ "data-tao-table-header-content": "",
491
+ className: resolvedClassNames["header.content"],
492
+ style: resolvedStyles["header.content"],
493
+ children: [
494
+ hasSorter ? /*#__PURE__*/ jsxs("button", {
495
+ type: "button",
496
+ "data-tao-table-header-title": "",
497
+ "data-tao-sortable": "",
498
+ className: resolvedClassNames["header.title"],
499
+ style: resolvedStyles["header.title"],
500
+ onClick: onSort,
501
+ children: [
502
+ col_4.title,
503
+ /*#__PURE__*/ jsx(SortIcon, {
504
+ order: resolvedOrder
505
+ })
506
+ ]
507
+ }) : /*#__PURE__*/ jsx("span", {
508
+ "data-tao-table-header-title": "",
509
+ className: resolvedClassNames["header.title"],
510
+ style: resolvedStyles["header.title"],
511
+ children: col_4.title
512
+ }),
513
+ hasFilter && /*#__PURE__*/ jsx(TableFilterDropdown, {
514
+ filters: col_4.filters,
515
+ activeValues: activeFilterValues,
516
+ onSelect: onFilter
517
+ })
518
+ ]
519
+ }));
520
+ })
521
+ ]
575
522
  })
576
- })
523
+ }),
524
+ t22
577
525
  ]
578
526
  })
579
527
  ]
580
528
  }),
581
- hasPagination && totalForPagination > 0 && /*#__PURE__*/ jsx("div", {
582
- "data-tao-table-pagination": "",
583
- className: resolvedClassNames.pagination,
584
- style: resolvedStyles.pagination,
585
- children: /*#__PURE__*/ jsx(Pagination, {
586
- current: currentPage,
587
- pageSize: pageSize,
588
- total: totalForPagination,
589
- onChange: handlePageChange,
590
- size: resolvedSize,
591
- showSizeChanger: paginationConfig?.showSizeChanger,
592
- pageSizeOptions: paginationConfig?.pageSizeOptions,
593
- showTotal: paginationConfig?.showTotal
594
- })
595
- })
529
+ t23
596
530
  ]
597
531
  });
598
532
  }
533
+ function _temp(col_0) {
534
+ return col_0.responsive;
535
+ }
599
536
  export { Table };