@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.
- package/bpk-component-aria-live/src/BpkAriaLive.js +0 -1
- package/bpk-component-badge/src/BpkBadge.js +0 -1
- package/{bpk-scrim-utils/src/customPropTypes.js → bpk-component-banner-alert/index.d.ts} +16 -14
- package/bpk-component-banner-alert/src/AnimateAndFade.d.ts +61 -0
- package/bpk-component-banner-alert/src/AnimateAndFade.js +3 -9
- package/bpk-component-banner-alert/src/BpkBannerAlert.d.ts +29 -0
- package/bpk-component-banner-alert/src/BpkBannerAlert.js +42 -21
- package/bpk-component-banner-alert/src/BpkBannerAlertDismissable.d.ts +30 -0
- package/bpk-component-banner-alert/src/BpkBannerAlertDismissable.js +31 -33
- package/bpk-component-banner-alert/src/BpkBannerAlertExpandable.d.ts +35 -0
- package/bpk-component-banner-alert/src/BpkBannerAlertExpandable.js +15 -28
- package/bpk-component-banner-alert/src/BpkBannerAlertInner.d.ts +58 -0
- package/bpk-component-banner-alert/src/BpkBannerAlertInner.js +65 -87
- package/bpk-component-banner-alert/src/common-types.d.ts +44 -0
- package/bpk-component-banner-alert/src/common-types.js +5 -23
- package/bpk-component-banner-alert/src/themeAttributes.d.ts +20 -0
- package/bpk-component-banner-alert/src/withBannerAlertState.d.ts +169 -0
- package/bpk-component-banner-alert/src/withBannerAlertState.js +10 -29
- package/bpk-component-boilerplate/src/BpkBoilerplate.js +0 -1
- package/bpk-component-button/src/BpkButtonV2/BpkButton.js +0 -1
- package/bpk-component-calendar/index.d.ts +30 -0
- package/bpk-component-calendar/index.js +5 -4
- package/bpk-component-calendar/src/BpkCalendarContainer.d.ts +464 -0
- package/bpk-component-calendar/src/BpkCalendarContainer.js +19 -29
- package/bpk-component-calendar/src/BpkCalendarDate.d.ts +62 -0
- package/bpk-component-calendar/src/BpkCalendarDate.js +15 -39
- package/bpk-component-calendar/src/BpkCalendarGrid.d.ts +68 -0
- package/bpk-component-calendar/src/BpkCalendarGrid.js +9 -40
- package/bpk-component-calendar/src/BpkCalendarGridHeader.d.ts +36 -0
- package/bpk-component-calendar/src/BpkCalendarGridHeader.js +33 -52
- package/bpk-component-calendar/src/BpkCalendarGridTransition.d.ts +56 -0
- package/bpk-component-calendar/src/BpkCalendarGridTransition.js +43 -42
- package/bpk-component-calendar/src/BpkCalendarNav.d.ts +37 -0
- package/bpk-component-calendar/src/BpkCalendarNav.js +18 -32
- package/bpk-component-calendar/src/Week.d.ts +51 -0
- package/bpk-component-calendar/src/Week.js +48 -70
- package/bpk-component-calendar/src/composeCalendar.d.ts +55 -0
- package/bpk-component-calendar/src/composeCalendar.js +34 -95
- package/bpk-component-calendar/src/custom-proptypes-legacy.js +140 -0
- package/bpk-component-calendar/src/custom-proptypes.d.ts +46 -0
- package/bpk-component-calendar/src/custom-proptypes.js +2 -61
- package/bpk-component-calendar/src/date-utils.d.ts +54 -0
- package/bpk-component-calendar/src/utils.d.ts +26 -0
- package/bpk-component-calendar/src/utils.js +1 -0
- package/bpk-component-calendar/test-utils.d.ts +56 -0
- package/bpk-component-calendar/test-utils.js +2 -2
- package/bpk-component-card/index.d.ts +24 -0
- package/bpk-component-card/src/BpkCard.d.ts +39 -0
- package/bpk-component-card/src/BpkCard.js +9 -25
- package/bpk-component-card/src/BpkCardWrapper.d.ts +33 -0
- package/bpk-component-card/src/BpkCardWrapper.js +10 -18
- package/bpk-component-card/src/BpkDividedCard.d.ts +43 -0
- package/bpk-component-card/src/BpkDividedCard.js +9 -24
- package/bpk-component-chip/index.d.ts +32 -0
- package/bpk-component-chip/src/BpkDismissibleChip.d.ts +28 -0
- package/bpk-component-chip/src/BpkDismissibleChip.js +9 -8
- package/bpk-component-chip/src/BpkDropdownChip.d.ts +29 -0
- package/bpk-component-chip/src/BpkDropdownChip.js +39 -25
- package/bpk-component-chip/src/BpkSelectableChip.d.ts +39 -0
- package/bpk-component-chip/src/BpkSelectableChip.js +33 -48
- package/bpk-component-chip/src/commonTypes.d.ts +56 -0
- package/bpk-component-chip/src/commonTypes.js +8 -2
- package/bpk-component-dialog/src/BpkDialog.d.ts +1 -12
- package/bpk-component-dialog/src/BpkDialog.js +1 -2
- package/bpk-component-dialog/src/BpkDialogInner.d.ts +256 -2
- package/bpk-component-dialog/src/BpkDialogInner.js +0 -4
- package/bpk-component-dialog/src/common-types.d.ts +20 -21
- package/bpk-component-graphic-promotion/src/BpkGraphicPromo.js +0 -4
- package/bpk-component-icon/src/classNameModifierHOCFactory.js +0 -1
- package/bpk-component-icon/src/withAlignment.js +1 -1
- package/bpk-component-icon/src/withDescription.js +1 -1
- package/bpk-component-icon/src/withRtlSupport.js +0 -2
- package/bpk-component-input/index.d.ts +39 -0
- package/bpk-component-input/src/BpkClearButton.d.ts +28 -0
- package/bpk-component-input/src/BpkClearButton.js +6 -14
- package/bpk-component-input/src/BpkInput.d.ts +46 -0
- package/bpk-component-input/src/BpkInput.js +7 -3
- package/bpk-component-input/src/common-types.d.ts +91 -0
- package/bpk-component-input/src/common-types.js +4 -1
- package/bpk-component-input/src/withOpenEvents.d.ts +121 -0
- package/bpk-component-input/src/withOpenEvents.js +14 -25
- package/bpk-component-modal/index.d.ts +26 -0
- package/bpk-component-modal/index.js +13 -6
- package/bpk-component-modal/src/BpkModal.d.ts +32 -0
- package/bpk-component-modal/src/BpkModal.js +24 -44
- package/bpk-component-modal/src/BpkModalInner.d.ts +39 -0
- package/bpk-component-modal/src/BpkModalInner.js +67 -84
- package/bpk-component-modal/src/BpkModalV2/BpKModal.module.css +18 -0
- package/bpk-component-modal/src/BpkModalV2/BpkModal.d.ts +35 -0
- package/bpk-component-modal/src/BpkModalV2/BpkModal.js +131 -0
- package/bpk-component-modal/src/legacy-prop-types.js +86 -0
- package/bpk-component-modal/src/themeAttributes.js +1 -0
- package/bpk-component-rtl-toggle/index.d.ts +23 -0
- package/bpk-component-rtl-toggle/src/BpkRtlToggle.d.ts +41 -0
- package/bpk-component-rtl-toggle/src/BpkRtlToggle.js +9 -12
- package/bpk-component-rtl-toggle/src/updateOnDirectionChange.d.ts +151 -0
- package/bpk-component-rtl-toggle/src/updateOnDirectionChange.js +9 -2
- package/bpk-component-rtl-toggle/src/utils.d.ts +25 -0
- package/bpk-component-text/index.d.ts +21 -0
- package/bpk-component-text/index.js +0 -6
- package/bpk-component-text/src/BpkText.d.ts +60 -0
- package/bpk-component-text/src/BpkText.js +16 -56
- package/bpk-component-text/src/BpkText.module.css +1 -1
- package/bpk-component-tooltip/index.d.ts +24 -0
- package/bpk-component-tooltip/src/BpkTooltip.d.ts +29 -0
- package/bpk-component-tooltip/src/BpkTooltip.js +9 -26
- package/bpk-component-tooltip/src/BpkTooltipPortal.d.ts +60 -0
- package/bpk-component-tooltip/src/BpkTooltipPortal.js +13 -21
- package/bpk-component-tooltip/src/constants.d.ts +31 -0
- package/bpk-component-tooltip/src/constants.js +3 -1
- package/bpk-react-utils/index.d.ts +58 -0
- package/bpk-react-utils/index.js +1 -0
- package/bpk-react-utils/src/Portal.d.ts +76 -0
- package/bpk-react-utils/src/Portal.js +33 -43
- package/bpk-react-utils/src/TransitionInitialMount.d.ts +27 -0
- package/bpk-react-utils/src/TransitionInitialMount.js +7 -8
- package/bpk-react-utils/src/cssModules.d.ts +22 -0
- package/bpk-react-utils/src/deprecated.js +2 -1
- package/bpk-react-utils/src/deviceDetection.d.ts +22 -0
- package/bpk-react-utils/src/deviceDetection.js +3 -1
- package/bpk-react-utils/src/isRTL.d.ts +20 -0
- package/bpk-react-utils/src/isRTL.js +3 -1
- package/bpk-react-utils/src/withDefaultProps.d.ts +33 -0
- package/bpk-react-utils/src/withDefaultProps.js +11 -24
- package/bpk-react-utils/src/wrapDisplayName.d.ts +21 -0
- package/bpk-scrim-utils/index.d.ts +283 -0
- package/bpk-scrim-utils/src/BpkScrim.d.ts +24 -0
- package/bpk-scrim-utils/src/BpkScrim.js +5 -10
- package/bpk-scrim-utils/src/scroll-utils.d.ts +24 -0
- package/bpk-scrim-utils/src/scroll-utils.js +1 -1
- package/bpk-scrim-utils/src/withScrim.d.ts +96 -0
- package/bpk-scrim-utils/src/withScrim.js +5 -12
- package/package.json +1 -1
|
@@ -3,76 +3,95 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
6
|
+
exports.default = void 0;
|
|
8
7
|
var _bpkComponentLink = require("../../bpk-component-link");
|
|
9
8
|
var _bpkComponentCloseButton = _interopRequireDefault(require("../../bpk-component-close-button"));
|
|
10
9
|
var _bpkComponentNavigationBar = _interopRequireDefault(require("../../bpk-component-navigation-bar"));
|
|
11
10
|
var _bpkReactUtils = require("../../bpk-react-utils");
|
|
12
11
|
var _BpkModalInnerModule = _interopRequireDefault(require("./BpkModalInner.module.css"));
|
|
13
|
-
var _customPropTypes = require("./customPropTypes");
|
|
14
12
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
|
+
const _excluded = ["isIphone", "id", "dialogRef", "children", "title", "onClose", "className", "contentClassName", "closeLabel", "closeText", "wide", "showHeader", "fullScreenOnMobile", "fullScreen", "padded", "accessoryView"];
|
|
14
|
+
/*
|
|
15
|
+
* Backpack - Skyscanner's Design System
|
|
16
|
+
*
|
|
17
|
+
* Copyright 2016 Skyscanner Ltd
|
|
18
|
+
*
|
|
19
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
20
|
+
* you may not use this file except in compliance with the License.
|
|
21
|
+
* You may obtain a copy of the License at
|
|
22
|
+
*
|
|
23
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
24
|
+
*
|
|
25
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
26
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
27
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
28
|
+
* See the License for the specific language governing permissions and
|
|
29
|
+
* limitations under the License.
|
|
30
|
+
*/
|
|
31
|
+
// @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
|
|
32
|
+
// @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
|
|
33
|
+
// @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
|
|
15
34
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
|
-
function
|
|
17
|
-
function
|
|
18
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
19
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
20
|
-
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } /*
|
|
21
|
-
* Backpack - Skyscanner's Design System
|
|
22
|
-
*
|
|
23
|
-
* Copyright 2016 Skyscanner Ltd
|
|
24
|
-
*
|
|
25
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
26
|
-
* you may not use this file except in compliance with the License.
|
|
27
|
-
* You may obtain a copy of the License at
|
|
28
|
-
*
|
|
29
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
30
|
-
*
|
|
31
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
32
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
33
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
34
|
-
* See the License for the specific language governing permissions and
|
|
35
|
-
* limitations under the License.
|
|
36
|
-
*/
|
|
35
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
36
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
37
37
|
const getClassName = (0, _bpkReactUtils.cssModules)(_BpkModalInnerModule.default);
|
|
38
|
-
const BpkModalInner =
|
|
38
|
+
const BpkModalInner = _ref => {
|
|
39
|
+
let {
|
|
40
|
+
isIphone,
|
|
41
|
+
id,
|
|
42
|
+
dialogRef,
|
|
43
|
+
children,
|
|
44
|
+
title = null,
|
|
45
|
+
onClose = () => null,
|
|
46
|
+
className = null,
|
|
47
|
+
contentClassName = null,
|
|
48
|
+
closeLabel = '',
|
|
49
|
+
closeText = null,
|
|
50
|
+
wide = false,
|
|
51
|
+
showHeader = true,
|
|
52
|
+
fullScreenOnMobile = true,
|
|
53
|
+
fullScreen = false,
|
|
54
|
+
padded = true,
|
|
55
|
+
accessoryView = null
|
|
56
|
+
} = _ref,
|
|
57
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
39
58
|
const classNames = [getClassName('bpk-modal')];
|
|
40
59
|
const contentClassNames = [getClassName('bpk-modal__content')];
|
|
41
60
|
const navigationStyles = [getClassName('bpk-modal__navigation')];
|
|
42
|
-
if (
|
|
61
|
+
if (wide) {
|
|
43
62
|
classNames.push(getClassName('bpk-modal--wide'));
|
|
44
63
|
}
|
|
45
|
-
if (
|
|
46
|
-
classNames.push(
|
|
64
|
+
if (className) {
|
|
65
|
+
classNames.push(className);
|
|
47
66
|
}
|
|
48
|
-
if (
|
|
67
|
+
if (fullScreen || isIphone) {
|
|
49
68
|
classNames.push(getClassName('bpk-modal--full-screen'));
|
|
50
|
-
} else if (
|
|
69
|
+
} else if (fullScreenOnMobile) {
|
|
51
70
|
classNames.push(getClassName('bpk-modal--full-screen-mobile'));
|
|
52
71
|
}
|
|
53
|
-
if (
|
|
72
|
+
if (padded) {
|
|
54
73
|
contentClassNames.push(getClassName('bpk-modal__content--padded'));
|
|
55
74
|
}
|
|
56
|
-
if (
|
|
57
|
-
contentClassNames.push(
|
|
75
|
+
if (contentClassName) {
|
|
76
|
+
contentClassNames.push(contentClassName);
|
|
58
77
|
}
|
|
59
|
-
const headingId = `bpk-modal-heading-${
|
|
60
|
-
const accessoryViewFinal =
|
|
78
|
+
const headingId = `bpk-modal-heading-${id}`;
|
|
79
|
+
const accessoryViewFinal = accessoryView ? /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
61
80
|
className: getClassName('bpk-modal__accessory-view'),
|
|
62
|
-
children:
|
|
81
|
+
children: accessoryView
|
|
63
82
|
}) : null;
|
|
64
83
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_bpkReactUtils.TransitionInitialMount, {
|
|
65
84
|
appearClassName: getClassName('bpk-modal--appear'),
|
|
66
85
|
appearActiveClassName: getClassName('bpk-modal--appear-active'),
|
|
67
86
|
transitionTimeout: 300,
|
|
68
87
|
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("section", {
|
|
69
|
-
id:
|
|
70
|
-
tabIndex:
|
|
88
|
+
id: id,
|
|
89
|
+
tabIndex: -1,
|
|
71
90
|
role: "dialog",
|
|
72
|
-
"aria-labelledby":
|
|
91
|
+
"aria-labelledby": showHeader ? headingId : undefined,
|
|
73
92
|
className: classNames.join(' '),
|
|
74
|
-
ref:
|
|
75
|
-
children: [
|
|
93
|
+
ref: dialogRef,
|
|
94
|
+
children: [showHeader && /*#__PURE__*/(0, _jsxRuntime.jsx)("header", {
|
|
76
95
|
className: getClassName('bpk-modal__header'),
|
|
77
96
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_bpkComponentNavigationBar.default, {
|
|
78
97
|
id: headingId,
|
|
@@ -80,61 +99,25 @@ const BpkModalInner = props => {
|
|
|
80
99
|
title: /*#__PURE__*/(0, _jsxRuntime.jsx)("h2", {
|
|
81
100
|
id: headingId,
|
|
82
101
|
className: getClassName('bpk-modal__heading'),
|
|
83
|
-
children:
|
|
102
|
+
children: title
|
|
84
103
|
}),
|
|
85
104
|
leadingButton: accessoryViewFinal,
|
|
86
|
-
trailingButton:
|
|
105
|
+
trailingButton: closeText ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_bpkComponentLink.BpkButtonLink, {
|
|
87
106
|
className: getClassName('bpk-modal__close-button'),
|
|
88
|
-
onClick:
|
|
89
|
-
children:
|
|
107
|
+
onClick: onClose,
|
|
108
|
+
children: closeText
|
|
90
109
|
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_bpkComponentCloseButton.default, {
|
|
91
110
|
className: getClassName('bpk-modal__close-button'),
|
|
92
|
-
label:
|
|
93
|
-
onClick:
|
|
111
|
+
label: closeLabel,
|
|
112
|
+
onClick: onClose
|
|
94
113
|
})
|
|
95
114
|
})
|
|
96
115
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
97
116
|
className: contentClassNames.join(' '),
|
|
98
|
-
children:
|
|
117
|
+
children: children
|
|
99
118
|
})]
|
|
100
119
|
})
|
|
101
120
|
});
|
|
102
121
|
};
|
|
103
|
-
const propTypes = {
|
|
104
|
-
id: _propTypes.default.string.isRequired,
|
|
105
|
-
children: _propTypes.default.node.isRequired,
|
|
106
|
-
isIphone: _propTypes.default.bool.isRequired,
|
|
107
|
-
dialogRef: _propTypes.default.func.isRequired,
|
|
108
|
-
title: _customPropTypes.titlePropType,
|
|
109
|
-
onClose: _customPropTypes.onClosePropType,
|
|
110
|
-
className: _propTypes.default.string,
|
|
111
|
-
contentClassName: _propTypes.default.string,
|
|
112
|
-
closeLabel: _propTypes.default.string,
|
|
113
|
-
closeText: _propTypes.default.string,
|
|
114
|
-
wide: _propTypes.default.bool,
|
|
115
|
-
showHeader: _propTypes.default.bool,
|
|
116
|
-
fullScreenOnMobile: _propTypes.default.bool,
|
|
117
|
-
fullScreen: _propTypes.default.bool,
|
|
118
|
-
padded: _propTypes.default.bool,
|
|
119
|
-
accesoryView: _propTypes.default.func
|
|
120
|
-
};
|
|
121
|
-
exports.propTypes = propTypes;
|
|
122
|
-
const defaultProps = {
|
|
123
|
-
title: null,
|
|
124
|
-
onClose: () => null,
|
|
125
|
-
className: null,
|
|
126
|
-
contentClassName: null,
|
|
127
|
-
closeLabel: '',
|
|
128
|
-
closeText: null,
|
|
129
|
-
wide: false,
|
|
130
|
-
showHeader: true,
|
|
131
|
-
fullScreenOnMobile: true,
|
|
132
|
-
fullScreen: false,
|
|
133
|
-
padded: true,
|
|
134
|
-
accessoryView: null
|
|
135
|
-
};
|
|
136
|
-
exports.defaultProps = defaultProps;
|
|
137
|
-
BpkModalInner.propTypes = _objectSpread({}, propTypes);
|
|
138
|
-
BpkModalInner.defaultProps = _objectSpread({}, defaultProps);
|
|
139
122
|
var _default = BpkModalInner;
|
|
140
123
|
exports.default = _default;
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
@keyframes bpk-keyframe-spin{100%{transform:rotate(1turn)}}.bpk-modal-wrapper.bpk-modal-polyfill .bpk-modal-backdrop{position:fixed;top:0;right:0;bottom:0;left:0;z-index:0;background-color:rgba(0,0,0,0.7);inset:0;inset-block-end:0;inset-inline:0;inset-inline-end:0}.bpk-modal-wrapper.bpk-modal-polyfill .bpk-modal{position:fixed;display:block;z-index:1}.bpk-modal-wrapper.bpk-modal-polyfill .bpk-modal:not([data-open='true']),.bpk-modal-wrapper.bpk-modal-polyfill .bpk-modal-backdrop:not([data-open='true']){display:none}.bpk-modal{top:0;right:0;left:0;width:100%;max-width:100%;height:100%;max-height:100%;margin:0 auto;padding:0;border:none;background:#eff1f2;overflow-y:scroll;inset-block-start:0;inset-inline:0;inset-inline-end:0;scrollbar-width:none;box-shadow:0px 12px 50px 0px rgba(37,32,31,0.25)}@media (min-width: 32.0625rem){.bpk-modal{width:32rem;max-width:none;height:fit-content;max-height:90%;top:50%;transform:translateY(-50%);border-radius:.75rem;inset-block-start:50%}.bpk-modal--full-screen-desktop{width:100%;height:100%;max-height:100%;border-radius:0}.bpk-modal--wide{width:64rem}}.bpk-modal--no-full-screen-mobile{width:90%;max-width:none;height:fit-content;max-height:90%;top:50%;transform:translateY(-50%);border-radius:.75rem;inset-block-start:50%}@media (min-width: 32.0625rem){.bpk-modal--no-full-screen-mobile{width:32rem;max-width:none}}.bpk-modal::backdrop{position:fixed;background-color:rgba(0,0,0,0.7);inset:0;inset-block-end:0;inset-inline:0;inset-inline-end:0}.bpk-modal::-webkit-scrollbar{display:none}.bpk-modal__header-title{padding:1rem;border-block-end:solid 0.0625rem #C2C9CD;display:flex;min-height:1.5rem;flex-wrap:nowrap;justify-content:flex-end;align-items:center}.bpk-modal__header-title-container{display:flex;width:100%;justify-content:flex-start}.bpk-modal__title{padding-inline-end:1rem;font-size:1rem;line-height:1.5rem;font-weight:700}.bpk-modal__button-container{padding-block-start:1rem;padding-inline-end:1rem;display:flex;min-height:1.5rem;flex-wrap:nowrap;justify-content:flex-end;align-items:center}.bpk-modal__container{min-height:100%;padding:1rem}.bpk-modal__container--padded{padding:0}.bpk-modal__container--full-screen-desktop{height:100%}
|
|
@@ -0,0 +1,35 @@
|
|
|
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 { ReactNode } from 'react';
|
|
21
|
+
|
|
22
|
+
export type Props = {
|
|
23
|
+
id: string | undefined;
|
|
24
|
+
ariaLabelledby: string;
|
|
25
|
+
children: ReactNode;
|
|
26
|
+
closeLabel: string;
|
|
27
|
+
fullScreenOnDesktop?: boolean;
|
|
28
|
+
isOpen: boolean;
|
|
29
|
+
noFullScreenOnMobile?: boolean;
|
|
30
|
+
onClose: () => void | null;
|
|
31
|
+
padded?: boolean;
|
|
32
|
+
title?: string | null;
|
|
33
|
+
wide?: boolean;
|
|
34
|
+
};
|
|
35
|
+
export declare const BpkModalV2: (props: Props) => JSX.Element | null;
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.BpkModalV2 = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _bpkComponentCloseButton = _interopRequireDefault(require("../../../bpk-component-close-button"));
|
|
9
|
+
var _bpkComponentText = _interopRequireWildcard(require("../../../bpk-component-text"));
|
|
10
|
+
var _bpkReactUtils = require("../../../bpk-react-utils");
|
|
11
|
+
var _BpKModalModule = _interopRequireDefault(require("./BpKModal.module.css"));
|
|
12
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
|
+
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); }
|
|
14
|
+
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; }
|
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
|
+
/*
|
|
17
|
+
* Backpack - Skyscanner's Design System
|
|
18
|
+
*
|
|
19
|
+
* Copyright 2016 Skyscanner Ltd
|
|
20
|
+
*
|
|
21
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
22
|
+
* you may not use this file except in compliance with the License.
|
|
23
|
+
* You may obtain a copy of the License at
|
|
24
|
+
*
|
|
25
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
26
|
+
*
|
|
27
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
28
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
29
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
30
|
+
* See the License for the specific language governing permissions and
|
|
31
|
+
* limitations under the License.
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
// @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
|
|
35
|
+
|
|
36
|
+
const getClassName = (0, _bpkReactUtils.cssModules)(_BpKModalModule.default);
|
|
37
|
+
const Heading = (0, _bpkReactUtils.withDefaultProps)(_bpkComponentText.default, {
|
|
38
|
+
textStyle: _bpkComponentText.TEXT_STYLES.label1,
|
|
39
|
+
tagName: 'h2',
|
|
40
|
+
className: getClassName('bpk-modal__title')
|
|
41
|
+
});
|
|
42
|
+
// TODO: this check if the browser support the HTML dialog element. We can remove it once we drop support as a business for Safari 14
|
|
43
|
+
const dialogSupported = typeof HTMLDialogElement === 'function';
|
|
44
|
+
const setPageProperties = ({
|
|
45
|
+
isDialogOpen
|
|
46
|
+
}) => {
|
|
47
|
+
document.body.style.overflowY = isDialogOpen ? 'hidden' : 'visible';
|
|
48
|
+
if (!dialogSupported) {
|
|
49
|
+
document.body.style.position = isDialogOpen ? 'fixed' : 'relative';
|
|
50
|
+
document.body.style.width = isDialogOpen ? '100%' : 'auto';
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
const BpkModalV2 = props => {
|
|
54
|
+
const {
|
|
55
|
+
ariaLabelledby,
|
|
56
|
+
children,
|
|
57
|
+
closeLabel,
|
|
58
|
+
fullScreenOnDesktop,
|
|
59
|
+
id,
|
|
60
|
+
isOpen,
|
|
61
|
+
noFullScreenOnMobile,
|
|
62
|
+
onClose,
|
|
63
|
+
padded,
|
|
64
|
+
title,
|
|
65
|
+
wide
|
|
66
|
+
} = props;
|
|
67
|
+
const ref = (0, _react.useRef)(null);
|
|
68
|
+
(0, _react.useEffect)(() => {
|
|
69
|
+
if (isOpen) {
|
|
70
|
+
ref.current?.showModal?.();
|
|
71
|
+
const dialog = document.getElementById(`${id}`);
|
|
72
|
+
if (dialog) {
|
|
73
|
+
dialog.addEventListener('click', event => {
|
|
74
|
+
const {
|
|
75
|
+
target
|
|
76
|
+
} = event;
|
|
77
|
+
if (target instanceof HTMLElement && target.id === `${id}`) {
|
|
78
|
+
ref.current?.close?.();
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
} else {
|
|
83
|
+
ref.current?.close?.();
|
|
84
|
+
}
|
|
85
|
+
setPageProperties({
|
|
86
|
+
isDialogOpen: isOpen
|
|
87
|
+
});
|
|
88
|
+
return () => setPageProperties({
|
|
89
|
+
isDialogOpen: false
|
|
90
|
+
});
|
|
91
|
+
}, [id, isOpen]);
|
|
92
|
+
const classNames = getClassName('bpk-modal', fullScreenOnDesktop && 'bpk-modal--full-screen-desktop', noFullScreenOnMobile && 'bpk-modal--no-full-screen-mobile', wide && 'bpk-modal--wide');
|
|
93
|
+
const contentClassNames = getClassName('bpk-modal__container', fullScreenOnDesktop && 'bpk-modal__container--full-screen-desktop', padded && 'bpk-modal__container--padded');
|
|
94
|
+
const closeButton = /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
95
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_bpkComponentCloseButton.default, {
|
|
96
|
+
label: closeLabel,
|
|
97
|
+
onClick: onClose
|
|
98
|
+
})
|
|
99
|
+
});
|
|
100
|
+
return isOpen ? /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
101
|
+
className: getClassName('bpk-modal-wrapper', dialogSupported ? '' : 'bpk-modal-polyfill'),
|
|
102
|
+
children: [!dialogSupported && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
103
|
+
id: `${id}-polyfill`,
|
|
104
|
+
className: getClassName('bpk-modal-backdrop'),
|
|
105
|
+
"data-open": isOpen
|
|
106
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("dialog", {
|
|
107
|
+
id: id,
|
|
108
|
+
className: classNames,
|
|
109
|
+
onClose: onClose,
|
|
110
|
+
"aria-labelledby": ariaLabelledby,
|
|
111
|
+
"data-open": isOpen,
|
|
112
|
+
ref: ref,
|
|
113
|
+
children: [title ? /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
114
|
+
className: getClassName('bpk-modal__header-title'),
|
|
115
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
116
|
+
className: getClassName('bpk-modal__header-title-container'),
|
|
117
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Heading, {
|
|
118
|
+
children: title
|
|
119
|
+
})
|
|
120
|
+
}), closeButton]
|
|
121
|
+
}) : /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
122
|
+
className: getClassName('bpk-modal__button-container'),
|
|
123
|
+
children: closeButton
|
|
124
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
125
|
+
className: contentClassNames,
|
|
126
|
+
children: children
|
|
127
|
+
})]
|
|
128
|
+
})]
|
|
129
|
+
}) : null;
|
|
130
|
+
};
|
|
131
|
+
exports.BpkModalV2 = BpkModalV2;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.propTypes = exports.defaultProps = void 0;
|
|
7
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
8
|
+
var _bpkReactUtils = require("../../bpk-react-utils");
|
|
9
|
+
var _customPropTypes = require("./customPropTypes");
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
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; }
|
|
12
|
+
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; }
|
|
13
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
14
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
15
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
16
|
+
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; }
|
|
17
|
+
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; } /*
|
|
18
|
+
* Backpack - Skyscanner's Design System
|
|
19
|
+
*
|
|
20
|
+
* Copyright 2016 Skyscanner Ltd
|
|
21
|
+
*
|
|
22
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
23
|
+
* you may not use this file except in compliance with the License.
|
|
24
|
+
* You may obtain a copy of the License at
|
|
25
|
+
*
|
|
26
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
27
|
+
*
|
|
28
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
29
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
30
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
31
|
+
* See the License for the specific language governing permissions and
|
|
32
|
+
* limitations under the License.
|
|
33
|
+
*/
|
|
34
|
+
const modalDialogPropTypes = {
|
|
35
|
+
id: _propTypes.default.string.isRequired,
|
|
36
|
+
children: _propTypes.default.node.isRequired,
|
|
37
|
+
isIphone: _propTypes.default.bool.isRequired,
|
|
38
|
+
dialogRef: _propTypes.default.func.isRequired,
|
|
39
|
+
title: _customPropTypes.titlePropType,
|
|
40
|
+
onClose: _customPropTypes.onClosePropType,
|
|
41
|
+
className: _propTypes.default.string,
|
|
42
|
+
contentClassName: _propTypes.default.string,
|
|
43
|
+
closeLabel: _propTypes.default.string,
|
|
44
|
+
closeText: _propTypes.default.string,
|
|
45
|
+
wide: _propTypes.default.bool,
|
|
46
|
+
showHeader: _propTypes.default.bool,
|
|
47
|
+
fullScreenOnMobile: _propTypes.default.bool,
|
|
48
|
+
fullScreen: _propTypes.default.bool,
|
|
49
|
+
padded: _propTypes.default.bool,
|
|
50
|
+
accesoryView: _propTypes.default.func
|
|
51
|
+
};
|
|
52
|
+
const modalDialogDefaultProps = {
|
|
53
|
+
title: null,
|
|
54
|
+
onClose: () => null,
|
|
55
|
+
className: null,
|
|
56
|
+
contentClassName: null,
|
|
57
|
+
closeLabel: '',
|
|
58
|
+
closeText: null,
|
|
59
|
+
wide: false,
|
|
60
|
+
showHeader: true,
|
|
61
|
+
fullScreenOnMobile: true,
|
|
62
|
+
fullScreen: false,
|
|
63
|
+
padded: true,
|
|
64
|
+
accessoryView: null
|
|
65
|
+
};
|
|
66
|
+
const {
|
|
67
|
+
dialogRef
|
|
68
|
+
} = modalDialogPropTypes,
|
|
69
|
+
newModalDialogPropTypes = _objectWithoutProperties(modalDialogPropTypes, ["dialogRef"]);
|
|
70
|
+
const propTypes = _objectSpread(_objectSpread({}, newModalDialogPropTypes), {}, {
|
|
71
|
+
onClose: _propTypes.default.func,
|
|
72
|
+
isIphone: _propTypes.default.bool,
|
|
73
|
+
isOpen: _propTypes.default.bool.isRequired,
|
|
74
|
+
renderTarget: _propTypes.default.func,
|
|
75
|
+
closeOnScrimClick: _propTypes.default.bool,
|
|
76
|
+
closeOnEscPressed: _propTypes.default.bool
|
|
77
|
+
});
|
|
78
|
+
exports.propTypes = propTypes;
|
|
79
|
+
const defaultProps = _objectSpread(_objectSpread({}, modalDialogDefaultProps), {}, {
|
|
80
|
+
onClose: () => null,
|
|
81
|
+
renderTarget: null,
|
|
82
|
+
isIphone: (0, _bpkReactUtils.isDeviceIphone)(),
|
|
83
|
+
closeOnScrimClick: true,
|
|
84
|
+
closeOnEscPressed: true
|
|
85
|
+
});
|
|
86
|
+
exports.defaultProps = defaultProps;
|
|
@@ -22,5 +22,6 @@ var _bpkComponentLink = require("../../bpk-component-link");
|
|
|
22
22
|
* See the License for the specific language governing permissions and
|
|
23
23
|
* limitations under the License.
|
|
24
24
|
*/
|
|
25
|
+
// @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
|
|
25
26
|
var _default = [..._bpkComponentLink.themeAttributes];
|
|
26
27
|
exports.default = _default;
|
|
@@ -0,0 +1,23 @@
|
|
|
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 BpkRtlToggle from './src/BpkRtlToggle';
|
|
20
|
+
import updateOnDirectionChange from './src/updateOnDirectionChange';
|
|
21
|
+
|
|
22
|
+
export default BpkRtlToggle;
|
|
23
|
+
export { updateOnDirectionChange };
|
|
@@ -0,0 +1,41 @@
|
|
|
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
|
+
type State = {
|
|
22
|
+
direction: string;
|
|
23
|
+
};
|
|
24
|
+
type Props = {
|
|
25
|
+
className?: string | null;
|
|
26
|
+
};
|
|
27
|
+
type InteractionEvents = KeyboardEvent | MouseEvent | TouchEvent;
|
|
28
|
+
declare class BpkRtlToggle extends Component<Props, State> {
|
|
29
|
+
constructor(props: Props);
|
|
30
|
+
|
|
31
|
+
componentDidMount(): void;
|
|
32
|
+
|
|
33
|
+
componentWillUnmount(): void;
|
|
34
|
+
|
|
35
|
+
handleKeyDown: (e: KeyboardEvent) => void;
|
|
36
|
+
|
|
37
|
+
toggleRtl: (e: InteractionEvents) => void;
|
|
38
|
+
|
|
39
|
+
render(): JSX.Element;
|
|
40
|
+
}
|
|
41
|
+
export default BpkRtlToggle;
|
|
@@ -5,11 +5,9 @@ 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 _bpkComponentLink = require("../../bpk-component-link");
|
|
10
9
|
var _utils = require("./utils");
|
|
11
10
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
11
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
14
12
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
15
13
|
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } /*
|
|
@@ -28,12 +26,17 @@ function _toPrimitive(input, hint) { if (typeof input !== "object" || input ===
|
|
|
28
26
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
29
27
|
* See the License for the specific language governing permissions and
|
|
30
28
|
* limitations under the License.
|
|
31
|
-
*/
|
|
32
|
-
const getDirection = () =>
|
|
29
|
+
*/ // @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
|
|
30
|
+
const getDirection = () => {
|
|
31
|
+
const htmlElement = (0, _utils.getHtmlElement)();
|
|
32
|
+
return htmlElement instanceof HTMLElement ? htmlElement.dir : _utils.DIRECTIONS.LTR;
|
|
33
|
+
};
|
|
33
34
|
const setDirection = direction => {
|
|
34
35
|
const htmlElement = (0, _utils.getHtmlElement)();
|
|
35
|
-
htmlElement
|
|
36
|
-
|
|
36
|
+
if (htmlElement instanceof HTMLElement) {
|
|
37
|
+
htmlElement.dir = direction;
|
|
38
|
+
htmlElement.dispatchEvent(new Event(_utils.DIRECTION_CHANGE_EVENT));
|
|
39
|
+
}
|
|
37
40
|
};
|
|
38
41
|
class BpkRtlToggle extends _react.Component {
|
|
39
42
|
constructor(props) {
|
|
@@ -74,11 +77,5 @@ class BpkRtlToggle extends _react.Component {
|
|
|
74
77
|
});
|
|
75
78
|
}
|
|
76
79
|
}
|
|
77
|
-
BpkRtlToggle.propTypes = {
|
|
78
|
-
className: _propTypes.default.string
|
|
79
|
-
};
|
|
80
|
-
BpkRtlToggle.defaultProps = {
|
|
81
|
-
className: null
|
|
82
|
-
};
|
|
83
80
|
var _default = BpkRtlToggle;
|
|
84
81
|
exports.default = _default;
|