feat: add vxe-table component (#4563)
* chore: wip vxe-table * feat: add table demo * chore: follow ci recommendations to adjust details * chore: add custom-cell demo * feat: add custom-cell table demo * feat: add table from demo
This commit is contained in:
42
packages/effects/plugins/src/vxe-table/use-vxe-grid.ts
Normal file
42
packages/effects/plugins/src/vxe-table/use-vxe-grid.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
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();
|
||||
});
|
||||
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;
|
||||
}
|
Reference in New Issue
Block a user