@skyscanner/backpack-web 27.0.0 → 28.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18,9 +18,8 @@
18
18
 
19
19
  if (typeof window === 'undefined') {
20
20
  global.IntersectionObserver = class {
21
- observe() {} // eslint-disable-line class-methods-use-this
22
-
23
- unobserve() {} // eslint-disable-line class-methods-use-this
21
+ observe() {}
22
+ unobserve() {}
24
23
  };
25
24
  } else {
26
25
  require('intersection-observer'); /* eslint-disable-line global-require */
@@ -18,5 +18,5 @@
18
18
 
19
19
  /// <reference types="react" />
20
20
  import { type CommonProps } from './common-types';
21
- declare const BpkNudger: ({ className, buttonType, ...rest }: CommonProps) => JSX.Element;
21
+ declare const BpkNudger: ({ buttonType, className, icon, id, subtitle, title, ...rest }: CommonProps) => JSX.Element;
22
22
  export default BpkNudger;
@@ -17,9 +17,13 @@
17
17
  */
18
18
 
19
19
  import { cssModules } from "../../bpk-react-utils";
20
+ import BpkText, { TEXT_STYLES } from "../../bpk-component-text";
21
+ // @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
22
+ import BpkLabel from "../../bpk-component-label";
20
23
  import BpkConfigurableNudger from "./BpkConfigurableNudger";
21
24
  import STYLES from "./BpkNudger.module.css";
22
25
  import { jsx as _jsx } from "react/jsx-runtime";
26
+ import { jsxs as _jsxs } from "react/jsx-runtime";
23
27
  const getClassName = cssModules(STYLES);
24
28
  const compareValues = (a, b) => a - b;
25
29
  const incrementValue = currentValue => currentValue + 1;
@@ -28,15 +32,42 @@ const formatValue = currentValue => currentValue.toString();
28
32
  const BpkNudger = ({
29
33
  buttonType = 'secondary',
30
34
  className = null,
35
+ icon,
36
+ id,
37
+ subtitle,
38
+ title,
31
39
  ...rest
32
- }) => /*#__PURE__*/_jsx(BpkConfigurableNudger, {
33
- inputClassName: getClassName('bpk-nudger__input--numeric'),
34
- compareValues: compareValues,
35
- incrementValue: incrementValue,
36
- decrementValue: decrementValue,
37
- formatValue: formatValue,
38
- className: className,
39
- buttonType: buttonType,
40
- ...rest
41
- });
40
+ }) => {
41
+ const classNames = getClassName(title && 'bpk-nudger__container');
42
+ return /*#__PURE__*/_jsxs("div", {
43
+ className: classNames,
44
+ children: [title && /*#__PURE__*/_jsxs(BpkLabel, {
45
+ htmlFor: id,
46
+ className: getClassName('bpk-nudger__label'),
47
+ children: [icon, /*#__PURE__*/_jsxs("span", {
48
+ // For a11y on IOS, role='text' forces label to be read in full. More info: https://axesslab.com/text-splitting/
49
+ // eslint-disable-next-line jsx-a11y/aria-role
50
+ role: "text",
51
+ className: getClassName('bpk-nudger__label--title-subtitle'),
52
+ children: [/*#__PURE__*/_jsx(BpkText, {
53
+ textStyle: TEXT_STYLES.heading5,
54
+ children: title
55
+ }), subtitle && /*#__PURE__*/_jsx(BpkText, {
56
+ className: getClassName('bpk-nudger__label--subtitle'),
57
+ children: subtitle
58
+ })]
59
+ })]
60
+ }), /*#__PURE__*/_jsx(BpkConfigurableNudger, {
61
+ inputClassName: getClassName('bpk-nudger__input--numeric'),
62
+ compareValues: compareValues,
63
+ incrementValue: incrementValue,
64
+ decrementValue: decrementValue,
65
+ formatValue: formatValue,
66
+ className: className,
67
+ buttonType: buttonType,
68
+ id: id,
69
+ ...rest
70
+ })]
71
+ });
72
+ };
42
73
  export default BpkNudger;
@@ -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
- @keyframes bpk-keyframe-spin{100%{transform:rotate(1turn)}}.bpk-nudger__button{position:relative}.bpk-nudger__input{display:inline-block;padding:0.5rem 0;border:none;color:#161616;text-align:center;vertical-align:middle;margin:0;font-size:1.5rem;line-height:2rem;font-weight:400}.bpk-nudger__input--secondary-on-dark{background-color:transparent;color:#fff}.bpk-nudger__input--numeric{width:2.5rem}
18
+ @keyframes bpk-keyframe-spin{100%{transform:rotate(1turn)}}.bpk-nudger__button{position:relative}.bpk-nudger__input{display:inline-block;padding:0.5rem 0;border:none;color:#161616;text-align:center;vertical-align:middle;margin:0;font-size:1rem;line-height:1.25rem;font-weight:700}.bpk-nudger__input--secondary-on-dark{background-color:transparent;color:#fff}.bpk-nudger__input--numeric{width:2.5rem}.bpk-nudger__container{display:flex;justify-content:space-between;align-items:center}.bpk-nudger__label{display:flex;gap:0.5rem}.bpk-nudger__label--title-subtitle{display:flex;flex-direction:column;justify-content:space-between}.bpk-nudger__label--subtitle{color:#545860}
@@ -16,14 +16,18 @@
16
16
  * limitations under the License.
17
17
  */
18
18
 
19
+ import type { ReactNode } from "react";
19
20
  export type CommonProps = {
20
21
  id: string;
21
22
  min: string | number;
22
23
  max: string | number;
23
24
  value: string | number;
24
- onChange: (arg0: any) => (void | null);
25
+ onChange: (arg0: any) => void | null;
25
26
  className?: string | null;
26
27
  increaseButtonLabel: string;
27
28
  decreaseButtonLabel: string;
28
29
  buttonType?: string;
30
+ title?: string;
31
+ subtitle?: string;
32
+ icon?: ReactNode;
29
33
  };
@@ -17,7 +17,7 @@
17
17
  */
18
18
 
19
19
  // We disable eslint here as this package is listed as a peerDep so consumers are required to install this when using this package.
20
- // eslint-disable-next-line import/no-unresolved
20
+
21
21
  const nodeSass = require('node-sass');
22
22
 
23
23
  module.exports = {
@@ -192,7 +192,7 @@ class Portal extends Component {
192
192
 
193
193
  // This function is taken from modernizr
194
194
  // See https://github.com/modernizr/modernizr
195
- // eslint-disable-next-line class-methods-use-this
195
+
196
196
  supportsPassiveEvents() {
197
197
  let supportsPassiveOption = false;
198
198
  try {
@@ -18,9 +18,7 @@
18
18
  // We disable eslint on the below line because it breaks the flow type definitions and the FlowIssue comment below
19
19
  // We can remove this when we migrate this file to TypeScript.
20
20
  // $FlowIssue[value-as-type] - PropType is imported as a type so is incorrectly reporting the PropType is not a valid type
21
- const deprecated = (propType, alternativeSuggestion) =>
22
- // eslint-disable-line
23
- (props, propName, componentName, ...rest) => {
21
+ const deprecated = (propType, alternativeSuggestion) => (props, propName, componentName, ...rest) => {
24
22
  if (props[propName] != null) {
25
23
  const message = `Warning: "${propName}" property of "${componentName}" has been deprecated. ${alternativeSuggestion}`;
26
24
  // eslint-disable-next-line no-console
@@ -27,7 +27,7 @@ import './index.scss';
27
27
 
28
28
  // touch support
29
29
  classNames.push(
30
- 'ontouchstart' in window || // eslint-disable-line no-undef
30
+ 'ontouchstart' in window ||
31
31
  (window.DocumentTouch && document instanceof DocumentTouch) // eslint-disable-line no-undef
32
32
  ? 'touch-support'
33
33
  : 'no-touch-support',
@@ -35,7 +35,7 @@ import './index.scss';
35
35
 
36
36
  // add more feature tests here...
37
37
 
38
- // eslint-disable-next-line no-undef
38
+
39
39
  document.documentElement.className += ` ${classNames
40
40
  .map((className) => `bpk-${className}`)
41
41
  .join(' ')}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skyscanner/backpack-web",
3
- "version": "27.0.0",
3
+ "version": "28.0.0",
4
4
  "description": "Backpack Design System web library",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,21 +0,0 @@
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 BpkNudgerRow, { type Props as BpkNudgerRowProps } from './src/BpkNudgerRow';
20
- export type { BpkNudgerRowProps };
21
- export default BpkNudgerRow;
@@ -1,20 +0,0 @@
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 BpkNudgerRow from "./src/BpkNudgerRow";
20
- export default BpkNudgerRow;
@@ -1,33 +0,0 @@
1
- /*
2
- * Backpack - Skyscanner's Design System
3
- *
4
- * Copyright 2016 Skyscanner Ltd
5
- *
6
- * Licensed under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License.
8
- * You may obtain a copy of the License at
9
- *
10
- * http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- */
18
-
19
- /// <reference types="react" />
20
- export type Props = {
21
- title: string;
22
- nudgerId: string;
23
- value: number;
24
- decreaseButtonLabel: string;
25
- increaseButtonLabel: string;
26
- min: number;
27
- max: number;
28
- onChange: (arg0: any) => (null | void);
29
- subtitle?: string;
30
- className?: string | null;
31
- };
32
- declare const BpkNudgerRow: ({ title, nudgerId, subtitle, decreaseButtonLabel, increaseButtonLabel, min, max, onChange, value, className }: Props) => JSX.Element;
33
- export default BpkNudgerRow;
@@ -1,69 +0,0 @@
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 BpkText, { TEXT_STYLES } from "../../bpk-component-text";
21
- import BpkNudger from "../../bpk-component-nudger";
22
- // @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
23
- import BpkLabel from "../../bpk-component-label";
24
- import STYLES from "./BpkNudgerRow.module.css";
25
- import { jsx as _jsx } from "react/jsx-runtime";
26
- import { jsxs as _jsxs } from "react/jsx-runtime";
27
- const getClassName = cssModules(STYLES);
28
- const BpkNudgerRow = ({
29
- className = null,
30
- decreaseButtonLabel,
31
- increaseButtonLabel,
32
- max,
33
- min,
34
- nudgerId,
35
- onChange,
36
- subtitle,
37
- title,
38
- value
39
- }) => {
40
- const classNames = getClassName('bpk-nudger-row', className);
41
- return /*#__PURE__*/_jsxs("div", {
42
- className: classNames,
43
- children: [/*#__PURE__*/_jsx(BpkLabel, {
44
- htmlFor: nudgerId,
45
- children: /*#__PURE__*/_jsxs("span", {
46
- // For a11y on IOS, role='text' forces label to be read in full. More info: https://axesslab.com/text-splitting/
47
- // eslint-disable-next-line jsx-a11y/aria-role
48
- role: "text",
49
- className: getClassName('bpk-nudger-row__title-subtitle'),
50
- children: [/*#__PURE__*/_jsx(BpkText, {
51
- textStyle: TEXT_STYLES.heading5,
52
- children: title
53
- }), subtitle && /*#__PURE__*/_jsx(BpkText, {
54
- className: getClassName('bpk-nudger-row__subtitle'),
55
- children: subtitle
56
- })]
57
- })
58
- }), /*#__PURE__*/_jsx(BpkNudger, {
59
- id: nudgerId,
60
- decreaseButtonLabel: decreaseButtonLabel,
61
- increaseButtonLabel: increaseButtonLabel,
62
- min: min,
63
- max: max,
64
- onChange: onChange,
65
- value: value
66
- })]
67
- });
68
- };
69
- export default BpkNudgerRow;
@@ -1,18 +0,0 @@
1
- /*
2
- * Backpack - Skyscanner's Design System
3
- *
4
- * Copyright 2016 Skyscanner Ltd
5
- *
6
- * Licensed under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License.
8
- * You may obtain a copy of the License at
9
- *
10
- * http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- */
18
- @keyframes bpk-keyframe-spin{100%{transform:rotate(1turn)}}.bpk-nudger-row{display:flex;justify-content:space-between;align-items:center}.bpk-nudger-row__title-subtitle{display:flex;flex-direction:column;justify-content:space-between}.bpk-nudger-row__subtitle{color:#545860}