@skyscanner/backpack-web 42.24.0-dev-v27397479883.1 → 42.25.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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
2
|
export interface BpkProviderProps {
|
|
3
3
|
children: ReactNode;
|
|
4
4
|
}
|
|
@@ -14,6 +14,6 @@ export interface BpkProviderProps {
|
|
|
14
14
|
* tree render correctly in RTL without requiring additional wrapping or prop changes.
|
|
15
15
|
*
|
|
16
16
|
* @param {BpkProviderProps} props - The provider props.
|
|
17
|
-
* @returns {
|
|
17
|
+
* @returns {JSX.Element} The provider wrapping its children with Chakra and Ark context.
|
|
18
18
|
*/
|
|
19
|
-
export declare const BpkProvider: ({ children }: BpkProviderProps) =>
|
|
19
|
+
export declare const BpkProvider: ({ children }: BpkProviderProps) => JSX.Element;
|
|
@@ -19,8 +19,6 @@
|
|
|
19
19
|
import { useEffect, useState } from 'react';
|
|
20
20
|
import { LocaleProvider } from '@ark-ui/react';
|
|
21
21
|
import { ChakraProvider, createSystem, defaultBaseConfig } from '@chakra-ui/react';
|
|
22
|
-
import createCache from '@emotion/cache';
|
|
23
|
-
import { CacheProvider } from '@emotion/react';
|
|
24
22
|
import { createBpkConfig } from "./theme";
|
|
25
23
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
26
24
|
/**
|
|
@@ -31,9 +29,6 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
31
29
|
* See: https://chakra-ui.com/guides/component-bundle-optimization
|
|
32
30
|
*/
|
|
33
31
|
const bpkSystem = createSystem(defaultBaseConfig, createBpkConfig());
|
|
34
|
-
const createBpkEmotionCache = () => createCache({
|
|
35
|
-
key: 'bpk'
|
|
36
|
-
});
|
|
37
32
|
// Fallback locale mapping used when no explicit locale is available on the document.
|
|
38
33
|
// Maps DOM direction to minimal BCP 47 locales understood by Ark's isRTL() utility.
|
|
39
34
|
// 'ar-SA' is the minimal RTL locale — Ark only uses it to derive dir='rtl'.
|
|
@@ -78,7 +73,15 @@ const getArkLocale = () => {
|
|
|
78
73
|
if (lang && getLangDir(lang) === explicitDir) return lang;
|
|
79
74
|
return FALLBACK_LOCALE_BY_DIRECTION[explicitDir];
|
|
80
75
|
}
|
|
81
|
-
|
|
76
|
+
if (lang) {
|
|
77
|
+
try {
|
|
78
|
+
const locale = new Intl.Locale(lang);
|
|
79
|
+
if (locale) return lang;
|
|
80
|
+
} catch {
|
|
81
|
+
// Invalid locale string — fall through to default
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return 'en-US';
|
|
82
85
|
};
|
|
83
86
|
|
|
84
87
|
// Reactive hook: subscribes to document.documentElement[dir] and [lang] changes
|
|
@@ -113,23 +116,17 @@ const useArkLocale = () => {
|
|
|
113
116
|
* tree render correctly in RTL without requiring additional wrapping or prop changes.
|
|
114
117
|
*
|
|
115
118
|
* @param {BpkProviderProps} props - The provider props.
|
|
116
|
-
* @returns {
|
|
119
|
+
* @returns {JSX.Element} The provider wrapping its children with Chakra and Ark context.
|
|
117
120
|
*/
|
|
118
121
|
export const BpkProvider = ({
|
|
119
122
|
children
|
|
120
123
|
}) => {
|
|
121
|
-
// Initialise Emotion before Chakra's inner cache so legacy hydrate consumers
|
|
122
|
-
// do not bail on SSR className mismatches.
|
|
123
|
-
const [cache] = useState(createBpkEmotionCache);
|
|
124
124
|
const locale = useArkLocale();
|
|
125
|
-
return /*#__PURE__*/_jsx(
|
|
126
|
-
value:
|
|
127
|
-
children: /*#__PURE__*/_jsx(
|
|
128
|
-
|
|
129
|
-
children:
|
|
130
|
-
locale: locale,
|
|
131
|
-
children: children
|
|
132
|
-
})
|
|
125
|
+
return /*#__PURE__*/_jsx(ChakraProvider, {
|
|
126
|
+
value: bpkSystem,
|
|
127
|
+
children: /*#__PURE__*/_jsx(LocaleProvider, {
|
|
128
|
+
locale: locale,
|
|
129
|
+
children: children
|
|
133
130
|
})
|
|
134
131
|
});
|
|
135
132
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skyscanner/backpack-web",
|
|
3
|
-
"version": "42.
|
|
3
|
+
"version": "42.25.0",
|
|
4
4
|
"description": "Backpack Design System web library",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -24,8 +24,6 @@
|
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@ark-ui/react": "^5.34.1",
|
|
26
26
|
"@chakra-ui/react": "^3.33.0",
|
|
27
|
-
"@emotion/cache": "^11.14.0",
|
|
28
|
-
"@emotion/react": "^11.14.0",
|
|
29
27
|
"@floating-ui/react": "^0.26.12",
|
|
30
28
|
"@radix-ui/react-compose-refs": "^1.1.1",
|
|
31
29
|
"@radix-ui/react-slider": "1.3.5",
|