@oiij/naive-ui 0.0.76 → 0.0.78
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.
- package/dist/components/config-providers/ConfigProviders.vue.d.ts +2 -2
- package/dist/components/config-providers/index.d.ts +16 -7
- package/dist/components/copy-button/CopyButton.js +2 -2
- package/dist/components/copy-button/CopyButton.vue.d.ts +4 -4
- package/dist/components/copy-button/index.d.ts +6 -3
- package/dist/components/data-table-plus/DataTablePlus.js +74 -125
- package/dist/components/data-table-plus/DataTablePlus.vue.d.ts +46 -111
- package/dist/components/data-table-plus/index.d.ts +52 -32
- package/dist/components/index.d.ts +2 -4
- package/dist/components/loading-provider/LoadingProvider.js +2 -2
- package/dist/components/loading-provider/LoadingProvider.vue.d.ts +2 -2
- package/dist/components/loading-provider/index.d.ts +19 -10
- package/dist/components/loading-provider/index.js +5 -2
- package/dist/components/preset-form/PresetForm.js +42 -21
- package/dist/components/preset-form/PresetForm.vue.d.ts +21 -21
- package/dist/components/preset-form/_utils.js +23 -8
- package/dist/components/preset-form/index.d.ts +32 -13
- package/dist/components/preset-input/PresetInput.vue.d.ts +3 -3
- package/dist/components/preset-input/index.d.ts +30 -20
- package/dist/components/preset-picker/PresetPicker.js +31 -34
- package/dist/components/preset-picker/PresetPicker.vue.d.ts +5 -10
- package/dist/components/preset-picker/index.d.ts +45 -31
- package/dist/components/preset-select/PresetSelect.js +23 -59
- package/dist/components/preset-select/PresetSelect.vue.d.ts +35 -39
- package/dist/components/preset-select/index.d.ts +56 -22
- package/dist/components/remote-request/RemoteRequest.js +7 -7
- package/dist/components/remote-request/RemoteRequest.vue.d.ts +13 -13
- package/dist/components/remote-request/index.d.ts +30 -8
- package/dist/components/search-input/SearchInput.vue.d.ts +4 -4
- package/dist/components/search-input/index.d.ts +10 -7
- package/dist/components/toggle-input/ToggleInput.vue.d.ts +4 -4
- package/dist/components/tooltip-button/TooltipButton.vue.d.ts +4 -4
- package/dist/components/tooltip-button/index.d.ts +5 -2
- package/dist/components/transition/BaseTransition.vue.d.ts +2 -2
- package/dist/components/transition/index.d.ts +4 -1
- package/dist/components.d.ts +2 -4
- package/dist/components.js +2 -3
- package/dist/composables/_helper.d.ts +7 -4
- package/dist/composables/_helper.js +47 -0
- package/dist/composables/index.d.ts +1 -1
- package/dist/composables/use-data-request.d.ts +25 -18
- package/dist/composables/use-data-request.js +22 -3
- package/dist/composables/use-loading.d.ts +6 -0
- package/dist/composables/use-loading.js +8 -2
- package/dist/composables/use-naive-form.d.ts +21 -13
- package/dist/composables/use-naive-form.js +48 -39
- package/dist/composables/use-naive-menu.d.ts +20 -5
- package/dist/composables/use-naive-menu.js +19 -61
- package/dist/composables/use-naive-theme.d.ts +27 -14
- package/dist/composables/use-naive-theme.js +22 -4
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/package.json +5 -7
- package/dist/components/_utils/prismjs.js +0 -16
- package/dist/components/icons/MageArrowUp.js +0 -29
- package/dist/components/type-writer/TypeWriter.js +0 -75
- package/dist/components/type-writer/TypeWriter.vue.d.ts +0 -22
- package/dist/components/type-writer/index.d.ts +0 -13
- package/dist/components/type-writer/type-writer.cssr.js +0 -27
|
@@ -4,22 +4,44 @@ import { ComponentExposed } from "vue-component-type-helpers";
|
|
|
4
4
|
import { UseRequestOptions, UseRequestPlugin } from "vue-hooks-plus/es/useRequest/types";
|
|
5
5
|
|
|
6
6
|
//#region src/components/remote-request/index.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* 远程请求字段配置
|
|
9
|
+
*/
|
|
7
10
|
type RemoteRequestFields = DataRequestFields & {};
|
|
11
|
+
/**
|
|
12
|
+
* 远程请求暴露的方法
|
|
13
|
+
* @template P 请求参数类型
|
|
14
|
+
* @template D 响应数据类型
|
|
15
|
+
* @template R 列表项类型
|
|
16
|
+
*/
|
|
8
17
|
type RemoteRequestExpose<P extends DataObject = DataObject, D extends DataObject = DataObject, R extends DataObject = DataObject> = UseDataRequestReturns<P, D, R>;
|
|
18
|
+
/**
|
|
19
|
+
* 远程请求属性
|
|
20
|
+
* @template P 请求参数类型
|
|
21
|
+
* @template D 响应数据类型
|
|
22
|
+
*/
|
|
9
23
|
type RemoteRequestProps<P extends DataObject = DataObject, D extends DataObject = DataObject> = {
|
|
10
|
-
api: (...args: P[]) => Promise<D>;
|
|
11
|
-
defaultParams?: Partial<P>;
|
|
12
|
-
manual?: boolean;
|
|
13
|
-
fields?: RemoteRequestFields;
|
|
14
|
-
requestOptions?: UseRequestOptions<D, P[]>;
|
|
24
|
+
/** API 函数 */api: (...args: P[]) => Promise<D>; /** 默认请求参数 */
|
|
25
|
+
defaultParams?: Partial<P>; /** 是否手动触发 */
|
|
26
|
+
manual?: boolean; /** 字段配置 */
|
|
27
|
+
fields?: RemoteRequestFields; /** 请求选项 */
|
|
28
|
+
requestOptions?: UseRequestOptions<D, P[]>; /** 请求插件 */
|
|
15
29
|
requestPlugins?: UseRequestPlugin<D, P[]>[];
|
|
16
30
|
};
|
|
31
|
+
/**
|
|
32
|
+
* 远程请求事件
|
|
33
|
+
* @template P 请求参数类型
|
|
34
|
+
* @template D 响应数据类型
|
|
35
|
+
*/
|
|
17
36
|
type RemoteRequestEmits<P extends DataObject = DataObject, D extends DataObject = DataObject> = {
|
|
18
|
-
(e: 'before', params: P[]): void;
|
|
19
|
-
(e: 'success', data: D, params: P[]): void;
|
|
20
|
-
(e: 'error', err: Error, params: P[]): void;
|
|
37
|
+
/** 请求前事件 */(e: 'before', params: P[]): void; /** 请求成功事件 */
|
|
38
|
+
(e: 'success', data: D, params: P[]): void; /** 请求错误事件 */
|
|
39
|
+
(e: 'error', err: Error, params: P[]): void; /** 请求完成事件 */
|
|
21
40
|
(e: 'finally', params: P[], data?: D, err?: Error): void;
|
|
22
41
|
};
|
|
42
|
+
/**
|
|
43
|
+
* 远程请求实例类型
|
|
44
|
+
*/
|
|
23
45
|
type RemoteRequestInst = ComponentExposed<typeof _default>;
|
|
24
46
|
//#endregion
|
|
25
47
|
export { RemoteRequestEmits, RemoteRequestExpose, RemoteRequestFields, RemoteRequestInst, RemoteRequestProps };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SearchInputProps } from "./index.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as vue36 from "vue";
|
|
3
3
|
|
|
4
4
|
//#region src/components/search-input/SearchInput.vue.d.ts
|
|
5
5
|
declare var __VLS_19: {}, __VLS_21: {}, __VLS_28: {
|
|
@@ -15,11 +15,11 @@ type __VLS_Slots = {} & {
|
|
|
15
15
|
} & {
|
|
16
16
|
'button-icon'?: (props: typeof __VLS_39) => any;
|
|
17
17
|
};
|
|
18
|
-
declare const __VLS_base:
|
|
18
|
+
declare const __VLS_base: vue36.DefineComponent<SearchInputProps, {}, {}, {}, {}, vue36.ComponentOptionsMixin, vue36.ComponentOptionsMixin, {} & {
|
|
19
19
|
"update:value": (v: string | null | undefined) => any;
|
|
20
|
-
}, string,
|
|
20
|
+
}, string, vue36.PublicProps, Readonly<SearchInputProps> & Readonly<{
|
|
21
21
|
"onUpdate:value"?: ((v: string | null | undefined) => any) | undefined;
|
|
22
|
-
}>, {}, {}, {}, {}, string,
|
|
22
|
+
}>, {}, {}, {}, {}, string, vue36.ComponentProvideOptions, false, {}, any>;
|
|
23
23
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
24
24
|
declare const _default: typeof __VLS_export;
|
|
25
25
|
type __VLS_WithSlots<T, S> = T & {
|
|
@@ -3,14 +3,17 @@ import { ClassStyle } from "../data-table-plus/index.js";
|
|
|
3
3
|
import { ButtonProps, InputProps } from "naive-ui";
|
|
4
4
|
|
|
5
5
|
//#region src/components/search-input/index.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* 搜索输入框属性
|
|
8
|
+
*/
|
|
6
9
|
type SearchInputProps = {
|
|
7
|
-
value?: string | null;
|
|
8
|
-
type?: ButtonProps['type'];
|
|
9
|
-
placeholder?: string;
|
|
10
|
-
loading?: boolean;
|
|
11
|
-
autoTrigger?: boolean | number;
|
|
12
|
-
searchButton?: 'text' | 'icon' | boolean;
|
|
13
|
-
inputProps?: InputProps & ClassStyle;
|
|
10
|
+
/** 值 */value?: string | null; /** 按钮类型 */
|
|
11
|
+
type?: ButtonProps['type']; /** 占位符 */
|
|
12
|
+
placeholder?: string; /** 是否加载中 */
|
|
13
|
+
loading?: boolean; /** 是否自动触发 */
|
|
14
|
+
autoTrigger?: boolean | number; /** 搜索按钮类型 */
|
|
15
|
+
searchButton?: 'text' | 'icon' | boolean; /** 输入框属性 */
|
|
16
|
+
inputProps?: InputProps & ClassStyle; /** 按钮属性 */
|
|
14
17
|
buttonProps?: ButtonProps & ClassStyle;
|
|
15
18
|
};
|
|
16
19
|
//#endregion
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ClassStyle } from "../data-table-plus/index.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as vue10 from "vue";
|
|
3
3
|
import { InputProps } from "naive-ui";
|
|
4
4
|
|
|
5
5
|
//#region src/components/toggle-input/ToggleInput.vue.d.ts
|
|
@@ -27,14 +27,14 @@ type __VLS_Slots = {} & {
|
|
|
27
27
|
} & {
|
|
28
28
|
default?: (props: typeof __VLS_13) => any;
|
|
29
29
|
};
|
|
30
|
-
declare const __VLS_base:
|
|
30
|
+
declare const __VLS_base: vue10.DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, vue10.ComponentOptionsMixin, vue10.ComponentOptionsMixin, {
|
|
31
31
|
"update:value": (value: string | number | undefined) => any;
|
|
32
32
|
} & {
|
|
33
33
|
trigger: () => any;
|
|
34
|
-
}, string,
|
|
34
|
+
}, string, vue10.PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
35
35
|
"onUpdate:value"?: ((value: string | number | undefined) => any) | undefined;
|
|
36
36
|
onTrigger?: (() => any) | undefined;
|
|
37
|
-
}>, {}, {}, {}, {}, string,
|
|
37
|
+
}>, {}, {}, {}, {}, string, vue10.ComponentProvideOptions, false, {}, any>;
|
|
38
38
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
39
39
|
declare const _default: typeof __VLS_export;
|
|
40
40
|
type __VLS_WithSlots<T, S> = T & {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TooltipButtonProps } from "./index.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as vue25 from "vue";
|
|
3
3
|
|
|
4
4
|
//#region src/components/tooltip-button/TooltipButton.vue.d.ts
|
|
5
5
|
declare var __VLS_17: {}, __VLS_20: {}, __VLS_22: {};
|
|
@@ -10,11 +10,11 @@ type __VLS_Slots = {} & {
|
|
|
10
10
|
} & {
|
|
11
11
|
tooltip?: (props: typeof __VLS_22) => any;
|
|
12
12
|
};
|
|
13
|
-
declare const __VLS_base:
|
|
13
|
+
declare const __VLS_base: vue25.DefineComponent<TooltipButtonProps, {}, {}, {}, {}, vue25.ComponentOptionsMixin, vue25.ComponentOptionsMixin, {} & {
|
|
14
14
|
click: (ev: MouseEvent) => any;
|
|
15
|
-
}, string,
|
|
15
|
+
}, string, vue25.PublicProps, Readonly<TooltipButtonProps> & Readonly<{
|
|
16
16
|
onClick?: ((ev: MouseEvent) => any) | undefined;
|
|
17
|
-
}>, {}, {}, {}, {}, string,
|
|
17
|
+
}>, {}, {}, {}, {}, string, vue25.ComponentProvideOptions, false, {}, any>;
|
|
18
18
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
19
19
|
declare const _default: typeof __VLS_export;
|
|
20
20
|
type __VLS_WithSlots<T, S> = T & {
|
|
@@ -3,9 +3,12 @@ import { _default } from "./TooltipButton.vue.js";
|
|
|
3
3
|
import { ButtonProps, TooltipProps } from "naive-ui";
|
|
4
4
|
|
|
5
5
|
//#region src/components/tooltip-button/index.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* 提示按钮属性
|
|
8
|
+
*/
|
|
6
9
|
type TooltipButtonProps = {
|
|
7
|
-
tooltip?: string;
|
|
8
|
-
tooltipProps?: TooltipProps & ClassStyle;
|
|
10
|
+
/** 提示文本 */tooltip?: string; /** 提示框属性 */
|
|
11
|
+
tooltipProps?: TooltipProps & ClassStyle; /** 按钮属性 */
|
|
9
12
|
buttonProps?: ButtonProps & ClassStyle;
|
|
10
13
|
};
|
|
11
14
|
//#endregion
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { TransitionProps as TransitionProps$1 } from "./index.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as vue20 from "vue";
|
|
3
3
|
|
|
4
4
|
//#region src/components/transition/BaseTransition.vue.d.ts
|
|
5
5
|
declare var __VLS_7: {};
|
|
6
6
|
type __VLS_Slots = {} & {
|
|
7
7
|
default?: (props: typeof __VLS_7) => any;
|
|
8
8
|
};
|
|
9
|
-
declare const __VLS_base:
|
|
9
|
+
declare const __VLS_base: vue20.DefineComponent<TransitionProps$1, {}, {}, {}, {}, vue20.ComponentOptionsMixin, vue20.ComponentOptionsMixin, {}, string, vue20.PublicProps, Readonly<TransitionProps$1> & Readonly<{}>, {}, {}, {}, {}, string, vue20.ComponentProvideOptions, false, {}, any>;
|
|
10
10
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
11
11
|
declare const _default: typeof __VLS_export;
|
|
12
12
|
type __VLS_WithSlots<T, S> = T & {
|
|
@@ -3,8 +3,11 @@ import { _default } from "./BaseTransition.vue.js";
|
|
|
3
3
|
import { TransitionProps } from "vue";
|
|
4
4
|
|
|
5
5
|
//#region src/components/transition/index.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* 过渡动画属性
|
|
8
|
+
*/
|
|
6
9
|
type TransitionProps$1 = {
|
|
7
|
-
name?: string;
|
|
10
|
+
/** 过渡名称 */name?: string; /** 过渡属性 */
|
|
8
11
|
transitionProps?: TransitionProps & ClassStyle;
|
|
9
12
|
};
|
|
10
13
|
//#endregion
|
package/dist/components.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { SearchInputProps } from "./components/search-input/index.js";
|
|
|
5
5
|
import { _default as _default$2 } from "./components/data-table-plus/DataTablePlus.vue.js";
|
|
6
6
|
import { ClassStyle, DataTablePlusEmits, DataTablePlusExpose, DataTablePlusFields, DataTablePlusInst, DataTablePlusProps } from "./components/data-table-plus/index.js";
|
|
7
7
|
import { _default as _default$3 } from "./components/loading-provider/LoadingProvider.vue.js";
|
|
8
|
-
import { LoadingProviderInst, LoadingProviderProps
|
|
8
|
+
import { LOADING_PROVIDER_INJECTION_KEY, LoadingProviderInst, LoadingProviderProps } from "./components/loading-provider/index.js";
|
|
9
9
|
import { UseNaiveFormRules } from "./composables/use-naive-form.js";
|
|
10
10
|
import { _default } from "./components/config-providers/ConfigProviders.vue.js";
|
|
11
11
|
import { ConfigProvidersProps } from "./components/config-providers/index.js";
|
|
@@ -24,8 +24,6 @@ import { _default as _default$11 } from "./components/tooltip-button/TooltipButt
|
|
|
24
24
|
import { TooltipButtonProps } from "./components/tooltip-button/index.js";
|
|
25
25
|
import { _default as _default$12 } from "./components/transition/BaseTransition.vue.js";
|
|
26
26
|
import { TransitionProps } from "./components/transition/index.js";
|
|
27
|
-
import { _default as _default$13 } from "./components/type-writer/TypeWriter.vue.js";
|
|
28
|
-
import { TypeWriterProps } from "./components/type-writer/index.js";
|
|
29
27
|
import "./components/index.js";
|
|
30
28
|
import { ComponentAttrs, ComponentEmit, ComponentExposed, ComponentProps, ComponentSlots } from "vue-component-type-helpers";
|
|
31
|
-
export { ArrayAwareType, ClassStyle, ComponentAttrs, ComponentEmit, ComponentExposed, ComponentProps, ComponentSlots, ConfigProvidersProps, CopyButtonProps, DataTablePlusEmits, DataTablePlusExpose, DataTablePlusFields, DataTablePlusInst, DataTablePlusProps, LoadingProviderInst, LoadingProviderProps, _default as NConfigProviders, _default$1 as NCopyButton, _default$2 as NDataTablePlus, _default$3 as NLoadingProvider, _default$4 as NPresetForm, _default$5 as NPresetInput, _default$6 as NPresetPicker, _default$7 as NPresetSelect, _default$8 as NRemoteRequest, _default$9 as NSearchInput, _default$10 as NToggleInput, _default$11 as NTooltipButton, _default$12 as NTransition,
|
|
29
|
+
export { ArrayAwareType, ClassStyle, ComponentAttrs, ComponentEmit, ComponentExposed, ComponentProps, ComponentSlots, ConfigProvidersProps, CopyButtonProps, DataTablePlusEmits, DataTablePlusExpose, DataTablePlusFields, DataTablePlusInst, DataTablePlusProps, LOADING_PROVIDER_INJECTION_KEY, LoadingProviderInst, LoadingProviderProps, _default as NConfigProviders, _default$1 as NCopyButton, _default$2 as NDataTablePlus, _default$3 as NLoadingProvider, _default$4 as NPresetForm, _default$5 as NPresetInput, _default$6 as NPresetPicker, _default$7 as NPresetSelect, _default$8 as NRemoteRequest, _default$9 as NSearchInput, _default$10 as NToggleInput, _default$11 as NTooltipButton, _default$12 as NTransition, OptionFormat, PresetFormExpose, PresetFormInst, PresetFormOptionItem, PresetFormOptions, PresetFormProps, PresetInputOptions, PresetInputProps, PresetInputType, PresetPickerEmits, PresetPickerExpose, PresetPickerInst, PresetPickerProps, PresetPickerValue, PresetSelectEmits, PresetSelectExpose, PresetSelectFields, PresetSelectInst, PresetSelectProps, PresetSelectValue, RemoteRequestEmits, RemoteRequestExpose, RemoteRequestFields, RemoteRequestInst, RemoteRequestProps, SearchInputProps, TooltipButtonProps, TransitionProps, UseNaiveFormRules };
|
package/dist/components.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import BaseTransition_default from "./components/transition/BaseTransition.js";
|
|
2
2
|
import LoadingProvider_default from "./components/loading-provider/LoadingProvider.js";
|
|
3
|
-
import {
|
|
3
|
+
import { LOADING_PROVIDER_INJECTION_KEY } from "./components/loading-provider/index.js";
|
|
4
4
|
import ConfigProviders_default from "./components/config-providers/ConfigProviders.js";
|
|
5
5
|
import CopyButton_default from "./components/copy-button/CopyButton.js";
|
|
6
6
|
import SearchInput_default from "./components/search-input/SearchInput.js";
|
|
@@ -12,7 +12,6 @@ import PresetSelect_default from "./components/preset-select/PresetSelect.js";
|
|
|
12
12
|
import RemoteRequest_default from "./components/remote-request/RemoteRequest.js";
|
|
13
13
|
import ToggleInput_default from "./components/toggle-input/ToggleInput.js";
|
|
14
14
|
import TooltipButton_default from "./components/tooltip-button/TooltipButton.js";
|
|
15
|
-
import TypeWriter_default from "./components/type-writer/TypeWriter.js";
|
|
16
15
|
import { ComponentAttrs, ComponentEmit, ComponentExposed, ComponentProps, ComponentSlots } from "vue-component-type-helpers";
|
|
17
16
|
|
|
18
|
-
export { ComponentAttrs, ComponentEmit, ComponentExposed, ComponentProps, ComponentSlots, ConfigProviders_default as NConfigProviders, CopyButton_default as NCopyButton, DataTablePlus_default as NDataTablePlus, LoadingProvider_default as NLoadingProvider, PresetForm_default as NPresetForm, PresetInput_default as NPresetInput, PresetPicker_default as NPresetPicker, PresetSelect_default as NPresetSelect, RemoteRequest_default as NRemoteRequest, SearchInput_default as NSearchInput, ToggleInput_default as NToggleInput, TooltipButton_default as NTooltipButton, BaseTransition_default as NTransition
|
|
17
|
+
export { ComponentAttrs, ComponentEmit, ComponentExposed, ComponentProps, ComponentSlots, LOADING_PROVIDER_INJECTION_KEY, ConfigProviders_default as NConfigProviders, CopyButton_default as NCopyButton, DataTablePlus_default as NDataTablePlus, LoadingProvider_default as NLoadingProvider, PresetForm_default as NPresetForm, PresetInput_default as NPresetInput, PresetPicker_default as NPresetPicker, PresetSelect_default as NPresetSelect, RemoteRequest_default as NRemoteRequest, SearchInput_default as NSearchInput, ToggleInput_default as NToggleInput, TooltipButton_default as NTooltipButton, BaseTransition_default as NTransition };
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
//#region src/composables/_helper.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* 颜色配置类型,用于定义主题的基础颜色
|
|
4
|
+
*/
|
|
2
5
|
type Colors = {
|
|
3
|
-
primary?: string;
|
|
4
|
-
info?: string;
|
|
5
|
-
success?: string;
|
|
6
|
-
warning?: string;
|
|
6
|
+
/** 主色 */primary?: string; /** 信息色 */
|
|
7
|
+
info?: string; /** 成功色 */
|
|
8
|
+
success?: string; /** 警告色 */
|
|
9
|
+
warning?: string; /** 错误色 */
|
|
7
10
|
error?: string;
|
|
8
11
|
};
|
|
9
12
|
//#endregion
|
|
@@ -1,12 +1,34 @@
|
|
|
1
1
|
import { colord } from "colord";
|
|
2
2
|
|
|
3
3
|
//#region src/composables/_helper.ts
|
|
4
|
+
/**
|
|
5
|
+
* 获取变亮的颜色
|
|
6
|
+
* @param color - 原始颜色值
|
|
7
|
+
* @returns 变亮后的颜色值,如果输入无效则返回 undefined
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* const darkColor = getDarkColor('#1890ff')
|
|
11
|
+
* // 返回变亮后的颜色值
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
4
14
|
function getDarkColor(color) {
|
|
5
15
|
if (!color) return void 0;
|
|
6
16
|
const colorInst = colord(color);
|
|
7
17
|
if (!colorInst.isValid()) return void 0;
|
|
8
18
|
return colorInst.lighten(.1).toHex();
|
|
9
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* 获取一组变亮的颜色
|
|
22
|
+
* @param colors - 颜色配置对象
|
|
23
|
+
* @returns 包含变亮后颜色的对象
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* const darkColors = getDarkColors({
|
|
27
|
+
* primary: '#1890ff',
|
|
28
|
+
* success: '#52c41a'
|
|
29
|
+
* })
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
10
32
|
function getDarkColors(colors) {
|
|
11
33
|
return {
|
|
12
34
|
primary: getDarkColor(colors.primary),
|
|
@@ -16,6 +38,16 @@ function getDarkColors(colors) {
|
|
|
16
38
|
error: getDarkColor(colors.error)
|
|
17
39
|
};
|
|
18
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* 获取状态颜色对象,包含基础颜色和交互状态颜色
|
|
43
|
+
* @param color - 原始颜色值
|
|
44
|
+
* @returns 状态颜色对象,如果输入无效则返回 undefined
|
|
45
|
+
* @example
|
|
46
|
+
* ```ts
|
|
47
|
+
* const statusColor = getStatusColor('#1890ff')
|
|
48
|
+
* // 返回 { color: '#1890ff', hover: '...', pressed: '...', suppl: '...' }
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
19
51
|
function getStatusColor(color) {
|
|
20
52
|
if (!color) return void 0;
|
|
21
53
|
const colorInst = colord(color);
|
|
@@ -27,6 +59,21 @@ function getStatusColor(color) {
|
|
|
27
59
|
suppl: colorInst.lighten(.1).toHex()
|
|
28
60
|
};
|
|
29
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* 获取一组状态颜色
|
|
64
|
+
* @param colors - 颜色配置对象
|
|
65
|
+
* @returns 包含各状态颜色的对象
|
|
66
|
+
* @example
|
|
67
|
+
* ```ts
|
|
68
|
+
* const colors = getColors({
|
|
69
|
+
* primary: '#1890ff',
|
|
70
|
+
* info: '#1890ff',
|
|
71
|
+
* success: '#52c41a',
|
|
72
|
+
* warning: '#faad14',
|
|
73
|
+
* error: '#f5222d'
|
|
74
|
+
* })
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
30
77
|
function getColors(colors) {
|
|
31
78
|
const { primary, info, success, warning, error } = colors ?? {};
|
|
32
79
|
return {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DataObject, DataRequestFields, UseDataRequestOptions, UseDataRequestPagination, UseDataRequestReturns, useDataRequest } from "./use-data-request.js";
|
|
2
2
|
import { useLoading } from "./use-loading.js";
|
|
3
3
|
import { UseNaiveFormClearRules, UseNaiveFormOptions, UseNaiveFormReturns, UseNaiveFormRules, useNaiveForm } from "./use-naive-form.js";
|
|
4
|
-
import { UseNaiveMenuOptions, UseNaiveMenuReturn, useNaiveMenu } from "./use-naive-menu.js";
|
|
4
|
+
import { UseNaiveMenuOptions, UseNaiveMenuReturn, flattenDeep, useNaiveMenu } from "./use-naive-menu.js";
|
|
5
5
|
import { UseNaiveThemeOptions, UseNaiveThemeReturns, useNaiveTheme } from "./use-naive-theme.js";
|
|
@@ -46,13 +46,20 @@ type UseDataRequestPagination = {
|
|
|
46
46
|
* @param api 请求 API 函数
|
|
47
47
|
* @param options 配置选项
|
|
48
48
|
* @returns 数据请求操作对象
|
|
49
|
+
* @example
|
|
50
|
+
* ```ts
|
|
51
|
+
* const { loading, data, list, pagination, run, refresh } = useDataRequest(api, {
|
|
52
|
+
* defaultParams: { page: 1, pageSize: 10 },
|
|
53
|
+
* fields: { page: 'page', pageSize: 'size', list: 'data', count: 'total' }
|
|
54
|
+
* })
|
|
55
|
+
* ```
|
|
49
56
|
*/
|
|
50
57
|
declare function useDataRequest<P extends DataObject = DataObject, D extends DataObject = DataObject, R extends DataObject = DataObject>(api: (...args: P[]) => Promise<D>, options?: UseDataRequestOptions<P, D>): {
|
|
51
|
-
|
|
52
|
-
data: Readonly<vue0.Ref<D | undefined, D | undefined>>;
|
|
53
|
-
error: Readonly<vue0.Ref<Error | undefined, Error | undefined>>;
|
|
54
|
-
params: Readonly<vue0.Ref<
|
|
55
|
-
list: vue0.ComputedRef<R[]>;
|
|
58
|
+
loading: Readonly<vue0.Ref<boolean, boolean>>;
|
|
59
|
+
data: Readonly<vue0.Ref<D | undefined, D | undefined>>;
|
|
60
|
+
error: Readonly<vue0.Ref<Error | undefined, Error | undefined>>;
|
|
61
|
+
params: Readonly<vue0.Ref<[] | P[], [] | P[]>>;
|
|
62
|
+
list: vue0.ComputedRef<R[]>;
|
|
56
63
|
pagination: vue0.Ref<{
|
|
57
64
|
page: number;
|
|
58
65
|
pageSize: number;
|
|
@@ -61,19 +68,19 @@ declare function useDataRequest<P extends DataObject = DataObject, D extends Dat
|
|
|
61
68
|
page: number;
|
|
62
69
|
pageSize: number;
|
|
63
70
|
itemCount: number;
|
|
64
|
-
}>;
|
|
65
|
-
run: (...params: P[]) => void;
|
|
66
|
-
runAsync: (...params: P[]) => Promise<D>;
|
|
67
|
-
refresh: () => void;
|
|
68
|
-
refreshAsync: () => Promise<D>;
|
|
69
|
-
cancel: () => void;
|
|
70
|
-
mutate: (data?: D | ((oldData?: D | undefined) => D | undefined) | undefined) => void;
|
|
71
|
-
setParams: (_params: Partial<P>) => void;
|
|
72
|
-
runParams: (_params: Partial<P>) => void;
|
|
73
|
-
runParamsAsync: (_params: Partial<P>) => Promise<D>;
|
|
74
|
-
onBefore: _vueuse_core0.EventHookOn<[P[]]>;
|
|
75
|
-
onSuccess: _vueuse_core0.EventHookOn<[D, P[]]>;
|
|
76
|
-
onError: _vueuse_core0.EventHookOn<[Error, P[]]>;
|
|
71
|
+
}>;
|
|
72
|
+
run: (...params: P[]) => void;
|
|
73
|
+
runAsync: (...params: P[]) => Promise<D>;
|
|
74
|
+
refresh: () => void;
|
|
75
|
+
refreshAsync: () => Promise<D>;
|
|
76
|
+
cancel: () => void;
|
|
77
|
+
mutate: (data?: D | ((oldData?: D | undefined) => D | undefined) | undefined) => void;
|
|
78
|
+
setParams: (_params: Partial<P>) => void;
|
|
79
|
+
runParams: (_params: Partial<P>) => void;
|
|
80
|
+
runParamsAsync: (_params: Partial<P>) => Promise<D>;
|
|
81
|
+
onBefore: _vueuse_core0.EventHookOn<[P[]]>;
|
|
82
|
+
onSuccess: _vueuse_core0.EventHookOn<[D, P[]]>;
|
|
83
|
+
onError: _vueuse_core0.EventHookOn<[Error, P[]]>;
|
|
77
84
|
onFinally: _vueuse_core0.EventHookOn<[P[], D | undefined, Error | undefined]>;
|
|
78
85
|
};
|
|
79
86
|
/**
|
|
@@ -11,6 +11,13 @@ import useRequest from "vue-hooks-plus/es/useRequest";
|
|
|
11
11
|
* @param api 请求 API 函数
|
|
12
12
|
* @param options 配置选项
|
|
13
13
|
* @returns 数据请求操作对象
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* const { loading, data, list, pagination, run, refresh } = useDataRequest(api, {
|
|
17
|
+
* defaultParams: { page: 1, pageSize: 10 },
|
|
18
|
+
* fields: { page: 'page', pageSize: 'size', list: 'data', count: 'total' }
|
|
19
|
+
* })
|
|
20
|
+
* ```
|
|
14
21
|
*/
|
|
15
22
|
function useDataRequest(api, options) {
|
|
16
23
|
const { defaultParams, manual, fields, requestOptions, requestPlugins } = options ?? {};
|
|
@@ -70,15 +77,23 @@ function useDataRequest(api, options) {
|
|
|
70
77
|
const list = computed(() => data.value?.[_fields.list] ?? []);
|
|
71
78
|
/**
|
|
72
79
|
* 设置请求参数
|
|
73
|
-
* @param _params 要设置的参数
|
|
80
|
+
* @param _params - 要设置的参数
|
|
81
|
+
* @example
|
|
82
|
+
* ```ts
|
|
83
|
+
* setParams({ page: 2 })
|
|
84
|
+
* ```
|
|
74
85
|
*/
|
|
75
86
|
function setParams(_params) {
|
|
76
87
|
Object.assign(params.value?.[0], _params);
|
|
77
88
|
}
|
|
78
89
|
/**
|
|
79
90
|
* 设置参数并运行请求
|
|
80
|
-
* @param _params 要设置的参数
|
|
91
|
+
* @param _params - 要设置的参数
|
|
81
92
|
* @returns 请求结果
|
|
93
|
+
* @example
|
|
94
|
+
* ```ts
|
|
95
|
+
* runParams({ page: 2 })
|
|
96
|
+
* ```
|
|
82
97
|
*/
|
|
83
98
|
function runParams(_params) {
|
|
84
99
|
return run({
|
|
@@ -88,8 +103,12 @@ function useDataRequest(api, options) {
|
|
|
88
103
|
}
|
|
89
104
|
/**
|
|
90
105
|
* 设置参数并异步运行请求
|
|
91
|
-
* @param _params 要设置的参数
|
|
106
|
+
* @param _params - 要设置的参数
|
|
92
107
|
* @returns 请求结果 Promise
|
|
108
|
+
* @example
|
|
109
|
+
* ```ts
|
|
110
|
+
* await runParamsAsync({ page: 2 })
|
|
111
|
+
* ```
|
|
93
112
|
*/
|
|
94
113
|
function runParamsAsync(_params) {
|
|
95
114
|
return runAsync({
|
|
@@ -4,6 +4,12 @@ import { LoadingProviderInst } from "../components/loading-provider/index.js";
|
|
|
4
4
|
/**
|
|
5
5
|
* 用于获取 Naive UI 加载状态提供者的组合式 API
|
|
6
6
|
* @returns 加载状态提供者实例
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* const loading = useLoading()
|
|
10
|
+
* loading?.start()
|
|
11
|
+
* loading?.finish()
|
|
12
|
+
* ```
|
|
7
13
|
*/
|
|
8
14
|
declare function useLoading(): LoadingProviderInst | undefined;
|
|
9
15
|
//#endregion
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LOADING_PROVIDER_INJECTION_KEY } from "../components/loading-provider/index.js";
|
|
2
2
|
import { inject } from "vue";
|
|
3
3
|
|
|
4
4
|
//#region src/composables/use-loading.ts
|
|
@@ -9,9 +9,15 @@ import { inject } from "vue";
|
|
|
9
9
|
/**
|
|
10
10
|
* 用于获取 Naive UI 加载状态提供者的组合式 API
|
|
11
11
|
* @returns 加载状态提供者实例
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* const loading = useLoading()
|
|
15
|
+
* loading?.start()
|
|
16
|
+
* loading?.finish()
|
|
17
|
+
* ```
|
|
12
18
|
*/
|
|
13
19
|
function useLoading() {
|
|
14
|
-
return inject(
|
|
20
|
+
return inject(LOADING_PROVIDER_INJECTION_KEY);
|
|
15
21
|
}
|
|
16
22
|
|
|
17
23
|
//#endregion
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DataObject } from "./use-data-request.js";
|
|
2
2
|
import * as _vueuse_core3 from "@vueuse/core";
|
|
3
|
-
import * as
|
|
3
|
+
import * as vue5 from "vue";
|
|
4
4
|
import { MaybeRefOrGetter, Ref, TemplateRef } from "vue";
|
|
5
5
|
import { FormInst, FormItemRule, FormRules } from "naive-ui";
|
|
6
6
|
import { ValidateError } from "async-validator";
|
|
@@ -35,23 +35,31 @@ type UseNaiveFormOptions<T extends DataObject> = {
|
|
|
35
35
|
* @param formInstRef 表单实例引用
|
|
36
36
|
* @param options 配置选项
|
|
37
37
|
* @returns 表单操作对象
|
|
38
|
+
* @example
|
|
39
|
+
* ```ts
|
|
40
|
+
* const formRef = ref<FormInst>()
|
|
41
|
+
* const { formValue, formRules, formProps, validate, reset, clear } = useNaiveForm(formRef, {
|
|
42
|
+
* value: { name: '', age: 0 },
|
|
43
|
+
* rules: { name: { required: true, message: '请输入姓名' } }
|
|
44
|
+
* })
|
|
45
|
+
* ```
|
|
38
46
|
*/
|
|
39
47
|
declare function useNaiveForm<T extends DataObject = DataObject>(formInstRef: TemplateRef<FormInst>, options?: UseNaiveFormOptions<T>): {
|
|
40
|
-
|
|
41
|
-
formValue: Ref<T, T>;
|
|
42
|
-
formRules: Ref<Partial<Record<keyof T, FormRules | FormItemRule | FormItemRule[]>>, Partial<Record<keyof T, FormRules | FormItemRule | FormItemRule[]>>>;
|
|
48
|
+
formInst: Readonly<vue5.ShallowRef<FormInst | null>>;
|
|
49
|
+
formValue: Ref<T, T>;
|
|
50
|
+
formRules: Ref<Partial<Record<keyof T, FormRules | FormItemRule | FormItemRule[]>>, Partial<Record<keyof T, FormRules | FormItemRule | FormItemRule[]>>>;
|
|
43
51
|
formProps: {
|
|
44
|
-
model:
|
|
45
|
-
rules:
|
|
46
|
-
};
|
|
47
|
-
setValue: (
|
|
52
|
+
model: vue5.Reactive<T>;
|
|
53
|
+
rules: vue5.Reactive<Partial<Record<keyof T, FormRules | FormItemRule | FormItemRule[]>>>;
|
|
54
|
+
};
|
|
55
|
+
setValue: (value: Partial<T>) => void;
|
|
48
56
|
validate: () => Promise<{
|
|
49
57
|
warnings?: ValidateError[][];
|
|
50
|
-
}>;
|
|
51
|
-
resetValidation: () => void;
|
|
52
|
-
resetForm: () => void;
|
|
53
|
-
reset: () => void;
|
|
54
|
-
clear: () => void;
|
|
58
|
+
}>;
|
|
59
|
+
resetValidation: () => void;
|
|
60
|
+
resetForm: () => void;
|
|
61
|
+
reset: () => void;
|
|
62
|
+
clear: () => void;
|
|
55
63
|
onValidated: _vueuse_core3.EventHookOn<[T]>;
|
|
56
64
|
};
|
|
57
65
|
/**
|