@skyscanner/backpack-web 42.20.2 → 42.21.1
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-layout/src/BpkStack.js +45 -3
- package/bpk-component-layout/src/commonProps.d.ts +6 -1
- package/bpk-component-layout/src/tokenUtils.js +2 -2
- package/bpk-component-layout/src/types.d.ts +27 -37
- package/bpk-component-tooltip/src/BpkTooltip.d.ts +2 -1
- package/bpk-component-tooltip/src/BpkTooltip.js +5 -1
- package/package.json +1 -1
|
@@ -24,12 +24,26 @@ import STYLES from "./BpkLayout.module.css";
|
|
|
24
24
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
25
25
|
const getClassName = cssModules(STYLES);
|
|
26
26
|
export const BpkStack = /*#__PURE__*/forwardRef(({
|
|
27
|
+
align,
|
|
28
|
+
alignItems,
|
|
27
29
|
backgroundColor,
|
|
28
30
|
children,
|
|
29
31
|
color,
|
|
32
|
+
justify,
|
|
33
|
+
justifyContent,
|
|
30
34
|
...props
|
|
31
35
|
}, ref) => {
|
|
32
|
-
const
|
|
36
|
+
const resolvedAlign = align ?? alignItems;
|
|
37
|
+
const resolvedJustify = justify ?? justifyContent;
|
|
38
|
+
const processedProps = processBpkComponentProps({
|
|
39
|
+
...props,
|
|
40
|
+
...(resolvedAlign !== undefined && {
|
|
41
|
+
align: resolvedAlign
|
|
42
|
+
}),
|
|
43
|
+
...(resolvedJustify !== undefined && {
|
|
44
|
+
justify: resolvedJustify
|
|
45
|
+
})
|
|
46
|
+
}, {
|
|
33
47
|
component: 'BpkStack'
|
|
34
48
|
});
|
|
35
49
|
const classNames = color || backgroundColor ? getClassName('bpk-layout', color ? `bpk-layout--${color}` : '', backgroundColor ? `bpk-layout--${backgroundColor}` : '') : undefined;
|
|
@@ -47,12 +61,26 @@ export const BpkStack = /*#__PURE__*/forwardRef(({
|
|
|
47
61
|
});
|
|
48
62
|
BpkStack.displayName = 'BpkStack';
|
|
49
63
|
export const BpkHStack = /*#__PURE__*/forwardRef(({
|
|
64
|
+
align,
|
|
65
|
+
alignItems,
|
|
50
66
|
backgroundColor,
|
|
51
67
|
children,
|
|
52
68
|
color,
|
|
69
|
+
justify,
|
|
70
|
+
justifyContent,
|
|
53
71
|
...props
|
|
54
72
|
}, ref) => {
|
|
55
|
-
const
|
|
73
|
+
const resolvedAlign = align ?? alignItems;
|
|
74
|
+
const resolvedJustify = justify ?? justifyContent;
|
|
75
|
+
const processedProps = processBpkComponentProps({
|
|
76
|
+
...props,
|
|
77
|
+
...(resolvedAlign !== undefined && {
|
|
78
|
+
align: resolvedAlign
|
|
79
|
+
}),
|
|
80
|
+
...(resolvedJustify !== undefined && {
|
|
81
|
+
justify: resolvedJustify
|
|
82
|
+
})
|
|
83
|
+
}, {
|
|
56
84
|
component: 'BpkStack'
|
|
57
85
|
});
|
|
58
86
|
const classNames = color || backgroundColor ? getClassName('bpk-layout', color ? `bpk-layout--${color}` : '', backgroundColor ? `bpk-layout--${backgroundColor}` : '') : undefined;
|
|
@@ -70,12 +98,26 @@ export const BpkHStack = /*#__PURE__*/forwardRef(({
|
|
|
70
98
|
});
|
|
71
99
|
BpkHStack.displayName = 'BpkHStack';
|
|
72
100
|
export const BpkVStack = /*#__PURE__*/forwardRef(({
|
|
101
|
+
align,
|
|
102
|
+
alignItems,
|
|
73
103
|
backgroundColor,
|
|
74
104
|
children,
|
|
75
105
|
color,
|
|
106
|
+
justify,
|
|
107
|
+
justifyContent,
|
|
76
108
|
...props
|
|
77
109
|
}, ref) => {
|
|
78
|
-
const
|
|
110
|
+
const resolvedAlign = align ?? alignItems;
|
|
111
|
+
const resolvedJustify = justify ?? justifyContent;
|
|
112
|
+
const processedProps = processBpkComponentProps({
|
|
113
|
+
...props,
|
|
114
|
+
...(resolvedAlign !== undefined && {
|
|
115
|
+
align: resolvedAlign
|
|
116
|
+
}),
|
|
117
|
+
...(resolvedJustify !== undefined && {
|
|
118
|
+
justify: resolvedJustify
|
|
119
|
+
})
|
|
120
|
+
}, {
|
|
79
121
|
component: 'BpkStack'
|
|
80
122
|
});
|
|
81
123
|
const classNames = color || backgroundColor ? getClassName('bpk-layout', color ? `bpk-layout--${color}` : '', backgroundColor ? `bpk-layout--${backgroundColor}` : '') : undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AriaAttributes, AriaRole, KeyboardEventHandler, MouseEventHandler } from 'react';
|
|
1
|
+
import type { AriaAttributes, AriaRole, ElementType, KeyboardEventHandler, MouseEventHandler } from 'react';
|
|
2
2
|
import type { BpkLayoutBackgroundColor } from './backgroundColors';
|
|
3
3
|
import type { BpkSpacingValue, BpkSizeValue, BpkPositionValue, BpkPositionKeyword, BpkOverflowValue, BpkZIndexValue, BpkResponsiveValue } from './tokens';
|
|
4
4
|
import type { TextColor, TextStyle } from '../../bpk-component-text';
|
|
@@ -23,6 +23,8 @@ export interface BpkSpacingProps {
|
|
|
23
23
|
paddingEnd?: BpkResponsiveValue<BpkSpacingValue>;
|
|
24
24
|
marginInline?: BpkResponsiveValue<BpkSpacingValue>;
|
|
25
25
|
paddingInline?: BpkResponsiveValue<BpkSpacingValue>;
|
|
26
|
+
marginBlock?: BpkResponsiveValue<BpkSpacingValue>;
|
|
27
|
+
paddingBlock?: BpkResponsiveValue<BpkSpacingValue>;
|
|
26
28
|
gap?: BpkResponsiveValue<BpkSpacingValue>;
|
|
27
29
|
width?: BpkResponsiveValue<BpkSizeValue>;
|
|
28
30
|
height?: BpkResponsiveValue<BpkSizeValue>;
|
|
@@ -60,6 +62,9 @@ export interface BpkCommonLayoutProps extends BpkSpacingProps, AriaAttributes {
|
|
|
60
62
|
overflowX?: BpkResponsiveValue<BpkOverflowValue>;
|
|
61
63
|
overflowY?: BpkResponsiveValue<BpkOverflowValue>;
|
|
62
64
|
zIndex?: BpkZIndexValue;
|
|
65
|
+
as?: ElementType;
|
|
66
|
+
opacity?: number;
|
|
67
|
+
dir?: 'ltr' | 'rtl' | 'auto';
|
|
63
68
|
'data-testid'?: string;
|
|
64
69
|
'data-cy'?: string;
|
|
65
70
|
color?: TextColor;
|
|
@@ -241,9 +241,9 @@ export function processResponsiveValue(value, converter, validator, propName) {
|
|
|
241
241
|
export function processSpacingProps(props) {
|
|
242
242
|
const spacingKeys = [
|
|
243
243
|
// Padding props
|
|
244
|
-
'padding', 'paddingTop', 'paddingRight', 'paddingBottom', 'paddingLeft', 'paddingStart', 'paddingEnd', 'paddingInline',
|
|
244
|
+
'padding', 'paddingTop', 'paddingRight', 'paddingBottom', 'paddingLeft', 'paddingStart', 'paddingEnd', 'paddingInline', 'paddingBlock',
|
|
245
245
|
// Margin props
|
|
246
|
-
'margin', 'marginTop', 'marginRight', 'marginBottom', 'marginLeft', 'marginStart', 'marginEnd', 'marginInline',
|
|
246
|
+
'margin', 'marginTop', 'marginRight', 'marginBottom', 'marginLeft', 'marginStart', 'marginEnd', 'marginInline', 'marginBlock',
|
|
247
247
|
// Gap and spacing
|
|
248
248
|
'gap', 'spacing', 'rowGap', 'columnGap',
|
|
249
249
|
// Size props
|
|
@@ -3,19 +3,6 @@ import type StackOptionKeys from './BpkStack.constant';
|
|
|
3
3
|
import type { BpkCommonLayoutProps } from './commonProps';
|
|
4
4
|
import type { BpkSpacingValue, BpkResponsiveValue, BpkBasisValue } from './tokens';
|
|
5
5
|
import type { BoxProps, FlexProps, GridProps, GridItemProps, StackProps } from '@chakra-ui/react';
|
|
6
|
-
/**
|
|
7
|
-
* Layout-level event props that should not be exposed on layout components.
|
|
8
|
-
* onClick is handled via BpkCommonLayoutProps; onFocus/onBlur are reintroduced
|
|
9
|
-
* on BpkBoxProps only.
|
|
10
|
-
*/
|
|
11
|
-
type LayoutEventProps = 'onMouseEnter' | 'onMouseLeave' | 'onMouseOver' | 'onMouseOut' | 'onMouseDown' | 'onMouseUp' | 'onFocus' | 'onBlur' | 'onKeyDown' | 'onKeyUp' | 'onKeyPress';
|
|
12
|
-
/**
|
|
13
|
-
* Shorthand props from the underlying layout system that we do NOT expose on
|
|
14
|
-
* Backpack layout components. These mostly mirror longer-form spacing,
|
|
15
|
-
* sizing and visual props that we already model explicitly via
|
|
16
|
-
* BpkCommonLayoutProps and BpkFlexGridProps.
|
|
17
|
-
*/
|
|
18
|
-
type DisallowedShorthandProps = 'p' | 'pt' | 'pr' | 'pb' | 'pl' | 'px' | 'py' | 'm' | 'mt' | 'mr' | 'mb' | 'ml' | 'mx' | 'my' | 'w' | 'h' | 'minW' | 'maxW' | 'minH' | 'maxH' | 'bg' | 'rounded' | 'shadow';
|
|
19
6
|
/**
|
|
20
7
|
* Flexbox & grid layout props that we explicitly support on Backpack layout
|
|
21
8
|
* components. These are a curated subset of the underlying Box flex/grid API
|
|
@@ -79,17 +66,10 @@ type BpkBoxResponsiveLayoutProps = {
|
|
|
79
66
|
};
|
|
80
67
|
type BpkBoxResponsiveLayoutPropKeys = keyof BpkBoxResponsiveLayoutProps;
|
|
81
68
|
/**
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
* These will be replaced with Backpack-specific types.
|
|
86
|
-
*/
|
|
87
|
-
export type RemoveCommonProps<T> = Omit<T, keyof BpkCommonLayoutProps | 'className' | 'children' | LayoutEventProps | FlexGridPropKeys | DisallowedShorthandProps>;
|
|
88
|
-
/**
|
|
89
|
-
* Component-specific props for BpkBox
|
|
90
|
-
* Includes all Box props except those in BpkCommonLayoutProps
|
|
69
|
+
* Component-specific props for BpkBox.
|
|
70
|
+
* Explicit allowlist — does NOT inherit from Chakra BoxProps.
|
|
91
71
|
*/
|
|
92
|
-
export interface BpkBoxSpecificProps extends
|
|
72
|
+
export interface BpkBoxSpecificProps extends BpkBoxResponsiveLayoutProps, Omit<BpkFlexGridProps, BpkBoxResponsiveLayoutPropKeys> {
|
|
93
73
|
}
|
|
94
74
|
/**
|
|
95
75
|
* Props for BpkBox component
|
|
@@ -147,10 +127,10 @@ export type BpkVesselProps = {
|
|
|
147
127
|
as?: VesselElement;
|
|
148
128
|
} & HTMLAttributes<HTMLElement>;
|
|
149
129
|
/**
|
|
150
|
-
* Component-specific props for BpkFlex
|
|
151
|
-
*
|
|
130
|
+
* Component-specific props for BpkFlex.
|
|
131
|
+
* Explicit allowlist — does NOT inherit from Chakra FlexProps.
|
|
152
132
|
*/
|
|
153
|
-
export interface BpkFlexSpecificProps
|
|
133
|
+
export interface BpkFlexSpecificProps {
|
|
154
134
|
direction?: BpkResponsiveValue<FlexProps['flexDirection']>;
|
|
155
135
|
justify?: BpkResponsiveValue<FlexProps['justifyContent']>;
|
|
156
136
|
align?: BpkResponsiveValue<FlexProps['alignItems']>;
|
|
@@ -168,10 +148,10 @@ export interface BpkFlexProps extends BpkCommonLayoutProps, BpkFlexSpecificProps
|
|
|
168
148
|
children?: ReactNode;
|
|
169
149
|
}
|
|
170
150
|
/**
|
|
171
|
-
* Component-specific props for BpkGrid
|
|
172
|
-
*
|
|
151
|
+
* Component-specific props for BpkGrid.
|
|
152
|
+
* Explicit allowlist — does NOT inherit from Chakra GridProps.
|
|
173
153
|
*/
|
|
174
|
-
export interface BpkGridSpecificProps
|
|
154
|
+
export interface BpkGridSpecificProps {
|
|
175
155
|
justify?: BpkResponsiveValue<GridProps['justifyContent']>;
|
|
176
156
|
align?: BpkResponsiveValue<GridProps['alignItems']>;
|
|
177
157
|
templateColumns?: BpkResponsiveValue<GridProps['gridTemplateColumns']>;
|
|
@@ -194,10 +174,10 @@ export interface BpkGridProps extends BpkCommonLayoutProps, BpkGridSpecificProps
|
|
|
194
174
|
children?: ReactNode;
|
|
195
175
|
}
|
|
196
176
|
/**
|
|
197
|
-
* Component-specific props for BpkGridItem
|
|
198
|
-
*
|
|
177
|
+
* Component-specific props for BpkGridItem.
|
|
178
|
+
* Explicit allowlist — does NOT inherit from Chakra GridItemProps.
|
|
199
179
|
*/
|
|
200
|
-
export interface BpkGridItemSpecificProps
|
|
180
|
+
export interface BpkGridItemSpecificProps {
|
|
201
181
|
area?: GridItemProps['area'];
|
|
202
182
|
colEnd?: GridItemProps['colEnd'];
|
|
203
183
|
colStart?: GridItemProps['colStart'];
|
|
@@ -221,11 +201,21 @@ type BpkStackOptions = {
|
|
|
221
201
|
[K in StackOptionKeysType]?: K extends keyof StackProps ? BpkResponsiveValue<StackProps[K]> | StackProps[K] : never;
|
|
222
202
|
};
|
|
223
203
|
/**
|
|
224
|
-
* Component-specific props for BpkStack
|
|
225
|
-
*
|
|
226
|
-
* Overrides StackOptions to support BpkResponsiveValue
|
|
227
|
-
|
|
228
|
-
|
|
204
|
+
* Component-specific props for BpkStack.
|
|
205
|
+
* Explicit allowlist — does NOT inherit from Chakra StackProps.
|
|
206
|
+
* Overrides StackOptions to support BpkResponsiveValue.
|
|
207
|
+
* `alignItems` and `justifyContent` are accepted as semantic aliases for `align` and `justify`.
|
|
208
|
+
* If both are provided, `align`/`justify` take precedence.
|
|
209
|
+
*
|
|
210
|
+
* `alignItems` and `justifyContent` are explicitly omitted from `BpkFlexGridProps` here so
|
|
211
|
+
* that the responsive alias declarations below (which match BpkStackOptions) unambiguously
|
|
212
|
+
* replace the non-responsive `BoxProps` variants from `BpkFlexGridProps`.
|
|
213
|
+
*/
|
|
214
|
+
export interface BpkStackSpecificProps extends BpkStackOptions, Omit<BpkFlexGridProps, 'alignItems' | 'justifyContent'> {
|
|
215
|
+
/** Alias for `align`. Maps to CSS `align-items`. Responsive — replaces the non-responsive BpkFlexGridProps.alignItems. */
|
|
216
|
+
alignItems?: BpkStackOptions['align'];
|
|
217
|
+
/** Alias for `justify`. Maps to CSS `justify-content`. Responsive — replaces the non-responsive BpkFlexGridProps.justifyContent. */
|
|
218
|
+
justifyContent?: BpkStackOptions['justify'];
|
|
229
219
|
}
|
|
230
220
|
/**
|
|
231
221
|
* Props for BpkStack component
|
|
@@ -19,6 +19,7 @@ export type Props = {
|
|
|
19
19
|
hideOnTouchDevices?: boolean;
|
|
20
20
|
placement?: Placement;
|
|
21
21
|
isOpen?: boolean;
|
|
22
|
+
zIndexValue?: number;
|
|
22
23
|
};
|
|
23
|
-
declare const BpkTooltip: ({ ariaLabel, children, hideOnTouchDevices, id, isOpen, padded, placement, target, type, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
24
|
+
declare const BpkTooltip: ({ ariaLabel, children, hideOnTouchDevices, id, isOpen, padded, placement, target, type, zIndexValue, ...rest }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
24
25
|
export default BpkTooltip;
|
|
@@ -60,6 +60,7 @@ const BpkTooltip = ({
|
|
|
60
60
|
placement = 'bottom',
|
|
61
61
|
target,
|
|
62
62
|
type = TOOLTIP_TYPES.light,
|
|
63
|
+
zIndexValue,
|
|
63
64
|
...rest
|
|
64
65
|
}) => {
|
|
65
66
|
const [isOpenState, setIsOpenState] = useState(isOpen);
|
|
@@ -107,7 +108,10 @@ const BpkTooltip = ({
|
|
|
107
108
|
children: /*#__PURE__*/_jsx("div", {
|
|
108
109
|
className: getClassName('bpk-tooltip--container'),
|
|
109
110
|
ref: refs.setFloating,
|
|
110
|
-
style:
|
|
111
|
+
style: {
|
|
112
|
+
...floatingStyles,
|
|
113
|
+
zIndex: zIndexValue
|
|
114
|
+
},
|
|
111
115
|
...getFloatingProps(),
|
|
112
116
|
children: /*#__PURE__*/_jsx(TransitionInitialMount, {
|
|
113
117
|
appearClassName: getClassName('bpk-tooltip--appear'),
|