hanbiro-react16-sdk 1.0.25 → 1.0.26

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 (40) hide show
  1. package/dist/components/ChatAIDraft/ChatInput.d.ts +27 -0
  2. package/dist/components/ChatAIDraft/ChatInput.js +190 -0
  3. package/dist/components/ChatAIDraft/ChatList/AIAvatar.d.ts +3 -0
  4. package/dist/components/ChatAIDraft/ChatList/AIAvatar.js +24 -0
  5. package/dist/components/ChatAIDraft/ChatList/LoadingDots.d.ts +6 -0
  6. package/dist/components/ChatAIDraft/ChatList/LoadingDots.js +24 -0
  7. package/dist/components/ChatAIDraft/ChatList/MessageItem.d.ts +11 -0
  8. package/dist/components/ChatAIDraft/ChatList/MessageItem.js +124 -0
  9. package/dist/components/ChatAIDraft/ChatList/helpers.d.ts +1 -0
  10. package/dist/components/ChatAIDraft/ChatList/helpers.js +35 -0
  11. package/dist/components/ChatAIDraft/ChatList/index.d.ts +11 -0
  12. package/dist/components/ChatAIDraft/ChatList/index.js +36 -0
  13. package/dist/components/ChatAIDraft/{EmptyState.js → CreatePanel/EmptyState.js} +4 -4
  14. package/dist/components/ChatAIDraft/CreatePanel/index.d.ts +30 -0
  15. package/dist/components/ChatAIDraft/CreatePanel/index.js +173 -0
  16. package/dist/components/ChatAIDraft/ReplyPanel/EmptyState.d.ts +10 -0
  17. package/dist/components/ChatAIDraft/ReplyPanel/EmptyState.js +365 -0
  18. package/dist/components/ChatAIDraft/ReplyPanel/MailListSelect.d.ts +26 -0
  19. package/dist/components/ChatAIDraft/ReplyPanel/MailListSelect.js +480 -0
  20. package/dist/components/ChatAIDraft/ReplyPanel/helper.d.ts +13 -0
  21. package/dist/components/ChatAIDraft/ReplyPanel/helper.js +100 -0
  22. package/dist/components/ChatAIDraft/ReplyPanel/index.d.ts +46 -0
  23. package/dist/components/ChatAIDraft/ReplyPanel/index.js +465 -0
  24. package/dist/components/ChatAIDraft/helper.d.ts +1 -0
  25. package/dist/components/ChatAIDraft/helper.js +12 -1
  26. package/dist/components/ChatAIDraft/index.d.ts +4 -32
  27. package/dist/components/ChatAIDraft/index.js +19 -307
  28. package/dist/components/ChatAIDraft/types.d.ts +36 -0
  29. package/dist/hanbiro-react16-sdk.style.css +41 -1
  30. package/dist/hanbiro-react16-sdk.umd.js +5143 -3379
  31. package/dist/index.js +1 -1
  32. package/dist/node_modules/react-feather/dist/icons/arrow-left.js +73 -0
  33. package/dist/node_modules/react-feather/dist/icons/lock.js +75 -0
  34. package/dist/node_modules/react-feather/dist/icons/mail.js +70 -0
  35. package/dist/node_modules/react-feather/dist/icons/paperclip.js +68 -0
  36. package/dist/node_modules/react-feather/dist/icons/plus.js +76 -0
  37. package/package.json +1 -1
  38. package/dist/components/ChatAIDraft/List.d.ts +0 -10
  39. package/dist/components/ChatAIDraft/List.js +0 -188
  40. /package/dist/components/ChatAIDraft/{EmptyState.d.ts → CreatePanel/EmptyState.d.ts} +0 -0
@@ -0,0 +1,173 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
+ var __spreadValues = (a, b) => {
9
+ for (var prop in b || (b = {}))
10
+ if (__hasOwnProp.call(b, prop))
11
+ __defNormalProp(a, prop, b[prop]);
12
+ if (__getOwnPropSymbols)
13
+ for (var prop of __getOwnPropSymbols(b)) {
14
+ if (__propIsEnum.call(b, prop))
15
+ __defNormalProp(a, prop, b[prop]);
16
+ }
17
+ return a;
18
+ };
19
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
21
+ var __async = (__this, __arguments, generator) => {
22
+ return new Promise((resolve, reject) => {
23
+ var fulfilled = (value) => {
24
+ try {
25
+ step(generator.next(value));
26
+ } catch (e) {
27
+ reject(e);
28
+ }
29
+ };
30
+ var rejected = (value) => {
31
+ try {
32
+ step(generator.throw(value));
33
+ } catch (e) {
34
+ reject(e);
35
+ }
36
+ };
37
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
38
+ step((generator = generator.apply(__this, __arguments)).next());
39
+ });
40
+ };
41
+ import * as React from "react";
42
+ import { callAI } from "../helper.js";
43
+ import ChatList from "../ChatList/index.js";
44
+ import ChatInput from "../ChatInput.js";
45
+ import EmptyState from "./EmptyState.js";
46
+ import { LENGTH_OPTIONS, TONE_OPTIONS } from "../constants.js";
47
+ import { AI_LANG_FLAGS } from "../../../constants/index.js";
48
+ import v4 from "../../../node_modules/uuid/dist/esm-browser/v4.js";
49
+ class CreatePanel extends React.Component {
50
+ constructor(props) {
51
+ var _a;
52
+ super(props);
53
+ __publicField(this, "rootRef");
54
+ __publicField(this, "handleMessageChange", (value) => {
55
+ this.setState({ message: value });
56
+ });
57
+ __publicField(this, "handleSubmit", () => __async(this, null, function* () {
58
+ const { message, messages, lang, tone, length, conversationId } = this.state;
59
+ if (!message.trim()) return;
60
+ const newId = v4();
61
+ const newMessage = {
62
+ id: newId,
63
+ question: message,
64
+ subject: "",
65
+ body: "",
66
+ created_at: (/* @__PURE__ */ new Date()).getTime(),
67
+ isLoading: true
68
+ };
69
+ this.setState({
70
+ messages: [...messages, newMessage],
71
+ message: "",
72
+ isSending: true
73
+ });
74
+ const params = {
75
+ query: message,
76
+ default_language: lang ? lang.value : "KR",
77
+ debug_grpc: true
78
+ };
79
+ if (tone) params.tone = tone.value;
80
+ if (length) params.length = length.value;
81
+ if (conversationId) params.conversation_id = conversationId;
82
+ const setContent = (nContent) => {
83
+ this.setState((prevState) => ({
84
+ messages: prevState.messages.map(
85
+ (m) => m.id === newId ? __spreadProps(__spreadValues({}, m), {
86
+ subject: "Some thing not used",
87
+ body: nContent,
88
+ isLoading: false,
89
+ created_at: (/* @__PURE__ */ new Date()).getTime()
90
+ }) : m
91
+ )
92
+ }));
93
+ };
94
+ const setIsLoading = (loading) => {
95
+ this.setState((prevState) => ({
96
+ messages: prevState.messages.map(
97
+ (m) => m.id === newId ? __spreadProps(__spreadValues({}, m), { isLoading: loading }) : m
98
+ )
99
+ }));
100
+ };
101
+ const setConversationId = (id) => {
102
+ this.setState({ conversationId: id });
103
+ };
104
+ yield callAI(params, { setContent, setIsLoading, setConversationId });
105
+ this.setState({ isSending: false });
106
+ }));
107
+ __publicField(this, "setLang", (lang) => this.setState({ lang }));
108
+ __publicField(this, "setTone", (tone) => this.setState({ tone }));
109
+ __publicField(this, "setLength", (length) => this.setState({ length }));
110
+ this.rootRef = React.createRef();
111
+ const lang = ((_a = AI_LANG_FLAGS) == null ? void 0 : _a.find((_item) => (_item == null ? void 0 : _item.value) === (props == null ? void 0 : props.defaultLang))) || AI_LANG_FLAGS[0];
112
+ this.state = {
113
+ message: "",
114
+ messages: [],
115
+ isSending: false,
116
+ lang,
117
+ tone: TONE_OPTIONS[2],
118
+ length: LENGTH_OPTIONS[2],
119
+ conversationId: ""
120
+ };
121
+ }
122
+ render() {
123
+ const { onApply, getEditorContent } = this.props;
124
+ const { message, messages, isSending, lang, tone, length } = this.state;
125
+ return /* @__PURE__ */ React.createElement(
126
+ "div",
127
+ {
128
+ ref: this.rootRef,
129
+ style: {
130
+ display: "flex",
131
+ height: "100%",
132
+ padding: 16,
133
+ flexDirection: "column",
134
+ background: "#fff",
135
+ fontFamily: "inherit",
136
+ boxSizing: "border-box"
137
+ }
138
+ },
139
+ messages.length > 0 ? /* @__PURE__ */ React.createElement(
140
+ ChatList,
141
+ {
142
+ items: messages,
143
+ onApply,
144
+ getEditorContent
145
+ }
146
+ ) : /* @__PURE__ */ React.createElement(
147
+ EmptyState,
148
+ {
149
+ onSelectPrompt: (text) => this.setState({ message: text })
150
+ }
151
+ ),
152
+ /* @__PURE__ */ React.createElement(
153
+ ChatInput,
154
+ {
155
+ message,
156
+ onMessageChange: this.handleMessageChange,
157
+ onSubmit: this.handleSubmit,
158
+ isSending,
159
+ lang,
160
+ setLang: this.setLang,
161
+ tone,
162
+ setTone: this.setTone,
163
+ length,
164
+ setLength: this.setLength,
165
+ parentRef: this.rootRef
166
+ }
167
+ )
168
+ );
169
+ }
170
+ }
171
+ export {
172
+ CreatePanel as default
173
+ };
@@ -0,0 +1,10 @@
1
+ import { ContextMail } from '../types';
2
+ import * as React from "react";
3
+ interface EmptyStateProps {
4
+ sourceMail: ContextMail | null;
5
+ selectedMails: ContextMail[];
6
+ onAddClick: () => void;
7
+ onRemoveSelected: (mid: string) => void;
8
+ }
9
+ declare const EmptyState: React.FunctionComponent<EmptyStateProps>;
10
+ export default EmptyState;
@@ -0,0 +1,365 @@
1
+ import * as React from "react";
2
+ import CustomAiIcon from "../CustomAIIcon.js";
3
+ import Lock from "../../../node_modules/react-feather/dist/icons/lock.js";
4
+ import Plus from "../../../node_modules/react-feather/dist/icons/plus.js";
5
+ import Mail from "../../../node_modules/react-feather/dist/icons/mail.js";
6
+ import MessageCircle from "../../../node_modules/react-feather/dist/icons/message-circle.js";
7
+ const FEATURES = [
8
+ {
9
+ icon: /* @__PURE__ */ React.createElement(Mail, { size: 16 }),
10
+ title: "Auto-include source",
11
+ desc: "The email you are replying to is automatically added as context."
12
+ },
13
+ {
14
+ icon: /* @__PURE__ */ React.createElement(CustomAiIcon, { size: 16, stroke: 2 }),
15
+ title: "Add send history (optional)",
16
+ desc: "Use '+ Add' to pick past emails and reference their tone."
17
+ },
18
+ {
19
+ icon: /* @__PURE__ */ React.createElement(MessageCircle, { size: 16 }),
20
+ title: "Refine with conversation",
21
+ desc: "Get an AI draft, then adjust freely with chips or messages."
22
+ }
23
+ ];
24
+ const SourceCard = ({
25
+ mail
26
+ }) => /* @__PURE__ */ React.createElement(
27
+ "div",
28
+ {
29
+ style: {
30
+ border: "1px solid var(--border-light)",
31
+ borderRadius: 8,
32
+ padding: 10,
33
+ display: "flex",
34
+ gap: 8,
35
+ alignItems: "flex-start",
36
+ background: "#fff"
37
+ }
38
+ },
39
+ /* @__PURE__ */ React.createElement("div", { style: { flex: 1, minWidth: 0 } }, /* @__PURE__ */ React.createElement(
40
+ "div",
41
+ {
42
+ style: {
43
+ fontSize: 13,
44
+ fontWeight: 600,
45
+ color: "var(--text-primary)",
46
+ whiteSpace: "nowrap",
47
+ overflow: "hidden",
48
+ textOverflow: "ellipsis"
49
+ }
50
+ },
51
+ mail.subject || "(no subject)"
52
+ ), /* @__PURE__ */ React.createElement(
53
+ "div",
54
+ {
55
+ style: {
56
+ fontSize: 12,
57
+ color: "var(--text-secondary)",
58
+ marginTop: 2,
59
+ whiteSpace: "nowrap",
60
+ overflow: "hidden",
61
+ textOverflow: "ellipsis"
62
+ }
63
+ },
64
+ mail.from_name,
65
+ mail.from_addr ? ` <${mail.from_addr}>` : "",
66
+ mail.date ? ` · ${mail.date}` : ""
67
+ ))
68
+ );
69
+ const SelectedChip = ({ index, mail, onRemove }) => /* @__PURE__ */ React.createElement(
70
+ "div",
71
+ {
72
+ style: {
73
+ display: "inline-flex",
74
+ alignItems: "center",
75
+ gap: 6,
76
+ padding: "6px 8px",
77
+ borderRadius: 8,
78
+ border: "1px solid var(--border-light)",
79
+ background: "var(--primary-lighter)",
80
+ fontSize: 12,
81
+ maxWidth: 160
82
+ }
83
+ },
84
+ /* @__PURE__ */ React.createElement(
85
+ "span",
86
+ {
87
+ style: {
88
+ width: 16,
89
+ height: 16,
90
+ borderRadius: "50%",
91
+ background: "var(--primary-main)",
92
+ color: "var(--primary-contrasttext)",
93
+ fontSize: 10,
94
+ fontWeight: 700,
95
+ display: "inline-flex",
96
+ alignItems: "center",
97
+ justifyContent: "center",
98
+ flexShrink: 0
99
+ }
100
+ },
101
+ index + 1
102
+ ),
103
+ /* @__PURE__ */ React.createElement(
104
+ "span",
105
+ {
106
+ style: {
107
+ whiteSpace: "nowrap",
108
+ overflow: "hidden",
109
+ textOverflow: "ellipsis",
110
+ color: "var(--text-primary)"
111
+ }
112
+ },
113
+ mail.subject || "(no subject)"
114
+ ),
115
+ /* @__PURE__ */ React.createElement(
116
+ "button",
117
+ {
118
+ type: "button",
119
+ onClick: () => onRemove(mail.mid),
120
+ style: {
121
+ border: "none",
122
+ background: "transparent",
123
+ color: "var(--text-secondary)",
124
+ cursor: "pointer",
125
+ padding: 0,
126
+ display: "inline-flex",
127
+ alignItems: "center",
128
+ flexShrink: 0
129
+ }
130
+ },
131
+ "×"
132
+ )
133
+ );
134
+ const EmptyState = ({
135
+ sourceMail,
136
+ selectedMails,
137
+ onAddClick,
138
+ onRemoveSelected
139
+ }) => {
140
+ return /* @__PURE__ */ React.createElement(
141
+ "div",
142
+ {
143
+ style: {
144
+ flex: 1,
145
+ minHeight: 0,
146
+ overflowY: "auto",
147
+ display: "flex",
148
+ flexDirection: "column",
149
+ paddingRight: 8,
150
+ marginRight: -8,
151
+ paddingBottom: 16,
152
+ gap: 12
153
+ }
154
+ },
155
+ sourceMail && /* @__PURE__ */ React.createElement("div", { style: { display: "flex", flexDirection: "column", gap: 6 } }, /* @__PURE__ */ React.createElement(
156
+ "div",
157
+ {
158
+ style: {
159
+ display: "flex",
160
+ alignItems: "center",
161
+ gap: 6,
162
+ fontSize: 12,
163
+ color: "var(--text-primary)",
164
+ fontWeight: 600
165
+ }
166
+ },
167
+ /* @__PURE__ */ React.createElement("span", null, "Source context"),
168
+ /* @__PURE__ */ React.createElement(
169
+ "span",
170
+ {
171
+ style: {
172
+ background: "var(--primary-main)",
173
+ color: "var(--primary-contrasttext)",
174
+ fontSize: 10,
175
+ padding: "1px 6px",
176
+ borderRadius: 999,
177
+ fontWeight: 600
178
+ }
179
+ },
180
+ "1"
181
+ ),
182
+ /* @__PURE__ */ React.createElement(
183
+ "span",
184
+ {
185
+ style: {
186
+ display: "inline-flex",
187
+ alignItems: "center",
188
+ gap: 2,
189
+ fontSize: 11,
190
+ color: "var(--text-secondary)",
191
+ fontWeight: 500
192
+ }
193
+ },
194
+ /* @__PURE__ */ React.createElement(Lock, { size: 11 }),
195
+ " Auto"
196
+ )
197
+ ), /* @__PURE__ */ React.createElement(SourceCard, { mail: sourceMail })),
198
+ /* @__PURE__ */ React.createElement("div", { style: { display: "flex", flexDirection: "column", gap: 6 } }, /* @__PURE__ */ React.createElement(
199
+ "div",
200
+ {
201
+ style: {
202
+ display: "flex",
203
+ alignItems: "center",
204
+ justifyContent: "space-between"
205
+ }
206
+ },
207
+ /* @__PURE__ */ React.createElement(
208
+ "div",
209
+ {
210
+ style: {
211
+ display: "flex",
212
+ alignItems: "center",
213
+ gap: 6,
214
+ fontSize: 12,
215
+ color: "var(--text-primary)",
216
+ fontWeight: 600
217
+ }
218
+ },
219
+ /* @__PURE__ */ React.createElement("span", null, "Selected context"),
220
+ /* @__PURE__ */ React.createElement(
221
+ "span",
222
+ {
223
+ style: {
224
+ background: "var(--background-softGrey)",
225
+ color: "var(--text-primary)",
226
+ fontSize: 10,
227
+ padding: "1px 6px",
228
+ borderRadius: 999,
229
+ fontWeight: 600
230
+ }
231
+ },
232
+ selectedMails.length
233
+ )
234
+ ),
235
+ /* @__PURE__ */ React.createElement(
236
+ "button",
237
+ {
238
+ type: "button",
239
+ onClick: onAddClick,
240
+ className: "text-button primary"
241
+ },
242
+ /* @__PURE__ */ React.createElement(Plus, { size: 12 }),
243
+ " Add"
244
+ )
245
+ ), selectedMails.length > 0 && /* @__PURE__ */ React.createElement("div", { style: { display: "flex", flexWrap: "wrap", gap: 6 } }, selectedMails.map((m, i) => /* @__PURE__ */ React.createElement(
246
+ SelectedChip,
247
+ {
248
+ key: m.mid,
249
+ index: i,
250
+ mail: m,
251
+ onRemove: onRemoveSelected
252
+ }
253
+ )))),
254
+ /* @__PURE__ */ React.createElement("div", { style: { textAlign: "center", marginTop: 8 } }, /* @__PURE__ */ React.createElement(
255
+ "div",
256
+ {
257
+ style: {
258
+ fontSize: 13,
259
+ color: "var(--text-secondary)",
260
+ lineHeight: 1.6
261
+ }
262
+ },
263
+ "We'll draft a reply based on the received email.",
264
+ /* @__PURE__ */ React.createElement("br", null),
265
+ "Add send history if you want to match the tone."
266
+ )),
267
+ /* @__PURE__ */ React.createElement(
268
+ "div",
269
+ {
270
+ style: {
271
+ alignSelf: "center",
272
+ width: 100,
273
+ height: 100,
274
+ borderRadius: "50%",
275
+ background: "var(--primary-lighter)",
276
+ display: "flex",
277
+ alignItems: "center",
278
+ justifyContent: "center",
279
+ margin: "8px 0",
280
+ color: "var(--primary-main)",
281
+ flexShrink: 0
282
+ }
283
+ },
284
+ /* @__PURE__ */ React.createElement(CustomAiIcon, { size: 44, stroke: 1.5 })
285
+ ),
286
+ /* @__PURE__ */ React.createElement("div", { style: { textAlign: "center" } }, /* @__PURE__ */ React.createElement(
287
+ "div",
288
+ {
289
+ style: {
290
+ fontSize: 13,
291
+ color: "var(--text-secondary)",
292
+ lineHeight: 1.6
293
+ }
294
+ },
295
+ "The source is auto-included. Adjust tone and length through conversation."
296
+ )),
297
+ /* @__PURE__ */ React.createElement(
298
+ "div",
299
+ {
300
+ style: {
301
+ borderTop: "1px solid var(--border-light)",
302
+ marginTop: 8,
303
+ paddingTop: 16,
304
+ display: "flex",
305
+ flexDirection: "column",
306
+ gap: 14
307
+ }
308
+ },
309
+ FEATURES.map((f, i) => /* @__PURE__ */ React.createElement(
310
+ "div",
311
+ {
312
+ key: i,
313
+ style: {
314
+ display: "flex",
315
+ flexDirection: "row",
316
+ alignItems: "flex-start",
317
+ gap: 10
318
+ }
319
+ },
320
+ /* @__PURE__ */ React.createElement(
321
+ "div",
322
+ {
323
+ style: {
324
+ width: 28,
325
+ height: 28,
326
+ borderRadius: "50%",
327
+ background: "var(--primary-lighter)",
328
+ color: "var(--primary-main)",
329
+ display: "flex",
330
+ alignItems: "center",
331
+ justifyContent: "center",
332
+ flexShrink: 0
333
+ }
334
+ },
335
+ f.icon
336
+ ),
337
+ /* @__PURE__ */ React.createElement("div", { style: { flex: 1, minWidth: 0 } }, /* @__PURE__ */ React.createElement(
338
+ "div",
339
+ {
340
+ style: {
341
+ fontSize: 13,
342
+ fontWeight: 600,
343
+ color: "var(--text-primary)"
344
+ }
345
+ },
346
+ f.title
347
+ ), /* @__PURE__ */ React.createElement(
348
+ "div",
349
+ {
350
+ style: {
351
+ fontSize: 12,
352
+ color: "var(--text-secondary)",
353
+ marginTop: 2,
354
+ lineHeight: 1.5
355
+ }
356
+ },
357
+ f.desc
358
+ ))
359
+ ))
360
+ )
361
+ );
362
+ };
363
+ export {
364
+ EmptyState as default
365
+ };
@@ -0,0 +1,26 @@
1
+ import { MailListItem } from '../types';
2
+ import * as React from "react";
3
+ interface MailListSelectProps {
4
+ accountEmail: string;
5
+ initialSelected: string[];
6
+ onCancel: () => void;
7
+ onConfirm: (mids: string[]) => void;
8
+ }
9
+ interface MailListSelectState {
10
+ page: number;
11
+ total: number;
12
+ items: MailListItem[];
13
+ selectedMids: string[];
14
+ isLoading: boolean;
15
+ }
16
+ declare class MailListSelect extends React.Component<MailListSelectProps, MailListSelectState> {
17
+ constructor(props: MailListSelectProps);
18
+ componentDidMount(): void;
19
+ loadPage: (page: number) => Promise<void>;
20
+ toggleMid: (mid: string) => void;
21
+ toggleAll: () => void;
22
+ clearAll: () => void;
23
+ renderPagination(): React.JSX.Element;
24
+ render(): React.JSX.Element;
25
+ }
26
+ export default MailListSelect;