@toolbox-web/grid 1.23.4 → 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 (207) 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 +21 -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 +8 -2
  13. package/lib/core/plugin/base-plugin.d.ts.map +1 -1
  14. package/lib/core/plugin/types.d.ts +1 -1
  15. package/lib/core/types.d.ts +59 -0
  16. package/lib/core/types.d.ts.map +1 -1
  17. package/lib/features/clipboard.d.ts +8 -0
  18. package/lib/features/clipboard.d.ts.map +1 -0
  19. package/lib/features/clipboard.js +2 -0
  20. package/lib/features/clipboard.js.map +1 -0
  21. package/lib/features/column-virtualization.d.ts +8 -0
  22. package/lib/features/column-virtualization.d.ts.map +1 -0
  23. package/lib/features/column-virtualization.js +2 -0
  24. package/lib/features/column-virtualization.js.map +1 -0
  25. package/lib/features/context-menu.d.ts +8 -0
  26. package/lib/features/context-menu.d.ts.map +1 -0
  27. package/lib/features/context-menu.js +2 -0
  28. package/lib/features/context-menu.js.map +1 -0
  29. package/lib/features/editing.d.ts +8 -0
  30. package/lib/features/editing.d.ts.map +1 -0
  31. package/lib/features/editing.js +2 -0
  32. package/lib/features/editing.js.map +1 -0
  33. package/lib/features/export.d.ts +8 -0
  34. package/lib/features/export.d.ts.map +1 -0
  35. package/lib/features/export.js +2 -0
  36. package/lib/features/export.js.map +1 -0
  37. package/lib/features/filtering.d.ts +8 -0
  38. package/lib/features/filtering.d.ts.map +1 -0
  39. package/lib/features/filtering.js +2 -0
  40. package/lib/features/filtering.js.map +1 -0
  41. package/lib/features/grouping-columns.d.ts +8 -0
  42. package/lib/features/grouping-columns.d.ts.map +1 -0
  43. package/lib/features/grouping-columns.js +2 -0
  44. package/lib/features/grouping-columns.js.map +1 -0
  45. package/lib/features/grouping-rows.d.ts +8 -0
  46. package/lib/features/grouping-rows.d.ts.map +1 -0
  47. package/lib/features/grouping-rows.js +2 -0
  48. package/lib/features/grouping-rows.js.map +1 -0
  49. package/lib/features/magic-string.es-CkyDP9Ir.mjs.map +1 -0
  50. package/lib/features/master-detail.d.ts +8 -0
  51. package/lib/features/master-detail.d.ts.map +1 -0
  52. package/lib/features/master-detail.js +2 -0
  53. package/lib/features/master-detail.js.map +1 -0
  54. package/lib/features/multi-sort.d.ts +10 -0
  55. package/lib/features/multi-sort.d.ts.map +1 -0
  56. package/lib/features/multi-sort.js +2 -0
  57. package/lib/features/multi-sort.js.map +1 -0
  58. package/lib/features/pinned-columns.d.ts +18 -0
  59. package/lib/features/pinned-columns.d.ts.map +1 -0
  60. package/lib/features/pinned-columns.js +2 -0
  61. package/lib/features/pinned-columns.js.map +1 -0
  62. package/lib/features/pinned-rows.d.ts +8 -0
  63. package/lib/features/pinned-rows.d.ts.map +1 -0
  64. package/lib/features/pinned-rows.js +2 -0
  65. package/lib/features/pinned-rows.js.map +1 -0
  66. package/lib/features/pivot.d.ts +8 -0
  67. package/lib/features/pivot.d.ts.map +1 -0
  68. package/lib/features/pivot.js +2 -0
  69. package/lib/features/pivot.js.map +1 -0
  70. package/lib/features/print.d.ts +8 -0
  71. package/lib/features/print.d.ts.map +1 -0
  72. package/lib/features/print.js +2 -0
  73. package/lib/features/print.js.map +1 -0
  74. package/lib/features/registry.d.ts +50 -0
  75. package/lib/features/registry.d.ts.map +1 -0
  76. package/lib/features/registry.js +2 -0
  77. package/lib/features/registry.js.map +1 -0
  78. package/lib/features/registry.spec.js +5 -0
  79. package/lib/features/registry.spec.js.map +1 -0
  80. package/lib/features/reorder-columns.d.ts +10 -0
  81. package/lib/features/reorder-columns.d.ts.map +1 -0
  82. package/lib/features/reorder-columns.js +2 -0
  83. package/lib/features/reorder-columns.js.map +1 -0
  84. package/lib/features/reorder-rows.d.ts +10 -0
  85. package/lib/features/reorder-rows.d.ts.map +1 -0
  86. package/lib/features/reorder-rows.js +2 -0
  87. package/lib/features/reorder-rows.js.map +1 -0
  88. package/lib/features/responsive.d.ts +8 -0
  89. package/lib/features/responsive.d.ts.map +1 -0
  90. package/lib/features/responsive.js +2 -0
  91. package/lib/features/responsive.js.map +1 -0
  92. package/lib/features/selection.d.ts +8 -0
  93. package/lib/features/selection.d.ts.map +1 -0
  94. package/lib/features/selection.js +2 -0
  95. package/lib/features/selection.js.map +1 -0
  96. package/lib/features/server-side.d.ts +8 -0
  97. package/lib/features/server-side.d.ts.map +1 -0
  98. package/lib/features/server-side.js +2 -0
  99. package/lib/features/server-side.js.map +1 -0
  100. package/lib/features/tree.d.ts +8 -0
  101. package/lib/features/tree.d.ts.map +1 -0
  102. package/lib/features/tree.js +2 -0
  103. package/lib/features/tree.js.map +1 -0
  104. package/lib/features/undo-redo.d.ts +8 -0
  105. package/lib/features/undo-redo.d.ts.map +1 -0
  106. package/lib/features/undo-redo.js +2 -0
  107. package/lib/features/undo-redo.js.map +1 -0
  108. package/lib/features/visibility.d.ts +8 -0
  109. package/lib/features/visibility.d.ts.map +1 -0
  110. package/lib/features/visibility.js +2 -0
  111. package/lib/features/visibility.js.map +1 -0
  112. package/lib/plugins/clipboard/index.js +1 -1
  113. package/lib/plugins/clipboard/index.js.map +1 -1
  114. package/lib/plugins/column-virtualization/index.js +1 -1
  115. package/lib/plugins/column-virtualization/index.js.map +1 -1
  116. package/lib/plugins/context-menu/index.js +1 -1
  117. package/lib/plugins/context-menu/index.js.map +1 -1
  118. package/lib/plugins/editing/index.js +1 -1
  119. package/lib/plugins/editing/index.js.map +1 -1
  120. package/lib/plugins/export/index.js +1 -1
  121. package/lib/plugins/export/index.js.map +1 -1
  122. package/lib/plugins/filtering/index.js +1 -1
  123. package/lib/plugins/filtering/index.js.map +1 -1
  124. package/lib/plugins/filtering/types.d.ts +428 -27
  125. package/lib/plugins/filtering/types.d.ts.map +1 -1
  126. package/lib/plugins/grouping-columns/index.d.ts +1 -1
  127. package/lib/plugins/grouping-columns/index.js +1 -1
  128. package/lib/plugins/grouping-columns/index.js.map +1 -1
  129. package/lib/plugins/grouping-rows/index.d.ts +2 -2
  130. package/lib/plugins/grouping-rows/index.d.ts.map +1 -1
  131. package/lib/plugins/grouping-rows/index.js +1 -1
  132. package/lib/plugins/grouping-rows/index.js.map +1 -1
  133. package/lib/plugins/master-detail/MasterDetailPlugin.d.ts +2 -2
  134. package/lib/plugins/master-detail/index.js +1 -1
  135. package/lib/plugins/master-detail/index.js.map +1 -1
  136. package/lib/plugins/multi-sort/index.js +1 -1
  137. package/lib/plugins/multi-sort/index.js.map +1 -1
  138. package/lib/plugins/pinned-columns/index.js +1 -1
  139. package/lib/plugins/pinned-columns/index.js.map +1 -1
  140. package/lib/plugins/pinned-columns/types.d.ts +3 -3
  141. package/lib/plugins/pinned-rows/index.js +1 -1
  142. package/lib/plugins/pinned-rows/index.js.map +1 -1
  143. package/lib/plugins/pivot/index.js +1 -1
  144. package/lib/plugins/pivot/index.js.map +1 -1
  145. package/lib/plugins/print/index.js +1 -1
  146. package/lib/plugins/print/index.js.map +1 -1
  147. package/lib/plugins/{reorder → reorder-columns}/ReorderPlugin.d.ts +5 -3
  148. package/lib/plugins/reorder-columns/ReorderPlugin.d.ts.map +1 -0
  149. package/lib/plugins/reorder-columns/column-drag.d.ts.map +1 -0
  150. package/lib/plugins/{reorder → reorder-columns}/index.d.ts +2 -2
  151. package/lib/plugins/reorder-columns/index.d.ts.map +1 -0
  152. package/lib/plugins/reorder-columns/index.js +2 -0
  153. package/lib/plugins/reorder-columns/index.js.map +1 -0
  154. package/lib/plugins/{reorder → reorder-columns}/types.d.ts +5 -0
  155. package/lib/plugins/reorder-columns/types.d.ts.map +1 -0
  156. package/lib/plugins/{row-reorder → reorder-rows}/RowReorderPlugin.d.ts +5 -3
  157. package/lib/plugins/reorder-rows/RowReorderPlugin.d.ts.map +1 -0
  158. package/lib/plugins/{row-reorder → reorder-rows}/index.d.ts +2 -2
  159. package/lib/plugins/reorder-rows/index.d.ts.map +1 -0
  160. package/lib/plugins/reorder-rows/index.js +2 -0
  161. package/lib/plugins/reorder-rows/index.js.map +1 -0
  162. package/lib/plugins/{row-reorder → reorder-rows}/types.d.ts +5 -0
  163. package/lib/plugins/reorder-rows/types.d.ts.map +1 -0
  164. package/lib/plugins/responsive/ResponsivePlugin.d.ts +2 -2
  165. package/lib/plugins/responsive/index.js +1 -1
  166. package/lib/plugins/responsive/index.js.map +1 -1
  167. package/lib/plugins/selection/index.js +1 -1
  168. package/lib/plugins/selection/index.js.map +1 -1
  169. package/lib/plugins/server-side/index.js +1 -1
  170. package/lib/plugins/server-side/index.js.map +1 -1
  171. package/lib/plugins/tree/index.js +1 -1
  172. package/lib/plugins/tree/index.js.map +1 -1
  173. package/lib/plugins/undo-redo/index.js +1 -1
  174. package/lib/plugins/undo-redo/index.js.map +1 -1
  175. package/lib/plugins/visibility/VisibilityPlugin.d.ts +1 -1
  176. package/lib/plugins/visibility/index.js +1 -1
  177. package/lib/plugins/visibility/index.js.map +1 -1
  178. package/package.json +17 -2
  179. package/public.d.ts +9 -2
  180. package/public.d.ts.map +1 -1
  181. package/umd/grid.all.umd.js +1 -1
  182. package/umd/grid.all.umd.js.map +1 -1
  183. package/umd/grid.umd.js +1 -1
  184. package/umd/grid.umd.js.map +1 -1
  185. package/umd/plugins/master-detail.umd.js.map +1 -1
  186. package/umd/plugins/reorder-columns.umd.js +2 -0
  187. package/umd/plugins/reorder-columns.umd.js.map +1 -0
  188. package/umd/plugins/reorder-rows.umd.js +2 -0
  189. package/umd/plugins/reorder-rows.umd.js.map +1 -0
  190. package/umd/plugins/responsive.umd.js.map +1 -1
  191. package/umd/plugins/visibility.umd.js.map +1 -1
  192. package/lib/plugins/reorder/ReorderPlugin.d.ts.map +0 -1
  193. package/lib/plugins/reorder/column-drag.d.ts.map +0 -1
  194. package/lib/plugins/reorder/index.d.ts.map +0 -1
  195. package/lib/plugins/reorder/index.js +0 -2
  196. package/lib/plugins/reorder/index.js.map +0 -1
  197. package/lib/plugins/reorder/types.d.ts.map +0 -1
  198. package/lib/plugins/row-reorder/RowReorderPlugin.d.ts.map +0 -1
  199. package/lib/plugins/row-reorder/index.d.ts.map +0 -1
  200. package/lib/plugins/row-reorder/index.js +0 -2
  201. package/lib/plugins/row-reorder/index.js.map +0 -1
  202. package/lib/plugins/row-reorder/types.d.ts.map +0 -1
  203. package/umd/plugins/reorder.umd.js +0 -2
  204. package/umd/plugins/reorder.umd.js.map +0 -1
  205. package/umd/plugins/row-reorder.umd.js +0 -2
  206. package/umd/plugins/row-reorder.umd.js.map +0 -1
  207. /package/lib/plugins/{reorder → reorder-columns}/column-drag.d.ts +0 -0
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../libs/grid/src/lib/plugins/reorder/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,gBAAgB,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,CAAC;AAEvD,mDAAmD;AACnD,MAAM,WAAW,aAAa;IAC5B;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAE7B;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,mDAAmD;AACnD,MAAM,WAAW,YAAY;IAC3B,8CAA8C;IAC9C,UAAU,EAAE,OAAO,CAAC;IACpB,qDAAqD;IACrD,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,+CAA+C;IAC/C,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,4BAA4B;IAC5B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,mCAAmC;IACnC,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAED,kDAAkD;AAClD,MAAM,WAAW,gBAAgB;IAC/B,yCAAyC;IACzC,KAAK,EAAE,MAAM,CAAC;IACd,uCAAuC;IACvC,SAAS,EAAE,MAAM,CAAC;IAClB,kCAAkC;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,+CAA+C;IAC/C,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAGD,OAAO,QAAQ,kBAAkB,CAAC;IAChC,UAAU,aAAa;QACrB,OAAO,EAAE,OAAO,iBAAiB,EAAE,aAAa,CAAC;KAClD;CACF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"RowReorderPlugin.d.ts","sourceRoot":"","sources":["../../../../../../libs/grid/src/lib/plugins/row-reorder/RowReorderPlugin.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,KAAK,EAAE,YAAY,EAAgB,MAAM,kBAAkB,CAAC;AAEnE,OAAO,KAAK,EAA8B,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE5E,4CAA4C;AAC5C,eAAO,MAAM,qBAAqB,mBAAmB,CAAC;AAEtD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;AACH,qBAAa,gBAAiB,SAAQ,cAAc,CAAC,gBAAgB,CAAC;IACpE,gBAAgB;IAChB,QAAQ,CAAC,IAAI,gBAAgB;IAC7B,gBAAgB;IAChB,SAAkB,MAAM,SAAU;IAElC,gBAAgB;IAChB,cAAuB,aAAa,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAShE;IAED;;;OAGG;IACH,OAAO,KAAK,aAAa,GAQxB;IAGD,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,eAAe,CAAuB;IAC9C,OAAO,CAAC,YAAY,CAAuB;IAC3C,OAAO,CAAC,WAAW,CAA4B;IAC/C,OAAO,CAAC,aAAa,CAA8C;IACnE,qDAAqD;IACrD,OAAO,CAAC,YAAY,CAAK;IAKzB,gBAAgB;IACP,MAAM,IAAI,IAAI;IAWvB,gBAAgB;IACP,cAAc,CAAC,OAAO,EAAE,SAAS,YAAY,EAAE,GAAG,YAAY,EAAE;IAwCzE,gBAAgB;IACP,WAAW,IAAI,IAAI;IA+B5B;;;OAGG;IACM,SAAS,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,GAAG,IAAI;IAoCxD;;;;OAIG;IACM,WAAW,IAAI,IAAI;IAS5B;;;;OAIG;IACH,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI;IAiBjD;;;;OAIG;IACH,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO;IAevD;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAwBhC;;;OAGG;IACH,OAAO,CAAC,qBAAqB;IAkD7B;;;OAGG;IACH,OAAO,CAAC,kBAAkB;IAmD1B;;;OAGG;IACH,OAAO,CAAC,gBAAgB;IAmCxB;;OAEG;IACH,OAAO,CAAC,WAAW;IAiCnB;;;OAGG;IACH,OAAO,CAAC,mBAAmB;IAW3B;;;;;;OAMG;IACH,OAAO,CAAC,WAAW;IAoEnB;;;OAGG;IACH,OAAO,CAAC,WAAW;IAKnB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAMxB;;OAEG;IACH,OAAO,CAAC,kBAAkB;CAO3B"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../libs/grid/src/lib/plugins/row-reorder/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC7E,YAAY,EAAE,WAAW,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC"}
@@ -1,2 +0,0 @@
1
- document.createElement("template").innerHTML='<div class="cell" role="gridcell" part="cell"></div>';function e(e,t){if(e._virtualization?.enabled){const{rowHeight:t,container:r,viewportEl:o}=e._virtualization,i=r,n=o?.clientHeight??i?.clientHeight??0;if(i&&n>0){const r=e._focusRow*t;r<i.scrollTop?i.scrollTop=r:r+t>i.scrollTop+n&&(i.scrollTop=r-n+t)}}const r=void 0!==e._activeEditRows&&-1!==e._activeEditRows||!!e._isGridEditMode;var o;r||e.refreshVirtualWindow(!1),(o=e._bodyEl)&&o.querySelectorAll(".cell-focus").forEach(e=>e.classList.remove("cell-focus")),Array.from(e._bodyEl.querySelectorAll('[aria-selected="true"]')).forEach(e=>{e.setAttribute("aria-selected","false")});const i=e._focusRow,n=e._virtualization.start??0,s=e._virtualization.end??e._rows.length;if(i>=n&&i<s){const o=e._bodyEl.querySelectorAll(".data-grid-row")[i-n];let s=o?.children[e._focusCol];if(s&&s.classList?.contains("cell")||(s=o?.querySelector(`.cell[data-col="${e._focusCol}"]`)??o?.querySelector(".cell[data-col]")),s){s.classList.add("cell-focus"),s.setAttribute("aria-selected","true");const i=e.querySelector(".tbw-scroll-area");if(i&&s&&(!r||t?.forceHorizontalScroll)){const t=e._getHorizontalScrollOffsets?.(o??void 0,s)??{left:0,right:0};if(!t.skipScroll){const e=s.getBoundingClientRect(),r=i.getBoundingClientRect(),o=e.left-r.left+i.scrollLeft,n=o+e.width,a=i.scrollLeft+t.left,l=i.scrollLeft+i.clientWidth-t.right;o<a?i.scrollLeft=o-t.left:n>l&&(i.scrollLeft=n-i.clientWidth+t.right)}}if(r&&s.classList.contains("editing")){const e=s.querySelector('input,select,textarea,[contenteditable="true"],[contenteditable=""],[tabindex]:not([tabindex="-1"])');if(e&&document.activeElement!==e)try{e.focus({preventScroll:!0})}catch{}}else if(r&&!s.contains(document.activeElement)){s.hasAttribute("tabindex")||s.setAttribute("tabindex","-1");try{s.focus({preventScroll:!0})}catch{}}else if(!r){const t=e;document.activeElement!==t&&t.focus({preventScroll:!0})}}}}document.createElement("template").innerHTML='<div class="data-grid-row" role="row" part="row"></div>';const t='<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>',r={expand:"▶",collapse:"▼",sortAsc:"▲",sortDesc:"▼",sortNone:"⇅",submenuArrow:"▶",dragHandle:"⋮⋮",toolPanel:"☰",filter:t,filterActive:t,print:"🖨️"};class o{static dependencies;static manifest;version="undefined"!=typeof __GRID_VERSION__?__GRID_VERSION__:"dev";styles;cellRenderers;headerRenderers;cellEditors;grid;config;userConfig;#e;get defaultConfig(){return{}}constructor(e={}){this.userConfig=e}attach(e){this.#e?.abort(),this.#e=new AbortController,this.grid=e,this.config={...this.defaultConfig,...this.userConfig}}detach(){this.#e?.abort(),this.#e=void 0}getPlugin(e){return this.grid?.getPlugin(e)}emit(e,t){this.grid?.dispatchEvent?.(new CustomEvent(e,{detail:t,bubbles:!0}))}emitCancelable(e,t){const r=new CustomEvent(e,{detail:t,bubbles:!0,cancelable:!0});return this.grid?.dispatchEvent?.(r),r.defaultPrevented}on(e,t){this.grid?._pluginManager?.subscribe(this,e,t)}off(e){this.grid?._pluginManager?.unsubscribe(this,e)}emitPluginEvent(e,t){this.grid?._pluginManager?.emitPluginEvent(e,t)}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.#e?.signal??this.grid?.disconnectSignal}get gridIcons(){const e=this.grid?.gridConfig?.icons??{};return{...r,...e}}get isAnimationEnabled(){const e=this.grid?.effectiveConfig?.animation?.mode??"reduced-motion";if(!1===e||"off"===e)return!1;if(!0===e||"on"===e)return!0;const t=this.gridElement;if(t){return"0"!==getComputedStyle(t).getPropertyValue("--tbw-animation-enabled").trim()}return!0}get animationDuration(){const e=this.gridElement;if(e){const t=getComputedStyle(e).getPropertyValue("--tbw-animation-duration").trim(),r=parseInt(t,10);if(!isNaN(r))return r}return 200}resolveIcon(e,t){return void 0!==t?t:this.gridIcons[e]}setIcon(e,t){"string"==typeof t?e.innerHTML=t:t instanceof HTMLElement&&(e.innerHTML="",e.appendChild(t.cloneNode(!0)))}warn(e){console.warn(`[tbw-grid:${this.name}] ${e}`)}}const i="__tbw_row_drag";class n extends o{name="rowReorder";styles='@layer tbw-plugins{[data-field=__tbw_row_drag]{display:flex;align-items:center;justify-content:center}.dg-row-drag-handle{display:flex;align-items:center;justify-content:center;min-width:1em;min-height:1em;cursor:grab;-webkit-user-select:none;user-select:none;color:var(--tbw-row-reorder-handle-color, var(--tbw-color-fg-muted));transition:color var(--tbw-transition-duration, .12s) var(--tbw-transition-ease, ease);font-size:var(--tbw-font-size, 1em);letter-spacing:-2px}.dg-row-drag-handle:hover{color:var(--tbw-row-reorder-handle-hover, var(--tbw-color-fg))}.dg-row-drag-handle:active{cursor:grabbing}.data-grid-row.dragging{opacity:.6}.data-grid-row.drop-target{position:relative}.data-grid-row.drop-target.drop-before:before{content:"";position:absolute;top:0;left:0;right:0;height:2px;background-color:var(--tbw-row-reorder-indicator, var(--tbw-color-accent));z-index:10}.data-grid-row.drop-target.drop-after:after{content:"";position:absolute;bottom:0;left:0;right:0;height:2px;background-color:var(--tbw-row-reorder-indicator, var(--tbw-color-accent));z-index:10}.data-grid-row.keyboard-moving{background-color:var(--tbw-row-reorder-moving-bg, var(--tbw-focus-background));box-shadow:0 0 0 1px var(--tbw-row-reorder-moving-border, var(--tbw-color-accent)) inset}.data-grid-row.flip-animating{transition:transform var(--tbw-animation-duration, .2s) ease-out;will-change:transform;z-index:1}}';get defaultConfig(){return{enableKeyboard:!0,showDragHandle:!0,dragHandlePosition:"left",dragHandleWidth:40,debounceMs:150,animation:"flip"}}get animationType(){return!!this.isAnimationEnabled&&(void 0!==this.config.animation?this.config.animation:"flip")}isDragging=!1;draggedRowIndex=null;dropRowIndex=null;pendingMove=null;debounceTimer=null;lastFocusCol=0;detach(){this.clearDebounceTimer(),this.isDragging=!1,this.draggedRowIndex=null,this.dropRowIndex=null,this.pendingMove=null}processColumns(e){if(!this.config.showDragHandle)return[...e];const t={field:i,header:"",width:this.config.dragHandleWidth??40,resizable:!1,sortable:!1,filterable:!1,meta:{lockPosition:!0,suppressMovable:!0,utility:!0},viewRenderer:()=>{const e=document.createElement("div");return e.className="dg-row-drag-handle",e.setAttribute("aria-label","Drag to reorder"),e.setAttribute("role","button"),e.setAttribute("tabindex","-1"),e.draggable=!0,this.setIcon(e,this.resolveIcon("dragHandle")),e}};return"right"===this.config.dragHandlePosition?[...e,t]:[t,...e]}afterRender(){if(!this.config.showDragHandle)return;const e=this.gridElement;if(!e)return;e.querySelectorAll(".dg-row-drag-handle").forEach(e=>{const t=e;if(t.getAttribute("data-drag-bound"))return;t.setAttribute("data-drag-bound","true");const r=t.closest(".data-grid-row");r&&this.setupHandleDragListeners(t,r)});e.querySelectorAll(".data-grid-row").forEach(e=>{const t=e;t.getAttribute("data-drop-bound")||(t.setAttribute("data-drop-bound","true"),this.setupRowDropListeners(t))})}onKeyDown(e){if(!this.config.enableKeyboard)return;if(!e.ctrlKey||"ArrowUp"!==e.key&&"ArrowDown"!==e.key)return;const t=this.grid,r=t._focusRow,o=t._rows??this.sourceRows;if(r<0||r>=o.length)return;const i="ArrowUp"===e.key?"up":"down",n="up"===i?r-1:r+1;if(n<0||n>=o.length)return;const s=o[r];return!this.config.canMove||this.config.canMove(s,r,n,i)?(this.handleKeyboardMove(s,r,n,i,t._focusCol),e.preventDefault(),e.stopPropagation(),!0):void 0}onCellClick(){this.flushPendingMove()}moveRow(e,t){const r=[...this.sourceRows];if(e<0||e>=r.length)return;if(t<0||t>=r.length)return;if(e===t)return;const o=t<e?"up":"down",i=r[e];this.config.canMove&&!this.config.canMove(i,e,t,o)||this.executeMove(i,e,t,"keyboard")}canMoveRow(e,t){const r=this.sourceRows;if(e<0||e>=r.length)return!1;if(t<0||t>=r.length)return!1;if(e===t)return!1;if(!this.config.canMove)return!0;const o=t<e?"up":"down";return this.config.canMove(r[e],e,t,o)}setupHandleDragListeners(e,t){e.addEventListener("dragstart",e=>{const r=this.getRowIndex(t);r<0||(this.isDragging=!0,this.draggedRowIndex=r,e.dataTransfer&&(e.dataTransfer.effectAllowed="move",e.dataTransfer.setData("text/plain",String(r))),t.classList.add("dragging"))}),e.addEventListener("dragend",()=>{this.isDragging=!1,this.draggedRowIndex=null,this.dropRowIndex=null,this.clearDragClasses()})}setupRowDropListeners(e){e.addEventListener("dragover",t=>{if(t.preventDefault(),!this.isDragging||null===this.draggedRowIndex)return;const r=this.getRowIndex(e);if(r<0||r===this.draggedRowIndex)return;const o=e.getBoundingClientRect(),i=o.top+o.height/2,n=t.clientY<i;this.dropRowIndex=n?r:r+1,e.classList.add("drop-target"),e.classList.toggle("drop-before",n),e.classList.toggle("drop-after",!n)}),e.addEventListener("dragleave",()=>{e.classList.remove("drop-target","drop-before","drop-after")}),e.addEventListener("drop",e=>{e.preventDefault();const t=this.draggedRowIndex;let r=this.dropRowIndex;if(this.isDragging&&null!==t&&null!==r&&(r>t&&r--,t!==r)){const e=this.sourceRows[t],o=r<t?"up":"down";this.config.canMove&&!this.config.canMove(e,t,r,o)||this.executeMove(e,t,r,"drag")}})}handleKeyboardMove(t,r,o,i,n){this.pendingMove?this.pendingMove.currentIndex=o:this.pendingMove={originalIndex:r,currentIndex:o,row:t},this.lastFocusCol=n;const s=this.grid,a=[...s._rows??this.sourceRows],[l]=a.splice(r,1);a.splice(o,0,l),s._rows=a,s._focusRow=o,s._focusCol=n,s.refreshVirtualWindow(!0),e(s),this.clearDebounceTimer(),this.debounceTimer=setTimeout(()=>{this.flushPendingMove()},this.config.debounceMs??300)}flushPendingMove(){if(this.clearDebounceTimer(),!this.pendingMove)return;const{originalIndex:t,currentIndex:r,row:o}=this.pendingMove;if(this.pendingMove=null,t===r)return;const i={row:o,fromIndex:t,toIndex:r,rows:[...this.sourceRows],source:"keyboard"};if(this.emitCancelable("row-move",i)){const o=[...this.sourceRows],[i]=o.splice(r,1);o.splice(t,0,i);const n=this.grid;n._rows=o,n._focusRow=t,n._focusCol=this.lastFocusCol,n.refreshVirtualWindow(!0),e(n)}}executeMove(e,t,r,o){const i=[...this.sourceRows],[n]=i.splice(t,1);i.splice(r,0,n);const s={row:e,fromIndex:t,toIndex:r,rows:i,source:o};if(!this.emitCancelable("row-move",s))if("flip"===this.animationType&&this.gridElement){const e=this.captureRowPositions();this.grid.rows=i,requestAnimationFrame(()=>{this.gridElement.offsetHeight,this.animateFLIP(e,t,r)})}else this.grid.rows=i}captureRowPositions(){const e=/* @__PURE__ */new Map;return this.gridElement?.querySelectorAll(".data-grid-row").forEach(t=>{const r=this.getRowIndex(t);r>=0&&e.set(r,t.getBoundingClientRect().top)}),e}animateFLIP(e,t,r){const o=this.gridElement;if(!o||0===e.size)return;const i=Math.min(t,r),n=Math.max(t,r),s=[];if(o.querySelectorAll(".data-grid-row").forEach(o=>{const a=o,l=this.getRowIndex(a);if(l<0||l<i||l>n)return;let d;d=l===r?t:t<r?l+1:l-1;const c=e.get(d);if(void 0===c)return;const g=c-a.getBoundingClientRect().top;Math.abs(g)>1&&s.push({el:a,deltaY:g})}),0===s.length)return;s.forEach(({el:e,deltaY:t})=>{e.style.transform=`translateY(${t}px)`}),o.offsetHeight;const a=this.animationDuration;requestAnimationFrame(()=>{s.forEach(({el:e})=>{e.classList.add("flip-animating"),e.style.transform=""}),setTimeout(()=>{s.forEach(({el:e})=>{e.style.transform="",e.classList.remove("flip-animating")})},a+50)})}getRowIndex(e){const t=e.querySelector(".cell[data-row]");return t?parseInt(t.getAttribute("data-row")??"-1",10):-1}clearDragClasses(){this.gridElement?.querySelectorAll(".data-grid-row").forEach(e=>{e.classList.remove("dragging","drop-target","drop-before","drop-after")})}clearDebounceTimer(){this.debounceTimer&&(clearTimeout(this.debounceTimer),this.debounceTimer=null)}}export{i as ROW_DRAG_HANDLE_FIELD,n as RowReorderPlugin};
2
- //# sourceMappingURL=index.js.map