@arco-design/mobile-react 2.35.2 → 2.36.1
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 +30 -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/ellipsis/components/js-ellipsis.js +3 -1
- 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/popover/hooks/usePosition.js +26 -8
- 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 +301 -47
- 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/ellipsis/components/js-ellipsis.js +3 -1
- 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/popover/hooks/usePosition.js +26 -8
- 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/ellipsis/components/js-ellipsis.js +2 -0
- 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/popover/hooks/usePosition.js +32 -12
- 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/ellipsis/components/js-ellipsis.js +3 -1
- 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/popover/hooks/usePosition.js +26 -8
- 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/umd/date-picker/index.js
CHANGED
@@ -30,7 +30,7 @@
|
|
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 @@
|
|
58
58
|
_props$typeArr = props.typeArr,
|
59
59
|
typeArr = _props$typeArr === void 0 ? [] : _props$typeArr,
|
60
60
|
_props$minTs = props.minTs,
|
61
|
-
|
61
|
+
userSetMinTs = _props$minTs === void 0 ? initMinDate : _props$minTs,
|
62
62
|
_props$maxTs = props.maxTs,
|
63
|
-
|
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 @@
|
|
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
|
78
|
+
var isRange = typeof userSetCurrentTs !== 'number';
|
77
79
|
|
78
|
-
var _useState = (0, _react.useState)([
|
79
|
-
|
80
|
-
|
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
|
-
|
84
|
-
|
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 @@
|
|
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 @@
|
|
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 @@
|
|
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 @@
|
|
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
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
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 @@
|
|
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 @@
|
|
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
|
-
|
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 @@
|
|
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
|
}
|
@@ -90,9 +90,11 @@
|
|
90
90
|
currentText += temp;
|
91
91
|
l = m;
|
92
92
|
}
|
93
|
-
} // Remove the
|
93
|
+
} // Remove the last character if it is orphaned high-surrogate characters (indicative of incomplete emoji).
|
94
94
|
|
95
95
|
|
96
|
+
currentText = currentText.replace(/[\uD800-\uDBFF]+$/, ''); // Remove the exclude char at the end of the content.
|
97
|
+
|
96
98
|
while (endExcludes && endExcludes.includes(currentText[currentText.length - 1])) {
|
97
99
|
currentText = currentText.slice(0, -1);
|
98
100
|
} // Callback after reflow.
|
@@ -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;
|
@@ -50,7 +50,11 @@
|
|
50
50
|
|
51
51
|
var className = prefixCls + "-form-picker-link-container";
|
52
52
|
var dateTimeStr = (0, _react.useMemo)(function () {
|
53
|
-
|
53
|
+
if (typeof ts === 'number') {
|
54
|
+
return formatDateTimeStr(ts, types);
|
55
|
+
}
|
56
|
+
|
57
|
+
return formatDateTimeStr(ts[0], types) + " ~ " + formatDateTimeStr(ts[1], types);
|
54
58
|
}, [ts, types]);
|
55
59
|
|
56
60
|
function formatDateTimeStr(timestamp, itemTypes) {
|
package/umd/picker/index.js
CHANGED
@@ -36,7 +36,7 @@
|
|
36
36
|
if (key in _exports && _exports[key] === _type[key]) return;
|
37
37
|
_exports[key] = _type[key];
|
38
38
|
});
|
39
|
-
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"];
|
39
|
+
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"];
|
40
40
|
|
41
41
|
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); }
|
42
42
|
|
@@ -77,6 +77,7 @@
|
|
77
77
|
_props$gestureOutOfCo = props.gestureOutOfControl,
|
78
78
|
gestureOutOfControl = _props$gestureOutOfCo === void 0 ? true : _props$gestureOutOfCo,
|
79
79
|
renderLinkedContainer = props.renderLinkedContainer,
|
80
|
+
renderExtraHeader = props.renderExtraHeader,
|
80
81
|
otherProps = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded);
|
81
82
|
var scrollValueRef = (0, _helpers.useLatestRef)(value);
|
82
83
|
var domRef = (0, _react.useRef)(null);
|
@@ -223,7 +224,7 @@
|
|
223
224
|
}, title), /*#__PURE__*/_react.default.createElement("div", {
|
224
225
|
className: prefixCls + "-picker-header-btn right",
|
225
226
|
onClick: handleConfirm
|
226
|
-
}, okText || (locale == null ? void 0 : locale.Picker.okText))), /*#__PURE__*/_react.default.createElement(_pickerView.default, {
|
227
|
+
}, okText || (locale == null ? void 0 : locale.Picker.okText))), renderExtraHeader && renderExtraHeader(), /*#__PURE__*/_react.default.createElement(_pickerView.default, {
|
227
228
|
ref: pickerViewRef,
|
228
229
|
data: data,
|
229
230
|
cascade: cascade,
|
package/umd/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
|
}
|
@@ -239,20 +239,38 @@
|
|
239
239
|
|
240
240
|
|
241
241
|
if (verticalAuto) {
|
242
|
-
var
|
243
|
-
var popoverBottom = childRect.top + (newConfig.top && newConfig.height ? newConfig.top + newConfig.height : 0); // 顶部安全距离不够,调整到底部
|
244
|
-
// @en The top safety distance is not enough, adjust to the bottom
|
245
|
-
|
246
|
-
if (directionState.indexOf('top') !== -1 && popoverTop < topOffset) {
|
242
|
+
var setToBottom = function setToBottom() {
|
247
243
|
newConfig.top = verticalOffset + childRect.height;
|
248
244
|
newConfig.bottom = null;
|
249
245
|
onAdjustDirection('bottom');
|
250
|
-
}
|
251
|
-
|
252
|
-
|
246
|
+
};
|
247
|
+
|
248
|
+
var setToTop = function setToTop() {
|
253
249
|
newConfig.top = null;
|
254
250
|
newConfig.bottom = verticalOffset + childRect.height;
|
255
251
|
onAdjustDirection('top');
|
252
|
+
}; // 判断上下空间是否都不足以展示气泡内容
|
253
|
+
// @en Determine whether there is insufficient space both above and below to display content
|
254
|
+
|
255
|
+
|
256
|
+
var isPopoverTooTall = window.innerHeight - topOffset - bottomOffset < 2 * (newConfig.height || 0) + 2 * verticalOffset + childRect.height;
|
257
|
+
|
258
|
+
if (isPopoverTooTall) {
|
259
|
+
var spaceAbove = childRect.top;
|
260
|
+
var spaceBelow = window.innerHeight - childRect.bottom;
|
261
|
+
spaceAbove > spaceBelow ? setToTop() : setToBottom();
|
262
|
+
} else {
|
263
|
+
var popoverTop = childRect.bottom - (newConfig.bottom && newConfig.height ? newConfig.bottom + newConfig.height : 0);
|
264
|
+
var popoverBottom = childRect.top + (newConfig.top && newConfig.height ? newConfig.top + newConfig.height : 0); // 顶部安全距离不够,调整到底部
|
265
|
+
// @en The top safety distance is not enough, adjust to the bottom
|
266
|
+
|
267
|
+
if (directionState.indexOf('top') !== -1 && popoverTop < topOffset) {
|
268
|
+
setToBottom();
|
269
|
+
} else if ( // 底部安全距离不够,调整到顶部
|
270
|
+
// @en The bottom safety distance is not enough, adjust to the top
|
271
|
+
directionState.indexOf('bottom') !== -1 && popoverBottom + bottomOffset > window.innerHeight) {
|
272
|
+
setToTop();
|
273
|
+
}
|
256
274
|
}
|
257
275
|
} // 挂载在全局的气泡需要计算相对屏幕的位置
|
258
276
|
// @en Bubble mounted in the global needs to calculate the position relative to the screen
|
@@ -77,8 +77,8 @@
|
|
77
77
|
return /*#__PURE__*/_react.default.createElement("div", {
|
78
78
|
key: index,
|
79
79
|
className: searchBarAssociationPrefixCls + "-item",
|
80
|
-
onClick: function onClick() {
|
81
|
-
return onAssociationItemClick == null ? void 0 : onAssociationItemClick(item, index);
|
80
|
+
onClick: function onClick(e) {
|
81
|
+
return onAssociationItemClick == null ? void 0 : onAssociationItemClick(item, index, e);
|
82
82
|
}
|
83
83
|
}, node);
|
84
84
|
};
|
package/umd/search-bar/type.d.ts
CHANGED
@@ -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
|
@@ -1,16 +1,16 @@
|
|
1
1
|
(function (global, factory) {
|
2
2
|
if (typeof define === "function" && define.amd) {
|
3
|
-
define(["exports", "react"], factory);
|
3
|
+
define(["exports", "react", "es6-promise"], factory);
|
4
4
|
} else if (typeof exports !== "undefined") {
|
5
|
-
factory(exports, require("react"));
|
5
|
+
factory(exports, require("react"), require("es6-promise"));
|
6
6
|
} else {
|
7
7
|
var mod = {
|
8
8
|
exports: {}
|
9
9
|
};
|
10
|
-
factory(mod.exports, global.react);
|
10
|
+
factory(mod.exports, global.react, global.es6Promise);
|
11
11
|
global.useValue = mod.exports;
|
12
12
|
}
|
13
|
-
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _react) {
|
13
|
+
})(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports, _react, _es6Promise) {
|
14
14
|
"use strict";
|
15
15
|
|
16
16
|
_exports.__esModule = true;
|
@@ -32,7 +32,7 @@
|
|
32
32
|
var tempValue = typeof updater === 'function' ? updater(innerValue) : updater;
|
33
33
|
|
34
34
|
if (formatter) {
|
35
|
-
new Promise(function (resolve) {
|
35
|
+
new _es6Promise.Promise(function (resolve) {
|
36
36
|
resolve(formatter(Number(tempValue)));
|
37
37
|
}).then(function (result) {
|
38
38
|
var res = Math.max(min, Math.min(max, result));
|