UNPKG

@ithinkdt/naive

Version:

iThinkDT Naive UI

108 lines (93 loc) 3.93 kB
/* eslint-disable unicorn/prefer-module */ import { CSSProperties, MaybeRef, Ref, VNodeChild } from 'vue' import { GetCurdFormItems, FormItems, ModuleItem, DictOption, Icon } from '@ithinkdt/core' import { PublicProps, GenericCtx, GenericReturn, GenericExposed } from '@ithinkdt/common' import { NTreeSelect, TreeProps } from 'ithinkdt-ui' import { IconifyInfo, IconifyJSON } from '@iconify/types' type ModuleData<T extends {}> = T & { icon?: string | PartialKeys<Icon, 'id' | 'type'> children?: ModuleData<T>[] } interface _ModuleTreeProps<T extends ModuleItem> { entity?: new () => T save?: ( m: ModuleData<Omit<T, 'key' | 'parent' | 'children' | 'icon'>> & { key?: string appCode: string presetActions?: string[] actionPathPrefix?: string actionApiPrefix?: string }, ) => Promise<T> delete?: (m: T) => Promise<void> data: T[] forms?: GetCurdFormItems<T, { items: FormItems<T> }> | FormItems<T> formWidth?: CSSProperties['width'] formHeight?: CSSProperties['height'] getIcon?: (icon: string) => MaybeRef<string> loading?: boolean draggable?: boolean creatable?: boolean modifiable?: boolean deletable?: boolean showSubmitBtn?: boolean submiting?: boolean treeProps?: Omit<TreeProps, 'data' | 'pattern' | 'checkedKeys' | 'onUpdateCheckedKeys' | 'checkable'> iconColls?: Record<string, IconifyInfo> iconLoader?: (key: string) => Promise<IconifyJSON> apps?: DictOption[] lcSelectable?: boolean getPages?: (appCode: string) => Promise<DictOption[]> // eslint-disable-next-line @typescript-eslint/no-explicit-any onRefresh?: () => any // eslint-disable-next-line @typescript-eslint/no-explicit-any onSubmit?: () => any } interface _ModuleTreeEmits { (e: 'refresh'): void (e: 'submit'): void } export declare const DtModuleTree: <T extends ModuleItem>( props: _ModuleTreeProps<T> & PublicProps, ctx?: Pick<GenericCtx<_ModuleTreeProps<T>, _ModuleTreeEmits>, 'attrs' | 'emit' | 'slots'>, expose?: (exposed?: GenericExposed) => void, setup?: GenericCtx<_ModuleTreeProps<T>, _ModuleTreeEmits>, ) => GenericReturn<_ModuleTreeProps<T>, _ModuleTreeEmits> export declare function useModuleRender(options?: { iconSize: number | string }): { renderIcon: (module: ModuleItem, iconSize?: number | string) => VNodeChild renderLabel: (module: ModuleItem) => VNodeChild renderSuffix: ( module: ModuleItem, access?: { creatable?: boolean; modifiable?: boolean; deletable?: boolean }, // eslint-disable-next-line @typescript-eslint/no-explicit-any action?: { add: (m: ModuleItem) => any; edit: (m: ModuleItem) => any; del: (m: ModuleItem) => any }, ) => VNodeChild filterModule: (pattern: string, module: ModuleItem) => boolean } export declare const DtModuleTreeSelect: typeof NTreeSelect export declare function useModuleSelect( modules: Ref<ModuleItem[]>, options?: { title?: MaybeRef<string> | (() => VNodeChild) // eslint-disable-next-line @typescript-eslint/no-explicit-any onRefresh?: () => any includeParents?: boolean loading?: Ref<boolean> treeProps?: _ModuleTreeProps<ModuleItem>['treeProps'] }, ): { open: ( selection: string[] | Promise<string[]> | Ref<string[]>, then: (selection: string[]) => MaybePromise<void | undefined | boolean>, ) => Promise<void> close: () => Promise<void> modulePathsMap: Map<ModuleItem['key'], ModuleItem['key'][]> renderModuleSelect: ( showSubmitBtn?: boolean, submiting?: boolean, // eslint-disable-next-line @typescript-eslint/no-explicit-any onSubmit?: (selection: string[]) => MaybePromise<any>, ) => VNodeChild setSelection: (selection: string[]) => void getSelection: () => string[] }