@toolbox-web/grid 1.14.1 → 1.16.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 (91) hide show
  1. package/README.md +5 -1
  2. package/all.js +2013 -1564
  3. package/all.js.map +1 -1
  4. package/index.js +918 -880
  5. package/index.js.map +1 -1
  6. package/lib/core/grid.d.ts.map +1 -1
  7. package/lib/core/internal/columns.d.ts +0 -5
  8. package/lib/core/internal/columns.d.ts.map +1 -1
  9. package/lib/core/internal/rows.d.ts.map +1 -1
  10. package/lib/core/internal/validate-config.d.ts.map +1 -1
  11. package/lib/core/types.d.ts +12 -0
  12. package/lib/core/types.d.ts.map +1 -1
  13. package/lib/plugins/clipboard/index.js.map +1 -1
  14. package/lib/plugins/column-virtualization/ColumnVirtualizationPlugin.d.ts.map +1 -1
  15. package/lib/plugins/column-virtualization/index.js +1 -1
  16. package/lib/plugins/column-virtualization/index.js.map +1 -1
  17. package/lib/plugins/context-menu/ContextMenuPlugin.d.ts +20 -1
  18. package/lib/plugins/context-menu/ContextMenuPlugin.d.ts.map +1 -1
  19. package/lib/plugins/context-menu/index.d.ts +1 -1
  20. package/lib/plugins/context-menu/index.d.ts.map +1 -1
  21. package/lib/plugins/context-menu/index.js +177 -84
  22. package/lib/plugins/context-menu/index.js.map +1 -1
  23. package/lib/plugins/context-menu/menu.d.ts +7 -0
  24. package/lib/plugins/context-menu/menu.d.ts.map +1 -1
  25. package/lib/plugins/context-menu/types.d.ts +48 -2
  26. package/lib/plugins/context-menu/types.d.ts.map +1 -1
  27. package/lib/plugins/editing/EditingPlugin.d.ts.map +1 -1
  28. package/lib/plugins/editing/index.js +327 -298
  29. package/lib/plugins/editing/index.js.map +1 -1
  30. package/lib/plugins/export/index.js.map +1 -1
  31. package/lib/plugins/filtering/FilteringPlugin.d.ts +7 -1
  32. package/lib/plugins/filtering/FilteringPlugin.d.ts.map +1 -1
  33. package/lib/plugins/filtering/filter-model.d.ts.map +1 -1
  34. package/lib/plugins/filtering/index.js +173 -138
  35. package/lib/plugins/filtering/index.js.map +1 -1
  36. package/lib/plugins/grouping-columns/GroupingColumnsPlugin.d.ts +5 -1
  37. package/lib/plugins/grouping-columns/GroupingColumnsPlugin.d.ts.map +1 -1
  38. package/lib/plugins/grouping-columns/index.js +242 -109
  39. package/lib/plugins/grouping-columns/index.js.map +1 -1
  40. package/lib/plugins/grouping-columns/types.d.ts +7 -0
  41. package/lib/plugins/grouping-columns/types.d.ts.map +1 -1
  42. package/lib/plugins/grouping-rows/index.js.map +1 -1
  43. package/lib/plugins/master-detail/index.js.map +1 -1
  44. package/lib/plugins/multi-sort/index.js.map +1 -1
  45. package/lib/plugins/pinned-columns/PinnedColumnsPlugin.d.ts +11 -1
  46. package/lib/plugins/pinned-columns/PinnedColumnsPlugin.d.ts.map +1 -1
  47. package/lib/plugins/pinned-columns/index.d.ts +1 -1
  48. package/lib/plugins/pinned-columns/index.d.ts.map +1 -1
  49. package/lib/plugins/pinned-columns/index.js +174 -79
  50. package/lib/plugins/pinned-columns/index.js.map +1 -1
  51. package/lib/plugins/pinned-columns/pinned-columns.d.ts +23 -4
  52. package/lib/plugins/pinned-columns/pinned-columns.d.ts.map +1 -1
  53. package/lib/plugins/pinned-columns/types.d.ts +21 -9
  54. package/lib/plugins/pinned-columns/types.d.ts.map +1 -1
  55. package/lib/plugins/pinned-rows/index.js.map +1 -1
  56. package/lib/plugins/pivot/index.js.map +1 -1
  57. package/lib/plugins/print/index.js.map +1 -1
  58. package/lib/plugins/reorder/index.js.map +1 -1
  59. package/lib/plugins/responsive/index.js.map +1 -1
  60. package/lib/plugins/row-reorder/index.js.map +1 -1
  61. package/lib/plugins/selection/index.js.map +1 -1
  62. package/lib/plugins/server-side/index.js.map +1 -1
  63. package/lib/plugins/tree/index.js.map +1 -1
  64. package/lib/plugins/undo-redo/index.js.map +1 -1
  65. package/lib/plugins/visibility/VisibilityPlugin.d.ts +42 -2
  66. package/lib/plugins/visibility/VisibilityPlugin.d.ts.map +1 -1
  67. package/lib/plugins/visibility/index.d.ts +1 -1
  68. package/lib/plugins/visibility/index.d.ts.map +1 -1
  69. package/lib/plugins/visibility/index.js +219 -59
  70. package/lib/plugins/visibility/index.js.map +1 -1
  71. package/lib/plugins/visibility/types.d.ts +25 -0
  72. package/lib/plugins/visibility/types.d.ts.map +1 -1
  73. package/package.json +1 -1
  74. package/umd/grid.all.umd.js +27 -27
  75. package/umd/grid.all.umd.js.map +1 -1
  76. package/umd/grid.umd.js +21 -21
  77. package/umd/grid.umd.js.map +1 -1
  78. package/umd/plugins/column-virtualization.umd.js +1 -1
  79. package/umd/plugins/column-virtualization.umd.js.map +1 -1
  80. package/umd/plugins/context-menu.umd.js +1 -1
  81. package/umd/plugins/context-menu.umd.js.map +1 -1
  82. package/umd/plugins/editing.umd.js +1 -1
  83. package/umd/plugins/editing.umd.js.map +1 -1
  84. package/umd/plugins/filtering.umd.js +1 -1
  85. package/umd/plugins/filtering.umd.js.map +1 -1
  86. package/umd/plugins/grouping-columns.umd.js +1 -1
  87. package/umd/plugins/grouping-columns.umd.js.map +1 -1
  88. package/umd/plugins/pinned-columns.umd.js +1 -1
  89. package/umd/plugins/pinned-columns.umd.js.map +1 -1
  90. package/umd/plugins/visibility.umd.js +1 -1
  91. package/umd/plugins/visibility.umd.js.map +1 -1
@@ -1,6 +1,6 @@
1
1
  import { PluginManifest, PluginQuery, BaseGridPlugin } from '../../core/plugin/base-plugin';
2
2
  import { ColumnConfig } from '../../core/types';
3
- import { PinnedColumnsConfig } from './types';
3
+ import { PinnedColumnsConfig, PinnedPosition } from './types';
4
4
  /**
5
5
  * Pinned Columns Plugin for tbw-grid
6
6
  *
@@ -19,6 +19,7 @@ import { PinnedColumnsConfig } from './types';
19
19
  * | Property | Type | Description |
20
20
  * |----------|------|-------------|
21
21
  * | `pinned` | `'left' \| 'right' \| 'start' \| 'end'` | Pin column to edge (logical or physical) |
22
+ * | `meta.lockPinning` | `boolean` | `false` | Prevent user from pin/unpin via context menu |
22
23
  *
23
24
  * ### RTL Support
24
25
  *
@@ -69,6 +70,7 @@ import { PinnedColumnsConfig } from './types';
69
70
  * @internal Extends BaseGridPlugin
70
71
  */
71
72
  export declare class PinnedColumnsPlugin extends BaseGridPlugin<PinnedColumnsConfig> {
73
+ #private;
72
74
  /**
73
75
  * Plugin manifest - declares owned properties and handled queries.
74
76
  * @internal
@@ -98,6 +100,14 @@ export declare class PinnedColumnsPlugin extends BaseGridPlugin<PinnedColumnsCon
98
100
  * @internal
99
101
  */
100
102
  handleQuery(query: PluginQuery): unknown;
103
+ /**
104
+ * Set the pin position for a column.
105
+ * Updates the column's `pinned` property and triggers a full re-render.
106
+ *
107
+ * @param field - The field name of the column to pin/unpin
108
+ * @param position - The pin position (`'left'`, `'right'`, `'start'`, `'end'`), or `undefined` to unpin
109
+ */
110
+ setPinPosition(field: string, position: PinnedPosition | undefined): void;
101
111
  /**
102
112
  * Re-apply sticky offsets (e.g., after column resize).
103
113
  */
@@ -1 +1 @@
1
- {"version":3,"file":"PinnedColumnsPlugin.d.ts","sourceRoot":"","sources":["../../../../../../libs/grid/src/lib/plugins/pinned-columns/PinnedColumnsPlugin.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AACjF,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAQrD,OAAO,KAAK,EAAE,mBAAmB,EAAkB,MAAM,SAAS,CAAC;AAKnE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkEG;AACH,qBAAa,mBAAoB,SAAQ,cAAc,CAAC,mBAAmB,CAAC;IAC1E;;;OAGG;IACH,gBAAyB,QAAQ,EAAE,cAAc,CAmB/C;IAEF,gBAAgB;IAChB,QAAQ,CAAC,IAAI,mBAAmB;IAEhC,gBAAgB;IAChB,cAAuB,aAAa,IAAI,OAAO,CAAC,mBAAmB,CAAC,CAEnE;IAGD,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,WAAW,CAA6B;IAChD,OAAO,CAAC,YAAY,CAA6B;IAKjD,gBAAgB;IACP,MAAM,IAAI,IAAI;IASvB;;OAEG;IACH,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,OAAO,EAAE,EAAE,MAAM,EAAE;QAAE,OAAO,CAAC,EAAE,YAAY,EAAE,CAAA;KAAE,GAAG,OAAO;IAStF,gBAAgB;IACP,cAAc,CAAC,OAAO,EAAE,SAAS,YAAY,EAAE,GAAG,YAAY,EAAE;IAMzE,gBAAgB;IACP,WAAW,IAAI,IAAI;IAoB5B;;;OAGG;IACM,WAAW,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO;IAgCjD;;OAEG;IACH,oBAAoB,IAAI,IAAI;IAK5B;;OAEG;IACH,oBAAoB,IAAI,YAAY,EAAE;IAMtC;;OAEG;IACH,qBAAqB,IAAI,YAAY,EAAE;IAMvC;;OAEG;IACH,oBAAoB,IAAI,IAAI;IAI5B;;;;OAIG;IACM,0BAA0B,CACjC,KAAK,CAAC,EAAE,WAAW,EACnB,WAAW,CAAC,EAAE,WAAW,GACxB;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,SAAS;CAsCrE"}
1
+ {"version":3,"file":"PinnedColumnsPlugin.d.ts","sourceRoot":"","sources":["../../../../../../libs/grid/src/lib/plugins/pinned-columns/PinnedColumnsPlugin.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AACjF,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAWrD,OAAO,KAAK,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAKnE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmEG;AACH,qBAAa,mBAAoB,SAAQ,cAAc,CAAC,mBAAmB,CAAC;;IAC1E;;;OAGG;IACH,gBAAyB,QAAQ,EAAE,cAAc,CAqC/C;IAEF,gBAAgB;IAChB,QAAQ,CAAC,IAAI,mBAAmB;IAEhC,gBAAgB;IAChB,cAAuB,aAAa,IAAI,OAAO,CAAC,mBAAmB,CAAC,CAEnE;IAGD,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,WAAW,CAA6B;IAChD,OAAO,CAAC,YAAY,CAA6B;IAUjD,gBAAgB;IACP,MAAM,IAAI,IAAI;IAUvB;;OAEG;IACH,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,OAAO,EAAE,EAAE,MAAM,EAAE;QAAE,OAAO,CAAC,EAAE,YAAY,EAAE,CAAA;KAAE,GAAG,OAAO;IAStF,gBAAgB;IACP,cAAc,CAAC,OAAO,EAAE,SAAS,YAAY,EAAE,GAAG,YAAY,EAAE;IAUzE,gBAAgB;IACP,WAAW,IAAI,IAAI;IAoB5B;;;OAGG;IACM,WAAW,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO;IAyEjD;;;;;;OAMG;IACH,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,GAAG,SAAS,GAAG,IAAI;IAoEzE;;OAEG;IACH,oBAAoB,IAAI,IAAI;IAK5B;;OAEG;IACH,oBAAoB,IAAI,YAAY,EAAE;IAMtC;;OAEG;IACH,qBAAqB,IAAI,YAAY,EAAE;IAMvC;;OAEG;IACH,oBAAoB,IAAI,IAAI;IAI5B;;;;OAIG;IACM,0BAA0B,CACjC,KAAK,CAAC,EAAE,WAAW,EACnB,WAAW,CAAC,EAAE,WAAW,GACxB;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,SAAS;CAsCrE"}
@@ -5,5 +5,5 @@
5
5
  * @module Plugins/Pinned Columns
6
6
  */
7
7
  export { PinnedColumnsPlugin } from './PinnedColumnsPlugin';
8
- export type { PinnedColumnsConfig } from './types';
8
+ export type { PinnedColumnsConfig, PinnedPosition, StickyPosition } from './types';
9
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../libs/grid/src/lib/plugins/pinned-columns/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,YAAY,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../libs/grid/src/lib/plugins/pinned-columns/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,YAAY,EAAE,mBAAmB,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC"}
@@ -1,4 +1,4 @@
1
- function u(i) {
1
+ function a(i) {
2
2
  try {
3
3
  if (getComputedStyle(i).direction === "rtl") return "rtl";
4
4
  } catch {
@@ -9,10 +9,10 @@ function u(i) {
9
9
  }
10
10
  return "ltr";
11
11
  }
12
- function b(i, t) {
12
+ function P(i, t) {
13
13
  return i === "left" || i === "right" ? i : t === "rtl" ? i === "start" ? "right" : "left" : i === "start" ? "left" : "right";
14
14
  }
15
- const h = '<svg viewBox="0 0 16 16" width="12" height="12"><path fill="currentColor" d="M6 10.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 0 1h-3a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-11a.5.5 0 0 1-.5-.5z"/></svg>', v = {
15
+ const m = '<svg viewBox="0 0 16 16" width="12" height="12"><path fill="currentColor" d="M6 10.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 0 1h-3a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h7a.5.5 0 0 1 0 1h-7a.5.5 0 0 1-.5-.5zm-2-3a.5.5 0 0 1 .5-.5h11a.5.5 0 0 1 0 1h-11a.5.5 0 0 1-.5-.5z"/></svg>', A = {
16
16
  expand: "▶",
17
17
  collapse: "▼",
18
18
  sortAsc: "▲",
@@ -21,11 +21,11 @@ const h = '<svg viewBox="0 0 16 16" width="12" height="12"><path fill="currentCo
21
21
  submenuArrow: "▶",
22
22
  dragHandle: "⋮⋮",
23
23
  toolPanel: "☰",
24
- filter: h,
25
- filterActive: h,
24
+ filter: m,
25
+ filterActive: m,
26
26
  print: "🖨️"
27
27
  };
28
- class A {
28
+ class R {
29
29
  /**
30
30
  * Plugin dependencies - declare other plugins this one requires.
31
31
  *
@@ -160,8 +160,8 @@ class A {
160
160
  * @returns `true` if the event was cancelled (preventDefault called), `false` otherwise
161
161
  */
162
162
  emitCancelable(t, e) {
163
- const s = new CustomEvent(t, { detail: e, bubbles: !0, cancelable: !0 });
164
- return this.grid?.dispatchEvent?.(s), s.defaultPrevented;
163
+ const n = new CustomEvent(t, { detail: e, bubbles: !0, cancelable: !0 });
164
+ return this.grid?.dispatchEvent?.(n), n.defaultPrevented;
165
165
  }
166
166
  // =========================================================================
167
167
  // Event Bus - Plugin-to-Plugin Communication
@@ -315,7 +315,7 @@ class A {
315
315
  */
316
316
  get gridIcons() {
317
317
  const t = this.grid?.gridConfig?.icons ?? {};
318
- return { ...v, ...t };
318
+ return { ...A, ...t };
319
319
  }
320
320
  // #region Animation Helpers
321
321
  /**
@@ -356,8 +356,8 @@ class A {
356
356
  get animationDuration() {
357
357
  const t = this.gridElement;
358
358
  if (t) {
359
- const e = getComputedStyle(t).getPropertyValue("--tbw-animation-duration").trim(), s = parseInt(e, 10);
360
- if (!isNaN(s)) return s;
359
+ const e = getComputedStyle(t).getPropertyValue("--tbw-animation-duration").trim(), n = parseInt(e, 10);
360
+ if (!isNaN(n)) return n;
361
361
  }
362
362
  return 200;
363
363
  }
@@ -391,80 +391,102 @@ class A {
391
391
  }
392
392
  // #endregion
393
393
  }
394
- function p(i, t) {
395
- return b(i, t);
394
+ function d(i) {
395
+ return i.pinned ?? i.sticky ?? i.meta?.pinned ?? i.meta?.sticky;
396
396
  }
397
- function k(i, t) {
398
- const e = i.sticky;
399
- return e ? p(e, t) === "left" : !1;
397
+ function g(i, t) {
398
+ return P(i, t);
400
399
  }
401
- function C(i, t) {
402
- const e = i.sticky;
403
- return e ? p(e, t) === "right" : !1;
400
+ function b(i, t) {
401
+ const e = d(i);
402
+ return e ? g(e, t) === "left" : !1;
403
+ }
404
+ function v(i, t) {
405
+ const e = d(i);
406
+ return e ? g(e, t) === "right" : !1;
404
407
  }
405
408
  function S(i, t = "ltr") {
406
- return i.filter((e) => k(e, t));
409
+ return i.filter((e) => b(e, t));
407
410
  }
408
- function R(i, t = "ltr") {
409
- return i.filter((e) => C(e, t));
411
+ function E(i, t = "ltr") {
412
+ return i.filter((e) => v(e, t));
410
413
  }
411
- function a(i) {
412
- return i.some(
413
- (t) => t.sticky === "left" || t.sticky === "right" || t.sticky === "start" || t.sticky === "end"
414
- );
414
+ function h(i) {
415
+ return i.some((t) => d(t) != null);
415
416
  }
416
- function g(i, t) {
417
+ function y(i, t) {
417
418
  const e = Array.from(i.querySelectorAll(".header-row .cell"));
418
419
  if (!e.length) return;
419
- const s = u(i), o = /* @__PURE__ */ new Map();
420
- t.forEach((n, r) => {
421
- n.field && o.set(n.field, r);
422
- });
423
- let d = 0;
424
- for (const n of t)
425
- if (k(n, s)) {
426
- const r = o.get(n.field), l = e.find((c) => c.getAttribute("data-field") === n.field);
427
- l && (l.classList.add("sticky-left"), l.style.position = "sticky", l.style.left = d + "px", r !== void 0 && i.querySelectorAll(`.data-grid-row .cell[data-col="${r}"]`).forEach((c) => {
428
- c.classList.add("sticky-left"), c.style.position = "sticky", c.style.left = d + "px";
429
- }), d += l.offsetWidth);
420
+ const n = a(i);
421
+ let l = 0;
422
+ for (const o of t)
423
+ if (b(o, n)) {
424
+ const r = e.find((s) => s.getAttribute("data-field") === o.field);
425
+ r && (r.classList.add("sticky-left"), r.style.position = "sticky", r.style.left = l + "px", i.querySelectorAll(`.data-grid-row .cell[data-field="${o.field}"]`).forEach((s) => {
426
+ s.classList.add("sticky-left"), s.style.position = "sticky", s.style.left = l + "px";
427
+ }), l += r.offsetWidth);
430
428
  }
431
- let f = 0;
432
- for (const n of [...t].reverse())
433
- if (C(n, s)) {
434
- const r = o.get(n.field), l = e.find((c) => c.getAttribute("data-field") === n.field);
435
- l && (l.classList.add("sticky-right"), l.style.position = "sticky", l.style.right = f + "px", r !== void 0 && i.querySelectorAll(`.data-grid-row .cell[data-col="${r}"]`).forEach((c) => {
436
- c.classList.add("sticky-right"), c.style.position = "sticky", c.style.right = f + "px";
437
- }), f += l.offsetWidth);
429
+ let c = 0;
430
+ for (const o of [...t].reverse())
431
+ if (v(o, n)) {
432
+ const r = e.find((s) => s.getAttribute("data-field") === o.field);
433
+ r && (r.classList.add("sticky-right"), r.style.position = "sticky", r.style.right = c + "px", i.querySelectorAll(`.data-grid-row .cell[data-field="${o.field}"]`).forEach((s) => {
434
+ s.classList.add("sticky-right"), s.style.position = "sticky", s.style.right = c + "px";
435
+ }), c += r.offsetWidth);
438
436
  }
439
437
  }
440
- function y(i) {
438
+ function O(i, t = "ltr") {
439
+ const e = [], n = [], l = [];
440
+ for (const c of i) {
441
+ const o = d(c);
442
+ o ? g(o, t) === "left" ? e.push(c) : l.push(c) : n.push(c);
443
+ }
444
+ return [...e, ...n, ...l];
445
+ }
446
+ function C(i) {
441
447
  i.querySelectorAll(".sticky-left, .sticky-right").forEach((e) => {
442
448
  e.classList.remove("sticky-left", "sticky-right"), e.style.position = "", e.style.left = "", e.style.right = "";
443
449
  });
444
450
  }
445
- const m = "canMoveColumn";
446
- class E extends A {
451
+ const k = "canMoveColumn";
452
+ class I extends R {
447
453
  /**
448
454
  * Plugin manifest - declares owned properties and handled queries.
449
455
  * @internal
450
456
  */
451
457
  static manifest = {
452
458
  ownedProperties: [
459
+ {
460
+ property: "pinned",
461
+ level: "column",
462
+ description: 'the "pinned" column property',
463
+ isUsed: (t) => t === "left" || t === "right" || t === "start" || t === "end"
464
+ },
453
465
  {
454
466
  property: "sticky",
455
467
  level: "column",
456
- description: 'the "sticky" column property',
468
+ description: 'the "sticky" column property (deprecated, use "pinned")',
457
469
  isUsed: (t) => t === "left" || t === "right" || t === "start" || t === "end"
458
470
  }
459
471
  ],
472
+ incompatibleWith: [
473
+ {
474
+ name: "groupingColumns",
475
+ reason: "Pinning reorders columns to the grid edges, but moving a column out of its column group is not supported. The group header layout cannot accommodate members at different positions."
476
+ }
477
+ ],
460
478
  queries: [
461
479
  {
462
- type: m,
480
+ type: k,
463
481
  description: "Prevents pinned (sticky) columns from being moved/reordered"
464
482
  },
465
483
  {
466
484
  type: "getStickyOffsets",
467
485
  description: "Returns the sticky offsets for left/right pinned columns"
486
+ },
487
+ {
488
+ type: "getContextMenuItems",
489
+ description: "Contributes pin/unpin items to the header context menu"
468
490
  }
469
491
  ]
470
492
  };
@@ -478,11 +500,16 @@ class E extends A {
478
500
  isApplied = !1;
479
501
  leftOffsets = /* @__PURE__ */ new Map();
480
502
  rightOffsets = /* @__PURE__ */ new Map();
503
+ /**
504
+ * Snapshot of the column field order before the first context-menu pin.
505
+ * Used to restore original positions when unpinning.
506
+ */
507
+ #t = [];
481
508
  // #endregion
482
509
  // #region Lifecycle
483
510
  /** @internal */
484
511
  detach() {
485
- this.leftOffsets.clear(), this.rightOffsets.clear(), this.isApplied = !1;
512
+ this.leftOffsets.clear(), this.rightOffsets.clear(), this.isApplied = !1, this.#t = [];
486
513
  }
487
514
  // #endregion
488
515
  // #region Detection
@@ -490,26 +517,29 @@ class E extends A {
490
517
  * Auto-detect sticky columns from column configuration.
491
518
  */
492
519
  static detect(t, e) {
493
- const s = e?.columns;
494
- return Array.isArray(s) ? a(s) : !1;
520
+ const n = e?.columns;
521
+ return Array.isArray(n) ? h(n) : !1;
495
522
  }
496
523
  // #endregion
497
524
  // #region Hooks
498
525
  /** @internal */
499
526
  processColumns(t) {
500
- return this.isApplied = a([...t]), [...t];
527
+ const e = [...t];
528
+ if (this.isApplied = h(e), !this.isApplied) return e;
529
+ const n = this.gridElement, l = n ? a(n) : "ltr";
530
+ return O(e, l);
501
531
  }
502
532
  /** @internal */
503
533
  afterRender() {
504
534
  if (!this.isApplied)
505
535
  return;
506
536
  const t = this.grid, e = [...this.columns];
507
- if (!a(e)) {
508
- y(t), this.isApplied = !1;
537
+ if (!h(e)) {
538
+ C(t), this.isApplied = !1;
509
539
  return;
510
540
  }
511
541
  queueMicrotask(() => {
512
- g(t, e);
542
+ y(t, e);
513
543
  });
514
544
  }
515
545
  /**
@@ -518,50 +548,115 @@ class E extends A {
518
548
  */
519
549
  handleQuery(t) {
520
550
  switch (t.type) {
521
- case m: {
522
- const e = t.context, s = e.sticky;
523
- if (s === "left" || s === "right" || s === "start" || s === "end")
524
- return !1;
525
- const o = e.meta?.sticky;
526
- return o === "left" || o === "right" || o === "start" || o === "end" ? !1 : void 0;
551
+ case k: {
552
+ const e = t.context;
553
+ return d(e) != null ? !1 : void 0;
527
554
  }
528
555
  case "getStickyOffsets":
529
556
  return {
530
557
  left: Object.fromEntries(this.leftOffsets),
531
558
  right: Object.fromEntries(this.rightOffsets)
532
559
  };
560
+ case "getContextMenuItems": {
561
+ const e = t.context;
562
+ if (!e.isHeader) return;
563
+ const n = e.column;
564
+ if (!n?.field || n.meta?.lockPinning || this.grid?.getPluginByName("groupingColumns")?.isGroupingActive()) return;
565
+ const o = d(n) != null, r = [];
566
+ return o ? r.push({
567
+ id: "pinned/unpin",
568
+ label: "Unpin Column",
569
+ icon: "📌",
570
+ order: 40,
571
+ action: () => this.setPinPosition(n.field, void 0)
572
+ }) : (r.push({
573
+ id: "pinned/pin-left",
574
+ label: "Pin Left",
575
+ icon: "⬅",
576
+ order: 40,
577
+ action: () => this.setPinPosition(n.field, "left")
578
+ }), r.push({
579
+ id: "pinned/pin-right",
580
+ label: "Pin Right",
581
+ icon: "➡",
582
+ order: 41,
583
+ action: () => this.setPinPosition(n.field, "right")
584
+ })), r;
585
+ }
533
586
  default:
534
587
  return;
535
588
  }
536
589
  }
537
590
  // #endregion
538
591
  // #region Public API
592
+ /**
593
+ * Set the pin position for a column.
594
+ * Updates the column's `pinned` property and triggers a full re-render.
595
+ *
596
+ * @param field - The field name of the column to pin/unpin
597
+ * @param position - The pin position (`'left'`, `'right'`, `'start'`, `'end'`), or `undefined` to unpin
598
+ */
599
+ setPinPosition(t, e) {
600
+ const n = this.columns;
601
+ if (!n?.length) return;
602
+ const l = n.findIndex((o) => o.field === t);
603
+ if (l === -1) return;
604
+ const c = this.grid;
605
+ if (e) {
606
+ this.#t.length === 0 && (this.#t = n.map((r) => r.field));
607
+ const o = n.map((r) => {
608
+ if (r.field !== t) return r;
609
+ const s = { ...r };
610
+ return s.pinned = e, delete s.sticky, s;
611
+ });
612
+ c.columns = o;
613
+ } else {
614
+ const r = { ...n[l] };
615
+ delete r.pinned, delete r.sticky;
616
+ const s = [...n];
617
+ s.splice(l, 1);
618
+ const p = this.#t.indexOf(t);
619
+ if (p >= 0) {
620
+ let f = s.length;
621
+ for (let u = 0; u < s.length; u++) {
622
+ if (d(s[u])) continue;
623
+ if (this.#t.indexOf(s[u].field) > p) {
624
+ f = u;
625
+ break;
626
+ }
627
+ }
628
+ s.splice(f, 0, r);
629
+ } else
630
+ s.splice(Math.min(l, s.length), 0, r);
631
+ s.some((f) => d(f) != null) || (this.#t = []), c.columns = s;
632
+ }
633
+ }
539
634
  /**
540
635
  * Re-apply sticky offsets (e.g., after column resize).
541
636
  */
542
637
  refreshStickyOffsets() {
543
638
  const t = [...this.columns];
544
- g(this.grid, t);
639
+ y(this.grid, t);
545
640
  }
546
641
  /**
547
642
  * Get columns pinned to the left (after resolving logical positions for current direction).
548
643
  */
549
644
  getLeftPinnedColumns() {
550
- const t = [...this.columns], e = u(this.grid);
645
+ const t = [...this.columns], e = a(this.grid);
551
646
  return S(t, e);
552
647
  }
553
648
  /**
554
649
  * Get columns pinned to the right (after resolving logical positions for current direction).
555
650
  */
556
651
  getRightPinnedColumns() {
557
- const t = [...this.columns], e = u(this.grid);
558
- return R(t, e);
652
+ const t = [...this.columns], e = a(this.grid);
653
+ return E(t, e);
559
654
  }
560
655
  /**
561
656
  * Clear all sticky positioning.
562
657
  */
563
658
  clearStickyPositions() {
564
- y(this.grid);
659
+ C(this.grid);
565
660
  }
566
661
  /**
567
662
  * Report horizontal scroll boundary offsets for pinned columns.
@@ -571,24 +666,24 @@ class E extends A {
571
666
  getHorizontalScrollOffsets(t, e) {
572
667
  if (!this.isApplied)
573
668
  return;
574
- let s = 0, o = 0;
669
+ let n = 0, l = 0;
575
670
  if (t) {
576
- const f = t.querySelectorAll(".sticky-left"), n = t.querySelectorAll(".sticky-right");
577
- f.forEach((r) => {
578
- s += r.offsetWidth;
579
- }), n.forEach((r) => {
580
- o += r.offsetWidth;
671
+ const o = t.querySelectorAll(".sticky-left"), r = t.querySelectorAll(".sticky-right");
672
+ o.forEach((s) => {
673
+ n += s.offsetWidth;
674
+ }), r.forEach((s) => {
675
+ l += s.offsetWidth;
581
676
  });
582
677
  } else
583
- this.grid.querySelectorAll(".header-row .cell").forEach((r) => {
584
- r.classList.contains("sticky-left") ? s += r.offsetWidth : r.classList.contains("sticky-right") && (o += r.offsetWidth);
678
+ this.grid.querySelectorAll(".header-row .cell").forEach((s) => {
679
+ s.classList.contains("sticky-left") ? n += s.offsetWidth : s.classList.contains("sticky-right") && (l += s.offsetWidth);
585
680
  });
586
- const d = e?.classList.contains("sticky-left") || e?.classList.contains("sticky-right");
587
- return { left: s, right: o, skipScroll: d };
681
+ const c = e?.classList.contains("sticky-left") || e?.classList.contains("sticky-right");
682
+ return { left: n, right: l, skipScroll: c };
588
683
  }
589
684
  // #endregion
590
685
  }
591
686
  export {
592
- E as PinnedColumnsPlugin
687
+ I as PinnedColumnsPlugin
593
688
  };
594
689
  //# sourceMappingURL=index.js.map