@skyscanner/backpack-web 36.17.1 → 37.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 (29) hide show
  1. package/bpk-component-button/src/BpkButtonBase.module.css +1 -1
  2. package/bpk-component-button/src/BpkButtonV2/BpkButton.module.css +1 -1
  3. package/bpk-component-carousel/src/BpkCarousel.js +0 -2
  4. package/bpk-component-checkbox/src/BpkCheckbox.module.css +1 -1
  5. package/bpk-component-link/src/BpkLink.js +11 -5
  6. package/bpk-component-link/src/BpkLink.module.css +1 -1
  7. package/bpk-component-overlay/src/BpkOverlay.d.ts +2 -2
  8. package/bpk-component-overlay/src/BpkOverlay.js +4 -4
  9. package/bpk-component-overlay/src/BpkOverlay.module.css +1 -1
  10. package/bpk-component-page-indicator/index.d.ts +6 -0
  11. package/bpk-component-page-indicator/index.js +3 -1
  12. package/bpk-component-page-indicator/src/BpkPageIndicator.d.ts +21 -0
  13. package/bpk-component-page-indicator/src/BpkPageIndicator.js +49 -68
  14. package/bpk-component-page-indicator/src/NavButton.d.ts +15 -0
  15. package/bpk-component-page-indicator/src/NavButton.js +22 -35
  16. package/bpk-component-tooltip/index.d.ts +4 -4
  17. package/bpk-component-tooltip/index.js +2 -2
  18. package/bpk-component-tooltip/src/BpkTooltip.d.ts +17 -4
  19. package/bpk-component-tooltip/src/BpkTooltip.js +100 -23
  20. package/bpk-component-tooltip/src/BpkTooltip.module.css +1 -1
  21. package/bpk-mixins/_buttons.scss +5 -1
  22. package/bpk-mixins/_forms.scss +5 -26
  23. package/bpk-mixins/_typography.scss +101 -8
  24. package/package.json +1 -1
  25. package/unstable__bpk-mixins/_buttons.scss +5 -1
  26. package/unstable__bpk-mixins/_forms.scss +5 -28
  27. package/unstable__bpk-mixins/_typography.scss +101 -8
  28. package/bpk-component-tooltip/src/BpkTooltipPortal.d.ts +0 -54
  29. package/bpk-component-tooltip/src/BpkTooltipPortal.js +0 -154
@@ -1,154 +0,0 @@
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 { cloneElement, Component } from 'react';
20
- import { createPopper } from '@popperjs/core';
21
- import { Portal, cssModules } from "../../bpk-react-utils";
22
- import BpkTooltip from "./BpkTooltip";
23
- import { TOOLTIP_TYPES } from "./constants";
24
- import STYLES from "./BpkTooltip.module.css";
25
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
26
- const getClassName = cssModules(STYLES);
27
- const hasTouchSupport = () => !!(typeof window !== 'undefined' && ('ontouchstart' in window || navigator.maxTouchPoints > 0));
28
- class BpkTooltipPortal extends Component {
29
- static defaultProps = {
30
- // Disabling as the rule doesn't work when types are defined in a different file
31
- /* eslint-disable react/default-props-match-prop-types */
32
- className: null,
33
- padded: true,
34
- type: TOOLTIP_TYPES.light,
35
- /* eslint-enable */
36
- placement: 'bottom',
37
- hideOnTouchDevices: true,
38
- portalStyle: null,
39
- portalClassName: null,
40
- renderTarget: null,
41
- popperModifiers: null
42
- };
43
- constructor(props) {
44
- super(props);
45
- this.state = {
46
- isOpen: false
47
- };
48
- this.popper = null;
49
- this.targetRef = null;
50
- }
51
- componentDidMount() {
52
- if (this.targetRef) {
53
- const ref = this.targetRef;
54
- ref.addEventListener('focusin', this.openTooltip);
55
- ref.addEventListener('focusout', this.closeTooltip);
56
- ref.addEventListener('mouseenter', this.openTooltip);
57
- ref.addEventListener('mouseleave', this.closeTooltip);
58
- }
59
- }
60
- componentWillUnmount() {
61
- if (this.targetRef) {
62
- const ref = this.targetRef;
63
- ref.addEventListener('focusin', this.openTooltip);
64
- ref.addEventListener('focusout', this.closeTooltip);
65
- ref.removeEventListener('mouseenter', this.openTooltip);
66
- ref.removeEventListener('mouseleave', this.closeTooltip);
67
- }
68
- }
69
- onOpen = (tooltipElement, targetElement) => {
70
- // The default modifiers for the popper
71
- // Note that GPU acceleration should be disabled otherwise Popper will use `translate3d`
72
- // which can cause blurriness in Safari and Chrome.
73
- const stdModifiers = [{
74
- name: 'computeStyles',
75
- options: {
76
- gpuAcceleration: false
77
- }
78
- }, {
79
- name: 'offset',
80
- options: {
81
- offset: [0, 8]
82
- }
83
- }];
84
- this.popper = createPopper(targetElement, tooltipElement, {
85
- placement: this.props.placement,
86
- modifiers: this.props.popperModifiers ? [...this.props.popperModifiers, ...stdModifiers] : stdModifiers
87
- });
88
- this.popper.update();
89
- };
90
- beforeClose = done => {
91
- if (this.popper) {
92
- this.popper.destroy();
93
- this.popper = null;
94
- }
95
- done();
96
- };
97
- openTooltip = () => {
98
- this.setState({
99
- isOpen: true
100
- });
101
- };
102
- closeTooltip = () => {
103
- this.setState({
104
- isOpen: false
105
- });
106
- };
107
- render() {
108
- const {
109
- ariaLabel,
110
- children,
111
- hideOnTouchDevices,
112
- padded,
113
- placement,
114
- popperModifiers,
115
- portalClassName,
116
- portalStyle,
117
- renderTarget,
118
- target,
119
- ...rest
120
- } = this.props;
121
- const classNames = [getClassName('bpk-tooltip-portal')];
122
- const renderPortal = !hasTouchSupport() || !hideOnTouchDevices;
123
- const targetWithAccessibilityProps = /*#__PURE__*/cloneElement(target, {
124
- tabIndex: '0',
125
- 'aria-label': ariaLabel
126
- });
127
- if (portalClassName) {
128
- classNames.push(portalClassName);
129
- }
130
- return /*#__PURE__*/_jsxs(_Fragment, {
131
- children: [targetWithAccessibilityProps, renderPortal && /*#__PURE__*/_jsx(Portal, {
132
- target: targetWithAccessibilityProps,
133
- targetRef: targetRef => {
134
- this.targetRef = targetRef;
135
- },
136
- isOpen: this.state.isOpen,
137
- onOpen: this.onOpen,
138
- onClose: this.closeTooltip,
139
- style: portalStyle,
140
- renderTarget: renderTarget
141
- // TODO: className to be removed
142
- // eslint-disable-next-line @skyscanner/rules/forbid-component-props
143
- ,
144
- className: classNames.join(' '),
145
- children: /*#__PURE__*/_jsx(BpkTooltip, {
146
- padded: padded,
147
- ...rest,
148
- children: children
149
- })
150
- })]
151
- });
152
- }
153
- }
154
- export default BpkTooltipPortal;