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