@skyscanner/backpack-web 42.10.0-dev-v24443725500.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.
- package/bpk-component-ai-blurb/src/BpkAiBlurb.module.css +1 -1
- package/bpk-component-ai-blurb/src/BpkAiBlurbFeedback.js +21 -13
- package/bpk-component-chatbot-input/index.d.ts +2 -1
- package/bpk-component-chatbot-input/src/BpkChatbotInput.d.ts +3 -13
- package/bpk-component-chatbot-input/src/BpkChatbotInput.js +98 -18
- package/bpk-component-chatbot-input/src/BpkChatbotInput.module.css +1 -1
- package/bpk-component-chatbot-input/src/SendButton/SendButton.d.ts +9 -0
- package/bpk-component-chatbot-input/src/SendButton/SendButton.js +47 -0
- package/bpk-component-chatbot-input/src/TextAreaField/TextAreaField.d.ts +0 -1
- package/bpk-component-chatbot-input/src/TextAreaField/TextAreaField.js +1 -5
- package/bpk-component-chatbot-input/src/common-types.d.ts +3 -23
- package/bpk-component-chatbot-input/src/hooks/useChatbotInput.d.ts +1 -2
- package/bpk-component-chatbot-input/src/hooks/useChatbotInput.js +1 -3
- package/bpk-component-chatbot-input/src/hooks/useTextAreaAutoResize.d.ts +1 -2
- package/bpk-component-chatbot-input/src/hooks/useTextAreaAutoResize.js +6 -19
- package/bpk-component-layout/src/theme.js +252 -29
- package/bpk-component-layout/src/tokenUtils.js +9 -31
- package/package.json +1 -1
- package/bpk-component-chatbot-input/src/BpkChatbotInputContext.d.ts +0 -9
- package/bpk-component-chatbot-input/src/BpkChatbotInputContext.js +0 -26
- package/bpk-component-chatbot-input/src/BpkChatbotInputInput.d.ts +0 -3
- package/bpk-component-chatbot-input/src/BpkChatbotInputInput.js +0 -125
- package/bpk-component-chatbot-input/src/BpkChatbotInputRoot.d.ts +0 -3
- package/bpk-component-chatbot-input/src/BpkChatbotInputRoot.js +0 -77
- package/bpk-component-chatbot-input/src/BpkChatbotInputToolbar.d.ts +0 -3
- package/bpk-component-chatbot-input/src/BpkChatbotInputToolbar.js +0 -33
- package/bpk-component-layout/src/resolveTextStyle.d.ts +0 -13
- package/bpk-component-layout/src/resolveTextStyle.js +0 -265
|
@@ -18,17 +18,9 @@
|
|
|
18
18
|
|
|
19
19
|
import { defineConfig } from '@chakra-ui/react';
|
|
20
20
|
|
|
21
|
-
// Import
|
|
22
|
-
//
|
|
23
|
-
|
|
24
|
-
// Chakra theme config.
|
|
25
|
-
import {
|
|
26
|
-
// Border sizes
|
|
27
|
-
borderSizeSm, borderSizeLg, borderSizeXl,
|
|
28
|
-
// Border radii
|
|
29
|
-
borderRadiusXs, borderRadiusSm, borderRadiusMd, borderRadiusLg, borderRadiusXl, borderRadiusFull,
|
|
30
|
-
// Box shadows
|
|
31
|
-
boxShadowSm, boxShadowLg, boxShadowXl } from '@skyscanner/bpk-foundations-web/tokens/base.es6';
|
|
21
|
+
// Import tokens from Backpack foundations
|
|
22
|
+
// Note: Some tokens may not be in TypeScript definitions but exist at runtime
|
|
23
|
+
import * as bpkTokens from '@skyscanner/bpk-foundations-web/tokens/base.es6';
|
|
32
24
|
// NOTE:
|
|
33
25
|
// We intentionally do not use the raw breakpoint *values* from foundations here.
|
|
34
26
|
// Foundations exports breakpoint values such as `breakpointMobile = "32rem"` which
|
|
@@ -108,9 +100,9 @@ const spacingMap = {
|
|
|
108
100
|
* These come directly from @skyscanner/bpk-foundations-web
|
|
109
101
|
*/
|
|
110
102
|
const borderSizeMap = {
|
|
111
|
-
'bpk-border-size-sm': borderSizeSm,
|
|
112
|
-
'bpk-border-size-lg': borderSizeLg,
|
|
113
|
-
'bpk-border-size-xl': borderSizeXl
|
|
103
|
+
'bpk-border-size-sm': bpkTokens.borderSizeSm,
|
|
104
|
+
'bpk-border-size-lg': bpkTokens.borderSizeLg,
|
|
105
|
+
'bpk-border-size-xl': bpkTokens.borderSizeXl
|
|
114
106
|
};
|
|
115
107
|
|
|
116
108
|
/**
|
|
@@ -119,12 +111,12 @@ const borderSizeMap = {
|
|
|
119
111
|
*/
|
|
120
112
|
const borderRadiusMap = {
|
|
121
113
|
'bpk-border-radius-none': '0',
|
|
122
|
-
'bpk-border-radius-xs': borderRadiusXs,
|
|
123
|
-
'bpk-border-radius-sm': borderRadiusSm,
|
|
124
|
-
'bpk-border-radius-md': borderRadiusMd,
|
|
125
|
-
'bpk-border-radius-lg': borderRadiusLg,
|
|
126
|
-
'bpk-border-radius-xl': borderRadiusXl,
|
|
127
|
-
'bpk-border-radius-full': borderRadiusFull
|
|
114
|
+
'bpk-border-radius-xs': bpkTokens.borderRadiusXs,
|
|
115
|
+
'bpk-border-radius-sm': bpkTokens.borderRadiusSm,
|
|
116
|
+
'bpk-border-radius-md': bpkTokens.borderRadiusMd,
|
|
117
|
+
'bpk-border-radius-lg': bpkTokens.borderRadiusLg,
|
|
118
|
+
'bpk-border-radius-xl': bpkTokens.borderRadiusXl,
|
|
119
|
+
'bpk-border-radius-full': bpkTokens.borderRadiusFull
|
|
128
120
|
};
|
|
129
121
|
|
|
130
122
|
/**
|
|
@@ -132,9 +124,9 @@ const borderRadiusMap = {
|
|
|
132
124
|
* These come directly from @skyscanner/bpk-foundations-web
|
|
133
125
|
*/
|
|
134
126
|
const shadowMap = {
|
|
135
|
-
'bpk-shadow-sm': boxShadowSm,
|
|
136
|
-
'bpk-shadow-lg': boxShadowLg,
|
|
137
|
-
'bpk-shadow-xl': boxShadowXl
|
|
127
|
+
'bpk-shadow-sm': bpkTokens.boxShadowSm,
|
|
128
|
+
'bpk-shadow-lg': bpkTokens.boxShadowLg,
|
|
129
|
+
'bpk-shadow-xl': bpkTokens.boxShadowXl
|
|
138
130
|
};
|
|
139
131
|
|
|
140
132
|
/**
|
|
@@ -217,6 +209,242 @@ export function getBorderRadiusValue(token) {
|
|
|
217
209
|
export function getShadowValue(token) {
|
|
218
210
|
return shadowMap[token];
|
|
219
211
|
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Maps Backpack text style tokens to Chakra UI textStyles.
|
|
215
|
+
* CSS property values are sourced from @skyscanner/bpk-foundations-web/tokens/base.es6.
|
|
216
|
+
* Each entry mirrors the corresponding SCSS mixin in bpk-mixins/_typography.scss.
|
|
217
|
+
*/
|
|
218
|
+
const textStylesMap = {
|
|
219
|
+
xs: {
|
|
220
|
+
value: {
|
|
221
|
+
fontSize: bpkTokens.fontSizeXs,
|
|
222
|
+
lineHeight: bpkTokens.lineHeightXs,
|
|
223
|
+
fontWeight: bpkTokens.fontWeightBook
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
sm: {
|
|
227
|
+
value: {
|
|
228
|
+
fontSize: bpkTokens.fontSizeSm,
|
|
229
|
+
lineHeight: bpkTokens.lineHeightSm,
|
|
230
|
+
fontWeight: bpkTokens.fontWeightBook
|
|
231
|
+
}
|
|
232
|
+
},
|
|
233
|
+
base: {
|
|
234
|
+
value: {
|
|
235
|
+
fontSize: bpkTokens.fontSizeBase,
|
|
236
|
+
lineHeight: bpkTokens.lineHeightBase,
|
|
237
|
+
fontWeight: bpkTokens.fontWeightBook
|
|
238
|
+
}
|
|
239
|
+
},
|
|
240
|
+
lg: {
|
|
241
|
+
value: {
|
|
242
|
+
fontSize: bpkTokens.fontSizeLg,
|
|
243
|
+
lineHeight: bpkTokens.lineHeightLg,
|
|
244
|
+
fontWeight: bpkTokens.fontWeightBook
|
|
245
|
+
}
|
|
246
|
+
},
|
|
247
|
+
xl: {
|
|
248
|
+
value: {
|
|
249
|
+
fontSize: bpkTokens.fontSizeXl,
|
|
250
|
+
lineHeight: bpkTokens.lineHeightXl,
|
|
251
|
+
fontWeight: bpkTokens.fontWeightBook
|
|
252
|
+
}
|
|
253
|
+
},
|
|
254
|
+
xxl: {
|
|
255
|
+
value: {
|
|
256
|
+
fontSize: bpkTokens.fontSizeXxl,
|
|
257
|
+
lineHeight: bpkTokens.lineHeightXxl,
|
|
258
|
+
fontWeight: bpkTokens.fontWeightBold
|
|
259
|
+
}
|
|
260
|
+
},
|
|
261
|
+
xxxl: {
|
|
262
|
+
value: {
|
|
263
|
+
fontSize: bpkTokens.fontSizeXxxl,
|
|
264
|
+
lineHeight: bpkTokens.lineHeightXxxl,
|
|
265
|
+
fontWeight: bpkTokens.fontWeightBold
|
|
266
|
+
}
|
|
267
|
+
},
|
|
268
|
+
xxxxl: {
|
|
269
|
+
value: {
|
|
270
|
+
fontSize: bpkTokens.fontSizeXxxxl,
|
|
271
|
+
lineHeight: bpkTokens.lineHeightXxxxl,
|
|
272
|
+
fontWeight: bpkTokens.fontWeightBold,
|
|
273
|
+
letterSpacing: bpkTokens.letterSpacingTight
|
|
274
|
+
}
|
|
275
|
+
},
|
|
276
|
+
xxxxxl: {
|
|
277
|
+
value: {
|
|
278
|
+
fontSize: bpkTokens.fontSizeXxxxxl,
|
|
279
|
+
lineHeight: bpkTokens.lineHeightXxxxxl,
|
|
280
|
+
fontWeight: bpkTokens.fontWeightBold,
|
|
281
|
+
letterSpacing: bpkTokens.letterSpacingTight
|
|
282
|
+
}
|
|
283
|
+
},
|
|
284
|
+
caption: {
|
|
285
|
+
value: {
|
|
286
|
+
fontSize: bpkTokens.fontSizeXs,
|
|
287
|
+
lineHeight: bpkTokens.lineHeightXs,
|
|
288
|
+
fontWeight: bpkTokens.fontWeightBook
|
|
289
|
+
}
|
|
290
|
+
},
|
|
291
|
+
footnote: {
|
|
292
|
+
value: {
|
|
293
|
+
fontSize: bpkTokens.fontSizeSm,
|
|
294
|
+
lineHeight: bpkTokens.lineHeightSm,
|
|
295
|
+
fontWeight: bpkTokens.fontWeightBook
|
|
296
|
+
}
|
|
297
|
+
},
|
|
298
|
+
'label-1': {
|
|
299
|
+
value: {
|
|
300
|
+
fontSize: bpkTokens.fontSizeBase,
|
|
301
|
+
lineHeight: bpkTokens.lineHeightBase,
|
|
302
|
+
fontWeight: bpkTokens.fontWeightBold
|
|
303
|
+
}
|
|
304
|
+
},
|
|
305
|
+
'label-2': {
|
|
306
|
+
value: {
|
|
307
|
+
fontSize: bpkTokens.fontSizeSm,
|
|
308
|
+
lineHeight: bpkTokens.lineHeightSm,
|
|
309
|
+
fontWeight: bpkTokens.fontWeightBold
|
|
310
|
+
}
|
|
311
|
+
},
|
|
312
|
+
'label-3': {
|
|
313
|
+
value: {
|
|
314
|
+
fontSize: bpkTokens.fontSizeXs,
|
|
315
|
+
lineHeight: bpkTokens.lineHeightXs,
|
|
316
|
+
fontWeight: bpkTokens.fontWeightBold
|
|
317
|
+
}
|
|
318
|
+
},
|
|
319
|
+
'body-default': {
|
|
320
|
+
value: {
|
|
321
|
+
fontSize: bpkTokens.fontSizeBase,
|
|
322
|
+
lineHeight: bpkTokens.lineHeightBase,
|
|
323
|
+
fontWeight: bpkTokens.fontWeightBook
|
|
324
|
+
}
|
|
325
|
+
},
|
|
326
|
+
'body-longform': {
|
|
327
|
+
value: {
|
|
328
|
+
fontSize: bpkTokens.fontSizeLg,
|
|
329
|
+
lineHeight: bpkTokens.lineHeightLg,
|
|
330
|
+
fontWeight: bpkTokens.fontWeightBook
|
|
331
|
+
}
|
|
332
|
+
},
|
|
333
|
+
subheading: {
|
|
334
|
+
value: {
|
|
335
|
+
fontSize: bpkTokens.fontSizeXl,
|
|
336
|
+
lineHeight: bpkTokens.lineHeightXl,
|
|
337
|
+
fontWeight: bpkTokens.fontWeightBook
|
|
338
|
+
}
|
|
339
|
+
},
|
|
340
|
+
'heading-1': {
|
|
341
|
+
value: {
|
|
342
|
+
fontSize: bpkTokens.fontSizeXxxl,
|
|
343
|
+
lineHeight: bpkTokens.lineHeightXxxl,
|
|
344
|
+
fontWeight: bpkTokens.fontWeightBold
|
|
345
|
+
}
|
|
346
|
+
},
|
|
347
|
+
'heading-2': {
|
|
348
|
+
value: {
|
|
349
|
+
fontSize: bpkTokens.fontSizeXxl,
|
|
350
|
+
lineHeight: bpkTokens.lineHeightXxl,
|
|
351
|
+
fontWeight: bpkTokens.fontWeightBold
|
|
352
|
+
}
|
|
353
|
+
},
|
|
354
|
+
'heading-3': {
|
|
355
|
+
value: {
|
|
356
|
+
fontSize: bpkTokens.fontSizeXl,
|
|
357
|
+
lineHeight: bpkTokens.lineHeightXlTight,
|
|
358
|
+
fontWeight: bpkTokens.fontWeightBold
|
|
359
|
+
}
|
|
360
|
+
},
|
|
361
|
+
'heading-4': {
|
|
362
|
+
value: {
|
|
363
|
+
fontSize: bpkTokens.fontSizeLg,
|
|
364
|
+
lineHeight: bpkTokens.lineHeightLgTight,
|
|
365
|
+
fontWeight: bpkTokens.fontWeightBold
|
|
366
|
+
}
|
|
367
|
+
},
|
|
368
|
+
'heading-5': {
|
|
369
|
+
value: {
|
|
370
|
+
fontSize: bpkTokens.fontSizeBase,
|
|
371
|
+
lineHeight: bpkTokens.lineHeightBaseTight,
|
|
372
|
+
fontWeight: bpkTokens.fontWeightBold
|
|
373
|
+
}
|
|
374
|
+
},
|
|
375
|
+
'hero-1': {
|
|
376
|
+
value: {
|
|
377
|
+
fontSize: bpkTokens.fontSize8Xl,
|
|
378
|
+
lineHeight: bpkTokens.lineHeight8Xl,
|
|
379
|
+
fontWeight: bpkTokens.fontWeightBlack,
|
|
380
|
+
letterSpacing: bpkTokens.letterSpacingHero
|
|
381
|
+
}
|
|
382
|
+
},
|
|
383
|
+
'hero-2': {
|
|
384
|
+
value: {
|
|
385
|
+
fontSize: bpkTokens.fontSize7Xl,
|
|
386
|
+
lineHeight: bpkTokens.lineHeight7Xl,
|
|
387
|
+
fontWeight: bpkTokens.fontWeightBlack,
|
|
388
|
+
letterSpacing: bpkTokens.letterSpacingHero
|
|
389
|
+
}
|
|
390
|
+
},
|
|
391
|
+
'hero-3': {
|
|
392
|
+
value: {
|
|
393
|
+
fontSize: bpkTokens.fontSize6Xl,
|
|
394
|
+
lineHeight: bpkTokens.lineHeight6Xl,
|
|
395
|
+
fontWeight: bpkTokens.fontWeightBlack,
|
|
396
|
+
letterSpacing: bpkTokens.letterSpacingHero
|
|
397
|
+
}
|
|
398
|
+
},
|
|
399
|
+
'hero-4': {
|
|
400
|
+
value: {
|
|
401
|
+
fontSize: bpkTokens.fontSizeXxxxxl,
|
|
402
|
+
lineHeight: bpkTokens.lineHeightXxxxxl,
|
|
403
|
+
fontWeight: bpkTokens.fontWeightBlack,
|
|
404
|
+
letterSpacing: bpkTokens.letterSpacingHero
|
|
405
|
+
}
|
|
406
|
+
},
|
|
407
|
+
'hero-5': {
|
|
408
|
+
value: {
|
|
409
|
+
fontSize: bpkTokens.fontSizeXxxxl,
|
|
410
|
+
lineHeight: bpkTokens.lineHeightXxxl,
|
|
411
|
+
fontWeight: bpkTokens.fontWeightBlack,
|
|
412
|
+
letterSpacing: bpkTokens.letterSpacingHero
|
|
413
|
+
}
|
|
414
|
+
},
|
|
415
|
+
'hero-6': {
|
|
416
|
+
value: {
|
|
417
|
+
fontSize: bpkTokens.fontSizeXxxl,
|
|
418
|
+
lineHeight: bpkTokens.lineHeightXxl,
|
|
419
|
+
fontWeight: bpkTokens.fontWeightBlack,
|
|
420
|
+
letterSpacing: bpkTokens.letterSpacingHero
|
|
421
|
+
}
|
|
422
|
+
},
|
|
423
|
+
'editorial-1': {
|
|
424
|
+
value: {
|
|
425
|
+
fontFamily: `var(--bpk-larken-font-stack, ${bpkTokens.fontFamilyLarken})`,
|
|
426
|
+
fontSize: bpkTokens.fontSizeXxxxl,
|
|
427
|
+
lineHeight: bpkTokens.lineHeightXxxxl,
|
|
428
|
+
fontWeight: bpkTokens.fontWeightLight
|
|
429
|
+
}
|
|
430
|
+
},
|
|
431
|
+
'editorial-2': {
|
|
432
|
+
value: {
|
|
433
|
+
fontFamily: `var(--bpk-larken-font-stack, ${bpkTokens.fontFamilyLarken})`,
|
|
434
|
+
fontSize: bpkTokens.fontSizeXxl,
|
|
435
|
+
lineHeight: bpkTokens.lineHeightXxl,
|
|
436
|
+
fontWeight: bpkTokens.fontWeightLight
|
|
437
|
+
}
|
|
438
|
+
},
|
|
439
|
+
'editorial-3': {
|
|
440
|
+
value: {
|
|
441
|
+
fontFamily: `var(--bpk-larken-font-stack, ${bpkTokens.fontFamilyLarken})`,
|
|
442
|
+
fontSize: bpkTokens.fontSizeLg,
|
|
443
|
+
lineHeight: bpkTokens.lineHeightLg,
|
|
444
|
+
fontWeight: bpkTokens.fontWeightBook
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
};
|
|
220
448
|
export function createBpkConfig() {
|
|
221
449
|
// Convert breakpoint map to Chakra UI format
|
|
222
450
|
// Breakpoints in Chakra v3 are typically simple strings in the breakpoints object
|
|
@@ -224,12 +452,6 @@ export function createBpkConfig() {
|
|
|
224
452
|
Object.entries(breakpointMap).forEach(([token, value]) => {
|
|
225
453
|
chakraBreakpoints[token] = value;
|
|
226
454
|
});
|
|
227
|
-
|
|
228
|
-
// textStyles have been removed from the Chakra config to reduce bundle size.
|
|
229
|
-
// Text style resolution is now handled inline by resolveTextStyle.ts via
|
|
230
|
-
// expandTextStyleProps(), which expands textStyle tokens into concrete CSS
|
|
231
|
-
// properties at prop-processing time. This means layout-only consumers that
|
|
232
|
-
// never use textStyle pay nothing for the typography map.
|
|
233
455
|
return defineConfig({
|
|
234
456
|
// Disable Chakra's preflight (CSS reset) so it does not override Backpack's
|
|
235
457
|
// global font styles, in particular the `-webkit-font-smoothing: antialiased`
|
|
@@ -240,6 +462,7 @@ export function createBpkConfig() {
|
|
|
240
462
|
tokens: {
|
|
241
463
|
spacing: spacingMap
|
|
242
464
|
},
|
|
465
|
+
textStyles: textStylesMap,
|
|
243
466
|
breakpoints: chakraBreakpoints
|
|
244
467
|
}
|
|
245
468
|
});
|
|
@@ -17,7 +17,6 @@
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
import StackOptionKeys from "./BpkStack.constant";
|
|
20
|
-
import { expandTextStyleProps } from "./resolveTextStyle";
|
|
21
20
|
import { getSpacingValue } from "./theme";
|
|
22
21
|
import { BpkBreakpointToChakraKey, isValidSpacingValue, isValidSizeValue, isValidPositionValue, isPercentage } from "./tokens";
|
|
23
22
|
|
|
@@ -35,6 +34,8 @@ import { BpkBreakpointToChakraKey, isValidSpacingValue, isValidSizeValue, isVali
|
|
|
35
34
|
export const BPK_RESPONSIVE_PROP_GROUPS_BY_COMPONENT = {
|
|
36
35
|
BpkBox: {
|
|
37
36
|
container: [
|
|
37
|
+
// Typography
|
|
38
|
+
'textStyle',
|
|
38
39
|
// Display
|
|
39
40
|
'display',
|
|
40
41
|
// Flex container props
|
|
@@ -51,14 +52,14 @@ export const BPK_RESPONSIVE_PROP_GROUPS_BY_COMPONENT = {
|
|
|
51
52
|
},
|
|
52
53
|
// Note: BpkFlex maps its public API props to these Chakra keys.
|
|
53
54
|
BpkFlex: {
|
|
54
|
-
container: ['flexDirection', 'justifyContent', 'alignItems', 'flexWrap',
|
|
55
|
+
container: ['textStyle', 'flexDirection', 'justifyContent', 'alignItems', 'flexWrap',
|
|
55
56
|
// Position keyword and overflow (from BpkCommonLayoutProps)
|
|
56
57
|
'position', 'overflow', 'overflowX', 'overflowY'],
|
|
57
58
|
item: ['flexGrow', 'flexShrink', 'flexBasis']
|
|
58
59
|
},
|
|
59
60
|
// Note: BpkGrid maps its public API props to these Chakra keys.
|
|
60
61
|
BpkGrid: {
|
|
61
|
-
container: ['justifyContent', 'alignItems', 'gridTemplateColumns', 'gridTemplateRows', 'gridTemplateAreas', 'gridAutoFlow', 'gridAutoRows', 'gridAutoColumns',
|
|
62
|
+
container: ['textStyle', 'justifyContent', 'alignItems', 'gridTemplateColumns', 'gridTemplateRows', 'gridTemplateAreas', 'gridAutoFlow', 'gridAutoRows', 'gridAutoColumns',
|
|
62
63
|
// Position keyword and overflow (from BpkCommonLayoutProps)
|
|
63
64
|
'position', 'overflow', 'overflowX', 'overflowY'],
|
|
64
65
|
item: [
|
|
@@ -66,11 +67,11 @@ export const BPK_RESPONSIVE_PROP_GROUPS_BY_COMPONENT = {
|
|
|
66
67
|
'gridColumn', 'gridRow']
|
|
67
68
|
},
|
|
68
69
|
BpkGridItem: {
|
|
69
|
-
container: ['position', 'overflow', 'overflowX', 'overflowY']
|
|
70
|
+
container: ['textStyle', 'position', 'overflow', 'overflowX', 'overflowY']
|
|
70
71
|
},
|
|
71
72
|
// Note: BpkStack uses Chakra Stack option prop names directly.
|
|
72
73
|
BpkStack: {
|
|
73
|
-
container: [...StackOptionKeys,
|
|
74
|
+
container: ['textStyle', ...StackOptionKeys,
|
|
74
75
|
// Position keyword and overflow (from BpkCommonLayoutProps)
|
|
75
76
|
'position', 'overflow', 'overflowX', 'overflowY']
|
|
76
77
|
}
|
|
@@ -107,37 +108,18 @@ function filterToAllowlist(props, allowlist) {
|
|
|
107
108
|
*/
|
|
108
109
|
export function processBpkComponentProps(props, options) {
|
|
109
110
|
const processed = processBpkProps(props);
|
|
110
|
-
|
|
111
|
-
// --- textStyle inline resolution ---
|
|
112
|
-
// textStyle is no longer part of the Chakra theme config. Instead we resolve
|
|
113
|
-
// it here into concrete CSS properties (fontSize, lineHeight, fontWeight, etc.).
|
|
114
|
-
// The value may come from:
|
|
115
|
-
// - responsiveProps (BpkFlex, BpkGrid explicitly pass it)
|
|
116
|
-
// - processed props (BpkBox, BpkStack pass it via ...props)
|
|
117
|
-
const textStyleValue = options.responsiveProps?.textStyle ?? processed.textStyle;
|
|
118
|
-
delete processed.textStyle;
|
|
119
|
-
// Strip textStyle from responsiveProps without mutating the original object.
|
|
120
|
-
const {
|
|
121
|
-
textStyle: _ts,
|
|
122
|
-
...cleanResponsiveProps
|
|
123
|
-
} = options.responsiveProps ?? {};
|
|
124
|
-
const expandedTextStyle = expandTextStyleProps(textStyleValue);
|
|
125
111
|
const allowlist = BPK_RESPONSIVE_PROP_KEYS_BY_COMPONENT[options.component];
|
|
126
112
|
// When responsiveProps is provided (e.g. BpkFlex maps direction→flexDirection),
|
|
127
113
|
// merge it with any allowlisted props already in `processed` (e.g. position/overflow
|
|
128
114
|
// that come in via ...props and are NOT included in responsiveProps).
|
|
129
115
|
// responsiveProps takes precedence so that explicit prop-name mappings always win.
|
|
130
116
|
const processedAllowlisted = filterToAllowlist(processed, allowlist);
|
|
131
|
-
const
|
|
132
|
-
const responsiveSource = hasResponsiveProps ? {
|
|
117
|
+
const responsiveSource = options.responsiveProps ? {
|
|
133
118
|
...processedAllowlisted,
|
|
134
|
-
...filterToAllowlist(
|
|
119
|
+
...filterToAllowlist(options.responsiveProps, allowlist)
|
|
135
120
|
} : processedAllowlisted;
|
|
136
121
|
if (Object.keys(responsiveSource).length === 0) {
|
|
137
|
-
return
|
|
138
|
-
...processed,
|
|
139
|
-
...expandedTextStyle
|
|
140
|
-
};
|
|
122
|
+
return processed;
|
|
141
123
|
}
|
|
142
124
|
|
|
143
125
|
// Ensure allowlisted layout props do NOT fall through unprocessed (e.g. array responsive values).
|
|
@@ -158,11 +140,7 @@ export function processBpkComponentProps(props, options) {
|
|
|
158
140
|
delete responsiveProcessed[key];
|
|
159
141
|
}
|
|
160
142
|
});
|
|
161
|
-
|
|
162
|
-
// Expanded textStyle props are applied last so they don't get overridden by
|
|
163
|
-
// the responsive pipeline, but explicit CSS props from the user take precedence.
|
|
164
143
|
return {
|
|
165
|
-
...expandedTextStyle,
|
|
166
144
|
...cleanedProcessed,
|
|
167
145
|
...responsiveProcessed
|
|
168
146
|
};
|
package/package.json
CHANGED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { ChatbotInputType } from './common-types';
|
|
2
|
-
type BpkChatbotInputContextValue = {
|
|
3
|
-
inputType: ChatbotInputType;
|
|
4
|
-
isOverLimit: boolean;
|
|
5
|
-
setIsOverLimit: (value: boolean) => void;
|
|
6
|
-
};
|
|
7
|
-
export declare const BpkChatbotInputContext: import("react").Context<BpkChatbotInputContextValue>;
|
|
8
|
-
export declare const useChatbotInputContext: () => BpkChatbotInputContextValue;
|
|
9
|
-
export {};
|
|
@@ -1,26 +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 { createContext, useContext } from 'react';
|
|
20
|
-
import { CHATBOT_INPUT_TYPES } from "./common-types";
|
|
21
|
-
export const BpkChatbotInputContext = /*#__PURE__*/createContext({
|
|
22
|
-
inputType: CHATBOT_INPUT_TYPES.COMPOSER,
|
|
23
|
-
isOverLimit: false,
|
|
24
|
-
setIsOverLimit: () => {}
|
|
25
|
-
});
|
|
26
|
-
export const useChatbotInputContext = () => useContext(BpkChatbotInputContext);
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import type { BpkChatbotInputInputProps } from './common-types';
|
|
2
|
-
declare const BpkChatbotInputInput: ({ inputValue, isPolling, isSending, loadingAriaLabel, maxCharacters, maxLines, onInputBlur, onInputChange, onInputClick, onInputFocus, onKeyDown, onSubmit, placeholder, renderSendButton, sendAriaLabel, }: BpkChatbotInputInputProps) => import("react/jsx-runtime").JSX.Element;
|
|
3
|
-
export default BpkChatbotInputInput;
|
|
@@ -1,125 +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 } from 'react';
|
|
20
|
-
import BpkButton, { BUTTON_TYPES, SIZE_TYPES } from "../../bpk-component-button";
|
|
21
|
-
import { withButtonAlignment } from "../../bpk-component-icon";
|
|
22
|
-
import ArrowUpIcon from "../../bpk-component-icon/sm/long-arrow-up";
|
|
23
|
-
import { BpkFlex, BpkSpacing } from "../../bpk-component-layout";
|
|
24
|
-
import { getDataComponentAttribute } from "../../bpk-react-utils";
|
|
25
|
-
import { useChatbotInputContext } from "./BpkChatbotInputContext";
|
|
26
|
-
import InputField from "./InputField/InputField";
|
|
27
|
-
import TextAreaField from "./TextAreaField/TextAreaField";
|
|
28
|
-
import { CHATBOT_INPUT_TYPES } from "./common-types";
|
|
29
|
-
import { MAX_CHARACTERS } from "./constants";
|
|
30
|
-
import { useChatbotInput } from "./hooks";
|
|
31
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
32
|
-
const AlignedArrowUpIcon = withButtonAlignment(ArrowUpIcon);
|
|
33
|
-
const BpkChatbotInputInput = ({
|
|
34
|
-
inputValue,
|
|
35
|
-
isPolling = false,
|
|
36
|
-
isSending = false,
|
|
37
|
-
loadingAriaLabel,
|
|
38
|
-
maxCharacters = MAX_CHARACTERS,
|
|
39
|
-
maxLines,
|
|
40
|
-
onInputBlur,
|
|
41
|
-
onInputChange,
|
|
42
|
-
onInputClick = () => {},
|
|
43
|
-
onInputFocus,
|
|
44
|
-
onKeyDown = () => {},
|
|
45
|
-
onSubmit,
|
|
46
|
-
placeholder,
|
|
47
|
-
renderSendButton,
|
|
48
|
-
sendAriaLabel
|
|
49
|
-
}) => {
|
|
50
|
-
const {
|
|
51
|
-
inputType,
|
|
52
|
-
setIsOverLimit
|
|
53
|
-
} = useChatbotInputContext();
|
|
54
|
-
const {
|
|
55
|
-
containerHeight,
|
|
56
|
-
handleSubmit,
|
|
57
|
-
inputProps,
|
|
58
|
-
inputRef,
|
|
59
|
-
isCapped,
|
|
60
|
-
isCars,
|
|
61
|
-
isExpanding,
|
|
62
|
-
isOverLimit,
|
|
63
|
-
sendButtonDisabled,
|
|
64
|
-
textareaHeight
|
|
65
|
-
} = useChatbotInput({
|
|
66
|
-
placeholder,
|
|
67
|
-
inputType,
|
|
68
|
-
inputValue,
|
|
69
|
-
isPolling,
|
|
70
|
-
isSending,
|
|
71
|
-
maxCharacters,
|
|
72
|
-
maxLines,
|
|
73
|
-
onInputBlur,
|
|
74
|
-
onInputChange,
|
|
75
|
-
onInputClick,
|
|
76
|
-
onInputFocus,
|
|
77
|
-
onKeyDown,
|
|
78
|
-
onSubmit
|
|
79
|
-
});
|
|
80
|
-
useEffect(() => {
|
|
81
|
-
setIsOverLimit(isOverLimit);
|
|
82
|
-
}, [isOverLimit, setIsOverLimit]);
|
|
83
|
-
const isComposer = inputType === CHATBOT_INPUT_TYPES.COMPOSER;
|
|
84
|
-
const flexProps = isCars ? {
|
|
85
|
-
align: 'center',
|
|
86
|
-
gap: BpkSpacing.MD
|
|
87
|
-
} : {
|
|
88
|
-
align: isExpanding ? 'flex-end' : 'center',
|
|
89
|
-
gap: BpkSpacing.Base
|
|
90
|
-
};
|
|
91
|
-
return /*#__PURE__*/_jsxs(BpkFlex, {
|
|
92
|
-
width: "100%",
|
|
93
|
-
...flexProps,
|
|
94
|
-
...getDataComponentAttribute('ChatbotInput.Input'),
|
|
95
|
-
children: [isCars ? /*#__PURE__*/_jsx(InputField, {
|
|
96
|
-
ref: inputRef,
|
|
97
|
-
...inputProps
|
|
98
|
-
}) : /*#__PURE__*/_jsx(TextAreaField, {
|
|
99
|
-
ref: inputRef,
|
|
100
|
-
containerHeight: containerHeight,
|
|
101
|
-
textareaHeight: textareaHeight,
|
|
102
|
-
isCapped: isCapped,
|
|
103
|
-
isExpanding: isExpanding,
|
|
104
|
-
isComposer: isComposer,
|
|
105
|
-
maxLines: maxLines,
|
|
106
|
-
...inputProps
|
|
107
|
-
}), renderSendButton ? renderSendButton({
|
|
108
|
-
disabled: sendButtonDisabled,
|
|
109
|
-
onClick: handleSubmit,
|
|
110
|
-
loading: isPolling,
|
|
111
|
-
ariaLabel: isPolling ? loadingAriaLabel : sendAriaLabel
|
|
112
|
-
}) : /*#__PURE__*/_jsx(BpkButton, {
|
|
113
|
-
type: BUTTON_TYPES.primary,
|
|
114
|
-
size: SIZE_TYPES.small,
|
|
115
|
-
iconOnly: true,
|
|
116
|
-
onClick: handleSubmit,
|
|
117
|
-
disabled: sendButtonDisabled,
|
|
118
|
-
loading: isPolling,
|
|
119
|
-
"aria-label": isPolling ? loadingAriaLabel : sendAriaLabel,
|
|
120
|
-
"data-testid": "bpk-chatbot-input-send",
|
|
121
|
-
children: /*#__PURE__*/_jsx(AlignedArrowUpIcon, {})
|
|
122
|
-
})]
|
|
123
|
-
});
|
|
124
|
-
};
|
|
125
|
-
export default BpkChatbotInputInput;
|
|
@@ -1,77 +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 { useCallback, useMemo, useState } from 'react';
|
|
20
|
-
import { BpkVStack, BpkSpacing } from "../../bpk-component-layout";
|
|
21
|
-
import { cssModules, getDataComponentAttribute } from "../../bpk-react-utils";
|
|
22
|
-
import { BpkChatbotInputContext } from "./BpkChatbotInputContext";
|
|
23
|
-
import { CHATBOT_INPUT_TYPES } from "./common-types";
|
|
24
|
-
import STYLES from "./BpkChatbotInput.module.css";
|
|
25
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
26
|
-
const getClassName = cssModules(STYLES);
|
|
27
|
-
const BpkChatbotInputRoot = ({
|
|
28
|
-
align = 'flex-start',
|
|
29
|
-
children,
|
|
30
|
-
gap = BpkSpacing.Base,
|
|
31
|
-
inputType = CHATBOT_INPUT_TYPES.COMPOSER,
|
|
32
|
-
...rest
|
|
33
|
-
}) => {
|
|
34
|
-
const isCars = inputType === CHATBOT_INPUT_TYPES.CARS;
|
|
35
|
-
const isComposer = inputType === CHATBOT_INPUT_TYPES.COMPOSER;
|
|
36
|
-
const [isOverLimit, setIsOverLimit] = useState(false);
|
|
37
|
-
const stableSetIsOverLimit = useCallback(value => {
|
|
38
|
-
setIsOverLimit(value);
|
|
39
|
-
}, []);
|
|
40
|
-
const contextValue = useMemo(() => ({
|
|
41
|
-
inputType,
|
|
42
|
-
isOverLimit,
|
|
43
|
-
setIsOverLimit: stableSetIsOverLimit
|
|
44
|
-
}), [inputType, isOverLimit, stableSetIsOverLimit]);
|
|
45
|
-
const containerClassName = getClassName(isCars ? 'bpk-chatbot-input--cars' : 'bpk-chatbot-input--composer', isComposer && 'bpk-chatbot-input--composer--with-shadow', isOverLimit && !isCars && 'bpk-chatbot-input--composer--overLimit');
|
|
46
|
-
const paddingProps = isCars ? {
|
|
47
|
-
paddingTop: BpkSpacing.MD,
|
|
48
|
-
paddingBottom: BpkSpacing.MD,
|
|
49
|
-
paddingEnd: BpkSpacing.MD,
|
|
50
|
-
paddingStart: BpkSpacing.Base
|
|
51
|
-
} : {
|
|
52
|
-
padding: BpkSpacing.Base
|
|
53
|
-
};
|
|
54
|
-
const handleContainerEvent = e => {
|
|
55
|
-
e.stopPropagation();
|
|
56
|
-
};
|
|
57
|
-
return /*#__PURE__*/_jsx(BpkChatbotInputContext.Provider, {
|
|
58
|
-
value: contextValue,
|
|
59
|
-
children: /*#__PURE__*/_jsx("div", {
|
|
60
|
-
className: containerClassName,
|
|
61
|
-
onClick: handleContainerEvent,
|
|
62
|
-
onTouchStart: handleContainerEvent,
|
|
63
|
-
role: "presentation",
|
|
64
|
-
"data-testid": "bpk-chatbot-input-container",
|
|
65
|
-
...getDataComponentAttribute('ChatbotInput'),
|
|
66
|
-
children: /*#__PURE__*/_jsx(BpkVStack, {
|
|
67
|
-
align: align,
|
|
68
|
-
gap: gap,
|
|
69
|
-
width: "100%",
|
|
70
|
-
...paddingProps,
|
|
71
|
-
...rest,
|
|
72
|
-
children: children
|
|
73
|
-
})
|
|
74
|
-
})
|
|
75
|
-
});
|
|
76
|
-
};
|
|
77
|
-
export default BpkChatbotInputRoot;
|