@antscorp/antsomi-ui 1.3.5-beta.15 → 1.3.5-beta.17
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/es/components/molecules/CalendarSelection/CalendarSelection.js +11 -11
- package/es/components/molecules/CalendarSelection/components/CustomPicker/CustomPicker.js +13 -6
- package/es/components/molecules/CalendarSelection/components/CustomPicker/styled.js +14 -3
- package/es/components/molecules/CalendarSelection/components/TimeRangeDisplay/TimeRangeDisplay.d.ts +3 -0
- package/es/components/molecules/CalendarSelection/components/TimeRangeDisplay/TimeRangeDisplay.js +7 -3
- package/es/components/molecules/CalendarSelection/reducer.js +2 -2
- package/es/components/molecules/CalendarSelection/styled.d.ts +1 -0
- package/es/components/molecules/CalendarSelection/styled.js +4 -1
- package/es/components/molecules/CalendarSelection/types.d.ts +2 -3
- package/es/components/molecules/CalendarSelection/utils.d.ts +27 -23
- package/es/components/molecules/CalendarSelection/utils.js +34 -30
- package/es/components/molecules/DatePicker/components/AdvancedPicker/AdvancedPicker.js +1 -1
- package/es/components/molecules/DatePicker/components/AdvancedRangePicker/AdvancedRangePicker.d.ts +1 -0
- package/es/components/molecules/DatePicker/components/AdvancedRangePicker/AdvancedRangePicker.js +3 -3
- package/package.json +1 -1
|
@@ -3,10 +3,10 @@ import React, { useLayoutEffect, useReducer, useRef } from 'react';
|
|
|
3
3
|
import { Divider } from 'antd';
|
|
4
4
|
import { ActionContext, StateContext } from './context';
|
|
5
5
|
import { reducer, INITIAL_STATE } from './reducer';
|
|
6
|
-
import { StyledPopover, StyledPopoverBody } from './styled';
|
|
6
|
+
import { StyledPopover, StyledPopoverBody, StyledPopoverContainer } from './styled';
|
|
7
7
|
import { CustomPicker, Footer, RangeSelectOptions, TimeRangeDisplay } from './components';
|
|
8
8
|
import { LOCAL_TIMEZONE, RANGE_LIMIT } from './constants';
|
|
9
|
-
import { initState } from './actions';
|
|
9
|
+
import { initState, resetValue } from './actions';
|
|
10
10
|
import { useTriggerOut } from './hooks/useTriggerOut';
|
|
11
11
|
export const CalendarSelection = props => {
|
|
12
12
|
const initialed = useRef(false);
|
|
@@ -18,15 +18,15 @@ export const CalendarSelection = props => {
|
|
|
18
18
|
dispatch(initState(value, !initialed.current));
|
|
19
19
|
initialed.current = true;
|
|
20
20
|
}, [value]);
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
useLayoutEffect(() => {
|
|
22
|
+
if (!state.open) {
|
|
23
|
+
return () => {
|
|
24
|
+
dispatch(resetValue());
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
}, [state.open]);
|
|
28
28
|
useTriggerOut({ state, dispatch, onChange });
|
|
29
|
-
const popoverContent = (React.createElement(
|
|
29
|
+
const popoverContent = (React.createElement(StyledPopoverContainer, null,
|
|
30
30
|
React.createElement(StyledPopoverBody, null,
|
|
31
31
|
React.createElement(RangeSelectOptions, null),
|
|
32
32
|
React.createElement(Divider, { type: "vertical", style: { margin: 0, height: 'auto' } }),
|
|
@@ -41,5 +41,5 @@ export const CalendarSelection = props => {
|
|
|
41
41
|
if (!isOpen)
|
|
42
42
|
dispatch({ type: 'toggle_popover' });
|
|
43
43
|
} }),
|
|
44
|
-
React.createElement(TimeRangeDisplay, {
|
|
44
|
+
React.createElement(TimeRangeDisplay, Object.assign({}, timeDisplayProps))))));
|
|
45
45
|
};
|
|
@@ -30,12 +30,9 @@ export const CustomPicker = () => {
|
|
|
30
30
|
}
|
|
31
31
|
}, [rangeValue.length]);
|
|
32
32
|
const handleCalendarChange = (start, end) => {
|
|
33
|
-
var _a, _b;
|
|
34
33
|
if (!start || !end || activeRangeIdx === null)
|
|
35
34
|
return;
|
|
36
35
|
const replacedRange = rangeValue[activeRangeIdx];
|
|
37
|
-
if (((_a = replacedRange.start) === null || _a === void 0 ? void 0 : _a.isSame(start)) && ((_b = replacedRange.end) === null || _b === void 0 ? void 0 : _b.isSame(end)))
|
|
38
|
-
return;
|
|
39
36
|
const updatedRangeValue = [...rangeValue];
|
|
40
37
|
updatedRangeValue.splice(activeRangeIdx, 1, Object.assign(Object.assign({}, replacedRange), { start,
|
|
41
38
|
end }));
|
|
@@ -69,7 +66,7 @@ export const CustomPicker = () => {
|
|
|
69
66
|
} },
|
|
70
67
|
React.createElement("div", { className: "range-input" },
|
|
71
68
|
React.createElement("div", { className: "range-input-label" }, generateRangeInputLabel(rangeIdx, range.label)),
|
|
72
|
-
React.createElement(RangePicker, { open: true, value: [range.start, range.end], onClick: () => setActiveRangeIdx(rangeIdx), getPopupContainer: () => popupContainer.current || document.body, panelRender: originalPanel => {
|
|
69
|
+
React.createElement(RangePicker, { open: true, value: [dayjs(range.start), dayjs(range.end)], onClick: () => setActiveRangeIdx(rangeIdx), getPopupContainer: () => popupContainer.current || document.body, panelRender: originalPanel => {
|
|
73
70
|
if (activeRangeIdx !== rangeIdx)
|
|
74
71
|
return null;
|
|
75
72
|
return originalPanel;
|
|
@@ -80,8 +77,18 @@ export const CustomPicker = () => {
|
|
|
80
77
|
return renderCellDate(current, info.originNode);
|
|
81
78
|
}, onCalendarChange: value => {
|
|
82
79
|
var _a, _b;
|
|
83
|
-
|
|
84
|
-
|
|
80
|
+
let start = '';
|
|
81
|
+
let end = '';
|
|
82
|
+
const valueFirst = dayjs((_a = value === null || value === void 0 ? void 0 : value.at(0)) === null || _a === void 0 ? void 0 : _a.toDate());
|
|
83
|
+
const valueSecond = dayjs((_b = value === null || value === void 0 ? void 0 : value.at(1)) === null || _b === void 0 ? void 0 : _b.toDate());
|
|
84
|
+
if (valueFirst.isBefore(valueSecond)) {
|
|
85
|
+
start = valueFirst.toISOString();
|
|
86
|
+
end = valueSecond.toISOString();
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
start = valueSecond.toISOString();
|
|
90
|
+
end = valueFirst.toISOString();
|
|
91
|
+
}
|
|
85
92
|
handleCalendarChange(start, end);
|
|
86
93
|
} })))))),
|
|
87
94
|
React.createElement(AutoUpdateTo, null),
|
|
@@ -79,7 +79,6 @@ export const CalendarContainerStyled = styled.div `
|
|
|
79
79
|
|
|
80
80
|
/* Date node */
|
|
81
81
|
.antsomi-picker-cell-inner {
|
|
82
|
-
height: 21.5px;
|
|
83
82
|
}
|
|
84
83
|
|
|
85
84
|
/* Today node */
|
|
@@ -110,9 +109,9 @@ export const CalendarContainerStyled = styled.div `
|
|
|
110
109
|
background: var(--colorInRange) !important;
|
|
111
110
|
}
|
|
112
111
|
.antsomi-picker-cell-inner {
|
|
113
|
-
background: var(--colorInRange) !important;
|
|
112
|
+
/* background: var(--colorInRange) !important; */
|
|
114
113
|
&::after {
|
|
115
|
-
content: none;
|
|
114
|
+
content: none !important;
|
|
116
115
|
background: var(--colorInRange) !important;
|
|
117
116
|
}
|
|
118
117
|
}
|
|
@@ -133,6 +132,18 @@ export const CalendarContainerStyled = styled.div `
|
|
|
133
132
|
background: var(--colorInRange) !important;
|
|
134
133
|
}
|
|
135
134
|
}
|
|
135
|
+
|
|
136
|
+
/* Hover */
|
|
137
|
+
.antsomi-picker-cell-in-view {
|
|
138
|
+
&.antsomi-picker-cell-range-hover,
|
|
139
|
+
&.antsomi-picker-cell-range-hover-start,
|
|
140
|
+
&.antsomi-picker-cell-range-hover-end {
|
|
141
|
+
&:not(.antsomi-picker-cell-in-range)::after {
|
|
142
|
+
content: none !important;
|
|
143
|
+
border: none;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
136
147
|
}
|
|
137
148
|
.antsomi-picker-range-arrow {
|
|
138
149
|
display: none !important;
|
package/es/components/molecules/CalendarSelection/components/TimeRangeDisplay/TimeRangeDisplay.js
CHANGED
|
@@ -19,19 +19,23 @@ import { StyledBtnDisplayWrapper } from './styled';
|
|
|
19
19
|
import Icon from '@antscorp/icons';
|
|
20
20
|
const { Text } = Typography;
|
|
21
21
|
export const TimeRangeDisplay = forwardRef((props, ref) => {
|
|
22
|
-
const { showType = true } = props, rest = __rest(props, ["showType"]);
|
|
22
|
+
const { showType = true, formatStart, formatEnd, operator } = props, rest = __rest(props, ["showType", "formatStart", "formatEnd", "operator"]);
|
|
23
23
|
const { state, action } = useCalendarSelectionContext();
|
|
24
24
|
// console.log({ state, action });
|
|
25
25
|
const [collapse, setCollapse] = useState(false);
|
|
26
26
|
useEffect(() => {
|
|
27
27
|
setCollapse(false);
|
|
28
28
|
}, []);
|
|
29
|
-
const { rangeInfo, rangeValue } = state.value.
|
|
29
|
+
const { rangeInfo, rangeValue } = state.value.original;
|
|
30
30
|
const handleOpenPopover = () => {
|
|
31
31
|
action.dispatch({ type: ACTION_TYPES.togglePopover });
|
|
32
32
|
};
|
|
33
33
|
const rangeSelectedTitle = getRangeTypeSelectedTitle(rangeInfo);
|
|
34
|
-
const rangeValueTitles = getRangeValueSelctedTitle(rangeValue
|
|
34
|
+
const rangeValueTitles = getRangeValueSelctedTitle(rangeValue, {
|
|
35
|
+
formatStart,
|
|
36
|
+
formatEnd,
|
|
37
|
+
operator,
|
|
38
|
+
});
|
|
35
39
|
// console.log({ rangeSelectedTitle, rangeValueTitles });
|
|
36
40
|
return (React.createElement(StyledBtnDisplayWrapper, Object.assign({ ref: ref }, rest, { onClick: handleOpenPopover, role: "button" }),
|
|
37
41
|
showType && (React.createElement(Text, { className: "range-type", ellipsis: { tooltip: rangeSelectedTitle } }, rangeSelectedTitle)),
|
|
@@ -2,4 +2,5 @@
|
|
|
2
2
|
export declare const StyledPopover: import("styled-components").StyledComponent<import("react").ForwardRefExoticComponent<import("antd").PopoverProps & import("react").RefAttributes<unknown>> & {
|
|
3
3
|
_InternalPanelDoNotUseOrYouWillBeFired: import("react").FC<import("antd/es/popover/PurePanel").PurePanelProps>;
|
|
4
4
|
}, any, {}, never>;
|
|
5
|
+
export declare const StyledPopoverContainer: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
5
6
|
export declare const StyledPopoverBody: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
@@ -3,8 +3,11 @@ import styled from 'styled-components';
|
|
|
3
3
|
export const StyledPopover = styled(Popover) `
|
|
4
4
|
font-size: 12px;
|
|
5
5
|
`;
|
|
6
|
+
export const StyledPopoverContainer = styled.div ``;
|
|
6
7
|
export const StyledPopoverBody = styled.div `
|
|
7
8
|
font-size: 12px;
|
|
8
9
|
display: flex;
|
|
9
|
-
max-
|
|
10
|
+
max-height: 75vh;
|
|
11
|
+
|
|
12
|
+
overflow: auto;
|
|
10
13
|
`;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { PopoverProps } from 'antd';
|
|
2
|
-
import { Dayjs } from 'dayjs';
|
|
3
2
|
import { Dispatch } from 'react';
|
|
4
3
|
import { ValueOf } from 'type-fest';
|
|
5
4
|
import { updateRangeInfo, changeRangeType, updateRangeValue, changeAutoUpdateTo, initState, togglePopover, apply, resetValue } from './actions';
|
|
@@ -86,8 +85,8 @@ export type DaysUpToYesterday = {
|
|
|
86
85
|
};
|
|
87
86
|
export type RangeInfo = Custom | ToDay | Yesterday | ThisWeek | LastWeek | Last7Days | Last14Days | Last30Days | ThisMonth | LastMonth | ThisQuarter | LastQuarter | AllTime | DaysUpToToday | DaysUpToYesterday;
|
|
88
87
|
export type RangeValue = {
|
|
89
|
-
start:
|
|
90
|
-
end:
|
|
88
|
+
start: string | null;
|
|
89
|
+
end: string | null;
|
|
91
90
|
label?: string;
|
|
92
91
|
color?: string;
|
|
93
92
|
};
|
|
@@ -1,38 +1,42 @@
|
|
|
1
|
-
import dayjs from 'dayjs';
|
|
2
1
|
import { AutoUpdateTo, RangeInfo, RangeValue, ReducerState } from './types';
|
|
3
2
|
export declare const rangeInfoToStringType: (rangeInfo: RangeInfo) => string;
|
|
4
3
|
export declare const serializeWeekStartsOn: (rangeType: string) => number | undefined;
|
|
5
4
|
export declare const generateRangeInfo: (rangeType: string) => RangeInfo | null;
|
|
6
5
|
export declare const getDefaultDate: () => {
|
|
7
|
-
toDay:
|
|
8
|
-
yesterday:
|
|
9
|
-
startWeekSS:
|
|
10
|
-
startWeekMS:
|
|
11
|
-
last7Days:
|
|
12
|
-
startLastWeekSS:
|
|
13
|
-
startLastWeekMS:
|
|
14
|
-
endLastWeekSS:
|
|
15
|
-
endLastWeekMS:
|
|
16
|
-
last14Days:
|
|
17
|
-
startOfThisMonth:
|
|
18
|
-
endOfThisMonth:
|
|
19
|
-
last30Days:
|
|
20
|
-
lastMonthFirstDate:
|
|
21
|
-
lastMonthLastDate:
|
|
22
|
-
thisQuaterFirstDate:
|
|
23
|
-
thisQuaterLastDate:
|
|
24
|
-
lastQuaterFirstDate:
|
|
25
|
-
lastQuaterLastDate:
|
|
6
|
+
toDay: string;
|
|
7
|
+
yesterday: string;
|
|
8
|
+
startWeekSS: string;
|
|
9
|
+
startWeekMS: string;
|
|
10
|
+
last7Days: string;
|
|
11
|
+
startLastWeekSS: string;
|
|
12
|
+
startLastWeekMS: string;
|
|
13
|
+
endLastWeekSS: string;
|
|
14
|
+
endLastWeekMS: string;
|
|
15
|
+
last14Days: string;
|
|
16
|
+
startOfThisMonth: string;
|
|
17
|
+
endOfThisMonth: string;
|
|
18
|
+
last30Days: string;
|
|
19
|
+
lastMonthFirstDate: string;
|
|
20
|
+
lastMonthLastDate: string;
|
|
21
|
+
thisQuaterFirstDate: string;
|
|
22
|
+
thisQuaterLastDate: string;
|
|
23
|
+
lastQuaterFirstDate: string;
|
|
24
|
+
lastQuaterLastDate: string;
|
|
26
25
|
maxSub: number;
|
|
27
|
-
todayUptoCount: (val: number) =>
|
|
28
|
-
yesterdayUptoCount: (val: number) =>
|
|
26
|
+
todayUptoCount: (val: number) => string;
|
|
27
|
+
yesterdayUptoCount: (val: number) => string;
|
|
29
28
|
};
|
|
30
29
|
export declare const getRangeValue: ({ rangeInfo, currentRangeValue, limitNumOfDays, }: {
|
|
31
30
|
rangeInfo: RangeInfo;
|
|
32
31
|
currentRangeValue: RangeValue[];
|
|
33
32
|
limitNumOfDays?: number | undefined;
|
|
34
33
|
}) => RangeValue[];
|
|
35
|
-
export declare const getRangeValueSelctedTitle: (rangeValue: RangeValue[]
|
|
34
|
+
export declare const getRangeValueSelctedTitle: (rangeValue: RangeValue[], options?: {
|
|
35
|
+
formatStart?: string;
|
|
36
|
+
formatEnd?: string;
|
|
37
|
+
minimize?: boolean;
|
|
38
|
+
operator?: string;
|
|
39
|
+
}) => string[];
|
|
36
40
|
export declare const getRangeTypeSelectedTitle: (rangeInfo: RangeInfo) => string;
|
|
37
41
|
export declare const combineCurrentValue: (state: ReducerState) => {
|
|
38
42
|
rangeInfo: RangeInfo;
|
|
@@ -96,28 +96,28 @@ export const generateRangeInfo = (rangeType) => {
|
|
|
96
96
|
export const getDefaultDate = () => {
|
|
97
97
|
const toDayTz = dayjs(new Date());
|
|
98
98
|
return {
|
|
99
|
-
toDay: toDayTz,
|
|
100
|
-
yesterday: toDayTz.subtract(1, 'd'),
|
|
101
|
-
startWeekSS: toDayTz.weekday(0),
|
|
102
|
-
startWeekMS: toDayTz.isoWeekday(1),
|
|
103
|
-
last7Days: toDayTz.subtract(1, 'w'),
|
|
104
|
-
startLastWeekSS: toDayTz.subtract(1, 'w').weekday(0),
|
|
105
|
-
startLastWeekMS: toDayTz.subtract(1, 'w').isoWeekday(1),
|
|
106
|
-
endLastWeekSS: toDayTz.subtract(1, 'w').weekday(6),
|
|
107
|
-
endLastWeekMS: toDayTz.subtract(1, 'w').isoWeekday(7),
|
|
108
|
-
last14Days: toDayTz.subtract(14, 'd'),
|
|
109
|
-
startOfThisMonth: toDayTz.startOf('M'),
|
|
110
|
-
endOfThisMonth: toDayTz.endOf('M'),
|
|
111
|
-
last30Days: toDayTz.subtract(30, 'd'),
|
|
112
|
-
lastMonthFirstDate: toDayTz.subtract(1, 'M').startOf('M'),
|
|
113
|
-
lastMonthLastDate: toDayTz.subtract(1, 'M').endOf('M'),
|
|
114
|
-
thisQuaterFirstDate: toDayTz.startOf('Q'),
|
|
115
|
-
thisQuaterLastDate: toDayTz.endOf('Q'),
|
|
116
|
-
lastQuaterFirstDate: toDayTz.subtract(1, 'Q').startOf('Q'),
|
|
117
|
-
lastQuaterLastDate: toDayTz.subtract(1, 'Q').endOf('Q'),
|
|
99
|
+
toDay: toDayTz.toISOString(),
|
|
100
|
+
yesterday: toDayTz.subtract(1, 'd').toISOString(),
|
|
101
|
+
startWeekSS: toDayTz.weekday(0).toISOString(),
|
|
102
|
+
startWeekMS: toDayTz.isoWeekday(1).toISOString(),
|
|
103
|
+
last7Days: toDayTz.subtract(1, 'w').toISOString(),
|
|
104
|
+
startLastWeekSS: toDayTz.subtract(1, 'w').weekday(0).toISOString(),
|
|
105
|
+
startLastWeekMS: toDayTz.subtract(1, 'w').isoWeekday(1).toISOString(),
|
|
106
|
+
endLastWeekSS: toDayTz.subtract(1, 'w').weekday(6).toISOString(),
|
|
107
|
+
endLastWeekMS: toDayTz.subtract(1, 'w').isoWeekday(7).toISOString(),
|
|
108
|
+
last14Days: toDayTz.subtract(14, 'd').toISOString(),
|
|
109
|
+
startOfThisMonth: toDayTz.startOf('M').toISOString(),
|
|
110
|
+
endOfThisMonth: toDayTz.endOf('M').toISOString(),
|
|
111
|
+
last30Days: toDayTz.subtract(30, 'd').toISOString(),
|
|
112
|
+
lastMonthFirstDate: toDayTz.subtract(1, 'M').startOf('M').toISOString(),
|
|
113
|
+
lastMonthLastDate: toDayTz.subtract(1, 'M').endOf('M').toISOString(),
|
|
114
|
+
thisQuaterFirstDate: toDayTz.startOf('Q').toISOString(),
|
|
115
|
+
thisQuaterLastDate: toDayTz.endOf('Q').toISOString(),
|
|
116
|
+
lastQuaterFirstDate: toDayTz.subtract(1, 'Q').startOf('Q').toISOString(),
|
|
117
|
+
lastQuaterLastDate: toDayTz.subtract(1, 'Q').endOf('Q').toISOString(),
|
|
118
118
|
maxSub: toDayTz.diff(dayZero, 'd'),
|
|
119
|
-
todayUptoCount: (val) => toDayTz.subtract(Math.round(val - 1), 'd'),
|
|
120
|
-
yesterdayUptoCount: (val) => toDayTz.subtract(Math.round(val - 1) + 1, 'd'),
|
|
119
|
+
todayUptoCount: (val) => toDayTz.subtract(Math.round(val - 1), 'd').toISOString(),
|
|
120
|
+
yesterdayUptoCount: (val) => toDayTz.subtract(Math.round(val - 1) + 1, 'd').toISOString(),
|
|
121
121
|
};
|
|
122
122
|
};
|
|
123
123
|
export const getRangeValue = ({ rangeInfo, currentRangeValue, limitNumOfDays = RANGE_LIMIT, }) => {
|
|
@@ -206,17 +206,17 @@ export const getRangeValue = ({ rangeInfo, currentRangeValue, limitNumOfDays = R
|
|
|
206
206
|
break;
|
|
207
207
|
}
|
|
208
208
|
case SELECTION_KEY.all_time: {
|
|
209
|
-
temp.start = defaultDates.toDay.subtract(limitNumOfDays, 'd');
|
|
209
|
+
temp.start = dayjs(defaultDates.toDay).subtract(limitNumOfDays, 'd').toISOString();
|
|
210
210
|
temp.end = defaultDates.toDay;
|
|
211
211
|
break;
|
|
212
212
|
}
|
|
213
213
|
case SELECTION_KEY.days_up_to_today: {
|
|
214
|
-
temp.start = defaultDates.toDay.subtract(rangeInfo.numOfDays, 'd');
|
|
214
|
+
temp.start = dayjs(defaultDates.toDay).subtract(rangeInfo.numOfDays, 'd').toISOString();
|
|
215
215
|
temp.end = defaultDates.toDay;
|
|
216
216
|
break;
|
|
217
217
|
}
|
|
218
218
|
case SELECTION_KEY.days_up_to_yesterday: {
|
|
219
|
-
temp.start = defaultDates.toDay.subtract(rangeInfo.numOfDays, 'd');
|
|
219
|
+
temp.start = dayjs(defaultDates.toDay).subtract(rangeInfo.numOfDays, 'd').toISOString();
|
|
220
220
|
temp.end = defaultDates.yesterday;
|
|
221
221
|
break;
|
|
222
222
|
}
|
|
@@ -227,17 +227,21 @@ export const getRangeValue = ({ rangeInfo, currentRangeValue, limitNumOfDays = R
|
|
|
227
227
|
});
|
|
228
228
|
return result;
|
|
229
229
|
};
|
|
230
|
-
export const getRangeValueSelctedTitle = (rangeValue) => {
|
|
230
|
+
export const getRangeValueSelctedTitle = (rangeValue, options) => {
|
|
231
|
+
const { formatStart, formatEnd, operator = '-' } = options || {};
|
|
231
232
|
const result = [];
|
|
232
233
|
rangeValue.forEach(range => {
|
|
234
|
+
var _a, _b, _c, _d, _e;
|
|
233
235
|
const { start, end } = range;
|
|
234
|
-
let startFormat = 'MMM D';
|
|
235
|
-
|
|
236
|
-
|
|
236
|
+
let startFormat = formatStart || 'MMM D';
|
|
237
|
+
const endFormat = formatEnd || 'MMM D YYYY';
|
|
238
|
+
if ((_a = dayjs(start)) === null || _a === void 0 ? void 0 : _a.isSame(dayjs(end), 'D')) {
|
|
239
|
+
return result.push((_b = dayjs(start)) === null || _b === void 0 ? void 0 : _b.format('MMM D YYYY'));
|
|
237
240
|
}
|
|
238
|
-
if (!(start === null ||
|
|
241
|
+
if (!((_c = dayjs(start)) === null || _c === void 0 ? void 0 : _c.isSame(dayjs(end), 'y')) && !formatStart) {
|
|
239
242
|
startFormat = `${startFormat} YYYY`;
|
|
240
|
-
|
|
243
|
+
}
|
|
244
|
+
result.push(`${(_d = dayjs(start)) === null || _d === void 0 ? void 0 : _d.format(startFormat)} ${operator} ${(_e = dayjs(end)) === null || _e === void 0 ? void 0 : _e.format(endFormat)}`);
|
|
241
245
|
});
|
|
242
246
|
return result;
|
|
243
247
|
};
|
|
@@ -385,7 +385,7 @@ export const AdvancedPicker = props => {
|
|
|
385
385
|
// ref={ref}
|
|
386
386
|
, {
|
|
387
387
|
// ref={ref}
|
|
388
|
-
disabled: disabled, open: !disabled && isOpen, allowClear: false, inputReadOnly: true, status: errorMessage ? 'error' : '', inputRender: () => (React.createElement(DatePickerCustomInput, { readOnly: true, placeholder: "Select Date", value: selectedDateTitle, onClick: () => toggleOpenDropdown() })), value: currDate,
|
|
388
|
+
disabled: disabled, open: !disabled && isOpen, allowClear: false, inputReadOnly: true, style: Object.assign({ textOverflow: 'ellipsis' }, inputStyle), status: errorMessage ? 'error' : '', inputRender: () => (React.createElement(DatePickerCustomInput, { readOnly: true, placeholder: "Select Date", value: selectedDateTitle, onClick: () => toggleOpenDropdown() })), value: currDate,
|
|
389
389
|
// style={{
|
|
390
390
|
// width: 120,
|
|
391
391
|
// }}
|
package/es/components/molecules/DatePicker/components/AdvancedRangePicker/AdvancedRangePicker.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export interface AdvancedRangePickerProps {
|
|
|
13
13
|
showTime?: boolean;
|
|
14
14
|
timezone?: string;
|
|
15
15
|
separator?: ReactNode;
|
|
16
|
+
inputStyle?: React.CSSProperties;
|
|
16
17
|
onChange?: ({ timeRange, mode }: TOnChangePayload) => void;
|
|
17
18
|
}
|
|
18
19
|
export declare const AdvancedRangePicker: React.FC<AdvancedRangePickerProps>;
|
package/es/components/molecules/DatePicker/components/AdvancedRangePicker/AdvancedRangePicker.js
CHANGED
|
@@ -19,7 +19,7 @@ const PATH = '@antscorp/antsomi-ui/es/components/molecules/DatePicker/components
|
|
|
19
19
|
export const AdvancedRangePicker = props => {
|
|
20
20
|
const { t } = i18nInstance;
|
|
21
21
|
// Props
|
|
22
|
-
const { valueType, timeRange, errorMessage, showLabel, startDateConfig, endDateConfig, showTime, showCalculationTypeCondition, disabled, timezone, separator, onChange, } = props;
|
|
22
|
+
const { valueType, timeRange, errorMessage, showLabel, startDateConfig, endDateConfig, showTime, showCalculationTypeCondition, disabled, timezone, separator, inputStyle, onChange, } = props;
|
|
23
23
|
const [timeRangeState, setTimeRange] = useState(timeRange);
|
|
24
24
|
useDeepCompareEffect(() => {
|
|
25
25
|
if (typeof onChange === 'function') {
|
|
@@ -55,9 +55,9 @@ export const AdvancedRangePicker = props => {
|
|
|
55
55
|
}
|
|
56
56
|
};
|
|
57
57
|
return (React.createElement(Space, { size: 20, align: "end" },
|
|
58
|
-
React.createElement(AdvancedPicker, { valueType: valueType, disabled: disabled, label: showLabel ? t(translations.datePicker.startDate) || '' : '', date: timeRange.startDate.date, option: omit(timeRange.startDate, 'date'), operatorKey: "between", type: "startDate", format: ADVANCED_RANGE_PICKER_FORMAT.startDate, errorMessage: errorMessage, disableAfterDate: timeRange.endDate.date, showTime: showTime, calculationTypeKeysShow: startDateConfig === null || startDateConfig === void 0 ? void 0 : startDateConfig.calculationTypeKeysShow, showCalculationTypeCondition: showCalculationTypeCondition, timezone: timezone, onUpdatedNewDate: ({ date }) => onUpdateTimeRange('startDate', { date }, 'system'), onApply: ({ date, option }) => onUpdateTimeRange('startDate', Object.assign({ date }, option), 'user') }),
|
|
58
|
+
React.createElement(AdvancedPicker, { valueType: valueType, disabled: disabled, label: showLabel ? t(translations.datePicker.startDate) || '' : '', date: timeRange.startDate.date, option: omit(timeRange.startDate, 'date'), operatorKey: "between", type: "startDate", format: ADVANCED_RANGE_PICKER_FORMAT.startDate, errorMessage: errorMessage, disableAfterDate: timeRange.endDate.date, showTime: showTime, calculationTypeKeysShow: startDateConfig === null || startDateConfig === void 0 ? void 0 : startDateConfig.calculationTypeKeysShow, showCalculationTypeCondition: showCalculationTypeCondition, timezone: timezone, onUpdatedNewDate: ({ date }) => onUpdateTimeRange('startDate', { date }, 'system'), onApply: ({ date, option }) => onUpdateTimeRange('startDate', Object.assign({ date }, option), 'user'), inputStyle: inputStyle }),
|
|
59
59
|
separator || null,
|
|
60
|
-
React.createElement(AdvancedPicker, { valueType: valueType, disabled: disabled, label: showLabel ? t(translations.datePicker.endDate) || '' : '', date: timeRange.endDate.date, option: omit(timeRange.endDate, 'date'), operatorKey: "between", type: "endDate", format: ADVANCED_RANGE_PICKER_FORMAT.endDate, errorMessage: errorMessage, showTime: showTime, calculationTypeKeysShow: endDateConfig === null || endDateConfig === void 0 ? void 0 : endDateConfig.calculationTypeKeysShow, showCalculationTypeCondition: showCalculationTypeCondition, timezone: timezone, onUpdatedNewDate: ({ date }) => onUpdateTimeRange('endDate', { date }, 'system'), onApply: ({ date, option }) => onUpdateTimeRange('endDate', Object.assign({ date }, option), 'user') })));
|
|
60
|
+
React.createElement(AdvancedPicker, { valueType: valueType, disabled: disabled, label: showLabel ? t(translations.datePicker.endDate) || '' : '', date: timeRange.endDate.date, option: omit(timeRange.endDate, 'date'), operatorKey: "between", type: "endDate", format: ADVANCED_RANGE_PICKER_FORMAT.endDate, errorMessage: errorMessage, showTime: showTime, calculationTypeKeysShow: endDateConfig === null || endDateConfig === void 0 ? void 0 : endDateConfig.calculationTypeKeysShow, showCalculationTypeCondition: showCalculationTypeCondition, timezone: timezone, onUpdatedNewDate: ({ date }) => onUpdateTimeRange('endDate', { date }, 'system'), onApply: ({ date, option }) => onUpdateTimeRange('endDate', Object.assign({ date }, option), 'user'), inputStyle: inputStyle })));
|
|
61
61
|
};
|
|
62
62
|
AdvancedRangePicker.defaultProps = {
|
|
63
63
|
timeRange: {
|