@spaced-out/ui-design-system 0.1.99 → 0.1.101
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/.cspell/custom-words.txt +2 -0
- package/.github/workflows/publish_to_npm.yml +1 -1
- package/CHANGELOG.md +16 -0
- package/lib/components/CircularLoader/CircularLoader.js +1 -1
- package/lib/components/CircularLoader/CircularLoader.js.flow +1 -1
- package/lib/components/DateRangePicker/DateRangePicker.js +8 -6
- package/lib/components/DateRangePicker/DateRangePicker.js.flow +13 -8
- package/lib/components/DateRangePicker/DateRangeWrapper.js +11 -10
- package/lib/components/DateRangePicker/DateRangeWrapper.js.flow +26 -22
- package/lib/components/DateRangePicker/utils.js +12 -9
- package/lib/components/DateRangePicker/utils.js.flow +15 -9
- package/lib/components/Pagination/Pagination.js +10 -3
- package/lib/components/Pagination/Pagination.js.flow +11 -3
- package/package.json +1 -1
package/.cspell/custom-words.txt
CHANGED
|
@@ -22,7 +22,7 @@ jobs:
|
|
|
22
22
|
- name: Check Permissions
|
|
23
23
|
id: check-permissions
|
|
24
24
|
env:
|
|
25
|
-
ALLOWED_USERS: superrover, Anant-Raj, ashwini-sensehq, vish-sah, VishalBarnawal, sanskar-s, VivekJangid
|
|
25
|
+
ALLOWED_USERS: superrover, Anant-Raj, ashwini-sensehq, vish-sah, VishalBarnawal, sanskar-s, VivekJangid, sharad-kushwah
|
|
26
26
|
if: ${{ !contains(env.ALLOWED_USERS, github.actor) }}
|
|
27
27
|
run: |
|
|
28
28
|
echo "You don't have correct permissions to do this release"
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,22 @@
|
|
|
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.1.101](https://github.com/spaced-out/ui-design-system/compare/v0.1.100...v0.1.101) (2024-06-21)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* [GDS-413] tz offset in dateRangePicker prop ([#230](https://github.com/spaced-out/ui-design-system/issues/230)) ([e155e85](https://github.com/spaced-out/ui-design-system/commit/e155e85779589fd0a3c31dbeb5818f212415bf48))
|
|
11
|
+
* timeZone changed to timezone ([#231](https://github.com/spaced-out/ui-design-system/issues/231)) ([1a680f0](https://github.com/spaced-out/ui-design-system/commit/1a680f02d49095cc53a6c1d7a785e05cb6648f65))
|
|
12
|
+
|
|
13
|
+
### [0.1.100](https://github.com/spaced-out/ui-design-system/compare/v0.1.99...v0.1.100) (2024-06-13)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Bug Fixes
|
|
17
|
+
|
|
18
|
+
* circular loader default color ([#227](https://github.com/spaced-out/ui-design-system/issues/227)) ([fdf816b](https://github.com/spaced-out/ui-design-system/commit/fdf816b96e80f07d2b1c34f9f5ea58e137fca364))
|
|
19
|
+
* responsive secondary pagination controls ([#225](https://github.com/spaced-out/ui-design-system/issues/225)) ([43b8d4d](https://github.com/spaced-out/ui-design-system/commit/43b8d4da02793e85c9a453c25ded86aab2ebb605))
|
|
20
|
+
|
|
5
21
|
### [0.1.99](https://github.com/spaced-out/ui-design-system/compare/v0.1.98...v0.1.99) (2024-06-03)
|
|
6
22
|
|
|
7
23
|
|
|
@@ -16,7 +16,7 @@ const CircularLoader = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
16
16
|
let {
|
|
17
17
|
size = 'medium',
|
|
18
18
|
className,
|
|
19
|
-
colorToken = '
|
|
19
|
+
colorToken = 'colorTextClickable',
|
|
20
20
|
ariaLabel = 'Loading'
|
|
21
21
|
} = _ref;
|
|
22
22
|
return /*#__PURE__*/React.createElement("div", {
|
|
@@ -21,16 +21,17 @@ const DateRangePicker = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
21
21
|
onApply,
|
|
22
22
|
onCancel,
|
|
23
23
|
classNames,
|
|
24
|
-
|
|
24
|
+
selectedDateRange = {},
|
|
25
|
+
hideTimezone = false
|
|
25
26
|
} = _ref;
|
|
26
27
|
const today = (0, _utils.formatIsoDate)();
|
|
27
|
-
const currentTimezone = _momentTimezone.default.tz.guess();
|
|
28
28
|
const {
|
|
29
|
+
timezone: initialTimezone,
|
|
29
30
|
dateRange: initialRange,
|
|
30
31
|
monthRange
|
|
31
|
-
} = (0, _utils.getInitialDates)(
|
|
32
|
+
} = (0, _utils.getInitialDates)(selectedDateRange);
|
|
32
33
|
const [dateRange, setDateRange] = React.useState(initialRange);
|
|
33
|
-
const [
|
|
34
|
+
const [timezone, setTimezone] = React.useState(initialTimezone);
|
|
34
35
|
const [rangeStartMonth, setRangeStartMonth] = React.useState(monthRange.rangeStartMonth);
|
|
35
36
|
const [rangeEndMonth, setRangeEndMonth] = React.useState(monthRange.rangeEndMonth);
|
|
36
37
|
const [hoverDay, setHoverDay] = React.useState('');
|
|
@@ -92,14 +93,15 @@ const DateRangePicker = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
92
93
|
handlers: handlers,
|
|
93
94
|
hoverDay: hoverDay,
|
|
94
95
|
onCancel: onCancel,
|
|
95
|
-
|
|
96
|
+
timezone: timezone,
|
|
96
97
|
dateRange: dateRange,
|
|
97
|
-
|
|
98
|
+
setTimezone: setTimezone,
|
|
98
99
|
rangeStartMonth: rangeStartMonth,
|
|
99
100
|
rangeEndMonth: rangeEndMonth,
|
|
100
101
|
inHoverRange: inHoverRange,
|
|
101
102
|
setRangeStartMonth: setRangeStartMonthValidated,
|
|
102
103
|
setRangeEndMonth: setRangeEndMonthValidated,
|
|
104
|
+
hideTimezone: hideTimezone,
|
|
103
105
|
cardWrapperClass: (0, _classify.default)(_DateRangePickerModule.default.container, classNames?.wrapper)
|
|
104
106
|
});
|
|
105
107
|
});
|
|
@@ -25,9 +25,10 @@ type ClassNames = $ReadOnly<{wrapper?: string}>;
|
|
|
25
25
|
|
|
26
26
|
export type DateRangePickerProps = {
|
|
27
27
|
classNames?: ClassNames,
|
|
28
|
-
|
|
28
|
+
selectedDateRange?: DateRangeWithTimezone,
|
|
29
29
|
onApply: (datePickerSelectedRange: DateRangeWithTimezone) => void,
|
|
30
30
|
onCancel: () => void,
|
|
31
|
+
hideTimezone?: boolean,
|
|
31
32
|
};
|
|
32
33
|
|
|
33
34
|
export const DateRangePicker: React$AbstractComponent<
|
|
@@ -39,18 +40,21 @@ export const DateRangePicker: React$AbstractComponent<
|
|
|
39
40
|
onApply,
|
|
40
41
|
onCancel,
|
|
41
42
|
classNames,
|
|
42
|
-
|
|
43
|
+
selectedDateRange = {},
|
|
44
|
+
hideTimezone = false,
|
|
43
45
|
}: DateRangePickerProps,
|
|
44
46
|
ref,
|
|
45
47
|
): React.Node => {
|
|
46
48
|
const today = formatIsoDate();
|
|
47
|
-
const currentTimezone = moment.tz.guess();
|
|
48
49
|
|
|
49
|
-
const {
|
|
50
|
-
|
|
50
|
+
const {
|
|
51
|
+
timezone: initialTimezone,
|
|
52
|
+
dateRange: initialRange,
|
|
53
|
+
monthRange,
|
|
54
|
+
} = getInitialDates(selectedDateRange);
|
|
51
55
|
|
|
52
56
|
const [dateRange, setDateRange] = React.useState<DateRange>(initialRange);
|
|
53
|
-
const [
|
|
57
|
+
const [timezone, setTimezone] = React.useState<string>(initialTimezone);
|
|
54
58
|
const [rangeStartMonth, setRangeStartMonth] = React.useState<string>(
|
|
55
59
|
monthRange.rangeStartMonth,
|
|
56
60
|
);
|
|
@@ -156,14 +160,15 @@ export const DateRangePicker: React$AbstractComponent<
|
|
|
156
160
|
handlers={handlers}
|
|
157
161
|
hoverDay={hoverDay}
|
|
158
162
|
onCancel={onCancel}
|
|
159
|
-
|
|
163
|
+
timezone={timezone}
|
|
160
164
|
dateRange={dateRange}
|
|
161
|
-
|
|
165
|
+
setTimezone={setTimezone}
|
|
162
166
|
rangeStartMonth={rangeStartMonth}
|
|
163
167
|
rangeEndMonth={rangeEndMonth}
|
|
164
168
|
inHoverRange={inHoverRange}
|
|
165
169
|
setRangeStartMonth={setRangeStartMonthValidated}
|
|
166
170
|
setRangeEndMonth={setRangeEndMonthValidated}
|
|
171
|
+
hideTimezone={hideTimezone}
|
|
167
172
|
cardWrapperClass={classify(css.container, classNames?.wrapper)}
|
|
168
173
|
/>
|
|
169
174
|
);
|
|
@@ -81,15 +81,16 @@ const DateRangeWrapper = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
|
|
|
81
81
|
onCancel,
|
|
82
82
|
handlers,
|
|
83
83
|
hoverDay,
|
|
84
|
-
|
|
84
|
+
timezone,
|
|
85
85
|
dateRange,
|
|
86
86
|
rangeStartMonth,
|
|
87
|
-
|
|
87
|
+
setTimezone,
|
|
88
88
|
rangeEndMonth,
|
|
89
89
|
inHoverRange,
|
|
90
90
|
setRangeStartMonth,
|
|
91
91
|
setRangeEndMonth,
|
|
92
|
-
cardWrapperClass
|
|
92
|
+
cardWrapperClass,
|
|
93
|
+
hideTimezone
|
|
93
94
|
} = _ref2;
|
|
94
95
|
const canNavigateCloser = (0, _momentTimezone.default)(rangeStartMonth).year() !== (0, _momentTimezone.default)(rangeEndMonth).year() || Math.abs((0, _momentTimezone.default)(rangeStartMonth).month() - (0, _momentTimezone.default)(rangeEndMonth).month()) > 1;
|
|
95
96
|
const handleApplyClick = () => {
|
|
@@ -97,14 +98,14 @@ const DateRangeWrapper = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
|
|
|
97
98
|
startDate,
|
|
98
99
|
endDate
|
|
99
100
|
} = dateRange;
|
|
100
|
-
const startDateUTC = startDate && (0, _utils.
|
|
101
|
-
const endDateUTC = endDate && (0, _utils.
|
|
101
|
+
const startDateUTC = startDate && (0, _utils.addTimezone)(startDate, timezone);
|
|
102
|
+
const endDateUTC = endDate && (0, _utils.addTimezone)(endDate, timezone);
|
|
102
103
|
onApply({
|
|
103
104
|
startDate,
|
|
104
105
|
endDate,
|
|
105
106
|
startDateUTC,
|
|
106
107
|
endDateUTC,
|
|
107
|
-
|
|
108
|
+
timezone
|
|
108
109
|
});
|
|
109
110
|
};
|
|
110
111
|
const {
|
|
@@ -155,13 +156,13 @@ const DateRangeWrapper = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
|
|
|
155
156
|
value: rangeEndMonth
|
|
156
157
|
}, commonProps))), /*#__PURE__*/React.createElement(_Card.CardFooter, null, /*#__PURE__*/React.createElement(_Card.CardTitle, {
|
|
157
158
|
className: _DateRangeWrapperModule.default.timezoneDropdownContainer
|
|
158
|
-
}, /*#__PURE__*/React.createElement(_Dropdown.SimpleDropdown, {
|
|
159
|
-
options: (0, _utils.
|
|
159
|
+
}, !hideTimezone && /*#__PURE__*/React.createElement(_Dropdown.SimpleDropdown, {
|
|
160
|
+
options: (0, _utils.getTimezones)(),
|
|
160
161
|
classNames: {
|
|
161
162
|
box: _DateRangeWrapperModule.default.timezoneDropdown
|
|
162
163
|
},
|
|
163
|
-
selectedKeys: [
|
|
164
|
-
onChange: event =>
|
|
164
|
+
selectedKeys: [timezone],
|
|
165
|
+
onChange: event => setTimezone(event.key),
|
|
165
166
|
size: "small",
|
|
166
167
|
menuVirtualization: {
|
|
167
168
|
enable: true
|
|
@@ -21,12 +21,12 @@ import {ClickableIcon} from '../Icon';
|
|
|
21
21
|
import {Calendar} from './Calendar.js';
|
|
22
22
|
import type {DateRange, DateRangeWithTimezone} from './utils';
|
|
23
23
|
import {
|
|
24
|
-
|
|
24
|
+
addTimezone,
|
|
25
25
|
generateAvailableYears,
|
|
26
26
|
getAddedDate,
|
|
27
27
|
getAvailableMonths,
|
|
28
28
|
getMonthStartDate,
|
|
29
|
-
|
|
29
|
+
getTimezones,
|
|
30
30
|
MARKERS,
|
|
31
31
|
MONTHS,
|
|
32
32
|
NAVIGATION_ACTION,
|
|
@@ -55,11 +55,12 @@ type DateRangeWrapperProps = {
|
|
|
55
55
|
cardWrapperClass: ?string,
|
|
56
56
|
setRangeStartMonth: (string) => void,
|
|
57
57
|
setRangeEndMonth: (string) => void,
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
setTimezone: (string) => void,
|
|
59
|
+
timezone: string,
|
|
60
60
|
onApply: (datePickerSelectedRange: DateRangeWithTimezone) => void,
|
|
61
61
|
onCancel: () => void,
|
|
62
62
|
inHoverRange: (day: string) => boolean,
|
|
63
|
+
hideTimezone: boolean,
|
|
63
64
|
handlers: {
|
|
64
65
|
onDayClick: (day: string) => void,
|
|
65
66
|
onDayHover: (day: string) => void,
|
|
@@ -149,15 +150,16 @@ export const DateRangeWrapper: React$AbstractComponent<
|
|
|
149
150
|
onCancel,
|
|
150
151
|
handlers,
|
|
151
152
|
hoverDay,
|
|
152
|
-
|
|
153
|
+
timezone,
|
|
153
154
|
dateRange,
|
|
154
155
|
rangeStartMonth,
|
|
155
|
-
|
|
156
|
+
setTimezone,
|
|
156
157
|
rangeEndMonth,
|
|
157
158
|
inHoverRange,
|
|
158
159
|
setRangeStartMonth,
|
|
159
160
|
setRangeEndMonth,
|
|
160
161
|
cardWrapperClass,
|
|
162
|
+
hideTimezone,
|
|
161
163
|
}: DateRangeWrapperProps,
|
|
162
164
|
ref,
|
|
163
165
|
): React.Node => {
|
|
@@ -169,14 +171,14 @@ export const DateRangeWrapper: React$AbstractComponent<
|
|
|
169
171
|
|
|
170
172
|
const handleApplyClick = () => {
|
|
171
173
|
const {startDate, endDate} = dateRange;
|
|
172
|
-
const startDateUTC = startDate &&
|
|
173
|
-
const endDateUTC = endDate &&
|
|
174
|
+
const startDateUTC = startDate && addTimezone(startDate, timezone);
|
|
175
|
+
const endDateUTC = endDate && addTimezone(endDate, timezone);
|
|
174
176
|
onApply({
|
|
175
177
|
startDate,
|
|
176
178
|
endDate,
|
|
177
179
|
startDateUTC,
|
|
178
180
|
endDateUTC,
|
|
179
|
-
|
|
181
|
+
timezone,
|
|
180
182
|
});
|
|
181
183
|
};
|
|
182
184
|
|
|
@@ -252,19 +254,21 @@ export const DateRangeWrapper: React$AbstractComponent<
|
|
|
252
254
|
</CardContent>
|
|
253
255
|
<CardFooter>
|
|
254
256
|
<CardTitle className={css.timezoneDropdownContainer}>
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
257
|
+
{!hideTimezone && (
|
|
258
|
+
<SimpleDropdown
|
|
259
|
+
options={getTimezones()}
|
|
260
|
+
classNames={{
|
|
261
|
+
box: css.timezoneDropdown,
|
|
262
|
+
}}
|
|
263
|
+
selectedKeys={[timezone]}
|
|
264
|
+
onChange={(event) => setTimezone(event.key)}
|
|
265
|
+
size="small"
|
|
266
|
+
menuVirtualization={{
|
|
267
|
+
enable: true,
|
|
268
|
+
}}
|
|
269
|
+
allowSearch
|
|
270
|
+
/>
|
|
271
|
+
)}
|
|
268
272
|
</CardTitle>
|
|
269
273
|
<CardActions>
|
|
270
274
|
<Button type="ghost" onClick={onCancel} size="small">
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.wrangleMoment = exports.isStartOfRange = exports.isStartDateEndDateSame = exports.isEndOfRange = exports.inDateRange = exports.
|
|
6
|
+
exports.wrangleMoment = exports.isStartOfRange = exports.isStartDateEndDateSame = exports.isEndOfRange = exports.inDateRange = exports.getTimezones = exports.getSubtractedDate = exports.getMonthStartDate = exports.getInitialDates = exports.getDaysInMonth = exports.getAvailableMonths = exports.getAddedDate = exports.generateAvailableYears = exports.formatIsoDate = exports.addTimezone = exports.WEEKDAYS = exports.NAVIGATION_ACTION = exports.MONTHS = exports.MARKERS = void 0;
|
|
7
7
|
var _formatISO = _interopRequireDefault(require("date-fns/formatISO"));
|
|
8
8
|
var _parseISO = _interopRequireDefault(require("date-fns/parseISO"));
|
|
9
9
|
var _lodash = _interopRequireDefault(require("lodash"));
|
|
@@ -153,16 +153,16 @@ const getSubtractedDate = (date, subtractCount, timeUnit) => formatIsoDate((0, _
|
|
|
153
153
|
exports.getSubtractedDate = getSubtractedDate;
|
|
154
154
|
const getMonthStartDate = date => formatIsoDate((0, _momentTimezone.default)(date).startOf('M'));
|
|
155
155
|
exports.getMonthStartDate = getMonthStartDate;
|
|
156
|
-
const
|
|
157
|
-
exports.
|
|
158
|
-
const
|
|
156
|
+
const addTimezone = (date, timezone) => _momentTimezone.default.tz(date, timezone).startOf('d').utc().toISOString();
|
|
157
|
+
exports.addTimezone = addTimezone;
|
|
158
|
+
const getTimezones = () => Object.keys(_timezones.TIMEZONES).reduce((menuOptions, key) => {
|
|
159
159
|
menuOptions.push({
|
|
160
160
|
key,
|
|
161
161
|
label: _timezones.TIMEZONES[key]
|
|
162
162
|
});
|
|
163
163
|
return menuOptions;
|
|
164
164
|
}, []);
|
|
165
|
-
exports.
|
|
165
|
+
exports.getTimezones = getTimezones;
|
|
166
166
|
const generateAvailableYears = (count, firstCalendarDate, secondCalendarDate, marker) => {
|
|
167
167
|
const startYear = (0, _momentTimezone.default)().year() - count + 1;
|
|
168
168
|
const firstCalendarYear = (0, _momentTimezone.default)(firstCalendarDate).add(1, 'M').year();
|
|
@@ -201,12 +201,14 @@ const getAvailableMonths = (Months, first, second, marker) => {
|
|
|
201
201
|
});
|
|
202
202
|
};
|
|
203
203
|
exports.getAvailableMonths = getAvailableMonths;
|
|
204
|
-
const getInitialDates =
|
|
204
|
+
const getInitialDates = selectedDateRange => {
|
|
205
205
|
const today = formatIsoDate();
|
|
206
|
+
const currentTimezone = _momentTimezone.default.tz.guess();
|
|
206
207
|
const {
|
|
207
208
|
startDate,
|
|
208
|
-
endDate
|
|
209
|
-
|
|
209
|
+
endDate,
|
|
210
|
+
timezone
|
|
211
|
+
} = selectedDateRange;
|
|
210
212
|
const isStartDateValid = (0, _momentTimezone.default)(startDate).isSameOrBefore(today);
|
|
211
213
|
const isEndDateValid = (0, _momentTimezone.default)(endDate).isSameOrBefore(today);
|
|
212
214
|
const dateRange = startDate && endDate && isStartDateValid && isEndDateValid && (0, _momentTimezone.default)(endDate).isSameOrAfter(startDate) ? {
|
|
@@ -227,7 +229,8 @@ const getInitialDates = initialDateRange => {
|
|
|
227
229
|
};
|
|
228
230
|
return {
|
|
229
231
|
dateRange,
|
|
230
|
-
monthRange
|
|
232
|
+
monthRange,
|
|
233
|
+
timezone: timezone ?? currentTimezone
|
|
231
234
|
};
|
|
232
235
|
};
|
|
233
236
|
exports.getInitialDates = getInitialDates;
|
|
@@ -19,13 +19,14 @@ export type DateRangeWithTimezone = {|
|
|
|
19
19
|
...DateRange,
|
|
20
20
|
startDateUTC?: string,
|
|
21
21
|
endDateUTC?: string,
|
|
22
|
-
|
|
22
|
+
timezone?: string,
|
|
23
23
|
|};
|
|
24
24
|
|
|
25
25
|
type MonthRange = {rangeStartMonth: string, rangeEndMonth: string};
|
|
26
|
-
type
|
|
26
|
+
type SelectedDateRangeTimezone = {
|
|
27
27
|
dateRange: DateRange,
|
|
28
28
|
monthRange: MonthRange,
|
|
29
|
+
timezone: string,
|
|
29
30
|
};
|
|
30
31
|
|
|
31
32
|
export const NAVIGATION_ACTION = Object.freeze({
|
|
@@ -141,10 +142,10 @@ export const getSubtractedDate = (
|
|
|
141
142
|
export const getMonthStartDate = (date: string): string =>
|
|
142
143
|
formatIsoDate(moment(date).startOf('M'));
|
|
143
144
|
|
|
144
|
-
export const
|
|
145
|
-
moment.tz(date,
|
|
145
|
+
export const addTimezone = (date: string, timezone: string): string =>
|
|
146
|
+
moment.tz(date, timezone).startOf('d').utc().toISOString();
|
|
146
147
|
|
|
147
|
-
export const
|
|
148
|
+
export const getTimezones = (): Array<MenuOption> =>
|
|
148
149
|
Object.keys(TIMEZONES).reduce((menuOptions, key) => {
|
|
149
150
|
menuOptions.push({
|
|
150
151
|
key,
|
|
@@ -206,10 +207,11 @@ export const getAvailableMonths = (
|
|
|
206
207
|
};
|
|
207
208
|
|
|
208
209
|
export const getInitialDates = (
|
|
209
|
-
|
|
210
|
-
):
|
|
210
|
+
selectedDateRange: DateRangeWithTimezone,
|
|
211
|
+
): SelectedDateRangeTimezone => {
|
|
211
212
|
const today = formatIsoDate();
|
|
212
|
-
const
|
|
213
|
+
const currentTimezone = moment.tz.guess();
|
|
214
|
+
const {startDate, endDate, timezone} = selectedDateRange;
|
|
213
215
|
|
|
214
216
|
const isStartDateValid = moment(startDate).isSameOrBefore(today);
|
|
215
217
|
const isEndDateValid = moment(endDate).isSameOrBefore(today);
|
|
@@ -235,5 +237,9 @@ export const getInitialDates = (
|
|
|
235
237
|
}
|
|
236
238
|
|
|
237
239
|
const monthRange = {rangeStartMonth: startMonth, rangeEndMonth: endMonth};
|
|
238
|
-
return {
|
|
240
|
+
return {
|
|
241
|
+
dateRange,
|
|
242
|
+
monthRange,
|
|
243
|
+
timezone: timezone ?? currentTimezone,
|
|
244
|
+
};
|
|
239
245
|
};
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.Pagination = void 0;
|
|
7
7
|
var React = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _usePagination = require("../../hooks/usePagination");
|
|
9
|
+
var _useWindowSize = require("../../hooks/useWindowSize");
|
|
9
10
|
var _classify = _interopRequireDefault(require("../../utils/classify"));
|
|
10
11
|
var _helpers = require("../../utils/helpers");
|
|
11
12
|
var _Dropdown = require("../Dropdown");
|
|
@@ -17,7 +18,12 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
17
18
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
18
19
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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); }
|
|
19
20
|
const LARGE_LIST_DROPDOWN_OPTIONS = 50;
|
|
21
|
+
const TABLET_SCREEN_SIZE = 640;
|
|
20
22
|
const Pagination = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
23
|
+
const {
|
|
24
|
+
width
|
|
25
|
+
} = (0, _useWindowSize.useWindowSize)();
|
|
26
|
+
const showExtraSecPaginationButtons = width > TABLET_SCREEN_SIZE;
|
|
21
27
|
const {
|
|
22
28
|
classNames,
|
|
23
29
|
style = 'primary',
|
|
@@ -25,10 +31,11 @@ const Pagination = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
25
31
|
currentPage = 1,
|
|
26
32
|
totalPages = 1,
|
|
27
33
|
onChange,
|
|
28
|
-
showFirstButton = style !== 'primary',
|
|
29
|
-
showLastButton = style !== 'primary',
|
|
34
|
+
showFirstButton = style !== 'primary' && showExtraSecPaginationButtons,
|
|
35
|
+
showLastButton = style !== 'primary' && showExtraSecPaginationButtons,
|
|
30
36
|
...restPaginationProps
|
|
31
37
|
} = props;
|
|
38
|
+
const showPageSelectionDropDown = style !== 'primary' && showExtraSecPaginationButtons;
|
|
32
39
|
const {
|
|
33
40
|
items
|
|
34
41
|
} = (0, _usePagination.usePagination)({
|
|
@@ -56,7 +63,7 @@ const Pagination = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
56
63
|
className: (0, _classify.default)(_PaginationModule.default.childrenSlot, classNames?.children)
|
|
57
64
|
}, children), /*#__PURE__*/React.createElement("div", {
|
|
58
65
|
className: _PaginationModule.default.paginatorSlots
|
|
59
|
-
}, style === 'secondary' && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_Dropdown.Dropdown, {
|
|
66
|
+
}, style === 'secondary' && showPageSelectionDropDown && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_Dropdown.Dropdown, {
|
|
60
67
|
size: "small",
|
|
61
68
|
classNames: {
|
|
62
69
|
wrapper: _PaginationModule.default.dropdownWrapper
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
|
|
5
5
|
import {usePagination} from '../../hooks/usePagination';
|
|
6
|
+
import {useWindowSize} from '../../hooks/useWindowSize';
|
|
6
7
|
import classify from '../../utils/classify';
|
|
7
8
|
import {range} from '../../utils/helpers';
|
|
8
9
|
import {Dropdown} from '../Dropdown';
|
|
@@ -59,11 +60,15 @@ export type PaginationItemProps = {
|
|
|
59
60
|
|
|
60
61
|
const LARGE_LIST_DROPDOWN_OPTIONS = 50;
|
|
61
62
|
|
|
63
|
+
const TABLET_SCREEN_SIZE = 640;
|
|
64
|
+
|
|
62
65
|
export const Pagination: React$AbstractComponent<
|
|
63
66
|
PaginationProps,
|
|
64
67
|
HTMLDivElement,
|
|
65
68
|
> = React.forwardRef<PaginationProps, HTMLDivElement>(
|
|
66
69
|
(props: PaginationProps, ref) => {
|
|
70
|
+
const {width} = useWindowSize();
|
|
71
|
+
const showExtraSecPaginationButtons = width > TABLET_SCREEN_SIZE;
|
|
67
72
|
const {
|
|
68
73
|
classNames,
|
|
69
74
|
style = 'primary',
|
|
@@ -71,10 +76,13 @@ export const Pagination: React$AbstractComponent<
|
|
|
71
76
|
currentPage = 1,
|
|
72
77
|
totalPages = 1,
|
|
73
78
|
onChange,
|
|
74
|
-
showFirstButton = style !== 'primary',
|
|
75
|
-
showLastButton = style !== 'primary',
|
|
79
|
+
showFirstButton = style !== 'primary' && showExtraSecPaginationButtons,
|
|
80
|
+
showLastButton = style !== 'primary' && showExtraSecPaginationButtons,
|
|
76
81
|
...restPaginationProps
|
|
77
82
|
} = props;
|
|
83
|
+
const showPageSelectionDropDown =
|
|
84
|
+
style !== 'primary' && showExtraSecPaginationButtons;
|
|
85
|
+
|
|
78
86
|
const {items} = usePagination({
|
|
79
87
|
style,
|
|
80
88
|
showFirstButton,
|
|
@@ -108,7 +116,7 @@ export const Pagination: React$AbstractComponent<
|
|
|
108
116
|
{children}
|
|
109
117
|
</div>
|
|
110
118
|
<div className={css.paginatorSlots}>
|
|
111
|
-
{style === 'secondary' && (
|
|
119
|
+
{style === 'secondary' && showPageSelectionDropDown && (
|
|
112
120
|
<>
|
|
113
121
|
<Dropdown
|
|
114
122
|
size="small"
|