@spaced-out/ui-design-system 0.5.26 → 0.5.27
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 +7 -0
- package/lib/components/DateRangePicker/Calendar.d.ts +6 -0
- package/lib/components/DateRangePicker/Calendar.d.ts.map +1 -1
- package/lib/components/DateRangePicker/Calendar.js +91 -20
- package/lib/components/DateRangePicker/Calendar.module.css +9 -0
- package/lib/components/DateRangePicker/DateRangePicker.d.ts.map +1 -1
- package/lib/components/DateRangePicker/DateRangePicker.js +48 -3
- package/lib/components/DateRangePicker/DateRangeWrapper.d.ts +8 -1
- package/lib/components/DateRangePicker/DateRangeWrapper.d.ts.map +1 -1
- package/lib/components/DateRangePicker/DateRangeWrapper.js +470 -189
- package/lib/components/DateRangePicker/DateRangeWrapper.module.css +36 -2
- package/lib/components/DateRangePicker/Day.d.ts +2 -1
- package/lib/components/DateRangePicker/Day.d.ts.map +1 -1
- package/lib/components/DateRangePicker/Day.js +5 -3
- package/lib/components/DateRangePicker/Day.module.css +7 -1
- package/lib/utils/date-range-picker/date-range-picker.d.ts +9 -3
- package/lib/utils/date-range-picker/date-range-picker.d.ts.map +1 -1
- package/lib/utils/date-range-picker/date-range-picker.js +36 -3
- package/mcp/package.json +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [0.5.27](https://github.com/spaced-out/ui-design-system/compare/v0.5.26...v0.5.27) (2025-11-24)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* **GDS-540:** Small Date Range ([#419](https://github.com/spaced-out/ui-design-system/issues/419)) ([01ebf91](https://github.com/spaced-out/ui-design-system/commit/01ebf91060231df5838ab5f32e2282001f6f06c5))
|
|
11
|
+
|
|
5
12
|
### [0.5.26](https://github.com/spaced-out/ui-design-system/compare/v0.5.25...v0.5.26) (2025-11-20)
|
|
6
13
|
|
|
7
14
|
|
|
@@ -18,6 +18,12 @@ interface CalendarProps {
|
|
|
18
18
|
t: ((key: string, fallback: string) => string) | null | undefined;
|
|
19
19
|
testId?: string;
|
|
20
20
|
}
|
|
21
|
+
interface CalendarMobileProps extends Omit<CalendarProps, 'marker' | 'handlers'> {
|
|
22
|
+
handlers: Omit<CalendarProps['handlers'], 'onMonthNavigate'> & {
|
|
23
|
+
onMonthNavigate: (action: (typeof NAVIGATION_ACTION)[keyof typeof NAVIGATION_ACTION]) => void;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
21
26
|
export declare const Calendar: ({ value, minDate, maxDate, handlers, hoverDay, dateRange, inHoverRange, today, t, testId, }: CalendarProps) => React.JSX.Element;
|
|
27
|
+
export declare const CalendarMobile: ({ value, minDate, maxDate, handlers, hoverDay, dateRange, inHoverRange, today, t, testId, }: CalendarMobileProps) => React.JSX.Element;
|
|
22
28
|
export {};
|
|
23
29
|
//# sourceMappingURL=Calendar.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Calendar.d.ts","sourceRoot":"","sources":["../../../src/components/DateRangePicker/Calendar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAC,OAAO,EAAE,iBAAiB,EAAC,MAAM,WAAW,CAAC;AAwB1D,UAAU,aAAa;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,CAAC,OAAO,OAAO,CAAC,CAAC,MAAM,OAAO,OAAO,CAAC,CAAC;IAC/C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAA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AAC;IACvC,QAAQ,EAAE;QACR,UAAU,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;QAClC,UAAU,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;QAClC,eAAe,EAAE,CACf,MAAM,EAAE,CAAC,OAAO,OAAO,CAAC,CAAC,MAAM,OAAO,OAAO,CAAC,EAC9C,MAAM,EAAE,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,OAAO,iBAAiB,CAAC,KAC/D,IAAI,CAAC;KACX,CAAC;IACF,KAAK,EAAE,MAAM,CAAC;IACd,CAAC,EAAE,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC;IAClE,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,UAAU,mBACR,SAAQ,IAAI,CAAC,aAAa,EAAE,QAAQ,GAAG,UAAU,CAAC;IAClD,QAAQ,EAAE,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,EAAE,iBAAiB,CAAC,GAAG;QAC7D,eAAe,EAAE,CACf,MAAM,EAAE,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,OAAO,iBAAiB,CAAC,KAC/D,IAAI,CAAC;KACX,CAAC;CACH;AAsBD,eAAO,MAAM,QAAQ,GAAI,6FAWtB,aAAa,sBAmDf,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,6FAW5B,mBAAmB,sBAoDrB,CAAC"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.Calendar = void 0;
|
|
6
|
+
exports.CalendarMobile = exports.Calendar = void 0;
|
|
7
7
|
var React = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _moment = _interopRequireDefault(require("moment"));
|
|
9
9
|
var _utils = require("../../utils");
|
|
@@ -15,7 +15,29 @@ var _CalendarModule = _interopRequireDefault(require("./Calendar.module.css"));
|
|
|
15
15
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
16
16
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
17
17
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
18
|
-
const
|
|
18
|
+
const WeekDayHeader = _ref => {
|
|
19
|
+
let {
|
|
20
|
+
t,
|
|
21
|
+
testId
|
|
22
|
+
} = _ref;
|
|
23
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
24
|
+
className: _CalendarModule.default.calendarRow,
|
|
25
|
+
"data-testid": (0, _qa.generateTestId)({
|
|
26
|
+
base: testId,
|
|
27
|
+
slot: 'weekdays'
|
|
28
|
+
}),
|
|
29
|
+
children: _utils.WEEKDAYS.map(day => /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.BodySmall, {
|
|
30
|
+
className: _CalendarModule.default.calendarRowItem,
|
|
31
|
+
color: _Text.TEXT_COLORS.tertiary,
|
|
32
|
+
testId: (0, _qa.generateTestId)({
|
|
33
|
+
base: testId,
|
|
34
|
+
slot: `weekday-${day}`
|
|
35
|
+
}),
|
|
36
|
+
children: (0, _dateRangePicker.getTranslation)(t, day)
|
|
37
|
+
}, day))
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
const Calendar = _ref2 => {
|
|
19
41
|
let {
|
|
20
42
|
value,
|
|
21
43
|
minDate,
|
|
@@ -27,28 +49,16 @@ const Calendar = _ref => {
|
|
|
27
49
|
today,
|
|
28
50
|
t,
|
|
29
51
|
testId
|
|
30
|
-
} =
|
|
52
|
+
} = _ref2;
|
|
31
53
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
32
54
|
className: _CalendarModule.default.calendar,
|
|
33
55
|
"data-testid": (0, _qa.generateTestId)({
|
|
34
56
|
base: testId,
|
|
35
57
|
slot: `calendar-${value}`
|
|
36
58
|
}),
|
|
37
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
base: testId,
|
|
41
|
-
slot: 'weekdays'
|
|
42
|
-
}),
|
|
43
|
-
children: _utils.WEEKDAYS.map(day => /*#__PURE__*/(0, _jsxRuntime.jsx)(_Text.BodySmall, {
|
|
44
|
-
className: _CalendarModule.default.calendarRowItem,
|
|
45
|
-
color: _Text.TEXT_COLORS.tertiary,
|
|
46
|
-
testId: (0, _qa.generateTestId)({
|
|
47
|
-
base: testId,
|
|
48
|
-
slot: `weekday-${day}`
|
|
49
|
-
}),
|
|
50
|
-
children: (0, _dateRangePicker.getTranslation)(t, day)
|
|
51
|
-
}, day))
|
|
59
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(WeekDayHeader, {
|
|
60
|
+
t: t,
|
|
61
|
+
testId: testId
|
|
52
62
|
}), (0, _utils.getDaysInMonth)(value).map((week, index) => /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
53
63
|
className: _CalendarModule.default.calendarRow,
|
|
54
64
|
"data-testid": (0, _qa.generateTestId)({
|
|
@@ -80,10 +90,71 @@ const Calendar = _ref => {
|
|
|
80
90
|
testId: (0, _qa.generateTestId)({
|
|
81
91
|
base: testId,
|
|
82
92
|
slot: `day-${date}`
|
|
83
|
-
})
|
|
93
|
+
}),
|
|
94
|
+
inDateRange: Boolean(dateRange.startDate && dateRange.endDate && (0, _utils.inDateRange)(dateRange, date))
|
|
84
95
|
}, date);
|
|
85
96
|
})
|
|
86
97
|
}, week[index]))]
|
|
87
98
|
});
|
|
88
99
|
};
|
|
89
|
-
exports.Calendar = Calendar;
|
|
100
|
+
exports.Calendar = Calendar;
|
|
101
|
+
const CalendarMobile = _ref3 => {
|
|
102
|
+
let {
|
|
103
|
+
value,
|
|
104
|
+
minDate,
|
|
105
|
+
maxDate = (0, _utils.formatIsoDate)(),
|
|
106
|
+
handlers,
|
|
107
|
+
hoverDay,
|
|
108
|
+
dateRange,
|
|
109
|
+
inHoverRange,
|
|
110
|
+
today,
|
|
111
|
+
t,
|
|
112
|
+
testId
|
|
113
|
+
} = _ref3;
|
|
114
|
+
const monthMoment = _moment.default.utc(value, 'YYYY-MM');
|
|
115
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
116
|
+
className: _CalendarModule.default.calendarMobile,
|
|
117
|
+
"data-testid": (0, _qa.generateTestId)({
|
|
118
|
+
base: testId,
|
|
119
|
+
slot: `calendar-${value}`
|
|
120
|
+
}),
|
|
121
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(WeekDayHeader, {
|
|
122
|
+
t: t,
|
|
123
|
+
testId: testId
|
|
124
|
+
}), (0, _utils.getDaysInMonth)(value).map((week, index) => /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
125
|
+
className: _CalendarModule.default.calendarRow,
|
|
126
|
+
"data-testid": (0, _qa.generateTestId)({
|
|
127
|
+
base: testId,
|
|
128
|
+
slot: `week-${index}`
|
|
129
|
+
}),
|
|
130
|
+
children: week.map(date => {
|
|
131
|
+
const isStart = date === dateRange.startDate;
|
|
132
|
+
const isEnd = date === dateRange.endDate;
|
|
133
|
+
const highlighted = (0, _utils.inDateRange)(dateRange, date) || inHoverRange(date);
|
|
134
|
+
const {
|
|
135
|
+
onDayClick,
|
|
136
|
+
onDayHover
|
|
137
|
+
} = handlers;
|
|
138
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Day.Day, {
|
|
139
|
+
date: date,
|
|
140
|
+
filled: isStart || isEnd,
|
|
141
|
+
startOfRange: isStart && !dateRange.endDate,
|
|
142
|
+
endOfRange: isEnd && !dateRange.startDate,
|
|
143
|
+
highlighted: highlighted,
|
|
144
|
+
outlined: date === today,
|
|
145
|
+
disabled: minDate && (0, _dateRangePicker.isBefore)(date, minDate) || maxDate && (0, _dateRangePicker.isAfter)(date, maxDate) || !monthMoment.isSame(_moment.default.utc(date), 'month'),
|
|
146
|
+
value: _moment.default.utc(date).date().toString(),
|
|
147
|
+
hoverDay: hoverDay,
|
|
148
|
+
onClick: () => onDayClick(date),
|
|
149
|
+
onHover: () => onDayHover(date),
|
|
150
|
+
testId: (0, _qa.generateTestId)({
|
|
151
|
+
base: testId,
|
|
152
|
+
slot: `day-${date}`
|
|
153
|
+
}),
|
|
154
|
+
inDateRange: Boolean(dateRange.startDate && dateRange.endDate && (0, _utils.inDateRange)(dateRange, date))
|
|
155
|
+
}, date);
|
|
156
|
+
})
|
|
157
|
+
}, week[0]))]
|
|
158
|
+
});
|
|
159
|
+
};
|
|
160
|
+
exports.CalendarMobile = CalendarMobile;
|
|
@@ -23,6 +23,15 @@
|
|
|
23
23
|
gap: spaceNone;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
.calendarMobile {
|
|
27
|
+
display: flex;
|
|
28
|
+
flex-direction: column;
|
|
29
|
+
justify-content: center;
|
|
30
|
+
width: spaceFluid;
|
|
31
|
+
padding: spaceXSmall spaceLarge;
|
|
32
|
+
gap: spaceNone;
|
|
33
|
+
}
|
|
34
|
+
|
|
26
35
|
.calendarRow {
|
|
27
36
|
display: grid;
|
|
28
37
|
grid-template-columns: repeat(7, 1fr);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateRangePicker.d.ts","sourceRoot":"","sources":["../../../src/components/DateRangePicker/DateRangePicker.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,4BAA4B,CAAC;AAIrD,OAAO,KAAK,EAEV,oBAAoB,EACpB,qBAAqB,EACtB,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"DateRangePicker.d.ts","sourceRoot":"","sources":["../../../src/components/DateRangePicker/DateRangePicker.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,4BAA4B,CAAC;AAIrD,OAAO,KAAK,EAEV,oBAAoB,EACpB,qBAAqB,EACtB,MAAM,WAAW,CAAC;AAsBnB,KAAK,UAAU,GAAG,QAAQ,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC,CAAC;AAEH,MAAM,WAAW,oBAAoB;IACnC,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,iBAAiB,CAAC,EAAE,qBAAqB,CAAC;IAC1C,OAAO,EAAE,CAAC,uBAAuB,EAAE,qBAAqB,KAAK,IAAI,CAAC;IAClE,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,oBAAoB,KAAK,IAAI,CAAC;IAC/C,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC;IACnE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,eAAO,MAAM,eAAe,EAAE,IAAI,CAAC,iBAAiB,CAClD,oBAAoB,EACpB,cAAc,CA2Of,CAAC"}
|
|
@@ -8,10 +8,8 @@ var React = _interopRequireWildcard(require("react"));
|
|
|
8
8
|
var _lodash = require("lodash");
|
|
9
9
|
var _momentTimezone = _interopRequireDefault(require("moment-timezone"));
|
|
10
10
|
var _utils = require("../../utils");
|
|
11
|
-
var _classify = _interopRequireDefault(require("../../utils/classify"));
|
|
12
11
|
var _dateRangePicker = require("../../utils/date-range-picker");
|
|
13
12
|
var _DateRangeWrapper = require("./DateRangeWrapper");
|
|
14
|
-
var _DateRangePickerModule = _interopRequireDefault(require("./DateRangePicker.module.css"));
|
|
15
13
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
16
14
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
17
15
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
@@ -60,6 +58,7 @@ const DateRangePicker = exports.DateRangePicker = /*#__PURE__*/React.forwardRef(
|
|
|
60
58
|
const [hoverDay, setHoverDay] = React.useState('');
|
|
61
59
|
const [rangeStartMonth, setRangeStartMonth] = React.useState(validRangeStartMonth);
|
|
62
60
|
const [rangeEndMonth, setRangeEndMonth] = React.useState(validRangeEndMonth);
|
|
61
|
+
const [isMobileSyncedToStartMonth, setIsMobileSyncedToStartMonth] = React.useState(false);
|
|
63
62
|
const setRangeStartMonthValidated = date => {
|
|
64
63
|
if ((0, _dateRangePicker.isSameOrAfter)(date, validMinDate) && (0, _dateRangePicker.isBefore)(date, rangeEndMonth)) {
|
|
65
64
|
setRangeStartMonth(date);
|
|
@@ -78,11 +77,48 @@ const DateRangePicker = exports.DateRangePicker = /*#__PURE__*/React.forwardRef(
|
|
|
78
77
|
if (marker === _utils.MARKERS.DATE_RANGE_START) {
|
|
79
78
|
const newMonth = action === _utils.NAVIGATION_ACTION.NEXT ? (0, _utils.getMonthEndDate)((0, _utils.getAddedDate)(rangeStartMonth, 1, 'M')) : (0, _utils.getMonthEndDate)((0, _utils.getSubtractedDate)(rangeStartMonth, 1, 'M'));
|
|
80
79
|
setRangeStartMonthValidated(newMonth);
|
|
80
|
+
setIsMobileSyncedToStartMonth(true);
|
|
81
81
|
} else {
|
|
82
82
|
const newMonth = action === _utils.NAVIGATION_ACTION.NEXT ? (0, _utils.getMonthEndDate)((0, _utils.getAddedDate)(rangeEndMonth, 1, 'M')) : (0, _utils.getMonthEndDate)((0, _utils.getSubtractedDate)(rangeEndMonth, 1, 'M'));
|
|
83
83
|
setRangeEndMonthValidated(newMonth);
|
|
84
|
+
setIsMobileSyncedToStartMonth(false);
|
|
84
85
|
}
|
|
85
86
|
};
|
|
87
|
+
const handleMobileCalendarMonthSelection = newMonth => {
|
|
88
|
+
const {
|
|
89
|
+
startDate,
|
|
90
|
+
endDate
|
|
91
|
+
} = dateRange;
|
|
92
|
+
let start = rangeStartMonth,
|
|
93
|
+
end = rangeEndMonth,
|
|
94
|
+
syncToStart = isMobileSyncedToStartMonth;
|
|
95
|
+
const isEndMonthBeforeStartDate = startDate ? (0, _dateRangePicker.isBefore)(rangeEndMonth, startDate) : false;
|
|
96
|
+
if (startDate && endDate) {
|
|
97
|
+
syncToStart = isEndMonthBeforeStartDate ? (0, _dateRangePicker.isBefore)(newMonth, (0, _utils.getMonthEndDate)(rangeEndMonth)) : (0, _dateRangePicker.isBefore)(newMonth, (0, _utils.getMonthEndDate)(endDate));
|
|
98
|
+
if (syncToStart && (0, _dateRangePicker.isAfter)(newMonth, (0, _utils.getMonthEndDate)(startDate))) {
|
|
99
|
+
syncToStart = false;
|
|
100
|
+
}
|
|
101
|
+
[start, end] = syncToStart ? [newMonth, endDate] : [startDate, newMonth];
|
|
102
|
+
} else if (startDate) {
|
|
103
|
+
syncToStart = isEndMonthBeforeStartDate ? (0, _dateRangePicker.isBefore)(newMonth, (0, _utils.getMonthEndDate)(rangeEndMonth)) : (0, _dateRangePicker.isSameOrBefore)(newMonth, (0, _utils.getMonthEndDate)(startDate));
|
|
104
|
+
[start, end] = syncToStart ? [newMonth, end] : [startDate, newMonth];
|
|
105
|
+
} else {
|
|
106
|
+
syncToStart = (0, _dateRangePicker.isBefore)(newMonth, rangeEndMonth);
|
|
107
|
+
[start, end] = syncToStart ? [newMonth, validMaxDate] : [(0, _utils.getSubtractedDate)(newMonth, 1, 'M'), newMonth];
|
|
108
|
+
}
|
|
109
|
+
setRangeStartMonthValidated(start);
|
|
110
|
+
setRangeEndMonthValidated(end);
|
|
111
|
+
setIsMobileSyncedToStartMonth(syncToStart);
|
|
112
|
+
};
|
|
113
|
+
const handleMobileMonthSelection = date => {
|
|
114
|
+
const newMonth = (0, _utils.getMonthEndDate)(date);
|
|
115
|
+
handleMobileCalendarMonthSelection(newMonth);
|
|
116
|
+
};
|
|
117
|
+
const onMobileMonthNavigate = action => {
|
|
118
|
+
const mobileMonth = isMobileSyncedToStartMonth ? rangeStartMonth : rangeEndMonth;
|
|
119
|
+
const newMonth = action === _utils.NAVIGATION_ACTION.NEXT ? (0, _utils.getMonthEndDate)((0, _utils.getAddedDate)(mobileMonth, 1, 'M')) : (0, _utils.getMonthEndDate)((0, _utils.getSubtractedDate)(mobileMonth, 1, 'M'));
|
|
120
|
+
handleMobileCalendarMonthSelection(newMonth);
|
|
121
|
+
};
|
|
86
122
|
const onDayClick = day => {
|
|
87
123
|
const {
|
|
88
124
|
startDate,
|
|
@@ -98,6 +134,7 @@ const DateRangePicker = exports.DateRangePicker = /*#__PURE__*/React.forwardRef(
|
|
|
98
134
|
startDate: day
|
|
99
135
|
});
|
|
100
136
|
}
|
|
137
|
+
setIsMobileSyncedToStartMonth((0, _utils.getMonthEndDate)(day) === (0, _utils.getMonthEndDate)(rangeStartMonth));
|
|
101
138
|
setHoverDay(day);
|
|
102
139
|
};
|
|
103
140
|
const inHoverRange = day => {
|
|
@@ -112,6 +149,11 @@ const DateRangePicker = exports.DateRangePicker = /*#__PURE__*/React.forwardRef(
|
|
|
112
149
|
onDayHover: setHoverDay,
|
|
113
150
|
onMonthNavigate
|
|
114
151
|
};
|
|
152
|
+
const mobileCalendarHandlers = {
|
|
153
|
+
onDayClick,
|
|
154
|
+
onDayHover: setHoverDay,
|
|
155
|
+
onMonthNavigate: onMobileMonthNavigate
|
|
156
|
+
};
|
|
115
157
|
const handleTimeZone = newTimezone => {
|
|
116
158
|
setToday((0, _dateRangePicker.getTodayInTimezone)(newTimezone));
|
|
117
159
|
setTimezone(newTimezone);
|
|
@@ -122,6 +164,7 @@ const DateRangePicker = exports.DateRangePicker = /*#__PURE__*/React.forwardRef(
|
|
|
122
164
|
maxDate: validMaxDate,
|
|
123
165
|
onApply: onApply,
|
|
124
166
|
handlers: handlers,
|
|
167
|
+
mobileCalendarHandlers: mobileCalendarHandlers,
|
|
125
168
|
hoverDay: hoverDay,
|
|
126
169
|
onCancel: onCancel,
|
|
127
170
|
timezone: timezone,
|
|
@@ -129,11 +172,13 @@ const DateRangePicker = exports.DateRangePicker = /*#__PURE__*/React.forwardRef(
|
|
|
129
172
|
setTimezone: handleTimeZone,
|
|
130
173
|
rangeStartMonth: rangeStartMonth,
|
|
131
174
|
rangeEndMonth: rangeEndMonth,
|
|
175
|
+
mobileCalendarMonth: isMobileSyncedToStartMonth ? rangeStartMonth : rangeEndMonth,
|
|
132
176
|
inHoverRange: inHoverRange,
|
|
133
177
|
setRangeStartMonth: setRangeStartMonthValidated,
|
|
134
178
|
setRangeEndMonth: setRangeEndMonthValidated,
|
|
179
|
+
setRangeMonth: handleMobileMonthSelection,
|
|
135
180
|
hideTimezone: hideTimezone,
|
|
136
|
-
cardWrapperClass:
|
|
181
|
+
cardWrapperClass: classNames?.wrapper,
|
|
137
182
|
today: today,
|
|
138
183
|
startDateLabel: startDateLabel,
|
|
139
184
|
endDateLabel: endDateLabel,
|
|
@@ -8,9 +8,11 @@ interface DateRangeWrapperProps {
|
|
|
8
8
|
maxDate: string;
|
|
9
9
|
rangeStartMonth: string;
|
|
10
10
|
rangeEndMonth: string;
|
|
11
|
+
mobileCalendarMonth: string;
|
|
11
12
|
cardWrapperClass: string | null | undefined;
|
|
12
13
|
setRangeStartMonth: (arg1: string) => void;
|
|
13
14
|
setRangeEndMonth: (arg1: string) => void;
|
|
15
|
+
setRangeMonth: (arg1: string) => void;
|
|
14
16
|
setTimezone: (arg1: string) => void;
|
|
15
17
|
timezone: string;
|
|
16
18
|
onApply: (datePickerSelectedRange: DateRangeWithTimezone) => void;
|
|
@@ -22,10 +24,15 @@ interface DateRangeWrapperProps {
|
|
|
22
24
|
onDayHover: (day: string) => void;
|
|
23
25
|
onMonthNavigate: (marker: (typeof MARKERS)[keyof typeof MARKERS], action: (typeof NAVIGATION_ACTION)[keyof typeof NAVIGATION_ACTION]) => void;
|
|
24
26
|
};
|
|
27
|
+
mobileCalendarHandlers: {
|
|
28
|
+
onDayClick: (day: string) => void;
|
|
29
|
+
onDayHover: (day: string) => void;
|
|
30
|
+
onMonthNavigate: (action: (typeof NAVIGATION_ACTION)[keyof typeof NAVIGATION_ACTION]) => void;
|
|
31
|
+
};
|
|
25
32
|
today: string;
|
|
26
33
|
startDateLabel?: string;
|
|
27
34
|
endDateLabel?: string;
|
|
28
|
-
t
|
|
35
|
+
t: ((key: string, fallback: string) => string) | null | undefined;
|
|
29
36
|
locale?: string;
|
|
30
37
|
testId?: string;
|
|
31
38
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateRangeWrapper.d.ts","sourceRoot":"","sources":["../../../src/components/DateRangePicker/DateRangeWrapper.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,IAAI,EAAC,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"DateRangeWrapper.d.ts","sourceRoot":"","sources":["../../../src/components/DateRangePic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