botframework-webchat-fluent-theme 4.17.0-main.20240411.ff34969 → 4.17.0-main.20240416.4ff01ae
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/dist/botframework-webchat-fluent-theme.development.css.map +1 -0
- package/dist/botframework-webchat-fluent-theme.development.js +384 -2081
- package/dist/botframework-webchat-fluent-theme.development.js.map +1 -1
- package/dist/botframework-webchat-fluent-theme.production.min.css.map +1 -0
- package/dist/botframework-webchat-fluent-theme.production.min.js +1 -3
- package/dist/botframework-webchat-fluent-theme.production.min.js.map +1 -1
- package/dist/index.css.map +1 -0
- package/dist/index.d.mts +27 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.js +360 -648
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1076 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -8
- package/src/components/Theme.module.css +60 -0
- package/src/components/Theme.tsx +4 -64
- package/src/components/dropZone/index.module.css +23 -0
- package/src/components/dropZone/index.tsx +6 -31
- package/src/components/sendbox/AddAttachmentButton.module.css +10 -0
- package/src/components/sendbox/AddAttachmentButton.tsx +5 -17
- package/src/components/sendbox/Attachments.module.css +7 -0
- package/src/components/sendbox/Attachments.tsx +3 -12
- package/src/components/sendbox/ErrorMessage.module.css +9 -0
- package/src/components/sendbox/ErrorMessage.tsx +2 -13
- package/src/components/sendbox/TelephoneKeypadToolbarButton.tsx +1 -1
- package/src/components/sendbox/TextArea.module.css +61 -0
- package/src/components/sendbox/TextArea.tsx +9 -70
- package/src/components/sendbox/Toolbar.module.css +49 -0
- package/src/components/sendbox/Toolbar.tsx +4 -55
- package/src/components/sendbox/index.module.css +58 -0
- package/src/components/sendbox/index.tsx +16 -81
- package/src/components/suggestedActions/SuggestedAction.module.css +34 -0
- package/src/components/suggestedActions/SuggestedAction.tsx +5 -47
- package/src/components/suggestedActions/index.module.css +23 -0
- package/src/components/suggestedActions/index.tsx +18 -23
- package/src/components/telephoneKeypad/private/Button.module.css +62 -0
- package/src/components/telephoneKeypad/private/Button.tsx +5 -67
- package/src/components/telephoneKeypad/private/TelephoneKeypad.module.css +30 -0
- package/src/components/telephoneKeypad/private/TelephoneKeypad.tsx +4 -35
- package/src/env.d.ts +7 -0
- package/src/index.ts +3 -0
- package/src/styles/injectStyle.ts +9 -0
- package/src/styles/useStyles.ts +19 -0
- package/src/styles.ts +4 -0
- package/src/tsconfig.json +2 -1
- package/src/private/useStyleToEmotionObject.ts +0 -32
- package/src/styles/index.ts +0 -15
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,1076 @@
|
|
|
1
|
+
// src/index.ts
|
|
2
|
+
import { injectMetaTag } from "inject-meta-tag";
|
|
3
|
+
|
|
4
|
+
// src/private/FluentThemeProvider.tsx
|
|
5
|
+
import { Components } from "botframework-webchat-component";
|
|
6
|
+
import React21, { memo as memo15 } from "react";
|
|
7
|
+
|
|
8
|
+
// src/components/telephoneKeypad/Provider.tsx
|
|
9
|
+
import React, { memo, useMemo, useState } from "react";
|
|
10
|
+
|
|
11
|
+
// src/components/telephoneKeypad/private/Context.ts
|
|
12
|
+
import { createContext } from "react";
|
|
13
|
+
var Context = createContext(
|
|
14
|
+
new Proxy({}, {
|
|
15
|
+
get() {
|
|
16
|
+
throw new Error("botframework-webchat: This hook can only used under its corresponding <Provider>.");
|
|
17
|
+
}
|
|
18
|
+
})
|
|
19
|
+
);
|
|
20
|
+
Context.displayName = "TelephoneKeypad.Context";
|
|
21
|
+
var Context_default = Context;
|
|
22
|
+
|
|
23
|
+
// src/components/telephoneKeypad/Provider.tsx
|
|
24
|
+
var Provider = memo(({ children }) => {
|
|
25
|
+
const [shown, setShown] = useState(false);
|
|
26
|
+
const context = useMemo(
|
|
27
|
+
() => Object.freeze({
|
|
28
|
+
setShown,
|
|
29
|
+
shown
|
|
30
|
+
}),
|
|
31
|
+
[setShown, shown]
|
|
32
|
+
);
|
|
33
|
+
return /* @__PURE__ */ React.createElement(Context_default.Provider, { value: context }, children);
|
|
34
|
+
});
|
|
35
|
+
var Provider_default = Provider;
|
|
36
|
+
|
|
37
|
+
// src/components/telephoneKeypad/Surrogate.tsx
|
|
38
|
+
import React4, { memo as memo4 } from "react";
|
|
39
|
+
|
|
40
|
+
// src/components/telephoneKeypad/private/TelephoneKeypad.tsx
|
|
41
|
+
import React3, { memo as memo3, useCallback as useCallback2, useEffect, useRef } from "react";
|
|
42
|
+
import { useRefFrom as useRefFrom2 } from "use-ref-from";
|
|
43
|
+
|
|
44
|
+
// src/components/telephoneKeypad/private/Button.tsx
|
|
45
|
+
import React2, { forwardRef, memo as memo2, useCallback } from "react";
|
|
46
|
+
import { useRefFrom } from "use-ref-from";
|
|
47
|
+
|
|
48
|
+
// src/components/telephoneKeypad/private/Button.module.css
|
|
49
|
+
var Button_default = {
|
|
50
|
+
"telephone-keypad__button": "Button_telephone-keypad__button",
|
|
51
|
+
"telephone-keypad__button__ruby": "Button_telephone-keypad__button__ruby",
|
|
52
|
+
"telephone-keypad__button__text": "Button_telephone-keypad__button__text",
|
|
53
|
+
"telephone-keypad--horizontal": "Button_telephone-keypad--horizontal"
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
// src/styles/injectStyle.ts
|
|
57
|
+
var injectedStyles = "/* src/components/telephoneKeypad/private/Button.module.css */\n.webchat-fluent .Button_telephone-keypad__button {\n -webkit-user-select: none;\n align-items: center;\n appearance: none;\n background-color: White;\n border-radius: 100%;\n border: solid 1px var(--webchat-colorNeutralStroke1);\n color: var(--webchat-colorGray200);\n font-weight: var(--webchat-fontWeightSemibold);\n cursor: pointer;\n display: flex;\n flex-direction: column;\n height: 60px;\n opacity: 0.7;\n padding: 0;\n position: relative;\n touch-action: none;\n user-select: none;\n width: 60px;\n}\n.webchat-fluent .Button_telephone-keypad__button:hover {\n background-color: var(--webchat-colorGray30);\n}\n.webchat-fluent .Button_telephone-keypad__button__ruby {\n color: var(--webchat-colorGray190);\n font-size: 10px;\n}\n.webchat-fluent .Button_telephone-keypad__button__text {\n font-size: 24px;\n margin-top: 8px;\n}\n.webchat-fluent .Button_telephone-keypad--horizontal .Button_telephone-keypad__button {\n height: 32px;\n justify-content: center;\n margin: 8px 4px;\n width: 32px;\n}\n.webchat-fluent .Button_telephone-keypad--horizontal .Button_telephone-keypad__button__ruby {\n display: none;\n}\n.webchat-fluent .Button_telephone-keypad--horizontal .Button_telephone-keypad__button__text {\n font-size: 20px;\n margin-top: 0;\n}\n\n/* src/components/telephoneKeypad/private/TelephoneKeypad.module.css */\n.webchat-fluent .TelephoneKeypad_telephone-keypad {\n align-items: center;\n background: var(--webchat-colorNeutralBackground1);\n border: none;\n border-radius: var(--webchat-borderRadiusXLarge);\n display: flex;\n flex-direction: column;\n font-family: var(--webchat-fontFamilyBase);\n justify-content: center;\n}\n.webchat-fluent .TelephoneKeypad_telephone-keypad__box {\n box-sizing: border-box;\n display: grid;\n gap: 16px;\n grid-template-columns: repeat(3, 1fr);\n grid-template-rows: repeat(4, 1fr);\n justify-items: center;\n padding: 16px;\n width: 100%;\n}\n\n/* src/components/Theme.module.css */\n.webchat-fluent.Theme_theme {\n display: contents;\n --webchat-colorNeutralForeground1: var(--colorNeutralForeground1, #242424);\n --webchat-colorNeutralForeground2: var(--colorNeutralForeground2, #424242);\n --webchat-colorNeutralForeground4: var(--colorNeutralForeground4, #707070);\n --webchat-colorNeutralForegroundDisabled: var(--colorNeutralForegroundDisabled, #bdbdbd);\n --webchat-colorNeutralBackground1: var(--colorNeutralBackground1, #ffffff);\n --webchat-colorNeutralBackground4: var(--colorNeutralBackground4, #f0f0f0);\n --webchat-colorNeutralBackground5: var(--colorNeutralBackground5, #ebebeb);\n --webchat-colorSubtleBackgroundHover: var(--colorSubtleBackgroundHover, #f5f5f5);\n --webchat-colorSubtleBackgroundPressed: var(--colorSubtleBackgroundPressed, #e0e0e0);\n --webchat-colorNeutralStroke1: var(--colorNeutralStroke1, #d1d1d1);\n --webchat-colorNeutralStroke2: var(--colorNeutralStroke2, #e0e0e0);\n --webchat-colorNeutralStroke1Selected: var(--colorNeutralStroke1Selected, #bdbdbd);\n --webchat-colorBrandStroke2: var(--colorBrandStroke2, #9edcf7);\n --webchat-colorBrandForeground2Hover: var(--colorBrandForeground2Hover, #015a7a);\n --webchat-colorBrandForeground2Pressed: var(--colorBrandForeground2Pressed, #01384d);\n --webchat-colorBrandBackground2Hover: var(--colorBrandBackground2Hover, #bee7fa);\n --webchat-colorBrandBackground2Pressed: var(--colorBrandBackground2Pressed, #7fd2f5);\n --webchat-colorCompoundBrandForeground1: var(--colorCompoundBrandForeground1, #077fab);\n --webchat-colorCompoundBrandForeground1Hover: var(--colorCompoundBrandForeground1Hover, #02729c);\n --webchat-colorCompoundBrandForeground1Pressed: var(--colorCompoundBrandForeground1Pressed, #01678c);\n --webchat-colorStatusDangerForeground1: var(--colorStatusDangerForeground1, #b10e1c);\n --webchat-colorGray30: var(--colorGray30, #edebe9);\n --webchat-colorGray160: var(--colorGray160, #323130);\n --webchat-colorGray190: var(--colorGray190, #201f1e);\n --webchat-colorGray200: var(--colorGray200, #1b1a19);\n --webchat-borderRadiusSmall: var(--borderRadiusSmall, 2px);\n --webchat-borderRadiusLarge: var(--borderRadiusLarge, 6px);\n --webchat-borderRadiusXLarge: var(--borderRadiusXLarge, 8px);\n --webchat-shadow16: var(--shadow16, 0 6.4px 14.4px 0 rgba(0, 0, 0, 0.132), 0 1.2px 3.6px 0 rgba(0, 0, 0, 0.108));\n --webchat-spacingHorizontalMNudge: var(--spacingHorizontalMNudge, 10px);\n --webchat-fontFamilyBase: var(--fontFamilyBase, \"Segoe UI\", \"Segoe UI Web (West European)\", -apple-system, BlinkMacSystemFont, Roboto, \"Helvetica Neue\", sans-serif);\n --webchat-fontFamilyNumeric: var(--fontFamilyNumeric, Bahnschrift, \"Segoe UI\", \"Segoe UI Web (West European)\", -apple-system, BlinkMacSystemFont, Roboto, \"Helvetica Neue\", sans-serif);\n --webchat-fontWeightSemibold: var(--fontWeightSemibold, 600);\n}\n\n/* src/components/dropZone/index.module.css */\n.webchat-fluent .dropZone_sendbox__attachment-drop-zone {\n background-color: var(--webchat-colorNeutralBackground4);\n border-radius: inherit;\n cursor: copy;\n display: grid;\n gap: 8px;\n inset: 0;\n place-content: center;\n place-items: center;\n position: absolute;\n}\n.webchat-fluent .dropZone_sendbox__attachment-drop-zone--droppable {\n background-color: #e00;\n color: White;\n}\n.webchat-fluent .dropZone_sendbox__attachment-drop-zone-icon {\n height: 36px;\n pointer-events: none;\n width: 36px;\n}\n\n/* src/components/suggestedActions/SuggestedAction.module.css */\n.webchat-fluent .SuggestedAction_suggested-action {\n align-items: center;\n background: transparent;\n border-radius: 8px;\n border: 1px solid var(--webchat-colorBrandStroke2);\n cursor: pointer;\n display: flex;\n font-size: 12px;\n gap: 4px;\n padding: 4px 8px 4px;\n text-align: start;\n transition: all .15s ease-out;\n}\n@media (hover: hover) {\n .webchat-fluent .SuggestedAction_suggested-action:not([aria-disabled=true]):hover {\n background-color: var(--webchat-colorBrandBackground2Hover);\n color: var(--webchat-colorBrandForeground2Hover);\n }\n}\n.webchat-fluent .SuggestedAction_suggested-action:not([aria-disabled=true]):active {\n background-color: var(--webchat-colorBrandBackground2Pressed);\n color: var(--webchat-colorBrandForeground2Pressed);\n}\n.webchat-fluent .SuggestedAction_suggested-action[aria-disabled=true] {\n color: var(--webchat-colorNeutralForegroundDisabled);\n cursor: not-allowed;\n}\n.webchat-fluent .SuggestedAction_suggested-action__image {\n font-size: 12px;\n height: 1em;\n width: 1em;\n}\n\n/* src/components/suggestedActions/index.module.css */\n.webchat-fluent .suggestedActions_suggested-actions {\n align-items: flex-end;\n align-self: flex-end;\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n.webchat-fluent .suggestedActions_suggested-actions:not(:empty) {\n padding-block-end: 8px;\n padding-inline-start: 4px;\n}\n.webchat-fluent .suggestedActions_suggested-actions.suggestedActions_suggested-actions--flow {\n flex-direction: row;\n flex-wrap: wrap;\n justify-content: flex-end;\n}\n.webchat-fluent .suggestedActions_suggested-actions.suggestedActions_suggested-actions--stacked {\n flex-direction: column;\n}\n\n/* src/components/sendbox/Toolbar.module.css */\n.webchat-fluent .Toolbar_sendbox__toolbar {\n display: flex;\n gap: 4px;\n margin-inline-start: auto;\n}\n.webchat-fluent .Toolbar_sendbox__toolbar-button {\n align-items: center;\n appearance: none;\n aspect-ratio: 1;\n background: transparent;\n border-radius: var(--webchat-borderRadiusSmall);\n border: none;\n cursor: pointer;\n display: flex;\n justify-content: center;\n padding: 3px;\n width: 32px;\n}\n.webchat-fluent .Toolbar_sendbox__toolbar-button > svg {\n font-size: 20px;\n pointer-events: none;\n}\n@media (hover: hover) {\n .webchat-fluent .Toolbar_sendbox__toolbar-button:not([aria-disabled=true]):hover {\n background-color: var(--webchat-colorSubtleBackgroundHover);\n color: var(--webchat-colorCompoundBrandForeground1Hover);\n }\n}\n.webchat-fluent .Toolbar_sendbox__toolbar-button:not([aria-disabled=true]):active {\n background-color: var(--webchat-colorSubtleBackgroundPressed);\n color: var(--webchat-colorCompoundBrandForeground1Pressed);\n}\n.webchat-fluent .Toolbar_sendbox__toolbar-button[aria-disabled=true] {\n color: var(--webchat-colorNeutralForegroundDisabled);\n cursor: not-allowed;\n}\n.webchat-fluent .Toolbar_sendbox__toolbar-separator {\n align-self: center;\n border-inline-end: 1px solid var(--webchat-colorNeutralStroke2);\n height: 28px;\n}\n.webchat-fluent .Toolbar_sendbox__toolbar-separator:is(:first-child, :last-child, :only-child) {\n display: none;\n}\n\n/* src/components/sendbox/AddAttachmentButton.module.css */\n.webchat-fluent .AddAttachmentButton_sendbox__add-attachment {\n display: grid;\n}\n.webchat-fluent .AddAttachmentButton_sendbox__add-attachment-input {\n font-size: 0;\n height: 0;\n opacity: 0;\n width: 0;\n}\n\n/* src/components/sendbox/Attachments.module.css */\n.webchat-fluent .Attachments_sendbox__attachment {\n border-radius: var(--webchat-borderRadiusLarge);\n border: 1px solid var(--webchat-colorNeutralStroke1);\n cursor: default;\n padding: 6px 8px;\n width: fit-content;\n}\n\n/* src/components/sendbox/ErrorMessage.module.css */\n.webchat-fluent .ErrorMessage_sendbox__error-message {\n color: transparent;\n font-size: 0;\n height: 0;\n left: 0;\n position: absolute;\n top: 0;\n width: 0;\n}\n\n/* src/components/sendbox/TextArea.module.css */\n.webchat-fluent .TextArea_sendbox__text-area {\n display: grid;\n grid-template-areas: \"main\";\n max-height: 200px;\n overflow: hidden;\n}\n.webchat-fluent .TextArea_sendbox__text-area--hidden {\n height: 0;\n visibility: collapse;\n}\n.webchat-fluent .TextArea_sendbox__text-area-shared {\n border: none;\n font: inherit;\n grid-area: main;\n outline: inherit;\n overflow-wrap: anywhere;\n resize: inherit;\n scrollbar-gutter: stable;\n}\n.webchat-fluent .TextArea_sendbox__text-area-doppelganger {\n overflow: hidden;\n visibility: hidden;\n white-space: pre-wrap;\n}\n.webchat-fluent .TextArea_sendbox__text-area-input {\n height: 100%;\n padding: 0;\n}\n.webchat-fluent .TextArea_sendbox__text-area-input--scroll {\n scrollbar-color: unset;\n scrollbar-width: unset;\n -moz-scrollbar-color: var(--webchat-colorNeutralBackground5) var(--webchat-colorNeutralForeground2);\n -moz-scrollbar-width: thin;\n}\n.webchat-fluent .TextArea_sendbox__text-area-input--scroll::-webkit-scrollbar {\n width: 8px;\n}\n.webchat-fluent .TextArea_sendbox__text-area-input--scroll::-webkit-scrollbar-track {\n background-color: var(--webchat-colorNeutralBackground5);\n border-radius: 16px;\n}\n.webchat-fluent .TextArea_sendbox__text-area-input--scroll::-webkit-scrollbar-thumb {\n background-color: var(--webchat-colorNeutralForeground2);\n border-radius: 16px;\n}\n.webchat-fluent .TextArea_sendbox__text-area-input--scroll::-webkit-scrollbar-corner {\n background-color: var(--webchat-colorNeutralBackground5);\n}\n\n/* src/components/sendbox/index.module.css */\n.webchat-fluent .sendbox_sendbox {\n color: var(--webchat-colorNeutralForeground1);\n font-family: var(--webchat-fontFamilyBase);\n padding: 0 10px 10px;\n text-rendering: optimizeLegibility;\n}\n.webchat-fluent .sendbox_sendbox__sendbox {\n background-color: var(--webchat-colorNeutralBackground1);\n border-radius: var(--webchat-borderRadiusLarge);\n border: 1px solid var(--webchat-colorNeutralStroke1);\n display: grid;\n font-family: var(--webchat-fontFamilyBase);\n font-size: 14px;\n gap: 6px;\n line-height: 20px;\n padding: 8px;\n position: relative;\n}\n.webchat-fluent .sendbox_sendbox__sendbox:focus-within {\n border-color: var(--webchat-colorNeutralStroke1Selected);\n box-shadow: inset 0 -6px 0 -3px var(--webchat-colorCompoundBrandForeground1Hover);\n}\n.webchat-fluent .sendbox_sendbox__sendbox-text {\n background-color: transparent;\n border: none;\n flex: auto;\n font-family: var(--webchat-fontFamilyBase);\n font-size: 14px;\n line-height: 20px;\n outline: none;\n padding: 4px 4px 0;\n resize: none;\n}\n.webchat-fluent .sendbox_sendbox__sendbox-controls {\n align-items: center;\n display: flex;\n padding-inline-start: 4px;\n}\n.webchat-fluent .sendbox_sendbox__text-counter {\n color: var(--webchat-colorNeutralForeground4);\n cursor: default;\n font-family: var(--webchat-fontFamilyNumeric);\n font-size: 10px;\n line-height: 14px;\n}\n.webchat-fluent .sendbox_sendbox__text-counter--error {\n color: var(--webchat-colorStatusDangerForeground1);\n}\n";
|
|
58
|
+
function injectStyles() {
|
|
59
|
+
if (globalThis.document) {
|
|
60
|
+
const style = document.createElement("style");
|
|
61
|
+
style.append(document.createTextNode(injectedStyles));
|
|
62
|
+
document.head.appendChild(style);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// src/styles/useStyles.ts
|
|
67
|
+
import { useMemo as useMemo2 } from "react";
|
|
68
|
+
function useStyles(styles) {
|
|
69
|
+
return useMemo2(
|
|
70
|
+
() => Object.freeze(
|
|
71
|
+
Object.fromEntries(
|
|
72
|
+
Object.entries(styles).map(([baseClassName, resultClassName]) => [
|
|
73
|
+
baseClassName,
|
|
74
|
+
`${baseClassName} ${resultClassName}`
|
|
75
|
+
])
|
|
76
|
+
)
|
|
77
|
+
),
|
|
78
|
+
[styles]
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
var useStyles_default = useStyles;
|
|
82
|
+
|
|
83
|
+
// src/components/telephoneKeypad/private/Button.tsx
|
|
84
|
+
var Button = memo2(
|
|
85
|
+
// As we are all TypeScript, internal components do not need propTypes.
|
|
86
|
+
// eslint-disable-next-line react/prop-types
|
|
87
|
+
forwardRef(({ button, "data-testid": dataTestId, onClick, ruby }, ref) => {
|
|
88
|
+
const classNames = useStyles_default(Button_default);
|
|
89
|
+
const onClickRef = useRefFrom(onClick);
|
|
90
|
+
const handleClick = useCallback(() => onClickRef.current?.(), [onClickRef]);
|
|
91
|
+
return /* @__PURE__ */ React2.createElement(
|
|
92
|
+
"button",
|
|
93
|
+
{
|
|
94
|
+
className: classNames["telephone-keypad__button"],
|
|
95
|
+
"data-testid": dataTestId,
|
|
96
|
+
onClick: handleClick,
|
|
97
|
+
ref,
|
|
98
|
+
type: "button"
|
|
99
|
+
},
|
|
100
|
+
/* @__PURE__ */ React2.createElement("span", { className: classNames["telephone-keypad__button__text"] }, button === "star" ? "\u2217" : button === "pound" ? "#" : button),
|
|
101
|
+
!!ruby && /* @__PURE__ */ React2.createElement("ruby", { className: classNames["telephone-keypad__button__ruby"] }, ruby)
|
|
102
|
+
);
|
|
103
|
+
})
|
|
104
|
+
);
|
|
105
|
+
Button.displayName = "TelephoneKeypad.Button";
|
|
106
|
+
var Button_default2 = Button;
|
|
107
|
+
|
|
108
|
+
// src/testIds.ts
|
|
109
|
+
var testIds = {
|
|
110
|
+
sendBoxDropZone: "send box drop zone",
|
|
111
|
+
sendBoxSendButton: "send box send button",
|
|
112
|
+
sendBoxTextBox: "send box text area",
|
|
113
|
+
sendBoxTelephoneKeypadButton1: `send box telephone keypad button 1`,
|
|
114
|
+
sendBoxTelephoneKeypadButton2: `send box telephone keypad button 2`,
|
|
115
|
+
sendBoxTelephoneKeypadButton3: `send box telephone keypad button 3`,
|
|
116
|
+
sendBoxTelephoneKeypadButton4: `send box telephone keypad button 4`,
|
|
117
|
+
sendBoxTelephoneKeypadButton5: `send box telephone keypad button 5`,
|
|
118
|
+
sendBoxTelephoneKeypadButton6: `send box telephone keypad button 6`,
|
|
119
|
+
sendBoxTelephoneKeypadButton7: `send box telephone keypad button 7`,
|
|
120
|
+
sendBoxTelephoneKeypadButton8: `send box telephone keypad button 8`,
|
|
121
|
+
sendBoxTelephoneKeypadButton9: `send box telephone keypad button 9`,
|
|
122
|
+
sendBoxTelephoneKeypadButton0: `send box telephone keypad button 0`,
|
|
123
|
+
sendBoxTelephoneKeypadButtonStar: `send box telephone keypad button star`,
|
|
124
|
+
sendBoxTelephoneKeypadButtonPound: `send box telephone keypad button pound`,
|
|
125
|
+
sendBoxTelephoneKeypadToolbarButton: "send box telephone keypad toolbar button",
|
|
126
|
+
sendBoxUploadButton: "send box upload button"
|
|
127
|
+
};
|
|
128
|
+
var testIds_default = testIds;
|
|
129
|
+
|
|
130
|
+
// src/components/telephoneKeypad/useShown.ts
|
|
131
|
+
import { useContext, useMemo as useMemo3 } from "react";
|
|
132
|
+
function useShown() {
|
|
133
|
+
const { setShown, shown } = useContext(Context_default);
|
|
134
|
+
return useMemo3(() => Object.freeze([shown, setShown]), [shown, setShown]);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// src/components/telephoneKeypad/private/TelephoneKeypad.module.css
|
|
138
|
+
var TelephoneKeypad_default = {
|
|
139
|
+
"telephone-keypad": "TelephoneKeypad_telephone-keypad",
|
|
140
|
+
"telephone-keypad__box": "TelephoneKeypad_telephone-keypad__box"
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
// src/components/telephoneKeypad/private/TelephoneKeypad.tsx
|
|
144
|
+
var Orientation = memo3(
|
|
145
|
+
({ children, isHorizontal }) => {
|
|
146
|
+
const classNames = useStyles_default(TelephoneKeypad_default);
|
|
147
|
+
return isHorizontal ? (
|
|
148
|
+
// <HorizontalDialPadController>{children}</HorizontalDialPadController>
|
|
149
|
+
false
|
|
150
|
+
) : /* @__PURE__ */ React3.createElement("div", { className: classNames["telephone-keypad__box"] }, children);
|
|
151
|
+
}
|
|
152
|
+
);
|
|
153
|
+
Orientation.displayName = "TelephoneKeypad:Orientation";
|
|
154
|
+
var TelephoneKeypad = memo3(({ autoFocus, onButtonClick, isHorizontal }) => {
|
|
155
|
+
const autoFocusRef = useRefFrom2(autoFocus);
|
|
156
|
+
const classNames = useStyles_default(TelephoneKeypad_default);
|
|
157
|
+
const firstButtonRef = useRef(null);
|
|
158
|
+
const onButtonClickRef = useRefFrom2(onButtonClick);
|
|
159
|
+
const [, setShown] = useShown();
|
|
160
|
+
const handleButton1Click = useCallback2(() => onButtonClickRef.current?.("1"), [onButtonClickRef]);
|
|
161
|
+
const handleButton2Click = useCallback2(() => onButtonClickRef.current?.("2"), [onButtonClickRef]);
|
|
162
|
+
const handleButton3Click = useCallback2(() => onButtonClickRef.current?.("3"), [onButtonClickRef]);
|
|
163
|
+
const handleButton4Click = useCallback2(() => onButtonClickRef.current?.("4"), [onButtonClickRef]);
|
|
164
|
+
const handleButton5Click = useCallback2(() => onButtonClickRef.current?.("5"), [onButtonClickRef]);
|
|
165
|
+
const handleButton6Click = useCallback2(() => onButtonClickRef.current?.("6"), [onButtonClickRef]);
|
|
166
|
+
const handleButton7Click = useCallback2(() => onButtonClickRef.current?.("7"), [onButtonClickRef]);
|
|
167
|
+
const handleButton8Click = useCallback2(() => onButtonClickRef.current?.("8"), [onButtonClickRef]);
|
|
168
|
+
const handleButton9Click = useCallback2(() => onButtonClickRef.current?.("9"), [onButtonClickRef]);
|
|
169
|
+
const handleButton0Click = useCallback2(() => onButtonClickRef.current?.("0"), [onButtonClickRef]);
|
|
170
|
+
const handleButtonStarClick = useCallback2(() => onButtonClickRef.current?.("star"), [onButtonClickRef]);
|
|
171
|
+
const handleButtonPoundClick = useCallback2(() => onButtonClickRef.current?.("pound"), [onButtonClickRef]);
|
|
172
|
+
const handleKeyDown = useCallback2(
|
|
173
|
+
(event) => {
|
|
174
|
+
if (event.key === "Escape") {
|
|
175
|
+
setShown(false);
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
[setShown]
|
|
179
|
+
);
|
|
180
|
+
useEffect(() => {
|
|
181
|
+
autoFocusRef.current && firstButtonRef.current?.focus();
|
|
182
|
+
}, [autoFocusRef, firstButtonRef]);
|
|
183
|
+
return /* @__PURE__ */ React3.createElement("div", { className: classNames["telephone-keypad"], onKeyDown: handleKeyDown }, /* @__PURE__ */ React3.createElement(Orientation, { isHorizontal }, /* @__PURE__ */ React3.createElement(
|
|
184
|
+
Button_default2,
|
|
185
|
+
{
|
|
186
|
+
button: "1",
|
|
187
|
+
"data-testid": testIds_default.sendBoxTelephoneKeypadButton1,
|
|
188
|
+
onClick: handleButton1Click,
|
|
189
|
+
ref: firstButtonRef
|
|
190
|
+
}
|
|
191
|
+
), /* @__PURE__ */ React3.createElement(
|
|
192
|
+
Button_default2,
|
|
193
|
+
{
|
|
194
|
+
button: "2",
|
|
195
|
+
"data-testid": testIds_default.sendBoxTelephoneKeypadButton2,
|
|
196
|
+
onClick: handleButton2Click,
|
|
197
|
+
ruby: "ABC"
|
|
198
|
+
}
|
|
199
|
+
), /* @__PURE__ */ React3.createElement(
|
|
200
|
+
Button_default2,
|
|
201
|
+
{
|
|
202
|
+
button: "3",
|
|
203
|
+
"data-testid": testIds_default.sendBoxTelephoneKeypadButton3,
|
|
204
|
+
onClick: handleButton3Click,
|
|
205
|
+
ruby: "DEF"
|
|
206
|
+
}
|
|
207
|
+
), /* @__PURE__ */ React3.createElement(
|
|
208
|
+
Button_default2,
|
|
209
|
+
{
|
|
210
|
+
button: "4",
|
|
211
|
+
"data-testid": testIds_default.sendBoxTelephoneKeypadButton4,
|
|
212
|
+
onClick: handleButton4Click,
|
|
213
|
+
ruby: "GHI"
|
|
214
|
+
}
|
|
215
|
+
), /* @__PURE__ */ React3.createElement(
|
|
216
|
+
Button_default2,
|
|
217
|
+
{
|
|
218
|
+
button: "5",
|
|
219
|
+
"data-testid": testIds_default.sendBoxTelephoneKeypadButton5,
|
|
220
|
+
onClick: handleButton5Click,
|
|
221
|
+
ruby: "JKL"
|
|
222
|
+
}
|
|
223
|
+
), /* @__PURE__ */ React3.createElement(
|
|
224
|
+
Button_default2,
|
|
225
|
+
{
|
|
226
|
+
button: "6",
|
|
227
|
+
"data-testid": testIds_default.sendBoxTelephoneKeypadButton6,
|
|
228
|
+
onClick: handleButton6Click,
|
|
229
|
+
ruby: "MNO"
|
|
230
|
+
}
|
|
231
|
+
), /* @__PURE__ */ React3.createElement(
|
|
232
|
+
Button_default2,
|
|
233
|
+
{
|
|
234
|
+
button: "7",
|
|
235
|
+
"data-testid": testIds_default.sendBoxTelephoneKeypadButton7,
|
|
236
|
+
onClick: handleButton7Click,
|
|
237
|
+
ruby: "PQRS"
|
|
238
|
+
}
|
|
239
|
+
), /* @__PURE__ */ React3.createElement(
|
|
240
|
+
Button_default2,
|
|
241
|
+
{
|
|
242
|
+
button: "8",
|
|
243
|
+
"data-testid": testIds_default.sendBoxTelephoneKeypadButton8,
|
|
244
|
+
onClick: handleButton8Click,
|
|
245
|
+
ruby: "TUV"
|
|
246
|
+
}
|
|
247
|
+
), /* @__PURE__ */ React3.createElement(
|
|
248
|
+
Button_default2,
|
|
249
|
+
{
|
|
250
|
+
button: "9",
|
|
251
|
+
"data-testid": testIds_default.sendBoxTelephoneKeypadButton9,
|
|
252
|
+
onClick: handleButton9Click,
|
|
253
|
+
ruby: "WXYZ"
|
|
254
|
+
}
|
|
255
|
+
), /* @__PURE__ */ React3.createElement(Button_default2, { button: "star", "data-testid": testIds_default.sendBoxTelephoneKeypadButtonStar, onClick: handleButtonStarClick }), /* @__PURE__ */ React3.createElement(Button_default2, { button: "0", "data-testid": testIds_default.sendBoxTelephoneKeypadButton0, onClick: handleButton0Click, ruby: "+" }), /* @__PURE__ */ React3.createElement(
|
|
256
|
+
Button_default2,
|
|
257
|
+
{
|
|
258
|
+
button: "pound",
|
|
259
|
+
"data-testid": testIds_default.sendBoxTelephoneKeypadButtonPound,
|
|
260
|
+
onClick: handleButtonPoundClick
|
|
261
|
+
}
|
|
262
|
+
)));
|
|
263
|
+
});
|
|
264
|
+
TelephoneKeypad.displayName = "TelephoneKeypad";
|
|
265
|
+
var TelephoneKeypad_default2 = TelephoneKeypad;
|
|
266
|
+
|
|
267
|
+
// src/components/telephoneKeypad/Surrogate.tsx
|
|
268
|
+
var TelephoneKeypadSurrogate = memo4((props) => useShown()[0] ? /* @__PURE__ */ React4.createElement(TelephoneKeypad_default2, { ...props }) : false);
|
|
269
|
+
TelephoneKeypadSurrogate.displayName = "TelephoneKeypad.Surrogate";
|
|
270
|
+
var Surrogate_default = TelephoneKeypadSurrogate;
|
|
271
|
+
|
|
272
|
+
// src/components/Theme.tsx
|
|
273
|
+
import React5 from "react";
|
|
274
|
+
import cx from "classnames";
|
|
275
|
+
|
|
276
|
+
// src/components/Theme.module.css
|
|
277
|
+
var Theme_default = {
|
|
278
|
+
theme: "Theme_theme"
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
// src/components/Theme.tsx
|
|
282
|
+
var rootClassName = "webchat-fluent";
|
|
283
|
+
function WebchatTheme(props) {
|
|
284
|
+
const classNames = useStyles_default(Theme_default);
|
|
285
|
+
return /* @__PURE__ */ React5.createElement("div", { className: cx(rootClassName, classNames["theme"]) }, props.children);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
// src/components/sendbox/index.tsx
|
|
289
|
+
import { hooks as hooks8 } from "botframework-webchat-component";
|
|
290
|
+
import cx7 from "classnames";
|
|
291
|
+
import React20, { memo as memo14, useCallback as useCallback8, useRef as useRef6, useState as useState3 } from "react";
|
|
292
|
+
import { useRefFrom as useRefFrom6 } from "use-ref-from";
|
|
293
|
+
|
|
294
|
+
// src/icons/SendIcon.tsx
|
|
295
|
+
import React6 from "react";
|
|
296
|
+
function SendIcon(props) {
|
|
297
|
+
return /* @__PURE__ */ React6.createElement(
|
|
298
|
+
"svg",
|
|
299
|
+
{
|
|
300
|
+
"aria-hidden": "true",
|
|
301
|
+
className: props.className,
|
|
302
|
+
fill: "currentColor",
|
|
303
|
+
height: "1em",
|
|
304
|
+
viewBox: "0 0 20 20",
|
|
305
|
+
width: "1em",
|
|
306
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
307
|
+
},
|
|
308
|
+
/* @__PURE__ */ React6.createElement(
|
|
309
|
+
"path",
|
|
310
|
+
{
|
|
311
|
+
d: "M2.18 2.11a.5.5 0 0 1 .54-.06l15 7.5a.5.5 0 0 1 0 .9l-15 7.5a.5.5 0 0 1-.7-.58L3.98 10 2.02 2.63a.5.5 0 0 1 .16-.52Zm2.7 8.39-1.61 6.06L16.38 10 3.27 3.44 4.88 9.5h6.62a.5.5 0 1 1 0 1H4.88Z",
|
|
312
|
+
fill: "currentColor"
|
|
313
|
+
}
|
|
314
|
+
)
|
|
315
|
+
);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
// src/components/dropZone/index.tsx
|
|
319
|
+
import { hooks } from "botframework-webchat-component";
|
|
320
|
+
import cx2 from "classnames";
|
|
321
|
+
import React8, { memo as memo5, useCallback as useCallback3, useEffect as useEffect2, useRef as useRef2, useState as useState2 } from "react";
|
|
322
|
+
import { useRefFrom as useRefFrom3 } from "use-ref-from";
|
|
323
|
+
|
|
324
|
+
// src/icons/AddDocumentIcon.tsx
|
|
325
|
+
import React7 from "react";
|
|
326
|
+
function AddDocumentIcon(props) {
|
|
327
|
+
return /* @__PURE__ */ React7.createElement(
|
|
328
|
+
"svg",
|
|
329
|
+
{
|
|
330
|
+
"aria-hidden": "true",
|
|
331
|
+
className: props.className,
|
|
332
|
+
fill: "currentColor",
|
|
333
|
+
height: "1em",
|
|
334
|
+
viewBox: "0 0 20 20",
|
|
335
|
+
width: "1em",
|
|
336
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
337
|
+
},
|
|
338
|
+
/* @__PURE__ */ React7.createElement(
|
|
339
|
+
"path",
|
|
340
|
+
{
|
|
341
|
+
d: "M6 2a2 2 0 0 0-2 2v5.2c.32-.08.66-.15 1-.18V4a1 1 0 0 1 1-1h4v3.5c0 .83.67 1.5 1.5 1.5H15v8a1 1 0 0 1-1 1h-3.6c-.18.36-.4.7-.66 1H14a2 2 0 0 0 2-2V7.41c0-.4-.16-.78-.44-1.06l-3.91-3.91A1.5 1.5 0 0 0 10.59 2H6Zm8.8 5h-3.3a.5.5 0 0 1-.5-.5V3.2L14.8 7ZM10 14.5a4.5 4.5 0 1 1-9 0 4.5 4.5 0 0 1 9 0Zm-4-2a.5.5 0 0 0-1 0V14H3.5a.5.5 0 0 0 0 1H5v1.5a.5.5 0 0 0 1 0V15h1.5a.5.5 0 0 0 0-1H6v-1.5Z",
|
|
342
|
+
fill: "currentColor"
|
|
343
|
+
}
|
|
344
|
+
)
|
|
345
|
+
);
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
// src/components/dropZone/index.module.css
|
|
349
|
+
var dropZone_default = {
|
|
350
|
+
"sendbox__attachment-drop-zone": "dropZone_sendbox__attachment-drop-zone",
|
|
351
|
+
"sendbox__attachment-drop-zone--droppable": "dropZone_sendbox__attachment-drop-zone--droppable",
|
|
352
|
+
"sendbox__attachment-drop-zone-icon": "dropZone_sendbox__attachment-drop-zone-icon"
|
|
353
|
+
};
|
|
354
|
+
|
|
355
|
+
// src/components/dropZone/index.tsx
|
|
356
|
+
var { useLocalizer } = hooks;
|
|
357
|
+
var handleDragOver = (event) => {
|
|
358
|
+
event.preventDefault();
|
|
359
|
+
};
|
|
360
|
+
var isFilesTransferEvent = (event) => !!event.dataTransfer?.types?.some((type) => type.toLowerCase() === "files");
|
|
361
|
+
function isDescendantOf(target, ancestor) {
|
|
362
|
+
let current = target.parentNode;
|
|
363
|
+
while (current) {
|
|
364
|
+
if (current === ancestor) {
|
|
365
|
+
return true;
|
|
366
|
+
}
|
|
367
|
+
current = current.parentNode;
|
|
368
|
+
}
|
|
369
|
+
return false;
|
|
370
|
+
}
|
|
371
|
+
var DropZone = (props) => {
|
|
372
|
+
const [dropZoneState, setDropZoneState] = useState2(false);
|
|
373
|
+
const classNames = useStyles_default(dropZone_default);
|
|
374
|
+
const dropZoneRef = useRef2(null);
|
|
375
|
+
const localize = useLocalizer();
|
|
376
|
+
const onFilesAddedRef = useRefFrom3(props.onFilesAdded);
|
|
377
|
+
useEffect2(() => {
|
|
378
|
+
let entranceCounter = 0;
|
|
379
|
+
const handleDragEnter = (event) => {
|
|
380
|
+
entranceCounter++;
|
|
381
|
+
if (isFilesTransferEvent(event)) {
|
|
382
|
+
setDropZoneState(
|
|
383
|
+
dropZoneRef.current && (event.target === dropZoneRef.current || event.target instanceof HTMLElement && isDescendantOf(event.target, dropZoneRef.current)) ? "droppable" : "visible"
|
|
384
|
+
);
|
|
385
|
+
}
|
|
386
|
+
};
|
|
387
|
+
const handleDragLeave = () => --entranceCounter <= 0 && setDropZoneState(false);
|
|
388
|
+
document.addEventListener("dragenter", handleDragEnter, false);
|
|
389
|
+
document.addEventListener("dragleave", handleDragLeave, false);
|
|
390
|
+
return () => {
|
|
391
|
+
document.removeEventListener("dragenter", handleDragEnter);
|
|
392
|
+
document.removeEventListener("dragleave", handleDragLeave);
|
|
393
|
+
};
|
|
394
|
+
}, [setDropZoneState]);
|
|
395
|
+
const handleDrop = useCallback3(
|
|
396
|
+
(event) => {
|
|
397
|
+
event.preventDefault();
|
|
398
|
+
setDropZoneState(false);
|
|
399
|
+
if (!isFilesTransferEvent(event.nativeEvent)) {
|
|
400
|
+
return;
|
|
401
|
+
}
|
|
402
|
+
onFilesAddedRef.current([...event.dataTransfer.files]);
|
|
403
|
+
},
|
|
404
|
+
[onFilesAddedRef, setDropZoneState]
|
|
405
|
+
);
|
|
406
|
+
return dropZoneState ? /* @__PURE__ */ React8.createElement(
|
|
407
|
+
"div",
|
|
408
|
+
{
|
|
409
|
+
className: cx2(classNames["sendbox__attachment-drop-zone"], {
|
|
410
|
+
[classNames["sendbox__attachment-drop-zone--droppable"]]: dropZoneState === "droppable"
|
|
411
|
+
}),
|
|
412
|
+
"data-testid": testIds_default.sendBoxDropZone,
|
|
413
|
+
onDragOver: handleDragOver,
|
|
414
|
+
onDrop: handleDrop,
|
|
415
|
+
ref: dropZoneRef
|
|
416
|
+
},
|
|
417
|
+
/* @__PURE__ */ React8.createElement(AddDocumentIcon, { className: classNames["sendbox__attachment-drop-zone-icon"] }),
|
|
418
|
+
localize("TEXT_INPUT_DROP_ZONE")
|
|
419
|
+
) : null;
|
|
420
|
+
};
|
|
421
|
+
DropZone.displayName = "DropZone";
|
|
422
|
+
var dropZone_default2 = memo5(DropZone);
|
|
423
|
+
|
|
424
|
+
// src/components/DropZone.tsx
|
|
425
|
+
var DropZone_default = dropZone_default2;
|
|
426
|
+
|
|
427
|
+
// src/components/suggestedActions/index.tsx
|
|
428
|
+
import { hooks as hooks3 } from "botframework-webchat-component";
|
|
429
|
+
import cx4 from "classnames";
|
|
430
|
+
import React11, { memo as memo8 } from "react";
|
|
431
|
+
|
|
432
|
+
// src/components/suggestedActions/SuggestedAction.tsx
|
|
433
|
+
import { hooks as hooks2 } from "botframework-webchat-component";
|
|
434
|
+
import cx3 from "classnames";
|
|
435
|
+
import React10, { memo as memo7, useCallback as useCallback4, useRef as useRef4 } from "react";
|
|
436
|
+
|
|
437
|
+
// src/components/suggestedActions/SuggestedAction.module.css
|
|
438
|
+
var SuggestedAction_default = {
|
|
439
|
+
"suggested-action": "SuggestedAction_suggested-action",
|
|
440
|
+
"suggested-action__image": "SuggestedAction_suggested-action__image"
|
|
441
|
+
};
|
|
442
|
+
|
|
443
|
+
// src/components/suggestedActions/AccessibleButton.tsx
|
|
444
|
+
import React9, { forwardRef as forwardRef2, memo as memo6, useRef as useRef3 } from "react";
|
|
445
|
+
var preventDefaultHandler = (event) => event.preventDefault();
|
|
446
|
+
var AccessibleButton = forwardRef2(
|
|
447
|
+
({ "aria-hidden": ariaHidden, children, disabled, onClick, tabIndex, ...props }, forwardedRef) => {
|
|
448
|
+
const targetRef = useRef3(null);
|
|
449
|
+
const ref = forwardedRef || targetRef;
|
|
450
|
+
return /* @__PURE__ */ React9.createElement(
|
|
451
|
+
"button",
|
|
452
|
+
{
|
|
453
|
+
"aria-disabled": disabled ? "true" : "false",
|
|
454
|
+
"aria-hidden": ariaHidden,
|
|
455
|
+
onClick: disabled ? preventDefaultHandler : onClick,
|
|
456
|
+
ref,
|
|
457
|
+
tabIndex,
|
|
458
|
+
...disabled && {
|
|
459
|
+
"aria-disabled": "true",
|
|
460
|
+
tabIndex: -1
|
|
461
|
+
},
|
|
462
|
+
...props,
|
|
463
|
+
type: "button"
|
|
464
|
+
},
|
|
465
|
+
children
|
|
466
|
+
);
|
|
467
|
+
}
|
|
468
|
+
);
|
|
469
|
+
var AccessibleButton_default = memo6(AccessibleButton);
|
|
470
|
+
|
|
471
|
+
// src/components/suggestedActions/SuggestedAction.tsx
|
|
472
|
+
var { useDisabled, useFocus, usePerformCardAction, useScrollToEnd, useStyleSet, useSuggestedActions } = hooks2;
|
|
473
|
+
function SuggestedAction({
|
|
474
|
+
buttonText,
|
|
475
|
+
className,
|
|
476
|
+
displayText,
|
|
477
|
+
image,
|
|
478
|
+
imageAlt,
|
|
479
|
+
text,
|
|
480
|
+
type,
|
|
481
|
+
value
|
|
482
|
+
}) {
|
|
483
|
+
const [_, setSuggestedActions] = useSuggestedActions();
|
|
484
|
+
const [{ suggestedAction: suggestedActionStyleSet }] = useStyleSet();
|
|
485
|
+
const [disabled] = useDisabled();
|
|
486
|
+
const focus = useFocus();
|
|
487
|
+
const focusRef = useRef4(null);
|
|
488
|
+
const performCardAction = usePerformCardAction();
|
|
489
|
+
const classNames = useStyles_default(SuggestedAction_default);
|
|
490
|
+
const scrollToEnd = useScrollToEnd();
|
|
491
|
+
const handleClick = useCallback4(
|
|
492
|
+
({ target }) => {
|
|
493
|
+
(async function() {
|
|
494
|
+
await focus("sendBoxWithoutKeyboard");
|
|
495
|
+
performCardAction({ displayText, text, type, value }, { target });
|
|
496
|
+
type === "openUrl" && setSuggestedActions([]);
|
|
497
|
+
scrollToEnd();
|
|
498
|
+
})();
|
|
499
|
+
},
|
|
500
|
+
[displayText, focus, performCardAction, scrollToEnd, setSuggestedActions, text, type, value]
|
|
501
|
+
);
|
|
502
|
+
return /* @__PURE__ */ React10.createElement(
|
|
503
|
+
AccessibleButton_default,
|
|
504
|
+
{
|
|
505
|
+
className: cx3(classNames["suggested-action"], suggestedActionStyleSet + "", (className || "") + ""),
|
|
506
|
+
disabled,
|
|
507
|
+
onClick: handleClick,
|
|
508
|
+
ref: focusRef,
|
|
509
|
+
type: "button"
|
|
510
|
+
},
|
|
511
|
+
image && /* @__PURE__ */ React10.createElement("img", { alt: imageAlt, className: classNames["suggested-action__image"], src: image }),
|
|
512
|
+
/* @__PURE__ */ React10.createElement("span", null, buttonText)
|
|
513
|
+
);
|
|
514
|
+
}
|
|
515
|
+
var SuggestedAction_default2 = memo7(SuggestedAction);
|
|
516
|
+
|
|
517
|
+
// src/components/suggestedActions/private/computeSuggestedActionText.ts
|
|
518
|
+
function computeSuggestedActionText(cardAction) {
|
|
519
|
+
const { title } = cardAction;
|
|
520
|
+
const { type, value } = cardAction;
|
|
521
|
+
if (type === "messageBack") {
|
|
522
|
+
return title || cardAction.displayText;
|
|
523
|
+
} else if (title) {
|
|
524
|
+
return title;
|
|
525
|
+
} else if (typeof value === "string") {
|
|
526
|
+
return value;
|
|
527
|
+
}
|
|
528
|
+
return JSON.stringify(value);
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
// src/components/suggestedActions/index.module.css
|
|
532
|
+
var suggestedActions_default = {
|
|
533
|
+
"suggested-actions": "suggestedActions_suggested-actions",
|
|
534
|
+
"suggested-actions--flow": "suggestedActions_suggested-actions--flow",
|
|
535
|
+
"suggested-actions--stacked": "suggestedActions_suggested-actions--stacked"
|
|
536
|
+
};
|
|
537
|
+
|
|
538
|
+
// src/components/suggestedActions/index.tsx
|
|
539
|
+
var { useLocalizer: useLocalizer2, useStyleOptions, useStyleSet: useStyleSet2, useSuggestedActions: useSuggestedActions2 } = hooks3;
|
|
540
|
+
function SuggestedActionStackedOrFlowContainer(props) {
|
|
541
|
+
const [{ suggestedActionLayout }] = useStyleOptions();
|
|
542
|
+
const [{ suggestedActions: suggestedActionsStyleSet }] = useStyleSet2();
|
|
543
|
+
const classNames = useStyles_default(suggestedActions_default);
|
|
544
|
+
return /* @__PURE__ */ React11.createElement(
|
|
545
|
+
"div",
|
|
546
|
+
{
|
|
547
|
+
"aria-label": props["aria-label"],
|
|
548
|
+
"aria-live": "polite",
|
|
549
|
+
"aria-orientation": "vertical",
|
|
550
|
+
className: cx4(
|
|
551
|
+
classNames["suggested-actions"],
|
|
552
|
+
suggestedActionsStyleSet + "",
|
|
553
|
+
{
|
|
554
|
+
[classNames["suggested-actions--flow"]]: suggestedActionLayout === "flow",
|
|
555
|
+
[classNames["suggested-actions--stacked"]]: suggestedActionLayout !== "flow"
|
|
556
|
+
},
|
|
557
|
+
props.className
|
|
558
|
+
),
|
|
559
|
+
role: "toolbar"
|
|
560
|
+
},
|
|
561
|
+
!!props.children && !!React11.Children.count(props.children) && props.children
|
|
562
|
+
);
|
|
563
|
+
}
|
|
564
|
+
function SuggestedActions() {
|
|
565
|
+
const classNames = useStyles_default(suggestedActions_default);
|
|
566
|
+
const localize = useLocalizer2();
|
|
567
|
+
const [suggestedActions] = useSuggestedActions2();
|
|
568
|
+
const children = suggestedActions.map((cardAction, index) => {
|
|
569
|
+
const { displayText, image, imageAltText, text, type, value } = cardAction;
|
|
570
|
+
if (!suggestedActions?.length) {
|
|
571
|
+
return null;
|
|
572
|
+
}
|
|
573
|
+
return /* @__PURE__ */ React11.createElement(
|
|
574
|
+
SuggestedAction_default2,
|
|
575
|
+
{
|
|
576
|
+
buttonText: computeSuggestedActionText(cardAction),
|
|
577
|
+
displayText,
|
|
578
|
+
image,
|
|
579
|
+
imageAlt: image && (imageAltText || text),
|
|
580
|
+
itemIndex: index,
|
|
581
|
+
key: index,
|
|
582
|
+
text,
|
|
583
|
+
type,
|
|
584
|
+
value
|
|
585
|
+
}
|
|
586
|
+
);
|
|
587
|
+
});
|
|
588
|
+
return /* @__PURE__ */ React11.createElement(
|
|
589
|
+
SuggestedActionStackedOrFlowContainer,
|
|
590
|
+
{
|
|
591
|
+
"aria-label": localize("SUGGESTED_ACTIONS_LABEL_ALT"),
|
|
592
|
+
className: classNames["suggested-actions"]
|
|
593
|
+
},
|
|
594
|
+
children
|
|
595
|
+
);
|
|
596
|
+
}
|
|
597
|
+
var suggestedActions_default2 = memo8(SuggestedActions);
|
|
598
|
+
|
|
599
|
+
// src/components/SuggestedActions.tsx
|
|
600
|
+
var SuggestedActions_default = suggestedActions_default2;
|
|
601
|
+
|
|
602
|
+
// src/components/sendbox/AddAttachmentButton.tsx
|
|
603
|
+
import { hooks as hooks4 } from "botframework-webchat-component";
|
|
604
|
+
import React14, { useCallback as useCallback5, useRef as useRef5, memo as memo10 } from "react";
|
|
605
|
+
import { useRefFrom as useRefFrom4 } from "use-ref-from";
|
|
606
|
+
|
|
607
|
+
// src/icons/AttachmentIcon.tsx
|
|
608
|
+
import React12 from "react";
|
|
609
|
+
function AttachmentIcon(props) {
|
|
610
|
+
return /* @__PURE__ */ React12.createElement(
|
|
611
|
+
"svg",
|
|
612
|
+
{
|
|
613
|
+
"aria-hidden": "true",
|
|
614
|
+
className: props.className,
|
|
615
|
+
fill: "currentColor",
|
|
616
|
+
height: "1em",
|
|
617
|
+
viewBox: "0 0 20 20",
|
|
618
|
+
width: "1em",
|
|
619
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
620
|
+
},
|
|
621
|
+
/* @__PURE__ */ React12.createElement(
|
|
622
|
+
"path",
|
|
623
|
+
{
|
|
624
|
+
d: "m4.83 10.48 5.65-5.65a3 3 0 0 1 4.25 4.24L8 15.8a1.5 1.5 0 0 1-2.12-2.12l6-6.01a.5.5 0 1 0-.7-.71l-6 6.01a2.5 2.5 0 0 0 3.53 3.54l6.71-6.72a4 4 0 1 0-5.65-5.66L4.12 9.78a.5.5 0 0 0 .7.7Z",
|
|
625
|
+
fill: "currentColor"
|
|
626
|
+
}
|
|
627
|
+
)
|
|
628
|
+
);
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
// src/components/sendbox/Toolbar.tsx
|
|
632
|
+
import cx5 from "classnames";
|
|
633
|
+
import React13, { memo as memo9 } from "react";
|
|
634
|
+
|
|
635
|
+
// src/components/sendbox/Toolbar.module.css
|
|
636
|
+
var Toolbar_default = {
|
|
637
|
+
sendbox__toolbar: "Toolbar_sendbox__toolbar",
|
|
638
|
+
"sendbox__toolbar-button": "Toolbar_sendbox__toolbar-button",
|
|
639
|
+
"sendbox__toolbar-separator": "Toolbar_sendbox__toolbar-separator"
|
|
640
|
+
};
|
|
641
|
+
|
|
642
|
+
// src/components/sendbox/Toolbar.tsx
|
|
643
|
+
var preventDefaultHandler2 = (event) => event.preventDefault();
|
|
644
|
+
var ToolbarButton = memo9(
|
|
645
|
+
(props) => {
|
|
646
|
+
const classNames = useStyles_default(Toolbar_default);
|
|
647
|
+
return /* @__PURE__ */ React13.createElement(
|
|
648
|
+
"button",
|
|
649
|
+
{
|
|
650
|
+
"aria-label": props["aria-label"],
|
|
651
|
+
className: cx5(classNames["sendbox__toolbar-button"], props.className),
|
|
652
|
+
"data-testid": props["data-testid"],
|
|
653
|
+
onClick: props.disabled ? preventDefaultHandler2 : props.onClick,
|
|
654
|
+
type: props.type === "submit" ? "submit" : "button",
|
|
655
|
+
...props.disabled && {
|
|
656
|
+
"aria-disabled": "true",
|
|
657
|
+
tabIndex: -1
|
|
658
|
+
}
|
|
659
|
+
},
|
|
660
|
+
props.children
|
|
661
|
+
);
|
|
662
|
+
}
|
|
663
|
+
);
|
|
664
|
+
ToolbarButton.displayName = "ToolbarButton";
|
|
665
|
+
var Toolbar = memo9((props) => {
|
|
666
|
+
const classNames = useStyles_default(Toolbar_default);
|
|
667
|
+
return /* @__PURE__ */ React13.createElement("div", { className: cx5(classNames["sendbox__toolbar"], props.className) }, props.children);
|
|
668
|
+
});
|
|
669
|
+
Toolbar.displayName = "Toolbar";
|
|
670
|
+
var ToolbarSeparator = memo9(
|
|
671
|
+
(props) => {
|
|
672
|
+
const classNames = useStyles_default(Toolbar_default);
|
|
673
|
+
return /* @__PURE__ */ React13.createElement(
|
|
674
|
+
"div",
|
|
675
|
+
{
|
|
676
|
+
"aria-orientation": "vertical",
|
|
677
|
+
className: cx5(classNames["sendbox__toolbar-separator"], props.className),
|
|
678
|
+
role: "separator"
|
|
679
|
+
}
|
|
680
|
+
);
|
|
681
|
+
}
|
|
682
|
+
);
|
|
683
|
+
ToolbarSeparator.displayName = "ToolbarSeparator";
|
|
684
|
+
|
|
685
|
+
// src/components/sendbox/AddAttachmentButton.module.css
|
|
686
|
+
var AddAttachmentButton_default = {
|
|
687
|
+
"sendbox__add-attachment": "AddAttachmentButton_sendbox__add-attachment",
|
|
688
|
+
"sendbox__add-attachment-input": "AddAttachmentButton_sendbox__add-attachment-input"
|
|
689
|
+
};
|
|
690
|
+
|
|
691
|
+
// src/components/sendbox/AddAttachmentButton.tsx
|
|
692
|
+
var { useLocalizer: useLocalizer3, useStyleOptions: useStyleOptions2 } = hooks4;
|
|
693
|
+
function AddAttachmentButton(props) {
|
|
694
|
+
const inputRef = useRef5(null);
|
|
695
|
+
const classNames = useStyles_default(AddAttachmentButton_default);
|
|
696
|
+
const localize = useLocalizer3();
|
|
697
|
+
const [{ uploadAccept, uploadMultiple }] = useStyleOptions2();
|
|
698
|
+
const onFilesAddedRef = useRefFrom4(props.onFilesAdded);
|
|
699
|
+
const handleClick = useCallback5(() => inputRef.current?.click(), [inputRef]);
|
|
700
|
+
const handleFileChange = useCallback5(
|
|
701
|
+
({ target: { files } }) => {
|
|
702
|
+
if (files) {
|
|
703
|
+
onFilesAddedRef.current?.([...files]);
|
|
704
|
+
if (inputRef.current) {
|
|
705
|
+
inputRef.current.value = "";
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
},
|
|
709
|
+
[inputRef, onFilesAddedRef]
|
|
710
|
+
);
|
|
711
|
+
return /* @__PURE__ */ React14.createElement("div", { className: classNames["sendbox__add-attachment"] }, /* @__PURE__ */ React14.createElement(
|
|
712
|
+
"input",
|
|
713
|
+
{
|
|
714
|
+
accept: uploadAccept,
|
|
715
|
+
"aria-disabled": props.disabled,
|
|
716
|
+
"aria-hidden": "true",
|
|
717
|
+
className: classNames["sendbox__add-attachment-input"],
|
|
718
|
+
multiple: uploadMultiple,
|
|
719
|
+
onInput: props.disabled ? void 0 : handleFileChange,
|
|
720
|
+
readOnly: props.disabled,
|
|
721
|
+
ref: inputRef,
|
|
722
|
+
role: "button",
|
|
723
|
+
tabIndex: -1,
|
|
724
|
+
type: "file"
|
|
725
|
+
}
|
|
726
|
+
), /* @__PURE__ */ React14.createElement(
|
|
727
|
+
ToolbarButton,
|
|
728
|
+
{
|
|
729
|
+
"aria-label": localize("TEXT_INPUT_UPLOAD_BUTTON_ALT"),
|
|
730
|
+
"data-testid": testIds_default.sendBoxUploadButton,
|
|
731
|
+
onClick: handleClick
|
|
732
|
+
},
|
|
733
|
+
/* @__PURE__ */ React14.createElement(AttachmentIcon, null)
|
|
734
|
+
));
|
|
735
|
+
}
|
|
736
|
+
var AddAttachmentButton_default2 = memo10(AddAttachmentButton);
|
|
737
|
+
|
|
738
|
+
// src/components/sendbox/Attachments.tsx
|
|
739
|
+
import { hooks as hooks5 } from "botframework-webchat-component";
|
|
740
|
+
import React15, { memo as memo11 } from "react";
|
|
741
|
+
|
|
742
|
+
// src/components/sendbox/Attachments.module.css
|
|
743
|
+
var Attachments_default = {
|
|
744
|
+
sendbox__attachment: "Attachments_sendbox__attachment"
|
|
745
|
+
};
|
|
746
|
+
|
|
747
|
+
// src/components/sendbox/Attachments.tsx
|
|
748
|
+
var { useLocalizer: useLocalizer4 } = hooks5;
|
|
749
|
+
var attachmentsPluralStringIds = {
|
|
750
|
+
one: "TEXT_INPUT_ATTACHMENTS_ONE",
|
|
751
|
+
two: "TEXT_INPUT_ATTACHMENTS_TWO",
|
|
752
|
+
few: "TEXT_INPUT_ATTACHMENTS_FEW",
|
|
753
|
+
many: "TEXT_INPUT_ATTACHMENTS_MANY",
|
|
754
|
+
other: "TEXT_INPUT_ATTACHMENTS_OTHER"
|
|
755
|
+
};
|
|
756
|
+
function Attachments({
|
|
757
|
+
attachments
|
|
758
|
+
}) {
|
|
759
|
+
const classNames = useStyles_default(Attachments_default);
|
|
760
|
+
const localizeWithPlural = useLocalizer4({ plural: true });
|
|
761
|
+
return attachments.length ? /* @__PURE__ */ React15.createElement("div", { className: classNames["sendbox__attachment"] }, localizeWithPlural(attachmentsPluralStringIds, attachments.length)) : null;
|
|
762
|
+
}
|
|
763
|
+
var Attachments_default2 = memo11(Attachments);
|
|
764
|
+
|
|
765
|
+
// src/components/sendbox/ErrorMessage.tsx
|
|
766
|
+
import React16, { memo as memo12 } from "react";
|
|
767
|
+
|
|
768
|
+
// src/components/sendbox/ErrorMessage.module.css
|
|
769
|
+
var ErrorMessage_default = {
|
|
770
|
+
"sendbox__error-message": "ErrorMessage_sendbox__error-message"
|
|
771
|
+
};
|
|
772
|
+
|
|
773
|
+
// src/components/sendbox/ErrorMessage.tsx
|
|
774
|
+
function ErrorMessage(props) {
|
|
775
|
+
const classNames = useStyles_default(ErrorMessage_default);
|
|
776
|
+
return (
|
|
777
|
+
// eslint-disable-next-line react/forbid-dom-props
|
|
778
|
+
/* @__PURE__ */ React16.createElement("span", { className: classNames["sendbox__error-message"], id: props.id, role: "alert" }, props.error)
|
|
779
|
+
);
|
|
780
|
+
}
|
|
781
|
+
var ErrorMessage_default2 = memo12(ErrorMessage);
|
|
782
|
+
|
|
783
|
+
// src/components/sendbox/TelephoneKeypadToolbarButton.tsx
|
|
784
|
+
import React18, { memo as memo13, useCallback as useCallback6 } from "react";
|
|
785
|
+
import { hooks as hooks6 } from "botframework-webchat-component";
|
|
786
|
+
|
|
787
|
+
// src/icons/TelephoneKeypad.tsx
|
|
788
|
+
import React17 from "react";
|
|
789
|
+
function TelephoneKeypadIcon(props) {
|
|
790
|
+
return /* @__PURE__ */ React17.createElement(
|
|
791
|
+
"svg",
|
|
792
|
+
{
|
|
793
|
+
"aria-hidden": "true",
|
|
794
|
+
className: props.className,
|
|
795
|
+
fill: "currentColor",
|
|
796
|
+
height: "1em",
|
|
797
|
+
viewBox: "0 0 20 20",
|
|
798
|
+
width: "1em",
|
|
799
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
800
|
+
},
|
|
801
|
+
/* @__PURE__ */ React17.createElement(
|
|
802
|
+
"path",
|
|
803
|
+
{
|
|
804
|
+
d: "M6 5.25a1.25 1.25 0 1 0 0-2.5 1.25 1.25 0 0 0 0 2.5Zm0 4a1.25 1.25 0 1 0 0-2.5 1.25 1.25 0 0 0 0 2.5ZM7.25 12a1.25 1.25 0 1 1-2.5 0 1.25 1.25 0 0 1 2.5 0ZM10 5.25a1.25 1.25 0 1 0 0-2.5 1.25 1.25 0 0 0 0 2.5ZM11.25 8a1.25 1.25 0 1 1-2.5 0 1.25 1.25 0 0 1 2.5 0ZM10 13.25a1.25 1.25 0 1 0 0-2.5 1.25 1.25 0 0 0 0 2.5ZM11.25 16a1.25 1.25 0 1 1-2.5 0 1.25 1.25 0 0 1 2.5 0ZM14 5.25a1.25 1.25 0 1 0 0-2.5 1.25 1.25 0 0 0 0 2.5ZM15.25 8a1.25 1.25 0 1 1-2.5 0 1.25 1.25 0 0 1 2.5 0ZM14 13.25a1.25 1.25 0 1 0 0-2.5 1.25 1.25 0 0 0 0 2.5Z",
|
|
805
|
+
fill: "currentColor"
|
|
806
|
+
}
|
|
807
|
+
)
|
|
808
|
+
);
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
// src/components/sendbox/TelephoneKeypadToolbarButton.tsx
|
|
812
|
+
var { useLocalizer: useLocalizer5 } = hooks6;
|
|
813
|
+
var TelephoneKeypadToolbarButton = memo13(() => {
|
|
814
|
+
const [, setTelephoneKeypadShown] = useShown();
|
|
815
|
+
const localize = useLocalizer5();
|
|
816
|
+
const handleClick = useCallback6(() => setTelephoneKeypadShown((shown) => !shown), [setTelephoneKeypadShown]);
|
|
817
|
+
return /* @__PURE__ */ React18.createElement(
|
|
818
|
+
ToolbarButton,
|
|
819
|
+
{
|
|
820
|
+
"aria-label": localize("TEXT_INPUT_TELEPHONE_KEYPAD_BUTTON_ALT"),
|
|
821
|
+
"data-testid": testIds_default.sendBoxTelephoneKeypadToolbarButton,
|
|
822
|
+
onClick: handleClick
|
|
823
|
+
},
|
|
824
|
+
/* @__PURE__ */ React18.createElement(TelephoneKeypadIcon, null)
|
|
825
|
+
);
|
|
826
|
+
});
|
|
827
|
+
TelephoneKeypadToolbarButton.displayName = "SendBox.TelephoneKeypadToolbarButton";
|
|
828
|
+
var TelephoneKeypadToolbarButton_default = TelephoneKeypadToolbarButton;
|
|
829
|
+
|
|
830
|
+
// src/components/sendbox/TextArea.tsx
|
|
831
|
+
import cx6 from "classnames";
|
|
832
|
+
import React19, { forwardRef as forwardRef3, useCallback as useCallback7 } from "react";
|
|
833
|
+
|
|
834
|
+
// src/components/sendbox/TextArea.module.css
|
|
835
|
+
var TextArea_default = {
|
|
836
|
+
"sendbox__text-area": "TextArea_sendbox__text-area",
|
|
837
|
+
"sendbox__text-area--hidden": "TextArea_sendbox__text-area--hidden",
|
|
838
|
+
"sendbox__text-area-shared": "TextArea_sendbox__text-area-shared",
|
|
839
|
+
"sendbox__text-area-doppelganger": "TextArea_sendbox__text-area-doppelganger",
|
|
840
|
+
"sendbox__text-area-input": "TextArea_sendbox__text-area-input",
|
|
841
|
+
"sendbox__text-area-input--scroll": "TextArea_sendbox__text-area-input--scroll"
|
|
842
|
+
};
|
|
843
|
+
|
|
844
|
+
// src/components/sendbox/TextArea.tsx
|
|
845
|
+
var TextArea = forwardRef3((props, ref) => {
|
|
846
|
+
const classNames = useStyles_default(TextArea_default);
|
|
847
|
+
const handleKeyDown = useCallback7((event) => {
|
|
848
|
+
if (!event.shiftKey && event.key === "Enter") {
|
|
849
|
+
event.preventDefault();
|
|
850
|
+
if ("form" in event.target && event.target.form instanceof HTMLFormElement) {
|
|
851
|
+
event.target?.form?.requestSubmit();
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
}, []);
|
|
855
|
+
return /* @__PURE__ */ React19.createElement(
|
|
856
|
+
"div",
|
|
857
|
+
{
|
|
858
|
+
className: cx6(
|
|
859
|
+
classNames["sendbox__text-area"],
|
|
860
|
+
{
|
|
861
|
+
[classNames["sendbox__text-area--hidden"]]: props.hidden
|
|
862
|
+
},
|
|
863
|
+
props.className
|
|
864
|
+
),
|
|
865
|
+
role: props.hidden ? "hidden" : void 0
|
|
866
|
+
},
|
|
867
|
+
/* @__PURE__ */ React19.createElement(
|
|
868
|
+
"div",
|
|
869
|
+
{
|
|
870
|
+
className: cx6(
|
|
871
|
+
classNames["sendbox__text-area-doppelganger"],
|
|
872
|
+
classNames["sendbox__text-area-shared"],
|
|
873
|
+
classNames["sendbox__text-area-input--scroll"]
|
|
874
|
+
)
|
|
875
|
+
},
|
|
876
|
+
props.value || props.placeholder,
|
|
877
|
+
" "
|
|
878
|
+
),
|
|
879
|
+
/* @__PURE__ */ React19.createElement(
|
|
880
|
+
"textarea",
|
|
881
|
+
{
|
|
882
|
+
"aria-label": props["aria-label"],
|
|
883
|
+
className: cx6(
|
|
884
|
+
classNames["sendbox__text-area-input"],
|
|
885
|
+
classNames["sendbox__text-area-shared"],
|
|
886
|
+
classNames["sendbox__text-area-input--scroll"]
|
|
887
|
+
),
|
|
888
|
+
"data-testid": props["data-testid"],
|
|
889
|
+
onInput: props.onInput,
|
|
890
|
+
onKeyDown: handleKeyDown,
|
|
891
|
+
placeholder: props.placeholder,
|
|
892
|
+
ref,
|
|
893
|
+
rows: props.startRows ?? 1,
|
|
894
|
+
tabIndex: props.hidden ? -1 : void 0,
|
|
895
|
+
value: props.value
|
|
896
|
+
}
|
|
897
|
+
)
|
|
898
|
+
);
|
|
899
|
+
});
|
|
900
|
+
TextArea.displayName = "TextArea";
|
|
901
|
+
var TextArea_default2 = TextArea;
|
|
902
|
+
|
|
903
|
+
// src/components/sendbox/private/useSubmitError.ts
|
|
904
|
+
import { hooks as hooks7 } from "botframework-webchat-component";
|
|
905
|
+
import { useMemo as useMemo4 } from "react";
|
|
906
|
+
import { useRefFrom as useRefFrom5 } from "use-ref-from";
|
|
907
|
+
var { useConnectivityStatus, useLocalizer: useLocalizer6 } = hooks7;
|
|
908
|
+
var useSubmitError = ({
|
|
909
|
+
attachments,
|
|
910
|
+
message
|
|
911
|
+
}) => {
|
|
912
|
+
const [connectivityStatus] = useConnectivityStatus();
|
|
913
|
+
const localize = useLocalizer6();
|
|
914
|
+
const submitErrorRef = useRefFrom5(
|
|
915
|
+
connectivityStatus !== "connected" && connectivityStatus !== "reconnected" ? "offline" : !message && !attachments.length ? "empty" : void 0
|
|
916
|
+
);
|
|
917
|
+
const errorMessageStringMap = useMemo4(
|
|
918
|
+
() => Object.freeze(
|
|
919
|
+
(/* @__PURE__ */ new Map()).set("empty", localize("SEND_BOX_IS_EMPTY_TOOLTIP_ALT")).set("offline", localize("CONNECTIVITY_STATUS_ALT_FATAL"))
|
|
920
|
+
),
|
|
921
|
+
[localize]
|
|
922
|
+
);
|
|
923
|
+
return useMemo4(
|
|
924
|
+
() => Object.freeze([submitErrorRef, submitErrorRef.current && errorMessageStringMap.get(submitErrorRef.current)]),
|
|
925
|
+
[errorMessageStringMap, submitErrorRef]
|
|
926
|
+
);
|
|
927
|
+
};
|
|
928
|
+
var useSubmitError_default = useSubmitError;
|
|
929
|
+
|
|
930
|
+
// src/components/sendbox/private/useUniqueId.ts
|
|
931
|
+
import { useMemo as useMemo5 } from "react";
|
|
932
|
+
function useUniqueId(prefix) {
|
|
933
|
+
const id = useMemo5(() => Math.random().toString(36).substr(2, 5), []);
|
|
934
|
+
prefix = prefix ? `${prefix}--` : "";
|
|
935
|
+
return `${prefix}${id}`;
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
// src/components/sendbox/index.module.css
|
|
939
|
+
var sendbox_default = {
|
|
940
|
+
sendbox: "sendbox_sendbox",
|
|
941
|
+
sendbox__sendbox: "sendbox_sendbox__sendbox",
|
|
942
|
+
"sendbox__sendbox-text": "sendbox_sendbox__sendbox-text",
|
|
943
|
+
"sendbox__sendbox-controls": "sendbox_sendbox__sendbox-controls",
|
|
944
|
+
"sendbox__text-counter": "sendbox_sendbox__text-counter",
|
|
945
|
+
"sendbox__text-counter--error": "sendbox_sendbox__text-counter--error"
|
|
946
|
+
};
|
|
947
|
+
|
|
948
|
+
// src/components/sendbox/index.tsx
|
|
949
|
+
var { useStyleOptions: useStyleOptions3, useMakeThumbnail, useLocalizer: useLocalizer7, useSendBoxAttachments, useSendMessage } = hooks8;
|
|
950
|
+
function SendBox(props) {
|
|
951
|
+
const inputRef = useRef6(null);
|
|
952
|
+
const [message, setMessage] = useState3("");
|
|
953
|
+
const [attachments, setAttachments] = useSendBoxAttachments();
|
|
954
|
+
const [{ hideTelephoneKeypadButton, hideUploadButton, maxMessageLength }] = useStyleOptions3();
|
|
955
|
+
const isMessageLengthExceeded = !!maxMessageLength && message.length > maxMessageLength;
|
|
956
|
+
const classNames = useStyles_default(sendbox_default);
|
|
957
|
+
const localize = useLocalizer7();
|
|
958
|
+
const sendMessage = useSendMessage();
|
|
959
|
+
const makeThumbnail = useMakeThumbnail();
|
|
960
|
+
const errorMessageId = useUniqueId("sendbox__error-message-id");
|
|
961
|
+
const [errorRef, errorMessage] = useSubmitError_default({ message, attachments });
|
|
962
|
+
const [telephoneKeypadShown] = useShown();
|
|
963
|
+
const attachmentsRef = useRefFrom6(attachments);
|
|
964
|
+
const messageRef = useRefFrom6(message);
|
|
965
|
+
const handleSendBoxClick = useCallback8(
|
|
966
|
+
(event) => {
|
|
967
|
+
if ("tabIndex" in event.target && typeof event.target.tabIndex === "number" && event.target.tabIndex >= 0) {
|
|
968
|
+
return;
|
|
969
|
+
}
|
|
970
|
+
inputRef.current?.focus();
|
|
971
|
+
},
|
|
972
|
+
[inputRef]
|
|
973
|
+
);
|
|
974
|
+
const handleMessageChange = useCallback8(
|
|
975
|
+
(event) => setMessage(event.currentTarget.value),
|
|
976
|
+
[setMessage]
|
|
977
|
+
);
|
|
978
|
+
const handleAddFiles = useCallback8(
|
|
979
|
+
async (inputFiles) => {
|
|
980
|
+
const newAttachments = Object.freeze(
|
|
981
|
+
await Promise.all(
|
|
982
|
+
inputFiles.map(
|
|
983
|
+
(file) => makeThumbnail(file).then(
|
|
984
|
+
(thumbnailURL) => Object.freeze({
|
|
985
|
+
blob: file,
|
|
986
|
+
...thumbnailURL && { thumbnailURL }
|
|
987
|
+
})
|
|
988
|
+
)
|
|
989
|
+
)
|
|
990
|
+
)
|
|
991
|
+
);
|
|
992
|
+
setAttachments(newAttachments);
|
|
993
|
+
},
|
|
994
|
+
[makeThumbnail, setAttachments]
|
|
995
|
+
);
|
|
996
|
+
const handleFormSubmit = useCallback8(
|
|
997
|
+
(event) => {
|
|
998
|
+
event.preventDefault();
|
|
999
|
+
if (errorRef.current !== "empty" && !isMessageLengthExceeded) {
|
|
1000
|
+
sendMessage(messageRef.current, void 0, { attachments: attachmentsRef.current });
|
|
1001
|
+
setMessage("");
|
|
1002
|
+
setAttachments([]);
|
|
1003
|
+
}
|
|
1004
|
+
inputRef.current?.focus();
|
|
1005
|
+
},
|
|
1006
|
+
[attachmentsRef, messageRef, sendMessage, setAttachments, setMessage, isMessageLengthExceeded, errorRef, inputRef]
|
|
1007
|
+
);
|
|
1008
|
+
const handleTelephoneKeypadButtonClick = useCallback8(
|
|
1009
|
+
// TODO: We need more official way of sending DTMF.
|
|
1010
|
+
(dtmf) => sendMessage(`/DTMF ${dtmf}`),
|
|
1011
|
+
[sendMessage]
|
|
1012
|
+
);
|
|
1013
|
+
const aria = {
|
|
1014
|
+
"aria-invalid": "false",
|
|
1015
|
+
...errorMessage && {
|
|
1016
|
+
"aria-invalid": "true",
|
|
1017
|
+
"aria-errormessage": errorMessageId
|
|
1018
|
+
}
|
|
1019
|
+
};
|
|
1020
|
+
return /* @__PURE__ */ React20.createElement("form", { ...aria, className: cx7(classNames["sendbox"], props.className), onSubmit: handleFormSubmit }, /* @__PURE__ */ React20.createElement(SuggestedActions_default, null), /* @__PURE__ */ React20.createElement("div", { className: cx7(classNames["sendbox__sendbox"]), onClickCapture: handleSendBoxClick }, /* @__PURE__ */ React20.createElement(
|
|
1021
|
+
Surrogate_default,
|
|
1022
|
+
{
|
|
1023
|
+
autoFocus: true,
|
|
1024
|
+
isHorizontal: false,
|
|
1025
|
+
onButtonClick: handleTelephoneKeypadButtonClick
|
|
1026
|
+
}
|
|
1027
|
+
), /* @__PURE__ */ React20.createElement(
|
|
1028
|
+
TextArea_default2,
|
|
1029
|
+
{
|
|
1030
|
+
"aria-label": isMessageLengthExceeded ? localize("TEXT_INPUT_LENGTH_EXCEEDED_ALT") : localize("TEXT_INPUT_ALT"),
|
|
1031
|
+
className: classNames["sendbox__sendbox-text"],
|
|
1032
|
+
"data-testid": testIds_default.sendBoxTextBox,
|
|
1033
|
+
hidden: telephoneKeypadShown,
|
|
1034
|
+
onInput: handleMessageChange,
|
|
1035
|
+
placeholder: props.placeholder ?? localize("TEXT_INPUT_PLACEHOLDER"),
|
|
1036
|
+
ref: inputRef,
|
|
1037
|
+
value: message
|
|
1038
|
+
}
|
|
1039
|
+
), /* @__PURE__ */ React20.createElement(Attachments_default2, { attachments }), /* @__PURE__ */ React20.createElement("div", { className: cx7(classNames["sendbox__sendbox-controls"]) }, maxMessageLength && /* @__PURE__ */ React20.createElement(
|
|
1040
|
+
"div",
|
|
1041
|
+
{
|
|
1042
|
+
className: cx7(classNames["sendbox__text-counter"], {
|
|
1043
|
+
[classNames["sendbox__text-counter--error"]]: isMessageLengthExceeded
|
|
1044
|
+
})
|
|
1045
|
+
},
|
|
1046
|
+
`${message.length}/${maxMessageLength}`
|
|
1047
|
+
), /* @__PURE__ */ React20.createElement(Toolbar, null, !hideTelephoneKeypadButton && /* @__PURE__ */ React20.createElement(TelephoneKeypadToolbarButton_default, null), !hideUploadButton && /* @__PURE__ */ React20.createElement(AddAttachmentButton_default2, { onFilesAdded: handleAddFiles }), /* @__PURE__ */ React20.createElement(ToolbarSeparator, null), /* @__PURE__ */ React20.createElement(
|
|
1048
|
+
ToolbarButton,
|
|
1049
|
+
{
|
|
1050
|
+
"aria-label": localize("TEXT_INPUT_SEND_BUTTON_ALT"),
|
|
1051
|
+
"data-testid": testIds_default.sendBoxSendButton,
|
|
1052
|
+
disabled: isMessageLengthExceeded,
|
|
1053
|
+
type: "submit"
|
|
1054
|
+
},
|
|
1055
|
+
/* @__PURE__ */ React20.createElement(SendIcon, null)
|
|
1056
|
+
))), /* @__PURE__ */ React20.createElement(DropZone_default, { onFilesAdded: handleAddFiles }), /* @__PURE__ */ React20.createElement(ErrorMessage_default2, { error: errorMessage, id: errorMessageId })));
|
|
1057
|
+
}
|
|
1058
|
+
var sendbox_default2 = memo14(SendBox);
|
|
1059
|
+
|
|
1060
|
+
// src/components/SendBox.tsx
|
|
1061
|
+
var SendBox_default = sendbox_default2;
|
|
1062
|
+
|
|
1063
|
+
// src/private/FluentThemeProvider.tsx
|
|
1064
|
+
var { ThemeProvider } = Components;
|
|
1065
|
+
var sendBoxMiddleware = [() => () => () => SendBox_default];
|
|
1066
|
+
var FluentThemeProvider = ({ children }) => /* @__PURE__ */ React21.createElement(WebchatTheme, null, /* @__PURE__ */ React21.createElement(Provider_default, null, /* @__PURE__ */ React21.createElement(ThemeProvider, { sendBoxMiddleware }, children)));
|
|
1067
|
+
var FluentThemeProvider_default = memo15(FluentThemeProvider);
|
|
1068
|
+
|
|
1069
|
+
// src/index.ts
|
|
1070
|
+
injectMetaTag("botframework-webchat-fluent-theme:version", "4.17.0-main.20240416.4ff01ae");
|
|
1071
|
+
injectStyles();
|
|
1072
|
+
export {
|
|
1073
|
+
FluentThemeProvider_default as FluentThemeProvider,
|
|
1074
|
+
testIds_default as testIds
|
|
1075
|
+
};
|
|
1076
|
+
//# sourceMappingURL=index.mjs.map
|