antd-mobile 5.2.2 → 5.4.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 (116) hide show
  1. package/2x/cjs/components/avatar/avatar.js +1 -0
  2. package/2x/cjs/components/calendar/calendar.js +23 -20
  3. package/2x/cjs/components/date-picker/date-picker.js +3 -7
  4. package/2x/cjs/components/ellipsis/ellipsis.d.ts +2 -0
  5. package/2x/cjs/components/ellipsis/ellipsis.js +8 -5
  6. package/2x/cjs/components/floating-bubble/floating-bubble.d.ts +2 -0
  7. package/2x/cjs/components/floating-bubble/floating-bubble.js +47 -16
  8. package/2x/cjs/components/form/context.d.ts +2 -1
  9. package/2x/cjs/components/form/context.js +6 -5
  10. package/2x/cjs/components/form/form-item.css +27 -1
  11. package/2x/cjs/components/form/form-item.d.ts +1 -0
  12. package/2x/cjs/components/form/form-item.js +44 -13
  13. package/2x/cjs/components/form/form.js +19 -10
  14. package/2x/cjs/components/form/index.css +27 -1
  15. package/2x/cjs/components/infinite-scroll/infinite-scroll.js +23 -19
  16. package/2x/cjs/components/input/input.js +2 -2
  17. package/2x/cjs/components/modal/modal.js +0 -1
  18. package/2x/cjs/components/notice-bar/notice-bar.js +1 -1
  19. package/2x/cjs/components/pull-to-refresh/pull-to-refresh.js +1 -1
  20. package/2x/cjs/components/search-bar/search-bar.js +0 -1
  21. package/2x/cjs/components/swiper/swiper.js +1 -1
  22. package/2x/cjs/components/text-area/text-area.css +4 -1
  23. package/2x/cjs/components/text-area/text-area.d.ts +2 -2
  24. package/2x/cjs/locales/base.d.ts +51 -0
  25. package/2x/cjs/locales/base.js +52 -0
  26. package/2x/cjs/locales/en-US.d.ts +51 -0
  27. package/2x/cjs/locales/zh-CN.d.ts +51 -0
  28. package/2x/cjs/locales/zh-CN.js +52 -0
  29. package/2x/es/components/avatar/avatar.js +1 -0
  30. package/2x/es/components/calendar/calendar.js +23 -19
  31. package/2x/es/components/date-picker/date-picker.js +3 -7
  32. package/2x/es/components/ellipsis/ellipsis.d.ts +2 -0
  33. package/2x/es/components/ellipsis/ellipsis.js +7 -5
  34. package/2x/es/components/floating-bubble/floating-bubble.d.ts +2 -0
  35. package/2x/es/components/floating-bubble/floating-bubble.js +48 -17
  36. package/2x/es/components/form/context.d.ts +2 -1
  37. package/2x/es/components/form/context.js +4 -3
  38. package/2x/es/components/form/form-item.css +27 -1
  39. package/2x/es/components/form/form-item.d.ts +1 -0
  40. package/2x/es/components/form/form-item.js +43 -13
  41. package/2x/es/components/form/form.js +19 -12
  42. package/2x/es/components/form/index.css +27 -1
  43. package/2x/es/components/infinite-scroll/infinite-scroll.js +22 -19
  44. package/2x/es/components/input/input.js +2 -2
  45. package/2x/es/components/modal/modal.js +0 -1
  46. package/2x/es/components/notice-bar/notice-bar.js +1 -1
  47. package/2x/es/components/pull-to-refresh/pull-to-refresh.js +1 -1
  48. package/2x/es/components/search-bar/search-bar.js +0 -1
  49. package/2x/es/components/swiper/swiper.js +1 -1
  50. package/2x/es/components/text-area/text-area.css +4 -1
  51. package/2x/es/components/text-area/text-area.d.ts +2 -2
  52. package/2x/es/locales/base.d.ts +51 -0
  53. package/2x/es/locales/base.js +52 -0
  54. package/2x/es/locales/en-US.d.ts +51 -0
  55. package/2x/es/locales/zh-CN.d.ts +51 -0
  56. package/2x/es/locales/zh-CN.js +52 -0
  57. package/2x/package.json +4 -4
  58. package/cjs/components/avatar/avatar.js +1 -0
  59. package/cjs/components/calendar/calendar.js +23 -20
  60. package/cjs/components/date-picker/date-picker.js +3 -7
  61. package/cjs/components/ellipsis/ellipsis.d.ts +2 -0
  62. package/cjs/components/ellipsis/ellipsis.js +8 -5
  63. package/cjs/components/floating-bubble/floating-bubble.d.ts +2 -0
  64. package/cjs/components/floating-bubble/floating-bubble.js +47 -16
  65. package/cjs/components/form/context.d.ts +2 -1
  66. package/cjs/components/form/context.js +6 -5
  67. package/cjs/components/form/form-item.css +21 -1
  68. package/cjs/components/form/form-item.d.ts +1 -0
  69. package/cjs/components/form/form-item.js +44 -13
  70. package/cjs/components/form/form.js +19 -10
  71. package/cjs/components/form/index.css +21 -1
  72. package/cjs/components/infinite-scroll/infinite-scroll.js +23 -19
  73. package/cjs/components/input/input.js +2 -2
  74. package/cjs/components/modal/modal.js +0 -1
  75. package/cjs/components/notice-bar/notice-bar.js +1 -1
  76. package/cjs/components/pull-to-refresh/pull-to-refresh.js +1 -1
  77. package/cjs/components/search-bar/search-bar.js +0 -1
  78. package/cjs/components/swiper/swiper.js +1 -1
  79. package/cjs/components/text-area/text-area.css +4 -1
  80. package/cjs/components/text-area/text-area.d.ts +2 -2
  81. package/cjs/locales/base.d.ts +51 -0
  82. package/cjs/locales/base.js +52 -0
  83. package/cjs/locales/en-US.d.ts +51 -0
  84. package/cjs/locales/zh-CN.d.ts +51 -0
  85. package/cjs/locales/zh-CN.js +52 -0
  86. package/es/components/avatar/avatar.js +1 -0
  87. package/es/components/calendar/calendar.js +23 -19
  88. package/es/components/date-picker/date-picker.js +3 -7
  89. package/es/components/ellipsis/ellipsis.d.ts +2 -0
  90. package/es/components/ellipsis/ellipsis.js +7 -5
  91. package/es/components/floating-bubble/floating-bubble.d.ts +2 -0
  92. package/es/components/floating-bubble/floating-bubble.js +48 -17
  93. package/es/components/form/context.d.ts +2 -1
  94. package/es/components/form/context.js +4 -3
  95. package/es/components/form/form-item.css +21 -1
  96. package/es/components/form/form-item.d.ts +1 -0
  97. package/es/components/form/form-item.js +43 -13
  98. package/es/components/form/form.js +19 -12
  99. package/es/components/form/index.css +21 -1
  100. package/es/components/infinite-scroll/infinite-scroll.js +22 -19
  101. package/es/components/input/input.js +2 -2
  102. package/es/components/modal/modal.js +0 -1
  103. package/es/components/notice-bar/notice-bar.js +1 -1
  104. package/es/components/pull-to-refresh/pull-to-refresh.js +1 -1
  105. package/es/components/search-bar/search-bar.js +0 -1
  106. package/es/components/swiper/swiper.js +1 -1
  107. package/es/components/text-area/text-area.css +4 -1
  108. package/es/components/text-area/text-area.d.ts +2 -2
  109. package/es/locales/base.d.ts +51 -0
  110. package/es/locales/base.js +52 -0
  111. package/es/locales/en-US.d.ts +51 -0
  112. package/es/locales/zh-CN.d.ts +51 -0
  113. package/es/locales/zh-CN.js +52 -0
  114. package/package.json +4 -4
  115. package/umd/antd-mobile.js +1 -1
  116. package/umd/antd-mobile.js.LICENSE.txt +0 -24
@@ -1,47 +1,74 @@
1
1
  import React, { useRef } from 'react';
2
- import { useSpring, animated } from '@react-spring/web';
2
+ import { useSpring, animated, to } from '@react-spring/web';
3
3
  import { useDrag } from '@use-gesture/react';
4
4
  import { mergeProps } from '../../utils/with-default-props';
5
5
  import { withNativeProps } from '../../utils/native-props';
6
6
  const classPrefix = `adm-floating-bubble`;
7
- const defaultProps = {};
7
+ const defaultProps = {
8
+ axis: 'y'
9
+ };
8
10
  export const FloatingBubble = p => {
9
11
  const props = mergeProps(defaultProps, p);
10
12
  const boundaryRef = useRef(null);
13
+ const buttonRef = useRef(null);
11
14
  /**
12
15
  * memoize the `to` function
13
16
  * inside a component that renders frequently
14
17
  * to prevent an unintended restart
15
18
  */
16
19
 
17
- const [animationStyles, animation] = useSpring(() => ({
20
+ const [{
21
+ x,
22
+ y,
23
+ opacity
24
+ }, api] = useSpring(() => ({
25
+ x: 0,
18
26
  y: 0,
19
- scale: 1,
20
27
  opacity: 1
21
28
  }));
22
29
  const bind = useDrag(state => {
23
- if (state.down) {
24
- // be movable in y axis
25
- animation.start({
26
- y: state.offset[1]
27
- });
28
- } // active status
30
+ let nextX = state.offset[0];
31
+ let nextY = state.offset[1];
29
32
 
33
+ if (state.last) {
34
+ const boundary = boundaryRef.current;
35
+ const button = buttonRef.current;
36
+ if (!boundary || !button) return;
30
37
 
31
- animation.start({
32
- scale: state.active ? 1.1 : 1,
38
+ if (props.magnetic === 'x') {
39
+ const compensation = x.goal - x.get();
40
+ const boundaryRect = boundary.getBoundingClientRect();
41
+ const buttonRect = button.getBoundingClientRect();
42
+ const leftDistance = buttonRect.left + compensation - boundaryRect.left;
43
+ const rightDistance = boundaryRect.right - (buttonRect.right + compensation);
44
+
45
+ if (rightDistance <= leftDistance) {
46
+ nextX += rightDistance;
47
+ } else {
48
+ nextX -= leftDistance;
49
+ }
50
+ }
51
+ }
52
+
53
+ api.start({
54
+ x: nextX,
55
+ y: nextY // immediate: !state.last,
56
+
57
+ }); // active status
58
+
59
+ api.start({
33
60
  opacity: state.active ? 0.8 : 1
34
61
  });
35
62
  }, {
36
- // only trigger if a movement is detected on the specified axis.
37
- axis: 'y',
63
+ axis: props.axis === 'xy' ? undefined : props.axis,
38
64
  pointer: {
39
65
  touch: true
40
66
  },
41
67
  // the component won't trigger drag logic if the user just clicked on the component.
42
68
  filterTaps: true,
43
69
  // set constraints to the user gesture
44
- bounds: boundaryRef
70
+ bounds: boundaryRef,
71
+ from: () => [x.get(), y.get()]
45
72
  });
46
73
  return withNativeProps(props, React.createElement("div", {
47
74
  className: classPrefix
@@ -51,8 +78,12 @@ export const FloatingBubble = p => {
51
78
  className: `${classPrefix}-boundary`,
52
79
  ref: boundaryRef
53
80
  })), React.createElement(animated.div, Object.assign({}, bind(), {
54
- style: Object.assign({}, animationStyles),
81
+ style: {
82
+ opacity,
83
+ transform: to([x, y], (x, y) => `translate(${x}px, ${y}px)`)
84
+ },
55
85
  onClick: props.onClick,
56
- className: `${classPrefix}-button`
86
+ className: `${classPrefix}-button`,
87
+ ref: buttonRef
57
88
  }), props.children)));
58
89
  };
@@ -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 = [];
@@ -41,7 +45,7 @@ export const Form = forwardRef((p, ref) => {
41
45
  items = [];
42
46
  }
43
47
 
44
- React.Children.forEach(props.children, (child, index) => {
48
+ React.Children.forEach(props.children, child => {
45
49
  if (React.isValidElement(child) && child.type === Header) {
46
50
  collect();
47
51
  currentHeader = child.props.children;
@@ -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);
@@ -1,5 +1,6 @@
1
+ import { __awaiter } from "tslib";
1
2
  import { mergeProps } from '../../utils/with-default-props';
2
- import React, { useEffect, useRef } from 'react';
3
+ import React, { useEffect, useRef, useState } from 'react';
3
4
  import { useLockFn, useMemoizedFn } from 'ahooks';
4
5
  import { withNativeProps } from '../../utils/native-props';
5
6
  import { getScrollParent } from '../../utils/get-scroll-parent';
@@ -23,25 +24,27 @@ export const InfiniteScroll = p => {
23
24
  }, p);
24
25
  const doLoadMore = useLockFn(() => props.loadMore());
25
26
  const elementRef = useRef(null);
26
- const checkTimeoutRef = useRef();
27
- const check = useMemoizedFn(() => {
28
- window.clearTimeout(checkTimeoutRef.current);
29
- checkTimeoutRef.current = window.setTimeout(() => {
30
- if (!props.hasMore) return;
31
- const element = elementRef.current;
32
- if (!element) return;
33
- if (!element.offsetParent) return;
34
- const parent = getScrollParent(element);
35
- if (!parent) return;
36
- const rect = element.getBoundingClientRect();
37
- const elementTop = rect.top;
38
- const current = isWindow(parent) ? window.innerHeight : parent.getBoundingClientRect().bottom;
27
+ const [flag, setFlag] = useState({});
28
+ const nextFlagRef = useRef(flag);
29
+ const check = useMemoizedFn(() => __awaiter(void 0, void 0, void 0, function* () {
30
+ if (nextFlagRef.current !== flag) return;
31
+ if (!props.hasMore) return;
32
+ const element = elementRef.current;
33
+ if (!element) return;
34
+ if (!element.offsetParent) return;
35
+ const parent = getScrollParent(element);
36
+ if (!parent) return;
37
+ const rect = element.getBoundingClientRect();
38
+ const elementTop = rect.top;
39
+ const current = isWindow(parent) ? window.innerHeight : parent.getBoundingClientRect().bottom;
39
40
 
40
- if (current >= elementTop - props.threshold) {
41
- doLoadMore();
42
- }
43
- });
44
- }); // 确保在内容不足时会自动触发加载事件
41
+ if (current >= elementTop - props.threshold) {
42
+ const nextFlag = {};
43
+ nextFlagRef.current = nextFlag;
44
+ yield doLoadMore();
45
+ setFlag(nextFlag);
46
+ }
47
+ })); // 确保在内容不足时会自动触发加载事件
45
48
 
46
49
  useEffect(() => {
47
50
  check();
@@ -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();
@@ -13,7 +13,6 @@ import AutoCenter from '../auto-center';
13
13
  import { useSpring, animated } from '@react-spring/web';
14
14
  import { withNativeProps } from '../../utils/native-props';
15
15
  import { CloseOutline } from 'antd-mobile-icons';
16
- const classPrefix = `adm-modal`;
17
16
  const defaultProps = {
18
17
  visible: false,
19
18
  actions: [],
@@ -55,7 +55,7 @@ export const NoticeBar = memo(p => {
55
55
  delayLockRef.current = false;
56
56
  start();
57
57
  }, props.delay);
58
- useResizeEffect(text => {
58
+ useResizeEffect(() => {
59
59
  start();
60
60
  }, containerRef);
61
61
  useMutationEffect(() => {
@@ -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;
@@ -45,7 +45,6 @@ export const SearchBar = forwardRef((p, ref) => {
45
45
 
46
46
  const renderCancelButton = () => {
47
47
  let isShowCancel = false;
48
- const showCancelButton = props.showCancelButton;
49
48
 
50
49
  if (typeof props.showCancelButton === 'function') {
51
50
  isShowCancel = props.showCancelButton(hasFocus, value);
@@ -230,7 +230,7 @@ export const Swiper = forwardRef(staged((p, ref) => {
230
230
  style: {
231
231
  [isVertical ? 'y' : 'x']: position.to(position => `${-position}%`)
232
232
  }
233
- }, React.Children.map(validChildren, (child, index) => {
233
+ }, React.Children.map(validChildren, child => {
234
234
  return React.createElement("div", {
235
235
  className: 'adm-swiper-slide'
236
236
  }, child);
@@ -3,6 +3,8 @@
3
3
  --color: var(--adm-color-text);
4
4
  --placeholder-color: var(--adm-color-light);
5
5
  --disabled-color: var(--adm-color-weak);
6
+ --text-align: left;
7
+ --count-text-align: right;
6
8
  width: 100%;
7
9
  max-width: 100%;
8
10
  max-height: 100%;
@@ -26,6 +28,7 @@
26
28
  outline: none;
27
29
  appearance: none;
28
30
  min-height: 1.5em;
31
+ text-align: var(--text-align);
29
32
  }
30
33
  .adm-text-area-element::placeholder {
31
34
  color: var(--placeholder-color);
@@ -53,7 +56,7 @@
53
56
  pointer-events: none;
54
57
  }
55
58
  .adm-text-area-count {
56
- text-align: right;
59
+ text-align: var(--count-text-align);
57
60
  color: var(--adm-color-weak);
58
61
  font-size: 17px;
59
62
  padding-top: 8px;
@@ -14,7 +14,7 @@ export declare type TextAreaProps = Pick<React.DetailedHTMLProps<React.TextareaH
14
14
  maxRows?: number;
15
15
  };
16
16
  id?: string;
17
- } & NativeProps<'--font-size' | '--color' | '--placeholder-color' | '--disabled-color'>;
17
+ } & NativeProps<'--font-size' | '--color' | '--placeholder-color' | '--disabled-color' | '--text-align' | '--count-text-align'>;
18
18
  export declare type TextAreaRef = {
19
19
  clear: () => void;
20
20
  focus: () => void;
@@ -33,4 +33,4 @@ export declare const TextArea: React.ForwardRefExoticComponent<Pick<React.Detail
33
33
  maxRows?: number | undefined;
34
34
  } | undefined;
35
35
  id?: string | undefined;
36
- } & NativeProps<"--color" | "--font-size" | "--placeholder-color" | "--disabled-color"> & React.RefAttributes<TextAreaRef>>;
36
+ } & NativeProps<"--color" | "--font-size" | "--placeholder-color" | "--text-align" | "--disabled-color" | "--count-text-align"> & React.RefAttributes<TextAreaRef>>;
@@ -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
  },