antd-mobile 5.2.2 → 5.3.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/2x/cjs/components/date-picker/date-picker.js +3 -7
- package/2x/cjs/components/ellipsis/ellipsis.d.ts +2 -0
- package/2x/cjs/components/ellipsis/ellipsis.js +8 -5
- package/2x/cjs/components/form/context.d.ts +2 -1
- package/2x/cjs/components/form/context.js +6 -5
- package/2x/cjs/components/form/form-item.css +27 -1
- package/2x/cjs/components/form/form-item.d.ts +1 -0
- package/2x/cjs/components/form/form-item.js +44 -13
- package/2x/cjs/components/form/form.js +18 -9
- package/2x/cjs/components/form/index.css +27 -1
- package/2x/cjs/components/input/input.js +2 -2
- package/2x/cjs/components/pull-to-refresh/pull-to-refresh.js +1 -1
- package/2x/cjs/locales/base.d.ts +51 -0
- package/2x/cjs/locales/base.js +52 -0
- package/2x/cjs/locales/en-US.d.ts +51 -0
- package/2x/cjs/locales/zh-CN.d.ts +51 -0
- package/2x/cjs/locales/zh-CN.js +52 -0
- package/2x/es/components/date-picker/date-picker.js +3 -7
- package/2x/es/components/ellipsis/ellipsis.d.ts +2 -0
- package/2x/es/components/ellipsis/ellipsis.js +7 -5
- package/2x/es/components/form/context.d.ts +2 -1
- package/2x/es/components/form/context.js +4 -3
- package/2x/es/components/form/form-item.css +27 -1
- package/2x/es/components/form/form-item.d.ts +1 -0
- package/2x/es/components/form/form-item.js +43 -13
- package/2x/es/components/form/form.js +18 -11
- package/2x/es/components/form/index.css +27 -1
- package/2x/es/components/input/input.js +2 -2
- package/2x/es/components/pull-to-refresh/pull-to-refresh.js +1 -1
- package/2x/es/locales/base.d.ts +51 -0
- package/2x/es/locales/base.js +52 -0
- package/2x/es/locales/en-US.d.ts +51 -0
- package/2x/es/locales/zh-CN.d.ts +51 -0
- package/2x/es/locales/zh-CN.js +52 -0
- package/2x/package.json +4 -4
- package/cjs/components/date-picker/date-picker.js +3 -7
- package/cjs/components/ellipsis/ellipsis.d.ts +2 -0
- package/cjs/components/ellipsis/ellipsis.js +8 -5
- package/cjs/components/form/context.d.ts +2 -1
- package/cjs/components/form/context.js +6 -5
- package/cjs/components/form/form-item.css +21 -1
- package/cjs/components/form/form-item.d.ts +1 -0
- package/cjs/components/form/form-item.js +44 -13
- package/cjs/components/form/form.js +18 -9
- package/cjs/components/form/index.css +21 -1
- package/cjs/components/input/input.js +2 -2
- package/cjs/components/pull-to-refresh/pull-to-refresh.js +1 -1
- package/cjs/locales/base.d.ts +51 -0
- package/cjs/locales/base.js +52 -0
- package/cjs/locales/en-US.d.ts +51 -0
- package/cjs/locales/zh-CN.d.ts +51 -0
- package/cjs/locales/zh-CN.js +52 -0
- package/es/components/date-picker/date-picker.js +3 -7
- package/es/components/ellipsis/ellipsis.d.ts +2 -0
- package/es/components/ellipsis/ellipsis.js +7 -5
- package/es/components/form/context.d.ts +2 -1
- package/es/components/form/context.js +4 -3
- package/es/components/form/form-item.css +21 -1
- package/es/components/form/form-item.d.ts +1 -0
- package/es/components/form/form-item.js +43 -13
- package/es/components/form/form.js +18 -11
- package/es/components/form/index.css +21 -1
- package/es/components/input/input.js +2 -2
- package/es/components/pull-to-refresh/pull-to-refresh.js +1 -1
- package/es/locales/base.d.ts +51 -0
- package/es/locales/base.js +52 -0
- package/es/locales/en-US.d.ts +51 -0
- package/es/locales/zh-CN.d.ts +51 -0
- package/es/locales/zh-CN.js +52 -0
- package/package.json +4 -4
- package/umd/antd-mobile.js +1 -1
package/2x/es/locales/zh-CN.d.ts
CHANGED
|
@@ -31,6 +31,57 @@ declare const zhCN: {
|
|
|
31
31
|
description: string;
|
|
32
32
|
};
|
|
33
33
|
};
|
|
34
|
+
Form: {
|
|
35
|
+
required: string;
|
|
36
|
+
optional: string;
|
|
37
|
+
defaultValidateMessages: {
|
|
38
|
+
default: string;
|
|
39
|
+
required: string;
|
|
40
|
+
enum: string;
|
|
41
|
+
whitespace: string;
|
|
42
|
+
date: {
|
|
43
|
+
format: string;
|
|
44
|
+
parse: string;
|
|
45
|
+
invalid: string;
|
|
46
|
+
};
|
|
47
|
+
types: {
|
|
48
|
+
string: string;
|
|
49
|
+
method: string;
|
|
50
|
+
array: string;
|
|
51
|
+
object: string;
|
|
52
|
+
number: string;
|
|
53
|
+
date: string;
|
|
54
|
+
boolean: string;
|
|
55
|
+
integer: string;
|
|
56
|
+
float: string;
|
|
57
|
+
regexp: string;
|
|
58
|
+
email: string;
|
|
59
|
+
url: string;
|
|
60
|
+
hex: string;
|
|
61
|
+
};
|
|
62
|
+
string: {
|
|
63
|
+
len: string;
|
|
64
|
+
min: string;
|
|
65
|
+
max: string;
|
|
66
|
+
range: string;
|
|
67
|
+
};
|
|
68
|
+
number: {
|
|
69
|
+
len: string;
|
|
70
|
+
min: string;
|
|
71
|
+
max: string;
|
|
72
|
+
range: string;
|
|
73
|
+
};
|
|
74
|
+
array: {
|
|
75
|
+
len: string;
|
|
76
|
+
min: string;
|
|
77
|
+
max: string;
|
|
78
|
+
range: string;
|
|
79
|
+
};
|
|
80
|
+
pattern: {
|
|
81
|
+
mismatch: string;
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
};
|
|
34
85
|
ImageUploader: {
|
|
35
86
|
uploading: string;
|
|
36
87
|
};
|
package/2x/es/locales/zh-CN.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { mergeLocale } from '../utils/merge-locale';
|
|
2
2
|
import { base } from './base';
|
|
3
|
+
const typeTemplate = '${label}不是一个有效的${type}';
|
|
3
4
|
const zhCN = mergeLocale(base, {
|
|
4
5
|
common: {
|
|
5
6
|
confirm: '确定',
|
|
@@ -33,6 +34,57 @@ const zhCN = mergeLocale(base, {
|
|
|
33
34
|
description: '找找其他的吧'
|
|
34
35
|
}
|
|
35
36
|
},
|
|
37
|
+
Form: {
|
|
38
|
+
required: '必填',
|
|
39
|
+
optional: '选填',
|
|
40
|
+
defaultValidateMessages: {
|
|
41
|
+
default: '字段验证错误${label}',
|
|
42
|
+
required: '请输入${label}',
|
|
43
|
+
enum: '${label}必须是其中一个[${enum}]',
|
|
44
|
+
whitespace: '${label}不能为空字符',
|
|
45
|
+
date: {
|
|
46
|
+
format: '${label}日期格式无效',
|
|
47
|
+
parse: '${label}不能转换为日期',
|
|
48
|
+
invalid: '${label}是一个无效日期'
|
|
49
|
+
},
|
|
50
|
+
types: {
|
|
51
|
+
string: typeTemplate,
|
|
52
|
+
method: typeTemplate,
|
|
53
|
+
array: typeTemplate,
|
|
54
|
+
object: typeTemplate,
|
|
55
|
+
number: typeTemplate,
|
|
56
|
+
date: typeTemplate,
|
|
57
|
+
boolean: typeTemplate,
|
|
58
|
+
integer: typeTemplate,
|
|
59
|
+
float: typeTemplate,
|
|
60
|
+
regexp: typeTemplate,
|
|
61
|
+
email: typeTemplate,
|
|
62
|
+
url: typeTemplate,
|
|
63
|
+
hex: typeTemplate
|
|
64
|
+
},
|
|
65
|
+
string: {
|
|
66
|
+
len: '${label}须为${len}个字符',
|
|
67
|
+
min: '${label}最少${min}个字符',
|
|
68
|
+
max: '${label}最多${max}个字符',
|
|
69
|
+
range: '${label}须在${min}-${max}字符之间'
|
|
70
|
+
},
|
|
71
|
+
number: {
|
|
72
|
+
len: '${label}必须等于${len}',
|
|
73
|
+
min: '${label}最小值为${min}',
|
|
74
|
+
max: '${label}最大值为${max}',
|
|
75
|
+
range: '${label}须在${min}-${max}之间'
|
|
76
|
+
},
|
|
77
|
+
array: {
|
|
78
|
+
len: '须为${len}个${label}',
|
|
79
|
+
min: '最少${min}个${label}',
|
|
80
|
+
max: '最多${max}个${label}',
|
|
81
|
+
range: '${label}数量须在${min}-${max}之间'
|
|
82
|
+
},
|
|
83
|
+
pattern: {
|
|
84
|
+
mismatch: '${label}与模式不匹配${pattern}'
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
},
|
|
36
88
|
ImageUploader: {
|
|
37
89
|
uploading: '上传中...'
|
|
38
90
|
},
|
package/2x/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "antd-mobile",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.3.0",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"@react-spring/web": "^9.4.3",
|
|
6
6
|
"@types/resize-observer-browser": "^0.1.7",
|
|
7
|
-
"@use-gesture/react": "^10.2.
|
|
7
|
+
"@use-gesture/react": "^10.2.7",
|
|
8
8
|
"ahooks": "^3.1.10",
|
|
9
9
|
"antd-mobile-icons": "^0.2.2",
|
|
10
10
|
"antd-mobile-v5-count": "^1.0.1",
|
|
11
11
|
"classnames": "^2.3.1",
|
|
12
|
-
"dayjs": "^1.10.
|
|
12
|
+
"dayjs": "^1.10.8",
|
|
13
13
|
"lodash": "^4.17.21",
|
|
14
|
-
"rc-field-form": "^1.23.
|
|
14
|
+
"rc-field-form": "^1.23.1",
|
|
15
15
|
"rc-tooltip": "^5.1.1",
|
|
16
16
|
"staged-components": "^1.1.2",
|
|
17
17
|
"tslib": "^2.3.1",
|
|
@@ -50,14 +50,10 @@ const DatePicker = p => {
|
|
|
50
50
|
});
|
|
51
51
|
const now = (0, _react.useMemo)(() => new Date(), []);
|
|
52
52
|
const pickerValue = (0, _react.useMemo)(() => {
|
|
53
|
-
let date = value;
|
|
54
|
-
|
|
55
|
-
if (date === null) {
|
|
56
|
-
date = new Date((0, _bound.bound)(now.getTime(), props.min.getTime(), props.max.getTime()));
|
|
57
|
-
}
|
|
58
|
-
|
|
53
|
+
let date = value !== null && value !== void 0 ? value : now;
|
|
54
|
+
date = new Date((0, _bound.bound)(date.getTime(), props.min.getTime(), props.max.getTime()));
|
|
59
55
|
return (0, _datePickerUtils.convertDateToStringArray)(date, props.precision);
|
|
60
|
-
}, [value, props.precision]);
|
|
56
|
+
}, [value, props.precision, props.min, props.max]);
|
|
61
57
|
const onConfirm = (0, _react.useCallback)(val => {
|
|
62
58
|
setValue((0, _datePickerUtils.convertStringArrayToDate)(val, props.precision));
|
|
63
59
|
}, [setValue, props.precision]);
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
2
|
import { NativeProps } from '../../utils/native-props';
|
|
3
|
+
import { PropagationEvent } from '../../utils/with-stop-propagation';
|
|
3
4
|
export declare type EllipsisProps = {
|
|
4
5
|
content: string;
|
|
5
6
|
direction?: 'start' | 'end' | 'middle';
|
|
6
7
|
rows?: number;
|
|
7
8
|
expandText?: string;
|
|
8
9
|
collapseText?: string;
|
|
10
|
+
stopPropagationForActionButtons?: PropagationEvent[];
|
|
9
11
|
} & NativeProps;
|
|
10
12
|
export declare const Ellipsis: FC<EllipsisProps>;
|
|
@@ -15,6 +15,8 @@ var _useResizeEffect = require("../../utils/use-resize-effect");
|
|
|
15
15
|
|
|
16
16
|
var _ahooks = require("ahooks");
|
|
17
17
|
|
|
18
|
+
var _withStopPropagation = require("../../utils/with-stop-propagation");
|
|
19
|
+
|
|
18
20
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
19
21
|
|
|
20
22
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -24,7 +26,8 @@ const defaultProps = {
|
|
|
24
26
|
direction: 'end',
|
|
25
27
|
rows: 1,
|
|
26
28
|
expandText: '',
|
|
27
|
-
collapseText: ''
|
|
29
|
+
collapseText: '',
|
|
30
|
+
stopPropagationForActionButtons: []
|
|
28
31
|
};
|
|
29
32
|
|
|
30
33
|
const Ellipsis = p => {
|
|
@@ -134,16 +137,16 @@ const Ellipsis = p => {
|
|
|
134
137
|
(0, _ahooks.useIsomorphicLayoutEffect)(() => {
|
|
135
138
|
calcEllipsised();
|
|
136
139
|
}, [props.content, props.direction, props.rows, props.expandText, props.collapseText]);
|
|
137
|
-
const expandActionElement = exceeded && props.expandText ? _react.default.createElement("a", {
|
|
140
|
+
const expandActionElement = exceeded && props.expandText ? (0, _withStopPropagation.withStopPropagation)(props.stopPropagationForActionButtons, _react.default.createElement("a", {
|
|
138
141
|
onClick: () => {
|
|
139
142
|
setExpanded(true);
|
|
140
143
|
}
|
|
141
|
-
}, props.expandText) : null;
|
|
142
|
-
const collapseActionElement = exceeded && props.expandText ? _react.default.createElement("a", {
|
|
144
|
+
}, props.expandText)) : null;
|
|
145
|
+
const collapseActionElement = exceeded && props.expandText ? (0, _withStopPropagation.withStopPropagation)(props.stopPropagationForActionButtons, _react.default.createElement("a", {
|
|
143
146
|
onClick: () => {
|
|
144
147
|
setExpanded(false);
|
|
145
148
|
}
|
|
146
|
-
}, props.collapseText) : null;
|
|
149
|
+
}, props.collapseText)) : null;
|
|
147
150
|
|
|
148
151
|
const renderContent = () => {
|
|
149
152
|
if (!exceeded) {
|
|
@@ -4,8 +4,9 @@ import type { Meta, InternalNamePath } from 'rc-field-form/lib/interface';
|
|
|
4
4
|
export declare type FormContextType = {
|
|
5
5
|
hasFeedback: boolean;
|
|
6
6
|
layout: FormLayout;
|
|
7
|
+
requiredMarkStyle: 'asterisk' | 'text-required' | 'text-optional';
|
|
7
8
|
};
|
|
8
|
-
export declare const
|
|
9
|
+
export declare const defaultFormContext: FormContextType;
|
|
9
10
|
export declare const FormContext: React.Context<FormContextType>;
|
|
10
11
|
export declare type OnSubMetaChange = (meta: Meta & {
|
|
11
12
|
destroy?: boolean;
|
|
@@ -3,19 +3,20 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.defaultFormContext = exports.NoStyleItemContext = exports.FormContext = void 0;
|
|
7
7
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
|
|
10
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
11
|
|
|
12
|
-
const
|
|
12
|
+
const defaultFormContext = {
|
|
13
13
|
hasFeedback: true,
|
|
14
|
-
layout: 'vertical'
|
|
14
|
+
layout: 'vertical',
|
|
15
|
+
requiredMarkStyle: 'asterisk'
|
|
15
16
|
};
|
|
16
|
-
exports.
|
|
17
|
+
exports.defaultFormContext = defaultFormContext;
|
|
17
18
|
|
|
18
|
-
const FormContext = _react.default.createContext(
|
|
19
|
+
const FormContext = _react.default.createContext(defaultFormContext);
|
|
19
20
|
|
|
20
21
|
exports.FormContext = FormContext;
|
|
21
22
|
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
position: relative;
|
|
10
10
|
color: #666666;
|
|
11
11
|
}
|
|
12
|
-
.adm-form-item-label-required {
|
|
12
|
+
.adm-form-item-label .adm-form-item-required-asterisk {
|
|
13
13
|
position: absolute;
|
|
14
14
|
left: -0.6em;
|
|
15
15
|
top: 0;
|
|
@@ -17,8 +17,28 @@
|
|
|
17
17
|
color: var(--adm-color-danger);
|
|
18
18
|
user-select: none;
|
|
19
19
|
}
|
|
20
|
+
.adm-form-item-label .adm-form-item-required-text {
|
|
21
|
+
margin-left: 4px;
|
|
22
|
+
color: var(--adm-color-weak);
|
|
23
|
+
}
|
|
20
24
|
.adm-form-item-label-help {
|
|
21
25
|
margin-left: 4px;
|
|
26
|
+
cursor: pointer;
|
|
27
|
+
}
|
|
28
|
+
.adm-form-item-child {
|
|
29
|
+
display: flex;
|
|
30
|
+
}
|
|
31
|
+
.adm-form-item-child-position-normal {
|
|
32
|
+
justify-content: normal;
|
|
33
|
+
}
|
|
34
|
+
.adm-form-item-child-position-normal > * {
|
|
35
|
+
flex: auto;
|
|
36
|
+
}
|
|
37
|
+
.adm-form-item-child-position-right {
|
|
38
|
+
justify-content: right;
|
|
39
|
+
}
|
|
40
|
+
.adm-form-item-child-position-right > * {
|
|
41
|
+
flex: none;
|
|
22
42
|
}
|
|
23
43
|
.adm-form-item-footer {
|
|
24
44
|
color: var(--adm-color-danger);
|
|
@@ -16,6 +16,7 @@ export declare type FormItemProps = Pick<RcFieldProps, 'dependencies' | 'valuePr
|
|
|
16
16
|
disabled?: boolean;
|
|
17
17
|
hidden?: boolean;
|
|
18
18
|
layout?: FormLayout;
|
|
19
|
+
childElementPosition?: 'normal' | 'right';
|
|
19
20
|
children: ChildrenType;
|
|
20
21
|
} & NativeProps;
|
|
21
22
|
export declare const FormItem: FC<FormItemProps>;
|
|
@@ -27,6 +27,8 @@ var _popover = _interopRequireDefault(require("../popover"));
|
|
|
27
27
|
|
|
28
28
|
var _antdMobileIcons = require("antd-mobile-icons");
|
|
29
29
|
|
|
30
|
+
var _configProvider = require("../config-provider");
|
|
31
|
+
|
|
30
32
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
31
33
|
|
|
32
34
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
@@ -54,18 +56,47 @@ const FormItemLayout = props => {
|
|
|
54
56
|
hidden,
|
|
55
57
|
errors,
|
|
56
58
|
arrow,
|
|
57
|
-
description
|
|
59
|
+
description,
|
|
60
|
+
childElementPosition = 'normal'
|
|
58
61
|
} = props;
|
|
59
62
|
const context = (0, _react.useContext)(_context.FormContext);
|
|
63
|
+
const {
|
|
64
|
+
locale
|
|
65
|
+
} = (0, _configProvider.useConfig)();
|
|
60
66
|
const hasFeedback = props.hasFeedback !== undefined ? props.hasFeedback : context.hasFeedback;
|
|
61
67
|
const layout = props.layout || context.layout;
|
|
62
68
|
const feedback = hasFeedback && errors && errors.length > 0 ? errors[0] : null;
|
|
69
|
+
|
|
70
|
+
const requiredMark = (() => {
|
|
71
|
+
const {
|
|
72
|
+
requiredMarkStyle
|
|
73
|
+
} = context;
|
|
74
|
+
|
|
75
|
+
switch (requiredMarkStyle) {
|
|
76
|
+
case 'asterisk':
|
|
77
|
+
return required && _react.default.createElement("span", {
|
|
78
|
+
className: `${classPrefix}-required-asterisk`
|
|
79
|
+
}, "*");
|
|
80
|
+
|
|
81
|
+
case 'text-required':
|
|
82
|
+
return required && _react.default.createElement("span", {
|
|
83
|
+
className: `${classPrefix}-required-text`
|
|
84
|
+
}, "(", locale.Form.required, ")");
|
|
85
|
+
|
|
86
|
+
case 'text-optional':
|
|
87
|
+
return !required && _react.default.createElement("span", {
|
|
88
|
+
className: `${classPrefix}-required-text`
|
|
89
|
+
}, "(", locale.Form.optional, ")");
|
|
90
|
+
|
|
91
|
+
default:
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
})();
|
|
95
|
+
|
|
63
96
|
const labelElement = label ? _react.default.createElement("label", {
|
|
64
97
|
className: `${classPrefix}-label`,
|
|
65
98
|
htmlFor: htmlFor
|
|
66
|
-
}, label,
|
|
67
|
-
className: `${classPrefix}-label-required`
|
|
68
|
-
}, "*"), help && _react.default.createElement("span", {
|
|
99
|
+
}, label, requiredMark, help && _react.default.createElement("span", {
|
|
69
100
|
className: `${classPrefix}-label-help`
|
|
70
101
|
}, _react.default.createElement(_popover.default, {
|
|
71
102
|
content: help,
|
|
@@ -87,7 +118,11 @@ const FormItemLayout = props => {
|
|
|
87
118
|
disabled: disabled,
|
|
88
119
|
onClick: props.onClick,
|
|
89
120
|
arrow: arrow
|
|
90
|
-
},
|
|
121
|
+
}, _react.default.createElement("div", {
|
|
122
|
+
className: (0, _classnames.default)(`${classPrefix}-child`, `${classPrefix}-child-position-${childElementPosition}`)
|
|
123
|
+
}, _react.default.createElement("div", {
|
|
124
|
+
className: (0, _classnames.default)(`${classPrefix}-child-inner`)
|
|
125
|
+
}, children)));
|
|
91
126
|
};
|
|
92
127
|
|
|
93
128
|
const FormItem = props => {
|
|
@@ -105,6 +140,7 @@ const FormItem = props => {
|
|
|
105
140
|
noStyle,
|
|
106
141
|
hidden,
|
|
107
142
|
layout,
|
|
143
|
+
childElementPosition,
|
|
108
144
|
description,
|
|
109
145
|
// Field 相关
|
|
110
146
|
disabled,
|
|
@@ -118,7 +154,7 @@ const FormItem = props => {
|
|
|
118
154
|
dependencies,
|
|
119
155
|
arrow
|
|
120
156
|
} = props,
|
|
121
|
-
fieldProps = (0, _tslib.__rest)(props, ["className", "style", "label", "help", "extra", "hasFeedback", "name", "required", "noStyle", "hidden", "layout", "description", "disabled", "rules", "children", "messageVariables", "trigger", "validateTrigger", "onClick", "shouldUpdate", "dependencies", "arrow"]);
|
|
157
|
+
fieldProps = (0, _tslib.__rest)(props, ["className", "style", "label", "help", "extra", "hasFeedback", "name", "required", "noStyle", "hidden", "layout", "childElementPosition", "description", "disabled", "rules", "children", "messageVariables", "trigger", "validateTrigger", "onClick", "shouldUpdate", "dependencies", "arrow"]);
|
|
122
158
|
|
|
123
159
|
const {
|
|
124
160
|
validateTrigger: contextValidateTrigger
|
|
@@ -179,6 +215,7 @@ const FormItem = props => {
|
|
|
179
215
|
onClick: onClick,
|
|
180
216
|
hidden: hidden,
|
|
181
217
|
layout: layout,
|
|
218
|
+
childElementPosition: childElementPosition,
|
|
182
219
|
arrow: arrow
|
|
183
220
|
}, _react.default.createElement(_context.NoStyleItemContext.Provider, {
|
|
184
221
|
value: onSubMetaChange
|
|
@@ -221,13 +258,7 @@ const FormItem = props => {
|
|
|
221
258
|
messageVariables: Variables
|
|
222
259
|
}), (control, meta, context) => {
|
|
223
260
|
let childNode = null;
|
|
224
|
-
const isRequired = required !== undefined ? required :
|
|
225
|
-
if (rule && typeof rule === 'object' && rule.required) {
|
|
226
|
-
return true;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
return false;
|
|
230
|
-
}));
|
|
261
|
+
const isRequired = required !== undefined ? required : rules && rules.some(rule => !!(rule && typeof rule === 'object' && rule.required));
|
|
231
262
|
const fieldId = ((0, _utils.toArray)(name).length && meta ? meta.name : []).join('_');
|
|
232
263
|
|
|
233
264
|
if (shouldUpdate && dependencies) {
|
|
@@ -21,6 +21,10 @@ var _withDefaultProps = require("../../utils/with-default-props");
|
|
|
21
21
|
|
|
22
22
|
var _header = require("./header");
|
|
23
23
|
|
|
24
|
+
var _configProvider = require("../config-provider");
|
|
25
|
+
|
|
26
|
+
var _merge = _interopRequireDefault(require("lodash/merge"));
|
|
27
|
+
|
|
24
28
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
29
|
|
|
26
30
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
@@ -28,10 +32,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
28
32
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
29
33
|
|
|
30
34
|
const classPrefix = 'adm-form';
|
|
31
|
-
const defaultProps =
|
|
32
|
-
hasFeedback: true,
|
|
33
|
-
layout: 'vertical'
|
|
34
|
-
};
|
|
35
|
+
const defaultProps = _context.defaultFormContext;
|
|
35
36
|
const Form = (0, _react.forwardRef)((p, ref) => {
|
|
36
37
|
const props = (0, _withDefaultProps.mergeProps)(defaultProps, p);
|
|
37
38
|
const {
|
|
@@ -41,9 +42,14 @@ const Form = (0, _react.forwardRef)((p, ref) => {
|
|
|
41
42
|
children,
|
|
42
43
|
layout,
|
|
43
44
|
footer,
|
|
44
|
-
mode
|
|
45
|
+
mode,
|
|
46
|
+
requiredMarkStyle
|
|
45
47
|
} = props,
|
|
46
|
-
formProps = (0, _tslib.__rest)(props, ["className", "style", "hasFeedback", "children", "layout", "footer", "mode"]);
|
|
48
|
+
formProps = (0, _tslib.__rest)(props, ["className", "style", "hasFeedback", "children", "layout", "footer", "mode", "requiredMarkStyle"]);
|
|
49
|
+
const {
|
|
50
|
+
locale
|
|
51
|
+
} = (0, _configProvider.useConfig)();
|
|
52
|
+
const validateMessages = (0, _react.useMemo)(() => (0, _merge.default)({}, locale.Form.defaultValidateMessages, formProps.validateMessages), [locale.Form.defaultValidateMessages, formProps.validateMessages]);
|
|
47
53
|
const lists = [];
|
|
48
54
|
let currentHeader = null;
|
|
49
55
|
let items = [];
|
|
@@ -74,10 +80,13 @@ const Form = (0, _react.forwardRef)((p, ref) => {
|
|
|
74
80
|
className: (0, _classnames.default)(classPrefix, className),
|
|
75
81
|
style: style,
|
|
76
82
|
ref: ref
|
|
77
|
-
}, formProps
|
|
83
|
+
}, formProps, {
|
|
84
|
+
validateMessages: validateMessages
|
|
85
|
+
}), _react.default.createElement(_context.FormContext.Provider, {
|
|
78
86
|
value: {
|
|
79
|
-
hasFeedback
|
|
80
|
-
layout
|
|
87
|
+
hasFeedback,
|
|
88
|
+
layout,
|
|
89
|
+
requiredMarkStyle
|
|
81
90
|
}
|
|
82
91
|
}, lists), footer && _react.default.createElement("div", {
|
|
83
92
|
className: `${classPrefix}-footer`
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
position: relative;
|
|
28
28
|
color: #666666;
|
|
29
29
|
}
|
|
30
|
-
.adm-form-item-label-required {
|
|
30
|
+
.adm-form-item-label .adm-form-item-required-asterisk {
|
|
31
31
|
position: absolute;
|
|
32
32
|
left: -0.6em;
|
|
33
33
|
top: 0;
|
|
@@ -35,8 +35,28 @@
|
|
|
35
35
|
color: var(--adm-color-danger);
|
|
36
36
|
user-select: none;
|
|
37
37
|
}
|
|
38
|
+
.adm-form-item-label .adm-form-item-required-text {
|
|
39
|
+
margin-left: 4px;
|
|
40
|
+
color: var(--adm-color-weak);
|
|
41
|
+
}
|
|
38
42
|
.adm-form-item-label-help {
|
|
39
43
|
margin-left: 4px;
|
|
44
|
+
cursor: pointer;
|
|
45
|
+
}
|
|
46
|
+
.adm-form-item-child {
|
|
47
|
+
display: flex;
|
|
48
|
+
}
|
|
49
|
+
.adm-form-item-child-position-normal {
|
|
50
|
+
justify-content: normal;
|
|
51
|
+
}
|
|
52
|
+
.adm-form-item-child-position-normal > * {
|
|
53
|
+
flex: auto;
|
|
54
|
+
}
|
|
55
|
+
.adm-form-item-child-position-right {
|
|
56
|
+
justify-content: right;
|
|
57
|
+
}
|
|
58
|
+
.adm-form-item-child-position-right > * {
|
|
59
|
+
flex: none;
|
|
40
60
|
}
|
|
41
61
|
.adm-form-item-footer {
|
|
42
62
|
color: var(--adm-color-danger);
|
|
@@ -78,7 +78,7 @@ const Input = (0, _react.forwardRef)((p, ref) => {
|
|
|
78
78
|
let nextValue = value;
|
|
79
79
|
|
|
80
80
|
if (props.type === 'number') {
|
|
81
|
-
nextValue = (0, _bound.bound)(parseFloat(nextValue), props.min, props.max).toString();
|
|
81
|
+
nextValue = nextValue && (0, _bound.bound)(parseFloat(nextValue), props.min, props.max).toString();
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
if (nextValue !== value) {
|
|
@@ -126,7 +126,7 @@ const Input = (0, _react.forwardRef)((p, ref) => {
|
|
|
126
126
|
onKeyUp: props.onKeyUp,
|
|
127
127
|
onCompositionStart: props.onCompositionStart,
|
|
128
128
|
onCompositionEnd: props.onCompositionEnd
|
|
129
|
-
}), props.clearable && !!value && !props.readOnly && _react.default.createElement("div", {
|
|
129
|
+
}), props.clearable && !!value && !props.readOnly && hasFocus && _react.default.createElement("div", {
|
|
130
130
|
className: `${classPrefix}-clear`,
|
|
131
131
|
onMouseDown: e => {
|
|
132
132
|
e.preventDefault();
|
|
@@ -131,7 +131,7 @@ const PullToRefresh = p => {
|
|
|
131
131
|
if (!element) return;
|
|
132
132
|
const scrollParent = (0, _getScrollParent.getScrollParent)(element);
|
|
133
133
|
if (!scrollParent) return;
|
|
134
|
-
const top = 'scrollTop' in scrollParent ? scrollParent.scrollTop : scrollParent.
|
|
134
|
+
const top = 'scrollTop' in scrollParent ? scrollParent.scrollTop : scrollParent.scrollY;
|
|
135
135
|
|
|
136
136
|
if (top <= 0 && y > 0) {
|
|
137
137
|
pullingRef.current = true;
|
package/cjs/locales/base.d.ts
CHANGED
|
@@ -31,6 +31,57 @@ export declare const base: {
|
|
|
31
31
|
description: string;
|
|
32
32
|
};
|
|
33
33
|
};
|
|
34
|
+
Form: {
|
|
35
|
+
required: string;
|
|
36
|
+
optional: string;
|
|
37
|
+
defaultValidateMessages: {
|
|
38
|
+
default: string;
|
|
39
|
+
required: string;
|
|
40
|
+
enum: string;
|
|
41
|
+
whitespace: string;
|
|
42
|
+
date: {
|
|
43
|
+
format: string;
|
|
44
|
+
parse: string;
|
|
45
|
+
invalid: string;
|
|
46
|
+
};
|
|
47
|
+
types: {
|
|
48
|
+
string: string;
|
|
49
|
+
method: string;
|
|
50
|
+
array: string;
|
|
51
|
+
object: string;
|
|
52
|
+
number: string;
|
|
53
|
+
date: string;
|
|
54
|
+
boolean: string;
|
|
55
|
+
integer: string;
|
|
56
|
+
float: string;
|
|
57
|
+
regexp: string;
|
|
58
|
+
email: string;
|
|
59
|
+
url: string;
|
|
60
|
+
hex: string;
|
|
61
|
+
};
|
|
62
|
+
string: {
|
|
63
|
+
len: string;
|
|
64
|
+
min: string;
|
|
65
|
+
max: string;
|
|
66
|
+
range: string;
|
|
67
|
+
};
|
|
68
|
+
number: {
|
|
69
|
+
len: string;
|
|
70
|
+
min: string;
|
|
71
|
+
max: string;
|
|
72
|
+
range: string;
|
|
73
|
+
};
|
|
74
|
+
array: {
|
|
75
|
+
len: string;
|
|
76
|
+
min: string;
|
|
77
|
+
max: string;
|
|
78
|
+
range: string;
|
|
79
|
+
};
|
|
80
|
+
pattern: {
|
|
81
|
+
mismatch: string;
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
};
|
|
34
85
|
ImageUploader: {
|
|
35
86
|
uploading: string;
|
|
36
87
|
};
|
package/cjs/locales/base.js
CHANGED
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.base = void 0;
|
|
7
|
+
const typeTemplate = '${label} is not a valid ${type}';
|
|
7
8
|
const base = {
|
|
8
9
|
common: {
|
|
9
10
|
confirm: 'Confirm',
|
|
@@ -37,6 +38,57 @@ const base = {
|
|
|
37
38
|
description: 'Want to try a new search?'
|
|
38
39
|
}
|
|
39
40
|
},
|
|
41
|
+
Form: {
|
|
42
|
+
required: 'Required',
|
|
43
|
+
optional: 'Optional',
|
|
44
|
+
defaultValidateMessages: {
|
|
45
|
+
default: 'Field validation error for ${label}',
|
|
46
|
+
required: 'Please enter ${label}',
|
|
47
|
+
enum: '${label} must be one of [${enum}]',
|
|
48
|
+
whitespace: '${label} cannot be a blank character',
|
|
49
|
+
date: {
|
|
50
|
+
format: '${label} date format is invalid',
|
|
51
|
+
parse: '${label} cannot be converted to a date',
|
|
52
|
+
invalid: '${label} is an invalid date'
|
|
53
|
+
},
|
|
54
|
+
types: {
|
|
55
|
+
string: typeTemplate,
|
|
56
|
+
method: typeTemplate,
|
|
57
|
+
array: typeTemplate,
|
|
58
|
+
object: typeTemplate,
|
|
59
|
+
number: typeTemplate,
|
|
60
|
+
date: typeTemplate,
|
|
61
|
+
boolean: typeTemplate,
|
|
62
|
+
integer: typeTemplate,
|
|
63
|
+
float: typeTemplate,
|
|
64
|
+
regexp: typeTemplate,
|
|
65
|
+
email: typeTemplate,
|
|
66
|
+
url: typeTemplate,
|
|
67
|
+
hex: typeTemplate
|
|
68
|
+
},
|
|
69
|
+
string: {
|
|
70
|
+
len: '${label} must be ${len} characters',
|
|
71
|
+
min: '${label} must be at least ${min} characters',
|
|
72
|
+
max: '${label} must be up to ${max} characters',
|
|
73
|
+
range: '${label} must be between ${min}-${max} characters'
|
|
74
|
+
},
|
|
75
|
+
number: {
|
|
76
|
+
len: '${label} must be equal to ${len}',
|
|
77
|
+
min: '${label} must be minimum ${min}',
|
|
78
|
+
max: '${label} must be maximum ${max}',
|
|
79
|
+
range: '${label} must be between ${min}-${max}'
|
|
80
|
+
},
|
|
81
|
+
array: {
|
|
82
|
+
len: 'Must be ${len} ${label}',
|
|
83
|
+
min: 'At least ${min} ${label}',
|
|
84
|
+
max: 'At most ${max} ${label}',
|
|
85
|
+
range: 'The amount of ${label} must be between ${min}-${max}'
|
|
86
|
+
},
|
|
87
|
+
pattern: {
|
|
88
|
+
mismatch: '${label} does not match the pattern ${pattern}'
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
},
|
|
40
92
|
ImageUploader: {
|
|
41
93
|
uploading: 'Uploading...'
|
|
42
94
|
},
|