@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
|
@@ -132,6 +132,7 @@ const BpkBottomSheet = ({
|
|
|
132
132
|
title: titleWithId,
|
|
133
133
|
titleTextStyle: TEXT_STYLES.label1,
|
|
134
134
|
titleTagName: hasTitle ? 'h2' : 'span',
|
|
135
|
+
wrapTitle: true,
|
|
135
136
|
className: getClassName('bpk-bottom-sheet--header'),
|
|
136
137
|
leadingButton: /*#__PURE__*/_jsx(BpkCloseButton, {
|
|
137
138
|
label: closeLabel,
|
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
export { BpkProvider } from './src/BpkProvider';
|
|
2
|
-
export { BpkLayoutProvider } from './src/BpkLayoutProvider';
|
|
3
|
-
export { BpkArkProvider } from './src/BpkArkProvider';
|
|
4
2
|
export { BpkBox } from './src/BpkBox';
|
|
5
3
|
export { BpkVessel } from './src/BpkVessel';
|
|
6
4
|
export { BpkFlex } from './src/BpkFlex';
|
|
7
5
|
export { BpkGrid } from './src/BpkGrid';
|
|
8
6
|
export { BpkGridItem } from './src/BpkGridItem';
|
|
9
7
|
export type { BpkProviderProps } from './src/BpkProvider';
|
|
10
|
-
export type { BpkLayoutProviderProps } from './src/BpkLayoutProvider';
|
|
11
|
-
export type { BpkArkProviderProps } from './src/BpkArkProvider';
|
|
12
8
|
export type { BpkBoxProps } from './src/BpkBox';
|
|
13
9
|
export type { BpkVesselProps } from './src/BpkVessel';
|
|
14
10
|
export type { BpkFlexProps } from './src/BpkFlex';
|
|
@@ -17,8 +17,6 @@
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
export { BpkProvider } from "./src/BpkProvider";
|
|
20
|
-
export { BpkLayoutProvider } from "./src/BpkLayoutProvider";
|
|
21
|
-
export { BpkArkProvider } from "./src/BpkArkProvider";
|
|
22
20
|
export { BpkBox } from "./src/BpkBox";
|
|
23
21
|
export { BpkVessel } from "./src/BpkVessel";
|
|
24
22
|
export { BpkFlex } from "./src/BpkFlex";
|
|
@@ -17,10 +17,9 @@
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
import { forwardRef } from 'react';
|
|
20
|
+
import { Box } from '@chakra-ui/react';
|
|
20
21
|
import { cssModules, getDataComponentAttribute } from "../../bpk-react-utils";
|
|
21
|
-
import { buildLayoutOutput } from "./responsiveStyleBuilder";
|
|
22
22
|
import { processBpkComponentProps } from "./tokenUtils";
|
|
23
|
-
import useCurrentBreakpoint from "./useCurrentBreakpoint";
|
|
24
23
|
import STYLES from "./BpkLayout.module.css";
|
|
25
24
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
26
25
|
const getClassName = cssModules(STYLES);
|
|
@@ -30,22 +29,20 @@ export const BpkBox = /*#__PURE__*/forwardRef(({
|
|
|
30
29
|
color,
|
|
31
30
|
...props
|
|
32
31
|
}, ref) => {
|
|
33
|
-
const currentBreakpoint = useCurrentBreakpoint();
|
|
34
32
|
const processedProps = processBpkComponentProps(props, {
|
|
35
33
|
component: 'BpkBox'
|
|
36
34
|
});
|
|
37
|
-
const {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
});
|
|
35
|
+
const classNames = color || backgroundColor ? getClassName('bpk-layout', color ? `bpk-layout--${color}` : '', backgroundColor ? `bpk-layout--${backgroundColor}` : '') : undefined;
|
|
36
|
+
return (
|
|
37
|
+
/*#__PURE__*/
|
|
38
|
+
// eslint-disable-next-line @skyscanner/rules/forbid-component-props
|
|
39
|
+
_jsx(Box, {
|
|
40
|
+
ref: ref,
|
|
41
|
+
className: classNames,
|
|
42
|
+
...getDataComponentAttribute('Box'),
|
|
43
|
+
...processedProps,
|
|
44
|
+
children: children
|
|
45
|
+
})
|
|
46
|
+
);
|
|
50
47
|
});
|
|
51
48
|
BpkBox.displayName = 'BpkBox';
|
|
@@ -17,10 +17,9 @@
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
import { forwardRef } from 'react';
|
|
20
|
+
import { Flex } from '@chakra-ui/react';
|
|
20
21
|
import { cssModules, getDataComponentAttribute } from "../../bpk-react-utils";
|
|
21
|
-
import { buildLayoutOutput } from "./responsiveStyleBuilder";
|
|
22
22
|
import { processBpkComponentProps } from "./tokenUtils";
|
|
23
|
-
import useCurrentBreakpoint from "./useCurrentBreakpoint";
|
|
24
23
|
import STYLES from "./BpkLayout.module.css";
|
|
25
24
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
26
25
|
const getClassName = cssModules(STYLES);
|
|
@@ -39,7 +38,6 @@ export const BpkFlex = /*#__PURE__*/forwardRef(({
|
|
|
39
38
|
wrap,
|
|
40
39
|
...props
|
|
41
40
|
}, ref) => {
|
|
42
|
-
const currentBreakpoint = useCurrentBreakpoint();
|
|
43
41
|
const processedProps = processBpkComponentProps(props, {
|
|
44
42
|
component: 'BpkFlex',
|
|
45
43
|
responsiveProps: {
|
|
@@ -53,24 +51,15 @@ export const BpkFlex = /*#__PURE__*/forwardRef(({
|
|
|
53
51
|
flexBasis: basis
|
|
54
52
|
}
|
|
55
53
|
});
|
|
56
|
-
const {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
if (!style.display) {
|
|
63
|
-
style.display = inline ? 'inline-flex' : 'flex';
|
|
64
|
-
} else if (inline) {
|
|
65
|
-
style.display = 'inline-flex';
|
|
66
|
-
}
|
|
67
|
-
const className = color || backgroundColor ? getClassName('bpk-layout', color ? `bpk-layout--${color}` : '', backgroundColor ? `bpk-layout--${backgroundColor}` : '') : undefined;
|
|
68
|
-
return /*#__PURE__*/_jsx("div", {
|
|
69
|
-
ref: ref,
|
|
70
|
-
className: className,
|
|
71
|
-
style: style,
|
|
54
|
+
const classNames = color || backgroundColor ? getClassName('bpk-layout', color ? `bpk-layout--${color}` : '', backgroundColor ? `bpk-layout--${backgroundColor}` : '') : undefined;
|
|
55
|
+
return /*#__PURE__*/_jsx(Flex, {
|
|
56
|
+
ref: ref
|
|
57
|
+
// eslint-disable-next-line @skyscanner/rules/forbid-component-props
|
|
58
|
+
,
|
|
59
|
+
className: classNames,
|
|
72
60
|
...getDataComponentAttribute('Flex'),
|
|
73
|
-
...
|
|
61
|
+
...processedProps,
|
|
62
|
+
display: inline ? 'inline-flex' : undefined,
|
|
74
63
|
children: children
|
|
75
64
|
});
|
|
76
65
|
});
|
|
@@ -17,10 +17,9 @@
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
import { forwardRef } from 'react';
|
|
20
|
+
import { Grid } from '@chakra-ui/react';
|
|
20
21
|
import { cssModules, getDataComponentAttribute } from "../../bpk-react-utils";
|
|
21
|
-
import { buildLayoutOutput } from "./responsiveStyleBuilder";
|
|
22
22
|
import { processBpkComponentProps } from "./tokenUtils";
|
|
23
|
-
import useCurrentBreakpoint from "./useCurrentBreakpoint";
|
|
24
23
|
import STYLES from "./BpkLayout.module.css";
|
|
25
24
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
26
25
|
const getClassName = cssModules(STYLES);
|
|
@@ -42,7 +41,6 @@ export const BpkGrid = /*#__PURE__*/forwardRef(({
|
|
|
42
41
|
textStyle,
|
|
43
42
|
...props
|
|
44
43
|
}, ref) => {
|
|
45
|
-
const currentBreakpoint = useCurrentBreakpoint();
|
|
46
44
|
const processedProps = processBpkComponentProps(props, {
|
|
47
45
|
component: 'BpkGrid',
|
|
48
46
|
responsiveProps: {
|
|
@@ -59,24 +57,15 @@ export const BpkGrid = /*#__PURE__*/forwardRef(({
|
|
|
59
57
|
gridRow: row
|
|
60
58
|
}
|
|
61
59
|
});
|
|
62
|
-
const {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
if (!style.display) {
|
|
69
|
-
style.display = inline ? 'inline-grid' : 'grid';
|
|
70
|
-
} else if (inline) {
|
|
71
|
-
style.display = 'inline-grid';
|
|
72
|
-
}
|
|
73
|
-
const className = color || backgroundColor ? getClassName('bpk-layout', color ? `bpk-layout--${color}` : '', backgroundColor ? `bpk-layout--${backgroundColor}` : '') : undefined;
|
|
74
|
-
return /*#__PURE__*/_jsx("div", {
|
|
75
|
-
ref: ref,
|
|
76
|
-
className: className,
|
|
77
|
-
style: style,
|
|
60
|
+
const classNames = color || backgroundColor ? getClassName('bpk-layout', color ? `bpk-layout--${color}` : '', backgroundColor ? `bpk-layout--${backgroundColor}` : '') : undefined;
|
|
61
|
+
return /*#__PURE__*/_jsx(Grid, {
|
|
62
|
+
ref: ref
|
|
63
|
+
// eslint-disable-next-line @skyscanner/rules/forbid-component-props
|
|
64
|
+
,
|
|
65
|
+
className: classNames,
|
|
78
66
|
...getDataComponentAttribute('Grid'),
|
|
79
|
-
...
|
|
67
|
+
...processedProps,
|
|
68
|
+
display: inline ? 'inline-grid' : undefined,
|
|
80
69
|
children: children
|
|
81
70
|
});
|
|
82
71
|
});
|
|
@@ -17,10 +17,9 @@
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
import { forwardRef } from 'react';
|
|
20
|
+
import { GridItem } from '@chakra-ui/react';
|
|
20
21
|
import { cssModules, getDataComponentAttribute } from "../../bpk-react-utils";
|
|
21
|
-
import { buildLayoutOutput } from "./responsiveStyleBuilder";
|
|
22
22
|
import { processBpkComponentProps } from "./tokenUtils";
|
|
23
|
-
import useCurrentBreakpoint from "./useCurrentBreakpoint";
|
|
24
23
|
import STYLES from "./BpkLayout.module.css";
|
|
25
24
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
26
25
|
const getClassName = cssModules(STYLES);
|
|
@@ -38,34 +37,27 @@ export const BpkGridItem = /*#__PURE__*/forwardRef(({
|
|
|
38
37
|
textStyle,
|
|
39
38
|
...props
|
|
40
39
|
}, ref) => {
|
|
41
|
-
const currentBreakpoint = useCurrentBreakpoint();
|
|
42
40
|
const processedProps = processBpkComponentProps({
|
|
43
41
|
textStyle,
|
|
44
42
|
...props
|
|
45
43
|
}, {
|
|
46
44
|
component: 'BpkGridItem'
|
|
47
45
|
});
|
|
48
|
-
const {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
if (area != null) style.gridArea = area;
|
|
55
|
-
// Use "span N / span N" format to ensure forward-only spanning
|
|
56
|
-
if (colSpan != null) style.gridColumn = `span ${colSpan}/span ${colSpan}`;
|
|
57
|
-
if (colStart != null) style.gridColumnStart = String(colStart);
|
|
58
|
-
if (colEnd != null) style.gridColumnEnd = String(colEnd);
|
|
59
|
-
if (rowSpan != null) style.gridRow = `span ${rowSpan}/span ${rowSpan}`;
|
|
60
|
-
if (rowStart != null) style.gridRowStart = String(rowStart);
|
|
61
|
-
if (rowEnd != null) style.gridRowEnd = String(rowEnd);
|
|
62
|
-
const className = color || backgroundColor ? getClassName('bpk-layout', color ? `bpk-layout--${color}` : '', backgroundColor ? `bpk-layout--${backgroundColor}` : '') : undefined;
|
|
63
|
-
return /*#__PURE__*/_jsx("div", {
|
|
64
|
-
ref: ref,
|
|
65
|
-
className: className,
|
|
66
|
-
style: style,
|
|
46
|
+
const classNames = color || backgroundColor ? getClassName('bpk-layout', color ? `bpk-layout--${color}` : '', backgroundColor ? `bpk-layout--${backgroundColor}` : '') : undefined;
|
|
47
|
+
return /*#__PURE__*/_jsx(GridItem, {
|
|
48
|
+
ref: ref
|
|
49
|
+
// eslint-disable-next-line @skyscanner/rules/forbid-component-props
|
|
50
|
+
,
|
|
51
|
+
className: classNames,
|
|
67
52
|
...getDataComponentAttribute('GridItem'),
|
|
68
|
-
...
|
|
53
|
+
...processedProps,
|
|
54
|
+
area: area,
|
|
55
|
+
colEnd: colEnd,
|
|
56
|
+
colStart: colStart,
|
|
57
|
+
colSpan: colSpan,
|
|
58
|
+
rowEnd: rowEnd,
|
|
59
|
+
rowStart: rowStart,
|
|
60
|
+
rowSpan: rowSpan,
|
|
69
61
|
children: children
|
|
70
62
|
});
|
|
71
63
|
});
|
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
import type React from 'react';
|
|
2
1
|
import type { ReactNode } from 'react';
|
|
3
2
|
export interface BpkProviderProps {
|
|
4
3
|
children: ReactNode;
|
|
5
4
|
}
|
|
6
5
|
/**
|
|
7
|
-
* BpkProvider - Provides context for Ark-based components.
|
|
6
|
+
* BpkProvider - Provides context for Backpack layout and Ark-based components.
|
|
8
7
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* Ark-based components
|
|
8
|
+
* Wraps children with:
|
|
9
|
+
* - Chakra UI system context (for layout components: BpkFlex, BpkGrid, etc.)
|
|
10
|
+
* - Ark UI LocaleProvider (for Ark-based components: BpkCheckboxV2, BpkSegmentedControlV2, etc.)
|
|
11
|
+
*
|
|
12
|
+
* RTL support: reads document direction reactively via MutationObserver and passes
|
|
13
|
+
* the appropriate locale to Ark's LocaleProvider. All Ark-based components in the
|
|
14
|
+
* tree render correctly in RTL without requiring additional wrapping or prop changes.
|
|
12
15
|
*
|
|
13
16
|
* @param {BpkProviderProps} props - The provider props.
|
|
14
|
-
* @returns {
|
|
17
|
+
* @returns {JSX.Element} The provider wrapping its children with Chakra and Ark context.
|
|
15
18
|
*/
|
|
16
|
-
export declare const BpkProvider: ({ children }: BpkProviderProps) =>
|
|
19
|
+
export declare const BpkProvider: ({ children }: BpkProviderProps) => JSX.Element;
|
|
@@ -16,23 +16,109 @@
|
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
19
|
+
import { useEffect, useState } from 'react';
|
|
20
|
+
import { LocaleProvider } from '@ark-ui/react';
|
|
21
|
+
import { ChakraProvider, createSystem, defaultBaseConfig } from '@chakra-ui/react';
|
|
22
|
+
import { createBpkConfig } from "./theme";
|
|
21
23
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
22
24
|
/**
|
|
23
|
-
*
|
|
25
|
+
* Creates a Chakra UI system with Backpack token mappings.
|
|
24
26
|
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
27
|
+
* Uses `defaultBaseConfig` (conditions + utilities only) instead of
|
|
28
|
+
* `defaultConfig` to avoid bundling ~141KB of unused component recipes.
|
|
29
|
+
* See: https://chakra-ui.com/guides/component-bundle-optimization
|
|
30
|
+
*/
|
|
31
|
+
const bpkSystem = createSystem(defaultBaseConfig, createBpkConfig());
|
|
32
|
+
// Fallback locale mapping used when no explicit locale is available on the document.
|
|
33
|
+
// Maps DOM direction to minimal BCP 47 locales understood by Ark's isRTL() utility.
|
|
34
|
+
// 'ar-SA' is the minimal RTL locale — Ark only uses it to derive dir='rtl'.
|
|
35
|
+
const FALLBACK_LOCALE_BY_DIRECTION = {
|
|
36
|
+
ltr: 'en-US',
|
|
37
|
+
rtl: 'ar-SA'
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
// Known RTL language subtags (ISO 639 codes). Used as fallback when
|
|
41
|
+
// Intl.Locale.textInfo is unavailable (Node < 22, older browsers).
|
|
42
|
+
const RTL_LANGUAGE_SUBTAGS = new Set(['ar', 'he', 'fa', 'ur', 'yi', 'iw', 'ps', 'sd', 'ug', 'ku']);
|
|
43
|
+
|
|
44
|
+
// Returns the text direction implied by a BCP 47 locale string.
|
|
45
|
+
// Uses Intl.Locale.textInfo when available (Chrome 99+, Safari 15.4+, Firefox 126+, Node 22+);
|
|
46
|
+
// falls back to a known-RTL-subtag lookup.
|
|
47
|
+
const getLangDir = locale => {
|
|
48
|
+
try {
|
|
49
|
+
const dir = new Intl.Locale(locale).textInfo?.direction;
|
|
50
|
+
if (dir) return dir === 'rtl' ? 'rtl' : 'ltr';
|
|
51
|
+
} catch {
|
|
52
|
+
// Ignore invalid locale strings
|
|
53
|
+
}
|
|
54
|
+
return RTL_LANGUAGE_SUBTAGS.has(locale.split('-')[0].toLowerCase()) ? 'rtl' : 'ltr';
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
// Resolves the locale to pass to Ark's LocaleProvider.
|
|
58
|
+
//
|
|
59
|
+
// Priority rules:
|
|
60
|
+
// 1. If html[dir] is explicitly set:
|
|
61
|
+
// - Use html[lang] only when its direction is consistent with html[dir].
|
|
62
|
+
// - Otherwise fall back to FALLBACK_LOCALE_BY_DIRECTION[dir].
|
|
63
|
+
// This prevents an LTR html[lang] (e.g. 'en' from a page template) from
|
|
64
|
+
// overriding an explicit html[dir]="rtl" signal (e.g. from a dev RTL toggle).
|
|
65
|
+
// 2. If html[dir] is not set: use html[lang] if present, else 'en-US'.
|
|
66
|
+
//
|
|
67
|
+
// SSR-safe: returns 'en-US' when document is unavailable.
|
|
68
|
+
const getArkLocale = () => {
|
|
69
|
+
if (typeof document === 'undefined') return 'en-US';
|
|
70
|
+
const explicitDir = document.documentElement.getAttribute('dir');
|
|
71
|
+
const lang = document.documentElement.getAttribute('lang');
|
|
72
|
+
if (explicitDir === 'rtl' || explicitDir === 'ltr') {
|
|
73
|
+
if (lang && getLangDir(lang) === explicitDir) return lang;
|
|
74
|
+
return FALLBACK_LOCALE_BY_DIRECTION[explicitDir];
|
|
75
|
+
}
|
|
76
|
+
return lang || 'en-US';
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
// Reactive hook: subscribes to document.documentElement[dir] and [lang] changes
|
|
80
|
+
// via MutationObserver. Re-renders BpkProvider when direction or locale is toggled
|
|
81
|
+
// (e.g. Storybook RTL toolbar, runtime locale switcher).
|
|
82
|
+
// SSR-safe: always initialises to 'en-US' so server and client agree on the first render,
|
|
83
|
+
// avoiding hydration mismatches. The real locale is read inside useEffect,
|
|
84
|
+
// which does not run on the server.
|
|
85
|
+
const useArkLocale = () => {
|
|
86
|
+
const [locale, setLocale] = useState('en-US');
|
|
87
|
+
useEffect(() => {
|
|
88
|
+
setLocale(getArkLocale());
|
|
89
|
+
const observer = new MutationObserver(() => setLocale(getArkLocale()));
|
|
90
|
+
observer.observe(document.documentElement, {
|
|
91
|
+
attributes: true,
|
|
92
|
+
attributeFilter: ['dir', 'lang']
|
|
93
|
+
});
|
|
94
|
+
return () => observer.disconnect();
|
|
95
|
+
}, []);
|
|
96
|
+
return locale;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* BpkProvider - Provides context for Backpack layout and Ark-based components.
|
|
101
|
+
*
|
|
102
|
+
* Wraps children with:
|
|
103
|
+
* - Chakra UI system context (for layout components: BpkFlex, BpkGrid, etc.)
|
|
104
|
+
* - Ark UI LocaleProvider (for Ark-based components: BpkCheckboxV2, BpkSegmentedControlV2, etc.)
|
|
105
|
+
*
|
|
106
|
+
* RTL support: reads document direction reactively via MutationObserver and passes
|
|
107
|
+
* the appropriate locale to Ark's LocaleProvider. All Ark-based components in the
|
|
108
|
+
* tree render correctly in RTL without requiring additional wrapping or prop changes.
|
|
28
109
|
*
|
|
29
110
|
* @param {BpkProviderProps} props - The provider props.
|
|
30
|
-
* @returns {
|
|
111
|
+
* @returns {JSX.Element} The provider wrapping its children with Chakra and Ark context.
|
|
31
112
|
*/
|
|
32
113
|
export const BpkProvider = ({
|
|
33
114
|
children
|
|
34
|
-
}) =>
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
115
|
+
}) => {
|
|
116
|
+
const locale = useArkLocale();
|
|
117
|
+
return /*#__PURE__*/_jsx(ChakraProvider, {
|
|
118
|
+
value: bpkSystem,
|
|
119
|
+
children: /*#__PURE__*/_jsx(LocaleProvider, {
|
|
120
|
+
locale: locale,
|
|
121
|
+
children: children
|
|
122
|
+
})
|
|
123
|
+
});
|
|
124
|
+
};
|
|
@@ -16,8 +16,7 @@
|
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
//
|
|
20
|
-
//
|
|
21
|
-
// names (alignItems, justifyContent, flexWrap, flexDirection) internally.
|
|
19
|
+
// these options align with Chakra's StackOption excluding separator
|
|
20
|
+
// TODO: add separator to Stack
|
|
22
21
|
const StackOptionKeys = ['align', 'justify', 'wrap', 'direction'];
|
|
23
22
|
export default StackOptionKeys;
|
|
@@ -17,127 +17,78 @@
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
import { forwardRef } from 'react';
|
|
20
|
+
import { Stack, VStack, HStack } from '@chakra-ui/react';
|
|
20
21
|
import { cssModules, getDataComponentAttribute } from "../../bpk-react-utils";
|
|
21
|
-
import { buildLayoutOutput } from "./responsiveStyleBuilder";
|
|
22
22
|
import { processBpkComponentProps } from "./tokenUtils";
|
|
23
|
-
import useCurrentBreakpoint from "./useCurrentBreakpoint";
|
|
24
23
|
import STYLES from "./BpkLayout.module.css";
|
|
25
24
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
26
25
|
const getClassName = cssModules(STYLES);
|
|
27
26
|
export const BpkStack = /*#__PURE__*/forwardRef(({
|
|
28
|
-
align,
|
|
29
27
|
backgroundColor,
|
|
30
28
|
children,
|
|
31
29
|
color,
|
|
32
|
-
direction,
|
|
33
|
-
justify,
|
|
34
|
-
wrap,
|
|
35
30
|
...props
|
|
36
31
|
}, ref) => {
|
|
37
|
-
const currentBreakpoint = useCurrentBreakpoint();
|
|
38
32
|
const processedProps = processBpkComponentProps(props, {
|
|
39
|
-
component: 'BpkStack'
|
|
40
|
-
responsiveProps: {
|
|
41
|
-
alignItems: align,
|
|
42
|
-
justifyContent: justify,
|
|
43
|
-
flexWrap: wrap,
|
|
44
|
-
flexDirection: direction
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
const {
|
|
48
|
-
passthrough,
|
|
49
|
-
style
|
|
50
|
-
} = buildLayoutOutput(processedProps, currentBreakpoint);
|
|
51
|
-
|
|
52
|
-
// Default: flex + column
|
|
53
|
-
if (!style.display) style.display = 'flex';
|
|
54
|
-
if (!style.flexDirection) style.flexDirection = 'column';
|
|
55
|
-
const className = color || backgroundColor ? getClassName('bpk-layout', color ? `bpk-layout--${color}` : '', backgroundColor ? `bpk-layout--${backgroundColor}` : '') : undefined;
|
|
56
|
-
return /*#__PURE__*/_jsx("div", {
|
|
57
|
-
ref: ref,
|
|
58
|
-
className: className,
|
|
59
|
-
style: style,
|
|
60
|
-
...getDataComponentAttribute('Stack'),
|
|
61
|
-
...passthrough,
|
|
62
|
-
children: children
|
|
33
|
+
component: 'BpkStack'
|
|
63
34
|
});
|
|
35
|
+
const classNames = color || backgroundColor ? getClassName('bpk-layout', color ? `bpk-layout--${color}` : '', backgroundColor ? `bpk-layout--${backgroundColor}` : '') : undefined;
|
|
36
|
+
return (
|
|
37
|
+
/*#__PURE__*/
|
|
38
|
+
// eslint-disable-next-line @skyscanner/rules/forbid-component-props
|
|
39
|
+
_jsx(Stack, {
|
|
40
|
+
ref: ref,
|
|
41
|
+
className: classNames,
|
|
42
|
+
...getDataComponentAttribute('Stack'),
|
|
43
|
+
...processedProps,
|
|
44
|
+
children: children
|
|
45
|
+
})
|
|
46
|
+
);
|
|
64
47
|
});
|
|
65
48
|
BpkStack.displayName = 'BpkStack';
|
|
66
49
|
export const BpkHStack = /*#__PURE__*/forwardRef(({
|
|
67
|
-
align = 'center',
|
|
68
50
|
backgroundColor,
|
|
69
51
|
children,
|
|
70
52
|
color,
|
|
71
|
-
direction = 'row',
|
|
72
|
-
justify,
|
|
73
|
-
wrap,
|
|
74
53
|
...props
|
|
75
54
|
}, ref) => {
|
|
76
|
-
const currentBreakpoint = useCurrentBreakpoint();
|
|
77
55
|
const processedProps = processBpkComponentProps(props, {
|
|
78
|
-
component: 'BpkStack'
|
|
79
|
-
responsiveProps: {
|
|
80
|
-
alignItems: align,
|
|
81
|
-
justifyContent: justify,
|
|
82
|
-
flexWrap: wrap,
|
|
83
|
-
flexDirection: direction
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
const {
|
|
87
|
-
passthrough,
|
|
88
|
-
style
|
|
89
|
-
} = buildLayoutOutput(processedProps, currentBreakpoint);
|
|
90
|
-
|
|
91
|
-
// Default: flex + row
|
|
92
|
-
if (!style.display) style.display = 'flex';
|
|
93
|
-
if (!style.flexDirection) style.flexDirection = 'row';
|
|
94
|
-
const className = color || backgroundColor ? getClassName('bpk-layout', color ? `bpk-layout--${color}` : '', backgroundColor ? `bpk-layout--${backgroundColor}` : '') : undefined;
|
|
95
|
-
return /*#__PURE__*/_jsx("div", {
|
|
96
|
-
ref: ref,
|
|
97
|
-
className: className,
|
|
98
|
-
style: style,
|
|
99
|
-
...getDataComponentAttribute('HStack'),
|
|
100
|
-
...passthrough,
|
|
101
|
-
children: children
|
|
56
|
+
component: 'BpkStack'
|
|
102
57
|
});
|
|
58
|
+
const classNames = color || backgroundColor ? getClassName('bpk-layout', color ? `bpk-layout--${color}` : '', backgroundColor ? `bpk-layout--${backgroundColor}` : '') : undefined;
|
|
59
|
+
return (
|
|
60
|
+
/*#__PURE__*/
|
|
61
|
+
// eslint-disable-next-line @skyscanner/rules/forbid-component-props
|
|
62
|
+
_jsx(HStack, {
|
|
63
|
+
ref: ref,
|
|
64
|
+
className: classNames,
|
|
65
|
+
...getDataComponentAttribute('HStack'),
|
|
66
|
+
...processedProps,
|
|
67
|
+
children: children
|
|
68
|
+
})
|
|
69
|
+
);
|
|
103
70
|
});
|
|
104
71
|
BpkHStack.displayName = 'BpkHStack';
|
|
105
72
|
export const BpkVStack = /*#__PURE__*/forwardRef(({
|
|
106
|
-
align = 'center',
|
|
107
73
|
backgroundColor,
|
|
108
74
|
children,
|
|
109
75
|
color,
|
|
110
|
-
direction = 'column',
|
|
111
|
-
justify,
|
|
112
|
-
wrap,
|
|
113
76
|
...props
|
|
114
77
|
}, ref) => {
|
|
115
|
-
const currentBreakpoint = useCurrentBreakpoint();
|
|
116
78
|
const processedProps = processBpkComponentProps(props, {
|
|
117
|
-
component: 'BpkStack'
|
|
118
|
-
responsiveProps: {
|
|
119
|
-
alignItems: align,
|
|
120
|
-
justifyContent: justify,
|
|
121
|
-
flexWrap: wrap,
|
|
122
|
-
flexDirection: direction
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
const {
|
|
126
|
-
passthrough,
|
|
127
|
-
style
|
|
128
|
-
} = buildLayoutOutput(processedProps, currentBreakpoint);
|
|
129
|
-
|
|
130
|
-
// Default: flex + column
|
|
131
|
-
if (!style.display) style.display = 'flex';
|
|
132
|
-
if (!style.flexDirection) style.flexDirection = 'column';
|
|
133
|
-
const className = color || backgroundColor ? getClassName('bpk-layout', color ? `bpk-layout--${color}` : '', backgroundColor ? `bpk-layout--${backgroundColor}` : '') : undefined;
|
|
134
|
-
return /*#__PURE__*/_jsx("div", {
|
|
135
|
-
ref: ref,
|
|
136
|
-
className: className,
|
|
137
|
-
style: style,
|
|
138
|
-
...getDataComponentAttribute('VStack'),
|
|
139
|
-
...passthrough,
|
|
140
|
-
children: children
|
|
79
|
+
component: 'BpkStack'
|
|
141
80
|
});
|
|
81
|
+
const classNames = color || backgroundColor ? getClassName('bpk-layout', color ? `bpk-layout--${color}` : '', backgroundColor ? `bpk-layout--${backgroundColor}` : '') : undefined;
|
|
82
|
+
return (
|
|
83
|
+
/*#__PURE__*/
|
|
84
|
+
// eslint-disable-next-line @skyscanner/rules/forbid-component-props
|
|
85
|
+
_jsx(VStack, {
|
|
86
|
+
ref: ref,
|
|
87
|
+
className: classNames,
|
|
88
|
+
...getDataComponentAttribute('VStack'),
|
|
89
|
+
...processedProps,
|
|
90
|
+
children: children
|
|
91
|
+
})
|
|
92
|
+
);
|
|
142
93
|
});
|
|
143
94
|
BpkVStack.displayName = 'BpkVStack';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AriaAttributes, AriaRole,
|
|
1
|
+
import type { AriaAttributes, AriaRole, 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';
|
|
@@ -90,13 +90,6 @@ export interface BpkCommonLayoutProps extends BpkSpacingProps, AriaAttributes {
|
|
|
90
90
|
borderBlock?: never;
|
|
91
91
|
borderX?: never;
|
|
92
92
|
borderY?: never;
|
|
93
|
-
textAlign?: BpkResponsiveValue<CSSProperties['textAlign']>;
|
|
94
|
-
whiteSpace?: CSSProperties['whiteSpace'];
|
|
95
|
-
cursor?: CSSProperties['cursor'];
|
|
96
|
-
opacity?: CSSProperties['opacity'];
|
|
97
|
-
visibility?: CSSProperties['visibility'];
|
|
98
|
-
pointerEvents?: CSSProperties['pointerEvents'];
|
|
99
|
-
userSelect?: CSSProperties['userSelect'];
|
|
100
93
|
transition?: never;
|
|
101
94
|
transitionProperty?: never;
|
|
102
95
|
transitionDuration?: never;
|
|
@@ -33,3 +33,4 @@ export declare function getBorderRadiusValue(token: string): string | undefined;
|
|
|
33
33
|
* @returns {string | undefined} The actual box-shadow value.
|
|
34
34
|
*/
|
|
35
35
|
export declare function getShadowValue(token: string): string | undefined;
|
|
36
|
+
export declare function createBpkConfig(): import("@chakra-ui/react").SystemConfig;
|