@skyscanner/backpack-web 42.16.0 → 42.17.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 (37) hide show
  1. package/bpk-component-autosuggest/index.d.ts +6 -0
  2. package/bpk-component-autosuggest/index.js +3 -1
  3. package/bpk-component-autosuggest/src/BpkAutosuggest.d.ts +2 -0
  4. package/bpk-component-autosuggest/src/BpkAutosuggest.js +14 -15
  5. package/bpk-component-autosuggest/src/BpkAutosuggestSuggestion.d.ts +11 -0
  6. package/bpk-component-autosuggest/src/BpkAutosuggestSuggestion.js +35 -55
  7. package/bpk-component-collapsible/index.d.ts +11 -0
  8. package/bpk-component-collapsible/index.js +22 -0
  9. package/bpk-component-collapsible/src/BpkCollapsible.d.ts +8 -0
  10. package/bpk-component-collapsible/src/BpkCollapsible.js +31 -0
  11. package/bpk-component-collapsible/src/BpkCollapsible.module.css +18 -0
  12. package/bpk-component-collapsible/src/BpkCollapsibleContent.d.ts +6 -0
  13. package/bpk-component-collapsible/src/BpkCollapsibleContent.js +36 -0
  14. package/bpk-component-collapsible/src/BpkCollapsibleIndicator.d.ts +6 -0
  15. package/bpk-component-collapsible/src/BpkCollapsibleIndicator.js +34 -0
  16. package/bpk-component-collapsible/src/BpkCollapsibleRoot.d.ts +22 -0
  17. package/bpk-component-collapsible/src/BpkCollapsibleRoot.js +49 -0
  18. package/bpk-component-collapsible/src/BpkCollapsibleRootProvider.d.ts +10 -0
  19. package/bpk-component-collapsible/src/BpkCollapsibleRootProvider.js +33 -0
  20. package/bpk-component-collapsible/src/BpkCollapsibleTrigger.d.ts +6 -0
  21. package/bpk-component-collapsible/src/BpkCollapsibleTrigger.js +43 -0
  22. package/bpk-component-collapsible/src/common-types.d.ts +9 -0
  23. package/bpk-component-collapsible/src/common-types.js +29 -0
  24. package/bpk-component-collapsible/src/useBpkCollapsible.d.ts +5 -0
  25. package/bpk-component-collapsible/src/useBpkCollapsible.js +21 -0
  26. package/bpk-component-horizontal-nav/index.d.ts +6 -0
  27. package/bpk-component-horizontal-nav/index.js +3 -1
  28. package/bpk-component-horizontal-nav/src/BpkHorizontalNav.d.ts +27 -0
  29. package/bpk-component-horizontal-nav/src/BpkHorizontalNav.js +79 -114
  30. package/bpk-component-horizontal-nav/src/BpkHorizontalNavItem.d.ts +25 -0
  31. package/bpk-component-horizontal-nav/src/BpkHorizontalNavItem.js +38 -73
  32. package/bpk-component-switch/index.d.ts +3 -3
  33. package/bpk-component-switch/index.js +2 -2
  34. package/bpk-component-switch/src/BpkSwitch.d.ts +7 -1
  35. package/bpk-component-switch/src/BpkSwitch.js +10 -1
  36. package/bpk-component-switch/src/BpkSwitch.module.css +1 -1
  37. package/package.json +2 -2
@@ -0,0 +1,6 @@
1
+ import BpkAutosuggestLegacy from './src/BpkAutosuggest';
2
+ import BpkAutosuggestSuggestion from './src/BpkAutosuggestSuggestion';
3
+ import { defaultTheme } from './src/BpkAutosuggestV2/BpkAutosuggest';
4
+ declare const BpkAutosuggest: import("react").ForwardRefExoticComponent<import("./src/BpkAutosuggestV2/BpkAutosuggest").BpkAutoSuggestProps<any> & import("react").RefAttributes<HTMLInputElement>>;
5
+ export default BpkAutosuggest;
6
+ export { BpkAutosuggestLegacy, BpkAutosuggestSuggestion, defaultTheme };
@@ -14,7 +14,9 @@
14
14
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
15
  * See the License for the specific language governing permissions and
16
16
  * limitations under the License.
17
- */import BpkAutosuggestLegacy from "./src/BpkAutosuggest";
17
+ */
18
+
19
+ import BpkAutosuggestLegacy from "./src/BpkAutosuggest";
18
20
  import BpkAutosuggestSuggestion from "./src/BpkAutosuggestSuggestion";
19
21
  import BpkAutosuggestV2, { defaultTheme } from "./src/BpkAutosuggestV2/BpkAutosuggest";
20
22
  const BpkAutosuggest = BpkAutosuggestV2;
@@ -0,0 +1,2 @@
1
+ import Autosuggest from 'react-autosuggest';
2
+ export default Autosuggest;
@@ -14,7 +14,10 @@
14
14
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
15
  * See the License for the specific language governing permissions and
16
16
  * limitations under the License.
17
- */import Autosuggest from 'react-autosuggest';
17
+ */
18
+
19
+ // @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
20
+ import Autosuggest from 'react-autosuggest';
18
21
  import BpkInput from "../../bpk-component-input";
19
22
  import { cssModules } from "../../bpk-react-utils";
20
23
  import STYLES from "./BpkAutosuggest.module.css";
@@ -47,19 +50,15 @@ Autosuggest.defaultProps.renderInputComponent = inputProps => {
47
50
  ref,
48
51
  ...rest
49
52
  } = inputProps;
50
- return (
51
- /*#__PURE__*/
52
- // $FlowFixMe[cannot-spread-inexact] - inexact rest. See 'decisions/flowfixme.md'.
53
- _jsx(BpkInput, {
54
- inputRef: element => {
55
- ref(element);
56
- if (typeof inputRef === 'function') {
57
- inputRef(element);
58
- }
59
- },
60
- autoComplete: autoComplete,
61
- ...rest
62
- })
63
- );
53
+ return /*#__PURE__*/_jsx(BpkInput, {
54
+ inputRef: element => {
55
+ ref(element);
56
+ if (typeof inputRef === 'function') {
57
+ inputRef(element);
58
+ }
59
+ },
60
+ autoComplete: autoComplete,
61
+ ...rest
62
+ });
64
63
  };
65
64
  export default Autosuggest;
@@ -0,0 +1,11 @@
1
+ import type { ComponentType, HTMLAttributes, ReactNode } from 'react';
2
+ type Props = Omit<HTMLAttributes<HTMLElement>, 'className'> & {
3
+ value: ReactNode;
4
+ subHeading?: ReactNode | null;
5
+ tertiaryLabel?: string | null;
6
+ icon?: ComponentType | null;
7
+ indent?: boolean;
8
+ className?: string | null;
9
+ };
10
+ declare const BpkAutosuggestSuggestion: ({ className, icon: Icon, indent, subHeading, tertiaryLabel, value, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
11
+ export default BpkAutosuggestSuggestion;
@@ -14,72 +14,52 @@
14
14
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
15
  * See the License for the specific language governing permissions and
16
16
  * limitations under the License.
17
- */import PropTypes from 'prop-types';
17
+ */
18
+
18
19
  import { cssModules } from "../../bpk-react-utils";
19
20
  import STYLES from "./BpkAutosuggest.module.css";
20
21
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
21
22
  const getClassName = cssModules(STYLES);
22
- const BpkAutosuggestSuggestion = props => {
23
+ const BpkAutosuggestSuggestion = ({
24
+ className,
25
+ icon: Icon,
26
+ indent = false,
27
+ subHeading,
28
+ tertiaryLabel,
29
+ value,
30
+ ...rest
31
+ }) => {
23
32
  const classNames = [getClassName('bpk-autosuggest__suggestion')];
24
- const {
25
- className,
26
- icon,
27
- indent,
28
- subHeading,
29
- tertiaryLabel,
30
- value,
31
- ...rest
32
- } = props;
33
- const Icon = icon;
34
33
  if (indent) {
35
34
  classNames.push(getClassName('bpk-autosuggest__suggestion--indent'));
36
35
  }
37
36
  if (className) {
38
37
  classNames.push(className);
39
38
  }
40
- return (
41
- /*#__PURE__*/
42
- // $FlowFixMe[cannot-spread-inexact] - inexact rest. See 'decisions/flowfixme.md'.
43
- _jsxs("section", {
44
- className: classNames.join(' '),
45
- ...rest,
46
- children: [icon ? /*#__PURE__*/_jsx("div", {
47
- className: getClassName('bpk-autosuggest__suggestion-icon'),
48
- children: /*#__PURE__*/_jsx(Icon, {})
49
- }) : null, /*#__PURE__*/_jsx("div", {
50
- className: getClassName('bpk-autosuggest__suggestion-content'),
51
- children: /*#__PURE__*/_jsxs("div", {
52
- className: getClassName('bpk-autosuggest__suggestion-inner'),
53
- children: [/*#__PURE__*/_jsxs("div", {
54
- children: [/*#__PURE__*/_jsx("span", {
55
- className: getClassName('bpk-autosuggest__suggestion-value'),
56
- children: value
57
- }), subHeading || tertiaryLabel ? /*#__PURE__*/_jsx("small", {
58
- className: getClassName('bpk-autosuggest__suggestion-sub-heading'),
59
- children: subHeading
60
- }) : null]
61
- }), tertiaryLabel ? /*#__PURE__*/_jsx("aside", {
62
- className: getClassName('bpk-autosuggest__suggestion-tertiary-label'),
63
- children: tertiaryLabel
39
+ return /*#__PURE__*/_jsxs("section", {
40
+ className: classNames.join(' '),
41
+ ...rest,
42
+ children: [Icon ? /*#__PURE__*/_jsx("div", {
43
+ className: getClassName('bpk-autosuggest__suggestion-icon'),
44
+ children: /*#__PURE__*/_jsx(Icon, {})
45
+ }) : null, /*#__PURE__*/_jsx("div", {
46
+ className: getClassName('bpk-autosuggest__suggestion-content'),
47
+ children: /*#__PURE__*/_jsxs("div", {
48
+ className: getClassName('bpk-autosuggest__suggestion-inner'),
49
+ children: [/*#__PURE__*/_jsxs("div", {
50
+ children: [/*#__PURE__*/_jsx("span", {
51
+ className: getClassName('bpk-autosuggest__suggestion-value'),
52
+ children: value
53
+ }), subHeading || tertiaryLabel ? /*#__PURE__*/_jsx("small", {
54
+ className: getClassName('bpk-autosuggest__suggestion-sub-heading'),
55
+ children: subHeading
64
56
  }) : null]
65
- })
66
- })]
67
- })
68
- );
69
- };
70
- BpkAutosuggestSuggestion.propTypes = {
71
- value: PropTypes.node.isRequired,
72
- subHeading: PropTypes.node,
73
- tertiaryLabel: PropTypes.string,
74
- icon: PropTypes.func,
75
- indent: PropTypes.bool,
76
- className: PropTypes.string
77
- };
78
- BpkAutosuggestSuggestion.defaultProps = {
79
- subHeading: null,
80
- tertiaryLabel: null,
81
- icon: null,
82
- indent: false,
83
- className: null
57
+ }), tertiaryLabel ? /*#__PURE__*/_jsx("aside", {
58
+ className: getClassName('bpk-autosuggest__suggestion-tertiary-label'),
59
+ children: tertiaryLabel
60
+ }) : null]
61
+ })
62
+ })]
63
+ });
84
64
  };
85
65
  export default BpkAutosuggestSuggestion;
@@ -0,0 +1,11 @@
1
+ import BpkCollapsible from './src/BpkCollapsible';
2
+ export { default as useBpkCollapsible } from './src/useBpkCollapsible';
3
+ export { COLLAPSIBLE_VARIANTS } from './src/common-types';
4
+ export default BpkCollapsible;
5
+ export type { BpkCollapsibleOpenChangeDetails, BpkCollapsibleVariant, } from './src/common-types';
6
+ export type { BpkCollapsibleRootProps } from './src/BpkCollapsibleRoot';
7
+ export type { BpkCollapsibleRootProviderProps } from './src/BpkCollapsibleRootProvider';
8
+ export type { BpkCollapsibleTriggerProps } from './src/BpkCollapsibleTrigger';
9
+ export type { BpkCollapsibleIndicatorProps } from './src/BpkCollapsibleIndicator';
10
+ export type { BpkCollapsibleContentProps } from './src/BpkCollapsibleContent';
11
+ export type { BpkUseCollapsibleProps, BpkUseCollapsibleReturn, } from './src/useBpkCollapsible';
@@ -0,0 +1,22 @@
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 BpkCollapsible from "./src/BpkCollapsible";
20
+ export { default as useBpkCollapsible } from "./src/useBpkCollapsible";
21
+ export { COLLAPSIBLE_VARIANTS } from "./src/common-types";
22
+ export default BpkCollapsible;
@@ -0,0 +1,8 @@
1
+ declare const BpkCollapsible: {
2
+ Root: ({ children, collapsedHeight, defaultOpen, disabled, ids, lazyMount, onExitComplete, onOpenChange, open, unmountOnExit, variant, }: import("./BpkCollapsibleRoot").BpkCollapsibleRootProps) => import("react/jsx-runtime").JSX.Element;
3
+ RootProvider: ({ children, value, variant, }: import("./BpkCollapsibleRootProvider").BpkCollapsibleRootProviderProps) => import("react/jsx-runtime").JSX.Element;
4
+ Trigger: import("react").ForwardRefExoticComponent<import("./BpkCollapsibleTrigger").BpkCollapsibleTriggerProps & import("react").RefAttributes<HTMLButtonElement>>;
5
+ Indicator: import("react").ForwardRefExoticComponent<import("./BpkCollapsibleIndicator").BpkCollapsibleIndicatorProps & import("react").RefAttributes<HTMLDivElement>>;
6
+ Content: import("react").ForwardRefExoticComponent<import("./BpkCollapsibleContent").BpkCollapsibleContentProps & import("react").RefAttributes<HTMLDivElement>>;
7
+ };
8
+ export default BpkCollapsible;
@@ -0,0 +1,31 @@
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 BpkCollapsibleContent from "./BpkCollapsibleContent";
20
+ import BpkCollapsibleIndicator from "./BpkCollapsibleIndicator";
21
+ import BpkCollapsibleRoot from "./BpkCollapsibleRoot";
22
+ import BpkCollapsibleRootProvider from "./BpkCollapsibleRootProvider";
23
+ import BpkCollapsibleTrigger from "./BpkCollapsibleTrigger";
24
+ const BpkCollapsible = {
25
+ Root: BpkCollapsibleRoot,
26
+ RootProvider: BpkCollapsibleRootProvider,
27
+ Trigger: BpkCollapsibleTrigger,
28
+ Indicator: BpkCollapsibleIndicator,
29
+ Content: BpkCollapsibleContent
30
+ };
31
+ export default BpkCollapsible;
@@ -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
+ .bpk-collapsible{display:block;inline-size:100%;min-inline-size:0}.bpk-collapsible--default{color:#161616}.bpk-collapsible--on-contrast{color:#fff}.bpk-collapsible--on-contrast .bpk-collapsible__trigger:disabled,.bpk-collapsible--on-contrast .bpk-collapsible__content[data-disabled]{color:hsla(0,0%,100%,.5)}.bpk-collapsible__trigger{display:flex;padding:0;align-items:center;border:0;background:rgba(0,0,0,0);color:inherit;text-align:start;cursor:pointer;appearance:none;gap:.25rem;inline-size:100%}.bpk-collapsible__trigger:disabled,.bpk-collapsible__trigger[data-disabled]{cursor:not-allowed}.bpk-collapsible__trigger:disabled{color:rgba(0,0,0,.2)}.bpk-collapsible__trigger:focus-visible{outline:.125rem solid #0062e3;outline-offset:.125rem}.bpk-collapsible__indicator{display:inline-flex;justify-content:center;align-items:center;transition:transform 200ms ease;color:inherit;margin-inline-start:auto}@media(prefers-reduced-motion: reduce){.bpk-collapsible__indicator{transition:none}}.bpk-collapsible__indicator svg{fill:currentcolor}.bpk-collapsible__indicator[data-state=open]{transform:rotate(180deg)}.bpk-collapsible__content{overflow:hidden}@media(prefers-reduced-motion: reduce){.bpk-collapsible__content[data-state=open],.bpk-collapsible__content[data-state=closing],.bpk-collapsible__content[data-state=closed]{animation:none}}.bpk-collapsible__content[data-disabled]{color:rgba(0,0,0,.2)}.bpk-collapsible__content[data-state=open]{animation:bpk-collapsible-expand 200ms ease}.bpk-collapsible__content[data-state=closing],.bpk-collapsible__content[data-state=closed]{animation:bpk-collapsible-collapse 200ms ease}.bpk-collapsible__content-inner{display:block}@keyframes bpk-collapsible-expand{from{block-size:var(--collapsed-height, 0)}to{block-size:var(--height)}}@keyframes bpk-collapsible-collapse{from{block-size:var(--height)}to{block-size:var(--collapsed-height, 0)}}
@@ -0,0 +1,6 @@
1
+ import type { ReactNode } from 'react';
2
+ export type BpkCollapsibleContentProps = {
3
+ children: ReactNode;
4
+ };
5
+ declare const BpkCollapsibleContent: import("react").ForwardRefExoticComponent<BpkCollapsibleContentProps & import("react").RefAttributes<HTMLDivElement>>;
6
+ export default BpkCollapsibleContent;
@@ -0,0 +1,36 @@
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 { forwardRef } from 'react';
20
+ import { Collapsible } from '@ark-ui/react';
21
+ import { cssModules } from "../../bpk-react-utils";
22
+ import STYLES from "./BpkCollapsible.module.css";
23
+ import { jsx as _jsx } from "react/jsx-runtime";
24
+ const getClassName = cssModules(STYLES);
25
+ const BpkCollapsibleContent = /*#__PURE__*/forwardRef(({
26
+ children
27
+ }, ref) => /*#__PURE__*/_jsx(Collapsible.Content, {
28
+ ref: ref,
29
+ className: getClassName('bpk-collapsible__content'),
30
+ children: /*#__PURE__*/_jsx("div", {
31
+ className: getClassName('bpk-collapsible__content-inner'),
32
+ children: children
33
+ })
34
+ }));
35
+ BpkCollapsibleContent.displayName = 'BpkCollapsibleContent';
36
+ export default BpkCollapsibleContent;
@@ -0,0 +1,6 @@
1
+ import type { ReactNode } from 'react';
2
+ export type BpkCollapsibleIndicatorProps = {
3
+ children: ReactNode;
4
+ };
5
+ declare const BpkCollapsibleIndicator: import("react").ForwardRefExoticComponent<BpkCollapsibleIndicatorProps & import("react").RefAttributes<HTMLDivElement>>;
6
+ export default BpkCollapsibleIndicator;
@@ -0,0 +1,34 @@
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 { forwardRef } from 'react';
20
+ import { Collapsible } from '@ark-ui/react';
21
+ import { cssModules } from "../../bpk-react-utils";
22
+ import STYLES from "./BpkCollapsible.module.css";
23
+ import { jsx as _jsx } from "react/jsx-runtime";
24
+ const getClassName = cssModules(STYLES);
25
+ const BpkCollapsibleIndicator = /*#__PURE__*/forwardRef(({
26
+ children
27
+ }, ref) => /*#__PURE__*/_jsx(Collapsible.Indicator, {
28
+ ref: ref,
29
+ className: getClassName('bpk-collapsible__indicator'),
30
+ "aria-hidden": true,
31
+ children: children
32
+ }));
33
+ BpkCollapsibleIndicator.displayName = 'BpkCollapsibleIndicator';
34
+ export default BpkCollapsibleIndicator;
@@ -0,0 +1,22 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { BpkCollapsibleOpenChangeDetails, BpkCollapsibleVariant } from './common-types';
3
+ type ElementIds = Partial<{
4
+ root: string;
5
+ trigger: string;
6
+ content: string;
7
+ }>;
8
+ export type BpkCollapsibleRootProps = {
9
+ children: ReactNode;
10
+ collapsedHeight?: string | number;
11
+ defaultOpen?: boolean;
12
+ disabled?: boolean;
13
+ ids?: ElementIds;
14
+ lazyMount?: boolean;
15
+ onExitComplete?: () => void;
16
+ onOpenChange?: (details: BpkCollapsibleOpenChangeDetails) => void;
17
+ open?: boolean;
18
+ unmountOnExit?: boolean;
19
+ variant?: BpkCollapsibleVariant;
20
+ };
21
+ declare const BpkCollapsibleRoot: ({ children, collapsedHeight, defaultOpen, disabled, ids, lazyMount, onExitComplete, onOpenChange, open, unmountOnExit, variant, }: BpkCollapsibleRootProps) => import("react/jsx-runtime").JSX.Element;
22
+ export default BpkCollapsibleRoot;
@@ -0,0 +1,49 @@
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 { Collapsible } from '@ark-ui/react';
20
+ import { getDataComponentAttribute } from "../../bpk-react-utils";
21
+ import { COLLAPSIBLE_VARIANTS, getRootClassName } from "./common-types";
22
+ import { jsx as _jsx } from "react/jsx-runtime";
23
+ const BpkCollapsibleRoot = ({
24
+ children,
25
+ collapsedHeight,
26
+ defaultOpen,
27
+ disabled = false,
28
+ ids,
29
+ lazyMount,
30
+ onExitComplete,
31
+ onOpenChange,
32
+ open,
33
+ unmountOnExit,
34
+ variant = COLLAPSIBLE_VARIANTS.default
35
+ }) => /*#__PURE__*/_jsx(Collapsible.Root, {
36
+ className: getRootClassName(variant),
37
+ collapsedHeight: collapsedHeight,
38
+ defaultOpen: defaultOpen,
39
+ disabled: disabled,
40
+ ids: ids,
41
+ lazyMount: lazyMount,
42
+ onExitComplete: onExitComplete,
43
+ onOpenChange: onOpenChange,
44
+ open: open,
45
+ unmountOnExit: unmountOnExit,
46
+ ...getDataComponentAttribute('Collapsible'),
47
+ children: children
48
+ });
49
+ export default BpkCollapsibleRoot;
@@ -0,0 +1,10 @@
1
+ import type { ReactNode } from 'react';
2
+ import type { BpkCollapsibleVariant } from './common-types';
3
+ import type { BpkUseCollapsibleReturn } from './useBpkCollapsible';
4
+ export type BpkCollapsibleRootProviderProps = {
5
+ children: ReactNode;
6
+ value: BpkUseCollapsibleReturn;
7
+ variant?: BpkCollapsibleVariant;
8
+ };
9
+ declare const BpkCollapsibleRootProvider: ({ children, value, variant, }: BpkCollapsibleRootProviderProps) => import("react/jsx-runtime").JSX.Element;
10
+ export default BpkCollapsibleRootProvider;
@@ -0,0 +1,33 @@
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 { Collapsible } from '@ark-ui/react';
20
+ import { getDataComponentAttribute } from "../../bpk-react-utils";
21
+ import { COLLAPSIBLE_VARIANTS, getRootClassName } from "./common-types";
22
+ import { jsx as _jsx } from "react/jsx-runtime";
23
+ const BpkCollapsibleRootProvider = ({
24
+ children,
25
+ value,
26
+ variant = COLLAPSIBLE_VARIANTS.default
27
+ }) => /*#__PURE__*/_jsx(Collapsible.RootProvider, {
28
+ className: getRootClassName(variant),
29
+ value: value,
30
+ ...getDataComponentAttribute('Collapsible'),
31
+ children: children
32
+ });
33
+ export default BpkCollapsibleRootProvider;
@@ -0,0 +1,6 @@
1
+ import type { ReactNode } from 'react';
2
+ export type BpkCollapsibleTriggerProps = {
3
+ children: ReactNode;
4
+ };
5
+ declare const BpkCollapsibleTrigger: import("react").ForwardRefExoticComponent<BpkCollapsibleTriggerProps & import("react").RefAttributes<HTMLButtonElement>>;
6
+ export default BpkCollapsibleTrigger;
@@ -0,0 +1,43 @@
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 { forwardRef } from 'react';
20
+ import { Collapsible, useCollapsibleContext } from '@ark-ui/react';
21
+ import { cssModules } from "../../bpk-react-utils";
22
+ import STYLES from "./BpkCollapsible.module.css";
23
+ import { jsx as _jsx } from "react/jsx-runtime";
24
+ const getClassName = cssModules(STYLES);
25
+ // Applies the native HTML `disabled` attribute to the underlying <button> so
26
+ // the trigger is removed from the tab order and announced as disabled by
27
+ // assistive tech. Ark/Zag only emit `data-disabled`, which would otherwise
28
+ // leave the button tabbable and announced as enabled.
29
+ const BpkCollapsibleTrigger = /*#__PURE__*/forwardRef(({
30
+ children
31
+ }, ref) => {
32
+ const {
33
+ disabled
34
+ } = useCollapsibleContext();
35
+ return /*#__PURE__*/_jsx(Collapsible.Trigger, {
36
+ ref: ref,
37
+ className: getClassName('bpk-collapsible__trigger'),
38
+ disabled: disabled,
39
+ children: children
40
+ });
41
+ });
42
+ BpkCollapsibleTrigger.displayName = 'BpkCollapsibleTrigger';
43
+ export default BpkCollapsibleTrigger;
@@ -0,0 +1,9 @@
1
+ export declare const COLLAPSIBLE_VARIANTS: {
2
+ readonly default: "default";
3
+ readonly onContrast: "onContrast";
4
+ };
5
+ export type BpkCollapsibleVariant = (typeof COLLAPSIBLE_VARIANTS)[keyof typeof COLLAPSIBLE_VARIANTS];
6
+ export type BpkCollapsibleOpenChangeDetails = {
7
+ open: boolean;
8
+ };
9
+ export declare const getRootClassName: (variant: BpkCollapsibleVariant) => string;
@@ -0,0 +1,29 @@
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 { cssModules } from "../../bpk-react-utils";
20
+ import STYLES from "./BpkCollapsible.module.css";
21
+ export const COLLAPSIBLE_VARIANTS = {
22
+ default: 'default',
23
+ onContrast: 'onContrast'
24
+ };
25
+ const getClassName = cssModules(STYLES);
26
+ export const getRootClassName = variant => {
27
+ const variantModifier = variant === COLLAPSIBLE_VARIANTS.onContrast ? 'on-contrast' : 'default';
28
+ return getClassName('bpk-collapsible', `bpk-collapsible--${variantModifier}`);
29
+ };
@@ -0,0 +1,5 @@
1
+ import type { UseCollapsibleProps, UseCollapsibleReturn } from '@ark-ui/react';
2
+ export type BpkUseCollapsibleProps = UseCollapsibleProps;
3
+ export type BpkUseCollapsibleReturn = UseCollapsibleReturn;
4
+ declare const useBpkCollapsible: (props?: BpkUseCollapsibleProps) => BpkUseCollapsibleReturn;
5
+ export default useBpkCollapsible;
@@ -0,0 +1,21 @@
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 { useCollapsible } from '@ark-ui/react';
20
+ const useBpkCollapsible = props => useCollapsible(props);
21
+ export default useBpkCollapsible;
@@ -0,0 +1,6 @@
1
+ import BpkHorizontalNav, { HORIZONTAL_NAV_TYPES, type Props as NavProps } from './src/BpkHorizontalNav';
2
+ import BpkHorizontalNavItem, { type Props as ItemProps, themeAttributes } from './src/BpkHorizontalNavItem';
3
+ export type BpkHorizontalNavProps = NavProps;
4
+ export type BpkHorizontalNavItemProps = ItemProps;
5
+ export { HORIZONTAL_NAV_TYPES, BpkHorizontalNavItem, themeAttributes };
6
+ export default BpkHorizontalNav;
@@ -14,7 +14,9 @@
14
14
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
15
  * See the License for the specific language governing permissions and
16
16
  * limitations under the License.
17
- */import BpkHorizontalNav, { HORIZONTAL_NAV_TYPES } from "./src/BpkHorizontalNav";
17
+ */
18
+
19
+ import BpkHorizontalNav, { HORIZONTAL_NAV_TYPES } from "./src/BpkHorizontalNav";
18
20
  import BpkHorizontalNavItem, { themeAttributes } from "./src/BpkHorizontalNavItem";
19
21
  export { HORIZONTAL_NAV_TYPES, BpkHorizontalNavItem, themeAttributes };
20
22
  export default BpkHorizontalNav;
@@ -0,0 +1,27 @@
1
+ import { type ReactNode } from 'react';
2
+ declare const HORIZONTAL_NAV_TYPES: {
3
+ readonly default: "default";
4
+ readonly light: "light";
5
+ };
6
+ type Props = {
7
+ children: ReactNode;
8
+ ariaLabel?: string | null;
9
+ /**
10
+ * Ensures that the selected item is within view when loaded on narrow-screened devices.
11
+ */
12
+ autoScrollToSelected?: boolean;
13
+ className?: string | null;
14
+ leadingScrollIndicatorClassName?: string | null;
15
+ /**
16
+ * When set to "false", the bottom border on the component isn't included. This refers
17
+ * to the underline on the whole "BpkHorizontalNav", not the line that appears under the selected item.
18
+ */
19
+ showUnderline?: boolean;
20
+ trailingScrollIndicatorClassName?: string | null;
21
+ type?: keyof typeof HORIZONTAL_NAV_TYPES;
22
+ [rest: string]: any;
23
+ };
24
+ declare const BpkHorizontalNav: ({ ariaLabel, autoScrollToSelected, children: rawChildren, className, leadingScrollIndicatorClassName, showUnderline, trailingScrollIndicatorClassName, type, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
25
+ export type { Props };
26
+ export default BpkHorizontalNav;
27
+ export { HORIZONTAL_NAV_TYPES };
@@ -14,8 +14,9 @@
14
14
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
15
  * See the License for the specific language governing permissions and
16
16
  * limitations under the License.
17
- */import PropTypes from 'prop-types';
18
- import { Component, Children, cloneElement } from 'react';
17
+ */
18
+
19
+ import { Children, cloneElement, useCallback, useEffect, useRef } from 'react';
19
20
  import BpkMobileScrollContainer from "../../bpk-component-mobile-scroll-container";
20
21
  import { cssModules } from "../../bpk-react-utils";
21
22
  import STYLES from "./BpkHorizontalNav.module.css";
@@ -29,138 +30,102 @@ const getPos = ref => {
29
30
  if (!ref) {
30
31
  return null;
31
32
  }
32
- const pos = ref.getBoundingClientRect();
33
- return pos;
33
+ return ref.getBoundingClientRect();
34
34
  };
35
- class BpkHorizontalNav extends Component {
36
- constructor(props) {
37
- super(props);
38
- this.scrollRef = null;
39
- this.selectedItemRef = null;
40
- }
41
- componentDidMount() {
42
- requestAnimationFrame(() => {
43
- this.scrollSelectedIntoView(false);
44
- });
45
- }
46
- componentDidUpdate() {
47
- this.scrollSelectedIntoView(true);
48
- }
49
- scrollSelectedIntoView = useSmoothScroll => {
50
- if (!this.props.autoScrollToSelected || !this.scrollRef || !this.selectedItemRef) {
51
- return;
52
- }
53
- if (!this.scrollRef) {
35
+ const BpkHorizontalNav = ({
36
+ ariaLabel = null,
37
+ autoScrollToSelected = false,
38
+ children: rawChildren,
39
+ className = null,
40
+ leadingScrollIndicatorClassName = null,
41
+ showUnderline = true,
42
+ trailingScrollIndicatorClassName = null,
43
+ type = HORIZONTAL_NAV_TYPES.default,
44
+ ...rest
45
+ }) => {
46
+ const scrollRef = useRef(null);
47
+ const selectedItemRef = useRef(null);
48
+ const isMounted = useRef(false);
49
+ const scrollSelectedIntoView = useCallback(useSmoothScroll => {
50
+ if (!autoScrollToSelected || !scrollRef.current || !selectedItemRef.current) {
54
51
  return;
55
52
  }
56
- const selectedItemPos = getPos(this.selectedItemRef);
53
+ const selectedItemPos = getPos(selectedItemRef.current);
57
54
  if (!selectedItemPos) {
58
55
  return;
59
56
  }
60
- const scrollPos = getPos(this.scrollRef);
57
+ const scrollPos = getPos(scrollRef.current);
61
58
  if (!scrollPos) {
62
59
  return;
63
60
  }
64
-
65
- // We only need to carry out a scroll if the element is not already fully within the scroll view
66
61
  const needsScroll = selectedItemPos.left < scrollPos.left || selectedItemPos.right > scrollPos.right;
67
62
  if (!needsScroll) {
68
63
  return;
69
64
  }
70
65
  const scrollAdjustment = selectedItemPos.left - scrollPos.left;
71
- // Some browsers don't support smooth scrolling, so in those cases we must fall back to simply setting `scrollLeft`
72
- if (this.scrollRef && this.scrollRef.scroll && typeof this.scrollRef.scroll === 'function' && useSmoothScroll) {
73
- this.scrollRef.scroll({
66
+ if (scrollRef.current.scroll && typeof scrollRef.current.scroll === 'function' && useSmoothScroll) {
67
+ scrollRef.current.scroll({
74
68
  left: scrollAdjustment,
75
69
  behavior: 'smooth'
76
70
  });
77
- } else if (this.scrollRef) {
78
- this.scrollRef.scrollLeft = scrollAdjustment;
71
+ } else {
72
+ scrollRef.current.scrollLeft = scrollAdjustment;
79
73
  }
80
- };
81
- render() {
82
- const {
83
- ariaLabel,
84
- autoScrollToSelected,
85
- children: rawChildren,
86
- className,
87
- leadingScrollIndicatorClassName,
88
- showUnderline,
89
- trailingScrollIndicatorClassName,
90
- type,
91
- ...rest
92
- } = this.props;
93
- const classNames = getClassName('bpk-horizontal-nav', showUnderline && `bpk-horizontal-nav--show-${type}-underline`, className);
94
- let children = rawChildren;
95
- if (autoScrollToSelected || type === HORIZONTAL_NAV_TYPES.light) {
96
- children = Children.map(rawChildren, child => {
97
- const childProps = {};
98
- let childRef;
99
- if (autoScrollToSelected) {
100
- if (child && child.props && child.props.selected) {
101
- childRef = ref => {
102
- this.selectedItemRef = ref;
103
- };
104
- }
105
- }
106
- if (type === HORIZONTAL_NAV_TYPES.light) {
107
- childProps.type = HORIZONTAL_NAV_TYPES.light;
108
- }
109
- return child ? /*#__PURE__*/_jsx("div", {
110
- ref: childRef,
111
- children: /*#__PURE__*/cloneElement(child, childProps)
112
- }) : null;
113
- });
74
+ }, [autoScrollToSelected]);
75
+ useEffect(() => {
76
+ requestAnimationFrame(() => {
77
+ scrollSelectedIntoView(false);
78
+ });
79
+ // eslint-disable-next-line react-hooks/exhaustive-deps
80
+ }, []);
81
+ useEffect(() => {
82
+ if (isMounted.current) {
83
+ scrollSelectedIntoView(true);
84
+ } else {
85
+ isMounted.current = true;
114
86
  }
115
- return (
116
- /*#__PURE__*/
117
- // $FlowFixMe[cannot-spread-inexact] - inexact rest. See 'decisions/flowfixme.md'.
118
- _jsx("div", {
119
- className: classNames,
120
- children: /*#__PURE__*/_jsx(BpkMobileScrollContainer, {
121
- ariaLabel: ariaLabel,
122
- innerContainerTagName: "nav",
123
- leadingIndicatorClassName: leadingScrollIndicatorClassName,
124
- trailingIndicatorClassName: trailingScrollIndicatorClassName,
125
- scrollerRef: ref => {
126
- this.scrollRef = ref;
127
- },
128
- ...rest,
129
- children: /*#__PURE__*/_jsx("div", {
130
- className: getClassName('bpk-horizontal-nav__list'),
131
- role: "tablist",
132
- children: children
133
- })
134
- })
135
- })
136
- );
87
+ });
88
+ const classNames = getClassName('bpk-horizontal-nav', showUnderline && `bpk-horizontal-nav--show-${type}-underline`, className);
89
+ let children = rawChildren;
90
+ if (autoScrollToSelected || type === HORIZONTAL_NAV_TYPES.light) {
91
+ children = Children.map(rawChildren, child => {
92
+ const isElement = typeof child === 'object' && child !== null && 'props' in child;
93
+ const childProps = {};
94
+ let childRef;
95
+ if (autoScrollToSelected) {
96
+ if (isElement && child.props.selected) {
97
+ childRef = ref => {
98
+ selectedItemRef.current = ref;
99
+ };
100
+ }
101
+ }
102
+ if (type === HORIZONTAL_NAV_TYPES.light) {
103
+ childProps.type = HORIZONTAL_NAV_TYPES.light;
104
+ }
105
+ return isElement ? /*#__PURE__*/_jsx("div", {
106
+ ref: childRef,
107
+ children: /*#__PURE__*/cloneElement(child, childProps)
108
+ }) : null;
109
+ });
137
110
  }
138
- }
139
- BpkHorizontalNav.propTypes = {
140
- ariaLabel: PropTypes.string,
141
- children: PropTypes.node.isRequired,
142
- /**
143
- * Ensures that the selected item is within view when loaded on narrow-screened devices.
144
- */
145
- autoScrollToSelected: PropTypes.bool,
146
- className: PropTypes.string,
147
- leadingScrollIndicatorClassName: PropTypes.string,
148
- /**
149
- * When set to "false", the bottom border on the component isn't included. This refers
150
- * to the underline on the whole "BpkHorizontalNav", not the line that appears under the selected item.
151
- */
152
- showUnderline: PropTypes.bool,
153
- trailingScrollIndicatorClassName: PropTypes.string,
154
- type: PropTypes.oneOf(Object.keys(HORIZONTAL_NAV_TYPES))
155
- };
156
- BpkHorizontalNav.defaultProps = {
157
- ariaLabel: null,
158
- autoScrollToSelected: false,
159
- className: null,
160
- leadingScrollIndicatorClassName: null,
161
- showUnderline: true,
162
- trailingScrollIndicatorClassName: null,
163
- type: HORIZONTAL_NAV_TYPES.default
111
+ return /*#__PURE__*/_jsx("div", {
112
+ className: classNames,
113
+ children: /*#__PURE__*/_jsx(BpkMobileScrollContainer, {
114
+ ariaLabel: ariaLabel ?? undefined,
115
+ innerContainerTagName: "nav",
116
+ leadingIndicatorClassName: leadingScrollIndicatorClassName ?? undefined,
117
+ trailingIndicatorClassName: trailingScrollIndicatorClassName ?? undefined,
118
+ scrollerRef: ref => {
119
+ scrollRef.current = ref;
120
+ },
121
+ ...rest,
122
+ children: /*#__PURE__*/_jsx("div", {
123
+ className: getClassName('bpk-horizontal-nav__list'),
124
+ role: "tablist",
125
+ children: children
126
+ })
127
+ })
128
+ });
164
129
  };
165
130
  export default BpkHorizontalNav;
166
131
  export { HORIZONTAL_NAV_TYPES };
@@ -0,0 +1,25 @@
1
+ import { type ReactNode } from 'react';
2
+ import { HORIZONTAL_NAV_TYPES } from './BpkHorizontalNav';
3
+ type Props = {
4
+ children: ReactNode;
5
+ className?: string | null;
6
+ /**
7
+ * **Note:**
8
+ * "disabled" and "selected" are mutually exclusive for true values, i.e. only one of them can be true for a given nav item.
9
+ */
10
+ disabled?: boolean;
11
+ href?: string | null;
12
+ /**
13
+ * **Note:**
14
+ * "disabled" and "selected" are mutually exclusive for true values, i.e. only one of them can be true for a given nav item.
15
+ */
16
+ selected?: boolean;
17
+ spaceAround?: boolean;
18
+ type?: keyof typeof HORIZONTAL_NAV_TYPES;
19
+ [rest: string]: any;
20
+ };
21
+ declare const BpkHorizontalNavItem: import("react").ForwardRefExoticComponent<Omit<Props, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
22
+ declare const themeAttributes: string[];
23
+ export type { Props };
24
+ export { themeAttributes };
25
+ export default BpkHorizontalNavItem;
@@ -14,84 +14,49 @@
14
14
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
15
  * See the License for the specific language governing permissions and
16
16
  * limitations under the License.
17
- */import PropTypes from 'prop-types';
18
- import { Component } from 'react';
17
+ */
18
+
19
+ import { forwardRef } from 'react';
19
20
  import { cssModules } from "../../bpk-react-utils";
20
21
  import { HORIZONTAL_NAV_TYPES } from "./BpkHorizontalNav";
21
22
  import STYLES from "./BpkHorizontalNavItem.module.css";
22
23
  import { jsx as _jsx } from "react/jsx-runtime";
23
24
  const getClassName = cssModules(STYLES);
24
- // In order to be able to access refs on the HorizontalNavItems, they need to be a fully defined
25
- // React Component class.
26
- // eslint-disable-next-line react/prefer-stateless-function
27
- class BpkHorizontalNavItem extends Component {
28
- render() {
29
- const {
30
- children,
31
- className,
32
- disabled,
33
- href,
34
- selected,
35
- spaceAround,
36
- type,
37
- ...rest
38
- } = this.props;
39
- const classNames = getClassName('bpk-horizontal-nav__item', spaceAround && 'bpk-horizontal-nav__item--space-around');
40
- const innerClassNames = getClassName('bpk-horizontal-nav__link', `bpk-horizontal-nav__link--${type}`, selected && `bpk-horizontal-nav__link--${type}-selected`, disabled && `bpk-horizontal-nav__link--${type}-disabled`, className);
41
- const clickableElement = href ?
42
- /*#__PURE__*/
43
- // $FlowFixMe[cannot-spread-inexact] - inexact rest. See 'decisions/flowfixme.md'.
44
- _jsx("a", {
45
- href: href,
46
- className: innerClassNames,
47
- "aria-disabled": disabled,
48
- role: "tab",
49
- "aria-selected": selected ? 'true' : 'false',
50
- ...rest,
51
- children: children
52
- }) :
53
- /*#__PURE__*/
54
- // $FlowFixMe[cannot-spread-inexact] - inexact rest. See 'decisions/flowfixme.md'.
55
- _jsx("button", {
56
- type: "button",
57
- className: innerClassNames,
58
- disabled: disabled,
59
- role: "tab",
60
- "aria-selected": selected ? 'true' : 'false',
61
- ...rest,
62
- children: children
63
- });
64
- return /*#__PURE__*/_jsx("div", {
65
- className: classNames,
66
- children: clickableElement
67
- });
68
- }
69
- }
70
- BpkHorizontalNavItem.propTypes = {
71
- children: PropTypes.node.isRequired,
72
- className: PropTypes.string,
73
- /**
74
- * **Note:**
75
- * "disabled" and "selected" are mutually exclusive for true values, i.e. only one of them can be true for a given nav item.
76
- */
77
- disabled: PropTypes.bool,
78
- href: PropTypes.string,
79
- /**
80
- * **Note:**
81
- * "disabled" and "selected" are mutually exclusive for true values, i.e. only one of them can be true for a given nav item.
82
- */
83
- selected: PropTypes.bool,
84
- spaceAround: PropTypes.bool,
85
- type: PropTypes.oneOf(Object.keys(HORIZONTAL_NAV_TYPES))
86
- };
87
- BpkHorizontalNavItem.defaultProps = {
88
- className: null,
89
- disabled: false,
90
- href: null,
91
- selected: false,
92
- spaceAround: false,
93
- type: HORIZONTAL_NAV_TYPES.default
94
- };
25
+ const BpkHorizontalNavItem = /*#__PURE__*/forwardRef(({
26
+ children,
27
+ className = null,
28
+ disabled = false,
29
+ href = null,
30
+ selected = false,
31
+ spaceAround = false,
32
+ type = HORIZONTAL_NAV_TYPES.default,
33
+ ...rest
34
+ }, ref) => {
35
+ const classNames = getClassName('bpk-horizontal-nav__item', spaceAround && 'bpk-horizontal-nav__item--space-around');
36
+ const innerClassNames = getClassName('bpk-horizontal-nav__link', `bpk-horizontal-nav__link--${type}`, selected && `bpk-horizontal-nav__link--${type}-selected`, disabled && `bpk-horizontal-nav__link--${type}-disabled`, className);
37
+ const clickableElement = href ? /*#__PURE__*/_jsx("a", {
38
+ href: href,
39
+ className: innerClassNames,
40
+ "aria-disabled": disabled,
41
+ role: "tab",
42
+ "aria-selected": selected ? 'true' : 'false',
43
+ ...rest,
44
+ children: children
45
+ }) : /*#__PURE__*/_jsx("button", {
46
+ type: "button",
47
+ className: innerClassNames,
48
+ disabled: disabled,
49
+ role: "tab",
50
+ "aria-selected": selected ? 'true' : 'false',
51
+ ...rest,
52
+ children: children
53
+ });
54
+ return /*#__PURE__*/_jsx("div", {
55
+ ref: ref,
56
+ className: classNames,
57
+ children: clickableElement
58
+ });
59
+ });
95
60
  const themeAttributes = ['horizontalNavLinkColor', 'horizontalNavLinkHoverColor', 'horizontalNavLinkActiveColor', 'horizontalNavLinkSelectedColor', 'horizontalNavBarSelectedColor'];
96
61
  export { themeAttributes };
97
62
  export default BpkHorizontalNavItem;
@@ -1,5 +1,5 @@
1
- import BpkSwitch, { type Props as BpkSwitchProps } from './src/BpkSwitch';
1
+ import BpkSwitch, { SWITCH_VARIANTS, type Props as BpkSwitchProps, type SwitchVariant } from './src/BpkSwitch';
2
2
  import themeAttributes from './src/themeAttributes';
3
- export type { BpkSwitchProps };
4
- export { themeAttributes };
3
+ export type { BpkSwitchProps, SwitchVariant };
4
+ export { SWITCH_VARIANTS, themeAttributes };
5
5
  export default BpkSwitch;
@@ -14,7 +14,7 @@
14
14
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
15
  * See the License for the specific language governing permissions and
16
16
  * limitations under the License.
17
- */import BpkSwitch from "./src/BpkSwitch";
17
+ */import BpkSwitch, { SWITCH_VARIANTS } from "./src/BpkSwitch";
18
18
  import themeAttributes from "./src/themeAttributes";
19
- export { themeAttributes };
19
+ export { SWITCH_VARIANTS, themeAttributes };
20
20
  export default BpkSwitch;
@@ -1,8 +1,14 @@
1
+ export declare const SWITCH_VARIANTS: {
2
+ readonly default: "default";
3
+ readonly onContrast: "onContrast";
4
+ };
5
+ export type SwitchVariant = (typeof SWITCH_VARIANTS)[keyof typeof SWITCH_VARIANTS];
1
6
  export type Props = {
2
7
  ariaLabel: string;
3
8
  className?: string | null;
4
9
  small?: boolean;
10
+ variant?: SwitchVariant;
5
11
  [rest: string]: any;
6
12
  };
7
- declare const BpkSwitch: ({ ariaLabel, className, small, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
13
+ declare const BpkSwitch: ({ ariaLabel, className, small, variant, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
8
14
  export default BpkSwitch;
@@ -19,14 +19,23 @@
19
19
  import { cssModules, getDataComponentAttribute } from "../../bpk-react-utils";
20
20
  import STYLES from "./BpkSwitch.module.css";
21
21
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
22
+ export const SWITCH_VARIANTS = {
23
+ default: 'default',
24
+ onContrast: 'onContrast'
25
+ };
22
26
  const getClassName = cssModules(STYLES);
27
+ const switchVariantClassNames = {
28
+ [SWITCH_VARIANTS.default]: null,
29
+ [SWITCH_VARIANTS.onContrast]: getClassName('bpk-switch__switch--on-contrast')
30
+ };
23
31
  const BpkSwitch = ({
24
32
  ariaLabel,
25
33
  className = null,
26
34
  small = false,
35
+ variant = SWITCH_VARIANTS.default,
27
36
  ...rest
28
37
  }) => {
29
- const switchClassNames = getClassName('bpk-switch__switch', small && 'bpk-switch__switch--small');
38
+ const switchClassNames = getClassName('bpk-switch__switch', small && 'bpk-switch__switch--small', switchVariantClassNames[variant]);
30
39
  return /*#__PURE__*/_jsxs("label", {
31
40
  className: getClassName('bpk-switch', className),
32
41
  ...getDataComponentAttribute('Switch'),
@@ -15,4 +15,4 @@
15
15
  * See the License for the specific language governing permissions and
16
16
  * limitations under the License.
17
17
  */
18
- .bpk-switch{position:relative;display:flex;width:fit-content;align-items:center;border-radius:1rem}.bpk-switch__checkbox{position:absolute;opacity:0}.bpk-switch__checkbox:checked~.bpk-switch__switch{background:#0062e3;background:var(--bpk-switch-checked-color, rgb(0, 98, 227))}.bpk-switch__checkbox:checked~.bpk-switch__switch::before{left:1.375rem}.bpk-switch__checkbox:focus-visible~.bpk-switch__switch{outline:.125rem solid #0062e3;outline-offset:.125rem}.bpk-switch__switch{position:relative;float:right;display:block;min-width:3.25rem;height:2rem;transition:background 200ms linear;border-radius:1rem;background:rgba(0,0,0,.2);cursor:pointer}.bpk-switch__switch::before{position:absolute;top:.125rem;left:.125rem;content:"";display:block;width:1.75rem;height:1.75rem;transition:left 200ms ease-out;border-radius:50%;background:#fff;box-shadow:0px 1px 3px 0px rgba(37,32,31,.3)}.bpk-switch__switch--small{min-width:2.5rem;height:1.25rem}.bpk-switch__switch--small::before{width:1rem;height:1rem}
18
+ .bpk-switch{position:relative;display:flex;width:fit-content;align-items:center;border-radius:1rem}.bpk-switch__checkbox{position:absolute;opacity:0}.bpk-switch__checkbox:checked~.bpk-switch__switch{background:#0062e3;background:var(--bpk-switch-checked-color, rgb(0, 98, 227))}.bpk-switch__checkbox:checked~.bpk-switch__switch::before{left:1.375rem}.bpk-switch__checkbox:focus-visible~.bpk-switch__switch{outline:.125rem solid #0062e3;outline-offset:.125rem}.bpk-switch__switch{position:relative;float:right;display:block;min-width:3.25rem;height:2rem;transition:background 200ms linear;border-radius:1rem;background:rgba(0,0,0,.2);cursor:pointer}.bpk-switch__switch::before{position:absolute;top:.125rem;left:.125rem;content:"";display:block;width:1.75rem;height:1.75rem;transition:left 200ms ease-out;border-radius:50%;background:#fff;box-shadow:0px 1px 3px 0px rgba(37,32,31,.3)}.bpk-switch__switch--small{min-width:2.5rem;height:1.25rem}.bpk-switch__switch--small::before{width:1rem;height:1rem}.bpk-switch__switch--on-contrast{background:hsla(0,0%,100%,.2)}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skyscanner/backpack-web",
3
- "version": "42.16.0",
3
+ "version": "42.17.0",
4
4
  "description": "Backpack Design System web library",
5
5
  "repository": {
6
6
  "type": "git",
@@ -28,7 +28,7 @@
28
28
  "@radix-ui/react-compose-refs": "^1.1.1",
29
29
  "@radix-ui/react-slider": "1.3.5",
30
30
  "@react-google-maps/api": "^2.19.3",
31
- "@skyscanner/bpk-foundations-web": "^24.5.0",
31
+ "@skyscanner/bpk-foundations-web": "^24.6.0",
32
32
  "@skyscanner/bpk-svgs": "^20.11.0",
33
33
  "tabbable": "^6.4.0",
34
34
  "d3-path": "^3.1.0",