@qn-pandora/pandora-component 4.2.0 → 4.3.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.json +41 -1
- package/CHANGELOG.md +16 -2
- package/es/components/DateTimePicker/Base/index.d.ts +6 -1
- package/es/components/DateTimePicker/Base/index.js +44 -17
- package/es/components/DateTimePicker/Base/relativeTimePicker.js +10 -7
- package/es/components/DateTimePicker/constants.d.ts +57 -1
- package/es/components/DateTimePicker/constants.js +3 -5
- package/es/components/DateTimePicker/time.js +2 -2
- package/es/components/DateTimePicker/transform.d.ts +5 -1
- package/es/components/DateTimePicker/transform.js +3 -2
- package/es/components/Drawer/CloseIcon/index.d.ts +1 -0
- package/es/components/Drawer/CloseIcon/index.js +2 -2
- package/es/components/Drawer/index.d.ts +2 -0
- package/es/components/Drawer/index.js +30 -23
- package/es/components/Drawer/style.css +3 -0
- package/es/components/Drawer/style.less +4 -0
- package/es/constants/language/modal/en.js +3 -1
- package/es/constants/language/modal/type.d.ts +2 -0
- package/es/constants/language/modal/zh.js +3 -1
- package/es/index.css +49 -46
- package/es/index.less +4 -4
- package/es/style/theme.less +5 -0
- package/lib/components/DateTimePicker/Base/index.d.ts +6 -1
- package/lib/components/DateTimePicker/Base/index.js +43 -16
- package/lib/components/DateTimePicker/Base/relativeTimePicker.js +8 -5
- package/lib/components/DateTimePicker/constants.d.ts +57 -1
- package/lib/components/DateTimePicker/constants.js +3 -5
- package/lib/components/DateTimePicker/time.js +1 -1
- package/lib/components/DateTimePicker/transform.d.ts +5 -1
- package/lib/components/DateTimePicker/transform.js +3 -2
- package/lib/components/Drawer/CloseIcon/index.d.ts +1 -0
- package/lib/components/Drawer/CloseIcon/index.js +2 -2
- package/lib/components/Drawer/index.d.ts +2 -0
- package/lib/components/Drawer/index.js +29 -22
- package/lib/components/Drawer/style.css +3 -0
- package/lib/components/Drawer/style.less +4 -0
- package/lib/constants/language/modal/en.js +3 -1
- package/lib/constants/language/modal/type.d.ts +2 -0
- package/lib/constants/language/modal/zh.js +3 -1
- package/lib/index.css +3337 -3334
- package/lib/index.less +4 -4
- package/lib/style/theme.less +5 -0
- package/package.json +3 -3
package/CHANGELOG.json
CHANGED
@@ -1,10 +1,50 @@
|
|
1
1
|
{
|
2
2
|
"name": "@qn-pandora/pandora-component",
|
3
3
|
"entries": [
|
4
|
+
{
|
5
|
+
"version": "4.3.1",
|
6
|
+
"tag": "@qn-pandora/pandora-component_v4.3.1",
|
7
|
+
"date": "Mon, 30 Oct 2023 08:56:57 GMT",
|
8
|
+
"comments": {
|
9
|
+
"patch": [
|
10
|
+
{
|
11
|
+
"comment": "2023-10-30发包"
|
12
|
+
}
|
13
|
+
],
|
14
|
+
"dependency": [
|
15
|
+
{
|
16
|
+
"comment": "Updating dependency \"@qn-pandora/pandora-component-icons\" from `^3.3.0` to `^3.3.1`"
|
17
|
+
},
|
18
|
+
{
|
19
|
+
"comment": "Updating dependency \"@qn-pandora/app-sdk\" from `^3.3.0` to `^3.3.1`"
|
20
|
+
}
|
21
|
+
]
|
22
|
+
}
|
23
|
+
},
|
24
|
+
{
|
25
|
+
"version": "4.3.0",
|
26
|
+
"tag": "@qn-pandora/pandora-component_v4.3.0",
|
27
|
+
"date": "Tue, 24 Oct 2023 08:06:30 GMT",
|
28
|
+
"comments": {
|
29
|
+
"minor": [
|
30
|
+
{
|
31
|
+
"comment": "2023-10-24发包"
|
32
|
+
}
|
33
|
+
],
|
34
|
+
"dependency": [
|
35
|
+
{
|
36
|
+
"comment": "Updating dependency \"@qn-pandora/pandora-component-icons\" from `^3.2.0` to `^3.3.0`"
|
37
|
+
},
|
38
|
+
{
|
39
|
+
"comment": "Updating dependency \"@qn-pandora/app-sdk\" from `^3.2.0` to `^3.3.0`"
|
40
|
+
}
|
41
|
+
]
|
42
|
+
}
|
43
|
+
},
|
4
44
|
{
|
5
45
|
"version": "4.2.0",
|
6
46
|
"tag": "@qn-pandora/pandora-component_v4.2.0",
|
7
|
-
"date": "Mon, 25 Sep 2023
|
47
|
+
"date": "Mon, 25 Sep 2023 07:36:39 GMT",
|
8
48
|
"comments": {
|
9
49
|
"minor": [
|
10
50
|
{
|
package/CHANGELOG.md
CHANGED
@@ -1,9 +1,23 @@
|
|
1
1
|
# Change Log - @qn-pandora/pandora-component
|
2
2
|
|
3
|
-
This log was last generated on Mon,
|
3
|
+
This log was last generated on Mon, 30 Oct 2023 08:56:57 GMT and should not be manually modified.
|
4
|
+
|
5
|
+
## 4.3.1
|
6
|
+
Mon, 30 Oct 2023 08:56:57 GMT
|
7
|
+
|
8
|
+
### Patches
|
9
|
+
|
10
|
+
- 2023-10-30发包
|
11
|
+
|
12
|
+
## 4.3.0
|
13
|
+
Tue, 24 Oct 2023 08:06:30 GMT
|
14
|
+
|
15
|
+
### Minor changes
|
16
|
+
|
17
|
+
- 2023-10-24发包
|
4
18
|
|
5
19
|
## 4.2.0
|
6
|
-
Mon, 25 Sep 2023
|
20
|
+
Mon, 25 Sep 2023 07:36:39 GMT
|
7
21
|
|
8
22
|
### Minor changes
|
9
23
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import * as React from 'react';
|
2
2
|
import * as moment from 'moment';
|
3
3
|
import { ICompositedTime } from './relativeTimePicker';
|
4
|
-
import { EPresetMode, IPreset, RangePreset, IRelativeTime, IQuarterTime, IBaseProps, TimeType } from '../constants';
|
4
|
+
import { EPresetMode, IPreset, RangePreset, IRelativeTime, IQuarterTime, IBaseProps, TimeType, IRelativeTimeUnit } from '../constants';
|
5
5
|
declare enum RelativeInvalid {
|
6
6
|
Valid = 0,
|
7
7
|
From = 1,
|
@@ -51,6 +51,11 @@ export default class Base extends React.Component<IBaseProps, any> {
|
|
51
51
|
getYears(): number[];
|
52
52
|
constructor(props: IBaseProps);
|
53
53
|
UNSAFE_componentWillReceiveProps(nextProps: IBaseProps): void;
|
54
|
+
getRelativeMap(relativeTimeUnits: IRelativeTimeUnit[]): IKeyValues<{
|
55
|
+
text: string;
|
56
|
+
value: string;
|
57
|
+
time: (num: number) => moment.Moment;
|
58
|
+
}>;
|
54
59
|
isRelativeTimeValidFunc(from: ICompositedTime, to: ICompositedTime): boolean;
|
55
60
|
getAllPresetItems(): JSX.Element[];
|
56
61
|
handlePresetClick(preset: IPreset): void;
|
@@ -50,7 +50,7 @@ import Selector from '../../Selector';
|
|
50
50
|
import NameLimiter from '../../NameLimiter';
|
51
51
|
import RelativeTimePicker from './relativeTimePicker';
|
52
52
|
import Time from '../time';
|
53
|
-
import { defaultPresets, EPresetMode,
|
53
|
+
import { defaultPresets, EPresetMode, RangePreset, rangePresetOptions, TimeType, RelativeUnitValue, RELATIVE_TIME_UNITS } from '../constants';
|
54
54
|
import { Quarters } from './constants';
|
55
55
|
var Panel = Collapse.Panel;
|
56
56
|
var RelativeInvalid;
|
@@ -71,17 +71,22 @@ export var RELATIVE_DEFAULT_VALUE = {
|
|
71
71
|
var Base = /** @class */ (function (_super) {
|
72
72
|
__extends(Base, _super);
|
73
73
|
function Base(props) {
|
74
|
+
var _a, _b, _c, _d;
|
74
75
|
var _this = _super.call(this, props) || this;
|
75
76
|
_this.range = [undefined, undefined];
|
76
77
|
_this.rangePreset = RangePreset.BetweenTime;
|
77
78
|
_this.relative = {
|
78
79
|
from: {
|
79
|
-
num:
|
80
|
-
|
80
|
+
num: ((_a = _this.props.defaultRelativeValue) === null || _a === void 0 ? void 0 : _a.from.num) ||
|
81
|
+
RELATIVE_DEFAULT_VALUE.FROM_NUM,
|
82
|
+
unit: ((_b = _this.props.defaultRelativeValue) === null || _b === void 0 ? void 0 : _b.from.unit) ||
|
83
|
+
RELATIVE_DEFAULT_VALUE.FROM_UNIT
|
81
84
|
},
|
82
85
|
to: {
|
83
|
-
num:
|
84
|
-
|
86
|
+
num: ((_c = _this.props.defaultRelativeValue) === null || _c === void 0 ? void 0 : _c.to.num) ||
|
87
|
+
RELATIVE_DEFAULT_VALUE.TO_NUM,
|
88
|
+
unit: ((_d = _this.props.defaultRelativeValue) === null || _d === void 0 ? void 0 : _d.to.unit) ||
|
89
|
+
RELATIVE_DEFAULT_VALUE.TO_UNIT
|
85
90
|
}
|
86
91
|
};
|
87
92
|
_this.relativeTimeInValid = RelativeInvalid.Valid;
|
@@ -233,9 +238,21 @@ var Base = /** @class */ (function (_super) {
|
|
233
238
|
}
|
234
239
|
}
|
235
240
|
};
|
241
|
+
Base.prototype.getRelativeMap = function (relativeTimeUnits) {
|
242
|
+
var res = {};
|
243
|
+
relativeTimeUnits.forEach(function (relative) {
|
244
|
+
res[relative.value] = relative;
|
245
|
+
});
|
246
|
+
return res;
|
247
|
+
};
|
236
248
|
Base.prototype.isRelativeTimeValidFunc = function (from, to) {
|
237
|
-
var
|
238
|
-
var
|
249
|
+
var _a = this.props, relativeTimeUnits = _a.relativeTimeUnits, relativeStartTimeUnits = _a.relativeStartTimeUnits, relativeEndTimeUnits = _a.relativeEndTimeUnits;
|
250
|
+
var start = relativeStartTimeUnits || relativeTimeUnits || RELATIVE_TIME_UNITS;
|
251
|
+
var end = relativeEndTimeUnits || relativeTimeUnits || RELATIVE_TIME_UNITS;
|
252
|
+
var startRelativeMap = this.getRelativeMap(start);
|
253
|
+
var endRelativeMap = this.getRelativeMap(end);
|
254
|
+
var fromDate = startRelativeMap["" + from.unit].time(from.num).valueOf();
|
255
|
+
var toDate = endRelativeMap["" + to.unit].time(to.num).valueOf();
|
239
256
|
return fromDate < toDate;
|
240
257
|
};
|
241
258
|
Base.prototype.getAllPresetItems = function () {
|
@@ -262,14 +279,14 @@ var Base = /** @class */ (function (_super) {
|
|
262
279
|
}
|
263
280
|
};
|
264
281
|
Base.prototype.handlePickerOk = function () {
|
265
|
-
var
|
282
|
+
var _a = this.props, onChange = _a.onChange, showTime = _a.showTime;
|
266
283
|
if (onChange) {
|
267
284
|
var start = this.range[0];
|
268
285
|
var end = this.range[1];
|
269
286
|
onChange(new Time({
|
270
287
|
// 赋值时将毫秒数清零
|
271
|
-
start: start === null || start === void 0 ? void 0 : start.milliseconds(0),
|
272
|
-
end: end === null || end === void 0 ? void 0 : end.milliseconds(0),
|
288
|
+
start: showTime === false ? start === null || start === void 0 ? void 0 : start.startOf('day') : start === null || start === void 0 ? void 0 : start.milliseconds(0),
|
289
|
+
end: showTime === false ? end === null || end === void 0 ? void 0 : end.startOf('day') : end === null || end === void 0 ? void 0 : end.milliseconds(0),
|
273
290
|
rangePreset: this.rangePreset
|
274
291
|
}));
|
275
292
|
}
|
@@ -328,22 +345,26 @@ var Base = /** @class */ (function (_super) {
|
|
328
345
|
};
|
329
346
|
Base.prototype.renderRelativeContent = function () {
|
330
347
|
var _a;
|
348
|
+
var _b, _c, _d, _e;
|
331
349
|
var locale = this.context.locale;
|
332
|
-
var fromNum = _.get(this.relative, 'from.num',
|
333
|
-
|
334
|
-
var
|
335
|
-
|
350
|
+
var fromNum = _.get(this.relative, 'from.num', ((_b = this.props.defaultRelativeValue) === null || _b === void 0 ? void 0 : _b.from.num) ||
|
351
|
+
RELATIVE_DEFAULT_VALUE.FROM_NUM);
|
352
|
+
var fromUnit = _.get(this.relative, 'from.unit', ((_c = this.props.defaultRelativeValue) === null || _c === void 0 ? void 0 : _c.from.unit) ||
|
353
|
+
RELATIVE_DEFAULT_VALUE.FROM_UNIT);
|
354
|
+
var toNum = _.get(this.relative, 'to.num', ((_d = this.props.defaultRelativeValue) === null || _d === void 0 ? void 0 : _d.to.num) || RELATIVE_DEFAULT_VALUE.TO_NUM);
|
355
|
+
var toUnit = _.get(this.relative, 'to.unit', ((_e = this.props.defaultRelativeValue) === null || _e === void 0 ? void 0 : _e.to.unit) || RELATIVE_DEFAULT_VALUE.TO_UNIT);
|
356
|
+
var _f = this.props, relativeStartTimeUnits = _f.relativeStartTimeUnits, relativeEndTimeUnits = _f.relativeEndTimeUnits, relativeTimeUnits = _f.relativeTimeUnits;
|
336
357
|
if (!this.isRangePicker()) {
|
337
358
|
return (React.createElement("div", { className: SDK_PREFIX + "-datetime-pick-content" },
|
338
359
|
React.createElement("div", { className: SDK_PREFIX + "-datetime-pick-relative-container" },
|
339
|
-
React.createElement(RelativeTimePicker, { className: SDK_PREFIX + "-datetime-pick-relative", num: fromNum, unit: fromUnit, onChange: this.handleRetiveTimeFromChange, relativeTimeUnits:
|
360
|
+
React.createElement(RelativeTimePicker, { className: SDK_PREFIX + "-datetime-pick-relative", num: fromNum, unit: fromUnit, onChange: this.handleRetiveTimeFromChange, relativeTimeUnits: relativeStartTimeUnits || relativeTimeUnits }),
|
340
361
|
React.createElement(Button, { disabled: !this.isRelativeTimeValid, className: SDK_PREFIX + "-datetime-pick-relative-confirm", onClick: this.handleRelativeChange }, formatString(DateTimeLocale.confirm, locale)))));
|
341
362
|
}
|
342
363
|
return (React.createElement("div", { className: SDK_PREFIX + "-datetime-pick-content" },
|
343
364
|
React.createElement("div", { className: SDK_PREFIX + "-datetime-pick-relative-container" },
|
344
|
-
React.createElement(RelativeTimePicker, { className: SDK_PREFIX + "-datetime-pick-relative-timepicker", num: fromNum, unit: fromUnit, onChange: this.handleRetiveTimeFromChange, relativeTimeUnits:
|
365
|
+
React.createElement(RelativeTimePicker, { className: SDK_PREFIX + "-datetime-pick-relative-timepicker", num: fromNum, unit: fromUnit, onChange: this.handleRetiveTimeFromChange, relativeTimeUnits: relativeStartTimeUnits || relativeTimeUnits, withoutNow: true }),
|
345
366
|
React.createElement("span", { className: SDK_PREFIX + "-datetime-pick-relative-container-to" }, formatString(DateTimeLocale.to, locale)),
|
346
|
-
React.createElement(RelativeTimePicker, { className: SDK_PREFIX + "-datetime-pick-relative-timepicker", num: toNum, unit: toUnit, onChange: this.handleRetiveTimeToChange, relativeTimeUnits:
|
367
|
+
React.createElement(RelativeTimePicker, { className: SDK_PREFIX + "-datetime-pick-relative-timepicker", num: toNum, unit: toUnit, onChange: this.handleRetiveTimeToChange, relativeTimeUnits: relativeEndTimeUnits || relativeTimeUnits })),
|
347
368
|
React.createElement("div", { className: classnames(SDK_PREFIX + "-datetime-pick-relative-footer", (_a = {},
|
348
369
|
_a[SDK_PREFIX + "-datetime-pick-relative-footer-witNow"] = toUnit === RelativeUnitValue.NowStatic,
|
349
370
|
_a)) },
|
@@ -521,6 +542,12 @@ var Base = /** @class */ (function (_super) {
|
|
521
542
|
__metadata("design:paramtypes", [Object]),
|
522
543
|
__metadata("design:returntype", void 0)
|
523
544
|
], Base.prototype, "setRelative", null);
|
545
|
+
__decorate([
|
546
|
+
bind,
|
547
|
+
__metadata("design:type", Function),
|
548
|
+
__metadata("design:paramtypes", [Array]),
|
549
|
+
__metadata("design:returntype", void 0)
|
550
|
+
], Base.prototype, "getRelativeMap", null);
|
524
551
|
__decorate([
|
525
552
|
bind,
|
526
553
|
__metadata("design:type", Function),
|
@@ -14,14 +14,14 @@ var __extends = (this && this.__extends) || (function () {
|
|
14
14
|
import * as React from 'react';
|
15
15
|
import { InputNumber } from 'antd';
|
16
16
|
import { ConfigContext } from 'antd/es/config-provider';
|
17
|
-
import { isNil } from 'lodash';
|
17
|
+
import { isNil, find } from 'lodash';
|
18
18
|
import classnames from 'classnames';
|
19
19
|
import { formatString } from '../../../utils/language';
|
20
20
|
import { SDK_PREFIX } from '../../../constants/style';
|
21
21
|
import { DateTimeLocale } from '../../../constants/language/datetime/type';
|
22
22
|
import { toFormatTime } from '../../../utils/time';
|
23
23
|
import Selector from '../../Selector';
|
24
|
-
import {
|
24
|
+
import { RELATIVE_TIME_UNITS, RelativeUnitValue } from '../constants';
|
25
25
|
var RetiveTimePicker = /** @class */ (function (_super) {
|
26
26
|
__extends(RetiveTimePicker, _super);
|
27
27
|
function RetiveTimePicker() {
|
@@ -60,16 +60,19 @@ var RetiveTimePicker = /** @class */ (function (_super) {
|
|
60
60
|
return _this.containerRef.current || document.body;
|
61
61
|
};
|
62
62
|
_this.shouldShowInput = function () {
|
63
|
-
var
|
64
|
-
|
63
|
+
var _a;
|
64
|
+
var _b = _this.props, unit = _b.unit, relativeTimeUnits = _b.relativeTimeUnits;
|
65
|
+
return (unit !== RelativeUnitValue.Now &&
|
66
|
+
unit !== RelativeUnitValue.NowStatic &&
|
67
|
+
((_a = find(relativeTimeUnits || RELATIVE_TIME_UNITS, function (item) { return item.value === unit; })) === null || _a === void 0 ? void 0 : _a.static) !== true);
|
65
68
|
};
|
66
69
|
return _this;
|
67
70
|
}
|
68
71
|
RetiveTimePicker.prototype.render = function () {
|
69
|
-
var _a = this.props, num = _a.num, unit = _a.unit, className = _a.className, withoutNow = _a.withoutNow;
|
72
|
+
var _a = this.props, num = _a.num, unit = _a.unit, className = _a.className, withoutNow = _a.withoutNow, relativeTimeUnits = _a.relativeTimeUnits;
|
70
73
|
var locale = this.context.locale;
|
71
|
-
var options =
|
72
|
-
|
74
|
+
var options = relativeTimeUnits ||
|
75
|
+
RELATIVE_TIME_UNITS.map(function (option) {
|
73
76
|
return {
|
74
77
|
text: formatString(option.text, locale),
|
75
78
|
value: option.value,
|
@@ -32,6 +32,28 @@ export interface IPreset {
|
|
32
32
|
export interface IRelativeTimeUnit {
|
33
33
|
text: string;
|
34
34
|
value: string;
|
35
|
+
/**
|
36
|
+
* 是否是一个能完整表达的静态时间,例如昨天、前天、上个月,不需要用户再额外输入数字
|
37
|
+
*
|
38
|
+
* 例:
|
39
|
+
* 像两天前,或者几天前,需要用户输入一个数字来确定具体的时间,就是不完整时间。
|
40
|
+
* {
|
41
|
+
text: '天前',
|
42
|
+
value: 'day',
|
43
|
+
static: false,
|
44
|
+
time: (num: number) => moment().startOf('day').subtract(num, 'days')
|
45
|
+
}
|
46
|
+
*
|
47
|
+
|
48
|
+
* 像 昨天、前天、上个月,不需要用户再额外输入数字。
|
49
|
+
* {
|
50
|
+
text: '昨天',
|
51
|
+
value: 'yesterday',
|
52
|
+
static: true,
|
53
|
+
time: (_: number) => moment().startOf('day').subtract(1, 'days')
|
54
|
+
}
|
55
|
+
*/
|
56
|
+
static?: boolean;
|
35
57
|
time: (num: number) => moment.Moment;
|
36
58
|
}
|
37
59
|
export declare const defaultPresets: IPreset[];
|
@@ -55,10 +77,32 @@ export declare enum RelativeUnitValue {
|
|
55
77
|
Quarter = "Q",
|
56
78
|
Year = "y"
|
57
79
|
}
|
58
|
-
export declare const
|
80
|
+
export declare const RELATIVE_TIME_UNITS: IRelativeTimeUnit[];
|
59
81
|
export declare const relativeTimeUnitsWithoutNowStatic: {
|
60
82
|
text: string;
|
61
83
|
value: string;
|
84
|
+
/**
|
85
|
+
* 是否是一个能完整表达的静态时间,例如昨天、前天、上个月,不需要用户再额外输入数字
|
86
|
+
*
|
87
|
+
* 例:
|
88
|
+
* 像两天前,或者几天前,需要用户输入一个数字来确定具体的时间,就是不完整时间。
|
89
|
+
* {
|
90
|
+
text: '天前',
|
91
|
+
value: 'day',
|
92
|
+
static: false,
|
93
|
+
time: (num: number) => moment().startOf('day').subtract(num, 'days')
|
94
|
+
}
|
95
|
+
*
|
96
|
+
|
97
|
+
* 像 昨天、前天、上个月,不需要用户再额外输入数字。
|
98
|
+
* {
|
99
|
+
text: '昨天',
|
100
|
+
value: 'yesterday',
|
101
|
+
static: true,
|
102
|
+
time: (_: number) => moment().startOf('day').subtract(1, 'days')
|
103
|
+
}
|
104
|
+
*/
|
105
|
+
static?: boolean | undefined;
|
62
106
|
time: (num: number) => moment.Moment;
|
63
107
|
}[];
|
64
108
|
export declare const relativeMap: IKeyValues<{
|
@@ -114,6 +158,14 @@ export interface IBaseProps {
|
|
114
158
|
* 预设
|
115
159
|
*/
|
116
160
|
presets?: IPreset[];
|
161
|
+
/**
|
162
|
+
* 自定义相对时间单位(开始)
|
163
|
+
*/
|
164
|
+
relativeStartTimeUnits?: IRelativeTimeUnit[];
|
165
|
+
/**
|
166
|
+
* 自定义相对时间单位(结束)
|
167
|
+
*/
|
168
|
+
relativeEndTimeUnits?: IRelativeTimeUnit[];
|
117
169
|
/**
|
118
170
|
* 自定义相对时间单位
|
119
171
|
*/
|
@@ -196,6 +248,10 @@ export interface IBaseProps {
|
|
196
248
|
* 语言
|
197
249
|
*/
|
198
250
|
locale?: string;
|
251
|
+
/**
|
252
|
+
* 默认的相对时间
|
253
|
+
*/
|
254
|
+
defaultRelativeValue?: IRelativeTime;
|
199
255
|
}
|
200
256
|
export interface ITimeRange {
|
201
257
|
relative?: IRelativeTime;
|
@@ -242,7 +242,7 @@ export var RelativeUnitValue;
|
|
242
242
|
RelativeUnitValue["Quarter"] = "Q";
|
243
243
|
RelativeUnitValue["Year"] = "y";
|
244
244
|
})(RelativeUnitValue || (RelativeUnitValue = {}));
|
245
|
-
export var
|
245
|
+
export var RELATIVE_TIME_UNITS = [
|
246
246
|
{
|
247
247
|
text: DateTimeLocale.relative.now,
|
248
248
|
value: RelativeUnitValue.Now,
|
@@ -294,15 +294,13 @@ export var relativeTimeUnits = [
|
|
294
294
|
time: function (num) { return moment().subtract(num, 'years'); }
|
295
295
|
}
|
296
296
|
];
|
297
|
-
export var relativeTimeUnitsWithoutNowStatic =
|
298
|
-
.filter(function (item) { return item.value !== RelativeUnitValue.NowStatic; })
|
299
|
-
.map(function (item) {
|
297
|
+
export var relativeTimeUnitsWithoutNowStatic = RELATIVE_TIME_UNITS.filter(function (item) { return item.value !== RelativeUnitValue.NowStatic; }).map(function (item) {
|
300
298
|
return item.value === RelativeUnitValue.Now
|
301
299
|
? __assign(__assign({}, item), { text: DateTimeLocale.relative.now_text }) : __assign({}, item);
|
302
300
|
});
|
303
301
|
export var relativeMap = (function () {
|
304
302
|
var res = {};
|
305
|
-
|
303
|
+
RELATIVE_TIME_UNITS.forEach(function (relative) {
|
306
304
|
res[relative.value] = relative;
|
307
305
|
});
|
308
306
|
return res;
|
@@ -2,7 +2,7 @@ import moment from 'moment';
|
|
2
2
|
import { isEmpty, isEqual } from 'lodash';
|
3
3
|
import zhCN from 'antd/es/locale-provider/zh_CN';
|
4
4
|
import { toFormatTime } from '../../utils/time';
|
5
|
-
import { defaultPresets,
|
5
|
+
import { defaultPresets, RELATIVE_TIME_UNITS, RelativeUnitValue, RangePreset, QuartersMap } from './constants';
|
6
6
|
import { formatString } from '../../utils/language';
|
7
7
|
import { DateTimeLocale } from '../../constants/language/datetime/type';
|
8
8
|
var Time = /** @class */ (function () {
|
@@ -34,7 +34,7 @@ var Time = /** @class */ (function () {
|
|
34
34
|
this.isPointPicker = options.isPointPicker;
|
35
35
|
this.quarterTime = time.quarterTime;
|
36
36
|
this.presetMap = this.getPresetMap(isEmpty(options.presets) ? defaultPresets : options.presets);
|
37
|
-
this.relativeMap = this.getRelativeMap(isEmpty(options.relatives) ?
|
37
|
+
this.relativeMap = this.getRelativeMap(isEmpty(options.relatives) ? RELATIVE_TIME_UNITS : options.relatives);
|
38
38
|
}
|
39
39
|
Time.toMoment = function (time) {
|
40
40
|
try {
|
@@ -4,7 +4,11 @@ export declare function transformToTime(time: ITimeRange): ITime;
|
|
4
4
|
export declare function transformToTimeRange(time: ITime): ITimeRange;
|
5
5
|
export declare function getTimeShiftUnit(time: string): TimeShiftUnit.Second | TimeShiftUnit;
|
6
6
|
export declare function getRelativeTime(timeShift: string, time: moment.Moment): moment.Moment | undefined;
|
7
|
-
export declare function calcFullTime(time?: ITimeRange
|
7
|
+
export declare function calcFullTime(time?: ITimeRange, options?: {
|
8
|
+
presets?: any;
|
9
|
+
relatives?: any;
|
10
|
+
isPointPicker?: boolean;
|
11
|
+
}): {
|
8
12
|
start: number | undefined;
|
9
13
|
end: number | undefined;
|
10
14
|
} | undefined;
|
@@ -59,12 +59,13 @@ export function getRelativeTime(timeShift, time) {
|
|
59
59
|
return moment(time).subtract(timeShiftValue, timeShiftUnit);
|
60
60
|
}
|
61
61
|
}
|
62
|
-
export function calcFullTime(time) {
|
62
|
+
export function calcFullTime(time, options) {
|
63
|
+
if (options === void 0) { options = {}; }
|
63
64
|
if (!time) {
|
64
65
|
return;
|
65
66
|
}
|
66
67
|
var timeShift = time.timeShift;
|
67
|
-
var _a = new Time(transformToTime(time)).toDate(), start = _a.start, end = _a.end;
|
68
|
+
var _a = new Time(transformToTime(time), options).toDate(), start = _a.start, end = _a.end;
|
68
69
|
var relativeStart = timeShift && start ? getRelativeTime(timeShift, start) : start;
|
69
70
|
var relativeEnd = timeShift && end ? getRelativeTime(timeShift, end) : end;
|
70
71
|
return {
|
@@ -8,8 +8,8 @@ import { formatString } from '../../../utils/language';
|
|
8
8
|
import { ModalLocale } from '../../../constants/language/modal/type';
|
9
9
|
export var CloseIcon = function (props) {
|
10
10
|
var locale = useContext(ConfigContext).locale;
|
11
|
-
var className = props.className, onClick = props.onClick;
|
12
|
-
return (React.createElement(Tooltip, { title: formatString(ModalLocale.close_tooltip, locale) },
|
11
|
+
var className = props.className, onClick = props.onClick, getPopupContainer = props.getPopupContainer;
|
12
|
+
return (React.createElement(Tooltip, { title: formatString(ModalLocale.close_tooltip, locale), getPopupContainer: getPopupContainer },
|
13
13
|
React.createElement(Close, { className: classnames(SDK_PREFIX + "-modal-close-icon", className), onClick: onClick })));
|
14
14
|
};
|
15
15
|
export default CloseIcon;
|
@@ -78,6 +78,7 @@ export declare class Drawer extends React.Component<React.PropsWithChildren<IDra
|
|
78
78
|
realWidth: React.ReactText;
|
79
79
|
isFullscreen: boolean;
|
80
80
|
throttleMouseMove: import("lodash").DebouncedFunc<(e: any) => void>;
|
81
|
+
static contextType: React.Context<import("antd/es/config-provider").ConfigConsumerProps>;
|
81
82
|
get closable(): boolean | undefined;
|
82
83
|
get extra(): JSX.Element;
|
83
84
|
setIsResizing(isResizing?: boolean): void;
|
@@ -89,6 +90,7 @@ export declare class Drawer extends React.Component<React.PropsWithChildren<IDra
|
|
89
90
|
onMouseMove(e: any): void;
|
90
91
|
onMouseClick(e: MouseEvent): void;
|
91
92
|
initWidth(width?: string | number, size?: string): React.ReactText;
|
93
|
+
handleClose(e: EventType | null): void;
|
92
94
|
componentDidMount(): void;
|
93
95
|
UNSAFE_componentWillUpdate(nextProps: Readonly<React.PropsWithChildren<IDrawerProps>>): void;
|
94
96
|
componentWillUnmount(): void;
|
@@ -47,14 +47,16 @@ import classnames from 'classnames';
|
|
47
47
|
import { throttle } from 'lodash';
|
48
48
|
import { observer } from 'mobx-react';
|
49
49
|
import { observable, action, computed } from 'mobx';
|
50
|
-
import { Drawer as BaseDrawer } from 'antd';
|
51
|
-
import
|
50
|
+
import { Drawer as BaseDrawer, Tooltip } from 'antd';
|
51
|
+
import { ConfigContext } from 'antd/es/config-provider';
|
52
52
|
import { FullscreenExitOutlined, FullscreenOutlined } from '@qn-pandora/pandora-component-icons';
|
53
53
|
import { doesDOMMatchSelector } from '../../utils/dom';
|
54
54
|
import { SDK_PREFIX, ANT_PREFIX } from '../../constants/style';
|
55
55
|
import modalPopupContainerWrapper from '../../hoc/modalPopupContainer';
|
56
56
|
import bind from '../../utils/bind';
|
57
57
|
import CloseIcon from './CloseIcon';
|
58
|
+
import { formatString } from '../../utils/language';
|
59
|
+
import { ModalLocale } from '../../constants/language/modal/type';
|
58
60
|
var DEFAULT_WIDTH = '50%';
|
59
61
|
var SMALL_WIDTH = '38%';
|
60
62
|
var LARGE_WIDTH = '75%';
|
@@ -85,13 +87,15 @@ var Drawer = /** @class */ (function (_super) {
|
|
85
87
|
});
|
86
88
|
Object.defineProperty(Drawer.prototype, "extra", {
|
87
89
|
get: function () {
|
88
|
-
var _a = this.props, closable = _a.closable, closeIconPlacement = _a.closeIconPlacement,
|
89
|
-
var fullIcon = showFullScreen === true ? (this.isFullscreen ? (React.createElement(
|
90
|
+
var _a = this.props, closable = _a.closable, closeIconPlacement = _a.closeIconPlacement, showFullScreen = _a.showFullScreen;
|
91
|
+
var fullIcon = showFullScreen === true ? (this.isFullscreen ? (React.createElement(Tooltip, { title: formatString(ModalLocale.exit_full, this.context.locale) },
|
92
|
+
React.createElement(FullscreenExitOutlined, { onClick: this.handleFull, className: SDK_PREFIX + "-drawer-header-full-icon" }))) : (React.createElement(Tooltip, { title: formatString(ModalLocale.full, this.context.locale) },
|
93
|
+
React.createElement(FullscreenOutlined, { onClick: this.handleFull, className: SDK_PREFIX + "-drawer-header-full-icon" })))) : null;
|
90
94
|
if (closable !== false && closeIconPlacement === 'right') {
|
91
95
|
return (React.createElement(React.Fragment, null,
|
92
96
|
this.props.extra,
|
93
97
|
fullIcon,
|
94
|
-
React.createElement(CloseIcon, { className: SDK_PREFIX + "-drawer-close-icon", onClick:
|
98
|
+
React.createElement(CloseIcon, { className: SDK_PREFIX + "-drawer-close-icon", onClick: this.handleClose })));
|
95
99
|
}
|
96
100
|
return (React.createElement(React.Fragment, null,
|
97
101
|
fullIcon,
|
@@ -111,12 +115,7 @@ var Drawer = /** @class */ (function (_super) {
|
|
111
115
|
this.isFullscreen = isFullscreen;
|
112
116
|
};
|
113
117
|
Drawer.prototype.handleFull = function () {
|
114
|
-
var draw = document.querySelector("." + this.drawerId);
|
115
|
-
if (!screenfull || !draw) {
|
116
|
-
return;
|
117
|
-
}
|
118
118
|
this.setIsFullscreen(!this.isFullscreen);
|
119
|
-
screenfull.toggle(draw);
|
120
119
|
};
|
121
120
|
Drawer.prototype.onMouseDown = function () {
|
122
121
|
this.setIsResizing(true);
|
@@ -136,7 +135,8 @@ var Drawer = /** @class */ (function (_super) {
|
|
136
135
|
}
|
137
136
|
};
|
138
137
|
Drawer.prototype.onMouseClick = function (e) {
|
139
|
-
var _a
|
138
|
+
var _a;
|
139
|
+
var _b = this.props, mask = _b.mask, maskClosable = _b.maskClosable, nonCloseSelector = _b.nonCloseSelector, visible = _b.visible;
|
140
140
|
if (this.isResizing)
|
141
141
|
return;
|
142
142
|
if (mask === false && maskClosable && visible) {
|
@@ -157,7 +157,7 @@ var Drawer = /** @class */ (function (_super) {
|
|
157
157
|
currentEl = currentEl.parentElement;
|
158
158
|
}
|
159
159
|
if (shouldClose) {
|
160
|
-
|
160
|
+
(_a = this.handleClose) === null || _a === void 0 ? void 0 : _a.call(this, null);
|
161
161
|
}
|
162
162
|
}
|
163
163
|
};
|
@@ -171,18 +171,18 @@ var Drawer = /** @class */ (function (_super) {
|
|
171
171
|
return LARGE_WIDTH;
|
172
172
|
return DEFAULT_WIDTH;
|
173
173
|
};
|
174
|
-
Drawer.prototype.
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
onScreenFullChange(screenfull.isFullscreen);
|
182
|
-
}
|
183
|
-
});
|
174
|
+
Drawer.prototype.handleClose = function (e) {
|
175
|
+
var _a = this.props, onClose = _a.onClose, showFullScreen = _a.showFullScreen;
|
176
|
+
if (onClose) {
|
177
|
+
onClose(e);
|
178
|
+
// 如果在全屏的状态下关闭抽屉,需要将关闭全屏
|
179
|
+
if (showFullScreen && this.isFullscreen) {
|
180
|
+
this.handleFull();
|
184
181
|
}
|
185
182
|
}
|
183
|
+
};
|
184
|
+
Drawer.prototype.componentDidMount = function () {
|
185
|
+
document.body.addEventListener('mousedown', this.onMouseClick);
|
186
186
|
if (this.props.canDrag) {
|
187
187
|
document.addEventListener('mousemove', this.throttleMouseMove);
|
188
188
|
document.addEventListener('mouseup', this.onMouseUp);
|
@@ -204,10 +204,11 @@ var Drawer = /** @class */ (function (_super) {
|
|
204
204
|
var _b = this.props, width = _b.width, className = _b.className, children = _b.children, canDrag = _b.canDrag, visible = _b.visible, closable = _b.closable, extra = _b.extra, size = _b.size, onClose = _b.onClose, other = __rest(_b, ["width", "className", "children", "canDrag", "visible", "closable", "extra", "size", "onClose"]);
|
205
205
|
return (React.createElement(BaseDrawer, __assign({ className: classnames(this.drawerId, SDK_PREFIX + "-drawer", className, (_a = {},
|
206
206
|
_a[SDK_PREFIX + "-drawer-no-mask"] = this.props.mask === false,
|
207
|
-
_a)), width: this.realWidth || 800, zIndex: 1200, visible: visible, closable: this.closable, extra: this.extra, closeIcon: React.createElement(CloseIcon, { className: SDK_PREFIX + "-drawer-close-icon", onClick:
|
207
|
+
_a)), width: this.isFullscreen ? '100%' : this.realWidth || 800, zIndex: 1200, visible: visible, closable: this.closable, extra: this.extra, closeIcon: React.createElement(CloseIcon, { className: SDK_PREFIX + "-drawer-close-icon", onClick: this.handleClose }), onClose: this.handleClose }, other),
|
208
208
|
canDrag && (React.createElement("div", { className: SDK_PREFIX + "-scroll-handler", onMouseDown: this.onMouseDown })),
|
209
209
|
children));
|
210
210
|
};
|
211
|
+
Drawer.contextType = ConfigContext;
|
211
212
|
__decorate([
|
212
213
|
observable,
|
213
214
|
__metadata("design:type", Object)
|
@@ -287,6 +288,12 @@ var Drawer = /** @class */ (function (_super) {
|
|
287
288
|
__metadata("design:paramtypes", [Object, String]),
|
288
289
|
__metadata("design:returntype", void 0)
|
289
290
|
], Drawer.prototype, "initWidth", null);
|
291
|
+
__decorate([
|
292
|
+
bind,
|
293
|
+
__metadata("design:type", Function),
|
294
|
+
__metadata("design:paramtypes", [Object]),
|
295
|
+
__metadata("design:returntype", void 0)
|
296
|
+
], Drawer.prototype, "handleClose", null);
|
290
297
|
Drawer = __decorate([
|
291
298
|
observer
|
292
299
|
], Drawer);
|