@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.
- package/CHANGELOG.md +29 -0
- package/README.en-US.md +2 -2
- package/README.md +2 -2
- package/cjs/_helpers/hooks.d.ts +10 -2
- package/cjs/_helpers/hooks.js +12 -5
- package/cjs/date-picker/index.js +218 -18
- package/cjs/date-picker/style/css/index.css +42 -0
- package/cjs/date-picker/style/index.less +38 -1
- package/cjs/date-picker/type.d.ts +22 -6
- package/cjs/form/linked-container.d.ts +2 -2
- package/cjs/form/linked-container.js +5 -1
- package/cjs/picker/index.js +3 -2
- package/cjs/picker/type.d.ts +5 -0
- package/cjs/pull-refresh/android-pull-refresh.js +5 -8
- package/cjs/pull-refresh/model.d.ts +1 -0
- package/cjs/search-bar/association.js +2 -2
- package/cjs/search-bar/type.d.ts +1 -1
- package/cjs/stepper/hooks/useValue.js +3 -1
- package/cjs/tabs/index.js +1 -1
- package/cjs/tabs/type.d.ts +2 -2
- package/dist/index.js +275 -46
- package/dist/index.min.js +4 -4
- package/dist/style.css +23 -0
- package/dist/style.min.css +1 -1
- package/esm/_helpers/hooks.d.ts +10 -2
- package/esm/_helpers/hooks.js +12 -5
- package/esm/date-picker/index.js +218 -18
- package/esm/date-picker/style/css/index.css +42 -0
- package/esm/date-picker/style/index.less +38 -1
- package/esm/date-picker/type.d.ts +22 -6
- package/esm/form/linked-container.d.ts +2 -2
- package/esm/form/linked-container.js +5 -1
- package/esm/picker/index.js +3 -2
- package/esm/picker/type.d.ts +5 -0
- package/esm/pull-refresh/android-pull-refresh.js +3 -7
- package/esm/pull-refresh/model.d.ts +1 -0
- package/esm/search-bar/association.js +2 -2
- package/esm/search-bar/type.d.ts +1 -1
- package/esm/stepper/hooks/useValue.js +1 -0
- package/esm/tabs/index.js +1 -1
- package/esm/tabs/type.d.ts +2 -2
- package/esnext/_helpers/hooks.d.ts +10 -2
- package/esnext/_helpers/hooks.js +12 -5
- package/esnext/date-picker/index.js +167 -10
- package/esnext/date-picker/style/css/index.css +42 -0
- package/esnext/date-picker/style/index.less +38 -1
- package/esnext/date-picker/type.d.ts +22 -6
- package/esnext/form/linked-container.d.ts +2 -2
- package/esnext/form/linked-container.js +7 -2
- package/esnext/picker/index.js +2 -1
- package/esnext/picker/type.d.ts +5 -0
- package/esnext/pull-refresh/android-pull-refresh.js +5 -6
- package/esnext/pull-refresh/model.d.ts +1 -0
- package/esnext/search-bar/association.js +1 -1
- package/esnext/search-bar/type.d.ts +1 -1
- package/esnext/stepper/hooks/useValue.js +1 -0
- package/esnext/tabs/index.js +1 -1
- package/esnext/tabs/type.d.ts +2 -2
- package/package.json +3 -3
- package/tokens/app/arcodesign/default/css-variables.less +10 -0
- package/tokens/app/arcodesign/default/index.d.ts +10 -0
- package/tokens/app/arcodesign/default/index.js +11 -1
- package/tokens/app/arcodesign/default/index.json +108 -0
- package/tokens/app/arcodesign/default/index.less +10 -0
- package/umd/_helpers/hooks.d.ts +10 -2
- package/umd/_helpers/hooks.js +12 -5
- package/umd/date-picker/index.js +218 -18
- package/umd/date-picker/style/css/index.css +42 -0
- package/umd/date-picker/style/index.less +38 -1
- package/umd/date-picker/type.d.ts +22 -6
- package/umd/form/linked-container.d.ts +2 -2
- package/umd/form/linked-container.js +5 -1
- package/umd/picker/index.js +3 -2
- package/umd/picker/type.d.ts +5 -0
- package/umd/pull-refresh/android-pull-refresh.js +7 -12
- package/umd/pull-refresh/model.d.ts +1 -0
- package/umd/search-bar/association.js +2 -2
- package/umd/search-bar/type.d.ts +1 -1
- package/umd/stepper/hooks/useValue.js +5 -5
- package/umd/tabs/index.js +1 -1
- package/umd/tabs/type.d.ts +2 -2
package/esm/_helpers/hooks.d.ts
CHANGED
@@ -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
|
-
* @
|
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
|
package/esm/_helpers/hooks.js
CHANGED
@@ -245,28 +245,35 @@ export function useLatestRef(variable) {
|
|
245
245
|
/**
|
246
246
|
* 从navigator.userAgent中获取当前操作系统,如果无法获取ua,则从ContextProvider传入的system中获取值
|
247
247
|
* @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
|
248
|
-
* @
|
248
|
+
* @param options 配置选项
|
249
|
+
* @param {en} options Configuration options
|
250
|
+
* @param options.detectHarmony 是否识别鸿蒙系统,默认为 false,鸿蒙系统会被识别为 android
|
251
|
+
* @param {en} options.detectHarmony Whether to detect HarmonyOS separately, default is false, HarmonyOS will be recognized as android
|
252
|
+
* @returns 返回当前设备的操作系统,可能的值包括 'android'、'ios'、'harmony' 或 'pc',如果无法获取,则返回空字符串
|
253
|
+
* @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
|
249
254
|
* @example
|
250
255
|
* ```
|
251
256
|
* import { useSystem } from '@arco-design/mobile-react/esm/_helpers/hooks';
|
252
257
|
*
|
253
258
|
* const system = useSystem();
|
259
|
+
* // Or with options
|
260
|
+
* const systemWithHarmony = useSystem({ detectHarmony: true });
|
254
261
|
* ```
|
255
262
|
*/
|
256
263
|
|
257
|
-
export function useSystem() {
|
264
|
+
export function useSystem(options) {
|
258
265
|
var _useContext = useContext(GlobalContext),
|
259
266
|
currentSystem = _useContext.system;
|
260
267
|
|
261
268
|
var _useState5 = useState(function () {
|
262
|
-
return currentSystem || getSystem();
|
269
|
+
return currentSystem || getSystem(options);
|
263
270
|
}),
|
264
271
|
system = _useState5[0],
|
265
272
|
setSystem = _useState5[1];
|
266
273
|
|
267
274
|
useEffect(function () {
|
268
|
-
setSystem(currentSystem || getSystem());
|
269
|
-
}, [currentSystem]);
|
275
|
+
setSystem(currentSystem || getSystem(options));
|
276
|
+
}, [currentSystem, options]);
|
270
277
|
return system;
|
271
278
|
}
|
272
279
|
/**
|
package/esm/date-picker/index.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
|
3
|
-
var _excluded = ["currentTs", "className", "visible", "onOk", "onChange", "onValueChange", "mode", "typeArr", "minTs", "maxTs", "formatter", "valueFilter", "columnsProcessor", "touchToStop", "useUTC", "renderLinkedContainer"];
|
3
|
+
var _excluded = ["currentTs", "className", "visible", "onOk", "onChange", "onValueChange", "mode", "typeArr", "minTs", "maxTs", "rangeItemFormat", "formatter", "valueFilter", "columnsProcessor", "touchToStop", "useUTC", "renderSeparator", "renderLinkedContainer"];
|
4
4
|
import React, { useEffect, useRef, useState, useMemo, forwardRef, useImperativeHandle } from 'react';
|
5
5
|
import { cls, componentWrapper, formatDateNumber, isEmptyValue } from '@arco-design/mobile-utils';
|
6
6
|
import Picker from '../picker';
|
@@ -28,9 +28,10 @@ var DatePicker = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
28
28
|
_props$typeArr = props.typeArr,
|
29
29
|
typeArr = _props$typeArr === void 0 ? [] : _props$typeArr,
|
30
30
|
_props$minTs = props.minTs,
|
31
|
-
|
31
|
+
userSetMinTs = _props$minTs === void 0 ? initMinDate : _props$minTs,
|
32
32
|
_props$maxTs = props.maxTs,
|
33
|
-
|
33
|
+
userSetMaxTs = _props$maxTs === void 0 ? initMaxDate : _props$maxTs,
|
34
|
+
rangeItemFormat = props.rangeItemFormat,
|
34
35
|
_props$formatter = props.formatter,
|
35
36
|
formatter = _props$formatter === void 0 ? defaultFormatter : _props$formatter,
|
36
37
|
_props$valueFilter = props.valueFilter,
|
@@ -41,18 +42,41 @@ var DatePicker = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
41
42
|
touchToStop = props.touchToStop,
|
42
43
|
_props$useUTC = props.useUTC,
|
43
44
|
useUTC = _props$useUTC === void 0 ? false : _props$useUTC,
|
45
|
+
renderSeparator = props.renderSeparator,
|
44
46
|
renderLinkedContainer = props.renderLinkedContainer,
|
45
47
|
otherProps = _objectWithoutPropertiesLoose(props, _excluded);
|
46
48
|
|
47
|
-
var
|
49
|
+
var isRange = typeof userSetCurrentTs !== 'number';
|
48
50
|
|
49
|
-
var _useState = useState([
|
50
|
-
|
51
|
-
|
51
|
+
var _useState = useState(userSetCurrentTs[0]),
|
52
|
+
leftTimeValue = _useState[0],
|
53
|
+
setLeftTimeValue = _useState[1];
|
52
54
|
|
53
|
-
var _useState2 = useState([]),
|
54
|
-
|
55
|
-
|
55
|
+
var _useState2 = useState(userSetCurrentTs[1]),
|
56
|
+
rightTimeValue = _useState2[0],
|
57
|
+
setRightTimeValue = _useState2[1];
|
58
|
+
|
59
|
+
var _useState3 = useState(0),
|
60
|
+
activeTabIndex = _useState3[0],
|
61
|
+
setActiveTabIndex = _useState3[1];
|
62
|
+
|
63
|
+
var _useMemo = useMemo(function () {
|
64
|
+
return _updateTimeScope();
|
65
|
+
}, [userSetMinTs, userSetMaxTs, activeTabIndex]),
|
66
|
+
minTs = _useMemo[0],
|
67
|
+
maxTs = _useMemo[1];
|
68
|
+
|
69
|
+
var _useState4 = useState(isRange ? Math.min(maxTs, Math.max(minTs, userSetCurrentTs[0])) : Math.min(maxTs, Math.max(minTs, userSetCurrentTs))),
|
70
|
+
currentTs = _useState4[0],
|
71
|
+
setCurrentTs = _useState4[1];
|
72
|
+
|
73
|
+
var _useState5 = useState([[]]),
|
74
|
+
data = _useState5[0],
|
75
|
+
setData = _useState5[1];
|
76
|
+
|
77
|
+
var _useState6 = useState([]),
|
78
|
+
value = _useState6[0],
|
79
|
+
setValue = _useState6[1];
|
56
80
|
|
57
81
|
var currentDateObjRef = useRef(_convertTsToDateObj(currentTs));
|
58
82
|
var minDateObjRef = useRef(_convertTsToDateObj(minTs));
|
@@ -60,7 +84,36 @@ var DatePicker = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
60
84
|
var keyOptions = useMemo(function () {
|
61
85
|
return _getKeyOptions();
|
62
86
|
}, [mode, typeArr]);
|
87
|
+
var leftTimeString = useMemo(function () {
|
88
|
+
return _getRangeItemValue(leftTimeValue);
|
89
|
+
}, [leftTimeValue]);
|
90
|
+
var rightTimeString = useMemo(function () {
|
91
|
+
return _getRangeItemValue(rightTimeValue);
|
92
|
+
}, [rightTimeValue]);
|
63
93
|
var pickerRef = useRef(null);
|
94
|
+
|
95
|
+
function _updateRangeValue(nowCurrentTs) {
|
96
|
+
var leftMinTs = typeof userSetMinTs !== 'number' ? userSetMinTs.startTs : userSetMinTs;
|
97
|
+
var rightMinTs = typeof userSetMinTs !== 'number' ? userSetMinTs.endTs : userSetMinTs;
|
98
|
+
var leftMaxTs = typeof userSetMaxTs !== 'number' ? userSetMaxTs.startTs : userSetMaxTs;
|
99
|
+
var rightMaxTs = typeof userSetMaxTs !== 'number' ? userSetMaxTs.endTs : userSetMaxTs;
|
100
|
+
|
101
|
+
if (isRange) {
|
102
|
+
var leftTime, rightTime;
|
103
|
+
|
104
|
+
if (activeTabIndex === 0) {
|
105
|
+
leftTime = nowCurrentTs;
|
106
|
+
rightTime = Math.min(rightMaxTs, Math.max(Math.max(leftTime, rightMinTs), rightTimeValue));
|
107
|
+
} else {
|
108
|
+
rightTime = nowCurrentTs;
|
109
|
+
leftTime = Math.min(leftMaxTs, Math.max(leftMinTs, leftTimeValue));
|
110
|
+
}
|
111
|
+
|
112
|
+
setLeftTimeValue(leftTime);
|
113
|
+
setRightTimeValue(rightTime);
|
114
|
+
}
|
115
|
+
}
|
116
|
+
|
64
117
|
useImperativeHandle(ref, function () {
|
65
118
|
return {
|
66
119
|
dom: pickerRef.current ? pickerRef.current.dom : null
|
@@ -84,6 +137,65 @@ var DatePicker = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
84
137
|
};
|
85
138
|
}
|
86
139
|
|
140
|
+
function _parseFormat(format, timeValue) {
|
141
|
+
var year = timeValue.year,
|
142
|
+
month = timeValue.month,
|
143
|
+
date = timeValue.date,
|
144
|
+
hour = timeValue.hour,
|
145
|
+
minute = timeValue.minute,
|
146
|
+
second = timeValue.second;
|
147
|
+
|
148
|
+
var padZero = function padZero(num, targetLength) {
|
149
|
+
if (targetLength === void 0) {
|
150
|
+
targetLength = 2;
|
151
|
+
}
|
152
|
+
|
153
|
+
var str = "" + num;
|
154
|
+
|
155
|
+
while (str.length < targetLength) {
|
156
|
+
str = "0" + str;
|
157
|
+
}
|
158
|
+
|
159
|
+
return str;
|
160
|
+
};
|
161
|
+
|
162
|
+
var replace = function replace(formatArg, str, num) {
|
163
|
+
if (formatArg.includes(str)) {
|
164
|
+
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));
|
165
|
+
}
|
166
|
+
|
167
|
+
return formatArg;
|
168
|
+
};
|
169
|
+
|
170
|
+
return [['Y', year], ['M', month], ['D', date], ['H', hour], ['m', minute], ['s', second]].reduce(function (current, item) {
|
171
|
+
return replace(current, item[0], item[1]);
|
172
|
+
}, format);
|
173
|
+
}
|
174
|
+
|
175
|
+
function _getRangeItemValue(time) {
|
176
|
+
var timeValue = _convertTsToDateObj(time);
|
177
|
+
|
178
|
+
if (!isRange) {
|
179
|
+
return;
|
180
|
+
}
|
181
|
+
|
182
|
+
if (rangeItemFormat) {
|
183
|
+
return _parseFormat(rangeItemFormat, timeValue);
|
184
|
+
}
|
185
|
+
|
186
|
+
var format = function format(options, joinString) {
|
187
|
+
return options.filter(function (option) {
|
188
|
+
return keyOptions.includes(option);
|
189
|
+
}).map(function (option) {
|
190
|
+
return timeValue[option] < 10 ? "0" + timeValue[option] : "" + timeValue[option];
|
191
|
+
}).join(joinString);
|
192
|
+
};
|
193
|
+
|
194
|
+
var datePart = format(['year', 'month', 'date'], '/');
|
195
|
+
var timePart = format(['hour', 'minute', 'second'], ':');
|
196
|
+
return datePart + (datePart && timePart && ' ') + timePart;
|
197
|
+
}
|
198
|
+
|
87
199
|
function _getSelectValue(columns) {
|
88
200
|
var val = keyOptions.map(function (opt, index) {
|
89
201
|
var _curCol$Math$max;
|
@@ -217,7 +329,7 @@ var DatePicker = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
217
329
|
|
218
330
|
function _handlePickerChange(values, index) {
|
219
331
|
var type = keyOptions[index];
|
220
|
-
var nowDateObj =
|
332
|
+
var nowDateObj = currentDateObjRef.current;
|
221
333
|
values.forEach(function (i, keyIndex) {
|
222
334
|
nowDateObj[keyOptions[keyIndex]] = i;
|
223
335
|
});
|
@@ -245,18 +357,35 @@ var DatePicker = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
245
357
|
setValue(val);
|
246
358
|
}
|
247
359
|
|
360
|
+
setCurrentTs(_convertObjToTs(nowDateObj, currentTs));
|
361
|
+
|
248
362
|
if (onValueChange) {
|
249
363
|
onValueChange(_convertObjToTs(nowDateObj, currentTs), nowDateObj, index);
|
250
364
|
}
|
251
365
|
}
|
252
366
|
|
253
367
|
function _handlePickerConfirm(values) {
|
254
|
-
var nowDateObj
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
368
|
+
var nowDateObj;
|
369
|
+
var newTs;
|
370
|
+
|
371
|
+
if (isRange) {
|
372
|
+
var leftTimeObj = _convertTsToDateObj(leftTimeValue);
|
373
|
+
|
374
|
+
var rightTimeObj = _convertTsToDateObj(rightTimeValue);
|
375
|
+
|
376
|
+
nowDateObj = keyOptions.reduce(function (arr, key) {
|
377
|
+
arr[0][key] = leftTimeObj[key];
|
378
|
+
arr[1][key] = rightTimeObj[key];
|
379
|
+
return arr;
|
380
|
+
}, [{}, {}]);
|
381
|
+
newTs = [_convertObjToTs(nowDateObj[0], currentTs), _convertObjToTs(nowDateObj[1], currentTs)];
|
382
|
+
} else {
|
383
|
+
nowDateObj = {};
|
384
|
+
values.forEach(function (index, keyIndex) {
|
385
|
+
nowDateObj[keyOptions[keyIndex]] = index;
|
386
|
+
});
|
387
|
+
newTs = _convertObjToTs(nowDateObj, currentTs);
|
388
|
+
}
|
260
389
|
|
261
390
|
if (onOk) {
|
262
391
|
onOk(newTs, nowDateObj);
|
@@ -290,6 +419,24 @@ var DatePicker = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
290
419
|
return options;
|
291
420
|
}
|
292
421
|
|
422
|
+
function _updateTimeScope(isLeft) {
|
423
|
+
var nowMaxTs, nowMinTs;
|
424
|
+
|
425
|
+
if (isLeft || activeTabIndex === 0) {
|
426
|
+
nowMaxTs = typeof userSetMaxTs === 'number' ? userSetMaxTs : userSetMaxTs.startTs;
|
427
|
+
nowMinTs = Math.min(nowMaxTs, typeof userSetMinTs === 'number' ? userSetMinTs : userSetMinTs.startTs);
|
428
|
+
} else {
|
429
|
+
nowMinTs = Math.max(Math.min(typeof userSetMaxTs === 'number' ? userSetMaxTs : userSetMaxTs.startTs, leftTimeValue), typeof userSetMinTs === 'number' ? userSetMinTs : userSetMinTs.endTs);
|
430
|
+
nowMaxTs = Math.max(nowMinTs, typeof userSetMaxTs === 'number' ? userSetMaxTs : userSetMaxTs.endTs);
|
431
|
+
}
|
432
|
+
|
433
|
+
return [nowMinTs, nowMaxTs];
|
434
|
+
}
|
435
|
+
|
436
|
+
function _chooseTimeActive(index) {
|
437
|
+
setActiveTabIndex(index);
|
438
|
+
}
|
439
|
+
|
293
440
|
useEffect(function () {
|
294
441
|
minDateObjRef.current = _convertTsToDateObj(minTs);
|
295
442
|
currentDateObjRef.current = _convertTsToDateObj(currentTs);
|
@@ -297,9 +444,45 @@ var DatePicker = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
297
444
|
|
298
445
|
_initData();
|
299
446
|
}, [currentTs, minTs, maxTs, useUTC]);
|
447
|
+
useEffect(function () {
|
448
|
+
var nowCurrentTs;
|
449
|
+
|
450
|
+
if (isRange) {
|
451
|
+
nowCurrentTs = Math.min(maxTs, Math.max(minTs, activeTabIndex === 0 ? leftTimeValue : rightTimeValue));
|
452
|
+
|
453
|
+
if (currentTs === nowCurrentTs) {
|
454
|
+
_updateRangeValue(currentTs);
|
455
|
+
}
|
456
|
+
} else {
|
457
|
+
nowCurrentTs = Math.min(maxTs, Math.max(minTs, currentTs));
|
458
|
+
}
|
459
|
+
|
460
|
+
setCurrentTs(nowCurrentTs);
|
461
|
+
}, [minTs, maxTs]);
|
462
|
+
useEffect(function () {
|
463
|
+
_updateRangeValue(currentTs);
|
464
|
+
}, [currentTs]);
|
300
465
|
useEffect(function () {
|
301
466
|
if (visible) {
|
302
|
-
|
467
|
+
// 初始化当前时间
|
468
|
+
if (isRange) {
|
469
|
+
setActiveTabIndex(0);
|
470
|
+
setLeftTimeValue(userSetCurrentTs[0]);
|
471
|
+
setRightTimeValue(userSetCurrentTs[1]);
|
472
|
+
|
473
|
+
var _updateTimeScope2 = _updateTimeScope(true),
|
474
|
+
nowMinTs = _updateTimeScope2[0],
|
475
|
+
nowMaxTs = _updateTimeScope2[1];
|
476
|
+
|
477
|
+
var nowCurrentTs = Math.min(nowMaxTs, Math.max(nowMinTs, userSetCurrentTs[0]));
|
478
|
+
setCurrentTs(nowCurrentTs);
|
479
|
+
|
480
|
+
if (currentTs === nowCurrentTs) {
|
481
|
+
_updateRangeValue(currentTs);
|
482
|
+
}
|
483
|
+
} else {
|
484
|
+
setCurrentTs(Math.min(maxTs, Math.max(minTs, userSetCurrentTs)));
|
485
|
+
}
|
303
486
|
|
304
487
|
_initData();
|
305
488
|
}
|
@@ -316,6 +499,23 @@ var DatePicker = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
316
499
|
onPickerChange: _handlePickerChange,
|
317
500
|
onOk: _handlePickerConfirm,
|
318
501
|
touchToStop: touchToStop,
|
502
|
+
renderExtraHeader: isRange ? function () {
|
503
|
+
return /*#__PURE__*/React.createElement("div", {
|
504
|
+
className: prefixCls + "-date-picker-show"
|
505
|
+
}, /*#__PURE__*/React.createElement("span", {
|
506
|
+
className: cls("" + (activeTabIndex === 0 ? prefixCls + "-date-picker-range-item-active" : ''), prefixCls + "-date-picker-range-item"),
|
507
|
+
onClick: function onClick() {
|
508
|
+
return _chooseTimeActive(0);
|
509
|
+
}
|
510
|
+
}, leftTimeString), renderSeparator ? renderSeparator() : /*#__PURE__*/React.createElement("span", {
|
511
|
+
className: prefixCls + "-date-picker-show-separate"
|
512
|
+
}, "~"), /*#__PURE__*/React.createElement("span", {
|
513
|
+
className: cls("" + (activeTabIndex === 1 ? prefixCls + "-date-picker-range-item-active" : ''), prefixCls + "-date-picker-range-item"),
|
514
|
+
onClick: function onClick() {
|
515
|
+
return _chooseTimeActive(1);
|
516
|
+
}
|
517
|
+
}, rightTimeString));
|
518
|
+
} : undefined,
|
319
519
|
renderLinkedContainer: renderLinkedContainer ? function () {
|
320
520
|
return renderLinkedContainer(isEmptyValue(props.currentTs) ? undefined : currentTs, keyOptions);
|
321
521
|
} : 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;
|
@@ -27,7 +27,11 @@ export function DefaultDatePickerLinkedContainer(_ref2) {
|
|
27
27
|
|
28
28
|
var className = prefixCls + "-form-picker-link-container";
|
29
29
|
var dateTimeStr = useMemo(function () {
|
30
|
-
|
30
|
+
if (typeof ts === 'number') {
|
31
|
+
return formatDateTimeStr(ts, types);
|
32
|
+
}
|
33
|
+
|
34
|
+
return formatDateTimeStr(ts[0], types) + " ~ " + formatDateTimeStr(ts[1], types);
|
31
35
|
}, [ts, types]);
|
32
36
|
|
33
37
|
function formatDateTimeStr(timestamp, itemTypes) {
|
package/esm/picker/index.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
2
2
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
|
3
|
-
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"];
|
3
|
+
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"];
|
4
4
|
import React, { useEffect, useRef, forwardRef, useImperativeHandle, useState } from 'react';
|
5
5
|
import { cls, componentWrapper, nextTick } from '@arco-design/mobile-utils';
|
6
6
|
import { ContextLayout } from '../context-provider';
|
@@ -44,6 +44,7 @@ var Picker = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
44
44
|
_props$gestureOutOfCo = props.gestureOutOfControl,
|
45
45
|
gestureOutOfControl = _props$gestureOutOfCo === void 0 ? true : _props$gestureOutOfCo,
|
46
46
|
renderLinkedContainer = props.renderLinkedContainer,
|
47
|
+
renderExtraHeader = props.renderExtraHeader,
|
47
48
|
otherProps = _objectWithoutPropertiesLoose(props, _excluded);
|
48
49
|
|
49
50
|
var scrollValueRef = useLatestRef(value);
|
@@ -191,7 +192,7 @@ var Picker = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
191
192
|
}, title), /*#__PURE__*/React.createElement("div", {
|
192
193
|
className: prefixCls + "-picker-header-btn right",
|
193
194
|
onClick: handleConfirm
|
194
|
-
}, okText || (locale == null ? void 0 : locale.Picker.okText))), /*#__PURE__*/React.createElement(PickerView, {
|
195
|
+
}, okText || (locale == null ? void 0 : locale.Picker.okText))), renderExtraHeader && renderExtraHeader(), /*#__PURE__*/React.createElement(PickerView, {
|
195
196
|
ref: pickerViewRef,
|
196
197
|
data: data,
|
197
198
|
cascade: cascade,
|
package/esm/picker/type.d.ts
CHANGED
@@ -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
|
}
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
2
2
|
import React, { useRef, forwardRef, useCallback, useMemo, useContext, useEffect, useImperativeHandle } from 'react';
|
3
3
|
import { cls, nextTick, defaultLocale } from '@arco-design/mobile-utils';
|
4
|
+
import { Promise } from 'es6-promise';
|
4
5
|
import Loading from '../loading';
|
5
6
|
import { GlobalContext } from '../context-provider';
|
6
7
|
import { PullRefreshStatus } from './model';
|
@@ -104,8 +105,8 @@ export var PullRefresh = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
104
105
|
}, ms ? {
|
105
106
|
transition: "all " + ms / 1000 + "s"
|
106
107
|
} : {}));
|
107
|
-
setTimeout(function () {
|
108
|
-
callback
|
108
|
+
callback && setTimeout(function () {
|
109
|
+
callback();
|
109
110
|
}, ms);
|
110
111
|
};
|
111
112
|
|
@@ -132,11 +133,6 @@ export var PullRefresh = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
132
133
|
if (disabled || touchRef.current || loadingRef.current || !domRef.current) return;
|
133
134
|
if (!ifShouldHandle()) return;
|
134
135
|
setTouching(true);
|
135
|
-
|
136
|
-
if (domRef.current.scrollTop === 0) {
|
137
|
-
domRef.current.scrollTop = 1;
|
138
|
-
}
|
139
|
-
|
140
136
|
var _e$touches$ = e.touches[0],
|
141
137
|
pageX = _e$touches$.pageX,
|
142
138
|
pageY = _e$touches$.pageY;
|