@revolist/revogrid 4.10.21 → 4.10.22
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.
- package/dist/cjs/revo-grid.cjs.entry.js +20 -8
- package/dist/cjs/revo-grid.cjs.entry.js.map +1 -1
- package/dist/cjs/revogr-attribution_7.cjs.entry.js +4 -4
- package/dist/cjs/revogr-attribution_7.cjs.entry.js.map +1 -1
- package/dist/cjs/revogr-clipboard_3.cjs.entry.js.map +1 -1
- package/dist/cjs/text-editor-62095c25.js.map +1 -1
- package/dist/collection/components/editors/revogr-edit.js +1 -1
- package/dist/collection/components/editors/revogr-edit.js.map +1 -1
- package/dist/collection/components/editors/text-editor.js.map +1 -1
- package/dist/collection/components/overlay/revogr-overlay-selection.js +7 -7
- package/dist/collection/components/overlay/revogr-overlay-selection.js.map +1 -1
- package/dist/collection/components/revoGrid/revo-grid.js +27 -12
- package/dist/collection/components/revoGrid/revo-grid.js.map +1 -1
- package/dist/collection/components/revoGrid/viewport.service.js +1 -1
- package/dist/collection/components/revoGrid/viewport.service.js.map +1 -1
- package/dist/collection/services/data.provider.js.map +1 -1
- package/dist/collection/types/selection.js.map +1 -1
- package/dist/collection/types/viewport.interfaces.js.map +1 -1
- package/dist/esm/revo-grid.entry.js +20 -8
- package/dist/esm/revo-grid.entry.js.map +1 -1
- package/dist/esm/revogr-attribution_7.entry.js +4 -4
- package/dist/esm/revogr-attribution_7.entry.js.map +1 -1
- package/dist/esm/revogr-clipboard_3.entry.js.map +1 -1
- package/dist/esm/text-editor-c799aad2.js.map +1 -1
- package/dist/revo-grid/revo-grid.entry.js +1 -1
- package/dist/revo-grid/revo-grid.entry.js.map +1 -1
- package/dist/revo-grid/revogr-attribution_7.entry.js +1 -1
- package/dist/revo-grid/revogr-attribution_7.entry.js.map +1 -1
- package/dist/revo-grid/revogr-clipboard_3.entry.js.map +1 -1
- package/dist/revo-grid/text-editor-c799aad2.js.map +1 -1
- package/dist/types/components/editors/revogr-edit.d.ts +2 -2
- package/dist/types/components/editors/text-editor.d.ts +2 -3
- package/dist/types/components/overlay/revogr-overlay-selection.d.ts +1 -1
- package/dist/types/components/revoGrid/revo-grid.d.ts +8 -2
- package/dist/types/components.d.ts +6 -5
- package/dist/types/services/data.provider.d.ts +1 -1
- package/dist/types/types/selection.d.ts +4 -5
- package/dist/types/types/viewport.interfaces.d.ts +0 -2
- package/hydrate/index.js +24 -12
- package/hydrate/index.mjs +24 -12
- package/package.json +1 -1
- package/standalone/revo-grid.js +20 -8
- package/standalone/revo-grid.js.map +1 -1
- package/standalone/revogr-edit2.js.map +1 -1
- package/standalone/revogr-overlay-selection2.js +4 -4
- package/standalone/revogr-overlay-selection2.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Clipboard","onPaste","e","this","readonly","clipboardData","getData","isHTML","types","indexOf","data","dataText","beforePaste","emit","raw","event","defaultPrevented","parsedData","detail","table","htmlParse","textParse","beforePasteApply","parsed","pasteRegion","afterPasteApply","preventDefault","copyStarted","beforeCopy","copyRegion","undefined","cutStarted","beforeCut","clearRegion","doCopy","beforeCopyApply","parserCopy","setData","map","rgRow","join","result","rows","split","y","push","fragment","document","createRange","createContextualFragment","querySelector","Array","from","cells","cell","innerText","window","revogrEditStyleCss","RevogrEditStyle0","RevoEdit","currentEditor","preventSaveOnClose","cancelChanges","beforeDisconnect","_b","_a","call","onAutoSave","val","getValue","_c","beforeAutoSave","canSave","onSave","preventFocus","editCell","cellEdit","rgCol","x","type","prop","componentWillRender","column","editor","isEditorCtrConstructible","focusNext","closeEdit","TextEditor","componentDidRender","element","firstElementChild","disconnectedCallback","saveOnClose","render","h","Host","class","EDIT_INPUT_WR","additionalData","RowOrderService","constructor","config","currentCell","previousRow","endOrder","newRow","getCell","positionChanged","clear","startOrder","move","getRow","itemIndex","el","top","getBoundingClientRect","topRelative","getItemByPosition","absolutePosition","start","end","cols","left","leftRelative","OrderEditor","events","rowMoveFunc","debounce","rowOrderService","rowDrag","Object","assign","rowType","dragStart","originalEvent","length","clearOrder","pos","dragStartEvent","rowDragStart","text","DRAGG_TEXT","model","getSourceItem","dataStore","moveMove","mouseUp","mouseLeave","name","listener","addEventListener","forEach","v","removeEventListener","rowDragEnd","rowMouseMove","connectedCallback","to","dropEvent","rowDropped","rowOrderChange","parent","dimensionRow","state","dimensionCol"],"sources":["src/components/clipboard/revogr-clipboard.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","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, getSourceItem } 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';\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\n @Prop() rowType: 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 rowType: DimensionRows;\n model: any;\n }>;\n\n /** Row drag ended started */\n @Event({ eventName: 'rowdragendinit' })\n rowDragEnd: EventEmitter<{ rowType: DimensionRows }>;\n\n /** Row move started */\n @Event({ eventName: 'rowdragmoveinit', cancelable: true })\n rowDrag: EventEmitter<PositionItem & { rowType: DimensionRows }>;\n\n /** Row mouse move started */\n @Event({ eventName: 'rowdragmousemove', cancelable: true })\n rowMouseMove: EventEmitter<Cell & { rowType: DimensionRows }>;\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 rowType: DimensionRows;\n }>;\n\n /** Row drag ended finished. Time to apply data */\n @Event({ eventName: 'roworderchange' })\n rowOrderChange: EventEmitter<{\n from: number;\n to: number;\n rowType: DimensionRows;\n }>;\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({\n ...rgRow,\n rowType: this.rowType,\n });\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 rowType: this.rowType,\n model: getSourceItem(this.dataStore, pos.itemIndex),\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({ rowType: this.rowType });\n }\n // #endregion\n\n move({ x, y }: { x: number; y: number }) {\n this.rowMouseMove.emit({ x, y, rowType: this.rowType });\n this.rowMoveFunc(y);\n }\n\n connectedCallback() {\n this.rowOrderService = new RowOrderService({\n positionChanged: (from: number, to: number) => {\n const dropEvent = this.rowDropped.emit({\n from,\n to,\n rowType: this.rowType,\n });\n if (dropEvent.defaultPrevented) {\n return;\n }\n this.rowOrderChange.emit(dropEvent.detail);\n },\n });\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"],"mappings":";;;oTAaaA,EAAS,M,obAkFqB,OAAAC,CAAQC,GAE/C,GAAIC,KAAKC,SAAU,CACjB,M,CAEF,MAAMC,EAAgBF,KAAKG,QAAQJ,GACnC,MAAMK,IAAUF,IAAa,MAAbA,SAAa,SAAbA,EAAeG,MAAMC,QAAQ,gBAAiB,IAAM,EACpE,MAAMC,GAAQH,EACVF,IAAa,MAAbA,SAAa,SAAbA,EAAeC,QAAQ,aACvBD,IAAa,MAAbA,SAAa,SAAbA,EAAeC,QAAQ,UAAY,GACvC,MAAMK,GAAWN,IAAa,MAAbA,SAAa,SAAbA,EAAeC,QAAQ,UAAW,GAEnD,MAAMM,EAAcT,KAAKS,YAAYC,KAAK,CACxCC,IAAKJ,EACLC,WACAJ,SACAQ,MAAOb,IAGT,GAAIU,EAAYI,iBAAkB,CAChC,M,CAGF,IAAIC,EAEJ,GAAIL,EAAYM,OAAOX,OAAQ,CAC7B,MAAMY,EAAQhB,KAAKiB,UAAUR,EAAYM,OAAOJ,KAEhDG,EAAaE,GAAShB,KAAKkB,UAAUV,GAAY,G,KAC5C,CACLM,EAAad,KAAKkB,UAAUT,EAAYM,OAAOJ,I,CAEjD,MAAMQ,EAAmBnB,KAAKmB,iBAAiBT,KAAK,CAClDC,IAAKJ,EACLa,OAAQN,EACRF,MAAOb,IAET,GAAIoB,EAAiBN,iBAAkB,CACr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clipboard","onPaste","e","this","readonly","clipboardData","getData","isHTML","types","indexOf","data","dataText","beforePaste","emit","raw","event","defaultPrevented","parsedData","detail","table","htmlParse","textParse","beforePasteApply","parsed","pasteRegion","afterPasteApply","preventDefault","copyStarted","beforeCopy","copyRegion","undefined","cutStarted","beforeCut","clearRegion","doCopy","beforeCopyApply","parserCopy","setData","map","rgRow","join","result","rows","split","y","push","fragment","document","createRange","createContextualFragment","querySelector","Array","from","cells","cell","innerText","window","revogrEditStyleCss","RevogrEditStyle0","RevoEdit","currentEditor","preventSaveOnClose","cancelChanges","beforeDisconnect","_b","_a","call","onAutoSave","val","getValue","_c","beforeAutoSave","canSave","onSave","preventFocus","editCell","cellEdit","rgCol","x","type","prop","componentWillRender","column","editor","isEditorCtrConstructible","focusNext","closeEdit","TextEditor","componentDidRender","element","firstElementChild","disconnectedCallback","saveOnClose","render","h","Host","class","EDIT_INPUT_WR","additionalData","RowOrderService","constructor","config","currentCell","previousRow","endOrder","newRow","getCell","positionChanged","clear","startOrder","move","getRow","itemIndex","el","top","getBoundingClientRect","topRelative","getItemByPosition","absolutePosition","start","end","cols","left","leftRelative","OrderEditor","events","rowMoveFunc","debounce","rowOrderService","rowDrag","Object","assign","rowType","dragStart","originalEvent","length","clearOrder","pos","dragStartEvent","rowDragStart","text","DRAGG_TEXT","model","getSourceItem","dataStore","moveMove","mouseUp","mouseLeave","name","listener","addEventListener","forEach","v","removeEventListener","rowDragEnd","rowMouseMove","connectedCallback","to","dropEvent","rowDropped","rowOrderChange","parent","dimensionRow","state","dimensionCol"],"sources":["src/components/clipboard/revogr-clipboard.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","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} 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?: any, 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, getSourceItem } 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';\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\n @Prop() rowType: 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 rowType: DimensionRows;\n model: any;\n }>;\n\n /** Row drag ended started */\n @Event({ eventName: 'rowdragendinit' })\n rowDragEnd: EventEmitter<{ rowType: DimensionRows }>;\n\n /** Row move started */\n @Event({ eventName: 'rowdragmoveinit', cancelable: true })\n rowDrag: EventEmitter<PositionItem & { rowType: DimensionRows }>;\n\n /** Row mouse move started */\n @Event({ eventName: 'rowdragmousemove', cancelable: true })\n rowMouseMove: EventEmitter<Cell & { rowType: DimensionRows }>;\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 rowType: DimensionRows;\n }>;\n\n /** Row drag ended finished. Time to apply data */\n @Event({ eventName: 'roworderchange' })\n rowOrderChange: EventEmitter<{\n from: number;\n to: number;\n rowType: DimensionRows;\n }>;\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({\n ...rgRow,\n rowType: this.rowType,\n });\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 rowType: this.rowType,\n model: getSourceItem(this.dataStore, pos.itemIndex),\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({ rowType: this.rowType });\n }\n // #endregion\n\n move({ x, y }: { x: number; y: number }) {\n this.rowMouseMove.emit({ x, y, rowType: this.rowType });\n this.rowMoveFunc(y);\n }\n\n connectedCallback() {\n this.rowOrderService = new RowOrderService({\n positionChanged: (from: number, to: number) => {\n const dropEvent = this.rowDropped.emit({\n from,\n to,\n rowType: this.rowType,\n });\n if (dropEvent.defaultPrevented) {\n return;\n }\n this.rowOrderChange.emit(dropEvent.detail);\n },\n });\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"],"mappings":";;;oTAaaA,EAAS,M,obAkFqB,OAAAC,CAAQC,GAE/C,GAAIC,KAAKC,SAAU,CACjB,M,CAEF,MAAMC,EAAgBF,KAAKG,QAAQJ,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AAO0B,SAAQC,GAAKzG,SAAS0G,oBAAoBD,EAAEJ,KAAMI,EAAEH,YAChElJ,KAAK0H,OAAOU,OAAS,EACrBpI,KAAKuJ,WAAW7I,KAAK,CAAEuH,QAASjI,KAAKiI,S,CAIvC,IAAAtB,EAAKhC,EAAEA,EAAClC,EAAEA,IACRzC,KAAKwJ,aAAa9I,KAAK,CAAEiE,IAAGlC,IAAGwF,QAASjI,KAAKiI,UAC7CjI,KAAK2H,YAAYlF,E,CAGnB,iBAAAgH,GACEzJ,KAAK6H,gBAAkB,IAAI7B,EAAgB,CACzCQ,gBAAiB,CAACvD,EAAcyG,KAC9B,MAAMC,EAAY3J,KAAK4J,WAAWlJ,KAAK,CACrCuC,OACAyG,KACAzB,QAASjI,KAAKiI,UAEhB,GAAI0B,EAAU9I,iBAAkB,CAC9B,M,CAEFb,KAAK6J,eAAenJ,KAAKiJ,EAAU5I,OAAO,G,CAKxC,OAAAZ,GACN,MAAO,CACL2G,GAAI9G,KAAK8J,OACTvH,KAAMvC,KAAK+J,aAAaC,MACxB1C,KAAMtH,KAAKiK,aAAaD,M","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["TextEditor","constructor","data","saveCallback","this","editInput","element","editCell","undefined","componentDidRender","timeout","_a","focus","onKeyDown","e","isEnter","isEnterKeyValue","key","isKeyTab","isTab","target","isComposing","beforeDisconnect","getValue","blur","value","render","h","_additionalData","type","enterKeyHint","_b","val","ref","el"],"sources":["src/components/editors/text-editor.ts"],"sourcesContent":["import { type VNode, h as createElement } from '@stencil/core';\nimport { isEnterKeyValue, isTab } from '../../utils/key.utils';\nimport { timeout } from '../../utils';\nimport
|
|
1
|
+
{"version":3,"names":["TextEditor","constructor","data","saveCallback","this","editInput","element","editCell","undefined","componentDidRender","timeout","_a","focus","onKeyDown","e","isEnter","isEnterKeyValue","key","isKeyTab","isTab","target","isComposing","beforeDisconnect","getValue","blur","value","render","h","_additionalData","type","enterKeyHint","_b","val","ref","el"],"sources":["src/components/editors/text-editor.ts"],"sourcesContent":["import { type VNode, h as createElement } from '@stencil/core';\nimport { isEnterKeyValue, isTab } from '../../utils/key.utils';\nimport { timeout } from '../../utils';\nimport type { EditCell, EditorBase, ColumnDataSchemaModel } 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: any, preventFocus: boolean) => void;\n\nexport class TextEditor implements EditorBase {\n editInput: HTMLInputElement | null = null;\n\n element: Element | null = null;\n editCell?: EditCell = undefined;\n\n constructor(\n public data: ColumnDataSchemaModel,\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 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"],"mappings":";;;6GAmBaA,EAMX,WAAAC,CACSC,EACCC,GADDC,KAAAF,OACCE,KAAAD,eAPVC,KAAAC,UAAqC,KAErCD,KAAAE,QAA0B,KAC1BF,KAAAG,SAAsBC,S,CAUtB,wBAAMC,G,MACJ,GAAIL,KAAKC,UAAW,OACZK,KACNC,EAAAP,KAAKC,aAAS,MAAAM,SAAA,SAAAA,EAAEC,O,EAIpB,SAAAC,CAAUC,GACR,MAAMC,EAAUC,EAAgBF,EAAEG,KAClC,MAAMC,EAAWC,EAAML,EAAEG,KAEzB,IACGC,GAAYH,IACbD,EAAEM,QACFhB,KAAKD,eACJW,EAAEO,YACH,CAEAjB,KAAKkB,mBAELlB,KAAKD,aAAaC,KAAKmB,WAAYL,E,EAOvC,gBAAAI,G,OACEX,EAAAP,KAAKC,aAAS,MAAAM,SAAA,SAAAA,EAAEa,M,CAMlB,QAAAD,G,MACE,OAAOZ,EAAAP,KAAKC,aAAS,MAAAM,SAAA,SAAAA,EAAEc,K,CAYzB,MAAAC,CAAOC,EAAyBC,G,QAC9B,OAAOD,EAAE,QAAS,CAChBE,KAAM,OACNC,aAAc,QAEdL,OAAOM,GAAApB,EAAAP,KAAKG,YAAQ,MAAAI,SAAA,SAAAA,EAAEqB,OAAG,MAAAD,SAAA,EAAAA,EAAI,GAE7BE,IAAMC,IACJ9B,KAAKC,UAAY6B,CAAE,EAGrBrB,UAAYC,GAAqBV,KAAKS,UAAUC,I","ignoreList":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EventEmitter } from '../../stencil-public-runtime';
|
|
2
2
|
import { ColumnDataSchemaModel } from "../../types/index";
|
|
3
|
-
import { EditCell, EditorCtr, SaveDataDetails
|
|
3
|
+
import { EditCell, EditorCtr, SaveDataDetails } from "../../types/index";
|
|
4
4
|
/**
|
|
5
5
|
* Represents a cell editor in a grid.
|
|
6
6
|
* It manages the editing of cells by handling events, saving data, rendering the editor UI,
|
|
@@ -55,7 +55,7 @@ export declare class RevoEdit {
|
|
|
55
55
|
* Closes editor when called.
|
|
56
56
|
* @param preventFocus - if true, editor will not be closed & next cell will not be focused.
|
|
57
57
|
*/
|
|
58
|
-
onSave(val?:
|
|
58
|
+
onSave(val?: any, preventFocus?: boolean): void;
|
|
59
59
|
componentWillRender(): void;
|
|
60
60
|
componentDidRender(): void;
|
|
61
61
|
disconnectedCallback(): void;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { type VNode, h as createElement } from '../../stencil-public-runtime';
|
|
2
|
-
import { ColumnDataSchemaModel } from "../../types/index";
|
|
3
|
-
import { EditCell, EditorBase, SaveData } from "../../types/index";
|
|
2
|
+
import type { EditCell, EditorBase, ColumnDataSchemaModel } from "../../types/index";
|
|
4
3
|
/**
|
|
5
4
|
* Represents a cell editor in a grid.
|
|
6
5
|
*
|
|
@@ -12,7 +11,7 @@ import { EditCell, EditorBase, SaveData } from "../../types/index";
|
|
|
12
11
|
* Closes editor when called
|
|
13
12
|
* @param preventFocus - if true editor will not be closed and next cell will not be focused
|
|
14
13
|
*/
|
|
15
|
-
export type SaveCallback = (value:
|
|
14
|
+
export type SaveCallback = (value: any, preventFocus: boolean) => void;
|
|
16
15
|
export declare class TextEditor implements EditorBase {
|
|
17
16
|
data: ColumnDataSchemaModel;
|
|
18
17
|
private saveCallback?;
|
|
@@ -210,7 +210,7 @@ export declare class OverlaySelection {
|
|
|
210
210
|
/**
|
|
211
211
|
* Selection & Keyboard
|
|
212
212
|
*/
|
|
213
|
-
selectionServiceSet(
|
|
213
|
+
selectionServiceSet(selectionStore: Observable<SelectionStoreState>): void;
|
|
214
214
|
/** Autofill */
|
|
215
215
|
createAutoFillService(): void;
|
|
216
216
|
/** Columns */
|
|
@@ -431,13 +431,19 @@ export declare class RevoGridComponent {
|
|
|
431
431
|
*/
|
|
432
432
|
refresh(type?: DimensionRows | 'all'): Promise<void>;
|
|
433
433
|
/**
|
|
434
|
-
*
|
|
434
|
+
* Refreshes data at specified cell.
|
|
435
435
|
* Useful for performance optimization.
|
|
436
436
|
* No viewport update will be triggered.
|
|
437
|
+
*
|
|
438
|
+
* @example
|
|
439
|
+
* const grid = document.querySelector('revo-grid');
|
|
440
|
+
* grid.setDataAt({ row: 0, col: 0, val: 'test' }); // refresh
|
|
437
441
|
*/
|
|
438
|
-
setDataAt(
|
|
442
|
+
setDataAt({ row, col, colType, rowType, val, skipDataUpdate }: {
|
|
439
443
|
row: number;
|
|
440
444
|
col: number;
|
|
445
|
+
val?: any;
|
|
446
|
+
skipDataUpdate?: boolean;
|
|
441
447
|
} & AllDimensionType): Promise<void | undefined>;
|
|
442
448
|
/**
|
|
443
449
|
* Scrolls viewport to specified row by index.
|
|
@@ -256,9 +256,10 @@ export namespace Components {
|
|
|
256
256
|
*/
|
|
257
257
|
"setCellsFocus": (cellStart?: Cell, cellEnd?: Cell, colType?: string, rowType?: string) => Promise<void>;
|
|
258
258
|
/**
|
|
259
|
-
*
|
|
259
|
+
* Refreshes data at specified cell. Useful for performance optimization. No viewport update will be triggered.
|
|
260
|
+
* @example const grid = document.querySelector('revo-grid'); grid.setDataAt({ row: 0, col: 0, val: 'test' }); // refresh
|
|
260
261
|
*/
|
|
261
|
-
"setDataAt": (
|
|
262
|
+
"setDataAt": ({ row, col, colType, rowType, val, skipDataUpdate }: { row: number; col: number; val?: any; skipDataUpdate?: boolean; } & AllDimensionType) => Promise<void | undefined>;
|
|
262
263
|
/**
|
|
263
264
|
* Source - defines main data source. Can be an Object or 2 dimensional array([][]); Keys/indexes referenced from columns Prop.
|
|
264
265
|
*/
|
|
@@ -2023,11 +2024,11 @@ declare namespace LocalJSX {
|
|
|
2023
2024
|
/**
|
|
2024
2025
|
* Column data store.
|
|
2025
2026
|
*/
|
|
2026
|
-
"colData"
|
|
2027
|
+
"colData": Observable<DSourceState<ColumnRegular, DimensionCols>>;
|
|
2027
2028
|
/**
|
|
2028
2029
|
* Row data store.
|
|
2029
2030
|
*/
|
|
2030
|
-
"dataStore"
|
|
2031
|
+
"dataStore": Observable<DSourceState<DataType, DimensionRows>>;
|
|
2031
2032
|
/**
|
|
2032
2033
|
* Dimension settings X.
|
|
2033
2034
|
*/
|
|
@@ -2159,7 +2160,7 @@ declare namespace LocalJSX {
|
|
|
2159
2160
|
/**
|
|
2160
2161
|
* Selection, range, focus.
|
|
2161
2162
|
*/
|
|
2162
|
-
"selectionStore"
|
|
2163
|
+
"selectionStore": Observable<SelectionStoreState>;
|
|
2163
2164
|
/**
|
|
2164
2165
|
* Enable revogr-clipboard component (read more in revogr-clipboard component). Allows copy/paste.
|
|
2165
2166
|
*/
|
|
@@ -23,7 +23,7 @@ export declare class DataProvider {
|
|
|
23
23
|
from: number;
|
|
24
24
|
to: number;
|
|
25
25
|
}): void;
|
|
26
|
-
setCellData({ type, rowIndex, prop, val }: BeforeSaveDataDetails, mutate?: boolean): void;
|
|
26
|
+
setCellData({ type, rowIndex, prop, val }: Pick<BeforeSaveDataDetails, 'type' | 'rowIndex' | 'prop' | 'val'>, mutate?: boolean): void;
|
|
27
27
|
setRangeData(data: DataLookup, type: DimensionRows): void;
|
|
28
28
|
refresh(type?: DimensionRows | 'all'): void;
|
|
29
29
|
refreshItems(type?: DimensionRows): void;
|
|
@@ -81,7 +81,6 @@ export type RangeAreaCss = {
|
|
|
81
81
|
width: string;
|
|
82
82
|
height: string;
|
|
83
83
|
};
|
|
84
|
-
export type SaveData = string;
|
|
85
84
|
export type SaveDataDetails = {
|
|
86
85
|
rgRow: RowIndex;
|
|
87
86
|
rgCol: ColIndex;
|
|
@@ -95,7 +94,7 @@ export interface BeforeSaveDataDetails extends ColumnDataSchemaModel {
|
|
|
95
94
|
/**
|
|
96
95
|
* Value from editor to save, not part of the model value yet
|
|
97
96
|
*/
|
|
98
|
-
val?:
|
|
97
|
+
val?: any;
|
|
99
98
|
}
|
|
100
99
|
export type BeforeRangeSaveDataDetails = {
|
|
101
100
|
data: DataLookup;
|
|
@@ -107,7 +106,7 @@ export type AfterEditEvent = BeforeRangeSaveDataDetails | BeforeSaveDataDetails;
|
|
|
107
106
|
* Edit cell info for store
|
|
108
107
|
*/
|
|
109
108
|
export interface EditCellStore extends Cell {
|
|
110
|
-
val?:
|
|
109
|
+
val?: any;
|
|
111
110
|
}
|
|
112
111
|
/**
|
|
113
112
|
* Edit cell info for editor
|
|
@@ -127,13 +126,13 @@ export type EditorCtr = EditorCtrCallable | EditorCtrConstructible;
|
|
|
127
126
|
* Editor component callable function
|
|
128
127
|
*/
|
|
129
128
|
export type EditorCtrCallable = {
|
|
130
|
-
(column: ColumnDataSchemaModel, save: (value
|
|
129
|
+
(column: ColumnDataSchemaModel, save: (value?: any, preventFocus?: boolean) => void, close: (focusNext?: boolean) => void): EditorBase;
|
|
131
130
|
};
|
|
132
131
|
/**
|
|
133
132
|
* Editor component constructible class
|
|
134
133
|
*/
|
|
135
134
|
export interface EditorCtrConstructible {
|
|
136
|
-
new (column: ColumnDataSchemaModel, save: (value:
|
|
135
|
+
new (column: ColumnDataSchemaModel, save: (value: any, preventFocus?: boolean) => void, close: (focusNext?: boolean) => void): EditorBase;
|
|
137
136
|
}
|
|
138
137
|
/**
|
|
139
138
|
* Editor interface
|
|
@@ -24,8 +24,6 @@ export type ViewportColumn = {
|
|
|
24
24
|
colStore: Observable<DSourceState<ColumnRegular, DimensionCols>>;
|
|
25
25
|
} & Partial<JSX.RevogrViewportScroll> & Partial<JSX.RevogrHeader>;
|
|
26
26
|
export type ViewportData = {
|
|
27
|
-
/** Selection connection */
|
|
28
|
-
segmentSelectionStore: Observable<SelectionStoreState>;
|
|
29
27
|
/** Slot to put data */
|
|
30
28
|
slot: SlotType;
|
|
31
29
|
style?: {
|
package/hydrate/index.js
CHANGED
|
@@ -9506,13 +9506,13 @@ class OverlaySelection {
|
|
|
9506
9506
|
/**
|
|
9507
9507
|
* Selection & Keyboard
|
|
9508
9508
|
*/
|
|
9509
|
-
selectionServiceSet(
|
|
9509
|
+
selectionServiceSet(selectionStore) {
|
|
9510
9510
|
// clear subscriptions
|
|
9511
9511
|
this.unsubscribeSelectionStore.forEach(v => v());
|
|
9512
9512
|
this.unsubscribeSelectionStore.length = 0;
|
|
9513
|
-
this.unsubscribeSelectionStore.push(
|
|
9513
|
+
this.unsubscribeSelectionStore.push(selectionStore.onChange('nextFocus', v => v && this.doFocus(v, v)));
|
|
9514
9514
|
this.keyboardService = new KeyboardService({
|
|
9515
|
-
selectionStore
|
|
9515
|
+
selectionStore,
|
|
9516
9516
|
range: r => !!r && this.triggerRangeEvent(r),
|
|
9517
9517
|
focus: (f, changes, focusNextViewport) => {
|
|
9518
9518
|
if (focusNextViewport) {
|
|
@@ -9651,7 +9651,7 @@ class OverlaySelection {
|
|
|
9651
9651
|
nodes.push(hAsync("revogr-order-editor", { ref: e => (this.orderEditor = e), dataStore: this.dataStore, dimensionRow: this.dimensionRow, dimensionCol: this.dimensionCol, parent: this.element, rowType: this.types.rowType, onRowdragstartinit: e => this.rowDragStart(e) }));
|
|
9652
9652
|
}
|
|
9653
9653
|
}
|
|
9654
|
-
return (hAsync(Host, { key: '
|
|
9654
|
+
return (hAsync(Host, { key: '16eb46317cda519daf53f0b347700e8c1cdbd144', class: { mobile: this.isMobileDevice }, onDblClick: (e) => this.onElementDblClick(e), onMouseDown: (e) => this.onElementMouseDown(e), onTouchStart: (e) => this.onElementMouseDown(e, true) }, nodes, hAsync("slot", { key: '8e71ab9946f8b8251aaee867c6551e1fada92c6d', name: "data" })));
|
|
9655
9655
|
}
|
|
9656
9656
|
/**
|
|
9657
9657
|
* Executes the focus operation on the specified range of cells.
|
|
@@ -12713,7 +12713,7 @@ class ViewportService {
|
|
|
12713
12713
|
segmentSelection.setLastCell(rgRow.lastCell);
|
|
12714
12714
|
// register selection store for Row
|
|
12715
12715
|
const rowSelectionStore = this.registerRow(rgRow.position.y, rgRow.type);
|
|
12716
|
-
const rowDef = Object.assign(Object.assign({ colType: val }, rgRow), { rowSelectionStore,
|
|
12716
|
+
const rowDef = Object.assign(Object.assign({ colType: val }, rgRow), { rowSelectionStore, selectionStore: segmentSelection.store, ref: (e) => config.selectionStoreConnector.registerSection(e), onSetrange: e => {
|
|
12717
12717
|
segmentSelection.setRangeArea(e.detail);
|
|
12718
12718
|
}, onSettemprange: e => segmentSelection.setTempArea(e.detail), onFocuscell: e => {
|
|
12719
12719
|
// todo: multi focus
|
|
@@ -13916,15 +13916,27 @@ class RevoGridComponent {
|
|
|
13916
13916
|
this.dataProvider.refresh(type);
|
|
13917
13917
|
}
|
|
13918
13918
|
/**
|
|
13919
|
-
*
|
|
13919
|
+
* Refreshes data at specified cell.
|
|
13920
13920
|
* Useful for performance optimization.
|
|
13921
13921
|
* No viewport update will be triggered.
|
|
13922
|
+
*
|
|
13923
|
+
* @example
|
|
13924
|
+
* const grid = document.querySelector('revo-grid');
|
|
13925
|
+
* grid.setDataAt({ row: 0, col: 0, val: 'test' }); // refresh
|
|
13922
13926
|
*/
|
|
13923
|
-
async setDataAt(
|
|
13924
|
-
|
|
13927
|
+
async setDataAt({ row, col, colType = 'rgCol', rowType = 'rgRow', val, skipDataUpdate = false }) {
|
|
13928
|
+
if (this.dataProvider && !skipDataUpdate) {
|
|
13929
|
+
this.dataProvider.setCellData({
|
|
13930
|
+
type: rowType,
|
|
13931
|
+
rowIndex: row,
|
|
13932
|
+
prop: col,
|
|
13933
|
+
val,
|
|
13934
|
+
}, false);
|
|
13935
|
+
}
|
|
13936
|
+
const dataElement = this.element.querySelector(`revogr-data[type="${rowType}"][col-type="${colType}"]`);
|
|
13925
13937
|
return dataElement === null || dataElement === void 0 ? void 0 : dataElement.updateCell({
|
|
13926
|
-
row
|
|
13927
|
-
col
|
|
13938
|
+
row,
|
|
13939
|
+
col,
|
|
13928
13940
|
});
|
|
13929
13941
|
}
|
|
13930
13942
|
/**
|
|
@@ -14627,13 +14639,13 @@ class RevoGridComponent {
|
|
|
14627
14639
|
// Render viewport data (vertical sections)
|
|
14628
14640
|
view.dataPorts.forEach(data => {
|
|
14629
14641
|
const key = `${data.type}_${view.type}`;
|
|
14630
|
-
const dataView = (hAsync("revogr-overlay-selection", Object.assign({}, data, { isMobileDevice: isMobile,
|
|
14642
|
+
const dataView = (hAsync("revogr-overlay-selection", Object.assign({}, data, { isMobileDevice: isMobile, onSelectall: () => { var _a; return (_a = this.selectionStoreConnector) === null || _a === void 0 ? void 0 : _a.selectAll(); }, editors: this.editors, readonly: this.readonly, range: this.range, useClipboard: this.useClipboard, applyChangesOnClose: this.applyOnClose, additionalData: this.additionalData, slot: data.slot, onBeforenextvpfocus: (e) => { var _a; return (_a = this.selectionStoreConnector) === null || _a === void 0 ? void 0 : _a.beforeNextFocusCell(e.detail); }, onCanceledit: () => { var _a; return (_a = this.selectionStoreConnector) === null || _a === void 0 ? void 0 : _a.setEdit(false); }, onSetedit: ({ detail }) => {
|
|
14631
14643
|
var _a;
|
|
14632
14644
|
const event = this.beforeeditstart.emit(detail);
|
|
14633
14645
|
if (!event.defaultPrevented) {
|
|
14634
14646
|
(_a = this.selectionStoreConnector) === null || _a === void 0 ? void 0 : _a.setEdit(detail.val);
|
|
14635
14647
|
}
|
|
14636
|
-
} }), hAsync("revogr-data", Object.assign({}, data, { colType: view.type, key: key, readonly: this.readonly, range: this.range, rowClass: this.rowClass, rowSelectionStore: data.rowSelectionStore, additionalData: this.additionalData, jobsBeforeRender: this.jobsBeforeRender, slot: DATA_SLOT }), hAsync("slot", { name: `data-${view.type}-${data.type}` })), hAsync("revogr-temp-range", { selectionStore: data.
|
|
14648
|
+
} }), hAsync("revogr-data", Object.assign({}, data, { colType: view.type, key: key, readonly: this.readonly, range: this.range, rowClass: this.rowClass, rowSelectionStore: data.rowSelectionStore, additionalData: this.additionalData, jobsBeforeRender: this.jobsBeforeRender, slot: DATA_SLOT }), hAsync("slot", { name: `data-${view.type}-${data.type}` })), hAsync("revogr-temp-range", { selectionStore: data.selectionStore, dimensionRow: data.dimensionRow, dimensionCol: data.dimensionCol }), hAsync("revogr-focus", { colData: data.colData, dataStore: data.dataStore, focusTemplate: this.focusTemplate, rowType: data.type, colType: view.type, selectionStore: data.selectionStore, dimensionRow: data.dimensionRow, dimensionCol: data.dimensionCol }, hAsync("slot", { name: `focus-${view.type}-${data.type}` }))));
|
|
14637
14649
|
dataViews.push(dataView);
|
|
14638
14650
|
});
|
|
14639
14651
|
// Add viewport scroll in the end
|
package/hydrate/index.mjs
CHANGED
|
@@ -9502,13 +9502,13 @@ class OverlaySelection {
|
|
|
9502
9502
|
/**
|
|
9503
9503
|
* Selection & Keyboard
|
|
9504
9504
|
*/
|
|
9505
|
-
selectionServiceSet(
|
|
9505
|
+
selectionServiceSet(selectionStore) {
|
|
9506
9506
|
// clear subscriptions
|
|
9507
9507
|
this.unsubscribeSelectionStore.forEach(v => v());
|
|
9508
9508
|
this.unsubscribeSelectionStore.length = 0;
|
|
9509
|
-
this.unsubscribeSelectionStore.push(
|
|
9509
|
+
this.unsubscribeSelectionStore.push(selectionStore.onChange('nextFocus', v => v && this.doFocus(v, v)));
|
|
9510
9510
|
this.keyboardService = new KeyboardService({
|
|
9511
|
-
selectionStore
|
|
9511
|
+
selectionStore,
|
|
9512
9512
|
range: r => !!r && this.triggerRangeEvent(r),
|
|
9513
9513
|
focus: (f, changes, focusNextViewport) => {
|
|
9514
9514
|
if (focusNextViewport) {
|
|
@@ -9647,7 +9647,7 @@ class OverlaySelection {
|
|
|
9647
9647
|
nodes.push(hAsync("revogr-order-editor", { ref: e => (this.orderEditor = e), dataStore: this.dataStore, dimensionRow: this.dimensionRow, dimensionCol: this.dimensionCol, parent: this.element, rowType: this.types.rowType, onRowdragstartinit: e => this.rowDragStart(e) }));
|
|
9648
9648
|
}
|
|
9649
9649
|
}
|
|
9650
|
-
return (hAsync(Host, { key: '
|
|
9650
|
+
return (hAsync(Host, { key: '16eb46317cda519daf53f0b347700e8c1cdbd144', class: { mobile: this.isMobileDevice }, onDblClick: (e) => this.onElementDblClick(e), onMouseDown: (e) => this.onElementMouseDown(e), onTouchStart: (e) => this.onElementMouseDown(e, true) }, nodes, hAsync("slot", { key: '8e71ab9946f8b8251aaee867c6551e1fada92c6d', name: "data" })));
|
|
9651
9651
|
}
|
|
9652
9652
|
/**
|
|
9653
9653
|
* Executes the focus operation on the specified range of cells.
|
|
@@ -12709,7 +12709,7 @@ class ViewportService {
|
|
|
12709
12709
|
segmentSelection.setLastCell(rgRow.lastCell);
|
|
12710
12710
|
// register selection store for Row
|
|
12711
12711
|
const rowSelectionStore = this.registerRow(rgRow.position.y, rgRow.type);
|
|
12712
|
-
const rowDef = Object.assign(Object.assign({ colType: val }, rgRow), { rowSelectionStore,
|
|
12712
|
+
const rowDef = Object.assign(Object.assign({ colType: val }, rgRow), { rowSelectionStore, selectionStore: segmentSelection.store, ref: (e) => config.selectionStoreConnector.registerSection(e), onSetrange: e => {
|
|
12713
12713
|
segmentSelection.setRangeArea(e.detail);
|
|
12714
12714
|
}, onSettemprange: e => segmentSelection.setTempArea(e.detail), onFocuscell: e => {
|
|
12715
12715
|
// todo: multi focus
|
|
@@ -13912,15 +13912,27 @@ class RevoGridComponent {
|
|
|
13912
13912
|
this.dataProvider.refresh(type);
|
|
13913
13913
|
}
|
|
13914
13914
|
/**
|
|
13915
|
-
*
|
|
13915
|
+
* Refreshes data at specified cell.
|
|
13916
13916
|
* Useful for performance optimization.
|
|
13917
13917
|
* No viewport update will be triggered.
|
|
13918
|
+
*
|
|
13919
|
+
* @example
|
|
13920
|
+
* const grid = document.querySelector('revo-grid');
|
|
13921
|
+
* grid.setDataAt({ row: 0, col: 0, val: 'test' }); // refresh
|
|
13918
13922
|
*/
|
|
13919
|
-
async setDataAt(
|
|
13920
|
-
|
|
13923
|
+
async setDataAt({ row, col, colType = 'rgCol', rowType = 'rgRow', val, skipDataUpdate = false }) {
|
|
13924
|
+
if (this.dataProvider && !skipDataUpdate) {
|
|
13925
|
+
this.dataProvider.setCellData({
|
|
13926
|
+
type: rowType,
|
|
13927
|
+
rowIndex: row,
|
|
13928
|
+
prop: col,
|
|
13929
|
+
val,
|
|
13930
|
+
}, false);
|
|
13931
|
+
}
|
|
13932
|
+
const dataElement = this.element.querySelector(`revogr-data[type="${rowType}"][col-type="${colType}"]`);
|
|
13921
13933
|
return dataElement === null || dataElement === void 0 ? void 0 : dataElement.updateCell({
|
|
13922
|
-
row
|
|
13923
|
-
col
|
|
13934
|
+
row,
|
|
13935
|
+
col,
|
|
13924
13936
|
});
|
|
13925
13937
|
}
|
|
13926
13938
|
/**
|
|
@@ -14623,13 +14635,13 @@ class RevoGridComponent {
|
|
|
14623
14635
|
// Render viewport data (vertical sections)
|
|
14624
14636
|
view.dataPorts.forEach(data => {
|
|
14625
14637
|
const key = `${data.type}_${view.type}`;
|
|
14626
|
-
const dataView = (hAsync("revogr-overlay-selection", Object.assign({}, data, { isMobileDevice: isMobile,
|
|
14638
|
+
const dataView = (hAsync("revogr-overlay-selection", Object.assign({}, data, { isMobileDevice: isMobile, onSelectall: () => { var _a; return (_a = this.selectionStoreConnector) === null || _a === void 0 ? void 0 : _a.selectAll(); }, editors: this.editors, readonly: this.readonly, range: this.range, useClipboard: this.useClipboard, applyChangesOnClose: this.applyOnClose, additionalData: this.additionalData, slot: data.slot, onBeforenextvpfocus: (e) => { var _a; return (_a = this.selectionStoreConnector) === null || _a === void 0 ? void 0 : _a.beforeNextFocusCell(e.detail); }, onCanceledit: () => { var _a; return (_a = this.selectionStoreConnector) === null || _a === void 0 ? void 0 : _a.setEdit(false); }, onSetedit: ({ detail }) => {
|
|
14627
14639
|
var _a;
|
|
14628
14640
|
const event = this.beforeeditstart.emit(detail);
|
|
14629
14641
|
if (!event.defaultPrevented) {
|
|
14630
14642
|
(_a = this.selectionStoreConnector) === null || _a === void 0 ? void 0 : _a.setEdit(detail.val);
|
|
14631
14643
|
}
|
|
14632
|
-
} }), hAsync("revogr-data", Object.assign({}, data, { colType: view.type, key: key, readonly: this.readonly, range: this.range, rowClass: this.rowClass, rowSelectionStore: data.rowSelectionStore, additionalData: this.additionalData, jobsBeforeRender: this.jobsBeforeRender, slot: DATA_SLOT }), hAsync("slot", { name: `data-${view.type}-${data.type}` })), hAsync("revogr-temp-range", { selectionStore: data.
|
|
14644
|
+
} }), hAsync("revogr-data", Object.assign({}, data, { colType: view.type, key: key, readonly: this.readonly, range: this.range, rowClass: this.rowClass, rowSelectionStore: data.rowSelectionStore, additionalData: this.additionalData, jobsBeforeRender: this.jobsBeforeRender, slot: DATA_SLOT }), hAsync("slot", { name: `data-${view.type}-${data.type}` })), hAsync("revogr-temp-range", { selectionStore: data.selectionStore, dimensionRow: data.dimensionRow, dimensionCol: data.dimensionCol }), hAsync("revogr-focus", { colData: data.colData, dataStore: data.dataStore, focusTemplate: this.focusTemplate, rowType: data.type, colType: view.type, selectionStore: data.selectionStore, dimensionRow: data.dimensionRow, dimensionCol: data.dimensionCol }, hAsync("slot", { name: `focus-${view.type}-${data.type}` }))));
|
|
14633
14645
|
dataViews.push(dataView);
|
|
14634
14646
|
});
|
|
14635
14647
|
// Add viewport scroll in the end
|
package/package.json
CHANGED
package/standalone/revo-grid.js
CHANGED
|
@@ -3032,7 +3032,7 @@ class ViewportService {
|
|
|
3032
3032
|
segmentSelection.setLastCell(rgRow.lastCell);
|
|
3033
3033
|
// register selection store for Row
|
|
3034
3034
|
const rowSelectionStore = this.registerRow(rgRow.position.y, rgRow.type);
|
|
3035
|
-
const rowDef = Object.assign(Object.assign({ colType: val }, rgRow), { rowSelectionStore,
|
|
3035
|
+
const rowDef = Object.assign(Object.assign({ colType: val }, rgRow), { rowSelectionStore, selectionStore: segmentSelection.store, ref: (e) => config.selectionStoreConnector.registerSection(e), onSetrange: e => {
|
|
3036
3036
|
segmentSelection.setRangeArea(e.detail);
|
|
3037
3037
|
}, onSettemprange: e => segmentSelection.setTempArea(e.detail), onFocuscell: e => {
|
|
3038
3038
|
// todo: multi focus
|
|
@@ -3594,15 +3594,27 @@ const RevoGridComponent = /*@__PURE__*/ proxyCustomElement(class RevoGridCompone
|
|
|
3594
3594
|
this.dataProvider.refresh(type);
|
|
3595
3595
|
}
|
|
3596
3596
|
/**
|
|
3597
|
-
*
|
|
3597
|
+
* Refreshes data at specified cell.
|
|
3598
3598
|
* Useful for performance optimization.
|
|
3599
3599
|
* No viewport update will be triggered.
|
|
3600
|
+
*
|
|
3601
|
+
* @example
|
|
3602
|
+
* const grid = document.querySelector('revo-grid');
|
|
3603
|
+
* grid.setDataAt({ row: 0, col: 0, val: 'test' }); // refresh
|
|
3600
3604
|
*/
|
|
3601
|
-
async setDataAt(
|
|
3602
|
-
|
|
3605
|
+
async setDataAt({ row, col, colType = 'rgCol', rowType = 'rgRow', val, skipDataUpdate = false }) {
|
|
3606
|
+
if (this.dataProvider && !skipDataUpdate) {
|
|
3607
|
+
this.dataProvider.setCellData({
|
|
3608
|
+
type: rowType,
|
|
3609
|
+
rowIndex: row,
|
|
3610
|
+
prop: col,
|
|
3611
|
+
val,
|
|
3612
|
+
}, false);
|
|
3613
|
+
}
|
|
3614
|
+
const dataElement = this.element.querySelector(`revogr-data[type="${rowType}"][col-type="${colType}"]`);
|
|
3603
3615
|
return dataElement === null || dataElement === void 0 ? void 0 : dataElement.updateCell({
|
|
3604
|
-
row
|
|
3605
|
-
col
|
|
3616
|
+
row,
|
|
3617
|
+
col,
|
|
3606
3618
|
});
|
|
3607
3619
|
}
|
|
3608
3620
|
/**
|
|
@@ -4305,13 +4317,13 @@ const RevoGridComponent = /*@__PURE__*/ proxyCustomElement(class RevoGridCompone
|
|
|
4305
4317
|
// Render viewport data (vertical sections)
|
|
4306
4318
|
view.dataPorts.forEach(data => {
|
|
4307
4319
|
const key = `${data.type}_${view.type}`;
|
|
4308
|
-
const dataView = (h("revogr-overlay-selection", Object.assign({}, data, { isMobileDevice: isMobile,
|
|
4320
|
+
const dataView = (h("revogr-overlay-selection", Object.assign({}, data, { isMobileDevice: isMobile, onSelectall: () => { var _a; return (_a = this.selectionStoreConnector) === null || _a === void 0 ? void 0 : _a.selectAll(); }, editors: this.editors, readonly: this.readonly, range: this.range, useClipboard: this.useClipboard, applyChangesOnClose: this.applyOnClose, additionalData: this.additionalData, slot: data.slot, onBeforenextvpfocus: (e) => { var _a; return (_a = this.selectionStoreConnector) === null || _a === void 0 ? void 0 : _a.beforeNextFocusCell(e.detail); }, onCanceledit: () => { var _a; return (_a = this.selectionStoreConnector) === null || _a === void 0 ? void 0 : _a.setEdit(false); }, onSetedit: ({ detail }) => {
|
|
4309
4321
|
var _a;
|
|
4310
4322
|
const event = this.beforeeditstart.emit(detail);
|
|
4311
4323
|
if (!event.defaultPrevented) {
|
|
4312
4324
|
(_a = this.selectionStoreConnector) === null || _a === void 0 ? void 0 : _a.setEdit(detail.val);
|
|
4313
4325
|
}
|
|
4314
|
-
} }), h("revogr-data", Object.assign({}, data, { colType: view.type, key: key, readonly: this.readonly, range: this.range, rowClass: this.rowClass, rowSelectionStore: data.rowSelectionStore, additionalData: this.additionalData, jobsBeforeRender: this.jobsBeforeRender, slot: DATA_SLOT }), h("slot", { name: `data-${view.type}-${data.type}` })), h("revogr-temp-range", { selectionStore: data.
|
|
4326
|
+
} }), h("revogr-data", Object.assign({}, data, { colType: view.type, key: key, readonly: this.readonly, range: this.range, rowClass: this.rowClass, rowSelectionStore: data.rowSelectionStore, additionalData: this.additionalData, jobsBeforeRender: this.jobsBeforeRender, slot: DATA_SLOT }), h("slot", { name: `data-${view.type}-${data.type}` })), h("revogr-temp-range", { selectionStore: data.selectionStore, dimensionRow: data.dimensionRow, dimensionCol: data.dimensionCol }), h("revogr-focus", { colData: data.colData, dataStore: data.dataStore, focusTemplate: this.focusTemplate, rowType: data.type, colType: view.type, selectionStore: data.selectionStore, dimensionRow: data.dimensionRow, dimensionCol: data.dimensionCol }, h("slot", { name: `focus-${view.type}-${data.type}` }))));
|
|
4315
4327
|
dataViews.push(dataView);
|
|
4316
4328
|
});
|
|
4317
4329
|
// Add viewport scroll in the end
|