@qn-pandora/pandora-component 4.2.0 → 4.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (30) hide show
  1. package/CHANGELOG.json +21 -1
  2. package/CHANGELOG.md +9 -2
  3. package/es/components/DateTimePicker/Base/index.d.ts +6 -1
  4. package/es/components/DateTimePicker/Base/index.js +44 -17
  5. package/es/components/DateTimePicker/Base/relativeTimePicker.js +10 -7
  6. package/es/components/DateTimePicker/constants.d.ts +57 -1
  7. package/es/components/DateTimePicker/constants.js +3 -5
  8. package/es/components/DateTimePicker/time.js +2 -2
  9. package/es/components/DateTimePicker/transform.d.ts +5 -1
  10. package/es/components/DateTimePicker/transform.js +3 -2
  11. package/es/components/Drawer/index.d.ts +1 -0
  12. package/es/components/Drawer/index.js +22 -5
  13. package/es/components/Drawer/style.css +3 -0
  14. package/es/components/Drawer/style.less +4 -0
  15. package/es/index.css +43 -40
  16. package/es/index.less +3 -3
  17. package/lib/components/DateTimePicker/Base/index.d.ts +6 -1
  18. package/lib/components/DateTimePicker/Base/index.js +43 -16
  19. package/lib/components/DateTimePicker/Base/relativeTimePicker.js +8 -5
  20. package/lib/components/DateTimePicker/constants.d.ts +57 -1
  21. package/lib/components/DateTimePicker/constants.js +3 -5
  22. package/lib/components/DateTimePicker/time.js +1 -1
  23. package/lib/components/DateTimePicker/transform.d.ts +5 -1
  24. package/lib/components/DateTimePicker/transform.js +3 -2
  25. package/lib/components/Drawer/index.d.ts +1 -0
  26. package/lib/components/Drawer/index.js +22 -5
  27. package/lib/components/Drawer/style.css +3 -0
  28. package/lib/components/Drawer/style.less +4 -0
  29. package/lib/index.css +3 -0
  30. package/package.json +3 -3
package/CHANGELOG.json CHANGED
@@ -1,10 +1,30 @@
1
1
  {
2
2
  "name": "@qn-pandora/pandora-component",
3
3
  "entries": [
4
+ {
5
+ "version": "4.3.0",
6
+ "tag": "@qn-pandora/pandora-component_v4.3.0",
7
+ "date": "Tue, 24 Oct 2023 08:06:30 GMT",
8
+ "comments": {
9
+ "minor": [
10
+ {
11
+ "comment": "2023-10-24发包"
12
+ }
13
+ ],
14
+ "dependency": [
15
+ {
16
+ "comment": "Updating dependency \"@qn-pandora/pandora-component-icons\" from `^3.2.0` to `^3.3.0`"
17
+ },
18
+ {
19
+ "comment": "Updating dependency \"@qn-pandora/app-sdk\" from `^3.2.0` to `^3.3.0`"
20
+ }
21
+ ]
22
+ }
23
+ },
4
24
  {
5
25
  "version": "4.2.0",
6
26
  "tag": "@qn-pandora/pandora-component_v4.2.0",
7
- "date": "Mon, 25 Sep 2023 06:36:41 GMT",
27
+ "date": "Mon, 25 Sep 2023 07:36:39 GMT",
8
28
  "comments": {
9
29
  "minor": [
10
30
  {
package/CHANGELOG.md CHANGED
@@ -1,9 +1,16 @@
1
1
  # Change Log - @qn-pandora/pandora-component
2
2
 
3
- This log was last generated on Mon, 25 Sep 2023 06:36:41 GMT and should not be manually modified.
3
+ This log was last generated on Tue, 24 Oct 2023 08:06:30 GMT and should not be manually modified.
4
+
5
+ ## 4.3.0
6
+ Tue, 24 Oct 2023 08:06:30 GMT
7
+
8
+ ### Minor changes
9
+
10
+ - 2023-10-24发包
4
11
 
5
12
  ## 4.2.0
6
- Mon, 25 Sep 2023 06:36:41 GMT
13
+ Mon, 25 Sep 2023 07:36:39 GMT
7
14
 
8
15
  ### Minor changes
9
16
 
@@ -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, relativeMap, RangePreset, rangePresetOptions, TimeType, RelativeUnitValue } from '../constants';
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: RELATIVE_DEFAULT_VALUE.FROM_NUM,
80
- unit: RELATIVE_DEFAULT_VALUE.FROM_UNIT
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: RELATIVE_DEFAULT_VALUE.TO_NUM,
84
- unit: RELATIVE_DEFAULT_VALUE.TO_UNIT
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 fromDate = relativeMap[from.unit].time(from.num).valueOf();
238
- var toDate = relativeMap[to.unit].time(to.num).valueOf();
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 onChange = this.props.onChange;
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', RELATIVE_DEFAULT_VALUE.FROM_NUM);
333
- var fromUnit = _.get(this.relative, 'from.unit', RELATIVE_DEFAULT_VALUE.FROM_UNIT);
334
- var toNum = _.get(this.relative, 'to.num', RELATIVE_DEFAULT_VALUE.TO_NUM);
335
- var toUnit = _.get(this.relative, 'to.unit', RELATIVE_DEFAULT_VALUE.TO_UNIT);
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: this.props.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: this.props.relativeTimeUnits, withoutNow: true }),
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: this.props.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 { relativeTimeUnits, RelativeUnitValue } from '../constants';
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 unit = _this.props.unit;
64
- return (unit !== RelativeUnitValue.Now && unit !== RelativeUnitValue.NowStatic);
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 = this.props.relativeTimeUnits ||
72
- relativeTimeUnits.map(function (option) {
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 relativeTimeUnits: IRelativeTimeUnit[];
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 relativeTimeUnits = [
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 = relativeTimeUnits
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
- relativeTimeUnits.forEach(function (relative) {
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, relativeTimeUnits, RelativeUnitValue, RangePreset, QuartersMap } from './constants';
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) ? relativeTimeUnits : 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 {
@@ -89,6 +89,7 @@ export declare class Drawer extends React.Component<React.PropsWithChildren<IDra
89
89
  onMouseMove(e: any): void;
90
90
  onMouseClick(e: MouseEvent): void;
91
91
  initWidth(width?: string | number, size?: string): React.ReactText;
92
+ handleClose(e: EventType | null): void;
92
93
  componentDidMount(): void;
93
94
  UNSAFE_componentWillUpdate(nextProps: Readonly<React.PropsWithChildren<IDrawerProps>>): void;
94
95
  componentWillUnmount(): void;
@@ -85,13 +85,13 @@ var Drawer = /** @class */ (function (_super) {
85
85
  });
86
86
  Object.defineProperty(Drawer.prototype, "extra", {
87
87
  get: function () {
88
- var _a = this.props, closable = _a.closable, closeIconPlacement = _a.closeIconPlacement, onClose = _a.onClose, showFullScreen = _a.showFullScreen;
88
+ var _a = this.props, closable = _a.closable, closeIconPlacement = _a.closeIconPlacement, showFullScreen = _a.showFullScreen;
89
89
  var fullIcon = showFullScreen === true ? (this.isFullscreen ? (React.createElement(FullscreenExitOutlined, { onClick: this.handleFull, className: SDK_PREFIX + "-drawer-header-full-icon" })) : (React.createElement(FullscreenOutlined, { onClick: this.handleFull, className: SDK_PREFIX + "-drawer-header-full-icon" }))) : null;
90
90
  if (closable !== false && closeIconPlacement === 'right') {
91
91
  return (React.createElement(React.Fragment, null,
92
92
  this.props.extra,
93
93
  fullIcon,
94
- React.createElement(CloseIcon, { className: SDK_PREFIX + "-drawer-close-icon", onClick: onClose })));
94
+ React.createElement(CloseIcon, { className: SDK_PREFIX + "-drawer-close-icon", onClick: this.handleClose })));
95
95
  }
96
96
  return (React.createElement(React.Fragment, null,
97
97
  fullIcon,
@@ -136,7 +136,8 @@ var Drawer = /** @class */ (function (_super) {
136
136
  }
137
137
  };
138
138
  Drawer.prototype.onMouseClick = function (e) {
139
- var _a = this.props, mask = _a.mask, maskClosable = _a.maskClosable, nonCloseSelector = _a.nonCloseSelector, onClose = _a.onClose, visible = _a.visible;
139
+ var _a;
140
+ var _b = this.props, mask = _b.mask, maskClosable = _b.maskClosable, nonCloseSelector = _b.nonCloseSelector, visible = _b.visible;
140
141
  if (this.isResizing)
141
142
  return;
142
143
  if (mask === false && maskClosable && visible) {
@@ -157,7 +158,7 @@ var Drawer = /** @class */ (function (_super) {
157
158
  currentEl = currentEl.parentElement;
158
159
  }
159
160
  if (shouldClose) {
160
- onClose === null || onClose === void 0 ? void 0 : onClose(null);
161
+ (_a = this.handleClose) === null || _a === void 0 ? void 0 : _a.call(this, null);
161
162
  }
162
163
  }
163
164
  };
@@ -171,6 +172,16 @@ var Drawer = /** @class */ (function (_super) {
171
172
  return LARGE_WIDTH;
172
173
  return DEFAULT_WIDTH;
173
174
  };
175
+ Drawer.prototype.handleClose = function (e) {
176
+ var _a = this.props, onClose = _a.onClose, showFullScreen = _a.showFullScreen;
177
+ if (onClose) {
178
+ onClose(e);
179
+ // 如果在全屏的状态下关闭抽屉,需要将关闭全屏
180
+ if (showFullScreen && this.isFullscreen) {
181
+ this.handleFull();
182
+ }
183
+ }
184
+ };
174
185
  Drawer.prototype.componentDidMount = function () {
175
186
  document.body.addEventListener('mousedown', this.onMouseClick);
176
187
  var onScreenFullChange = this.props.onScreenFullChange;
@@ -204,7 +215,7 @@ var Drawer = /** @class */ (function (_super) {
204
215
  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
216
  return (React.createElement(BaseDrawer, __assign({ className: classnames(this.drawerId, SDK_PREFIX + "-drawer", className, (_a = {},
206
217
  _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: onClose }), onClose: onClose }, other),
218
+ _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: this.handleClose }), onClose: this.handleClose }, other),
208
219
  canDrag && (React.createElement("div", { className: SDK_PREFIX + "-scroll-handler", onMouseDown: this.onMouseDown })),
209
220
  children));
210
221
  };
@@ -287,6 +298,12 @@ var Drawer = /** @class */ (function (_super) {
287
298
  __metadata("design:paramtypes", [Object, String]),
288
299
  __metadata("design:returntype", void 0)
289
300
  ], Drawer.prototype, "initWidth", null);
301
+ __decorate([
302
+ bind,
303
+ __metadata("design:type", Function),
304
+ __metadata("design:paramtypes", [Object]),
305
+ __metadata("design:returntype", void 0)
306
+ ], Drawer.prototype, "handleClose", null);
290
307
  Drawer = __decorate([
291
308
  observer
292
309
  ], Drawer);
@@ -296,3 +296,6 @@
296
296
  color: #333;
297
297
  font-size: 14px;
298
298
  }
299
+ .pandora-sdk-drawer-no-mask {
300
+ background-color: #ffffff;
301
+ }
@@ -55,3 +55,7 @@
55
55
  color: @font-color-7;
56
56
  font-size: 14px;
57
57
  }
58
+
59
+ .@{sdk-prefix}-drawer-no-mask {
60
+ background-color: @normal-color;
61
+ }
package/es/index.css CHANGED
@@ -5173,6 +5173,9 @@ textarea.ant-input {
5173
5173
  color: #333;
5174
5174
  font-size: 14px;
5175
5175
  }
5176
+ .pandora-sdk-drawer-no-mask {
5177
+ background-color: #d9d9d9;
5178
+ }
5176
5179
  .ant-upload {
5177
5180
  -webkit-box-sizing: border-box;
5178
5181
  box-sizing: border-box;
@@ -20410,6 +20413,18 @@ _:-ms-fullscreen .ant-picker-range-wrapper .ant-picker-year-panel .ant-picker-ce
20410
20413
  .pandora-sdk-modal-close-icon:hover {
20411
20414
  background: #f4f5f6;
20412
20415
  }
20416
+ .pandora-sdk-popover-inline-list {
20417
+ display: inline-block;
20418
+ vertical-align: middle;
20419
+ }
20420
+ .pandora-sdk-popover-inline-list .pandora-sdk-popover-inline-item {
20421
+ display: inline-block;
20422
+ height: 100%;
20423
+ margin-right: 12px;
20424
+ }
20425
+ .pandora-sdk-popover-inline-list .pandora-sdk-popover-inline-item i {
20426
+ color: #2c6dd2;
20427
+ }
20413
20428
  .pandora-sdk-item {
20414
20429
  color: #2c6dd2;
20415
20430
  cursor: pointer;
@@ -20432,18 +20447,6 @@ _:-ms-fullscreen .ant-picker-range-wrapper .ant-picker-year-panel .ant-picker-ce
20432
20447
  color: inherit;
20433
20448
  cursor: inherit;
20434
20449
  }
20435
- .pandora-sdk-popover-inline-list {
20436
- display: inline-block;
20437
- vertical-align: middle;
20438
- }
20439
- .pandora-sdk-popover-inline-list .pandora-sdk-popover-inline-item {
20440
- display: inline-block;
20441
- height: 100%;
20442
- margin-right: 12px;
20443
- }
20444
- .pandora-sdk-popover-inline-list .pandora-sdk-popover-inline-item i {
20445
- color: #2c6dd2;
20446
- }
20447
20450
  .pandora-sdk-popover-item {
20448
20451
  display: inline-block;
20449
20452
  line-height: 18px;
@@ -20726,34 +20729,6 @@ _:-ms-fullscreen .ant-picker-range-wrapper .ant-picker-year-panel .ant-picker-ce
20726
20729
  .pandora-sdk-transfer-list-body .pandora-sdk-transfer-mb10 {
20727
20730
  margin-bottom: 10px;
20728
20731
  }
20729
- .pandora-sdk-panel-title {
20730
- display: -webkit-box;
20731
- display: -ms-flexbox;
20732
- display: flex;
20733
- -webkit-box-pack: justify;
20734
- -ms-flex-pack: justify;
20735
- justify-content: space-between;
20736
- font-size: 12px;
20737
- color: #42526e;
20738
- cursor: pointer;
20739
- padding-bottom: 16px;
20740
- border-bottom: 1px solid #d9d9d9;
20741
- }
20742
- .pandora-sdk-panel-title .icon {
20743
- font-size: 14px;
20744
- }
20745
- .pandora-sdk-panel-content {
20746
- padding: 20px 0 0 0;
20747
- }
20748
- .pandora-sdk-panel-hidden {
20749
- display: none;
20750
- }
20751
- .pandora-sdk-panel {
20752
- margin-bottom: 20px;
20753
- }
20754
- .pandora-sdk-panel-disable {
20755
- cursor: default;
20756
- }
20757
20732
  .pandora-sdk-datetime-mobile-pick-range-preset-head {
20758
20733
  display: -webkit-box;
20759
20734
  display: -ms-flexbox;
@@ -20790,3 +20765,31 @@ _:-ms-fullscreen .ant-picker-range-wrapper .ant-picker-year-panel .ant-picker-ce
20790
20765
  border-radius: 2px;
20791
20766
  border: 2px solid #939393;
20792
20767
  }
20768
+ .pandora-sdk-panel-title {
20769
+ display: -webkit-box;
20770
+ display: -ms-flexbox;
20771
+ display: flex;
20772
+ -webkit-box-pack: justify;
20773
+ -ms-flex-pack: justify;
20774
+ justify-content: space-between;
20775
+ font-size: 12px;
20776
+ color: #42526e;
20777
+ cursor: pointer;
20778
+ padding-bottom: 16px;
20779
+ border-bottom: 1px solid #d9d9d9;
20780
+ }
20781
+ .pandora-sdk-panel-title .icon {
20782
+ font-size: 14px;
20783
+ }
20784
+ .pandora-sdk-panel-content {
20785
+ padding: 20px 0 0 0;
20786
+ }
20787
+ .pandora-sdk-panel-hidden {
20788
+ display: none;
20789
+ }
20790
+ .pandora-sdk-panel {
20791
+ margin-bottom: 20px;
20792
+ }
20793
+ .pandora-sdk-panel-disable {
20794
+ cursor: default;
20795
+ }
package/es/index.less CHANGED
@@ -38,8 +38,8 @@
38
38
  @import './components/DateTimePicker/BaseMobile/style.less';
39
39
  @import './components/DateTimePicker/DisplayInput/style.less';
40
40
  @import './components/Drawer/CloseIcon/style.less';
41
- @import './components/OptionList/OptionItem/style.less';
42
41
  @import './components/OptionList/InlineOptionList/style.less';
42
+ @import './components/OptionList/OptionItem/style.less';
43
43
  @import './components/OptionList/PopoverOptionList/style.less';
44
44
  @import './components/Steps/ControlButton/style.less';
45
45
  @import './components/Table/ColumnSetting/style.less';
@@ -49,5 +49,5 @@
49
49
  @import './components/Timeline/TimelineItem/style.less';
50
50
  @import './components/Transfer/List/style.less';
51
51
  @import './components/Transfer/ListBody/style.less';
52
- @import './components/DateTimePicker/Collapse/Panel/style.less';
53
- @import './components/DateTimePicker/BaseMobile/Absolute/style.less';
52
+ @import './components/DateTimePicker/BaseMobile/Absolute/style.less';
53
+ @import './components/DateTimePicker/Collapse/Panel/style.less';
@@ -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: exports.RELATIVE_DEFAULT_VALUE.FROM_NUM,
92
- unit: exports.RELATIVE_DEFAULT_VALUE.FROM_UNIT
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: exports.RELATIVE_DEFAULT_VALUE.TO_NUM,
96
- unit: exports.RELATIVE_DEFAULT_VALUE.TO_UNIT
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 fromDate = constants_1.relativeMap[from.unit].time(from.num).valueOf();
250
- var toDate = constants_1.relativeMap[to.unit].time(to.num).valueOf();
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 onChange = this.props.onChange;
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', exports.RELATIVE_DEFAULT_VALUE.FROM_NUM);
345
- var fromUnit = _.get(this.relative, 'from.unit', exports.RELATIVE_DEFAULT_VALUE.FROM_UNIT);
346
- var toNum = _.get(this.relative, 'to.num', exports.RELATIVE_DEFAULT_VALUE.TO_NUM);
347
- var toUnit = _.get(this.relative, 'to.unit', exports.RELATIVE_DEFAULT_VALUE.TO_UNIT);
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: this.props.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: this.props.relativeTimeUnits, withoutNow: true }),
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: this.props.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 unit = _this.props.unit;
76
- return (unit !== constants_1.RelativeUnitValue.Now && unit !== constants_1.RelativeUnitValue.NowStatic);
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 = this.props.relativeTimeUnits ||
84
- constants_1.relativeTimeUnits.map(function (option) {
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 relativeTimeUnits: IRelativeTimeUnit[];
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.relativeTimeUnits = [
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.relativeTimeUnits
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.relativeTimeUnits.forEach(function (relative) {
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.relativeTimeUnits : options.relatives);
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 {
@@ -89,6 +89,7 @@ export declare class Drawer extends React.Component<React.PropsWithChildren<IDra
89
89
  onMouseMove(e: any): void;
90
90
  onMouseClick(e: MouseEvent): void;
91
91
  initWidth(width?: string | number, size?: string): React.ReactText;
92
+ handleClose(e: EventType | null): void;
92
93
  componentDidMount(): void;
93
94
  UNSAFE_componentWillUpdate(nextProps: Readonly<React.PropsWithChildren<IDrawerProps>>): void;
94
95
  componentWillUnmount(): void;
@@ -90,13 +90,13 @@ var Drawer = /** @class */ (function (_super) {
90
90
  });
91
91
  Object.defineProperty(Drawer.prototype, "extra", {
92
92
  get: function () {
93
- var _a = this.props, closable = _a.closable, closeIconPlacement = _a.closeIconPlacement, onClose = _a.onClose, showFullScreen = _a.showFullScreen;
93
+ var _a = this.props, closable = _a.closable, closeIconPlacement = _a.closeIconPlacement, showFullScreen = _a.showFullScreen;
94
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;
95
95
  if (closable !== false && closeIconPlacement === 'right') {
96
96
  return (react_1.default.createElement(react_1.default.Fragment, null,
97
97
  this.props.extra,
98
98
  fullIcon,
99
- react_1.default.createElement(CloseIcon_1.default, { className: style_1.SDK_PREFIX + "-drawer-close-icon", onClick: onClose })));
99
+ react_1.default.createElement(CloseIcon_1.default, { className: style_1.SDK_PREFIX + "-drawer-close-icon", onClick: this.handleClose })));
100
100
  }
101
101
  return (react_1.default.createElement(react_1.default.Fragment, null,
102
102
  fullIcon,
@@ -141,7 +141,8 @@ var Drawer = /** @class */ (function (_super) {
141
141
  }
142
142
  };
143
143
  Drawer.prototype.onMouseClick = function (e) {
144
- var _a = this.props, mask = _a.mask, maskClosable = _a.maskClosable, nonCloseSelector = _a.nonCloseSelector, onClose = _a.onClose, visible = _a.visible;
144
+ var _a;
145
+ var _b = this.props, mask = _b.mask, maskClosable = _b.maskClosable, nonCloseSelector = _b.nonCloseSelector, visible = _b.visible;
145
146
  if (this.isResizing)
146
147
  return;
147
148
  if (mask === false && maskClosable && visible) {
@@ -162,7 +163,7 @@ var Drawer = /** @class */ (function (_super) {
162
163
  currentEl = currentEl.parentElement;
163
164
  }
164
165
  if (shouldClose) {
165
- onClose === null || onClose === void 0 ? void 0 : onClose(null);
166
+ (_a = this.handleClose) === null || _a === void 0 ? void 0 : _a.call(this, null);
166
167
  }
167
168
  }
168
169
  };
@@ -176,6 +177,16 @@ var Drawer = /** @class */ (function (_super) {
176
177
  return LARGE_WIDTH;
177
178
  return DEFAULT_WIDTH;
178
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
+ };
179
190
  Drawer.prototype.componentDidMount = function () {
180
191
  document.body.addEventListener('mousedown', this.onMouseClick);
181
192
  var onScreenFullChange = this.props.onScreenFullChange;
@@ -209,7 +220,7 @@ var Drawer = /** @class */ (function (_super) {
209
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"]);
210
221
  return (react_1.default.createElement(antd_1.Drawer, __assign({ className: classnames_1.default(this.drawerId, style_1.SDK_PREFIX + "-drawer", className, (_a = {},
211
222
  _a[style_1.SDK_PREFIX + "-drawer-no-mask"] = this.props.mask === false,
212
- _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),
213
224
  canDrag && (react_1.default.createElement("div", { className: style_1.SDK_PREFIX + "-scroll-handler", onMouseDown: this.onMouseDown })),
214
225
  children));
215
226
  };
@@ -292,6 +303,12 @@ var Drawer = /** @class */ (function (_super) {
292
303
  __metadata("design:paramtypes", [Object, String]),
293
304
  __metadata("design:returntype", void 0)
294
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);
295
312
  Drawer = __decorate([
296
313
  mobx_react_1.observer
297
314
  ], Drawer);
@@ -296,3 +296,6 @@
296
296
  color: #333;
297
297
  font-size: 14px;
298
298
  }
299
+ .pandora-sdk-drawer-no-mask {
300
+ background-color: #ffffff;
301
+ }
@@ -55,3 +55,7 @@
55
55
  color: @font-color-7;
56
56
  font-size: 14px;
57
57
  }
58
+
59
+ .@{sdk-prefix}-drawer-no-mask {
60
+ background-color: @normal-color;
61
+ }
package/lib/index.css CHANGED
@@ -5173,6 +5173,9 @@ textarea.ant-input {
5173
5173
  color: #333;
5174
5174
  font-size: 14px;
5175
5175
  }
5176
+ .pandora-sdk-drawer-no-mask {
5177
+ background-color: #d9d9d9;
5178
+ }
5176
5179
  .ant-upload {
5177
5180
  -webkit-box-sizing: border-box;
5178
5181
  box-sizing: border-box;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qn-pandora/pandora-component",
3
- "version": "4.2.0",
3
+ "version": "4.3.0",
4
4
  "description": "基础组件",
5
5
  "author": "pandora <pandora@qiniu.com>",
6
6
  "homepage": "https://github.com/qbox/phoenix#readme",
@@ -66,8 +66,8 @@
66
66
  "dependencies": {
67
67
  "@ant-design/compatible": "1.0.8",
68
68
  "@ant-design/icons": "4.7.0",
69
- "@qn-pandora/pandora-component-icons": "^3.2.0",
70
- "@qn-pandora/app-sdk": "^3.2.0",
69
+ "@qn-pandora/pandora-component-icons": "^3.3.0",
70
+ "@qn-pandora/app-sdk": "^3.3.0",
71
71
  "flat": "^5.0.0",
72
72
  "antd-mobile": "2.3.3",
73
73
  "css": "3.0.0",