@inkeep/cxkit-primitives 0.5.6 → 0.5.8

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.
Files changed (54) hide show
  1. package/dist/atoms/api/analytics/events.cjs +1 -1
  2. package/dist/atoms/api/analytics/events.js +2 -2
  3. package/dist/components/embedded-chat/use-chat-action.cjs +1 -1
  4. package/dist/components/embedded-chat/use-chat-action.js +14 -16
  5. package/dist/components/embedded-chat/use-inkeep-chat.cjs +3 -3
  6. package/dist/components/embedded-chat/use-inkeep-chat.js +117 -123
  7. package/dist/components/embedded-chat.cjs +5 -5
  8. package/dist/components/embedded-chat.d.cts +9 -8
  9. package/dist/components/embedded-chat.d.ts +9 -8
  10. package/dist/components/embedded-chat.js +952 -963
  11. package/dist/components/embedded-search/use-inkeep-search.cjs +1 -1
  12. package/dist/components/embedded-search/use-inkeep-search.js +10 -10
  13. package/dist/components/embedded-search.d.cts +2 -2
  14. package/dist/components/embedded-search.d.ts +2 -2
  15. package/dist/components/embedded-search.js +79 -79
  16. package/dist/components/intelligent-form/intelligent-form-provider.cjs +1 -1
  17. package/dist/components/intelligent-form/intelligent-form-provider.d.cts +3 -3
  18. package/dist/components/intelligent-form/intelligent-form-provider.d.ts +3 -3
  19. package/dist/components/intelligent-form/intelligent-form-provider.js +2 -2
  20. package/dist/components/intelligent-form/use-inkeep-intelligent-form.cjs +1 -1
  21. package/dist/components/intelligent-form/use-inkeep-intelligent-form.d.cts +5 -5
  22. package/dist/components/intelligent-form/use-inkeep-intelligent-form.d.ts +5 -5
  23. package/dist/components/intelligent-form/use-inkeep-intelligent-form.js +88 -109
  24. package/dist/components/intelligent-form.cjs +1 -1
  25. package/dist/components/intelligent-form.d.cts +4 -3
  26. package/dist/components/intelligent-form.d.ts +4 -3
  27. package/dist/components/intelligent-form.js +191 -188
  28. package/dist/components/modal.cjs +1 -1
  29. package/dist/components/modal.d.cts +1 -1
  30. package/dist/components/modal.d.ts +1 -1
  31. package/dist/components/modal.js +26 -26
  32. package/dist/providers/base-events-provider.cjs +1 -1
  33. package/dist/providers/base-events-provider.js +1 -1
  34. package/dist/providers/chat-events-provider.cjs +1 -1
  35. package/dist/providers/chat-events-provider.d.cts +9 -1
  36. package/dist/providers/chat-events-provider.d.ts +9 -1
  37. package/dist/providers/chat-events-provider.js +54 -57
  38. package/dist/providers/chat-form-provider.cjs +1 -1
  39. package/dist/providers/chat-form-provider.d.cts +3 -3
  40. package/dist/providers/chat-form-provider.d.ts +3 -3
  41. package/dist/providers/chat-form-provider.js +17 -17
  42. package/dist/providers/feedback-provider.cjs +1 -1
  43. package/dist/providers/feedback-provider.js +23 -23
  44. package/dist/utils/default-settings.cjs +1 -1
  45. package/dist/utils/default-settings.d.cts +1 -0
  46. package/dist/utils/default-settings.d.ts +1 -0
  47. package/dist/utils/default-settings.js +13 -11
  48. package/dist/utils/misc.cjs +1 -1
  49. package/dist/utils/misc.d.cts +2 -2
  50. package/dist/utils/misc.d.ts +2 -2
  51. package/dist/utils/misc.js +15 -13
  52. package/package.json +5 -4
  53. package/dist/atoms/dialog.cjs +0 -1
  54. 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 '../atoms/dialog';
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
  /**
@@ -1,40 +1,40 @@
1
1
  "use client";
2
2
  import { jsx as e } from "react/jsx-runtime";
3
- import { Overlay as l, Root as d, Content as m, Close as s } from "../atoms/dialog.js";
3
+ import * as i from "@radix-ui/react-dialog";
4
4
  import { ikp as n } from "./factory.js";
5
- import { CustomIcon as c } from "../atoms/icons/custom-icon.js";
6
- import { useInkeepModal as p } from "./modal/use-inkeep-modal.js";
7
- import { ModalProvider as C, useModal as M } from "./modal/modal-provider.js";
8
- import { composeEventHandlers as f } from "../utils/compose-event-handlers.js";
9
- import { useMediaQuery as u } from "../hooks/use-media-query.js";
10
- import { dataAttr as v } from "../utils/misc.js";
11
- const _ = n(d, {
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
- }), A = (o) => {
14
- const { onOpenChange: t, config: i, ...a } = o, r = p(i);
15
- return /* @__PURE__ */ e(C, { modal: r, children: /* @__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: f(t, r.handleOpenChange),
20
- ...a
19
+ onOpenChange: p(t, r.handleOpenChange),
20
+ ...l
21
21
  }
22
22
  ) });
23
- }, E = n(l, {
23
+ }, I = n(i.Overlay, {
24
24
  _id: "modal__Overlay"
25
- }), O = n(m, {
25
+ }), f = n(i.Content, {
26
26
  _id: "modal__Content",
27
27
  "aria-describedby": void 0
28
- }), H = (o) => {
29
- const t = u("(max-width: 768px)");
30
- return /* @__PURE__ */ e(O, { "data-mobile": v(t), ...o });
31
- }, h = n(s, {
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(c, { iconKey: "close" })
34
- }), K = (o) => M() ? /* @__PURE__ */ e(h, { ...o }) : null;
33
+ children: /* @__PURE__ */ e(d, { iconKey: "close" })
34
+ }), w = (o) => c() ? /* @__PURE__ */ e(u, { ...o }) : null;
35
35
  export {
36
- K as Close,
37
- H as Content,
38
- A as Modal,
39
- E as Overlay
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.6",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;
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.8",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.6",
10
+ widgetLibraryVersion: "0.5.8",
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 a=require("react/jsx-runtime"),n=require("react"),x=require("../atoms/api/analytics/conversation.cjs"),j=require("./config-provider.cjs"),w=require("./conversation-provider.cjs"),B=require("./user-provider.cjs"),m=require("./base-events-provider.cjs"),f=n.createContext(void 0),P=({children:s})=>{const{baseSettings:_}=j.useInkeepConfig(),{apiKey:c,analyticsApiBaseUrl:v,tags:u,privacyPreferences:{optOutAllAnalytics:d},env:l}=_,{userProperties:C}=B.useUser(),{logEvent:p}=m.useBaseEvents(),{conversation:o,setConversation:E}=w.useInkeepConversation(),r=n.useRef(o.id);n.useEffect(()=>{r.current=o.id},[o.id]);const b=["chat_message_submitted","chat_message_bot_response_received","intelligent_form_primary_submitted","intelligent_form_qa_response"],i=n.useCallback(async e=>{const h=r.current,t=await x.logConversation(h,{messages:e,tags:u,userProperties:C},c,v);return t&&E(t),t},[v,c,u,C,E]),y={logEvent:n.useCallback(async e=>{if(!(!d&&l!=="development"))return;let t=r.current;if(b.includes(e.eventName)&&"messages"in e.properties){const g=await i(e.properties.messages);g&&(t=g.id,r.current=t)}const q={...e,properties:{...e.properties,conversationId:t}};p(q)},[p,i,d,l]),logConversation:i};return a.jsx(f.Provider,{value:y,children:s})},I=({children:s})=>a.jsx(m.BaseEventsProvider,{children:a.jsx(P,{children:s})}),k=()=>{const s=n.useContext(f);if(!s)throw new Error("useChatEvents must be used within a ChatEventsProvider");return s};exports.ChatEventsProvider=P;exports.ChatEventsProviderWithBase=I;exports.useChatEvents=k;
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
- logEvent: (event: InkeepEvent) => void;
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
- logEvent: (event: InkeepEvent) => void;
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 i } from "react/jsx-runtime";
3
- import { useRef as b, useEffect as x, useCallback as g, createContext as w, useContext as I } from "react";
4
- import { logConversation as B } from "../atoms/api/analytics/conversation.js";
5
- import { useInkeepConfig as k } from "./config-provider.js";
6
- import { useInkeepConversation as A } from "./conversation-provider.js";
7
- import { useUser as L } from "./user-provider.js";
8
- import { useBaseEvents as U, BaseEventsProvider as j } from "./base-events-provider.js";
9
- const E = w(void 0), q = ({ children: s }) => {
10
- const { baseSettings: h } = k(), {
11
- apiKey: a,
12
- analyticsApiBaseUrl: c,
13
- tags: v,
14
- privacyPreferences: { optOutAllAnalytics: u },
15
- env: p
16
- } = h, { userProperties: m } = L(), { logEvent: l } = U(), { conversation: o, setConversation: d } = A(), n = b(o.id);
17
- x(() => {
18
- n.current = o.id;
19
- }, [o.id]);
20
- const _ = [
21
- "chat_message_submitted",
22
- "chat_message_bot_response_received",
23
- "intelligent_form_primary_submitted",
24
- "intelligent_form_qa_response"
25
- ], r = g(
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: e,
31
- tags: v,
32
- userProperties: m
27
+ messages: r,
28
+ tags: l,
29
+ userProperties: C
33
30
  },
34
- a,
35
- c
31
+ u,
32
+ p
36
33
  );
37
- return t && d(t), t;
34
+ return e && E(e), e;
38
35
  },
39
- [c, a, v, m, d]
40
- ), y = {
41
- logEvent: g(
42
- async (e) => {
43
- if (!(!u && p !== "development")) return;
44
- let t = n.current;
45
- if (_.includes(e.eventName) && "messages" in e.properties) {
46
- const C = await r(e.properties.messages);
47
- C && (t = C.id, n.current = t);
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 P = {
50
- ...e,
46
+ const y = {
47
+ ...r,
51
48
  properties: {
52
- ...e.properties,
53
- conversationId: t
49
+ conversation: e,
50
+ ...r.properties
54
51
  }
55
52
  };
56
- l(P);
53
+ f(y);
57
54
  },
58
- [l, r, u, p]
55
+ [f, c, n, o]
59
56
  ),
60
- logConversation: r
57
+ logConversation: c
61
58
  };
62
- return /* @__PURE__ */ i(E.Provider, { value: y, children: s });
63
- }, D = ({ children: s }) => /* @__PURE__ */ i(j, { children: /* @__PURE__ */ i(q, { children: s }) }), F = () => {
64
- const s = I(E);
65
- if (!s)
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 s;
64
+ return t;
68
65
  };
69
66
  export {
70
- q as ChatEventsProvider,
71
- D as ChatEventsProviderWithBase,
72
- F as useChatEvents
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 R=require("react/jsx-runtime"),o=require("react"),q=require("react-hook-form"),x=require("./conversation-provider.cjs"),P=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}=x.useInkeepConversation(),v=P.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 r=e;return"_type"in e&&e._type==="include_chat_session"&&(r.isRequired=!1,r.inputType="checkbox",i.id||(r.isHidden=!0)),r}),[t?.fields,i.id]),a=c?.find(e=>"_type"in e&&e._type==="include_chat_session"),s=o.useMemo(()=>M.getFormDefaultValues(c),[c]),{control:b,handleSubmit:p,formState:{errors:m,isSubmitting:E},setError:_,reset:l}=q.useForm({defaultValues:s});o.useEffect(()=>{s&&l(s)},[l,s]);const w=p(async e=>{const r=typeof window>"u"?"":window.location.href,g=i.id&&a&&e[a.name]?i:null;try{await t?.buttons.submit.onSubmit({values:e,conversation:g,client:{currentUrl:r}}),u(!0)}catch(d){_(j,{message:d instanceof Error?d.message:"Something went wrong."})}}),y=m?.root?.serverError;return{form:t,openForm:F,closeForm:C,handleSubmit:w,isSuccess:S,isSubmitting:E,formError:y,fields:c,errors:m,control:b,defaultValues:s}}const k=({children:t})=>{const n=h();return R.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
+ "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 { FormConfig, FormField } from '@inkeep/cxkit-types';
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: FormConfig | null;
6
- openForm: (formConfig: FormConfig) => void;
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 { FormConfig, FormField } from '@inkeep/cxkit-types';
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: FormConfig | null;
6
- openForm: (formConfig: FormConfig) => void;
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 g } from "react/jsx-runtime";
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, s] = d(null), [h, c] = d(!1), { conversation: n } = k(), S = I(), b = (o) => {
11
- s(o);
10
+ const [t, r] = d(null), [h, c] = d(!1), { conversation: n } = k(), S = I(), b = (o) => {
11
+ r(o);
12
12
  }, v = () => {
13
- s(null), c(!1), t?.buttons.close?.action === "close_modal" && S?.closeModal();
13
+ r(null), c(!1), t?.buttons.close?.action === "close_modal" && S?.closeModal();
14
14
  }, i = f(() => t?.fields.map((o) => {
15
- const e = o;
16
- return "_type" in o && o._type === "include_chat_session" && (e.isRequired = !1, e.inputType = "checkbox", n.id || (e.isHidden = !0)), e;
17
- }), [t?.fields, n.id]), a = i?.find((o) => "_type" in o && o._type === "include_chat_session"), r = f(() => j(i), [i]), {
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: r
24
+ defaultValues: e
25
25
  });
26
26
  R(() => {
27
- r && m(r);
28
- }, [m, r]);
29
- const w = F(async (o) => {
30
- const e = typeof window > "u" ? "" : window.location.href, x = n.id && a && o[a.name] ? n : null;
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: x, client: { currentUrl: e } }), c(!0);
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: w,
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: r
50
+ defaultValues: e
51
51
  };
52
52
  }
53
53
  const G = ({ children: t }) => {
54
- const s = A();
55
- return /* @__PURE__ */ g(p.Provider, { value: s, children: t });
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 _=require("react/jsx-runtime"),n=require("react"),x=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,h]=n.useState({}),{conversation:k}=E.useInkeepConversation(),{messages:c,selectedWorkflow:p}=M.useChat(),{userProperties:m}=I.useUser(),{logEvent:C}=j.useChatEvents(),r=n.useCallback(async(t,a,i=[])=>{const u=await x.submitFeedback({type:a,messageId:t,reasons:i,apiKey:s,apiUrl:o,userProperties:m});u&&h(d=>({...d,[t]:{type:u.type,reasons:u.reasons}}));const v=c.findIndex(d=>d.id===t),w=c[v],y={conversationId:k.id,question:l.getMessageContent(c[v-1]),answer:l.getMessageContent(w),messageId:t,reasons:i,workflowId:p?.id};C({eventName:a==="positive"?"chat_thumbs_up_feedback_submitted":"chat_thumbs_down_feedback_submitted",properties:y})},[c,k]),P=n.useCallback(async t=>{r(t,"positive")},[r]),q=n.useCallback(async(t,a)=>{const i=$(a);r(t,"negative",i)},[r]);return{feedback:F,currentFeedback:b,setCurrentFeedback:g,submitPositiveFeedback:P,submitNegativeFeedback:q}}const U=({children:e})=>{const s=R();return _.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;
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 l = I(void 0);
11
+ const v = I(void 0);
12
12
  function B() {
13
- const { baseSettings: e } = S(), { apiKey: s, analyticsApiBaseUrl: o } = e, [b, v] = p(null), [F, h] = p({}), { conversation: m } = j(), { messages: n, selectedWorkflow: g } = N(), { userProperties: C } = A(), { logEvent: w } = q(), r = u(
14
- async (t, c, i = []) => {
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: c,
16
+ type: i,
17
17
  messageId: t,
18
- reasons: i,
18
+ reasons: c,
19
19
  apiKey: s,
20
20
  apiUrl: o,
21
- userProperties: C
21
+ userProperties: h
22
22
  });
23
- a && h((d) => ({
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), y = n[k], P = {
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(y),
30
+ answer: f(P),
31
31
  messageId: t,
32
- reasons: i,
33
- workflowId: g?.id
32
+ reasons: c,
33
+ workflowId: C?.id
34
34
  };
35
35
  w({
36
- eventName: c === "positive" ? "chat_thumbs_up_feedback_submitted" : "chat_thumbs_down_feedback_submitted",
37
- properties: P
36
+ eventName: i === "positive" ? "assistant_positive_feedback_submitted" : "assistant_negative_feedback_submitted",
37
+ properties: _
38
38
  });
39
39
  },
40
40
  [n, m]
41
- ), _ = u(
41
+ ), x = u(
42
42
  async (t) => {
43
43
  r(t, "positive");
44
44
  },
45
45
  [r]
46
- ), x = u(
47
- async (t, c) => {
48
- const i = K(c);
49
- r(t, "negative", i);
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: v,
57
- submitPositiveFeedback: _,
58
- submitNegativeFeedback: x
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(l.Provider, { value: s, children: e });
63
+ return /* @__PURE__ */ E(v.Provider, { value: s, children: e });
64
64
  }, Q = () => {
65
- const e = U(l);
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.analytics.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},l={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=l;
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:o=>{}},i={env:"production",apiKey:"",aiApiBaseUrl:"https://api.inkeep.com",analyticsApiBaseUrl:"https://api.analytics.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},l={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=l;
@@ -96,6 +96,7 @@ export declare const defaultInkeepAIChatSettings: {
96
96
  };
97
97
  };
98
98
  }[];
99
+ onToolCall: (_toolCall: any) => undefined;
99
100
  };
100
101
  export declare const defaultInkeepBaseSettings: {
101
102
  env: InkeepBaseSettings["env"];
@@ -96,6 +96,7 @@ export declare const defaultInkeepAIChatSettings: {
96
96
  };
97
97
  };
98
98
  }[];
99
+ onToolCall: (_toolCall: any) => undefined;
99
100
  };
100
101
  export declare const defaultInkeepBaseSettings: {
101
102
  env: InkeepBaseSettings["env"];
@@ -1,8 +1,8 @@
1
1
  "use client";
2
2
  import { theme as e, DEFAULT_PRIMARY_BRAND_COLOR as s } from "@inkeep/cxkit-theme";
3
- import { defaultTransformSource as t } from "./transform-source/index.js";
4
- import { linksSchema as a } from "./tools/links-schema.js";
5
- const r = {
3
+ import { defaultTransformSource as a } from "./transform-source/index.js";
4
+ import { linksSchema as t } from "./tools/links-schema.js";
5
+ const n = {
6
6
  model: "inkeep-qa-expert",
7
7
  placeholder: "How do I get started?",
8
8
  aiAssistantName: void 0,
@@ -34,12 +34,14 @@ const r = {
34
34
  function: {
35
35
  name: "provideLinks",
36
36
  description: "Provides links",
37
- parameters: a
37
+ parameters: t
38
38
  }
39
39
  }
40
- ]
40
+ ],
41
41
  // biome-ignore lint/suspicious/noExplicitAny: <explanation>
42
- }, n = {
42
+ onToolCall: (o) => {
43
+ }
44
+ }, p = {
43
45
  env: "production",
44
46
  apiKey: "",
45
47
  aiApiBaseUrl: "https://api.inkeep.com",
@@ -60,8 +62,8 @@ const r = {
60
62
  varsClassName: "inkeep-widget-vars",
61
63
  ...e
62
64
  },
63
- transformSource: t
64
- }, p = {
65
+ transformSource: a
66
+ }, c = {
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
- r as defaultInkeepAIChatSettings,
75
- n as defaultInkeepBaseSettings,
76
- p as defaultInkeepSearchSettings
76
+ n as defaultInkeepAIChatSettings,
77
+ p as defaultInkeepBaseSettings,
78
+ c as defaultInkeepSearchSettings
77
79
  };
@@ -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}},a=(...t)=>(...e)=>{for(const n of t)n?.(...e)},s=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 l(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 f(t,e){return typeof t=="function"?t(e):t}const g=t=>typeof t.content=="string"?t.content:t.content[0].text;exports.callAll=a;exports.dataAttr=i;exports.getInitials=l;exports.getMessageContent=g;exports.isString=s;exports.maybeRender=f;exports.parseIfJson=o;exports.toKebabCase=c;
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;
@@ -1,5 +1,5 @@
1
- import { Message } from '@inkeep/cxkit-types';
2
- export declare const parseIfJson: (value: string) => any;
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
  /**
@@ -1,5 +1,5 @@
1
- import { Message } from '@inkeep/cxkit-types';
2
- export declare const parseIfJson: (value: string) => any;
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
  /**