@qn-pandora/pandora-component 4.1.7 → 4.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +25 -8
- package/CHANGELOG.md +12 -5
- 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/index.d.ts +21 -1
- package/es/components/Drawer/index.js +74 -13
- package/es/components/Drawer/style.css +11 -0
- package/es/components/Drawer/style.less +13 -0
- package/es/components/RadioGroup/style.css +7 -0
- package/es/components/RadioGroup/style.less +9 -0
- package/es/components/Table/ColumnSetting/index.d.ts +16 -0
- package/es/components/Table/ColumnSetting/index.js +91 -0
- package/es/components/Table/ColumnSetting/style.css +47 -0
- package/es/components/Table/ColumnSetting/style.less +46 -0
- package/es/components/Table/index.d.ts +27 -2
- package/es/components/Table/index.js +127 -3
- package/es/components/Table/style.css +4 -0
- package/es/components/Table/style.less +7 -0
- package/es/constants/language/table/en.js +4 -1
- package/es/constants/language/table/type.d.ts +3 -0
- package/es/constants/language/table/zh.js +4 -1
- package/es/index.css +2758 -2689
- package/es/index.less +5 -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/index.d.ts +21 -1
- package/lib/components/Drawer/index.js +74 -13
- package/lib/components/Drawer/style.css +11 -0
- package/lib/components/Drawer/style.less +13 -0
- package/lib/components/RadioGroup/style.css +7 -0
- package/lib/components/RadioGroup/style.less +9 -0
- package/lib/components/Table/ColumnSetting/index.d.ts +16 -0
- package/lib/components/Table/ColumnSetting/index.js +104 -0
- package/lib/components/Table/ColumnSetting/style.css +47 -0
- package/lib/components/Table/ColumnSetting/style.less +46 -0
- package/lib/components/Table/index.d.ts +27 -2
- package/lib/components/Table/index.js +126 -2
- package/lib/components/Table/style.css +4 -0
- package/lib/components/Table/style.less +7 -0
- package/lib/constants/language/table/en.js +4 -1
- package/lib/constants/language/table/type.d.ts +3 -0
- package/lib/constants/language/table/zh.js +4 -1
- package/lib/index.css +2295 -2226
- package/lib/index.less +3 -2
- package/lib/style/theme.less +5 -0
- package/package.json +6 -5
package/es/index.less
CHANGED
@@ -2,24 +2,24 @@
|
|
2
2
|
@import './style/theme.less';
|
3
3
|
@import './components/AutoComplete/style.less';
|
4
4
|
@import './components/Breadcrumb/style.less';
|
5
|
-
@import './components/Card/style.less';
|
6
5
|
@import './components/Button/style.less';
|
6
|
+
@import './components/Card/style.less';
|
7
7
|
@import './components/CheckTransformList/style.less';
|
8
8
|
@import './components/Checkbox/style.less';
|
9
9
|
@import './components/CheckboxList/style.less';
|
10
10
|
@import './components/Collapse/style.less';
|
11
11
|
@import './components/CollapsiblePanel/style.less';
|
12
|
-
@import './components/Descriptions/style.less';
|
13
12
|
@import './components/DateTimePicker/style.less';
|
14
|
-
@import './components/
|
13
|
+
@import './components/Descriptions/style.less';
|
15
14
|
@import './components/Drawer/style.less';
|
15
|
+
@import './components/FileResumable/style.less';
|
16
16
|
@import './components/Input/style.less';
|
17
17
|
@import './components/KeyValuePair/style.less';
|
18
18
|
@import './components/Menu/style.less';
|
19
19
|
@import './components/Modal/style.less';
|
20
|
+
@import './components/NameExplainTooltip/style.less';
|
20
21
|
@import './components/NameLimiter/style.less';
|
21
22
|
@import './components/OptionList/style.less';
|
22
|
-
@import './components/NameExplainTooltip/style.less';
|
23
23
|
@import './components/RadioGroup/style.less';
|
24
24
|
@import './components/RangeInput/style.less';
|
25
25
|
@import './components/RemarkName/style.less';
|
@@ -42,6 +42,7 @@
|
|
42
42
|
@import './components/OptionList/OptionItem/style.less';
|
43
43
|
@import './components/OptionList/PopoverOptionList/style.less';
|
44
44
|
@import './components/Steps/ControlButton/style.less';
|
45
|
+
@import './components/Table/ColumnSetting/style.less';
|
45
46
|
@import './components/Table/ColumnTag/style.less';
|
46
47
|
@import './components/TagList/Tag/style.less';
|
47
48
|
@import './components/TagList/TagSwitch/style.less';
|
package/es/style/theme.less
CHANGED
@@ -72,6 +72,7 @@
|
|
72
72
|
@font-color-6: #666;
|
73
73
|
@font-color-9: #999;
|
74
74
|
@font-color-7: #333;
|
75
|
+
@font-color-8: #8c8c8c;
|
75
76
|
@secondary-font-color: #c1c7d0; // phoenix
|
76
77
|
@disabled-text-color: #9eaec5; // pandora-visualization pheonix
|
77
78
|
@log-font-family: 'Droid Sans Mono', 'Consolas', 'Monaco', 'Courier New',
|
@@ -394,7 +395,11 @@
|
|
394
395
|
@agent-box-shadow-color: rgba(53, 53, 53, 0.07);
|
395
396
|
@agent-cursor-color: #282828;
|
396
397
|
@agent-spl-background-color: #edeff2;
|
398
|
+
@agent-example-desc-color: #595959;
|
397
399
|
@agent-input-border-color: #e9e9e9;
|
398
400
|
@agent-border-color: #e8e8e8;
|
399
401
|
@background-color-fa: #fafafa;
|
400
402
|
@background-color-f5: #f5f5f5;
|
403
|
+
@background-color-f4: #f4f5f6;
|
404
|
+
@background-linear-color: rgba(244, 245, 246, 0);
|
405
|
+
@background-color-e2: #e2e4e6;
|
@@ -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;
|
@@ -83,17 +83,22 @@ exports.RELATIVE_DEFAULT_VALUE = {
|
|
83
83
|
var Base = /** @class */ (function (_super) {
|
84
84
|
__extends(Base, _super);
|
85
85
|
function Base(props) {
|
86
|
+
var _a, _b, _c, _d;
|
86
87
|
var _this = _super.call(this, props) || this;
|
87
88
|
_this.range = [undefined, undefined];
|
88
89
|
_this.rangePreset = constants_1.RangePreset.BetweenTime;
|
89
90
|
_this.relative = {
|
90
91
|
from: {
|
91
|
-
num:
|
92
|
-
|
92
|
+
num: ((_a = _this.props.defaultRelativeValue) === null || _a === void 0 ? void 0 : _a.from.num) ||
|
93
|
+
exports.RELATIVE_DEFAULT_VALUE.FROM_NUM,
|
94
|
+
unit: ((_b = _this.props.defaultRelativeValue) === null || _b === void 0 ? void 0 : _b.from.unit) ||
|
95
|
+
exports.RELATIVE_DEFAULT_VALUE.FROM_UNIT
|
93
96
|
},
|
94
97
|
to: {
|
95
|
-
num:
|
96
|
-
|
98
|
+
num: ((_c = _this.props.defaultRelativeValue) === null || _c === void 0 ? void 0 : _c.to.num) ||
|
99
|
+
exports.RELATIVE_DEFAULT_VALUE.TO_NUM,
|
100
|
+
unit: ((_d = _this.props.defaultRelativeValue) === null || _d === void 0 ? void 0 : _d.to.unit) ||
|
101
|
+
exports.RELATIVE_DEFAULT_VALUE.TO_UNIT
|
97
102
|
}
|
98
103
|
};
|
99
104
|
_this.relativeTimeInValid = RelativeInvalid.Valid;
|
@@ -245,9 +250,21 @@ var Base = /** @class */ (function (_super) {
|
|
245
250
|
}
|
246
251
|
}
|
247
252
|
};
|
253
|
+
Base.prototype.getRelativeMap = function (relativeTimeUnits) {
|
254
|
+
var res = {};
|
255
|
+
relativeTimeUnits.forEach(function (relative) {
|
256
|
+
res[relative.value] = relative;
|
257
|
+
});
|
258
|
+
return res;
|
259
|
+
};
|
248
260
|
Base.prototype.isRelativeTimeValidFunc = function (from, to) {
|
249
|
-
var
|
250
|
-
var
|
261
|
+
var _a = this.props, relativeTimeUnits = _a.relativeTimeUnits, relativeStartTimeUnits = _a.relativeStartTimeUnits, relativeEndTimeUnits = _a.relativeEndTimeUnits;
|
262
|
+
var start = relativeStartTimeUnits || relativeTimeUnits || constants_1.RELATIVE_TIME_UNITS;
|
263
|
+
var end = relativeEndTimeUnits || relativeTimeUnits || constants_1.RELATIVE_TIME_UNITS;
|
264
|
+
var startRelativeMap = this.getRelativeMap(start);
|
265
|
+
var endRelativeMap = this.getRelativeMap(end);
|
266
|
+
var fromDate = startRelativeMap["" + from.unit].time(from.num).valueOf();
|
267
|
+
var toDate = endRelativeMap["" + to.unit].time(to.num).valueOf();
|
251
268
|
return fromDate < toDate;
|
252
269
|
};
|
253
270
|
Base.prototype.getAllPresetItems = function () {
|
@@ -274,14 +291,14 @@ var Base = /** @class */ (function (_super) {
|
|
274
291
|
}
|
275
292
|
};
|
276
293
|
Base.prototype.handlePickerOk = function () {
|
277
|
-
var
|
294
|
+
var _a = this.props, onChange = _a.onChange, showTime = _a.showTime;
|
278
295
|
if (onChange) {
|
279
296
|
var start = this.range[0];
|
280
297
|
var end = this.range[1];
|
281
298
|
onChange(new time_2.default({
|
282
299
|
// 赋值时将毫秒数清零
|
283
|
-
start: start === null || start === void 0 ? void 0 : start.milliseconds(0),
|
284
|
-
end: end === null || end === void 0 ? void 0 : end.milliseconds(0),
|
300
|
+
start: showTime === false ? start === null || start === void 0 ? void 0 : start.startOf('day') : start === null || start === void 0 ? void 0 : start.milliseconds(0),
|
301
|
+
end: showTime === false ? end === null || end === void 0 ? void 0 : end.startOf('day') : end === null || end === void 0 ? void 0 : end.milliseconds(0),
|
285
302
|
rangePreset: this.rangePreset
|
286
303
|
}));
|
287
304
|
}
|
@@ -340,22 +357,26 @@ var Base = /** @class */ (function (_super) {
|
|
340
357
|
};
|
341
358
|
Base.prototype.renderRelativeContent = function () {
|
342
359
|
var _a;
|
360
|
+
var _b, _c, _d, _e;
|
343
361
|
var locale = this.context.locale;
|
344
|
-
var fromNum = _.get(this.relative, 'from.num',
|
345
|
-
|
346
|
-
var
|
347
|
-
|
362
|
+
var fromNum = _.get(this.relative, 'from.num', ((_b = this.props.defaultRelativeValue) === null || _b === void 0 ? void 0 : _b.from.num) ||
|
363
|
+
exports.RELATIVE_DEFAULT_VALUE.FROM_NUM);
|
364
|
+
var fromUnit = _.get(this.relative, 'from.unit', ((_c = this.props.defaultRelativeValue) === null || _c === void 0 ? void 0 : _c.from.unit) ||
|
365
|
+
exports.RELATIVE_DEFAULT_VALUE.FROM_UNIT);
|
366
|
+
var toNum = _.get(this.relative, 'to.num', ((_d = this.props.defaultRelativeValue) === null || _d === void 0 ? void 0 : _d.to.num) || exports.RELATIVE_DEFAULT_VALUE.TO_NUM);
|
367
|
+
var toUnit = _.get(this.relative, 'to.unit', ((_e = this.props.defaultRelativeValue) === null || _e === void 0 ? void 0 : _e.to.unit) || exports.RELATIVE_DEFAULT_VALUE.TO_UNIT);
|
368
|
+
var _f = this.props, relativeStartTimeUnits = _f.relativeStartTimeUnits, relativeEndTimeUnits = _f.relativeEndTimeUnits, relativeTimeUnits = _f.relativeTimeUnits;
|
348
369
|
if (!this.isRangePicker()) {
|
349
370
|
return (React.createElement("div", { className: style_1.SDK_PREFIX + "-datetime-pick-content" },
|
350
371
|
React.createElement("div", { className: style_1.SDK_PREFIX + "-datetime-pick-relative-container" },
|
351
|
-
React.createElement(relativeTimePicker_1.default, { className: style_1.SDK_PREFIX + "-datetime-pick-relative", num: fromNum, unit: fromUnit, onChange: this.handleRetiveTimeFromChange, relativeTimeUnits:
|
372
|
+
React.createElement(relativeTimePicker_1.default, { className: style_1.SDK_PREFIX + "-datetime-pick-relative", num: fromNum, unit: fromUnit, onChange: this.handleRetiveTimeFromChange, relativeTimeUnits: relativeStartTimeUnits || relativeTimeUnits }),
|
352
373
|
React.createElement(Button_1.default, { disabled: !this.isRelativeTimeValid, className: style_1.SDK_PREFIX + "-datetime-pick-relative-confirm", onClick: this.handleRelativeChange }, language_1.formatString(type_1.DateTimeLocale.confirm, locale)))));
|
353
374
|
}
|
354
375
|
return (React.createElement("div", { className: style_1.SDK_PREFIX + "-datetime-pick-content" },
|
355
376
|
React.createElement("div", { className: style_1.SDK_PREFIX + "-datetime-pick-relative-container" },
|
356
|
-
React.createElement(relativeTimePicker_1.default, { className: style_1.SDK_PREFIX + "-datetime-pick-relative-timepicker", num: fromNum, unit: fromUnit, onChange: this.handleRetiveTimeFromChange, relativeTimeUnits:
|
377
|
+
React.createElement(relativeTimePicker_1.default, { className: style_1.SDK_PREFIX + "-datetime-pick-relative-timepicker", num: fromNum, unit: fromUnit, onChange: this.handleRetiveTimeFromChange, relativeTimeUnits: relativeStartTimeUnits || relativeTimeUnits, withoutNow: true }),
|
357
378
|
React.createElement("span", { className: style_1.SDK_PREFIX + "-datetime-pick-relative-container-to" }, language_1.formatString(type_1.DateTimeLocale.to, locale)),
|
358
|
-
React.createElement(relativeTimePicker_1.default, { className: style_1.SDK_PREFIX + "-datetime-pick-relative-timepicker", num: toNum, unit: toUnit, onChange: this.handleRetiveTimeToChange, relativeTimeUnits:
|
379
|
+
React.createElement(relativeTimePicker_1.default, { className: style_1.SDK_PREFIX + "-datetime-pick-relative-timepicker", num: toNum, unit: toUnit, onChange: this.handleRetiveTimeToChange, relativeTimeUnits: relativeEndTimeUnits || relativeTimeUnits })),
|
359
380
|
React.createElement("div", { className: classnames_1.default(style_1.SDK_PREFIX + "-datetime-pick-relative-footer", (_a = {},
|
360
381
|
_a[style_1.SDK_PREFIX + "-datetime-pick-relative-footer-witNow"] = toUnit === constants_1.RelativeUnitValue.NowStatic,
|
361
382
|
_a)) },
|
@@ -533,6 +554,12 @@ var Base = /** @class */ (function (_super) {
|
|
533
554
|
__metadata("design:paramtypes", [Object]),
|
534
555
|
__metadata("design:returntype", void 0)
|
535
556
|
], Base.prototype, "setRelative", null);
|
557
|
+
__decorate([
|
558
|
+
bind_1.default,
|
559
|
+
__metadata("design:type", Function),
|
560
|
+
__metadata("design:paramtypes", [Array]),
|
561
|
+
__metadata("design:returntype", void 0)
|
562
|
+
], Base.prototype, "getRelativeMap", null);
|
536
563
|
__decorate([
|
537
564
|
bind_1.default,
|
538
565
|
__metadata("design:type", Function),
|
@@ -72,16 +72,19 @@ var RetiveTimePicker = /** @class */ (function (_super) {
|
|
72
72
|
return _this.containerRef.current || document.body;
|
73
73
|
};
|
74
74
|
_this.shouldShowInput = function () {
|
75
|
-
var
|
76
|
-
|
75
|
+
var _a;
|
76
|
+
var _b = _this.props, unit = _b.unit, relativeTimeUnits = _b.relativeTimeUnits;
|
77
|
+
return (unit !== constants_1.RelativeUnitValue.Now &&
|
78
|
+
unit !== constants_1.RelativeUnitValue.NowStatic &&
|
79
|
+
((_a = lodash_1.find(relativeTimeUnits || constants_1.RELATIVE_TIME_UNITS, function (item) { return item.value === unit; })) === null || _a === void 0 ? void 0 : _a.static) !== true);
|
77
80
|
};
|
78
81
|
return _this;
|
79
82
|
}
|
80
83
|
RetiveTimePicker.prototype.render = function () {
|
81
|
-
var _a = this.props, num = _a.num, unit = _a.unit, className = _a.className, withoutNow = _a.withoutNow;
|
84
|
+
var _a = this.props, num = _a.num, unit = _a.unit, className = _a.className, withoutNow = _a.withoutNow, relativeTimeUnits = _a.relativeTimeUnits;
|
82
85
|
var locale = this.context.locale;
|
83
|
-
var options =
|
84
|
-
constants_1.
|
86
|
+
var options = relativeTimeUnits ||
|
87
|
+
constants_1.RELATIVE_TIME_UNITS.map(function (option) {
|
85
88
|
return {
|
86
89
|
text: language_1.formatString(option.text, locale),
|
87
90
|
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;
|
@@ -247,7 +247,7 @@ var RelativeUnitValue;
|
|
247
247
|
RelativeUnitValue["Quarter"] = "Q";
|
248
248
|
RelativeUnitValue["Year"] = "y";
|
249
249
|
})(RelativeUnitValue = exports.RelativeUnitValue || (exports.RelativeUnitValue = {}));
|
250
|
-
exports.
|
250
|
+
exports.RELATIVE_TIME_UNITS = [
|
251
251
|
{
|
252
252
|
text: type_1.DateTimeLocale.relative.now,
|
253
253
|
value: RelativeUnitValue.Now,
|
@@ -299,15 +299,13 @@ exports.relativeTimeUnits = [
|
|
299
299
|
time: function (num) { return moment_1.default().subtract(num, 'years'); }
|
300
300
|
}
|
301
301
|
];
|
302
|
-
exports.relativeTimeUnitsWithoutNowStatic = exports.
|
303
|
-
.filter(function (item) { return item.value !== RelativeUnitValue.NowStatic; })
|
304
|
-
.map(function (item) {
|
302
|
+
exports.relativeTimeUnitsWithoutNowStatic = exports.RELATIVE_TIME_UNITS.filter(function (item) { return item.value !== RelativeUnitValue.NowStatic; }).map(function (item) {
|
305
303
|
return item.value === RelativeUnitValue.Now
|
306
304
|
? __assign(__assign({}, item), { text: type_1.DateTimeLocale.relative.now_text }) : __assign({}, item);
|
307
305
|
});
|
308
306
|
exports.relativeMap = (function () {
|
309
307
|
var res = {};
|
310
|
-
exports.
|
308
|
+
exports.RELATIVE_TIME_UNITS.forEach(function (relative) {
|
311
309
|
res[relative.value] = relative;
|
312
310
|
});
|
313
311
|
return res;
|
@@ -39,7 +39,7 @@ var Time = /** @class */ (function () {
|
|
39
39
|
this.isPointPicker = options.isPointPicker;
|
40
40
|
this.quarterTime = time.quarterTime;
|
41
41
|
this.presetMap = this.getPresetMap(lodash_1.isEmpty(options.presets) ? constants_1.defaultPresets : options.presets);
|
42
|
-
this.relativeMap = this.getRelativeMap(lodash_1.isEmpty(options.relatives) ? constants_1.
|
42
|
+
this.relativeMap = this.getRelativeMap(lodash_1.isEmpty(options.relatives) ? constants_1.RELATIVE_TIME_UNITS : options.relatives);
|
43
43
|
}
|
44
44
|
Time.toMoment = function (time) {
|
45
45
|
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;
|
@@ -68,12 +68,13 @@ function getRelativeTime(timeShift, time) {
|
|
68
68
|
}
|
69
69
|
}
|
70
70
|
exports.getRelativeTime = getRelativeTime;
|
71
|
-
function calcFullTime(time) {
|
71
|
+
function calcFullTime(time, options) {
|
72
|
+
if (options === void 0) { options = {}; }
|
72
73
|
if (!time) {
|
73
74
|
return;
|
74
75
|
}
|
75
76
|
var timeShift = time.timeShift;
|
76
|
-
var _a = new time_1.default(transformToTime(time)).toDate(), start = _a.start, end = _a.end;
|
77
|
+
var _a = new time_1.default(transformToTime(time), options).toDate(), start = _a.start, end = _a.end;
|
77
78
|
var relativeStart = timeShift && start ? getRelativeTime(timeShift, start) : start;
|
78
79
|
var relativeEnd = timeShift && end ? getRelativeTime(timeShift, end) : end;
|
79
80
|
return {
|
@@ -57,27 +57,39 @@ export declare type IDrawerProps = Overwrite<DrawerProps, {
|
|
57
57
|
* 是否允许拖拽
|
58
58
|
*/
|
59
59
|
canDrag?: boolean;
|
60
|
+
/**
|
61
|
+
* 关闭按钮显示的位置,默认left
|
62
|
+
*/
|
60
63
|
closeIconPlacement?: 'left' | 'right';
|
61
64
|
/**
|
62
65
|
* 无遮罩时点击空白处中的哪些元素不关闭
|
63
66
|
*/
|
64
67
|
nonCloseSelector?: string;
|
65
68
|
size?: 'small' | 'default' | 'large';
|
69
|
+
/**
|
70
|
+
* 是否显示全屏按钮
|
71
|
+
*/
|
72
|
+
showFullScreen?: boolean;
|
73
|
+
onScreenFullChange?: (showFullScreen: boolean) => void;
|
66
74
|
}>;
|
67
75
|
export declare class Drawer extends React.Component<React.PropsWithChildren<IDrawerProps>, any> {
|
68
76
|
drawerId: string;
|
69
77
|
isResizing: boolean;
|
70
78
|
realWidth: React.ReactText;
|
79
|
+
isFullscreen: boolean;
|
71
80
|
throttleMouseMove: import("lodash").DebouncedFunc<(e: any) => void>;
|
72
81
|
get closable(): boolean | undefined;
|
73
|
-
get extra():
|
82
|
+
get extra(): JSX.Element;
|
74
83
|
setIsResizing(isResizing?: boolean): void;
|
75
84
|
setRealWidth(realWidth: string | number): void;
|
85
|
+
setIsFullscreen(isFullscreen: boolean): void;
|
86
|
+
handleFull(): void;
|
76
87
|
onMouseDown(): void;
|
77
88
|
onMouseUp(): void;
|
78
89
|
onMouseMove(e: any): void;
|
79
90
|
onMouseClick(e: MouseEvent): void;
|
80
91
|
initWidth(width?: string | number, size?: string): React.ReactText;
|
92
|
+
handleClose(e: EventType | null): void;
|
81
93
|
componentDidMount(): void;
|
82
94
|
UNSAFE_componentWillUpdate(nextProps: Readonly<React.PropsWithChildren<IDrawerProps>>): void;
|
83
95
|
componentWillUnmount(): void;
|
@@ -136,12 +148,20 @@ declare const _default: (props: {
|
|
136
148
|
* 是否允许拖拽
|
137
149
|
*/
|
138
150
|
canDrag?: boolean | undefined;
|
151
|
+
/**
|
152
|
+
* 关闭按钮显示的位置,默认left
|
153
|
+
*/
|
139
154
|
closeIconPlacement?: import("antd/es/collapse/Collapse").ExpandIconPosition;
|
140
155
|
/**
|
141
156
|
* 无遮罩时点击空白处中的哪些元素不关闭
|
142
157
|
*/
|
143
158
|
nonCloseSelector?: string | undefined;
|
144
159
|
size?: "small" | "default" | "large" | undefined;
|
160
|
+
/**
|
161
|
+
* 是否显示全屏按钮
|
162
|
+
*/
|
163
|
+
showFullScreen?: boolean | undefined;
|
164
|
+
onScreenFullChange?: ((showFullScreen: boolean) => void) | undefined;
|
145
165
|
} & Pick<DrawerProps, "style" | "autoFocus" | "prefixCls" | "footer" | "extra" | "bodyStyle" | "forceRender" | "keyboard" | "destroyOnClose" | "closeIcon" | "drawerStyle" | "headerStyle" | "contentWrapperStyle" | "push" | "handler" | "footerStyle" | "level" | "levelMove"> & {
|
146
166
|
children?: React.ReactNode;
|
147
167
|
} & {
|
@@ -53,14 +53,16 @@ var lodash_1 = require("lodash");
|
|
53
53
|
var mobx_react_1 = require("mobx-react");
|
54
54
|
var mobx_1 = require("mobx");
|
55
55
|
var antd_1 = require("antd");
|
56
|
+
var screenfull_1 = __importDefault(require("screenfull"));
|
57
|
+
var pandora_component_icons_1 = require("@qn-pandora/pandora-component-icons");
|
56
58
|
var dom_1 = require("../../utils/dom");
|
57
59
|
var style_1 = require("../../constants/style");
|
58
60
|
var modalPopupContainer_1 = __importDefault(require("../../hoc/modalPopupContainer"));
|
59
61
|
var bind_1 = __importDefault(require("../../utils/bind"));
|
60
62
|
var CloseIcon_1 = __importDefault(require("./CloseIcon"));
|
61
|
-
var DEFAULT_WIDTH =
|
62
|
-
var SMALL_WIDTH =
|
63
|
-
var LARGE_WIDTH =
|
63
|
+
var DEFAULT_WIDTH = '50%';
|
64
|
+
var SMALL_WIDTH = '38%';
|
65
|
+
var LARGE_WIDTH = '75%';
|
64
66
|
var MAX_WIDTH = 6000;
|
65
67
|
var MIN_WIDTH = 300;
|
66
68
|
var Drawer = /** @class */ (function (_super) {
|
@@ -70,6 +72,7 @@ var Drawer = /** @class */ (function (_super) {
|
|
70
72
|
_this.drawerId = "drawer-id-" + Math.floor(Math.random() * 10000);
|
71
73
|
_this.isResizing = false;
|
72
74
|
_this.realWidth = _this.initWidth(_this.props.width, _this.props.size);
|
75
|
+
_this.isFullscreen = false;
|
73
76
|
_this.throttleMouseMove = lodash_1.throttle(function (e) { return _this.onMouseMove(e); }, 100);
|
74
77
|
return _this;
|
75
78
|
}
|
@@ -87,13 +90,17 @@ var Drawer = /** @class */ (function (_super) {
|
|
87
90
|
});
|
88
91
|
Object.defineProperty(Drawer.prototype, "extra", {
|
89
92
|
get: function () {
|
90
|
-
var _a = this.props, closable = _a.closable, closeIconPlacement = _a.closeIconPlacement,
|
93
|
+
var _a = this.props, closable = _a.closable, closeIconPlacement = _a.closeIconPlacement, showFullScreen = _a.showFullScreen;
|
94
|
+
var fullIcon = showFullScreen === true ? (this.isFullscreen ? (react_1.default.createElement(pandora_component_icons_1.FullscreenExitOutlined, { onClick: this.handleFull, className: style_1.SDK_PREFIX + "-drawer-header-full-icon" })) : (react_1.default.createElement(pandora_component_icons_1.FullscreenOutlined, { onClick: this.handleFull, className: style_1.SDK_PREFIX + "-drawer-header-full-icon" }))) : null;
|
91
95
|
if (closable !== false && closeIconPlacement === 'right') {
|
92
96
|
return (react_1.default.createElement(react_1.default.Fragment, null,
|
93
97
|
this.props.extra,
|
94
|
-
|
98
|
+
fullIcon,
|
99
|
+
react_1.default.createElement(CloseIcon_1.default, { className: style_1.SDK_PREFIX + "-drawer-close-icon", onClick: this.handleClose })));
|
95
100
|
}
|
96
|
-
return
|
101
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
102
|
+
fullIcon,
|
103
|
+
this.props.extra));
|
97
104
|
},
|
98
105
|
enumerable: true,
|
99
106
|
configurable: true
|
@@ -105,6 +112,17 @@ var Drawer = /** @class */ (function (_super) {
|
|
105
112
|
Drawer.prototype.setRealWidth = function (realWidth) {
|
106
113
|
this.realWidth = realWidth;
|
107
114
|
};
|
115
|
+
Drawer.prototype.setIsFullscreen = function (isFullscreen) {
|
116
|
+
this.isFullscreen = isFullscreen;
|
117
|
+
};
|
118
|
+
Drawer.prototype.handleFull = function () {
|
119
|
+
var draw = document.querySelector("." + this.drawerId);
|
120
|
+
if (!screenfull_1.default || !draw) {
|
121
|
+
return;
|
122
|
+
}
|
123
|
+
this.setIsFullscreen(!this.isFullscreen);
|
124
|
+
screenfull_1.default.toggle(draw);
|
125
|
+
};
|
108
126
|
Drawer.prototype.onMouseDown = function () {
|
109
127
|
this.setIsResizing(true);
|
110
128
|
};
|
@@ -123,7 +141,10 @@ var Drawer = /** @class */ (function (_super) {
|
|
123
141
|
}
|
124
142
|
};
|
125
143
|
Drawer.prototype.onMouseClick = function (e) {
|
126
|
-
var _a
|
144
|
+
var _a;
|
145
|
+
var _b = this.props, mask = _b.mask, maskClosable = _b.maskClosable, nonCloseSelector = _b.nonCloseSelector, visible = _b.visible;
|
146
|
+
if (this.isResizing)
|
147
|
+
return;
|
127
148
|
if (mask === false && maskClosable && visible) {
|
128
149
|
var currentEl = e.target;
|
129
150
|
var shouldClose = true;
|
@@ -142,7 +163,7 @@ var Drawer = /** @class */ (function (_super) {
|
|
142
163
|
currentEl = currentEl.parentElement;
|
143
164
|
}
|
144
165
|
if (shouldClose) {
|
145
|
-
|
166
|
+
(_a = this.handleClose) === null || _a === void 0 ? void 0 : _a.call(this, null);
|
146
167
|
}
|
147
168
|
}
|
148
169
|
};
|
@@ -156,12 +177,32 @@ var Drawer = /** @class */ (function (_super) {
|
|
156
177
|
return LARGE_WIDTH;
|
157
178
|
return DEFAULT_WIDTH;
|
158
179
|
};
|
180
|
+
Drawer.prototype.handleClose = function (e) {
|
181
|
+
var _a = this.props, onClose = _a.onClose, showFullScreen = _a.showFullScreen;
|
182
|
+
if (onClose) {
|
183
|
+
onClose(e);
|
184
|
+
// 如果在全屏的状态下关闭抽屉,需要将关闭全屏
|
185
|
+
if (showFullScreen && this.isFullscreen) {
|
186
|
+
this.handleFull();
|
187
|
+
}
|
188
|
+
}
|
189
|
+
};
|
159
190
|
Drawer.prototype.componentDidMount = function () {
|
191
|
+
document.body.addEventListener('mousedown', this.onMouseClick);
|
192
|
+
var onScreenFullChange = this.props.onScreenFullChange;
|
193
|
+
if (this.props.showFullScreen) {
|
194
|
+
if (screenfull_1.default && onScreenFullChange) {
|
195
|
+
screenfull_1.default.on('change', function () {
|
196
|
+
if (screenfull_1.default) {
|
197
|
+
onScreenFullChange(screenfull_1.default.isFullscreen);
|
198
|
+
}
|
199
|
+
});
|
200
|
+
}
|
201
|
+
}
|
160
202
|
if (this.props.canDrag) {
|
161
203
|
document.addEventListener('mousemove', this.throttleMouseMove);
|
162
204
|
document.addEventListener('mouseup', this.onMouseUp);
|
163
205
|
}
|
164
|
-
document.body.addEventListener('click', this.onMouseClick);
|
165
206
|
};
|
166
207
|
Drawer.prototype.UNSAFE_componentWillUpdate = function (nextProps) {
|
167
208
|
if (nextProps.canDrag && !this.props.canDrag) {
|
@@ -179,10 +220,7 @@ var Drawer = /** @class */ (function (_super) {
|
|
179
220
|
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"]);
|
180
221
|
return (react_1.default.createElement(antd_1.Drawer, __assign({ className: classnames_1.default(this.drawerId, style_1.SDK_PREFIX + "-drawer", className, (_a = {},
|
181
222
|
_a[style_1.SDK_PREFIX + "-drawer-no-mask"] = this.props.mask === false,
|
182
|
-
_a
|
183
|
-
_a[style_1.SDK_PREFIX + "-drawer-size-default"] = size === 'default',
|
184
|
-
_a[style_1.SDK_PREFIX + "-drawer-size-large"] = size === 'large',
|
185
|
-
_a)), width: this.realWidth || 800, zIndex: 1200, visible: visible, closable: this.closable, extra: this.extra, closeIcon: react_1.default.createElement(CloseIcon_1.default, { className: style_1.SDK_PREFIX + "-drawer-close-icon", onClick: onClose }), onClose: onClose }, other),
|
223
|
+
_a)), width: this.realWidth || 800, zIndex: 1200, visible: visible, closable: this.closable, extra: this.extra, closeIcon: react_1.default.createElement(CloseIcon_1.default, { className: style_1.SDK_PREFIX + "-drawer-close-icon", onClick: this.handleClose }), onClose: this.handleClose }, other),
|
186
224
|
canDrag && (react_1.default.createElement("div", { className: style_1.SDK_PREFIX + "-scroll-handler", onMouseDown: this.onMouseDown })),
|
187
225
|
children));
|
188
226
|
};
|
@@ -194,6 +232,10 @@ var Drawer = /** @class */ (function (_super) {
|
|
194
232
|
mobx_1.observable,
|
195
233
|
__metadata("design:type", Object)
|
196
234
|
], Drawer.prototype, "realWidth", void 0);
|
235
|
+
__decorate([
|
236
|
+
mobx_1.observable,
|
237
|
+
__metadata("design:type", Boolean)
|
238
|
+
], Drawer.prototype, "isFullscreen", void 0);
|
197
239
|
__decorate([
|
198
240
|
mobx_1.computed,
|
199
241
|
__metadata("design:type", Object),
|
@@ -218,6 +260,19 @@ var Drawer = /** @class */ (function (_super) {
|
|
218
260
|
__metadata("design:paramtypes", [Object]),
|
219
261
|
__metadata("design:returntype", void 0)
|
220
262
|
], Drawer.prototype, "setRealWidth", null);
|
263
|
+
__decorate([
|
264
|
+
bind_1.default,
|
265
|
+
mobx_1.action,
|
266
|
+
__metadata("design:type", Function),
|
267
|
+
__metadata("design:paramtypes", [Boolean]),
|
268
|
+
__metadata("design:returntype", void 0)
|
269
|
+
], Drawer.prototype, "setIsFullscreen", null);
|
270
|
+
__decorate([
|
271
|
+
bind_1.default,
|
272
|
+
__metadata("design:type", Function),
|
273
|
+
__metadata("design:paramtypes", []),
|
274
|
+
__metadata("design:returntype", void 0)
|
275
|
+
], Drawer.prototype, "handleFull", null);
|
221
276
|
__decorate([
|
222
277
|
bind_1.default,
|
223
278
|
__metadata("design:type", Function),
|
@@ -248,6 +303,12 @@ var Drawer = /** @class */ (function (_super) {
|
|
248
303
|
__metadata("design:paramtypes", [Object, String]),
|
249
304
|
__metadata("design:returntype", void 0)
|
250
305
|
], Drawer.prototype, "initWidth", null);
|
306
|
+
__decorate([
|
307
|
+
bind_1.default,
|
308
|
+
__metadata("design:type", Function),
|
309
|
+
__metadata("design:paramtypes", [Object]),
|
310
|
+
__metadata("design:returntype", void 0)
|
311
|
+
], Drawer.prototype, "handleClose", null);
|
251
312
|
Drawer = __decorate([
|
252
313
|
mobx_react_1.observer
|
253
314
|
], Drawer);
|
@@ -263,6 +263,9 @@
|
|
263
263
|
height: 60px;
|
264
264
|
line-height: 60px;
|
265
265
|
}
|
266
|
+
.pandora-sdk-drawer .ant-drawer-header-title {
|
267
|
+
overflow: hidden;
|
268
|
+
}
|
266
269
|
.pandora-sdk-drawer-size-small {
|
267
270
|
max-width: 38%;
|
268
271
|
}
|
@@ -288,3 +291,11 @@
|
|
288
291
|
.pandora-sdk-drawer-close-icon {
|
289
292
|
margin-left: 24px;
|
290
293
|
}
|
294
|
+
.pandora-sdk-drawer-header-full-icon {
|
295
|
+
margin-left: 24px;
|
296
|
+
color: #333;
|
297
|
+
font-size: 14px;
|
298
|
+
}
|
299
|
+
.pandora-sdk-drawer-no-mask {
|
300
|
+
background-color: #ffffff;
|
301
|
+
}
|