From f8ce3fdf1ff90bd9c30a966c77eb48f0ebf18fb4 Mon Sep 17 00:00:00 2001 From: Vben Date: Mon, 7 Oct 2024 13:32:37 +0800 Subject: [PATCH] feat: useVxeTable returns formApi instance (#4582) --- packages/@core/ui-kit/form-ui/src/index.ts | 3 +- packages/effects/plugins/src/vxe-table/api.ts | 12 ++- .../plugins/src/vxe-table/use-vxe-grid.vue | 2 +- pnpm-lock.yaml | 102 +++++++++--------- pnpm-workspace.yaml | 10 +- 5 files changed, 67 insertions(+), 62 deletions(-) diff --git a/packages/@core/ui-kit/form-ui/src/index.ts b/packages/@core/ui-kit/form-ui/src/index.ts index 100c224e..67ed4a50 100644 --- a/packages/@core/ui-kit/form-ui/src/index.ts +++ b/packages/@core/ui-kit/form-ui/src/index.ts @@ -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'; diff --git a/packages/effects/plugins/src/vxe-table/api.ts b/packages/effects/plugins/src/vxe-table/api.ts index a566d5d4..365c90b7 100644 --- a/packages/effects/plugins/src/vxe-table/api.ts +++ b/packages/effects/plugins/src/vxe-table/api.ts @@ -1,3 +1,4 @@ +import type { ExtendedFormApi } from '@vben-core/form-ui'; import type { VxeGridInstance } from 'vxe-table'; import type { VxeGridProps } from './types'; @@ -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; constructor(options: VxeGridProps = {}) { @@ -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; } diff --git a/packages/effects/plugins/src/vxe-table/use-vxe-grid.vue b/packages/effects/plugins/src/vxe-table/use-vxe-grid.vue index 806e0719..f6c92aa8 100644 --- a/packages/effects/plugins/src/vxe-table/use-vxe-grid.vue +++ b/packages/effects/plugins/src/vxe-table/use-vxe-grid.vue @@ -217,7 +217,7 @@ async function init() { } onMounted(() => { - props.api?.mount?.(gridRef.value); + props.api?.mount?.(gridRef.value, formApi); init(); }); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index aba36c31..949c5b1c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -40,8 +40,8 @@ catalogs: specifier: ^4.1.2 version: 4.1.2 '@intlify/core-base': - specifier: ^10.0.3 - version: 10.0.3 + specifier: ^10.0.4 + version: 10.0.4 '@intlify/unplugin-vue-i18n': specifier: ^5.2.0 version: 5.2.0 @@ -184,11 +184,11 @@ catalogs: specifier: ^7.0.6 version: 7.0.6 cz-git: - specifier: ^1.10.0 - version: 1.10.0 + specifier: ^1.10.1 + version: 1.10.1 czg: - specifier: ^1.10.0 - version: 1.10.0 + specifier: ^1.10.1 + version: 1.10.1 dayjs: specifier: ^1.11.13 version: 1.11.13 @@ -466,8 +466,8 @@ catalogs: specifier: ^9.4.3 version: 9.4.3 vue-i18n: - specifier: ^10.0.3 - version: 10.0.3 + specifier: ^10.0.4 + version: 10.0.4 vue-router: specifier: ^4.4.5 version: 4.4.5 @@ -475,8 +475,8 @@ catalogs: specifier: ^2.1.6 version: 2.1.6 vxe-pc-ui: - specifier: ^4.2.14 - version: 4.2.14 + specifier: ^4.2.15 + version: 4.2.15 vxe-table: specifier: ^4.7.84 version: 4.7.85 @@ -871,10 +871,10 @@ importers: version: 4.0.0(@commitlint/lint@19.5.0) cz-git: specifier: 'catalog:' - version: 1.10.0 + version: 1.10.1 czg: specifier: 'catalog:' - version: 1.10.0 + version: 1.10.1 internal/lint-configs/eslint-config: dependencies: @@ -1106,7 +1106,7 @@ importers: dependencies: '@intlify/unplugin-vue-i18n': specifier: 'catalog:' - version: 5.2.0(@vue/compiler-dom@3.5.11)(eslint@9.12.0(jiti@2.2.1))(rollup@4.24.0)(typescript@5.6.2)(vue-i18n@10.0.3(vue@3.5.11(typescript@5.6.2)))(vue@3.5.11(typescript@5.6.2)) + version: 5.2.0(@vue/compiler-dom@3.5.11)(eslint@9.12.0(jiti@2.2.1))(rollup@4.24.0)(typescript@5.6.2)(vue-i18n@10.0.4(vue@3.5.11(typescript@5.6.2)))(vue@3.5.11(typescript@5.6.2)) '@jspm/generator': specifier: 'catalog:' version: 2.3.1 @@ -1634,7 +1634,7 @@ importers: version: 3.5.11(typescript@5.6.2) vxe-pc-ui: specifier: 'catalog:' - version: 4.2.14 + version: 4.2.15 vxe-table: specifier: 'catalog:' version: 4.7.85 @@ -1665,7 +1665,7 @@ importers: dependencies: '@intlify/core-base': specifier: 'catalog:' - version: 10.0.3 + version: 10.0.4 '@vben-core/composables': specifier: workspace:* version: link:../@core/composables @@ -1674,7 +1674,7 @@ importers: version: 3.5.11(typescript@5.6.2) vue-i18n: specifier: 'catalog:' - version: 10.0.3(vue@3.5.11(typescript@5.6.2)) + version: 10.0.4(vue@3.5.11(typescript@5.6.2)) packages/preferences: dependencies: @@ -3973,24 +3973,24 @@ packages: vue-i18n: optional: true - '@intlify/core-base@10.0.3': - resolution: {integrity: sha512-ysJnTGDtuXPa6R2Ii4JIvfMVvDahUUny3aY8+P4r6/0TYHkblgzIMjV6cAn60em67AB0M7OWNAdcAVfWWeN8Qg==} + '@intlify/core-base@10.0.4': + resolution: {integrity: sha512-GG428DkrrWCMhxRMRQZjuS7zmSUzarYcaHJqG9VB8dXAxw4iQDoKVQ7ChJRB6ZtsCsX3Jse1PEUlHrJiyQrOTg==} engines: {node: '>= 16'} '@intlify/message-compiler@10.0.0': resolution: {integrity: sha512-OcaWc63NC/9p1cMdgoNKBj4d61BH8sUW1Hfs6YijTd9656ZR4rNqXAlRnBrfS5ABq0vjQjpa8VnyvH9hK49yBw==} engines: {node: '>= 16'} - '@intlify/message-compiler@10.0.3': - resolution: {integrity: sha512-KC2fG8nCzSYmXjHptEt6i/xM3k6S2szsPaHDCRgWKEYAbeHe6JFm6X4KRw3Csy112A8CxpavMi1dh3h7khwV5w==} + '@intlify/message-compiler@10.0.4': + resolution: {integrity: sha512-AFbhEo10DP095/45EauinQJ5hJ3rJUmuuqltGguvc3WsvezZN+g8qNHLGWKu60FHQVizMrQY7VJ+zVlBXlQQkQ==} engines: {node: '>= 16'} '@intlify/shared@10.0.0': resolution: {integrity: sha512-6ngLfI7DOTew2dcF9WMJx+NnMWghMBhIiHbGg+wRvngpzD5KZJZiJVuzMsUQE1a5YebEmtpTEfUrDp/NqVGdiw==} engines: {node: '>= 16'} - '@intlify/shared@10.0.3': - resolution: {integrity: sha512-PWxrCb6fDlnoGLnXLlWu6d7o/HdWACB9TjRnpLro+9uyfqgWA9hvqg5vekcPRyraTieV5srCbTk/ldYw9V3LHw==} + '@intlify/shared@10.0.4': + resolution: {integrity: sha512-ukFn0I01HsSgr3VYhYcvkTCLS7rGa0gw4A4AMpcy/A9xx/zRJy7PS2BElMXLwUazVFMAr5zuiTk3MQeoeGXaJg==} engines: {node: '>= 16'} '@intlify/unplugin-vue-i18n@5.2.0': @@ -5823,12 +5823,12 @@ packages: csstype@3.1.3: resolution: {integrity: sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==} - cz-git@1.10.0: - resolution: {integrity: sha512-WJidM6BwqJXPi2KUBzkUgZwZYh9U5VP5tJSIZ5G4+CDDv0lzLo8vrOrsWItE12f3xpAvlZTeQipreSczuaxFRA==} + cz-git@1.10.1: + resolution: {integrity: sha512-pBudDYUEqSOgt5cAlAk6BDs/h99lxfiii+1KCxfuVNOgcpn+yz7AejDjdBEJ+XDt7MOeAvcpYW3gi7C7il+IFA==} engines: {node: '>=v12.20.0'} - czg@1.10.0: - resolution: {integrity: sha512-RJqFwHtEoDe6eivsLXI1hrUTNRd7Fy16+wivm+q9C9VT6/uC+g77piaz27rcMVeqa5zmtTlWuSGr3svzqWe2WA==} + czg@1.10.1: + resolution: {integrity: sha512-melR80u+GA4EWNexwiWkbAPkFkxBqtLMQU4ePmnkF4N9F//8lB9mo1i0PmxphTamhn0N6kRAmnrkFrkRteNW8g==} engines: {node: '>=v12.20.0'} hasBin: true @@ -10188,8 +10188,8 @@ packages: peerDependencies: eslint: '>=6.0.0' - vue-i18n@10.0.3: - resolution: {integrity: sha512-8ul2S4Hy9orKs7eOlkw/zqnVu98GttUdyIMRyjoMpv6hFPxnybgBLdep/UCmdan5kUHyxqMnr2cGHTBuPBYJaw==} + vue-i18n@10.0.4: + resolution: {integrity: sha512-1xkzVxqBLk2ZFOmeI+B5r1J7aD/WtNJ4j9k2mcFcQo5BnOmHBmD7z4/oZohh96AAaRZ4Q7mNQvxc9h+aT+Md3w==} engines: {node: '>= 16'} peerDependencies: vue: ^3.5.11 @@ -10224,8 +10224,8 @@ packages: peerDependencies: vue: ^3.5.11 - vxe-pc-ui@4.2.14: - resolution: {integrity: sha512-yXZo7axUmn62bksPKFwOHafGJTDH7QXsvhWVwr/xb+vM4wLA14WUijyEnAJJvY78lM5FB8cIFZqwahOhj1Pu8w==} + vxe-pc-ui@4.2.15: + resolution: {integrity: sha512-Vdmd2YpUsH0jKVREurolAet2SMViwkkgNbCI8V0CQRqAA1JWNSw3RfeXywN+IQwBaghzihZFnKSfRSAVaALX3A==} vxe-table@4.7.85: resolution: {integrity: sha512-sNQ4jKnU6vZkStTK2JDDKgIz5kKCCWtTtOVl7dpNsLJ16NYWMCDlNby5m/DJC+xa0dPvSdr7+AH4TXfD1vpRFg==} @@ -12662,7 +12662,7 @@ snapshots: dependencies: '@swc/helpers': 0.5.13 - '@intlify/bundle-utils@9.0.0-beta.0(vue-i18n@10.0.3(vue@3.5.11(typescript@5.6.2)))': + '@intlify/bundle-utils@9.0.0-beta.0(vue-i18n@10.0.4(vue@3.5.11(typescript@5.6.2)))': dependencies: '@intlify/message-compiler': 10.0.0 '@intlify/shared': 10.0.0 @@ -12674,33 +12674,33 @@ snapshots: source-map-js: 1.2.1 yaml-eslint-parser: 1.2.3 optionalDependencies: - vue-i18n: 10.0.3(vue@3.5.11(typescript@5.6.2)) + vue-i18n: 10.0.4(vue@3.5.11(typescript@5.6.2)) - '@intlify/core-base@10.0.3': + '@intlify/core-base@10.0.4': dependencies: - '@intlify/message-compiler': 10.0.3 - '@intlify/shared': 10.0.3 + '@intlify/message-compiler': 10.0.4 + '@intlify/shared': 10.0.4 '@intlify/message-compiler@10.0.0': dependencies: '@intlify/shared': 10.0.0 source-map-js: 1.2.1 - '@intlify/message-compiler@10.0.3': + '@intlify/message-compiler@10.0.4': dependencies: - '@intlify/shared': 10.0.3 + '@intlify/shared': 10.0.4 source-map-js: 1.2.1 '@intlify/shared@10.0.0': {} - '@intlify/shared@10.0.3': {} + '@intlify/shared@10.0.4': {} - '@intlify/unplugin-vue-i18n@5.2.0(@vue/compiler-dom@3.5.11)(eslint@9.12.0(jiti@2.2.1))(rollup@4.24.0)(typescript@5.6.2)(vue-i18n@10.0.3(vue@3.5.11(typescript@5.6.2)))(vue@3.5.11(typescript@5.6.2))': + '@intlify/unplugin-vue-i18n@5.2.0(@vue/compiler-dom@3.5.11)(eslint@9.12.0(jiti@2.2.1))(rollup@4.24.0)(typescript@5.6.2)(vue-i18n@10.0.4(vue@3.5.11(typescript@5.6.2)))(vue@3.5.11(typescript@5.6.2))': dependencies: '@eslint-community/eslint-utils': 4.4.0(eslint@9.12.0(jiti@2.2.1)) - '@intlify/bundle-utils': 9.0.0-beta.0(vue-i18n@10.0.3(vue@3.5.11(typescript@5.6.2))) + '@intlify/bundle-utils': 9.0.0-beta.0(vue-i18n@10.0.4(vue@3.5.11(typescript@5.6.2))) '@intlify/shared': 10.0.0 - '@intlify/vue-i18n-extensions': 7.0.0(@intlify/shared@10.0.0)(@vue/compiler-dom@3.5.11)(vue-i18n@10.0.3(vue@3.5.11(typescript@5.6.2)))(vue@3.5.11(typescript@5.6.2)) + '@intlify/vue-i18n-extensions': 7.0.0(@intlify/shared@10.0.0)(@vue/compiler-dom@3.5.11)(vue-i18n@10.0.4(vue@3.5.11(typescript@5.6.2)))(vue@3.5.11(typescript@5.6.2)) '@rollup/pluginutils': 5.1.2(rollup@4.24.0) '@typescript-eslint/scope-manager': 7.18.0 '@typescript-eslint/typescript-estree': 7.18.0(typescript@5.6.2) @@ -12714,7 +12714,7 @@ snapshots: unplugin: 1.14.1 vue: 3.5.11(typescript@5.6.2) optionalDependencies: - vue-i18n: 10.0.3(vue@3.5.11(typescript@5.6.2)) + vue-i18n: 10.0.4(vue@3.5.11(typescript@5.6.2)) transitivePeerDependencies: - '@vue/compiler-dom' - eslint @@ -12723,14 +12723,14 @@ snapshots: - typescript - webpack-sources - '@intlify/vue-i18n-extensions@7.0.0(@intlify/shared@10.0.0)(@vue/compiler-dom@3.5.11)(vue-i18n@10.0.3(vue@3.5.11(typescript@5.6.2)))(vue@3.5.11(typescript@5.6.2))': + '@intlify/vue-i18n-extensions@7.0.0(@intlify/shared@10.0.0)(@vue/compiler-dom@3.5.11)(vue-i18n@10.0.4(vue@3.5.11(typescript@5.6.2)))(vue@3.5.11(typescript@5.6.2))': dependencies: '@babel/parser': 7.25.7 optionalDependencies: '@intlify/shared': 10.0.0 '@vue/compiler-dom': 3.5.11 vue: 3.5.11(typescript@5.6.2) - vue-i18n: 10.0.3(vue@3.5.11(typescript@5.6.2)) + vue-i18n: 10.0.4(vue@3.5.11(typescript@5.6.2)) '@ioredis/commands@1.2.0': {} @@ -15000,9 +15000,9 @@ snapshots: csstype@3.1.3: {} - cz-git@1.10.0: {} + cz-git@1.10.1: {} - czg@1.10.0: {} + czg@1.10.1: {} dargs@8.1.0: {} @@ -19821,10 +19821,10 @@ snapshots: transitivePeerDependencies: - supports-color - vue-i18n@10.0.3(vue@3.5.11(typescript@5.6.2)): + vue-i18n@10.0.4(vue@3.5.11(typescript@5.6.2)): dependencies: - '@intlify/core-base': 10.0.3 - '@intlify/shared': 10.0.3 + '@intlify/core-base': 10.0.4 + '@intlify/shared': 10.0.4 '@vue/devtools-api': 6.6.4 vue: 3.5.11(typescript@5.6.2) @@ -19866,13 +19866,13 @@ snapshots: vooks: 0.2.12(vue@3.5.11(typescript@5.6.2)) vue: 3.5.11(typescript@5.6.2) - vxe-pc-ui@4.2.14: + vxe-pc-ui@4.2.15: dependencies: '@vxe-ui/core': 4.0.12 vxe-table@4.7.85: dependencies: - vxe-pc-ui: 4.2.14 + vxe-pc-ui: 4.2.15 warning@4.0.3: dependencies: diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 96c5adfc..ca9b1cec 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -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 @@ -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 @@ -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