Skip to content

Commit

Permalink
fix: EditorType update for editor data
Browse files Browse the repository at this point in the history
  • Loading branch information
m2a2x committed Jul 4, 2024
1 parent 46dd698 commit 6c10c6f
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 21 deletions.
23 changes: 17 additions & 6 deletions lib/editor.adapter.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { VueConstructor } from 'vue/types/umd';
import { VueConstructor } from 'vue';
import { VGridVueTemplateConstructor } from './renderer';
import {
ColumnDataSchemaModel,
Expand All @@ -9,6 +9,15 @@ import {
VNode,
} from '@revolist/revogrid';

/**
* Data passed to editor
*/
export type EditorType = {
column: ColumnDataSchemaModel;
save: (value: SaveData, preventFocus?: boolean) => void;
close: (focusNext?: boolean) => void;
} & Partial<EditCell>;

/**
* Vue editor adapter
*/
Expand Down Expand Up @@ -42,14 +51,16 @@ export default class VueEditorAdapter implements EditorBase {
if (!el) {
return;
}
const editorData: EditorType = {
...this.editCell,
column: this.column,
save: this.save,
close: this.close,
};
const template = VGridVueTemplateConstructor(
this.VueEditorConstructor,
el,
{
...this.editCell,
save: this.save,
close: this.close,
},
editorData,
addition
);
if (!template) {
Expand Down
3 changes: 1 addition & 2 deletions lib/editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import VueEditorAdapter from './editor.adapter';
* This function creates editor constructor by wrapping it with VueEditorAdapter
* which is responsible for connecting editor with Vue lifecycle events
*/
const Editor = (vueConstructor: VueConstructor): EditorCtr => {
export const Editor = (vueConstructor: VueConstructor): EditorCtr => {
return function (
column: ColumnDataSchemaModel,
save: (value: SaveData, preventFocus?: boolean) => void,
Expand All @@ -17,4 +17,3 @@ const Editor = (vueConstructor: VueConstructor): EditorCtr => {
};
};

export default Editor;
5 changes: 3 additions & 2 deletions lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { RevoGrid } from './revogrid';
import { defineCustomElements } from '@revolist/revogrid/loader';
export { default as VGridVueTemplate, VGridVueTemplateConstructor } from './renderer';
export { default as VGridVueEditor } from './editor';
export { Template as VGridVueTemplate, VGridVueTemplateConstructor } from './renderer';
export { Editor as VGridVueEditor } from './editor';
export { type EditorType } from './editor.adapter';
export type * from '@revolist/revogrid';

export const VGrid = (async () => {
Expand Down
3 changes: 1 addition & 2 deletions lib/renderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const VGridVueTemplateConstructor = (
/**
* Vue template wrapper for virtual nodes
*/
const Template = (cntr: VueConstructor, customProps?: any) => {
export const Template = (cntr: VueConstructor, customProps?: any) => {
return (h: Function, p: any, addition?: any) => {
const props = customProps ? { ...customProps, ...p } : p;
const wrapper = (
Expand All @@ -65,4 +65,3 @@ const Template = (cntr: VueConstructor, customProps?: any) => {
};
};

export default Template;
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6c10c6f

Please sign in to comment.