@revolist/revogrid 4.9.3 → 4.9.5

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 (124) hide show
  1. package/dist/cjs/{column.service-01f4a6c7.js → column.service-08df359f.js} +3 -3
  2. package/dist/cjs/{column.service-01f4a6c7.js.map → column.service-08df359f.js.map} +1 -1
  3. package/dist/cjs/{base.plugin-bf5f43a0.js → column.utils-0f0f4dc4.js} +127 -2
  4. package/dist/cjs/column.utils-0f0f4dc4.js.map +1 -0
  5. package/dist/cjs/{dimension.helpers-a6788214.js → dimension.helpers-85294778.js} +1 -2
  6. package/dist/cjs/dimension.helpers-85294778.js.map +1 -0
  7. package/dist/cjs/{header-cell-renderer-3bc70679.js → header-cell-renderer-fb2f9a2d.js} +2 -2
  8. package/dist/cjs/{header-cell-renderer-3bc70679.js.map → header-cell-renderer-fb2f9a2d.js.map} +1 -1
  9. package/dist/cjs/index.cjs.js +15 -9
  10. package/dist/cjs/index.cjs.js.map +1 -1
  11. package/dist/cjs/revo-grid.cjs.entry.js +80 -250
  12. package/dist/cjs/revo-grid.cjs.entry.js.map +1 -1
  13. package/dist/cjs/revogr-attribution_6.cjs.entry.js +8 -7
  14. package/dist/cjs/revogr-attribution_6.cjs.entry.js.map +1 -1
  15. package/dist/cjs/revogr-clipboard_3.cjs.entry.js +3 -3
  16. package/dist/cjs/revogr-clipboard_3.cjs.entry.js.map +1 -1
  17. package/dist/cjs/revogr-data_4.cjs.entry.js +4 -4
  18. package/dist/cjs/{selection.helpers-1a8c8d49.js → selection.helpers-371a38aa.js} +2 -2
  19. package/dist/cjs/{selection.helpers-1a8c8d49.js.map → selection.helpers-371a38aa.js.map} +1 -1
  20. package/dist/cjs/{viewport.store-35a3e7ee.js → viewport.store-300977e4.js} +2 -2
  21. package/dist/cjs/{viewport.store-35a3e7ee.js.map → viewport.store-300977e4.js.map} +1 -1
  22. package/dist/collection/components/clipboard/revogr-clipboard.js +2 -2
  23. package/dist/collection/components/clipboard/revogr-clipboard.js.map +1 -1
  24. package/dist/collection/components/editors/revogr-edit.js +1 -1
  25. package/dist/collection/components/overlay/revogr-overlay-selection.js +19 -8
  26. package/dist/collection/components/overlay/revogr-overlay-selection.js.map +1 -1
  27. package/dist/collection/components/overlay/selection.utils.js.map +1 -1
  28. package/dist/collection/components/revoGrid/revo-grid.js +12 -11
  29. package/dist/collection/components/revoGrid/revo-grid.js.map +1 -1
  30. package/dist/collection/index.js +1 -0
  31. package/dist/collection/index.js.map +1 -1
  32. package/dist/collection/plugins/base.plugin.js.map +1 -1
  33. package/dist/collection/plugins/column.auto-size.plugin.js +2 -2
  34. package/dist/collection/plugins/column.auto-size.plugin.js.map +1 -1
  35. package/dist/collection/plugins/column.stretch.plugin.js.map +1 -1
  36. package/dist/collection/plugins/groupingRow/grouping.row.plugin.js.map +1 -1
  37. package/dist/collection/plugins/moveColumn/column.drag.plugin.js +1 -1
  38. package/dist/collection/plugins/moveColumn/column.drag.plugin.js.map +1 -1
  39. package/dist/collection/plugins/sorting/sorting.plugin.js +2 -2
  40. package/dist/collection/plugins/sorting/sorting.plugin.js.map +1 -1
  41. package/dist/collection/services/column.data.provider.js +32 -88
  42. package/dist/collection/services/column.data.provider.js.map +1 -1
  43. package/dist/collection/services/dimension.provider.js +2 -2
  44. package/dist/collection/services/dimension.provider.js.map +1 -1
  45. package/dist/collection/types/interfaces.js.map +1 -1
  46. package/dist/collection/utils/column.utils.js +124 -0
  47. package/dist/collection/utils/column.utils.js.map +1 -0
  48. package/dist/esm/{column.service-5d14e7e9.js → column.service-cfc1149b.js} +3 -3
  49. package/dist/esm/{column.service-5d14e7e9.js.map → column.service-cfc1149b.js.map} +1 -1
  50. package/dist/esm/{base.plugin-5e7a3c51.js → column.utils-f6300fb5.js} +122 -3
  51. package/dist/esm/column.utils-f6300fb5.js.map +1 -0
  52. package/dist/esm/{dimension.helpers-56298828.js → dimension.helpers-938ea850.js} +2 -2
  53. package/dist/esm/dimension.helpers-938ea850.js.map +1 -0
  54. package/dist/esm/{header-cell-renderer-fc999784.js → header-cell-renderer-6f8eb067.js} +2 -2
  55. package/dist/esm/{header-cell-renderer-fc999784.js.map → header-cell-renderer-6f8eb067.js.map} +1 -1
  56. package/dist/esm/index.js +4 -4
  57. package/dist/esm/revo-grid.entry.js +49 -219
  58. package/dist/esm/revo-grid.entry.js.map +1 -1
  59. package/dist/esm/revogr-attribution_6.entry.js +8 -7
  60. package/dist/esm/revogr-attribution_6.entry.js.map +1 -1
  61. package/dist/esm/revogr-clipboard_3.entry.js +3 -3
  62. package/dist/esm/revogr-clipboard_3.entry.js.map +1 -1
  63. package/dist/esm/revogr-data_4.entry.js +4 -4
  64. package/dist/esm/{selection.helpers-accaad4a.js → selection.helpers-a49a3d09.js} +2 -2
  65. package/dist/esm/{selection.helpers-accaad4a.js.map → selection.helpers-a49a3d09.js.map} +1 -1
  66. package/dist/esm/{viewport.store-d8e03528.js → viewport.store-a690096b.js} +2 -2
  67. package/dist/esm/{viewport.store-d8e03528.js.map → viewport.store-a690096b.js.map} +1 -1
  68. package/dist/revo-grid/{column.service-5d14e7e9.js → column.service-cfc1149b.js} +2 -2
  69. package/dist/revo-grid/column.utils-f6300fb5.js +5 -0
  70. package/dist/revo-grid/column.utils-f6300fb5.js.map +1 -0
  71. package/dist/revo-grid/{dimension.helpers-56298828.js → dimension.helpers-938ea850.js} +2 -2
  72. package/dist/revo-grid/{header-cell-renderer-fc999784.js → header-cell-renderer-6f8eb067.js} +2 -2
  73. package/dist/revo-grid/index.esm.js +1 -1
  74. package/dist/revo-grid/revo-grid.entry.js +1 -1
  75. package/dist/revo-grid/revo-grid.entry.js.map +1 -1
  76. package/dist/revo-grid/revogr-attribution_6.entry.js +1 -1
  77. package/dist/revo-grid/revogr-attribution_6.entry.js.map +1 -1
  78. package/dist/revo-grid/revogr-clipboard_3.entry.js +1 -1
  79. package/dist/revo-grid/revogr-clipboard_3.entry.js.map +1 -1
  80. package/dist/revo-grid/revogr-data_4.entry.js +1 -1
  81. package/dist/revo-grid/{selection.helpers-accaad4a.js → selection.helpers-a49a3d09.js} +2 -2
  82. package/dist/revo-grid/{viewport.store-d8e03528.js → viewport.store-a690096b.js} +2 -2
  83. package/dist/types/components/overlay/revogr-overlay-selection.d.ts +6 -2
  84. package/dist/types/components/overlay/selection.utils.d.ts +2 -1
  85. package/dist/types/components/revoGrid/revo-grid.d.ts +2 -1
  86. package/dist/types/components.d.ts +8 -6
  87. package/dist/types/index.d.ts +1 -0
  88. package/dist/types/plugins/base.plugin.d.ts +1 -1
  89. package/dist/types/plugins/column.auto-size.plugin.d.ts +1 -2
  90. package/dist/types/plugins/column.stretch.plugin.d.ts +2 -4
  91. package/dist/types/services/column.data.provider.d.ts +2 -13
  92. package/dist/types/services/dimension.provider.d.ts +0 -1
  93. package/dist/types/types/interfaces.d.ts +11 -11
  94. package/dist/types/utils/column.utils.d.ts +46 -0
  95. package/hydrate/index.js +304 -354
  96. package/hydrate/index.mjs +304 -354
  97. package/package.json +1 -1
  98. package/standalone/column.service.js +1 -1
  99. package/standalone/data.store.js +1 -1
  100. package/standalone/data.store.js.map +1 -1
  101. package/standalone/dimension.helpers.js +1 -1
  102. package/standalone/index.js +1 -1
  103. package/standalone/revo-grid.js +165 -216
  104. package/standalone/revo-grid.js.map +1 -1
  105. package/standalone/revogr-clipboard2.js +2 -2
  106. package/standalone/revogr-clipboard2.js.map +1 -1
  107. package/standalone/revogr-header2.js +1 -1
  108. package/standalone/revogr-overlay-selection2.js +4 -3
  109. package/standalone/revogr-overlay-selection2.js.map +1 -1
  110. package/standalone/selection.utils.js.map +1 -1
  111. package/dist/cjs/base.plugin-bf5f43a0.js.map +0 -1
  112. package/dist/cjs/dimension.helpers-a6788214.js.map +0 -1
  113. package/dist/collection/plugins/groupingColumn/grouping.col.plugin.js +0 -43
  114. package/dist/collection/plugins/groupingColumn/grouping.col.plugin.js.map +0 -1
  115. package/dist/esm/base.plugin-5e7a3c51.js.map +0 -1
  116. package/dist/esm/dimension.helpers-56298828.js.map +0 -1
  117. package/dist/revo-grid/base.plugin-5e7a3c51.js +0 -5
  118. package/dist/revo-grid/base.plugin-5e7a3c51.js.map +0 -1
  119. package/dist/types/plugins/groupingColumn/grouping.col.plugin.d.ts +0 -17
  120. /package/dist/revo-grid/{column.service-5d14e7e9.js.map → column.service-cfc1149b.js.map} +0 -0
  121. /package/dist/revo-grid/{dimension.helpers-56298828.js.map → dimension.helpers-938ea850.js.map} +0 -0
  122. /package/dist/revo-grid/{header-cell-renderer-fc999784.js.map → header-cell-renderer-6f8eb067.js.map} +0 -0
  123. /package/dist/revo-grid/{selection.helpers-accaad4a.js.map → selection.helpers-a49a3d09.js.map} +0 -0
  124. /package/dist/revo-grid/{viewport.store-d8e03528.js.map → viewport.store-a690096b.js.map} +0 -0
@@ -1 +1 @@
1
- {"file":"revogr-clipboard.revogr-edit.revogr-order-editor.entry.js","mappings":";;;;;;;;;;MAaa,SAAS;;;;;;;;;;;;;;IAkFqB,OAAO,CAAC,CAAiB;;QAEhE,IAAI,IAAI,CAAC,QAAQ,EAAE;YACjB,OAAO;SACR;QACD,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QACtC,MAAM,MAAM,GAAG,CAAC,CAAA,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,KAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;QACtE,MAAM,IAAI,GAAG,CAAC,MAAM;cAChB,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,OAAO,CAAC,WAAW,CAAC;cACnC,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QAC1C,MAAM,QAAQ,GAAG,CAAA,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,OAAO,CAAC,MAAM,CAAC,KAAI,EAAE,CAAC;QAEtD,MAAM,WAAW,GAA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-clipboard.tsx","src/components/editors/text-editor.tsx","src/components/editors/revogr-edit-style.scss?tag=revogr-edit","src/components/editors/revogr-edit.tsx","src/components/order/order-row.service.ts","src/components/order/revogr-order-editor.tsx"],"sourcesContent":["import {\n Component,\n Listen,\n Method,\n Event,\n EventEmitter,\n Prop,\n} from '@stencil/core';\nimport { DataFormat } from '@type';\n/**\n * This Clipboard provides functionality for handling clipboard events in a web application.\n */\n@Component({ tag: 'revogr-clipboard' })\nexport class Clipboard {\n /**\n * If readonly mode - disabled Paste event\n */\n @Prop() readonly: boolean;\n\n /**\n * Paste 1. Fired before paste applied to the grid\n * defaultPrevented - if true, paste will be canceled\n */\n @Event({ eventName: 'beforepaste' }) beforePaste: EventEmitter<{\n raw: string;\n isHTML: boolean;\n event: ClipboardEvent;\n dataText: string;\n }>;\n\n /**\n * Paste 2. Fired before paste applied to the grid and after data parsed\n */\n @Event({ eventName: 'beforepasteapply' })\n beforePasteApply: EventEmitter<{\n raw: string;\n parsed: string[][];\n event: ClipboardEvent;\n }>;\n\n /**\n * Paste 3. Internal method. When data region is ready pass it to the top.\n * @property {string[][]} data - data to paste\n * @property {boolean} defaultPrevented - if true, paste will be canceled\n */\n @Event({ eventName: 'pasteregion', bubbles: false })\n pasteRegion: EventEmitter<string[][]>;\n\n /**\n * Paste 4. Fired after paste applied to the grid\n * defaultPrevented - if true, paste will be canceled\n */\n @Event({ eventName: 'afterpasteapply' }) afterPasteApply: EventEmitter<{\n raw: string;\n parsed: string[][];\n event: ClipboardEvent;\n }>;\n\n /**\n * Cut 1. Fired before cut triggered\n * defaultPrevented - if true, cut will be canceled\n */\n @Event({ eventName: 'beforecut' }) beforeCut: EventEmitter<{\n event: ClipboardEvent;\n }>;\n\n /**\n * Cut 2. Clears region when cut is done\n */\n @Event({ eventName: 'clearregion' }) clearRegion: EventEmitter<DataTransfer>;\n\n /**\n * Copy 1. Fired before copy triggered\n * defaultPrevented - if true, copy will be canceled\n */\n @Event({ eventName: 'beforecopy' }) beforeCopy: EventEmitter<{\n event: ClipboardEvent;\n }>;\n\n /**\n * Copy Method 1. Fired before copy applied to the clipboard from outside.\n * defaultPrevented - if true, copy will be canceled\n */\n @Event({ eventName: 'beforecopyapply' }) beforeCopyApply: EventEmitter<{\n event: DataTransfer;\n data?: string[][];\n }>;\n\n /**\n * Copy 2. Fired when region copied\n * defaultPrevented - if true, copy will be canceled\n */\n @Event({ eventName: 'copyregion', bubbles: false })\n copyRegion: EventEmitter<DataTransfer>;\n\n @Listen('paste', { target: 'document' }) onPaste(e: ClipboardEvent) {\n // if readonly do nothing\n if (this.readonly) {\n return;\n }\n const clipboardData = this.getData(e);\n const isHTML = (clipboardData?.types.indexOf('text/html') || -1) > -1;\n const data = (isHTML\n ? clipboardData?.getData('text/html')\n : clipboardData?.getData('text')) || '';\n const dataText = clipboardData?.getData('text') || '';\n\n const beforePaste = this.beforePaste.emit({\n raw: data,\n dataText,\n isHTML,\n event: e,\n });\n\n if (beforePaste.defaultPrevented) {\n return;\n }\n\n let parsedData: string[][];\n // if html, then search for table if no table fallback to regular text parsing\n if (beforePaste.detail.isHTML) {\n const table = this.htmlParse(beforePaste.detail.raw);\n // fallback to text if not possible to parse as html\n parsedData = table || this.textParse(dataText || '');\n } else {\n parsedData = this.textParse(beforePaste.detail.raw);\n }\n const beforePasteApply = this.beforePasteApply.emit({\n raw: data,\n parsed: parsedData,\n event: e,\n });\n if (beforePasteApply.defaultPrevented) {\n return;\n }\n this.pasteRegion.emit(beforePasteApply.detail.parsed);\n // post paste action\n const afterPasteApply = this.afterPasteApply.emit({\n raw: data,\n parsed: parsedData,\n event: e,\n });\n // keep default behavior if needed\n if (afterPasteApply.defaultPrevented) {\n return;\n }\n e.preventDefault();\n }\n\n /**\n * Listen to copy event and emit copy region event\n */\n @Listen('copy', { target: 'document' }) copyStarted(e: ClipboardEvent) {\n const beforeCopy = this.beforeCopy.emit({\n event: e,\n });\n if (beforeCopy.defaultPrevented) {\n return;\n }\n const data = this.getData(beforeCopy.detail.event);\n this.copyRegion.emit(data || undefined);\n e.preventDefault();\n }\n\n /**\n * Listen to copy event and emit copy region event\n */\n @Listen('cut', { target: 'document' }) cutStarted(e: ClipboardEvent) {\n const beforeCut = this.beforeCut.emit({\n event: e,\n });\n if (beforeCut.defaultPrevented) {\n return;\n }\n const data = this.getData(beforeCut.detail.event);\n this.copyStarted(e);\n\n // if readonly do nothing\n if (this.readonly) {\n return;\n }\n\n this.clearRegion.emit(data || undefined);\n e.preventDefault();\n }\n\n @Method() async doCopy(e: DataTransfer, data?: DataFormat[][]) {\n const beforeCopyApply = this.beforeCopyApply.emit({\n event: e,\n data,\n });\n if (beforeCopyApply.defaultPrevented) {\n return;\n }\n const parsed = data ? this.parserCopy(data) : '';\n e.setData('text/plain', parsed);\n }\n\n parserCopy(data: DataFormat[][]) {\n return data.map(rgRow => rgRow.join('\\t')).join('\\n');\n }\n\n private textParse(data: string) {\n const result: string[][] = [];\n const rows = data.split(/\\r\\n|\\n|\\r/);\n for (let y in rows) {\n result.push(rows[y].split('\\t'));\n }\n return result;\n }\n\n private htmlParse(data: string) {\n const result: string[][] = [];\n const fragment = document.createRange().createContextualFragment(data);\n const table = fragment.querySelector('table');\n if (!table) {\n return null;\n }\n for (const rgRow of Array.from(table.rows)) {\n result.push(Array.from(rgRow.cells).map(cell => cell.innerText));\n }\n return result;\n }\n\n private getData(e: ClipboardEvent) {\n return (\n e.clipboardData ||\n (window as unknown as { clipboardData: DataTransfer | null })\n ?.clipboardData\n );\n }\n}\n","import { VNode, h as createElement } from '@stencil/core';\nimport { isEnterKeyValue, isTab } from '../../utils/key.utils';\nimport { timeout } from '../../utils';\nimport { ColumnRegular } from '@type';\nimport { EditCell, EditorBase, SaveData } from '@type';\n\n/**\n * Represents a cell editor in a grid.\n *\n * It's a good place to start with your own editor.\n * It manages the editing of cells by handling events, saving data, rendering the editor UI, and managing the lifecycle of the editor instance.\n */\n\n/**\n * Callback triggered on cell editor save\n * Closes editor when called\n * @param preventFocus - if true editor will not be closed and next cell will not be focused\n */\nexport type SaveCallback = (value: SaveData | undefined, preventFocus: boolean) => void;\n\nexport class TextEditor implements EditorBase {\n private editInput: HTMLInputElement | null = null;\n\n public element: Element | null = null;\n public editCell?: EditCell = undefined;\n\n constructor(\n public column: ColumnRegular,\n private saveCallback?: SaveCallback,\n ) {}\n\n /**\n * Callback triggered on cell editor render\n */\n async componentDidRender(): Promise<void> {\n if (this.editInput) {\n await timeout();\n this.editInput?.focus();\n }\n }\n\n private onKeyDown(e: KeyboardEvent) {\n const isEnter = isEnterKeyValue(e.key);\n const isKeyTab = isTab(e.key);\n\n if (\n (isKeyTab || isEnter) &&\n e.target &&\n this.saveCallback &&\n !e.isComposing\n ) {\n // blur is needed to avoid autoscroll\n this.beforeDisconnect();\n // request callback which will close cell after all\n this.saveCallback(this.getValue(), isKeyTab);\n }\n }\n\n /**\n * IMPORTANT: Prevent scroll glitches when editor is closed and focus is on current input element.\n */\n beforeDisconnect() {\n this.editInput?.blur();\n }\n\n /**\n * Get value from input\n */\n getValue() {\n return this.editInput?.value;\n }\n\n /**\n * Render method for Editor plugin.\n * Renders input element with passed data from cell.\n *\n * @required @method\n * @param {Function} h - h function from stencil render.\n * @param {Object} _additionalData - additional data from plugin.\n * @returns {VNode} - input element.\n */\n render(h: typeof createElement, _additionalData: any): VNode | VNode[] {\n return h('input', {\n type: 'text',\n enterKeyHint: 'enter',\n // set input value from cell data\n value: this.editCell?.val ?? '',\n // save input element as ref for further usage\n ref: (el: HTMLInputElement | null) => {\n this.editInput = el;\n },\n // listen to keydown event on input element\n onKeyDown: (e: KeyboardEvent) => this.onKeyDown(e),\n });\n }\n}\n","revogr-edit {\n display: block;\n position: absolute;\n background-color: #fff;\n\n input {\n height: 100%;\n width: 100%;\n box-sizing: border-box;\n }\n\n revo-dropdown {\n height: 100%;\n\n &.shrink {\n fieldset legend > span {\n display: none;\n }\n }\n }\n}\n","import {\n Component,\n Event,\n EventEmitter,\n Prop,\n h,\n Element,\n Host,\n Method,\n} from '@stencil/core';\nimport { EDIT_INPUT_WR } from '../../utils/consts';\nimport { TextEditor } from './text-editor';\nimport { ColumnDataSchemaModel } from '@type';\nimport {\n EditCell,\n EditorCtr,\n SaveDataDetails,\n EditorBase,\n SaveData,\n} from '@type';\n\nimport { isEditorCtrConstructible } from './edit.utils';\n\n/**\n * Represents a cell editor in a grid.\n * It manages the editing of cells by handling events, saving data, rendering the editor UI,\n * and managing the lifecycle of the editor instance.\n */\n@Component({\n tag: 'revogr-edit',\n styleUrl: 'revogr-edit-style.scss',\n})\nexport class RevoEdit {\n /**\n * Cell to edit data.\n */\n @Prop() editCell: EditCell;\n\n /**\n * Column data for editor.\n */\n @Prop() column: ColumnDataSchemaModel | null;\n /**\n * Custom editors register\n */\n @Prop() editor: EditorCtr | null;\n\n /**\n * Save on editor close. Defines if data should be saved on editor close.\n */\n @Prop() saveOnClose = false;\n /**\n * Additional data to pass to renderer\n */\n @Prop() additionalData: any;\n\n /**\n * Cell edit event\n */\n @Event({ eventName: 'celledit' }) cellEdit: EventEmitter<SaveDataDetails>;\n\n /**\n * Close editor event\n * pass true if requires focus next\n */\n @Event({ eventName: 'closeedit' }) closeEdit: EventEmitter<\n boolean | undefined\n >;\n\n /** Edit session editor */\n @Element() element: HTMLElement;\n private currentEditor: EditorBase | null = null;\n private preventSaveOnClose = false;\n\n /**\n * Cancel pending changes flag. Editor will be closed without autosave.\n */\n @Method() async cancelChanges() {\n this.preventSaveOnClose = true;\n }\n\n /**\n * Before editor got disconnected.\n * Can be triggered multiple times before actual disconnect.\n */\n @Method() async beforeDisconnect() {\n this.currentEditor?.beforeDisconnect?.();\n }\n\n onAutoSave() {\n this.preventSaveOnClose = true;\n const val = this.currentEditor?.getValue?.();\n // For Editor plugin internal usage.\n // When you want to prevent save and use custom save of your own.\n if (this.currentEditor?.beforeAutoSave) {\n const canSave = this.currentEditor.beforeAutoSave(val);\n if (canSave === false) {\n return;\n }\n }\n this.onSave(val, true);\n }\n\n /**\n * Callback triggered when cell editor saved.\n * Closes editor when called.\n * @param preventFocus - if true, editor will not be closed & next cell will not be focused.\n */\n onSave(val?: SaveData, preventFocus?: boolean) {\n this.preventSaveOnClose = true;\n if (this.editCell) {\n this.cellEdit.emit({\n rgCol: this.editCell.x,\n rgRow: this.editCell.y,\n type: this.editCell.type,\n prop: this.editCell.prop,\n val,\n preventFocus,\n });\n }\n }\n\n componentWillRender() {\n // Active editor present and not yet closed.\n if (this.currentEditor || !this.column) {\n return;\n }\n this.preventSaveOnClose = false;\n\n // Custom editor usage.\n // Start with TextEditor (editors/text.tsx) for Custom editor.\n // It can be class or function\n if (this.editor) {\n // if editor is constructible\n if (isEditorCtrConstructible(this.editor)) {\n this.currentEditor = new this.editor(\n this.column,\n // save callback\n (e, preventFocus) => {\n this.onSave(e, preventFocus);\n },\n // cancel callback\n focusNext => {\n this.preventSaveOnClose = true;\n this.closeEdit.emit(focusNext);\n },\n );\n // if editor is function\n } else {\n this.currentEditor = this.editor(\n this.column,\n // save callback\n (e, preventFocus) => {\n this.onSave(e, preventFocus);\n },\n // cancel callback\n focusNext => {\n this.preventSaveOnClose = true;\n this.closeEdit.emit(focusNext);\n },\n );\n }\n return;\n }\n // Default text editor usage\n this.currentEditor = new TextEditor(this.column, (e, preventFocus) =>\n this.onSave(e, preventFocus),\n );\n }\n\n componentDidRender() {\n if (!this.currentEditor) {\n return;\n }\n this.currentEditor.element = this.element.firstElementChild;\n this.currentEditor.componentDidRender?.();\n }\n\n disconnectedCallback() {\n if (this.saveOnClose) {\n // Can not be cancelled by `preventSaveOnClose` prop.\n // Editor requires `getValue` to be able to save.\n if (!this.preventSaveOnClose) {\n this.onAutoSave();\n }\n }\n\n this.preventSaveOnClose = false;\n if (!this.currentEditor) {\n return;\n }\n\n this.currentEditor.disconnectedCallback?.();\n this.currentEditor.element = null;\n this.currentEditor = null;\n }\n\n render() {\n if (this.currentEditor) {\n this.currentEditor.editCell = this.editCell;\n return (\n <Host class={EDIT_INPUT_WR}>\n {this.currentEditor.render(h, this.additionalData)}\n </Host>\n );\n }\n return '';\n }\n}\n","import { getItemByPosition } from '@store';\nimport { DimensionSettingsState, PositionItem, Cell } from '@type';\n\ntype EventData = { el: HTMLElement; rows: DimensionSettingsState; cols: DimensionSettingsState };\ninterface Config {\n positionChanged(from: number, to: number): void;\n}\n\nexport default class RowOrderService {\n private currentCell: Cell | null = null;\n private previousRow: number | null = null;\n\n constructor(private config: Config) {}\n\n /** Drag finished, calculate and apply changes */\n endOrder(e: MouseEvent, data: EventData) {\n if (this.currentCell === null) {\n return;\n }\n const newRow = this.getCell(e, data);\n\n // if position changed\n if (newRow.y !== this.currentCell.y) {\n // rgRow dragged out table\n if (newRow.y < 0) {\n newRow.y = 0;\n }\n // rgRow dragged to the top\n else if (newRow.y < this.currentCell.y) {\n newRow.y++;\n }\n this.config.positionChanged(this.currentCell.y, newRow.y);\n }\n this.clear();\n }\n\n /** Drag started, reserve initial cell for farther use */\n startOrder(e: MouseEvent, data: EventData): Cell {\n this.currentCell = this.getCell(e, data);\n return this.currentCell;\n }\n\n move(y: number, data: EventData): PositionItem | null {\n const rgRow = this.getRow(y, data);\n // if rgRow same as previous or below range (-1 = 0) do nothing\n if (this.previousRow === rgRow.itemIndex || rgRow.itemIndex < -1) {\n return null;\n }\n this.previousRow = rgRow.itemIndex;\n return rgRow;\n }\n\n /** Drag stopped, probably cursor outside of document area */\n clear() {\n this.currentCell = null;\n this.previousRow = null;\n }\n\n /** Calculate cell based on x, y position */\n getRow(y: number, { el, rows }: EventData): PositionItem {\n const { top } = el.getBoundingClientRect();\n const topRelative = y - top;\n const rgRow = getItemByPosition(rows, topRelative);\n const absolutePosition = {\n itemIndex: rgRow.itemIndex,\n start: rgRow.start + top,\n end: rgRow.end + top,\n };\n return absolutePosition;\n }\n\n /** Calculate cell based on x, y position */\n getCell({ x, y }: Cell, { el, rows, cols }: EventData): Cell {\n const { top, left } = el.getBoundingClientRect();\n const topRelative = y - top;\n const leftRelative = x - left;\n const rgRow = getItemByPosition(rows, topRelative);\n const rgCol = getItemByPosition(cols, leftRelative);\n return { x: rgCol.itemIndex, y: rgRow.itemIndex };\n }\n}\n","import { Component, Method, Event, EventEmitter, Prop } from '@stencil/core';\nimport debounce from 'lodash/debounce';\n\nimport { DSourceState, setItems } from '@store';\nimport { DRAGG_TEXT } from '../../utils/consts';\nimport RowOrderService from './order-row.service';\nimport {\n DimensionRows,\n DataType,\n DimensionSettingsState,\n DragStartEvent,\n PositionItem,\n Cell,\n} from '@type';\nimport { Observable } from '../../utils/store.utils';\n\n/**\n * Component for handling row order editor.\n */\n@Component({ tag: 'revogr-order-editor' })\nexport class OrderEditor {\n // #region Properties\n /** Parent element */\n @Prop() parent: HTMLElement;\n /** Dimension settings Y */\n @Prop() dimensionRow: Observable<DimensionSettingsState>;\n /** Dimension settings X */\n @Prop() dimensionCol: Observable<DimensionSettingsState>;\n\n /** Static stores, not expected to change during component lifetime */\n @Prop() dataStore: Observable<DSourceState<DataType, DimensionRows>>;\n // #endregion\n\n // #region Events\n /** Row drag started */\n @Event({ eventName: 'rowdragstartinit', cancelable: true })\n rowDragStart: EventEmitter<{\n cell: Cell;\n text: string;\n pos: PositionItem;\n event: MouseEvent;\n }>;\n\n /** Row drag ended started */\n @Event({ eventName: 'rowdragendinit' })\n rowDragEnd: EventEmitter;\n\n /** Row move started */\n @Event({ eventName: 'rowdragmoveinit', cancelable: true })\n rowDrag: EventEmitter<PositionItem>;\n\n /** Row mouse move started */\n @Event({ eventName: 'rowdragmousemove', cancelable: true })\n rowMouseMove: EventEmitter<Cell>;\n\n /** Row dragged, new range ready to be applied */\n @Event({ eventName: 'rowdropinit', cancelable: true })\n rowDropped: EventEmitter<{\n from: number;\n to: number;\n }>;\n // #endregion\n\n // #region Private\n private rowOrderService: RowOrderService;\n private events: {\n name: keyof DocumentEventMap;\n listener: (e: MouseEvent) => void;\n }[] = [];\n private rowMoveFunc = debounce((y: number) => {\n const rgRow = this.rowOrderService.move(y, this.getData());\n if (rgRow !== null) {\n this.rowDrag.emit(rgRow);\n }\n }, 5);\n // #endregion\n\n // #region Methods\n @Method() async dragStart(e: DragStartEvent) {\n e.originalEvent.preventDefault();\n\n // extra check if previous ended\n if (this.events.length) {\n this.clearOrder();\n }\n\n const data = this.getData();\n const cell = this.rowOrderService.startOrder(e.originalEvent, data);\n const pos = this.rowOrderService.getRow(e.originalEvent.y, data);\n const dragStartEvent = this.rowDragStart.emit({\n cell,\n text: DRAGG_TEXT,\n pos,\n event: e.originalEvent,\n });\n if (dragStartEvent.defaultPrevented) {\n return;\n }\n\n const moveMove = (e: MouseEvent) => this.move(e);\n const mouseUp = (e: MouseEvent) => this.endOrder(e);\n const mouseLeave = () => this.clearOrder();\n\n this.events.push(\n {\n name: 'mousemove',\n listener: moveMove,\n },\n {\n name: 'mouseup',\n listener: mouseUp,\n },\n {\n name: 'mouseleave',\n listener: mouseLeave,\n },\n );\n document.addEventListener('mousemove', moveMove);\n // Action finished inside of the document\n document.addEventListener('mouseup', mouseUp);\n document.addEventListener('mouseleave', mouseLeave);\n }\n\n @Method() async endOrder(e: MouseEvent) {\n this.rowOrderService.endOrder(e, this.getData());\n this.clearOrder();\n }\n\n @Method() async clearOrder() {\n this.rowOrderService.clear();\n this.events.forEach(v => document.removeEventListener(v.name, v.listener));\n this.events.length = 0;\n this.rowDragEnd.emit();\n }\n // #endregion\n\n move({ x, y }: { x: number; y: number }) {\n this.rowMouseMove.emit({ x, y });\n this.rowMoveFunc(y);\n }\n\n connectedCallback() {\n this.rowOrderService = new RowOrderService({\n positionChanged: (f, t) => this.onPositionChanged(f, t),\n });\n }\n\n private onPositionChanged(from: number, to: number) {\n const dropEvent = this.rowDropped.emit({ from, to });\n if (dropEvent.defaultPrevented) {\n return;\n }\n const items = [...this.dataStore.get('items')];\n const toMove = items.splice(from, 1);\n items.splice(to, 0, ...toMove);\n setItems(this.dataStore, items);\n }\n\n private getData() {\n return {\n el: this.parent,\n rows: this.dimensionRow.state,\n cols: this.dimensionCol.state,\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AAC;KACJ;IAEO,iBAAiB,CAAC,IAAY,EAAE,EAAU;QAChD,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;QACrD,IAAI,SAAS,CAAC,gBAAgB,EAAE;YAC9B,OAAO;SACR;QACD,MAAM,KAAK,GAAG,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;QAC/C,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;QACrC,KAAK,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC,EAAE,GAAG,MAAM,CAAC,CAAC;QAC/B,QAAQ,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;KACjC;IAEO,OAAO;QACb,OAAO;YACL,EAAE,EAAE,IAAI,CAAC,MAAM;YACf,IAAI,EAAE,IAAI,CAAC,YAAY,CAAC,KAAK;YAC7B,IAAI,EAAE,IAAI,CAAC,YAAY,CAAC,KAAK;SAC9B,CAAC;KACH;;;;;","names":["debounce"],"sources":["src/components/clipboard/revogr-clipboard.tsx","src/components/editors/text-editor.tsx","src/components/editors/revogr-edit-style.scss?tag=revogr-edit","src/components/editors/revogr-edit.tsx","src/components/order/order-row.service.ts","src/components/order/revogr-order-editor.tsx"],"sourcesContent":["import {\n Component,\n Listen,\n Method,\n Event,\n EventEmitter,\n Prop,\n} from '@stencil/core';\nimport { DataFormat } from '@type';\n/**\n * This Clipboard provides functionality for handling clipboard events in a web application.\n */\n@Component({ tag: 'revogr-clipboard' })\nexport class Clipboard {\n /**\n * If readonly mode - disabled Paste event\n */\n @Prop() readonly: boolean;\n\n /**\n * Paste 1. Fired before paste applied to the grid\n * defaultPrevented - if true, paste will be canceled\n */\n @Event({ eventName: 'beforepaste' }) beforePaste: EventEmitter<{\n raw: string;\n isHTML: boolean;\n event: ClipboardEvent;\n dataText: string;\n }>;\n\n /**\n * Paste 2. Fired before paste applied to the grid and after data parsed\n */\n @Event({ eventName: 'beforepasteapply' })\n beforePasteApply: EventEmitter<{\n raw: string;\n parsed: string[][];\n event: ClipboardEvent;\n }>;\n\n /**\n * Paste 3. Internal method. When data region is ready pass it to the top.\n * @property {string[][]} data - data to paste\n * @property {boolean} defaultPrevented - if true, paste will be canceled\n */\n @Event({ eventName: 'pasteregion' })\n pasteRegion: EventEmitter<string[][]>;\n\n /**\n * Paste 4. Fired after paste applied to the grid\n * defaultPrevented - if true, paste will be canceled\n */\n @Event({ eventName: 'afterpasteapply' }) afterPasteApply: EventEmitter<{\n raw: string;\n parsed: string[][];\n event: ClipboardEvent;\n }>;\n\n /**\n * Cut 1. Fired before cut triggered\n * defaultPrevented - if true, cut will be canceled\n */\n @Event({ eventName: 'beforecut' }) beforeCut: EventEmitter<{\n event: ClipboardEvent;\n }>;\n\n /**\n * Cut 2. Clears region when cut is done\n */\n @Event({ eventName: 'clearregion' }) clearRegion: EventEmitter<DataTransfer>;\n\n /**\n * Copy 1. Fired before copy triggered\n * defaultPrevented - if true, copy will be canceled\n */\n @Event({ eventName: 'beforecopy' }) beforeCopy: EventEmitter<{\n event: ClipboardEvent;\n }>;\n\n /**\n * Copy Method 1. Fired before copy applied to the clipboard from outside.\n * defaultPrevented - if true, copy will be canceled\n */\n @Event({ eventName: 'beforecopyapply' }) beforeCopyApply: EventEmitter<{\n event: DataTransfer;\n data?: string[][];\n }>;\n\n /**\n * Copy 2. Fired when region copied\n * defaultPrevented - if true, copy will be canceled\n */\n @Event({ eventName: 'copyregion' })\n copyRegion: EventEmitter<DataTransfer>;\n\n @Listen('paste', { target: 'document' }) onPaste(e: ClipboardEvent) {\n // if readonly do nothing\n if (this.readonly) {\n return;\n }\n const clipboardData = this.getData(e);\n const isHTML = (clipboardData?.types.indexOf('text/html') || -1) > -1;\n const data = (isHTML\n ? clipboardData?.getData('text/html')\n : clipboardData?.getData('text')) || '';\n const dataText = clipboardData?.getData('text') || '';\n\n const beforePaste = this.beforePaste.emit({\n raw: data,\n dataText,\n isHTML,\n event: e,\n });\n\n if (beforePaste.defaultPrevented) {\n return;\n }\n\n let parsedData: string[][];\n // if html, then search for table if no table fallback to regular text parsing\n if (beforePaste.detail.isHTML) {\n const table = this.htmlParse(beforePaste.detail.raw);\n // fallback to text if not possible to parse as html\n parsedData = table || this.textParse(dataText || '');\n } else {\n parsedData = this.textParse(beforePaste.detail.raw);\n }\n const beforePasteApply = this.beforePasteApply.emit({\n raw: data,\n parsed: parsedData,\n event: e,\n });\n if (beforePasteApply.defaultPrevented) {\n return;\n }\n this.pasteRegion.emit(beforePasteApply.detail.parsed);\n // post paste action\n const afterPasteApply = this.afterPasteApply.emit({\n raw: data,\n parsed: parsedData,\n event: e,\n });\n // keep default behavior if needed\n if (afterPasteApply.defaultPrevented) {\n return;\n }\n e.preventDefault();\n }\n\n /**\n * Listen to copy event and emit copy region event\n */\n @Listen('copy', { target: 'document' }) copyStarted(e: ClipboardEvent) {\n const beforeCopy = this.beforeCopy.emit({\n event: e,\n });\n if (beforeCopy.defaultPrevented) {\n return;\n }\n const data = this.getData(beforeCopy.detail.event);\n this.copyRegion.emit(data || undefined);\n e.preventDefault();\n }\n\n /**\n * Listen to copy event and emit copy region event\n */\n @Listen('cut', { target: 'document' }) cutStarted(e: ClipboardEvent) {\n const beforeCut = this.beforeCut.emit({\n event: e,\n });\n if (beforeCut.defaultPrevented) {\n return;\n }\n const data = this.getData(beforeCut.detail.event);\n this.copyStarted(e);\n\n // if readonly do nothing\n if (this.readonly) {\n return;\n }\n\n this.clearRegion.emit(data || undefined);\n e.preventDefault();\n }\n\n @Method() async doCopy(e: DataTransfer, data?: DataFormat[][]) {\n const beforeCopyApply = this.beforeCopyApply.emit({\n event: e,\n data,\n });\n if (beforeCopyApply.defaultPrevented) {\n return;\n }\n const parsed = data ? this.parserCopy(data) : '';\n e.setData('text/plain', parsed);\n }\n\n parserCopy(data: DataFormat[][]) {\n return data.map(rgRow => rgRow.join('\\t')).join('\\n');\n }\n\n private textParse(data: string) {\n const result: string[][] = [];\n const rows = data.split(/\\r\\n|\\n|\\r/);\n for (let y in rows) {\n result.push(rows[y].split('\\t'));\n }\n return result;\n }\n\n private htmlParse(data: string) {\n const result: string[][] = [];\n const fragment = document.createRange().createContextualFragment(data);\n const table = fragment.querySelector('table');\n if (!table) {\n return null;\n }\n for (const rgRow of Array.from(table.rows)) {\n result.push(Array.from(rgRow.cells).map(cell => cell.innerText));\n }\n return result;\n }\n\n private getData(e: ClipboardEvent) {\n return (\n e.clipboardData ||\n (window as unknown as { clipboardData: DataTransfer | null })\n ?.clipboardData\n );\n }\n}\n","import { VNode, h as createElement } from '@stencil/core';\nimport { isEnterKeyValue, isTab } from '../../utils/key.utils';\nimport { timeout } from '../../utils';\nimport { ColumnRegular } from '@type';\nimport { EditCell, EditorBase, SaveData } from '@type';\n\n/**\n * Represents a cell editor in a grid.\n *\n * It's a good place to start with your own editor.\n * It manages the editing of cells by handling events, saving data, rendering the editor UI, and managing the lifecycle of the editor instance.\n */\n\n/**\n * Callback triggered on cell editor save\n * Closes editor when called\n * @param preventFocus - if true editor will not be closed and next cell will not be focused\n */\nexport type SaveCallback = (value: SaveData | undefined, preventFocus: boolean) => void;\n\nexport class TextEditor implements EditorBase {\n private editInput: HTMLInputElement | null = null;\n\n public element: Element | null = null;\n public editCell?: EditCell = undefined;\n\n constructor(\n public column: ColumnRegular,\n private saveCallback?: SaveCallback,\n ) {}\n\n /**\n * Callback triggered on cell editor render\n */\n async componentDidRender(): Promise<void> {\n if (this.editInput) {\n await timeout();\n this.editInput?.focus();\n }\n }\n\n private onKeyDown(e: KeyboardEvent) {\n const isEnter = isEnterKeyValue(e.key);\n const isKeyTab = isTab(e.key);\n\n if (\n (isKeyTab || isEnter) &&\n e.target &&\n this.saveCallback &&\n !e.isComposing\n ) {\n // blur is needed to avoid autoscroll\n this.beforeDisconnect();\n // request callback which will close cell after all\n this.saveCallback(this.getValue(), isKeyTab);\n }\n }\n\n /**\n * IMPORTANT: Prevent scroll glitches when editor is closed and focus is on current input element.\n */\n beforeDisconnect() {\n this.editInput?.blur();\n }\n\n /**\n * Get value from input\n */\n getValue() {\n return this.editInput?.value;\n }\n\n /**\n * Render method for Editor plugin.\n * Renders input element with passed data from cell.\n *\n * @required @method\n * @param {Function} h - h function from stencil render.\n * @param {Object} _additionalData - additional data from plugin.\n * @returns {VNode} - input element.\n */\n render(h: typeof createElement, _additionalData: any): VNode | VNode[] {\n return h('input', {\n type: 'text',\n enterKeyHint: 'enter',\n // set input value from cell data\n value: this.editCell?.val ?? '',\n // save input element as ref for further usage\n ref: (el: HTMLInputElement | null) => {\n this.editInput = el;\n },\n // listen to keydown event on input element\n onKeyDown: (e: KeyboardEvent) => this.onKeyDown(e),\n });\n }\n}\n","revogr-edit {\n display: block;\n position: absolute;\n background-color: #fff;\n\n input {\n height: 100%;\n width: 100%;\n box-sizing: border-box;\n }\n\n revo-dropdown {\n height: 100%;\n\n &.shrink {\n fieldset legend > span {\n display: none;\n }\n }\n }\n}\n","import {\n Component,\n Event,\n EventEmitter,\n Prop,\n h,\n Element,\n Host,\n Method,\n} from '@stencil/core';\nimport { EDIT_INPUT_WR } from '../../utils/consts';\nimport { TextEditor } from './text-editor';\nimport { ColumnDataSchemaModel } from '@type';\nimport {\n EditCell,\n EditorCtr,\n SaveDataDetails,\n EditorBase,\n SaveData,\n} from '@type';\n\nimport { isEditorCtrConstructible } from './edit.utils';\n\n/**\n * Represents a cell editor in a grid.\n * It manages the editing of cells by handling events, saving data, rendering the editor UI,\n * and managing the lifecycle of the editor instance.\n */\n@Component({\n tag: 'revogr-edit',\n styleUrl: 'revogr-edit-style.scss',\n})\nexport class RevoEdit {\n /**\n * Cell to edit data.\n */\n @Prop() editCell: EditCell;\n\n /**\n * Column data for editor.\n */\n @Prop() column: ColumnDataSchemaModel | null;\n /**\n * Custom editors register\n */\n @Prop() editor: EditorCtr | null;\n\n /**\n * Save on editor close. Defines if data should be saved on editor close.\n */\n @Prop() saveOnClose = false;\n /**\n * Additional data to pass to renderer\n */\n @Prop() additionalData: any;\n\n /**\n * Cell edit event\n */\n @Event({ eventName: 'celledit' }) cellEdit: EventEmitter<SaveDataDetails>;\n\n /**\n * Close editor event\n * pass true if requires focus next\n */\n @Event({ eventName: 'closeedit' }) closeEdit: EventEmitter<\n boolean | undefined\n >;\n\n /** Edit session editor */\n @Element() element: HTMLElement;\n private currentEditor: EditorBase | null = null;\n private preventSaveOnClose = false;\n\n /**\n * Cancel pending changes flag. Editor will be closed without autosave.\n */\n @Method() async cancelChanges() {\n this.preventSaveOnClose = true;\n }\n\n /**\n * Before editor got disconnected.\n * Can be triggered multiple times before actual disconnect.\n */\n @Method() async beforeDisconnect() {\n this.currentEditor?.beforeDisconnect?.();\n }\n\n onAutoSave() {\n this.preventSaveOnClose = true;\n const val = this.currentEditor?.getValue?.();\n // For Editor plugin internal usage.\n // When you want to prevent save and use custom save of your own.\n if (this.currentEditor?.beforeAutoSave) {\n const canSave = this.currentEditor.beforeAutoSave(val);\n if (canSave === false) {\n return;\n }\n }\n this.onSave(val, true);\n }\n\n /**\n * Callback triggered when cell editor saved.\n * Closes editor when called.\n * @param preventFocus - if true, editor will not be closed & next cell will not be focused.\n */\n onSave(val?: SaveData, preventFocus?: boolean) {\n this.preventSaveOnClose = true;\n if (this.editCell) {\n this.cellEdit.emit({\n rgCol: this.editCell.x,\n rgRow: this.editCell.y,\n type: this.editCell.type,\n prop: this.editCell.prop,\n val,\n preventFocus,\n });\n }\n }\n\n componentWillRender() {\n // Active editor present and not yet closed.\n if (this.currentEditor || !this.column) {\n return;\n }\n this.preventSaveOnClose = false;\n\n // Custom editor usage.\n // Start with TextEditor (editors/text.tsx) for Custom editor.\n // It can be class or function\n if (this.editor) {\n // if editor is constructible\n if (isEditorCtrConstructible(this.editor)) {\n this.currentEditor = new this.editor(\n this.column,\n // save callback\n (e, preventFocus) => {\n this.onSave(e, preventFocus);\n },\n // cancel callback\n focusNext => {\n this.preventSaveOnClose = true;\n this.closeEdit.emit(focusNext);\n },\n );\n // if editor is function\n } else {\n this.currentEditor = this.editor(\n this.column,\n // save callback\n (e, preventFocus) => {\n this.onSave(e, preventFocus);\n },\n // cancel callback\n focusNext => {\n this.preventSaveOnClose = true;\n this.closeEdit.emit(focusNext);\n },\n );\n }\n return;\n }\n // Default text editor usage\n this.currentEditor = new TextEditor(this.column, (e, preventFocus) =>\n this.onSave(e, preventFocus),\n );\n }\n\n componentDidRender() {\n if (!this.currentEditor) {\n return;\n }\n this.currentEditor.element = this.element.firstElementChild;\n this.currentEditor.componentDidRender?.();\n }\n\n disconnectedCallback() {\n if (this.saveOnClose) {\n // Can not be cancelled by `preventSaveOnClose` prop.\n // Editor requires `getValue` to be able to save.\n if (!this.preventSaveOnClose) {\n this.onAutoSave();\n }\n }\n\n this.preventSaveOnClose = false;\n if (!this.currentEditor) {\n return;\n }\n\n this.currentEditor.disconnectedCallback?.();\n this.currentEditor.element = null;\n this.currentEditor = null;\n }\n\n render() {\n if (this.currentEditor) {\n this.currentEditor.editCell = this.editCell;\n return (\n <Host class={EDIT_INPUT_WR}>\n {this.currentEditor.render(h, this.additionalData)}\n </Host>\n );\n }\n return '';\n }\n}\n","import { getItemByPosition } from '@store';\nimport { DimensionSettingsState, PositionItem, Cell } from '@type';\n\ntype EventData = { el: HTMLElement; rows: DimensionSettingsState; cols: DimensionSettingsState };\ninterface Config {\n positionChanged(from: number, to: number): void;\n}\n\nexport default class RowOrderService {\n private currentCell: Cell | null = null;\n private previousRow: number | null = null;\n\n constructor(private config: Config) {}\n\n /** Drag finished, calculate and apply changes */\n endOrder(e: MouseEvent, data: EventData) {\n if (this.currentCell === null) {\n return;\n }\n const newRow = this.getCell(e, data);\n\n // if position changed\n if (newRow.y !== this.currentCell.y) {\n // rgRow dragged out table\n if (newRow.y < 0) {\n newRow.y = 0;\n }\n // rgRow dragged to the top\n else if (newRow.y < this.currentCell.y) {\n newRow.y++;\n }\n this.config.positionChanged(this.currentCell.y, newRow.y);\n }\n this.clear();\n }\n\n /** Drag started, reserve initial cell for farther use */\n startOrder(e: MouseEvent, data: EventData): Cell {\n this.currentCell = this.getCell(e, data);\n return this.currentCell;\n }\n\n move(y: number, data: EventData): PositionItem | null {\n const rgRow = this.getRow(y, data);\n // if rgRow same as previous or below range (-1 = 0) do nothing\n if (this.previousRow === rgRow.itemIndex || rgRow.itemIndex < -1) {\n return null;\n }\n this.previousRow = rgRow.itemIndex;\n return rgRow;\n }\n\n /** Drag stopped, probably cursor outside of document area */\n clear() {\n this.currentCell = null;\n this.previousRow = null;\n }\n\n /** Calculate cell based on x, y position */\n getRow(y: number, { el, rows }: EventData): PositionItem {\n const { top } = el.getBoundingClientRect();\n const topRelative = y - top;\n const rgRow = getItemByPosition(rows, topRelative);\n const absolutePosition = {\n itemIndex: rgRow.itemIndex,\n start: rgRow.start + top,\n end: rgRow.end + top,\n };\n return absolutePosition;\n }\n\n /** Calculate cell based on x, y position */\n getCell({ x, y }: Cell, { el, rows, cols }: EventData): Cell {\n const { top, left } = el.getBoundingClientRect();\n const topRelative = y - top;\n const leftRelative = x - left;\n const rgRow = getItemByPosition(rows, topRelative);\n const rgCol = getItemByPosition(cols, leftRelative);\n return { x: rgCol.itemIndex, y: rgRow.itemIndex };\n }\n}\n","import { Component, Method, Event, EventEmitter, Prop } from '@stencil/core';\nimport debounce from 'lodash/debounce';\n\nimport { DSourceState, setItems } from '@store';\nimport { DRAGG_TEXT } from '../../utils/consts';\nimport RowOrderService from './order-row.service';\nimport {\n DimensionRows,\n DataType,\n DimensionSettingsState,\n DragStartEvent,\n PositionItem,\n Cell,\n} from '@type';\nimport { Observable } from '../../utils/store.utils';\n\n/**\n * Component for handling row order editor.\n */\n@Component({ tag: 'revogr-order-editor' })\nexport class OrderEditor {\n // #region Properties\n /** Parent element */\n @Prop() parent: HTMLElement;\n /** Dimension settings Y */\n @Prop() dimensionRow: Observable<DimensionSettingsState>;\n /** Dimension settings X */\n @Prop() dimensionCol: Observable<DimensionSettingsState>;\n\n /** Static stores, not expected to change during component lifetime */\n @Prop() dataStore: Observable<DSourceState<DataType, DimensionRows>>;\n // #endregion\n\n // #region Events\n /** Row drag started */\n @Event({ eventName: 'rowdragstartinit', cancelable: true })\n rowDragStart: EventEmitter<{\n cell: Cell;\n text: string;\n pos: PositionItem;\n event: MouseEvent;\n }>;\n\n /** Row drag ended started */\n @Event({ eventName: 'rowdragendinit' })\n rowDragEnd: EventEmitter;\n\n /** Row move started */\n @Event({ eventName: 'rowdragmoveinit', cancelable: true })\n rowDrag: EventEmitter<PositionItem>;\n\n /** Row mouse move started */\n @Event({ eventName: 'rowdragmousemove', cancelable: true })\n rowMouseMove: EventEmitter<Cell>;\n\n /** Row dragged, new range ready to be applied */\n @Event({ eventName: 'rowdropinit', cancelable: true })\n rowDropped: EventEmitter<{\n from: number;\n to: number;\n }>;\n // #endregion\n\n // #region Private\n private rowOrderService: RowOrderService;\n private events: {\n name: keyof DocumentEventMap;\n listener: (e: MouseEvent) => void;\n }[] = [];\n private rowMoveFunc = debounce((y: number) => {\n const rgRow = this.rowOrderService.move(y, this.getData());\n if (rgRow !== null) {\n this.rowDrag.emit(rgRow);\n }\n }, 5);\n // #endregion\n\n // #region Methods\n @Method() async dragStart(e: DragStartEvent) {\n e.originalEvent.preventDefault();\n\n // extra check if previous ended\n if (this.events.length) {\n this.clearOrder();\n }\n\n const data = this.getData();\n const cell = this.rowOrderService.startOrder(e.originalEvent, data);\n const pos = this.rowOrderService.getRow(e.originalEvent.y, data);\n const dragStartEvent = this.rowDragStart.emit({\n cell,\n text: DRAGG_TEXT,\n pos,\n event: e.originalEvent,\n });\n if (dragStartEvent.defaultPrevented) {\n return;\n }\n\n const moveMove = (e: MouseEvent) => this.move(e);\n const mouseUp = (e: MouseEvent) => this.endOrder(e);\n const mouseLeave = () => this.clearOrder();\n\n this.events.push(\n {\n name: 'mousemove',\n listener: moveMove,\n },\n {\n name: 'mouseup',\n listener: mouseUp,\n },\n {\n name: 'mouseleave',\n listener: mouseLeave,\n },\n );\n document.addEventListener('mousemove', moveMove);\n // Action finished inside of the document\n document.addEventListener('mouseup', mouseUp);\n document.addEventListener('mouseleave', mouseLeave);\n }\n\n @Method() async endOrder(e: MouseEvent) {\n this.rowOrderService.endOrder(e, this.getData());\n this.clearOrder();\n }\n\n @Method() async clearOrder() {\n this.rowOrderService.clear();\n this.events.forEach(v => document.removeEventListener(v.name, v.listener));\n this.events.length = 0;\n this.rowDragEnd.emit();\n }\n // #endregion\n\n move({ x, y }: { x: number; y: number }) {\n this.rowMouseMove.emit({ x, y });\n this.rowMoveFunc(y);\n }\n\n connectedCallback() {\n this.rowOrderService = new RowOrderService({\n positionChanged: (f, t) => this.onPositionChanged(f, t),\n });\n }\n\n private onPositionChanged(from: number, to: number) {\n const dropEvent = this.rowDropped.emit({ from, to });\n if (dropEvent.defaultPrevented) {\n return;\n }\n const items = [...this.dataStore.get('items')];\n const toMove = items.splice(from, 1);\n items.splice(to, 0, ...toMove);\n setItems(this.dataStore, items);\n }\n\n private getData() {\n return {\n el: this.parent,\n rows: this.dimensionRow.state,\n cols: this.dimensionCol.state,\n };\n }\n}\n"],"version":3}
@@ -2,14 +2,14 @@
2
2
  * Built by Revolist OU ❤️
3
3
  */
4
4
  import { h, r as registerInstance, c as createEvent, H as Host, a as getElement } from './index-a61f225b.js';
5
- import { n as GROUP_EXPAND_BTN, h as GROUP_EXPAND_EVENT, o as PSEUDO_GROUP_ITEM, G as GROUP_EXPANDED, c as GROUP_DEPTH, p as isRowDragService, q as getCellData, m as ColumnService, i as isGrouping, H as HEADER_SLOT, C as CONTENT_SLOT, F as FOOTER_SLOT } from './column.service-5d14e7e9.js';
5
+ import { n as GROUP_EXPAND_BTN, h as GROUP_EXPAND_EVENT, o as PSEUDO_GROUP_ITEM, G as GROUP_EXPANDED, c as GROUP_DEPTH, p as isRowDragService, q as getCellData, m as ColumnService, i as isGrouping, H as HEADER_SLOT, C as CONTENT_SLOT, F as FOOTER_SLOT } from './column.service-cfc1149b.js';
6
6
  import { d as DATA_ROW, e as ROW_FOCUSED_CLASS, f as DRAG_ICON_CLASS, h as DRAGGABLE_CLASS, i as DATA_COL, F as FOCUS_CLASS, H as HEADER_CLASS, j as HEADER_SORTABLE_CLASS, k as MIN_COL_SIZE, l as HEADER_ROW_CLASS, m as HEADER_ACTUAL_ROW_CLASS } from './index-4e881436.js';
7
- import { b as getSourceItem, E as _getNative, q as _baseEach, _ as _baseIteratee, v as isArray_1, o as findIndex_1, j as getItemByIndex } from './dimension.helpers-56298828.js';
7
+ import { b as getSourceItem, B as _getNative, C as _baseEach, _ as _baseIteratee, m as isArray_1, q as findIndex_1, j as getItemByIndex } from './dimension.helpers-938ea850.js';
8
8
  import './toNumber-8de324a7.js';
9
9
  import { a as FilterButton } from './filter.button-37373672.js';
10
- import { H as HeaderCellRenderer } from './header-cell-renderer-fc999784.js';
10
+ import { H as HeaderCellRenderer } from './header-cell-renderer-6f8eb067.js';
11
11
  import { t as throttle_1, L as LocalScrollTimer, a as LocalScrollService } from './throttle-7283692c.js';
12
- import './selection.helpers-accaad4a.js';
12
+ import './selection.helpers-a49a3d09.js';
13
13
  import './dispatcher-ea08404f.js';
14
14
  import './debounce-7781346d.js';
15
15
 
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * Built by Revolist OU ❤️
3
3
  */
4
- import { l as createStore, k as setStore } from './dimension.helpers-56298828.js';
4
+ import { l as createStore, k as setStore } from './dimension.helpers-938ea850.js';
5
5
  import './toNumber-8de324a7.js';
6
6
  import './index-a61f225b.js';
7
7
 
@@ -438,4 +438,4 @@ function isRangeSingleCell(a) {
438
438
 
439
439
  export { EMPTY_INDEX as E, SelectionStore as S, isRangeSingleCell as a, SelectionStoreConnector as b, cropCellToMax as c, getRange as g, isHiddenStore as i, nextCell as n };
440
440
 
441
- //# sourceMappingURL=selection.helpers-accaad4a.js.map
441
+ //# sourceMappingURL=selection.helpers-a49a3d09.js.map
@@ -1 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AAU,CAAC,GAAG,CAAC,EAAE;YACxB,WAAW,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;SAC7B;aAAM,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,QAAQ,CAAC,UAAU,CAAC,EAAE;YACnD,WAAW,CAAC,UAAU,CAAC,GAAG,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;SACpD;KACF;IAED,OAAO,WAAW,CAAC;AACrB,CAAC;SAEe,QAAQ,CAAC,KAAmB,EAAE,GAAiB;IAC7D,OAAO,KAAK,IAAI,GAAG;UACf;YACE,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;YAC3B,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;YAC3B,EAAE,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;YAC5B,EAAE,EAAE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;SAC7B;UACD,IAAI,CAAC;AACX,CAAC;SAEe,iBAAiB,CAAC,CAAY;IAC5C,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;AACtC;;;;","names":[],"sources":["src/store/selection/selection.store.ts","src/services/selection.store.connector.ts","src/store/selection/selection.helpers.ts"],"sourcesContent":["/**\n * Selection store\n */\n\nimport { setStore, Observable } from '../../utils/store.utils';\nimport { getRange } from '@store';\nimport { SelectionStoreState, Cell, TempRange, RangeArea, Nullable } from '@type';\nimport { createStore } from '@stencil/store';\n\nfunction defaultState(): SelectionStoreState {\n return {\n range: null,\n tempRange: null,\n tempRangeType: null,\n focus: null,\n edit: null,\n lastCell: null,\n nextFocus: null,\n };\n}\n\nexport class SelectionStore {\n readonly store: Observable<SelectionStoreState>;\n private unsubscribe: { (): void }[] = [];\n constructor() {\n this.store = createStore(defaultState());\n this.store.on('set', (key, newVal) => {\n if (key === 'tempRange' && !newVal) {\n this.store.set('tempRangeType', null);\n }\n });\n }\n\n onChange<Key extends keyof SelectionStoreState>(propName: Key, cb: (newValue: SelectionStoreState[Key]) => void) {\n this.unsubscribe.push(this.store.onChange(propName, cb));\n }\n\n clearFocus() {\n setStore(this.store, { focus: null, range: null, edit: null, tempRange: null });\n }\n\n setFocus(focus: Cell, end?: Cell) {\n if (!end) {\n setStore(this.store, { focus });\n } else {\n setStore(this.store, {\n focus,\n range: getRange(focus, end),\n edit: null,\n tempRange: null,\n });\n }\n }\n\n setNextFocus(focus: Cell) {\n setStore(this.store, { nextFocus: focus });\n }\n\n setTempArea(range: Nullable<TempRange> | null) {\n setStore(this.store, { tempRange: range?.area, tempRangeType: range?.type, edit: null });\n }\n\n clearTemp() {\n setStore(this.store, { tempRange: null });\n }\n\n /** Can be applied from selection change or from simple keyboard change clicks */\n setRangeArea(range: RangeArea | null) {\n setStore(this.store, { range, edit: null, tempRange: null });\n }\n setRange(start: Cell, end: Cell) {\n const range = getRange(start, end);\n this.setRangeArea(range);\n }\n\n setLastCell(lastCell: Cell) {\n setStore(this.store, { lastCell });\n }\n\n setEdit(val?: string | boolean) {\n const focus = this.store.get('focus');\n if (focus && typeof val === 'string') {\n setStore(this.store, {\n edit: { x: focus.x, y: focus.y, val },\n });\n return;\n }\n setStore(this.store, { edit: null });\n }\n\n dispose() {\n this.unsubscribe.forEach(f => f());\n this.store.dispose();\n }\n}\n","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","import { EMPTY_INDEX } from '../../services/selection.store.connector';\nimport { Cell, RangeArea } from '@type';\n\nexport function isHiddenStore(pos: number) {\n return pos === EMPTY_INDEX;\n}\n\nexport function nextCell(cell: Cell, lastCell: Cell): Partial<Cell> | null {\n const nextItem: Partial<Cell> = {};\n let types: (keyof Cell)[] = ['x', 'y'];\n\n // previous item check\n for (let t of types) {\n if (cell[t] < 0) {\n nextItem[t] = cell[t];\n return nextItem;\n }\n }\n // next item check\n for (let t of types) {\n if (cell[t] >= lastCell[t]) {\n nextItem[t] = cell[t] - lastCell[t];\n return nextItem;\n }\n }\n return null;\n}\n\nexport function cropCellToMax(cell: Cell, lastCell: Cell): Cell {\n const croppedCell: Cell = { ...cell };\n const cellCoordinates: (keyof Cell)[] = ['x', 'y'];\n\n for (const coordinate of cellCoordinates) {\n if (cell[coordinate] < 0) {\n croppedCell[coordinate] = 0;\n } else if (cell[coordinate] >= lastCell[coordinate]) {\n croppedCell[coordinate] = lastCell[coordinate] - 1;\n }\n }\n\n return croppedCell;\n}\n\nexport function getRange(start?: Cell | null, end?: Cell | null): RangeArea | null {\n return start && end\n ? {\n x: Math.min(start.x, end.x),\n y: Math.min(start.y, end.y),\n x1: Math.max(start.x, end.x),\n y1: Math.max(start.y, end.y),\n }\n : null;\n}\n\nexport function isRangeSingleCell(a: RangeArea): boolean {\n return a.x === a.x1 && a.y === a.y1;\n}\n"],"version":3}
1
+ {"file":"selection.helpers-a49a3d09.js","mappings":";;;;;;;AAAA;;;AASA,SAAS,YAAY;IACnB,OAAO;QACL,KAAK,EAAE,IAAI;QACX,SAAS,EAAE,IAAI;QACf,aAAa,EAAE,IAAI;QACnB,KAAK,EAAE,IAAI;QACX,IAAI,EAAE,IAAI;QACV,QAAQ,EAAE,IAAI;QACd,SAAS,EAAE,IAAI;KAChB,CAAC;AACJ,CAAC;MAEY,cAAc;IAGzB;QADQ,gBAAW,GAAmB,EAAE,CAAC;QAEvC,IAAI,CAAC,KAAK,GAAG,WAAW,CAAC,YAAY,EAAE,CAAC,CAAC;QACzC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM;YAC/B,IAAI,GAAG,KAAK,WAAW,IAAI,CAAC,MAAM,EAAE;gBAClC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC;aACvC;SACF,CAAC,CAAC;KACJ;IAED,QAAQ,CAAwC,QAAa,EAAE,EAAgD;QAC7G,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC;KAC1D;IAED,UAAU;QACR,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,K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CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;AACtC;;;;","names":[],"sources":["src/store/selection/selection.store.ts","src/services/selection.store.connector.ts","src/store/selection/selection.helpers.ts"],"sourcesContent":["/**\n * Selection store\n */\n\nimport { setStore, Observable } from '../../utils/store.utils';\nimport { getRange } from '@store';\nimport { SelectionStoreState, Cell, TempRange, RangeArea, Nullable } from '@type';\nimport { createStore } from '@stencil/store';\n\nfunction defaultState(): SelectionStoreState {\n return {\n range: null,\n tempRange: null,\n tempRangeType: null,\n focus: null,\n edit: null,\n lastCell: null,\n nextFocus: null,\n };\n}\n\nexport class SelectionStore {\n readonly store: Observable<SelectionStoreState>;\n private unsubscribe: { (): void }[] = [];\n constructor() {\n this.store = createStore(defaultState());\n this.store.on('set', (key, newVal) => {\n if (key === 'tempRange' && !newVal) {\n this.store.set('tempRangeType', null);\n }\n });\n }\n\n onChange<Key extends keyof SelectionStoreState>(propName: Key, cb: (newValue: SelectionStoreState[Key]) => void) {\n this.unsubscribe.push(this.store.onChange(propName, cb));\n }\n\n clearFocus() {\n setStore(this.store, { focus: null, range: null, edit: null, tempRange: null });\n }\n\n setFocus(focus: Cell, end?: Cell) {\n if (!end) {\n setStore(this.store, { focus });\n } else {\n setStore(this.store, {\n focus,\n range: getRange(focus, end),\n edit: null,\n tempRange: null,\n });\n }\n }\n\n setNextFocus(focus: Cell) {\n setStore(this.store, { nextFocus: focus });\n }\n\n setTempArea(range: Nullable<TempRange> | null) {\n setStore(this.store, { tempRange: range?.area, tempRangeType: range?.type, edit: null });\n }\n\n clearTemp() {\n setStore(this.store, { tempRange: null });\n }\n\n /** Can be applied from selection change or from simple keyboard change clicks */\n setRangeArea(range: RangeArea | null) {\n setStore(this.store, { range, edit: null, tempRange: null });\n }\n setRange(start: Cell, end: Cell) {\n const range = getRange(start, end);\n this.setRangeArea(range);\n }\n\n setLastCell(lastCell: Cell) {\n setStore(this.store, { lastCell });\n }\n\n setEdit(val?: string | boolean) {\n const focus = this.store.get('focus');\n if (focus && typeof val === 'string') {\n setStore(this.store, {\n edit: { x: focus.x, y: focus.y, val },\n });\n return;\n }\n setStore(this.store, { edit: null });\n }\n\n dispose() {\n this.unsubscribe.forEach(f => f());\n this.store.dispose();\n }\n}\n","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","import { EMPTY_INDEX } from '../../services/selection.store.connector';\nimport { Cell, RangeArea } from '@type';\n\nexport function isHiddenStore(pos: number) {\n return pos === EMPTY_INDEX;\n}\n\nexport function nextCell(cell: Cell, lastCell: Cell): Partial<Cell> | null {\n const nextItem: Partial<Cell> = {};\n let types: (keyof Cell)[] = ['x', 'y'];\n\n // previous item check\n for (let t of types) {\n if (cell[t] < 0) {\n nextItem[t] = cell[t];\n return nextItem;\n }\n }\n // next item check\n for (let t of types) {\n if (cell[t] >= lastCell[t]) {\n nextItem[t] = cell[t] - lastCell[t];\n return nextItem;\n }\n }\n return null;\n}\n\nexport function cropCellToMax(cell: Cell, lastCell: Cell): Cell {\n const croppedCell: Cell = { ...cell };\n const cellCoordinates: (keyof Cell)[] = ['x', 'y'];\n\n for (const coordinate of cellCoordinates) {\n if (cell[coordinate] < 0) {\n croppedCell[coordinate] = 0;\n } else if (cell[coordinate] >= lastCell[coordinate]) {\n croppedCell[coordinate] = lastCell[coordinate] - 1;\n }\n }\n\n return croppedCell;\n}\n\nexport function getRange(start?: Cell | null, end?: Cell | null): RangeArea | null {\n return start && end\n ? {\n x: Math.min(start.x, end.x),\n y: Math.min(start.y, end.y),\n x1: Math.max(start.x, end.x),\n y1: Math.max(start.y, end.y),\n }\n : null;\n}\n\nexport function isRangeSingleCell(a: RangeArea): boolean {\n return a.x === a.x1 && a.y === a.y1;\n}\n"],"version":3}
@@ -1,7 +1,7 @@
1
1
  /*!
2
2
  * Built by Revolist OU ❤️
3
3
  */
4
- import { i as getItemByPosition, l as createStore, k as setStore } from './dimension.helpers-56298828.js';
4
+ import { i as getItemByPosition, l as createStore, k as setStore } from './dimension.helpers-938ea850.js';
5
5
 
6
6
  /**
7
7
  * Update items based on new scroll position
@@ -397,4 +397,4 @@ class ViewportStore {
397
397
 
398
398
  export { ViewportStore as V, addMissingItems as a, getItems as b, isActiveRangeOutsideLastItem as c, getFirstItem as d, getLastItem as e, getUpdatedItemsByPosition as g, isActiveRange as i, recombineByOffset as r, setItemSizes as s, updateMissingAndRange as u };
399
399
 
400
- //# sourceMappingURL=viewport.store-d8e03528.js.map
400
+ //# sourceMappingURL=viewport.store-a690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;SACR;QAED,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE;YACnB,KAAK,EAAE,YAAY,CACjB,KAAK,EACL,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,EACvB,IAAI,EACJ,IAAI,CAAC,cAAc,CACpB;SACF,CAAC,CAAC;KACJ;IAED,QAAQ;QACN,OAAO;YACL,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC;YAC9B,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC;YAC9B,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC;SAC3B,CAAC;KACH;IAED,WAAW,CAAC,IAA4B;QACtC,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;KAC5B;IAED,UAAU;QACR,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;KAC7B;;;;;","names":[],"sources":["src/store/vp/viewport.helpers.ts","src/store/vp/viewport.store.ts"],"sourcesContent":["import {\n DimensionSettingsState,\n PositionItem,\n ViewSettingSizeProp,\n ViewportStateItems,\n VirtualPositionItem,\n Range,\n} from '@type';\n\nimport { getItemByPosition } from '../dimension/dimension.helpers';\n\nexport type DimensionDataViewport = Pick<\n DimensionSettingsState,\n | 'indexes'\n | 'positionIndexes'\n | 'positionIndexToItem'\n | 'sizes'\n | 'originItemSize'\n | 'realSize'\n>;\n\nexport type ItemsToUpdate = Pick<ViewportStateItems, 'items' | 'start' | 'end'>;\n/**\n * Update items based on new scroll position\n * If viewport wasn't changed fully simple recombination of positions\n * Otherwise rebuild viewport items\n */\nexport function getUpdatedItemsByPosition<T extends ItemsToUpdate>(\n pos: number, // coordinate\n items: T,\n realCount: number,\n virtualSize: number,\n dimension: DimensionDataViewport,\n): ItemsToUpdate {\n const activeItem: PositionItem = getItemByPosition(dimension, pos);\n const firstItem = getFirstItem(items);\n let toUpdate: ItemsToUpdate | undefined;\n // do simple position recombination if items already present in viewport\n if (firstItem) {\n let changedOffsetStart = activeItem.itemIndex - (firstItem.itemIndex || 0);\n // if item changed\n if (changedOffsetStart) {\n // simple recombination\n toUpdate = recombineByOffset(Math.abs(changedOffsetStart), {\n positiveDirection: changedOffsetStart > -1,\n ...dimension,\n ...items,\n });\n }\n }\n\n const maxSizeVirtualSize = getMaxVirtualSize(\n virtualSize,\n dimension.realSize,\n activeItem,\n );\n // if partial recombination add items if revo-viewport has some space left\n if (toUpdate) {\n const extra = addMissingItems(\n activeItem,\n realCount,\n maxSizeVirtualSize,\n toUpdate,\n dimension,\n );\n if (extra.length) {\n updateMissingAndRange(toUpdate.items, extra, toUpdate);\n }\n }\n\n // new collection if no items after replacement full replacement\n if (!toUpdate) {\n const items = getItems({\n firstItemStart: activeItem.start,\n firstItemIndex: activeItem.itemIndex,\n origSize: dimension.originItemSize,\n maxSize: maxSizeVirtualSize,\n maxCount: realCount,\n sizes: dimension.sizes,\n });\n\n // range now comes from 0 to length - 1\n toUpdate = {\n items,\n start: 0,\n end: items.length - 1,\n };\n }\n return toUpdate;\n}\n\n// virtual size can differ based on scroll position if some big items are present\n// scroll can be in the middle of item and virtual size will be larger\n// so we need to exclude this part from virtual size hence it's already passed\nfunction getMaxVirtualSize(\n virtualSize: number,\n realSize: number,\n activeItem: PositionItem,\n) {\n return Math.min(virtualSize + (activeItem.end - activeItem.start), realSize);\n}\n\nexport function updateMissingAndRange(\n items: VirtualPositionItem[],\n missing: VirtualPositionItem[],\n range: Range,\n) {\n items.splice(range.end + 1, 0, ...missing);\n // update range if start larger after recombination\n if (\n range.start >= range.end &&\n !(range.start === range.end && range.start === 0)\n ) {\n range.start += missing.length;\n }\n range.end += missing.length;\n}\n\n/**\n * If partial replacement\n * this function adds items if viewport has some space left\n */\nexport function addMissingItems<T extends ItemsToUpdate>(\n firstItem: PositionItem,\n realCount: number,\n virtualSize: number,\n existingCollection: T,\n dimension: Pick<DimensionSettingsState, 'sizes' | 'originItemSize'>,\n): VirtualPositionItem[] {\n const lastItem: VirtualPositionItem = getLastItem(existingCollection);\n const items = getItems({\n sizes: dimension.sizes,\n firstItemStart: lastItem.end,\n firstItemIndex: lastItem.itemIndex + 1,\n origSize: dimension.originItemSize,\n maxSize: virtualSize - (lastItem.end - firstItem.start),\n maxCount: realCount,\n });\n return items;\n}\n\n/**\n * Get wiewport items parameters\n * caching position and calculating items count in viewport\n */\nexport function getItems(\n opt: {\n firstItemIndex: number;\n firstItemStart: number;\n origSize: number;\n maxSize: number; // virtual size\n maxCount: number; // real item count, where the last item\n sizes?: ViewSettingSizeProp;\n },\n currentSize = 0,\n) {\n const items: VirtualPositionItem[] = [];\n\n let index = opt.firstItemIndex;\n let size = currentSize;\n\n // max size or max count\n while (size <= opt.maxSize && index < opt.maxCount) {\n const newSize = getItemSize(index, opt.sizes, opt.origSize);\n items.push({\n start: opt.firstItemStart + size,\n end: opt.firstItemStart + size + newSize,\n itemIndex: index,\n size: newSize,\n });\n size += newSize;\n index++;\n }\n return items;\n}\n\n/**\n * Do batch items recombination\n * If items not overlapped with existing viewport returns null\n */\ntype RecombindDimensionData = Pick<\n DimensionSettingsState,\n 'sizes' | 'realSize' | 'originItemSize'\n>;\ntype RecombineOffsetData = {\n positiveDirection: boolean;\n} & ItemsToUpdate &\n RecombindDimensionData;\nexport function recombineByOffset(\n offset: number,\n data: RecombineOffsetData,\n): ItemsToUpdate | undefined {\n const newItems = [...data.items];\n const itemsCount = newItems.length;\n let newRange = {\n start: data.start,\n end: data.end,\n };\n\n // if offset out of revo-viewport, makes sense whole redraw\n if (offset > itemsCount) {\n return undefined;\n }\n\n // is direction of scroll positive\n if (data.positiveDirection) {\n // push item to the end\n let lastItem: VirtualPositionItem = getLastItem(data);\n\n let i = newRange.start;\n const length = i + offset;\n for (; i < length; i++) {\n const newIndex = lastItem.itemIndex + 1;\n const size = getItemSize(\n newIndex,\n data.sizes,\n data.originItemSize,\n );\n\n // if item overlapped limit break a loop\n if (lastItem.end + size > data.realSize) {\n break;\n }\n\n // new item index to recombine\n let newEnd = i % itemsCount;\n\n // item should always present, we do not create new item, we recombine them\n if (!newItems[newEnd]) {\n throw new Error('incorrect index');\n }\n\n // do recombination\n newItems[newEnd] = lastItem = {\n start: lastItem.end,\n end: lastItem.end + size,\n itemIndex: newIndex,\n size: size,\n };\n // update range\n newRange.start++;\n newRange.end = newEnd;\n }\n\n // direction is negative\n } else {\n // push item to the start\n let firstItem = getFirstItem(data);\n\n const end = newRange.end;\n for (let i = 0; i < offset; i++) {\n const newIndex = (firstItem?.itemIndex ?? 0) - 1;\n const size = getItemSize(\n newIndex,\n data.sizes,\n data.originItemSize,\n );\n\n // new item index to recombine\n let newStart = end - i;\n newStart = (newStart < 0 ? itemsCount + newStart : newStart) % itemsCount;\n\n // item should always present, we do not create new item, we recombine them\n if (!newItems[newStart]) {\n console.error('incorrect index');\n break;\n }\n\n // do recombination\n const firstItemStart = firstItem?.start ?? 0;\n newItems[newStart] = firstItem = {\n start: firstItemStart - size,\n end: firstItemStart,\n itemIndex: newIndex,\n size: size,\n };\n // update range\n newRange.start = newStart;\n newRange.end--;\n }\n }\n const range = {\n start:\n (newRange.start < 0 ? itemsCount + newRange.start : newRange.start) %\n itemsCount,\n end:\n (newRange.end < 0 ? itemsCount + newRange.end : newRange.end) %\n itemsCount,\n };\n return {\n items: newItems,\n ...range,\n };\n}\n\nfunction getItemSize(\n index: number,\n sizes?: ViewSettingSizeProp,\n origSize = 0,\n): number {\n if (sizes && sizes[index]) {\n return sizes[index];\n }\n return origSize;\n}\n\n/**\n * Verify if position is in range of the PositionItem, start and end are included\n */\nexport function isActiveRange(\n pos: number,\n realSize: number,\n first?: PositionItem,\n last?: PositionItem,\n): boolean {\n if (!first || !last) {\n return false;\n }\n // if position is in range of first item\n // or position is after first item and last item is the last item in real size\n return (\n (pos >= first.start && pos <= first.end) ||\n (pos > first.end && last.end === realSize)\n );\n}\n\nexport function isActiveRangeOutsideLastItem(\n pos: number,\n virtualSize: number,\n firstItem?: PositionItem,\n lastItem?: PositionItem,\n) {\n // if no first item, means no items in viewport\n if (!firstItem) {\n return false;\n }\n return virtualSize + pos > (lastItem?.end ?? 0);\n}\n\nexport function getFirstItem(\n s: ItemsToUpdate,\n) {\n return s.items[s.start];\n}\n\nexport function getLastItem(s: ItemsToUpdate): VirtualPositionItem {\n return s.items[s.end];\n}\n\n/**\n * Set items sizes from start index to end\n * @param vpItems\n * @param start\n * @param size\n * @param lastCoordinate\n * @returns\n */\nexport function setItemSizes(\n vpItems: VirtualPositionItem[],\n initialIndex: number,\n size: number,\n lastCoordinate: number,\n) {\n const items = [...vpItems];\n const count = items.length;\n\n let pos = lastCoordinate;\n let i = 0;\n let start = initialIndex;\n\n // viewport not inited\n if (!count) {\n return [];\n }\n // loop through array from initial item after recombination\n while (i < count) {\n const item = items[start];\n item.start = pos;\n item.size = size;\n item.end = item.start + size;\n pos = item.end;\n // loop by start index\n start++;\n i++;\n\n // if start index out of array, reset it\n if (start === count) {\n start = 0;\n }\n }\n return items;\n}\n","import {\n DimensionDataViewport,\n addMissingItems,\n getFirstItem,\n getLastItem,\n getUpdatedItemsByPosition,\n isActiveRange,\n setItemSizes,\n updateMissingAndRange,\n isActiveRangeOutsideLastItem,\n ItemsToUpdate,\n} from './viewport.helpers';\nimport { createStore } from '@stencil/store';\nimport { type Observable, setStore } from '../../utils/store.utils';\nimport type {\n VirtualPositionItem,\n ViewportState,\n MultiDimensionType,\n} from '@type';\n\n/**\n * Viewport store\n * Used for virtualization (process of rendering only visible part of data)\n * Redraws viewport based on position and dimension\n */\nfunction initialState(): ViewportState {\n return {\n // virtual item information per rendered item\n items: [],\n // virtual dom item order to render\n start: 0,\n end: 0,\n\n // size of viewport in px\n virtualSize: 0,\n\n // total number of items\n realCount: 0,\n };\n}\n\n/**\n * Viewport store class\n */\nexport class ViewportStore {\n readonly store: Observable<ViewportState>;\n\n // last coordinate for store position restore\n private lastKnownScroll = 0;\n\n get lastCoordinate() {\n return this.lastKnownScroll;\n }\n set lastCoordinate(value: number) {\n this.lastKnownScroll = value;\n }\n constructor(readonly type: MultiDimensionType) {\n this.store = createStore(initialState());\n // drop items on real size change, require a new item set\n this.store.onChange('realCount', () => this.clearItems());\n // drop items on virtual size change, require a new item set\n this.store.onChange('virtualSize', () => this.clearItems());\n }\n\n /**\n * Render viewport based on coordinate\n * It's the main method for draw\n * Use force if you want to re-render viewport\n */\n setViewPortCoordinate(position: number, dimension: DimensionDataViewport, force = false) {\n const viewportSize = this.store.get('virtualSize');\n // no visible data to calculate\n if (!viewportSize) {\n return;\n }\n\n const frameOffset = 1;\n const singleOffsetInPx = dimension.originItemSize * frameOffset;\n // add offset to virtual size from both sides\n const outsize = singleOffsetInPx * 2;\n // math virtual size is based on visible area + 2 items outside of visible area\n const virtualSize = viewportSize + outsize;\n\n // expected no scroll if real size less than virtual size, position is 0\n let maxCoordinate = 0;\n // if there is nodes outside of viewport, max coordinate has to be adjusted\n if (dimension.realSize > viewportSize) {\n // max coordinate is real size minus virtual/rendered space\n maxCoordinate = dimension.realSize - viewportSize - singleOffsetInPx;\n }\n\n let pos = position;\n // limit position to max and min coordinates\n if (pos < 0) {\n pos = 0;\n } else if (pos > maxCoordinate) {\n pos = maxCoordinate;\n }\n\n // store last coordinate for further restore on redraw\n this.lastCoordinate = pos;\n\n // actual position is less than first item start based on offset\n pos -= singleOffsetInPx;\n pos = pos < 0 ? 0 : pos < maxCoordinate ? pos : maxCoordinate;\n\n let allItems: ItemsToUpdate;\n // if force clear all items and start from 0\n if (force) {\n allItems = {\n items: [],\n start: 0,\n end: 0,\n };\n } else {\n allItems = this.getItems()\n }\n\n const firstItem: VirtualPositionItem | undefined = getFirstItem(allItems);\n const lastItem: VirtualPositionItem | undefined = getLastItem(allItems);\n\n let toUpdate: Partial<ViewportState> = {};\n\n // left position changed\n // verify if new position is in range of previously rendered first item\n if (!isActiveRange(pos, dimension.realSize, firstItem, lastItem)) {\n toUpdate = {\n ...toUpdate,\n ...getUpdatedItemsByPosition(\n pos,\n allItems,\n this.store.get('realCount'),\n virtualSize,\n dimension,\n ),\n };\n this.setViewport({ ...toUpdate });\n // verify is render area is outside of last item\n } else if (\n isActiveRangeOutsideLastItem(pos, virtualSize, firstItem, lastItem)\n ) {\n const items = [...allItems.items];\n // check is any item missing for fulfill content\n const missing = addMissingItems(\n firstItem,\n this.store.get('realCount'),\n virtualSize + pos - firstItem.start,\n allItems,\n {\n sizes: dimension.sizes,\n originItemSize: dimension.originItemSize,\n },\n );\n\n // update missing items\n if (missing.length) {\n const range = {\n start: this.store.get('start'),\n end: this.store.get('end'),\n };\n updateMissingAndRange(items, missing, range);\n toUpdate = {\n ...toUpdate,\n items: [...items],\n ...range,\n };\n this.setViewport({ ...toUpdate });\n }\n }\n }\n\n /**\n * Set sizes for existing items\n */\n setOriginalSizes(size: number) {\n const items = this.store.get('items');\n const count = items.length;\n // viewport not inited\n if (!count) {\n return;\n }\n\n setStore(this.store, {\n items: setItemSizes(\n items,\n this.store.get('start'),\n size,\n this.lastCoordinate,\n ),\n });\n }\n\n getItems(): ItemsToUpdate {\n return {\n items: this.store.get('items'),\n start: this.store.get('start'),\n end: this.store.get('end'),\n };\n }\n\n setViewport(data: Partial<ViewportState>) {\n setStore(this.store, data);\n }\n\n clearItems() {\n this.store.set('items', []);\n }\n}\n"],"version":3}
1
+ {"file":"viewport.store-a690096b.js","mappings":";;;;;AAsBA;;;;;SAKgB,yBAAyB,CACvC,GAAW;AACX,KAAQ,EACR,SAAiB,EACjB,WAAmB,EACnB,SAAgC;IAEhC,MAAM,UAAU,GAAiB,iBAAiB,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;IACnE,MAAM,SAAS,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;IACtC,IAAI,QAAmC,CAAC;;IAExC,IAAI,SAAS,EAAE;QACb,IAAI,kBAAkB,GAAG,UAAU,CAAC,SAAS,IAAI,SAAS,CAAC,SAAS,IAAI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C,GAAG,CAAC,KAAK,CAAC;SAC3B,CAAC;KACH;IAED,WAAW,CAAC,IAA4B;QACtC,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;KAC5B;IAED,UAAU;QACR,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;KAC7B;;;;;","names":[],"sources":["src/store/vp/viewport.helpers.ts","src/store/vp/viewport.store.ts"],"sourcesContent":["import {\n DimensionSettingsState,\n PositionItem,\n ViewSettingSizeProp,\n ViewportStateItems,\n VirtualPositionItem,\n Range,\n} from '@type';\n\nimport { getItemByPosition } from '../dimension/dimension.helpers';\n\nexport type DimensionDataViewport = Pick<\n DimensionSettingsState,\n | 'indexes'\n | 'positionIndexes'\n | 'positionIndexToItem'\n | 'sizes'\n | 'originItemSize'\n | 'realSize'\n>;\n\nexport type ItemsToUpdate = Pick<ViewportStateItems, 'items' | 'start' | 'end'>;\n/**\n * Update items based on new scroll position\n * If viewport wasn't changed fully simple recombination of positions\n * Otherwise rebuild viewport items\n */\nexport function getUpdatedItemsByPosition<T extends ItemsToUpdate>(\n pos: number, // coordinate\n items: T,\n realCount: number,\n virtualSize: number,\n dimension: DimensionDataViewport,\n): ItemsToUpdate {\n const activeItem: PositionItem = getItemByPosition(dimension, pos);\n const firstItem = getFirstItem(items);\n let toUpdate: ItemsToUpdate | undefined;\n // do simple position recombination if items already present in viewport\n if (firstItem) {\n let changedOffsetStart = activeItem.itemIndex - (firstItem.itemIndex || 0);\n // if item changed\n if (changedOffsetStart) {\n // simple recombination\n toUpdate = recombineByOffset(Math.abs(changedOffsetStart), {\n positiveDirection: changedOffsetStart > -1,\n ...dimension,\n ...items,\n });\n }\n }\n\n const maxSizeVirtualSize = getMaxVirtualSize(\n virtualSize,\n dimension.realSize,\n activeItem,\n );\n // if partial recombination add items if revo-viewport has some space left\n if (toUpdate) {\n const extra = addMissingItems(\n activeItem,\n realCount,\n maxSizeVirtualSize,\n toUpdate,\n dimension,\n );\n if (extra.length) {\n updateMissingAndRange(toUpdate.items, extra, toUpdate);\n }\n }\n\n // new collection if no items after replacement full replacement\n if (!toUpdate) {\n const items = getItems({\n firstItemStart: activeItem.start,\n firstItemIndex: activeItem.itemIndex,\n origSize: dimension.originItemSize,\n maxSize: maxSizeVirtualSize,\n maxCount: realCount,\n sizes: dimension.sizes,\n });\n\n // range now comes from 0 to length - 1\n toUpdate = {\n items,\n start: 0,\n end: items.length - 1,\n };\n }\n return toUpdate;\n}\n\n// virtual size can differ based on scroll position if some big items are present\n// scroll can be in the middle of item and virtual size will be larger\n// so we need to exclude this part from virtual size hence it's already passed\nfunction getMaxVirtualSize(\n virtualSize: number,\n realSize: number,\n activeItem: PositionItem,\n) {\n return Math.min(virtualSize + (activeItem.end - activeItem.start), realSize);\n}\n\nexport function updateMissingAndRange(\n items: VirtualPositionItem[],\n missing: VirtualPositionItem[],\n range: Range,\n) {\n items.splice(range.end + 1, 0, ...missing);\n // update range if start larger after recombination\n if (\n range.start >= range.end &&\n !(range.start === range.end && range.start === 0)\n ) {\n range.start += missing.length;\n }\n range.end += missing.length;\n}\n\n/**\n * If partial replacement\n * this function adds items if viewport has some space left\n */\nexport function addMissingItems<T extends ItemsToUpdate>(\n firstItem: PositionItem,\n realCount: number,\n virtualSize: number,\n existingCollection: T,\n dimension: Pick<DimensionSettingsState, 'sizes' | 'originItemSize'>,\n): VirtualPositionItem[] {\n const lastItem: VirtualPositionItem = getLastItem(existingCollection);\n const items = getItems({\n sizes: dimension.sizes,\n firstItemStart: lastItem.end,\n firstItemIndex: lastItem.itemIndex + 1,\n origSize: dimension.originItemSize,\n maxSize: virtualSize - (lastItem.end - firstItem.start),\n maxCount: realCount,\n });\n return items;\n}\n\n/**\n * Get wiewport items parameters\n * caching position and calculating items count in viewport\n */\nexport function getItems(\n opt: {\n firstItemIndex: number;\n firstItemStart: number;\n origSize: number;\n maxSize: number; // virtual size\n maxCount: number; // real item count, where the last item\n sizes?: ViewSettingSizeProp;\n },\n currentSize = 0,\n) {\n const items: VirtualPositionItem[] = [];\n\n let index = opt.firstItemIndex;\n let size = currentSize;\n\n // max size or max count\n while (size <= opt.maxSize && index < opt.maxCount) {\n const newSize = getItemSize(index, opt.sizes, opt.origSize);\n items.push({\n start: opt.firstItemStart + size,\n end: opt.firstItemStart + size + newSize,\n itemIndex: index,\n size: newSize,\n });\n size += newSize;\n index++;\n }\n return items;\n}\n\n/**\n * Do batch items recombination\n * If items not overlapped with existing viewport returns null\n */\ntype RecombindDimensionData = Pick<\n DimensionSettingsState,\n 'sizes' | 'realSize' | 'originItemSize'\n>;\ntype RecombineOffsetData = {\n positiveDirection: boolean;\n} & ItemsToUpdate &\n RecombindDimensionData;\nexport function recombineByOffset(\n offset: number,\n data: RecombineOffsetData,\n): ItemsToUpdate | undefined {\n const newItems = [...data.items];\n const itemsCount = newItems.length;\n let newRange = {\n start: data.start,\n end: data.end,\n };\n\n // if offset out of revo-viewport, makes sense whole redraw\n if (offset > itemsCount) {\n return undefined;\n }\n\n // is direction of scroll positive\n if (data.positiveDirection) {\n // push item to the end\n let lastItem: VirtualPositionItem = getLastItem(data);\n\n let i = newRange.start;\n const length = i + offset;\n for (; i < length; i++) {\n const newIndex = lastItem.itemIndex + 1;\n const size = getItemSize(\n newIndex,\n data.sizes,\n data.originItemSize,\n );\n\n // if item overlapped limit break a loop\n if (lastItem.end + size > data.realSize) {\n break;\n }\n\n // new item index to recombine\n let newEnd = i % itemsCount;\n\n // item should always present, we do not create new item, we recombine them\n if (!newItems[newEnd]) {\n throw new Error('incorrect index');\n }\n\n // do recombination\n newItems[newEnd] = lastItem = {\n start: lastItem.end,\n end: lastItem.end + size,\n itemIndex: newIndex,\n size: size,\n };\n // update range\n newRange.start++;\n newRange.end = newEnd;\n }\n\n // direction is negative\n } else {\n // push item to the start\n let firstItem = getFirstItem(data);\n\n const end = newRange.end;\n for (let i = 0; i < offset; i++) {\n const newIndex = (firstItem?.itemIndex ?? 0) - 1;\n const size = getItemSize(\n newIndex,\n data.sizes,\n data.originItemSize,\n );\n\n // new item index to recombine\n let newStart = end - i;\n newStart = (newStart < 0 ? itemsCount + newStart : newStart) % itemsCount;\n\n // item should always present, we do not create new item, we recombine them\n if (!newItems[newStart]) {\n console.error('incorrect index');\n break;\n }\n\n // do recombination\n const firstItemStart = firstItem?.start ?? 0;\n newItems[newStart] = firstItem = {\n start: firstItemStart - size,\n end: firstItemStart,\n itemIndex: newIndex,\n size: size,\n };\n // update range\n newRange.start = newStart;\n newRange.end--;\n }\n }\n const range = {\n start:\n (newRange.start < 0 ? itemsCount + newRange.start : newRange.start) %\n itemsCount,\n end:\n (newRange.end < 0 ? itemsCount + newRange.end : newRange.end) %\n itemsCount,\n };\n return {\n items: newItems,\n ...range,\n };\n}\n\nfunction getItemSize(\n index: number,\n sizes?: ViewSettingSizeProp,\n origSize = 0,\n): number {\n if (sizes && sizes[index]) {\n return sizes[index];\n }\n return origSize;\n}\n\n/**\n * Verify if position is in range of the PositionItem, start and end are included\n */\nexport function isActiveRange(\n pos: number,\n realSize: number,\n first?: PositionItem,\n last?: PositionItem,\n): boolean {\n if (!first || !last) {\n return false;\n }\n // if position is in range of first item\n // or position is after first item and last item is the last item in real size\n return (\n (pos >= first.start && pos <= first.end) ||\n (pos > first.end && last.end === realSize)\n );\n}\n\nexport function isActiveRangeOutsideLastItem(\n pos: number,\n virtualSize: number,\n firstItem?: PositionItem,\n lastItem?: PositionItem,\n) {\n // if no first item, means no items in viewport\n if (!firstItem) {\n return false;\n }\n return virtualSize + pos > (lastItem?.end ?? 0);\n}\n\nexport function getFirstItem(\n s: ItemsToUpdate,\n) {\n return s.items[s.start];\n}\n\nexport function getLastItem(s: ItemsToUpdate): VirtualPositionItem {\n return s.items[s.end];\n}\n\n/**\n * Set items sizes from start index to end\n * @param vpItems\n * @param start\n * @param size\n * @param lastCoordinate\n * @returns\n */\nexport function setItemSizes(\n vpItems: VirtualPositionItem[],\n initialIndex: number,\n size: number,\n lastCoordinate: number,\n) {\n const items = [...vpItems];\n const count = items.length;\n\n let pos = lastCoordinate;\n let i = 0;\n let start = initialIndex;\n\n // viewport not inited\n if (!count) {\n return [];\n }\n // loop through array from initial item after recombination\n while (i < count) {\n const item = items[start];\n item.start = pos;\n item.size = size;\n item.end = item.start + size;\n pos = item.end;\n // loop by start index\n start++;\n i++;\n\n // if start index out of array, reset it\n if (start === count) {\n start = 0;\n }\n }\n return items;\n}\n","import {\n DimensionDataViewport,\n addMissingItems,\n getFirstItem,\n getLastItem,\n getUpdatedItemsByPosition,\n isActiveRange,\n setItemSizes,\n updateMissingAndRange,\n isActiveRangeOutsideLastItem,\n ItemsToUpdate,\n} from './viewport.helpers';\nimport { createStore } from '@stencil/store';\nimport { type Observable, setStore } from '../../utils/store.utils';\nimport type {\n VirtualPositionItem,\n ViewportState,\n MultiDimensionType,\n} from '@type';\n\n/**\n * Viewport store\n * Used for virtualization (process of rendering only visible part of data)\n * Redraws viewport based on position and dimension\n */\nfunction initialState(): ViewportState {\n return {\n // virtual item information per rendered item\n items: [],\n // virtual dom item order to render\n start: 0,\n end: 0,\n\n // size of viewport in px\n virtualSize: 0,\n\n // total number of items\n realCount: 0,\n };\n}\n\n/**\n * Viewport store class\n */\nexport class ViewportStore {\n readonly store: Observable<ViewportState>;\n\n // last coordinate for store position restore\n private lastKnownScroll = 0;\n\n get lastCoordinate() {\n return this.lastKnownScroll;\n }\n set lastCoordinate(value: number) {\n this.lastKnownScroll = value;\n }\n constructor(readonly type: MultiDimensionType) {\n this.store = createStore(initialState());\n // drop items on real size change, require a new item set\n this.store.onChange('realCount', () => this.clearItems());\n // drop items on virtual size change, require a new item set\n this.store.onChange('virtualSize', () => this.clearItems());\n }\n\n /**\n * Render viewport based on coordinate\n * It's the main method for draw\n * Use force if you want to re-render viewport\n */\n setViewPortCoordinate(position: number, dimension: DimensionDataViewport, force = false) {\n const viewportSize = this.store.get('virtualSize');\n // no visible data to calculate\n if (!viewportSize) {\n return;\n }\n\n const frameOffset = 1;\n const singleOffsetInPx = dimension.originItemSize * frameOffset;\n // add offset to virtual size from both sides\n const outsize = singleOffsetInPx * 2;\n // math virtual size is based on visible area + 2 items outside of visible area\n const virtualSize = viewportSize + outsize;\n\n // expected no scroll if real size less than virtual size, position is 0\n let maxCoordinate = 0;\n // if there is nodes outside of viewport, max coordinate has to be adjusted\n if (dimension.realSize > viewportSize) {\n // max coordinate is real size minus virtual/rendered space\n maxCoordinate = dimension.realSize - viewportSize - singleOffsetInPx;\n }\n\n let pos = position;\n // limit position to max and min coordinates\n if (pos < 0) {\n pos = 0;\n } else if (pos > maxCoordinate) {\n pos = maxCoordinate;\n }\n\n // store last coordinate for further restore on redraw\n this.lastCoordinate = pos;\n\n // actual position is less than first item start based on offset\n pos -= singleOffsetInPx;\n pos = pos < 0 ? 0 : pos < maxCoordinate ? pos : maxCoordinate;\n\n let allItems: ItemsToUpdate;\n // if force clear all items and start from 0\n if (force) {\n allItems = {\n items: [],\n start: 0,\n end: 0,\n };\n } else {\n allItems = this.getItems()\n }\n\n const firstItem: VirtualPositionItem | undefined = getFirstItem(allItems);\n const lastItem: VirtualPositionItem | undefined = getLastItem(allItems);\n\n let toUpdate: Partial<ViewportState> = {};\n\n // left position changed\n // verify if new position is in range of previously rendered first item\n if (!isActiveRange(pos, dimension.realSize, firstItem, lastItem)) {\n toUpdate = {\n ...toUpdate,\n ...getUpdatedItemsByPosition(\n pos,\n allItems,\n this.store.get('realCount'),\n virtualSize,\n dimension,\n ),\n };\n this.setViewport({ ...toUpdate });\n // verify is render area is outside of last item\n } else if (\n isActiveRangeOutsideLastItem(pos, virtualSize, firstItem, lastItem)\n ) {\n const items = [...allItems.items];\n // check is any item missing for fulfill content\n const missing = addMissingItems(\n firstItem,\n this.store.get('realCount'),\n virtualSize + pos - firstItem.start,\n allItems,\n {\n sizes: dimension.sizes,\n originItemSize: dimension.originItemSize,\n },\n );\n\n // update missing items\n if (missing.length) {\n const range = {\n start: this.store.get('start'),\n end: this.store.get('end'),\n };\n updateMissingAndRange(items, missing, range);\n toUpdate = {\n ...toUpdate,\n items: [...items],\n ...range,\n };\n this.setViewport({ ...toUpdate });\n }\n }\n }\n\n /**\n * Set sizes for existing items\n */\n setOriginalSizes(size: number) {\n const items = this.store.get('items');\n const count = items.length;\n // viewport not inited\n if (!count) {\n return;\n }\n\n setStore(this.store, {\n items: setItemSizes(\n items,\n this.store.get('start'),\n size,\n this.lastCoordinate,\n ),\n });\n }\n\n getItems(): ItemsToUpdate {\n return {\n items: this.store.get('items'),\n start: this.store.get('start'),\n end: this.store.get('end'),\n };\n }\n\n setViewport(data: Partial<ViewportState>) {\n setStore(this.store, data);\n }\n\n clearItems() {\n this.store.set('items', []);\n }\n}\n"],"version":3}
@@ -1,5 +1,5 @@
1
1
  /*!
2
2
  * Built by Revolist OU ❤️
3
3
  */
4
- import{C as t,B as n,a as e,b as o}from"./dimension.helpers-56298828.js";import"./toNumber-8de324a7.js";import"./index-a61f225b.js";import{g as s}from"./selection.helpers-accaad4a.js";import{G as r,C as i,D as c}from"./index-4e881436.js";const a=`${r}-depth`;const u=`${r}-name`;const l=`${r}-id`;const f=`${r}-value`;const d=`${r}-column`;const p=`${r}-expanded`;const h=`${r}-original-index`;const y=`group-expand`;const v=`groupexpandclick`;const g="rgRow";function m(t,n){return t[n]||null}function x(t,n,{prevExpanded:e,expandedAll:o,getGroupValue:s=m}){const r=new Map;t.forEach(((t,e)=>{const o=n.map((n=>s(t,n)));const i=o.pop();let c=r;o.forEach((t=>{if(!c.has(t)){c.set(t,new Map)}c=c.get(t)}));if(!c.has(i)){c.set(i,[])}const a=c.get(i);a.push(Object.assign(Object.assign({},t),{[h]:e}))}));let i=-1;const c=n.length;const d={};const y={};const v={};const g=[];function x(t,n,s){const r=n.length;t.forEach(((t,c)=>{const m=[...n,c];const j=m.join(",");const b=s&&(!!o||!!(e===null||e===void 0?void 0:e[j]));g.push({[u]:c,[a]:r,[l]:JSON.stringify(m),[f]:j,[p]:b});i+=1;if(!b&&r){d[i]=true}if(Array.isArray(t)){t.forEach((t=>{i+=1;if(!b){d[i]=true}y[t[h]]=i;const n=m.map(((t,n)=>m.slice(0,n+1).join(",")));n.forEach((t=>{if(!v[t]){v[t]=[]}v[t].push(i)}))}));g.push(...t)}else{x(t,m,b)}}))}x(r,[],true);return{sourceWithGroups:g,depth:c,trimmed:d,oldNewIndexMap:y,childrenByGroup:v}}function j(t){return t&&t[u]}function b(t){return t&&typeof t[u]!=="undefined"}function w(t){return t&&typeof t[d]!=="undefined"}function O(t,n){const e=t.length;let o=0;for(;o<e;o++){if(t[o]!==n[o]){return o}}return o}function C(t){const n=JSON.parse(t);if(!Array.isArray(n)){return null}return n}function D(t,n,e){const o=C(e[l]);if(!o){return false}const s=O(t,o);return n[a]<s}const I="header";const R="footer";const $="content";const T="data";function A(t,n){const e=t.viewports[t.colType].store.get("realCount");const o=t.viewports[n].store.get("realCount");return{x:e,y:o}}function G(t,n,e,o){return{colData:t.colStore,viewportCol:t.viewports[t.colType].store,viewportRow:t.viewports[n].store,lastCell:A(t,n),slot:e,type:n,canDrag:!o,position:t.position,dataStore:t.rowStores[n].store,dimensionCol:t.dimensions[t.colType].store,dimensionRow:t.dimensions[n].store,style:o?{height:`${t.dimensions[n].store.get("realSize")}px`}:undefined}}function S(t,n,e){var o=-1,s=t.length;if(n<0){n=-n>s?0:s+n}e=e>s?s:e;if(e<0){e+=s}s=n>e?0:e-n>>>0;n>>>=0;var r=Array(s);while(++o<s){r[o]=t[o+n]}return r}var M=S;var N=M,P=t,k=n;function B(t,n,e){var o=t==null?0:t.length;if(!o){return[]}if(e&&typeof e!="number"&&P(t,n,e)){n=0;e=o}else{n=n==null?0:k(n);e=e===undefined?o:k(e)}return N(t,n,e)}var E=B;class J{get columns(){return e(this.source)}constructor(t,n){this.dataStore=t;this.source=n;this.unsubscribe=[];this.hasGrouping=false;this.unsubscribe.push(n.onChange("source",(t=>this.checkGrouping(t))));this.checkGrouping(n.get("source"));this.type=n.get("type")}checkGrouping(t){for(let n of t){if(w(n)){this.hasGrouping=true;return}this.hasGrouping=false}}isReadOnly(t,n){var e;const o=(e=this.columns[n])===null||e===void 0?void 0:e.readonly;if(typeof o==="function"){const e=this.rowDataModel(t,n);return o(e)}return!!o}mergeProperties(t,n,e,o,s){const r={[i]:true,[c]:this.isReadOnly(t,n)};let a=Object.assign(Object.assign({},e),{class:r});const u=s===null||s===void 0?void 0:s(o);if(!u){return a}return F(a,u)}getRowClass(t,n){const e=o(this.dataStore,t)||{};return e[n]||""}getCellData(t,n){const e=this.rowDataModel(t,n);return q(e.model[e.prop])}getSaveData(t,n,e){if(typeof e==="undefined"){e=this.getCellData(t,n)}const o=this.rowDataModel(t,n);return{prop:o.prop,rowIndex:t,colIndex:n,val:e,model:o.model,colType:this.type,type:this.dataStore.get("type")}}getCellEditor(t,n,e){var o;const s=(o=this.columns[n])===null||o===void 0?void 0:o.editor;if(!s){return undefined}if(typeof s==="string"){return e[s]}return s}rowDataModel(t,n){const e=this.columns[n];const s=e===null||e===void 0?void 0:e.prop;const r=o(this.dataStore,t)||{};const i=r[s];const c=this.dataStore.get("type");return{prop:s,model:r,data:this.dataStore.get("source"),column:e,rowIndex:t,colIndex:n,colType:this.type,type:c,value:i}}getRangeData(t,n){var e;const s={};const r=t.oldRange.x1-t.oldRange.x+1;const i=t.oldRange.y1-t.oldRange.y+1;const c={};for(let a=t.newRange.y,u=0;a<t.newRange.y1+1;a++,u++){const l=t.oldRange.y+u%i;const f=o(this.dataStore,l)||{};for(let o=t.newRange.x,i=0;o<t.newRange.x1+1;o++,i++){if(a>=t.oldRange.y&&a<=t.oldRange.y1&&o>=t.oldRange.x&&o<=t.oldRange.x1){continue}if(!this.columns[o]){continue}const u=(e=this.columns[o])===null||e===void 0?void 0:e.prop;const d=t.oldRange.x+i%r;const p=n[d].prop;if(!this.isReadOnly(a,o)){if(!s[a]){s[a]={}}s[a][u]=f[p];if(!c[a]){c[a]={}}c[a][u]={colIndex:d,colProp:p,rowIndex:l}}}}return{changed:s,mapping:c}}getTransformedDataToApply(t,n){const e={};const o=n.length;const r=this.columns.length;const i=this.dataStore.get("items").length;let c=t.y;let a=0;for(let s=0;c<i&&s<o;c++,s++){const i=n[s%o];const u=(i===null||i===void 0?void 0:i.length)||0;let l=t.x;for(let t=0;l<r&&t<u;l++,t++){const n=this.columns[l].prop;const o=t%r;if(!this.isReadOnly(c,l)){if(!e[c]){e[c]={}}e[c][n]=i[o]}}a=Math.max(a,l-1)}const u=s(t,{y:c-1,x:a});return{changed:e,range:u}}getRangeStaticData(t,n){const e={};for(let o=t.y,s=0;o<t.y1+1;o++,s++){for(let s=t.x,r=0;s<t.x1+1;s++,r++){if(!this.columns[s]){continue}const t=this.columns[s].prop;if(!this.isReadOnly(o,s)){if(!e[o]){e[o]={}}e[o][t]=n}}}return e}getRangeTransformedToProps(t,n){var e;const s=[];const r=this.dataStore.get("type");for(let i=t.y,c=0;i<t.y1+1;i++,c++){for(let c=t.x,a=0;c<t.x1+1;c++,a++){const t=(e=this.columns[c])===null||e===void 0?void 0:e.prop;s.push({prop:t,rowIndex:i,colIndex:c,model:o(n,i),type:r,colType:this.type})}}return s}copyRangeArray(t,n){const e=[...this.columns];const s=E(e,t.x,t.x1+1).map((t=>t.prop));const r=[];const i={};for(let e=t.y;e<=t.y1;e++){const t=[];i[e]={};for(let r of s){const s=o(n,e);if(!s){continue}const c=s[r];t.push(c);i[e][r]=c}r.push(t)}return{data:r,mapping:i}}destroy(){this.unsubscribe.forEach((t=>t()))}}function q(t){if(typeof t==="undefined"||t===null){return""}return t}function z(t,n){if(typeof t==="function"){return t(n)}return!!t}function F(t,n){let e=Object.assign(Object.assign({},n),t);if(n.class){if(typeof n.class==="object"&&typeof e.class==="object"){e.class=Object.assign(Object.assign({},n.class),e.class)}else if(typeof n.class==="string"&&typeof e.class==="object"){e.class[n.class]=true}else if(typeof e.class==="string"){e.class+=" "+n.class}}if(n.style){e.style=Object.assign(Object.assign({},n.style),e.style)}return e}export{$ as C,T as D,R as F,p as G,I as H,f as P,C as a,D as b,a as c,l as d,g as e,d as f,j as g,v as h,b as i,x as j,w as k,F as l,J as m,y as n,u as o,z as p,q,G as v};
5
- //# sourceMappingURL=column.service-5d14e7e9.js.map
4
+ import{A as t,z as n,a as e,b as o}from"./dimension.helpers-938ea850.js";import"./toNumber-8de324a7.js";import"./index-a61f225b.js";import{g as s}from"./selection.helpers-a49a3d09.js";import{G as r,C as i,D as c}from"./index-4e881436.js";const a=`${r}-depth`;const u=`${r}-name`;const l=`${r}-id`;const f=`${r}-value`;const d=`${r}-column`;const p=`${r}-expanded`;const h=`${r}-original-index`;const y=`group-expand`;const v=`groupexpandclick`;const g="rgRow";function m(t,n){return t[n]||null}function x(t,n,{prevExpanded:e,expandedAll:o,getGroupValue:s=m}){const r=new Map;t.forEach(((t,e)=>{const o=n.map((n=>s(t,n)));const i=o.pop();let c=r;o.forEach((t=>{if(!c.has(t)){c.set(t,new Map)}c=c.get(t)}));if(!c.has(i)){c.set(i,[])}const a=c.get(i);a.push(Object.assign(Object.assign({},t),{[h]:e}))}));let i=-1;const c=n.length;const d={};const y={};const v={};const g=[];function x(t,n,s){const r=n.length;t.forEach(((t,c)=>{const m=[...n,c];const j=m.join(",");const b=s&&(!!o||!!(e===null||e===void 0?void 0:e[j]));g.push({[u]:c,[a]:r,[l]:JSON.stringify(m),[f]:j,[p]:b});i+=1;if(!b&&r){d[i]=true}if(Array.isArray(t)){t.forEach((t=>{i+=1;if(!b){d[i]=true}y[t[h]]=i;const n=m.map(((t,n)=>m.slice(0,n+1).join(",")));n.forEach((t=>{if(!v[t]){v[t]=[]}v[t].push(i)}))}));g.push(...t)}else{x(t,m,b)}}))}x(r,[],true);return{sourceWithGroups:g,depth:c,trimmed:d,oldNewIndexMap:y,childrenByGroup:v}}function j(t){return t&&t[u]}function b(t){return t&&typeof t[u]!=="undefined"}function w(t){return t&&typeof t[d]!=="undefined"}function O(t,n){const e=t.length;let o=0;for(;o<e;o++){if(t[o]!==n[o]){return o}}return o}function C(t){const n=JSON.parse(t);if(!Array.isArray(n)){return null}return n}function D(t,n,e){const o=C(e[l]);if(!o){return false}const s=O(t,o);return n[a]<s}const I="header";const R="footer";const $="content";const A="data";function T(t,n){const e=t.viewports[t.colType].store.get("realCount");const o=t.viewports[n].store.get("realCount");return{x:e,y:o}}function G(t,n,e,o){return{colData:t.colStore,viewportCol:t.viewports[t.colType].store,viewportRow:t.viewports[n].store,lastCell:T(t,n),slot:e,type:n,canDrag:!o,position:t.position,dataStore:t.rowStores[n].store,dimensionCol:t.dimensions[t.colType].store,dimensionRow:t.dimensions[n].store,style:o?{height:`${t.dimensions[n].store.get("realSize")}px`}:undefined}}function S(t,n,e){var o=-1,s=t.length;if(n<0){n=-n>s?0:s+n}e=e>s?s:e;if(e<0){e+=s}s=n>e?0:e-n>>>0;n>>>=0;var r=Array(s);while(++o<s){r[o]=t[o+n]}return r}var M=S;var N=M,P=t,k=n;function z(t,n,e){var o=t==null?0:t.length;if(!o){return[]}if(e&&typeof e!="number"&&P(t,n,e)){n=0;e=o}else{n=n==null?0:k(n);e=e===undefined?o:k(e)}return N(t,n,e)}var E=z;class J{get columns(){return e(this.source)}constructor(t,n){this.dataStore=t;this.source=n;this.unsubscribe=[];this.hasGrouping=false;this.unsubscribe.push(n.onChange("source",(t=>this.checkGrouping(t))));this.checkGrouping(n.get("source"));this.type=n.get("type")}checkGrouping(t){for(let n of t){if(w(n)){this.hasGrouping=true;return}this.hasGrouping=false}}isReadOnly(t,n){var e;const o=(e=this.columns[n])===null||e===void 0?void 0:e.readonly;if(typeof o==="function"){const e=this.rowDataModel(t,n);return o(e)}return!!o}mergeProperties(t,n,e,o,s){const r={[i]:true,[c]:this.isReadOnly(t,n)};let a=Object.assign(Object.assign({},e),{class:r});const u=s===null||s===void 0?void 0:s(o);if(!u){return a}return F(a,u)}getRowClass(t,n){const e=o(this.dataStore,t)||{};return e[n]||""}getCellData(t,n){const e=this.rowDataModel(t,n);return q(e.model[e.prop])}getSaveData(t,n,e){if(typeof e==="undefined"){e=this.getCellData(t,n)}const o=this.rowDataModel(t,n);return{prop:o.prop,rowIndex:t,colIndex:n,val:e,model:o.model,colType:this.type,type:this.dataStore.get("type")}}getCellEditor(t,n,e){var o;const s=(o=this.columns[n])===null||o===void 0?void 0:o.editor;if(!s){return undefined}if(typeof s==="string"){return e[s]}return s}rowDataModel(t,n){const e=this.columns[n];const s=e===null||e===void 0?void 0:e.prop;const r=o(this.dataStore,t)||{};const i=r[s];const c=this.dataStore.get("type");return{prop:s,model:r,data:this.dataStore.get("source"),column:e,rowIndex:t,colIndex:n,colType:this.type,type:c,value:i}}getRangeData(t,n){var e;const s={};const r=t.oldRange.x1-t.oldRange.x+1;const i=t.oldRange.y1-t.oldRange.y+1;const c={};for(let a=t.newRange.y,u=0;a<t.newRange.y1+1;a++,u++){const l=t.oldRange.y+u%i;const f=o(this.dataStore,l)||{};for(let o=t.newRange.x,i=0;o<t.newRange.x1+1;o++,i++){if(a>=t.oldRange.y&&a<=t.oldRange.y1&&o>=t.oldRange.x&&o<=t.oldRange.x1){continue}if(!this.columns[o]){continue}const u=(e=this.columns[o])===null||e===void 0?void 0:e.prop;const d=t.oldRange.x+i%r;const p=n[d].prop;if(!this.isReadOnly(a,o)){if(!s[a]){s[a]={}}s[a][u]=f[p];if(!c[a]){c[a]={}}c[a][u]={colIndex:d,colProp:p,rowIndex:l}}}}return{changed:s,mapping:c}}getTransformedDataToApply(t,n){const e={};const o=n.length;const r=this.columns.length;const i=this.dataStore.get("items").length;let c=t.y;let a=0;for(let s=0;c<i&&s<o;c++,s++){const i=n[s%o];const u=(i===null||i===void 0?void 0:i.length)||0;let l=t.x;for(let t=0;l<r&&t<u;l++,t++){const n=this.columns[l].prop;const o=t%r;if(!this.isReadOnly(c,l)){if(!e[c]){e[c]={}}e[c][n]=i[o]}}a=Math.max(a,l-1)}const u=s(t,{y:c-1,x:a});return{changed:e,range:u}}getRangeStaticData(t,n){const e={};for(let o=t.y,s=0;o<t.y1+1;o++,s++){for(let s=t.x,r=0;s<t.x1+1;s++,r++){if(!this.columns[s]){continue}const t=this.columns[s].prop;if(!this.isReadOnly(o,s)){if(!e[o]){e[o]={}}e[o][t]=n}}}return e}getRangeTransformedToProps(t,n){var e;const s=[];const r=this.dataStore.get("type");for(let i=t.y,c=0;i<t.y1+1;i++,c++){for(let c=t.x,a=0;c<t.x1+1;c++,a++){const t=(e=this.columns[c])===null||e===void 0?void 0:e.prop;s.push({prop:t,rowIndex:i,colIndex:c,model:o(n,i),type:r,colType:this.type})}}return s}copyRangeArray(t,n){const e=[...this.columns];const s=E(e,t.x,t.x1+1).map((t=>t.prop));const r=[];const i={};for(let e=t.y;e<=t.y1;e++){const t=[];i[e]={};for(let r of s){const s=o(n,e);if(!s){continue}const c=s[r];t.push(c);i[e][r]=c}r.push(t)}return{data:r,mapping:i}}destroy(){this.unsubscribe.forEach((t=>t()))}}function q(t){if(typeof t==="undefined"||t===null){return""}return t}function B(t,n){if(typeof t==="function"){return t(n)}return!!t}function F(t,n){let e=Object.assign(Object.assign({},n),t);if(n.class){if(typeof n.class==="object"&&typeof e.class==="object"){e.class=Object.assign(Object.assign({},n.class),e.class)}else if(typeof n.class==="string"&&typeof e.class==="object"){e.class[n.class]=true}else if(typeof e.class==="string"){e.class+=" "+n.class}}if(n.style){e.style=Object.assign(Object.assign({},n.style),e.style)}return e}export{$ as C,A as D,R as F,p as G,I as H,f as P,C as a,D as b,a as c,l as d,g as e,d as f,j as g,v as h,b as i,x as j,w as k,F as l,J as m,y as n,u as o,B as p,q,G as v};
5
+ //# sourceMappingURL=column.service-cfc1149b.js.map
@@ -0,0 +1,5 @@
1
+ /*!
2
+ * Built by Revolist OU ❤️
3
+ */
4
+ import{l as t,r as e,k as i,h as n,m as s}from"./dimension.helpers-938ea850.js";import"./toNumber-8de324a7.js";import{h as o}from"./index-a61f225b.js";const r=t=>{let e={};const i=(i,n)=>{const s=Object.assign({},i);e={};for(const[t,i]of Object.entries(n)){const n=t;if(i&&s[n]){e[n]=s[n];delete s[n]}}t.setDimensionSize(s)};return{set(n,s){switch(n){case"trimmed":const n=s;const o=t.store.get("sizes");i(Object.assign(Object.assign({},o),e),n);break}}}};const c=t=>({set(e){switch(e){case"count":case"sizes":case"originItemSize":let e=0;const i=t.store.get("count");for(let n=0;n<i;n++){e+=t.store.get("sizes")[n]||t.store.get("originItemSize")}t.setStore({realSize:e})}}});function u(){return{indexes:[],count:0,trimmed:{},sizes:{},positionIndexToItem:{},indexToItem:{},positionIndexes:[]}}function a(){return Object.assign(Object.assign({},u()),{realSize:0,originItemSize:0})}class l{constructor(){this.store=t(a());this.store.use(r(this));this.store.use(c(this))}getCurrentState(){const t=a();const i=Object.keys(t);return e(i,((t,e)=>{const i=this.store.get(e);t[e]=i;return t}),t)}dispose(){i(this.store,a())}setStore(t){i(this.store,t)}drop(){i(this.store,u())}setDimensionSize(t){const e=n(this.store.get("originItemSize"),t);i(this.store,e)}}const f=["rowPinStart","rgRow","rowPinEnd"];const d=["colPinStart","rgCol","colPinEnd"];function h(t){return f.indexOf(t)>-1}class m{constructor(t,e){this.revogrid=t;this.providers=e;this.h=o;this.subscriptions={}}addEventListener(t,e){this.revogrid.addEventListener(t,e);this.subscriptions[t]=e}watch(t,e,{immediate:i}={immediate:false}){const n=Object.getOwnPropertyDescriptor(this.revogrid,t)||Object.getOwnPropertyDescriptor(this.revogrid.constructor.prototype,t);Object.defineProperty(this.revogrid,t,{set(t){var i;const s=e(t);if(s===false){return}return(i=n===null||n===void 0?void 0:n.set)===null||i===void 0?void 0:i.call(this,t)},get(){var t;return(t=n===null||n===void 0?void 0:n.get)===null||t===void 0?void 0:t.call(this)}});if(i){e(n===null||n===void 0?void 0:n.value)}}removeEventListener(t){this.revogrid.removeEventListener(t,this.subscriptions[t]);delete this.subscriptions[t]}emit(t,e){const i=new CustomEvent(t,{detail:e,cancelable:true});this.revogrid.dispatchEvent(i);return i}clearSubscriptions(){for(let t in this.subscriptions){this.removeEventListener(t)}}destroy(){this.clearSubscriptions()}}function b(t){if(t.pin){return t.pin}return"rgCol"}function j(t){const e={};for(const[i,n]of t.entries()){if(n.size){e[i]=n.size}}return e}function v(t){return!!t.children}function O(t,i=0,n){const s={columns:{rgCol:[],colPinStart:[],colPinEnd:[]},columnByProp:{},columnGrouping:{rgCol:[],colPinStart:[],colPinEnd:[]},maxLevel:i,sort:{}};return e(t,((t,e)=>{if(v(e)){return S(t,e,O(e.children,i+1,n),i)}const s=Object.assign(Object.assign({},e.columnType&&n&&n[e.columnType]),e);if(!s.pin){t.columns.rgCol.push(s)}else{t.columns[s.pin].push(s)}if(s.order){t.sort[s.prop]=s}if(!t.columnByProp[s.prop]){t.columnByProp[s.prop]=[]}t.columnByProp[s.prop].push(s);s.beforeSetup&&s.beforeSetup(s);return t}),s)}function S(t,e,i,n=0){const o=Object.assign(Object.assign({},e),{level:n,ids:[]});for(let e in i.columns){const n=e;const r=t.columns[n];const c=i.columns[n];if(s(r)&&s(c)){r.push(...c);if(c.length){t.columnGrouping[n].push(Object.assign(Object.assign({},o),{ids:c.map((t=>t.prop))}))}}}for(let e in i.columnGrouping){const n=e;const s=i.columnGrouping[n];t.columnGrouping[n].push(...s)}t.maxLevel=Math.max(t.maxLevel,i.maxLevel);t.sort=Object.assign(Object.assign({},t.sort),i.sort);return t}function g(t,e){for(const i of t){if(v(i)){const t=g(i.children,e);if(t){return t}}else if(i.prop===e){return i}}return undefined}function p(t,e){return g(t,e)}export{m as B,l as D,j as a,v as b,d as c,O as d,S as e,p as f,b as g,h as i,f as r};
5
+ //# sourceMappingURL=column.utils-f6300fb5.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["trimmedPlugin","store","trimmedSize","setTrimmed","sizes","trimmed","newSize","Object","assign","index","v","entries","i","setDimensionSize","set","key","val","trim","get","realSizePlugin","k","realSize","count","setStore","initialBase","indexes","positionIndexToItem","indexToItem","positionIndexes","initialState","originItemSize","DimensionStore","constructor","this","createStore","use","getCurrentState","state","keys","reduce","r","data","dispose","drop","dimensionData","calculateDimensionData","rowTypes","columnTypes","isRowType","type","indexOf","BasePlugin","revogrid","providers","h","subscriptions","addEventListener","eventName","callback","watch","prop","immediate","nativeValueDesc","getOwnPropertyDescriptor","prototype","defineProperty","keepDefault","_a","call","value","removeEventListener","emit","detail","event","CustomEvent","cancelable","dispatchEvent","clearSubscriptions","destroy","getColumnType","rgCol","pin","getColumnSizes","cols","res","c","size","isColGrouping","colData","children","getColumns","columns","level","types","collection","colPinStart","colPinEnd","columnByProp","columnGrouping","maxLevel","sort","gatherGroup","regularColumn","columnType","push","order","beforeSetup","group","ids","resultItem","collectionItem","isArray","length","map","item","Math","max","findColumn","found","undefined","getColumnByProp"],"sources":["src/store/dimension/dimension.store.ts","src/store/index.ts","src/plugins/base.plugin.ts","src/utils/column.utils.ts"],"sourcesContent":["/**\n * Storing pre-calculated\n * Dimension information and sizes\n */\nimport reduce from 'lodash/reduce';\nimport { createStore } from '@stencil/store';\n\nimport { setStore, Observable, PluginSubscribe } from '../../utils/store.utils';\nimport { calculateDimensionData } from './dimension.helpers';\nimport {\n DimensionCalc,\n DimensionSettingsState,\n ViewSettingSizeProp,\n MultiDimensionType,\n} from '@type';\n\nexport type DimensionStoreCollection = {\n [T in MultiDimensionType]: DimensionStore;\n};\n\ntype Item = keyof DimensionSettingsState;\n\nconst trimmedPlugin = (\n store: DimensionStore,\n): PluginSubscribe<DimensionSettingsState> => {\n let trimmedSize: DimensionSettingsState['sizes'] = {};\n\n const setTrimmed = (\n sizes: DimensionSettingsState['sizes'],\n trimmed: DimensionSettingsState['trimmed'],\n ) => {\n const newSize: DimensionSettingsState['sizes'] = { ...sizes };\n trimmedSize = {};\n for (const [index, v] of Object.entries(trimmed)) {\n const i = index as keyof DimensionSettingsState['sizes'];\n if (v && newSize[i]) {\n trimmedSize[i] = newSize[i];\n delete newSize[i];\n }\n }\n store.setDimensionSize(newSize);\n };\n return {\n set(key, val) {\n switch (key) {\n case 'trimmed':\n const trim = val as DimensionSettingsState['trimmed'];\n const sizes = store.store.get('sizes');\n // recover trimmed, apply new trim\n setTrimmed({ ...sizes, ...trimmedSize }, trim);\n break;\n }\n },\n };\n};\n\nconst realSizePlugin = (\n store: DimensionStore,\n): PluginSubscribe<DimensionSettingsState> => {\n return {\n set(k) {\n switch (k) {\n case 'count':\n case 'sizes':\n case 'originItemSize':\n let realSize = 0;\n const count = store.store.get('count');\n for (let i = 0; i < count; i++) {\n realSize +=\n store.store.get('sizes')[i] || store.store.get('originItemSize');\n }\n store.setStore({ realSize });\n }\n },\n };\n};\n\nfunction initialBase(): DimensionCalc {\n return {\n indexes: [],\n count: 0,\n\n // plugin support\n trimmed: {},\n\n // size operations, this provider stores only changed sizes, not all of them\n // same as indexes but for sizes and positions\n // item index to size\n sizes: {},\n // order in indexes[] to coordinate\n positionIndexToItem: {},\n // initial element to coordinate ^\n indexToItem: {},\n positionIndexes: [],\n };\n}\n\nfunction initialState(): DimensionSettingsState {\n return {\n ...initialBase(),\n // size which all items can take\n realSize: 0,\n\n // initial item size if it wasn't changed\n originItemSize: 0,\n };\n}\n\nexport class DimensionStore {\n readonly store: Observable<DimensionSettingsState>;\n constructor() {\n this.store = createStore(initialState());\n this.store.use(trimmedPlugin(this));\n this.store.use(realSizePlugin(this));\n }\n\n getCurrentState(): DimensionSettingsState {\n const state = initialState();\n const keys = Object.keys(state);\n return reduce(\n keys,\n (r: DimensionSettingsState, k: Item) => {\n const data = this.store.get(k);\n r[k] = data as never;\n return r;\n },\n state,\n );\n }\n\n dispose() {\n setStore(this.store, initialState());\n }\n\n setStore<T extends Record<string, any>>(data: Partial<T>) {\n setStore(this.store, data);\n }\n\n drop() {\n setStore(this.store, initialBase());\n }\n\n /**\n * Set custom dimension sizes and overwrite old\n * Generates new indexes based on sizes\n * @param sizes - sizes to set\n */\n setDimensionSize(sizes: ViewSettingSizeProp) {\n const dimensionData = calculateDimensionData(\n this.store.get('originItemSize'),\n sizes,\n );\n setStore(this.store, dimensionData);\n }\n}\n","import type { DimensionCols, DimensionRows } from '@type';\n\nexport * from './dataSource';\nexport * from './dimension';\nexport * from './selection';\nexport * from './vp';\n\nexport const rowTypes: DimensionRows[] = ['rowPinStart', 'rgRow', 'rowPinEnd'];\nexport const columnTypes: DimensionCols[] = [\n 'colPinStart',\n 'rgCol',\n 'colPinEnd',\n];\n\nexport function isRowType(type: DimensionRows | any): type is DimensionRows {\n return rowTypes.indexOf(type) > -1;\n}\n","import { h } from '@stencil/core';\nimport { PluginProviders, PluginBaseComponent } from '..';\n\ntype WatchConfig = { immediate: boolean };\n\n/**\n * Base layer for plugins\n * Provide minimal starting core for plugins to work\n * Extend this class to create plugin\n */\nexport class BasePlugin implements PluginBaseComponent {\n readonly h = h;\n readonly subscriptions: Record<string, (...args: any[]) => void> = {};\n constructor(public revogrid: HTMLRevoGridElement, public providers: PluginProviders) {}\n /**\n *\n * @param eventName - event name to subscribe to in revo-grid component (e.g. 'beforeheaderclick')\n * @param callback - callback function for event\n */\n addEventListener<T = any>(\n eventName: string,\n callback: (e: CustomEvent<T>) => void,\n ) {\n this.revogrid.addEventListener(eventName, callback);\n this.subscriptions[eventName] = callback;\n }\n\n /**\n * Subscribe to property change in revo-grid component\n * You can return false in callback to prevent default value set\n *\n * @param prop - property name\n * @param callback - callback function\n * @param immediate - trigger callback immediately with current value\n */\n watch<T extends any>(\n prop: string,\n callback: (arg: T) => boolean | void,\n { immediate }: Partial<WatchConfig> = { immediate: false },\n ) {\n const nativeValueDesc =\n Object.getOwnPropertyDescriptor(this.revogrid, prop) ||\n Object.getOwnPropertyDescriptor(this.revogrid.constructor.prototype, prop);\n\n // Overwrite property descriptor for this instance\n Object.defineProperty(this.revogrid, prop, {\n set(val: T) {\n const keepDefault = callback(val);\n if (keepDefault === false) {\n return;\n }\n // Continue with native behavior\n return nativeValueDesc?.set?.call(this, val);\n },\n get() {\n // Continue with native behavior\n return nativeValueDesc?.get?.call(this);\n },\n });\n if (immediate) {\n callback(nativeValueDesc?.value);\n }\n }\n\n /**\n * Remove event listener\n * @param eventName\n */\n removeEventListener(eventName: string) {\n this.revogrid.removeEventListener(eventName, this.subscriptions[eventName]);\n delete this.subscriptions[eventName];\n }\n\n /**\n * Emit event from revo-grid component\n * Event can be cancelled by calling event.preventDefault() in callback\n */\n emit<T = any>(eventName: string, detail?: T) {\n const event = new CustomEvent<T>(eventName, { detail, cancelable: true });\n this.revogrid.dispatchEvent(event);\n return event;\n }\n\n /**\n * Clear all subscriptions\n */\n clearSubscriptions() {\n for (let type in this.subscriptions) {\n this.removeEventListener(type);\n }\n }\n\n /**\n * Destroy plugin and clear all subscriptions\n */\n destroy() {\n this.clearSubscriptions();\n }\n}\n\nexport type GridPlugin = (typeof BasePlugin);\n","import isArray from 'lodash/isArray';\nimport reduce from 'lodash/reduce';\n\nimport {\n ColumnData,\n ColumnGrouping,\n ColumnProp,\n ColumnRegular,\n ColumnTypes,\n DimensionCols,\n ViewSettingSizeProp,\n} from '@type';\nimport { Group as StoreGroup } from '@store';\n\nexport type ColumnItems = Record<DimensionCols, ColumnRegular[]>;\nexport interface ColumnGroup extends StoreGroup {\n level: number;\n}\nexport type ColumnGroupingCollection = Record<DimensionCols, ColumnGroup[]>;\n\n/**\n * Column collection definition.\n * Used to access indexed data for columns.\n * Can be accessed via different events.\n */\nexport type ColumnCollection = {\n /**\n * Columns as they are in stores\n */\n columns: Record<DimensionCols, ColumnRegular[]>;\n /**\n * Columns indexed by prop for quick access, it's possible to have multiple columns with same prop but not recommended\n */\n columnByProp: Record<ColumnProp, ColumnRegular[]>;\n /**\n * Grouped columns\n */\n columnGrouping: ColumnGroupingCollection;\n /**\n * Max level of grouping\n */\n maxLevel: number;\n /**\n * Sorting\n */\n sort: Record<ColumnProp, ColumnRegular>;\n};\n\nexport function getColumnType(rgCol: ColumnRegular): DimensionCols {\n if (rgCol.pin) {\n return rgCol.pin;\n }\n return 'rgCol';\n}\n\nexport function getColumnSizes(cols: ColumnRegular[]): ViewSettingSizeProp {\n const res: ViewSettingSizeProp = {};\n for (const [i, c] of cols.entries()) {\n if (c.size) {\n res[i] = c.size;\n }\n }\n return res;\n}\n\n\n/**\n * Check if column is grouping column\n */\nexport function isColGrouping(\n colData: ColumnGrouping | ColumnRegular,\n): colData is ColumnGrouping {\n return !!(colData as ColumnGrouping).children;\n}\n\n/**\n * This function is used to create a collection of columns.\n */\nexport function getColumns(\n columns: ColumnData,\n level = 0,\n types?: ColumnTypes,\n): ColumnCollection {\n const collection: ColumnCollection = {\n // columns as they are in stores per type\n columns: {\n rgCol: [],\n colPinStart: [],\n colPinEnd: [],\n },\n // columns indexed by prop for quick access\n columnByProp: {},\n // column grouping\n columnGrouping: {\n rgCol: [],\n colPinStart: [],\n colPinEnd: [],\n },\n // max depth level for column grouping\n maxLevel: level,\n // sorting\n sort: {},\n };\n\n return reduce(\n columns,\n (res: ColumnCollection, colData: ColumnGrouping | ColumnRegular) => {\n // Grouped column\n if (isColGrouping(colData)) {\n return gatherGroup(\n res,\n colData,\n getColumns(colData.children, level + 1, types),\n level,\n );\n }\n // Regular column\n const regularColumn = {\n ...(colData.columnType && types && types[colData.columnType]),\n ...colData,\n };\n // Regular column, no Pin\n if (!regularColumn.pin) {\n res.columns.rgCol.push(regularColumn);\n // Pin\n } else {\n res.columns[regularColumn.pin].push(regularColumn);\n }\n if (regularColumn.order) {\n res.sort[regularColumn.prop] = regularColumn;\n }\n // it's possible that some columns have same prop, but better to avoid it\n if (!res.columnByProp[regularColumn.prop]) {\n res.columnByProp[regularColumn.prop] = [];\n }\n res.columnByProp[regularColumn.prop].push(regularColumn);\n\n // trigger setup hook if present\n regularColumn.beforeSetup && regularColumn.beforeSetup(regularColumn);\n return res;\n },\n collection,\n );\n}\n\nexport function gatherGroup<T extends ColumnCollection>(\n res: T,\n colData: ColumnGrouping,\n collection: T,\n level = 0,\n): T {\n // group template\n const group: ColumnGroup = {\n ...colData,\n level,\n ids: [],\n };\n\n // check columns for update\n for (let k in collection.columns) {\n const key = k as keyof ColumnCollection['columns'];\n const resultItem = res.columns[key];\n const collectionItem = collection.columns[key];\n\n // if column data\n if (isArray(resultItem) && isArray(collectionItem)) {\n // fill columns\n resultItem.push(...collectionItem);\n\n // fill grouping\n if (collectionItem.length) {\n res.columnGrouping[key].push({\n ...group,\n ids: collectionItem.map(item => item.prop),\n });\n }\n }\n }\n // merge column groupings\n for (let k in collection.columnGrouping) {\n const key = k as DimensionCols;\n const collectionItem = collection.columnGrouping[key];\n res.columnGrouping[key].push(...collectionItem);\n }\n res.maxLevel = Math.max(res.maxLevel, collection.maxLevel);\n res.sort = { ...res.sort, ...collection.sort };\n return res;\n}\n\nfunction findColumn(\n columns: ColumnData,\n prop: ColumnProp,\n): ColumnRegular | undefined {\n for (const c of columns) {\n if (isColGrouping(c)) {\n const found = findColumn(c.children, prop);\n if (found) {\n return found;\n }\n } else if (c.prop === prop) {\n return c;\n }\n }\n return undefined;\n}\n\nexport function getColumnByProp(\n columns: ColumnData,\n prop: ColumnProp,\n): ColumnRegular | undefined {\n return findColumn(columns, prop);\n}\n"],"mappings":";;;uJAsBA,MAAMA,EACJC,IAEA,IAAIC,EAA+C,GAEnD,MAAMC,EAAa,CACjBC,EACAC,KAEA,MAAMC,EAAOC,OAAAC,OAAA,GAAyCJ,GACtDF,EAAc,GACd,IAAK,MAAOO,EAAOC,KAAMH,OAAOI,QAAQN,GAAU,CAChD,MAAMO,EAAIH,EACV,GAAIC,GAAKJ,EAAQM,GAAI,CACnBV,EAAYU,GAAKN,EAAQM,UAClBN,EAAQM,E,EAGnBX,EAAMY,iBAAiBP,EAAQ,EAEjC,MAAO,CACL,GAAAQ,CAAIC,EAAKC,GACP,OAAQD,GACN,IAAK,UACH,MAAME,EAAOD,EACb,MAAMZ,EAAQH,EAAMA,MAAMiB,IAAI,SAE9Bf,EAAUI,OAAAC,OAAAD,OAAAC,OAAA,GAAMJ,GAAUF,GAAee,GACzC,M,EAGP,EAGH,MAAME,EACJlB,IAEO,CACL,GAAAa,CAAIM,GACF,OAA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