@oiij/naive-ui 0.0.76 → 0.0.77
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 +15 -80
- 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 +17 -17
- 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 +33 -37
- 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 +6 -6
- 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/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/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 +5 -4
- package/dist/composables/use-naive-menu.js +2 -50
- package/dist/composables/use-naive-theme.d.ts +27 -14
- package/dist/composables/use-naive-theme.js +22 -4
- 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
|
@@ -3,57 +3,77 @@ import { RemoteRequestEmits, RemoteRequestProps } from "../remote-request/index.
|
|
|
3
3
|
import { SearchInputProps } from "../search-input/index.js";
|
|
4
4
|
import { _default } from "./DataTablePlus.vue.js";
|
|
5
5
|
import { CSSProperties, Ref, ShallowRef } from "vue";
|
|
6
|
-
import {
|
|
6
|
+
import { DataTableColumns, DataTableFilterState, DataTableInst, DataTableProps, DataTableSortState, PaginationProps } from "naive-ui";
|
|
7
7
|
import { ComponentExposed } from "vue-component-type-helpers";
|
|
8
|
-
import { FilterState, TableBaseColumn } from "naive-ui/es/data-table/src/interface";
|
|
8
|
+
import { FilterState, RowKey, TableBaseColumn } from "naive-ui/es/data-table/src/interface";
|
|
9
9
|
|
|
10
10
|
//#region src/components/data-table-plus/index.d.ts
|
|
11
|
+
/**
|
|
12
|
+
* 类样式类型
|
|
13
|
+
*/
|
|
11
14
|
type ClassStyle = {
|
|
12
|
-
class?: string;
|
|
15
|
+
/** CSS 类名 */class?: string; /** CSS 样式 */
|
|
13
16
|
style?: CSSProperties | string;
|
|
14
17
|
};
|
|
18
|
+
/**
|
|
19
|
+
* 数据表格增强组件暴露的方法
|
|
20
|
+
* @template P 请求参数类型
|
|
21
|
+
* @template D 响应数据类型
|
|
22
|
+
* @template R 列表项类型
|
|
23
|
+
*/
|
|
15
24
|
type DataTablePlusExpose<P extends DataObject = DataObject, D extends DataObject = DataObject, R extends DataObject = DataObject> = UseDataRequestReturns<P, D, R> & {
|
|
16
|
-
filters: Ref<DataTableFilterState | undefined>;
|
|
17
|
-
sorters: Ref<Record<string, DataTableSortState> | undefined>;
|
|
25
|
+
/** 筛选状态 */filters: Ref<DataTableFilterState | undefined>; /** 排序状态 */
|
|
26
|
+
sorters: Ref<Record<string, DataTableSortState> | undefined>; /** 数据表格实例 */
|
|
18
27
|
dataTableInst: Readonly<ShallowRef<DataTableInst | null>>;
|
|
19
28
|
};
|
|
29
|
+
/**
|
|
30
|
+
* 数据表格增强字段配置
|
|
31
|
+
*/
|
|
20
32
|
type DataTablePlusFields = DataRequestFields & {
|
|
21
|
-
filter?: string;
|
|
22
|
-
sorter?: string;
|
|
23
|
-
rowKey?: string;
|
|
24
|
-
search?: string;
|
|
33
|
+
/** 筛选字段名 */filter?: string; /** 排序字段名 */
|
|
34
|
+
sorter?: string; /** 行键字段名 */
|
|
35
|
+
rowKey?: string; /** 搜索字段名 */
|
|
36
|
+
search?: string; /** 子节点字段名 */
|
|
25
37
|
children?: string;
|
|
26
38
|
};
|
|
39
|
+
/**
|
|
40
|
+
* 数据表格增强组件属性
|
|
41
|
+
* @template P 请求参数类型
|
|
42
|
+
* @template D 响应数据类型
|
|
43
|
+
* @template R 列表项类型
|
|
44
|
+
*/
|
|
27
45
|
type DataTablePlusProps<P extends DataObject = DataObject, D extends DataObject = DataObject, R extends DataObject = DataObject> = RemoteRequestProps<P, D> & {
|
|
28
|
-
title?: string;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
search?: SearchInputProps & ClassStyle | boolean;
|
|
36
|
-
pagination?: Omit<PaginationProps, 'page' | 'pageSize' | 'itemCount'> & ClassStyle | boolean;
|
|
37
|
-
columnsFilterOptions?: (filters: DataTableFilterState) => Record<string, any>;
|
|
38
|
-
columnsSorterOptions?: (sorters: Record<string, DataTableSortState>) => Record<string, any>;
|
|
46
|
+
/** 标题 */title?: string; /** 表格列配置 */
|
|
47
|
+
columns?: DataTableColumns<R>; /** 字段配置 */
|
|
48
|
+
fields?: DataTablePlusFields; /** 搜索配置 */
|
|
49
|
+
search?: SearchInputProps & ClassStyle | boolean; /** 分页配置 */
|
|
50
|
+
pagination?: Omit<PaginationProps, 'page' | 'pageSize' | 'itemCount'> & ClassStyle | boolean; /** 列筛选选项 */
|
|
51
|
+
columnsFilterOptions?: (filters: DataTableFilterState) => Record<string, any>; /** 列排序选项 */
|
|
52
|
+
columnsSorterOptions?: (sorters: Record<string, DataTableSortState>) => Record<string, any>; /** 数据表格属性 */
|
|
39
53
|
dataTableProps?: DataTableProps & ClassStyle;
|
|
40
54
|
};
|
|
55
|
+
/**
|
|
56
|
+
* 数据表格增强组件事件
|
|
57
|
+
* @template P 请求参数类型
|
|
58
|
+
* @template D 响应数据类型
|
|
59
|
+
* @template R 列表项类型
|
|
60
|
+
*/
|
|
41
61
|
type DataTablePlusEmits<P extends DataObject = DataObject, D extends DataObject = DataObject, R extends DataObject = DataObject> = RemoteRequestEmits<P, D> & {
|
|
42
|
-
(e: 'clickRow', row: R, index: number, event: MouseEvent, currentData: R[]): void;
|
|
43
|
-
(e: 'contextMenuRow', row: R, index: number, event: MouseEvent, currentData: R[]): void;
|
|
44
|
-
(e: '
|
|
45
|
-
(e: 'scroll', ev: Event): void;
|
|
46
|
-
(e: 'scrollBottom', ev: Event): void;
|
|
47
|
-
(e: 'update:checkedRowKeys', keys: (string | number)[], rows: (R | undefined)[], meta: {
|
|
62
|
+
/** 点击行事件 */(e: 'clickRow', row: R, index: number, event: MouseEvent, currentData: R[]): void; /** 右键点击行事件 */
|
|
63
|
+
(e: 'contextMenuRow', row: R, index: number, event: MouseEvent, currentData: R[]): void; /** 更新选中行键事件 */
|
|
64
|
+
(e: 'update:checkedRowKeys', keys: RowKey[], rows: R[], meta: {
|
|
48
65
|
row: R | undefined;
|
|
49
66
|
action: 'check' | 'uncheck' | 'checkAll' | 'uncheckAll';
|
|
50
|
-
}, currentData: R[]): void;
|
|
51
|
-
(e: 'update:
|
|
52
|
-
(e: 'update:
|
|
53
|
-
(e: 'update:
|
|
54
|
-
(e: 'update:
|
|
55
|
-
(e: '
|
|
67
|
+
}, currentData: R[]): void; /** 更新筛选事件 */
|
|
68
|
+
(e: 'update:filters', filterState: FilterState, sourceColumn: TableBaseColumn): void; /** 更新排序事件 */
|
|
69
|
+
(e: 'update:sorter', options: DataTableSortState | DataTableSortState[] | null): void; /** 更新页码事件 */
|
|
70
|
+
(e: 'update:page', page: number): void; /** 更新每页大小事件 */
|
|
71
|
+
(e: 'update:pageSize', pageSize: number): void; /** 成功事件 */
|
|
72
|
+
(e: 'loadedRows', data: R[]): void;
|
|
56
73
|
};
|
|
74
|
+
/**
|
|
75
|
+
* 数据表格增强组件实例类型
|
|
76
|
+
*/
|
|
57
77
|
type DataTablePlusInst = ComponentExposed<typeof _default>;
|
|
58
78
|
//#endregion
|
|
59
79
|
export { ClassStyle, DataTablePlusEmits, DataTablePlusExpose, DataTablePlusFields, DataTablePlusInst, DataTablePlusProps };
|
|
@@ -5,7 +5,7 @@ import { SearchInputProps } from "./search-input/index.js";
|
|
|
5
5
|
import { _default as _default$2 } from "./data-table-plus/DataTablePlus.vue.js";
|
|
6
6
|
import { ClassStyle, DataTablePlusEmits, DataTablePlusExpose, DataTablePlusFields, DataTablePlusInst, DataTablePlusProps } from "./data-table-plus/index.js";
|
|
7
7
|
import { _default as _default$3 } from "./loading-provider/LoadingProvider.vue.js";
|
|
8
|
-
import { LoadingProviderInst, LoadingProviderProps
|
|
8
|
+
import { LOADING_PROVIDER_INJECTION_KEY, LoadingProviderInst, LoadingProviderProps } from "./loading-provider/index.js";
|
|
9
9
|
import { UseNaiveFormRules } from "../composables/use-naive-form.js";
|
|
10
10
|
import { _default as _default$4 } from "./config-providers/ConfigProviders.vue.js";
|
|
11
11
|
import { ConfigProvidersProps } from "./config-providers/index.js";
|
|
@@ -24,6 +24,4 @@ import "./toggle-input/index.js";
|
|
|
24
24
|
import { _default as _default$11 } from "./tooltip-button/TooltipButton.vue.js";
|
|
25
25
|
import { TooltipButtonProps } from "./tooltip-button/index.js";
|
|
26
26
|
import { _default as _default$12 } from "./transition/BaseTransition.vue.js";
|
|
27
|
-
import { TransitionProps } from "./transition/index.js";
|
|
28
|
-
import { _default as _default$13 } from "./type-writer/TypeWriter.vue.js";
|
|
29
|
-
import { TypeWriterProps } from "./type-writer/index.js";
|
|
27
|
+
import { TransitionProps } from "./transition/index.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import BaseTransition_default from "../transition/BaseTransition.js";
|
|
2
2
|
import { cName, loadingProviderCssr } from "./loading-provider.cssr.js";
|
|
3
|
-
import {
|
|
3
|
+
import { LOADING_PROVIDER_INJECTION_KEY } from "./index.js";
|
|
4
4
|
import { Fragment, Teleport, createBlock, createCommentVNode, createElementBlock, createSlots, createVNode, defineComponent, mergeProps, normalizeClass, normalizeStyle, openBlock, provide, ref, renderSlot, unref, watchEffect, withCtx } from "vue";
|
|
5
5
|
import { useStyle } from "@oiij/css-render";
|
|
6
6
|
import { NEl, NSpin } from "naive-ui";
|
|
@@ -41,7 +41,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
41
41
|
}, _duration ?? __props.duration);
|
|
42
42
|
return { hide: hideLoading };
|
|
43
43
|
}
|
|
44
|
-
provide(
|
|
44
|
+
provide(LOADING_PROVIDER_INJECTION_KEY, {
|
|
45
45
|
show: showLoading,
|
|
46
46
|
hide: hideLoading
|
|
47
47
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LoadingProviderProps } from "./index.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as vue63 from "vue";
|
|
3
3
|
|
|
4
4
|
//#region src/components/loading-provider/LoadingProvider.vue.d.ts
|
|
5
5
|
declare var __VLS_26: {}, __VLS_29: {}, __VLS_31: {};
|
|
@@ -10,7 +10,7 @@ type __VLS_Slots = {} & {
|
|
|
10
10
|
} & {
|
|
11
11
|
default?: (props: typeof __VLS_31) => any;
|
|
12
12
|
};
|
|
13
|
-
declare const __VLS_base:
|
|
13
|
+
declare const __VLS_base: vue63.DefineComponent<LoadingProviderProps, {}, {}, {}, {}, vue63.ComponentOptionsMixin, vue63.ComponentOptionsMixin, {}, string, vue63.PublicProps, Readonly<LoadingProviderProps> & Readonly<{}>, {}, {}, {}, {}, string, vue63.ComponentProvideOptions, false, {}, any>;
|
|
14
14
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
15
15
|
declare const _default: typeof __VLS_export;
|
|
16
16
|
type __VLS_WithSlots<T, S> = T & {
|
|
@@ -4,21 +4,30 @@ import { CSSProperties, InjectionKey, RendererElement } from "vue";
|
|
|
4
4
|
import { SpinProps } from "naive-ui";
|
|
5
5
|
|
|
6
6
|
//#region src/components/loading-provider/index.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* 加载提供者实例
|
|
9
|
+
*/
|
|
7
10
|
type LoadingProviderInst = {
|
|
8
|
-
show: (options?: {
|
|
9
|
-
text?: string;
|
|
11
|
+
/** 显示加载 */show: (options?: {
|
|
12
|
+
/** 加载文本 */text?: string; /** 持续时间 */
|
|
10
13
|
duration?: number;
|
|
11
|
-
}) => void;
|
|
14
|
+
}) => void; /** 隐藏加载 */
|
|
12
15
|
hide: () => void;
|
|
13
16
|
};
|
|
14
|
-
|
|
17
|
+
/**
|
|
18
|
+
* 加载提供者注入键
|
|
19
|
+
*/
|
|
20
|
+
declare const LOADING_PROVIDER_INJECTION_KEY: InjectionKey<LoadingProviderInst>;
|
|
21
|
+
/**
|
|
22
|
+
* 加载提供者属性
|
|
23
|
+
*/
|
|
15
24
|
type LoadingProviderProps = {
|
|
16
|
-
show?: boolean;
|
|
17
|
-
appendTo?: string | RendererElement;
|
|
18
|
-
mask?: boolean | CSSProperties;
|
|
19
|
-
blur?: boolean;
|
|
20
|
-
duration?: number;
|
|
25
|
+
/** 是否显示 */show?: boolean; /** 挂载目标元素 */
|
|
26
|
+
appendTo?: string | RendererElement; /** 遮罩层配置 */
|
|
27
|
+
mask?: boolean | CSSProperties; /** 是否模糊 */
|
|
28
|
+
blur?: boolean; /** 持续时间 */
|
|
29
|
+
duration?: number; /** 加载组件属性 */
|
|
21
30
|
spinProps?: Omit<SpinProps, 'show'> & ClassStyle;
|
|
22
31
|
};
|
|
23
32
|
//#endregion
|
|
24
|
-
export { LoadingProviderInst, LoadingProviderProps
|
|
33
|
+
export { LOADING_PROVIDER_INJECTION_KEY, LoadingProviderInst, LoadingProviderProps };
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import LoadingProvider_default from "./LoadingProvider.js";
|
|
2
2
|
|
|
3
3
|
//#region src/components/loading-provider/index.ts
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* 加载提供者注入键
|
|
6
|
+
*/
|
|
7
|
+
const LOADING_PROVIDER_INJECTION_KEY = Symbol("loading-provider-key");
|
|
5
8
|
|
|
6
9
|
//#endregion
|
|
7
|
-
export {
|
|
10
|
+
export { LOADING_PROVIDER_INJECTION_KEY };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useNaiveForm } from "../../composables/use-naive-form.js";
|
|
2
2
|
import PresetInput_default from "../preset-input/PresetInput.js";
|
|
3
3
|
import { mergeRule } from "./_utils.js";
|
|
4
|
-
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createTextVNode, createVNode, defineComponent, guardReactiveProps, mergeProps, normalizeProps, openBlock, ref, renderList, renderSlot, resolveDynamicComponent, toDisplayString,
|
|
4
|
+
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createTextVNode, createVNode, defineComponent, guardReactiveProps, mergeProps, normalizeProps, openBlock, ref, renderList, renderSlot, resolveDynamicComponent, toDisplayString, unref, useTemplateRef, withCtx } from "vue";
|
|
5
5
|
import { NButton, NCollapseTransition, NDivider, NForm, NFormItem, NGi, NGrid } from "naive-ui";
|
|
6
6
|
|
|
7
7
|
//#region src/components/preset-form/PresetForm.vue
|
|
@@ -27,15 +27,36 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
27
27
|
emit("validated", value);
|
|
28
28
|
});
|
|
29
29
|
const filterCollapsed = ref(false);
|
|
30
|
+
const visibleOptions = computed(() => {
|
|
31
|
+
return __props.options?.filter((f) => typeof f.hidden === "function" ? !f.hidden() : !f.hidden) || [];
|
|
32
|
+
});
|
|
30
33
|
const _options = computed(() => {
|
|
31
|
-
return
|
|
34
|
+
return visibleOptions.value.filter((f) => typeof f.collapsed === "function" ? !f.collapsed() : !f.collapsed);
|
|
32
35
|
});
|
|
33
36
|
const _collapsedOptions = computed(() => {
|
|
34
|
-
return
|
|
37
|
+
return visibleOptions.value.filter((f) => typeof f.collapsed === "function" ? f.collapsed() : f.collapsed);
|
|
35
38
|
});
|
|
36
39
|
function onPresetInputUpdate(val, key) {
|
|
37
40
|
if (key) setValue({ [key]: val });
|
|
38
41
|
}
|
|
42
|
+
function presetFormProps(options) {
|
|
43
|
+
return options.map((option) => {
|
|
44
|
+
const { key, label, required, span, rule, itemProps, render, ...inputOption } = option;
|
|
45
|
+
const { offset, suffix, ...extraItemProps } = itemProps ?? {};
|
|
46
|
+
return {
|
|
47
|
+
key: typeof key === "string" ? key : void 0,
|
|
48
|
+
label: typeof label === "function" ? label() : label,
|
|
49
|
+
span: typeof span === "function" ? span() : span ?? itemProps?.span,
|
|
50
|
+
required,
|
|
51
|
+
rule,
|
|
52
|
+
offset,
|
|
53
|
+
suffix,
|
|
54
|
+
itemProps: extraItemProps,
|
|
55
|
+
render,
|
|
56
|
+
inputOption
|
|
57
|
+
};
|
|
58
|
+
});
|
|
59
|
+
}
|
|
39
60
|
const expose = {
|
|
40
61
|
formInst,
|
|
41
62
|
formValue,
|
|
@@ -52,10 +73,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
52
73
|
const templateBind = computed(() => {
|
|
53
74
|
return {
|
|
54
75
|
...expose,
|
|
55
|
-
formInst:
|
|
56
|
-
formValue:
|
|
57
|
-
formRules:
|
|
58
|
-
formProps:
|
|
76
|
+
formInst: formInst.value,
|
|
77
|
+
formValue: formValue.value,
|
|
78
|
+
formRules: formRules.value,
|
|
79
|
+
formProps: _formProps
|
|
59
80
|
};
|
|
60
81
|
});
|
|
61
82
|
__expose(expose);
|
|
@@ -68,30 +89,30 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
68
89
|
default: withCtx(() => [
|
|
69
90
|
renderSlot(_ctx.$slots, "header", normalizeProps(guardReactiveProps(templateBind.value))),
|
|
70
91
|
renderSlot(_ctx.$slots, "default", normalizeProps(guardReactiveProps(templateBind.value)), () => [_options.value && _options.value.length > 0 ? (openBlock(), createBlock(unref(NGrid), normalizeProps(mergeProps({ key: 0 }, __props.gridProps)), {
|
|
71
|
-
default: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList(_options.value, ({
|
|
92
|
+
default: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList(presetFormProps(_options.value), ({ span, offset, suffix, label, key, required, rule, itemProps, render, inputOption }, index) => {
|
|
72
93
|
return openBlock(), createBlock(unref(NGi), mergeProps({
|
|
73
|
-
key:
|
|
74
|
-
span
|
|
94
|
+
key: index,
|
|
95
|
+
span
|
|
75
96
|
}, { ref_for: true }, {
|
|
76
97
|
offset,
|
|
77
98
|
suffix
|
|
78
99
|
}), {
|
|
79
100
|
default: withCtx(({ overflow }) => [createVNode(unref(NFormItem), mergeProps({
|
|
80
|
-
label
|
|
81
|
-
path:
|
|
101
|
+
label,
|
|
102
|
+
path: key,
|
|
82
103
|
rule: unref(mergeRule)({
|
|
83
104
|
key,
|
|
84
105
|
label,
|
|
85
106
|
required,
|
|
86
107
|
rule
|
|
87
108
|
})
|
|
88
|
-
}, { ref_for: true },
|
|
109
|
+
}, { ref_for: true }, itemProps), {
|
|
89
110
|
default: withCtx(() => [render ? (openBlock(), createBlock(resolveDynamicComponent(render({
|
|
90
111
|
...expose,
|
|
91
112
|
overflow
|
|
92
113
|
})), { key: 0 })) : (openBlock(), createBlock(unref(PresetInput_default), {
|
|
93
114
|
key: 1,
|
|
94
|
-
options:
|
|
115
|
+
options: inputOption,
|
|
95
116
|
value: key ? unref(formValue)[key] : void 0,
|
|
96
117
|
"onUpdate:value": (val) => onPresetInputUpdate(val, key)
|
|
97
118
|
}, null, 8, [
|
|
@@ -120,30 +141,30 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
120
141
|
_: 1
|
|
121
142
|
}), createVNode(unref(NCollapseTransition), { show: filterCollapsed.value }, {
|
|
122
143
|
default: withCtx(() => [createVNode(unref(NGrid), normalizeProps(guardReactiveProps(__props.gridProps)), {
|
|
123
|
-
default: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList(_collapsedOptions.value, ({
|
|
144
|
+
default: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList(presetFormProps(_collapsedOptions.value), ({ span, offset, suffix, label, key, required, rule, itemProps, render, inputOption }, index) => {
|
|
124
145
|
return openBlock(), createBlock(unref(NGi), mergeProps({
|
|
125
|
-
key:
|
|
126
|
-
span
|
|
146
|
+
key: index,
|
|
147
|
+
span
|
|
127
148
|
}, { ref_for: true }, {
|
|
128
149
|
offset,
|
|
129
150
|
suffix
|
|
130
151
|
}), {
|
|
131
152
|
default: withCtx(({ overflow }) => [createVNode(unref(NFormItem), mergeProps({
|
|
132
|
-
label
|
|
133
|
-
path:
|
|
153
|
+
label,
|
|
154
|
+
path: key,
|
|
134
155
|
rule: unref(mergeRule)({
|
|
135
156
|
key,
|
|
136
157
|
label,
|
|
137
158
|
required,
|
|
138
159
|
rule
|
|
139
160
|
})
|
|
140
|
-
}, { ref_for: true },
|
|
161
|
+
}, { ref_for: true }, itemProps), {
|
|
141
162
|
default: withCtx(() => [render ? (openBlock(), createBlock(resolveDynamicComponent(render({
|
|
142
163
|
...expose,
|
|
143
164
|
overflow
|
|
144
165
|
})), { key: 0 })) : (openBlock(), createBlock(unref(PresetInput_default), {
|
|
145
166
|
key: 1,
|
|
146
|
-
options:
|
|
167
|
+
options: inputOption,
|
|
147
168
|
value: key ? unref(formValue)[key] : void 0,
|
|
148
169
|
"onUpdate:value": (val) => onPresetInputUpdate(val, key)
|
|
149
170
|
}, null, 8, [
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { DataObject } from "../../composables/use-data-request.js";
|
|
2
2
|
import { PresetFormExpose, PresetFormProps } from "./index.js";
|
|
3
|
-
import * as
|
|
4
|
-
import * as
|
|
3
|
+
import * as _vueuse_core28 from "@vueuse/core";
|
|
4
|
+
import * as vue46 from "vue";
|
|
5
5
|
import * as naive_ui0 from "naive-ui";
|
|
6
6
|
import { FormInst, FormRules } from "naive-ui";
|
|
7
7
|
import * as async_validator0 from "async-validator";
|
|
8
8
|
|
|
9
9
|
//#region src/components/preset-form/PresetForm.vue.d.ts
|
|
10
10
|
declare const __VLS_export: <V extends DataObject>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
11
|
-
props:
|
|
11
|
+
props: vue46.PublicProps & __VLS_PrettifyLocal<PresetFormProps<V> & {
|
|
12
12
|
onValidated?: ((val: V) => any) | undefined;
|
|
13
13
|
}> & (typeof globalThis extends {
|
|
14
14
|
__VLS_PROPS_FALLBACK: infer P;
|
|
15
15
|
} ? P : {});
|
|
16
|
-
expose: (exposed:
|
|
16
|
+
expose: (exposed: vue46.ShallowUnwrapRef<PresetFormExpose<V>>) => void;
|
|
17
17
|
attrs: any;
|
|
18
18
|
slots: {
|
|
19
19
|
header?: (props: {
|
|
@@ -21,10 +21,10 @@ declare const __VLS_export: <V extends DataObject>(__VLS_props: NonNullable<Awai
|
|
|
21
21
|
formValue: V;
|
|
22
22
|
formRules: Partial<Record<keyof V, FormRules | naive_ui0.FormItemRule | naive_ui0.FormItemRule[]>>;
|
|
23
23
|
formProps: {
|
|
24
|
-
model:
|
|
25
|
-
rules:
|
|
24
|
+
model: vue46.Reactive<V>;
|
|
25
|
+
rules: vue46.Reactive<Partial<Record<keyof V, FormRules | naive_ui0.FormItemRule | naive_ui0.FormItemRule[]>>>;
|
|
26
26
|
};
|
|
27
|
-
setValue: (
|
|
27
|
+
setValue: (value: Partial<V>) => void;
|
|
28
28
|
validate: () => Promise<{
|
|
29
29
|
warnings?: async_validator0.ValidateError[][];
|
|
30
30
|
}>;
|
|
@@ -32,7 +32,7 @@ declare const __VLS_export: <V extends DataObject>(__VLS_props: NonNullable<Awai
|
|
|
32
32
|
resetForm: () => void;
|
|
33
33
|
reset: () => void;
|
|
34
34
|
clear: () => void;
|
|
35
|
-
onValidated:
|
|
35
|
+
onValidated: _vueuse_core28.EventHookOn<[V]>;
|
|
36
36
|
}) => any;
|
|
37
37
|
} & {
|
|
38
38
|
default?: (props: {
|
|
@@ -40,10 +40,10 @@ declare const __VLS_export: <V extends DataObject>(__VLS_props: NonNullable<Awai
|
|
|
40
40
|
formValue: V;
|
|
41
41
|
formRules: Partial<Record<keyof V, FormRules | naive_ui0.FormItemRule | naive_ui0.FormItemRule[]>>;
|
|
42
42
|
formProps: {
|
|
43
|
-
model:
|
|
44
|
-
rules:
|
|
43
|
+
model: vue46.Reactive<V>;
|
|
44
|
+
rules: vue46.Reactive<Partial<Record<keyof V, FormRules | naive_ui0.FormItemRule | naive_ui0.FormItemRule[]>>>;
|
|
45
45
|
};
|
|
46
|
-
setValue: (
|
|
46
|
+
setValue: (value: Partial<V>) => void;
|
|
47
47
|
validate: () => Promise<{
|
|
48
48
|
warnings?: async_validator0.ValidateError[][];
|
|
49
49
|
}>;
|
|
@@ -51,7 +51,7 @@ declare const __VLS_export: <V extends DataObject>(__VLS_props: NonNullable<Awai
|
|
|
51
51
|
resetForm: () => void;
|
|
52
52
|
reset: () => void;
|
|
53
53
|
clear: () => void;
|
|
54
|
-
onValidated:
|
|
54
|
+
onValidated: _vueuse_core28.EventHookOn<[V]>;
|
|
55
55
|
}) => any;
|
|
56
56
|
} & {
|
|
57
57
|
footer?: (props: {
|
|
@@ -59,10 +59,10 @@ declare const __VLS_export: <V extends DataObject>(__VLS_props: NonNullable<Awai
|
|
|
59
59
|
formValue: V;
|
|
60
60
|
formRules: Partial<Record<keyof V, FormRules | naive_ui0.FormItemRule | naive_ui0.FormItemRule[]>>;
|
|
61
61
|
formProps: {
|
|
62
|
-
model:
|
|
63
|
-
rules:
|
|
62
|
+
model: vue46.Reactive<V>;
|
|
63
|
+
rules: vue46.Reactive<Partial<Record<keyof V, FormRules | naive_ui0.FormItemRule | naive_ui0.FormItemRule[]>>>;
|
|
64
64
|
};
|
|
65
|
-
setValue: (
|
|
65
|
+
setValue: (value: Partial<V>) => void;
|
|
66
66
|
validate: () => Promise<{
|
|
67
67
|
warnings?: async_validator0.ValidateError[][];
|
|
68
68
|
}>;
|
|
@@ -70,11 +70,11 @@ declare const __VLS_export: <V extends DataObject>(__VLS_props: NonNullable<Awai
|
|
|
70
70
|
resetForm: () => void;
|
|
71
71
|
reset: () => void;
|
|
72
72
|
clear: () => void;
|
|
73
|
-
onValidated:
|
|
73
|
+
onValidated: _vueuse_core28.EventHookOn<[V]>;
|
|
74
74
|
}) => any;
|
|
75
75
|
};
|
|
76
76
|
emit: (e: "validated", val: V) => void;
|
|
77
|
-
}>) =>
|
|
77
|
+
}>) => vue46.VNode & {
|
|
78
78
|
__ctx?: Awaited<typeof __VLS_setup>;
|
|
79
79
|
};
|
|
80
80
|
declare const _default: typeof __VLS_export;
|
|
@@ -1,15 +1,30 @@
|
|
|
1
1
|
//#region src/components/preset-form/_utils.ts
|
|
2
2
|
function mergeRule(option) {
|
|
3
3
|
const { key, label, required, rule } = option ?? {};
|
|
4
|
-
|
|
5
|
-
if (
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
const _required = typeof required === "function" ? required() : required;
|
|
5
|
+
if (!_required && !rule) return;
|
|
6
|
+
const getLabelText = () => {
|
|
7
|
+
if (typeof label === "string") return label;
|
|
8
|
+
if (typeof label === "function") return label();
|
|
9
|
+
if (typeof key === "string") return key;
|
|
10
|
+
return "字段";
|
|
9
11
|
};
|
|
10
|
-
if (
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
if (_required) {
|
|
13
|
+
const requiredRule = {
|
|
14
|
+
required: true,
|
|
15
|
+
message: `${getLabelText()}不能为空`,
|
|
16
|
+
trigger: ["input", "blur"]
|
|
17
|
+
};
|
|
18
|
+
if (rule) {
|
|
19
|
+
if (Array.isArray(rule)) return [requiredRule, ...rule];
|
|
20
|
+
return {
|
|
21
|
+
...requiredRule,
|
|
22
|
+
...rule
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
return requiredRule;
|
|
26
|
+
}
|
|
27
|
+
return rule;
|
|
13
28
|
}
|
|
14
29
|
|
|
15
30
|
//#endregion
|
|
@@ -8,29 +8,48 @@ import { FormItemProps, FormItemRule, FormProps, FormRules, GridItemProps, GridP
|
|
|
8
8
|
import { ComponentExposed } from "vue-component-type-helpers";
|
|
9
9
|
|
|
10
10
|
//#region src/components/preset-form/index.d.ts
|
|
11
|
+
/**
|
|
12
|
+
* 预设表单暴露的方法
|
|
13
|
+
* @template V 表单值类型
|
|
14
|
+
*/
|
|
11
15
|
type PresetFormExpose<V extends DataObject = DataObject> = UseNaiveFormReturns<V>;
|
|
16
|
+
/**
|
|
17
|
+
* 预设表单选项项
|
|
18
|
+
* @template V 表单值类型
|
|
19
|
+
*/
|
|
12
20
|
type PresetFormOptionItem<V extends DataObject = DataObject> = PresetInputOptions & {
|
|
13
|
-
key?: keyof V;
|
|
14
|
-
label?: string | (() => string);
|
|
15
|
-
required?: boolean | (() => boolean);
|
|
16
|
-
collapsed?: boolean | (() => boolean);
|
|
17
|
-
span?: string | number | (() => string | number);
|
|
18
|
-
hidden?: boolean | (() => boolean);
|
|
19
|
-
rule?: FormRules | FormItemRule | FormItemRule[];
|
|
20
|
-
itemProps?: FormItemProps & GridItemProps & ClassStyle;
|
|
21
|
+
/** 字段键名 */key?: keyof V; /** 标签 */
|
|
22
|
+
label?: string | (() => string); /** 是否必填 */
|
|
23
|
+
required?: boolean | (() => boolean); /** 是否折叠 */
|
|
24
|
+
collapsed?: boolean | (() => boolean); /** 跨度 */
|
|
25
|
+
span?: string | number | (() => string | number); /** 是否隐藏 */
|
|
26
|
+
hidden?: boolean | (() => boolean); /** 验证规则 */
|
|
27
|
+
rule?: FormRules | FormItemRule | FormItemRule[]; /** 表单项属性 */
|
|
28
|
+
itemProps?: FormItemProps & GridItemProps & ClassStyle; /** 自定义渲染函数 */
|
|
21
29
|
render?: (params: PresetFormExpose<V> & {
|
|
22
30
|
overflow: boolean;
|
|
23
31
|
}) => VNode | null;
|
|
24
32
|
};
|
|
33
|
+
/**
|
|
34
|
+
* 预设表单选项
|
|
35
|
+
* @template V 表单值类型
|
|
36
|
+
*/
|
|
25
37
|
type PresetFormOptions<V extends DataObject = DataObject> = PresetFormOptionItem<V>[];
|
|
38
|
+
/**
|
|
39
|
+
* 预设表单属性
|
|
40
|
+
* @template V 表单值类型
|
|
41
|
+
*/
|
|
26
42
|
type PresetFormProps<V extends DataObject = DataObject> = {
|
|
27
|
-
options?: PresetFormOptions<V>;
|
|
28
|
-
value?: V;
|
|
29
|
-
rules?: UseNaiveFormRules<V>;
|
|
30
|
-
clearRules?: UseNaiveFormClearRules;
|
|
31
|
-
formProps?: FormProps & ClassStyle;
|
|
43
|
+
/** 表单选项 */options?: PresetFormOptions<V>; /** 表单值 */
|
|
44
|
+
value?: V; /** 验证规则 */
|
|
45
|
+
rules?: UseNaiveFormRules<V>; /** 清空规则 */
|
|
46
|
+
clearRules?: UseNaiveFormClearRules; /** 表单属性 */
|
|
47
|
+
formProps?: FormProps & ClassStyle; /** 网格属性 */
|
|
32
48
|
gridProps?: GridProps & ClassStyle;
|
|
33
49
|
};
|
|
50
|
+
/**
|
|
51
|
+
* 预设表单实例类型
|
|
52
|
+
*/
|
|
34
53
|
type PresetFormInst = ComponentExposed<typeof _default>;
|
|
35
54
|
//#endregion
|
|
36
55
|
export { PresetFormExpose, PresetFormInst, PresetFormOptionItem, PresetFormOptions, PresetFormProps };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { PresetInputProps } from "./index.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as vue28 from "vue";
|
|
3
3
|
|
|
4
4
|
//#region src/components/preset-input/PresetInput.vue.d.ts
|
|
5
5
|
declare const __VLS_export: <V>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
6
|
-
props:
|
|
6
|
+
props: vue28.PublicProps & __VLS_PrettifyLocal<PresetInputProps<V> & {
|
|
7
7
|
"onUpdate:value"?: ((val?: V | undefined) => any) | undefined;
|
|
8
8
|
}> & (typeof globalThis extends {
|
|
9
9
|
__VLS_PROPS_FALLBACK: infer P;
|
|
@@ -12,7 +12,7 @@ declare const __VLS_export: <V>(__VLS_props: NonNullable<Awaited<typeof __VLS_se
|
|
|
12
12
|
attrs: any;
|
|
13
13
|
slots: {};
|
|
14
14
|
emit: (e: "update:value", val?: V) => void;
|
|
15
|
-
}>) =>
|
|
15
|
+
}>) => vue28.VNode & {
|
|
16
16
|
__ctx?: Awaited<typeof __VLS_setup>;
|
|
17
17
|
};
|
|
18
18
|
declare const _default: typeof __VLS_export;
|