Skip to content

Commit

Permalink
Merge pull request #660 from revolist/range-events
Browse files Browse the repository at this point in the history
Provided range area into range fill
  • Loading branch information
revolist authored Dec 4, 2024
2 parents 119f3e8 + 0356dc8 commit 4b01754
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion docs
Submodule docs updated 1 files
+92 −1 guide/svelte/index.md
8 changes: 5 additions & 3 deletions src/components/overlay/autofill.service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -262,14 +262,16 @@ export class AutoFillService {
/**
* Trigger range apply events and handle responses
*/
onRangeApply(newData: DataLookup, range: RangeArea | null) {
onRangeApply(newData: DataLookup, newRange: RangeArea | null, oldRange: RangeArea | null) {
this.sv.rangeDataApply({
data: newData,
models: collectModelsOfRange(newData, this.sv.dataStore),
type: this.sv.dataStore.get('type'),
oldRange,
newRange
});

this.sv.setRange(range);
this.sv.setRange(newRange);
}

/** Apply range and copy data during range application */
Expand Down Expand Up @@ -301,7 +303,7 @@ export class AutoFillService {
this.sv.setRange(newRange);
return;
}
this.onRangeApply(rangeData.newData, newRange);
this.onRangeApply(rangeData.newData, newRange, rangeToCopy);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/components/overlay/revogr-overlay-selection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,7 @@ export class OverlaySelection {
if (canPaste) {
return;
}
this.autoFillService?.onRangeApply(changed, range);
this.autoFillService?.onRangeApply(changed, range, range);
}

private async focusNext() {
Expand All @@ -863,7 +863,7 @@ export class OverlaySelection {
const range = this.selectionStore.get('range');
if (range && !isRangeSingleCell(range)) {
const data = this.columnService.getRangeStaticData(range, '');
this.autoFillService?.onRangeApply(data, range);
this.autoFillService?.onRangeApply(data, range, range);
} else if (this.canEdit()) {
const focused = this.selectionStore.get('focus');
if (!focused) {
Expand Down
5 changes: 3 additions & 2 deletions src/components/revoGrid/revo-grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -997,7 +997,7 @@ export class RevoGridComponent {
}

@Listen('rangeeditapply') onRangeEdit(
e: CustomEvent<BeforeRangeSaveDataDetails>,
e: CustomEvent<HTMLRevogrOverlaySelectionElementEventMap['rangeeditapply']>,
) {
if (!this.dataProvider) {
throw new Error('Not connected');
Expand All @@ -1011,7 +1011,8 @@ export class RevoGridComponent {
this.afteredit.emit(detail);
}

@Listen('selectionchangeinit') onRangeChanged(e: CustomEvent<ChangedRange>) {
@Listen('selectionchangeinit') onRangeChanged(
e: CustomEvent<HTMLRevogrOverlaySelectionElementEventMap['selectionchangeinit']>) {
const beforeange = this.beforerange.emit(e.detail);
if (beforeange.defaultPrevented) {
e.preventDefault();
Expand Down
2 changes: 2 additions & 0 deletions src/types/selection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ export type BeforeRangeSaveDataDetails = {
data: DataLookup;
models: Partial<DataLookup>;
type: DimensionRows;
newRange: RangeArea | null;
oldRange: RangeArea | null;
};

export type AfterEditEvent = BeforeRangeSaveDataDetails | BeforeSaveDataDetails;
Expand Down

0 comments on commit 4b01754

Please sign in to comment.