cnhis-design-vue 3.1.17-beta.0 → 3.1.17-beta.3
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/es/packages/big-table/src/components/separate.js +1 -1
- package/es/packages/big-table/src/hooks/useSeparateRow.js +2 -2
- package/es/packages/fabric-chart/index.d.ts +2 -0
- package/es/packages/fabric-chart/src/FabricChart.js +20 -5
- package/es/packages/fabric-chart/src/FabricChart.vue.d.ts +2 -0
- package/es/packages/fabric-chart/src/hooks/useCenter.js +19 -18
- package/es/packages/fabric-chart/src/hooks/useLeft.d.ts +3 -1
- package/es/packages/fabric-chart/src/hooks/useLeft.js +30 -12
- package/es/packages/fabric-chart/src/hooks/useRight.d.ts +1 -1
- package/es/packages/fabric-chart/src/hooks/useRight.js +11 -69
- package/es/packages/fabric-chart/src/interface.d.ts +3 -0
- package/es/packages/form-config/index.d.ts +115 -1
- package/es/packages/form-config/src/FormConfig.js +11 -17
- package/es/packages/form-config/src/FormConfig.vue.d.ts +115 -1
- package/es/packages/form-config/src/components/CloseButton.js +45 -0
- package/es/packages/form-config/src/components/CloseButton.vue.d.ts +1499 -0
- package/es/packages/form-config/src/components/ComplexNode.js +45 -0
- package/es/packages/form-config/src/components/ComplexNode.vue.d.ts +1661 -0
- package/es/packages/form-config/src/components/DefaultNode.js +54 -0
- package/es/packages/form-config/src/components/DefaultNode.vue.d.ts +1543 -0
- package/es/packages/form-config/src/components/FormConfigCreator.js +3 -1
- package/es/packages/form-config/src/components/FormConfigDragDisplay.js +43 -0
- package/es/packages/form-config/src/components/FormConfigDragDisplay.vue.d.ts +114 -0
- package/es/packages/form-config/src/components/FormConfigEdit.js +1 -0
- package/es/packages/form-config/src/components/FormConfigEdit.vue.d.ts +2 -0
- package/es/packages/form-config/src/constants/index.d.ts +2 -0
- package/es/packages/form-config/src/constants/index.js +5 -2
- package/es/packages/form-config/src/hooks/useConfigurationField.js +9 -9
- package/es/packages/form-config/src/hooks/usePresetRenderer.d.ts +2 -2
- package/es/packages/form-config/src/hooks/usePresetRenderer.js +6 -84
- package/es/packages/form-config/src/hooks/useSortable.js +3 -7
- package/es/packages/form-config/src/types/index.d.ts +2 -1
- package/es/packages/form-config/src/utils/index.d.ts +8 -1
- package/es/packages/form-config/src/utils/index.js +23 -9
- package/es/packages/form-config/style/index.css +26 -5
- package/es/packages/form-render/index.js +1 -1
- package/es/packages/form-render/src/hooks/index.d.ts +1 -1
- package/es/packages/form-render/src/hooks/index.js +1 -1
- package/es/packages/form-render/src/hooks/useBusinessBinding.d.ts +5 -6
- package/es/packages/form-render/src/hooks/useBusinessBinding.js +22 -20
- package/es/packages/form-render/src/hooks/useFieldListAdaptor.js +4 -4
- package/es/packages/form-render/src/hooks/useFieldNormalize.d.ts +5 -0
- package/es/packages/form-render/src/hooks/useFieldNormalize.js +58 -0
- package/es/packages/form-render/src/hooks/useFieldVisitor.js +1 -5
- package/es/packages/index.css +26 -5
- package/es/packages/index.js +1 -1
- package/es/src/utils/tapable/AsyncParallelBailHook.d.ts +3 -0
- package/es/src/utils/tapable/AsyncParallelBailHook.js +78 -0
- package/es/src/utils/tapable/AsyncParallelHook.d.ts +3 -0
- package/es/src/utils/tapable/AsyncParallelHook.js +27 -0
- package/es/src/utils/tapable/AsyncSeriesBailHook.d.ts +3 -0
- package/es/src/utils/tapable/AsyncSeriesBailHook.js +33 -0
- package/es/src/utils/tapable/AsyncSeriesHook.d.ts +3 -0
- package/es/src/utils/tapable/AsyncSeriesHook.js +27 -0
- package/es/src/utils/tapable/AsyncSeriesLoopHook.d.ts +3 -0
- package/es/src/utils/tapable/AsyncSeriesLoopHook.js +27 -0
- package/es/src/utils/tapable/AsyncSeriesWaterfallHook.d.ts +3 -0
- package/es/src/utils/tapable/AsyncSeriesWaterfallHook.js +40 -0
- package/es/src/utils/tapable/Hook.d.ts +50 -0
- package/es/src/utils/tapable/Hook.js +140 -0
- package/es/src/utils/tapable/HookCodeFactory.d.ts +58 -0
- package/es/src/utils/tapable/HookCodeFactory.js +444 -0
- package/es/src/utils/tapable/HookMap.d.ts +11 -0
- package/es/src/utils/tapable/HookMap.js +32 -0
- package/es/src/utils/tapable/MultiHook.d.ts +12 -0
- package/es/src/utils/tapable/MultiHook.js +38 -0
- package/es/src/utils/tapable/SyncBailHook.d.ts +3 -0
- package/es/src/utils/tapable/SyncBailHook.js +40 -0
- package/es/src/utils/tapable/SyncHook.d.ts +3 -0
- package/es/src/utils/tapable/SyncHook.js +34 -0
- package/es/src/utils/tapable/SyncLoopHook.d.ts +3 -0
- package/es/src/utils/tapable/SyncLoopHook.js +34 -0
- package/es/src/utils/tapable/SyncWaterfallHook.d.ts +3 -0
- package/es/src/utils/tapable/SyncWaterfallHook.js +48 -0
- package/es/src/utils/tapable/index.d.ts +139 -0
- package/es/src/utils/tapable/index.js +12 -0
- package/package.json +1 -1
- package/es/packages/form-render/src/hooks/useTypeNormalize.d.ts +0 -4
- package/es/packages/form-render/src/hooks/useTypeNormalize.js +0 -46
|
@@ -29,7 +29,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
29
29
|
return;
|
|
30
30
|
await formRef.validate();
|
|
31
31
|
const formData = formRef.getFormValues();
|
|
32
|
-
emit("submit", { layoutWidthEnum: "ALL_LINE", ...formData, type, key: formData.name });
|
|
32
|
+
emit("submit", { layoutWidthEnum: "ALL_LINE", ...formData, type, key: formData.name, __new: true });
|
|
33
33
|
}
|
|
34
34
|
return (_ctx, _cache) => {
|
|
35
35
|
return openBlock(), createBlock(unref(NButtonGroup), { size: "small" }, {
|
|
@@ -50,6 +50,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
50
50
|
]),
|
|
51
51
|
default: withCtx(() => [
|
|
52
52
|
createVNode(unref(FormRender), {
|
|
53
|
+
column: 12,
|
|
53
54
|
ref_key: "lineBreakFormRef",
|
|
54
55
|
ref: lineBreakFormRef,
|
|
55
56
|
"initial-data": unref(pick)(initialData, ["layoutWidthEnum"]),
|
|
@@ -77,6 +78,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
77
78
|
]),
|
|
78
79
|
default: withCtx(() => [
|
|
79
80
|
createVNode(unref(FormRender), {
|
|
81
|
+
column: 12,
|
|
80
82
|
ref_key: "linebarFormRef",
|
|
81
83
|
ref: linebarFormRef,
|
|
82
84
|
"initial-data": initialData,
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { defineComponent, openBlock, createBlock, unref, mergeProps, withCtx, createElementVNode, normalizeStyle, resolveDynamicComponent } from 'vue';
|
|
2
|
+
import Draggable from 'vuedraggable';
|
|
3
|
+
import { useSortable } from '../../../../packages/form-config/src/hooks';
|
|
4
|
+
import { layoutWidthEnum2Column } from '../../../../packages/form-config/src/utils';
|
|
5
|
+
import _export_sfc from '../../../../_virtual/plugin-vue_export-helper.js';
|
|
6
|
+
|
|
7
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
8
|
+
__name: "FormConfigDragDisplay",
|
|
9
|
+
props: {
|
|
10
|
+
fieldItem: { type: Object },
|
|
11
|
+
getRenderer: { type: Function, require: true },
|
|
12
|
+
textFormatter: { type: Function, required: true }
|
|
13
|
+
},
|
|
14
|
+
setup(__props) {
|
|
15
|
+
function getItemColumnStyle(fieldItem) {
|
|
16
|
+
return { "--item-column": fieldItem ? layoutWidthEnum2Column(fieldItem.layoutWidthEnum) : 24 };
|
|
17
|
+
}
|
|
18
|
+
const { commonConfig } = useSortable();
|
|
19
|
+
return (_ctx, _cache) => {
|
|
20
|
+
return openBlock(), createBlock(unref(Draggable), mergeProps(unref(commonConfig), {
|
|
21
|
+
style: getItemColumnStyle(__props.fieldItem),
|
|
22
|
+
group: "__display"
|
|
23
|
+
}), {
|
|
24
|
+
item: withCtx(({ element }) => [
|
|
25
|
+
createElementVNode("div", {
|
|
26
|
+
class: "form-config__displayContentItem",
|
|
27
|
+
style: normalizeStyle(getItemColumnStyle(element))
|
|
28
|
+
}, [
|
|
29
|
+
(openBlock(), createBlock(resolveDynamicComponent(__props.getRenderer(element)), {
|
|
30
|
+
"get-renderer": __props.getRenderer,
|
|
31
|
+
"field-item": element,
|
|
32
|
+
textFormatter: __props.textFormatter
|
|
33
|
+
}, null, 8, ["get-renderer", "field-item", "textFormatter"]))
|
|
34
|
+
], 4)
|
|
35
|
+
]),
|
|
36
|
+
_: 1
|
|
37
|
+
}, 16, ["style"]);
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
var FormConfigDragDisplay = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "FormConfigDragDisplay.vue"]]);
|
|
42
|
+
|
|
43
|
+
export { FormConfigDragDisplay as default };
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { Func } from '../../../../../es/src/types';
|
|
2
|
+
import { PropType } from 'vue';
|
|
3
|
+
import { FormConfigItem, FormConfigTextFormatter } from '../../../../../es/packages/form-config';
|
|
4
|
+
declare const _default: import("vue").DefineComponent<{
|
|
5
|
+
fieldItem: {
|
|
6
|
+
type: PropType<FormConfigItem>;
|
|
7
|
+
};
|
|
8
|
+
getRenderer: {
|
|
9
|
+
type: Func<any[], any>;
|
|
10
|
+
require: boolean;
|
|
11
|
+
};
|
|
12
|
+
textFormatter: {
|
|
13
|
+
type: PropType<FormConfigTextFormatter>;
|
|
14
|
+
required: true;
|
|
15
|
+
};
|
|
16
|
+
}, {
|
|
17
|
+
getItemColumnStyle: (fieldItem?: FormConfigItem) => {
|
|
18
|
+
'--item-column': number;
|
|
19
|
+
};
|
|
20
|
+
commonConfig: {
|
|
21
|
+
onMove: ({ to, from }: import("sortablejs").SortableEvent) => void;
|
|
22
|
+
onChoose: ({ target, item }: import("sortablejs").SortableEvent) => void;
|
|
23
|
+
onUnchoose: ({ from, to, target, item }: import("sortablejs").SortableEvent) => void;
|
|
24
|
+
tag: string;
|
|
25
|
+
animation: string;
|
|
26
|
+
'item-key': string;
|
|
27
|
+
};
|
|
28
|
+
Draggable: import("vue").DefineComponent<{
|
|
29
|
+
list: {
|
|
30
|
+
type: ArrayConstructor;
|
|
31
|
+
required: boolean;
|
|
32
|
+
default: any;
|
|
33
|
+
};
|
|
34
|
+
modelValue: {
|
|
35
|
+
type: ArrayConstructor;
|
|
36
|
+
required: boolean;
|
|
37
|
+
default: any;
|
|
38
|
+
};
|
|
39
|
+
itemKey: {
|
|
40
|
+
type: (StringConstructor | FunctionConstructor)[];
|
|
41
|
+
required: boolean;
|
|
42
|
+
};
|
|
43
|
+
clone: {
|
|
44
|
+
type: FunctionConstructor;
|
|
45
|
+
default: (original: any) => any;
|
|
46
|
+
};
|
|
47
|
+
tag: {
|
|
48
|
+
type: StringConstructor;
|
|
49
|
+
default: string;
|
|
50
|
+
};
|
|
51
|
+
move: {
|
|
52
|
+
type: FunctionConstructor;
|
|
53
|
+
default: any;
|
|
54
|
+
};
|
|
55
|
+
componentData: {
|
|
56
|
+
type: ObjectConstructor;
|
|
57
|
+
required: boolean;
|
|
58
|
+
default: any;
|
|
59
|
+
};
|
|
60
|
+
}, unknown, {
|
|
61
|
+
error: boolean;
|
|
62
|
+
}, {
|
|
63
|
+
realList(): any;
|
|
64
|
+
getKey(): any;
|
|
65
|
+
}, {
|
|
66
|
+
getUnderlyingVm(domElement: any): any;
|
|
67
|
+
getUnderlyingPotencialDraggableComponent(htmElement: any): any;
|
|
68
|
+
emitChanges(evt: any): void;
|
|
69
|
+
alterList(onList: any): void;
|
|
70
|
+
spliceList(): void;
|
|
71
|
+
updatePosition(oldIndex: any, newIndex: any): void;
|
|
72
|
+
getRelatedContextFromMoveEvent({ to, related }: {
|
|
73
|
+
to: any;
|
|
74
|
+
related: any;
|
|
75
|
+
}): any;
|
|
76
|
+
getVmIndexFromDomIndex(domIndex: any): any;
|
|
77
|
+
onDragStart(evt: any): void;
|
|
78
|
+
onDragAdd(evt: any): void;
|
|
79
|
+
onDragRemove(evt: any): void;
|
|
80
|
+
onDragUpdate(evt: any): void;
|
|
81
|
+
computeFutureIndex(relatedContext: any, evt: any): any;
|
|
82
|
+
onDragMove(evt: any, originalEvent: any): any;
|
|
83
|
+
onDragEnd(): void;
|
|
84
|
+
}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, any[], any, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<{
|
|
85
|
+
move: Function;
|
|
86
|
+
tag: string;
|
|
87
|
+
clone: Function;
|
|
88
|
+
list: unknown[];
|
|
89
|
+
modelValue: unknown[];
|
|
90
|
+
componentData: Record<string, any>;
|
|
91
|
+
} & {
|
|
92
|
+
itemKey?: string | Function | undefined;
|
|
93
|
+
}>, {
|
|
94
|
+
move: Function;
|
|
95
|
+
tag: string;
|
|
96
|
+
clone: Function;
|
|
97
|
+
list: unknown[];
|
|
98
|
+
modelValue: unknown[];
|
|
99
|
+
componentData: Record<string, any>;
|
|
100
|
+
}>;
|
|
101
|
+
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
102
|
+
fieldItem: {
|
|
103
|
+
type: PropType<FormConfigItem>;
|
|
104
|
+
};
|
|
105
|
+
getRenderer: {
|
|
106
|
+
type: Func<any[], any>;
|
|
107
|
+
require: boolean;
|
|
108
|
+
};
|
|
109
|
+
textFormatter: {
|
|
110
|
+
type: PropType<FormConfigTextFormatter>;
|
|
111
|
+
required: true;
|
|
112
|
+
};
|
|
113
|
+
}>>, {}>;
|
|
114
|
+
export default _default;
|
|
@@ -54,6 +54,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
54
54
|
return openBlock(), createElementBlock(Fragment, null, [
|
|
55
55
|
(openBlock(), createBlock(unref(CFormRender), {
|
|
56
56
|
key: key.value,
|
|
57
|
+
column: 12,
|
|
57
58
|
ref_key: "formRenderRef",
|
|
58
59
|
ref: formRenderRef,
|
|
59
60
|
size: "small",
|
|
@@ -1687,7 +1687,9 @@ declare const _default: import("vue").DefineComponent<{}, {
|
|
|
1687
1687
|
notes?: string | undefined;
|
|
1688
1688
|
desc?: string | undefined;
|
|
1689
1689
|
children?: any[] | undefined;
|
|
1690
|
+
__new?: boolean | undefined;
|
|
1690
1691
|
}[] | undefined;
|
|
1692
|
+
__new?: boolean | undefined;
|
|
1691
1693
|
}>;
|
|
1692
1694
|
generateFieldListByFieldItem: (fieldItem: FormConfigItem) => FieldItem[];
|
|
1693
1695
|
showModal: import("vue").Ref<boolean>;
|
|
@@ -59,4 +59,6 @@ export declare function isNullOptionConfig(): {
|
|
|
59
59
|
value: boolean;
|
|
60
60
|
};
|
|
61
61
|
};
|
|
62
|
+
export declare const InjectionFieldList: InjectionKey<Ref<FormConfigItem[]>>;
|
|
63
|
+
export declare const InjectionMaterialList: InjectionKey<Ref<FormConfigItem[]>>;
|
|
62
64
|
export declare const InjectionActiveFieldItem: InjectionKey<Ref<UndefinedAble<FormConfigItem>>>;
|
|
@@ -24,7 +24,8 @@ function widgetWidthOptionConfig() {
|
|
|
24
24
|
{ text: "1/3", value: "ONE_THREE" },
|
|
25
25
|
{ text: "3/4", value: "THREE_FOUR" },
|
|
26
26
|
{ text: "1/4", value: "ONE_FOUR" },
|
|
27
|
-
{ text: "1/6", value: "ONE_SIX" }
|
|
27
|
+
{ text: "1/6", value: "ONE_SIX" },
|
|
28
|
+
{ text: "1/8", value: "ONE_EIGHT" }
|
|
28
29
|
]
|
|
29
30
|
};
|
|
30
31
|
}
|
|
@@ -52,6 +53,8 @@ function isNullOptionConfig() {
|
|
|
52
53
|
close: { describe: "\u4E0D\u5FC5\u586B", value: false }
|
|
53
54
|
};
|
|
54
55
|
}
|
|
56
|
+
const InjectionFieldList = Symbol("InjectionFieldList");
|
|
57
|
+
const InjectionMaterialList = Symbol("InjectionMaterialList");
|
|
55
58
|
const InjectionActiveFieldItem = Symbol("InjectionActiveFieldItem");
|
|
56
59
|
|
|
57
|
-
export { EditAbleField, InjectionActiveFieldItem, WidgetTextMap, isEditOptionConfig, isNotFoldOptionConfig, isNullOptionConfig, isShowOptionConfig, widgetWidthOptionConfig };
|
|
60
|
+
export { EditAbleField, InjectionActiveFieldItem, InjectionFieldList, InjectionMaterialList, WidgetTextMap, isEditOptionConfig, isNotFoldOptionConfig, isNullOptionConfig, isShowOptionConfig, widgetWidthOptionConfig };
|
|
@@ -2,24 +2,24 @@ import { EditAbleField, widgetWidthOptionConfig, isShowOptionConfig, isNotFoldOp
|
|
|
2
2
|
|
|
3
3
|
function useConfigurationField() {
|
|
4
4
|
const fieldMap = /* @__PURE__ */ new Map([
|
|
5
|
-
[EditAbleField.NAME, { alias: "\u540D\u79F0", elem_width:
|
|
6
|
-
[EditAbleField.NOTES, { alias: "\u95EE\u53F7\u63D0\u793A", elem_width:
|
|
5
|
+
[EditAbleField.NAME, { alias: "\u540D\u79F0", elem_width: 6, is_null: "0", html_type: "INPUT" }],
|
|
6
|
+
[EditAbleField.NOTES, { alias: "\u95EE\u53F7\u63D0\u793A", elem_width: 6, html_type: "INPUT" }],
|
|
7
7
|
[
|
|
8
8
|
EditAbleField.DEFAULT_VALUE,
|
|
9
|
-
{ alias: "\u9ED8\u8BA4\u503C", elem_width:
|
|
9
|
+
{ alias: "\u9ED8\u8BA4\u503C", elem_width: 6, html_type: "INPUT", validate: { max_length: 20 } }
|
|
10
10
|
],
|
|
11
11
|
[
|
|
12
12
|
EditAbleField.LAYOUT_WIDTH_ENUM,
|
|
13
|
-
{ alias: "\u5BBD\u5EA6", fieldType: "number", html_type: "SELECT", elem_width:
|
|
13
|
+
{ alias: "\u5BBD\u5EA6", fieldType: "number", html_type: "SELECT", elem_width: 6, ...widgetWidthOptionConfig() }
|
|
14
14
|
],
|
|
15
|
-
[EditAbleField.DESC, { alias: "\u8BF4\u660E\u6587\u672C", elem_width:
|
|
15
|
+
[EditAbleField.DESC, { alias: "\u8BF4\u660E\u6587\u672C", elem_width: 6, html_type: "INPUT", validate: { max_length: 30 } }],
|
|
16
16
|
[
|
|
17
17
|
EditAbleField.DEFAULT_EXPAND,
|
|
18
|
-
{ alias: "\u662F\u5426\u9ED8\u8BA4\u5C55\u5F00", html_type: "SWITCH", elem_width:
|
|
18
|
+
{ alias: "\u662F\u5426\u9ED8\u8BA4\u5C55\u5F00", html_type: "SWITCH", elem_width: 6, ...isShowOptionConfig() }
|
|
19
19
|
],
|
|
20
|
-
[EditAbleField.FOLD, { alias: "\u662F\u5426\u53EF\u6298\u53E0", html_type: "SWITCH", elem_width:
|
|
21
|
-
[EditAbleField.EDITABLE, { alias: "\u662F\u5426\u53EF\u7F16\u8F91", html_type: "SWITCH", elem_width:
|
|
22
|
-
[EditAbleField.REQUIRED, { alias: "\u662F\u5426\u5FC5\u586B", html_type: "SWITCH", elem_width:
|
|
20
|
+
[EditAbleField.FOLD, { alias: "\u662F\u5426\u53EF\u6298\u53E0", html_type: "SWITCH", elem_width: 6, ...isNotFoldOptionConfig() }],
|
|
21
|
+
[EditAbleField.EDITABLE, { alias: "\u662F\u5426\u53EF\u7F16\u8F91", html_type: "SWITCH", elem_width: 6, ...isEditOptionConfig() }],
|
|
22
|
+
[EditAbleField.REQUIRED, { alias: "\u662F\u5426\u5FC5\u586B", html_type: "SWITCH", elem_width: 6, ...isNullOptionConfig() }]
|
|
23
23
|
]);
|
|
24
24
|
function generateFieldListByKeys(keyList) {
|
|
25
25
|
return keyList.map((key) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FormConfigItem
|
|
2
|
-
export declare function usePresetRenderer(
|
|
1
|
+
import { FormConfigItem } from '../types';
|
|
2
|
+
export declare function usePresetRenderer(): {
|
|
3
3
|
getRenderer: (fieldItem: FormConfigItem) => import("vue").Component<any, any, any, import("vue").ComputedOptions, import("vue").MethodOptions> | import("vue").FunctionalComponent<{}, {}>;
|
|
4
4
|
};
|
|
@@ -1,94 +1,16 @@
|
|
|
1
|
-
import { defineComponent, computed, createVNode, mergeProps, inject } from 'vue';
|
|
2
1
|
import { isString, isArray, isFunction } from 'lodash-es';
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import { layoutWidthEnum2Column } from '../../../../packages/form-config/src/utils';
|
|
7
|
-
import { NEllipsis } from 'naive-ui';
|
|
2
|
+
import { computed } from 'vue';
|
|
3
|
+
import DefaultNode from '../components/DefaultNode.js';
|
|
4
|
+
import ComplexNode from '../components/ComplexNode.js';
|
|
8
5
|
|
|
9
|
-
function usePresetRenderer(
|
|
6
|
+
function usePresetRenderer() {
|
|
10
7
|
const renderDefaultNode = {
|
|
11
8
|
matcher: () => true,
|
|
12
|
-
renderer
|
|
13
|
-
fieldItem
|
|
14
|
-
}) {
|
|
15
|
-
const currentActiveEditField = inject(InjectionActiveFieldItem);
|
|
16
|
-
return createVNode("section", {
|
|
17
|
-
"onClick": () => currentActiveEditField.value = fieldItem,
|
|
18
|
-
"class": {
|
|
19
|
-
"is-active": currentActiveEditField.value === fieldItem
|
|
20
|
-
}
|
|
21
|
-
}, [createVNode(NEllipsis, {
|
|
22
|
-
"class": ["form-config__renderer--default", {
|
|
23
|
-
"is-required": fieldItem.required,
|
|
24
|
-
"is-disabled": fieldItem.editable === false
|
|
25
|
-
}]
|
|
26
|
-
}, {
|
|
27
|
-
default: () => getDisplayText()
|
|
28
|
-
})]);
|
|
29
|
-
function getDisplayText() {
|
|
30
|
-
const type = WidgetTextMap.get(fieldItem.type);
|
|
31
|
-
return textFormatter(fieldItem, `${fieldItem.name}${type ? `(${type})` : ""}`);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
9
|
+
renderer: DefaultNode
|
|
34
10
|
};
|
|
35
11
|
const renderComplexNode = {
|
|
36
12
|
matcher: ["COMPLEX", "COMBINATION"],
|
|
37
|
-
renderer:
|
|
38
|
-
props: {
|
|
39
|
-
fieldItem: {
|
|
40
|
-
type: Object,
|
|
41
|
-
required: true
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
setup(props) {
|
|
45
|
-
function fieldFor(key) {
|
|
46
|
-
return props.fieldItem[key];
|
|
47
|
-
}
|
|
48
|
-
const classList = computed(() => {
|
|
49
|
-
return "form-config__renderer--complex form-config__renderer--complex--grid";
|
|
50
|
-
});
|
|
51
|
-
const style = computed(() => {
|
|
52
|
-
return {
|
|
53
|
-
"--item-column": layoutWidthEnum2Column(fieldFor("layoutWidthEnum"))
|
|
54
|
-
};
|
|
55
|
-
});
|
|
56
|
-
function renderField(fieldItem) {
|
|
57
|
-
const Renderer = getRenderer(fieldItem);
|
|
58
|
-
return createVNode("div", {
|
|
59
|
-
"class": "form-config__displayContentItem",
|
|
60
|
-
"style": {
|
|
61
|
-
"--item-column": layoutWidthEnum2Column(fieldItem.layoutWidthEnum)
|
|
62
|
-
}
|
|
63
|
-
}, [createVNode(Renderer, {
|
|
64
|
-
"fieldItem": fieldItem
|
|
65
|
-
}, null)]);
|
|
66
|
-
}
|
|
67
|
-
const childrenList = computed({
|
|
68
|
-
get() {
|
|
69
|
-
return fieldFor("children");
|
|
70
|
-
},
|
|
71
|
-
set(v) {
|
|
72
|
-
props.fieldItem.children = v;
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
const {
|
|
76
|
-
commonConfig
|
|
77
|
-
} = useSortable();
|
|
78
|
-
const DraggableComponent = Draggable;
|
|
79
|
-
return () => createVNode(DraggableComponent, mergeProps(commonConfig, {
|
|
80
|
-
"class": classList.value,
|
|
81
|
-
"style": style.value,
|
|
82
|
-
"group": fieldFor("key"),
|
|
83
|
-
"modelValue": childrenList.value,
|
|
84
|
-
"onUpdate:modelValue": ($event) => childrenList.value = $event
|
|
85
|
-
}), {
|
|
86
|
-
item: ({
|
|
87
|
-
element
|
|
88
|
-
}) => renderField(element)
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
})
|
|
13
|
+
renderer: ComplexNode
|
|
92
14
|
};
|
|
93
15
|
const rendererWithPreset = computed(() => {
|
|
94
16
|
return [renderComplexNode, renderDefaultNode];
|
|
@@ -15,13 +15,9 @@ function useSortable() {
|
|
|
15
15
|
}
|
|
16
16
|
let prevTo;
|
|
17
17
|
function onMove({ to, from }) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
} else {
|
|
22
|
-
from.classList.remove("is-choosing-area");
|
|
23
|
-
prevTo = to;
|
|
24
|
-
}
|
|
18
|
+
prevTo == null ? void 0 : prevTo.classList.remove("is-choosing-area");
|
|
19
|
+
prevTo = to;
|
|
20
|
+
from.classList.remove("is-choosing-area");
|
|
25
21
|
to.classList.add("is-choosing-area");
|
|
26
22
|
}
|
|
27
23
|
const commonConfig = { onMove, onChoose, onUnchoose, tag: "section", animation: "150", "item-key": "key" };
|
|
@@ -8,7 +8,7 @@ export declare type FormConfigRenderer = {
|
|
|
8
8
|
renderer: Component | FunctionalComponent;
|
|
9
9
|
};
|
|
10
10
|
export declare type FormConfigType = 'NEWLINE' | 'LINE_BAR' | 'OTHER' | string;
|
|
11
|
-
export declare type FormConfigWidth = 'ALL_LINE' | 'HALF_LINE' | 'FIVE_SIX' | 'TWO_THREE' | 'ONE_THREE' | 'THREE_FOUR' | 'ONE_FOUR' | 'ONE_SIX';
|
|
11
|
+
export declare type FormConfigWidth = 'ALL_LINE' | 'HALF_LINE' | 'FIVE_SIX' | 'TWO_THREE' | 'ONE_THREE' | 'THREE_FOUR' | 'ONE_FOUR' | 'ONE_SIX' | 'ONE_EIGHT';
|
|
12
12
|
export declare type FormConfigItem = {
|
|
13
13
|
key: string;
|
|
14
14
|
layoutWidthEnum: FormConfigWidth;
|
|
@@ -24,6 +24,7 @@ export declare type FormConfigItem = {
|
|
|
24
24
|
notes: string;
|
|
25
25
|
desc: string;
|
|
26
26
|
children: FormConfigItem[];
|
|
27
|
+
__new: boolean;
|
|
27
28
|
}>;
|
|
28
29
|
export interface FormConfigTextFormatter {
|
|
29
30
|
(fieldItem: FormConfigItem, parsedText: string): string;
|
|
@@ -1,2 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Func } from '../../../../../es/src/types';
|
|
2
|
+
import { FormConfigItem, FormConfigWidth } from '../../../../../es/packages/form-config';
|
|
2
3
|
export declare function layoutWidthEnum2Column(layoutWidthEnum: FormConfigWidth): number;
|
|
4
|
+
export declare function stopModifier(fn: Func): (event: Event, ...args: unknown[]) => any;
|
|
5
|
+
export declare function bindHover(fieldItem: FormConfigItem): {
|
|
6
|
+
onMouseenter: () => FormConfigItem;
|
|
7
|
+
onMouseleave: () => undefined;
|
|
8
|
+
'is-hovering': boolean;
|
|
9
|
+
};
|
|
@@ -1,15 +1,29 @@
|
|
|
1
|
+
import { ref, withModifiers } from 'vue';
|
|
2
|
+
|
|
1
3
|
function layoutWidthEnum2Column(layoutWidthEnum) {
|
|
2
4
|
const transferMap = {
|
|
3
|
-
ALL_LINE:
|
|
4
|
-
HALF_LINE:
|
|
5
|
-
FIVE_SIX:
|
|
6
|
-
TWO_THREE:
|
|
7
|
-
ONE_THREE:
|
|
8
|
-
THREE_FOUR:
|
|
9
|
-
ONE_FOUR:
|
|
10
|
-
ONE_SIX:
|
|
5
|
+
ALL_LINE: 24,
|
|
6
|
+
HALF_LINE: 12,
|
|
7
|
+
FIVE_SIX: 20,
|
|
8
|
+
TWO_THREE: 16,
|
|
9
|
+
ONE_THREE: 8,
|
|
10
|
+
THREE_FOUR: 18,
|
|
11
|
+
ONE_FOUR: 6,
|
|
12
|
+
ONE_SIX: 4,
|
|
13
|
+
ONE_EIGHT: 3
|
|
11
14
|
};
|
|
12
15
|
return transferMap[layoutWidthEnum] || 12;
|
|
13
16
|
}
|
|
17
|
+
function stopModifier(fn) {
|
|
18
|
+
return withModifiers(fn, ["stop"]);
|
|
19
|
+
}
|
|
20
|
+
const hovering = ref();
|
|
21
|
+
function bindHover(fieldItem) {
|
|
22
|
+
return {
|
|
23
|
+
onMouseenter: () => hovering.value = fieldItem,
|
|
24
|
+
onMouseleave: () => hovering.value = void 0,
|
|
25
|
+
"is-hovering": hovering.value === fieldItem
|
|
26
|
+
};
|
|
27
|
+
}
|
|
14
28
|
|
|
15
|
-
export { layoutWidthEnum2Column };
|
|
29
|
+
export { bindHover, layoutWidthEnum2Column, stopModifier };
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
display: flex;
|
|
31
31
|
align-items: center;
|
|
32
32
|
padding: 8px;
|
|
33
|
+
cursor: move;
|
|
33
34
|
border: 1px dashed #d9d9d9;
|
|
34
35
|
box-sizing: border-box;
|
|
35
36
|
background-color: #fafafa;
|
|
@@ -58,8 +59,8 @@
|
|
|
58
59
|
height: fit-content;
|
|
59
60
|
background: #eeeeee;
|
|
60
61
|
display: grid !important;
|
|
61
|
-
grid-template-columns: repeat(
|
|
62
|
-
gap: 8px
|
|
62
|
+
grid-template-columns: repeat(24, minmax(0px, 1fr));
|
|
63
|
+
gap: 8px;
|
|
63
64
|
}
|
|
64
65
|
.form-config__displayContentItem {
|
|
65
66
|
grid-column: span var(--item-column) / span var(--item-column);
|
|
@@ -85,6 +86,9 @@
|
|
|
85
86
|
overflow-y: auto;
|
|
86
87
|
max-height: var(--max-height);
|
|
87
88
|
}
|
|
89
|
+
.form-config__renderer {
|
|
90
|
+
cursor: move;
|
|
91
|
+
}
|
|
88
92
|
.form-config__renderer--default {
|
|
89
93
|
display: flex;
|
|
90
94
|
align-items: center;
|
|
@@ -97,13 +101,21 @@
|
|
|
97
101
|
width: 100%;
|
|
98
102
|
}
|
|
99
103
|
.form-config__renderer--complex {
|
|
100
|
-
border: 1px dashed
|
|
104
|
+
border: 1px dashed skyblue;
|
|
105
|
+
border-radius: 8px;
|
|
106
|
+
padding: 8px;
|
|
107
|
+
}
|
|
108
|
+
.form-config__renderer--complexHeader {
|
|
109
|
+
display: flex;
|
|
110
|
+
justify-content: center;
|
|
101
111
|
padding: 8px;
|
|
112
|
+
margin-top: -8px;
|
|
113
|
+
position: relative;
|
|
102
114
|
}
|
|
103
115
|
.form-config__renderer--complex--grid {
|
|
104
116
|
display: grid !important;
|
|
105
|
-
grid-template-columns: repeat(
|
|
106
|
-
gap: 8px
|
|
117
|
+
grid-template-columns: repeat(24, minmax(0px, 1fr));
|
|
118
|
+
gap: 8px;
|
|
107
119
|
grid-column: span var(--item-column) / span var(--item-column);
|
|
108
120
|
}
|
|
109
121
|
.form-config__renderer--complex--flex {
|
|
@@ -130,3 +142,12 @@
|
|
|
130
142
|
.form-config .is-choosing-area {
|
|
131
143
|
background: #f0f7ff;
|
|
132
144
|
}
|
|
145
|
+
.form-config [is-hovering='true'] > .form-config__renderer--closeButton {
|
|
146
|
+
visibility: visible;
|
|
147
|
+
}
|
|
148
|
+
.form-config .form-config__renderer--closeButton {
|
|
149
|
+
position: absolute;
|
|
150
|
+
visibility: hidden;
|
|
151
|
+
top: 12px;
|
|
152
|
+
right: 5px;
|
|
153
|
+
}
|
|
@@ -7,7 +7,7 @@ export { useCommonLog } from './src/hooks/useCommonLog.js';
|
|
|
7
7
|
export { useFormField } from './src/hooks/useFormField.js';
|
|
8
8
|
export { AsyncQueue, useAsyncQueue } from './src/hooks/useAsyncQueue.js';
|
|
9
9
|
export { useFieldVisitor } from './src/hooks/useFieldVisitor.js';
|
|
10
|
-
export {
|
|
10
|
+
export { useFieldNormalize } from './src/hooks/useFieldNormalize.js';
|
|
11
11
|
export { useFormValidator } from './src/hooks/useFormValidator.js';
|
|
12
12
|
export { BusinessCollector, useBusinessBinding } from './src/hooks/useBusinessBinding.js';
|
|
13
13
|
export { ContextCollector, useChangeContext } from './src/hooks/useChangeContext.js';
|
|
@@ -4,7 +4,7 @@ export * from './useCommonLog';
|
|
|
4
4
|
export * from './useFormField';
|
|
5
5
|
export * from './useAsyncQueue';
|
|
6
6
|
export * from './useFieldVisitor';
|
|
7
|
-
export * from './
|
|
7
|
+
export * from './useFieldNormalize';
|
|
8
8
|
export * from './useFormValidator';
|
|
9
9
|
export * from './useBusinessBinding';
|
|
10
10
|
export * from './useChangeContext';
|
|
@@ -4,7 +4,7 @@ export { useCommonLog } from './useCommonLog.js';
|
|
|
4
4
|
export { useFormField } from './useFormField.js';
|
|
5
5
|
export { AsyncQueue, useAsyncQueue } from './useAsyncQueue.js';
|
|
6
6
|
export { useFieldVisitor } from './useFieldVisitor.js';
|
|
7
|
-
export {
|
|
7
|
+
export { useFieldNormalize } from './useFieldNormalize.js';
|
|
8
8
|
export { useFormValidator } from './useFormValidator.js';
|
|
9
9
|
export { BusinessCollector, useBusinessBinding } from './useBusinessBinding.js';
|
|
10
10
|
export { ContextCollector, useChangeContext } from './useChangeContext.js';
|
|
@@ -12,12 +12,11 @@ export declare class BusinessCollector {
|
|
|
12
12
|
private getField;
|
|
13
13
|
private getType;
|
|
14
14
|
private getValueByField;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
private
|
|
20
|
-
private handlerChangeMap;
|
|
15
|
+
getValueByType(type: FIELD_BUSINESS_TYPE): unknown;
|
|
16
|
+
setValueByType(type: FIELD_BUSINESS_TYPE, value: unknown, force?: boolean): void;
|
|
17
|
+
registerChangeBusiness(type: FIELD_BUSINESS_TYPE, handler: () => void): this;
|
|
18
|
+
registerBlurBusiness(type: FIELD_BUSINESS_TYPE, handler: () => void): this;
|
|
19
|
+
private changeHandlerMap;
|
|
21
20
|
private blurHandlerMap;
|
|
22
21
|
trigger(fieldName: string, triggerType?: 'change' | 'blur'): void;
|
|
23
22
|
}
|
|
@@ -10,14 +10,8 @@ class BusinessCollector {
|
|
|
10
10
|
this.businessFormatter = businessFormatter;
|
|
11
11
|
this.typeCollector = /* @__PURE__ */ new Map();
|
|
12
12
|
this.fieldNameCollector = /* @__PURE__ */ new Map();
|
|
13
|
-
this.
|
|
14
|
-
|
|
15
|
-
[FIELD_BUSINESS_TYPE.AGE_UNIT, this.handlerAgeType.bind(this)]
|
|
16
|
-
]);
|
|
17
|
-
this.blurHandlerMap = /* @__PURE__ */ new Map([
|
|
18
|
-
[FIELD_BUSINESS_TYPE.BIRTHDAY, this.handlerBirthdayType.bind(this)],
|
|
19
|
-
[FIELD_BUSINESS_TYPE.AGE, this.handlerAgeType.bind(this)]
|
|
20
|
-
]);
|
|
13
|
+
this.changeHandlerMap = /* @__PURE__ */ new Map([]);
|
|
14
|
+
this.blurHandlerMap = /* @__PURE__ */ new Map([]);
|
|
21
15
|
}
|
|
22
16
|
formatter(...args) {
|
|
23
17
|
return isFunction(this.businessFormatter) ? this.businessFormatter(...args) : args[0].value;
|
|
@@ -48,7 +42,23 @@ class BusinessCollector {
|
|
|
48
42
|
state.value = this.formatter({ value, type, fieldKey: field });
|
|
49
43
|
});
|
|
50
44
|
}
|
|
51
|
-
|
|
45
|
+
registerChangeBusiness(type, handler) {
|
|
46
|
+
this.changeHandlerMap.set(type, handler);
|
|
47
|
+
return this;
|
|
48
|
+
}
|
|
49
|
+
registerBlurBusiness(type, handler) {
|
|
50
|
+
this.blurHandlerMap.set(type, handler);
|
|
51
|
+
return this;
|
|
52
|
+
}
|
|
53
|
+
trigger(fieldName, triggerType = "change") {
|
|
54
|
+
var _a, _b;
|
|
55
|
+
const type = this.getType(fieldName);
|
|
56
|
+
const handlerMaps = { change: this.changeHandlerMap, blur: this.blurHandlerMap };
|
|
57
|
+
type && ((_b = (_a = handlerMaps[triggerType]) == null ? void 0 : _a.get(type)) == null ? void 0 : _b.call(this));
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function useBusinessBinding() {
|
|
61
|
+
function handlerIdCardType() {
|
|
52
62
|
const idCard = this.getValueByType(FIELD_BUSINESS_TYPE.ID_CARD);
|
|
53
63
|
if (!idCard || !isString(idCard) || !isIdCard(idCard))
|
|
54
64
|
return;
|
|
@@ -59,7 +69,7 @@ class BusinessCollector {
|
|
|
59
69
|
this.setValueByType(FIELD_BUSINESS_TYPE.SEX, info.sex);
|
|
60
70
|
this.setValueByType(FIELD_BUSINESS_TYPE.BIRTHDAY, info.birthday);
|
|
61
71
|
}
|
|
62
|
-
handlerBirthdayType() {
|
|
72
|
+
function handlerBirthdayType() {
|
|
63
73
|
const birthday = this.getValueByType(FIELD_BUSINESS_TYPE.BIRTHDAY);
|
|
64
74
|
if (!isString(birthday))
|
|
65
75
|
return;
|
|
@@ -67,7 +77,7 @@ class BusinessCollector {
|
|
|
67
77
|
this.setValueByType(FIELD_BUSINESS_TYPE.AGE_UNIT, ageUnit);
|
|
68
78
|
this.setValueByType(FIELD_BUSINESS_TYPE.AGE, age);
|
|
69
79
|
}
|
|
70
|
-
handlerAgeType() {
|
|
80
|
+
function handlerAgeType() {
|
|
71
81
|
const age = this.getValueByType(FIELD_BUSINESS_TYPE.AGE);
|
|
72
82
|
const ageUnit = this.getValueByType(FIELD_BUSINESS_TYPE.AGE_UNIT);
|
|
73
83
|
if (!isString(age) && !isNumber(age) || age === "")
|
|
@@ -76,16 +86,8 @@ class BusinessCollector {
|
|
|
76
86
|
return;
|
|
77
87
|
this.setValueByType(FIELD_BUSINESS_TYPE.BIRTHDAY, parseAge2Birthday(+age, ageUnit), false);
|
|
78
88
|
}
|
|
79
|
-
trigger(fieldName, triggerType = "change") {
|
|
80
|
-
var _a;
|
|
81
|
-
const type = this.getType(fieldName);
|
|
82
|
-
const handler = triggerType === "change" ? this.handlerChangeMap : triggerType === "blur" ? this.blurHandlerMap : null;
|
|
83
|
-
type && ((_a = handler == null ? void 0 : handler.get(type)) == null ? void 0 : _a());
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
function useBusinessBinding() {
|
|
87
89
|
function create(formModel, formatter) {
|
|
88
|
-
return new BusinessCollector(formModel, formatter);
|
|
90
|
+
return new BusinessCollector(formModel, formatter).registerChangeBusiness(FIELD_BUSINESS_TYPE.ID_CARD, handlerIdCardType).registerChangeBusiness(FIELD_BUSINESS_TYPE.AGE_UNIT, handlerAgeType).registerBlurBusiness(FIELD_BUSINESS_TYPE.BIRTHDAY, handlerBirthdayType).registerBlurBusiness(FIELD_BUSINESS_TYPE.AGE, handlerAgeType);
|
|
89
91
|
}
|
|
90
92
|
return { create };
|
|
91
93
|
}
|