antd-mobile 5.11.2 → 5.12.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 (146) hide show
  1. package/2x/cjs/components/calendar/calendar.d.ts +4 -0
  2. package/2x/cjs/components/calendar/calendar.js +13 -9
  3. package/2x/cjs/components/capsule-tabs/capsule-tabs.css +1 -0
  4. package/2x/cjs/components/cascade-picker/cascade-picker.d.ts +6 -3
  5. package/2x/cjs/components/cascade-picker/cascade-picker.js +8 -4
  6. package/2x/cjs/components/cascade-picker/index.d.ts +4 -2
  7. package/2x/cjs/components/date-picker/date-picker.d.ts +18 -4
  8. package/2x/cjs/components/date-picker/date-picker.js +5 -6
  9. package/2x/cjs/components/date-picker/index.d.ts +15 -2
  10. package/2x/cjs/components/dialog/dialog.js +2 -2
  11. package/2x/cjs/components/form/form-item.d.ts +2 -1
  12. package/2x/cjs/components/form/form-item.js +21 -4
  13. package/2x/cjs/components/form/utils.d.ts +1 -0
  14. package/2x/cjs/components/form/utils.js +20 -0
  15. package/2x/cjs/components/image-uploader/image-uploader.js +1 -2
  16. package/2x/cjs/components/input/input.d.ts +2 -2
  17. package/2x/cjs/components/input/input.js +1 -0
  18. package/2x/cjs/components/jumbo-tabs/jumbo-tabs.css +1 -0
  19. package/2x/cjs/components/list/list.css +1 -0
  20. package/2x/cjs/components/mask/mask.js +1 -1
  21. package/2x/cjs/components/modal/modal.js +2 -2
  22. package/2x/cjs/components/picker/index.d.ts +44 -3
  23. package/2x/cjs/components/picker/picker.d.ts +32 -2
  24. package/2x/cjs/components/picker/picker.js +43 -16
  25. package/2x/cjs/components/popup/popup.js +1 -1
  26. package/2x/cjs/components/swipe-action/swipe-action.js +1 -1
  27. package/2x/cjs/components/tabs/tabs.css +1 -0
  28. package/2x/cjs/components/text-area/text-area.d.ts +2 -2
  29. package/2x/cjs/components/text-area/text-area.js +4 -1
  30. package/2x/cjs/components/toast/methods.js +3 -7
  31. package/2x/cjs/utils/render-to-body.js +3 -6
  32. package/2x/cjs/utils/render.d.ts +9 -0
  33. package/2x/cjs/utils/render.js +80 -0
  34. package/2x/cjs/utils/use-drag-and-pinch.d.ts +1 -1
  35. package/2x/cjs/utils/use-props-value.d.ts +1 -1
  36. package/2x/es/components/calendar/calendar.d.ts +4 -0
  37. package/2x/es/components/calendar/calendar.js +13 -9
  38. package/2x/es/components/capsule-tabs/capsule-tabs.css +1 -0
  39. package/2x/es/components/cascade-picker/cascade-picker.d.ts +6 -3
  40. package/2x/es/components/cascade-picker/cascade-picker.js +4 -3
  41. package/2x/es/components/cascade-picker/index.d.ts +4 -2
  42. package/2x/es/components/date-picker/date-picker.d.ts +18 -4
  43. package/2x/es/components/date-picker/date-picker.js +6 -5
  44. package/2x/es/components/date-picker/index.d.ts +15 -2
  45. package/2x/es/components/dialog/dialog.js +2 -2
  46. package/2x/es/components/form/form-item.d.ts +2 -1
  47. package/2x/es/components/form/form-item.js +23 -4
  48. package/2x/es/components/form/utils.d.ts +1 -0
  49. package/2x/es/components/form/utils.js +17 -0
  50. package/2x/es/components/image-uploader/image-uploader.js +1 -2
  51. package/2x/es/components/input/input.d.ts +2 -2
  52. package/2x/es/components/input/input.js +1 -0
  53. package/2x/es/components/jumbo-tabs/jumbo-tabs.css +1 -0
  54. package/2x/es/components/list/list.css +1 -0
  55. package/2x/es/components/mask/mask.js +1 -1
  56. package/2x/es/components/modal/modal.js +2 -2
  57. package/2x/es/components/picker/index.d.ts +44 -3
  58. package/2x/es/components/picker/picker.d.ts +32 -2
  59. package/2x/es/components/picker/picker.js +42 -17
  60. package/2x/es/components/popup/popup.js +1 -1
  61. package/2x/es/components/swipe-action/swipe-action.js +1 -1
  62. package/2x/es/components/tabs/tabs.css +1 -0
  63. package/2x/es/components/text-area/text-area.d.ts +2 -2
  64. package/2x/es/components/text-area/text-area.js +4 -2
  65. package/2x/es/components/toast/methods.js +3 -3
  66. package/2x/es/utils/render-to-body.js +3 -3
  67. package/2x/es/utils/render.d.ts +9 -0
  68. package/2x/es/utils/render.js +65 -0
  69. package/2x/es/utils/use-drag-and-pinch.d.ts +1 -1
  70. package/2x/es/utils/use-props-value.d.ts +1 -1
  71. package/2x/package.json +8 -8
  72. package/bundle/antd-mobile.cjs.js +5041 -4302
  73. package/bundle/antd-mobile.es.js +5043 -4304
  74. package/bundle/style.css +4 -0
  75. package/cjs/components/calendar/calendar.d.ts +4 -0
  76. package/cjs/components/calendar/calendar.js +13 -9
  77. package/cjs/components/capsule-tabs/capsule-tabs.css +1 -0
  78. package/cjs/components/cascade-picker/cascade-picker.d.ts +6 -3
  79. package/cjs/components/cascade-picker/cascade-picker.js +8 -4
  80. package/cjs/components/cascade-picker/index.d.ts +4 -2
  81. package/cjs/components/date-picker/date-picker.d.ts +18 -4
  82. package/cjs/components/date-picker/date-picker.js +5 -6
  83. package/cjs/components/date-picker/index.d.ts +15 -2
  84. package/cjs/components/dialog/dialog.js +2 -2
  85. package/cjs/components/form/form-item.d.ts +2 -1
  86. package/cjs/components/form/form-item.js +21 -4
  87. package/cjs/components/form/utils.d.ts +1 -0
  88. package/cjs/components/form/utils.js +20 -0
  89. package/cjs/components/image-uploader/image-uploader.js +1 -2
  90. package/cjs/components/input/input.d.ts +2 -2
  91. package/cjs/components/input/input.js +1 -0
  92. package/cjs/components/jumbo-tabs/jumbo-tabs.css +1 -0
  93. package/cjs/components/list/list.css +1 -0
  94. package/cjs/components/mask/mask.js +1 -1
  95. package/cjs/components/modal/modal.js +2 -2
  96. package/cjs/components/picker/index.d.ts +44 -3
  97. package/cjs/components/picker/picker.d.ts +32 -2
  98. package/cjs/components/picker/picker.js +43 -16
  99. package/cjs/components/popup/popup.js +1 -1
  100. package/cjs/components/swipe-action/swipe-action.js +1 -1
  101. package/cjs/components/tabs/tabs.css +1 -0
  102. package/cjs/components/text-area/text-area.d.ts +2 -2
  103. package/cjs/components/text-area/text-area.js +4 -1
  104. package/cjs/components/toast/methods.js +3 -7
  105. package/cjs/utils/render-to-body.js +3 -6
  106. package/cjs/utils/render.d.ts +9 -0
  107. package/cjs/utils/render.js +80 -0
  108. package/cjs/utils/use-drag-and-pinch.d.ts +1 -1
  109. package/cjs/utils/use-props-value.d.ts +1 -1
  110. package/es/components/calendar/calendar.d.ts +4 -0
  111. package/es/components/calendar/calendar.js +13 -9
  112. package/es/components/capsule-tabs/capsule-tabs.css +1 -0
  113. package/es/components/cascade-picker/cascade-picker.d.ts +6 -3
  114. package/es/components/cascade-picker/cascade-picker.js +4 -3
  115. package/es/components/cascade-picker/index.d.ts +4 -2
  116. package/es/components/date-picker/date-picker.d.ts +18 -4
  117. package/es/components/date-picker/date-picker.js +6 -5
  118. package/es/components/date-picker/index.d.ts +15 -2
  119. package/es/components/dialog/dialog.js +2 -2
  120. package/es/components/form/form-item.d.ts +2 -1
  121. package/es/components/form/form-item.js +23 -4
  122. package/es/components/form/utils.d.ts +1 -0
  123. package/es/components/form/utils.js +17 -0
  124. package/es/components/image-uploader/image-uploader.js +1 -2
  125. package/es/components/input/input.d.ts +2 -2
  126. package/es/components/input/input.js +1 -0
  127. package/es/components/jumbo-tabs/jumbo-tabs.css +1 -0
  128. package/es/components/list/list.css +1 -0
  129. package/es/components/mask/mask.js +1 -1
  130. package/es/components/modal/modal.js +2 -2
  131. package/es/components/picker/index.d.ts +44 -3
  132. package/es/components/picker/picker.d.ts +32 -2
  133. package/es/components/picker/picker.js +42 -17
  134. package/es/components/popup/popup.js +1 -1
  135. package/es/components/swipe-action/swipe-action.js +1 -1
  136. package/es/components/tabs/tabs.css +1 -0
  137. package/es/components/text-area/text-area.d.ts +2 -2
  138. package/es/components/text-area/text-area.js +4 -2
  139. package/es/components/toast/methods.js +3 -3
  140. package/es/utils/render-to-body.js +3 -3
  141. package/es/utils/render.d.ts +9 -0
  142. package/es/utils/render.js +65 -0
  143. package/es/utils/use-drag-and-pinch.d.ts +1 -1
  144. package/es/utils/use-props-value.d.ts +1 -1
  145. package/package.json +8 -8
  146. package/umd/antd-mobile.js +1 -1
@@ -7,6 +7,8 @@ exports.Picker = void 0;
7
7
 
8
8
  var _react = _interopRequireWildcard(require("react"));
9
9
 
10
+ var _classnames = _interopRequireDefault(require("classnames"));
11
+
10
12
  var _popup = _interopRequireDefault(require("../popup"));
11
13
 
12
14
  var _withDefaultProps = require("../../utils/with-default-props");
@@ -27,6 +29,8 @@ var _safeArea = _interopRequireDefault(require("../safe-area"));
27
29
 
28
30
  var _pickerUtils = require("./picker-utils");
29
31
 
32
+ var _shouldRender = require("../../utils/should-render");
33
+
30
34
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
31
35
 
32
36
  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); }
@@ -39,7 +43,7 @@ const defaultProps = {
39
43
  closeOnMaskClick: true,
40
44
  renderLabel: _pickerUtils.defaultRenderLabel
41
45
  };
42
- const Picker = (0, _react.memo)(p => {
46
+ const Picker = (0, _react.memo)((0, _react.forwardRef)((p, ref) => {
43
47
  var _a;
44
48
 
45
49
  const {
@@ -49,6 +53,29 @@ const Picker = (0, _react.memo)(p => {
49
53
  confirmText: locale.common.confirm,
50
54
  cancelText: locale.common.cancel
51
55
  }, p);
56
+ const [visible, setVisible] = (0, _usePropsValue.usePropsValue)({
57
+ value: props.visible,
58
+ defaultValue: false,
59
+ onChange: v => {
60
+ var _a;
61
+
62
+ if (v === false) {
63
+ (_a = props.onClose) === null || _a === void 0 ? void 0 : _a.call(props);
64
+ }
65
+ }
66
+ });
67
+ const actions = {
68
+ toggle: () => {
69
+ setVisible(v => !v);
70
+ },
71
+ open: () => {
72
+ setVisible(true);
73
+ },
74
+ close: () => {
75
+ setVisible(false);
76
+ }
77
+ };
78
+ (0, _react.useImperativeHandle)(ref, () => actions);
52
79
  const [value, setValue] = (0, _usePropsValue.usePropsValue)(Object.assign(Object.assign({}, props), {
53
80
  onChange: val => {
54
81
  var _a;
@@ -63,9 +90,9 @@ const Picker = (0, _react.memo)(p => {
63
90
  if (innerValue !== value) {
64
91
  setInnerValue(value);
65
92
  }
66
- }, [props.visible]);
93
+ }, [visible]);
67
94
  (0, _react.useEffect)(() => {
68
- if (!props.visible) {
95
+ if (!visible) {
69
96
  setInnerValue(value);
70
97
  }
71
98
  }, [value]);
@@ -74,10 +101,11 @@ const Picker = (0, _react.memo)(p => {
74
101
 
75
102
  setInnerValue(val);
76
103
 
77
- if (props.visible) {
104
+ if (visible) {
78
105
  (_a = props.onSelect) === null || _a === void 0 ? void 0 : _a.call(props, val, ext);
79
106
  }
80
107
  });
108
+ const shouldRender = (0, _shouldRender.useShouldRender)(visible, props.forceRender, props.destroyOnClose);
81
109
  const pickerElement = (0, _nativeProps.withNativeProps)(props, _react.default.createElement("div", {
82
110
  className: classPrefix
83
111
  }, _react.default.createElement("div", {
@@ -85,20 +113,18 @@ const Picker = (0, _react.memo)(p => {
85
113
  }, _react.default.createElement("a", {
86
114
  className: `${classPrefix}-header-button`,
87
115
  onClick: () => {
88
- var _a, _b;
116
+ var _a;
89
117
 
90
118
  (_a = props.onCancel) === null || _a === void 0 ? void 0 : _a.call(props);
91
- (_b = props.onClose) === null || _b === void 0 ? void 0 : _b.call(props);
119
+ setVisible(false);
92
120
  }
93
121
  }, props.cancelText), _react.default.createElement("div", {
94
122
  className: `${classPrefix}-header-title`
95
123
  }, props.title), _react.default.createElement("a", {
96
124
  className: `${classPrefix}-header-button`,
97
125
  onClick: () => {
98
- var _a;
99
-
100
126
  setValue(innerValue);
101
- (_a = props.onClose) === null || _a === void 0 ? void 0 : _a.call(props);
127
+ setVisible(false);
102
128
  }
103
129
  }, props.confirmText)), _react.default.createElement("div", {
104
130
  className: `${classPrefix}-body`
@@ -111,15 +137,16 @@ const Picker = (0, _react.memo)(p => {
111
137
  }))));
112
138
 
113
139
  const popupElement = _react.default.createElement(_popup.default, {
114
- className: `${classPrefix}-popup`,
115
- visible: props.visible,
140
+ style: props.popupStyle,
141
+ className: (0, _classnames.default)(`${classPrefix}-popup`, props.popupClassName),
142
+ visible: visible,
116
143
  position: 'bottom',
117
144
  onMaskClick: () => {
118
- var _a, _b;
145
+ var _a;
119
146
 
120
147
  if (!props.closeOnMaskClick) return;
121
148
  (_a = props.onCancel) === null || _a === void 0 ? void 0 : _a.call(props);
122
- (_b = props.onClose) === null || _b === void 0 ? void 0 : _b.call(props);
149
+ setVisible(false);
123
150
  },
124
151
  getContainer: props.getContainer,
125
152
  destroyOnClose: true,
@@ -128,11 +155,11 @@ const Picker = (0, _react.memo)(p => {
128
155
  onClick: props.onClick,
129
156
  forceRender: true,
130
157
  stopPropagation: props.stopPropagation
131
- }, pickerElement, _react.default.createElement(_safeArea.default, {
158
+ }, shouldRender && pickerElement, _react.default.createElement(_safeArea.default, {
132
159
  position: 'bottom'
133
160
  }));
134
161
 
135
- return _react.default.createElement(_react.default.Fragment, null, popupElement, (_a = props.children) === null || _a === void 0 ? void 0 : _a.call(props, extend.items));
136
- });
162
+ return _react.default.createElement(_react.default.Fragment, null, popupElement, (_a = props.children) === null || _a === void 0 ? void 0 : _a.call(props, extend.items, actions));
163
+ }));
137
164
  exports.Picker = Picker;
138
165
  Picker.displayName = 'Picker';
@@ -80,7 +80,7 @@ const Popup = p => {
80
80
  className: classPrefix,
81
81
  onClick: props.onClick,
82
82
  style: {
83
- display: active ? 'unset' : 'none'
83
+ display: active ? undefined : 'none'
84
84
  }
85
85
  }, props.mask && _react.default.createElement(_mask.default, {
86
86
  visible: props.visible,
@@ -206,7 +206,7 @@ const SwipeAction = (0, _react.forwardRef)((p, ref) => {
206
206
  }
207
207
  }, _react.default.createElement(_web.animated.div, {
208
208
  style: {
209
- pointerEvents: x.to(v => v !== 0 && x.goal !== 0 ? 'none' : 'unset')
209
+ pointerEvents: x.to(v => v !== 0 && x.goal !== 0 ? 'none' : 'auto')
210
210
  }
211
211
  }, props.children)), (0, _withStopPropagation.withStopPropagation)(props.stopPropagation, _react.default.createElement("div", {
212
212
  className: 'adm-swipe-action-actions adm-swipe-action-actions-right',
@@ -4,6 +4,7 @@
4
4
  --active-line-height: 4px;
5
5
  --active-line-border-radius: var(--active-line-height);
6
6
  position: relative;
7
+ min-width: 0;
7
8
  }
8
9
 
9
10
  .adm-tabs-header {
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import type { ReactNode } from 'react';
3
3
  import { NativeProps } from '../../utils/native-props';
4
- export declare type TextAreaProps = Pick<React.DetailedHTMLProps<React.TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement>, 'autoComplete' | 'autoFocus' | 'disabled' | 'readOnly' | 'onFocus' | 'onBlur' | 'onCompositionStart' | 'onCompositionEnd' | 'onClick'> & {
4
+ export declare type TextAreaProps = Pick<React.DetailedHTMLProps<React.TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement>, 'autoComplete' | 'autoFocus' | 'disabled' | 'readOnly' | 'name' | 'onFocus' | 'onBlur' | 'onCompositionStart' | 'onCompositionEnd' | 'onClick'> & {
5
5
  onChange?: (val: string) => void;
6
6
  value?: string;
7
7
  defaultValue?: string;
@@ -20,7 +20,7 @@ export declare type TextAreaRef = {
20
20
  focus: () => void;
21
21
  blur: () => void;
22
22
  };
23
- export declare const TextArea: React.ForwardRefExoticComponent<Pick<React.DetailedHTMLProps<React.TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement>, "onClick" | "disabled" | "onCompositionEnd" | "onCompositionStart" | "onFocus" | "onBlur" | "autoComplete" | "autoFocus" | "readOnly"> & {
23
+ export declare const TextArea: React.ForwardRefExoticComponent<Pick<React.DetailedHTMLProps<React.TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement>, "onClick" | "disabled" | "name" | "onCompositionEnd" | "onCompositionStart" | "onFocus" | "onBlur" | "autoComplete" | "autoFocus" | "readOnly"> & {
24
24
  onChange?: ((val: string) => void) | undefined;
25
25
  value?: string | undefined;
26
26
  defaultValue?: string | undefined;
@@ -7,6 +7,8 @@ exports.TextArea = void 0;
7
7
 
8
8
  var _react = _interopRequireWildcard(require("react"));
9
9
 
10
+ var _ahooks = require("ahooks");
11
+
10
12
  var _nativeProps = require("../../utils/native-props");
11
13
 
12
14
  var _usePropsValue = require("../../utils/use-props-value");
@@ -57,7 +59,7 @@ const TextArea = (0, _react.forwardRef)((p, ref) => {
57
59
  (_a = nativeTextAreaRef.current) === null || _a === void 0 ? void 0 : _a.blur();
58
60
  }
59
61
  }));
60
- (0, _react.useLayoutEffect)(() => {
62
+ (0, _ahooks.useIsomorphicLayoutEffect)(() => {
61
63
  if (!autoSize) return;
62
64
  const textArea = nativeTextAreaRef.current;
63
65
  if (!textArea) return;
@@ -130,6 +132,7 @@ const TextArea = (0, _react.forwardRef)((p, ref) => {
130
132
  autoFocus: props.autoFocus,
131
133
  disabled: props.disabled,
132
134
  readOnly: props.readOnly,
135
+ name: props.name,
133
136
  onFocus: props.onFocus,
134
137
  onBlur: props.onBlur,
135
138
  onClick: props.onClick
@@ -11,13 +11,11 @@ var _react = _interopRequireWildcard(require("react"));
11
11
 
12
12
  var _getContainer = require("../../utils/get-container");
13
13
 
14
- var _reactDom = _interopRequireDefault(require("react-dom"));
15
-
16
14
  var _toast = require("./toast");
17
15
 
18
16
  var _withDefaultProps = require("../../utils/with-default-props");
19
17
 
20
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
18
+ var _render = require("../../utils/render");
21
19
 
22
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); }
23
21
 
@@ -26,7 +24,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
26
24
  const containers = [];
27
25
 
28
26
  function unmount(container) {
29
- const unmountResult = _reactDom.default.unmountComponentAtNode(container);
27
+ const unmountResult = (0, _render.unmount)(container);
30
28
 
31
29
  if (unmountResult && container.parentNode) {
32
30
  container.parentNode.removeChild(container);
@@ -85,11 +83,9 @@ function show(p) {
85
83
  }));
86
84
  });
87
85
  const ref = (0, _react.createRef)();
88
-
89
- _reactDom.default.render(_react.default.createElement(TempToast, {
86
+ (0, _render.render)(_react.default.createElement(TempToast, {
90
87
  ref: ref
91
88
  }), container);
92
-
93
89
  return {
94
90
  close: () => {
95
91
  var _a;
@@ -5,23 +5,20 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.renderToBody = renderToBody;
7
7
 
8
- var _reactDom = _interopRequireDefault(require("react-dom"));
9
-
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
8
+ var _render = require("./render");
11
9
 
12
10
  function renderToBody(element) {
13
11
  const container = document.createElement('div');
14
12
  document.body.appendChild(container);
15
13
 
16
14
  function unmount() {
17
- const unmountResult = _reactDom.default.unmountComponentAtNode(container);
15
+ const unmountResult = (0, _render.unmount)(container);
18
16
 
19
17
  if (unmountResult && container.parentNode) {
20
18
  container.parentNode.removeChild(container);
21
19
  }
22
20
  }
23
21
 
24
- _reactDom.default.render(element, container);
25
-
22
+ (0, _render.render)(element, container);
26
23
  return unmount;
27
24
  }
@@ -0,0 +1,9 @@
1
+ import { ReactElement } from 'react';
2
+ import type { Root } from 'react-dom/client';
3
+ declare const MARK = "__antd_mobile_root__";
4
+ declare type ContainerType = (Element | DocumentFragment) & {
5
+ [MARK]?: Root;
6
+ };
7
+ export declare function render(node: ReactElement, container: ContainerType): void;
8
+ export declare function unmount(container: ContainerType): boolean | Promise<void>;
9
+ export {};
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.render = render;
7
+ exports.unmount = unmount;
8
+
9
+ var _tslib = require("tslib");
10
+
11
+ var ReactDOM = _interopRequireWildcard(require("react-dom"));
12
+
13
+ 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); }
14
+
15
+ 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; }
16
+
17
+ // Let compiler not to search module usage
18
+ const fullClone = Object.assign({}, ReactDOM);
19
+ const {
20
+ version,
21
+ render: reactRender,
22
+ unmountComponentAtNode
23
+ } = fullClone;
24
+ let createRoot;
25
+
26
+ try {
27
+ const mainVersion = Number((version || '').split('.')[0]);
28
+
29
+ if (mainVersion >= 18) {
30
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
31
+ createRoot = require('react-dom/client').createRoot;
32
+ }
33
+ } catch (e) {// Do nothing;
34
+ }
35
+
36
+ const MARK = '__antd_mobile_root__';
37
+
38
+ function legacyRender(node, container) {
39
+ reactRender(node, container);
40
+ }
41
+
42
+ function concurrentRender(node, container) {
43
+ const root = container[MARK] || createRoot(container);
44
+ root.render(node);
45
+ container[MARK] = root;
46
+ }
47
+
48
+ function render(node, container) {
49
+ if (createRoot) {
50
+ concurrentRender(node, container);
51
+ return;
52
+ }
53
+
54
+ legacyRender(node, container);
55
+ } // ========================== Unmount =========================
56
+
57
+
58
+ function legacyUnmount(container) {
59
+ return unmountComponentAtNode(container);
60
+ }
61
+
62
+ function concurrentUnmount(container) {
63
+ return (0, _tslib.__awaiter)(this, void 0, void 0, function* () {
64
+ // Delay to unmount to avoid React 18 sync warning
65
+ return Promise.resolve().then(() => {
66
+ var _a;
67
+
68
+ (_a = container[MARK]) === null || _a === void 0 ? void 0 : _a.unmount();
69
+ delete container[MARK];
70
+ });
71
+ });
72
+ }
73
+
74
+ function unmount(container) {
75
+ if (createRoot) {
76
+ return concurrentUnmount(container);
77
+ }
78
+
79
+ return legacyUnmount(container);
80
+ }
@@ -1 +1 @@
1
- export declare const useDragAndPinch: <Config extends import("@use-gesture/react").UserGestureConfig = import("@use-gesture/react").UserGestureConfig>(_handlers: Partial<import("@use-gesture/react").NativeHandlers<import("@use-gesture/react").EventTypes> & import("@use-gesture/react").UserHandlers<import("@use-gesture/react").EventTypes>>, _config?: {} | Config | undefined) => Config["target"] extends object ? void : (...args: any[]) => import("@use-gesture/react").ReactDOMAttributes;
1
+ export declare const useDragAndPinch: <Config extends import("@use-gesture/react").UserGestureConfig = import("@use-gesture/react").UserGestureConfig>(_handlers: Partial<import("@use-gesture/react").NativeHandlers<import("@use-gesture/react").EventTypes> & import("@use-gesture/react").UserHandlers<import("@use-gesture/react").EventTypes>>, _config?: Config | undefined) => Config["target"] extends object ? void : (...args: any[]) => import("@use-gesture/react").ReactDOMAttributes;
@@ -4,5 +4,5 @@ declare type Options<T> = {
4
4
  defaultValue: T;
5
5
  onChange?: (v: T) => void;
6
6
  };
7
- export declare function usePropsValue<T>(options: Options<T>): readonly [T, (this: unknown, v: SetStateAction<T>) => void];
7
+ export declare function usePropsValue<T>(options: Options<T>): readonly [T, (v: SetStateAction<T>) => void];
8
8
  export {};
@@ -9,6 +9,10 @@ export declare type CalenderRef = {
9
9
  jumpToToday: () => void;
10
10
  };
11
11
  export declare type CalendarProps = {
12
+ prevMonthButton?: React.ReactNode;
13
+ prevYearButton?: React.ReactNode;
14
+ nextMonthButton?: React.ReactNode;
15
+ nextYearButton?: React.ReactNode;
12
16
  onPageChange?: (year: number, month: number) => void;
13
17
  weekStartsOn?: 'Monday' | 'Sunday';
14
18
  renderLabel?: (date: Date) => string | null | undefined;
@@ -15,7 +15,11 @@ const classPrefix = 'adm-calendar';
15
15
  const defaultProps = {
16
16
  weekStartsOn: 'Sunday',
17
17
  defaultValue: null,
18
- allowClear: true
18
+ allowClear: true,
19
+ prevMonthButton: React.createElement(ArrowLeft, null),
20
+ prevYearButton: React.createElement(ArrowLeftDouble, null),
21
+ nextMonthButton: React.createElement(ArrowLeft, null),
22
+ nextYearButton: React.createElement(ArrowLeftDouble, null)
19
23
  };
20
24
  export const Calendar = forwardRef((p, ref) => {
21
25
  const today = dayjs();
@@ -72,28 +76,28 @@ export const Calendar = forwardRef((p, ref) => {
72
76
  const header = React.createElement("div", {
73
77
  className: `${classPrefix}-header`
74
78
  }, React.createElement("a", {
75
- className: `${classPrefix}-arrow-button`,
79
+ className: `${classPrefix}-arrow-button ${classPrefix}-arrow-button-year`,
76
80
  onClick: () => {
77
81
  setCurrent(current.subtract(1, 'year'));
78
82
  }
79
- }, React.createElement(ArrowLeftDouble, null)), React.createElement("a", {
80
- className: `${classPrefix}-arrow-button`,
83
+ }, props.prevYearButton), React.createElement("a", {
84
+ className: `${classPrefix}-arrow-button ${classPrefix}-arrow-button-month`,
81
85
  onClick: () => {
82
86
  setCurrent(current.subtract(1, 'month'));
83
87
  }
84
- }, React.createElement(ArrowLeft, null)), React.createElement("div", {
88
+ }, props.prevMonthButton), React.createElement("div", {
85
89
  className: `${classPrefix}-title`
86
90
  }, locale.Calendar.renderYearAndMonth(current.year(), current.month() + 1)), React.createElement("a", {
87
- className: `${classPrefix}-arrow-button ${classPrefix}-arrow-button-right`,
91
+ className: classNames(`${classPrefix}-arrow-button`, `${classPrefix}-arrow-button-right`, `${classPrefix}-arrow-button-right-month`),
88
92
  onClick: () => {
89
93
  setCurrent(current.add(1, 'month'));
90
94
  }
91
- }, React.createElement(ArrowLeft, null)), React.createElement("a", {
92
- className: `${classPrefix}-arrow-button ${classPrefix}-arrow-button-right`,
95
+ }, props.nextMonthButton), React.createElement("a", {
96
+ className: classNames(`${classPrefix}-arrow-button`, `${classPrefix}-arrow-button-right`, `${classPrefix}-arrow-button-right-year`),
93
97
  onClick: () => {
94
98
  setCurrent(current.add(1, 'year'));
95
99
  }
96
- }, React.createElement(ArrowLeftDouble, null)));
100
+ }, props.nextYearButton));
97
101
  const maxDay = useMemo(() => props.max && dayjs(props.max), [props.max]);
98
102
  const minDay = useMemo(() => props.min && dayjs(props.min), [props.min]);
99
103
 
@@ -1,5 +1,6 @@
1
1
  .adm-capsule-tabs {
2
2
  position: relative;
3
+ min-width: 0;
3
4
  }
4
5
 
5
6
  .adm-capsule-tabs-header {
@@ -1,5 +1,6 @@
1
- import { FC } from 'react';
2
- import type { PickerProps } from '../picker';
1
+ import React from 'react';
2
+ import type { PickerProps, PickerRef } from '../picker';
3
+ export declare type CascadePickerRef = PickerRef;
3
4
  export declare type CascadePickerOption = {
4
5
  label: string;
5
6
  value: string;
@@ -8,4 +9,6 @@ export declare type CascadePickerOption = {
8
9
  export declare type CascadePickerProps = Omit<PickerProps, 'columns'> & {
9
10
  options: CascadePickerOption[];
10
11
  };
11
- export declare const CascadePicker: FC<CascadePickerProps>;
12
+ export declare const CascadePicker: React.ForwardRefExoticComponent<Omit<PickerProps, "columns"> & {
13
+ options: CascadePickerOption[];
14
+ } & React.RefAttributes<import("../picker").PickerActions>>;
@@ -1,8 +1,8 @@
1
1
  import { __rest } from "tslib";
2
- import React from 'react';
2
+ import React, { forwardRef } from 'react';
3
3
  import Picker from '../picker';
4
4
  import { useColumnsFn } from './cascade-picker-utils';
5
- export const CascadePicker = props => {
5
+ export const CascadePicker = forwardRef((props, ref) => {
6
6
  const {
7
7
  options
8
8
  } = props,
@@ -10,6 +10,7 @@ export const CascadePicker = props => {
10
10
 
11
11
  const columnsFn = useColumnsFn(options);
12
12
  return React.createElement(Picker, Object.assign({}, pickerProps, {
13
+ ref: ref,
13
14
  columns: columnsFn
14
15
  }));
15
- };
16
+ });
@@ -1,7 +1,9 @@
1
1
  /// <reference types="react" />
2
2
  import { prompt } from './prompt';
3
- export type { CascadePickerProps, CascadePickerOption } from './cascade-picker';
4
- declare const _default: import("react").FC<import("./cascade-picker").CascadePickerProps> & {
3
+ export type { CascadePickerProps, CascadePickerRef, CascadePickerOption, } from './cascade-picker';
4
+ declare const _default: import("react").ForwardRefExoticComponent<Omit<import("../picker").PickerProps, "columns"> & {
5
+ options: import("./cascade-picker").CascadePickerOption[];
6
+ } & import("react").RefAttributes<import("../picker").PickerActions>> & {
5
7
  prompt: typeof prompt;
6
8
  };
7
9
  export default _default;
@@ -1,7 +1,8 @@
1
- import { FC, ReactNode } from 'react';
2
- import type { PickerProps } from '../picker';
1
+ import React, { ReactNode } from 'react';
2
+ import type { PickerProps, PickerRef, PickerActions } from '../picker';
3
3
  import { NativeProps } from '../../utils/native-props';
4
4
  import type { Precision, DatePickerFilter } from './date-picker-utils';
5
+ export declare type DatePickerRef = PickerRef;
5
6
  export declare type DatePickerProps = Pick<PickerProps, 'onCancel' | 'onClose' | 'closeOnMaskClick' | 'visible' | 'confirmText' | 'cancelText' | 'getContainer' | 'afterShow' | 'afterClose' | 'onClick' | 'title' | 'stopPropagation' | 'style' | 'mouseWheel'> & {
6
7
  value?: Date | null;
7
8
  defaultValue?: Date | null;
@@ -10,8 +11,21 @@ export declare type DatePickerProps = Pick<PickerProps, 'onCancel' | 'onClose' |
10
11
  min?: Date;
11
12
  max?: Date;
12
13
  precision?: Precision;
13
- children?: (value: Date | null) => ReactNode;
14
+ children?: (value: Date | null, actions: PickerActions) => ReactNode;
14
15
  renderLabel?: (type: Precision, data: number) => ReactNode;
15
16
  filter?: DatePickerFilter;
16
17
  } & NativeProps;
17
- export declare const DatePicker: FC<DatePickerProps>;
18
+ export declare const DatePicker: React.ForwardRefExoticComponent<Pick<PickerProps, "style" | "title" | "onClick" | "visible" | "getContainer" | "afterShow" | "afterClose" | "stopPropagation" | "onCancel" | "onClose" | "cancelText" | "closeOnMaskClick" | "mouseWheel" | "confirmText"> & {
19
+ value?: Date | null | undefined;
20
+ defaultValue?: Date | null | undefined;
21
+ onSelect?: ((value: Date) => void) | undefined;
22
+ onConfirm?: ((value: Date) => void) | undefined;
23
+ min?: Date | undefined;
24
+ max?: Date | undefined;
25
+ precision?: Precision | undefined;
26
+ children?: ((value: Date | null, actions: PickerActions) => ReactNode) | undefined;
27
+ renderLabel?: ((type: Precision, data: number) => ReactNode) | undefined;
28
+ filter?: Partial<Record<Precision, (val: number, extend: {
29
+ date: Date;
30
+ }) => boolean>> | undefined;
31
+ } & NativeProps<never> & React.RefAttributes<PickerActions>>;
@@ -1,4 +1,4 @@
1
- import React, { useCallback, useMemo } from 'react';
1
+ import React, { forwardRef, useCallback, useMemo } from 'react';
2
2
  import { useMemoizedFn } from 'ahooks';
3
3
  import Picker from '../picker';
4
4
  import { withNativeProps } from '../../utils/native-props';
@@ -14,7 +14,7 @@ const defaultProps = {
14
14
  renderLabel: defaultRenderLabel,
15
15
  defaultValue: null
16
16
  };
17
- export const DatePicker = p => {
17
+ export const DatePicker = forwardRef((p, ref) => {
18
18
  const props = mergeProps(defaultProps, p);
19
19
  const [value, setValue] = usePropsValue({
20
20
  value: props.value,
@@ -43,6 +43,7 @@ export const DatePicker = p => {
43
43
  });
44
44
  const columns = useCallback(selected => generateDatePickerColumns(selected, props.min, props.max, props.precision, props.renderLabel, props.filter), [props.min, props.max, props.precision, props.renderLabel]);
45
45
  return withNativeProps(props, React.createElement(Picker, {
46
+ ref: ref,
46
47
  columns: columns,
47
48
  value: pickerValue,
48
49
  onCancel: props.onCancel,
@@ -60,9 +61,9 @@ export const DatePicker = p => {
60
61
  title: props.title,
61
62
  stopPropagation: props.stopPropagation,
62
63
  mouseWheel: props.mouseWheel
63
- }, () => {
64
+ }, (_, actions) => {
64
65
  var _a;
65
66
 
66
- return (_a = props.children) === null || _a === void 0 ? void 0 : _a.call(props, value);
67
+ return (_a = props.children) === null || _a === void 0 ? void 0 : _a.call(props, value, actions);
67
68
  }));
68
- };
69
+ });
@@ -1,9 +1,22 @@
1
1
  /// <reference types="react" />
2
2
  import './date-picker.less';
3
3
  import { prompt } from './prompt';
4
- export type { DatePickerProps } from './date-picker';
4
+ export type { DatePickerProps, DatePickerRef } from './date-picker';
5
5
  export type { DatePickerFilter } from './date-picker-utils';
6
- declare const _default: import("react").FC<import("./date-picker").DatePickerProps> & {
6
+ declare const _default: import("react").ForwardRefExoticComponent<Pick<import("../picker").PickerProps, "style" | "title" | "onClick" | "visible" | "getContainer" | "afterShow" | "afterClose" | "stopPropagation" | "onCancel" | "onClose" | "cancelText" | "closeOnMaskClick" | "mouseWheel" | "confirmText"> & {
7
+ value?: Date | null | undefined;
8
+ defaultValue?: Date | null | undefined;
9
+ onSelect?: ((value: Date) => void) | undefined;
10
+ onConfirm?: ((value: Date) => void) | undefined;
11
+ min?: Date | undefined;
12
+ max?: Date | undefined;
13
+ precision?: import("./date-picker-utils").Precision | undefined;
14
+ children?: ((value: Date | null, actions: import("../picker").PickerActions) => import("react").ReactNode) | undefined;
15
+ renderLabel?: ((type: import("./date-picker-utils").Precision, data: number) => import("react").ReactNode) | undefined;
16
+ filter?: Partial<Record<import("./date-picker-utils").Precision, (val: number, extend: {
17
+ date: Date;
18
+ }) => boolean>> | undefined;
19
+ } & import("../../utils/native-props").NativeProps<never> & import("react").RefAttributes<import("../picker").PickerActions>> & {
7
20
  prompt: typeof prompt;
8
21
  };
9
22
  export default _default;
@@ -88,7 +88,7 @@ export const Dialog = p => {
88
88
  const node = withNativeProps(props, React.createElement("div", {
89
89
  className: cls(),
90
90
  style: {
91
- display: active ? 'unset' : 'none'
91
+ display: active ? undefined : 'none'
92
92
  }
93
93
  }, React.createElement(Mask, {
94
94
  visible: props.visible,
@@ -99,7 +99,7 @@ export const Dialog = p => {
99
99
  }), React.createElement("div", {
100
100
  className: cls('wrap'),
101
101
  style: {
102
- pointerEvents: props.visible ? 'unset' : 'none'
102
+ pointerEvents: props.visible ? undefined : 'none'
103
103
  }
104
104
  }, React.createElement(animated.div, {
105
105
  style: style
@@ -7,7 +7,7 @@ import type { FormLayout } from './index';
7
7
  declare type RenderChildren<Values = any> = (form: FormInstance<Values>) => React.ReactNode;
8
8
  declare type ChildrenType<Values = any> = RenderChildren<Values> | React.ReactNode;
9
9
  declare type RcFieldProps = Omit<FieldProps, 'children'>;
10
- export declare type FormItemProps = Pick<RcFieldProps, 'dependencies' | 'valuePropName' | 'name' | 'rules' | 'messageVariables' | 'trigger' | 'validateTrigger' | 'shouldUpdate' | 'initialValue'> & Pick<ListItemProps, 'style' | 'onClick' | 'extra' | 'clickable' | 'arrow' | 'description'> & {
10
+ export declare type FormItemProps = Pick<RcFieldProps, 'dependencies' | 'valuePropName' | 'name' | 'rules' | 'messageVariables' | 'trigger' | 'validateTrigger' | 'shouldUpdate' | 'initialValue'> & Pick<ListItemProps, 'style' | 'extra' | 'clickable' | 'arrow' | 'description'> & {
11
11
  label?: React.ReactNode;
12
12
  help?: React.ReactNode;
13
13
  hasFeedback?: boolean;
@@ -18,6 +18,7 @@ export declare type FormItemProps = Pick<RcFieldProps, 'dependencies' | 'valuePr
18
18
  layout?: FormLayout;
19
19
  childElementPosition?: 'normal' | 'right';
20
20
  children?: ChildrenType;
21
+ onClick?: (e: React.MouseEvent, widgetRef: React.MutableRefObject<any>) => void;
21
22
  } & NativeProps;
22
23
  export declare const FormItem: FC<FormItemProps>;
23
24
  export {};