antd-mobile 5.11.0 → 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 (230) 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-utils.d.ts +2 -2
  5. package/2x/cjs/components/cascade-picker/cascade-picker-utils.js +37 -16
  6. package/2x/cjs/components/cascade-picker/cascade-picker.d.ts +6 -3
  7. package/2x/cjs/components/cascade-picker/cascade-picker.js +10 -11
  8. package/2x/cjs/components/cascade-picker/index.d.ts +4 -2
  9. package/2x/cjs/components/cascade-picker-view/cascade-picker-view.js +2 -7
  10. package/2x/cjs/components/date-picker/date-picker.d.ts +18 -4
  11. package/2x/cjs/components/date-picker/date-picker.js +5 -6
  12. package/2x/cjs/components/date-picker/index.d.ts +15 -2
  13. package/2x/cjs/components/dialog/dialog.js +2 -2
  14. package/2x/cjs/components/form/form-item.d.ts +2 -1
  15. package/2x/cjs/components/form/form-item.js +21 -4
  16. package/2x/cjs/components/form/utils.d.ts +1 -0
  17. package/2x/cjs/components/form/utils.js +20 -0
  18. package/2x/cjs/components/image-uploader/image-uploader.js +10 -4
  19. package/2x/cjs/components/input/input.d.ts +2 -2
  20. package/2x/cjs/components/input/input.js +1 -0
  21. package/2x/cjs/components/jumbo-tabs/jumbo-tabs.css +1 -0
  22. package/2x/cjs/components/list/list-item.js +7 -5
  23. package/2x/cjs/components/list/list.css +1 -0
  24. package/2x/cjs/components/mask/mask.js +1 -1
  25. package/2x/cjs/components/modal/modal.js +2 -2
  26. package/2x/cjs/components/picker/index.d.ts +44 -3
  27. package/2x/cjs/components/picker/picker.d.ts +32 -2
  28. package/2x/cjs/components/picker/picker.js +43 -16
  29. package/2x/cjs/components/popup/popup.js +1 -1
  30. package/2x/cjs/components/swipe-action/swipe-action.js +1 -1
  31. package/2x/cjs/components/swiper/index.d.ts +16 -1
  32. package/2x/cjs/components/swiper/swiper.d.ts +16 -1
  33. package/2x/cjs/components/tabs/tabs.css +1 -0
  34. package/2x/cjs/components/text-area/text-area.d.ts +2 -2
  35. package/2x/cjs/components/text-area/text-area.js +4 -1
  36. package/2x/cjs/components/toast/methods.js +3 -7
  37. package/2x/cjs/components/virtual-input/virtual-input.js +2 -1
  38. package/2x/cjs/locales/base.d.ts +1 -0
  39. package/2x/cjs/locales/base.js +2 -1
  40. package/2x/cjs/locales/en-US.d.ts +1 -0
  41. package/2x/cjs/locales/es-ES.d.ts +1 -0
  42. package/2x/cjs/locales/fa-IR.d.ts +1 -0
  43. package/2x/cjs/locales/ko-KR.d.ts +1 -0
  44. package/2x/cjs/locales/zh-CN.d.ts +1 -0
  45. package/2x/cjs/locales/zh-CN.js +2 -1
  46. package/2x/cjs/locales/zh-HK.d.ts +1 -0
  47. package/2x/cjs/locales/zh-TW.d.ts +1 -0
  48. package/2x/cjs/utils/is-node-with-content.d.ts +4 -0
  49. package/2x/cjs/utils/is-node-with-content.js +10 -0
  50. package/2x/cjs/utils/render-to-body.js +3 -6
  51. package/2x/cjs/utils/render.d.ts +9 -0
  52. package/2x/cjs/utils/render.js +80 -0
  53. package/2x/cjs/utils/use-drag-and-pinch.d.ts +1 -1
  54. package/2x/cjs/utils/use-props-value.d.ts +1 -1
  55. package/2x/es/components/calendar/calendar.d.ts +4 -0
  56. package/2x/es/components/calendar/calendar.js +13 -9
  57. package/2x/es/components/capsule-tabs/capsule-tabs.css +1 -0
  58. package/2x/es/components/cascade-picker/cascade-picker-utils.d.ts +2 -2
  59. package/2x/es/components/cascade-picker/cascade-picker-utils.js +35 -15
  60. package/2x/es/components/cascade-picker/cascade-picker.d.ts +6 -3
  61. package/2x/es/components/cascade-picker/cascade-picker.js +7 -10
  62. package/2x/es/components/cascade-picker/index.d.ts +4 -2
  63. package/2x/es/components/cascade-picker-view/cascade-picker-view.js +3 -7
  64. package/2x/es/components/date-picker/date-picker.d.ts +18 -4
  65. package/2x/es/components/date-picker/date-picker.js +6 -5
  66. package/2x/es/components/date-picker/index.d.ts +15 -2
  67. package/2x/es/components/dialog/dialog.js +2 -2
  68. package/2x/es/components/form/form-item.d.ts +2 -1
  69. package/2x/es/components/form/form-item.js +23 -4
  70. package/2x/es/components/form/utils.d.ts +1 -0
  71. package/2x/es/components/form/utils.js +17 -0
  72. package/2x/es/components/image-uploader/image-uploader.js +9 -4
  73. package/2x/es/components/input/input.d.ts +2 -2
  74. package/2x/es/components/input/input.js +1 -0
  75. package/2x/es/components/jumbo-tabs/jumbo-tabs.css +1 -0
  76. package/2x/es/components/list/list-item.js +6 -5
  77. package/2x/es/components/list/list.css +1 -0
  78. package/2x/es/components/mask/mask.js +1 -1
  79. package/2x/es/components/modal/modal.js +2 -2
  80. package/2x/es/components/picker/index.d.ts +44 -3
  81. package/2x/es/components/picker/picker.d.ts +32 -2
  82. package/2x/es/components/picker/picker.js +42 -17
  83. package/2x/es/components/popup/popup.js +1 -1
  84. package/2x/es/components/swipe-action/swipe-action.js +1 -1
  85. package/2x/es/components/swiper/index.d.ts +16 -1
  86. package/2x/es/components/swiper/swiper.d.ts +16 -1
  87. package/2x/es/components/tabs/tabs.css +1 -0
  88. package/2x/es/components/text-area/text-area.d.ts +2 -2
  89. package/2x/es/components/text-area/text-area.js +4 -2
  90. package/2x/es/components/toast/methods.js +3 -3
  91. package/2x/es/components/virtual-input/virtual-input.js +2 -1
  92. package/2x/es/locales/base.d.ts +1 -0
  93. package/2x/es/locales/base.js +2 -1
  94. package/2x/es/locales/en-US.d.ts +1 -0
  95. package/2x/es/locales/es-ES.d.ts +1 -0
  96. package/2x/es/locales/fa-IR.d.ts +1 -0
  97. package/2x/es/locales/ko-KR.d.ts +1 -0
  98. package/2x/es/locales/zh-CN.d.ts +1 -0
  99. package/2x/es/locales/zh-CN.js +2 -1
  100. package/2x/es/locales/zh-HK.d.ts +1 -0
  101. package/2x/es/locales/zh-TW.d.ts +1 -0
  102. package/2x/es/utils/is-node-with-content.d.ts +4 -0
  103. package/2x/es/utils/is-node-with-content.js +3 -0
  104. package/2x/es/utils/render-to-body.js +3 -3
  105. package/2x/es/utils/render.d.ts +9 -0
  106. package/2x/es/utils/render.js +65 -0
  107. package/2x/es/utils/use-drag-and-pinch.d.ts +1 -1
  108. package/2x/es/utils/use-props-value.d.ts +1 -1
  109. package/2x/package.json +8 -8
  110. package/bundle/antd-mobile.cjs.js +5093 -4356
  111. package/bundle/antd-mobile.es.js +5094 -4357
  112. package/bundle/style.css +4 -0
  113. package/cjs/components/calendar/calendar.d.ts +4 -0
  114. package/cjs/components/calendar/calendar.js +13 -9
  115. package/cjs/components/capsule-tabs/capsule-tabs.css +1 -0
  116. package/cjs/components/cascade-picker/cascade-picker-utils.d.ts +2 -2
  117. package/cjs/components/cascade-picker/cascade-picker-utils.js +37 -16
  118. package/cjs/components/cascade-picker/cascade-picker.d.ts +6 -3
  119. package/cjs/components/cascade-picker/cascade-picker.js +10 -11
  120. package/cjs/components/cascade-picker/index.d.ts +4 -2
  121. package/cjs/components/cascade-picker-view/cascade-picker-view.js +2 -7
  122. package/cjs/components/date-picker/date-picker.d.ts +18 -4
  123. package/cjs/components/date-picker/date-picker.js +5 -6
  124. package/cjs/components/date-picker/index.d.ts +15 -2
  125. package/cjs/components/dialog/dialog.js +2 -2
  126. package/cjs/components/form/form-item.d.ts +2 -1
  127. package/cjs/components/form/form-item.js +21 -4
  128. package/cjs/components/form/utils.d.ts +1 -0
  129. package/cjs/components/form/utils.js +20 -0
  130. package/cjs/components/image-uploader/image-uploader.js +10 -4
  131. package/cjs/components/input/input.d.ts +2 -2
  132. package/cjs/components/input/input.js +1 -0
  133. package/cjs/components/jumbo-tabs/jumbo-tabs.css +1 -0
  134. package/cjs/components/list/list-item.js +7 -5
  135. package/cjs/components/list/list.css +1 -0
  136. package/cjs/components/mask/mask.js +1 -1
  137. package/cjs/components/modal/modal.js +2 -2
  138. package/cjs/components/picker/index.d.ts +44 -3
  139. package/cjs/components/picker/picker.d.ts +32 -2
  140. package/cjs/components/picker/picker.js +43 -16
  141. package/cjs/components/popup/popup.js +1 -1
  142. package/cjs/components/swipe-action/swipe-action.js +1 -1
  143. package/cjs/components/swiper/index.d.ts +16 -1
  144. package/cjs/components/swiper/swiper.d.ts +16 -1
  145. package/cjs/components/tabs/tabs.css +1 -0
  146. package/cjs/components/text-area/text-area.d.ts +2 -2
  147. package/cjs/components/text-area/text-area.js +4 -1
  148. package/cjs/components/toast/methods.js +3 -7
  149. package/cjs/components/virtual-input/virtual-input.js +2 -1
  150. package/cjs/locales/base.d.ts +1 -0
  151. package/cjs/locales/base.js +2 -1
  152. package/cjs/locales/en-US.d.ts +1 -0
  153. package/cjs/locales/es-ES.d.ts +1 -0
  154. package/cjs/locales/fa-IR.d.ts +1 -0
  155. package/cjs/locales/ko-KR.d.ts +1 -0
  156. package/cjs/locales/zh-CN.d.ts +1 -0
  157. package/cjs/locales/zh-CN.js +2 -1
  158. package/cjs/locales/zh-HK.d.ts +1 -0
  159. package/cjs/locales/zh-TW.d.ts +1 -0
  160. package/cjs/utils/is-node-with-content.d.ts +4 -0
  161. package/cjs/utils/is-node-with-content.js +10 -0
  162. package/cjs/utils/render-to-body.js +3 -6
  163. package/cjs/utils/render.d.ts +9 -0
  164. package/cjs/utils/render.js +80 -0
  165. package/cjs/utils/use-drag-and-pinch.d.ts +1 -1
  166. package/cjs/utils/use-props-value.d.ts +1 -1
  167. package/es/components/calendar/calendar.d.ts +4 -0
  168. package/es/components/calendar/calendar.js +13 -9
  169. package/es/components/capsule-tabs/capsule-tabs.css +1 -0
  170. package/es/components/cascade-picker/cascade-picker-utils.d.ts +2 -2
  171. package/es/components/cascade-picker/cascade-picker-utils.js +35 -15
  172. package/es/components/cascade-picker/cascade-picker.d.ts +6 -3
  173. package/es/components/cascade-picker/cascade-picker.js +7 -10
  174. package/es/components/cascade-picker/index.d.ts +4 -2
  175. package/es/components/cascade-picker-view/cascade-picker-view.js +3 -7
  176. package/es/components/date-picker/date-picker.d.ts +18 -4
  177. package/es/components/date-picker/date-picker.js +6 -5
  178. package/es/components/date-picker/index.d.ts +15 -2
  179. package/es/components/dialog/dialog.js +2 -2
  180. package/es/components/form/form-item.d.ts +2 -1
  181. package/es/components/form/form-item.js +23 -4
  182. package/es/components/form/utils.d.ts +1 -0
  183. package/es/components/form/utils.js +17 -0
  184. package/es/components/image-uploader/image-uploader.js +9 -4
  185. package/es/components/input/input.d.ts +2 -2
  186. package/es/components/input/input.js +1 -0
  187. package/es/components/jumbo-tabs/jumbo-tabs.css +1 -0
  188. package/es/components/list/list-item.js +6 -5
  189. package/es/components/list/list.css +1 -0
  190. package/es/components/mask/mask.js +1 -1
  191. package/es/components/modal/modal.js +2 -2
  192. package/es/components/picker/index.d.ts +44 -3
  193. package/es/components/picker/picker.d.ts +32 -2
  194. package/es/components/picker/picker.js +42 -17
  195. package/es/components/popup/popup.js +1 -1
  196. package/es/components/swipe-action/swipe-action.js +1 -1
  197. package/es/components/swiper/index.d.ts +16 -1
  198. package/es/components/swiper/swiper.d.ts +16 -1
  199. package/es/components/tabs/tabs.css +1 -0
  200. package/es/components/text-area/text-area.d.ts +2 -2
  201. package/es/components/text-area/text-area.js +4 -2
  202. package/es/components/toast/methods.js +3 -3
  203. package/es/components/virtual-input/virtual-input.js +2 -1
  204. package/es/locales/base.d.ts +1 -0
  205. package/es/locales/base.js +2 -1
  206. package/es/locales/en-US.d.ts +1 -0
  207. package/es/locales/es-ES.d.ts +1 -0
  208. package/es/locales/fa-IR.d.ts +1 -0
  209. package/es/locales/ko-KR.d.ts +1 -0
  210. package/es/locales/zh-CN.d.ts +1 -0
  211. package/es/locales/zh-CN.js +2 -1
  212. package/es/locales/zh-HK.d.ts +1 -0
  213. package/es/locales/zh-TW.d.ts +1 -0
  214. package/es/utils/is-node-with-content.d.ts +4 -0
  215. package/es/utils/is-node-with-content.js +3 -0
  216. package/es/utils/render-to-body.js +3 -3
  217. package/es/utils/render.d.ts +9 -0
  218. package/es/utils/render.js +65 -0
  219. package/es/utils/use-drag-and-pinch.d.ts +1 -1
  220. package/es/utils/use-props-value.d.ts +1 -1
  221. package/package.json +8 -8
  222. package/umd/antd-mobile.js +1 -1
  223. package/2x/cjs/components/cascade-picker/use-cascade-picker-options.d.ts +0 -5
  224. package/2x/cjs/components/cascade-picker/use-cascade-picker-options.js +0 -40
  225. package/2x/es/components/cascade-picker/use-cascade-picker-options.d.ts +0 -5
  226. package/2x/es/components/cascade-picker/use-cascade-picker-options.js +0 -32
  227. package/cjs/components/cascade-picker/use-cascade-picker-options.d.ts +0 -5
  228. package/cjs/components/cascade-picker/use-cascade-picker-options.js +0 -40
  229. package/es/components/cascade-picker/use-cascade-picker-options.d.ts +0 -5
  230. package/es/components/cascade-picker/use-cascade-picker-options.js +0 -32
@@ -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,3 +1,3 @@
1
- import { PickerColumn } from '../picker-view';
1
+ import { PickerColumn, PickerValue } from '../picker-view';
2
2
  import { CascadePickerOption } from './cascade-picker';
3
- export declare function generateCascadePickerColumns(value: string[], options: CascadePickerOption[], depth: number, subOptionsRecord: Record<string, CascadePickerOption[]>): PickerColumn[];
3
+ export declare function useColumnsFn(options: CascadePickerOption[]): (selected: PickerValue[]) => PickerColumn[];
@@ -1,23 +1,43 @@
1
- export function generateCascadePickerColumns(value, options, depth, subOptionsRecord) {
2
- const columns = [];
3
- columns.push(options.map(option => ({
4
- label: option.label,
5
- value: option.value
6
- })));
1
+ import { useMemo } from 'react';
2
+ export function useColumnsFn(options) {
3
+ const depth = useMemo(() => {
4
+ let depth = 0;
7
5
 
8
- for (let i = 0; i < depth - 1; i++) {
9
- const x = value[i];
10
- const subOptions = subOptionsRecord[x];
6
+ function traverse(options, currentDepth) {
7
+ if (currentDepth > depth) depth = currentDepth;
8
+ const nextDepth = currentDepth + 1;
9
+ options.forEach(option => {
10
+ if (option.children) {
11
+ traverse(option.children, nextDepth);
12
+ }
13
+ });
14
+ }
11
15
 
12
- if (!subOptions) {
13
- columns.push([]);
14
- } else {
15
- columns.push(subOptions.map(option => ({
16
+ traverse(options, 1);
17
+ return depth;
18
+ }, [options]);
19
+ return selected => {
20
+ const columns = [];
21
+ let currentOptions = options;
22
+ let i = 0;
23
+
24
+ while (true) {
25
+ columns.push(currentOptions.map(option => ({
16
26
  label: option.label,
17
27
  value: option.value
18
28
  })));
29
+ const x = selected[i];
30
+ const targetOptions = currentOptions.find(option => option.value === x);
31
+ if (!targetOptions || !targetOptions.children) break;
32
+ currentOptions = targetOptions.children;
33
+ i++;
34
+ }
35
+
36
+ while (i < depth - 1) {
37
+ columns.push([]);
38
+ i++;
19
39
  }
20
- }
21
40
 
22
- return columns;
41
+ return columns;
42
+ };
23
43
  }
@@ -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,19 +1,16 @@
1
1
  import { __rest } from "tslib";
2
- import React from 'react';
2
+ import React, { forwardRef } from 'react';
3
3
  import Picker from '../picker';
4
- import { useCascadePickerOptions } from './use-cascade-picker-options';
5
- import { generateCascadePickerColumns } from './cascade-picker-utils';
6
- export const CascadePicker = props => {
4
+ import { useColumnsFn } from './cascade-picker-utils';
5
+ export const CascadePicker = forwardRef((props, ref) => {
7
6
  const {
8
7
  options
9
8
  } = props,
10
9
  pickerProps = __rest(props, ["options"]);
11
10
 
12
- const {
13
- depth,
14
- subOptionsRecord
15
- } = useCascadePickerOptions(options);
11
+ const columnsFn = useColumnsFn(options);
16
12
  return React.createElement(Picker, Object.assign({}, pickerProps, {
17
- columns: selected => generateCascadePickerColumns(selected, options, depth, subOptionsRecord)
13
+ ref: ref,
14
+ columns: columnsFn
18
15
  }));
19
- };
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,19 +1,15 @@
1
1
  import { __rest } from "tslib";
2
2
  import React from 'react';
3
3
  import PickerView from '../picker-view';
4
- import { useCascadePickerOptions } from '../cascade-picker/use-cascade-picker-options';
5
- import { generateCascadePickerColumns } from '../cascade-picker/cascade-picker-utils';
4
+ import { useColumnsFn } from '../cascade-picker/cascade-picker-utils';
6
5
  export const CascadePickerView = props => {
7
6
  const {
8
7
  options
9
8
  } = props,
10
9
  pickerProps = __rest(props, ["options"]);
11
10
 
12
- const {
13
- depth,
14
- subOptionsRecord
15
- } = useCascadePickerOptions(options);
11
+ const columnsFn = useColumnsFn(options);
16
12
  return React.createElement(PickerView, Object.assign({}, pickerProps, {
17
- columns: selected => generateCascadePickerColumns(selected, options, depth, subOptionsRecord)
13
+ columns: columnsFn
18
14
  }));
19
15
  };
@@ -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 {};
@@ -1,11 +1,11 @@
1
1
  import { __rest } from "tslib";
2
- import React, { useContext, useCallback, useState } from 'react';
2
+ import React, { useContext, useCallback, useState, useRef } from 'react';
3
3
  import classNames from 'classnames';
4
4
  import { Field } from 'rc-field-form';
5
5
  import FieldContext from 'rc-field-form/lib/FieldContext';
6
6
  import { devWarning } from '../../utils/dev-log';
7
7
  import { FormContext, NoStyleItemContext } from './context';
8
- import { toArray } from './utils';
8
+ import { toArray, isSafeSetRefComponent } from './utils';
9
9
  import List from '../list';
10
10
  import Popover from '../popover';
11
11
  import { QuestionCircleOutline } from 'antd-mobile-icons';
@@ -147,7 +147,8 @@ export const FormItem = props => {
147
147
  validateTrigger: contextValidateTrigger
148
148
  } = useContext(FieldContext);
149
149
  const mergedValidateTrigger = undefinedFallback(validateTrigger, contextValidateTrigger, trigger);
150
- const updateRef = React.useRef(0);
150
+ const widgetRef = useRef(null);
151
+ const updateRef = useRef(0);
151
152
  updateRef.current += 1;
152
153
  const [subMetas, setSubMetas] = useState({});
153
154
  const onSubMetaChange = useCallback((subMeta, namePath) => {
@@ -209,7 +210,7 @@ export const FormItem = props => {
209
210
  htmlFor: fieldId,
210
211
  errors: errors,
211
212
  warnings: warnings,
212
- onClick: onClick,
213
+ onClick: onClick && (e => onClick(e, widgetRef)),
213
214
  hidden: hidden,
214
215
  layout: layout,
215
216
  childElementPosition: childElementPosition,
@@ -286,6 +287,24 @@ export const FormItem = props => {
286
287
 
287
288
  const childProps = Object.assign(Object.assign({}, children.props), control);
288
289
 
290
+ if (isSafeSetRefComponent(children)) {
291
+ childProps.ref = instance => {
292
+ const originRef = children.ref;
293
+
294
+ if (originRef) {
295
+ if (typeof originRef === 'function') {
296
+ originRef(instance);
297
+ }
298
+
299
+ if ('current' in originRef) {
300
+ originRef.current = instance;
301
+ }
302
+ }
303
+
304
+ widgetRef.current = instance;
305
+ };
306
+ }
307
+
289
308
  if (!childProps.id) {
290
309
  childProps.id = fieldId;
291
310
  } // We should keep user origin event handler
@@ -1 +1,2 @@
1
1
  export declare function toArray<T>(candidate?: T | T[] | false): T[];
2
+ export declare function isSafeSetRefComponent(component: any): boolean;
@@ -1,4 +1,21 @@
1
+ import { isMemo, isFragment } from 'react-is';
1
2
  export function toArray(candidate) {
2
3
  if (candidate === undefined || candidate === false) return [];
3
4
  return Array.isArray(candidate) ? candidate : [candidate];
5
+ } // eslint-disable-next-line @typescript-eslint/ban-types
6
+
7
+ function shouldConstruct(Component) {
8
+ const prototype = Component.prototype;
9
+ return !!(prototype && prototype.isReactComponent);
10
+ } // https://github.com/facebook/react/blob/ce13860281f833de8a3296b7a3dad9caced102e9/packages/react-reconciler/src/ReactFiber.new.js#L225
11
+
12
+
13
+ function isSimpleFunctionComponent(type) {
14
+ return typeof type === 'function' && !shouldConstruct(type) && type.defaultProps === undefined;
15
+ }
16
+
17
+ export function isSafeSetRefComponent(component) {
18
+ if (isFragment(component)) return false;
19
+ if (isMemo(component)) return isSafeSetRefComponent(component.type);
20
+ return !isSimpleFunctionComponent(component.type);
4
21
  }
@@ -8,6 +8,7 @@ import { usePropsValue } from '../../utils/use-props-value';
8
8
  import { useIsomorphicLayoutEffect, useMemoizedFn, useUnmount } from 'ahooks';
9
9
  import Space from '../space';
10
10
  import { withNativeProps } from '../../utils/native-props';
11
+ import { useConfig } from '../config-provider';
11
12
  const classPrefix = `adm-image-uploader`;
12
13
  const defaultProps = {
13
14
  disableUpload: false,
@@ -22,6 +23,9 @@ const defaultProps = {
22
23
  imageFit: 'cover'
23
24
  };
24
25
  export const ImageUploader = p => {
26
+ const {
27
+ locale
28
+ } = useConfig();
25
29
  const props = mergeProps(defaultProps, p);
26
30
  const [value, setValue] = usePropsValue(props);
27
31
  const updateValue = useMemoizedFn(updater => {
@@ -61,6 +65,7 @@ export const ImageUploader = p => {
61
65
  } = e.target;
62
66
  if (!rawFiles) return;
63
67
  let files = [].slice.call(rawFiles);
68
+ e.target.value = ''; // HACK: fix the same file doesn't trigger onChange
64
69
 
65
70
  if (props.beforeUpload) {
66
71
  const postFiles = files.map(file => {
@@ -90,8 +95,6 @@ export const ImageUploader = p => {
90
95
  file
91
96
  }));
92
97
  setTasks(prev => [...prev, ...newTasks]);
93
- e.target.value = ''; // HACK: fix the same file doesn't trigger onChange
94
-
95
98
  yield Promise.all(newTasks.map(currentTask => __awaiter(this, void 0, void 0, function* () {
96
99
  try {
97
100
  const result = yield props.upload(currentTask.file);
@@ -194,7 +197,8 @@ export const ImageUploader = p => {
194
197
  className: `${classPrefix}-upload-button-wrap`
195
198
  }, props.children ? props.children : React.createElement("span", {
196
199
  className: `${classPrefix}-cell ${classPrefix}-upload-button`,
197
- role: 'button'
200
+ role: 'button',
201
+ "aria-label": locale.ImageUploader.upload
198
202
  }, React.createElement("span", {
199
203
  className: `${classPrefix}-upload-button-icon`
200
204
  }, React.createElement(AddOutline, null))), !props.disableUpload && React.createElement("input", {
@@ -203,6 +207,7 @@ export const ImageUploader = p => {
203
207
  multiple: props.multiple,
204
208
  type: 'file',
205
209
  className: `${classPrefix}-input`,
206
- onChange: onChange
210
+ onChange: onChange,
211
+ "aria-hidden": true
207
212
  })))));
208
213
  };
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { NativeProps } from '../../utils/native-props';
3
3
  declare type NativeInputProps = React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
4
- export declare type InputProps = Pick<NativeInputProps, 'maxLength' | 'minLength' | 'autoComplete' | 'autoFocus' | 'pattern' | 'inputMode' | 'type' | 'onFocus' | 'onBlur' | 'autoCapitalize' | 'autoCorrect' | 'onKeyDown' | 'onKeyUp' | 'onCompositionStart' | 'onCompositionEnd' | 'onClick'> & {
4
+ export declare type InputProps = Pick<NativeInputProps, 'maxLength' | 'minLength' | 'autoComplete' | 'autoFocus' | 'pattern' | 'inputMode' | 'type' | 'name' | 'onFocus' | 'onBlur' | 'autoCapitalize' | 'autoCorrect' | 'onKeyDown' | 'onKeyUp' | 'onCompositionStart' | 'onCompositionEnd' | 'onClick'> & {
5
5
  value?: string;
6
6
  defaultValue?: string;
7
7
  onChange?: (val: string) => void;
@@ -23,7 +23,7 @@ export declare type InputRef = {
23
23
  blur: () => void;
24
24
  nativeElement: HTMLInputElement | null;
25
25
  };
26
- export declare const Input: React.ForwardRefExoticComponent<Pick<NativeInputProps, "pattern" | "onClick" | "type" | "onCompositionEnd" | "onCompositionStart" | "onFocus" | "onBlur" | "onKeyDown" | "onKeyUp" | "autoCapitalize" | "autoCorrect" | "inputMode" | "autoComplete" | "autoFocus" | "maxLength" | "minLength"> & {
26
+ export declare const Input: React.ForwardRefExoticComponent<Pick<NativeInputProps, "pattern" | "onClick" | "name" | "type" | "onCompositionEnd" | "onCompositionStart" | "onFocus" | "onBlur" | "onKeyDown" | "onKeyUp" | "autoCapitalize" | "autoCorrect" | "inputMode" | "autoComplete" | "autoFocus" | "maxLength" | "minLength"> & {
27
27
  value?: string | undefined;
28
28
  defaultValue?: string | undefined;
29
29
  onChange?: ((val: string) => void) | undefined;
@@ -116,6 +116,7 @@ export const Input = forwardRef((p, ref) => {
116
116
  pattern: props.pattern,
117
117
  inputMode: props.inputMode,
118
118
  type: props.type,
119
+ name: props.name,
119
120
  autoCapitalize: props.autoCapitalize,
120
121
  autoCorrect: props.autoCorrect,
121
122
  onKeyDown: handleKeydown,
@@ -1,6 +1,7 @@
1
1
  .adm-jumbo-tabs {
2
2
  --gap: 16px;
3
3
  position: relative;
4
+ min-width: 0;
4
5
  }
5
6
 
6
7
  .adm-jumbo-tabs-header {
@@ -2,6 +2,7 @@ import React from 'react';
2
2
  import { withNativeProps } from '../../utils/native-props';
3
3
  import { RightOutline } from 'antd-mobile-icons';
4
4
  import classNames from 'classnames';
5
+ import { isNodeWithContent } from '../../utils/is-node-with-content';
5
6
  const classPrefix = `adm-list-item`;
6
7
  export const ListItem = props => {
7
8
  var _a;
@@ -10,17 +11,17 @@ export const ListItem = props => {
10
11
  const arrow = props.arrow === undefined ? clickable : props.arrow;
11
12
  const content = React.createElement("div", {
12
13
  className: `${classPrefix}-content`
13
- }, props.prefix && React.createElement("div", {
14
+ }, isNodeWithContent(props.prefix) && React.createElement("div", {
14
15
  className: `${classPrefix}-content-prefix`
15
16
  }, props.prefix), React.createElement("div", {
16
17
  className: `${classPrefix}-content-main`
17
- }, props.title && React.createElement("div", {
18
+ }, isNodeWithContent(props.title) && React.createElement("div", {
18
19
  className: `${classPrefix}-title`
19
- }, props.title), props.children, props.description && React.createElement("div", {
20
+ }, props.title), props.children, isNodeWithContent(props.description) && React.createElement("div", {
20
21
  className: `${classPrefix}-description`
21
- }, props.description)), props.extra && React.createElement("div", {
22
+ }, props.description)), isNodeWithContent(props.extra) && React.createElement("div", {
22
23
  className: `${classPrefix}-content-extra`
23
- }, props.extra), arrow && React.createElement("div", {
24
+ }, props.extra), isNodeWithContent(arrow) && React.createElement("div", {
24
25
  className: `${classPrefix}-content-arrow`
25
26
  }, arrow === true ? React.createElement(RightOutline, null) : arrow));
26
27
  return withNativeProps(props, React.createElement(clickable ? 'a' : 'div', {
@@ -50,6 +50,7 @@
50
50
  padding-left: var(--padding-left);
51
51
  position: relative;
52
52
  background-color: #ffffff;
53
+ line-height: 1.5;
53
54
  }
54
55
 
55
56
  .adm-list-item-title,
@@ -75,7 +75,7 @@ export const Mask = p => {
75
75
  background,
76
76
  opacity
77
77
  }, props.style), {
78
- display: active ? 'unset' : 'none'
78
+ display: active ? undefined : 'none'
79
79
  }),
80
80
  onClick: e => {
81
81
  var _a;
@@ -92,7 +92,7 @@ export const Modal = p => {
92
92
  const node = withStopPropagation(props.stopPropagation, withNativeProps(props, React.createElement("div", {
93
93
  className: cls(),
94
94
  style: {
95
- display: active ? 'unset' : 'none'
95
+ display: active ? undefined : 'none'
96
96
  }
97
97
  }, React.createElement(Mask, {
98
98
  visible: props.visible,
@@ -103,7 +103,7 @@ export const Modal = p => {
103
103
  }), React.createElement("div", {
104
104
  className: cls('wrap'),
105
105
  style: {
106
- pointerEvents: props.visible ? 'unset' : 'none'
106
+ pointerEvents: props.visible ? undefined : 'none'
107
107
  }
108
108
  }, React.createElement(animated.div, {
109
109
  style: style