@revolist/revogrid 4.9.41 → 4.9.42

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 (403) hide show
  1. package/dist/cjs/app-globals-c0b20747.js.map +1 -1
  2. package/dist/cjs/{column.drag.plugin-fcd892ec.js → column.drag.plugin-a6ef25bf.js} +1034 -149
  3. package/dist/cjs/column.drag.plugin-a6ef25bf.js.map +1 -0
  4. package/dist/cjs/column.service-831e1c92.js +1321 -0
  5. package/dist/cjs/column.service-831e1c92.js.map +1 -0
  6. package/dist/cjs/{column.service-26c61ed6.js → dimension.helpers-1927ad24.js} +490 -1273
  7. package/dist/cjs/dimension.helpers-1927ad24.js.map +1 -0
  8. package/dist/cjs/{edit.utils-179c0800.js → edit.utils-e51411f6.js} +3 -3
  9. package/dist/cjs/{edit.utils-179c0800.js.map → edit.utils-e51411f6.js.map} +1 -1
  10. package/dist/cjs/{header-cell-renderer-d879d95e.js → header-cell-renderer-53ecdcdb.js} +2 -2
  11. package/dist/cjs/{header-cell-renderer-d879d95e.js.map → header-cell-renderer-53ecdcdb.js.map} +1 -1
  12. package/dist/cjs/index.cjs.js +127 -69
  13. package/dist/cjs/index.cjs.js.map +1 -1
  14. package/dist/cjs/key.utils-96d0bc42.js +101 -0
  15. package/dist/cjs/key.utils-96d0bc42.js.map +1 -0
  16. package/dist/cjs/loader.cjs.js +1 -1
  17. package/dist/cjs/revo-grid.cjs.entry.js +310 -941
  18. package/dist/cjs/revo-grid.cjs.entry.js.map +1 -1
  19. package/dist/cjs/revo-grid.cjs.js +1 -1
  20. package/dist/cjs/revogr-attribution_7.cjs.entry.js +100 -70
  21. package/dist/cjs/revogr-attribution_7.cjs.entry.js.map +1 -1
  22. package/dist/cjs/revogr-clipboard_3.cjs.entry.js +11 -10
  23. package/dist/cjs/revogr-clipboard_3.cjs.entry.js.map +1 -1
  24. package/dist/cjs/revogr-data_4.cjs.entry.js +88 -78
  25. package/dist/cjs/revogr-data_4.cjs.entry.js.map +1 -1
  26. package/dist/cjs/revogr-filter-panel.cjs.entry.js +33 -13
  27. package/dist/cjs/revogr-filter-panel.cjs.entry.js.map +1 -1
  28. package/dist/cjs/{text-editor-b756d6b3.js → text-editor-1afffaf1.js} +6 -6
  29. package/dist/cjs/text-editor-1afffaf1.js.map +1 -0
  30. package/dist/cjs/{throttle-a57f51f9.js → throttle-bb713c73.js} +4 -4
  31. package/dist/cjs/{throttle-a57f51f9.js.map → throttle-bb713c73.js.map} +1 -1
  32. package/dist/cjs/{row-header-utils-c37f76e4.js → viewport.store-69b45f22.js} +15 -14
  33. package/dist/cjs/viewport.store-69b45f22.js.map +1 -0
  34. package/dist/collection/components/attribution/revogr-attribution.js +1 -1
  35. package/dist/collection/components/attribution/revogr-attribution.js.map +1 -1
  36. package/dist/collection/components/data/cell-renderer.js +11 -9
  37. package/dist/collection/components/data/cell-renderer.js.map +1 -1
  38. package/dist/collection/components/data/column.service.js +7 -19
  39. package/dist/collection/components/data/column.service.js.map +1 -1
  40. package/dist/collection/components/data/revogr-data-style.css +10 -5
  41. package/dist/collection/components/data/revogr-data.js +50 -28
  42. package/dist/collection/components/data/revogr-data.js.map +1 -1
  43. package/dist/collection/components/data/row-highlight.plugin.js.map +1 -1
  44. package/dist/collection/components/data/row-renderer.js.map +1 -1
  45. package/dist/collection/components/editors/revogr-edit-style.css +8 -5
  46. package/dist/collection/components/editors/revogr-edit.js +2 -2
  47. package/dist/collection/components/editors/revogr-edit.js.map +1 -1
  48. package/dist/collection/components/editors/text-editor.js +2 -2
  49. package/dist/collection/components/editors/text-editor.js.map +1 -1
  50. package/dist/collection/components/extra/revogr-extra.js +44 -6
  51. package/dist/collection/components/extra/revogr-extra.js.map +1 -1
  52. package/dist/collection/components/header/header-cell-renderer.js.map +1 -1
  53. package/dist/collection/components/header/header-renderer.js.map +1 -1
  54. package/dist/collection/components/header/resizable.element.js.map +1 -1
  55. package/dist/collection/components/header/revogr-header-style.css +8 -5
  56. package/dist/collection/components/header/revogr-header.js +9 -9
  57. package/dist/collection/components/header/revogr-header.js.map +1 -1
  58. package/dist/collection/components/order/order-renderer.js.map +1 -1
  59. package/dist/collection/components/order/revogr-order-editor.js +12 -24
  60. package/dist/collection/components/order/revogr-order-editor.js.map +1 -1
  61. package/dist/collection/components/overlay/autofill.service.js +7 -5
  62. package/dist/collection/components/overlay/autofill.service.js.map +1 -1
  63. package/dist/collection/components/overlay/keyboard.service.js +1 -4
  64. package/dist/collection/components/overlay/keyboard.service.js.map +1 -1
  65. package/dist/collection/components/overlay/revogr-overlay-selection.js +88 -72
  66. package/dist/collection/components/overlay/revogr-overlay-selection.js.map +1 -1
  67. package/dist/collection/components/overlay/revogr-overlay-style.css +8 -5
  68. package/dist/collection/components/overlay/selection.utils.js.map +1 -1
  69. package/dist/collection/components/revoGrid/plugin.service.js +81 -0
  70. package/dist/collection/components/revoGrid/plugin.service.js.map +1 -0
  71. package/dist/collection/components/revoGrid/revo-grid-style.css +18 -11
  72. package/dist/collection/components/revoGrid/revo-grid.js +289 -140
  73. package/dist/collection/components/revoGrid/revo-grid.js.map +1 -1
  74. package/dist/collection/components/revoGrid/viewport.service.js +9 -9
  75. package/dist/collection/components/revoGrid/viewport.service.js.map +1 -1
  76. package/dist/collection/components/rowHeaders/revogr-row-headers.js +1 -1
  77. package/dist/collection/components/rowHeaders/revogr-row-headers.js.map +1 -1
  78. package/dist/collection/components/rowHeaders/row-header-render.js.map +1 -1
  79. package/dist/collection/components/scroll/revogr-viewport-scroll-style.css +8 -5
  80. package/dist/collection/components/scroll/revogr-viewport-scroll.js +26 -20
  81. package/dist/collection/components/scroll/revogr-viewport-scroll.js.map +1 -1
  82. package/dist/collection/components/scrollable/revogr-scroll-style.css +10 -7
  83. package/dist/collection/components/scrollable/revogr-scroll-virtual.js +10 -8
  84. package/dist/collection/components/scrollable/revogr-scroll-virtual.js.map +1 -1
  85. package/dist/collection/components/selectionFocus/revogr-focus-style.css +8 -5
  86. package/dist/collection/components/selectionFocus/revogr-focus.js +10 -10
  87. package/dist/collection/components/selectionFocus/revogr-focus.js.map +1 -1
  88. package/dist/collection/components/selectionTempRange/revogr-temp-range-style.css +8 -5
  89. package/dist/collection/components/selectionTempRange/revogr-temp-range.js +6 -6
  90. package/dist/collection/components/selectionTempRange/revogr-temp-range.js.map +1 -1
  91. package/dist/collection/components/vnode/vnode-converter.js +1 -1
  92. package/dist/collection/components/vnode/vnode-converter.js.map +1 -1
  93. package/dist/collection/components/vnode/vnode.utils.js.map +1 -1
  94. package/dist/collection/index.js.map +1 -1
  95. package/dist/collection/plugins/add-rows-on-paste.plugin.js +40 -0
  96. package/dist/collection/plugins/add-rows-on-paste.plugin.js.map +1 -0
  97. package/dist/collection/plugins/base.plugin.js.map +1 -1
  98. package/dist/collection/plugins/column.auto-size.plugin.js +1 -1
  99. package/dist/collection/plugins/column.auto-size.plugin.js.map +1 -1
  100. package/dist/collection/plugins/column.stretch.plugin.js +1 -1
  101. package/dist/collection/plugins/column.stretch.plugin.js.map +1 -1
  102. package/dist/collection/plugins/export/csv.js +1 -1
  103. package/dist/collection/plugins/export/csv.js.map +1 -1
  104. package/dist/collection/plugins/export/export.plugin.js +4 -2
  105. package/dist/collection/plugins/export/export.plugin.js.map +1 -1
  106. package/dist/collection/plugins/filter/filter.indexed.js +1 -0
  107. package/dist/collection/plugins/filter/filter.indexed.js.map +1 -1
  108. package/dist/collection/plugins/filter/filter.panel.js +35 -35
  109. package/dist/collection/plugins/filter/filter.panel.js.map +1 -1
  110. package/dist/collection/plugins/filter/filter.plugin.js +117 -77
  111. package/dist/collection/plugins/filter/filter.plugin.js.map +1 -1
  112. package/dist/collection/plugins/filter/filter.style.css +19 -5
  113. package/dist/collection/plugins/filter/filter.types.js.map +1 -1
  114. package/dist/collection/plugins/groupingColumn/columnGroupsRenderer.js.map +1 -1
  115. package/dist/collection/plugins/groupingColumn/headerGroupRenderer.js.map +1 -1
  116. package/dist/collection/plugins/groupingRow/grouping.const.js +1 -0
  117. package/dist/collection/plugins/groupingRow/grouping.const.js.map +1 -1
  118. package/dist/collection/plugins/groupingRow/grouping.row.plugin.js +64 -79
  119. package/dist/collection/plugins/groupingRow/grouping.row.plugin.js.map +1 -1
  120. package/dist/collection/plugins/groupingRow/grouping.row.renderer.js +3 -3
  121. package/dist/collection/plugins/groupingRow/grouping.row.renderer.js.map +1 -1
  122. package/dist/collection/plugins/groupingRow/grouping.row.types.js.map +1 -1
  123. package/dist/collection/plugins/groupingRow/grouping.service.js +40 -6
  124. package/dist/collection/plugins/groupingRow/grouping.service.js.map +1 -1
  125. package/dist/collection/plugins/index.js +2 -0
  126. package/dist/collection/plugins/index.js.map +1 -1
  127. package/dist/collection/plugins/moveColumn/column.drag.plugin.js +12 -6
  128. package/dist/collection/plugins/moveColumn/column.drag.plugin.js.map +1 -1
  129. package/dist/collection/plugins/sorting/sorting.func.js +42 -0
  130. package/dist/collection/plugins/sorting/sorting.func.js.map +1 -0
  131. package/dist/collection/plugins/sorting/sorting.plugin.js +71 -69
  132. package/dist/collection/plugins/sorting/sorting.plugin.js.map +1 -1
  133. package/dist/collection/plugins/sorting/sorting.types.js +2 -0
  134. package/dist/collection/plugins/sorting/sorting.types.js.map +1 -0
  135. package/dist/collection/serve/controller.js +32 -15
  136. package/dist/collection/serve/data.js +18 -11
  137. package/dist/collection/services/column.data.provider.js +5 -2
  138. package/dist/collection/services/column.data.provider.js.map +1 -1
  139. package/dist/collection/services/data.provider.js +18 -7
  140. package/dist/collection/services/data.provider.js.map +1 -1
  141. package/dist/collection/services/dimension.provider.js +32 -33
  142. package/dist/collection/services/dimension.provider.js.map +1 -1
  143. package/dist/collection/services/selection.store.connector.js +1 -1
  144. package/dist/collection/services/selection.store.connector.js.map +1 -1
  145. package/dist/collection/store/dataSource/data.proxy.js +9 -15
  146. package/dist/collection/store/dataSource/data.proxy.js.map +1 -1
  147. package/dist/collection/store/dataSource/data.store.js +1 -1
  148. package/dist/collection/store/dataSource/data.store.js.map +1 -1
  149. package/dist/collection/store/dataSource/trimmed.plugin.js +5 -8
  150. package/dist/collection/store/dataSource/trimmed.plugin.js.map +1 -1
  151. package/dist/collection/store/dimension/dimension.helpers.js +7 -9
  152. package/dist/collection/store/dimension/dimension.helpers.js.map +1 -1
  153. package/dist/collection/store/dimension/dimension.recalculate.plugin.js +35 -0
  154. package/dist/collection/store/dimension/dimension.recalculate.plugin.js.map +1 -0
  155. package/dist/collection/store/dimension/dimension.store.js +47 -67
  156. package/dist/collection/store/dimension/dimension.store.js.map +1 -1
  157. package/dist/collection/store/dimension/dimension.trim.plugin.js +61 -0
  158. package/dist/collection/store/dimension/dimension.trim.plugin.js.map +1 -0
  159. package/dist/collection/store/selection/selection.store.js +1 -1
  160. package/dist/collection/store/selection/selection.store.js.map +1 -1
  161. package/dist/collection/store/vp/viewport.store.js +4 -2
  162. package/dist/collection/store/vp/viewport.store.js.map +1 -1
  163. package/dist/collection/types/events.js +6 -2
  164. package/dist/collection/types/events.js.map +1 -1
  165. package/dist/collection/types/interfaces.js +4 -0
  166. package/dist/collection/types/interfaces.js.map +1 -1
  167. package/dist/collection/types/plugin.types.js.map +1 -1
  168. package/dist/collection/types/selection.js.map +1 -1
  169. package/dist/collection/types/viewport.interfaces.js.map +1 -1
  170. package/dist/collection/utils/column.utils.js +13 -3
  171. package/dist/collection/utils/column.utils.js.map +1 -1
  172. package/dist/esm/app-globals-3a760941.js.map +1 -1
  173. package/dist/esm/{column.drag.plugin-3cc77986.js → column.drag.plugin-50f49fa9.js} +1012 -130
  174. package/dist/esm/column.drag.plugin-50f49fa9.js.map +1 -0
  175. package/dist/esm/column.service-a6a7c415.js +1281 -0
  176. package/dist/esm/column.service-a6a7c415.js.map +1 -0
  177. package/dist/esm/{debounce-72878ced.js → debounce-b3166f78.js} +2 -2
  178. package/dist/esm/{debounce-72878ced.js.map → debounce-b3166f78.js.map} +1 -1
  179. package/dist/esm/{column.service-751345b2.js → dimension.helpers-d0d709c4.js} +450 -1234
  180. package/dist/esm/dimension.helpers-d0d709c4.js.map +1 -0
  181. package/dist/esm/{edit.utils-6fc686b9.js → edit.utils-0ae0db50.js} +2 -2
  182. package/dist/esm/{edit.utils-6fc686b9.js.map → edit.utils-0ae0db50.js.map} +1 -1
  183. package/dist/esm/{header-cell-renderer-32d2ed96.js → header-cell-renderer-36ecbdef.js} +2 -2
  184. package/dist/esm/{header-cell-renderer-32d2ed96.js.map → header-cell-renderer-36ecbdef.js.map} +1 -1
  185. package/dist/esm/index.js +52 -11
  186. package/dist/esm/index.js.map +1 -1
  187. package/dist/esm/{key.utils-17273f42.js → key.utils-7c3218d4.js} +2 -2
  188. package/dist/esm/{key.utils-17273f42.js.map → key.utils-7c3218d4.js.map} +1 -1
  189. package/dist/esm/loader.js +1 -1
  190. package/dist/esm/revo-grid.entry.js +246 -877
  191. package/dist/esm/revo-grid.entry.js.map +1 -1
  192. package/dist/esm/revo-grid.js +1 -1
  193. package/dist/esm/revogr-attribution_7.entry.js +63 -33
  194. package/dist/esm/revogr-attribution_7.entry.js.map +1 -1
  195. package/dist/esm/revogr-clipboard_3.entry.js +7 -6
  196. package/dist/esm/revogr-clipboard_3.entry.js.map +1 -1
  197. package/dist/esm/revogr-data_4.entry.js +60 -50
  198. package/dist/esm/revogr-data_4.entry.js.map +1 -1
  199. package/dist/esm/revogr-filter-panel.entry.js +34 -14
  200. package/dist/esm/revogr-filter-panel.entry.js.map +1 -1
  201. package/dist/esm/{text-editor-901c3eb8.js → text-editor-148a17c1.js} +5 -5
  202. package/dist/esm/text-editor-148a17c1.js.map +1 -0
  203. package/dist/esm/{throttle-138d69c3.js → throttle-394e489c.js} +3 -3
  204. package/dist/esm/{throttle-138d69c3.js.map → throttle-394e489c.js.map} +1 -1
  205. package/dist/esm/{row-header-utils-3dfbb81f.js → viewport.store-afa8c4fe.js} +11 -10
  206. package/dist/esm/viewport.store-afa8c4fe.js.map +1 -0
  207. package/dist/revo-grid/app-globals-3a760941.js +8 -1
  208. package/dist/revo-grid/app-globals-3a760941.js.map +1 -1
  209. package/dist/revo-grid/column.drag.plugin-50f49fa9.js +2541 -0
  210. package/dist/revo-grid/column.drag.plugin-50f49fa9.js.map +1 -0
  211. package/dist/revo-grid/column.service-a6a7c415.js +1281 -0
  212. package/dist/revo-grid/column.service-a6a7c415.js.map +1 -0
  213. package/dist/revo-grid/debounce-b3166f78.js +495 -0
  214. package/dist/revo-grid/debounce-b3166f78.js.map +1 -0
  215. package/dist/revo-grid/dimension.helpers-d0d709c4.js +3611 -0
  216. package/dist/revo-grid/dimension.helpers-d0d709c4.js.map +1 -0
  217. package/dist/revo-grid/edit.utils-0ae0db50.js +17 -0
  218. package/dist/revo-grid/edit.utils-0ae0db50.js.map +1 -0
  219. package/dist/revo-grid/events-cf0893a3.js +38 -1
  220. package/dist/revo-grid/events-cf0893a3.js.map +1 -1
  221. package/dist/revo-grid/filter.button-d40ab17b.js +34 -1
  222. package/dist/revo-grid/filter.button-d40ab17b.js.map +1 -1
  223. package/dist/revo-grid/header-cell-renderer-36ecbdef.js +339 -0
  224. package/dist/revo-grid/header-cell-renderer-36ecbdef.js.map +1 -0
  225. package/dist/revo-grid/index-a61f225b.js +1845 -2
  226. package/dist/revo-grid/index-a61f225b.js.map +1 -1
  227. package/dist/revo-grid/index.esm.js +160 -1
  228. package/dist/revo-grid/index.esm.js.map +1 -1
  229. package/dist/revo-grid/key.utils-7c3218d4.js +89 -0
  230. package/dist/revo-grid/key.utils-7c3218d4.js.map +1 -0
  231. package/dist/revo-grid/resize-observer-83c9e167.js +501 -1
  232. package/dist/revo-grid/resize-observer-83c9e167.js.map +1 -1
  233. package/dist/revo-grid/revo-grid.entry.js +1934 -1
  234. package/dist/revo-grid/revo-grid.entry.js.map +1 -1
  235. package/dist/revo-grid/revo-grid.esm.js +21 -1
  236. package/dist/revo-grid/revo-grid.esm.js.map +1 -1
  237. package/dist/revo-grid/revogr-attribution_7.entry.js +1431 -1
  238. package/dist/revo-grid/revogr-attribution_7.entry.js.map +1 -1
  239. package/dist/revo-grid/revogr-clipboard_3.entry.js +455 -1
  240. package/dist/revo-grid/revogr-clipboard_3.entry.js.map +1 -1
  241. package/dist/revo-grid/revogr-data_4.entry.js +974 -1
  242. package/dist/revo-grid/revogr-data_4.entry.js.map +1 -1
  243. package/dist/revo-grid/revogr-filter-panel.entry.js +340 -1
  244. package/dist/revo-grid/revogr-filter-panel.entry.js.map +1 -1
  245. package/dist/revo-grid/sorting.sign-1a675bf7.js +9 -1
  246. package/dist/revo-grid/sorting.sign-1a675bf7.js.map +1 -1
  247. package/dist/revo-grid/text-editor-148a17c1.js +80 -0
  248. package/dist/revo-grid/text-editor-148a17c1.js.map +1 -0
  249. package/dist/revo-grid/throttle-394e489c.js +230 -0
  250. package/dist/revo-grid/throttle-394e489c.js.map +1 -0
  251. package/dist/revo-grid/viewport.helpers-7e7f9dad.js +48 -1
  252. package/dist/revo-grid/viewport.helpers-7e7f9dad.js.map +1 -1
  253. package/dist/revo-grid/viewport.store-afa8c4fe.js +406 -0
  254. package/dist/revo-grid/viewport.store-afa8c4fe.js.map +1 -0
  255. package/dist/types/components/data/cell-renderer.d.ts +3 -5
  256. package/dist/types/components/data/column.service.d.ts +2 -3
  257. package/dist/types/components/data/revogr-data.d.ts +10 -6
  258. package/dist/types/components/data/row-highlight.plugin.d.ts +1 -1
  259. package/dist/types/components/data/row-renderer.d.ts +1 -1
  260. package/dist/types/components/editors/revogr-edit.d.ts +2 -2
  261. package/dist/types/components/editors/text-editor.d.ts +5 -6
  262. package/dist/types/components/extra/revogr-extra.d.ts +17 -3
  263. package/dist/types/components/header/header-cell-renderer.d.ts +1 -1
  264. package/dist/types/components/header/header-renderer.d.ts +2 -2
  265. package/dist/types/components/header/resizable.element.d.ts +1 -1
  266. package/dist/types/components/header/revogr-header.d.ts +2 -3
  267. package/dist/types/components/order/order-renderer.d.ts +1 -1
  268. package/dist/types/components/order/revogr-order-editor.d.ts +4 -10
  269. package/dist/types/components/overlay/autofill.service.d.ts +2 -2
  270. package/dist/types/components/overlay/keyboard.service.d.ts +1 -1
  271. package/dist/types/components/overlay/revogr-overlay-selection.d.ts +16 -13
  272. package/dist/types/components/overlay/selection.utils.d.ts +1 -1
  273. package/dist/types/components/revoGrid/plugin.service.d.ts +37 -0
  274. package/dist/types/components/revoGrid/revo-grid.d.ts +105 -61
  275. package/dist/types/components/revoGrid/viewport.service.d.ts +2 -2
  276. package/dist/types/components/rowHeaders/row-header-render.d.ts +2 -2
  277. package/dist/types/components/scroll/revogr-viewport-scroll.d.ts +2 -5
  278. package/dist/types/components/scrollable/revogr-scroll-virtual.d.ts +2 -3
  279. package/dist/types/components/selectionFocus/revogr-focus.d.ts +2 -2
  280. package/dist/types/components/selectionTempRange/revogr-temp-range.d.ts +2 -3
  281. package/dist/types/components/vnode/vnode-converter.d.ts +1 -1
  282. package/dist/types/components/vnode/vnode.utils.d.ts +2 -2
  283. package/dist/types/components.d.ts +191 -108
  284. package/dist/types/index.d.ts +1 -1
  285. package/dist/types/plugins/add-rows-on-paste.plugin.d.ts +14 -0
  286. package/dist/types/plugins/base.plugin.d.ts +3 -4
  287. package/dist/types/plugins/column.auto-size.plugin.d.ts +1 -1
  288. package/dist/types/plugins/column.stretch.plugin.d.ts +1 -1
  289. package/dist/types/plugins/export/csv.d.ts +1 -1
  290. package/dist/types/plugins/export/export.plugin.d.ts +4 -3
  291. package/dist/types/plugins/filter/filter.panel.d.ts +2 -2
  292. package/dist/types/plugins/filter/filter.plugin.d.ts +25 -7
  293. package/dist/types/plugins/filter/filter.types.d.ts +32 -10
  294. package/dist/types/plugins/groupingColumn/columnGroupsRenderer.d.ts +2 -2
  295. package/dist/types/plugins/groupingColumn/headerGroupRenderer.d.ts +3 -4
  296. package/dist/types/plugins/groupingRow/grouping.const.d.ts +3 -1
  297. package/dist/types/plugins/groupingRow/grouping.row.plugin.d.ts +15 -10
  298. package/dist/types/plugins/groupingRow/grouping.row.types.d.ts +38 -4
  299. package/dist/types/plugins/groupingRow/grouping.service.d.ts +9 -12
  300. package/dist/types/plugins/index.d.ts +2 -0
  301. package/dist/types/plugins/moveColumn/column.drag.plugin.d.ts +2 -2
  302. package/dist/types/plugins/sorting/sorting.func.d.ts +3 -0
  303. package/dist/types/plugins/sorting/sorting.plugin.d.ts +14 -13
  304. package/dist/types/plugins/sorting/sorting.types.d.ts +13 -0
  305. package/dist/types/services/column.data.provider.d.ts +5 -2
  306. package/dist/types/services/data.provider.d.ts +3 -1
  307. package/dist/types/services/dimension.provider.d.ts +9 -4
  308. package/dist/types/services/selection.store.connector.d.ts +4 -4
  309. package/dist/types/store/dataSource/data.proxy.d.ts +7 -9
  310. package/dist/types/store/dataSource/data.store.d.ts +2 -3
  311. package/dist/types/store/dataSource/trimmed.plugin.d.ts +1 -1
  312. package/dist/types/store/dimension/dimension.helpers.d.ts +1 -4
  313. package/dist/types/store/dimension/dimension.recalculate.plugin.d.ts +9 -0
  314. package/dist/types/store/dimension/dimension.store.d.ts +3 -2
  315. package/dist/types/store/dimension/dimension.trim.plugin.d.ts +13 -0
  316. package/dist/types/store/selection/selection.store.d.ts +1 -1
  317. package/dist/types/store/vp/viewport.store.d.ts +1 -1
  318. package/dist/types/types/events.d.ts +1 -1
  319. package/dist/types/types/interfaces.d.ts +36 -12
  320. package/dist/types/types/plugin.types.d.ts +17 -1
  321. package/dist/types/types/selection.d.ts +23 -17
  322. package/dist/types/types/viewport.interfaces.d.ts +1 -3
  323. package/dist/types/utils/column.utils.d.ts +1 -0
  324. package/hydrate/index.js +2490 -2135
  325. package/hydrate/index.mjs +2490 -2135
  326. package/package.json +20 -19
  327. package/readme.md +15 -17
  328. package/standalone/column.service.js +192 -160
  329. package/standalone/column.service.js.map +1 -1
  330. package/standalone/data.store.js +36 -25
  331. package/standalone/data.store.js.map +1 -1
  332. package/standalone/dimension.helpers.js +8 -10
  333. package/standalone/dimension.helpers.js.map +1 -1
  334. package/standalone/index.js +46 -6
  335. package/standalone/index.js.map +1 -1
  336. package/standalone/revo-grid.js +1275 -1022
  337. package/standalone/revo-grid.js.map +1 -1
  338. package/standalone/revogr-attribution2.js +1 -1
  339. package/standalone/revogr-attribution2.js.map +1 -1
  340. package/standalone/revogr-data2.js +26 -22
  341. package/standalone/revogr-data2.js.map +1 -1
  342. package/standalone/revogr-edit2.js +3 -3
  343. package/standalone/revogr-edit2.js.map +1 -1
  344. package/standalone/revogr-extra2.js +25 -4
  345. package/standalone/revogr-extra2.js.map +1 -1
  346. package/standalone/revogr-filter-panel.js +34 -14
  347. package/standalone/revogr-filter-panel.js.map +1 -1
  348. package/standalone/revogr-focus2.js +2 -1
  349. package/standalone/revogr-focus2.js.map +1 -1
  350. package/standalone/revogr-header2.js +6 -5
  351. package/standalone/revogr-header2.js.map +1 -1
  352. package/standalone/revogr-order-editor2.js +3 -0
  353. package/standalone/revogr-order-editor2.js.map +1 -1
  354. package/standalone/revogr-overlay-selection2.js +29 -17
  355. package/standalone/revogr-overlay-selection2.js.map +1 -1
  356. package/standalone/revogr-row-headers2.js +12 -9
  357. package/standalone/revogr-row-headers2.js.map +1 -1
  358. package/standalone/revogr-scroll-virtual2.js +6 -4
  359. package/standalone/revogr-scroll-virtual2.js.map +1 -1
  360. package/standalone/revogr-temp-range2.js +1 -1
  361. package/standalone/revogr-temp-range2.js.map +1 -1
  362. package/standalone/revogr-viewport-scroll2.js +27 -21
  363. package/standalone/revogr-viewport-scroll2.js.map +1 -1
  364. package/standalone/selection.utils.js +1 -0
  365. package/standalone/selection.utils.js.map +1 -1
  366. package/standalone/vnode-converter.js +1 -1
  367. package/standalone/vnode-converter.js.map +1 -1
  368. package/dist/cjs/column.drag.plugin-fcd892ec.js.map +0 -1
  369. package/dist/cjs/column.service-26c61ed6.js.map +0 -1
  370. package/dist/cjs/index-3ab26ab9.js +0 -513
  371. package/dist/cjs/index-3ab26ab9.js.map +0 -1
  372. package/dist/cjs/key.utils-f49d7bee.js +0 -101
  373. package/dist/cjs/key.utils-f49d7bee.js.map +0 -1
  374. package/dist/cjs/row-header-utils-c37f76e4.js.map +0 -1
  375. package/dist/cjs/text-editor-b756d6b3.js.map +0 -1
  376. package/dist/esm/column.drag.plugin-3cc77986.js.map +0 -1
  377. package/dist/esm/column.service-751345b2.js.map +0 -1
  378. package/dist/esm/index-1dcad6ef.js +0 -476
  379. package/dist/esm/index-1dcad6ef.js.map +0 -1
  380. package/dist/esm/row-header-utils-3dfbb81f.js.map +0 -1
  381. package/dist/esm/text-editor-901c3eb8.js.map +0 -1
  382. package/dist/revo-grid/column.drag.plugin-3cc77986.js +0 -5
  383. package/dist/revo-grid/column.drag.plugin-3cc77986.js.map +0 -1
  384. package/dist/revo-grid/column.service-751345b2.js +0 -5
  385. package/dist/revo-grid/column.service-751345b2.js.map +0 -1
  386. package/dist/revo-grid/debounce-72878ced.js +0 -5
  387. package/dist/revo-grid/debounce-72878ced.js.map +0 -1
  388. package/dist/revo-grid/edit.utils-6fc686b9.js +0 -5
  389. package/dist/revo-grid/edit.utils-6fc686b9.js.map +0 -1
  390. package/dist/revo-grid/header-cell-renderer-32d2ed96.js +0 -5
  391. package/dist/revo-grid/header-cell-renderer-32d2ed96.js.map +0 -1
  392. package/dist/revo-grid/index-1dcad6ef.js +0 -5
  393. package/dist/revo-grid/index-1dcad6ef.js.map +0 -1
  394. package/dist/revo-grid/key.utils-17273f42.js +0 -5
  395. package/dist/revo-grid/key.utils-17273f42.js.map +0 -1
  396. package/dist/revo-grid/row-header-utils-3dfbb81f.js +0 -5
  397. package/dist/revo-grid/row-header-utils-3dfbb81f.js.map +0 -1
  398. package/dist/revo-grid/text-editor-901c3eb8.js +0 -5
  399. package/dist/revo-grid/text-editor-901c3eb8.js.map +0 -1
  400. package/dist/revo-grid/throttle-138d69c3.js +0 -5
  401. package/dist/revo-grid/throttle-138d69c3.js.map +0 -1
  402. package/standalone/identity.js +0 -26
  403. package/standalone/identity.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"selection.store.connector.js","sourceRoot":"","sources":["../../src/services/selection.store.connector.ts"],"names":[],"mappings":"AAAA,OA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Content":["import { cropCellToMax, isHiddenStore, nextCell, SelectionStore } from '@store';\nimport type {\n MultiDimensionType,\n DimensionCols,\n DimensionRows,\n Cell,\n} from '@type';\n\ntype StoreByDimension = Record<number, SelectionStore>;\ntype FocusedStore = {\n entity: SelectionStore;\n cell: Cell;\n position: Cell;\n};\n\ntype StoresMapping<T> = { [xOrY: number]: Partial<T> };\n\nexport const EMPTY_INDEX = -1;\n\nexport default class SelectionStoreConnector {\n // dirty flag required to cleanup whole store in case visibility of panels changed\n private dirty = false;\n readonly stores: { [y: number]: { [x: number]: SelectionStore } } = {};\n\n readonly columnStores: StoreByDimension = {};\n readonly rowStores: { [y: number]: SelectionStore } = {};\n\n /**\n * Helpers for data conversion\n */\n readonly storesByType: Partial<Record<MultiDimensionType, number>> = {};\n readonly storesXToType: StoresMapping<DimensionCols> = {};\n readonly storesYToType: StoresMapping<DimensionRows> = {};\n\n get focusedStore(): FocusedStore | null {\n for (let y in this.stores) {\n for (let x in this.stores[y]) {\n const focused = this.stores[y][x]?.store.get('focus');\n if (focused) {\n return {\n entity: this.stores[y][x],\n cell: focused,\n position: {\n x: parseInt(x, 10),\n y: parseInt(y, 10),\n },\n };\n }\n }\n }\n return null;\n }\n\n get edit() {\n return this.focusedStore?.entity.store.get('edit');\n }\n\n get focused() {\n return this.focusedStore?.entity.store.get('focus');\n }\n\n get selectedRange() {\n return this.focusedStore?.entity.store.get('range');\n }\n\n private readonly sections: Element[] = [];\n\n registerSection(e?: Element) {\n if (!e) {\n this.sections.length = 0;\n // some elements removed, rebuild stores\n this.dirty = true;\n return;\n }\n if (this.sections.indexOf(e) === -1) {\n this.sections.push(e);\n }\n }\n\n // check if require to cleanup all stores\n beforeUpdate() {\n if (this.dirty) {\n for (let y in this.stores) {\n for (let x in this.stores[y]) {\n this.stores[y][x].dispose();\n }\n }\n this.dirty = false;\n }\n }\n\n registerColumn(x: number, type: DimensionCols): SelectionStore {\n // if hidden just create store but no operations needed\n if (isHiddenStore(x)) {\n return new SelectionStore();\n }\n if (this.columnStores[x]) {\n return this.columnStores[x];\n }\n this.columnStores[x] = new SelectionStore();\n // build cross-linking type to position\n this.storesByType[type] = x;\n this.storesXToType[x] = type;\n return this.columnStores[x];\n }\n\n registerRow(y: number, type: DimensionRows): SelectionStore {\n // if hidden just create store\n if (isHiddenStore(y)) {\n return new SelectionStore();\n }\n if (this.rowStores[y]) {\n return this.rowStores[y];\n }\n this.rowStores[y] = new SelectionStore();\n // build cross linking type to position\n this.storesByType[type] = y;\n this.storesYToType[y] = type;\n return this.rowStores[y];\n }\n\n /**\n * Cross store proxy, based on multiple dimensions\n */\n register({ x, y }: Cell): SelectionStore {\n // if hidden just create store\n if (isHiddenStore(x) || isHiddenStore(y)) {\n return new SelectionStore();\n }\n if (!this.stores[y]) {\n this.stores[y] = {};\n }\n if (this.stores[y][x]) {\n // Store already registered. Do not register twice\n return this.stores[y][x];\n }\n this.stores[y][x] = new SelectionStore();\n // proxy update, column store trigger only range area\n this.stores[y][x]?.onChange('range', c => {\n this.columnStores[x].setRangeArea(c);\n this.rowStores[y].setRangeArea(c);\n });\n // clean up on remove\n this.stores[y][x]?.store.on('dispose', () => this.destroy(x, y));\n return this.stores[y][x];\n }\n\n private destroy(x: number, y: number) {\n this.columnStores[x]?.dispose();\n this.rowStores[y]?.dispose();\n\n delete this.rowStores[y];\n delete this.columnStores[x];\n // clear x cross-link\n if (this.storesXToType[x]) {\n const type = this.storesXToType[x];\n delete this.storesXToType[x];\n delete this.storesByType[type];\n }\n // clear y cross-link\n if (this.storesYToType[y]) {\n const type = this.storesYToType[y];\n delete this.storesYToType[y];\n delete this.storesByType[type];\n }\n if (this.stores[y]) {\n delete this.stores[y][x];\n }\n // clear empty rows\n if (!Object.keys(this.stores[y] || {}).length) {\n delete this.stores[y];\n }\n }\n\n setEditByCell<T extends Cell>(storePos: T, editCell: T) {\n this.focusByCell(storePos, editCell, editCell);\n this.setEdit('');\n }\n\n /**\n * Sets the next focus cell before the current one.\n * \n * @param focus - The cell to set as the next focus.\n */\n beforeNextFocusCell(focus: Cell) {\n // If there is no focused store, return early.\n if (!this.focusedStore) {\n return;\n }\n\n // Get the next store based on the current focus and the last cell.\n const lastCell = this.focusedStore.entity.store.get('lastCell');\n const next = lastCell && this.getNextStore(focus, this.focusedStore.position, lastCell);\n\n // Set the next focus cell in the store.\n next?.store?.setNextFocus({ ...focus, ...next.item });\n }\n\n focusByCell<T extends Cell>(storePos: T, start: T, end: T) {\n const store = this.stores[storePos.y][storePos.x];\n this.focus(store, { focus: start, end });\n }\n\n focus(store: SelectionStore, { focus, end }: { focus: Cell; end: Cell }) {\n const currentStorePointer = this.getCurrentStorePointer(store);\n if (!currentStorePointer) {\n return null;\n }\n\n // check for the focus in nearby store/viewport\n const lastCell = store.store.get('lastCell');\n const next = lastCell && this.getNextStore(focus, currentStorePointer, lastCell);\n\n // if next store present - update\n if (next?.store) {\n const item = { ...focus, ...next.item };\n this.focus(next.store, { focus: item, end: item });\n return null;\n }\n\n if (lastCell) {\n focus = cropCellToMax(focus, lastCell);\n end = cropCellToMax(end, lastCell); \n }\n store.setFocus(focus, end);\n return focus;\n }\n\n /**\n * Retrieves the current store pointer based on the active store.\n * Clears focus from all stores except the active one.\n */\n getCurrentStorePointer(store: SelectionStore) {\n let currentStorePointer: Cell | undefined;\n\n // Iterate through all stores\n for (let y in this.stores) {\n for (let x in this.stores[y]) {\n const s = this.stores[y][x];\n\n // Clear focus from stores other than the active one\n if (s !== store) {\n s.clearFocus();\n } else {\n // Update the current store pointer with the active store coordinates\n currentStorePointer = { \n x: parseInt(x, 10), \n y: parseInt(y, 10) \n };\n }\n }\n }\n\n return currentStorePointer;\n }\n\n /**\n * Retrieves the next store based on the focus cell and current store pointer.\n * If the next store exists, returns an object with the next store and the item in the new store.\n * If the next store does not exist, returns null.\n */\n getNextStore(\n focus: Cell,\n currentStorePointer: Cell,\n lastCell: Cell,\n ) {\n // item in new store\n const nextItem: Partial<Cell> | null = nextCell(focus, lastCell);\n\n let nextStore: SelectionStore | undefined;\n if (nextItem) {\n Object.entries(nextItem).forEach(([type, nextItemCoord]: [keyof Cell, number]) => {\n let stores;\n switch (type) {\n case 'x':\n // Get the X stores for the current Y coordinate of the current store pointer\n stores = this.getXStores(currentStorePointer.y);\n break;\n case 'y':\n // Get the Y stores for the current X coordinate of the current store pointer\n stores = this.getYStores(currentStorePointer.x);\n break;\n }\n\n // Get the next store based on the item in the new store\n if (nextItemCoord >= 0) {\n nextStore = stores[++currentStorePointer[type]];\n } else {\n nextStore = stores[--currentStorePointer[type]];\n const nextLastCell = nextStore?.store.get('lastCell');\n if (nextLastCell) {\n nextItem[type] = nextLastCell[type] + nextItemCoord;\n }\n }\n });\n }\n return {\n store: nextStore,\n item: nextItem,\n };\n }\n\n clearAll() {\n for (let y in this.stores) {\n for (let x in this.stores[y]) {\n this.stores[y][x]?.clearFocus();\n }\n }\n }\n\n setEdit(val?: string | boolean) {\n if (!this.focusedStore) {\n return;\n }\n this.focusedStore.entity.setEdit(val);\n }\n\n /**\n * Select all cells across all stores\n */\n selectAll() {\n for (let y in this.stores) {\n for (let x in this.stores[y]) {\n const store = this.stores[y][x];\n if (!store) {\n continue;\n }\n const lastCell = store.store.get('lastCell');\n if (lastCell) {\n store.setRange(\n { x: 0, y: 0 },\n { x: lastCell.x - 1, y: lastCell.y - 1 },\n );\n }\n }\n }\n }\n\n private getXStores(y: number) {\n return this.stores[y];\n }\n\n private getYStores(x: number) {\n const stores: { [p: number]: SelectionStore } = {};\n for (let i in this.stores) {\n stores[i] = this.stores[i][x];\n }\n return stores;\n }\n}\n"]}
1
+ {"version":3,"file":"selection.store.connector.js","sourceRoot":"","sources":["../../src/services/selection.store.connector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAmBhF,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAC,CAAC;AAE9B,MAAM,OAAO,uBAAuB;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;IACxC,CAAC;IAED;;OAEG;IACH,SAAS;QACP,KAAK,IAAI,CAAC,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAC1B,KAAK,IAAI,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;gBAC7B,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBAChC,IAAI,CAAC,KAAK,EAAE,CAAC;oBACX,SAAS;gBACX,CAAC;gBACD,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;gBAC7C,IAAI,QAAQ,EAAE,CAAC;oBACb,KAAK,CAAC,QAAQ,CACZ,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EACd,EAAE,CAAC,EAAE,QAAQ,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,QAAQ,CAAC,CAAC,GAAG,CAAC,EAAE,CACzC,CAAC;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAEO,UAAU,CAAC,CAAS;QAC1B,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IACxB,CAAC;IAEO,UAAU,CAAC,CAAS;QAC1B,MAAM,MAAM,GAAoC,EAAE,CAAC;QACnD,KAAK,IAAI,CAAC,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAC1B,MAAM,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAChC,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF","sourcesContent":["import { cropCellToMax, isHiddenStore, nextCell, SelectionStore } from '@store';\nimport type {\n MultiDimensionType,\n DimensionCols,\n DimensionRows,\n Cell,\n EditCellStore,\n RangeArea,\n} from '@type';\n\ntype StoreByDimension = Record<number, SelectionStore>;\ntype FocusedStore = {\n entity: SelectionStore;\n cell: Cell;\n position: Cell;\n};\n\ntype StoresMapping<T> = { [xOrY: number]: Partial<T> };\n\nexport const EMPTY_INDEX = -1;\n\nexport class SelectionStoreConnector {\n // dirty flag required to cleanup whole store in case visibility of panels changed\n private dirty = false;\n readonly stores: { [y: number]: { [x: number]: SelectionStore } } = {};\n\n readonly columnStores: StoreByDimension = {};\n readonly rowStores: { [y: number]: SelectionStore } = {};\n\n /**\n * Helpers for data conversion\n */\n readonly storesByType: Partial<Record<MultiDimensionType, number>> = {};\n readonly storesXToType: StoresMapping<DimensionCols> = {};\n readonly storesYToType: StoresMapping<DimensionRows> = {};\n\n get focusedStore(): FocusedStore | null {\n for (let y in this.stores) {\n for (let x in this.stores[y]) {\n const focused = this.stores[y][x]?.store.get('focus');\n if (focused) {\n return {\n entity: this.stores[y][x],\n cell: focused,\n position: {\n x: parseInt(x, 10),\n y: parseInt(y, 10),\n },\n };\n }\n }\n }\n return null;\n }\n\n get edit(): EditCellStore | null | undefined {\n return this.focusedStore?.entity.store.get('edit');\n }\n\n get focused(): Cell | null | undefined {\n return this.focusedStore?.entity.store.get('focus');\n }\n\n get selectedRange(): RangeArea | null | undefined {\n return this.focusedStore?.entity.store.get('range');\n }\n\n private readonly sections: Element[] = [];\n\n registerSection(e?: Element) {\n if (!e) {\n this.sections.length = 0;\n // some elements removed, rebuild stores\n this.dirty = true;\n return;\n }\n if (this.sections.indexOf(e) === -1) {\n this.sections.push(e);\n }\n }\n\n // check if require to cleanup all stores\n beforeUpdate() {\n if (this.dirty) {\n for (let y in this.stores) {\n for (let x in this.stores[y]) {\n this.stores[y][x].dispose();\n }\n }\n this.dirty = false;\n }\n }\n\n registerColumn(x: number, type: DimensionCols): SelectionStore {\n // if hidden just create store but no operations needed\n if (isHiddenStore(x)) {\n return new SelectionStore();\n }\n if (this.columnStores[x]) {\n return this.columnStores[x];\n }\n this.columnStores[x] = new SelectionStore();\n // build cross-linking type to position\n this.storesByType[type] = x;\n this.storesXToType[x] = type;\n return this.columnStores[x];\n }\n\n registerRow(y: number, type: DimensionRows): SelectionStore {\n // if hidden just create store\n if (isHiddenStore(y)) {\n return new SelectionStore();\n }\n if (this.rowStores[y]) {\n return this.rowStores[y];\n }\n this.rowStores[y] = new SelectionStore();\n // build cross linking type to position\n this.storesByType[type] = y;\n this.storesYToType[y] = type;\n return this.rowStores[y];\n }\n\n /**\n * Cross store proxy, based on multiple dimensions\n */\n register({ x, y }: Cell): SelectionStore {\n // if hidden just create store\n if (isHiddenStore(x) || isHiddenStore(y)) {\n return new SelectionStore();\n }\n if (!this.stores[y]) {\n this.stores[y] = {};\n }\n if (this.stores[y][x]) {\n // Store already registered. Do not register twice\n return this.stores[y][x];\n }\n this.stores[y][x] = new SelectionStore();\n // proxy update, column store trigger only range area\n this.stores[y][x]?.onChange('range', c => {\n this.columnStores[x].setRangeArea(c);\n this.rowStores[y].setRangeArea(c);\n });\n // clean up on remove\n this.stores[y][x]?.store.on('dispose', () => this.destroy(x, y));\n return this.stores[y][x];\n }\n\n private destroy(x: number, y: number) {\n this.columnStores[x]?.dispose();\n this.rowStores[y]?.dispose();\n\n delete this.rowStores[y];\n delete this.columnStores[x];\n // clear x cross-link\n if (this.storesXToType[x]) {\n const type = this.storesXToType[x];\n delete this.storesXToType[x];\n delete this.storesByType[type];\n }\n // clear y cross-link\n if (this.storesYToType[y]) {\n const type = this.storesYToType[y];\n delete this.storesYToType[y];\n delete this.storesByType[type];\n }\n if (this.stores[y]) {\n delete this.stores[y][x];\n }\n // clear empty rows\n if (!Object.keys(this.stores[y] || {}).length) {\n delete this.stores[y];\n }\n }\n\n setEditByCell<T extends Cell>(storePos: T, editCell: T) {\n this.focusByCell(storePos, editCell, editCell);\n this.setEdit('');\n }\n\n /**\n * Sets the next focus cell before the current one.\n * \n * @param focus - The cell to set as the next focus.\n */\n beforeNextFocusCell(focus: Cell) {\n // If there is no focused store, return early.\n if (!this.focusedStore) {\n return;\n }\n\n // Get the next store based on the current focus and the last cell.\n const lastCell = this.focusedStore.entity.store.get('lastCell');\n const next = lastCell && this.getNextStore(focus, this.focusedStore.position, lastCell);\n\n // Set the next focus cell in the store.\n next?.store?.setNextFocus({ ...focus, ...next.item });\n }\n\n focusByCell<T extends Cell>(storePos: T, start: T, end: T) {\n const store = this.stores[storePos.y][storePos.x];\n this.focus(store, { focus: start, end });\n }\n\n focus(store: SelectionStore, { focus, end }: { focus: Cell; end: Cell }) {\n const currentStorePointer = this.getCurrentStorePointer(store);\n if (!currentStorePointer) {\n return null;\n }\n\n // check for the focus in nearby store/viewport\n const lastCell = store.store.get('lastCell');\n const next = lastCell && this.getNextStore(focus, currentStorePointer, lastCell);\n\n // if next store present - update\n if (next?.store) {\n const item = { ...focus, ...next.item };\n this.focus(next.store, { focus: item, end: item });\n return null;\n }\n\n if (lastCell) {\n focus = cropCellToMax(focus, lastCell);\n end = cropCellToMax(end, lastCell); \n }\n store.setFocus(focus, end);\n return focus;\n }\n\n /**\n * Retrieves the current store pointer based on the active store.\n * Clears focus from all stores except the active one.\n */\n getCurrentStorePointer(store: SelectionStore) {\n let currentStorePointer: Cell | undefined;\n\n // Iterate through all stores\n for (let y in this.stores) {\n for (let x in this.stores[y]) {\n const s = this.stores[y][x];\n\n // Clear focus from stores other than the active one\n if (s !== store) {\n s.clearFocus();\n } else {\n // Update the current store pointer with the active store coordinates\n currentStorePointer = { \n x: parseInt(x, 10), \n y: parseInt(y, 10) \n };\n }\n }\n }\n\n return currentStorePointer;\n }\n\n /**\n * Retrieves the next store based on the focus cell and current store pointer.\n * If the next store exists, returns an object with the next store and the item in the new store.\n * If the next store does not exist, returns null.\n */\n getNextStore(\n focus: Cell,\n currentStorePointer: Cell,\n lastCell: Cell,\n ) {\n // item in new store\n const nextItem: Partial<Cell> | null = nextCell(focus, lastCell);\n\n let nextStore: SelectionStore | undefined;\n if (nextItem) {\n Object.entries(nextItem).forEach(([type, nextItemCoord]: [keyof Cell, number]) => {\n let stores;\n switch (type) {\n case 'x':\n // Get the X stores for the current Y coordinate of the current store pointer\n stores = this.getXStores(currentStorePointer.y);\n break;\n case 'y':\n // Get the Y stores for the current X coordinate of the current store pointer\n stores = this.getYStores(currentStorePointer.x);\n break;\n }\n\n // Get the next store based on the item in the new store\n if (nextItemCoord >= 0) {\n nextStore = stores[++currentStorePointer[type]];\n } else {\n nextStore = stores[--currentStorePointer[type]];\n const nextLastCell = nextStore?.store.get('lastCell');\n if (nextLastCell) {\n nextItem[type] = nextLastCell[type] + nextItemCoord;\n }\n }\n });\n }\n return {\n store: nextStore,\n item: nextItem,\n };\n }\n\n clearAll() {\n for (let y in this.stores) {\n for (let x in this.stores[y]) {\n this.stores[y][x]?.clearFocus();\n }\n }\n }\n\n setEdit(val?: string | boolean) {\n if (!this.focusedStore) {\n return;\n }\n this.focusedStore.entity.setEdit(val);\n }\n\n /**\n * Select all cells across all stores\n */\n selectAll() {\n for (let y in this.stores) {\n for (let x in this.stores[y]) {\n const store = this.stores[y][x];\n if (!store) {\n continue;\n }\n const lastCell = store.store.get('lastCell');\n if (lastCell) {\n store.setRange(\n { x: 0, y: 0 },\n { x: lastCell.x - 1, y: lastCell.y - 1 },\n );\n }\n }\n }\n }\n\n private getXStores(y: number) {\n return this.stores[y];\n }\n\n private getYStores(x: number) {\n const stores: { [p: number]: SelectionStore } = {};\n for (let i in this.stores) {\n stores[i] = this.stores[i][x];\n }\n return stores;\n }\n}\n"]}
@@ -1,16 +1,14 @@
1
1
  /*!
2
2
  * Built by Revolist OU ❤️
3
3
  */
4
+ /**
5
+ * Todo:
6
+ * Refactor proxy plugin: when items changed outside proxy get recalculated
7
+ */
4
8
  /**
5
9
  * Proxy plugin for data source.
6
- * This plugin is used to sort the data source.
7
- * It keeps the order of the items but does not modify the final source.
8
- * It is also used to filter the items in the data source.
9
- * The `set` method takes a key and a new value as arguments.
10
- * If the key is 'proxyItems' it will filter the items in the data source according to the new value.
11
- * The new value should be an array of numbers representing the indexes of the items that should be visible.
12
- * The method will return a new array of numbers with the indexes of the items that should be visible.
13
- * The method will also update the 'items' property of the store with the new array.
10
+ *
11
+ * This plugin is used keep sortint in the data source, even when trimming is applied sorting has to be preserved.
14
12
  */
15
13
  export const proxyPlugin = (store) => ({
16
14
  /**
@@ -21,11 +19,11 @@ export const proxyPlugin = (store) => ({
21
19
  * The method will also update the 'items' property of the store with the new array.
22
20
  */
23
21
  set(k, newVal) {
24
- if (!isProxy(k)) {
22
+ if (k !== 'proxyItems') {
25
23
  return;
26
24
  }
27
25
  /**
28
- * Getting existing collection of items
26
+ * Getting existing collection of items (trimmed and filtered)
29
27
  * Mark indexes as visible
30
28
  */
31
29
  const oldItems = store.get('items').reduce((r, v) => {
@@ -33,8 +31,7 @@ export const proxyPlugin = (store) => ({
33
31
  return r;
34
32
  }, new Set());
35
33
  /**
36
- * Check if new values where present in items
37
- * Filter item collection according presense
34
+ * Check if new values where present in items, keep filtering and trimming
38
35
  */
39
36
  const newItems = newVal.reduce((r, i) => {
40
37
  if (oldItems.has(i)) {
@@ -45,7 +42,4 @@ export const proxyPlugin = (store) => ({
45
42
  store.set('items', newItems);
46
43
  },
47
44
  });
48
- function isProxy(k) {
49
- return k === 'proxyItems';
50
- }
51
45
  //# sourceMappingURL=data.proxy.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"data.proxy.js","sourceRoot":"","sources":["../../../src/store/dataSource/data.proxy.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAwB,EAA0B,EAAE,CAAC,CAAC;IAChF;;;;;;OAMG;IACH,GAAG,CAAC,CAAC,EAAE,MAAM;QACX,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;YAChB,OAAO;QACT,CAAC;QACD;;;WAGG;QACH,MAAM,QAAQ,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAS,EAAE,EAAE;YAC1D,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YACT,OAAO,CAAC,CAAC;QACX,CAAC,EAAE,IAAI,GAAG,EAAU,CAAC,CAAC;QACtB;;;WAGG;QACH,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAW,EAAE,CAAS,EAAE,EAAE;YACxD,IAAI,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;gBACpB,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YACZ,CAAC;YACD,OAAO,CAAC,CAAC;QACX,CAAC,EAAE,EAAE,CAAC,CAAC;QACP,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAC/B,CAAC;CACF,CAAC,CAAC;AAEH,SAAS,OAAO,CAAC,CAAc;IAC7B,OAAO,CAAC,KAAK,YAAY,CAAC;AAC5B,CAAC","sourcesContent":["import { DSourceState } from '@store';\nimport { Observable, PluginSubscribe } from '../../utils/store.utils';\n\ntype State = DSourceState<any, any>;\n\n/**\n * Proxy plugin for data source.\n * This plugin is used to sort the data source.\n * It keeps the order of the items but does not modify the final source.\n * It is also used to filter the items in the data source.\n * The `set` method takes a key and a new value as arguments.\n * If the key is 'proxyItems' it will filter the items in the data source according to the new value.\n * The new value should be an array of numbers representing the indexes of the items that should be visible.\n * The method will return a new array of numbers with the indexes of the items that should be visible.\n * The method will also update the 'items' property of the store with the new array.\n */\nexport const proxyPlugin = (store: Observable<State>): PluginSubscribe<State> => ({\n /**\n * Set the value of a property in the store.\n * If the key is 'proxyItems' it will filter the items in the data source according to the new value.\n * The new value should be an array of numbers representing the indexes of the items that should be visible.\n * The method will return a new array of numbers with the indexes of the items that should be visible.\n * The method will also update the 'items' property of the store with the new array.\n */\n set(k, newVal) {\n if (!isProxy(k)) {\n return;\n }\n /**\n * Getting existing collection of items\n * Mark indexes as visible\n */\n const oldItems = store.get('items').reduce((r, v: number) => {\n r.add(v);\n return r;\n }, new Set<number>());\n /**\n * Check if new values where present in items\n * Filter item collection according presense\n */\n const newItems = newVal.reduce((r: number[], i: number) => {\n if (oldItems.has(i)) {\n r.push(i);\n }\n return r;\n }, []);\n store.set('items', newItems);\n },\n});\n\nfunction isProxy(k: keyof State): k is 'proxyItems' {\n return k === 'proxyItems';\n}\n"]}
1
+ {"version":3,"file":"data.proxy.js","sourceRoot":"","sources":["../../../src/store/dataSource/data.proxy.ts"],"names":[],"mappings":"AAKA;;;GAGG;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAwB,EAA0B,EAAE,CAAC,CAAC;IAChF;;;;;;OAMG;IACH,GAAG,CAAC,CAAC,EAAE,MAAM;QACX,IAAI,CAAC,KAAK,YAAY,EAAE,CAAC;YACvB,OAAO;QACT,CAAC;QACD;;;WAGG;QACH,MAAM,QAAQ,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAS,EAAE,EAAE;YAC1D,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YACT,OAAO,CAAC,CAAC;QACX,CAAC,EAAE,IAAI,GAAG,EAAU,CAAC,CAAC;QACtB;;WAEG;QACH,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAW,EAAE,CAAS,EAAE,EAAE;YACxD,IAAI,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;gBACpB,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YACZ,CAAC;YACD,OAAO,CAAC,CAAC;QACX,CAAC,EAAE,EAAE,CAAC,CAAC;QACP,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAC/B,CAAC;CACF,CAAC,CAAC","sourcesContent":["import { DSourceState } from '@store';\nimport type { Observable, PluginSubscribe } from '../../utils';\n\ntype State = DSourceState<any, any>;\n\n/**\n * Todo:\n * Refactor proxy plugin: when items changed outside proxy get recalculated\n */\n\n/**\n * Proxy plugin for data source.\n * \n * This plugin is used keep sortint in the data source, even when trimming is applied sorting has to be preserved.\n */\nexport const proxyPlugin = (store: Observable<State>): PluginSubscribe<State> => ({\n /**\n * Set the value of a property in the store.\n * If the key is 'proxyItems' it will filter the items in the data source according to the new value.\n * The new value should be an array of numbers representing the indexes of the items that should be visible.\n * The method will return a new array of numbers with the indexes of the items that should be visible.\n * The method will also update the 'items' property of the store with the new array.\n */\n set(k, newVal) {\n if (k !== 'proxyItems') {\n return;\n }\n /**\n * Getting existing collection of items (trimmed and filtered)\n * Mark indexes as visible\n */\n const oldItems = store.get('items').reduce((r, v: number) => {\n r.add(v);\n return r;\n }, new Set<number>());\n /**\n * Check if new values where present in items, keep filtering and trimming\n */\n const newItems = newVal.reduce((r: number[], i: number) => {\n if (oldItems.has(i)) {\n r.push(i);\n }\n return r;\n }, []);\n store.set('items', newItems);\n },\n});\n"]}
@@ -5,7 +5,7 @@ import findIndex from "lodash/findIndex";
5
5
  import range from "lodash/range";
6
6
  import { createStore } from "@stencil/store";
7
7
  import { trimmedPlugin } from "./trimmed.plugin";
8
- import { setStore } from "../../utils/store.utils";
8
+ import { setStore } from "../../utils";
9
9
  import { proxyPlugin } from "./data.proxy";
10
10
  /**
11
11
  * Data store
@@ -1 +1 @@
1
- {"version":3,"file":"data.store.js","sourceRoot":"","sources":["../../../src/store/dataSource/data.store.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,kBAAkB,CAAC;AACzC,OAAO,KAAK,MAAM,cAAc,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,EAAW,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAc,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AA4B3C;;;GAGG;AACH,MAAM,OAAO,SAAS;IAEpB,IAAI,KAAK;QACP,OAAO,IAAI,CA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AAQ,CAAC,CAAC;IACnC,KAAK,IAAI,KAAK,IAAI,YAAY,EAAE,CAAC;QAC/B,MAAM,CAAC,KAAK,CAAC,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC;IACD,IAAI,MAAM,EAAE,CAAC;QACX,KAAK,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC;IACnC,CAAC;AACH,CAAC;AAED,MAAM,UAAU,QAAQ,CACtB,KAAuC,EACvC,KAAe;IAEf,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;AAC5B,CAAC;AAED,MAAM,UAAU,+BAA+B,CAC7C,KAAyC,EACzC,IAAgB;IAEhB,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACjC,MAAM,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACnC,MAAM,aAAa,GAAG,SAAS,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;IAClD,OAAO,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;AACtC,CAAC","sourcesContent":["import findIndex from 'lodash/findIndex';\nimport range from 'lodash/range';\nimport { createStore } from '@stencil/store';\n\nimport { Trimmed, trimmedPlugin } from './trimmed.plugin';\nimport { setStore, Observable } from '../../utils/store.utils';\nimport { proxyPlugin } from './data.proxy';\nimport { GroupLabelTemplateFunc } from '../../plugins/groupingRow/grouping.row.types';\nimport { DimensionRows, DimensionCols } from '@type';\nimport type {\n ColumnProperties,\n ColumnGrouping,\n ColumnRegular,\n DataType,\n DataSourceState,\n ColumnProp,\n} from '@type';\n\nexport interface Group extends ColumnProperties {\n name: string;\n children: (ColumnGrouping | ColumnRegular)[];\n // props/ids\n ids: (string | number)[];\n}\nexport type Groups = Record<any, any>;\nexport type GDataType = DataType | ColumnRegular;\nexport type GDimension = DimensionRows | DimensionCols;\nexport type DSourceState<\n T1 extends GDataType,\n T2 extends GDimension,\n> = DataSourceState<T1, T2> & {\n groupingCustomRenderer?: GroupLabelTemplateFunc | null;\n};\n\n/**\n * Data store\n * Manage the state of a data source and provide methods for updating, adding, and refreshing the data.\n */\nexport class DataStore<T extends GDataType, ST extends GDimension> {\n private readonly dataStore: Observable<DSourceState<T, ST>>;\n get store(): Observable<DSourceState<T, ST>> {\n return this.dataStore;\n }\n constructor(type: ST, storeData?: DSourceState<T, ST>) {\n const store = (this.dataStore = createStore<DSourceState<T, ST>>({\n items: [],\n proxyItems: [],\n source: [],\n groupingDepth: 0,\n groups: {},\n type,\n trimmed: {},\n groupingCustomRenderer: undefined,\n ...storeData,\n }));\n store.use(proxyPlugin(store));\n store.use(trimmedPlugin(store));\n }\n\n /**\n * full data source update\n * @param source - data column/rgRow source\n * @param grouping - grouping information if present\n */\n updateData(\n source: T[],\n grouping?: {\n depth: number;\n groups?: Groups;\n customRenderer?: GroupLabelTemplateFunc;\n },\n silent = false,\n ) {\n // during full update we do drop trim\n if (!silent) {\n this.store.set('trimmed', {});\n }\n // clear items\n this.store.set('items', []);\n const items = range(0, source?.length || 0);\n\n // set proxy first\n setStore(this.store, {\n source,\n proxyItems: [...items],\n });\n // update data items\n this.store.set('items', items);\n // apply grouping if present\n if (grouping) {\n setStore(this.store, {\n groupingDepth: grouping.depth,\n groups: grouping.groups,\n groupingCustomRenderer: grouping.customRenderer,\n });\n }\n }\n\n addTrimmed(some: Partial<Trimmed>) {\n let trimmed = this.store.get('trimmed');\n trimmed = { ...trimmed, ...some };\n setStore(this.store, { trimmed });\n }\n\n setSourceData(items: Record<number, any>, mutate = true) {\n setSourceByVirtualIndex(this.store, items, mutate);\n }\n\n // local data update\n setData(input: Partial<DSourceState<T, ST>>) {\n const data: Partial<DSourceState<T, ST>> = {\n ...input,\n };\n setStore(this.store, data);\n }\n\n refresh() {\n const source = this.store.get('source');\n this.store.set('source', [...source]);\n }\n}\n/**\n * get physical index by virtual\n * @param store - store to process\n */\nexport function getPhysical(\n store: Observable<DSourceState<any, any>>,\n virtualIndex: number,\n) {\n const items = store.get('items');\n return items[virtualIndex];\n}\n\n/**\n * get all visible items\n * @param store - store to process\n */\nexport function getVisibleSourceItem(\n store: Observable<DSourceState<any, any>>,\n) {\n const source = store.get('source');\n return store.get('items').map(v => source[v]);\n}\n\n/**\n * get mapped item from source\n * @param store - store to process\n * @param virtualIndex - virtual index to process\n */\nexport const getSourceItem = <T1 extends GDataType, T2 extends GDimension>(\n store: Observable<DSourceState<T1, T2>>,\n virtualIndex: number,\n) => {\n const source = store.get('source');\n return source[getSourcePhysicalIndex(store, virtualIndex)];\n};\n/**\n * Get physical index from virtual index\n */\nexport const getSourcePhysicalIndex = <T1 extends GDataType, T2 extends GDimension>(\n store: Observable<DSourceState<T1, T2>>,\n virtualIndex: number,\n) => {\n const items = store.get('items');\n return items[virtualIndex];\n};\n\n/**\n * Apply silently item/model/row value to data source\n * @param store - data source with changes\n * @param modelByIndex - collection of rows/values with virtual indexes to setup/replace in store/data source\n * @param mutate - if true, store will be mutated and whole viewport will be re-rendered\n */\nexport function setSourceByVirtualIndex<T extends GDataType>(\n store: Observable<DSourceState<T, any>>,\n modelByIndex: Record<number, T | undefined>,\n mutate = true,\n) {\n const items = store.get('items');\n const source = store.get('source');\n\n for (let virtualIndex in modelByIndex) {\n const realIndex = items[virtualIndex];\n const item = modelByIndex[virtualIndex];\n source[realIndex] = item as T;\n }\n if (mutate) {\n store.set('source', [...source]);\n }\n}\n\n/**\n * set item to source\n * @param store - store to process\n * @param modelByIndex - collection of rows with physical indexes to setup\n * @param mutate - if true, store will be mutated and whole viewport will be re-rendered\n */\nexport function setSourceByPhysicalIndex<T extends GDataType>(\n store: Observable<DSourceState<T, any>>,\n modelByIndex: Record<number, T>,\n mutate = true,\n) {\n const source = store.get('source');\n for (let index in modelByIndex) {\n source[index] = modelByIndex[index];\n }\n if (mutate) {\n store.set('source', [...source]);\n }\n}\n\nexport function setItems<T extends GDataType>(\n store: Observable<DSourceState<T, any>>,\n items: number[],\n) {\n store.set('items', items);\n}\n\nexport function getSourceItemVirtualIndexByProp(\n store: Observable<DSourceState<any, any>>,\n prop: ColumnProp,\n) {\n const items = store.get('items');\n const source = store.get('source');\n const physicalIndex = findIndex(source, { prop });\n return items.indexOf(physicalIndex);\n}\n"]}
1
+ {"version":3,"file":"data.store.js","sourceRoot":"","sources":["../../../src/store/dataSource/data.store.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,kBAAkB,CAAC;AACzC,OAAO,KAAK,MAAM,cAAc,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,EAAW,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAc,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AA6B3C;;;GAGG;AACH,MAAM,OAAO,SAAS;IAEpB,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IACD,YAAY,IAAQ,EAAE,SAA+B;QACnD,MAAM,KAAK,GAAG,CAAC,IAAI,CAAC,SAAS,GAAG,WAAW,iBACzC,KAAK,EAAE,EAAE,EACT,UAAU,EAAE,EAAE,EACd,MAAM,EAAE,EAAE,EACV,aAAa,EAAE,CAAC,EAChB,MAAM,EAAE,EAAE,EACV,IAAI,EACJ,OAAO,EAAE,EAAE,EACX,sBAAsB,EAAE,SAAS,IAC9B,SAAS,EACZ,CAAC,CAAC;QACJ,KAAK,CAAC,GAAG,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC;QAC9B,KAAK,CAAC,GAAG,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC;IAClC,CAAC;IAED;;;;OAIG;IACH,UAAU,CACR,MAAW,EACX,QAIC,EACD,MAAM,GAAG,KAAK;QAEd,qCAAqC;QACrC,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ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aAAa,GAAG,SAAS,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;IAClD,OAAO,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;AACtC,CAAC","sourcesContent":["import findIndex from 'lodash/findIndex';\nimport range from 'lodash/range';\nimport { createStore } from '@stencil/store';\n\nimport { Trimmed, trimmedPlugin } from './trimmed.plugin';\nimport { setStore, Observable } from '../../utils';\nimport { proxyPlugin } from './data.proxy';\nimport { GroupLabelTemplateFunc } from '../../plugins/groupingRow/grouping.row.types';\nimport type {\n DimensionRows,\n DimensionCols,\n ColumnProperties,\n ColumnGrouping,\n ColumnRegular,\n DataType,\n DataSourceState,\n ColumnProp,\n} from '@type';\n\nexport interface Group extends ColumnProperties {\n name: string;\n children: (ColumnGrouping | ColumnRegular)[];\n // props/ids\n ids: (string | number)[];\n}\nexport type Groups = Record<any, any>;\nexport type GDataType = DataType | ColumnRegular;\nexport type GDimension = DimensionRows | DimensionCols;\nexport type DSourceState<\n T1 extends GDataType,\n T2 extends GDimension,\n> = DataSourceState<T1, T2> & {\n groupingCustomRenderer?: GroupLabelTemplateFunc | null;\n};\n\n/**\n * Data store\n * Manage the state of a data source and provide methods for updating, adding, and refreshing the data.\n */\nexport class DataStore<T extends GDataType, ST extends GDimension> {\n private readonly dataStore: Observable<DSourceState<T, ST>>;\n get store(): Observable<DSourceState<T, ST>> {\n return this.dataStore;\n }\n constructor(type: ST, storeData?: DSourceState<T, ST>) {\n const store = (this.dataStore = createStore<DSourceState<T, ST>>({\n items: [],\n proxyItems: [],\n source: [],\n groupingDepth: 0,\n groups: {},\n type,\n trimmed: {},\n groupingCustomRenderer: undefined,\n ...storeData,\n }));\n store.use(proxyPlugin(store));\n store.use(trimmedPlugin(store));\n }\n\n /**\n * full data source update\n * @param source - data column/rgRow source\n * @param grouping - grouping information if present\n */\n updateData(\n source: T[],\n grouping?: {\n depth: number;\n groups?: Groups;\n customRenderer?: GroupLabelTemplateFunc;\n },\n silent = false,\n ) {\n // during full update we do drop trim\n if (!silent) {\n this.store.set('trimmed', {});\n }\n // clear items\n this.store.set('items', []);\n const items = range(0, source?.length || 0);\n\n // set proxy first\n setStore(this.store, {\n source,\n proxyItems: [...items],\n });\n // update data items\n this.store.set('items', items);\n // apply grouping if present\n if (grouping) {\n setStore(this.store, {\n groupingDepth: grouping.depth,\n groups: grouping.groups,\n groupingCustomRenderer: grouping.customRenderer,\n });\n }\n }\n\n addTrimmed(some: Partial<Trimmed>) {\n let trimmed = this.store.get('trimmed');\n trimmed = { ...trimmed, ...some };\n setStore(this.store, { trimmed });\n }\n\n setSourceData(items: Record<number, any>, mutate = true) {\n setSourceByVirtualIndex(this.store, items, mutate);\n }\n\n // local data update\n setData(input: Partial<DSourceState<T, ST>>) {\n const data: Partial<DSourceState<T, ST>> = {\n ...input,\n };\n setStore(this.store, data);\n }\n\n refresh() {\n const source = this.store.get('source');\n this.store.set('source', [...source]);\n }\n}\n/**\n * get physical index by virtual\n * @param store - store to process\n */\nexport function getPhysical(\n store: Observable<DSourceState<any, any>>,\n virtualIndex: number,\n) {\n const items = store.get('items');\n return items[virtualIndex];\n}\n\n/**\n * get all visible items\n * @param store - store to process\n */\nexport function getVisibleSourceItem(\n store: Observable<DSourceState<any, any>>,\n) {\n const source = store.get('source');\n return store.get('items').map(v => source[v]);\n}\n\n/**\n * get mapped item from source\n * @param store - store to process\n * @param virtualIndex - virtual index to process\n */\nexport const getSourceItem = <T1 extends GDataType, T2 extends GDimension>(\n store: Observable<DSourceState<T1, T2>>,\n virtualIndex: number,\n) => {\n const source = store.get('source');\n return source[getSourcePhysicalIndex(store, virtualIndex)];\n};\n/**\n * Get physical index from virtual index\n */\nexport const getSourcePhysicalIndex = <T1 extends GDataType, T2 extends GDimension>(\n store: Observable<DSourceState<T1, T2>>,\n virtualIndex: number,\n) => {\n const items = store.get('items');\n return items[virtualIndex];\n};\n\n/**\n * Apply silently item/model/row value to data source\n * @param store - data source with changes\n * @param modelByIndex - collection of rows/values with virtual indexes to setup/replace in store/data source\n * @param mutate - if true, store will be mutated and whole viewport will be re-rendered\n */\nexport function setSourceByVirtualIndex<T extends GDataType>(\n store: Observable<DSourceState<T, any>>,\n modelByIndex: Record<number, T | undefined>,\n mutate = true,\n) {\n const items = store.get('items');\n const source = store.get('source');\n\n for (let virtualIndex in modelByIndex) {\n const realIndex = items[virtualIndex];\n const item = modelByIndex[virtualIndex];\n source[realIndex] = item as T;\n }\n if (mutate) {\n store.set('source', [...source]);\n }\n}\n\n/**\n * set item to source\n * @param store - store to process\n * @param modelByIndex - collection of rows with physical indexes to setup\n * @param mutate - if true, store will be mutated and whole viewport will be re-rendered\n */\nexport function setSourceByPhysicalIndex<T extends GDataType>(\n store: Observable<DSourceState<T, any>>,\n modelByIndex: Record<number, T>,\n mutate = true,\n) {\n const source = store.get('source');\n for (let index in modelByIndex) {\n source[index] = modelByIndex[index];\n }\n if (mutate) {\n store.set('source', [...source]);\n }\n}\n\nexport function setItems<T extends GDataType>(\n store: Observable<DSourceState<T, any>>,\n items: number[],\n) {\n store.set('items', items);\n}\n\nexport function getSourceItemVirtualIndexByProp(\n store: Observable<DSourceState<any, any>>,\n prop: ColumnProp,\n) {\n const items = store.get('items');\n const source = store.get('source');\n const physicalIndex = findIndex(source, { prop });\n return items.indexOf(physicalIndex);\n}\n"]}
@@ -8,18 +8,15 @@
8
8
  export const trimmedPlugin = (store) => ({
9
9
  set(k, newVal) {
10
10
  switch (k) {
11
- case 'trimmed':
11
+ case 'trimmed': {
12
+ // full sorted items list
12
13
  const proxy = store.get('proxyItems');
13
14
  const trimmed = gatherTrimmedItems(newVal);
14
- const newItems = proxy.reduce((result, v) => {
15
- // check if present in new trimmed remove from items (filter)
16
- if (!trimmed[v]) {
17
- result.push(v);
18
- }
19
- return result;
20
- }, []);
15
+ const newItems = proxy.filter(v => !trimmed[v]);
16
+ // set trimmed items in store
21
17
  store.set('items', newItems);
22
18
  break;
19
+ }
23
20
  }
24
21
  },
25
22
  });
@@ -1 +1 @@
1
- {"version":3,"file":"trimmed.plugin.js","sourceRoot":"","sources":["../../../src/store/dataSource/trimmed.plugin.ts"],"names":[],"mappings":"AAMA;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAsB,KAAuC,EAAyC,EAAE,CAAC,CAAC;IACrI,GAAG,CAAC,CAAC,EAAE,MAAM;QACX,QAAQ,CAAC,EAAE,CAAC;YACV,KAAK,SAAS;gBACZ,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;gBACtC,MAAM,OAAO,GAAG,kBAAkB,CAAC,MAAiB,CAAC,CAAC;gBAEtD,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,MAAgB,EAAE,CAAS,EAAE,EAAE;oBAC5D,6DAA6D;oBAC7D,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;wBAChB,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;oBACjB,CAAC;oBACD,OAAO,MAAM,CAAC;gBAChB,CAAC,EAAE,EAAE,CAAC,CAAC;gBAEP,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;gBAC7B,MAAM;QACV,CAAC;IACH,CAAC;CACF,CAAC,CAAC;AAEH,MAAM,UAAU,kBAAkB,CAAC,YAAqB;IACtD,MAAM,OAAO,GAAkB,EAAE,CAAC;IAElC,KAAK,IAAI,UAAU,IAAI,YAAY,EAAE,CAAC;QACpC,iCAAiC;QACjC,KAAK,IAAI,CAAC,IAAI,YAAY,CAAC,UAAU,CAAC,EAAE,CAAC;YACvC,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,YAAY,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;QACzD,CAAC;IACH,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import { Observable, PluginSubscribe } from '../../utils/store.utils';\nimport { DSourceState, GDataType } from './data.store';\n\nexport type TrimmedEntity = Record<number, boolean>;\nexport type Trimmed = Record<string, TrimmedEntity>;\n\n/**\n * Hide items from main collection\n * But keep them in store\n */\nexport const trimmedPlugin = <T extends GDataType>(store: Observable<DSourceState<T, any>>): PluginSubscribe<DSourceState<T, any>> => ({\n set(k, newVal) {\n switch (k) {\n case 'trimmed':\n const proxy = store.get('proxyItems');\n const trimmed = gatherTrimmedItems(newVal as Trimmed);\n\n const newItems = proxy.reduce((result: number[], v: number) => {\n // check if present in new trimmed remove from items (filter)\n if (!trimmed[v]) {\n result.push(v);\n }\n return result;\n }, []);\n\n store.set('items', newItems);\n break;\n }\n },\n});\n\nexport function gatherTrimmedItems(trimmedItems: Trimmed) {\n const trimmed: TrimmedEntity = {};\n\n for (let trimmedKey in trimmedItems) {\n // trimmed overweight not trimmed\n for (let t in trimmedItems[trimmedKey]) {\n trimmed[t] = trimmed[t] || trimmedItems[trimmedKey][t];\n }\n }\n return trimmed;\n}\n"]}
1
+ {"version":3,"file":"trimmed.plugin.js","sourceRoot":"","sources":["../../../src/store/dataSource/trimmed.plugin.ts"],"names":[],"mappings":"AAMA;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,KAAuC,EACA,EAAE,CAAC,CAAC;IAC3C,GAAG,CAAC,CAAC,EAAE,MAAM;QACX,QAAQ,CAAC,EAAE,CAAC;YACV,KAAK,SAAS,CAAC,CAAC,CAAC;gBACf,yBAAyB;gBACzB,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;gBACtC,MAAM,OAAO,GAAG,kBAAkB,CAAC,MAAiB,CAAC,CAAC;gBACtD,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;gBAEhD,6BAA6B;gBAC7B,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;gBAC7B,MAAM;YACR,CAAC;QACH,CAAC;IACH,CAAC;CACF,CAAC,CAAC;AAEH,MAAM,UAAU,kBAAkB,CAAC,YAAqB;IACtD,MAAM,OAAO,GAAkB,EAAE,CAAC;IAElC,KAAK,IAAI,UAAU,IAAI,YAAY,EAAE,CAAC;QACpC,iCAAiC;QACjC,KAAK,IAAI,CAAC,IAAI,YAAY,CAAC,UAAU,CAAC,EAAE,CAAC;YACvC,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,IAAI,YAAY,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;QACzD,CAAC;IACH,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["import { Observable, PluginSubscribe } from '../../utils';\nimport { DSourceState, GDataType } from './data.store';\n\nexport type TrimmedEntity = Record<number, boolean>;\nexport type Trimmed = Record<string, TrimmedEntity>;\n\n/**\n * Hide items from main collection\n * But keep them in store\n */\nexport const trimmedPlugin = <T extends GDataType>(\n store: Observable<DSourceState<T, any>>,\n): PluginSubscribe<DSourceState<T, any>> => ({\n set(k, newVal) {\n switch (k) {\n case 'trimmed': {\n // full sorted items list\n const proxy = store.get('proxyItems');\n const trimmed = gatherTrimmedItems(newVal as Trimmed);\n const newItems = proxy.filter(v => !trimmed[v]);\n\n // set trimmed items in store\n store.set('items', newItems);\n break;\n }\n }\n },\n});\n\nexport function gatherTrimmedItems(trimmedItems: Trimmed) {\n const trimmed: TrimmedEntity = {};\n\n for (let trimmedKey in trimmedItems) {\n // trimmed overweight not trimmed\n for (let t in trimmedItems[trimmedKey]) {\n trimmed[t] = trimmed[t] || trimmedItems[trimmedKey][t];\n }\n }\n return trimmed;\n}\n"]}
@@ -11,12 +11,11 @@ export function calculateDimensionData(originItemSize, newSizes = {}) {
11
11
  const positionIndexes = [];
12
12
  const positionIndexToItem = {};
13
13
  const indexToItem = {};
14
- // combine all new sizes
15
- const sizes = Object.assign({}, newSizes);
16
14
  // prepare order sorted new sizes and calculate changed real size
17
- const newIndexes = Object.keys(sizes).map(Number).sort((a, b) => a - b);
18
- // fill new coordinates based on what is changed
19
- newIndexes.reduce((previous, itemIndex, i) => {
15
+ const newIndexes = Object.keys(newSizes).map(Number).sort((a, b) => a - b);
16
+ let previous;
17
+ for (let i = 0; i < newIndexes.length; i++) {
18
+ const itemIndex = newIndexes[i];
20
19
  const newItem = {
21
20
  itemIndex,
22
21
  start: 0,
@@ -30,17 +29,16 @@ export function calculateDimensionData(originItemSize, newSizes = {}) {
30
29
  else {
31
30
  newItem.start = itemIndex * originItemSize;
32
31
  }
33
- newItem.end = newItem.start + sizes[itemIndex];
32
+ newItem.end = newItem.start + newSizes[itemIndex];
34
33
  positionIndexes.push(newItem.start);
35
34
  indexToItem[itemIndex] = positionIndexToItem[i] = newItem;
36
- return newItem;
37
- }, undefined);
35
+ previous = newItem;
36
+ }
38
37
  return {
39
38
  indexes: newIndexes,
40
39
  positionIndexes: [...positionIndexes],
41
40
  positionIndexToItem: Object.assign({}, positionIndexToItem),
42
41
  indexToItem,
43
- sizes,
44
42
  };
45
43
  }
46
44
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"dimension.helpers.js","sourceRoot":"","sources":["../../../src/store/dimension/dimension.helpers.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,oBAAoB,CAAC;AAyB7C;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CACpC,cAAsB,EACtB,WAAgC,EAAE;IAElC,MAAM,eAAe,GAAa,EAAE,CAAC;IACrC,MAAM,mBAAmB,GAAyC,EAAE,CAAC;IACrE,MAAM,WAAW,GAAsC,EAAE,CAAC;IAE1D,wBAAwB;IACxB,MAAM,KAAK,qBAAQ,QAAQ,CAAE,CAAC;IAC9B,iEAAiE;IACjE,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,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E,CAAC;QACjC,OAAO,SAAS,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IACtC,CAAC;IAED,MAAM,YAAY,GAAG,SAAS,CAAC,OAAO,CAAC,MAAM;QAC3C,CAAC,CAAC,WAAW,CAAC,SAAS,CAAC,OAAO,EAAE,KAAK,CAAC;QACvC,CAAC,CAAC,CAAC,CAAC;IACN,2BAA2B;IAC3B,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC,cAAc,CAAC;QACvD,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC,cAAc,CAAC;QACjD,OAAO,IAAI,CAAC;IACd,CAAC;IACD,uCAAuC;IACvC,MAAM,YAAY,GAChB,SAAS,CAAC,WAAW,CAAC,SAAS,CAAC,OAAO,CAAC,YAAY,GAAG,CAAC,CAAC,CAAC,CAAC;IAC7D,IAAI,CAAC,KAAK;QACR,YAAY,CAAC,GAAG;YAChB,CAAC,KAAK,GAAG,YAAY,CAAC,SAAS,GAAG,CAAC,CAAC,GAAG,SAAS,CAAC,cAAc,CAAC;IAClE,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC,cAAc,CAAC;IACjD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import sortedIndex from 'lodash/sortedIndex';\n\nimport type {\n DimensionSettingsState,\n PositionItem,\n ViewSettingSizeProp,\n} from '@type';\n\nexport type DimensionPosition = Pick<\n DimensionSettingsState,\n 'indexes' | 'positionIndexes' | 'originItemSize' | 'positionIndexToItem'\n>;\nexport type DimensionIndexInput = Pick<\n DimensionSettingsState,\n 'indexes' | 'originItemSize' | 'indexToItem'\n>;\nexport type DimensionSize = Pick<\n DimensionSettingsState,\n | 'indexes'\n | 'positionIndexes'\n | 'positionIndexToItem'\n | 'indexToItem'\n | 'realSize'\n | 'sizes'\n>;\n/**\n * Pre-calculation\n * Dimension custom sizes for each cell\n * Keeps only changed sizes, skips origin size\n */\nexport function calculateDimensionData(\n originItemSize: number,\n newSizes: ViewSettingSizeProp = {},\n) {\n const positionIndexes: number[] = [];\n const positionIndexToItem: { [position: number]: PositionItem } = {};\n const indexToItem: { [index: number]: PositionItem } = {};\n\n // combine all new sizes\n const sizes = { ...newSizes };\n // prepare order sorted new sizes and calculate changed real size\n const newIndexes = Object.keys(sizes).map(Number).sort((a, b) => a - b);\n // fill new coordinates based on what is changed\n newIndexes.reduce(\n (previous: PositionItem | undefined, itemIndex: number, i: number) => {\n const newItem: PositionItem = {\n itemIndex,\n start: 0,\n end: 0,\n };\n // if previous item was changed too\n if (previous) {\n const itemsBetween =\n (itemIndex - previous.itemIndex - 1) * originItemSize;\n newItem.start = itemsBetween + previous.end;\n } else {\n newItem.start = itemIndex * originItemSize;\n }\n newItem.end = newItem.start + sizes[itemIndex];\n positionIndexes.push(newItem.start);\n indexToItem[itemIndex] = positionIndexToItem[i] = newItem;\n return newItem;\n },\n undefined,\n );\n\n return {\n indexes: newIndexes,\n positionIndexes: [...positionIndexes],\n positionIndexToItem: { ...positionIndexToItem },\n indexToItem,\n sizes,\n };\n}\n\n/**\n * Calculate item by position\n */\nexport const getItemByPosition = (\n {\n indexes,\n positionIndexes,\n originItemSize,\n positionIndexToItem,\n }: DimensionPosition,\n pos: number,\n) => {\n const item: PositionItem = {\n itemIndex: 0,\n start: 0,\n end: 0,\n };\n const currentPlace = indexes.length ? sortedIndex(positionIndexes, pos) : 0;\n // not found or first index\n if (!currentPlace) {\n item.itemIndex = Math.floor(pos / originItemSize);\n item.start = item.itemIndex * originItemSize;\n item.end = item.start + originItemSize;\n return item;\n }\n const positionItem = positionIndexToItem[currentPlace - 1];\n // if item has specified size\n if (positionItem.end > pos) {\n return positionItem;\n }\n // special size item was present before\n const relativePos = pos - positionItem.end;\n const relativeIndex = Math.floor(relativePos / originItemSize);\n item.itemIndex = positionItem.itemIndex + 1 + relativeIndex;\n item.start = positionItem.end + relativeIndex * originItemSize;\n item.end = item.start + originItemSize;\n return item;\n};\n\nexport function getItemByIndex(\n dimension: Pick<\n DimensionIndexInput,\n 'indexToItem' | 'indexes' | 'originItemSize'\n >,\n index: number,\n) {\n let item: PositionItem = {\n itemIndex: index,\n start: 0,\n end: 0,\n };\n // if item has specified size\n if (dimension.indexToItem[index]) {\n return dimension.indexToItem[index];\n }\n\n const currentPlace = dimension.indexes.length\n ? sortedIndex(dimension.indexes, index)\n : 0;\n // not found or first index\n if (!currentPlace) {\n item.start = item.itemIndex * dimension.originItemSize;\n item.end = item.start + dimension.originItemSize;\n return item;\n }\n // special size item was present before\n const positionItem =\n dimension.indexToItem[dimension.indexes[currentPlace - 1]];\n item.start =\n positionItem.end +\n (index - positionItem.itemIndex - 1) * dimension.originItemSize;\n item.end = item.start + dimension.originItemSize;\n return item;\n}\n"]}
1
+ {"version":3,"file":"dimension.helpers.js","sourceRoot":"","sources":["../../../src/store/dimension/dimension.helpers.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,oBAAoB,CAAC;AAyB7C;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CACpC,cAAsB,EACtB,WAAgC,EAAE;IAElC,MAAM,eAAe,GAAa,EAAE,CAAC;IACrC,MAAM,mBAAmB,GAAyC,EAAE,CAAC;IACrE,MAAM,WAAW,GAAsC,EAAE,CAAC;IAE1D,iEAAiE;IACjE,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAC3E,IAAI,QAAkC,CAAC;IACvC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAC3C,MAAM,SAAS,GAAG,UAAU,CAAC,CAAC,CAAC,CA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AS,CAAC,OAAO,EAAE,KAAK,CAAC;QACvC,CAAC,CAAC,CAAC,CAAC;IACN,2BAA2B;IAC3B,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC,cAAc,CAAC;QACvD,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC,cAAc,CAAC;QACjD,OAAO,IAAI,CAAC;IACd,CAAC;IACD,uCAAuC;IACvC,MAAM,YAAY,GAChB,SAAS,CAAC,WAAW,CAAC,SAAS,CAAC,OAAO,CAAC,YAAY,GAAG,CAAC,CAAC,CAAC,CAAC;IAC7D,IAAI,CAAC,KAAK;QACR,YAAY,CAAC,GAAG;YAChB,CAAC,KAAK,GAAG,YAAY,CAAC,SAAS,GAAG,CAAC,CAAC,GAAG,SAAS,CAAC,cAAc,CAAC;IAClE,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC,cAAc,CAAC;IACjD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import sortedIndex from 'lodash/sortedIndex';\n\nimport type {\n DimensionSettingsState,\n PositionItem,\n ViewSettingSizeProp,\n} from '@type';\n\nexport type DimensionPosition = Pick<\n DimensionSettingsState,\n 'indexes' | 'positionIndexes' | 'originItemSize' | 'positionIndexToItem'\n>;\nexport type DimensionIndexInput = Pick<\n DimensionSettingsState,\n 'indexes' | 'originItemSize' | 'indexToItem'\n>;\nexport type DimensionSize = Pick<\n DimensionSettingsState,\n | 'indexes'\n | 'positionIndexes'\n | 'positionIndexToItem'\n | 'indexToItem'\n | 'realSize'\n | 'sizes'\n>;\n/**\n * Pre-calculation\n * Dimension custom sizes for each cell\n * Keeps only changed sizes, skips origin size\n */\nexport function calculateDimensionData(\n originItemSize: number,\n newSizes: ViewSettingSizeProp = {},\n) {\n const positionIndexes: number[] = [];\n const positionIndexToItem: { [position: number]: PositionItem } = {};\n const indexToItem: { [index: number]: PositionItem } = {};\n\n // prepare order sorted new sizes and calculate changed real size\n const newIndexes = Object.keys(newSizes).map(Number).sort((a, b) => a - b);\n let previous: PositionItem | undefined;\n for (let i = 0; i < newIndexes.length; i++) {\n const itemIndex = newIndexes[i];\n const newItem: PositionItem = {\n itemIndex,\n start: 0,\n end: 0,\n };\n // if previous item was changed too\n if (previous) {\n const itemsBetween =\n (itemIndex - previous.itemIndex - 1) * originItemSize;\n newItem.start = itemsBetween + previous.end;\n } else {\n newItem.start = itemIndex * originItemSize;\n }\n newItem.end = newItem.start + newSizes[itemIndex];\n positionIndexes.push(newItem.start);\n indexToItem[itemIndex] = positionIndexToItem[i] = newItem;\n previous = newItem;\n }\n return {\n indexes: newIndexes,\n positionIndexes: [...positionIndexes],\n positionIndexToItem: { ...positionIndexToItem },\n indexToItem,\n };\n}\n\n/**\n * Calculate item by position\n */\nexport const getItemByPosition = (\n {\n indexes,\n positionIndexes,\n originItemSize,\n positionIndexToItem,\n }: Pick<DimensionPosition, 'indexes' | 'positionIndexes' | 'originItemSize' | 'positionIndexToItem'>,\n pos: number,\n) => {\n const item: PositionItem = {\n itemIndex: 0,\n start: 0,\n end: 0,\n };\n const currentPlace = indexes.length ? sortedIndex(positionIndexes, pos) : 0;\n // not found or first index\n if (!currentPlace) {\n item.itemIndex = Math.floor(pos / originItemSize);\n item.start = item.itemIndex * originItemSize;\n item.end = item.start + originItemSize;\n return item;\n }\n const positionItem = positionIndexToItem[currentPlace - 1];\n // if item has specified size\n if (positionItem.end > pos) {\n return positionItem;\n }\n // special size item was present before\n const relativePos = pos - positionItem.end;\n const relativeIndex = Math.floor(relativePos / originItemSize);\n item.itemIndex = positionItem.itemIndex + 1 + relativeIndex;\n item.start = positionItem.end + relativeIndex * originItemSize;\n item.end = item.start + originItemSize;\n return item;\n};\n\nexport function getItemByIndex(\n dimension: Pick<\n DimensionIndexInput,\n 'indexToItem' | 'indexes' | 'originItemSize'\n >,\n index: number,\n) {\n let item: PositionItem = {\n itemIndex: index,\n start: 0,\n end: 0,\n };\n // if item has specified size\n if (dimension.indexToItem[index]) {\n return dimension.indexToItem[index];\n }\n\n const currentPlace = dimension.indexes.length\n ? sortedIndex(dimension.indexes, index)\n : 0;\n // not found or first index\n if (!currentPlace) {\n item.start = item.itemIndex * dimension.originItemSize;\n item.end = item.start + dimension.originItemSize;\n return item;\n }\n // special size item was present before\n const positionItem =\n dimension.indexToItem[dimension.indexes[currentPlace - 1]];\n item.start =\n positionItem.end +\n (index - positionItem.itemIndex - 1) * dimension.originItemSize;\n item.end = item.start + dimension.originItemSize;\n return item;\n}\n"]}
@@ -0,0 +1,35 @@
1
+ /*!
2
+ * Built by Revolist OU ❤️
3
+ */
4
+ /**
5
+ * Plugin which recalculates realSize on changes of sizes, originItemSize and count
6
+ */
7
+ export const recalculateRealSizePlugin = (storeService) => {
8
+ /**
9
+ * Recalculates realSize if size, origin size or count changes
10
+ */
11
+ return {
12
+ /**
13
+ * Reacts on changes of count, sizes and originItemSize
14
+ */
15
+ set(k) {
16
+ switch (k) {
17
+ case 'count':
18
+ case 'sizes':
19
+ case 'originItemSize': {
20
+ // recalculate realSize
21
+ let realSize = 0;
22
+ const count = storeService.store.get('count');
23
+ for (let i = 0; i < count; i++) {
24
+ realSize +=
25
+ storeService.store.get('sizes')[i] ||
26
+ storeService.store.get('originItemSize');
27
+ }
28
+ storeService.setStore({ realSize });
29
+ break;
30
+ }
31
+ }
32
+ },
33
+ };
34
+ };
35
+ //# sourceMappingURL=dimension.recalculate.plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dimension.recalculate.plugin.js","sourceRoot":"","sources":["../../../src/store/dimension/dimension.recalculate.plugin.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,YAGzC,EAA2C,EAAE;IAC5C;;OAEG;IACH,OAAO;QACL;;WAEG;QACH,GAAG,CAAC,CAAC;YACH,QAAQ,CAAC,EAAE,CAAC;gBACV,KAAK,OAAO,CAAC;gBACb,KAAK,OAAO,CAAC;gBACb,KAAK,gBAAgB,CAAC,CAAC,CAAC;oBACtB,uBAAuB;oBACvB,IAAI,QAAQ,GAAG,CAAC,CAAC;oBACjB,MAAM,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;oBAC9C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC;wBAC/B,QAAQ;4BACN,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;gCAClC,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;oBAC7C,CAAC;oBACD,YAAY,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC;oBACpC,MAAM;gBACR,CAAC;YACH,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { DimensionSettingsState } from '@type';\nimport type { Observable, PluginSubscribe } from '../../utils';\n\n/**\n * Plugin which recalculates realSize on changes of sizes, originItemSize and count\n */\nexport const recalculateRealSizePlugin = (storeService: {\n store: Observable<DimensionSettingsState>;\n setStore: (k: Partial<DimensionSettingsState>) => void;\n}): PluginSubscribe<DimensionSettingsState> => {\n /**\n * Recalculates realSize if size, origin size or count changes\n */\n return {\n /**\n * Reacts on changes of count, sizes and originItemSize\n */\n set(k) {\n switch (k) {\n case 'count':\n case 'sizes':\n case 'originItemSize': {\n // recalculate realSize\n let realSize = 0;\n const count = storeService.store.get('count');\n for (let i = 0; i < count; i++) {\n realSize +=\n storeService.store.get('sizes')[i] ||\n storeService.store.get('originItemSize');\n }\n storeService.setStore({ realSize });\n break;\n }\n }\n },\n };\n};\n"]}
@@ -7,74 +7,17 @@
7
7
  */
8
8
  import reduce from "lodash/reduce";
9
9
  import { createStore } from "@stencil/store";
10
- import { setStore } from "../../utils/store.utils";
10
+ import { setStore } from "../../utils";
11
11
  import { calculateDimensionData } from "./dimension.helpers";
12
- const trimmedPlugin = (store) => {
13
- let trimmedSize = {};
14
- const setTrimmed = (sizes, trimmed) => {
15
- const newSize = Object.assign({}, sizes);
16
- trimmedSize = {};
17
- for (const [index, v] of Object.entries(trimmed)) {
18
- const i = index;
19
- if (v && newSize[i]) {
20
- trimmedSize[i] = newSize[i];
21
- delete newSize[i];
22
- }
23
- }
24
- store.setDimensionSize(newSize);
25
- };
26
- return {
27
- set(key, val) {
28
- switch (key) {
29
- case 'trimmed':
30
- const trim = val;
31
- const sizes = store.store.get('sizes');
32
- // recover trimmed, apply new trim
33
- setTrimmed(Object.assign(Object.assign({}, sizes), trimmedSize), trim);
34
- break;
35
- }
36
- },
37
- };
38
- };
39
- /**
40
- * Plugin which recalculates realSize on changes of sizes, originItemSize and count
41
- */
42
- const recalculateRealSizePlugin = (storeService) => {
43
- /**
44
- * Recalculates realSize if size, origin size or count changes
45
- */
46
- return {
47
- /**
48
- * Reacts on changes of count, sizes and originItemSize
49
- */
50
- set(k) {
51
- switch (k) {
52
- case 'count':
53
- case 'sizes':
54
- case 'originItemSize':
55
- // recalculate realSize
56
- let realSize = 0;
57
- const count = storeService.store.get('count');
58
- for (let i = 0; i < count; i++) {
59
- realSize +=
60
- storeService.store.get('sizes')[i] ||
61
- storeService.store.get('originItemSize');
62
- }
63
- storeService.setStore({ realSize });
64
- break;
65
- }
66
- },
67
- };
68
- };
12
+ import { recalculateRealSizePlugin } from "./dimension.recalculate.plugin";
13
+ import { trimmedPlugin } from "./dimension.trim.plugin";
69
14
  function initialBase() {
70
15
  return {
71
16
  indexes: [],
72
17
  count: 0,
73
- // plugin support
74
- trimmed: {},
75
- // size operations, this provider stores only changed sizes, not all of them
76
- // same as indexes but for sizes and positions
77
- // item index to size
18
+ // hidden items
19
+ trimmed: null,
20
+ // virtual item index to size
78
21
  sizes: {},
79
22
  // order in indexes[] to coordinate
80
23
  positionIndexToItem: {},
@@ -95,8 +38,14 @@ export class DimensionStore {
95
38
  constructor(type) {
96
39
  this.type = type;
97
40
  this.store = createStore(initialState());
98
- this.store.use(trimmedPlugin(this));
99
- this.store.use(recalculateRealSizePlugin(this));
41
+ this.store.use(trimmedPlugin({
42
+ store: this.store,
43
+ setSizes: this.setDimensionSize.bind(this),
44
+ }));
45
+ this.store.use(recalculateRealSizePlugin({
46
+ store: this.store,
47
+ setStore: this.setStore.bind(this),
48
+ }));
100
49
  }
101
50
  getCurrentState() {
102
51
  const state = initialState();
@@ -121,9 +70,40 @@ export class DimensionStore {
121
70
  * Generates new indexes based on sizes
122
71
  * @param sizes - sizes to set
123
72
  */
124
- setDimensionSize(sizes) {
73
+ setDimensionSize(sizes = {}) {
125
74
  const dimensionData = calculateDimensionData(this.store.get('originItemSize'), sizes);
126
- setStore(this.store, dimensionData);
75
+ setStore(this.store, Object.assign(Object.assign({}, dimensionData), { sizes }));
76
+ }
77
+ updateSizesPositionByIndexes(newItemsOrder, prevItemsOrder = []) {
78
+ // Move custom sizes to new order
79
+ const customSizes = Object.assign({}, this.store.get('sizes'));
80
+ if (!Object.keys(customSizes).length) {
81
+ return;
82
+ }
83
+ // Step 1: Create a map of original indices, but allow duplicates by storing arrays of indices
84
+ const originalIndices = {};
85
+ prevItemsOrder.forEach((physIndex, virtIndex) => {
86
+ if (!originalIndices[physIndex]) {
87
+ originalIndices[physIndex] = [];
88
+ }
89
+ originalIndices[physIndex].push(virtIndex); // Store all indices for each value
90
+ });
91
+ // Step 2: Create new sizes based on new item order
92
+ const newSizes = {};
93
+ newItemsOrder.forEach((physIndex, virtIndex) => {
94
+ const indices = originalIndices[physIndex]; // Get all original indices for this value
95
+ if (indices && indices.length > 0) {
96
+ const originalIndex = indices.shift(); // Get the first available original index
97
+ if (originalIndex !== undefined && originalIndex !== virtIndex && customSizes[originalIndex]) {
98
+ newSizes[virtIndex] = customSizes[originalIndex];
99
+ delete customSizes[originalIndex];
100
+ }
101
+ }
102
+ });
103
+ // Step 3: Set new sizes if there are changes
104
+ if (Object.keys(newSizes).length) {
105
+ this.setDimensionSize(Object.assign(Object.assign({}, customSizes), newSizes));
106
+ }
127
107
  }
128
108
  }
129
109
  //# sourceMappingURL=dimension.store.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"dimension.store.js","sourceRoot":"","sources":["../../../src/store/dimension/dimension.store.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,MAAM,MAAM,eAAe,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,EAAE,QAAQ,EAA+B,MAAM,yBAAyB,CAAC;AAChF,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAc7D,MAAM,aAAa,GAAG,CACpB,KAAqB,EACoB,EAAE;IAC3C,IAAI,WAAW,GAAoC,EAAE,CAAC;IAEtD,MAAM,UAAU,GAAG,CACjB,KAAsC,EACtC,OAA0C,EAC1C,EAAE;QACF,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,CAAC;YACjD,MAAM,CAAC,GAAG,KAA8C,CAAC;YACzD,IAAI,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;gBACpB,WAAW,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;gBAC5B,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC;YACpB,CAAC;QACH,CAAC;QACD,KAAK,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAClC,CAAC,CAAC;IACF,OAAO;QACL,GAAG,CAAC,GAAG,EAAE,GAAG;YACV,QAAQ,GAAG,EAAE,CAAC;gBACZ,KAAK,SAAS;oBACZ,MAAM,IAAI,GAAG,GAAwC,CAAC;oBACtD,MAAM,KAAK,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AAK,CAAC,GAAG,CAAC,gBAAgB,CAAC,EAChC,KAAK,CACN,CAAC;QACF,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC;IACtC,CAAC;CACF","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\n/**\n * Plugin which recalculates realSize on changes of sizes, originItemSize and count\n */\nconst recalculateRealSizePlugin = (\n storeService: DimensionStore,\n): PluginSubscribe<DimensionSettingsState> => {\n /**\n * Recalculates realSize if size, origin size or count changes\n */\n return {\n /**\n * Reacts on changes of count, sizes and originItemSize\n */\n set(k) {\n switch (k) {\n case 'count':\n case 'sizes':\n case 'originItemSize':\n // recalculate realSize\n let realSize = 0;\n const count = storeService.store.get('count');\n for (let i = 0; i < count; i++) {\n realSize +=\n storeService.store.get('sizes')[i] ||\n storeService.store.get('originItemSize');\n }\n storeService.setStore({ realSize });\n break;\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(public readonly type: MultiDimensionType) {\n this.store = createStore(initialState());\n this.store.use(trimmedPlugin(this));\n this.store.use(recalculateRealSizePlugin(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"]}
1
+ {"version":3,"file":"dimension.store.js","sourceRoot":"","sources":["../../../src/store/dimension/dimension.store.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,MAAM,MAAM,eAAe,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAA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AAC;gBAChC,eAAe,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC;YAClC,CAAC;YACD,eAAe,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,mCAAmC;QACjF,CAAC,CAAC,CAAC;QAEH,mDAAmD;QACnD,MAAM,QAAQ,GAA2B,EAAE,CAAC;QAE5C,aAAa,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,SAAS,EAAE,EAAE;YAC7C,MAAM,OAAO,GAAG,eAAe,CAAC,SAAS,CAAC,CAAC,CAAC,0CAA0C;YAEtF,IAAI,OAAO,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAClC,MAAM,aAAa,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,yCAAyC;gBAEhF,IAAI,aAAa,KAAK,SAAS,IAAI,aAAa,KAAK,SAAS,IAAI,WAAW,CAAC,aAAa,CAAC,EAAE,CAAC;oBAC7F,QAAQ,CAAC,SAAS,CAAC,GAAG,WAAW,CAAC,aAAa,CAAC,CAAC;oBACjD,OAAO,WAAW,CAAC,aAAa,CAAC,CAAC;gBACpC,CAAC;YACH,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,6CAA6C;QAC7C,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,MAAM,EAAE,CAAC;YACjC,IAAI,CAAC,gBAAgB,iCAChB,WAAW,GACX,QAAQ,EACX,CAAC;QACL,CAAC;IACH,CAAC;CACF","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 } from '../../utils';\nimport { calculateDimensionData } from './dimension.helpers';\nimport {\n DimensionCalc,\n DimensionSettingsState,\n ViewSettingSizeProp,\n MultiDimensionType,\n} from '@type';\nimport { recalculateRealSizePlugin } from './dimension.recalculate.plugin';\nimport { trimmedPlugin } from './dimension.trim.plugin';\n\nexport type DimensionStoreCollection = {\n [T in MultiDimensionType]: DimensionStore;\n};\n\ntype Item = keyof DimensionSettingsState;\n\nfunction initialBase(): DimensionCalc {\n return {\n indexes: [],\n count: 0,\n\n // hidden items\n trimmed: null,\n\n // virtual 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(public readonly type: MultiDimensionType) {\n this.store = createStore(initialState());\n this.store.use(trimmedPlugin({\n store: this.store,\n setSizes: this.setDimensionSize.bind(this),\n }));\n this.store.use(recalculateRealSizePlugin({\n store: this.store,\n setStore: this.setStore.bind(this),\n }));\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, {\n ...dimensionData,\n sizes,\n });\n }\n\n updateSizesPositionByIndexes(newItemsOrder: number[], prevItemsOrder: number[] = []) {\n // Move custom sizes to new order\n const customSizes = {...this.store.get('sizes')};\n if (!Object.keys(customSizes).length) {\n return;\n }\n // Step 1: Create a map of original indices, but allow duplicates by storing arrays of indices\n const originalIndices: Record<number, number[]> = {};\n prevItemsOrder.forEach((physIndex, virtIndex) => {\n if (!originalIndices[physIndex]) {\n originalIndices[physIndex] = [];\n }\n originalIndices[physIndex].push(virtIndex); // Store all indices for each value\n });\n\n // Step 2: Create new sizes based on new item order\n const newSizes: Record<number, number> = {};\n\n newItemsOrder.forEach((physIndex, virtIndex) => {\n const indices = originalIndices[physIndex]; // Get all original indices for this value\n \n if (indices && indices.length > 0) {\n const originalIndex = indices.shift(); // Get the first available original index\n\n if (originalIndex !== undefined && originalIndex !== virtIndex && customSizes[originalIndex]) {\n newSizes[virtIndex] = customSizes[originalIndex];\n delete customSizes[originalIndex];\n }\n }\n });\n\n // Step 3: Set new sizes if there are changes\n if (Object.keys(newSizes).length) {\n this.setDimensionSize({\n ...customSizes,\n ...newSizes,\n });\n }\n }\n}\n"]}