@antdv-next1/pro-field 1.0.0
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/LICENSE +21 -0
- package/dist/FieldHOC/index.d.ts +16 -0
- package/dist/FieldHOC/index.js +51 -0
- package/dist/ProField.d.ts +18 -0
- package/dist/ProField.js +417 -0
- package/dist/ProPureField.d.ts +10 -0
- package/dist/ProPureField.js +222 -0
- package/dist/ValueTypeToComponent.d.ts +6 -0
- package/dist/ValueTypeToComponent.js +442 -0
- package/dist/components/Cascader/index.d.ts +40 -0
- package/dist/components/Cascader/index.js +202 -0
- package/dist/components/Checkbox/index.d.ts +37 -0
- package/dist/components/Checkbox/index.js +149 -0
- package/dist/components/Checkbox/style/index.d.ts +11 -0
- package/dist/components/Checkbox/style/index.js +26 -0
- package/dist/components/Code/index.d.ts +34 -0
- package/dist/components/Code/index.js +125 -0
- package/dist/components/ColorPicker/index.d.ts +22 -0
- package/dist/components/ColorPicker/index.js +278 -0
- package/dist/components/DatePicker/index.d.ts +27 -0
- package/dist/components/DatePicker/index.js +171 -0
- package/dist/components/Digit/index.d.ts +27 -0
- package/dist/components/Digit/index.js +159 -0
- package/dist/components/DigitRange/index.d.ts +48 -0
- package/dist/components/DigitRange/index.js +197 -0
- package/dist/components/FromNow/index.d.ts +23 -0
- package/dist/components/FromNow/index.js +123 -0
- package/dist/components/Image/index.d.ts +23 -0
- package/dist/components/Image/index.js +119 -0
- package/dist/components/IndexColumn/index.d.ts +13 -0
- package/dist/components/IndexColumn/index.js +30 -0
- package/dist/components/IndexColumn/style/index.d.ts +11 -0
- package/dist/components/IndexColumn/style/index.js +29 -0
- package/dist/components/Money/InputNumberPopover.d.ts +120 -0
- package/dist/components/Money/InputNumberPopover.js +345 -0
- package/dist/components/Money/index.d.ts +303 -0
- package/dist/components/Money/index.js +274 -0
- package/dist/components/Options/index.d.ts +18 -0
- package/dist/components/Options/index.js +120 -0
- package/dist/components/Password/index.d.ts +33 -0
- package/dist/components/Password/index.js +137 -0
- package/dist/components/Percent/index.d.ts +45 -0
- package/dist/components/Percent/index.js +171 -0
- package/dist/components/Percent/util.d.ts +10 -0
- package/dist/components/Percent/util.js +22 -0
- package/dist/components/Progress/index.d.ts +22 -0
- package/dist/components/Progress/index.js +124 -0
- package/dist/components/Radio/index.d.ts +36 -0
- package/dist/components/Radio/index.js +138 -0
- package/dist/components/Radio/style/index.d.ts +11 -0
- package/dist/components/Radio/style/index.js +21 -0
- package/dist/components/RangePicker/DatePicker.d.ts +29 -0
- package/dist/components/RangePicker/DatePicker.js +189 -0
- package/dist/components/RangePicker/TimePicker.d.ts +25 -0
- package/dist/components/RangePicker/TimePicker.js +177 -0
- package/dist/components/RangePicker/index.d.ts +3 -0
- package/dist/components/RangePicker/index.js +3 -0
- package/dist/components/Rate/index.d.ts +19 -0
- package/dist/components/Rate/index.js +98 -0
- package/dist/components/Second/index.d.ts +28 -0
- package/dist/components/Second/index.js +151 -0
- package/dist/components/Segmented/index.d.ts +36 -0
- package/dist/components/Segmented/index.js +138 -0
- package/dist/components/Select/Highlight/index.d.ts +14 -0
- package/dist/components/Select/Highlight/index.js +46 -0
- package/dist/components/Select/Highlight/style/index.d.ts +12 -0
- package/dist/components/Select/Highlight/style/index.js +24 -0
- package/dist/components/Select/LightSelect/index.d.ts +45 -0
- package/dist/components/Select/LightSelect/index.js +621 -0
- package/dist/components/Select/LightSelect/style/index.d.ts +11 -0
- package/dist/components/Select/LightSelect/style/index.js +28 -0
- package/dist/components/Select/SearchSelect/index.d.ts +78 -0
- package/dist/components/Select/SearchSelect/index.js +273 -0
- package/dist/components/Select/index.d.ts +67 -0
- package/dist/components/Select/index.js +357 -0
- package/dist/components/Slider/index.d.ts +18 -0
- package/dist/components/Slider/index.js +99 -0
- package/dist/components/Status/index.d.ts +31 -0
- package/dist/components/Status/index.js +71 -0
- package/dist/components/Switch/index.d.ts +31 -0
- package/dist/components/Switch/index.js +132 -0
- package/dist/components/Text/index.d.ts +37 -0
- package/dist/components/Text/index.js +146 -0
- package/dist/components/TextArea/index.d.ts +25 -0
- package/dist/components/TextArea/index.js +117 -0
- package/dist/components/TextArea/readonly/index.d.ts +17 -0
- package/dist/components/TextArea/readonly/index.js +20 -0
- package/dist/components/TextArea/readonly/style/index.d.ts +11 -0
- package/dist/components/TextArea/readonly/style/index.js +20 -0
- package/dist/components/TimePicker/index.d.ts +23 -0
- package/dist/components/TimePicker/index.js +153 -0
- package/dist/components/TreeSelect/index.d.ts +45 -0
- package/dist/components/TreeSelect/index.js +762 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.js +33 -0
- package/dist/pro-field.esm.js +72945 -0
- package/dist/pro-field.js +214 -0
- package/dist/typing.d.ts +28 -0
- package/dist/typing.js +1 -0
- package/dist/utils/useFieldExpose.d.ts +7 -0
- package/dist/utils/useFieldExpose.js +9 -0
- package/package.json +63 -0
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { getColorByRealValue, getRealTextWithPrecision, getSymbolByRealValue, toNumber } from "./util.js";
|
|
2
|
+
import { Fragment, createVNode, defineComponent, mergeProps } from "vue";
|
|
3
|
+
import { useIntl } from "@antdv-next1/pro-provider";
|
|
4
|
+
import { useMemo } from "@antdv-next1/pro-utils";
|
|
5
|
+
import { InputNumber } from "antdv-next";
|
|
6
|
+
//#region src/components/Percent/index.tsx
|
|
7
|
+
const FieldPercent = /* @__PURE__ */ defineComponent((props) => {
|
|
8
|
+
const intl = useIntl();
|
|
9
|
+
const realValue = useMemo(() => typeof props.text === "string" && props.text.includes("%") ? toNumber(props.text.replace("%", "")) : toNumber(props.text), [() => props.text]);
|
|
10
|
+
const showSymbol = useMemo(() => {
|
|
11
|
+
if (typeof props.showSymbol === "function") return props.showSymbol(props.text);
|
|
12
|
+
return props.showSymbol;
|
|
13
|
+
}, [() => props.showSymbol, () => props.text]);
|
|
14
|
+
return () => {
|
|
15
|
+
const { text, prefix, precision, suffix = "%", mode, showColor = false, render, formItemRender, fieldProps, placeholder: propsPlaceholder, ...rest } = props;
|
|
16
|
+
if (mode === "read") {
|
|
17
|
+
const dom = createVNode("span", { "style": showColor ? { color: getColorByRealValue(realValue.value) } : {} }, [
|
|
18
|
+
prefix && createVNode("span", null, [prefix]),
|
|
19
|
+
showSymbol.value && createVNode(Fragment, null, [getSymbolByRealValue(realValue.value), " "]),
|
|
20
|
+
getRealTextWithPrecision(Math.abs(realValue.value), precision),
|
|
21
|
+
suffix && suffix
|
|
22
|
+
]);
|
|
23
|
+
if (render) return createVNode(Fragment, null, [render(text, {
|
|
24
|
+
mode,
|
|
25
|
+
...rest,
|
|
26
|
+
fieldProps,
|
|
27
|
+
prefix,
|
|
28
|
+
precision,
|
|
29
|
+
showSymbol: showSymbol.value,
|
|
30
|
+
suffix
|
|
31
|
+
}, dom)]);
|
|
32
|
+
return dom;
|
|
33
|
+
}
|
|
34
|
+
if (mode === "edit" || mode === "update") {
|
|
35
|
+
const placeholder = propsPlaceholder || intl.value.getMessage({
|
|
36
|
+
id: "tableForm.inputPlaceholder",
|
|
37
|
+
defaultMessage: "请输入"
|
|
38
|
+
});
|
|
39
|
+
const dom = createVNode(InputNumber, mergeProps({
|
|
40
|
+
"defaultValue": text,
|
|
41
|
+
"formatter": (value) => {
|
|
42
|
+
if (value && prefix) return `${prefix} ${value}`.replace(/\B(?=(\d{3})+$)/g, ",");
|
|
43
|
+
return value;
|
|
44
|
+
},
|
|
45
|
+
"parser": (value) => value ? value.replace(/.*\s|,/g, "") : "",
|
|
46
|
+
"placeholder": placeholder
|
|
47
|
+
}, fieldProps), null);
|
|
48
|
+
if (formItemRender) return createVNode(Fragment, null, [formItemRender(text, {
|
|
49
|
+
mode,
|
|
50
|
+
...rest,
|
|
51
|
+
placeholder
|
|
52
|
+
}, dom)]);
|
|
53
|
+
return dom;
|
|
54
|
+
}
|
|
55
|
+
return null;
|
|
56
|
+
};
|
|
57
|
+
}, {
|
|
58
|
+
props: {
|
|
59
|
+
text: {
|
|
60
|
+
type: [
|
|
61
|
+
Object,
|
|
62
|
+
Function,
|
|
63
|
+
String,
|
|
64
|
+
Number,
|
|
65
|
+
null,
|
|
66
|
+
Boolean,
|
|
67
|
+
Array
|
|
68
|
+
],
|
|
69
|
+
required: false,
|
|
70
|
+
default: void 0
|
|
71
|
+
},
|
|
72
|
+
"onUpdate:text": {
|
|
73
|
+
type: Function,
|
|
74
|
+
required: false
|
|
75
|
+
},
|
|
76
|
+
fieldProps: {
|
|
77
|
+
type: Object,
|
|
78
|
+
required: false
|
|
79
|
+
},
|
|
80
|
+
mode: {
|
|
81
|
+
type: String,
|
|
82
|
+
required: false
|
|
83
|
+
},
|
|
84
|
+
light: {
|
|
85
|
+
type: Boolean,
|
|
86
|
+
required: false,
|
|
87
|
+
default: void 0
|
|
88
|
+
},
|
|
89
|
+
label: {
|
|
90
|
+
type: [
|
|
91
|
+
Object,
|
|
92
|
+
Function,
|
|
93
|
+
String,
|
|
94
|
+
Number,
|
|
95
|
+
null,
|
|
96
|
+
Boolean,
|
|
97
|
+
Array
|
|
98
|
+
],
|
|
99
|
+
required: false,
|
|
100
|
+
default: void 0
|
|
101
|
+
},
|
|
102
|
+
valueEnum: {
|
|
103
|
+
type: [Object, Map],
|
|
104
|
+
required: false
|
|
105
|
+
},
|
|
106
|
+
proFieldKey: {
|
|
107
|
+
type: [String, Number],
|
|
108
|
+
required: false
|
|
109
|
+
},
|
|
110
|
+
render: {
|
|
111
|
+
type: Function,
|
|
112
|
+
required: false
|
|
113
|
+
},
|
|
114
|
+
formItemRender: {
|
|
115
|
+
type: Function,
|
|
116
|
+
required: false
|
|
117
|
+
},
|
|
118
|
+
prefix: {
|
|
119
|
+
type: [
|
|
120
|
+
Object,
|
|
121
|
+
Function,
|
|
122
|
+
String,
|
|
123
|
+
Number,
|
|
124
|
+
null,
|
|
125
|
+
Boolean,
|
|
126
|
+
Array
|
|
127
|
+
],
|
|
128
|
+
required: false,
|
|
129
|
+
default: void 0
|
|
130
|
+
},
|
|
131
|
+
suffix: {
|
|
132
|
+
type: [
|
|
133
|
+
Object,
|
|
134
|
+
Function,
|
|
135
|
+
String,
|
|
136
|
+
Number,
|
|
137
|
+
null,
|
|
138
|
+
Boolean,
|
|
139
|
+
Array
|
|
140
|
+
],
|
|
141
|
+
required: false,
|
|
142
|
+
default: void 0
|
|
143
|
+
},
|
|
144
|
+
precision: {
|
|
145
|
+
type: Number,
|
|
146
|
+
required: false
|
|
147
|
+
},
|
|
148
|
+
showColor: {
|
|
149
|
+
type: Boolean,
|
|
150
|
+
required: false,
|
|
151
|
+
default: void 0
|
|
152
|
+
},
|
|
153
|
+
showSymbol: {
|
|
154
|
+
type: [Boolean, Function],
|
|
155
|
+
required: false,
|
|
156
|
+
default: void 0
|
|
157
|
+
},
|
|
158
|
+
placeholder: {
|
|
159
|
+
type: String,
|
|
160
|
+
required: false
|
|
161
|
+
},
|
|
162
|
+
id: {
|
|
163
|
+
type: String,
|
|
164
|
+
required: false
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
name: "FieldPercent",
|
|
168
|
+
inheritAttrs: false
|
|
169
|
+
});
|
|
170
|
+
//#endregion
|
|
171
|
+
export { FieldPercent as default };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/components/Percent/util.d.ts
|
|
2
|
+
/** 获取展示符号 */
|
|
3
|
+
declare function getSymbolByRealValue(realValue: number): "-" | "+" | null;
|
|
4
|
+
/** 获取颜色 */
|
|
5
|
+
declare function getColorByRealValue(realValue: number /** ,color: string */): "#595959" | "#ff4d4f" | "#52c41a";
|
|
6
|
+
/** 获取到最后展示的数字 */
|
|
7
|
+
declare function getRealTextWithPrecision(realValue: number, precision?: number): string | number;
|
|
8
|
+
declare function toNumber(value: any): number;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { getColorByRealValue, getRealTextWithPrecision, getSymbolByRealValue, toNumber };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//#region src/components/Percent/util.ts
|
|
2
|
+
/** 获取展示符号 */
|
|
3
|
+
function getSymbolByRealValue(realValue) {
|
|
4
|
+
if (realValue === 0) return null;
|
|
5
|
+
if (realValue > 0) return "+";
|
|
6
|
+
return "-";
|
|
7
|
+
}
|
|
8
|
+
/** 获取颜色 */
|
|
9
|
+
function getColorByRealValue(realValue) {
|
|
10
|
+
if (realValue === 0) return "#595959";
|
|
11
|
+
return realValue > 0 ? "#ff4d4f" : "#52c41a";
|
|
12
|
+
}
|
|
13
|
+
/** 获取到最后展示的数字 */
|
|
14
|
+
function getRealTextWithPrecision(realValue, precision = 2) {
|
|
15
|
+
return precision >= 0 ? realValue?.toFixed(precision) : realValue;
|
|
16
|
+
}
|
|
17
|
+
function toNumber(value) {
|
|
18
|
+
if (typeof value === "symbol" || typeof value === "symbol") return NaN;
|
|
19
|
+
return Number(value);
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
export { getColorByRealValue, getRealTextWithPrecision, getSymbolByRealValue, toNumber };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ProFieldFC } from "../../typing.js";
|
|
2
|
+
import * as _$vue from "vue";
|
|
3
|
+
import * as _$_antdv_next1_pro_provider0 from "@antdv-next1/pro-provider";
|
|
4
|
+
import { InputNumberProps, ProgressProps } from "antdv-next";
|
|
5
|
+
import { CustomSlotsType, VueNode } from "@v-c/util/dist/type";
|
|
6
|
+
|
|
7
|
+
//#region src/components/Progress/index.d.ts
|
|
8
|
+
declare function getProgressStatus(text: number): 'success' | 'exception' | 'normal' | 'active';
|
|
9
|
+
type FieldProgressProps = ProFieldFC<{
|
|
10
|
+
text: number | string;
|
|
11
|
+
placeholder?: string;
|
|
12
|
+
}, ProgressProps | InputNumberProps>;
|
|
13
|
+
declare const FieldProgress: _$vue.DefineSetupFnComponent<FieldProgressProps, {}, CustomSlotsType<{
|
|
14
|
+
default?: () => VueNode;
|
|
15
|
+
}>, _$_antdv_next1_pro_provider0.BaseProFieldFC<InputNumberProps | ProgressProps> & _$_antdv_next1_pro_provider0.ProRenderFieldPropsType<InputNumberProps | ProgressProps> & {
|
|
16
|
+
text: number | string;
|
|
17
|
+
placeholder?: string;
|
|
18
|
+
} & {
|
|
19
|
+
id?: string;
|
|
20
|
+
} & {}, _$vue.PublicProps>;
|
|
21
|
+
//#endregion
|
|
22
|
+
export { FieldProgressProps, FieldProgress as default, getProgressStatus };
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { toNumber } from "../Percent/util.js";
|
|
2
|
+
import { Fragment, createVNode, defineComponent, mergeProps } from "vue";
|
|
3
|
+
import { useIntl } from "@antdv-next1/pro-provider";
|
|
4
|
+
import { useMemo } from "@antdv-next1/pro-utils";
|
|
5
|
+
import { InputNumber, Progress } from "antdv-next";
|
|
6
|
+
//#region src/components/Progress/index.tsx
|
|
7
|
+
function getProgressStatus(text) {
|
|
8
|
+
if (text === 100) return "success";
|
|
9
|
+
if (text < 0) return "exception";
|
|
10
|
+
if (text < 100) return "active";
|
|
11
|
+
return "normal";
|
|
12
|
+
}
|
|
13
|
+
const FieldProgress = /* @__PURE__ */ defineComponent((props) => {
|
|
14
|
+
const intl = useIntl();
|
|
15
|
+
const realValue = useMemo(() => typeof props.text === "string" && props.text.includes("%") ? toNumber(props.text.replace("%", "")) : toNumber(props.text), [() => props.text]);
|
|
16
|
+
return () => {
|
|
17
|
+
const { text, mode, render, formItemRender, fieldProps, placeholder: propsPlaceholder } = props;
|
|
18
|
+
if (mode === "read") {
|
|
19
|
+
const dom = createVNode(Progress, mergeProps({
|
|
20
|
+
"size": "small",
|
|
21
|
+
"style": {
|
|
22
|
+
minWidth: `100px`,
|
|
23
|
+
maxWidth: `320px`
|
|
24
|
+
},
|
|
25
|
+
"percent": realValue.value,
|
|
26
|
+
"steps": fieldProps?.steps,
|
|
27
|
+
"status": getProgressStatus(realValue.value)
|
|
28
|
+
}, fieldProps), null);
|
|
29
|
+
if (render) return createVNode(Fragment, null, [render(realValue.value, {
|
|
30
|
+
mode,
|
|
31
|
+
fieldProps
|
|
32
|
+
}, dom)]);
|
|
33
|
+
return dom;
|
|
34
|
+
}
|
|
35
|
+
if (mode === "edit" || mode === "update") {
|
|
36
|
+
const placeholder = propsPlaceholder || intl.value.getMessage({
|
|
37
|
+
id: "tableForm.inputPlaceholder",
|
|
38
|
+
defaultMessage: "请输入"
|
|
39
|
+
});
|
|
40
|
+
const dom = createVNode(InputNumber, mergeProps({ "placeholder": placeholder }, fieldProps), null);
|
|
41
|
+
if (formItemRender) return createVNode(Fragment, null, [formItemRender(text, {
|
|
42
|
+
mode,
|
|
43
|
+
fieldProps,
|
|
44
|
+
placeholder
|
|
45
|
+
}, dom)]);
|
|
46
|
+
return dom;
|
|
47
|
+
}
|
|
48
|
+
return null;
|
|
49
|
+
};
|
|
50
|
+
}, {
|
|
51
|
+
props: {
|
|
52
|
+
text: {
|
|
53
|
+
type: [
|
|
54
|
+
Object,
|
|
55
|
+
Function,
|
|
56
|
+
String,
|
|
57
|
+
Number,
|
|
58
|
+
null,
|
|
59
|
+
Boolean,
|
|
60
|
+
Array
|
|
61
|
+
],
|
|
62
|
+
required: false,
|
|
63
|
+
default: void 0
|
|
64
|
+
},
|
|
65
|
+
"onUpdate:text": {
|
|
66
|
+
type: Function,
|
|
67
|
+
required: false
|
|
68
|
+
},
|
|
69
|
+
fieldProps: {
|
|
70
|
+
type: Object,
|
|
71
|
+
required: false
|
|
72
|
+
},
|
|
73
|
+
mode: {
|
|
74
|
+
type: String,
|
|
75
|
+
required: false
|
|
76
|
+
},
|
|
77
|
+
light: {
|
|
78
|
+
type: Boolean,
|
|
79
|
+
required: false,
|
|
80
|
+
default: void 0
|
|
81
|
+
},
|
|
82
|
+
label: {
|
|
83
|
+
type: [
|
|
84
|
+
Object,
|
|
85
|
+
Function,
|
|
86
|
+
String,
|
|
87
|
+
Number,
|
|
88
|
+
null,
|
|
89
|
+
Boolean,
|
|
90
|
+
Array
|
|
91
|
+
],
|
|
92
|
+
required: false,
|
|
93
|
+
default: void 0
|
|
94
|
+
},
|
|
95
|
+
valueEnum: {
|
|
96
|
+
type: [Object, Map],
|
|
97
|
+
required: false
|
|
98
|
+
},
|
|
99
|
+
proFieldKey: {
|
|
100
|
+
type: [String, Number],
|
|
101
|
+
required: false
|
|
102
|
+
},
|
|
103
|
+
render: {
|
|
104
|
+
type: Function,
|
|
105
|
+
required: false
|
|
106
|
+
},
|
|
107
|
+
formItemRender: {
|
|
108
|
+
type: Function,
|
|
109
|
+
required: false
|
|
110
|
+
},
|
|
111
|
+
placeholder: {
|
|
112
|
+
type: String,
|
|
113
|
+
required: false
|
|
114
|
+
},
|
|
115
|
+
id: {
|
|
116
|
+
type: String,
|
|
117
|
+
required: false
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
name: "FieldProgress",
|
|
121
|
+
inheritAttrs: false
|
|
122
|
+
});
|
|
123
|
+
//#endregion
|
|
124
|
+
export { FieldProgress as default, getProgressStatus };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ProFieldFC } from "../../typing.js";
|
|
2
|
+
import { FieldSelectProps } from "../Select/index.js";
|
|
3
|
+
import * as _$vue from "vue";
|
|
4
|
+
import { CSSProperties } from "vue";
|
|
5
|
+
import * as _$_antdv_next1_pro_provider0 from "@antdv-next1/pro-provider";
|
|
6
|
+
import { RadioGroupProps } from "antdv-next";
|
|
7
|
+
import { CustomSlotsType, VueNode } from "@v-c/util/dist/type";
|
|
8
|
+
import * as _$antdv_next_dist_radio_group0 from "antdv-next/dist/radio/group";
|
|
9
|
+
|
|
10
|
+
//#region src/components/Radio/index.d.ts
|
|
11
|
+
type FieldRadioProps = ProFieldFC<{
|
|
12
|
+
options?: RadioGroupProps['options'];
|
|
13
|
+
radioType?: RadioGroupProps['optionType'];
|
|
14
|
+
}, RadioGroupProps & {
|
|
15
|
+
class?: string;
|
|
16
|
+
style?: CSSProperties;
|
|
17
|
+
layout?: 'horizontal' | 'vertical';
|
|
18
|
+
}> & Omit<FieldSelectProps, 'variant' | 'fieldProps' | 'id' | 'label' | 'labelTrigger' | 'lightLabel' | 'light' | 'plain'>;
|
|
19
|
+
declare const FieldRadio: _$vue.DefineSetupFnComponent<FieldRadioProps, {}, CustomSlotsType<{
|
|
20
|
+
default?: () => VueNode;
|
|
21
|
+
}>, _$_antdv_next1_pro_provider0.BaseProFieldFC<_$antdv_next_dist_radio_group0.InternalRadioGroupProps & {
|
|
22
|
+
class?: string;
|
|
23
|
+
style?: CSSProperties;
|
|
24
|
+
layout?: "horizontal" | "vertical";
|
|
25
|
+
}> & _$_antdv_next1_pro_provider0.ProRenderFieldPropsType<_$antdv_next_dist_radio_group0.InternalRadioGroupProps & {
|
|
26
|
+
class?: string;
|
|
27
|
+
style?: CSSProperties;
|
|
28
|
+
layout?: "horizontal" | "vertical";
|
|
29
|
+
}> & {
|
|
30
|
+
options?: RadioGroupProps["options"];
|
|
31
|
+
radioType?: RadioGroupProps["optionType"];
|
|
32
|
+
} & {
|
|
33
|
+
id?: string;
|
|
34
|
+
} & Omit<FieldSelectProps, "id" | "variant" | "fieldProps" | "light" | "label" | "labelTrigger" | "lightLabel" | "plain"> & {}, _$vue.PublicProps>;
|
|
35
|
+
//#endregion
|
|
36
|
+
export { FieldRadioProps, FieldRadio as default };
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { useFieldFetchData } from "../Select/index.js";
|
|
2
|
+
import { useStyle } from "./style/index.js";
|
|
3
|
+
import { Fragment, computed, createVNode, defineComponent, mergeProps, ref } from "vue";
|
|
4
|
+
import { objectToMap, proFieldParsingText } from "@antdv-next1/pro-utils";
|
|
5
|
+
import { RadioGroup, Spin } from "antdv-next";
|
|
6
|
+
import { classNames } from "@v-c/util";
|
|
7
|
+
import { useConfig as useConfig$1 } from "antdv-next/dist/config-provider/context";
|
|
8
|
+
import { useFormItemInputContext } from "antdv-next/dist/form/context";
|
|
9
|
+
//#region src/components/Radio/index.tsx
|
|
10
|
+
const FieldRadio = /* @__PURE__ */ defineComponent((props, { expose, attrs }) => {
|
|
11
|
+
const config = useConfig$1();
|
|
12
|
+
const formItemInputContext = useFormItemInputContext();
|
|
13
|
+
const layoutClassName = computed(() => config.value.getPrefixCls("pro-field-radio"));
|
|
14
|
+
const [loading, options, fetchData] = useFieldFetchData(props);
|
|
15
|
+
const radioRef = ref();
|
|
16
|
+
const { wrapSSR, hashId } = useStyle(layoutClassName);
|
|
17
|
+
expose({ fetchData: (keyWord) => fetchData(keyWord) });
|
|
18
|
+
return () => {
|
|
19
|
+
const { mode, render, formItemRender, options: propsOptions, request, params, debounceTime, defaultKeyWords, radioType, ...rest } = props;
|
|
20
|
+
if (loading.value) return createVNode(Spin, { "size": "small" }, null);
|
|
21
|
+
if (mode === "read") {
|
|
22
|
+
const optionsValueEnum = options.value?.length ? options.value?.reduce((pre, cur) => {
|
|
23
|
+
return {
|
|
24
|
+
...pre,
|
|
25
|
+
[cur.value ?? ""]: cur.label
|
|
26
|
+
};
|
|
27
|
+
}, {}) : void 0;
|
|
28
|
+
const dom = createVNode(Fragment, null, [proFieldParsingText(rest.text, objectToMap(rest.valueEnum || optionsValueEnum))]);
|
|
29
|
+
if (render) return createVNode(Fragment, null, [render(rest.text, {
|
|
30
|
+
mode,
|
|
31
|
+
...rest
|
|
32
|
+
}, dom) ?? null]);
|
|
33
|
+
return dom;
|
|
34
|
+
}
|
|
35
|
+
if (props.mode === "edit") {
|
|
36
|
+
const dom = wrapSSR(createVNode(RadioGroup, mergeProps({ "ref": radioRef }, attrs, { "optionType": radioType }, rest.fieldProps, {
|
|
37
|
+
"class": classNames(rest.fieldProps?.class, {
|
|
38
|
+
[`${layoutClassName.value}-error`]: formItemInputContext.value.status === "error",
|
|
39
|
+
[`${layoutClassName.value}-warning`]: formItemInputContext.value.status === "warning"
|
|
40
|
+
}, hashId.value, `${layoutClassName.value}-${props.fieldProps?.layout || "horizontal"}`),
|
|
41
|
+
"options": options.value
|
|
42
|
+
}), null));
|
|
43
|
+
if (formItemRender) return createVNode(Fragment, null, [formItemRender(rest.text, {
|
|
44
|
+
mode,
|
|
45
|
+
...rest,
|
|
46
|
+
options: options.value,
|
|
47
|
+
loading: loading.value
|
|
48
|
+
}, dom) ?? null]);
|
|
49
|
+
return dom;
|
|
50
|
+
}
|
|
51
|
+
return null;
|
|
52
|
+
};
|
|
53
|
+
}, {
|
|
54
|
+
props: {
|
|
55
|
+
text: {
|
|
56
|
+
type: [
|
|
57
|
+
Object,
|
|
58
|
+
Function,
|
|
59
|
+
String,
|
|
60
|
+
Number,
|
|
61
|
+
null,
|
|
62
|
+
Boolean,
|
|
63
|
+
Array
|
|
64
|
+
],
|
|
65
|
+
required: false,
|
|
66
|
+
default: void 0
|
|
67
|
+
},
|
|
68
|
+
"onUpdate:text": {
|
|
69
|
+
type: Function,
|
|
70
|
+
required: false
|
|
71
|
+
},
|
|
72
|
+
fieldProps: {
|
|
73
|
+
type: Object,
|
|
74
|
+
required: false
|
|
75
|
+
},
|
|
76
|
+
mode: {
|
|
77
|
+
type: String,
|
|
78
|
+
required: false
|
|
79
|
+
},
|
|
80
|
+
light: {
|
|
81
|
+
type: Boolean,
|
|
82
|
+
required: false,
|
|
83
|
+
default: void 0
|
|
84
|
+
},
|
|
85
|
+
label: {
|
|
86
|
+
type: [
|
|
87
|
+
Object,
|
|
88
|
+
Function,
|
|
89
|
+
String,
|
|
90
|
+
Number,
|
|
91
|
+
null,
|
|
92
|
+
Boolean,
|
|
93
|
+
Array
|
|
94
|
+
],
|
|
95
|
+
required: false,
|
|
96
|
+
default: void 0
|
|
97
|
+
},
|
|
98
|
+
valueEnum: {
|
|
99
|
+
type: [Object, Map],
|
|
100
|
+
required: false
|
|
101
|
+
},
|
|
102
|
+
proFieldKey: {
|
|
103
|
+
type: [String, Number],
|
|
104
|
+
required: false
|
|
105
|
+
},
|
|
106
|
+
render: {
|
|
107
|
+
type: Function,
|
|
108
|
+
required: false
|
|
109
|
+
},
|
|
110
|
+
formItemRender: {
|
|
111
|
+
type: Function,
|
|
112
|
+
required: false
|
|
113
|
+
},
|
|
114
|
+
options: { required: false },
|
|
115
|
+
radioType: { required: false },
|
|
116
|
+
id: {
|
|
117
|
+
type: String,
|
|
118
|
+
required: false
|
|
119
|
+
},
|
|
120
|
+
debounceTime: {
|
|
121
|
+
type: Number,
|
|
122
|
+
required: false
|
|
123
|
+
},
|
|
124
|
+
request: {
|
|
125
|
+
type: Function,
|
|
126
|
+
required: false
|
|
127
|
+
},
|
|
128
|
+
params: { required: false },
|
|
129
|
+
defaultKeyWords: {
|
|
130
|
+
type: String,
|
|
131
|
+
required: false
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
name: "FieldRadio",
|
|
135
|
+
inheritAttrs: false
|
|
136
|
+
});
|
|
137
|
+
//#endregion
|
|
138
|
+
export { FieldRadio as default };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ComputedRef } from "vue";
|
|
2
|
+
import * as _$_antdv_next1_pro_provider0 from "@antdv-next1/pro-provider";
|
|
3
|
+
import { ProAliasToken } from "@antdv-next1/pro-provider";
|
|
4
|
+
|
|
5
|
+
//#region src/components/Radio/style/index.d.ts
|
|
6
|
+
interface ProFieldRadioToken extends ProAliasToken {
|
|
7
|
+
componentCls: string;
|
|
8
|
+
}
|
|
9
|
+
declare function useStyle(prefixCls: ComputedRef<string>): _$_antdv_next1_pro_provider0.UseStyleResult;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { ProFieldRadioToken, useStyle };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { useStyle as useStyle$1 } from "@antdv-next1/pro-provider";
|
|
2
|
+
//#region src/components/Radio/style/index.ts
|
|
3
|
+
const genProFieldRadioStyle = (token) => {
|
|
4
|
+
return { [token.componentCls]: {
|
|
5
|
+
"&-error": { span: { color: token.colorError } },
|
|
6
|
+
"&-vertical": { [`${token.antCls}-radio-wrapper`]: {
|
|
7
|
+
display: "flex",
|
|
8
|
+
marginInlineEnd: 0
|
|
9
|
+
} }
|
|
10
|
+
} };
|
|
11
|
+
};
|
|
12
|
+
function useStyle(prefixCls) {
|
|
13
|
+
return useStyle$1("ProFieldRadio", (token) => {
|
|
14
|
+
return [genProFieldRadioStyle({
|
|
15
|
+
...token,
|
|
16
|
+
componentCls: `.${prefixCls.value}`
|
|
17
|
+
})];
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
export { useStyle };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ProFieldFC, ProFieldLightProps } from "../../typing.js";
|
|
2
|
+
import * as _$vue from "vue";
|
|
3
|
+
import * as _$_antdv_next1_pro_provider0 from "@antdv-next1/pro-provider";
|
|
4
|
+
import { RangePickerProps } from "antdv-next";
|
|
5
|
+
import { CustomSlotsType, VueNode } from "@v-c/util/dist/type";
|
|
6
|
+
|
|
7
|
+
//#region src/components/RangePicker/DatePicker.d.ts
|
|
8
|
+
type FieldDateRangePickerProps = ProFieldFC<{
|
|
9
|
+
text: string[];
|
|
10
|
+
format?: string;
|
|
11
|
+
variant?: 'outlined' | 'borderless' | 'filled' | 'underlined';
|
|
12
|
+
showTime?: boolean;
|
|
13
|
+
separator?: string;
|
|
14
|
+
picker?: 'time' | 'date' | 'week' | 'month' | 'quarter' | 'year';
|
|
15
|
+
} & ProFieldLightProps, RangePickerProps>;
|
|
16
|
+
declare const FieldDateRangePicker: _$vue.DefineSetupFnComponent<FieldDateRangePickerProps, {}, CustomSlotsType<{
|
|
17
|
+
default?: () => VueNode;
|
|
18
|
+
}>, _$_antdv_next1_pro_provider0.BaseProFieldFC<RangePickerProps> & _$_antdv_next1_pro_provider0.ProRenderFieldPropsType<RangePickerProps> & {
|
|
19
|
+
text: string[];
|
|
20
|
+
format?: string;
|
|
21
|
+
variant?: "outlined" | "borderless" | "filled" | "underlined";
|
|
22
|
+
showTime?: boolean;
|
|
23
|
+
separator?: string;
|
|
24
|
+
picker?: "time" | "date" | "week" | "month" | "quarter" | "year";
|
|
25
|
+
} & ProFieldLightProps & {
|
|
26
|
+
id?: string;
|
|
27
|
+
} & {}, _$vue.PublicProps>;
|
|
28
|
+
//#endregion
|
|
29
|
+
export { FieldDateRangePickerProps, FieldDateRangePicker as default };
|