@oceanbase/ui 0.4.18 → 0.4.20
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/dist/ui.min.css +1 -1
- package/dist/ui.min.js +1 -1
- package/es/DateRanger/PickerPanel.js +1 -1
- package/es/DateRanger/Ranger.d.ts +4 -0
- package/es/DateRanger/Ranger.js +158 -14
- package/es/DateRanger/constant/index.d.ts +1 -0
- package/es/DateRanger/constant/index.js +11 -1
- package/es/DateRanger/index.d.ts +1 -0
- package/es/DateRanger/index.js +2 -1
- package/es/DateRanger/index.less +23 -0
- package/es/ProTable/index.js +4 -1
- package/lib/DateRanger/PickerPanel.js +1 -1
- package/lib/DateRanger/Ranger.d.ts +4 -0
- package/lib/DateRanger/Ranger.js +134 -1
- package/lib/DateRanger/constant/index.d.ts +1 -0
- package/lib/DateRanger/constant/index.js +13 -1
- package/lib/DateRanger/index.d.ts +1 -0
- package/lib/DateRanger/index.js +1 -0
- package/lib/DateRanger/index.less +23 -0
- package/lib/ProTable/index.js +5 -1
- package/package.json +6 -7
|
@@ -119,7 +119,7 @@ var InternalPickerPanel = function InternalPickerPanel(props) {
|
|
|
119
119
|
var formatValues = _toConsumableArray(calendarValue).sort(function (a, b) {
|
|
120
120
|
return (a === null || a === void 0 ? void 0 : a.valueOf()) - (b === null || b === void 0 ? void 0 : b.valueOf());
|
|
121
121
|
}).map(function (item) {
|
|
122
|
-
return item.format(DATE_FORMAT);
|
|
122
|
+
return item === null || item === void 0 ? void 0 : item.format(DATE_FORMAT);
|
|
123
123
|
});
|
|
124
124
|
var _Form$useForm = Form.useForm(),
|
|
125
125
|
_Form$useForm2 = _slicedToArray(_Form$useForm, 1),
|
|
@@ -8,6 +8,7 @@ import type { Rule } from './PickerPanel';
|
|
|
8
8
|
import './index.less';
|
|
9
9
|
export type RangeName = 'customize' | string;
|
|
10
10
|
export type RangeValue = [Moment, Moment] | [Dayjs, Dayjs] | [] | null;
|
|
11
|
+
export type RangeValueFormat = [string, string] | [] | null;
|
|
11
12
|
export type RangeDateValue = {
|
|
12
13
|
name: RangeName;
|
|
13
14
|
range: RangeValue;
|
|
@@ -20,6 +21,9 @@ export interface DateRangerProps extends Omit<RangePickerProps, 'mode' | 'picker
|
|
|
20
21
|
hasSync?: boolean;
|
|
21
22
|
hasForward?: boolean;
|
|
22
23
|
hasZoomOut?: boolean;
|
|
24
|
+
history?: boolean | {
|
|
25
|
+
capacity: number;
|
|
26
|
+
};
|
|
23
27
|
hasTagInPicker?: boolean;
|
|
24
28
|
tip?: string;
|
|
25
29
|
rules?: Rule[];
|
package/es/DateRanger/Ranger.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
var _excluded = ["selects", "value", "defaultValue", "defaultQuickValue", "hasRewind", "hasPlay", "hasSync", "hasForward", "hasZoomOut", "hasTagInPicker", "pastOnly", "simpleMode", "hideYear", "hideSecond", "autoCalcRange", "onChange", "disabledDate", "locale", "size", "stickRangeName", "tooltipProps", "isMoment", "rules", "tip", "autoAdjustOverflow", "overlayClassName", "overlayStyle", "getPopupContainer"];
|
|
1
|
+
var _excluded = ["selects", "value", "defaultValue", "defaultQuickValue", "hasRewind", "hasPlay", "hasSync", "hasForward", "hasZoomOut", "hasTagInPicker", "pastOnly", "simpleMode", "hideYear", "hideSecond", "autoCalcRange", "history", "onChange", "disabledDate", "locale", "size", "stickRangeName", "tooltipProps", "isMoment", "rules", "tip", "autoAdjustOverflow", "overlayClassName", "overlayStyle", "getPopupContainer"];
|
|
3
2
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
4
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
@@ -9,6 +8,7 @@ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableTo
|
|
|
9
8
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
10
9
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
11
10
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
11
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
12
12
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
13
13
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
14
14
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
@@ -17,11 +17,11 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
|
|
|
17
17
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
18
18
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
19
19
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
20
|
-
import React, { useEffect, useState, useImperativeHandle,
|
|
21
|
-
import { Button, DatePicker, Divider, Dropdown, Radio, Space, Tooltip, theme } from '@oceanbase/design';
|
|
22
|
-
import { LeftOutlined, RightOutlined, ZoomOutOutlined, SyncOutlined } from '@oceanbase/icons';
|
|
20
|
+
import React, { useEffect, useRef, useState, useImperativeHandle, useMemo } from 'react';
|
|
21
|
+
import { Button, DatePicker, Divider, Dropdown, Flex, Menu, Radio, Space, Tooltip, message, theme } from '@oceanbase/design';
|
|
22
|
+
import { LeftOutlined, RightOutlined, ZoomOutOutlined, SyncOutlined, ArrowLeftOutlined, CopyOutlined, DeleteOutlined } from '@oceanbase/icons';
|
|
23
23
|
import dayjs from 'dayjs';
|
|
24
|
-
import { findIndex, isNil, noop, omit } from 'lodash';
|
|
24
|
+
import { findIndex, isEqual as _isEqual, isNil, noop, omit } from 'lodash';
|
|
25
25
|
import moment from 'moment';
|
|
26
26
|
import classNames from 'classnames';
|
|
27
27
|
import LocaleWrapper from "../locale/LocaleWrapper";
|
|
@@ -31,8 +31,10 @@ import InternalPickerPanel from "./PickerPanel";
|
|
|
31
31
|
import zhCN from "./locale/zh-CN";
|
|
32
32
|
import "./index.less";
|
|
33
33
|
import { useClickAway } from 'ahooks';
|
|
34
|
+
import { useLocalStorageState } from '@oceanbase/util';
|
|
34
35
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
35
36
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
37
|
+
var DefaultMaxHistoryCapacity = 20;
|
|
36
38
|
var prefix = getPrefix('date-ranger');
|
|
37
39
|
var Ranger = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
38
40
|
var _selects$;
|
|
@@ -63,6 +65,8 @@ var Ranger = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
63
65
|
hideSecond = _props$hideSecond === void 0 ? false : _props$hideSecond,
|
|
64
66
|
_props$autoCalcRange = props.autoCalcRange,
|
|
65
67
|
autoCalcRange = _props$autoCalcRange === void 0 ? false : _props$autoCalcRange,
|
|
68
|
+
_props$history = props.history,
|
|
69
|
+
historyProp = _props$history === void 0 ? false : _props$history,
|
|
66
70
|
_props$onChange = props.onChange,
|
|
67
71
|
onChange = _props$onChange === void 0 ? noop : _props$onChange,
|
|
68
72
|
disabledDate = props.disabledDate,
|
|
@@ -116,15 +120,59 @@ var Ranger = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
116
120
|
_useState10 = _slicedToArray(_useState9, 2),
|
|
117
121
|
backRadioFocused = _useState10[0],
|
|
118
122
|
setBackRadioFocused = _useState10[1];
|
|
123
|
+
var _useState11 = useState(false),
|
|
124
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
125
|
+
historyMenuVisible = _useState12[0],
|
|
126
|
+
setHistoryMenuVisible = _useState12[1];
|
|
119
127
|
var rangeRef = useRef(null);
|
|
120
128
|
var popRef = useRef(null);
|
|
121
129
|
var labelRef = useRef(null);
|
|
122
130
|
|
|
123
131
|
// 没有 selects 时,回退到普通 RangePicker, 当前时间选项为自定义时,应该显示 RangePicker
|
|
124
|
-
var
|
|
125
|
-
|
|
126
|
-
isPlay =
|
|
127
|
-
setIsPlay =
|
|
132
|
+
var _useState13 = useState(rangeName !== CUSTOMIZE),
|
|
133
|
+
_useState14 = _slicedToArray(_useState13, 2),
|
|
134
|
+
isPlay = _useState14[0],
|
|
135
|
+
setIsPlay = _useState14[1];
|
|
136
|
+
var history = useMemo(function () {
|
|
137
|
+
if (historyProp) {
|
|
138
|
+
return {
|
|
139
|
+
capacity: _typeof(historyProp) === 'object' ? historyProp.capacity : DefaultMaxHistoryCapacity
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
return false;
|
|
143
|
+
}, [historyProp]);
|
|
144
|
+
var _useLocalStorageState = useLocalStorageState('ob-design-date-ranger-local-storage-range-history-state', {
|
|
145
|
+
defaultValue: [],
|
|
146
|
+
listenStorageChange: true
|
|
147
|
+
}),
|
|
148
|
+
_useLocalStorageState2 = _slicedToArray(_useLocalStorageState, 2),
|
|
149
|
+
rangeHistory = _useLocalStorageState2[0],
|
|
150
|
+
setRangeHistory = _useLocalStorageState2[1];
|
|
151
|
+
var updateRangeHistory = function updateRangeHistory(range) {
|
|
152
|
+
if (!range) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
if (range.length < 2 || !history) {
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
var formattedValue = [range[0].format(YEAR_DATE_TIME_SECOND_FORMAT_CN), range[1].format(YEAR_DATE_TIME_SECOND_FORMAT_CN)];
|
|
159
|
+
if (rangeHistory.find(function (item) {
|
|
160
|
+
return _isEqual(item, formattedValue);
|
|
161
|
+
})) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
var updatedValue = [formattedValue].concat(_toConsumableArray(rangeHistory));
|
|
165
|
+
if (updatedValue.length > history.capacity) {
|
|
166
|
+
updatedValue.splice(0, history.capacity);
|
|
167
|
+
}
|
|
168
|
+
setRangeHistory(updatedValue);
|
|
169
|
+
};
|
|
170
|
+
var delRangeHistory = function delRangeHistory(range) {
|
|
171
|
+
var updatedValue = rangeHistory.filter(function (item) {
|
|
172
|
+
return !_isEqual(item, range);
|
|
173
|
+
});
|
|
174
|
+
setRangeHistory(updatedValue);
|
|
175
|
+
};
|
|
128
176
|
var compare = function compare(m1, m2) {
|
|
129
177
|
if (Array.isArray(m1) && !Array.isArray(m2)) return false;
|
|
130
178
|
if (Array.isArray(m2) && !Array.isArray(m1)) return false;
|
|
@@ -159,6 +207,7 @@ var Ranger = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
159
207
|
var rangeChange = function rangeChange(range) {
|
|
160
208
|
setInnerValue(range);
|
|
161
209
|
onChange(range);
|
|
210
|
+
updateRangeHistory(range);
|
|
162
211
|
};
|
|
163
212
|
var datePickerChange = function datePickerChange(range) {
|
|
164
213
|
rangeChange(range);
|
|
@@ -221,6 +270,9 @@ var Ranger = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
221
270
|
}
|
|
222
271
|
return isEN ? "Nearly ".concat(differenceSeconds, " seconds") : "\u8FD1 ".concat(differenceSeconds, " \u79D2");
|
|
223
272
|
};
|
|
273
|
+
var getHistoryTitle = function getHistoryTitle() {
|
|
274
|
+
return isEN ? 'History records' : '历史记录';
|
|
275
|
+
};
|
|
224
276
|
var setNow = function setNow() {
|
|
225
277
|
var selected = selects.find(function (item) {
|
|
226
278
|
return item.name === rangeName;
|
|
@@ -284,7 +336,99 @@ var Ranger = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
284
336
|
ref: popRef,
|
|
285
337
|
className: classNames("".concat(prefix, "-dropdown-picker"), overlayClassName),
|
|
286
338
|
style: overlayStyle,
|
|
287
|
-
children: [
|
|
339
|
+
children: [/*#__PURE__*/_jsxs(Flex, {
|
|
340
|
+
vertical: true,
|
|
341
|
+
justify: "space-between",
|
|
342
|
+
children: [!historyMenuVisible && /*#__PURE__*/_jsx("div", {
|
|
343
|
+
className: "options",
|
|
344
|
+
children: originNode
|
|
345
|
+
}), history && historyMenuVisible && /*#__PURE__*/_jsxs("div", {
|
|
346
|
+
className: "history",
|
|
347
|
+
children: [/*#__PURE__*/_jsxs(Button, {
|
|
348
|
+
type: "link",
|
|
349
|
+
style: {
|
|
350
|
+
paddingLeft: 8,
|
|
351
|
+
color: token.colorTextBase
|
|
352
|
+
},
|
|
353
|
+
onClick: function onClick(e) {
|
|
354
|
+
setHistoryMenuVisible(false);
|
|
355
|
+
e.stopPropagation();
|
|
356
|
+
},
|
|
357
|
+
children: [/*#__PURE__*/_jsx(ArrowLeftOutlined, {
|
|
358
|
+
color: token.colorTextLabel
|
|
359
|
+
}), getHistoryTitle()]
|
|
360
|
+
}), /*#__PURE__*/_jsx(Menu, {
|
|
361
|
+
onClick: function onClick(_ref4) {
|
|
362
|
+
var rangeString = _ref4.key;
|
|
363
|
+
var vList = rangeString.split(',').map(function (v) {
|
|
364
|
+
return v.trim();
|
|
365
|
+
});
|
|
366
|
+
rangeChange(vList.map(function (v) {
|
|
367
|
+
return isMoment ? moment(v) : dayjs(v);
|
|
368
|
+
}));
|
|
369
|
+
handleNameChange(CUSTOMIZE);
|
|
370
|
+
},
|
|
371
|
+
style: {
|
|
372
|
+
maxHeight: 480,
|
|
373
|
+
overflowY: 'auto'
|
|
374
|
+
},
|
|
375
|
+
items: rangeHistory.map(function (range) {
|
|
376
|
+
return {
|
|
377
|
+
key: String(range),
|
|
378
|
+
label: /*#__PURE__*/_jsxs(Flex, {
|
|
379
|
+
className: "".concat(prefix, "-history-menu-item"),
|
|
380
|
+
vertical: true,
|
|
381
|
+
children: [/*#__PURE__*/_jsxs("span", {
|
|
382
|
+
children: [(isMoment ? moment(range[0]) : dayjs(range[0])).format(YEAR_DATE_TIME_SECOND_FORMAT_CN), "~"]
|
|
383
|
+
}), /*#__PURE__*/_jsx("span", {
|
|
384
|
+
children: (isMoment ? moment(range[1]) : dayjs(range[1])).format(YEAR_DATE_TIME_SECOND_FORMAT_CN)
|
|
385
|
+
}), /*#__PURE__*/_jsxs(Space, {
|
|
386
|
+
className: "".concat(prefix, "-menu-text-btn-wrapper"),
|
|
387
|
+
children: [/*#__PURE__*/_jsx(Button, {
|
|
388
|
+
className: "".concat(prefix, "-menu-text-btn"),
|
|
389
|
+
type: "text",
|
|
390
|
+
color: "default",
|
|
391
|
+
variant: "filled",
|
|
392
|
+
size: "small",
|
|
393
|
+
onClick: function onClick(e) {
|
|
394
|
+
e.stopPropagation();
|
|
395
|
+
var vList = range.map(function (v) {
|
|
396
|
+
return v;
|
|
397
|
+
});
|
|
398
|
+
var text = "".concat(vList.join('~'));
|
|
399
|
+
navigator.clipboard.writeText(text);
|
|
400
|
+
message.success(text);
|
|
401
|
+
},
|
|
402
|
+
children: /*#__PURE__*/_jsx(CopyOutlined, {})
|
|
403
|
+
}), /*#__PURE__*/_jsx(Button, {
|
|
404
|
+
className: "".concat(prefix, "-menu-text-btn"),
|
|
405
|
+
type: "text",
|
|
406
|
+
color: "default",
|
|
407
|
+
variant: "filled",
|
|
408
|
+
size: "small",
|
|
409
|
+
onClick: function onClick(e) {
|
|
410
|
+
e.stopPropagation();
|
|
411
|
+
delRangeHistory(range);
|
|
412
|
+
},
|
|
413
|
+
children: /*#__PURE__*/_jsx(DeleteOutlined, {})
|
|
414
|
+
})]
|
|
415
|
+
})]
|
|
416
|
+
}, String(range))
|
|
417
|
+
};
|
|
418
|
+
})
|
|
419
|
+
})]
|
|
420
|
+
}), history && !historyMenuVisible && /*#__PURE__*/_jsxs(Button, {
|
|
421
|
+
type: "link",
|
|
422
|
+
style: {
|
|
423
|
+
width: 'max-content'
|
|
424
|
+
},
|
|
425
|
+
onClick: function onClick(e) {
|
|
426
|
+
setHistoryMenuVisible(true);
|
|
427
|
+
e.stopPropagation();
|
|
428
|
+
},
|
|
429
|
+
children: [getHistoryTitle(), /*#__PURE__*/_jsx(RightOutlined, {})]
|
|
430
|
+
})]
|
|
431
|
+
}), /*#__PURE__*/_jsx(Divider, {
|
|
288
432
|
type: "vertical",
|
|
289
433
|
style: {
|
|
290
434
|
height: 'auto',
|
|
@@ -317,9 +461,9 @@ var Ranger = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
317
461
|
menu: {
|
|
318
462
|
selectable: true,
|
|
319
463
|
defaultSelectedKeys: [rangeName],
|
|
320
|
-
onClick: function onClick(
|
|
321
|
-
var key =
|
|
322
|
-
domEvent =
|
|
464
|
+
onClick: function onClick(_ref5) {
|
|
465
|
+
var key = _ref5.key,
|
|
466
|
+
domEvent = _ref5.domEvent;
|
|
323
467
|
var selected = selects.find(function (_item) {
|
|
324
468
|
return _item.name === key;
|
|
325
469
|
});
|
|
@@ -25,6 +25,7 @@ export declare const YESTERDAY: RangeOption;
|
|
|
25
25
|
export declare const LAST_1_DAY: RangeOption;
|
|
26
26
|
export declare const LAST_3_DAYS: RangeOption;
|
|
27
27
|
export declare const LAST_7_DAYS: RangeOption;
|
|
28
|
+
export declare const LAST_30_DAYS: RangeOption;
|
|
28
29
|
export declare const THIS_WEEK: RangeOption;
|
|
29
30
|
export declare const LAST_WEEK: RangeOption;
|
|
30
31
|
export declare const THIS_MONTH: RangeOption;
|
|
@@ -169,6 +169,16 @@ export var LAST_7_DAYS = {
|
|
|
169
169
|
return [current.clone().subtract(7, 'days'), current.clone()];
|
|
170
170
|
}
|
|
171
171
|
};
|
|
172
|
+
export var LAST_30_DAYS = {
|
|
173
|
+
label: '近 30 天',
|
|
174
|
+
enLabel: 'Last 30 Days',
|
|
175
|
+
rangeLabel: '30d',
|
|
176
|
+
name: 'LAST_30_DAYS',
|
|
177
|
+
range: function range() {
|
|
178
|
+
var current = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : moment();
|
|
179
|
+
return [current.clone().subtract(30, 'days'), current.clone()];
|
|
180
|
+
}
|
|
181
|
+
};
|
|
172
182
|
export var THIS_WEEK = {
|
|
173
183
|
label: '近一周',
|
|
174
184
|
enLabel: 'Nearly a week',
|
|
@@ -182,7 +192,7 @@ export var THIS_WEEK = {
|
|
|
182
192
|
export var LAST_WEEK = {
|
|
183
193
|
label: '上周',
|
|
184
194
|
enLabel: 'Last week',
|
|
185
|
-
rangeLabel: '
|
|
195
|
+
rangeLabel: '1w',
|
|
186
196
|
name: 'LAST_WEEK',
|
|
187
197
|
range: function range() {
|
|
188
198
|
var current = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : moment();
|
package/es/DateRanger/index.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ declare const DateRanger: import("react").ForwardRefExoticComponent<import("./Ra
|
|
|
15
15
|
LAST_1_DAY: import("./typing").RangeOption;
|
|
16
16
|
LAST_3_DAYS: import("./typing").RangeOption;
|
|
17
17
|
LAST_7_DAYS: import("./typing").RangeOption;
|
|
18
|
+
LAST_30_DAYS: import("./typing").RangeOption;
|
|
18
19
|
YESTERDAY: import("./typing").RangeOption;
|
|
19
20
|
THIS_WEEK: import("./typing").RangeOption;
|
|
20
21
|
LAST_WEEK: import("./typing").RangeOption;
|
package/es/DateRanger/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LAST_1_DAY, LAST_3_DAYS, LAST_7_DAYS, LAST_MONTH, LAST_WEEK, LAST_YEAR, NEAR_10_MINUTES, NEAR_12_HOURS, NEAR_1_HOURS, NEAR_1_MINUTES, NEAR_20_MINUTES, NEAR_2_HOURS, NEAR_30_MINUTES, NEAR_3_HOURS, NEAR_5_MINUTES, NEAR_6_HOURS, NEXT_YEAR, THIS_MONTH, THIS_WEEK, THIS_YEAR, TODAY, YESTERDAY } from "./constant";
|
|
1
|
+
import { LAST_1_DAY, LAST_3_DAYS, LAST_7_DAYS, LAST_30_DAYS, LAST_MONTH, LAST_WEEK, LAST_YEAR, NEAR_10_MINUTES, NEAR_12_HOURS, NEAR_1_HOURS, NEAR_1_MINUTES, NEAR_20_MINUTES, NEAR_2_HOURS, NEAR_30_MINUTES, NEAR_3_HOURS, NEAR_5_MINUTES, NEAR_6_HOURS, NEXT_YEAR, THIS_MONTH, THIS_WEEK, THIS_YEAR, TODAY, YESTERDAY } from "./constant";
|
|
2
2
|
import InternalDateRanger from "./Ranger";
|
|
3
3
|
export * from "./Ranger";
|
|
4
4
|
var DateRanger = Object.assign(InternalDateRanger, {
|
|
@@ -16,6 +16,7 @@ var DateRanger = Object.assign(InternalDateRanger, {
|
|
|
16
16
|
LAST_1_DAY: LAST_1_DAY,
|
|
17
17
|
LAST_3_DAYS: LAST_3_DAYS,
|
|
18
18
|
LAST_7_DAYS: LAST_7_DAYS,
|
|
19
|
+
LAST_30_DAYS: LAST_30_DAYS,
|
|
19
20
|
YESTERDAY: YESTERDAY,
|
|
20
21
|
THIS_WEEK: THIS_WEEK,
|
|
21
22
|
LAST_WEEK: LAST_WEEK,
|
package/es/DateRanger/index.less
CHANGED
|
@@ -155,3 +155,26 @@
|
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
157
|
}
|
|
158
|
+
|
|
159
|
+
.@{prefix}-history-menu-item {
|
|
160
|
+
.@{prefix}-menu-text-btn-wrapper {
|
|
161
|
+
justify-content: space-between;
|
|
162
|
+
height: 0;
|
|
163
|
+
transition: height 0.2s;
|
|
164
|
+
overflow: hidden;
|
|
165
|
+
}
|
|
166
|
+
&:hover {
|
|
167
|
+
.@{prefix}-menu-text-btn-wrapper {
|
|
168
|
+
height: 22px;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.@{prefix}-menu-text-btn {
|
|
174
|
+
width: 72px;
|
|
175
|
+
|
|
176
|
+
background-color: @colorFillSecondary !important;
|
|
177
|
+
&:hover {
|
|
178
|
+
background-color: @colorFill !important;
|
|
179
|
+
}
|
|
180
|
+
}
|
package/es/ProTable/index.js
CHANGED
|
@@ -80,7 +80,10 @@ function ProTable(_ref) {
|
|
|
80
80
|
toolbar: toolbar,
|
|
81
81
|
toolBarRender: toolBarRender,
|
|
82
82
|
cardProps: _objectSpread(_objectSpread({}, cardProps), {}, {
|
|
83
|
-
className: classNames(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "".concat(proCardCls, "-has-title"), !!headerTitle || options || options === undefined || optionsRender || toolbar || toolBarRender), "".concat(proCardCls, "-no-divider"), !(cardProps !== null && cardProps !== void 0 && cardProps.headerBordered)), "".concat(proCardCls, "-no-padding"), true), "".concat(proCardCls, "-contain-tabs"), !!(cardProps !== null && cardProps !== void 0 && cardProps.tabs)), cardProps === null || cardProps === void 0 ? void 0 : cardProps.className)
|
|
83
|
+
className: classNames(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "".concat(proCardCls, "-has-title"), !!headerTitle || options || options === undefined || optionsRender || toolbar || toolBarRender), "".concat(proCardCls, "-no-divider"), !(cardProps !== null && cardProps !== void 0 && cardProps.headerBordered)), "".concat(proCardCls, "-no-padding"), true), "".concat(proCardCls, "-contain-tabs"), !!(cardProps !== null && cardProps !== void 0 && cardProps.tabs)), cardProps === null || cardProps === void 0 ? void 0 : cardProps.className),
|
|
84
|
+
bodyStyle: _objectSpread({
|
|
85
|
+
paddingBlock: 0
|
|
86
|
+
}, cardProps === null || cardProps === void 0 ? void 0 : cardProps.bodyStyle)
|
|
84
87
|
}),
|
|
85
88
|
expandable: expandable ? _objectSpread({
|
|
86
89
|
columnWidth: !size || size === 'large' ? 40 : 32
|
|
@@ -110,7 +110,7 @@ var InternalPickerPanel = (props) => {
|
|
|
110
110
|
const formatValues = [...calendarValue].sort((a, b) => {
|
|
111
111
|
return (a == null ? void 0 : a.valueOf()) - (b == null ? void 0 : b.valueOf());
|
|
112
112
|
}).map((item) => {
|
|
113
|
-
return item.format(DATE_FORMAT);
|
|
113
|
+
return item == null ? void 0 : item.format(DATE_FORMAT);
|
|
114
114
|
});
|
|
115
115
|
const [form] = import_design.Form.useForm();
|
|
116
116
|
const [_sDate, _eDate] = formatValues;
|
|
@@ -8,6 +8,7 @@ import type { Rule } from './PickerPanel';
|
|
|
8
8
|
import './index.less';
|
|
9
9
|
export type RangeName = 'customize' | string;
|
|
10
10
|
export type RangeValue = [Moment, Moment] | [Dayjs, Dayjs] | [] | null;
|
|
11
|
+
export type RangeValueFormat = [string, string] | [] | null;
|
|
11
12
|
export type RangeDateValue = {
|
|
12
13
|
name: RangeName;
|
|
13
14
|
range: RangeValue;
|
|
@@ -20,6 +21,9 @@ export interface DateRangerProps extends Omit<RangePickerProps, 'mode' | 'picker
|
|
|
20
21
|
hasSync?: boolean;
|
|
21
22
|
hasForward?: boolean;
|
|
22
23
|
hasZoomOut?: boolean;
|
|
24
|
+
history?: boolean | {
|
|
25
|
+
capacity: number;
|
|
26
|
+
};
|
|
23
27
|
hasTagInPicker?: boolean;
|
|
24
28
|
tip?: string;
|
|
25
29
|
rules?: Rule[];
|
package/lib/DateRanger/Ranger.js
CHANGED
|
@@ -46,6 +46,8 @@ var import_PickerPanel = __toESM(require("./PickerPanel"));
|
|
|
46
46
|
var import_zh_CN = __toESM(require("./locale/zh-CN"));
|
|
47
47
|
var import_index = require("./index.less");
|
|
48
48
|
var import_ahooks = require("ahooks");
|
|
49
|
+
var import_util2 = require("@oceanbase/util");
|
|
50
|
+
var DefaultMaxHistoryCapacity = 20;
|
|
49
51
|
var prefix = (0, import_util.getPrefix)("date-ranger");
|
|
50
52
|
var Ranger = import_react.default.forwardRef((props, ref) => {
|
|
51
53
|
var _a;
|
|
@@ -73,6 +75,7 @@ var Ranger = import_react.default.forwardRef((props, ref) => {
|
|
|
73
75
|
hideYear = false,
|
|
74
76
|
hideSecond = false,
|
|
75
77
|
autoCalcRange = false,
|
|
78
|
+
history: historyProp = false,
|
|
76
79
|
onChange = import_lodash.noop,
|
|
77
80
|
disabledDate,
|
|
78
81
|
locale,
|
|
@@ -106,10 +109,47 @@ var Ranger = import_react.default.forwardRef((props, ref) => {
|
|
|
106
109
|
const [open, setOpen] = (0, import_react.useState)(false);
|
|
107
110
|
const [tooltipOpen, setTooltipOpen] = (0, import_react.useState)(false);
|
|
108
111
|
const [backRadioFocused, setBackRadioFocused] = (0, import_react.useState)(false);
|
|
112
|
+
const [historyMenuVisible, setHistoryMenuVisible] = (0, import_react.useState)(false);
|
|
109
113
|
const rangeRef = (0, import_react.useRef)(null);
|
|
110
114
|
const popRef = (0, import_react.useRef)(null);
|
|
111
115
|
const labelRef = (0, import_react.useRef)(null);
|
|
112
116
|
const [isPlay, setIsPlay] = (0, import_react.useState)(rangeName !== import_constant.CUSTOMIZE);
|
|
117
|
+
const history = (0, import_react.useMemo)(() => {
|
|
118
|
+
if (historyProp) {
|
|
119
|
+
return {
|
|
120
|
+
capacity: typeof historyProp === "object" ? historyProp.capacity : DefaultMaxHistoryCapacity
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
return false;
|
|
124
|
+
}, [historyProp]);
|
|
125
|
+
const [rangeHistory, setRangeHistory] = (0, import_util2.useLocalStorageState)(
|
|
126
|
+
"ob-design-date-ranger-local-storage-range-history-state",
|
|
127
|
+
{ defaultValue: [], listenStorageChange: true }
|
|
128
|
+
);
|
|
129
|
+
const updateRangeHistory = (range) => {
|
|
130
|
+
if (!range) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
if (range.length < 2 || !history) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
const formattedValue = [
|
|
137
|
+
range[0].format(import_constant.YEAR_DATE_TIME_SECOND_FORMAT_CN),
|
|
138
|
+
range[1].format(import_constant.YEAR_DATE_TIME_SECOND_FORMAT_CN)
|
|
139
|
+
];
|
|
140
|
+
if (rangeHistory.find((item) => (0, import_lodash.isEqual)(item, formattedValue))) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
const updatedValue = [formattedValue, ...rangeHistory];
|
|
144
|
+
if (updatedValue.length > history.capacity) {
|
|
145
|
+
updatedValue.splice(0, history.capacity);
|
|
146
|
+
}
|
|
147
|
+
setRangeHistory(updatedValue);
|
|
148
|
+
};
|
|
149
|
+
const delRangeHistory = (range) => {
|
|
150
|
+
const updatedValue = rangeHistory.filter((item) => !(0, import_lodash.isEqual)(item, range));
|
|
151
|
+
setRangeHistory(updatedValue);
|
|
152
|
+
};
|
|
113
153
|
const compare = (m1, m2) => {
|
|
114
154
|
if (Array.isArray(m1) && !Array.isArray(m2))
|
|
115
155
|
return false;
|
|
@@ -151,6 +191,7 @@ var Ranger = import_react.default.forwardRef((props, ref) => {
|
|
|
151
191
|
const rangeChange = (range) => {
|
|
152
192
|
setInnerValue(range);
|
|
153
193
|
onChange(range);
|
|
194
|
+
updateRangeHistory(range);
|
|
154
195
|
};
|
|
155
196
|
const datePickerChange = (range) => {
|
|
156
197
|
rangeChange(range);
|
|
@@ -212,6 +253,9 @@ var Ranger = import_react.default.forwardRef((props, ref) => {
|
|
|
212
253
|
}
|
|
213
254
|
return isEN ? `Nearly ${differenceSeconds} seconds` : `近 ${differenceSeconds} 秒`;
|
|
214
255
|
};
|
|
256
|
+
const getHistoryTitle = () => {
|
|
257
|
+
return isEN ? "History records" : "历史记录";
|
|
258
|
+
};
|
|
215
259
|
const setNow = () => {
|
|
216
260
|
const selected = selects.find((item) => item.name === rangeName);
|
|
217
261
|
if (selected == null ? void 0 : selected.range) {
|
|
@@ -276,7 +320,96 @@ var Ranger = import_react.default.forwardRef((props, ref) => {
|
|
|
276
320
|
className: (0, import_classnames.default)(`${prefix}-dropdown-picker`, overlayClassName),
|
|
277
321
|
style: overlayStyle
|
|
278
322
|
},
|
|
279
|
-
originNode,
|
|
323
|
+
/* @__PURE__ */ import_react.default.createElement(import_design.Flex, { vertical: true, justify: "space-between" }, !historyMenuVisible && /* @__PURE__ */ import_react.default.createElement("div", { className: "options" }, originNode), history && historyMenuVisible && /* @__PURE__ */ import_react.default.createElement("div", { className: "history" }, /* @__PURE__ */ import_react.default.createElement(
|
|
324
|
+
import_design.Button,
|
|
325
|
+
{
|
|
326
|
+
type: "link",
|
|
327
|
+
style: { paddingLeft: 8, color: token.colorTextBase },
|
|
328
|
+
onClick: (e) => {
|
|
329
|
+
setHistoryMenuVisible(false);
|
|
330
|
+
e.stopPropagation();
|
|
331
|
+
}
|
|
332
|
+
},
|
|
333
|
+
/* @__PURE__ */ import_react.default.createElement(import_icons.ArrowLeftOutlined, { color: token.colorTextLabel }),
|
|
334
|
+
getHistoryTitle()
|
|
335
|
+
), /* @__PURE__ */ import_react.default.createElement(
|
|
336
|
+
import_design.Menu,
|
|
337
|
+
{
|
|
338
|
+
onClick: ({ key: rangeString }) => {
|
|
339
|
+
const vList = rangeString.split(",").map((v) => v.trim());
|
|
340
|
+
rangeChange(
|
|
341
|
+
vList.map((v) => {
|
|
342
|
+
return isMoment ? (0, import_moment.default)(v) : (0, import_dayjs.default)(v);
|
|
343
|
+
})
|
|
344
|
+
);
|
|
345
|
+
handleNameChange(import_constant.CUSTOMIZE);
|
|
346
|
+
},
|
|
347
|
+
style: { maxHeight: 480, overflowY: "auto" },
|
|
348
|
+
items: rangeHistory.map((range) => {
|
|
349
|
+
return {
|
|
350
|
+
key: String(range),
|
|
351
|
+
label: /* @__PURE__ */ import_react.default.createElement(
|
|
352
|
+
import_design.Flex,
|
|
353
|
+
{
|
|
354
|
+
className: `${prefix}-history-menu-item`,
|
|
355
|
+
key: String(range),
|
|
356
|
+
vertical: true
|
|
357
|
+
},
|
|
358
|
+
/* @__PURE__ */ import_react.default.createElement("span", null, (isMoment ? (0, import_moment.default)(range[0]) : (0, import_dayjs.default)(range[0])).format(
|
|
359
|
+
import_constant.YEAR_DATE_TIME_SECOND_FORMAT_CN
|
|
360
|
+
), "~"),
|
|
361
|
+
/* @__PURE__ */ import_react.default.createElement("span", null, (isMoment ? (0, import_moment.default)(range[1]) : (0, import_dayjs.default)(range[1])).format(
|
|
362
|
+
import_constant.YEAR_DATE_TIME_SECOND_FORMAT_CN
|
|
363
|
+
)),
|
|
364
|
+
/* @__PURE__ */ import_react.default.createElement(import_design.Space, { className: `${prefix}-menu-text-btn-wrapper` }, /* @__PURE__ */ import_react.default.createElement(
|
|
365
|
+
import_design.Button,
|
|
366
|
+
{
|
|
367
|
+
className: `${prefix}-menu-text-btn`,
|
|
368
|
+
type: "text",
|
|
369
|
+
color: "default",
|
|
370
|
+
variant: "filled",
|
|
371
|
+
size: "small",
|
|
372
|
+
onClick: (e) => {
|
|
373
|
+
e.stopPropagation();
|
|
374
|
+
const vList = range.map((v) => v);
|
|
375
|
+
const text = `${vList.join("~")}`;
|
|
376
|
+
navigator.clipboard.writeText(text);
|
|
377
|
+
import_design.message.success(text);
|
|
378
|
+
}
|
|
379
|
+
},
|
|
380
|
+
/* @__PURE__ */ import_react.default.createElement(import_icons.CopyOutlined, null)
|
|
381
|
+
), /* @__PURE__ */ import_react.default.createElement(
|
|
382
|
+
import_design.Button,
|
|
383
|
+
{
|
|
384
|
+
className: `${prefix}-menu-text-btn`,
|
|
385
|
+
type: "text",
|
|
386
|
+
color: "default",
|
|
387
|
+
variant: "filled",
|
|
388
|
+
size: "small",
|
|
389
|
+
onClick: (e) => {
|
|
390
|
+
e.stopPropagation();
|
|
391
|
+
delRangeHistory(range);
|
|
392
|
+
}
|
|
393
|
+
},
|
|
394
|
+
/* @__PURE__ */ import_react.default.createElement(import_icons.DeleteOutlined, null)
|
|
395
|
+
))
|
|
396
|
+
)
|
|
397
|
+
};
|
|
398
|
+
})
|
|
399
|
+
}
|
|
400
|
+
)), history && !historyMenuVisible && /* @__PURE__ */ import_react.default.createElement(
|
|
401
|
+
import_design.Button,
|
|
402
|
+
{
|
|
403
|
+
type: "link",
|
|
404
|
+
style: { width: "max-content" },
|
|
405
|
+
onClick: (e) => {
|
|
406
|
+
setHistoryMenuVisible(true);
|
|
407
|
+
e.stopPropagation();
|
|
408
|
+
}
|
|
409
|
+
},
|
|
410
|
+
getHistoryTitle(),
|
|
411
|
+
/* @__PURE__ */ import_react.default.createElement(import_icons.RightOutlined, null)
|
|
412
|
+
)),
|
|
280
413
|
/* @__PURE__ */ import_react.default.createElement(import_design.Divider, { type: "vertical", style: { height: "auto", margin: "0px 4px 0px 0px" } }),
|
|
281
414
|
/* @__PURE__ */ import_react.default.createElement(
|
|
282
415
|
import_PickerPanel.default,
|
|
@@ -25,6 +25,7 @@ export declare const YESTERDAY: RangeOption;
|
|
|
25
25
|
export declare const LAST_1_DAY: RangeOption;
|
|
26
26
|
export declare const LAST_3_DAYS: RangeOption;
|
|
27
27
|
export declare const LAST_7_DAYS: RangeOption;
|
|
28
|
+
export declare const LAST_30_DAYS: RangeOption;
|
|
28
29
|
export declare const THIS_WEEK: RangeOption;
|
|
29
30
|
export declare const LAST_WEEK: RangeOption;
|
|
30
31
|
export declare const THIS_MONTH: RangeOption;
|
|
@@ -37,6 +37,7 @@ __export(constant_exports, {
|
|
|
37
37
|
DATE_TIME_SECOND_FORMAT: () => DATE_TIME_SECOND_FORMAT,
|
|
38
38
|
DATE_TIME_SECOND_FORMAT_CN: () => DATE_TIME_SECOND_FORMAT_CN,
|
|
39
39
|
LAST_1_DAY: () => LAST_1_DAY,
|
|
40
|
+
LAST_30_DAYS: () => LAST_30_DAYS,
|
|
40
41
|
LAST_3_DAYS: () => LAST_3_DAYS,
|
|
41
42
|
LAST_7_DAYS: () => LAST_7_DAYS,
|
|
42
43
|
LAST_MONTH: () => LAST_MONTH,
|
|
@@ -234,6 +235,16 @@ var LAST_7_DAYS = {
|
|
|
234
235
|
current.clone()
|
|
235
236
|
]
|
|
236
237
|
};
|
|
238
|
+
var LAST_30_DAYS = {
|
|
239
|
+
label: "近 30 天",
|
|
240
|
+
enLabel: "Last 30 Days",
|
|
241
|
+
rangeLabel: "30d",
|
|
242
|
+
name: "LAST_30_DAYS",
|
|
243
|
+
range: (current = (0, import_moment.default)()) => [
|
|
244
|
+
current.clone().subtract(30, "days"),
|
|
245
|
+
current.clone()
|
|
246
|
+
]
|
|
247
|
+
};
|
|
237
248
|
var THIS_WEEK = {
|
|
238
249
|
label: "近一周",
|
|
239
250
|
enLabel: "Nearly a week",
|
|
@@ -247,7 +258,7 @@ var THIS_WEEK = {
|
|
|
247
258
|
var LAST_WEEK = {
|
|
248
259
|
label: "上周",
|
|
249
260
|
enLabel: "Last week",
|
|
250
|
-
rangeLabel: "
|
|
261
|
+
rangeLabel: "1w",
|
|
251
262
|
name: "LAST_WEEK",
|
|
252
263
|
range: (current = (0, import_moment.default)()) => [
|
|
253
264
|
current.clone().startOf(WEEK_UNIT).add(-1, WEEK_UNIT),
|
|
@@ -337,6 +348,7 @@ var NEAR_TIME_LIST = [
|
|
|
337
348
|
DATE_TIME_SECOND_FORMAT,
|
|
338
349
|
DATE_TIME_SECOND_FORMAT_CN,
|
|
339
350
|
LAST_1_DAY,
|
|
351
|
+
LAST_30_DAYS,
|
|
340
352
|
LAST_3_DAYS,
|
|
341
353
|
LAST_7_DAYS,
|
|
342
354
|
LAST_MONTH,
|
|
@@ -15,6 +15,7 @@ declare const DateRanger: import("react").ForwardRefExoticComponent<import("./Ra
|
|
|
15
15
|
LAST_1_DAY: import("./typing").RangeOption;
|
|
16
16
|
LAST_3_DAYS: import("./typing").RangeOption;
|
|
17
17
|
LAST_7_DAYS: import("./typing").RangeOption;
|
|
18
|
+
LAST_30_DAYS: import("./typing").RangeOption;
|
|
18
19
|
YESTERDAY: import("./typing").RangeOption;
|
|
19
20
|
THIS_WEEK: import("./typing").RangeOption;
|
|
20
21
|
LAST_WEEK: import("./typing").RangeOption;
|
package/lib/DateRanger/index.js
CHANGED
|
@@ -51,6 +51,7 @@ var DateRanger = Object.assign(import_Ranger.default, {
|
|
|
51
51
|
LAST_1_DAY: import_constant.LAST_1_DAY,
|
|
52
52
|
LAST_3_DAYS: import_constant.LAST_3_DAYS,
|
|
53
53
|
LAST_7_DAYS: import_constant.LAST_7_DAYS,
|
|
54
|
+
LAST_30_DAYS: import_constant.LAST_30_DAYS,
|
|
54
55
|
YESTERDAY: import_constant.YESTERDAY,
|
|
55
56
|
THIS_WEEK: import_constant.THIS_WEEK,
|
|
56
57
|
LAST_WEEK: import_constant.LAST_WEEK,
|