@expcat/tigercat-react 1.2.37 → 1.2.41
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.
- package/dist/{chunk-2CJKAO2I.mjs → chunk-2VE2CP7E.mjs} +144 -9
- package/dist/{chunk-JNRUOQNT.js → chunk-36I5APFX.js} +2 -2
- package/dist/{chunk-C3NKZZQQ.js → chunk-AE2QE2C6.js} +2 -2
- package/dist/{chunk-4XOWNEZA.mjs → chunk-C44WSDEY.mjs} +19 -4
- package/dist/{chunk-6HELKWFN.js → chunk-JIFSUUGA.js} +19 -4
- package/dist/{chunk-AKZY7QYA.js → chunk-JLQBG5XU.js} +23 -17
- package/dist/{chunk-L2CAJUXH.js → chunk-LHBE3N3U.js} +162 -27
- package/dist/{chunk-IAONLOJN.js → chunk-LYYL2JMP.js} +2 -2
- package/dist/{chunk-UKBVJWP3.mjs → chunk-MV54EEKO.mjs} +1 -1
- package/dist/{chunk-KRFD27WA.js → chunk-OBY4FYRZ.js} +2 -2
- package/dist/{chunk-O4UDB6ZE.mjs → chunk-TANTMMR7.mjs} +1 -1
- package/dist/{chunk-WVTUGFWO.mjs → chunk-TYZNV54N.mjs} +23 -17
- package/dist/{chunk-ZGPOMSGD.mjs → chunk-WYGO6XC7.mjs} +232 -74
- package/dist/{chunk-MIINT2WV.js → chunk-XUETAIF3.js} +264 -106
- package/dist/{chunk-VE2YEFG2.mjs → chunk-ZDS5WL22.mjs} +1 -1
- package/dist/{chunk-73OAHAPC.mjs → chunk-ZL44XLSB.mjs} +1 -1
- package/dist/components/ChatWindow.js +3 -3
- package/dist/components/ChatWindow.mjs +2 -2
- package/dist/components/DataTableWithToolbar.d.mts +2 -2
- package/dist/components/DataTableWithToolbar.d.ts +2 -2
- package/dist/components/DataTableWithToolbar.js +12 -3
- package/dist/components/DataTableWithToolbar.mjs +11 -2
- package/dist/components/Dropdown.js +2 -2
- package/dist/components/Dropdown.mjs +1 -1
- package/dist/components/DropdownItem.js +3 -3
- package/dist/components/DropdownItem.mjs +2 -2
- package/dist/components/DropdownMenu.js +2 -2
- package/dist/components/DropdownMenu.mjs +1 -1
- package/dist/components/Popconfirm.js +3 -3
- package/dist/components/Popconfirm.mjs +2 -2
- package/dist/components/Popover.js +3 -3
- package/dist/components/Popover.mjs +2 -2
- package/dist/components/Table.d.mts +2 -2
- package/dist/components/Table.d.ts +2 -2
- package/dist/components/Table.js +9 -2
- package/dist/components/Table.mjs +8 -1
- package/dist/components/Tooltip.js +3 -3
- package/dist/components/Tooltip.mjs +2 -2
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +20 -20
- package/dist/index.mjs +20 -20
- package/dist/{types-mtq1tZJd.d.ts → types-CHmCMNEM.d.mts} +1 -0
- package/dist/{types-mtq1tZJd.d.mts → types-CHmCMNEM.d.ts} +1 -0
- package/package.json +2 -2
- package/dist/{chunk-7KPALCG3.js → chunk-ABTJVM3X.js} +2 -2
- package/dist/{chunk-GYFR2O27.mjs → chunk-OXDX6CH2.mjs} +3 -3
|
@@ -1,6 +1,18 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Select
|
|
3
|
+
} from "./chunk-T4OVGM4X.mjs";
|
|
4
|
+
import {
|
|
5
|
+
Radio
|
|
6
|
+
} from "./chunk-NPTXXUXF.mjs";
|
|
1
7
|
import {
|
|
2
8
|
useTigerConfig
|
|
3
9
|
} from "./chunk-QAIBQHIO.mjs";
|
|
10
|
+
import {
|
|
11
|
+
Empty
|
|
12
|
+
} from "./chunk-WIWTY74F.mjs";
|
|
13
|
+
import {
|
|
14
|
+
Checkbox
|
|
15
|
+
} from "./chunk-MSHCPJIJ.mjs";
|
|
4
16
|
|
|
5
17
|
// src/components/Table.tsx
|
|
6
18
|
import { useEffect as useEffect2, useMemo as useMemo2, useRef, useState as useState2 } from "react";
|
|
@@ -12,6 +24,9 @@ import {
|
|
|
12
24
|
getTableResponsiveCardListClasses,
|
|
13
25
|
getTableResponsiveTableClasses,
|
|
14
26
|
getTableVirtualRecommendation,
|
|
27
|
+
formatTableSelectRowAriaLabel,
|
|
28
|
+
formatTableSortByText,
|
|
29
|
+
getTableLabels,
|
|
15
30
|
tableBaseClasses,
|
|
16
31
|
tableResponsiveCardClasses,
|
|
17
32
|
tableResponsiveCardLabelClasses,
|
|
@@ -100,13 +115,16 @@ import {
|
|
|
100
115
|
createTableRowKeyCache,
|
|
101
116
|
filterDataAdvanced,
|
|
102
117
|
groupDataByColumn,
|
|
103
|
-
getFixedColumnOffsets
|
|
118
|
+
getFixedColumnOffsets,
|
|
119
|
+
filterHiddenColumns
|
|
104
120
|
} from "@expcat/tigercat-core";
|
|
105
121
|
import { exportTableData, downloadTableExport } from "@expcat/tigercat-core";
|
|
106
122
|
function useTableState(input) {
|
|
107
123
|
const {
|
|
108
124
|
columns,
|
|
109
125
|
dataSource,
|
|
126
|
+
hiddenColumnKeys,
|
|
127
|
+
defaultHiddenColumnKeys,
|
|
110
128
|
sort,
|
|
111
129
|
defaultSort,
|
|
112
130
|
filters,
|
|
@@ -128,6 +146,7 @@ function useTableState(input) {
|
|
|
128
146
|
onSelectionChange,
|
|
129
147
|
onSortChange,
|
|
130
148
|
onFilterChange,
|
|
149
|
+
onHiddenColumnsChange,
|
|
131
150
|
onPageChange,
|
|
132
151
|
onExpandChange,
|
|
133
152
|
onCellChange,
|
|
@@ -137,6 +156,7 @@ function useTableState(input) {
|
|
|
137
156
|
} = input;
|
|
138
157
|
const isSortControlled = sort !== void 0;
|
|
139
158
|
const isFiltersControlled = filters !== void 0;
|
|
159
|
+
const isHiddenColumnsControlled = hiddenColumnKeys !== void 0;
|
|
140
160
|
const paginationConfig = pagination !== false && typeof pagination === "object" ? pagination : null;
|
|
141
161
|
const isCurrentPageControlled = paginationConfig?.current !== void 0;
|
|
142
162
|
const isPageSizeControlled = paginationConfig?.pageSize !== void 0;
|
|
@@ -145,6 +165,9 @@ function useTableState(input) {
|
|
|
145
165
|
const [uncontrolledSortState, setUncontrolledSortState] = useState(
|
|
146
166
|
defaultSort ?? { key: null, direction: null }
|
|
147
167
|
);
|
|
168
|
+
const [uncontrolledHiddenColumnKeys, setUncontrolledHiddenColumnKeys] = useState(
|
|
169
|
+
defaultHiddenColumnKeys ?? hiddenColumnKeys ?? []
|
|
170
|
+
);
|
|
148
171
|
const [uncontrolledFilterState, setUncontrolledFilterState] = useState(
|
|
149
172
|
defaultFilters ?? {}
|
|
150
173
|
);
|
|
@@ -157,6 +180,7 @@ function useTableState(input) {
|
|
|
157
180
|
const [uncontrolledSelectedRowKeys, setUncontrolledSelectedRowKeys] = useState(rowSelection?.defaultSelectedRowKeys ?? rowSelection?.selectedRowKeys ?? []);
|
|
158
181
|
const [uncontrolledExpandedRowKeys, setUncontrolledExpandedRowKeys] = useState(expandable?.defaultExpandedRowKeys ?? expandable?.expandedRowKeys ?? []);
|
|
159
182
|
const sortState = isSortControlled ? sort : uncontrolledSortState;
|
|
183
|
+
const effectiveHiddenColumnKeys = isHiddenColumnsControlled ? hiddenColumnKeys : uncontrolledHiddenColumnKeys;
|
|
160
184
|
const filterState = isFiltersControlled ? filters : uncontrolledFilterState;
|
|
161
185
|
const currentPage = isCurrentPageControlled ? paginationConfig.current : uncontrolledCurrentPage;
|
|
162
186
|
const currentPageSize = isPageSizeControlled ? paginationConfig.pageSize : uncontrolledCurrentPageSize;
|
|
@@ -187,6 +211,11 @@ function useTableState(input) {
|
|
|
187
211
|
setUncontrolledSelectedRowKeys(rowSelection?.selectedRowKeys ?? []);
|
|
188
212
|
}
|
|
189
213
|
}, [isSelectionControlled, rowSelection?.selectedRowKeys]);
|
|
214
|
+
useEffect(() => {
|
|
215
|
+
if (isHiddenColumnsControlled && hiddenColumnKeys) {
|
|
216
|
+
setUncontrolledHiddenColumnKeys(hiddenColumnKeys);
|
|
217
|
+
}
|
|
218
|
+
}, [isHiddenColumnsControlled, hiddenColumnKeys]);
|
|
190
219
|
useEffect(() => {
|
|
191
220
|
if (isExpandControlled) {
|
|
192
221
|
setUncontrolledExpandedRowKeys(expandable?.expandedRowKeys ?? []);
|
|
@@ -194,14 +223,15 @@ function useTableState(input) {
|
|
|
194
223
|
}, [isExpandControlled, expandable?.expandedRowKeys]);
|
|
195
224
|
const [fixedOverrides, setFixedOverrides] = useState({});
|
|
196
225
|
const displayColumns = useMemo(() => {
|
|
197
|
-
|
|
226
|
+
const mapped = columns.map((column) => {
|
|
198
227
|
const hasOverride = Object.prototype.hasOwnProperty.call(fixedOverrides, column.key);
|
|
199
228
|
return {
|
|
200
229
|
...column,
|
|
201
230
|
fixed: hasOverride ? fixedOverrides[column.key] : column.fixed
|
|
202
231
|
};
|
|
203
232
|
});
|
|
204
|
-
|
|
233
|
+
return filterHiddenColumns(mapped, effectiveHiddenColumnKeys);
|
|
234
|
+
}, [columns, fixedOverrides, effectiveHiddenColumnKeys]);
|
|
205
235
|
const totalColumnCount = useMemo(() => {
|
|
206
236
|
let count = displayColumns.length;
|
|
207
237
|
if (rowSelection && rowSelection.showCheckbox !== false) count++;
|
|
@@ -219,6 +249,12 @@ function useTableState(input) {
|
|
|
219
249
|
() => getFixedColumnOffsets(displayColumns, measuredColumnWidths),
|
|
220
250
|
[displayColumns, measuredColumnWidths]
|
|
221
251
|
);
|
|
252
|
+
function handleSetHiddenColumns(hiddenKeys) {
|
|
253
|
+
if (!isHiddenColumnsControlled) {
|
|
254
|
+
setUncontrolledHiddenColumnKeys(hiddenKeys);
|
|
255
|
+
}
|
|
256
|
+
onHiddenColumnsChange?.(hiddenKeys);
|
|
257
|
+
}
|
|
222
258
|
function toggleColumnLock(columnKey) {
|
|
223
259
|
setFixedOverrides((prev) => {
|
|
224
260
|
const original = columns.find((c) => c.key === columnKey)?.fixed;
|
|
@@ -268,6 +304,17 @@ function useTableState(input) {
|
|
|
268
304
|
const total = paginationConfig?.total !== void 0 && paginationConfig.total > 0 ? paginationConfig.total : processedData.length;
|
|
269
305
|
return calculatePagination(total, currentPage, currentPageSize);
|
|
270
306
|
}, [processedData.length, currentPage, currentPageSize, pagination, paginationConfig?.total]);
|
|
307
|
+
function handleSetSort(newSortState) {
|
|
308
|
+
if (!isSortControlled) {
|
|
309
|
+
setUncontrolledSortState(newSortState);
|
|
310
|
+
}
|
|
311
|
+
onSortChange?.(newSortState);
|
|
312
|
+
onChange?.({
|
|
313
|
+
sort: newSortState,
|
|
314
|
+
filters: filterState,
|
|
315
|
+
pagination: pagination !== false ? { current: currentPage, pageSize: currentPageSize } : null
|
|
316
|
+
});
|
|
317
|
+
}
|
|
271
318
|
function handleSort(columnKey) {
|
|
272
319
|
const column = columnByKey[columnKey];
|
|
273
320
|
if (!column || !column.sortable) return;
|
|
@@ -279,18 +326,9 @@ function useTableState(input) {
|
|
|
279
326
|
newDirection = null;
|
|
280
327
|
}
|
|
281
328
|
}
|
|
282
|
-
|
|
329
|
+
handleSetSort({
|
|
283
330
|
key: newDirection ? columnKey : null,
|
|
284
331
|
direction: newDirection
|
|
285
|
-
};
|
|
286
|
-
if (!isSortControlled) {
|
|
287
|
-
setUncontrolledSortState(newSortState);
|
|
288
|
-
}
|
|
289
|
-
onSortChange?.(newSortState);
|
|
290
|
-
onChange?.({
|
|
291
|
-
sort: newSortState,
|
|
292
|
-
filters: filterState,
|
|
293
|
-
pagination: pagination !== false ? { current: currentPage, pageSize: currentPageSize } : null
|
|
294
332
|
});
|
|
295
333
|
}
|
|
296
334
|
function handleFilter(columnKey, value) {
|
|
@@ -460,14 +498,17 @@ function useTableState(input) {
|
|
|
460
498
|
sortState,
|
|
461
499
|
currentPage,
|
|
462
500
|
currentPageSize,
|
|
501
|
+
hiddenColumnKeys: effectiveHiddenColumnKeys,
|
|
463
502
|
editingCell,
|
|
464
503
|
editingValue,
|
|
465
504
|
setEditingValue,
|
|
466
505
|
toggleColumnLock,
|
|
506
|
+
handleSetHiddenColumns,
|
|
467
507
|
handleSort,
|
|
468
508
|
handleFilter,
|
|
469
509
|
handlePageChange,
|
|
470
510
|
handlePageSizeChange,
|
|
511
|
+
handleSetSort,
|
|
471
512
|
handleRowClick,
|
|
472
513
|
handleToggleExpand,
|
|
473
514
|
handleSelectRow,
|
|
@@ -920,6 +961,8 @@ function Table({
|
|
|
920
961
|
columns,
|
|
921
962
|
columnLockable = false,
|
|
922
963
|
dataSource = [],
|
|
964
|
+
hiddenColumnKeys,
|
|
965
|
+
defaultHiddenColumnKeys,
|
|
923
966
|
sort,
|
|
924
967
|
defaultSort,
|
|
925
968
|
filters,
|
|
@@ -929,7 +972,9 @@ function Table({
|
|
|
929
972
|
striped = false,
|
|
930
973
|
hoverable = true,
|
|
931
974
|
loading = false,
|
|
932
|
-
|
|
975
|
+
locale,
|
|
976
|
+
labels,
|
|
977
|
+
emptyText,
|
|
933
978
|
pagination = {
|
|
934
979
|
current: 1,
|
|
935
980
|
pageSize: 10,
|
|
@@ -947,6 +992,8 @@ function Table({
|
|
|
947
992
|
tableLayout = "auto",
|
|
948
993
|
responsiveMode = "scroll",
|
|
949
994
|
cardBreakpoint = "sm",
|
|
995
|
+
cardClassName,
|
|
996
|
+
renderCard,
|
|
950
997
|
// v0.6.0 props
|
|
951
998
|
virtual = false,
|
|
952
999
|
autoVirtual = true,
|
|
@@ -970,6 +1017,7 @@ function Table({
|
|
|
970
1017
|
onSelectionChange,
|
|
971
1018
|
onSortChange,
|
|
972
1019
|
onFilterChange,
|
|
1020
|
+
onHiddenColumnsChange,
|
|
973
1021
|
onPageChange,
|
|
974
1022
|
onExpandChange,
|
|
975
1023
|
onCellChange,
|
|
@@ -988,12 +1036,20 @@ function Table({
|
|
|
988
1036
|
const internalExpandable = expandable;
|
|
989
1037
|
const internalRowClassName = rowClassName;
|
|
990
1038
|
const paginationLocaleInput = pagination !== false && typeof pagination === "object" ? pagination.locale : void 0;
|
|
1039
|
+
const tableLocaleInput = locale;
|
|
991
1040
|
const isPaginationI18nDisabled = paginationLocaleInput === false;
|
|
992
1041
|
const immediatePaginationLocale = useMemo2(
|
|
993
1042
|
() => paginationLocaleInput && !isPaginationI18nDisabled ? getImmediateTigerLocale(paginationLocaleInput) : void 0,
|
|
994
1043
|
[isPaginationI18nDisabled, paginationLocaleInput]
|
|
995
1044
|
);
|
|
996
1045
|
const [resolvedPaginationLocale, setResolvedPaginationLocale] = useState2(immediatePaginationLocale);
|
|
1046
|
+
const immediateTableLocale = useMemo2(
|
|
1047
|
+
() => tableLocaleInput ? getImmediateTigerLocale(tableLocaleInput) : void 0,
|
|
1048
|
+
[tableLocaleInput]
|
|
1049
|
+
);
|
|
1050
|
+
const [resolvedTableLocale, setResolvedTableLocale] = useState2(
|
|
1051
|
+
immediateTableLocale
|
|
1052
|
+
);
|
|
997
1053
|
useEffect2(() => {
|
|
998
1054
|
let active = true;
|
|
999
1055
|
setResolvedPaginationLocale(immediatePaginationLocale);
|
|
@@ -1008,13 +1064,41 @@ function Table({
|
|
|
1008
1064
|
active = false;
|
|
1009
1065
|
};
|
|
1010
1066
|
}, [isPaginationI18nDisabled, paginationLocaleInput, immediatePaginationLocale]);
|
|
1067
|
+
useEffect2(() => {
|
|
1068
|
+
let active = true;
|
|
1069
|
+
setResolvedTableLocale(immediateTableLocale);
|
|
1070
|
+
if (tableLocaleInput && isLazyTigerLocale(tableLocaleInput)) {
|
|
1071
|
+
resolveTigerLocale(tableLocaleInput).then((nextLocale) => {
|
|
1072
|
+
if (active) setResolvedTableLocale(nextLocale);
|
|
1073
|
+
}).catch(() => {
|
|
1074
|
+
if (active) setResolvedTableLocale(immediateTableLocale);
|
|
1075
|
+
});
|
|
1076
|
+
}
|
|
1077
|
+
return () => {
|
|
1078
|
+
active = false;
|
|
1079
|
+
};
|
|
1080
|
+
}, [tableLocaleInput, immediateTableLocale]);
|
|
1011
1081
|
const paginationLocale = useMemo2(
|
|
1012
1082
|
() => isPaginationI18nDisabled ? void 0 : mergeTigerLocale(config.locale, resolvedPaginationLocale),
|
|
1013
1083
|
[config.locale, isPaginationI18nDisabled, resolvedPaginationLocale]
|
|
1014
1084
|
);
|
|
1085
|
+
const tableLocale = useMemo2(
|
|
1086
|
+
() => mergeTigerLocale(config.locale, resolvedTableLocale),
|
|
1087
|
+
[config.locale, resolvedTableLocale]
|
|
1088
|
+
);
|
|
1089
|
+
const tableLabelOverrides = useMemo2(
|
|
1090
|
+
() => emptyText === void 0 ? labels : { ...labels, emptyText },
|
|
1091
|
+
[emptyText, labels]
|
|
1092
|
+
);
|
|
1093
|
+
const tableLabels = useMemo2(
|
|
1094
|
+
() => getTableLabels(tableLocale, tableLabelOverrides),
|
|
1095
|
+
[tableLabelOverrides, tableLocale]
|
|
1096
|
+
);
|
|
1015
1097
|
const ctx = useTableState({
|
|
1016
1098
|
columns,
|
|
1017
1099
|
dataSource,
|
|
1100
|
+
hiddenColumnKeys,
|
|
1101
|
+
defaultHiddenColumnKeys,
|
|
1018
1102
|
sort,
|
|
1019
1103
|
defaultSort,
|
|
1020
1104
|
filters,
|
|
@@ -1036,6 +1120,7 @@ function Table({
|
|
|
1036
1120
|
onSelectionChange,
|
|
1037
1121
|
onSortChange,
|
|
1038
1122
|
onFilterChange,
|
|
1123
|
+
onHiddenColumnsChange,
|
|
1039
1124
|
onPageChange,
|
|
1040
1125
|
onExpandChange,
|
|
1041
1126
|
onCellChange,
|
|
@@ -1129,7 +1214,7 @@ function Table({
|
|
|
1129
1214
|
hoverable,
|
|
1130
1215
|
striped,
|
|
1131
1216
|
loading,
|
|
1132
|
-
emptyText,
|
|
1217
|
+
emptyText: tableLabels.emptyText,
|
|
1133
1218
|
rowSelection: internalRowSelection,
|
|
1134
1219
|
expandable: internalExpandable,
|
|
1135
1220
|
rowClassName: internalRowClassName,
|
|
@@ -1144,68 +1229,141 @@ function Table({
|
|
|
1144
1229
|
]
|
|
1145
1230
|
}
|
|
1146
1231
|
),
|
|
1147
|
-
responsiveMode === "card" && /* @__PURE__ */
|
|
1232
|
+
responsiveMode === "card" && /* @__PURE__ */ jsxs5(
|
|
1148
1233
|
"div",
|
|
1149
1234
|
{
|
|
1150
1235
|
className: getTableResponsiveCardListClasses(cardBreakpoint),
|
|
1151
1236
|
"data-tiger-table-mobile": "card",
|
|
1152
|
-
children:
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
const isRowExpandable = internalExpandable ? internalExpandable.rowExpandable ? internalExpandable.rowExpandable(record) : true : false;
|
|
1156
|
-
const expandedContent = internalExpandable && isExpanded && isRowExpandable ? internalExpandable.expandedRowRender?.(record, index) : null;
|
|
1157
|
-
const expandedNode = expandedContent;
|
|
1158
|
-
return /* @__PURE__ */ jsxs5(
|
|
1159
|
-
"div",
|
|
1237
|
+
children: [
|
|
1238
|
+
internalRowSelection?.type !== "radio" && internalRowSelection?.showCheckbox !== false && internalRowSelection && ctx.paginatedData.length > 0 ? /* @__PURE__ */ jsx6("div", { className: "flex items-center justify-between rounded-[var(--tiger-radius-md,0.5rem)] border border-[var(--tiger-border,#e5e7eb)] bg-[var(--tiger-surface,#ffffff)] px-3 py-2", children: /* @__PURE__ */ jsx6(
|
|
1239
|
+
Checkbox,
|
|
1160
1240
|
{
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
{
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
(
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1241
|
+
size: "sm",
|
|
1242
|
+
checked: ctx.allSelected,
|
|
1243
|
+
indeterminate: ctx.someSelected,
|
|
1244
|
+
onChange: (checked) => ctx.handleSelectAll(checked),
|
|
1245
|
+
children: tableLabels.selectAllText
|
|
1246
|
+
}
|
|
1247
|
+
) }) : null,
|
|
1248
|
+
ctx.displayColumns.some((column) => column.sortable) ? /* @__PURE__ */ jsx6("div", { className: "rounded-[var(--tiger-radius-md,0.5rem)] border border-[var(--tiger-border,#e5e7eb)] bg-[var(--tiger-surface,#ffffff)] px-3 py-2", children: /* @__PURE__ */ jsx6(
|
|
1249
|
+
Select,
|
|
1250
|
+
{
|
|
1251
|
+
size: "sm",
|
|
1252
|
+
value: ctx.sortState.key && ctx.sortState.direction ? `${ctx.sortState.key}:${ctx.sortState.direction}` : "",
|
|
1253
|
+
options: [
|
|
1254
|
+
{ label: tableLabels.clearSortText, value: "" },
|
|
1255
|
+
...ctx.displayColumns.filter((column) => column.sortable).flatMap((column) => [
|
|
1256
|
+
{
|
|
1257
|
+
label: `${formatTableSortByText(tableLabels.sortByText, column.title)} \u2191`,
|
|
1258
|
+
value: `${column.key}:asc`
|
|
1259
|
+
},
|
|
1260
|
+
{
|
|
1261
|
+
label: `${formatTableSortByText(tableLabels.sortByText, column.title)} \u2193`,
|
|
1262
|
+
value: `${column.key}:desc`
|
|
1263
|
+
}
|
|
1264
|
+
])
|
|
1265
|
+
],
|
|
1266
|
+
clearable: false,
|
|
1267
|
+
onChange: (value) => {
|
|
1268
|
+
const nextValue = String(value ?? "");
|
|
1269
|
+
if (!nextValue) {
|
|
1270
|
+
ctx.handleSetSort({ key: null, direction: null });
|
|
1271
|
+
return;
|
|
1272
|
+
}
|
|
1273
|
+
const separatorIndex = nextValue.lastIndexOf(":");
|
|
1274
|
+
const key = nextValue.slice(0, separatorIndex);
|
|
1275
|
+
const direction = nextValue.slice(separatorIndex + 1);
|
|
1276
|
+
ctx.handleSetSort({ key, direction });
|
|
1277
|
+
}
|
|
1278
|
+
}
|
|
1279
|
+
) }) : null,
|
|
1280
|
+
ctx.paginatedData.length === 0 ? /* @__PURE__ */ jsx6("div", { className: tableResponsiveCardClasses, children: /* @__PURE__ */ jsx6(Empty, { showImage: false, description: tableLabels.emptyText }) }) : ctx.paginatedData.map((record, index) => {
|
|
1281
|
+
const key = ctx.pageRowKeys[index];
|
|
1282
|
+
const isExpanded = ctx.expandedRowKeySet.has(key);
|
|
1283
|
+
const isSelected = ctx.selectedRowKeySet.has(key);
|
|
1284
|
+
const isRowExpandable = internalExpandable ? internalExpandable.rowExpandable ? internalExpandable.rowExpandable(record) : true : false;
|
|
1285
|
+
const expandedContent = internalExpandable && isExpanded && isRowExpandable ? internalExpandable.expandedRowRender?.(record, index) : null;
|
|
1286
|
+
const expandedNode = expandedContent;
|
|
1287
|
+
const renderContext = {
|
|
1288
|
+
record,
|
|
1289
|
+
index,
|
|
1290
|
+
columns: ctx.displayColumns,
|
|
1291
|
+
selected: isSelected,
|
|
1292
|
+
expanded: isExpanded,
|
|
1293
|
+
toggleExpand: () => ctx.handleToggleExpand(key, record),
|
|
1294
|
+
selectRow: (checked) => ctx.handleSelectRow(key, checked)
|
|
1295
|
+
};
|
|
1296
|
+
const customCard = renderCard?.(renderContext);
|
|
1297
|
+
const resolvedCardClassName = typeof cardClassName === "function" ? cardClassName(record, index) : cardClassName;
|
|
1298
|
+
return /* @__PURE__ */ jsx6(
|
|
1299
|
+
"div",
|
|
1300
|
+
{
|
|
1301
|
+
className: classNames3(tableResponsiveCardClasses, resolvedCardClassName),
|
|
1302
|
+
onClick: () => ctx.handleRowClick(record, index, key),
|
|
1303
|
+
children: customCard !== void 0 && customCard !== null ? customCard : /* @__PURE__ */ jsxs5(Fragment, { children: [
|
|
1304
|
+
internalRowSelection?.showCheckbox !== false && internalRowSelection || internalExpandable && isRowExpandable ? /* @__PURE__ */ jsxs5("div", { className: "mb-2 flex items-center gap-3", children: [
|
|
1305
|
+
internalRowSelection && internalRowSelection.showCheckbox !== false && /* @__PURE__ */ jsx6("span", { onClick: (event) => event.stopPropagation(), children: internalRowSelection.type === "radio" ? /* @__PURE__ */ jsx6(
|
|
1306
|
+
Radio,
|
|
1307
|
+
{
|
|
1308
|
+
value: key,
|
|
1309
|
+
checked: isSelected,
|
|
1310
|
+
disabled: internalRowSelection.getCheckboxProps?.(record)?.disabled,
|
|
1311
|
+
"aria-label": formatTableSelectRowAriaLabel(
|
|
1312
|
+
tableLabels.selectRowAriaLabel,
|
|
1313
|
+
index + 1,
|
|
1314
|
+
tableLocale?.locale
|
|
1315
|
+
),
|
|
1316
|
+
onChange: () => ctx.handleSelectRow(key, true)
|
|
1317
|
+
}
|
|
1318
|
+
) : /* @__PURE__ */ jsx6(
|
|
1319
|
+
Checkbox,
|
|
1320
|
+
{
|
|
1321
|
+
size: "sm",
|
|
1322
|
+
checked: isSelected,
|
|
1323
|
+
disabled: internalRowSelection.getCheckboxProps?.(record)?.disabled,
|
|
1324
|
+
"aria-label": formatTableSelectRowAriaLabel(
|
|
1325
|
+
tableLabels.selectRowAriaLabel,
|
|
1326
|
+
index + 1,
|
|
1327
|
+
tableLocale?.locale
|
|
1328
|
+
),
|
|
1329
|
+
onChange: (checked) => ctx.handleSelectRow(key, checked)
|
|
1330
|
+
}
|
|
1331
|
+
) }),
|
|
1332
|
+
internalExpandable && isRowExpandable && /* @__PURE__ */ jsx6(
|
|
1333
|
+
"button",
|
|
1334
|
+
{
|
|
1335
|
+
type: "button",
|
|
1336
|
+
className: "text-sm text-[var(--tiger-primary,#2563eb)]",
|
|
1337
|
+
"aria-expanded": isExpanded,
|
|
1338
|
+
onClick: (event) => {
|
|
1339
|
+
event.stopPropagation();
|
|
1340
|
+
ctx.handleToggleExpand(key, record);
|
|
1341
|
+
},
|
|
1342
|
+
children: isExpanded ? tableLabels.collapseText : tableLabels.expandText
|
|
1343
|
+
}
|
|
1344
|
+
)
|
|
1345
|
+
] }) : null,
|
|
1346
|
+
(() => {
|
|
1347
|
+
const { titleColumn, bodyColumns } = getCardColumns(ctx.displayColumns);
|
|
1348
|
+
const renderCellContent = (column) => {
|
|
1349
|
+
const dataKey = column.dataKey || column.key;
|
|
1350
|
+
return column.render ? column.render(record, index) : record[dataKey];
|
|
1351
|
+
};
|
|
1352
|
+
return /* @__PURE__ */ jsxs5(Fragment, { children: [
|
|
1353
|
+
titleColumn && /* @__PURE__ */ jsx6("div", { className: tableResponsiveCardTitleClasses, children: renderCellContent(titleColumn) }),
|
|
1354
|
+
bodyColumns.map((column) => /* @__PURE__ */ jsxs5("div", { className: tableResponsiveCardRowClasses, children: [
|
|
1355
|
+
/* @__PURE__ */ jsx6("div", { className: tableResponsiveCardLabelClasses, children: column.title }),
|
|
1356
|
+
/* @__PURE__ */ jsx6("div", { className: tableResponsiveCardValueClasses, children: renderCellContent(column) })
|
|
1357
|
+
] }, column.key))
|
|
1358
|
+
] });
|
|
1359
|
+
})(),
|
|
1360
|
+
expandedNode && /* @__PURE__ */ jsx6("div", { className: "mt-3 border-t border-[var(--tiger-border,#e5e7eb)] pt-3", children: expandedNode })
|
|
1361
|
+
] })
|
|
1362
|
+
},
|
|
1363
|
+
key
|
|
1364
|
+
);
|
|
1365
|
+
})
|
|
1366
|
+
]
|
|
1209
1367
|
}
|
|
1210
1368
|
),
|
|
1211
1369
|
loading && /* @__PURE__ */ jsxs5(
|
|
@@ -1214,10 +1372,10 @@ function Table({
|
|
|
1214
1372
|
className: tableLoadingOverlayClasses,
|
|
1215
1373
|
role: "status",
|
|
1216
1374
|
"aria-live": "polite",
|
|
1217
|
-
"aria-label":
|
|
1375
|
+
"aria-label": tableLabels.loadingText,
|
|
1218
1376
|
children: [
|
|
1219
1377
|
/* @__PURE__ */ jsx6(LoadingSpinner, {}),
|
|
1220
|
-
/* @__PURE__ */ jsx6("span", { className: "sr-only", children:
|
|
1378
|
+
/* @__PURE__ */ jsx6("span", { className: "sr-only", children: tableLabels.loadingText })
|
|
1221
1379
|
]
|
|
1222
1380
|
}
|
|
1223
1381
|
),
|