@cognite/aura 1.46426.0 → 1.46449.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/colors-deprecated.css +45 -15
- package/dist/components/ui/core/data-grid/data-grid-selection-state.d.ts +3 -2
- package/dist/components/ui/core/data-grid/data-grid-selection-state.js +4 -1
- package/dist/components/ui/core/data-grid/data-grid-selection-state.js.map +1 -1
- package/dist/components/ui/core/data-grid/data-grid-selection-toolbar.d.ts +11 -0
- package/dist/components/ui/core/data-grid/data-grid-selection-toolbar.js +128 -0
- package/dist/components/ui/core/data-grid/data-grid-selection-toolbar.js.map +1 -0
- package/dist/components/ui/core/data-grid/data-grid-selection.types.d.ts +24 -0
- package/dist/components/ui/core/data-grid/data-grid-selection.types.js +3 -0
- package/dist/components/ui/core/data-grid/data-grid-selection.types.js.map +1 -0
- package/dist/components/ui/core/data-grid/data-grid.d.ts +3 -1
- package/dist/components/ui/core/data-grid/data-grid.js +121 -109
- package/dist/components/ui/core/data-grid/data-grid.js.map +1 -1
- package/dist/components/ui/core/data-grid/index.d.ts +1 -0
- package/dist/components/ui/core/data-grid/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
|
@@ -18,12 +18,20 @@
|
|
|
18
18
|
--color-foreground: var(--foreground);
|
|
19
19
|
--color-foreground-fixed-dark: var(--foreground-fixed-dark);
|
|
20
20
|
--color-foreground-fixed-light: var(--foreground-fixed-light);
|
|
21
|
-
--color-foreground-secondary-fixed-dark: var(
|
|
21
|
+
--color-foreground-secondary-fixed-dark: var(
|
|
22
|
+
--foreground-secondary-fixed-dark
|
|
23
|
+
);
|
|
22
24
|
--color-muted-foreground-fixed-light: var(--muted-foreground-fixed-light);
|
|
23
|
-
--color-primary-background-fixed-dark-hover: var(
|
|
25
|
+
--color-primary-background-fixed-dark-hover: var(
|
|
26
|
+
--primary-background-fixed-dark-hover
|
|
27
|
+
);
|
|
24
28
|
--color-ring: var(--ring);
|
|
25
|
-
--color-secondary-background-fixed-dark-hover: var(
|
|
26
|
-
|
|
29
|
+
--color-secondary-background-fixed-dark-hover: var(
|
|
30
|
+
--secondary-background-fixed-dark-hover
|
|
31
|
+
);
|
|
32
|
+
--color-secondary-foreground-fixed-light: var(
|
|
33
|
+
--secondary-foreground-fixed-light
|
|
34
|
+
);
|
|
27
35
|
/* Deprecated semantic/status tokens. Migrate to Reflect names (info-background, critical-*, etc.). Removed in 1.0.0. */
|
|
28
36
|
--color-accent-background: var(--accent-background);
|
|
29
37
|
--color-accent-background-fixed-dark: var(--accent-background-fixed-dark);
|
|
@@ -36,10 +44,14 @@
|
|
|
36
44
|
--color-destructive-background: var(--destructive-background);
|
|
37
45
|
--color-destructive-background-hover: var(--destructive-background-hover);
|
|
38
46
|
--color-destructive-foreground: var(--destructive-foreground);
|
|
39
|
-
--color-destructive-foreground-on-critical: var(
|
|
47
|
+
--color-destructive-foreground-on-critical: var(
|
|
48
|
+
--destructive-foreground-on-critical
|
|
49
|
+
);
|
|
40
50
|
--color-destructive-foreground-strong: var(--destructive-foreground-strong);
|
|
41
51
|
--color-destructive-muted-background: var(--destructive-muted-background);
|
|
42
|
-
--color-destructive-muted-background-hover: var(
|
|
52
|
+
--color-destructive-muted-background-hover: var(
|
|
53
|
+
--destructive-muted-background-hover
|
|
54
|
+
);
|
|
43
55
|
--color-disabled-background: var(--disabled-background);
|
|
44
56
|
--color-disabled-background-fixed-dark: var(--disabled-background-fixed-dark);
|
|
45
57
|
--color-disabled-foreground: var(--disabled-foreground);
|
|
@@ -59,19 +71,33 @@
|
|
|
59
71
|
--color-warning-muted-background: var(--warning-muted-background);
|
|
60
72
|
/* Deprecated named-ramp decorative tokens. Migrate to decorative-{1..7}-*. Removed in 1.0.0. */
|
|
61
73
|
--color-decorative-background-aurora: var(--decorative-background-aurora);
|
|
62
|
-
--color-decorative-background-aurora-hover: var(
|
|
74
|
+
--color-decorative-background-aurora-hover: var(
|
|
75
|
+
--decorative-background-aurora-hover
|
|
76
|
+
);
|
|
63
77
|
--color-decorative-background-dusk: var(--decorative-background-dusk);
|
|
64
|
-
--color-decorative-background-dusk-hover: var(
|
|
78
|
+
--color-decorative-background-dusk-hover: var(
|
|
79
|
+
--decorative-background-dusk-hover
|
|
80
|
+
);
|
|
65
81
|
--color-decorative-background-fjord: var(--decorative-background-fjord);
|
|
66
|
-
--color-decorative-background-fjord-hover: var(
|
|
82
|
+
--color-decorative-background-fjord-hover: var(
|
|
83
|
+
--decorative-background-fjord-hover
|
|
84
|
+
);
|
|
67
85
|
--color-decorative-background-mountain: var(--decorative-background-mountain);
|
|
68
|
-
--color-decorative-background-mountain-hover: var(
|
|
86
|
+
--color-decorative-background-mountain-hover: var(
|
|
87
|
+
--decorative-background-mountain-hover
|
|
88
|
+
);
|
|
69
89
|
--color-decorative-background-nordic: var(--decorative-background-nordic);
|
|
70
|
-
--color-decorative-background-nordic-hover: var(
|
|
90
|
+
--color-decorative-background-nordic-hover: var(
|
|
91
|
+
--decorative-background-nordic-hover
|
|
92
|
+
);
|
|
71
93
|
--color-decorative-background-orange: var(--decorative-background-orange);
|
|
72
|
-
--color-decorative-background-orange-hover: var(
|
|
94
|
+
--color-decorative-background-orange-hover: var(
|
|
95
|
+
--decorative-background-orange-hover
|
|
96
|
+
);
|
|
73
97
|
--color-decorative-background-sky: var(--decorative-background-sky);
|
|
74
|
-
--color-decorative-background-sky-hover: var(
|
|
98
|
+
--color-decorative-background-sky-hover: var(
|
|
99
|
+
--decorative-background-sky-hover
|
|
100
|
+
);
|
|
75
101
|
--color-decorative-foreground-aurora: var(--decorative-foreground-aurora);
|
|
76
102
|
--color-decorative-foreground-dusk: var(--decorative-foreground-dusk);
|
|
77
103
|
--color-decorative-foreground-fjord: var(--decorative-foreground-fjord);
|
|
@@ -306,9 +332,13 @@
|
|
|
306
332
|
--foreground-fixed-light: var(--popover-foreground-fixed-dark);
|
|
307
333
|
--foreground-secondary-fixed-dark: var(--mountain-700);
|
|
308
334
|
--muted-foreground-fixed-light: var(--medium-foreground-fixed-dark);
|
|
309
|
-
--primary-background-fixed-dark-hover: var(
|
|
335
|
+
--primary-background-fixed-dark-hover: var(
|
|
336
|
+
--primary-background-hover-fixed-dark
|
|
337
|
+
);
|
|
310
338
|
--ring: var(--ring-default);
|
|
311
|
-
--secondary-background-fixed-dark-hover: var(
|
|
339
|
+
--secondary-background-fixed-dark-hover: var(
|
|
340
|
+
--secondary-background-hover-fixed-dark
|
|
341
|
+
);
|
|
312
342
|
--secondary-foreground-fixed-light: var(--secondary-foreground-fixed-dark);
|
|
313
343
|
/* Deprecated semantic/status tokens → Reflect names */
|
|
314
344
|
--accent-background: var(--base-background-hover);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Row } from "@tanstack/react-table";
|
|
1
|
+
import type { Row, RowSelectionState } from "@tanstack/react-table";
|
|
2
2
|
type DataGridCheckboxState = boolean | "indeterminate";
|
|
3
3
|
type DataGridSelectionRow<TData> = Pick<Row<TData>, "getIsSelected" | "getIsSomeSelected" | "getIsAllSubRowsSelected"> & {
|
|
4
4
|
subRows: Pick<Row<TData>["subRows"], "length">;
|
|
@@ -11,4 +11,5 @@ type DataGridToggleableRow = {
|
|
|
11
11
|
subRows: readonly DataGridToggleableRow[];
|
|
12
12
|
};
|
|
13
13
|
declare function selectDataGridRowTree(row: DataGridToggleableRow): void;
|
|
14
|
-
|
|
14
|
+
declare function countSelectedRowIds(rowSelection: RowSelectionState): number;
|
|
15
|
+
export { countSelectedRowIds, getDataGridCheckboxState, isDataGridRowHighlighted, selectDataGridRowTree, type DataGridCheckboxState, type DataGridSelectionRow };
|
|
@@ -24,6 +24,9 @@ function selectDataGridRowTree(row) {
|
|
|
24
24
|
selectDataGridRowTree(subRow);
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
|
|
27
|
+
function countSelectedRowIds(rowSelection) {
|
|
28
|
+
return Object.values(rowSelection).filter(Boolean).length;
|
|
29
|
+
}
|
|
30
|
+
export { countSelectedRowIds, getDataGridCheckboxState, isDataGridRowHighlighted, selectDataGridRowTree };
|
|
28
31
|
|
|
29
32
|
//# sourceMappingURL=data-grid-selection-state.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/components/ui/core/data-grid/data-grid-selection-state.ts"],"sourcesContent":["import type { Row } from '@tanstack/react-table';\n\ntype DataGridCheckboxState = boolean | 'indeterminate';\n\n// This is the slice of `Row<TData>` that selection reads.\ntype DataGridSelectionRow<TData> = Pick<\n Row<TData>,\n 'getIsSelected' | 'getIsSomeSelected' | 'getIsAllSubRowsSelected'\n> & {\n subRows: Pick<Row<TData>['subRows'], 'length'>;\n};\n\nfunction getDataGridCheckboxState<TData>(\n row: DataGridSelectionRow<TData>\n): DataGridCheckboxState {\n if (row.subRows.length === 0) {\n return row.getIsSelected();\n }\n\n if (row.getIsAllSubRowsSelected()) {\n return true;\n }\n\n if (row.getIsSomeSelected()) {\n return 'indeterminate';\n }\n\n return false;\n}\n\nfunction isDataGridRowHighlighted<TData>(\n row: DataGridSelectionRow<TData>\n): boolean {\n return row.getIsSelected() || row.getIsSomeSelected();\n}\n\ntype DataGridToggleableRow = {\n getIsSelected: () => boolean;\n toggleSelected: (value?: boolean) => void;\n subRows: readonly DataGridToggleableRow[];\n};\n\n// TanStack ignores toggleSelected(true) when the row id is already selected.\n// A partial parent is in that state, so its missing descendants must be selected directly.\nfunction selectDataGridRowTree(row: DataGridToggleableRow): void {\n if (!row.getIsSelected()) {\n row.toggleSelected(true);\n return;\n }\n\n for (const subRow of row.subRows) {\n selectDataGridRowTree(subRow);\n }\n}\n\nexport {\n getDataGridCheckboxState,\n isDataGridRowHighlighted,\n selectDataGridRowTree,\n type DataGridCheckboxState,\n type DataGridSelectionRow,\n};\n"],"names":["getDataGridCheckboxState","row","subRows","length","getIsSelected","getIsAllSubRowsSelected","getIsSomeSelected","isDataGridRowHighlighted","selectDataGridRowTree","toggleSelected","subRow"],"mappings":"AAYA,SAASA,yBACPC,GAAgC;IAEhC,IAAIA,IAAIC,OAAO,CAACC,MAAM,KAAK,GAAG;QAC5B,OAAOF,IAAIG,aAAa;IAC1B;IAEA,IAAIH,IAAII,uBAAuB,IAAI;QACjC,OAAO;IACT;IAEA,IAAIJ,IAAIK,iBAAiB,IAAI;QAC3B,OAAO;IACT;IAEA,OAAO;AACT;AAEA,SAASC,yBACPN,GAAgC;IAEhC,OAAOA,IAAIG,aAAa,MAAMH,IAAIK,iBAAiB;AACrD;AAQA,6EAA6E;AAC7E,2FAA2F;AAC3F,SAASE,sBAAsBP,GAA0B;IACvD,IAAI,CAACA,IAAIG,aAAa,IAAI;QACxBH,IAAIQ,cAAc,CAAC;QACnB;IACF;IAEA,KAAK,MAAMC,UAAUT,IAAIC,OAAO,CAAE;QAChCM,sBAAsBE;IACxB;AACF;AAEA,
|
|
1
|
+
{"version":3,"sources":["../../../../../src/components/ui/core/data-grid/data-grid-selection-state.ts"],"sourcesContent":["import type { Row, RowSelectionState } from '@tanstack/react-table';\n\ntype DataGridCheckboxState = boolean | 'indeterminate';\n\n// This is the slice of `Row<TData>` that selection reads.\ntype DataGridSelectionRow<TData> = Pick<\n Row<TData>,\n 'getIsSelected' | 'getIsSomeSelected' | 'getIsAllSubRowsSelected'\n> & {\n subRows: Pick<Row<TData>['subRows'], 'length'>;\n};\n\nfunction getDataGridCheckboxState<TData>(\n row: DataGridSelectionRow<TData>\n): DataGridCheckboxState {\n if (row.subRows.length === 0) {\n return row.getIsSelected();\n }\n\n if (row.getIsAllSubRowsSelected()) {\n return true;\n }\n\n if (row.getIsSomeSelected()) {\n return 'indeterminate';\n }\n\n return false;\n}\n\nfunction isDataGridRowHighlighted<TData>(\n row: DataGridSelectionRow<TData>\n): boolean {\n return row.getIsSelected() || row.getIsSomeSelected();\n}\n\ntype DataGridToggleableRow = {\n getIsSelected: () => boolean;\n toggleSelected: (value?: boolean) => void;\n subRows: readonly DataGridToggleableRow[];\n};\n\n// TanStack ignores toggleSelected(true) when the row id is already selected.\n// A partial parent is in that state, so its missing descendants must be selected directly.\nfunction selectDataGridRowTree(row: DataGridToggleableRow): void {\n if (!row.getIsSelected()) {\n row.toggleSelected(true);\n return;\n }\n\n for (const subRow of row.subRows) {\n selectDataGridRowTree(subRow);\n }\n}\n\nfunction countSelectedRowIds(rowSelection: RowSelectionState): number {\n return Object.values(rowSelection).filter(Boolean).length;\n}\n\nexport {\n countSelectedRowIds,\n getDataGridCheckboxState,\n isDataGridRowHighlighted,\n selectDataGridRowTree,\n type DataGridCheckboxState,\n type DataGridSelectionRow,\n};\n"],"names":["getDataGridCheckboxState","row","subRows","length","getIsSelected","getIsAllSubRowsSelected","getIsSomeSelected","isDataGridRowHighlighted","selectDataGridRowTree","toggleSelected","subRow","countSelectedRowIds","rowSelection","Object","values","filter","Boolean"],"mappings":"AAYA,SAASA,yBACPC,GAAgC;IAEhC,IAAIA,IAAIC,OAAO,CAACC,MAAM,KAAK,GAAG;QAC5B,OAAOF,IAAIG,aAAa;IAC1B;IAEA,IAAIH,IAAII,uBAAuB,IAAI;QACjC,OAAO;IACT;IAEA,IAAIJ,IAAIK,iBAAiB,IAAI;QAC3B,OAAO;IACT;IAEA,OAAO;AACT;AAEA,SAASC,yBACPN,GAAgC;IAEhC,OAAOA,IAAIG,aAAa,MAAMH,IAAIK,iBAAiB;AACrD;AAQA,6EAA6E;AAC7E,2FAA2F;AAC3F,SAASE,sBAAsBP,GAA0B;IACvD,IAAI,CAACA,IAAIG,aAAa,IAAI;QACxBH,IAAIQ,cAAc,CAAC;QACnB;IACF;IAEA,KAAK,MAAMC,UAAUT,IAAIC,OAAO,CAAE;QAChCM,sBAAsBE;IACxB;AACF;AAEA,SAASC,oBAAoBC,YAA+B;IAC1D,OAAOC,OAAOC,MAAM,CAACF,cAAcG,MAAM,CAACC,SAASb,MAAM;AAC3D;AAEA,SACEQ,mBAAmB,EACnBX,wBAAwB,EACxBO,wBAAwB,EACxBC,qBAAqB,GAGrB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type ReactElement } from "react";
|
|
2
|
+
import type { RowSelectionState } from "@tanstack/react-table";
|
|
3
|
+
import type { DataGridSelectionActions } from "./data-grid-selection.types";
|
|
4
|
+
type DataGridSelectionToolbarProps = {
|
|
5
|
+
selectedCount: number;
|
|
6
|
+
rowSelection: RowSelectionState;
|
|
7
|
+
selectionActions?: DataGridSelectionActions;
|
|
8
|
+
onClear: () => void;
|
|
9
|
+
};
|
|
10
|
+
declare function DataGridSelectionToolbar({ selectedCount, rowSelection, selectionActions, onClear }: DataGridSelectionToolbarProps): ReactElement;
|
|
11
|
+
export { DataGridSelectionToolbar };
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect } from "react";
|
|
3
|
+
import { IconDotsVertical } from "@tabler/icons-react";
|
|
4
|
+
import { ActionToolbar, ActionToolbarAction, ActionToolbarActionClear, ActionToolbarActions, ActionToolbarPrimaryAction, ActionToolbarSelection, ActionToolbarSelectionSummary } from "../action-toolbar/action-toolbar.js";
|
|
5
|
+
import { Button } from "../button/button.js";
|
|
6
|
+
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "../dropdown-menu/dropdown-menu.js";
|
|
7
|
+
const MAX_SECONDARY_ACTIONS = 5;
|
|
8
|
+
function DataGridSelectionToolbar({ selectedCount, rowSelection, selectionActions, onClear }) {
|
|
9
|
+
const primaryAction = selectionActions?.primaryAction;
|
|
10
|
+
const requestedSecondaryActions = selectionActions?.secondaryActions ?? [];
|
|
11
|
+
const secondaryActions = limitSecondaryActions(requestedSecondaryActions);
|
|
12
|
+
const menuActions = selectionActions?.menuActions ?? [];
|
|
13
|
+
const secondaryActionCount = requestedSecondaryActions.length;
|
|
14
|
+
useEffect(()=>{
|
|
15
|
+
if (secondaryActionCount <= MAX_SECONDARY_ACTIONS) return;
|
|
16
|
+
console.warn(`[Aura DataGrid] The selection toolbar shows at most ${MAX_SECONDARY_ACTIONS} secondary actions. ` + 'Move the rest to menuActions.');
|
|
17
|
+
}, [
|
|
18
|
+
secondaryActionCount
|
|
19
|
+
]);
|
|
20
|
+
return /*#__PURE__*/ _jsx("div", {
|
|
21
|
+
className: "pointer-events-none sticky bottom-4 z-20 flex justify-center px-4",
|
|
22
|
+
children: /*#__PURE__*/ _jsxs(ActionToolbar, {
|
|
23
|
+
selectedCount: selectedCount,
|
|
24
|
+
width: "full",
|
|
25
|
+
"aria-label": "Selection actions",
|
|
26
|
+
className: "pointer-events-auto",
|
|
27
|
+
children: [
|
|
28
|
+
/*#__PURE__*/ _jsxs(ActionToolbarSelection, {
|
|
29
|
+
"aria-label": "Selected rows",
|
|
30
|
+
children: [
|
|
31
|
+
/*#__PURE__*/ _jsx(ActionToolbarSelectionSummary, {}),
|
|
32
|
+
/*#__PURE__*/ _jsx(ActionToolbarActionClear, {
|
|
33
|
+
onClick: onClear
|
|
34
|
+
})
|
|
35
|
+
]
|
|
36
|
+
}),
|
|
37
|
+
/*#__PURE__*/ _jsxs(ActionToolbarActions, {
|
|
38
|
+
"aria-label": "Actions",
|
|
39
|
+
children: [
|
|
40
|
+
menuActions.length > 0 ? /*#__PURE__*/ _jsx(DataGridSelectionMenu, {
|
|
41
|
+
actions: menuActions,
|
|
42
|
+
rowSelection: rowSelection
|
|
43
|
+
}) : null,
|
|
44
|
+
secondaryActions.map((action)=>/*#__PURE__*/ _jsx(DataGridSecondaryToolbarAction, {
|
|
45
|
+
action: action,
|
|
46
|
+
rowSelection: rowSelection
|
|
47
|
+
}, actionListKey(secondaryActions, action))),
|
|
48
|
+
primaryAction ? /*#__PURE__*/ _jsxs(ActionToolbarPrimaryAction, {
|
|
49
|
+
onClick: ()=>primaryAction.onClick(rowSelection),
|
|
50
|
+
children: [
|
|
51
|
+
primaryAction.icon ? /*#__PURE__*/ _jsx("span", {
|
|
52
|
+
"aria-hidden": "true",
|
|
53
|
+
children: primaryAction.icon
|
|
54
|
+
}) : null,
|
|
55
|
+
primaryAction.label
|
|
56
|
+
]
|
|
57
|
+
}) : null
|
|
58
|
+
]
|
|
59
|
+
})
|
|
60
|
+
]
|
|
61
|
+
})
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
function DataGridSecondaryToolbarAction({ action, rowSelection }) {
|
|
65
|
+
if (action.label != null) {
|
|
66
|
+
return /*#__PURE__*/ _jsxs(ActionToolbarAction, {
|
|
67
|
+
onClick: ()=>action.onClick(rowSelection),
|
|
68
|
+
children: [
|
|
69
|
+
action.icon ? /*#__PURE__*/ _jsx("span", {
|
|
70
|
+
"aria-hidden": "true",
|
|
71
|
+
children: action.icon
|
|
72
|
+
}) : null,
|
|
73
|
+
action.label
|
|
74
|
+
]
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
return /*#__PURE__*/ _jsx(ActionToolbarAction, {
|
|
78
|
+
iconOnly: true,
|
|
79
|
+
"aria-label": action['aria-label'],
|
|
80
|
+
onClick: ()=>action.onClick(rowSelection),
|
|
81
|
+
children: /*#__PURE__*/ _jsx("span", {
|
|
82
|
+
"aria-hidden": "true",
|
|
83
|
+
children: action.icon
|
|
84
|
+
})
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
function DataGridSelectionMenu({ actions, rowSelection }) {
|
|
88
|
+
return /*#__PURE__*/ _jsxs(DropdownMenu, {
|
|
89
|
+
children: [
|
|
90
|
+
/*#__PURE__*/ _jsx(DropdownMenuTrigger, {
|
|
91
|
+
render: /*#__PURE__*/ _jsx(Button, {
|
|
92
|
+
variant: "ghostOnDark",
|
|
93
|
+
size: "icon",
|
|
94
|
+
"aria-label": "More actions",
|
|
95
|
+
children: /*#__PURE__*/ _jsx(IconDotsVertical, {
|
|
96
|
+
"aria-hidden": "true"
|
|
97
|
+
})
|
|
98
|
+
})
|
|
99
|
+
}),
|
|
100
|
+
/*#__PURE__*/ _jsx(DropdownMenuContent, {
|
|
101
|
+
side: "top",
|
|
102
|
+
align: "end",
|
|
103
|
+
children: actions.map((action)=>/*#__PURE__*/ _jsxs(DropdownMenuItem, {
|
|
104
|
+
onClick: ()=>action.onClick(rowSelection),
|
|
105
|
+
children: [
|
|
106
|
+
action.icon ? /*#__PURE__*/ _jsx("span", {
|
|
107
|
+
"aria-hidden": "true",
|
|
108
|
+
children: action.icon
|
|
109
|
+
}) : null,
|
|
110
|
+
action.label
|
|
111
|
+
]
|
|
112
|
+
}, actionListKey(actions, action)))
|
|
113
|
+
})
|
|
114
|
+
]
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
function actionListKey(actions, action) {
|
|
118
|
+
const name = action.label ?? action['aria-label'] ?? '';
|
|
119
|
+
const earlierDuplicates = actions.slice(0, actions.indexOf(action)).filter((candidate)=>(candidate.label ?? candidate['aria-label']) === name).length;
|
|
120
|
+
if (earlierDuplicates === 0) return name;
|
|
121
|
+
return `${name}-${earlierDuplicates + 1}`;
|
|
122
|
+
}
|
|
123
|
+
function limitSecondaryActions(actions) {
|
|
124
|
+
return actions.slice(0, MAX_SECONDARY_ACTIONS);
|
|
125
|
+
}
|
|
126
|
+
export { DataGridSelectionToolbar };
|
|
127
|
+
|
|
128
|
+
//# sourceMappingURL=data-grid-selection-toolbar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/components/ui/core/data-grid/data-grid-selection-toolbar.tsx"],"sourcesContent":["import { useEffect, type ReactElement } from 'react';\n\nimport { IconDotsVertical } from '@tabler/icons-react';\nimport type { RowSelectionState } from '@tanstack/react-table';\n\nimport {\n ActionToolbar,\n ActionToolbarAction,\n ActionToolbarActionClear,\n ActionToolbarActions,\n ActionToolbarPrimaryAction,\n ActionToolbarSelection,\n ActionToolbarSelectionSummary,\n} from '../action-toolbar/action-toolbar';\nimport { Button } from '../button/button';\nimport {\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuTrigger,\n} from '../dropdown-menu/dropdown-menu';\n\nimport type {\n DataGridSecondaryAction,\n DataGridSelectionAction,\n DataGridSelectionActions,\n} from './data-grid-selection.types';\n\ntype DataGridSelectionToolbarProps = {\n selectedCount: number;\n rowSelection: RowSelectionState;\n selectionActions?: DataGridSelectionActions;\n onClear: () => void;\n};\n\nconst MAX_SECONDARY_ACTIONS = 5;\n\nfunction DataGridSelectionToolbar({\n selectedCount,\n rowSelection,\n selectionActions,\n onClear,\n}: DataGridSelectionToolbarProps): ReactElement {\n const primaryAction = selectionActions?.primaryAction;\n const requestedSecondaryActions = selectionActions?.secondaryActions ?? [];\n const secondaryActions = limitSecondaryActions(requestedSecondaryActions);\n const menuActions = selectionActions?.menuActions ?? [];\n\n const secondaryActionCount = requestedSecondaryActions.length;\n\n useEffect(() => {\n if (secondaryActionCount <= MAX_SECONDARY_ACTIONS) return;\n console.warn(\n `[Aura DataGrid] The selection toolbar shows at most ${MAX_SECONDARY_ACTIONS} secondary actions. ` +\n 'Move the rest to menuActions.'\n );\n }, [secondaryActionCount]);\n\n return (\n <div className=\"pointer-events-none sticky bottom-4 z-20 flex justify-center px-4\">\n <ActionToolbar\n selectedCount={selectedCount}\n width=\"full\"\n aria-label=\"Selection actions\"\n className=\"pointer-events-auto\"\n >\n <ActionToolbarSelection aria-label=\"Selected rows\">\n <ActionToolbarSelectionSummary />\n <ActionToolbarActionClear onClick={onClear} />\n </ActionToolbarSelection>\n <ActionToolbarActions aria-label=\"Actions\">\n {menuActions.length > 0 ? (\n <DataGridSelectionMenu\n actions={menuActions}\n rowSelection={rowSelection}\n />\n ) : null}\n {secondaryActions.map((action: DataGridSecondaryAction) => (\n <DataGridSecondaryToolbarAction\n key={actionListKey(secondaryActions, action)}\n action={action}\n rowSelection={rowSelection}\n />\n ))}\n {primaryAction ? (\n <ActionToolbarPrimaryAction\n onClick={() => primaryAction.onClick(rowSelection)}\n >\n {primaryAction.icon ? (\n <span aria-hidden=\"true\">{primaryAction.icon}</span>\n ) : null}\n {primaryAction.label}\n </ActionToolbarPrimaryAction>\n ) : null}\n </ActionToolbarActions>\n </ActionToolbar>\n </div>\n );\n}\n\nfunction DataGridSecondaryToolbarAction({\n action,\n rowSelection,\n}: {\n action: DataGridSecondaryAction;\n rowSelection: RowSelectionState;\n}): ReactElement {\n if (action.label != null) {\n return (\n <ActionToolbarAction onClick={() => action.onClick(rowSelection)}>\n {action.icon ? <span aria-hidden=\"true\">{action.icon}</span> : null}\n {action.label}\n </ActionToolbarAction>\n );\n }\n\n return (\n <ActionToolbarAction\n iconOnly\n aria-label={action['aria-label']}\n onClick={() => action.onClick(rowSelection)}\n >\n <span aria-hidden=\"true\">{action.icon}</span>\n </ActionToolbarAction>\n );\n}\n\nfunction DataGridSelectionMenu({\n actions,\n rowSelection,\n}: {\n actions: readonly DataGridSelectionAction[];\n rowSelection: RowSelectionState;\n}): ReactElement {\n return (\n <DropdownMenu>\n <DropdownMenuTrigger\n render={\n <Button variant=\"ghostOnDark\" size=\"icon\" aria-label=\"More actions\">\n <IconDotsVertical aria-hidden=\"true\" />\n </Button>\n }\n />\n <DropdownMenuContent side=\"top\" align=\"end\">\n {actions.map((action: DataGridSelectionAction) => (\n <DropdownMenuItem\n key={actionListKey(actions, action)}\n onClick={() => action.onClick(rowSelection)}\n >\n {action.icon ? <span aria-hidden=\"true\">{action.icon}</span> : null}\n {action.label}\n </DropdownMenuItem>\n ))}\n </DropdownMenuContent>\n </DropdownMenu>\n );\n}\n\nfunction actionListKey<T extends { label?: string; 'aria-label'?: string }>(\n actions: readonly T[],\n action: T\n): string {\n const name = action.label ?? action['aria-label'] ?? '';\n const earlierDuplicates = actions\n .slice(0, actions.indexOf(action))\n .filter(\n (candidate) => (candidate.label ?? candidate['aria-label']) === name\n ).length;\n if (earlierDuplicates === 0) return name;\n return `${name}-${earlierDuplicates + 1}`;\n}\n\nfunction limitSecondaryActions(\n actions: readonly DataGridSecondaryAction[]\n): readonly DataGridSecondaryAction[] {\n return actions.slice(0, MAX_SECONDARY_ACTIONS);\n}\n\nexport { DataGridSelectionToolbar };\n"],"names":["useEffect","IconDotsVertical","ActionToolbar","ActionToolbarAction","ActionToolbarActionClear","ActionToolbarActions","ActionToolbarPrimaryAction","ActionToolbarSelection","ActionToolbarSelectionSummary","Button","DropdownMenu","DropdownMenuContent","DropdownMenuItem","DropdownMenuTrigger","MAX_SECONDARY_ACTIONS","DataGridSelectionToolbar","selectedCount","rowSelection","selectionActions","onClear","primaryAction","requestedSecondaryActions","secondaryActions","limitSecondaryActions","menuActions","secondaryActionCount","length","console","warn","div","className","width","aria-label","onClick","DataGridSelectionMenu","actions","map","action","DataGridSecondaryToolbarAction","actionListKey","icon","span","aria-hidden","label","iconOnly","render","variant","size","side","align","name","earlierDuplicates","slice","indexOf","filter","candidate"],"mappings":";AAAA,SAASA,SAAS,QAA2B,QAAQ;AAErD,SAASC,gBAAgB,QAAQ,sBAAsB;AAGvD,SACEC,aAAa,EACbC,mBAAmB,EACnBC,wBAAwB,EACxBC,oBAAoB,EACpBC,0BAA0B,EAC1BC,sBAAsB,EACtBC,6BAA6B,QACxB,sCAAmC;AAC1C,SAASC,MAAM,QAAQ,sBAAmB;AAC1C,SACEC,YAAY,EACZC,mBAAmB,EACnBC,gBAAgB,EAChBC,mBAAmB,QACd,oCAAiC;AAexC,MAAMC,wBAAwB;AAE9B,SAASC,yBAAyB,EAChCC,aAAa,EACbC,YAAY,EACZC,gBAAgB,EAChBC,OAAO,EACuB;IAC9B,MAAMC,gBAAgBF,kBAAkBE;IACxC,MAAMC,4BAA4BH,kBAAkBI,oBAAoB,EAAE;IAC1E,MAAMA,mBAAmBC,sBAAsBF;IAC/C,MAAMG,cAAcN,kBAAkBM,eAAe,EAAE;IAEvD,MAAMC,uBAAuBJ,0BAA0BK,MAAM;IAE7D1B,UAAU;QACR,IAAIyB,wBAAwBX,uBAAuB;QACnDa,QAAQC,IAAI,CACV,CAAC,oDAAoD,EAAEd,sBAAsB,oBAAoB,CAAC,GAChG;IAEN,GAAG;QAACW;KAAqB;IAEzB,qBACE,KAACI;QAAIC,WAAU;kBACb,cAAA,MAAC5B;YACCc,eAAeA;YACfe,OAAM;YACNC,cAAW;YACXF,WAAU;;8BAEV,MAACvB;oBAAuByB,cAAW;;sCACjC,KAACxB;sCACD,KAACJ;4BAAyB6B,SAASd;;;;8BAErC,MAACd;oBAAqB2B,cAAW;;wBAC9BR,YAAYE,MAAM,GAAG,kBACpB,KAACQ;4BACCC,SAASX;4BACTP,cAAcA;6BAEd;wBACHK,iBAAiBc,GAAG,CAAC,CAACC,uBACrB,KAACC;gCAECD,QAAQA;gCACRpB,cAAcA;+BAFTsB,cAAcjB,kBAAkBe;wBAKxCjB,8BACC,MAACd;4BACC2B,SAAS,IAAMb,cAAca,OAAO,CAAChB;;gCAEpCG,cAAcoB,IAAI,iBACjB,KAACC;oCAAKC,eAAY;8CAAQtB,cAAcoB,IAAI;qCAC1C;gCACHpB,cAAcuB,KAAK;;6BAEpB;;;;;;AAKd;AAEA,SAASL,+BAA+B,EACtCD,MAAM,EACNpB,YAAY,EAIb;IACC,IAAIoB,OAAOM,KAAK,IAAI,MAAM;QACxB,qBACE,MAACxC;YAAoB8B,SAAS,IAAMI,OAAOJ,OAAO,CAAChB;;gBAChDoB,OAAOG,IAAI,iBAAG,KAACC;oBAAKC,eAAY;8BAAQL,OAAOG,IAAI;qBAAW;gBAC9DH,OAAOM,KAAK;;;IAGnB;IAEA,qBACE,KAACxC;QACCyC,QAAQ;QACRZ,cAAYK,MAAM,CAAC,aAAa;QAChCJ,SAAS,IAAMI,OAAOJ,OAAO,CAAChB;kBAE9B,cAAA,KAACwB;YAAKC,eAAY;sBAAQL,OAAOG,IAAI;;;AAG3C;AAEA,SAASN,sBAAsB,EAC7BC,OAAO,EACPlB,YAAY,EAIb;IACC,qBACE,MAACP;;0BACC,KAACG;gBACCgC,sBACE,KAACpC;oBAAOqC,SAAQ;oBAAcC,MAAK;oBAAOf,cAAW;8BACnD,cAAA,KAAC/B;wBAAiByC,eAAY;;;;0BAIpC,KAAC/B;gBAAoBqC,MAAK;gBAAMC,OAAM;0BACnCd,QAAQC,GAAG,CAAC,CAACC,uBACZ,MAACzB;wBAECqB,SAAS,IAAMI,OAAOJ,OAAO,CAAChB;;4BAE7BoB,OAAOG,IAAI,iBAAG,KAACC;gCAAKC,eAAY;0CAAQL,OAAOG,IAAI;iCAAW;4BAC9DH,OAAOM,KAAK;;uBAJRJ,cAAcJ,SAASE;;;;AAUxC;AAEA,SAASE,cACPJ,OAAqB,EACrBE,MAAS;IAET,MAAMa,OAAOb,OAAOM,KAAK,IAAIN,MAAM,CAAC,aAAa,IAAI;IACrD,MAAMc,oBAAoBhB,QACvBiB,KAAK,CAAC,GAAGjB,QAAQkB,OAAO,CAAChB,SACzBiB,MAAM,CACL,CAACC,YAAc,AAACA,CAAAA,UAAUZ,KAAK,IAAIY,SAAS,CAAC,aAAa,AAAD,MAAOL,MAChExB,MAAM;IACV,IAAIyB,sBAAsB,GAAG,OAAOD;IACpC,OAAO,GAAGA,KAAK,CAAC,EAAEC,oBAAoB,GAAG;AAC3C;AAEA,SAAS5B,sBACPY,OAA2C;IAE3C,OAAOA,QAAQiB,KAAK,CAAC,GAAGtC;AAC1B;AAEA,SAASC,wBAAwB,GAAG"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { RowSelectionState } from "@tanstack/react-table";
|
|
3
|
+
type DataGridSelectionActionClick = (rowSelection: RowSelectionState) => void;
|
|
4
|
+
type DataGridSelectionAction = {
|
|
5
|
+
label: string;
|
|
6
|
+
icon?: ReactNode;
|
|
7
|
+
onClick: DataGridSelectionActionClick;
|
|
8
|
+
};
|
|
9
|
+
type DataGridSecondaryAction = {
|
|
10
|
+
onClick: DataGridSelectionActionClick;
|
|
11
|
+
} & ({
|
|
12
|
+
label: string;
|
|
13
|
+
icon?: ReactNode;
|
|
14
|
+
} | {
|
|
15
|
+
icon: ReactNode;
|
|
16
|
+
label?: undefined;
|
|
17
|
+
"aria-label": string;
|
|
18
|
+
});
|
|
19
|
+
type DataGridSelectionActions = {
|
|
20
|
+
primaryAction?: DataGridSelectionAction;
|
|
21
|
+
secondaryActions?: readonly DataGridSecondaryAction[];
|
|
22
|
+
menuActions?: readonly DataGridSelectionAction[];
|
|
23
|
+
};
|
|
24
|
+
export type { DataGridSecondaryAction, DataGridSelectionAction, DataGridSelectionActions };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../src/components/ui/core/data-grid/data-grid-selection.types.ts"],"sourcesContent":["import type { ReactNode } from 'react';\n\nimport type { RowSelectionState } from '@tanstack/react-table';\n\n// The grid passes the current selection.\ntype DataGridSelectionActionClick = (rowSelection: RowSelectionState) => void;\n\ntype DataGridSelectionAction = {\n label: string;\n icon?: ReactNode;\n onClick: DataGridSelectionActionClick;\n};\n\ntype DataGridSecondaryAction = {\n onClick: DataGridSelectionActionClick;\n} & (\n | { label: string; icon?: ReactNode }\n | { icon: ReactNode; label?: undefined; 'aria-label': string }\n);\n\ntype DataGridSelectionActions = {\n primaryAction?: DataGridSelectionAction;\n secondaryActions?: readonly DataGridSecondaryAction[];\n menuActions?: readonly DataGridSelectionAction[];\n};\n\nexport type {\n DataGridSecondaryAction,\n DataGridSelectionAction,\n DataGridSelectionActions,\n};\n"],"names":[],"mappings":"AA0BA,WAIE"}
|
|
@@ -2,6 +2,7 @@ import { type ComponentProps, type ComponentRef, type ForwardRefExoticComponent,
|
|
|
2
2
|
import { type ColumnDef, type ColumnSizingState, type ExpandedState, type FilterFnOption, type PaginationState, type Row, type RowSelectionState, type Table, type SortingState } from "@tanstack/react-table";
|
|
3
3
|
import { Button } from "../button/button";
|
|
4
4
|
import { Search } from "../search/search";
|
|
5
|
+
import type { DataGridSelectionActions } from "./data-grid-selection.types";
|
|
5
6
|
type DataGridContextValue = {
|
|
6
7
|
searchValue: string;
|
|
7
8
|
setSearchValue: (value: string) => void;
|
|
@@ -55,6 +56,7 @@ type DataGridBaseProps<TData> = {
|
|
|
55
56
|
rowSelection?: RowSelectionState;
|
|
56
57
|
defaultRowSelection?: RowSelectionState;
|
|
57
58
|
onRowSelectionChange?: (value: RowSelectionState) => void;
|
|
59
|
+
selectionActions?: DataGridSelectionActions;
|
|
58
60
|
sorting?: SortingState;
|
|
59
61
|
defaultSorting?: SortingState;
|
|
60
62
|
onSortingChange?: (value: SortingState) => void;
|
|
@@ -99,7 +101,7 @@ type DataGridAccessibleNameProps = {
|
|
|
99
101
|
"aria-label"?: string;
|
|
100
102
|
};
|
|
101
103
|
type DataGridProps<TData> = DataGridBaseProps<TData> & DataGridAccessibleNameProps;
|
|
102
|
-
declare function DataGrid<TData>({ data, columns, getRowId, rowCount, globalFilterFn, enableRowSelection, enableSorting, enableColumnResizing, columnGrow, columnSizing, defaultColumnSizing, onColumnSizingChange, manualPagination, manualSorting, rowSelection, defaultRowSelection, onRowSelectionChange, sorting, defaultSorting, onSortingChange, pagination, defaultPagination, onPaginationChange, getSubRows, expanded, defaultExpanded, onExpandedChange, getRowCanExpand, maxDepth, pinnedColumns, gridRef, size, children, className, onRowClick, searchValue, defaultSearchValue, onSearchValueChange, queryMode, loading, loadingVariant, loadingRowCount, renderLoadingCell, emptyState, noResultsState, filteredResultCount, totalResultCount, onClearSearch, onClearFilters, labels: labelOverrides, rowHeight, headerHeight, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy }: DataGridProps<TData>): ReactElement;
|
|
104
|
+
declare function DataGrid<TData>({ data, columns, getRowId, rowCount, globalFilterFn, enableRowSelection, enableSorting, enableColumnResizing, columnGrow, columnSizing, defaultColumnSizing, onColumnSizingChange, manualPagination, manualSorting, rowSelection, defaultRowSelection, onRowSelectionChange, selectionActions, sorting, defaultSorting, onSortingChange, pagination, defaultPagination, onPaginationChange, getSubRows, expanded, defaultExpanded, onExpandedChange, getRowCanExpand, maxDepth, pinnedColumns, gridRef, size, children, className, onRowClick, searchValue, defaultSearchValue, onSearchValueChange, queryMode, loading, loadingVariant, loadingRowCount, renderLoadingCell, emptyState, noResultsState, filteredResultCount, totalResultCount, onClearSearch, onClearFilters, labels: labelOverrides, rowHeight, headerHeight, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy }: DataGridProps<TData>): ReactElement;
|
|
103
105
|
declare function DataGridCheckboxHeader<TData>({ table }: {
|
|
104
106
|
table: Table<TData>;
|
|
105
107
|
}): ReactElement;
|