@skyscanner/backpack-web 42.27.3 → 43.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.
- package/bpk-component-accordion/src/BpkAccordionItem.d.ts +1 -1
- package/bpk-component-accordion/src/withAccordionItemState.d.ts +2 -7
- package/bpk-component-accordion/src/withAccordionItemState.js +4 -6
- package/bpk-component-accordion/src/withSingleItemAccordionState.d.ts +1 -1
- package/bpk-component-aria-live/src/BpkAriaLive.d.ts +1 -1
- package/bpk-component-aria-live/src/BpkAriaLive.story-helpers.d.ts +2 -2
- package/bpk-component-autosuggest/src/BpkAutosuggestV2/BpkAutosuggest.d.ts +4 -4
- package/bpk-component-badge/src/BpkBadge.module.css +1 -1
- package/bpk-component-banner-alert/src/AnimateAndFade.d.ts +4 -7
- package/bpk-component-banner-alert/src/AnimateAndFade.js +14 -10
- package/bpk-component-banner-alert/src/withBannerAlertState.d.ts +0 -10
- package/bpk-component-banner-alert/src/withBannerAlertState.js +3 -13
- package/bpk-component-barchart/src/BpkBarchart.js +24 -41
- package/bpk-component-barchart/src/BpkBarchartBar.js +7 -16
- package/bpk-component-barchart/src/BpkBarchartBars.js +6 -14
- package/bpk-component-barchart/src/BpkChartAxis.js +5 -12
- package/bpk-component-barchart/src/BpkChartDataTable.js +1 -4
- package/bpk-component-barchart/src/BpkChartGridLines.js +3 -8
- package/bpk-component-calendar/index.d.ts +2 -2
- package/bpk-component-calendar/index.js +2 -2
- package/bpk-component-calendar/src/BpkCalendarContainer.d.ts +3 -28
- package/bpk-component-calendar/src/BpkCalendarContainer.js +47 -34
- package/bpk-component-calendar/src/BpkCalendarDate.d.ts +0 -1
- package/bpk-component-calendar/src/BpkCalendarDate.js +32 -31
- package/bpk-component-calendar/src/BpkCalendarGrid.d.ts +13 -14
- package/bpk-component-calendar/src/BpkCalendarGrid.js +28 -37
- package/bpk-component-calendar/src/BpkCalendarGridHeader.d.ts +0 -4
- package/bpk-component-calendar/src/BpkCalendarGridHeader.js +2 -6
- package/bpk-component-calendar/src/BpkCalendarGridTransition.d.ts +0 -5
- package/bpk-component-calendar/src/BpkCalendarGridTransition.js +0 -5
- package/bpk-component-calendar/src/BpkCalendarWeek.d.ts +0 -1
- package/bpk-component-calendar/src/BpkCalendarWeek.js +19 -27
- package/bpk-component-calendar/src/custom-proptypes.d.ts +1 -1
- package/bpk-component-card-list/src/BpkCardList.js +0 -3
- package/bpk-component-card-list/src/BpkCardListRowRail/BpkCardListCarousel.js +1 -3
- package/bpk-component-card-list/src/BpkCardListRowRail/BpkCardListRowRailContainer.js +1 -14
- package/bpk-component-card-list/src/BpkCardListRowRail/utils.d.ts +1 -2
- package/bpk-component-card-list/src/BpkCardListRowRail/utils.js +0 -21
- package/bpk-component-card-list/src/common-types.d.ts +4 -7
- package/bpk-component-chatbot-input/src/hooks/useChatbotInput.d.ts +1 -1
- package/bpk-component-chatbot-input/src/hooks/useTextAreaAutoResize.d.ts +1 -1
- package/bpk-component-datepicker/src/BpkDatepicker.d.ts +6 -192
- package/bpk-component-datepicker/src/BpkDatepicker.js +46 -53
- package/bpk-component-dialog/src/BpkDialogInner.d.ts +0 -7
- package/bpk-component-drawer/src/BpkDrawerContent.d.ts +2 -2
- package/bpk-component-drawer/src/BpkDrawerContent.js +13 -1
- package/bpk-component-fieldset/src/BpkFieldset.d.ts +1 -1
- package/bpk-component-floating-notification/src/BpkFloatingNotification.js +4 -1
- package/bpk-component-grid-toggle/src/BpkGridToggle.js +9 -7
- package/bpk-component-image/src/BpkBackgroundImage.d.ts +1 -9
- package/bpk-component-image/src/BpkBackgroundImage.js +18 -18
- package/bpk-component-image/src/BpkImage.d.ts +1 -8
- package/bpk-component-image/src/BpkImage.js +10 -18
- package/bpk-component-image/src/withLazyLoading.d.ts +0 -4
- package/bpk-component-image/src/withLazyLoading.js +2 -6
- package/bpk-component-infinite-scroll/src/withInfiniteScroll.js +6 -8
- package/bpk-component-info-banner/src/AnimateAndFade.d.ts +4 -7
- package/bpk-component-info-banner/src/AnimateAndFade.js +14 -10
- package/bpk-component-info-banner/src/withBannerAlertState.d.ts +0 -10
- package/bpk-component-info-banner/src/withBannerAlertState.js +3 -13
- package/bpk-component-input/index.d.ts +2 -2
- package/bpk-component-input/index.js +2 -2
- package/bpk-component-input/src/BpkInput.d.ts +0 -13
- package/bpk-component-input/src/BpkInput.js +13 -12
- package/bpk-component-input/src/common-types.d.ts +0 -32
- package/bpk-component-input/src/common-types.js +1 -56
- package/bpk-component-input/src/withOpenEvents.d.ts +1 -12
- package/bpk-component-input/src/withOpenEvents.js +2 -14
- package/bpk-component-layout/src/types.d.ts +19 -35
- package/bpk-component-map/src/BpkBasicMapMarker.d.ts +1 -8
- package/bpk-component-map/src/BpkBasicMapMarker.js +0 -6
- package/bpk-component-map/src/BpkIconMarker.js +4 -10
- package/bpk-component-map/src/BpkIconMarkerBackground.js +3 -8
- package/bpk-component-map/src/BpkMap.js +14 -30
- package/bpk-component-map/src/withGoogleMapsScript.js +4 -8
- package/bpk-component-mobile-scroll-container/src/BpkMobileScrollContainer.d.ts +0 -1
- package/bpk-component-mobile-scroll-container/src/BpkMobileScrollContainer.js +1 -5
- package/bpk-component-modal/index.d.ts +1 -2
- package/bpk-component-modal/index.js +1 -3
- package/bpk-component-navigation-bar/src/BpkNavigationBar.d.ts +2 -2
- package/bpk-component-phone-input/src/BpkPhoneInput.js +6 -14
- package/bpk-component-progress/src/BpkProgress.d.ts +0 -8
- package/bpk-component-progress/src/BpkProgress.js +10 -16
- package/bpk-component-scrollable-calendar/src/BpkScrollableCalendar.d.ts +0 -14
- package/bpk-component-section-list/src/BpkSectionListItem.js +4 -10
- package/bpk-component-section-list/src/BpkSectionListSection.js +1 -4
- package/bpk-component-segmented-control/src/BpkSegmentedControl.d.ts +1 -1
- package/bpk-component-select/src/BpkSelect.d.ts +1 -1
- package/bpk-component-slider/src/BpkSlider.js +1 -1
- package/bpk-component-spinner/src/SpinnerLayout.story-helpers.d.ts +1 -7
- package/bpk-component-spinner/src/SpinnerLayout.story-helpers.js +0 -4
- package/bpk-component-split-input/src/BpkInputField.d.ts +2 -6
- package/bpk-component-split-input/src/BpkInputField.js +2 -6
- package/bpk-component-split-input/src/BpkSplitInput.d.ts +0 -6
- package/bpk-component-split-input/src/BpkSplitInput.js +7 -13
- package/bpk-component-star-rating/src/withInteractiveStarRatingState.d.ts +0 -3
- package/bpk-component-star-rating/src/withInteractiveStarRatingState.js +0 -3
- package/bpk-component-ticket/src/BpkTicket.js +6 -14
- package/bpk-mixins/_badges.scss +3 -3
- package/bpk-react-utils/index.d.ts +3 -1
- package/bpk-react-utils/src/BpkDialogWrapper/BpkDialogWrapper.js +1 -0
- package/bpk-react-utils/src/Portal.d.ts +10 -22
- package/bpk-react-utils/src/Portal.js +22 -19
- package/bpk-react-utils/src/TransitionInitialMount.d.ts +4 -2
- package/bpk-react-utils/src/TransitionInitialMount.js +23 -14
- package/bpk-scrim-utils/index.d.ts +0 -7
- package/bpk-scrim-utils/src/withScrim.d.ts +0 -7
- package/bpk-scrim-utils/src/withScrim.js +10 -15
- package/package.json +3 -3
- package/bpk-component-modal/src/legacy-prop-types.js +0 -74
|
@@ -17,12 +17,6 @@ interface State {
|
|
|
17
17
|
inputValue: string[] | number[];
|
|
18
18
|
}
|
|
19
19
|
declare class BpkSplitInput extends Component<Props, State> {
|
|
20
|
-
static defaultProps: {
|
|
21
|
-
type: "number";
|
|
22
|
-
inputLength: number;
|
|
23
|
-
large: boolean;
|
|
24
|
-
placeholder: string;
|
|
25
|
-
};
|
|
26
20
|
constructor(props: Props);
|
|
27
21
|
onInputChange: (input: string[] | number[]) => void;
|
|
28
22
|
updateInputValue: (value: string | number) => void;
|
|
@@ -24,12 +24,6 @@ import STYLES from "./BpkSplitInput.module.css";
|
|
|
24
24
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
25
25
|
const getClassName = cssModules(STYLES);
|
|
26
26
|
class BpkSplitInput extends Component {
|
|
27
|
-
static defaultProps = {
|
|
28
|
-
type: INPUT_TYPES.number,
|
|
29
|
-
inputLength: 4,
|
|
30
|
-
large: true,
|
|
31
|
-
placeholder: ''
|
|
32
|
-
};
|
|
33
27
|
constructor(props) {
|
|
34
28
|
super(props);
|
|
35
29
|
this.state = {
|
|
@@ -77,14 +71,14 @@ class BpkSplitInput extends Component {
|
|
|
77
71
|
}
|
|
78
72
|
return true;
|
|
79
73
|
};
|
|
80
|
-
isNumeric = () => this.props.type === INPUT_TYPES.number;
|
|
74
|
+
isNumeric = () => (this.props.type ?? INPUT_TYPES.number) === INPUT_TYPES.number;
|
|
81
75
|
isInputValid = value => {
|
|
82
76
|
const isTypeValid = this.isNumeric() ? /^\d$/.test(`${value}`) : typeof value === 'string';
|
|
83
77
|
return isTypeValid && `${value}`.trim().length === 1;
|
|
84
78
|
};
|
|
85
79
|
focusInput = inputIndex => {
|
|
86
80
|
const {
|
|
87
|
-
inputLength
|
|
81
|
+
inputLength = 4
|
|
88
82
|
} = this.props;
|
|
89
83
|
const focusedInput = Math.max(Math.min(inputLength - 1, inputIndex), 0);
|
|
90
84
|
this.setState({
|
|
@@ -106,7 +100,7 @@ class BpkSplitInput extends Component {
|
|
|
106
100
|
handleOnPaste = e => {
|
|
107
101
|
e.preventDefault();
|
|
108
102
|
const {
|
|
109
|
-
inputLength
|
|
103
|
+
inputLength = 4
|
|
110
104
|
} = this.props;
|
|
111
105
|
const {
|
|
112
106
|
focusedInput,
|
|
@@ -170,12 +164,12 @@ class BpkSplitInput extends Component {
|
|
|
170
164
|
} = this.state;
|
|
171
165
|
const {
|
|
172
166
|
id,
|
|
173
|
-
inputLength,
|
|
167
|
+
inputLength = 4,
|
|
174
168
|
label,
|
|
175
|
-
large,
|
|
169
|
+
large = true,
|
|
176
170
|
name,
|
|
177
|
-
placeholder,
|
|
178
|
-
type,
|
|
171
|
+
placeholder = '',
|
|
172
|
+
type = INPUT_TYPES.number,
|
|
179
173
|
...rest
|
|
180
174
|
} = this.props;
|
|
181
175
|
const inputs = [];
|
|
@@ -34,9 +34,6 @@ declare const withInteractiveStarRatingState: <P extends object>(InteractiveStar
|
|
|
34
34
|
UNSAFE_componentWillUpdate?(nextProps: Readonly<P & WithInteractiveStarRatingStateProps>, nextState: Readonly<State>, nextContext: any): void;
|
|
35
35
|
};
|
|
36
36
|
displayName: string;
|
|
37
|
-
defaultProps: {
|
|
38
|
-
onRatingSelect: () => null;
|
|
39
|
-
};
|
|
40
37
|
contextType?: import("react").Context<any> | undefined;
|
|
41
38
|
};
|
|
42
39
|
export default withInteractiveStarRatingState;
|
|
@@ -21,9 +21,6 @@ import { wrapDisplayName } from "../../bpk-react-utils";
|
|
|
21
21
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
22
22
|
const withInteractiveStarRatingState = InteractiveStarRating => {
|
|
23
23
|
class EnhancedComponent extends Component {
|
|
24
|
-
static defaultProps = {
|
|
25
|
-
onRatingSelect: () => null
|
|
26
|
-
};
|
|
27
24
|
constructor(props) {
|
|
28
25
|
super(props);
|
|
29
26
|
this.state = {
|
|
@@ -28,13 +28,13 @@ const getClassName = cssModules(STYLES);
|
|
|
28
28
|
const BpkTicket = props => {
|
|
29
29
|
const {
|
|
30
30
|
children,
|
|
31
|
-
className,
|
|
32
|
-
href,
|
|
33
|
-
padded,
|
|
31
|
+
className = null,
|
|
32
|
+
href = null,
|
|
33
|
+
padded = true,
|
|
34
34
|
stub,
|
|
35
|
-
stubClassName,
|
|
36
|
-
stubProps,
|
|
37
|
-
vertical,
|
|
35
|
+
stubClassName = null,
|
|
36
|
+
stubProps = {},
|
|
37
|
+
vertical = false,
|
|
38
38
|
...rest
|
|
39
39
|
} = props;
|
|
40
40
|
const classNames = getClassName('bpk-ticket', className, vertical && 'bpk-ticket--vertical');
|
|
@@ -94,12 +94,4 @@ BpkTicket.propTypes = {
|
|
|
94
94
|
stubClassName: PropTypes.string,
|
|
95
95
|
stubProps: PropTypes.object // eslint-disable-line react/forbid-prop-types
|
|
96
96
|
};
|
|
97
|
-
BpkTicket.defaultProps = {
|
|
98
|
-
className: null,
|
|
99
|
-
href: null,
|
|
100
|
-
padded: true,
|
|
101
|
-
vertical: false,
|
|
102
|
-
stubClassName: null,
|
|
103
|
-
stubProps: {}
|
|
104
|
-
};
|
|
105
97
|
export default BpkTicket;
|
package/bpk-mixins/_badges.scss
CHANGED
|
@@ -45,11 +45,11 @@
|
|
|
45
45
|
tokens.$bpk-border-radius-xs
|
|
46
46
|
);
|
|
47
47
|
@include typography.bpk-text;
|
|
48
|
-
@include typography.bpk-
|
|
48
|
+
@include typography.bpk-caption;
|
|
49
49
|
@include utils.bpk-themeable-property(
|
|
50
50
|
font-size,
|
|
51
51
|
--bpk-badge-font-size,
|
|
52
|
-
tokens.$bpk-font-size-
|
|
52
|
+
tokens.$bpk-font-size-xs
|
|
53
53
|
);
|
|
54
54
|
@include utils.bpk-themeable-property(
|
|
55
55
|
font-weight,
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
@include utils.bpk-themeable-property(
|
|
60
60
|
line-height,
|
|
61
61
|
--bpk-badge-line-height,
|
|
62
|
-
tokens.$bpk-line-height-
|
|
62
|
+
tokens.$bpk-line-height-xs
|
|
63
63
|
);
|
|
64
64
|
}
|
|
65
65
|
|
|
@@ -19,7 +19,9 @@ declare const _default: {
|
|
|
19
19
|
appearClassName: string;
|
|
20
20
|
appearActiveClassName: string;
|
|
21
21
|
transitionTimeout: number;
|
|
22
|
-
children:
|
|
22
|
+
children: import("react").ReactElement<{
|
|
23
|
+
ref?: import("react").RefObject<HTMLElement | null>;
|
|
24
|
+
}>;
|
|
23
25
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
24
26
|
cssModules: (styles?: {
|
|
25
27
|
[key: string]: any;
|
|
@@ -109,6 +109,7 @@ export const BpkDialogWrapper = ({
|
|
|
109
109
|
className: getClassName('bpk-dialog-wrapper--backdrop'),
|
|
110
110
|
"data-open": isOpen
|
|
111
111
|
}), /*#__PURE__*/_jsx(CSSTransition, {
|
|
112
|
+
nodeRef: ref,
|
|
112
113
|
classNames: transitionClassNames,
|
|
113
114
|
in: !exiting,
|
|
114
115
|
appear: !exiting,
|
|
@@ -4,18 +4,18 @@ type InteractionEvents = TouchEvent | MouseEvent | KeyboardEvent;
|
|
|
4
4
|
type Props = {
|
|
5
5
|
children: string | ReactNode;
|
|
6
6
|
isOpen: boolean;
|
|
7
|
-
beforeClose
|
|
8
|
-
className
|
|
9
|
-
onClose
|
|
7
|
+
beforeClose?: ((arg0: () => void) => void) | null | undefined;
|
|
8
|
+
className?: string | null | undefined;
|
|
9
|
+
onClose?: (arg0: InteractionEvents, arg1: {
|
|
10
10
|
source: 'ESCAPE' | 'DOCUMENT_CLICK';
|
|
11
11
|
}) => void;
|
|
12
|
-
onOpen
|
|
13
|
-
onRender
|
|
14
|
-
style
|
|
15
|
-
renderTarget
|
|
16
|
-
target
|
|
17
|
-
targetRef
|
|
18
|
-
closeOnEscPressed
|
|
12
|
+
onOpen?: (arg0: HTMLElement, arg1?: HTMLElement | null | undefined) => void;
|
|
13
|
+
onRender?: (arg0: HTMLElement | null | undefined, arg1: HTMLElement | null | undefined) => void;
|
|
14
|
+
style?: {} | null | undefined;
|
|
15
|
+
renderTarget?: null | HTMLElement | (() => null | HTMLElement);
|
|
16
|
+
target?: null | HTMLElement | JSX.Element | (() => HTMLElement);
|
|
17
|
+
targetRef?: ((arg0: null | Element | undefined) => void) | null | undefined;
|
|
18
|
+
closeOnEscPressed?: boolean;
|
|
19
19
|
};
|
|
20
20
|
type State = {
|
|
21
21
|
isVisible: boolean;
|
|
@@ -23,18 +23,6 @@ type State = {
|
|
|
23
23
|
declare class Portal extends Component<Props, State> {
|
|
24
24
|
portalElement: null | HTMLDivElement;
|
|
25
25
|
shouldClose: boolean;
|
|
26
|
-
static defaultProps: {
|
|
27
|
-
beforeClose: null;
|
|
28
|
-
className: null;
|
|
29
|
-
onClose: () => null;
|
|
30
|
-
onOpen: () => null;
|
|
31
|
-
onRender: () => null;
|
|
32
|
-
style: null;
|
|
33
|
-
renderTarget: null;
|
|
34
|
-
target: null;
|
|
35
|
-
targetRef: null;
|
|
36
|
-
closeOnEscPressed: boolean;
|
|
37
|
-
};
|
|
38
26
|
constructor(props: Props);
|
|
39
27
|
componentDidMount(): void;
|
|
40
28
|
componentDidUpdate(prevProps: Props): void;
|
|
@@ -25,19 +25,8 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
25
25
|
const KEYCODES = {
|
|
26
26
|
ESCAPE: 'Escape'
|
|
27
27
|
};
|
|
28
|
+
const noop = () => null;
|
|
28
29
|
class Portal extends Component {
|
|
29
|
-
static defaultProps = {
|
|
30
|
-
beforeClose: null,
|
|
31
|
-
className: null,
|
|
32
|
-
onClose: () => null,
|
|
33
|
-
onOpen: () => null,
|
|
34
|
-
onRender: () => null,
|
|
35
|
-
style: null,
|
|
36
|
-
renderTarget: null,
|
|
37
|
-
target: null,
|
|
38
|
-
targetRef: null,
|
|
39
|
-
closeOnEscPressed: true
|
|
40
|
-
};
|
|
41
30
|
constructor(props) {
|
|
42
31
|
super(props);
|
|
43
32
|
this.portalElement = null;
|
|
@@ -69,15 +58,19 @@ class Portal extends Component {
|
|
|
69
58
|
// call their beforeClose function so that they can trigger the close.
|
|
70
59
|
// If they don't provide `beforeClose` we just call `close` directly.
|
|
71
60
|
componentDidUpdate(prevProps) {
|
|
61
|
+
const {
|
|
62
|
+
beforeClose,
|
|
63
|
+
onRender = noop
|
|
64
|
+
} = this.props;
|
|
72
65
|
if (this.props.isOpen) {
|
|
73
66
|
if (!prevProps.isOpen) {
|
|
74
67
|
this.open();
|
|
75
68
|
} else {
|
|
76
|
-
|
|
69
|
+
onRender(this.portalElement, this.getTargetElement());
|
|
77
70
|
}
|
|
78
71
|
} else if (prevProps.isOpen) {
|
|
79
|
-
if (
|
|
80
|
-
|
|
72
|
+
if (beforeClose) {
|
|
73
|
+
beforeClose(this.close);
|
|
81
74
|
} else {
|
|
82
75
|
this.close();
|
|
83
76
|
}
|
|
@@ -95,6 +88,9 @@ class Portal extends Component {
|
|
|
95
88
|
this.shouldClose = true;
|
|
96
89
|
}
|
|
97
90
|
onDocumentMouseUp(event) {
|
|
91
|
+
const {
|
|
92
|
+
onClose = noop
|
|
93
|
+
} = this.props;
|
|
98
94
|
const clickEventProperties = this.getClickEventProperties(event);
|
|
99
95
|
if (clickEventProperties.isNotLeftClick || clickEventProperties.isTargetClick || clickEventProperties.isPortalClick) {
|
|
100
96
|
this.shouldClose = false;
|
|
@@ -103,16 +99,20 @@ class Portal extends Component {
|
|
|
103
99
|
if (this.shouldClose) {
|
|
104
100
|
// `onClose` tells the consumer that they should change `isOpen` to false.
|
|
105
101
|
// Once the consumer has responded to `onClose`, `beforeClose` and `close` will be called.
|
|
106
|
-
|
|
102
|
+
onClose(event, {
|
|
107
103
|
source: 'DOCUMENT_CLICK'
|
|
108
104
|
});
|
|
109
105
|
}
|
|
110
106
|
}
|
|
111
107
|
onDocumentKeyDown(event) {
|
|
112
|
-
|
|
108
|
+
const {
|
|
109
|
+
closeOnEscPressed = true,
|
|
110
|
+
onClose = noop
|
|
111
|
+
} = this.props;
|
|
112
|
+
if (event.key === KEYCODES.ESCAPE && this.props.isOpen && closeOnEscPressed) {
|
|
113
113
|
// `onClose` tells the consumer that they should change `isOpen` to false.
|
|
114
114
|
// Once the consumer has responded to `onClose`, `beforeClose` and `close` will be called.
|
|
115
|
-
|
|
115
|
+
onClose(event, {
|
|
116
116
|
source: 'ESCAPE'
|
|
117
117
|
});
|
|
118
118
|
}
|
|
@@ -166,10 +166,13 @@ class Portal extends Component {
|
|
|
166
166
|
if (this.props.className) {
|
|
167
167
|
portalElement.className = this.props.className;
|
|
168
168
|
}
|
|
169
|
+
const {
|
|
170
|
+
onOpen = noop
|
|
171
|
+
} = this.props;
|
|
169
172
|
this.portalElement = portalElement;
|
|
170
173
|
this.setState({
|
|
171
174
|
isVisible: true
|
|
172
|
-
}, () =>
|
|
175
|
+
}, () => onOpen(portalElement, this.getTargetElement()));
|
|
173
176
|
}
|
|
174
177
|
close() {
|
|
175
178
|
if (!this.portalElement) {
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ReactElement, RefObject } from 'react';
|
|
2
2
|
type Props = {
|
|
3
3
|
appearClassName: string;
|
|
4
4
|
appearActiveClassName: string;
|
|
5
5
|
transitionTimeout: number;
|
|
6
|
-
children:
|
|
6
|
+
children: ReactElement<{
|
|
7
|
+
ref?: RefObject<HTMLElement | null>;
|
|
8
|
+
}>;
|
|
7
9
|
};
|
|
8
10
|
declare const TransitionInitialMount: ({ appearActiveClassName, appearClassName, children, transitionTimeout, }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
9
11
|
export default TransitionInitialMount;
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
+
import { cloneElement, useRef } from 'react';
|
|
19
20
|
// @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
|
|
20
21
|
import assign from 'object-assign';
|
|
21
22
|
import CSSTransition from 'react-transition-group/CSSTransition';
|
|
@@ -24,23 +25,31 @@ import CSSTransition from 'react-transition-group/CSSTransition';
|
|
|
24
25
|
// It will use the native implementation if it's present and isn't buggy.
|
|
25
26
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
26
27
|
Object.assign = assign;
|
|
28
|
+
// TODO: revisit the cloneElement pattern when react-transition-group v5 ships;
|
|
29
|
+
// it is expected to remove the nodeRef requirement.
|
|
27
30
|
const TransitionInitialMount = ({
|
|
28
31
|
appearActiveClassName,
|
|
29
32
|
appearClassName,
|
|
30
33
|
children,
|
|
31
34
|
transitionTimeout
|
|
32
|
-
}) =>
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
35
|
+
}) => {
|
|
36
|
+
const nodeRef = useRef(null);
|
|
37
|
+
return /*#__PURE__*/_jsx(CSSTransition, {
|
|
38
|
+
nodeRef: nodeRef,
|
|
39
|
+
classNames: {
|
|
40
|
+
appear: appearClassName,
|
|
41
|
+
appearActive: appearActiveClassName
|
|
42
|
+
},
|
|
43
|
+
in: true,
|
|
44
|
+
appear: true,
|
|
45
|
+
timeout: {
|
|
46
|
+
exit: 0,
|
|
47
|
+
enter: 0,
|
|
48
|
+
appear: transitionTimeout
|
|
49
|
+
},
|
|
50
|
+
children: /*#__PURE__*/cloneElement(children, {
|
|
51
|
+
ref: nodeRef
|
|
52
|
+
})
|
|
53
|
+
});
|
|
54
|
+
};
|
|
46
55
|
export default TransitionInitialMount;
|
|
@@ -54,13 +54,6 @@ declare const _default: {
|
|
|
54
54
|
UNSAFE_componentWillUpdate?(nextProps: Readonly<import("./src/withScrim").Props & Omit<P, "dialogRef">>, nextState: Readonly<{}>, nextContext: any): void;
|
|
55
55
|
};
|
|
56
56
|
displayName: string;
|
|
57
|
-
defaultProps: {
|
|
58
|
-
onClose: null;
|
|
59
|
-
isIphone: boolean;
|
|
60
|
-
isIpad: boolean;
|
|
61
|
-
containerClassName: null;
|
|
62
|
-
closeOnScrimClick: boolean;
|
|
63
|
-
};
|
|
64
57
|
contextType?: import("react").Context<any> | undefined;
|
|
65
58
|
};
|
|
66
59
|
};
|
|
@@ -72,13 +72,6 @@ declare const withScrim: <P extends object>(WrappedComponent: ComponentType<P> |
|
|
|
72
72
|
UNSAFE_componentWillUpdate?(nextProps: Readonly<Props & Omit<P, "dialogRef">>, nextState: Readonly<{}>, nextContext: any): void;
|
|
73
73
|
};
|
|
74
74
|
displayName: string;
|
|
75
|
-
defaultProps: {
|
|
76
|
-
onClose: null;
|
|
77
|
-
isIphone: boolean;
|
|
78
|
-
isIpad: boolean;
|
|
79
|
-
containerClassName: null;
|
|
80
|
-
closeOnScrimClick: boolean;
|
|
81
|
-
};
|
|
82
75
|
contextType?: import("react").Context<any> | undefined;
|
|
83
76
|
};
|
|
84
77
|
export default withScrim;
|
|
@@ -25,20 +25,15 @@ import { fixBody, lockScroll, lockTouchAction, restoreScroll, storeScroll, unfix
|
|
|
25
25
|
import STYLES from "./bpk-scrim-content.module.css";
|
|
26
26
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
27
27
|
const getClassName = cssModules(STYLES);
|
|
28
|
+
const DEFAULT_IS_IPHONE = isDeviceIphone();
|
|
29
|
+
const DEFAULT_IS_IPAD = isDeviceIpad();
|
|
28
30
|
const withScrim = WrappedComponent => {
|
|
29
31
|
class WithScrim extends Component {
|
|
30
|
-
static defaultProps = {
|
|
31
|
-
onClose: null,
|
|
32
|
-
isIphone: isDeviceIphone(),
|
|
33
|
-
isIpad: isDeviceIpad(),
|
|
34
|
-
containerClassName: null,
|
|
35
|
-
closeOnScrimClick: true
|
|
36
|
-
};
|
|
37
32
|
componentDidMount() {
|
|
38
33
|
const {
|
|
39
34
|
getApplicationElement,
|
|
40
|
-
isIpad,
|
|
41
|
-
isIphone
|
|
35
|
+
isIpad = DEFAULT_IS_IPAD,
|
|
36
|
+
isIphone = DEFAULT_IS_IPHONE
|
|
42
37
|
} = this.props;
|
|
43
38
|
const applicationElement = getApplicationElement();
|
|
44
39
|
|
|
@@ -73,8 +68,8 @@ const withScrim = WrappedComponent => {
|
|
|
73
68
|
componentWillUnmount() {
|
|
74
69
|
const {
|
|
75
70
|
getApplicationElement,
|
|
76
|
-
isIpad,
|
|
77
|
-
isIphone
|
|
71
|
+
isIpad = DEFAULT_IS_IPAD,
|
|
72
|
+
isIphone = DEFAULT_IS_IPHONE
|
|
78
73
|
} = this.props;
|
|
79
74
|
const applicationElement = getApplicationElement();
|
|
80
75
|
if (isIphone || isIpad) {
|
|
@@ -96,11 +91,11 @@ const withScrim = WrappedComponent => {
|
|
|
96
91
|
};
|
|
97
92
|
render() {
|
|
98
93
|
const {
|
|
99
|
-
closeOnScrimClick,
|
|
100
|
-
containerClassName,
|
|
94
|
+
closeOnScrimClick = true,
|
|
95
|
+
containerClassName = null,
|
|
101
96
|
getApplicationElement,
|
|
102
|
-
isIpad,
|
|
103
|
-
isIphone,
|
|
97
|
+
isIpad = DEFAULT_IS_IPAD,
|
|
98
|
+
isIphone = DEFAULT_IS_IPHONE,
|
|
104
99
|
onClose,
|
|
105
100
|
...rest
|
|
106
101
|
} = this.props;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skyscanner/backpack-web",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "43.0.0",
|
|
4
4
|
"description": "Backpack Design System web library",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -50,8 +50,8 @@
|
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
52
|
"date-fns": "3.3.1 - 4",
|
|
53
|
-
"react": "
|
|
54
|
-
"react-dom": "
|
|
53
|
+
"react": "18.3.1 - 19.2.5",
|
|
54
|
+
"react-dom": "18.3.1 - 19.2.5",
|
|
55
55
|
"react-transition-group": "^4.4.5",
|
|
56
56
|
"sass": "^1",
|
|
57
57
|
"sass-embedded": "^1"
|
|
@@ -1,74 +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 PropTypes from 'prop-types';
|
|
20
|
-
import { isDeviceIphone } from "../../bpk-react-utils";
|
|
21
|
-
import { titlePropType, onClosePropType } from "./customPropTypes";
|
|
22
|
-
const modalDialogPropTypes = {
|
|
23
|
-
id: PropTypes.string.isRequired,
|
|
24
|
-
children: PropTypes.node.isRequired,
|
|
25
|
-
isIphone: PropTypes.bool.isRequired,
|
|
26
|
-
dialogRef: PropTypes.func.isRequired,
|
|
27
|
-
title: titlePropType,
|
|
28
|
-
onClose: onClosePropType,
|
|
29
|
-
className: PropTypes.string,
|
|
30
|
-
contentClassName: PropTypes.string,
|
|
31
|
-
closeLabel: PropTypes.string,
|
|
32
|
-
closeText: PropTypes.string,
|
|
33
|
-
wide: PropTypes.bool,
|
|
34
|
-
showHeader: PropTypes.bool,
|
|
35
|
-
fullScreenOnMobile: PropTypes.bool,
|
|
36
|
-
fullScreen: PropTypes.bool,
|
|
37
|
-
padded: PropTypes.bool,
|
|
38
|
-
accesoryView: PropTypes.func
|
|
39
|
-
};
|
|
40
|
-
const modalDialogDefaultProps = {
|
|
41
|
-
title: null,
|
|
42
|
-
onClose: () => null,
|
|
43
|
-
className: null,
|
|
44
|
-
contentClassName: null,
|
|
45
|
-
closeLabel: '',
|
|
46
|
-
closeText: null,
|
|
47
|
-
wide: false,
|
|
48
|
-
showHeader: true,
|
|
49
|
-
fullScreenOnMobile: true,
|
|
50
|
-
fullScreen: false,
|
|
51
|
-
padded: true,
|
|
52
|
-
accessoryView: null
|
|
53
|
-
};
|
|
54
|
-
const {
|
|
55
|
-
dialogRef,
|
|
56
|
-
...newModalDialogPropTypes
|
|
57
|
-
} = modalDialogPropTypes;
|
|
58
|
-
export const propTypes = {
|
|
59
|
-
...newModalDialogPropTypes,
|
|
60
|
-
onClose: PropTypes.func,
|
|
61
|
-
isIphone: PropTypes.bool,
|
|
62
|
-
isOpen: PropTypes.bool.isRequired,
|
|
63
|
-
renderTarget: PropTypes.func,
|
|
64
|
-
closeOnScrimClick: PropTypes.bool,
|
|
65
|
-
closeOnEscPressed: PropTypes.bool
|
|
66
|
-
};
|
|
67
|
-
export const defaultProps = {
|
|
68
|
-
...modalDialogDefaultProps,
|
|
69
|
-
onClose: () => null,
|
|
70
|
-
renderTarget: null,
|
|
71
|
-
isIphone: isDeviceIphone(),
|
|
72
|
-
closeOnScrimClick: true,
|
|
73
|
-
closeOnEscPressed: true
|
|
74
|
-
};
|