@arco-design/mobile-react 2.35.1 → 2.36.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 (81) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/README.en-US.md +2 -2
  3. package/README.md +2 -2
  4. package/cjs/_helpers/hooks.d.ts +10 -2
  5. package/cjs/_helpers/hooks.js +12 -5
  6. package/cjs/date-picker/index.js +218 -18
  7. package/cjs/date-picker/style/css/index.css +42 -0
  8. package/cjs/date-picker/style/index.less +38 -1
  9. package/cjs/date-picker/type.d.ts +22 -6
  10. package/cjs/form/linked-container.d.ts +2 -2
  11. package/cjs/form/linked-container.js +5 -1
  12. package/cjs/picker/index.js +3 -2
  13. package/cjs/picker/type.d.ts +5 -0
  14. package/cjs/pull-refresh/android-pull-refresh.js +5 -8
  15. package/cjs/pull-refresh/model.d.ts +1 -0
  16. package/cjs/search-bar/association.js +2 -2
  17. package/cjs/search-bar/type.d.ts +1 -1
  18. package/cjs/stepper/hooks/useValue.js +3 -1
  19. package/cjs/tabs/index.js +1 -1
  20. package/cjs/tabs/type.d.ts +2 -2
  21. package/dist/index.js +275 -46
  22. package/dist/index.min.js +4 -4
  23. package/dist/style.css +23 -0
  24. package/dist/style.min.css +1 -1
  25. package/esm/_helpers/hooks.d.ts +10 -2
  26. package/esm/_helpers/hooks.js +12 -5
  27. package/esm/date-picker/index.js +218 -18
  28. package/esm/date-picker/style/css/index.css +42 -0
  29. package/esm/date-picker/style/index.less +38 -1
  30. package/esm/date-picker/type.d.ts +22 -6
  31. package/esm/form/linked-container.d.ts +2 -2
  32. package/esm/form/linked-container.js +5 -1
  33. package/esm/picker/index.js +3 -2
  34. package/esm/picker/type.d.ts +5 -0
  35. package/esm/pull-refresh/android-pull-refresh.js +3 -7
  36. package/esm/pull-refresh/model.d.ts +1 -0
  37. package/esm/search-bar/association.js +2 -2
  38. package/esm/search-bar/type.d.ts +1 -1
  39. package/esm/stepper/hooks/useValue.js +1 -0
  40. package/esm/tabs/index.js +1 -1
  41. package/esm/tabs/type.d.ts +2 -2
  42. package/esnext/_helpers/hooks.d.ts +10 -2
  43. package/esnext/_helpers/hooks.js +12 -5
  44. package/esnext/date-picker/index.js +167 -10
  45. package/esnext/date-picker/style/css/index.css +42 -0
  46. package/esnext/date-picker/style/index.less +38 -1
  47. package/esnext/date-picker/type.d.ts +22 -6
  48. package/esnext/form/linked-container.d.ts +2 -2
  49. package/esnext/form/linked-container.js +7 -2
  50. package/esnext/picker/index.js +2 -1
  51. package/esnext/picker/type.d.ts +5 -0
  52. package/esnext/pull-refresh/android-pull-refresh.js +5 -6
  53. package/esnext/pull-refresh/model.d.ts +1 -0
  54. package/esnext/search-bar/association.js +1 -1
  55. package/esnext/search-bar/type.d.ts +1 -1
  56. package/esnext/stepper/hooks/useValue.js +1 -0
  57. package/esnext/tabs/index.js +1 -1
  58. package/esnext/tabs/type.d.ts +2 -2
  59. package/package.json +3 -3
  60. package/tokens/app/arcodesign/default/css-variables.less +10 -0
  61. package/tokens/app/arcodesign/default/index.d.ts +10 -0
  62. package/tokens/app/arcodesign/default/index.js +11 -1
  63. package/tokens/app/arcodesign/default/index.json +108 -0
  64. package/tokens/app/arcodesign/default/index.less +10 -0
  65. package/umd/_helpers/hooks.d.ts +10 -2
  66. package/umd/_helpers/hooks.js +12 -5
  67. package/umd/date-picker/index.js +218 -18
  68. package/umd/date-picker/style/css/index.css +42 -0
  69. package/umd/date-picker/style/index.less +38 -1
  70. package/umd/date-picker/type.d.ts +22 -6
  71. package/umd/form/linked-container.d.ts +2 -2
  72. package/umd/form/linked-container.js +5 -1
  73. package/umd/picker/index.js +3 -2
  74. package/umd/picker/type.d.ts +5 -0
  75. package/umd/pull-refresh/android-pull-refresh.js +7 -12
  76. package/umd/pull-refresh/model.d.ts +1 -0
  77. package/umd/search-bar/association.js +2 -2
  78. package/umd/search-bar/type.d.ts +1 -1
  79. package/umd/stepper/hooks/useValue.js +5 -5
  80. package/umd/tabs/index.js +1 -1
  81. package/umd/tabs/type.d.ts +2 -2
package/CHANGELOG.md CHANGED
@@ -3,6 +3,35 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [2.36.0](https://github.com/arco-design/arco-design-mobile/compare/@arco-design/mobile-react@2.35.2...@arco-design/mobile-react@2.36.0) (2025-05-13)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * `SearchBar` add mouse event param to "onAssociationItemClick" ([#319](https://github.com/arco-design/arco-design-mobile/issues/319)) ([c31c0a5](https://github.com/arco-design/arco-design-mobile/commit/c31c0a5edc0a5fdb172aa81c0216071648dea3a8))
12
+ * `Tabs` optimize updateLayout ([#320](https://github.com/arco-design/arco-design-mobile/issues/320)) ([7b59074](https://github.com/arco-design/arco-design-mobile/commit/7b59074949e62c1552beec4702f911a720e966e3))
13
+ * add harmony system detection support ([#317](https://github.com/arco-design/arco-design-mobile/issues/317)) ([105f459](https://github.com/arco-design/arco-design-mobile/commit/105f45941317c6044aaf0f2f284ca48e630dfc08))
14
+
15
+
16
+ ### Features
17
+
18
+ * `DatePicker` add date range picker ([#323](https://github.com/arco-design/arco-design-mobile/issues/323)) ([d02357c](https://github.com/arco-design/arco-design-mobile/commit/d02357cdf6ed43e102c0827937f8ea8396bfb8ae))
19
+
20
+
21
+
22
+
23
+
24
+ ## [2.35.2](https://github.com/arco-design/arco-design-mobile/compare/@arco-design/mobile-react@2.35.1...@arco-design/mobile-react@2.35.2) (2025-03-17)
25
+
26
+
27
+ ### Bug Fixes
28
+
29
+ * `PullRefresh` fix severe lagging in Android device ([#316](https://github.com/arco-design/arco-design-mobile/issues/316)) ([2b14461](https://github.com/arco-design/arco-design-mobile/commit/2b14461f787c42035e06c7a76b50955f22cadde2))
30
+
31
+
32
+
33
+
34
+
6
35
  ## [2.35.1](https://github.com/arco-design/arco-design-mobile/compare/@arco-design/mobile-react@2.35.0...@arco-design/mobile-react@2.35.1) (2025-02-26)
7
36
 
8
37
 
package/README.en-US.md CHANGED
@@ -59,8 +59,8 @@ React & ReactDOM: **<a href="https://reactjs.org/docs/cdn-links.html" target="_b
59
59
  React Transition Group: **<a href="https://reactcommunity.org/react-transition-group/" target="_blank">Click here</a>**
60
60
 
61
61
  ```
62
- <link ref="stylesheet" href="https://unpkg.com/@arco-design/mobile-react@2.35.0/dist/style.min.css">
63
- <script src="https://unpkg.com/@arco-design/mobile-react@2.35.0/dist/index.min.js"></script>
62
+ <link ref="stylesheet" href="https://unpkg.com/@arco-design/mobile-react@2.35.2/dist/style.min.css">
63
+ <script src="https://unpkg.com/@arco-design/mobile-react@2.35.2/dist/index.min.js"></script>
64
64
  ```
65
65
 
66
66
  ## Full import
package/README.md CHANGED
@@ -59,8 +59,8 @@ React & ReactDOM: **<a href="https://reactjs.org/docs/cdn-links.html" target="
59
59
  React Transition Group: **<a href="https://reactcommunity.org/react-transition-group/" target="_blank">戳这里获取</a>**
60
60
 
61
61
  ```
62
- <link ref="stylesheet" href="https://unpkg.com/@arco-design/mobile-react@2.35.0/dist/style.min.css">
63
- <script src="https://unpkg.com/@arco-design/mobile-react@2.35.0/dist/index.min.js"></script>
62
+ <link ref="stylesheet" href="https://unpkg.com/@arco-design/mobile-react@2.35.2/dist/style.min.css">
63
+ <script src="https://unpkg.com/@arco-design/mobile-react@2.35.2/dist/index.min.js"></script>
64
64
  ```
65
65
 
66
66
  ## 引入全部
@@ -4,6 +4,7 @@
4
4
  * @name_en General Hooks
5
5
  */
6
6
  import React from 'react';
7
+ import type { SystemOptions } from '@arco-design/mobile-utils';
7
8
  import { BezierType } from '../progress';
8
9
  /**
9
10
  * 监听页面resize事件的统一封装
@@ -130,15 +131,22 @@ export declare function useLatestRef<T>(variable: T): React.MutableRefObject<T>;
130
131
  /**
131
132
  * 从navigator.userAgent中获取当前操作系统,如果无法获取ua,则从ContextProvider传入的system中获取值
132
133
  * @desc {en} Get the current operating system from navigator.userAgent, if ua cannot be obtained, get the value from the system passed in by ContextProvider
133
- * @returns system 操作系统,"" | "pc" | "android" | "ios"
134
+ * @param options 配置选项
135
+ * @param {en} options Configuration options
136
+ * @param options.detectHarmony 是否识别鸿蒙系统,默认为 false,鸿蒙系统会被识别为 android
137
+ * @param {en} options.detectHarmony Whether to detect HarmonyOS separately, default is false, HarmonyOS will be recognized as android
138
+ * @returns 返回当前设备的操作系统,可能的值包括 'android'、'ios'、'harmony' 或 'pc',如果无法获取,则返回空字符串
139
+ * @returns {en} Returns the operating system of the current device, possible values are 'android', 'ios', 'harmony', or 'pc'. Returns an empty string if it cannot be obtained
134
140
  * @example
135
141
  * ```
136
142
  * import { useSystem } from '@arco-design/mobile-react/esm/_helpers/hooks';
137
143
  *
138
144
  * const system = useSystem();
145
+ * // Or with options
146
+ * const systemWithHarmony = useSystem({ detectHarmony: true });
139
147
  * ```
140
148
  */
141
- export declare function useSystem(): "" | "android" | "ios" | "pc";
149
+ export declare function useSystem(options?: SystemOptions): "" | "android" | "harmony" | "ios" | "pc";
142
150
  /**
143
151
  * 获取页面视口宽高大小,并在页面有resize时更新大小
144
152
  * @desc {en} Get the width and height of the page viewport, and update the size when the page is resized
@@ -276,29 +276,36 @@ function useLatestRef(variable) {
276
276
  /**
277
277
  * 从navigator.userAgent中获取当前操作系统,如果无法获取ua,则从ContextProvider传入的system中获取值
278
278
  * @desc {en} Get the current operating system from navigator.userAgent, if ua cannot be obtained, get the value from the system passed in by ContextProvider
279
- * @returns system 操作系统,"" | "pc" | "android" | "ios"
279
+ * @param options 配置选项
280
+ * @param {en} options Configuration options
281
+ * @param options.detectHarmony 是否识别鸿蒙系统,默认为 false,鸿蒙系统会被识别为 android
282
+ * @param {en} options.detectHarmony Whether to detect HarmonyOS separately, default is false, HarmonyOS will be recognized as android
283
+ * @returns 返回当前设备的操作系统,可能的值包括 'android'、'ios'、'harmony' 或 'pc',如果无法获取,则返回空字符串
284
+ * @returns {en} Returns the operating system of the current device, possible values are 'android', 'ios', 'harmony', or 'pc'. Returns an empty string if it cannot be obtained
280
285
  * @example
281
286
  * ```
282
287
  * import { useSystem } from '@arco-design/mobile-react/esm/_helpers/hooks';
283
288
  *
284
289
  * const system = useSystem();
290
+ * // Or with options
291
+ * const systemWithHarmony = useSystem({ detectHarmony: true });
285
292
  * ```
286
293
  */
287
294
 
288
295
 
289
- function useSystem() {
296
+ function useSystem(options) {
290
297
  var _useContext = (0, _react.useContext)(_contextProvider.GlobalContext),
291
298
  currentSystem = _useContext.system;
292
299
 
293
300
  var _useState5 = (0, _react.useState)(function () {
294
- return currentSystem || (0, _mobileUtils.getSystem)();
301
+ return currentSystem || (0, _mobileUtils.getSystem)(options);
295
302
  }),
296
303
  system = _useState5[0],
297
304
  setSystem = _useState5[1];
298
305
 
299
306
  (0, _react.useEffect)(function () {
300
- setSystem(currentSystem || (0, _mobileUtils.getSystem)());
301
- }, [currentSystem]);
307
+ setSystem(currentSystem || (0, _mobileUtils.getSystem)(options));
308
+ }, [currentSystem, options]);
302
309
  return system;
303
310
  }
304
311
  /**
@@ -30,7 +30,7 @@ Object.keys(_type).forEach(function (key) {
30
30
  if (key in exports && exports[key] === _type[key]) return;
31
31
  exports[key] = _type[key];
32
32
  });
33
- var _excluded = ["currentTs", "className", "visible", "onOk", "onChange", "onValueChange", "mode", "typeArr", "minTs", "maxTs", "formatter", "valueFilter", "columnsProcessor", "touchToStop", "useUTC", "renderLinkedContainer"];
33
+ var _excluded = ["currentTs", "className", "visible", "onOk", "onChange", "onValueChange", "mode", "typeArr", "minTs", "maxTs", "rangeItemFormat", "formatter", "valueFilter", "columnsProcessor", "touchToStop", "useUTC", "renderSeparator", "renderLinkedContainer"];
34
34
 
35
35
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
36
36
 
@@ -58,9 +58,10 @@ var DatePicker = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
58
58
  _props$typeArr = props.typeArr,
59
59
  typeArr = _props$typeArr === void 0 ? [] : _props$typeArr,
60
60
  _props$minTs = props.minTs,
61
- minTs = _props$minTs === void 0 ? initMinDate : _props$minTs,
61
+ userSetMinTs = _props$minTs === void 0 ? initMinDate : _props$minTs,
62
62
  _props$maxTs = props.maxTs,
63
- maxTs = _props$maxTs === void 0 ? initMaxDate : _props$maxTs,
63
+ userSetMaxTs = _props$maxTs === void 0 ? initMaxDate : _props$maxTs,
64
+ rangeItemFormat = props.rangeItemFormat,
64
65
  _props$formatter = props.formatter,
65
66
  formatter = _props$formatter === void 0 ? defaultFormatter : _props$formatter,
66
67
  _props$valueFilter = props.valueFilter,
@@ -71,17 +72,40 @@ var DatePicker = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
71
72
  touchToStop = props.touchToStop,
72
73
  _props$useUTC = props.useUTC,
73
74
  useUTC = _props$useUTC === void 0 ? false : _props$useUTC,
75
+ renderSeparator = props.renderSeparator,
74
76
  renderLinkedContainer = props.renderLinkedContainer,
75
77
  otherProps = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
76
- var currentTs = Math.min(maxTs, Math.max(minTs, userSetCurrentTs));
78
+ var isRange = typeof userSetCurrentTs !== 'number';
77
79
 
78
- var _useState = (0, _react.useState)([[]]),
79
- data = _useState[0],
80
- setData = _useState[1];
80
+ var _useState = (0, _react.useState)(userSetCurrentTs[0]),
81
+ leftTimeValue = _useState[0],
82
+ setLeftTimeValue = _useState[1];
81
83
 
82
- var _useState2 = (0, _react.useState)([]),
83
- value = _useState2[0],
84
- setValue = _useState2[1];
84
+ var _useState2 = (0, _react.useState)(userSetCurrentTs[1]),
85
+ rightTimeValue = _useState2[0],
86
+ setRightTimeValue = _useState2[1];
87
+
88
+ var _useState3 = (0, _react.useState)(0),
89
+ activeTabIndex = _useState3[0],
90
+ setActiveTabIndex = _useState3[1];
91
+
92
+ var _useMemo = (0, _react.useMemo)(function () {
93
+ return _updateTimeScope();
94
+ }, [userSetMinTs, userSetMaxTs, activeTabIndex]),
95
+ minTs = _useMemo[0],
96
+ maxTs = _useMemo[1];
97
+
98
+ var _useState4 = (0, _react.useState)(isRange ? Math.min(maxTs, Math.max(minTs, userSetCurrentTs[0])) : Math.min(maxTs, Math.max(minTs, userSetCurrentTs))),
99
+ currentTs = _useState4[0],
100
+ setCurrentTs = _useState4[1];
101
+
102
+ var _useState5 = (0, _react.useState)([[]]),
103
+ data = _useState5[0],
104
+ setData = _useState5[1];
105
+
106
+ var _useState6 = (0, _react.useState)([]),
107
+ value = _useState6[0],
108
+ setValue = _useState6[1];
85
109
 
86
110
  var currentDateObjRef = (0, _react.useRef)(_convertTsToDateObj(currentTs));
87
111
  var minDateObjRef = (0, _react.useRef)(_convertTsToDateObj(minTs));
@@ -89,7 +113,36 @@ var DatePicker = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
89
113
  var keyOptions = (0, _react.useMemo)(function () {
90
114
  return _getKeyOptions();
91
115
  }, [mode, typeArr]);
116
+ var leftTimeString = (0, _react.useMemo)(function () {
117
+ return _getRangeItemValue(leftTimeValue);
118
+ }, [leftTimeValue]);
119
+ var rightTimeString = (0, _react.useMemo)(function () {
120
+ return _getRangeItemValue(rightTimeValue);
121
+ }, [rightTimeValue]);
92
122
  var pickerRef = (0, _react.useRef)(null);
123
+
124
+ function _updateRangeValue(nowCurrentTs) {
125
+ var leftMinTs = typeof userSetMinTs !== 'number' ? userSetMinTs.startTs : userSetMinTs;
126
+ var rightMinTs = typeof userSetMinTs !== 'number' ? userSetMinTs.endTs : userSetMinTs;
127
+ var leftMaxTs = typeof userSetMaxTs !== 'number' ? userSetMaxTs.startTs : userSetMaxTs;
128
+ var rightMaxTs = typeof userSetMaxTs !== 'number' ? userSetMaxTs.endTs : userSetMaxTs;
129
+
130
+ if (isRange) {
131
+ var leftTime, rightTime;
132
+
133
+ if (activeTabIndex === 0) {
134
+ leftTime = nowCurrentTs;
135
+ rightTime = Math.min(rightMaxTs, Math.max(Math.max(leftTime, rightMinTs), rightTimeValue));
136
+ } else {
137
+ rightTime = nowCurrentTs;
138
+ leftTime = Math.min(leftMaxTs, Math.max(leftMinTs, leftTimeValue));
139
+ }
140
+
141
+ setLeftTimeValue(leftTime);
142
+ setRightTimeValue(rightTime);
143
+ }
144
+ }
145
+
93
146
  (0, _react.useImperativeHandle)(ref, function () {
94
147
  return {
95
148
  dom: pickerRef.current ? pickerRef.current.dom : null
@@ -113,6 +166,65 @@ var DatePicker = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
113
166
  };
114
167
  }
115
168
 
169
+ function _parseFormat(format, timeValue) {
170
+ var year = timeValue.year,
171
+ month = timeValue.month,
172
+ date = timeValue.date,
173
+ hour = timeValue.hour,
174
+ minute = timeValue.minute,
175
+ second = timeValue.second;
176
+
177
+ var padZero = function padZero(num, targetLength) {
178
+ if (targetLength === void 0) {
179
+ targetLength = 2;
180
+ }
181
+
182
+ var str = "" + num;
183
+
184
+ while (str.length < targetLength) {
185
+ str = "0" + str;
186
+ }
187
+
188
+ return str;
189
+ };
190
+
191
+ var replace = function replace(formatArg, str, num) {
192
+ if (formatArg.includes(str)) {
193
+ return str !== 'Y' ? formatArg.replace(str.repeat(2), padZero(num)).replace(str, padZero(num)) : formatArg.replace(str.repeat(4), padZero(num)).replace(str.repeat(2), padZero(num)).replace(str, padZero(num));
194
+ }
195
+
196
+ return formatArg;
197
+ };
198
+
199
+ return [['Y', year], ['M', month], ['D', date], ['H', hour], ['m', minute], ['s', second]].reduce(function (current, item) {
200
+ return replace(current, item[0], item[1]);
201
+ }, format);
202
+ }
203
+
204
+ function _getRangeItemValue(time) {
205
+ var timeValue = _convertTsToDateObj(time);
206
+
207
+ if (!isRange) {
208
+ return;
209
+ }
210
+
211
+ if (rangeItemFormat) {
212
+ return _parseFormat(rangeItemFormat, timeValue);
213
+ }
214
+
215
+ var format = function format(options, joinString) {
216
+ return options.filter(function (option) {
217
+ return keyOptions.includes(option);
218
+ }).map(function (option) {
219
+ return timeValue[option] < 10 ? "0" + timeValue[option] : "" + timeValue[option];
220
+ }).join(joinString);
221
+ };
222
+
223
+ var datePart = format(['year', 'month', 'date'], '/');
224
+ var timePart = format(['hour', 'minute', 'second'], ':');
225
+ return datePart + (datePart && timePart && ' ') + timePart;
226
+ }
227
+
116
228
  function _getSelectValue(columns) {
117
229
  var val = keyOptions.map(function (opt, index) {
118
230
  var _curCol$Math$max;
@@ -245,7 +357,7 @@ var DatePicker = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
245
357
 
246
358
  function _handlePickerChange(values, index) {
247
359
  var type = keyOptions[index];
248
- var nowDateObj = {};
360
+ var nowDateObj = currentDateObjRef.current;
249
361
  values.forEach(function (i, keyIndex) {
250
362
  nowDateObj[keyOptions[keyIndex]] = i;
251
363
  });
@@ -273,18 +385,35 @@ var DatePicker = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
273
385
  setValue(val);
274
386
  }
275
387
 
388
+ setCurrentTs(_convertObjToTs(nowDateObj, currentTs));
389
+
276
390
  if (onValueChange) {
277
391
  onValueChange(_convertObjToTs(nowDateObj, currentTs), nowDateObj, index);
278
392
  }
279
393
  }
280
394
 
281
395
  function _handlePickerConfirm(values) {
282
- var nowDateObj = {};
283
- values.forEach(function (index, keyIndex) {
284
- nowDateObj[keyOptions[keyIndex]] = index;
285
- });
286
-
287
- var newTs = _convertObjToTs(nowDateObj, currentTs);
396
+ var nowDateObj;
397
+ var newTs;
398
+
399
+ if (isRange) {
400
+ var leftTimeObj = _convertTsToDateObj(leftTimeValue);
401
+
402
+ var rightTimeObj = _convertTsToDateObj(rightTimeValue);
403
+
404
+ nowDateObj = keyOptions.reduce(function (arr, key) {
405
+ arr[0][key] = leftTimeObj[key];
406
+ arr[1][key] = rightTimeObj[key];
407
+ return arr;
408
+ }, [{}, {}]);
409
+ newTs = [_convertObjToTs(nowDateObj[0], currentTs), _convertObjToTs(nowDateObj[1], currentTs)];
410
+ } else {
411
+ nowDateObj = {};
412
+ values.forEach(function (index, keyIndex) {
413
+ nowDateObj[keyOptions[keyIndex]] = index;
414
+ });
415
+ newTs = _convertObjToTs(nowDateObj, currentTs);
416
+ }
288
417
 
289
418
  if (onOk) {
290
419
  onOk(newTs, nowDateObj);
@@ -318,6 +447,24 @@ var DatePicker = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
318
447
  return options;
319
448
  }
320
449
 
450
+ function _updateTimeScope(isLeft) {
451
+ var nowMaxTs, nowMinTs;
452
+
453
+ if (isLeft || activeTabIndex === 0) {
454
+ nowMaxTs = typeof userSetMaxTs === 'number' ? userSetMaxTs : userSetMaxTs.startTs;
455
+ nowMinTs = Math.min(nowMaxTs, typeof userSetMinTs === 'number' ? userSetMinTs : userSetMinTs.startTs);
456
+ } else {
457
+ nowMinTs = Math.max(Math.min(typeof userSetMaxTs === 'number' ? userSetMaxTs : userSetMaxTs.startTs, leftTimeValue), typeof userSetMinTs === 'number' ? userSetMinTs : userSetMinTs.endTs);
458
+ nowMaxTs = Math.max(nowMinTs, typeof userSetMaxTs === 'number' ? userSetMaxTs : userSetMaxTs.endTs);
459
+ }
460
+
461
+ return [nowMinTs, nowMaxTs];
462
+ }
463
+
464
+ function _chooseTimeActive(index) {
465
+ setActiveTabIndex(index);
466
+ }
467
+
321
468
  (0, _react.useEffect)(function () {
322
469
  minDateObjRef.current = _convertTsToDateObj(minTs);
323
470
  currentDateObjRef.current = _convertTsToDateObj(currentTs);
@@ -325,9 +472,45 @@ var DatePicker = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
325
472
 
326
473
  _initData();
327
474
  }, [currentTs, minTs, maxTs, useUTC]);
475
+ (0, _react.useEffect)(function () {
476
+ var nowCurrentTs;
477
+
478
+ if (isRange) {
479
+ nowCurrentTs = Math.min(maxTs, Math.max(minTs, activeTabIndex === 0 ? leftTimeValue : rightTimeValue));
480
+
481
+ if (currentTs === nowCurrentTs) {
482
+ _updateRangeValue(currentTs);
483
+ }
484
+ } else {
485
+ nowCurrentTs = Math.min(maxTs, Math.max(minTs, currentTs));
486
+ }
487
+
488
+ setCurrentTs(nowCurrentTs);
489
+ }, [minTs, maxTs]);
490
+ (0, _react.useEffect)(function () {
491
+ _updateRangeValue(currentTs);
492
+ }, [currentTs]);
328
493
  (0, _react.useEffect)(function () {
329
494
  if (visible) {
330
- currentDateObjRef.current = _convertTsToDateObj(currentTs);
495
+ // 初始化当前时间
496
+ if (isRange) {
497
+ setActiveTabIndex(0);
498
+ setLeftTimeValue(userSetCurrentTs[0]);
499
+ setRightTimeValue(userSetCurrentTs[1]);
500
+
501
+ var _updateTimeScope2 = _updateTimeScope(true),
502
+ nowMinTs = _updateTimeScope2[0],
503
+ nowMaxTs = _updateTimeScope2[1];
504
+
505
+ var nowCurrentTs = Math.min(nowMaxTs, Math.max(nowMinTs, userSetCurrentTs[0]));
506
+ setCurrentTs(nowCurrentTs);
507
+
508
+ if (currentTs === nowCurrentTs) {
509
+ _updateRangeValue(currentTs);
510
+ }
511
+ } else {
512
+ setCurrentTs(Math.min(maxTs, Math.max(minTs, userSetCurrentTs)));
513
+ }
331
514
 
332
515
  _initData();
333
516
  }
@@ -344,6 +527,23 @@ var DatePicker = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
344
527
  onPickerChange: _handlePickerChange,
345
528
  onOk: _handlePickerConfirm,
346
529
  touchToStop: touchToStop,
530
+ renderExtraHeader: isRange ? function () {
531
+ return /*#__PURE__*/_react.default.createElement("div", {
532
+ className: prefixCls + "-date-picker-show"
533
+ }, /*#__PURE__*/_react.default.createElement("span", {
534
+ className: (0, _mobileUtils.cls)("" + (activeTabIndex === 0 ? prefixCls + "-date-picker-range-item-active" : ''), prefixCls + "-date-picker-range-item"),
535
+ onClick: function onClick() {
536
+ return _chooseTimeActive(0);
537
+ }
538
+ }, leftTimeString), renderSeparator ? renderSeparator() : /*#__PURE__*/_react.default.createElement("span", {
539
+ className: prefixCls + "-date-picker-show-separate"
540
+ }, "~"), /*#__PURE__*/_react.default.createElement("span", {
541
+ className: (0, _mobileUtils.cls)("" + (activeTabIndex === 1 ? prefixCls + "-date-picker-range-item-active" : ''), prefixCls + "-date-picker-range-item"),
542
+ onClick: function onClick() {
543
+ return _chooseTimeActive(1);
544
+ }
545
+ }, rightTimeString));
546
+ } : undefined,
347
547
  renderLinkedContainer: renderLinkedContainer ? function () {
348
548
  return renderLinkedContainer((0, _mobileUtils.isEmptyValue)(props.currentTs) ? undefined : currentTs, keyOptions);
349
549
  } : undefined
@@ -510,6 +510,41 @@
510
510
  * }
511
511
  * ```
512
512
  */
513
+ .arco-date-picker-show {
514
+ display: -webkit-box;
515
+ display: -webkit-flex;
516
+ display: flex;
517
+ font-size: 0.32rem ;
518
+ padding: 0 0.32rem ;
519
+ color: #c9cdd4 ;
520
+ min-height: 0.96rem ;
521
+ background-color: #FBFCFC ;
522
+ }
523
+ .arco-date-picker-show > span {
524
+ display: -webkit-box;
525
+ display: -webkit-flex;
526
+ display: flex;
527
+ -webkit-box-align: center;
528
+ -webkit-align-items: center;
529
+ align-items: center;
530
+ -webkit-box-pack: center;
531
+ -webkit-justify-content: center;
532
+ justify-content: center;
533
+ }
534
+ .arco-date-picker-show-separate {
535
+ -webkit-box-flex: 0;
536
+ -webkit-flex: 0 1 auto;
537
+ flex: 0 1 auto;
538
+ min-width: 0.96rem ;
539
+ }
540
+ .arco-date-picker-range-item {
541
+ -webkit-box-flex: 1;
542
+ -webkit-flex: 1 0 auto;
543
+ flex: 1 0 auto;
544
+ }
545
+ .arco-date-picker-range-item-active {
546
+ color: #1d2129 ;
547
+ }
513
548
  /***************************************************
514
549
  * *
515
550
  * Arco Theme Style *
@@ -523,4 +558,11 @@
523
558
  background: #2e2e30 ;
524
559
  color: #929293 ;
525
560
  }
561
+ .arco-theme-dark .arco-date-picker-show {
562
+ color: #5f5f60 ;
563
+ background-color: #1E1E1E ;
564
+ }
565
+ .arco-theme-dark .arco-date-picker-range-item-active {
566
+ color: #f6f6f6 ;
567
+ }
526
568
  /********************* End *************************/
@@ -1,7 +1,29 @@
1
1
  @import '../../../style/mixin.less';
2
2
 
3
3
  .@{prefix}-date-picker {
4
-
4
+ &-show {
5
+ display: flex;
6
+ .use-var(font-size, date-picker-range-font-size);
7
+ .use-var(padding, date-picker-range-show-padding);
8
+ .use-var(color, date-picker-range-disabled-font-color);
9
+ .use-var(min-height, date-picker-range-show-min-height);
10
+ .use-var(background-color, date-picker-range-background-color);
11
+ & > span {
12
+ display: flex;
13
+ align-items: center;
14
+ justify-content: center;
15
+ }
16
+ &-separate {
17
+ flex: 0 1 auto;
18
+ .use-var(min-width, date-picker-range-separate-min-width);
19
+ }
20
+ }
21
+ &-range-item {
22
+ flex: 1 0 auto;
23
+ &-active {
24
+ .use-var(color, date-picker-range-font-color);
25
+ }
26
+ }
5
27
  }
6
28
 
7
29
  /***************************************************
@@ -26,5 +48,20 @@
26
48
  .use-var(color, dark-sub-info-font-color);
27
49
  }
28
50
  }
51
+ .@{prefix}-date-picker {
52
+ &-show {
53
+ @{arco-dark-mode-selector} & {
54
+ .use-var(color, dark-date-picker-range-disabled-font-color);
55
+ .use-var(background-color, dark-date-picker-range-background-color);
56
+ }
57
+ }
58
+ &-range-item {
59
+ &-active {
60
+ @{arco-dark-mode-selector} & {
61
+ .use-var(color, dark-date-picker-range-font-color);
62
+ }
63
+ }
64
+ }
65
+ }
29
66
  }
30
67
  /********************* End *************************/
@@ -40,18 +40,18 @@ export interface DatePickerProps extends Omit<PickerProps, 'data' | 'cascade' |
40
40
  * 点击选中时执行的回调
41
41
  * @en Callback when clicking OK
42
42
  */
43
- onOk?: (timestamp: number, obj: IDateObj) => void;
43
+ onOk?: (timestamp: number | [number, number], obj: IDateObj | [IDateObj, IDateObj]) => void;
44
44
  /**
45
45
  * 当前选中的时间,timestamp
46
46
  * @en The currently selected time, timestamp
47
47
  * @default Date.now()
48
48
  */
49
- currentTs?: number;
49
+ currentTs?: number | [number, number];
50
50
  /**
51
51
  * 选中后的回调
52
52
  * @en Callback when value is changed
53
53
  */
54
- onChange?: (timestamp: number, obj: IDateObj) => void;
54
+ onChange?: (timestamp: number | [number, number], obj: IDateObj | [IDateObj, IDateObj]) => void;
55
55
  /**
56
56
  * 每列数据选择变化后的回调函数
57
57
  * @en The callback function after each column data selection changes
@@ -75,20 +75,31 @@ export interface DatePickerProps extends Omit<PickerProps, 'data' | 'cascade' |
75
75
  * @default 当前时间的前十年
76
76
  * @default_en 10 years ago from the current time
77
77
  */
78
- minTs?: number;
78
+ minTs?: number | {
79
+ startTs: number;
80
+ endTs: number;
81
+ };
79
82
  /**
80
83
  * 最大可选日期,timestamp
81
84
  * @en Maximum selectable date, timestamp
82
85
  * @default 当前时间的后十年
83
86
  * @default_en Next decade from current time
84
87
  */
85
- maxTs?: number;
88
+ maxTs?: number | {
89
+ startTs: number;
90
+ endTs: number;
91
+ };
86
92
  /**
87
93
  * 是否使用 UTC 时间
88
94
  * @en Whether to use UTC
89
95
  * @default false
90
96
  */
91
97
  useUTC?: boolean;
98
+ /**
99
+ * 日期时间范围选择展示格式
100
+ * @en Time range picker display format
101
+ */
102
+ rangeItemFormat?: string;
92
103
  /**
93
104
  * 各可选项展示的格式化方法,参数type为ItemTypes,参数value为当前行的值,返回展示的文字
94
105
  * @en The formatting method of each optional item, the parameter type is ItemTypes, the parameter value is the value of the current row, and the displayed text is returned.
@@ -106,9 +117,14 @@ export interface DatePickerProps extends Omit<PickerProps, 'data' | 'cascade' |
106
117
  * @en Selector list item intervention to insert custom options.
107
118
  */
108
119
  columnsProcessor?: (columns: PickerData[][], currentDateObj: IDateObj) => PickerData[][];
120
+ /**
121
+ * 自定义分隔符
122
+ * @en Defined separator area
123
+ */
124
+ renderSeparator?: () => React.ReactNode;
109
125
  /**
110
126
  * 将选择器的展现隐藏状态及选中值的展示与某个容器关联,传入后将同时渲染该容器和选择器组件,此时选择器组件的 visible 和 onHide 属性可不传,点击该容器会唤起选择器
111
127
  * @en Associate the hidden state of the picker and the display of the selected value with a container. After passing it in, the container and the picker component will be rendered at the same time. At this time, the visible and onHide attributes of the picker component are optional values. Clicking the container will evoke the picker
112
128
  */
113
- renderLinkedContainer?: (currentTs: number | undefined, itemTypes: ItemType[]) => ReactNode;
129
+ renderLinkedContainer?: (currentTs: number | [number, number] | undefined, itemTypes: ItemType[]) => ReactNode;
114
130
  }
@@ -2,7 +2,7 @@
2
2
  export declare function DefaultPickerLinkedContainer({ value }: {
3
3
  value: (string | number)[];
4
4
  }): JSX.Element;
5
- export declare function DefaultDatePickerLinkedContainer({ ts, types }: {
6
- ts: number;
5
+ export declare function DefaultDatePickerLinkedContainer({ ts, types, }: {
6
+ ts: number | [number, number];
7
7
  types: string[];
8
8
  }): JSX.Element;
@@ -45,7 +45,11 @@ function DefaultDatePickerLinkedContainer(_ref2) {
45
45
 
46
46
  var className = prefixCls + "-form-picker-link-container";
47
47
  var dateTimeStr = (0, _react.useMemo)(function () {
48
- return formatDateTimeStr(ts, types);
48
+ if (typeof ts === 'number') {
49
+ return formatDateTimeStr(ts, types);
50
+ }
51
+
52
+ return formatDateTimeStr(ts[0], types) + " ~ " + formatDateTimeStr(ts[1], types);
49
53
  }, [ts, types]);
50
54
 
51
55
  function formatDateTimeStr(timestamp, itemTypes) {