botframework-webchat-fluent-theme 4.17.0-main.20240411.647b269 → 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 +2384 -0
- package/dist/botframework-webchat-fluent-theme.development.js.map +1 -0
- package/dist/botframework-webchat-fluent-theme.production.min.css.map +1 -0
- package/dist/botframework-webchat-fluent-theme.production.min.js +6 -16
- 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 +1062 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1076 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +17 -7
- package/src/bundle.ts +9 -2
- package/src/components/DropZone.tsx +3 -0
- package/src/components/SendBox.tsx +3 -0
- package/src/components/SuggestedActions.tsx +3 -0
- package/src/components/TelephoneKeypad.tsx +1 -0
- package/src/components/Theme.module.css +60 -0
- package/src/components/Theme.tsx +11 -0
- package/src/components/dropZone/index.module.css +23 -0
- package/src/components/dropZone/index.tsx +107 -0
- package/src/components/sendbox/AddAttachmentButton.module.css +10 -0
- package/src/components/sendbox/AddAttachmentButton.tsx +65 -0
- package/src/components/sendbox/Attachments.module.css +7 -0
- package/src/components/sendbox/Attachments.tsx +31 -0
- package/src/components/sendbox/ErrorMessage.module.css +9 -0
- package/src/components/sendbox/ErrorMessage.tsx +15 -0
- package/src/components/sendbox/TelephoneKeypadToolbarButton.tsx +30 -0
- package/src/components/sendbox/TextArea.module.css +61 -0
- package/src/components/sendbox/TextArea.tsx +85 -0
- package/src/components/sendbox/Toolbar.module.css +49 -0
- package/src/components/sendbox/Toolbar.tsx +64 -0
- package/src/components/sendbox/index.module.css +58 -0
- package/src/components/sendbox/index.tsx +169 -0
- package/src/components/sendbox/private/useSubmitError.ts +46 -0
- package/src/components/sendbox/private/useUniqueId.ts +13 -0
- package/src/components/suggestedActions/AccessibleButton.tsx +59 -0
- package/src/components/suggestedActions/SuggestedAction.module.css +34 -0
- package/src/components/suggestedActions/SuggestedAction.tsx +87 -0
- package/src/components/suggestedActions/index.module.css +23 -0
- package/src/components/suggestedActions/index.tsx +98 -0
- package/src/components/suggestedActions/private/computeSuggestedActionText.ts +21 -0
- package/src/components/telephoneKeypad/Provider.tsx +22 -0
- package/src/components/telephoneKeypad/Surrogate.tsx +13 -0
- package/src/components/telephoneKeypad/index.ts +6 -0
- package/src/components/telephoneKeypad/private/Button.module.css +62 -0
- package/src/components/telephoneKeypad/private/Button.tsx +45 -0
- package/src/components/telephoneKeypad/private/Context.ts +18 -0
- package/src/components/telephoneKeypad/private/TelephoneKeypad.module.css +30 -0
- package/src/components/telephoneKeypad/private/TelephoneKeypad.tsx +137 -0
- package/src/components/telephoneKeypad/types.ts +1 -0
- package/src/components/telephoneKeypad/useShown.ts +9 -0
- package/src/env.d.ts +7 -0
- package/src/external.umd/botframework-webchat-api.ts +3 -0
- package/src/external.umd/botframework-webchat-component.ts +4 -0
- package/src/external.umd/react.ts +1 -0
- package/src/icons/AddDocumentIcon.tsx +20 -0
- package/src/icons/AttachmentIcon.tsx +20 -0
- package/src/icons/SendIcon.tsx +20 -0
- package/src/icons/TelephoneKeypad.tsx +20 -0
- package/src/index.ts +5 -1
- package/src/private/FluentThemeProvider.tsx +11 -7
- package/src/styles/injectStyle.ts +9 -0
- package/src/styles/useStyles.ts +19 -0
- package/src/styles.ts +4 -0
- package/src/testIds.ts +21 -0
- package/src/tsconfig.json +2 -1
- package/src/types/PropsOf.ts +7 -0
- package/src/external/ThemeProvider.tsx +0 -16
- package/src/private/SendBox.tsx +0 -7
package/dist/index.js
CHANGED
|
@@ -30,37 +30,1083 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var src_exports = {};
|
|
32
32
|
__export(src_exports, {
|
|
33
|
-
FluentThemeProvider: () => FluentThemeProvider_default
|
|
33
|
+
FluentThemeProvider: () => FluentThemeProvider_default,
|
|
34
|
+
testIds: () => testIds_default
|
|
34
35
|
});
|
|
35
36
|
module.exports = __toCommonJS(src_exports);
|
|
36
37
|
var import_inject_meta_tag = require("inject-meta-tag");
|
|
37
38
|
|
|
38
39
|
// src/private/FluentThemeProvider.tsx
|
|
40
|
+
var import_botframework_webchat_component9 = require("botframework-webchat-component");
|
|
41
|
+
var import_react26 = __toESM(require("react"));
|
|
42
|
+
|
|
43
|
+
// src/components/telephoneKeypad/Provider.tsx
|
|
39
44
|
var import_react2 = __toESM(require("react"));
|
|
40
45
|
|
|
41
|
-
// src/
|
|
42
|
-
var
|
|
43
|
-
|
|
44
|
-
|
|
46
|
+
// src/components/telephoneKeypad/private/Context.ts
|
|
47
|
+
var import_react = require("react");
|
|
48
|
+
var Context = (0, import_react.createContext)(
|
|
49
|
+
new Proxy({}, {
|
|
50
|
+
get() {
|
|
51
|
+
throw new Error("botframework-webchat: This hook can only used under its corresponding <Provider>.");
|
|
52
|
+
}
|
|
53
|
+
})
|
|
54
|
+
);
|
|
55
|
+
Context.displayName = "TelephoneKeypad.Context";
|
|
56
|
+
var Context_default = Context;
|
|
57
|
+
|
|
58
|
+
// src/components/telephoneKeypad/Provider.tsx
|
|
59
|
+
var Provider = (0, import_react2.memo)(({ children }) => {
|
|
60
|
+
const [shown, setShown] = (0, import_react2.useState)(false);
|
|
61
|
+
const context = (0, import_react2.useMemo)(
|
|
62
|
+
() => Object.freeze({
|
|
63
|
+
setShown,
|
|
64
|
+
shown
|
|
65
|
+
}),
|
|
66
|
+
[setShown, shown]
|
|
67
|
+
);
|
|
68
|
+
return /* @__PURE__ */ import_react2.default.createElement(Context_default.Provider, { value: context }, children);
|
|
69
|
+
});
|
|
70
|
+
var Provider_default = Provider;
|
|
71
|
+
|
|
72
|
+
// src/components/telephoneKeypad/Surrogate.tsx
|
|
73
|
+
var import_react7 = __toESM(require("react"));
|
|
74
|
+
|
|
75
|
+
// src/components/telephoneKeypad/private/TelephoneKeypad.tsx
|
|
76
|
+
var import_react6 = __toESM(require("react"));
|
|
77
|
+
var import_use_ref_from2 = require("use-ref-from");
|
|
78
|
+
|
|
79
|
+
// src/components/telephoneKeypad/private/Button.tsx
|
|
80
|
+
var import_react4 = __toESM(require("react"));
|
|
81
|
+
var import_use_ref_from = require("use-ref-from");
|
|
82
|
+
|
|
83
|
+
// src/components/telephoneKeypad/private/Button.module.css
|
|
84
|
+
var Button_default = {
|
|
85
|
+
"telephone-keypad__button": "Button_telephone-keypad__button",
|
|
86
|
+
"telephone-keypad__button__ruby": "Button_telephone-keypad__button__ruby",
|
|
87
|
+
"telephone-keypad__button__text": "Button_telephone-keypad__button__text",
|
|
88
|
+
"telephone-keypad--horizontal": "Button_telephone-keypad--horizontal"
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
// src/styles/injectStyle.ts
|
|
92
|
+
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";
|
|
93
|
+
function injectStyles() {
|
|
94
|
+
if (globalThis.document) {
|
|
95
|
+
const style = document.createElement("style");
|
|
96
|
+
style.append(document.createTextNode(injectedStyles));
|
|
97
|
+
document.head.appendChild(style);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// src/styles/useStyles.ts
|
|
102
|
+
var import_react3 = require("react");
|
|
103
|
+
function useStyles(styles) {
|
|
104
|
+
return (0, import_react3.useMemo)(
|
|
105
|
+
() => Object.freeze(
|
|
106
|
+
Object.fromEntries(
|
|
107
|
+
Object.entries(styles).map(([baseClassName, resultClassName]) => [
|
|
108
|
+
baseClassName,
|
|
109
|
+
`${baseClassName} ${resultClassName}`
|
|
110
|
+
])
|
|
111
|
+
)
|
|
112
|
+
),
|
|
113
|
+
[styles]
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
var useStyles_default = useStyles;
|
|
117
|
+
|
|
118
|
+
// src/components/telephoneKeypad/private/Button.tsx
|
|
119
|
+
var Button = (0, import_react4.memo)(
|
|
120
|
+
// As we are all TypeScript, internal components do not need propTypes.
|
|
121
|
+
// eslint-disable-next-line react/prop-types
|
|
122
|
+
(0, import_react4.forwardRef)(({ button, "data-testid": dataTestId, onClick, ruby }, ref) => {
|
|
123
|
+
const classNames = useStyles_default(Button_default);
|
|
124
|
+
const onClickRef = (0, import_use_ref_from.useRefFrom)(onClick);
|
|
125
|
+
const handleClick = (0, import_react4.useCallback)(() => onClickRef.current?.(), [onClickRef]);
|
|
126
|
+
return /* @__PURE__ */ import_react4.default.createElement(
|
|
127
|
+
"button",
|
|
128
|
+
{
|
|
129
|
+
className: classNames["telephone-keypad__button"],
|
|
130
|
+
"data-testid": dataTestId,
|
|
131
|
+
onClick: handleClick,
|
|
132
|
+
ref,
|
|
133
|
+
type: "button"
|
|
134
|
+
},
|
|
135
|
+
/* @__PURE__ */ import_react4.default.createElement("span", { className: classNames["telephone-keypad__button__text"] }, button === "star" ? "\u2217" : button === "pound" ? "#" : button),
|
|
136
|
+
!!ruby && /* @__PURE__ */ import_react4.default.createElement("ruby", { className: classNames["telephone-keypad__button__ruby"] }, ruby)
|
|
137
|
+
);
|
|
138
|
+
})
|
|
139
|
+
);
|
|
140
|
+
Button.displayName = "TelephoneKeypad.Button";
|
|
141
|
+
var Button_default2 = Button;
|
|
142
|
+
|
|
143
|
+
// src/testIds.ts
|
|
144
|
+
var testIds = {
|
|
145
|
+
sendBoxDropZone: "send box drop zone",
|
|
146
|
+
sendBoxSendButton: "send box send button",
|
|
147
|
+
sendBoxTextBox: "send box text area",
|
|
148
|
+
sendBoxTelephoneKeypadButton1: `send box telephone keypad button 1`,
|
|
149
|
+
sendBoxTelephoneKeypadButton2: `send box telephone keypad button 2`,
|
|
150
|
+
sendBoxTelephoneKeypadButton3: `send box telephone keypad button 3`,
|
|
151
|
+
sendBoxTelephoneKeypadButton4: `send box telephone keypad button 4`,
|
|
152
|
+
sendBoxTelephoneKeypadButton5: `send box telephone keypad button 5`,
|
|
153
|
+
sendBoxTelephoneKeypadButton6: `send box telephone keypad button 6`,
|
|
154
|
+
sendBoxTelephoneKeypadButton7: `send box telephone keypad button 7`,
|
|
155
|
+
sendBoxTelephoneKeypadButton8: `send box telephone keypad button 8`,
|
|
156
|
+
sendBoxTelephoneKeypadButton9: `send box telephone keypad button 9`,
|
|
157
|
+
sendBoxTelephoneKeypadButton0: `send box telephone keypad button 0`,
|
|
158
|
+
sendBoxTelephoneKeypadButtonStar: `send box telephone keypad button star`,
|
|
159
|
+
sendBoxTelephoneKeypadButtonPound: `send box telephone keypad button pound`,
|
|
160
|
+
sendBoxTelephoneKeypadToolbarButton: "send box telephone keypad toolbar button",
|
|
161
|
+
sendBoxUploadButton: "send box upload button"
|
|
162
|
+
};
|
|
163
|
+
var testIds_default = testIds;
|
|
164
|
+
|
|
165
|
+
// src/components/telephoneKeypad/useShown.ts
|
|
166
|
+
var import_react5 = require("react");
|
|
167
|
+
function useShown() {
|
|
168
|
+
const { setShown, shown } = (0, import_react5.useContext)(Context_default);
|
|
169
|
+
return (0, import_react5.useMemo)(() => Object.freeze([shown, setShown]), [shown, setShown]);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// src/components/telephoneKeypad/private/TelephoneKeypad.module.css
|
|
173
|
+
var TelephoneKeypad_default = {
|
|
174
|
+
"telephone-keypad": "TelephoneKeypad_telephone-keypad",
|
|
175
|
+
"telephone-keypad__box": "TelephoneKeypad_telephone-keypad__box"
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
// src/components/telephoneKeypad/private/TelephoneKeypad.tsx
|
|
179
|
+
var Orientation = (0, import_react6.memo)(
|
|
180
|
+
({ children, isHorizontal }) => {
|
|
181
|
+
const classNames = useStyles_default(TelephoneKeypad_default);
|
|
182
|
+
return isHorizontal ? (
|
|
183
|
+
// <HorizontalDialPadController>{children}</HorizontalDialPadController>
|
|
184
|
+
false
|
|
185
|
+
) : /* @__PURE__ */ import_react6.default.createElement("div", { className: classNames["telephone-keypad__box"] }, children);
|
|
186
|
+
}
|
|
187
|
+
);
|
|
188
|
+
Orientation.displayName = "TelephoneKeypad:Orientation";
|
|
189
|
+
var TelephoneKeypad = (0, import_react6.memo)(({ autoFocus, onButtonClick, isHorizontal }) => {
|
|
190
|
+
const autoFocusRef = (0, import_use_ref_from2.useRefFrom)(autoFocus);
|
|
191
|
+
const classNames = useStyles_default(TelephoneKeypad_default);
|
|
192
|
+
const firstButtonRef = (0, import_react6.useRef)(null);
|
|
193
|
+
const onButtonClickRef = (0, import_use_ref_from2.useRefFrom)(onButtonClick);
|
|
194
|
+
const [, setShown] = useShown();
|
|
195
|
+
const handleButton1Click = (0, import_react6.useCallback)(() => onButtonClickRef.current?.("1"), [onButtonClickRef]);
|
|
196
|
+
const handleButton2Click = (0, import_react6.useCallback)(() => onButtonClickRef.current?.("2"), [onButtonClickRef]);
|
|
197
|
+
const handleButton3Click = (0, import_react6.useCallback)(() => onButtonClickRef.current?.("3"), [onButtonClickRef]);
|
|
198
|
+
const handleButton4Click = (0, import_react6.useCallback)(() => onButtonClickRef.current?.("4"), [onButtonClickRef]);
|
|
199
|
+
const handleButton5Click = (0, import_react6.useCallback)(() => onButtonClickRef.current?.("5"), [onButtonClickRef]);
|
|
200
|
+
const handleButton6Click = (0, import_react6.useCallback)(() => onButtonClickRef.current?.("6"), [onButtonClickRef]);
|
|
201
|
+
const handleButton7Click = (0, import_react6.useCallback)(() => onButtonClickRef.current?.("7"), [onButtonClickRef]);
|
|
202
|
+
const handleButton8Click = (0, import_react6.useCallback)(() => onButtonClickRef.current?.("8"), [onButtonClickRef]);
|
|
203
|
+
const handleButton9Click = (0, import_react6.useCallback)(() => onButtonClickRef.current?.("9"), [onButtonClickRef]);
|
|
204
|
+
const handleButton0Click = (0, import_react6.useCallback)(() => onButtonClickRef.current?.("0"), [onButtonClickRef]);
|
|
205
|
+
const handleButtonStarClick = (0, import_react6.useCallback)(() => onButtonClickRef.current?.("star"), [onButtonClickRef]);
|
|
206
|
+
const handleButtonPoundClick = (0, import_react6.useCallback)(() => onButtonClickRef.current?.("pound"), [onButtonClickRef]);
|
|
207
|
+
const handleKeyDown = (0, import_react6.useCallback)(
|
|
208
|
+
(event) => {
|
|
209
|
+
if (event.key === "Escape") {
|
|
210
|
+
setShown(false);
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
[setShown]
|
|
214
|
+
);
|
|
215
|
+
(0, import_react6.useEffect)(() => {
|
|
216
|
+
autoFocusRef.current && firstButtonRef.current?.focus();
|
|
217
|
+
}, [autoFocusRef, firstButtonRef]);
|
|
218
|
+
return /* @__PURE__ */ import_react6.default.createElement("div", { className: classNames["telephone-keypad"], onKeyDown: handleKeyDown }, /* @__PURE__ */ import_react6.default.createElement(Orientation, { isHorizontal }, /* @__PURE__ */ import_react6.default.createElement(
|
|
219
|
+
Button_default2,
|
|
220
|
+
{
|
|
221
|
+
button: "1",
|
|
222
|
+
"data-testid": testIds_default.sendBoxTelephoneKeypadButton1,
|
|
223
|
+
onClick: handleButton1Click,
|
|
224
|
+
ref: firstButtonRef
|
|
225
|
+
}
|
|
226
|
+
), /* @__PURE__ */ import_react6.default.createElement(
|
|
227
|
+
Button_default2,
|
|
228
|
+
{
|
|
229
|
+
button: "2",
|
|
230
|
+
"data-testid": testIds_default.sendBoxTelephoneKeypadButton2,
|
|
231
|
+
onClick: handleButton2Click,
|
|
232
|
+
ruby: "ABC"
|
|
233
|
+
}
|
|
234
|
+
), /* @__PURE__ */ import_react6.default.createElement(
|
|
235
|
+
Button_default2,
|
|
236
|
+
{
|
|
237
|
+
button: "3",
|
|
238
|
+
"data-testid": testIds_default.sendBoxTelephoneKeypadButton3,
|
|
239
|
+
onClick: handleButton3Click,
|
|
240
|
+
ruby: "DEF"
|
|
241
|
+
}
|
|
242
|
+
), /* @__PURE__ */ import_react6.default.createElement(
|
|
243
|
+
Button_default2,
|
|
244
|
+
{
|
|
245
|
+
button: "4",
|
|
246
|
+
"data-testid": testIds_default.sendBoxTelephoneKeypadButton4,
|
|
247
|
+
onClick: handleButton4Click,
|
|
248
|
+
ruby: "GHI"
|
|
249
|
+
}
|
|
250
|
+
), /* @__PURE__ */ import_react6.default.createElement(
|
|
251
|
+
Button_default2,
|
|
252
|
+
{
|
|
253
|
+
button: "5",
|
|
254
|
+
"data-testid": testIds_default.sendBoxTelephoneKeypadButton5,
|
|
255
|
+
onClick: handleButton5Click,
|
|
256
|
+
ruby: "JKL"
|
|
257
|
+
}
|
|
258
|
+
), /* @__PURE__ */ import_react6.default.createElement(
|
|
259
|
+
Button_default2,
|
|
260
|
+
{
|
|
261
|
+
button: "6",
|
|
262
|
+
"data-testid": testIds_default.sendBoxTelephoneKeypadButton6,
|
|
263
|
+
onClick: handleButton6Click,
|
|
264
|
+
ruby: "MNO"
|
|
265
|
+
}
|
|
266
|
+
), /* @__PURE__ */ import_react6.default.createElement(
|
|
267
|
+
Button_default2,
|
|
268
|
+
{
|
|
269
|
+
button: "7",
|
|
270
|
+
"data-testid": testIds_default.sendBoxTelephoneKeypadButton7,
|
|
271
|
+
onClick: handleButton7Click,
|
|
272
|
+
ruby: "PQRS"
|
|
273
|
+
}
|
|
274
|
+
), /* @__PURE__ */ import_react6.default.createElement(
|
|
275
|
+
Button_default2,
|
|
276
|
+
{
|
|
277
|
+
button: "8",
|
|
278
|
+
"data-testid": testIds_default.sendBoxTelephoneKeypadButton8,
|
|
279
|
+
onClick: handleButton8Click,
|
|
280
|
+
ruby: "TUV"
|
|
281
|
+
}
|
|
282
|
+
), /* @__PURE__ */ import_react6.default.createElement(
|
|
283
|
+
Button_default2,
|
|
284
|
+
{
|
|
285
|
+
button: "9",
|
|
286
|
+
"data-testid": testIds_default.sendBoxTelephoneKeypadButton9,
|
|
287
|
+
onClick: handleButton9Click,
|
|
288
|
+
ruby: "WXYZ"
|
|
289
|
+
}
|
|
290
|
+
), /* @__PURE__ */ import_react6.default.createElement(Button_default2, { button: "star", "data-testid": testIds_default.sendBoxTelephoneKeypadButtonStar, onClick: handleButtonStarClick }), /* @__PURE__ */ import_react6.default.createElement(Button_default2, { button: "0", "data-testid": testIds_default.sendBoxTelephoneKeypadButton0, onClick: handleButton0Click, ruby: "+" }), /* @__PURE__ */ import_react6.default.createElement(
|
|
291
|
+
Button_default2,
|
|
292
|
+
{
|
|
293
|
+
button: "pound",
|
|
294
|
+
"data-testid": testIds_default.sendBoxTelephoneKeypadButtonPound,
|
|
295
|
+
onClick: handleButtonPoundClick
|
|
296
|
+
}
|
|
297
|
+
)));
|
|
298
|
+
});
|
|
299
|
+
TelephoneKeypad.displayName = "TelephoneKeypad";
|
|
300
|
+
var TelephoneKeypad_default2 = TelephoneKeypad;
|
|
301
|
+
|
|
302
|
+
// src/components/telephoneKeypad/Surrogate.tsx
|
|
303
|
+
var TelephoneKeypadSurrogate = (0, import_react7.memo)((props) => useShown()[0] ? /* @__PURE__ */ import_react7.default.createElement(TelephoneKeypad_default2, { ...props }) : false);
|
|
304
|
+
TelephoneKeypadSurrogate.displayName = "TelephoneKeypad.Surrogate";
|
|
305
|
+
var Surrogate_default = TelephoneKeypadSurrogate;
|
|
306
|
+
|
|
307
|
+
// src/components/Theme.tsx
|
|
308
|
+
var import_react8 = __toESM(require("react"));
|
|
309
|
+
var import_classnames = __toESM(require("classnames"));
|
|
310
|
+
|
|
311
|
+
// src/components/Theme.module.css
|
|
312
|
+
var Theme_default = {
|
|
313
|
+
theme: "Theme_theme"
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
// src/components/Theme.tsx
|
|
317
|
+
var rootClassName = "webchat-fluent";
|
|
318
|
+
function WebchatTheme(props) {
|
|
319
|
+
const classNames = useStyles_default(Theme_default);
|
|
320
|
+
return /* @__PURE__ */ import_react8.default.createElement("div", { className: (0, import_classnames.default)(rootClassName, classNames["theme"]) }, props.children);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
// src/components/sendbox/index.tsx
|
|
324
|
+
var import_botframework_webchat_component8 = require("botframework-webchat-component");
|
|
325
|
+
var import_classnames7 = __toESM(require("classnames"));
|
|
326
|
+
var import_react25 = __toESM(require("react"));
|
|
327
|
+
var import_use_ref_from6 = require("use-ref-from");
|
|
328
|
+
|
|
329
|
+
// src/icons/SendIcon.tsx
|
|
330
|
+
var import_react9 = __toESM(require("react"));
|
|
331
|
+
function SendIcon(props) {
|
|
332
|
+
return /* @__PURE__ */ import_react9.default.createElement(
|
|
333
|
+
"svg",
|
|
334
|
+
{
|
|
335
|
+
"aria-hidden": "true",
|
|
336
|
+
className: props.className,
|
|
337
|
+
fill: "currentColor",
|
|
338
|
+
height: "1em",
|
|
339
|
+
viewBox: "0 0 20 20",
|
|
340
|
+
width: "1em",
|
|
341
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
342
|
+
},
|
|
343
|
+
/* @__PURE__ */ import_react9.default.createElement(
|
|
344
|
+
"path",
|
|
345
|
+
{
|
|
346
|
+
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",
|
|
347
|
+
fill: "currentColor"
|
|
348
|
+
}
|
|
349
|
+
)
|
|
350
|
+
);
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
// src/components/dropZone/index.tsx
|
|
354
|
+
var import_botframework_webchat_component = require("botframework-webchat-component");
|
|
355
|
+
var import_classnames2 = __toESM(require("classnames"));
|
|
356
|
+
var import_react11 = __toESM(require("react"));
|
|
357
|
+
var import_use_ref_from3 = require("use-ref-from");
|
|
358
|
+
|
|
359
|
+
// src/icons/AddDocumentIcon.tsx
|
|
360
|
+
var import_react10 = __toESM(require("react"));
|
|
361
|
+
function AddDocumentIcon(props) {
|
|
362
|
+
return /* @__PURE__ */ import_react10.default.createElement(
|
|
363
|
+
"svg",
|
|
364
|
+
{
|
|
365
|
+
"aria-hidden": "true",
|
|
366
|
+
className: props.className,
|
|
367
|
+
fill: "currentColor",
|
|
368
|
+
height: "1em",
|
|
369
|
+
viewBox: "0 0 20 20",
|
|
370
|
+
width: "1em",
|
|
371
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
372
|
+
},
|
|
373
|
+
/* @__PURE__ */ import_react10.default.createElement(
|
|
374
|
+
"path",
|
|
375
|
+
{
|
|
376
|
+
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",
|
|
377
|
+
fill: "currentColor"
|
|
378
|
+
}
|
|
379
|
+
)
|
|
380
|
+
);
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
// src/components/dropZone/index.module.css
|
|
384
|
+
var dropZone_default = {
|
|
385
|
+
"sendbox__attachment-drop-zone": "dropZone_sendbox__attachment-drop-zone",
|
|
386
|
+
"sendbox__attachment-drop-zone--droppable": "dropZone_sendbox__attachment-drop-zone--droppable",
|
|
387
|
+
"sendbox__attachment-drop-zone-icon": "dropZone_sendbox__attachment-drop-zone-icon"
|
|
388
|
+
};
|
|
389
|
+
|
|
390
|
+
// src/components/dropZone/index.tsx
|
|
391
|
+
var { useLocalizer } = import_botframework_webchat_component.hooks;
|
|
392
|
+
var handleDragOver = (event) => {
|
|
393
|
+
event.preventDefault();
|
|
394
|
+
};
|
|
395
|
+
var isFilesTransferEvent = (event) => !!event.dataTransfer?.types?.some((type) => type.toLowerCase() === "files");
|
|
396
|
+
function isDescendantOf(target, ancestor) {
|
|
397
|
+
let current = target.parentNode;
|
|
398
|
+
while (current) {
|
|
399
|
+
if (current === ancestor) {
|
|
400
|
+
return true;
|
|
401
|
+
}
|
|
402
|
+
current = current.parentNode;
|
|
403
|
+
}
|
|
404
|
+
return false;
|
|
405
|
+
}
|
|
406
|
+
var DropZone = (props) => {
|
|
407
|
+
const [dropZoneState, setDropZoneState] = (0, import_react11.useState)(false);
|
|
408
|
+
const classNames = useStyles_default(dropZone_default);
|
|
409
|
+
const dropZoneRef = (0, import_react11.useRef)(null);
|
|
410
|
+
const localize = useLocalizer();
|
|
411
|
+
const onFilesAddedRef = (0, import_use_ref_from3.useRefFrom)(props.onFilesAdded);
|
|
412
|
+
(0, import_react11.useEffect)(() => {
|
|
413
|
+
let entranceCounter = 0;
|
|
414
|
+
const handleDragEnter = (event) => {
|
|
415
|
+
entranceCounter++;
|
|
416
|
+
if (isFilesTransferEvent(event)) {
|
|
417
|
+
setDropZoneState(
|
|
418
|
+
dropZoneRef.current && (event.target === dropZoneRef.current || event.target instanceof HTMLElement && isDescendantOf(event.target, dropZoneRef.current)) ? "droppable" : "visible"
|
|
419
|
+
);
|
|
420
|
+
}
|
|
421
|
+
};
|
|
422
|
+
const handleDragLeave = () => --entranceCounter <= 0 && setDropZoneState(false);
|
|
423
|
+
document.addEventListener("dragenter", handleDragEnter, false);
|
|
424
|
+
document.addEventListener("dragleave", handleDragLeave, false);
|
|
425
|
+
return () => {
|
|
426
|
+
document.removeEventListener("dragenter", handleDragEnter);
|
|
427
|
+
document.removeEventListener("dragleave", handleDragLeave);
|
|
428
|
+
};
|
|
429
|
+
}, [setDropZoneState]);
|
|
430
|
+
const handleDrop = (0, import_react11.useCallback)(
|
|
431
|
+
(event) => {
|
|
432
|
+
event.preventDefault();
|
|
433
|
+
setDropZoneState(false);
|
|
434
|
+
if (!isFilesTransferEvent(event.nativeEvent)) {
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
437
|
+
onFilesAddedRef.current([...event.dataTransfer.files]);
|
|
438
|
+
},
|
|
439
|
+
[onFilesAddedRef, setDropZoneState]
|
|
440
|
+
);
|
|
441
|
+
return dropZoneState ? /* @__PURE__ */ import_react11.default.createElement(
|
|
442
|
+
"div",
|
|
443
|
+
{
|
|
444
|
+
className: (0, import_classnames2.default)(classNames["sendbox__attachment-drop-zone"], {
|
|
445
|
+
[classNames["sendbox__attachment-drop-zone--droppable"]]: dropZoneState === "droppable"
|
|
446
|
+
}),
|
|
447
|
+
"data-testid": testIds_default.sendBoxDropZone,
|
|
448
|
+
onDragOver: handleDragOver,
|
|
449
|
+
onDrop: handleDrop,
|
|
450
|
+
ref: dropZoneRef
|
|
451
|
+
},
|
|
452
|
+
/* @__PURE__ */ import_react11.default.createElement(AddDocumentIcon, { className: classNames["sendbox__attachment-drop-zone-icon"] }),
|
|
453
|
+
localize("TEXT_INPUT_DROP_ZONE")
|
|
454
|
+
) : null;
|
|
455
|
+
};
|
|
456
|
+
DropZone.displayName = "DropZone";
|
|
457
|
+
var dropZone_default2 = (0, import_react11.memo)(DropZone);
|
|
458
|
+
|
|
459
|
+
// src/components/DropZone.tsx
|
|
460
|
+
var DropZone_default = dropZone_default2;
|
|
461
|
+
|
|
462
|
+
// src/components/suggestedActions/index.tsx
|
|
463
|
+
var import_botframework_webchat_component3 = require("botframework-webchat-component");
|
|
464
|
+
var import_classnames4 = __toESM(require("classnames"));
|
|
465
|
+
var import_react14 = __toESM(require("react"));
|
|
466
|
+
|
|
467
|
+
// src/components/suggestedActions/SuggestedAction.tsx
|
|
468
|
+
var import_botframework_webchat_component2 = require("botframework-webchat-component");
|
|
469
|
+
var import_classnames3 = __toESM(require("classnames"));
|
|
470
|
+
var import_react13 = __toESM(require("react"));
|
|
471
|
+
|
|
472
|
+
// src/components/suggestedActions/SuggestedAction.module.css
|
|
473
|
+
var SuggestedAction_default = {
|
|
474
|
+
"suggested-action": "SuggestedAction_suggested-action",
|
|
475
|
+
"suggested-action__image": "SuggestedAction_suggested-action__image"
|
|
476
|
+
};
|
|
477
|
+
|
|
478
|
+
// src/components/suggestedActions/AccessibleButton.tsx
|
|
479
|
+
var import_react12 = __toESM(require("react"));
|
|
480
|
+
var preventDefaultHandler = (event) => event.preventDefault();
|
|
481
|
+
var AccessibleButton = (0, import_react12.forwardRef)(
|
|
482
|
+
({ "aria-hidden": ariaHidden, children, disabled, onClick, tabIndex, ...props }, forwardedRef) => {
|
|
483
|
+
const targetRef = (0, import_react12.useRef)(null);
|
|
484
|
+
const ref = forwardedRef || targetRef;
|
|
485
|
+
return /* @__PURE__ */ import_react12.default.createElement(
|
|
486
|
+
"button",
|
|
487
|
+
{
|
|
488
|
+
"aria-disabled": disabled ? "true" : "false",
|
|
489
|
+
"aria-hidden": ariaHidden,
|
|
490
|
+
onClick: disabled ? preventDefaultHandler : onClick,
|
|
491
|
+
ref,
|
|
492
|
+
tabIndex,
|
|
493
|
+
...disabled && {
|
|
494
|
+
"aria-disabled": "true",
|
|
495
|
+
tabIndex: -1
|
|
496
|
+
},
|
|
497
|
+
...props,
|
|
498
|
+
type: "button"
|
|
499
|
+
},
|
|
500
|
+
children
|
|
501
|
+
);
|
|
502
|
+
}
|
|
503
|
+
);
|
|
504
|
+
var AccessibleButton_default = (0, import_react12.memo)(AccessibleButton);
|
|
505
|
+
|
|
506
|
+
// src/components/suggestedActions/SuggestedAction.tsx
|
|
507
|
+
var { useDisabled, useFocus, usePerformCardAction, useScrollToEnd, useStyleSet, useSuggestedActions } = import_botframework_webchat_component2.hooks;
|
|
508
|
+
function SuggestedAction({
|
|
509
|
+
buttonText,
|
|
510
|
+
className,
|
|
511
|
+
displayText,
|
|
512
|
+
image,
|
|
513
|
+
imageAlt,
|
|
514
|
+
text,
|
|
515
|
+
type,
|
|
516
|
+
value
|
|
517
|
+
}) {
|
|
518
|
+
const [_, setSuggestedActions] = useSuggestedActions();
|
|
519
|
+
const [{ suggestedAction: suggestedActionStyleSet }] = useStyleSet();
|
|
520
|
+
const [disabled] = useDisabled();
|
|
521
|
+
const focus = useFocus();
|
|
522
|
+
const focusRef = (0, import_react13.useRef)(null);
|
|
523
|
+
const performCardAction = usePerformCardAction();
|
|
524
|
+
const classNames = useStyles_default(SuggestedAction_default);
|
|
525
|
+
const scrollToEnd = useScrollToEnd();
|
|
526
|
+
const handleClick = (0, import_react13.useCallback)(
|
|
527
|
+
({ target }) => {
|
|
528
|
+
(async function() {
|
|
529
|
+
await focus("sendBoxWithoutKeyboard");
|
|
530
|
+
performCardAction({ displayText, text, type, value }, { target });
|
|
531
|
+
type === "openUrl" && setSuggestedActions([]);
|
|
532
|
+
scrollToEnd();
|
|
533
|
+
})();
|
|
534
|
+
},
|
|
535
|
+
[displayText, focus, performCardAction, scrollToEnd, setSuggestedActions, text, type, value]
|
|
536
|
+
);
|
|
537
|
+
return /* @__PURE__ */ import_react13.default.createElement(
|
|
538
|
+
AccessibleButton_default,
|
|
539
|
+
{
|
|
540
|
+
className: (0, import_classnames3.default)(classNames["suggested-action"], suggestedActionStyleSet + "", (className || "") + ""),
|
|
541
|
+
disabled,
|
|
542
|
+
onClick: handleClick,
|
|
543
|
+
ref: focusRef,
|
|
544
|
+
type: "button"
|
|
545
|
+
},
|
|
546
|
+
image && /* @__PURE__ */ import_react13.default.createElement("img", { alt: imageAlt, className: classNames["suggested-action__image"], src: image }),
|
|
547
|
+
/* @__PURE__ */ import_react13.default.createElement("span", null, buttonText)
|
|
548
|
+
);
|
|
549
|
+
}
|
|
550
|
+
var SuggestedAction_default2 = (0, import_react13.memo)(SuggestedAction);
|
|
551
|
+
|
|
552
|
+
// src/components/suggestedActions/private/computeSuggestedActionText.ts
|
|
553
|
+
function computeSuggestedActionText(cardAction) {
|
|
554
|
+
const { title } = cardAction;
|
|
555
|
+
const { type, value } = cardAction;
|
|
556
|
+
if (type === "messageBack") {
|
|
557
|
+
return title || cardAction.displayText;
|
|
558
|
+
} else if (title) {
|
|
559
|
+
return title;
|
|
560
|
+
} else if (typeof value === "string") {
|
|
561
|
+
return value;
|
|
45
562
|
}
|
|
46
|
-
|
|
47
|
-
|
|
563
|
+
return JSON.stringify(value);
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
// src/components/suggestedActions/index.module.css
|
|
567
|
+
var suggestedActions_default = {
|
|
568
|
+
"suggested-actions": "suggestedActions_suggested-actions",
|
|
569
|
+
"suggested-actions--flow": "suggestedActions_suggested-actions--flow",
|
|
570
|
+
"suggested-actions--stacked": "suggestedActions_suggested-actions--stacked"
|
|
571
|
+
};
|
|
572
|
+
|
|
573
|
+
// src/components/suggestedActions/index.tsx
|
|
574
|
+
var { useLocalizer: useLocalizer2, useStyleOptions, useStyleSet: useStyleSet2, useSuggestedActions: useSuggestedActions2 } = import_botframework_webchat_component3.hooks;
|
|
575
|
+
function SuggestedActionStackedOrFlowContainer(props) {
|
|
576
|
+
const [{ suggestedActionLayout }] = useStyleOptions();
|
|
577
|
+
const [{ suggestedActions: suggestedActionsStyleSet }] = useStyleSet2();
|
|
578
|
+
const classNames = useStyles_default(suggestedActions_default);
|
|
579
|
+
return /* @__PURE__ */ import_react14.default.createElement(
|
|
580
|
+
"div",
|
|
581
|
+
{
|
|
582
|
+
"aria-label": props["aria-label"],
|
|
583
|
+
"aria-live": "polite",
|
|
584
|
+
"aria-orientation": "vertical",
|
|
585
|
+
className: (0, import_classnames4.default)(
|
|
586
|
+
classNames["suggested-actions"],
|
|
587
|
+
suggestedActionsStyleSet + "",
|
|
588
|
+
{
|
|
589
|
+
[classNames["suggested-actions--flow"]]: suggestedActionLayout === "flow",
|
|
590
|
+
[classNames["suggested-actions--stacked"]]: suggestedActionLayout !== "flow"
|
|
591
|
+
},
|
|
592
|
+
props.className
|
|
593
|
+
),
|
|
594
|
+
role: "toolbar"
|
|
595
|
+
},
|
|
596
|
+
!!props.children && !!import_react14.default.Children.count(props.children) && props.children
|
|
597
|
+
);
|
|
598
|
+
}
|
|
599
|
+
function SuggestedActions() {
|
|
600
|
+
const classNames = useStyles_default(suggestedActions_default);
|
|
601
|
+
const localize = useLocalizer2();
|
|
602
|
+
const [suggestedActions] = useSuggestedActions2();
|
|
603
|
+
const children = suggestedActions.map((cardAction, index) => {
|
|
604
|
+
const { displayText, image, imageAltText, text, type, value } = cardAction;
|
|
605
|
+
if (!suggestedActions?.length) {
|
|
606
|
+
return null;
|
|
607
|
+
}
|
|
608
|
+
return /* @__PURE__ */ import_react14.default.createElement(
|
|
609
|
+
SuggestedAction_default2,
|
|
610
|
+
{
|
|
611
|
+
buttonText: computeSuggestedActionText(cardAction),
|
|
612
|
+
displayText,
|
|
613
|
+
image,
|
|
614
|
+
imageAlt: image && (imageAltText || text),
|
|
615
|
+
itemIndex: index,
|
|
616
|
+
key: index,
|
|
617
|
+
text,
|
|
618
|
+
type,
|
|
619
|
+
value
|
|
620
|
+
}
|
|
621
|
+
);
|
|
622
|
+
});
|
|
623
|
+
return /* @__PURE__ */ import_react14.default.createElement(
|
|
624
|
+
SuggestedActionStackedOrFlowContainer,
|
|
625
|
+
{
|
|
626
|
+
"aria-label": localize("SUGGESTED_ACTIONS_LABEL_ALT"),
|
|
627
|
+
className: classNames["suggested-actions"]
|
|
628
|
+
},
|
|
629
|
+
children
|
|
630
|
+
);
|
|
631
|
+
}
|
|
632
|
+
var suggestedActions_default2 = (0, import_react14.memo)(SuggestedActions);
|
|
633
|
+
|
|
634
|
+
// src/components/SuggestedActions.tsx
|
|
635
|
+
var SuggestedActions_default = suggestedActions_default2;
|
|
636
|
+
|
|
637
|
+
// src/components/sendbox/AddAttachmentButton.tsx
|
|
638
|
+
var import_botframework_webchat_component4 = require("botframework-webchat-component");
|
|
639
|
+
var import_react17 = __toESM(require("react"));
|
|
640
|
+
var import_use_ref_from4 = require("use-ref-from");
|
|
641
|
+
|
|
642
|
+
// src/icons/AttachmentIcon.tsx
|
|
643
|
+
var import_react15 = __toESM(require("react"));
|
|
644
|
+
function AttachmentIcon(props) {
|
|
645
|
+
return /* @__PURE__ */ import_react15.default.createElement(
|
|
646
|
+
"svg",
|
|
647
|
+
{
|
|
648
|
+
"aria-hidden": "true",
|
|
649
|
+
className: props.className,
|
|
650
|
+
fill: "currentColor",
|
|
651
|
+
height: "1em",
|
|
652
|
+
viewBox: "0 0 20 20",
|
|
653
|
+
width: "1em",
|
|
654
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
655
|
+
},
|
|
656
|
+
/* @__PURE__ */ import_react15.default.createElement(
|
|
657
|
+
"path",
|
|
658
|
+
{
|
|
659
|
+
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",
|
|
660
|
+
fill: "currentColor"
|
|
661
|
+
}
|
|
662
|
+
)
|
|
663
|
+
);
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
// src/components/sendbox/Toolbar.tsx
|
|
667
|
+
var import_classnames5 = __toESM(require("classnames"));
|
|
668
|
+
var import_react16 = __toESM(require("react"));
|
|
669
|
+
|
|
670
|
+
// src/components/sendbox/Toolbar.module.css
|
|
671
|
+
var Toolbar_default = {
|
|
672
|
+
sendbox__toolbar: "Toolbar_sendbox__toolbar",
|
|
673
|
+
"sendbox__toolbar-button": "Toolbar_sendbox__toolbar-button",
|
|
674
|
+
"sendbox__toolbar-separator": "Toolbar_sendbox__toolbar-separator"
|
|
675
|
+
};
|
|
676
|
+
|
|
677
|
+
// src/components/sendbox/Toolbar.tsx
|
|
678
|
+
var preventDefaultHandler2 = (event) => event.preventDefault();
|
|
679
|
+
var ToolbarButton = (0, import_react16.memo)(
|
|
680
|
+
(props) => {
|
|
681
|
+
const classNames = useStyles_default(Toolbar_default);
|
|
682
|
+
return /* @__PURE__ */ import_react16.default.createElement(
|
|
683
|
+
"button",
|
|
684
|
+
{
|
|
685
|
+
"aria-label": props["aria-label"],
|
|
686
|
+
className: (0, import_classnames5.default)(classNames["sendbox__toolbar-button"], props.className),
|
|
687
|
+
"data-testid": props["data-testid"],
|
|
688
|
+
onClick: props.disabled ? preventDefaultHandler2 : props.onClick,
|
|
689
|
+
type: props.type === "submit" ? "submit" : "button",
|
|
690
|
+
...props.disabled && {
|
|
691
|
+
"aria-disabled": "true",
|
|
692
|
+
tabIndex: -1
|
|
693
|
+
}
|
|
694
|
+
},
|
|
695
|
+
props.children
|
|
696
|
+
);
|
|
697
|
+
}
|
|
698
|
+
);
|
|
699
|
+
ToolbarButton.displayName = "ToolbarButton";
|
|
700
|
+
var Toolbar = (0, import_react16.memo)((props) => {
|
|
701
|
+
const classNames = useStyles_default(Toolbar_default);
|
|
702
|
+
return /* @__PURE__ */ import_react16.default.createElement("div", { className: (0, import_classnames5.default)(classNames["sendbox__toolbar"], props.className) }, props.children);
|
|
703
|
+
});
|
|
704
|
+
Toolbar.displayName = "Toolbar";
|
|
705
|
+
var ToolbarSeparator = (0, import_react16.memo)(
|
|
706
|
+
(props) => {
|
|
707
|
+
const classNames = useStyles_default(Toolbar_default);
|
|
708
|
+
return /* @__PURE__ */ import_react16.default.createElement(
|
|
709
|
+
"div",
|
|
710
|
+
{
|
|
711
|
+
"aria-orientation": "vertical",
|
|
712
|
+
className: (0, import_classnames5.default)(classNames["sendbox__toolbar-separator"], props.className),
|
|
713
|
+
role: "separator"
|
|
714
|
+
}
|
|
715
|
+
);
|
|
716
|
+
}
|
|
717
|
+
);
|
|
718
|
+
ToolbarSeparator.displayName = "ToolbarSeparator";
|
|
719
|
+
|
|
720
|
+
// src/components/sendbox/AddAttachmentButton.module.css
|
|
721
|
+
var AddAttachmentButton_default = {
|
|
722
|
+
"sendbox__add-attachment": "AddAttachmentButton_sendbox__add-attachment",
|
|
723
|
+
"sendbox__add-attachment-input": "AddAttachmentButton_sendbox__add-attachment-input"
|
|
724
|
+
};
|
|
725
|
+
|
|
726
|
+
// src/components/sendbox/AddAttachmentButton.tsx
|
|
727
|
+
var { useLocalizer: useLocalizer3, useStyleOptions: useStyleOptions2 } = import_botframework_webchat_component4.hooks;
|
|
728
|
+
function AddAttachmentButton(props) {
|
|
729
|
+
const inputRef = (0, import_react17.useRef)(null);
|
|
730
|
+
const classNames = useStyles_default(AddAttachmentButton_default);
|
|
731
|
+
const localize = useLocalizer3();
|
|
732
|
+
const [{ uploadAccept, uploadMultiple }] = useStyleOptions2();
|
|
733
|
+
const onFilesAddedRef = (0, import_use_ref_from4.useRefFrom)(props.onFilesAdded);
|
|
734
|
+
const handleClick = (0, import_react17.useCallback)(() => inputRef.current?.click(), [inputRef]);
|
|
735
|
+
const handleFileChange = (0, import_react17.useCallback)(
|
|
736
|
+
({ target: { files } }) => {
|
|
737
|
+
if (files) {
|
|
738
|
+
onFilesAddedRef.current?.([...files]);
|
|
739
|
+
if (inputRef.current) {
|
|
740
|
+
inputRef.current.value = "";
|
|
741
|
+
}
|
|
742
|
+
}
|
|
743
|
+
},
|
|
744
|
+
[inputRef, onFilesAddedRef]
|
|
745
|
+
);
|
|
746
|
+
return /* @__PURE__ */ import_react17.default.createElement("div", { className: classNames["sendbox__add-attachment"] }, /* @__PURE__ */ import_react17.default.createElement(
|
|
747
|
+
"input",
|
|
748
|
+
{
|
|
749
|
+
accept: uploadAccept,
|
|
750
|
+
"aria-disabled": props.disabled,
|
|
751
|
+
"aria-hidden": "true",
|
|
752
|
+
className: classNames["sendbox__add-attachment-input"],
|
|
753
|
+
multiple: uploadMultiple,
|
|
754
|
+
onInput: props.disabled ? void 0 : handleFileChange,
|
|
755
|
+
readOnly: props.disabled,
|
|
756
|
+
ref: inputRef,
|
|
757
|
+
role: "button",
|
|
758
|
+
tabIndex: -1,
|
|
759
|
+
type: "file"
|
|
760
|
+
}
|
|
761
|
+
), /* @__PURE__ */ import_react17.default.createElement(
|
|
762
|
+
ToolbarButton,
|
|
763
|
+
{
|
|
764
|
+
"aria-label": localize("TEXT_INPUT_UPLOAD_BUTTON_ALT"),
|
|
765
|
+
"data-testid": testIds_default.sendBoxUploadButton,
|
|
766
|
+
onClick: handleClick
|
|
767
|
+
},
|
|
768
|
+
/* @__PURE__ */ import_react17.default.createElement(AttachmentIcon, null)
|
|
769
|
+
));
|
|
770
|
+
}
|
|
771
|
+
var AddAttachmentButton_default2 = (0, import_react17.memo)(AddAttachmentButton);
|
|
772
|
+
|
|
773
|
+
// src/components/sendbox/Attachments.tsx
|
|
774
|
+
var import_botframework_webchat_component5 = require("botframework-webchat-component");
|
|
775
|
+
var import_react18 = __toESM(require("react"));
|
|
776
|
+
|
|
777
|
+
// src/components/sendbox/Attachments.module.css
|
|
778
|
+
var Attachments_default = {
|
|
779
|
+
sendbox__attachment: "Attachments_sendbox__attachment"
|
|
780
|
+
};
|
|
781
|
+
|
|
782
|
+
// src/components/sendbox/Attachments.tsx
|
|
783
|
+
var { useLocalizer: useLocalizer4 } = import_botframework_webchat_component5.hooks;
|
|
784
|
+
var attachmentsPluralStringIds = {
|
|
785
|
+
one: "TEXT_INPUT_ATTACHMENTS_ONE",
|
|
786
|
+
two: "TEXT_INPUT_ATTACHMENTS_TWO",
|
|
787
|
+
few: "TEXT_INPUT_ATTACHMENTS_FEW",
|
|
788
|
+
many: "TEXT_INPUT_ATTACHMENTS_MANY",
|
|
789
|
+
other: "TEXT_INPUT_ATTACHMENTS_OTHER"
|
|
790
|
+
};
|
|
791
|
+
function Attachments({
|
|
792
|
+
attachments
|
|
793
|
+
}) {
|
|
794
|
+
const classNames = useStyles_default(Attachments_default);
|
|
795
|
+
const localizeWithPlural = useLocalizer4({ plural: true });
|
|
796
|
+
return attachments.length ? /* @__PURE__ */ import_react18.default.createElement("div", { className: classNames["sendbox__attachment"] }, localizeWithPlural(attachmentsPluralStringIds, attachments.length)) : null;
|
|
797
|
+
}
|
|
798
|
+
var Attachments_default2 = (0, import_react18.memo)(Attachments);
|
|
799
|
+
|
|
800
|
+
// src/components/sendbox/ErrorMessage.tsx
|
|
801
|
+
var import_react19 = __toESM(require("react"));
|
|
802
|
+
|
|
803
|
+
// src/components/sendbox/ErrorMessage.module.css
|
|
804
|
+
var ErrorMessage_default = {
|
|
805
|
+
"sendbox__error-message": "ErrorMessage_sendbox__error-message"
|
|
806
|
+
};
|
|
807
|
+
|
|
808
|
+
// src/components/sendbox/ErrorMessage.tsx
|
|
809
|
+
function ErrorMessage(props) {
|
|
810
|
+
const classNames = useStyles_default(ErrorMessage_default);
|
|
811
|
+
return (
|
|
812
|
+
// eslint-disable-next-line react/forbid-dom-props
|
|
813
|
+
/* @__PURE__ */ import_react19.default.createElement("span", { className: classNames["sendbox__error-message"], id: props.id, role: "alert" }, props.error)
|
|
814
|
+
);
|
|
815
|
+
}
|
|
816
|
+
var ErrorMessage_default2 = (0, import_react19.memo)(ErrorMessage);
|
|
817
|
+
|
|
818
|
+
// src/components/sendbox/TelephoneKeypadToolbarButton.tsx
|
|
819
|
+
var import_react21 = __toESM(require("react"));
|
|
820
|
+
var import_botframework_webchat_component6 = require("botframework-webchat-component");
|
|
821
|
+
|
|
822
|
+
// src/icons/TelephoneKeypad.tsx
|
|
823
|
+
var import_react20 = __toESM(require("react"));
|
|
824
|
+
function TelephoneKeypadIcon(props) {
|
|
825
|
+
return /* @__PURE__ */ import_react20.default.createElement(
|
|
826
|
+
"svg",
|
|
827
|
+
{
|
|
828
|
+
"aria-hidden": "true",
|
|
829
|
+
className: props.className,
|
|
830
|
+
fill: "currentColor",
|
|
831
|
+
height: "1em",
|
|
832
|
+
viewBox: "0 0 20 20",
|
|
833
|
+
width: "1em",
|
|
834
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
835
|
+
},
|
|
836
|
+
/* @__PURE__ */ import_react20.default.createElement(
|
|
837
|
+
"path",
|
|
838
|
+
{
|
|
839
|
+
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",
|
|
840
|
+
fill: "currentColor"
|
|
841
|
+
}
|
|
842
|
+
)
|
|
843
|
+
);
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
// src/components/sendbox/TelephoneKeypadToolbarButton.tsx
|
|
847
|
+
var { useLocalizer: useLocalizer5 } = import_botframework_webchat_component6.hooks;
|
|
848
|
+
var TelephoneKeypadToolbarButton = (0, import_react21.memo)(() => {
|
|
849
|
+
const [, setTelephoneKeypadShown] = useShown();
|
|
850
|
+
const localize = useLocalizer5();
|
|
851
|
+
const handleClick = (0, import_react21.useCallback)(() => setTelephoneKeypadShown((shown) => !shown), [setTelephoneKeypadShown]);
|
|
852
|
+
return /* @__PURE__ */ import_react21.default.createElement(
|
|
853
|
+
ToolbarButton,
|
|
854
|
+
{
|
|
855
|
+
"aria-label": localize("TEXT_INPUT_TELEPHONE_KEYPAD_BUTTON_ALT"),
|
|
856
|
+
"data-testid": testIds_default.sendBoxTelephoneKeypadToolbarButton,
|
|
857
|
+
onClick: handleClick
|
|
858
|
+
},
|
|
859
|
+
/* @__PURE__ */ import_react21.default.createElement(TelephoneKeypadIcon, null)
|
|
860
|
+
);
|
|
861
|
+
});
|
|
862
|
+
TelephoneKeypadToolbarButton.displayName = "SendBox.TelephoneKeypadToolbarButton";
|
|
863
|
+
var TelephoneKeypadToolbarButton_default = TelephoneKeypadToolbarButton;
|
|
864
|
+
|
|
865
|
+
// src/components/sendbox/TextArea.tsx
|
|
866
|
+
var import_classnames6 = __toESM(require("classnames"));
|
|
867
|
+
var import_react22 = __toESM(require("react"));
|
|
868
|
+
|
|
869
|
+
// src/components/sendbox/TextArea.module.css
|
|
870
|
+
var TextArea_default = {
|
|
871
|
+
"sendbox__text-area": "TextArea_sendbox__text-area",
|
|
872
|
+
"sendbox__text-area--hidden": "TextArea_sendbox__text-area--hidden",
|
|
873
|
+
"sendbox__text-area-shared": "TextArea_sendbox__text-area-shared",
|
|
874
|
+
"sendbox__text-area-doppelganger": "TextArea_sendbox__text-area-doppelganger",
|
|
875
|
+
"sendbox__text-area-input": "TextArea_sendbox__text-area-input",
|
|
876
|
+
"sendbox__text-area-input--scroll": "TextArea_sendbox__text-area-input--scroll"
|
|
877
|
+
};
|
|
878
|
+
|
|
879
|
+
// src/components/sendbox/TextArea.tsx
|
|
880
|
+
var TextArea = (0, import_react22.forwardRef)((props, ref) => {
|
|
881
|
+
const classNames = useStyles_default(TextArea_default);
|
|
882
|
+
const handleKeyDown = (0, import_react22.useCallback)((event) => {
|
|
883
|
+
if (!event.shiftKey && event.key === "Enter") {
|
|
884
|
+
event.preventDefault();
|
|
885
|
+
if ("form" in event.target && event.target.form instanceof HTMLFormElement) {
|
|
886
|
+
event.target?.form?.requestSubmit();
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
}, []);
|
|
890
|
+
return /* @__PURE__ */ import_react22.default.createElement(
|
|
891
|
+
"div",
|
|
892
|
+
{
|
|
893
|
+
className: (0, import_classnames6.default)(
|
|
894
|
+
classNames["sendbox__text-area"],
|
|
895
|
+
{
|
|
896
|
+
[classNames["sendbox__text-area--hidden"]]: props.hidden
|
|
897
|
+
},
|
|
898
|
+
props.className
|
|
899
|
+
),
|
|
900
|
+
role: props.hidden ? "hidden" : void 0
|
|
901
|
+
},
|
|
902
|
+
/* @__PURE__ */ import_react22.default.createElement(
|
|
903
|
+
"div",
|
|
904
|
+
{
|
|
905
|
+
className: (0, import_classnames6.default)(
|
|
906
|
+
classNames["sendbox__text-area-doppelganger"],
|
|
907
|
+
classNames["sendbox__text-area-shared"],
|
|
908
|
+
classNames["sendbox__text-area-input--scroll"]
|
|
909
|
+
)
|
|
910
|
+
},
|
|
911
|
+
props.value || props.placeholder,
|
|
912
|
+
" "
|
|
913
|
+
),
|
|
914
|
+
/* @__PURE__ */ import_react22.default.createElement(
|
|
915
|
+
"textarea",
|
|
916
|
+
{
|
|
917
|
+
"aria-label": props["aria-label"],
|
|
918
|
+
className: (0, import_classnames6.default)(
|
|
919
|
+
classNames["sendbox__text-area-input"],
|
|
920
|
+
classNames["sendbox__text-area-shared"],
|
|
921
|
+
classNames["sendbox__text-area-input--scroll"]
|
|
922
|
+
),
|
|
923
|
+
"data-testid": props["data-testid"],
|
|
924
|
+
onInput: props.onInput,
|
|
925
|
+
onKeyDown: handleKeyDown,
|
|
926
|
+
placeholder: props.placeholder,
|
|
927
|
+
ref,
|
|
928
|
+
rows: props.startRows ?? 1,
|
|
929
|
+
tabIndex: props.hidden ? -1 : void 0,
|
|
930
|
+
value: props.value
|
|
931
|
+
}
|
|
932
|
+
)
|
|
933
|
+
);
|
|
934
|
+
});
|
|
935
|
+
TextArea.displayName = "TextArea";
|
|
936
|
+
var TextArea_default2 = TextArea;
|
|
937
|
+
|
|
938
|
+
// src/components/sendbox/private/useSubmitError.ts
|
|
939
|
+
var import_botframework_webchat_component7 = require("botframework-webchat-component");
|
|
940
|
+
var import_react23 = require("react");
|
|
941
|
+
var import_use_ref_from5 = require("use-ref-from");
|
|
942
|
+
var { useConnectivityStatus, useLocalizer: useLocalizer6 } = import_botframework_webchat_component7.hooks;
|
|
943
|
+
var useSubmitError = ({
|
|
944
|
+
attachments,
|
|
945
|
+
message
|
|
946
|
+
}) => {
|
|
947
|
+
const [connectivityStatus] = useConnectivityStatus();
|
|
948
|
+
const localize = useLocalizer6();
|
|
949
|
+
const submitErrorRef = (0, import_use_ref_from5.useRefFrom)(
|
|
950
|
+
connectivityStatus !== "connected" && connectivityStatus !== "reconnected" ? "offline" : !message && !attachments.length ? "empty" : void 0
|
|
951
|
+
);
|
|
952
|
+
const errorMessageStringMap = (0, import_react23.useMemo)(
|
|
953
|
+
() => Object.freeze(
|
|
954
|
+
(/* @__PURE__ */ new Map()).set("empty", localize("SEND_BOX_IS_EMPTY_TOOLTIP_ALT")).set("offline", localize("CONNECTIVITY_STATUS_ALT_FATAL"))
|
|
955
|
+
),
|
|
956
|
+
[localize]
|
|
957
|
+
);
|
|
958
|
+
return (0, import_react23.useMemo)(
|
|
959
|
+
() => Object.freeze([submitErrorRef, submitErrorRef.current && errorMessageStringMap.get(submitErrorRef.current)]),
|
|
960
|
+
[errorMessageStringMap, submitErrorRef]
|
|
961
|
+
);
|
|
962
|
+
};
|
|
963
|
+
var useSubmitError_default = useSubmitError;
|
|
964
|
+
|
|
965
|
+
// src/components/sendbox/private/useUniqueId.ts
|
|
966
|
+
var import_react24 = require("react");
|
|
967
|
+
function useUniqueId(prefix) {
|
|
968
|
+
const id = (0, import_react24.useMemo)(() => Math.random().toString(36).substr(2, 5), []);
|
|
969
|
+
prefix = prefix ? `${prefix}--` : "";
|
|
970
|
+
return `${prefix}${id}`;
|
|
971
|
+
}
|
|
972
|
+
|
|
973
|
+
// src/components/sendbox/index.module.css
|
|
974
|
+
var sendbox_default = {
|
|
975
|
+
sendbox: "sendbox_sendbox",
|
|
976
|
+
sendbox__sendbox: "sendbox_sendbox__sendbox",
|
|
977
|
+
"sendbox__sendbox-text": "sendbox_sendbox__sendbox-text",
|
|
978
|
+
"sendbox__sendbox-controls": "sendbox_sendbox__sendbox-controls",
|
|
979
|
+
"sendbox__text-counter": "sendbox_sendbox__text-counter",
|
|
980
|
+
"sendbox__text-counter--error": "sendbox_sendbox__text-counter--error"
|
|
981
|
+
};
|
|
982
|
+
|
|
983
|
+
// src/components/sendbox/index.tsx
|
|
984
|
+
var { useStyleOptions: useStyleOptions3, useMakeThumbnail, useLocalizer: useLocalizer7, useSendBoxAttachments, useSendMessage } = import_botframework_webchat_component8.hooks;
|
|
985
|
+
function SendBox(props) {
|
|
986
|
+
const inputRef = (0, import_react25.useRef)(null);
|
|
987
|
+
const [message, setMessage] = (0, import_react25.useState)("");
|
|
988
|
+
const [attachments, setAttachments] = useSendBoxAttachments();
|
|
989
|
+
const [{ hideTelephoneKeypadButton, hideUploadButton, maxMessageLength }] = useStyleOptions3();
|
|
990
|
+
const isMessageLengthExceeded = !!maxMessageLength && message.length > maxMessageLength;
|
|
991
|
+
const classNames = useStyles_default(sendbox_default);
|
|
992
|
+
const localize = useLocalizer7();
|
|
993
|
+
const sendMessage = useSendMessage();
|
|
994
|
+
const makeThumbnail = useMakeThumbnail();
|
|
995
|
+
const errorMessageId = useUniqueId("sendbox__error-message-id");
|
|
996
|
+
const [errorRef, errorMessage] = useSubmitError_default({ message, attachments });
|
|
997
|
+
const [telephoneKeypadShown] = useShown();
|
|
998
|
+
const attachmentsRef = (0, import_use_ref_from6.useRefFrom)(attachments);
|
|
999
|
+
const messageRef = (0, import_use_ref_from6.useRefFrom)(message);
|
|
1000
|
+
const handleSendBoxClick = (0, import_react25.useCallback)(
|
|
1001
|
+
(event) => {
|
|
1002
|
+
if ("tabIndex" in event.target && typeof event.target.tabIndex === "number" && event.target.tabIndex >= 0) {
|
|
1003
|
+
return;
|
|
1004
|
+
}
|
|
1005
|
+
inputRef.current?.focus();
|
|
1006
|
+
},
|
|
1007
|
+
[inputRef]
|
|
1008
|
+
);
|
|
1009
|
+
const handleMessageChange = (0, import_react25.useCallback)(
|
|
1010
|
+
(event) => setMessage(event.currentTarget.value),
|
|
1011
|
+
[setMessage]
|
|
1012
|
+
);
|
|
1013
|
+
const handleAddFiles = (0, import_react25.useCallback)(
|
|
1014
|
+
async (inputFiles) => {
|
|
1015
|
+
const newAttachments = Object.freeze(
|
|
1016
|
+
await Promise.all(
|
|
1017
|
+
inputFiles.map(
|
|
1018
|
+
(file) => makeThumbnail(file).then(
|
|
1019
|
+
(thumbnailURL) => Object.freeze({
|
|
1020
|
+
blob: file,
|
|
1021
|
+
...thumbnailURL && { thumbnailURL }
|
|
1022
|
+
})
|
|
1023
|
+
)
|
|
1024
|
+
)
|
|
1025
|
+
)
|
|
1026
|
+
);
|
|
1027
|
+
setAttachments(newAttachments);
|
|
1028
|
+
},
|
|
1029
|
+
[makeThumbnail, setAttachments]
|
|
1030
|
+
);
|
|
1031
|
+
const handleFormSubmit = (0, import_react25.useCallback)(
|
|
1032
|
+
(event) => {
|
|
1033
|
+
event.preventDefault();
|
|
1034
|
+
if (errorRef.current !== "empty" && !isMessageLengthExceeded) {
|
|
1035
|
+
sendMessage(messageRef.current, void 0, { attachments: attachmentsRef.current });
|
|
1036
|
+
setMessage("");
|
|
1037
|
+
setAttachments([]);
|
|
1038
|
+
}
|
|
1039
|
+
inputRef.current?.focus();
|
|
1040
|
+
},
|
|
1041
|
+
[attachmentsRef, messageRef, sendMessage, setAttachments, setMessage, isMessageLengthExceeded, errorRef, inputRef]
|
|
1042
|
+
);
|
|
1043
|
+
const handleTelephoneKeypadButtonClick = (0, import_react25.useCallback)(
|
|
1044
|
+
// TODO: We need more official way of sending DTMF.
|
|
1045
|
+
(dtmf) => sendMessage(`/DTMF ${dtmf}`),
|
|
1046
|
+
[sendMessage]
|
|
1047
|
+
);
|
|
1048
|
+
const aria = {
|
|
1049
|
+
"aria-invalid": "false",
|
|
1050
|
+
...errorMessage && {
|
|
1051
|
+
"aria-invalid": "true",
|
|
1052
|
+
"aria-errormessage": errorMessageId
|
|
1053
|
+
}
|
|
1054
|
+
};
|
|
1055
|
+
return /* @__PURE__ */ import_react25.default.createElement("form", { ...aria, className: (0, import_classnames7.default)(classNames["sendbox"], props.className), onSubmit: handleFormSubmit }, /* @__PURE__ */ import_react25.default.createElement(SuggestedActions_default, null), /* @__PURE__ */ import_react25.default.createElement("div", { className: (0, import_classnames7.default)(classNames["sendbox__sendbox"]), onClickCapture: handleSendBoxClick }, /* @__PURE__ */ import_react25.default.createElement(
|
|
1056
|
+
Surrogate_default,
|
|
1057
|
+
{
|
|
1058
|
+
autoFocus: true,
|
|
1059
|
+
isHorizontal: false,
|
|
1060
|
+
onButtonClick: handleTelephoneKeypadButtonClick
|
|
1061
|
+
}
|
|
1062
|
+
), /* @__PURE__ */ import_react25.default.createElement(
|
|
1063
|
+
TextArea_default2,
|
|
1064
|
+
{
|
|
1065
|
+
"aria-label": isMessageLengthExceeded ? localize("TEXT_INPUT_LENGTH_EXCEEDED_ALT") : localize("TEXT_INPUT_ALT"),
|
|
1066
|
+
className: classNames["sendbox__sendbox-text"],
|
|
1067
|
+
"data-testid": testIds_default.sendBoxTextBox,
|
|
1068
|
+
hidden: telephoneKeypadShown,
|
|
1069
|
+
onInput: handleMessageChange,
|
|
1070
|
+
placeholder: props.placeholder ?? localize("TEXT_INPUT_PLACEHOLDER"),
|
|
1071
|
+
ref: inputRef,
|
|
1072
|
+
value: message
|
|
1073
|
+
}
|
|
1074
|
+
), /* @__PURE__ */ import_react25.default.createElement(Attachments_default2, { attachments }), /* @__PURE__ */ import_react25.default.createElement("div", { className: (0, import_classnames7.default)(classNames["sendbox__sendbox-controls"]) }, maxMessageLength && /* @__PURE__ */ import_react25.default.createElement(
|
|
1075
|
+
"div",
|
|
1076
|
+
{
|
|
1077
|
+
className: (0, import_classnames7.default)(classNames["sendbox__text-counter"], {
|
|
1078
|
+
[classNames["sendbox__text-counter--error"]]: isMessageLengthExceeded
|
|
1079
|
+
})
|
|
1080
|
+
},
|
|
1081
|
+
`${message.length}/${maxMessageLength}`
|
|
1082
|
+
), /* @__PURE__ */ import_react25.default.createElement(Toolbar, null, !hideTelephoneKeypadButton && /* @__PURE__ */ import_react25.default.createElement(TelephoneKeypadToolbarButton_default, null), !hideUploadButton && /* @__PURE__ */ import_react25.default.createElement(AddAttachmentButton_default2, { onFilesAdded: handleAddFiles }), /* @__PURE__ */ import_react25.default.createElement(ToolbarSeparator, null), /* @__PURE__ */ import_react25.default.createElement(
|
|
1083
|
+
ToolbarButton,
|
|
1084
|
+
{
|
|
1085
|
+
"aria-label": localize("TEXT_INPUT_SEND_BUTTON_ALT"),
|
|
1086
|
+
"data-testid": testIds_default.sendBoxSendButton,
|
|
1087
|
+
disabled: isMessageLengthExceeded,
|
|
1088
|
+
type: "submit"
|
|
1089
|
+
},
|
|
1090
|
+
/* @__PURE__ */ import_react25.default.createElement(SendIcon, null)
|
|
1091
|
+
))), /* @__PURE__ */ import_react25.default.createElement(DropZone_default, { onFilesAdded: handleAddFiles }), /* @__PURE__ */ import_react25.default.createElement(ErrorMessage_default2, { error: errorMessage, id: errorMessageId })));
|
|
1092
|
+
}
|
|
1093
|
+
var sendbox_default2 = (0, import_react25.memo)(SendBox);
|
|
48
1094
|
|
|
49
|
-
// src/
|
|
50
|
-
var
|
|
51
|
-
var SendBox = ({ className }) => /* @__PURE__ */ import_react.default.createElement("div", { className }, "Fluent send box");
|
|
52
|
-
var SendBox_default = (0, import_react.memo)(SendBox);
|
|
1095
|
+
// src/components/SendBox.tsx
|
|
1096
|
+
var SendBox_default = sendbox_default2;
|
|
53
1097
|
|
|
54
1098
|
// src/private/FluentThemeProvider.tsx
|
|
55
|
-
var
|
|
1099
|
+
var { ThemeProvider } = import_botframework_webchat_component9.Components;
|
|
56
1100
|
var sendBoxMiddleware = [() => () => () => SendBox_default];
|
|
57
|
-
var FluentThemeProvider = ({ children }) => /* @__PURE__ */
|
|
58
|
-
var FluentThemeProvider_default = (0,
|
|
1101
|
+
var FluentThemeProvider = ({ children }) => /* @__PURE__ */ import_react26.default.createElement(WebchatTheme, null, /* @__PURE__ */ import_react26.default.createElement(Provider_default, null, /* @__PURE__ */ import_react26.default.createElement(ThemeProvider, { sendBoxMiddleware }, children)));
|
|
1102
|
+
var FluentThemeProvider_default = (0, import_react26.memo)(FluentThemeProvider);
|
|
59
1103
|
|
|
60
1104
|
// src/index.ts
|
|
61
|
-
(0, import_inject_meta_tag.injectMetaTag)("botframework-webchat-fluent-theme:version", "4.17.0-main.
|
|
1105
|
+
(0, import_inject_meta_tag.injectMetaTag)("botframework-webchat-fluent-theme:version", "4.17.0-main.20240416.4ff01ae");
|
|
1106
|
+
injectStyles();
|
|
62
1107
|
// Annotate the CommonJS export names for ESM import in node:
|
|
63
1108
|
0 && (module.exports = {
|
|
64
|
-
FluentThemeProvider
|
|
1109
|
+
FluentThemeProvider,
|
|
1110
|
+
testIds
|
|
65
1111
|
});
|
|
66
1112
|
//# sourceMappingURL=index.js.map
|