antd-mobile 5.10.4 → 5.11.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 (114) hide show
  1. package/2x/cjs/components/button/button.d.ts +6 -4
  2. package/2x/cjs/components/button/button.js +31 -7
  3. package/2x/cjs/components/calendar/calendar.css +2 -2
  4. package/2x/cjs/components/calendar/calendar.d.ts +2 -0
  5. package/2x/cjs/components/calendar/calendar.js +6 -1
  6. package/2x/cjs/components/date-picker/date-picker.js +1 -0
  7. package/2x/cjs/components/dialog/dialog-action-button.js +3 -26
  8. package/2x/cjs/components/floating-panel/floating-panel.js +1 -1
  9. package/2x/cjs/components/form/context.d.ts +1 -0
  10. package/2x/cjs/components/form/context.js +2 -1
  11. package/2x/cjs/components/form/form-item.css +1 -1
  12. package/2x/cjs/components/form/form-item.js +3 -1
  13. package/2x/cjs/components/form/form.d.ts +0 -3
  14. package/2x/cjs/components/form/form.js +4 -2
  15. package/2x/cjs/components/form/index.css +1 -1
  16. package/2x/cjs/components/form/index.d.ts +2 -2
  17. package/2x/cjs/components/form/index.js +2 -1
  18. package/2x/cjs/components/index-bar/panel.d.ts +1 -0
  19. package/2x/cjs/components/input/input.css +4 -0
  20. package/2x/cjs/components/input/input.d.ts +2 -0
  21. package/2x/cjs/components/input/input.js +13 -2
  22. package/2x/cjs/components/modal/modal-action-button.js +3 -26
  23. package/2x/cjs/components/search-bar/search-bar.d.ts +2 -0
  24. package/2x/cjs/components/search-bar/search-bar.js +2 -0
  25. package/2x/cjs/components/swiper/index.d.ts +1 -16
  26. package/2x/cjs/components/swiper/swiper.d.ts +1 -16
  27. package/2x/cjs/global/index.js +2 -0
  28. package/2x/es/components/button/button.d.ts +6 -4
  29. package/2x/es/components/button/button.js +30 -8
  30. package/2x/es/components/calendar/calendar.css +2 -2
  31. package/2x/es/components/calendar/calendar.d.ts +2 -0
  32. package/2x/es/components/calendar/calendar.js +6 -2
  33. package/2x/es/components/date-picker/date-picker.js +1 -0
  34. package/2x/es/components/dialog/dialog-action-button.js +3 -21
  35. package/2x/es/components/floating-panel/floating-panel.js +1 -1
  36. package/2x/es/components/form/context.d.ts +1 -0
  37. package/2x/es/components/form/context.js +2 -1
  38. package/2x/es/components/form/form-item.css +1 -1
  39. package/2x/es/components/form/form-item.js +3 -1
  40. package/2x/es/components/form/form.d.ts +0 -3
  41. package/2x/es/components/form/form.js +4 -2
  42. package/2x/es/components/form/index.css +1 -1
  43. package/2x/es/components/form/index.d.ts +2 -2
  44. package/2x/es/components/form/index.js +3 -2
  45. package/2x/es/components/index-bar/panel.d.ts +1 -0
  46. package/2x/es/components/input/input.css +4 -0
  47. package/2x/es/components/input/input.d.ts +2 -0
  48. package/2x/es/components/input/input.js +13 -2
  49. package/2x/es/components/modal/modal-action-button.js +3 -21
  50. package/2x/es/components/search-bar/search-bar.d.ts +2 -0
  51. package/2x/es/components/search-bar/search-bar.js +2 -0
  52. package/2x/es/components/swiper/index.d.ts +1 -16
  53. package/2x/es/components/swiper/swiper.d.ts +1 -16
  54. package/2x/es/global/index.js +2 -0
  55. package/2x/package.json +2 -2
  56. package/bundle/antd-mobile.cjs.js +66 -48
  57. package/bundle/antd-mobile.es.js +67 -49
  58. package/bundle/style.css +6 -3
  59. package/cjs/components/button/button.d.ts +6 -4
  60. package/cjs/components/button/button.js +31 -7
  61. package/cjs/components/calendar/calendar.css +2 -2
  62. package/cjs/components/calendar/calendar.d.ts +2 -0
  63. package/cjs/components/calendar/calendar.js +6 -1
  64. package/cjs/components/date-picker/date-picker.js +1 -0
  65. package/cjs/components/dialog/dialog-action-button.js +3 -26
  66. package/cjs/components/floating-panel/floating-panel.js +1 -1
  67. package/cjs/components/form/context.d.ts +1 -0
  68. package/cjs/components/form/context.js +2 -1
  69. package/cjs/components/form/form-item.css +1 -1
  70. package/cjs/components/form/form-item.js +3 -1
  71. package/cjs/components/form/form.d.ts +0 -3
  72. package/cjs/components/form/form.js +4 -2
  73. package/cjs/components/form/index.css +1 -1
  74. package/cjs/components/form/index.d.ts +2 -2
  75. package/cjs/components/form/index.js +2 -1
  76. package/cjs/components/index-bar/panel.d.ts +1 -0
  77. package/cjs/components/input/input.css +3 -0
  78. package/cjs/components/input/input.d.ts +2 -0
  79. package/cjs/components/input/input.js +13 -2
  80. package/cjs/components/modal/modal-action-button.js +3 -26
  81. package/cjs/components/search-bar/search-bar.d.ts +2 -0
  82. package/cjs/components/search-bar/search-bar.js +2 -0
  83. package/cjs/components/swiper/index.d.ts +1 -16
  84. package/cjs/components/swiper/swiper.d.ts +1 -16
  85. package/cjs/global/index.js +2 -0
  86. package/es/components/button/button.d.ts +6 -4
  87. package/es/components/button/button.js +30 -8
  88. package/es/components/calendar/calendar.css +2 -2
  89. package/es/components/calendar/calendar.d.ts +2 -0
  90. package/es/components/calendar/calendar.js +6 -2
  91. package/es/components/date-picker/date-picker.js +1 -0
  92. package/es/components/dialog/dialog-action-button.js +3 -21
  93. package/es/components/floating-panel/floating-panel.js +1 -1
  94. package/es/components/form/context.d.ts +1 -0
  95. package/es/components/form/context.js +2 -1
  96. package/es/components/form/form-item.css +1 -1
  97. package/es/components/form/form-item.js +3 -1
  98. package/es/components/form/form.d.ts +0 -3
  99. package/es/components/form/form.js +4 -2
  100. package/es/components/form/index.css +1 -1
  101. package/es/components/form/index.d.ts +2 -2
  102. package/es/components/form/index.js +3 -2
  103. package/es/components/index-bar/panel.d.ts +1 -0
  104. package/es/components/input/input.css +3 -0
  105. package/es/components/input/input.d.ts +2 -0
  106. package/es/components/input/input.js +13 -2
  107. package/es/components/modal/modal-action-button.js +3 -21
  108. package/es/components/search-bar/search-bar.d.ts +2 -0
  109. package/es/components/search-bar/search-bar.js +2 -0
  110. package/es/components/swiper/index.d.ts +1 -16
  111. package/es/components/swiper/swiper.d.ts +1 -16
  112. package/es/global/index.js +2 -0
  113. package/package.json +2 -2
  114. package/umd/antd-mobile.js +1 -1
@@ -1,32 +1,56 @@
1
- import React, { forwardRef, useImperativeHandle, useRef } from 'react';
1
+ import { __awaiter } from "tslib";
2
+ import React, { forwardRef, useImperativeHandle, useRef, useState } from 'react';
2
3
  import classNames from 'classnames';
3
4
  import DotLoading from '../dot-loading';
4
5
  import { mergeProps } from '../../utils/with-default-props';
5
6
  import { withNativeProps } from '../../utils/native-props';
7
+ import { isPromise } from '../../utils/validate';
6
8
  const classPrefix = `adm-button`;
7
9
  const defaultProps = {
8
10
  color: 'default',
9
11
  fill: 'solid',
10
12
  block: false,
11
13
  loading: false,
14
+ loadingIcon: React.createElement(DotLoading, {
15
+ color: 'currentColor'
16
+ }),
12
17
  type: 'button',
13
18
  shape: 'default',
14
19
  size: 'middle'
15
20
  };
16
21
  export const Button = forwardRef((p, ref) => {
17
22
  const props = mergeProps(defaultProps, p);
18
- const disabled = props.disabled || props.loading;
23
+ const [innerLoading, setInnerLoading] = useState(false);
19
24
  const nativeButtonRef = useRef(null);
25
+ const loading = props.loading === 'auto' ? innerLoading : props.loading;
26
+ const disabled = props.disabled || loading;
20
27
  useImperativeHandle(ref, () => ({
21
28
  get nativeElement() {
22
29
  return nativeButtonRef.current;
23
30
  }
24
31
 
25
32
  }));
33
+
34
+ const handleClick = e => __awaiter(void 0, void 0, void 0, function* () {
35
+ if (!props.onClick) return;
36
+ const promise = props.onClick(e);
37
+
38
+ if (isPromise(promise)) {
39
+ try {
40
+ setInnerLoading(true);
41
+ yield promise;
42
+ setInnerLoading(false);
43
+ } catch (e) {
44
+ setInnerLoading(false);
45
+ throw e;
46
+ }
47
+ }
48
+ });
49
+
26
50
  return withNativeProps(props, React.createElement("button", {
27
51
  ref: nativeButtonRef,
28
52
  type: props.type,
29
- onClick: props.onClick,
53
+ onClick: handleClick,
30
54
  className: classNames(classPrefix, props.color ? `${classPrefix}-${props.color}` : null, {
31
55
  [`${classPrefix}-block`]: props.block,
32
56
  [`${classPrefix}-disabled`]: disabled,
@@ -35,12 +59,10 @@ export const Button = forwardRef((p, ref) => {
35
59
  [`${classPrefix}-mini`]: props.size === 'mini',
36
60
  [`${classPrefix}-small`]: props.size === 'small',
37
61
  [`${classPrefix}-large`]: props.size === 'large',
38
- [`${classPrefix}-loading`]: props.loading
62
+ [`${classPrefix}-loading`]: loading
39
63
  }, `${classPrefix}-shape-${props.shape}`),
40
64
  disabled: disabled
41
- }, props.loading ? React.createElement("div", {
65
+ }, loading ? React.createElement("div", {
42
66
  className: `${classPrefix}-loading-wrapper`
43
- }, React.createElement(DotLoading, {
44
- color: 'currentColor'
45
- }), props.loadingText) : props.children));
67
+ }, props.loadingIcon, props.loadingText) : props.children));
46
68
  });
@@ -59,11 +59,11 @@
59
59
  color: var(--adm-color-primary);
60
60
  }
61
61
 
62
- .adm-calendar-cell.adm-calendar-cell-out {
62
+ .adm-calendar-cell.adm-calendar-cell-disabled {
63
63
  color: var(--adm-color-light);
64
64
  }
65
65
 
66
- .adm-calendar-cell.adm-calendar-cell-out .adm-calendar-cell-bottom {
66
+ .adm-calendar-cell.adm-calendar-cell-disabled .adm-calendar-cell-bottom {
67
67
  color: var(--adm-color-light);
68
68
  }
69
69
 
@@ -13,6 +13,8 @@ export declare type CalendarProps = {
13
13
  weekStartsOn?: 'Monday' | 'Sunday';
14
14
  renderLabel?: (date: Date) => string | null | undefined;
15
15
  allowClear?: boolean;
16
+ max?: Date;
17
+ min?: Date;
16
18
  } & ({
17
19
  selectionMode?: undefined;
18
20
  value?: undefined;
@@ -1,4 +1,4 @@
1
- import React, { forwardRef, useState, useImperativeHandle } from 'react';
1
+ import React, { forwardRef, useState, useImperativeHandle, useMemo } from 'react';
2
2
  import { withNativeProps } from '../../utils/native-props';
3
3
  import dayjs from 'dayjs';
4
4
  import classNames from 'classnames';
@@ -94,6 +94,8 @@ export const Calendar = forwardRef((p, ref) => {
94
94
  setCurrent(current.add(1, 'year'));
95
95
  }
96
96
  }, React.createElement(ArrowLeftDouble, null)));
97
+ const maxDay = useMemo(() => props.max && dayjs(props.max), [props.max]);
98
+ const minDay = useMemo(() => props.min && dayjs(props.min), [props.min]);
97
99
 
98
100
  function renderCells() {
99
101
  var _a;
@@ -119,9 +121,10 @@ export const Calendar = forwardRef((p, ref) => {
119
121
  }
120
122
 
121
123
  const inThisMonth = d.month() === current.month();
124
+ const disabled = !inThisMonth || maxDay && d.isAfter(maxDay, 'day') || minDay && d.isBefore(minDay, 'day');
122
125
  cells.push(React.createElement("div", {
123
126
  key: d.valueOf(),
124
- className: classNames(`${classPrefix}-cell`, inThisMonth ? `${classPrefix}-cell-in` : `${classPrefix}-cell-out`, inThisMonth && {
127
+ className: classNames(`${classPrefix}-cell`, disabled && `${classPrefix}-cell-disabled`, inThisMonth && {
125
128
  [`${classPrefix}-cell-today`]: d.isSame(today, 'day'),
126
129
  [`${classPrefix}-cell-selected`]: isSelect,
127
130
  [`${classPrefix}-cell-selected-begin`]: isBegin,
@@ -129,6 +132,7 @@ export const Calendar = forwardRef((p, ref) => {
129
132
  }),
130
133
  onClick: () => {
131
134
  if (!props.selectionMode) return;
135
+ if (disabled) return;
132
136
  const date = d.toDate();
133
137
 
134
138
  if (!inThisMonth) {
@@ -47,6 +47,7 @@ export const DatePicker = p => {
47
47
  value: pickerValue,
48
48
  onCancel: props.onCancel,
49
49
  onClose: props.onClose,
50
+ closeOnMaskClick: props.closeOnMaskClick,
50
51
  visible: props.visible,
51
52
  confirmText: props.confirmText,
52
53
  cancelText: props.cancelText,
@@ -1,5 +1,4 @@
1
- import { __awaiter } from "tslib";
2
- import React, { useState } from 'react';
1
+ import React from 'react';
3
2
  import classNames from 'classnames';
4
3
  import Button from '../button';
5
4
  import { withNativeProps } from '../../utils/native-props';
@@ -7,26 +6,9 @@ export const DialogActionButton = props => {
7
6
  const {
8
7
  action
9
8
  } = props;
10
- const [loading, setLoading] = useState(false);
11
-
12
- function handleClick() {
13
- return __awaiter(this, void 0, void 0, function* () {
14
- setLoading(true);
15
-
16
- try {
17
- const promise = props.onAction();
18
- yield promise;
19
- setLoading(false);
20
- } catch (e) {
21
- setLoading(false);
22
- throw e;
23
- }
24
- });
25
- }
26
-
27
9
  return withNativeProps(props.action, React.createElement(Button, {
28
10
  key: action.key,
29
- onClick: handleClick,
11
+ onClick: props.onAction,
30
12
  className: classNames('adm-dialog-button', {
31
13
  'adm-dialog-button-bold': action.bold
32
14
  }),
@@ -34,7 +16,7 @@ export const DialogActionButton = props => {
34
16
  shape: 'rectangular',
35
17
  block: true,
36
18
  color: action.danger ? 'danger' : 'primary',
37
- loading: loading,
19
+ loading: 'auto',
38
20
  disabled: action.disabled
39
21
  }, action.text));
40
22
  };
@@ -37,7 +37,7 @@ export const FloatingPanel = forwardRef((p, ref) => {
37
37
  tension: 300
38
38
  },
39
39
  onChange: result => {
40
- onHeightChange(result.value.y, y.isAnimating);
40
+ onHeightChange(-result.value.y, y.isAnimating);
41
41
  }
42
42
  }));
43
43
  useDrag(state => {
@@ -6,6 +6,7 @@ export declare type FormContextType = {
6
6
  hasFeedback: boolean;
7
7
  layout: FormLayout;
8
8
  requiredMarkStyle: 'asterisk' | 'text-required' | 'text-optional';
9
+ disabled: boolean;
9
10
  };
10
11
  export declare const defaultFormContext: FormContextType;
11
12
  export declare const FormContext: React.Context<FormContextType>;
@@ -3,7 +3,8 @@ export const defaultFormContext = {
3
3
  name: undefined,
4
4
  hasFeedback: true,
5
5
  layout: 'vertical',
6
- requiredMarkStyle: 'asterisk'
6
+ requiredMarkStyle: 'asterisk',
7
+ disabled: false
7
8
  };
8
9
  export const FormContext = React.createContext(defaultFormContext);
9
10
  export const NoStyleItemContext = React.createContext(null);
@@ -66,7 +66,7 @@
66
66
 
67
67
  .adm-form-item.adm-form-item-horizontal.adm-list-item {
68
68
  --align-items: stretch;
69
- --prefix-width: 6em;
69
+ --prefix-width: 6.8em;
70
70
  }
71
71
 
72
72
  .adm-form-item.adm-form-item-horizontal .adm-list-item-content-prefix {
@@ -18,6 +18,8 @@ const MemoInput = React.memo(({
18
18
  }) => children, (prev, next) => prev.value === next.value && prev.update === next.update);
19
19
 
20
20
  const FormItemLayout = props => {
21
+ var _a;
22
+
21
23
  const {
22
24
  className,
23
25
  style,
@@ -25,7 +27,6 @@ const FormItemLayout = props => {
25
27
  label,
26
28
  help,
27
29
  required,
28
- disabled,
29
30
  children,
30
31
  htmlFor,
31
32
  hidden,
@@ -38,6 +39,7 @@ const FormItemLayout = props => {
38
39
  } = useConfig();
39
40
  const hasFeedback = props.hasFeedback !== undefined ? props.hasFeedback : context.hasFeedback;
40
41
  const layout = props.layout || context.layout;
42
+ const disabled = (_a = props.disabled) !== null && _a !== void 0 ? _a : context.disabled;
41
43
 
42
44
  const requiredMark = (() => {
43
45
  const {
@@ -3,15 +3,12 @@ import { NativeProps } from '../../utils/native-props';
3
3
  import { ListProps } from '../list';
4
4
  import type { FormProps as RcFormProps, FormInstance as RCFormInstance } from 'rc-field-form';
5
5
  import { FormContextType } from './context';
6
- import type { FormLayout } from '.';
7
6
  export declare type FormInstance = Pick<RCFormInstance, 'getFieldValue' | 'getFieldsValue' | 'getFieldError' | 'getFieldsError' | 'isFieldTouched' | 'isFieldsTouched' | 'resetFields' | 'setFields' | 'setFieldsValue' | 'submit' | 'validateFields'>;
8
7
  export declare type FormProps = Pick<RcFormProps, 'form' | 'initialValues' | 'name' | 'preserve' | 'validateMessages' | 'validateTrigger' | 'onFieldsChange' | 'onFinish' | 'onFinishFailed' | 'onValuesChange' | 'children'> & NativeProps<'--border-inner' | '--border-top' | '--border-bottom'> & Partial<FormContextType> & {
9
8
  footer?: ReactNode;
10
- layout?: FormLayout;
11
9
  mode?: ListProps['mode'];
12
10
  };
13
11
  export declare const Form: React.ForwardRefExoticComponent<Pick<RcFormProps<any>, "children" | "form" | "name" | "initialValues" | "preserve" | "validateMessages" | "validateTrigger" | "onFieldsChange" | "onFinish" | "onFinishFailed" | "onValuesChange"> & NativeProps<"--border-inner" | "--border-top" | "--border-bottom"> & Partial<FormContextType> & {
14
12
  footer?: ReactNode;
15
- layout?: FormLayout | undefined;
16
13
  mode?: ListProps['mode'];
17
14
  } & React.RefAttributes<FormInstance>>;
@@ -23,9 +23,10 @@ export const Form = forwardRef((p, ref) => {
23
23
  layout,
24
24
  footer,
25
25
  mode,
26
+ disabled,
26
27
  requiredMarkStyle
27
28
  } = props,
28
- formProps = __rest(props, ["className", "style", "hasFeedback", "children", "layout", "footer", "mode", "requiredMarkStyle"]);
29
+ formProps = __rest(props, ["className", "style", "hasFeedback", "children", "layout", "footer", "mode", "disabled", "requiredMarkStyle"]);
29
30
 
30
31
  const {
31
32
  locale
@@ -76,7 +77,8 @@ export const Form = forwardRef((p, ref) => {
76
77
  name: formProps.name,
77
78
  hasFeedback,
78
79
  layout,
79
- requiredMarkStyle
80
+ requiredMarkStyle,
81
+ disabled: disabled
80
82
  }
81
83
  }, lists), footer && React.createElement("div", {
82
84
  className: `${classPrefix}-footer`
@@ -92,7 +92,7 @@
92
92
 
93
93
  .adm-form-item.adm-form-item-horizontal.adm-list-item {
94
94
  --align-items: stretch;
95
- --prefix-width: 6em;
95
+ --prefix-width: 6.8em;
96
96
  }
97
97
 
98
98
  .adm-form-item.adm-form-item-horizontal .adm-list-item-content-prefix {
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import './index.less';
3
- import { useForm } from 'rc-field-form';
3
+ import { useWatch, useForm } from 'rc-field-form';
4
4
  export declare type FormLayout = 'vertical' | 'horizontal';
5
5
  export type { FormProps, FormInstance } from './form';
6
6
  export type { FormItemProps } from './form-item';
@@ -9,7 +9,6 @@ export type { ValidateMessages, FieldData, NamePath, } from 'rc-field-form/es/in
9
9
  export type { FormArrayField, FormArrayOperation, FormArrayProps, } from './form-array';
10
10
  declare const _default: import("react").ForwardRefExoticComponent<Pick<import("rc-field-form").FormProps<any>, "children" | "form" | "name" | "initialValues" | "preserve" | "validateMessages" | "validateTrigger" | "onFieldsChange" | "onFinish" | "onFinishFailed" | "onValuesChange"> & import("../../utils/native-props").NativeProps<"--border-inner" | "--border-top" | "--border-bottom"> & Partial<import("./context").FormContextType> & {
11
11
  footer?: import("react").ReactNode;
12
- layout?: FormLayout | undefined;
13
12
  mode?: "default" | "card" | undefined;
14
13
  } & import("react").RefAttributes<import("./form").FormInstance>> & {
15
14
  Item: import("react").FC<import("./form-item").FormItemProps>;
@@ -19,5 +18,6 @@ declare const _default: import("react").ForwardRefExoticComponent<Pick<import("r
19
18
  }>;
20
19
  Array: import("react").FC<import("./form-array").FormArrayProps>;
21
20
  useForm: typeof useForm;
21
+ useWatch: typeof useWatch;
22
22
  };
23
23
  export default _default;
@@ -3,7 +3,7 @@ import { Form } from './form';
3
3
  import { attachPropertiesToComponent } from '../../utils/attach-properties-to-component';
4
4
  import { FormItem } from './form-item';
5
5
  import { Header } from './header';
6
- import { useForm } from 'rc-field-form';
6
+ import { useWatch, useForm } from 'rc-field-form';
7
7
  import { FormSubscribe } from './form-subscribe';
8
8
  import { FormArray } from './form-array';
9
9
  export default attachPropertiesToComponent(Form, {
@@ -11,5 +11,6 @@ export default attachPropertiesToComponent(Form, {
11
11
  Subscribe: FormSubscribe,
12
12
  Header,
13
13
  Array: FormArray,
14
- useForm
14
+ useForm,
15
+ useWatch
15
16
  });
@@ -4,5 +4,6 @@ export declare type IndexBarPanelProps = {
4
4
  index: string;
5
5
  title?: ReactNode;
6
6
  brief?: ReactNode;
7
+ children?: ReactNode;
7
8
  } & NativeProps;
8
9
  export declare const Panel: FC<IndexBarPanelProps>;
@@ -68,6 +68,10 @@
68
68
  display: none;
69
69
  }
70
70
 
71
+ .adm-input-element:disabled {
72
+ opacity: 1;
73
+ }
74
+
71
75
  .adm-input-element[type='date'],
72
76
  .adm-input-element[type='time'],
73
77
  .adm-input-element[type='datetime-local'] {
@@ -9,6 +9,7 @@ export declare type InputProps = Pick<NativeInputProps, 'maxLength' | 'minLength
9
9
  disabled?: boolean;
10
10
  readOnly?: boolean;
11
11
  clearable?: boolean;
12
+ onlyShowClearWhenFocus?: boolean;
12
13
  onClear?: () => void;
13
14
  id?: string;
14
15
  onEnterPress?: (e: React.KeyboardEvent<HTMLInputElement>) => void;
@@ -30,6 +31,7 @@ export declare const Input: React.ForwardRefExoticComponent<Pick<NativeInputProp
30
31
  disabled?: boolean | undefined;
31
32
  readOnly?: boolean | undefined;
32
33
  clearable?: boolean | undefined;
34
+ onlyShowClearWhenFocus?: boolean | undefined;
33
35
  onClear?: (() => void) | undefined;
34
36
  id?: string | undefined;
35
37
  onEnterPress?: ((e: React.KeyboardEvent<HTMLInputElement>) => void) | undefined;
@@ -8,7 +8,8 @@ import { useIsomorphicLayoutEffect } from 'ahooks';
8
8
  import { bound } from '../../utils/bound';
9
9
  const classPrefix = `adm-input`;
10
10
  const defaultProps = {
11
- defaultValue: ''
11
+ defaultValue: '',
12
+ onlyShowClearWhenFocus: true
12
13
  };
13
14
  export const Input = forwardRef((p, ref) => {
14
15
  const props = mergeProps(defaultProps, p);
@@ -70,6 +71,16 @@ export const Input = forwardRef((p, ref) => {
70
71
  }
71
72
  }
72
73
 
74
+ const shouldShowClear = (() => {
75
+ if (!props.clearable || !value || props.readOnly) return false;
76
+
77
+ if (props.onlyShowClearWhenFocus) {
78
+ return hasFocus;
79
+ } else {
80
+ return true;
81
+ }
82
+ })();
83
+
73
84
  return withNativeProps(props, React.createElement("div", {
74
85
  className: classNames(`${classPrefix}`, props.disabled && `${classPrefix}-disabled`)
75
86
  }, React.createElement("input", {
@@ -112,7 +123,7 @@ export const Input = forwardRef((p, ref) => {
112
123
  onCompositionStart: props.onCompositionStart,
113
124
  onCompositionEnd: props.onCompositionEnd,
114
125
  onClick: props.onClick
115
- }), props.clearable && !!value && !props.readOnly && hasFocus && React.createElement("div", {
126
+ }), shouldShowClear && React.createElement("div", {
116
127
  className: `${classPrefix}-clear`,
117
128
  onMouseDown: e => {
118
129
  e.preventDefault();
@@ -1,5 +1,4 @@
1
- import { __awaiter } from "tslib";
2
- import React, { useState } from 'react';
1
+ import React from 'react';
3
2
  import classNames from 'classnames';
4
3
  import Button from '../button';
5
4
  import { withNativeProps } from '../../utils/native-props';
@@ -7,26 +6,9 @@ export const ModalActionButton = props => {
7
6
  const {
8
7
  action
9
8
  } = props;
10
- const [loading, setLoading] = useState(false);
11
-
12
- function handleClick() {
13
- return __awaiter(this, void 0, void 0, function* () {
14
- setLoading(true);
15
-
16
- try {
17
- const promise = props.onAction();
18
- yield promise;
19
- setLoading(false);
20
- } catch (e) {
21
- setLoading(false);
22
- throw e;
23
- }
24
- });
25
- }
26
-
27
9
  return withNativeProps(props.action, React.createElement(Button, {
28
10
  key: action.key,
29
- onClick: handleClick,
11
+ onClick: props.onAction,
30
12
  className: classNames('adm-modal-button', {
31
13
  'adm-modal-button-primary': props.action.primary
32
14
  }),
@@ -34,7 +16,7 @@ export const ModalActionButton = props => {
34
16
  size: props.action.primary ? 'large' : 'middle',
35
17
  block: true,
36
18
  color: action.danger ? 'danger' : 'primary',
37
- loading: loading,
19
+ loading: 'auto',
38
20
  disabled: action.disabled
39
21
  }, action.text));
40
22
  };
@@ -8,6 +8,7 @@ export declare type SearchBarProps = Pick<InputProps, 'onFocus' | 'onBlur' | 'on
8
8
  maxLength?: number;
9
9
  placeholder?: string;
10
10
  clearable?: boolean;
11
+ onlyShowClearWhenFocus?: boolean;
11
12
  showCancelButton?: boolean | ((focus: boolean, value: string) => boolean);
12
13
  cancelText?: string;
13
14
  icon?: ReactNode;
@@ -22,6 +23,7 @@ export declare const SearchBar: React.ForwardRefExoticComponent<Pick<InputProps,
22
23
  maxLength?: number | undefined;
23
24
  placeholder?: string | undefined;
24
25
  clearable?: boolean | undefined;
26
+ onlyShowClearWhenFocus?: boolean | undefined;
25
27
  showCancelButton?: boolean | ((focus: boolean, value: string) => boolean) | undefined;
26
28
  cancelText?: string | undefined;
27
29
  icon?: ReactNode;
@@ -10,6 +10,7 @@ import { useConfig } from '../config-provider';
10
10
  const classPrefix = `adm-search-bar`;
11
11
  const defaultProps = {
12
12
  clearable: true,
13
+ onlyShowClearWhenFocus: false,
13
14
  showCancelButton: false,
14
15
  defaultValue: '',
15
16
  clearOnCancel: true,
@@ -101,6 +102,7 @@ export const SearchBar = forwardRef((p, ref) => {
101
102
  maxLength: props.maxLength,
102
103
  placeholder: props.placeholder,
103
104
  clearable: props.clearable,
105
+ onlyShowClearWhenFocus: props.onlyShowClearWhenFocus,
104
106
  onFocus: e => {
105
107
  var _a;
106
108
 
@@ -1,22 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import './swiper.less';
3
3
  export type { SwiperProps, SwiperRef } from './swiper';
4
- declare const _default: import("react").ForwardRefExoticComponent<{
5
- defaultIndex?: number | undefined;
6
- allowTouchMove?: boolean | undefined;
7
- autoplay?: boolean | undefined;
8
- autoplayInterval?: number | undefined;
9
- loop?: boolean | undefined;
10
- direction?: "vertical" | "horizontal" | undefined;
11
- onIndexChange?: ((index: number) => void) | undefined;
12
- indicatorProps?: Pick<import("../page-indicator").PageIndicatorProps, "style" | "className" | "color"> | undefined;
13
- indicator?: ((total: number, current: number) => import("react").ReactNode) | undefined;
14
- slideSize?: number | undefined;
15
- trackOffset?: number | undefined;
16
- stuckAtBoundary?: boolean | undefined;
17
- rubberband?: boolean | undefined;
18
- children?: import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>> | import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>[] | undefined;
19
- } & import("../../utils/native-props").NativeProps<"--border-radius" | "--width" | "--height" | "--track-padding"> & import("react").RefAttributes<import("./swiper").SwiperRef>> & {
4
+ declare const _default: import("react").ForwardRefExoticComponent<import("react").RefAttributes<unknown>> & {
20
5
  Item: import("react").FC<{
21
6
  onClick?: ((e: import("react").MouseEvent<HTMLDivElement, MouseEvent>) => void) | undefined;
22
7
  children?: import("react").ReactNode;
@@ -22,19 +22,4 @@ export declare type SwiperProps = {
22
22
  rubberband?: boolean;
23
23
  children?: ReactElement | ReactElement[];
24
24
  } & NativeProps<'--height' | '--width' | '--border-radius' | '--track-padding'>;
25
- export declare const Swiper: React.ForwardRefExoticComponent<{
26
- defaultIndex?: number | undefined;
27
- allowTouchMove?: boolean | undefined;
28
- autoplay?: boolean | undefined;
29
- autoplayInterval?: number | undefined;
30
- loop?: boolean | undefined;
31
- direction?: "vertical" | "horizontal" | undefined;
32
- onIndexChange?: ((index: number) => void) | undefined;
33
- indicatorProps?: Pick<PageIndicatorProps, "style" | "className" | "color"> | undefined;
34
- indicator?: ((total: number, current: number) => ReactNode) | undefined;
35
- slideSize?: number | undefined;
36
- trackOffset?: number | undefined;
37
- stuckAtBoundary?: boolean | undefined;
38
- rubberband?: boolean | undefined;
39
- children?: React.ReactElement<any, string | React.JSXElementConstructor<any>> | React.ReactElement<any, string | React.JSXElementConstructor<any>>[] | undefined;
40
- } & NativeProps<"--border-radius" | "--width" | "--height" | "--track-padding"> & React.RefAttributes<SwiperRef>>;
25
+ export declare const Swiper: React.ForwardRefExoticComponent<React.RefAttributes<unknown>>;
@@ -2,5 +2,7 @@ import "./global.css";
2
2
  import { canUseDom } from '../utils/can-use-dom';
3
3
 
4
4
  if (canUseDom) {
5
+ // Make sure the `:active` CSS selector of `button` and `a` take effect
6
+ // See: https://stackoverflow.com/questions/3885018/active-pseudo-class-doesnt-work-in-mobile-safari
5
7
  document.addEventListener('touchstart', () => {}, true);
6
8
  }
package/2x/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "antd-mobile",
3
- "version": "5.10.4",
3
+ "version": "5.11.0",
4
4
  "dependencies": {
5
5
  "@floating-ui/dom": "^0.4.2",
6
6
  "@react-spring/web": "^9.4.4",
@@ -16,7 +16,7 @@
16
16
  "classnames": "^2.3.1",
17
17
  "dayjs": "^1.11.0",
18
18
  "lodash": "^4.17.21",
19
- "rc-field-form": "^1.24.0",
19
+ "rc-field-form": "^1.26.2",
20
20
  "react-is": "^17.0.2",
21
21
  "staged-components": "^1.1.2",
22
22
  "tslib": "^2.3.1"