@skyscanner/backpack-web 42.10.0-dev-v24496611676.1 → 42.11.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-bottom-sheet/src/BpkBottomSheet.js +1 -0
- package/bpk-component-layout/index.d.ts +0 -4
- package/bpk-component-layout/index.js +0 -2
- package/bpk-component-layout/src/BpkBox.js +13 -16
- package/bpk-component-layout/src/BpkFlex.js +9 -20
- package/bpk-component-layout/src/BpkGrid.js +9 -20
- package/bpk-component-layout/src/BpkGridItem.js +15 -23
- package/bpk-component-layout/src/BpkProvider.d.ts +10 -7
- package/bpk-component-layout/src/BpkProvider.js +98 -12
- package/bpk-component-layout/src/BpkStack.constant.js +2 -3
- package/bpk-component-layout/src/BpkStack.js +40 -89
- package/bpk-component-layout/src/commonProps.d.ts +1 -8
- package/bpk-component-layout/src/theme.d.ts +1 -0
- package/bpk-component-layout/src/theme.js +301 -27
- package/bpk-component-layout/src/tokenUtils.js +11 -34
- package/bpk-component-layout/src/types.d.ts +147 -84
- package/bpk-component-navigation-bar/src/BpkNavigationBar.d.ts +3 -0
- package/bpk-component-navigation-bar/src/BpkNavigationBar.js +2 -1
- package/bpk-component-navigation-bar/src/BpkNavigationBar.module.css +1 -1
- package/bpk-component-page-indicator/src/NavButton.js +3 -3
- package/package.json +3 -2
- package/bpk-component-layout/src/BpkArkProvider.d.ts +0 -20
- package/bpk-component-layout/src/BpkArkProvider.js +0 -112
- package/bpk-component-layout/src/BpkLayoutProvider.d.ts +0 -18
- package/bpk-component-layout/src/BpkLayoutProvider.js +0 -36
- package/bpk-component-layout/src/resolveTextStyle.d.ts +0 -13
- package/bpk-component-layout/src/resolveTextStyle.js +0 -265
- package/bpk-component-layout/src/responsiveStyleBuilder.d.ts +0 -22
- package/bpk-component-layout/src/responsiveStyleBuilder.js +0 -152
- package/bpk-component-layout/src/useCurrentBreakpoint.d.ts +0 -9
- package/bpk-component-layout/src/useCurrentBreakpoint.js +0 -89
|
@@ -1,75 +1,108 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
import type StackOptionKeys from './BpkStack.constant';
|
|
2
3
|
import type { BpkCommonLayoutProps } from './commonProps';
|
|
3
4
|
import type { BpkSpacingValue, BpkResponsiveValue, BpkBasisValue } from './tokens';
|
|
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';
|
|
4
19
|
/**
|
|
5
20
|
* Flexbox & grid layout props that we explicitly support on Backpack layout
|
|
6
|
-
* components. These are a curated subset of
|
|
7
|
-
* useful for structural layout.
|
|
21
|
+
* components. These are a curated subset of the underlying Box flex/grid API
|
|
22
|
+
* that are useful for structural layout.
|
|
8
23
|
*/
|
|
9
24
|
export interface BpkFlexGridProps {
|
|
10
|
-
display?:
|
|
11
|
-
flexDirection?:
|
|
12
|
-
flexWrap?:
|
|
13
|
-
justifyContent?:
|
|
14
|
-
alignItems?:
|
|
15
|
-
alignContent?:
|
|
16
|
-
flex?:
|
|
17
|
-
flexGrow?:
|
|
18
|
-
flexShrink?:
|
|
19
|
-
flexBasis?:
|
|
20
|
-
order?:
|
|
21
|
-
alignSelf?:
|
|
22
|
-
justifySelf?:
|
|
23
|
-
gridTemplateColumns?:
|
|
24
|
-
gridTemplateRows?:
|
|
25
|
-
gridTemplateAreas?:
|
|
26
|
-
gridAutoFlow?:
|
|
27
|
-
gridAutoRows?:
|
|
28
|
-
gridAutoColumns?:
|
|
29
|
-
rowGap?:
|
|
30
|
-
columnGap?:
|
|
25
|
+
display?: BoxProps['display'];
|
|
26
|
+
flexDirection?: BoxProps['flexDirection'];
|
|
27
|
+
flexWrap?: BoxProps['flexWrap'];
|
|
28
|
+
justifyContent?: BoxProps['justifyContent'];
|
|
29
|
+
alignItems?: BoxProps['alignItems'];
|
|
30
|
+
alignContent?: BoxProps['alignContent'];
|
|
31
|
+
flex?: BoxProps['flex'];
|
|
32
|
+
flexGrow?: BoxProps['flexGrow'];
|
|
33
|
+
flexShrink?: BoxProps['flexShrink'];
|
|
34
|
+
flexBasis?: BoxProps['flexBasis'];
|
|
35
|
+
order?: BoxProps['order'];
|
|
36
|
+
alignSelf?: BoxProps['alignSelf'];
|
|
37
|
+
justifySelf?: BoxProps['justifySelf'];
|
|
38
|
+
gridTemplateColumns?: BoxProps['gridTemplateColumns'];
|
|
39
|
+
gridTemplateRows?: BoxProps['gridTemplateRows'];
|
|
40
|
+
gridTemplateAreas?: BoxProps['gridTemplateAreas'];
|
|
41
|
+
gridAutoFlow?: BoxProps['gridAutoFlow'];
|
|
42
|
+
gridAutoRows?: BoxProps['gridAutoRows'];
|
|
43
|
+
gridAutoColumns?: BoxProps['gridAutoColumns'];
|
|
44
|
+
rowGap?: BoxProps['rowGap'];
|
|
45
|
+
columnGap?: BoxProps['columnGap'];
|
|
31
46
|
}
|
|
32
47
|
export type FlexGridPropKeys = keyof BpkFlexGridProps;
|
|
33
48
|
/**
|
|
34
|
-
* Curated subset of layout props that support Backpack responsive values.
|
|
35
|
-
*
|
|
49
|
+
* Curated subset of Box layout props that support Backpack responsive values.
|
|
50
|
+
*
|
|
51
|
+
* NOTE:
|
|
52
|
+
* - These are structural layout props (flex/grid/display) that we want to allow
|
|
53
|
+
* on `BpkBox`, but using Backpack breakpoint keys rather than Chakra's
|
|
54
|
+
* array syntax or Chakra breakpoint keys.
|
|
55
|
+
* - Spacing/size/position props are handled separately via `BpkCommonLayoutProps`.
|
|
36
56
|
*/
|
|
37
57
|
type BpkBoxResponsiveLayoutProps = {
|
|
38
|
-
display?: BpkResponsiveValue<
|
|
39
|
-
flexDirection?: BpkResponsiveValue<
|
|
40
|
-
flexWrap?: BpkResponsiveValue<
|
|
41
|
-
justifyContent?: BpkResponsiveValue<
|
|
42
|
-
alignItems?: BpkResponsiveValue<
|
|
43
|
-
alignContent?: BpkResponsiveValue<
|
|
44
|
-
flex?: BpkResponsiveValue<
|
|
45
|
-
flexGrow?: BpkResponsiveValue<
|
|
46
|
-
flexShrink?: BpkResponsiveValue<
|
|
47
|
-
flexBasis?: BpkResponsiveValue<
|
|
48
|
-
order?: BpkResponsiveValue<
|
|
49
|
-
alignSelf?: BpkResponsiveValue<
|
|
50
|
-
justifySelf?: BpkResponsiveValue<
|
|
51
|
-
gridTemplateColumns?: BpkResponsiveValue<
|
|
52
|
-
gridTemplateRows?: BpkResponsiveValue<
|
|
53
|
-
gridTemplateAreas?: BpkResponsiveValue<
|
|
54
|
-
gridAutoFlow?: BpkResponsiveValue<
|
|
55
|
-
gridAutoRows?: BpkResponsiveValue<
|
|
56
|
-
gridAutoColumns?: BpkResponsiveValue<
|
|
57
|
-
gridColumn?: BpkResponsiveValue<
|
|
58
|
-
gridRow?: BpkResponsiveValue<
|
|
58
|
+
display?: BpkResponsiveValue<BoxProps['display']>;
|
|
59
|
+
flexDirection?: BpkResponsiveValue<BoxProps['flexDirection']>;
|
|
60
|
+
flexWrap?: BpkResponsiveValue<BoxProps['flexWrap']>;
|
|
61
|
+
justifyContent?: BpkResponsiveValue<BoxProps['justifyContent']>;
|
|
62
|
+
alignItems?: BpkResponsiveValue<BoxProps['alignItems']>;
|
|
63
|
+
alignContent?: BpkResponsiveValue<BoxProps['alignContent']>;
|
|
64
|
+
flex?: BpkResponsiveValue<BoxProps['flex']>;
|
|
65
|
+
flexGrow?: BpkResponsiveValue<BoxProps['flexGrow']>;
|
|
66
|
+
flexShrink?: BpkResponsiveValue<BoxProps['flexShrink']>;
|
|
67
|
+
flexBasis?: BpkResponsiveValue<BoxProps['flexBasis']>;
|
|
68
|
+
order?: BpkResponsiveValue<BoxProps['order']>;
|
|
69
|
+
alignSelf?: BpkResponsiveValue<BoxProps['alignSelf']>;
|
|
70
|
+
justifySelf?: BpkResponsiveValue<BoxProps['justifySelf']>;
|
|
71
|
+
gridTemplateColumns?: BpkResponsiveValue<BoxProps['gridTemplateColumns']>;
|
|
72
|
+
gridTemplateRows?: BpkResponsiveValue<BoxProps['gridTemplateRows']>;
|
|
73
|
+
gridTemplateAreas?: BpkResponsiveValue<BoxProps['gridTemplateAreas']>;
|
|
74
|
+
gridAutoFlow?: BpkResponsiveValue<BoxProps['gridAutoFlow']>;
|
|
75
|
+
gridAutoRows?: BpkResponsiveValue<BoxProps['gridAutoRows']>;
|
|
76
|
+
gridAutoColumns?: BpkResponsiveValue<BoxProps['gridAutoColumns']>;
|
|
77
|
+
gridColumn?: BpkResponsiveValue<BoxProps['gridColumn']>;
|
|
78
|
+
gridRow?: BpkResponsiveValue<BoxProps['gridRow']>;
|
|
59
79
|
};
|
|
80
|
+
type BpkBoxResponsiveLayoutPropKeys = keyof BpkBoxResponsiveLayoutProps;
|
|
81
|
+
/**
|
|
82
|
+
* Base type that removes common layout props, reserved props (className,
|
|
83
|
+
* children) and all layout-level event props from Chakra UI props.
|
|
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>;
|
|
60
88
|
/**
|
|
61
89
|
* Component-specific props for BpkBox
|
|
90
|
+
* Includes all Box props except those in BpkCommonLayoutProps
|
|
62
91
|
*/
|
|
63
|
-
export interface BpkBoxSpecificProps extends BpkBoxResponsiveLayoutProps, BpkFlexGridProps {
|
|
92
|
+
export interface BpkBoxSpecificProps extends Omit<RemoveCommonProps<BoxProps>, BpkBoxResponsiveLayoutPropKeys>, BpkBoxResponsiveLayoutProps, Omit<BpkFlexGridProps, BpkBoxResponsiveLayoutPropKeys> {
|
|
64
93
|
}
|
|
65
94
|
/**
|
|
66
95
|
* Props for BpkBox component
|
|
67
96
|
* Combines Box-specific props with Backpack common layout props.
|
|
97
|
+
* onClick is inherited from BpkCommonLayoutProps.
|
|
98
|
+
* onFocus and onBlur are reintroduced here as BpkBox-only interaction props.
|
|
99
|
+
* textStyle maps to Chakra's `textStyle` theme prop for Backpack typography and supports responsive values.
|
|
68
100
|
*/
|
|
101
|
+
type BoxEventProps = Pick<BoxProps, 'onFocus' | 'onBlur'>;
|
|
69
102
|
export interface BpkBoxProps extends BpkCommonLayoutProps, BpkBoxSpecificProps {
|
|
70
103
|
children?: ReactNode;
|
|
71
|
-
onFocus?:
|
|
72
|
-
onBlur?:
|
|
104
|
+
onFocus?: BoxEventProps['onFocus'];
|
|
105
|
+
onBlur?: BoxEventProps['onBlur'];
|
|
73
106
|
}
|
|
74
107
|
/**
|
|
75
108
|
* Valid HTML elements that can be used with BpkVessel
|
|
@@ -80,20 +113,50 @@ export type VesselElement = 'div' | 'span' | 'section' | 'article' | 'nav' | 'ma
|
|
|
80
113
|
*
|
|
81
114
|
* BpkVessel is a "migration hatch" that renders an HTML element
|
|
82
115
|
* and accepts all standard HTML attributes for maximum migration flexibility.
|
|
116
|
+
*
|
|
117
|
+
* Accepts all React.HTMLAttributes including:
|
|
118
|
+
* - Styling: className, style
|
|
119
|
+
* - Testing: data-testid, data-cy, data-*
|
|
120
|
+
* - Accessibility: aria-*, role, tabIndex
|
|
121
|
+
* - Basic HTML: id, title, dir, lang, hidden, etc.
|
|
122
|
+
* - All standard DOM events: onClick, onChange, onFocus, etc.
|
|
123
|
+
*
|
|
124
|
+
* @example
|
|
125
|
+
* ```tsx
|
|
126
|
+
* <BpkVessel
|
|
127
|
+
* className="legacy-wrapper"
|
|
128
|
+
* style={{ padding: '16px', transition: 'opacity 0.3s' }}
|
|
129
|
+
* data-testid="migration-wrapper"
|
|
130
|
+
* onClick={handleClick}
|
|
131
|
+
* >
|
|
132
|
+
* Content
|
|
133
|
+
* </BpkVessel>
|
|
134
|
+
*
|
|
135
|
+
* <BpkVessel
|
|
136
|
+
* as="section"
|
|
137
|
+
* className="legacy-section"
|
|
138
|
+
* aria-label="Main content"
|
|
139
|
+
* role="region"
|
|
140
|
+
* dir="rtl"
|
|
141
|
+
* >
|
|
142
|
+
* Section Content
|
|
143
|
+
* </BpkVessel>
|
|
144
|
+
* ```
|
|
83
145
|
*/
|
|
84
146
|
export type BpkVesselProps = {
|
|
85
147
|
as?: VesselElement;
|
|
86
148
|
} & HTMLAttributes<HTMLElement>;
|
|
87
149
|
/**
|
|
88
150
|
* Component-specific props for BpkFlex
|
|
151
|
+
* Includes all Flex props except those in BpkCommonLayoutProps
|
|
89
152
|
*/
|
|
90
|
-
export interface BpkFlexSpecificProps {
|
|
91
|
-
direction?: BpkResponsiveValue<
|
|
92
|
-
justify?: BpkResponsiveValue<
|
|
93
|
-
align?: BpkResponsiveValue<
|
|
94
|
-
wrap?: BpkResponsiveValue<
|
|
95
|
-
grow?: BpkResponsiveValue<
|
|
96
|
-
shrink?: BpkResponsiveValue<
|
|
153
|
+
export interface BpkFlexSpecificProps extends RemoveCommonProps<FlexProps> {
|
|
154
|
+
direction?: BpkResponsiveValue<FlexProps['flexDirection']>;
|
|
155
|
+
justify?: BpkResponsiveValue<FlexProps['justifyContent']>;
|
|
156
|
+
align?: BpkResponsiveValue<FlexProps['alignItems']>;
|
|
157
|
+
wrap?: BpkResponsiveValue<FlexProps['flexWrap']>;
|
|
158
|
+
grow?: BpkResponsiveValue<FlexProps['flexGrow']>;
|
|
159
|
+
shrink?: BpkResponsiveValue<FlexProps['flexShrink']>;
|
|
97
160
|
basis?: BpkResponsiveValue<BpkBasisValue>;
|
|
98
161
|
inline?: boolean;
|
|
99
162
|
}
|
|
@@ -106,20 +169,21 @@ export interface BpkFlexProps extends BpkCommonLayoutProps, BpkFlexSpecificProps
|
|
|
106
169
|
}
|
|
107
170
|
/**
|
|
108
171
|
* Component-specific props for BpkGrid
|
|
172
|
+
* Includes all Grid props except those in BpkCommonLayoutProps
|
|
109
173
|
*/
|
|
110
|
-
export interface BpkGridSpecificProps {
|
|
111
|
-
justify?: BpkResponsiveValue<
|
|
112
|
-
align?: BpkResponsiveValue<
|
|
113
|
-
templateColumns?: BpkResponsiveValue<
|
|
114
|
-
templateRows?: BpkResponsiveValue<
|
|
115
|
-
templateAreas?: BpkResponsiveValue<
|
|
116
|
-
autoFlow?: BpkResponsiveValue<
|
|
117
|
-
autoRows?: BpkResponsiveValue<
|
|
118
|
-
autoColumns?: BpkResponsiveValue<
|
|
174
|
+
export interface BpkGridSpecificProps extends RemoveCommonProps<GridProps> {
|
|
175
|
+
justify?: BpkResponsiveValue<GridProps['justifyContent']>;
|
|
176
|
+
align?: BpkResponsiveValue<GridProps['alignItems']>;
|
|
177
|
+
templateColumns?: BpkResponsiveValue<GridProps['gridTemplateColumns']>;
|
|
178
|
+
templateRows?: BpkResponsiveValue<GridProps['gridTemplateRows']>;
|
|
179
|
+
templateAreas?: BpkResponsiveValue<GridProps['gridTemplateAreas']>;
|
|
180
|
+
autoFlow?: BpkResponsiveValue<GridProps['gridAutoFlow']>;
|
|
181
|
+
autoRows?: BpkResponsiveValue<GridProps['gridAutoRows']>;
|
|
182
|
+
autoColumns?: BpkResponsiveValue<GridProps['gridAutoColumns']>;
|
|
119
183
|
rowGap?: BpkResponsiveValue<BpkSpacingValue>;
|
|
120
184
|
columnGap?: BpkResponsiveValue<BpkSpacingValue>;
|
|
121
|
-
column?: BpkResponsiveValue<
|
|
122
|
-
row?: BpkResponsiveValue<
|
|
185
|
+
column?: BpkResponsiveValue<GridProps['gridColumn']>;
|
|
186
|
+
row?: BpkResponsiveValue<GridProps['gridRow']>;
|
|
123
187
|
inline?: boolean;
|
|
124
188
|
}
|
|
125
189
|
/**
|
|
@@ -131,15 +195,16 @@ export interface BpkGridProps extends BpkCommonLayoutProps, BpkGridSpecificProps
|
|
|
131
195
|
}
|
|
132
196
|
/**
|
|
133
197
|
* Component-specific props for BpkGridItem
|
|
198
|
+
* Includes all GridItem props except those in BpkCommonLayoutProps
|
|
134
199
|
*/
|
|
135
|
-
export interface BpkGridItemSpecificProps {
|
|
136
|
-
area?:
|
|
137
|
-
colEnd?:
|
|
138
|
-
colStart?:
|
|
139
|
-
colSpan?:
|
|
140
|
-
rowEnd?:
|
|
141
|
-
rowStart?:
|
|
142
|
-
rowSpan?:
|
|
200
|
+
export interface BpkGridItemSpecificProps extends RemoveCommonProps<GridItemProps> {
|
|
201
|
+
area?: GridItemProps['area'];
|
|
202
|
+
colEnd?: GridItemProps['colEnd'];
|
|
203
|
+
colStart?: GridItemProps['colStart'];
|
|
204
|
+
colSpan?: GridItemProps['colSpan'];
|
|
205
|
+
rowEnd?: GridItemProps['rowEnd'];
|
|
206
|
+
rowStart?: GridItemProps['rowStart'];
|
|
207
|
+
rowSpan?: GridItemProps['rowSpan'];
|
|
143
208
|
}
|
|
144
209
|
/**
|
|
145
210
|
* Props for BpkGridItem component
|
|
@@ -148,21 +213,19 @@ export interface BpkGridItemSpecificProps {
|
|
|
148
213
|
export interface BpkGridItemProps extends BpkCommonLayoutProps, BpkGridItemSpecificProps {
|
|
149
214
|
children?: ReactNode;
|
|
150
215
|
}
|
|
216
|
+
type StackOptionKeysType = typeof StackOptionKeys[number];
|
|
151
217
|
/**
|
|
152
|
-
*
|
|
153
|
-
* These map to CSS-standard names internally:
|
|
154
|
-
* align → alignItems, justify → justifyContent, wrap → flexWrap, direction → flexDirection
|
|
218
|
+
* Overrides StackOptions to support BpkResponsiveValue
|
|
155
219
|
*/
|
|
156
220
|
type BpkStackOptions = {
|
|
157
|
-
|
|
158
|
-
justify?: BpkResponsiveValue<CSSProperties['justifyContent']> | CSSProperties['justifyContent'];
|
|
159
|
-
wrap?: BpkResponsiveValue<CSSProperties['flexWrap']> | CSSProperties['flexWrap'];
|
|
160
|
-
direction?: BpkResponsiveValue<CSSProperties['flexDirection']> | CSSProperties['flexDirection'];
|
|
221
|
+
[K in StackOptionKeysType]?: K extends keyof StackProps ? BpkResponsiveValue<StackProps[K]> | StackProps[K] : never;
|
|
161
222
|
};
|
|
162
223
|
/**
|
|
163
224
|
* Component-specific props for BpkStack
|
|
225
|
+
* Includes all Stack props except those in BpkCommonLayoutProps
|
|
226
|
+
* Overrides StackOptions to support BpkResponsiveValue
|
|
164
227
|
*/
|
|
165
|
-
export interface BpkStackSpecificProps extends BpkStackOptions, BpkFlexGridProps {
|
|
228
|
+
export interface BpkStackSpecificProps extends Omit<RemoveCommonProps<StackProps>, StackOptionKeysType>, BpkStackOptions, BpkFlexGridProps {
|
|
166
229
|
}
|
|
167
230
|
/**
|
|
168
231
|
* Props for BpkStack component
|
|
@@ -10,6 +10,9 @@ export type Props = {
|
|
|
10
10
|
title: ReactNode;
|
|
11
11
|
titleTextStyle?: TextStyle;
|
|
12
12
|
titleTagName?: Tag;
|
|
13
|
+
/** When true, prevents the title from being truncated with an ellipsis and allows it to wrap onto multiple lines.
|
|
14
|
+
* Note: this prop only applies when `title` is a string; ReactNode titles are not truncated and wrap naturally. */
|
|
15
|
+
wrapTitle?: boolean;
|
|
13
16
|
className?: string;
|
|
14
17
|
leadingButton?: ReactElement | null;
|
|
15
18
|
trailingButton?: ReactElement | null;
|
|
@@ -36,6 +36,7 @@ const BpkNavigationBar = props => {
|
|
|
36
36
|
titleTagName = "span",
|
|
37
37
|
titleTextStyle = TEXT_STYLES.heading5,
|
|
38
38
|
trailingButton,
|
|
39
|
+
wrapTitle = false,
|
|
39
40
|
...rest
|
|
40
41
|
} = props;
|
|
41
42
|
|
|
@@ -51,7 +52,7 @@ const BpkNavigationBar = props => {
|
|
|
51
52
|
className: getClassNames('bpk-navigation-bar__leading-item', `bpk-navigation-bar__leading-item--${barStyle}`),
|
|
52
53
|
children: leadingButton
|
|
53
54
|
}), typeof title === 'string' ? /*#__PURE__*/_jsx("span", {
|
|
54
|
-
className: getClassNames('bpk-navigation-bar__title', `bpk-navigation-bar__title--${barStyle}
|
|
55
|
+
className: getClassNames('bpk-navigation-bar__title', `bpk-navigation-bar__title--${barStyle}`, wrapTitle && 'bpk-navigation-bar__title--wrap'),
|
|
55
56
|
children: /*#__PURE__*/_jsx(BpkText, {
|
|
56
57
|
id: titleId,
|
|
57
58
|
textStyle: titleTextStyle,
|
|
@@ -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-navigation-bar{position:relative;display:grid;min-height:3.5rem;padding:1rem;grid-template-rows:auto;grid-template-columns:minmax(1.5rem, auto) minmax(1rem, 1fr) minmax(1.5rem, auto);justify-content:space-between;align-items:center;gap:1rem;background-color:#fff;background-color:var(--bpk-navigation-bar-background-color, rgb(255, 255, 255))}.bpk-navigation-bar--on-dark{background-color:#05203c}.bpk-navigation-bar__title{grid-column:2;text-align:center;text-overflow:ellipsis;white-space:nowrap;overflow:hidden;color:#161616;color:var(--bpk-navigation-bar-title-color, rgb(22, 22, 22))}.bpk-navigation-bar__title :first-child{display:inline}.bpk-navigation-bar__title--on-dark{color:#fff}.bpk-navigation-bar__title-container{justify-self:center}.bpk-navigation-bar__leading-item,.bpk-navigation-bar__trailing-item{font-size:.875rem;line-height:1.25rem;font-weight:700}.bpk-navigation-bar__leading-item{grid-column:1;justify-self:start}.bpk-navigation-bar__trailing-item{grid-column:3;justify-self:end}.bpk-navigation-bar__sticky{position:sticky;top:0;z-index:899;box-shadow:0px 1px 3px 0px rgba(37,32,31,.3)}
|
|
18
|
+
.bpk-navigation-bar{position:relative;display:grid;min-height:3.5rem;padding:1rem;grid-template-rows:auto;grid-template-columns:minmax(1.5rem, auto) minmax(1rem, 1fr) minmax(1.5rem, auto);justify-content:space-between;align-items:center;gap:1rem;background-color:#fff;background-color:var(--bpk-navigation-bar-background-color, rgb(255, 255, 255))}.bpk-navigation-bar--on-dark{background-color:#05203c}.bpk-navigation-bar__title{grid-column:2;text-align:center;text-overflow:ellipsis;white-space:nowrap;overflow:hidden;color:#161616;color:var(--bpk-navigation-bar-title-color, rgb(22, 22, 22))}.bpk-navigation-bar__title :first-child{display:inline}.bpk-navigation-bar__title--on-dark{color:#fff}.bpk-navigation-bar__title--wrap{text-overflow:unset;white-space:normal;overflow:visible}.bpk-navigation-bar__title-container{justify-self:center}.bpk-navigation-bar__leading-item,.bpk-navigation-bar__trailing-item{font-size:.875rem;line-height:1.25rem;font-weight:700}.bpk-navigation-bar__leading-item{grid-column:1;justify-self:start}.bpk-navigation-bar__trailing-item{grid-column:3;justify-self:end}.bpk-navigation-bar__sticky{position:sticky;top:0;z-index:899;box-shadow:0px 1px 3px 0px rgba(37,32,31,.3)}
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
import BpkButton, { BUTTON_TYPES } from "../../bpk-component-button";
|
|
20
|
-
import {
|
|
20
|
+
import { withLargeButtonAlignment, withRtlSupport } from "../../bpk-component-icon";
|
|
21
21
|
import LeftArrowIcon from "../../bpk-component-icon/lg/chevron-left";
|
|
22
22
|
import RightArrowIcon from "../../bpk-component-icon/lg/chevron-right";
|
|
23
23
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -26,8 +26,8 @@ export const DIRECTIONS = {
|
|
|
26
26
|
INDICATORS: 'INDICATORS',
|
|
27
27
|
NEXT: 'NEXT'
|
|
28
28
|
};
|
|
29
|
-
const AlignedLeftArrowIcon =
|
|
30
|
-
const AlignedRightArrowIcon =
|
|
29
|
+
const AlignedLeftArrowIcon = withLargeButtonAlignment(withRtlSupport(LeftArrowIcon));
|
|
30
|
+
const AlignedRightArrowIcon = withLargeButtonAlignment(withRtlSupport(RightArrowIcon));
|
|
31
31
|
const NavButton = ({
|
|
32
32
|
ariaLabel,
|
|
33
33
|
currentIndex,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skyscanner/backpack-web",
|
|
3
|
-
"version": "42.
|
|
3
|
+
"version": "42.11.0",
|
|
4
4
|
"description": "Backpack Design System web library",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@ark-ui/react": "^5.34.1",
|
|
26
|
+
"@chakra-ui/react": "^3.33.0",
|
|
26
27
|
"@floating-ui/react": "^0.26.12",
|
|
27
28
|
"@radix-ui/react-compose-refs": "^1.1.1",
|
|
28
29
|
"@radix-ui/react-slider": "1.3.5",
|
|
@@ -34,7 +35,7 @@
|
|
|
34
35
|
"d3-scale": "^4.0.2",
|
|
35
36
|
"downshift": "^9.0.10",
|
|
36
37
|
"intersection-observer": "^0.12.2",
|
|
37
|
-
"lodash": "^4.
|
|
38
|
+
"lodash": "^4.18.1",
|
|
38
39
|
"lodash.clamp": "^4.0.3",
|
|
39
40
|
"lodash.debounce": "^4.0.8",
|
|
40
41
|
"normalize.css": "4.2.0",
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { ReactNode } from 'react';
|
|
2
|
-
export interface BpkArkProviderProps {
|
|
3
|
-
children: ReactNode;
|
|
4
|
-
}
|
|
5
|
-
/**
|
|
6
|
-
* BpkArkProvider - Provides locale context for Ark-based Backpack components.
|
|
7
|
-
*
|
|
8
|
-
* Wraps children with Ark UI's LocaleProvider, reactively tracking
|
|
9
|
-
* document direction (html[dir]) and language (html[lang]) via MutationObserver.
|
|
10
|
-
* This enables correct RTL rendering for Ark-based components such as
|
|
11
|
-
* BpkCheckboxV2, BpkSegmentedControlV2, etc.
|
|
12
|
-
*
|
|
13
|
-
* Use BpkProvider (which composes BpkLayoutProvider + BpkArkProvider) if you
|
|
14
|
-
* need both layout primitives and Ark-based components. Use BpkArkProvider
|
|
15
|
-
* directly only if you need Ark locale context without the Chakra layout system.
|
|
16
|
-
*
|
|
17
|
-
* @param {BpkArkProviderProps} props - The provider props.
|
|
18
|
-
* @returns {JSX.Element} The provider wrapping its children with Ark locale context.
|
|
19
|
-
*/
|
|
20
|
-
export declare const BpkArkProvider: ({ children, }: BpkArkProviderProps) => JSX.Element;
|
|
@@ -1,112 +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 { useEffect, useState } from 'react';
|
|
20
|
-
import { LocaleProvider } from '@ark-ui/react';
|
|
21
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
22
|
-
// Fallback locale mapping used when no explicit locale is available on the document.
|
|
23
|
-
// Maps DOM direction to minimal BCP 47 locales understood by Ark's isRTL() utility.
|
|
24
|
-
// 'ar-SA' is the minimal RTL locale — Ark only uses it to derive dir='rtl'.
|
|
25
|
-
const FALLBACK_LOCALE_BY_DIRECTION = {
|
|
26
|
-
ltr: 'en-US',
|
|
27
|
-
rtl: 'ar-SA'
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
// Known RTL language subtags (ISO 639 codes). Used as fallback when
|
|
31
|
-
// Intl.Locale.textInfo is unavailable (Node < 22, older browsers).
|
|
32
|
-
const RTL_LANGUAGE_SUBTAGS = new Set(['ar', 'he', 'fa', 'ur', 'yi', 'iw', 'ps', 'sd', 'ug', 'ku']);
|
|
33
|
-
|
|
34
|
-
// Returns the text direction implied by a BCP 47 locale string.
|
|
35
|
-
// Uses Intl.Locale.textInfo when available (Chrome 99+, Safari 15.4+, Firefox 126+, Node 22+);
|
|
36
|
-
// falls back to a known-RTL-subtag lookup.
|
|
37
|
-
const getLangDir = locale => {
|
|
38
|
-
try {
|
|
39
|
-
const dir = new Intl.Locale(locale).textInfo?.direction;
|
|
40
|
-
if (dir) return dir === 'rtl' ? 'rtl' : 'ltr';
|
|
41
|
-
} catch {
|
|
42
|
-
// Ignore invalid locale strings
|
|
43
|
-
}
|
|
44
|
-
return RTL_LANGUAGE_SUBTAGS.has(locale.split('-')[0].toLowerCase()) ? 'rtl' : 'ltr';
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
// Resolves the locale to pass to Ark's LocaleProvider.
|
|
48
|
-
//
|
|
49
|
-
// Priority rules:
|
|
50
|
-
// 1. If html[dir] is explicitly set:
|
|
51
|
-
// - Use html[lang] only when its direction is consistent with html[dir].
|
|
52
|
-
// - Otherwise fall back to FALLBACK_LOCALE_BY_DIRECTION[dir].
|
|
53
|
-
// This prevents an LTR html[lang] (e.g. 'en' from a page template) from
|
|
54
|
-
// overriding an explicit html[dir]="rtl" signal (e.g. from a dev RTL toggle).
|
|
55
|
-
// 2. If html[dir] is not set: use html[lang] if present, else 'en-US'.
|
|
56
|
-
//
|
|
57
|
-
// SSR-safe: returns 'en-US' when document is unavailable.
|
|
58
|
-
const getArkLocale = () => {
|
|
59
|
-
if (typeof document === 'undefined') return 'en-US';
|
|
60
|
-
const explicitDir = document.documentElement.getAttribute('dir');
|
|
61
|
-
const lang = document.documentElement.getAttribute('lang');
|
|
62
|
-
if (explicitDir === 'rtl' || explicitDir === 'ltr') {
|
|
63
|
-
if (lang && getLangDir(lang) === explicitDir) return lang;
|
|
64
|
-
return FALLBACK_LOCALE_BY_DIRECTION[explicitDir];
|
|
65
|
-
}
|
|
66
|
-
return lang || 'en-US';
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
// Reactive hook: subscribes to document.documentElement[dir] and [lang] changes
|
|
70
|
-
// via MutationObserver. Re-renders when direction or locale is toggled
|
|
71
|
-
// (e.g. Storybook RTL toolbar, runtime locale switcher).
|
|
72
|
-
// SSR-safe: always initialises to 'en-US' so server and client agree on the first render,
|
|
73
|
-
// avoiding hydration mismatches. The real locale is read inside useEffect,
|
|
74
|
-
// which does not run on the server.
|
|
75
|
-
const useArkLocale = () => {
|
|
76
|
-
const [locale, setLocale] = useState('en-US');
|
|
77
|
-
useEffect(() => {
|
|
78
|
-
setLocale(getArkLocale());
|
|
79
|
-
const observer = new MutationObserver(() => setLocale(getArkLocale()));
|
|
80
|
-
observer.observe(document.documentElement, {
|
|
81
|
-
attributes: true,
|
|
82
|
-
attributeFilter: ['dir', 'lang']
|
|
83
|
-
});
|
|
84
|
-
return () => observer.disconnect();
|
|
85
|
-
}, []);
|
|
86
|
-
return locale;
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* BpkArkProvider - Provides locale context for Ark-based Backpack components.
|
|
91
|
-
*
|
|
92
|
-
* Wraps children with Ark UI's LocaleProvider, reactively tracking
|
|
93
|
-
* document direction (html[dir]) and language (html[lang]) via MutationObserver.
|
|
94
|
-
* This enables correct RTL rendering for Ark-based components such as
|
|
95
|
-
* BpkCheckboxV2, BpkSegmentedControlV2, etc.
|
|
96
|
-
*
|
|
97
|
-
* Use BpkProvider (which composes BpkLayoutProvider + BpkArkProvider) if you
|
|
98
|
-
* need both layout primitives and Ark-based components. Use BpkArkProvider
|
|
99
|
-
* directly only if you need Ark locale context without the Chakra layout system.
|
|
100
|
-
*
|
|
101
|
-
* @param {BpkArkProviderProps} props - The provider props.
|
|
102
|
-
* @returns {JSX.Element} The provider wrapping its children with Ark locale context.
|
|
103
|
-
*/
|
|
104
|
-
export const BpkArkProvider = ({
|
|
105
|
-
children
|
|
106
|
-
}) => {
|
|
107
|
-
const locale = useArkLocale();
|
|
108
|
-
return /*#__PURE__*/_jsx(LocaleProvider, {
|
|
109
|
-
locale: locale,
|
|
110
|
-
children: children
|
|
111
|
-
});
|
|
112
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type React from 'react';
|
|
2
|
-
import type { ReactNode } from 'react';
|
|
3
|
-
export interface BpkLayoutProviderProps {
|
|
4
|
-
children: ReactNode;
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* BpkLayoutProvider - Kept for backwards compatibility.
|
|
8
|
-
*
|
|
9
|
-
* Layout components (BpkBox, BpkFlex, BpkGrid, BpkStack, etc.) no longer
|
|
10
|
-
* require a provider. They use CSS Modules and inline styles directly.
|
|
11
|
-
*
|
|
12
|
-
* This component is a passthrough that simply renders its children.
|
|
13
|
-
* It can be safely removed from your app, but keeping it is harmless.
|
|
14
|
-
*
|
|
15
|
-
* @deprecated No provider is needed for layout components.
|
|
16
|
-
* @returns {ReactNode} The children as-is.
|
|
17
|
-
*/
|
|
18
|
-
export declare const BpkLayoutProvider: ({ children, }: BpkLayoutProviderProps) => React.JSX.Element;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
/*
|
|
3
|
-
* Backpack - Skyscanner's Design System
|
|
4
|
-
*
|
|
5
|
-
* Copyright 2016 Skyscanner Ltd
|
|
6
|
-
*
|
|
7
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
-
* you may not use this file except in compliance with the License.
|
|
9
|
-
* You may obtain a copy of the License at
|
|
10
|
-
*
|
|
11
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
-
*
|
|
13
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
-
* See the License for the specific language governing permissions and
|
|
17
|
-
* limitations under the License.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* BpkLayoutProvider - Kept for backwards compatibility.
|
|
22
|
-
*
|
|
23
|
-
* Layout components (BpkBox, BpkFlex, BpkGrid, BpkStack, etc.) no longer
|
|
24
|
-
* require a provider. They use CSS Modules and inline styles directly.
|
|
25
|
-
*
|
|
26
|
-
* This component is a passthrough that simply renders its children.
|
|
27
|
-
* It can be safely removed from your app, but keeping it is harmless.
|
|
28
|
-
*
|
|
29
|
-
* @deprecated No provider is needed for layout components.
|
|
30
|
-
* @returns {ReactNode} The children as-is.
|
|
31
|
-
*/
|
|
32
|
-
export const BpkLayoutProvider = ({
|
|
33
|
-
children
|
|
34
|
-
}) => /*#__PURE__*/_jsx(_Fragment, {
|
|
35
|
-
children: children
|
|
36
|
-
});
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Expands a textStyle token (or responsive object of tokens) into concrete
|
|
3
|
-
* CSS property values that can be spread directly onto a Chakra component.
|
|
4
|
-
*
|
|
5
|
-
* Supports:
|
|
6
|
-
* - Static values: `textStyle="heading-3"` → `{ fontSize, lineHeight, fontWeight }`
|
|
7
|
-
* - Responsive objects: `textStyle={{ mobile: 'heading-5', desktop: 'heading-3' }}`
|
|
8
|
-
* → `{ fontSize: { md: '...', '2xl': '...' }, lineHeight: { ... }, ... }`
|
|
9
|
-
*
|
|
10
|
-
* @param {any} value - A textStyle token string, responsive object, or undefined/null.
|
|
11
|
-
* @returns {Record<string, any>} An object of CSS props to spread, or an empty object if no match.
|
|
12
|
-
*/
|
|
13
|
-
export declare function expandTextStyleProps(value: any): Record<string, any>;
|