@skyscanner/backpack-web 40.1.1 → 40.2.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.
@@ -9,7 +9,7 @@ import BpkButtonSecondary from './BpkButtonSecondary';
9
9
  import BpkButtonSecondaryOnDark from './BpkButtonSecondaryOnDark';
10
10
  import BpkButton from './src/BpkButton';
11
11
  import { BpkButtonV2 } from './src/BpkButtonV2/BpkButton';
12
- export { BUTTON_TYPES, SIZE_TYPES } from './src/BpkButtonV2/common-types';
12
+ export { BUTTON_TYPES, SIZE_TYPES, type ButtonType, type SizeType, type Props, } from './src/BpkButtonV2/common-types';
13
13
  export { buttonThemeAttributes, primaryThemeAttributes, primaryOnDarkThemeAttributes, primaryOnLightThemeAttributes, secondaryThemeAttributes, secondaryOnDarkThemeAttributes, featuredThemeAttributes, destructiveThemeAttributes, } from './themeAttributes';
14
14
  export default BpkButton;
15
15
  export { BpkButtonPrimary, BpkButtonPrimaryOnDark, BpkButtonPrimaryOnLight, BpkButtonSecondary, BpkButtonSecondaryOnDark, BpkButtonDestructive, BpkButtonLink, BpkButtonLinkOnDark, BpkButtonFeatured, BpkButtonV2, };
@@ -0,0 +1,5 @@
1
+ import BpkCheckbox, { type Props as BpkCheckboxProps } from './src/BpkCheckbox';
2
+ import themeAttributes from './src/themeAttributes';
3
+ export type { BpkCheckboxProps };
4
+ export default BpkCheckbox;
5
+ export { themeAttributes };
@@ -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 BpkCheckbox from "./src/BpkCheckbox";
17
+ */
18
+
19
+ import BpkCheckbox from "./src/BpkCheckbox";
18
20
  import themeAttributes from "./src/themeAttributes";
19
21
  export default BpkCheckbox;
20
22
  export { themeAttributes };
@@ -0,0 +1,18 @@
1
+ import type { ReactNode } from 'react';
2
+ type NativeInputProps = React.InputHTMLAttributes<HTMLInputElement>;
3
+ export type Props = Omit<NativeInputProps, 'type' | 'className'> & {
4
+ name: string;
5
+ label: ReactNode;
6
+ required?: boolean;
7
+ disabled?: boolean;
8
+ white?: boolean;
9
+ className?: string | null;
10
+ smallLabel?: boolean;
11
+ valid?: boolean | null;
12
+ /**
13
+ * The indeterminate prop is only a visual clue, it does not affect the checked state of the checkbox. If `indeterminate` is flagged then the checkbox will be displayed with a minus sign in the box. This is used when there is a checkbox group and the parent displays this state when not all child checkboxes are selected.
14
+ */
15
+ indeterminate?: boolean;
16
+ };
17
+ declare const BpkCheckbox: ({ checked, className, disabled, indeterminate, label, name, required, smallLabel, valid, white, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
18
+ export default BpkCheckbox;
@@ -14,7 +14,8 @@
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 "./BpkCheckbox.module.css";
20
21
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
@@ -45,7 +46,7 @@ const BpkCheckbox = ({
45
46
  className: inputClasses,
46
47
  name: name,
47
48
  disabled: disabled,
48
- "aria-label": label,
49
+ "aria-label": typeof label === 'string' ? label : undefined,
49
50
  "aria-invalid": isInvalid,
50
51
  "data-indeterminate": indeterminate,
51
52
  ref: e => {
@@ -65,16 +66,4 @@ const BpkCheckbox = ({
65
66
  })]
66
67
  });
67
68
  };
68
- BpkCheckbox.propTypes = {
69
- name: PropTypes.string.isRequired,
70
- label: PropTypes.node.isRequired,
71
- required: PropTypes.bool,
72
- disabled: PropTypes.bool,
73
- white: PropTypes.bool,
74
- className: PropTypes.string,
75
- smallLabel: PropTypes.bool,
76
- valid: PropTypes.bool,
77
- checked: PropTypes.bool,
78
- indeterminate: PropTypes.bool
79
- };
80
69
  export default BpkCheckbox;
@@ -0,0 +1,2 @@
1
+ declare const _default: string[];
2
+ export default _default;
@@ -14,4 +14,6 @@
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
- */export default ['checkboxCheckedColor'];
17
+ */
18
+
19
+ export default ['checkboxCheckedColor'];
@@ -0,0 +1,5 @@
1
+ import BpkFieldset, { type Props as BpkFieldsetProps } from './src/BpkFieldset';
2
+ import themeAttributes from './src/themeAttributes';
3
+ export type { BpkFieldsetProps };
4
+ export { themeAttributes };
5
+ export default BpkFieldset;
@@ -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 BpkFieldset, { propTypes, defaultProps } from "./src/BpkFieldset";
17
+ */
18
+
19
+ import BpkFieldset from "./src/BpkFieldset";
18
20
  import themeAttributes from "./src/themeAttributes";
19
- export default BpkFieldset;
20
- export { propTypes, defaultProps, themeAttributes };
21
+ export { themeAttributes };
22
+ export default BpkFieldset;
@@ -0,0 +1,29 @@
1
+ import type { ReactElement } from 'react';
2
+ type BaseProps = {
3
+ children: ReactElement;
4
+ disabled?: boolean;
5
+ valid?: boolean | null;
6
+ required?: boolean;
7
+ className?: string | null;
8
+ validationMessage?: string | null;
9
+ validationProps?: Record<string, unknown>;
10
+ description?: string | null;
11
+ [rest: string]: any;
12
+ };
13
+ type CheckboxFieldsetProps = BaseProps & {
14
+ isCheckbox: true;
15
+ /**
16
+ * Optional when `isCheckbox` is true.
17
+ */
18
+ label?: string | null;
19
+ };
20
+ type NonCheckboxFieldsetProps = BaseProps & {
21
+ /**
22
+ * When `isCheckbox` is false or omitted, `label` is required.
23
+ */
24
+ isCheckbox?: false | undefined;
25
+ label: string;
26
+ };
27
+ export type Props = CheckboxFieldsetProps | NonCheckboxFieldsetProps;
28
+ declare const BpkFieldset: ({ children, className, description, disabled, isCheckbox, label, required, valid, validationMessage, validationProps, ...rest }: Props) => import("react/jsx-runtime").JSX.Element | null;
29
+ export default BpkFieldset;
@@ -14,9 +14,12 @@
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 { cloneElement } from 'react';
20
+ // @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
19
21
  import BpkFormValidation from "../../bpk-component-form-validation";
22
+ // @ts-expect-error Untyped import. See `decisions/imports-ts-suppressions.md`.
20
23
  import BpkLabel from "../../bpk-component-label";
21
24
  import { cssModules } from "../../bpk-react-utils";
22
25
  import STYLES from "./BpkFieldset.module.css";
@@ -39,21 +42,16 @@ const BpkFieldset = ({
39
42
  return null;
40
43
  }
41
44
 
42
- // $FlowIgnore[prop-missing] - As children could be any element and might not have a value which is safe
43
- let childId = children.props.id;
44
- if (
45
- // Flow is being dumb here and doesn't let us do this check, even though it's perfectly safe!
46
- // $FlowIgnore[prop-missing]
47
- // $FlowIgnore[sketchy-null-mixed]
48
- children.props.inputProps &&
49
- // $FlowIgnore[sketchy-null-mixed]
50
- children.props.inputProps.id && typeof children.props.inputProps.id === 'string') {
51
- childId = children.props.inputProps.id;
45
+ // Get the child's id, checking both direct props and inputProps
46
+ const childProps = children.props;
47
+ let childId = childProps.id || '';
48
+ if (childProps.inputProps?.id && typeof childProps.inputProps.id === 'string') {
49
+ childId = childProps.inputProps.id;
52
50
  }
53
51
  const classNames = [getClassName('bpk-fieldset')];
54
52
  const validationMessageId = `${childId}_validation_message`;
55
53
  const descriptionId = `${childId}_description`;
56
- const isValid = isCheckbox ? valid : children.props.valid;
54
+ const isValid = isCheckbox ? valid : childProps.valid;
57
55
 
58
56
  // Explicit check for false primitive value as undefined is
59
57
  // treated as neither valid nor invalid
@@ -75,75 +73,29 @@ const BpkFieldset = ({
75
73
  if (className) {
76
74
  classNames.push(className);
77
75
  }
78
- return (
79
- /*#__PURE__*/
80
- // $FlowFixMe[cannot-spread-inexact] - inexact rest. See 'decisions/flowfixme.md'.
81
- _jsxs("fieldset", {
82
- className: classNames.join(' '),
83
- ...rest,
84
- children: [!isCheckbox && /*#__PURE__*/_jsx("div", {
85
- className: getClassName('bpk-fieldset__label'),
86
- children: /*#__PURE__*/_jsx(BpkLabel, {
87
- htmlFor: childId,
88
- required: required,
89
- disabled: disabled,
90
- valid: isValid,
91
- children: label
92
- })
93
- }), clonedChildren, description && /*#__PURE__*/_jsx("span", {
94
- className: getClassName('bpk-fieldset__description'),
95
- id: descriptionId,
96
- children: description
97
- }), !disabled && validationMessage &&
98
- /*#__PURE__*/
99
- // $FlowFixMe[cannot-spread-inexact] - inexact rest. See 'decisions/flowfixme.md'.
100
- _jsx(BpkFormValidation, {
101
- id: validationMessageId,
102
- expanded: isInvalid,
103
- isCheckbox: isCheckbox,
104
- ...validationProps,
105
- children: validationMessage
106
- })]
107
- })
108
- );
109
- };
110
- const labelPropType = (props, propName) => {
111
- const {
112
- isCheckbox,
113
- label
114
- } = props;
115
- if (!label && !isCheckbox) {
116
- return new Error(`\`${propName}\` is required when \`isCheckbox\` is false.`);
117
- }
118
- return false;
119
- };
120
- export const propTypes = {
121
- children: PropTypes.element.isRequired,
122
- /**
123
- * Required when `isCheckbox` is false.
124
- */
125
- label: labelPropType,
126
- disabled: PropTypes.bool,
127
- valid: PropTypes.bool,
128
- required: PropTypes.bool,
129
- className: PropTypes.string,
130
- validationMessage: PropTypes.string,
131
- isCheckbox: PropTypes.bool,
132
- validationProps: PropTypes.object,
133
- description: PropTypes.string
134
- };
135
- export const defaultProps = {
136
- label: null,
137
- disabled: false,
138
- valid: null,
139
- required: false,
140
- className: null,
141
- validationMessage: null,
142
- isCheckbox: false,
143
- validationProps: {},
144
- description: null
145
- };
146
- BpkFieldset.propTypes = {
147
- ...propTypes
76
+ return /*#__PURE__*/_jsxs("fieldset", {
77
+ className: classNames.join(' '),
78
+ ...rest,
79
+ children: [!isCheckbox && /*#__PURE__*/_jsx("div", {
80
+ className: getClassName('bpk-fieldset__label'),
81
+ children: /*#__PURE__*/_jsx(BpkLabel, {
82
+ htmlFor: childId,
83
+ required: required,
84
+ disabled: disabled,
85
+ valid: isValid,
86
+ children: label
87
+ })
88
+ }), clonedChildren, description && /*#__PURE__*/_jsx("span", {
89
+ className: getClassName('bpk-fieldset__description'),
90
+ id: descriptionId,
91
+ children: description
92
+ }), !disabled && validationMessage && /*#__PURE__*/_jsx(BpkFormValidation, {
93
+ id: validationMessageId,
94
+ expanded: isInvalid,
95
+ isCheckbox: isCheckbox,
96
+ ...validationProps,
97
+ children: validationMessage
98
+ })]
99
+ });
148
100
  };
149
101
  export default BpkFieldset;
@@ -0,0 +1,2 @@
1
+ declare const _default: string[];
2
+ export default _default;
@@ -1,5 +1,5 @@
1
1
  import type { ReactElement, ReactNode } from 'react';
2
- import type { Props as ButtonProps } from '../../bpk-component-button/src/BpkButtonV2/common-types';
2
+ import type { Props as ButtonProps } from '../../bpk-component-button';
3
3
  export declare const ICON_POSITION: {
4
4
  LEADING: string;
5
5
  TRAILING: string;
@@ -1,2 +1,2 @@
1
- import { secondaryThemeAttributes as themeAttributes } from '../../bpk-component-button/themeAttributes';
1
+ import { secondaryThemeAttributes as themeAttributes } from '../../bpk-component-button';
2
2
  export default themeAttributes;
@@ -16,5 +16,5 @@
16
16
  * limitations under the License.
17
17
  */
18
18
 
19
- import { secondaryThemeAttributes as themeAttributes } from "../../bpk-component-button/themeAttributes";
19
+ import { secondaryThemeAttributes as themeAttributes } from "../../bpk-component-button";
20
20
  export default themeAttributes;
@@ -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-swap-button{transform:translateY(-50%) rotate(90deg)}@media(max-width: 48rem){.bpk-swap-button{transform:rotate(0deg)}}.bpk-swap-button :focus-visible{box-shadow:0 0 0 .125rem #fff,0 0 0 .25rem #0062e3}.bpk-swap-button__button{display:flex;width:2.5rem;height:2.5rem;justify-content:center;align-items:center;transition:transform 400ms;border:3px solid #05203c;border-radius:50%;background-color:#fff}@media(max-width: 48rem){.bpk-swap-button__button{border:2px solid #05203c}}.bpk-no-touch-support .bpk-swap-button__button:hover:not(:active):not(:disabled){background-color:#e0e4e9}:global(.bpk-no-touch-support) .bpk-swap-button__button:hover:not(:active):not(:disabled){background-color:#e0e4e9}.bpk-swap-button__button span{display:inline-flex;line-height:1rem}.bpk-swap-button__button--canvas-default{border:3px solid #fff;background-color:#eff3f8}.bpk-swap-button__button--canvas-contrast{border:3px solid #eff3f8}
18
+ .bpk-swap-button{transform:translateY(-50%) rotate(90deg)}@media(max-width: 48rem){.bpk-swap-button{transform:rotate(0deg)}}.bpk-swap-button :focus-visible{box-shadow:0 0 0 .125rem #fff,0 0 0 .25rem #0062e3}.bpk-swap-button__button{display:flex;width:2.5rem;height:2.5rem;padding:0;justify-content:center;align-items:center;transition:transform 400ms;border:3px solid #05203c;border-radius:50%;background-color:#fff}@media(max-width: 48rem){.bpk-swap-button__button{border:2px solid #05203c}}.bpk-no-touch-support .bpk-swap-button__button:hover:not(:active):not(:disabled){background-color:#e0e4e9}:global(.bpk-no-touch-support) .bpk-swap-button__button:hover:not(:active):not(:disabled){background-color:#e0e4e9}.bpk-swap-button__button span{display:inline-flex;line-height:1rem}.bpk-swap-button__button--canvas-default{border:3px solid #fff;background-color:#eff3f8}.bpk-swap-button__button--canvas-contrast{border:3px solid #eff3f8}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skyscanner/backpack-web",
3
- "version": "40.1.1",
3
+ "version": "40.2.0",
4
4
  "description": "Backpack Design System web library",
5
5
  "repository": {
6
6
  "type": "git",