@brainfish-ai/components 0.18.8 → 0.19.1
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/chat-search.d.ts +11 -2
- package/dist/esm/chunks/{ChatSearch.DCnEmHuh.js → ChatSearch.g9-_lvsz.js} +200 -72
- package/dist/esm/chunks/ChatSearch.g9-_lvsz.js.map +1 -0
- package/dist/esm/chunks/font-picker.DX1mER3H.js +181 -0
- package/dist/esm/chunks/font-picker.DX1mER3H.js.map +1 -0
- package/dist/esm/components/chat-search.js +1 -1
- package/dist/esm/components/font-picker.js +2 -0
- package/dist/esm/components/font-picker.js.map +1 -0
- package/dist/esm/index.js +6 -179
- package/dist/esm/index.js.map +1 -1
- package/dist/font-picker.d.ts +106 -0
- package/dist/index.d.ts +11 -2
- package/dist/stats.html +1 -1
- package/package.json +1 -1
- package/dist/esm/chunks/ChatSearch.DCnEmHuh.js.map +0 -1
package/dist/chat-search.d.ts
CHANGED
|
@@ -58,7 +58,12 @@ declare enum ActionType {
|
|
|
58
58
|
CallPhone = "call_phone",
|
|
59
59
|
OpenUrl = "open_url",
|
|
60
60
|
SendEmail = "send_email",
|
|
61
|
-
RunCallback = "run_callback"
|
|
61
|
+
RunCallback = "run_callback",
|
|
62
|
+
LaunchIntercomChat = "launch_intercom_chat",
|
|
63
|
+
LaunchZendeskChat = "launch_zendesk_chat",
|
|
64
|
+
LaunchZendeskMessenger = "launch_zendesk_messenger",
|
|
65
|
+
LaunchFreshdesk = "launch_freshdesk",
|
|
66
|
+
LaunchSupportTicketForm = "launch_support_ticket_form"
|
|
62
67
|
}
|
|
63
68
|
|
|
64
69
|
declare type AddActionButtons = {
|
|
@@ -328,7 +333,11 @@ declare enum NextBestActionType {
|
|
|
328
333
|
Email = "email",
|
|
329
334
|
Phone = "phone",
|
|
330
335
|
Callback = "callback",
|
|
331
|
-
Function = "function"
|
|
336
|
+
Function = "function",
|
|
337
|
+
ZendeskChat = "zendesk_chat",
|
|
338
|
+
ZendeskMessenger = "zendesk_messenger",
|
|
339
|
+
IntercomChat = "intercom_chat",
|
|
340
|
+
Freshdesk = "freshdesk"
|
|
332
341
|
}
|
|
333
342
|
|
|
334
343
|
declare type NoArticlesFound = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React__default, { useState, useCallback, useMemo, createContext, useContext,
|
|
1
|
+
import React__default, { useState, useCallback, useMemo, createContext, useContext, useRef, useEffect, forwardRef, useImperativeHandle } from 'react';
|
|
2
2
|
import { motion, AnimatePresence } from 'framer-motion';
|
|
3
3
|
import rehypeRaw from 'rehype-raw';
|
|
4
4
|
import remarkGfm from 'remark-gfm';
|
|
@@ -3920,7 +3920,51 @@ function AnswerBlock({ block, redirectRules, state }) {
|
|
|
3920
3920
|
}
|
|
3921
3921
|
}
|
|
3922
3922
|
|
|
3923
|
+
var ActionType = /* @__PURE__ */ ((ActionType2) => {
|
|
3924
|
+
ActionType2["CallPhone"] = "call_phone";
|
|
3925
|
+
ActionType2["OpenUrl"] = "open_url";
|
|
3926
|
+
ActionType2["SendEmail"] = "send_email";
|
|
3927
|
+
ActionType2["RunCallback"] = "run_callback";
|
|
3928
|
+
ActionType2["LaunchIntercomChat"] = "launch_intercom_chat";
|
|
3929
|
+
ActionType2["LaunchZendeskChat"] = "launch_zendesk_chat";
|
|
3930
|
+
ActionType2["LaunchZendeskMessenger"] = "launch_zendesk_messenger";
|
|
3931
|
+
ActionType2["LaunchFreshdesk"] = "launch_freshdesk";
|
|
3932
|
+
ActionType2["LaunchSupportTicketForm"] = "launch_support_ticket_form";
|
|
3933
|
+
return ActionType2;
|
|
3934
|
+
})(ActionType || {});
|
|
3935
|
+
var NextBestActionType = /* @__PURE__ */ ((NextBestActionType2) => {
|
|
3936
|
+
NextBestActionType2["Link"] = "link";
|
|
3937
|
+
NextBestActionType2["Email"] = "email";
|
|
3938
|
+
NextBestActionType2["Phone"] = "phone";
|
|
3939
|
+
NextBestActionType2["Callback"] = "callback";
|
|
3940
|
+
NextBestActionType2["Function"] = "function";
|
|
3941
|
+
NextBestActionType2["ZendeskChat"] = "zendesk_chat";
|
|
3942
|
+
NextBestActionType2["ZendeskMessenger"] = "zendesk_messenger";
|
|
3943
|
+
NextBestActionType2["IntercomChat"] = "intercom_chat";
|
|
3944
|
+
NextBestActionType2["Freshdesk"] = "freshdesk";
|
|
3945
|
+
return NextBestActionType2;
|
|
3946
|
+
})(NextBestActionType || {});
|
|
3947
|
+
|
|
3923
3948
|
const MotionButton$1 = motion(Button);
|
|
3949
|
+
const closeBrainfishWidget = () => {
|
|
3950
|
+
if (window.Brainfish?.HelpWidget?.close) {
|
|
3951
|
+
window.Brainfish.HelpWidget.close();
|
|
3952
|
+
}
|
|
3953
|
+
};
|
|
3954
|
+
const ActionButton = ({ icon, label, index, onClick, showArrowOut = false, asChild = false, children }) => /* @__PURE__ */ React__default.createElement(
|
|
3955
|
+
MotionButton$1,
|
|
3956
|
+
{
|
|
3957
|
+
initial: { opacity: 0, x: -20 },
|
|
3958
|
+
animate: { opacity: 1, x: 0 },
|
|
3959
|
+
transition: { delay: index * 0.1 },
|
|
3960
|
+
className: "w-full text-left h-12 text-base [&_svg]:size-6",
|
|
3961
|
+
variant: "ghost",
|
|
3962
|
+
onClick,
|
|
3963
|
+
asChild
|
|
3964
|
+
},
|
|
3965
|
+
asChild ? children : /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, icon && /* @__PURE__ */ React__default.createElement(MemoizedIcon, { iconName: icon }), /* @__PURE__ */ React__default.createElement("span", { className: "flex-grow" }, label), showArrowOut && /* @__PURE__ */ React__default.createElement(MemoizedIcon, { iconName: "ArrowSquareOut" }))
|
|
3966
|
+
);
|
|
3967
|
+
const ActionLink = ({ href, icon, label, index, onClick }) => /* @__PURE__ */ React__default.createElement(ActionButton, { icon, label, index, onClick, asChild: true }, /* @__PURE__ */ React__default.createElement("a", { href, target: "_blank", rel: "noopener noreferrer" }, icon && /* @__PURE__ */ React__default.createElement(MemoizedIcon, { iconName: icon }), /* @__PURE__ */ React__default.createElement("span", { className: "flex-grow" }, label), /* @__PURE__ */ React__default.createElement(MemoizedIcon, { iconName: "ArrowSquareOut" })));
|
|
3924
3968
|
const NextBestActions = ({ nextBestActions, onActionClick }) => {
|
|
3925
3969
|
if (!nextBestActions.length) return null;
|
|
3926
3970
|
return /* @__PURE__ */ React__default.createElement(
|
|
@@ -3932,102 +3976,155 @@ const NextBestActions = ({ nextBestActions, onActionClick }) => {
|
|
|
3932
3976
|
className: "w-full"
|
|
3933
3977
|
},
|
|
3934
3978
|
/* @__PURE__ */ React__default.createElement("div", { className: "rounded-lg overflow-hidden bg-card border divide-y divide-dark-300" }, nextBestActions.map((action, index) => {
|
|
3935
|
-
const handleClick = () => {
|
|
3936
|
-
onActionClick(action);
|
|
3979
|
+
const handleClick = (success) => {
|
|
3980
|
+
onActionClick(action, success);
|
|
3937
3981
|
};
|
|
3938
|
-
const className = "w-full h-12 py-2 px-4 inline-flex items-center justify-center gap-2 whitespace-nowrap text-base font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-6 [&_svg]:shrink-0 hover:bg-accent hover:text-accent-foreground";
|
|
3939
3982
|
const key = `${action.label}-${index}`.replace(/\s+/g, "-");
|
|
3940
3983
|
switch (action.type) {
|
|
3941
|
-
case
|
|
3984
|
+
case NextBestActionType.Email:
|
|
3942
3985
|
return /* @__PURE__ */ React__default.createElement(
|
|
3943
|
-
|
|
3986
|
+
ActionLink,
|
|
3944
3987
|
{
|
|
3945
3988
|
key,
|
|
3946
|
-
initial: { opacity: 0, x: -20 },
|
|
3947
|
-
animate: { opacity: 1, x: 0 },
|
|
3948
|
-
transition: { delay: index * 0.1 },
|
|
3949
3989
|
href: `mailto:${action.value}`,
|
|
3950
|
-
|
|
3951
|
-
|
|
3952
|
-
|
|
3990
|
+
icon: action.icon,
|
|
3991
|
+
label: action.label,
|
|
3992
|
+
index,
|
|
3953
3993
|
onClick: () => handleClick()
|
|
3954
|
-
}
|
|
3955
|
-
action.icon && /* @__PURE__ */ React__default.createElement(MemoizedIcon, { iconName: action.icon }),
|
|
3956
|
-
/* @__PURE__ */ React__default.createElement("span", { className: "flex-grow" }, action.label),
|
|
3957
|
-
/* @__PURE__ */ React__default.createElement(MemoizedIcon, { iconName: "ArrowSquareOut" })
|
|
3994
|
+
}
|
|
3958
3995
|
);
|
|
3959
|
-
case
|
|
3996
|
+
case NextBestActionType.Link:
|
|
3960
3997
|
return /* @__PURE__ */ React__default.createElement(
|
|
3961
|
-
|
|
3998
|
+
ActionLink,
|
|
3962
3999
|
{
|
|
3963
4000
|
key,
|
|
3964
|
-
initial: { opacity: 0, x: -20 },
|
|
3965
|
-
animate: { opacity: 1, x: 0 },
|
|
3966
|
-
transition: { delay: index * 0.1 },
|
|
3967
4001
|
href: addPopupWidgetUtm(action.value),
|
|
3968
|
-
|
|
3969
|
-
|
|
3970
|
-
|
|
4002
|
+
icon: action.icon,
|
|
4003
|
+
label: action.label,
|
|
4004
|
+
index,
|
|
3971
4005
|
onClick: () => handleClick()
|
|
3972
|
-
}
|
|
3973
|
-
action.icon && /* @__PURE__ */ React__default.createElement(MemoizedIcon, { iconName: action.icon }),
|
|
3974
|
-
/* @__PURE__ */ React__default.createElement("span", { className: "flex-grow" }, action.label),
|
|
3975
|
-
/* @__PURE__ */ React__default.createElement(MemoizedIcon, { iconName: "ArrowSquareOut" })
|
|
4006
|
+
}
|
|
3976
4007
|
);
|
|
3977
|
-
case
|
|
4008
|
+
case NextBestActionType.Phone:
|
|
3978
4009
|
return /* @__PURE__ */ React__default.createElement(
|
|
3979
|
-
|
|
4010
|
+
ActionLink,
|
|
3980
4011
|
{
|
|
3981
4012
|
key,
|
|
3982
|
-
initial: { opacity: 0, x: -20 },
|
|
3983
|
-
animate: { opacity: 1, x: 0 },
|
|
3984
|
-
transition: { delay: index * 0.1 },
|
|
3985
4013
|
href: `tel:${action.value}`,
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
|
|
4014
|
+
icon: action.icon,
|
|
4015
|
+
label: action.label,
|
|
4016
|
+
index,
|
|
3989
4017
|
onClick: () => handleClick()
|
|
3990
|
-
}
|
|
3991
|
-
|
|
3992
|
-
|
|
3993
|
-
|
|
4018
|
+
}
|
|
4019
|
+
);
|
|
4020
|
+
case NextBestActionType.ZendeskChat:
|
|
4021
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
4022
|
+
ActionButton,
|
|
4023
|
+
{
|
|
4024
|
+
key,
|
|
4025
|
+
icon: action.icon,
|
|
4026
|
+
label: action.label,
|
|
4027
|
+
index,
|
|
4028
|
+
onClick: () => {
|
|
4029
|
+
if (window.zE) {
|
|
4030
|
+
closeBrainfishWidget();
|
|
4031
|
+
window.zE("webWidget", "open");
|
|
4032
|
+
handleClick(true);
|
|
4033
|
+
} else {
|
|
4034
|
+
console.error(
|
|
4035
|
+
"Zendesk Chat is not loaded. Make sure you've included the Zendesk Chat script in your website."
|
|
4036
|
+
);
|
|
4037
|
+
handleClick(false);
|
|
4038
|
+
}
|
|
4039
|
+
}
|
|
4040
|
+
}
|
|
4041
|
+
);
|
|
4042
|
+
case NextBestActionType.ZendeskMessenger:
|
|
4043
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
4044
|
+
ActionButton,
|
|
4045
|
+
{
|
|
4046
|
+
key,
|
|
4047
|
+
icon: action.icon,
|
|
4048
|
+
label: action.label,
|
|
4049
|
+
index,
|
|
4050
|
+
onClick: () => {
|
|
4051
|
+
if (window.zE) {
|
|
4052
|
+
closeBrainfishWidget();
|
|
4053
|
+
window.zE("messenger", "open");
|
|
4054
|
+
handleClick(true);
|
|
4055
|
+
} else {
|
|
4056
|
+
console.error(
|
|
4057
|
+
"Zendesk Messenger is not loaded. Make sure you've included the Zendesk Messenger script in your website."
|
|
4058
|
+
);
|
|
4059
|
+
handleClick(false);
|
|
4060
|
+
}
|
|
4061
|
+
}
|
|
4062
|
+
}
|
|
4063
|
+
);
|
|
4064
|
+
case NextBestActionType.IntercomChat:
|
|
4065
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
4066
|
+
ActionButton,
|
|
4067
|
+
{
|
|
4068
|
+
key,
|
|
4069
|
+
icon: action.icon,
|
|
4070
|
+
label: action.label,
|
|
4071
|
+
index,
|
|
4072
|
+
onClick: () => {
|
|
4073
|
+
if (window.Intercom) {
|
|
4074
|
+
closeBrainfishWidget();
|
|
4075
|
+
window.Intercom("show");
|
|
4076
|
+
handleClick(true);
|
|
4077
|
+
} else {
|
|
4078
|
+
console.error(
|
|
4079
|
+
"Intercom is not loaded. Make sure you've included the Intercom script in your website."
|
|
4080
|
+
);
|
|
4081
|
+
handleClick(false);
|
|
4082
|
+
}
|
|
4083
|
+
}
|
|
4084
|
+
}
|
|
4085
|
+
);
|
|
4086
|
+
case NextBestActionType.Freshdesk:
|
|
4087
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
4088
|
+
ActionButton,
|
|
4089
|
+
{
|
|
4090
|
+
key,
|
|
4091
|
+
icon: action.icon,
|
|
4092
|
+
label: action.label,
|
|
4093
|
+
index,
|
|
4094
|
+
onClick: () => {
|
|
4095
|
+
if (window.fcWidget) {
|
|
4096
|
+
closeBrainfishWidget();
|
|
4097
|
+
setTimeout(() => {
|
|
4098
|
+
window.fcWidget.open();
|
|
4099
|
+
window.fcWidget.show();
|
|
4100
|
+
}, 300);
|
|
4101
|
+
handleClick(true);
|
|
4102
|
+
} else {
|
|
4103
|
+
console.error(
|
|
4104
|
+
"Freshdesk is not loaded. Make sure you've included the Freshdesk script in your website."
|
|
4105
|
+
);
|
|
4106
|
+
handleClick(false);
|
|
4107
|
+
}
|
|
4108
|
+
}
|
|
4109
|
+
}
|
|
3994
4110
|
);
|
|
3995
4111
|
default:
|
|
3996
|
-
return /* @__PURE__ */ React__default.createElement(
|
|
3997
|
-
|
|
4112
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
4113
|
+
ActionButton,
|
|
3998
4114
|
{
|
|
3999
|
-
|
|
4000
|
-
|
|
4001
|
-
|
|
4002
|
-
|
|
4003
|
-
|
|
4004
|
-
|
|
4005
|
-
}
|
|
4006
|
-
|
|
4007
|
-
/* @__PURE__ */ React__default.createElement("span", { className: "flex-grow" }, action.label),
|
|
4008
|
-
/* @__PURE__ */ React__default.createElement(MemoizedIcon, { iconName: "ArrowSquareOut" })
|
|
4009
|
-
));
|
|
4115
|
+
key,
|
|
4116
|
+
icon: "ArrowCircleRight",
|
|
4117
|
+
label: action.label,
|
|
4118
|
+
index,
|
|
4119
|
+
onClick: () => handleClick(),
|
|
4120
|
+
showArrowOut: true
|
|
4121
|
+
}
|
|
4122
|
+
);
|
|
4010
4123
|
}
|
|
4011
4124
|
}))
|
|
4012
4125
|
);
|
|
4013
4126
|
};
|
|
4014
4127
|
|
|
4015
|
-
var ActionType = /* @__PURE__ */ ((ActionType2) => {
|
|
4016
|
-
ActionType2["CallPhone"] = "call_phone";
|
|
4017
|
-
ActionType2["OpenUrl"] = "open_url";
|
|
4018
|
-
ActionType2["SendEmail"] = "send_email";
|
|
4019
|
-
ActionType2["RunCallback"] = "run_callback";
|
|
4020
|
-
return ActionType2;
|
|
4021
|
-
})(ActionType || {});
|
|
4022
|
-
var NextBestActionType = /* @__PURE__ */ ((NextBestActionType2) => {
|
|
4023
|
-
NextBestActionType2["Link"] = "link";
|
|
4024
|
-
NextBestActionType2["Email"] = "email";
|
|
4025
|
-
NextBestActionType2["Phone"] = "phone";
|
|
4026
|
-
NextBestActionType2["Callback"] = "callback";
|
|
4027
|
-
NextBestActionType2["Function"] = "function";
|
|
4028
|
-
return NextBestActionType2;
|
|
4029
|
-
})(NextBestActionType || {});
|
|
4030
|
-
|
|
4031
4128
|
const getActionMapping = (action) => {
|
|
4032
4129
|
const actionMapping = {
|
|
4033
4130
|
[ActionType.CallPhone]: {
|
|
@@ -4058,6 +4155,36 @@ const getActionMapping = (action) => {
|
|
|
4058
4155
|
});
|
|
4059
4156
|
},
|
|
4060
4157
|
getLabel: (a) => a.action?.options?.title || "Run Action"
|
|
4158
|
+
},
|
|
4159
|
+
[ActionType.LaunchZendeskChat]: {
|
|
4160
|
+
type: NextBestActionType.ZendeskChat,
|
|
4161
|
+
icon: "ChatCircleDots",
|
|
4162
|
+
getValue: (a) => a.action?.options?.embedKey || a.id,
|
|
4163
|
+
getLabel: (a) => a.action?.options?.title || "Chat with us"
|
|
4164
|
+
},
|
|
4165
|
+
[ActionType.LaunchZendeskMessenger]: {
|
|
4166
|
+
type: NextBestActionType.ZendeskMessenger,
|
|
4167
|
+
icon: "ChatCircleDots",
|
|
4168
|
+
getValue: (a) => a.action?.options?.embedKey || a.id,
|
|
4169
|
+
getLabel: (a) => a.action?.options?.title || "Chat with us"
|
|
4170
|
+
},
|
|
4171
|
+
[ActionType.LaunchIntercomChat]: {
|
|
4172
|
+
type: NextBestActionType.IntercomChat,
|
|
4173
|
+
icon: "ChatCircleDots",
|
|
4174
|
+
getValue: (a) => a.action?.options?.appId || a.id,
|
|
4175
|
+
getLabel: (a) => a.action?.options?.title || "Chat with us"
|
|
4176
|
+
},
|
|
4177
|
+
[ActionType.LaunchFreshdesk]: {
|
|
4178
|
+
type: NextBestActionType.Freshdesk,
|
|
4179
|
+
icon: "ChatCircleDots",
|
|
4180
|
+
getValue: (a) => a.action?.options?.token || a.id,
|
|
4181
|
+
getLabel: (a) => a.action?.options?.title || "Chat with us"
|
|
4182
|
+
},
|
|
4183
|
+
[ActionType.LaunchSupportTicketForm]: {
|
|
4184
|
+
type: NextBestActionType.Link,
|
|
4185
|
+
icon: "Notepad",
|
|
4186
|
+
getValue: (a) => a.action?.options?.formUrl || a.id,
|
|
4187
|
+
getLabel: (a) => a.action?.options?.title || "Submit a ticket"
|
|
4061
4188
|
}
|
|
4062
4189
|
};
|
|
4063
4190
|
const mapping = actionMapping[action.type] || {
|
|
@@ -4112,13 +4239,14 @@ const AnswerActions = ({
|
|
|
4112
4239
|
NextBestActions,
|
|
4113
4240
|
{
|
|
4114
4241
|
nextBestActions: mappedActions,
|
|
4115
|
-
onActionClick: (action) => {
|
|
4242
|
+
onActionClick: (action, success) => {
|
|
4116
4243
|
if (action) {
|
|
4117
4244
|
handleActionClick?.({
|
|
4118
4245
|
action,
|
|
4119
4246
|
searchQueryId: searchQueryId || "",
|
|
4120
4247
|
query: question,
|
|
4121
|
-
answer
|
|
4248
|
+
answer,
|
|
4249
|
+
success
|
|
4122
4250
|
});
|
|
4123
4251
|
}
|
|
4124
4252
|
}
|
|
@@ -6513,4 +6641,4 @@ const ChatSearch = forwardRef(({ featureFlags, ...props }, ref) => /* @__PURE__
|
|
|
6513
6641
|
ChatSearch.displayName = "ChatSearch";
|
|
6514
6642
|
|
|
6515
6643
|
export { ChatSearch as C, ChatSearchProvider as a, useIsChatSearchDirty as b, useChatSearch as u };
|
|
6516
|
-
//# sourceMappingURL=ChatSearch.
|
|
6644
|
+
//# sourceMappingURL=ChatSearch.g9-_lvsz.js.map
|