@genesislcap/grid-pro 15.17.1 → 15.18.0-FUI-2601.4
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/custom-elements.json +5163 -3233
- package/dist/dts/columns-tool-panel/columns-tool-panel-ag-drag.d.ts +12 -0
- package/dist/dts/columns-tool-panel/columns-tool-panel-ag-drag.d.ts.map +1 -0
- package/dist/dts/columns-tool-panel/columns-tool-panel.d.ts +150 -0
- package/dist/dts/columns-tool-panel/columns-tool-panel.d.ts.map +1 -0
- package/dist/dts/columns-tool-panel/columns-tool-panel.styles.d.ts +9 -0
- package/dist/dts/columns-tool-panel/columns-tool-panel.styles.d.ts.map +1 -0
- package/dist/dts/columns-tool-panel/columns-tool-panel.template.d.ts +12 -0
- package/dist/dts/columns-tool-panel/columns-tool-panel.template.d.ts.map +1 -0
- package/dist/dts/columns-tool-panel/columns-tool-panel.utils.d.ts +48 -0
- package/dist/dts/columns-tool-panel/columns-tool-panel.utils.d.ts.map +1 -0
- package/dist/dts/columns-tool-panel/grid-pro-column-drag-bridge.d.ts +39 -0
- package/dist/dts/columns-tool-panel/grid-pro-column-drag-bridge.d.ts.map +1 -0
- package/dist/dts/columns-tool-panel/index.d.ts +5 -0
- package/dist/dts/columns-tool-panel/index.d.ts.map +1 -0
- package/dist/dts/grid-pro-beta.d.ts +27 -3
- package/dist/dts/grid-pro-beta.d.ts.map +1 -1
- package/dist/dts/grid-pro.d.ts.map +1 -1
- package/dist/dts/grid-pro.styles.d.ts.map +1 -1
- package/dist/dts/grid-pro.template.d.ts.map +1 -1
- package/dist/dts/grid-pro.types.d.ts +10 -0
- package/dist/dts/grid-pro.types.d.ts.map +1 -1
- package/dist/dts/index.d.ts +2 -0
- package/dist/dts/index.d.ts.map +1 -1
- package/dist/dts/react.d.ts +20 -0
- package/dist/dts/row-alert/row-alert.d.ts +2 -0
- package/dist/dts/row-alert/row-alert.d.ts.map +1 -1
- package/dist/dts/side-bar/index.d.ts +6 -0
- package/dist/dts/side-bar/index.d.ts.map +1 -0
- package/dist/dts/side-bar/side-bar.d.ts +418 -0
- package/dist/dts/side-bar/side-bar.d.ts.map +1 -0
- package/dist/dts/side-bar/side-bar.styles.d.ts +19 -0
- package/dist/dts/side-bar/side-bar.styles.d.ts.map +1 -0
- package/dist/dts/side-bar/side-bar.template.d.ts +11 -0
- package/dist/dts/side-bar/side-bar.template.d.ts.map +1 -0
- package/dist/dts/side-bar/side-bar.tools.d.ts +19 -0
- package/dist/dts/side-bar/side-bar.tools.d.ts.map +1 -0
- package/dist/dts/side-bar/side-bar.types.d.ts +86 -0
- package/dist/dts/side-bar/side-bar.types.d.ts.map +1 -0
- package/dist/esm/columns-tool-panel/columns-tool-panel-ag-drag.js +50 -0
- package/dist/esm/columns-tool-panel/columns-tool-panel.js +500 -0
- package/dist/esm/columns-tool-panel/columns-tool-panel.styles.js +180 -0
- package/dist/esm/columns-tool-panel/columns-tool-panel.template.js +70 -0
- package/dist/esm/columns-tool-panel/columns-tool-panel.utils.js +185 -0
- package/dist/esm/columns-tool-panel/grid-pro-column-drag-bridge.js +57 -0
- package/dist/esm/columns-tool-panel/index.js +4 -0
- package/dist/esm/grid-pro-beta.js +95 -3
- package/dist/esm/grid-pro.js +2 -2
- package/dist/esm/grid-pro.styles.js +4 -0
- package/dist/esm/grid-pro.template.js +13 -1
- package/dist/esm/grid-pro.types.js +11 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/row-alert/row-alert.js +4 -0
- package/dist/esm/side-bar/index.js +5 -0
- package/dist/esm/side-bar/side-bar.js +204 -0
- package/dist/esm/side-bar/side-bar.styles.js +155 -0
- package/dist/esm/side-bar/side-bar.template.js +53 -0
- package/dist/esm/side-bar/side-bar.tools.js +26 -0
- package/dist/esm/side-bar/side-bar.types.js +45 -0
- package/dist/grid-pro.api.json +11006 -7961
- package/dist/grid-pro.d.ts +986 -150
- package/dist/react.cjs +14 -0
- package/dist/react.mjs +12 -0
- package/package.json +14 -14
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { html, repeat } from '@microsoft/fast-element';
|
|
2
|
+
/**
|
|
3
|
+
* Columns tool panel template with Design System prefix (`rapid-text-field`, etc.).
|
|
4
|
+
* @public
|
|
5
|
+
*/
|
|
6
|
+
export const getColumnsToolPanelTemplate = (prefix = 'foundation') => {
|
|
7
|
+
const textField = `${prefix}-text-field`;
|
|
8
|
+
const checkbox = `${prefix}-checkbox`;
|
|
9
|
+
const columnRow = html `
|
|
10
|
+
<div
|
|
11
|
+
class="${(x) => `grid-pro-columns-item${x.visible ? '' : ' grid-pro-columns-item--unselected'}`}"
|
|
12
|
+
data-col-id="${(x) => x.colId}"
|
|
13
|
+
data-test-id="${(x) => `grid-pro-columns-item-${x.colId}`}"
|
|
14
|
+
>
|
|
15
|
+
<${checkbox}
|
|
16
|
+
class="grid-pro-columns-checkbox"
|
|
17
|
+
data-test-id="${(x) => `grid-pro-columns-check-${x.colId}`}"
|
|
18
|
+
?checked="${(x) => x.visible}"
|
|
19
|
+
?disabled="${(x) => x.lockVisible}"
|
|
20
|
+
@click="${(x, c) => c.parent.onCheckboxClick(x, c.event)}"
|
|
21
|
+
></${checkbox}>
|
|
22
|
+
<span
|
|
23
|
+
class="grid-pro-columns-handle"
|
|
24
|
+
data-test-id="${(x) => `grid-pro-columns-handle-${x.colId}`}"
|
|
25
|
+
aria-hidden="${(x, c) => {
|
|
26
|
+
const panel = c.parent;
|
|
27
|
+
return String(!(panel.canDrag && (x.visible || panel.canDragToGrid(x))));
|
|
28
|
+
}}"
|
|
29
|
+
>
|
|
30
|
+
⋮⋮
|
|
31
|
+
</span>
|
|
32
|
+
<span class="grid-pro-columns-label">${(x) => x.headerName}</span>
|
|
33
|
+
</div>
|
|
34
|
+
`;
|
|
35
|
+
return html `
|
|
36
|
+
<template>
|
|
37
|
+
<div class="grid-pro-columns-toolbar" data-test-id="grid-pro-columns-toolbar">
|
|
38
|
+
<${checkbox}
|
|
39
|
+
class="grid-pro-columns-select-all"
|
|
40
|
+
data-test-id="grid-pro-columns-select-all"
|
|
41
|
+
?checked="${(x) => x.selectAllChecked}"
|
|
42
|
+
:indeterminate="${(x) => x.selectAllIndeterminate}"
|
|
43
|
+
@click="${(x, c) => x.onSelectAllClick(c.event)}"
|
|
44
|
+
></${checkbox}>
|
|
45
|
+
<${textField}
|
|
46
|
+
class="grid-pro-columns-search"
|
|
47
|
+
placeholder="Search"
|
|
48
|
+
data-test-id="grid-pro-columns-search"
|
|
49
|
+
:value="${(x) => x.search}"
|
|
50
|
+
@input="${(x, c) => x.onSearchInput(c.event.target.value)}"
|
|
51
|
+
></${textField}>
|
|
52
|
+
</div>
|
|
53
|
+
<div class="grid-pro-columns-list" data-test-id="grid-pro-columns-list">
|
|
54
|
+
<div class="grid-pro-columns-section" data-test-id="grid-pro-columns-selected">
|
|
55
|
+
${repeat((x) => x.selectedItems, columnRow, { recycle: false })}
|
|
56
|
+
</div>
|
|
57
|
+
<div class="grid-pro-columns-section" data-test-id="grid-pro-columns-unselected">
|
|
58
|
+
${repeat((x) => x.unselectedItems, columnRow, { recycle: false })}
|
|
59
|
+
</div>
|
|
60
|
+
</div>
|
|
61
|
+
</template>
|
|
62
|
+
`;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Default columns tool panel template (`foundation-*` components).
|
|
66
|
+
* @public
|
|
67
|
+
*/
|
|
68
|
+
export const columnsToolPanelTemplate = html `
|
|
69
|
+
${(x) => getColumnsToolPanelTemplate(x.prefix || 'foundation')}
|
|
70
|
+
`;
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { GridProToolPanelTypes } from '../grid-pro.types';
|
|
2
|
+
export const GRID_PRO_COLUMNS_TOOL_PANEL_SORT_DEFAULT = 'selected-first';
|
|
3
|
+
export function resolveColumnsToolPanelSort(sort) {
|
|
4
|
+
return sort === 'ag-grid' ? 'ag-grid' : GRID_PRO_COLUMNS_TOOL_PANEL_SORT_DEFAULT;
|
|
5
|
+
}
|
|
6
|
+
export const gridProColumnsToolPanelDef = {
|
|
7
|
+
id: 'columns',
|
|
8
|
+
labelDefault: 'Columns',
|
|
9
|
+
labelKey: 'columns',
|
|
10
|
+
iconKey: 'columns',
|
|
11
|
+
toolPanel: GridProToolPanelTypes.columns,
|
|
12
|
+
};
|
|
13
|
+
const filtersToolPanelDef = {
|
|
14
|
+
id: 'filters',
|
|
15
|
+
labelDefault: 'Filters',
|
|
16
|
+
labelKey: 'filters',
|
|
17
|
+
iconKey: 'filter',
|
|
18
|
+
toolPanel: 'agFiltersToolPanel',
|
|
19
|
+
};
|
|
20
|
+
export function toPickerItem(col) {
|
|
21
|
+
const colDef = col.getColDef();
|
|
22
|
+
if (colDef.suppressColumnsToolPanel) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
if (typeof col.isPrimary === 'function' && !col.isPrimary()) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
const colId = col.getColId();
|
|
29
|
+
const headerName = String(colDef.headerName || colDef.field || colId || '');
|
|
30
|
+
return {
|
|
31
|
+
colId,
|
|
32
|
+
headerName,
|
|
33
|
+
visible: col.isVisible(),
|
|
34
|
+
lockVisible: Boolean(colDef.lockVisible),
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export function getPickerItems(columns) {
|
|
38
|
+
return columns.map(toPickerItem).filter((item) => item != null);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Column order for the picker list.
|
|
42
|
+
*
|
|
43
|
+
* - `selected-first` (default): displayed columns first (current grid visual order), then
|
|
44
|
+
* any non-displayed columns in `getColumns()` order (caller alphabetizes hidden via
|
|
45
|
+
* {@link partitionPickerItems}).
|
|
46
|
+
* - `ag-grid`: current column-state order (`getColumnState`), visible and hidden interleaved —
|
|
47
|
+
* same live order AG's columns tool panel reflects after moves. Falls back to `getColumns()`
|
|
48
|
+
* when state is empty.
|
|
49
|
+
*/
|
|
50
|
+
export function orderColumnsForPicker(displayed, all, sort = GRID_PRO_COLUMNS_TOOL_PANEL_SORT_DEFAULT, columnState) {
|
|
51
|
+
if (sort === 'ag-grid') {
|
|
52
|
+
if (!(columnState === null || columnState === void 0 ? void 0 : columnState.length)) {
|
|
53
|
+
return all;
|
|
54
|
+
}
|
|
55
|
+
const byId = new Map(all.map((column) => [column.getColId(), column]));
|
|
56
|
+
const ordered = [];
|
|
57
|
+
const seen = new Set();
|
|
58
|
+
for (const state of columnState) {
|
|
59
|
+
const colId = state.colId;
|
|
60
|
+
if (colId == null || seen.has(colId)) {
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
const column = byId.get(colId);
|
|
64
|
+
if (column) {
|
|
65
|
+
ordered.push(column);
|
|
66
|
+
seen.add(colId);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
for (const column of all) {
|
|
70
|
+
const colId = column.getColId();
|
|
71
|
+
if (!seen.has(colId)) {
|
|
72
|
+
ordered.push(column);
|
|
73
|
+
seen.add(colId);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return ordered;
|
|
77
|
+
}
|
|
78
|
+
const displayedIds = new Set(displayed.map((column) => column.getColId()));
|
|
79
|
+
return [...displayed, ...all.filter((column) => !displayedIds.has(column.getColId()))];
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Splits / filters picker items for the template sections.
|
|
83
|
+
*
|
|
84
|
+
* - `selected-first`: visible rows in input order; hidden rows A–Z by header.
|
|
85
|
+
* - `ag-grid`: one flat list in input order (AG column-model order) in `selected`;
|
|
86
|
+
* `unselected` is empty so the template does not re-group.
|
|
87
|
+
*/
|
|
88
|
+
export function partitionPickerItems(items, search, sort = GRID_PRO_COLUMNS_TOOL_PANEL_SORT_DEFAULT) {
|
|
89
|
+
const query = search.trim().toLowerCase();
|
|
90
|
+
const matches = (item) => !query || item.headerName.toLowerCase().includes(query);
|
|
91
|
+
const filtered = items.filter(matches);
|
|
92
|
+
if (sort === 'ag-grid') {
|
|
93
|
+
return { selected: filtered, unselected: [] };
|
|
94
|
+
}
|
|
95
|
+
return {
|
|
96
|
+
selected: filtered.filter((item) => item.visible),
|
|
97
|
+
unselected: filtered
|
|
98
|
+
.filter((item) => !item.visible)
|
|
99
|
+
.sort((a, b) => a.headerName.localeCompare(b.headerName, undefined, { sensitivity: 'base' })),
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
export function reorderVisibleIds(allVisibleIds, shownIds, fromId, toId) {
|
|
103
|
+
const shown = [...shownIds];
|
|
104
|
+
const fromIndex = shown.indexOf(fromId);
|
|
105
|
+
const toIndex = shown.indexOf(toId);
|
|
106
|
+
if (fromIndex < 0 || toIndex < 0 || fromId === toId) {
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
shown.splice(fromIndex, 1);
|
|
110
|
+
shown.splice(toIndex, 0, fromId);
|
|
111
|
+
let index = 0;
|
|
112
|
+
return allVisibleIds.map((id) => {
|
|
113
|
+
if (!shownIds.includes(id)) {
|
|
114
|
+
return id;
|
|
115
|
+
}
|
|
116
|
+
const nextId = shown[index];
|
|
117
|
+
index += 1;
|
|
118
|
+
return nextId;
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
export function applyVisibleOrder(columnState, visibleOrder) {
|
|
122
|
+
const byId = new Map(columnState.map((state) => [state.colId, state]));
|
|
123
|
+
let index = 0;
|
|
124
|
+
return columnState.map((state) => {
|
|
125
|
+
if (state.hide) {
|
|
126
|
+
return state;
|
|
127
|
+
}
|
|
128
|
+
const nextId = visibleOrder[index];
|
|
129
|
+
index += 1;
|
|
130
|
+
return (nextId && byId.get(nextId)) || state;
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
function isColumnsToolPanel(panel) {
|
|
134
|
+
if (panel === 'columns' || panel === 'agColumnsToolPanel') {
|
|
135
|
+
return true;
|
|
136
|
+
}
|
|
137
|
+
if (typeof panel === 'string') {
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
return (panel.toolPanel === 'agColumnsToolPanel' ||
|
|
141
|
+
panel.toolPanel === GridProToolPanelTypes.columns ||
|
|
142
|
+
panel.id === 'columns');
|
|
143
|
+
}
|
|
144
|
+
function toColumnsToolPanel(panel) {
|
|
145
|
+
if (typeof panel === 'string') {
|
|
146
|
+
return Object.assign({}, gridProColumnsToolPanelDef);
|
|
147
|
+
}
|
|
148
|
+
return Object.assign(Object.assign(Object.assign({}, gridProColumnsToolPanelDef), panel), { toolPanel: GridProToolPanelTypes.columns });
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Rewrites `sideBar: ['columns']` / `agColumnsToolPanel` to the custom Grid Pro picker.
|
|
152
|
+
*/
|
|
153
|
+
export function resolveGridProSideBar(sideBar) {
|
|
154
|
+
var _a;
|
|
155
|
+
if (!sideBar) {
|
|
156
|
+
return sideBar;
|
|
157
|
+
}
|
|
158
|
+
if (sideBar === true || sideBar === 'true') {
|
|
159
|
+
return {
|
|
160
|
+
toolPanels: [gridProColumnsToolPanelDef, filtersToolPanelDef],
|
|
161
|
+
defaultToolPanel: 'filters',
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
if (sideBar === 'columns' || sideBar === 'agColumnsToolPanel') {
|
|
165
|
+
return { toolPanels: [gridProColumnsToolPanelDef] };
|
|
166
|
+
}
|
|
167
|
+
if (typeof sideBar === 'string') {
|
|
168
|
+
return sideBar;
|
|
169
|
+
}
|
|
170
|
+
if (Array.isArray(sideBar)) {
|
|
171
|
+
if (!sideBar.some(isColumnsToolPanel)) {
|
|
172
|
+
return sideBar;
|
|
173
|
+
}
|
|
174
|
+
return {
|
|
175
|
+
toolPanels: sideBar.map((panel) => isColumnsToolPanel(panel) ? toColumnsToolPanel(panel) : panel),
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
if (!((_a = sideBar.toolPanels) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
179
|
+
return sideBar;
|
|
180
|
+
}
|
|
181
|
+
if (!sideBar.toolPanels.some(isColumnsToolPanel)) {
|
|
182
|
+
return sideBar;
|
|
183
|
+
}
|
|
184
|
+
return Object.assign(Object.assign({}, sideBar), { toolPanels: sideBar.toolPanels.map((panel) => isColumnsToolPanel(panel) ? toColumnsToolPanel(panel) : panel) });
|
|
185
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { _ColumnMoveModule as ColumnMoveModule, } from 'ag-grid-community';
|
|
2
|
+
/** Context key on `gridOptions.context` for AG column drag integration. */
|
|
3
|
+
export const GRID_PRO_COLUMN_DRAG_BRIDGE_CONTEXT_KEY = 'gridProColumnDragBridge';
|
|
4
|
+
/** @internal Writes DnD beans onto the shared bridge object in grid context. */
|
|
5
|
+
export function syncColumnDragBridge(beans) {
|
|
6
|
+
var _a, _b;
|
|
7
|
+
if (!(beans === null || beans === void 0 ? void 0 : beans.dragAndDrop) || !beans.gos) {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
const context = (_a = beans.gos.get('context')) !== null && _a !== void 0 ? _a : (_b = beans.gridOptions) === null || _b === void 0 ? void 0 : _b.context;
|
|
11
|
+
const bridge = context === null || context === void 0 ? void 0 : context[GRID_PRO_COLUMN_DRAG_BRIDGE_CONTEXT_KEY];
|
|
12
|
+
if (!bridge) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
bridge.dragAndDrop = beans.dragAndDrop;
|
|
16
|
+
bridge.gos = beans.gos;
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
/** @internal Populates {@link GridProColumnDragBridge} once core DnD beans exist. */
|
|
20
|
+
class GridProColumnDragBridgeInit {
|
|
21
|
+
constructor() {
|
|
22
|
+
this.beanName = 'gridProColumnDragBridgeInit';
|
|
23
|
+
this.beans = null;
|
|
24
|
+
}
|
|
25
|
+
wireBeans(beans) {
|
|
26
|
+
this.beans = beans;
|
|
27
|
+
}
|
|
28
|
+
postConstruct() {
|
|
29
|
+
syncColumnDragBridge(this.beans);
|
|
30
|
+
queueMicrotask(() => syncColumnDragBridge(this.beans));
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Registers drag-and-drop beans on `gridOptions.context` so custom tool panels
|
|
35
|
+
* can call `dragAndDrop.addDragSource` (same contract as Enterprise Columns panel).
|
|
36
|
+
* @internal
|
|
37
|
+
*/
|
|
38
|
+
export const gridProColumnDragBridgeModule = {
|
|
39
|
+
moduleName: 'GridProColumnDragBridge',
|
|
40
|
+
version: ColumnMoveModule.version,
|
|
41
|
+
beans: [GridProColumnDragBridgeInit],
|
|
42
|
+
dependsOn: [ColumnMoveModule],
|
|
43
|
+
};
|
|
44
|
+
export function resolveColumnDragBridge(context) {
|
|
45
|
+
const bridge = context === null || context === void 0 ? void 0 : context[GRID_PRO_COLUMN_DRAG_BRIDGE_CONTEXT_KEY];
|
|
46
|
+
return resolveColumnDragBridgeDirect(bridge);
|
|
47
|
+
}
|
|
48
|
+
export function resolveColumnDragBridgeDirect(bridge) {
|
|
49
|
+
if (!(bridge === null || bridge === void 0 ? void 0 : bridge.dragAndDrop) || !(bridge === null || bridge === void 0 ? void 0 : bridge.gos)) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
return bridge;
|
|
53
|
+
}
|
|
54
|
+
export function resolveColumnDragBridgeFromApi(api) {
|
|
55
|
+
var _a;
|
|
56
|
+
return resolveColumnDragBridge((_a = api === null || api === void 0 ? void 0 : api.getGridOption) === null || _a === void 0 ? void 0 : _a.call(api, 'context'));
|
|
57
|
+
}
|
|
@@ -4,24 +4,27 @@ import { avoidTreeShaking, LifecycleMixin, respondToVisibility, } from '@genesis
|
|
|
4
4
|
import { baseLayerLuminance, StandardLuminance } from '@microsoft/fast-components';
|
|
5
5
|
import { attr, DOM, observable } from '@microsoft/fast-element';
|
|
6
6
|
import { FoundationElement } from '@microsoft/fast-foundation';
|
|
7
|
-
import { CellStyleModule, CheckboxEditorModule, ClientSideRowModelApiModule, ClientSideRowModelModule, ColumnApiModule, ColumnAutoSizeModule, createGrid, CsvExportModule, CustomEditorModule, DateEditorModule, DateFilterModule, EventApiModule, HighlightChangesModule, ModuleRegistry, NumberEditorModule, NumberFilterModule, PaginationModule, RenderApiModule, RowApiModule, RowSelectionModule, RowStyleModule, SelectEditorModule, TextEditorModule, TextFilterModule, TooltipModule, } from 'ag-grid-community';
|
|
7
|
+
import { CellStyleModule, CheckboxEditorModule, ClientSideRowModelApiModule, ClientSideRowModelModule, ColumnApiModule, ColumnAutoSizeModule, DragAndDropModule, createGrid, CsvExportModule, CustomEditorModule, DateEditorModule, DateFilterModule, EventApiModule, HighlightChangesModule, ModuleRegistry, NumberEditorModule, NumberFilterModule, PaginationModule, RenderApiModule, RowApiModule, RowSelectionModule, RowStyleModule, SelectEditorModule, TextEditorModule, TextFilterModule, TooltipModule, _ColumnMoveModule as ColumnMoveModule, } from 'ag-grid-community';
|
|
8
8
|
import * as changeCase from 'change-case';
|
|
9
9
|
import debounce from 'lodash.debounce';
|
|
10
10
|
import { GridProCell } from './cell';
|
|
11
11
|
import { DateEditor, MultiselectEditor, NumberEditor, SelectEditor, StringEditor, } from './cell-editors';
|
|
12
12
|
import { ActionRenderer, ActionsMenuRenderer, BooleanRenderer, EditableRenderer, IconRenderer, SelectRenderer, StatusPillRenderer, } from './cell-renderers';
|
|
13
13
|
import { GridProColumn, resolveVisibleColumnFields } from './column';
|
|
14
|
+
import { ColumnsToolPanel, resolveGridProSideBar } from './columns-tool-panel';
|
|
15
|
+
import { GRID_PRO_COLUMN_DRAG_BRIDGE_CONTEXT_KEY, gridProColumnDragBridgeModule, } from './columns-tool-panel/grid-pro-column-drag-bridge';
|
|
14
16
|
import { GridProClientSideDatasource, GridProServerSideDatasource } from './datasource';
|
|
15
17
|
import { baseDatasourceEventNames } from './datasource/base.types';
|
|
16
18
|
import { GridProGenesisDatasource, gridProGenesisDatasourceEventNames, } from './grid-pro-genesis-datasource';
|
|
17
19
|
import { datasourceEventNames, } from './grid-pro-genesis-datasource/datasource-events.types';
|
|
18
20
|
import { AG_PROPERTIES, copyAttributesToGridOptions, DEBOUNCED_RESIZE_TIME, gridProErrorNames, gridProEventNames, } from './grid-pro.definitions';
|
|
19
|
-
import { DEFAULT_STATUS_BAR_CONFIG, EDITED_COLUMN_FIELD, ERROR_COLUMN_FIELD, GRID_READY_EVENT, GridOptionsConfig, GridProRendererTypes, GridProStatusBarTypes, } from './grid-pro.types';
|
|
21
|
+
import { DEFAULT_STATUS_BAR_CONFIG, EDITED_COLUMN_FIELD, ERROR_COLUMN_FIELD, GRID_READY_EVENT, GridOptionsConfig, GridProRendererTypes, GridProStatusBarTypes, GridProToolPanelTypes, } from './grid-pro.types';
|
|
22
|
+
import { GridProSideBar, resolveAgSideBarToolPanels, } from './side-bar';
|
|
20
23
|
import { StatePersistence } from './state-persistence';
|
|
21
24
|
import { LabelValueStatusBarComponent, LoadMoreStatusBarComponent, ReloadStatusBarComponent, RowCountStatusBarComponent, } from './status-bar-components';
|
|
22
25
|
import { ErrorTooltip } from './tooltips';
|
|
23
26
|
import { convertToKebabCase, logger, mergeAndDedupColDefWithColumnState, sanitizeColumnState, } from './utils';
|
|
24
|
-
avoidTreeShaking(GridProGenesisDatasource, GridProClientSideDatasource, GridProServerSideDatasource, GridProCell, GridProColumn);
|
|
27
|
+
avoidTreeShaking(GridProGenesisDatasource, GridProClientSideDatasource, GridProServerSideDatasource, GridProCell, GridProColumn, GridProSideBar);
|
|
25
28
|
ModuleRegistry.registerModules([
|
|
26
29
|
CsvExportModule,
|
|
27
30
|
ClientSideRowModelModule,
|
|
@@ -46,6 +49,9 @@ ModuleRegistry.registerModules([
|
|
|
46
49
|
DateEditorModule,
|
|
47
50
|
SelectEditorModule,
|
|
48
51
|
CheckboxEditorModule,
|
|
52
|
+
DragAndDropModule,
|
|
53
|
+
ColumnMoveModule,
|
|
54
|
+
gridProColumnDragBridgeModule,
|
|
49
55
|
// ValidationModule,
|
|
50
56
|
]);
|
|
51
57
|
const DEBOUNCE_TIME = 400;
|
|
@@ -82,6 +88,10 @@ function findDeclaredAccessor(target, key) {
|
|
|
82
88
|
* @remarks Re-emits AG Grid public API events when listeners are registered via `addEventListener` (event names match AG Grid public event strings). The same AG Grid events are also dispatched as native `Event`s with lowercased `type` and payload on `agGridDetails` (for example `addEventListener('columnresized', ...)`).
|
|
83
89
|
*/
|
|
84
90
|
export class GridProBeta extends LifecycleMixin(FoundationElement) {
|
|
91
|
+
/** @internal Shared AG column-drag bridge for custom tool panels. */
|
|
92
|
+
getColumnDragBridge() {
|
|
93
|
+
return this.columnDragBridge;
|
|
94
|
+
}
|
|
85
95
|
rowDataChanged(_, rowData) {
|
|
86
96
|
// `initialised` flips true right after createGrid(), but `gridApi` is only assigned in the
|
|
87
97
|
// async onGridReady callback — so a binding push in that window would crash on an undefined
|
|
@@ -105,6 +115,21 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
|
|
|
105
115
|
this.initGrid();
|
|
106
116
|
}
|
|
107
117
|
}
|
|
118
|
+
sideBarConfigChanged() {
|
|
119
|
+
this.syncSideBarHostLayout();
|
|
120
|
+
if (this.hasSideBar && this.initialised && this.gridApi) {
|
|
121
|
+
this.applyCommunitySideBarOptions();
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
/** Whether the Community side bar is enabled (`sideBarConfig` is set). */
|
|
125
|
+
get hasSideBar() {
|
|
126
|
+
return this.sideBarConfig != null;
|
|
127
|
+
}
|
|
128
|
+
/** Tools from {@link GridProBeta.sideBarConfig} (empty when config is omitted). */
|
|
129
|
+
get resolvedSideBarTools() {
|
|
130
|
+
var _a, _b;
|
|
131
|
+
return (_b = (_a = this.sideBarConfig) === null || _a === void 0 ? void 0 : _a.tools) !== null && _b !== void 0 ? _b : [];
|
|
132
|
+
}
|
|
108
133
|
getfilterModel() {
|
|
109
134
|
return __awaiter(this, void 0, void 0, function* () {
|
|
110
135
|
if (!this.persistFilterModelKey) {
|
|
@@ -132,6 +157,8 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
|
|
|
132
157
|
// Coalesces bursts of column-visibility events (e.g. a "hide all" tool-panel toggle fires one
|
|
133
158
|
// per column) into a single datasource notification + reload.
|
|
134
159
|
this.debouncedNotifyDatasourceVisibleColumns = debounce(this.notifyDatasourceVisibleColumns.bind(this), DEBOUNCE_TIME);
|
|
160
|
+
/** Wired to `gridOptions.context` for columns picker → grid drag (see bridge module). */
|
|
161
|
+
this.columnDragBridge = {};
|
|
135
162
|
// Genesis-specific attrs
|
|
136
163
|
this.autoCellRendererByType = false;
|
|
137
164
|
this.onlyTemplateColDefs = false;
|
|
@@ -168,6 +195,11 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
|
|
|
168
195
|
* This requires AG Grid Enterprise module to be available for the status bar to be displayed when enabled.
|
|
169
196
|
*/
|
|
170
197
|
this.withStatusBar = false;
|
|
198
|
+
/**
|
|
199
|
+
* Side bar configuration. When set, enables the Community side-bar shell and its tool tabs.
|
|
200
|
+
* Omit for no side bar. Use {@link DEFAULT_SIDE_BAR_CONFIG} for Columns only.
|
|
201
|
+
*/
|
|
202
|
+
this.sideBarConfig = null;
|
|
171
203
|
this.applyingDatasourceGridOptions = false;
|
|
172
204
|
this.rehydrationAttempted = false;
|
|
173
205
|
this.rootEventsListeners = [];
|
|
@@ -293,6 +325,7 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
|
|
|
293
325
|
connectedCallback() {
|
|
294
326
|
var _a;
|
|
295
327
|
super.connectedCallback();
|
|
328
|
+
this.syncSideBarHostLayout();
|
|
296
329
|
this.disposed = false;
|
|
297
330
|
const luminanceTarget = (_a = this.provider) !== null && _a !== void 0 ? _a : this;
|
|
298
331
|
this.luminanceSubscription = baseLayerLuminance.subscribe(this.luminanceObserver, luminanceTarget);
|
|
@@ -369,6 +402,7 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
|
|
|
369
402
|
}
|
|
370
403
|
this.initialised = false;
|
|
371
404
|
this.resetGridOptionsState();
|
|
405
|
+
this.destroySideBarTools();
|
|
372
406
|
this.destroyGridInstance();
|
|
373
407
|
// Only remove datasource listeners on a real teardown. A blocked (reflow) disconnect must
|
|
374
408
|
// leave them in place, or a grid that survives the reflow stops reacting to datasource
|
|
@@ -680,6 +714,7 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
|
|
|
680
714
|
[GridProStatusBarTypes.loadMore]: LoadMoreStatusBarComponent,
|
|
681
715
|
[GridProStatusBarTypes.reload]: ReloadStatusBarComponent,
|
|
682
716
|
[GridProStatusBarTypes.rowCount]: RowCountStatusBarComponent,
|
|
717
|
+
[GridProToolPanelTypes.columns]: ColumnsToolPanel,
|
|
683
718
|
};
|
|
684
719
|
return Object.assign(Object.assign(Object.assign({}, defaultFoundationAgComponents), gridOptionsComponents), this.gridComponents);
|
|
685
720
|
}
|
|
@@ -903,6 +938,7 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
|
|
|
903
938
|
get gridParams() {
|
|
904
939
|
return {
|
|
905
940
|
globalListener: this.boundGlobalEventListener,
|
|
941
|
+
modules: [gridProColumnDragBridgeModule, ColumnMoveModule, DragAndDropModule],
|
|
906
942
|
};
|
|
907
943
|
}
|
|
908
944
|
/**
|
|
@@ -1012,6 +1048,10 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
|
|
|
1012
1048
|
this.restoreColumnState();
|
|
1013
1049
|
this.restoreCachedFilterConfig();
|
|
1014
1050
|
this.debouncedColumnAutosize();
|
|
1051
|
+
if (this.hasSideBar && this.sideBar) {
|
|
1052
|
+
this.sideBar.columnDragBridge = this.columnDragBridge;
|
|
1053
|
+
}
|
|
1054
|
+
DOM.queueUpdate(() => { var _a; return (_a = this.sideBar) === null || _a === void 0 ? void 0 : _a.mountActiveTool(); });
|
|
1015
1055
|
}), onFirstDataRendered: (event) => {
|
|
1016
1056
|
// Safety net: by now the grid columns are populated, so (re)seed the datasource's visible
|
|
1017
1057
|
// columns in case the initial grid-ready seed ran before columns were available.
|
|
@@ -1062,6 +1102,52 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
|
|
|
1062
1102
|
setLocalGridOptions(derivedOptions) {
|
|
1063
1103
|
// Merge options with reflected AG properties from attributes
|
|
1064
1104
|
this.agGridOptions = Object.assign(Object.assign({}, this.agGridOptions), copyAttributesToGridOptions(derivedOptions, this.agAttributes));
|
|
1105
|
+
if (this.hasSideBar) {
|
|
1106
|
+
this.applyCommunitySideBarOptions();
|
|
1107
|
+
}
|
|
1108
|
+
else {
|
|
1109
|
+
this.agGridOptions.sideBar = resolveGridProSideBar(this.agGridOptions.sideBar);
|
|
1110
|
+
}
|
|
1111
|
+
this.agGridOptions.context = Object.assign(Object.assign({}, this.agGridOptions.context), { [GRID_PRO_COLUMN_DRAG_BRIDGE_CONTEXT_KEY]: this.columnDragBridge });
|
|
1112
|
+
}
|
|
1113
|
+
applyCommunitySideBarOptions() {
|
|
1114
|
+
if (!this.agGridOptions) {
|
|
1115
|
+
return;
|
|
1116
|
+
}
|
|
1117
|
+
const toolPanels = resolveAgSideBarToolPanels(this.resolvedSideBarTools);
|
|
1118
|
+
this.agGridOptions.sideBar = toolPanels.length
|
|
1119
|
+
? {
|
|
1120
|
+
toolPanels,
|
|
1121
|
+
hiddenByDefault: true,
|
|
1122
|
+
hideButtons: true,
|
|
1123
|
+
}
|
|
1124
|
+
: undefined;
|
|
1125
|
+
this.agGridOptions.context = Object.assign(Object.assign({}, this.agGridOptions.context), { [GRID_PRO_COLUMN_DRAG_BRIDGE_CONTEXT_KEY]: this.columnDragBridge });
|
|
1126
|
+
if (this.agGridOptions.allowDragFromColumnsToolPanel == null) {
|
|
1127
|
+
this.agGridOptions.allowDragFromColumnsToolPanel = true;
|
|
1128
|
+
}
|
|
1129
|
+
if (this.gridApi && typeof this.gridApi.setGridOption === 'function') {
|
|
1130
|
+
this.gridApi.setGridOption('sideBar', this.agGridOptions.sideBar);
|
|
1131
|
+
this.gridApi.setGridOption('context', this.agGridOptions.context);
|
|
1132
|
+
if (this.agGridOptions.allowDragFromColumnsToolPanel) {
|
|
1133
|
+
this.gridApi.setGridOption('allowDragFromColumnsToolPanel', true);
|
|
1134
|
+
}
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
1137
|
+
/**
|
|
1138
|
+
* Selects a Community side-bar tool. Clicking the active open tool collapses the panel.
|
|
1139
|
+
* @public
|
|
1140
|
+
*/
|
|
1141
|
+
selectSideBarTool(tool) {
|
|
1142
|
+
var _a;
|
|
1143
|
+
(_a = this.sideBar) === null || _a === void 0 ? void 0 : _a.selectTool(tool);
|
|
1144
|
+
}
|
|
1145
|
+
syncSideBarHostLayout() {
|
|
1146
|
+
this.classList.toggle('has-side-bar', this.hasSideBar);
|
|
1147
|
+
}
|
|
1148
|
+
destroySideBarTools() {
|
|
1149
|
+
var _a;
|
|
1150
|
+
(_a = this.sideBar) === null || _a === void 0 ? void 0 : _a.destroyTools();
|
|
1065
1151
|
}
|
|
1066
1152
|
/**
|
|
1067
1153
|
* Clears the local grid options, this is used to clear the grid options when the grid is restarted.
|
|
@@ -1379,6 +1465,12 @@ __decorate([
|
|
|
1379
1465
|
__decorate([
|
|
1380
1466
|
attr({ mode: 'boolean', attribute: 'with-status-bar' })
|
|
1381
1467
|
], GridProBeta.prototype, "withStatusBar", void 0);
|
|
1468
|
+
__decorate([
|
|
1469
|
+
observable
|
|
1470
|
+
], GridProBeta.prototype, "sideBarConfig", void 0);
|
|
1471
|
+
__decorate([
|
|
1472
|
+
observable
|
|
1473
|
+
], GridProBeta.prototype, "sideBar", void 0);
|
|
1382
1474
|
__decorate([
|
|
1383
1475
|
observable
|
|
1384
1476
|
], GridProBeta.prototype, "customErrorHandlerTemplate", void 0);
|
package/dist/esm/grid-pro.js
CHANGED
|
@@ -332,7 +332,7 @@ export class GridPro extends LifecycleMixin(FoundationElement) {
|
|
|
332
332
|
* (e.g. disconnect before `grid-ready`), fall back to {@link Grid#destroy} on the vanilla wrapper.
|
|
333
333
|
*/
|
|
334
334
|
destroyGridInstance() {
|
|
335
|
-
var _a, _b;
|
|
335
|
+
var _a, _b, _c, _d;
|
|
336
336
|
if (this.gridApi) {
|
|
337
337
|
this.gridEventListeners.forEach((listener, eventType) => {
|
|
338
338
|
this.gridApi.removeEventListener(eventType, listener);
|
|
@@ -353,7 +353,7 @@ export class GridPro extends LifecycleMixin(FoundationElement) {
|
|
|
353
353
|
logger.debug('Grid Pro: failed to clear row data before destroy', e);
|
|
354
354
|
}
|
|
355
355
|
}
|
|
356
|
-
this.gridApi.destroy();
|
|
356
|
+
(_d = (_c = this.gridApi).destroy) === null || _d === void 0 ? void 0 : _d.call(_c);
|
|
357
357
|
}
|
|
358
358
|
else if (this.agGrid) {
|
|
359
359
|
this.agGrid.destroy();
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { alertFlashPhaseProperty } from '@genesislcap/foundation-ui';
|
|
2
2
|
import { css } from '@microsoft/fast-element';
|
|
3
|
+
import { columnsToolPanelStyles } from './columns-tool-panel/columns-tool-panel.styles';
|
|
3
4
|
import { errorHandlerDialogStyles } from './datasource/error-handler.dialog';
|
|
4
5
|
import { ROW_MATCH_ALERT_CELL_CLASS, ROW_MATCH_ALERT_CLASS } from './datasource/row-match.classes';
|
|
5
6
|
import { agExternalStockStyles } from './external';
|
|
7
|
+
import { gridProSideBarHostStyles } from './side-bar/side-bar.styles';
|
|
6
8
|
/**
|
|
7
9
|
* Workaround for an AG Grid (v36, still present in v36.1.0) drag-ghost positioning bug in
|
|
8
10
|
* shadow DOM. The row-drag "N rows" ghost is appended to the grid's containing shadow root
|
|
@@ -86,6 +88,8 @@ export const foundationGridProStyles = css `
|
|
|
86
88
|
${agExternalStockStyles}
|
|
87
89
|
${errorHandlerDialogStyles}
|
|
88
90
|
${agDragGhostShadowDomStyles}
|
|
91
|
+
${gridProSideBarHostStyles}
|
|
92
|
+
${columnsToolPanelStyles}
|
|
89
93
|
${rowMatchAlertStyles}
|
|
90
94
|
:host {
|
|
91
95
|
--datasource-error-background-color: var(--neutral-layer-4);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { html, ref } from '@microsoft/fast-element';
|
|
1
|
+
import { html, ref, when } from '@microsoft/fast-element';
|
|
2
2
|
import { getErrorHandlerDialogTemplate } from './datasource/error-handler.dialog';
|
|
3
3
|
/**
|
|
4
4
|
* Get a Design System prefixed The Grid Pro template.
|
|
@@ -12,6 +12,18 @@ export const getGridProTemplate = (prefix = 'foundation') => html `
|
|
|
12
12
|
<slot name="grid" ${ref('gridSlot')}></slot>
|
|
13
13
|
<slot></slot>
|
|
14
14
|
</span>
|
|
15
|
+
${when((x) => !!x.hasSideBar, html `
|
|
16
|
+
<grid-pro-side-bar
|
|
17
|
+
class="grid-pro-side-bar"
|
|
18
|
+
part="side-bar"
|
|
19
|
+
data-test-id="grid-pro-side-bar"
|
|
20
|
+
prefix="${() => prefix}"
|
|
21
|
+
${ref('sideBar')}
|
|
22
|
+
:tools="${(x) => x.resolvedSideBarTools}"
|
|
23
|
+
:gridApi="${(x) => x.gridApi}"
|
|
24
|
+
:columnDragBridge="${(x) => x.getColumnDragBridge()}"
|
|
25
|
+
></grid-pro-side-bar>
|
|
26
|
+
`)}
|
|
15
27
|
${(x) => x.customErrorHandlerTemplate
|
|
16
28
|
? x.customErrorHandlerTemplate(prefix, x.gridErrorItems.filter(({ type }) => type === 'datasource'))
|
|
17
29
|
: getErrorHandlerDialogTemplate(prefix, x.gridErrorItems.filter(({ type }) => type === 'datasource'))}
|
|
@@ -152,6 +152,17 @@ export var GridProStatusBarTypes;
|
|
|
152
152
|
GridProStatusBarTypes["reload"] = "reload";
|
|
153
153
|
GridProStatusBarTypes["rowCount"] = "rowCount";
|
|
154
154
|
})(GridProStatusBarTypes || (GridProStatusBarTypes = {}));
|
|
155
|
+
/**
|
|
156
|
+
* Custom Grid Pro tool panel component names.
|
|
157
|
+
* @public
|
|
158
|
+
* @remarks
|
|
159
|
+
* Registered for AG `sideBar` hosts (`SideBarModule` still required for that path).
|
|
160
|
+
* Prefer `sideBarConfig` on {@link GridProBeta} for a Community-only columns UI.
|
|
161
|
+
*/
|
|
162
|
+
export var GridProToolPanelTypes;
|
|
163
|
+
(function (GridProToolPanelTypes) {
|
|
164
|
+
GridProToolPanelTypes["columns"] = "gridProColumnsToolPanel";
|
|
165
|
+
})(GridProToolPanelTypes || (GridProToolPanelTypes = {}));
|
|
155
166
|
/**
|
|
156
167
|
* Event fired when grid is ready
|
|
157
168
|
* @public
|
package/dist/esm/index.js
CHANGED
|
@@ -2,6 +2,7 @@ export * from './cell';
|
|
|
2
2
|
export * from './cell-renderers';
|
|
3
3
|
export * from './cell-editors';
|
|
4
4
|
export * from './column';
|
|
5
|
+
export * from './columns-tool-panel';
|
|
5
6
|
export * from './datasource';
|
|
6
7
|
export * from './external';
|
|
7
8
|
export * from './grid-components';
|
|
@@ -13,6 +14,7 @@ export * from './grid-pro';
|
|
|
13
14
|
export * from './grid-pro-genesis-datasource';
|
|
14
15
|
export * from './multicolumn-dropdown';
|
|
15
16
|
export * from './row-alert';
|
|
17
|
+
export * from './side-bar';
|
|
16
18
|
export * from './state-persistence';
|
|
17
19
|
export * from './status-bar-components';
|
|
18
20
|
export * from './style';
|
|
@@ -24,6 +24,10 @@ function resolveStatePersistence(options) {
|
|
|
24
24
|
* a single preference: recolouring from one grid's menu is reflected in every other's.
|
|
25
25
|
*/
|
|
26
26
|
const storesByKey = new Map();
|
|
27
|
+
/** @internal Clears shared preference stores between tests. */
|
|
28
|
+
export function resetRowAlertPreferenceStoresForTesting() {
|
|
29
|
+
storesByKey.clear();
|
|
30
|
+
}
|
|
27
31
|
function createPreferenceStore(options) {
|
|
28
32
|
const { persistPreferencesKey, target, mirrorColorTo = [] } = options;
|
|
29
33
|
const statePersistence = persistPreferencesKey ? resolveStatePersistence(options) : undefined;
|