@synerise/ds-date-range-picker 0.13.4 → 0.14.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.md +22 -0
- package/README.md +26 -28
- package/dist/DateRangePicker.types.d.ts +6 -0
- package/dist/Footer/Footer.d.ts +1 -1
- package/dist/Footer/Footer.js +6 -4
- package/dist/Footer/Footer.styles.d.ts +11 -0
- package/dist/Footer/Footer.styles.js +16 -1
- package/dist/Footer/Footer.types.d.ts +1 -0
- package/dist/RangePicker/RangePicker.js +41 -15
- package/dist/RangePicker/RangePicker.types.d.ts +1 -0
- package/dist/RawDateRangePicker.d.ts +1 -1
- package/dist/RawDateRangePicker.js +13 -7
- package/dist/utils.js +9 -2
- package/package.json +6 -6
- package/dist/style/index.css +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,28 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [0.14.0](https://github.com/Synerise/synerise-design/compare/@synerise/ds-date-range-picker@0.13.4...@synerise/ds-date-range-picker@0.14.0) (2022-07-28)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **date-range-picker:** empty select time if ALL_TIME ([476ac41](https://github.com/Synerise/synerise-design/commit/476ac419a0ab1b1a43349e6b9c6647dceb564430))
|
|
12
|
+
* **date-range-picker:** ensure proper relative-date-range onApply value ([e5a7d3a](https://github.com/Synerise/synerise-design/commit/e5a7d3acf4994e9be1a7f382d957eed70993de0c))
|
|
13
|
+
* **date-range-picker:** fix and refactor tests, (re)add start/end of day ([413151d](https://github.com/Synerise/synerise-design/commit/413151d5f511ec5722c0576f0765ea74857b6b8d))
|
|
14
|
+
* **date-range-picker:** fix prop and tests ([2ecb365](https://github.com/Synerise/synerise-design/commit/2ecb3658019bc67c820f85e759f42ad22417b001))
|
|
15
|
+
* **date-range-picker:** fix selection of new date ([f94d822](https://github.com/Synerise/synerise-design/commit/f94d822f9fc3b78f806b96f98c4e723dac0dd075))
|
|
16
|
+
* **date-range-picker:** fix selection of new date and tests ([07f703a](https://github.com/Synerise/synerise-design/commit/07f703a24ae9d62d6bf24bdc2ee3fb0157681be2))
|
|
17
|
+
* **date-range-picker:** no relative date properties if absolute range ([e0bd9cb](https://github.com/Synerise/synerise-design/commit/e0bd9cb9c7a2a84bcbad1129b21186048482bc71))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
* **date-range-picker:** failing test for proper relative-date props ([2746147](https://github.com/Synerise/synerise-design/commit/27461470eccd39a9749b54d1aa508503c8861d98))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
6
28
|
## [0.13.4](https://github.com/Synerise/synerise-design/compare/@synerise/ds-date-range-picker@0.13.3...@synerise/ds-date-range-picker@0.13.4) (2022-07-17)
|
|
7
29
|
|
|
8
30
|
**Note:** Version bump only for package @synerise/ds-date-range-picker
|
package/README.md
CHANGED
|
@@ -41,36 +41,34 @@ const value = {
|
|
|
41
41
|
|
|
42
42
|
## API
|
|
43
43
|
|
|
44
|
-
| Property | Description
|
|
45
|
-
| -------------------- | -------------------------------------------------------------------
|
|
46
|
-
| disabledDate | Function to specify if particular dates are disabled or not
|
|
47
|
-
| disabledDefaultTexts | Disables the default texts translations provided by `react-intl`
|
|
48
|
-
| forceAbsolute | Force the outcome to be converted to an absolute date
|
|
49
|
-
| format | Format of the value displayed in the footer
|
|
50
|
-
| onApply | Callback executed after applying changes
|
|
51
|
-
| ranges | An array containing custom ranges which may be used as a short-hand
|
|
52
|
-
| popoverProps | Object representing props applied to the Antd Popover component
|
|
53
|
-
| rangeUnits | Units available in relative range picker
|
|
54
|
-
| relativePast | Enable relative filter for past ranges
|
|
55
|
-
| relativeFuture | Enable relative filter for future ranges
|
|
56
|
-
| showTime | Enable user to choose particular hour
|
|
57
|
-
| showFilter | Enable range filtering
|
|
58
|
-
| showCustomRange | Enable custom range form in relative range picker
|
|
59
|
-
| validate | Function to specify if particular date ranges are correct
|
|
60
|
-
| value | Value of the picker
|
|
61
|
-
|
|
|
44
|
+
| Property | Description | Type | Default |
|
|
45
|
+
| -------------------- | ------------------------------------------------------------------- | -------------------- | ------------------------------------------------------------- |
|
|
46
|
+
| disabledDate | Function to specify if particular dates are disabled or not | (date:Date)=>boolean | - |
|
|
47
|
+
| disabledDefaultTexts | Disables the default texts translations provided by `react-intl` | boolean | `false` |
|
|
48
|
+
| forceAbsolute | Force the outcome to be converted to an absolute date | boolean | `false` |
|
|
49
|
+
| format | Format of the value displayed in the footer | string | "MMM D, YYYY" |
|
|
50
|
+
| onApply | Callback executed after applying changes | (date:Date)=>void | - |
|
|
51
|
+
| ranges | An array containing custom ranges which may be used as a short-hand | DateRange[] | [] |
|
|
52
|
+
| popoverProps | Object representing props applied to the Antd Popover component | AntdPopoverProps | {} |
|
|
53
|
+
| rangeUnits | Units available in relative range picker | RelativeUnits[] | ['SECONDS','MINUTES','HOURS','DAYS','WEEKS','MONTHS','YEARS'] |
|
|
54
|
+
| relativePast | Enable relative filter for past ranges | boolean | `false` |
|
|
55
|
+
| relativeFuture | Enable relative filter for future ranges | boolean | `false` |
|
|
56
|
+
| showTime | Enable user to choose particular hour | boolean | `false` |
|
|
57
|
+
| showFilter | Enable range filtering | boolean | `false` |
|
|
58
|
+
| showCustomRange | Enable custom range form in relative range picker | boolean | `true` |
|
|
59
|
+
| validate | Function to specify if particular date ranges are correct | (date:Date)=>boolean | - |
|
|
60
|
+
| value | Value of the picker | DateRange | new Date() |
|
|
61
|
+
| startAlwaysOnTheLeft | Enable not to move month from left side to right side | boolean | `false` |
|
|
62
|
+
| onVisibleChange | Callback executed when popover with dateRangePicker changes its visibility | (visible: boolean) => void | - |
|
|
62
63
|
|
|
63
|
-
|
|
64
64
|
### DateRange
|
|
65
65
|
|
|
66
|
-
| Property
|
|
67
|
-
|
|
|
68
|
-
| from
|
|
69
|
-
| to
|
|
70
|
-
| type
|
|
71
|
-
| duration
|
|
72
|
-
| offset
|
|
73
|
-
| arrowColor | Custom color arrow of popover when is footer | {['bottomLeft' | 'topLeft' | 'anyOtherPlacement']: 'white' | 'grey' | anyPaletteColorToken} | - |
|
|
74
|
-
|
|
66
|
+
| Property | Description | Type | Default |
|
|
67
|
+
| -------- | ---------------------------------------------- | ------------------------------------- | ------- |
|
|
68
|
+
| from | Start date | Date / string | - |
|
|
69
|
+
| to | End date | Date / string | - |
|
|
70
|
+
| type | String key for identifying the range type | 'ABSOLUTE' / 'RELATIVE' / 'SINCE' | - |
|
|
71
|
+
| duration | Duration of the relative range | {type: RelativeUnit, duration:number} | - |
|
|
72
|
+
| offset | Offset of the relative range from today's date | {type: RelativeUnit, duration:number} | - |
|
|
75
73
|
|
|
76
74
|
`RelativeUnit = 'SECONDS' | 'MINUTES' | 'HOURS' | 'DAYS' | 'WEEKS' | 'MONTHS' | 'YEARS'`
|
|
@@ -4,6 +4,7 @@ import { PopoverProps } from 'antd/lib/popover';
|
|
|
4
4
|
import { DateFilter, DateRange, RelativeUnits } from './date.types';
|
|
5
5
|
import { FilterDefinition } from './RangeFilter/RangeFilter.types';
|
|
6
6
|
import { SavedFilter } from './RangeFilter/Shared/FilterDropdown/FilterDropdown.types';
|
|
7
|
+
import { Props as FooterProps } from './Footer/Footer.types';
|
|
7
8
|
export declare type CustomColorArrow = 'blue' | 'grey' | 'red' | 'green' | 'yellow' | 'pink' | 'mars' | 'orange' | 'fern' | 'cyan' | 'purple' | 'violet';
|
|
8
9
|
export declare type AdditionalMapper = {
|
|
9
10
|
topLeft: CustomColorArrow;
|
|
@@ -16,11 +17,16 @@ export declare type AdditionalMapper = {
|
|
|
16
17
|
rightBottom: CustomColorArrow;
|
|
17
18
|
};
|
|
18
19
|
export interface Props extends WrappedComponentProps {
|
|
20
|
+
/**
|
|
21
|
+
* overwrite default container's class. Default value is `ds-date-range-picker`.
|
|
22
|
+
*/
|
|
23
|
+
containerClass?: string;
|
|
19
24
|
disableDefaultTexts?: boolean;
|
|
20
25
|
disabledDate?: (date?: Date) => boolean;
|
|
21
26
|
format?: string;
|
|
22
27
|
forceAdjacentMonths?: boolean;
|
|
23
28
|
forceAbsolute?: boolean;
|
|
29
|
+
footerProps?: Partial<FooterProps>;
|
|
24
30
|
onValueChange?: (value: Partial<DateFilter> | undefined) => void;
|
|
25
31
|
onApply: (value: Partial<DateFilter> | undefined) => void;
|
|
26
32
|
onVisibleChange?: (visible: boolean) => void;
|
package/dist/Footer/Footer.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { Props } from './Footer.types';
|
|
3
|
-
declare const _default: React.ForwardRefExoticComponent<Pick<Props, "texts" | "format" | "mode" | "value" | "message" | "onApply" | "showTime" | "dateOnly" | "canSwitchMode" | "onSwitchMode" | "canApply"> & {
|
|
3
|
+
declare const _default: React.ForwardRefExoticComponent<Pick<Props, "texts" | "format" | "mode" | "value" | "message" | "onApply" | "showTime" | "dateOnly" | "canSwitchMode" | "onSwitchMode" | "canApply" | "displayDateContainerClass"> & {
|
|
4
4
|
forwardedRef?: ((instance: any) => void) | React.RefObject<any> | null | undefined;
|
|
5
5
|
} & React.RefAttributes<any>> & {
|
|
6
6
|
WrappedComponent: React.ComponentType<Props>;
|
package/dist/Footer/Footer.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _excluded = ["canApply", "onApply", "intl", "canSwitchMode", "onSwitchMode", "mode", "dateOnly", "message", "texts", "value", "format", "showTime"];
|
|
1
|
+
var _excluded = ["canApply", "onApply", "intl", "canSwitchMode", "onSwitchMode", "mode", "dateOnly", "message", "texts", "value", "format", "showTime", "displayDateContainerClass"];
|
|
2
2
|
|
|
3
3
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
4
4
|
|
|
@@ -27,6 +27,8 @@ var Footer = function Footer(_ref) {
|
|
|
27
27
|
value = _ref.value,
|
|
28
28
|
format = _ref.format,
|
|
29
29
|
showTime = _ref.showTime,
|
|
30
|
+
_ref$displayDateConta = _ref.displayDateContainerClass,
|
|
31
|
+
displayDateContainerClass = _ref$displayDateConta === void 0 ? 'ds-date-range-picker-value' : _ref$displayDateConta,
|
|
30
32
|
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
31
33
|
|
|
32
34
|
var footerFormat = format || (showTime ? 'MMM D, YYYY, HH:mm' : 'MMM D, YYYY');
|
|
@@ -40,11 +42,11 @@ var Footer = function Footer(_ref) {
|
|
|
40
42
|
}
|
|
41
43
|
|
|
42
44
|
return /*#__PURE__*/React.createElement(S.ChosenRange, {
|
|
43
|
-
className:
|
|
44
|
-
}, !!value && !!value.from ? fnsFormat(getDateFromString(value == null ? void 0 : value.from), footerFormat, intl.locale) : texts.startDatePlaceholder, /*#__PURE__*/React.createElement(Icon, {
|
|
45
|
+
className: displayDateContainerClass
|
|
46
|
+
}, !!value && !!value.from ? fnsFormat(getDateFromString(value == null ? void 0 : value.from), footerFormat, intl.locale) : texts.startDatePlaceholder, /*#__PURE__*/React.createElement(S.InvisibleTextContent, null, ' – '), /*#__PURE__*/React.createElement(Icon, {
|
|
45
47
|
component: /*#__PURE__*/React.createElement(ArrowRightS, null)
|
|
46
48
|
}), !!value && !!value.to ? fnsFormat(getDateFromString(value == null ? void 0 : value.to), footerFormat, intl.locale) : texts.endDatePlaceholder);
|
|
47
|
-
}, [value, footerFormat, intl.locale, texts]);
|
|
49
|
+
}, [value, footerFormat, intl.locale, texts, displayDateContainerClass]);
|
|
48
50
|
return /*#__PURE__*/React.createElement(S.Container, _extends({
|
|
49
51
|
className: "ds-date-range-picker-footer"
|
|
50
52
|
}, rest), ChosenRange, /*#__PURE__*/React.createElement(S.ActionsPlaceholder, null), /*#__PURE__*/React.createElement(S.Actions, null, /*#__PURE__*/React.createElement(Tooltip, {
|
|
@@ -4,3 +4,14 @@ export declare const Actions: import("styled-components").StyledComponent<"div",
|
|
|
4
4
|
export declare const Range: import("styled-components").StyledComponent<typeof Button, any, {}, never>;
|
|
5
5
|
export declare const ActionsPlaceholder: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
6
6
|
export declare const ChosenRange: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
7
|
+
/**
|
|
8
|
+
* This is mainly for unit-tests capabilitiess and WCAG compliancy, it is visible
|
|
9
|
+
* can be used for em-dashes (APA style) which will be recognized by screen-readers
|
|
10
|
+
* or in tests in `textContent` JS DOM property.
|
|
11
|
+
*
|
|
12
|
+
* Example usage:
|
|
13
|
+
*
|
|
14
|
+
* <S.InvisibleTextContent>{' – '}</S.InvisibleTextContent>
|
|
15
|
+
* <Icon component={<ArrowRightS/>}/>
|
|
16
|
+
*/
|
|
17
|
+
export declare const InvisibleTextContent: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
@@ -25,4 +25,19 @@ export var ChosenRange = styled.div.withConfig({
|
|
|
25
25
|
return props.theme.palette['grey-800'];
|
|
26
26
|
}, function (props) {
|
|
27
27
|
return props.theme.palette['grey-400'];
|
|
28
|
-
});
|
|
28
|
+
});
|
|
29
|
+
/**
|
|
30
|
+
* This is mainly for unit-tests capabilitiess and WCAG compliancy, it is visible
|
|
31
|
+
* can be used for em-dashes (APA style) which will be recognized by screen-readers
|
|
32
|
+
* or in tests in `textContent` JS DOM property.
|
|
33
|
+
*
|
|
34
|
+
* Example usage:
|
|
35
|
+
*
|
|
36
|
+
* <S.InvisibleTextContent>{' – '}</S.InvisibleTextContent>
|
|
37
|
+
* <Icon component={<ArrowRightS/>}/>
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
export var InvisibleTextContent = styled.span.withConfig({
|
|
41
|
+
displayName: "Footerstyles__InvisibleTextContent",
|
|
42
|
+
componentId: "sc-1oatjb7-5"
|
|
43
|
+
})(["display:none;"]);
|
|
@@ -34,6 +34,36 @@ var NOOP = function NOOP() {};
|
|
|
34
34
|
|
|
35
35
|
var TOOLTIP_FORMAT = 'MMM d, yyyy, HH:mm';
|
|
36
36
|
|
|
37
|
+
function replaceRange(value, day) {
|
|
38
|
+
var from = value.from,
|
|
39
|
+
to = value.to; // arguments to DateUtils functions are casted to Date because function arguments require Date
|
|
40
|
+
|
|
41
|
+
if (!from) {
|
|
42
|
+
from = day;
|
|
43
|
+
} else if (from && to && DateUtils.isSameDay(from, to) && DateUtils.isSameDay(day, from)) {
|
|
44
|
+
from = null;
|
|
45
|
+
to = null;
|
|
46
|
+
} else if (to && DateUtils.isSameDay(day, to)) {
|
|
47
|
+
from = day;
|
|
48
|
+
to = day;
|
|
49
|
+
} else if (from && to) {
|
|
50
|
+
from = day;
|
|
51
|
+
to = null;
|
|
52
|
+
} else {
|
|
53
|
+
to = day;
|
|
54
|
+
|
|
55
|
+
if (DateUtils.isDayBefore(to, from)) {
|
|
56
|
+
to = from;
|
|
57
|
+
from = day;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return {
|
|
62
|
+
from: from,
|
|
63
|
+
to: to
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
|
|
37
67
|
var RangePicker = /*#__PURE__*/function (_React$PureComponent) {
|
|
38
68
|
_inheritsLoose(RangePicker, _React$PureComponent);
|
|
39
69
|
|
|
@@ -63,21 +93,12 @@ var RangePicker = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
63
93
|
onChange = _this$props.onChange;
|
|
64
94
|
if (modifiers.disabled) return;
|
|
65
95
|
|
|
66
|
-
var
|
|
67
|
-
from =
|
|
68
|
-
to =
|
|
96
|
+
var _replaceRange = replaceRange(value, day),
|
|
97
|
+
from = _replaceRange.from,
|
|
98
|
+
to = _replaceRange.to;
|
|
69
99
|
|
|
70
100
|
from = from ? fnsStartOfDay(from) : from;
|
|
71
101
|
to = to ? fnsEndOfDay(to) : to;
|
|
72
|
-
|
|
73
|
-
if (to) {
|
|
74
|
-
var now = new Date();
|
|
75
|
-
|
|
76
|
-
if (fnsIsSameDay(legacyParse(to), legacyParse(now))) {
|
|
77
|
-
to = now;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
102
|
onChange && onChange({
|
|
82
103
|
type: ABSOLUTE,
|
|
83
104
|
from: from,
|
|
@@ -382,11 +403,16 @@ var RangePicker = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
382
403
|
|
|
383
404
|
var _this$props8 = this.props,
|
|
384
405
|
value = _this$props8.value,
|
|
385
|
-
forceAdjacentMonths = _this$props8.forceAdjacentMonths
|
|
406
|
+
forceAdjacentMonths = _this$props8.forceAdjacentMonths,
|
|
407
|
+
startAlwaysOnTheLeft = _this$props8.startAlwaysOnTheLeft;
|
|
386
408
|
var left = this.state.left;
|
|
409
|
+
var toDateChanged = !!(value != null && value.to) && (value == null ? void 0 : value.to) !== (prevProps == null ? void 0 : (_prevProps$value = prevProps.value) == null ? void 0 : _prevProps$value.to);
|
|
410
|
+
var fromDateChanged = !!(value != null && value.from) && (value == null ? void 0 : value.from) !== (prevProps == null ? void 0 : (_prevProps$value2 = prevProps.value) == null ? void 0 : _prevProps$value2.from);
|
|
387
411
|
|
|
388
|
-
if (
|
|
389
|
-
|
|
412
|
+
if (toDateChanged && !fnsIsSameMonth(legacyParse(value.to), legacyParse(left.month)) || fromDateChanged && !fnsIsSameMonth(legacyParse(value.from), legacyParse(left.month)) || forceAdjacentMonths !== prevProps.forceAdjacentMonths) {
|
|
413
|
+
if (startAlwaysOnTheLeft) {
|
|
414
|
+
this.setState(getSidesState(value, forceAdjacentMonths));
|
|
415
|
+
}
|
|
390
416
|
}
|
|
391
417
|
|
|
392
418
|
return null;
|
|
@@ -24,7 +24,7 @@ export declare class RawDateRangePicker extends React.PureComponent<Props, State
|
|
|
24
24
|
getAddons: () => AddonType[];
|
|
25
25
|
render(): JSX.Element;
|
|
26
26
|
}
|
|
27
|
-
declare const _default: React.ForwardRefExoticComponent<Pick<Props, "texts" | "format" | "value" | "onVisibleChange" | "rangeUnits" | "disableDefaultTexts" | "disabledDate" | "forceAdjacentMonths" | "forceAbsolute" | "onValueChange" | "onApply" | "onFilterSave" | "popoverProps" | "popoverTrigger" | "ranges" | "relativeFuture" | "relativePast" | "relativeModes" | "savedFilters" | "showRelativePicker" | "showFilter" | "showTime" | "showCustomRange" | "validate" | "arrowColor"> & {
|
|
27
|
+
declare const _default: React.ForwardRefExoticComponent<Pick<Props, "texts" | "format" | "value" | "onVisibleChange" | "rangeUnits" | "containerClass" | "disableDefaultTexts" | "disabledDate" | "forceAdjacentMonths" | "forceAbsolute" | "footerProps" | "onValueChange" | "onApply" | "onFilterSave" | "popoverProps" | "popoverTrigger" | "ranges" | "relativeFuture" | "relativePast" | "relativeModes" | "savedFilters" | "showRelativePicker" | "showFilter" | "showTime" | "showCustomRange" | "validate" | "arrowColor"> & {
|
|
28
28
|
forwardedRef?: ((instance: any) => void) | React.RefObject<any> | null | undefined;
|
|
29
29
|
} & React.RefAttributes<any>> & {
|
|
30
30
|
WrappedComponent: React.ComponentType<Props>;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
|
|
1
3
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
2
4
|
|
|
3
5
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
@@ -15,6 +17,7 @@ import fnsIsValid from 'date-fns/isValid';
|
|
|
15
17
|
import { Container, Separator, Addon } from './DateRangePicker.styles';
|
|
16
18
|
import RangePicker from './RangePicker/RangePicker';
|
|
17
19
|
import { RELATIVE, ABSOLUTE, MODES, RELATIVE_PRESETS, ABSOLUTE_PRESETS } from './constants';
|
|
20
|
+
import * as CONST from './constants';
|
|
18
21
|
import relativeToAbsolute from './dateUtils/relativeToAbsolute';
|
|
19
22
|
import AddonCollapse from './AddonCollapse/AddonCollapse';
|
|
20
23
|
import RelativeRangePicker from './RelativeRangePicker/RelativeRangePicker';
|
|
@@ -64,7 +67,7 @@ export var RawDateRangePicker = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
64
67
|
filter: value.filter
|
|
65
68
|
}));
|
|
66
69
|
|
|
67
|
-
if (newValue.type === 'RELATIVE' && mode === MODES.TIME) {
|
|
70
|
+
if ((newValue.type === 'RELATIVE' || newValue.key === CONST.ALL_TIME) && mode === MODES.TIME) {
|
|
68
71
|
// clicked on RangeButtons and was selecting time
|
|
69
72
|
_this.setState({
|
|
70
73
|
mode: MODES.DATE
|
|
@@ -92,7 +95,7 @@ export var RawDateRangePicker = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
92
95
|
return;
|
|
93
96
|
}
|
|
94
97
|
|
|
95
|
-
if (value.key ===
|
|
98
|
+
if (value.key === CONST.ALL_TIME) {
|
|
96
99
|
onApply && onApply(omitBy(value, isUndefined));
|
|
97
100
|
return;
|
|
98
101
|
}
|
|
@@ -232,7 +235,10 @@ export var RawDateRangePicker = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
232
235
|
texts = _this$props3.texts,
|
|
233
236
|
savedFilters = _this$props3.savedFilters,
|
|
234
237
|
onFilterSave = _this$props3.onFilterSave,
|
|
235
|
-
intl = _this$props3.intl
|
|
238
|
+
intl = _this$props3.intl,
|
|
239
|
+
_this$props3$containe = _this$props3.containerClass,
|
|
240
|
+
containerClass = _this$props3$containe === void 0 ? 'ds-date-range-picker' : _this$props3$containe,
|
|
241
|
+
footerProps = _this$props3.footerProps;
|
|
236
242
|
var _this$state3 = this.state,
|
|
237
243
|
value = _this$state3.value,
|
|
238
244
|
mode = _this$state3.mode;
|
|
@@ -251,9 +257,9 @@ export var RawDateRangePicker = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
251
257
|
var validator = validate ? validate(value) : {
|
|
252
258
|
valid: true
|
|
253
259
|
};
|
|
254
|
-
var isValid =
|
|
260
|
+
var isValid = key !== CONST.ALL_TIME && !!(from && to) && validator.valid;
|
|
255
261
|
return /*#__PURE__*/React.createElement(Container, {
|
|
256
|
-
className:
|
|
262
|
+
className: containerClass
|
|
257
263
|
}, /*#__PURE__*/React.createElement(RangePicker, {
|
|
258
264
|
value: value,
|
|
259
265
|
onChange: this.handleRangeChange,
|
|
@@ -271,7 +277,7 @@ export var RawDateRangePicker = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
271
277
|
className: "addon-wrapper",
|
|
272
278
|
key: addon.key
|
|
273
279
|
}, addon.content);
|
|
274
|
-
}), /*#__PURE__*/React.createElement(Footer, {
|
|
280
|
+
}), /*#__PURE__*/React.createElement(Footer, _extends({
|
|
275
281
|
canApply: isValid,
|
|
276
282
|
onApply: this.handleApply,
|
|
277
283
|
dateOnly: !showTime,
|
|
@@ -283,7 +289,7 @@ export var RawDateRangePicker = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
283
289
|
value: value,
|
|
284
290
|
showTime: showTime,
|
|
285
291
|
format: format
|
|
286
|
-
}));
|
|
292
|
+
}, footerProps)));
|
|
287
293
|
};
|
|
288
294
|
|
|
289
295
|
return RawDateRangePicker;
|
package/dist/utils.js
CHANGED
|
@@ -7,6 +7,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
|
|
7
7
|
import fnsMin from 'date-fns/min';
|
|
8
8
|
import fnsMax from 'date-fns/max';
|
|
9
9
|
import { legacyParse } from '@date-fns/upgrade/v2';
|
|
10
|
+
import { omit } from 'lodash';
|
|
10
11
|
import { ABSOLUTE, CUSTOM_RANGE_KEY, RELATIVE } from './constants';
|
|
11
12
|
import ADD from './dateUtils/add';
|
|
12
13
|
import START_OF from './dateUtils/startOf';
|
|
@@ -54,11 +55,17 @@ export var normalizeRange = function normalizeRange(range) {
|
|
|
54
55
|
|
|
55
56
|
var from = range.from ? legacyParse(range.from) : undefined;
|
|
56
57
|
var to = range.to ? legacyParse(range.to) : undefined;
|
|
57
|
-
|
|
58
|
-
|
|
58
|
+
|
|
59
|
+
var dropNonAbsolute = function dropNonAbsolute(dateRange) {
|
|
60
|
+
return omit(dateRange, ['offset', 'duration']);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
var absoluteRange = _objectSpread({}, dropNonAbsolute(range), {
|
|
59
64
|
from: from,
|
|
60
65
|
to: to
|
|
61
66
|
});
|
|
67
|
+
|
|
68
|
+
return absoluteRange;
|
|
62
69
|
};
|
|
63
70
|
|
|
64
71
|
var getIntlMessage = function getIntlMessage(textMessageId, intl, areDefaultTextsDisabled) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synerise/ds-date-range-picker",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "Date-Range-Picker UI Component for the Synerise Design System",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"repository": "Synerise/synerise-design",
|
|
@@ -34,11 +34,11 @@
|
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@date-fns/upgrade": "^1.0.3",
|
|
36
36
|
"@synerise/ds-button": "^0.17.2",
|
|
37
|
-
"@synerise/ds-date-picker": "^0.6.
|
|
37
|
+
"@synerise/ds-date-picker": "^0.6.24",
|
|
38
38
|
"@synerise/ds-icon": "^0.49.0",
|
|
39
|
-
"@synerise/ds-manageable-list": "^0.23.
|
|
40
|
-
"@synerise/ds-time-picker": "^0.6.
|
|
41
|
-
"@synerise/ds-tooltip": "^0.11.
|
|
39
|
+
"@synerise/ds-manageable-list": "^0.23.19",
|
|
40
|
+
"@synerise/ds-time-picker": "^0.6.23",
|
|
41
|
+
"@synerise/ds-tooltip": "^0.11.10",
|
|
42
42
|
"@synerise/ds-utils": "^0.19.0",
|
|
43
43
|
"date-fns": "^2.16.1",
|
|
44
44
|
"dayjs": "^1.8.35",
|
|
@@ -54,5 +54,5 @@
|
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@types/ramda": "^0.27.14"
|
|
56
56
|
},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "bf12565ec1e6a4124b0c54cdb61e22eae4401d93"
|
|
58
58
|
}
|
package/dist/style/index.css
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
.ant-popover.ds-date-range-popover>.ant-popover-content>.ant-popover-arrow{display:none}.ant-popover.ds-date-range-popover>.ant-popover-content{margin:-5px 0}.ant-dropdown{box-shadow:0 16px 32px 0 rgba(35,41,54,.1)}
|