@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.d.mts
CHANGED
|
@@ -287,6 +287,7 @@ interface WidgetStrings {
|
|
|
287
287
|
chatInputPlaceholder: string;
|
|
288
288
|
sendButton: string;
|
|
289
289
|
handBackButton: string;
|
|
290
|
+
converseDoneButton: string;
|
|
290
291
|
}
|
|
291
292
|
declare const defaultStrings: WidgetStrings;
|
|
292
293
|
/** Merge a partial override on top of the defaults. */
|
package/dist/index.d.ts
CHANGED
|
@@ -287,6 +287,7 @@ interface WidgetStrings {
|
|
|
287
287
|
chatInputPlaceholder: string;
|
|
288
288
|
sendButton: string;
|
|
289
289
|
handBackButton: string;
|
|
290
|
+
converseDoneButton: string;
|
|
290
291
|
}
|
|
291
292
|
declare const defaultStrings: WidgetStrings;
|
|
292
293
|
/** Merge a partial override on top of the defaults. */
|
package/dist/index.js
CHANGED
|
@@ -492,6 +492,7 @@ var widget_default = {
|
|
|
492
492
|
converseHint: "widget_converseHint",
|
|
493
493
|
converseHintDot: "widget_converseHintDot",
|
|
494
494
|
"cf-converse-pulse": "widget_cf-converse-pulse",
|
|
495
|
+
converseDoneButton: "widget_converseDoneButton",
|
|
495
496
|
newMessageChip: "widget_newMessageChip",
|
|
496
497
|
activeInputRow: "widget_activeInputRow",
|
|
497
498
|
activeInputField: "widget_activeInputField",
|
|
@@ -2686,7 +2687,8 @@ var defaultStrings = {
|
|
|
2686
2687
|
somethingWentWrong: "Something went wrong",
|
|
2687
2688
|
chatInputPlaceholder: "Type a message\u2026",
|
|
2688
2689
|
sendButton: "Send",
|
|
2689
|
-
handBackButton: "Hand Back"
|
|
2690
|
+
handBackButton: "Hand Back",
|
|
2691
|
+
converseDoneButton: "I'm done"
|
|
2690
2692
|
};
|
|
2691
2693
|
function resolveStrings(overrides) {
|
|
2692
2694
|
return overrides ? { ...defaultStrings, ...overrides } : defaultStrings;
|
|
@@ -5836,7 +5838,7 @@ var ChatAdapter = react.forwardRef(
|
|
|
5836
5838
|
components,
|
|
5837
5839
|
strings
|
|
5838
5840
|
}, ref) {
|
|
5839
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i
|
|
5841
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
5840
5842
|
const t = resolveStrings(strings);
|
|
5841
5843
|
const apiBaseResolved = apiBase;
|
|
5842
5844
|
const appBaseResolved = typeof window !== "undefined" ? window.location.origin : (_a = process.env.APP_URL) != null ? _a : "http://localhost:3000";
|
|
@@ -6128,7 +6130,11 @@ var ChatAdapter = react.forwardRef(
|
|
|
6128
6130
|
}
|
|
6129
6131
|
) });
|
|
6130
6132
|
}
|
|
6131
|
-
|
|
6133
|
+
const converseCtx = activeSession == null ? void 0 : activeSession.entry_context;
|
|
6134
|
+
const isConverseSession = (converseCtx == null ? void 0 : converseCtx.converse_session) === true;
|
|
6135
|
+
const converseUserCanEnd = (converseCtx == null ? void 0 : converseCtx.converse_user_can_end) === true;
|
|
6136
|
+
const field = activeSession ? extractField(activeSession) : null;
|
|
6137
|
+
if (status === "awaiting_chat" && activeSession && !(isConverseSession && field)) {
|
|
6132
6138
|
const hbCtx = (_e = activeSession.entry_context) == null ? void 0 : _e.handback;
|
|
6133
6139
|
const outputSchema = hbCtx == null ? void 0 : hbCtx.output_schema;
|
|
6134
6140
|
const requireOutput = (_f = hbCtx == null ? void 0 : hbCtx.require_output) != null ? _f : false;
|
|
@@ -6224,18 +6230,16 @@ var ChatAdapter = react.forwardRef(
|
|
|
6224
6230
|
] })
|
|
6225
6231
|
] });
|
|
6226
6232
|
}
|
|
6227
|
-
const field = activeSession ? extractField(activeSession) : null;
|
|
6228
6233
|
const surface = activeSession ? extractSurface(activeSession) : null;
|
|
6229
6234
|
const surfaceConfig = activeSession ? extractSurfaceConfig(activeSession) : null;
|
|
6230
6235
|
const nodeVoice = activeSession ? extractNodeVoice(activeSession) : null;
|
|
6231
6236
|
const InputComponent = field ? getInputComponent(field.input_type) : null;
|
|
6232
|
-
const isConverseSession = ((_g = activeSession == null ? void 0 : activeSession.entry_context) == null ? void 0 : _g.converse_session) === true;
|
|
6233
6237
|
const effectiveVoiceMode = resolveVoiceMode(surface, surfaceConfig, nodeVoice);
|
|
6234
6238
|
const shouldUseVoice = effectiveVoiceMode !== "off";
|
|
6235
6239
|
const voiceRenderer = effectiveVoiceMode === "push_to_talk" ? "click" : "continuous";
|
|
6236
6240
|
const isLiveVoice = surface === "widget/voice" && (surfaceConfig == null ? void 0 : surfaceConfig.style) === "live";
|
|
6237
6241
|
if (shouldUseVoice && activeSession && field) {
|
|
6238
|
-
const spokenHint = (
|
|
6242
|
+
const spokenHint = (_h = nodeVoice == null ? void 0 : nodeVoice.hint) != null ? _h : (_g = field.voice) == null ? void 0 : _g.hint;
|
|
6239
6243
|
const handleVoiceValue = (value) => {
|
|
6240
6244
|
setInputValue(value);
|
|
6241
6245
|
void submitHandback(value, crypto.randomUUID());
|
|
@@ -6267,7 +6271,7 @@ var ChatAdapter = react.forwardRef(
|
|
|
6267
6271
|
participantToken,
|
|
6268
6272
|
onValue: handleVoiceValue,
|
|
6269
6273
|
autoSubmitMode: "confirm",
|
|
6270
|
-
confidenceThreshold: (
|
|
6274
|
+
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,
|
|
6271
6275
|
enqueueSpeak,
|
|
6272
6276
|
isSpeaking,
|
|
6273
6277
|
disabled: submitting
|
|
@@ -6342,7 +6346,17 @@ var ChatAdapter = react.forwardRef(
|
|
|
6342
6346
|
serverErrors.length > 1 && serverErrors.slice(1).map((e, i) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: widget_default.inlineError, children: [
|
|
6343
6347
|
e.field !== "_" ? `${e.field}: ` : "",
|
|
6344
6348
|
e.message
|
|
6345
|
-
] }, i))
|
|
6349
|
+
] }, i)),
|
|
6350
|
+
isConverseSession && converseUserCanEnd && /* @__PURE__ */ jsxRuntime.jsx(
|
|
6351
|
+
"button",
|
|
6352
|
+
{
|
|
6353
|
+
type: "button",
|
|
6354
|
+
className: widget_default.converseDoneButton,
|
|
6355
|
+
onClick: () => void submitHandback({ _done: true }),
|
|
6356
|
+
disabled: submitting,
|
|
6357
|
+
children: t.converseDoneButton
|
|
6358
|
+
}
|
|
6359
|
+
)
|
|
6346
6360
|
] }),
|
|
6347
6361
|
!activeSession && status === "running" && timeline.length === 0 && (emptyState != null ? emptyState : /* @__PURE__ */ jsxRuntime.jsx(StatusDisplay, { status: "running", strings })),
|
|
6348
6362
|
footer
|