@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.
- package/bpk-component-button/index.d.ts +1 -1
- package/bpk-component-checkbox/index.d.ts +5 -0
- package/bpk-component-checkbox/index.js +3 -1
- package/bpk-component-checkbox/src/BpkCheckbox.d.ts +18 -0
- package/bpk-component-checkbox/src/BpkCheckbox.js +3 -14
- package/bpk-component-checkbox/src/themeAttributes.d.ts +2 -0
- package/bpk-component-checkbox/src/themeAttributes.js +3 -1
- package/bpk-component-fieldset/index.d.ts +5 -0
- package/bpk-component-fieldset/index.js +5 -3
- package/bpk-component-fieldset/src/BpkFieldset.d.ts +29 -0
- package/bpk-component-fieldset/src/BpkFieldset.js +34 -82
- package/bpk-component-fieldset/src/themeAttributes.d.ts +2 -0
- package/bpk-component-loading-button/src/BpkLoadingButton.d.ts +1 -1
- package/bpk-component-nudger/src/themeAttributes.d.ts +1 -1
- package/bpk-component-nudger/src/themeAttributes.js +1 -1
- package/bpk-component-swap-button/src/BpkSwapButton.module.css +1 -1
- package/package.json +1 -1
|
@@ -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, };
|
|
@@ -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
|
-
*/
|
|
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
|
-
*/
|
|
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;
|
|
@@ -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
|
-
*/
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
export default ['checkboxCheckedColor'];
|
|
@@ -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
|
-
*/
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import BpkFieldset from "./src/BpkFieldset";
|
|
18
20
|
import themeAttributes from "./src/themeAttributes";
|
|
19
|
-
export
|
|
20
|
-
export
|
|
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
|
-
*/
|
|
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
|
-
//
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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 :
|
|
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
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
className:
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
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;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ReactElement, ReactNode } from 'react';
|
|
2
|
-
import type { Props as ButtonProps } from '../../bpk-component-button
|
|
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
|
|
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
|
|
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}
|