botframework-webchat-fluent-theme 4.17.0-main.20240411.647b269 → 4.17.0-main.20240411.ff34969
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.js +4081 -0
- package/dist/botframework-webchat-fluent-theme.development.js.map +1 -0
- package/dist/botframework-webchat-fluent-theme.production.min.js +8 -16
- package/dist/botframework-webchat-fluent-theme.production.min.js.map +1 -1
- package/dist/index.js +1350 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +13 -4
- 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.tsx +71 -0
- package/src/components/dropZone/index.tsx +132 -0
- package/src/components/sendbox/AddAttachmentButton.tsx +77 -0
- package/src/components/sendbox/Attachments.tsx +40 -0
- package/src/components/sendbox/ErrorMessage.tsx +26 -0
- package/src/components/sendbox/TelephoneKeypadToolbarButton.tsx +30 -0
- package/src/components/sendbox/TextArea.tsx +146 -0
- package/src/components/sendbox/Toolbar.tsx +115 -0
- package/src/components/sendbox/index.tsx +234 -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.tsx +129 -0
- package/src/components/suggestedActions/index.tsx +103 -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.tsx +107 -0
- package/src/components/telephoneKeypad/private/Context.ts +18 -0
- package/src/components/telephoneKeypad/private/TelephoneKeypad.tsx +168 -0
- package/src/components/telephoneKeypad/types.ts +1 -0
- package/src/components/telephoneKeypad/useShown.ts +9 -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 +2 -1
- package/src/private/FluentThemeProvider.tsx +11 -7
- package/src/private/useStyleToEmotionObject.ts +32 -0
- package/src/styles/index.ts +15 -0
- package/src/testIds.ts +21 -0
- 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,1371 @@ 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_component5 = require("botframework-webchat-component");
|
|
41
|
+
var import_react27 = __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_react8 = __toESM(require("react"));
|
|
74
|
+
|
|
75
|
+
// src/components/telephoneKeypad/private/TelephoneKeypad.tsx
|
|
76
|
+
var import_react7 = __toESM(require("react"));
|
|
77
|
+
var import_use_ref_from2 = require("use-ref-from");
|
|
78
|
+
|
|
79
|
+
// src/styles/index.ts
|
|
80
|
+
var import_react4 = require("react");
|
|
81
|
+
|
|
82
|
+
// src/private/useStyleToEmotionObject.ts
|
|
83
|
+
var import_create_instance = __toESM(require("@emotion/css/create-instance"));
|
|
84
|
+
var import_react3 = require("react");
|
|
85
|
+
var { random } = Math;
|
|
86
|
+
var emotionPool = {};
|
|
87
|
+
var nonce = "";
|
|
88
|
+
function createCSSKey() {
|
|
89
|
+
return random().toString(26).substr(2, 5).replace(/\d/gu, (value) => String.fromCharCode(value.charCodeAt(0) + 65));
|
|
90
|
+
}
|
|
91
|
+
function useStyleToEmotionObject() {
|
|
92
|
+
return (0, import_react3.useMemo)(() => {
|
|
93
|
+
const emotion = (
|
|
94
|
+
// Prefix "id-" to prevent object injection attack.
|
|
95
|
+
emotionPool[`id-${nonce}`] || (emotionPool[`id-${nonce}`] = (0, import_create_instance.default)({ key: `webchat--css-${createCSSKey()}`, nonce }))
|
|
96
|
+
);
|
|
97
|
+
return (style) => emotion.css(style);
|
|
98
|
+
}, []);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// src/styles/index.ts
|
|
102
|
+
function useStyles(styles13) {
|
|
103
|
+
const getClassName = useStyleToEmotionObject();
|
|
104
|
+
return (0, import_react4.useMemo)(
|
|
105
|
+
() => Object.freeze(
|
|
106
|
+
Object.fromEntries(Object.entries(styles13).map(([cls, style]) => [cls, `${cls} ${getClassName(style)}`]))
|
|
107
|
+
),
|
|
108
|
+
[styles13, getClassName]
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// src/components/telephoneKeypad/private/Button.tsx
|
|
113
|
+
var import_react5 = __toESM(require("react"));
|
|
114
|
+
var import_use_ref_from = require("use-ref-from");
|
|
115
|
+
var styles = {
|
|
116
|
+
"webchat__telephone-keypad__button": {
|
|
117
|
+
"-webkit-user-select": "none",
|
|
118
|
+
alignItems: "center",
|
|
119
|
+
appearance: "none",
|
|
120
|
+
// backgroundColor: isDarkTheme() || isHighContrastTheme() ? black : white,
|
|
121
|
+
backgroundColor: "White",
|
|
122
|
+
borderRadius: "100%",
|
|
123
|
+
// Whitelabel styles
|
|
124
|
+
// border: `solid 1px ${isHighContrastTheme() ? white : isDarkTheme() ? gray160 : gray40}`,
|
|
125
|
+
// color: 'inherit',
|
|
126
|
+
border: "solid 1px var(--webchat-colorNeutralStroke1)",
|
|
127
|
+
color: "var(--webchat-colorNeutralForeground1)",
|
|
128
|
+
fontWeight: "var(--webchat-fontWeightSemibold)",
|
|
129
|
+
cursor: "pointer",
|
|
130
|
+
display: "flex",
|
|
131
|
+
flexDirection: "column",
|
|
132
|
+
height: 60,
|
|
133
|
+
opacity: 0.7,
|
|
134
|
+
padding: 0,
|
|
135
|
+
position: "relative",
|
|
136
|
+
touchAction: "none",
|
|
137
|
+
userSelect: "none",
|
|
138
|
+
width: 60,
|
|
139
|
+
"&:hover": {
|
|
140
|
+
// backgroundColor: isHighContrastTheme() ? gray210 : isDarkTheme() ? gray150 : gray30
|
|
141
|
+
backgroundColor: "var(--webchat-colorGray30)"
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
"webchat__telephone-keypad__button__ruby": {
|
|
145
|
+
// color: isHighContrastTheme() ? white : isDarkTheme() ? gray40 : gray160,
|
|
146
|
+
color: "var(--webchat-colorGray160)",
|
|
147
|
+
fontSize: 10
|
|
148
|
+
},
|
|
149
|
+
"webchat__telephone-keypad__button__text": {
|
|
150
|
+
fontSize: 24,
|
|
151
|
+
marginTop: 8
|
|
152
|
+
},
|
|
153
|
+
"webchat__telephone-keypad--horizontal": {
|
|
154
|
+
"& .webchat__telephone-keypad__button": {
|
|
155
|
+
height: 32,
|
|
156
|
+
width: 32,
|
|
157
|
+
margin: "8px 4px",
|
|
158
|
+
justifyContent: "center"
|
|
159
|
+
},
|
|
160
|
+
"webchat__telephone-keypad__button__ruby": {
|
|
161
|
+
display: "none"
|
|
162
|
+
},
|
|
163
|
+
"& .webchat__telephone-keypad__button__text": {
|
|
164
|
+
fontSize: 20,
|
|
165
|
+
marginTop: 0
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
var Button = (0, import_react5.memo)(
|
|
170
|
+
// As we are all TypeScript, internal components do not need propTypes.
|
|
171
|
+
// eslint-disable-next-line react/prop-types
|
|
172
|
+
(0, import_react5.forwardRef)(({ button, "data-testid": dataTestId, onClick, ruby }, ref) => {
|
|
173
|
+
const classNames = useStyles(styles);
|
|
174
|
+
const onClickRef = (0, import_use_ref_from.useRefFrom)(onClick);
|
|
175
|
+
const handleClick = (0, import_react5.useCallback)(() => onClickRef.current?.(), [onClickRef]);
|
|
176
|
+
return /* @__PURE__ */ import_react5.default.createElement(
|
|
177
|
+
"button",
|
|
178
|
+
{
|
|
179
|
+
className: classNames["webchat__telephone-keypad__button"],
|
|
180
|
+
"data-testid": dataTestId,
|
|
181
|
+
onClick: handleClick,
|
|
182
|
+
ref,
|
|
183
|
+
type: "button"
|
|
184
|
+
},
|
|
185
|
+
/* @__PURE__ */ import_react5.default.createElement("span", { className: classNames["webchat__telephone-keypad__button__text"] }, button === "star" ? "\u2217" : button === "pound" ? "#" : button),
|
|
186
|
+
!!ruby && /* @__PURE__ */ import_react5.default.createElement("ruby", { className: classNames["webchat__telephone-keypad__button__ruby"] }, ruby)
|
|
187
|
+
);
|
|
188
|
+
})
|
|
189
|
+
);
|
|
190
|
+
Button.displayName = "TelephoneKeypad.Button";
|
|
191
|
+
var Button_default = Button;
|
|
192
|
+
|
|
193
|
+
// src/testIds.ts
|
|
194
|
+
var testIds = {
|
|
195
|
+
sendBoxDropZone: "send box drop zone",
|
|
196
|
+
sendBoxSendButton: "send box send button",
|
|
197
|
+
sendBoxTextBox: "send box text area",
|
|
198
|
+
sendBoxTelephoneKeypadButton1: `send box telephone keypad button 1`,
|
|
199
|
+
sendBoxTelephoneKeypadButton2: `send box telephone keypad button 2`,
|
|
200
|
+
sendBoxTelephoneKeypadButton3: `send box telephone keypad button 3`,
|
|
201
|
+
sendBoxTelephoneKeypadButton4: `send box telephone keypad button 4`,
|
|
202
|
+
sendBoxTelephoneKeypadButton5: `send box telephone keypad button 5`,
|
|
203
|
+
sendBoxTelephoneKeypadButton6: `send box telephone keypad button 6`,
|
|
204
|
+
sendBoxTelephoneKeypadButton7: `send box telephone keypad button 7`,
|
|
205
|
+
sendBoxTelephoneKeypadButton8: `send box telephone keypad button 8`,
|
|
206
|
+
sendBoxTelephoneKeypadButton9: `send box telephone keypad button 9`,
|
|
207
|
+
sendBoxTelephoneKeypadButton0: `send box telephone keypad button 0`,
|
|
208
|
+
sendBoxTelephoneKeypadButtonStar: `send box telephone keypad button star`,
|
|
209
|
+
sendBoxTelephoneKeypadButtonPound: `send box telephone keypad button pound`,
|
|
210
|
+
sendBoxTelephoneKeypadToolbarButton: "send box telephone keypad toolbar button",
|
|
211
|
+
sendBoxUploadButton: "send box upload button"
|
|
212
|
+
};
|
|
213
|
+
var testIds_default = testIds;
|
|
214
|
+
|
|
215
|
+
// src/components/telephoneKeypad/useShown.ts
|
|
216
|
+
var import_react6 = require("react");
|
|
217
|
+
function useShown() {
|
|
218
|
+
const { setShown, shown } = (0, import_react6.useContext)(Context_default);
|
|
219
|
+
return (0, import_react6.useMemo)(() => Object.freeze([shown, setShown]), [shown, setShown]);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// src/components/telephoneKeypad/private/TelephoneKeypad.tsx
|
|
223
|
+
var styles2 = {
|
|
224
|
+
"webchat__telephone-keypad": {
|
|
225
|
+
/* Commented out whitelabel styles for now. */
|
|
226
|
+
// background: getHighContrastDarkThemeColor(highContrastColor: black, darkThemeColor: gray190, string, defaultColor: gray10),
|
|
227
|
+
// borderRadius: '8px 8px 0px 0px',
|
|
228
|
+
// boxShadow: '-3px 0px 7px 0px rgba(0, 0, 0, 0.13), -0.6px 0px 1.8px 0px rgba(0, 0, 0, 0.10)',
|
|
229
|
+
alignItems: "center",
|
|
230
|
+
background: "var(--webchat-colorNeutralBackground1)",
|
|
231
|
+
// border: isHighContrastTheme() ? `1px solid ${white}` : 'none',
|
|
232
|
+
border: "none",
|
|
233
|
+
borderRadius: "var(--webchat-borderRadiusXLarge)",
|
|
234
|
+
// boxShadow: 'var(--shadow16)',
|
|
235
|
+
display: "flex",
|
|
236
|
+
flexDirection: "column",
|
|
237
|
+
fontFamily: "var(--webchat-fontFamilyBase)",
|
|
238
|
+
justifyContent: "center"
|
|
239
|
+
// margin: 'var(--spacingHorizontalMNudge)'
|
|
240
|
+
},
|
|
241
|
+
"webchat__telephone-keypad__box": {
|
|
242
|
+
boxSizing: "border-box",
|
|
243
|
+
display: "grid",
|
|
244
|
+
gap: "16px",
|
|
245
|
+
gridTemplateColumns: "repeat(3, 1fr)",
|
|
246
|
+
gridTemplateRows: "repeat(4, 1fr)",
|
|
247
|
+
justifyItems: "center",
|
|
248
|
+
padding: "16px",
|
|
249
|
+
width: "100%"
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
var Orientation = (0, import_react7.memo)(
|
|
253
|
+
({ children, isHorizontal }) => {
|
|
254
|
+
const classNames = useStyles(styles2);
|
|
255
|
+
return isHorizontal ? (
|
|
256
|
+
// <HorizontalDialPadController>{children}</HorizontalDialPadController>
|
|
257
|
+
false
|
|
258
|
+
) : /* @__PURE__ */ import_react7.default.createElement("div", { className: classNames["webchat__telephone-keypad__box"] }, children);
|
|
259
|
+
}
|
|
260
|
+
);
|
|
261
|
+
Orientation.displayName = "TelephoneKeypad:Orientation";
|
|
262
|
+
var TelephoneKeypad = (0, import_react7.memo)(({ autoFocus, onButtonClick, isHorizontal }) => {
|
|
263
|
+
const autoFocusRef = (0, import_use_ref_from2.useRefFrom)(autoFocus);
|
|
264
|
+
const classNames = useStyles(styles2);
|
|
265
|
+
const firstButtonRef = (0, import_react7.useRef)(null);
|
|
266
|
+
const onButtonClickRef = (0, import_use_ref_from2.useRefFrom)(onButtonClick);
|
|
267
|
+
const [, setShown] = useShown();
|
|
268
|
+
const handleButton1Click = (0, import_react7.useCallback)(() => onButtonClickRef.current?.("1"), [onButtonClickRef]);
|
|
269
|
+
const handleButton2Click = (0, import_react7.useCallback)(() => onButtonClickRef.current?.("2"), [onButtonClickRef]);
|
|
270
|
+
const handleButton3Click = (0, import_react7.useCallback)(() => onButtonClickRef.current?.("3"), [onButtonClickRef]);
|
|
271
|
+
const handleButton4Click = (0, import_react7.useCallback)(() => onButtonClickRef.current?.("4"), [onButtonClickRef]);
|
|
272
|
+
const handleButton5Click = (0, import_react7.useCallback)(() => onButtonClickRef.current?.("5"), [onButtonClickRef]);
|
|
273
|
+
const handleButton6Click = (0, import_react7.useCallback)(() => onButtonClickRef.current?.("6"), [onButtonClickRef]);
|
|
274
|
+
const handleButton7Click = (0, import_react7.useCallback)(() => onButtonClickRef.current?.("7"), [onButtonClickRef]);
|
|
275
|
+
const handleButton8Click = (0, import_react7.useCallback)(() => onButtonClickRef.current?.("8"), [onButtonClickRef]);
|
|
276
|
+
const handleButton9Click = (0, import_react7.useCallback)(() => onButtonClickRef.current?.("9"), [onButtonClickRef]);
|
|
277
|
+
const handleButton0Click = (0, import_react7.useCallback)(() => onButtonClickRef.current?.("0"), [onButtonClickRef]);
|
|
278
|
+
const handleButtonStarClick = (0, import_react7.useCallback)(() => onButtonClickRef.current?.("star"), [onButtonClickRef]);
|
|
279
|
+
const handleButtonPoundClick = (0, import_react7.useCallback)(() => onButtonClickRef.current?.("pound"), [onButtonClickRef]);
|
|
280
|
+
const handleKeyDown = (0, import_react7.useCallback)(
|
|
281
|
+
(event) => {
|
|
282
|
+
if (event.key === "Escape") {
|
|
283
|
+
setShown(false);
|
|
284
|
+
}
|
|
285
|
+
},
|
|
286
|
+
[setShown]
|
|
287
|
+
);
|
|
288
|
+
(0, import_react7.useEffect)(() => {
|
|
289
|
+
autoFocusRef.current && firstButtonRef.current?.focus();
|
|
290
|
+
}, [autoFocusRef, firstButtonRef]);
|
|
291
|
+
return /* @__PURE__ */ import_react7.default.createElement("div", { className: classNames["webchat__telephone-keypad"], onKeyDown: handleKeyDown }, /* @__PURE__ */ import_react7.default.createElement(Orientation, { isHorizontal }, /* @__PURE__ */ import_react7.default.createElement(
|
|
292
|
+
Button_default,
|
|
293
|
+
{
|
|
294
|
+
button: "1",
|
|
295
|
+
"data-testid": testIds_default.sendBoxTelephoneKeypadButton1,
|
|
296
|
+
onClick: handleButton1Click,
|
|
297
|
+
ref: firstButtonRef
|
|
298
|
+
}
|
|
299
|
+
), /* @__PURE__ */ import_react7.default.createElement(
|
|
300
|
+
Button_default,
|
|
301
|
+
{
|
|
302
|
+
button: "2",
|
|
303
|
+
"data-testid": testIds_default.sendBoxTelephoneKeypadButton2,
|
|
304
|
+
onClick: handleButton2Click,
|
|
305
|
+
ruby: "ABC"
|
|
306
|
+
}
|
|
307
|
+
), /* @__PURE__ */ import_react7.default.createElement(
|
|
308
|
+
Button_default,
|
|
309
|
+
{
|
|
310
|
+
button: "3",
|
|
311
|
+
"data-testid": testIds_default.sendBoxTelephoneKeypadButton3,
|
|
312
|
+
onClick: handleButton3Click,
|
|
313
|
+
ruby: "DEF"
|
|
314
|
+
}
|
|
315
|
+
), /* @__PURE__ */ import_react7.default.createElement(
|
|
316
|
+
Button_default,
|
|
317
|
+
{
|
|
318
|
+
button: "4",
|
|
319
|
+
"data-testid": testIds_default.sendBoxTelephoneKeypadButton4,
|
|
320
|
+
onClick: handleButton4Click,
|
|
321
|
+
ruby: "GHI"
|
|
322
|
+
}
|
|
323
|
+
), /* @__PURE__ */ import_react7.default.createElement(
|
|
324
|
+
Button_default,
|
|
325
|
+
{
|
|
326
|
+
button: "5",
|
|
327
|
+
"data-testid": testIds_default.sendBoxTelephoneKeypadButton5,
|
|
328
|
+
onClick: handleButton5Click,
|
|
329
|
+
ruby: "JKL"
|
|
330
|
+
}
|
|
331
|
+
), /* @__PURE__ */ import_react7.default.createElement(
|
|
332
|
+
Button_default,
|
|
333
|
+
{
|
|
334
|
+
button: "6",
|
|
335
|
+
"data-testid": testIds_default.sendBoxTelephoneKeypadButton6,
|
|
336
|
+
onClick: handleButton6Click,
|
|
337
|
+
ruby: "MNO"
|
|
338
|
+
}
|
|
339
|
+
), /* @__PURE__ */ import_react7.default.createElement(
|
|
340
|
+
Button_default,
|
|
341
|
+
{
|
|
342
|
+
button: "7",
|
|
343
|
+
"data-testid": testIds_default.sendBoxTelephoneKeypadButton7,
|
|
344
|
+
onClick: handleButton7Click,
|
|
345
|
+
ruby: "PQRS"
|
|
346
|
+
}
|
|
347
|
+
), /* @__PURE__ */ import_react7.default.createElement(
|
|
348
|
+
Button_default,
|
|
349
|
+
{
|
|
350
|
+
button: "8",
|
|
351
|
+
"data-testid": testIds_default.sendBoxTelephoneKeypadButton8,
|
|
352
|
+
onClick: handleButton8Click,
|
|
353
|
+
ruby: "TUV"
|
|
354
|
+
}
|
|
355
|
+
), /* @__PURE__ */ import_react7.default.createElement(
|
|
356
|
+
Button_default,
|
|
357
|
+
{
|
|
358
|
+
button: "9",
|
|
359
|
+
"data-testid": testIds_default.sendBoxTelephoneKeypadButton9,
|
|
360
|
+
onClick: handleButton9Click,
|
|
361
|
+
ruby: "WXYZ"
|
|
362
|
+
}
|
|
363
|
+
), /* @__PURE__ */ import_react7.default.createElement(Button_default, { button: "star", "data-testid": testIds_default.sendBoxTelephoneKeypadButtonStar, onClick: handleButtonStarClick }), /* @__PURE__ */ import_react7.default.createElement(Button_default, { button: "0", "data-testid": testIds_default.sendBoxTelephoneKeypadButton0, onClick: handleButton0Click, ruby: "+" }), /* @__PURE__ */ import_react7.default.createElement(
|
|
364
|
+
Button_default,
|
|
365
|
+
{
|
|
366
|
+
button: "pound",
|
|
367
|
+
"data-testid": testIds_default.sendBoxTelephoneKeypadButtonPound,
|
|
368
|
+
onClick: handleButtonPoundClick
|
|
369
|
+
}
|
|
370
|
+
)));
|
|
371
|
+
});
|
|
372
|
+
TelephoneKeypad.displayName = "TelephoneKeypad";
|
|
373
|
+
var TelephoneKeypad_default = TelephoneKeypad;
|
|
374
|
+
|
|
375
|
+
// src/components/telephoneKeypad/Surrogate.tsx
|
|
376
|
+
var TelephoneKeypadSurrogate = (0, import_react8.memo)((props) => useShown()[0] ? /* @__PURE__ */ import_react8.default.createElement(TelephoneKeypad_default, { ...props }) : false);
|
|
377
|
+
TelephoneKeypadSurrogate.displayName = "TelephoneKeypad.Surrogate";
|
|
378
|
+
var Surrogate_default = TelephoneKeypadSurrogate;
|
|
379
|
+
|
|
380
|
+
// src/components/Theme.tsx
|
|
381
|
+
var import_react9 = __toESM(require("react"));
|
|
382
|
+
var styles3 = {
|
|
383
|
+
"webchat-fluent__theme": {
|
|
384
|
+
display: "contents",
|
|
385
|
+
"--webchat-colorNeutralForeground1": "var(--colorNeutralForeground1, #242424)",
|
|
386
|
+
"--webchat-colorNeutralForeground2": "var(--colorNeutralForeground2, #424242)",
|
|
387
|
+
"--webchat-colorNeutralForeground4": "var(--colorNeutralForeground4, #707070)",
|
|
388
|
+
"--webchat-colorNeutralForegroundDisabled": "var(--colorNeutralForegroundDisabled, #bdbdbd)",
|
|
389
|
+
"--webchat-colorNeutralBackground1": "var(--colorNeutralBackground1, #ffffff)",
|
|
390
|
+
"--webchat-colorNeutralBackground4": "var(--colorNeutralBackground4, #f0f0f0)",
|
|
391
|
+
"--webchat-colorNeutralBackground5": "var(--colorNeutralBackground5, #ebebeb)",
|
|
392
|
+
"--webchat-colorSubtleBackgroundHover": "var(--colorSubtleBackgroundHover, #f5f5f5)",
|
|
393
|
+
"--webchat-colorSubtleBackgroundPressed": "var(--colorSubtleBackgroundPressed, #e0e0e0)",
|
|
394
|
+
"--webchat-colorNeutralStroke1": "var(--colorNeutralStroke1, #d1d1d1)",
|
|
395
|
+
"--webchat-colorNeutralStroke2": "var(--colorNeutralStroke2, #e0e0e0)",
|
|
396
|
+
"--webchat-colorNeutralStroke1Selected": "var(--colorNeutralStroke1Selected, #bdbdbd)",
|
|
397
|
+
"--webchat-colorBrandStroke2": "var(--colorBrandStroke2, #9edcf7)",
|
|
398
|
+
"--webchat-colorBrandForeground2Hover": "var(--colorBrandForeground2Hover, #015a7a)",
|
|
399
|
+
"--webchat-colorBrandForeground2Pressed": "var(--colorBrandForeground2Pressed, #01384d)",
|
|
400
|
+
"--webchat-colorBrandBackground2Hover": "var(--colorBrandBackground2Hover, #bee7fa)",
|
|
401
|
+
"--webchat-colorBrandBackground2Pressed": "var(--colorBrandBackground2Pressed, #7fd2f5)",
|
|
402
|
+
"--webchat-colorCompoundBrandForeground1": "var(--colorCompoundBrandForeground1, #077fab)",
|
|
403
|
+
"--webchat-colorCompoundBrandForeground1Hover": "var(--colorCompoundBrandForeground1Hover, #02729c)",
|
|
404
|
+
"--webchat-colorCompoundBrandForeground1Pressed": "var(--colorCompoundBrandForeground1Pressed, #01678c)",
|
|
405
|
+
"--webchat-colorStatusDangerForeground1": "var(--colorStatusDangerForeground1, #b10e1c)",
|
|
406
|
+
// https://github.com/microsoft/fluentui/blob/master/packages/tokens/src/global/colors.ts
|
|
407
|
+
"--webchat-colorGray30": "var(--colorGray30, #edebe9)",
|
|
408
|
+
"--webchat-colorGray160": "var(--colorGray160, #323130)",
|
|
409
|
+
"--webchat-colorGray200": "var(--colorGray200, #1b1a19)",
|
|
410
|
+
// https://github.com/microsoft/fluentui/blob/master/packages/tokens/src/global/borderRadius.ts
|
|
411
|
+
"--webchat-borderRadiusSmall": "var(--borderRadiusSmall, 2px)",
|
|
412
|
+
"--webchat-borderRadiusLarge": "var(--borderRadiusLarge, 6px)",
|
|
413
|
+
"--webchat-borderRadiusXLarge": "var(--borderRadiusXLarge, 8px)",
|
|
414
|
+
// https://github.com/microsoft/fluentui/blob/master/packages/tokens/src/utils/shadows.ts
|
|
415
|
+
"--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))",
|
|
416
|
+
// https://github.com/microsoft/fluentui/blob/master/packages/tokens/src/global/spacings.ts
|
|
417
|
+
"--webchat-spacingHorizontalMNudge": "var(--spacingHorizontalMNudge, 10px)",
|
|
418
|
+
// https://github.com/microsoft/fluentui/blob/master/packages/tokens/src/global/fonts.ts
|
|
419
|
+
"--webchat-fontFamilyBase": `var(--fontFamilyBase, 'Segoe UI)', 'Segoe UI Web (West European))', -apple-system,
|
|
420
|
+
BlinkMacSystemFont, Roboto, 'Helvetica Neue)', sans-serif)`,
|
|
421
|
+
"--webchat-fontFamilyNumeric": `var(--fontFamilyNumeric, Bahnschrift, 'Segoe UI)', 'Segoe UI Web (West European))',
|
|
422
|
+
-apple-system, BlinkMacSystemFont, Roboto, 'Helvetica Neue)', sans-serif)`,
|
|
423
|
+
// https://github.com/microsoft/fluentui/blob/master/packages/tokens/src/global/fonts.ts
|
|
424
|
+
"--webchat-fontWeightSemibold": "var(--fontWeightSemibold, 600)"
|
|
425
|
+
}
|
|
426
|
+
};
|
|
427
|
+
function WebchatTheme(props) {
|
|
428
|
+
const classNames = useStyles(styles3);
|
|
429
|
+
return /* @__PURE__ */ import_react9.default.createElement("div", { className: classNames["webchat-fluent__theme"] }, props.children);
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
// src/components/sendbox/index.tsx
|
|
433
|
+
var import_botframework_webchat_component4 = require("botframework-webchat-component");
|
|
434
|
+
var import_classnames6 = __toESM(require("classnames"));
|
|
435
|
+
var import_react26 = __toESM(require("react"));
|
|
436
|
+
var import_use_ref_from6 = require("use-ref-from");
|
|
437
|
+
|
|
438
|
+
// src/icons/SendIcon.tsx
|
|
439
|
+
var import_react10 = __toESM(require("react"));
|
|
440
|
+
function SendIcon(props) {
|
|
441
|
+
return /* @__PURE__ */ import_react10.default.createElement(
|
|
442
|
+
"svg",
|
|
443
|
+
{
|
|
444
|
+
"aria-hidden": "true",
|
|
445
|
+
className: props.className,
|
|
446
|
+
fill: "currentColor",
|
|
447
|
+
height: "1em",
|
|
448
|
+
viewBox: "0 0 20 20",
|
|
449
|
+
width: "1em",
|
|
450
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
451
|
+
},
|
|
452
|
+
/* @__PURE__ */ import_react10.default.createElement(
|
|
453
|
+
"path",
|
|
454
|
+
{
|
|
455
|
+
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",
|
|
456
|
+
fill: "currentColor"
|
|
457
|
+
}
|
|
458
|
+
)
|
|
459
|
+
);
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
// src/components/dropZone/index.tsx
|
|
463
|
+
var import_botframework_webchat_api = require("botframework-webchat-api");
|
|
464
|
+
var import_classnames = __toESM(require("classnames"));
|
|
465
|
+
var import_react12 = __toESM(require("react"));
|
|
466
|
+
var import_use_ref_from3 = require("use-ref-from");
|
|
467
|
+
|
|
468
|
+
// src/icons/AddDocumentIcon.tsx
|
|
469
|
+
var import_react11 = __toESM(require("react"));
|
|
470
|
+
function AddDocumentIcon(props) {
|
|
471
|
+
return /* @__PURE__ */ import_react11.default.createElement(
|
|
472
|
+
"svg",
|
|
473
|
+
{
|
|
474
|
+
"aria-hidden": "true",
|
|
475
|
+
className: props.className,
|
|
476
|
+
fill: "currentColor",
|
|
477
|
+
height: "1em",
|
|
478
|
+
viewBox: "0 0 20 20",
|
|
479
|
+
width: "1em",
|
|
480
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
481
|
+
},
|
|
482
|
+
/* @__PURE__ */ import_react11.default.createElement(
|
|
483
|
+
"path",
|
|
484
|
+
{
|
|
485
|
+
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",
|
|
486
|
+
fill: "currentColor"
|
|
487
|
+
}
|
|
488
|
+
)
|
|
489
|
+
);
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
// src/components/dropZone/index.tsx
|
|
493
|
+
var { useLocalizer } = import_botframework_webchat_api.hooks;
|
|
494
|
+
var styles4 = {
|
|
495
|
+
"webchat-fluent__sendbox__attachment-drop-zone": {
|
|
496
|
+
backgroundColor: "var(--webchat-colorNeutralBackground4)",
|
|
497
|
+
borderRadius: "inherit",
|
|
498
|
+
cursor: "copy",
|
|
499
|
+
display: "grid",
|
|
500
|
+
gap: "8px",
|
|
501
|
+
inset: "0",
|
|
502
|
+
placeContent: "center",
|
|
503
|
+
placeItems: "center",
|
|
504
|
+
position: "absolute"
|
|
505
|
+
},
|
|
506
|
+
"webchat-fluent__sendbox__attachment-drop-zone--droppable": {
|
|
507
|
+
backgroundColor: "#e00",
|
|
508
|
+
color: "White"
|
|
509
|
+
},
|
|
510
|
+
"webchat-fluent__sendbox__attachment-drop-zone-icon": {
|
|
511
|
+
height: "36px",
|
|
512
|
+
// Set "pointer-events: none" to ignore dragging over the icon. Otherwise, when dragging over the icon, it would disable the "--droppable" modifier.
|
|
513
|
+
pointerEvents: "none",
|
|
514
|
+
width: "36px"
|
|
515
|
+
}
|
|
516
|
+
};
|
|
517
|
+
var handleDragOver = (event) => {
|
|
518
|
+
event.preventDefault();
|
|
519
|
+
};
|
|
520
|
+
var isFilesTransferEvent = (event) => !!event.dataTransfer?.types?.some((type) => type.toLowerCase() === "files");
|
|
521
|
+
function isDescendantOf(target, ancestor) {
|
|
522
|
+
let current = target.parentNode;
|
|
523
|
+
while (current) {
|
|
524
|
+
if (current === ancestor) {
|
|
525
|
+
return true;
|
|
526
|
+
}
|
|
527
|
+
current = current.parentNode;
|
|
528
|
+
}
|
|
529
|
+
return false;
|
|
530
|
+
}
|
|
531
|
+
var DropZone = (props) => {
|
|
532
|
+
const [dropZoneState, setDropZoneState] = (0, import_react12.useState)(false);
|
|
533
|
+
const classNames = useStyles(styles4);
|
|
534
|
+
const dropZoneRef = (0, import_react12.useRef)(null);
|
|
535
|
+
const localize = useLocalizer();
|
|
536
|
+
const onFilesAddedRef = (0, import_use_ref_from3.useRefFrom)(props.onFilesAdded);
|
|
537
|
+
(0, import_react12.useEffect)(() => {
|
|
538
|
+
let entranceCounter = 0;
|
|
539
|
+
const handleDragEnter = (event) => {
|
|
540
|
+
entranceCounter++;
|
|
541
|
+
if (isFilesTransferEvent(event)) {
|
|
542
|
+
setDropZoneState(
|
|
543
|
+
dropZoneRef.current && (event.target === dropZoneRef.current || event.target instanceof HTMLElement && isDescendantOf(event.target, dropZoneRef.current)) ? "droppable" : "visible"
|
|
544
|
+
);
|
|
545
|
+
}
|
|
546
|
+
};
|
|
547
|
+
const handleDragLeave = () => --entranceCounter <= 0 && setDropZoneState(false);
|
|
548
|
+
document.addEventListener("dragenter", handleDragEnter, false);
|
|
549
|
+
document.addEventListener("dragleave", handleDragLeave, false);
|
|
550
|
+
return () => {
|
|
551
|
+
document.removeEventListener("dragenter", handleDragEnter);
|
|
552
|
+
document.removeEventListener("dragleave", handleDragLeave);
|
|
553
|
+
};
|
|
554
|
+
}, [setDropZoneState]);
|
|
555
|
+
const handleDrop = (0, import_react12.useCallback)(
|
|
556
|
+
(event) => {
|
|
557
|
+
event.preventDefault();
|
|
558
|
+
setDropZoneState(false);
|
|
559
|
+
if (!isFilesTransferEvent(event.nativeEvent)) {
|
|
560
|
+
return;
|
|
561
|
+
}
|
|
562
|
+
onFilesAddedRef.current([...event.dataTransfer.files]);
|
|
563
|
+
},
|
|
564
|
+
[onFilesAddedRef, setDropZoneState]
|
|
565
|
+
);
|
|
566
|
+
return dropZoneState ? /* @__PURE__ */ import_react12.default.createElement(
|
|
567
|
+
"div",
|
|
568
|
+
{
|
|
569
|
+
className: (0, import_classnames.default)(classNames["webchat-fluent__sendbox__attachment-drop-zone"], {
|
|
570
|
+
[classNames["webchat-fluent__sendbox__attachment-drop-zone--droppable"]]: dropZoneState === "droppable"
|
|
571
|
+
}),
|
|
572
|
+
"data-testid": testIds_default.sendBoxDropZone,
|
|
573
|
+
onDragOver: handleDragOver,
|
|
574
|
+
onDrop: handleDrop,
|
|
575
|
+
ref: dropZoneRef
|
|
576
|
+
},
|
|
577
|
+
/* @__PURE__ */ import_react12.default.createElement(AddDocumentIcon, { className: classNames["webchat-fluent__sendbox__attachment-drop-zone-icon"] }),
|
|
578
|
+
localize("TEXT_INPUT_DROP_ZONE")
|
|
579
|
+
) : null;
|
|
580
|
+
};
|
|
581
|
+
DropZone.displayName = "DropZone";
|
|
582
|
+
var dropZone_default = (0, import_react12.memo)(DropZone);
|
|
583
|
+
|
|
584
|
+
// src/components/DropZone.tsx
|
|
585
|
+
var DropZone_default = dropZone_default;
|
|
586
|
+
|
|
587
|
+
// src/components/suggestedActions/index.tsx
|
|
588
|
+
var import_botframework_webchat_component2 = require("botframework-webchat-component");
|
|
589
|
+
var import_classnames3 = __toESM(require("classnames"));
|
|
590
|
+
var import_react15 = __toESM(require("react"));
|
|
591
|
+
|
|
592
|
+
// src/components/suggestedActions/private/computeSuggestedActionText.ts
|
|
593
|
+
function computeSuggestedActionText(cardAction) {
|
|
594
|
+
const { title } = cardAction;
|
|
595
|
+
const { type, value } = cardAction;
|
|
596
|
+
if (type === "messageBack") {
|
|
597
|
+
return title || cardAction.displayText;
|
|
598
|
+
} else if (title) {
|
|
599
|
+
return title;
|
|
600
|
+
} else if (typeof value === "string") {
|
|
601
|
+
return value;
|
|
602
|
+
}
|
|
603
|
+
return JSON.stringify(value);
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
// src/components/suggestedActions/SuggestedAction.tsx
|
|
607
|
+
var import_botframework_webchat_component = require("botframework-webchat-component");
|
|
608
|
+
var import_classnames2 = __toESM(require("classnames"));
|
|
609
|
+
var import_react14 = __toESM(require("react"));
|
|
610
|
+
|
|
611
|
+
// src/components/suggestedActions/AccessibleButton.tsx
|
|
612
|
+
var import_react13 = __toESM(require("react"));
|
|
613
|
+
var preventDefaultHandler = (event) => event.preventDefault();
|
|
614
|
+
var AccessibleButton = (0, import_react13.forwardRef)(
|
|
615
|
+
({ "aria-hidden": ariaHidden, children, disabled, onClick, tabIndex, ...props }, forwardedRef) => {
|
|
616
|
+
const targetRef = (0, import_react13.useRef)(null);
|
|
617
|
+
const ref = forwardedRef || targetRef;
|
|
618
|
+
return /* @__PURE__ */ import_react13.default.createElement(
|
|
619
|
+
"button",
|
|
620
|
+
{
|
|
621
|
+
"aria-disabled": disabled ? "true" : "false",
|
|
622
|
+
"aria-hidden": ariaHidden,
|
|
623
|
+
onClick: disabled ? preventDefaultHandler : onClick,
|
|
624
|
+
ref,
|
|
625
|
+
tabIndex,
|
|
626
|
+
...disabled && {
|
|
627
|
+
"aria-disabled": "true",
|
|
628
|
+
tabIndex: -1
|
|
629
|
+
},
|
|
630
|
+
...props,
|
|
631
|
+
type: "button"
|
|
632
|
+
},
|
|
633
|
+
children
|
|
634
|
+
);
|
|
45
635
|
}
|
|
46
|
-
|
|
47
|
-
var
|
|
636
|
+
);
|
|
637
|
+
var AccessibleButton_default = (0, import_react13.memo)(AccessibleButton);
|
|
638
|
+
|
|
639
|
+
// src/components/suggestedActions/SuggestedAction.tsx
|
|
640
|
+
var { useScrollToEnd, useStyleSet, usePerformCardAction, useFocus, useSuggestedActions, useDisabled } = import_botframework_webchat_component.hooks;
|
|
641
|
+
var styles5 = {
|
|
642
|
+
"webchat-fluent__suggested-action": {
|
|
643
|
+
background: "transparent",
|
|
644
|
+
border: "1px solid var(--webchat-colorBrandStroke2)",
|
|
645
|
+
borderRadius: "8px",
|
|
646
|
+
cursor: "pointer",
|
|
647
|
+
fontSize: "12px",
|
|
648
|
+
lineHeight: "14px",
|
|
649
|
+
padding: "6px 8px 4px",
|
|
650
|
+
textAlign: "start",
|
|
651
|
+
display: "flex",
|
|
652
|
+
gap: "4px",
|
|
653
|
+
alignItems: "center",
|
|
654
|
+
transition: "all .15s ease-out",
|
|
655
|
+
"@media (hover: hover)": {
|
|
656
|
+
'&:not([aria-disabled="true"]):hover': {
|
|
657
|
+
backgroundColor: "var(--webchat-colorBrandBackground2Hover)",
|
|
658
|
+
color: "var(--webchat-colorBrandForeground2Hover)"
|
|
659
|
+
}
|
|
660
|
+
},
|
|
661
|
+
'&:not([aria-disabled="true"]):active': {
|
|
662
|
+
backgroundColor: "var(--webchat-colorBrandBackground2Pressed)",
|
|
663
|
+
color: "var(--webchat-colorBrandForeground2Pressed)"
|
|
664
|
+
},
|
|
665
|
+
'&[aria-disabled="true"]': {
|
|
666
|
+
color: " var(--webchat-colorNeutralForegroundDisabled)",
|
|
667
|
+
cursor: "not-allowed"
|
|
668
|
+
}
|
|
669
|
+
},
|
|
670
|
+
"webchat-fluent__suggested-action__image": {
|
|
671
|
+
width: "1em",
|
|
672
|
+
height: "1em",
|
|
673
|
+
fontSize: "20px",
|
|
674
|
+
translate: "0 -1px"
|
|
675
|
+
}
|
|
676
|
+
};
|
|
677
|
+
function SuggestedAction({
|
|
678
|
+
buttonText,
|
|
679
|
+
className,
|
|
680
|
+
displayText,
|
|
681
|
+
image,
|
|
682
|
+
imageAlt,
|
|
683
|
+
text,
|
|
684
|
+
type,
|
|
685
|
+
value
|
|
686
|
+
}) {
|
|
687
|
+
const [_, setSuggestedActions] = useSuggestedActions();
|
|
688
|
+
const [{ suggestedAction: suggestedActionStyleSet }] = useStyleSet();
|
|
689
|
+
const [disabled] = useDisabled();
|
|
690
|
+
const focus = useFocus();
|
|
691
|
+
const focusRef = (0, import_react14.useRef)(null);
|
|
692
|
+
const performCardAction = usePerformCardAction();
|
|
693
|
+
const classNames = useStyles(styles5);
|
|
694
|
+
const scrollToEnd = useScrollToEnd();
|
|
695
|
+
const handleClick = (0, import_react14.useCallback)(
|
|
696
|
+
({ target }) => {
|
|
697
|
+
(async function() {
|
|
698
|
+
await focus("sendBoxWithoutKeyboard");
|
|
699
|
+
performCardAction({ displayText, text, type, value }, { target });
|
|
700
|
+
type === "openUrl" && setSuggestedActions([]);
|
|
701
|
+
scrollToEnd();
|
|
702
|
+
})();
|
|
703
|
+
},
|
|
704
|
+
[displayText, focus, performCardAction, scrollToEnd, setSuggestedActions, text, type, value]
|
|
705
|
+
);
|
|
706
|
+
return /* @__PURE__ */ import_react14.default.createElement(
|
|
707
|
+
AccessibleButton_default,
|
|
708
|
+
{
|
|
709
|
+
className: (0, import_classnames2.default)(
|
|
710
|
+
classNames["webchat-fluent__suggested-action"],
|
|
711
|
+
suggestedActionStyleSet + "",
|
|
712
|
+
(className || "") + ""
|
|
713
|
+
),
|
|
714
|
+
disabled,
|
|
715
|
+
onClick: handleClick,
|
|
716
|
+
ref: focusRef,
|
|
717
|
+
type: "button"
|
|
718
|
+
},
|
|
719
|
+
image && /* @__PURE__ */ import_react14.default.createElement("img", { alt: imageAlt, className: classNames["webchat-fluent__suggested-action__image"], src: image }),
|
|
720
|
+
/* @__PURE__ */ import_react14.default.createElement("span", null, buttonText)
|
|
721
|
+
);
|
|
722
|
+
}
|
|
723
|
+
var SuggestedAction_default = (0, import_react14.memo)(SuggestedAction);
|
|
724
|
+
|
|
725
|
+
// src/components/suggestedActions/index.tsx
|
|
726
|
+
var { useLocalizer: useLocalizer2, useStyleSet: useStyleSet2, useSuggestedActions: useSuggestedActions2 } = import_botframework_webchat_component2.hooks;
|
|
727
|
+
var styles6 = {
|
|
728
|
+
"webchat-fluent__suggested-actions": {
|
|
729
|
+
alignItems: "flex-end",
|
|
730
|
+
alignSelf: "flex-end",
|
|
731
|
+
display: "flex",
|
|
732
|
+
flexDirection: "column",
|
|
733
|
+
gap: "8px",
|
|
734
|
+
"&:not(:empty)": {
|
|
735
|
+
paddingBlockEnd: "8px",
|
|
736
|
+
paddingInlineStart: "4px"
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
};
|
|
740
|
+
function SuggestedActionStackedContainer(props) {
|
|
741
|
+
const [{ suggestedActions: suggestedActionsStyleSet }] = useStyleSet2();
|
|
742
|
+
const classNames = useStyles(styles6);
|
|
743
|
+
return /* @__PURE__ */ import_react15.default.createElement(
|
|
744
|
+
"div",
|
|
745
|
+
{
|
|
746
|
+
"aria-label": props["aria-label"],
|
|
747
|
+
"aria-live": "polite",
|
|
748
|
+
"aria-orientation": "vertical",
|
|
749
|
+
className: (0, import_classnames3.default)(classNames["webchat-fluent__suggested-actions"], suggestedActionsStyleSet + "", props.className),
|
|
750
|
+
role: "toolbar"
|
|
751
|
+
},
|
|
752
|
+
!!props.children && !!import_react15.default.Children.count(props.children) && props.children
|
|
753
|
+
);
|
|
754
|
+
}
|
|
755
|
+
function SuggestedActions() {
|
|
756
|
+
const classNames = useStyles(styles6);
|
|
757
|
+
const localize = useLocalizer2();
|
|
758
|
+
const [suggestedActions] = useSuggestedActions2();
|
|
759
|
+
const children = suggestedActions.map((cardAction, index) => {
|
|
760
|
+
const { displayText, image, imageAltText, text, type, value } = cardAction;
|
|
761
|
+
if (!suggestedActions?.length) {
|
|
762
|
+
return null;
|
|
763
|
+
}
|
|
764
|
+
return /* @__PURE__ */ import_react15.default.createElement(
|
|
765
|
+
SuggestedAction_default,
|
|
766
|
+
{
|
|
767
|
+
buttonText: computeSuggestedActionText(cardAction),
|
|
768
|
+
displayText,
|
|
769
|
+
image,
|
|
770
|
+
imageAlt: image && (imageAltText || text),
|
|
771
|
+
itemIndex: index,
|
|
772
|
+
key: index,
|
|
773
|
+
text,
|
|
774
|
+
type,
|
|
775
|
+
value
|
|
776
|
+
}
|
|
777
|
+
);
|
|
778
|
+
});
|
|
779
|
+
return /* @__PURE__ */ import_react15.default.createElement(
|
|
780
|
+
SuggestedActionStackedContainer,
|
|
781
|
+
{
|
|
782
|
+
"aria-label": localize("SUGGESTED_ACTIONS_LABEL_ALT"),
|
|
783
|
+
className: classNames["webchat-fluent__suggested-actions"]
|
|
784
|
+
},
|
|
785
|
+
children
|
|
786
|
+
);
|
|
787
|
+
}
|
|
788
|
+
var suggestedActions_default = (0, import_react15.memo)(SuggestedActions);
|
|
789
|
+
|
|
790
|
+
// src/components/SuggestedActions.tsx
|
|
791
|
+
var SuggestedActions_default = suggestedActions_default;
|
|
792
|
+
|
|
793
|
+
// src/components/sendbox/AddAttachmentButton.tsx
|
|
794
|
+
var import_botframework_webchat_api2 = require("botframework-webchat-api");
|
|
795
|
+
var import_react18 = __toESM(require("react"));
|
|
796
|
+
var import_use_ref_from4 = require("use-ref-from");
|
|
797
|
+
|
|
798
|
+
// src/icons/AttachmentIcon.tsx
|
|
799
|
+
var import_react16 = __toESM(require("react"));
|
|
800
|
+
function AttachmentIcon(props) {
|
|
801
|
+
return /* @__PURE__ */ import_react16.default.createElement(
|
|
802
|
+
"svg",
|
|
803
|
+
{
|
|
804
|
+
"aria-hidden": "true",
|
|
805
|
+
className: props.className,
|
|
806
|
+
fill: "currentColor",
|
|
807
|
+
height: "1em",
|
|
808
|
+
viewBox: "0 0 20 20",
|
|
809
|
+
width: "1em",
|
|
810
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
811
|
+
},
|
|
812
|
+
/* @__PURE__ */ import_react16.default.createElement(
|
|
813
|
+
"path",
|
|
814
|
+
{
|
|
815
|
+
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",
|
|
816
|
+
fill: "currentColor"
|
|
817
|
+
}
|
|
818
|
+
)
|
|
819
|
+
);
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
// src/components/sendbox/Toolbar.tsx
|
|
823
|
+
var import_classnames4 = __toESM(require("classnames"));
|
|
824
|
+
var import_react17 = __toESM(require("react"));
|
|
825
|
+
var styles7 = {
|
|
826
|
+
"webchat-fluent__sendbox__toolbar": {
|
|
827
|
+
display: "flex",
|
|
828
|
+
gap: "4px",
|
|
829
|
+
marginInlineStart: "auto"
|
|
830
|
+
},
|
|
831
|
+
"webchat-fluent__sendbox__toolbar-button": {
|
|
832
|
+
alignItems: "center",
|
|
833
|
+
appearance: "none",
|
|
834
|
+
aspectRatio: "1",
|
|
835
|
+
background: "transparent",
|
|
836
|
+
border: "none",
|
|
837
|
+
borderRadius: "var(--webchat-borderRadiusSmall)",
|
|
838
|
+
cursor: "pointer",
|
|
839
|
+
display: "flex",
|
|
840
|
+
justifyContent: "center",
|
|
841
|
+
padding: "3px",
|
|
842
|
+
width: "32px",
|
|
843
|
+
"> svg": {
|
|
844
|
+
fontSize: "20px",
|
|
845
|
+
pointerEvents: "none"
|
|
846
|
+
},
|
|
847
|
+
"@media (hover: hover)": {
|
|
848
|
+
'&:not([aria-disabled="true"]):hover': {
|
|
849
|
+
backgroundColor: "var(--webchat-colorSubtleBackgroundHover)",
|
|
850
|
+
color: "var(--webchat-colorCompoundBrandForeground1Hover)"
|
|
851
|
+
}
|
|
852
|
+
},
|
|
853
|
+
'&:not([aria-disabled="true"]):active': {
|
|
854
|
+
backgroundColor: "var(--webchat-colorSubtleBackgroundPressed)",
|
|
855
|
+
color: "var(--webchat-colorCompoundBrandForeground1Pressed)"
|
|
856
|
+
},
|
|
857
|
+
'&[aria-disabled="true"]': {
|
|
858
|
+
color: " var(--webchat-colorNeutralForegroundDisabled)",
|
|
859
|
+
cursor: "not-allowed"
|
|
860
|
+
}
|
|
861
|
+
},
|
|
862
|
+
"webchat-fluent__sendbox__toolbar-separator": {
|
|
863
|
+
alignSelf: "center",
|
|
864
|
+
borderInlineEnd: "1px solid var(--webchat-colorNeutralStroke2)",
|
|
865
|
+
height: "28px",
|
|
866
|
+
"&:first-child, &:last-child, &:only-child": {
|
|
867
|
+
display: "none"
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
};
|
|
871
|
+
var preventDefaultHandler2 = (event) => event.preventDefault();
|
|
872
|
+
var ToolbarButton = (0, import_react17.memo)(
|
|
873
|
+
(props) => {
|
|
874
|
+
const classNames = useStyles(styles7);
|
|
875
|
+
return /* @__PURE__ */ import_react17.default.createElement(
|
|
876
|
+
"button",
|
|
877
|
+
{
|
|
878
|
+
"aria-label": props["aria-label"],
|
|
879
|
+
className: (0, import_classnames4.default)(classNames["webchat-fluent__sendbox__toolbar-button"], props.className),
|
|
880
|
+
"data-testid": props["data-testid"],
|
|
881
|
+
onClick: props.disabled ? preventDefaultHandler2 : props.onClick,
|
|
882
|
+
type: props.type === "submit" ? "submit" : "button",
|
|
883
|
+
...props.disabled && {
|
|
884
|
+
"aria-disabled": "true",
|
|
885
|
+
tabIndex: -1
|
|
886
|
+
}
|
|
887
|
+
},
|
|
888
|
+
props.children
|
|
889
|
+
);
|
|
890
|
+
}
|
|
891
|
+
);
|
|
892
|
+
ToolbarButton.displayName = "ToolbarButton";
|
|
893
|
+
var Toolbar = (0, import_react17.memo)((props) => {
|
|
894
|
+
const classNames = useStyles(styles7);
|
|
895
|
+
return /* @__PURE__ */ import_react17.default.createElement("div", { className: (0, import_classnames4.default)(classNames["webchat-fluent__sendbox__toolbar"], props.className) }, props.children);
|
|
896
|
+
});
|
|
897
|
+
Toolbar.displayName = "Toolbar";
|
|
898
|
+
var ToolbarSeparator = (0, import_react17.memo)(
|
|
899
|
+
(props) => {
|
|
900
|
+
const classNames = useStyles(styles7);
|
|
901
|
+
return /* @__PURE__ */ import_react17.default.createElement(
|
|
902
|
+
"div",
|
|
903
|
+
{
|
|
904
|
+
"aria-orientation": "vertical",
|
|
905
|
+
className: (0, import_classnames4.default)(classNames["webchat-fluent__sendbox__toolbar-separator"], props.className),
|
|
906
|
+
role: "separator"
|
|
907
|
+
}
|
|
908
|
+
);
|
|
909
|
+
}
|
|
910
|
+
);
|
|
911
|
+
ToolbarSeparator.displayName = "ToolbarSeparator";
|
|
912
|
+
|
|
913
|
+
// src/components/sendbox/AddAttachmentButton.tsx
|
|
914
|
+
var { useLocalizer: useLocalizer3, useStyleOptions } = import_botframework_webchat_api2.hooks;
|
|
915
|
+
var styles8 = {
|
|
916
|
+
"webchat-fluent__sendbox__add-attachment": {
|
|
917
|
+
display: "grid"
|
|
918
|
+
},
|
|
919
|
+
"webchat-fluent__sendbox__add-attachment-input": {
|
|
920
|
+
fontSize: 0,
|
|
921
|
+
height: 0,
|
|
922
|
+
opacity: 0,
|
|
923
|
+
width: 0
|
|
924
|
+
}
|
|
925
|
+
};
|
|
926
|
+
function AddAttachmentButton(props) {
|
|
927
|
+
const inputRef = (0, import_react18.useRef)(null);
|
|
928
|
+
const classNames = useStyles(styles8);
|
|
929
|
+
const localize = useLocalizer3();
|
|
930
|
+
const [{ uploadAccept, uploadMultiple }] = useStyleOptions();
|
|
931
|
+
const onFilesAddedRef = (0, import_use_ref_from4.useRefFrom)(props.onFilesAdded);
|
|
932
|
+
const handleClick = (0, import_react18.useCallback)(() => inputRef.current?.click(), [inputRef]);
|
|
933
|
+
const handleFileChange = (0, import_react18.useCallback)(
|
|
934
|
+
({ target: { files } }) => {
|
|
935
|
+
if (files) {
|
|
936
|
+
onFilesAddedRef.current?.([...files]);
|
|
937
|
+
if (inputRef.current) {
|
|
938
|
+
inputRef.current.value = "";
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
},
|
|
942
|
+
[inputRef, onFilesAddedRef]
|
|
943
|
+
);
|
|
944
|
+
return /* @__PURE__ */ import_react18.default.createElement("div", { className: classNames["webchat-fluent__sendbox__add-attachment"] }, /* @__PURE__ */ import_react18.default.createElement(
|
|
945
|
+
"input",
|
|
946
|
+
{
|
|
947
|
+
accept: uploadAccept,
|
|
948
|
+
"aria-disabled": props.disabled,
|
|
949
|
+
"aria-hidden": "true",
|
|
950
|
+
className: classNames["webchat-fluent__sendbox__add-attachment-input"],
|
|
951
|
+
multiple: uploadMultiple,
|
|
952
|
+
onInput: props.disabled ? void 0 : handleFileChange,
|
|
953
|
+
readOnly: props.disabled,
|
|
954
|
+
ref: inputRef,
|
|
955
|
+
role: "button",
|
|
956
|
+
tabIndex: -1,
|
|
957
|
+
type: "file"
|
|
958
|
+
}
|
|
959
|
+
), /* @__PURE__ */ import_react18.default.createElement(
|
|
960
|
+
ToolbarButton,
|
|
961
|
+
{
|
|
962
|
+
"aria-label": localize("TEXT_INPUT_UPLOAD_BUTTON_ALT"),
|
|
963
|
+
"data-testid": testIds_default.sendBoxUploadButton,
|
|
964
|
+
onClick: handleClick
|
|
965
|
+
},
|
|
966
|
+
/* @__PURE__ */ import_react18.default.createElement(AttachmentIcon, null)
|
|
967
|
+
));
|
|
968
|
+
}
|
|
969
|
+
var AddAttachmentButton_default = (0, import_react18.memo)(AddAttachmentButton);
|
|
970
|
+
|
|
971
|
+
// src/components/sendbox/Attachments.tsx
|
|
972
|
+
var import_botframework_webchat_api3 = require("botframework-webchat-api");
|
|
973
|
+
var import_react19 = __toESM(require("react"));
|
|
974
|
+
var { useLocalizer: useLocalizer4 } = import_botframework_webchat_api3.hooks;
|
|
975
|
+
var styles9 = {
|
|
976
|
+
"webchat-fluent__sendbox__attachment": {
|
|
977
|
+
border: "1px solid var(--webchat-colorNeutralStroke1)",
|
|
978
|
+
borderRadius: "var(--webchat-borderRadiusLarge)",
|
|
979
|
+
cursor: "default",
|
|
980
|
+
padding: "6px 8px",
|
|
981
|
+
width: "fit-content"
|
|
982
|
+
}
|
|
983
|
+
};
|
|
984
|
+
var attachmentsPluralStringIds = {
|
|
985
|
+
one: "TEXT_INPUT_ATTACHMENTS_ONE",
|
|
986
|
+
two: "TEXT_INPUT_ATTACHMENTS_TWO",
|
|
987
|
+
few: "TEXT_INPUT_ATTACHMENTS_FEW",
|
|
988
|
+
many: "TEXT_INPUT_ATTACHMENTS_MANY",
|
|
989
|
+
other: "TEXT_INPUT_ATTACHMENTS_OTHER"
|
|
990
|
+
};
|
|
991
|
+
function Attachments({
|
|
992
|
+
attachments
|
|
993
|
+
}) {
|
|
994
|
+
const classNames = useStyles(styles9);
|
|
995
|
+
const localizeWithPlural = useLocalizer4({ plural: true });
|
|
996
|
+
return attachments.length ? /* @__PURE__ */ import_react19.default.createElement("div", { className: classNames["webchat-fluent__sendbox__attachment"] }, localizeWithPlural(attachmentsPluralStringIds, attachments.length)) : null;
|
|
997
|
+
}
|
|
998
|
+
var Attachments_default = (0, import_react19.memo)(Attachments);
|
|
999
|
+
|
|
1000
|
+
// src/components/sendbox/ErrorMessage.tsx
|
|
1001
|
+
var import_react20 = __toESM(require("react"));
|
|
1002
|
+
var styles10 = {
|
|
1003
|
+
"webchat-fluent___sendbox__error-message": {
|
|
1004
|
+
fontSize: 0,
|
|
1005
|
+
height: 0,
|
|
1006
|
+
width: 0,
|
|
1007
|
+
position: "absolute",
|
|
1008
|
+
top: 0,
|
|
1009
|
+
left: 0,
|
|
1010
|
+
color: "transparent"
|
|
1011
|
+
}
|
|
1012
|
+
};
|
|
1013
|
+
function ErrorMessage(props) {
|
|
1014
|
+
const classNames = useStyles(styles10);
|
|
1015
|
+
return (
|
|
1016
|
+
// eslint-disable-next-line react/forbid-dom-props
|
|
1017
|
+
/* @__PURE__ */ import_react20.default.createElement("span", { className: classNames["webchat-fluent___sendbox__error-message"], id: props.id, role: "alert" }, props.error)
|
|
1018
|
+
);
|
|
1019
|
+
}
|
|
1020
|
+
var ErrorMessage_default = (0, import_react20.memo)(ErrorMessage);
|
|
1021
|
+
|
|
1022
|
+
// src/components/sendbox/TelephoneKeypadToolbarButton.tsx
|
|
1023
|
+
var import_react22 = __toESM(require("react"));
|
|
1024
|
+
var import_botframework_webchat_api4 = require("botframework-webchat-api");
|
|
1025
|
+
|
|
1026
|
+
// src/icons/TelephoneKeypad.tsx
|
|
1027
|
+
var import_react21 = __toESM(require("react"));
|
|
1028
|
+
function TelephoneKeypadIcon(props) {
|
|
1029
|
+
return /* @__PURE__ */ import_react21.default.createElement(
|
|
1030
|
+
"svg",
|
|
1031
|
+
{
|
|
1032
|
+
"aria-hidden": "true",
|
|
1033
|
+
className: props.className,
|
|
1034
|
+
fill: "currentColor",
|
|
1035
|
+
height: "1em",
|
|
1036
|
+
viewBox: "0 0 20 20",
|
|
1037
|
+
width: "1em",
|
|
1038
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
1039
|
+
},
|
|
1040
|
+
/* @__PURE__ */ import_react21.default.createElement(
|
|
1041
|
+
"path",
|
|
1042
|
+
{
|
|
1043
|
+
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",
|
|
1044
|
+
fill: "currentColor"
|
|
1045
|
+
}
|
|
1046
|
+
)
|
|
1047
|
+
);
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1050
|
+
// src/components/sendbox/TelephoneKeypadToolbarButton.tsx
|
|
1051
|
+
var { useLocalizer: useLocalizer5 } = import_botframework_webchat_api4.hooks;
|
|
1052
|
+
var TelephoneKeypadToolbarButton = (0, import_react22.memo)(() => {
|
|
1053
|
+
const [, setTelephoneKeypadShown] = useShown();
|
|
1054
|
+
const localize = useLocalizer5();
|
|
1055
|
+
const handleClick = (0, import_react22.useCallback)(() => setTelephoneKeypadShown((shown) => !shown), [setTelephoneKeypadShown]);
|
|
1056
|
+
return /* @__PURE__ */ import_react22.default.createElement(
|
|
1057
|
+
ToolbarButton,
|
|
1058
|
+
{
|
|
1059
|
+
"aria-label": localize("TEXT_INPUT_TELEPHONE_KEYPAD_BUTTON_ALT"),
|
|
1060
|
+
"data-testid": testIds_default.sendBoxTelephoneKeypadToolbarButton,
|
|
1061
|
+
onClick: handleClick
|
|
1062
|
+
},
|
|
1063
|
+
/* @__PURE__ */ import_react22.default.createElement(TelephoneKeypadIcon, null)
|
|
1064
|
+
);
|
|
1065
|
+
});
|
|
1066
|
+
TelephoneKeypadToolbarButton.displayName = "SendBox.TelephoneKeypadToolbarButton";
|
|
1067
|
+
var TelephoneKeypadToolbarButton_default = TelephoneKeypadToolbarButton;
|
|
1068
|
+
|
|
1069
|
+
// src/components/sendbox/TextArea.tsx
|
|
1070
|
+
var import_classnames5 = __toESM(require("classnames"));
|
|
1071
|
+
var import_react23 = __toESM(require("react"));
|
|
1072
|
+
var styles11 = {
|
|
1073
|
+
"webchat-fluent__sendbox__text-area": {
|
|
1074
|
+
display: "grid",
|
|
1075
|
+
gridTemplateAreas: `'main'`,
|
|
1076
|
+
maxHeight: "200px",
|
|
1077
|
+
overflow: "hidden"
|
|
1078
|
+
},
|
|
1079
|
+
"webchat-fluent__sendbox__text-area--hidden": {
|
|
1080
|
+
// TODO: Not perfect way of hiding the text box.
|
|
1081
|
+
height: 0,
|
|
1082
|
+
visibility: "collapse"
|
|
1083
|
+
},
|
|
1084
|
+
"webchat-fluent__sendbox__text-area-shared": {
|
|
1085
|
+
border: "none",
|
|
1086
|
+
font: "inherit",
|
|
1087
|
+
gridArea: "main",
|
|
1088
|
+
outline: "inherit",
|
|
1089
|
+
overflowWrap: "anywhere",
|
|
1090
|
+
resize: "inherit",
|
|
1091
|
+
scrollbarGutter: "stable"
|
|
1092
|
+
},
|
|
1093
|
+
"webchat-fluent__sendbox__text-area-doppelganger": {
|
|
1094
|
+
overflow: "hidden",
|
|
1095
|
+
visibility: "hidden",
|
|
1096
|
+
whiteSpace: "pre-wrap"
|
|
1097
|
+
},
|
|
1098
|
+
"webchat-fluent__sendbox__text-area-input": {
|
|
1099
|
+
height: "100%",
|
|
1100
|
+
padding: 0
|
|
1101
|
+
},
|
|
1102
|
+
"webchat-fluent__sendbox__text-area-input--scroll": {
|
|
1103
|
+
/* Firefox */
|
|
1104
|
+
MozScrollbarColor: "var(--webchat-colorNeutralBackground5) var(--webchat-colorNeutralForeground2)",
|
|
1105
|
+
MozScrollbarWidth: "thin",
|
|
1106
|
+
/* Chrome, Edge, and Safari */
|
|
1107
|
+
"&::-webkit-scrollbar": {
|
|
1108
|
+
width: "8px"
|
|
1109
|
+
},
|
|
1110
|
+
"&::-webkit-scrollbar-track": {
|
|
1111
|
+
backgroundColor: " var(--webchat-colorNeutralBackground5)",
|
|
1112
|
+
borderRadius: "16px"
|
|
1113
|
+
},
|
|
1114
|
+
"&::-webkit-scrollbar-thumb": {
|
|
1115
|
+
backgroundColor: "var(--webchat-colorNeutralForeground2)",
|
|
1116
|
+
borderRadius: "16px"
|
|
1117
|
+
},
|
|
1118
|
+
"&::-webkit-scrollbar-corner": {
|
|
1119
|
+
backgroundColor: "var(--webchat-colorNeutralBackground5)"
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
};
|
|
1123
|
+
var TextArea = (0, import_react23.forwardRef)((props, ref) => {
|
|
1124
|
+
const classNames = useStyles(styles11);
|
|
1125
|
+
const handleKeyDown = (0, import_react23.useCallback)((event) => {
|
|
1126
|
+
if (!event.shiftKey && event.key === "Enter") {
|
|
1127
|
+
event.preventDefault();
|
|
1128
|
+
if ("form" in event.target && event.target.form instanceof HTMLFormElement) {
|
|
1129
|
+
event.target?.form?.requestSubmit();
|
|
1130
|
+
}
|
|
1131
|
+
}
|
|
1132
|
+
}, []);
|
|
1133
|
+
return /* @__PURE__ */ import_react23.default.createElement(
|
|
1134
|
+
"div",
|
|
1135
|
+
{
|
|
1136
|
+
className: (0, import_classnames5.default)(
|
|
1137
|
+
classNames["webchat-fluent__sendbox__text-area"],
|
|
1138
|
+
{
|
|
1139
|
+
[classNames["webchat-fluent__sendbox__text-area--hidden"]]: props.hidden
|
|
1140
|
+
},
|
|
1141
|
+
props.className
|
|
1142
|
+
),
|
|
1143
|
+
role: props.hidden ? "hidden" : void 0
|
|
1144
|
+
},
|
|
1145
|
+
/* @__PURE__ */ import_react23.default.createElement(
|
|
1146
|
+
"div",
|
|
1147
|
+
{
|
|
1148
|
+
className: (0, import_classnames5.default)(
|
|
1149
|
+
classNames["webchat-fluent__sendbox__text-area-doppelganger"],
|
|
1150
|
+
classNames["webchat-fluent__sendbox__text-area-shared"],
|
|
1151
|
+
classNames["webchat-fluent__sendbox__text-area-input--scroll"]
|
|
1152
|
+
)
|
|
1153
|
+
},
|
|
1154
|
+
props.value || props.placeholder,
|
|
1155
|
+
" "
|
|
1156
|
+
),
|
|
1157
|
+
/* @__PURE__ */ import_react23.default.createElement(
|
|
1158
|
+
"textarea",
|
|
1159
|
+
{
|
|
1160
|
+
"aria-label": props["aria-label"],
|
|
1161
|
+
className: (0, import_classnames5.default)(
|
|
1162
|
+
classNames["webchat-fluent__sendbox__text-area-input"],
|
|
1163
|
+
classNames["webchat-fluent__sendbox__text-area-shared"],
|
|
1164
|
+
classNames["webchat-fluent__sendbox__text-area-input--scroll"]
|
|
1165
|
+
),
|
|
1166
|
+
"data-testid": props["data-testid"],
|
|
1167
|
+
onInput: props.onInput,
|
|
1168
|
+
onKeyDown: handleKeyDown,
|
|
1169
|
+
placeholder: props.placeholder,
|
|
1170
|
+
ref,
|
|
1171
|
+
rows: props.startRows ?? 1,
|
|
1172
|
+
tabIndex: props.hidden ? -1 : void 0,
|
|
1173
|
+
value: props.value
|
|
1174
|
+
}
|
|
1175
|
+
)
|
|
1176
|
+
);
|
|
1177
|
+
});
|
|
1178
|
+
TextArea.displayName = "TextArea";
|
|
1179
|
+
var TextArea_default = TextArea;
|
|
1180
|
+
|
|
1181
|
+
// src/components/sendbox/private/useSubmitError.ts
|
|
1182
|
+
var import_botframework_webchat_component3 = require("botframework-webchat-component");
|
|
1183
|
+
var import_react24 = require("react");
|
|
1184
|
+
var import_use_ref_from5 = require("use-ref-from");
|
|
1185
|
+
var { useConnectivityStatus, useLocalizer: useLocalizer6 } = import_botframework_webchat_component3.hooks;
|
|
1186
|
+
var useSubmitError = ({
|
|
1187
|
+
attachments,
|
|
1188
|
+
message
|
|
1189
|
+
}) => {
|
|
1190
|
+
const [connectivityStatus] = useConnectivityStatus();
|
|
1191
|
+
const localize = useLocalizer6();
|
|
1192
|
+
const submitErrorRef = (0, import_use_ref_from5.useRefFrom)(
|
|
1193
|
+
connectivityStatus !== "connected" && connectivityStatus !== "reconnected" ? "offline" : !message && !attachments.length ? "empty" : void 0
|
|
1194
|
+
);
|
|
1195
|
+
const errorMessageStringMap = (0, import_react24.useMemo)(
|
|
1196
|
+
() => Object.freeze(
|
|
1197
|
+
(/* @__PURE__ */ new Map()).set("empty", localize("SEND_BOX_IS_EMPTY_TOOLTIP_ALT")).set("offline", localize("CONNECTIVITY_STATUS_ALT_FATAL"))
|
|
1198
|
+
),
|
|
1199
|
+
[localize]
|
|
1200
|
+
);
|
|
1201
|
+
return (0, import_react24.useMemo)(
|
|
1202
|
+
() => Object.freeze([submitErrorRef, submitErrorRef.current && errorMessageStringMap.get(submitErrorRef.current)]),
|
|
1203
|
+
[errorMessageStringMap, submitErrorRef]
|
|
1204
|
+
);
|
|
1205
|
+
};
|
|
1206
|
+
var useSubmitError_default = useSubmitError;
|
|
1207
|
+
|
|
1208
|
+
// src/components/sendbox/private/useUniqueId.ts
|
|
1209
|
+
var import_react25 = require("react");
|
|
1210
|
+
function useUniqueId(prefix) {
|
|
1211
|
+
const id = (0, import_react25.useMemo)(() => Math.random().toString(36).substr(2, 5), []);
|
|
1212
|
+
prefix = prefix ? `${prefix}--` : "";
|
|
1213
|
+
return `${prefix}${id}`;
|
|
1214
|
+
}
|
|
1215
|
+
|
|
1216
|
+
// src/components/sendbox/index.tsx
|
|
1217
|
+
var { useStyleOptions: useStyleOptions2, useMakeThumbnail, useLocalizer: useLocalizer7, useSendBoxAttachments, useSendMessage } = import_botframework_webchat_component4.hooks;
|
|
1218
|
+
var styles12 = {
|
|
1219
|
+
"webchat-fluent__sendbox": {
|
|
1220
|
+
color: "var(--webchat-colorNeutralForeground1)",
|
|
1221
|
+
fontFamily: "var(--webchat-fontFamilyBase)",
|
|
1222
|
+
padding: "0 10px 10px",
|
|
1223
|
+
textRendering: "optimizeLegibility"
|
|
1224
|
+
},
|
|
1225
|
+
"webchat-fluent__sendbox__sendbox": {
|
|
1226
|
+
backgroundColor: "var(--webchat-colorNeutralBackground1)",
|
|
1227
|
+
border: "1px solid var(--webchat-colorNeutralStroke1)",
|
|
1228
|
+
borderRadius: "var(--webchat-borderRadiusLarge)",
|
|
1229
|
+
display: "grid",
|
|
1230
|
+
fontFamily: "var(--webchat-fontFamilyBase)",
|
|
1231
|
+
fontSize: "14px",
|
|
1232
|
+
gap: "6px",
|
|
1233
|
+
lineHeight: "20px",
|
|
1234
|
+
padding: "8px",
|
|
1235
|
+
position: "relative",
|
|
1236
|
+
"&:focus-within": {
|
|
1237
|
+
borderColor: "var(--webchat-colorNeutralStroke1Selected)",
|
|
1238
|
+
// TODO clarify with design the color:
|
|
1239
|
+
// - Teams is using colorCompoundBrandForeground1
|
|
1240
|
+
// - Fluent is using colorCompoundBrandStroke
|
|
1241
|
+
// - we are using colorCompoundBrandForeground1Hover
|
|
1242
|
+
boxShadow: "inset 0 -6px 0 -3px var(--webchat-colorCompoundBrandForeground1Hover)"
|
|
1243
|
+
}
|
|
1244
|
+
},
|
|
1245
|
+
"webchat-fluent__sendbox__sendbox-text": {
|
|
1246
|
+
backgroundColor: "transparent",
|
|
1247
|
+
border: "none",
|
|
1248
|
+
flex: "auto",
|
|
1249
|
+
fontFamily: "var(--webchat-fontFamilyBase)",
|
|
1250
|
+
fontSize: "14px",
|
|
1251
|
+
lineHeight: "20px",
|
|
1252
|
+
outline: "none",
|
|
1253
|
+
padding: "4px 4px 0",
|
|
1254
|
+
resize: "none"
|
|
1255
|
+
},
|
|
1256
|
+
"webchat-fluent__sendbox__sendbox-controls": {
|
|
1257
|
+
alignItems: "center",
|
|
1258
|
+
display: "flex",
|
|
1259
|
+
paddingInlineStart: "4px"
|
|
1260
|
+
},
|
|
1261
|
+
"webchat-fluent__sendbox__text-counter": {
|
|
1262
|
+
color: "var(--webchat-colorNeutralForeground4)",
|
|
1263
|
+
cursor: "default",
|
|
1264
|
+
fontFamily: "var(--webchat-fontFamilyNumeric)",
|
|
1265
|
+
fontSize: "10px",
|
|
1266
|
+
lineHeight: "14px"
|
|
1267
|
+
},
|
|
1268
|
+
"webchat-fluent__sendbox__text-counter--error": {
|
|
1269
|
+
color: "var(--webchat-colorStatusDangerForeground1)"
|
|
1270
|
+
}
|
|
1271
|
+
};
|
|
1272
|
+
function SendBox(props) {
|
|
1273
|
+
const inputRef = (0, import_react26.useRef)(null);
|
|
1274
|
+
const [message, setMessage] = (0, import_react26.useState)("");
|
|
1275
|
+
const [attachments, setAttachments] = useSendBoxAttachments();
|
|
1276
|
+
const [{ maxMessageLength }] = useStyleOptions2();
|
|
1277
|
+
const isMessageLengthExceeded = !!maxMessageLength && message.length > maxMessageLength;
|
|
1278
|
+
const classNames = useStyles(styles12);
|
|
1279
|
+
const localize = useLocalizer7();
|
|
1280
|
+
const sendMessage = useSendMessage();
|
|
1281
|
+
const makeThumbnail = useMakeThumbnail();
|
|
1282
|
+
const errorMessageId = useUniqueId("webchat-fluent__sendbox__error-message-id");
|
|
1283
|
+
const [errorRef, errorMessage] = useSubmitError_default({ message, attachments });
|
|
1284
|
+
const [telephoneKeypadShown, setTelephoneKeypadShown] = useShown();
|
|
1285
|
+
const attachmentsRef = (0, import_use_ref_from6.useRefFrom)(attachments);
|
|
1286
|
+
const messageRef = (0, import_use_ref_from6.useRefFrom)(message);
|
|
1287
|
+
const handleSendBoxClick = (0, import_react26.useCallback)(
|
|
1288
|
+
(event) => {
|
|
1289
|
+
if ("tabIndex" in event.target && typeof event.target.tabIndex === "number" && event.target.tabIndex >= 0) {
|
|
1290
|
+
return;
|
|
1291
|
+
}
|
|
1292
|
+
inputRef.current?.focus();
|
|
1293
|
+
},
|
|
1294
|
+
[inputRef]
|
|
1295
|
+
);
|
|
1296
|
+
const handleMessageChange = (0, import_react26.useCallback)(
|
|
1297
|
+
(event) => setMessage(event.currentTarget.value),
|
|
1298
|
+
[setMessage]
|
|
1299
|
+
);
|
|
1300
|
+
const handleAddFiles = (0, import_react26.useCallback)(
|
|
1301
|
+
async (inputFiles) => {
|
|
1302
|
+
const newAttachments = Object.freeze(
|
|
1303
|
+
await Promise.all(
|
|
1304
|
+
inputFiles.map(
|
|
1305
|
+
(file) => makeThumbnail(file).then(
|
|
1306
|
+
(thumbnailURL) => Object.freeze({
|
|
1307
|
+
blob: file,
|
|
1308
|
+
...thumbnailURL && { thumbnailURL }
|
|
1309
|
+
})
|
|
1310
|
+
)
|
|
1311
|
+
)
|
|
1312
|
+
)
|
|
1313
|
+
);
|
|
1314
|
+
setAttachments(newAttachments);
|
|
1315
|
+
},
|
|
1316
|
+
[makeThumbnail, setAttachments]
|
|
1317
|
+
);
|
|
1318
|
+
const handleFormSubmit = (0, import_react26.useCallback)(
|
|
1319
|
+
(event) => {
|
|
1320
|
+
event.preventDefault();
|
|
1321
|
+
if (errorRef.current !== "empty" && !isMessageLengthExceeded) {
|
|
1322
|
+
sendMessage(messageRef.current, void 0, { attachments: attachmentsRef.current });
|
|
1323
|
+
setMessage("");
|
|
1324
|
+
setAttachments([]);
|
|
1325
|
+
}
|
|
1326
|
+
inputRef.current?.focus();
|
|
1327
|
+
},
|
|
1328
|
+
[attachmentsRef, messageRef, sendMessage, setAttachments, setMessage, isMessageLengthExceeded, errorRef, inputRef]
|
|
1329
|
+
);
|
|
1330
|
+
const handleTelephoneKeypadButtonClick = (0, import_react26.useCallback)(
|
|
1331
|
+
(dtmf) => {
|
|
1332
|
+
sendMessage(`/DTMF ${dtmf}`);
|
|
1333
|
+
setTelephoneKeypadShown(false);
|
|
1334
|
+
},
|
|
1335
|
+
[sendMessage, setTelephoneKeypadShown]
|
|
1336
|
+
);
|
|
1337
|
+
const aria = {
|
|
1338
|
+
"aria-invalid": "false",
|
|
1339
|
+
...errorMessage && {
|
|
1340
|
+
"aria-invalid": "true",
|
|
1341
|
+
"aria-errormessage": errorMessageId
|
|
1342
|
+
}
|
|
1343
|
+
};
|
|
1344
|
+
return /* @__PURE__ */ import_react26.default.createElement("form", { ...aria, className: (0, import_classnames6.default)(classNames["webchat-fluent__sendbox"], props.className), onSubmit: handleFormSubmit }, /* @__PURE__ */ import_react26.default.createElement(SuggestedActions_default, null), /* @__PURE__ */ import_react26.default.createElement("div", { className: (0, import_classnames6.default)(classNames["webchat-fluent__sendbox__sendbox"]), onClickCapture: handleSendBoxClick }, /* @__PURE__ */ import_react26.default.createElement(
|
|
1345
|
+
Surrogate_default,
|
|
1346
|
+
{
|
|
1347
|
+
autoFocus: true,
|
|
1348
|
+
isHorizontal: false,
|
|
1349
|
+
onButtonClick: handleTelephoneKeypadButtonClick
|
|
1350
|
+
}
|
|
1351
|
+
), /* @__PURE__ */ import_react26.default.createElement(
|
|
1352
|
+
TextArea_default,
|
|
1353
|
+
{
|
|
1354
|
+
"aria-label": isMessageLengthExceeded ? localize("TEXT_INPUT_LENGTH_EXCEEDED_ALT") : localize("TEXT_INPUT_ALT"),
|
|
1355
|
+
className: classNames["webchat-fluent__sendbox__sendbox-text"],
|
|
1356
|
+
"data-testid": testIds_default.sendBoxTextBox,
|
|
1357
|
+
hidden: telephoneKeypadShown,
|
|
1358
|
+
onInput: handleMessageChange,
|
|
1359
|
+
placeholder: props.placeholder ?? localize("TEXT_INPUT_PLACEHOLDER"),
|
|
1360
|
+
ref: inputRef,
|
|
1361
|
+
value: message
|
|
1362
|
+
}
|
|
1363
|
+
), /* @__PURE__ */ import_react26.default.createElement(Attachments_default, { attachments }), /* @__PURE__ */ import_react26.default.createElement("div", { className: (0, import_classnames6.default)(classNames["webchat-fluent__sendbox__sendbox-controls"]) }, maxMessageLength && /* @__PURE__ */ import_react26.default.createElement(
|
|
1364
|
+
"div",
|
|
1365
|
+
{
|
|
1366
|
+
className: (0, import_classnames6.default)(classNames["webchat-fluent__sendbox__text-counter"], {
|
|
1367
|
+
[classNames["webchat-fluent__sendbox__text-counter--error"]]: isMessageLengthExceeded
|
|
1368
|
+
})
|
|
1369
|
+
},
|
|
1370
|
+
`${message.length}/${maxMessageLength}`
|
|
1371
|
+
), /* @__PURE__ */ import_react26.default.createElement(Toolbar, null, /* @__PURE__ */ import_react26.default.createElement(TelephoneKeypadToolbarButton_default, null), /* @__PURE__ */ import_react26.default.createElement(AddAttachmentButton_default, { onFilesAdded: handleAddFiles }), /* @__PURE__ */ import_react26.default.createElement(ToolbarSeparator, null), /* @__PURE__ */ import_react26.default.createElement(
|
|
1372
|
+
ToolbarButton,
|
|
1373
|
+
{
|
|
1374
|
+
"aria-label": localize("TEXT_INPUT_SEND_BUTTON_ALT"),
|
|
1375
|
+
"data-testid": testIds_default.sendBoxSendButton,
|
|
1376
|
+
disabled: isMessageLengthExceeded,
|
|
1377
|
+
type: "submit"
|
|
1378
|
+
},
|
|
1379
|
+
/* @__PURE__ */ import_react26.default.createElement(SendIcon, null)
|
|
1380
|
+
))), /* @__PURE__ */ import_react26.default.createElement(DropZone_default, { onFilesAdded: handleAddFiles }), /* @__PURE__ */ import_react26.default.createElement(ErrorMessage_default, { error: errorMessage, id: errorMessageId })));
|
|
1381
|
+
}
|
|
1382
|
+
var sendbox_default = (0, import_react26.memo)(SendBox);
|
|
48
1383
|
|
|
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);
|
|
1384
|
+
// src/components/SendBox.tsx
|
|
1385
|
+
var SendBox_default = sendbox_default;
|
|
53
1386
|
|
|
54
1387
|
// src/private/FluentThemeProvider.tsx
|
|
55
|
-
var
|
|
1388
|
+
var { ThemeProvider } = import_botframework_webchat_component5.Components;
|
|
56
1389
|
var sendBoxMiddleware = [() => () => () => SendBox_default];
|
|
57
|
-
var FluentThemeProvider = ({ children }) => /* @__PURE__ */
|
|
58
|
-
var FluentThemeProvider_default = (0,
|
|
1390
|
+
var FluentThemeProvider = ({ children }) => /* @__PURE__ */ import_react27.default.createElement(WebchatTheme, null, /* @__PURE__ */ import_react27.default.createElement(Provider_default, null, /* @__PURE__ */ import_react27.default.createElement(ThemeProvider, { sendBoxMiddleware }, children)));
|
|
1391
|
+
var FluentThemeProvider_default = (0, import_react27.memo)(FluentThemeProvider);
|
|
59
1392
|
|
|
60
1393
|
// src/index.ts
|
|
61
|
-
(0, import_inject_meta_tag.injectMetaTag)("botframework-webchat-fluent-theme:version", "4.17.0-main.20240411.
|
|
1394
|
+
(0, import_inject_meta_tag.injectMetaTag)("botframework-webchat-fluent-theme:version", "4.17.0-main.20240411.ff34969");
|
|
62
1395
|
// Annotate the CommonJS export names for ESM import in node:
|
|
63
1396
|
0 && (module.exports = {
|
|
64
|
-
FluentThemeProvider
|
|
1397
|
+
FluentThemeProvider,
|
|
1398
|
+
testIds
|
|
65
1399
|
});
|
|
66
1400
|
//# sourceMappingURL=index.js.map
|