@kopexa/data-grid 18.1.0 → 18.2.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-M6DRKGKE.mjs +15 -0
- package/dist/{chunk-KSAE2MI5.mjs → chunk-YJSXJPR4.mjs} +46 -2
- 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 +17 -1
- package/dist/data-grid.d.ts +17 -1
- package/dist/data-grid.js +56 -2
- package/dist/data-grid.mjs +4 -1
- package/dist/index.d.mts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +56 -3
- package/dist/index.mjs +5 -2
- package/package.json +10 -5
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/data-grid-messages.ts
|
|
4
|
+
import { defineMessages } from "@kopexa/i18n";
|
|
5
|
+
var dataGridMessages = defineMessages({
|
|
6
|
+
columns: {
|
|
7
|
+
id: "data-grid.columns",
|
|
8
|
+
defaultMessage: "Columns",
|
|
9
|
+
description: "Label for the column visibility toggle button"
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export {
|
|
14
|
+
dataGridMessages
|
|
15
|
+
};
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import {
|
|
3
|
+
dataGridMessages
|
|
4
|
+
} from "./chunk-M6DRKGKE.mjs";
|
|
2
5
|
|
|
3
6
|
// src/data-grid.tsx
|
|
7
|
+
import { Button } from "@kopexa/button";
|
|
4
8
|
import { Checkbox } from "@kopexa/checkbox";
|
|
9
|
+
import { DropdownMenu } from "@kopexa/dropdown-menu";
|
|
10
|
+
import { useSafeIntl } from "@kopexa/i18n";
|
|
11
|
+
import { TableHeaderColumnIcon } from "@kopexa/icons";
|
|
5
12
|
import { createContext } from "@kopexa/react-utils";
|
|
6
13
|
import { cn } from "@kopexa/shared-utils";
|
|
7
14
|
import { datagrid } from "@kopexa/theme";
|
|
@@ -80,6 +87,7 @@ function DataGrid(props) {
|
|
|
80
87
|
rowBorder,
|
|
81
88
|
cellBorder,
|
|
82
89
|
loadingMode,
|
|
90
|
+
width,
|
|
83
91
|
emptyMessage,
|
|
84
92
|
isLoading,
|
|
85
93
|
pageSize,
|
|
@@ -95,6 +103,7 @@ function DataGrid(props) {
|
|
|
95
103
|
rowBorder,
|
|
96
104
|
cellBorder,
|
|
97
105
|
loadingMode,
|
|
106
|
+
width,
|
|
98
107
|
emptyMessage,
|
|
99
108
|
isLoading,
|
|
100
109
|
pageSize,
|
|
@@ -141,14 +150,17 @@ function DataGridTableHeadRow({
|
|
|
141
150
|
function DataGridTableBase({
|
|
142
151
|
children,
|
|
143
152
|
className,
|
|
153
|
+
style,
|
|
144
154
|
...restProps
|
|
145
155
|
}) {
|
|
146
|
-
const { styles } = useDataGridContext();
|
|
156
|
+
const { styles, table, width } = useDataGridContext();
|
|
157
|
+
const minWidth = width === "fixed" ? table.getVisibleLeafColumns().reduce((acc, column) => acc + column.getSize(), 0) : void 0;
|
|
147
158
|
return /* @__PURE__ */ jsx(
|
|
148
159
|
"table",
|
|
149
160
|
{
|
|
150
161
|
"data-slot": "data-grid-table",
|
|
151
162
|
className: styles.table({ className }),
|
|
163
|
+
style: minWidth ? { minWidth, ...style } : style,
|
|
152
164
|
...restProps,
|
|
153
165
|
children
|
|
154
166
|
}
|
|
@@ -215,7 +227,7 @@ function DataGridTableBody({
|
|
|
215
227
|
}
|
|
216
228
|
function DataGridTableEmpty() {
|
|
217
229
|
const { styles, table, emptyMessage } = useDataGridContext();
|
|
218
|
-
const totalColumns = table.
|
|
230
|
+
const totalColumns = table.getVisibleLeafColumns().length;
|
|
219
231
|
return /* @__PURE__ */ jsx("tr", { children: /* @__PURE__ */ jsx("td", { colSpan: totalColumns, className: styles.empty(), children: emptyMessage || "No data available." }) });
|
|
220
232
|
}
|
|
221
233
|
function DataGridTableBodyRowSkeleton({ children }) {
|
|
@@ -381,6 +393,37 @@ function getPinningStyles(column) {
|
|
|
381
393
|
zIndex: isPinned ? 1 : 0
|
|
382
394
|
};
|
|
383
395
|
}
|
|
396
|
+
function DataGridColumnToggle({
|
|
397
|
+
label,
|
|
398
|
+
align = "end",
|
|
399
|
+
children
|
|
400
|
+
}) {
|
|
401
|
+
const { table } = useDataGridContext();
|
|
402
|
+
const t = useSafeIntl();
|
|
403
|
+
const columns = table.getAllLeafColumns().filter((column) => column.getCanHide());
|
|
404
|
+
if (columns.length === 0) {
|
|
405
|
+
return null;
|
|
406
|
+
}
|
|
407
|
+
return /* @__PURE__ */ jsxs(DropdownMenu.Root, { children: [
|
|
408
|
+
/* @__PURE__ */ jsx(DropdownMenu.Trigger, { asChild: true, children: children != null ? children : /* @__PURE__ */ jsxs(Button, { variant: "outline", size: "sm", children: [
|
|
409
|
+
/* @__PURE__ */ jsx(TableHeaderColumnIcon, { className: "size-4" }),
|
|
410
|
+
label != null ? label : t.formatMessage(dataGridMessages.columns)
|
|
411
|
+
] }) }),
|
|
412
|
+
/* @__PURE__ */ jsx(DropdownMenu.Content, { align, children: columns.map((column) => {
|
|
413
|
+
var _a, _b;
|
|
414
|
+
return /* @__PURE__ */ jsx(
|
|
415
|
+
DropdownMenu.CheckboxItem,
|
|
416
|
+
{
|
|
417
|
+
checked: column.getIsVisible(),
|
|
418
|
+
onCheckedChange: (value) => column.toggleVisibility(!!value),
|
|
419
|
+
onSelect: (event) => event.preventDefault(),
|
|
420
|
+
children: (_b = (_a = column.columnDef.meta) == null ? void 0 : _a.headerTitle) != null ? _b : column.id
|
|
421
|
+
},
|
|
422
|
+
column.id
|
|
423
|
+
);
|
|
424
|
+
}) })
|
|
425
|
+
] });
|
|
426
|
+
}
|
|
384
427
|
function DataGridTableRowSelectAll({
|
|
385
428
|
size
|
|
386
429
|
}) {
|
|
@@ -429,6 +472,7 @@ export {
|
|
|
429
472
|
DataGrid,
|
|
430
473
|
DataGridContainer,
|
|
431
474
|
DataGridTable,
|
|
475
|
+
DataGridColumnToggle,
|
|
432
476
|
DataGridTableRowSelectAll,
|
|
433
477
|
DataGridTableRowSelect
|
|
434
478
|
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/data-grid-messages.ts
|
|
22
|
+
var data_grid_messages_exports = {};
|
|
23
|
+
__export(data_grid_messages_exports, {
|
|
24
|
+
dataGridMessages: () => dataGridMessages
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(data_grid_messages_exports);
|
|
27
|
+
var import_i18n = require("@kopexa/i18n");
|
|
28
|
+
var dataGridMessages = (0, import_i18n.defineMessages)({
|
|
29
|
+
columns: {
|
|
30
|
+
id: "data-grid.columns",
|
|
31
|
+
defaultMessage: "Columns",
|
|
32
|
+
description: "Label for the column visibility toggle button"
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
36
|
+
0 && (module.exports = {
|
|
37
|
+
dataGridMessages
|
|
38
|
+
});
|
package/dist/data-grid.d.mts
CHANGED
|
@@ -29,6 +29,22 @@ declare function DataGridContainer({ children, className, }: {
|
|
|
29
29
|
border?: boolean;
|
|
30
30
|
}): react_jsx_runtime.JSX.Element;
|
|
31
31
|
declare function DataGridTable<TData>(): react_jsx_runtime.JSX.Element;
|
|
32
|
+
type DataGridColumnToggleProps = {
|
|
33
|
+
/**
|
|
34
|
+
* Trigger button label. Defaults to the translated "Columns" message;
|
|
35
|
+
* ignored when `children` is provided.
|
|
36
|
+
*/
|
|
37
|
+
label?: string;
|
|
38
|
+
align?: "start" | "center" | "end";
|
|
39
|
+
/** Custom trigger; replaces the default button. */
|
|
40
|
+
children?: ReactNode;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Dropdown that toggles column visibility. Lists every hideable leaf column
|
|
44
|
+
* (`enableHiding !== false`) and reflects/sets `columnVisibility` on the table.
|
|
45
|
+
* Column labels come from `meta.headerTitle`, falling back to the column id.
|
|
46
|
+
*/
|
|
47
|
+
declare function DataGridColumnToggle({ label, align, children, }: DataGridColumnToggleProps): react_jsx_runtime.JSX.Element | null;
|
|
32
48
|
declare function DataGridTableRowSelectAll({ size, }: {
|
|
33
49
|
size?: "sm" | "md" | "lg";
|
|
34
50
|
}): react_jsx_runtime.JSX.Element;
|
|
@@ -37,4 +53,4 @@ declare function DataGridTableRowSelect<TData>({ row, size, }: {
|
|
|
37
53
|
size?: "sm" | "md" | "lg";
|
|
38
54
|
}): react_jsx_runtime.JSX.Element;
|
|
39
55
|
|
|
40
|
-
export { DataGrid, DataGridContainer, type DataGridProps, DataGridTable, DataGridTableRowSelect, DataGridTableRowSelectAll };
|
|
56
|
+
export { DataGrid, DataGridColumnToggle, type DataGridColumnToggleProps, DataGridContainer, type DataGridProps, DataGridTable, DataGridTableRowSelect, DataGridTableRowSelectAll };
|
package/dist/data-grid.d.ts
CHANGED
|
@@ -29,6 +29,22 @@ declare function DataGridContainer({ children, className, }: {
|
|
|
29
29
|
border?: boolean;
|
|
30
30
|
}): react_jsx_runtime.JSX.Element;
|
|
31
31
|
declare function DataGridTable<TData>(): react_jsx_runtime.JSX.Element;
|
|
32
|
+
type DataGridColumnToggleProps = {
|
|
33
|
+
/**
|
|
34
|
+
* Trigger button label. Defaults to the translated "Columns" message;
|
|
35
|
+
* ignored when `children` is provided.
|
|
36
|
+
*/
|
|
37
|
+
label?: string;
|
|
38
|
+
align?: "start" | "center" | "end";
|
|
39
|
+
/** Custom trigger; replaces the default button. */
|
|
40
|
+
children?: ReactNode;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Dropdown that toggles column visibility. Lists every hideable leaf column
|
|
44
|
+
* (`enableHiding !== false`) and reflects/sets `columnVisibility` on the table.
|
|
45
|
+
* Column labels come from `meta.headerTitle`, falling back to the column id.
|
|
46
|
+
*/
|
|
47
|
+
declare function DataGridColumnToggle({ label, align, children, }: DataGridColumnToggleProps): react_jsx_runtime.JSX.Element | null;
|
|
32
48
|
declare function DataGridTableRowSelectAll({ size, }: {
|
|
33
49
|
size?: "sm" | "md" | "lg";
|
|
34
50
|
}): react_jsx_runtime.JSX.Element;
|
|
@@ -37,4 +53,4 @@ declare function DataGridTableRowSelect<TData>({ row, size, }: {
|
|
|
37
53
|
size?: "sm" | "md" | "lg";
|
|
38
54
|
}): react_jsx_runtime.JSX.Element;
|
|
39
55
|
|
|
40
|
-
export { DataGrid, DataGridContainer, type DataGridProps, DataGridTable, DataGridTableRowSelect, DataGridTableRowSelectAll };
|
|
56
|
+
export { DataGrid, DataGridColumnToggle, type DataGridColumnToggleProps, DataGridContainer, type DataGridProps, DataGridTable, DataGridTableRowSelect, DataGridTableRowSelectAll };
|
package/dist/data-grid.js
CHANGED
|
@@ -23,18 +23,35 @@ 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
30
|
DataGridTableRowSelectAll: () => DataGridTableRowSelectAll
|
|
30
31
|
});
|
|
31
32
|
module.exports = __toCommonJS(data_grid_exports);
|
|
33
|
+
var import_button = require("@kopexa/button");
|
|
32
34
|
var import_checkbox = require("@kopexa/checkbox");
|
|
35
|
+
var import_dropdown_menu = require("@kopexa/dropdown-menu");
|
|
36
|
+
var import_i18n2 = require("@kopexa/i18n");
|
|
37
|
+
var import_icons = require("@kopexa/icons");
|
|
33
38
|
var import_react_utils = require("@kopexa/react-utils");
|
|
34
39
|
var import_shared_utils = require("@kopexa/shared-utils");
|
|
35
40
|
var import_theme = require("@kopexa/theme");
|
|
36
41
|
var import_react_table = require("@tanstack/react-table");
|
|
37
42
|
var import_react = require("react");
|
|
43
|
+
|
|
44
|
+
// src/data-grid-messages.ts
|
|
45
|
+
var import_i18n = require("@kopexa/i18n");
|
|
46
|
+
var dataGridMessages = (0, import_i18n.defineMessages)({
|
|
47
|
+
columns: {
|
|
48
|
+
id: "data-grid.columns",
|
|
49
|
+
defaultMessage: "Columns",
|
|
50
|
+
description: "Label for the column visibility toggle button"
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
// src/data-grid.tsx
|
|
38
55
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
39
56
|
var [DataGridProvider, useDataGridContext] = (
|
|
40
57
|
// biome-ignore lint/suspicious/noExplicitAny: no idea.
|
|
@@ -103,6 +120,7 @@ function DataGrid(props) {
|
|
|
103
120
|
rowBorder,
|
|
104
121
|
cellBorder,
|
|
105
122
|
loadingMode,
|
|
123
|
+
width,
|
|
106
124
|
emptyMessage,
|
|
107
125
|
isLoading,
|
|
108
126
|
pageSize,
|
|
@@ -118,6 +136,7 @@ function DataGrid(props) {
|
|
|
118
136
|
rowBorder,
|
|
119
137
|
cellBorder,
|
|
120
138
|
loadingMode,
|
|
139
|
+
width,
|
|
121
140
|
emptyMessage,
|
|
122
141
|
isLoading,
|
|
123
142
|
pageSize,
|
|
@@ -164,14 +183,17 @@ function DataGridTableHeadRow({
|
|
|
164
183
|
function DataGridTableBase({
|
|
165
184
|
children,
|
|
166
185
|
className,
|
|
186
|
+
style,
|
|
167
187
|
...restProps
|
|
168
188
|
}) {
|
|
169
|
-
const { styles } = useDataGridContext();
|
|
189
|
+
const { styles, table, width } = useDataGridContext();
|
|
190
|
+
const minWidth = width === "fixed" ? table.getVisibleLeafColumns().reduce((acc, column) => acc + column.getSize(), 0) : void 0;
|
|
170
191
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
171
192
|
"table",
|
|
172
193
|
{
|
|
173
194
|
"data-slot": "data-grid-table",
|
|
174
195
|
className: styles.table({ className }),
|
|
196
|
+
style: minWidth ? { minWidth, ...style } : style,
|
|
175
197
|
...restProps,
|
|
176
198
|
children
|
|
177
199
|
}
|
|
@@ -238,7 +260,7 @@ function DataGridTableBody({
|
|
|
238
260
|
}
|
|
239
261
|
function DataGridTableEmpty() {
|
|
240
262
|
const { styles, table, emptyMessage } = useDataGridContext();
|
|
241
|
-
const totalColumns = table.
|
|
263
|
+
const totalColumns = table.getVisibleLeafColumns().length;
|
|
242
264
|
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
265
|
}
|
|
244
266
|
function DataGridTableBodyRowSkeleton({ children }) {
|
|
@@ -404,6 +426,37 @@ function getPinningStyles(column) {
|
|
|
404
426
|
zIndex: isPinned ? 1 : 0
|
|
405
427
|
};
|
|
406
428
|
}
|
|
429
|
+
function DataGridColumnToggle({
|
|
430
|
+
label,
|
|
431
|
+
align = "end",
|
|
432
|
+
children
|
|
433
|
+
}) {
|
|
434
|
+
const { table } = useDataGridContext();
|
|
435
|
+
const t = (0, import_i18n2.useSafeIntl)();
|
|
436
|
+
const columns = table.getAllLeafColumns().filter((column) => column.getCanHide());
|
|
437
|
+
if (columns.length === 0) {
|
|
438
|
+
return null;
|
|
439
|
+
}
|
|
440
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_dropdown_menu.DropdownMenu.Root, { children: [
|
|
441
|
+
/* @__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: [
|
|
442
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.TableHeaderColumnIcon, { className: "size-4" }),
|
|
443
|
+
label != null ? label : t.formatMessage(dataGridMessages.columns)
|
|
444
|
+
] }) }),
|
|
445
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dropdown_menu.DropdownMenu.Content, { align, children: columns.map((column) => {
|
|
446
|
+
var _a, _b;
|
|
447
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
448
|
+
import_dropdown_menu.DropdownMenu.CheckboxItem,
|
|
449
|
+
{
|
|
450
|
+
checked: column.getIsVisible(),
|
|
451
|
+
onCheckedChange: (value) => column.toggleVisibility(!!value),
|
|
452
|
+
onSelect: (event) => event.preventDefault(),
|
|
453
|
+
children: (_b = (_a = column.columnDef.meta) == null ? void 0 : _a.headerTitle) != null ? _b : column.id
|
|
454
|
+
},
|
|
455
|
+
column.id
|
|
456
|
+
);
|
|
457
|
+
}) })
|
|
458
|
+
] });
|
|
459
|
+
}
|
|
407
460
|
function DataGridTableRowSelectAll({
|
|
408
461
|
size
|
|
409
462
|
}) {
|
|
@@ -450,6 +503,7 @@ function DataGridTableRowSelect({
|
|
|
450
503
|
// Annotate the CommonJS export names for ESM import in node:
|
|
451
504
|
0 && (module.exports = {
|
|
452
505
|
DataGrid,
|
|
506
|
+
DataGridColumnToggle,
|
|
453
507
|
DataGridContainer,
|
|
454
508
|
DataGridTable,
|
|
455
509
|
DataGridTableRowSelect,
|
package/dist/data-grid.mjs
CHANGED
|
@@ -2,13 +2,16 @@
|
|
|
2
2
|
"use client";
|
|
3
3
|
import {
|
|
4
4
|
DataGrid,
|
|
5
|
+
DataGridColumnToggle,
|
|
5
6
|
DataGridContainer,
|
|
6
7
|
DataGridTable,
|
|
7
8
|
DataGridTableRowSelect,
|
|
8
9
|
DataGridTableRowSelectAll
|
|
9
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-YJSXJPR4.mjs";
|
|
11
|
+
import "./chunk-M6DRKGKE.mjs";
|
|
10
12
|
export {
|
|
11
13
|
DataGrid,
|
|
14
|
+
DataGridColumnToggle,
|
|
12
15
|
DataGridContainer,
|
|
13
16
|
DataGridTable,
|
|
14
17
|
DataGridTableRowSelect,
|
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 };
|
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.
|
|
@@ -100,6 +116,7 @@ function DataGrid(props) {
|
|
|
100
116
|
rowBorder,
|
|
101
117
|
cellBorder,
|
|
102
118
|
loadingMode,
|
|
119
|
+
width,
|
|
103
120
|
emptyMessage,
|
|
104
121
|
isLoading,
|
|
105
122
|
pageSize,
|
|
@@ -115,6 +132,7 @@ function DataGrid(props) {
|
|
|
115
132
|
rowBorder,
|
|
116
133
|
cellBorder,
|
|
117
134
|
loadingMode,
|
|
135
|
+
width,
|
|
118
136
|
emptyMessage,
|
|
119
137
|
isLoading,
|
|
120
138
|
pageSize,
|
|
@@ -161,14 +179,17 @@ function DataGridTableHeadRow({
|
|
|
161
179
|
function DataGridTableBase({
|
|
162
180
|
children,
|
|
163
181
|
className,
|
|
182
|
+
style,
|
|
164
183
|
...restProps
|
|
165
184
|
}) {
|
|
166
|
-
const { styles } = useDataGridContext();
|
|
185
|
+
const { styles, table, width } = useDataGridContext();
|
|
186
|
+
const minWidth = width === "fixed" ? table.getVisibleLeafColumns().reduce((acc, column) => acc + column.getSize(), 0) : void 0;
|
|
167
187
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
168
188
|
"table",
|
|
169
189
|
{
|
|
170
190
|
"data-slot": "data-grid-table",
|
|
171
191
|
className: styles.table({ className }),
|
|
192
|
+
style: minWidth ? { minWidth, ...style } : style,
|
|
172
193
|
...restProps,
|
|
173
194
|
children
|
|
174
195
|
}
|
|
@@ -235,7 +256,7 @@ function DataGridTableBody({
|
|
|
235
256
|
}
|
|
236
257
|
function DataGridTableEmpty() {
|
|
237
258
|
const { styles, table, emptyMessage } = useDataGridContext();
|
|
238
|
-
const totalColumns = table.
|
|
259
|
+
const totalColumns = table.getVisibleLeafColumns().length;
|
|
239
260
|
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
261
|
}
|
|
241
262
|
function DataGridTableBodyRowSkeleton({ children }) {
|
|
@@ -401,6 +422,37 @@ function getPinningStyles(column) {
|
|
|
401
422
|
zIndex: isPinned ? 1 : 0
|
|
402
423
|
};
|
|
403
424
|
}
|
|
425
|
+
function DataGridColumnToggle({
|
|
426
|
+
label,
|
|
427
|
+
align = "end",
|
|
428
|
+
children
|
|
429
|
+
}) {
|
|
430
|
+
const { table } = useDataGridContext();
|
|
431
|
+
const t = (0, import_i18n2.useSafeIntl)();
|
|
432
|
+
const columns = table.getAllLeafColumns().filter((column) => column.getCanHide());
|
|
433
|
+
if (columns.length === 0) {
|
|
434
|
+
return null;
|
|
435
|
+
}
|
|
436
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_dropdown_menu.DropdownMenu.Root, { children: [
|
|
437
|
+
/* @__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: [
|
|
438
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.TableHeaderColumnIcon, { className: "size-4" }),
|
|
439
|
+
label != null ? label : t.formatMessage(dataGridMessages.columns)
|
|
440
|
+
] }) }),
|
|
441
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dropdown_menu.DropdownMenu.Content, { align, children: columns.map((column) => {
|
|
442
|
+
var _a, _b;
|
|
443
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
444
|
+
import_dropdown_menu.DropdownMenu.CheckboxItem,
|
|
445
|
+
{
|
|
446
|
+
checked: column.getIsVisible(),
|
|
447
|
+
onCheckedChange: (value) => column.toggleVisibility(!!value),
|
|
448
|
+
onSelect: (event) => event.preventDefault(),
|
|
449
|
+
children: (_b = (_a = column.columnDef.meta) == null ? void 0 : _a.headerTitle) != null ? _b : column.id
|
|
450
|
+
},
|
|
451
|
+
column.id
|
|
452
|
+
);
|
|
453
|
+
}) })
|
|
454
|
+
] });
|
|
455
|
+
}
|
|
404
456
|
function DataGridTableRowSelectAll({
|
|
405
457
|
size
|
|
406
458
|
}) {
|
|
@@ -450,7 +502,8 @@ var DataGrid2 = Object.assign(DataGrid, {
|
|
|
450
502
|
Container: DataGridContainer,
|
|
451
503
|
Table: DataGridTable,
|
|
452
504
|
SelectAll: DataGridTableRowSelectAll,
|
|
453
|
-
RowSelect: DataGridTableRowSelect
|
|
505
|
+
RowSelect: DataGridTableRowSelect,
|
|
506
|
+
ColumnToggle: DataGridColumnToggle
|
|
454
507
|
});
|
|
455
508
|
// Annotate the CommonJS export names for ESM import in node:
|
|
456
509
|
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-YJSXJPR4.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.2.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.2.0"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@tanstack/react-table": "^8.21.3",
|
|
35
|
-
"@kopexa/react-utils": "18.
|
|
36
|
-
"@kopexa/checkbox": "18.
|
|
37
|
-
"@kopexa/
|
|
35
|
+
"@kopexa/react-utils": "18.2.0",
|
|
36
|
+
"@kopexa/checkbox": "18.2.0",
|
|
37
|
+
"@kopexa/icons": "18.2.0",
|
|
38
|
+
"@kopexa/button": "18.2.0",
|
|
39
|
+
"@kopexa/i18n": "18.2.0",
|
|
40
|
+
"@kopexa/shared-utils": "18.2.0",
|
|
41
|
+
"@kopexa/dropdown-menu": "18.2.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"
|