@chatterfly/widget 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/embed.css +1 -1
- package/dist/embed.css.map +1 -1
- package/dist/embed.global.js +12 -12
- package/dist/embed.global.js.map +1 -1
- package/dist/index.css +25 -0
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +22 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +22 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +60 -61
package/dist/index.mjs
CHANGED
|
@@ -490,6 +490,7 @@ var widget_default = {
|
|
|
490
490
|
converseHint: "widget_converseHint",
|
|
491
491
|
converseHintDot: "widget_converseHintDot",
|
|
492
492
|
"cf-converse-pulse": "widget_cf-converse-pulse",
|
|
493
|
+
converseDoneButton: "widget_converseDoneButton",
|
|
493
494
|
newMessageChip: "widget_newMessageChip",
|
|
494
495
|
activeInputRow: "widget_activeInputRow",
|
|
495
496
|
activeInputField: "widget_activeInputField",
|
|
@@ -2684,7 +2685,8 @@ var defaultStrings = {
|
|
|
2684
2685
|
somethingWentWrong: "Something went wrong",
|
|
2685
2686
|
chatInputPlaceholder: "Type a message\u2026",
|
|
2686
2687
|
sendButton: "Send",
|
|
2687
|
-
handBackButton: "Hand Back"
|
|
2688
|
+
handBackButton: "Hand Back",
|
|
2689
|
+
converseDoneButton: "I'm done"
|
|
2688
2690
|
};
|
|
2689
2691
|
function resolveStrings(overrides) {
|
|
2690
2692
|
return overrides ? { ...defaultStrings, ...overrides } : defaultStrings;
|
|
@@ -5834,7 +5836,7 @@ var ChatAdapter = forwardRef(
|
|
|
5834
5836
|
components,
|
|
5835
5837
|
strings
|
|
5836
5838
|
}, ref) {
|
|
5837
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i
|
|
5839
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
5838
5840
|
const t = resolveStrings(strings);
|
|
5839
5841
|
const apiBaseResolved = apiBase;
|
|
5840
5842
|
const appBaseResolved = typeof window !== "undefined" ? window.location.origin : (_a = process.env.APP_URL) != null ? _a : "http://localhost:3000";
|
|
@@ -6126,7 +6128,11 @@ var ChatAdapter = forwardRef(
|
|
|
6126
6128
|
}
|
|
6127
6129
|
) });
|
|
6128
6130
|
}
|
|
6129
|
-
|
|
6131
|
+
const converseCtx = activeSession == null ? void 0 : activeSession.entry_context;
|
|
6132
|
+
const isConverseSession = (converseCtx == null ? void 0 : converseCtx.converse_session) === true;
|
|
6133
|
+
const converseUserCanEnd = (converseCtx == null ? void 0 : converseCtx.converse_user_can_end) === true;
|
|
6134
|
+
const field = activeSession ? extractField(activeSession) : null;
|
|
6135
|
+
if (status === "awaiting_chat" && activeSession && !(isConverseSession && field)) {
|
|
6130
6136
|
const hbCtx = (_e = activeSession.entry_context) == null ? void 0 : _e.handback;
|
|
6131
6137
|
const outputSchema = hbCtx == null ? void 0 : hbCtx.output_schema;
|
|
6132
6138
|
const requireOutput = (_f = hbCtx == null ? void 0 : hbCtx.require_output) != null ? _f : false;
|
|
@@ -6222,18 +6228,16 @@ var ChatAdapter = forwardRef(
|
|
|
6222
6228
|
] })
|
|
6223
6229
|
] });
|
|
6224
6230
|
}
|
|
6225
|
-
const field = activeSession ? extractField(activeSession) : null;
|
|
6226
6231
|
const surface = activeSession ? extractSurface(activeSession) : null;
|
|
6227
6232
|
const surfaceConfig = activeSession ? extractSurfaceConfig(activeSession) : null;
|
|
6228
6233
|
const nodeVoice = activeSession ? extractNodeVoice(activeSession) : null;
|
|
6229
6234
|
const InputComponent = field ? getInputComponent(field.input_type) : null;
|
|
6230
|
-
const isConverseSession = ((_g = activeSession == null ? void 0 : activeSession.entry_context) == null ? void 0 : _g.converse_session) === true;
|
|
6231
6235
|
const effectiveVoiceMode = resolveVoiceMode(surface, surfaceConfig, nodeVoice);
|
|
6232
6236
|
const shouldUseVoice = effectiveVoiceMode !== "off";
|
|
6233
6237
|
const voiceRenderer = effectiveVoiceMode === "push_to_talk" ? "click" : "continuous";
|
|
6234
6238
|
const isLiveVoice = surface === "widget/voice" && (surfaceConfig == null ? void 0 : surfaceConfig.style) === "live";
|
|
6235
6239
|
if (shouldUseVoice && activeSession && field) {
|
|
6236
|
-
const spokenHint = (
|
|
6240
|
+
const spokenHint = (_h = nodeVoice == null ? void 0 : nodeVoice.hint) != null ? _h : (_g = field.voice) == null ? void 0 : _g.hint;
|
|
6237
6241
|
const handleVoiceValue = (value) => {
|
|
6238
6242
|
setInputValue(value);
|
|
6239
6243
|
void submitHandback(value, crypto.randomUUID());
|
|
@@ -6265,7 +6269,7 @@ var ChatAdapter = forwardRef(
|
|
|
6265
6269
|
participantToken,
|
|
6266
6270
|
onValue: handleVoiceValue,
|
|
6267
6271
|
autoSubmitMode: "confirm",
|
|
6268
|
-
confidenceThreshold: (
|
|
6272
|
+
confidenceThreshold: (_i = nodeVoice == null ? void 0 : nodeVoice.confidence_threshold) != null ? _i : typeof (surfaceConfig == null ? void 0 : surfaceConfig.confidence_threshold) === "number" ? surfaceConfig.confidence_threshold : 0.7,
|
|
6269
6273
|
enqueueSpeak,
|
|
6270
6274
|
isSpeaking,
|
|
6271
6275
|
disabled: submitting
|
|
@@ -6340,7 +6344,17 @@ var ChatAdapter = forwardRef(
|
|
|
6340
6344
|
serverErrors.length > 1 && serverErrors.slice(1).map((e, i) => /* @__PURE__ */ jsxs("div", { className: widget_default.inlineError, children: [
|
|
6341
6345
|
e.field !== "_" ? `${e.field}: ` : "",
|
|
6342
6346
|
e.message
|
|
6343
|
-
] }, i))
|
|
6347
|
+
] }, i)),
|
|
6348
|
+
isConverseSession && converseUserCanEnd && /* @__PURE__ */ jsx(
|
|
6349
|
+
"button",
|
|
6350
|
+
{
|
|
6351
|
+
type: "button",
|
|
6352
|
+
className: widget_default.converseDoneButton,
|
|
6353
|
+
onClick: () => void submitHandback({ _done: true }),
|
|
6354
|
+
disabled: submitting,
|
|
6355
|
+
children: t.converseDoneButton
|
|
6356
|
+
}
|
|
6357
|
+
)
|
|
6344
6358
|
] }),
|
|
6345
6359
|
!activeSession && status === "running" && timeline.length === 0 && (emptyState != null ? emptyState : /* @__PURE__ */ jsx(StatusDisplay, { status: "running", strings })),
|
|
6346
6360
|
footer
|