@skyscanner/backpack-web 41.14.0 → 41.15.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.
Files changed (31) hide show
  1. package/bpk-component-bottom-sheet/src/BpkBottomSheet.d.ts +1 -1
  2. package/bpk-component-bottom-sheet/src/BpkBottomSheet.js +11 -4
  3. package/bpk-component-layout/index.d.ts +18 -0
  4. package/bpk-component-layout/index.js +29 -0
  5. package/bpk-component-layout/src/BpkBox.d.ts +3 -0
  6. package/bpk-component-layout/src/BpkBox.js +35 -0
  7. package/bpk-component-layout/src/BpkFlex.d.ts +3 -0
  8. package/bpk-component-layout/src/BpkFlex.js +53 -0
  9. package/bpk-component-layout/src/BpkGrid.d.ts +3 -0
  10. package/bpk-component-layout/src/BpkGrid.js +59 -0
  11. package/bpk-component-layout/src/BpkGridItem.d.ts +3 -0
  12. package/bpk-component-layout/src/BpkGridItem.js +47 -0
  13. package/bpk-component-layout/src/BpkProvider.d.ts +14 -0
  14. package/bpk-component-layout/src/BpkProvider.js +42 -0
  15. package/bpk-component-layout/src/BpkStack.constant.d.ts +2 -0
  16. package/bpk-component-layout/src/BpkStack.constant.js +22 -0
  17. package/bpk-component-layout/src/BpkStack.d.ts +5 -0
  18. package/bpk-component-layout/src/BpkStack.js +61 -0
  19. package/bpk-component-layout/src/BpkVessel.d.ts +46 -0
  20. package/bpk-component-layout/src/BpkVessel.js +72 -0
  21. package/bpk-component-layout/src/commonProps.d.ts +86 -0
  22. package/bpk-component-layout/src/commonProps.js +1 -0
  23. package/bpk-component-layout/src/theme.d.ts +36 -0
  24. package/bpk-component-layout/src/theme.js +229 -0
  25. package/bpk-component-layout/src/tokenUtils.d.ts +108 -0
  26. package/bpk-component-layout/src/tokenUtils.js +323 -0
  27. package/bpk-component-layout/src/tokens.d.ts +96 -0
  28. package/bpk-component-layout/src/tokens.js +138 -0
  29. package/bpk-component-layout/src/types.d.ts +236 -0
  30. package/bpk-component-layout/src/types.js +1 -0
  31. package/package.json +2 -1
@@ -0,0 +1,236 @@
1
+ import type { ReactNode } from 'react';
2
+ import type StackOptionKeys from './BpkStack.constant';
3
+ import type { BpkCommonLayoutProps } from './commonProps';
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
+ * by default. BpkBox will reintroduce a minimal subset (onClick, onFocus,
9
+ * onBlur) explicitly on its own props type.
10
+ */
11
+ type LayoutEventProps = 'onClick' | '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
+ /**
20
+ * Flexbox & grid layout props that we explicitly support on Backpack layout
21
+ * components. These are a curated subset of the underlying Box flex/grid API
22
+ * that are useful for structural layout.
23
+ */
24
+ export interface BpkFlexGridProps {
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'];
46
+ }
47
+ export type FlexGridPropKeys = keyof BpkFlexGridProps;
48
+ /**
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`.
56
+ */
57
+ type BpkBoxResponsiveLayoutProps = {
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']>;
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>;
88
+ /**
89
+ * Component-specific props for BpkBox
90
+ * Includes all Box props except those in BpkCommonLayoutProps
91
+ */
92
+ export interface BpkBoxSpecificProps extends Omit<RemoveCommonProps<BoxProps>, BpkBoxResponsiveLayoutPropKeys>, BpkBoxResponsiveLayoutProps, Omit<BpkFlexGridProps, BpkBoxResponsiveLayoutPropKeys> {
93
+ }
94
+ /**
95
+ * Props for BpkBox component
96
+ * Combines Box-specific props with Backpack common layout props
97
+ * and reintroduces a minimal set of interaction props.
98
+ */
99
+ type BoxEventProps = Pick<BoxProps, 'onClick' | 'onFocus' | 'onBlur'>;
100
+ export interface BpkBoxProps extends BpkCommonLayoutProps, BpkBoxSpecificProps {
101
+ children?: ReactNode;
102
+ onClick?: BoxEventProps['onClick'];
103
+ onFocus?: BoxEventProps['onFocus'];
104
+ onBlur?: BoxEventProps['onBlur'];
105
+ }
106
+ /**
107
+ * Valid HTML elements that can be used with BpkVessel
108
+ */
109
+ export type VesselElement = 'div' | 'span' | 'section' | 'article' | 'nav' | 'main' | 'aside' | 'header' | 'footer';
110
+ /**
111
+ * Props for BpkVessel component.
112
+ *
113
+ * BpkVessel is a "migration hatch" that renders an HTML element
114
+ * and accepts all standard HTML attributes for maximum migration flexibility.
115
+ *
116
+ * Accepts all React.HTMLAttributes including:
117
+ * - Styling: className, style
118
+ * - Testing: data-testid, data-cy, data-*
119
+ * - Accessibility: aria-*, role, tabIndex
120
+ * - Basic HTML: id, title, dir, lang, hidden, etc.
121
+ * - All standard DOM events: onClick, onChange, onFocus, etc.
122
+ *
123
+ * @example
124
+ * ```tsx
125
+ * <BpkVessel
126
+ * className="legacy-wrapper"
127
+ * style={{ padding: '16px', transition: 'opacity 0.3s' }}
128
+ * data-testid="migration-wrapper"
129
+ * onClick={handleClick}
130
+ * >
131
+ * Content
132
+ * </BpkVessel>
133
+ *
134
+ * <BpkVessel
135
+ * as="section"
136
+ * className="legacy-section"
137
+ * aria-label="Main content"
138
+ * role="region"
139
+ * dir="rtl"
140
+ * >
141
+ * Section Content
142
+ * </BpkVessel>
143
+ * ```
144
+ */
145
+ export type BpkVesselProps = {
146
+ as?: VesselElement;
147
+ } & React.HTMLAttributes<HTMLElement>;
148
+ /**
149
+ * Component-specific props for BpkFlex
150
+ * Includes all Flex props except those in BpkCommonLayoutProps
151
+ */
152
+ export interface BpkFlexSpecificProps extends RemoveCommonProps<FlexProps> {
153
+ direction?: BpkResponsiveValue<FlexProps['flexDirection']>;
154
+ justify?: BpkResponsiveValue<FlexProps['justifyContent']>;
155
+ align?: BpkResponsiveValue<FlexProps['alignItems']>;
156
+ wrap?: BpkResponsiveValue<FlexProps['flexWrap']>;
157
+ grow?: BpkResponsiveValue<FlexProps['flexGrow']>;
158
+ shrink?: BpkResponsiveValue<FlexProps['flexShrink']>;
159
+ basis?: BpkResponsiveValue<BpkBasisValue>;
160
+ inline?: boolean;
161
+ }
162
+ /**
163
+ * Props for BpkFlex component
164
+ * Combines Flex-specific props with Backpack common layout props
165
+ */
166
+ export interface BpkFlexProps extends BpkCommonLayoutProps, BpkFlexSpecificProps {
167
+ children?: ReactNode;
168
+ }
169
+ /**
170
+ * Component-specific props for BpkGrid
171
+ * Includes all Grid props except those in BpkCommonLayoutProps
172
+ */
173
+ export interface BpkGridSpecificProps extends RemoveCommonProps<GridProps> {
174
+ justify?: BpkResponsiveValue<GridProps['justifyContent']>;
175
+ align?: BpkResponsiveValue<GridProps['alignItems']>;
176
+ templateColumns?: BpkResponsiveValue<GridProps['gridTemplateColumns']>;
177
+ templateRows?: BpkResponsiveValue<GridProps['gridTemplateRows']>;
178
+ templateAreas?: BpkResponsiveValue<GridProps['gridTemplateAreas']>;
179
+ autoFlow?: BpkResponsiveValue<GridProps['gridAutoFlow']>;
180
+ autoRows?: BpkResponsiveValue<GridProps['gridAutoRows']>;
181
+ autoColumns?: BpkResponsiveValue<GridProps['gridAutoColumns']>;
182
+ rowGap?: BpkResponsiveValue<BpkSpacingValue>;
183
+ columnGap?: BpkResponsiveValue<BpkSpacingValue>;
184
+ column?: BpkResponsiveValue<GridProps['gridColumn']>;
185
+ row?: BpkResponsiveValue<GridProps['gridRow']>;
186
+ inline?: boolean;
187
+ }
188
+ /**
189
+ * Props for BpkGrid component
190
+ * Combines Grid-specific props with Backpack common layout props
191
+ */
192
+ export interface BpkGridProps extends BpkCommonLayoutProps, BpkGridSpecificProps {
193
+ children?: ReactNode;
194
+ }
195
+ /**
196
+ * Component-specific props for BpkGridItem
197
+ * Includes all GridItem props except those in BpkCommonLayoutProps
198
+ */
199
+ export interface BpkGridItemSpecificProps extends RemoveCommonProps<GridItemProps> {
200
+ area?: GridItemProps['area'];
201
+ colEnd?: GridItemProps['colEnd'];
202
+ colStart?: GridItemProps['colStart'];
203
+ colSpan?: GridItemProps['colSpan'];
204
+ rowEnd?: GridItemProps['rowEnd'];
205
+ rowStart?: GridItemProps['rowStart'];
206
+ rowSpan?: GridItemProps['rowSpan'];
207
+ }
208
+ /**
209
+ * Props for BpkGridItem component
210
+ * Combines GridItem-specific props with Backpack common layout props
211
+ */
212
+ export interface BpkGridItemProps extends BpkCommonLayoutProps, BpkGridItemSpecificProps {
213
+ children?: ReactNode;
214
+ }
215
+ type StackOptionKeysType = typeof StackOptionKeys[number];
216
+ /**
217
+ * Overrides StackOptions to support BpkResponsiveValue
218
+ */
219
+ type BpkStackOptions = {
220
+ [K in StackOptionKeysType]?: K extends keyof StackProps ? BpkResponsiveValue<StackProps[K]> | StackProps[K] : never;
221
+ };
222
+ /**
223
+ * Component-specific props for BpkStack
224
+ * Includes all Stack props except those in BpkCommonLayoutProps
225
+ * Overrides StackOptions to support BpkResponsiveValue
226
+ */
227
+ export interface BpkStackSpecificProps extends Omit<RemoveCommonProps<StackProps>, StackOptionKeysType>, BpkStackOptions, BpkFlexGridProps {
228
+ }
229
+ /**
230
+ * Props for BpkStack component
231
+ * Combines Stack-specific props with Backpack common layout props
232
+ */
233
+ export interface BpkStackProps extends BpkCommonLayoutProps, BpkStackSpecificProps {
234
+ children?: ReactNode;
235
+ }
236
+ export type { BpkCommonLayoutProps };
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skyscanner/backpack-web",
3
- "version": "41.14.0",
3
+ "version": "41.15.1",
4
4
  "description": "Backpack Design System web library",
5
5
  "repository": {
6
6
  "type": "git",
@@ -22,6 +22,7 @@
22
22
  "access": "public"
23
23
  },
24
24
  "dependencies": {
25
+ "@chakra-ui/react": "^3.30.0",
25
26
  "@floating-ui/react": "^0.26.12",
26
27
  "@popperjs/core": "^2.11.8",
27
28
  "@radix-ui/react-compose-refs": "^1.1.1",