@kopexa/data-grid 18.1.0 → 18.3.0
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-KSAE2MI5.mjs → chunk-EVXFPN6F.mjs} +199 -39
- package/dist/chunk-M6DRKGKE.mjs +15 -0
- package/dist/data-grid-messages.d.mts +9 -0
- package/dist/data-grid-messages.d.ts +9 -0
- package/dist/data-grid-messages.js +38 -0
- package/dist/data-grid-messages.mjs +7 -0
- package/dist/data-grid.d.mts +26 -1
- package/dist/data-grid.d.ts +26 -1
- package/dist/data-grid.js +212 -41
- package/dist/data-grid.mjs +8 -3
- package/dist/index.d.mts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +208 -40
- package/dist/index.mjs +5 -2
- package/package.json +10 -5
package/dist/data-grid.js
CHANGED
|
@@ -23,18 +23,36 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
23
23
|
var data_grid_exports = {};
|
|
24
24
|
__export(data_grid_exports, {
|
|
25
25
|
DataGrid: () => DataGrid,
|
|
26
|
+
DataGridColumnToggle: () => DataGridColumnToggle,
|
|
26
27
|
DataGridContainer: () => DataGridContainer,
|
|
27
28
|
DataGridTable: () => DataGridTable,
|
|
28
29
|
DataGridTableRowSelect: () => DataGridTableRowSelect,
|
|
29
|
-
DataGridTableRowSelectAll: () => DataGridTableRowSelectAll
|
|
30
|
+
DataGridTableRowSelectAll: () => DataGridTableRowSelectAll,
|
|
31
|
+
SETTINGS_COLUMN_WIDTH: () => SETTINGS_COLUMN_WIDTH
|
|
30
32
|
});
|
|
31
33
|
module.exports = __toCommonJS(data_grid_exports);
|
|
34
|
+
var import_button = require("@kopexa/button");
|
|
32
35
|
var import_checkbox = require("@kopexa/checkbox");
|
|
36
|
+
var import_dropdown_menu = require("@kopexa/dropdown-menu");
|
|
37
|
+
var import_i18n2 = require("@kopexa/i18n");
|
|
38
|
+
var import_icons = require("@kopexa/icons");
|
|
33
39
|
var import_react_utils = require("@kopexa/react-utils");
|
|
34
40
|
var import_shared_utils = require("@kopexa/shared-utils");
|
|
35
41
|
var import_theme = require("@kopexa/theme");
|
|
36
42
|
var import_react_table = require("@tanstack/react-table");
|
|
37
43
|
var import_react = require("react");
|
|
44
|
+
|
|
45
|
+
// src/data-grid-messages.ts
|
|
46
|
+
var import_i18n = require("@kopexa/i18n");
|
|
47
|
+
var dataGridMessages = (0, import_i18n.defineMessages)({
|
|
48
|
+
columns: {
|
|
49
|
+
id: "data-grid.columns",
|
|
50
|
+
defaultMessage: "Columns",
|
|
51
|
+
description: "Label for the column visibility toggle button"
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
// src/data-grid.tsx
|
|
38
56
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
39
57
|
var [DataGridProvider, useDataGridContext] = (
|
|
40
58
|
// biome-ignore lint/suspicious/noExplicitAny: no idea.
|
|
@@ -59,6 +77,7 @@ function DataGrid(props) {
|
|
|
59
77
|
isLoading = false,
|
|
60
78
|
pageSize = 20,
|
|
61
79
|
cellBorder,
|
|
80
|
+
columnVisibilityToggle,
|
|
62
81
|
onRowClick,
|
|
63
82
|
...rest
|
|
64
83
|
} = props;
|
|
@@ -103,9 +122,11 @@ function DataGrid(props) {
|
|
|
103
122
|
rowBorder,
|
|
104
123
|
cellBorder,
|
|
105
124
|
loadingMode,
|
|
125
|
+
width,
|
|
106
126
|
emptyMessage,
|
|
107
127
|
isLoading,
|
|
108
128
|
pageSize,
|
|
129
|
+
columnVisibilityToggle,
|
|
109
130
|
onRowClick
|
|
110
131
|
}),
|
|
111
132
|
[
|
|
@@ -118,9 +139,11 @@ function DataGrid(props) {
|
|
|
118
139
|
rowBorder,
|
|
119
140
|
cellBorder,
|
|
120
141
|
loadingMode,
|
|
142
|
+
width,
|
|
121
143
|
emptyMessage,
|
|
122
144
|
isLoading,
|
|
123
145
|
pageSize,
|
|
146
|
+
columnVisibilityToggle,
|
|
124
147
|
onRowClick
|
|
125
148
|
]
|
|
126
149
|
);
|
|
@@ -164,23 +187,33 @@ function DataGridTableHeadRow({
|
|
|
164
187
|
function DataGridTableBase({
|
|
165
188
|
children,
|
|
166
189
|
className,
|
|
190
|
+
style,
|
|
167
191
|
...restProps
|
|
168
192
|
}) {
|
|
169
|
-
const { styles } = useDataGridContext();
|
|
193
|
+
const { styles, table, width } = useDataGridContext();
|
|
194
|
+
const minWidth = width === "fixed" ? table.getVisibleLeafColumns().reduce((acc, column) => acc + column.getSize(), 0) : void 0;
|
|
170
195
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
171
196
|
"table",
|
|
172
197
|
{
|
|
173
198
|
"data-slot": "data-grid-table",
|
|
174
199
|
className: styles.table({ className }),
|
|
200
|
+
style: minWidth ? { minWidth, ...style } : style,
|
|
175
201
|
...restProps,
|
|
176
202
|
children
|
|
177
203
|
}
|
|
178
204
|
);
|
|
179
205
|
}
|
|
206
|
+
var STICKY_RIGHT_CELL = "sticky end-0 bg-background border-s border-border shadow-[-2px_0_5px_-2px_rgba(0,0,0,0.1)]";
|
|
207
|
+
var stickyRightStyle = (z) => ({
|
|
208
|
+
position: "sticky",
|
|
209
|
+
right: 0,
|
|
210
|
+
zIndex: z
|
|
211
|
+
});
|
|
180
212
|
function DataGridTableHeadRowCell({
|
|
181
213
|
children,
|
|
182
214
|
header,
|
|
183
|
-
dndRef
|
|
215
|
+
dndRef,
|
|
216
|
+
stickyRight
|
|
184
217
|
}) {
|
|
185
218
|
var _a;
|
|
186
219
|
const { styles, columnsPinnable } = useDataGridContext();
|
|
@@ -194,13 +227,15 @@ function DataGridTableHeadRowCell({
|
|
|
194
227
|
ref: dndRef,
|
|
195
228
|
style: {
|
|
196
229
|
"--size": `${header.getSize()}px`,
|
|
197
|
-
...columnsPinnable && isPinned && getPinningStyles(column)
|
|
230
|
+
...columnsPinnable && isPinned && getPinningStyles(column),
|
|
231
|
+
...stickyRight && stickyRightStyle(30)
|
|
198
232
|
},
|
|
199
233
|
"data-pinned": isPinned || void 0,
|
|
200
234
|
"data-last-col": isLastLeftPinned ? "left" : isFirstRightPinned ? "right" : void 0,
|
|
201
235
|
className: (0, import_shared_utils.cn)(
|
|
202
236
|
styles.headerRowCell(),
|
|
203
|
-
(_a = header.column.columnDef.meta) == null ? void 0 : _a.headerClassName
|
|
237
|
+
(_a = header.column.columnDef.meta) == null ? void 0 : _a.headerClassName,
|
|
238
|
+
stickyRight && STICKY_RIGHT_CELL
|
|
204
239
|
),
|
|
205
240
|
children
|
|
206
241
|
},
|
|
@@ -237,8 +272,12 @@ function DataGridTableBody({
|
|
|
237
272
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("tbody", { className: (0, import_shared_utils.cn)(styles.body({ className })), ...restProps, children });
|
|
238
273
|
}
|
|
239
274
|
function DataGridTableEmpty() {
|
|
240
|
-
const { styles, table, emptyMessage } = useDataGridContext();
|
|
241
|
-
const
|
|
275
|
+
const { styles, table, emptyMessage, columnVisibilityToggle } = useDataGridContext();
|
|
276
|
+
const { append: hasSettingsColumn } = getSettingsPlacement(
|
|
277
|
+
table,
|
|
278
|
+
columnVisibilityToggle
|
|
279
|
+
);
|
|
280
|
+
const totalColumns = table.getVisibleLeafColumns().length + (hasSettingsColumn ? 1 : 0);
|
|
242
281
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("tr", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { colSpan: totalColumns, className: styles.empty(), children: emptyMessage || "No data available." }) });
|
|
243
282
|
}
|
|
244
283
|
function DataGridTableBodyRowSkeleton({ children }) {
|
|
@@ -259,7 +298,8 @@ function DataGridTableBodyRowCell({
|
|
|
259
298
|
children,
|
|
260
299
|
cell,
|
|
261
300
|
dndRef,
|
|
262
|
-
dndStyle
|
|
301
|
+
dndStyle,
|
|
302
|
+
stickyRight
|
|
263
303
|
}) {
|
|
264
304
|
var _a;
|
|
265
305
|
const { styles, columnsResizable, columnsDraggable, columnsPinnable } = useDataGridContext();
|
|
@@ -275,14 +315,16 @@ function DataGridTableBodyRowCell({
|
|
|
275
315
|
style: {
|
|
276
316
|
"--size": `${column.getSize()}px`,
|
|
277
317
|
...columnsPinnable && isPinned && getPinningStyles(column),
|
|
278
|
-
...dndStyle ? dndStyle : null
|
|
318
|
+
...dndStyle ? dndStyle : null,
|
|
319
|
+
...stickyRight && stickyRightStyle(10)
|
|
279
320
|
},
|
|
280
321
|
"data-pinned": isPinned || void 0,
|
|
281
322
|
"data-last-col": isLastLeftPinned ? "left" : isFirstRightPinned ? "right" : void 0,
|
|
282
323
|
className: (0, import_shared_utils.cn)(
|
|
283
324
|
styles.bodyRowCell(),
|
|
284
325
|
columnsResizable && column.getCanResize() && "truncate",
|
|
285
|
-
(_a = cell.column.columnDef.meta) == null ? void 0 : _a.cellClassName
|
|
326
|
+
(_a = cell.column.columnDef.meta) == null ? void 0 : _a.cellClassName,
|
|
327
|
+
stickyRight && STICKY_RIGHT_CELL
|
|
286
328
|
),
|
|
287
329
|
children
|
|
288
330
|
},
|
|
@@ -291,7 +333,8 @@ function DataGridTableBodyRowCell({
|
|
|
291
333
|
}
|
|
292
334
|
function DataGridTableBodyRowSkeletonCell({
|
|
293
335
|
children,
|
|
294
|
-
column
|
|
336
|
+
column,
|
|
337
|
+
stickyRight
|
|
295
338
|
}) {
|
|
296
339
|
var _a;
|
|
297
340
|
const { styles, columnsResizable, columnsPinnable } = useDataGridContext();
|
|
@@ -303,14 +346,16 @@ function DataGridTableBodyRowSkeletonCell({
|
|
|
303
346
|
{
|
|
304
347
|
style: {
|
|
305
348
|
"--size": `${column.getSize()}px`,
|
|
306
|
-
...columnsPinnable && isPinned && getPinningStyles(column)
|
|
349
|
+
...columnsPinnable && isPinned && getPinningStyles(column),
|
|
350
|
+
...stickyRight && stickyRightStyle(10)
|
|
307
351
|
},
|
|
308
352
|
"data-pinned": isPinned || void 0,
|
|
309
353
|
"data-last-col": isLastLeftPinned ? "left" : isFirstRightPinned ? "right" : void 0,
|
|
310
354
|
className: (0, import_shared_utils.cn)(
|
|
311
355
|
styles.bodyRowSkeletonCell(),
|
|
312
356
|
columnsResizable && column.getCanResize() && "truncate",
|
|
313
|
-
(_a = column.columnDef.meta) == null ? void 0 : _a.cellClassName
|
|
357
|
+
(_a = column.columnDef.meta) == null ? void 0 : _a.cellClassName,
|
|
358
|
+
stickyRight && STICKY_RIGHT_CELL
|
|
314
359
|
),
|
|
315
360
|
children
|
|
316
361
|
}
|
|
@@ -341,15 +386,33 @@ function DataGridTableBodyRow({
|
|
|
341
386
|
}
|
|
342
387
|
function DataGridTableBodyRowExpanded({ row }) {
|
|
343
388
|
var _a, _b, _c;
|
|
344
|
-
const { table, styles } = useDataGridContext();
|
|
345
|
-
|
|
389
|
+
const { table, styles, columnVisibilityToggle } = useDataGridContext();
|
|
390
|
+
const { append: hasSettingsColumn } = getSettingsPlacement(
|
|
391
|
+
table,
|
|
392
|
+
columnVisibilityToggle
|
|
393
|
+
);
|
|
394
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("tr", { className: styles.bodyRowExpanded(), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("td", { colSpan: row.getVisibleCells().length + (hasSettingsColumn ? 1 : 0), children: (_c = (_b = (_a = table.getAllColumns().find((column) => {
|
|
346
395
|
var _a2;
|
|
347
396
|
return (_a2 = column.columnDef.meta) == null ? void 0 : _a2.expandedContent;
|
|
348
397
|
})) == null ? void 0 : _a.columnDef.meta) == null ? void 0 : _b.expandedContent) == null ? void 0 : _c.call(_b, row.original) }) });
|
|
349
398
|
}
|
|
399
|
+
var SETTINGS_COLUMN_WIDTH = 44;
|
|
400
|
+
function getSettingsPlacement(table, enabled) {
|
|
401
|
+
if (!enabled) return { append: false };
|
|
402
|
+
if (!table.getAllLeafColumns().some((column) => column.getCanHide())) {
|
|
403
|
+
return { append: false };
|
|
404
|
+
}
|
|
405
|
+
const leafColumns = table.getVisibleLeafColumns();
|
|
406
|
+
const lastColumn = leafColumns[leafColumns.length - 1];
|
|
407
|
+
if (lastColumn && lastColumn.accessorFn == null) {
|
|
408
|
+
return { reuseColumnId: lastColumn.id, append: false };
|
|
409
|
+
}
|
|
410
|
+
return { append: true };
|
|
411
|
+
}
|
|
350
412
|
function DataGridTable() {
|
|
351
413
|
const {
|
|
352
414
|
table,
|
|
415
|
+
styles,
|
|
353
416
|
columnsResizable,
|
|
354
417
|
columnsPinnable,
|
|
355
418
|
stripped,
|
|
@@ -357,38 +420,98 @@ function DataGridTable() {
|
|
|
357
420
|
cellBorder,
|
|
358
421
|
loadingMode,
|
|
359
422
|
isLoading,
|
|
360
|
-
pageSize
|
|
423
|
+
pageSize,
|
|
424
|
+
columnVisibilityToggle
|
|
361
425
|
} = useDataGridContext();
|
|
426
|
+
const { reuseColumnId, append: showColumnSettings } = getSettingsPlacement(
|
|
427
|
+
table,
|
|
428
|
+
columnVisibilityToggle
|
|
429
|
+
);
|
|
430
|
+
const headerGroups = table.getHeaderGroups();
|
|
431
|
+
const settingsCellStyle = {
|
|
432
|
+
"--size": `${SETTINGS_COLUMN_WIDTH}px`
|
|
433
|
+
};
|
|
362
434
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(DataGridTableBase, { children: [
|
|
363
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(DataGridTableHead, { children:
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
435
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(DataGridTableHead, { children: headerGroups.map((headerGroup, groupIndex) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(DataGridTableHeadRow, { headerGroup, children: [
|
|
436
|
+
headerGroup.headers.map((header) => {
|
|
437
|
+
const { column } = header;
|
|
438
|
+
const isReuseColumn = reuseColumnId != null && column.id === reuseColumnId;
|
|
439
|
+
const reuseToggleHere = isReuseColumn && groupIndex === headerGroups.length - 1;
|
|
440
|
+
const headerContent = header.isPlaceholder ? null : (0, import_react_table.flexRender)(
|
|
367
441
|
header.column.columnDef.header,
|
|
368
442
|
header.getContext()
|
|
369
|
-
)
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
443
|
+
);
|
|
444
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
445
|
+
DataGridTableHeadRowCell,
|
|
446
|
+
{
|
|
447
|
+
header,
|
|
448
|
+
stickyRight: isReuseColumn,
|
|
449
|
+
children: [
|
|
450
|
+
reuseToggleHere ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "flex w-full items-center justify-center gap-1.5", children: [
|
|
451
|
+
headerContent,
|
|
452
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(DataGridHeaderColumnToggle, {})
|
|
453
|
+
] }) : headerContent,
|
|
454
|
+
columnsResizable && column.getCanResize() && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DataGridTableHeadRowCellResize, { header })
|
|
455
|
+
]
|
|
456
|
+
},
|
|
457
|
+
column.id
|
|
458
|
+
);
|
|
459
|
+
}),
|
|
460
|
+
showColumnSettings && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
461
|
+
"th",
|
|
462
|
+
{
|
|
463
|
+
className: (0, import_shared_utils.cn)(styles.headerRowCell(), STICKY_RIGHT_CELL),
|
|
464
|
+
style: { ...settingsCellStyle, ...stickyRightStyle(30) },
|
|
465
|
+
children: groupIndex === headerGroups.length - 1 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "flex justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DataGridHeaderColumnToggle, {}) })
|
|
466
|
+
}
|
|
467
|
+
)
|
|
468
|
+
] }, headerGroup.id)) }),
|
|
373
469
|
(stripped || !rowBorder) && !cellBorder && !columnsPinnable && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DataGridTableRowSpacer, {}),
|
|
374
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(DataGridTableBody, { children: loadingMode === "skeleton" && isLoading && pageSize ? Array.from({ length: pageSize }).map((_, rowIndex) => /* @__PURE__ */ (0, import_jsx_runtime.
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
470
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(DataGridTableBody, { children: loadingMode === "skeleton" && isLoading && pageSize ? Array.from({ length: pageSize }).map((_, rowIndex) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(DataGridTableBodyRowSkeleton, { children: [
|
|
471
|
+
table.getVisibleFlatColumns().map((column, colIndex) => {
|
|
472
|
+
var _a;
|
|
473
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
474
|
+
DataGridTableBodyRowSkeletonCell,
|
|
475
|
+
{
|
|
476
|
+
column,
|
|
477
|
+
stickyRight: reuseColumnId != null && column.id === reuseColumnId,
|
|
478
|
+
children: (_a = column.columnDef.meta) == null ? void 0 : _a.skeleton
|
|
479
|
+
},
|
|
480
|
+
colIndex.toString()
|
|
481
|
+
);
|
|
482
|
+
}),
|
|
483
|
+
showColumnSettings && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
484
|
+
"td",
|
|
378
485
|
{
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
}) }, rowIndex.toString())) : table.getRowModel().rows.length ? table.getRowModel().rows.map((row) => {
|
|
486
|
+
className: (0, import_shared_utils.cn)(styles.bodyRowCell(), STICKY_RIGHT_CELL),
|
|
487
|
+
style: { ...settingsCellStyle, ...stickyRightStyle(10) }
|
|
488
|
+
}
|
|
489
|
+
)
|
|
490
|
+
] }, rowIndex.toString())) : table.getRowModel().rows.length ? table.getRowModel().rows.map((row) => {
|
|
385
491
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react.Fragment, { children: [
|
|
386
|
-
/* @__PURE__ */ (0, import_jsx_runtime.
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
492
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(DataGridTableBodyRow, { row, children: [
|
|
493
|
+
row.getVisibleCells().map((cell) => {
|
|
494
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
495
|
+
DataGridTableBodyRowCell,
|
|
496
|
+
{
|
|
497
|
+
cell,
|
|
498
|
+
stickyRight: reuseColumnId != null && cell.column.id === reuseColumnId,
|
|
499
|
+
children: (0, import_react_table.flexRender)(
|
|
500
|
+
cell.column.columnDef.cell,
|
|
501
|
+
cell.getContext()
|
|
502
|
+
)
|
|
503
|
+
},
|
|
504
|
+
cell.id
|
|
505
|
+
);
|
|
506
|
+
}),
|
|
507
|
+
showColumnSettings && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
508
|
+
"td",
|
|
509
|
+
{
|
|
510
|
+
className: (0, import_shared_utils.cn)(styles.bodyRowCell(), STICKY_RIGHT_CELL),
|
|
511
|
+
style: { ...settingsCellStyle, ...stickyRightStyle(10) }
|
|
512
|
+
}
|
|
513
|
+
)
|
|
514
|
+
] }, row.id),
|
|
392
515
|
row.getIsExpanded() && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DataGridTableBodyRowExpanded, { row })
|
|
393
516
|
] }, row.id);
|
|
394
517
|
}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DataGridTableEmpty, {}) })
|
|
@@ -404,6 +527,52 @@ function getPinningStyles(column) {
|
|
|
404
527
|
zIndex: isPinned ? 1 : 0
|
|
405
528
|
};
|
|
406
529
|
}
|
|
530
|
+
function DataGridColumnToggle({
|
|
531
|
+
label,
|
|
532
|
+
align = "end",
|
|
533
|
+
children
|
|
534
|
+
}) {
|
|
535
|
+
const { table } = useDataGridContext();
|
|
536
|
+
const t = (0, import_i18n2.useSafeIntl)();
|
|
537
|
+
const columns = table.getAllLeafColumns().filter((column) => column.getCanHide());
|
|
538
|
+
if (columns.length === 0) {
|
|
539
|
+
return null;
|
|
540
|
+
}
|
|
541
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_dropdown_menu.DropdownMenu.Root, { children: [
|
|
542
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dropdown_menu.DropdownMenu.Trigger, { asChild: true, children: children != null ? children : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_button.Button, { variant: "outline", size: "sm", children: [
|
|
543
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.TableHeaderColumnIcon, { className: "size-4" }),
|
|
544
|
+
label != null ? label : t.formatMessage(dataGridMessages.columns)
|
|
545
|
+
] }) }),
|
|
546
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dropdown_menu.DropdownMenu.Content, { align, children: columns.map((column) => {
|
|
547
|
+
var _a, _b;
|
|
548
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
549
|
+
import_dropdown_menu.DropdownMenu.CheckboxItem,
|
|
550
|
+
{
|
|
551
|
+
checked: column.getIsVisible(),
|
|
552
|
+
onCheckedChange: (value) => column.toggleVisibility(!!value),
|
|
553
|
+
onSelect: (event) => event.preventDefault(),
|
|
554
|
+
children: (_b = (_a = column.columnDef.meta) == null ? void 0 : _a.headerTitle) != null ? _b : column.id
|
|
555
|
+
},
|
|
556
|
+
column.id
|
|
557
|
+
);
|
|
558
|
+
}) })
|
|
559
|
+
] });
|
|
560
|
+
}
|
|
561
|
+
function DataGridHeaderColumnToggle() {
|
|
562
|
+
const t = (0, import_i18n2.useSafeIntl)();
|
|
563
|
+
const label = t.formatMessage(dataGridMessages.columns);
|
|
564
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DataGridColumnToggle, { align: "end", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
565
|
+
import_button.IconButton,
|
|
566
|
+
{
|
|
567
|
+
"aria-label": label,
|
|
568
|
+
tooltip: label,
|
|
569
|
+
variant: "ghost",
|
|
570
|
+
size: "sm",
|
|
571
|
+
className: "shrink-0",
|
|
572
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.TableHeaderColumnIcon, {})
|
|
573
|
+
}
|
|
574
|
+
) });
|
|
575
|
+
}
|
|
407
576
|
function DataGridTableRowSelectAll({
|
|
408
577
|
size
|
|
409
578
|
}) {
|
|
@@ -450,8 +619,10 @@ function DataGridTableRowSelect({
|
|
|
450
619
|
// Annotate the CommonJS export names for ESM import in node:
|
|
451
620
|
0 && (module.exports = {
|
|
452
621
|
DataGrid,
|
|
622
|
+
DataGridColumnToggle,
|
|
453
623
|
DataGridContainer,
|
|
454
624
|
DataGridTable,
|
|
455
625
|
DataGridTableRowSelect,
|
|
456
|
-
DataGridTableRowSelectAll
|
|
626
|
+
DataGridTableRowSelectAll,
|
|
627
|
+
SETTINGS_COLUMN_WIDTH
|
|
457
628
|
});
|
package/dist/data-grid.mjs
CHANGED
|
@@ -2,15 +2,20 @@
|
|
|
2
2
|
"use client";
|
|
3
3
|
import {
|
|
4
4
|
DataGrid,
|
|
5
|
+
DataGridColumnToggle,
|
|
5
6
|
DataGridContainer,
|
|
6
7
|
DataGridTable,
|
|
7
8
|
DataGridTableRowSelect,
|
|
8
|
-
DataGridTableRowSelectAll
|
|
9
|
-
|
|
9
|
+
DataGridTableRowSelectAll,
|
|
10
|
+
SETTINGS_COLUMN_WIDTH
|
|
11
|
+
} from "./chunk-EVXFPN6F.mjs";
|
|
12
|
+
import "./chunk-M6DRKGKE.mjs";
|
|
10
13
|
export {
|
|
11
14
|
DataGrid,
|
|
15
|
+
DataGridColumnToggle,
|
|
12
16
|
DataGridContainer,
|
|
13
17
|
DataGridTable,
|
|
14
18
|
DataGridTableRowSelect,
|
|
15
|
-
DataGridTableRowSelectAll
|
|
19
|
+
DataGridTableRowSelectAll,
|
|
20
|
+
SETTINGS_COLUMN_WIDTH
|
|
16
21
|
};
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DataGrid as DataGrid$1, DataGridContainer, DataGridTable, DataGridTableRowSelectAll, DataGridTableRowSelect } from './data-grid.mjs';
|
|
2
|
-
export { DataGridProps } from './data-grid.mjs';
|
|
1
|
+
import { DataGrid as DataGrid$1, DataGridContainer, DataGridTable, DataGridTableRowSelectAll, DataGridTableRowSelect, DataGridColumnToggle } from './data-grid.mjs';
|
|
2
|
+
export { DataGridColumnToggleProps, DataGridProps } from './data-grid.mjs';
|
|
3
3
|
import 'react/jsx-runtime';
|
|
4
4
|
import '@kopexa/theme';
|
|
5
5
|
import '@tanstack/react-table';
|
|
@@ -10,6 +10,7 @@ declare const DataGrid: typeof DataGrid$1 & {
|
|
|
10
10
|
Table: typeof DataGridTable;
|
|
11
11
|
SelectAll: typeof DataGridTableRowSelectAll;
|
|
12
12
|
RowSelect: typeof DataGridTableRowSelect;
|
|
13
|
+
ColumnToggle: typeof DataGridColumnToggle;
|
|
13
14
|
};
|
|
14
15
|
|
|
15
16
|
export { DataGrid };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DataGrid as DataGrid$1, DataGridContainer, DataGridTable, DataGridTableRowSelectAll, DataGridTableRowSelect } from './data-grid.js';
|
|
2
|
-
export { DataGridProps } from './data-grid.js';
|
|
1
|
+
import { DataGrid as DataGrid$1, DataGridContainer, DataGridTable, DataGridTableRowSelectAll, DataGridTableRowSelect, DataGridColumnToggle } from './data-grid.js';
|
|
2
|
+
export { DataGridColumnToggleProps, DataGridProps } from './data-grid.js';
|
|
3
3
|
import 'react/jsx-runtime';
|
|
4
4
|
import '@kopexa/theme';
|
|
5
5
|
import '@tanstack/react-table';
|
|
@@ -10,6 +10,7 @@ declare const DataGrid: typeof DataGrid$1 & {
|
|
|
10
10
|
Table: typeof DataGridTable;
|
|
11
11
|
SelectAll: typeof DataGridTableRowSelectAll;
|
|
12
12
|
RowSelect: typeof DataGridTableRowSelect;
|
|
13
|
+
ColumnToggle: typeof DataGridColumnToggle;
|
|
13
14
|
};
|
|
14
15
|
|
|
15
16
|
export { DataGrid };
|