@inkeep/cxkit-primitives 0.5.6 → 0.5.9
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/atoms/api/analytics/events.cjs +1 -1
- package/dist/atoms/api/analytics/events.js +2 -2
- package/dist/components/embedded-chat/use-chat-action.cjs +1 -1
- package/dist/components/embedded-chat/use-chat-action.js +14 -16
- package/dist/components/embedded-chat/use-inkeep-chat.cjs +3 -3
- package/dist/components/embedded-chat/use-inkeep-chat.js +117 -123
- package/dist/components/embedded-chat.cjs +5 -5
- package/dist/components/embedded-chat.d.cts +9 -8
- package/dist/components/embedded-chat.d.ts +9 -8
- package/dist/components/embedded-chat.js +952 -963
- package/dist/components/embedded-search/use-inkeep-search.cjs +1 -1
- package/dist/components/embedded-search/use-inkeep-search.js +10 -10
- package/dist/components/embedded-search.d.cts +2 -2
- package/dist/components/embedded-search.d.ts +2 -2
- package/dist/components/embedded-search.js +79 -79
- package/dist/components/intelligent-form/intelligent-form-provider.cjs +1 -1
- package/dist/components/intelligent-form/intelligent-form-provider.d.cts +3 -3
- package/dist/components/intelligent-form/intelligent-form-provider.d.ts +3 -3
- package/dist/components/intelligent-form/intelligent-form-provider.js +2 -2
- package/dist/components/intelligent-form/use-inkeep-intelligent-form.cjs +1 -1
- package/dist/components/intelligent-form/use-inkeep-intelligent-form.d.cts +5 -5
- package/dist/components/intelligent-form/use-inkeep-intelligent-form.d.ts +5 -5
- package/dist/components/intelligent-form/use-inkeep-intelligent-form.js +88 -109
- package/dist/components/intelligent-form.cjs +1 -1
- package/dist/components/intelligent-form.d.cts +4 -3
- package/dist/components/intelligent-form.d.ts +4 -3
- package/dist/components/intelligent-form.js +191 -188
- package/dist/components/modal.cjs +1 -1
- package/dist/components/modal.d.cts +1 -1
- package/dist/components/modal.d.ts +1 -1
- package/dist/components/modal.js +26 -26
- package/dist/providers/base-events-provider.cjs +1 -1
- package/dist/providers/base-events-provider.js +1 -1
- package/dist/providers/chat-events-provider.cjs +1 -1
- package/dist/providers/chat-events-provider.d.cts +9 -1
- package/dist/providers/chat-events-provider.d.ts +9 -1
- package/dist/providers/chat-events-provider.js +54 -57
- package/dist/providers/chat-form-provider.cjs +1 -1
- package/dist/providers/chat-form-provider.d.cts +3 -3
- package/dist/providers/chat-form-provider.d.ts +3 -3
- package/dist/providers/chat-form-provider.js +17 -17
- package/dist/providers/feedback-provider.cjs +1 -1
- package/dist/providers/feedback-provider.js +23 -23
- package/dist/utils/default-settings.cjs +1 -1
- package/dist/utils/default-settings.d.cts +1 -0
- package/dist/utils/default-settings.d.ts +1 -0
- package/dist/utils/default-settings.js +10 -8
- package/dist/utils/misc.cjs +1 -1
- package/dist/utils/misc.d.cts +2 -2
- package/dist/utils/misc.d.ts +2 -2
- package/dist/utils/misc.js +15 -13
- package/package.json +5 -4
- package/dist/atoms/dialog.cjs +0 -1
- package/dist/atoms/dialog.js +0 -185
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ComponentPropsWithRef, ForwardRefExoticComponent, RefAttributes } from 'react';
|
|
2
2
|
import { InkeepModalSettings } from '@inkeep/cxkit-types';
|
|
3
3
|
import { PolymorphicProps } from './factory';
|
|
4
|
-
import * as DialogPrimitive from '
|
|
4
|
+
import * as DialogPrimitive from '@radix-ui/react-dialog';
|
|
5
5
|
declare const Modal: ForwardRefExoticComponent< PolymorphicProps & Omit<DialogPrimitive.DialogProps, "_id"> & Partial<Pick<DialogPrimitive.DialogProps, "_id">>>;
|
|
6
6
|
export interface PrimitiveModalProps extends ComponentPropsWithRef<typeof Modal> {
|
|
7
7
|
/**
|
package/dist/components/modal.js
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as e } from "react/jsx-runtime";
|
|
3
|
-
import
|
|
3
|
+
import * as i from "@radix-ui/react-dialog";
|
|
4
4
|
import { ikp as n } from "./factory.js";
|
|
5
|
-
import { CustomIcon as
|
|
6
|
-
import { useInkeepModal as
|
|
7
|
-
import { ModalProvider as
|
|
8
|
-
import { composeEventHandlers as
|
|
9
|
-
import { useMediaQuery as
|
|
10
|
-
import { dataAttr as
|
|
11
|
-
const
|
|
5
|
+
import { CustomIcon as d } from "../atoms/icons/custom-icon.js";
|
|
6
|
+
import { useInkeepModal as m } from "./modal/use-inkeep-modal.js";
|
|
7
|
+
import { ModalProvider as s, useModal as c } from "./modal/modal-provider.js";
|
|
8
|
+
import { composeEventHandlers as p } from "../utils/compose-event-handlers.js";
|
|
9
|
+
import { useMediaQuery as C } from "../hooks/use-media-query.js";
|
|
10
|
+
import { dataAttr as M } from "../utils/misc.js";
|
|
11
|
+
const v = n(i.Root, {
|
|
12
12
|
_id: "modal"
|
|
13
|
-
}),
|
|
14
|
-
const { onOpenChange: t, config:
|
|
15
|
-
return /* @__PURE__ */ e(
|
|
16
|
-
|
|
13
|
+
}), k = (o) => {
|
|
14
|
+
const { onOpenChange: t, config: a, ...l } = o, r = m(a);
|
|
15
|
+
return /* @__PURE__ */ e(s, { modal: r, children: /* @__PURE__ */ e(
|
|
16
|
+
v,
|
|
17
17
|
{
|
|
18
18
|
open: r.isOpen,
|
|
19
|
-
onOpenChange:
|
|
20
|
-
...
|
|
19
|
+
onOpenChange: p(t, r.handleOpenChange),
|
|
20
|
+
...l
|
|
21
21
|
}
|
|
22
22
|
) });
|
|
23
|
-
},
|
|
23
|
+
}, I = n(i.Overlay, {
|
|
24
24
|
_id: "modal__Overlay"
|
|
25
|
-
}),
|
|
25
|
+
}), f = n(i.Content, {
|
|
26
26
|
_id: "modal__Content",
|
|
27
27
|
"aria-describedby": void 0
|
|
28
|
-
}),
|
|
29
|
-
const t =
|
|
30
|
-
return /* @__PURE__ */ e(
|
|
31
|
-
},
|
|
28
|
+
}), j = (o) => {
|
|
29
|
+
const t = C("(max-width: 768px)");
|
|
30
|
+
return /* @__PURE__ */ e(f, { "data-mobile": M(t), ...o });
|
|
31
|
+
}, u = n(i.Close, {
|
|
32
32
|
_id: "modal__Close",
|
|
33
|
-
children: /* @__PURE__ */ e(
|
|
34
|
-
}),
|
|
33
|
+
children: /* @__PURE__ */ e(d, { iconKey: "close" })
|
|
34
|
+
}), w = (o) => c() ? /* @__PURE__ */ e(u, { ...o }) : null;
|
|
35
35
|
export {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
w as Close,
|
|
37
|
+
j as Content,
|
|
38
|
+
k as Modal,
|
|
39
|
+
I as Overlay
|
|
40
40
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("react/jsx-runtime"),t=require("react"),y=require("../atoms/api/analytics/events.cjs"),B=require("./config-provider.cjs"),b=require("./user-provider.cjs"),p=t.createContext(void 0),f=({children:e})=>{const{baseSettings:s,componentType:n}=B.useInkeepConfig(),{apiKey:o,analyticsApiBaseUrl:r,tags:i,privacyPreferences:d,env:E}=s,{userProperties:c}=b.useUser(),a=t.useMemo(()=>({widgetLibraryVersion:"0.5.
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("react/jsx-runtime"),t=require("react"),y=require("../atoms/api/analytics/events.cjs"),B=require("./config-provider.cjs"),b=require("./user-provider.cjs"),p=t.createContext(void 0),f=({children:e})=>{const{baseSettings:s,componentType:n}=B.useInkeepConfig(),{apiKey:o,analyticsApiBaseUrl:r,tags:i,privacyPreferences:d,env:E}=s,{userProperties:c}=b.useUser(),a=t.useMemo(()=>({widgetLibraryVersion:"0.5.9",componentType:n,tags:i}),[n,i]),u=!d.optOutAllAnalytics&&E!=="development",g={logEvent:t.useCallback(async v=>{const m={...a,...v.properties},l={eventName:v.eventName,properties:m,userProperties:c};u&&y.logEvent(l,o,r),s.onEvent?.(l)},[u,s,o,r,c,a])};return P.jsx(p.Provider,{value:g,children:e})},x=()=>{const e=t.useContext(p);if(!e)throw new Error("useBaseEvents must be used within a BaseEventsProvider");return e};exports.BaseEventsProvider=f;exports.useBaseEvents=x;
|
|
@@ -7,7 +7,7 @@ import { useUser as b } from "./user-provider.js";
|
|
|
7
7
|
const m = x(void 0), U = ({ children: e }) => {
|
|
8
8
|
const { baseSettings: t, componentType: o } = C(), { apiKey: n, analyticsApiBaseUrl: s, tags: r, privacyPreferences: u, env: l } = t, { userProperties: i } = b(), a = d(
|
|
9
9
|
() => ({
|
|
10
|
-
widgetLibraryVersion: "0.5.
|
|
10
|
+
widgetLibraryVersion: "0.5.9",
|
|
11
11
|
componentType: o,
|
|
12
12
|
tags: r
|
|
13
13
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react/jsx-runtime"),n=require("react"),w=require("../atoms/api/analytics/conversation.cjs"),B=require("./config-provider.cjs"),k=require("./conversation-provider.cjs"),m=require("./user-provider.cjs"),f=require("./base-events-provider.cjs"),g=n.createContext(void 0),x=({children:e})=>{const{baseSettings:y}=B.useInkeepConfig(),{apiKey:l,analyticsApiBaseUrl:C,tags:E,privacyPreferences:{optOutAllAnalytics:s},env:r}=y,{userProperties:d}=m.useUser(),{logEvent:h}=f.useBaseEvents(),{conversation:a,setConversation:p}=k.useInkeepConversation(),c=n.useRef(a);n.useEffect(()=>{c.current=a},[a]);const v=n.useCallback(async o=>{const i=c.current;if(!(!s&&r!=="development"))return;const t=await w.logConversation(i.id,{messages:o,tags:E,userProperties:d},l,C);return t&&p(t),t},[C,l,E,d,p,s,r]),b={logEvent:n.useCallback(async(o,i)=>{if(!(!s&&r!=="development"))return;let t=c.current;if(i){const P=await v(i);P&&(t=P)}const j={...o,properties:{conversation:t,...o.properties}};h(j)},[h,v,s,r]),logConversation:v};return u.jsx(g.Provider,{value:b,children:e})},L=({children:e})=>u.jsx(f.BaseEventsProvider,{children:u.jsx(x,{children:e})}),A=()=>{const e=n.useContext(g);if(!e)throw new Error("useChatEvents must be used within a ChatEventsProvider");return e};exports.ChatEventsProvider=x;exports.ChatEventsProviderWithBase=L;exports.useChatEvents=A;
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { ConversationResponse, InkeepEvent, Message } from '@inkeep/cxkit-types';
|
|
2
2
|
export type ChatEventsContextValue = {
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Log an event.
|
|
5
|
+
* Pass messages if you want it to also log a conversation.
|
|
6
|
+
* The conversation will be appended to the event properties.
|
|
7
|
+
*/
|
|
8
|
+
logEvent: (event: InkeepEvent, messages?: Message[]) => void;
|
|
9
|
+
/**
|
|
10
|
+
* Log a conversation.
|
|
11
|
+
*/
|
|
4
12
|
logConversation: (messages: Message[]) => Promise<ConversationResponse | undefined>;
|
|
5
13
|
};
|
|
6
14
|
export declare const ChatEventsProvider: React.FC<{
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { ConversationResponse, InkeepEvent, Message } from '@inkeep/cxkit-types';
|
|
2
2
|
export type ChatEventsContextValue = {
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Log an event.
|
|
5
|
+
* Pass messages if you want it to also log a conversation.
|
|
6
|
+
* The conversation will be appended to the event properties.
|
|
7
|
+
*/
|
|
8
|
+
logEvent: (event: InkeepEvent, messages?: Message[]) => void;
|
|
9
|
+
/**
|
|
10
|
+
* Log a conversation.
|
|
11
|
+
*/
|
|
4
12
|
logConversation: (messages: Message[]) => Promise<ConversationResponse | undefined>;
|
|
5
13
|
};
|
|
6
14
|
export declare const ChatEventsProvider: React.FC<{
|
|
@@ -1,73 +1,70 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import { useRef as
|
|
4
|
-
import { logConversation as
|
|
5
|
-
import { useInkeepConfig as
|
|
6
|
-
import { useInkeepConversation as
|
|
7
|
-
import { useUser as
|
|
8
|
-
import { useBaseEvents as
|
|
9
|
-
const
|
|
10
|
-
const { baseSettings:
|
|
11
|
-
apiKey:
|
|
12
|
-
analyticsApiBaseUrl:
|
|
13
|
-
tags:
|
|
14
|
-
privacyPreferences: { optOutAllAnalytics:
|
|
15
|
-
env:
|
|
16
|
-
} =
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}, [
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
async (e) => {
|
|
27
|
-
const f = n.current, t = await B(
|
|
28
|
-
f,
|
|
2
|
+
import { jsx as v } from "react/jsx-runtime";
|
|
3
|
+
import { useRef as w, useEffect as B, useCallback as h, createContext as L, useContext as b } from "react";
|
|
4
|
+
import { logConversation as k } from "../atoms/api/analytics/conversation.js";
|
|
5
|
+
import { useInkeepConfig as A } from "./config-provider.js";
|
|
6
|
+
import { useInkeepConversation as I } from "./conversation-provider.js";
|
|
7
|
+
import { useUser as U } from "./user-provider.js";
|
|
8
|
+
import { useBaseEvents as j, BaseEventsProvider as K } from "./base-events-provider.js";
|
|
9
|
+
const d = L(void 0), O = ({ children: t }) => {
|
|
10
|
+
const { baseSettings: g } = A(), {
|
|
11
|
+
apiKey: u,
|
|
12
|
+
analyticsApiBaseUrl: p,
|
|
13
|
+
tags: l,
|
|
14
|
+
privacyPreferences: { optOutAllAnalytics: n },
|
|
15
|
+
env: o
|
|
16
|
+
} = g, { userProperties: C } = U(), { logEvent: f } = j(), { conversation: i, setConversation: E } = I(), a = w(i);
|
|
17
|
+
B(() => {
|
|
18
|
+
a.current = i;
|
|
19
|
+
}, [i]);
|
|
20
|
+
const c = h(
|
|
21
|
+
async (r) => {
|
|
22
|
+
const s = a.current;
|
|
23
|
+
if (!(!n && o !== "development")) return;
|
|
24
|
+
const e = await k(
|
|
25
|
+
s.id,
|
|
29
26
|
{
|
|
30
|
-
messages:
|
|
31
|
-
tags:
|
|
32
|
-
userProperties:
|
|
27
|
+
messages: r,
|
|
28
|
+
tags: l,
|
|
29
|
+
userProperties: C
|
|
33
30
|
},
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
u,
|
|
32
|
+
p
|
|
36
33
|
);
|
|
37
|
-
return
|
|
34
|
+
return e && E(e), e;
|
|
38
35
|
},
|
|
39
|
-
[
|
|
40
|
-
),
|
|
41
|
-
logEvent:
|
|
42
|
-
async (
|
|
43
|
-
if (!(!
|
|
44
|
-
let
|
|
45
|
-
if (
|
|
46
|
-
const
|
|
47
|
-
|
|
36
|
+
[p, u, l, C, E, n, o]
|
|
37
|
+
), P = {
|
|
38
|
+
logEvent: h(
|
|
39
|
+
async (r, s) => {
|
|
40
|
+
if (!(!n && o !== "development")) return;
|
|
41
|
+
let e = a.current;
|
|
42
|
+
if (s) {
|
|
43
|
+
const m = await c(s);
|
|
44
|
+
m && (e = m);
|
|
48
45
|
}
|
|
49
|
-
const
|
|
50
|
-
...
|
|
46
|
+
const y = {
|
|
47
|
+
...r,
|
|
51
48
|
properties: {
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
conversation: e,
|
|
50
|
+
...r.properties
|
|
54
51
|
}
|
|
55
52
|
};
|
|
56
|
-
|
|
53
|
+
f(y);
|
|
57
54
|
},
|
|
58
|
-
[
|
|
55
|
+
[f, c, n, o]
|
|
59
56
|
),
|
|
60
|
-
logConversation:
|
|
57
|
+
logConversation: c
|
|
61
58
|
};
|
|
62
|
-
return /* @__PURE__ */
|
|
63
|
-
},
|
|
64
|
-
const
|
|
65
|
-
if (!
|
|
59
|
+
return /* @__PURE__ */ v(d.Provider, { value: P, children: t });
|
|
60
|
+
}, G = ({ children: t }) => /* @__PURE__ */ v(K, { children: /* @__PURE__ */ v(O, { children: t }) }), H = () => {
|
|
61
|
+
const t = b(d);
|
|
62
|
+
if (!t)
|
|
66
63
|
throw new Error("useChatEvents must be used within a ChatEventsProvider");
|
|
67
|
-
return
|
|
64
|
+
return t;
|
|
68
65
|
};
|
|
69
66
|
export {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
67
|
+
O as ChatEventsProvider,
|
|
68
|
+
G as ChatEventsProviderWithBase,
|
|
69
|
+
H as useChatEvents
|
|
73
70
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const q=require("react/jsx-runtime"),o=require("react"),x=require("react-hook-form"),P=require("./conversation-provider.cjs"),w=require("../components/modal/modal-provider.cjs"),M=require("../utils/form.cjs"),j="root.serverError",f=o.createContext(void 0);function h(){const[t,n]=o.useState(null),[S,u]=o.useState(!1),{conversation:i}=P.useInkeepConversation(),v=w.useModal(),F=e=>{n(e)},C=()=>{n(null),u(!1),t?.buttons.close?.action==="close_modal"&&v?.closeModal()},c=o.useMemo(()=>t?.fields.map(e=>{const s=e;return"_type"in e&&e._type==="include_chat_session"&&(s.isRequired=!1,s.inputType="checkbox",i.id||(s.isHidden=!0)),s}),[t?.fields,i.id]),a=c?.find(e=>"_type"in e&&e._type==="include_chat_session"),r=o.useMemo(()=>M.getFormDefaultValues(c),[c]),{control:b,handleSubmit:p,formState:{errors:m,isSubmitting:E},setError:_,reset:l}=x.useForm({defaultValues:r});o.useEffect(()=>{r&&l(r)},[l,r]);const y=p(async e=>{const R=i.id&&a&&e[a.name]?i:null;try{await t?.buttons.submit.onSubmit({values:e,conversation:R}),u(!0)}catch(d){_(j,{message:d instanceof Error?d.message:"Something went wrong."})}}),g=m?.root?.serverError;return{form:t,openForm:F,closeForm:C,handleSubmit:y,isSuccess:S,isSubmitting:E,formError:g,fields:c,errors:m,control:b,defaultValues:r}}const k=({children:t})=>{const n=h();return q.jsx(f.Provider,{value:n,children:t})},V=()=>{const t=o.useContext(f);if(!t)throw new Error("useChatForm must be used within a ChatFormProvider");return t};exports.ChatFormProvider=k;exports.useChatForm=V;exports.useChatFormState=h;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AIChatFormSettings, FormField } from '@inkeep/cxkit-types';
|
|
2
2
|
import { Message, FieldErrors, Control } from 'react-hook-form';
|
|
3
3
|
export type ChatFormContextValue = ReturnType<typeof useChatFormState>;
|
|
4
4
|
export declare function useChatFormState(): {
|
|
5
|
-
form:
|
|
6
|
-
openForm: (
|
|
5
|
+
form: AIChatFormSettings | null;
|
|
6
|
+
openForm: (formSettings: AIChatFormSettings) => void;
|
|
7
7
|
closeForm: () => void;
|
|
8
8
|
handleSubmit: (e?: React.BaseSyntheticEvent) => Promise<void>;
|
|
9
9
|
isSuccess: boolean;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AIChatFormSettings, FormField } from '@inkeep/cxkit-types';
|
|
2
2
|
import { Message, FieldErrors, Control } from 'react-hook-form';
|
|
3
3
|
export type ChatFormContextValue = ReturnType<typeof useChatFormState>;
|
|
4
4
|
export declare function useChatFormState(): {
|
|
5
|
-
form:
|
|
6
|
-
openForm: (
|
|
5
|
+
form: AIChatFormSettings | null;
|
|
6
|
+
openForm: (formSettings: AIChatFormSettings) => void;
|
|
7
7
|
closeForm: () => void;
|
|
8
8
|
handleSubmit: (e?: React.BaseSyntheticEvent) => Promise<void>;
|
|
9
9
|
isSuccess: boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
2
|
+
import { jsx as w } from "react/jsx-runtime";
|
|
3
3
|
import { useState as d, useMemo as f, useEffect as R, createContext as M, useContext as P } from "react";
|
|
4
4
|
import { useForm as V } from "react-hook-form";
|
|
5
5
|
import { useInkeepConversation as k } from "./conversation-provider.js";
|
|
@@ -7,29 +7,29 @@ import { useModal as I } from "../components/modal/modal-provider.js";
|
|
|
7
7
|
import { getFormDefaultValues as j } from "../utils/form.js";
|
|
8
8
|
const q = "root.serverError", p = M(void 0);
|
|
9
9
|
function A() {
|
|
10
|
-
const [t,
|
|
11
|
-
|
|
10
|
+
const [t, r] = d(null), [h, c] = d(!1), { conversation: n } = k(), S = I(), b = (o) => {
|
|
11
|
+
r(o);
|
|
12
12
|
}, v = () => {
|
|
13
|
-
|
|
13
|
+
r(null), c(!1), t?.buttons.close?.action === "close_modal" && S?.closeModal();
|
|
14
14
|
}, i = f(() => t?.fields.map((o) => {
|
|
15
|
-
const
|
|
16
|
-
return "_type" in o && o._type === "include_chat_session" && (
|
|
17
|
-
}), [t?.fields, n.id]), a = i?.find((o) => "_type" in o && o._type === "include_chat_session"),
|
|
15
|
+
const s = o;
|
|
16
|
+
return "_type" in o && o._type === "include_chat_session" && (s.isRequired = !1, s.inputType = "checkbox", n.id || (s.isHidden = !0)), s;
|
|
17
|
+
}), [t?.fields, n.id]), a = i?.find((o) => "_type" in o && o._type === "include_chat_session"), e = f(() => j(i), [i]), {
|
|
18
18
|
control: C,
|
|
19
19
|
handleSubmit: F,
|
|
20
20
|
formState: { errors: u, isSubmitting: E },
|
|
21
21
|
setError: _,
|
|
22
22
|
reset: m
|
|
23
23
|
} = V({
|
|
24
|
-
defaultValues:
|
|
24
|
+
defaultValues: e
|
|
25
25
|
});
|
|
26
26
|
R(() => {
|
|
27
|
-
|
|
28
|
-
}, [m,
|
|
29
|
-
const
|
|
30
|
-
const
|
|
27
|
+
e && m(e);
|
|
28
|
+
}, [m, e]);
|
|
29
|
+
const x = F(async (o) => {
|
|
30
|
+
const g = n.id && a && o[a.name] ? n : null;
|
|
31
31
|
try {
|
|
32
|
-
await t?.buttons.submit.onSubmit({ values: o, conversation:
|
|
32
|
+
await t?.buttons.submit.onSubmit({ values: o, conversation: g }), c(!0);
|
|
33
33
|
} catch (l) {
|
|
34
34
|
_(q, {
|
|
35
35
|
message: l instanceof Error ? l.message : "Something went wrong."
|
|
@@ -40,19 +40,19 @@ function A() {
|
|
|
40
40
|
form: t,
|
|
41
41
|
openForm: b,
|
|
42
42
|
closeForm: v,
|
|
43
|
-
handleSubmit:
|
|
43
|
+
handleSubmit: x,
|
|
44
44
|
isSuccess: h,
|
|
45
45
|
isSubmitting: E,
|
|
46
46
|
formError: y,
|
|
47
47
|
fields: i,
|
|
48
48
|
errors: u,
|
|
49
49
|
control: C,
|
|
50
|
-
defaultValues:
|
|
50
|
+
defaultValues: e
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
53
|
const G = ({ children: t }) => {
|
|
54
|
-
const
|
|
55
|
-
return /* @__PURE__ */
|
|
54
|
+
const r = A();
|
|
55
|
+
return /* @__PURE__ */ w(p.Provider, { value: r, children: t });
|
|
56
56
|
}, J = () => {
|
|
57
57
|
const t = P(p);
|
|
58
58
|
if (!t)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const x=require("react/jsx-runtime"),n=require("react"),_=require("../atoms/api/analytics/feedback.cjs"),M=require("../components/embedded-chat/chat-provider.cjs"),l=require("../utils/misc.cjs"),S=require("./config-provider.cjs"),E=require("./conversation-provider.cjs"),j=require("./chat-events-provider.cjs"),I=require("./user-provider.cjs"),f=n.createContext(void 0);function R(){const{baseSettings:e}=S.useInkeepConfig(),{apiKey:s,analyticsApiBaseUrl:o}=e,[b,g]=n.useState(null),[F,p]=n.useState({}),{conversation:k}=E.useInkeepConversation(),{messages:c,selectedWorkflow:C}=M.useChat(),{userProperties:P}=I.useUser(),{logEvent:m}=j.useChatEvents(),r=n.useCallback(async(t,i,a=[])=>{const u=await _.submitFeedback({type:i,messageId:t,reasons:a,apiKey:s,apiUrl:o,userProperties:P});u&&p(d=>({...d,[t]:{type:u.type,reasons:u.reasons}}));const v=c.findIndex(d=>d.id===t),y=c[v],w={conversationId:k.id,question:l.getMessageContent(c[v-1]),answer:l.getMessageContent(y),messageId:t,reasons:a,workflowId:C?.id};m({eventName:i==="positive"?"assistant_positive_feedback_submitted":"assistant_negative_feedback_submitted",properties:w})},[c,k]),h=n.useCallback(async t=>{r(t,"positive")},[r]),q=n.useCallback(async(t,i)=>{const a=$(i);r(t,"negative",a)},[r]);return{feedback:F,currentFeedback:b,setCurrentFeedback:g,submitPositiveFeedback:h,submitNegativeFeedback:q}}const U=({children:e})=>{const s=R();return x.jsx(f.Provider,{value:s,children:e})},N=()=>{const e=n.useContext(f);if(!e)throw new Error("useFeedback must be used within a FeedbackProvider");return e};function $(e){const s=[];for(const o in e)e[o]==="on"&&s.push({label:o,details:e[`${o}:description`]||""});return s.length>0?s:[]}exports.FeedbackProvider=U;exports.useMessageFeedback=N;
|
|
@@ -8,61 +8,61 @@ import { useInkeepConfig as S } from "./config-provider.js";
|
|
|
8
8
|
import { useInkeepConversation as j } from "./conversation-provider.js";
|
|
9
9
|
import { useChatEvents as q } from "./chat-events-provider.js";
|
|
10
10
|
import { useUser as A } from "./user-provider.js";
|
|
11
|
-
const
|
|
11
|
+
const v = I(void 0);
|
|
12
12
|
function B() {
|
|
13
|
-
const { baseSettings: e } = S(), { apiKey: s, analyticsApiBaseUrl: o } = e, [b,
|
|
14
|
-
async (t,
|
|
13
|
+
const { baseSettings: e } = S(), { apiKey: s, analyticsApiBaseUrl: o } = e, [b, l] = p(null), [F, g] = p({}), { conversation: m } = j(), { messages: n, selectedWorkflow: C } = N(), { userProperties: h } = A(), { logEvent: w } = q(), r = u(
|
|
14
|
+
async (t, i, c = []) => {
|
|
15
15
|
const a = await M({
|
|
16
|
-
type:
|
|
16
|
+
type: i,
|
|
17
17
|
messageId: t,
|
|
18
|
-
reasons:
|
|
18
|
+
reasons: c,
|
|
19
19
|
apiKey: s,
|
|
20
20
|
apiUrl: o,
|
|
21
|
-
userProperties:
|
|
21
|
+
userProperties: h
|
|
22
22
|
});
|
|
23
|
-
a &&
|
|
23
|
+
a && g((d) => ({
|
|
24
24
|
...d,
|
|
25
25
|
[t]: { type: a.type, reasons: a.reasons }
|
|
26
26
|
}));
|
|
27
|
-
const k = n.findIndex((d) => d.id === t),
|
|
27
|
+
const k = n.findIndex((d) => d.id === t), P = n[k], _ = {
|
|
28
28
|
conversationId: m.id,
|
|
29
29
|
question: f(n[k - 1]),
|
|
30
|
-
answer: f(
|
|
30
|
+
answer: f(P),
|
|
31
31
|
messageId: t,
|
|
32
|
-
reasons:
|
|
33
|
-
workflowId:
|
|
32
|
+
reasons: c,
|
|
33
|
+
workflowId: C?.id
|
|
34
34
|
};
|
|
35
35
|
w({
|
|
36
|
-
eventName:
|
|
37
|
-
properties:
|
|
36
|
+
eventName: i === "positive" ? "assistant_positive_feedback_submitted" : "assistant_negative_feedback_submitted",
|
|
37
|
+
properties: _
|
|
38
38
|
});
|
|
39
39
|
},
|
|
40
40
|
[n, m]
|
|
41
|
-
),
|
|
41
|
+
), x = u(
|
|
42
42
|
async (t) => {
|
|
43
43
|
r(t, "positive");
|
|
44
44
|
},
|
|
45
45
|
[r]
|
|
46
|
-
),
|
|
47
|
-
async (t,
|
|
48
|
-
const
|
|
49
|
-
r(t, "negative",
|
|
46
|
+
), y = u(
|
|
47
|
+
async (t, i) => {
|
|
48
|
+
const c = K(i);
|
|
49
|
+
r(t, "negative", c);
|
|
50
50
|
},
|
|
51
51
|
[r]
|
|
52
52
|
);
|
|
53
53
|
return {
|
|
54
54
|
feedback: F,
|
|
55
55
|
currentFeedback: b,
|
|
56
|
-
setCurrentFeedback:
|
|
57
|
-
submitPositiveFeedback:
|
|
58
|
-
submitNegativeFeedback:
|
|
56
|
+
setCurrentFeedback: l,
|
|
57
|
+
submitPositiveFeedback: x,
|
|
58
|
+
submitNegativeFeedback: y
|
|
59
59
|
};
|
|
60
60
|
}
|
|
61
61
|
const O = ({ children: e }) => {
|
|
62
62
|
const s = B();
|
|
63
|
-
return /* @__PURE__ */ E(
|
|
63
|
+
return /* @__PURE__ */ E(v.Provider, { value: s, children: e });
|
|
64
64
|
}, Q = () => {
|
|
65
|
-
const e = U(
|
|
65
|
+
const e = U(v);
|
|
66
66
|
if (!e)
|
|
67
67
|
throw new Error("useFeedback must be used within a FeedbackProvider");
|
|
68
68
|
return e;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@inkeep/cxkit-theme"),t=require("./transform-source/index.cjs"),s=require("./tools/links-schema.cjs"),a={model:"inkeep-qa-expert",placeholder:"How do I get started?",aiAssistantName:void 0,shouldOpenLinksInNewTab:!0,disclaimerSettings:{isEnabled:!1,label:"Usage policy"},isShareButtonVisible:!1,isViewOnly:!1,exampleQuestionsLabel:"Example questions",exampleQuestions:[],isFirstExampleQuestionHighlighted:!0,isCopyChatButtonVisible:!1,getHelpOptions:[],workflowsHeader:"Workflows",workflows:[],toolbarButtonLabels:{clear:"Clear",share:"Share",getHelp:"Get help",stop:"Stop",copyChat:"Copy"},prompts:[],tools:[{type:"function",function:{name:"provideLinks",description:"Provides links",parameters:s.linksSchema}}]},i={env:"production",apiKey:"",aiApiBaseUrl:"https://api.inkeep.com",analyticsApiBaseUrl:"https://api.
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@inkeep/cxkit-theme"),t=require("./transform-source/index.cjs"),s=require("./tools/links-schema.cjs"),a={model:"inkeep-qa-expert",placeholder:"How do I get started?",aiAssistantName:void 0,shouldOpenLinksInNewTab:!0,disclaimerSettings:{isEnabled:!1,label:"Usage policy"},isShareButtonVisible:!1,isViewOnly:!1,exampleQuestionsLabel:"Example questions",exampleQuestions:[],isFirstExampleQuestionHighlighted:!0,isCopyChatButtonVisible:!1,getHelpOptions:[],workflowsHeader:"Workflows",workflows:[],toolbarButtonLabels:{clear:"Clear",share:"Share",getHelp:"Get help",stop:"Stop",copyChat:"Copy"},prompts:[],tools:[{type:"function",function:{name:"provideLinks",description:"Provides links",parameters:s.linksSchema}}],onToolCall:l=>{}},i={env:"production",apiKey:"",aiApiBaseUrl:"https://api.inkeep.com",analyticsApiBaseUrl:"https://api.io.inkeep.com",shouldBypassCaptcha:!1,privacyPreferences:{optOutAnalyticalCookies:!1,optOutAllAnalytics:!1,optOutFunctionalCookies:!1},tags:[],userProperties:{},primaryBrandColor:e.DEFAULT_PRIMARY_BRAND_COLOR,theme:{varsClassName:"inkeep-widget-vars",...e.theme},transformSource:t.defaultTransformSource},o={shouldOpenLinksInNewTab:!1,maxResults:40,defaultQuery:"",debounceTimeMs:0,tabs:["All","Publications","PDFs","GitHub","Forums","Discord","Slack","StackOverflow"],searchQueryParamKey:"q",placeholder:"Search for anything..."};exports.defaultInkeepAIChatSettings=a;exports.defaultInkeepBaseSettings=i;exports.defaultInkeepSearchSettings=o;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { theme as e, DEFAULT_PRIMARY_BRAND_COLOR as s } from "@inkeep/cxkit-theme";
|
|
3
3
|
import { defaultTransformSource as t } from "./transform-source/index.js";
|
|
4
4
|
import { linksSchema as a } from "./tools/links-schema.js";
|
|
5
|
-
const
|
|
5
|
+
const n = {
|
|
6
6
|
model: "inkeep-qa-expert",
|
|
7
7
|
placeholder: "How do I get started?",
|
|
8
8
|
aiAssistantName: void 0,
|
|
@@ -37,13 +37,15 @@ const r = {
|
|
|
37
37
|
parameters: a
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
]
|
|
40
|
+
],
|
|
41
41
|
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
42
|
-
|
|
42
|
+
onToolCall: (o) => {
|
|
43
|
+
}
|
|
44
|
+
}, p = {
|
|
43
45
|
env: "production",
|
|
44
46
|
apiKey: "",
|
|
45
47
|
aiApiBaseUrl: "https://api.inkeep.com",
|
|
46
|
-
analyticsApiBaseUrl: "https://api.
|
|
48
|
+
analyticsApiBaseUrl: "https://api.io.inkeep.com",
|
|
47
49
|
shouldBypassCaptcha: !1,
|
|
48
50
|
privacyPreferences: {
|
|
49
51
|
optOutAnalyticalCookies: !1,
|
|
@@ -61,7 +63,7 @@ const r = {
|
|
|
61
63
|
...e
|
|
62
64
|
},
|
|
63
65
|
transformSource: t
|
|
64
|
-
},
|
|
66
|
+
}, u = {
|
|
65
67
|
shouldOpenLinksInNewTab: !1,
|
|
66
68
|
maxResults: 40,
|
|
67
69
|
defaultQuery: "",
|
|
@@ -71,7 +73,7 @@ const r = {
|
|
|
71
73
|
placeholder: "Search for anything..."
|
|
72
74
|
};
|
|
73
75
|
export {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
76
|
+
n as defaultInkeepAIChatSettings,
|
|
77
|
+
p as defaultInkeepBaseSettings,
|
|
78
|
+
u as defaultInkeepSearchSettings
|
|
77
79
|
};
|
package/dist/utils/misc.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=t=>{try{return JSON.parse(t)}catch{return t}},
|
|
1
|
+
"use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=t=>{if(typeof t=="string")try{return JSON.parse(t)}catch{return t}return t},s=(...t)=>(...e)=>{for(const n of t)n?.(...e)},a=t=>typeof t=="string";function c(t){return t.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/([A-Z])([A-Z][a-z])/g,"$1-$2").replace(/__/g,"__").toLowerCase()}const i=t=>t?"":void 0;function f(t){const e=t.split(" "),n=e[0]??"",r=e.length>1?e[e.length-1]:"";return n&&r?`${n.charAt(0)}${r.charAt(0)}`:n.charAt(0)}function g(t,e){return typeof t=="function"?t(e):t}const l=t=>typeof t.content=="string"?t.content:t.content[0].text;exports.callAll=s;exports.dataAttr=i;exports.getInitials=f;exports.getMessageContent=l;exports.isString=a;exports.maybeRender=g;exports.parseIfJson=o;exports.toKebabCase=c;
|
package/dist/utils/misc.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Message } from '@inkeep/cxkit-types';
|
|
2
|
-
export declare const parseIfJson: (value:
|
|
1
|
+
import { ConversationResponse, Message } from '@inkeep/cxkit-types';
|
|
2
|
+
export declare const parseIfJson: (value: ConversationResponse["messages"][number]["content"]) => any;
|
|
3
3
|
export declare const callAll: <T extends (...a: any[]) => void>(...fns: (T | undefined)[]) => (...a: Parameters<T>) => void;
|
|
4
4
|
export declare const isString: (v: any) => v is string;
|
|
5
5
|
/**
|
package/dist/utils/misc.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Message } from '@inkeep/cxkit-types';
|
|
2
|
-
export declare const parseIfJson: (value:
|
|
1
|
+
import { ConversationResponse, Message } from '@inkeep/cxkit-types';
|
|
2
|
+
export declare const parseIfJson: (value: ConversationResponse["messages"][number]["content"]) => any;
|
|
3
3
|
export declare const callAll: <T extends (...a: any[]) => void>(...fns: (T | undefined)[]) => (...a: Parameters<T>) => void;
|
|
4
4
|
export declare const isString: (v: any) => v is string;
|
|
5
5
|
/**
|