@skyscanner/backpack-web 23.3.0 → 24.1.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 (37) hide show
  1. package/bpk-component-calendar/src/BpkCalendarContainer.d.ts +74 -39
  2. package/bpk-component-calendar/src/BpkCalendarContainer.js +4 -4
  3. package/bpk-component-calendar/src/composeCalendar.d.ts +6 -3
  4. package/bpk-component-calendar/src/composeCalendar.js +3 -3
  5. package/bpk-component-chip/src/BpkSelectableChip.js +0 -1
  6. package/bpk-component-dialog/src/BpkDialog.d.ts +1 -12
  7. package/bpk-component-dialog/src/BpkDialog.js +1 -1
  8. package/bpk-component-dialog/src/BpkDialogInner.d.ts +256 -2
  9. package/bpk-component-dialog/src/BpkDialogInner.js +0 -2
  10. package/bpk-component-dialog/src/common-types.d.ts +20 -21
  11. package/bpk-component-graphic-promotion/src/BpkGraphicPromo.js +0 -2
  12. package/bpk-component-modal/index.d.ts +26 -0
  13. package/bpk-component-modal/index.js +5 -5
  14. package/bpk-component-modal/src/BpkModal.d.ts +32 -0
  15. package/bpk-component-modal/src/BpkModal.js +24 -44
  16. package/bpk-component-modal/src/BpkModalInner.d.ts +39 -0
  17. package/bpk-component-modal/src/BpkModalInner.js +67 -84
  18. package/bpk-component-modal/src/BpkModalV2/BpKModal.module.css +1 -1
  19. package/bpk-component-modal/src/BpkModalV2/BpkModal.d.ts +1 -0
  20. package/bpk-component-modal/src/BpkModalV2/BpkModal.js +35 -19
  21. package/bpk-component-modal/src/legacy-prop-types.js +86 -0
  22. package/bpk-component-modal/src/themeAttributes.js +1 -0
  23. package/bpk-component-text/index.d.ts +21 -0
  24. package/bpk-component-text/index.js +0 -6
  25. package/bpk-component-text/src/BpkText.d.ts +60 -0
  26. package/bpk-component-text/src/BpkText.js +16 -56
  27. package/bpk-component-text/src/BpkText.module.css +1 -1
  28. package/bpk-component-tooltip/index.d.ts +24 -0
  29. package/bpk-component-tooltip/src/BpkTooltip.d.ts +29 -0
  30. package/bpk-component-tooltip/src/BpkTooltip.js +9 -26
  31. package/bpk-component-tooltip/src/BpkTooltipPortal.d.ts +60 -0
  32. package/bpk-component-tooltip/src/BpkTooltipPortal.js +13 -21
  33. package/bpk-component-tooltip/src/constants.d.ts +31 -0
  34. package/bpk-component-tooltip/src/constants.js +3 -1
  35. package/bpk-scrim-utils/index.d.ts +283 -0
  36. package/bpk-scrim-utils/src/withScrim.d.ts +2 -1
  37. package/package.json +1 -1
@@ -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
+ import { BpkModalV2 } from './src/BpkModalV2/BpkModal';
20
+ import themeAttributes from './src/themeAttributes';
21
+ import BpkModal from './src/BpkModal';
22
+ import type { Props } from './src/BpkModal';
23
+ import { propTypes, defaultProps } from './src/legacy-prop-types';
24
+ export type BpkModalProps = Props;
25
+ export default BpkModal;
26
+ export { propTypes, defaultProps, themeAttributes, BpkModalV2 };
@@ -13,13 +13,13 @@ exports.default = void 0;
13
13
  Object.defineProperty(exports, "defaultProps", {
14
14
  enumerable: true,
15
15
  get: function () {
16
- return _BpkModal2.defaultProps;
16
+ return _legacyPropTypes.defaultProps;
17
17
  }
18
18
  });
19
19
  Object.defineProperty(exports, "propTypes", {
20
20
  enumerable: true,
21
21
  get: function () {
22
- return _BpkModal2.propTypes;
22
+ return _legacyPropTypes.propTypes;
23
23
  }
24
24
  });
25
25
  Object.defineProperty(exports, "themeAttributes", {
@@ -30,9 +30,8 @@ Object.defineProperty(exports, "themeAttributes", {
30
30
  });
31
31
  var _BpkModal = require("./src/BpkModalV2/BpkModal");
32
32
  var _themeAttributes = _interopRequireDefault(require("./src/themeAttributes"));
33
- var _BpkModal2 = _interopRequireWildcard(require("./src/BpkModal"));
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); }
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; }
33
+ var _BpkModal2 = _interopRequireDefault(require("./src/BpkModal"));
34
+ var _legacyPropTypes = require("./src/legacy-prop-types");
36
35
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
37
36
  /*
38
37
  * Backpack - Skyscanner's Design System
@@ -51,5 +50,6 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
51
50
  * See the License for the specific language governing permissions and
52
51
  * limitations under the License.
53
52
  */
53
+ // @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
54
54
  var _default = _BpkModal2.default;
55
55
  exports.default = _default;
@@ -0,0 +1,32 @@
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 { Props as ModalDialogProps } from './BpkModalInner';
21
+ export type Props = ModalDialogProps & {
22
+ isOpen: boolean;
23
+ closeOnScrimClick?: boolean;
24
+ closeOnEscPressed?: boolean;
25
+ renderTarget?: null | HTMLElement | (() => null | HTMLElement);
26
+ onClose: (arg0: TouchEvent | MouseEvent | KeyboardEvent, arg1: {
27
+ source: 'ESCAPE' | 'DOCUMENT_CLICK';
28
+ }) => void;
29
+ getApplicationElement: () => HTMLElement | null;
30
+ };
31
+ declare const BpkModal: ({ title, onClose, className, contentClassName, closeLabel, closeText, wide, showHeader, fullScreenOnMobile, fullScreen, padded, accessoryView, renderTarget, isIphone, closeOnScrimClick, closeOnEscPressed, isOpen, ...rest }: Props) => JSX.Element;
32
+ export default BpkModal;
@@ -3,14 +3,13 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.propTypes = exports.defaultProps = exports.default = void 0;
7
- var _propTypes = _interopRequireDefault(require("prop-types"));
6
+ exports.default = void 0;
8
7
  var _bpkScrimUtils = require("../../bpk-scrim-utils");
9
8
  var _bpkReactUtils = require("../../bpk-react-utils");
10
9
  var _BpkModalModule = _interopRequireDefault(require("./BpkModal.module.css"));
11
- var _BpkModalInner = _interopRequireWildcard(require("./BpkModalInner"));
10
+ var _BpkModalInner = _interopRequireDefault(require("./BpkModalInner"));
12
11
  var _jsxRuntime = require("react/jsx-runtime");
13
- const _excluded = ["closeOnEscPressed", "closeOnScrimClick", "fullScreen", "fullScreenOnMobile", "isIphone", "isOpen", "onClose", "renderTarget"];
12
+ const _excluded = ["title", "onClose", "className", "contentClassName", "closeLabel", "closeText", "wide", "showHeader", "fullScreenOnMobile", "fullScreen", "padded", "accessoryView", "renderTarget", "isIphone", "closeOnScrimClick", "closeOnEscPressed", "isOpen"];
14
13
  /*
15
14
  * Backpack - Skyscanner's Design System
16
15
  *
@@ -28,8 +27,6 @@ const _excluded = ["closeOnEscPressed", "closeOnScrimClick", "fullScreen", "full
28
27
  * See the License for the specific language governing permissions and
29
28
  * limitations under the License.
30
29
  */
31
- 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); }
32
- 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; }
33
30
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
34
31
  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; }
35
32
  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,21 +37,27 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
40
37
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
41
38
  const getClassName = (0, _bpkReactUtils.cssModules)(_BpkModalModule.default);
42
39
  const ScrimBpkModalInner = (0, _bpkScrimUtils.withScrim)(_BpkModalInner.default);
43
-
44
- // Please remove this type when `withScrim` is flow-typed
45
-
46
- const BpkModal = props => {
47
- const {
48
- closeOnEscPressed,
49
- closeOnScrimClick,
50
- fullScreen,
51
- fullScreenOnMobile,
52
- isIphone,
53
- isOpen,
54
- onClose,
55
- renderTarget
56
- } = props,
57
- rest = _objectWithoutProperties(props, _excluded);
40
+ const BpkModal = _ref => {
41
+ let {
42
+ title = null,
43
+ onClose = () => null,
44
+ className = null,
45
+ contentClassName = null,
46
+ closeLabel = '',
47
+ closeText = null,
48
+ wide = false,
49
+ showHeader = true,
50
+ fullScreenOnMobile = true,
51
+ fullScreen = false,
52
+ padded = true,
53
+ accessoryView = null,
54
+ renderTarget = null,
55
+ isIphone = (0, _bpkReactUtils.isDeviceIphone)(),
56
+ closeOnScrimClick = true,
57
+ closeOnEscPressed = true,
58
+ isOpen
59
+ } = _ref,
60
+ rest = _objectWithoutProperties(_ref, _excluded);
58
61
  const containerClass = [getClassName('bpk-modal__container')];
59
62
  if (fullScreen || isIphone) {
60
63
  containerClass.push(getClassName('bpk-modal__container--full-screen'));
@@ -76,28 +79,5 @@ const BpkModal = props => {
76
79
  }, rest))
77
80
  });
78
81
  };
79
- const {
80
- dialogRef
81
- } = _BpkModalInner.propTypes,
82
- newModalDialogPropTypes = _objectWithoutProperties(_BpkModalInner.propTypes, ["dialogRef"]);
83
- const propTypes = _objectSpread(_objectSpread({}, newModalDialogPropTypes), {}, {
84
- onClose: _propTypes.default.func,
85
- isIphone: _propTypes.default.bool,
86
- isOpen: _propTypes.default.bool.isRequired,
87
- renderTarget: _propTypes.default.func,
88
- closeOnScrimClick: _propTypes.default.bool,
89
- closeOnEscPressed: _propTypes.default.bool
90
- });
91
- exports.propTypes = propTypes;
92
- const defaultProps = _objectSpread(_objectSpread({}, _BpkModalInner.defaultProps), {}, {
93
- onClose: () => null,
94
- renderTarget: null,
95
- isIphone: (0, _bpkReactUtils.isDeviceIphone)(),
96
- closeOnScrimClick: true,
97
- closeOnEscPressed: true
98
- });
99
- exports.defaultProps = defaultProps;
100
- BpkModal.propTypes = _objectSpread({}, propTypes);
101
- BpkModal.defaultProps = _objectSpread({}, defaultProps);
102
82
  var _default = BpkModal;
103
83
  exports.default = _default;
@@ -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
+ export type Props = {
21
+ id: string;
22
+ children: ReactNode;
23
+ wide?: boolean;
24
+ isIphone: boolean;
25
+ showHeader?: boolean;
26
+ fullScreenOnMobile?: boolean;
27
+ fullScreen?: boolean;
28
+ padded?: boolean;
29
+ dialogRef: (ref: HTMLElement | null | undefined) => void;
30
+ onClose?: () => void;
31
+ className?: string | null;
32
+ contentClassName?: string | null;
33
+ title?: string | null;
34
+ closeLabel?: string;
35
+ closeText?: string | null;
36
+ accessoryView?: ReactNode;
37
+ };
38
+ declare const BpkModalInner: ({ isIphone, id, dialogRef, children, title, onClose, className, contentClassName, closeLabel, closeText, wide, showHeader, fullScreenOnMobile, fullScreen, padded, accessoryView, ...rest }: Props) => JSX.Element;
39
+ export default BpkModalInner;
@@ -3,76 +3,95 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.propTypes = exports.defaultProps = exports.default = void 0;
7
- var _propTypes = _interopRequireDefault(require("prop-types"));
6
+ exports.default = void 0;
8
7
  var _bpkComponentLink = require("../../bpk-component-link");
9
8
  var _bpkComponentCloseButton = _interopRequireDefault(require("../../bpk-component-close-button"));
10
9
  var _bpkComponentNavigationBar = _interopRequireDefault(require("../../bpk-component-navigation-bar"));
11
10
  var _bpkReactUtils = require("../../bpk-react-utils");
12
11
  var _BpkModalInnerModule = _interopRequireDefault(require("./BpkModalInner.module.css"));
13
- var _customPropTypes = require("./customPropTypes");
14
12
  var _jsxRuntime = require("react/jsx-runtime");
13
+ const _excluded = ["isIphone", "id", "dialogRef", "children", "title", "onClose", "className", "contentClassName", "closeLabel", "closeText", "wide", "showHeader", "fullScreenOnMobile", "fullScreen", "padded", "accessoryView"];
14
+ /*
15
+ * Backpack - Skyscanner's Design System
16
+ *
17
+ * Copyright 2016 Skyscanner Ltd
18
+ *
19
+ * Licensed under the Apache License, Version 2.0 (the "License");
20
+ * you may not use this file except in compliance with the License.
21
+ * You may obtain a copy of the License at
22
+ *
23
+ * http://www.apache.org/licenses/LICENSE-2.0
24
+ *
25
+ * Unless required by applicable law or agreed to in writing, software
26
+ * distributed under the License is distributed on an "AS IS" BASIS,
27
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
28
+ * See the License for the specific language governing permissions and
29
+ * limitations under the License.
30
+ */
31
+ // @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
32
+ // @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
33
+ // @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
15
34
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
- 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; }
17
- 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; }
18
- 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; }
19
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
20
- 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); } /*
21
- * Backpack - Skyscanner's Design System
22
- *
23
- * Copyright 2016 Skyscanner Ltd
24
- *
25
- * Licensed under the Apache License, Version 2.0 (the "License");
26
- * you may not use this file except in compliance with the License.
27
- * You may obtain a copy of the License at
28
- *
29
- * http://www.apache.org/licenses/LICENSE-2.0
30
- *
31
- * Unless required by applicable law or agreed to in writing, software
32
- * distributed under the License is distributed on an "AS IS" BASIS,
33
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
34
- * See the License for the specific language governing permissions and
35
- * limitations under the License.
36
- */
35
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
36
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
37
37
  const getClassName = (0, _bpkReactUtils.cssModules)(_BpkModalInnerModule.default);
38
- const BpkModalInner = props => {
38
+ const BpkModalInner = _ref => {
39
+ let {
40
+ isIphone,
41
+ id,
42
+ dialogRef,
43
+ children,
44
+ title = null,
45
+ onClose = () => null,
46
+ className = null,
47
+ contentClassName = null,
48
+ closeLabel = '',
49
+ closeText = null,
50
+ wide = false,
51
+ showHeader = true,
52
+ fullScreenOnMobile = true,
53
+ fullScreen = false,
54
+ padded = true,
55
+ accessoryView = null
56
+ } = _ref,
57
+ rest = _objectWithoutProperties(_ref, _excluded);
39
58
  const classNames = [getClassName('bpk-modal')];
40
59
  const contentClassNames = [getClassName('bpk-modal__content')];
41
60
  const navigationStyles = [getClassName('bpk-modal__navigation')];
42
- if (props.wide) {
61
+ if (wide) {
43
62
  classNames.push(getClassName('bpk-modal--wide'));
44
63
  }
45
- if (props.className) {
46
- classNames.push(props.className);
64
+ if (className) {
65
+ classNames.push(className);
47
66
  }
48
- if (props.fullScreen || props.isIphone) {
67
+ if (fullScreen || isIphone) {
49
68
  classNames.push(getClassName('bpk-modal--full-screen'));
50
- } else if (props.fullScreenOnMobile) {
69
+ } else if (fullScreenOnMobile) {
51
70
  classNames.push(getClassName('bpk-modal--full-screen-mobile'));
52
71
  }
53
- if (props.padded) {
72
+ if (padded) {
54
73
  contentClassNames.push(getClassName('bpk-modal__content--padded'));
55
74
  }
56
- if (props.contentClassName) {
57
- contentClassNames.push(props.contentClassName);
75
+ if (contentClassName) {
76
+ contentClassNames.push(contentClassName);
58
77
  }
59
- const headingId = `bpk-modal-heading-${props.id}`;
60
- const accessoryViewFinal = props.accessoryView ? /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
78
+ const headingId = `bpk-modal-heading-${id}`;
79
+ const accessoryViewFinal = accessoryView ? /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
61
80
  className: getClassName('bpk-modal__accessory-view'),
62
- children: props.accessoryView
81
+ children: accessoryView
63
82
  }) : null;
64
83
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_bpkReactUtils.TransitionInitialMount, {
65
84
  appearClassName: getClassName('bpk-modal--appear'),
66
85
  appearActiveClassName: getClassName('bpk-modal--appear-active'),
67
86
  transitionTimeout: 300,
68
87
  children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("section", {
69
- id: props.id,
70
- tabIndex: "-1",
88
+ id: id,
89
+ tabIndex: -1,
71
90
  role: "dialog",
72
- "aria-labelledby": props.showHeader ? headingId : null,
91
+ "aria-labelledby": showHeader ? headingId : undefined,
73
92
  className: classNames.join(' '),
74
- ref: props.dialogRef,
75
- children: [props.showHeader && /*#__PURE__*/(0, _jsxRuntime.jsx)("header", {
93
+ ref: dialogRef,
94
+ children: [showHeader && /*#__PURE__*/(0, _jsxRuntime.jsx)("header", {
76
95
  className: getClassName('bpk-modal__header'),
77
96
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_bpkComponentNavigationBar.default, {
78
97
  id: headingId,
@@ -80,61 +99,25 @@ const BpkModalInner = props => {
80
99
  title: /*#__PURE__*/(0, _jsxRuntime.jsx)("h2", {
81
100
  id: headingId,
82
101
  className: getClassName('bpk-modal__heading'),
83
- children: props.title
102
+ children: title
84
103
  }),
85
104
  leadingButton: accessoryViewFinal,
86
- trailingButton: props.closeText ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_bpkComponentLink.BpkButtonLink, {
105
+ trailingButton: closeText ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_bpkComponentLink.BpkButtonLink, {
87
106
  className: getClassName('bpk-modal__close-button'),
88
- onClick: props.onClose,
89
- children: props.closeText
107
+ onClick: onClose,
108
+ children: closeText
90
109
  }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_bpkComponentCloseButton.default, {
91
110
  className: getClassName('bpk-modal__close-button'),
92
- label: props.closeLabel,
93
- onClick: props.onClose
111
+ label: closeLabel,
112
+ onClick: onClose
94
113
  })
95
114
  })
96
115
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
97
116
  className: contentClassNames.join(' '),
98
- children: props.children
117
+ children: children
99
118
  })]
100
119
  })
101
120
  });
102
121
  };
103
- const propTypes = {
104
- id: _propTypes.default.string.isRequired,
105
- children: _propTypes.default.node.isRequired,
106
- isIphone: _propTypes.default.bool.isRequired,
107
- dialogRef: _propTypes.default.func.isRequired,
108
- title: _customPropTypes.titlePropType,
109
- onClose: _customPropTypes.onClosePropType,
110
- className: _propTypes.default.string,
111
- contentClassName: _propTypes.default.string,
112
- closeLabel: _propTypes.default.string,
113
- closeText: _propTypes.default.string,
114
- wide: _propTypes.default.bool,
115
- showHeader: _propTypes.default.bool,
116
- fullScreenOnMobile: _propTypes.default.bool,
117
- fullScreen: _propTypes.default.bool,
118
- padded: _propTypes.default.bool,
119
- accesoryView: _propTypes.default.func
120
- };
121
- exports.propTypes = propTypes;
122
- const defaultProps = {
123
- title: null,
124
- onClose: () => null,
125
- className: null,
126
- contentClassName: null,
127
- closeLabel: '',
128
- closeText: null,
129
- wide: false,
130
- showHeader: true,
131
- fullScreenOnMobile: true,
132
- fullScreen: false,
133
- padded: true,
134
- accessoryView: null
135
- };
136
- exports.defaultProps = defaultProps;
137
- BpkModalInner.propTypes = _objectSpread({}, propTypes);
138
- BpkModalInner.defaultProps = _objectSpread({}, defaultProps);
139
122
  var _default = BpkModalInner;
140
123
  exports.default = _default;
@@ -15,4 +15,4 @@
15
15
  * See the License for the specific language governing permissions and
16
16
  * limitations under the License.
17
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%}
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:#fff;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%}
@@ -29,6 +29,7 @@ export type Props = {
29
29
  noFullScreenOnMobile?: boolean;
30
30
  onClose: () => void | null;
31
31
  padded?: boolean;
32
+ showHeader?: boolean;
32
33
  title?: string | null;
33
34
  wide?: boolean;
34
35
  };
@@ -33,9 +33,36 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
33
33
 
34
34
  // @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
35
35
 
36
- // @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
37
-
38
36
  const getClassName = (0, _bpkReactUtils.cssModules)(_BpKModalModule.default);
37
+ const Header = ({
38
+ closeLabel,
39
+ id,
40
+ onClose,
41
+ title
42
+ }) => {
43
+ if (title) {
44
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
45
+ id: id,
46
+ className: getClassName('bpk-modal__header-title'),
47
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
48
+ className: getClassName('bpk-modal__header-title-container'),
49
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Heading, {
50
+ children: title
51
+ })
52
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_bpkComponentCloseButton.default, {
53
+ label: closeLabel,
54
+ onClick: onClose
55
+ })]
56
+ });
57
+ }
58
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
59
+ className: getClassName('bpk-modal__button-container'),
60
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_bpkComponentCloseButton.default, {
61
+ label: closeLabel,
62
+ onClick: onClose
63
+ })
64
+ });
65
+ };
39
66
  const Heading = (0, _bpkReactUtils.withDefaultProps)(_bpkComponentText.default, {
40
67
  textStyle: _bpkComponentText.TEXT_STYLES.label1,
41
68
  tagName: 'h2',
@@ -63,6 +90,7 @@ const BpkModalV2 = props => {
63
90
  noFullScreenOnMobile,
64
91
  onClose,
65
92
  padded,
93
+ showHeader = true,
66
94
  title,
67
95
  wide
68
96
  } = props;
@@ -93,12 +121,6 @@ const BpkModalV2 = props => {
93
121
  }, [id, isOpen]);
94
122
  const classNames = getClassName('bpk-modal', fullScreenOnDesktop && 'bpk-modal--full-screen-desktop', noFullScreenOnMobile && 'bpk-modal--no-full-screen-mobile', wide && 'bpk-modal--wide');
95
123
  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
124
  return isOpen ? /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
103
125
  className: getClassName('bpk-modal-wrapper', dialogSupported ? '' : 'bpk-modal-polyfill'),
104
126
  children: [!dialogSupported && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
@@ -112,17 +134,11 @@ const BpkModalV2 = props => {
112
134
  "aria-labelledby": ariaLabelledby,
113
135
  "data-open": isOpen,
114
136
  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
137
+ children: [showHeader && /*#__PURE__*/(0, _jsxRuntime.jsx)(Header, {
138
+ id: `${id}-title`,
139
+ title: title,
140
+ closeLabel: closeLabel,
141
+ onClose: onClose
126
142
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
127
143
  className: contentClassNames,
128
144
  children: children