@skyscanner/backpack-web 23.2.2 → 23.3.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/bpk-component-aria-live/src/BpkAriaLive.js +0 -1
- package/bpk-component-badge/src/BpkBadge.js +0 -1
- package/{bpk-scrim-utils/src/customPropTypes.js → bpk-component-banner-alert/index.d.ts} +16 -14
- package/bpk-component-banner-alert/src/AnimateAndFade.d.ts +61 -0
- package/bpk-component-banner-alert/src/AnimateAndFade.js +3 -9
- package/bpk-component-banner-alert/src/BpkBannerAlert.d.ts +29 -0
- package/bpk-component-banner-alert/src/BpkBannerAlert.js +42 -21
- package/bpk-component-banner-alert/src/BpkBannerAlertDismissable.d.ts +30 -0
- package/bpk-component-banner-alert/src/BpkBannerAlertDismissable.js +31 -33
- package/bpk-component-banner-alert/src/BpkBannerAlertExpandable.d.ts +35 -0
- package/bpk-component-banner-alert/src/BpkBannerAlertExpandable.js +15 -28
- package/bpk-component-banner-alert/src/BpkBannerAlertInner.d.ts +58 -0
- package/bpk-component-banner-alert/src/BpkBannerAlertInner.js +65 -87
- package/bpk-component-banner-alert/src/common-types.d.ts +44 -0
- package/bpk-component-banner-alert/src/common-types.js +5 -23
- package/bpk-component-banner-alert/src/themeAttributes.d.ts +20 -0
- package/bpk-component-banner-alert/src/withBannerAlertState.d.ts +169 -0
- package/bpk-component-banner-alert/src/withBannerAlertState.js +10 -29
- package/bpk-component-boilerplate/src/BpkBoilerplate.js +0 -1
- package/bpk-component-button/src/BpkButtonV2/BpkButton.js +0 -1
- package/bpk-component-calendar/index.d.ts +30 -0
- package/bpk-component-calendar/index.js +5 -4
- package/bpk-component-calendar/src/BpkCalendarContainer.d.ts +429 -0
- package/bpk-component-calendar/src/BpkCalendarContainer.js +19 -29
- package/bpk-component-calendar/src/BpkCalendarDate.d.ts +62 -0
- package/bpk-component-calendar/src/BpkCalendarDate.js +15 -39
- package/bpk-component-calendar/src/BpkCalendarGrid.d.ts +68 -0
- package/bpk-component-calendar/src/BpkCalendarGrid.js +9 -40
- package/bpk-component-calendar/src/BpkCalendarGridHeader.d.ts +36 -0
- package/bpk-component-calendar/src/BpkCalendarGridHeader.js +33 -52
- package/bpk-component-calendar/src/BpkCalendarGridTransition.d.ts +56 -0
- package/bpk-component-calendar/src/BpkCalendarGridTransition.js +43 -42
- package/bpk-component-calendar/src/BpkCalendarNav.d.ts +37 -0
- package/bpk-component-calendar/src/BpkCalendarNav.js +18 -32
- package/bpk-component-calendar/src/Week.d.ts +51 -0
- package/bpk-component-calendar/src/Week.js +48 -70
- package/bpk-component-calendar/src/composeCalendar.d.ts +52 -0
- package/bpk-component-calendar/src/composeCalendar.js +34 -95
- package/bpk-component-calendar/src/custom-proptypes-legacy.js +140 -0
- package/bpk-component-calendar/src/custom-proptypes.d.ts +46 -0
- package/bpk-component-calendar/src/custom-proptypes.js +2 -61
- package/bpk-component-calendar/src/date-utils.d.ts +54 -0
- package/bpk-component-calendar/src/utils.d.ts +26 -0
- package/bpk-component-calendar/src/utils.js +1 -0
- package/bpk-component-calendar/test-utils.d.ts +56 -0
- package/bpk-component-calendar/test-utils.js +2 -2
- package/bpk-component-card/index.d.ts +24 -0
- package/bpk-component-card/src/BpkCard.d.ts +39 -0
- package/bpk-component-card/src/BpkCard.js +9 -25
- package/bpk-component-card/src/BpkCardWrapper.d.ts +33 -0
- package/bpk-component-card/src/BpkCardWrapper.js +10 -18
- package/bpk-component-card/src/BpkDividedCard.d.ts +43 -0
- package/bpk-component-card/src/BpkDividedCard.js +9 -24
- package/bpk-component-chip/index.d.ts +32 -0
- package/bpk-component-chip/src/BpkDismissibleChip.d.ts +28 -0
- package/bpk-component-chip/src/BpkDismissibleChip.js +9 -8
- package/bpk-component-chip/src/BpkDropdownChip.d.ts +29 -0
- package/bpk-component-chip/src/BpkDropdownChip.js +39 -25
- package/bpk-component-chip/src/BpkSelectableChip.d.ts +39 -0
- package/bpk-component-chip/src/BpkSelectableChip.js +34 -48
- package/bpk-component-chip/src/commonTypes.d.ts +56 -0
- package/bpk-component-chip/src/commonTypes.js +8 -2
- package/bpk-component-dialog/src/BpkDialog.js +0 -1
- package/bpk-component-dialog/src/BpkDialogInner.js +0 -2
- package/bpk-component-graphic-promotion/src/BpkGraphicPromo.js +0 -2
- package/bpk-component-icon/src/classNameModifierHOCFactory.js +0 -1
- package/bpk-component-icon/src/withAlignment.js +1 -1
- package/bpk-component-icon/src/withDescription.js +1 -1
- package/bpk-component-icon/src/withRtlSupport.js +0 -2
- package/bpk-component-input/index.d.ts +39 -0
- package/bpk-component-input/src/BpkClearButton.d.ts +28 -0
- package/bpk-component-input/src/BpkClearButton.js +6 -14
- package/bpk-component-input/src/BpkInput.d.ts +46 -0
- package/bpk-component-input/src/BpkInput.js +7 -3
- package/bpk-component-input/src/common-types.d.ts +91 -0
- package/bpk-component-input/src/common-types.js +4 -1
- package/bpk-component-input/src/withOpenEvents.d.ts +121 -0
- package/bpk-component-input/src/withOpenEvents.js +14 -25
- package/bpk-component-modal/index.js +11 -4
- package/bpk-component-modal/src/BpkModalV2/BpKModal.module.css +18 -0
- package/bpk-component-modal/src/BpkModalV2/BpkModal.d.ts +35 -0
- package/bpk-component-modal/src/BpkModalV2/BpkModal.js +133 -0
- package/bpk-component-rtl-toggle/index.d.ts +23 -0
- package/bpk-component-rtl-toggle/src/BpkRtlToggle.d.ts +41 -0
- package/bpk-component-rtl-toggle/src/BpkRtlToggle.js +9 -12
- package/bpk-component-rtl-toggle/src/updateOnDirectionChange.d.ts +151 -0
- package/bpk-component-rtl-toggle/src/updateOnDirectionChange.js +9 -2
- package/bpk-component-rtl-toggle/src/utils.d.ts +25 -0
- package/bpk-react-utils/index.d.ts +58 -0
- package/bpk-react-utils/index.js +1 -0
- package/bpk-react-utils/src/Portal.d.ts +76 -0
- package/bpk-react-utils/src/Portal.js +33 -43
- package/bpk-react-utils/src/TransitionInitialMount.d.ts +27 -0
- package/bpk-react-utils/src/TransitionInitialMount.js +7 -8
- package/bpk-react-utils/src/cssModules.d.ts +22 -0
- package/bpk-react-utils/src/deprecated.js +2 -1
- package/bpk-react-utils/src/deviceDetection.d.ts +22 -0
- package/bpk-react-utils/src/deviceDetection.js +3 -1
- package/bpk-react-utils/src/isRTL.d.ts +20 -0
- package/bpk-react-utils/src/isRTL.js +3 -1
- package/bpk-react-utils/src/withDefaultProps.d.ts +33 -0
- package/bpk-react-utils/src/withDefaultProps.js +11 -24
- package/bpk-react-utils/src/wrapDisplayName.d.ts +21 -0
- package/bpk-scrim-utils/src/BpkScrim.d.ts +24 -0
- package/bpk-scrim-utils/src/BpkScrim.js +5 -10
- package/bpk-scrim-utils/src/scroll-utils.d.ts +24 -0
- package/bpk-scrim-utils/src/scroll-utils.js +1 -1
- package/bpk-scrim-utils/src/withScrim.d.ts +95 -0
- package/bpk-scrim-utils/src/withScrim.js +5 -12
- package/package.json +1 -1
|
@@ -4,13 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
8
7
|
var _bpkReactUtils = require("../../bpk-react-utils");
|
|
9
|
-
var _customProptypes =
|
|
8
|
+
var _customProptypes = require("./custom-proptypes");
|
|
10
9
|
var _BpkCalendarModule = _interopRequireDefault(require("./BpkCalendar.module.css"));
|
|
11
10
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
13
|
-
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; }
|
|
14
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
12
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
16
13
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
@@ -35,38 +32,40 @@ function _toPrimitive(input, hint) { if (typeof input !== "object" || input ===
|
|
|
35
32
|
*/
|
|
36
33
|
const getClassName = (0, _bpkReactUtils.cssModules)(_BpkCalendarModule.default);
|
|
37
34
|
const composeCalendar = (Nav, GridHeader, Grid, CalendarDate) => {
|
|
38
|
-
const BpkCalendar =
|
|
35
|
+
const BpkCalendar = ({
|
|
36
|
+
changeMonthLabel = null,
|
|
37
|
+
className = null,
|
|
38
|
+
dateModifiers = {},
|
|
39
|
+
dateProps = {},
|
|
40
|
+
daysOfWeek,
|
|
41
|
+
fixedWidth = true,
|
|
42
|
+
focusedDate = null,
|
|
43
|
+
formatDateFull,
|
|
44
|
+
formatMonth,
|
|
45
|
+
gridClassName = null,
|
|
46
|
+
gridProps = {},
|
|
47
|
+
headerProps = {},
|
|
48
|
+
id,
|
|
49
|
+
markOutsideDays = true,
|
|
50
|
+
markToday = true,
|
|
51
|
+
maxDate,
|
|
52
|
+
minDate,
|
|
53
|
+
month,
|
|
54
|
+
navProps = {},
|
|
55
|
+
nextMonthLabel = null,
|
|
56
|
+
onDateClick = () => {},
|
|
57
|
+
onDateKeyDown = () => {},
|
|
58
|
+
onMonthChange = () => {},
|
|
59
|
+
preventKeyboardFocus = false,
|
|
60
|
+
previousMonthLabel = null,
|
|
61
|
+
selectionConfiguration = {
|
|
62
|
+
type: _customProptypes.CALENDAR_SELECTION_TYPE.single,
|
|
63
|
+
date: null
|
|
64
|
+
},
|
|
65
|
+
weekDayKey = 'nameAbbr',
|
|
66
|
+
weekStartsOn
|
|
67
|
+
}) => {
|
|
39
68
|
const classNames = [getClassName('bpk-calendar')];
|
|
40
|
-
const {
|
|
41
|
-
changeMonthLabel,
|
|
42
|
-
className,
|
|
43
|
-
dateModifiers,
|
|
44
|
-
dateProps,
|
|
45
|
-
daysOfWeek,
|
|
46
|
-
fixedWidth,
|
|
47
|
-
focusedDate,
|
|
48
|
-
formatDateFull,
|
|
49
|
-
formatMonth,
|
|
50
|
-
gridClassName,
|
|
51
|
-
gridProps,
|
|
52
|
-
headerProps,
|
|
53
|
-
id,
|
|
54
|
-
markOutsideDays,
|
|
55
|
-
markToday,
|
|
56
|
-
maxDate,
|
|
57
|
-
minDate,
|
|
58
|
-
month,
|
|
59
|
-
navProps,
|
|
60
|
-
nextMonthLabel,
|
|
61
|
-
onDateClick,
|
|
62
|
-
onDateKeyDown,
|
|
63
|
-
onMonthChange,
|
|
64
|
-
preventKeyboardFocus,
|
|
65
|
-
previousMonthLabel,
|
|
66
|
-
selectionConfiguration,
|
|
67
|
-
weekDayKey,
|
|
68
|
-
weekStartsOn
|
|
69
|
-
} = props;
|
|
70
69
|
if (className) {
|
|
71
70
|
classNames.push(className);
|
|
72
71
|
}
|
|
@@ -127,66 +126,6 @@ const composeCalendar = (Nav, GridHeader, Grid, CalendarDate) => {
|
|
|
127
126
|
}, gridProps))]
|
|
128
127
|
});
|
|
129
128
|
};
|
|
130
|
-
BpkCalendar.propTypes = {
|
|
131
|
-
// Required
|
|
132
|
-
changeMonthLabel: Nav ? _propTypes.default.string.isRequired : _propTypes.default.string,
|
|
133
|
-
daysOfWeek: _customProptypes.default.DaysOfWeek.isRequired,
|
|
134
|
-
formatDateFull: _propTypes.default.func.isRequired,
|
|
135
|
-
formatMonth: _propTypes.default.func.isRequired,
|
|
136
|
-
id: _propTypes.default.string.isRequired,
|
|
137
|
-
maxDate: _propTypes.default.instanceOf(Date).isRequired,
|
|
138
|
-
minDate: _propTypes.default.instanceOf(Date).isRequired,
|
|
139
|
-
month: _propTypes.default.instanceOf(Date).isRequired,
|
|
140
|
-
nextMonthLabel: Nav ? _propTypes.default.string.isRequired : _propTypes.default.string,
|
|
141
|
-
previousMonthLabel: Nav ? _propTypes.default.string.isRequired : _propTypes.default.string,
|
|
142
|
-
weekStartsOn: _propTypes.default.number.isRequired,
|
|
143
|
-
// Optional
|
|
144
|
-
className: _propTypes.default.string,
|
|
145
|
-
dateModifiers: _customProptypes.default.DateModifiers,
|
|
146
|
-
fixedWidth: _propTypes.default.bool,
|
|
147
|
-
focusedDate: _propTypes.default.instanceOf(Date),
|
|
148
|
-
markOutsideDays: _propTypes.default.bool,
|
|
149
|
-
markToday: _propTypes.default.bool,
|
|
150
|
-
onMonthChange: _propTypes.default.func,
|
|
151
|
-
onDateClick: _propTypes.default.func,
|
|
152
|
-
onDateKeyDown: _propTypes.default.func,
|
|
153
|
-
preventKeyboardFocus: _propTypes.default.bool,
|
|
154
|
-
selectionConfiguration: _customProptypes.default.SelectionConfiguration,
|
|
155
|
-
gridClassName: _propTypes.default.string,
|
|
156
|
-
weekDayKey: _propTypes.default.string,
|
|
157
|
-
/* eslint-disable react/forbid-prop-types */
|
|
158
|
-
navProps: _propTypes.default.object,
|
|
159
|
-
headerProps: _propTypes.default.object,
|
|
160
|
-
gridProps: _propTypes.default.object,
|
|
161
|
-
dateProps: _propTypes.default.object
|
|
162
|
-
/* eslint-enable */
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
BpkCalendar.defaultProps = {
|
|
166
|
-
changeMonthLabel: null,
|
|
167
|
-
className: null,
|
|
168
|
-
dateModifiers: {},
|
|
169
|
-
fixedWidth: true,
|
|
170
|
-
focusedDate: null,
|
|
171
|
-
markOutsideDays: true,
|
|
172
|
-
markToday: true,
|
|
173
|
-
nextMonthLabel: null,
|
|
174
|
-
onMonthChange: () => null,
|
|
175
|
-
onDateClick: () => null,
|
|
176
|
-
onDateKeyDown: () => null,
|
|
177
|
-
preventKeyboardFocus: false,
|
|
178
|
-
previousMonthLabel: null,
|
|
179
|
-
selectionConfiguration: {
|
|
180
|
-
type: _customProptypes.CALENDAR_SELECTION_TYPE.single,
|
|
181
|
-
date: null
|
|
182
|
-
},
|
|
183
|
-
gridClassName: null,
|
|
184
|
-
weekDayKey: 'nameAbbr',
|
|
185
|
-
navProps: null,
|
|
186
|
-
headerProps: null,
|
|
187
|
-
gridProps: null,
|
|
188
|
-
dateProps: null
|
|
189
|
-
};
|
|
190
129
|
return BpkCalendar;
|
|
191
130
|
};
|
|
192
131
|
var _default = composeCalendar;
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.SELECTION_TYPES = exports.CALENDAR_SELECTION_TYPE = exports.BpkCalendarGridPropTypes = exports.BpkCalendarDatePropTypes = void 0;
|
|
7
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
8
|
+
var _dateUtils = require("./date-utils");
|
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
+
/*
|
|
11
|
+
* Backpack - Skyscanner's Design System
|
|
12
|
+
*
|
|
13
|
+
* Copyright 2016 Skyscanner Ltd
|
|
14
|
+
*
|
|
15
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
16
|
+
* you may not use this file except in compliance with the License.
|
|
17
|
+
* You may obtain a copy of the License at
|
|
18
|
+
*
|
|
19
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
20
|
+
*
|
|
21
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
22
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
23
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
24
|
+
* See the License for the specific language governing permissions and
|
|
25
|
+
* limitations under the License.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
const DateType = () => props => {
|
|
29
|
+
const {
|
|
30
|
+
endDate,
|
|
31
|
+
startDate
|
|
32
|
+
} = props;
|
|
33
|
+
|
|
34
|
+
// No range selected
|
|
35
|
+
if (!startDate && !endDate) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// End date without a start date is not allowed
|
|
40
|
+
if (!startDate && endDate) {
|
|
41
|
+
return new Error(`Cannot specify \`endDate\` without \`startDate\`.`);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Start date without an end date is always valid
|
|
45
|
+
if (startDate && !endDate) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Start date cannot be after end date
|
|
50
|
+
if ((0, _dateUtils.isBefore)(endDate, startDate) && !(0, _dateUtils.isSameDay)(endDate, startDate)) {
|
|
51
|
+
return new Error(`Start date \`${startDate}\` cannot be after end date \`${endDate}\`.`);
|
|
52
|
+
}
|
|
53
|
+
return null;
|
|
54
|
+
};
|
|
55
|
+
const CALENDAR_SELECTION_TYPE = {
|
|
56
|
+
single: 'single',
|
|
57
|
+
range: 'range'
|
|
58
|
+
};
|
|
59
|
+
exports.CALENDAR_SELECTION_TYPE = CALENDAR_SELECTION_TYPE;
|
|
60
|
+
const SELECTION_TYPES = {
|
|
61
|
+
none: 'none',
|
|
62
|
+
single: 'single',
|
|
63
|
+
start: 'start',
|
|
64
|
+
middle: 'middle',
|
|
65
|
+
end: 'end',
|
|
66
|
+
sameDay: 'sameDay'
|
|
67
|
+
};
|
|
68
|
+
exports.SELECTION_TYPES = SELECTION_TYPES;
|
|
69
|
+
const SelectionConfigurationSingle = _propTypes.default.shape({
|
|
70
|
+
type: _propTypes.default.oneOf([CALENDAR_SELECTION_TYPE.single]),
|
|
71
|
+
date: _propTypes.default.instanceOf(Date)
|
|
72
|
+
});
|
|
73
|
+
const SelectionConfigurationRange = _propTypes.default.shape({
|
|
74
|
+
type: _propTypes.default.oneOf([CALENDAR_SELECTION_TYPE.range]),
|
|
75
|
+
startDate: DateType(),
|
|
76
|
+
endDate: DateType()
|
|
77
|
+
});
|
|
78
|
+
const SelectionConfiguration = _propTypes.default.oneOfType([SelectionConfigurationSingle, SelectionConfigurationRange]);
|
|
79
|
+
const WeekDay = _propTypes.default.shape({
|
|
80
|
+
name: _propTypes.default.string,
|
|
81
|
+
nameAbbr: _propTypes.default.string,
|
|
82
|
+
index: _propTypes.default.number,
|
|
83
|
+
isWeekend: _propTypes.default.bool
|
|
84
|
+
});
|
|
85
|
+
const WeekDayKey = _propTypes.default.string;
|
|
86
|
+
const DaysOfWeek = _propTypes.default.arrayOf(WeekDay);
|
|
87
|
+
const DateModifiers = _propTypes.default.objectOf(_propTypes.default.func);
|
|
88
|
+
const ReactComponent = _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.func]);
|
|
89
|
+
const BpkCalendarGridPropTypes = {
|
|
90
|
+
// Required
|
|
91
|
+
DateComponent: _propTypes.default.elementType.isRequired,
|
|
92
|
+
formatDateFull: _propTypes.default.func.isRequired,
|
|
93
|
+
month: _propTypes.default.instanceOf(Date).isRequired,
|
|
94
|
+
weekStartsOn: _propTypes.default.number.isRequired,
|
|
95
|
+
// Optional
|
|
96
|
+
className: _propTypes.default.string,
|
|
97
|
+
cellClassName: _propTypes.default.string,
|
|
98
|
+
dateModifiers: DateModifiers,
|
|
99
|
+
focusedDate: _propTypes.default.instanceOf(Date),
|
|
100
|
+
isKeyboardFocusable: _propTypes.default.bool,
|
|
101
|
+
markOutsideDays: _propTypes.default.bool,
|
|
102
|
+
markToday: _propTypes.default.bool,
|
|
103
|
+
maxDate: _propTypes.default.instanceOf(Date),
|
|
104
|
+
minDate: _propTypes.default.instanceOf(Date),
|
|
105
|
+
onDateClick: _propTypes.default.func,
|
|
106
|
+
onDateKeyDown: _propTypes.default.func,
|
|
107
|
+
preventKeyboardFocus: _propTypes.default.bool,
|
|
108
|
+
selectionConfiguration: SelectionConfiguration,
|
|
109
|
+
ignoreOutsideDate: _propTypes.default.bool,
|
|
110
|
+
dateProps: _propTypes.default.object
|
|
111
|
+
};
|
|
112
|
+
exports.BpkCalendarGridPropTypes = BpkCalendarGridPropTypes;
|
|
113
|
+
const BpkCalendarDatePropTypes = {
|
|
114
|
+
// Required
|
|
115
|
+
date: _propTypes.default.instanceOf(Date).isRequired,
|
|
116
|
+
// Optional
|
|
117
|
+
className: _propTypes.default.string,
|
|
118
|
+
isBlocked: _propTypes.default.bool,
|
|
119
|
+
isFocused: _propTypes.default.bool,
|
|
120
|
+
isKeyboardFocusable: _propTypes.default.bool,
|
|
121
|
+
isOutside: _propTypes.default.bool,
|
|
122
|
+
isSelected: _propTypes.default.bool,
|
|
123
|
+
isToday: _propTypes.default.bool,
|
|
124
|
+
modifiers: DateModifiers,
|
|
125
|
+
onClick: _propTypes.default.func,
|
|
126
|
+
onDateKeyDown: _propTypes.default.func,
|
|
127
|
+
preventKeyboardFocus: _propTypes.default.bool,
|
|
128
|
+
selectionType: _propTypes.default.oneOf(Object.keys(SELECTION_TYPES)),
|
|
129
|
+
style: _propTypes.default.object
|
|
130
|
+
};
|
|
131
|
+
exports.BpkCalendarDatePropTypes = BpkCalendarDatePropTypes;
|
|
132
|
+
var _default = {
|
|
133
|
+
SelectionConfiguration,
|
|
134
|
+
DateModifiers,
|
|
135
|
+
DaysOfWeek,
|
|
136
|
+
ReactComponent,
|
|
137
|
+
WeekDay,
|
|
138
|
+
WeekDayKey
|
|
139
|
+
};
|
|
140
|
+
exports.default = _default;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Backpack - Skyscanner's Design System
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2016 Skyscanner Ltd
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import type { ReactElement } from 'react';
|
|
20
|
+
export declare const CALENDAR_SELECTION_TYPE: {
|
|
21
|
+
readonly single: "single";
|
|
22
|
+
readonly range: "range";
|
|
23
|
+
};
|
|
24
|
+
export type SelectionConfigurationSingle = {
|
|
25
|
+
type: typeof CALENDAR_SELECTION_TYPE.single;
|
|
26
|
+
date: Date | null;
|
|
27
|
+
};
|
|
28
|
+
export type SelectionConfigurationRange = {
|
|
29
|
+
type: typeof CALENDAR_SELECTION_TYPE.range;
|
|
30
|
+
startDate: Date | null;
|
|
31
|
+
endDate: Date | null;
|
|
32
|
+
};
|
|
33
|
+
export type SelectionConfiguration = SelectionConfigurationSingle | SelectionConfigurationRange;
|
|
34
|
+
export type WeekDay = {
|
|
35
|
+
name: string;
|
|
36
|
+
nameAbbr: string;
|
|
37
|
+
index: number;
|
|
38
|
+
isWeekend: boolean;
|
|
39
|
+
[key: string]: any;
|
|
40
|
+
};
|
|
41
|
+
export type WeekDayKey = string;
|
|
42
|
+
export type DaysOfWeek = WeekDay[];
|
|
43
|
+
export type DateModifiers = {
|
|
44
|
+
[key: string]: Function;
|
|
45
|
+
};
|
|
46
|
+
export type ReactComponent = string | ((props: any) => ReactElement);
|
|
@@ -3,10 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
8
|
-
var _dateUtils = require("./date-utils");
|
|
9
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
6
|
+
exports.CALENDAR_SELECTION_TYPE = void 0;
|
|
10
7
|
/*
|
|
11
8
|
* Backpack - Skyscanner's Design System
|
|
12
9
|
*
|
|
@@ -25,64 +22,8 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
25
22
|
* limitations under the License.
|
|
26
23
|
*/
|
|
27
24
|
|
|
28
|
-
const DateType = () => props => {
|
|
29
|
-
const {
|
|
30
|
-
endDate,
|
|
31
|
-
startDate
|
|
32
|
-
} = props;
|
|
33
|
-
|
|
34
|
-
// No range selected
|
|
35
|
-
if (!startDate && !endDate) {
|
|
36
|
-
return null;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// End date without a start date is not allowed
|
|
40
|
-
if (!startDate && endDate) {
|
|
41
|
-
return new Error(`Cannot specify \`endDate\` without \`startDate\`.`);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// Start date without an end date is always valid
|
|
45
|
-
if (startDate && !endDate) {
|
|
46
|
-
return null;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// Start date cannot be after end date
|
|
50
|
-
if ((0, _dateUtils.isBefore)(endDate, startDate) && !(0, _dateUtils.isSameDay)(endDate, startDate)) {
|
|
51
|
-
return new Error(`Start date \`${startDate}\` cannot be after end date \`${endDate}\`.`);
|
|
52
|
-
}
|
|
53
|
-
return null;
|
|
54
|
-
};
|
|
55
25
|
const CALENDAR_SELECTION_TYPE = {
|
|
56
26
|
single: 'single',
|
|
57
27
|
range: 'range'
|
|
58
28
|
};
|
|
59
|
-
exports.CALENDAR_SELECTION_TYPE = CALENDAR_SELECTION_TYPE;
|
|
60
|
-
const SelectionConfigurationSingle = _propTypes.default.shape({
|
|
61
|
-
type: _propTypes.default.oneOf([CALENDAR_SELECTION_TYPE.single]),
|
|
62
|
-
date: _propTypes.default.instanceOf(Date)
|
|
63
|
-
});
|
|
64
|
-
const SelectionConfigurationRange = _propTypes.default.shape({
|
|
65
|
-
type: _propTypes.default.oneOf([CALENDAR_SELECTION_TYPE.range]),
|
|
66
|
-
startDate: DateType(),
|
|
67
|
-
endDate: DateType()
|
|
68
|
-
});
|
|
69
|
-
const SelectionConfiguration = _propTypes.default.oneOfType([SelectionConfigurationSingle, SelectionConfigurationRange]);
|
|
70
|
-
const WeekDay = _propTypes.default.shape({
|
|
71
|
-
name: _propTypes.default.string,
|
|
72
|
-
nameAbbr: _propTypes.default.string,
|
|
73
|
-
index: _propTypes.default.number,
|
|
74
|
-
isWeekend: _propTypes.default.bool
|
|
75
|
-
});
|
|
76
|
-
const WeekDayKey = _propTypes.default.string;
|
|
77
|
-
const DaysOfWeek = _propTypes.default.arrayOf(WeekDay);
|
|
78
|
-
const DateModifiers = _propTypes.default.objectOf(_propTypes.default.func);
|
|
79
|
-
const ReactComponent = _propTypes.default.oneOfType([_propTypes.default.string, _propTypes.default.func]);
|
|
80
|
-
var _default = {
|
|
81
|
-
SelectionConfiguration,
|
|
82
|
-
DateModifiers,
|
|
83
|
-
DaysOfWeek,
|
|
84
|
-
ReactComponent,
|
|
85
|
-
WeekDay,
|
|
86
|
-
WeekDayKey
|
|
87
|
-
};
|
|
88
|
-
exports.default = _default;
|
|
29
|
+
exports.CALENDAR_SELECTION_TYPE = CALENDAR_SELECTION_TYPE;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Backpack - Skyscanner's Design System
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2016 Skyscanner Ltd
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import startOfMonth from 'date-fns/startOfMonth';
|
|
20
|
+
import endOfMonth from 'date-fns/endOfMonth';
|
|
21
|
+
import lastDayOfMonth from 'date-fns/lastDayOfMonth';
|
|
22
|
+
import getDay from 'date-fns/getDay';
|
|
23
|
+
import isWithinRange from 'date-fns/isWithinInterval';
|
|
24
|
+
import isToday from 'date-fns/isToday';
|
|
25
|
+
import isSaturday from 'date-fns/isSaturday';
|
|
26
|
+
import isSunday from 'date-fns/isSunday';
|
|
27
|
+
import isSameDay from 'date-fns/isSameDay';
|
|
28
|
+
import isSameWeek from 'date-fns/isSameWeek';
|
|
29
|
+
import isSameMonth from 'date-fns/isSameMonth';
|
|
30
|
+
import isBefore from 'date-fns/isBefore';
|
|
31
|
+
import isAfter from 'date-fns/isAfter';
|
|
32
|
+
import differenceInCalendarMonths from 'date-fns/differenceInCalendarMonths';
|
|
33
|
+
import addDays from 'date-fns/addDays';
|
|
34
|
+
import addMonths from 'date-fns/addMonths';
|
|
35
|
+
import startOfDay from 'date-fns/startOfDay';
|
|
36
|
+
import parseISO from 'date-fns/parseISO';
|
|
37
|
+
import format from 'date-fns/format';
|
|
38
|
+
import type { DaysOfWeek } from './custom-proptypes';
|
|
39
|
+
declare function daysInMonth(year: number, month: number): number;
|
|
40
|
+
declare function getCalendarMonthWeeks(date: Date, weekStartsOn: number): Date[][];
|
|
41
|
+
declare function getLastDayOfWeekend(daysOfWeek: DaysOfWeek): number;
|
|
42
|
+
declare function getFirstDayOfWeekend(daysOfWeek: DaysOfWeek): number;
|
|
43
|
+
declare const orderDaysOfWeek: (daysOfWeek: DaysOfWeek, weekStartsOn: number) => import("./custom-proptypes").WeekDay[];
|
|
44
|
+
declare function getMonthRange(from: Date, to: Date): {
|
|
45
|
+
min: Date;
|
|
46
|
+
max: Date;
|
|
47
|
+
};
|
|
48
|
+
declare function getMonthsInRange(from: Date, to: Date): Date[];
|
|
49
|
+
declare const dateToBoundaries: (date: Date | null, minDate: Date, maxDate: Date) => Date;
|
|
50
|
+
declare const setMonthYear: (date: Date | null, newMonth: number, newYear: number) => Date;
|
|
51
|
+
declare const parseIsoDate: typeof parseISO;
|
|
52
|
+
declare const formatIsoDate: (date: Date) => string;
|
|
53
|
+
declare const formatIsoMonth: (date: Date) => string;
|
|
54
|
+
export { getCalendarMonthWeeks, getFirstDayOfWeekend, getLastDayOfWeekend, getMonthsInRange, getMonthRange, getDay, dateToBoundaries, isWithinRange, isSaturday, isSunday, isToday, isSameDay, isSameWeek, isSameMonth, isBefore, isAfter, differenceInCalendarMonths, addMonths, addDays, orderDaysOfWeek, setMonthYear, startOfMonth, lastDayOfMonth, startOfDay, format, daysInMonth, formatIsoDate, formatIsoMonth, parseIsoDate, endOfMonth, };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Backpack - Skyscanner's Design System
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2016 Skyscanner Ltd
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
export declare const getCalendarGridWidth: (multiplier?: number) => string;
|
|
20
|
+
export declare const getTransformStyles: (transformValue: string) => {
|
|
21
|
+
transform: string;
|
|
22
|
+
msTransform: string;
|
|
23
|
+
MozTransform: string;
|
|
24
|
+
WebkitTransform: string;
|
|
25
|
+
};
|
|
26
|
+
export declare const isTransitionEndSupported: () => boolean;
|
|
@@ -38,6 +38,7 @@ const getCalendarGridWidth = (multiplier = 1) => {
|
|
|
38
38
|
if (sizeUnit !== spacingUnit) {
|
|
39
39
|
throw new Error(`'calendarDaySize' and 'calendarDaySpacing' must use the same unit. Got ${sizeUnit} and ${spacingUnit}`);
|
|
40
40
|
}
|
|
41
|
+
// @ts-expect-error TS doesn't correctly read the size and spacing values type i.e. numbers as returned by parseFloat
|
|
41
42
|
const width = multiplier * (7 * (sizeValue + 2 * spacingValue));
|
|
42
43
|
return `${width}${sizeUnit}`;
|
|
43
44
|
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Backpack - Skyscanner's Design System
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2016 Skyscanner Ltd
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
export declare const formatDateFull: (date: Date) => string;
|
|
20
|
+
export declare const formatDateFullArabic: (date: Date) => string;
|
|
21
|
+
export declare const formatDateFullJapanese: (date: Date) => string;
|
|
22
|
+
export declare const formatMonth: (date: Date) => string;
|
|
23
|
+
export declare const formatMonthArabic: (date: Date) => string;
|
|
24
|
+
export declare const formatMonthJapanese: (date: Date) => string;
|
|
25
|
+
export declare const weekDays: {
|
|
26
|
+
name: string;
|
|
27
|
+
nameAbbr: string;
|
|
28
|
+
nameNarrow: string;
|
|
29
|
+
index: number;
|
|
30
|
+
isWeekend: boolean;
|
|
31
|
+
}[];
|
|
32
|
+
export declare const weekDaysMoreWeekend: {
|
|
33
|
+
name: string;
|
|
34
|
+
nameAbbr: string;
|
|
35
|
+
nameNarrow: string;
|
|
36
|
+
index: number;
|
|
37
|
+
isWeekend: boolean;
|
|
38
|
+
}[];
|
|
39
|
+
export declare const weekDaysArabic: {
|
|
40
|
+
name: string;
|
|
41
|
+
nameAbbr: string;
|
|
42
|
+
nameShort: string;
|
|
43
|
+
nameNarrow: string;
|
|
44
|
+
index: number;
|
|
45
|
+
cldrKey: string;
|
|
46
|
+
isWeekend: boolean;
|
|
47
|
+
}[];
|
|
48
|
+
export declare const weekDaysJapanese: {
|
|
49
|
+
name: string;
|
|
50
|
+
nameAbbr: string;
|
|
51
|
+
nameShort: string;
|
|
52
|
+
nameNarrow: string;
|
|
53
|
+
index: number;
|
|
54
|
+
cldrKey: string;
|
|
55
|
+
isWeekend: boolean;
|
|
56
|
+
}[];
|
|
@@ -28,13 +28,13 @@ const formatDateFull = date => (0, _format.default)(date, 'EEEE, do MMMM yyyy');
|
|
|
28
28
|
exports.formatDateFull = formatDateFull;
|
|
29
29
|
const formatDateFullArabic = date => {
|
|
30
30
|
const dateString = 'EEEE, dd، MMMM، yyyy';
|
|
31
|
-
const newString = dateString.replace('yyyy', date.getUTCFullYear());
|
|
31
|
+
const newString = dateString.replace('yyyy', `${date.getUTCFullYear()}`);
|
|
32
32
|
return (0, _format.default)(date, newString);
|
|
33
33
|
};
|
|
34
34
|
exports.formatDateFullArabic = formatDateFullArabic;
|
|
35
35
|
const formatDateFullJapanese = date => {
|
|
36
36
|
const dateString = 'Y年M月d日EEEE';
|
|
37
|
-
const newString = dateString.replace('Y', date.getUTCFullYear());
|
|
37
|
+
const newString = dateString.replace('Y', `${date.getUTCFullYear()}`);
|
|
38
38
|
return (0, _format.default)(date, newString);
|
|
39
39
|
};
|
|
40
40
|
exports.formatDateFullJapanese = formatDateFullJapanese;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Backpack - Skyscanner's Design System
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2016 Skyscanner Ltd
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import BpkCard from './src/BpkCard';
|
|
20
|
+
import BpkCardWrapper from './src/BpkCardWrapper';
|
|
21
|
+
import BpkDividedCard, { ORIENTATION } from './src/BpkDividedCard';
|
|
22
|
+
|
|
23
|
+
export { ORIENTATION, BpkDividedCard, BpkCardWrapper };
|
|
24
|
+
export default BpkCard;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Backpack - Skyscanner's Design System
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2016 Skyscanner Ltd
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import type { ReactNode } from 'react';
|
|
20
|
+
|
|
21
|
+
type Props = {
|
|
22
|
+
children: ReactNode | string;
|
|
23
|
+
className?: string | null;
|
|
24
|
+
href?: string | null;
|
|
25
|
+
padded?: boolean;
|
|
26
|
+
blank?: boolean;
|
|
27
|
+
atomic?: boolean;
|
|
28
|
+
[rest: string]: any;
|
|
29
|
+
};
|
|
30
|
+
declare const BpkCard: ({
|
|
31
|
+
atomic,
|
|
32
|
+
blank,
|
|
33
|
+
children,
|
|
34
|
+
className,
|
|
35
|
+
href,
|
|
36
|
+
padded,
|
|
37
|
+
...rest
|
|
38
|
+
}: Props) => JSX.Element;
|
|
39
|
+
export default BpkCard;
|