@revolist/revogrid 4.9.2 → 4.9.4

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 (253) hide show
  1. package/dist/cjs/{base.plugin-d48d867d.js → base.plugin-bf5f43a0.js} +2 -2
  2. package/dist/cjs/{base.plugin-d48d867d.js.map → base.plugin-bf5f43a0.js.map} +1 -1
  3. package/dist/cjs/{column.service-6f691f50.js → column.service-01f4a6c7.js} +25 -6
  4. package/dist/cjs/column.service-01f4a6c7.js.map +1 -0
  5. package/dist/cjs/{dimension.helpers-e9d22516.js → dimension.helpers-a6788214.js} +10 -5
  6. package/dist/cjs/dimension.helpers-a6788214.js.map +1 -0
  7. package/dist/cjs/{header-cell-renderer-81a22b00.js → header-cell-renderer-3bc70679.js} +10 -8
  8. package/dist/cjs/header-cell-renderer-3bc70679.js.map +1 -0
  9. package/dist/cjs/index.cjs.js +4 -4
  10. package/dist/cjs/revo-grid.cjs.entry.js +81 -93
  11. package/dist/cjs/revo-grid.cjs.entry.js.map +1 -1
  12. package/dist/cjs/revogr-attribution_6.cjs.entry.js +61 -41
  13. package/dist/cjs/revogr-attribution_6.cjs.entry.js.map +1 -1
  14. package/dist/cjs/revogr-clipboard_3.cjs.entry.js +9 -7
  15. package/dist/cjs/revogr-clipboard_3.cjs.entry.js.map +1 -1
  16. package/dist/cjs/revogr-data_4.cjs.entry.js +45 -36
  17. package/dist/cjs/revogr-data_4.cjs.entry.js.map +1 -1
  18. package/dist/cjs/revogr-filter-panel.cjs.entry.js.map +1 -1
  19. package/dist/cjs/{selection.helpers-8fa19c04.js → selection.helpers-1a8c8d49.js} +32 -31
  20. package/dist/cjs/selection.helpers-1a8c8d49.js.map +1 -0
  21. package/dist/cjs/{throttle-bcc4740d.js → throttle-52be9e67.js} +4 -3
  22. package/dist/cjs/throttle-52be9e67.js.map +1 -0
  23. package/dist/cjs/{viewport.store-9cf01c71.js → viewport.store-35a3e7ee.js} +13 -9
  24. package/dist/cjs/viewport.store-35a3e7ee.js.map +1 -0
  25. package/dist/collection/components/clipboard/revogr-clipboard.js +5 -5
  26. package/dist/collection/components/clipboard/revogr-clipboard.js.map +1 -1
  27. package/dist/collection/components/data/cell-renderer.js +7 -4
  28. package/dist/collection/components/data/cell-renderer.js.map +1 -1
  29. package/dist/collection/components/data/column.service.js +1 -1
  30. package/dist/collection/components/data/column.service.js.map +1 -1
  31. package/dist/collection/components/data/revogr-data.js +1 -1
  32. package/dist/collection/components/data/revogr-data.js.map +1 -1
  33. package/dist/collection/components/editors/revogr-edit.js +6 -6
  34. package/dist/collection/components/editors/revogr-edit.js.map +1 -1
  35. package/dist/collection/components/editors/text-editor.js +3 -1
  36. package/dist/collection/components/editors/text-editor.js.map +1 -1
  37. package/dist/collection/components/header/header-renderer.js +2 -1
  38. package/dist/collection/components/header/header-renderer.js.map +1 -1
  39. package/dist/collection/components/header/resizable.directive.js +7 -5
  40. package/dist/collection/components/header/resizable.directive.js.map +1 -1
  41. package/dist/collection/components/header/resizable.element.js +1 -1
  42. package/dist/collection/components/header/resizable.element.js.map +1 -1
  43. package/dist/collection/components/overlay/autofill.service.js +5 -4
  44. package/dist/collection/components/overlay/autofill.service.js.map +1 -1
  45. package/dist/collection/components/overlay/keyboard.service.js.map +1 -1
  46. package/dist/collection/components/overlay/revogr-overlay-selection.js +71 -37
  47. package/dist/collection/components/overlay/revogr-overlay-selection.js.map +1 -1
  48. package/dist/collection/components/overlay/selection.utils.js +4 -4
  49. package/dist/collection/components/overlay/selection.utils.js.map +1 -1
  50. package/dist/collection/components/revoGrid/grid.helpers.js +10 -8
  51. package/dist/collection/components/revoGrid/grid.helpers.js.map +1 -1
  52. package/dist/collection/components/revoGrid/revo-grid.js +42 -42
  53. package/dist/collection/components/revoGrid/revo-grid.js.map +1 -1
  54. package/dist/collection/components/revoGrid/viewport.helpers.js +19 -0
  55. package/dist/collection/components/revoGrid/viewport.helpers.js.map +1 -1
  56. package/dist/collection/components/revoGrid/viewport.scrolling.service.js +4 -3
  57. package/dist/collection/components/revoGrid/viewport.scrolling.service.js.map +1 -1
  58. package/dist/collection/components/revoGrid/viewport.service.js +27 -37
  59. package/dist/collection/components/revoGrid/viewport.service.js.map +1 -1
  60. package/dist/collection/components/rowHeaders/revogr-row-headers.js +2 -2
  61. package/dist/collection/components/rowHeaders/revogr-row-headers.js.map +1 -1
  62. package/dist/collection/components/scroll/revogr-viewport-scroll.js +34 -29
  63. package/dist/collection/components/scroll/revogr-viewport-scroll.js.map +1 -1
  64. package/dist/collection/components/scrollable/autohide-scroll.plugin.js +1 -1
  65. package/dist/collection/components/scrollable/autohide-scroll.plugin.js.map +1 -1
  66. package/dist/collection/components/scrollable/revogr-scroll-virtual.js +3 -3
  67. package/dist/collection/components/selectionFocus/revogr-focus.js +1 -1
  68. package/dist/collection/components/selectionFocus/revogr-focus.js.map +1 -1
  69. package/dist/collection/components/selectionTempRange/revogr-temp-range.js.map +1 -1
  70. package/dist/collection/components/vnode/vnode-converter.js +6 -6
  71. package/dist/collection/components/vnode/vnode-converter.js.map +1 -1
  72. package/dist/collection/components/vnode/vnode.utils.js.map +1 -1
  73. package/dist/collection/global/global.js.map +1 -1
  74. package/dist/collection/plugins/export/export.plugin.js +2 -2
  75. package/dist/collection/plugins/export/export.plugin.js.map +1 -1
  76. package/dist/collection/plugins/filter/filter.panel.js +4 -4
  77. package/dist/collection/plugins/groupingColumn/columnGroupsRenderer.js +1 -1
  78. package/dist/collection/plugins/groupingColumn/columnGroupsRenderer.js.map +1 -1
  79. package/dist/collection/plugins/groupingRow/grouping.row.plugin.js +2 -2
  80. package/dist/collection/plugins/groupingRow/grouping.row.plugin.js.map +1 -1
  81. package/dist/collection/plugins/groupingRow/grouping.service.js +1 -1
  82. package/dist/collection/plugins/groupingRow/grouping.service.js.map +1 -1
  83. package/dist/collection/plugins/moveColumn/column.drag.plugin.js +1 -1
  84. package/dist/collection/plugins/moveColumn/column.drag.plugin.js.map +1 -1
  85. package/dist/collection/plugins/sorting/sorting.plugin.js +9 -12
  86. package/dist/collection/plugins/sorting/sorting.plugin.js.map +1 -1
  87. package/dist/collection/services/cell.helpers.js +3 -2
  88. package/dist/collection/services/cell.helpers.js.map +1 -1
  89. package/dist/collection/services/column.data.provider.js.map +1 -1
  90. package/dist/collection/services/data.provider.js.map +1 -1
  91. package/dist/collection/services/dimension.provider.js +2 -1
  92. package/dist/collection/services/dimension.provider.js.map +1 -1
  93. package/dist/collection/services/local.scroll.service.js +3 -2
  94. package/dist/collection/services/local.scroll.service.js.map +1 -1
  95. package/dist/collection/services/selection.store.connector.js +20 -16
  96. package/dist/collection/services/selection.store.connector.js.map +1 -1
  97. package/dist/collection/store/selection/selection.helpers.js +8 -12
  98. package/dist/collection/store/selection/selection.helpers.js.map +1 -1
  99. package/dist/collection/store/selection/selection.store.js +2 -1
  100. package/dist/collection/store/selection/selection.store.js.map +1 -1
  101. package/dist/collection/store/vp/viewport.helpers.js +10 -6
  102. package/dist/collection/store/vp/viewport.helpers.js.map +1 -1
  103. package/dist/collection/store/vp/viewport.store.js +1 -1
  104. package/dist/collection/store/vp/viewport.store.js.map +1 -1
  105. package/dist/collection/themeManager/theme.service.js +1 -1
  106. package/dist/collection/themeManager/theme.service.js.map +1 -1
  107. package/dist/collection/types/interfaces.js.map +1 -1
  108. package/dist/collection/types/selection.js.map +1 -1
  109. package/dist/collection/types/viewport.interfaces.js.map +1 -1
  110. package/dist/collection/utils/closest.polifill.js.map +1 -1
  111. package/dist/collection/utils/store.utils.js +9 -4
  112. package/dist/collection/utils/store.utils.js.map +1 -1
  113. package/dist/esm/{base.plugin-78393655.js → base.plugin-5e7a3c51.js} +2 -2
  114. package/dist/esm/{base.plugin-78393655.js.map → base.plugin-5e7a3c51.js.map} +1 -1
  115. package/dist/esm/{column.service-0e41057a.js → column.service-5d14e7e9.js} +25 -6
  116. package/dist/esm/column.service-5d14e7e9.js.map +1 -0
  117. package/dist/esm/{dimension.helpers-91398565.js → dimension.helpers-56298828.js} +10 -5
  118. package/dist/esm/dimension.helpers-56298828.js.map +1 -0
  119. package/dist/esm/{header-cell-renderer-6d8ac25d.js → header-cell-renderer-fc999784.js} +10 -8
  120. package/dist/esm/header-cell-renderer-fc999784.js.map +1 -0
  121. package/dist/esm/index.js +4 -4
  122. package/dist/esm/revo-grid.entry.js +81 -93
  123. package/dist/esm/revo-grid.entry.js.map +1 -1
  124. package/dist/esm/revogr-attribution_6.entry.js +61 -41
  125. package/dist/esm/revogr-attribution_6.entry.js.map +1 -1
  126. package/dist/esm/revogr-clipboard_3.entry.js +9 -7
  127. package/dist/esm/revogr-clipboard_3.entry.js.map +1 -1
  128. package/dist/esm/revogr-data_4.entry.js +45 -36
  129. package/dist/esm/revogr-data_4.entry.js.map +1 -1
  130. package/dist/esm/revogr-filter-panel.entry.js.map +1 -1
  131. package/dist/esm/{selection.helpers-50e9f09d.js → selection.helpers-accaad4a.js} +32 -31
  132. package/dist/esm/selection.helpers-accaad4a.js.map +1 -0
  133. package/dist/esm/{throttle-1b1dd9d2.js → throttle-7283692c.js} +4 -3
  134. package/dist/esm/throttle-7283692c.js.map +1 -0
  135. package/dist/esm/{viewport.store-bfd0b036.js → viewport.store-d8e03528.js} +13 -9
  136. package/dist/esm/viewport.store-d8e03528.js.map +1 -0
  137. package/dist/revo-grid/{base.plugin-78393655.js → base.plugin-5e7a3c51.js} +2 -2
  138. package/dist/revo-grid/column.service-5d14e7e9.js +5 -0
  139. package/dist/revo-grid/column.service-5d14e7e9.js.map +1 -0
  140. package/dist/revo-grid/{dimension.helpers-91398565.js → dimension.helpers-56298828.js} +2 -2
  141. package/dist/revo-grid/{dimension.helpers-91398565.js.map → dimension.helpers-56298828.js.map} +1 -1
  142. package/dist/revo-grid/header-cell-renderer-fc999784.js +5 -0
  143. package/dist/revo-grid/header-cell-renderer-fc999784.js.map +1 -0
  144. package/dist/revo-grid/index.esm.js +1 -1
  145. package/dist/revo-grid/revo-grid.entry.js +1 -1
  146. package/dist/revo-grid/revo-grid.entry.js.map +1 -1
  147. package/dist/revo-grid/revogr-attribution_6.entry.js +1 -1
  148. package/dist/revo-grid/revogr-attribution_6.entry.js.map +1 -1
  149. package/dist/revo-grid/revogr-clipboard_3.entry.js +1 -1
  150. package/dist/revo-grid/revogr-clipboard_3.entry.js.map +1 -1
  151. package/dist/revo-grid/revogr-data_4.entry.js +1 -1
  152. package/dist/revo-grid/revogr-data_4.entry.js.map +1 -1
  153. package/dist/revo-grid/revogr-filter-panel.entry.js.map +1 -1
  154. package/dist/revo-grid/selection.helpers-accaad4a.js +5 -0
  155. package/dist/revo-grid/selection.helpers-accaad4a.js.map +1 -0
  156. package/dist/revo-grid/{throttle-1b1dd9d2.js → throttle-7283692c.js} +2 -2
  157. package/dist/revo-grid/throttle-7283692c.js.map +1 -0
  158. package/dist/revo-grid/viewport.store-d8e03528.js +5 -0
  159. package/dist/revo-grid/viewport.store-d8e03528.js.map +1 -0
  160. package/dist/types/components/data/column.service.d.ts +1 -1
  161. package/dist/types/components/data/row-highlight.plugin.d.ts +1 -1
  162. package/dist/types/components/editors/revogr-edit.d.ts +1 -1
  163. package/dist/types/components/editors/text-editor.d.ts +3 -3
  164. package/dist/types/components/header/header-renderer.d.ts +2 -2
  165. package/dist/types/components/header/resizable.directive.d.ts +2 -2
  166. package/dist/types/components/overlay/autofill.service.d.ts +6 -6
  167. package/dist/types/components/overlay/keyboard.service.d.ts +4 -4
  168. package/dist/types/components/overlay/revogr-overlay-selection.d.ts +15 -11
  169. package/dist/types/components/overlay/selection.utils.d.ts +5 -4
  170. package/dist/types/components/revoGrid/revo-grid.d.ts +7 -6
  171. package/dist/types/components/revoGrid/viewport.helpers.d.ts +18 -3
  172. package/dist/types/components/revoGrid/viewport.scrolling.service.d.ts +1 -1
  173. package/dist/types/components/revoGrid/viewport.service.d.ts +2 -6
  174. package/dist/types/components/scroll/revogr-viewport-scroll.d.ts +6 -6
  175. package/dist/types/components/selectionTempRange/revogr-temp-range.d.ts +1 -1
  176. package/dist/types/components/vnode/vnode-converter.d.ts +1 -1
  177. package/dist/types/components/vnode/vnode.utils.d.ts +1 -1
  178. package/dist/types/components.d.ts +21 -18
  179. package/dist/types/plugins/column.auto-size.plugin.d.ts +2 -2
  180. package/dist/types/plugins/export/export.plugin.d.ts +3 -3
  181. package/dist/types/plugins/filter/filter.button.d.ts +1 -1
  182. package/dist/types/plugins/filter/filter.panel.d.ts +1 -1
  183. package/dist/types/plugins/groupingRow/grouping.row.plugin.d.ts +1 -1
  184. package/dist/types/plugins/groupingRow/grouping.service.d.ts +3 -3
  185. package/dist/types/plugins/sorting/sorting.plugin.d.ts +8 -8
  186. package/dist/types/services/column.data.provider.d.ts +1 -1
  187. package/dist/types/services/data.provider.d.ts +1 -1
  188. package/dist/types/services/dimension.provider.d.ts +3 -2
  189. package/dist/types/services/selection.store.connector.d.ts +9 -9
  190. package/dist/types/store/selection/selection.helpers.d.ts +1 -1
  191. package/dist/types/store/selection/selection.store.d.ts +4 -4
  192. package/dist/types/store/vp/viewport.helpers.d.ts +2 -2
  193. package/dist/types/themeManager/theme.service.d.ts +1 -1
  194. package/dist/types/types/interfaces.d.ts +4 -1
  195. package/dist/types/types/viewport.interfaces.d.ts +2 -2
  196. package/dist/types/utils/store.utils.d.ts +7 -4
  197. package/hydrate/index.js +261 -210
  198. package/hydrate/index.mjs +261 -210
  199. package/package.json +1 -1
  200. package/standalone/column.service.js +32 -31
  201. package/standalone/column.service.js.map +1 -1
  202. package/standalone/data.store.js +9 -4
  203. package/standalone/data.store.js.map +1 -1
  204. package/standalone/index.js.map +1 -1
  205. package/standalone/local.scroll.timer.js +3 -2
  206. package/standalone/local.scroll.timer.js.map +1 -1
  207. package/standalone/revo-grid.js +76 -88
  208. package/standalone/revo-grid.js.map +1 -1
  209. package/standalone/revogr-clipboard2.js +3 -3
  210. package/standalone/revogr-clipboard2.js.map +1 -1
  211. package/standalone/revogr-data2.js +7 -4
  212. package/standalone/revogr-data2.js.map +1 -1
  213. package/standalone/revogr-edit2.js +5 -3
  214. package/standalone/revogr-edit2.js.map +1 -1
  215. package/standalone/revogr-filter-panel.js.map +1 -1
  216. package/standalone/revogr-focus2.js.map +1 -1
  217. package/standalone/revogr-header2.js +11 -8
  218. package/standalone/revogr-header2.js.map +1 -1
  219. package/standalone/revogr-overlay-selection2.js +50 -30
  220. package/standalone/revogr-overlay-selection2.js.map +1 -1
  221. package/standalone/revogr-row-headers2.js +12 -8
  222. package/standalone/revogr-row-headers2.js.map +1 -1
  223. package/standalone/revogr-scroll-virtual2.js +1 -1
  224. package/standalone/revogr-scroll-virtual2.js.map +1 -1
  225. package/standalone/revogr-temp-range2.js.map +1 -1
  226. package/standalone/revogr-viewport-scroll2.js +47 -23
  227. package/standalone/revogr-viewport-scroll2.js.map +1 -1
  228. package/standalone/selection.utils.js +4 -4
  229. package/standalone/selection.utils.js.map +1 -1
  230. package/standalone/vnode-converter.js +3 -3
  231. package/standalone/vnode-converter.js.map +1 -1
  232. package/dist/cjs/column.service-6f691f50.js.map +0 -1
  233. package/dist/cjs/dimension.helpers-e9d22516.js.map +0 -1
  234. package/dist/cjs/header-cell-renderer-81a22b00.js.map +0 -1
  235. package/dist/cjs/selection.helpers-8fa19c04.js.map +0 -1
  236. package/dist/cjs/throttle-bcc4740d.js.map +0 -1
  237. package/dist/cjs/viewport.store-9cf01c71.js.map +0 -1
  238. package/dist/esm/column.service-0e41057a.js.map +0 -1
  239. package/dist/esm/dimension.helpers-91398565.js.map +0 -1
  240. package/dist/esm/header-cell-renderer-6d8ac25d.js.map +0 -1
  241. package/dist/esm/selection.helpers-50e9f09d.js.map +0 -1
  242. package/dist/esm/throttle-1b1dd9d2.js.map +0 -1
  243. package/dist/esm/viewport.store-bfd0b036.js.map +0 -1
  244. package/dist/revo-grid/column.service-0e41057a.js +0 -5
  245. package/dist/revo-grid/column.service-0e41057a.js.map +0 -1
  246. package/dist/revo-grid/header-cell-renderer-6d8ac25d.js +0 -5
  247. package/dist/revo-grid/header-cell-renderer-6d8ac25d.js.map +0 -1
  248. package/dist/revo-grid/selection.helpers-50e9f09d.js +0 -5
  249. package/dist/revo-grid/selection.helpers-50e9f09d.js.map +0 -1
  250. package/dist/revo-grid/throttle-1b1dd9d2.js.map +0 -1
  251. package/dist/revo-grid/viewport.store-bfd0b036.js +0 -5
  252. package/dist/revo-grid/viewport.store-bfd0b036.js.map +0 -1
  253. /package/dist/revo-grid/{base.plugin-78393655.js.map → base.plugin-5e7a3c51.js.map} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"selection.helpers.js","sourceRoot":"","sources":["../../../src/store/selection/selection.helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0CAA0C,CAAC;AAGvE,MAAM,UAAU,aAAa,CAAC,GAAW;IACvC,OAAO,GAAG,KAAK,WAAW,CAAC;AAC7B,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,IAAU,EAAE,QAAc;IACjD,MAAM,QAAQ,GAAkB,EAAE,CAAC;IACnC,IAAI,KAAK,GAAmB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAEvC,sBAAsB;IACtB,KAAK,IAAI,CAAC,IAAI,KAAK,EAAE,CAAC;QACpB,IAAI,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC;YAChB,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;YACtB,OAAO,QAAQ,CAAC;QAClB,CAAC;IACH,CAAC;IACD,kBAAkB;IAClB,KAAK,IAAI,CAAC,IAAI,KAAK,EAAE,CAAC;QACpB,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;YAC3B,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;YACpC,OAAO,QAAQ,CAAC;QAClB,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MA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AAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;AACtC,CAAC","sourcesContent":["import { EMPTY_INDEX } from '../../services/selection.store.connector';\nimport { Cell, RangeArea } from '@type';\n\nexport function isHiddenStore(pos: number) {\n return pos === EMPTY_INDEX;\n}\n\nexport function nextCell(cell: Cell, lastCell: Cell): Partial<Cell> | null {\n const nextItem: Partial<Cell> = {};\n let types: (keyof Cell)[] = ['x', 'y'];\n\n // previous item check\n for (let t of types) {\n if (cell[t] < 0) {\n nextItem[t] = cell[t];\n return nextItem;\n }\n }\n // next item check\n for (let t of types) {\n if (cell[t] >= lastCell[t]) {\n nextItem[t] = cell[t] - lastCell[t];\n return nextItem;\n }\n }\n return null;\n}\n\nexport function cropCellToMax(cell: Cell, lastCell: Cell): Cell {\n const newCell: Cell = { ...cell };\n let types: (keyof Cell)[] = ['x', 'y'];\n // previous item check\n for (let t of types) {\n if (cell[t] < 0) {\n newCell[t] = 0;\n }\n }\n // next item check\n for (let t of types) {\n if (cell[t] >= lastCell[t]) {\n newCell[t] = lastCell[t] - 1;\n }\n }\n return newCell;\n}\n\nexport function getRange(start?: Cell, end?: Cell): RangeArea | null {\n return start && end\n ? {\n x: Math.min(start.x, end.x),\n y: Math.min(start.y, end.y),\n x1: Math.max(start.x, end.x),\n y1: Math.max(start.y, end.y),\n }\n : null;\n}\n\nexport function isRangeSingleCell(a: RangeArea): boolean {\n return a.x === a.x1 && a.y === a.y1;\n}\n"]}
1
+ {"version":3,"file":"selection.helpers.js","sourceRoot":"","sources":["../../../src/store/selection/selection.helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0CAA0C,CAAC;AAGvE,MAAM,UAAU,aAAa,CAAC,GAAW;IACvC,OAAO,GAAG,KAAK,WAAW,CAAC;AAC7B,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,IAAU,EAAE,QAAc;IACjD,MAAM,QAAQ,GAAkB,EAAE,CAAC;IACnC,IAAI,KAAK,GAAmB,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AAC;YACE,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;YAC3B,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;YAC3B,EAAE,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;YAC5B,EAAE,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;SAC7B;QACH,CAAC,CAAC,IAAI,CAAC;AACX,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,CAAY;IAC5C,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;AACtC,CAAC","sourcesContent":["import { EMPTY_INDEX } from '../../services/selection.store.connector';\nimport { Cell, RangeArea } from '@type';\n\nexport function isHiddenStore(pos: number) {\n return pos === EMPTY_INDEX;\n}\n\nexport function nextCell(cell: Cell, lastCell: Cell): Partial<Cell> | null {\n const nextItem: Partial<Cell> = {};\n let types: (keyof Cell)[] = ['x', 'y'];\n\n // previous item check\n for (let t of types) {\n if (cell[t] < 0) {\n nextItem[t] = cell[t];\n return nextItem;\n }\n }\n // next item check\n for (let t of types) {\n if (cell[t] >= lastCell[t]) {\n nextItem[t] = cell[t] - lastCell[t];\n return nextItem;\n }\n }\n return null;\n}\n\nexport function cropCellToMax(cell: Cell, lastCell: Cell): Cell {\n const croppedCell: Cell = { ...cell };\n const cellCoordinates: (keyof Cell)[] = ['x', 'y'];\n\n for (const coordinate of cellCoordinates) {\n if (cell[coordinate] < 0) {\n croppedCell[coordinate] = 0;\n } else if (cell[coordinate] >= lastCell[coordinate]) {\n croppedCell[coordinate] = lastCell[coordinate] - 1;\n }\n }\n\n return croppedCell;\n}\n\nexport function getRange(start?: Cell | null, end?: Cell | null): RangeArea | null {\n return start && end\n ? {\n x: Math.min(start.x, end.x),\n y: Math.min(start.y, end.y),\n x1: Math.max(start.x, end.x),\n y1: Math.max(start.y, end.y),\n }\n : null;\n}\n\nexport function isRangeSingleCell(a: RangeArea): boolean {\n return a.x === a.x1 && a.y === a.y1;\n}\n"]}
@@ -61,7 +61,8 @@ export class SelectionStore {
61
61
  setStore(this.store, { range, edit: null, tempRange: null });
62
62
  }
63
63
  setRange(start, end) {
64
- this.setRangeArea(getRange(start, end));
64
+ const range = getRange(start, end);
65
+ this.setRangeArea(range);
65
66
  }
66
67
  setLastCell(lastCell) {
67
68
  setStore(this.store, { lastCell });
@@ -1 +1 @@
1
- {"version":3,"file":"selection.store.js","sourceRoot":"","sources":["../../../src/store/selection/selection.store.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAc,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAElC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,SAAS,YAAY;IACnB,OAAO;QACL,KAAK,EAAE,IAAI;QACX,SAAS,EAAE,IAAI;QACf,aAAa,EAAE,IAAI;QACnB,KAAK,EAAE,IAAI;QACX,IAAI,EAAE,IAAI;QACV,QAAQ,EAAE,IAAI;QACd,SAAS,EAAE,IAAI;KAChB,CAAC;AACJ,CAAC;AAED,MAAM,OAAO,cAAc;IAGzB;QADQ,gBAAW,GAAmB,EAAE,CAAC;QAEvC,IAAI,CAAC,KAAK,GAAG,WAAW,CAAC,YAAY,EAAE,CAAC,CAAC;QACzC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE;YACnC,IAAI,GAAG,KAAK,WAAW,IAAI,CAAC,MAAM,EAAE,CAAC;gBACnC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,eAAe,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,EAAE,CAAC,CAAC;IAC5C,CAAC;IAED,iFAAiF;IACjF,YAAY,CAAC,KAAgB;QAC3B,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC/D,CAAC;IACD,QAAQ,CAAC,KAAW,EAAE,GAAS;QAC7B,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAC;IAC1C,CAAC;IAED,WAAW,CAAC,QAAc;QACxB,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC;IACrC,CAAC;IAED,OAAO,CAAC,GAAqB;QAC3B,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACtC,IAAI,KAAK,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;YACrC,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE;gBACnB,IAAI,EAAE,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE;aACtC,CAAC,CAAC;YACH,OAAO;QACT,CAAC;QACD,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IACvC,CAAC;IAED,OAAO;QACL,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;QACnC,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;IACvB,CAAC;CACF","sourcesContent":["/**\n * Selection store\n */\n\nimport { setStore, Observable } from '../../utils/store.utils';\nimport { getRange } from '@store';\nimport { SelectionStoreState, Cell, TempRange, RangeArea } from '@type';\nimport { createStore } from '@stencil/store';\n\nfunction defaultState(): SelectionStoreState {\n return {\n range: null,\n tempRange: null,\n tempRangeType: null,\n focus: null,\n edit: null,\n lastCell: null,\n nextFocus: null,\n };\n}\n\nexport class SelectionStore {\n readonly store: Observable<SelectionStoreState>;\n private unsubscribe: { (): void }[] = [];\n constructor() {\n this.store = createStore(defaultState());\n this.store.on('set', (key, newVal) => {\n if (key === 'tempRange' && !newVal) {\n this.store.set('tempRangeType', null);\n }\n });\n }\n\n onChange<Key extends keyof SelectionStoreState>(propName: Key, cb: (newValue: SelectionStoreState[Key]) => void) {\n this.unsubscribe.push(this.store.onChange(propName, cb));\n }\n\n clearFocus() {\n setStore(this.store, { focus: null, range: null, edit: null, tempRange: null });\n }\n\n setFocus(focus: Cell, end?: Cell) {\n if (!end) {\n setStore(this.store, { focus });\n } else {\n setStore(this.store, {\n focus,\n range: getRange(focus, end),\n edit: null,\n tempRange: null,\n });\n }\n }\n\n setNextFocus(focus: Cell) {\n setStore(this.store, { nextFocus: focus });\n }\n\n setTempArea(range: TempRange | null) {\n setStore(this.store, { tempRange: range?.area, tempRangeType: range?.type, edit: null });\n }\n\n clearTemp() {\n setStore(this.store, { tempRange: null });\n }\n\n /** Can be applied from selection change or from simple keyboard change clicks */\n setRangeArea(range: RangeArea) {\n setStore(this.store, { range, edit: null, tempRange: null });\n }\n setRange(start: Cell, end: Cell) {\n this.setRangeArea(getRange(start, end));\n }\n\n setLastCell(lastCell: Cell) {\n setStore(this.store, { lastCell });\n }\n\n setEdit(val: string | boolean) {\n const focus = this.store.get('focus');\n if (focus && typeof val === 'string') {\n setStore(this.store, {\n edit: { x: focus.x, y: focus.y, val },\n });\n return;\n }\n setStore(this.store, { edit: null });\n }\n\n dispose() {\n this.unsubscribe.forEach(f => f());\n this.store.dispose();\n }\n}\n"]}
1
+ {"version":3,"file":"selection.store.js","sourceRoot":"","sources":["../../../src/store/selection/selection.store.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAc,MAAM,yBAAyB,CAAC;AAC/D,OAAO,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I,KAAK,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;YACrC,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE;gBACnB,IAAI,EAAE,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE;aACtC,CAAC,CAAC;YACH,OAAO;QACT,CAAC;QACD,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IACvC,CAAC;IAED,OAAO;QACL,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;QACnC,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;IACvB,CAAC;CACF","sourcesContent":["/**\n * Selection store\n */\n\nimport { setStore, Observable } from '../../utils/store.utils';\nimport { getRange } from '@store';\nimport { SelectionStoreState, Cell, TempRange, RangeArea, Nullable } from '@type';\nimport { createStore } from '@stencil/store';\n\nfunction defaultState(): SelectionStoreState {\n return {\n range: null,\n tempRange: null,\n tempRangeType: null,\n focus: null,\n edit: null,\n lastCell: null,\n nextFocus: null,\n };\n}\n\nexport class SelectionStore {\n readonly store: Observable<SelectionStoreState>;\n private unsubscribe: { (): void }[] = [];\n constructor() {\n this.store = createStore(defaultState());\n this.store.on('set', (key, newVal) => {\n if (key === 'tempRange' && !newVal) {\n this.store.set('tempRangeType', null);\n }\n });\n }\n\n onChange<Key extends keyof SelectionStoreState>(propName: Key, cb: (newValue: SelectionStoreState[Key]) => void) {\n this.unsubscribe.push(this.store.onChange(propName, cb));\n }\n\n clearFocus() {\n setStore(this.store, { focus: null, range: null, edit: null, tempRange: null });\n }\n\n setFocus(focus: Cell, end?: Cell) {\n if (!end) {\n setStore(this.store, { focus });\n } else {\n setStore(this.store, {\n focus,\n range: getRange(focus, end),\n edit: null,\n tempRange: null,\n });\n }\n }\n\n setNextFocus(focus: Cell) {\n setStore(this.store, { nextFocus: focus });\n }\n\n setTempArea(range: Nullable<TempRange> | null) {\n setStore(this.store, { tempRange: range?.area, tempRangeType: range?.type, edit: null });\n }\n\n clearTemp() {\n setStore(this.store, { tempRange: null });\n }\n\n /** Can be applied from selection change or from simple keyboard change clicks */\n setRangeArea(range: RangeArea | null) {\n setStore(this.store, { range, edit: null, tempRange: null });\n }\n setRange(start: Cell, end: Cell) {\n const range = getRange(start, end);\n this.setRangeArea(range);\n }\n\n setLastCell(lastCell: Cell) {\n setStore(this.store, { lastCell });\n }\n\n setEdit(val?: string | boolean) {\n const focus = this.store.get('focus');\n if (focus && typeof val === 'string') {\n setStore(this.store, {\n edit: { x: focus.x, y: focus.y, val },\n });\n return;\n }\n setStore(this.store, { edit: null });\n }\n\n dispose() {\n this.unsubscribe.forEach(f => f());\n this.store.dispose();\n }\n}\n"]}
@@ -102,6 +102,7 @@ export function getItems(opt, currentSize = 0) {
102
102
  return items;
103
103
  }
104
104
  export function recombineByOffset(offset, data) {
105
+ var _a, _b;
105
106
  const newItems = [...data.items];
106
107
  const itemsCount = newItems.length;
107
108
  let newRange = {
@@ -110,7 +111,7 @@ export function recombineByOffset(offset, data) {
110
111
  };
111
112
  // if offset out of revo-viewport, makes sense whole redraw
112
113
  if (offset > itemsCount) {
113
- return null;
114
+ return undefined;
114
115
  }
115
116
  // is direction of scroll positive
116
117
  if (data.positiveDirection) {
@@ -149,19 +150,21 @@ export function recombineByOffset(offset, data) {
149
150
  let firstItem = getFirstItem(data);
150
151
  const end = newRange.end;
151
152
  for (let i = 0; i < offset; i++) {
152
- const newIndex = firstItem.itemIndex - 1;
153
+ const newIndex = ((_a = firstItem === null || firstItem === void 0 ? void 0 : firstItem.itemIndex) !== null && _a !== void 0 ? _a : 0) - 1;
153
154
  const size = getItemSize(newIndex, data.sizes, data.originItemSize);
154
155
  // new item index to recombine
155
156
  let newStart = end - i;
156
157
  newStart = (newStart < 0 ? itemsCount + newStart : newStart) % itemsCount;
157
158
  // item should always present, we do not create new item, we recombine them
158
159
  if (!newItems[newStart]) {
159
- throw new Error('incorrect index');
160
+ console.error('incorrect index');
161
+ break;
160
162
  }
161
163
  // do recombination
164
+ const firstItemStart = (_b = firstItem === null || firstItem === void 0 ? void 0 : firstItem.start) !== null && _b !== void 0 ? _b : 0;
162
165
  newItems[newStart] = firstItem = {
163
- start: firstItem.start - size,
164
- end: firstItem.start,
166
+ start: firstItemStart - size,
167
+ end: firstItemStart,
165
168
  itemIndex: newIndex,
166
169
  size: size,
167
170
  };
@@ -197,11 +200,12 @@ export function isActiveRange(pos, realSize, first, last) {
197
200
  (pos > first.end && last.end === realSize));
198
201
  }
199
202
  export function isActiveRangeOutsideLastItem(pos, virtualSize, firstItem, lastItem) {
203
+ var _a;
200
204
  // if no first item, means no items in viewport
201
205
  if (!firstItem) {
202
206
  return false;
203
207
  }
204
- return virtualSize + pos > (lastItem === null || lastItem === void 0 ? void 0 : lastItem.end);
208
+ return virtualSize + pos > ((_a = lastItem === null || lastItem === void 0 ? void 0 : lastItem.end) !== null && _a !== void 0 ? _a : 0);
205
209
  }
206
210
  export function getFirstItem(s) {
207
211
  return s.items[s.start];
@@ -1 +1 @@
1
- {"version":3,"file":"viewport.helpers.js","sourceRoot":"","sources":["../../../src/store/vp/viewport.helpers.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAanE;;;;GAIG;AACH,MAAM,UAAU,yBAAyB,CACvC,GAAW,EAAE,aAAa;AAC1B,KAAQ,EACR,SAAiB,EACjB,WAAmB,EACnB,SAAgC;IAEhC,MAAM,UAAU,GAAiB,iBAAiB,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;IACnE,MAAM,SAAS,GAAiB,YAAY,CAAC,KAAK,CAAC,CAAC;IACpD,IAAI,QAAuB,CAAC;IAC5B,wEAAwE;IACxE,IAAI,SAAS,EAAE,CAAC;QACd,IAAI,kBAAkB,GAAG,UAAU,CAAC,SAAS,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AE3B,IAAI,GAAG,GAAG,cAAc,CAAC;IACzB,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,IAAI,KAAK,GAAG,YAAY,CAAC;IAEzB,sBAAsB;IACtB,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,2DAA2D;IAC3D,OAAO,CAAC,GAAG,KAAK,EAAE,CAAC;QACjB,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;QAC1B,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAC7B,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;QACf,sBAAsB;QACtB,KAAK,EAAE,CAAC;QACR,CAAC,EAAE,CAAC;QAEJ,wCAAwC;QACxC,IAAI,KAAK,KAAK,KAAK,EAAE,CAAC;YACpB,KAAK,GAAG,CAAC,CAAC;QACZ,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import {\n DimensionSettingsState,\n PositionItem,\n ViewSettingSizeProp,\n ViewportStateItems,\n VirtualPositionItem,\n Range,\n} from '@type';\n\nimport { getItemByPosition } from '../dimension/dimension.helpers';\n\nexport type DimensionDataViewport = Pick<\n DimensionSettingsState,\n | 'indexes'\n | 'positionIndexes'\n | 'positionIndexToItem'\n | 'sizes'\n | 'originItemSize'\n | 'realSize'\n>;\n\nexport type ItemsToUpdate = Pick<ViewportStateItems, 'items' | 'start' | 'end'>;\n/**\n * Update items based on new scroll position\n * If viewport wasn't changed fully simple recombination of positions\n * Otherwise rebuild viewport items\n */\nexport function getUpdatedItemsByPosition<T extends ItemsToUpdate>(\n pos: number, // coordinate\n items: T,\n realCount: number,\n virtualSize: number,\n dimension: DimensionDataViewport,\n): ItemsToUpdate {\n const activeItem: PositionItem = getItemByPosition(dimension, pos);\n const firstItem: PositionItem = getFirstItem(items);\n let toUpdate: ItemsToUpdate;\n // do simple position recombination if items already present in viewport\n if (firstItem) {\n let changedOffsetStart = activeItem.itemIndex - (firstItem.itemIndex || 0);\n // if item changed\n if (changedOffsetStart) {\n // simple recombination\n toUpdate = recombineByOffset(Math.abs(changedOffsetStart), {\n positiveDirection: changedOffsetStart > -1,\n ...dimension,\n ...items,\n });\n }\n }\n\n const maxSizeVirtualSize = getMaxVirtualSize(\n virtualSize,\n dimension.realSize,\n activeItem,\n );\n // if partial recombination add items if revo-viewport has some space left\n if (toUpdate) {\n const extra = addMissingItems(\n activeItem,\n realCount,\n maxSizeVirtualSize,\n toUpdate,\n dimension,\n );\n if (extra.length) {\n updateMissingAndRange(toUpdate.items, extra, toUpdate);\n }\n }\n\n // new collection if no items after replacement full replacement\n if (!toUpdate) {\n const items = getItems({\n firstItemStart: activeItem.start,\n firstItemIndex: activeItem.itemIndex,\n origSize: dimension.originItemSize,\n maxSize: maxSizeVirtualSize,\n maxCount: realCount,\n sizes: dimension.sizes,\n });\n\n // range now comes from 0 to length - 1\n toUpdate = {\n items,\n start: 0,\n end: items.length - 1,\n };\n }\n return toUpdate;\n}\n\n// virtual size can differ based on scroll position if some big items are present\n// scroll can be in the middle of item and virtual size will be larger\n// so we need to exclude this part from virtual size hence it's already passed\nfunction getMaxVirtualSize(\n virtualSize: number,\n realSize: number,\n activeItem: PositionItem,\n) {\n return Math.min(virtualSize + (activeItem.end - activeItem.start), realSize);\n}\n\nexport function updateMissingAndRange(\n items: VirtualPositionItem[],\n missing: VirtualPositionItem[],\n range: Range,\n) {\n items.splice(range.end + 1, 0, ...missing);\n // update range if start larger after recombination\n if (\n range.start >= range.end &&\n !(range.start === range.end && range.start === 0)\n ) {\n range.start += missing.length;\n }\n range.end += missing.length;\n}\n\n/**\n * If partial replacement\n * this function adds items if viewport has some space left\n */\nexport function addMissingItems<T extends ItemsToUpdate>(\n firstItem: PositionItem,\n realCount: number,\n virtualSize: number,\n existingCollection: T,\n dimension: Pick<DimensionSettingsState, 'sizes' | 'originItemSize'>,\n): VirtualPositionItem[] {\n const lastItem: VirtualPositionItem = getLastItem(existingCollection);\n const items = getItems({\n sizes: dimension.sizes,\n firstItemStart: lastItem.end,\n firstItemIndex: lastItem.itemIndex + 1,\n origSize: dimension.originItemSize,\n maxSize: virtualSize - (lastItem.end - firstItem.start),\n maxCount: realCount,\n });\n return items;\n}\n\n/**\n * Get wiewport items parameters\n * caching position and calculating items count in viewport\n */\nexport function getItems(\n opt: {\n firstItemIndex: number;\n firstItemStart: number;\n origSize: number;\n maxSize: number; // virtual size\n maxCount: number; // real item count, where the last item\n sizes?: ViewSettingSizeProp;\n },\n currentSize = 0,\n) {\n const items: VirtualPositionItem[] = [];\n\n let index = opt.firstItemIndex;\n let size = currentSize;\n\n // max size or max count\n while (size <= opt.maxSize && index < opt.maxCount) {\n const newSize = getItemSize(index, opt.sizes, opt.origSize);\n items.push({\n start: opt.firstItemStart + size,\n end: opt.firstItemStart + size + newSize,\n itemIndex: index,\n size: newSize,\n });\n size += newSize;\n index++;\n }\n return items;\n}\n\n/**\n * Do batch items recombination\n * If items not overlapped with existing viewport returns null\n */\ntype RecombindDimensionData = Pick<\n DimensionSettingsState,\n 'sizes' | 'realSize' | 'originItemSize'\n>;\ntype RecombineOffsetData = {\n positiveDirection: boolean;\n} & ItemsToUpdate &\n RecombindDimensionData;\nexport function recombineByOffset(\n offset: number,\n data: RecombineOffsetData,\n): ItemsToUpdate | null {\n const newItems = [...data.items];\n const itemsCount = newItems.length;\n let newRange = {\n start: data.start,\n end: data.end,\n };\n\n // if offset out of revo-viewport, makes sense whole redraw\n if (offset > itemsCount) {\n return null;\n }\n\n // is direction of scroll positive\n if (data.positiveDirection) {\n // push item to the end\n let lastItem: VirtualPositionItem = getLastItem(data);\n\n let i = newRange.start;\n const length = i + offset;\n for (; i < length; i++) {\n const newIndex = lastItem.itemIndex + 1;\n const size = getItemSize(\n newIndex,\n data.sizes,\n data.originItemSize,\n );\n\n // if item overlapped limit break a loop\n if (lastItem.end + size > data.realSize) {\n break;\n }\n\n // new item index to recombine\n let newEnd = i % itemsCount;\n\n // item should always present, we do not create new item, we recombine them\n if (!newItems[newEnd]) {\n throw new Error('incorrect index');\n }\n\n // do recombination\n newItems[newEnd] = lastItem = {\n start: lastItem.end,\n end: lastItem.end + size,\n itemIndex: newIndex,\n size: size,\n };\n // update range\n newRange.start++;\n newRange.end = newEnd;\n }\n\n // direction is negative\n } else {\n // push item to the start\n let firstItem: VirtualPositionItem = getFirstItem(data);\n\n const end = newRange.end;\n for (let i = 0; i < offset; i++) {\n const newIndex = firstItem.itemIndex - 1;\n const size = getItemSize(\n newIndex,\n data.sizes,\n data.originItemSize,\n );\n\n // new item index to recombine\n let newStart = end - i;\n newStart = (newStart < 0 ? itemsCount + newStart : newStart) % itemsCount;\n\n // item should always present, we do not create new item, we recombine them\n if (!newItems[newStart]) {\n throw new Error('incorrect index');\n }\n\n // do recombination\n newItems[newStart] = firstItem = {\n start: firstItem.start - size,\n end: firstItem.start,\n itemIndex: newIndex,\n size: size,\n };\n // update range\n newRange.start = newStart;\n newRange.end--;\n }\n }\n const range = {\n start:\n (newRange.start < 0 ? itemsCount + newRange.start : newRange.start) %\n itemsCount,\n end:\n (newRange.end < 0 ? itemsCount + newRange.end : newRange.end) %\n itemsCount,\n };\n return {\n items: newItems,\n ...range,\n };\n}\n\nfunction getItemSize(\n index: number,\n sizes?: ViewSettingSizeProp,\n origSize = 0,\n): number {\n if (sizes && sizes[index]) {\n return sizes[index];\n }\n return origSize;\n}\n\n/**\n * Verify if position is in range of the PositionItem, start and end are included\n */\nexport function isActiveRange(\n pos: number,\n realSize: number,\n first?: PositionItem,\n last?: PositionItem,\n): boolean {\n if (!first || !last) {\n return false;\n }\n // if position is in range of first item\n // or position is after first item and last item is the last item in real size\n return (\n (pos >= first.start && pos <= first.end) ||\n (pos > first.end && last.end === realSize)\n );\n}\n\nexport function isActiveRangeOutsideLastItem(\n pos: number,\n virtualSize: number,\n firstItem?: PositionItem,\n lastItem?: PositionItem,\n) {\n // if no first item, means no items in viewport\n if (!firstItem) {\n return false;\n }\n return virtualSize + pos > lastItem?.end;\n}\n\nexport function getFirstItem(\n s: ItemsToUpdate,\n): VirtualPositionItem | undefined {\n return s.items[s.start];\n}\n\nexport function getLastItem(s: ItemsToUpdate): VirtualPositionItem {\n return s.items[s.end];\n}\n\n/**\n * Set items sizes from start index to end\n * @param vpItems\n * @param start\n * @param size\n * @param lastCoordinate\n * @returns\n */\nexport function setItemSizes(\n vpItems: VirtualPositionItem[],\n initialIndex: number,\n size: number,\n lastCoordinate: number,\n) {\n const items = [...vpItems];\n const count = items.length;\n\n let pos = lastCoordinate;\n let i = 0;\n let start = initialIndex;\n\n // viewport not inited\n if (!count) {\n return [];\n }\n // loop through array from initial item after recombination\n while (i < count) {\n const item = items[start];\n item.start = pos;\n item.size = size;\n item.end = item.start + size;\n pos = item.end;\n // loop by start index\n start++;\n i++;\n\n // if start index out of array, reset it\n if (start === count) {\n start = 0;\n }\n }\n return items;\n}\n"]}
1
+ {"version":3,"file":"viewport.helpers.js","sourceRoot":"","sources":["../../../src/store/vp/viewport.helpers.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AAanE;;;;GAIG;AACH,MAAM,UAAU,yBAAyB,CACvC,GAAW,EAAE,aAAa;AAC1B,KAAQ,EACR,SAAiB,EACjB,WAAmB,EACnB,SAAgC;IAEhC,MAAM,UAAU,GAAiB,iBAAiB,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;IACnE,MAAM,SAAS,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;IACtC,IAAI,QAAmC,CAAC;IACxC,wEAAwE;IACxE,IAAI,SAAS,EAAE,CAAC;QACd,IAAI,kBAAkB,GAAG,UAAU,CAAC,SAAS,GAAG,CAAC,SAAS,CAAC,SAAS,IAAI,CAAC,CAAC,CAAC;QAC3E,k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EtB,MAAM,KAAK,GAAG,CAAC,GAAG,OAAO,CAAC,CAAC;IAC3B,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC;IAE3B,IAAI,GAAG,GAAG,cAAc,CAAC;IACzB,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,IAAI,KAAK,GAAG,YAAY,CAAC;IAEzB,sBAAsB;IACtB,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,2DAA2D;IAC3D,OAAO,CAAC,GAAG,KAAK,EAAE,CAAC;QACjB,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;QAC1B,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAC7B,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;QACf,sBAAsB;QACtB,KAAK,EAAE,CAAC;QACR,CAAC,EAAE,CAAC;QAEJ,wCAAwC;QACxC,IAAI,KAAK,KAAK,KAAK,EAAE,CAAC;YACpB,KAAK,GAAG,CAAC,CAAC;QACZ,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import {\n DimensionSettingsState,\n PositionItem,\n ViewSettingSizeProp,\n ViewportStateItems,\n VirtualPositionItem,\n Range,\n} from '@type';\n\nimport { getItemByPosition } from '../dimension/dimension.helpers';\n\nexport type DimensionDataViewport = Pick<\n DimensionSettingsState,\n | 'indexes'\n | 'positionIndexes'\n | 'positionIndexToItem'\n | 'sizes'\n | 'originItemSize'\n | 'realSize'\n>;\n\nexport type ItemsToUpdate = Pick<ViewportStateItems, 'items' | 'start' | 'end'>;\n/**\n * Update items based on new scroll position\n * If viewport wasn't changed fully simple recombination of positions\n * Otherwise rebuild viewport items\n */\nexport function getUpdatedItemsByPosition<T extends ItemsToUpdate>(\n pos: number, // coordinate\n items: T,\n realCount: number,\n virtualSize: number,\n dimension: DimensionDataViewport,\n): ItemsToUpdate {\n const activeItem: PositionItem = getItemByPosition(dimension, pos);\n const firstItem = getFirstItem(items);\n let toUpdate: ItemsToUpdate | undefined;\n // do simple position recombination if items already present in viewport\n if (firstItem) {\n let changedOffsetStart = activeItem.itemIndex - (firstItem.itemIndex || 0);\n // if item changed\n if (changedOffsetStart) {\n // simple recombination\n toUpdate = recombineByOffset(Math.abs(changedOffsetStart), {\n positiveDirection: changedOffsetStart > -1,\n ...dimension,\n ...items,\n });\n }\n }\n\n const maxSizeVirtualSize = getMaxVirtualSize(\n virtualSize,\n dimension.realSize,\n activeItem,\n );\n // if partial recombination add items if revo-viewport has some space left\n if (toUpdate) {\n const extra = addMissingItems(\n activeItem,\n realCount,\n maxSizeVirtualSize,\n toUpdate,\n dimension,\n );\n if (extra.length) {\n updateMissingAndRange(toUpdate.items, extra, toUpdate);\n }\n }\n\n // new collection if no items after replacement full replacement\n if (!toUpdate) {\n const items = getItems({\n firstItemStart: activeItem.start,\n firstItemIndex: activeItem.itemIndex,\n origSize: dimension.originItemSize,\n maxSize: maxSizeVirtualSize,\n maxCount: realCount,\n sizes: dimension.sizes,\n });\n\n // range now comes from 0 to length - 1\n toUpdate = {\n items,\n start: 0,\n end: items.length - 1,\n };\n }\n return toUpdate;\n}\n\n// virtual size can differ based on scroll position if some big items are present\n// scroll can be in the middle of item and virtual size will be larger\n// so we need to exclude this part from virtual size hence it's already passed\nfunction getMaxVirtualSize(\n virtualSize: number,\n realSize: number,\n activeItem: PositionItem,\n) {\n return Math.min(virtualSize + (activeItem.end - activeItem.start), realSize);\n}\n\nexport function updateMissingAndRange(\n items: VirtualPositionItem[],\n missing: VirtualPositionItem[],\n range: Range,\n) {\n items.splice(range.end + 1, 0, ...missing);\n // update range if start larger after recombination\n if (\n range.start >= range.end &&\n !(range.start === range.end && range.start === 0)\n ) {\n range.start += missing.length;\n }\n range.end += missing.length;\n}\n\n/**\n * If partial replacement\n * this function adds items if viewport has some space left\n */\nexport function addMissingItems<T extends ItemsToUpdate>(\n firstItem: PositionItem,\n realCount: number,\n virtualSize: number,\n existingCollection: T,\n dimension: Pick<DimensionSettingsState, 'sizes' | 'originItemSize'>,\n): VirtualPositionItem[] {\n const lastItem: VirtualPositionItem = getLastItem(existingCollection);\n const items = getItems({\n sizes: dimension.sizes,\n firstItemStart: lastItem.end,\n firstItemIndex: lastItem.itemIndex + 1,\n origSize: dimension.originItemSize,\n maxSize: virtualSize - (lastItem.end - firstItem.start),\n maxCount: realCount,\n });\n return items;\n}\n\n/**\n * Get wiewport items parameters\n * caching position and calculating items count in viewport\n */\nexport function getItems(\n opt: {\n firstItemIndex: number;\n firstItemStart: number;\n origSize: number;\n maxSize: number; // virtual size\n maxCount: number; // real item count, where the last item\n sizes?: ViewSettingSizeProp;\n },\n currentSize = 0,\n) {\n const items: VirtualPositionItem[] = [];\n\n let index = opt.firstItemIndex;\n let size = currentSize;\n\n // max size or max count\n while (size <= opt.maxSize && index < opt.maxCount) {\n const newSize = getItemSize(index, opt.sizes, opt.origSize);\n items.push({\n start: opt.firstItemStart + size,\n end: opt.firstItemStart + size + newSize,\n itemIndex: index,\n size: newSize,\n });\n size += newSize;\n index++;\n }\n return items;\n}\n\n/**\n * Do batch items recombination\n * If items not overlapped with existing viewport returns null\n */\ntype RecombindDimensionData = Pick<\n DimensionSettingsState,\n 'sizes' | 'realSize' | 'originItemSize'\n>;\ntype RecombineOffsetData = {\n positiveDirection: boolean;\n} & ItemsToUpdate &\n RecombindDimensionData;\nexport function recombineByOffset(\n offset: number,\n data: RecombineOffsetData,\n): ItemsToUpdate | undefined {\n const newItems = [...data.items];\n const itemsCount = newItems.length;\n let newRange = {\n start: data.start,\n end: data.end,\n };\n\n // if offset out of revo-viewport, makes sense whole redraw\n if (offset > itemsCount) {\n return undefined;\n }\n\n // is direction of scroll positive\n if (data.positiveDirection) {\n // push item to the end\n let lastItem: VirtualPositionItem = getLastItem(data);\n\n let i = newRange.start;\n const length = i + offset;\n for (; i < length; i++) {\n const newIndex = lastItem.itemIndex + 1;\n const size = getItemSize(\n newIndex,\n data.sizes,\n data.originItemSize,\n );\n\n // if item overlapped limit break a loop\n if (lastItem.end + size > data.realSize) {\n break;\n }\n\n // new item index to recombine\n let newEnd = i % itemsCount;\n\n // item should always present, we do not create new item, we recombine them\n if (!newItems[newEnd]) {\n throw new Error('incorrect index');\n }\n\n // do recombination\n newItems[newEnd] = lastItem = {\n start: lastItem.end,\n end: lastItem.end + size,\n itemIndex: newIndex,\n size: size,\n };\n // update range\n newRange.start++;\n newRange.end = newEnd;\n }\n\n // direction is negative\n } else {\n // push item to the start\n let firstItem = getFirstItem(data);\n\n const end = newRange.end;\n for (let i = 0; i < offset; i++) {\n const newIndex = (firstItem?.itemIndex ?? 0) - 1;\n const size = getItemSize(\n newIndex,\n data.sizes,\n data.originItemSize,\n );\n\n // new item index to recombine\n let newStart = end - i;\n newStart = (newStart < 0 ? itemsCount + newStart : newStart) % itemsCount;\n\n // item should always present, we do not create new item, we recombine them\n if (!newItems[newStart]) {\n console.error('incorrect index');\n break;\n }\n\n // do recombination\n const firstItemStart = firstItem?.start ?? 0;\n newItems[newStart] = firstItem = {\n start: firstItemStart - size,\n end: firstItemStart,\n itemIndex: newIndex,\n size: size,\n };\n // update range\n newRange.start = newStart;\n newRange.end--;\n }\n }\n const range = {\n start:\n (newRange.start < 0 ? itemsCount + newRange.start : newRange.start) %\n itemsCount,\n end:\n (newRange.end < 0 ? itemsCount + newRange.end : newRange.end) %\n itemsCount,\n };\n return {\n items: newItems,\n ...range,\n };\n}\n\nfunction getItemSize(\n index: number,\n sizes?: ViewSettingSizeProp,\n origSize = 0,\n): number {\n if (sizes && sizes[index]) {\n return sizes[index];\n }\n return origSize;\n}\n\n/**\n * Verify if position is in range of the PositionItem, start and end are included\n */\nexport function isActiveRange(\n pos: number,\n realSize: number,\n first?: PositionItem,\n last?: PositionItem,\n): boolean {\n if (!first || !last) {\n return false;\n }\n // if position is in range of first item\n // or position is after first item and last item is the last item in real size\n return (\n (pos >= first.start && pos <= first.end) ||\n (pos > first.end && last.end === realSize)\n );\n}\n\nexport function isActiveRangeOutsideLastItem(\n pos: number,\n virtualSize: number,\n firstItem?: PositionItem,\n lastItem?: PositionItem,\n) {\n // if no first item, means no items in viewport\n if (!firstItem) {\n return false;\n }\n return virtualSize + pos > (lastItem?.end ?? 0);\n}\n\nexport function getFirstItem(\n s: ItemsToUpdate,\n) {\n return s.items[s.start];\n}\n\nexport function getLastItem(s: ItemsToUpdate): VirtualPositionItem {\n return s.items[s.end];\n}\n\n/**\n * Set items sizes from start index to end\n * @param vpItems\n * @param start\n * @param size\n * @param lastCoordinate\n * @returns\n */\nexport function setItemSizes(\n vpItems: VirtualPositionItem[],\n initialIndex: number,\n size: number,\n lastCoordinate: number,\n) {\n const items = [...vpItems];\n const count = items.length;\n\n let pos = lastCoordinate;\n let i = 0;\n let start = initialIndex;\n\n // viewport not inited\n if (!count) {\n return [];\n }\n // loop through array from initial item after recombination\n while (i < count) {\n const item = items[start];\n item.start = pos;\n item.size = size;\n item.end = item.start + size;\n pos = item.end;\n // loop by start index\n start++;\n i++;\n\n // if start index out of array, reset it\n if (start === count) {\n start = 0;\n }\n }\n return items;\n}\n"]}
@@ -103,7 +103,7 @@ export class ViewportStore {
103
103
  }
104
104
  else if (isActiveRangeOutsideLastItem(pos, virtualSize, firstItem, lastItem)) {
105
105
  const items = [...allItems.items];
106
- // check is any item missing for full fill content
106
+ // check is any item missing for fulfill content
107
107
  const missing = addMissingItems(firstItem, this.store.get('realCount'), virtualSize + pos - firstItem.start, allItems, {
108
108
  sizes: dimension.sizes,
109
109
  originItemSize: dimension.originItemSize,
@@ -1 +1 @@
1
- {"version":3,"file":"viewport.store.js","sourceRoot":"","sources":["../../../src/store/vp/viewport.store.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,eAAe,EACf,YAAY,EACZ,WAAW,EACX,yBAAyB,EACzB,a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C7C,QAAQ,iDACH,QAAQ,KACX,KAAK,EAAE,CAAC,GAAG,KAAK,CAAC,KACd,KAAK,CACT,CAAC;gBACF,IAAI,CAAC,WAAW,mBAAM,QAAQ,EAAG,CAAC;YACpC,CAAC;QACH,CAAC;IACH,CAAC;IAED;;OAEG;IACH,gBAAgB,CAAC,IAAY;QAC3B,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACtC,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC;QAC3B,sBAAsB;QACtB,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,OAAO;QACT,CAAC;QAED,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE;YACnB,KAAK,EAAE,YAAY,CACjB,KAAK,EACL,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,EACvB,IAAI,EACJ,IAAI,CAAC,cAAc,CACpB;SACF,CAAC,CAAC;IACL,CAAC;IAED,QAAQ;QACN,OAAO;YACL,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC;YAC9B,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC;YAC9B,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC;SAC3B,CAAC;IACJ,CAAC;IAED,WAAW,CAAC,IAA4B;QACtC,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IAC7B,CAAC;IAED,UAAU;QACR,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IAC9B,CAAC;CACF","sourcesContent":["import {\n DimensionDataViewport,\n addMissingItems,\n getFirstItem,\n getLastItem,\n getUpdatedItemsByPosition,\n isActiveRange,\n setItemSizes,\n updateMissingAndRange,\n isActiveRangeOutsideLastItem,\n ItemsToUpdate,\n} from './viewport.helpers';\nimport { createStore } from '@stencil/store';\nimport { type Observable, setStore } from '../../utils/store.utils';\nimport type {\n VirtualPositionItem,\n ViewportState,\n MultiDimensionType,\n} from '@type';\n\n/**\n * Viewport store\n * Used for virtualization (process of rendering only visible part of data)\n * Redraws viewport based on position and dimension\n */\nfunction initialState(): ViewportState {\n return {\n // virtual item information per rendered item\n items: [],\n // virtual dom item order to render\n start: 0,\n end: 0,\n\n // size of viewport in px\n virtualSize: 0,\n\n // total number of items\n realCount: 0,\n };\n}\n\n/**\n * Viewport store class\n */\nexport class ViewportStore {\n readonly store: Observable<ViewportState>;\n\n // last coordinate for store position restore\n private lastKnownScroll = 0;\n\n get lastCoordinate() {\n return this.lastKnownScroll;\n }\n set lastCoordinate(value: number) {\n this.lastKnownScroll = value;\n }\n constructor(readonly type: MultiDimensionType) {\n this.store = createStore(initialState());\n // drop items on real size change, require a new item set\n this.store.onChange('realCount', () => this.clearItems());\n // drop items on virtual size change, require a new item set\n this.store.onChange('virtualSize', () => this.clearItems());\n }\n\n /**\n * Render viewport based on coordinate\n * It's the main method for draw\n * Use force if you want to re-render viewport\n */\n setViewPortCoordinate(position: number, dimension: DimensionDataViewport, force = false) {\n const viewportSize = this.store.get('virtualSize');\n // no visible data to calculate\n if (!viewportSize) {\n return;\n }\n\n const frameOffset = 1;\n const singleOffsetInPx = dimension.originItemSize * frameOffset;\n // add offset to virtual size from both sides\n const outsize = singleOffsetInPx * 2;\n // math virtual size is based on visible area + 2 items outside of visible area\n const virtualSize = viewportSize + outsize;\n\n // expected no scroll if real size less than virtual size, position is 0\n let maxCoordinate = 0;\n // if there is nodes outside of viewport, max coordinate has to be adjusted\n if (dimension.realSize > viewportSize) {\n // max coordinate is real size minus virtual/rendered space\n maxCoordinate = dimension.realSize - viewportSize - singleOffsetInPx;\n }\n\n let pos = position;\n // limit position to max and min coordinates\n if (pos < 0) {\n pos = 0;\n } else if (pos > maxCoordinate) {\n pos = maxCoordinate;\n }\n\n // store last coordinate for further restore on redraw\n this.lastCoordinate = pos;\n\n // actual position is less than first item start based on offset\n pos -= singleOffsetInPx;\n pos = pos < 0 ? 0 : pos < maxCoordinate ? pos : maxCoordinate;\n\n let allItems: ItemsToUpdate;\n // if force clear all items and start from 0\n if (force) {\n allItems = {\n items: [],\n start: 0,\n end: 0,\n };\n } else {\n allItems = this.getItems()\n }\n\n const firstItem: VirtualPositionItem | undefined = getFirstItem(allItems);\n const lastItem: VirtualPositionItem | undefined = getLastItem(allItems);\n\n let toUpdate: Partial<ViewportState> = {};\n\n // left position changed\n // verify if new position is in range of previously rendered first item\n if (!isActiveRange(pos, dimension.realSize, firstItem, lastItem)) {\n toUpdate = {\n ...toUpdate,\n ...getUpdatedItemsByPosition(\n pos,\n allItems,\n this.store.get('realCount'),\n virtualSize,\n dimension,\n ),\n };\n this.setViewport({ ...toUpdate });\n // verify is render area is outside of last item\n } else if (\n isActiveRangeOutsideLastItem(pos, virtualSize, firstItem, lastItem)\n ) {\n const items = [...allItems.items];\n // check is any item missing for full fill content\n const missing = addMissingItems(\n firstItem,\n this.store.get('realCount'),\n virtualSize + pos - firstItem.start,\n allItems,\n {\n sizes: dimension.sizes,\n originItemSize: dimension.originItemSize,\n },\n );\n\n // update missing items\n if (missing.length) {\n const range = {\n start: this.store.get('start'),\n end: this.store.get('end'),\n };\n updateMissingAndRange(items, missing, range);\n toUpdate = {\n ...toUpdate,\n items: [...items],\n ...range,\n };\n this.setViewport({ ...toUpdate });\n }\n }\n }\n\n /**\n * Set sizes for existing items\n */\n setOriginalSizes(size: number) {\n const items = this.store.get('items');\n const count = items.length;\n // viewport not inited\n if (!count) {\n return;\n }\n\n setStore(this.store, {\n items: setItemSizes(\n items,\n this.store.get('start'),\n size,\n this.lastCoordinate,\n ),\n });\n }\n\n getItems(): ItemsToUpdate {\n return {\n items: this.store.get('items'),\n start: this.store.get('start'),\n end: this.store.get('end'),\n };\n }\n\n setViewport(data: Partial<ViewportState>) {\n setStore(this.store, data);\n }\n\n clearItems() {\n this.store.set('items', []);\n }\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ionDataViewport,\n addMissingItems,\n getFirstItem,\n getLastItem,\n getUpdatedItemsByPosition,\n isActiveRange,\n setItemSizes,\n updateMissingAndRange,\n isActiveRangeOutsideLastItem,\n ItemsToUpdate,\n} from './viewport.helpers';\nimport { createStore } from '@stencil/store';\nimport { type Observable, setStore } from '../../utils/store.utils';\nimport type {\n VirtualPositionItem,\n ViewportState,\n MultiDimensionType,\n} from '@type';\n\n/**\n * Viewport store\n * Used for virtualization (process of rendering only visible part of data)\n * Redraws viewport based on position and dimension\n */\nfunction initialState(): ViewportState {\n return {\n // virtual item information per rendered item\n items: [],\n // virtual dom item order to render\n start: 0,\n end: 0,\n\n // size of viewport in px\n virtualSize: 0,\n\n // total number of items\n realCount: 0,\n };\n}\n\n/**\n * Viewport store class\n */\nexport class ViewportStore {\n readonly store: Observable<ViewportState>;\n\n // last coordinate for store position restore\n private lastKnownScroll = 0;\n\n get lastCoordinate() {\n return this.lastKnownScroll;\n }\n set lastCoordinate(value: number) {\n this.lastKnownScroll = value;\n }\n constructor(readonly type: MultiDimensionType) {\n this.store = createStore(initialState());\n // drop items on real size change, require a new item set\n this.store.onChange('realCount', () => this.clearItems());\n // drop items on virtual size change, require a new item set\n this.store.onChange('virtualSize', () => this.clearItems());\n }\n\n /**\n * Render viewport based on coordinate\n * It's the main method for draw\n * Use force if you want to re-render viewport\n */\n setViewPortCoordinate(position: number, dimension: DimensionDataViewport, force = false) {\n const viewportSize = this.store.get('virtualSize');\n // no visible data to calculate\n if (!viewportSize) {\n return;\n }\n\n const frameOffset = 1;\n const singleOffsetInPx = dimension.originItemSize * frameOffset;\n // add offset to virtual size from both sides\n const outsize = singleOffsetInPx * 2;\n // math virtual size is based on visible area + 2 items outside of visible area\n const virtualSize = viewportSize + outsize;\n\n // expected no scroll if real size less than virtual size, position is 0\n let maxCoordinate = 0;\n // if there is nodes outside of viewport, max coordinate has to be adjusted\n if (dimension.realSize > viewportSize) {\n // max coordinate is real size minus virtual/rendered space\n maxCoordinate = dimension.realSize - viewportSize - singleOffsetInPx;\n }\n\n let pos = position;\n // limit position to max and min coordinates\n if (pos < 0) {\n pos = 0;\n } else if (pos > maxCoordinate) {\n pos = maxCoordinate;\n }\n\n // store last coordinate for further restore on redraw\n this.lastCoordinate = pos;\n\n // actual position is less than first item start based on offset\n pos -= singleOffsetInPx;\n pos = pos < 0 ? 0 : pos < maxCoordinate ? pos : maxCoordinate;\n\n let allItems: ItemsToUpdate;\n // if force clear all items and start from 0\n if (force) {\n allItems = {\n items: [],\n start: 0,\n end: 0,\n };\n } else {\n allItems = this.getItems()\n }\n\n const firstItem: VirtualPositionItem | undefined = getFirstItem(allItems);\n const lastItem: VirtualPositionItem | undefined = getLastItem(allItems);\n\n let toUpdate: Partial<ViewportState> = {};\n\n // left position changed\n // verify if new position is in range of previously rendered first item\n if (!isActiveRange(pos, dimension.realSize, firstItem, lastItem)) {\n toUpdate = {\n ...toUpdate,\n ...getUpdatedItemsByPosition(\n pos,\n allItems,\n this.store.get('realCount'),\n virtualSize,\n dimension,\n ),\n };\n this.setViewport({ ...toUpdate });\n // verify is render area is outside of last item\n } else if (\n isActiveRangeOutsideLastItem(pos, virtualSize, firstItem, lastItem)\n ) {\n const items = [...allItems.items];\n // check is any item missing for fulfill content\n const missing = addMissingItems(\n firstItem,\n this.store.get('realCount'),\n virtualSize + pos - firstItem.start,\n allItems,\n {\n sizes: dimension.sizes,\n originItemSize: dimension.originItemSize,\n },\n );\n\n // update missing items\n if (missing.length) {\n const range = {\n start: this.store.get('start'),\n end: this.store.get('end'),\n };\n updateMissingAndRange(items, missing, range);\n toUpdate = {\n ...toUpdate,\n items: [...items],\n ...range,\n };\n this.setViewport({ ...toUpdate });\n }\n }\n }\n\n /**\n * Set sizes for existing items\n */\n setOriginalSizes(size: number) {\n const items = this.store.get('items');\n const count = items.length;\n // viewport not inited\n if (!count) {\n return;\n }\n\n setStore(this.store, {\n items: setItemSizes(\n items,\n this.store.get('start'),\n size,\n this.lastCoordinate,\n ),\n });\n }\n\n getItems(): ItemsToUpdate {\n return {\n items: this.store.get('items'),\n start: this.store.get('start'),\n end: this.store.get('end'),\n };\n }\n\n setViewport(data: Partial<ViewportState>) {\n setStore(this.store, data);\n }\n\n clearItems() {\n this.store.set('items', []);\n }\n}\n"]}
@@ -44,7 +44,7 @@ export default class ThemeService {
44
44
  }
45
45
  }
46
46
  static getTheme(theme) {
47
- if (allowedThemes.indexOf(theme) > -1) {
47
+ if (theme && allowedThemes.indexOf(theme) > -1) {
48
48
  return theme;
49
49
  }
50
50
  return DEFAULT_THEME;
@@ -1 +1 @@
1
- {"version":3,"file":"theme.service.js","sourceRoot":"","sources":["../../src/themeManager/theme.service.ts"],"names":[],"mappings":"AACA,OAAO,YAAY,MAAM,iBAAiB,CAAC;AAC3C,OAAO,YAAY,MAAM,iBAAiB,CAAC;AAC3C,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAE7C,MAAM,CAAC,MAAM,aAAa,GAAG,SAAS,CAAC;AAEvC,MAAM,CAAC,MAAM,aAAa,GAAY;IACpC,aAAa;IACb,UAAU;IACV,SAAS;IACT,cAAc;IACd,aAAa;CACd,CAAC;AACF,MAAM,CAAC,OAAO,OAAO,YAAY;IAI/B,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,aAAa,IAAI,IAAI,CAAC,YAAY,CAAC,cAAc,CAAC;IAChE,CAAC;IAED,IAAI,OAAO,CAAC,IAAY;QACtB,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;IAC5B,CAAC;IAED,YAAY,GAAgB;QAdpB,kBAAa,GAAG,CAAC,CAAC;QAexB,IAAI,CAAC,aAAa,GAAG,GAAG,CAAC,OAAO,CAAC;QACjC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;IAC3B,CAAC;IAED,QAAQ,CAAC,KAAY;QACnB,MAAM,WAAW,GAAG,YAAY,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACjD,QAAQ,WAAW,EAAE,CAAC;YACpB,KAAK,UAAU,CAAC;YAChB,KAAK,cAAc;gBACjB,IAAI,CAAC,YAAY,GAAG,IAAI,aAAa,EAAE,CAAC;gBACxC,MAAM;YACR,KAAK,SAAS,CAAC;YACf,KAAK,aAAa;gBAChB,IAAI,CAAC,YAAY,GAAG,IAAI,YAAY,EAAE,CAAC;gBACvC,MAAM;YACR;gBACE,IAAI,CAAC,YAAY,GAAG,IAAI,YAAY,EAAE,CAAC;gBACvC,MAAM;QACV,CAAC;IACH,CAAC;IAED,MAAM,CAAC,QAAQ,CAAC,KAAa;QAC3B,IAAI,aAAa,CAAC,OAAO,CAAC,KAAc,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;YAC/C,OAAO,KAAc,CAAC;QACxB,CAAC;QACD,OAAO,aAAa,CAAC;IACvB,CAAC;CACF","sourcesContent":["import { Theme, ThemeConfig, ThemePackage } from '../types/theme';\nimport ThemeCompact from './theme.compact';\nimport ThemeDefault from './theme.default';\nimport ThemeMaterial from './theme.material';\n\nexport const DEFAULT_THEME = 'default';\n\nexport const allowedThemes: Theme[] = [\n DEFAULT_THEME,\n 'material',\n 'compact',\n 'darkMaterial',\n 'darkCompact',\n];\nexport default class ThemeService {\n private currentTheme: ThemePackage;\n private customRowSize = 0;\n\n get theme() {\n return this.currentTheme;\n }\n\n get rowSize(): number {\n return this.customRowSize || this.currentTheme.defaultRowSize;\n }\n\n set rowSize(size: number) {\n this.customRowSize = size;\n }\n\n constructor(cfg: ThemeConfig) {\n this.customRowSize = cfg.rowSize;\n this.register('default');\n }\n\n register(theme: Theme) {\n const parsedTheme = ThemeService.getTheme(theme);\n switch (parsedTheme) {\n case 'material':\n case 'darkMaterial':\n this.currentTheme = new ThemeMaterial();\n break;\n case 'compact':\n case 'darkCompact':\n this.currentTheme = new ThemeCompact();\n break;\n default:\n this.currentTheme = new ThemeDefault();\n break;\n }\n }\n\n static getTheme(theme: string): Theme {\n if (allowedThemes.indexOf(theme as Theme) > -1) {\n return theme as Theme;\n }\n return DEFAULT_THEME;\n }\n}\n"]}
1
+ {"version":3,"file":"theme.service.js","sourceRoot":"","sources":["../../src/themeManager/theme.service.ts"],"names":[],"mappings":"AACA,OAAO,YAAY,MAAM,iBAAiB,CAAC;AAC3C,OAAO,YAAY,MAAM,iBAAiB,CAAC;AAC3C,OAAO,aAAa,MAAM,kBAAkB,CAAC;AAE7C,MAAM,CAAC,MAAM,aAAa,GAAG,SAAS,CAAC;AAEvC,MAAM,CAAC,MAAM,aAAa,GAAY;IACpC,aAAa;IACb,UAAU;IACV,SAAS;IACT,cAAc;IACd,aAAa;CACd,CAAC;AACF,MAAM,CAAC,OAAO,OAAO,YAAY;IAI/B,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,aAAa,IAAI,IAAI,CAAC,YAAY,CAAC,cAAc,CAAC;IAChE,CAAC;IAED,IAAI,OAAO,CAAC,IAAY;QACtB,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;IAC5B,CAAC;IAED,YAAY,GAAgB;QAdpB,kBAAa,GAAG,CAAC,CAAC;QAexB,IAAI,CAAC,aAAa,GAAG,GAAG,CAAC,OAAO,CAAC;QACjC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;IAC3B,CAAC;IAED,QAAQ,CAAC,KAAY;QACnB,MAAM,WAAW,GAAG,YAAY,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACjD,QAAQ,WAAW,EAAE,CAAC;YACpB,KAAK,UAAU,CAAC;YAChB,KAAK,cAAc;gBACjB,IAAI,CAAC,YAAY,GAAG,IAAI,aAAa,EAAE,CAAC;gBACxC,MAAM;YACR,KAAK,SAAS,CAAC;YACf,KAAK,aAAa;gBAChB,IAAI,CAAC,YAAY,GAAG,IAAI,YAAY,EAAE,CAAC;gBACvC,MAAM;YACR;gBACE,IAAI,CAAC,YAAY,GAAG,IAAI,YAAY,EAAE,CAAC;gBACvC,MAAM;QACV,CAAC;IACH,CAAC;IAED,MAAM,CAAC,QAAQ,CAAC,KAAqB;QACnC,IAAI,KAAK,IAAI,aAAa,CAAC,OAAO,CAAC,KAAc,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;YACxD,OAAO,KAAc,CAAC;QACxB,CAAC;QACD,OAAO,aAAa,CAAC;IACvB,CAAC;CACF","sourcesContent":["import { Theme, ThemeConfig, ThemePackage } from '../types/theme';\nimport ThemeCompact from './theme.compact';\nimport ThemeDefault from './theme.default';\nimport ThemeMaterial from './theme.material';\n\nexport const DEFAULT_THEME = 'default';\n\nexport const allowedThemes: Theme[] = [\n DEFAULT_THEME,\n 'material',\n 'compact',\n 'darkMaterial',\n 'darkCompact',\n];\nexport default class ThemeService {\n private currentTheme: ThemePackage;\n private customRowSize = 0;\n\n get theme() {\n return this.currentTheme;\n }\n\n get rowSize(): number {\n return this.customRowSize || this.currentTheme.defaultRowSize;\n }\n\n set rowSize(size: number) {\n this.customRowSize = size;\n }\n\n constructor(cfg: ThemeConfig) {\n this.customRowSize = cfg.rowSize;\n this.register('default');\n }\n\n register(theme: Theme) {\n const parsedTheme = ThemeService.getTheme(theme);\n switch (parsedTheme) {\n case 'material':\n case 'darkMaterial':\n this.currentTheme = new ThemeMaterial();\n break;\n case 'compact':\n case 'darkCompact':\n this.currentTheme = new ThemeCompact();\n break;\n default:\n this.currentTheme = new ThemeDefault();\n break;\n }\n }\n\n static getTheme(theme?: string | null): Theme {\n if (theme && allowedThemes.indexOf(theme as Theme) > -1) {\n return theme as Theme;\n }\n return DEFAULT_THEME;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../src/types/interfaces.ts"],"names":[],"mappings":"AA2PC,CAAC","sourcesContent":["import type { VNode } from '@stencil/core';\n\nimport {\n DimensionCols,\n DimensionRows,\n DimensionColPin,\n DimensionType,\n MultiDimensionType,\n} from './dimension';\nimport {\n Cell,\n EditorCtr,\n FocusedCells,\n OldNewRangeMapping,\n RangeArea,\n SelectionStoreState,\n} from './selection';\nimport type { Observable } from '../utils/store.utils';\n\n/**\n * Advanced column data schema model.\n * Used for transpassing data to cell renderer and editor.\n */\nexport type ColumnDataSchemaModel = {\n /**\n * Column prop used for mapping value to cell from data source model/row\n */\n prop: ColumnProp;\n /**\n * Row data object\n */\n model: DataType;\n /**\n * Column data object\n */\n column: ColumnRegular;\n /**\n * Index of the row in the viewport\n */\n rowIndex: number;\n /**\n * Index of the column in the viewport\n */\n colIndex: number;\n /**\n * Column type based on viewport\n */\n colType: DimensionCols;\n /**\n * Row type based on viewport\n */\n type: DimensionRows;\n /**\n * Row models based on viewport\n */\n data: DataType[];\n /**\n * Current cell data\n */\n value: any;\n};\n/**\n * Template property for each cell, extends the column data schema model.\n * Additionally, it provides access to the providers injected into the template.\n */\nexport interface CellTemplateProp extends ColumnDataSchemaModel {\n /**\n * Providers injected into the template\n */\n providers: Providers;\n}\n/**\n * The ReadOnlyFormat type is a boolean value or a function that takes ColumnDataSchemaModel\n * as a parameter and returns a boolean value.\n *\n * If it is a boolean value, it represents whether the cell in question is read-only.\n * If it is a function, it returns whether the cell in question is read-only based on the provided\n * ColumnDataSchemaModel.\n */\nexport type ReadOnlyFormat =\n | boolean\n | ((params: ColumnDataSchemaModel) => boolean);\nexport type RowDrag =\n | boolean\n | {\n (params: ColumnDataSchemaModel): boolean;\n };\n/**\n * `ColumnGrouping` type is used to define a grouping in a column.\n */\nexport type ColumnGrouping = {\n /**\n * An array of objects that represent the children of the grouping.\n */\n children: (ColumnGrouping | ColumnRegular)[];\n /**\n * A `DataFormat` object that represents the name of the grouping.\n */\n name: DataFormat;\n};\n/**\n * Configuration for header inner template properties\n */\nexport interface ColumnProperties {\n /**\n * Header inner template\n * Function/component to render custom header content\n */\n columnTemplate?: ColumnTemplateFunc;\n /**\n * Header Cell properties\n * Custom function/component to render header properties\n */\n columnProperties?: ColPropertiesFunc;\n}\n/**\n * Type that represents a collection of column types.\n * The keys are the names of the column types and the values are the corresponding column type objects.\n */\nexport type ColumnTypes = {\n /**\n * The name of the column type.\n */\n [name: string]: ColumnType;\n};\n\n/**\n * Interface for custom cell renderer.\n */\nexport interface CellTemplate {\n // TODO: Add Promise support for template and all custom function so user will be able to use async render on the light speed\n (\n createElement: HyperFunc<VNode>,\n props: CellTemplateProp,\n additionalData?: any,\n ): any;\n}\n/**\n * Interface for regular column definition.\n * Regular column can be any column that is not a grouping column.\n */\nexport interface ColumnType extends ColumnProperties {\n /**\n * Represents whether the column or cell is read-only.\n * Can be a boolean or a function that returns a boolean.\n * The function receives column data as a parameter.\n */\n readonly?: ReadOnlyFormat;\n /**\n * Represents the default column size.\n */\n size?: number;\n /**\n * Represents the minimal column size.\n * This property cannot be less than cell padding\n * in order to keep performance on top and minimize DOM elements number.\n */\n minSize?: number;\n /**\n * Represents the maximum column size.\n */\n maxSize?: number;\n /**\n * Represents a custom editor defined in @editors property.\n * Can be a string or an editor constructor function.\n */\n editor?: string | EditorCtr;\n /**\n * Represents cell properties for custom styling, classes, and events.\n */\n cellProperties?: PropertiesFunc;\n /**\n * Represents the cell template for custom rendering.\n */\n cellTemplate?: CellTemplate;\n /**\n * Represents the cell compare function for custom sorting.\n */\n cellCompare?: CellCompareFunc;\n}\nexport type Order = 'asc' | 'desc' | undefined;\n/**\n * Interface for regular column definition.\n * Regular column can be any column that is not a grouping column.\n * \n */\n/**\n * ColumnRegular interface represents regular column definition.\n * Regular column can be any column that is not a grouping column.\n */\nexport interface ColumnRegular extends ColumnType {\n /**\n * Column prop used for mapping value to cell from data source model/row, used for indexing.\n */\n prop: ColumnProp;\n /**\n * Column pin 'colPinStart'|'colPinEnd'.\n */\n pin?: DimensionColPin;\n /**\n * Column header text.\n */\n name?: DataFormat;\n /**\n * Column size would be changed based on space left.\n */\n autoSize?: boolean;\n /**\n * Filter. Require filter plugin to be installed and activated through grid config @filter.\n */\n filter?: boolean | string | string[];\n /**\n * Is column can be sorted, check @cellCompare function for custom sorting.\n */\n sortable?: boolean;\n /**\n * Sort order.\n */\n order?: Order;\n /**\n * Is cell in column or individual can be dragged.\n */\n rowDrag?: RowDrag;\n /**\n * Represents type defined in @columnTypes property through grid config.\n */\n columnType?: string;\n /**\n * Function called before column applied to the store.\n */\n beforeSetup?(rgCol: ColumnRegular): void;\n /**\n * Additional properties can be added to the column definition.\n */\n [key: string]: any;\n}\n\nexport type ColumnData = (ColumnGrouping | ColumnRegular)[];\n/**\n * Column template property.\n * Contains extended properties for column.\n */\nexport interface ColumnTemplateProp extends ColumnRegular {\n /**\n * Providers injected into the template.\n */\n providers: Providers<DimensionCols | 'rowHeaders'>;\n /**\n * Index of the column, used for mapping value to cell from data source model/row.\n */\n index: number;\n};\n\nexport type ColumnPropProp = ColumnGrouping | ColumnTemplateProp;\n// Column prop used for mapping value to cell from data source model/row, used for indexing.\nexport type ColumnProp = string | number;\n\nexport type DataFormat = any;\n\nexport type CellProp = string | number | object | boolean | undefined;\n\n/**\n * Additional properties applied to the cell.\n * Contains style object where key is CSS property and value is CSS property value.\n * Contains class object where key is CSS class and value is boolean flag indicating if class should be applied.\n * Contains additional properties for custom cell rendering.\n */\nexport type CellProps = {\n // CSS styles applied to the cell\n style?: {\n [key: string]: string | undefined;\n };\n // CSS classes applied to the cell\n class?:\n | {\n // CSS class name\n [key: string]: boolean;\n }\n | string;\n // Additional properties for custom cell rendering\n [attr: string]: CellProp;\n};\n\n/**\n * Providers for grid which are going to be injected into each cell template\n */\nexport type Providers<T = DimensionRows> = {\n /**\n * Dimension type (e.g. row or column)\n */\n type: T;\n /**\n * Flag indicating if grid is in readonly mode\n */\n readonly: boolean;\n /**\n * Data source store\n */\n data: Observable<DataSourceState<any, any>> | ColumnRegular[];\n /**\n * Viewport store\n */\n viewport: Observable<ViewportState>;\n /**\n * Dimension store\n */\n dimension: Observable<DimensionSettingsState>;\n /**\n * Selection store\n */\n selection: Observable<SelectionStoreState>;\n};\n/**\n * `HyperFunc` is a function that takes an HTML tag or component, and returns a\n * JSX element. This function is used to create JSX elements in a context where\n * JSX is not valid.\n */\nexport interface HyperFunc<T> {\n // (tag: any): T;\n (tag: any): T;\n}\n/**\n * `HyperFunc` is a function that takes an HTML tag or component, and returns a\n * JSX element. This function is used to create JSX elements in a context where\n * JSX is not valid.\n */\nexport interface HyperFunc<T> {\n (tag: any, data: any): T;\n}\n/**\n * `HyperFunc` is a function that takes an HTML tag or component, and returns a\n * JSX element. This function is used to create JSX elements in a context where\n * JSX is not valid.\n */\nexport interface HyperFunc<T> {\n (tag: any, text: string): T;\n}\n\n/**\n * `HyperFunc` is a function that takes an HTML tag or component, and returns a\n * JSX element. This function is used to create JSX elements in a context where\n * JSX is not valid.\n */\nexport interface HyperFunc<T> {\n (sel: any, children: Array<T | undefined | null>): T;\n}\n\n/**\n * `HyperFunc` is a function that takes an HTML tag or component, and returns a\n * JSX element. This function is used to create JSX elements in a context where\n * JSX is not valid.\n */\nexport interface HyperFunc<T> {\n (sel: any, data: any, text: string): T;\n}\n\n/**\n * `HyperFunc` is a function that takes an HTML tag or component, and returns a\n * JSX element. This function is used to create JSX elements in a context where\n * JSX is not valid.\n */\nexport interface HyperFunc<T> {\n (sel: any, data: any, children: Array<T | undefined | null>): T;\n}\n\n/**\n * `HyperFunc` is a function that takes an HTML tag or component, and returns a\n * JSX element. This function is used to create JSX elements in a context where\n * JSX is not valid.\n */\nexport interface HyperFunc<T> {\n (sel: any, data: any, children: T): T;\n}\n/**\n * `FocusTemplateFunc` is a function that takes an HTML tag or component, and\n * returns a JSX element. This function is used to create JSX elements in a\n * context where JSX is not valid.\n */\nexport type FocusTemplateFunc = (\n createElement: HyperFunc<VNode>,\n detail: FocusRenderEvent,\n) => any;\n\n\n/**\n * `CellCompareFunc` is a function that takes the column property to compare,\n * the data of the first cell, and the data of the second cell. It returns a\n * number indicating the relative order of the two cells.\n */\nexport type CellCompareFunc = (\n // The column property to compare.\n prop: ColumnProp,\n // The data of the first cell.\n a: DataType,\n // The data of the second cell.\n b: DataType,\n) => number;\nexport type ColumnTemplateFunc = (\n createElement: HyperFunc<VNode>,\n props: ColumnTemplateProp,\n additionalData?: any,\n) => any;\nexport type PropertiesFunc = (\n props: ColumnDataSchemaModel,\n) => CellProps | void | undefined;\nexport type ColPropertiesFunc = (\n props: ColumnPropProp,\n) => CellProps | void | undefined;\nexport type DataType = {\n [T in ColumnProp]: DataFormat;\n};\n\nexport type DataLookup = {\n [rowIndex: number]: DataType;\n};\n/**\n * `RowDefinition` is a type that represents a row definition in the\n * viewport.\n */\nexport type RowDefinition = {\n /**\n * The type of the row.\n */\n type: DimensionRows;\n /**\n * The size of the row.\n */\n size: number;\n /**\n * The index of the row.\n */\n index: number;\n};\nexport interface RowHeaders extends ColumnRegular {}\n/**\n * `ViewPortResizeEvent` is an object that contains information about a resize\n * event in the viewport.\n */\nexport type ViewPortResizeEvent = {\n /* The dimension of the viewport being resized. */\n dimension: DimensionType;\n /* The new size of the viewport. */\n size: number;\n /* Indicates whether the resize event is for a row header. */\n rowHeader?: boolean;\n};\n\n/**\n * `ViewPortScrollEvent` is an object that contains information about a scroll\n * event in the viewport.\n */\nexport type ViewPortScrollEvent = {\n /**\n * The dimension of the viewport being scrolled.\n */\n dimension: DimensionType;\n /**\n * The coordinate of the scroll event.\n */\n coordinate: number;\n /**\n * The change in coordinate between scroll events.\n */\n delta?: number;\n /**\n * Indicates whether the scroll event occurred outside the viewport.\n */\n outside?: boolean;\n};\n\n/**\n * `InitialHeaderClick` represents the information needed to handle a click\n * event on the initial column header.\n */\nexport type InitialHeaderClick = {\n /**\n * The index of the column header that was clicked.\n */\n index: number;\n /**\n * The original mouse event that triggered the click.\n */\n originalEvent: MouseEvent;\n /**\n * The column that was clicked.\n */\n column: ColumnRegular;\n providers: Providers<DimensionCols | 'rowHeaders'>;\n};\n\n/**\n * `Range` is an object that represents a range of values.\n */\nexport type Range = {\n /**\n * The start of the range.\n */\n start: number;\n /**\n * The end of the range.\n */\n end: number;\n};\n\n/**\n * `ViewportStateItems` is an object that represents the items in a viewport\n * along with their corresponding range.\n */\nexport type ViewportStateItems = {\n /**\n * The items in the viewport.\n */\n items: VirtualPositionItem[];\n} & Range;\n\n/**\n * `ViewportState` is an object that represents the state of a viewport.\n */\nexport interface ViewportState extends ViewportStateItems {\n /**\n * The number of real items in the viewport.\n */\n realCount: number;\n /**\n * The virtual size of the viewport.\n */\n virtualSize: number;\n}\n\n/**\n * `ViewSettingSizeProp` is a record that maps column or row indexes to their\n * corresponding sizes.\n */\nexport type ViewSettingSizeProp = Record<string, number>;\n\n/**\n * `VirtualPositionItem` is an object that represents a virtual position item\n * in the viewport.\n */\nexport interface VirtualPositionItem extends PositionItem {\n /**\n * The size of the virtual position item.\n */\n size: number;\n}\nexport type DataSourceState<\n T extends DataType | ColumnRegular,\n ST extends DimensionRows | DimensionCols,\n> = {\n // items - index based array for mapping to source tree\n items: number[];\n // all items, used as proxy for sorting, trimming and others manipulations\n proxyItems: number[];\n // original data source\n source: T[];\n // grouping\n groupingDepth: number;\n groups: Record<any, any>;\n // data source type\n type: ST;\n // trim data, to hide entities from visible data source\n trimmed: Record<any, any>;\n};\nexport interface PositionItem {\n itemIndex: number;\n start: number;\n end: number;\n}\n/**\n * Object containing information about calculated dimensions.\n * Used for both columns and rows.\n */\nexport interface DimensionCalc {\n /**\n * Array of indexes of visible items.\n */\n indexes: number[];\n\n /**\n * Count of visible items.\n */\n count: number;\n\n /**\n * Array of indexes of visible items.\n * Used for mapping items to their position in DOM.\n */\n positionIndexes: number[];\n\n /**\n * Mapping of position to item.\n * Used for mapping position in DOM to item.\n */\n positionIndexToItem: {\n /**\n * Position in DOM.\n */\n [position: number]: PositionItem;\n };\n\n /**\n * Mapping of index to item.\n * Used for mapping index in data source to item.\n */\n indexToItem: {\n /**\n * Index in data source.\n */\n [index: number]: PositionItem;\n };\n\n /**\n * Object containing information about trimmed data.\n * Used for hiding entities from visible data source.\n */\n trimmed: Record<any, any>;\n\n /**\n * Object containing size for each visible item.\n */\n sizes: ViewSettingSizeProp;\n}\n/**\n * Represents the settings state of a dimension.\n * It extends the calculation properties of a dimension.\n * It also includes the real size and origin item size of the dimension.\n */\nexport interface DimensionSettingsState extends DimensionCalc {\n /**\n * Represents the real size of the dimension.\n */\n realSize: number;\n\n /**\n * Represents the origin item size of the dimension.\n */\n originItemSize: number;\n}\n\n/**\n * Represents the mapping of dimension types to their corresponding observable stores.\n */\nexport type DimensionStores = {\n [T in MultiDimensionType]: Observable<DimensionSettingsState>;\n};\n\n/**\n * Represents the mapping of dimension types to their corresponding observable stores for the viewport.\n */\nexport type ViewportStores = {\n [T in MultiDimensionType]: Observable<ViewportState>;\n};\n\n/**\n * Represents the event object that is emitted when the drag operation starts.\n */\nexport interface DragStartEvent {\n /**\n * Represents the original mouse event that triggered the drag operation.\n */\n originalEvent: MouseEvent;\n\n /**\n * Represents the model of the column being dragged.\n */\n model: ColumnDataSchemaModel;\n}\n\n/**\n * Represents the event object that is emitted before cell rendering.\n * It includes information about the dimension type, column, row, and model.\n */\nexport interface BeforeCellRenderEvent<T = any> extends AllDimensionType {\n /**\n * Represents the column being rendered.\n */\n column: VirtualPositionItem;\n\n /**\n * Represents the row being rendered.\n */\n row: VirtualPositionItem;\n\n /**\n * Represents the model being rendered.\n */\n model: T;\n}\n\n/**\n * Represents the event object that is emitted before row rendering.\n * It includes information about the dimension type, data item, item, and node.\n */\nexport interface BeforeRowRenderEvent<T = any> extends AllDimensionType {\n /**\n * Represents the data item being rendered.\n */\n model: T;\n\n /**\n * Represents the item being rendered.\n */\n item: VirtualPositionItem;\n\n /**\n * Represents the node being rendered.\n */\n node: VNode;\n}\n\n/**\n * Represents the event object that is emitted after rendering.\n * It includes information about the dimension type.\n */\nexport type AfterRendererEvent = {\n /**\n * Represents the type of dimension being rendered.\n */\n type: DimensionType;\n};\n\n/**\n * Represents the mapping of dimension types to their corresponding dimension types.\n */\nexport interface AllDimensionType {\n /**\n * Represents the dimension type for rows.\n */\n rowType: DimensionRows;\n\n /**\n * Represents the dimension type for columns.\n */\n colType: DimensionCols;\n}\n\n/**\n * Represents the event object that is emitted when applying focus.\n * It includes information about the dimension type and focused cells.\n */\nexport interface ApplyFocusEvent extends AllDimensionType, FocusedCells {}\n\n/**\n * Represents the event object that is emitted before focus rendering.\n * It includes information about the dimension type and range area.\n */\nexport interface FocusRenderEvent extends AllDimensionType {\n /**\n * Represents the range area of the focus.\n */\n range: RangeArea;\n\n /**\n * Changes for the next cell to focus. @example { y: -1 }\n */\n next?: Partial<Cell>;\n}\n/**\n * Represents the event object that is emitted when scrolling occurs.\n * The `type` property indicates the type of dimension (row or column) being scrolled.\n * The `coordinate` property represents the current scroll position in that dimension.\n */\nexport type ScrollCoordinateEvent = {\n /**\n * Represents the type of dimension being scrolled.\n * Possible values are 'rgRow' and 'rgCol'.\n */\n type: DimensionType;\n\n /**\n * Represents the current scroll position in the specified dimension.\n * The value is a number representing the coordinate in pixels.\n */\n coordinate: number;\n};\n\n\n/** Range paste. */\nexport type RangeClipboardPasteEvent = {\n data: DataLookup;\n models: {\n [rowIndex: number]: DataType;\n };\n range: RangeArea;\n} & AllDimensionType;\n\n/** Range copy. */\nexport type RangeClipboardCopyEventProps = {\n data: DataFormat[][];\n range: RangeArea;\n mapping: OldNewRangeMapping;\n} & AllDimensionType;"]}
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../src/types/interfaces.ts"],"names":[],"mappings":"AA+PC,CAAC","sourcesContent":["import type { VNode } from '@stencil/core';\n\nimport {\n DimensionCols,\n DimensionRows,\n DimensionColPin,\n DimensionType,\n MultiDimensionType,\n} from './dimension';\nimport {\n Cell,\n EditorCtr,\n FocusedCells,\n OldNewRangeMapping,\n RangeArea,\n SelectionStoreState,\n} from './selection';\nimport type { Observable } from '../utils/store.utils';\n\nexport type Nullable<T> = {\n [P in keyof T]: T[P] | null;\n};\n\n/**\n * Advanced column data schema model.\n * Used for transpassing data to cell renderer and editor.\n */\nexport type ColumnDataSchemaModel = {\n /**\n * Column prop used for mapping value to cell from data source model/row\n */\n prop: ColumnProp;\n /**\n * Row data object\n */\n model: DataType;\n /**\n * Column data object\n */\n column: ColumnRegular;\n /**\n * Index of the row in the viewport\n */\n rowIndex: number;\n /**\n * Index of the column in the viewport\n */\n colIndex: number;\n /**\n * Column type based on viewport\n */\n colType: DimensionCols;\n /**\n * Row type based on viewport\n */\n type: DimensionRows;\n /**\n * Row models based on viewport\n */\n data: DataType[];\n /**\n * Current cell data\n */\n value: any;\n};\n/**\n * Template property for each cell, extends the column data schema model.\n * Additionally, it provides access to the providers injected into the template.\n */\nexport interface CellTemplateProp extends ColumnDataSchemaModel {\n /**\n * Providers injected into the template\n */\n providers: Providers;\n}\n/**\n * The ReadOnlyFormat type is a boolean value or a function that takes ColumnDataSchemaModel\n * as a parameter and returns a boolean value.\n *\n * If it is a boolean value, it represents whether the cell in question is read-only.\n * If it is a function, it returns whether the cell in question is read-only based on the provided\n * ColumnDataSchemaModel.\n */\nexport type ReadOnlyFormat =\n | boolean\n | ((params: ColumnDataSchemaModel) => boolean);\nexport type RowDrag =\n | boolean\n | {\n (params: ColumnDataSchemaModel): boolean;\n };\n/**\n * `ColumnGrouping` type is used to define a grouping in a column.\n */\nexport type ColumnGrouping = {\n /**\n * An array of objects that represent the children of the grouping.\n */\n children: (ColumnGrouping | ColumnRegular)[];\n /**\n * A `DataFormat` object that represents the name of the grouping.\n */\n name: DataFormat;\n};\n/**\n * Configuration for header inner template properties\n */\nexport interface ColumnProperties {\n /**\n * Header inner template\n * Function/component to render custom header content\n */\n columnTemplate?: ColumnTemplateFunc;\n /**\n * Header Cell properties\n * Custom function/component to render header properties\n */\n columnProperties?: ColPropertiesFunc;\n}\n/**\n * Type that represents a collection of column types.\n * The keys are the names of the column types and the values are the corresponding column type objects.\n */\nexport type ColumnTypes = {\n /**\n * The name of the column type.\n */\n [name: string]: ColumnType;\n};\n\n/**\n * Interface for custom cell renderer.\n */\nexport interface CellTemplate {\n // TODO: Add Promise support for template and all custom function so user will be able to use async render on the light speed\n (\n createElement: HyperFunc<VNode>,\n props: CellTemplateProp,\n additionalData?: any,\n ): any;\n}\n/**\n * Interface for regular column definition.\n * Regular column can be any column that is not a grouping column.\n */\nexport interface ColumnType extends ColumnProperties {\n /**\n * Represents whether the column or cell is read-only.\n * Can be a boolean or a function that returns a boolean.\n * The function receives column data as a parameter.\n */\n readonly?: ReadOnlyFormat;\n /**\n * Represents the default column size.\n */\n size?: number;\n /**\n * Represents the minimal column size.\n * This property cannot be less than cell padding\n * in order to keep performance on top and minimize DOM elements number.\n */\n minSize?: number;\n /**\n * Represents the maximum column size.\n */\n maxSize?: number;\n /**\n * Represents a custom editor defined in @editors property.\n * Can be a string or an editor constructor function.\n */\n editor?: string | EditorCtr;\n /**\n * Represents cell properties for custom styling, classes, and events.\n */\n cellProperties?: PropertiesFunc;\n /**\n * Represents the cell template for custom rendering.\n */\n cellTemplate?: CellTemplate;\n /**\n * Represents the cell compare function for custom sorting.\n */\n cellCompare?: CellCompareFunc;\n}\nexport type Order = 'asc' | 'desc' | undefined;\n/**\n * Interface for regular column definition.\n * Regular column can be any column that is not a grouping column.\n * \n */\n/**\n * ColumnRegular interface represents regular column definition.\n * Regular column can be any column that is not a grouping column.\n */\nexport interface ColumnRegular extends ColumnType {\n /**\n * Column prop used for mapping value to cell from data source model/row, used for indexing.\n */\n prop: ColumnProp;\n /**\n * Column pin 'colPinStart'|'colPinEnd'.\n */\n pin?: DimensionColPin;\n /**\n * Column header text.\n */\n name?: DataFormat;\n /**\n * Column size would be changed based on space left.\n */\n autoSize?: boolean;\n /**\n * Filter. Require filter plugin to be installed and activated through grid config @filter.\n */\n filter?: boolean | string | string[];\n /**\n * Is column can be sorted, check @cellCompare function for custom sorting.\n */\n sortable?: boolean;\n /**\n * Sort order.\n */\n order?: Order;\n /**\n * Is cell in column or individual can be dragged.\n */\n rowDrag?: RowDrag;\n /**\n * Represents type defined in @columnTypes property through grid config.\n */\n columnType?: string;\n /**\n * Function called before column applied to the store.\n */\n beforeSetup?(rgCol: ColumnRegular): void;\n /**\n * Additional properties can be added to the column definition.\n */\n [key: string]: any;\n}\n\nexport type ColumnData = (ColumnGrouping | ColumnRegular)[];\n/**\n * Column template property.\n * Contains extended properties for column.\n */\nexport interface ColumnTemplateProp extends ColumnRegular {\n /**\n * Providers injected into the template.\n */\n providers: Providers<DimensionCols | 'rowHeaders'>;\n /**\n * Index of the column, used for mapping value to cell from data source model/row.\n */\n index: number;\n};\n\nexport type ColumnPropProp = ColumnGrouping | ColumnTemplateProp;\n// Column prop used for mapping value to cell from data source model/row, used for indexing.\nexport type ColumnProp = string | number;\n\nexport type DataFormat = any;\n\nexport type CellProp = string | number | object | boolean | undefined;\n\n/**\n * Additional properties applied to the cell.\n * Contains style object where key is CSS property and value is CSS property value.\n * Contains class object where key is CSS class and value is boolean flag indicating if class should be applied.\n * Contains additional properties for custom cell rendering.\n */\nexport type CellProps = {\n // CSS styles applied to the cell\n style?: {\n [key: string]: string | undefined;\n };\n // CSS classes applied to the cell\n class?:\n | {\n // CSS class name\n [key: string]: boolean;\n }\n | string;\n // Additional properties for custom cell rendering\n [attr: string]: CellProp;\n};\n\n/**\n * Providers for grid which are going to be injected into each cell template\n */\nexport type Providers<T = DimensionRows> = {\n /**\n * Dimension type (e.g. row or column)\n */\n type: T;\n /**\n * Flag indicating if grid is in readonly mode\n */\n readonly: boolean;\n /**\n * Data source store\n */\n data: Observable<DataSourceState<any, any>> | ColumnRegular[];\n /**\n * Viewport store\n */\n viewport: Observable<ViewportState>;\n /**\n * Dimension store\n */\n dimension: Observable<DimensionSettingsState>;\n /**\n * Selection store\n */\n selection: Observable<SelectionStoreState>;\n};\n/**\n * `HyperFunc` is a function that takes an HTML tag or component, and returns a\n * JSX element. This function is used to create JSX elements in a context where\n * JSX is not valid.\n */\nexport interface HyperFunc<T> {\n // (tag: any): T;\n (tag: any): T;\n}\n/**\n * `HyperFunc` is a function that takes an HTML tag or component, and returns a\n * JSX element. This function is used to create JSX elements in a context where\n * JSX is not valid.\n */\nexport interface HyperFunc<T> {\n (tag: any, data: any): T;\n}\n/**\n * `HyperFunc` is a function that takes an HTML tag or component, and returns a\n * JSX element. This function is used to create JSX elements in a context where\n * JSX is not valid.\n */\nexport interface HyperFunc<T> {\n (tag: any, text: string): T;\n}\n\n/**\n * `HyperFunc` is a function that takes an HTML tag or component, and returns a\n * JSX element. This function is used to create JSX elements in a context where\n * JSX is not valid.\n */\nexport interface HyperFunc<T> {\n (sel: any, children: Array<T | undefined | null>): T;\n}\n\n/**\n * `HyperFunc` is a function that takes an HTML tag or component, and returns a\n * JSX element. This function is used to create JSX elements in a context where\n * JSX is not valid.\n */\nexport interface HyperFunc<T> {\n (sel: any, data: any, text: string): T;\n}\n\n/**\n * `HyperFunc` is a function that takes an HTML tag or component, and returns a\n * JSX element. This function is used to create JSX elements in a context where\n * JSX is not valid.\n */\nexport interface HyperFunc<T> {\n (sel: any, data: any, children: Array<T | undefined | null>): T;\n}\n\n/**\n * `HyperFunc` is a function that takes an HTML tag or component, and returns a\n * JSX element. This function is used to create JSX elements in a context where\n * JSX is not valid.\n */\nexport interface HyperFunc<T> {\n (sel: any, data: any, children: T): T;\n}\n/**\n * `FocusTemplateFunc` is a function that takes an HTML tag or component, and\n * returns a JSX element. This function is used to create JSX elements in a\n * context where JSX is not valid.\n */\nexport type FocusTemplateFunc = (\n createElement: HyperFunc<VNode>,\n detail: FocusRenderEvent,\n) => any;\n\n\n/**\n * `CellCompareFunc` is a function that takes the column property to compare,\n * the data of the first cell, and the data of the second cell. It returns a\n * number indicating the relative order of the two cells.\n */\nexport type CellCompareFunc = (\n // The column property to compare.\n prop: ColumnProp,\n // The data of the first cell.\n a: DataType,\n // The data of the second cell.\n b: DataType,\n) => number;\nexport type ColumnTemplateFunc = (\n createElement: HyperFunc<VNode>,\n props: ColumnTemplateProp,\n additionalData?: any,\n) => any;\nexport type PropertiesFunc = (\n props: ColumnDataSchemaModel,\n) => CellProps | void | undefined;\nexport type ColPropertiesFunc = (\n props: ColumnPropProp,\n) => CellProps | void | undefined;\nexport type DataType = {\n [T in ColumnProp]: DataFormat;\n};\n\nexport type DataLookup = {\n [rowIndex: number]: DataType;\n};\n/**\n * `RowDefinition` is a type that represents a row definition in the\n * viewport.\n */\nexport type RowDefinition = {\n /**\n * The type of the row.\n */\n type: DimensionRows;\n /**\n * The size of the row.\n */\n size: number;\n /**\n * The index of the row.\n */\n index: number;\n};\nexport interface RowHeaders extends ColumnRegular {}\n/**\n * `ViewPortResizeEvent` is an object that contains information about a resize\n * event in the viewport.\n */\nexport type ViewPortResizeEvent = {\n /* The dimension of the viewport being resized. */\n dimension: DimensionType;\n /* The new size of the viewport. */\n size: number;\n /* Indicates whether the resize event is for a row header. */\n rowHeader?: boolean;\n};\n\n/**\n * `ViewPortScrollEvent` is an object that contains information about a scroll\n * event in the viewport.\n */\nexport type ViewPortScrollEvent = {\n /**\n * The dimension of the viewport being scrolled.\n */\n dimension: DimensionType;\n /**\n * The coordinate of the scroll event.\n */\n coordinate: number;\n /**\n * The change in coordinate between scroll events.\n */\n delta?: number;\n /**\n * Indicates whether the scroll event occurred outside the viewport.\n */\n outside?: boolean;\n};\n\n/**\n * `InitialHeaderClick` represents the information needed to handle a click\n * event on the initial column header.\n */\nexport type InitialHeaderClick = {\n /**\n * The index of the column header that was clicked.\n */\n index: number;\n /**\n * The original mouse event that triggered the click.\n */\n originalEvent: MouseEvent;\n /**\n * The column that was clicked.\n */\n column: ColumnRegular;\n providers: Providers<DimensionCols | 'rowHeaders'>;\n};\n\n/**\n * `Range` is an object that represents a range of values.\n */\nexport type Range = {\n /**\n * The start of the range.\n */\n start: number;\n /**\n * The end of the range.\n */\n end: number;\n};\n\n/**\n * `ViewportStateItems` is an object that represents the items in a viewport\n * along with their corresponding range.\n */\nexport type ViewportStateItems = {\n /**\n * The items in the viewport.\n */\n items: VirtualPositionItem[];\n} & Range;\n\n/**\n * `ViewportState` is an object that represents the state of a viewport.\n */\nexport interface ViewportState extends ViewportStateItems {\n /**\n * The number of real items in the viewport.\n */\n realCount: number;\n /**\n * The virtual size of the viewport.\n */\n virtualSize: number;\n}\n\n/**\n * `ViewSettingSizeProp` is a record that maps column or row indexes to their\n * corresponding sizes.\n */\nexport type ViewSettingSizeProp = Record<string, number>;\n\n/**\n * `VirtualPositionItem` is an object that represents a virtual position item\n * in the viewport.\n */\nexport interface VirtualPositionItem extends PositionItem {\n /**\n * The size of the virtual position item.\n */\n size: number;\n}\nexport type DataSourceState<\n T extends DataType | ColumnRegular,\n ST extends DimensionRows | DimensionCols,\n> = {\n // items - index based array for mapping to source tree\n items: number[];\n // all items, used as proxy for sorting, trimming and others manipulations\n proxyItems: number[];\n // original data source\n source: T[];\n // grouping\n groupingDepth: number;\n groups: Record<any, any>;\n // data source type\n type: ST;\n // trim data, to hide entities from visible data source\n trimmed: Record<any, any>;\n};\nexport interface PositionItem {\n itemIndex: number;\n start: number;\n end: number;\n}\n/**\n * Object containing information about calculated dimensions.\n * Used for both columns and rows.\n */\nexport interface DimensionCalc {\n /**\n * Array of indexes of visible items.\n */\n indexes: number[];\n\n /**\n * Count of visible items.\n */\n count: number;\n\n /**\n * Array of indexes of visible items.\n * Used for mapping items to their position in DOM.\n */\n positionIndexes: number[];\n\n /**\n * Mapping of position to item.\n * Used for mapping position in DOM to item.\n */\n positionIndexToItem: {\n /**\n * Position in DOM.\n */\n [position: number]: PositionItem;\n };\n\n /**\n * Mapping of index to item.\n * Used for mapping index in data source to item.\n */\n indexToItem: {\n /**\n * Index in data source.\n */\n [index: number]: PositionItem;\n };\n\n /**\n * Object containing information about trimmed data.\n * Used for hiding entities from visible data source.\n */\n trimmed: Record<any, any>;\n\n /**\n * Object containing size for each visible item.\n */\n sizes: ViewSettingSizeProp;\n}\n/**\n * Represents the settings state of a dimension.\n * It extends the calculation properties of a dimension.\n * It also includes the real size and origin item size of the dimension.\n */\nexport interface DimensionSettingsState extends DimensionCalc {\n /**\n * Represents the real size of the dimension.\n */\n realSize: number;\n\n /**\n * Represents the origin item size of the dimension.\n */\n originItemSize: number;\n}\n\n/**\n * Represents the mapping of dimension types to their corresponding observable stores.\n */\nexport type DimensionStores = {\n [T in MultiDimensionType]: Observable<DimensionSettingsState>;\n};\n\n/**\n * Represents the mapping of dimension types to their corresponding observable stores for the viewport.\n */\nexport type ViewportStores = {\n [T in MultiDimensionType]: Observable<ViewportState>;\n};\n\n/**\n * Represents the event object that is emitted when the drag operation starts.\n */\nexport interface DragStartEvent {\n /**\n * Represents the original mouse event that triggered the drag operation.\n */\n originalEvent: MouseEvent;\n\n /**\n * Represents the model of the column being dragged.\n */\n model: ColumnDataSchemaModel;\n}\n\n/**\n * Represents the event object that is emitted before cell rendering.\n * It includes information about the dimension type, column, row, and model.\n */\nexport interface BeforeCellRenderEvent<T = any> extends AllDimensionType {\n /**\n * Represents the column being rendered.\n */\n column: VirtualPositionItem;\n\n /**\n * Represents the row being rendered.\n */\n row: VirtualPositionItem;\n\n /**\n * Represents the model being rendered.\n */\n model: T;\n}\n\n/**\n * Represents the event object that is emitted before row rendering.\n * It includes information about the dimension type, data item, item, and node.\n */\nexport interface BeforeRowRenderEvent<T = any> extends AllDimensionType {\n /**\n * Represents the data item being rendered.\n */\n model: T;\n\n /**\n * Represents the item being rendered.\n */\n item: VirtualPositionItem;\n\n /**\n * Represents the node being rendered.\n */\n node: VNode;\n}\n\n/**\n * Represents the event object that is emitted after rendering.\n * It includes information about the dimension type.\n */\nexport type AfterRendererEvent = {\n /**\n * Represents the type of dimension being rendered.\n */\n type: DimensionType;\n};\n\n/**\n * Represents the mapping of dimension types to their corresponding dimension types.\n */\nexport interface AllDimensionType {\n /**\n * Represents the dimension type for rows.\n */\n rowType: DimensionRows;\n\n /**\n * Represents the dimension type for columns.\n */\n colType: DimensionCols;\n}\n\n/**\n * Represents the event object that is emitted when applying focus.\n * It includes information about the dimension type and focused cells.\n */\nexport interface ApplyFocusEvent extends AllDimensionType, FocusedCells {}\n\n/**\n * Represents the event object that is emitted before focus rendering.\n * It includes information about the dimension type and range area.\n */\nexport interface FocusRenderEvent extends AllDimensionType {\n /**\n * Represents the range area of the focus.\n */\n range: RangeArea;\n\n /**\n * Changes for the next cell to focus. @example { y: -1 }\n */\n next?: Partial<Cell>;\n}\n/**\n * Represents the event object that is emitted when scrolling occurs.\n * The `type` property indicates the type of dimension (row or column) being scrolled.\n * The `coordinate` property represents the current scroll position in that dimension.\n */\nexport type ScrollCoordinateEvent = {\n /**\n * Represents the type of dimension being scrolled.\n * Possible values are 'rgRow' and 'rgCol'.\n */\n type: DimensionType;\n\n /**\n * Represents the current scroll position in the specified dimension.\n * The value is a number representing the coordinate in pixels.\n */\n coordinate: number;\n};\n\n\n/** Range paste. */\nexport type RangeClipboardPasteEvent = {\n data: DataLookup;\n models: {\n [rowIndex: number]: DataType;\n };\n range: RangeArea | null;\n} & AllDimensionType;\n\n/** Range copy. */\nexport type RangeClipboardCopyEventProps = {\n data: DataFormat[][];\n range: RangeArea;\n mapping: OldNewRangeMapping;\n} & AllDimensionType;"]}
@@ -1 +1 @@
1
- {"version":3,"file":"selection.js","sourceRoot":"","sources":["../../src/types/selection.ts"],"names":[],"mappings":"","sourcesContent":["import { VNode } from '@stencil/core';\nimport { DimensionRows, DimensionCols } from './dimension';\nimport {\n ColumnProp,\n DataType,\n DataLookup,\n HyperFunc,\n ColumnDataSchemaModel,\n} from './interfaces';\n\nexport type RowIndex = number;\nexport type ColIndex = number;\n\n/**\n * Represents the state of the selection store.\n * It contains information about the selection range, temporary range,\n * focused cell, editing cell, last focused cell, and next cell to focus.\n */\nexport type SelectionStoreState = {\n range: RangeArea | null;\n /**\n * Temporary range selection area\n */\n tempRange: RangeArea | null;\n /**\n * Type of the temporary range selection\n */\n tempRangeType: string | null;\n /**\n * Focused cell coordinate\n */\n focus: Cell | null;\n /**\n * Editing cell store\n */\n edit: EditCellStore | null;\n /**\n * Last cell which was focused\n */\n lastCell: Cell | null;\n /**\n * Next cell to focus\n */\n nextFocus: Cell | null;\n};\nexport type RangeArea = {\n x: ColIndex;\n y: RowIndex;\n x1: ColIndex;\n y1: RowIndex;\n};\nexport type TempRange = {\n type: string;\n area: RangeArea;\n};\nexport type OldNewRangeMapping = {\n [rowIndex: number]: {\n [T in ColumnProp]: {\n rowIndex: number;\n colIndex: number;\n colProp: ColumnProp;\n };\n };\n};\nexport type ChangedRange = {\n type: DimensionRows;\n colType: DimensionCols;\n newRange: RangeArea;\n oldRange: RangeArea;\n mapping: OldNewRangeMapping;\n newData: {\n [key: number]: DataType;\n };\n};\n\n/**\n * Cell coordinates\n */\nexport interface Cell {\n x: ColIndex;\n y: RowIndex;\n}\nexport type FocusedCells = {\n focus: Cell;\n end: Cell;\n};\nexport type RangeAreaCss = {\n left: string;\n top: string;\n width: string;\n height: string;\n};\n\nexport type SaveData = string;\nexport type SaveDataDetails = {\n rgRow: RowIndex;\n rgCol: ColIndex;\n type: DimensionRows;\n prop: ColumnProp;\n val: any;\n preventFocus?: boolean;\n};\n\nexport type BeforeEdit = BeforeSaveDataDetails;\n\nexport type BeforeSaveDataDetails = {\n prop: ColumnProp;\n model: DataType;\n val?: SaveData;\n rowIndex: number;\n colIndex: number;\n colType: DimensionCols;\n type: DimensionRows;\n};\nexport type BeforeRangeSaveDataDetails = {\n data: DataLookup;\n models: {\n [rowIndex: number]: DataType;\n };\n type: DimensionRows;\n};\n\nexport type AfterEditEvent = BeforeRangeSaveDataDetails | BeforeSaveDataDetails;\n\n/**\n * Edit cell info for store\n */\nexport interface EditCellStore extends Cell {\n val?: SaveData;\n}\n/**\n * Edit cell info for editor\n */\nexport type EditCell = EditCellStore & BeforeSaveDataDetails;\n\n/**\n * Available editors in grid\n */\nexport type Editors = {\n [name: string]: EditorCtr;\n};\n\n/**\n * Editor component\n */\nexport type EditorCtr = EditorCtrCallable | EditorCtrConstructible;\n\n\n/**\n * Editor component callable function\n */\nexport type EditorCtrCallable = {\n (\n column: ColumnDataSchemaModel,\n save: (value: SaveData, preventFocus?: boolean) => void,\n close: (focusNext?: boolean) => void,\n ): EditorBase;\n}\n/**\n * Editor component constructible class\n */\nexport interface EditorCtrConstructible {\n new (\n column: ColumnDataSchemaModel,\n save: (value: SaveData, preventFocus?: boolean) => void,\n close: (focusNext?: boolean) => void,\n ): EditorBase;\n}\n\n/**\n * Editor interface\n */\nexport interface EditorBase {\n element?: Element | null;\n editCell?: EditCell;\n /**\n * Autosave usage when you want to return value for models.\n */\n getValue?(): any;\n /**\n * For Editor plugin internal usage.\n * Prevents Editor save. Manual save usage required.\n */\n beforeAutoSave?(val?: any): boolean;\n beforeUpdate?(): void;\n /**\n * Before editor got disconnected.\n * Can be triggered multiple times before actual disconnect.\n */\n beforeDisconnect?(): void;\n componentDidRender?(): void;\n disconnectedCallback?(): void;\n render(\n createElement?: HyperFunc<VNode>,\n additionalData?: any,\n ): VNode | VNode[] | string | void;\n}\n"]}
1
+ {"version":3,"file":"selection.js","sourceRoot":"","sources":["../../src/types/selection.ts"],"names":[],"mappings":"","sourcesContent":["import { VNode } from '@stencil/core';\nimport { DimensionRows, DimensionCols } from './dimension';\nimport {\n ColumnProp,\n DataType,\n DataLookup,\n HyperFunc,\n ColumnDataSchemaModel,\n} from './interfaces';\n\nexport type RowIndex = number;\nexport type ColIndex = number;\n\n/**\n * Represents the state of the selection store.\n * It contains information about the selection range, temporary range,\n * focused cell, editing cell, last focused cell, and next cell to focus.\n */\nexport type SelectionStoreState = {\n range: RangeArea | null;\n /**\n * Temporary range selection area\n */\n tempRange: RangeArea | null;\n /**\n * Type of the temporary range selection\n */\n tempRangeType: string | null;\n /**\n * Focused cell coordinate\n */\n focus: Cell | null;\n /**\n * Editing cell store\n */\n edit: EditCellStore | null;\n /**\n * Last cell which was focused\n */\n lastCell: Cell | null;\n /**\n * Next cell to focus\n */\n nextFocus: Cell | null;\n};\nexport type RangeArea = {\n x: ColIndex;\n y: RowIndex;\n x1: ColIndex;\n y1: RowIndex;\n};\nexport type TempRange = {\n type: string;\n area: RangeArea;\n};\nexport type OldNewRangeMapping = {\n [rowIndex: number]: {\n [T in ColumnProp]: {\n rowIndex: number;\n colIndex: number;\n colProp: ColumnProp;\n };\n };\n};\nexport type ChangedRange = {\n type: DimensionRows;\n colType: DimensionCols;\n newRange: RangeArea; // new range to apply\n oldRange: RangeArea; // range to copy from\n mapping: OldNewRangeMapping;\n newData: {\n [key: number]: DataType;\n };\n};\n\n/**\n * Cell coordinates\n */\nexport interface Cell {\n x: ColIndex;\n y: RowIndex;\n}\nexport type FocusedCells = {\n focus: Cell;\n end: Cell;\n};\nexport type RangeAreaCss = {\n left: string;\n top: string;\n width: string;\n height: string;\n};\n\nexport type SaveData = string;\nexport type SaveDataDetails = {\n rgRow: RowIndex;\n rgCol: ColIndex;\n type: DimensionRows;\n prop: ColumnProp;\n val: any;\n preventFocus?: boolean;\n};\n\nexport type BeforeEdit = BeforeSaveDataDetails;\n\nexport type BeforeSaveDataDetails = {\n prop: ColumnProp;\n model: DataType;\n val?: SaveData;\n rowIndex: number;\n colIndex: number;\n colType: DimensionCols;\n type: DimensionRows;\n};\nexport type BeforeRangeSaveDataDetails = {\n data: DataLookup;\n models: {\n [rowIndex: number]: DataType;\n };\n type: DimensionRows;\n};\n\nexport type AfterEditEvent = BeforeRangeSaveDataDetails | BeforeSaveDataDetails;\n\n/**\n * Edit cell info for store\n */\nexport interface EditCellStore extends Cell {\n val?: SaveData;\n}\n/**\n * Edit cell info for editor\n */\nexport type EditCell = EditCellStore & BeforeSaveDataDetails;\n\n/**\n * Available editors in grid\n */\nexport type Editors = {\n [name: string]: EditorCtr;\n};\n\n/**\n * Editor component\n */\nexport type EditorCtr = EditorCtrCallable | EditorCtrConstructible;\n\n\n/**\n * Editor component callable function\n */\nexport type EditorCtrCallable = {\n (\n column: ColumnDataSchemaModel,\n save: (value: SaveData, preventFocus?: boolean) => void,\n close: (focusNext?: boolean) => void,\n ): EditorBase;\n}\n/**\n * Editor component constructible class\n */\nexport interface EditorCtrConstructible {\n new (\n column: ColumnDataSchemaModel,\n save: (value: SaveData, preventFocus?: boolean) => void,\n close: (focusNext?: boolean) => void,\n ): EditorBase;\n}\n\n/**\n * Editor interface\n */\nexport interface EditorBase {\n element?: Element | null;\n editCell?: EditCell;\n /**\n * Autosave usage when you want to return value for models.\n */\n getValue?(): any;\n /**\n * For Editor plugin internal usage.\n * Prevents Editor save. Manual save usage required.\n */\n beforeAutoSave?(val?: any): boolean;\n beforeUpdate?(): void;\n /**\n * Before editor got disconnected.\n * Can be triggered multiple times before actual disconnect.\n */\n beforeDisconnect?(): void;\n componentDidRender?(): void;\n disconnectedCallback?(): void;\n render(\n createElement?: HyperFunc<VNode>,\n additionalData?: any,\n ): VNode | VNode[] | string | void;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"viewport.interfaces.js","sourceRoot":"","sources":["../../src/types/viewport.interfaces.ts"],"names":[],"mappings":"","sourcesContent":["import type { JSXBase } from '@stencil/core/internal';\nimport type {\n DimensionCols,\n ColumnRegular,\n ViewPortScrollEvent,\n ViewportState,\n Cell,\n SelectionStoreState,\n} from '@type';\nimport type {\n DimensionStoreCollection,\n ViewportStoreCollection,\n DSourceState,\n} from '@store';\nimport { Observable } from '../utils/store.utils';\nimport type { RowDataSources } from '../services/data.provider';\nimport type { JSX } from '..';\n\nexport type SlotType = 'content' | 'header' | 'footer';\n\nexport interface ElementScroll {\n changeScroll?(\n e: ViewPortScrollEvent,\n silent?: boolean,\n ): Promise<ViewPortScrollEvent>;\n setScroll?(e: ViewPortScrollEvent): Promise<void>;\n}\nexport type ElementsScroll = { [key: string]: ElementScroll[] };\n\nexport type HeaderProperties = JSX.RevogrHeader;\n\nexport type ViewportProperties = JSX.RevogrViewportScroll &\n JSXBase.HTMLAttributes<HTMLRevogrViewportScrollElement>;\n\nexport type ViewportColumn = {\n colType: DimensionCols;\n position: Cell;\n\n fixWidth?: boolean;\n\n viewports: ViewportStoreCollection;\n dimensions: DimensionStoreCollection;\n\n rowStores: RowDataSources;\n colStore: Observable<DSourceState<ColumnRegular, DimensionCols>>;\n} & Partial<JSX.RevogrViewportScroll> &\n Partial<JSX.RevogrHeader>;\n\nexport type ViewportData = {\n /** Selection connection */\n segmentSelectionStore: Observable<SelectionStoreState>;\n\n /** Slot to put data */\n slot: SlotType;\n style?: { [key: string]: string };\n} & JSX.RevogrOverlaySelection &\n JSX.RevogrData;\n\nexport type ViewportProps = {\n prop: JSX.RevogrViewportScroll &\n JSXBase.HTMLAttributes<HTMLRevogrViewportScrollElement>;\n position: Cell;\n type: DimensionCols;\n /** Cols dataset */\n viewportCol: Observable<ViewportState>;\n\n /** header container props */\n headerProp: HeaderProperties;\n\n /** parent selector link */\n // parent: string;\n\n /** viewport rows */\n dataPorts: ViewportData[];\n\n columnSelectionStore: Observable<SelectionStoreState>;\n};\n"]}
1
+ {"version":3,"file":"viewport.interfaces.js","sourceRoot":"","sources":["../../src/types/viewport.interfaces.ts"],"names":[],"mappings":"","sourcesContent":["import type { JSXBase } from '@stencil/core/internal';\nimport type {\n DimensionCols,\n ColumnRegular,\n ViewPortScrollEvent,\n ViewportState,\n Cell,\n SelectionStoreState,\n} from '@type';\nimport type {\n DimensionStoreCollection,\n ViewportStoreCollection,\n DSourceState,\n} from '@store';\nimport { Observable } from '../utils/store.utils';\nimport type { RowDataSources } from '../services/data.provider';\nimport type { JSX } from '..';\n\nexport type SlotType = 'content' | 'header' | 'footer';\n\nexport interface ElementScroll {\n changeScroll?(\n e: ViewPortScrollEvent,\n silent?: boolean,\n ): Promise<ViewPortScrollEvent | undefined>;\n setScroll?(e: ViewPortScrollEvent): Promise<void>;\n}\nexport type ElementsScroll = { [key: string]: ElementScroll[] };\n\nexport type HeaderProperties = JSX.RevogrHeader;\n\nexport type ViewportProperties = JSX.RevogrViewportScroll &\n JSXBase.HTMLAttributes<HTMLRevogrViewportScrollElement>;\n\nexport type ViewportColumn = {\n colType: DimensionCols;\n position: Cell;\n\n fixWidth?: boolean;\n\n viewports: ViewportStoreCollection;\n dimensions: DimensionStoreCollection;\n\n rowStores: RowDataSources;\n colStore: Observable<DSourceState<ColumnRegular, DimensionCols>>;\n} & Partial<JSX.RevogrViewportScroll> &\n Partial<JSX.RevogrHeader>;\n\nexport type ViewportData = {\n /** Selection connection */\n segmentSelectionStore: Observable<SelectionStoreState>;\n\n /** Slot to put data */\n slot: SlotType;\n style?: { [key: string]: string };\n} & JSX.RevogrOverlaySelection &\n (Pick<JSXBase.HTMLAttributes<HTMLRevogrOverlaySelectionElement>, 'ref'> &\n Pick<JSXBase.HTMLAttributes<HTMLRevogrDataElement>, 'ref'>) &\n JSX.RevogrData;\n\nexport type ViewportProps = {\n prop: JSX.RevogrViewportScroll &\n JSXBase.HTMLAttributes<HTMLRevogrViewportScrollElement>;\n position: Cell;\n type: DimensionCols;\n /** Cols dataset */\n viewportCol: Observable<ViewportState>;\n\n /** header container props */\n headerProp: HeaderProperties;\n\n /** parent selector link */\n // parent: string;\n\n /** viewport rows */\n dataPorts: ViewportData[];\n\n columnSelectionStore: Observable<SelectionStoreState>;\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"closest.polifill.js","sourceRoot":"","sources":["../../src/utils/closest.polifill.ts"],"names":[],"mappings":"AAAA,CAAC,SAAS,OAAO;IACf,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;QAC/B,OAAO,CAAC,SAAS,CAAC,OAAO;YACrB,OAAO,CAAC,SAA+E,CAAC,iBAAiB,IAAI,OAAO,CAAC,SAAS,CAAC,qBAAqB,CAAC;IAC3J,CAAC;IAED,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;QAC/B,OAAO,CAAC,SAAS,CAAC,OAAO,GAAG,UAAU,CAAS;YAC7C,IAAI,EAAE,GAAgD,IAAI,CAAC;YAE3D,GAAG,CAAC;gBACF,IAAI,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC;oBAC1C,OAAO,EAAE,CAAC;gBACZ,CAAC;gBACD,EAAE,GAAG,EAAE,CAAC,aAAa,IAAI,EAAE,CAAC,UAAU,CAAC;YACzC,CAAC,QAAQ,EAAE,KAAK,IAAI,IAAI,EAAE,CAAC,QAAQ,KAAK,CAAC,EAAE;YAC3C,OAAO,IAAI,CAAC;QACd,CAAC,CAAC;IACJ,CAAC;AACH,CAAC,CAAC,EAAE,CAAC","sourcesContent":["(function closest() {\n if (!Element.prototype.matches) {\n Element.prototype.matches =\n ((Element.prototype as unknown) as { msMatchesSelector: (selectors: string) => boolean }).msMatchesSelector || Element.prototype.webkitMatchesSelector;\n }\n\n if (!Element.prototype.closest) {\n Element.prototype.closest = function (s: string) {\n let el: HTMLElement | Element | (Node & ParentNode) = this;\n\n do {\n if (Element.prototype.matches.call(el, s)) {\n return el;\n }\n el = el.parentElement || el.parentNode;\n } while (el !== null && el.nodeType === 1);\n return null;\n };\n }\n})();\n"]}
1
+ {"version":3,"file":"closest.polifill.js","sourceRoot":"","sources":["../../src/utils/closest.polifill.ts"],"names":[],"mappings":"AAAA,CAAC,SAAS,OAAO;IACf,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;QAC/B,OAAO,CAAC,SAAS,CAAC,OAAO;YACrB,OAAO,CAAC,SAA+E,CAAC,iBAAiB,IAAI,OAAO,CAAC,SAAS,CAAC,qBAAqB,CAAC;IAC3J,CAAC;IAED,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;QAC/B,OAAO,CAAC,SAAS,CAAC,OAAO,GAAG,UAAU,CAAS;YAC7C,IAAI,EAAE,GAAuD,IAAI,CAAC;YAElE,GAAG,CAAC;gBACF,IAAI,OAAO,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC;oBAC1C,OAAO,EAAE,CAAC;gBACZ,CAAC;gBACD,EAAE,GAAG,EAAE,CAAC,aAAa,IAAI,EAAE,CAAC,UAAU,CAAC;YACzC,CAAC,QAAQ,EAAE,KAAK,IAAI,IAAI,EAAE,CAAC,QAAQ,KAAK,CAAC,EAAE;YAC3C,OAAO,IAAI,CAAC;QACd,CAAC,CAAC;IACJ,CAAC;AACH,CAAC,CAAC,EAAE,CAAC","sourcesContent":["(function closest() {\n if (!Element.prototype.matches) {\n Element.prototype.matches =\n ((Element.prototype as unknown) as { msMatchesSelector: (selectors: string) => boolean }).msMatchesSelector || Element.prototype.webkitMatchesSelector;\n }\n\n if (!Element.prototype.closest) {\n Element.prototype.closest = function (s: string) {\n let el: HTMLElement | Element | (Node & ParentNode) | null = this;\n\n do {\n if (Element.prototype.matches.call(el, s)) {\n return el;\n }\n el = el.parentElement || el.parentNode;\n } while (el !== null && el.nodeType === 1);\n return null;\n };\n }\n})();\n"]}
@@ -1,10 +1,15 @@
1
1
  /*!
2
2
  * Built by Revolist OU ❤️
3
3
  */
4
- /** Set stores data */
4
+ /**
5
+ * Sets the given data on the specified store.
6
+ *
7
+ * @param store - The store to set data on.
8
+ * @param data - The data to set on the store.
9
+ */
5
10
  export function setStore(store, data) {
6
- for (let key in data) {
7
- store.set(key, data[key]);
8
- }
11
+ Object.entries(data).forEach(([key, value]) => {
12
+ store.set(key, value);
13
+ });
9
14
  }
10
15
  //# sourceMappingURL=store.utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"store.utils.js","sourceRoot":"","sources":["../../src/utils/store.utils.ts"],"names":[],"mappings":"AAMA,sBAAsB;AACtB,MAAM,UAAU,QAAQ,CACtB,KAAoB,EACpB,IAAgB;IAEhB,KAAK,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;QACrB,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAC5B,CAAC;AACH,CAAC","sourcesContent":["\nimport { ObservableMap, Subscription } from './store.types';\n\nexport type Observable<T> = ObservableMap<T>;\nexport type PluginSubscribe<T> = Subscription<T>;\n\n/** Set stores data */\nexport function setStore<T extends { [key: string]: any }>(\n store: Observable<T>,\n data: Partial<T>,\n) {\n for (let key in data) {\n store.set(key, data[key]);\n }\n}\n\n"]}
1
+ {"version":3,"file":"store.utils.js","sourceRoot":"","sources":["../../src/utils/store.utils.ts"],"names":[],"mappings":"AAMA;;;;;GAKG;AACH,MAAM,UAAU,QAAQ,CACtB,KAAuB,EACvB,IAAgB;IAEhB,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE;QAC5C,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IACxB,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["\nimport { ObservableMap, Subscription } from './store.types';\n\nexport type Observable<T> = ObservableMap<T>;\nexport type PluginSubscribe<T> = Subscription<T>;\n\n/**\n * Sets the given data on the specified store.\n *\n * @param store - The store to set data on.\n * @param data - The data to set on the store.\n */\nexport function setStore<T extends Record<string, any>>(\n store: ObservableMap<T>,\n data: Partial<T>,\n): void {\n Object.entries(data).forEach(([key, value]) => {\n store.set(key, value);\n });\n}\n\n"]}
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * Built by Revolist OU ❤️
3
3
  */
4
- import { l as createStore, r as reduce_1, k as setStore, h as calculateDimensionData } from './dimension.helpers-91398565.js';
4
+ import { l as createStore, r as reduce_1, k as setStore, h as calculateDimensionData } from './dimension.helpers-56298828.js';
5
5
  import './toNumber-8de324a7.js';
6
6
  import { h } from './index-a61f225b.js';
7
7
 
@@ -211,4 +211,4 @@ class BasePlugin {
211
211
 
212
212
  export { BasePlugin as B, DimensionStore as D, columnTypes as c, isRowType as i, rowTypes as r };
213
213
 
214
- //# sourceMappingURL=base.plugin-78393655.js.map
214
+ //# sourceMappingURL=base.plugin-5e7a3c51.js.map
@@ -1 +1 @@
1
- {"file":"base.plugin-78393655.js","mappings":";;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C,aAAa,EAAE;YACnC,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;SAChC;KACF;;;;IAKD,OAAO;QACL,IAAI,CAAC,kBAAkB,EAAE,CAAC;KAC3B;;;;;","names":["reduce"],"sources":["src/store/dimension/dimension.store.ts","src/store/index.ts","src/plugins/base.plugin.ts"],"sourcesContent":["/**\n * Storing pre-calculated\n * Dimension information and sizes\n */\nimport reduce from 'lodash/reduce';\nimport { createStore } from '@stencil/store';\n\nimport { setStore, Observable, PluginSubscribe } from '../../utils/store.utils';\nimport { calculateDimensionData } from './dimension.helpers';\nimport {\n DimensionCalc,\n DimensionSettingsState,\n ViewSettingSizeProp,\n MultiDimensionType,\n} from '@type';\n\nexport type DimensionStoreCollection = {\n [T in MultiDimensionType]: DimensionStore;\n};\n\ntype Item = keyof DimensionSettingsState;\n\nconst trimmedPlugin = (\n store: DimensionStore,\n): PluginSubscribe<DimensionSettingsState> => {\n let trimmedSize: DimensionSettingsState['sizes'] = {};\n\n const setTrimmed = (\n sizes: DimensionSettingsState['sizes'],\n trimmed: DimensionSettingsState['trimmed'],\n ) => {\n const newSize: DimensionSettingsState['sizes'] = { ...sizes };\n trimmedSize = {};\n for (const [index, v] of Object.entries(trimmed)) {\n const i = index as keyof DimensionSettingsState['sizes'];\n if (v && newSize[i]) {\n trimmedSize[i] = newSize[i];\n delete newSize[i];\n }\n }\n store.setDimensionSize(newSize);\n };\n return {\n set(key, val) {\n switch (key) {\n case 'trimmed':\n const trim = val as DimensionSettingsState['trimmed'];\n const sizes = store.store.get('sizes');\n // recover trimmed, apply new trim\n setTrimmed({ ...sizes, ...trimmedSize }, trim);\n break;\n }\n },\n };\n};\n\nconst realSizePlugin = (\n store: DimensionStore,\n): PluginSubscribe<DimensionSettingsState> => {\n return {\n set(k) {\n switch (k) {\n case 'count':\n case 'sizes':\n case 'originItemSize':\n let realSize = 0;\n const count = store.store.get('count');\n for (let i = 0; i < count; i++) {\n realSize +=\n store.store.get('sizes')[i] || store.store.get('originItemSize');\n }\n store.setStore({ realSize });\n }\n },\n };\n};\n\nfunction initialBase(): DimensionCalc {\n return {\n indexes: [],\n count: 0,\n\n // plugin support\n trimmed: {},\n\n // size operations, this provider stores only changed sizes, not all of them\n // same as indexes but for sizes and positions\n // item index to size\n sizes: {},\n // order in indexes[] to coordinate\n positionIndexToItem: {},\n // initial element to coordinate ^\n indexToItem: {},\n positionIndexes: [],\n };\n}\n\nfunction initialState(): DimensionSettingsState {\n return {\n ...initialBase(),\n // size which all items can take\n realSize: 0,\n\n // initial item size if it wasn't changed\n originItemSize: 0,\n };\n}\n\nexport class DimensionStore {\n readonly store: Observable<DimensionSettingsState>;\n constructor() {\n this.store = createStore(initialState());\n this.store.use(trimmedPlugin(this));\n this.store.use(realSizePlugin(this));\n }\n\n getCurrentState(): DimensionSettingsState {\n const state = initialState();\n const keys = Object.keys(state);\n return reduce(\n keys,\n (r: DimensionSettingsState, k: Item) => {\n const data = this.store.get(k);\n r[k] = data as never;\n return r;\n },\n state,\n );\n }\n\n dispose() {\n setStore(this.store, initialState());\n }\n\n setStore<T extends Record<string, any>>(data: Partial<T>) {\n setStore(this.store, data);\n }\n\n drop() {\n setStore(this.store, initialBase());\n }\n\n /**\n * Set custom dimension sizes and overwrite old\n * Generates new indexes based on sizes\n * @param sizes - sizes to set\n */\n setDimensionSize(sizes: ViewSettingSizeProp) {\n const dimensionData = calculateDimensionData(\n this.store.get('originItemSize'),\n sizes,\n );\n setStore(this.store, dimensionData);\n }\n}\n","import type { DimensionCols, DimensionRows } from '@type';\n\nexport * from './dataSource';\nexport * from './dimension';\nexport * from './selection';\nexport * from './vp';\n\nexport const rowTypes: DimensionRows[] = ['rowPinStart', 'rgRow', 'rowPinEnd'];\nexport const columnTypes: DimensionCols[] = [\n 'colPinStart',\n 'rgCol',\n 'colPinEnd',\n];\n\nexport function isRowType(type: DimensionRows | any): type is DimensionRows {\n return rowTypes.indexOf(type) > -1;\n}\n","import { h } from '@stencil/core';\nimport { PluginProviders, PluginBaseComponent } from '..';\n\ntype WatchConfig = { immediate: boolean };\n\n/**\n * Base layer for plugins\n * Provide minimal starting core for plugins to work\n * Extend this class to create plugin\n */\nexport class BasePlugin implements PluginBaseComponent {\n readonly h = h;\n readonly subscriptions: Record<string, (...args: any[]) => void> = {};\n constructor(public revogrid: HTMLRevoGridElement, public providers: PluginProviders) {}\n /**\n *\n * @param eventName - event name to subscribe to in revo-grid component (e.g. 'beforeheaderclick')\n * @param callback - callback function for event\n */\n addEventListener(\n eventName: string,\n callback: (e: CustomEvent) => void,\n ) {\n this.revogrid.addEventListener(eventName, callback);\n this.subscriptions[eventName] = callback;\n }\n\n /**\n * Subscribe to property change in revo-grid component\n * You can return false in callback to prevent default value set\n *\n * @param prop - property name\n * @param callback - callback function\n * @param immediate - trigger callback immediately with current value\n */\n watch<T extends any>(\n prop: string,\n callback: (arg: T) => boolean | void,\n { immediate }: Partial<WatchConfig> = { immediate: false },\n ) {\n const nativeValueDesc =\n Object.getOwnPropertyDescriptor(this.revogrid, prop) ||\n Object.getOwnPropertyDescriptor(this.revogrid.constructor.prototype, prop);\n\n // Overwrite property descriptor for this instance\n Object.defineProperty(this.revogrid, prop, {\n set(val: T) {\n const keepDefault = callback(val);\n if (keepDefault === false) {\n return;\n }\n // Continue with native behavior\n return nativeValueDesc?.set?.call(this, val);\n },\n get() {\n // Continue with native behavior\n return nativeValueDesc?.get?.call(this);\n },\n });\n if (immediate) {\n callback(nativeValueDesc?.value);\n }\n }\n\n /**\n * Remove event listener\n * @param eventName\n */\n removeEventListener(eventName: string) {\n this.revogrid.removeEventListener(eventName, this.subscriptions[eventName]);\n delete this.subscriptions[eventName];\n }\n\n /**\n * Emit event from revo-grid component\n * Event can be cancelled by calling event.preventDefault() in callback\n */\n emit<T = any>(eventName: string, detail?: T) {\n const event = new CustomEvent<T>(eventName, { detail, cancelable: true });\n this.revogrid.dispatchEvent(event);\n return event;\n }\n\n /**\n * Clear all subscriptions\n */\n clearSubscriptions() {\n for (let type in this.subscriptions) {\n this.removeEventListener(type);\n }\n }\n\n /**\n * Destroy plugin and clear all subscriptions\n */\n destroy() {\n this.clearSubscriptions();\n }\n}\n\nexport type GridPlugin = (typeof BasePlugin);\n"],"version":3}
1
+ {"file":"base.plugin-5e7a3c51.js","mappings":";;;;;;;AAAA;;;;AAsBA,MAAM,aAAa,GAAG,CACpB,KAAqB;IAErB,IAAI,WAAW,GAAoC,EAAE,CAAC;IAEtD,MAAM,UAAU,GAAG,CACjB,KAAsC,EACtC,OAA0C;QAE1C,MAAM,OAAO,qBAAyC,KAAK,CAAE,CAAC;QAC9D,WAAW,GAAG,EAAE,CAAC;QACjB,KAAK,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;YAChD,MAAM,CAAC,GAAG,KAA8C,CAAC;YACzD,IAAI,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE;gBACnB,WAAW,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;gBAC5B,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC;aACnB;SACF;QACD,KAAK,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;KACjC,CAAC;IACF,OAAO;QACL,GAAG,CAAC,GAAG,EAAE,GAAG;YACV,QAAQ,GAAG;gBACT,KAAK,SAAS;oBACZ,MAAM,IAAI,GAAG,GAAwC,CAAC;oBACtD,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;;oBAEvC,UAAU,iCAAM,KAAK,GAAK,WAAW,GAAI,IAAI,CAAC,CAAC;oBAC/C,MAAM;aACT;SACF;KACF,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,cAAc,GAAG,CACrB,KAAqB;IAErB,OAAO;QACL,GAAG,CAAC,CAAC;YACH,QAAQ,CAAC;gBACP,KAAK,OAAO,CAAC;gBACb,KAAK,OAAO,CAAC;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AAU,EAAE,IAAI,EAAE,CAAC,CAAC;QAC1E,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QACnC,OAAO,KAAK,CAAC;KACd;;;;IAKD,kBAAkB;QAChB,KAAK,IAAI,IAAI,IAAI,IAAI,CAAC,aAAa,EAAE;YACnC,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;SAChC;KACF;;;;IAKD,OAAO;QACL,IAAI,CAAC,kBAAkB,EAAE,CAAC;KAC3B;;;;;","names":["reduce"],"sources":["src/store/dimension/dimension.store.ts","src/store/index.ts","src/plugins/base.plugin.ts"],"sourcesContent":["/**\n * Storing pre-calculated\n * Dimension information and sizes\n */\nimport reduce from 'lodash/reduce';\nimport { createStore } from '@stencil/store';\n\nimport { setStore, Observable, PluginSubscribe } from '../../utils/store.utils';\nimport { calculateDimensionData } from './dimension.helpers';\nimport {\n DimensionCalc,\n DimensionSettingsState,\n ViewSettingSizeProp,\n MultiDimensionType,\n} from '@type';\n\nexport type DimensionStoreCollection = {\n [T in MultiDimensionType]: DimensionStore;\n};\n\ntype Item = keyof DimensionSettingsState;\n\nconst trimmedPlugin = (\n store: DimensionStore,\n): PluginSubscribe<DimensionSettingsState> => {\n let trimmedSize: DimensionSettingsState['sizes'] = {};\n\n const setTrimmed = (\n sizes: DimensionSettingsState['sizes'],\n trimmed: DimensionSettingsState['trimmed'],\n ) => {\n const newSize: DimensionSettingsState['sizes'] = { ...sizes };\n trimmedSize = {};\n for (const [index, v] of Object.entries(trimmed)) {\n const i = index as keyof DimensionSettingsState['sizes'];\n if (v && newSize[i]) {\n trimmedSize[i] = newSize[i];\n delete newSize[i];\n }\n }\n store.setDimensionSize(newSize);\n };\n return {\n set(key, val) {\n switch (key) {\n case 'trimmed':\n const trim = val as DimensionSettingsState['trimmed'];\n const sizes = store.store.get('sizes');\n // recover trimmed, apply new trim\n setTrimmed({ ...sizes, ...trimmedSize }, trim);\n break;\n }\n },\n };\n};\n\nconst realSizePlugin = (\n store: DimensionStore,\n): PluginSubscribe<DimensionSettingsState> => {\n return {\n set(k) {\n switch (k) {\n case 'count':\n case 'sizes':\n case 'originItemSize':\n let realSize = 0;\n const count = store.store.get('count');\n for (let i = 0; i < count; i++) {\n realSize +=\n store.store.get('sizes')[i] || store.store.get('originItemSize');\n }\n store.setStore({ realSize });\n }\n },\n };\n};\n\nfunction initialBase(): DimensionCalc {\n return {\n indexes: [],\n count: 0,\n\n // plugin support\n trimmed: {},\n\n // size operations, this provider stores only changed sizes, not all of them\n // same as indexes but for sizes and positions\n // item index to size\n sizes: {},\n // order in indexes[] to coordinate\n positionIndexToItem: {},\n // initial element to coordinate ^\n indexToItem: {},\n positionIndexes: [],\n };\n}\n\nfunction initialState(): DimensionSettingsState {\n return {\n ...initialBase(),\n // size which all items can take\n realSize: 0,\n\n // initial item size if it wasn't changed\n originItemSize: 0,\n };\n}\n\nexport class DimensionStore {\n readonly store: Observable<DimensionSettingsState>;\n constructor() {\n this.store = createStore(initialState());\n this.store.use(trimmedPlugin(this));\n this.store.use(realSizePlugin(this));\n }\n\n getCurrentState(): DimensionSettingsState {\n const state = initialState();\n const keys = Object.keys(state);\n return reduce(\n keys,\n (r: DimensionSettingsState, k: Item) => {\n const data = this.store.get(k);\n r[k] = data as never;\n return r;\n },\n state,\n );\n }\n\n dispose() {\n setStore(this.store, initialState());\n }\n\n setStore<T extends Record<string, any>>(data: Partial<T>) {\n setStore(this.store, data);\n }\n\n drop() {\n setStore(this.store, initialBase());\n }\n\n /**\n * Set custom dimension sizes and overwrite old\n * Generates new indexes based on sizes\n * @param sizes - sizes to set\n */\n setDimensionSize(sizes: ViewSettingSizeProp) {\n const dimensionData = calculateDimensionData(\n this.store.get('originItemSize'),\n sizes,\n );\n setStore(this.store, dimensionData);\n }\n}\n","import type { DimensionCols, DimensionRows } from '@type';\n\nexport * from './dataSource';\nexport * from './dimension';\nexport * from './selection';\nexport * from './vp';\n\nexport const rowTypes: DimensionRows[] = ['rowPinStart', 'rgRow', 'rowPinEnd'];\nexport const columnTypes: DimensionCols[] = [\n 'colPinStart',\n 'rgCol',\n 'colPinEnd',\n];\n\nexport function isRowType(type: DimensionRows | any): type is DimensionRows {\n return rowTypes.indexOf(type) > -1;\n}\n","import { h } from '@stencil/core';\nimport { PluginProviders, PluginBaseComponent } from '..';\n\ntype WatchConfig = { immediate: boolean };\n\n/**\n * Base layer for plugins\n * Provide minimal starting core for plugins to work\n * Extend this class to create plugin\n */\nexport class BasePlugin implements PluginBaseComponent {\n readonly h = h;\n readonly subscriptions: Record<string, (...args: any[]) => void> = {};\n constructor(public revogrid: HTMLRevoGridElement, public providers: PluginProviders) {}\n /**\n *\n * @param eventName - event name to subscribe to in revo-grid component (e.g. 'beforeheaderclick')\n * @param callback - callback function for event\n */\n addEventListener(\n eventName: string,\n callback: (e: CustomEvent) => void,\n ) {\n this.revogrid.addEventListener(eventName, callback);\n this.subscriptions[eventName] = callback;\n }\n\n /**\n * Subscribe to property change in revo-grid component\n * You can return false in callback to prevent default value set\n *\n * @param prop - property name\n * @param callback - callback function\n * @param immediate - trigger callback immediately with current value\n */\n watch<T extends any>(\n prop: string,\n callback: (arg: T) => boolean | void,\n { immediate }: Partial<WatchConfig> = { immediate: false },\n ) {\n const nativeValueDesc =\n Object.getOwnPropertyDescriptor(this.revogrid, prop) ||\n Object.getOwnPropertyDescriptor(this.revogrid.constructor.prototype, prop);\n\n // Overwrite property descriptor for this instance\n Object.defineProperty(this.revogrid, prop, {\n set(val: T) {\n const keepDefault = callback(val);\n if (keepDefault === false) {\n return;\n }\n // Continue with native behavior\n return nativeValueDesc?.set?.call(this, val);\n },\n get() {\n // Continue with native behavior\n return nativeValueDesc?.get?.call(this);\n },\n });\n if (immediate) {\n callback(nativeValueDesc?.value);\n }\n }\n\n /**\n * Remove event listener\n * @param eventName\n */\n removeEventListener(eventName: string) {\n this.revogrid.removeEventListener(eventName, this.subscriptions[eventName]);\n delete this.subscriptions[eventName];\n }\n\n /**\n * Emit event from revo-grid component\n * Event can be cancelled by calling event.preventDefault() in callback\n */\n emit<T = any>(eventName: string, detail?: T) {\n const event = new CustomEvent<T>(eventName, { detail, cancelable: true });\n this.revogrid.dispatchEvent(event);\n return event;\n }\n\n /**\n * Clear all subscriptions\n */\n clearSubscriptions() {\n for (let type in this.subscriptions) {\n this.removeEventListener(type);\n }\n }\n\n /**\n * Destroy plugin and clear all subscriptions\n */\n destroy() {\n this.clearSubscriptions();\n }\n}\n\nexport type GridPlugin = (typeof BasePlugin);\n"],"version":3}