@skyscanner/backpack-web 42.15.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 (50) hide show
  1. package/bpk-component-accordion/src/BpkAccordionItem.module.css +1 -1
  2. package/bpk-component-autosuggest/index.d.ts +6 -0
  3. package/bpk-component-autosuggest/index.js +3 -1
  4. package/bpk-component-autosuggest/src/BpkAutosuggest.d.ts +2 -0
  5. package/bpk-component-autosuggest/src/BpkAutosuggest.js +14 -15
  6. package/bpk-component-autosuggest/src/BpkAutosuggest.module.css +1 -1
  7. package/bpk-component-autosuggest/src/BpkAutosuggestSuggestion.d.ts +11 -0
  8. package/bpk-component-autosuggest/src/BpkAutosuggestSuggestion.js +35 -55
  9. package/bpk-component-autosuggest/src/BpkAutosuggestV2/BpkAutosuggest.module.css +1 -1
  10. package/bpk-component-collapsible/index.d.ts +11 -0
  11. package/bpk-component-collapsible/index.js +22 -0
  12. package/bpk-component-collapsible/src/BpkCollapsible.d.ts +8 -0
  13. package/bpk-component-collapsible/src/BpkCollapsible.js +31 -0
  14. package/bpk-component-collapsible/src/BpkCollapsible.module.css +18 -0
  15. package/bpk-component-collapsible/src/BpkCollapsibleContent.d.ts +6 -0
  16. package/bpk-component-collapsible/src/BpkCollapsibleContent.js +36 -0
  17. package/bpk-component-collapsible/src/BpkCollapsibleIndicator.d.ts +6 -0
  18. package/bpk-component-collapsible/src/BpkCollapsibleIndicator.js +34 -0
  19. package/bpk-component-collapsible/src/BpkCollapsibleRoot.d.ts +22 -0
  20. package/bpk-component-collapsible/src/BpkCollapsibleRoot.js +49 -0
  21. package/bpk-component-collapsible/src/BpkCollapsibleRootProvider.d.ts +10 -0
  22. package/bpk-component-collapsible/src/BpkCollapsibleRootProvider.js +33 -0
  23. package/bpk-component-collapsible/src/BpkCollapsibleTrigger.d.ts +6 -0
  24. package/bpk-component-collapsible/src/BpkCollapsibleTrigger.js +43 -0
  25. package/bpk-component-collapsible/src/common-types.d.ts +9 -0
  26. package/bpk-component-collapsible/src/common-types.js +29 -0
  27. package/bpk-component-collapsible/src/useBpkCollapsible.d.ts +5 -0
  28. package/bpk-component-collapsible/src/useBpkCollapsible.js +21 -0
  29. package/bpk-component-comparison-table/src/BpkComparisonTable/BpkComparisonTable.module.css +1 -1
  30. package/bpk-component-comparison-table/src/BpkComparisonTable/BpkComparisonTableColumnHeader.d.ts +2 -4
  31. package/bpk-component-comparison-table/src/BpkComparisonTable/BpkComparisonTableColumnHeader.js +1 -15
  32. package/bpk-component-comparison-table/src/BpkComparisonTable/BpkComparisonTableContent.js +20 -4
  33. package/bpk-component-comparison-table/src/BpkComparisonTable/BpkComparisonTableHeaderRow.d.ts +1 -2
  34. package/bpk-component-comparison-table/src/BpkComparisonTable/BpkComparisonTableHeaderRow.js +1 -5
  35. package/bpk-component-comparison-table/src/BpkComparisonTable/BpkComparisonTableRoot.d.ts +1 -1
  36. package/bpk-component-comparison-table/src/BpkComparisonTable/BpkComparisonTableRoot.js +25 -13
  37. package/bpk-component-comparison-table/src/BpkComparisonTable/common-types.d.ts +2 -0
  38. package/bpk-component-comparison-table/src/BpkComparisonTray/BpkComparisonTray.module.css +1 -1
  39. package/bpk-component-horizontal-nav/index.d.ts +6 -0
  40. package/bpk-component-horizontal-nav/index.js +3 -1
  41. package/bpk-component-horizontal-nav/src/BpkHorizontalNav.d.ts +27 -0
  42. package/bpk-component-horizontal-nav/src/BpkHorizontalNav.js +79 -114
  43. package/bpk-component-horizontal-nav/src/BpkHorizontalNavItem.d.ts +25 -0
  44. package/bpk-component-horizontal-nav/src/BpkHorizontalNavItem.js +38 -73
  45. package/bpk-component-switch/index.d.ts +3 -3
  46. package/bpk-component-switch/index.js +2 -2
  47. package/bpk-component-switch/src/BpkSwitch.d.ts +7 -1
  48. package/bpk-component-switch/src/BpkSwitch.js +10 -1
  49. package/bpk-component-switch/src/BpkSwitch.module.css +1 -1
  50. package/package.json +2 -2
@@ -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.15.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",