@arco-design/mobile-react 2.35.2 → 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 (73) hide show
  1. package/CHANGELOG.md +18 -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/search-bar/association.js +2 -2
  15. package/cjs/search-bar/type.d.ts +1 -1
  16. package/cjs/stepper/hooks/useValue.js +3 -1
  17. package/cjs/tabs/index.js +1 -1
  18. package/cjs/tabs/type.d.ts +2 -2
  19. package/dist/index.js +272 -38
  20. package/dist/index.min.js +4 -4
  21. package/dist/style.css +23 -0
  22. package/dist/style.min.css +1 -1
  23. package/esm/_helpers/hooks.d.ts +10 -2
  24. package/esm/_helpers/hooks.js +12 -5
  25. package/esm/date-picker/index.js +218 -18
  26. package/esm/date-picker/style/css/index.css +42 -0
  27. package/esm/date-picker/style/index.less +38 -1
  28. package/esm/date-picker/type.d.ts +22 -6
  29. package/esm/form/linked-container.d.ts +2 -2
  30. package/esm/form/linked-container.js +5 -1
  31. package/esm/picker/index.js +3 -2
  32. package/esm/picker/type.d.ts +5 -0
  33. package/esm/search-bar/association.js +2 -2
  34. package/esm/search-bar/type.d.ts +1 -1
  35. package/esm/stepper/hooks/useValue.js +1 -0
  36. package/esm/tabs/index.js +1 -1
  37. package/esm/tabs/type.d.ts +2 -2
  38. package/esnext/_helpers/hooks.d.ts +10 -2
  39. package/esnext/_helpers/hooks.js +12 -5
  40. package/esnext/date-picker/index.js +167 -10
  41. package/esnext/date-picker/style/css/index.css +42 -0
  42. package/esnext/date-picker/style/index.less +38 -1
  43. package/esnext/date-picker/type.d.ts +22 -6
  44. package/esnext/form/linked-container.d.ts +2 -2
  45. package/esnext/form/linked-container.js +7 -2
  46. package/esnext/picker/index.js +2 -1
  47. package/esnext/picker/type.d.ts +5 -0
  48. package/esnext/search-bar/association.js +1 -1
  49. package/esnext/search-bar/type.d.ts +1 -1
  50. package/esnext/stepper/hooks/useValue.js +1 -0
  51. package/esnext/tabs/index.js +1 -1
  52. package/esnext/tabs/type.d.ts +2 -2
  53. package/package.json +3 -3
  54. package/tokens/app/arcodesign/default/css-variables.less +10 -0
  55. package/tokens/app/arcodesign/default/index.d.ts +10 -0
  56. package/tokens/app/arcodesign/default/index.js +11 -1
  57. package/tokens/app/arcodesign/default/index.json +108 -0
  58. package/tokens/app/arcodesign/default/index.less +10 -0
  59. package/umd/_helpers/hooks.d.ts +10 -2
  60. package/umd/_helpers/hooks.js +12 -5
  61. package/umd/date-picker/index.js +218 -18
  62. package/umd/date-picker/style/css/index.css +42 -0
  63. package/umd/date-picker/style/index.less +38 -1
  64. package/umd/date-picker/type.d.ts +22 -6
  65. package/umd/form/linked-container.d.ts +2 -2
  66. package/umd/form/linked-container.js +5 -1
  67. package/umd/picker/index.js +3 -2
  68. package/umd/picker/type.d.ts +5 -0
  69. package/umd/search-bar/association.js +2 -2
  70. package/umd/search-bar/type.d.ts +1 -1
  71. package/umd/stepper/hooks/useValue.js +5 -5
  72. package/umd/tabs/index.js +1 -1
  73. package/umd/tabs/type.d.ts +2 -2
@@ -38,7 +38,7 @@ Object.keys(_type).forEach(function (key) {
38
38
  if (key in exports && exports[key] === _type[key]) return;
39
39
  exports[key] = _type[key];
40
40
  });
41
- var _excluded = ["className", "itemStyle", "cascade", "cols", "rows", "data", "okText", "dismissText", "disabled", "clickable", "hideEmptyCols", "title", "visible", "value", "needBottomOffset", "onDismiss", "onOk", "onChange", "maskClosable", "onHide", "onPickerChange", "touchToStop", "gestureOutOfControl", "renderLinkedContainer"];
41
+ var _excluded = ["className", "itemStyle", "cascade", "cols", "rows", "data", "okText", "dismissText", "disabled", "clickable", "hideEmptyCols", "title", "visible", "value", "needBottomOffset", "onDismiss", "onOk", "onChange", "maskClosable", "onHide", "onPickerChange", "touchToStop", "gestureOutOfControl", "renderLinkedContainer", "renderExtraHeader"];
42
42
 
43
43
  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); }
44
44
 
@@ -79,6 +79,7 @@ var Picker = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
79
79
  _props$gestureOutOfCo = props.gestureOutOfControl,
80
80
  gestureOutOfControl = _props$gestureOutOfCo === void 0 ? true : _props$gestureOutOfCo,
81
81
  renderLinkedContainer = props.renderLinkedContainer,
82
+ renderExtraHeader = props.renderExtraHeader,
82
83
  otherProps = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
83
84
  var scrollValueRef = (0, _helpers.useLatestRef)(value);
84
85
  var domRef = (0, _react.useRef)(null);
@@ -225,7 +226,7 @@ var Picker = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
225
226
  }, title), /*#__PURE__*/_react.default.createElement("div", {
226
227
  className: prefixCls + "-picker-header-btn right",
227
228
  onClick: handleConfirm
228
- }, okText || (locale == null ? void 0 : locale.Picker.okText))), /*#__PURE__*/_react.default.createElement(_pickerView.default, {
229
+ }, okText || (locale == null ? void 0 : locale.Picker.okText))), renderExtraHeader && renderExtraHeader(), /*#__PURE__*/_react.default.createElement(_pickerView.default, {
229
230
  ref: pickerViewRef,
230
231
  data: data,
231
232
  cascade: cascade,
@@ -128,4 +128,9 @@ export interface PickerProps extends Omit<PopupProps, 'visible' | 'close' | 'chi
128
128
  * @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
129
129
  */
130
130
  renderLinkedContainer?: (value: ValueType[], data: PickerData[]) => ReactNode;
131
+ /**
132
+ * 自定义头部扩展区域
133
+ * @en Define the area of extra header
134
+ */
135
+ renderExtraHeader?: () => ReactNode;
131
136
  }
@@ -69,8 +69,8 @@ function SearchBarAssociation(props) {
69
69
  return /*#__PURE__*/_react.default.createElement("div", {
70
70
  key: index,
71
71
  className: searchBarAssociationPrefixCls + "-item",
72
- onClick: function onClick() {
73
- return onAssociationItemClick == null ? void 0 : onAssociationItemClick(item, index);
72
+ onClick: function onClick(e) {
73
+ return onAssociationItemClick == null ? void 0 : onAssociationItemClick(item, index, e);
74
74
  }
75
75
  }, node);
76
76
  };
@@ -57,7 +57,7 @@ export interface SearchBarAssociationProps<Data = Record<string, any>> {
57
57
  * 每行搜索结果的点击回调
58
58
  * @en Click callback for each row of search results
59
59
  */
60
- onAssociationItemClick?: (item: SearchAssociationItem<Data>, index: number) => void;
60
+ onAssociationItemClick?: (item: SearchAssociationItem<Data>, index: number, event: React.MouseEvent<HTMLDivElement, MouseEvent>) => void;
61
61
  /**
62
62
  * 搜索联想框整体被点击的回调
63
63
  * @en The callback for the overall click of the search association box
@@ -5,6 +5,8 @@ exports.default = useValue;
5
5
 
6
6
  var _react = require("react");
7
7
 
8
+ var _es6Promise = require("es6-promise");
9
+
8
10
  function useValue(params) {
9
11
  var defaultValue = params.defaultValue,
10
12
  formatter = params.formatter,
@@ -21,7 +23,7 @@ function useValue(params) {
21
23
  var tempValue = typeof updater === 'function' ? updater(innerValue) : updater;
22
24
 
23
25
  if (formatter) {
24
- new Promise(function (resolve) {
26
+ new _es6Promise.Promise(function (resolve) {
25
27
  resolve(formatter(Number(tempValue)));
26
28
  }).then(function (result) {
27
29
  var res = Math.max(min, Math.min(max, result));
package/cjs/tabs/index.js CHANGED
@@ -439,7 +439,7 @@ var Tabs = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
439
439
  width = _getOffset.width,
440
440
  height = _getOffset.height;
441
441
 
442
- cellRef.current && cellRef.current.resetUnderlineStyle();
442
+ cellRef.current && cellRef.current.updateLayout();
443
443
  setWrapWidth(width || ((_domRef$current = domRef.current) == null ? void 0 : _domRef$current.offsetWidth) || 0);
444
444
  setWrapHeight(height || ((_domRef$current2 = domRef.current) == null ? void 0 : _domRef$current2.offsetHeight) || 0);
445
445
  paneRef.current && paneRef.current.setCurrentHeight();
@@ -561,8 +561,8 @@ export interface TabCellRef {
561
561
  */
562
562
  setCaterpillarAnimate: (ratio?: number) => void;
563
563
  /**
564
- * 重新计算下划线样式
565
- * @en Recalculate underline style
564
+ * 重新计算下划线样式(仅重算位置,如果 tab cell DOM 被人为改变,请调用 updateLayout)
565
+ * @en Recalculate underline style (only recalculate position, if the tab cell DOM is changed manually, please call updateLayout)
566
566
  */
567
567
  resetUnderlineStyle: () => void;
568
568
  /**
package/dist/index.js CHANGED
@@ -1580,12 +1580,17 @@
1580
1580
  /**
1581
1581
  * 获取当前设备的操作系统
1582
1582
  * @desc {en} Get the operating system of the current device
1583
- * @returns {string} 返回当前设备的操作系统,可能的值包括 'android'、'ios' 或 'pc',如果无法获取,则返回空字符串
1584
- * @returns {string} {en} Returns the operating system of the current device, possible values are 'android', 'ios', or 'pc'. Returns an empty string if it cannot be obtained
1583
+ * @param options 配置选项
1584
+ * @param {en} options Configuration options
1585
+ * @param options.detectHarmony 是否识别鸿蒙系统,默认为 false,鸿蒙系统会被识别为 android
1586
+ * @param {en} options.detectHarmony Whether to detect HarmonyOS separately, default is false, HarmonyOS will be recognized as android
1587
+ * @returns 返回当前设备的操作系统,可能的值包括 'android'、'ios'、'harmony' 或 'pc',如果无法获取,则返回空字符串
1588
+ * @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
1585
1589
  * @example
1586
1590
  * ```
1587
1591
  * import { getSystem } from '@arco-design/mobile-utils';
1588
1592
  *
1593
+ * // Default behavior
1589
1594
  * const systemInfo = getSystem();
1590
1595
  * if (systemInfo === 'android') {
1591
1596
  * console.log('You are using the Android operating system');
@@ -1596,16 +1601,32 @@
1596
1601
  * } else {
1597
1602
  * console.log('Unable to detect your operating system');
1598
1603
  * }
1604
+ *
1605
+ * // With HarmonyOS detection enabled
1606
+ * const systemInfoWithHarmony = getSystem({ detectHarmony: true });
1607
+ * if (systemInfoWithHarmony === 'harmony') {
1608
+ * console.log('You are using HarmonyOS');
1609
+ * }
1599
1610
  * ```
1600
1611
  */
1601
- function getSystem() {
1612
+ function getSystem(options) {
1602
1613
  try {
1603
- var u = navigator.userAgent;
1604
- var android = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1;
1605
- var ios = u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
1606
- var pc = !android && !ios;
1607
- var system = android ? 'android' : 'ios';
1608
- return pc ? 'pc' : system;
1614
+ var u = navigator.userAgent; // Do not modify the Harmony OS ua judgment rule, please refer to the official documentation: https://developer.huawei.com/consumer/cn/doc/harmonyos-guides/web-default-useragent
1615
+
1616
+ if (/OpenHarmony/i.test(u)) {
1617
+ return (options === null || options === void 0 ? void 0 : options.detectHarmony) ? 'harmony' : 'android';
1618
+ } // Do not ignore the case of the first letter
1619
+
1620
+
1621
+ if (/Android|Linux/.test(u)) {
1622
+ return 'android';
1623
+ }
1624
+
1625
+ if (/\(i[^;]+;( U;)? CPU.+Mac OS X/.test(u)) {
1626
+ return 'ios';
1627
+ }
1628
+
1629
+ return 'pc';
1609
1630
  } catch (e) {
1610
1631
  return '';
1611
1632
  }
@@ -4124,27 +4145,34 @@
4124
4145
  /**
4125
4146
  * 从navigator.userAgent中获取当前操作系统,如果无法获取ua,则从ContextProvider传入的system中获取值
4126
4147
  * @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
4127
- * @returns system 操作系统,"" | "pc" | "android" | "ios"
4148
+ * @param options 配置选项
4149
+ * @param {en} options Configuration options
4150
+ * @param options.detectHarmony 是否识别鸿蒙系统,默认为 false,鸿蒙系统会被识别为 android
4151
+ * @param {en} options.detectHarmony Whether to detect HarmonyOS separately, default is false, HarmonyOS will be recognized as android
4152
+ * @returns 返回当前设备的操作系统,可能的值包括 'android'、'ios'、'harmony' 或 'pc',如果无法获取,则返回空字符串
4153
+ * @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
4128
4154
  * @example
4129
4155
  * ```
4130
4156
  * import { useSystem } from '@arco-design/mobile-react/esm/_helpers/hooks';
4131
4157
  *
4132
4158
  * const system = useSystem();
4159
+ * // Or with options
4160
+ * const systemWithHarmony = useSystem({ detectHarmony: true });
4133
4161
  * ```
4134
4162
  */
4135
4163
 
4136
- function useSystem() {
4164
+ function useSystem(options) {
4137
4165
  var currentSystem = React.useContext(GlobalContext).system;
4138
4166
 
4139
4167
  var _a = React.useState(function () {
4140
- return currentSystem || getSystem();
4168
+ return currentSystem || getSystem(options);
4141
4169
  }),
4142
4170
  system = _a[0],
4143
4171
  setSystem = _a[1];
4144
4172
 
4145
4173
  React.useEffect(function () {
4146
- setSystem(currentSystem || getSystem());
4147
- }, [currentSystem]);
4174
+ setSystem(currentSystem || getSystem(options));
4175
+ }, [currentSystem, options]);
4148
4176
  return system;
4149
4177
  }
4150
4178
  /**
@@ -6707,7 +6735,7 @@
6707
6735
  width = _c.width,
6708
6736
  height = _c.height;
6709
6737
 
6710
- cellRef.current && cellRef.current.resetUnderlineStyle();
6738
+ cellRef.current && cellRef.current.updateLayout();
6711
6739
  setWrapWidth(width || ((_a = domRef.current) === null || _a === void 0 ? void 0 : _a.offsetWidth) || 0);
6712
6740
  setWrapHeight(height || ((_b = domRef.current) === null || _b === void 0 ? void 0 : _b.offsetHeight) || 0);
6713
6741
  paneRef.current && paneRef.current.setCurrentHeight();
@@ -13485,7 +13513,8 @@
13485
13513
  _k = props.gestureOutOfControl,
13486
13514
  gestureOutOfControl = _k === void 0 ? true : _k,
13487
13515
  renderLinkedContainer = props.renderLinkedContainer,
13488
- otherProps = __rest$1(props, ["className", "itemStyle", "cascade", "cols", "rows", "data", "okText", "dismissText", "disabled", "clickable", "hideEmptyCols", "title", "visible", "value", "needBottomOffset", "onDismiss", "onOk", "onChange", "maskClosable", "onHide", "onPickerChange", "touchToStop", "gestureOutOfControl", "renderLinkedContainer"]);
13516
+ renderExtraHeader = props.renderExtraHeader,
13517
+ otherProps = __rest$1(props, ["className", "itemStyle", "cascade", "cols", "rows", "data", "okText", "dismissText", "disabled", "clickable", "hideEmptyCols", "title", "visible", "value", "needBottomOffset", "onDismiss", "onOk", "onChange", "maskClosable", "onHide", "onPickerChange", "touchToStop", "gestureOutOfControl", "renderLinkedContainer", "renderExtraHeader"]);
13489
13518
 
13490
13519
  var scrollValueRef = useLatestRef(value);
13491
13520
  var domRef = React.useRef(null);
@@ -13632,7 +13661,7 @@
13632
13661
  }, title), /*#__PURE__*/React__default["default"].createElement("div", {
13633
13662
  className: prefixCls + "-picker-header-btn right",
13634
13663
  onClick: handleConfirm
13635
- }, okText || (locale === null || locale === void 0 ? void 0 : locale.Picker.okText))), /*#__PURE__*/React__default["default"].createElement(PickerView$1, {
13664
+ }, okText || (locale === null || locale === void 0 ? void 0 : locale.Picker.okText))), renderExtraHeader && renderExtraHeader(), /*#__PURE__*/React__default["default"].createElement(PickerView$1, {
13636
13665
  ref: pickerViewRef,
13637
13666
  data: data,
13638
13667
  cascade: cascade,
@@ -13730,9 +13759,10 @@
13730
13759
  _e = props.typeArr,
13731
13760
  typeArr = _e === void 0 ? [] : _e,
13732
13761
  _f = props.minTs,
13733
- minTs = _f === void 0 ? initMinDate : _f,
13762
+ userSetMinTs = _f === void 0 ? initMinDate : _f,
13734
13763
  _g = props.maxTs,
13735
- maxTs = _g === void 0 ? initMaxDate : _g,
13764
+ userSetMaxTs = _g === void 0 ? initMaxDate : _g,
13765
+ rangeItemFormat = props.rangeItemFormat,
13736
13766
  _h = props.formatter,
13737
13767
  formatter = _h === void 0 ? defaultFormatter : _h,
13738
13768
  _j = props.valueFilter,
@@ -13743,18 +13773,41 @@
13743
13773
  touchToStop = props.touchToStop,
13744
13774
  _k = props.useUTC,
13745
13775
  useUTC = _k === void 0 ? false : _k,
13776
+ renderSeparator = props.renderSeparator,
13746
13777
  renderLinkedContainer = props.renderLinkedContainer,
13747
- otherProps = __rest$1(props, ["currentTs", "className", "visible", "onOk", "onChange", "onValueChange", "mode", "typeArr", "minTs", "maxTs", "formatter", "valueFilter", "columnsProcessor", "touchToStop", "useUTC", "renderLinkedContainer"]);
13778
+ otherProps = __rest$1(props, ["currentTs", "className", "visible", "onOk", "onChange", "onValueChange", "mode", "typeArr", "minTs", "maxTs", "rangeItemFormat", "formatter", "valueFilter", "columnsProcessor", "touchToStop", "useUTC", "renderSeparator", "renderLinkedContainer"]);
13779
+
13780
+ var isRange = typeof userSetCurrentTs !== 'number';
13781
+
13782
+ var _l = React.useState(userSetCurrentTs[0]),
13783
+ leftTimeValue = _l[0],
13784
+ setLeftTimeValue = _l[1];
13748
13785
 
13749
- var currentTs = Math.min(maxTs, Math.max(minTs, userSetCurrentTs));
13786
+ var _m = React.useState(userSetCurrentTs[1]),
13787
+ rightTimeValue = _m[0],
13788
+ setRightTimeValue = _m[1];
13750
13789
 
13751
- var _l = React.useState([[]]),
13752
- data = _l[0],
13753
- setData = _l[1];
13790
+ var _o = React.useState(0),
13791
+ activeTabIndex = _o[0],
13792
+ setActiveTabIndex = _o[1];
13754
13793
 
13755
- var _m = React.useState([]),
13756
- value = _m[0],
13757
- setValue = _m[1];
13794
+ var _p = React.useMemo(function () {
13795
+ return _updateTimeScope();
13796
+ }, [userSetMinTs, userSetMaxTs, activeTabIndex]),
13797
+ minTs = _p[0],
13798
+ maxTs = _p[1];
13799
+
13800
+ var _q = React.useState(isRange ? Math.min(maxTs, Math.max(minTs, userSetCurrentTs[0])) : Math.min(maxTs, Math.max(minTs, userSetCurrentTs))),
13801
+ currentTs = _q[0],
13802
+ setCurrentTs = _q[1];
13803
+
13804
+ var _r = React.useState([[]]),
13805
+ data = _r[0],
13806
+ setData = _r[1];
13807
+
13808
+ var _s = React.useState([]),
13809
+ value = _s[0],
13810
+ setValue = _s[1];
13758
13811
 
13759
13812
  var currentDateObjRef = React.useRef(_convertTsToDateObj(currentTs));
13760
13813
  var minDateObjRef = React.useRef(_convertTsToDateObj(minTs));
@@ -13762,7 +13815,37 @@
13762
13815
  var keyOptions = React.useMemo(function () {
13763
13816
  return _getKeyOptions();
13764
13817
  }, [mode, typeArr]);
13818
+ var leftTimeString = React.useMemo(function () {
13819
+ return _getRangeItemValue(leftTimeValue);
13820
+ }, [leftTimeValue]);
13821
+ var rightTimeString = React.useMemo(function () {
13822
+ return _getRangeItemValue(rightTimeValue);
13823
+ }, [rightTimeValue]);
13765
13824
  var pickerRef = React.useRef(null);
13825
+
13826
+ function _updateRangeValue(nowCurrentTs) {
13827
+ var leftMinTs = typeof userSetMinTs !== 'number' ? userSetMinTs.startTs : userSetMinTs;
13828
+ var rightMinTs = typeof userSetMinTs !== 'number' ? userSetMinTs.endTs : userSetMinTs;
13829
+ var leftMaxTs = typeof userSetMaxTs !== 'number' ? userSetMaxTs.startTs : userSetMaxTs;
13830
+ var rightMaxTs = typeof userSetMaxTs !== 'number' ? userSetMaxTs.endTs : userSetMaxTs;
13831
+
13832
+ if (isRange) {
13833
+ var leftTime = void 0,
13834
+ rightTime = void 0;
13835
+
13836
+ if (activeTabIndex === 0) {
13837
+ leftTime = nowCurrentTs;
13838
+ rightTime = Math.min(rightMaxTs, Math.max(Math.max(leftTime, rightMinTs), rightTimeValue));
13839
+ } else {
13840
+ rightTime = nowCurrentTs;
13841
+ leftTime = Math.min(leftMaxTs, Math.max(leftMinTs, leftTimeValue));
13842
+ }
13843
+
13844
+ setLeftTimeValue(leftTime);
13845
+ setRightTimeValue(rightTime);
13846
+ }
13847
+ }
13848
+
13766
13849
  React.useImperativeHandle(ref, function () {
13767
13850
  return {
13768
13851
  dom: pickerRef.current ? pickerRef.current.dom : null
@@ -13786,6 +13869,65 @@
13786
13869
  };
13787
13870
  }
13788
13871
 
13872
+ function _parseFormat(format, timeValue) {
13873
+ var year = timeValue.year,
13874
+ month = timeValue.month,
13875
+ date = timeValue.date,
13876
+ hour = timeValue.hour,
13877
+ minute = timeValue.minute,
13878
+ second = timeValue.second;
13879
+
13880
+ var padZero = function padZero(num, targetLength) {
13881
+ if (targetLength === void 0) {
13882
+ targetLength = 2;
13883
+ }
13884
+
13885
+ var str = "" + num;
13886
+
13887
+ while (str.length < targetLength) {
13888
+ str = "0" + str;
13889
+ }
13890
+
13891
+ return str;
13892
+ };
13893
+
13894
+ var replace = function replace(formatArg, str, num) {
13895
+ if (formatArg.includes(str)) {
13896
+ 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));
13897
+ }
13898
+
13899
+ return formatArg;
13900
+ };
13901
+
13902
+ return [['Y', year], ['M', month], ['D', date], ['H', hour], ['m', minute], ['s', second]].reduce(function (current, item) {
13903
+ return replace(current, item[0], item[1]);
13904
+ }, format);
13905
+ }
13906
+
13907
+ function _getRangeItemValue(time) {
13908
+ var timeValue = _convertTsToDateObj(time);
13909
+
13910
+ if (!isRange) {
13911
+ return;
13912
+ }
13913
+
13914
+ if (rangeItemFormat) {
13915
+ return _parseFormat(rangeItemFormat, timeValue);
13916
+ }
13917
+
13918
+ var format = function format(options, joinString) {
13919
+ return options.filter(function (option) {
13920
+ return keyOptions.includes(option);
13921
+ }).map(function (option) {
13922
+ return timeValue[option] < 10 ? "0" + timeValue[option] : "" + timeValue[option];
13923
+ }).join(joinString);
13924
+ };
13925
+
13926
+ var datePart = format(['year', 'month', 'date'], '/');
13927
+ var timePart = format(['hour', 'minute', 'second'], ':');
13928
+ return datePart + (datePart && timePart && ' ') + timePart;
13929
+ }
13930
+
13789
13931
  function _getSelectValue(columns) {
13790
13932
  var val = keyOptions.map(function (opt, index) {
13791
13933
  var _a;
@@ -13916,7 +14058,7 @@
13916
14058
 
13917
14059
  function _handlePickerChange(values, index) {
13918
14060
  var type = keyOptions[index];
13919
- var nowDateObj = {};
14061
+ var nowDateObj = currentDateObjRef.current;
13920
14062
  values.forEach(function (i, keyIndex) {
13921
14063
  nowDateObj[keyOptions[keyIndex]] = i;
13922
14064
  });
@@ -13944,18 +14086,35 @@
13944
14086
  setValue(val);
13945
14087
  }
13946
14088
 
14089
+ setCurrentTs(_convertObjToTs(nowDateObj, currentTs));
14090
+
13947
14091
  if (onValueChange) {
13948
14092
  onValueChange(_convertObjToTs(nowDateObj, currentTs), nowDateObj, index);
13949
14093
  }
13950
14094
  }
13951
14095
 
13952
14096
  function _handlePickerConfirm(values) {
13953
- var nowDateObj = {};
13954
- values.forEach(function (index, keyIndex) {
13955
- nowDateObj[keyOptions[keyIndex]] = index;
13956
- });
14097
+ var nowDateObj;
14098
+ var newTs;
13957
14099
 
13958
- var newTs = _convertObjToTs(nowDateObj, currentTs);
14100
+ if (isRange) {
14101
+ var leftTimeObj_1 = _convertTsToDateObj(leftTimeValue);
14102
+
14103
+ var rightTimeObj_1 = _convertTsToDateObj(rightTimeValue);
14104
+
14105
+ nowDateObj = keyOptions.reduce(function (arr, key) {
14106
+ arr[0][key] = leftTimeObj_1[key];
14107
+ arr[1][key] = rightTimeObj_1[key];
14108
+ return arr;
14109
+ }, [{}, {}]);
14110
+ newTs = [_convertObjToTs(nowDateObj[0], currentTs), _convertObjToTs(nowDateObj[1], currentTs)];
14111
+ } else {
14112
+ nowDateObj = {};
14113
+ values.forEach(function (index, keyIndex) {
14114
+ nowDateObj[keyOptions[keyIndex]] = index;
14115
+ });
14116
+ newTs = _convertObjToTs(nowDateObj, currentTs);
14117
+ }
13959
14118
 
13960
14119
  if (onOk) {
13961
14120
  onOk(newTs, nowDateObj);
@@ -13989,6 +14148,24 @@
13989
14148
  return options;
13990
14149
  }
13991
14150
 
14151
+ function _updateTimeScope(isLeft) {
14152
+ var nowMaxTs, nowMinTs;
14153
+
14154
+ if (isLeft || activeTabIndex === 0) {
14155
+ nowMaxTs = typeof userSetMaxTs === 'number' ? userSetMaxTs : userSetMaxTs.startTs;
14156
+ nowMinTs = Math.min(nowMaxTs, typeof userSetMinTs === 'number' ? userSetMinTs : userSetMinTs.startTs);
14157
+ } else {
14158
+ nowMinTs = Math.max(Math.min(typeof userSetMaxTs === 'number' ? userSetMaxTs : userSetMaxTs.startTs, leftTimeValue), typeof userSetMinTs === 'number' ? userSetMinTs : userSetMinTs.endTs);
14159
+ nowMaxTs = Math.max(nowMinTs, typeof userSetMaxTs === 'number' ? userSetMaxTs : userSetMaxTs.endTs);
14160
+ }
14161
+
14162
+ return [nowMinTs, nowMaxTs];
14163
+ }
14164
+
14165
+ function _chooseTimeActive(index) {
14166
+ setActiveTabIndex(index);
14167
+ }
14168
+
13992
14169
  React.useEffect(function () {
13993
14170
  minDateObjRef.current = _convertTsToDateObj(minTs);
13994
14171
  currentDateObjRef.current = _convertTsToDateObj(currentTs);
@@ -13996,9 +14173,45 @@
13996
14173
 
13997
14174
  _initData();
13998
14175
  }, [currentTs, minTs, maxTs, useUTC]);
14176
+ React.useEffect(function () {
14177
+ var nowCurrentTs;
14178
+
14179
+ if (isRange) {
14180
+ nowCurrentTs = Math.min(maxTs, Math.max(minTs, activeTabIndex === 0 ? leftTimeValue : rightTimeValue));
14181
+
14182
+ if (currentTs === nowCurrentTs) {
14183
+ _updateRangeValue(currentTs);
14184
+ }
14185
+ } else {
14186
+ nowCurrentTs = Math.min(maxTs, Math.max(minTs, currentTs));
14187
+ }
14188
+
14189
+ setCurrentTs(nowCurrentTs);
14190
+ }, [minTs, maxTs]);
14191
+ React.useEffect(function () {
14192
+ _updateRangeValue(currentTs);
14193
+ }, [currentTs]);
13999
14194
  React.useEffect(function () {
14000
14195
  if (visible) {
14001
- currentDateObjRef.current = _convertTsToDateObj(currentTs);
14196
+ // 初始化当前时间
14197
+ if (isRange) {
14198
+ setActiveTabIndex(0);
14199
+ setLeftTimeValue(userSetCurrentTs[0]);
14200
+ setRightTimeValue(userSetCurrentTs[1]);
14201
+
14202
+ var _a = _updateTimeScope(true),
14203
+ nowMinTs = _a[0],
14204
+ nowMaxTs = _a[1];
14205
+
14206
+ var nowCurrentTs = Math.min(nowMaxTs, Math.max(nowMinTs, userSetCurrentTs[0]));
14207
+ setCurrentTs(nowCurrentTs);
14208
+
14209
+ if (currentTs === nowCurrentTs) {
14210
+ _updateRangeValue(currentTs);
14211
+ }
14212
+ } else {
14213
+ setCurrentTs(Math.min(maxTs, Math.max(minTs, userSetCurrentTs)));
14214
+ }
14002
14215
 
14003
14216
  _initData();
14004
14217
  }
@@ -14015,6 +14228,23 @@
14015
14228
  onPickerChange: _handlePickerChange,
14016
14229
  onOk: _handlePickerConfirm,
14017
14230
  touchToStop: touchToStop,
14231
+ renderExtraHeader: isRange ? function () {
14232
+ return /*#__PURE__*/React__default["default"].createElement("div", {
14233
+ className: prefixCls + "-date-picker-show"
14234
+ }, /*#__PURE__*/React__default["default"].createElement("span", {
14235
+ className: cls("" + (activeTabIndex === 0 ? prefixCls + "-date-picker-range-item-active" : ''), prefixCls + "-date-picker-range-item"),
14236
+ onClick: function onClick() {
14237
+ return _chooseTimeActive(0);
14238
+ }
14239
+ }, leftTimeString), renderSeparator ? renderSeparator() : /*#__PURE__*/React__default["default"].createElement("span", {
14240
+ className: prefixCls + "-date-picker-show-separate"
14241
+ }, "~"), /*#__PURE__*/React__default["default"].createElement("span", {
14242
+ className: cls("" + (activeTabIndex === 1 ? prefixCls + "-date-picker-range-item-active" : ''), prefixCls + "-date-picker-range-item"),
14243
+ onClick: function onClick() {
14244
+ return _chooseTimeActive(1);
14245
+ }
14246
+ }, rightTimeString));
14247
+ } : undefined,
14018
14248
  renderLinkedContainer: renderLinkedContainer ? function () {
14019
14249
  return renderLinkedContainer(isEmptyValue(props.currentTs) ? undefined : currentTs, keyOptions);
14020
14250
  } : undefined
@@ -17920,7 +18150,11 @@
17920
18150
 
17921
18151
  var className = prefixCls + "-form-picker-link-container";
17922
18152
  var dateTimeStr = React.useMemo(function () {
17923
- return formatDateTimeStr(ts, types);
18153
+ if (typeof ts === 'number') {
18154
+ return formatDateTimeStr(ts, types);
18155
+ }
18156
+
18157
+ return formatDateTimeStr(ts[0], types) + " ~ " + formatDateTimeStr(ts[1], types);
17924
18158
  }, [ts, types]);
17925
18159
 
17926
18160
  function formatDateTimeStr(timestamp, itemTypes) {
@@ -26762,8 +26996,8 @@
26762
26996
  return /*#__PURE__*/React__default["default"].createElement("div", {
26763
26997
  key: index,
26764
26998
  className: searchBarAssociationPrefixCls + "-item",
26765
- onClick: function onClick() {
26766
- return onAssociationItemClick === null || onAssociationItemClick === void 0 ? void 0 : onAssociationItemClick(item, index);
26999
+ onClick: function onClick(e) {
27000
+ return onAssociationItemClick === null || onAssociationItemClick === void 0 ? void 0 : onAssociationItemClick(item, index, e);
26767
27001
  }
26768
27002
  }, node);
26769
27003
  };
@@ -28802,7 +29036,7 @@
28802
29036
  var tempValue = typeof updater === 'function' ? updater(innerValue) : updater;
28803
29037
 
28804
29038
  if (formatter) {
28805
- new Promise(function (resolve) {
29039
+ new es6Promise.Promise(function (resolve) {
28806
29040
  resolve(formatter(Number(tempValue)));
28807
29041
  }).then(function (result) {
28808
29042
  var res = Math.max(min, Math.min(max, result));