@inkeep/cxkit-primitives 0.5.48 → 0.5.50

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.
@@ -1,26 +1,26 @@
1
1
  "use client";
2
- import Re from "openai";
3
- import { useState as c, useRef as U, useEffect as ae, useImperativeHandle as Pe } from "react";
4
- import { useInkeepConfig as Ue } from "../../providers/config-provider.js";
5
- import { useInkeepConversation as Fe } from "../../providers/conversation-provider.js";
6
- import { useChatEvents as Ke } from "../../providers/chat-events-provider.js";
7
- import { getMessageMetadata as Te, serializeAttachments as We, serializeWorkflow as Je } from "../../utils/get-message-metadata.js";
8
- import { parseIfJson as ze } from "../../utils/misc.js";
2
+ import De from "openai";
3
+ import { useState as c, useRef as U, useEffect as ae, useImperativeHandle as Oe } from "react";
4
+ import { useInkeepConfig as Re } from "../../providers/config-provider.js";
5
+ import { useInkeepConversation as Pe } from "../../providers/conversation-provider.js";
6
+ import { useChatEvents as Ue } from "../../providers/chat-events-provider.js";
7
+ import { getMessageMetadata as Fe, serializeAttachments as Ke, serializeWorkflow as Te } from "../../utils/get-message-metadata.js";
8
+ import { parseIfJson as We } from "../../utils/misc.js";
9
9
  import { resetQueryParams as re } from "../../utils/reset-query-params.js";
10
- import { useChatForm as He } from "../../providers/chat-form-provider.js";
11
- import { useWidget as Qe } from "../../providers/widget-provider.js";
12
- import { useMediaQuery as je } from "../../hooks/use-media-query.js";
13
- import { useCaptcha as qe } from "./use-captcha.js";
14
- import { useModal as Ge } from "../modal/modal-provider.js";
10
+ import { useChatForm as Je } from "../../providers/chat-form-provider.js";
11
+ import { useWidget as ze } from "../../providers/widget-provider.js";
12
+ import { useMediaQuery as He } from "../../hooks/use-media-query.js";
13
+ import { useCaptcha as Qe } from "./use-captcha.js";
14
+ import { useModal as je } from "../modal/modal-provider.js";
15
15
  import { generateUid as u } from "../../utils/generate-uid.js";
16
- import { provideLinksTool as Ve } from "../../utils/tools/links-tool.js";
17
- import { getConversation as Xe } from "../../atoms/api/analytics/conversation.js";
18
- const dt = () => {
19
- const { chatId: d, setConversation: ie, conversation: x, resetConversation: ce } = Fe(), { baseSettings: b, aiChatSettings: F } = Ue(), { aiApiBaseUrl: K, shouldBypassCaptcha: T, filters: W } = b, J = Ge(), { getSolution: le, prefetchSolution: $, invalidateSolution: z } = qe({
16
+ import { provideLinksTool as qe } from "../../utils/tools/links-tool.js";
17
+ import { getConversation as Ge } from "../../atoms/api/analytics/conversation.js";
18
+ const gt = () => {
19
+ const { chatId: d, setConversation: ie, conversation: x, resetConversation: ce } = Pe(), { baseSettings: b, aiChatSettings: F } = Re(), { aiApiBaseUrl: K, shouldBypassCaptcha: T, filters: W } = b, J = je(), { getSolution: le, prefetchSolution: $, invalidateSolution: z } = Qe({
20
20
  fetchUrl: `${K}/v1/challenge`,
21
21
  shouldBypassCaptcha: T,
22
22
  shouldMakeInitialRequest: J ? J.isOpen : !0
23
- }), ue = new Re({
23
+ }), ue = new De({
24
24
  baseURL: `${K}/v1`,
25
25
  apiKey: b.apiKey,
26
26
  dangerouslyAllowBrowser: !0
@@ -37,25 +37,25 @@ const dt = () => {
37
37
  }, [f]);
38
38
  const [m, l] = c([]), [j, h] = c(!1), [he, y] = c(!1), [ye, q] = c(null), [B, G] = c(null), [C, v] = c([]), Ce = (e) => {
39
39
  v((t) => [...t, e]);
40
- }, [ve, V] = c({}), a = U([]), w = U(null), { logEvent: E, logConversation: we } = Ke(), X = pe?.map((e, t) => ({
40
+ }, [ve, V] = c({}), a = U([]), w = U(null), { logEvent: E } = Ue(), X = pe?.map((e, t) => ({
41
41
  id: `system-${Date.now().toString()}-${u(4)}-${t}`,
42
42
  role: "system",
43
43
  content: e
44
- })), [Ie, Me] = c(!!d);
44
+ })), [we, Ie] = c(!!d);
45
45
  ae(() => {
46
46
  if (d) {
47
47
  const { apiKey: e, analyticsApiBaseUrl: t } = b;
48
- Xe(d, e, t).then((n) => {
48
+ Ge(d, e, t).then((n) => {
49
49
  if (n) {
50
50
  E({
51
51
  eventName: "shared_chat_loaded",
52
52
  properties: {
53
53
  conversation: n
54
54
  }
55
- }), Me(!1), ie({ ...n, id: "" });
55
+ }), Ie(!1), ie({ ...n, id: "" });
56
56
  const o = n.messages.map((i) => ({
57
57
  id: Date.now().toString() + u(4) + i.id,
58
- content: ze(i.content),
58
+ content: We(i.content),
59
59
  role: i.role,
60
60
  links: i.links
61
61
  }));
@@ -64,7 +64,7 @@ const dt = () => {
64
64
  });
65
65
  }
66
66
  }, [d]);
67
- const Se = (e) => {
67
+ const Me = (e) => {
68
68
  switch (e.code) {
69
69
  case 400:
70
70
  return e.message;
@@ -78,19 +78,19 @@ It seems I might be having some issues right now. Please clear the chat and try
78
78
  }, Y = (e) => {
79
79
  q(e), l((t) => {
80
80
  const n = [...t], o = n[n.length - 1];
81
- return o && (o.content = Se(e)), n;
81
+ return o && (o.content = Me(e)), n;
82
82
  }), h(!1), y(!1), z(), $();
83
- }, D = !f.trim() && !C.length || j, ke = (e) => {
83
+ }, D = !f.trim() && !C.length || j, Se = (e) => {
84
84
  e.key === "Enter" && !e.shiftKey && !D && !e.nativeEvent.isComposing && (e.preventDefault(), O());
85
- }, be = (e) => {
85
+ }, ke = (e) => {
86
86
  const t = e.target.value;
87
87
  L(t);
88
88
  }, O = async (e = f) => {
89
89
  if (D && (!e || e.trim().length === 0)) return;
90
90
  h(!0);
91
- const t = B ? m.length === 2 : m.length === 0, n = Te(B, C, t);
91
+ const t = B ? m.length === 2 : m.length === 0, n = Fe(B, C, t);
92
92
  let o;
93
- const i = We(C);
93
+ const i = Ke(C);
94
94
  C.length && i ? o = [{ type: "text", text: i }] : o = e;
95
95
  const ee = {
96
96
  id: `${Date.now().toString()}-${u(4)}-1`,
@@ -105,7 +105,7 @@ It seems I might be having some issues right now. Please clear the chat and try
105
105
  },
106
106
  a.current
107
107
  );
108
- const te = [Ve, ...ge?.({ conversation: x }) || []];
108
+ const te = [qe, ...ge?.({ conversation: x }) || []];
109
109
  try {
110
110
  const I = {
111
111
  model: de,
@@ -136,10 +136,10 @@ It seems I might be having some issues right now. Please clear the chat and try
136
136
  }), g.on("tool_calls.function.arguments.done", async (M) => {
137
137
  const { name: S, arguments: A } = M, r = te?.find((p) => p.function.name === S);
138
138
  if (!r) return;
139
- const k = ("parse" in r.function ? r.function.parse : JSON.parse)(A), xe = r.function.function?.(k, g), Le = r.renderMessageButtons?.({ args: k, execution: xe }) ?? [];
139
+ const k = ("parse" in r.function ? r.function.parse : JSON.parse)(A), Ae = r.function.function?.(k, g), xe = r.renderMessageButtons?.({ args: k, execution: Ae }) ?? [];
140
140
  S === "provideLinks" ? s.links = k.links ?? [] : V((p) => ({
141
141
  ...p,
142
- [s.id]: [...p[s.id] ?? [], ...Le]
142
+ [s.id]: [...p[s.id] ?? [], ...xe]
143
143
  })), s.toolCalls?.push({
144
144
  id: "call_" + u(24),
145
145
  type: "function",
@@ -148,14 +148,14 @@ It seems I might be having some issues right now. Please clear the chat and try
148
148
  arguments: A
149
149
  }
150
150
  }), l((p) => {
151
- const P = [...p], De = P.findIndex((Oe) => Oe.id === s.id);
152
- return P[De] = { ...s }, P;
151
+ const P = [...p], Le = P.findIndex((Be) => Be.id === s.id);
152
+ return P[Le] = { ...s }, P;
153
+ }), fe?.(M, {
154
+ conversation: {
155
+ ...x,
156
+ messages: [...a.current, s]
157
+ }
153
158
  });
154
- const Be = await we([
155
- ...a.current,
156
- s
157
- ]);
158
- fe?.(M, { conversation: Be ?? x });
159
159
  }), g.on("error", Y), g.finalChatCompletion().then(() => {
160
160
  a.current = [...a.current, s], w.current = null, h(!1), y(!1), $(), E(
161
161
  {
@@ -168,7 +168,7 @@ It seems I might be having some issues right now. Please clear the chat and try
168
168
  } catch (I) {
169
169
  Y(I), h(!1), y(!1);
170
170
  }
171
- }, $e = () => {
171
+ }, be = () => {
172
172
  w.current && (w.current.abort(), w.current = null), h(!1), y(!1), $();
173
173
  }, Z = () => {
174
174
  q(null), l([]), a.current = [], ce(), V({}), v([]), re(), G(null), z(), $(), E({
@@ -177,7 +177,7 @@ It seems I might be having some issues right now. Please clear the chat and try
177
177
  conversation: x
178
178
  }
179
179
  });
180
- }, Ee = (e) => {
180
+ }, $e = (e) => {
181
181
  G(e);
182
182
  const { initialReplyMessage: t, displayName: n } = e, o = {
183
183
  id: m.length.toString() + u(4),
@@ -192,38 +192,38 @@ It seems I might be having some issues right now. Please clear the chat and try
192
192
  id: `system-${Date.now().toString()}-${u(4)}-${e.id}`,
193
193
  role: "system",
194
194
  content: `Company has asked user to follow this guided workflow:
195
- ${Je(e)}`
195
+ ${Te(e)}`
196
196
  }, ...X, o, i];
197
197
  l(N), v([]);
198
- }, { openForm: Ne } = He(), _e = Qe();
199
- Pe(F.chatFunctionsRef, () => ({
198
+ }, { openForm: Ee } = Je(), Ne = ze();
199
+ Oe(F.chatFunctionsRef, () => ({
200
200
  submitMessage: O,
201
201
  updateInputMessage(e) {
202
202
  L(e);
203
203
  },
204
204
  clearChat: Z,
205
205
  openForm: (e) => {
206
- _e?.setView("chat"), Ne(e);
206
+ Ne?.setView("chat"), Ee(e);
207
207
  },
208
208
  focusInput: () => {
209
209
  Q.current?.focus();
210
210
  }
211
211
  }));
212
- const Ae = je("(max-width: 768px)");
212
+ const _e = He("(max-width: 768px)");
213
213
  return {
214
214
  messages: m,
215
215
  input: f,
216
216
  isLoading: j,
217
217
  isStreaming: he,
218
- isLoadingConversation: Ie,
218
+ isLoadingConversation: we,
219
219
  error: ye,
220
220
  isSubmitDisabled: D,
221
- handleInputChange: be,
222
- handleInputKeyDown: ke,
221
+ handleInputChange: ke,
222
+ handleInputKeyDown: Se,
223
223
  handleSubmit: O,
224
- stop: $e,
224
+ stop: be,
225
225
  clear: Z,
226
- handleWorkflow: Ee,
226
+ handleWorkflow: $e,
227
227
  selectedWorkflow: B,
228
228
  messageAttachments: C,
229
229
  setMessageAttachments: v,
@@ -231,9 +231,9 @@ ${Je(e)}`
231
231
  messageButtons: ve,
232
232
  isEmpty: m.length === 0,
233
233
  inputRef: Q,
234
- isMobile: Ae
234
+ isMobile: _e
235
235
  };
236
236
  };
237
237
  export {
238
- dt as useInkeepChat
238
+ gt as useInkeepChat
239
239
  };
package/dist/index.d.cts CHANGED
@@ -22,7 +22,6 @@ import { FeebackReason } from '@inkeep/cxkit-types';
22
22
  import { FeedbackItemType } from '@inkeep/cxkit-types';
23
23
  import { FeedbackType } from '@inkeep/cxkit-types';
24
24
  import { FieldErrors } from 'react-hook-form';
25
- import { FocusScope } from '@radix-ui/react-focus-scope';
26
25
  import { FormField } from '@inkeep/cxkit-types';
27
26
  import { FormHTMLAttributes } from 'react';
28
27
  import { ForwardRefExoticComponent } from 'react';
@@ -54,7 +53,6 @@ import * as PopoverPrimitive from '@radix-ui/react-popover';
54
53
  import { Portal as Portal_2 } from '@radix-ui/react-portal';
55
54
  import { Primitive } from '@radix-ui/react-primitive';
56
55
  import { PropsWithChildren } from 'react';
57
- import * as RadixDialog from '@radix-ui/react-dialog';
58
56
  import * as React_2 from 'react';
59
57
  import { ReactElement } from 'react';
60
58
  import { ReactNode } from 'react';
@@ -74,6 +72,7 @@ import { ToolCallAction } from '@inkeep/cxkit-types';
74
72
  import * as TooltipPrimitive from '@radix-ui/react-tooltip';
75
73
  import { TopLevelHeading } from '@inkeep/cxkit-types';
76
74
  import { TransformedSource } from '@inkeep/cxkit-types';
75
+ import { TrapFocusOptions } from '@zag-js/focus-trap';
77
76
  import { UrlQueryParam } from '@inkeep/cxkit-types';
78
77
  import { UserProperties as UserProperties_2 } from '@inkeep/cxkit-types';
79
78
  import { Workflow } from '@inkeep/cxkit-types';
@@ -548,7 +547,7 @@ export declare const Command: React_2.ForwardRefExoticComponent<Children & Omit<
548
547
  /** Whether this separator should always be rendered. Useful if you disable automatic filtering. */
549
548
  alwaysRender?: boolean;
550
549
  } & React_2.RefAttributes<HTMLDivElement>>;
551
- Dialog: React_2.ForwardRefExoticComponent<RadixDialog.DialogProps & Children & Omit<React_2.ClassAttributes<HTMLDivElement> & React_2.HTMLAttributes<HTMLDivElement> & {
550
+ Dialog: React_2.ForwardRefExoticComponent<DialogPrimitive.DialogProps & Children & Omit<React_2.ClassAttributes<HTMLDivElement> & React_2.HTMLAttributes<HTMLDivElement> & {
552
551
  asChild?: boolean;
553
552
  }, "ref"> & {
554
553
  /**
@@ -620,7 +619,7 @@ export declare const Command: React_2.ForwardRefExoticComponent<Children & Omit<
620
619
  /**
621
620
  * Renders the command menu in a Radix Dialog.
622
621
  */
623
- export declare const CommandDialog: React_2.ForwardRefExoticComponent<RadixDialog.DialogProps & Children & Omit<React_2.ClassAttributes<HTMLDivElement> & React_2.HTMLAttributes<HTMLDivElement> & {
622
+ export declare const CommandDialog: React_2.ForwardRefExoticComponent<DialogPrimitive.DialogProps & Children & Omit<React_2.ClassAttributes<HTMLDivElement> & React_2.HTMLAttributes<HTMLDivElement> & {
624
623
  asChild?: boolean;
625
624
  }, "ref"> & {
626
625
  /**
@@ -1443,17 +1442,17 @@ declare interface DialogContentImplProps extends Omit<DismissableLayerProps, 'on
1443
1442
  * pointer, or a programmatic focus.
1444
1443
  * @defaultValue false
1445
1444
  */
1446
- trapFocus?: FocusScopeProps['trapped'];
1445
+ trapFocus?: boolean;
1447
1446
  /**
1448
1447
  * Event handler called when auto-focusing on open.
1449
1448
  * Can be prevented.
1450
1449
  */
1451
- onOpenAutoFocus?: FocusScopeProps['onMountAutoFocus'];
1450
+ onOpenAutoFocus?: TrapFocusOptions['onActivate'];
1452
1451
  /**
1453
1452
  * Event handler called when auto-focusing on close.
1454
1453
  * Can be prevented.
1455
1454
  */
1456
- onCloseAutoFocus?: FocusScopeProps['onUnmountAutoFocus'];
1455
+ onCloseAutoFocus?: TrapFocusOptions['onDeactivate'];
1457
1456
  }
1458
1457
 
1459
1458
  declare interface DialogContentProps extends DialogContentTypeProps {
@@ -2717,8 +2716,6 @@ export declare const FeedbackProvider: React.FC<{
2717
2716
  children: React.ReactNode;
2718
2717
  }>;
2719
2718
 
2720
- declare type FocusScopeProps = React_2.ComponentPropsWithoutRef<typeof FocusScope>;
2721
-
2722
2719
  declare type FormErrors = Record<'title' | 'content', string | undefined>;
2723
2720
 
2724
2721
  export declare interface FormFieldContextValue extends FormFieldCtx {
package/dist/index.d.ts CHANGED
@@ -22,7 +22,6 @@ import { FeebackReason } from '@inkeep/cxkit-types';
22
22
  import { FeedbackItemType } from '@inkeep/cxkit-types';
23
23
  import { FeedbackType } from '@inkeep/cxkit-types';
24
24
  import { FieldErrors } from 'react-hook-form';
25
- import { FocusScope } from '@radix-ui/react-focus-scope';
26
25
  import { FormField } from '@inkeep/cxkit-types';
27
26
  import { FormHTMLAttributes } from 'react';
28
27
  import { ForwardRefExoticComponent } from 'react';
@@ -54,7 +53,6 @@ import * as PopoverPrimitive from '@radix-ui/react-popover';
54
53
  import { Portal as Portal_2 } from '@radix-ui/react-portal';
55
54
  import { Primitive } from '@radix-ui/react-primitive';
56
55
  import { PropsWithChildren } from 'react';
57
- import * as RadixDialog from '@radix-ui/react-dialog';
58
56
  import * as React_2 from 'react';
59
57
  import { ReactElement } from 'react';
60
58
  import { ReactNode } from 'react';
@@ -74,6 +72,7 @@ import { ToolCallAction } from '@inkeep/cxkit-types';
74
72
  import * as TooltipPrimitive from '@radix-ui/react-tooltip';
75
73
  import { TopLevelHeading } from '@inkeep/cxkit-types';
76
74
  import { TransformedSource } from '@inkeep/cxkit-types';
75
+ import { TrapFocusOptions } from '@zag-js/focus-trap';
77
76
  import { UrlQueryParam } from '@inkeep/cxkit-types';
78
77
  import { UserProperties as UserProperties_2 } from '@inkeep/cxkit-types';
79
78
  import { Workflow } from '@inkeep/cxkit-types';
@@ -548,7 +547,7 @@ export declare const Command: React_2.ForwardRefExoticComponent<Children & Omit<
548
547
  /** Whether this separator should always be rendered. Useful if you disable automatic filtering. */
549
548
  alwaysRender?: boolean;
550
549
  } & React_2.RefAttributes<HTMLDivElement>>;
551
- Dialog: React_2.ForwardRefExoticComponent<RadixDialog.DialogProps & Children & Omit<React_2.ClassAttributes<HTMLDivElement> & React_2.HTMLAttributes<HTMLDivElement> & {
550
+ Dialog: React_2.ForwardRefExoticComponent<DialogPrimitive.DialogProps & Children & Omit<React_2.ClassAttributes<HTMLDivElement> & React_2.HTMLAttributes<HTMLDivElement> & {
552
551
  asChild?: boolean;
553
552
  }, "ref"> & {
554
553
  /**
@@ -620,7 +619,7 @@ export declare const Command: React_2.ForwardRefExoticComponent<Children & Omit<
620
619
  /**
621
620
  * Renders the command menu in a Radix Dialog.
622
621
  */
623
- export declare const CommandDialog: React_2.ForwardRefExoticComponent<RadixDialog.DialogProps & Children & Omit<React_2.ClassAttributes<HTMLDivElement> & React_2.HTMLAttributes<HTMLDivElement> & {
622
+ export declare const CommandDialog: React_2.ForwardRefExoticComponent<DialogPrimitive.DialogProps & Children & Omit<React_2.ClassAttributes<HTMLDivElement> & React_2.HTMLAttributes<HTMLDivElement> & {
624
623
  asChild?: boolean;
625
624
  }, "ref"> & {
626
625
  /**
@@ -1443,17 +1442,17 @@ declare interface DialogContentImplProps extends Omit<DismissableLayerProps, 'on
1443
1442
  * pointer, or a programmatic focus.
1444
1443
  * @defaultValue false
1445
1444
  */
1446
- trapFocus?: FocusScopeProps['trapped'];
1445
+ trapFocus?: boolean;
1447
1446
  /**
1448
1447
  * Event handler called when auto-focusing on open.
1449
1448
  * Can be prevented.
1450
1449
  */
1451
- onOpenAutoFocus?: FocusScopeProps['onMountAutoFocus'];
1450
+ onOpenAutoFocus?: TrapFocusOptions['onActivate'];
1452
1451
  /**
1453
1452
  * Event handler called when auto-focusing on close.
1454
1453
  * Can be prevented.
1455
1454
  */
1456
- onCloseAutoFocus?: FocusScopeProps['onUnmountAutoFocus'];
1455
+ onCloseAutoFocus?: TrapFocusOptions['onDeactivate'];
1457
1456
  }
1458
1457
 
1459
1458
  declare interface DialogContentProps extends DialogContentTypeProps {
@@ -2717,8 +2716,6 @@ export declare const FeedbackProvider: React.FC<{
2717
2716
  children: React.ReactNode;
2718
2717
  }>;
2719
2718
 
2720
- declare type FocusScopeProps = React_2.ComponentPropsWithoutRef<typeof FocusScope>;
2721
-
2722
2719
  declare type FormErrors = Record<'title' | 'content', string | undefined>;
2723
2720
 
2724
2721
  export declare interface FormFieldContextValue extends FormFieldCtx {
@@ -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"),f=require("./user-provider.cjs"),d=t.createContext(void 0),b=({children:e})=>{const{baseSettings:n,componentType:o}=B.useInkeepConfig(),{apiKey:r,analyticsApiBaseUrl:i,tags:c,privacyPreferences:E,env:g}=n,{userProperties:a}=f.useUser(),v=t.useMemo(()=>({widgetLibraryVersion:"0.5.48",componentType:o,tags:c}),[o,c]),u=!E.optOutAllAnalytics&&g!=="development",m={logEvent:t.useCallback(async l=>{const s={...v,...l.properties},p={eventName:l.eventName,properties:s,userProperties:a};if(u){if("conversation"in s&&!s.conversation?.id)return;y.logEvent(p,r,i)}n.onEvent?.(p)},[u,n,r,i,a,v])};return P.jsx(d.Provider,{value:m,children:e})},x=()=>{const e=t.useContext(d);if(!e)throw new Error("useBaseEvents must be used within a BaseEventsProvider");return e};exports.BaseEventsProvider=b;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"),f=require("./user-provider.cjs"),d=t.createContext(void 0),b=({children:e})=>{const{baseSettings:n,componentType:o}=B.useInkeepConfig(),{apiKey:r,analyticsApiBaseUrl:i,tags:c,privacyPreferences:E,env:g}=n,{userProperties:a}=f.useUser(),v=t.useMemo(()=>({widgetLibraryVersion:"0.5.50",componentType:o,tags:c}),[o,c]),u=!E.optOutAllAnalytics&&g!=="development",m={logEvent:t.useCallback(async l=>{const s={...v,...l.properties},p={eventName:l.eventName,properties:s,userProperties:a};if(u){if("conversation"in s&&!s.conversation?.id)return;y.logEvent(p,r,i)}n.onEvent?.(p)},[u,n,r,i,a,v])};return P.jsx(d.Provider,{value:m,children:e})},x=()=>{const e=t.useContext(d);if(!e)throw new Error("useBaseEvents must be used within a BaseEventsProvider");return e};exports.BaseEventsProvider=b;exports.useBaseEvents=x;
@@ -7,7 +7,7 @@ import { useUser as b } from "./user-provider.js";
7
7
  const u = x(void 0), U = ({ children: e }) => {
8
8
  const { baseSettings: t, componentType: n } = C(), { apiKey: s, analyticsApiBaseUrl: r, tags: i, privacyPreferences: l, env: E } = t, { userProperties: a } = b(), c = g(
9
9
  () => ({
10
- widgetLibraryVersion: "0.5.48",
10
+ widgetLibraryVersion: "0.5.50",
11
11
  componentType: n,
12
12
  tags: i
13
13
  }),
@@ -1 +1 @@
1
- "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react/jsx-runtime"),t=require("react"),j=require("../atoms/api/analytics/conversation.cjs"),w=require("./config-provider.cjs"),B=require("./conversation-provider.cjs"),k=require("./user-provider.cjs"),f=require("./base-events-provider.cjs"),g=t.createContext(void 0),b=({children:e})=>{const{baseSettings:x}=w.useInkeepConfig(),{apiKey:l,analyticsApiBaseUrl:C,tags:d,privacyPreferences:{optOutAllAnalytics:i},env:a}=x,{userProperties:E}=k.useUser(),{logEvent:h}=f.useBaseEvents(),{conversation:o,setConversation:y}=B.useInkeepConversation(),p=t.useRef(o);t.useEffect(()=>{p.current=o},[o]);const c=t.useCallback(async n=>{const s=p.current,v=!i&&a!=="development";let r=Object.assign({},s,{messages:n});if(v){const P=await j.logConversation(s.id,{messages:n,tags:d,userProperties:E},l,C);P&&(r=P)}return r},[C,l,d,E,i,a]),q={logEvent:t.useCallback(async(n,s)=>{if(s){const r=await c(s);y(r)}const v={...n,properties:{conversation:o,...n.properties}};h(v)},[h,c,i,a]),logConversation:c};return u.jsx(g.Provider,{value:q,children:e})},A=({children:e})=>u.jsx(f.BaseEventsProvider,{children:u.jsx(b,{children:e})}),O=()=>{const e=t.useContext(g);if(!e)throw new Error("useChatEvents must be used within a ChatEventsProvider");return e};exports.ChatEventsProvider=b;exports.ChatEventsProviderWithBase=A;exports.useChatEvents=O;
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),t=require("react"),j=require("../atoms/api/analytics/conversation.cjs"),w=require("./config-provider.cjs"),B=require("./conversation-provider.cjs"),k=require("./user-provider.cjs"),f=require("./base-events-provider.cjs"),g=t.createContext(void 0),b=({children:e})=>{const{baseSettings:x}=w.useInkeepConfig(),{apiKey:C,analyticsApiBaseUrl:d,tags:E,privacyPreferences:{optOutAllAnalytics:i},env:a}=x,{userProperties:h}=k.useUser(),{logEvent:p}=f.useBaseEvents(),{conversation:c,setConversation:y}=B.useInkeepConversation(),v=t.useRef(c);t.useEffect(()=>{v.current=c},[c]);const u=t.useCallback(async n=>{const s=v.current,r=!i&&a!=="development";let o=Object.assign({},s,{messages:n});if(r){const P=await j.logConversation(s.id,{messages:n,tags:E,userProperties:h},C,d);P&&(o=P)}return o},[d,C,E,h,i,a]),q={logEvent:t.useCallback(async(n,s)=>{let r=v.current;s&&(r=await u(s),y(r));const o={...n,properties:{conversation:r,...n.properties}};p(o)},[p,u,i,a]),logConversation:u};return l.jsx(g.Provider,{value:q,children:e})},A=({children:e})=>l.jsx(f.BaseEventsProvider,{children:l.jsx(b,{children:e})}),O=()=>{const e=t.useContext(g);if(!e)throw new Error("useChatEvents must be used within a ChatEventsProvider");return e};exports.ChatEventsProvider=b;exports.ChatEventsProviderWithBase=A;exports.useChatEvents=O;
@@ -1,65 +1,63 @@
1
1
  "use client";
2
- import { jsx as v } from "react/jsx-runtime";
3
- import { useRef as y, useEffect as w, useCallback as m, createContext as b, useContext as B } from "react";
2
+ import { jsx as u } from "react/jsx-runtime";
3
+ import { useRef as y, useEffect as w, useCallback as h, createContext as b, useContext as B } from "react";
4
4
  import { logConversation as k } from "../atoms/api/analytics/conversation.js";
5
5
  import { useInkeepConfig as A } from "./config-provider.js";
6
6
  import { useInkeepConversation as j } from "./conversation-provider.js";
7
7
  import { useUser as I } from "./user-provider.js";
8
8
  import { useBaseEvents as O, BaseEventsProvider as U } from "./base-events-provider.js";
9
- const d = b(void 0), K = ({ children: t }) => {
9
+ const m = b(void 0), K = ({ children: t }) => {
10
10
  const { baseSettings: g } = A(), {
11
- apiKey: u,
12
- analyticsApiBaseUrl: p,
13
- tags: l,
11
+ apiKey: p,
12
+ analyticsApiBaseUrl: l,
13
+ tags: C,
14
14
  privacyPreferences: { optOutAllAnalytics: s },
15
15
  env: i
16
- } = g, { userProperties: C } = I(), { logEvent: f } = O(), { conversation: o, setConversation: P } = j(), E = y(o);
16
+ } = g, { userProperties: f } = I(), { logEvent: E } = O(), { conversation: a, setConversation: P } = j(), c = y(a);
17
17
  w(() => {
18
- E.current = o;
19
- }, [o]);
20
- const a = m(
18
+ c.current = a;
19
+ }, [a]);
20
+ const v = h(
21
21
  async (e) => {
22
- const n = E.current, c = !s && i !== "development";
22
+ const n = c.current, o = !s && i !== "development";
23
23
  let r = Object.assign({}, n, { messages: e });
24
- if (c) {
25
- const h = await k(
24
+ if (o) {
25
+ const d = await k(
26
26
  n.id,
27
27
  {
28
28
  messages: e,
29
- tags: l,
30
- userProperties: C
29
+ tags: C,
30
+ userProperties: f
31
31
  },
32
- u,
33
- p
32
+ p,
33
+ l
34
34
  );
35
- h && (r = h);
35
+ d && (r = d);
36
36
  }
37
37
  return r;
38
38
  },
39
- [p, u, l, C, s, i]
39
+ [l, p, C, f, s, i]
40
40
  ), x = {
41
- logEvent: m(
41
+ logEvent: h(
42
42
  async (e, n) => {
43
- if (n) {
44
- const r = await a(n);
45
- P(r);
46
- }
47
- const c = {
43
+ let o = c.current;
44
+ n && (o = await v(n), P(o));
45
+ const r = {
48
46
  ...e,
49
47
  properties: {
50
48
  conversation: o,
51
49
  ...e.properties
52
50
  }
53
51
  };
54
- f(c);
52
+ E(r);
55
53
  },
56
- [f, a, s, i]
54
+ [E, v, s, i]
57
55
  ),
58
- logConversation: a
56
+ logConversation: v
59
57
  };
60
- return /* @__PURE__ */ v(d.Provider, { value: x, children: t });
61
- }, F = ({ children: t }) => /* @__PURE__ */ v(U, { children: /* @__PURE__ */ v(K, { children: t }) }), G = () => {
62
- const t = B(d);
58
+ return /* @__PURE__ */ u(m.Provider, { value: x, children: t });
59
+ }, F = ({ children: t }) => /* @__PURE__ */ u(U, { children: /* @__PURE__ */ u(K, { children: t }) }), G = () => {
60
+ const t = B(m);
63
61
  if (!t)
64
62
  throw new Error("useChatEvents must be used within a ChatEventsProvider");
65
63
  return t;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inkeep/cxkit-primitives",
3
- "version": "0.5.48",
3
+ "version": "0.5.50",
4
4
  "description": "",
5
5
  "license": "Inkeep, Inc. Customer License (IICL) v1.1",
6
6
  "homepage": "",
@@ -25,25 +25,25 @@
25
25
  "@radix-ui/react-checkbox": "1.1.3",
26
26
  "@radix-ui/react-compose-refs": "^1.1.1",
27
27
  "@radix-ui/react-context": "^1.1.1",
28
- "@radix-ui/react-dialog": "1.1.4",
29
28
  "@radix-ui/react-dismissable-layer": "^1.1.5",
30
29
  "@radix-ui/react-focus-guards": "^1.1.1",
31
30
  "@radix-ui/react-focus-scope": "^1.1.2",
32
31
  "@radix-ui/react-hover-card": "^1.1.6",
33
32
  "@radix-ui/react-id": "^1.1.0",
34
- "@radix-ui/react-popover": "1.1.4",
33
+ "@radix-ui/react-popover": "1.1.6",
35
34
  "@radix-ui/react-portal": "^1.1.4",
36
35
  "@radix-ui/react-presence": "^1.1.2",
37
36
  "@radix-ui/react-primitive": "^2.0.2",
38
37
  "@radix-ui/react-scroll-area": "1.2.2",
39
- "@radix-ui/react-select": "2.1.4",
38
+ "@radix-ui/react-select": "2.1.6",
40
39
  "@radix-ui/react-slot": "^1.1.2",
41
40
  "@radix-ui/react-tabs": "1.1.2",
42
41
  "@radix-ui/react-tooltip": "1.1.6",
42
+ "@radix-ui/react-use-callback-ref": "^1.1.0",
43
43
  "@radix-ui/react-use-controllable-state": "^1.1.0",
44
+ "@zag-js/focus-trap": "^1.7.0",
44
45
  "altcha-lib": "^1.2.0",
45
46
  "aria-hidden": "^1.2.4",
46
- "cmdk": "^1.0.4",
47
47
  "dequal": "^2.0.3",
48
48
  "humps": "2.0.1",
49
49
  "merge-anything": "5.1.7",
@@ -59,9 +59,9 @@
59
59
  "remark-gfm": "^4.0.1",
60
60
  "unist-util-visit": "^5.0.0",
61
61
  "use-sync-external-store": "^1.4.0",
62
- "@inkeep/cxkit-color-mode": "0.5.48",
63
- "@inkeep/cxkit-theme": "0.5.48",
64
- "@inkeep/cxkit-types": "0.5.48"
62
+ "@inkeep/cxkit-color-mode": "0.5.50",
63
+ "@inkeep/cxkit-theme": "0.5.50",
64
+ "@inkeep/cxkit-types": "0.5.50"
65
65
  },
66
66
  "devDependencies": {
67
67
  "@biomejs/biome": "1.9.4",