Skip to content

Commit

Permalink
feat: useVxeTable returns formApi instance
Browse files Browse the repository at this point in the history
  • Loading branch information
anncwb committed Oct 7, 2024
1 parent 60c615c commit 4f4ad99
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 62 deletions.
3 changes: 2 additions & 1 deletion packages/@core/ui-kit/form-ui/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
export { setupVbenForm } from './config';

export type {
BaseFormComponentType,
ExtendedFormApi,
FormSchema as VbenFormSchema,
VbenFormProps,
} from './types';

export * from './use-vben-form';

// export { default as VbenForm } from './vben-form.vue';
export * as z from 'zod';
12 changes: 8 additions & 4 deletions packages/effects/plugins/src/vxe-table/api.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { ExtendedFormApi } from '@vben-core/form-ui';
import type { VxeGridInstance } from 'vxe-table';

import type { VxeGridProps } from './types';
Expand All @@ -23,14 +24,16 @@ function getDefaultState(): VxeGridProps {
}

export class VxeGridApi {
private isMounted = false;

private stateHandler: StateHandler;
public formApi = {} as ExtendedFormApi;

// private prevState: null | VxeGridProps = null;
public grid = {} as VxeGridInstance;

isMounted = false;
public state: null | VxeGridProps = null;

stateHandler: StateHandler;

public store: Store<VxeGridProps>;

constructor(options: VxeGridProps = {}) {
Expand All @@ -52,9 +55,10 @@ export class VxeGridApi {
bindMethods(this);
}

mount(instance: null | VxeGridInstance) {
mount(instance: null | VxeGridInstance, formApi: ExtendedFormApi) {
if (!this.isMounted && instance) {
this.grid = instance;
this.formApi = formApi;
this.stateHandler.setConditionTrue();
this.isMounted = true;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/effects/plugins/src/vxe-table/use-vxe-grid.vue
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ async function init() {
}
onMounted(() => {
props.api?.mount?.(gridRef.value);
props.api?.mount?.(gridRef.value, formApi);
init();
});
</script>
Expand Down
102 changes: 51 additions & 51 deletions pnpm-lock.yaml

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

10 changes: 5 additions & 5 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ catalog:
'@iconify/json': ^2.2.256
'@iconify/tailwind': ^1.1.3
'@iconify/vue': ^4.1.2
'@intlify/core-base': ^10.0.3
'@intlify/core-base': ^10.0.4
'@intlify/unplugin-vue-i18n': ^5.2.0
'@jspm/generator': ^2.3.1
'@manypkg/get-packages': ^2.2.2
Expand Down Expand Up @@ -74,8 +74,8 @@ catalog:
cross-env: ^7.0.3
cspell: ^8.14.4
cssnano: ^7.0.6
cz-git: ^1.10.0
czg: ^1.10.0
cz-git: ^1.10.1
czg: ^1.10.1
dayjs: ^1.11.13
defu: ^6.1.4
depcheck: ^1.4.7
Expand Down Expand Up @@ -170,10 +170,10 @@ catalog:
vitest: ^2.1.2
vue: ^3.5.11
vue-eslint-parser: ^9.4.3
vue-i18n: ^10.0.3
vue-i18n: ^10.0.4
vue-router: ^4.4.5
vue-tsc: ^2.1.6
vxe-pc-ui: ^4.2.14
vxe-pc-ui: ^4.2.15
vxe-table: ^4.7.84
watermark-js-plus: ^1.5.7
zod: ^3.23.8
Expand Down

0 comments on commit 4f4ad99

Please sign in to comment.