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.
Files changed (71) hide show
  1. package/2x/cjs/components/date-picker/date-picker.js +3 -7
  2. package/2x/cjs/components/ellipsis/ellipsis.d.ts +2 -0
  3. package/2x/cjs/components/ellipsis/ellipsis.js +8 -5
  4. package/2x/cjs/components/form/context.d.ts +2 -1
  5. package/2x/cjs/components/form/context.js +6 -5
  6. package/2x/cjs/components/form/form-item.css +27 -1
  7. package/2x/cjs/components/form/form-item.d.ts +1 -0
  8. package/2x/cjs/components/form/form-item.js +44 -13
  9. package/2x/cjs/components/form/form.js +18 -9
  10. package/2x/cjs/components/form/index.css +27 -1
  11. package/2x/cjs/components/input/input.js +2 -2
  12. package/2x/cjs/components/pull-to-refresh/pull-to-refresh.js +1 -1
  13. package/2x/cjs/locales/base.d.ts +51 -0
  14. package/2x/cjs/locales/base.js +52 -0
  15. package/2x/cjs/locales/en-US.d.ts +51 -0
  16. package/2x/cjs/locales/zh-CN.d.ts +51 -0
  17. package/2x/cjs/locales/zh-CN.js +52 -0
  18. package/2x/es/components/date-picker/date-picker.js +3 -7
  19. package/2x/es/components/ellipsis/ellipsis.d.ts +2 -0
  20. package/2x/es/components/ellipsis/ellipsis.js +7 -5
  21. package/2x/es/components/form/context.d.ts +2 -1
  22. package/2x/es/components/form/context.js +4 -3
  23. package/2x/es/components/form/form-item.css +27 -1
  24. package/2x/es/components/form/form-item.d.ts +1 -0
  25. package/2x/es/components/form/form-item.js +43 -13
  26. package/2x/es/components/form/form.js +18 -11
  27. package/2x/es/components/form/index.css +27 -1
  28. package/2x/es/components/input/input.js +2 -2
  29. package/2x/es/components/pull-to-refresh/pull-to-refresh.js +1 -1
  30. package/2x/es/locales/base.d.ts +51 -0
  31. package/2x/es/locales/base.js +52 -0
  32. package/2x/es/locales/en-US.d.ts +51 -0
  33. package/2x/es/locales/zh-CN.d.ts +51 -0
  34. package/2x/es/locales/zh-CN.js +52 -0
  35. package/2x/package.json +4 -4
  36. package/cjs/components/date-picker/date-picker.js +3 -7
  37. package/cjs/components/ellipsis/ellipsis.d.ts +2 -0
  38. package/cjs/components/ellipsis/ellipsis.js +8 -5
  39. package/cjs/components/form/context.d.ts +2 -1
  40. package/cjs/components/form/context.js +6 -5
  41. package/cjs/components/form/form-item.css +21 -1
  42. package/cjs/components/form/form-item.d.ts +1 -0
  43. package/cjs/components/form/form-item.js +44 -13
  44. package/cjs/components/form/form.js +18 -9
  45. package/cjs/components/form/index.css +21 -1
  46. package/cjs/components/input/input.js +2 -2
  47. package/cjs/components/pull-to-refresh/pull-to-refresh.js +1 -1
  48. package/cjs/locales/base.d.ts +51 -0
  49. package/cjs/locales/base.js +52 -0
  50. package/cjs/locales/en-US.d.ts +51 -0
  51. package/cjs/locales/zh-CN.d.ts +51 -0
  52. package/cjs/locales/zh-CN.js +52 -0
  53. package/es/components/date-picker/date-picker.js +3 -7
  54. package/es/components/ellipsis/ellipsis.d.ts +2 -0
  55. package/es/components/ellipsis/ellipsis.js +7 -5
  56. package/es/components/form/context.d.ts +2 -1
  57. package/es/components/form/context.js +4 -3
  58. package/es/components/form/form-item.css +21 -1
  59. package/es/components/form/form-item.d.ts +1 -0
  60. package/es/components/form/form-item.js +43 -13
  61. package/es/components/form/form.js +18 -11
  62. package/es/components/form/index.css +21 -1
  63. package/es/components/input/input.js +2 -2
  64. package/es/components/pull-to-refresh/pull-to-refresh.js +1 -1
  65. package/es/locales/base.d.ts +51 -0
  66. package/es/locales/base.js +52 -0
  67. package/es/locales/en-US.d.ts +51 -0
  68. package/es/locales/zh-CN.d.ts +51 -0
  69. package/es/locales/zh-CN.js +52 -0
  70. package/package.json +4 -4
  71. package/umd/antd-mobile.js +1 -1
@@ -31,6 +31,57 @@ declare const enUS: {
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
  };
@@ -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
  };
@@ -9,6 +9,7 @@ var _mergeLocale = require("../utils/merge-locale");
9
9
 
10
10
  var _base = require("./base");
11
11
 
12
+ const typeTemplate = '${label}不是一个有效的${type}';
12
13
  const zhCN = (0, _mergeLocale.mergeLocale)(_base.base, {
13
14
  common: {
14
15
  confirm: '确定',
@@ -42,6 +43,57 @@ const zhCN = (0, _mergeLocale.mergeLocale)(_base.base, {
42
43
  description: '找找其他的吧'
43
44
  }
44
45
  },
46
+ Form: {
47
+ required: '必填',
48
+ optional: '选填',
49
+ defaultValidateMessages: {
50
+ default: '字段验证错误${label}',
51
+ required: '请输入${label}',
52
+ enum: '${label}必须是其中一个[${enum}]',
53
+ whitespace: '${label}不能为空字符',
54
+ date: {
55
+ format: '${label}日期格式无效',
56
+ parse: '${label}不能转换为日期',
57
+ invalid: '${label}是一个无效日期'
58
+ },
59
+ types: {
60
+ string: typeTemplate,
61
+ method: typeTemplate,
62
+ array: typeTemplate,
63
+ object: typeTemplate,
64
+ number: typeTemplate,
65
+ date: typeTemplate,
66
+ boolean: typeTemplate,
67
+ integer: typeTemplate,
68
+ float: typeTemplate,
69
+ regexp: typeTemplate,
70
+ email: typeTemplate,
71
+ url: typeTemplate,
72
+ hex: typeTemplate
73
+ },
74
+ string: {
75
+ len: '${label}须为${len}个字符',
76
+ min: '${label}最少${min}个字符',
77
+ max: '${label}最多${max}个字符',
78
+ range: '${label}须在${min}-${max}字符之间'
79
+ },
80
+ number: {
81
+ len: '${label}必须等于${len}',
82
+ min: '${label}最小值为${min}',
83
+ max: '${label}最大值为${max}',
84
+ range: '${label}须在${min}-${max}之间'
85
+ },
86
+ array: {
87
+ len: '须为${len}个${label}',
88
+ min: '最少${min}个${label}',
89
+ max: '最多${max}个${label}',
90
+ range: '${label}数量须在${min}-${max}之间'
91
+ },
92
+ pattern: {
93
+ mismatch: '${label}与模式不匹配${pattern}'
94
+ }
95
+ }
96
+ },
45
97
  ImageUploader: {
46
98
  uploading: '上传中...'
47
99
  },
@@ -28,14 +28,10 @@ export const DatePicker = p => {
28
28
  });
29
29
  const now = useMemo(() => new Date(), []);
30
30
  const pickerValue = useMemo(() => {
31
- let date = value;
32
-
33
- if (date === null) {
34
- date = new Date(bound(now.getTime(), props.min.getTime(), props.max.getTime()));
35
- }
36
-
31
+ let date = value !== null && value !== void 0 ? value : now;
32
+ date = new Date(bound(date.getTime(), props.min.getTime(), props.max.getTime()));
37
33
  return convertDateToStringArray(date, props.precision);
38
- }, [value, props.precision]);
34
+ }, [value, props.precision, props.min, props.max]);
39
35
  const onConfirm = useCallback(val => {
40
36
  setValue(convertStringArrayToDate(val, props.precision));
41
37
  }, [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>;
@@ -3,12 +3,14 @@ import { mergeProps } from '../../utils/with-default-props';
3
3
  import { withNativeProps } from '../../utils/native-props';
4
4
  import { useResizeEffect } from '../../utils/use-resize-effect';
5
5
  import { useIsomorphicLayoutEffect } from 'ahooks';
6
+ import { withStopPropagation } from '../../utils/with-stop-propagation';
6
7
  const classPrefix = `adm-ellipsis`;
7
8
  const defaultProps = {
8
9
  direction: 'end',
9
10
  rows: 1,
10
11
  expandText: '',
11
- collapseText: ''
12
+ collapseText: '',
13
+ stopPropagationForActionButtons: []
12
14
  };
13
15
  export const Ellipsis = p => {
14
16
  const props = mergeProps(defaultProps, p);
@@ -117,16 +119,16 @@ export const Ellipsis = p => {
117
119
  useIsomorphicLayoutEffect(() => {
118
120
  calcEllipsised();
119
121
  }, [props.content, props.direction, props.rows, props.expandText, props.collapseText]);
120
- const expandActionElement = exceeded && props.expandText ? React.createElement("a", {
122
+ const expandActionElement = exceeded && props.expandText ? withStopPropagation(props.stopPropagationForActionButtons, React.createElement("a", {
121
123
  onClick: () => {
122
124
  setExpanded(true);
123
125
  }
124
- }, props.expandText) : null;
125
- const collapseActionElement = exceeded && props.expandText ? React.createElement("a", {
126
+ }, props.expandText)) : null;
127
+ const collapseActionElement = exceeded && props.expandText ? withStopPropagation(props.stopPropagationForActionButtons, React.createElement("a", {
126
128
  onClick: () => {
127
129
  setExpanded(false);
128
130
  }
129
- }, props.collapseText) : null;
131
+ }, props.collapseText)) : null;
130
132
 
131
133
  const renderContent = () => {
132
134
  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 DEFAULT_FORM_CONTEXT: FormContextType;
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;
@@ -1,7 +1,8 @@
1
1
  import React from 'react';
2
- export const DEFAULT_FORM_CONTEXT = {
2
+ export const defaultFormContext = {
3
3
  hasFeedback: true,
4
- layout: 'vertical'
4
+ layout: 'vertical',
5
+ requiredMarkStyle: 'asterisk'
5
6
  };
6
- export const FormContext = React.createContext(DEFAULT_FORM_CONTEXT);
7
+ export const FormContext = React.createContext(defaultFormContext);
7
8
  export const NoStyleItemContext = React.createContext(null);
@@ -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>;
@@ -9,6 +9,7 @@ import { toArray } from './utils';
9
9
  import List from '../list';
10
10
  import Popover from '../popover';
11
11
  import { QuestionCircleOutline } from 'antd-mobile-icons';
12
+ import { useConfig } from '../config-provider';
12
13
  const NAME_SPLIT = '__SPLIT__';
13
14
  const classPrefix = `adm-form-item`;
14
15
  const MemoInput = React.memo(({
@@ -29,18 +30,47 @@ const FormItemLayout = props => {
29
30
  hidden,
30
31
  errors,
31
32
  arrow,
32
- description
33
+ description,
34
+ childElementPosition = 'normal'
33
35
  } = props;
34
36
  const context = useContext(FormContext);
37
+ const {
38
+ locale
39
+ } = useConfig();
35
40
  const hasFeedback = props.hasFeedback !== undefined ? props.hasFeedback : context.hasFeedback;
36
41
  const layout = props.layout || context.layout;
37
42
  const feedback = hasFeedback && errors && errors.length > 0 ? errors[0] : null;
43
+
44
+ const requiredMark = (() => {
45
+ const {
46
+ requiredMarkStyle
47
+ } = context;
48
+
49
+ switch (requiredMarkStyle) {
50
+ case 'asterisk':
51
+ return required && React.createElement("span", {
52
+ className: `${classPrefix}-required-asterisk`
53
+ }, "*");
54
+
55
+ case 'text-required':
56
+ return required && React.createElement("span", {
57
+ className: `${classPrefix}-required-text`
58
+ }, "(", locale.Form.required, ")");
59
+
60
+ case 'text-optional':
61
+ return !required && React.createElement("span", {
62
+ className: `${classPrefix}-required-text`
63
+ }, "(", locale.Form.optional, ")");
64
+
65
+ default:
66
+ return null;
67
+ }
68
+ })();
69
+
38
70
  const labelElement = label ? React.createElement("label", {
39
71
  className: `${classPrefix}-label`,
40
72
  htmlFor: htmlFor
41
- }, label, required && React.createElement("span", {
42
- className: `${classPrefix}-label-required`
43
- }, "*"), help && React.createElement("span", {
73
+ }, label, requiredMark, help && React.createElement("span", {
44
74
  className: `${classPrefix}-label-help`
45
75
  }, React.createElement(Popover, {
46
76
  content: help,
@@ -62,7 +92,11 @@ const FormItemLayout = props => {
62
92
  disabled: disabled,
63
93
  onClick: props.onClick,
64
94
  arrow: arrow
65
- }, children);
95
+ }, React.createElement("div", {
96
+ className: classNames(`${classPrefix}-child`, `${classPrefix}-child-position-${childElementPosition}`)
97
+ }, React.createElement("div", {
98
+ className: classNames(`${classPrefix}-child-inner`)
99
+ }, children)));
66
100
  };
67
101
 
68
102
  export const FormItem = props => {
@@ -80,6 +114,7 @@ export const FormItem = props => {
80
114
  noStyle,
81
115
  hidden,
82
116
  layout,
117
+ childElementPosition,
83
118
  description,
84
119
  // Field 相关
85
120
  disabled,
@@ -93,7 +128,7 @@ export const FormItem = props => {
93
128
  dependencies,
94
129
  arrow
95
130
  } = props,
96
- fieldProps = __rest(props, ["className", "style", "label", "help", "extra", "hasFeedback", "name", "required", "noStyle", "hidden", "layout", "description", "disabled", "rules", "children", "messageVariables", "trigger", "validateTrigger", "onClick", "shouldUpdate", "dependencies", "arrow"]);
131
+ fieldProps = __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"]);
97
132
 
98
133
  const {
99
134
  validateTrigger: contextValidateTrigger
@@ -151,6 +186,7 @@ export const FormItem = props => {
151
186
  onClick: onClick,
152
187
  hidden: hidden,
153
188
  layout: layout,
189
+ childElementPosition: childElementPosition,
154
190
  arrow: arrow
155
191
  }, React.createElement(NoStyleItemContext.Provider, {
156
192
  value: onSubMetaChange
@@ -193,13 +229,7 @@ export const FormItem = props => {
193
229
  messageVariables: Variables
194
230
  }), (control, meta, context) => {
195
231
  let childNode = null;
196
- const isRequired = required !== undefined ? required : !!(rules && rules.some(rule => {
197
- if (rule && typeof rule === 'object' && rule.required) {
198
- return true;
199
- }
200
-
201
- return false;
202
- }));
232
+ const isRequired = required !== undefined ? required : rules && rules.some(rule => !!(rule && typeof rule === 'object' && rule.required));
203
233
  const fieldId = (toArray(name).length && meta ? meta.name : []).join('_');
204
234
 
205
235
  if (shouldUpdate && dependencies) {
@@ -1,16 +1,15 @@
1
1
  import { __rest } from "tslib";
2
- import React, { forwardRef } from 'react';
2
+ import React, { forwardRef, useMemo } from 'react';
3
3
  import classNames from 'classnames';
4
4
  import List from '../list';
5
5
  import RcForm from 'rc-field-form';
6
- import { FormContext } from './context';
6
+ import { defaultFormContext, FormContext } from './context';
7
7
  import { mergeProps } from '../../utils/with-default-props';
8
8
  import { Header } from './header';
9
+ import { useConfig } from '../config-provider';
10
+ import merge from 'lodash/merge';
9
11
  const classPrefix = 'adm-form';
10
- const defaultProps = {
11
- hasFeedback: true,
12
- layout: 'vertical'
13
- };
12
+ const defaultProps = defaultFormContext;
14
13
  export const Form = forwardRef((p, ref) => {
15
14
  const props = mergeProps(defaultProps, p);
16
15
 
@@ -21,10 +20,15 @@ export const Form = forwardRef((p, ref) => {
21
20
  children,
22
21
  layout,
23
22
  footer,
24
- mode
23
+ mode,
24
+ requiredMarkStyle
25
25
  } = props,
26
- formProps = __rest(props, ["className", "style", "hasFeedback", "children", "layout", "footer", "mode"]);
26
+ formProps = __rest(props, ["className", "style", "hasFeedback", "children", "layout", "footer", "mode", "requiredMarkStyle"]);
27
27
 
28
+ const {
29
+ locale
30
+ } = useConfig();
31
+ const validateMessages = useMemo(() => merge({}, locale.Form.defaultValidateMessages, formProps.validateMessages), [locale.Form.defaultValidateMessages, formProps.validateMessages]);
28
32
  const lists = [];
29
33
  let currentHeader = null;
30
34
  let items = [];
@@ -54,10 +58,13 @@ export const Form = forwardRef((p, ref) => {
54
58
  className: classNames(classPrefix, className),
55
59
  style: style,
56
60
  ref: ref
57
- }, formProps), React.createElement(FormContext.Provider, {
61
+ }, formProps, {
62
+ validateMessages: validateMessages
63
+ }), React.createElement(FormContext.Provider, {
58
64
  value: {
59
- hasFeedback: hasFeedback,
60
- layout
65
+ hasFeedback,
66
+ layout,
67
+ requiredMarkStyle
61
68
  }
62
69
  }, lists), footer && React.createElement("div", {
63
70
  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);
@@ -57,7 +57,7 @@ export const Input = forwardRef((p, ref) => {
57
57
  let nextValue = value;
58
58
 
59
59
  if (props.type === 'number') {
60
- nextValue = bound(parseFloat(nextValue), props.min, props.max).toString();
60
+ nextValue = nextValue && bound(parseFloat(nextValue), props.min, props.max).toString();
61
61
  }
62
62
 
63
63
  if (nextValue !== value) {
@@ -105,7 +105,7 @@ export const Input = forwardRef((p, ref) => {
105
105
  onKeyUp: props.onKeyUp,
106
106
  onCompositionStart: props.onCompositionStart,
107
107
  onCompositionEnd: props.onCompositionEnd
108
- }), props.clearable && !!value && !props.readOnly && React.createElement("div", {
108
+ }), props.clearable && !!value && !props.readOnly && hasFocus && React.createElement("div", {
109
109
  className: `${classPrefix}-clear`,
110
110
  onMouseDown: e => {
111
111
  e.preventDefault();
@@ -108,7 +108,7 @@ export const PullToRefresh = p => {
108
108
  if (!element) return;
109
109
  const scrollParent = getScrollParent(element);
110
110
  if (!scrollParent) return;
111
- const top = 'scrollTop' in scrollParent ? scrollParent.scrollTop : scrollParent.pageYOffset;
111
+ const top = 'scrollTop' in scrollParent ? scrollParent.scrollTop : scrollParent.scrollY;
112
112
 
113
113
  if (top <= 0 && y > 0) {
114
114
  pullingRef.current = true;
@@ -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
  };
@@ -1,3 +1,4 @@
1
+ const typeTemplate = '${label} is not a valid ${type}';
1
2
  export const base = {
2
3
  common: {
3
4
  confirm: 'Confirm',
@@ -31,6 +32,57 @@ export const base = {
31
32
  description: 'Want to try a new search?'
32
33
  }
33
34
  },
35
+ Form: {
36
+ required: 'Required',
37
+ optional: 'Optional',
38
+ defaultValidateMessages: {
39
+ default: 'Field validation error for ${label}',
40
+ required: 'Please enter ${label}',
41
+ enum: '${label} must be one of [${enum}]',
42
+ whitespace: '${label} cannot be a blank character',
43
+ date: {
44
+ format: '${label} date format is invalid',
45
+ parse: '${label} cannot be converted to a date',
46
+ invalid: '${label} is an invalid date'
47
+ },
48
+ types: {
49
+ string: typeTemplate,
50
+ method: typeTemplate,
51
+ array: typeTemplate,
52
+ object: typeTemplate,
53
+ number: typeTemplate,
54
+ date: typeTemplate,
55
+ boolean: typeTemplate,
56
+ integer: typeTemplate,
57
+ float: typeTemplate,
58
+ regexp: typeTemplate,
59
+ email: typeTemplate,
60
+ url: typeTemplate,
61
+ hex: typeTemplate
62
+ },
63
+ string: {
64
+ len: '${label} must be ${len} characters',
65
+ min: '${label} must be at least ${min} characters',
66
+ max: '${label} must be up to ${max} characters',
67
+ range: '${label} must be between ${min}-${max} characters'
68
+ },
69
+ number: {
70
+ len: '${label} must be equal to ${len}',
71
+ min: '${label} must be minimum ${min}',
72
+ max: '${label} must be maximum ${max}',
73
+ range: '${label} must be between ${min}-${max}'
74
+ },
75
+ array: {
76
+ len: 'Must be ${len} ${label}',
77
+ min: 'At least ${min} ${label}',
78
+ max: 'At most ${max} ${label}',
79
+ range: 'The amount of ${label} must be between ${min}-${max}'
80
+ },
81
+ pattern: {
82
+ mismatch: '${label} does not match the pattern ${pattern}'
83
+ }
84
+ }
85
+ },
34
86
  ImageUploader: {
35
87
  uploading: 'Uploading...'
36
88
  },