@genesislcap/grid-pro 15.13.1 → 15.14.0-FUI-2601.2

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.
Files changed (56) hide show
  1. package/dist/custom-elements.json +1988 -563
  2. package/dist/dts/columns-tool-panel/columns-tool-panel.d.ts +98 -0
  3. package/dist/dts/columns-tool-panel/columns-tool-panel.d.ts.map +1 -0
  4. package/dist/dts/columns-tool-panel/columns-tool-panel.styles.d.ts +9 -0
  5. package/dist/dts/columns-tool-panel/columns-tool-panel.styles.d.ts.map +1 -0
  6. package/dist/dts/columns-tool-panel/columns-tool-panel.template.d.ts +12 -0
  7. package/dist/dts/columns-tool-panel/columns-tool-panel.template.d.ts.map +1 -0
  8. package/dist/dts/columns-tool-panel/columns-tool-panel.utils.d.ts +24 -0
  9. package/dist/dts/columns-tool-panel/columns-tool-panel.utils.d.ts.map +1 -0
  10. package/dist/dts/columns-tool-panel/index.d.ts +5 -0
  11. package/dist/dts/columns-tool-panel/index.d.ts.map +1 -0
  12. package/dist/dts/grid-pro-beta.d.ts +39 -4
  13. package/dist/dts/grid-pro-beta.d.ts.map +1 -1
  14. package/dist/dts/grid-pro.d.ts +10 -0
  15. package/dist/dts/grid-pro.d.ts.map +1 -1
  16. package/dist/dts/grid-pro.styles.d.ts.map +1 -1
  17. package/dist/dts/grid-pro.template.d.ts.map +1 -1
  18. package/dist/dts/grid-pro.types.d.ts +10 -0
  19. package/dist/dts/grid-pro.types.d.ts.map +1 -1
  20. package/dist/dts/index.d.ts +2 -0
  21. package/dist/dts/index.d.ts.map +1 -1
  22. package/dist/dts/react.d.ts +24 -4
  23. package/dist/dts/side-bar/index.d.ts +6 -0
  24. package/dist/dts/side-bar/index.d.ts.map +1 -0
  25. package/dist/dts/side-bar/side-bar.d.ts +412 -0
  26. package/dist/dts/side-bar/side-bar.d.ts.map +1 -0
  27. package/dist/dts/side-bar/side-bar.styles.d.ts +19 -0
  28. package/dist/dts/side-bar/side-bar.styles.d.ts.map +1 -0
  29. package/dist/dts/side-bar/side-bar.template.d.ts +11 -0
  30. package/dist/dts/side-bar/side-bar.template.d.ts.map +1 -0
  31. package/dist/dts/side-bar/side-bar.tools.d.ts +12 -0
  32. package/dist/dts/side-bar/side-bar.tools.d.ts.map +1 -0
  33. package/dist/dts/side-bar/side-bar.types.d.ts +77 -0
  34. package/dist/dts/side-bar/side-bar.types.d.ts.map +1 -0
  35. package/dist/esm/columns-tool-panel/columns-tool-panel.js +312 -0
  36. package/dist/esm/columns-tool-panel/columns-tool-panel.styles.js +122 -0
  37. package/dist/esm/columns-tool-panel/columns-tool-panel.template.js +79 -0
  38. package/dist/esm/columns-tool-panel/columns-tool-panel.utils.js +129 -0
  39. package/dist/esm/columns-tool-panel/index.js +4 -0
  40. package/dist/esm/grid-pro-beta.js +89 -3
  41. package/dist/esm/grid-pro.js +24 -1
  42. package/dist/esm/grid-pro.styles.js +4 -0
  43. package/dist/esm/grid-pro.template.js +18 -2
  44. package/dist/esm/grid-pro.types.js +11 -0
  45. package/dist/esm/index.js +2 -0
  46. package/dist/esm/side-bar/index.js +5 -0
  47. package/dist/esm/side-bar/side-bar.js +166 -0
  48. package/dist/esm/side-bar/side-bar.styles.js +154 -0
  49. package/dist/esm/side-bar/side-bar.template.js +48 -0
  50. package/dist/esm/side-bar/side-bar.tools.js +19 -0
  51. package/dist/esm/side-bar/side-bar.types.js +45 -0
  52. package/dist/grid-pro.api.json +8838 -6330
  53. package/dist/grid-pro.d.ts +906 -168
  54. package/dist/react.cjs +17 -3
  55. package/dist/react.mjs +14 -2
  56. package/package.json +14 -14
@@ -0,0 +1,312 @@
1
+ import { __decorate } from "tslib";
2
+ import { DOM, attr, customElement, observable } from '@microsoft/fast-element';
3
+ import { FoundationElement } from '@microsoft/fast-foundation';
4
+ import { columnsToolPanelStyles as styles } from './columns-tool-panel.styles';
5
+ import { columnsToolPanelTemplate } from './columns-tool-panel.template';
6
+ import { applyVisibleOrder, getPickerItems, partitionPickerItems, reorderVisibleIds, } from './columns-tool-panel.utils';
7
+ /**
8
+ * Custom columns tool panel. Replaces AG Grid Enterprise `agColumnsToolPanel`.
9
+ *
10
+ * @public
11
+ * @remarks
12
+ * Registered as `gridProColumnsToolPanel` (`GridProToolPanelTypes.columns`).
13
+ * `resolveGridProSideBar` rewrites `sideBar: ['columns']` / `agColumnsToolPanel` to this
14
+ * component when using AG's Enterprise `SideBarModule`.
15
+ *
16
+ * Prefer mounting via `with-side-bar` on {@link GridProBeta} for a Community-only UI
17
+ * that does not register any AG Enterprise modules.
18
+ *
19
+ * Layout: search → visible columns (drag to reorder) → divider → hidden columns.
20
+ * Checkboxes toggle visibility via `api.setColumnsVisible`; drag is limited to the
21
+ * visible list and disabled while a search filter is active.
22
+ *
23
+ * HTML Element: \<grid-pro-columns-tool-panel\>
24
+ */
25
+ let ColumnsToolPanel = class ColumnsToolPanel extends FoundationElement {
26
+ constructor() {
27
+ super(...arguments);
28
+ this.prefix = 'foundation';
29
+ /** Source colId while a visible-row drag is in progress. */
30
+ this.dragColId = null;
31
+ /** Row currently showing drag-over highlight (avoid observable updates mid-drag). */
32
+ this.dragOverElement = null;
33
+ /** Cancels row drag listeners when the selected list re-renders. */
34
+ this.dragBindingAbort = null;
35
+ /** Optimistic visibility while the grid applies setColumnsVisible. */
36
+ this.pendingVisibility = new Map();
37
+ this.search = '';
38
+ this.selectedItems = [];
39
+ this.unselectedItems = [];
40
+ /** Stable listener refs so `destroy` can remove the same functions `init` added. */
41
+ this.boundRefresh = () => this.refresh();
42
+ }
43
+ /** Drag reorder is only allowed on the full visible list (no active search). */
44
+ get canDrag() {
45
+ return !this.search.trim();
46
+ }
47
+ connectedCallback() {
48
+ var _a;
49
+ super.connectedCallback();
50
+ const sideBarPrefix = (_a = this.closest('grid-pro-side-bar')) === null || _a === void 0 ? void 0 : _a.getAttribute('prefix');
51
+ if (sideBarPrefix && sideBarPrefix !== this.prefix) {
52
+ this.prefix = sideBarPrefix;
53
+ }
54
+ this.classList.add('grid-pro-columns-tool-panel');
55
+ this.setAttribute('data-test-id', 'grid-pro-columns-tool-panel');
56
+ this.refresh();
57
+ }
58
+ /**
59
+ * AG Grid `IToolPanelComp` entry. Subscribes to column events so the picker
60
+ * stays in sync with header menu / API visibility changes.
61
+ */
62
+ init(params) {
63
+ this.params = params;
64
+ this.api = params.api;
65
+ this.api.addEventListener('columnVisible', this.boundRefresh);
66
+ this.api.addEventListener('columnMoved', this.boundRefresh);
67
+ this.api.addEventListener('newColumnsLoaded', this.boundRefresh);
68
+ this.api.addEventListener('displayedColumnsChanged', this.boundRefresh);
69
+ this.refresh();
70
+ }
71
+ /**
72
+ * Rebuilds both lists from current grid column state.
73
+ * Displayed columns stay first (grid order); hidden columns follow so search
74
+ * and drag operate on a single ordered picker model.
75
+ */
76
+ refresh() {
77
+ var _a, _b, _c, _d, _e, _f;
78
+ if (!this.api) {
79
+ return;
80
+ }
81
+ const activeElement = document.activeElement;
82
+ const activeTestId = activeElement && this.contains(activeElement)
83
+ ? activeElement.getAttribute('data-test-id')
84
+ : null;
85
+ const displayed = (_c = (_b = (_a = this.api).getAllDisplayedColumns) === null || _b === void 0 ? void 0 : _b.call(_a)) !== null && _c !== void 0 ? _c : [];
86
+ const all = (_f = (_e = (_d = this.api).getColumns) === null || _e === void 0 ? void 0 : _e.call(_d)) !== null && _f !== void 0 ? _f : [];
87
+ const displayedIds = new Set(displayed.map((column) => column.getColId()));
88
+ // Displayed first (current visual order), then any non-displayed columns.
89
+ const ordered = [...displayed, ...all.filter((column) => !displayedIds.has(column.getColId()))];
90
+ const items = this.applyPendingVisibility(getPickerItems(ordered));
91
+ const { selected, unselected } = partitionPickerItems(items, this.search);
92
+ this.selectedItems = selected;
93
+ this.unselectedItems = unselected;
94
+ if (activeTestId) {
95
+ DOM.queueUpdate(() => {
96
+ var _a;
97
+ (_a = this.querySelector(`[data-test-id="${activeTestId}"]`)) === null || _a === void 0 ? void 0 : _a.focus();
98
+ });
99
+ }
100
+ DOM.queueUpdate(() => this.bindSelectedRowDrag());
101
+ }
102
+ applyPendingVisibility(items) {
103
+ if (!this.pendingVisibility.size) {
104
+ return items;
105
+ }
106
+ return items.map((item) => {
107
+ const pending = this.pendingVisibility.get(item.colId);
108
+ if (pending === undefined) {
109
+ return item;
110
+ }
111
+ if (item.visible === pending) {
112
+ this.pendingVisibility.delete(item.colId);
113
+ }
114
+ return Object.assign(Object.assign({}, item), { visible: pending });
115
+ });
116
+ }
117
+ /** HTML5 drag on visible row handles only (disabled while search is active). */
118
+ bindSelectedRowDrag() {
119
+ var _a;
120
+ (_a = this.dragBindingAbort) === null || _a === void 0 ? void 0 : _a.abort();
121
+ this.dragBindingAbort = null;
122
+ if (!this.canDrag) {
123
+ return;
124
+ }
125
+ const rows = this.querySelectorAll('[data-test-id="grid-pro-columns-selected"] .grid-pro-columns-item');
126
+ if (!rows.length) {
127
+ return;
128
+ }
129
+ const abort = new AbortController();
130
+ this.dragBindingAbort = abort;
131
+ const { signal } = abort;
132
+ rows.forEach((row) => {
133
+ const colId = row.dataset.colId;
134
+ const handle = row.querySelector('.grid-pro-columns-handle');
135
+ if (!colId || !handle || handle.hidden) {
136
+ return;
137
+ }
138
+ handle.draggable = true;
139
+ handle.addEventListener('dragstart', (event) => {
140
+ this.onDragStart(event, colId, row);
141
+ }, { signal });
142
+ handle.addEventListener('dragend', () => this.onDragEnd(), { signal });
143
+ row.addEventListener('dragover', (event) => {
144
+ this.onDragOver(event, row);
145
+ }, { signal });
146
+ row.addEventListener('dragleave', (event) => {
147
+ this.onDragLeave(event, row);
148
+ }, { signal });
149
+ row.addEventListener('drop', (event) => {
150
+ this.onDrop(event, colId);
151
+ }, { signal });
152
+ });
153
+ }
154
+ /** Root element AG Grid mounts into the sidebar. */
155
+ getGui() {
156
+ return this;
157
+ }
158
+ destroy() {
159
+ var _a;
160
+ (_a = this.dragBindingAbort) === null || _a === void 0 ? void 0 : _a.abort();
161
+ this.dragBindingAbort = null;
162
+ this.pendingVisibility.clear();
163
+ if (this.api) {
164
+ this.api.removeEventListener('columnVisible', this.boundRefresh);
165
+ this.api.removeEventListener('columnMoved', this.boundRefresh);
166
+ this.api.removeEventListener('newColumnsLoaded', this.boundRefresh);
167
+ this.api.removeEventListener('displayedColumnsChanged', this.boundRefresh);
168
+ }
169
+ this.api = null;
170
+ }
171
+ /**
172
+ * @internal
173
+ */
174
+ onSearchInput(value) {
175
+ this.search = value;
176
+ this.refresh();
177
+ }
178
+ /**
179
+ * @internal
180
+ */
181
+ onCheckboxClick(item, event) {
182
+ event.preventDefault();
183
+ event.stopPropagation();
184
+ this.onVisibilityChange(item, !item.visible);
185
+ }
186
+ /**
187
+ * @internal
188
+ */
189
+ onVisibilityChange(item, visible) {
190
+ if (item.lockVisible || !this.api || item.visible === visible) {
191
+ return;
192
+ }
193
+ this.pendingVisibility.set(item.colId, visible);
194
+ this.api.setColumnsVisible([item.colId], visible);
195
+ this.refresh();
196
+ }
197
+ /**
198
+ * @internal
199
+ */
200
+ onDragStart(event, colId, row) {
201
+ if (!this.canDrag) {
202
+ event.preventDefault();
203
+ return;
204
+ }
205
+ this.dragColId = colId;
206
+ if (event.dataTransfer) {
207
+ event.dataTransfer.setData('text/plain', colId);
208
+ event.dataTransfer.effectAllowed = 'move';
209
+ }
210
+ (row !== null && row !== void 0 ? row : event.currentTarget).classList.add('dragging');
211
+ }
212
+ /**
213
+ * @internal
214
+ */
215
+ onDragEnd() {
216
+ this.dragColId = null;
217
+ this.clearDragOverHighlight();
218
+ this.querySelectorAll('.grid-pro-columns-item.dragging').forEach((row) => {
219
+ row.classList.remove('dragging');
220
+ });
221
+ }
222
+ /**
223
+ * @internal
224
+ */
225
+ onDragOver(event, row) {
226
+ var _a;
227
+ if (!this.canDrag) {
228
+ return;
229
+ }
230
+ event.preventDefault();
231
+ if (event.dataTransfer) {
232
+ event.dataTransfer.dropEffect = 'move';
233
+ }
234
+ if (this.dragOverElement !== row) {
235
+ (_a = this.dragOverElement) === null || _a === void 0 ? void 0 : _a.classList.remove('drag-over');
236
+ this.dragOverElement = row;
237
+ row.classList.add('drag-over');
238
+ }
239
+ }
240
+ /**
241
+ * @internal
242
+ */
243
+ onDragLeave(event, row) {
244
+ if (this.dragOverElement === row && !row.contains(event.relatedTarget)) {
245
+ row.classList.remove('drag-over');
246
+ this.dragOverElement = null;
247
+ }
248
+ }
249
+ /**
250
+ * @internal
251
+ */
252
+ onDrop(event, colId) {
253
+ var _a;
254
+ event.preventDefault();
255
+ this.clearDragOverHighlight();
256
+ const fromId = this.dragColId || ((_a = event.dataTransfer) === null || _a === void 0 ? void 0 : _a.getData('text/plain'));
257
+ if (fromId) {
258
+ this.reorderSelected(fromId, colId);
259
+ }
260
+ }
261
+ clearDragOverHighlight() {
262
+ var _a;
263
+ (_a = this.dragOverElement) === null || _a === void 0 ? void 0 : _a.classList.remove('drag-over');
264
+ this.dragOverElement = null;
265
+ }
266
+ /**
267
+ * Applies a new visible-column order via `applyColumnState({ applyOrder: true })`.
268
+ * Hidden columns keep their relative positions; only the visible slice is permuted.
269
+ */
270
+ reorderSelected(fromId, toId) {
271
+ var _a, _b, _c, _d, _e, _f;
272
+ if (!this.api || !this.api.getColumnState || !this.api.applyColumnState) {
273
+ return;
274
+ }
275
+ const displayed = (_c = (_b = (_a = this.api).getAllDisplayedColumns) === null || _b === void 0 ? void 0 : _b.call(_a)) !== null && _c !== void 0 ? _c : [];
276
+ const all = (_f = (_e = (_d = this.api).getColumns) === null || _e === void 0 ? void 0 : _e.call(_d)) !== null && _f !== void 0 ? _f : [];
277
+ const displayedIds = new Set(displayed.map((column) => column.getColId()));
278
+ const ordered = [...displayed, ...all.filter((column) => !displayedIds.has(column.getColId()))];
279
+ const items = getPickerItems(ordered);
280
+ const allVisibleIds = items.filter((item) => item.visible).map((item) => item.colId);
281
+ const { selected } = partitionPickerItems(items, this.search);
282
+ const nextOrder = reorderVisibleIds(allVisibleIds, selected.map((item) => item.colId), fromId, toId);
283
+ if (!nextOrder) {
284
+ return;
285
+ }
286
+ this.api.applyColumnState({
287
+ state: applyVisibleOrder(this.api.getColumnState(), nextOrder),
288
+ applyOrder: true,
289
+ });
290
+ }
291
+ };
292
+ __decorate([
293
+ attr
294
+ ], ColumnsToolPanel.prototype, "prefix", void 0);
295
+ __decorate([
296
+ observable
297
+ ], ColumnsToolPanel.prototype, "search", void 0);
298
+ __decorate([
299
+ observable
300
+ ], ColumnsToolPanel.prototype, "selectedItems", void 0);
301
+ __decorate([
302
+ observable
303
+ ], ColumnsToolPanel.prototype, "unselectedItems", void 0);
304
+ ColumnsToolPanel = __decorate([
305
+ customElement({
306
+ name: 'grid-pro-columns-tool-panel',
307
+ template: columnsToolPanelTemplate,
308
+ styles,
309
+ shadowOptions: null,
310
+ })
311
+ ], ColumnsToolPanel);
312
+ export { ColumnsToolPanel };
@@ -0,0 +1,122 @@
1
+ import { css } from '@microsoft/fast-element';
2
+ /**
3
+ * Styles for {@link ColumnsToolPanel}.
4
+ * Class selectors only — the element has no shadow root so styles land on the
5
+ * parent root (Grid Pro shadow / document); `:host` would target the wrong node.
6
+ * @public
7
+ */
8
+ export const columnsToolPanelStyles = css `
9
+ .grid-pro-columns-tool-panel {
10
+ display: flex;
11
+ flex-grow: 1;
12
+ flex-direction: column;
13
+ height: 100%;
14
+ min-width: 200px;
15
+ padding: 8px;
16
+ box-sizing: border-box;
17
+ color: var(--ag-foreground-color, var(--neutral-foreground-rest));
18
+ background: var(--ag-control-panel-background-color, var(--neutral-layer-2));
19
+ font-family: var(--ag-font-family, var(--body-font));
20
+ font-size: var(--ag-data-font-size, var(--type-ramp-minus-1-font-size));
21
+ }
22
+
23
+ .grid-pro-columns-search-wrap {
24
+ flex: 0 0 auto;
25
+ width: 100%;
26
+ margin-bottom: 8px;
27
+ }
28
+
29
+ .grid-pro-columns-search-wrap > * {
30
+ flex: 0 0 auto !important;
31
+ height: auto !important;
32
+ min-height: 0 !important;
33
+ width: 100%;
34
+ }
35
+
36
+ .grid-pro-columns-search {
37
+ width: 100%;
38
+ display: block;
39
+ }
40
+
41
+ .grid-pro-columns-list {
42
+ display: flex;
43
+ flex-direction: column;
44
+ gap: 2px;
45
+ flex: 1 1 0;
46
+ min-height: 0;
47
+ overflow: auto;
48
+ }
49
+
50
+ .grid-pro-columns-divider {
51
+ height: 1px;
52
+ margin: 8px 0;
53
+ background: var(--ag-border-color, var(--neutral-stroke-divider-rest));
54
+ flex-shrink: 0;
55
+ }
56
+
57
+ .grid-pro-columns-divider[hidden] {
58
+ display: none;
59
+ }
60
+
61
+ .grid-pro-columns-item {
62
+ display: flex;
63
+ align-items: center;
64
+ gap: 6px;
65
+ padding: 4px 6px;
66
+ border-radius: 4px;
67
+ cursor: default;
68
+ user-select: none;
69
+ }
70
+
71
+ .grid-pro-columns-item.dragging {
72
+ opacity: 0.5;
73
+ }
74
+
75
+ .grid-pro-columns-item.drag-over {
76
+ background: var(--ag-row-hover-color, var(--neutral-fill-hover));
77
+ }
78
+
79
+ .grid-pro-columns-handle {
80
+ flex: 0 0 auto;
81
+ display: inline-flex;
82
+ align-items: center;
83
+ justify-content: center;
84
+ min-width: 20px;
85
+ min-height: 24px;
86
+ margin: -4px 0;
87
+ padding: 4px 6px;
88
+ box-sizing: border-box;
89
+ opacity: 0.45;
90
+ letter-spacing: -1px;
91
+ font-size: 12px;
92
+ line-height: 1;
93
+ touch-action: none;
94
+ }
95
+
96
+ .grid-pro-columns-handle[draggable='true'] {
97
+ cursor: grab;
98
+ }
99
+
100
+ .grid-pro-columns-handle[draggable='true']:active {
101
+ cursor: grabbing;
102
+ }
103
+
104
+ .grid-pro-columns-item--unselected .grid-pro-columns-handle,
105
+ .grid-pro-columns-handle[hidden] {
106
+ visibility: hidden;
107
+ }
108
+
109
+ .grid-pro-columns-checkbox {
110
+ flex: 0 0 auto;
111
+ }
112
+
113
+ .grid-pro-columns-checkbox[aria-checked='true']:not([disabled]):hover::part(checked-indicator) {
114
+ fill: var(--foreground-on-accent-hover);
115
+ }
116
+
117
+ .grid-pro-columns-label {
118
+ overflow: hidden;
119
+ text-overflow: ellipsis;
120
+ white-space: nowrap;
121
+ }
122
+ `;
@@ -0,0 +1,79 @@
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
+ return html `
10
+ <template>
11
+ <div class="grid-pro-columns-search-wrap">
12
+ <${textField}
13
+ class="grid-pro-columns-search"
14
+ placeholder="Search"
15
+ data-test-id="grid-pro-columns-search"
16
+ :value="${(x) => x.search}"
17
+ @input="${(x, c) => x.onSearchInput(c.event.target.value)}"
18
+ ></${textField}>
19
+ </div>
20
+ <div class="grid-pro-columns-list" data-test-id="grid-pro-columns-selected">
21
+ ${repeat((x) => x.selectedItems, html `
22
+ <div
23
+ class="grid-pro-columns-item"
24
+ data-col-id="${(x) => x.colId}"
25
+ data-test-id="${(x) => `grid-pro-columns-item-${x.colId}`}"
26
+ >
27
+ <span
28
+ class="grid-pro-columns-handle"
29
+ data-test-id="${(x) => `grid-pro-columns-handle-${x.colId}`}"
30
+ ?hidden="${(x, c) => !c.parent.canDrag}"
31
+ aria-hidden="${(x, c) => String(!c.parent.canDrag)}"
32
+ >
33
+ ⋮⋮
34
+ </span>
35
+ <${checkbox}
36
+ class="grid-pro-columns-checkbox"
37
+ data-test-id="${(x) => `grid-pro-columns-check-${x.colId}`}"
38
+ ?checked="${(x) => x.visible}"
39
+ ?disabled="${(x) => x.lockVisible}"
40
+ @click="${(x, c) => c.parent.onCheckboxClick(x, c.event)}"
41
+ ></${checkbox}>
42
+ <span class="grid-pro-columns-label">${(x) => x.headerName}</span>
43
+ </div>
44
+ `, { recycle: false })}
45
+ </div>
46
+ <div
47
+ class="grid-pro-columns-divider"
48
+ data-test-id="grid-pro-columns-divider"
49
+ ?hidden="${(x) => !x.selectedItems.length || !x.unselectedItems.length}"
50
+ ></div>
51
+ <div class="grid-pro-columns-list" data-test-id="grid-pro-columns-unselected">
52
+ ${repeat((x) => x.unselectedItems, html `
53
+ <div
54
+ class="grid-pro-columns-item grid-pro-columns-item--unselected"
55
+ data-col-id="${(x) => x.colId}"
56
+ data-test-id="${(x) => `grid-pro-columns-item-${x.colId}`}"
57
+ >
58
+ <span class="grid-pro-columns-handle" aria-hidden="true"></span>
59
+ <${checkbox}
60
+ class="grid-pro-columns-checkbox"
61
+ data-test-id="${(x) => `grid-pro-columns-check-${x.colId}`}"
62
+ ?checked="${(x) => x.visible}"
63
+ ?disabled="${(x) => x.lockVisible}"
64
+ @click="${(x, c) => c.parent.onCheckboxClick(x, c.event)}"
65
+ ></${checkbox}>
66
+ <span class="grid-pro-columns-label">${(x) => x.headerName}</span>
67
+ </div>
68
+ `, { recycle: false })}
69
+ </div>
70
+ </template>
71
+ `;
72
+ };
73
+ /**
74
+ * Default columns tool panel template (`foundation-*` components).
75
+ * @public
76
+ */
77
+ export const columnsToolPanelTemplate = html `
78
+ ${(x) => getColumnsToolPanelTemplate(x.prefix || 'foundation')}
79
+ `;
@@ -0,0 +1,129 @@
1
+ import { GridProToolPanelTypes } from '../grid-pro.types';
2
+ export const gridProColumnsToolPanelDef = {
3
+ id: 'columns',
4
+ labelDefault: 'Columns',
5
+ labelKey: 'columns',
6
+ iconKey: 'columns',
7
+ toolPanel: GridProToolPanelTypes.columns,
8
+ };
9
+ const filtersToolPanelDef = {
10
+ id: 'filters',
11
+ labelDefault: 'Filters',
12
+ labelKey: 'filters',
13
+ iconKey: 'filter',
14
+ toolPanel: 'agFiltersToolPanel',
15
+ };
16
+ export function toPickerItem(col) {
17
+ const colDef = col.getColDef();
18
+ if (colDef.suppressColumnsToolPanel) {
19
+ return null;
20
+ }
21
+ if (typeof col.isPrimary === 'function' && !col.isPrimary()) {
22
+ return null;
23
+ }
24
+ const colId = col.getColId();
25
+ const headerName = String(colDef.headerName || colDef.field || colId || '');
26
+ return {
27
+ colId,
28
+ headerName,
29
+ visible: col.isVisible(),
30
+ lockVisible: Boolean(colDef.lockVisible),
31
+ };
32
+ }
33
+ export function getPickerItems(columns) {
34
+ return columns.map(toPickerItem).filter((item) => item != null);
35
+ }
36
+ export function partitionPickerItems(items, search) {
37
+ const query = search.trim().toLowerCase();
38
+ const matches = (item) => !query || item.headerName.toLowerCase().includes(query);
39
+ return {
40
+ selected: items.filter((item) => item.visible && matches(item)),
41
+ unselected: items
42
+ .filter((item) => !item.visible && matches(item))
43
+ .sort((a, b) => a.headerName.localeCompare(b.headerName, undefined, { sensitivity: 'base' })),
44
+ };
45
+ }
46
+ export function reorderVisibleIds(allVisibleIds, shownIds, fromId, toId) {
47
+ const shown = [...shownIds];
48
+ const fromIndex = shown.indexOf(fromId);
49
+ const toIndex = shown.indexOf(toId);
50
+ if (fromIndex < 0 || toIndex < 0 || fromId === toId) {
51
+ return null;
52
+ }
53
+ shown.splice(fromIndex, 1);
54
+ shown.splice(toIndex, 0, fromId);
55
+ let index = 0;
56
+ return allVisibleIds.map((id) => {
57
+ if (!shownIds.includes(id)) {
58
+ return id;
59
+ }
60
+ const nextId = shown[index];
61
+ index += 1;
62
+ return nextId;
63
+ });
64
+ }
65
+ export function applyVisibleOrder(columnState, visibleOrder) {
66
+ const byId = new Map(columnState.map((state) => [state.colId, state]));
67
+ let index = 0;
68
+ return columnState.map((state) => {
69
+ if (state.hide) {
70
+ return state;
71
+ }
72
+ const nextId = visibleOrder[index];
73
+ index += 1;
74
+ return (nextId && byId.get(nextId)) || state;
75
+ });
76
+ }
77
+ function isColumnsToolPanel(panel) {
78
+ if (panel === 'columns' || panel === 'agColumnsToolPanel') {
79
+ return true;
80
+ }
81
+ if (typeof panel === 'string') {
82
+ return false;
83
+ }
84
+ return (panel.toolPanel === 'agColumnsToolPanel' ||
85
+ panel.toolPanel === GridProToolPanelTypes.columns ||
86
+ panel.id === 'columns');
87
+ }
88
+ function toColumnsToolPanel(panel) {
89
+ if (typeof panel === 'string') {
90
+ return Object.assign({}, gridProColumnsToolPanelDef);
91
+ }
92
+ return Object.assign(Object.assign(Object.assign({}, gridProColumnsToolPanelDef), panel), { toolPanel: GridProToolPanelTypes.columns });
93
+ }
94
+ /**
95
+ * Rewrites `sideBar: ['columns']` / `agColumnsToolPanel` to the custom Grid Pro picker.
96
+ */
97
+ export function resolveGridProSideBar(sideBar) {
98
+ var _a;
99
+ if (!sideBar) {
100
+ return sideBar;
101
+ }
102
+ if (sideBar === true || sideBar === 'true') {
103
+ return {
104
+ toolPanels: [gridProColumnsToolPanelDef, filtersToolPanelDef],
105
+ defaultToolPanel: 'filters',
106
+ };
107
+ }
108
+ if (sideBar === 'columns' || sideBar === 'agColumnsToolPanel') {
109
+ return { toolPanels: [gridProColumnsToolPanelDef] };
110
+ }
111
+ if (typeof sideBar === 'string') {
112
+ return sideBar;
113
+ }
114
+ if (Array.isArray(sideBar)) {
115
+ if (!sideBar.some(isColumnsToolPanel)) {
116
+ return sideBar;
117
+ }
118
+ return {
119
+ toolPanels: sideBar.map((panel) => isColumnsToolPanel(panel) ? toColumnsToolPanel(panel) : panel),
120
+ };
121
+ }
122
+ if (!((_a = sideBar.toolPanels) === null || _a === void 0 ? void 0 : _a.length)) {
123
+ return sideBar;
124
+ }
125
+ if (!sideBar.toolPanels.some(isColumnsToolPanel)) {
126
+ return sideBar;
127
+ }
128
+ return Object.assign(Object.assign({}, sideBar), { toolPanels: sideBar.toolPanels.map((panel) => isColumnsToolPanel(panel) ? toColumnsToolPanel(panel) : panel) });
129
+ }
@@ -0,0 +1,4 @@
1
+ export * from './columns-tool-panel';
2
+ export * from './columns-tool-panel.styles';
3
+ export * from './columns-tool-panel.template';
4
+ export * from './columns-tool-panel.utils';