@skyscanner/backpack-web 23.3.0 → 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 (35) 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.js +0 -2
  19. package/bpk-component-modal/src/legacy-prop-types.js +86 -0
  20. package/bpk-component-modal/src/themeAttributes.js +1 -0
  21. package/bpk-component-text/index.d.ts +21 -0
  22. package/bpk-component-text/index.js +0 -6
  23. package/bpk-component-text/src/BpkText.d.ts +60 -0
  24. package/bpk-component-text/src/BpkText.js +16 -56
  25. package/bpk-component-text/src/BpkText.module.css +1 -1
  26. package/bpk-component-tooltip/index.d.ts +24 -0
  27. package/bpk-component-tooltip/src/BpkTooltip.d.ts +29 -0
  28. package/bpk-component-tooltip/src/BpkTooltip.js +9 -26
  29. package/bpk-component-tooltip/src/BpkTooltipPortal.d.ts +60 -0
  30. package/bpk-component-tooltip/src/BpkTooltipPortal.js +13 -21
  31. package/bpk-component-tooltip/src/constants.d.ts +31 -0
  32. package/bpk-component-tooltip/src/constants.js +3 -1
  33. package/bpk-scrim-utils/index.d.ts +283 -0
  34. package/bpk-scrim-utils/src/withScrim.d.ts +2 -1
  35. package/package.json +1 -1
@@ -0,0 +1,60 @@
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 declare const TEXT_STYLES: {
21
+ readonly xs: "xs";
22
+ readonly sm: "sm";
23
+ readonly base: "base";
24
+ readonly lg: "lg";
25
+ readonly xl: "xl";
26
+ readonly xxl: "xxl";
27
+ readonly xxxl: "xxxl";
28
+ readonly xxxxl: "xxxxl";
29
+ readonly xxxxxl: "xxxxxl";
30
+ readonly caption: "caption";
31
+ readonly footnote: "footnote";
32
+ readonly label1: "label-1";
33
+ readonly label2: "label-2";
34
+ readonly label3: "label-3";
35
+ readonly bodyDefault: "body-default";
36
+ readonly bodyLongform: "body-longform";
37
+ readonly subheading: "subheading";
38
+ readonly heading1: "heading-1";
39
+ readonly heading2: "heading-2";
40
+ readonly heading3: "heading-3";
41
+ readonly heading4: "heading-4";
42
+ readonly heading5: "heading-5";
43
+ readonly hero1: "hero-1";
44
+ readonly hero2: "hero-2";
45
+ readonly hero3: "hero-3";
46
+ readonly hero4: "hero-4";
47
+ readonly hero5: "hero-5";
48
+ };
49
+ export type TextStyle = typeof TEXT_STYLES[keyof typeof TEXT_STYLES];
50
+ export type Tag = 'span' | 'p' | 'text' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
51
+ type Props = {
52
+ children: ReactNode;
53
+ textStyle?: TextStyle;
54
+ tagName?: Tag;
55
+ className?: string | null;
56
+ id?: string;
57
+ [rest: string]: any;
58
+ };
59
+ declare const BpkText: ({ textStyle, tagName: TagName, className, children, ...rest }: Props) => JSX.Element;
60
+ export default BpkText;
@@ -3,12 +3,11 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = exports.WEIGHT_STYLES = exports.TEXT_STYLES = void 0;
7
- var _propTypes = _interopRequireDefault(require("prop-types"));
6
+ exports.default = exports.TEXT_STYLES = void 0;
8
7
  var _bpkReactUtils = require("../../bpk-react-utils");
9
8
  var _BpkTextModule = _interopRequireDefault(require("./BpkText.module.css"));
10
9
  var _jsxRuntime = require("react/jsx-runtime");
11
- const _excluded = ["bold", "children", "className", "tagName", "textStyle", "weight"];
10
+ const _excluded = ["textStyle", "tagName", "className", "children"];
12
11
  /*
13
12
  * Backpack - Skyscanner's Design System
14
13
  *
@@ -65,59 +64,20 @@ const TEXT_STYLES = {
65
64
  hero5: 'hero-5'
66
65
  };
67
66
  exports.TEXT_STYLES = TEXT_STYLES;
68
- const WEIGHT_STYLES = {
69
- regular: 'regular',
70
- bold: 'bold',
71
- black: 'black'
72
- };
73
- exports.WEIGHT_STYLES = WEIGHT_STYLES;
74
- const getWeight = (bold, weight, textStyle) => {
75
- if (bold || weight === WEIGHT_STYLES.bold) {
76
- return WEIGHT_STYLES.bold;
77
- }
78
-
79
- // Weight can only be black if textStyle is `xl`, `xxl` or `xxxl`.
80
- if (weight === WEIGHT_STYLES.black && textStyle.match(/^x+l$/)) {
81
- return WEIGHT_STYLES.black;
82
- }
83
- return null;
84
- };
85
- const BpkText = props => {
86
- const {
87
- bold,
88
- children,
89
- className,
90
- tagName: TagName,
91
- textStyle,
92
- weight
93
- } = props,
94
- rest = _objectWithoutProperties(props, _excluded);
95
- const validWeight = getWeight(bold, weight, textStyle);
96
- const classNames = getClassName('bpk-text', `bpk-text--${textStyle}`, validWeight && `bpk-text--${validWeight}`, className);
97
- return (
98
- /*#__PURE__*/
99
- // $FlowFixMe[cannot-spread-inexact] - inexact rest. See 'decisions/flowfixme.md'.
100
- (0, _jsxRuntime.jsx)(TagName, _objectSpread(_objectSpread({
101
- className: classNames
102
- }, rest), {}, {
103
- children: children
104
- }))
105
- );
106
- };
107
- BpkText.propTypes = {
108
- children: _propTypes.default.node.isRequired,
109
- textStyle: _propTypes.default.oneOf(Object.values(TEXT_STYLES)),
110
- tagName: _propTypes.default.oneOf(['span', 'p', 'text', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6']),
111
- className: _propTypes.default.string,
112
- bold: (0, _bpkReactUtils.deprecated)(_propTypes.default.bool, 'Use a different "textStyle" to achieve the desired weight.'),
113
- weight: (0, _bpkReactUtils.deprecated)(_propTypes.default.oneOf(Object.keys(WEIGHT_STYLES)), 'Use a different "textStyle" to achieve the desired weight.')
114
- };
115
- BpkText.defaultProps = {
116
- textStyle: TEXT_STYLES.bodyDefault,
117
- tagName: 'span',
118
- className: null,
119
- bold: null,
120
- weight: null
67
+ const BpkText = _ref => {
68
+ let {
69
+ textStyle = TEXT_STYLES.bodyDefault,
70
+ tagName: TagName = 'span',
71
+ className = null,
72
+ children
73
+ } = _ref,
74
+ rest = _objectWithoutProperties(_ref, _excluded);
75
+ const classNames = getClassName('bpk-text', `bpk-text--${textStyle}`, className);
76
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(TagName, _objectSpread(_objectSpread({
77
+ className: classNames
78
+ }, rest), {}, {
79
+ children: children
80
+ }));
121
81
  };
122
82
  var _default = BpkText;
123
83
  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-text{margin:0}.bpk-text--xs{font-size:.75rem;line-height:1rem;font-weight:400}.bpk-text--sm{font-size:.875rem;line-height:1.25rem;font-weight:400}.bpk-text--base{font-size:1rem;line-height:1.5rem;font-weight:400}.bpk-text--lg{font-size:1.25rem;line-height:1.75rem;font-weight:400}.bpk-text--xl{font-size:1.5rem;line-height:2rem;font-weight:400}.bpk-text--xxl{font-size:2rem;line-height:2.5rem;font-weight:700}.bpk-text--xxxl{font-size:2.5rem;line-height:3rem;font-weight:700}.bpk-text--xxxxl{font-size:3rem;line-height:3.5rem;font-weight:700;letter-spacing:-.02em}.bpk-text--xxxxxl{font-size:4rem;line-height:4.5rem;font-weight:700;letter-spacing:-.02em}.bpk-text--caption{font-size:.75rem;line-height:1rem;font-weight:400}.bpk-text--footnote{font-size:.875rem;line-height:1.25rem;font-weight:400}.bpk-text--label-1{font-size:1rem;line-height:1.5rem;font-weight:700}.bpk-text--label-2{font-size:.875rem;line-height:1.25rem;font-weight:700}.bpk-text--label-3{font-size:.75rem;line-height:1rem;font-weight:700}.bpk-text--body-default{font-size:1rem;line-height:1.5rem;font-weight:400}.bpk-text--body-longform{font-size:1.25rem;line-height:1.75rem;font-weight:400}.bpk-text--subheading{font-size:1.5rem;line-height:2rem;font-weight:400}.bpk-text--heading-1{font-size:2.5rem;line-height:3rem;font-weight:700}.bpk-text--heading-2{font-size:2rem;line-height:2.5rem;font-weight:700}.bpk-text--heading-3{font-size:1.5rem;line-height:1.75rem;font-weight:700}.bpk-text--heading-4{font-size:1.25rem;line-height:1.5rem;font-weight:700}.bpk-text--heading-5{font-size:1rem;line-height:1.25rem;font-weight:700}.bpk-text--hero-1{font-size:7.5rem;line-height:7.5rem;font-weight:700;letter-spacing:-.02em}.bpk-text--hero-2{font-size:6rem;line-height:6rem;font-weight:700;letter-spacing:-.02em}.bpk-text--hero-3{font-size:4.75rem;line-height:5.25rem;font-weight:700;letter-spacing:-.02em}.bpk-text--hero-4{font-size:4rem;line-height:4.5rem;font-weight:700;letter-spacing:-.02em}.bpk-text--hero-5{font-size:3rem;line-height:3.5rem;font-weight:700;letter-spacing:-.02em}.bpk-text--bold{font-weight:700}.bpk-text--black{font-weight:900}
18
+ @keyframes bpk-keyframe-spin{100%{transform:rotate(1turn)}}.bpk-text{margin:0}.bpk-text--xs{font-size:.75rem;line-height:1rem;font-weight:400}.bpk-text--sm{font-size:.875rem;line-height:1.25rem;font-weight:400}.bpk-text--base{font-size:1rem;line-height:1.5rem;font-weight:400}.bpk-text--lg{font-size:1.25rem;line-height:1.75rem;font-weight:400}.bpk-text--xl{font-size:1.5rem;line-height:2rem;font-weight:400}.bpk-text--xxl{font-size:2rem;line-height:2.5rem;font-weight:700}.bpk-text--xxxl{font-size:2.5rem;line-height:3rem;font-weight:700}.bpk-text--xxxxl{font-size:3rem;line-height:3.5rem;font-weight:700;letter-spacing:-.02em}.bpk-text--xxxxxl{font-size:4rem;line-height:4.5rem;font-weight:700;letter-spacing:-.02em}.bpk-text--caption{font-size:.75rem;line-height:1rem;font-weight:400}.bpk-text--footnote{font-size:.875rem;line-height:1.25rem;font-weight:400}.bpk-text--label-1{font-size:1rem;line-height:1.5rem;font-weight:700}.bpk-text--label-2{font-size:.875rem;line-height:1.25rem;font-weight:700}.bpk-text--label-3{font-size:.75rem;line-height:1rem;font-weight:700}.bpk-text--body-default{font-size:1rem;line-height:1.5rem;font-weight:400}.bpk-text--body-longform{font-size:1.25rem;line-height:1.75rem;font-weight:400}.bpk-text--subheading{font-size:1.5rem;line-height:2rem;font-weight:400}.bpk-text--heading-1{font-size:2.5rem;line-height:3rem;font-weight:700}.bpk-text--heading-2{font-size:2rem;line-height:2.5rem;font-weight:700}.bpk-text--heading-3{font-size:1.5rem;line-height:1.75rem;font-weight:700}.bpk-text--heading-4{font-size:1.25rem;line-height:1.5rem;font-weight:700}.bpk-text--heading-5{font-size:1rem;line-height:1.25rem;font-weight:700}.bpk-text--hero-1{font-size:7.5rem;line-height:7.5rem;font-weight:700;letter-spacing:-.02em}.bpk-text--hero-2{font-size:6rem;line-height:6rem;font-weight:700;letter-spacing:-.02em}.bpk-text--hero-3{font-size:4.75rem;line-height:5.25rem;font-weight:700;letter-spacing:-.02em}.bpk-text--hero-4{font-size:4rem;line-height:4.5rem;font-weight:700;letter-spacing:-.02em}.bpk-text--hero-5{font-size:3rem;line-height:3.5rem;font-weight:700;letter-spacing:-.02em}
@@ -0,0 +1,24 @@
1
+ /*
2
+ * Backpack - Skyscanner's Design System
3
+ *
4
+ * Copyright 2016 Skyscanner Ltd
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+
19
+ import BpkTooltipPortal from './src/BpkTooltipPortal';
20
+ import type { Props } from './src/BpkTooltipPortal';
21
+ import { TOOLTIP_TYPES } from './src/constants';
22
+ export type BpkTooltipPortalProps = Props;
23
+ export default BpkTooltipPortal;
24
+ export { TOOLTIP_TYPES };
@@ -0,0 +1,29 @@
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
+ import { TOOLTIP_TYPES } from './constants';
21
+ export type TooltipProps = {
22
+ id: string;
23
+ children: ReactNode | string;
24
+ type?: typeof TOOLTIP_TYPES[keyof typeof TOOLTIP_TYPES];
25
+ padded?: boolean;
26
+ className?: string | null;
27
+ };
28
+ declare const BpkTooltip: ({ children, className, id, padded, type, ...rest }: TooltipProps) => JSX.Element;
29
+ export default BpkTooltip;
@@ -3,8 +3,7 @@
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 _bpkReactUtils = require("../../bpk-react-utils");
9
8
  var _BpkTooltipModule = _interopRequireDefault(require("./BpkTooltip.module.css"));
10
9
  var _constants = require("./constants");
@@ -41,15 +40,15 @@ function _toPrimitive(input, hint) { if (typeof input !== "object" || input ===
41
40
  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; }
42
41
  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; }
43
42
  const getClassName = (0, _bpkReactUtils.cssModules)(_BpkTooltipModule.default);
44
- const BpkTooltip = props => {
45
- const {
43
+ const BpkTooltip = _ref => {
44
+ let {
46
45
  children,
47
- className,
46
+ className = null,
48
47
  id,
49
- padded,
50
- type
51
- } = props,
52
- rest = _objectWithoutProperties(props, _excluded);
48
+ padded = true,
49
+ type = _constants.TOOLTIP_TYPES.light
50
+ } = _ref,
51
+ rest = _objectWithoutProperties(_ref, _excluded);
53
52
  const classNames = getClassName('bpk-tooltip', className);
54
53
  const innerClassNames = getClassName('bpk-tooltip__inner', type === _constants.TOOLTIP_TYPES.dark && 'bpk-tooltip__inner--dark', padded && 'bpk-tooltip__inner--padded');
55
54
  const arrowClassNames = getClassName('bpk-tooltip__arrow', type === _constants.TOOLTIP_TYPES.dark && 'bpk-tooltip__arrow--dark');
@@ -59,7 +58,7 @@ const BpkTooltip = props => {
59
58
  transitionTimeout: 200,
60
59
  children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("section", _objectSpread(_objectSpread({
61
60
  id: id,
62
- tabIndex: "-1",
61
+ tabIndex: -1,
63
62
  role: "dialog",
64
63
  className: classNames
65
64
  }, rest), {}, {
@@ -75,21 +74,5 @@ const BpkTooltip = props => {
75
74
  }))
76
75
  });
77
76
  };
78
- const propTypes = {
79
- id: _propTypes.default.string.isRequired,
80
- children: _propTypes.default.node.isRequired,
81
- className: _propTypes.default.string,
82
- padded: _propTypes.default.bool,
83
- type: _propTypes.default.oneOf(Object.keys(_constants.TOOLTIP_TYPES))
84
- };
85
- exports.propTypes = propTypes;
86
- const defaultProps = {
87
- className: null,
88
- padded: true,
89
- type: _constants.TOOLTIP_TYPES.light
90
- };
91
- exports.defaultProps = defaultProps;
92
- BpkTooltip.propTypes = _objectSpread({}, propTypes);
93
- BpkTooltip.defaultProps = _objectSpread({}, defaultProps);
94
77
  var _default = BpkTooltip;
95
78
  exports.default = _default;
@@ -0,0 +1,60 @@
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 { createPopper } from '@popperjs/core';
20
+ import { Component } from 'react';
21
+ import type { ReactNode, ReactElement } from 'react';
22
+ import type { TooltipProps } from './BpkTooltip';
23
+ export type Props = TooltipProps & {
24
+ ariaLabel: string;
25
+ target: ReactElement<any>;
26
+ children: ReactNode | string;
27
+ placement?: 'top' | 'right' | 'bottom' | 'left' | 'auto';
28
+ hideOnTouchDevices?: boolean;
29
+ portalStyle?: object;
30
+ portalClassName?: string;
31
+ renderTarget: null | (() => null | HTMLElement);
32
+ popperModifiers?: object[];
33
+ };
34
+ type State = {
35
+ isOpen: boolean;
36
+ };
37
+ declare class BpkTooltipPortal extends Component<Props, State> {
38
+ popper?: ReturnType<typeof createPopper> | null;
39
+ targetRef?: Element | null;
40
+ static defaultProps: {
41
+ className: null;
42
+ padded: boolean;
43
+ type: "light";
44
+ placement: string;
45
+ hideOnTouchDevices: boolean;
46
+ portalStyle: null;
47
+ portalClassName: null;
48
+ renderTarget: null;
49
+ popperModifiers: null;
50
+ };
51
+ constructor(props: Props);
52
+ componentDidMount(): void;
53
+ componentWillUnmount(): void;
54
+ onOpen: (tooltipElement: HTMLElement, targetElement?: HTMLElement | null | undefined) => void;
55
+ beforeClose: (done: () => void | null) => void;
56
+ openTooltip: () => void;
57
+ closeTooltip: () => void;
58
+ render(): JSX.Element;
59
+ }
60
+ export default BpkTooltipPortal;
@@ -5,15 +5,13 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var _core = require("@popperjs/core");
8
- var _propTypes = _interopRequireDefault(require("prop-types"));
9
8
  var _react = require("react");
10
9
  var _bpkReactUtils = require("../../bpk-react-utils");
11
- var _BpkTooltip = _interopRequireWildcard(require("./BpkTooltip"));
10
+ var _BpkTooltip = _interopRequireDefault(require("./BpkTooltip"));
12
11
  var _BpkTooltipModule = _interopRequireDefault(require("./BpkTooltip.module.css"));
12
+ var _constants = require("./constants");
13
13
  var _jsxRuntime = require("react/jsx-runtime");
14
14
  const _excluded = ["ariaLabel", "children", "hideOnTouchDevices", "padded", "placement", "popperModifiers", "portalClassName", "portalStyle", "renderTarget", "target"];
15
- 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); }
16
- 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; }
17
15
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
18
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; }
19
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; }
@@ -39,10 +37,10 @@ function _toPrimitive(input, hint) { if (typeof input !== "object" || input ===
39
37
  * limitations under the License.
40
38
  */
41
39
  const getClassName = (0, _bpkReactUtils.cssModules)(_BpkTooltipModule.default);
42
- const hasTouchSupport = () => !!(typeof window !== 'undefined' && ('ontouchstart' in window || window.DocumentTouch && document instanceof window.DocumentTouch));
40
+ const hasTouchSupport = () => !!(typeof window !== 'undefined' && ('ontouchstart' in window || navigator.maxTouchPoints > 0));
43
41
  class BpkTooltipPortal extends _react.Component {
44
- constructor() {
45
- super();
42
+ constructor(props) {
43
+ super(props);
46
44
  _defineProperty(this, "popper", void 0);
47
45
  _defineProperty(this, "targetRef", void 0);
48
46
  _defineProperty(this, "onOpen", (tooltipElement, targetElement) => {
@@ -152,25 +150,19 @@ class BpkTooltipPortal extends _react.Component {
152
150
  });
153
151
  }
154
152
  }
155
- _defineProperty(BpkTooltipPortal, "propTypes", _objectSpread(_objectSpread({}, _BpkTooltip.propTypes), {}, {
156
- ariaLabel: _propTypes.default.string.isRequired,
157
- target: _propTypes.default.node.isRequired,
158
- children: _propTypes.default.node.isRequired,
159
- placement: _propTypes.default.oneOf(['top', 'right', 'bottom', 'left', 'auto']),
160
- hideOnTouchDevices: _propTypes.default.bool,
161
- portalStyle: _propTypes.default.object,
162
- // eslint-disable-line react/forbid-prop-types
163
- portalClassName: _propTypes.default.string,
164
- renderTarget: _propTypes.default.func,
165
- popperModifiers: _propTypes.default.arrayOf(_propTypes.default.object) // eslint-disable-line react/forbid-prop-types
166
- }));
167
- _defineProperty(BpkTooltipPortal, "defaultProps", _objectSpread(_objectSpread({}, _BpkTooltip.defaultProps), {}, {
153
+ _defineProperty(BpkTooltipPortal, "defaultProps", {
154
+ // Disabling as the rule doesn't work when types are defined in a different file
155
+ /* eslint-disable react/default-props-match-prop-types */
156
+ className: null,
157
+ padded: true,
158
+ type: _constants.TOOLTIP_TYPES.light,
159
+ /* eslint-enable */
168
160
  placement: 'bottom',
169
161
  hideOnTouchDevices: true,
170
162
  portalStyle: null,
171
163
  portalClassName: null,
172
164
  renderTarget: null,
173
165
  popperModifiers: null
174
- }));
166
+ });
175
167
  var _default = BpkTooltipPortal;
176
168
  exports.default = _default;
@@ -0,0 +1,31 @@
1
+ /*
2
+ * Backpack - Skyscanner's Design System
3
+ *
4
+ * Copyright 2016 Skyscanner Ltd
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+
19
+ export declare const ARROW_ID = "js-bpk-popover-arrow";
20
+ export declare const TOOLTIP_TYPES: {
21
+ readonly light: "light";
22
+ readonly dark: "dark";
23
+ };
24
+ declare const _default: {
25
+ ARROW_ID: string;
26
+ TOOLTIP_TYPES: {
27
+ readonly light: "light";
28
+ readonly dark: "dark";
29
+ };
30
+ };
31
+ export default _default;
@@ -20,7 +20,9 @@ exports.default = exports.TOOLTIP_TYPES = exports.ARROW_ID = void 0;
20
20
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21
21
  * See the License for the specific language governing permissions and
22
22
  * limitations under the License.
23
- */const ARROW_ID = 'js-bpk-popover-arrow';
23
+ */
24
+
25
+ const ARROW_ID = 'js-bpk-popover-arrow';
24
26
  exports.ARROW_ID = ARROW_ID;
25
27
  const TOOLTIP_TYPES = {
26
28
  light: 'light',