@skyscanner/backpack-web 42.10.0-dev-v24445021679.1 → 42.10.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.
Files changed (36) hide show
  1. package/bpk-component-ai-blurb/src/BpkAiBlurb.module.css +1 -1
  2. package/bpk-component-ai-blurb/src/BpkAiBlurbFeedback.js +21 -13
  3. package/bpk-component-chatbot-input/index.d.ts +2 -1
  4. package/bpk-component-chatbot-input/src/BpkChatbotInput.d.ts +3 -13
  5. package/bpk-component-chatbot-input/src/BpkChatbotInput.js +98 -18
  6. package/bpk-component-chatbot-input/src/BpkChatbotInput.module.css +1 -1
  7. package/bpk-component-chatbot-input/src/SendButton/SendButton.d.ts +9 -0
  8. package/bpk-component-chatbot-input/src/SendButton/SendButton.js +47 -0
  9. package/bpk-component-chatbot-input/src/TextAreaField/TextAreaField.d.ts +0 -1
  10. package/bpk-component-chatbot-input/src/TextAreaField/TextAreaField.js +1 -5
  11. package/bpk-component-chatbot-input/src/common-types.d.ts +3 -23
  12. package/bpk-component-chatbot-input/src/hooks/useChatbotInput.d.ts +1 -2
  13. package/bpk-component-chatbot-input/src/hooks/useChatbotInput.js +1 -3
  14. package/bpk-component-chatbot-input/src/hooks/useTextAreaAutoResize.d.ts +1 -2
  15. package/bpk-component-chatbot-input/src/hooks/useTextAreaAutoResize.js +6 -19
  16. package/bpk-component-layout/index.d.ts +0 -4
  17. package/bpk-component-layout/index.js +0 -2
  18. package/bpk-component-layout/src/BpkProvider.d.ts +7 -6
  19. package/bpk-component-layout/src/BpkProvider.js +96 -13
  20. package/bpk-component-layout/src/theme.js +252 -29
  21. package/bpk-component-layout/src/tokenUtils.js +9 -31
  22. package/package.json +1 -1
  23. package/bpk-component-chatbot-input/src/BpkChatbotInputContext.d.ts +0 -9
  24. package/bpk-component-chatbot-input/src/BpkChatbotInputContext.js +0 -26
  25. package/bpk-component-chatbot-input/src/BpkChatbotInputInput.d.ts +0 -3
  26. package/bpk-component-chatbot-input/src/BpkChatbotInputInput.js +0 -125
  27. package/bpk-component-chatbot-input/src/BpkChatbotInputRoot.d.ts +0 -3
  28. package/bpk-component-chatbot-input/src/BpkChatbotInputRoot.js +0 -77
  29. package/bpk-component-chatbot-input/src/BpkChatbotInputToolbar.d.ts +0 -3
  30. package/bpk-component-chatbot-input/src/BpkChatbotInputToolbar.js +0 -33
  31. package/bpk-component-layout/src/BpkArkProvider.d.ts +0 -20
  32. package/bpk-component-layout/src/BpkArkProvider.js +0 -112
  33. package/bpk-component-layout/src/BpkLayoutProvider.d.ts +0 -19
  34. package/bpk-component-layout/src/BpkLayoutProvider.js +0 -50
  35. package/bpk-component-layout/src/resolveTextStyle.d.ts +0 -13
  36. package/bpk-component-layout/src/resolveTextStyle.js +0 -265
@@ -1,33 +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 { BpkHStack, BpkSpacing } from "../../bpk-component-layout";
20
- import { getDataComponentAttribute } from "../../bpk-react-utils";
21
- import { jsx as _jsx } from "react/jsx-runtime";
22
- const BpkChatbotInputToolbar = ({
23
- children,
24
- gap = BpkSpacing.Base,
25
- ...rest
26
- }) => /*#__PURE__*/_jsx(BpkHStack, {
27
- gap: gap,
28
- width: "100%",
29
- ...getDataComponentAttribute('ChatbotInput.Toolbar'),
30
- ...rest,
31
- children: children
32
- });
33
- export default BpkChatbotInputToolbar;
@@ -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,19 +0,0 @@
1
- import type { ReactNode } from 'react';
2
- export interface BpkLayoutProviderProps {
3
- children: ReactNode;
4
- }
5
- /**
6
- * BpkLayoutProvider - Provides context for Backpack layout components only.
7
- *
8
- * Wraps children with the Chakra UI system context configured with Backpack
9
- * tokens (spacing, breakpoints). This is the minimal provider needed by
10
- * layout primitives (BpkBox, BpkFlex, BpkGrid, BpkStack, etc.).
11
- *
12
- * Use this instead of BpkProvider when you only need layout components and
13
- * want to avoid bundling Ark UI (used by BpkCheckboxV2, BpkSegmentedControlV2,
14
- * and other Ark-based components).
15
- *
16
- * @param {BpkLayoutProviderProps} props - The provider props.
17
- * @returns {JSX.Element} The provider wrapping its children with Chakra context.
18
- */
19
- export declare const BpkLayoutProvider: ({ children, }: BpkLayoutProviderProps) => JSX.Element;
@@ -1,50 +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 { ChakraProvider, createSystem, defaultBaseConfig } from '@chakra-ui/react';
20
- import { createBpkConfig } from "./theme";
21
- import { jsx as _jsx } from "react/jsx-runtime";
22
- /**
23
- * Creates a Chakra UI system with Backpack token mappings.
24
- *
25
- * Uses `defaultBaseConfig` (conditions + utilities only) instead of
26
- * `defaultConfig` to avoid bundling ~141KB of unused component recipes.
27
- * See: https://chakra-ui.com/guides/component-bundle-optimization
28
- */
29
- const bpkSystem = createSystem(defaultBaseConfig, createBpkConfig());
30
-
31
- /**
32
- * BpkLayoutProvider - Provides context for Backpack layout components only.
33
- *
34
- * Wraps children with the Chakra UI system context configured with Backpack
35
- * tokens (spacing, breakpoints). This is the minimal provider needed by
36
- * layout primitives (BpkBox, BpkFlex, BpkGrid, BpkStack, etc.).
37
- *
38
- * Use this instead of BpkProvider when you only need layout components and
39
- * want to avoid bundling Ark UI (used by BpkCheckboxV2, BpkSegmentedControlV2,
40
- * and other Ark-based components).
41
- *
42
- * @param {BpkLayoutProviderProps} props - The provider props.
43
- * @returns {JSX.Element} The provider wrapping its children with Chakra context.
44
- */
45
- export const BpkLayoutProvider = ({
46
- children
47
- }) => /*#__PURE__*/_jsx(ChakraProvider, {
48
- value: bpkSystem,
49
- children: children
50
- });
@@ -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>;
@@ -1,265 +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 only the specific tokens needed for text styles, rather than the
20
- // entire foundations module. This avoids pulling unused tokens (colors,
21
- // shadows, borders, etc.) into the layout bundle.
22
- import { fontSizeXs, fontSizeSm, fontSizeBase, fontSizeLg, fontSizeXl, fontSizeXxl, fontSizeXxxl, fontSizeXxxxl, fontSizeXxxxxl, fontSize6Xl, fontSize7Xl, fontSize8Xl, lineHeightXs, lineHeightSm, lineHeightBase, lineHeightBaseTight, lineHeightLg, lineHeightLgTight, lineHeightXl, lineHeightXlTight, lineHeightXxl, lineHeightXxxl, lineHeightXxxxl, lineHeightXxxxxl, lineHeight6Xl, lineHeight7Xl, lineHeight8Xl, fontWeightBook, fontWeightBold, fontWeightBlack, fontWeightLight, letterSpacingTight, letterSpacingHero, fontFamilyLarken } from '@skyscanner/bpk-foundations-web/tokens/base.es6';
23
- import { BpkBreakpointToChakraKey } from "./tokens";
24
- /**
25
- * Maps Backpack text style tokens to concrete CSS properties.
26
- *
27
- * This map is intentionally kept outside the Chakra theme config so that
28
- * layout-only consumers (who never use textStyle) do not pay for it.
29
- * Components that use textStyle expand it inline via `expandTextStyleProps`.
30
- */
31
- const TEXT_STYLE_MAP = {
32
- xs: {
33
- fontSize: fontSizeXs,
34
- lineHeight: lineHeightXs,
35
- fontWeight: fontWeightBook
36
- },
37
- sm: {
38
- fontSize: fontSizeSm,
39
- lineHeight: lineHeightSm,
40
- fontWeight: fontWeightBook
41
- },
42
- base: {
43
- fontSize: fontSizeBase,
44
- lineHeight: lineHeightBase,
45
- fontWeight: fontWeightBook
46
- },
47
- lg: {
48
- fontSize: fontSizeLg,
49
- lineHeight: lineHeightLg,
50
- fontWeight: fontWeightBook
51
- },
52
- xl: {
53
- fontSize: fontSizeXl,
54
- lineHeight: lineHeightXl,
55
- fontWeight: fontWeightBook
56
- },
57
- xxl: {
58
- fontSize: fontSizeXxl,
59
- lineHeight: lineHeightXxl,
60
- fontWeight: fontWeightBold
61
- },
62
- xxxl: {
63
- fontSize: fontSizeXxxl,
64
- lineHeight: lineHeightXxxl,
65
- fontWeight: fontWeightBold
66
- },
67
- xxxxl: {
68
- fontSize: fontSizeXxxxl,
69
- lineHeight: lineHeightXxxxl,
70
- fontWeight: fontWeightBold,
71
- letterSpacing: letterSpacingTight
72
- },
73
- xxxxxl: {
74
- fontSize: fontSizeXxxxxl,
75
- lineHeight: lineHeightXxxxxl,
76
- fontWeight: fontWeightBold,
77
- letterSpacing: letterSpacingTight
78
- },
79
- caption: {
80
- fontSize: fontSizeXs,
81
- lineHeight: lineHeightXs,
82
- fontWeight: fontWeightBook
83
- },
84
- footnote: {
85
- fontSize: fontSizeSm,
86
- lineHeight: lineHeightSm,
87
- fontWeight: fontWeightBook
88
- },
89
- 'label-1': {
90
- fontSize: fontSizeBase,
91
- lineHeight: lineHeightBase,
92
- fontWeight: fontWeightBold
93
- },
94
- 'label-2': {
95
- fontSize: fontSizeSm,
96
- lineHeight: lineHeightSm,
97
- fontWeight: fontWeightBold
98
- },
99
- 'label-3': {
100
- fontSize: fontSizeXs,
101
- lineHeight: lineHeightXs,
102
- fontWeight: fontWeightBold
103
- },
104
- 'body-default': {
105
- fontSize: fontSizeBase,
106
- lineHeight: lineHeightBase,
107
- fontWeight: fontWeightBook
108
- },
109
- 'body-longform': {
110
- fontSize: fontSizeLg,
111
- lineHeight: lineHeightLg,
112
- fontWeight: fontWeightBook
113
- },
114
- subheading: {
115
- fontSize: fontSizeXl,
116
- lineHeight: lineHeightXl,
117
- fontWeight: fontWeightBook
118
- },
119
- 'heading-1': {
120
- fontSize: fontSizeXxxl,
121
- lineHeight: lineHeightXxxl,
122
- fontWeight: fontWeightBold
123
- },
124
- 'heading-2': {
125
- fontSize: fontSizeXxl,
126
- lineHeight: lineHeightXxl,
127
- fontWeight: fontWeightBold
128
- },
129
- 'heading-3': {
130
- fontSize: fontSizeXl,
131
- lineHeight: lineHeightXlTight,
132
- fontWeight: fontWeightBold
133
- },
134
- 'heading-4': {
135
- fontSize: fontSizeLg,
136
- lineHeight: lineHeightLgTight,
137
- fontWeight: fontWeightBold
138
- },
139
- 'heading-5': {
140
- fontSize: fontSizeBase,
141
- lineHeight: lineHeightBaseTight,
142
- fontWeight: fontWeightBold
143
- },
144
- 'hero-1': {
145
- fontSize: fontSize8Xl,
146
- lineHeight: lineHeight8Xl,
147
- fontWeight: fontWeightBlack,
148
- letterSpacing: letterSpacingHero
149
- },
150
- 'hero-2': {
151
- fontSize: fontSize7Xl,
152
- lineHeight: lineHeight7Xl,
153
- fontWeight: fontWeightBlack,
154
- letterSpacing: letterSpacingHero
155
- },
156
- 'hero-3': {
157
- fontSize: fontSize6Xl,
158
- lineHeight: lineHeight6Xl,
159
- fontWeight: fontWeightBlack,
160
- letterSpacing: letterSpacingHero
161
- },
162
- 'hero-4': {
163
- fontSize: fontSizeXxxxxl,
164
- lineHeight: lineHeightXxxxxl,
165
- fontWeight: fontWeightBlack,
166
- letterSpacing: letterSpacingHero
167
- },
168
- 'hero-5': {
169
- fontSize: fontSizeXxxxl,
170
- lineHeight: lineHeightXxxl,
171
- fontWeight: fontWeightBlack,
172
- letterSpacing: letterSpacingHero
173
- },
174
- 'hero-6': {
175
- fontSize: fontSizeXxxl,
176
- lineHeight: lineHeightXxl,
177
- fontWeight: fontWeightBlack,
178
- letterSpacing: letterSpacingHero
179
- },
180
- 'editorial-1': {
181
- fontFamily: `var(--bpk-larken-font-stack, ${fontFamilyLarken})`,
182
- fontSize: fontSizeXxxxl,
183
- lineHeight: lineHeightXxxxl,
184
- fontWeight: fontWeightLight
185
- },
186
- 'editorial-2': {
187
- fontFamily: `var(--bpk-larken-font-stack, ${fontFamilyLarken})`,
188
- fontSize: fontSizeXxl,
189
- lineHeight: lineHeightXxl,
190
- fontWeight: fontWeightLight
191
- },
192
- 'editorial-3': {
193
- fontFamily: `var(--bpk-larken-font-stack, ${fontFamilyLarken})`,
194
- fontSize: fontSizeLg,
195
- lineHeight: lineHeightLg,
196
- fontWeight: fontWeightBook
197
- }
198
- };
199
-
200
- /**
201
- * Expands a textStyle token (or responsive object of tokens) into concrete
202
- * CSS property values that can be spread directly onto a Chakra component.
203
- *
204
- * Supports:
205
- * - Static values: `textStyle="heading-3"` → `{ fontSize, lineHeight, fontWeight }`
206
- * - Responsive objects: `textStyle={{ mobile: 'heading-5', desktop: 'heading-3' }}`
207
- * → `{ fontSize: { md: '...', '2xl': '...' }, lineHeight: { ... }, ... }`
208
- *
209
- * @param {any} value - A textStyle token string, responsive object, or undefined/null.
210
- * @returns {Record<string, any>} An object of CSS props to spread, or an empty object if no match.
211
- */
212
- // eslint-disable-next-line import/prefer-default-export
213
- export function expandTextStyleProps(value) {
214
- if (value == null) return {};
215
-
216
- // Responsive object: { mobile: 'heading-5', desktop: 'heading-3' }
217
- if (typeof value === 'object' && !Array.isArray(value)) {
218
- // Normalise Backpack breakpoint keys to Chakra keys inline (avoids
219
- // circular dependency on tokenUtils).
220
- const normalized = {};
221
- Object.entries(value).forEach(([key, val]) => {
222
- if (key === 'base') {
223
- normalized.base = val;
224
- } else {
225
- const chakraKey = BpkBreakpointToChakraKey[key];
226
- if (chakraKey) {
227
- normalized[chakraKey] = val;
228
- }
229
- }
230
- });
231
-
232
- // Pivot from { bp -> token } to { cssProp -> { bp -> cssValue } }
233
- const result = {};
234
- Object.entries(normalized).forEach(([bp, token]) => {
235
- const style = TEXT_STYLE_MAP[String(token)];
236
- if (!style) {
237
- if (process.env.NODE_ENV !== 'production') {
238
- // eslint-disable-next-line no-console
239
- console.warn(`Unknown textStyle token "${String(token)}" at breakpoint "${bp}".`);
240
- }
241
- return;
242
- }
243
- Object.entries(style).forEach(([cssProp, cssValue]) => {
244
- if (!result[cssProp]) {
245
- result[cssProp] = {};
246
- }
247
- result[cssProp][bp] = cssValue;
248
- });
249
- });
250
- return result;
251
- }
252
-
253
- // Static string value
254
- const style = TEXT_STYLE_MAP[String(value)];
255
- if (!style) {
256
- if (process.env.NODE_ENV !== 'production') {
257
- // eslint-disable-next-line no-console
258
- console.warn(`Unknown textStyle token "${String(value)}".`);
259
- }
260
- return {};
261
- }
262
- return {
263
- ...style
264
- };
265
- }