@rainbow-oh/yee-c 0.8.19 → 0.9.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/dist/cjs/Anchor/anchor.js +4 -1
- package/dist/cjs/Checkbox/checkbox.js +2 -1
- package/dist/cjs/Checkbox/style/index.less +3 -0
- package/dist/cjs/Form/Field.js +6 -6
- package/dist/cjs/Form/demo/field-status.d.ts +3 -0
- package/dist/cjs/Form/demo/field-status.js +116 -0
- package/dist/cjs/Form/form-store.d.ts +6 -1
- package/dist/cjs/Form/form-store.js +74 -2
- package/dist/cjs/Form/index.d.ts +1 -1
- package/dist/cjs/Form/interface.d.ts +17 -1
- package/dist/cjs/Form/style/index.less +26 -0
- package/dist/cjs/Progress/circle.js +46 -35
- package/dist/cjs/Progress/line.js +20 -11
- package/dist/cjs/Search/demo/basic.js +38 -3
- package/dist/cjs/Search/interface.d.ts +2 -2
- package/dist/cjs/Search/search.js +52 -32
- package/dist/cjs/Search/style/index.less +20 -3
- package/dist/cjs/Table/style/index.less +4 -2
- package/dist/cjs/Table/tbody/cell.js +2 -2
- package/dist/cjs/Transfer/interface.d.ts +0 -1
- package/dist/cjs/Transfer/style/index.less +4 -0
- package/dist/cjs/Transfer/transfer-list.js +1 -0
- package/dist/cjs/message/use-message.js +1 -3
- package/dist/cjs/notice/notice.js +1 -1
- package/dist/cjs/style/themes.css +1 -1
- package/dist/cjs/style/variables.css +1 -1
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/Checkbox/checkbox.js +2 -1
- package/dist/esm/Checkbox/style/index.less +3 -0
- package/dist/esm/Form/Field.js +6 -6
- package/dist/esm/Form/demo/field-status.d.ts +3 -0
- package/dist/esm/Form/demo/field-status.js +104 -0
- package/dist/esm/Form/form-store.d.ts +6 -1
- package/dist/esm/Form/form-store.js +88 -6
- package/dist/esm/Form/index.d.ts +1 -1
- package/dist/esm/Form/interface.d.ts +17 -1
- package/dist/esm/Form/style/index.less +26 -0
- package/dist/esm/Search/demo/basic.js +61 -7
- package/dist/esm/Search/interface.d.ts +2 -2
- package/dist/esm/Search/search.js +22 -15
- package/dist/esm/Search/style/index.less +20 -3
- package/dist/esm/Table/style/index.less +4 -2
- package/dist/esm/Table/tbody/cell.js +2 -2
- package/dist/esm/Transfer/interface.d.ts +0 -1
- package/dist/esm/Transfer/style/index.less +4 -0
- package/dist/esm/Transfer/transfer-list.js +1 -0
- package/dist/esm/notice/notice.js +1 -1
- package/dist/esm/style/themes.css +1 -1
- package/dist/esm/style/variables.css +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/umd/yee-c.min.css +1 -1
- package/dist/umd/yee-c.min.js +1 -1
- package/package.json +1 -1
- package/src/Anchor/anchor.tsx +9 -5
- package/src/Checkbox/checkbox.tsx +1 -0
- package/src/Checkbox/style/index.less +3 -0
- package/src/Form/Field.tsx +7 -8
- package/src/Form/demo/field-status.tsx +108 -0
- package/src/Form/form-store.ts +92 -2
- package/src/Form/index.en-US.md +6 -1
- package/src/Form/index.ts +2 -0
- package/src/Form/index.zh-CN.md +6 -1
- package/src/Form/interface.ts +19 -1
- package/src/Form/style/index.less +26 -0
- package/src/Progress/circle.tsx +5 -1
- package/src/Progress/line.tsx +5 -1
- package/src/Progress/progress.tsx +5 -1
- package/src/Search/demo/basic.tsx +43 -7
- package/src/Search/index.en-US.md +1 -1
- package/src/Search/index.zh-CN.md +1 -1
- package/src/Search/interface.ts +2 -2
- package/src/Search/search.tsx +40 -23
- package/src/Search/style/index.less +20 -3
- package/src/Spin/indicator.tsx +1 -1
- package/src/Table/style/index.less +4 -2
- package/src/Table/tbody/cell.tsx +2 -2
- package/src/Transfer/interface.ts +0 -1
- package/src/Transfer/style/index.less +4 -0
- package/src/Transfer/transfer-list.tsx +1 -0
- package/src/Tree/interface.ts +6 -1
- package/src/Tree/tree-node.tsx +7 -6
- package/src/Tree/utils/tree-tools.ts +4 -1
- package/src/Trigger/interface.ts +2 -1
- package/src/message/demo/base.tsx +1 -1
- package/src/message/interface.ts +1 -5
- package/src/message/message.test.tsx +15 -5
- package/src/message/message.tsx +10 -4
- package/src/message/use-message.tsx +2 -8
- package/src/message/wrapper.tsx +1 -2
- package/src/notice/interface.ts +1 -5
- package/src/notice/notice.test.tsx +14 -6
- package/src/notice/notice.tsx +12 -6
- package/src/notice/wrapper.tsx +1 -2
- package/src/version.ts +1 -1
- package/dist/cjs/Search/style/index.d.ts +0 -1
- package/dist/cjs/Search/style/index.js +0 -2
- package/dist/esm/Search/style/index.d.ts +0 -1
- package/dist/esm/Search/style/index.js +0 -1
- package/src/Search/style/index.ts +0 -1
|
@@ -361,7 +361,10 @@ var Anchor = (0, import_react.forwardRef)((baseprops, ref) => {
|
|
|
361
361
|
"pointerdown",
|
|
362
362
|
onUserInterrupt
|
|
363
363
|
);
|
|
364
|
-
container.removeEventListener(
|
|
364
|
+
container.removeEventListener(
|
|
365
|
+
"keydown",
|
|
366
|
+
onUserInterrupt
|
|
367
|
+
);
|
|
365
368
|
if (rafId !== null) {
|
|
366
369
|
cancelAnimationFrame(rafId);
|
|
367
370
|
}
|
|
@@ -157,7 +157,8 @@ var Checkbox = (baseprops) => {
|
|
|
157
157
|
"span",
|
|
158
158
|
{
|
|
159
159
|
className: (0, import_clsx.default)(`${prefixCls}-label`, classNames == null ? void 0 : classNames.label),
|
|
160
|
-
style: styles == null ? void 0 : styles.label
|
|
160
|
+
style: styles == null ? void 0 : styles.label,
|
|
161
|
+
title: typeof children === "string" ? children : void 0
|
|
161
162
|
},
|
|
162
163
|
children
|
|
163
164
|
) : null
|
package/dist/cjs/Form/Field.js
CHANGED
|
@@ -98,7 +98,7 @@ var Field = (props) => {
|
|
|
98
98
|
} = props;
|
|
99
99
|
const {
|
|
100
100
|
getCallbacks,
|
|
101
|
-
|
|
101
|
+
getFieldStatus,
|
|
102
102
|
getFieldValue,
|
|
103
103
|
getFieldsValue,
|
|
104
104
|
setFieldsValue,
|
|
@@ -129,7 +129,7 @@ var Field = (props) => {
|
|
|
129
129
|
const isRequired = () => {
|
|
130
130
|
return Array.isArray(rules) && rules.find((rule) => rule.required) || required;
|
|
131
131
|
};
|
|
132
|
-
const
|
|
132
|
+
const fieldStatus = getFieldStatus == null ? void 0 : getFieldStatus(normalizedName);
|
|
133
133
|
const tooltipConfig = (0, import_react2.useMemo)(() => {
|
|
134
134
|
if (tooltip === void 0 || tooltip === null || tooltip === false)
|
|
135
135
|
return null;
|
|
@@ -183,7 +183,7 @@ var Field = (props) => {
|
|
|
183
183
|
`${prefixCls}-item`,
|
|
184
184
|
`${prefixCls}-item-${layout}`,
|
|
185
185
|
{
|
|
186
|
-
[`${prefixCls}-item-${
|
|
186
|
+
[`${prefixCls}-item-${fieldStatus == null ? void 0 : fieldStatus.status}`]: fieldStatus == null ? void 0 : fieldStatus.status
|
|
187
187
|
},
|
|
188
188
|
className
|
|
189
189
|
),
|
|
@@ -216,7 +216,7 @@ var Field = (props) => {
|
|
|
216
216
|
getControlled(children)
|
|
217
217
|
) : /* @__PURE__ */ import_react2.default.createElement("span", null, children)
|
|
218
218
|
)),
|
|
219
|
-
/* @__PURE__ */ import_react2.default.createElement(import_react.AnimatePresence, null,
|
|
219
|
+
/* @__PURE__ */ import_react2.default.createElement(import_react.AnimatePresence, null, (fieldStatus == null ? void 0 : fieldStatus.message) && /* @__PURE__ */ import_react2.default.createElement(
|
|
220
220
|
import_react.motion.small,
|
|
221
221
|
{
|
|
222
222
|
initial: { opacity: 0, y: -10 },
|
|
@@ -224,10 +224,10 @@ var Field = (props) => {
|
|
|
224
224
|
exit: { opacity: 0, y: -10 },
|
|
225
225
|
transition: { duration: 0.16 },
|
|
226
226
|
className: (0, import_clsx.default)(`${prefixCls}-item-additional`, {
|
|
227
|
-
[`${prefixCls}-item-additional-${
|
|
227
|
+
[`${prefixCls}-item-additional-${fieldStatus.status}`]: fieldStatus.status
|
|
228
228
|
})
|
|
229
229
|
},
|
|
230
|
-
|
|
230
|
+
fieldStatus.message
|
|
231
231
|
))
|
|
232
232
|
);
|
|
233
233
|
};
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/Form/demo/field-status.tsx
|
|
30
|
+
var field_status_exports = {};
|
|
31
|
+
__export(field_status_exports, {
|
|
32
|
+
default: () => field_status_default
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(field_status_exports);
|
|
35
|
+
var import_yee_c = require("../..");
|
|
36
|
+
var import_react = __toESM(require("react"));
|
|
37
|
+
var field_status_default = () => {
|
|
38
|
+
const [form] = import_yee_c.Form.useForm();
|
|
39
|
+
const [currentStatus, setCurrentStatus] = (0, import_react.useState)(
|
|
40
|
+
null
|
|
41
|
+
);
|
|
42
|
+
const [submitResult, setSubmitResult] = (0, import_react.useState)("");
|
|
43
|
+
const applyStatus = (status) => {
|
|
44
|
+
form.setFieldStatus("username", status);
|
|
45
|
+
setCurrentStatus(form.getFieldStatus("username"));
|
|
46
|
+
setSubmitResult("");
|
|
47
|
+
};
|
|
48
|
+
return /* @__PURE__ */ import_react.default.createElement(
|
|
49
|
+
import_yee_c.Form,
|
|
50
|
+
{
|
|
51
|
+
form,
|
|
52
|
+
initialValues: { username: "demo-user" },
|
|
53
|
+
onFinish: () => setSubmitResult("Submit succeeded"),
|
|
54
|
+
onFinishFailed: () => setSubmitResult("Submit blocked by the blocking error")
|
|
55
|
+
},
|
|
56
|
+
/* @__PURE__ */ import_react.default.createElement(
|
|
57
|
+
import_yee_c.Form.Field,
|
|
58
|
+
{
|
|
59
|
+
name: "username",
|
|
60
|
+
label: "Username",
|
|
61
|
+
rules: [{ required: true, message: "Please input your username!" }]
|
|
62
|
+
},
|
|
63
|
+
/* @__PURE__ */ import_react.default.createElement(import_yee_c.Input, { placeholder: "Please input your username" })
|
|
64
|
+
),
|
|
65
|
+
/* @__PURE__ */ import_react.default.createElement(import_yee_c.Space, { style: { marginTop: 28, flexWrap: "wrap" } }, /* @__PURE__ */ import_react.default.createElement(
|
|
66
|
+
import_yee_c.Button,
|
|
67
|
+
{
|
|
68
|
+
onClick: () => applyStatus({
|
|
69
|
+
status: "error",
|
|
70
|
+
message: "This username is unavailable"
|
|
71
|
+
})
|
|
72
|
+
},
|
|
73
|
+
"Error"
|
|
74
|
+
), /* @__PURE__ */ import_react.default.createElement(
|
|
75
|
+
import_yee_c.Button,
|
|
76
|
+
{
|
|
77
|
+
onClick: () => applyStatus({
|
|
78
|
+
status: "error",
|
|
79
|
+
message: "This error prevents submission",
|
|
80
|
+
blocking: true
|
|
81
|
+
})
|
|
82
|
+
},
|
|
83
|
+
"Blocking error"
|
|
84
|
+
), /* @__PURE__ */ import_react.default.createElement(
|
|
85
|
+
import_yee_c.Button,
|
|
86
|
+
{
|
|
87
|
+
onClick: () => applyStatus({
|
|
88
|
+
status: "warning",
|
|
89
|
+
message: "This username is commonly used"
|
|
90
|
+
})
|
|
91
|
+
},
|
|
92
|
+
"Warning"
|
|
93
|
+
), /* @__PURE__ */ import_react.default.createElement(
|
|
94
|
+
import_yee_c.Button,
|
|
95
|
+
{
|
|
96
|
+
onClick: () => applyStatus({
|
|
97
|
+
status: "success",
|
|
98
|
+
message: "This username is available"
|
|
99
|
+
})
|
|
100
|
+
},
|
|
101
|
+
"Success"
|
|
102
|
+
), /* @__PURE__ */ import_react.default.createElement(
|
|
103
|
+
import_yee_c.Button,
|
|
104
|
+
{
|
|
105
|
+
onClick: () => applyStatus({
|
|
106
|
+
status: "info",
|
|
107
|
+
message: "The username can be changed later"
|
|
108
|
+
})
|
|
109
|
+
},
|
|
110
|
+
"Info"
|
|
111
|
+
), /* @__PURE__ */ import_react.default.createElement(import_yee_c.Button, { onClick: () => applyStatus(null) }, "Clear"), /* @__PURE__ */ import_react.default.createElement(import_yee_c.Button, { type: "primary", htmlType: "submit" }, "Submit")),
|
|
112
|
+
/* @__PURE__ */ import_react.default.createElement("pre", { style: { marginTop: 16 } }, "Current status: ", JSON.stringify(currentStatus, null, 2)),
|
|
113
|
+
submitResult ? /* @__PURE__ */ import_react.default.createElement("div", null, submitResult) : null,
|
|
114
|
+
/* @__PURE__ */ import_react.default.createElement("div", { style: { marginTop: 8, color: "#999" } }, "Tip: set Success, then clear the input — the rule error takes display precedence over the manually set status.")
|
|
115
|
+
);
|
|
116
|
+
};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import type { Callbacks, FieldEntity, FormInstance, FormListField, FormListOperation, GroupEntity, Name, NamePath, Store, TRIGGER, ValidateMessage } from './interface';
|
|
1
|
+
import type { Callbacks, FieldEntity, FieldStatusData, FormInstance, FormListField, FormListOperation, GroupEntity, Name, NamePath, Store, TRIGGER, ValidateMessage } from './interface';
|
|
2
2
|
export declare class FormStore {
|
|
3
3
|
private store;
|
|
4
4
|
private callbacks;
|
|
5
5
|
private fieldEntities;
|
|
6
6
|
private fieldMap;
|
|
7
7
|
private validateMessages;
|
|
8
|
+
private fieldStatuses;
|
|
8
9
|
private initialized;
|
|
9
10
|
private initialValues;
|
|
10
11
|
private listKeyManagers;
|
|
@@ -23,6 +24,10 @@ export declare class FormStore {
|
|
|
23
24
|
private getValueByPath;
|
|
24
25
|
getFieldValue: (name: Name) => any;
|
|
25
26
|
getFieldValidate: (name: Name) => ValidateMessage | null;
|
|
27
|
+
getFieldStatus: (name: NamePath) => FieldStatusData | null;
|
|
28
|
+
setFieldStatus: (name: NamePath, status: FieldStatusData | null) => void;
|
|
29
|
+
private deleteRelatedEntries;
|
|
30
|
+
private clearFieldStatuses;
|
|
26
31
|
setFieldsValue: (newStore: Store, trigger?: TRIGGER) => void;
|
|
27
32
|
resetFields: (name?: Name[]) => void;
|
|
28
33
|
clearFields: (name?: Name[]) => void;
|
|
@@ -88,6 +88,7 @@ var FormStore = class {
|
|
|
88
88
|
this.fieldEntities = [];
|
|
89
89
|
this.fieldMap = /* @__PURE__ */ new Map();
|
|
90
90
|
this.validateMessages = /* @__PURE__ */ new Map();
|
|
91
|
+
this.fieldStatuses = /* @__PURE__ */ new Map();
|
|
91
92
|
this.initialized = false;
|
|
92
93
|
this.initialValues = {};
|
|
93
94
|
// List key manager
|
|
@@ -143,6 +144,60 @@ var FormStore = class {
|
|
|
143
144
|
}
|
|
144
145
|
return null;
|
|
145
146
|
};
|
|
147
|
+
this.getFieldStatus = (name) => {
|
|
148
|
+
var _a;
|
|
149
|
+
const normalizedName = (0, import_path.stringifyPath)((0, import_path.getNamePath)(name));
|
|
150
|
+
const manualStatus = this.fieldStatuses.get(normalizedName);
|
|
151
|
+
const validateMessage = (_a = this.validateMessages.get(normalizedName)) == null ? void 0 : _a[0];
|
|
152
|
+
if ((validateMessage == null ? void 0 : validateMessage.status) === "error") {
|
|
153
|
+
return {
|
|
154
|
+
status: "error",
|
|
155
|
+
message: validateMessage.message
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
if (manualStatus) {
|
|
159
|
+
return __spreadValues({}, manualStatus);
|
|
160
|
+
}
|
|
161
|
+
if (validateMessage) {
|
|
162
|
+
return {
|
|
163
|
+
status: validateMessage.status,
|
|
164
|
+
message: validateMessage.message
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
return null;
|
|
168
|
+
};
|
|
169
|
+
this.setFieldStatus = (name, status) => {
|
|
170
|
+
var _a;
|
|
171
|
+
const normalizedName = (0, import_path.stringifyPath)((0, import_path.getNamePath)(name));
|
|
172
|
+
if (!normalizedName)
|
|
173
|
+
return;
|
|
174
|
+
if (status) {
|
|
175
|
+
this.fieldStatuses.set(normalizedName, __spreadValues({}, status));
|
|
176
|
+
} else {
|
|
177
|
+
this.fieldStatuses.delete(normalizedName);
|
|
178
|
+
}
|
|
179
|
+
(_a = this.fieldMap.get(normalizedName)) == null ? void 0 : _a.onStoreChange();
|
|
180
|
+
};
|
|
181
|
+
// Delete entries whose key equals or nests under one of `names`
|
|
182
|
+
// (no names = delete all). Keeps rule messages and manual statuses in
|
|
183
|
+
// sync with the fields that reset/clear actually touched.
|
|
184
|
+
this.deleteRelatedEntries = (entries, names) => {
|
|
185
|
+
if (!names) {
|
|
186
|
+
entries.clear();
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
const normalizedNames = names.map(
|
|
190
|
+
(name) => (0, import_path.stringifyPath)((0, import_path.getNamePath)(name))
|
|
191
|
+
);
|
|
192
|
+
Array.from(entries.keys()).forEach((fieldName) => {
|
|
193
|
+
if (normalizedNames.some((name) => isRelatedNamePath(fieldName, name))) {
|
|
194
|
+
entries.delete(fieldName);
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
};
|
|
198
|
+
this.clearFieldStatuses = (names) => {
|
|
199
|
+
this.deleteRelatedEntries(this.fieldStatuses, names);
|
|
200
|
+
};
|
|
146
201
|
this.setFieldsValue = (newStore, trigger = "onChange") => {
|
|
147
202
|
var _a, _b, _c, _d;
|
|
148
203
|
if (trigger === "reset" || trigger === "clear") {
|
|
@@ -208,7 +263,8 @@ var FormStore = class {
|
|
|
208
263
|
});
|
|
209
264
|
}
|
|
210
265
|
(_b = (_a = this.callbacks) == null ? void 0 : _a.onReset) == null ? void 0 : _b.call(_a);
|
|
211
|
-
this.validateMessages
|
|
266
|
+
this.deleteRelatedEntries(this.validateMessages, name);
|
|
267
|
+
this.clearFieldStatuses(name);
|
|
212
268
|
this.groupEntities.forEach((entity) => entity.reset());
|
|
213
269
|
this.refreshField();
|
|
214
270
|
};
|
|
@@ -218,6 +274,7 @@ var FormStore = class {
|
|
|
218
274
|
acc[name2] = void 0;
|
|
219
275
|
return acc;
|
|
220
276
|
}, {});
|
|
277
|
+
this.clearFieldStatuses(name);
|
|
221
278
|
this.setFieldsValue(clearStore, "clear");
|
|
222
279
|
};
|
|
223
280
|
this.validateField = (name, trigger) => __async(this, null, function* () {
|
|
@@ -483,7 +540,20 @@ var FormStore = class {
|
|
|
483
540
|
const { onFinish, onFinishFailed } = this.callbacks;
|
|
484
541
|
const fieldErrors = yield this.validateFields();
|
|
485
542
|
const groupErrors = yield this.validateGroups(true);
|
|
486
|
-
const
|
|
543
|
+
const statusErrors = Array.from(this.fieldStatuses.entries()).filter(
|
|
544
|
+
([, status]) => status.status === "error" && status.blocking === true
|
|
545
|
+
).map(
|
|
546
|
+
([name, status]) => {
|
|
547
|
+
var _a;
|
|
548
|
+
return {
|
|
549
|
+
name,
|
|
550
|
+
message: (_a = status.message) != null ? _a : "",
|
|
551
|
+
value: this.getFieldValue(name),
|
|
552
|
+
status: "error"
|
|
553
|
+
};
|
|
554
|
+
}
|
|
555
|
+
);
|
|
556
|
+
const allErrors = [...fieldErrors, ...groupErrors, ...statusErrors];
|
|
487
557
|
if (allErrors.length === 0) {
|
|
488
558
|
onFinish == null ? void 0 : onFinish(this.getFieldsValue());
|
|
489
559
|
} else {
|
|
@@ -520,6 +590,8 @@ var FormStore = class {
|
|
|
520
590
|
getForm() {
|
|
521
591
|
return {
|
|
522
592
|
getFieldValidate: this.getFieldValidate,
|
|
593
|
+
getFieldStatus: this.getFieldStatus,
|
|
594
|
+
setFieldStatus: this.setFieldStatus,
|
|
523
595
|
getFieldsValue: this.getFieldsValue,
|
|
524
596
|
getFieldValue: this.getFieldValue,
|
|
525
597
|
setFieldsValue: this.setFieldsValue,
|
package/dist/cjs/Form/index.d.ts
CHANGED
|
@@ -16,5 +16,5 @@ type FormInterface = typeof InternalForm & {
|
|
|
16
16
|
List: typeof List;
|
|
17
17
|
};
|
|
18
18
|
declare const Form: FormInterface;
|
|
19
|
-
export type { FieldGroupProps, FormInstance, FormListProps, FormProps, } from './interface';
|
|
19
|
+
export type { FieldGroupProps, FieldStatus, FieldStatusData, FormInstance, FormListProps, FormProps, } from './interface';
|
|
20
20
|
export default Form;
|
|
@@ -96,6 +96,15 @@ export interface FormInstance<Values = any> {
|
|
|
96
96
|
* Get field validation info
|
|
97
97
|
*/
|
|
98
98
|
getFieldValidate: (name: Name) => ValidateMessage | null;
|
|
99
|
+
/**
|
|
100
|
+
* Get the displayed field status. Rule validation errors take display
|
|
101
|
+
* precedence; otherwise a manually set status overrides validation.
|
|
102
|
+
*/
|
|
103
|
+
getFieldStatus: (name: NamePath) => FieldStatusData | null;
|
|
104
|
+
/**
|
|
105
|
+
* Set or clear a field's displayed status. Pass null to clear it.
|
|
106
|
+
*/
|
|
107
|
+
setFieldStatus: (name: NamePath, status: FieldStatusData | null) => void;
|
|
99
108
|
/**
|
|
100
109
|
* Get field value
|
|
101
110
|
*/
|
|
@@ -225,11 +234,18 @@ export type Rule = {
|
|
|
225
234
|
*/
|
|
226
235
|
validateTrigger?: 'onBlur' | 'onChange' | 'onSubmit' | 'reset' | Array<'onBlur' | 'onChange' | 'onSubmit'>;
|
|
227
236
|
};
|
|
237
|
+
export type FieldStatus = 'error' | 'success' | 'warning' | 'info';
|
|
238
|
+
export type FieldStatusData = {
|
|
239
|
+
status: FieldStatus;
|
|
240
|
+
message?: string;
|
|
241
|
+
/** Whether an error status should prevent form submission. */
|
|
242
|
+
blocking?: boolean;
|
|
243
|
+
};
|
|
228
244
|
export type ValidateMessage = {
|
|
229
245
|
name: NamePath | NamePath[] | undefined;
|
|
230
246
|
message: string;
|
|
231
247
|
value: unknown;
|
|
232
|
-
status:
|
|
248
|
+
status: FieldStatus;
|
|
233
249
|
};
|
|
234
250
|
export type FieldConfigurableTooltip = Omit<TooltipProps, 'children'> & {
|
|
235
251
|
/**
|
|
@@ -79,6 +79,18 @@
|
|
|
79
79
|
&-error {
|
|
80
80
|
color: var(--yee-error-color);
|
|
81
81
|
}
|
|
82
|
+
|
|
83
|
+
&-warning {
|
|
84
|
+
color: var(--yee-warning-color);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
&-success {
|
|
88
|
+
color: var(--yee-success-color);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
&-info {
|
|
92
|
+
color: var(--yee-info-color);
|
|
93
|
+
}
|
|
82
94
|
}
|
|
83
95
|
|
|
84
96
|
// 表单校验态:在此重定义控件读取的 border / box-shadow 变量,
|
|
@@ -97,5 +109,19 @@
|
|
|
97
109
|
--yee-input-focus-bs-color: var(--yee-warning-color-border);
|
|
98
110
|
--yee-checkbox-border-color: var(--yee-warning-color);
|
|
99
111
|
}
|
|
112
|
+
|
|
113
|
+
&&-success {
|
|
114
|
+
--yee-input-border-color: var(--yee-success-color);
|
|
115
|
+
--yee-input-hover-border-color: var(--yee-success-color-hover);
|
|
116
|
+
--yee-input-focus-bs-color: var(--yee-success-color-border);
|
|
117
|
+
--yee-checkbox-border-color: var(--yee-success-color);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
&&-info {
|
|
121
|
+
--yee-input-border-color: var(--yee-info-color);
|
|
122
|
+
--yee-input-hover-border-color: var(--yee-info-color-hover);
|
|
123
|
+
--yee-input-focus-bs-color: var(--yee-info-color-border);
|
|
124
|
+
--yee-checkbox-border-color: var(--yee-info-color);
|
|
125
|
+
}
|
|
100
126
|
}
|
|
101
127
|
}
|
|
@@ -148,42 +148,53 @@ var Circle = import_react.default.forwardRef((props, ref) => {
|
|
|
148
148
|
style: { width, height: width },
|
|
149
149
|
ref
|
|
150
150
|
},
|
|
151
|
-
/* @__PURE__ */ import_react.default.createElement(
|
|
152
|
-
"
|
|
153
|
-
{
|
|
154
|
-
className: `${prefixCls}-circle-trail`,
|
|
155
|
-
cx: "60",
|
|
156
|
-
cy: "60",
|
|
157
|
-
r: "56",
|
|
158
|
-
strokeWidth,
|
|
159
|
-
fill: "transparent"
|
|
160
|
-
}
|
|
161
|
-
), strokeColor instanceof Object && renderConicGradient(), strokeColor instanceof Object && renderForeignObject(), /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(
|
|
162
|
-
"circle",
|
|
163
|
-
__spreadProps(__spreadValues({
|
|
164
|
-
className: `${progressColor ? "" : `${prefixCls}-circle-path`}`,
|
|
165
|
-
cx: "60",
|
|
166
|
-
cy: "60",
|
|
167
|
-
r: "56",
|
|
168
|
-
strokeWidth
|
|
169
|
-
}, progressColor), {
|
|
170
|
-
fill: "transparent",
|
|
171
|
-
ref: path1Ref
|
|
172
|
-
})
|
|
173
|
-
), done && done.percent && /* @__PURE__ */ import_react.default.createElement(
|
|
174
|
-
"circle",
|
|
151
|
+
/* @__PURE__ */ import_react.default.createElement(
|
|
152
|
+
"svg",
|
|
175
153
|
{
|
|
176
|
-
className:
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
154
|
+
className: `${prefixCls}-circle`,
|
|
155
|
+
viewBox: "0 0 120 120",
|
|
156
|
+
"aria-hidden": "true"
|
|
157
|
+
},
|
|
158
|
+
/* @__PURE__ */ import_react.default.createElement(
|
|
159
|
+
"circle",
|
|
160
|
+
{
|
|
161
|
+
className: `${prefixCls}-circle-trail`,
|
|
162
|
+
cx: "60",
|
|
163
|
+
cy: "60",
|
|
164
|
+
r: "56",
|
|
165
|
+
strokeWidth,
|
|
166
|
+
fill: "transparent"
|
|
167
|
+
}
|
|
168
|
+
),
|
|
169
|
+
strokeColor instanceof Object && renderConicGradient(),
|
|
170
|
+
strokeColor instanceof Object && renderForeignObject(),
|
|
171
|
+
/* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(
|
|
172
|
+
"circle",
|
|
173
|
+
__spreadProps(__spreadValues({
|
|
174
|
+
className: `${progressColor ? "" : `${prefixCls}-circle-path`}`,
|
|
175
|
+
cx: "60",
|
|
176
|
+
cy: "60",
|
|
177
|
+
r: "56",
|
|
178
|
+
strokeWidth
|
|
179
|
+
}, progressColor), {
|
|
180
|
+
fill: "transparent",
|
|
181
|
+
ref: path1Ref
|
|
182
|
+
})
|
|
183
|
+
), done && done.percent && /* @__PURE__ */ import_react.default.createElement(
|
|
184
|
+
"circle",
|
|
185
|
+
{
|
|
186
|
+
className: (0, import_clsx.default)(`${prefixCls}-circle-segment-path2`, {
|
|
187
|
+
[`${prefixCls}-circle-segment-done`]: done && done.percent
|
|
188
|
+
}),
|
|
189
|
+
cx: "60",
|
|
190
|
+
cy: "60",
|
|
191
|
+
r: "56",
|
|
192
|
+
strokeWidth,
|
|
193
|
+
fill: "transparent",
|
|
194
|
+
ref: path2Ref
|
|
195
|
+
}
|
|
196
|
+
))
|
|
197
|
+
),
|
|
187
198
|
showInfo && /* @__PURE__ */ import_react.default.createElement("span", { className: `${prefixCls}-text` }, children)
|
|
188
199
|
);
|
|
189
200
|
});
|
|
@@ -72,19 +72,28 @@ var Line = import_react.default.forwardRef((props, ref) => {
|
|
|
72
72
|
};
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
|
-
return /* @__PURE__ */ import_react.default.createElement("div", { className: `${prefixCls}-outer`, ref }, /* @__PURE__ */ import_react.default.createElement(
|
|
75
|
+
return /* @__PURE__ */ import_react.default.createElement("div", { className: `${prefixCls}-outer`, ref }, /* @__PURE__ */ import_react.default.createElement(
|
|
76
76
|
"div",
|
|
77
77
|
{
|
|
78
|
-
className: `${prefixCls}-
|
|
79
|
-
style:
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
78
|
+
className: `${prefixCls}-inner`,
|
|
79
|
+
style: { height: strokeWidth },
|
|
80
|
+
"aria-hidden": "true"
|
|
81
|
+
},
|
|
82
|
+
/* @__PURE__ */ import_react.default.createElement(
|
|
83
|
+
"div",
|
|
84
|
+
{
|
|
85
|
+
className: `${prefixCls}-bg`,
|
|
86
|
+
style: __spreadValues({ width: percent + "%" }, progressColor)
|
|
87
|
+
}
|
|
88
|
+
),
|
|
89
|
+
done && done.percent && /* @__PURE__ */ import_react.default.createElement(
|
|
90
|
+
"div",
|
|
91
|
+
{
|
|
92
|
+
className: `${prefixCls}-done-bg`,
|
|
93
|
+
style: { width: done.percent + "%" }
|
|
94
|
+
}
|
|
95
|
+
)
|
|
96
|
+
), showInfo && /* @__PURE__ */ import_react.default.createElement("span", { className: `${prefixCls}-text` }, children));
|
|
88
97
|
});
|
|
89
98
|
Line.displayName = "Line";
|
|
90
99
|
var line_default = Line;
|
|
@@ -34,9 +34,44 @@ __export(basic_exports, {
|
|
|
34
34
|
module.exports = __toCommonJS(basic_exports);
|
|
35
35
|
var import_react = __toESM(require("react"));
|
|
36
36
|
var import__ = __toESM(require("../index"));
|
|
37
|
+
var people = [
|
|
38
|
+
{ key: "ada", value: "ada", label: "Ada Lovelace" },
|
|
39
|
+
{ key: "grace", value: "grace", label: "Grace Hopper" },
|
|
40
|
+
{ key: "alan", value: "alan", label: "Alan Turing" },
|
|
41
|
+
{ key: "margaret", value: "margaret", label: "Margaret Hamilton" }
|
|
42
|
+
];
|
|
37
43
|
var basic_default = () => {
|
|
38
|
-
const
|
|
39
|
-
|
|
44
|
+
const [keyword, setKeyword] = (0, import_react.useState)("");
|
|
45
|
+
const [selected, setSelected] = (0, import_react.useState)(null);
|
|
46
|
+
const results = (0, import_react.useMemo)(() => {
|
|
47
|
+
const normalizedKeyword = keyword.trim().toLowerCase();
|
|
48
|
+
const matched = people.filter(
|
|
49
|
+
(person) => String(person.label).toLowerCase().includes(normalizedKeyword)
|
|
50
|
+
);
|
|
51
|
+
return matched.length > 0 ? matched : [
|
|
52
|
+
{
|
|
53
|
+
key: "empty",
|
|
54
|
+
value: "empty",
|
|
55
|
+
label: "No results found",
|
|
56
|
+
disabled: true
|
|
57
|
+
}
|
|
58
|
+
];
|
|
59
|
+
}, [keyword]);
|
|
60
|
+
const handleSelect = (option) => {
|
|
61
|
+
setSelected(option);
|
|
62
|
+
if (option) {
|
|
63
|
+
setKeyword(String(option.label));
|
|
64
|
+
}
|
|
40
65
|
};
|
|
41
|
-
return /* @__PURE__ */ import_react.default.createElement("div", { style: { width:
|
|
66
|
+
return /* @__PURE__ */ import_react.default.createElement("div", { style: { width: 320 } }, /* @__PURE__ */ import_react.default.createElement(
|
|
67
|
+
import__.default,
|
|
68
|
+
{
|
|
69
|
+
allowClear: true,
|
|
70
|
+
value: keyword,
|
|
71
|
+
options: results,
|
|
72
|
+
placeholder: "Search people",
|
|
73
|
+
onSearch: setKeyword,
|
|
74
|
+
onChange: handleSelect
|
|
75
|
+
}
|
|
76
|
+
), /* @__PURE__ */ import_react.default.createElement("div", { style: { marginTop: 12 } }, "Selected: ", selected ? String(selected.label) : "None"));
|
|
42
77
|
};
|
|
@@ -50,7 +50,7 @@ export interface SearchProps extends Omit<React.InputHTMLAttributes<HTMLInputEle
|
|
|
50
50
|
/**
|
|
51
51
|
* @description Suffix content
|
|
52
52
|
*/
|
|
53
|
-
suffix?: React.ReactNode;
|
|
53
|
+
suffix?: React.ReactNode | false;
|
|
54
54
|
/**
|
|
55
55
|
* @description Whether disabled
|
|
56
56
|
* @default false
|
|
@@ -74,7 +74,7 @@ export interface SearchProps extends Omit<React.InputHTMLAttributes<HTMLInputEle
|
|
|
74
74
|
* @description trigger search event
|
|
75
75
|
* @default 'typing'
|
|
76
76
|
*/
|
|
77
|
-
searchOnAction?: 'typing' | 'enter';
|
|
77
|
+
searchOnAction?: 'typing' | 'enter' | 'button';
|
|
78
78
|
/**
|
|
79
79
|
* @description suggest data
|
|
80
80
|
*/
|