@oiij/naive-ui
Version:
Som Composable Functions And Components for Vue 3
43 lines (42 loc) • 2.55 kB
TypeScript
import { PaginationProps, SelectGroupOption, SelectInst, SelectOption, SelectProps } from 'naive-ui';
import { ShallowRef } from 'vue';
import { ClassStyle } from '../data-table-plus';
import { DataTablePlusExposeActionsBase, DataTablePlusExposeRefsBase } from '../data-table-plus/index';
import { RemoteRequestEmits, RemoteRequestProps, RObject } from '../remote-request/index';
export { default as NPresetSelect } from './PresetSelect.vue';
export type ArrayAwareType<V, T> = V extends null ? null : (V extends any[] ? T[] : T) | null;
export type OptionFormat<R extends RObject = RObject> = (row: R) => SelectOption | SelectGroupOption | false | undefined | null;
export type PresetSelectValue = string | number | (string | number)[] | null;
export type PresetSelectFields = Partial<Record<'page' | 'pageSize' | 'search' | 'list' | 'count' | 'rowKey' | 'label' | 'value' | 'children', string>>;
export type PresetSelectPagination = {
page: number;
pageSize: number;
itemCount: number;
};
export type PresetSelectExposeRefs<P extends RObject = RObject, D extends RObject = RObject, R extends RObject = RObject> = DataTablePlusExposeRefsBase<P, D, R> & {
selectRef: Readonly<ShallowRef<SelectInst | null>>;
};
export type PresetSelectExposeActions<P extends RObject = RObject, D extends RObject = RObject> = DataTablePlusExposeActionsBase<P, D> & {};
export type PresetSelectProps<V extends PresetSelectValue, P extends RObject = RObject, D extends RObject = RObject, R extends RObject = RObject> = RemoteRequestProps<P, D> & {
value?: V;
fallbackLabel?: string | ((val: string | number) => SelectOption);
multiple?: boolean;
disabled?: boolean;
clearable?: boolean;
debounce?: boolean | number;
optionFormat?: OptionFormat<R>;
fields?: PresetSelectFields;
selectProps?: SelectProps & ClassStyle;
pagination?: Omit<PaginationProps, 'page' | 'pageSize'> & ClassStyle | boolean;
};
export type PresetSelectEmits<V extends PresetSelectValue, P extends RObject = RObject, D extends RObject = RObject, R extends RObject = RObject> = RemoteRequestEmits<P, D> & {
(e: 'blur', ev: FocusEvent): void;
(e: 'clear'): void;
(e: 'create', label: string): SelectOption;
(e: 'focus', ev: FocusEvent): void;
(e: 'scroll', ev: Event): void;
(e: 'search', value: string): void;
(e: 'update:value', val: V | null, option: SelectOption | SelectOption[] | null, raw: R | R[] | null): void;
(e: 'update:page', page: number): void;
(e: 'update:pageSize', pageSize: number): void;
};