@skyscanner/backpack-web 42.1.0 → 42.3.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-banner-alert/src/BpkBannerAlert.js +0 -7
- package/bpk-component-breakpoint/src/BpkBreakpoint.js +3 -1
- package/bpk-component-calendar/src/utils.js +1 -1
- package/bpk-component-card/index.d.ts +4 -1
- package/bpk-component-card/index.js +3 -1
- package/bpk-component-card/src/BpkCardV2/BpkCardV2.d.ts +27 -0
- package/bpk-component-card/src/BpkCardV2/BpkCardV2.js +57 -0
- package/bpk-component-card/src/BpkCardV2/BpkCardV2.module.css +18 -0
- package/bpk-component-card/src/BpkCardV2/common-types.d.ts +124 -0
- package/bpk-component-card/src/BpkCardV2/common-types.js +102 -0
- package/bpk-component-card/src/BpkCardV2/subcomponents/Body.d.ts +36 -0
- package/bpk-component-card/src/BpkCardV2/subcomponents/Body.js +65 -0
- package/bpk-component-card/src/BpkCardV2/subcomponents/Divider.d.ts +13 -0
- package/bpk-component-card/src/BpkCardV2/subcomponents/Divider.js +37 -0
- package/bpk-component-card/src/BpkCardV2/subcomponents/Footer.d.ts +24 -0
- package/bpk-component-card/src/BpkCardV2/subcomponents/Footer.js +60 -0
- package/bpk-component-card/src/BpkCardV2/subcomponents/Header.d.ts +24 -0
- package/bpk-component-card/src/BpkCardV2/subcomponents/Header.js +60 -0
- package/bpk-component-card/src/BpkCardV2/subcomponents/Root.d.ts +28 -0
- package/bpk-component-card/src/BpkCardV2/subcomponents/Root.js +68 -0
- package/bpk-component-card/src/BpkCardV2/subcomponents/Section.d.ts +22 -0
- package/bpk-component-card/src/BpkCardV2/subcomponents/Section.js +53 -0
- package/bpk-component-card/src/BpkCardV2/subcomponents/resolveDirectionalPadding.d.ts +16 -0
- package/bpk-component-card/src/BpkCardV2/subcomponents/resolveDirectionalPadding.js +32 -0
- package/bpk-component-card-list/src/BpkCardList.module.css +1 -1
- package/bpk-component-card-list/src/BpkCardListRowRail/BpkCardListCarousel.js +3 -3
- package/bpk-component-chat-bubble/index.d.ts +4 -0
- package/bpk-component-chat-bubble/index.js +21 -0
- package/bpk-component-chat-bubble/src/BpkChatBubble.d.ts +3 -0
- package/bpk-component-chat-bubble/src/BpkChatBubble.js +107 -0
- package/bpk-component-chat-bubble/src/BpkChatBubble.module.css +18 -0
- package/bpk-component-chat-bubble/src/common-types.d.ts +55 -0
- package/bpk-component-chat-bubble/src/common-types.js +29 -0
- package/bpk-component-chatbot-input/index.d.ts +7 -0
- package/bpk-component-chatbot-input/index.js +23 -0
- package/bpk-component-chatbot-input/src/BpkChatbotInput.d.ts +4 -0
- package/bpk-component-chatbot-input/src/BpkChatbotInput.js +118 -0
- package/bpk-component-chatbot-input/src/BpkChatbotInput.module.css +18 -0
- package/bpk-component-chatbot-input/src/InputField/InputField.d.ts +3 -0
- package/bpk-component-chatbot-input/src/InputField/InputField.js +82 -0
- package/bpk-component-chatbot-input/src/InputField/InputField.module.css +18 -0
- 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 +10 -0
- package/bpk-component-chatbot-input/src/TextAreaField/TextAreaField.js +93 -0
- package/bpk-component-chatbot-input/src/TextAreaField/TextAreaField.module.css +18 -0
- package/bpk-component-chatbot-input/src/common-types.d.ts +37 -0
- package/bpk-component-chatbot-input/src/common-types.js +23 -0
- package/bpk-component-chatbot-input/src/constants.d.ts +5 -0
- package/bpk-component-chatbot-input/src/constants.js +22 -0
- package/bpk-component-chatbot-input/src/hooks/index.d.ts +4 -0
- package/bpk-component-chatbot-input/src/hooks/index.js +22 -0
- package/bpk-component-chatbot-input/src/hooks/useChatbotInput.d.ts +32 -0
- package/bpk-component-chatbot-input/src/hooks/useChatbotInput.js +111 -0
- package/bpk-component-chatbot-input/src/hooks/useChatbotInputManager.d.ts +20 -0
- package/bpk-component-chatbot-input/src/hooks/useChatbotInputManager.js +83 -0
- package/bpk-component-chatbot-input/src/hooks/useInputHandlers.d.ts +8 -0
- package/bpk-component-chatbot-input/src/hooks/useInputHandlers.js +54 -0
- package/bpk-component-chatbot-input/src/hooks/useTextAreaAutoResize.d.ts +22 -0
- package/bpk-component-chatbot-input/src/hooks/useTextAreaAutoResize.js +137 -0
- package/bpk-component-chatbot-input/src/themeAttributes.d.ts +14 -0
- package/bpk-component-chatbot-input/src/themeAttributes.js +34 -0
- package/bpk-component-checkbox/index.d.ts +8 -8
- package/bpk-component-checkbox/index.js +3 -3
- package/bpk-component-checkbox/src/BpkCheckboxV2/BpkCheckboxV2.d.ts +9 -0
- package/bpk-component-checkbox/src/BpkCheckboxV2/{BpkCheckbox.js → BpkCheckboxV2.js} +14 -14
- package/bpk-component-checkbox/src/BpkCheckboxV2/BpkCheckboxV2Control.d.ts +6 -0
- package/bpk-component-checkbox/src/BpkCheckboxV2/{BpkCheckboxControl.js → BpkCheckboxV2Control.js} +3 -3
- package/bpk-component-checkbox/src/BpkCheckboxV2/BpkCheckboxV2Description.d.ts +6 -0
- package/bpk-component-checkbox/src/BpkCheckboxV2/{BpkCheckboxDescription.js → BpkCheckboxV2Description.js} +3 -3
- package/bpk-component-checkbox/src/BpkCheckboxV2/BpkCheckboxV2HiddenInput.d.ts +2 -0
- package/bpk-component-checkbox/src/BpkCheckboxV2/{BpkCheckboxHiddenInput.js → BpkCheckboxV2HiddenInput.js} +2 -2
- package/bpk-component-checkbox/src/BpkCheckboxV2/BpkCheckboxV2Indicator.d.ts +2 -0
- package/bpk-component-checkbox/src/BpkCheckboxV2/{BpkCheckboxIndicator.js → BpkCheckboxV2Indicator.js} +3 -3
- package/bpk-component-checkbox/src/BpkCheckboxV2/BpkCheckboxV2Label.d.ts +6 -0
- package/bpk-component-checkbox/src/BpkCheckboxV2/{BpkCheckboxLabel.js → BpkCheckboxV2Label.js} +3 -3
- package/bpk-component-checkbox/src/BpkCheckboxV2/BpkCheckboxV2Root.d.ts +16 -0
- package/bpk-component-checkbox/src/BpkCheckboxV2/{BpkCheckboxRoot.js → BpkCheckboxV2Root.js} +3 -3
- package/bpk-component-checkbox-card/src/BpkCheckboxCard.module.css +1 -1
- package/bpk-component-floating-notification/index.d.ts +2 -1
- package/bpk-component-floating-notification/index.js +2 -1
- package/bpk-component-floating-notification/src/BpkFloatingNotification.d.ts +5 -0
- package/bpk-component-floating-notification/src/BpkFloatingNotification.js +8 -2
- package/bpk-component-floating-notification/src/BpkFloatingNotification.module.css +1 -1
- package/bpk-component-icon/scripts/generate-figma-connect.js +267 -0
- package/bpk-component-info-banner/src/BpkInfoBanner.module.css +1 -1
- package/bpk-component-info-banner/src/BpkInfoBannerInner.js +8 -3
- package/bpk-component-info-banner/src/common-types.d.ts +1 -0
- package/bpk-component-info-banner/src/common-types.js +2 -1
- package/bpk-component-inset-banner/index.d.ts +4 -1
- package/bpk-component-inset-banner/index.js +2 -1
- package/bpk-component-inset-banner/src/BpkInsetBannerV3/BpkInsetBannerV3.d.ts +56 -0
- package/bpk-component-inset-banner/src/BpkInsetBannerV3/BpkInsetBannerV3.js +118 -0
- package/bpk-component-inset-banner/src/BpkInsetBannerV3/BpkInsetBannerV3.module.css +18 -0
- package/bpk-component-layout/src/BpkProvider.d.ts +9 -4
- package/bpk-component-layout/src/BpkProvider.js +87 -8
- package/bpk-component-layout/src/types.d.ts +2 -2
- package/bpk-component-link/src/common-types.d.ts +1 -1
- package/bpk-component-modal/index.d.ts +3 -1
- package/bpk-component-modal/index.js +3 -1
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3.d.ts +14 -0
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3.js +43 -0
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3Body/BpkModalV3Body.d.ts +7 -0
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3Body/BpkModalV3Body.js +30 -0
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3Body/BpkModalV3Body.module.css +18 -0
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3CloseTrigger/BpkModalV3CloseTrigger.d.ts +7 -0
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3CloseTrigger/BpkModalV3CloseTrigger.js +49 -0
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3CloseTrigger/BpkModalV3CloseTrigger.module.css +18 -0
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3Content/BpkModalV3Content.d.ts +7 -0
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3Content/BpkModalV3Content.js +38 -0
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3Content/BpkModalV3Content.module.css +18 -0
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3Context.d.ts +3 -0
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3Context.js +22 -0
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3Description/BpkModalV3Description.d.ts +7 -0
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3Description/BpkModalV3Description.js +28 -0
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3Header/BpkModalV3Header.d.ts +7 -0
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3Header/BpkModalV3Header.js +34 -0
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3Header/BpkModalV3Header.module.css +18 -0
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3HeroImage/BpkModalV3HeroImage.d.ts +10 -0
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3HeroImage/BpkModalV3HeroImage.js +44 -0
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3HeroImage/BpkModalV3HeroImage.module.css +18 -0
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3Portal/BpkModalV3Portal.d.ts +7 -0
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3Portal/BpkModalV3Portal.js +26 -0
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3Root/BpkModalV3Root.d.ts +13 -0
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3Root/BpkModalV3Root.js +67 -0
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3Root/useBodyLock.d.ts +9 -0
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3Root/useBodyLock.js +69 -0
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3Scrim/BpkModalV3Scrim.d.ts +2 -0
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3Scrim/BpkModalV3Scrim.js +32 -0
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3Scrim/BpkModalV3Scrim.module.css +18 -0
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3Title/BpkModalV3Title.d.ts +7 -0
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3Title/BpkModalV3Title.js +31 -0
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3Title/BpkModalV3Title.module.css +18 -0
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3Trigger/BpkModalV3Trigger.d.ts +8 -0
- package/bpk-component-modal/src/BpkModalV3/BpkModalV3Trigger/BpkModalV3Trigger.js +30 -0
- package/bpk-component-modal/src/BpkModalV3/common-types.d.ts +7 -0
- package/bpk-component-modal/src/BpkModalV3/common-types.js +24 -0
- package/bpk-component-page-indicator/src/NavButton.d.ts +2 -1
- package/bpk-component-segmented-control/src/BpkSegmentedControlV2/BpkSegmentedControlV2.js +37 -16
- package/bpk-component-skeleton/src/BpkBaseSkeleton.d.d.ts +1 -0
- package/bpk-component-skeleton/src/BpkSkeleton.d.d.ts +1 -0
- package/bpk-component-table/index.d.ts +2 -1
- package/bpk-component-table/index.js +2 -1
- package/bpk-component-table/src/BpkTable.module.css +1 -1
- package/bpk-component-table/src/BpkTableBody.d.ts +4 -1
- package/bpk-component-table/src/BpkTableBody.js +19 -4
- package/bpk-component-table/src/common-types.d.ts +5 -0
- package/bpk-component-table/src/common-types.js +22 -0
- package/bpk-react-utils/src/Portal.d.ts +1 -1
- package/package.json +2 -2
- package/bpk-component-checkbox/src/BpkCheckboxV2/BpkCheckbox.d.ts +0 -9
- package/bpk-component-checkbox/src/BpkCheckboxV2/BpkCheckboxControl.d.ts +0 -6
- package/bpk-component-checkbox/src/BpkCheckboxV2/BpkCheckboxDescription.d.ts +0 -6
- package/bpk-component-checkbox/src/BpkCheckboxV2/BpkCheckboxHiddenInput.d.ts +0 -2
- package/bpk-component-checkbox/src/BpkCheckboxV2/BpkCheckboxIndicator.d.ts +0 -2
- package/bpk-component-checkbox/src/BpkCheckboxV2/BpkCheckboxLabel.d.ts +0 -6
- package/bpk-component-checkbox/src/BpkCheckboxV2/BpkCheckboxRoot.d.ts +0 -16
- /package/bpk-component-checkbox/src/BpkCheckboxV2/{BpkCheckbox.module.css → BpkCheckboxV2.module.css} +0 -0
|
@@ -0,0 +1,118 @@
|
|
|
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 { 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
|
+
});
|
|
117
|
+
};
|
|
118
|
+
export default BpkChatbotInput;
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
.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,82 @@
|
|
|
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 { forwardRef, useId } from 'react';
|
|
20
|
+
import { cssModules } from "../../../bpk-react-utils";
|
|
21
|
+
import { useInputHandlers } from "../hooks";
|
|
22
|
+
import STYLES from "./InputField.module.css";
|
|
23
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
24
|
+
const getClassName = cssModules(STYLES);
|
|
25
|
+
const InputField = /*#__PURE__*/forwardRef(({
|
|
26
|
+
dataTestId,
|
|
27
|
+
disabled = false,
|
|
28
|
+
onInputBlur,
|
|
29
|
+
onInputChange,
|
|
30
|
+
onInputClick,
|
|
31
|
+
onInputFocus,
|
|
32
|
+
onKeyDown,
|
|
33
|
+
placeholder,
|
|
34
|
+
value
|
|
35
|
+
}, ref) => {
|
|
36
|
+
const {
|
|
37
|
+
handleInputChange,
|
|
38
|
+
handleInputClick,
|
|
39
|
+
handleTouchEnd,
|
|
40
|
+
handleTouchStart
|
|
41
|
+
} = useInputHandlers(ref, onInputChange, onInputClick);
|
|
42
|
+
const id = useId();
|
|
43
|
+
const handleWrapperEvent = e => {
|
|
44
|
+
e.stopPropagation();
|
|
45
|
+
};
|
|
46
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
47
|
+
className: getClassName('bpk-chatbot-input-field'),
|
|
48
|
+
onClick: handleWrapperEvent,
|
|
49
|
+
onTouchStart: handleWrapperEvent,
|
|
50
|
+
role: "presentation",
|
|
51
|
+
children: [/*#__PURE__*/_jsx("label", {
|
|
52
|
+
htmlFor: id,
|
|
53
|
+
className: getClassName('bpk-chatbot-input-field__label'),
|
|
54
|
+
children: placeholder
|
|
55
|
+
}), /*#__PURE__*/_jsx("input", {
|
|
56
|
+
ref: ref,
|
|
57
|
+
id: id,
|
|
58
|
+
type: "text",
|
|
59
|
+
className: getClassName('bpk-chatbot-input-field__input'),
|
|
60
|
+
placeholder: placeholder,
|
|
61
|
+
value: value,
|
|
62
|
+
onChange: handleInputChange,
|
|
63
|
+
onKeyDown: onKeyDown,
|
|
64
|
+
onFocus: onInputFocus,
|
|
65
|
+
onBlur: onInputBlur,
|
|
66
|
+
onClick: handleInputClick,
|
|
67
|
+
onTouchStart: handleTouchStart,
|
|
68
|
+
onTouchEnd: handleTouchEnd,
|
|
69
|
+
disabled: disabled,
|
|
70
|
+
"aria-label": placeholder,
|
|
71
|
+
autoComplete: "off",
|
|
72
|
+
autoCorrect: "off",
|
|
73
|
+
autoCapitalize: "sentences",
|
|
74
|
+
spellCheck: "true",
|
|
75
|
+
tabIndex: 0,
|
|
76
|
+
inputMode: "text",
|
|
77
|
+
enterKeyHint: "send",
|
|
78
|
+
"data-testid": dataTestId
|
|
79
|
+
})]
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
export default InputField;
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
.bpk-chatbot-input-field{position:relative;min-width:0;flex:1;cursor:text;overflow:visible;touch-action:manipulation}.bpk-chatbot-input-field__label{position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;white-space:nowrap;overflow:hidden;clip:rect(0 0 0 0)}.bpk-chatbot-input-field__input{width:100%;padding:0;border:none;outline:none;background:rgba(0,0,0,0);color:#161616;text-overflow:ellipsis;white-space:nowrap;overflow:hidden;appearance:none;box-sizing:border-box;caret-color:#0062e3;touch-action:manipulation;font-size:.875rem;line-height:1.25rem;font-weight:400}@media(max-width: 32rem){.bpk-chatbot-input-field__input{font-size:1rem;line-height:1.5rem;font-weight:400}}.bpk-chatbot-input-field__input::placeholder{color:#626971;opacity:1}.bpk-chatbot-input-field__input:disabled{color:rgba(0,0,0,.2);cursor:not-allowed;opacity:1}
|
|
@@ -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;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { BaseInputFieldProps } from '../common-types';
|
|
2
|
+
interface TextAreaFieldProps extends BaseInputFieldProps {
|
|
3
|
+
containerHeight: number;
|
|
4
|
+
textareaHeight: number;
|
|
5
|
+
isCapped: boolean;
|
|
6
|
+
isExpanding: boolean;
|
|
7
|
+
isComposer: boolean;
|
|
8
|
+
}
|
|
9
|
+
declare const TextAreaField: import("react").ForwardRefExoticComponent<TextAreaFieldProps & import("react").RefAttributes<HTMLTextAreaElement>>;
|
|
10
|
+
export default TextAreaField;
|
|
@@ -0,0 +1,93 @@
|
|
|
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 { forwardRef, useId } from 'react';
|
|
20
|
+
import { cssModules } from "../../../bpk-react-utils";
|
|
21
|
+
import { useInputHandlers } from "../hooks";
|
|
22
|
+
import STYLES from "./TextAreaField.module.css";
|
|
23
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
24
|
+
const getClassName = cssModules(STYLES);
|
|
25
|
+
const TextAreaField = /*#__PURE__*/forwardRef(({
|
|
26
|
+
containerHeight,
|
|
27
|
+
dataTestId,
|
|
28
|
+
disabled = false,
|
|
29
|
+
isCapped,
|
|
30
|
+
isComposer,
|
|
31
|
+
isExpanding,
|
|
32
|
+
isOverLimit = false,
|
|
33
|
+
onInputBlur,
|
|
34
|
+
onInputChange,
|
|
35
|
+
onInputClick,
|
|
36
|
+
onInputFocus,
|
|
37
|
+
onKeyDown,
|
|
38
|
+
placeholder,
|
|
39
|
+
textareaHeight,
|
|
40
|
+
value
|
|
41
|
+
}, ref) => {
|
|
42
|
+
const {
|
|
43
|
+
handleInputChange,
|
|
44
|
+
handleInputClick,
|
|
45
|
+
handleTouchEnd,
|
|
46
|
+
handleTouchStart
|
|
47
|
+
} = useInputHandlers(ref, onInputChange, onInputClick);
|
|
48
|
+
const id = useId();
|
|
49
|
+
return /*#__PURE__*/_jsx("div", {
|
|
50
|
+
className: getClassName('bpk-chatbot-textarea-field__container', {
|
|
51
|
+
'bpk-chatbot-textarea-field__container--expanding': isExpanding,
|
|
52
|
+
'bpk-chatbot-textarea-field__container--overLimit': isOverLimit
|
|
53
|
+
}),
|
|
54
|
+
style: {
|
|
55
|
+
height: `${containerHeight}px`
|
|
56
|
+
},
|
|
57
|
+
children: /*#__PURE__*/_jsxs("div", {
|
|
58
|
+
className: getClassName('bpk-chatbot-textarea-field__field', isCapped && 'bpk-chatbot-textarea-field__field--capped'),
|
|
59
|
+
children: [/*#__PURE__*/_jsx("label", {
|
|
60
|
+
htmlFor: id,
|
|
61
|
+
className: getClassName('bpk-chatbot-textarea-field__label'),
|
|
62
|
+
children: placeholder
|
|
63
|
+
}), /*#__PURE__*/_jsx("textarea", {
|
|
64
|
+
ref: ref,
|
|
65
|
+
id: id,
|
|
66
|
+
className: getClassName('bpk-chatbot-textarea-field__textarea', isComposer && 'bpk-chatbot-textarea-field__textarea--with-shadow'),
|
|
67
|
+
placeholder: placeholder,
|
|
68
|
+
value: value,
|
|
69
|
+
onChange: handleInputChange,
|
|
70
|
+
onKeyDown: onKeyDown,
|
|
71
|
+
onFocus: onInputFocus,
|
|
72
|
+
onBlur: onInputBlur,
|
|
73
|
+
onClick: handleInputClick,
|
|
74
|
+
onTouchStart: handleTouchStart,
|
|
75
|
+
onTouchEnd: handleTouchEnd,
|
|
76
|
+
disabled: disabled,
|
|
77
|
+
"aria-label": placeholder,
|
|
78
|
+
autoComplete: "off",
|
|
79
|
+
autoCorrect: "off",
|
|
80
|
+
autoCapitalize: "sentences",
|
|
81
|
+
spellCheck: "true",
|
|
82
|
+
tabIndex: 0,
|
|
83
|
+
"data-testid": dataTestId,
|
|
84
|
+
rows: 1,
|
|
85
|
+
style: {
|
|
86
|
+
height: `${textareaHeight}px`,
|
|
87
|
+
resize: 'none'
|
|
88
|
+
}
|
|
89
|
+
})]
|
|
90
|
+
})
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
export default TextAreaField;
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
.bpk-chatbot-textarea-field__container{position:relative;display:flex;width:100%;align-items:center;transition:height .3s cubic-bezier(0.4, 0, 0.2, 1),padding .3s cubic-bezier(0.4, 0, 0.2, 1),transform .3s cubic-bezier(0.4, 0, 0.2, 1);will-change:height,padding,transform}.bpk-chatbot-textarea-field__container--expanding{align-items:flex-start}.bpk-chatbot-textarea-field__container--overLimit{padding-top:1rem;align-items:flex-end}.bpk-chatbot-textarea-field__field{position:relative;display:flex;width:100%;min-width:0;align-items:center;flex:1;cursor:text;overflow:visible}.bpk-chatbot-textarea-field__field--capped{padding-bottom:1rem}.bpk-chatbot-textarea-field__label{position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;white-space:nowrap;overflow:hidden;clip:rect(0 0 0 0)}.bpk-chatbot-textarea-field__textarea{width:100%;height:1.5rem;min-height:1.5rem;max-height:6.875rem;margin:0;padding:0;transition:height .3s cubic-bezier(0.4, 0, 0.2, 1),transform .3s cubic-bezier(0.4, 0, 0.2, 1),opacity .3s cubic-bezier(0.4, 0, 0.2, 1);border:none;outline:none;background:rgba(0,0,0,0);color:#161616;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;text-rendering:optimizelegibility;white-space:pre-wrap;overflow-x:hidden;overflow-y:auto;box-sizing:border-box;caret-color:#0062e3;overflow-wrap:break-word;resize:none;scrollbar-width:none;word-wrap:break-word;font-size:1rem;line-height:1.5rem;font-weight:400}.bpk-chatbot-textarea-field__textarea::placeholder{color:#626971;opacity:1}.bpk-chatbot-textarea-field__textarea:disabled{color:rgba(0,0,0,.2);cursor:not-allowed;opacity:.6}.bpk-chatbot-textarea-field__textarea::-webkit-scrollbar{display:none}.bpk-chatbot-textarea-field__textarea--with-shadow::placeholder{color:#161616}.bpk-chatbot-textarea-field__textarea--with-shadow:focus::placeholder{opacity:0}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { KeyboardEvent } from 'react';
|
|
2
|
+
export declare const CHATBOT_INPUT_TYPES: {
|
|
3
|
+
readonly CARS: "cars";
|
|
4
|
+
readonly CARS_COMPOSER: "cars-composer";
|
|
5
|
+
readonly COMPOSER: "composer";
|
|
6
|
+
};
|
|
7
|
+
export type ChatbotInputType = (typeof CHATBOT_INPUT_TYPES)[keyof typeof CHATBOT_INPUT_TYPES];
|
|
8
|
+
export type BpkChatbotInputProps = {
|
|
9
|
+
inputValue: string;
|
|
10
|
+
/** Accessible label for the loading state button (required for screen readers). */
|
|
11
|
+
loadingAriaLabel: string;
|
|
12
|
+
/** Accessible label for the send button (required for screen readers). */
|
|
13
|
+
sendAriaLabel: string;
|
|
14
|
+
onInputChange: (value: string) => void;
|
|
15
|
+
onInputFocus: () => void;
|
|
16
|
+
onInputBlur: () => void;
|
|
17
|
+
onSubmit: () => void | Promise<void>;
|
|
18
|
+
placeholder: string;
|
|
19
|
+
isSending?: boolean;
|
|
20
|
+
isPolling?: boolean;
|
|
21
|
+
inputType?: ChatbotInputType;
|
|
22
|
+
maxCharacters?: number;
|
|
23
|
+
onInputClick?: () => void;
|
|
24
|
+
onKeyDown?: (e: KeyboardEvent) => void;
|
|
25
|
+
};
|
|
26
|
+
export interface BaseInputFieldProps {
|
|
27
|
+
value: string;
|
|
28
|
+
placeholder: string;
|
|
29
|
+
disabled?: boolean;
|
|
30
|
+
isOverLimit?: boolean;
|
|
31
|
+
dataTestId: string;
|
|
32
|
+
onInputChange: (value: string) => void;
|
|
33
|
+
onInputFocus: () => void;
|
|
34
|
+
onInputBlur: () => void;
|
|
35
|
+
onInputClick: () => void;
|
|
36
|
+
onKeyDown: (e: KeyboardEvent) => void;
|
|
37
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
export const CHATBOT_INPUT_TYPES = {
|
|
20
|
+
CARS: 'cars',
|
|
21
|
+
CARS_COMPOSER: 'cars-composer',
|
|
22
|
+
COMPOSER: 'composer'
|
|
23
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
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
|
+
export const MAX_CHARACTERS = 500;
|
|
20
|
+
export default {
|
|
21
|
+
MAX_CHARACTERS
|
|
22
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { default as useChatbotInput } from './useChatbotInput';
|
|
2
|
+
export { default as useChatbotInputManager } from './useChatbotInputManager';
|
|
3
|
+
export { default as useInputHandlers } from './useInputHandlers';
|
|
4
|
+
export { default as useTextAreaAutoResize } from './useTextAreaAutoResize';
|
|
@@ -0,0 +1,22 @@
|
|
|
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
|
+
export { default as useChatbotInput } from "./useChatbotInput";
|
|
20
|
+
export { default as useChatbotInputManager } from "./useChatbotInputManager";
|
|
21
|
+
export { default as useInputHandlers } from "./useInputHandlers";
|
|
22
|
+
export { default as useTextAreaAutoResize } from "./useTextAreaAutoResize";
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { KeyboardEvent, RefObject } from 'react';
|
|
2
|
+
import type { BaseInputFieldProps, ChatbotInputType } from '../common-types';
|
|
3
|
+
interface UseChatbotInputOptions {
|
|
4
|
+
inputValue: string;
|
|
5
|
+
onInputChange: (value: string) => void;
|
|
6
|
+
onInputFocus: () => void;
|
|
7
|
+
onInputBlur: () => void;
|
|
8
|
+
onSubmit: () => void | Promise<void>;
|
|
9
|
+
placeholder: string;
|
|
10
|
+
isSending?: boolean;
|
|
11
|
+
isPolling?: boolean;
|
|
12
|
+
inputType?: ChatbotInputType;
|
|
13
|
+
maxCharacters?: number;
|
|
14
|
+
onInputClick?: () => void;
|
|
15
|
+
onKeyDown?: (e: KeyboardEvent) => void;
|
|
16
|
+
}
|
|
17
|
+
interface UseChatbotInputReturn {
|
|
18
|
+
inputRef: RefObject<HTMLInputElement | HTMLTextAreaElement>;
|
|
19
|
+
isFocused: boolean;
|
|
20
|
+
isDisabled: boolean;
|
|
21
|
+
isOverLimit: boolean;
|
|
22
|
+
isExpanding: boolean;
|
|
23
|
+
isCars: boolean;
|
|
24
|
+
sendButtonDisabled: boolean;
|
|
25
|
+
inputProps: BaseInputFieldProps;
|
|
26
|
+
handleSubmit: () => void;
|
|
27
|
+
containerHeight: number;
|
|
28
|
+
textareaHeight: number;
|
|
29
|
+
isCapped: boolean;
|
|
30
|
+
}
|
|
31
|
+
declare const useChatbotInput: ({ inputType, inputValue, isPolling, isSending, maxCharacters, onInputBlur, onInputChange, onInputClick, onInputFocus, onKeyDown, onSubmit, placeholder, }: UseChatbotInputOptions) => UseChatbotInputReturn;
|
|
32
|
+
export default useChatbotInput;
|