hanbiro-react16-sdk 1.0.18 → 1.0.19
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/README.md +2 -19
- package/dist/_virtual/_commonjsHelpers.js +6 -0
- package/dist/_virtual/index.js +4 -0
- package/dist/components/ChatAIDraft/CustomAIIcon.js +63 -0
- package/dist/components/ChatAIDraft/List.js +151 -0
- package/dist/components/ChatAIDraft/SettingPopper.js +225 -0
- package/dist/components/ChatAIDraft/TypingText.js +39 -0
- package/dist/components/ChatAIDraft/helper.js +121 -0
- package/dist/components/ChatAIDraft/index.js +281 -0
- package/dist/components/CountryFlag/flags/CNFlag.js +27 -0
- package/dist/components/CountryFlag/flags/DEFlag.js +21 -0
- package/dist/components/CountryFlag/flags/ESFlag.js +457 -0
- package/dist/components/CountryFlag/flags/FRFlag.js +21 -0
- package/dist/components/CountryFlag/flags/IDFlag.js +21 -0
- package/dist/components/CountryFlag/flags/ITFlag.js +21 -0
- package/dist/components/CountryFlag/flags/JPFlag.js +21 -0
- package/dist/components/CountryFlag/flags/KRFlag.js +39 -0
- package/dist/components/CountryFlag/flags/NLFlag.js +21 -0
- package/dist/components/CountryFlag/flags/PTFlag.js +139 -0
- package/dist/components/CountryFlag/flags/RUFlag.js +21 -0
- package/dist/components/CountryFlag/flags/SAFlag.js +24 -0
- package/dist/components/CountryFlag/flags/THFlag.js +21 -0
- package/dist/components/CountryFlag/flags/TWFlag.js +28 -0
- package/dist/components/CountryFlag/flags/USFlag.js +34 -0
- package/dist/components/CountryFlag/flags/VNFlag.js +29 -0
- package/dist/components/CountryFlag/index.js +73 -0
- package/dist/components/LoadingCircular/index.js +37 -0
- package/dist/components/LoadingContainer/index.js +53 -0
- package/dist/components/TinyMceEditor/index.js +181 -0
- package/dist/components/TinyMceEditor/scrollStyle.js +40 -0
- package/dist/components/TinyMceEditor/useEditor.js +120 -0
- package/dist/components/Tooltip/index.js +172 -0
- package/dist/constants/index.js +85 -0
- package/dist/hanbiro-react16-sdk.style.css +1 -1
- package/dist/hanbiro-react16-sdk.umd.js +2 -9680
- package/dist/index.js +23 -0
- package/dist/node_modules/@tinymce/tinymce-react/lib/es2015/main/ts/ScriptLoader2.js +148 -0
- package/dist/node_modules/@tinymce/tinymce-react/lib/es2015/main/ts/TinyMCE.js +7 -0
- package/dist/node_modules/@tinymce/tinymce-react/lib/es2015/main/ts/Utils.js +103 -0
- package/dist/node_modules/@tinymce/tinymce-react/lib/es2015/main/ts/components/Editor.js +353 -0
- package/dist/node_modules/@tinymce/tinymce-react/lib/es2015/main/ts/components/EditorPropTypes.js +102 -0
- package/dist/node_modules/axios/index.js +38 -0
- package/dist/node_modules/axios/lib/adapters/adapters.js +71 -0
- package/dist/node_modules/axios/lib/adapters/fetch.js +272 -0
- package/dist/node_modules/axios/lib/adapters/xhr.js +153 -0
- package/dist/node_modules/axios/lib/axios.js +50 -0
- package/dist/node_modules/axios/lib/cancel/CancelToken.js +99 -0
- package/dist/node_modules/axios/lib/cancel/CanceledError.js +20 -0
- package/dist/node_modules/axios/lib/cancel/isCancel.js +6 -0
- package/dist/node_modules/axios/lib/core/Axios.js +220 -0
- package/dist/node_modules/axios/lib/core/AxiosError.js +76 -0
- package/dist/node_modules/axios/lib/core/AxiosHeaders.js +238 -0
- package/dist/node_modules/axios/lib/core/InterceptorManager.js +66 -0
- package/dist/node_modules/axios/lib/core/buildFullPath.js +12 -0
- package/dist/node_modules/axios/lib/core/dispatchRequest.js +48 -0
- package/dist/node_modules/axios/lib/core/mergeConfig.js +100 -0
- package/dist/node_modules/axios/lib/core/settle.js +20 -0
- package/dist/node_modules/axios/lib/core/transformData.js +17 -0
- package/dist/node_modules/axios/lib/defaults/index.js +120 -0
- package/dist/node_modules/axios/lib/defaults/transitional.js +9 -0
- package/dist/node_modules/axios/lib/env/data.js +4 -0
- package/dist/node_modules/axios/lib/helpers/AxiosURLSearchParams.js +34 -0
- package/dist/node_modules/axios/lib/helpers/HttpStatusCode.js +77 -0
- package/dist/node_modules/axios/lib/helpers/bind.js +8 -0
- package/dist/node_modules/axios/lib/helpers/buildURL.js +32 -0
- package/dist/node_modules/axios/lib/helpers/combineURLs.js +6 -0
- package/dist/node_modules/axios/lib/helpers/composeSignals.js +41 -0
- package/dist/node_modules/axios/lib/helpers/cookies.js +49 -0
- package/dist/node_modules/axios/lib/helpers/formDataToJSON.js +54 -0
- package/dist/node_modules/axios/lib/helpers/isAbsoluteURL.js +9 -0
- package/dist/node_modules/axios/lib/helpers/isAxiosError.js +7 -0
- package/dist/node_modules/axios/lib/helpers/isURLSameOrigin.js +11 -0
- package/dist/node_modules/axios/lib/helpers/null.js +4 -0
- package/dist/node_modules/axios/lib/helpers/parseHeaders.js +47 -0
- package/dist/node_modules/axios/lib/helpers/parseProtocol.js +7 -0
- package/dist/node_modules/axios/lib/helpers/progressEventReducer.js +44 -0
- package/dist/node_modules/axios/lib/helpers/resolveConfig.js +52 -0
- package/dist/node_modules/axios/lib/helpers/speedometer.js +36 -0
- package/dist/node_modules/axios/lib/helpers/spread.js +8 -0
- package/dist/node_modules/axios/lib/helpers/throttle.js +35 -0
- package/dist/node_modules/axios/lib/helpers/toFormData.js +120 -0
- package/dist/node_modules/axios/lib/helpers/toURLEncodedForm.js +33 -0
- package/dist/node_modules/axios/lib/helpers/trackStream.js +169 -0
- package/dist/node_modules/axios/lib/helpers/validator.js +70 -0
- package/dist/node_modules/axios/lib/platform/browser/classes/Blob.js +4 -0
- package/dist/node_modules/axios/lib/platform/browser/classes/FormData.js +4 -0
- package/dist/node_modules/axios/lib/platform/browser/classes/URLSearchParams.js +5 -0
- package/dist/node_modules/axios/lib/platform/browser/index.js +15 -0
- package/dist/node_modules/axios/lib/platform/common/utils.js +15 -0
- package/dist/node_modules/axios/lib/platform/index.js +22 -0
- package/dist/node_modules/axios/lib/utils.js +429 -0
- package/dist/node_modules/marked/lib/marked.esm.js +2169 -0
- package/dist/node_modules/prop-types/factoryWithThrowingShims.js +51 -0
- package/dist/node_modules/prop-types/index.js +12 -0
- package/dist/node_modules/prop-types/lib/ReactPropTypesSecret.js +5 -0
- package/dist/node_modules/react-feather/dist/icons/copy.js +75 -0
- package/dist/node_modules/react-feather/dist/icons/send.js +73 -0
- package/dist/node_modules/react-feather/dist/icons/settings.js +72 -0
- package/dist/node_modules/uuid/dist/esm-browser/native.js +7 -0
- package/dist/node_modules/uuid/dist/esm-browser/rng.js +14 -0
- package/dist/node_modules/uuid/dist/esm-browser/stringify.js +10 -0
- package/dist/node_modules/uuid/dist/esm-browser/v4.js +16 -0
- package/dist/utils/axiosAPI.js +89 -0
- package/dist/utils/url.js +54 -0
- package/package.json +2 -1
- package/dist/hanbiro-react16-sdk.es.js +0 -7911
package/README.md
CHANGED
|
@@ -238,24 +238,7 @@ function setEmailContext(html) {
|
|
|
238
238
|
Follow these steps when updating the library:
|
|
239
239
|
|
|
240
240
|
1. **Finish coding**: Make your changes in the `src` directory.
|
|
241
|
-
2. **
|
|
241
|
+
2. **Publish**: Run the publish script which will automatically run typecheck, build, commit, bump version, and publish to npm.
|
|
242
242
|
```bash
|
|
243
|
-
|
|
244
|
-
```
|
|
245
|
-
3. **Build**: Run the build command and ensure there are no errors.
|
|
246
|
-
```bash
|
|
247
|
-
npm run build
|
|
248
|
-
```
|
|
249
|
-
4. **Commit**: Commit your changes to git.
|
|
250
|
-
5. **Patch version**: Increment the version number.
|
|
251
|
-
```bash
|
|
252
|
-
npm version patch
|
|
253
|
-
```
|
|
254
|
-
6. **Push**: Push the changes and tags to GitHub.
|
|
255
|
-
```bash
|
|
256
|
-
git push origin main --follow-tags
|
|
257
|
-
```
|
|
258
|
-
7. **Publish**: Publish the new version to npm.
|
|
259
|
-
```bash
|
|
260
|
-
npm publish
|
|
243
|
+
python3 publish.py
|
|
261
244
|
```
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
const CustomAiIcon = ({ isGradient = false, stroke = 1.5, size = 40 }) => {
|
|
3
|
+
const gradientId = "ai-gradient-" + Math.random().toString(36).substr(2, 9);
|
|
4
|
+
return /* @__PURE__ */ React.createElement(
|
|
5
|
+
"svg",
|
|
6
|
+
{
|
|
7
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
8
|
+
width: size,
|
|
9
|
+
height: size,
|
|
10
|
+
viewBox: "0 0 24 24",
|
|
11
|
+
style: { flexShrink: 0 }
|
|
12
|
+
},
|
|
13
|
+
isGradient && /* @__PURE__ */ React.createElement("defs", null, /* @__PURE__ */ React.createElement("linearGradient", { id: gradientId, x1: "0%", y1: "0%", x2: "0%", y2: "100%" }, /* @__PURE__ */ React.createElement("stop", { offset: "0%", stopColor: "#9D50BB" }, /* @__PURE__ */ React.createElement(
|
|
14
|
+
"animate",
|
|
15
|
+
{
|
|
16
|
+
attributeName: "offset",
|
|
17
|
+
values: "0%;0.4;0%",
|
|
18
|
+
dur: "1s",
|
|
19
|
+
repeatCount: "indefinite"
|
|
20
|
+
}
|
|
21
|
+
)), /* @__PURE__ */ React.createElement("stop", { offset: "30%", stopColor: "#6E48AA" }, /* @__PURE__ */ React.createElement(
|
|
22
|
+
"animate",
|
|
23
|
+
{
|
|
24
|
+
attributeName: "offset",
|
|
25
|
+
values: "0.4;0.7;0.4",
|
|
26
|
+
dur: "1s",
|
|
27
|
+
repeatCount: "indefinite"
|
|
28
|
+
}
|
|
29
|
+
)), /* @__PURE__ */ React.createElement("stop", { offset: "50%", stopColor: "#4776E6" }, /* @__PURE__ */ React.createElement(
|
|
30
|
+
"animate",
|
|
31
|
+
{
|
|
32
|
+
attributeName: "offset",
|
|
33
|
+
values: "0.5;0.7;0.5",
|
|
34
|
+
dur: "1s",
|
|
35
|
+
repeatCount: "indefinite"
|
|
36
|
+
}
|
|
37
|
+
)), /* @__PURE__ */ React.createElement(
|
|
38
|
+
"animateTransform",
|
|
39
|
+
{
|
|
40
|
+
attributeName: "gradientTransform",
|
|
41
|
+
type: "translate",
|
|
42
|
+
from: "0,0",
|
|
43
|
+
to: "100,0",
|
|
44
|
+
dur: "1s",
|
|
45
|
+
repeatCount: "indefinite"
|
|
46
|
+
}
|
|
47
|
+
))),
|
|
48
|
+
/* @__PURE__ */ React.createElement(
|
|
49
|
+
"path",
|
|
50
|
+
{
|
|
51
|
+
fill: "none",
|
|
52
|
+
stroke: isGradient ? `url(#${gradientId})` : "currentColor",
|
|
53
|
+
strokeLinecap: "round",
|
|
54
|
+
strokeLinejoin: "round",
|
|
55
|
+
strokeWidth: stroke,
|
|
56
|
+
d: "M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0zM20 3v4m2-2h-4M4 17v2m1-1H3"
|
|
57
|
+
}
|
|
58
|
+
)
|
|
59
|
+
);
|
|
60
|
+
};
|
|
61
|
+
export {
|
|
62
|
+
CustomAiIcon as default
|
|
63
|
+
};
|
|
@@ -0,0 +1,151 @@
|
|
|
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 { marked } from "../../node_modules/marked/lib/marked.esm.js";
|
|
23
|
+
import TypingText from "./TypingText.js";
|
|
24
|
+
import LoadingCircular from "../LoadingCircular/index.js";
|
|
25
|
+
import Tooltip from "../Tooltip/index.js";
|
|
26
|
+
import Copy from "../../node_modules/react-feather/dist/icons/copy.js";
|
|
27
|
+
const List = ({
|
|
28
|
+
items,
|
|
29
|
+
onApply,
|
|
30
|
+
getEditorContent
|
|
31
|
+
}) => {
|
|
32
|
+
const handleApply = (body) => __async(void 0, null, function* () {
|
|
33
|
+
const titleRegex = /제목:[^\n]*/g;
|
|
34
|
+
const matches = titleRegex.exec(body) || [];
|
|
35
|
+
(matches[0] || "").replace("제목: ", "").replace("\n", "");
|
|
36
|
+
const content = body.replace(titleRegex, "").replace("본문: ", "");
|
|
37
|
+
let html = yield marked.parse(content);
|
|
38
|
+
const signatureRegex = /<!--HanbiroSignatureStart-->([\s\S]*?)<!--HanbiroSignatureEnd-->/g;
|
|
39
|
+
const editorValue = getEditorContent ? getEditorContent() : "";
|
|
40
|
+
const signatureMatch = signatureRegex.exec(editorValue) || [];
|
|
41
|
+
if (signatureMatch[0]) {
|
|
42
|
+
html = html + "<br>" + signatureMatch[0];
|
|
43
|
+
}
|
|
44
|
+
onApply({ html });
|
|
45
|
+
});
|
|
46
|
+
return /* @__PURE__ */ React.createElement(
|
|
47
|
+
"div",
|
|
48
|
+
{
|
|
49
|
+
style: {
|
|
50
|
+
flex: 1,
|
|
51
|
+
minHeight: 0,
|
|
52
|
+
position: "relative",
|
|
53
|
+
overflowY: "auto",
|
|
54
|
+
paddingRight: 16,
|
|
55
|
+
marginRight: -16,
|
|
56
|
+
marginBottom: 8,
|
|
57
|
+
display: "flex",
|
|
58
|
+
flexDirection: "column"
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
items && items.map((_item) => /* @__PURE__ */ React.createElement(
|
|
62
|
+
"div",
|
|
63
|
+
{
|
|
64
|
+
key: _item.id,
|
|
65
|
+
style: {
|
|
66
|
+
display: "flex",
|
|
67
|
+
flexDirection: "column",
|
|
68
|
+
marginBottom: 16
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
/* @__PURE__ */ React.createElement(
|
|
72
|
+
"div",
|
|
73
|
+
{
|
|
74
|
+
style: {
|
|
75
|
+
width: "100%",
|
|
76
|
+
display: "flex",
|
|
77
|
+
alignItems: "flex-end",
|
|
78
|
+
flexDirection: "column",
|
|
79
|
+
position: "relative",
|
|
80
|
+
marginTop: 8
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
/* @__PURE__ */ React.createElement(
|
|
84
|
+
TypingText,
|
|
85
|
+
{
|
|
86
|
+
data: { question: _item.question },
|
|
87
|
+
style: {
|
|
88
|
+
borderRadius: 8,
|
|
89
|
+
borderTopRightRadius: 0,
|
|
90
|
+
padding: "8px 12px",
|
|
91
|
+
background: "var(--background-softGrey)"
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
)
|
|
95
|
+
),
|
|
96
|
+
/* @__PURE__ */ React.createElement(
|
|
97
|
+
"div",
|
|
98
|
+
{
|
|
99
|
+
style: {
|
|
100
|
+
width: "100%",
|
|
101
|
+
display: "flex",
|
|
102
|
+
alignItems: "flex-start",
|
|
103
|
+
flexDirection: "column",
|
|
104
|
+
position: "relative",
|
|
105
|
+
marginTop: 8
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
(_item == null ? void 0 : _item.isLoading) ? /* @__PURE__ */ React.createElement(LoadingCircular, { size: 32 }) : /* @__PURE__ */ React.createElement(
|
|
109
|
+
"div",
|
|
110
|
+
{
|
|
111
|
+
style: {
|
|
112
|
+
display: "flex",
|
|
113
|
+
flexDirection: "row",
|
|
114
|
+
alignItems: "flex-end",
|
|
115
|
+
width: "100%"
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
/* @__PURE__ */ React.createElement(
|
|
119
|
+
TypingText,
|
|
120
|
+
{
|
|
121
|
+
data: { subject: _item.subject, body: _item.body },
|
|
122
|
+
style: {
|
|
123
|
+
background: "var(--background-softGrey)",
|
|
124
|
+
borderRadius: 8,
|
|
125
|
+
borderTopLeftRadius: 0,
|
|
126
|
+
padding: "8px 12px",
|
|
127
|
+
flexShrink: 0
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
),
|
|
131
|
+
/* @__PURE__ */ React.createElement(Tooltip, { title: "Apply content" }, /* @__PURE__ */ React.createElement(
|
|
132
|
+
"button",
|
|
133
|
+
{
|
|
134
|
+
type: "button",
|
|
135
|
+
onClick: () => handleApply(_item.body),
|
|
136
|
+
color: "primary",
|
|
137
|
+
className: "icon-button small",
|
|
138
|
+
style: {
|
|
139
|
+
marginLeft: 4
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
/* @__PURE__ */ React.createElement(Copy, { size: 16 })
|
|
143
|
+
))
|
|
144
|
+
)
|
|
145
|
+
)
|
|
146
|
+
))
|
|
147
|
+
);
|
|
148
|
+
};
|
|
149
|
+
export {
|
|
150
|
+
List as default
|
|
151
|
+
};
|
|
@@ -0,0 +1,225 @@
|
|
|
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
|
+
var __async = (__this, __arguments, generator) => {
|
|
5
|
+
return new Promise((resolve, reject) => {
|
|
6
|
+
var fulfilled = (value) => {
|
|
7
|
+
try {
|
|
8
|
+
step(generator.next(value));
|
|
9
|
+
} catch (e) {
|
|
10
|
+
reject(e);
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
var rejected = (value) => {
|
|
14
|
+
try {
|
|
15
|
+
step(generator.throw(value));
|
|
16
|
+
} catch (e) {
|
|
17
|
+
reject(e);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
21
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
import * as React from "react";
|
|
25
|
+
import * as ReactDOM from "react-dom";
|
|
26
|
+
import TinyMceEditor from "../TinyMceEditor/index.js";
|
|
27
|
+
import Tooltip from "../Tooltip/index.js";
|
|
28
|
+
import { axiosApi } from "../../utils/axiosAPI.js";
|
|
29
|
+
import Settings from "../../node_modules/react-feather/dist/icons/settings.js";
|
|
30
|
+
import Copy from "../../node_modules/react-feather/dist/icons/copy.js";
|
|
31
|
+
class SettingPopper extends React.Component {
|
|
32
|
+
constructor(props) {
|
|
33
|
+
super(props);
|
|
34
|
+
__publicField(this, "containerRef");
|
|
35
|
+
__publicField(this, "popperRef");
|
|
36
|
+
__publicField(this, "getLanguageOptions", () => __async(this, null, function* () {
|
|
37
|
+
var _a;
|
|
38
|
+
const res = yield axiosApi.get("/email/ai/langlist");
|
|
39
|
+
if (res == null ? void 0 : res.list) {
|
|
40
|
+
const langs = (_a = Object.keys(res == null ? void 0 : res.list)) == null ? void 0 : _a.map((_key, i) => {
|
|
41
|
+
var _a2;
|
|
42
|
+
const _item = (_a2 = res == null ? void 0 : res.list) == null ? void 0 : _a2[_key];
|
|
43
|
+
return {
|
|
44
|
+
value: _key,
|
|
45
|
+
label: _item == null ? void 0 : _item.name
|
|
46
|
+
};
|
|
47
|
+
});
|
|
48
|
+
this.setState({ languageOptions: langs });
|
|
49
|
+
}
|
|
50
|
+
}));
|
|
51
|
+
__publicField(this, "handleClickOutside", (event) => {
|
|
52
|
+
const target = event.target;
|
|
53
|
+
if (this.containerRef.current && !this.containerRef.current.contains(target) && (!this.popperRef.current || !this.popperRef.current.contains(target))) {
|
|
54
|
+
this.setState({ open: false });
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
__publicField(this, "togglePopper", () => {
|
|
58
|
+
this.setState((prevState) => ({ open: !prevState.open }));
|
|
59
|
+
});
|
|
60
|
+
__publicField(this, "handleLangChange", (e) => {
|
|
61
|
+
const selected = this.state.languageOptions.find(
|
|
62
|
+
(opt) => opt.value === e.target.value
|
|
63
|
+
);
|
|
64
|
+
this.props.setLang(selected || null);
|
|
65
|
+
});
|
|
66
|
+
this.state = { open: false, languageOptions: [] };
|
|
67
|
+
this.containerRef = React.createRef();
|
|
68
|
+
this.popperRef = React.createRef();
|
|
69
|
+
}
|
|
70
|
+
componentDidMount() {
|
|
71
|
+
document.addEventListener("mousedown", this.handleClickOutside);
|
|
72
|
+
this.getLanguageOptions();
|
|
73
|
+
}
|
|
74
|
+
componentWillUnmount() {
|
|
75
|
+
document.removeEventListener("mousedown", this.handleClickOutside);
|
|
76
|
+
}
|
|
77
|
+
render() {
|
|
78
|
+
const {
|
|
79
|
+
lang,
|
|
80
|
+
originalEmail,
|
|
81
|
+
setOriginalEmail,
|
|
82
|
+
getEditorContent,
|
|
83
|
+
parentRef
|
|
84
|
+
} = this.props;
|
|
85
|
+
const { open, languageOptions } = this.state;
|
|
86
|
+
let popperTop = 0;
|
|
87
|
+
let popperLeft = 0;
|
|
88
|
+
let popperWidth = 320;
|
|
89
|
+
if (open && this.containerRef.current) {
|
|
90
|
+
const rect = this.containerRef.current.getBoundingClientRect();
|
|
91
|
+
popperTop = rect.top + (window.scrollY || document.documentElement.scrollTop) - 8;
|
|
92
|
+
popperLeft = rect.left + (window.scrollX || document.documentElement.scrollLeft);
|
|
93
|
+
if (parentRef && parentRef.current) {
|
|
94
|
+
const parentRect = parentRef.current.getBoundingClientRect();
|
|
95
|
+
popperWidth = parentRect.width - 16;
|
|
96
|
+
popperLeft = parentRect.left + 8;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return /* @__PURE__ */ React.createElement(
|
|
100
|
+
"div",
|
|
101
|
+
{
|
|
102
|
+
ref: this.containerRef,
|
|
103
|
+
style: { position: "relative", display: "inline-block" }
|
|
104
|
+
},
|
|
105
|
+
/* @__PURE__ */ React.createElement(
|
|
106
|
+
"button",
|
|
107
|
+
{
|
|
108
|
+
type: "button",
|
|
109
|
+
onClick: this.togglePopper,
|
|
110
|
+
className: "icon-button small"
|
|
111
|
+
},
|
|
112
|
+
/* @__PURE__ */ React.createElement(Settings, { size: 16 })
|
|
113
|
+
),
|
|
114
|
+
open && this.containerRef.current && ReactDOM.createPortal(
|
|
115
|
+
/* @__PURE__ */ React.createElement(
|
|
116
|
+
"div",
|
|
117
|
+
{
|
|
118
|
+
ref: this.popperRef,
|
|
119
|
+
style: {
|
|
120
|
+
position: "absolute",
|
|
121
|
+
top: popperTop,
|
|
122
|
+
left: popperLeft,
|
|
123
|
+
transform: "translateY(-100%)",
|
|
124
|
+
zIndex: 1051,
|
|
125
|
+
background: "#fff",
|
|
126
|
+
border: "1px solid #ddd",
|
|
127
|
+
boxShadow: "0px 4px 12px rgba(0, 0, 0, 0.1)",
|
|
128
|
+
borderRadius: 8,
|
|
129
|
+
padding: 16,
|
|
130
|
+
width: popperWidth,
|
|
131
|
+
boxSizing: "border-box"
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
/* @__PURE__ */ React.createElement(
|
|
135
|
+
"div",
|
|
136
|
+
{
|
|
137
|
+
style: { display: "flex", flexDirection: "column", gap: 12 }
|
|
138
|
+
},
|
|
139
|
+
/* @__PURE__ */ React.createElement(
|
|
140
|
+
"div",
|
|
141
|
+
{
|
|
142
|
+
style: { display: "flex", flexDirection: "column", gap: 4 }
|
|
143
|
+
},
|
|
144
|
+
/* @__PURE__ */ React.createElement(
|
|
145
|
+
"span",
|
|
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",
|
|
157
|
+
{
|
|
158
|
+
name: "language",
|
|
159
|
+
value: lang ? lang.value : "",
|
|
160
|
+
onChange: this.handleLangChange
|
|
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
|
+
})
|
|
166
|
+
)
|
|
167
|
+
),
|
|
168
|
+
/* @__PURE__ */ React.createElement(
|
|
169
|
+
"div",
|
|
170
|
+
{
|
|
171
|
+
style: { display: "flex", flexDirection: "column", gap: 4 }
|
|
172
|
+
},
|
|
173
|
+
/* @__PURE__ */ React.createElement(
|
|
174
|
+
"div",
|
|
175
|
+
{
|
|
176
|
+
style: {
|
|
177
|
+
display: "flex",
|
|
178
|
+
alignItems: "center",
|
|
179
|
+
justifyContent: "space-between"
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
/* @__PURE__ */ React.createElement(
|
|
183
|
+
"span",
|
|
184
|
+
{
|
|
185
|
+
style: {
|
|
186
|
+
fontSize: 12,
|
|
187
|
+
fontWeight: 500
|
|
188
|
+
// color: "var(--text-secondary)",
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
"AI Context"
|
|
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
|
+
}
|
|
214
|
+
)
|
|
215
|
+
)
|
|
216
|
+
)
|
|
217
|
+
),
|
|
218
|
+
document.body
|
|
219
|
+
)
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
export {
|
|
224
|
+
SettingPopper as default
|
|
225
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __spreadValues = (a, b) => {
|
|
7
|
+
for (var prop in b || (b = {}))
|
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
|
10
|
+
if (__getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
+
if (__propIsEnum.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
17
|
+
import * as React from "react";
|
|
18
|
+
import { marked } from "../../node_modules/marked/lib/marked.esm.js";
|
|
19
|
+
const TypingText = ({ data, style }) => {
|
|
20
|
+
return /* @__PURE__ */ React.createElement(
|
|
21
|
+
"div",
|
|
22
|
+
{
|
|
23
|
+
style: __spreadValues({
|
|
24
|
+
maxWidth: "80%"
|
|
25
|
+
}, style)
|
|
26
|
+
},
|
|
27
|
+
data && data.subject ? /* @__PURE__ */ React.createElement(
|
|
28
|
+
"div",
|
|
29
|
+
{
|
|
30
|
+
dangerouslySetInnerHTML: {
|
|
31
|
+
__html: marked.parse(data.body, { async: false })
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
) : /* @__PURE__ */ React.createElement("p", { style: { margin: 0, whiteSpace: "pre-wrap" } }, data ? data.question : "")
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
export {
|
|
38
|
+
TypingText as default
|
|
39
|
+
};
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __spreadValues = (a, b) => {
|
|
7
|
+
for (var prop in b || (b = {}))
|
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
|
10
|
+
if (__getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
+
if (__propIsEnum.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
17
|
+
var __async = (__this, __arguments, generator) => {
|
|
18
|
+
return new Promise((resolve, reject) => {
|
|
19
|
+
var fulfilled = (value) => {
|
|
20
|
+
try {
|
|
21
|
+
step(generator.next(value));
|
|
22
|
+
} catch (e) {
|
|
23
|
+
reject(e);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
var rejected = (value) => {
|
|
27
|
+
try {
|
|
28
|
+
step(generator.throw(value));
|
|
29
|
+
} catch (e) {
|
|
30
|
+
reject(e);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
34
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
import { getBaseUrl, SDKConfig } from "../../utils/url.js";
|
|
38
|
+
function callAI(_0, _1) {
|
|
39
|
+
return __async(this, arguments, function* (params, { setContent, setIsLoading, setConversationId }) {
|
|
40
|
+
var _a;
|
|
41
|
+
let currentContent = "";
|
|
42
|
+
const baseUrl = getBaseUrl();
|
|
43
|
+
try {
|
|
44
|
+
setIsLoading(true);
|
|
45
|
+
const config = {
|
|
46
|
+
method: "POST",
|
|
47
|
+
baseURL: baseUrl,
|
|
48
|
+
url: "/nmail/chatdraft",
|
|
49
|
+
params
|
|
50
|
+
};
|
|
51
|
+
let sigHeaders = {};
|
|
52
|
+
const signer = (_a = SDKConfig) == null ? void 0 : _a.signer;
|
|
53
|
+
if (signer && typeof signer.generateHeaders === "function") {
|
|
54
|
+
sigHeaders = yield signer.generateHeaders(config);
|
|
55
|
+
}
|
|
56
|
+
const response = yield fetch(`${baseUrl}/nmail/chatdraft`, {
|
|
57
|
+
method: "POST",
|
|
58
|
+
body: JSON.stringify(params),
|
|
59
|
+
headers: __spreadValues({
|
|
60
|
+
"Content-Type": "application/json",
|
|
61
|
+
"Access-Control-Allow-Origin": "*"
|
|
62
|
+
}, sigHeaders)
|
|
63
|
+
});
|
|
64
|
+
setIsLoading(false);
|
|
65
|
+
if (!response.body) {
|
|
66
|
+
throw new Error("Response body is not available for streaming.");
|
|
67
|
+
}
|
|
68
|
+
const reader = response.body.getReader();
|
|
69
|
+
let fullContentDecode = "";
|
|
70
|
+
let readIndex = 0;
|
|
71
|
+
while (true) {
|
|
72
|
+
const { done, value } = yield reader.read();
|
|
73
|
+
if (done) {
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
let originStr = "";
|
|
77
|
+
let jsonFormat = "";
|
|
78
|
+
try {
|
|
79
|
+
const contentDecode = new TextDecoder().decode(value);
|
|
80
|
+
fullContentDecode += contentDecode;
|
|
81
|
+
const contentRegex = /"answer":".*?"/g;
|
|
82
|
+
const conversationIdRegex = /"conversation_id"\s*:\s*"([^"]+)"/;
|
|
83
|
+
const matchArray = [...fullContentDecode.matchAll(contentRegex)];
|
|
84
|
+
const conversationIdmatch = fullContentDecode.match(conversationIdRegex);
|
|
85
|
+
if (conversationIdmatch && conversationIdmatch[1]) {
|
|
86
|
+
setConversationId(conversationIdmatch[1]);
|
|
87
|
+
}
|
|
88
|
+
while (readIndex < matchArray.length) {
|
|
89
|
+
const _regMatchItem = matchArray[readIndex];
|
|
90
|
+
try {
|
|
91
|
+
originStr = _regMatchItem[0];
|
|
92
|
+
const nVal = originStr.slice(10, originStr.length - 1);
|
|
93
|
+
jsonFormat = `"${nVal}"`;
|
|
94
|
+
if (nVal.endsWith("\\")) {
|
|
95
|
+
jsonFormat = `"${nVal}\\"`;
|
|
96
|
+
}
|
|
97
|
+
const decoded = JSON.parse(jsonFormat);
|
|
98
|
+
currentContent += decoded;
|
|
99
|
+
setContent(currentContent);
|
|
100
|
+
} catch (e) {
|
|
101
|
+
console.error("Parse error: ", e, originStr, jsonFormat);
|
|
102
|
+
}
|
|
103
|
+
readIndex++;
|
|
104
|
+
}
|
|
105
|
+
} catch (e) {
|
|
106
|
+
console.error("TextDecoder error: ", e, originStr);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
return currentContent;
|
|
110
|
+
} catch (e) {
|
|
111
|
+
console.error("Summary error:", e);
|
|
112
|
+
setContent("");
|
|
113
|
+
} finally {
|
|
114
|
+
setIsLoading(false);
|
|
115
|
+
}
|
|
116
|
+
return "";
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
export {
|
|
120
|
+
callAI
|
|
121
|
+
};
|