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,27 @@
1
+ import { LabelValue } from '../../types';
2
+ import * as React from "react";
3
+ interface ChatInputProps {
4
+ message: string;
5
+ onMessageChange: (value: string) => void;
6
+ onSubmit: () => void;
7
+ isSending: boolean;
8
+ lang: LabelValue | null;
9
+ setLang: (v: LabelValue | null) => void;
10
+ tone: LabelValue | null;
11
+ setTone: (v: LabelValue | null) => void;
12
+ length: LabelValue | null;
13
+ setLength: (v: LabelValue | null) => void;
14
+ parentRef?: React.RefObject<HTMLDivElement>;
15
+ placeholder?: string;
16
+ }
17
+ declare class ChatInput extends React.Component<ChatInputProps> {
18
+ private textareaRef;
19
+ constructor(props: ChatInputProps);
20
+ componentDidMount(): void;
21
+ componentDidUpdate(prev: ChatInputProps): void;
22
+ adjustHeight: () => void;
23
+ handleChange: (e: React.ChangeEvent<HTMLTextAreaElement>) => void;
24
+ handleKeyDown: (event: React.KeyboardEvent<HTMLTextAreaElement>) => void;
25
+ render(): React.JSX.Element;
26
+ }
27
+ export default ChatInput;
@@ -0,0 +1,190 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
+ import * as React from "react";
5
+ import { AI_LANG_FLAGS } from "../../constants/index.js";
6
+ import CountryFlag from "../CountryFlag/index.js";
7
+ import SettingPopper from "./SettingPopper/index.js";
8
+ import ArrowUp from "../../node_modules/react-feather/dist/icons/arrow-up.js";
9
+ class ChatInput extends React.Component {
10
+ constructor(props) {
11
+ super(props);
12
+ __publicField(this, "textareaRef");
13
+ __publicField(this, "adjustHeight", () => {
14
+ const el = this.textareaRef.current;
15
+ if (!el) return;
16
+ el.style.height = "auto";
17
+ el.style.height = `${Math.min(el.scrollHeight, 160)}px`;
18
+ });
19
+ __publicField(this, "handleChange", (e) => {
20
+ this.props.onMessageChange(e.target.value);
21
+ });
22
+ __publicField(this, "handleKeyDown", (event) => {
23
+ if (!event.shiftKey && event.key === "Enter" && !this.props.isSending) {
24
+ event.preventDefault();
25
+ this.props.onSubmit();
26
+ }
27
+ });
28
+ this.textareaRef = React.createRef();
29
+ }
30
+ componentDidMount() {
31
+ this.adjustHeight();
32
+ }
33
+ componentDidUpdate(prev) {
34
+ if (prev.message !== this.props.message) {
35
+ this.adjustHeight();
36
+ }
37
+ }
38
+ render() {
39
+ var _a, _b;
40
+ const {
41
+ message,
42
+ isSending,
43
+ lang,
44
+ setLang,
45
+ tone,
46
+ setTone,
47
+ length,
48
+ setLength,
49
+ parentRef,
50
+ onSubmit,
51
+ placeholder
52
+ } = this.props;
53
+ const flagCode = (_b = (_a = AI_LANG_FLAGS) == null ? void 0 : _a.find(
54
+ (_item) => (_item == null ? void 0 : _item.value) === (lang == null ? void 0 : lang.value)
55
+ )) == null ? void 0 : _b.flagCode;
56
+ const sendDisabled = !message.trim() || isSending;
57
+ return /* @__PURE__ */ React.createElement(
58
+ "div",
59
+ {
60
+ style: {
61
+ width: "100%",
62
+ borderRadius: 12,
63
+ overflow: "hidden",
64
+ background: "var(--background-softGrey)",
65
+ display: "flex",
66
+ flexDirection: "column",
67
+ border: "1px solid var(--border-light)"
68
+ }
69
+ },
70
+ /* @__PURE__ */ React.createElement(
71
+ "textarea",
72
+ {
73
+ ref: this.textareaRef,
74
+ value: message,
75
+ onChange: this.handleChange,
76
+ placeholder: placeholder || "Describe your email...",
77
+ name: "ai-content",
78
+ onKeyDown: this.handleKeyDown,
79
+ disabled: isSending,
80
+ rows: 1,
81
+ style: {
82
+ width: "100%",
83
+ minWidth: 0,
84
+ padding: 12,
85
+ fontSize: 13,
86
+ lineHeight: 1.4,
87
+ border: "none",
88
+ resize: "none",
89
+ outline: "none",
90
+ fontFamily: "inherit",
91
+ background: "transparent",
92
+ overflowY: "auto",
93
+ boxSizing: "border-box",
94
+ display: "block"
95
+ }
96
+ }
97
+ ),
98
+ /* @__PURE__ */ React.createElement(
99
+ "div",
100
+ {
101
+ style: {
102
+ display: "flex",
103
+ flexDirection: "row",
104
+ alignItems: "center",
105
+ width: "100%",
106
+ padding: "8px",
107
+ boxSizing: "border-box"
108
+ }
109
+ },
110
+ /* @__PURE__ */ React.createElement(
111
+ SettingPopper,
112
+ {
113
+ lang,
114
+ setLang,
115
+ tone,
116
+ setTone,
117
+ length,
118
+ setLength,
119
+ parentRef
120
+ }
121
+ ),
122
+ /* @__PURE__ */ React.createElement(
123
+ CountryFlag,
124
+ {
125
+ flagCode,
126
+ style: { marginLeft: 4, height: 14 }
127
+ }
128
+ ),
129
+ (tone || length) && /* @__PURE__ */ React.createElement(
130
+ "span",
131
+ {
132
+ style: {
133
+ marginLeft: 8,
134
+ padding: "2px 8px",
135
+ borderRadius: 999,
136
+ background: "var(--primary-lighter)",
137
+ color: "var(--primary-main)",
138
+ fontSize: 11,
139
+ fontWeight: 500,
140
+ whiteSpace: "nowrap",
141
+ display: "inline-flex",
142
+ alignItems: "center",
143
+ gap: 4
144
+ }
145
+ },
146
+ (tone == null ? void 0 : tone.label) && /* @__PURE__ */ React.createElement("span", null, tone.label),
147
+ (tone == null ? void 0 : tone.label) && (length == null ? void 0 : length.label) && /* @__PURE__ */ React.createElement(
148
+ "span",
149
+ {
150
+ style: {
151
+ width: 3,
152
+ height: 3,
153
+ borderRadius: "50%",
154
+ background: "currentColor",
155
+ display: "inline-block"
156
+ }
157
+ }
158
+ ),
159
+ (length == null ? void 0 : length.label) && /* @__PURE__ */ React.createElement("span", null, length.label)
160
+ ),
161
+ /* @__PURE__ */ React.createElement(
162
+ "button",
163
+ {
164
+ type: "button",
165
+ disabled: sendDisabled,
166
+ onClick: onSubmit,
167
+ style: {
168
+ marginLeft: "auto",
169
+ width: 28,
170
+ height: 28,
171
+ borderRadius: "50%",
172
+ border: "none",
173
+ display: "flex",
174
+ alignItems: "center",
175
+ justifyContent: "center",
176
+ background: sendDisabled ? "var(--primary-lighter)" : "var(--primary-main)",
177
+ color: "var(--primary-contrasttext)",
178
+ cursor: sendDisabled ? "not-allowed" : "pointer",
179
+ transition: "background 0.15s ease-in-out"
180
+ }
181
+ },
182
+ /* @__PURE__ */ React.createElement(ArrowUp, { size: 18 })
183
+ )
184
+ )
185
+ );
186
+ }
187
+ }
188
+ export {
189
+ ChatInput as default
190
+ };
@@ -0,0 +1,3 @@
1
+ import * as React from "react";
2
+ declare const AIAvatar: React.FunctionComponent;
3
+ export default AIAvatar;
@@ -0,0 +1,24 @@
1
+ import * as React from "react";
2
+ const AIAvatar = () => /* @__PURE__ */ React.createElement(
3
+ "div",
4
+ {
5
+ style: {
6
+ width: 28,
7
+ height: 28,
8
+ borderRadius: "50%",
9
+ background: "var(--primary-main)",
10
+ color: "var(--primary-contrasttext)",
11
+ display: "flex",
12
+ alignItems: "center",
13
+ justifyContent: "center",
14
+ fontSize: 11,
15
+ fontWeight: 700,
16
+ letterSpacing: 0.5,
17
+ flexShrink: 0
18
+ }
19
+ },
20
+ "AI"
21
+ );
22
+ export {
23
+ AIAvatar as default
24
+ };
@@ -0,0 +1,6 @@
1
+ import * as React from "react";
2
+ interface LoadingDotsProps {
3
+ label?: string;
4
+ }
5
+ declare const LoadingDots: React.FunctionComponent<LoadingDotsProps>;
6
+ export default LoadingDots;
@@ -0,0 +1,24 @@
1
+ import * as React from "react";
2
+ const LoadingDots = ({
3
+ label = "Thinking"
4
+ }) => /* @__PURE__ */ React.createElement(
5
+ "div",
6
+ {
7
+ style: {
8
+ display: "inline-flex",
9
+ alignItems: "center",
10
+ gap: 6,
11
+ background: "var(--background-softGrey)",
12
+ borderRadius: 8,
13
+ borderTopLeftRadius: 0,
14
+ padding: "8px 12px",
15
+ fontSize: 13,
16
+ color: "var(--text-secondary)"
17
+ }
18
+ },
19
+ /* @__PURE__ */ React.createElement("span", null, label),
20
+ /* @__PURE__ */ React.createElement("span", { className: "chat-ai-dots", "aria-hidden": "true" }, /* @__PURE__ */ React.createElement("span", null), /* @__PURE__ */ React.createElement("span", null), /* @__PURE__ */ React.createElement("span", null))
21
+ );
22
+ export {
23
+ LoadingDots as default
24
+ };
@@ -0,0 +1,11 @@
1
+ import { AIMessage } from '../types';
2
+ import * as React from "react";
3
+ interface MessageItemProps {
4
+ item: AIMessage;
5
+ onApply: (params: {
6
+ html: string;
7
+ }) => void;
8
+ getEditorContent?: () => string;
9
+ }
10
+ declare const MessageItem: React.FunctionComponent<MessageItemProps>;
11
+ export default MessageItem;
@@ -0,0 +1,124 @@
1
+ var __async = (__this, __arguments, generator) => {
2
+ return new Promise((resolve, reject) => {
3
+ var fulfilled = (value) => {
4
+ try {
5
+ step(generator.next(value));
6
+ } catch (e) {
7
+ reject(e);
8
+ }
9
+ };
10
+ var rejected = (value) => {
11
+ try {
12
+ step(generator.throw(value));
13
+ } catch (e) {
14
+ reject(e);
15
+ }
16
+ };
17
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
18
+ step((generator = generator.apply(__this, __arguments)).next());
19
+ });
20
+ };
21
+ import * as React from "react";
22
+ import Tooltip from "../../Tooltip/index.js";
23
+ import TypingText from "../TypingText.js";
24
+ import AIAvatar from "./AIAvatar.js";
25
+ import LoadingDots from "./LoadingDots.js";
26
+ import { buildApplyHtml } from "./helpers.js";
27
+ import Copy from "../../../node_modules/react-feather/dist/icons/copy.js";
28
+ const MessageItem = ({
29
+ item,
30
+ onApply,
31
+ getEditorContent
32
+ }) => {
33
+ const handleApply = () => __async(void 0, null, function* () {
34
+ const editorValue = getEditorContent ? getEditorContent() : "";
35
+ const html = yield buildApplyHtml(item.body, editorValue);
36
+ onApply({ html });
37
+ });
38
+ return /* @__PURE__ */ React.createElement(
39
+ "div",
40
+ {
41
+ style: {
42
+ display: "flex",
43
+ flexDirection: "column",
44
+ marginBottom: 16
45
+ }
46
+ },
47
+ /* @__PURE__ */ React.createElement(
48
+ "div",
49
+ {
50
+ style: {
51
+ width: "100%",
52
+ display: "flex",
53
+ alignItems: "flex-end",
54
+ flexDirection: "column",
55
+ position: "relative",
56
+ marginTop: 8
57
+ }
58
+ },
59
+ /* @__PURE__ */ React.createElement(
60
+ TypingText,
61
+ {
62
+ data: { question: item.question },
63
+ style: {
64
+ borderRadius: 8,
65
+ borderTopRightRadius: 0,
66
+ padding: "8px 12px",
67
+ background: "var(--primary-main)",
68
+ color: "var(--primary-contrasttext)"
69
+ }
70
+ }
71
+ )
72
+ ),
73
+ /* @__PURE__ */ React.createElement(
74
+ "div",
75
+ {
76
+ style: {
77
+ width: "100%",
78
+ display: "flex",
79
+ alignItems: "flex-start",
80
+ flexDirection: "row",
81
+ position: "relative",
82
+ marginTop: 8,
83
+ gap: 8
84
+ }
85
+ },
86
+ /* @__PURE__ */ React.createElement(AIAvatar, null),
87
+ /* @__PURE__ */ React.createElement(
88
+ "div",
89
+ {
90
+ style: {
91
+ flex: 1,
92
+ minWidth: 0,
93
+ display: "flex",
94
+ flexDirection: "column"
95
+ }
96
+ },
97
+ item.isLoading ? /* @__PURE__ */ React.createElement(LoadingDots, null) : /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
98
+ TypingText,
99
+ {
100
+ data: { subject: item.subject, body: item.body },
101
+ style: {
102
+ background: "var(--background-softGrey)",
103
+ borderRadius: 8,
104
+ borderTopLeftRadius: 0,
105
+ padding: "8px 12px"
106
+ }
107
+ }
108
+ ), /* @__PURE__ */ React.createElement("div", { style: { marginTop: 4 } }, /* @__PURE__ */ React.createElement(Tooltip, { title: "Apply content" }, /* @__PURE__ */ React.createElement(
109
+ "button",
110
+ {
111
+ type: "button",
112
+ onClick: handleApply,
113
+ color: "primary",
114
+ className: "icon-button small"
115
+ },
116
+ /* @__PURE__ */ React.createElement(Copy, { size: 16 })
117
+ ))))
118
+ )
119
+ )
120
+ );
121
+ };
122
+ export {
123
+ MessageItem as default
124
+ };
@@ -0,0 +1 @@
1
+ export declare const buildApplyHtml: (body: string, editorValue: string) => Promise<string>;
@@ -0,0 +1,35 @@
1
+ var __async = (__this, __arguments, generator) => {
2
+ return new Promise((resolve, reject) => {
3
+ var fulfilled = (value) => {
4
+ try {
5
+ step(generator.next(value));
6
+ } catch (e) {
7
+ reject(e);
8
+ }
9
+ };
10
+ var rejected = (value) => {
11
+ try {
12
+ step(generator.throw(value));
13
+ } catch (e) {
14
+ reject(e);
15
+ }
16
+ };
17
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
18
+ step((generator = generator.apply(__this, __arguments)).next());
19
+ });
20
+ };
21
+ import { marked } from "../../../node_modules/marked/lib/marked.esm.js";
22
+ const SIGNATURE_REGEX = /<!--HanbiroSignatureStart-->([\s\S]*?)<!--HanbiroSignatureEnd-->/g;
23
+ const TITLE_REGEX = /제목:[^\n]*/g;
24
+ const buildApplyHtml = (body, editorValue) => __async(void 0, null, function* () {
25
+ const content = body.replace(TITLE_REGEX, "").replace("본문: ", "");
26
+ let html = yield marked.parse(content);
27
+ const signatureMatch = SIGNATURE_REGEX.exec(editorValue) || [];
28
+ if (signatureMatch[0]) {
29
+ html = html + "<br>" + signatureMatch[0];
30
+ }
31
+ return html;
32
+ });
33
+ export {
34
+ buildApplyHtml
35
+ };
@@ -0,0 +1,11 @@
1
+ import { AIMessage } from '../types';
2
+ import * as React from "react";
3
+ interface ChatListProps {
4
+ items: AIMessage[];
5
+ onApply: (params: {
6
+ html: string;
7
+ }) => void;
8
+ getEditorContent?: () => string;
9
+ }
10
+ declare const ChatList: React.FunctionComponent<ChatListProps>;
11
+ export default ChatList;
@@ -0,0 +1,36 @@
1
+ import * as React from "react";
2
+ import MessageItem from "./MessageItem.js";
3
+ const ChatList = ({
4
+ items,
5
+ onApply,
6
+ getEditorContent
7
+ }) => {
8
+ return /* @__PURE__ */ React.createElement(
9
+ "div",
10
+ {
11
+ style: {
12
+ flex: 1,
13
+ minHeight: 0,
14
+ position: "relative",
15
+ overflowY: "auto",
16
+ paddingRight: 16,
17
+ marginRight: -16,
18
+ marginBottom: 8,
19
+ display: "flex",
20
+ flexDirection: "column"
21
+ }
22
+ },
23
+ items == null ? void 0 : items.map((item) => /* @__PURE__ */ React.createElement(
24
+ MessageItem,
25
+ {
26
+ key: item.id,
27
+ item,
28
+ onApply,
29
+ getEditorContent
30
+ }
31
+ ))
32
+ );
33
+ };
34
+ export {
35
+ ChatList as default
36
+ };
@@ -1,8 +1,8 @@
1
1
  import * as React from "react";
2
- import CustomAiIcon from "./CustomAIIcon.js";
3
- import MessageSquare from "../../node_modules/react-feather/dist/icons/message-square.js";
4
- import MessageCircle from "../../node_modules/react-feather/dist/icons/message-circle.js";
5
- import Check from "../../node_modules/react-feather/dist/icons/check.js";
2
+ import CustomAiIcon from "../CustomAIIcon.js";
3
+ import MessageSquare from "../../../node_modules/react-feather/dist/icons/message-square.js";
4
+ import MessageCircle from "../../../node_modules/react-feather/dist/icons/message-circle.js";
5
+ import Check from "../../../node_modules/react-feather/dist/icons/check.js";
6
6
  const FEATURES = [
7
7
  {
8
8
  icon: /* @__PURE__ */ React.createElement(MessageCircle, { size: 16 }),
@@ -0,0 +1,30 @@
1
+ import { LabelValue } from '../../../types';
2
+ import { AIMessage } from '../types';
3
+ import * as React from "react";
4
+ export interface CreatePanelProps {
5
+ defaultLang?: string;
6
+ getEditorContent?: () => string;
7
+ onApply: (params: {
8
+ html: string;
9
+ }) => void;
10
+ }
11
+ interface CreatePanelState {
12
+ message: string;
13
+ messages: AIMessage[];
14
+ isSending: boolean;
15
+ lang: LabelValue | null;
16
+ tone: LabelValue | null;
17
+ length: LabelValue | null;
18
+ conversationId: string;
19
+ }
20
+ declare class CreatePanel extends React.Component<CreatePanelProps, CreatePanelState> {
21
+ private rootRef;
22
+ constructor(props: CreatePanelProps);
23
+ handleMessageChange: (value: string) => void;
24
+ handleSubmit: () => Promise<void>;
25
+ setLang: (lang: LabelValue | null) => void;
26
+ setTone: (tone: LabelValue | null) => void;
27
+ setLength: (length: LabelValue | null) => void;
28
+ render(): React.JSX.Element;
29
+ }
30
+ export default CreatePanel;