@genesislcap/grid-pro 15.25.1 → 15.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/dist/custom-elements.json +2209 -829
  2. package/dist/dts/column-selection/column-picker-ag-drag.d.ts +18 -0
  3. package/dist/dts/column-selection/column-picker-ag-drag.d.ts.map +1 -0
  4. package/dist/dts/column-selection/column-picker.utils.d.ts +50 -0
  5. package/dist/dts/column-selection/column-picker.utils.d.ts.map +1 -0
  6. package/dist/dts/column-selection/column-selection.d.ts +549 -0
  7. package/dist/dts/column-selection/column-selection.d.ts.map +1 -0
  8. package/dist/dts/column-selection/column-selection.styles.d.ts +11 -0
  9. package/dist/dts/column-selection/column-selection.styles.d.ts.map +1 -0
  10. package/dist/dts/column-selection/column-selection.template.d.ts +13 -0
  11. package/dist/dts/column-selection/column-selection.template.d.ts.map +1 -0
  12. package/dist/dts/column-selection/grid-pro-column-drag-bridge.d.ts +46 -0
  13. package/dist/dts/column-selection/grid-pro-column-drag-bridge.d.ts.map +1 -0
  14. package/dist/dts/column-selection/index.d.ts +8 -0
  15. package/dist/dts/column-selection/index.d.ts.map +1 -0
  16. package/dist/dts/column-selection/resolve-columns-picker-api.d.ts +23 -0
  17. package/dist/dts/column-selection/resolve-columns-picker-api.d.ts.map +1 -0
  18. package/dist/dts/grid-pro-beta.d.ts +12 -0
  19. package/dist/dts/grid-pro-beta.d.ts.map +1 -1
  20. package/dist/dts/grid-pro.styles.d.ts.map +1 -1
  21. package/dist/dts/grid-pro.template.d.ts.map +1 -1
  22. package/dist/dts/index.d.ts +1 -0
  23. package/dist/dts/index.d.ts.map +1 -1
  24. package/dist/dts/react.d.ts +19 -9
  25. package/dist/esm/column-selection/column-picker-ag-drag.js +52 -0
  26. package/dist/esm/column-selection/column-picker.utils.js +118 -0
  27. package/dist/esm/column-selection/column-selection.js +620 -0
  28. package/dist/esm/column-selection/column-selection.styles.js +236 -0
  29. package/dist/esm/column-selection/column-selection.template.js +96 -0
  30. package/dist/esm/column-selection/grid-pro-column-drag-bridge.js +62 -0
  31. package/dist/esm/column-selection/index.js +7 -0
  32. package/dist/esm/column-selection/resolve-columns-picker-api.js +42 -0
  33. package/dist/esm/grid-pro-beta.js +33 -2
  34. package/dist/esm/grid-pro.styles.js +2 -0
  35. package/dist/esm/grid-pro.template.js +8 -1
  36. package/dist/esm/index.js +1 -0
  37. package/dist/grid-pro.api.json +6820 -4409
  38. package/dist/grid-pro.d.ts +781 -46
  39. package/dist/react.cjs +13 -6
  40. package/dist/react.mjs +11 -5
  41. package/package.json +13 -13
@@ -0,0 +1,620 @@
1
+ import { __decorate } from "tslib";
2
+ import { LifecycleMixin } from '@genesislcap/foundation-utils';
3
+ import { attr, DOM, observable } from '@microsoft/fast-element';
4
+ import { FoundationElement } from '@microsoft/fast-foundation';
5
+ import { bindAgColumnPickerDrag } from './column-picker-ag-drag';
6
+ import { applyVisibleOrder, COLUMN_PICKER_SORT_DEFAULT, getPickerItems, orderColumnsForPicker, partitionPickerItems, reorderVisibleIds, resolveColumnPickerSort, } from './column-picker.utils';
7
+ import { columnSelectionStyles as styles } from './column-selection.styles';
8
+ import { getColumnSelectionTemplate } from './column-selection.template';
9
+ import { resolveColumnDragBridgeDirect, resolveColumnDragBridgeFromApi, } from './grid-pro-column-drag-bridge';
10
+ import { resolveColumnsPickerApi } from './resolve-columns-picker-api';
11
+ /** Max animation-frame retries while waiting for AG column-drag bridge beans. */
12
+ const DRAG_BRIDGE_RETRY_MAX_ATTEMPTS = 30;
13
+ /**
14
+ * Instance API storage — keeps a stable binding across LifecycleMixin + FAST
15
+ * field-init / suite isolation (plain `private` was null after connectPicker in CI).
16
+ */
17
+ const pickerApiByElement = new WeakMap();
18
+ /**
19
+ * Button + popover column picker for Grid Pro (Community).
20
+ *
21
+ * @public
22
+ * @remarks
23
+ * HTML Element: \<%%prefix%%-column-selection\>
24
+ *
25
+ * Provide either `:gridApi` (AG v36) or `:gridHost` (Grid Pro element with `gridApi` / `columnApi`).
26
+ *
27
+ * The panel uses the Popover API (`popover="manual"`) so it paints in the top layer and is not
28
+ * clipped by layout ancestors with `overflow: hidden`. Placement is pure CSS (anchor positioning
29
+ * via `showPopover({ source })` + `position-area`).
30
+ *
31
+ * Layout: select-all + search → column list. Ordering via `sort`
32
+ * (`selected-first` default, or `ag-grid`). Checkboxes toggle visibility via
33
+ * `api.setColumnsVisible`; drag handles on hidden rows use AG native DnD onto the grid
34
+ * (`allowDragFromColumnsToolPanel`); visible rows reorder inside the picker via HTML5 drag.
35
+ *
36
+ * @tagname %%prefix%%-column-selection
37
+ */
38
+ export class ColumnSelection extends LifecycleMixin(FoundationElement) {
39
+ constructor() {
40
+ super(...arguments);
41
+ /** Button label. */
42
+ this.label = 'Column Selection';
43
+ /**
44
+ * Column list ordering.
45
+ * - `selected-first` (default): visible first (grid display order), then hidden A–Z.
46
+ * - `ag-grid`: `api.getColumnState()` order (visible/hidden interleaved).
47
+ */
48
+ this.sort = COLUMN_PICKER_SORT_DEFAULT;
49
+ /** Whether the popover is open. */
50
+ this.open = false;
51
+ /** Optional explicit AG grid API (v36). */
52
+ this.gridApi = null;
53
+ /** Grid Pro host element; column API is bridged when needed. */
54
+ this.gridHost = null;
55
+ this.search = '';
56
+ this.selectedItems = [];
57
+ this.unselectedItems = [];
58
+ /** Master checkbox checked when every toggleable column is visible. */
59
+ this.selectAllChecked = false;
60
+ /** Master checkbox mixed when some (but not all) toggleable columns are visible. */
61
+ this.selectAllIndeterminate = false;
62
+ /** Resolved sort; kept in sync with `@attr sort`. */
63
+ this.resolvedSort = COLUMN_PICKER_SORT_DEFAULT;
64
+ /** Source colId while a visible-row drag is in progress. */
65
+ this.dragColId = null;
66
+ /** Row currently showing drag-over highlight (avoid observable updates mid-drag). */
67
+ this.dragOverElement = null;
68
+ /** Cancels row drag listeners when the selected list re-renders. */
69
+ this.dragBindingAbort = null;
70
+ /** AG ToolPanel drag sources registered on hidden-row handles (grid drop). */
71
+ this.agDragBindings = [];
72
+ /** Shared DnD bridge from Grid Pro. */
73
+ this.columnDragBridge = null;
74
+ /** Retries `bindRowDrag` until the DnD bridge is populated. */
75
+ this.dragBridgeRetryId = 0;
76
+ /** Optimistic visibility while the grid applies setColumnsVisible. */
77
+ this.pendingVisibility = new Map();
78
+ /** Stable listener refs so close/disconnect can remove the same functions. */
79
+ this.boundRefresh = () => this.refresh();
80
+ this.handleClickOutside = (event) => {
81
+ if (!this.open || !this.root || !event.isTrusted) {
82
+ return;
83
+ }
84
+ if (!event.composedPath().includes(this.root)) {
85
+ this.open = false;
86
+ }
87
+ };
88
+ }
89
+ get pickerApi() {
90
+ var _a;
91
+ return (_a = pickerApiByElement.get(this)) !== null && _a !== void 0 ? _a : null;
92
+ }
93
+ set pickerApi(api) {
94
+ pickerApiByElement.set(this, api);
95
+ }
96
+ /** Query root for picker DOM (shadow panel). */
97
+ get pickerRoot() {
98
+ var _a;
99
+ return (_a = this.panelEl) !== null && _a !== void 0 ? _a : null;
100
+ }
101
+ /** Drag reorder / grid drop disabled while search filter is active. */
102
+ get canDrag() {
103
+ return !this.search.trim();
104
+ }
105
+ /** Handle is draggable onto the grid (hidden columns, or all when using ag-grid sort). */
106
+ canDragToGrid(item) {
107
+ if (!this.canDrag || item.lockVisible) {
108
+ return false;
109
+ }
110
+ if (this.resolvedSort === 'ag-grid') {
111
+ return true;
112
+ }
113
+ return !item.visible;
114
+ }
115
+ /** Columns in the current (search-filtered) picker lists that can be toggled. */
116
+ get toggleableItems() {
117
+ return [...this.selectedItems, ...this.unselectedItems].filter((item) => !item.lockVisible);
118
+ }
119
+ openChanged(oldValue) {
120
+ // Skip field-init notification before other private fields are constructed.
121
+ if (oldValue === undefined || !this.$fastController.isConnected) {
122
+ return;
123
+ }
124
+ if (this.open) {
125
+ DOM.queueUpdate(() => {
126
+ this.subscribePicker();
127
+ this.refresh();
128
+ this.showPanel();
129
+ // Defer listener — showPopover can emit a same-turn mousedown outside the root.
130
+ requestAnimationFrame(() => {
131
+ if (this.open) {
132
+ document.addEventListener('mousedown', this.handleClickOutside);
133
+ }
134
+ });
135
+ });
136
+ }
137
+ else {
138
+ document.removeEventListener('mousedown', this.handleClickOutside);
139
+ this.unsubscribePicker();
140
+ this.hidePanel();
141
+ }
142
+ }
143
+ sortChanged() {
144
+ this.resolvedSort = resolveColumnPickerSort(this.sort);
145
+ if (this.open) {
146
+ this.refresh();
147
+ }
148
+ }
149
+ gridApiChanged() {
150
+ if (this.open) {
151
+ this.resubscribePicker();
152
+ }
153
+ }
154
+ gridHostChanged() {
155
+ if (this.open) {
156
+ this.resubscribePicker();
157
+ }
158
+ }
159
+ panelElChanged() {
160
+ if (this.open) {
161
+ DOM.queueUpdate(() => {
162
+ this.refresh();
163
+ this.showPanel();
164
+ });
165
+ }
166
+ }
167
+ /**
168
+ * Subscribe to grid column events and rebuild picker lists.
169
+ * Called automatically when the popover opens; exposed for tests/hosts that need an early bind.
170
+ * @internal
171
+ */
172
+ connectPicker() {
173
+ this.subscribePicker();
174
+ this.refresh();
175
+ }
176
+ /**
177
+ * Opens or closes the popover.
178
+ * @public
179
+ */
180
+ toggle() {
181
+ this.open = !this.open;
182
+ }
183
+ /**
184
+ * Closes the popover.
185
+ * @public
186
+ */
187
+ close() {
188
+ this.open = false;
189
+ }
190
+ /**
191
+ * Rebuilds picker lists from current grid column state.
192
+ */
193
+ refresh() {
194
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
195
+ this.resolvedSort = resolveColumnPickerSort(this.sort);
196
+ if (!this.pickerApi) {
197
+ return;
198
+ }
199
+ const root = this.pickerRoot;
200
+ const activeElement = document.activeElement;
201
+ const activeTestId = activeElement && (root === null || root === void 0 ? void 0 : root.contains(activeElement))
202
+ ? activeElement.getAttribute('data-test-id')
203
+ : null;
204
+ const displayed = (_c = (_b = (_a = this.pickerApi).getAllDisplayedColumns) === null || _b === void 0 ? void 0 : _b.call(_a)) !== null && _c !== void 0 ? _c : [];
205
+ const all = (_f = (_e = (_d = this.pickerApi).getColumns) === null || _e === void 0 ? void 0 : _e.call(_d)) !== null && _f !== void 0 ? _f : [];
206
+ const columnState = (_j = (_h = (_g = this.pickerApi).getColumnState) === null || _h === void 0 ? void 0 : _h.call(_g)) !== null && _j !== void 0 ? _j : [];
207
+ const ordered = orderColumnsForPicker(displayed, all, this.resolvedSort, columnState);
208
+ const items = this.applyPendingVisibility(getPickerItems(ordered));
209
+ const { selected, unselected } = partitionPickerItems(items, this.search, this.resolvedSort);
210
+ this.selectedItems = selected;
211
+ this.unselectedItems = unselected;
212
+ this.syncSelectAllState();
213
+ if (activeTestId && root) {
214
+ DOM.queueUpdate(() => {
215
+ var _a;
216
+ (_a = root.querySelector(`[data-test-id="${activeTestId}"]`)) === null || _a === void 0 ? void 0 : _a.focus();
217
+ });
218
+ }
219
+ DOM.queueUpdate(() => {
220
+ this.bindRowDrag();
221
+ });
222
+ }
223
+ disconnectedCallback() {
224
+ document.removeEventListener('mousedown', this.handleClickOutside);
225
+ this.hidePanel();
226
+ this.unsubscribePicker();
227
+ this.open = false;
228
+ super.disconnectedCallback();
229
+ }
230
+ showPanel() {
231
+ const panel = this.panelEl;
232
+ if (!panel || typeof panel.showPopover !== 'function') {
233
+ return;
234
+ }
235
+ if (panel.matches(':popover-open')) {
236
+ return;
237
+ }
238
+ // `source` sets the implicit CSS anchor for position-area / anchor().
239
+ try {
240
+ panel.showPopover({
241
+ source: this.buttonEl,
242
+ });
243
+ }
244
+ catch (_a) {
245
+ panel.showPopover();
246
+ }
247
+ }
248
+ hidePanel() {
249
+ const panel = this.panelEl;
250
+ if (!panel || typeof panel.hidePopover !== 'function') {
251
+ return;
252
+ }
253
+ if (panel.matches(':popover-open')) {
254
+ panel.hidePopover();
255
+ }
256
+ }
257
+ subscribePicker() {
258
+ var _a, _b, _c;
259
+ const api = resolveColumnsPickerApi(this.gridHost, this.gridApi);
260
+ if (api && this.pickerApi === api) {
261
+ return;
262
+ }
263
+ this.unsubscribePicker();
264
+ if (!api) {
265
+ return;
266
+ }
267
+ this.pickerApi = api;
268
+ this.columnDragBridge = (_c = (_b = (_a = this.gridHost) === null || _a === void 0 ? void 0 : _a.getColumnDragBridge) === null || _b === void 0 ? void 0 : _b.call(_a)) !== null && _c !== void 0 ? _c : null;
269
+ this.resolvedSort = resolveColumnPickerSort(this.sort);
270
+ this.pickerApi.addEventListener('columnVisible', this.boundRefresh);
271
+ this.pickerApi.addEventListener('columnMoved', this.boundRefresh);
272
+ this.pickerApi.addEventListener('newColumnsLoaded', this.boundRefresh);
273
+ this.pickerApi.addEventListener('displayedColumnsChanged', this.boundRefresh);
274
+ }
275
+ resubscribePicker() {
276
+ this.subscribePicker();
277
+ this.refresh();
278
+ }
279
+ unsubscribePicker() {
280
+ var _a;
281
+ this.dragBridgeRetryId += 1;
282
+ (_a = this.dragBindingAbort) === null || _a === void 0 ? void 0 : _a.abort();
283
+ this.dragBindingAbort = null;
284
+ for (const binding of this.agDragBindings) {
285
+ binding.remove();
286
+ }
287
+ this.agDragBindings = [];
288
+ this.pendingVisibility.clear();
289
+ if (this.pickerApi) {
290
+ this.pickerApi.removeEventListener('columnVisible', this.boundRefresh);
291
+ this.pickerApi.removeEventListener('columnMoved', this.boundRefresh);
292
+ this.pickerApi.removeEventListener('newColumnsLoaded', this.boundRefresh);
293
+ this.pickerApi.removeEventListener('displayedColumnsChanged', this.boundRefresh);
294
+ }
295
+ this.pickerApi = null;
296
+ }
297
+ syncSelectAllState() {
298
+ const items = this.toggleableItems;
299
+ const visibleCount = items.filter((item) => item.visible).length;
300
+ this.selectAllChecked = items.length > 0 && visibleCount === items.length;
301
+ this.selectAllIndeterminate = visibleCount > 0 && visibleCount < items.length;
302
+ }
303
+ applyPendingVisibility(items) {
304
+ if (!this.pendingVisibility.size) {
305
+ return items;
306
+ }
307
+ return items.map((item) => {
308
+ const pending = this.pendingVisibility.get(item.colId);
309
+ if (pending === undefined) {
310
+ return item;
311
+ }
312
+ if (item.visible === pending) {
313
+ this.pendingVisibility.delete(item.colId);
314
+ }
315
+ return Object.assign(Object.assign({}, item), { visible: pending });
316
+ });
317
+ }
318
+ resolveDragBridge() {
319
+ var _a;
320
+ return ((_a = resolveColumnDragBridgeDirect(this.columnDragBridge)) !== null && _a !== void 0 ? _a : resolveColumnDragBridgeFromApi(this.pickerApi));
321
+ }
322
+ /**
323
+ * Visible rows: HTML5 reorder inside the picker.
324
+ * Hidden rows (or all rows when `sort=ag-grid`): AG ToolPanel drag onto the grid header.
325
+ */
326
+ bindRowDrag() {
327
+ var _a;
328
+ (_a = this.dragBindingAbort) === null || _a === void 0 ? void 0 : _a.abort();
329
+ this.dragBindingAbort = null;
330
+ for (const binding of this.agDragBindings) {
331
+ binding.remove();
332
+ }
333
+ this.agDragBindings = [];
334
+ const root = this.pickerRoot;
335
+ if (!this.canDrag || !this.pickerApi || !root) {
336
+ return;
337
+ }
338
+ const bridge = this.resolveDragBridge();
339
+ const rows = root.querySelectorAll('.grid-pro-columns-item');
340
+ if (!rows.length) {
341
+ return;
342
+ }
343
+ const abort = new AbortController();
344
+ this.dragBindingAbort = abort;
345
+ const { signal } = abort;
346
+ let needsBridgeRetry = false;
347
+ let boundGridDrag = false;
348
+ rows.forEach((row) => {
349
+ const colId = row.dataset.colId;
350
+ const handle = row.querySelector('.grid-pro-columns-handle');
351
+ if (!colId || !handle) {
352
+ return;
353
+ }
354
+ handle.classList.remove('grid-pro-columns-handle-grid-drag', 'grid-pro-columns-handle-panel-drag');
355
+ handle.removeAttribute('draggable');
356
+ const item = [...this.selectedItems, ...this.unselectedItems].find((i) => i.colId === colId);
357
+ if (!item) {
358
+ return;
359
+ }
360
+ const dragToGrid = this.canDragToGrid(item);
361
+ const reorderInPanel = this.resolvedSort === 'selected-first' &&
362
+ item.visible &&
363
+ !row.classList.contains('grid-pro-columns-item--unselected');
364
+ if (dragToGrid) {
365
+ if (bridge) {
366
+ const binding = bindAgColumnPickerDrag(bridge, this.pickerApi, handle, colId, item.headerName);
367
+ if (binding) {
368
+ boundGridDrag = true;
369
+ this.agDragBindings.push(binding);
370
+ handle.classList.add('grid-pro-columns-handle-grid-drag');
371
+ if (!reorderInPanel) {
372
+ return;
373
+ }
374
+ }
375
+ }
376
+ else {
377
+ needsBridgeRetry = true;
378
+ }
379
+ }
380
+ if (!reorderInPanel) {
381
+ return;
382
+ }
383
+ handle.draggable = true;
384
+ handle.classList.add('grid-pro-columns-handle-panel-drag');
385
+ handle.addEventListener('dragstart', (event) => {
386
+ this.onDragStart(event, colId, row);
387
+ }, { signal });
388
+ handle.addEventListener('dragend', () => this.onDragEnd(), { signal });
389
+ row.addEventListener('dragover', (event) => {
390
+ this.onDragOver(event, row);
391
+ }, { signal });
392
+ row.addEventListener('dragleave', (event) => {
393
+ this.onDragLeave(event, row);
394
+ }, { signal });
395
+ row.addEventListener('drop', (event) => {
396
+ this.onDrop(event, colId);
397
+ }, { signal });
398
+ });
399
+ if (needsBridgeRetry && !boundGridDrag) {
400
+ this.scheduleDragBridgeRetry();
401
+ }
402
+ }
403
+ scheduleDragBridgeRetry(attempt = 0) {
404
+ if (attempt > DRAG_BRIDGE_RETRY_MAX_ATTEMPTS || !this.pickerApi || !this.canDrag) {
405
+ return;
406
+ }
407
+ this.dragBridgeRetryId += 1;
408
+ const retryId = this.dragBridgeRetryId;
409
+ requestAnimationFrame(() => {
410
+ if (retryId !== this.dragBridgeRetryId || !this.isConnected) {
411
+ return;
412
+ }
413
+ if (this.resolveDragBridge()) {
414
+ this.bindRowDrag();
415
+ return;
416
+ }
417
+ this.scheduleDragBridgeRetry(attempt + 1);
418
+ });
419
+ }
420
+ /**
421
+ * @internal
422
+ */
423
+ onSearchInput(value) {
424
+ this.search = value;
425
+ this.refresh();
426
+ }
427
+ /**
428
+ * @internal
429
+ */
430
+ onSelectAllClick(event) {
431
+ var _a, _b;
432
+ (_a = event.preventDefault) === null || _a === void 0 ? void 0 : _a.call(event);
433
+ (_b = event.stopImmediatePropagation) === null || _b === void 0 ? void 0 : _b.call(event);
434
+ if (!this.pickerApi) {
435
+ return;
436
+ }
437
+ const items = this.toggleableItems;
438
+ if (!items.length) {
439
+ return;
440
+ }
441
+ const makeVisible = !this.selectAllChecked;
442
+ const ids = items.filter((item) => item.visible !== makeVisible).map((item) => item.colId);
443
+ if (!ids.length) {
444
+ return;
445
+ }
446
+ for (const id of ids) {
447
+ this.pendingVisibility.set(id, makeVisible);
448
+ }
449
+ this.pickerApi.setColumnsVisible(ids, makeVisible);
450
+ this.refresh();
451
+ }
452
+ /**
453
+ * @internal
454
+ */
455
+ onCheckboxClick(item, event) {
456
+ event.preventDefault();
457
+ event.stopPropagation();
458
+ this.onVisibilityChange(item, !item.visible);
459
+ }
460
+ /**
461
+ * @internal
462
+ */
463
+ onVisibilityChange(item, visible) {
464
+ if (item.lockVisible || !this.pickerApi || item.visible === visible) {
465
+ return;
466
+ }
467
+ this.pendingVisibility.set(item.colId, visible);
468
+ this.pickerApi.setColumnsVisible([item.colId], visible);
469
+ this.refresh();
470
+ }
471
+ /**
472
+ * @internal
473
+ */
474
+ onDragStart(event, colId, row) {
475
+ if (!this.canDrag) {
476
+ event.preventDefault();
477
+ return;
478
+ }
479
+ this.dragColId = colId;
480
+ if (event.dataTransfer) {
481
+ event.dataTransfer.setData('text/plain', colId);
482
+ event.dataTransfer.effectAllowed = 'move';
483
+ }
484
+ (row !== null && row !== void 0 ? row : event.currentTarget).classList.add('dragging');
485
+ }
486
+ /**
487
+ * @internal
488
+ */
489
+ onDragEnd() {
490
+ var _a;
491
+ this.dragColId = null;
492
+ this.clearDragOverHighlight();
493
+ (_a = this.pickerRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll('.grid-pro-columns-item.dragging').forEach((row) => {
494
+ row.classList.remove('dragging');
495
+ });
496
+ }
497
+ /**
498
+ * @internal
499
+ */
500
+ onDragOver(event, row) {
501
+ var _a;
502
+ if (!this.canDrag) {
503
+ return;
504
+ }
505
+ event.preventDefault();
506
+ if (event.dataTransfer) {
507
+ event.dataTransfer.dropEffect = 'move';
508
+ }
509
+ if (this.dragOverElement !== row) {
510
+ (_a = this.dragOverElement) === null || _a === void 0 ? void 0 : _a.classList.remove('drag-over');
511
+ this.dragOverElement = row;
512
+ row.classList.add('drag-over');
513
+ }
514
+ }
515
+ /**
516
+ * @internal
517
+ */
518
+ onDragLeave(event, row) {
519
+ if (this.dragOverElement === row && !row.contains(event.relatedTarget)) {
520
+ row.classList.remove('drag-over');
521
+ this.dragOverElement = null;
522
+ }
523
+ }
524
+ /**
525
+ * @internal
526
+ */
527
+ onDrop(event, colId) {
528
+ var _a;
529
+ event.preventDefault();
530
+ this.clearDragOverHighlight();
531
+ const fromId = this.dragColId || ((_a = event.dataTransfer) === null || _a === void 0 ? void 0 : _a.getData('text/plain'));
532
+ if (fromId) {
533
+ this.reorderSelected(fromId, colId);
534
+ }
535
+ }
536
+ clearDragOverHighlight() {
537
+ var _a;
538
+ (_a = this.dragOverElement) === null || _a === void 0 ? void 0 : _a.classList.remove('drag-over');
539
+ this.dragOverElement = null;
540
+ }
541
+ /**
542
+ * Applies a new visible-column order via `applyColumnState({ applyOrder: true })`.
543
+ * Hidden columns keep their relative positions; only the visible slice is permuted.
544
+ */
545
+ reorderSelected(fromId, toId) {
546
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
547
+ if (!this.pickerApi || !this.pickerApi.getColumnState || !this.pickerApi.applyColumnState) {
548
+ return;
549
+ }
550
+ const displayed = (_c = (_b = (_a = this.pickerApi).getAllDisplayedColumns) === null || _b === void 0 ? void 0 : _b.call(_a)) !== null && _c !== void 0 ? _c : [];
551
+ const all = (_f = (_e = (_d = this.pickerApi).getColumns) === null || _e === void 0 ? void 0 : _e.call(_d)) !== null && _f !== void 0 ? _f : [];
552
+ const columnState = (_j = (_h = (_g = this.pickerApi).getColumnState) === null || _h === void 0 ? void 0 : _h.call(_g)) !== null && _j !== void 0 ? _j : [];
553
+ const ordered = orderColumnsForPicker(displayed, all, this.resolvedSort, columnState);
554
+ const items = getPickerItems(ordered);
555
+ const allVisibleIds = items.filter((item) => item.visible).map((item) => item.colId);
556
+ const { selected } = partitionPickerItems(items, this.search, this.resolvedSort);
557
+ const shownIds = this.resolvedSort === 'selected-first'
558
+ ? selected.map((item) => item.colId)
559
+ : selected.filter((item) => item.visible).map((item) => item.colId);
560
+ const nextOrder = reorderVisibleIds(allVisibleIds, shownIds, fromId, toId);
561
+ if (!nextOrder) {
562
+ return;
563
+ }
564
+ this.pickerApi.applyColumnState({
565
+ state: applyVisibleOrder(columnState, nextOrder),
566
+ applyOrder: true,
567
+ });
568
+ }
569
+ }
570
+ __decorate([
571
+ attr
572
+ ], ColumnSelection.prototype, "label", void 0);
573
+ __decorate([
574
+ attr
575
+ ], ColumnSelection.prototype, "sort", void 0);
576
+ __decorate([
577
+ observable
578
+ ], ColumnSelection.prototype, "open", void 0);
579
+ __decorate([
580
+ observable
581
+ ], ColumnSelection.prototype, "gridApi", void 0);
582
+ __decorate([
583
+ observable
584
+ ], ColumnSelection.prototype, "gridHost", void 0);
585
+ __decorate([
586
+ observable
587
+ ], ColumnSelection.prototype, "root", void 0);
588
+ __decorate([
589
+ observable
590
+ ], ColumnSelection.prototype, "buttonEl", void 0);
591
+ __decorate([
592
+ observable
593
+ ], ColumnSelection.prototype, "panelEl", void 0);
594
+ __decorate([
595
+ observable
596
+ ], ColumnSelection.prototype, "search", void 0);
597
+ __decorate([
598
+ observable
599
+ ], ColumnSelection.prototype, "selectedItems", void 0);
600
+ __decorate([
601
+ observable
602
+ ], ColumnSelection.prototype, "unselectedItems", void 0);
603
+ __decorate([
604
+ observable
605
+ ], ColumnSelection.prototype, "selectAllChecked", void 0);
606
+ __decorate([
607
+ observable
608
+ ], ColumnSelection.prototype, "selectAllIndeterminate", void 0);
609
+ /**
610
+ * Foundation Column Selection registration.
611
+ *
612
+ * @public
613
+ * @remarks
614
+ * HTML Element: \<foundation-column-selection\>
615
+ */
616
+ export const foundationColumnSelection = ColumnSelection.compose({
617
+ baseName: 'column-selection',
618
+ template: getColumnSelectionTemplate('foundation'),
619
+ styles,
620
+ });