@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.
- package/dist/atoms/cmdk/index.cjs +1 -1
- package/dist/atoms/cmdk/index.js +183 -183
- package/dist/atoms/dialog.cjs +1 -1
- package/dist/atoms/dialog.js +130 -131
- package/dist/components/embedded-chat/use-inkeep-chat.cjs +3 -3
- package/dist/components/embedded-chat/use-inkeep-chat.js +52 -52
- package/dist/index.d.cts +6 -9
- package/dist/index.d.ts +6 -9
- 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.js +29 -31
- package/package.json +8 -8
package/dist/atoms/dialog.cjs
CHANGED
|
@@ -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 i=require("react/jsx-runtime"),T=require("react"),p=require("@radix-ui/primitive"),P=require("@radix-ui/react-compose-refs"),H=require("@radix-ui/react-context"),m=require("@radix-ui/react-id"),z=require("@radix-ui/react-use-controllable-state"),K=require("@radix-ui/react-dismissable-layer"),U=require("@zag-js/focus-trap"),V=require("@radix-ui/react-portal"),_=require("@radix-ui/react-presence"),g=require("@radix-ui/react-primitive"),Y=require("@radix-ui/react-focus-guards"),Z=require("react-remove-scroll"),B=require("aria-hidden"),J=require("@radix-ui/react-slot");function Q(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,s.get?s:{enumerable:!0,get:()=>e[t]})}}return n.default=e,Object.freeze(n)}const c=Q(T),x="Dialog",[N,W]=H.createContextScope(x),[X,l]=N(x),O=e=>{const{__scopeDialog:n,children:t,open:s,defaultOpen:o,onOpenChange:r,modal:a=!0}=e,u=c.useRef(null),f=c.useRef(null),[R=!1,C]=z.useControllableState({prop:s,defaultProp:o,onChange:r});return i.jsx(X,{scope:n,triggerRef:u,contentRef:f,contentId:m.useId(),titleId:m.useId(),descriptionId:m.useId(),open:R,onOpenChange:C,onOpenToggle:c.useCallback(()=>C(G=>!G),[C]),modal:a,children:t})};O.displayName=x;const M="DialogTrigger",S=c.forwardRef((e,n)=>{const{__scopeDialog:t,...s}=e,o=l(M,t),r=P.useComposedRefs(n,o.triggerRef);return i.jsx(g.Primitive.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":j(o.open),...s,ref:r,onClick:p.composeEventHandlers(e.onClick,o.onOpenToggle)})});S.displayName=M;const v="DialogPortal",[$,q]=N(v,{forceMount:void 0}),y=e=>{const{__scopeDialog:n,forceMount:t,children:s,container:o}=e,r=l(v,n);return i.jsx($,{scope:n,forceMount:t,children:c.Children.map(s,a=>i.jsx(_.Presence,{present:t||r.open,children:i.jsx(V.Portal,{asChild:!0,container:o,children:a})}))})};y.displayName=v;const D="DialogOverlay",E=c.forwardRef((e,n)=>{const t=q(D,e.__scopeDialog),{forceMount:s=t.forceMount,...o}=e,r=l(D,e.__scopeDialog);return r.modal?i.jsx(_.Presence,{present:s||r.open,children:i.jsx(ee,{...o,ref:n})}):null});E.displayName=D;const ee=c.forwardRef((e,n)=>{const{__scopeDialog:t,...s}=e,o=l(D,t);return i.jsx(Z.RemoveScroll,{as:J.Slot,allowPinchZoom:!0,shards:[o.contentRef],children:i.jsx(g.Primitive.div,{"data-state":j(o.open),...s,ref:n,style:{pointerEvents:"auto",...s.style}})})}),d="DialogContent",b=c.forwardRef((e,n)=>{const t=q(d,e.__scopeDialog),{forceMount:s=t.forceMount,...o}=e,r=l(d,e.__scopeDialog);return i.jsx(_.Presence,{present:s||r.open,children:r.modal?i.jsx(te,{...o,ref:n}):i.jsx(oe,{...o,ref:n})})});b.displayName=d;const te=c.forwardRef((e,n)=>{const t=l(d,e.__scopeDialog),s=c.useRef(null),o=P.useComposedRefs(n,t.contentRef,s);return c.useEffect(()=>{const r=s.current;if(r)return B.hideOthers(r)},[]),i.jsx(w,{...e,ref:o,trapFocus:t.open,disableOutsidePointerEvents:!0,onPointerDownOutside:p.composeEventHandlers(e.onPointerDownOutside,r=>{const a=r.detail.originalEvent,u=a.button===0&&a.ctrlKey===!0;(a.button===2||u)&&r.preventDefault()}),onFocusOutside:p.composeEventHandlers(e.onFocusOutside,r=>r.preventDefault())})}),oe=c.forwardRef((e,n)=>{const t=l(d,e.__scopeDialog),s=c.useRef(!1),o=c.useRef(!1);return i.jsx(w,{...e,ref:n,trapFocus:!1,disableOutsidePointerEvents:!1,onInteractOutside:r=>{e.onInteractOutside?.(r),r.defaultPrevented||(s.current=!0,r.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const a=r.target;t.triggerRef.current?.contains(a)&&r.preventDefault(),r.detail.originalEvent.type==="focusin"&&o.current&&r.preventDefault()}})}),w=c.forwardRef((e,n)=>{const{__scopeDialog:t,trapFocus:s,onOpenAutoFocus:o,onCloseAutoFocus:r,...a}=e,u=l(d,t),f=c.useRef(null),R=P.useComposedRefs(n,f);return Y.useFocusGuards(),T.useEffect(()=>{if(s)return U.trapFocus(f.current,{preventScroll:!0,onActivate:o,onDeactivate:r})},[]),i.jsx(K.DismissableLayer,{role:"dialog",id:u.contentId,"aria-describedby":u.descriptionId,"aria-labelledby":u.titleId,"data-state":j(u.open),...a,ref:R,onDismiss:()=>u.onOpenChange(!1)})}),A="DialogTitle",h=c.forwardRef((e,n)=>{const{__scopeDialog:t,...s}=e,o=l(A,t);return i.jsx(g.Primitive.h2,{id:o.titleId,...s,ref:n})});h.displayName=A;const F="DialogDescription",k=c.forwardRef((e,n)=>{const{__scopeDialog:t,...s}=e,o=l(F,t);return i.jsx(g.Primitive.p,{id:o.descriptionId,...s,ref:n})});k.displayName=F;const L="DialogClose",I=c.forwardRef((e,n)=>{const{__scopeDialog:t,...s}=e,o=l(L,t);return i.jsx(g.Primitive.button,{type:"button",...s,ref:n,onClick:p.composeEventHandlers(e.onClick,()=>o.onOpenChange(!1))})});I.displayName=L;function j(e){return e?"open":"closed"}const ne=O,re=y,se=E,ce=b,ie=h,ae=I;exports.Close=ae;exports.Content=ce;exports.Dialog=O;exports.DialogClose=I;exports.DialogContent=b;exports.DialogDescription=k;exports.DialogOverlay=E;exports.DialogPortal=y;exports.DialogTitle=h;exports.DialogTrigger=S;exports.Overlay=se;exports.Portal=re;exports.Root=ne;exports.Title=ie;exports.createDialogScope=W;
|
package/dist/atoms/dialog.js
CHANGED
|
@@ -1,216 +1,215 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as i
|
|
2
|
+
import { jsx as i } from "react/jsx-runtime";
|
|
3
3
|
import * as c from "react";
|
|
4
|
-
import {
|
|
4
|
+
import { useEffect as G } from "react";
|
|
5
|
+
import { composeEventHandlers as g } from "@radix-ui/primitive";
|
|
5
6
|
import { useComposedRefs as _ } from "@radix-ui/react-compose-refs";
|
|
6
|
-
import { createContextScope as
|
|
7
|
+
import { createContextScope as $ } from "@radix-ui/react-context";
|
|
7
8
|
import { useId as C } from "@radix-ui/react-id";
|
|
8
|
-
import { useControllableState as
|
|
9
|
-
import { DismissableLayer as
|
|
10
|
-
import {
|
|
11
|
-
import "@radix-ui/react-portal";
|
|
12
|
-
import { Presence as
|
|
13
|
-
import { Primitive as
|
|
14
|
-
import { useFocusGuards as
|
|
15
|
-
import { RemoveScroll as
|
|
16
|
-
import { hideOthers as
|
|
17
|
-
import { Slot as
|
|
18
|
-
const
|
|
19
|
-
const { __scopeDialog:
|
|
20
|
-
prop:
|
|
9
|
+
import { useControllableState as j } from "@radix-ui/react-use-controllable-state";
|
|
10
|
+
import { DismissableLayer as H } from "@radix-ui/react-dismissable-layer";
|
|
11
|
+
import { trapFocus as K } from "@zag-js/focus-trap";
|
|
12
|
+
import { Portal as V } from "@radix-ui/react-portal";
|
|
13
|
+
import { Presence as O } from "@radix-ui/react-presence";
|
|
14
|
+
import { Primitive as d } from "@radix-ui/react-primitive";
|
|
15
|
+
import { useFocusGuards as Y } from "@radix-ui/react-focus-guards";
|
|
16
|
+
import { RemoveScroll as Z } from "react-remove-scroll";
|
|
17
|
+
import { hideOthers as q } from "aria-hidden";
|
|
18
|
+
import { Slot as z } from "@radix-ui/react-slot";
|
|
19
|
+
const P = "Dialog", [E, Co] = $(P), [B, l] = E(P), I = (o) => {
|
|
20
|
+
const { __scopeDialog: n, children: r, open: s, defaultOpen: t, onOpenChange: e, modal: a = !0 } = o, f = c.useRef(null), p = c.useRef(null), [D = !1, R] = j({
|
|
21
|
+
prop: s,
|
|
21
22
|
defaultProp: t,
|
|
22
23
|
onChange: e
|
|
23
24
|
});
|
|
24
25
|
return /* @__PURE__ */ i(
|
|
25
|
-
|
|
26
|
+
B,
|
|
26
27
|
{
|
|
27
|
-
scope:
|
|
28
|
-
triggerRef:
|
|
29
|
-
contentRef:
|
|
28
|
+
scope: n,
|
|
29
|
+
triggerRef: f,
|
|
30
|
+
contentRef: p,
|
|
30
31
|
contentId: C(),
|
|
31
32
|
titleId: C(),
|
|
32
33
|
descriptionId: C(),
|
|
33
34
|
open: D,
|
|
34
35
|
onOpenChange: R,
|
|
35
|
-
onOpenToggle: c.useCallback(() => R((
|
|
36
|
-
modal:
|
|
36
|
+
onOpenToggle: c.useCallback(() => R((L) => !L), [R]),
|
|
37
|
+
modal: a,
|
|
37
38
|
children: r
|
|
38
39
|
}
|
|
39
40
|
);
|
|
40
41
|
};
|
|
41
|
-
|
|
42
|
-
const
|
|
43
|
-
(o,
|
|
44
|
-
const { __scopeDialog: r, ...
|
|
42
|
+
I.displayName = P;
|
|
43
|
+
const v = "DialogTrigger", J = c.forwardRef(
|
|
44
|
+
(o, n) => {
|
|
45
|
+
const { __scopeDialog: r, ...s } = o, t = l(v, r), e = _(n, t.triggerRef);
|
|
45
46
|
return /* @__PURE__ */ i(
|
|
46
|
-
|
|
47
|
+
d.button,
|
|
47
48
|
{
|
|
48
49
|
type: "button",
|
|
49
50
|
"aria-haspopup": "dialog",
|
|
50
51
|
"aria-expanded": t.open,
|
|
51
52
|
"aria-controls": t.contentId,
|
|
52
|
-
"data-state":
|
|
53
|
-
...
|
|
53
|
+
"data-state": y(t.open),
|
|
54
|
+
...s,
|
|
54
55
|
ref: e,
|
|
55
|
-
onClick:
|
|
56
|
+
onClick: g(o.onClick, t.onOpenToggle)
|
|
56
57
|
}
|
|
57
58
|
);
|
|
58
59
|
}
|
|
59
60
|
);
|
|
60
|
-
|
|
61
|
-
const
|
|
61
|
+
J.displayName = v;
|
|
62
|
+
const h = "DialogPortal", [Q, x] = E(h, {
|
|
62
63
|
forceMount: void 0
|
|
63
|
-
}),
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
}), N = (o) => {
|
|
65
|
+
const { __scopeDialog: n, forceMount: r, children: s, container: t } = o, e = l(h, n);
|
|
66
|
+
return /* @__PURE__ */ i(Q, { scope: n, forceMount: r, children: c.Children.map(s, (a) => /* @__PURE__ */ i(O, { present: r || e.open, children: /* @__PURE__ */ i(V, { asChild: !0, container: t, children: a }) })) });
|
|
67
|
+
};
|
|
68
|
+
N.displayName = h;
|
|
69
|
+
const m = "DialogOverlay", T = c.forwardRef(
|
|
70
|
+
(o, n) => {
|
|
71
|
+
const r = x(m, o.__scopeDialog), { forceMount: s = r.forceMount, ...t } = o, e = l(m, o.__scopeDialog);
|
|
72
|
+
return e.modal ? /* @__PURE__ */ i(O, { present: s || e.open, children: /* @__PURE__ */ i(U, { ...t, ref: n }) }) : null;
|
|
67
73
|
}
|
|
68
74
|
);
|
|
69
|
-
|
|
70
|
-
const
|
|
71
|
-
(o,
|
|
72
|
-
const { __scopeDialog: r, ...
|
|
75
|
+
T.displayName = m;
|
|
76
|
+
const U = c.forwardRef(
|
|
77
|
+
(o, n) => {
|
|
78
|
+
const { __scopeDialog: r, ...s } = o, t = l(m, r);
|
|
73
79
|
return (
|
|
74
80
|
// Make sure `Content` is scrollable even when it doesn't live inside `RemoveScroll`
|
|
75
81
|
// ie. when `Overlay` and `Content` are siblings
|
|
76
|
-
/* @__PURE__ */ i(
|
|
77
|
-
|
|
82
|
+
/* @__PURE__ */ i(Z, { as: z, allowPinchZoom: !0, shards: [t.contentRef], children: /* @__PURE__ */ i(
|
|
83
|
+
d.div,
|
|
78
84
|
{
|
|
79
|
-
"data-state":
|
|
80
|
-
...
|
|
81
|
-
ref:
|
|
82
|
-
style: { pointerEvents: "auto", ...
|
|
85
|
+
"data-state": y(t.open),
|
|
86
|
+
...s,
|
|
87
|
+
ref: n,
|
|
88
|
+
style: { pointerEvents: "auto", ...s.style }
|
|
83
89
|
}
|
|
84
90
|
) })
|
|
85
91
|
);
|
|
86
92
|
}
|
|
87
|
-
),
|
|
88
|
-
(o,
|
|
89
|
-
const r =
|
|
90
|
-
return /* @__PURE__ */ i(
|
|
93
|
+
), u = "DialogContent", M = c.forwardRef(
|
|
94
|
+
(o, n) => {
|
|
95
|
+
const r = x(u, o.__scopeDialog), { forceMount: s = r.forceMount, ...t } = o, e = l(u, o.__scopeDialog);
|
|
96
|
+
return /* @__PURE__ */ i(O, { present: s || e.open, children: e.modal ? /* @__PURE__ */ i(W, { ...t, ref: n }) : /* @__PURE__ */ i(X, { ...t, ref: n }) });
|
|
91
97
|
}
|
|
92
98
|
);
|
|
93
|
-
|
|
94
|
-
const
|
|
95
|
-
(o,
|
|
96
|
-
const r = l(
|
|
99
|
+
M.displayName = u;
|
|
100
|
+
const W = c.forwardRef(
|
|
101
|
+
(o, n) => {
|
|
102
|
+
const r = l(u, o.__scopeDialog), s = c.useRef(null), t = _(n, r.contentRef, s);
|
|
97
103
|
return c.useEffect(() => {
|
|
98
|
-
const e =
|
|
99
|
-
if (e) return
|
|
104
|
+
const e = s.current;
|
|
105
|
+
if (e) return q(e);
|
|
100
106
|
}, []), /* @__PURE__ */ i(
|
|
101
|
-
|
|
107
|
+
b,
|
|
102
108
|
{
|
|
103
109
|
...o,
|
|
104
110
|
ref: t,
|
|
105
111
|
trapFocus: r.open,
|
|
106
112
|
disableOutsidePointerEvents: !0,
|
|
107
|
-
|
|
108
|
-
e.
|
|
109
|
-
|
|
110
|
-
onPointerDownOutside: d(o.onPointerDownOutside, (e) => {
|
|
111
|
-
const u = e.detail.originalEvent, a = u.button === 0 && u.ctrlKey === !0;
|
|
112
|
-
(u.button === 2 || a) && e.preventDefault();
|
|
113
|
+
onPointerDownOutside: g(o.onPointerDownOutside, (e) => {
|
|
114
|
+
const a = e.detail.originalEvent, f = a.button === 0 && a.ctrlKey === !0;
|
|
115
|
+
(a.button === 2 || f) && e.preventDefault();
|
|
113
116
|
}),
|
|
114
|
-
onFocusOutside:
|
|
117
|
+
onFocusOutside: g(
|
|
115
118
|
o.onFocusOutside,
|
|
116
119
|
(e) => e.preventDefault()
|
|
117
120
|
)
|
|
118
121
|
}
|
|
119
122
|
);
|
|
120
123
|
}
|
|
121
|
-
),
|
|
122
|
-
(o,
|
|
123
|
-
const r = l(
|
|
124
|
+
), X = c.forwardRef(
|
|
125
|
+
(o, n) => {
|
|
126
|
+
const r = l(u, o.__scopeDialog), s = c.useRef(!1), t = c.useRef(!1);
|
|
124
127
|
return /* @__PURE__ */ i(
|
|
125
|
-
|
|
128
|
+
b,
|
|
126
129
|
{
|
|
127
130
|
...o,
|
|
128
|
-
ref:
|
|
131
|
+
ref: n,
|
|
129
132
|
trapFocus: !1,
|
|
130
133
|
disableOutsidePointerEvents: !1,
|
|
131
|
-
onCloseAutoFocus: (e) => {
|
|
132
|
-
o.onCloseAutoFocus?.(e), e.defaultPrevented || (n.current || r.triggerRef.current?.focus(), e.preventDefault()), n.current = !1, t.current = !1;
|
|
133
|
-
},
|
|
134
134
|
onInteractOutside: (e) => {
|
|
135
|
-
o.onInteractOutside?.(e), e.defaultPrevented || (
|
|
136
|
-
const
|
|
137
|
-
r.triggerRef.current?.contains(
|
|
135
|
+
o.onInteractOutside?.(e), e.defaultPrevented || (s.current = !0, e.detail.originalEvent.type === "pointerdown" && (t.current = !0));
|
|
136
|
+
const a = e.target;
|
|
137
|
+
r.triggerRef.current?.contains(a) && e.preventDefault(), e.detail.originalEvent.type === "focusin" && t.current && e.preventDefault();
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
140
|
);
|
|
141
141
|
}
|
|
142
|
-
),
|
|
143
|
-
(o,
|
|
144
|
-
const { __scopeDialog: r, trapFocus:
|
|
145
|
-
return
|
|
142
|
+
), b = c.forwardRef(
|
|
143
|
+
(o, n) => {
|
|
144
|
+
const { __scopeDialog: r, trapFocus: s, onOpenAutoFocus: t, onCloseAutoFocus: e, ...a } = o, f = l(u, r), p = c.useRef(null), D = _(n, p);
|
|
145
|
+
return Y(), G(() => {
|
|
146
|
+
if (s)
|
|
147
|
+
return K(p.current, {
|
|
148
|
+
preventScroll: !0,
|
|
149
|
+
onActivate: t,
|
|
150
|
+
onDeactivate: e
|
|
151
|
+
});
|
|
152
|
+
}, []), /* @__PURE__ */ i(
|
|
146
153
|
H,
|
|
147
154
|
{
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
role: "dialog",
|
|
157
|
-
id: a.contentId,
|
|
158
|
-
"aria-describedby": a.descriptionId,
|
|
159
|
-
"aria-labelledby": a.titleId,
|
|
160
|
-
"data-state": P(a.open),
|
|
161
|
-
...u,
|
|
162
|
-
ref: D,
|
|
163
|
-
onDismiss: () => a.onOpenChange(!1)
|
|
164
|
-
}
|
|
165
|
-
)
|
|
155
|
+
role: "dialog",
|
|
156
|
+
id: f.contentId,
|
|
157
|
+
"aria-describedby": f.descriptionId,
|
|
158
|
+
"aria-labelledby": f.titleId,
|
|
159
|
+
"data-state": y(f.open),
|
|
160
|
+
...a,
|
|
161
|
+
ref: D,
|
|
162
|
+
onDismiss: () => f.onOpenChange(!1)
|
|
166
163
|
}
|
|
167
|
-
)
|
|
164
|
+
);
|
|
168
165
|
}
|
|
169
|
-
),
|
|
170
|
-
(o,
|
|
171
|
-
const { __scopeDialog: r, ...
|
|
172
|
-
return /* @__PURE__ */ i(
|
|
166
|
+
), w = "DialogTitle", A = c.forwardRef(
|
|
167
|
+
(o, n) => {
|
|
168
|
+
const { __scopeDialog: r, ...s } = o, t = l(w, r);
|
|
169
|
+
return /* @__PURE__ */ i(d.h2, { id: t.titleId, ...s, ref: n });
|
|
173
170
|
}
|
|
174
171
|
);
|
|
175
|
-
|
|
176
|
-
const
|
|
177
|
-
(o,
|
|
178
|
-
const { __scopeDialog: r, ...
|
|
179
|
-
return /* @__PURE__ */ i(
|
|
172
|
+
A.displayName = w;
|
|
173
|
+
const F = "DialogDescription", oo = c.forwardRef(
|
|
174
|
+
(o, n) => {
|
|
175
|
+
const { __scopeDialog: r, ...s } = o, t = l(F, r);
|
|
176
|
+
return /* @__PURE__ */ i(d.p, { id: t.descriptionId, ...s, ref: n });
|
|
180
177
|
}
|
|
181
178
|
);
|
|
182
|
-
|
|
183
|
-
const
|
|
184
|
-
(o,
|
|
185
|
-
const { __scopeDialog: r, ...
|
|
179
|
+
oo.displayName = F;
|
|
180
|
+
const S = "DialogClose", k = c.forwardRef(
|
|
181
|
+
(o, n) => {
|
|
182
|
+
const { __scopeDialog: r, ...s } = o, t = l(S, r);
|
|
186
183
|
return /* @__PURE__ */ i(
|
|
187
|
-
|
|
184
|
+
d.button,
|
|
188
185
|
{
|
|
189
186
|
type: "button",
|
|
190
|
-
...
|
|
191
|
-
ref:
|
|
192
|
-
onClick:
|
|
187
|
+
...s,
|
|
188
|
+
ref: n,
|
|
189
|
+
onClick: g(o.onClick, () => t.onOpenChange(!1))
|
|
193
190
|
}
|
|
194
191
|
);
|
|
195
192
|
}
|
|
196
193
|
);
|
|
197
|
-
|
|
198
|
-
function
|
|
194
|
+
k.displayName = S;
|
|
195
|
+
function y(o) {
|
|
199
196
|
return o ? "open" : "closed";
|
|
200
197
|
}
|
|
201
|
-
const
|
|
198
|
+
const _o = I, Oo = N, Po = T, ho = M, yo = A, Eo = k;
|
|
202
199
|
export {
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
200
|
+
Eo as Close,
|
|
201
|
+
ho as Content,
|
|
202
|
+
I as Dialog,
|
|
203
|
+
k as DialogClose,
|
|
204
|
+
M as DialogContent,
|
|
205
|
+
oo as DialogDescription,
|
|
206
|
+
T as DialogOverlay,
|
|
207
|
+
N as DialogPortal,
|
|
208
|
+
A as DialogTitle,
|
|
209
|
+
J as DialogTrigger,
|
|
210
|
+
Po as Overlay,
|
|
211
|
+
Oo as Portal,
|
|
212
|
+
_o as Root,
|
|
213
|
+
yo as Title,
|
|
214
|
+
Co as createDialogScope
|
|
216
215
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
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 Ae=require("openai"),t=require("react"),Re=require("../../providers/config-provider.cjs"),Le=require("../../providers/conversation-provider.cjs"),xe=require("../../providers/chat-events-provider.cjs"),D=require("../../utils/get-message-metadata.cjs"),Be=require("../../utils/misc.cjs"),ae=require("../../utils/reset-query-params.cjs"),De=require("../../providers/chat-form-provider.cjs"),Oe=require("../../providers/widget-provider.cjs"),Fe=require("../../hooks/use-media-query.cjs"),Te=require("./use-captcha.cjs"),Ke=require("../modal/modal-provider.cjs"),l=require("../../utils/generate-uid.cjs"),Qe=require("../../utils/tools/links-tool.cjs"),We=require("../../atoms/api/analytics/conversation.cjs"),Je=()=>{const{chatId:f,setConversation:re,conversation:N,resetConversation:ie}=Le.useInkeepConversation(),{baseSettings:b,aiChatSettings:O}=Re.useInkeepConfig(),{aiApiBaseUrl:F,shouldBypassCaptcha:T,filters:K}=b,Q=Ke.useModal(),{getSolution:ce,prefetchSolution:q,invalidateSolution:W}=Te.useCaptcha({fetchUrl:`${F}/v1/challenge`,shouldBypassCaptcha:T,shouldMakeInitialRequest:Q?Q.isOpen:!0}),ue=new Ae({baseURL:`${F}/v1`,apiKey:b.apiKey,dangerouslyAllowBrowser:!0}),{onInputMessageChange:le,getTools:ge,prompts:de,model:me,filters:J,onToolCall:fe}=O,[p,_]=t.useState(""),z=t.useRef(null);t.useEffect(()=>{le?.(p)},[p]);const[g,u]=t.useState([]),[H,h]=t.useState(!1),[pe,v]=t.useState(!1),[he,j]=t.useState(null),[A,G]=t.useState(null),[y,S]=t.useState([]),ve=e=>{S(s=>[...s,e])},[ye,V]=t.useState({}),r=t.useRef([]),C=t.useRef(null),{logEvent:P}=xe.useChatEvents(),X=de?.map((e,s)=>({id:`system-${Date.now().toString()}-${l.generateUid(4)}-${s}`,role:"system",content:e})),[Se,Ce]=t.useState(!!f);t.useEffect(()=>{if(f){const{apiKey:e,analyticsApiBaseUrl:s}=b;We.getConversation(f,e,s).then(o=>{if(o){P({eventName:"shared_chat_loaded",properties:{conversation:o}}),Ce(!1),re({...o,id:""});const a=o.messages.map(c=>({id:Date.now().toString()+l.generateUid(4)+c.id,content:Be.parseIfJson(c.content),role:c.role,links:c.links}));u(a),r.current=a}})}},[f]);const Me=e=>{switch(e.code){case 400:return e.message;case 403:return`There seems to be a configuration error. Please contact ${b.organizationDisplayName??"Administrator"}`;default:return`Hmm..
|
|
2
2
|
|
|
3
|
-
It seems I might be having some issues right now. Please clear the chat and try again.`}},Y=e=>{j(e),u(s=>{const o=[...s],a=o[o.length-1];return a&&(a.content=Me(e)),o}),h(!1),v(!1),W(),q()},R=!
|
|
4
|
-
${D.serializeWorkflow(e)}`},...X,a,c];u(E),S([])},{openForm:
|
|
3
|
+
It seems I might be having some issues right now. Please clear the chat and try again.`}},Y=e=>{j(e),u(s=>{const o=[...s],a=o[o.length-1];return a&&(a.content=Me(e)),o}),h(!1),v(!1),W(),q()},R=!p.trim()&&!y.length||H,we=e=>{e.key==="Enter"&&!e.shiftKey&&!R&&!e.nativeEvent.isComposing&&(e.preventDefault(),L())},Ie=e=>{const s=e.target.value;_(s)},L=async(e=p)=>{if(R&&(!e||e.trim().length===0))return;h(!0);const s=A?g.length===2:g.length===0,o=D.getMessageMetadata(A,y,s);let a;const c=D.serializeAttachments(y);y.length&&c?a=[{type:"text",text:c}]:a=e;const ee={id:`${Date.now().toString()}-${l.generateUid(4)}-1`,role:"user",content:a,metadata:o},E=[...g.length?[]:X,ee];f&&ae.resetQueryParams(),u(M=>[...M,...E]),r.current=[...r.current,...E],S([]),_(""),P({eventName:"user_message_submitted",properties:{}},r.current);const te=[Qe.provideLinksTool,...ge?.({conversation:N})||[]];try{const M={model:me,messages:r.current,stream:!0,tools:te,tool_choice:"auto"},se=await ce(),ne=se?btoa(JSON.stringify(se)):null,oe=K||J?JSON.stringify({...K,...J}):void 0,U={};!T&&ne&&(U["X-INKEEP-CHALLENGE-SOLUTION"]=ne),oe&&(U["inkeep-filters"]=oe);const d=ue.beta.chat.completions.stream(M,Object.keys(U).length>0?{headers:U}:void 0),n={id:`${Date.now().toString()}-${l.generateUid(4)}-2`,role:"assistant",content:"",links:[],toolCalls:[]};u(w=>[...w,n]),d.on("content",(w,I)=>{v(!0),n.content=I,u($=>{const i=[...$],x=i.findIndex(k=>k.id===n.id);return x===-1?[...i,n]:(i[x]={...n},i)})}),d.on("tool_calls.function.arguments.done",async w=>{const{name:I,arguments:$}=w,i=te?.find(m=>m.function.name===I);if(!i)return;const k=("parse"in i.function?i.function.parse:JSON.parse)($),Ue=i.function.function?.(k,d),$e=i.renderMessageButtons?.({args:k,execution:Ue})??[];I==="provideLinks"?n.links=k.links??[]:V(m=>({...m,[n.id]:[...m[n.id]??[],...$e]})),n.toolCalls?.push({id:"call_"+l.generateUid(24),type:"function",function:{name:I,arguments:$}}),u(m=>{const B=[...m],Ne=B.findIndex(_e=>_e.id===n.id);return B[Ne]={...n},B}),fe?.(w,{conversation:{...N,messages:[...r.current,n]}})}),d.on("error",Y),d.finalChatCompletion().then(()=>{r.current=[...r.current,n],C.current=null,h(!1),v(!1),q(),P({eventName:"assistant_message_received",properties:{}},r.current)}),C.current=d.controller}catch(M){Y(M),h(!1),v(!1)}},ke=()=>{C.current&&(C.current.abort(),C.current=null),h(!1),v(!1),q()},Z=()=>{j(null),u([]),r.current=[],ie(),V({}),S([]),ae.resetQueryParams(),G(null),W(),q(),P({eventName:"chat_clear_button_clicked",properties:{conversation:N}})},be=e=>{G(e);const{initialReplyMessage:s,displayName:o}=e,a={id:g.length.toString()+l.generateUid(4),role:"user",content:o},c={id:(g.length+1).toString()+l.generateUid(4),role:"assistant",content:s,links:[]},E=[{id:`system-${Date.now().toString()}-${l.generateUid(4)}-${e.id}`,role:"system",content:`Company has asked user to follow this guided workflow:
|
|
4
|
+
${D.serializeWorkflow(e)}`},...X,a,c];u(E),S([])},{openForm:qe}=De.useChatForm(),Pe=Oe.useWidget();t.useImperativeHandle(O.chatFunctionsRef,()=>({submitMessage:L,updateInputMessage(e){_(e)},clearChat:Z,openForm:e=>{Pe?.setView("chat"),qe(e)},focusInput:()=>{z.current?.focus()}}));const Ee=Fe.useMediaQuery("(max-width: 768px)");return{messages:g,input:p,isLoading:H,isStreaming:pe,isLoadingConversation:Se,error:he,isSubmitDisabled:R,handleInputChange:Ie,handleInputKeyDown:we,handleSubmit:L,stop:ke,clear:Z,handleWorkflow:be,selectedWorkflow:A,messageAttachments:y,setMessageAttachments:S,addAttachment:ve,messageButtons:ye,isEmpty:g.length===0,inputRef:z,isMobile:Ee}};exports.useInkeepChat=Je;
|