@skyscanner/backpack-web 41.7.0 → 41.8.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.
@@ -21,6 +21,7 @@ import BpkBreakpoint, { BREAKPOINTS } from "../../bpk-component-breakpoint";
21
21
  import BpkSelectableChip, { BpkDismissibleChip, BpkIconChip, BpkDropdownChip, CHIP_TYPES } from "../../bpk-component-chip";
22
22
  import BpkMobileScrollContainer from "../../bpk-component-mobile-scroll-container";
23
23
  import BpkText, { TEXT_STYLES } from "../../bpk-component-text/src/BpkText";
24
+ import BpkVisuallyHidden from "../../bpk-component-visually-hidden";
24
25
  import { cssModules } from "../../bpk-react-utils";
25
26
  import BpkStickyChip from "./BpkStickyChip";
26
27
  import Nudger, { POSITION } from "./Nudger";
@@ -85,8 +86,8 @@ const ChipGroupContent = ({
85
86
  }) => /*#__PURE__*/_jsxs("fieldset", {
86
87
  className: chipGroupClassNames,
87
88
  role: ariaMultiselectable ? 'group' : 'radiogroup',
88
- children: [ariaLabel && /*#__PURE__*/_jsx("legend", {
89
- className: "visually-hidden",
89
+ children: [ariaLabel && /*#__PURE__*/_jsx(BpkVisuallyHidden, {
90
+ as: "legend",
90
91
  children: ariaLabel
91
92
  }), label && /*#__PURE__*/_jsx(BpkText, {
92
93
  textStyle: TEXT_STYLES.footnote,
@@ -16,16 +16,14 @@
16
16
  * limitations under the License.
17
17
  */
18
18
 
19
- import { cssModules, wrapDisplayName } from "../../bpk-react-utils";
20
- import STYLES from "./withDescription.module.css";
19
+ import BpkVisuallyHidden from "../../bpk-component-visually-hidden";
20
+ import { wrapDisplayName } from "../../bpk-react-utils";
21
21
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
22
- const getClassName = cssModules(STYLES);
23
22
  export default function withDescription(Component, description) {
24
23
  const WithDescription = props => /*#__PURE__*/_jsxs("span", {
25
24
  children: [/*#__PURE__*/_jsx(Component, {
26
25
  ...props
27
- }), /*#__PURE__*/_jsx("span", {
28
- className: getClassName('bpk-icon-description'),
26
+ }), /*#__PURE__*/_jsx(BpkVisuallyHidden, {
29
27
  children: description
30
28
  })]
31
29
  });
@@ -32,6 +32,7 @@ import ChevronUpIcon from "../../bpk-component-icon/sm/chevron-up";
32
32
  import InfoCircleIcon from "../../bpk-component-icon/sm/information-circle";
33
33
  import TickCircleIcon from "../../bpk-component-icon/sm/tick-circle";
34
34
  import BpkLink from "../../bpk-component-link";
35
+ import BpkVisuallyHidden from "../../bpk-component-visually-hidden";
35
36
  import { cssModules } from "../../bpk-react-utils";
36
37
  import AnimateAndFade from "./AnimateAndFade";
37
38
  import { ALERT_TYPES, STYLE_TYPES } from "./common-types";
@@ -68,8 +69,7 @@ const getIconForType = (type, CustomIcon) => {
68
69
  };
69
70
  const ToggleButton = props => /*#__PURE__*/_jsxs("div", {
70
71
  className: getClassName('bpk-info-banner__toggle-button'),
71
- children: [props.expanded ? /*#__PURE__*/_jsx(CollapseIcon, {}) : /*#__PURE__*/_jsx(ExpandIcon, {}), /*#__PURE__*/_jsx("span", {
72
- className: "visually-hidden",
72
+ children: [props.expanded ? /*#__PURE__*/_jsx(CollapseIcon, {}) : /*#__PURE__*/_jsx(ExpandIcon, {}), /*#__PURE__*/_jsx(BpkVisuallyHidden, {
73
73
  children: props.label
74
74
  })]
75
75
  });
@@ -20,13 +20,11 @@ import { Component } from 'react';
20
20
  import BpkLabel from "../../bpk-component-label";
21
21
  // @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
22
22
  import BpkSelect from "../../bpk-component-select";
23
- import { cssModules } from "../../bpk-react-utils";
23
+ import BpkVisuallyHidden from "../../bpk-component-visually-hidden";
24
24
  import bpkCustomThemes from "./theming";
25
25
  import { getHtmlElement, THEME_CHANGE_EVENT } from "./utils";
26
- import STYLES from "./BpkThemeToggle.module.css";
27
26
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
28
27
  const inputId = 'theme-select';
29
- const getClassName = cssModules(STYLES);
30
28
  const availableThemes = Object.keys(bpkCustomThemes);
31
29
  const setTheme = theme => {
32
30
  const htmlElement = getHtmlElement();
@@ -84,8 +82,7 @@ class BpkThemeToggle extends Component {
84
82
  } = this.props;
85
83
  return /*#__PURE__*/_jsxs("div", {
86
84
  ...rest,
87
- children: [/*#__PURE__*/_jsx("span", {
88
- className: getClassName('bpk-theme-toggle__label'),
85
+ children: [/*#__PURE__*/_jsx(BpkVisuallyHidden, {
89
86
  children: /*#__PURE__*/_jsx(BpkLabel, {
90
87
  htmlFor: inputId,
91
88
  children: "Change theme"
@@ -0,0 +1,3 @@
1
+ import BpkVisuallyHidden, { type Props as BpkVisuallyHiddenProps } from './src/BpkVisuallyHidden';
2
+ export type { BpkVisuallyHiddenProps };
3
+ export default BpkVisuallyHidden;
@@ -1,18 +1,20 @@
1
1
  /*
2
2
  * Backpack - Skyscanner's Design System
3
- *
3
+ *
4
4
  * Copyright 2016 Skyscanner Ltd
5
- *
5
+ *
6
6
  * Licensed under the Apache License, Version 2.0 (the "License");
7
7
  * you may not use this file except in compliance with the License.
8
8
  * You may obtain a copy of the License at
9
- *
9
+ *
10
10
  * http://www.apache.org/licenses/LICENSE-2.0
11
- *
11
+ *
12
12
  * Unless required by applicable law or agreed to in writing, software
13
13
  * distributed under the License is distributed on an "AS IS" BASIS,
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
17
  */
18
- .bpk-theme-toggle__label{position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;white-space:nowrap;overflow:hidden;clip:rect(0 0 0 0)}
18
+
19
+ import BpkVisuallyHidden from "./src/BpkVisuallyHidden";
20
+ export default BpkVisuallyHidden;
@@ -0,0 +1,8 @@
1
+ import type { ReactNode } from 'react';
2
+ export type VisuallyHiddenElement = 'span' | 'div' | 'p' | 'strong' | 'em' | 'small' | 'legend' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
3
+ export type Props = {
4
+ as?: VisuallyHiddenElement;
5
+ children: ReactNode;
6
+ };
7
+ declare const BpkVisuallyHidden: ({ as: Element, children, }: Props) => import("react/jsx-runtime").JSX.Element;
8
+ export default BpkVisuallyHidden;
@@ -0,0 +1,38 @@
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 "./BpkVisuallyHidden.module.css";
21
+ import { jsx as _jsx } from "react/jsx-runtime";
22
+ const getClassName = cssModules(STYLES);
23
+ const BpkVisuallyHidden = ({
24
+ as: Element = 'span',
25
+ children
26
+ }) => {
27
+ const classNames = getClassName('bpk-visually-hidden');
28
+ return (
29
+ /*#__PURE__*/
30
+ // Allowed, Element is always a dom element.
31
+ // eslint-disable-next-line @skyscanner/rules/forbid-component-props
32
+ _jsx(Element, {
33
+ className: classNames,
34
+ children: children
35
+ })
36
+ );
37
+ };
38
+ export default BpkVisuallyHidden;
@@ -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-icon-description{position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;white-space:nowrap;overflow:hidden;clip:rect(0 0 0 0)}
18
+ .bpk-visually-hidden{position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;white-space:nowrap;overflow:hidden;clip:rect(0 0 0 0)}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skyscanner/backpack-web",
3
- "version": "41.7.0",
3
+ "version": "41.8.0",
4
4
  "description": "Backpack Design System web library",
5
5
  "repository": {
6
6
  "type": "git",