@skyscanner/backpack-web 23.2.2 → 24.0.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.
Files changed (133) hide show
  1. package/bpk-component-aria-live/src/BpkAriaLive.js +0 -1
  2. package/bpk-component-badge/src/BpkBadge.js +0 -1
  3. package/{bpk-scrim-utils/src/customPropTypes.js → bpk-component-banner-alert/index.d.ts} +16 -14
  4. package/bpk-component-banner-alert/src/AnimateAndFade.d.ts +61 -0
  5. package/bpk-component-banner-alert/src/AnimateAndFade.js +3 -9
  6. package/bpk-component-banner-alert/src/BpkBannerAlert.d.ts +29 -0
  7. package/bpk-component-banner-alert/src/BpkBannerAlert.js +42 -21
  8. package/bpk-component-banner-alert/src/BpkBannerAlertDismissable.d.ts +30 -0
  9. package/bpk-component-banner-alert/src/BpkBannerAlertDismissable.js +31 -33
  10. package/bpk-component-banner-alert/src/BpkBannerAlertExpandable.d.ts +35 -0
  11. package/bpk-component-banner-alert/src/BpkBannerAlertExpandable.js +15 -28
  12. package/bpk-component-banner-alert/src/BpkBannerAlertInner.d.ts +58 -0
  13. package/bpk-component-banner-alert/src/BpkBannerAlertInner.js +65 -87
  14. package/bpk-component-banner-alert/src/common-types.d.ts +44 -0
  15. package/bpk-component-banner-alert/src/common-types.js +5 -23
  16. package/bpk-component-banner-alert/src/themeAttributes.d.ts +20 -0
  17. package/bpk-component-banner-alert/src/withBannerAlertState.d.ts +169 -0
  18. package/bpk-component-banner-alert/src/withBannerAlertState.js +10 -29
  19. package/bpk-component-boilerplate/src/BpkBoilerplate.js +0 -1
  20. package/bpk-component-button/src/BpkButtonV2/BpkButton.js +0 -1
  21. package/bpk-component-calendar/index.d.ts +30 -0
  22. package/bpk-component-calendar/index.js +5 -4
  23. package/bpk-component-calendar/src/BpkCalendarContainer.d.ts +464 -0
  24. package/bpk-component-calendar/src/BpkCalendarContainer.js +19 -29
  25. package/bpk-component-calendar/src/BpkCalendarDate.d.ts +62 -0
  26. package/bpk-component-calendar/src/BpkCalendarDate.js +15 -39
  27. package/bpk-component-calendar/src/BpkCalendarGrid.d.ts +68 -0
  28. package/bpk-component-calendar/src/BpkCalendarGrid.js +9 -40
  29. package/bpk-component-calendar/src/BpkCalendarGridHeader.d.ts +36 -0
  30. package/bpk-component-calendar/src/BpkCalendarGridHeader.js +33 -52
  31. package/bpk-component-calendar/src/BpkCalendarGridTransition.d.ts +56 -0
  32. package/bpk-component-calendar/src/BpkCalendarGridTransition.js +43 -42
  33. package/bpk-component-calendar/src/BpkCalendarNav.d.ts +37 -0
  34. package/bpk-component-calendar/src/BpkCalendarNav.js +18 -32
  35. package/bpk-component-calendar/src/Week.d.ts +51 -0
  36. package/bpk-component-calendar/src/Week.js +48 -70
  37. package/bpk-component-calendar/src/composeCalendar.d.ts +55 -0
  38. package/bpk-component-calendar/src/composeCalendar.js +34 -95
  39. package/bpk-component-calendar/src/custom-proptypes-legacy.js +140 -0
  40. package/bpk-component-calendar/src/custom-proptypes.d.ts +46 -0
  41. package/bpk-component-calendar/src/custom-proptypes.js +2 -61
  42. package/bpk-component-calendar/src/date-utils.d.ts +54 -0
  43. package/bpk-component-calendar/src/utils.d.ts +26 -0
  44. package/bpk-component-calendar/src/utils.js +1 -0
  45. package/bpk-component-calendar/test-utils.d.ts +56 -0
  46. package/bpk-component-calendar/test-utils.js +2 -2
  47. package/bpk-component-card/index.d.ts +24 -0
  48. package/bpk-component-card/src/BpkCard.d.ts +39 -0
  49. package/bpk-component-card/src/BpkCard.js +9 -25
  50. package/bpk-component-card/src/BpkCardWrapper.d.ts +33 -0
  51. package/bpk-component-card/src/BpkCardWrapper.js +10 -18
  52. package/bpk-component-card/src/BpkDividedCard.d.ts +43 -0
  53. package/bpk-component-card/src/BpkDividedCard.js +9 -24
  54. package/bpk-component-chip/index.d.ts +32 -0
  55. package/bpk-component-chip/src/BpkDismissibleChip.d.ts +28 -0
  56. package/bpk-component-chip/src/BpkDismissibleChip.js +9 -8
  57. package/bpk-component-chip/src/BpkDropdownChip.d.ts +29 -0
  58. package/bpk-component-chip/src/BpkDropdownChip.js +39 -25
  59. package/bpk-component-chip/src/BpkSelectableChip.d.ts +39 -0
  60. package/bpk-component-chip/src/BpkSelectableChip.js +33 -48
  61. package/bpk-component-chip/src/commonTypes.d.ts +56 -0
  62. package/bpk-component-chip/src/commonTypes.js +8 -2
  63. package/bpk-component-dialog/src/BpkDialog.d.ts +1 -12
  64. package/bpk-component-dialog/src/BpkDialog.js +1 -2
  65. package/bpk-component-dialog/src/BpkDialogInner.d.ts +256 -2
  66. package/bpk-component-dialog/src/BpkDialogInner.js +0 -4
  67. package/bpk-component-dialog/src/common-types.d.ts +20 -21
  68. package/bpk-component-graphic-promotion/src/BpkGraphicPromo.js +0 -4
  69. package/bpk-component-icon/src/classNameModifierHOCFactory.js +0 -1
  70. package/bpk-component-icon/src/withAlignment.js +1 -1
  71. package/bpk-component-icon/src/withDescription.js +1 -1
  72. package/bpk-component-icon/src/withRtlSupport.js +0 -2
  73. package/bpk-component-input/index.d.ts +39 -0
  74. package/bpk-component-input/src/BpkClearButton.d.ts +28 -0
  75. package/bpk-component-input/src/BpkClearButton.js +6 -14
  76. package/bpk-component-input/src/BpkInput.d.ts +46 -0
  77. package/bpk-component-input/src/BpkInput.js +7 -3
  78. package/bpk-component-input/src/common-types.d.ts +91 -0
  79. package/bpk-component-input/src/common-types.js +4 -1
  80. package/bpk-component-input/src/withOpenEvents.d.ts +121 -0
  81. package/bpk-component-input/src/withOpenEvents.js +14 -25
  82. package/bpk-component-modal/index.d.ts +26 -0
  83. package/bpk-component-modal/index.js +13 -6
  84. package/bpk-component-modal/src/BpkModal.d.ts +32 -0
  85. package/bpk-component-modal/src/BpkModal.js +24 -44
  86. package/bpk-component-modal/src/BpkModalInner.d.ts +39 -0
  87. package/bpk-component-modal/src/BpkModalInner.js +67 -84
  88. package/bpk-component-modal/src/BpkModalV2/BpKModal.module.css +18 -0
  89. package/bpk-component-modal/src/BpkModalV2/BpkModal.d.ts +35 -0
  90. package/bpk-component-modal/src/BpkModalV2/BpkModal.js +131 -0
  91. package/bpk-component-modal/src/legacy-prop-types.js +86 -0
  92. package/bpk-component-modal/src/themeAttributes.js +1 -0
  93. package/bpk-component-rtl-toggle/index.d.ts +23 -0
  94. package/bpk-component-rtl-toggle/src/BpkRtlToggle.d.ts +41 -0
  95. package/bpk-component-rtl-toggle/src/BpkRtlToggle.js +9 -12
  96. package/bpk-component-rtl-toggle/src/updateOnDirectionChange.d.ts +151 -0
  97. package/bpk-component-rtl-toggle/src/updateOnDirectionChange.js +9 -2
  98. package/bpk-component-rtl-toggle/src/utils.d.ts +25 -0
  99. package/bpk-component-text/index.d.ts +21 -0
  100. package/bpk-component-text/index.js +0 -6
  101. package/bpk-component-text/src/BpkText.d.ts +60 -0
  102. package/bpk-component-text/src/BpkText.js +16 -56
  103. package/bpk-component-text/src/BpkText.module.css +1 -1
  104. package/bpk-component-tooltip/index.d.ts +24 -0
  105. package/bpk-component-tooltip/src/BpkTooltip.d.ts +29 -0
  106. package/bpk-component-tooltip/src/BpkTooltip.js +9 -26
  107. package/bpk-component-tooltip/src/BpkTooltipPortal.d.ts +60 -0
  108. package/bpk-component-tooltip/src/BpkTooltipPortal.js +13 -21
  109. package/bpk-component-tooltip/src/constants.d.ts +31 -0
  110. package/bpk-component-tooltip/src/constants.js +3 -1
  111. package/bpk-react-utils/index.d.ts +58 -0
  112. package/bpk-react-utils/index.js +1 -0
  113. package/bpk-react-utils/src/Portal.d.ts +76 -0
  114. package/bpk-react-utils/src/Portal.js +33 -43
  115. package/bpk-react-utils/src/TransitionInitialMount.d.ts +27 -0
  116. package/bpk-react-utils/src/TransitionInitialMount.js +7 -8
  117. package/bpk-react-utils/src/cssModules.d.ts +22 -0
  118. package/bpk-react-utils/src/deprecated.js +2 -1
  119. package/bpk-react-utils/src/deviceDetection.d.ts +22 -0
  120. package/bpk-react-utils/src/deviceDetection.js +3 -1
  121. package/bpk-react-utils/src/isRTL.d.ts +20 -0
  122. package/bpk-react-utils/src/isRTL.js +3 -1
  123. package/bpk-react-utils/src/withDefaultProps.d.ts +33 -0
  124. package/bpk-react-utils/src/withDefaultProps.js +11 -24
  125. package/bpk-react-utils/src/wrapDisplayName.d.ts +21 -0
  126. package/bpk-scrim-utils/index.d.ts +283 -0
  127. package/bpk-scrim-utils/src/BpkScrim.d.ts +24 -0
  128. package/bpk-scrim-utils/src/BpkScrim.js +5 -10
  129. package/bpk-scrim-utils/src/scroll-utils.d.ts +24 -0
  130. package/bpk-scrim-utils/src/scroll-utils.js +1 -1
  131. package/bpk-scrim-utils/src/withScrim.d.ts +96 -0
  132. package/bpk-scrim-utils/src/withScrim.js +5 -12
  133. package/package.json +1 -1
@@ -3,11 +3,9 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.propTypes = exports.defaultProps = exports.default = exports.SELECTION_TYPES = exports.ROW_TYPES = void 0;
7
- var _propTypes = _interopRequireDefault(require("prop-types"));
6
+ exports.default = exports.SELECTION_TYPES = exports.ROW_TYPES = void 0;
8
7
  var _react = require("react");
9
8
  var _bpkReactUtils = require("../../bpk-react-utils");
10
- var _customProptypes = _interopRequireDefault(require("./custom-proptypes"));
11
9
  var _BpkCalendarDateModule = _interopRequireDefault(require("./BpkCalendarDate.module.css"));
12
10
  var _jsxRuntime = require("react/jsx-runtime");
13
11
  const _excluded = ["className", "date", "isBlocked", "isFocused", "isKeyboardFocusable", "isOutside", "isSelected", "isToday", "modifiers", "onClick", "onDateKeyDown", "selectionType", "style"];
@@ -52,20 +50,18 @@ const ROW_TYPES = {
52
50
  both: 'both'
53
51
  };
54
52
  exports.ROW_TYPES = ROW_TYPES;
55
- const navigatedByMonthNudger = () => document.activeElement.id && document.activeElement.id.indexOf('month_nudger') !== -1;
53
+ const navigatedByMonthNudger = () => document?.activeElement?.id && document.activeElement.id.indexOf('month_nudger') !== -1;
56
54
  class BpkCalendarDate extends _react.PureComponent {
57
55
  constructor(...args) {
58
56
  super(...args);
59
- _defineProperty(this, "getButtonRef", button => {
60
- this.button = button;
61
- });
57
+ _defineProperty(this, "button", null);
62
58
  }
63
59
  componentDidMount() {
64
60
  if (!this.props.preventKeyboardFocus && this.props.isFocused) {
65
61
  // If we got here by clicking the nudger, don't focus this date
66
62
  if (!navigatedByMonthNudger()) {
67
63
  // Giving focus after instantiation
68
- this.button.focus();
64
+ this.button?.focus();
69
65
  }
70
66
  }
71
67
  }
@@ -76,13 +72,13 @@ class BpkCalendarDate extends _react.PureComponent {
76
72
 
77
73
  // Giving focus after keyboard navigation
78
74
  if (!prevProps.isFocused && this.props.isFocused && this.props.isKeyboardFocusable) {
79
- this.button.focus();
75
+ this.button?.focus();
80
76
  return;
81
77
  }
82
78
 
83
79
  // Giving focus after changing months with transition
84
80
  if (this.props.isFocused && !prevProps.isKeyboardFocusable && this.props.isKeyboardFocusable) {
85
- this.button.focus();
81
+ this.button?.focus();
86
82
  }
87
83
  }
88
84
  render() {
@@ -133,9 +129,9 @@ class BpkCalendarDate extends _react.PureComponent {
133
129
  style: style,
134
130
  className: classNames.join(' '),
135
131
  "aria-hidden": isBlocked,
136
- "aria-label": date.getDate(),
132
+ "aria-label": `${date.getDate()}`,
137
133
  disabled: isBlocked,
138
- tabIndex: isKeyboardFocusable && isFocused ? '0' : '-1',
134
+ tabIndex: isKeyboardFocusable && isFocused ? 0 : -1,
139
135
  onClick: () => {
140
136
  if (onClick) {
141
137
  onClick(date);
@@ -143,7 +139,9 @@ class BpkCalendarDate extends _react.PureComponent {
143
139
  },
144
140
  onKeyDown: onDateKeyDown,
145
141
  "aria-pressed": isSelected,
146
- ref: this.getButtonRef
142
+ ref: button => {
143
+ this.button = button;
144
+ }
147
145
  }, buttonProps), {}, {
148
146
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
149
147
  "aria-hidden": "true",
@@ -152,27 +150,7 @@ class BpkCalendarDate extends _react.PureComponent {
152
150
  }));
153
151
  }
154
152
  }
155
- const propTypes = {
156
- // Required
157
- date: _propTypes.default.instanceOf(Date).isRequired,
158
- // Optional
159
- className: _propTypes.default.string,
160
- isBlocked: _propTypes.default.bool,
161
- isFocused: _propTypes.default.bool,
162
- isKeyboardFocusable: _propTypes.default.bool,
163
- isOutside: _propTypes.default.bool,
164
- isSelected: _propTypes.default.bool,
165
- isToday: _propTypes.default.bool,
166
- modifiers: _customProptypes.default.DateModifiers,
167
- onClick: _propTypes.default.func,
168
- onDateKeyDown: _propTypes.default.func,
169
- preventKeyboardFocus: _propTypes.default.bool,
170
- selectionType: _propTypes.default.oneOf(Object.keys(SELECTION_TYPES)),
171
- style: _propTypes.default.object
172
- };
173
- exports.propTypes = propTypes;
174
- BpkCalendarDate.propTypes = _objectSpread({}, propTypes);
175
- const defaultProps = {
153
+ _defineProperty(BpkCalendarDate, "defaultProps", {
176
154
  className: null,
177
155
  isBlocked: false,
178
156
  isFocused: false,
@@ -182,12 +160,10 @@ const defaultProps = {
182
160
  isToday: false,
183
161
  modifiers: {},
184
162
  onClick: null,
185
- onDateKeyDown: null,
163
+ onDateKeyDown: () => {},
186
164
  preventKeyboardFocus: true,
187
165
  selectionType: SELECTION_TYPES.none,
188
- style: null
189
- };
190
- exports.defaultProps = defaultProps;
191
- BpkCalendarDate.defaultProps = _objectSpread({}, defaultProps);
166
+ style: {}
167
+ });
192
168
  var _default = BpkCalendarDate;
193
169
  exports.default = _default;
@@ -0,0 +1,68 @@
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 { ElementType } from 'react';
20
+ import { Component } from 'react';
21
+ import type { DateModifiers, SelectionConfiguration } from './custom-proptypes';
22
+ type DefaultProps = {
23
+ className: string | null;
24
+ dateModifiers: DateModifiers;
25
+ focusedDate: Date | null;
26
+ cellClassName: string | null;
27
+ isKeyboardFocusable: boolean;
28
+ markOutsideDays: boolean;
29
+ markToday: boolean;
30
+ maxDate: Date;
31
+ minDate: Date;
32
+ onDateClick: () => void;
33
+ onDateKeyDown: () => void;
34
+ preventKeyboardFocus: boolean;
35
+ selectionConfiguration: SelectionConfiguration;
36
+ ignoreOutsideDate: boolean;
37
+ dateProps: {};
38
+ };
39
+ type Props = DefaultProps & {
40
+ DateComponent: ElementType;
41
+ formatDateFull: (date: Date) => Date | string;
42
+ month: Date;
43
+ weekStartsOn: 0 | 1 | 2 | 3 | 4 | 5 | 6;
44
+ };
45
+ type State = {
46
+ calendarMonthWeeks: Date[][];
47
+ };
48
+ declare class BpkCalendarGrid extends Component<Props, State> {
49
+ static defaultProps: DefaultProps;
50
+ constructor(props: Props);
51
+ UNSAFE_componentWillReceiveProps(nextProps: Props): void;
52
+ render(): JSX.Element;
53
+ }
54
+ declare const BpkCalendarGridWithTransition: typeof BpkCalendarGrid | ((props: Omit<DefaultProps & {
55
+ DateComponent: ElementType;
56
+ formatDateFull: (date: Date) => Date | string;
57
+ month: Date;
58
+ weekStartsOn: 0 | 1 | 2 | 3 | 4 | 5 | 6;
59
+ } & {
60
+ TransitionComponent: ElementType<any>;
61
+ } & {
62
+ [rest: string]: any;
63
+ className?: string | null | undefined;
64
+ month?: Date | undefined;
65
+ focusedDate?: Date | null | undefined;
66
+ }, "TransitionComponent">) => JSX.Element);
67
+ export default BpkCalendarGrid;
68
+ export { BpkCalendarGridWithTransition };
@@ -3,21 +3,16 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.propTypes = exports.default = exports.BpkCalendarGridWithTransition = void 0;
7
- var _propTypes = _interopRequireDefault(require("prop-types"));
6
+ exports.default = exports.BpkCalendarGridWithTransition = void 0;
8
7
  var _react = require("react");
9
8
  var _bpkReactUtils = require("../../bpk-react-utils");
10
9
  var _Week = _interopRequireDefault(require("./Week"));
11
10
  var _dateUtils = require("./date-utils");
12
- var _customProptypes = _interopRequireWildcard(require("./custom-proptypes"));
11
+ var _customProptypes = require("./custom-proptypes");
13
12
  var _BpkCalendarGridModule = _interopRequireDefault(require("./BpkCalendarGrid.module.css"));
14
13
  var _BpkCalendarGridTransition = require("./BpkCalendarGridTransition");
15
14
  var _jsxRuntime = require("react/jsx-runtime");
16
- 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); }
17
- 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
15
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
- 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; }
20
- 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; }
21
16
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
22
17
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
23
18
  function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } /*
@@ -44,7 +39,6 @@ function _toPrimitive(input, hint) { if (typeof input !== "object" || input ===
44
39
  // NOTE that ./Week is also importing ./BpkCalendarGrid.module.css so adding this after `./Week` would also do the job but
45
40
  // for clarity we should leave it here.
46
41
  const getClassName = (0, _bpkReactUtils.cssModules)(_BpkCalendarGridModule.default);
47
-
48
42
  /*
49
43
  BpkCalendarGrid - the grid representing a whole month
50
44
  */
@@ -120,32 +114,9 @@ class BpkCalendarGrid extends _react.Component {
120
114
  });
121
115
  }
122
116
  }
123
- const propTypes = {
124
- // Required
125
- DateComponent: _propTypes.default.elementType.isRequired,
126
- formatDateFull: _propTypes.default.func.isRequired,
127
- month: _propTypes.default.instanceOf(Date).isRequired,
128
- weekStartsOn: _propTypes.default.number.isRequired,
129
- // Optional
130
- className: _propTypes.default.string,
131
- cellClassName: _propTypes.default.string,
132
- dateModifiers: _customProptypes.default.DateModifiers,
133
- focusedDate: _propTypes.default.instanceOf(Date),
134
- isKeyboardFocusable: _propTypes.default.bool,
135
- markOutsideDays: _propTypes.default.bool,
136
- markToday: _propTypes.default.bool,
137
- maxDate: _propTypes.default.instanceOf(Date),
138
- minDate: _propTypes.default.instanceOf(Date),
139
- onDateClick: _propTypes.default.func,
140
- onDateKeyDown: _propTypes.default.func,
141
- preventKeyboardFocus: _propTypes.default.bool,
142
- selectionConfiguration: _customProptypes.default.SelectionConfiguration,
143
- ignoreOutsideDate: _propTypes.default.bool,
144
- dateProps: _propTypes.default.object
145
- };
146
- exports.propTypes = propTypes;
147
- BpkCalendarGrid.propTypes = _objectSpread({}, propTypes);
148
- BpkCalendarGrid.defaultProps = {
117
+
118
+ // On iOS, having transitions causes accessibility issues, so we disable it (KOA-4467).
119
+ _defineProperty(BpkCalendarGrid, "defaultProps", {
149
120
  className: null,
150
121
  dateModifiers: {},
151
122
  focusedDate: null,
@@ -154,19 +125,17 @@ BpkCalendarGrid.defaultProps = {
154
125
  markToday: true,
155
126
  maxDate: (0, _dateUtils.addMonths)(new Date(), 12),
156
127
  minDate: new Date(),
157
- onDateClick: null,
158
- onDateKeyDown: null,
128
+ onDateClick: () => {},
129
+ onDateKeyDown: () => {},
159
130
  preventKeyboardFocus: false,
160
131
  selectionConfiguration: {
161
132
  type: _customProptypes.CALENDAR_SELECTION_TYPE.single,
162
133
  date: null
163
134
  },
164
135
  ignoreOutsideDate: false,
165
- dateProps: null,
136
+ dateProps: {},
166
137
  cellClassName: null
167
- };
168
-
169
- // On iOS, having transitions causes accessibility issues, so we disable it (KOA-4467).
138
+ });
170
139
  const BpkCalendarGridWithTransition = (0, _bpkReactUtils.isDeviceIos)() ? BpkCalendarGrid : (0, _BpkCalendarGridTransition.addCalendarGridTransition)(BpkCalendarGrid);
171
140
  exports.BpkCalendarGridWithTransition = BpkCalendarGridWithTransition;
172
141
  var _default = BpkCalendarGrid;
@@ -0,0 +1,36 @@
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 { PureComponent } from 'react';
20
+ import type { DaysOfWeek, WeekDayKey } from './custom-proptypes';
21
+ type Props = DefaultProps & {
22
+ daysOfWeek: DaysOfWeek;
23
+ weekStartsOn: 0 | 1 | 2 | 3 | 4 | 5 | 6;
24
+ };
25
+ type DefaultProps = {
26
+ className?: string | null;
27
+ weekDayKey: WeekDayKey;
28
+ };
29
+ declare class BpkCalendarGridHeader extends PureComponent<Props> {
30
+ static defaultProps: {
31
+ className: null;
32
+ weekDayKey: string;
33
+ };
34
+ render(): JSX.Element;
35
+ }
36
+ export default BpkCalendarGridHeader;
@@ -4,59 +4,46 @@ 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 _react = require("react");
9
8
  var _bpkReactUtils = require("../../bpk-react-utils");
10
- var _customProptypes = _interopRequireDefault(require("./custom-proptypes"));
11
9
  var _dateUtils = require("./date-utils");
12
10
  var _BpkCalendarGridHeaderModule = _interopRequireDefault(require("./BpkCalendarGridHeader.module.css"));
13
11
  var _jsxRuntime = require("react/jsx-runtime");
14
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
- /*
16
- * Backpack - Skyscanner's Design System
17
- *
18
- * Copyright 2016 Skyscanner Ltd
19
- *
20
- * Licensed under the Apache License, Version 2.0 (the "License");
21
- * you may not use this file except in compliance with the License.
22
- * You may obtain a copy of the License at
23
- *
24
- * http://www.apache.org/licenses/LICENSE-2.0
25
- *
26
- * Unless required by applicable law or agreed to in writing, software
27
- * distributed under the License is distributed on an "AS IS" BASIS,
28
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
29
- * See the License for the specific language governing permissions and
30
- * limitations under the License.
31
- */
32
-
13
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
14
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
15
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } /*
16
+ * Backpack - Skyscanner's Design System
17
+ *
18
+ * Copyright 2016 Skyscanner Ltd
19
+ *
20
+ * Licensed under the Apache License, Version 2.0 (the "License");
21
+ * you may not use this file except in compliance with the License.
22
+ * You may obtain a copy of the License at
23
+ *
24
+ * http://www.apache.org/licenses/LICENSE-2.0
25
+ *
26
+ * Unless required by applicable law or agreed to in writing, software
27
+ * distributed under the License is distributed on an "AS IS" BASIS,
28
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
29
+ * See the License for the specific language governing permissions and
30
+ * limitations under the License.
31
+ */
33
32
  const getClassName = (0, _bpkReactUtils.cssModules)(_BpkCalendarGridHeaderModule.default);
34
-
35
33
  /*
36
34
  WeekDay - table header cells such as "Mon", "Tue", "Wed"...
37
35
  */
38
- const WeekDay = props => {
39
- const {
40
- Element,
41
- weekDay,
42
- weekDayKey
43
- } = props;
44
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(Element, {
45
- className: getClassName('bpk-calendar-header__weekday'),
46
- title: weekDay.name,
47
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
48
- children: weekDay[weekDayKey]
49
- })
50
- });
51
- };
52
- WeekDay.propTypes = {
53
- Element: _customProptypes.default.ReactComponent.isRequired,
54
- weekDay: _customProptypes.default.WeekDay.isRequired,
55
- weekDayKey: _customProptypes.default.WeekDayKey
56
- };
57
- WeekDay.defaultProps = {
58
- weekDayKey: 'nameAbbr'
59
- };
36
+ const WeekDayComponent = ({
37
+ Element,
38
+ weekDay,
39
+ weekDayKey = 'nameAbbr'
40
+ }) => /*#__PURE__*/(0, _jsxRuntime.jsx)(Element, {
41
+ className: getClassName('bpk-calendar-header__weekday'),
42
+ title: weekDay.name,
43
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
44
+ children: weekDay[weekDayKey]
45
+ })
46
+ });
60
47
  class BpkCalendarGridHeader extends _react.PureComponent {
61
48
  render() {
62
49
  const {
@@ -74,7 +61,7 @@ class BpkCalendarGridHeader extends _react.PureComponent {
74
61
  "aria-hidden": true,
75
62
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)("ol", {
76
63
  className: getClassName('bpk-calendar-header__week'),
77
- children: daysOfWeek.map(weekDay => /*#__PURE__*/(0, _jsxRuntime.jsx)(WeekDay, {
64
+ children: daysOfWeek.map(weekDay => /*#__PURE__*/(0, _jsxRuntime.jsx)(WeekDayComponent, {
78
65
  Element: "li",
79
66
  weekDay: weekDay,
80
67
  weekDayKey: weekDayKey
@@ -83,15 +70,9 @@ class BpkCalendarGridHeader extends _react.PureComponent {
83
70
  });
84
71
  }
85
72
  }
86
- BpkCalendarGridHeader.propTypes = {
87
- daysOfWeek: _customProptypes.default.DaysOfWeek.isRequired,
88
- weekStartsOn: _propTypes.default.number.isRequired,
89
- className: _propTypes.default.string,
90
- weekDayKey: _customProptypes.default.WeekDayKey
91
- };
92
- BpkCalendarGridHeader.defaultProps = {
73
+ _defineProperty(BpkCalendarGridHeader, "defaultProps", {
93
74
  className: null,
94
75
  weekDayKey: 'nameAbbr'
95
- };
76
+ });
96
77
  var _default = BpkCalendarGridHeader;
97
78
  exports.default = _default;
@@ -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
+ import type { ComponentType, ElementType } from 'react';
20
+ import { Component } from 'react';
21
+ export type Props = InjectedCalendarGridTransitionProps & {
22
+ className?: string | null;
23
+ month?: Date;
24
+ focusedDate?: Date | null;
25
+ [rest: string]: any;
26
+ };
27
+ type InjectedCalendarGridTransitionProps = {
28
+ TransitionComponent: ElementType;
29
+ };
30
+ type State = {
31
+ isTransitioning: boolean;
32
+ transitionValue: string;
33
+ currentMonth?: Date | null;
34
+ months: Date[];
35
+ };
36
+ declare class BpkCalendarGridTransition extends Component<Props, State> {
37
+ isTransitionEndSupported: boolean;
38
+ static defaultProps: {
39
+ className: null;
40
+ month: Date;
41
+ focusedDate: null;
42
+ };
43
+ constructor(props: Props);
44
+ UNSAFE_componentWillReceiveProps({ month: nextMonth }: Props): void;
45
+ componentDidUpdate(): void;
46
+ onMonthTransitionEnd(): void;
47
+ render(): JSX.Element;
48
+ }
49
+ declare const addCalendarGridTransition: <P extends {}>(TransitionComponent: ComponentType<P>) => (props: Omit<P & InjectedCalendarGridTransitionProps & {
50
+ [rest: string]: any;
51
+ className?: string | null | undefined;
52
+ month?: Date | undefined;
53
+ focusedDate?: Date | null | undefined;
54
+ }, "TransitionComponent">) => JSX.Element;
55
+ export default BpkCalendarGridTransition;
56
+ export { addCalendarGridTransition };