@toolbox-web/grid 1.23.3 → 1.24.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 (236) hide show
  1. package/README.md +35 -6
  2. package/all.d.ts +2 -2
  3. package/all.d.ts.map +1 -1
  4. package/all.js +2 -2
  5. package/all.js.map +1 -1
  6. package/index.js +1 -1
  7. package/index.js.map +1 -1
  8. package/lib/core/grid.d.ts +28 -0
  9. package/lib/core/grid.d.ts.map +1 -1
  10. package/lib/core/internal/feature-hook.d.ts +8 -0
  11. package/lib/core/internal/feature-hook.d.ts.map +1 -0
  12. package/lib/core/plugin/base-plugin.d.ts +14 -2
  13. package/lib/core/plugin/base-plugin.d.ts.map +1 -1
  14. package/lib/core/plugin/types.d.ts +2 -1
  15. package/lib/core/plugin/types.d.ts.map +1 -1
  16. package/lib/core/types.d.ts +68 -2
  17. package/lib/core/types.d.ts.map +1 -1
  18. package/lib/features/clipboard.d.ts +8 -0
  19. package/lib/features/clipboard.d.ts.map +1 -0
  20. package/lib/features/clipboard.js +2 -0
  21. package/lib/features/clipboard.js.map +1 -0
  22. package/lib/features/column-virtualization.d.ts +8 -0
  23. package/lib/features/column-virtualization.d.ts.map +1 -0
  24. package/lib/features/column-virtualization.js +2 -0
  25. package/lib/features/column-virtualization.js.map +1 -0
  26. package/lib/features/context-menu.d.ts +8 -0
  27. package/lib/features/context-menu.d.ts.map +1 -0
  28. package/lib/features/context-menu.js +2 -0
  29. package/lib/features/context-menu.js.map +1 -0
  30. package/lib/features/editing.d.ts +8 -0
  31. package/lib/features/editing.d.ts.map +1 -0
  32. package/lib/features/editing.js +2 -0
  33. package/lib/features/editing.js.map +1 -0
  34. package/lib/features/export.d.ts +8 -0
  35. package/lib/features/export.d.ts.map +1 -0
  36. package/lib/features/export.js +2 -0
  37. package/lib/features/export.js.map +1 -0
  38. package/lib/features/filtering.d.ts +8 -0
  39. package/lib/features/filtering.d.ts.map +1 -0
  40. package/lib/features/filtering.js +2 -0
  41. package/lib/features/filtering.js.map +1 -0
  42. package/lib/features/grouping-columns.d.ts +8 -0
  43. package/lib/features/grouping-columns.d.ts.map +1 -0
  44. package/lib/features/grouping-columns.js +2 -0
  45. package/lib/features/grouping-columns.js.map +1 -0
  46. package/lib/features/grouping-rows.d.ts +8 -0
  47. package/lib/features/grouping-rows.d.ts.map +1 -0
  48. package/lib/features/grouping-rows.js +2 -0
  49. package/lib/features/grouping-rows.js.map +1 -0
  50. package/lib/features/magic-string.es-CkyDP9Ir.mjs.map +1 -0
  51. package/lib/features/master-detail.d.ts +8 -0
  52. package/lib/features/master-detail.d.ts.map +1 -0
  53. package/lib/features/master-detail.js +2 -0
  54. package/lib/features/master-detail.js.map +1 -0
  55. package/lib/features/multi-sort.d.ts +10 -0
  56. package/lib/features/multi-sort.d.ts.map +1 -0
  57. package/lib/features/multi-sort.js +2 -0
  58. package/lib/features/multi-sort.js.map +1 -0
  59. package/lib/features/pinned-columns.d.ts +18 -0
  60. package/lib/features/pinned-columns.d.ts.map +1 -0
  61. package/lib/features/pinned-columns.js +2 -0
  62. package/lib/features/pinned-columns.js.map +1 -0
  63. package/lib/features/pinned-rows.d.ts +8 -0
  64. package/lib/features/pinned-rows.d.ts.map +1 -0
  65. package/lib/features/pinned-rows.js +2 -0
  66. package/lib/features/pinned-rows.js.map +1 -0
  67. package/lib/features/pivot.d.ts +8 -0
  68. package/lib/features/pivot.d.ts.map +1 -0
  69. package/lib/features/pivot.js +2 -0
  70. package/lib/features/pivot.js.map +1 -0
  71. package/lib/features/print.d.ts +8 -0
  72. package/lib/features/print.d.ts.map +1 -0
  73. package/lib/features/print.js +2 -0
  74. package/lib/features/print.js.map +1 -0
  75. package/lib/features/registry.d.ts +50 -0
  76. package/lib/features/registry.d.ts.map +1 -0
  77. package/lib/features/registry.js +2 -0
  78. package/lib/features/registry.js.map +1 -0
  79. package/lib/features/registry.spec.js +5 -0
  80. package/lib/features/registry.spec.js.map +1 -0
  81. package/lib/features/reorder-columns.d.ts +10 -0
  82. package/lib/features/reorder-columns.d.ts.map +1 -0
  83. package/lib/features/reorder-columns.js +2 -0
  84. package/lib/features/reorder-columns.js.map +1 -0
  85. package/lib/features/reorder-rows.d.ts +10 -0
  86. package/lib/features/reorder-rows.d.ts.map +1 -0
  87. package/lib/features/reorder-rows.js +2 -0
  88. package/lib/features/reorder-rows.js.map +1 -0
  89. package/lib/features/responsive.d.ts +8 -0
  90. package/lib/features/responsive.d.ts.map +1 -0
  91. package/lib/features/responsive.js +2 -0
  92. package/lib/features/responsive.js.map +1 -0
  93. package/lib/features/selection.d.ts +8 -0
  94. package/lib/features/selection.d.ts.map +1 -0
  95. package/lib/features/selection.js +2 -0
  96. package/lib/features/selection.js.map +1 -0
  97. package/lib/features/server-side.d.ts +8 -0
  98. package/lib/features/server-side.d.ts.map +1 -0
  99. package/lib/features/server-side.js +2 -0
  100. package/lib/features/server-side.js.map +1 -0
  101. package/lib/features/tree.d.ts +8 -0
  102. package/lib/features/tree.d.ts.map +1 -0
  103. package/lib/features/tree.js +2 -0
  104. package/lib/features/tree.js.map +1 -0
  105. package/lib/features/undo-redo.d.ts +8 -0
  106. package/lib/features/undo-redo.d.ts.map +1 -0
  107. package/lib/features/undo-redo.js +2 -0
  108. package/lib/features/undo-redo.js.map +1 -0
  109. package/lib/features/visibility.d.ts +8 -0
  110. package/lib/features/visibility.d.ts.map +1 -0
  111. package/lib/features/visibility.js +2 -0
  112. package/lib/features/visibility.js.map +1 -0
  113. package/lib/plugins/clipboard/ClipboardPlugin.d.ts +3 -3
  114. package/lib/plugins/clipboard/index.js +1 -1
  115. package/lib/plugins/clipboard/index.js.map +1 -1
  116. package/lib/plugins/clipboard/types.d.ts +1 -1
  117. package/lib/plugins/column-virtualization/index.js +1 -1
  118. package/lib/plugins/column-virtualization/index.js.map +1 -1
  119. package/lib/plugins/column-virtualization/types.d.ts +24 -2
  120. package/lib/plugins/column-virtualization/types.d.ts.map +1 -1
  121. package/lib/plugins/context-menu/index.js +1 -1
  122. package/lib/plugins/context-menu/index.js.map +1 -1
  123. package/lib/plugins/editing/index.js +1 -1
  124. package/lib/plugins/editing/index.js.map +1 -1
  125. package/lib/plugins/editing/types.d.ts +1 -1
  126. package/lib/plugins/export/ExportPlugin.d.ts +1 -1
  127. package/lib/plugins/export/index.js +1 -1
  128. package/lib/plugins/export/index.js.map +1 -1
  129. package/lib/plugins/export/types.d.ts +9 -1
  130. package/lib/plugins/export/types.d.ts.map +1 -1
  131. package/lib/plugins/filtering/index.js +1 -1
  132. package/lib/plugins/filtering/index.js.map +1 -1
  133. package/lib/plugins/filtering/types.d.ts +586 -29
  134. package/lib/plugins/filtering/types.d.ts.map +1 -1
  135. package/lib/plugins/grouping-columns/index.d.ts +1 -1
  136. package/lib/plugins/grouping-columns/index.js +1 -1
  137. package/lib/plugins/grouping-columns/index.js.map +1 -1
  138. package/lib/plugins/grouping-rows/index.d.ts +2 -2
  139. package/lib/plugins/grouping-rows/index.d.ts.map +1 -1
  140. package/lib/plugins/grouping-rows/index.js +1 -1
  141. package/lib/plugins/grouping-rows/index.js.map +1 -1
  142. package/lib/plugins/grouping-rows/types.d.ts +48 -3
  143. package/lib/plugins/grouping-rows/types.d.ts.map +1 -1
  144. package/lib/plugins/master-detail/MasterDetailPlugin.d.ts +2 -2
  145. package/lib/plugins/master-detail/index.js +1 -1
  146. package/lib/plugins/master-detail/index.js.map +1 -1
  147. package/lib/plugins/multi-sort/index.js +1 -1
  148. package/lib/plugins/multi-sort/index.js.map +1 -1
  149. package/lib/plugins/multi-sort/types.d.ts +40 -6
  150. package/lib/plugins/multi-sort/types.d.ts.map +1 -1
  151. package/lib/plugins/pinned-columns/index.js +1 -1
  152. package/lib/plugins/pinned-columns/index.js.map +1 -1
  153. package/lib/plugins/pinned-columns/types.d.ts +3 -3
  154. package/lib/plugins/pinned-rows/index.js +1 -1
  155. package/lib/plugins/pinned-rows/index.js.map +1 -1
  156. package/lib/plugins/pinned-rows/types.d.ts +42 -4
  157. package/lib/plugins/pinned-rows/types.d.ts.map +1 -1
  158. package/lib/plugins/pivot/index.js +1 -1
  159. package/lib/plugins/pivot/index.js.map +1 -1
  160. package/lib/plugins/pivot/types.d.ts +66 -1
  161. package/lib/plugins/pivot/types.d.ts.map +1 -1
  162. package/lib/plugins/print/PrintPlugin.d.ts +1 -1
  163. package/lib/plugins/print/index.js +1 -1
  164. package/lib/plugins/print/index.js.map +1 -1
  165. package/lib/plugins/print/types.d.ts +9 -1
  166. package/lib/plugins/print/types.d.ts.map +1 -1
  167. package/lib/plugins/{reorder → reorder-columns}/ReorderPlugin.d.ts +5 -3
  168. package/lib/plugins/reorder-columns/ReorderPlugin.d.ts.map +1 -0
  169. package/lib/plugins/reorder-columns/column-drag.d.ts.map +1 -0
  170. package/lib/plugins/{reorder → reorder-columns}/index.d.ts +2 -2
  171. package/lib/plugins/reorder-columns/index.d.ts.map +1 -0
  172. package/lib/plugins/reorder-columns/index.js +2 -0
  173. package/lib/plugins/reorder-columns/index.js.map +1 -0
  174. package/lib/plugins/{reorder → reorder-columns}/types.d.ts +17 -1
  175. package/lib/plugins/reorder-columns/types.d.ts.map +1 -0
  176. package/lib/plugins/{row-reorder → reorder-rows}/RowReorderPlugin.d.ts +5 -3
  177. package/lib/plugins/reorder-rows/RowReorderPlugin.d.ts.map +1 -0
  178. package/lib/plugins/{row-reorder → reorder-rows}/index.d.ts +2 -2
  179. package/lib/plugins/reorder-rows/index.d.ts.map +1 -0
  180. package/lib/plugins/reorder-rows/index.js +2 -0
  181. package/lib/plugins/reorder-rows/index.js.map +1 -0
  182. package/lib/plugins/{row-reorder → reorder-rows}/types.d.ts +5 -0
  183. package/lib/plugins/reorder-rows/types.d.ts.map +1 -0
  184. package/lib/plugins/responsive/ResponsivePlugin.d.ts +2 -2
  185. package/lib/plugins/responsive/index.js +1 -1
  186. package/lib/plugins/responsive/index.js.map +1 -1
  187. package/lib/plugins/selection/SelectionPlugin.d.ts +5 -5
  188. package/lib/plugins/selection/index.js +1 -1
  189. package/lib/plugins/selection/index.js.map +1 -1
  190. package/lib/plugins/server-side/index.js +1 -1
  191. package/lib/plugins/server-side/index.js.map +1 -1
  192. package/lib/plugins/server-side/types.d.ts +82 -0
  193. package/lib/plugins/server-side/types.d.ts.map +1 -1
  194. package/lib/plugins/tree/index.js +1 -1
  195. package/lib/plugins/tree/index.js.map +1 -1
  196. package/lib/plugins/undo-redo/index.js +1 -1
  197. package/lib/plugins/undo-redo/index.js.map +1 -1
  198. package/lib/plugins/visibility/VisibilityPlugin.d.ts +2 -2
  199. package/lib/plugins/visibility/index.js +1 -1
  200. package/lib/plugins/visibility/index.js.map +1 -1
  201. package/lib/plugins/visibility/types.d.ts +16 -2
  202. package/lib/plugins/visibility/types.d.ts.map +1 -1
  203. package/package.json +17 -2
  204. package/public.d.ts +9 -2
  205. package/public.d.ts.map +1 -1
  206. package/umd/grid.all.umd.js +1 -1
  207. package/umd/grid.all.umd.js.map +1 -1
  208. package/umd/grid.umd.js +1 -1
  209. package/umd/grid.umd.js.map +1 -1
  210. package/umd/plugins/clipboard.umd.js.map +1 -1
  211. package/umd/plugins/export.umd.js.map +1 -1
  212. package/umd/plugins/master-detail.umd.js.map +1 -1
  213. package/umd/plugins/print.umd.js.map +1 -1
  214. package/umd/plugins/reorder-columns.umd.js +2 -0
  215. package/umd/plugins/reorder-columns.umd.js.map +1 -0
  216. package/umd/plugins/reorder-rows.umd.js +2 -0
  217. package/umd/plugins/reorder-rows.umd.js.map +1 -0
  218. package/umd/plugins/responsive.umd.js.map +1 -1
  219. package/umd/plugins/selection.umd.js.map +1 -1
  220. package/umd/plugins/visibility.umd.js.map +1 -1
  221. package/lib/plugins/reorder/ReorderPlugin.d.ts.map +0 -1
  222. package/lib/plugins/reorder/column-drag.d.ts.map +0 -1
  223. package/lib/plugins/reorder/index.d.ts.map +0 -1
  224. package/lib/plugins/reorder/index.js +0 -2
  225. package/lib/plugins/reorder/index.js.map +0 -1
  226. package/lib/plugins/reorder/types.d.ts.map +0 -1
  227. package/lib/plugins/row-reorder/RowReorderPlugin.d.ts.map +0 -1
  228. package/lib/plugins/row-reorder/index.d.ts.map +0 -1
  229. package/lib/plugins/row-reorder/index.js +0 -2
  230. package/lib/plugins/row-reorder/index.js.map +0 -1
  231. package/lib/plugins/row-reorder/types.d.ts.map +0 -1
  232. package/umd/plugins/reorder.umd.js +0 -2
  233. package/umd/plugins/reorder.umd.js.map +0 -1
  234. package/umd/plugins/row-reorder.umd.js +0 -2
  235. package/umd/plugins/row-reorder.umd.js.map +0 -1
  236. /package/lib/plugins/{reorder → reorder-columns}/column-drag.d.ts +0 -0
@@ -3,18 +3,52 @@
3
3
  *
4
4
  * Type definitions for the multi-column sorting feature.
5
5
  */
6
- /** Represents a single column sort configuration */
6
+ /**
7
+ * Represents a single column's sort configuration within a multi-sort model.
8
+ *
9
+ * The **order** of `SortModel` entries in the array determines sort precedence:
10
+ * the first entry is the primary sort, the second breaks ties in the primary, and so on.
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * // Primary: department ascending, secondary: salary descending
15
+ * const sortModel: SortModel[] = [
16
+ * { field: 'department', direction: 'asc' },
17
+ * { field: 'salary', direction: 'desc' },
18
+ * ];
19
+ * ```
20
+ */
7
21
  export interface SortModel {
8
- /** The field key to sort by */
22
+ /** The column field key to sort by. Must match a `field` in the grid's column configuration. */
9
23
  field: string;
10
- /** Sort direction */
24
+ /** Sort direction: `'asc'` for ascending (A→Z, 0→9), `'desc'` for descending (Z→A, 9→0). */
11
25
  direction: 'asc' | 'desc';
12
26
  }
13
- /** Configuration options for the multi-sort plugin */
27
+ /**
28
+ * Configuration options for the multi-sort plugin.
29
+ *
30
+ * Multi-sort allows users to sort by multiple columns simultaneously.
31
+ * Users add sort columns by Shift+clicking column headers; the headers
32
+ * display numbered badges (1, 2, 3…) indicating sort precedence.
33
+ *
34
+ * @example
35
+ * ```typescript
36
+ * new MultiSortPlugin({ maxSortColumns: 5, showSortIndex: true })
37
+ * ```
38
+ */
14
39
  export interface MultiSortConfig {
15
- /** Maximum number of columns to sort by (default: 3) */
40
+ /**
41
+ * Maximum number of columns that can be sorted simultaneously.
42
+ * Once the limit is reached, adding a new sort column replaces the oldest one.
43
+ * @default 3
44
+ */
16
45
  maxSortColumns?: number;
17
- /** Whether to show sort order badges (1, 2, 3) on headers (default: true) */
46
+ /**
47
+ * Whether to show numbered badges (1, 2, 3…) on sorted column headers
48
+ * to indicate sort precedence. Disable for a cleaner look when precedence
49
+ * is not important to the user.
50
+ * @default true
51
+ */
18
52
  showSortIndex?: boolean;
19
53
  }
20
54
  /** Internal state managed by the multi-sort plugin */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../libs/grid/src/lib/plugins/multi-sort/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,oDAAoD;AACpD,MAAM,WAAW,SAAS;IACxB,+BAA+B;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,qBAAqB;IACrB,SAAS,EAAE,KAAK,GAAG,MAAM,CAAC;CAC3B;AAED,sDAAsD;AACtD,MAAM,WAAW,eAAe;IAC9B,wDAAwD;IACxD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,6EAA6E;IAC7E,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,sDAAsD;AACtD,MAAM,WAAW,cAAc;IAC7B,wDAAwD;IACxD,SAAS,EAAE,SAAS,EAAE,CAAC;CACxB;AAGD,OAAO,QAAQ,kBAAkB,CAAC;IAChC,UAAU,aAAa;QACrB,SAAS,EAAE,OAAO,mBAAmB,EAAE,eAAe,CAAC;KACxD;CACF"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../libs/grid/src/lib/plugins/multi-sort/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,SAAS;IACxB,gGAAgG;IAChG,KAAK,EAAE,MAAM,CAAC;IACd,4FAA4F;IAC5F,SAAS,EAAE,KAAK,GAAG,MAAM,CAAC;CAC3B;AAED;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;;;OAKG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,sDAAsD;AACtD,MAAM,WAAW,cAAc;IAC7B,wDAAwD;IACxD,SAAS,EAAE,SAAS,EAAE,CAAC;CACxB;AAGD,OAAO,QAAQ,kBAAkB,CAAC;IAChC,UAAU,aAAa;QACrB,SAAS,EAAE,OAAO,mBAAmB,EAAE,eAAe,CAAC;KACxD;CACF"}
@@ -1,2 +1,2 @@
1
- function t(t){try{if("rtl"===getComputedStyle(t).direction)return"rtl"}catch{}try{const e=t.closest?.("[dir]")?.getAttribute("dir");if("rtl"===e)return"rtl"}catch{}return"ltr"}const e='<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>',i={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:e,filterActive:e,print:"🖨️"};class n{static dependencies;static manifest;version="undefined"!=typeof __GRID_VERSION__?__GRID_VERSION__:"dev";styles;cellRenderers;headerRenderers;cellEditors;grid;config;userConfig;#t;get defaultConfig(){return{}}constructor(t={}){this.userConfig=t}attach(t){this.#t?.abort(),this.#t=new AbortController,this.grid=t,this.config={...this.defaultConfig,...this.userConfig}}detach(){this.#t?.abort(),this.#t=void 0}getPlugin(t){return this.grid?.getPlugin(t)}emit(t,e){this.grid?.dispatchEvent?.(new CustomEvent(t,{detail:e,bubbles:!0}))}emitCancelable(t,e){const i=new CustomEvent(t,{detail:e,bubbles:!0,cancelable:!0});return this.grid?.dispatchEvent?.(i),i.defaultPrevented}on(t,e){this.grid?._pluginManager?.subscribe(this,t,e)}off(t){this.grid?._pluginManager?.unsubscribe(this,t)}emitPluginEvent(t,e){this.grid?._pluginManager?.emitPluginEvent(t,e)}requestRender(){this.grid?.requestRender?.()}requestColumnsRender(){this.grid?.requestColumnsRender?.()}requestRenderWithFocus(){this.grid?.requestRenderWithFocus?.()}requestAfterRender(){this.grid?.requestAfterRender?.()}get rows(){return this.grid?.rows??[]}get sourceRows(){return this.grid?.sourceRows??[]}get columns(){return this.grid?.columns??[]}get visibleColumns(){return this.grid?._visibleColumns??[]}get gridElement(){return this.grid}get disconnectSignal(){return this.#t?.signal??this.grid?.disconnectSignal}get gridIcons(){const t=this.grid?.gridConfig?.icons??{};return{...i,...t}}get isAnimationEnabled(){const t=this.grid?.effectiveConfig?.animation?.mode??"reduced-motion";if(!1===t||"off"===t)return!1;if(!0===t||"on"===t)return!0;const e=this.gridElement;if(e){return"0"!==getComputedStyle(e).getPropertyValue("--tbw-animation-enabled").trim()}return!0}get animationDuration(){const t=this.gridElement;if(t){const e=getComputedStyle(t).getPropertyValue("--tbw-animation-duration").trim(),i=parseInt(e,10);if(!isNaN(i))return i}return 200}resolveIcon(t,e){return void 0!==e?e:this.gridIcons[t]}setIcon(t,e){"string"==typeof e?t.innerHTML=e:e instanceof HTMLElement&&(t.innerHTML="",t.appendChild(e.cloneNode(!0)))}warn(t){console.warn(`[tbw-grid:${this.name}] ${t}`)}}function r(t){return t.pinned??t.sticky??t.meta?.pinned??t.meta?.sticky}function s(t,e){return function(t,e){return"left"===t||"right"===t?t:"rtl"===e?"start"===t?"right":"left":"start"===t?"left":"right"}(t,e)}function o(t,e){const i=r(t);return!!i&&"left"===s(i,e)}function l(t,e){const i=r(t);return!!i&&"right"===s(i,e)}function c(t){return t.some(t=>null!=r(t))}function d(e,i){const n=Array.from(e.querySelectorAll(".header-row .cell"));if(!n.length)return;const r=t(e);let s=0;for(const t of i)if(o(t,r)){const i=n.find(e=>e.getAttribute("data-field")===t.field);i&&(i.classList.add("sticky-left"),i.style.position="sticky",i.style.left=s+"px",e.querySelectorAll(`.data-grid-row .cell[data-field="${t.field}"]`).forEach(t=>{t.classList.add("sticky-left"),t.style.position="sticky",t.style.left=s+"px"}),s+=i.offsetWidth)}let c=0;for(const t of[...i].reverse())if(l(t,r)){const i=n.find(e=>e.getAttribute("data-field")===t.field);i&&(i.classList.add("sticky-right"),i.style.position="sticky",i.style.right=c+"px",e.querySelectorAll(`.data-grid-row .cell[data-field="${t.field}"]`).forEach(t=>{t.classList.add("sticky-right"),t.style.position="sticky",t.style.right=c+"px"}),c+=i.offsetWidth)}}function u(t){t.querySelectorAll(".sticky-left, .sticky-right").forEach(t=>{t.classList.remove("sticky-left","sticky-right"),t.style.position="",t.style.left="",t.style.right=""})}const f="canMoveColumn";class a extends n{static manifest={ownedProperties:[{property:"pinned",level:"column",description:'the "pinned" column property',isUsed:t=>"left"===t||"right"===t||"start"===t||"end"===t},{property:"sticky",level:"column",description:'the "sticky" column property (deprecated, use "pinned")',isUsed:t=>"left"===t||"right"===t||"start"===t||"end"===t}],incompatibleWith:[{name:"groupingColumns",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."}],queries:[{type:f,description:"Prevents pinned (sticky) columns from being moved/reordered"},{type:"getStickyOffsets",description:"Returns the sticky offsets for left/right pinned columns"},{type:"getContextMenuItems",description:"Contributes pin/unpin items to the header context menu"}]};name="pinnedColumns";get defaultConfig(){return{}}isApplied=!1;leftOffsets=/* @__PURE__ */new Map;rightOffsets=/* @__PURE__ */new Map;#e=[];detach(){this.leftOffsets.clear(),this.rightOffsets.clear(),this.isApplied=!1,this.#e=[]}static detect(t,e){const i=e?.columns;return!!Array.isArray(i)&&c(i)}processColumns(e){const i=[...e];if(this.isApplied=c(i),!this.isApplied)return i;const n=this.gridElement;return function(t,e="ltr"){const i=[],n=[],o=[];for(const l of t){const t=r(l);t?"left"===s(t,e)?i.push(l):o.push(l):n.push(l)}return[...i,...n,...o]}(i,n?t(n):"ltr")}afterRender(){if(!this.isApplied)return;const t=this.grid,e=[...this.columns];if(!c(e))return u(t),void(this.isApplied=!1);queueMicrotask(()=>{d(t,e)})}handleQuery(t){switch(t.type){case f:return null==r(t.context)&&void 0;case"getStickyOffsets":return{left:Object.fromEntries(this.leftOffsets),right:Object.fromEntries(this.rightOffsets)};case"getContextMenuItems":{const e=t.context;if(!e.isHeader)return;const i=e.column;if(!i?.field)return;if(i.meta?.lockPinning)return;const n=this.grid?.getPluginByName("groupingColumns");if(n?.isGroupingActive())return;const s=[];return null!=r(i)?s.push({id:"pinned/unpin",label:"Unpin Column",icon:"📌",order:40,action:()=>this.setPinPosition(i.field,void 0)}):(s.push({id:"pinned/pin-left",label:"Pin Left",icon:"⬅",order:40,action:()=>this.setPinPosition(i.field,"left")}),s.push({id:"pinned/pin-right",label:"Pin Right",icon:"➡",order:41,action:()=>this.setPinPosition(i.field,"right")})),s}default:return}}setPinPosition(t,e){const i=this.columns;if(!i?.length)return;const n=i.findIndex(e=>e.field===t);if(-1===n)return;const s=this.grid;if(e){0===this.#e.length&&(this.#e=i.map(t=>t.field));const n=i.map(i=>{if(i.field!==t)return i;const n={...i};return n.pinned=e,delete n.sticky,n});s.columns=n}else{const e={...i[n]};delete e.pinned,delete e.sticky;const o=[...i];o.splice(n,1);const l=this.#e.indexOf(t);if(l>=0){let t=o.length;for(let e=0;e<o.length;e++){if(r(o[e]))continue;if(this.#e.indexOf(o[e].field)>l){t=e;break}}o.splice(t,0,e)}else o.splice(Math.min(n,o.length),0,e);o.some(t=>null!=r(t))||(this.#e=[]),s.columns=o}}refreshStickyOffsets(){const t=[...this.columns];d(this.grid,t)}getLeftPinnedColumns(){return function(t,e="ltr"){return t.filter(t=>o(t,e))}([...this.columns],t(this.grid))}getRightPinnedColumns(){return function(t,e="ltr"){return t.filter(t=>l(t,e))}([...this.columns],t(this.grid))}clearStickyPositions(){u(this.grid)}getHorizontalScrollOffsets(t,e){if(!this.isApplied)return;let i=0,n=0;if(t){const e=t.querySelectorAll(".sticky-left"),r=t.querySelectorAll(".sticky-right");e.forEach(t=>{i+=t.offsetWidth}),r.forEach(t=>{n+=t.offsetWidth})}else{this.grid.querySelectorAll(".header-row .cell").forEach(t=>{t.classList.contains("sticky-left")?i+=t.offsetWidth:t.classList.contains("sticky-right")&&(n+=t.offsetWidth)})}const r=e?.classList.contains("sticky-left")||e?.classList.contains("sticky-right");return{left:i,right:n,skipScroll:r}}}export{a as PinnedColumnsPlugin};
1
+ function t(t){try{if("rtl"===getComputedStyle(t).direction)return"rtl"}catch{}try{const e=t.closest?.("[dir]")?.getAttribute("dir");if("rtl"===e)return"rtl"}catch{}return"ltr"}const e='<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>',i={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:e,filterActive:e,print:"🖨️"};class n{static dependencies;static manifest;aliases;version="undefined"!=typeof __GRID_VERSION__?__GRID_VERSION__:"dev";styles;cellRenderers;headerRenderers;cellEditors;grid;config;userConfig;#t;get defaultConfig(){return{}}constructor(t={}){this.userConfig=t}attach(t){this.#t?.abort(),this.#t=new AbortController,this.grid=t,this.config={...this.defaultConfig,...this.userConfig}}detach(){this.#t?.abort(),this.#t=void 0}getPlugin(t){return this.grid?.getPlugin(t)}emit(t,e){this.grid?.dispatchEvent?.(new CustomEvent(t,{detail:e,bubbles:!0}))}emitCancelable(t,e){const i=new CustomEvent(t,{detail:e,bubbles:!0,cancelable:!0});return this.grid?.dispatchEvent?.(i),i.defaultPrevented}on(t,e){this.grid?._pluginManager?.subscribe(this,t,e)}off(t){this.grid?._pluginManager?.unsubscribe(this,t)}emitPluginEvent(t,e){this.grid?._pluginManager?.emitPluginEvent(t,e)}requestRender(){this.grid?.requestRender?.()}requestColumnsRender(){this.grid?.requestColumnsRender?.()}requestRenderWithFocus(){this.grid?.requestRenderWithFocus?.()}requestAfterRender(){this.grid?.requestAfterRender?.()}get rows(){return this.grid?.rows??[]}get sourceRows(){return this.grid?.sourceRows??[]}get columns(){return this.grid?.columns??[]}get visibleColumns(){return this.grid?._visibleColumns??[]}get gridElement(){return this.grid}get disconnectSignal(){return this.#t?.signal??this.grid?.disconnectSignal}get gridIcons(){const t=this.grid?.gridConfig?.icons??{};return{...i,...t}}get isAnimationEnabled(){const t=this.grid?.effectiveConfig?.animation?.mode??"reduced-motion";if(!1===t||"off"===t)return!1;if(!0===t||"on"===t)return!0;const e=this.gridElement;if(e){return"0"!==getComputedStyle(e).getPropertyValue("--tbw-animation-enabled").trim()}return!0}get animationDuration(){const t=this.gridElement;if(t){const e=getComputedStyle(t).getPropertyValue("--tbw-animation-duration").trim(),i=parseInt(e,10);if(!isNaN(i))return i}return 200}resolveIcon(t,e){return void 0!==e?e:this.gridIcons[t]}setIcon(t,e){"string"==typeof e?t.innerHTML=e:e instanceof HTMLElement&&(t.innerHTML="",t.appendChild(e.cloneNode(!0)))}warn(t){console.warn(`[tbw-grid:${this.name}] ${t}`)}}function r(t){return t.pinned??t.sticky??t.meta?.pinned??t.meta?.sticky}function s(t,e){return function(t,e){return"left"===t||"right"===t?t:"rtl"===e?"start"===t?"right":"left":"start"===t?"left":"right"}(t,e)}function o(t,e){const i=r(t);return!!i&&"left"===s(i,e)}function l(t,e){const i=r(t);return!!i&&"right"===s(i,e)}function c(t){return t.some(t=>null!=r(t))}function d(e,i){const n=Array.from(e.querySelectorAll(".header-row .cell"));if(!n.length)return;const r=t(e);let s=0;for(const t of i)if(o(t,r)){const i=n.find(e=>e.getAttribute("data-field")===t.field);i&&(i.classList.add("sticky-left"),i.style.position="sticky",i.style.left=s+"px",e.querySelectorAll(`.data-grid-row .cell[data-field="${t.field}"]`).forEach(t=>{t.classList.add("sticky-left"),t.style.position="sticky",t.style.left=s+"px"}),s+=i.offsetWidth)}let c=0;for(const t of[...i].reverse())if(l(t,r)){const i=n.find(e=>e.getAttribute("data-field")===t.field);i&&(i.classList.add("sticky-right"),i.style.position="sticky",i.style.right=c+"px",e.querySelectorAll(`.data-grid-row .cell[data-field="${t.field}"]`).forEach(t=>{t.classList.add("sticky-right"),t.style.position="sticky",t.style.right=c+"px"}),c+=i.offsetWidth)}}function u(t){t.querySelectorAll(".sticky-left, .sticky-right").forEach(t=>{t.classList.remove("sticky-left","sticky-right"),t.style.position="",t.style.left="",t.style.right=""})}const f="canMoveColumn";class a extends n{static manifest={ownedProperties:[{property:"pinned",level:"column",description:'the "pinned" column property',isUsed:t=>"left"===t||"right"===t||"start"===t||"end"===t},{property:"sticky",level:"column",description:'the "sticky" column property (deprecated, use "pinned")',isUsed:t=>"left"===t||"right"===t||"start"===t||"end"===t}],incompatibleWith:[{name:"groupingColumns",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."}],queries:[{type:f,description:"Prevents pinned (sticky) columns from being moved/reordered"},{type:"getStickyOffsets",description:"Returns the sticky offsets for left/right pinned columns"},{type:"getContextMenuItems",description:"Contributes pin/unpin items to the header context menu"}]};name="pinnedColumns";get defaultConfig(){return{}}isApplied=!1;leftOffsets=/* @__PURE__ */new Map;rightOffsets=/* @__PURE__ */new Map;#e=[];detach(){this.leftOffsets.clear(),this.rightOffsets.clear(),this.isApplied=!1,this.#e=[]}static detect(t,e){const i=e?.columns;return!!Array.isArray(i)&&c(i)}processColumns(e){const i=[...e];if(this.isApplied=c(i),!this.isApplied)return i;const n=this.gridElement;return function(t,e="ltr"){const i=[],n=[],o=[];for(const l of t){const t=r(l);t?"left"===s(t,e)?i.push(l):o.push(l):n.push(l)}return[...i,...n,...o]}(i,n?t(n):"ltr")}afterRender(){if(!this.isApplied)return;const t=this.grid,e=[...this.columns];if(!c(e))return u(t),void(this.isApplied=!1);queueMicrotask(()=>{d(t,e)})}handleQuery(t){switch(t.type){case f:return null==r(t.context)&&void 0;case"getStickyOffsets":return{left:Object.fromEntries(this.leftOffsets),right:Object.fromEntries(this.rightOffsets)};case"getContextMenuItems":{const e=t.context;if(!e.isHeader)return;const i=e.column;if(!i?.field)return;if(i.meta?.lockPinning)return;const n=this.grid?.getPluginByName("groupingColumns");if(n?.isGroupingActive())return;const s=[];return null!=r(i)?s.push({id:"pinned/unpin",label:"Unpin Column",icon:"📌",order:40,action:()=>this.setPinPosition(i.field,void 0)}):(s.push({id:"pinned/pin-left",label:"Pin Left",icon:"⬅",order:40,action:()=>this.setPinPosition(i.field,"left")}),s.push({id:"pinned/pin-right",label:"Pin Right",icon:"➡",order:41,action:()=>this.setPinPosition(i.field,"right")})),s}default:return}}setPinPosition(t,e){const i=this.columns;if(!i?.length)return;const n=i.findIndex(e=>e.field===t);if(-1===n)return;const s=this.grid;if(e){0===this.#e.length&&(this.#e=i.map(t=>t.field));const n=i.map(i=>{if(i.field!==t)return i;const n={...i};return n.pinned=e,delete n.sticky,n});s.columns=n}else{const e={...i[n]};delete e.pinned,delete e.sticky;const o=[...i];o.splice(n,1);const l=this.#e.indexOf(t);if(l>=0){let t=o.length;for(let e=0;e<o.length;e++){if(r(o[e]))continue;if(this.#e.indexOf(o[e].field)>l){t=e;break}}o.splice(t,0,e)}else o.splice(Math.min(n,o.length),0,e);o.some(t=>null!=r(t))||(this.#e=[]),s.columns=o}}refreshStickyOffsets(){const t=[...this.columns];d(this.grid,t)}getLeftPinnedColumns(){return function(t,e="ltr"){return t.filter(t=>o(t,e))}([...this.columns],t(this.grid))}getRightPinnedColumns(){return function(t,e="ltr"){return t.filter(t=>l(t,e))}([...this.columns],t(this.grid))}clearStickyPositions(){u(this.grid)}getHorizontalScrollOffsets(t,e){if(!this.isApplied)return;let i=0,n=0;if(t){const e=t.querySelectorAll(".sticky-left"),r=t.querySelectorAll(".sticky-right");e.forEach(t=>{i+=t.offsetWidth}),r.forEach(t=>{n+=t.offsetWidth})}else{this.grid.querySelectorAll(".header-row .cell").forEach(t=>{t.classList.contains("sticky-left")?i+=t.offsetWidth:t.classList.contains("sticky-right")&&(n+=t.offsetWidth)})}const r=e?.classList.contains("sticky-left")||e?.classList.contains("sticky-right");return{left:i,right:n,skipScroll:r}}}export{a as PinnedColumnsPlugin};
2
2
  //# sourceMappingURL=index.js.map