antd-mobile 5.6.1 → 5.7.2

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 (139) hide show
  1. package/2x/cjs/components/calendar/calendar.d.ts +4 -3
  2. package/2x/cjs/components/calendar/calendar.js +67 -56
  3. package/2x/cjs/components/calendar/convert.d.ts +2 -0
  4. package/2x/cjs/components/calendar/convert.js +22 -0
  5. package/2x/cjs/components/collapse/collapse.js +7 -0
  6. package/2x/cjs/components/dialog/confirm.js +9 -1
  7. package/2x/cjs/components/form/form-item.js +6 -3
  8. package/2x/cjs/components/modal/confirm.js +9 -1
  9. package/2x/cjs/components/passcode-input/passcode-input.js +1 -1
  10. package/2x/cjs/components/picker/picker.js +6 -9
  11. package/2x/cjs/components/picker-view/columns-extend.d.ts +3 -0
  12. package/2x/cjs/components/picker-view/columns-extend.js +45 -0
  13. package/2x/cjs/components/picker-view/picker-view.d.ts +1 -0
  14. package/2x/cjs/components/picker-view/picker-view.js +14 -16
  15. package/2x/cjs/components/pull-to-refresh/pull-to-refresh.js +11 -1
  16. package/2x/cjs/components/result/result.d.ts +2 -2
  17. package/2x/cjs/components/virtual-input/virtual-input.js +25 -14
  18. package/2x/cjs/locales/base.d.ts +6 -0
  19. package/2x/cjs/locales/base.js +7 -1
  20. package/2x/cjs/locales/en-US.d.ts +6 -0
  21. package/2x/cjs/locales/fa-IR.d.ts +101 -0
  22. package/2x/cjs/locales/fa-IR.js +108 -0
  23. package/2x/cjs/locales/zh-CN.d.ts +6 -0
  24. package/2x/cjs/locales/zh-CN.js +7 -1
  25. package/2x/cjs/locales/zh-HK.d.ts +101 -0
  26. package/2x/cjs/locales/zh-HK.js +58 -0
  27. package/2x/cjs/locales/zh-TW.d.ts +101 -0
  28. package/2x/cjs/locales/zh-TW.js +58 -0
  29. package/2x/cjs/utils/with-cache.d.ts +1 -0
  30. package/2x/cjs/utils/with-cache.js +17 -0
  31. package/2x/es/components/calendar/calendar.d.ts +4 -3
  32. package/2x/es/components/calendar/calendar.js +67 -58
  33. package/2x/es/components/calendar/convert.d.ts +2 -0
  34. package/2x/es/components/calendar/convert.js +15 -0
  35. package/2x/es/components/collapse/collapse.js +7 -0
  36. package/2x/es/components/dialog/confirm.js +8 -1
  37. package/2x/es/components/form/form-item.js +6 -3
  38. package/2x/es/components/modal/confirm.js +8 -1
  39. package/2x/es/components/passcode-input/passcode-input.js +1 -1
  40. package/2x/es/components/picker/picker.js +6 -8
  41. package/2x/es/components/picker-view/columns-extend.d.ts +3 -0
  42. package/2x/es/components/picker-view/columns-extend.js +34 -0
  43. package/2x/es/components/picker-view/picker-view.d.ts +1 -0
  44. package/2x/es/components/picker-view/picker-view.js +14 -15
  45. package/2x/es/components/pull-to-refresh/pull-to-refresh.js +10 -1
  46. package/2x/es/components/result/result.d.ts +2 -2
  47. package/2x/es/components/virtual-input/virtual-input.js +23 -14
  48. package/2x/es/locales/base.d.ts +6 -0
  49. package/2x/es/locales/base.js +7 -1
  50. package/2x/es/locales/en-US.d.ts +6 -0
  51. package/2x/es/locales/fa-IR.d.ts +101 -0
  52. package/2x/es/locales/fa-IR.js +98 -0
  53. package/2x/es/locales/zh-CN.d.ts +6 -0
  54. package/2x/es/locales/zh-CN.js +7 -1
  55. package/2x/es/locales/zh-HK.d.ts +101 -0
  56. package/2x/es/locales/zh-HK.js +48 -0
  57. package/2x/es/locales/zh-TW.d.ts +101 -0
  58. package/2x/es/locales/zh-TW.js +48 -0
  59. package/2x/es/utils/with-cache.d.ts +1 -0
  60. package/2x/es/utils/with-cache.js +10 -0
  61. package/2x/package.json +1 -1
  62. package/cjs/components/calendar/calendar.d.ts +4 -3
  63. package/cjs/components/calendar/calendar.js +67 -56
  64. package/cjs/components/calendar/convert.d.ts +2 -0
  65. package/cjs/components/calendar/convert.js +22 -0
  66. package/cjs/components/collapse/collapse.js +7 -0
  67. package/cjs/components/dialog/confirm.js +9 -1
  68. package/cjs/components/form/form-item.js +6 -3
  69. package/cjs/components/modal/confirm.js +9 -1
  70. package/cjs/components/passcode-input/passcode-input.js +1 -1
  71. package/cjs/components/picker/picker.js +6 -9
  72. package/cjs/components/picker-view/columns-extend.d.ts +3 -0
  73. package/cjs/components/picker-view/columns-extend.js +45 -0
  74. package/cjs/components/picker-view/picker-view.d.ts +1 -0
  75. package/cjs/components/picker-view/picker-view.js +14 -16
  76. package/cjs/components/pull-to-refresh/pull-to-refresh.js +11 -1
  77. package/cjs/components/result/result.d.ts +2 -2
  78. package/cjs/components/virtual-input/virtual-input.js +25 -14
  79. package/cjs/locales/base.d.ts +6 -0
  80. package/cjs/locales/base.js +7 -1
  81. package/cjs/locales/en-US.d.ts +6 -0
  82. package/cjs/locales/fa-IR.d.ts +101 -0
  83. package/cjs/locales/fa-IR.js +108 -0
  84. package/cjs/locales/zh-CN.d.ts +6 -0
  85. package/cjs/locales/zh-CN.js +7 -1
  86. package/cjs/locales/zh-HK.d.ts +101 -0
  87. package/cjs/locales/zh-HK.js +58 -0
  88. package/cjs/locales/zh-TW.d.ts +101 -0
  89. package/cjs/locales/zh-TW.js +58 -0
  90. package/cjs/utils/with-cache.d.ts +1 -0
  91. package/cjs/utils/with-cache.js +17 -0
  92. package/es/components/calendar/calendar.d.ts +4 -3
  93. package/es/components/calendar/calendar.js +67 -58
  94. package/es/components/calendar/convert.d.ts +2 -0
  95. package/es/components/calendar/convert.js +15 -0
  96. package/es/components/collapse/collapse.js +7 -0
  97. package/es/components/dialog/confirm.js +8 -1
  98. package/es/components/form/form-item.js +6 -3
  99. package/es/components/modal/confirm.js +8 -1
  100. package/es/components/passcode-input/passcode-input.js +1 -1
  101. package/es/components/picker/picker.js +6 -8
  102. package/es/components/picker-view/columns-extend.d.ts +3 -0
  103. package/es/components/picker-view/columns-extend.js +34 -0
  104. package/es/components/picker-view/picker-view.d.ts +1 -0
  105. package/es/components/picker-view/picker-view.js +14 -15
  106. package/es/components/pull-to-refresh/pull-to-refresh.js +10 -1
  107. package/es/components/result/result.d.ts +2 -2
  108. package/es/components/virtual-input/virtual-input.js +23 -14
  109. package/es/locales/base.d.ts +6 -0
  110. package/es/locales/base.js +7 -1
  111. package/es/locales/en-US.d.ts +6 -0
  112. package/es/locales/fa-IR.d.ts +101 -0
  113. package/es/locales/fa-IR.js +98 -0
  114. package/es/locales/zh-CN.d.ts +6 -0
  115. package/es/locales/zh-CN.js +7 -1
  116. package/es/locales/zh-HK.d.ts +101 -0
  117. package/es/locales/zh-HK.js +48 -0
  118. package/es/locales/zh-TW.d.ts +101 -0
  119. package/es/locales/zh-TW.js +48 -0
  120. package/es/utils/with-cache.d.ts +1 -0
  121. package/es/utils/with-cache.js +10 -0
  122. package/package.json +1 -1
  123. package/umd/antd-mobile.js +1 -1
  124. package/2x/cjs/components/picker-view/use-columns.d.ts +0 -2
  125. package/2x/cjs/components/picker-view/use-columns.js +0 -18
  126. package/2x/cjs/components/picker-view/use-picker-value-extend.d.ts +0 -2
  127. package/2x/cjs/components/picker-view/use-picker-value-extend.js +0 -37
  128. package/2x/es/components/picker-view/use-columns.d.ts +0 -2
  129. package/2x/es/components/picker-view/use-columns.js +0 -10
  130. package/2x/es/components/picker-view/use-picker-value-extend.d.ts +0 -2
  131. package/2x/es/components/picker-view/use-picker-value-extend.js +0 -26
  132. package/cjs/components/picker-view/use-columns.d.ts +0 -2
  133. package/cjs/components/picker-view/use-columns.js +0 -18
  134. package/cjs/components/picker-view/use-picker-value-extend.d.ts +0 -2
  135. package/cjs/components/picker-view/use-picker-value-extend.js +0 -37
  136. package/es/components/picker-view/use-columns.d.ts +0 -2
  137. package/es/components/picker-view/use-columns.js +0 -10
  138. package/es/components/picker-view/use-picker-value-extend.d.ts +0 -2
  139. package/es/components/picker-view/use-picker-value-extend.js +0 -26
@@ -1,4 +1,4 @@
1
- import React, { forwardRef, useMemo, useState, useImperativeHandle } from 'react';
1
+ import React, { forwardRef, useState, useImperativeHandle } from 'react';
2
2
  import { withNativeProps } from '../../utils/native-props';
3
3
  import dayjs from 'dayjs';
4
4
  import classNames from 'classnames';
@@ -7,11 +7,15 @@ import { ArrowLeft } from './arrow-left';
7
7
  import { ArrowLeftDouble } from './arrow-left-double';
8
8
  import { useConfig } from '../config-provider';
9
9
  import isoWeek from 'dayjs/plugin/isoWeek';
10
- import { useIsomorphicLayoutEffect, useUpdateEffect } from 'ahooks';
10
+ import { useUpdateEffect } from 'ahooks';
11
+ import { usePropsValue } from '../../utils/use-props-value';
12
+ import { convertValueToRange } from './convert';
11
13
  dayjs.extend(isoWeek);
12
14
  const classPrefix = 'adm-calendar';
13
15
  const defaultProps = {
14
- weekStartsOn: 'Sunday'
16
+ weekStartsOn: 'Sunday',
17
+ defaultValue: null,
18
+ allowClear: true
15
19
  };
16
20
  export const Calendar = forwardRef((p, ref) => {
17
21
  const today = dayjs();
@@ -26,29 +30,21 @@ export const Calendar = forwardRef((p, ref) => {
26
30
  if (item) markItems.unshift(item);
27
31
  }
28
32
 
29
- const dateRange = useMemo(() => {
30
- var _a, _b, _c, _d;
33
+ const [dateRange, setDateRange] = usePropsValue({
34
+ value: props.value === undefined ? undefined : convertValueToRange(props.selectionMode, props.value),
35
+ defaultValue: convertValueToRange(props.selectionMode, props.defaultValue),
36
+ onChange: v => {
37
+ var _a, _b;
31
38
 
32
- if (props.selectionMode === 'single') {
33
- const value = (_b = (_a = props.value) !== null && _a !== void 0 ? _a : props.defaultValue) !== null && _b !== void 0 ? _b : null;
34
- return [value, value];
35
- } else if (props.selectionMode === 'range') {
36
- return (_d = (_c = props.value) !== null && _c !== void 0 ? _c : props.defaultValue) !== null && _d !== void 0 ? _d : [null, null];
37
- } else {
38
- return [null, null];
39
+ if (props.selectionMode === 'single') {
40
+ (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, v ? v[0] : null);
41
+ } else if (props.selectionMode === 'range') {
42
+ (_b = props.onChange) === null || _b === void 0 ? void 0 : _b.call(props, v);
43
+ }
39
44
  }
40
- }, [props.selectionMode, props.value, props.defaultValue]);
41
- const [begin, setBegin] = useState(null);
42
- const [end, setEnd] = useState(null);
43
- useIsomorphicLayoutEffect(() => {
44
- setBegin(dateRange[0] ? dayjs(dateRange[0]) : null);
45
- setEnd(dateRange[1] ? dayjs(dateRange[1]) : null);
46
- }, [dateRange[0], dateRange[1]]);
47
- const [current, setCurrent] = useState(() => {
48
- var _a;
49
-
50
- return dayjs((_a = dateRange[0]) !== null && _a !== void 0 ? _a : today).date(1);
51
45
  });
46
+ const [intermediate, setIntermediate] = useState(false);
47
+ const [current, setCurrent] = useState(() => dayjs(dateRange ? dateRange[0] : today).date(1));
52
48
  useUpdateEffect(() => {
53
49
  var _a;
54
50
 
@@ -111,14 +107,16 @@ export const Calendar = forwardRef((p, ref) => {
111
107
 
112
108
  while (cells.length < 6 * 7) {
113
109
  const d = iterator;
114
-
115
- const isSelect = (() => {
116
- if (!begin) return false;
117
- if (d.isSame(begin, 'day')) return true;
118
- if (!end) return false;
119
- if (d.isSame(end, 'day')) return true;
120
- return d.isAfter(begin, 'day') && d.isBefore(end, 'day');
121
- })();
110
+ let isSelect = false;
111
+ let isBegin = false;
112
+ let isEnd = false;
113
+
114
+ if (dateRange) {
115
+ const [begin, end] = dateRange;
116
+ isBegin = d.isSame(begin, 'day');
117
+ isEnd = d.isSame(end, 'day');
118
+ isSelect = isBegin || isEnd || d.isAfter(begin, 'day') && d.isBefore(end, 'day');
119
+ }
122
120
 
123
121
  const inThisMonth = d.month() === current.month();
124
122
  cells.push(React.createElement("div", {
@@ -126,41 +124,52 @@ export const Calendar = forwardRef((p, ref) => {
126
124
  className: classNames(`${classPrefix}-cell`, inThisMonth ? `${classPrefix}-cell-in` : `${classPrefix}-cell-out`, inThisMonth && {
127
125
  [`${classPrefix}-cell-today`]: d.isSame(today, 'day'),
128
126
  [`${classPrefix}-cell-selected`]: isSelect,
129
- [`${classPrefix}-cell-selected-begin`]: isSelect && d.isSame(begin, 'day'),
130
- [`${classPrefix}-cell-selected-end`]: isSelect && (!end || d.isSame(end, 'day'))
127
+ [`${classPrefix}-cell-selected-begin`]: isBegin,
128
+ [`${classPrefix}-cell-selected-end`]: isEnd
131
129
  }),
132
130
  onClick: () => {
133
- var _a, _b, _c;
134
-
135
131
  if (!props.selectionMode) return;
132
+ const date = d.toDate();
133
+
134
+ if (!inThisMonth) {
135
+ setCurrent(d.clone().date(1));
136
+ }
137
+
138
+ function shouldClear() {
139
+ if (!props.allowClear) return false;
140
+ if (!dateRange) return false;
141
+ const [begin, end] = dateRange;
142
+ return d.isSame(begin, 'date') && d.isSame(end, 'day');
143
+ }
136
144
 
137
145
  if (props.selectionMode === 'single') {
138
- setBegin(d);
139
- setEnd(d);
140
- (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, d.toDate());
146
+ if (props.allowClear && shouldClear()) {
147
+ setDateRange(null);
148
+ return;
149
+ }
150
+
151
+ setDateRange([date, date]);
141
152
  } else if (props.selectionMode === 'range') {
142
- if (begin !== null && end === null) {
143
- if (begin.isSame(d.toDate())) {
144
- setBegin(null);
145
- setEnd(null);
146
- } else {
147
- if (d.isBefore(begin)) {
148
- setEnd(begin);
149
- setBegin(d);
150
- (_b = props.onChange) === null || _b === void 0 ? void 0 : _b.call(props, [d.toDate(), begin.toDate()]);
151
- } else {
152
- setEnd(d);
153
- (_c = props.onChange) === null || _c === void 0 ? void 0 : _c.call(props, [begin.toDate(), d.toDate()]);
154
- }
155
- }
156
- } else {
157
- setBegin(d);
158
- setEnd(null);
153
+ if (!dateRange) {
154
+ setDateRange([date, date]);
155
+ setIntermediate(true);
156
+ return;
159
157
  }
160
- }
161
158
 
162
- if (!inThisMonth) {
163
- setCurrent(d.clone().date(1));
159
+ if (shouldClear()) {
160
+ setDateRange(null);
161
+ setIntermediate(false);
162
+ return;
163
+ }
164
+
165
+ if (intermediate) {
166
+ const another = dateRange[0];
167
+ setDateRange(another > date ? [date, another] : [another, date]);
168
+ setIntermediate(false);
169
+ } else {
170
+ setDateRange([date, date]);
171
+ setIntermediate(true);
172
+ }
164
173
  }
165
174
  }
166
175
  }, React.createElement("div", {
@@ -0,0 +1,2 @@
1
+ export declare type DateRange = [Date, Date] | null;
2
+ export declare function convertValueToRange(selectionMode: 'single' | 'range' | undefined, value: Date | [Date, Date] | null): DateRange;
@@ -0,0 +1,15 @@
1
+ export function convertValueToRange(selectionMode, value) {
2
+ if (selectionMode === undefined) {
3
+ return null;
4
+ }
5
+
6
+ if (value === null) {
7
+ return null;
8
+ }
9
+
10
+ if (Array.isArray(value)) {
11
+ return value;
12
+ }
13
+
14
+ return [value, value];
15
+ }
@@ -24,6 +24,13 @@ const CollapsePanelContent = props => {
24
24
  }, api] = useSpring(() => ({
25
25
  from: {
26
26
  height: 0
27
+ },
28
+ config: {
29
+ precision: 0.01,
30
+ mass: 1,
31
+ tension: 200,
32
+ friction: 25,
33
+ clamp: true
27
34
  }
28
35
  }));
29
36
  useMount(() => {
@@ -1,12 +1,19 @@
1
1
  import { __awaiter } from "tslib";
2
2
  import { show } from './show';
3
3
  import { mergeProps } from '../../utils/with-default-props';
4
+ import { getDefaultConfig } from '../config-provider';
4
5
  const defaultProps = {
5
6
  confirmText: '确认',
6
7
  cancelText: '取消'
7
8
  };
8
9
  export function confirm(p) {
9
- const props = mergeProps(defaultProps, p);
10
+ const {
11
+ locale
12
+ } = getDefaultConfig();
13
+ const props = mergeProps(defaultProps, {
14
+ confirmText: locale.common.confirm,
15
+ cancelText: locale.common.cancel
16
+ }, p);
10
17
  return new Promise(resolve => {
11
18
  show(Object.assign(Object.assign({}, props), {
12
19
  closeOnAction: true,
@@ -67,12 +67,15 @@ const FormItemLayout = props => {
67
67
  const labelElement = label ? React.createElement("label", {
68
68
  className: `${classPrefix}-label`,
69
69
  htmlFor: htmlFor
70
- }, label, requiredMark, help && React.createElement("span", {
71
- className: `${classPrefix}-label-help`
72
- }, React.createElement(Popover, {
70
+ }, label, requiredMark, help && React.createElement(Popover, {
73
71
  content: help,
74
72
  mode: 'dark',
75
73
  trigger: 'click'
74
+ }, React.createElement("span", {
75
+ className: `${classPrefix}-label-help`,
76
+ onClick: e => {
77
+ e.preventDefault();
78
+ }
76
79
  }, React.createElement(QuestionCircleOutline, null)))) : null;
77
80
  const description = React.createElement(React.Fragment, null, props.description, hasFeedback && React.createElement(React.Fragment, null, props.errors.map((error, index) => React.createElement("div", {
78
81
  key: `error-${index}`,
@@ -1,12 +1,19 @@
1
1
  import { __awaiter } from "tslib";
2
2
  import { show } from './show';
3
3
  import { mergeProps } from '../../utils/with-default-props';
4
+ import { getDefaultConfig } from '../config-provider';
4
5
  const defaultProps = {
5
6
  confirmText: '确认',
6
7
  cancelText: '取消'
7
8
  };
8
9
  export function confirm(p) {
9
- const props = mergeProps(defaultProps, p);
10
+ const {
11
+ locale
12
+ } = getDefaultConfig();
13
+ const props = mergeProps(defaultProps, {
14
+ confirmText: locale.common.confirm,
15
+ cancelText: locale.common.cancel
16
+ }, p);
10
17
  return new Promise(resolve => {
11
18
  show(Object.assign(Object.assign({}, props), {
12
19
  closeOnAction: true,
@@ -27,7 +27,7 @@ export const PasscodeInput = forwardRef((p, ref) => {
27
27
  if (value.length >= cellLength) {
28
28
  (_a = props.onFill) === null || _a === void 0 ? void 0 : _a.call(props, value);
29
29
  }
30
- }, [props.onFill, value, cellLength]);
30
+ }, [value, cellLength]);
31
31
 
32
32
  const onFocus = () => {
33
33
  var _a, _b;
@@ -4,9 +4,8 @@ import { mergeProps } from '../../utils/with-default-props';
4
4
  import { withNativeProps } from '../../utils/native-props';
5
5
  import { usePropsValue } from '../../utils/use-props-value';
6
6
  import PickerView from '../picker-view';
7
- import { useColumns } from '../picker-view/use-columns';
7
+ import { generateColumnsExtend, useColumnsExtend } from '../picker-view/columns-extend';
8
8
  import { useConfig } from '../config-provider';
9
- import { usePickerValueExtend } from '../picker-view/use-picker-value-extend';
10
9
  import { useMemoizedFn } from 'ahooks';
11
10
  import SafeArea from '../safe-area';
12
11
  const classPrefix = `adm-picker`;
@@ -28,12 +27,11 @@ export const Picker = memo(p => {
28
27
  onChange: val => {
29
28
  var _a;
30
29
 
31
- (_a = props.onConfirm) === null || _a === void 0 ? void 0 : _a.call(props, val, generateValueExtend(val));
30
+ const extend = generateColumnsExtend(props.columns, val);
31
+ (_a = props.onConfirm) === null || _a === void 0 ? void 0 : _a.call(props, val, extend);
32
32
  }
33
- })); // TODO: columns generated twice in Picker and PickerView, which can be improved
34
-
35
- const columns = useColumns(props.columns, value);
36
- const generateValueExtend = usePickerValueExtend(columns);
33
+ }));
34
+ const extend = useColumnsExtend(props.columns, value);
37
35
  const [innerValue, setInnerValue] = useState(value);
38
36
  useEffect(() => {
39
37
  if (innerValue !== value) {
@@ -104,6 +102,6 @@ export const Picker = memo(p => {
104
102
  }, pickerElement, React.createElement(SafeArea, {
105
103
  position: 'bottom'
106
104
  }));
107
- return React.createElement(React.Fragment, null, popupElement, (_a = props.children) === null || _a === void 0 ? void 0 : _a.call(props, generateValueExtend(value).items));
105
+ return React.createElement(React.Fragment, null, popupElement, (_a = props.children) === null || _a === void 0 ? void 0 : _a.call(props, extend.items));
108
106
  });
109
107
  Picker.displayName = 'Picker';
@@ -0,0 +1,3 @@
1
+ import type { PickerViewProps, PickerValue, PickerValueExtend } from './picker-view';
2
+ export declare function generateColumnsExtend(rawColumns: PickerViewProps['columns'], val: PickerValue[]): PickerValueExtend;
3
+ export declare function useColumnsExtend(rawColumns: PickerViewProps['columns'], value: PickerValue[]): PickerValueExtend;
@@ -0,0 +1,34 @@
1
+ import { useMemo } from 'react';
2
+ import { withCache } from '../../utils/with-cache';
3
+ export function generateColumnsExtend(rawColumns, val) {
4
+ const columns = withCache(() => {
5
+ const c = typeof rawColumns === 'function' ? rawColumns(val) : rawColumns;
6
+ return c.map(column => column.map(item => typeof item === 'string' ? {
7
+ label: item,
8
+ value: item
9
+ } : item));
10
+ });
11
+ const items = withCache(() => {
12
+ return val.map((v, index) => {
13
+ var _a;
14
+
15
+ const column = columns()[index];
16
+ if (!column) return null;
17
+ return (_a = column.find(item => item.value === v)) !== null && _a !== void 0 ? _a : null;
18
+ });
19
+ });
20
+ const extend = {
21
+ get columns() {
22
+ return columns();
23
+ },
24
+
25
+ get items() {
26
+ return items();
27
+ }
28
+
29
+ };
30
+ return extend;
31
+ }
32
+ export function useColumnsExtend(rawColumns, value) {
33
+ return useMemo(() => generateColumnsExtend(rawColumns, value), [rawColumns, value]);
34
+ }
@@ -2,6 +2,7 @@ import React, { ReactNode } from 'react';
2
2
  import { NativeProps } from '../../utils/native-props';
3
3
  export declare type PickerValue = string | null;
4
4
  export declare type PickerValueExtend = {
5
+ columns: PickerColumnItem[][];
5
6
  items: (PickerColumnItem | null)[];
6
7
  };
7
8
  export declare type PickerColumnItem = {
@@ -1,9 +1,8 @@
1
1
  import React, { memo, useCallback, useEffect, useState } from 'react';
2
2
  import { mergeProps } from '../../utils/with-default-props';
3
3
  import { Wheel } from './wheel';
4
- import { useColumns } from './use-columns';
4
+ import { useColumnsExtend } from './columns-extend';
5
5
  import { withNativeProps } from '../../utils/native-props';
6
- import { usePickerValueExtend } from './use-picker-value-extend';
7
6
  import { useDebounceEffect } from 'ahooks';
8
7
  const classPrefix = `adm-picker-view`;
9
8
  const defaultProps = {
@@ -11,17 +10,7 @@ const defaultProps = {
11
10
  };
12
11
  export const PickerView = memo(p => {
13
12
  const props = mergeProps(defaultProps, p);
14
- const [innerValue, setInnerValue] = useState(props.value === undefined ? props.defaultValue : props.value);
15
- useDebounceEffect(() => {
16
- var _a;
17
-
18
- if (props.value === innerValue) return;
19
- (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, innerValue, generateValueExtend(innerValue));
20
- }, [innerValue], {
21
- wait: 0,
22
- leading: false,
23
- trailing: true
24
- }); // Sync `value` to `innerValue`
13
+ const [innerValue, setInnerValue] = useState(props.value === undefined ? props.defaultValue : props.value); // Sync `value` to `innerValue`
25
14
 
26
15
  useEffect(() => {
27
16
  if (props.value === undefined) return; // Uncontrolled mode
@@ -40,8 +29,18 @@ export const PickerView = memo(p => {
40
29
  window.clearTimeout(timeout);
41
30
  };
42
31
  }, [props.value, innerValue]);
43
- const columns = useColumns(props.columns, innerValue);
44
- const generateValueExtend = usePickerValueExtend(columns);
32
+ const extend = useColumnsExtend(props.columns, innerValue);
33
+ const columns = extend.columns;
34
+ useDebounceEffect(() => {
35
+ var _a;
36
+
37
+ if (props.value === innerValue) return;
38
+ (_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, innerValue, extend);
39
+ }, [innerValue], {
40
+ wait: 0,
41
+ leading: false,
42
+ trailing: true
43
+ });
45
44
  const handleSelect = useCallback((val, index) => {
46
45
  setInnerValue(prev => {
47
46
  const next = [...prev];
@@ -7,6 +7,7 @@ import React, { useEffect, useRef, useState } from 'react';
7
7
  import { supportsPassive } from '../../utils/supports-passive';
8
8
  import { convertPx } from '../../utils/convert-px';
9
9
  import { rubberbandIfOutOfBounds } from '../../utils/rubberband';
10
+ import { useConfig } from '../config-provider';
10
11
  import { sleep } from '../../utils/sleep';
11
12
  const classPrefix = `adm-pull-to-refresh`;
12
13
  export const defaultProps = {
@@ -21,7 +22,15 @@ export const defaultProps = {
21
22
  export const PullToRefresh = p => {
22
23
  var _a, _b;
23
24
 
24
- const props = mergeProps(defaultProps, p);
25
+ const {
26
+ locale
27
+ } = useConfig();
28
+ const props = mergeProps(defaultProps, {
29
+ refreshingText: locale.common.loading,
30
+ pullingText: locale.PullToRefresh.pulling,
31
+ canReleaseText: locale.PullToRefresh.canRelease,
32
+ completeText: locale.PullToRefresh.complete
33
+ }, p);
25
34
  const headHeight = (_a = props.headHeight) !== null && _a !== void 0 ? _a : convertPx(40);
26
35
  const threshold = (_b = props.threshold) !== null && _b !== void 0 ? _b : convertPx(60);
27
36
  const [status, setStatus] = useState('pulling');
@@ -2,8 +2,8 @@ import { FC, ReactNode } from 'react';
2
2
  import { NativeProps } from '../../utils/native-props';
3
3
  export declare type ResultProps = {
4
4
  status: 'success' | 'error' | 'info' | 'waiting' | 'warning';
5
- title: string;
6
- description?: string;
5
+ title: ReactNode;
6
+ description?: ReactNode;
7
7
  icon?: ReactNode;
8
8
  } & NativeProps;
9
9
  export declare const Result: FC<ResultProps>;
@@ -64,6 +64,28 @@ export const VirtualInput = forwardRef((p, ref) => {
64
64
  (_a = props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props);
65
65
  }
66
66
 
67
+ const keyboard = props.keyboard;
68
+ const keyboardElement = keyboard && React.cloneElement(keyboard, {
69
+ onInput: v => {
70
+ var _a, _b;
71
+
72
+ setValue(value + v);
73
+ (_b = (_a = keyboard.props).onInput) === null || _b === void 0 ? void 0 : _b.call(_a, v);
74
+ },
75
+ onDelete: () => {
76
+ var _a, _b;
77
+
78
+ setValue(value.slice(0, -1));
79
+ (_b = (_a = keyboard.props).onDelete) === null || _b === void 0 ? void 0 : _b.call(_a);
80
+ },
81
+ visible: hasFocus,
82
+ onClose: () => {
83
+ var _a, _b, _c;
84
+
85
+ (_a = rootRef.current) === null || _a === void 0 ? void 0 : _a.blur();
86
+ (_c = (_b = keyboard.props).onClose) === null || _c === void 0 ? void 0 : _c.call(_b);
87
+ }
88
+ });
67
89
  return withNativeProps(props, React.createElement("div", {
68
90
  ref: rootRef,
69
91
  className: classNames(classPrefix, {
@@ -91,18 +113,5 @@ export const VirtualInput = forwardRef((p, ref) => {
91
113
  }
92
114
  }, React.createElement(CloseCircleFill, null)), !value && React.createElement("div", {
93
115
  className: `${classPrefix}-placeholder`
94
- }, props.placeholder), props.keyboard && React.cloneElement(props.keyboard, {
95
- onInput: v => {
96
- setValue(value + v);
97
- },
98
- onDelete: () => {
99
- setValue(value.slice(0, -1));
100
- },
101
- visible: hasFocus,
102
- onClose: () => {
103
- var _a;
104
-
105
- (_a = rootRef.current) === null || _a === void 0 ? void 0 : _a.blur();
106
- }
107
- })));
116
+ }, props.placeholder), keyboardElement));
108
117
  });
@@ -2,6 +2,7 @@ export declare const base: {
2
2
  common: {
3
3
  confirm: string;
4
4
  cancel: string;
5
+ loading: string;
5
6
  };
6
7
  Calendar: {
7
8
  markItems: string[];
@@ -91,5 +92,10 @@ export declare const base: {
91
92
  Modal: {
92
93
  ok: string;
93
94
  };
95
+ PullToRefresh: {
96
+ pulling: string;
97
+ canRelease: string;
98
+ complete: string;
99
+ };
94
100
  };
95
101
  export declare type Locale = typeof base;
@@ -2,7 +2,8 @@ const typeTemplate = '${label} is not a valid ${type}';
2
2
  export const base = {
3
3
  common: {
4
4
  confirm: 'Confirm',
5
- cancel: 'Cancel'
5
+ cancel: 'Cancel',
6
+ loading: 'Loading...'
6
7
  },
7
8
  Calendar: {
8
9
  markItems: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
@@ -91,5 +92,10 @@ export const base = {
91
92
  },
92
93
  Modal: {
93
94
  ok: 'OK'
95
+ },
96
+ PullToRefresh: {
97
+ pulling: 'Scroll down to refresh',
98
+ canRelease: 'Release to refresh immediately',
99
+ complete: 'Refresh successful'
94
100
  }
95
101
  };
@@ -2,6 +2,7 @@ declare const enUS: {
2
2
  common: {
3
3
  confirm: string;
4
4
  cancel: string;
5
+ loading: string;
5
6
  };
6
7
  Calendar: {
7
8
  markItems: string[];
@@ -91,5 +92,10 @@ declare const enUS: {
91
92
  Modal: {
92
93
  ok: string;
93
94
  };
95
+ PullToRefresh: {
96
+ pulling: string;
97
+ canRelease: string;
98
+ complete: string;
99
+ };
94
100
  };
95
101
  export default enUS;
@@ -0,0 +1,101 @@
1
+ declare const faIR: {
2
+ common: {
3
+ confirm: string;
4
+ cancel: string;
5
+ loading: string;
6
+ };
7
+ Calendar: {
8
+ markItems: string[];
9
+ renderYearAndMonth: (year: number, month: number) => string;
10
+ };
11
+ Cascader: {
12
+ placeholder: string;
13
+ };
14
+ Dialog: {
15
+ ok: string;
16
+ };
17
+ ErrorBlock: {
18
+ default: {
19
+ title: string;
20
+ description: string;
21
+ };
22
+ busy: {
23
+ title: string;
24
+ description: string;
25
+ };
26
+ disconnected: {
27
+ title: string;
28
+ description: string;
29
+ };
30
+ empty: {
31
+ title: string;
32
+ description: string;
33
+ };
34
+ };
35
+ Form: {
36
+ required: string;
37
+ optional: string;
38
+ defaultValidateMessages: {
39
+ default: string;
40
+ required: string;
41
+ enum: string;
42
+ whitespace: string;
43
+ date: {
44
+ format: string;
45
+ parse: string;
46
+ invalid: string;
47
+ };
48
+ types: {
49
+ string: string;
50
+ method: string;
51
+ array: string;
52
+ object: string;
53
+ number: string;
54
+ date: string;
55
+ boolean: string;
56
+ integer: string;
57
+ float: string;
58
+ regexp: string;
59
+ email: string;
60
+ url: string;
61
+ hex: string;
62
+ };
63
+ string: {
64
+ len: string;
65
+ min: string;
66
+ max: string;
67
+ range: string;
68
+ };
69
+ number: {
70
+ len: string;
71
+ min: string;
72
+ max: string;
73
+ range: string;
74
+ };
75
+ array: {
76
+ len: string;
77
+ min: string;
78
+ max: string;
79
+ range: string;
80
+ };
81
+ pattern: {
82
+ mismatch: string;
83
+ };
84
+ };
85
+ };
86
+ ImageUploader: {
87
+ uploading: string;
88
+ };
89
+ Mask: {
90
+ name: string;
91
+ };
92
+ Modal: {
93
+ ok: string;
94
+ };
95
+ PullToRefresh: {
96
+ pulling: string;
97
+ canRelease: string;
98
+ complete: string;
99
+ };
100
+ };
101
+ export default faIR;