Download packages/effects/plugins/src/vxe-table/use-vxe-grid.ts from binhugg3/admin: direct link, hf CLI and curl.
- Browser
- Download file 1.2 kB
-
https://huggingface.co/spaces/binhugg3/admin/resolve/main/packages/effects/plugins/src/vxe-table/use-vxe-grid.ts
- Command line
-
hf download hf://spaces/binhugg3/admin/packages/effects/plugins/src/vxe-table/use-vxe-grid.ts
-
curl -L -o use-vxe-grid.ts https://huggingface.co/spaces/binhugg3/admin/resolve/main/packages/effects/plugins/src/vxe-table/use-vxe-grid.ts
1.2 kB
| import type { ExtendedVxeGridApi, VxeGridProps } from './types'; | |
| import { defineComponent, h, onBeforeUnmount } from 'vue'; | |
| import { useStore } from '@vben-core/shared/store'; | |
| import { VxeGridApi } from './api'; | |
| import VxeGrid from './use-vxe-grid.vue'; | |
| export function useVbenVxeGrid(options: VxeGridProps) { | |
| // const IS_REACTIVE = isReactive(options); | |
| const api = new VxeGridApi(options); | |
| const extendedApi: ExtendedVxeGridApi = api as ExtendedVxeGridApi; | |
| extendedApi.useStore = (selector) => { | |
| return useStore(api.store, selector); | |
| }; | |
| const Grid = defineComponent( | |
| (props: VxeGridProps, { attrs, slots }) => { | |
| onBeforeUnmount(() => { | |
| api.unmount(); | |
| }); | |
| api.setState({ ...props, ...attrs }); | |
| return () => h(VxeGrid, { ...props, ...attrs, api: extendedApi }, slots); | |
| }, | |
| { | |
| inheritAttrs: false, | |
| name: 'VbenVxeGrid', | |
| }, | |
| ); | |
| // Add reactivity support | |
| // if (IS_REACTIVE) { | |
| // watch( | |
| // () => options, | |
| // () => { | |
| // api.setState(options); | |
| // }, | |
| // { immediate: true }, | |
| // ); | |
| // } | |
| return [Grid, extendedApi] as const; | |
| } | |
| export type UseVbenVxeGrid = typeof useVbenVxeGrid; | |