hanbiro-react16-sdk 1.0.21 → 1.0.23
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/components/ChatAIDraft/EmptyState.d.ts +6 -0
- package/dist/components/ChatAIDraft/EmptyState.js +220 -0
- package/dist/components/ChatAIDraft/List.js +55 -18
- package/dist/components/ChatAIDraft/SettingPopper.d.ts +5 -4
- package/dist/components/ChatAIDraft/SettingPopper.js +235 -79
- package/dist/components/ChatAIDraft/constants.d.ts +4 -0
- package/dist/components/ChatAIDraft/constants.js +18 -0
- package/dist/components/ChatAIDraft/index.d.ts +5 -8
- package/dist/components/ChatAIDraft/index.js +80 -48
- package/dist/components/index.d.ts +1 -1
- package/dist/hanbiro-react16-sdk.style.css +39 -2
- package/dist/hanbiro-react16-sdk.umd.js +7213 -3
- package/dist/index.js +2 -2
- package/dist/node_modules/prop-types/index.js +1 -2
- package/dist/node_modules/react-feather/dist/icons/align-justify.js +86 -0
- package/dist/node_modules/react-feather/dist/icons/{send.js → arrow-up.js} +10 -10
- package/dist/node_modules/react-feather/dist/icons/award.js +72 -0
- package/dist/node_modules/react-feather/dist/icons/check.js +68 -0
- package/dist/node_modules/react-feather/dist/icons/chevron-down.js +68 -0
- package/dist/node_modules/react-feather/dist/icons/compass.js +72 -0
- package/dist/node_modules/react-feather/dist/icons/file-text.js +82 -0
- package/dist/node_modules/react-feather/dist/icons/frown.js +82 -0
- package/dist/node_modules/react-feather/dist/icons/heart.js +68 -0
- package/dist/node_modules/react-feather/dist/icons/message-circle.js +68 -0
- package/dist/node_modules/react-feather/dist/icons/message-square.js +68 -0
- package/dist/node_modules/react-feather/dist/icons/scissors.js +89 -0
- package/dist/node_modules/react-feather/dist/icons/smile.js +82 -0
- package/dist/node_modules/react-feather/dist/icons/thumbs-up.js +68 -0
- package/dist/node_modules/react-feather/dist/icons/zap.js +68 -0
- package/package.json +1 -1
- package/dist/components/TinyMceEditor/index.js +0 -181
- package/dist/components/TinyMceEditor/scrollStyle.js +0 -40
- package/dist/components/TinyMceEditor/useEditor.js +0 -120
- package/dist/node_modules/@tinymce/tinymce-react/lib/es2015/main/ts/ScriptLoader2.js +0 -148
- package/dist/node_modules/@tinymce/tinymce-react/lib/es2015/main/ts/TinyMCE.js +0 -7
- package/dist/node_modules/@tinymce/tinymce-react/lib/es2015/main/ts/Utils.js +0 -103
- package/dist/node_modules/@tinymce/tinymce-react/lib/es2015/main/ts/components/Editor.js +0 -353
- package/dist/node_modules/@tinymce/tinymce-react/lib/es2015/main/ts/components/EditorPropTypes.js +0 -102
|
@@ -23,11 +23,164 @@ var __async = (__this, __arguments, generator) => {
|
|
|
23
23
|
};
|
|
24
24
|
import * as React from "react";
|
|
25
25
|
import * as ReactDOM from "react-dom";
|
|
26
|
-
import TinyMceEditor from "../TinyMceEditor/index.js";
|
|
27
|
-
import Tooltip from "../Tooltip/index.js";
|
|
28
26
|
import { apiGet } from "../../utils/api.js";
|
|
27
|
+
import { AI_LANG_FLAGS } from "../../constants/index.js";
|
|
28
|
+
import CountryFlag from "../CountryFlag/index.js";
|
|
29
|
+
import { TONE_OPTIONS, LENGTH_OPTIONS } from "./constants.js";
|
|
29
30
|
import Settings from "../../node_modules/react-feather/dist/icons/settings.js";
|
|
30
|
-
import
|
|
31
|
+
import ChevronDown from "../../node_modules/react-feather/dist/icons/chevron-down.js";
|
|
32
|
+
import Frown from "../../node_modules/react-feather/dist/icons/frown.js";
|
|
33
|
+
import ThumbsUp from "../../node_modules/react-feather/dist/icons/thumbs-up.js";
|
|
34
|
+
import Smile from "../../node_modules/react-feather/dist/icons/smile.js";
|
|
35
|
+
import Compass from "../../node_modules/react-feather/dist/icons/compass.js";
|
|
36
|
+
import Heart from "../../node_modules/react-feather/dist/icons/heart.js";
|
|
37
|
+
import Award from "../../node_modules/react-feather/dist/icons/award.js";
|
|
38
|
+
import Zap from "../../node_modules/react-feather/dist/icons/zap.js";
|
|
39
|
+
import FileText from "../../node_modules/react-feather/dist/icons/file-text.js";
|
|
40
|
+
import AlignJustify from "../../node_modules/react-feather/dist/icons/align-justify.js";
|
|
41
|
+
import Scissors from "../../node_modules/react-feather/dist/icons/scissors.js";
|
|
42
|
+
const getFlagCode = (value) => {
|
|
43
|
+
var _a;
|
|
44
|
+
return (_a = AI_LANG_FLAGS.find((l) => l.value === value)) == null ? void 0 : _a.flagCode;
|
|
45
|
+
};
|
|
46
|
+
class LanguageSelect extends React.Component {
|
|
47
|
+
constructor(props) {
|
|
48
|
+
super(props);
|
|
49
|
+
__publicField(this, "ref");
|
|
50
|
+
__publicField(this, "handleClickOutside", (e) => {
|
|
51
|
+
if (this.ref.current && !this.ref.current.contains(e.target)) {
|
|
52
|
+
this.setState({ open: false });
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
__publicField(this, "toggle", () => {
|
|
56
|
+
this.setState((s) => ({ open: !s.open }));
|
|
57
|
+
});
|
|
58
|
+
__publicField(this, "pick", (opt) => {
|
|
59
|
+
this.props.onChange(opt);
|
|
60
|
+
this.setState({ open: false });
|
|
61
|
+
});
|
|
62
|
+
this.state = { open: false };
|
|
63
|
+
this.ref = React.createRef();
|
|
64
|
+
}
|
|
65
|
+
componentDidMount() {
|
|
66
|
+
document.addEventListener("mousedown", this.handleClickOutside);
|
|
67
|
+
}
|
|
68
|
+
componentWillUnmount() {
|
|
69
|
+
document.removeEventListener("mousedown", this.handleClickOutside);
|
|
70
|
+
}
|
|
71
|
+
render() {
|
|
72
|
+
const { value, options } = this.props;
|
|
73
|
+
const { open } = this.state;
|
|
74
|
+
const selectedFlag = getFlagCode(value == null ? void 0 : value.value);
|
|
75
|
+
return /* @__PURE__ */ React.createElement("div", { ref: this.ref, style: { position: "relative", width: "100%" } }, /* @__PURE__ */ React.createElement(
|
|
76
|
+
"button",
|
|
77
|
+
{
|
|
78
|
+
type: "button",
|
|
79
|
+
onClick: this.toggle,
|
|
80
|
+
style: {
|
|
81
|
+
width: "100%",
|
|
82
|
+
display: "flex",
|
|
83
|
+
alignItems: "center",
|
|
84
|
+
gap: 8,
|
|
85
|
+
padding: "8px 10px",
|
|
86
|
+
border: "1px solid var(--border-main)",
|
|
87
|
+
borderRadius: 4,
|
|
88
|
+
background: "#fff",
|
|
89
|
+
cursor: "pointer",
|
|
90
|
+
fontFamily: "inherit",
|
|
91
|
+
fontSize: 13,
|
|
92
|
+
color: "var(--text-primary)"
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
selectedFlag && /* @__PURE__ */ React.createElement(
|
|
96
|
+
CountryFlag,
|
|
97
|
+
{
|
|
98
|
+
flagCode: selectedFlag,
|
|
99
|
+
style: { width: 18, height: 14, flexShrink: 0 }
|
|
100
|
+
}
|
|
101
|
+
),
|
|
102
|
+
/* @__PURE__ */ React.createElement("span", { style: { flex: 1, textAlign: "left" } }, (value == null ? void 0 : value.label) || "Select Language"),
|
|
103
|
+
/* @__PURE__ */ React.createElement(
|
|
104
|
+
ChevronDown,
|
|
105
|
+
{
|
|
106
|
+
size: 14,
|
|
107
|
+
style: {
|
|
108
|
+
transform: open ? "rotate(180deg)" : "none",
|
|
109
|
+
transition: "transform 0.15s"
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
)
|
|
113
|
+
), open && /* @__PURE__ */ React.createElement(
|
|
114
|
+
"div",
|
|
115
|
+
{
|
|
116
|
+
style: {
|
|
117
|
+
position: "absolute",
|
|
118
|
+
top: "calc(100% + 4px)",
|
|
119
|
+
left: 0,
|
|
120
|
+
right: 0,
|
|
121
|
+
maxHeight: 220,
|
|
122
|
+
overflowY: "auto",
|
|
123
|
+
border: "1px solid var(--border-main)",
|
|
124
|
+
borderRadius: 4,
|
|
125
|
+
background: "#fff",
|
|
126
|
+
boxShadow: "0 4px 12px rgba(0, 0, 0, 0.08)",
|
|
127
|
+
zIndex: 2
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
options.map((opt) => {
|
|
131
|
+
const fc = getFlagCode(opt.value);
|
|
132
|
+
const isActive = (value == null ? void 0 : value.value) === opt.value;
|
|
133
|
+
return /* @__PURE__ */ React.createElement(
|
|
134
|
+
"button",
|
|
135
|
+
{
|
|
136
|
+
key: opt.value,
|
|
137
|
+
type: "button",
|
|
138
|
+
onClick: () => this.pick(opt),
|
|
139
|
+
className: "chat-ai-lang-option" + (isActive ? " is-active" : ""),
|
|
140
|
+
style: {
|
|
141
|
+
width: "100%",
|
|
142
|
+
display: "flex",
|
|
143
|
+
alignItems: "center",
|
|
144
|
+
gap: 8,
|
|
145
|
+
padding: "8px 10px",
|
|
146
|
+
border: "none",
|
|
147
|
+
background: isActive ? "var(--primary-lighter)" : void 0,
|
|
148
|
+
cursor: "pointer",
|
|
149
|
+
fontFamily: "inherit",
|
|
150
|
+
fontSize: 13,
|
|
151
|
+
textAlign: "left",
|
|
152
|
+
color: "var(--text-primary)",
|
|
153
|
+
fontWeight: 400
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
fc && /* @__PURE__ */ React.createElement(
|
|
157
|
+
CountryFlag,
|
|
158
|
+
{
|
|
159
|
+
flagCode: fc,
|
|
160
|
+
style: { width: 18, height: 14, flexShrink: 0 }
|
|
161
|
+
}
|
|
162
|
+
),
|
|
163
|
+
/* @__PURE__ */ React.createElement("span", null, opt.label)
|
|
164
|
+
);
|
|
165
|
+
})
|
|
166
|
+
));
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
const ICON_SIZE = 14;
|
|
170
|
+
const TONE_ICONS = {
|
|
171
|
+
formal: /* @__PURE__ */ React.createElement(Award, { size: ICON_SIZE }),
|
|
172
|
+
polite: /* @__PURE__ */ React.createElement(Heart, { size: ICON_SIZE }),
|
|
173
|
+
neutral: /* @__PURE__ */ React.createElement(Compass, { size: ICON_SIZE }),
|
|
174
|
+
friendly: /* @__PURE__ */ React.createElement(Smile, { size: ICON_SIZE }),
|
|
175
|
+
firm: /* @__PURE__ */ React.createElement(ThumbsUp, { size: ICON_SIZE }),
|
|
176
|
+
apologetic: /* @__PURE__ */ React.createElement(Frown, { size: ICON_SIZE })
|
|
177
|
+
};
|
|
178
|
+
const LENGTH_ICONS = {
|
|
179
|
+
short: /* @__PURE__ */ React.createElement(Scissors, { size: ICON_SIZE }),
|
|
180
|
+
medium: /* @__PURE__ */ React.createElement(AlignJustify, { size: ICON_SIZE }),
|
|
181
|
+
long: /* @__PURE__ */ React.createElement(FileText, { size: ICON_SIZE }),
|
|
182
|
+
one_liner: /* @__PURE__ */ React.createElement(Zap, { size: ICON_SIZE })
|
|
183
|
+
};
|
|
31
184
|
class SettingPopper extends React.Component {
|
|
32
185
|
constructor(props) {
|
|
33
186
|
super(props);
|
|
@@ -57,12 +210,56 @@ class SettingPopper extends React.Component {
|
|
|
57
210
|
__publicField(this, "togglePopper", () => {
|
|
58
211
|
this.setState((prevState) => ({ open: !prevState.open }));
|
|
59
212
|
});
|
|
60
|
-
__publicField(this, "
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
213
|
+
__publicField(this, "renderChipGroup", (options, selected, onSelect, iconMap, columns = 3) => /* @__PURE__ */ React.createElement(
|
|
214
|
+
"div",
|
|
215
|
+
{
|
|
216
|
+
style: {
|
|
217
|
+
display: "grid",
|
|
218
|
+
gridTemplateColumns: `repeat(${columns}, minmax(0, 1fr))`,
|
|
219
|
+
gap: 6
|
|
220
|
+
}
|
|
221
|
+
},
|
|
222
|
+
options.map((opt) => {
|
|
223
|
+
const isActive = (selected == null ? void 0 : selected.value) === opt.value;
|
|
224
|
+
return /* @__PURE__ */ React.createElement(
|
|
225
|
+
"button",
|
|
226
|
+
{
|
|
227
|
+
key: opt.value,
|
|
228
|
+
type: "button",
|
|
229
|
+
onClick: () => onSelect(opt),
|
|
230
|
+
style: {
|
|
231
|
+
display: "flex",
|
|
232
|
+
alignItems: "center",
|
|
233
|
+
justifyContent: "center",
|
|
234
|
+
gap: 6,
|
|
235
|
+
padding: "8px 10px",
|
|
236
|
+
borderRadius: 4,
|
|
237
|
+
border: isActive ? "1px solid var(--primary-main)" : "1px solid var(--border-main)",
|
|
238
|
+
background: isActive ? "var(--primary-lighter)" : "#fff",
|
|
239
|
+
color: isActive ? "var(--primary-main)" : "var(--text-primary)",
|
|
240
|
+
fontWeight: isActive ? 600 : 400,
|
|
241
|
+
fontSize: 13,
|
|
242
|
+
cursor: "pointer",
|
|
243
|
+
fontFamily: "inherit",
|
|
244
|
+
transition: "background 0.15s, border-color 0.15s",
|
|
245
|
+
minWidth: 0
|
|
246
|
+
}
|
|
247
|
+
},
|
|
248
|
+
/* @__PURE__ */ React.createElement(
|
|
249
|
+
"span",
|
|
250
|
+
{
|
|
251
|
+
style: {
|
|
252
|
+
display: "inline-flex",
|
|
253
|
+
alignItems: "center",
|
|
254
|
+
flexShrink: 0
|
|
255
|
+
}
|
|
256
|
+
},
|
|
257
|
+
iconMap[opt.value]
|
|
258
|
+
),
|
|
259
|
+
/* @__PURE__ */ React.createElement("span", { style: { whiteSpace: "nowrap" } }, opt.label)
|
|
260
|
+
);
|
|
261
|
+
})
|
|
262
|
+
));
|
|
66
263
|
this.state = { open: false, languageOptions: [] };
|
|
67
264
|
this.containerRef = React.createRef();
|
|
68
265
|
this.popperRef = React.createRef();
|
|
@@ -75,13 +272,7 @@ class SettingPopper extends React.Component {
|
|
|
75
272
|
document.removeEventListener("mousedown", this.handleClickOutside);
|
|
76
273
|
}
|
|
77
274
|
render() {
|
|
78
|
-
const {
|
|
79
|
-
lang,
|
|
80
|
-
originalEmail,
|
|
81
|
-
setOriginalEmail,
|
|
82
|
-
getEditorContent,
|
|
83
|
-
parentRef
|
|
84
|
-
} = this.props;
|
|
275
|
+
const { lang, tone, length, parentRef } = this.props;
|
|
85
276
|
const { open, languageOptions } = this.state;
|
|
86
277
|
let popperTop = 0;
|
|
87
278
|
let popperLeft = 0;
|
|
@@ -139,78 +330,43 @@ class SettingPopper extends React.Component {
|
|
|
139
330
|
/* @__PURE__ */ React.createElement(
|
|
140
331
|
"div",
|
|
141
332
|
{
|
|
142
|
-
style: { display: "flex", flexDirection: "column", gap:
|
|
333
|
+
style: { display: "flex", flexDirection: "column", gap: 6 }
|
|
143
334
|
},
|
|
335
|
+
/* @__PURE__ */ React.createElement("span", { style: { fontSize: 12, fontWeight: 600 } }, "Language"),
|
|
144
336
|
/* @__PURE__ */ React.createElement(
|
|
145
|
-
|
|
146
|
-
{
|
|
147
|
-
style: {
|
|
148
|
-
fontSize: 12,
|
|
149
|
-
fontWeight: 500
|
|
150
|
-
// color: "var(--text-secondary)",
|
|
151
|
-
}
|
|
152
|
-
},
|
|
153
|
-
"Language"
|
|
154
|
-
),
|
|
155
|
-
/* @__PURE__ */ React.createElement(
|
|
156
|
-
"select",
|
|
337
|
+
LanguageSelect,
|
|
157
338
|
{
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
onChange: this.
|
|
161
|
-
}
|
|
162
|
-
/* @__PURE__ */ React.createElement("option", { value: "", disabled: true }, "Select Language"),
|
|
163
|
-
languageOptions.map((opt) => {
|
|
164
|
-
return /* @__PURE__ */ React.createElement("option", { key: opt.value, value: opt.value }, opt.label);
|
|
165
|
-
})
|
|
339
|
+
value: lang,
|
|
340
|
+
options: languageOptions,
|
|
341
|
+
onChange: (opt) => this.props.setLang(opt)
|
|
342
|
+
}
|
|
166
343
|
)
|
|
167
344
|
),
|
|
168
345
|
/* @__PURE__ */ React.createElement(
|
|
169
346
|
"div",
|
|
170
347
|
{
|
|
171
|
-
style: { display: "flex", flexDirection: "column", gap:
|
|
348
|
+
style: { display: "flex", flexDirection: "column", gap: 6 }
|
|
172
349
|
},
|
|
173
|
-
/* @__PURE__ */ React.createElement(
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
getEditorContent && /* @__PURE__ */ React.createElement(Tooltip, { title: "Copy from origin email" }, /* @__PURE__ */ React.createElement(
|
|
194
|
-
"button",
|
|
195
|
-
{
|
|
196
|
-
type: "button",
|
|
197
|
-
onClick: () => {
|
|
198
|
-
const currentContent = getEditorContent();
|
|
199
|
-
setOriginalEmail(currentContent);
|
|
200
|
-
},
|
|
201
|
-
className: "icon-button small"
|
|
202
|
-
},
|
|
203
|
-
/* @__PURE__ */ React.createElement(Copy, null)
|
|
204
|
-
))
|
|
205
|
-
),
|
|
206
|
-
/* @__PURE__ */ React.createElement(
|
|
207
|
-
TinyMceEditor,
|
|
208
|
-
{
|
|
209
|
-
value: originalEmail,
|
|
210
|
-
onChange: (val) => setOriginalEmail(val),
|
|
211
|
-
height: 350,
|
|
212
|
-
isSimple: true
|
|
213
|
-
}
|
|
350
|
+
/* @__PURE__ */ React.createElement("span", { style: { fontSize: 12, fontWeight: 600 } }, "Tone"),
|
|
351
|
+
this.renderChipGroup(
|
|
352
|
+
TONE_OPTIONS,
|
|
353
|
+
tone,
|
|
354
|
+
(opt) => this.props.setTone(opt),
|
|
355
|
+
TONE_ICONS
|
|
356
|
+
)
|
|
357
|
+
),
|
|
358
|
+
/* @__PURE__ */ React.createElement(
|
|
359
|
+
"div",
|
|
360
|
+
{
|
|
361
|
+
style: { display: "flex", flexDirection: "column", gap: 6 }
|
|
362
|
+
},
|
|
363
|
+
/* @__PURE__ */ React.createElement("span", { style: { fontSize: 12, fontWeight: 600 } }, "Length"),
|
|
364
|
+
this.renderChipGroup(
|
|
365
|
+
LENGTH_OPTIONS,
|
|
366
|
+
length,
|
|
367
|
+
(opt) => this.props.setLength(opt),
|
|
368
|
+
LENGTH_ICONS,
|
|
369
|
+
4
|
|
214
370
|
)
|
|
215
371
|
)
|
|
216
372
|
)
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const TONE_OPTIONS = [
|
|
2
|
+
{ label: "Formal", value: "formal" },
|
|
3
|
+
{ label: "Polite", value: "polite" },
|
|
4
|
+
{ label: "Neutral", value: "neutral" },
|
|
5
|
+
{ label: "Friendly", value: "friendly" },
|
|
6
|
+
{ label: "Firm", value: "firm" },
|
|
7
|
+
{ label: "Apology", value: "apologetic" }
|
|
8
|
+
];
|
|
9
|
+
const LENGTH_OPTIONS = [
|
|
10
|
+
{ label: "Short", value: "short" },
|
|
11
|
+
{ label: "Medium", value: "medium" },
|
|
12
|
+
{ label: "Long", value: "long" },
|
|
13
|
+
{ label: "1-liner", value: "one_liner" }
|
|
14
|
+
];
|
|
15
|
+
export {
|
|
16
|
+
LENGTH_OPTIONS,
|
|
17
|
+
TONE_OPTIONS
|
|
18
|
+
};
|
|
@@ -7,10 +7,6 @@ export interface ChatAIDraftProps {
|
|
|
7
7
|
html: string;
|
|
8
8
|
}) => void;
|
|
9
9
|
}
|
|
10
|
-
/** Public imperative API exposed via ref */
|
|
11
|
-
export interface ChatAIDraftRef {
|
|
12
|
-
setAIContext: (html: string) => void;
|
|
13
|
-
}
|
|
14
10
|
export interface AIMessage {
|
|
15
11
|
id: string;
|
|
16
12
|
question: string;
|
|
@@ -24,18 +20,19 @@ interface AIPaneState {
|
|
|
24
20
|
messages: AIMessage[];
|
|
25
21
|
isSending: boolean;
|
|
26
22
|
lang: LabelValue | null;
|
|
23
|
+
tone: LabelValue | null;
|
|
24
|
+
length: LabelValue | null;
|
|
27
25
|
conversationId: string;
|
|
28
|
-
originalEmail: string;
|
|
29
26
|
}
|
|
30
|
-
declare class ChatAIDraft extends React.Component<ChatAIDraftProps, AIPaneState>
|
|
27
|
+
declare class ChatAIDraft extends React.Component<ChatAIDraftProps, AIPaneState> {
|
|
31
28
|
private rootRef;
|
|
32
29
|
constructor(props: ChatAIDraftProps);
|
|
33
|
-
setAIContext: (html: string) => void;
|
|
34
30
|
handleMessageChange: (e: React.ChangeEvent<HTMLTextAreaElement>) => void;
|
|
35
31
|
handleSubmit: () => Promise<void>;
|
|
36
32
|
handleKeyDown: (event: React.KeyboardEvent<HTMLTextAreaElement>) => void;
|
|
37
33
|
setLang: (lang: LabelValue | null) => void;
|
|
38
|
-
|
|
34
|
+
setTone: (tone: LabelValue | null) => void;
|
|
35
|
+
setLength: (length: LabelValue | null) => void;
|
|
39
36
|
render(): React.JSX.Element;
|
|
40
37
|
}
|
|
41
38
|
export default ChatAIDraft;
|
|
@@ -39,27 +39,25 @@ var __async = (__this, __arguments, generator) => {
|
|
|
39
39
|
});
|
|
40
40
|
};
|
|
41
41
|
import * as React from "react";
|
|
42
|
-
import CustomAiIcon from "./CustomAIIcon.js";
|
|
43
42
|
import { callAI } from "./helper.js";
|
|
44
43
|
import List from "./List.js";
|
|
44
|
+
import EmptyState from "./EmptyState.js";
|
|
45
45
|
import SettingPopper from "./SettingPopper.js";
|
|
46
|
+
import { LENGTH_OPTIONS, TONE_OPTIONS } from "./constants.js";
|
|
46
47
|
import { AI_LANG_FLAGS } from "../../constants/index.js";
|
|
47
48
|
import CountryFlag from "../CountryFlag/index.js";
|
|
48
49
|
import v4 from "../../node_modules/uuid/dist/esm-browser/v4.js";
|
|
49
|
-
import
|
|
50
|
+
import ArrowUp from "../../node_modules/react-feather/dist/icons/arrow-up.js";
|
|
50
51
|
class ChatAIDraft extends React.Component {
|
|
51
52
|
constructor(props) {
|
|
52
53
|
var _a;
|
|
53
54
|
super(props);
|
|
54
55
|
__publicField(this, "rootRef");
|
|
55
|
-
__publicField(this, "setAIContext", (html) => {
|
|
56
|
-
this.setState({ originalEmail: html });
|
|
57
|
-
});
|
|
58
56
|
__publicField(this, "handleMessageChange", (e) => {
|
|
59
57
|
this.setState({ message: e.target.value });
|
|
60
58
|
});
|
|
61
59
|
__publicField(this, "handleSubmit", () => __async(this, null, function* () {
|
|
62
|
-
const { message, messages, lang,
|
|
60
|
+
const { message, messages, lang, tone, length, conversationId } = this.state;
|
|
63
61
|
if (!message.trim()) return;
|
|
64
62
|
const newId = v4();
|
|
65
63
|
let newMessage = {
|
|
@@ -79,9 +77,14 @@ class ChatAIDraft extends React.Component {
|
|
|
79
77
|
const params = {
|
|
80
78
|
query: message,
|
|
81
79
|
default_language: lang ? lang.value : "KR",
|
|
82
|
-
original_email: originalEmail,
|
|
83
80
|
debug_grpc: true
|
|
84
81
|
};
|
|
82
|
+
if (tone) {
|
|
83
|
+
params.tone = tone.value;
|
|
84
|
+
}
|
|
85
|
+
if (length) {
|
|
86
|
+
params.length = length.value;
|
|
87
|
+
}
|
|
85
88
|
if (conversationId) {
|
|
86
89
|
params.conversation_id = conversationId;
|
|
87
90
|
}
|
|
@@ -125,8 +128,11 @@ class ChatAIDraft extends React.Component {
|
|
|
125
128
|
__publicField(this, "setLang", (lang) => {
|
|
126
129
|
this.setState({ lang });
|
|
127
130
|
});
|
|
128
|
-
__publicField(this, "
|
|
129
|
-
this.setState({
|
|
131
|
+
__publicField(this, "setTone", (tone) => {
|
|
132
|
+
this.setState({ tone });
|
|
133
|
+
});
|
|
134
|
+
__publicField(this, "setLength", (length) => {
|
|
135
|
+
this.setState({ length });
|
|
130
136
|
});
|
|
131
137
|
this.rootRef = React.createRef();
|
|
132
138
|
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];
|
|
@@ -135,14 +141,17 @@ class ChatAIDraft extends React.Component {
|
|
|
135
141
|
messages: [],
|
|
136
142
|
isSending: false,
|
|
137
143
|
lang,
|
|
138
|
-
|
|
139
|
-
|
|
144
|
+
tone: TONE_OPTIONS[2],
|
|
145
|
+
// Neutral
|
|
146
|
+
length: LENGTH_OPTIONS[1],
|
|
147
|
+
// Medium
|
|
148
|
+
conversationId: ""
|
|
140
149
|
};
|
|
141
150
|
}
|
|
142
151
|
render() {
|
|
143
152
|
var _a, _b;
|
|
144
153
|
const { onApply, getEditorContent } = this.props;
|
|
145
|
-
const { message, messages, isSending, lang,
|
|
154
|
+
const { message, messages, isSending, lang, tone, length } = this.state;
|
|
146
155
|
const flagCode = (_b = (_a = AI_LANG_FLAGS) == null ? void 0 : _a.find(
|
|
147
156
|
(_item) => (_item == null ? void 0 : _item.value) === (lang == null ? void 0 : lang.value)
|
|
148
157
|
)) == null ? void 0 : _b.flagCode;
|
|
@@ -168,41 +177,19 @@ class ChatAIDraft extends React.Component {
|
|
|
168
177
|
getEditorContent
|
|
169
178
|
}
|
|
170
179
|
) : /* @__PURE__ */ React.createElement(
|
|
171
|
-
|
|
180
|
+
EmptyState,
|
|
172
181
|
{
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
minHeight: 0,
|
|
176
|
-
display: "flex",
|
|
177
|
-
flexDirection: "column",
|
|
178
|
-
alignItems: "center",
|
|
179
|
-
justifyContent: "center",
|
|
180
|
-
color: "var(--grey-light)"
|
|
181
|
-
}
|
|
182
|
-
},
|
|
183
|
-
/* @__PURE__ */ React.createElement(CustomAiIcon, { size: 46 }),
|
|
184
|
-
/* @__PURE__ */ React.createElement(
|
|
185
|
-
"h2",
|
|
186
|
-
{
|
|
187
|
-
style: {
|
|
188
|
-
marginTop: 16,
|
|
189
|
-
fontWeight: 600,
|
|
190
|
-
color: "inherit",
|
|
191
|
-
fontSize: 18
|
|
192
|
-
}
|
|
193
|
-
},
|
|
194
|
-
"Build with Agent"
|
|
195
|
-
)
|
|
182
|
+
onSelectPrompt: (text) => this.setState({ message: text })
|
|
183
|
+
}
|
|
196
184
|
),
|
|
197
185
|
/* @__PURE__ */ React.createElement(
|
|
198
186
|
"div",
|
|
199
187
|
{
|
|
200
188
|
style: {
|
|
201
189
|
width: "100%",
|
|
202
|
-
|
|
203
|
-
borderRadius: 4,
|
|
190
|
+
borderRadius: 12,
|
|
204
191
|
overflow: "hidden",
|
|
205
|
-
background: "
|
|
192
|
+
background: "var(--background-softGrey)",
|
|
206
193
|
display: "flex",
|
|
207
194
|
flexDirection: "column"
|
|
208
195
|
}
|
|
@@ -219,14 +206,14 @@ class ChatAIDraft extends React.Component {
|
|
|
219
206
|
style: {
|
|
220
207
|
flex: 1,
|
|
221
208
|
minWidth: 0,
|
|
222
|
-
borderRadius: 4,
|
|
223
209
|
padding: 12,
|
|
224
210
|
fontSize: 13,
|
|
225
211
|
border: "none",
|
|
226
212
|
resize: "none",
|
|
227
213
|
outline: "none",
|
|
228
214
|
minHeight: 60,
|
|
229
|
-
fontFamily: "inherit"
|
|
215
|
+
fontFamily: "inherit",
|
|
216
|
+
background: "transparent"
|
|
230
217
|
}
|
|
231
218
|
}
|
|
232
219
|
),
|
|
@@ -247,9 +234,10 @@ class ChatAIDraft extends React.Component {
|
|
|
247
234
|
{
|
|
248
235
|
lang,
|
|
249
236
|
setLang: this.setLang,
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
237
|
+
tone,
|
|
238
|
+
setTone: this.setTone,
|
|
239
|
+
length,
|
|
240
|
+
setLength: this.setLength,
|
|
253
241
|
parentRef: this.rootRef
|
|
254
242
|
}
|
|
255
243
|
),
|
|
@@ -260,16 +248,60 @@ class ChatAIDraft extends React.Component {
|
|
|
260
248
|
style: { marginLeft: 4, height: 14 }
|
|
261
249
|
}
|
|
262
250
|
),
|
|
251
|
+
(tone || length) && /* @__PURE__ */ React.createElement(
|
|
252
|
+
"span",
|
|
253
|
+
{
|
|
254
|
+
style: {
|
|
255
|
+
marginLeft: 8,
|
|
256
|
+
padding: "2px 8px",
|
|
257
|
+
borderRadius: 999,
|
|
258
|
+
background: "var(--primary-lighter)",
|
|
259
|
+
color: "var(--primary-main)",
|
|
260
|
+
fontSize: 11,
|
|
261
|
+
fontWeight: 500,
|
|
262
|
+
whiteSpace: "nowrap",
|
|
263
|
+
display: "inline-flex",
|
|
264
|
+
alignItems: "center",
|
|
265
|
+
gap: 4
|
|
266
|
+
}
|
|
267
|
+
},
|
|
268
|
+
(tone == null ? void 0 : tone.label) && /* @__PURE__ */ React.createElement("span", null, tone.label),
|
|
269
|
+
(tone == null ? void 0 : tone.label) && (length == null ? void 0 : length.label) && /* @__PURE__ */ React.createElement(
|
|
270
|
+
"span",
|
|
271
|
+
{
|
|
272
|
+
style: {
|
|
273
|
+
width: 3,
|
|
274
|
+
height: 3,
|
|
275
|
+
borderRadius: "50%",
|
|
276
|
+
background: "currentColor",
|
|
277
|
+
display: "inline-block"
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
),
|
|
281
|
+
(length == null ? void 0 : length.label) && /* @__PURE__ */ React.createElement("span", null, length.label)
|
|
282
|
+
),
|
|
263
283
|
/* @__PURE__ */ React.createElement(
|
|
264
284
|
"button",
|
|
265
285
|
{
|
|
286
|
+
type: "button",
|
|
266
287
|
disabled: !message.trim() || isSending,
|
|
267
288
|
onClick: this.handleSubmit,
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
289
|
+
style: {
|
|
290
|
+
marginLeft: "auto",
|
|
291
|
+
width: 32,
|
|
292
|
+
height: 32,
|
|
293
|
+
borderRadius: "50%",
|
|
294
|
+
border: "none",
|
|
295
|
+
display: "flex",
|
|
296
|
+
alignItems: "center",
|
|
297
|
+
justifyContent: "center",
|
|
298
|
+
background: !message.trim() || isSending ? "var(--primary-lighter)" : "var(--primary-main)",
|
|
299
|
+
color: "var(--primary-contrasttext)",
|
|
300
|
+
cursor: !message.trim() || isSending ? "not-allowed" : "pointer",
|
|
301
|
+
transition: "background 0.15s ease-in-out"
|
|
302
|
+
}
|
|
271
303
|
},
|
|
272
|
-
/* @__PURE__ */ React.createElement(
|
|
304
|
+
/* @__PURE__ */ React.createElement(ArrowUp, { size: 18 })
|
|
273
305
|
)
|
|
274
306
|
)
|
|
275
307
|
)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { default as ChatAIDraft
|
|
1
|
+
export { default as ChatAIDraft } from './ChatAIDraft';
|
|
2
2
|
export { default as LoadingCircular } from './LoadingCircular';
|
|
3
3
|
export { default as LoadingContainer } from './LoadingContainer';
|
|
4
4
|
export { default as Tooltip } from './Tooltip';
|