@oiij/naive-ui 0.0.21 → 0.0.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,6 @@
1
- import { DataTableSortState } from 'naive-ui';
2
- import { FilterState, TableBaseColumn } from 'naive-ui/es/data-table/src/interface';
3
- import { ContextMenuSelectType, DataTablePlusClickRowType, DataTablePlusExposeActions, DataTablePlusExposeRefs, DataTablePlusProps } from './index';
4
- declare const _default: <P extends Record<string, any> = Record<string, any>, D extends Record<string, any> = Record<string, any>, R extends Record<string, any> = Record<string, any>>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
1
+ import { RObject } from '../remote-request/index';
2
+ import { DataTablePlusEmits, DataTablePlusExposeActions, DataTablePlusExposeRefs, DataTablePlusProps } from './index';
3
+ declare const _default: <P extends RObject, D extends RObject, R extends RObject>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
5
4
  props: __VLS_PrettifyLocal<any & DataTablePlusProps<P, D, R> & Partial<{}>> & import('vue').PublicProps;
6
5
  expose(exposed: import('vue').ShallowUnwrapRef<{
7
6
  refs: DataTablePlusExposeRefs<P, D, R>;
@@ -34,26 +33,7 @@ declare const _default: <P extends Record<string, any> = Record<string, any>, D
34
33
  actions: DataTablePlusExposeActions<P, D>;
35
34
  }): any;
36
35
  };
37
- emit: {
38
- (e: "before", params: P[]): void;
39
- (e: "success", data: D, params: P[]): void;
40
- (e: "error", err: Error, params: P[]): void;
41
- (e: "finally", params: P[], data?: D, err?: Error): void;
42
- (e: "clickRow", data: DataTablePlusClickRowType<R>): void;
43
- (e: "contextMenuRow", data: DataTablePlusClickRowType<R>): void;
44
- (e: "contextMenuSelect", data: ContextMenuSelectType<R>): void;
45
- (e: "load", row: R): Promise<void>;
46
- (e: "scroll", ev: Event): void;
47
- (e: "update:checkedRowKeys", keys: (string | number)[], rows: R[], meta: {
48
- row: R | undefined;
49
- action: "check" | "uncheck" | "checkAll" | "uncheckAll";
50
- }): void;
51
- (e: "update:expandedRowKeys", keys: (string | number)[]): void;
52
- (e: "update:filters", filterState: FilterState, sourceColumn: TableBaseColumn): void;
53
- (e: "update:sorter", options: DataTableSortState | DataTableSortState[] | null): void;
54
- (e: "update:page", page: number): void;
55
- (e: "update:pageSize", pageSize: number): void;
56
- };
36
+ emit: DataTablePlusEmits<P, D, R>;
57
37
  }>) => import('vue').VNode & {
58
38
  __ctx?: Awaited<typeof __VLS_setup>;
59
39
  };
@@ -1,10 +1,11 @@
1
- import { DataTableColumns, DataTableInst, DataTableProps, DropdownOption, FlexProps, FormItemProps, GridItemProps, GridProps, PaginationProps } from 'naive-ui';
1
+ import { DataTableColumns, DataTableInst, DataTableProps, DataTableSortState, DropdownOption, FlexProps, FormItemProps, GridItemProps, GridProps, PaginationProps } from 'naive-ui';
2
+ import { FilterState, TableBaseColumn } from 'naive-ui/es/data-table/src/interface';
2
3
  import { ComputedRef, CSSProperties, Ref, ShallowRef, VNode } from 'vue';
3
4
  import { useRequestResult } from 'vue-hooks-plus/es/useRequest/types';
4
5
  import { PresetInputOptions } from '../preset-input/index';
5
- import { RemoteRequestProps } from '../remote-request/index';
6
+ import { RemoteRequestEmits, RemoteRequestProps, RObject } from '../remote-request/index';
6
7
  export { default as NDataTablePlus } from './DataTablePlus.vue';
7
- export interface DataTablePlusExposeActions<P extends Record<string, any>, D extends Record<string, any>> {
8
+ export interface DataTablePlusExposeActions<P extends RObject, D extends RObject> {
8
9
  run: (params: P) => void;
9
10
  runAsync: (params: P) => Promise<D>;
10
11
  refresh: () => void;
@@ -20,14 +21,14 @@ export interface DataTablePlusPagination {
20
21
  pageSize: number;
21
22
  itemCount: number;
22
23
  }
23
- export type DataTablePlusExposeRefsBase<P extends Record<string, any>, D extends Record<string, any>, R extends Record<string, any>> = Pick<useRequestResult<D, P[], false, false>, 'loading' | 'data' | 'error' | 'params'> & {
24
+ export type DataTablePlusExposeRefsBase<P extends RObject, D extends RObject, R extends RObject> = Pick<useRequestResult<D, P[], false, false>, 'loading' | 'data' | 'error' | 'params'> & {
24
25
  pagination: Readonly<Ref<DataTablePlusPagination, DataTablePlusPagination>>;
25
26
  rawList: ComputedRef<R[]>;
26
27
  };
27
- export type DataTablePlusExposeRefs<P extends Record<string, any>, D extends Record<string, any>, R extends Record<string, any>> = DataTablePlusExposeRefsBase<P, D, R> & {
28
+ export type DataTablePlusExposeRefs<P extends RObject, D extends RObject, R extends RObject> = DataTablePlusExposeRefsBase<P, D, R> & {
28
29
  dataTableRef: Readonly<ShallowRef<DataTableInst | null>>;
29
30
  };
30
- export type DataTablePlusFilterOptions<P extends Record<string, any>, D extends Record<string, any>, R extends Record<string, any>> = (PresetInputOptions & {
31
+ export type DataTablePlusFilterOptions<P extends RObject, D extends RObject, R extends RObject> = (PresetInputOptions & {
31
32
  key?: keyof P;
32
33
  label?: string | boolean | (FormItemProps & {
33
34
  style?: CSSProperties;
@@ -37,18 +38,18 @@ export type DataTablePlusFilterOptions<P extends Record<string, any>, D extends
37
38
  gridItemProps?: GridItemProps;
38
39
  render?: (refs: DataTablePlusExposeRefs<P, D, R>, actions: DataTablePlusExposeActions<P, D>) => VNode;
39
40
  })[];
40
- export interface DataTablePlusClickRowType<R extends Record<string, any>> {
41
+ export interface DataTablePlusClickRowType<R extends RObject> {
41
42
  row: R;
42
43
  index: number;
43
44
  event: MouseEvent;
44
45
  }
45
- export interface ContextMenuSelectType<R extends Record<string, any>> {
46
+ export interface ContextMenuSelectType<R extends RObject> {
46
47
  key: string | number;
47
48
  option: DropdownOption;
48
49
  row?: R;
49
50
  }
50
51
  export type DataTablePlusFields = Partial<Record<'page' | 'pageSize' | 'filter' | 'sorter' | 'list' | 'count' | 'rowKey', string>>;
51
- export type DataTablePlusProps<P extends Record<string, any> = Record<string, any>, D extends Record<string, any> = Record<string, any>, R extends Record<string, any> = Record<string, any>> = RemoteRequestProps<P, D> & {
52
+ export type DataTablePlusProps<P extends RObject, D extends RObject, R extends RObject> = RemoteRequestProps<P, D> & {
52
53
  columns?: DataTableColumns<R>;
53
54
  filterOptions?: DataTablePlusFilterOptions<P, D, R>;
54
55
  filterGridProps?: GridProps;
@@ -61,3 +62,19 @@ export type DataTablePlusProps<P extends Record<string, any> = Record<string, an
61
62
  customStyle?: CSSProperties;
62
63
  customClass?: string;
63
64
  };
65
+ export type DataTablePlusEmits<P extends RObject, D extends RObject, R extends RObject> = RemoteRequestEmits<P, D> & {
66
+ (e: 'clickRow', data: DataTablePlusClickRowType<R>): void;
67
+ (e: 'contextMenuRow', data: DataTablePlusClickRowType<R>): void;
68
+ (e: 'contextMenuSelect', data: ContextMenuSelectType<R>): void;
69
+ (e: 'load', row: R): Promise<void>;
70
+ (e: 'scroll', ev: Event): void;
71
+ (e: 'update:checkedRowKeys', keys: (string | number)[], rows: R[], meta: {
72
+ row: R | undefined;
73
+ action: 'check' | 'uncheck' | 'checkAll' | 'uncheckAll';
74
+ }): void;
75
+ (e: 'update:expandedRowKeys', keys: (string | number)[]): void;
76
+ (e: 'update:filters', filterState: FilterState, sourceColumn: TableBaseColumn): void;
77
+ (e: 'update:sorter', options: DataTableSortState | DataTableSortState[] | null): void;
78
+ (e: 'update:page', page: number): void;
79
+ (e: 'update:pageSize', pageSize: number): void;
80
+ };
@@ -1,5 +1,6 @@
1
+ import { RObject } from '../remote-request/index';
1
2
  import { PresetFormProps } from './index';
2
- declare const _default: <V extends Record<string, any> = Record<string, any>>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
3
+ declare const _default: <V extends RObject>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
3
4
  props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
4
5
  readonly onValidated?: ((val: V) => any) | undefined;
5
6
  } & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, "onValidated"> & PresetFormProps<V> & Partial<{}>> & import('vue').PublicProps;
@@ -3,7 +3,9 @@ import { CSSProperties } from 'vue';
3
3
  import { SearchInputProps } from '../search-input/index';
4
4
  export { default as NPresetInput } from './PresetInput.vue';
5
5
  export interface PresetInputType {
6
- 'button': ButtonProps;
6
+ 'button': ButtonProps & {
7
+ label?: string;
8
+ };
7
9
  'color-picker': ColorPickerProps;
8
10
  'checkbox': CheckboxGroupProps & {
9
11
  options?: CheckboxProps[];
@@ -1,6 +1,6 @@
1
- import { SelectOption } from 'naive-ui';
2
- import { PresetSelectExposeActions, PresetSelectExposeRefs, PresetSelectProps, PresetSelectValue } from './index';
3
- declare const _default: <V extends PresetSelectValue = null, P extends Record<string, any> = Record<string, any>, D extends Record<string, any> = Record<string, any>, R extends Record<string, any> = Record<string, any>>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
1
+ import { RObject } from '../remote-request/index';
2
+ import { PresetSelectEmits, PresetSelectExposeActions, PresetSelectExposeRefs, PresetSelectProps, PresetSelectValue } from './index';
3
+ declare const _default: <V extends PresetSelectValue, P extends RObject, D extends RObject, R extends RObject>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
4
4
  props: __VLS_PrettifyLocal<any & PresetSelectProps<V, P, D, R> & Partial<{}>> & import('vue').PublicProps;
5
5
  expose(exposed: import('vue').ShallowUnwrapRef<{
6
6
  refs: PresetSelectExposeRefs<P, D, R>;
@@ -27,21 +27,7 @@ declare const _default: <V extends PresetSelectValue = null, P extends Record<st
27
27
  empty?(_: {}): any;
28
28
  arrow?(_: {}): any;
29
29
  };
30
- emit: {
31
- (e: "before", params: P[]): void;
32
- (e: "success", data: D, params: P[]): void;
33
- (e: "error", err: Error, params: P[]): void;
34
- (e: "finally", params: P[], data?: D, err?: Error): void;
35
- (e: "blur", ev: FocusEvent): void;
36
- (e: "clear"): void;
37
- (e: "create", label: string): SelectOption;
38
- (e: "focus", ev: FocusEvent): void;
39
- (e: "scroll", ev: Event): void;
40
- (e: "search", value: string): void;
41
- (e: "update:value", val: V | null, option: SelectOption | SelectOption[] | null, raw: R | R[] | null): void;
42
- (e: "update:page", page: number): void;
43
- (e: "update:pageSize", pageSize: number): void;
44
- };
30
+ emit: PresetSelectEmits<V, P, D, R>;
45
31
  }>) => import('vue').VNode & {
46
32
  __ctx?: Awaited<typeof __VLS_setup>;
47
33
  };
@@ -1,22 +1,22 @@
1
1
  import { PaginationProps, SelectGroupOption, SelectInst, SelectOption, SelectProps } from 'naive-ui';
2
2
  import { ShallowRef } from 'vue';
3
3
  import { DataTablePlusExposeActions, DataTablePlusExposeRefsBase } from '../data-table-plus';
4
- import { RemoteRequestProps } from '../remote-request';
4
+ import { RemoteRequestEmits, RemoteRequestProps, RObject } from '../remote-request';
5
5
  export { default as NPresetSelect } from './PresetSelect.vue';
6
- export type OptionFormat<R extends Record<string, any>> = (row: R) => SelectOption | SelectGroupOption | false | undefined | null;
7
- export type PresetSelectValue = string | number | (string | number)[] | null;
8
- export type PresetSelectUpdateValue<V extends PresetSelectValue, R extends Record<string, any>> = (val: V, option: SelectOption | SelectOption[] | null, raw: R | R[] | null) => void;
6
+ export type ArrayAwareType<V, T> = V extends null ? null : (V extends any[] ? T[] : T) | null;
7
+ export type OptionFormat<R extends RObject> = (row: R) => SelectOption | SelectGroupOption | false | undefined | null;
8
+ export type PresetSelectValue = string | number | (string | number)[];
9
9
  export type PresetSelectFields = Partial<Record<'page' | 'pageSize' | 'search' | 'list' | 'count' | 'rowKey' | 'label' | 'value' | 'children', string>>;
10
10
  export interface PresetSelectPagination {
11
11
  page: number;
12
12
  pageSize: number;
13
13
  itemCount: number;
14
14
  }
15
- export type PresetSelectExposeRefs<P extends Record<string, any>, D extends Record<string, any>, R extends Record<string, any>> = DataTablePlusExposeRefsBase<P, D, R> & {
15
+ export type PresetSelectExposeRefs<P extends RObject, D extends RObject, R extends RObject> = DataTablePlusExposeRefsBase<P, D, R> & {
16
16
  selectRef: Readonly<ShallowRef<SelectInst | null>>;
17
17
  };
18
- export type PresetSelectExposeActions<P extends Record<string, any>, D extends Record<string, any>> = DataTablePlusExposeActions<P, D>;
19
- export type PresetSelectProps<V extends PresetSelectValue = null, P extends Record<string, any> = Record<string, any>, D extends Record<string, any> = Record<string, any>, R extends Record<string, any> = Record<string, any>> = RemoteRequestProps<P, D> & {
18
+ export type PresetSelectExposeActions<P extends RObject, D extends RObject> = DataTablePlusExposeActions<P, D>;
19
+ export type PresetSelectProps<V extends PresetSelectValue, P extends RObject, D extends RObject, R extends RObject> = RemoteRequestProps<P, D> & {
20
20
  value?: V;
21
21
  fallbackLabel?: string;
22
22
  multiple?: boolean;
@@ -27,3 +27,14 @@ export type PresetSelectProps<V extends PresetSelectValue = null, P extends Reco
27
27
  selectProps?: SelectProps;
28
28
  pagination?: Omit<PaginationProps, 'page' | 'pageSize'> | boolean;
29
29
  };
30
+ export type PresetSelectEmits<V extends PresetSelectValue, P extends RObject, D extends RObject, R extends RObject> = RemoteRequestEmits<P, D> & {
31
+ (e: 'blur', ev: FocusEvent): void;
32
+ (e: 'clear'): void;
33
+ (e: 'create', label: string): SelectOption;
34
+ (e: 'focus', ev: FocusEvent): void;
35
+ (e: 'scroll', ev: Event): void;
36
+ (e: 'search', value: string): void;
37
+ (e: 'update:value', val: V | null, option: ArrayAwareType<V, SelectOption>, raw: ArrayAwareType<V, R>): void;
38
+ (e: 'update:page', page: number): void;
39
+ (e: 'update:pageSize', pageSize: number): void;
40
+ };
@@ -1,5 +1,5 @@
1
- import { RemoteRequestProps } from './index';
2
- declare const _default: <P extends Record<string, any> = Record<string, any>, D extends Record<string, any> = Record<string, any>>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
1
+ import { RemoteRequestEmits, RemoteRequestProps, RObject } from './index';
2
+ declare const _default: <P extends RObject, D extends RObject>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
3
3
  props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
4
4
  readonly onError?: ((err: Error, params: P[]) => any) | undefined;
5
5
  readonly onSuccess?: ((data: D, params: P[]) => any) | undefined;
@@ -47,12 +47,7 @@ declare const _default: <P extends Record<string, any> = Record<string, any>, D
47
47
  };
48
48
  }): any;
49
49
  };
50
- emit: {
51
- (e: "before", params: P[]): void;
52
- (e: "success", data: D, params: P[]): void;
53
- (e: "error", err: Error, params: P[]): void;
54
- (e: "finally", params: P[], data?: D, err?: Error): void;
55
- };
50
+ emit: RemoteRequestEmits<P, D>;
56
51
  }>) => import('vue').VNode & {
57
52
  __ctx?: Awaited<typeof __VLS_setup>;
58
53
  };
@@ -1,7 +1,8 @@
1
1
  import { UseRequestOptions, UseRequestPlugin } from 'vue-hooks-plus/es/useRequest/types';
2
2
  export { default as NRemoteRequest } from './RemoteRequest.vue';
3
+ export type RObject = Record<string, any>;
3
4
  export type RemoteRequestFields = Partial<Record<string, string>>;
4
- export interface RemoteRequestProps<P extends Record<string, any> = Record<string, any>, D extends Record<string, any> = Record<string, any>> {
5
+ export interface RemoteRequestProps<P extends RObject, D extends RObject> {
5
6
  api: (...args: P[]) => Promise<D>;
6
7
  defaultParams?: P;
7
8
  manual?: boolean;
@@ -9,3 +10,9 @@ export interface RemoteRequestProps<P extends Record<string, any> = Record<strin
9
10
  requestOptions?: UseRequestOptions<D, P[]>;
10
11
  requestPlugins?: UseRequestPlugin<D, P[]>[];
11
12
  }
13
+ export interface RemoteRequestEmits<P extends RObject, D extends RObject> {
14
+ (e: 'before', params: P[]): void;
15
+ (e: 'success', data: D, params: P[]): void;
16
+ (e: 'error', err: Error, params: P[]): void;
17
+ (e: 'finally', params: P[], data?: D, err?: Error): void;
18
+ }