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
@@ -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;
@@ -41,7 +41,11 @@ const classPrefix = 'adm-calendar';
41
41
  const defaultProps = {
42
42
  weekStartsOn: 'Sunday',
43
43
  defaultValue: null,
44
- allowClear: true
44
+ allowClear: true,
45
+ prevMonthButton: _react.default.createElement(_arrowLeft.ArrowLeft, null),
46
+ prevYearButton: _react.default.createElement(_arrowLeftDouble.ArrowLeftDouble, null),
47
+ nextMonthButton: _react.default.createElement(_arrowLeft.ArrowLeft, null),
48
+ nextYearButton: _react.default.createElement(_arrowLeftDouble.ArrowLeftDouble, null)
45
49
  };
46
50
  const Calendar = (0, _react.forwardRef)((p, ref) => {
47
51
  const today = (0, _dayjs.default)();
@@ -99,28 +103,28 @@ const Calendar = (0, _react.forwardRef)((p, ref) => {
99
103
  const header = _react.default.createElement("div", {
100
104
  className: `${classPrefix}-header`
101
105
  }, _react.default.createElement("a", {
102
- className: `${classPrefix}-arrow-button`,
106
+ className: `${classPrefix}-arrow-button ${classPrefix}-arrow-button-year`,
103
107
  onClick: () => {
104
108
  setCurrent(current.subtract(1, 'year'));
105
109
  }
106
- }, _react.default.createElement(_arrowLeftDouble.ArrowLeftDouble, null)), _react.default.createElement("a", {
107
- className: `${classPrefix}-arrow-button`,
110
+ }, props.prevYearButton), _react.default.createElement("a", {
111
+ className: `${classPrefix}-arrow-button ${classPrefix}-arrow-button-month`,
108
112
  onClick: () => {
109
113
  setCurrent(current.subtract(1, 'month'));
110
114
  }
111
- }, _react.default.createElement(_arrowLeft.ArrowLeft, null)), _react.default.createElement("div", {
115
+ }, props.prevMonthButton), _react.default.createElement("div", {
112
116
  className: `${classPrefix}-title`
113
117
  }, locale.Calendar.renderYearAndMonth(current.year(), current.month() + 1)), _react.default.createElement("a", {
114
- className: `${classPrefix}-arrow-button ${classPrefix}-arrow-button-right`,
118
+ className: (0, _classnames.default)(`${classPrefix}-arrow-button`, `${classPrefix}-arrow-button-right`, `${classPrefix}-arrow-button-right-month`),
115
119
  onClick: () => {
116
120
  setCurrent(current.add(1, 'month'));
117
121
  }
118
- }, _react.default.createElement(_arrowLeft.ArrowLeft, null)), _react.default.createElement("a", {
119
- className: `${classPrefix}-arrow-button ${classPrefix}-arrow-button-right`,
122
+ }, props.nextMonthButton), _react.default.createElement("a", {
123
+ className: (0, _classnames.default)(`${classPrefix}-arrow-button`, `${classPrefix}-arrow-button-right`, `${classPrefix}-arrow-button-right-year`),
120
124
  onClick: () => {
121
125
  setCurrent(current.add(1, 'year'));
122
126
  }
123
- }, _react.default.createElement(_arrowLeftDouble.ArrowLeftDouble, null)));
127
+ }, props.nextYearButton));
124
128
 
125
129
  const maxDay = (0, _react.useMemo)(() => props.max && (0, _dayjs.default)(props.max), [props.max]);
126
130
  const minDay = (0, _react.useMemo)(() => props.min && (0, _dayjs.default)(props.min), [props.min]);
@@ -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>>;
@@ -7,7 +7,7 @@ exports.CascadePicker = void 0;
7
7
 
8
8
  var _tslib = require("tslib");
9
9
 
10
- var _react = _interopRequireDefault(require("react"));
10
+ var _react = _interopRequireWildcard(require("react"));
11
11
 
12
12
  var _picker = _interopRequireDefault(require("../picker"));
13
13
 
@@ -15,15 +15,19 @@ var _cascadePickerUtils = require("./cascade-picker-utils");
15
15
 
16
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
17
 
18
- const CascadePicker = props => {
18
+ 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); }
19
+
20
+ 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; }
21
+
22
+ const CascadePicker = (0, _react.forwardRef)((props, ref) => {
19
23
  const {
20
24
  options
21
25
  } = props,
22
26
  pickerProps = (0, _tslib.__rest)(props, ["options"]);
23
27
  const columnsFn = (0, _cascadePickerUtils.useColumnsFn)(options);
24
28
  return _react.default.createElement(_picker.default, Object.assign({}, pickerProps, {
29
+ ref: ref,
25
30
  columns: columnsFn
26
31
  }));
27
- };
28
-
32
+ });
29
33
  exports.CascadePicker = CascadePicker;
@@ -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>>;
@@ -35,8 +35,7 @@ const defaultProps = {
35
35
  renderLabel: _datePickerUtils.defaultRenderLabel,
36
36
  defaultValue: null
37
37
  };
38
-
39
- const DatePicker = p => {
38
+ const DatePicker = (0, _react.forwardRef)((p, ref) => {
40
39
  const props = (0, _withDefaultProps.mergeProps)(defaultProps, p);
41
40
  const [value, setValue] = (0, _usePropsValue.usePropsValue)({
42
41
  value: props.value,
@@ -65,6 +64,7 @@ const DatePicker = p => {
65
64
  });
66
65
  const columns = (0, _react.useCallback)(selected => (0, _datePickerUtils.generateDatePickerColumns)(selected, props.min, props.max, props.precision, props.renderLabel, props.filter), [props.min, props.max, props.precision, props.renderLabel]);
67
66
  return (0, _nativeProps.withNativeProps)(props, _react.default.createElement(_picker.default, {
67
+ ref: ref,
68
68
  columns: columns,
69
69
  value: pickerValue,
70
70
  onCancel: props.onCancel,
@@ -82,11 +82,10 @@ const DatePicker = p => {
82
82
  title: props.title,
83
83
  stopPropagation: props.stopPropagation,
84
84
  mouseWheel: props.mouseWheel
85
- }, () => {
85
+ }, (_, actions) => {
86
86
  var _a;
87
87
 
88
- return (_a = props.children) === null || _a === void 0 ? void 0 : _a.call(props, value);
88
+ return (_a = props.children) === null || _a === void 0 ? void 0 : _a.call(props, value, actions);
89
89
  }));
90
- };
91
-
90
+ });
92
91
  exports.DatePicker = DatePicker;
@@ -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;
@@ -117,7 +117,7 @@ const Dialog = p => {
117
117
  const node = (0, _nativeProps.withNativeProps)(props, _react.default.createElement("div", {
118
118
  className: cls(),
119
119
  style: {
120
- display: active ? 'unset' : 'none'
120
+ display: active ? undefined : 'none'
121
121
  }
122
122
  }, _react.default.createElement(_mask.default, {
123
123
  visible: props.visible,
@@ -128,7 +128,7 @@ const Dialog = p => {
128
128
  }), _react.default.createElement("div", {
129
129
  className: cls('wrap'),
130
130
  style: {
131
- pointerEvents: props.visible ? 'unset' : 'none'
131
+ pointerEvents: props.visible ? undefined : 'none'
132
132
  }
133
133
  }, _react.default.createElement(_web.animated.div, {
134
134
  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 {};
@@ -175,9 +175,8 @@ const FormItem = props => {
175
175
  validateTrigger: contextValidateTrigger
176
176
  } = (0, _react.useContext)(_FieldContext.default);
177
177
  const mergedValidateTrigger = (0, _undefinedFallback.undefinedFallback)(validateTrigger, contextValidateTrigger, trigger);
178
-
179
- const updateRef = _react.default.useRef(0);
180
-
178
+ const widgetRef = (0, _react.useRef)(null);
179
+ const updateRef = (0, _react.useRef)(0);
181
180
  updateRef.current += 1;
182
181
  const [subMetas, setSubMetas] = (0, _react.useState)({});
183
182
  const onSubMetaChange = (0, _react.useCallback)((subMeta, namePath) => {
@@ -239,7 +238,7 @@ const FormItem = props => {
239
238
  htmlFor: fieldId,
240
239
  errors: errors,
241
240
  warnings: warnings,
242
- onClick: onClick,
241
+ onClick: onClick && (e => onClick(e, widgetRef)),
243
242
  hidden: hidden,
244
243
  layout: layout,
245
244
  childElementPosition: childElementPosition,
@@ -316,6 +315,24 @@ const FormItem = props => {
316
315
 
317
316
  const childProps = Object.assign(Object.assign({}, children.props), control);
318
317
 
318
+ if ((0, _utils.isSafeSetRefComponent)(children)) {
319
+ childProps.ref = instance => {
320
+ const originRef = children.ref;
321
+
322
+ if (originRef) {
323
+ if (typeof originRef === 'function') {
324
+ originRef(instance);
325
+ }
326
+
327
+ if ('current' in originRef) {
328
+ originRef.current = instance;
329
+ }
330
+ }
331
+
332
+ widgetRef.current = instance;
333
+ };
334
+ }
335
+
319
336
  if (!childProps.id) {
320
337
  childProps.id = fieldId;
321
338
  } // 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;
@@ -3,9 +3,29 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.isSafeSetRefComponent = isSafeSetRefComponent;
6
7
  exports.toArray = toArray;
7
8
 
9
+ var _reactIs = require("react-is");
10
+
8
11
  function toArray(candidate) {
9
12
  if (candidate === undefined || candidate === false) return [];
10
13
  return Array.isArray(candidate) ? candidate : [candidate];
14
+ } // eslint-disable-next-line @typescript-eslint/ban-types
15
+
16
+
17
+ function shouldConstruct(Component) {
18
+ const prototype = Component.prototype;
19
+ return !!(prototype && prototype.isReactComponent);
20
+ } // https://github.com/facebook/react/blob/ce13860281f833de8a3296b7a3dad9caced102e9/packages/react-reconciler/src/ReactFiber.new.js#L225
21
+
22
+
23
+ function isSimpleFunctionComponent(type) {
24
+ return typeof type === 'function' && !shouldConstruct(type) && type.defaultProps === undefined;
25
+ }
26
+
27
+ function isSafeSetRefComponent(component) {
28
+ if ((0, _reactIs.isFragment)(component)) return false;
29
+ if ((0, _reactIs.isMemo)(component)) return isSafeSetRefComponent(component.type);
30
+ return !isSimpleFunctionComponent(component.type);
11
31
  }
@@ -90,6 +90,7 @@ const ImageUploader = p => {
90
90
  } = e.target;
91
91
  if (!rawFiles) return;
92
92
  let files = [].slice.call(rawFiles);
93
+ e.target.value = ''; // HACK: fix the same file doesn't trigger onChange
93
94
 
94
95
  if (props.beforeUpload) {
95
96
  const postFiles = files.map(file => {
@@ -119,8 +120,6 @@ const ImageUploader = p => {
119
120
  file
120
121
  }));
121
122
  setTasks(prev => [...prev, ...newTasks]);
122
- e.target.value = ''; // HACK: fix the same file doesn't trigger onChange
123
-
124
123
  yield Promise.all(newTasks.map(currentTask => (0, _tslib.__awaiter)(this, void 0, void 0, function* () {
125
124
  try {
126
125
  const result = yield props.upload(currentTask.file);
@@ -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;
@@ -137,6 +137,7 @@ const Input = (0, _react.forwardRef)((p, ref) => {
137
137
  pattern: props.pattern,
138
138
  inputMode: props.inputMode,
139
139
  type: props.type,
140
+ name: props.name,
140
141
  autoCapitalize: props.autoCapitalize,
141
142
  autoCorrect: props.autoCorrect,
142
143
  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 {
@@ -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,
@@ -97,7 +97,7 @@ const Mask = p => {
97
97
  background,
98
98
  opacity
99
99
  }, props.style), {
100
- display: active ? 'unset' : 'none'
100
+ display: active ? undefined : 'none'
101
101
  }),
102
102
  onClick: e => {
103
103
  var _a;
@@ -123,7 +123,7 @@ const Modal = p => {
123
123
  const node = (0, _withStopPropagation.withStopPropagation)(props.stopPropagation, (0, _nativeProps.withNativeProps)(props, _react.default.createElement("div", {
124
124
  className: cls(),
125
125
  style: {
126
- display: active ? 'unset' : 'none'
126
+ display: active ? undefined : 'none'
127
127
  }
128
128
  }, _react.default.createElement(_mask.default, {
129
129
  visible: props.visible,
@@ -134,7 +134,7 @@ const Modal = p => {
134
134
  }), _react.default.createElement("div", {
135
135
  className: cls('wrap'),
136
136
  style: {
137
- pointerEvents: props.visible ? 'unset' : 'none'
137
+ pointerEvents: props.visible ? undefined : 'none'
138
138
  }
139
139
  }, _react.default.createElement(_web.animated.div, {
140
140
  style: style
@@ -1,9 +1,50 @@
1
- /// <reference types="react" />
2
1
  import './picker.less';
3
2
  import { prompt } from './prompt';
4
- export type { PickerProps } from './picker';
3
+ export type { PickerProps, PickerRef, PickerActions } from './picker';
5
4
  export type { PickerValue, PickerColumnItem, PickerColumn, PickerValueExtend, } from '../picker-view';
6
- declare const _default: import("react").NamedExoticComponent<import("./picker").PickerProps> & {
5
+ declare const _default: import("react").NamedExoticComponent<{
6
+ columns: import("../picker-view").PickerColumn[] | ((value: import("../picker-view").PickerValue[]) => import("../picker-view").PickerColumn[]);
7
+ value?: import("../picker-view").PickerValue[] | undefined;
8
+ defaultValue?: import("../picker-view").PickerValue[] | undefined;
9
+ onSelect?: ((value: import("../picker-view").PickerValue[], extend: import("../picker-view").PickerValueExtend) => void) | undefined;
10
+ onConfirm?: ((value: import("../picker-view").PickerValue[], extend: import("../picker-view").PickerValueExtend) => void) | undefined;
11
+ onCancel?: (() => void) | undefined;
12
+ onClose?: (() => void) | undefined;
13
+ closeOnMaskClick?: boolean | undefined;
14
+ visible?: boolean | undefined;
15
+ title?: import("react").ReactNode;
16
+ confirmText?: import("react").ReactNode;
17
+ cancelText?: import("react").ReactNode;
18
+ children?: ((items: (import("../picker-view").PickerColumnItem | null)[], actions: import("./picker").PickerActions) => import("react").ReactNode) | undefined;
19
+ renderLabel?: ((item: import("../picker-view").PickerColumnItem) => import("react").ReactNode) | undefined;
20
+ mouseWheel?: boolean | undefined;
21
+ popupClassName?: string | undefined;
22
+ popupStyle?: import("react").CSSProperties | undefined;
23
+ forceRender?: boolean | undefined;
24
+ destroyOnClose?: boolean | undefined;
25
+ } & Pick<import("../popup").PopupProps, "onClick" | "getContainer" | "afterShow" | "afterClose" | "stopPropagation"> & import("../../utils/native-props").NativeProps<"--item-height" | "--header-button-font-size" | "--title-font-size" | "--item-font-size"> & import("react").RefAttributes<import("./picker").PickerActions>> & {
26
+ readonly type: import("react").ForwardRefExoticComponent<{
27
+ columns: import("../picker-view").PickerColumn[] | ((value: import("../picker-view").PickerValue[]) => import("../picker-view").PickerColumn[]);
28
+ value?: import("../picker-view").PickerValue[] | undefined;
29
+ defaultValue?: import("../picker-view").PickerValue[] | undefined;
30
+ onSelect?: ((value: import("../picker-view").PickerValue[], extend: import("../picker-view").PickerValueExtend) => void) | undefined;
31
+ onConfirm?: ((value: import("../picker-view").PickerValue[], extend: import("../picker-view").PickerValueExtend) => void) | undefined;
32
+ onCancel?: (() => void) | undefined;
33
+ onClose?: (() => void) | undefined;
34
+ closeOnMaskClick?: boolean | undefined;
35
+ visible?: boolean | undefined;
36
+ title?: import("react").ReactNode;
37
+ confirmText?: import("react").ReactNode;
38
+ cancelText?: import("react").ReactNode;
39
+ children?: ((items: (import("../picker-view").PickerColumnItem | null)[], actions: import("./picker").PickerActions) => import("react").ReactNode) | undefined;
40
+ renderLabel?: ((item: import("../picker-view").PickerColumnItem) => import("react").ReactNode) | undefined;
41
+ mouseWheel?: boolean | undefined;
42
+ popupClassName?: string | undefined;
43
+ popupStyle?: import("react").CSSProperties | undefined;
44
+ forceRender?: boolean | undefined;
45
+ destroyOnClose?: boolean | undefined;
46
+ } & Pick<import("../popup").PopupProps, "onClick" | "getContainer" | "afterShow" | "afterClose" | "stopPropagation"> & import("../../utils/native-props").NativeProps<"--item-height" | "--header-button-font-size" | "--title-font-size" | "--item-font-size"> & import("react").RefAttributes<import("./picker").PickerActions>>;
47
+ } & {
7
48
  prompt: typeof prompt;
8
49
  };
9
50
  export default _default;
@@ -2,6 +2,12 @@ import React, { ReactNode } from 'react';
2
2
  import { PopupProps } from '../popup';
3
3
  import { NativeProps } from '../../utils/native-props';
4
4
  import { PickerColumn, PickerColumnItem, PickerValue, PickerValueExtend } from './index';
5
+ export declare type PickerActions = {
6
+ open: () => void;
7
+ close: () => void;
8
+ toggle: () => void;
9
+ };
10
+ export declare type PickerRef = PickerActions;
5
11
  export declare type PickerProps = {
6
12
  columns: PickerColumn[] | ((value: PickerValue[]) => PickerColumn[]);
7
13
  value?: PickerValue[];
@@ -15,8 +21,32 @@ export declare type PickerProps = {
15
21
  title?: ReactNode;
16
22
  confirmText?: ReactNode;
17
23
  cancelText?: ReactNode;
18
- children?: (items: (PickerColumnItem | null)[]) => ReactNode;
24
+ children?: (items: (PickerColumnItem | null)[], actions: PickerActions) => ReactNode;
19
25
  renderLabel?: (item: PickerColumnItem) => ReactNode;
20
26
  mouseWheel?: boolean;
27
+ popupClassName?: string;
28
+ popupStyle?: React.CSSProperties;
29
+ forceRender?: boolean;
30
+ destroyOnClose?: boolean;
21
31
  } & Pick<PopupProps, 'getContainer' | 'afterShow' | 'afterClose' | 'onClick' | 'stopPropagation'> & NativeProps<'--header-button-font-size' | '--title-font-size' | '--item-font-size' | '--item-height'>;
22
- export declare const Picker: React.NamedExoticComponent<PickerProps>;
32
+ export declare const Picker: React.MemoExoticComponent<React.ForwardRefExoticComponent<{
33
+ columns: PickerColumn[] | ((value: PickerValue[]) => PickerColumn[]);
34
+ value?: PickerValue[] | undefined;
35
+ defaultValue?: PickerValue[] | undefined;
36
+ onSelect?: ((value: PickerValue[], extend: PickerValueExtend) => void) | undefined;
37
+ onConfirm?: ((value: PickerValue[], extend: PickerValueExtend) => void) | undefined;
38
+ onCancel?: (() => void) | undefined;
39
+ onClose?: (() => void) | undefined;
40
+ closeOnMaskClick?: boolean | undefined;
41
+ visible?: boolean | undefined;
42
+ title?: ReactNode;
43
+ confirmText?: ReactNode;
44
+ cancelText?: ReactNode;
45
+ children?: ((items: (PickerColumnItem | null)[], actions: PickerActions) => ReactNode) | undefined;
46
+ renderLabel?: ((item: PickerColumnItem) => ReactNode) | undefined;
47
+ mouseWheel?: boolean | undefined;
48
+ popupClassName?: string | undefined;
49
+ popupStyle?: React.CSSProperties | undefined;
50
+ forceRender?: boolean | undefined;
51
+ destroyOnClose?: boolean | undefined;
52
+ } & Pick<PopupProps, "onClick" | "getContainer" | "afterShow" | "afterClose" | "stopPropagation"> & NativeProps<"--item-height" | "--header-button-font-size" | "--title-font-size" | "--item-font-size"> & React.RefAttributes<PickerActions>>>;