@genesislcap/grid-pro 15.17.0 → 15.18.0-FUI-2601.3
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 +9111 -7238
- 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 +28 -3
- package/dist/dts/grid-pro-beta.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 +29 -9
- 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 +417 -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 +12 -0
- package/dist/dts/side-bar/side-bar.tools.d.ts.map +1 -0
- package/dist/dts/side-bar/side-bar.types.d.ts +77 -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 +93 -3
- package/dist/esm/grid-pro.styles.js +4 -0
- package/dist/esm/grid-pro.template.js +19 -2
- package/dist/esm/grid-pro.types.js +11 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/side-bar/index.js +5 -0
- package/dist/esm/side-bar/side-bar.js +188 -0
- package/dist/esm/side-bar/side-bar.styles.js +155 -0
- package/dist/esm/side-bar/side-bar.template.js +48 -0
- package/dist/esm/side-bar/side-bar.tools.js +19 -0
- package/dist/esm/side-bar/side-bar.types.js +45 -0
- package/dist/grid-pro.api.json +10626 -7663
- package/dist/grid-pro.d.ts +968 -153
- package/dist/react.cjs +20 -6
- package/dist/react.mjs +17 -5
- 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: '1',
|
|
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 { GRID_PRO_DEFAULT_SIDE_BAR_TOOLS, 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,16 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
|
|
|
105
115
|
this.initGrid();
|
|
106
116
|
}
|
|
107
117
|
}
|
|
118
|
+
sideBarToolsChanged() {
|
|
119
|
+
if (this.withSideBar && this.initialised && this.gridApi) {
|
|
120
|
+
this.applyCommunitySideBarOptions();
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
/** Resolved tools list used by the template. */
|
|
124
|
+
get resolvedSideBarTools() {
|
|
125
|
+
var _a;
|
|
126
|
+
return ((_a = this.sideBarTools) === null || _a === void 0 ? void 0 : _a.length) ? this.sideBarTools : GRID_PRO_DEFAULT_SIDE_BAR_TOOLS;
|
|
127
|
+
}
|
|
108
128
|
getfilterModel() {
|
|
109
129
|
return __awaiter(this, void 0, void 0, function* () {
|
|
110
130
|
if (!this.persistFilterModelKey) {
|
|
@@ -132,6 +152,8 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
|
|
|
132
152
|
// Coalesces bursts of column-visibility events (e.g. a "hide all" tool-panel toggle fires one
|
|
133
153
|
// per column) into a single datasource notification + reload.
|
|
134
154
|
this.debouncedNotifyDatasourceVisibleColumns = debounce(this.notifyDatasourceVisibleColumns.bind(this), DEBOUNCE_TIME);
|
|
155
|
+
/** Wired to `gridOptions.context` for columns picker → grid drag (see bridge module). */
|
|
156
|
+
this.columnDragBridge = {};
|
|
135
157
|
// Genesis-specific attrs
|
|
136
158
|
this.autoCellRendererByType = false;
|
|
137
159
|
this.onlyTemplateColDefs = false;
|
|
@@ -168,6 +190,15 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
|
|
|
168
190
|
* This requires AG Grid Enterprise module to be available for the status bar to be displayed when enabled.
|
|
169
191
|
*/
|
|
170
192
|
this.withStatusBar = false;
|
|
193
|
+
/**
|
|
194
|
+
* Community side bar shell (no AG side-bar chrome). Tools come from `sideBarTools`.
|
|
195
|
+
*/
|
|
196
|
+
this.withSideBar = false;
|
|
197
|
+
/**
|
|
198
|
+
* Dynamic side-bar tools (Columns, AG Filters, custom `IToolPanelComp`, etc.).
|
|
199
|
+
* Defaults to {@link GRID_PRO_DEFAULT_SIDE_BAR_TOOLS} (Columns only).
|
|
200
|
+
*/
|
|
201
|
+
this.sideBarTools = null;
|
|
171
202
|
this.applyingDatasourceGridOptions = false;
|
|
172
203
|
this.rehydrationAttempted = false;
|
|
173
204
|
this.rootEventsListeners = [];
|
|
@@ -369,6 +400,7 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
|
|
|
369
400
|
}
|
|
370
401
|
this.initialised = false;
|
|
371
402
|
this.resetGridOptionsState();
|
|
403
|
+
this.destroySideBarTools();
|
|
372
404
|
this.destroyGridInstance();
|
|
373
405
|
// Only remove datasource listeners on a real teardown. A blocked (reflow) disconnect must
|
|
374
406
|
// leave them in place, or a grid that survives the reflow stops reacting to datasource
|
|
@@ -680,6 +712,7 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
|
|
|
680
712
|
[GridProStatusBarTypes.loadMore]: LoadMoreStatusBarComponent,
|
|
681
713
|
[GridProStatusBarTypes.reload]: ReloadStatusBarComponent,
|
|
682
714
|
[GridProStatusBarTypes.rowCount]: RowCountStatusBarComponent,
|
|
715
|
+
[GridProToolPanelTypes.columns]: ColumnsToolPanel,
|
|
683
716
|
};
|
|
684
717
|
return Object.assign(Object.assign(Object.assign({}, defaultFoundationAgComponents), gridOptionsComponents), this.gridComponents);
|
|
685
718
|
}
|
|
@@ -903,6 +936,7 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
|
|
|
903
936
|
get gridParams() {
|
|
904
937
|
return {
|
|
905
938
|
globalListener: this.boundGlobalEventListener,
|
|
939
|
+
modules: [gridProColumnDragBridgeModule, ColumnMoveModule, DragAndDropModule],
|
|
906
940
|
};
|
|
907
941
|
}
|
|
908
942
|
/**
|
|
@@ -1012,6 +1046,10 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
|
|
|
1012
1046
|
this.restoreColumnState();
|
|
1013
1047
|
this.restoreCachedFilterConfig();
|
|
1014
1048
|
this.debouncedColumnAutosize();
|
|
1049
|
+
if (this.withSideBar && this.sideBar) {
|
|
1050
|
+
this.sideBar.columnDragBridge = this.columnDragBridge;
|
|
1051
|
+
}
|
|
1052
|
+
DOM.queueUpdate(() => { var _a; return (_a = this.sideBar) === null || _a === void 0 ? void 0 : _a.mountActiveTool(); });
|
|
1015
1053
|
}), onFirstDataRendered: (event) => {
|
|
1016
1054
|
// Safety net: by now the grid columns are populated, so (re)seed the datasource's visible
|
|
1017
1055
|
// columns in case the initial grid-ready seed ran before columns were available.
|
|
@@ -1062,6 +1100,49 @@ export class GridProBeta extends LifecycleMixin(FoundationElement) {
|
|
|
1062
1100
|
setLocalGridOptions(derivedOptions) {
|
|
1063
1101
|
// Merge options with reflected AG properties from attributes
|
|
1064
1102
|
this.agGridOptions = Object.assign(Object.assign({}, this.agGridOptions), copyAttributesToGridOptions(derivedOptions, this.agAttributes));
|
|
1103
|
+
if (this.withSideBar) {
|
|
1104
|
+
this.applyCommunitySideBarOptions();
|
|
1105
|
+
}
|
|
1106
|
+
else {
|
|
1107
|
+
this.agGridOptions.sideBar = resolveGridProSideBar(this.agGridOptions.sideBar);
|
|
1108
|
+
}
|
|
1109
|
+
this.agGridOptions.context = Object.assign(Object.assign({}, this.agGridOptions.context), { [GRID_PRO_COLUMN_DRAG_BRIDGE_CONTEXT_KEY]: this.columnDragBridge });
|
|
1110
|
+
}
|
|
1111
|
+
applyCommunitySideBarOptions() {
|
|
1112
|
+
if (!this.agGridOptions) {
|
|
1113
|
+
return;
|
|
1114
|
+
}
|
|
1115
|
+
const toolPanels = resolveAgSideBarToolPanels(this.resolvedSideBarTools);
|
|
1116
|
+
this.agGridOptions.sideBar = toolPanels.length
|
|
1117
|
+
? {
|
|
1118
|
+
toolPanels,
|
|
1119
|
+
hiddenByDefault: true,
|
|
1120
|
+
hideButtons: true,
|
|
1121
|
+
}
|
|
1122
|
+
: undefined;
|
|
1123
|
+
this.agGridOptions.context = Object.assign(Object.assign({}, this.agGridOptions.context), { [GRID_PRO_COLUMN_DRAG_BRIDGE_CONTEXT_KEY]: this.columnDragBridge });
|
|
1124
|
+
if (this.agGridOptions.allowDragFromColumnsToolPanel == null) {
|
|
1125
|
+
this.agGridOptions.allowDragFromColumnsToolPanel = true;
|
|
1126
|
+
}
|
|
1127
|
+
if (this.gridApi && typeof this.gridApi.setGridOption === 'function') {
|
|
1128
|
+
this.gridApi.setGridOption('sideBar', this.agGridOptions.sideBar);
|
|
1129
|
+
this.gridApi.setGridOption('context', this.agGridOptions.context);
|
|
1130
|
+
if (this.agGridOptions.allowDragFromColumnsToolPanel) {
|
|
1131
|
+
this.gridApi.setGridOption('allowDragFromColumnsToolPanel', true);
|
|
1132
|
+
}
|
|
1133
|
+
}
|
|
1134
|
+
}
|
|
1135
|
+
/**
|
|
1136
|
+
* Selects a Community side-bar tool. Clicking the active open tool collapses the panel.
|
|
1137
|
+
* @public
|
|
1138
|
+
*/
|
|
1139
|
+
selectSideBarTool(tool) {
|
|
1140
|
+
var _a;
|
|
1141
|
+
(_a = this.sideBar) === null || _a === void 0 ? void 0 : _a.selectTool(tool);
|
|
1142
|
+
}
|
|
1143
|
+
destroySideBarTools() {
|
|
1144
|
+
var _a;
|
|
1145
|
+
(_a = this.sideBar) === null || _a === void 0 ? void 0 : _a.destroyTools();
|
|
1065
1146
|
}
|
|
1066
1147
|
/**
|
|
1067
1148
|
* Clears the local grid options, this is used to clear the grid options when the grid is restarted.
|
|
@@ -1379,6 +1460,15 @@ __decorate([
|
|
|
1379
1460
|
__decorate([
|
|
1380
1461
|
attr({ mode: 'boolean', attribute: 'with-status-bar' })
|
|
1381
1462
|
], GridProBeta.prototype, "withStatusBar", void 0);
|
|
1463
|
+
__decorate([
|
|
1464
|
+
attr({ mode: 'boolean', attribute: 'with-side-bar' })
|
|
1465
|
+
], GridProBeta.prototype, "withSideBar", void 0);
|
|
1466
|
+
__decorate([
|
|
1467
|
+
observable
|
|
1468
|
+
], GridProBeta.prototype, "sideBarTools", void 0);
|
|
1469
|
+
__decorate([
|
|
1470
|
+
observable
|
|
1471
|
+
], GridProBeta.prototype, "sideBar", void 0);
|
|
1382
1472
|
__decorate([
|
|
1383
1473
|
observable
|
|
1384
1474
|
], GridProBeta.prototype, "customErrorHandlerTemplate", void 0);
|
|
@@ -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,5 @@
|
|
|
1
|
-
import { html, ref } from '@microsoft/fast-element';
|
|
1
|
+
import { html, ref, when } from '@microsoft/fast-element';
|
|
2
|
+
import { classNames } from '@microsoft/fast-web-utilities';
|
|
2
3
|
import { getErrorHandlerDialogTemplate } from './datasource/error-handler.dialog';
|
|
3
4
|
/**
|
|
4
5
|
* Get a Design System prefixed The Grid Pro template.
|
|
@@ -8,10 +9,26 @@ import { getErrorHandlerDialogTemplate } from './datasource/error-handler.dialog
|
|
|
8
9
|
*/
|
|
9
10
|
export const getGridProTemplate = (prefix = 'foundation') => html `
|
|
10
11
|
<template>
|
|
11
|
-
<span
|
|
12
|
+
<span
|
|
13
|
+
part="grid"
|
|
14
|
+
data-ag-theme-mode=${(x) => x.themeMode}
|
|
15
|
+
class="${(x) => classNames(x.classNames, ['with-side-bar', !!x.withSideBar])}"
|
|
16
|
+
>
|
|
12
17
|
<slot name="grid" ${ref('gridSlot')}></slot>
|
|
13
18
|
<slot></slot>
|
|
14
19
|
</span>
|
|
20
|
+
${when((x) => !!x.withSideBar, html `
|
|
21
|
+
<grid-pro-side-bar
|
|
22
|
+
class="grid-pro-side-bar"
|
|
23
|
+
part="side-bar"
|
|
24
|
+
data-test-id="grid-pro-side-bar"
|
|
25
|
+
prefix="${() => prefix}"
|
|
26
|
+
${ref('sideBar')}
|
|
27
|
+
:tools="${(x) => x.resolvedSideBarTools}"
|
|
28
|
+
:gridApi="${(x) => x.gridApi}"
|
|
29
|
+
:columnDragBridge="${(x) => x.getColumnDragBridge()}"
|
|
30
|
+
></grid-pro-side-bar>
|
|
31
|
+
`)}
|
|
15
32
|
${(x) => x.customErrorHandlerTemplate
|
|
16
33
|
? x.customErrorHandlerTemplate(prefix, x.gridErrorItems.filter(({ type }) => type === 'datasource'))
|
|
17
34
|
: 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 `with-side-bar` 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';
|