@omnigrid/react 0.1.27 → 0.1.28
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/groupCell.js +21 -2
- package/dist/pooledRow.js +2 -0
- package/package.json +1 -1
package/dist/groupCell.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { createElement } from "react";
|
|
2
2
|
import { contentToReactNode } from "./content";
|
|
3
|
+
function isToggleGroupMethod(method) {
|
|
4
|
+
return typeof method === "function";
|
|
5
|
+
}
|
|
3
6
|
/**
|
|
4
7
|
* Checks whether an arbitrary row node represents a grouping tree node.
|
|
5
8
|
*
|
|
@@ -76,6 +79,22 @@ export function renderGroupCellContent(info, bridgeArg, grid) {
|
|
|
76
79
|
return null;
|
|
77
80
|
const chevronName = node.expanded ? "chevron-down" : "chevron-right";
|
|
78
81
|
const icon = contentToReactNode(bridgeArg.context().api.icons.get(chevronName), bridgeArg);
|
|
82
|
+
const toggleButton = createElement("button", {
|
|
83
|
+
type: "button",
|
|
84
|
+
className: "omnigrid-icon-button",
|
|
85
|
+
"data-omnigrid-group-toggle": "",
|
|
86
|
+
"aria-label": `${node.expanded ? "Collapse" : "Expand"} ${String(node.key)} group`,
|
|
87
|
+
"aria-expanded": node.expanded,
|
|
88
|
+
onClick: (event) => {
|
|
89
|
+
event.stopPropagation();
|
|
90
|
+
const gridWithToggleGroup = grid;
|
|
91
|
+
const toggleGroup = grid.methods.toggleGroup ?? gridWithToggleGroup.toggleGroup;
|
|
92
|
+
if (!isToggleGroupMethod(toggleGroup)) {
|
|
93
|
+
throw new Error("Cannot toggle group: the grid does not expose a group toggle method.");
|
|
94
|
+
}
|
|
95
|
+
toggleGroup.call(grid, node.id);
|
|
96
|
+
},
|
|
97
|
+
}, icon);
|
|
79
98
|
if (groupRowRenderer) {
|
|
80
99
|
const rendered = groupRowRenderer({
|
|
81
100
|
node: node,
|
|
@@ -91,12 +110,12 @@ export function renderGroupCellContent(info, bridgeArg, grid) {
|
|
|
91
110
|
return createElement("span", {
|
|
92
111
|
style: { paddingLeft: mode === "single" ? level * 20 : 0, display: "flex", alignItems: "center", gap: 6 },
|
|
93
112
|
title: String(node.key),
|
|
94
|
-
},
|
|
113
|
+
}, toggleButton, " ", node.key, " (", node.childrenCount, ")");
|
|
95
114
|
}
|
|
96
115
|
return createElement("span", {
|
|
97
116
|
style: { paddingLeft: mode === "single" ? level * 20 : 0, display: "flex", alignItems: "center", gap: 6 },
|
|
98
117
|
title: String(node.key),
|
|
99
|
-
},
|
|
118
|
+
}, toggleButton, " ", node.key);
|
|
100
119
|
}
|
|
101
120
|
if (column.cellRenderer) {
|
|
102
121
|
const value = node.aggregations[column.id];
|
package/dist/pooledRow.js
CHANGED
|
@@ -299,6 +299,8 @@ export class PooledRowPane {
|
|
|
299
299
|
};
|
|
300
300
|
element.addEventListener("click", (event) => {
|
|
301
301
|
event.stopPropagation();
|
|
302
|
+
if (event.target instanceof Element && event.target.closest("[data-omnigrid-group-toggle]"))
|
|
303
|
+
return;
|
|
302
304
|
const row = this.row;
|
|
303
305
|
const column = cell.column;
|
|
304
306
|
if (!row || !column)
|