@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.
Files changed (28) 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/src/theme.js +252 -29
  17. package/bpk-component-layout/src/tokenUtils.js +9 -31
  18. package/package.json +1 -1
  19. package/bpk-component-chatbot-input/src/BpkChatbotInputContext.d.ts +0 -9
  20. package/bpk-component-chatbot-input/src/BpkChatbotInputContext.js +0 -26
  21. package/bpk-component-chatbot-input/src/BpkChatbotInputInput.d.ts +0 -3
  22. package/bpk-component-chatbot-input/src/BpkChatbotInputInput.js +0 -125
  23. package/bpk-component-chatbot-input/src/BpkChatbotInputRoot.d.ts +0 -3
  24. package/bpk-component-chatbot-input/src/BpkChatbotInputRoot.js +0 -77
  25. package/bpk-component-chatbot-input/src/BpkChatbotInputToolbar.d.ts +0 -3
  26. package/bpk-component-chatbot-input/src/BpkChatbotInputToolbar.js +0 -33
  27. package/bpk-component-layout/src/resolveTextStyle.d.ts +0 -13
  28. package/bpk-component-layout/src/resolveTextStyle.js +0 -265
@@ -15,4 +15,4 @@
15
15
  * See the License for the specific language governing permissions and
16
16
  * limitations under the License.
17
17
  */
18
- .bpk-ai-blurb{display:flex;flex-direction:column;gap:.5rem}.bpk-ai-blurb__header{color:#626971}.bpk-ai-blurb__header svg{fill:currentcolor}.bpk-ai-blurb__summary{display:block}.bpk-ai-blurb__error{display:flex;margin:0;flex-wrap:wrap;align-items:baseline;gap:0 .25rem;font-size:.75rem;line-height:1rem;font-weight:400}.bpk-ai-blurb__ellipsis{display:inline;vertical-align:baseline;margin-inline-start:.25rem}.bpk-ai-blurb__ellipsis-dot{display:inline;opacity:0;vertical-align:baseline;animation:bpk-ai-blurb-ellipsis-dot-1 1.2s infinite step-end}@media(prefers-reduced-motion: reduce){.bpk-ai-blurb__ellipsis-dot{opacity:1;animation:none}}.bpk-ai-blurb__ellipsis-dot--2{animation-name:bpk-ai-blurb-ellipsis-dot-2}.bpk-ai-blurb__ellipsis-dot--3{animation-name:bpk-ai-blurb-ellipsis-dot-3}@keyframes bpk-ai-blurb-ellipsis-dot-1{0%{opacity:1}75%{opacity:0}100%{opacity:0}}@keyframes bpk-ai-blurb-ellipsis-dot-2{0%{opacity:0}25%{opacity:1}75%{opacity:0}100%{opacity:0}}@keyframes bpk-ai-blurb-ellipsis-dot-3{0%{opacity:0}50%{opacity:1}75%{opacity:0}100%{opacity:0}}
18
+ .bpk-ai-blurb{display:flex;flex-direction:column;gap:.5rem}.bpk-ai-blurb__header{color:#626971}.bpk-ai-blurb__header svg{fill:currentcolor}.bpk-ai-blurb__summary{display:block}.bpk-ai-blurb__error{display:flex;margin:0;flex-wrap:wrap;align-items:baseline;gap:0 .25rem;font-size:.75rem;line-height:1rem;font-weight:400}.bpk-ai-blurb__feedback-thumb{display:inline-flex;padding:0;align-items:center;border:none;background:none;color:#161616;cursor:pointer;font-size:.75rem;line-height:1rem;font-weight:400}.bpk-ai-blurb__feedback-thumb svg{fill:currentcolor}.bpk-ai-blurb__feedback-thumb:hover{color:#626971}.bpk-ai-blurb__feedback-thumb:focus-visible{outline:.125rem solid #0062e3;outline-offset:.125rem}.bpk-ai-blurb__ellipsis{display:inline;vertical-align:baseline;margin-inline-start:.25rem}.bpk-ai-blurb__ellipsis-dot{display:inline;opacity:0;vertical-align:baseline;animation:bpk-ai-blurb-ellipsis-dot-1 1.2s infinite step-end}@media(prefers-reduced-motion: reduce){.bpk-ai-blurb__ellipsis-dot{opacity:1;animation:none}}.bpk-ai-blurb__ellipsis-dot--2{animation-name:bpk-ai-blurb-ellipsis-dot-2}.bpk-ai-blurb__ellipsis-dot--3{animation-name:bpk-ai-blurb-ellipsis-dot-3}@keyframes bpk-ai-blurb-ellipsis-dot-1{0%{opacity:1}75%{opacity:0}100%{opacity:0}}@keyframes bpk-ai-blurb-ellipsis-dot-2{0%{opacity:0}25%{opacity:1}75%{opacity:0}100%{opacity:0}}@keyframes bpk-ai-blurb-ellipsis-dot-3{0%{opacity:0}50%{opacity:1}75%{opacity:0}100%{opacity:0}}
@@ -18,10 +18,14 @@
18
18
 
19
19
  import { useState } from 'react';
20
20
  import BpkAriaLive from "../../bpk-component-aria-live";
21
+ import BpkSmallThumbsDownIcon from "../../bpk-component-icon/sm/thumbs-down";
22
+ import BpkSmallThumbsUpIcon from "../../bpk-component-icon/sm/thumbs-up";
21
23
  import { BpkFlex, BpkSpacing } from "../../bpk-component-layout";
22
24
  import BpkText, { TEXT_STYLES } from "../../bpk-component-text";
23
- import BpkThumbButton from "../../bpk-component-thumb-button";
25
+ import { cssModules } from "../../bpk-react-utils";
26
+ import STYLES from "./BpkAiBlurb.module.css";
24
27
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
28
+ const getClassName = cssModules(STYLES);
25
29
  const BpkAiBlurbFeedback = ({
26
30
  feedbackText,
27
31
  onFeedback,
@@ -41,18 +45,22 @@ const BpkAiBlurbFeedback = ({
41
45
  children: [/*#__PURE__*/_jsx(BpkText, {
42
46
  textStyle: TEXT_STYLES.caption,
43
47
  children: feedbackText
44
- }), /*#__PURE__*/_jsx(BpkThumbButton, {
45
- type: "up",
46
- size: "small",
47
- iconColor: "primary",
48
- accessibilityLabel: thumbsUpLabel,
49
- onClick: () => handleVote(true)
50
- }), /*#__PURE__*/_jsx(BpkThumbButton, {
51
- type: "down",
52
- size: "small",
53
- iconColor: "primary",
54
- accessibilityLabel: thumbsDownLabel,
55
- onClick: () => handleVote(false)
48
+ }), /*#__PURE__*/_jsx("button", {
49
+ type: "button",
50
+ className: getClassName('bpk-ai-blurb__feedback-thumb'),
51
+ onClick: () => handleVote(true),
52
+ "aria-label": thumbsUpLabel,
53
+ children: /*#__PURE__*/_jsx(BpkSmallThumbsUpIcon, {
54
+ "aria-hidden": true
55
+ })
56
+ }), /*#__PURE__*/_jsx("button", {
57
+ type: "button",
58
+ className: getClassName('bpk-ai-blurb__feedback-thumb'),
59
+ onClick: () => handleVote(false),
60
+ "aria-label": thumbsDownLabel,
61
+ children: /*#__PURE__*/_jsx(BpkSmallThumbsDownIcon, {
62
+ "aria-hidden": true
63
+ })
56
64
  })]
57
65
  }), /*#__PURE__*/_jsx(BpkAriaLive, {
58
66
  visible: hasVoted,
@@ -1,6 +1,7 @@
1
1
  import BpkChatbotInput from './src/BpkChatbotInput';
2
- export type { BpkChatbotInputInputProps, BpkChatbotInputNamespace, BpkChatbotInputRootProps, BpkChatbotInputToolbarProps, ChatbotInputType, SendButtonRenderProps, } from './src/common-types';
2
+ export type { BpkChatbotInputProps } from './src/common-types';
3
3
  export { CHATBOT_INPUT_TYPES } from './src/common-types';
4
+ export type { ChatbotInputType } from './src/common-types';
4
5
  export { useChatbotInputManager } from './src/hooks';
5
6
  export { default as themeAttributes } from './src/themeAttributes';
6
7
  export default BpkChatbotInput;
@@ -1,14 +1,4 @@
1
- import type { BpkChatbotInputNamespace } from './common-types';
2
- /**
3
- * BpkChatbotInput is a composable chatbot input namespace for Backpack.
4
- *
5
- * @example
6
- * <BpkChatbotInput.Root>
7
- * <BpkChatbotInput.Input {...inputProps} />
8
- * <BpkChatbotInput.Toolbar>
9
- * <BpkButton type={BUTTON_TYPES.link}>Attach</BpkButton>
10
- * </BpkChatbotInput.Toolbar>
11
- * </BpkChatbotInput.Root>
12
- */
13
- declare const BpkChatbotInput: BpkChatbotInputNamespace;
1
+ import type { BpkChatbotInputProps } from './common-types';
2
+ export type { BpkChatbotInputProps };
3
+ declare const BpkChatbotInput: ({ inputType, inputValue, isPolling, isSending, loadingAriaLabel, maxCharacters, onInputBlur, onInputChange, onInputClick, onInputFocus, onKeyDown, onSubmit, placeholder, sendAriaLabel, }: BpkChatbotInputProps) => import("react/jsx-runtime").JSX.Element;
14
4
  export default BpkChatbotInput;
@@ -16,23 +16,103 @@
16
16
  * limitations under the License.
17
17
  */
18
18
 
19
- import BpkChatbotInputInput from "./BpkChatbotInputInput";
20
- import BpkChatbotInputRoot from "./BpkChatbotInputRoot";
21
- import BpkChatbotInputToolbar from "./BpkChatbotInputToolbar";
22
- /**
23
- * BpkChatbotInput is a composable chatbot input namespace for Backpack.
24
- *
25
- * @example
26
- * <BpkChatbotInput.Root>
27
- * <BpkChatbotInput.Input {...inputProps} />
28
- * <BpkChatbotInput.Toolbar>
29
- * <BpkButton type={BUTTON_TYPES.link}>Attach</BpkButton>
30
- * </BpkChatbotInput.Toolbar>
31
- * </BpkChatbotInput.Root>
32
- */
33
- const BpkChatbotInput = {
34
- Root: BpkChatbotInputRoot,
35
- Input: BpkChatbotInputInput,
36
- Toolbar: BpkChatbotInputToolbar
19
+ import { BpkFlex, BpkSpacing } from "../../bpk-component-layout";
20
+ import { cssModules, getDataComponentAttribute } from "../../bpk-react-utils";
21
+ import InputField from "./InputField/InputField";
22
+ import SendButton from "./SendButton/SendButton";
23
+ import TextAreaField from "./TextAreaField/TextAreaField";
24
+ import { CHATBOT_INPUT_TYPES } from "./common-types";
25
+ import { MAX_CHARACTERS } from "./constants";
26
+ import { useChatbotInput } from "./hooks";
27
+ import STYLES from "./BpkChatbotInput.module.css";
28
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
29
+ const getClassName = cssModules(STYLES);
30
+ const BpkChatbotInput = ({
31
+ inputType = CHATBOT_INPUT_TYPES.COMPOSER,
32
+ inputValue,
33
+ isPolling = false,
34
+ isSending = false,
35
+ loadingAriaLabel,
36
+ maxCharacters = MAX_CHARACTERS,
37
+ onInputBlur,
38
+ onInputChange,
39
+ onInputClick = () => {},
40
+ onInputFocus,
41
+ onKeyDown = () => {},
42
+ onSubmit,
43
+ placeholder,
44
+ sendAriaLabel
45
+ }) => {
46
+ const {
47
+ containerHeight,
48
+ handleSubmit,
49
+ inputProps,
50
+ inputRef,
51
+ isCapped,
52
+ isCars,
53
+ isExpanding,
54
+ isOverLimit,
55
+ sendButtonDisabled,
56
+ textareaHeight
57
+ } = useChatbotInput({
58
+ placeholder,
59
+ inputType,
60
+ inputValue,
61
+ isPolling,
62
+ isSending,
63
+ maxCharacters,
64
+ onInputBlur,
65
+ onInputChange,
66
+ onInputClick,
67
+ onInputFocus,
68
+ onKeyDown,
69
+ onSubmit
70
+ });
71
+ const isComposer = inputType === CHATBOT_INPUT_TYPES.COMPOSER;
72
+ 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');
73
+ const flexProps = isCars ? {
74
+ align: 'center',
75
+ gap: BpkSpacing.MD,
76
+ paddingTop: BpkSpacing.MD,
77
+ paddingBottom: BpkSpacing.MD,
78
+ paddingEnd: BpkSpacing.MD,
79
+ paddingStart: BpkSpacing.Base
80
+ } : {
81
+ align: isExpanding ? 'flex-end' : 'center',
82
+ gap: BpkSpacing.Base,
83
+ padding: BpkSpacing.Base
84
+ };
85
+ const handleContainerEvent = e => {
86
+ e.stopPropagation();
87
+ };
88
+ return /*#__PURE__*/_jsx("div", {
89
+ className: containerClassName,
90
+ onClick: handleContainerEvent,
91
+ onTouchStart: handleContainerEvent,
92
+ role: "presentation",
93
+ "data-testid": "bpk-chatbot-input-container",
94
+ ...getDataComponentAttribute('ChatbotInput'),
95
+ children: /*#__PURE__*/_jsxs(BpkFlex, {
96
+ ...flexProps,
97
+ children: [isCars ? /*#__PURE__*/_jsx(InputField, {
98
+ ref: inputRef,
99
+ ...inputProps
100
+ }) : /*#__PURE__*/_jsx(TextAreaField, {
101
+ ref: inputRef,
102
+ containerHeight: containerHeight,
103
+ textareaHeight: textareaHeight,
104
+ isCapped: isCapped,
105
+ isExpanding: isExpanding,
106
+ isComposer: isComposer,
107
+ ...inputProps
108
+ }), /*#__PURE__*/_jsx(SendButton, {
109
+ isCars: isCars,
110
+ disabled: sendButtonDisabled,
111
+ onClick: handleSubmit,
112
+ ariaLabel: isCars && isPolling ? loadingAriaLabel : sendAriaLabel,
113
+ isLoading: !!(isCars && isPolling)
114
+ })]
115
+ })
116
+ });
37
117
  };
38
118
  export default BpkChatbotInput;
@@ -15,4 +15,4 @@
15
15
  * See the License for the specific language governing permissions and
16
16
  * limitations under the License.
17
17
  */
18
- .bpk-chatbot-input--cars{transition:border-color 200ms ease,box-shadow 200ms ease;border:.09375rem solid #c1c7cf;background:#fff;box-shadow:none;box-sizing:border-box;touch-action:manipulation;border-radius:.75rem;border-radius:var(--bpk-chatbot-input-border-radius, 0.75rem)}.bpk-no-touch-support .bpk-chatbot-input--cars:hover:not(:active):not(:disabled){border-color:#0062e3;border-color:var(--bpk-chatbot-input-focus-border-color, rgb(0, 98, 227))}:global(.bpk-no-touch-support) .bpk-chatbot-input--cars:hover:not(:active):not(:disabled){border-color:#0062e3;border-color:var(--bpk-chatbot-input-focus-border-color, rgb(0, 98, 227))}.bpk-chatbot-input--cars:active{border-color:#0062e3;border-color:var(--bpk-chatbot-input-focus-border-color, rgb(0, 98, 227))}.bpk-chatbot-input--cars:focus-within{box-shadow:0 0 0 .03125rem #0062e3;box-shadow:0 0 0 .03125rem var(--bpk-chatbot-input-focus-border-color, rgb(0, 98, 227));border-color:#0062e3;border-color:var(--bpk-chatbot-input-focus-border-color, rgb(0, 98, 227))}.bpk-chatbot-input--composer{position:relative;transition:transform .3s cubic-bezier(0.4, 0, 0.2, 1),box-shadow .3s cubic-bezier(0.4, 0, 0.2, 1);border:none;background:#fff;box-sizing:border-box;will-change:transform,box-shadow;border-radius:.75rem;border-radius:var(--bpk-chatbot-input-border-radius, 0.75rem)}.bpk-chatbot-input--composer--with-shadow:focus-within{box-shadow:0px 4px 14px 0px rgba(37,32,31,.25)}.bpk-chatbot-input--composer--overLimit{transform:translateY(-0.25rem)}
18
+ .bpk-chatbot-input--cars{transition:border-color 200ms ease,box-shadow 200ms ease;border:.09375rem solid #c1c7cf;background:#fff;box-shadow:none;box-sizing:border-box;touch-action:manipulation;border-radius:.75rem;border-radius:var(--bpk-chatbot-input-border-radius, 0.75rem)}.bpk-no-touch-support .bpk-chatbot-input--cars:hover:not(:active):not(:disabled){border-color:#0062e3;border-color:var(--bpk-chatbot-input-focus-border-color, rgb(0, 98, 227))}:global(.bpk-no-touch-support) .bpk-chatbot-input--cars:hover:not(:active):not(:disabled){border-color:#0062e3;border-color:var(--bpk-chatbot-input-focus-border-color, rgb(0, 98, 227))}.bpk-chatbot-input--cars:active{border-color:#0062e3;border-color:var(--bpk-chatbot-input-focus-border-color, rgb(0, 98, 227))}.bpk-chatbot-input--cars:focus-within{box-shadow:0 0 0 .03125rem #0062e3;box-shadow:0 0 0 .03125rem var(--bpk-chatbot-input-focus-border-color, rgb(0, 98, 227));border-color:#0062e3;border-color:var(--bpk-chatbot-input-focus-border-color, rgb(0, 98, 227))}.bpk-chatbot-input--composer{position:relative;transition:transform .3s cubic-bezier(0.4, 0, 0.2, 1),box-shadow .3s cubic-bezier(0.4, 0, 0.2, 1);border:none;background:#fff;box-sizing:border-box;will-change:transform,box-shadow;border-radius:.75rem;border-radius:var(--bpk-chatbot-input-border-radius, 0.75rem)}.bpk-chatbot-input--composer--with-shadow:focus-within{box-shadow:0px 12px 50px 0px rgba(37,32,31,.25)}.bpk-chatbot-input--composer--overLimit{transform:translateY(-0.25rem)}
@@ -0,0 +1,9 @@
1
+ export interface SendButtonProps {
2
+ ariaLabel: string;
3
+ isCars?: boolean;
4
+ disabled?: boolean;
5
+ isLoading?: boolean;
6
+ onClick: () => void;
7
+ }
8
+ declare const SendButton: ({ ariaLabel, disabled, isCars, isLoading, onClick, }: SendButtonProps) => import("react/jsx-runtime").JSX.Element;
9
+ export default SendButton;
@@ -0,0 +1,47 @@
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 BpkButton, { BUTTON_TYPES, SIZE_TYPES } from "../../../bpk-component-button";
20
+ import { withRtlSupport, withButtonAlignment } from "../../../bpk-component-icon";
21
+ import ArrowRightIcon from "../../../bpk-component-icon/sm/long-arrow-right";
22
+ import ArrowUpIcon from "../../../bpk-component-icon/sm/long-arrow-up";
23
+ import { jsx as _jsx } from "react/jsx-runtime";
24
+ const AlignedArrowRightIcon = withButtonAlignment(withRtlSupport(ArrowRightIcon));
25
+ const AlignedArrowUpIcon = withButtonAlignment(ArrowUpIcon);
26
+ const SendButton = ({
27
+ ariaLabel,
28
+ disabled = false,
29
+ isCars = true,
30
+ isLoading = false,
31
+ onClick
32
+ }) => {
33
+ const buttonType = isCars ? BUTTON_TYPES.featured : BUTTON_TYPES.primary;
34
+ const Icon = isCars ? AlignedArrowRightIcon : AlignedArrowUpIcon;
35
+ return /*#__PURE__*/_jsx(BpkButton, {
36
+ type: buttonType,
37
+ size: SIZE_TYPES.small,
38
+ iconOnly: true,
39
+ loading: isLoading,
40
+ onClick: onClick,
41
+ disabled: disabled,
42
+ "aria-label": ariaLabel,
43
+ "data-testid": isLoading ? 'bpk-chatbot-input-loading' : 'bpk-chatbot-input-send',
44
+ children: /*#__PURE__*/_jsx(Icon, {})
45
+ });
46
+ };
47
+ export default SendButton;
@@ -5,7 +5,6 @@ interface TextAreaFieldProps extends BaseInputFieldProps {
5
5
  isCapped: boolean;
6
6
  isExpanding: boolean;
7
7
  isComposer: boolean;
8
- maxLines?: number;
9
8
  }
10
9
  declare const TextAreaField: import("react").ForwardRefExoticComponent<TextAreaFieldProps & import("react").RefAttributes<HTMLTextAreaElement>>;
11
10
  export default TextAreaField;
@@ -30,7 +30,6 @@ const TextAreaField = /*#__PURE__*/forwardRef(({
30
30
  isComposer,
31
31
  isExpanding,
32
32
  isOverLimit = false,
33
- maxLines,
34
33
  onInputBlur,
35
34
  onInputChange,
36
35
  onInputClick,
@@ -85,10 +84,7 @@ const TextAreaField = /*#__PURE__*/forwardRef(({
85
84
  rows: 1,
86
85
  style: {
87
86
  height: `${textareaHeight}px`,
88
- resize: 'none',
89
- ...(maxLines !== undefined && {
90
- maxHeight: `${textareaHeight}px`
91
- })
87
+ resize: 'none'
92
88
  }
93
89
  })]
94
90
  })
@@ -1,19 +1,11 @@
1
- import type { KeyboardEvent, ReactElement, ReactNode } from 'react';
2
- import type { Props as BpkButtonProps } from '../../bpk-component-button';
3
- import type { BpkStackProps } from '../../bpk-component-layout';
1
+ import type { KeyboardEvent } from 'react';
4
2
  export declare const CHATBOT_INPUT_TYPES: {
5
3
  readonly CARS: "cars";
6
4
  readonly CARS_COMPOSER: "cars-composer";
7
5
  readonly COMPOSER: "composer";
8
6
  };
9
7
  export type ChatbotInputType = (typeof CHATBOT_INPUT_TYPES)[keyof typeof CHATBOT_INPUT_TYPES];
10
- export type SendButtonRenderProps = {
11
- disabled: boolean;
12
- onClick: () => void;
13
- loading: boolean;
14
- ariaLabel: string;
15
- };
16
- export type BpkChatbotInputInputProps = {
8
+ export type BpkChatbotInputProps = {
17
9
  inputValue: string;
18
10
  /** Accessible label for the loading state button (required for screen readers). */
19
11
  loadingAriaLabel: string;
@@ -26,22 +18,10 @@ export type BpkChatbotInputInputProps = {
26
18
  placeholder: string;
27
19
  isSending?: boolean;
28
20
  isPolling?: boolean;
21
+ inputType?: ChatbotInputType;
29
22
  maxCharacters?: number;
30
- /** Maximum number of visible lines before the textarea scrolls. Defaults to 4 (expanding to 5 when content exceeds 4 lines). Only applies to multiline input types. */
31
- maxLines?: number;
32
23
  onInputClick?: () => void;
33
24
  onKeyDown?: (e: KeyboardEvent) => void;
34
- /** Optional render prop for customising the send button. The consumer should return a BpkButton with the supplied props. When omitted, the default send button is used. */
35
- renderSendButton?: (props: SendButtonRenderProps) => ReactElement<BpkButtonProps>;
36
- };
37
- export type BpkChatbotInputRootProps = BpkStackProps & {
38
- inputType?: ChatbotInputType;
39
- };
40
- export type BpkChatbotInputToolbarProps = BpkStackProps;
41
- export type BpkChatbotInputNamespace = {
42
- Root: (props: BpkChatbotInputRootProps) => ReactNode;
43
- Input: (props: BpkChatbotInputInputProps) => ReactNode;
44
- Toolbar: (props: BpkChatbotInputToolbarProps) => ReactNode;
45
25
  };
46
26
  export interface BaseInputFieldProps {
47
27
  value: string;
@@ -11,7 +11,6 @@ interface UseChatbotInputOptions {
11
11
  isPolling?: boolean;
12
12
  inputType?: ChatbotInputType;
13
13
  maxCharacters?: number;
14
- maxLines?: number;
15
14
  onInputClick?: () => void;
16
15
  onKeyDown?: (e: KeyboardEvent) => void;
17
16
  }
@@ -29,5 +28,5 @@ interface UseChatbotInputReturn {
29
28
  textareaHeight: number;
30
29
  isCapped: boolean;
31
30
  }
32
- declare const useChatbotInput: ({ inputType, inputValue, isPolling, isSending, maxCharacters, maxLines, onInputBlur, onInputChange, onInputClick, onInputFocus, onKeyDown, onSubmit, placeholder, }: UseChatbotInputOptions) => UseChatbotInputReturn;
31
+ declare const useChatbotInput: ({ inputType, inputValue, isPolling, isSending, maxCharacters, onInputBlur, onInputChange, onInputClick, onInputFocus, onKeyDown, onSubmit, placeholder, }: UseChatbotInputOptions) => UseChatbotInputReturn;
33
32
  export default useChatbotInput;
@@ -26,7 +26,6 @@ const useChatbotInput = ({
26
26
  isPolling = false,
27
27
  isSending = false,
28
28
  maxCharacters = MAX_CHARACTERS,
29
- maxLines,
30
29
  onInputBlur,
31
30
  onInputChange,
32
31
  onInputClick = () => {},
@@ -49,8 +48,7 @@ const useChatbotInput = ({
49
48
  } = useTextAreaAutoResize({
50
49
  ref: inputRef,
51
50
  value: inputValue,
52
- enabled: isMultiLine,
53
- maxLines
51
+ enabled: isMultiLine
54
52
  });
55
53
  const handleSubmit = useCallback(() => {
56
54
  if (inputValue.trim() && !isDisabled && !isOverLimit) {
@@ -3,7 +3,6 @@ interface UseTextAreaAutoResizeProps {
3
3
  ref: RefObject<HTMLTextAreaElement>;
4
4
  value: string;
5
5
  enabled?: boolean;
6
- maxLines?: number;
7
6
  }
8
7
  interface UseTextAreaAutoResizeReturn {
9
8
  isExpanding: boolean;
@@ -19,5 +18,5 @@ export declare const MAX_INPUT_HEIGHT_PHASE_2: number;
19
18
  export declare const MIN_CONTAINER_HEIGHT = 24;
20
19
  export declare const MAX_CONTAINER_HEIGHT = 96;
21
20
  export declare const PARENT_PADDING_TOP = 16;
22
- declare const useTextAreaAutoResize: ({ enabled, maxLines, ref, value, }: UseTextAreaAutoResizeProps) => UseTextAreaAutoResizeReturn;
21
+ declare const useTextAreaAutoResize: ({ enabled, ref, value, }: UseTextAreaAutoResizeProps) => UseTextAreaAutoResizeReturn;
23
22
  export default useTextAreaAutoResize;
@@ -26,7 +26,6 @@ export const MAX_CONTAINER_HEIGHT = 96;
26
26
  export const PARENT_PADDING_TOP = 16;
27
27
  const useTextAreaAutoResize = ({
28
28
  enabled = true,
29
- maxLines,
30
29
  ref,
31
30
  value
32
31
  }) => {
@@ -100,27 +99,15 @@ const useTextAreaAutoResize = ({
100
99
  scrollHeight
101
100
  } = measureEl;
102
101
  const lines = Math.max(1, Math.ceil(scrollHeight / lineHeightRef.current));
103
- const hasCustomMaxLines = maxLines !== undefined;
104
- const isCapped = hasCustomMaxLines ? lines >= maxLines : lines >= 5;
105
- let maxInputHeight;
106
- if (hasCustomMaxLines) {
107
- maxInputHeight = lineHeightRef.current * maxLines;
108
- } else {
109
- maxInputHeight = isCapped ? MAX_INPUT_HEIGHT_PHASE_2 : MAX_INPUT_HEIGHT_PHASE_1;
110
- }
102
+ const isCapped = lines >= 5;
103
+ const maxInputHeight = isCapped ? MAX_INPUT_HEIGHT_PHASE_2 : MAX_INPUT_HEIGHT_PHASE_1;
111
104
  const targetInputHeight = Math.max(MIN_INPUT_HEIGHT, Math.min(scrollHeight, maxInputHeight));
112
- const customMaxContainerHeight = hasCustomMaxLines ? lineHeightRef.current * maxLines : MAX_CONTAINER_HEIGHT;
113
- const extraSpace = isCapped && !hasCustomMaxLines ? PARENT_PADDING_TOP : 0;
114
- const targetContainerHeight = Math.max(MIN_CONTAINER_HEIGHT, Math.min(targetInputHeight - extraSpace, customMaxContainerHeight));
105
+ const extraSpace = isCapped ? PARENT_PADDING_TOP : 0;
106
+ const targetContainerHeight = Math.max(MIN_CONTAINER_HEIGHT, Math.min(targetInputHeight - extraSpace, MAX_CONTAINER_HEIGHT));
115
107
  setDimensions(prev => {
116
108
  const isContentAdded = value.length > previousValueRef.current.length;
117
109
  const isAppending = value.startsWith(previousValueRef.current);
118
- let prevMaxHeight;
119
- if (hasCustomMaxLines) {
120
- prevMaxHeight = lineHeightRef.current * maxLines;
121
- } else {
122
- prevMaxHeight = prev.isCapped ? MAX_INPUT_HEIGHT_PHASE_2 : MAX_INPUT_HEIGHT_PHASE_1;
123
- }
110
+ const prevMaxHeight = prev.isCapped ? MAX_INPUT_HEIGHT_PHASE_2 : MAX_INPUT_HEIGHT_PHASE_1;
124
111
  const isInitialRender = isInitialRenderRef.current;
125
112
  const shouldScroll = isContentAdded && isAppending && textarea.scrollHeight > prevMaxHeight || isInitialRender && scrollHeight > maxInputHeight;
126
113
  shouldScrollRef.current = shouldScroll;
@@ -135,7 +122,7 @@ const useTextAreaAutoResize = ({
135
122
  };
136
123
  });
137
124
  previousValueRef.current = value;
138
- }, [value, ref, enabled, containerWidth, maxLines]);
125
+ }, [value, ref, enabled, containerWidth]);
139
126
  useLayoutEffect(() => {
140
127
  if (shouldScrollRef.current) {
141
128
  scrollToBottom();