@skyscanner/backpack-web 23.2.1 → 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.
Files changed (111) 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/index.js +13 -0
  21. package/bpk-component-button/src/BpkButtonV2/BpkButton.js +0 -1
  22. package/bpk-component-calendar/index.d.ts +30 -0
  23. package/bpk-component-calendar/index.js +5 -4
  24. package/bpk-component-calendar/src/BpkCalendarContainer.d.ts +429 -0
  25. package/bpk-component-calendar/src/BpkCalendarContainer.js +19 -29
  26. package/bpk-component-calendar/src/BpkCalendarDate.d.ts +62 -0
  27. package/bpk-component-calendar/src/BpkCalendarDate.js +15 -39
  28. package/bpk-component-calendar/src/BpkCalendarGrid.d.ts +68 -0
  29. package/bpk-component-calendar/src/BpkCalendarGrid.js +9 -40
  30. package/bpk-component-calendar/src/BpkCalendarGridHeader.d.ts +36 -0
  31. package/bpk-component-calendar/src/BpkCalendarGridHeader.js +33 -52
  32. package/bpk-component-calendar/src/BpkCalendarGridTransition.d.ts +56 -0
  33. package/bpk-component-calendar/src/BpkCalendarGridTransition.js +43 -42
  34. package/bpk-component-calendar/src/BpkCalendarNav.d.ts +37 -0
  35. package/bpk-component-calendar/src/BpkCalendarNav.js +18 -32
  36. package/bpk-component-calendar/src/Week.d.ts +51 -0
  37. package/bpk-component-calendar/src/Week.js +48 -70
  38. package/bpk-component-calendar/src/composeCalendar.d.ts +52 -0
  39. package/bpk-component-calendar/src/composeCalendar.js +34 -95
  40. package/bpk-component-calendar/src/custom-proptypes-legacy.js +140 -0
  41. package/bpk-component-calendar/src/custom-proptypes.d.ts +46 -0
  42. package/bpk-component-calendar/src/custom-proptypes.js +2 -61
  43. package/bpk-component-calendar/src/date-utils.d.ts +54 -0
  44. package/bpk-component-calendar/src/utils.d.ts +26 -0
  45. package/bpk-component-calendar/src/utils.js +1 -0
  46. package/bpk-component-calendar/test-utils.d.ts +56 -0
  47. package/bpk-component-calendar/test-utils.js +2 -2
  48. package/bpk-component-card/index.d.ts +24 -0
  49. package/bpk-component-card/src/BpkCard.d.ts +39 -0
  50. package/bpk-component-card/src/BpkCard.js +9 -25
  51. package/bpk-component-card/src/BpkCardWrapper.d.ts +33 -0
  52. package/bpk-component-card/src/BpkCardWrapper.js +10 -18
  53. package/bpk-component-card/src/BpkDividedCard.d.ts +43 -0
  54. package/bpk-component-card/src/BpkDividedCard.js +9 -24
  55. package/bpk-component-chip/index.d.ts +32 -0
  56. package/bpk-component-chip/src/BpkDismissibleChip.d.ts +28 -0
  57. package/bpk-component-chip/src/BpkDismissibleChip.js +9 -8
  58. package/bpk-component-chip/src/BpkDropdownChip.d.ts +29 -0
  59. package/bpk-component-chip/src/BpkDropdownChip.js +39 -25
  60. package/bpk-component-chip/src/BpkSelectableChip.d.ts +39 -0
  61. package/bpk-component-chip/src/BpkSelectableChip.js +34 -48
  62. package/bpk-component-chip/src/commonTypes.d.ts +56 -0
  63. package/bpk-component-chip/src/commonTypes.js +8 -2
  64. package/bpk-component-dialog/src/BpkDialog.js +0 -1
  65. package/bpk-component-dialog/src/BpkDialogInner.js +0 -2
  66. package/bpk-component-graphic-promotion/src/BpkGraphicPromo.js +0 -2
  67. package/bpk-component-icon/src/classNameModifierHOCFactory.js +0 -1
  68. package/bpk-component-icon/src/withAlignment.js +1 -1
  69. package/bpk-component-icon/src/withDescription.js +1 -1
  70. package/bpk-component-icon/src/withRtlSupport.js +0 -2
  71. package/bpk-component-input/index.d.ts +39 -0
  72. package/bpk-component-input/src/BpkClearButton.d.ts +28 -0
  73. package/bpk-component-input/src/BpkClearButton.js +6 -14
  74. package/bpk-component-input/src/BpkInput.d.ts +46 -0
  75. package/bpk-component-input/src/BpkInput.js +7 -3
  76. package/bpk-component-input/src/common-types.d.ts +91 -0
  77. package/bpk-component-input/src/common-types.js +4 -1
  78. package/bpk-component-input/src/withOpenEvents.d.ts +121 -0
  79. package/bpk-component-input/src/withOpenEvents.js +14 -25
  80. package/bpk-component-modal/index.js +11 -4
  81. package/bpk-component-modal/src/BpkModalV2/BpKModal.module.css +18 -0
  82. package/bpk-component-modal/src/BpkModalV2/BpkModal.d.ts +35 -0
  83. package/bpk-component-modal/src/BpkModalV2/BpkModal.js +133 -0
  84. package/bpk-component-rtl-toggle/index.d.ts +23 -0
  85. package/bpk-component-rtl-toggle/src/BpkRtlToggle.d.ts +41 -0
  86. package/bpk-component-rtl-toggle/src/BpkRtlToggle.js +9 -12
  87. package/bpk-component-rtl-toggle/src/updateOnDirectionChange.d.ts +151 -0
  88. package/bpk-component-rtl-toggle/src/updateOnDirectionChange.js +9 -2
  89. package/bpk-component-rtl-toggle/src/utils.d.ts +25 -0
  90. package/bpk-react-utils/index.d.ts +58 -0
  91. package/bpk-react-utils/index.js +1 -0
  92. package/bpk-react-utils/src/Portal.d.ts +76 -0
  93. package/bpk-react-utils/src/Portal.js +33 -43
  94. package/bpk-react-utils/src/TransitionInitialMount.d.ts +27 -0
  95. package/bpk-react-utils/src/TransitionInitialMount.js +7 -8
  96. package/bpk-react-utils/src/cssModules.d.ts +22 -0
  97. package/bpk-react-utils/src/deprecated.js +2 -1
  98. package/bpk-react-utils/src/deviceDetection.d.ts +22 -0
  99. package/bpk-react-utils/src/deviceDetection.js +3 -1
  100. package/bpk-react-utils/src/isRTL.d.ts +20 -0
  101. package/bpk-react-utils/src/isRTL.js +3 -1
  102. package/bpk-react-utils/src/withDefaultProps.d.ts +33 -0
  103. package/bpk-react-utils/src/withDefaultProps.js +11 -24
  104. package/bpk-react-utils/src/wrapDisplayName.d.ts +21 -0
  105. package/bpk-scrim-utils/src/BpkScrim.d.ts +24 -0
  106. package/bpk-scrim-utils/src/BpkScrim.js +5 -10
  107. package/bpk-scrim-utils/src/scroll-utils.d.ts +24 -0
  108. package/bpk-scrim-utils/src/scroll-utils.js +1 -1
  109. package/bpk-scrim-utils/src/withScrim.d.ts +95 -0
  110. package/bpk-scrim-utils/src/withScrim.js +5 -12
  111. package/package.json +1 -1
@@ -5,11 +5,10 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var _react = require("react");
8
- var _propTypes = _interopRequireDefault(require("prop-types"));
9
8
  var _bpkReactUtils = require("../../bpk-react-utils");
10
9
  var _BpkInputModule = _interopRequireDefault(require("./BpkInput.module.css"));
11
10
  var _jsxRuntime = require("react/jsx-runtime");
12
- const _excluded = ["className", "hasTouchSupport", "onBlur", "onClick", "onFocus", "onKeyDown", "onKeyUp", "onOpen", "onTouchEnd"];
11
+ const _excluded = ["className", "hasTouchSupport", "isOpen", "onBlur", "onClick", "onFocus", "onKeyDown", "onKeyUp", "onOpen", "onTouchEnd"];
13
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
13
  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; }
15
14
  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; }
@@ -40,13 +39,17 @@ const KEYCODES = {
40
39
  SPACEBAR: 32
41
40
  };
42
41
  const handleKeyEvent = (keyCode, callback) => e => {
43
- if (e.keyCode === keyCode) {
42
+ if (e instanceof KeyboardEvent && e.keyCode === keyCode) {
44
43
  e.preventDefault();
45
- callback();
44
+ if (callback) {
45
+ callback();
46
+ }
46
47
  }
47
48
  };
48
49
  const withEventHandler = (fn, eventHandler) => e => {
49
- fn(e);
50
+ if (fn) {
51
+ fn(e);
52
+ }
50
53
  if (eventHandler) {
51
54
  eventHandler(e);
52
55
  }
@@ -55,6 +58,7 @@ const withOpenEvents = InputComponent => {
55
58
  class WithOpenEvents extends _react.Component {
56
59
  constructor(props) {
57
60
  super(props);
61
+ _defineProperty(this, "focusCanOpen", void 0);
58
62
  _defineProperty(this, "handleTouchEnd", event => {
59
63
  // preventDefault fixes an issue on Android and iOS in which the popover closes immediately
60
64
  // because a touch event is registered on one of the dates.
@@ -89,6 +93,7 @@ const withOpenEvents = InputComponent => {
89
93
  {
90
94
  className,
91
95
  hasTouchSupport,
96
+ isOpen,
92
97
  onBlur,
93
98
  onClick,
94
99
  onFocus,
@@ -98,7 +103,6 @@ const withOpenEvents = InputComponent => {
98
103
  onTouchEnd
99
104
  } = _this$props,
100
105
  rest = _objectWithoutProperties(_this$props, _excluded);
101
- delete rest.isOpen;
102
106
  const classNames = [getClassName('bpk-input--with-open-events')];
103
107
  if (className) {
104
108
  classNames.push(className);
@@ -124,26 +128,11 @@ const withOpenEvents = InputComponent => {
124
128
  }, eventHandlers), rest));
125
129
  }
126
130
  }
127
- WithOpenEvents.propTypes = {
128
- // Custom props
129
- isOpen: _propTypes.default.bool,
130
- hasTouchSupport: _propTypes.default.bool,
131
- onOpen: _propTypes.default.func,
132
- // Input props
133
- className: _propTypes.default.string,
134
- onClick: _propTypes.default.func,
135
- onFocus: _propTypes.default.func,
136
- onBlur: _propTypes.default.func,
137
- onTouchEnd: _propTypes.default.func,
138
- onKeyDown: _propTypes.default.func,
139
- onKeyUp: _propTypes.default.func
140
- };
141
- WithOpenEvents.defaultProps = {
131
+ _defineProperty(WithOpenEvents, "displayName", void 0);
132
+ _defineProperty(WithOpenEvents, "defaultProps", {
142
133
  // Custom props
143
134
  isOpen: false,
144
- hasTouchSupport: !!(typeof window !== 'undefined' && ('ontouchstart' in window ||
145
- // eslint-disable-next-line no-undef
146
- window.DocumentTouch && document instanceof DocumentTouch)),
135
+ hasTouchSupport: !!(typeof window !== 'undefined' && 'ontouchstart' in window),
147
136
  onOpen: null,
148
137
  // Input props
149
138
  className: null,
@@ -153,7 +142,7 @@ const withOpenEvents = InputComponent => {
153
142
  onTouchEnd: null,
154
143
  onKeyDown: null,
155
144
  onKeyUp: null
156
- };
145
+ });
157
146
  WithOpenEvents.displayName = (0, _bpkReactUtils.wrapDisplayName)(InputComponent, 'withOpenEvents');
158
147
  return WithOpenEvents;
159
148
  };
@@ -3,17 +3,23 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ Object.defineProperty(exports, "BpkModalV2", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _BpkModal.BpkModalV2;
10
+ }
11
+ });
6
12
  exports.default = void 0;
7
13
  Object.defineProperty(exports, "defaultProps", {
8
14
  enumerable: true,
9
15
  get: function () {
10
- return _BpkModal.defaultProps;
16
+ return _BpkModal2.defaultProps;
11
17
  }
12
18
  });
13
19
  Object.defineProperty(exports, "propTypes", {
14
20
  enumerable: true,
15
21
  get: function () {
16
- return _BpkModal.propTypes;
22
+ return _BpkModal2.propTypes;
17
23
  }
18
24
  });
19
25
  Object.defineProperty(exports, "themeAttributes", {
@@ -22,8 +28,9 @@ Object.defineProperty(exports, "themeAttributes", {
22
28
  return _themeAttributes.default;
23
29
  }
24
30
  });
31
+ var _BpkModal = require("./src/BpkModalV2/BpkModal");
25
32
  var _themeAttributes = _interopRequireDefault(require("./src/themeAttributes"));
26
- var _BpkModal = _interopRequireWildcard(require("./src/BpkModal"));
33
+ var _BpkModal2 = _interopRequireWildcard(require("./src/BpkModal"));
27
34
  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); }
28
35
  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; }
29
36
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -44,5 +51,5 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
44
51
  * See the License for the specific language governing permissions and
45
52
  * limitations under the License.
46
53
  */
47
- var _default = _BpkModal.default;
54
+ var _default = _BpkModal2.default;
48
55
  exports.default = _default;
@@ -0,0 +1,18 @@
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
+ @keyframes bpk-keyframe-spin{100%{transform:rotate(1turn)}}.bpk-modal-wrapper.bpk-modal-polyfill .bpk-modal-backdrop{position:fixed;top:0;right:0;bottom:0;left:0;z-index:0;background-color:rgba(0,0,0,0.7);inset:0;inset-block-end:0;inset-inline:0;inset-inline-end:0}.bpk-modal-wrapper.bpk-modal-polyfill .bpk-modal{position:fixed;display:block;z-index:1}.bpk-modal-wrapper.bpk-modal-polyfill .bpk-modal:not([data-open='true']),.bpk-modal-wrapper.bpk-modal-polyfill .bpk-modal-backdrop:not([data-open='true']){display:none}.bpk-modal{top:0;right:0;left:0;width:100%;max-width:100%;height:100%;max-height:100%;margin:0 auto;padding:0;border:none;background:#eff1f2;overflow-y:scroll;inset-block-start:0;inset-inline:0;inset-inline-end:0;scrollbar-width:none;box-shadow:0px 12px 50px 0px rgba(37,32,31,0.25)}@media (min-width: 32.0625rem){.bpk-modal{width:32rem;max-width:none;height:fit-content;max-height:90%;top:50%;transform:translateY(-50%);border-radius:.75rem;inset-block-start:50%}.bpk-modal--full-screen-desktop{width:100%;height:100%;max-height:100%;border-radius:0}.bpk-modal--wide{width:64rem}}.bpk-modal--no-full-screen-mobile{width:90%;max-width:none;height:fit-content;max-height:90%;top:50%;transform:translateY(-50%);border-radius:.75rem;inset-block-start:50%}@media (min-width: 32.0625rem){.bpk-modal--no-full-screen-mobile{width:32rem;max-width:none}}.bpk-modal::backdrop{position:fixed;background-color:rgba(0,0,0,0.7);inset:0;inset-block-end:0;inset-inline:0;inset-inline-end:0}.bpk-modal::-webkit-scrollbar{display:none}.bpk-modal__header-title{padding:1rem;border-block-end:solid 0.0625rem #C2C9CD;display:flex;min-height:1.5rem;flex-wrap:nowrap;justify-content:flex-end;align-items:center}.bpk-modal__header-title-container{display:flex;width:100%;justify-content:flex-start}.bpk-modal__title{padding-inline-end:1rem;font-size:1rem;line-height:1.5rem;font-weight:700}.bpk-modal__button-container{padding-block-start:1rem;padding-inline-end:1rem;display:flex;min-height:1.5rem;flex-wrap:nowrap;justify-content:flex-end;align-items:center}.bpk-modal__container{min-height:100%;padding:1rem}.bpk-modal__container--padded{padding:0}.bpk-modal__container--full-screen-desktop{height:100%}
@@ -0,0 +1,35 @@
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
+ /// <reference types="react" />
20
+ import type { ReactNode } from 'react';
21
+
22
+ export type Props = {
23
+ id: string | undefined;
24
+ ariaLabelledby: string;
25
+ children: ReactNode;
26
+ closeLabel: string;
27
+ fullScreenOnDesktop?: boolean;
28
+ isOpen: boolean;
29
+ noFullScreenOnMobile?: boolean;
30
+ onClose: () => void | null;
31
+ padded?: boolean;
32
+ title?: string | null;
33
+ wide?: boolean;
34
+ };
35
+ export declare const BpkModalV2: (props: Props) => JSX.Element | null;
@@ -0,0 +1,133 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.BpkModalV2 = void 0;
7
+ var _react = require("react");
8
+ var _bpkComponentCloseButton = _interopRequireDefault(require("../../../bpk-component-close-button"));
9
+ var _bpkComponentText = _interopRequireWildcard(require("../../../bpk-component-text"));
10
+ var _bpkReactUtils = require("../../../bpk-react-utils");
11
+ var _BpKModalModule = _interopRequireDefault(require("./BpKModal.module.css"));
12
+ var _jsxRuntime = require("react/jsx-runtime");
13
+ 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); }
14
+ 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; }
15
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
+ /*
17
+ * Backpack - Skyscanner's Design System
18
+ *
19
+ * Copyright 2016 Skyscanner Ltd
20
+ *
21
+ * Licensed under the Apache License, Version 2.0 (the "License");
22
+ * you may not use this file except in compliance with the License.
23
+ * You may obtain a copy of the License at
24
+ *
25
+ * http://www.apache.org/licenses/LICENSE-2.0
26
+ *
27
+ * Unless required by applicable law or agreed to in writing, software
28
+ * distributed under the License is distributed on an "AS IS" BASIS,
29
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
30
+ * See the License for the specific language governing permissions and
31
+ * limitations under the License.
32
+ */
33
+
34
+ // @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
35
+
36
+ // @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
37
+
38
+ const getClassName = (0, _bpkReactUtils.cssModules)(_BpKModalModule.default);
39
+ const Heading = (0, _bpkReactUtils.withDefaultProps)(_bpkComponentText.default, {
40
+ textStyle: _bpkComponentText.TEXT_STYLES.label1,
41
+ tagName: 'h2',
42
+ className: getClassName('bpk-modal__title')
43
+ });
44
+ // TODO: this check if the browser support the HTML dialog element. We can remove it once we drop support as a business for Safari 14
45
+ const dialogSupported = typeof HTMLDialogElement === 'function';
46
+ const setPageProperties = ({
47
+ isDialogOpen
48
+ }) => {
49
+ document.body.style.overflowY = isDialogOpen ? 'hidden' : 'visible';
50
+ if (!dialogSupported) {
51
+ document.body.style.position = isDialogOpen ? 'fixed' : 'relative';
52
+ document.body.style.width = isDialogOpen ? '100%' : 'auto';
53
+ }
54
+ };
55
+ const BpkModalV2 = props => {
56
+ const {
57
+ ariaLabelledby,
58
+ children,
59
+ closeLabel,
60
+ fullScreenOnDesktop,
61
+ id,
62
+ isOpen,
63
+ noFullScreenOnMobile,
64
+ onClose,
65
+ padded,
66
+ title,
67
+ wide
68
+ } = props;
69
+ const ref = (0, _react.useRef)(null);
70
+ (0, _react.useEffect)(() => {
71
+ if (isOpen) {
72
+ ref.current?.showModal?.();
73
+ const dialog = document.getElementById(`${id}`);
74
+ if (dialog) {
75
+ dialog.addEventListener('click', event => {
76
+ const {
77
+ target
78
+ } = event;
79
+ if (target instanceof HTMLElement && target.id === `${id}`) {
80
+ ref.current?.close?.();
81
+ }
82
+ });
83
+ }
84
+ } else {
85
+ ref.current?.close?.();
86
+ }
87
+ setPageProperties({
88
+ isDialogOpen: isOpen
89
+ });
90
+ return () => setPageProperties({
91
+ isDialogOpen: false
92
+ });
93
+ }, [id, isOpen]);
94
+ const classNames = getClassName('bpk-modal', fullScreenOnDesktop && 'bpk-modal--full-screen-desktop', noFullScreenOnMobile && 'bpk-modal--no-full-screen-mobile', wide && 'bpk-modal--wide');
95
+ const contentClassNames = getClassName('bpk-modal__container', fullScreenOnDesktop && 'bpk-modal__container--full-screen-desktop', padded && 'bpk-modal__container--padded');
96
+ const closeButton = /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
97
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_bpkComponentCloseButton.default, {
98
+ label: closeLabel,
99
+ onClick: onClose
100
+ })
101
+ });
102
+ return isOpen ? /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
103
+ className: getClassName('bpk-modal-wrapper', dialogSupported ? '' : 'bpk-modal-polyfill'),
104
+ children: [!dialogSupported && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
105
+ id: `${id}-polyfill`,
106
+ className: getClassName('bpk-modal-backdrop'),
107
+ "data-open": isOpen
108
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("dialog", {
109
+ id: id,
110
+ className: classNames,
111
+ onClose: onClose,
112
+ "aria-labelledby": ariaLabelledby,
113
+ "data-open": isOpen,
114
+ ref: ref,
115
+ children: [title ? /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
116
+ className: getClassName('bpk-modal__header-title'),
117
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
118
+ className: getClassName('bpk-modal__header-title-container'),
119
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Heading, {
120
+ children: title
121
+ })
122
+ }), closeButton]
123
+ }) : /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
124
+ className: getClassName('bpk-modal__button-container'),
125
+ children: closeButton
126
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
127
+ className: contentClassNames,
128
+ children: children
129
+ })]
130
+ })]
131
+ }) : null;
132
+ };
133
+ exports.BpkModalV2 = BpkModalV2;
@@ -0,0 +1,23 @@
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 BpkRtlToggle from './src/BpkRtlToggle';
20
+ import updateOnDirectionChange from './src/updateOnDirectionChange';
21
+
22
+ export default BpkRtlToggle;
23
+ export { updateOnDirectionChange };
@@ -0,0 +1,41 @@
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 { Component } from 'react';
20
+
21
+ type State = {
22
+ direction: string;
23
+ };
24
+ type Props = {
25
+ className?: string | null;
26
+ };
27
+ type InteractionEvents = KeyboardEvent | MouseEvent | TouchEvent;
28
+ declare class BpkRtlToggle extends Component<Props, State> {
29
+ constructor(props: Props);
30
+
31
+ componentDidMount(): void;
32
+
33
+ componentWillUnmount(): void;
34
+
35
+ handleKeyDown: (e: KeyboardEvent) => void;
36
+
37
+ toggleRtl: (e: InteractionEvents) => void;
38
+
39
+ render(): JSX.Element;
40
+ }
41
+ export default BpkRtlToggle;
@@ -5,11 +5,9 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var _react = require("react");
8
- var _propTypes = _interopRequireDefault(require("prop-types"));
9
8
  var _bpkComponentLink = require("../../bpk-component-link");
10
9
  var _utils = require("./utils");
11
10
  var _jsxRuntime = require("react/jsx-runtime");
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
11
  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
12
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
15
13
  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); } /*
@@ -28,12 +26,17 @@ function _toPrimitive(input, hint) { if (typeof input !== "object" || input ===
28
26
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
29
27
  * See the License for the specific language governing permissions and
30
28
  * limitations under the License.
31
- */
32
- const getDirection = () => (0, _utils.getHtmlElement)().dir || _utils.DIRECTIONS.LTR;
29
+ */ // @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
30
+ const getDirection = () => {
31
+ const htmlElement = (0, _utils.getHtmlElement)();
32
+ return htmlElement instanceof HTMLElement ? htmlElement.dir : _utils.DIRECTIONS.LTR;
33
+ };
33
34
  const setDirection = direction => {
34
35
  const htmlElement = (0, _utils.getHtmlElement)();
35
- htmlElement.dir = direction;
36
- htmlElement.dispatchEvent(new Event(_utils.DIRECTION_CHANGE_EVENT));
36
+ if (htmlElement instanceof HTMLElement) {
37
+ htmlElement.dir = direction;
38
+ htmlElement.dispatchEvent(new Event(_utils.DIRECTION_CHANGE_EVENT));
39
+ }
37
40
  };
38
41
  class BpkRtlToggle extends _react.Component {
39
42
  constructor(props) {
@@ -74,11 +77,5 @@ class BpkRtlToggle extends _react.Component {
74
77
  });
75
78
  }
76
79
  }
77
- BpkRtlToggle.propTypes = {
78
- className: _propTypes.default.string
79
- };
80
- BpkRtlToggle.defaultProps = {
81
- className: null
82
- };
83
80
  var _default = BpkRtlToggle;
84
81
  exports.default = _default;
@@ -0,0 +1,151 @@
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 } from 'react';
20
+
21
+ declare const updateOnDirectionChange: (
22
+ EnhancedComponent: ComponentType<any> | string,
23
+ ) => {
24
+ new (props: {} | Readonly<{}>): {
25
+ componentDidMount(): void;
26
+ componentWillUnmount(): void;
27
+ onDirectionChange: () => void;
28
+ render(): JSX.Element;
29
+ context: any;
30
+ setState<K extends never>(
31
+ state:
32
+ | {}
33
+ | ((
34
+ prevState: Readonly<{}>,
35
+ props: Readonly<{}>,
36
+ ) => {} | Pick<{}, K> | null)
37
+ | Pick<{}, K>
38
+ | null,
39
+ callback?: (() => void) | undefined,
40
+ ): void;
41
+ forceUpdate(callback?: (() => void) | undefined): void;
42
+ readonly props: Readonly<{}> &
43
+ Readonly<{
44
+ children?: import('react').ReactNode;
45
+ }>;
46
+ state: Readonly<{}>;
47
+ refs: {
48
+ [key: string]: import('react').ReactInstance;
49
+ };
50
+ shouldComponentUpdate?(
51
+ nextProps: Readonly<{}>,
52
+ nextState: Readonly<{}>,
53
+ nextContext: any,
54
+ ): boolean;
55
+ componentDidCatch?(
56
+ error: Error,
57
+ errorInfo: import('react').ErrorInfo,
58
+ ): void;
59
+ getSnapshotBeforeUpdate?(
60
+ prevProps: Readonly<{}>,
61
+ prevState: Readonly<{}>,
62
+ ): any;
63
+ componentDidUpdate?(
64
+ prevProps: Readonly<{}>,
65
+ prevState: Readonly<{}>,
66
+ snapshot?: any,
67
+ ): void;
68
+ componentWillMount?(): void;
69
+ UNSAFE_componentWillMount?(): void;
70
+ componentWillReceiveProps?(nextProps: Readonly<{}>, nextContext: any): void;
71
+ UNSAFE_componentWillReceiveProps?(
72
+ nextProps: Readonly<{}>,
73
+ nextContext: any,
74
+ ): void;
75
+ componentWillUpdate?(
76
+ nextProps: Readonly<{}>,
77
+ nextState: Readonly<{}>,
78
+ nextContext: any,
79
+ ): void;
80
+ UNSAFE_componentWillUpdate?(
81
+ nextProps: Readonly<{}>,
82
+ nextState: Readonly<{}>,
83
+ nextContext: any,
84
+ ): void;
85
+ };
86
+ new (props: {}, context: any): {
87
+ componentDidMount(): void;
88
+ componentWillUnmount(): void;
89
+ onDirectionChange: () => void;
90
+ render(): JSX.Element;
91
+ context: any;
92
+ setState<K extends never>(
93
+ state:
94
+ | {}
95
+ | ((
96
+ prevState: Readonly<{}>,
97
+ props: Readonly<{}>,
98
+ ) => {} | Pick<{}, K> | null)
99
+ | Pick<{}, K>
100
+ | null,
101
+ callback?: (() => void) | undefined,
102
+ ): void;
103
+ forceUpdate(callback?: (() => void) | undefined): void;
104
+ readonly props: Readonly<{}> &
105
+ Readonly<{
106
+ children?: import('react').ReactNode;
107
+ }>;
108
+ state: Readonly<{}>;
109
+ refs: {
110
+ [key: string]: import('react').ReactInstance;
111
+ };
112
+ shouldComponentUpdate?(
113
+ nextProps: Readonly<{}>,
114
+ nextState: Readonly<{}>,
115
+ nextContext: any,
116
+ ): boolean;
117
+ componentDidCatch?(
118
+ error: Error,
119
+ errorInfo: import('react').ErrorInfo,
120
+ ): void;
121
+ getSnapshotBeforeUpdate?(
122
+ prevProps: Readonly<{}>,
123
+ prevState: Readonly<{}>,
124
+ ): any;
125
+ componentDidUpdate?(
126
+ prevProps: Readonly<{}>,
127
+ prevState: Readonly<{}>,
128
+ snapshot?: any,
129
+ ): void;
130
+ componentWillMount?(): void;
131
+ UNSAFE_componentWillMount?(): void;
132
+ componentWillReceiveProps?(nextProps: Readonly<{}>, nextContext: any): void;
133
+ UNSAFE_componentWillReceiveProps?(
134
+ nextProps: Readonly<{}>,
135
+ nextContext: any,
136
+ ): void;
137
+ componentWillUpdate?(
138
+ nextProps: Readonly<{}>,
139
+ nextState: Readonly<{}>,
140
+ nextContext: any,
141
+ ): void;
142
+ UNSAFE_componentWillUpdate?(
143
+ nextProps: Readonly<{}>,
144
+ nextState: Readonly<{}>,
145
+ nextContext: any,
146
+ ): void;
147
+ };
148
+ displayName: string;
149
+ contextType?: import('react').Context<any> | undefined;
150
+ };
151
+ export default updateOnDirectionChange;
@@ -38,15 +38,22 @@ const updateOnDirectionChange = EnhancedComponent => {
38
38
  });
39
39
  }
40
40
  componentDidMount() {
41
- (0, _utils.getHtmlElement)().addEventListener(_utils.DIRECTION_CHANGE_EVENT, this.onDirectionChange, false);
41
+ const htmlElement = (0, _utils.getHtmlElement)();
42
+ if (htmlElement instanceof HTMLElement) {
43
+ htmlElement.addEventListener(_utils.DIRECTION_CHANGE_EVENT, this.onDirectionChange, false);
44
+ }
42
45
  }
43
46
  componentWillUnmount() {
44
- (0, _utils.getHtmlElement)().removeEventListener(_utils.DIRECTION_CHANGE_EVENT, this.onDirectionChange, false);
47
+ const htmlElement = (0, _utils.getHtmlElement)();
48
+ if (htmlElement instanceof HTMLElement) {
49
+ htmlElement.removeEventListener(_utils.DIRECTION_CHANGE_EVENT, this.onDirectionChange, false);
50
+ }
45
51
  }
46
52
  render() {
47
53
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(EnhancedComponent, _objectSpread({}, this.props));
48
54
  }
49
55
  }
56
+ _defineProperty(UpdateOnDirectionChange, "displayName", void 0);
50
57
  UpdateOnDirectionChange.displayName = (0, _bpkReactUtils.wrapDisplayName)(EnhancedComponent, 'updateOnDirectionChange');
51
58
  return UpdateOnDirectionChange;
52
59
  };
@@ -0,0 +1,25 @@
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
+ declare const DIRECTIONS: {
20
+ readonly LTR: 'ltr';
21
+ readonly RTL: 'rtl';
22
+ };
23
+ declare const DIRECTION_CHANGE_EVENT = 'bpkchangedirection';
24
+ declare const getHtmlElement: () => HTMLElement | null | {};
25
+ export { DIRECTIONS, DIRECTION_CHANGE_EVENT, getHtmlElement };