@clubmed/trident-ui 2.0.0 → 2.1.0-beta.2
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/chunks/ChatMessage.js +367 -9804
- package/chunks/ChatMessage.js.map +1 -1
- package/chunks/Datepicker.js +1 -1
- package/chunks/Tooltip.js +1 -1
- package/chunks/chunk.js +5 -5
- package/examples/chat-body-demo.d.ts +1 -0
- package/examples/chat-body-demo.js +50 -0
- package/examples/chat-body-demo.js.map +1 -0
- package/examples/chat-header-demo.d.ts +1 -0
- package/examples/chat-header-demo.js +14 -0
- package/examples/chat-header-demo.js.map +1 -0
- package/package.json +1 -2
- package/ui/ChatBody.d.ts +25 -0
- package/ui/ChatBody.js +88 -0
- package/ui/ChatBody.js.map +1 -0
- package/ui/ChatHeader.d.ts +6 -0
- package/ui/ChatHeader.js +43 -0
- package/ui/ChatHeader.js.map +1 -0
- package/ui/ChatInput.js +2 -2
- package/ui/ChatInput.js.map +1 -1
- package/ui/ChatWindow.d.ts +18 -18
- package/ui/ChatWindow.js +37 -121
- package/ui/ChatWindow.js.map +1 -1
- package/ui/contexts/TridentUIConfig.js +1 -1
- package/chunks/client.js +0 -18953
- package/chunks/client.js.map +0 -1
package/ui/ChatWindow.js
CHANGED
|
@@ -1,135 +1,51 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { twMerge as e } from "./helpers/twMerge.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { forwardRef as s, useEffect as c, useImperativeHandle as l, useRef as u, useState as d } from "react";
|
|
10
|
-
import { jsx as f, jsxs as p } from "react/jsx-runtime";
|
|
11
|
-
import { Icon as m } from "@clubmed/trident-icons";
|
|
3
|
+
import { ChatBody as t } from "./ChatBody.js";
|
|
4
|
+
import { ChatInput as n } from "./ChatInput.js";
|
|
5
|
+
import { ChatHeader as r } from "./ChatHeader.js";
|
|
6
|
+
import { forwardRef as i } from "react";
|
|
7
|
+
import { Fragment as a, jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
8
|
+
import { Icon as c } from "@clubmed/trident-icons";
|
|
12
9
|
//#region lib/ui/ChatWindow.tsx
|
|
13
|
-
var
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
children: /* @__PURE__ */ f("path", {
|
|
19
|
-
d: "M0 0C10.8283 0 21.1946 5.40419 28.7327 13.2062L30.2673 14.7945C45.991 31.0685 72.009 31.0685 87.7327 14.7945L89.2673 13.2062C96.8054 5.40419 107.172 0 118 0C118 0 80.6853 0 0 0Z",
|
|
20
|
-
fill: "#F6EFE7"
|
|
21
|
-
})
|
|
22
|
-
}), g = s(function({ title: s = "Ask me a question", greeting: g, messages: _, inputValue: v, inputPlaceholder: y, isTyping: b = !1, onInputChange: x, onSubmit: S, onClose: C, onAudioClick: w, logo: T, onFeedbackRate: E, csatLabels: D, csatRenderRatingLabel: O, csatThankYouLabels: k, onQuoteCtaClick: A, className: j, ...M }, N) {
|
|
23
|
-
let P = u(null), [F, I] = d(!1), [L, R] = d(null), [z, B] = d([]);
|
|
24
|
-
l(N, () => ({
|
|
25
|
-
askForFeedback() {
|
|
26
|
-
I(!0);
|
|
27
|
-
},
|
|
28
|
-
showQuotes(e) {
|
|
29
|
-
B((t) => [...t, e]);
|
|
30
|
-
}
|
|
31
|
-
})), c(() => {
|
|
32
|
-
let e = P.current;
|
|
33
|
-
e && e.scrollTo({
|
|
34
|
-
top: e.scrollHeight,
|
|
35
|
-
behavior: "smooth"
|
|
36
|
-
});
|
|
37
|
-
}, [
|
|
38
|
-
_,
|
|
39
|
-
b,
|
|
40
|
-
F,
|
|
41
|
-
L,
|
|
42
|
-
z
|
|
43
|
-
]);
|
|
44
|
-
function V(e) {
|
|
45
|
-
R(String(O ? O(e) : e)), E?.(e);
|
|
46
|
-
}
|
|
47
|
-
let H = F && D && O;
|
|
48
|
-
return /* @__PURE__ */ p("div", {
|
|
49
|
-
...M,
|
|
50
|
-
className: e("flex flex-col gap-20 items-center", j),
|
|
51
|
-
children: [/* @__PURE__ */ p("div", {
|
|
10
|
+
var l = i(function({ title: i, onClose: l, logo: u, className: d, children: f, inputValue: p, inputPlaceholder: m, onInputChange: h, onSubmit: g, onAudioClick: _, greeting: v, messages: y, isTyping: b, onFeedbackRate: x, csatLabels: S, csatRenderRatingLabel: C, csatThankYouLabels: w, onQuoteCtaClick: T, ...E }, D) {
|
|
11
|
+
return /* @__PURE__ */ s("div", {
|
|
12
|
+
...E,
|
|
13
|
+
className: e("flex flex-col gap-20 items-center", d),
|
|
14
|
+
children: [/* @__PURE__ */ o("div", {
|
|
52
15
|
className: "chat-border bg-white flex flex-col h-full w-full rounded-32 overflow-hidden",
|
|
53
|
-
children: [
|
|
54
|
-
/* @__PURE__ */
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
className: "absolute inset-x-4 top-4 h-87 bg-lightSand rounded-[24]",
|
|
58
|
-
children: h
|
|
59
|
-
}), /* @__PURE__ */ p("div", {
|
|
60
|
-
className: "relative flex flex-col flex-1 items-center justify-end pb-8 w-full z-10",
|
|
61
|
-
children: [/* @__PURE__ */ f("div", {
|
|
62
|
-
className: "flex items-center justify-center px-12 py-8 w-full",
|
|
63
|
-
children: /* @__PURE__ */ f("p", {
|
|
64
|
-
className: "font-serif font-bold italic text-h5 text-center text-black line-clamp-2",
|
|
65
|
-
children: s
|
|
66
|
-
})
|
|
67
|
-
}), T ?? /* @__PURE__ */ f("button", {
|
|
68
|
-
type: "button",
|
|
69
|
-
"aria-label": "AI assistant",
|
|
70
|
-
className: "chat-border flex items-center justify-center size-48 rounded-full bg-white outline-none focus-visible:ring-4 focus-visible:ring-black focus-visible:ring-offset-2",
|
|
71
|
-
children: /* @__PURE__ */ f(m, {
|
|
72
|
-
name: "Sparkles",
|
|
73
|
-
width: "24px"
|
|
74
|
-
})
|
|
75
|
-
})]
|
|
76
|
-
})]
|
|
16
|
+
children: f ?? /* @__PURE__ */ s(a, { children: [
|
|
17
|
+
/* @__PURE__ */ o(r, {
|
|
18
|
+
title: i,
|
|
19
|
+
logo: u
|
|
77
20
|
}),
|
|
78
|
-
/* @__PURE__ */
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
className: "text-b3 text-black",
|
|
89
|
-
children: g
|
|
90
|
-
})
|
|
91
|
-
}) : null,
|
|
92
|
-
_.map((e) => /* @__PURE__ */ f(n, {
|
|
93
|
-
sender: e.sender,
|
|
94
|
-
children: e.content
|
|
95
|
-
}, e.id)),
|
|
96
|
-
b && /* @__PURE__ */ f("div", {
|
|
97
|
-
className: "px-12",
|
|
98
|
-
children: /* @__PURE__ */ f(r, {})
|
|
99
|
-
}),
|
|
100
|
-
H && /* @__PURE__ */ f(i, {
|
|
101
|
-
onRate: V,
|
|
102
|
-
labels: D,
|
|
103
|
-
renderRatingLabel: O
|
|
104
|
-
}),
|
|
105
|
-
L && /* @__PURE__ */ f(n, {
|
|
106
|
-
sender: "user",
|
|
107
|
-
children: L
|
|
108
|
-
}),
|
|
109
|
-
L && k && /* @__PURE__ */ f(a, { labels: k }),
|
|
110
|
-
z.map((e, t) => /* @__PURE__ */ f(o, {
|
|
111
|
-
quotes: e,
|
|
112
|
-
onCtaClick: A
|
|
113
|
-
}, t))
|
|
114
|
-
]
|
|
21
|
+
/* @__PURE__ */ o(t, {
|
|
22
|
+
greeting: v,
|
|
23
|
+
messages: y,
|
|
24
|
+
isTyping: b,
|
|
25
|
+
onFeedbackRate: x,
|
|
26
|
+
csatLabels: S,
|
|
27
|
+
csatRenderRatingLabel: C,
|
|
28
|
+
csatThankYouLabels: w,
|
|
29
|
+
onQuoteCtaClick: T,
|
|
30
|
+
ref: D
|
|
115
31
|
}),
|
|
116
|
-
/* @__PURE__ */
|
|
32
|
+
/* @__PURE__ */ o("div", {
|
|
117
33
|
className: "shrink-0 px-8 pb-8 pt-12",
|
|
118
|
-
children: /* @__PURE__ */
|
|
119
|
-
value:
|
|
120
|
-
placeholder:
|
|
121
|
-
onValueChange:
|
|
122
|
-
onSubmit:
|
|
123
|
-
onAudioClick:
|
|
34
|
+
children: /* @__PURE__ */ o(n, {
|
|
35
|
+
value: p,
|
|
36
|
+
placeholder: m,
|
|
37
|
+
onValueChange: h,
|
|
38
|
+
onSubmit: g,
|
|
39
|
+
onAudioClick: _
|
|
124
40
|
})
|
|
125
41
|
})
|
|
126
|
-
]
|
|
127
|
-
}),
|
|
42
|
+
] })
|
|
43
|
+
}), l && /* @__PURE__ */ o("button", {
|
|
128
44
|
type: "button",
|
|
129
45
|
"aria-label": "Close chat",
|
|
130
|
-
onClick:
|
|
46
|
+
onClick: l,
|
|
131
47
|
className: "flex items-center justify-center size-48 rounded-full bg-black border border-black text-white shrink-0 hover:opacity-80 transition-opacity outline-none focus-visible:ring-4 focus-visible:ring-black focus-visible:ring-offset-2",
|
|
132
|
-
children: /* @__PURE__ */
|
|
48
|
+
children: /* @__PURE__ */ o(c, {
|
|
133
49
|
name: "CrossDefault",
|
|
134
50
|
width: "24px"
|
|
135
51
|
})
|
|
@@ -137,6 +53,6 @@ var h = /* @__PURE__ */ f("svg", {
|
|
|
137
53
|
});
|
|
138
54
|
});
|
|
139
55
|
//#endregion
|
|
140
|
-
export {
|
|
56
|
+
export { l as ChatWindow };
|
|
141
57
|
|
|
142
58
|
//# sourceMappingURL=ChatWindow.js.map
|
package/ui/ChatWindow.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatWindow.js","names":[],"sources":["../../lib/ui/ChatWindow.tsx"],"sourcesContent":["'use client';\n\nimport { Icon } from '@clubmed/trident-icons';\nimport
|
|
1
|
+
{"version":3,"file":"ChatWindow.js","names":[],"sources":["../../lib/ui/ChatWindow.tsx"],"sourcesContent":["'use client';\n\nimport { Icon } from '@clubmed/trident-icons';\nimport { forwardRef, type ReactNode } from 'react';\nimport { twMerge } from './helpers/twMerge';\nimport type { ChatMessageSender } from './ChatMessage';\nimport type { ChatWindowCsatPromptLabels } from './ChatWindowCsatPrompt';\nimport type { ChatWindowCsatThankYouLabels } from './ChatWindowCsatThankYou';\nimport type { ChatWindowQuoteItem } from './ChatWindowQuote';\nimport { ChatHeader, type ChatHeaderProps } from './ChatHeader';\nimport { ChatBody, type ChatBodyProps } from './ChatBody';\nimport { ChatInput, type ChatInputProps } from '@/ui/ChatInput';\n\nexport type { ChatWindowCsatPromptLabels, ChatWindowCsatThankYouLabels, ChatWindowQuoteItem };\n\nexport interface ChatWindowMessage {\n id: string;\n sender: ChatMessageSender;\n content: ReactNode;\n}\n\ninterface ChatWindowInputProps {\n inputValue: ChatInputProps['value'];\n inputPlaceholder?: ChatInputProps['placeholder'];\n onInputChange: ChatInputProps['onValueChange'];\n onSubmit: ChatInputProps['onSubmit'];\n onAudioClick?: ChatInputProps['onAudioClick'];\n}\n\ninterface ChatWindowBaseProps extends ChatHeaderProps {\n onClose?: () => void;\n}\n\n// Either compose the panel from `ChatHeader`/`ChatBody`/`ChatInput` children,\n// or fall back to the opaque props-only form — in which case the message-log\n// and input props become required.\nexport type ChatWindowProps = ChatWindowBaseProps &\n (\n | ({ children: ReactNode } & Partial<ChatBodyProps> & Partial<ChatWindowInputProps>)\n | (ChatBodyProps & ChatWindowInputProps & { children?: undefined })\n );\n\nexport interface ChatWindowHandle {\n askForFeedback: () => void;\n showQuotes: (quotes: ChatWindowQuoteItem[]) => void;\n}\n\nexport const ChatWindow = forwardRef<ChatWindowHandle, ChatWindowProps>(function ChatWindow(\n {\n title,\n onClose,\n logo,\n className,\n children,\n inputValue,\n inputPlaceholder,\n onInputChange,\n onSubmit,\n onAudioClick,\n greeting,\n messages,\n isTyping,\n onFeedbackRate,\n csatLabels,\n csatRenderRatingLabel,\n csatThankYouLabels,\n onQuoteCtaClick,\n ...props\n },\n ref,\n) {\n return (\n <div {...props} className={twMerge('flex flex-col gap-20 items-center', className)}>\n <div className=\"chat-border bg-white flex flex-col h-full w-full rounded-32 overflow-hidden\">\n {children ?? (\n <>\n <ChatHeader title={title} logo={logo} />\n <ChatBody\n greeting={greeting}\n messages={messages!}\n isTyping={isTyping}\n onFeedbackRate={onFeedbackRate}\n csatLabels={csatLabels}\n csatRenderRatingLabel={csatRenderRatingLabel}\n csatThankYouLabels={csatThankYouLabels}\n onQuoteCtaClick={onQuoteCtaClick}\n ref={ref}\n />\n <div className=\"shrink-0 px-8 pb-8 pt-12\">\n <ChatInput\n value={inputValue!}\n placeholder={inputPlaceholder}\n onValueChange={onInputChange!}\n onSubmit={onSubmit!}\n onAudioClick={onAudioClick}\n />\n </div>\n </>\n )}\n </div>\n\n {onClose && (\n <button\n type=\"button\"\n aria-label=\"Close chat\"\n onClick={onClose}\n className=\"flex items-center justify-center size-48 rounded-full bg-black border border-black text-white shrink-0 hover:opacity-80 transition-opacity outline-none focus-visible:ring-4 focus-visible:ring-black focus-visible:ring-offset-2\"\n >\n <Icon name=\"CrossDefault\" width=\"24px\" />\n </button>\n )}\n </div>\n );\n});\n"],"mappings":";;;;;;;;;AA+CA,IAAa,IAAa,EAA8C,SACtE,EACE,UACA,YACA,SACA,cACA,aACA,eACA,qBACA,kBACA,aACA,iBACA,aACA,aACA,aACA,mBACA,eACA,0BACA,uBACA,oBACA,GAAG,KAEL,GACA;AACA,QACE,kBAAC,OAAD;EAAK,GAAI;EAAO,WAAW,EAAQ,qCAAqC,EAAU;YAAlF,CACE,kBAAC,OAAD;GAAK,WAAU;aACZ,KACC,kBAAA,GAAA,EAAA,UAAA;IACE,kBAAC,GAAD;KAAmB;KAAa;KAAQ,CAAA;IACxC,kBAAC,GAAD;KACY;KACA;KACA;KACM;KACJ;KACW;KACH;KACH;KACZ;KACL,CAAA;IACF,kBAAC,OAAD;KAAK,WAAU;eACb,kBAAC,GAAD;MACE,OAAO;MACP,aAAa;MACb,eAAe;MACL;MACI;MACd,CAAA;KACE,CAAA;IACL,EAAA,CAAA;GAED,CAAA,EAEL,KACC,kBAAC,UAAD;GACE,MAAK;GACL,cAAW;GACX,SAAS;GACT,WAAU;aAEV,kBAAC,GAAD;IAAM,MAAK;IAAe,OAAM;IAAS,CAAA;GAClC,CAAA,CAAA;;EAIf"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { i as e, t } from "../../chunks/chunk.js";
|
|
2
2
|
import { createContext as n, useContext as r } from "react";
|
|
3
3
|
import { jsx as i } from "react/jsx-runtime";
|
|
4
4
|
//#region ../../node_modules/.pnpm/lodash@4.17.23/node_modules/lodash/isArray.js
|