@skyscanner/backpack-web 23.2.2 → 23.3.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 +429 -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 +52 -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 +34 -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.js +0 -1
- package/bpk-component-dialog/src/BpkDialogInner.js +0 -2
- package/bpk-component-graphic-promotion/src/BpkGraphicPromo.js +0 -2
- 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.js +11 -4
- 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 +133 -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-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/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 +95 -0
- package/bpk-scrim-utils/src/withScrim.js +5 -12
- package/package.json +1 -1
|
@@ -0,0 +1,56 @@
|
|
|
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 { ComponentProps, ReactNode, SyntheticEvent } from 'react';
|
|
21
|
+
|
|
22
|
+
export declare const CHIP_TYPES: {
|
|
23
|
+
readonly default: 'default';
|
|
24
|
+
readonly onDark: 'on-dark';
|
|
25
|
+
readonly onImage: 'on-image';
|
|
26
|
+
};
|
|
27
|
+
interface ButtonProps extends Omit<ComponentProps<'button'>, 'type'> {
|
|
28
|
+
onClick: (event: SyntheticEvent<HTMLButtonElement>) => void | null;
|
|
29
|
+
children: ReactNode | string;
|
|
30
|
+
type?: typeof CHIP_TYPES[keyof typeof CHIP_TYPES];
|
|
31
|
+
}
|
|
32
|
+
export interface CommonProps extends ButtonProps {
|
|
33
|
+
accessibilityLabel: string;
|
|
34
|
+
disabled?: boolean;
|
|
35
|
+
selected?: boolean;
|
|
36
|
+
leadingAccessoryView?: ReactNode;
|
|
37
|
+
}
|
|
38
|
+
export declare const COMMON_PROP_TYPES: {
|
|
39
|
+
accessibilityLabel: PropTypes.Validator<string>;
|
|
40
|
+
children: PropTypes.Validator<NonNullable<PropTypes.ReactNodeLike>>;
|
|
41
|
+
onClick: PropTypes.Validator<(...args: any[]) => any>;
|
|
42
|
+
className: PropTypes.Requireable<string>;
|
|
43
|
+
disabled: PropTypes.Requireable<boolean>;
|
|
44
|
+
leadingAccessoryView: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
45
|
+
selected: PropTypes.Requireable<boolean>;
|
|
46
|
+
trailingAccessoryView: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
47
|
+
type: PropTypes.Requireable<'default' | 'on-dark' | 'on-image'>;
|
|
48
|
+
};
|
|
49
|
+
export declare const COMMON_DEFAULT_PROPS: {
|
|
50
|
+
disabled: boolean;
|
|
51
|
+
leadingAccessoryView: null;
|
|
52
|
+
selected: boolean;
|
|
53
|
+
trailingAccessoryView: null;
|
|
54
|
+
type: 'default';
|
|
55
|
+
};
|
|
56
|
+
export {};
|
|
@@ -22,12 +22,17 @@ 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
|
-
*/
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
const CHIP_TYPES = {
|
|
26
28
|
default: 'default',
|
|
27
29
|
onDark: 'on-dark',
|
|
28
30
|
onImage: 'on-image'
|
|
29
31
|
};
|
|
32
|
+
|
|
33
|
+
// onClick and children are already part of the button props, but we need to specify that they are required
|
|
30
34
|
exports.CHIP_TYPES = CHIP_TYPES;
|
|
35
|
+
// TODO: Remove once chip examples have been migrated to TS
|
|
31
36
|
const COMMON_PROP_TYPES = {
|
|
32
37
|
accessibilityLabel: _propTypes.default.string.isRequired,
|
|
33
38
|
children: _propTypes.default.node.isRequired,
|
|
@@ -39,9 +44,10 @@ const COMMON_PROP_TYPES = {
|
|
|
39
44
|
trailingAccessoryView: _propTypes.default.node,
|
|
40
45
|
type: _propTypes.default.oneOf(Object.values(CHIP_TYPES))
|
|
41
46
|
};
|
|
47
|
+
|
|
48
|
+
// TODO: Remove once chip examples have been migrated to TS
|
|
42
49
|
exports.COMMON_PROP_TYPES = COMMON_PROP_TYPES;
|
|
43
50
|
const COMMON_DEFAULT_PROPS = {
|
|
44
|
-
className: null,
|
|
45
51
|
disabled: false,
|
|
46
52
|
leadingAccessoryView: null,
|
|
47
53
|
selected: false,
|
|
@@ -29,7 +29,6 @@ const _excluded = ["children", "closeLabel", "dismissible", "headerIcon", "heade
|
|
|
29
29
|
* limitations under the License.
|
|
30
30
|
*/
|
|
31
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
32
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
34
33
|
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
34
|
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; }
|
|
@@ -32,8 +32,6 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
32
32
|
|
|
33
33
|
// @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
|
|
34
34
|
|
|
35
|
-
// @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
|
|
36
|
-
|
|
37
35
|
const getClassName = (0, _bpkReactUtils.cssModules)(_BpkDialogInnerModule.default);
|
|
38
36
|
const BpkDialogInner = props => {
|
|
39
37
|
const {
|
|
@@ -32,8 +32,6 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
32
32
|
|
|
33
33
|
// @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
|
|
34
34
|
|
|
35
|
-
// @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
|
|
36
|
-
|
|
37
35
|
const getClassName = (0, _bpkReactUtils.cssModules)(_BpkGraphicPromoModule.default);
|
|
38
36
|
const ACCESSIBILITY_KEYS = {
|
|
39
37
|
Enter: 13 /* Enter */,
|
|
@@ -24,7 +24,6 @@ const _excluded = ["className"];
|
|
|
24
24
|
* See the License for the specific language governing permissions and
|
|
25
25
|
* limitations under the License.
|
|
26
26
|
*/
|
|
27
|
-
// @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
|
|
28
27
|
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; }
|
|
29
28
|
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; }
|
|
30
29
|
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; }
|
|
@@ -26,7 +26,7 @@ function _toPrimitive(input, hint) { if (typeof input !== "object" || input ===
|
|
|
26
26
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
27
27
|
* See the License for the specific language governing permissions and
|
|
28
28
|
* limitations under the License.
|
|
29
|
-
*/
|
|
29
|
+
*/
|
|
30
30
|
function withAlignment(Component, objectHeight, subjectHeight) {
|
|
31
31
|
const WithAlignment = props => {
|
|
32
32
|
const objectHeightDecimal = `${objectHeight}`.replace('rem', '');
|
|
@@ -28,7 +28,7 @@ function _toPrimitive(input, hint) { if (typeof input !== "object" || input ===
|
|
|
28
28
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
29
29
|
* See the License for the specific language governing permissions and
|
|
30
30
|
* limitations under the License.
|
|
31
|
-
*/
|
|
31
|
+
*/
|
|
32
32
|
const getClassName = (0, _bpkReactUtils.cssModules)(_withDescriptionModule.default);
|
|
33
33
|
function withDescription(Component, description) {
|
|
34
34
|
const WithDescription = props => /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
|
|
@@ -26,8 +26,6 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
26
26
|
* limitations under the License.
|
|
27
27
|
*/
|
|
28
28
|
|
|
29
|
-
// @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
|
|
30
|
-
|
|
31
29
|
const getClassName = (0, _bpkReactUtils.cssModules)(_BpkIconModule.default);
|
|
32
30
|
var _default = (0, _classNameModifierHOCFactory.default)('withRtlSupport', [getClassName('bpk-icon--rtl-support')]);
|
|
33
31
|
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 BpkInput from './src/BpkInput';
|
|
20
|
+
import withOpenEvents from './src/withOpenEvents';
|
|
21
|
+
import {
|
|
22
|
+
propTypes,
|
|
23
|
+
defaultProps,
|
|
24
|
+
CLEAR_BUTTON_MODES,
|
|
25
|
+
INPUT_TYPES,
|
|
26
|
+
type Props,
|
|
27
|
+
} from './src/common-types';
|
|
28
|
+
import themeAttributes from './src/themeAttributes';
|
|
29
|
+
|
|
30
|
+
export default BpkInput;
|
|
31
|
+
export type BpkInputProps = Props;
|
|
32
|
+
export {
|
|
33
|
+
propTypes,
|
|
34
|
+
defaultProps,
|
|
35
|
+
withOpenEvents,
|
|
36
|
+
INPUT_TYPES,
|
|
37
|
+
CLEAR_BUTTON_MODES,
|
|
38
|
+
themeAttributes,
|
|
39
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
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
|
+
type Props = {
|
|
20
|
+
label: string;
|
|
21
|
+
};
|
|
22
|
+
declare const BpkClearButton: ({
|
|
23
|
+
className,
|
|
24
|
+
label,
|
|
25
|
+
onClick,
|
|
26
|
+
...rest
|
|
27
|
+
}: Props) => JSX.Element;
|
|
28
|
+
export default BpkClearButton;
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
8
7
|
var _closeCircle = _interopRequireDefault(require("../../bpk-component-icon/sm/close-circle"));
|
|
9
8
|
var _bpkComponentIcon = require("../../bpk-component-icon");
|
|
10
9
|
var _bpkReactUtils = require("../../bpk-react-utils");
|
|
@@ -28,6 +27,7 @@ const _excluded = ["className", "label", "onClick"];
|
|
|
28
27
|
* See the License for the specific language governing permissions and
|
|
29
28
|
* limitations under the License.
|
|
30
29
|
*/
|
|
30
|
+
// @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
|
|
31
31
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
32
32
|
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; }
|
|
33
33
|
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; }
|
|
@@ -38,14 +38,14 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
|
38
38
|
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; }
|
|
39
39
|
const getClassName = (0, _bpkReactUtils.cssModules)(_BpkClearButtonModule.default);
|
|
40
40
|
const ClearButtonIcon = (0, _bpkComponentIcon.withButtonAlignment)(_closeCircle.default);
|
|
41
|
-
const BpkClearButton =
|
|
42
|
-
|
|
43
|
-
const {
|
|
41
|
+
const BpkClearButton = _ref => {
|
|
42
|
+
let {
|
|
44
43
|
className,
|
|
45
44
|
label,
|
|
46
45
|
onClick
|
|
47
|
-
} =
|
|
48
|
-
rest = _objectWithoutProperties(
|
|
46
|
+
} = _ref,
|
|
47
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
48
|
+
const classNames = [getClassName('bpk-clear-button')];
|
|
49
49
|
if (className) {
|
|
50
50
|
classNames.push(className);
|
|
51
51
|
}
|
|
@@ -67,13 +67,5 @@ const BpkClearButton = props => {
|
|
|
67
67
|
}))
|
|
68
68
|
);
|
|
69
69
|
};
|
|
70
|
-
BpkClearButton.propTypes = {
|
|
71
|
-
label: _propTypes.default.string.isRequired,
|
|
72
|
-
onClick: _propTypes.default.func.isRequired,
|
|
73
|
-
className: _propTypes.default.string
|
|
74
|
-
};
|
|
75
|
-
BpkClearButton.defaultProps = {
|
|
76
|
-
className: null
|
|
77
|
-
};
|
|
78
70
|
var _default = BpkClearButton;
|
|
79
71
|
exports.default = _default;
|
|
@@ -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:
|
|
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
|
|
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
|
-
*/
|
|
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;
|