@skyscanner/backpack-web 23.2.2 → 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 (133) hide show
  1. package/bpk-component-aria-live/src/BpkAriaLive.js +0 -1
  2. package/bpk-component-badge/src/BpkBadge.js +0 -1
  3. package/{bpk-scrim-utils/src/customPropTypes.js → bpk-component-banner-alert/index.d.ts} +16 -14
  4. package/bpk-component-banner-alert/src/AnimateAndFade.d.ts +61 -0
  5. package/bpk-component-banner-alert/src/AnimateAndFade.js +3 -9
  6. package/bpk-component-banner-alert/src/BpkBannerAlert.d.ts +29 -0
  7. package/bpk-component-banner-alert/src/BpkBannerAlert.js +42 -21
  8. package/bpk-component-banner-alert/src/BpkBannerAlertDismissable.d.ts +30 -0
  9. package/bpk-component-banner-alert/src/BpkBannerAlertDismissable.js +31 -33
  10. package/bpk-component-banner-alert/src/BpkBannerAlertExpandable.d.ts +35 -0
  11. package/bpk-component-banner-alert/src/BpkBannerAlertExpandable.js +15 -28
  12. package/bpk-component-banner-alert/src/BpkBannerAlertInner.d.ts +58 -0
  13. package/bpk-component-banner-alert/src/BpkBannerAlertInner.js +65 -87
  14. package/bpk-component-banner-alert/src/common-types.d.ts +44 -0
  15. package/bpk-component-banner-alert/src/common-types.js +5 -23
  16. package/bpk-component-banner-alert/src/themeAttributes.d.ts +20 -0
  17. package/bpk-component-banner-alert/src/withBannerAlertState.d.ts +169 -0
  18. package/bpk-component-banner-alert/src/withBannerAlertState.js +10 -29
  19. package/bpk-component-boilerplate/src/BpkBoilerplate.js +0 -1
  20. package/bpk-component-button/src/BpkButtonV2/BpkButton.js +0 -1
  21. package/bpk-component-calendar/index.d.ts +30 -0
  22. package/bpk-component-calendar/index.js +5 -4
  23. package/bpk-component-calendar/src/BpkCalendarContainer.d.ts +464 -0
  24. package/bpk-component-calendar/src/BpkCalendarContainer.js +19 -29
  25. package/bpk-component-calendar/src/BpkCalendarDate.d.ts +62 -0
  26. package/bpk-component-calendar/src/BpkCalendarDate.js +15 -39
  27. package/bpk-component-calendar/src/BpkCalendarGrid.d.ts +68 -0
  28. package/bpk-component-calendar/src/BpkCalendarGrid.js +9 -40
  29. package/bpk-component-calendar/src/BpkCalendarGridHeader.d.ts +36 -0
  30. package/bpk-component-calendar/src/BpkCalendarGridHeader.js +33 -52
  31. package/bpk-component-calendar/src/BpkCalendarGridTransition.d.ts +56 -0
  32. package/bpk-component-calendar/src/BpkCalendarGridTransition.js +43 -42
  33. package/bpk-component-calendar/src/BpkCalendarNav.d.ts +37 -0
  34. package/bpk-component-calendar/src/BpkCalendarNav.js +18 -32
  35. package/bpk-component-calendar/src/Week.d.ts +51 -0
  36. package/bpk-component-calendar/src/Week.js +48 -70
  37. package/bpk-component-calendar/src/composeCalendar.d.ts +55 -0
  38. package/bpk-component-calendar/src/composeCalendar.js +34 -95
  39. package/bpk-component-calendar/src/custom-proptypes-legacy.js +140 -0
  40. package/bpk-component-calendar/src/custom-proptypes.d.ts +46 -0
  41. package/bpk-component-calendar/src/custom-proptypes.js +2 -61
  42. package/bpk-component-calendar/src/date-utils.d.ts +54 -0
  43. package/bpk-component-calendar/src/utils.d.ts +26 -0
  44. package/bpk-component-calendar/src/utils.js +1 -0
  45. package/bpk-component-calendar/test-utils.d.ts +56 -0
  46. package/bpk-component-calendar/test-utils.js +2 -2
  47. package/bpk-component-card/index.d.ts +24 -0
  48. package/bpk-component-card/src/BpkCard.d.ts +39 -0
  49. package/bpk-component-card/src/BpkCard.js +9 -25
  50. package/bpk-component-card/src/BpkCardWrapper.d.ts +33 -0
  51. package/bpk-component-card/src/BpkCardWrapper.js +10 -18
  52. package/bpk-component-card/src/BpkDividedCard.d.ts +43 -0
  53. package/bpk-component-card/src/BpkDividedCard.js +9 -24
  54. package/bpk-component-chip/index.d.ts +32 -0
  55. package/bpk-component-chip/src/BpkDismissibleChip.d.ts +28 -0
  56. package/bpk-component-chip/src/BpkDismissibleChip.js +9 -8
  57. package/bpk-component-chip/src/BpkDropdownChip.d.ts +29 -0
  58. package/bpk-component-chip/src/BpkDropdownChip.js +39 -25
  59. package/bpk-component-chip/src/BpkSelectableChip.d.ts +39 -0
  60. package/bpk-component-chip/src/BpkSelectableChip.js +33 -48
  61. package/bpk-component-chip/src/commonTypes.d.ts +56 -0
  62. package/bpk-component-chip/src/commonTypes.js +8 -2
  63. package/bpk-component-dialog/src/BpkDialog.d.ts +1 -12
  64. package/bpk-component-dialog/src/BpkDialog.js +1 -2
  65. package/bpk-component-dialog/src/BpkDialogInner.d.ts +256 -2
  66. package/bpk-component-dialog/src/BpkDialogInner.js +0 -4
  67. package/bpk-component-dialog/src/common-types.d.ts +20 -21
  68. package/bpk-component-graphic-promotion/src/BpkGraphicPromo.js +0 -4
  69. package/bpk-component-icon/src/classNameModifierHOCFactory.js +0 -1
  70. package/bpk-component-icon/src/withAlignment.js +1 -1
  71. package/bpk-component-icon/src/withDescription.js +1 -1
  72. package/bpk-component-icon/src/withRtlSupport.js +0 -2
  73. package/bpk-component-input/index.d.ts +39 -0
  74. package/bpk-component-input/src/BpkClearButton.d.ts +28 -0
  75. package/bpk-component-input/src/BpkClearButton.js +6 -14
  76. package/bpk-component-input/src/BpkInput.d.ts +46 -0
  77. package/bpk-component-input/src/BpkInput.js +7 -3
  78. package/bpk-component-input/src/common-types.d.ts +91 -0
  79. package/bpk-component-input/src/common-types.js +4 -1
  80. package/bpk-component-input/src/withOpenEvents.d.ts +121 -0
  81. package/bpk-component-input/src/withOpenEvents.js +14 -25
  82. package/bpk-component-modal/index.d.ts +26 -0
  83. package/bpk-component-modal/index.js +13 -6
  84. package/bpk-component-modal/src/BpkModal.d.ts +32 -0
  85. package/bpk-component-modal/src/BpkModal.js +24 -44
  86. package/bpk-component-modal/src/BpkModalInner.d.ts +39 -0
  87. package/bpk-component-modal/src/BpkModalInner.js +67 -84
  88. package/bpk-component-modal/src/BpkModalV2/BpKModal.module.css +18 -0
  89. package/bpk-component-modal/src/BpkModalV2/BpkModal.d.ts +35 -0
  90. package/bpk-component-modal/src/BpkModalV2/BpkModal.js +131 -0
  91. package/bpk-component-modal/src/legacy-prop-types.js +86 -0
  92. package/bpk-component-modal/src/themeAttributes.js +1 -0
  93. package/bpk-component-rtl-toggle/index.d.ts +23 -0
  94. package/bpk-component-rtl-toggle/src/BpkRtlToggle.d.ts +41 -0
  95. package/bpk-component-rtl-toggle/src/BpkRtlToggle.js +9 -12
  96. package/bpk-component-rtl-toggle/src/updateOnDirectionChange.d.ts +151 -0
  97. package/bpk-component-rtl-toggle/src/updateOnDirectionChange.js +9 -2
  98. package/bpk-component-rtl-toggle/src/utils.d.ts +25 -0
  99. package/bpk-component-text/index.d.ts +21 -0
  100. package/bpk-component-text/index.js +0 -6
  101. package/bpk-component-text/src/BpkText.d.ts +60 -0
  102. package/bpk-component-text/src/BpkText.js +16 -56
  103. package/bpk-component-text/src/BpkText.module.css +1 -1
  104. package/bpk-component-tooltip/index.d.ts +24 -0
  105. package/bpk-component-tooltip/src/BpkTooltip.d.ts +29 -0
  106. package/bpk-component-tooltip/src/BpkTooltip.js +9 -26
  107. package/bpk-component-tooltip/src/BpkTooltipPortal.d.ts +60 -0
  108. package/bpk-component-tooltip/src/BpkTooltipPortal.js +13 -21
  109. package/bpk-component-tooltip/src/constants.d.ts +31 -0
  110. package/bpk-component-tooltip/src/constants.js +3 -1
  111. package/bpk-react-utils/index.d.ts +58 -0
  112. package/bpk-react-utils/index.js +1 -0
  113. package/bpk-react-utils/src/Portal.d.ts +76 -0
  114. package/bpk-react-utils/src/Portal.js +33 -43
  115. package/bpk-react-utils/src/TransitionInitialMount.d.ts +27 -0
  116. package/bpk-react-utils/src/TransitionInitialMount.js +7 -8
  117. package/bpk-react-utils/src/cssModules.d.ts +22 -0
  118. package/bpk-react-utils/src/deprecated.js +2 -1
  119. package/bpk-react-utils/src/deviceDetection.d.ts +22 -0
  120. package/bpk-react-utils/src/deviceDetection.js +3 -1
  121. package/bpk-react-utils/src/isRTL.d.ts +20 -0
  122. package/bpk-react-utils/src/isRTL.js +3 -1
  123. package/bpk-react-utils/src/withDefaultProps.d.ts +33 -0
  124. package/bpk-react-utils/src/withDefaultProps.js +11 -24
  125. package/bpk-react-utils/src/wrapDisplayName.d.ts +21 -0
  126. package/bpk-scrim-utils/index.d.ts +283 -0
  127. package/bpk-scrim-utils/src/BpkScrim.d.ts +24 -0
  128. package/bpk-scrim-utils/src/BpkScrim.js +5 -10
  129. package/bpk-scrim-utils/src/scroll-utils.d.ts +24 -0
  130. package/bpk-scrim-utils/src/scroll-utils.js +1 -1
  131. package/bpk-scrim-utils/src/withScrim.d.ts +96 -0
  132. package/bpk-scrim-utils/src/withScrim.js +5 -12
  133. package/package.json +1 -1
@@ -0,0 +1,46 @@
1
+ /*
2
+ * Backpack - Skyscanner's Design System
3
+ *
4
+ * Copyright 2016 Skyscanner Ltd
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+
19
+ import { Component } from 'react';
20
+
21
+ import type { Props } from './common-types';
22
+
23
+ type State = {
24
+ persistClearButton: boolean;
25
+ };
26
+ declare class BpkInput extends Component<Props, State> {
27
+ static defaultProps: {
28
+ type: 'text';
29
+ className: null;
30
+ valid: null;
31
+ large: boolean;
32
+ docked: boolean;
33
+ dockedFirst: boolean;
34
+ dockedMiddle: boolean;
35
+ dockedLast: boolean;
36
+ inputRef: null;
37
+ clearButtonMode: 'never';
38
+ clearButtonLabel: null;
39
+ onClear: null;
40
+ };
41
+
42
+ constructor(props: Props);
43
+
44
+ render(): JSX.Element;
45
+ }
46
+ export default BpkInput;
@@ -134,7 +134,7 @@ class BpkInput extends _react.Component {
134
134
  return clearable ? /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
135
135
  className: containerClassNames.join(' '),
136
136
  children: [renderedInput, value.length > 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)(_BpkClearButton.default, {
137
- tabIndex: "-1",
137
+ tabIndex: -1,
138
138
  label: clearButtonLabel || '',
139
139
  onMouseDown: onMouseDown,
140
140
  onClick: e => {
@@ -142,7 +142,12 @@ class BpkInput extends _react.Component {
142
142
  ref.focus();
143
143
  }
144
144
  if (onClear) {
145
- e.target.name = name;
145
+ if (e.target instanceof HTMLButtonElement) {
146
+ const {
147
+ target
148
+ } = e;
149
+ target.name = name;
150
+ }
146
151
  onClear(e);
147
152
  this.setState({
148
153
  persistClearButton: false
@@ -154,7 +159,6 @@ class BpkInput extends _react.Component {
154
159
  }) : renderedInput;
155
160
  }
156
161
  }
157
- _defineProperty(BpkInput, "propTypes", _commonTypes.propTypes);
158
162
  _defineProperty(BpkInput, "defaultProps", _commonTypes.defaultProps);
159
163
  var _default = BpkInput;
160
164
  exports.default = _default;
@@ -0,0 +1,91 @@
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 PropTypes from 'prop-types';
20
+ import type { SyntheticEvent } from 'react';
21
+ export declare const CLEAR_BUTTON_MODES: {
22
+ readonly never: "never";
23
+ readonly whileEditing: "whileEditing";
24
+ readonly always: "always";
25
+ };
26
+ export declare const INPUT_TYPES: {
27
+ readonly text: "text";
28
+ readonly email: "email";
29
+ readonly number: "number";
30
+ readonly password: "password";
31
+ readonly tel: "tel";
32
+ };
33
+ type BaseProps = {
34
+ id: string;
35
+ name: string;
36
+ value: string;
37
+ type?: typeof INPUT_TYPES[keyof typeof INPUT_TYPES];
38
+ className?: string | null;
39
+ valid?: boolean | null;
40
+ large?: boolean;
41
+ docked?: boolean;
42
+ dockedFirst?: boolean;
43
+ dockedMiddle?: boolean;
44
+ dockedLast?: boolean;
45
+ inputRef?: ((ref: HTMLInputElement) => void) | null;
46
+ [rest: string]: any;
47
+ };
48
+ export type PropsWithoutClearButonMode = BaseProps & {
49
+ clearButtonMode?: 'never';
50
+ clearButtonLabel?: string | null;
51
+ onClear?: ((e?: SyntheticEvent<HTMLButtonElement>) => void) | null;
52
+ };
53
+ export type PropsWithClearButtonMode = BaseProps & {
54
+ clearButtonMode: typeof CLEAR_BUTTON_MODES[keyof Omit<typeof CLEAR_BUTTON_MODES, 'never'>];
55
+ clearButtonLabel: string;
56
+ onClear: (e?: SyntheticEvent<HTMLButtonElement>) => void;
57
+ };
58
+ export type Props = PropsWithoutClearButonMode | PropsWithClearButtonMode;
59
+ export declare const clearablePropType: (props: any, propName: string, componentName: string) => Error | null;
60
+ export declare const propTypes: {
61
+ id: PropTypes.Validator<string>;
62
+ name: PropTypes.Validator<string>;
63
+ value: PropTypes.Validator<string>;
64
+ type: PropTypes.Requireable<"number" | "text" | "tel" | "email" | "password">;
65
+ className: PropTypes.Requireable<string>;
66
+ valid: PropTypes.Requireable<boolean>;
67
+ large: PropTypes.Requireable<boolean>;
68
+ docked: PropTypes.Requireable<boolean>;
69
+ dockedFirst: PropTypes.Requireable<boolean>;
70
+ dockedMiddle: PropTypes.Requireable<boolean>;
71
+ dockedLast: PropTypes.Requireable<boolean>;
72
+ inputRef: PropTypes.Requireable<(...args: any[]) => any>;
73
+ clearButtonMode: PropTypes.Requireable<string>;
74
+ clearButtonLabel: (props: any, propName: string, componentName: string) => Error | null;
75
+ onClear: (props: any, propName: string, componentName: string) => Error | null;
76
+ };
77
+ export declare const defaultProps: {
78
+ type: "text";
79
+ className: null;
80
+ valid: null;
81
+ large: boolean;
82
+ docked: boolean;
83
+ dockedFirst: boolean;
84
+ dockedMiddle: boolean;
85
+ dockedLast: boolean;
86
+ inputRef: null;
87
+ clearButtonMode: "never";
88
+ clearButtonLabel: null;
89
+ onClear: null;
90
+ };
91
+ export {};
@@ -22,7 +22,9 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
22
22
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23
23
  * See the License for the specific language governing permissions and
24
24
  * limitations under the License.
25
- */const CLEAR_BUTTON_MODES = {
25
+ */
26
+
27
+ const CLEAR_BUTTON_MODES = {
26
28
  never: 'never',
27
29
  whileEditing: 'whileEditing',
28
30
  always: 'always'
@@ -36,6 +38,7 @@ const INPUT_TYPES = {
36
38
  tel: 'tel'
37
39
  };
38
40
  exports.INPUT_TYPES = INPUT_TYPES;
41
+ // TODO - this function should be removed once all input examples have been migrated to TS
39
42
  const clearablePropType = (props, propName, componentName) => {
40
43
  const createError = message => new Error(`Invalid prop \`${propName}\` supplied to \`${componentName}\`. ${message}.`);
41
44
  const propBeingChecked = props[propName];
@@ -0,0 +1,121 @@
1
+ /*
2
+ * Backpack - Skyscanner's Design System
3
+ *
4
+ * Copyright 2016 Skyscanner Ltd
5
+ *
6
+ * Licensed under the Apache License, Version 2.0 (the "License");
7
+ * you may not use this file except in compliance with the License.
8
+ * You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing, software
13
+ * distributed under the License is distributed on an "AS IS" BASIS,
14
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ * See the License for the specific language governing permissions and
16
+ * limitations under the License.
17
+ */
18
+
19
+ import type { ComponentType, ReactElement, UIEvent } from 'react';
20
+
21
+ type WithOpenEventsProps = {
22
+ isOpen?: boolean;
23
+ onOpen?: () => void;
24
+ hasTouchSupport?: boolean;
25
+ };
26
+ type InputProps = {
27
+ className?: string | null;
28
+ onClick?: (event: UIEvent) => void;
29
+ onFocus?: (event: UIEvent) => void;
30
+ onBlur?: (event: UIEvent) => void;
31
+ onTouchEnd?: (event: UIEvent) => void;
32
+ onKeyDown?: (event: UIEvent) => void;
33
+ onKeyUp?: (event: UIEvent) => void;
34
+ };
35
+ declare const withOpenEvents: <P extends InputProps>(
36
+ InputComponent: ComponentType<P>,
37
+ ) => {
38
+ new (props: P & WithOpenEventsProps): {
39
+ focusCanOpen: boolean;
40
+ handleTouchEnd: (event: UIEvent) => void;
41
+ handleFocus: () => void;
42
+ handleBlur: () => void;
43
+ render(): ReactElement;
44
+ context: any;
45
+ setState<K extends never>(
46
+ state:
47
+ | {}
48
+ | ((
49
+ prevState: Readonly<{}>,
50
+ props: Readonly<P & WithOpenEventsProps>, // eslint-disable-line no-shadow
51
+ ) => {} | Pick<{}, K> | null)
52
+ | Pick<{}, K>
53
+ | null,
54
+ callback?: (() => void) | undefined,
55
+ ): void;
56
+ forceUpdate(callback?: (() => void) | undefined): void;
57
+ readonly props: Readonly<P & WithOpenEventsProps> &
58
+ Readonly<{
59
+ children?: import('react').ReactNode;
60
+ }>;
61
+ state: Readonly<{}>;
62
+ refs: {
63
+ [key: string]: import('react').ReactInstance;
64
+ };
65
+ componentDidMount?(): void;
66
+ shouldComponentUpdate?(
67
+ nextProps: Readonly<P & WithOpenEventsProps>,
68
+ nextState: Readonly<{}>,
69
+ nextContext: any,
70
+ ): boolean;
71
+ componentWillUnmount?(): void;
72
+ componentDidCatch?(
73
+ error: Error,
74
+ errorInfo: import('react').ErrorInfo,
75
+ ): void;
76
+ getSnapshotBeforeUpdate?(
77
+ prevProps: Readonly<P & WithOpenEventsProps>,
78
+ prevState: Readonly<{}>,
79
+ ): any;
80
+ componentDidUpdate?(
81
+ prevProps: Readonly<P & WithOpenEventsProps>,
82
+ prevState: Readonly<{}>,
83
+ snapshot?: any,
84
+ ): void;
85
+ componentWillMount?(): void;
86
+ UNSAFE_componentWillMount?(): void;
87
+ componentWillReceiveProps?(
88
+ nextProps: Readonly<P & WithOpenEventsProps>,
89
+ nextContext: any,
90
+ ): void;
91
+ UNSAFE_componentWillReceiveProps?(
92
+ nextProps: Readonly<P & WithOpenEventsProps>,
93
+ nextContext: any,
94
+ ): void;
95
+ componentWillUpdate?(
96
+ nextProps: Readonly<P & WithOpenEventsProps>,
97
+ nextState: Readonly<{}>,
98
+ nextContext: any,
99
+ ): void;
100
+ UNSAFE_componentWillUpdate?(
101
+ nextProps: Readonly<P & WithOpenEventsProps>,
102
+ nextState: Readonly<{}>,
103
+ nextContext: any,
104
+ ): void;
105
+ };
106
+ displayName: string;
107
+ defaultProps: {
108
+ isOpen: boolean;
109
+ hasTouchSupport: boolean;
110
+ onOpen: null;
111
+ className: null;
112
+ onClick: null;
113
+ onFocus: null;
114
+ onBlur: null;
115
+ onTouchEnd: null;
116
+ onKeyDown: null;
117
+ onKeyUp: null;
118
+ };
119
+ contextType?: import('react').Context<any> | undefined;
120
+ };
121
+ export default withOpenEvents;
@@ -5,11 +5,10 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var _react = require("react");
8
- var _propTypes = _interopRequireDefault(require("prop-types"));
9
8
  var _bpkReactUtils = require("../../bpk-react-utils");
10
9
  var _BpkInputModule = _interopRequireDefault(require("./BpkInput.module.css"));
11
10
  var _jsxRuntime = require("react/jsx-runtime");
12
- const _excluded = ["className", "hasTouchSupport", "onBlur", "onClick", "onFocus", "onKeyDown", "onKeyUp", "onOpen", "onTouchEnd"];
11
+ const _excluded = ["className", "hasTouchSupport", "isOpen", "onBlur", "onClick", "onFocus", "onKeyDown", "onKeyUp", "onOpen", "onTouchEnd"];
13
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
13
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
15
14
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
@@ -40,13 +39,17 @@ const KEYCODES = {
40
39
  SPACEBAR: 32
41
40
  };
42
41
  const handleKeyEvent = (keyCode, callback) => e => {
43
- if (e.keyCode === keyCode) {
42
+ if (e instanceof KeyboardEvent && e.keyCode === keyCode) {
44
43
  e.preventDefault();
45
- callback();
44
+ if (callback) {
45
+ callback();
46
+ }
46
47
  }
47
48
  };
48
49
  const withEventHandler = (fn, eventHandler) => e => {
49
- fn(e);
50
+ if (fn) {
51
+ fn(e);
52
+ }
50
53
  if (eventHandler) {
51
54
  eventHandler(e);
52
55
  }
@@ -55,6 +58,7 @@ const withOpenEvents = InputComponent => {
55
58
  class WithOpenEvents extends _react.Component {
56
59
  constructor(props) {
57
60
  super(props);
61
+ _defineProperty(this, "focusCanOpen", void 0);
58
62
  _defineProperty(this, "handleTouchEnd", event => {
59
63
  // preventDefault fixes an issue on Android and iOS in which the popover closes immediately
60
64
  // because a touch event is registered on one of the dates.
@@ -89,6 +93,7 @@ const withOpenEvents = InputComponent => {
89
93
  {
90
94
  className,
91
95
  hasTouchSupport,
96
+ isOpen,
92
97
  onBlur,
93
98
  onClick,
94
99
  onFocus,
@@ -98,7 +103,6 @@ const withOpenEvents = InputComponent => {
98
103
  onTouchEnd
99
104
  } = _this$props,
100
105
  rest = _objectWithoutProperties(_this$props, _excluded);
101
- delete rest.isOpen;
102
106
  const classNames = [getClassName('bpk-input--with-open-events')];
103
107
  if (className) {
104
108
  classNames.push(className);
@@ -124,26 +128,11 @@ const withOpenEvents = InputComponent => {
124
128
  }, eventHandlers), rest));
125
129
  }
126
130
  }
127
- WithOpenEvents.propTypes = {
128
- // Custom props
129
- isOpen: _propTypes.default.bool,
130
- hasTouchSupport: _propTypes.default.bool,
131
- onOpen: _propTypes.default.func,
132
- // Input props
133
- className: _propTypes.default.string,
134
- onClick: _propTypes.default.func,
135
- onFocus: _propTypes.default.func,
136
- onBlur: _propTypes.default.func,
137
- onTouchEnd: _propTypes.default.func,
138
- onKeyDown: _propTypes.default.func,
139
- onKeyUp: _propTypes.default.func
140
- };
141
- WithOpenEvents.defaultProps = {
131
+ _defineProperty(WithOpenEvents, "displayName", void 0);
132
+ _defineProperty(WithOpenEvents, "defaultProps", {
142
133
  // Custom props
143
134
  isOpen: false,
144
- hasTouchSupport: !!(typeof window !== 'undefined' && ('ontouchstart' in window ||
145
- // eslint-disable-next-line no-undef
146
- window.DocumentTouch && document instanceof DocumentTouch)),
135
+ hasTouchSupport: !!(typeof window !== 'undefined' && 'ontouchstart' in window),
147
136
  onOpen: null,
148
137
  // Input props
149
138
  className: null,
@@ -153,7 +142,7 @@ const withOpenEvents = InputComponent => {
153
142
  onTouchEnd: null,
154
143
  onKeyDown: null,
155
144
  onKeyUp: null
156
- };
145
+ });
157
146
  WithOpenEvents.displayName = (0, _bpkReactUtils.wrapDisplayName)(InputComponent, 'withOpenEvents');
158
147
  return WithOpenEvents;
159
148
  };
@@ -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 };
@@ -3,17 +3,23 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ Object.defineProperty(exports, "BpkModalV2", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _BpkModal.BpkModalV2;
10
+ }
11
+ });
6
12
  exports.default = void 0;
7
13
  Object.defineProperty(exports, "defaultProps", {
8
14
  enumerable: true,
9
15
  get: function () {
10
- return _BpkModal.defaultProps;
16
+ return _legacyPropTypes.defaultProps;
11
17
  }
12
18
  });
13
19
  Object.defineProperty(exports, "propTypes", {
14
20
  enumerable: true,
15
21
  get: function () {
16
- return _BpkModal.propTypes;
22
+ return _legacyPropTypes.propTypes;
17
23
  }
18
24
  });
19
25
  Object.defineProperty(exports, "themeAttributes", {
@@ -22,10 +28,10 @@ Object.defineProperty(exports, "themeAttributes", {
22
28
  return _themeAttributes.default;
23
29
  }
24
30
  });
31
+ var _BpkModal = require("./src/BpkModalV2/BpkModal");
25
32
  var _themeAttributes = _interopRequireDefault(require("./src/themeAttributes"));
26
- var _BpkModal = _interopRequireWildcard(require("./src/BpkModal"));
27
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
28
- 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");
29
35
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
30
36
  /*
31
37
  * Backpack - Skyscanner's Design System
@@ -44,5 +50,6 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
44
50
  * See the License for the specific language governing permissions and
45
51
  * limitations under the License.
46
52
  */
47
- var _default = _BpkModal.default;
53
+ // @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
54
+ var _default = _BpkModal2.default;
48
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;