apex-grid 3.5.0 → 4.0.0-beta.1

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 (215) hide show
  1. package/CHANGELOG.md +573 -0
  2. package/LICENSE.md +125 -0
  3. package/README.md +143 -23
  4. package/components/cell.d.ts +43 -5
  5. package/components/cell.js +225 -64
  6. package/components/cell.js.map +1 -1
  7. package/components/filter-row.d.ts +2 -0
  8. package/components/filter-row.js +82 -28
  9. package/components/filter-row.js.map +1 -1
  10. package/components/grid.d.ts +281 -49
  11. package/components/grid.js +600 -159
  12. package/components/grid.js.map +1 -1
  13. package/components/group-header-row.js +28 -25
  14. package/components/group-header-row.js.map +1 -1
  15. package/components/header-row.d.ts +6 -10
  16. package/components/header-row.js +12 -28
  17. package/components/header-row.js.map +1 -1
  18. package/components/header.js +71 -22
  19. package/components/header.js.map +1 -1
  20. package/components/paginator.d.ts +20 -5
  21. package/components/paginator.js +54 -17
  22. package/components/paginator.js.map +1 -1
  23. package/components/row.d.ts +19 -3
  24. package/components/row.js +211 -56
  25. package/components/row.js.map +1 -1
  26. package/components/toolbar.d.ts +5 -1
  27. package/components/toolbar.js +6 -2
  28. package/components/toolbar.js.map +1 -1
  29. package/components/virtualize-rows.d.ts +38 -0
  30. package/components/virtualize-rows.js +286 -0
  31. package/components/virtualize-rows.js.map +1 -0
  32. package/components/virtualizer.d.ts +111 -1
  33. package/components/virtualizer.js +192 -5
  34. package/components/virtualizer.js.map +1 -1
  35. package/controllers/dom.d.ts +14 -7
  36. package/controllers/dom.js +45 -27
  37. package/controllers/dom.js.map +1 -1
  38. package/controllers/editing.d.ts +104 -37
  39. package/controllers/editing.js +230 -78
  40. package/controllers/editing.js.map +1 -1
  41. package/controllers/expansion.d.ts +14 -5
  42. package/controllers/expansion.js +24 -1
  43. package/controllers/expansion.js.map +1 -1
  44. package/controllers/filter.d.ts +10 -2
  45. package/controllers/filter.js +62 -17
  46. package/controllers/filter.js.map +1 -1
  47. package/controllers/history.d.ts +45 -8
  48. package/controllers/history.js +58 -20
  49. package/controllers/history.js.map +1 -1
  50. package/controllers/navigation.d.ts +130 -13
  51. package/controllers/navigation.js +474 -60
  52. package/controllers/navigation.js.map +1 -1
  53. package/controllers/pagination.d.ts +13 -6
  54. package/controllers/pagination.js +29 -22
  55. package/controllers/pagination.js.map +1 -1
  56. package/controllers/reorder.js +38 -22
  57. package/controllers/reorder.js.map +1 -1
  58. package/controllers/resize.d.ts +17 -2
  59. package/controllers/resize.js +16 -6
  60. package/controllers/resize.js.map +1 -1
  61. package/controllers/row-pin.d.ts +26 -2
  62. package/controllers/row-pin.js +24 -11
  63. package/controllers/row-pin.js.map +1 -1
  64. package/controllers/row-reorder.d.ts +40 -12
  65. package/controllers/row-reorder.js +137 -43
  66. package/controllers/row-reorder.js.map +1 -1
  67. package/controllers/selection.d.ts +33 -4
  68. package/controllers/selection.js +49 -11
  69. package/controllers/selection.js.map +1 -1
  70. package/controllers/sort.d.ts +22 -2
  71. package/controllers/sort.js +30 -25
  72. package/controllers/sort.js.map +1 -1
  73. package/controllers/state.d.ts +74 -7
  74. package/controllers/state.js +117 -36
  75. package/controllers/state.js.map +1 -1
  76. package/controllers/tree.d.ts +15 -10
  77. package/controllers/tree.js +0 -0
  78. package/controllers/tree.js.map +1 -1
  79. package/custom-elements.json +5091 -1023
  80. package/docs/assets/hierarchy.js +1 -1
  81. package/docs/assets/highlight.css +15 -8
  82. package/docs/assets/navigation.js +1 -1
  83. package/docs/assets/search.js +1 -1
  84. package/docs/classes/ApexGrid.html +233 -87
  85. package/docs/classes/ApexGridPaginator.html +39 -8
  86. package/docs/classes/ApexGridToolbar.html +11 -7
  87. package/docs/functions/localize.html +2 -2
  88. package/docs/hierarchy.html +1 -1
  89. package/docs/index.html +159 -26
  90. package/docs/interfaces/ApexCellValidationFailedEvent.html +3 -2
  91. package/docs/interfaces/ApexCellValueChangedEvent.html +4 -2
  92. package/docs/interfaces/ApexCellValueChangingEvent.html +3 -2
  93. package/docs/interfaces/ApexGridEventMap.html +5 -2
  94. package/docs/interfaces/ApexPageChangedEvent.html +3 -1
  95. package/docs/interfaces/ApexRowEditEndedEvent.html +2 -1
  96. package/docs/interfaces/ApexRowEditStartedEvent.html +2 -1
  97. package/docs/interfaces/ApexRowMovingEvent.html +9 -3
  98. package/docs/interfaces/ApexRowPinningEvent.html +1 -1
  99. package/docs/interfaces/ApexTreeRowExpandedEvent.html +4 -1
  100. package/docs/interfaces/ApexTreeRowExpandingEvent.html +4 -1
  101. package/docs/interfaces/BaseApexCellContext.html +18 -5
  102. package/docs/interfaces/BaseApexEditorContext.html +20 -5
  103. package/docs/interfaces/BaseFilterExpression.html +3 -3
  104. package/docs/interfaces/CSVExportOptions.html +12 -4
  105. package/docs/interfaces/DataPipelineConfiguration.html +4 -9
  106. package/docs/interfaces/ExportOptions.html +5 -3
  107. package/docs/interfaces/GridExpansionConfiguration.html +6 -2
  108. package/docs/interfaces/GridRowReorderingConfiguration.html +1 -1
  109. package/docs/interfaces/GridSelectionConfiguration.html +19 -4
  110. package/docs/interfaces/PaginationConfiguration.html +11 -4
  111. package/docs/interfaces/PaginationState.html +4 -2
  112. package/docs/interfaces/SetStateResult.html +3 -2
  113. package/docs/interfaces/ValidatorContext.html +7 -2
  114. package/docs/media/_token-values.scss +118 -0
  115. package/docs/media/package.json +9 -5
  116. package/docs/modules.html +1 -1
  117. package/docs/types/DataPipelineParams.html +2 -2
  118. package/docs/types/ExportSource.html +6 -4
  119. package/docs/types/OperandKeys.html +9 -0
  120. package/docs/types/PaginationMode.html +5 -4
  121. package/docs/variables/EN_LOCALE.html +2 -2
  122. package/i18n/en.d.ts +7 -0
  123. package/i18n/en.js +7 -0
  124. package/i18n/en.js.map +1 -1
  125. package/i18n/es.js +7 -0
  126. package/i18n/es.js.map +1 -1
  127. package/internal/column-types.d.ts +38 -2
  128. package/internal/column-types.js +83 -55
  129. package/internal/column-types.js.map +1 -1
  130. package/internal/constants.d.ts +1 -2
  131. package/internal/constants.js +0 -4
  132. package/internal/constants.js.map +1 -1
  133. package/internal/document-styles.d.ts +30 -0
  134. package/internal/document-styles.js +48 -0
  135. package/internal/document-styles.js.map +1 -0
  136. package/internal/export.d.ts +45 -7
  137. package/internal/export.js +39 -34
  138. package/internal/export.js.map +1 -1
  139. package/internal/feature-module.d.ts +67 -3
  140. package/internal/feature-module.js +6 -0
  141. package/internal/feature-module.js.map +1 -1
  142. package/internal/flip.d.ts +28 -16
  143. package/internal/flip.js +42 -10
  144. package/internal/flip.js.map +1 -1
  145. package/internal/index.d.ts +7 -5
  146. package/internal/index.js +6 -4
  147. package/internal/index.js.map +1 -1
  148. package/internal/normalize-case.d.ts +8 -1
  149. package/internal/normalize-case.js +3 -2
  150. package/internal/normalize-case.js.map +1 -1
  151. package/internal/state-snapshot.d.ts +60 -8
  152. package/internal/state-snapshot.js +87 -19
  153. package/internal/state-snapshot.js.map +1 -1
  154. package/internal/types.d.ts +92 -21
  155. package/internal/types.js.map +1 -1
  156. package/internal/utils.d.ts +34 -6
  157. package/internal/utils.js +30 -21
  158. package/internal/utils.js.map +1 -1
  159. package/internal/validators.js +1 -0
  160. package/internal/validators.js.map +1 -1
  161. package/operations/filter/operands/number.js +9 -6
  162. package/operations/filter/operands/number.js.map +1 -1
  163. package/operations/filter/operands/string.js +2 -3
  164. package/operations/filter/operands/string.js.map +1 -1
  165. package/operations/filter/types.d.ts +14 -2
  166. package/operations/filter/types.js.map +1 -1
  167. package/operations/filter.d.ts +6 -0
  168. package/operations/filter.js +23 -7
  169. package/operations/filter.js.map +1 -1
  170. package/operations/quick-filter.js +2 -5
  171. package/operations/quick-filter.js.map +1 -1
  172. package/operations/sort.d.ts +21 -2
  173. package/operations/sort.js +41 -14
  174. package/operations/sort.js.map +1 -1
  175. package/package.json +9 -4
  176. package/setup.d.ts +11 -0
  177. package/setup.js +9 -19
  178. package/setup.js.map +1 -1
  179. package/styles/_token-values.css.d.ts +1 -0
  180. package/styles/_token-values.css.js +3 -0
  181. package/styles/_token-values.css.js.map +1 -0
  182. package/styles/_tokens.css.js +1 -1
  183. package/styles/_tokens.css.js.map +1 -1
  184. package/styles/body-cell/body-cell.css.js +1 -1
  185. package/styles/body-cell/body-cell.css.js.map +1 -1
  186. package/styles/body-cell/cell-renderers.css.js +1 -1
  187. package/styles/body-cell/cell-renderers.css.js.map +1 -1
  188. package/styles/body-row/body-row.css.js +1 -1
  189. package/styles/body-row/body-row.css.js.map +1 -1
  190. package/styles/document-tokens.css.d.ts +1 -0
  191. package/styles/document-tokens.css.js +3 -0
  192. package/styles/document-tokens.css.js.map +1 -0
  193. package/styles/filter-row/filter-row.css.js +1 -1
  194. package/styles/filter-row/filter-row.css.js.map +1 -1
  195. package/styles/grid/_grid.base.css.js +1 -1
  196. package/styles/grid/_grid.base.css.js.map +1 -1
  197. package/styles/grid/grid.css.js +1 -1
  198. package/styles/grid/grid.css.js.map +1 -1
  199. package/styles/group-header-row/group-header-row.css.js +1 -1
  200. package/styles/group-header-row/group-header-row.css.js.map +1 -1
  201. package/styles/header-cell/header-cell.css.js +1 -1
  202. package/styles/header-cell/header-cell.css.js.map +1 -1
  203. package/styles/header-row/header-row.base.css.js +1 -1
  204. package/styles/header-row/header-row.base.css.js.map +1 -1
  205. package/styles/paginator/paginator.css.js +1 -1
  206. package/styles/paginator/paginator.css.js.map +1 -1
  207. package/styles/toolbar/toolbar.css.js +1 -1
  208. package/styles/toolbar/toolbar.css.js.map +1 -1
  209. package/tokens.css +78 -0
  210. package/LICENSE +0 -80
  211. package/docs/media/LICENSE +0 -80
  212. package/docs/media/_tokens.scss +0 -214
  213. package/operations/pagination.d.ts +0 -19
  214. package/operations/pagination.js +0 -12
  215. package/operations/pagination.js.map +0 -1
@@ -1,6 +1,7 @@
1
1
  import { html, nothing } from 'lit';
2
2
  import { styleMap } from 'lit/directives/style-map.js';
3
3
  import { MIN_COL_RESIZE_WIDTH } from '../internal/constants.js';
4
+ import { isRTL } from '../internal/utils.js';
4
5
  export class ResizeController {
5
6
  constructor(host) {
6
7
  this.host = host;
@@ -9,14 +10,23 @@ export class ResizeController {
9
10
  this.host.addController(this);
10
11
  }
11
12
  #maxSize(key, headerWidth) {
12
- const max = this.host.rows
13
- .map((row) => row.cells.find((cell) => cell.column.key === key))
14
- .reduce((prev, current) => (current.offsetWidth > prev ? current.offsetWidth : prev), 0);
15
- return Math.max(...[MIN_COL_RESIZE_WIDTH, max, headerWidth]);
13
+ let max = Math.max(MIN_COL_RESIZE_WIDTH, headerWidth);
14
+ for (const row of this.host.rows) {
15
+ const cell = row.cells.find((cell) => cell.column.key === key);
16
+ if (cell)
17
+ max = Math.max(max, cell.offsetWidth);
18
+ }
19
+ return max;
20
+ }
21
+ edge(header, width = header.offsetWidth, rtl = isRTL(header)) {
22
+ const { left, right } = header.getBoundingClientRect();
23
+ const grid = this.host;
24
+ const origin = grid.getBoundingClientRect().left + grid.clientLeft - grid.scrollLeft;
25
+ return (rtl ? right - width : left + width) - origin;
16
26
  }
17
27
  start(header) {
18
28
  this.indicatorActive = true;
19
- this.indicatorOffset = header.offsetLeft + header.offsetWidth;
29
+ this.indicatorOffset = this.edge(header);
20
30
  this.host.requestUpdate();
21
31
  }
22
32
  stop() {
@@ -24,7 +34,7 @@ export class ResizeController {
24
34
  this.host.requestUpdate();
25
35
  }
26
36
  resize(column, width, sizerOffset) {
27
- if (sizerOffset) {
37
+ if (sizerOffset !== undefined) {
28
38
  this.indicatorOffset = sizerOffset;
29
39
  }
30
40
  column.width = `${width}px`;
@@ -1 +1 @@
1
- {"version":3,"file":"resize.js","sourceRoot":"","sources":["../../src/controllers/resize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAA2B,MAAM,KAAK,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAGhE,MAAM,OAAO,gBAAgB;IAC3B,YAAsB,I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KAAK,IAAI,CAAC;QAC5B,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;IAC5B,CAAC;IAEM,KAAK,CAAC,QAAQ,CAAC,MAA8B,EAAE,MAAyB;QAC7E,MAAM,CAAC,KAAK,GAAG,aAAa,CAAC;QAE7B,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;QAC1B,MAAM,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC;QAE/B,MAAM,CAAC,KAAK,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC;QACpE,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;IAC5B,CAAC;IAEM,aAAa,KAAI,CAAC;IAKlB,eAAe;QACpB,OAAO,IAAI,CAAC,eAAe;YACzB,CAAC,CAAC,IAAI,CAAA;;kBAEM,QAAQ,CAAC;gBACf,SAAS,EAAE,cAAc,IAAI,CAAC,eAAe,KAAK;aACnD,CAAC;gBACI;YACV,CAAC,CAAC,OAAO,CAAC;IACd,CAAC;CACF","sourcesContent":["import { html, nothing, type ReactiveController } from 'lit';\nimport { styleMap } from 'lit/directives/style-map.js';\nimport type ApexGridHeader from '../components/header.js';\nimport { MIN_COL_RESIZE_WIDTH } from '../internal/constants.js';\nimport type { ColumnConfiguration, GridHost, Keys } from '../internal/types.js';\n\nexport class ResizeController<T extends object> implements ReactiveController {\n constructor(protected host: GridHost<T>) {\n this.host.addController(this);\n }\n\n public indicatorActive = false;\n public indicatorOffset = 0;\n\n #maxSize(key: Keys<T>, headerWidth: number) {\n const max = this.host.rows\n .map((row) => row.cells.find((cell) => cell.column.key === key)!)\n .reduce((prev, current) => (current.offsetWidth > prev ? current.offsetWidth : prev), 0);\n\n return Math.max(...[MIN_COL_RESIZE_WIDTH, max, headerWidth]);\n }\n\n /**\n * Begins resizing a column by showing and positioning the resize indicator in relation to the column.\n *\n * @param header the\n */\n public start(header: ApexGridHeader<T>) {\n this.indicatorActive = true;\n this.indicatorOffset = header.offsetLeft + header.offsetWidth;\n this.host.requestUpdate();\n }\n\n /**\n * Stops and resets the resizing state.\n */\n public stop() {\n this.indicatorActive = false;\n this.host.requestUpdate();\n }\n\n public resize(column: ColumnConfiguration<T>, width: number, sizerOffset?: number) {\n if (sizerOffset) {\n this.indicatorOffset = sizerOffset;\n }\n\n column.width = `${width}px`;\n this.host.requestUpdate();\n }\n\n public async autosize(column: ColumnConfiguration<T>, header: ApexGridHeader<T>) {\n column.width = 'max-content';\n\n this.host.requestUpdate();\n await this.host.updateComplete;\n\n column.width = `${this.#maxSize(column.key, header.offsetWidth)}px`;\n this.host.requestUpdate();\n }\n\n public hostConnected() {}\n\n /**\n * Renders the resize indicator in the grid.\n */\n public renderIndicator() {\n return this.indicatorActive\n ? html`<div\n part=\"resize-indicator\"\n style=${styleMap({\n transform: `translateX(${this.indicatorOffset}px)`,\n })}\n ></div>`\n : nothing;\n }\n}\n"]}
1
+ {"version":3,"file":"resize.js","sourceRoot":"","sources":["../../src/controllers/resize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAA2B,MAAM,KAAK,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAEvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAEhE,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAE7C,MAAM,OAAO,gBAAgB;IAC3B,YAAsB,IAAiB;QAAjB,SAAI,GAAJ,IAAI,CAAa;QAIhC,oBAAe,GAAG,KAAK,CAAC;QACxB,oBAAe,GAAG,CAAC,CAAC;QAJzB,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;IAKD,QAAQ,CAAC,GAAY,EAAE,WAAmB;QACxC,IAAI,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,oBAAoB,EAAE,WAAW,CAAC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E,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;YAC9B,IAAI,CAAC,eAAe,GAAG,WAAW,CAAC;QACrC,CAAC;QAED,MAAM,CAAC,KAAK,GAAG,GAAG,KAAK,IAAI,CAAC;QAC5B,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;IAC5B,CAAC;IAEM,KAAK,CAAC,QAAQ,CAAC,MAA8B,EAAE,MAAyB;QAC7E,MAAM,CAAC,KAAK,GAAG,aAAa,CAAC;QAE7B,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;QAC1B,MAAM,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC;QAE/B,MAAM,CAAC,KAAK,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC;QACpE,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;IAC5B,CAAC;IAEM,aAAa,KAAI,CAAC;IAKlB,eAAe;QACpB,OAAO,IAAI,CAAC,eAAe;YACzB,CAAC,CAAC,IAAI,CAAA;;kBAEM,QAAQ,CAAC;gBACf,SAAS,EAAE,cAAc,IAAI,CAAC,eAAe,KAAK;aACnD,CAAC;gBACI;YACV,CAAC,CAAC,OAAO,CAAC;IACd,CAAC;CACF","sourcesContent":["import { html, nothing, type ReactiveController } from 'lit';\nimport { styleMap } from 'lit/directives/style-map.js';\nimport type ApexGridHeader from '../components/header.js';\nimport { MIN_COL_RESIZE_WIDTH } from '../internal/constants.js';\nimport type { ColumnConfiguration, GridHost, Keys } from '../internal/types.js';\nimport { isRTL } from '../internal/utils.js';\n\nexport class ResizeController<T extends object> implements ReactiveController {\n constructor(protected host: GridHost<T>) {\n this.host.addController(this);\n }\n\n public indicatorActive = false;\n public indicatorOffset = 0;\n\n #maxSize(key: Keys<T>, headerWidth: number) {\n let max = Math.max(MIN_COL_RESIZE_WIDTH, headerWidth);\n // Rows rendered as one full-width block (group headers, total rows, rows\n // still loading) have no cell for the column, so they do not count.\n for (const row of this.host.rows) {\n const cell = row.cells.find((cell) => cell.column.key === key);\n if (cell) max = Math.max(max, cell.offsetWidth);\n }\n return max;\n }\n\n /**\n * Indicator offset for the edge being dragged when `header` is `width`\n * pixels wide. That is the inline-end edge: the right one in LTR, the left\n * one under `dir=\"rtl\"`, where the fixed inline-start edge is the right one.\n *\n * Measured in client coordinates against the indicator's origin, the grid's\n * padding box at scroll 0 (`left: 0`, moved with a physical `translateX`).\n * A header offset would count from the far left of the header row, which\n * under RTL with horizontal overflow lies outside the grid.\n *\n * @param header the header being resized\n * @param width the column width to place the edge for, its current width by default\n * @param rtl whether the header lays out right to left\n */\n public edge(header: ApexGridHeader<T>, width = header.offsetWidth, rtl = isRTL(header)) {\n const { left, right } = header.getBoundingClientRect();\n const grid = this.host;\n // scrollLeft is negative when scrolled under RTL, so this holds either way.\n const origin = grid.getBoundingClientRect().left + grid.clientLeft - grid.scrollLeft;\n return (rtl ? right - width : left + width) - origin;\n }\n\n /**\n * Begins resizing a column by showing the resize indicator on the dragged edge of its header.\n *\n * @param header the header being resized\n */\n public start(header: ApexGridHeader<T>) {\n this.indicatorActive = true;\n this.indicatorOffset = this.edge(header);\n this.host.requestUpdate();\n }\n\n /**\n * Stops and resets the resizing state.\n */\n public stop() {\n this.indicatorActive = false;\n this.host.requestUpdate();\n }\n\n public resize(column: ColumnConfiguration<T>, width: number, sizerOffset?: number) {\n if (sizerOffset !== undefined) {\n this.indicatorOffset = sizerOffset;\n }\n\n column.width = `${width}px`;\n this.host.requestUpdate();\n }\n\n public async autosize(column: ColumnConfiguration<T>, header: ApexGridHeader<T>) {\n column.width = 'max-content';\n\n this.host.requestUpdate();\n await this.host.updateComplete;\n\n column.width = `${this.#maxSize(column.key, header.offsetWidth)}px`;\n this.host.requestUpdate();\n }\n\n public hostConnected() {}\n\n /**\n * Renders the resize indicator in the grid.\n */\n public renderIndicator() {\n return this.indicatorActive\n ? html`<div\n part=\"resize-indicator\"\n style=${styleMap({\n transform: `translateX(${this.indicatorOffset}px)`,\n })}\n ></div>`\n : nothing;\n }\n}\n"]}
@@ -11,7 +11,12 @@ export type RowPinPosition = 'top' | 'bottom';
11
11
  * reference-based: the controller holds a `Set` of row data references per band,
12
12
  * so pins survive sort / filter / pagination as long as those preserve row
13
13
  * identity (the default in-place pipeline does). Replacing {@link ApexGrid.data}
14
- * wholesale should be followed by re-pinning or {@link clear}.
14
+ * carries the pins onto the new array: by `rowId` when set, else a pin whose
15
+ * row left the data is dropped.
16
+ *
17
+ * While `rowPinning.enabled` is false every query reports no pins and the
18
+ * rows stay in the body; the pins are kept (and `getState` still saves them),
19
+ * and re-enabling brings them back.
15
20
  *
16
21
  * Mutations go through the cancellable `rowPinning` event and emit a follow-up
17
22
  * `rowPinned` event, mirroring selection / expansion.
@@ -23,7 +28,13 @@ export declare class RowPinController<T extends object> implements ReactiveContr
23
28
  hostConnected(): void;
24
29
  /** Whether row pinning is enabled at the grid level. */
25
30
  get enabled(): boolean;
26
- /** Whether any row is currently pinned. */
31
+ /**
32
+ * Bumped whenever either band's contents change, so a view derived from the
33
+ * pins (the body's {@link ApexGrid.pageItems}) knows when to recompute.
34
+ * Read only.
35
+ */
36
+ version: number;
37
+ /** Whether any row is currently pinned (none while pinning is disabled). */
27
38
  get hasPinnedRows(): boolean;
28
39
  /** The band `row` is pinned to, or `null` when it is not pinned. */
29
40
  pinnedPosition(row: T): RowPinPosition | null;
@@ -34,6 +45,14 @@ export declare class RowPinController<T extends object> implements ReactiveContr
34
45
  top: T[];
35
46
  bottom: T[];
36
47
  };
48
+ /**
49
+ * Every pin per band, kept while pinning is disabled too, so a `getState`
50
+ * snapshot taken then still carries them.
51
+ */
52
+ get pins(): {
53
+ top: T[];
54
+ bottom: T[];
55
+ };
37
56
  /**
38
57
  * Pins `row` to the given band. Moves it between bands when already pinned
39
58
  * elsewhere. No-op (returns `true`) when it is already pinned there.
@@ -56,4 +75,9 @@ export declare class RowPinController<T extends object> implements ReactiveContr
56
75
  * preserves the given order within each band.
57
76
  */
58
77
  restore(top: ReadonlyArray<T>, bottom: ReadonlyArray<T>): void;
78
+ /**
79
+ * Carries the pins onto a new `data` array through `carry` (by `rowId` when
80
+ * set, else the rows still present), so the bands never show a stale object.
81
+ */
82
+ resetForDataChange(carry: (rows: T[]) => T[]): void;
59
83
  }
@@ -1,8 +1,11 @@
1
1
  export class RowPinController {
2
- #top = new Set();
3
- #bottom = new Set();
2
+ #top;
3
+ #bottom;
4
4
  constructor(host) {
5
5
  this.host = host;
6
+ this.#top = new Set();
7
+ this.#bottom = new Set();
8
+ this.version = 0;
6
9
  this.host.addController(this);
7
10
  }
8
11
  hostConnected() { }
@@ -10,21 +13,23 @@ export class RowPinController {
10
13
  return Boolean(this.host.rowPinning?.enabled);
11
14
  }
12
15
  get hasPinnedRows() {
13
- return this.#top.size > 0 || this.#bottom.size > 0;
16
+ return this.enabled && (this.#top.size > 0 || this.#bottom.size > 0);
14
17
  }
15
18
  pinnedPosition(row) {
16
- if (this.#top.has(row))
17
- return 'top';
18
- if (this.#bottom.has(row))
19
- return 'bottom';
20
- return null;
19
+ return this.enabled ? this.#band(row) : null;
21
20
  }
22
21
  isPinned(row) {
23
- return this.#top.has(row) || this.#bottom.has(row);
22
+ return this.pinnedPosition(row) !== null;
24
23
  }
25
24
  get pinnedRows() {
25
+ return this.enabled ? this.pins : { top: [], bottom: [] };
26
+ }
27
+ get pins() {
26
28
  return { top: [...this.#top], bottom: [...this.#bottom] };
27
29
  }
30
+ #band(row) {
31
+ return this.#top.has(row) ? 'top' : this.#bottom.has(row) ? 'bottom' : null;
32
+ }
28
33
  pinRow(row, position) {
29
34
  if (!this.enabled)
30
35
  return false;
@@ -39,7 +44,7 @@ export class RowPinController {
39
44
  return true;
40
45
  }
41
46
  unpinRow(row) {
42
- if (!this.isPinned(row))
47
+ if (!this.#band(row))
43
48
  return true;
44
49
  if (!this.#emitPinning(row, null))
45
50
  return false;
@@ -49,17 +54,24 @@ export class RowPinController {
49
54
  return true;
50
55
  }
51
56
  clear() {
52
- if (!this.hasPinnedRows)
57
+ if (!this.#top.size && !this.#bottom.size)
53
58
  return;
54
59
  this.#top.clear();
55
60
  this.#bottom.clear();
61
+ this.version++;
56
62
  this.host.requestUpdate();
57
63
  }
58
64
  restore(top, bottom) {
59
65
  this.#top = new Set(top);
60
66
  this.#bottom = new Set(bottom);
67
+ this.version++;
61
68
  this.host.requestUpdate();
62
69
  }
70
+ resetForDataChange(carry) {
71
+ if (this.#top.size || this.#bottom.size) {
72
+ this.restore(carry([...this.#top]), carry([...this.#bottom]));
73
+ }
74
+ }
63
75
  #emitPinning(row, position) {
64
76
  return this.host.emitEvent('rowPinning', {
65
77
  detail: { row, position },
@@ -67,6 +79,7 @@ export class RowPinController {
67
79
  });
68
80
  }
69
81
  #commit(row, position, message) {
82
+ this.version++;
70
83
  this.host.requestUpdate();
71
84
  this.host.announce(message);
72
85
  this.host.emitEvent('rowPinned', { detail: { row, position } });
@@ -1 +1 @@
1
- {"version":3,"file":"row-pin.js","sourceRoot":"","sources":["../../src/controllers/row-pin.ts"],"names":[],"mappings":"AAoBA,MAAM,OAAO,gBAAgB;IAC3B,IAAI,GAAW,IAAI,GAAG,EAAE,CAAC;IACzB,OAAO,GAAW,IAAI,GAAG,EAAE,CAAC;IAE5B,YAAsB,IAAiB;QAAjB,SAAI,GAAJ,IAAI,CAAa;QACrC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;IAEM,aAAa,KAAI,CAAC;IAGzB,IAAW,OAAO;QAChB,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IAChD,CAAC;IAGD,IAAW,aAAa;QACtB,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,GAAG,CAAC,CAAC;IACrD,CAAC;IAGM,cAAc,CAAC,GAAM;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,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;QAC1B,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAC5B,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC;IAClE,CAAC;CACF","sourcesContent":["import type { ReactiveController } from 'lit';\nimport type { GridHost } from '../internal/types.js';\n\n/** Where a row is pinned, or `null` when it scrolls with the body. */\nexport type RowPinPosition = 'top' | 'bottom';\n\n/**\n * Reactive controller backing row pinning.\n *\n * @remarks\n * Pinned rows are lifted out of the scrollable body and rendered in sticky\n * bands above (`'top'`) or below (`'bottom'`) the virtualized rows. State is\n * reference-based: the controller holds a `Set` of row data references per band,\n * so pins survive sort / filter / pagination as long as those preserve row\n * identity (the default in-place pipeline does). Replacing {@link ApexGrid.data}\n * wholesale should be followed by re-pinning or {@link clear}.\n *\n * Mutations go through the cancellable `rowPinning` event and emit a follow-up\n * `rowPinned` event, mirroring selection / expansion.\n */\nexport class RowPinController<T extends object> implements ReactiveController {\n #top: Set<T> = new Set();\n #bottom: Set<T> = new Set();\n\n constructor(protected host: GridHost<T>) {\n this.host.addController(this);\n }\n\n public hostConnected() {}\n\n /** Whether row pinning is enabled at the grid level. */\n public get enabled(): boolean {\n return Boolean(this.host.rowPinning?.enabled);\n }\n\n /** Whether any row is currently pinned. */\n public get hasPinnedRows(): boolean {\n return this.#top.size > 0 || this.#bottom.size > 0;\n }\n\n /** The band `row` is pinned to, or `null` when it is not pinned. */\n public pinnedPosition(row: T): RowPinPosition | null {\n if (this.#top.has(row)) return 'top';\n if (this.#bottom.has(row)) return 'bottom';\n return null;\n }\n\n /** Whether `row` is pinned to either band. */\n public isPinned(row: T): boolean {\n return this.#top.has(row) || this.#bottom.has(row);\n }\n\n /** Pinned rows per band, in the order they were pinned. */\n public get pinnedRows(): { top: T[]; bottom: T[] } {\n return { top: [...this.#top], bottom: [...this.#bottom] };\n }\n\n /**\n * Pins `row` to the given band. Moves it between bands when already pinned\n * elsewhere. No-op (returns `true`) when it is already pinned there.\n *\n * @returns `true` when applied, `false` when disabled or cancelled.\n */\n public pinRow(row: T, position: RowPinPosition): boolean {\n if (!this.enabled) return false;\n if (this.pinnedPosition(row) === position) return true;\n if (!this.#emitPinning(row, position)) return false;\n\n this.#top.delete(row);\n this.#bottom.delete(row);\n (position === 'top' ? this.#top : this.#bottom).add(row);\n this.#commit(\n row,\n position,\n this.host.localize(position === 'top' ? 'announce.rowPinnedTop' : 'announce.rowPinnedBottom')\n );\n return true;\n }\n\n /**\n * Unpins `row` from whichever band holds it. No-op (returns `true`) when it is\n * not pinned.\n *\n * @returns `true` when applied, `false` when cancelled.\n */\n public unpinRow(row: T): boolean {\n if (!this.isPinned(row)) return true;\n if (!this.#emitPinning(row, null)) return false;\n\n this.#top.delete(row);\n this.#bottom.delete(row);\n this.#commit(row, null, this.host.localize('announce.rowUnpinned'));\n return true;\n }\n\n /** Clears every pin in both bands. */\n public clear(): void {\n if (!this.hasPinnedRows) return;\n this.#top.clear();\n this.#bottom.clear();\n this.host.requestUpdate();\n }\n\n /**\n * Restores pinned rows from explicit per-band reference lists (state restore),\n * replacing any current pins. Silent: emits no `rowPinning` / `rowPinned` and\n * preserves the given order within each band.\n */\n public restore(top: ReadonlyArray<T>, bottom: ReadonlyArray<T>): void {\n this.#top = new Set(top);\n this.#bottom = new Set(bottom);\n this.host.requestUpdate();\n }\n\n #emitPinning(row: T, position: RowPinPosition | null): boolean {\n return this.host.emitEvent('rowPinning', {\n detail: { row, position },\n cancelable: true,\n });\n }\n\n #commit(row: T, position: RowPinPosition | null, message: string): void {\n this.host.requestUpdate();\n this.host.announce(message);\n this.host.emitEvent('rowPinned', { detail: { row, position } });\n }\n}\n"]}
1
+ {"version":3,"file":"row-pin.js","sourceRoot":"","sources":["../../src/controllers/row-pin.ts"],"names":[],"mappings":"AAyBA,MAAM,OAAO,g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E,IAAI;SACjB,CAAC,CAAC;IACL,CAAC;IAED,OAAO,CAAC,GAAM,EAAE,QAA+B,EAAE,OAAe;QAC9D,IAAI,CAAC,OAAO,EAAE,CAAC;QACf,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;QAC1B,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAC5B,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC;IAClE,CAAC;CACF","sourcesContent":["import type { ReactiveController } from 'lit';\nimport type { GridHost } from '../internal/types.js';\n\n/** Where a row is pinned, or `null` when it scrolls with the body. */\nexport type RowPinPosition = 'top' | 'bottom';\n\n/**\n * Reactive controller backing row pinning.\n *\n * @remarks\n * Pinned rows are lifted out of the scrollable body and rendered in sticky\n * bands above (`'top'`) or below (`'bottom'`) the virtualized rows. State is\n * reference-based: the controller holds a `Set` of row data references per band,\n * so pins survive sort / filter / pagination as long as those preserve row\n * identity (the default in-place pipeline does). Replacing {@link ApexGrid.data}\n * carries the pins onto the new array: by `rowId` when set, else a pin whose\n * row left the data is dropped.\n *\n * While `rowPinning.enabled` is false every query reports no pins and the\n * rows stay in the body; the pins are kept (and `getState` still saves them),\n * and re-enabling brings them back.\n *\n * Mutations go through the cancellable `rowPinning` event and emit a follow-up\n * `rowPinned` event, mirroring selection / expansion.\n */\nexport class RowPinController<T extends object> implements ReactiveController {\n #top: Set<T> = new Set();\n #bottom: Set<T> = new Set();\n\n constructor(protected host: GridHost<T>) {\n this.host.addController(this);\n }\n\n public hostConnected() {}\n\n /** Whether row pinning is enabled at the grid level. */\n public get enabled(): boolean {\n return Boolean(this.host.rowPinning?.enabled);\n }\n\n /**\n * Bumped whenever either band's contents change, so a view derived from the\n * pins (the body's {@link ApexGrid.pageItems}) knows when to recompute.\n * Read only.\n */\n public version = 0;\n\n /** Whether any row is currently pinned (none while pinning is disabled). */\n public get hasPinnedRows(): boolean {\n return this.enabled && (this.#top.size > 0 || this.#bottom.size > 0);\n }\n\n /** The band `row` is pinned to, or `null` when it is not pinned. */\n public pinnedPosition(row: T): RowPinPosition | null {\n return this.enabled ? this.#band(row) : null;\n }\n\n /** Whether `row` is pinned to either band. */\n public isPinned(row: T): boolean {\n return this.pinnedPosition(row) !== null;\n }\n\n /** Pinned rows per band, in the order they were pinned. */\n public get pinnedRows(): { top: T[]; bottom: T[] } {\n return this.enabled ? this.pins : { top: [], bottom: [] };\n }\n\n /**\n * Every pin per band, kept while pinning is disabled too, so a `getState`\n * snapshot taken then still carries them.\n */\n public get pins(): { top: T[]; bottom: T[] } {\n return { top: [...this.#top], bottom: [...this.#bottom] };\n }\n\n /** The band holding `row`, whether or not pinning is enabled. */\n #band(row: T): RowPinPosition | null {\n return this.#top.has(row) ? 'top' : this.#bottom.has(row) ? 'bottom' : null;\n }\n\n /**\n * Pins `row` to the given band. Moves it between bands when already pinned\n * elsewhere. No-op (returns `true`) when it is already pinned there.\n *\n * @returns `true` when applied, `false` when disabled or cancelled.\n */\n public pinRow(row: T, position: RowPinPosition): boolean {\n if (!this.enabled) return false;\n if (this.pinnedPosition(row) === position) return true;\n if (!this.#emitPinning(row, position)) return false;\n\n this.#top.delete(row);\n this.#bottom.delete(row);\n (position === 'top' ? this.#top : this.#bottom).add(row);\n this.#commit(\n row,\n position,\n this.host.localize(position === 'top' ? 'announce.rowPinnedTop' : 'announce.rowPinnedBottom')\n );\n return true;\n }\n\n /**\n * Unpins `row` from whichever band holds it. No-op (returns `true`) when it is\n * not pinned.\n *\n * @returns `true` when applied, `false` when cancelled.\n */\n public unpinRow(row: T): boolean {\n if (!this.#band(row)) return true;\n if (!this.#emitPinning(row, null)) return false;\n\n this.#top.delete(row);\n this.#bottom.delete(row);\n this.#commit(row, null, this.host.localize('announce.rowUnpinned'));\n return true;\n }\n\n /** Clears every pin in both bands. */\n public clear(): void {\n if (!this.#top.size && !this.#bottom.size) return;\n this.#top.clear();\n this.#bottom.clear();\n this.version++;\n this.host.requestUpdate();\n }\n\n /**\n * Restores pinned rows from explicit per-band reference lists (state restore),\n * replacing any current pins. Silent: emits no `rowPinning` / `rowPinned` and\n * preserves the given order within each band.\n */\n public restore(top: ReadonlyArray<T>, bottom: ReadonlyArray<T>): void {\n this.#top = new Set(top);\n this.#bottom = new Set(bottom);\n this.version++;\n this.host.requestUpdate();\n }\n\n /**\n * Carries the pins onto a new `data` array through `carry` (by `rowId` when\n * set, else the rows still present), so the bands never show a stale object.\n */\n public resetForDataChange(carry: (rows: T[]) => T[]): void {\n if (this.#top.size || this.#bottom.size) {\n this.restore(carry([...this.#top]), carry([...this.#bottom]));\n }\n }\n\n #emitPinning(row: T, position: RowPinPosition | null): boolean {\n return this.host.emitEvent('rowPinning', {\n detail: { row, position },\n cancelable: true,\n });\n }\n\n #commit(row: T, position: RowPinPosition | null, message: string): void {\n this.version++;\n this.host.requestUpdate();\n this.host.announce(message);\n this.host.emitEvent('rowPinned', { detail: { row, position } });\n }\n}\n"]}
@@ -21,6 +21,12 @@ export interface RowGhostInit {
21
21
  /** Per-cell snapshot of the row's visible content. */
22
22
  cells: RowGhostCell[];
23
23
  }
24
+ /**
25
+ * Snapshots a row element for the floating ghost: its bounding rect and each
26
+ * cell's rendered text, width and alignment. A cell renders into its own
27
+ * shadow root, so the text is read from there.
28
+ */
29
+ export declare function captureRowGhost(row: Element, cells: ReadonlyArray<Element>, clientX: number, clientY: number): RowGhostInit;
24
30
  /**
25
31
  * Live state for the floating "ghost" row that trails the cursor during a
26
32
  * pointer drag. Mirrors {@link ReorderController}'s column ghost: the source
@@ -45,9 +51,12 @@ export interface RowGhostState {
45
51
  * @remarks
46
52
  * Row order is normally derived (filter → sort). This controller adds a
47
53
  * **manual order**: an explicit sequence of row references applied as a
48
- * pipeline step after sort. While a manual order is active, sorting is mutually
49
- * exclusive (applying a sort clears the manual order). State is reference-based,
50
- * so it survives the in-place pipeline.
54
+ * pipeline step after sort. A manual order and a sort are mutually exclusive:
55
+ * applying a sort clears the manual order, and a move clears the sort. The
56
+ * order spans every row, hidden by a filter or not, so a move made under a
57
+ * filter leaves the hidden rows in place. State is reference-based, so it
58
+ * survives the in-place pipeline, and it is carried onto a new `data` array
59
+ * (by `rowId` when set, else by identity).
51
60
  *
52
61
  * Reordering happens through {@link moveRow} (pointer live-swap during a drag,
53
62
  * the keyboard grab/move flow, or the public API). Each move goes through the
@@ -75,6 +84,8 @@ export declare class RowReorderController<T extends object> implements ReactiveC
75
84
  grabbed: T | null;
76
85
  constructor(host: GridHost<T>);
77
86
  hostConnected(): void;
87
+ /** A grid detached mid-drag ends the gesture, so no frozen ghost stays behind. */
88
+ hostDisconnected(): void;
78
89
  /** Whether row reordering is enabled at the grid level. */
79
90
  get enabled(): boolean;
80
91
  /**
@@ -115,12 +126,20 @@ export declare class RowReorderController<T extends object> implements ReactiveC
115
126
  * Clears the manual order (e.g. when a sort is applied). Re-runs the pipeline.
116
127
  */
117
128
  clearManualOrder(announce?: boolean): void;
129
+ /**
130
+ * Carries the manual order onto a new `data` array through `carry` (by
131
+ * `rowId` when set, else the rows still present), clearing it when no row
132
+ * survives. A grab or drag follows its row onto the new data, so an app
133
+ * that re-sets `data` on `rowMoved` keeps the gesture; it ends only when
134
+ * the row is gone.
135
+ */
136
+ resetForDataChange(carry: (rows: T[]) => T[]): void;
118
137
  /**
119
138
  * Moves the row at view index `from` relative to the row at view index `to`.
120
139
  * Indices are into {@link ApexGrid.pageItems}.
121
140
  *
122
- * @returns `true` when applied, `false` when disabled, out of range, or
123
- * cancelled via `rowMoving`.
141
+ * @returns `true` when applied, `false` when disabled, out of range, a
142
+ * no-op (the row would land where it is), or cancelled via `rowMoving`.
124
143
  */
125
144
  moveRow(from: number, to: number, position?: RowDropPosition): boolean;
126
145
  /**
@@ -140,13 +159,17 @@ export declare class RowReorderController<T extends object> implements ReactiveC
140
159
  endDrag(): void;
141
160
  /**
142
161
  * Arms a pointer drag from a row press. Called by the row on `pointerdown`
143
- * (from the grip in handle mode, or anywhere in whole-row mode). The move /
144
- * up / cancel listeners are bound to the **grid host**, so the gesture is
145
- * immune to the source row's DOM being recycled by a live-swap. `getGhost` is
146
- * a thunk the controller invokes once, the instant the drag engages, to
147
- * snapshot the row's cells (the row is still in place then).
162
+ * (from the grip in handle mode, or anywhere in whole-row mode). The move
163
+ * listener is bound to the **grid host**, so the gesture is immune to the
164
+ * source row's DOM being recycled by a live-swap; the up / cancel listeners
165
+ * are bound to the document, so a release outside the grid ends it too, as
166
+ * does a move with the primary button no longer held. The ghost is
167
+ * snapshotted once, the instant the drag engages, from the row element that
168
+ * renders `data` then; `getGhost` is the pressed row's own snapshot, used
169
+ * when no rendered row shows `data`, and returns `null` once that row shows
170
+ * another record.
148
171
  */
149
- armPointerDrag(data: T, getGhost: () => RowGhostInit, event: PointerEvent): void;
172
+ armPointerDrag(data: T, getGhost: () => RowGhostInit | null, event: PointerEvent): void;
150
173
  /** Grabs the row at view index `rowIndex` for keyboard reorder. */
151
174
  grab(rowIndex: number): boolean;
152
175
  /**
@@ -156,6 +179,11 @@ export declare class RowReorderController<T extends object> implements ReactiveC
156
179
  moveGrabbed(direction: -1 | 1): number;
157
180
  /** Drops the grabbed row, keeping its moves. */
158
181
  drop(): void;
159
- /** Cancels the grab, reverting to the order captured when it was grabbed. */
182
+ /**
183
+ * Cancels the grab, reverting the order, the data order (with
184
+ * `applyToData`) and the sort to what they were when the row was grabbed.
185
+ * Emits `rowMoved` for the way back when the row had moved, so an app
186
+ * persisting each step sees the revert too.
187
+ */
160
188
  cancelGrab(): void;
161
189
  }
@@ -1,6 +1,16 @@
1
1
  import { PIPELINE } from '../internal/constants.js';
2
- import { awaitChildUpdates, playKeyedFlip } from '../internal/flip.js';
2
+ import { playKeyedFlip, settleRowsForFlip } from '../internal/flip.js';
3
+ import SortDataOperation from '../operations/sort.js';
3
4
  const DRAG_THRESHOLD_PX = 4;
5
+ export function captureRowGhost(row, cells, clientX, clientY) {
6
+ const rect = row.getBoundingClientRect();
7
+ const snapshot = cells.map((cell) => ({
8
+ text: ((cell.shadowRoot ?? cell).textContent ?? '').replace(/\s+/g, ' ').trim(),
9
+ width: cell.getBoundingClientRect().width,
10
+ align: getComputedStyle(cell).textAlign,
11
+ }));
12
+ return { rect, clientX, clientY, cells: snapshot };
13
+ }
4
14
  export class RowReorderController {
5
15
  #order;
6
16
  #preGrab;
@@ -19,6 +29,10 @@ export class RowReorderController {
19
29
  const pending = this.#pending;
20
30
  if (!pending || event.pointerId !== pending.pointerId)
21
31
  return;
32
+ if (!(event.buttons & 1)) {
33
+ this.#endPointer();
34
+ return;
35
+ }
22
36
  if (!this.dragging) {
23
37
  const dx = event.clientX - pending.startX;
24
38
  const dy = event.clientY - pending.startY;
@@ -29,27 +43,14 @@ export class RowReorderController {
29
43
  }
30
44
  catch {
31
45
  }
32
- this.startDrag(pending.data, pending.getGhost());
46
+ this.startDrag(pending.data, this.#ghostAtEngage(pending) ?? undefined);
33
47
  }
34
48
  this.moveGhost(event.clientX, event.clientY);
35
49
  this.dragOver(event.clientY);
36
50
  };
37
- this.#onHostPointerUp = (event) => {
38
- const pending = this.#pending;
39
- if (!pending || event.pointerId !== pending.pointerId)
40
- return;
41
- const host = this.#hostElement;
42
- host.removeEventListener('pointermove', this.#onHostPointerMove);
43
- host.removeEventListener('pointerup', this.#onHostPointerUp);
44
- host.removeEventListener('pointercancel', this.#onHostPointerUp);
45
- try {
46
- if (host.hasPointerCapture(pending.pointerId))
47
- host.releasePointerCapture(pending.pointerId);
48
- }
49
- catch {
50
- }
51
- this.#pending = null;
52
- this.endDrag();
51
+ this.#onPointerUp = (event) => {
52
+ if (event.pointerId === this.#pending?.pointerId)
53
+ this.#endPointer();
53
54
  };
54
55
  this.host.addController(this);
55
56
  }
@@ -57,6 +58,9 @@ export class RowReorderController {
57
58
  return this.host;
58
59
  }
59
60
  hostConnected() { }
61
+ hostDisconnected() {
62
+ this.#endPointer();
63
+ }
60
64
  get enabled() {
61
65
  return Boolean(this.host.rowReordering?.enabled);
62
66
  }
@@ -103,6 +107,33 @@ export class RowReorderController {
103
107
  if (announce)
104
108
  this.host.announce(this.host.localize('announce.manualOrderCleared'));
105
109
  }
110
+ resetForDataChange(carry) {
111
+ const pre = this.#preGrab;
112
+ if (this.grabbed) {
113
+ this.grabbed = carry([this.grabbed])[0] ?? null;
114
+ if (!this.grabbed)
115
+ this.#preGrab = null;
116
+ else if (pre) {
117
+ pre.order = pre.order && carry(pre.order);
118
+ pre.data = pre.data && carry(pre.data);
119
+ }
120
+ }
121
+ const pending = this.#pending;
122
+ const held = pending?.data ?? this.dragging;
123
+ if (held) {
124
+ const row = carry([held])[0];
125
+ if (!row)
126
+ this.#endPointer();
127
+ else {
128
+ if (pending)
129
+ pending.data = row;
130
+ if (this.dragging)
131
+ this.dragging = row;
132
+ }
133
+ }
134
+ if (this.#order)
135
+ this.restoreManualOrder(carry(this.#order));
136
+ }
106
137
  moveRow(from, to, position = 'before') {
107
138
  const view = this.host.pageItems;
108
139
  const before = this.#captureRowRects();
@@ -184,11 +215,36 @@ export class RowReorderController {
184
215
  };
185
216
  const host = this.#hostElement;
186
217
  host.addEventListener('pointermove', this.#onHostPointerMove);
187
- host.addEventListener('pointerup', this.#onHostPointerUp);
188
- host.addEventListener('pointercancel', this.#onHostPointerUp);
218
+ host.ownerDocument.addEventListener('pointerup', this.#onPointerUp, true);
219
+ host.ownerDocument.addEventListener('pointercancel', this.#onPointerUp, true);
189
220
  }
190
221
  #onHostPointerMove;
191
- #onHostPointerUp;
222
+ #ghostAtEngage(pending) {
223
+ const row = this.host.rows.find((candidate) => candidate.data === pending.data);
224
+ if (!row)
225
+ return pending.getGhost();
226
+ const cells = row.cells;
227
+ return captureRowGhost(row, cells, pending.startX, pending.startY);
228
+ }
229
+ #onPointerUp;
230
+ #endPointer() {
231
+ const pending = this.#pending;
232
+ if (pending) {
233
+ const host = this.#hostElement;
234
+ host.removeEventListener('pointermove', this.#onHostPointerMove);
235
+ host.ownerDocument.removeEventListener('pointerup', this.#onPointerUp, true);
236
+ host.ownerDocument.removeEventListener('pointercancel', this.#onPointerUp, true);
237
+ try {
238
+ if (host.hasPointerCapture(pending.pointerId)) {
239
+ host.releasePointerCapture(pending.pointerId);
240
+ }
241
+ }
242
+ catch {
243
+ }
244
+ this.#pending = null;
245
+ }
246
+ this.endDrag();
247
+ }
192
248
  async #dragSwap(target, position) {
193
249
  if (this.#swapping)
194
250
  return;
@@ -196,8 +252,7 @@ export class RowReorderController {
196
252
  try {
197
253
  const before = this.#captureRowRects();
198
254
  if (this.#commit(this.dragging, target, position)) {
199
- await this.host.updateComplete;
200
- await awaitChildUpdates(this.host.rows);
255
+ await settleRowsForFlip(this.host);
201
256
  this.#playRowFlip(before);
202
257
  }
203
258
  }
@@ -212,7 +267,12 @@ export class RowReorderController {
212
267
  if (!row)
213
268
  return false;
214
269
  this.grabbed = row;
215
- this.#preGrab = this.#order ? [...this.#order] : null;
270
+ this.#preGrab = {
271
+ order: this.#order,
272
+ data: this.applyToData ? [...this.host.data] : null,
273
+ sort: this.host.sortExpressions,
274
+ index: rowIndex,
275
+ };
216
276
  this.host.requestUpdate();
217
277
  this.host.announce(this.host.localize('announce.rowGrabbed'));
218
278
  return true;
@@ -244,13 +304,46 @@ export class RowReorderController {
244
304
  this.host.announce(this.host.localize('announce.rowDropped'));
245
305
  }
246
306
  cancelGrab() {
247
- if (!this.grabbed)
307
+ const row = this.grabbed;
308
+ const pre = this.#preGrab;
309
+ if (!row || !pre)
248
310
  return;
249
- this.grabbed = null;
250
- this.#order = this.#preGrab;
251
- this.#preGrab = null;
311
+ const from = this.host.pageItems.indexOf(row);
312
+ this.grabbed = this.#preGrab = null;
313
+ this.#order = pre.order;
314
+ if (pre.data)
315
+ this.#spliceData(pre.data);
316
+ if (pre.sort.length)
317
+ this.host.sortExpressions = pre.sort;
252
318
  this.host.requestUpdate(PIPELINE);
253
319
  this.host.announce(this.host.localize('announce.reorderCancelled'));
320
+ const to = pre.index;
321
+ if (from !== to) {
322
+ const position = from > to ? 'before' : 'after';
323
+ this.host.emitEvent('rowMoved', { detail: { from, to, position, toIndex: to, data: row } });
324
+ }
325
+ }
326
+ #fullOrder() {
327
+ const data = this.host.data;
328
+ const sort = this.host.sortExpressions;
329
+ let base;
330
+ if (this.#order) {
331
+ const rest = new Set(data);
332
+ base = this.#order.filter((row) => rest.delete(row));
333
+ base.push(...rest);
334
+ }
335
+ else if (sort.length && !this.host.dataPipelineConfiguration?.sort) {
336
+ const state = new Map(sort.map((expr) => [expr.key, expr]));
337
+ base = new SortDataOperation().apply([...data], state);
338
+ }
339
+ else {
340
+ base = [...data];
341
+ }
342
+ const listed = new Set(base);
343
+ const shown = this.host.dataView.filter((row) => listed.has(row));
344
+ const inView = new Set(shown);
345
+ let k = 0;
346
+ return base.map((row) => (inView.has(row) ? shown[k++] : row));
254
347
  }
255
348
  #commit(source, target, position, options = {}) {
256
349
  if (!this.enabled || !source || !target || source === target)
@@ -258,20 +351,22 @@ export class RowReorderController {
258
351
  const view = this.host.pageItems;
259
352
  const from = view.indexOf(source);
260
353
  const to = view.indexOf(target);
261
- const proceed = this.host.emitEvent('rowMoving', {
262
- detail: { from, to, data: source },
263
- cancelable: true,
264
- });
265
- if (!proceed)
354
+ const toIndex = position === 'after' ? (from < to ? to : to + 1) : from < to ? to - 1 : to;
355
+ if (from === -1 || to === -1 || toIndex === from)
356
+ return false;
357
+ const next = this.#fullOrder();
358
+ const at = next.indexOf(source);
359
+ if (at === -1 || !next.includes(target))
360
+ return false;
361
+ next.splice(at, 1);
362
+ next.splice(next.indexOf(target) + (position === 'after' ? 1 : 0), 0, source);
363
+ if (next.indexOf(source) === at)
266
364
  return false;
267
- const baseline = this.#order ?? [...this.host.dataView];
268
- const next = baseline.filter((row) => row !== source);
269
- let index = next.indexOf(target);
270
- if (index === -1)
365
+ const detail = { from, to, position, toIndex, data: source };
366
+ if (!this.host.emitEvent('rowMoving', { detail, cancelable: true }))
271
367
  return false;
272
- if (position === 'after')
273
- index += 1;
274
- next.splice(index, 0, source);
368
+ if (this.host.sortExpressions.length)
369
+ this.host.sortExpressions = [];
275
370
  if (this.applyToData) {
276
371
  this.#spliceData(next);
277
372
  this.#order = null;
@@ -282,7 +377,7 @@ export class RowReorderController {
282
377
  this.host.requestUpdate(PIPELINE);
283
378
  if (!options.silent)
284
379
  this.host.announce(this.host.localize('announce.rowMoved'));
285
- this.host.emitEvent('rowMoved', { detail: { from, to, data: source } });
380
+ this.host.emitEvent('rowMoved', { detail });
286
381
  return true;
287
382
  }
288
383
  #spliceData(order) {
@@ -317,8 +412,7 @@ export class RowReorderController {
317
412
  return entries;
318
413
  }
319
414
  async #flipAfterUpdate(before) {
320
- await this.host.updateComplete;
321
- await awaitChildUpdates(this.host.rows);
415
+ await settleRowsForFlip(this.host);
322
416
  this.#playRowFlip(before);
323
417
  }
324
418
  #playRowFlip(before) {