diff --git a/packages/svelte b/packages/svelte index f80ef2bf..f1d9611d 160000 --- a/packages/svelte +++ b/packages/svelte @@ -1 +1 @@ -Subproject commit f80ef2bfc9bfe5390e44410f64e505cf20cf953a +Subproject commit f1d9611d8fb6bb047cf347958971e37fd9bed7e6 diff --git a/src/components.d.ts b/src/components.d.ts index a3c8fcb0..cd709f30 100644 --- a/src/components.d.ts +++ b/src/components.d.ts @@ -1079,14 +1079,14 @@ declare global { "setedit": BeforeEdit; "beforeapplyrange": FocusRenderEvent; "beforesetrange": any; - "beforeeditrender": FocusRenderEvent; "setrange": RangeArea & { type: MultiDimensionType }; + "beforeeditrender": FocusRenderEvent; "selectall": any; "canceledit": any; "settemprange": Nullable | null; "beforesettemprange": { tempRange: Nullable | null } & EventData & AllDimensionType; "applyfocus": FocusRenderEvent; - "focuscell": ApplyFocusEvent; + "focuscell": ApplyFocusEvent & FocusRenderEvent; "beforerangedataapply": FocusRenderEvent; "selectionchangeinit": ChangedRange; "beforerangecopyapply": ChangedRange; @@ -1344,11 +1344,11 @@ declare namespace LocalJSX { order: Record; }>) => void; /** - * Triggered after data applied or range changed. + * After data applied or range changed. */ "onAfteredit"?: (event: RevoGridCustomEvent) => void; /** - * Triggered after focus render finished. Can be used to access a focus element through `event.target`. This is just a duplicate of `afterfocus` from `revogr-focus.tsx`. + * After focus render finished. Can be used to access a focus element through `event.target`. This is just a duplicate of `afterfocus` from `revogr-focus.tsx`. */ "onAfterfocus"?: (event: RevoGridCustomEvent) => void; /** @@ -1382,11 +1382,11 @@ declare namespace LocalJSX { source: DataType[]; }>) => void; /** - * This event is triggered before autofill is applied. To prevent the default behavior of applying the edit data, you can call `e.preventDefault()`. + * Before autofill is applied. To prevent the default behavior of applying the edit data, you can call `e.preventDefault()`. */ "onBeforeautofill"?: (event: RevoGridCustomEvent) => void; /** - * This event is triggered before the cell focus is changed. To prevent the default behavior of changing the cell focus, you can call `e.preventDefault()`. + * Before the cell focus is changed. To prevent the default behavior of changing the cell focus, you can call `e.preventDefault()`. */ "onBeforecellfocus"?: (event: RevoGridCustomEvent) => void; /** @@ -1398,7 +1398,7 @@ declare namespace LocalJSX { */ "onBeforecolumnsset"?: (event: RevoGridCustomEvent) => void; /** - * This event is triggered before the data is edited. To prevent the default behavior of editing data and use your own implementation, call `e.preventDefault()`. To override the edit result with your own value, set the `e.val` property to your desired value. + * Before the data is edited. To prevent the default behavior of editing data and use your own implementation, call `e.preventDefault()`. To override the edit result with your own value, set the `e.val` property to your desired value. */ "onBeforeedit"?: (event: RevoGridCustomEvent) => void; /** @@ -1421,7 +1421,7 @@ declare namespace LocalJSX { itemsToFilter: Record; }>) => void; /** - * This event is triggered before the grid focus is lost. To prevent the default behavior of changing the cell focus, you can call `e.preventDefault()`. + * Before the grid focus is lost. To prevent the default behavior of changing the cell focus, you can call `e.preventDefault()`. */ "onBeforefocuslost"?: (event: RevoGridCustomEvent) => void; /** @@ -1429,11 +1429,11 @@ declare namespace LocalJSX { */ "onBeforegridrender"?: (event: RevoGridCustomEvent) => void; /** - * Triggered before range applied. Use e.preventDefault() to prevent range. + * Before autofill is applied. Runs before beforeautofill event. Use e.preventDefault() to prevent range. */ "onBeforerange"?: (event: RevoGridCustomEvent) => void; /** - * This event is triggered before applying range data, specifically when a range selection occurs. To customize the data and prevent the default edit data from being set, you can call `e.preventDefault()`. + * Before applying range data, specifically when a range selection occurs. To customize the data and prevent the default edit data from being set, you can call `e.preventDefault()`. */ "onBeforerangeedit"?: (event: RevoGridCustomEvent) => void; /** @@ -1441,7 +1441,7 @@ declare namespace LocalJSX { */ "onBeforerowdefinition"?: (event: RevoGridCustomEvent<{ vals: any; oldVals: any }>) => void; /** - * Triggered by sorting.plugin.ts Before sorting event. Initial sorting triggered, if this event stops no other event called. Use e.preventDefault() to prevent sorting. + * By sorting.plugin.ts Before sorting event. Initial sorting triggered, if this event stops no other event called. Use e.preventDefault() to prevent sorting. */ "onBeforesorting"?: (event: RevoGridCustomEvent<{ column: ColumnRegular; @@ -1449,7 +1449,7 @@ declare namespace LocalJSX { additive: boolean; }>) => void; /** - * Triggered by sorting.plugin.ts Before sorting apply. Use e.preventDefault() to prevent sorting data change. + * By sorting.plugin.ts Before sorting apply. Use e.preventDefault() to prevent sorting data change. */ "onBeforesortingapply"?: (event: RevoGridCustomEvent<{ column: ColumnRegular; @@ -1495,7 +1495,7 @@ declare namespace LocalJSX { */ "onRowheaderschanged"?: (event: RevoGridCustomEvent) => void; /** - * This event is triggered before the order of `rgRow` is applied. To prevent the default behavior of changing the order of `rgRow`, you can call `e.preventDefault()`. + * Before the order of `rgRow` is applied. To prevent the default behavior of changing the order of `rgRow`, you can call `e.preventDefault()`. */ "onRoworderchanged"?: (event: RevoGridCustomEvent<{ from: number; to: number }>) => void; /** @@ -2053,7 +2053,7 @@ declare namespace LocalJSX { */ "onBeforesettemprange"?: (event: RevogrOverlaySelectionCustomEvent<{ tempRange: Nullable | null } & EventData & AllDimensionType>) => void; /** - * Used for editors support when editor close requested. + * Cancel edit. Used for editors support when editor close requested. */ "onCanceledit"?: (event: RevogrOverlaySelectionCustomEvent) => void; /** @@ -2071,17 +2071,17 @@ declare namespace LocalJSX { /** * Cell get focused. To prevent the default behavior of applying the edit data, you can call `e.preventDefault()`. */ - "onFocuscell"?: (event: RevogrOverlaySelectionCustomEvent) => void; + "onFocuscell"?: (event: RevogrOverlaySelectionCustomEvent) => void; /** * Range data apply. Triggers datasource edit on the root level. */ "onRangeeditapply"?: (event: RevogrOverlaySelectionCustomEvent) => void; /** - * Select all. + * Select all cells from keyboard. */ "onSelectall"?: (event: RevogrOverlaySelectionCustomEvent) => void; /** - * Selection range changed. + * Autofill data in range. First step in applyRangeWithData */ "onSelectionchangeinit"?: (event: RevogrOverlaySelectionCustomEvent) => void; /** @@ -2089,7 +2089,7 @@ declare namespace LocalJSX { */ "onSetedit"?: (event: RevogrOverlaySelectionCustomEvent) => void; /** - * Set range. + * Set range. Third step in triggerRangeEvent. */ "onSetrange"?: (event: RevogrOverlaySelectionCustomEvent) => void; /** diff --git a/src/components/overlay/revogr-overlay-selection.tsx b/src/components/overlay/revogr-overlay-selection.tsx index 78718b39..8cc12374 100644 --- a/src/components/overlay/revogr-overlay-selection.tsx +++ b/src/components/overlay/revogr-overlay-selection.tsx @@ -171,32 +171,36 @@ export class OverlaySelection { @Event({ eventName: 'setedit' }) setEdit: EventEmitter; /** - * Before range applied. First step in triggerRangeEvent. + * Before range applied. + * First step in triggerRangeEvent. */ @Event({ eventName: 'beforeapplyrange' }) beforeApplyRange: EventEmitter; /** - * Before range selection applied. Second step in triggerRangeEvent. + * Before range selection applied. + * Second step in triggerRangeEvent. */ @Event({ eventName: 'beforesetrange' }) beforeSetRange: EventEmitter; - /** - * Before editor render. - */ - @Event({ eventName: 'beforeeditrender' }) - beforeEditRender: EventEmitter; - /** * Set range. + * Third step in triggerRangeEvent. */ @Event({ eventName: 'setrange' }) setRange: EventEmitter< RangeArea & { type: MultiDimensionType } >; - /** Select all. */ + /** + * Before editor render. + */ + @Event({ eventName: 'beforeeditrender' }) + beforeEditRender: EventEmitter; + + + /** Select all cells from keyboard. */ @Event({ eventName: 'selectall' }) selectAll: EventEmitter; /** - * Used for editors support when editor close requested. + * Cancel edit. Used for editors support when editor close requested. */ @Event({ eventName: 'canceledit' }) cancelEdit: EventEmitter; @@ -225,11 +229,11 @@ export class OverlaySelection { * Cell get focused. * To prevent the default behavior of applying the edit data, you can call `e.preventDefault()`. */ - @Event({ eventName: 'focuscell' }) focusCell: EventEmitter; + @Event({ eventName: 'focuscell' }) focusCell: EventEmitter; /** Range data apply. */ @Event({ eventName: 'beforerangedataapply' }) beforeRangeDataApply: EventEmitter; - /** Selection range changed. */ + /** Autofill data in range. First step in applyRangeWithData */ @Event({ eventName: 'selectionchangeinit', cancelable: true }) selectionChange: EventEmitter; /** Before range copy. */ @@ -622,6 +626,7 @@ export class OverlaySelection { * Executes the focus operation on the specified range of cells. */ private doFocus(focus: Cell, end: Cell, changes?: Partial) { + // 1. Trigger beforeFocus event const { defaultPrevented } = this.beforeFocusCell.emit( this.columnService.getSaveData(focus.y, focus.x), ); @@ -639,11 +644,15 @@ export class OverlaySelection { rowDimension: { ...this.dimensionRow.state }, colDimension: { ...this.dimensionCol.state }, }; + + // 2. Trigger apply focus event const applyEvent = this.applyFocus.emit(evData); if (applyEvent.defaultPrevented) { return false; } const { range } = applyEvent.detail; + + // 3. Trigger focus event return !this.focusCell.emit({ focus: { x: range.x, @@ -659,6 +668,7 @@ export class OverlaySelection { private triggerRangeEvent(range: RangeArea) { const type = this.types.rowType; + // 1. Apply range const applyEvent = this.beforeApplyRange.emit({ range: { ...range }, ...this.types, @@ -672,7 +682,12 @@ export class OverlaySelection { applyEvent.detail.range, this.dataStore, ); + // 2. Before set range let e = this.beforeSetRange.emit(data); + if (e.defaultPrevented) { + return false; + } + // 3. Set range e = this.setRange.emit({ ...applyEvent.detail.range, type }); if (e.defaultPrevented) { return false; diff --git a/src/components/revoGrid/revo-grid.tsx b/src/components/revoGrid/revo-grid.tsx index b21d2b6b..e2f6daba 100644 --- a/src/components/revoGrid/revo-grid.tsx +++ b/src/components/revoGrid/revo-grid.tsx @@ -308,50 +308,50 @@ export class RevoGridComponent { @Event() contentsizechanged: EventEmitter; /** - * This event is triggered before the data is edited. + * Before the data is edited. * To prevent the default behavior of editing data and use your own implementation, call `e.preventDefault()`. * To override the edit result with your own value, set the `e.val` property to your desired value. */ @Event() beforeedit: EventEmitter; /** - * This event is triggered before applying range data, specifically when a range selection occurs. + * Before applying range data, specifically when a range selection occurs. * To customize the data and prevent the default edit data from being set, you can call `e.preventDefault()`. */ @Event() beforerangeedit: EventEmitter; /** - * Triggered after data applied or range changed. + * After data applied or range changed. */ @Event() afteredit: EventEmitter; /** - * This event is triggered before autofill is applied. + * Before autofill is applied. * To prevent the default behavior of applying the edit data, you can call `e.preventDefault()`. */ @Event() beforeautofill: EventEmitter; /** - * Triggered before range applied. + * Before autofill is applied. Runs before beforeautofill event. * Use e.preventDefault() to prevent range. */ @Event() beforerange: EventEmitter; /** - * Triggered after focus render finished. + * After focus render finished. * Can be used to access a focus element through `event.target`. * This is just a duplicate of `afterfocus` from `revogr-focus.tsx`. */ @Event() afterfocus: EventEmitter; /** - * This event is triggered before the order of `rgRow` is applied. + * Before the order of `rgRow` is applied. * To prevent the default behavior of changing the order of `rgRow`, you can call `e.preventDefault()`. */ @Event() roworderchanged: EventEmitter<{ from: number; to: number }>; /** - * Triggered by sorting.plugin.ts + * By sorting.plugin.ts * Before sorting apply. * Use e.preventDefault() to prevent sorting data change. */ @@ -362,7 +362,7 @@ export class RevoGridComponent { }>; /** - * Triggered by sorting.plugin.ts + * By sorting.plugin.ts * Before sorting event. * Initial sorting triggered, if this event stops no other event called. * Use e.preventDefault() to prevent sorting. @@ -389,13 +389,13 @@ export class RevoGridComponent { @Event() headerclick: EventEmitter; /** - * This event is triggered before the cell focus is changed. + * Before the cell focus is changed. * To prevent the default behavior of changing the cell focus, you can call `e.preventDefault()`. */ @Event() beforecellfocus: EventEmitter; /** - * This event is triggered before the grid focus is lost. + * Before the grid focus is lost. * To prevent the default behavior of changing the cell focus, you can call `e.preventDefault()`. */ @Event() beforefocuslost: EventEmitter; diff --git a/src/types/events.ts b/src/types/events.ts index 022c6235..61bbfc39 100644 --- a/src/types/events.ts +++ b/src/types/events.ts @@ -77,8 +77,8 @@ export type RevogridEvents = 'contentsizechanged'| 'setedit'| 'beforeapplyrange'| 'beforesetrange'| - 'beforeeditrender'| 'setrange'| + 'beforeeditrender'| 'selectall'| 'canceledit'| 'settemprange'| @@ -181,8 +181,8 @@ export const REVOGRID_EVENTS = new Map([ ['setedit', 'setedit'], ['beforeapplyrange', 'beforeapplyrange'], ['beforesetrange', 'beforesetrange'], - ['beforeeditrender', 'beforeeditrender'], ['setrange', 'setrange'], + ['beforeeditrender', 'beforeeditrender'], ['selectall', 'selectall'], ['canceledit', 'canceledit'], ['settemprange', 'settemprange'],