hanbiro-react16-sdk 1.0.22 → 1.0.24
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 +222 -0
- package/dist/components/ChatAIDraft/List.js +55 -18
- package/dist/components/ChatAIDraft/SettingPopper/ChipGroup.d.ts +11 -0
- package/dist/components/ChatAIDraft/SettingPopper/ChipGroup.js +62 -0
- package/dist/components/ChatAIDraft/SettingPopper/LanguageSelect.d.ts +21 -0
- package/dist/components/ChatAIDraft/SettingPopper/LanguageSelect.js +137 -0
- package/dist/components/ChatAIDraft/SettingPopper/icons.d.ts +3 -0
- package/dist/components/ChatAIDraft/SettingPopper/icons.js +30 -0
- package/dist/components/ChatAIDraft/{SettingPopper.d.ts → SettingPopper/index.d.ts} +5 -5
- package/dist/components/ChatAIDraft/{SettingPopper.js → SettingPopper/index.js} +37 -77
- package/dist/components/ChatAIDraft/constants.d.ts +4 -0
- package/dist/components/ChatAIDraft/constants.js +18 -0
- package/dist/components/ChatAIDraft/index.d.ts +8 -8
- package/dist/components/ChatAIDraft/index.js +100 -52
- package/dist/components/index.d.ts +1 -1
- package/dist/hanbiro-react16-sdk.style.css +39 -2
- package/dist/hanbiro-react16-sdk.umd.js +2244 -1646
- 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
|
@@ -0,0 +1,222 @@
|
|
|
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";
|
|
6
|
+
const FEATURES = [
|
|
7
|
+
{
|
|
8
|
+
icon: /* @__PURE__ */ React.createElement(MessageCircle, { size: 16 }),
|
|
9
|
+
title: "Request via message",
|
|
10
|
+
desc: 'e.g., "Draft an email to Director Hong proposing a Q3 collaboration meeting (May 20, 3 PM)"'
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
icon: /* @__PURE__ */ React.createElement(CustomAiIcon, { size: 16, stroke: 2 }),
|
|
14
|
+
title: "AI generates a draft",
|
|
15
|
+
desc: "Refine the draft freely with follow-ups like 'more polite' or 'add a deadline'."
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
icon: /* @__PURE__ */ React.createElement(Check, { size: 16 }),
|
|
19
|
+
title: "Apply to body",
|
|
20
|
+
desc: "Insert the response you like into the email body and send."
|
|
21
|
+
}
|
|
22
|
+
];
|
|
23
|
+
const SUGGESTIONS = [
|
|
24
|
+
"Propose a Q3 meeting to Director Hong (May 20, 3 PM)",
|
|
25
|
+
"Notify client of payment schedule (Due May 30)",
|
|
26
|
+
"Welcome message to new employee (Joining May 22)"
|
|
27
|
+
];
|
|
28
|
+
const EmptyState = ({
|
|
29
|
+
onSelectPrompt
|
|
30
|
+
}) => {
|
|
31
|
+
return /* @__PURE__ */ React.createElement(
|
|
32
|
+
"div",
|
|
33
|
+
{
|
|
34
|
+
style: {
|
|
35
|
+
flex: 1,
|
|
36
|
+
minHeight: 0,
|
|
37
|
+
overflowY: "auto",
|
|
38
|
+
display: "flex",
|
|
39
|
+
flexDirection: "column",
|
|
40
|
+
paddingRight: 8,
|
|
41
|
+
marginRight: -8,
|
|
42
|
+
paddingBottom: 16
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
/* @__PURE__ */ React.createElement("div", { style: { textAlign: "center", marginTop: 8 } }, /* @__PURE__ */ React.createElement(
|
|
46
|
+
"div",
|
|
47
|
+
{
|
|
48
|
+
style: {
|
|
49
|
+
fontSize: 14,
|
|
50
|
+
fontWeight: 600,
|
|
51
|
+
color: "var(--text-primary)",
|
|
52
|
+
lineHeight: 1.5
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
"Let's draft a new email together from scratch."
|
|
56
|
+
), /* @__PURE__ */ React.createElement(
|
|
57
|
+
"div",
|
|
58
|
+
{
|
|
59
|
+
style: {
|
|
60
|
+
fontSize: 13,
|
|
61
|
+
color: "var(--text-secondary)",
|
|
62
|
+
marginTop: 4
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
"Tell me what kind of email you'd like to write."
|
|
66
|
+
)),
|
|
67
|
+
/* @__PURE__ */ React.createElement(
|
|
68
|
+
"div",
|
|
69
|
+
{
|
|
70
|
+
style: {
|
|
71
|
+
alignSelf: "center",
|
|
72
|
+
width: 100,
|
|
73
|
+
height: 100,
|
|
74
|
+
borderRadius: "50%",
|
|
75
|
+
background: "var(--primary-lighter)",
|
|
76
|
+
display: "flex",
|
|
77
|
+
alignItems: "center",
|
|
78
|
+
justifyContent: "center",
|
|
79
|
+
margin: "20px 0",
|
|
80
|
+
color: "var(--primary-main)",
|
|
81
|
+
flexShrink: 0
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
/* @__PURE__ */ React.createElement(CustomAiIcon, { size: 52, stroke: 1.5 })
|
|
85
|
+
),
|
|
86
|
+
/* @__PURE__ */ React.createElement("div", { style: { textAlign: "center" } }, /* @__PURE__ */ React.createElement(
|
|
87
|
+
"div",
|
|
88
|
+
{
|
|
89
|
+
style: {
|
|
90
|
+
fontSize: 13,
|
|
91
|
+
color: "var(--text-secondary)",
|
|
92
|
+
lineHeight: 1.6
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
"Give me the recipient, purpose, and key points",
|
|
96
|
+
/* @__PURE__ */ React.createElement("br", null),
|
|
97
|
+
"and AI will generate a polished draft."
|
|
98
|
+
)),
|
|
99
|
+
/* @__PURE__ */ React.createElement(
|
|
100
|
+
"div",
|
|
101
|
+
{
|
|
102
|
+
style: {
|
|
103
|
+
borderTop: "1px solid var(--border-light)",
|
|
104
|
+
marginTop: 20,
|
|
105
|
+
paddingTop: 16,
|
|
106
|
+
display: "flex",
|
|
107
|
+
flexDirection: "column",
|
|
108
|
+
gap: 14
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
FEATURES.map((f, i) => /* @__PURE__ */ React.createElement(
|
|
112
|
+
"div",
|
|
113
|
+
{
|
|
114
|
+
key: i,
|
|
115
|
+
style: {
|
|
116
|
+
display: "flex",
|
|
117
|
+
flexDirection: "row",
|
|
118
|
+
alignItems: "flex-start",
|
|
119
|
+
gap: 10
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
/* @__PURE__ */ React.createElement(
|
|
123
|
+
"div",
|
|
124
|
+
{
|
|
125
|
+
style: {
|
|
126
|
+
width: 28,
|
|
127
|
+
height: 28,
|
|
128
|
+
borderRadius: "50%",
|
|
129
|
+
background: "var(--background-softGrey)",
|
|
130
|
+
color: "var(--primary-main)",
|
|
131
|
+
display: "flex",
|
|
132
|
+
alignItems: "center",
|
|
133
|
+
justifyContent: "center",
|
|
134
|
+
flexShrink: 0
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
f.icon
|
|
138
|
+
),
|
|
139
|
+
/* @__PURE__ */ React.createElement("div", { style: { flex: 1, minWidth: 0 } }, /* @__PURE__ */ React.createElement(
|
|
140
|
+
"div",
|
|
141
|
+
{
|
|
142
|
+
style: {
|
|
143
|
+
fontSize: 13,
|
|
144
|
+
fontWeight: 600,
|
|
145
|
+
color: "var(--text-primary)"
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
f.title
|
|
149
|
+
), /* @__PURE__ */ React.createElement(
|
|
150
|
+
"div",
|
|
151
|
+
{
|
|
152
|
+
style: {
|
|
153
|
+
fontSize: 12,
|
|
154
|
+
color: "var(--text-secondary)",
|
|
155
|
+
marginTop: 2,
|
|
156
|
+
lineHeight: 1.5
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
f.desc
|
|
160
|
+
))
|
|
161
|
+
))
|
|
162
|
+
),
|
|
163
|
+
/* @__PURE__ */ React.createElement(
|
|
164
|
+
"div",
|
|
165
|
+
{
|
|
166
|
+
style: {
|
|
167
|
+
borderTop: "1px solid var(--border-light)",
|
|
168
|
+
marginTop: 20,
|
|
169
|
+
paddingTop: 16
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
/* @__PURE__ */ React.createElement(
|
|
173
|
+
"div",
|
|
174
|
+
{
|
|
175
|
+
style: {
|
|
176
|
+
fontSize: 12,
|
|
177
|
+
color: "var(--text-secondary)",
|
|
178
|
+
marginBottom: 8
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
"💡 Try these prompts to get a draft right away"
|
|
182
|
+
),
|
|
183
|
+
/* @__PURE__ */ React.createElement("div", { style: { display: "flex", flexDirection: "column", gap: 8 } }, SUGGESTIONS.map((s, i) => /* @__PURE__ */ React.createElement(
|
|
184
|
+
"button",
|
|
185
|
+
{
|
|
186
|
+
key: i,
|
|
187
|
+
type: "button",
|
|
188
|
+
onClick: () => onSelectPrompt(s),
|
|
189
|
+
style: {
|
|
190
|
+
display: "flex",
|
|
191
|
+
alignItems: "center",
|
|
192
|
+
gap: 8,
|
|
193
|
+
width: "100%",
|
|
194
|
+
padding: "10px 12px",
|
|
195
|
+
borderRadius: 8,
|
|
196
|
+
border: "none",
|
|
197
|
+
background: "var(--primary-lighter)",
|
|
198
|
+
color: "var(--text-primary)",
|
|
199
|
+
fontSize: 13,
|
|
200
|
+
textAlign: "left",
|
|
201
|
+
cursor: "pointer",
|
|
202
|
+
fontFamily: "inherit"
|
|
203
|
+
}
|
|
204
|
+
},
|
|
205
|
+
/* @__PURE__ */ React.createElement(
|
|
206
|
+
MessageSquare,
|
|
207
|
+
{
|
|
208
|
+
size: 14,
|
|
209
|
+
style: {
|
|
210
|
+
color: "var(--primary-main)",
|
|
211
|
+
flexShrink: 0
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
),
|
|
215
|
+
/* @__PURE__ */ React.createElement("span", null, s)
|
|
216
|
+
)))
|
|
217
|
+
)
|
|
218
|
+
);
|
|
219
|
+
};
|
|
220
|
+
export {
|
|
221
|
+
EmptyState as default
|
|
222
|
+
};
|
|
@@ -21,9 +21,48 @@ var __async = (__this, __arguments, generator) => {
|
|
|
21
21
|
import * as React from "react";
|
|
22
22
|
import { marked } from "../../node_modules/marked/lib/marked.esm.js";
|
|
23
23
|
import TypingText from "./TypingText.js";
|
|
24
|
-
import LoadingCircular from "../LoadingCircular/index.js";
|
|
25
24
|
import Tooltip from "../Tooltip/index.js";
|
|
26
25
|
import Copy from "../../node_modules/react-feather/dist/icons/copy.js";
|
|
26
|
+
const AIAvatar = () => /* @__PURE__ */ React.createElement(
|
|
27
|
+
"div",
|
|
28
|
+
{
|
|
29
|
+
style: {
|
|
30
|
+
width: 28,
|
|
31
|
+
height: 28,
|
|
32
|
+
borderRadius: "50%",
|
|
33
|
+
background: "var(--primary-main)",
|
|
34
|
+
color: "var(--primary-contrasttext)",
|
|
35
|
+
display: "flex",
|
|
36
|
+
alignItems: "center",
|
|
37
|
+
justifyContent: "center",
|
|
38
|
+
fontSize: 11,
|
|
39
|
+
fontWeight: 700,
|
|
40
|
+
letterSpacing: 0.5,
|
|
41
|
+
flexShrink: 0
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"AI"
|
|
45
|
+
);
|
|
46
|
+
const LoadingDots = ({
|
|
47
|
+
label = "Thinking"
|
|
48
|
+
}) => /* @__PURE__ */ React.createElement(
|
|
49
|
+
"div",
|
|
50
|
+
{
|
|
51
|
+
style: {
|
|
52
|
+
display: "inline-flex",
|
|
53
|
+
alignItems: "center",
|
|
54
|
+
gap: 6,
|
|
55
|
+
background: "var(--background-softGrey)",
|
|
56
|
+
borderRadius: 8,
|
|
57
|
+
borderTopLeftRadius: 0,
|
|
58
|
+
padding: "8px 12px",
|
|
59
|
+
fontSize: 13,
|
|
60
|
+
color: "var(--text-secondary)"
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
/* @__PURE__ */ React.createElement("span", null, label),
|
|
64
|
+
/* @__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))
|
|
65
|
+
);
|
|
27
66
|
const List = ({
|
|
28
67
|
items,
|
|
29
68
|
onApply,
|
|
@@ -88,7 +127,8 @@ const List = ({
|
|
|
88
127
|
borderRadius: 8,
|
|
89
128
|
borderTopRightRadius: 0,
|
|
90
129
|
padding: "8px 12px",
|
|
91
|
-
background: "var(--
|
|
130
|
+
background: "var(--primary-main)",
|
|
131
|
+
color: "var(--primary-contrasttext)"
|
|
92
132
|
}
|
|
93
133
|
}
|
|
94
134
|
)
|
|
@@ -100,22 +140,24 @@ const List = ({
|
|
|
100
140
|
width: "100%",
|
|
101
141
|
display: "flex",
|
|
102
142
|
alignItems: "flex-start",
|
|
103
|
-
flexDirection: "
|
|
143
|
+
flexDirection: "row",
|
|
104
144
|
position: "relative",
|
|
105
|
-
marginTop: 8
|
|
145
|
+
marginTop: 8,
|
|
146
|
+
gap: 8
|
|
106
147
|
}
|
|
107
148
|
},
|
|
108
|
-
|
|
149
|
+
/* @__PURE__ */ React.createElement(AIAvatar, null),
|
|
150
|
+
/* @__PURE__ */ React.createElement(
|
|
109
151
|
"div",
|
|
110
152
|
{
|
|
111
153
|
style: {
|
|
154
|
+
flex: 1,
|
|
155
|
+
minWidth: 0,
|
|
112
156
|
display: "flex",
|
|
113
|
-
flexDirection: "
|
|
114
|
-
alignItems: "flex-end",
|
|
115
|
-
width: "100%"
|
|
157
|
+
flexDirection: "column"
|
|
116
158
|
}
|
|
117
159
|
},
|
|
118
|
-
/* @__PURE__ */ React.createElement(
|
|
160
|
+
(_item == null ? void 0 : _item.isLoading) ? /* @__PURE__ */ React.createElement(LoadingDots, null) : /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
|
|
119
161
|
TypingText,
|
|
120
162
|
{
|
|
121
163
|
data: { subject: _item.subject, body: _item.body },
|
|
@@ -123,24 +165,19 @@ const List = ({
|
|
|
123
165
|
background: "var(--background-softGrey)",
|
|
124
166
|
borderRadius: 8,
|
|
125
167
|
borderTopLeftRadius: 0,
|
|
126
|
-
padding: "8px 12px"
|
|
127
|
-
flexShrink: 0
|
|
168
|
+
padding: "8px 12px"
|
|
128
169
|
}
|
|
129
170
|
}
|
|
130
|
-
),
|
|
131
|
-
/* @__PURE__ */ React.createElement(Tooltip, { title: "Apply content" }, /* @__PURE__ */ React.createElement(
|
|
171
|
+
), /* @__PURE__ */ React.createElement("div", { style: { marginTop: 4 } }, /* @__PURE__ */ React.createElement(Tooltip, { title: "Apply content" }, /* @__PURE__ */ React.createElement(
|
|
132
172
|
"button",
|
|
133
173
|
{
|
|
134
174
|
type: "button",
|
|
135
175
|
onClick: () => handleApply(_item.body),
|
|
136
176
|
color: "primary",
|
|
137
|
-
className: "icon-button small"
|
|
138
|
-
style: {
|
|
139
|
-
marginLeft: 4
|
|
140
|
-
}
|
|
177
|
+
className: "icon-button small"
|
|
141
178
|
},
|
|
142
179
|
/* @__PURE__ */ React.createElement(Copy, { size: 16 })
|
|
143
|
-
))
|
|
180
|
+
))))
|
|
144
181
|
)
|
|
145
182
|
)
|
|
146
183
|
))
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { LabelValue } from '../../../types';
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
interface ChipGroupProps {
|
|
4
|
+
options: LabelValue[];
|
|
5
|
+
selected: LabelValue | null;
|
|
6
|
+
onSelect: (opt: LabelValue) => void;
|
|
7
|
+
iconMap: Record<string, React.ReactNode>;
|
|
8
|
+
columns?: number;
|
|
9
|
+
}
|
|
10
|
+
declare const ChipGroup: React.FunctionComponent<ChipGroupProps>;
|
|
11
|
+
export default ChipGroup;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
const ChipGroup = ({
|
|
3
|
+
options,
|
|
4
|
+
selected,
|
|
5
|
+
onSelect,
|
|
6
|
+
iconMap,
|
|
7
|
+
columns = 3
|
|
8
|
+
}) => {
|
|
9
|
+
return /* @__PURE__ */ React.createElement(
|
|
10
|
+
"div",
|
|
11
|
+
{
|
|
12
|
+
style: {
|
|
13
|
+
display: "grid",
|
|
14
|
+
gridTemplateColumns: `repeat(${columns}, minmax(0, 1fr))`,
|
|
15
|
+
gap: 6
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
options.map((opt) => {
|
|
19
|
+
const isActive = (selected == null ? void 0 : selected.value) === opt.value;
|
|
20
|
+
return /* @__PURE__ */ React.createElement(
|
|
21
|
+
"button",
|
|
22
|
+
{
|
|
23
|
+
key: opt.value,
|
|
24
|
+
type: "button",
|
|
25
|
+
onClick: () => onSelect(opt),
|
|
26
|
+
style: {
|
|
27
|
+
display: "flex",
|
|
28
|
+
alignItems: "center",
|
|
29
|
+
justifyContent: "center",
|
|
30
|
+
gap: 6,
|
|
31
|
+
padding: "8px 10px",
|
|
32
|
+
borderRadius: 4,
|
|
33
|
+
border: isActive ? "1px solid var(--primary-main)" : "1px solid var(--border-main)",
|
|
34
|
+
background: isActive ? "var(--primary-lighter)" : "#fff",
|
|
35
|
+
color: isActive ? "var(--primary-main)" : "var(--text-primary)",
|
|
36
|
+
fontWeight: isActive ? 600 : 400,
|
|
37
|
+
fontSize: 13,
|
|
38
|
+
cursor: "pointer",
|
|
39
|
+
fontFamily: "inherit",
|
|
40
|
+
transition: "background 0.15s, border-color 0.15s",
|
|
41
|
+
minWidth: 0
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
/* @__PURE__ */ React.createElement(
|
|
45
|
+
"span",
|
|
46
|
+
{
|
|
47
|
+
style: {
|
|
48
|
+
display: "inline-flex",
|
|
49
|
+
alignItems: "center",
|
|
50
|
+
flexShrink: 0
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
iconMap[opt.value]
|
|
54
|
+
),
|
|
55
|
+
/* @__PURE__ */ React.createElement("span", { style: { whiteSpace: "nowrap" } }, opt.label)
|
|
56
|
+
);
|
|
57
|
+
})
|
|
58
|
+
);
|
|
59
|
+
};
|
|
60
|
+
export {
|
|
61
|
+
ChipGroup as default
|
|
62
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { LabelValue } from '../../../types';
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
interface LanguageSelectProps {
|
|
4
|
+
value: LabelValue | null;
|
|
5
|
+
options: LabelValue[];
|
|
6
|
+
onChange: (opt: LabelValue) => void;
|
|
7
|
+
}
|
|
8
|
+
interface LanguageSelectState {
|
|
9
|
+
open: boolean;
|
|
10
|
+
}
|
|
11
|
+
declare class LanguageSelect extends React.Component<LanguageSelectProps, LanguageSelectState> {
|
|
12
|
+
private ref;
|
|
13
|
+
constructor(props: LanguageSelectProps);
|
|
14
|
+
componentDidMount(): void;
|
|
15
|
+
componentWillUnmount(): void;
|
|
16
|
+
handleClickOutside: (e: MouseEvent) => void;
|
|
17
|
+
toggle: () => void;
|
|
18
|
+
pick: (opt: LabelValue) => void;
|
|
19
|
+
render(): React.JSX.Element;
|
|
20
|
+
}
|
|
21
|
+
export default LanguageSelect;
|
|
@@ -0,0 +1,137 @@
|
|
|
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 ChevronDown from "../../../node_modules/react-feather/dist/icons/chevron-down.js";
|
|
8
|
+
const getFlagCode = (value) => {
|
|
9
|
+
var _a;
|
|
10
|
+
return (_a = AI_LANG_FLAGS.find((l) => l.value === value)) == null ? void 0 : _a.flagCode;
|
|
11
|
+
};
|
|
12
|
+
class LanguageSelect extends React.Component {
|
|
13
|
+
constructor(props) {
|
|
14
|
+
super(props);
|
|
15
|
+
__publicField(this, "ref");
|
|
16
|
+
__publicField(this, "handleClickOutside", (e) => {
|
|
17
|
+
if (this.ref.current && !this.ref.current.contains(e.target)) {
|
|
18
|
+
this.setState({ open: false });
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
__publicField(this, "toggle", () => {
|
|
22
|
+
this.setState((s) => ({ open: !s.open }));
|
|
23
|
+
});
|
|
24
|
+
__publicField(this, "pick", (opt) => {
|
|
25
|
+
this.props.onChange(opt);
|
|
26
|
+
this.setState({ open: false });
|
|
27
|
+
});
|
|
28
|
+
this.state = { open: false };
|
|
29
|
+
this.ref = React.createRef();
|
|
30
|
+
}
|
|
31
|
+
componentDidMount() {
|
|
32
|
+
document.addEventListener("mousedown", this.handleClickOutside);
|
|
33
|
+
}
|
|
34
|
+
componentWillUnmount() {
|
|
35
|
+
document.removeEventListener("mousedown", this.handleClickOutside);
|
|
36
|
+
}
|
|
37
|
+
render() {
|
|
38
|
+
const { value, options } = this.props;
|
|
39
|
+
const { open } = this.state;
|
|
40
|
+
const selectedFlag = getFlagCode(value == null ? void 0 : value.value);
|
|
41
|
+
return /* @__PURE__ */ React.createElement("div", { ref: this.ref, style: { position: "relative", width: "100%" } }, /* @__PURE__ */ React.createElement(
|
|
42
|
+
"button",
|
|
43
|
+
{
|
|
44
|
+
type: "button",
|
|
45
|
+
onClick: this.toggle,
|
|
46
|
+
style: {
|
|
47
|
+
width: "100%",
|
|
48
|
+
display: "flex",
|
|
49
|
+
alignItems: "center",
|
|
50
|
+
gap: 8,
|
|
51
|
+
padding: "8px 10px",
|
|
52
|
+
border: "1px solid var(--border-main)",
|
|
53
|
+
borderRadius: 4,
|
|
54
|
+
background: "#fff",
|
|
55
|
+
cursor: "pointer",
|
|
56
|
+
fontFamily: "inherit",
|
|
57
|
+
fontSize: 13,
|
|
58
|
+
color: "var(--text-primary)"
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
selectedFlag && /* @__PURE__ */ React.createElement(
|
|
62
|
+
CountryFlag,
|
|
63
|
+
{
|
|
64
|
+
flagCode: selectedFlag,
|
|
65
|
+
style: { width: 18, height: 14, flexShrink: 0 }
|
|
66
|
+
}
|
|
67
|
+
),
|
|
68
|
+
/* @__PURE__ */ React.createElement("span", { style: { flex: 1, textAlign: "left" } }, (value == null ? void 0 : value.label) || "Select Language"),
|
|
69
|
+
/* @__PURE__ */ React.createElement(
|
|
70
|
+
ChevronDown,
|
|
71
|
+
{
|
|
72
|
+
size: 14,
|
|
73
|
+
style: {
|
|
74
|
+
transform: open ? "rotate(180deg)" : "none",
|
|
75
|
+
transition: "transform 0.15s"
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
)
|
|
79
|
+
), open && /* @__PURE__ */ React.createElement(
|
|
80
|
+
"div",
|
|
81
|
+
{
|
|
82
|
+
style: {
|
|
83
|
+
position: "absolute",
|
|
84
|
+
top: "calc(100% + 4px)",
|
|
85
|
+
left: 0,
|
|
86
|
+
right: 0,
|
|
87
|
+
maxHeight: 220,
|
|
88
|
+
overflowY: "auto",
|
|
89
|
+
border: "1px solid var(--border-main)",
|
|
90
|
+
borderRadius: 4,
|
|
91
|
+
background: "#fff",
|
|
92
|
+
boxShadow: "0 4px 12px rgba(0, 0, 0, 0.08)",
|
|
93
|
+
zIndex: 2
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
options.map((opt) => {
|
|
97
|
+
const fc = getFlagCode(opt.value);
|
|
98
|
+
const isActive = (value == null ? void 0 : value.value) === opt.value;
|
|
99
|
+
return /* @__PURE__ */ React.createElement(
|
|
100
|
+
"button",
|
|
101
|
+
{
|
|
102
|
+
key: opt.value,
|
|
103
|
+
type: "button",
|
|
104
|
+
onClick: () => this.pick(opt),
|
|
105
|
+
className: "chat-ai-lang-option" + (isActive ? " is-active" : ""),
|
|
106
|
+
style: {
|
|
107
|
+
width: "100%",
|
|
108
|
+
display: "flex",
|
|
109
|
+
alignItems: "center",
|
|
110
|
+
gap: 8,
|
|
111
|
+
padding: "8px 10px",
|
|
112
|
+
border: "none",
|
|
113
|
+
background: isActive ? "var(--primary-lighter)" : void 0,
|
|
114
|
+
cursor: "pointer",
|
|
115
|
+
fontFamily: "inherit",
|
|
116
|
+
fontSize: 13,
|
|
117
|
+
textAlign: "left",
|
|
118
|
+
color: "var(--text-primary)",
|
|
119
|
+
fontWeight: 400
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
fc && /* @__PURE__ */ React.createElement(
|
|
123
|
+
CountryFlag,
|
|
124
|
+
{
|
|
125
|
+
flagCode: fc,
|
|
126
|
+
style: { width: 18, height: 14, flexShrink: 0 }
|
|
127
|
+
}
|
|
128
|
+
),
|
|
129
|
+
/* @__PURE__ */ React.createElement("span", null, opt.label)
|
|
130
|
+
);
|
|
131
|
+
})
|
|
132
|
+
));
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
export {
|
|
136
|
+
LanguageSelect as default
|
|
137
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import Frown from "../../../node_modules/react-feather/dist/icons/frown.js";
|
|
3
|
+
import ThumbsUp from "../../../node_modules/react-feather/dist/icons/thumbs-up.js";
|
|
4
|
+
import Smile from "../../../node_modules/react-feather/dist/icons/smile.js";
|
|
5
|
+
import Compass from "../../../node_modules/react-feather/dist/icons/compass.js";
|
|
6
|
+
import Heart from "../../../node_modules/react-feather/dist/icons/heart.js";
|
|
7
|
+
import Award from "../../../node_modules/react-feather/dist/icons/award.js";
|
|
8
|
+
import Zap from "../../../node_modules/react-feather/dist/icons/zap.js";
|
|
9
|
+
import FileText from "../../../node_modules/react-feather/dist/icons/file-text.js";
|
|
10
|
+
import AlignJustify from "../../../node_modules/react-feather/dist/icons/align-justify.js";
|
|
11
|
+
import Scissors from "../../../node_modules/react-feather/dist/icons/scissors.js";
|
|
12
|
+
const ICON_SIZE = 14;
|
|
13
|
+
const TONE_ICONS = {
|
|
14
|
+
formal: /* @__PURE__ */ React.createElement(Award, { size: ICON_SIZE }),
|
|
15
|
+
polite: /* @__PURE__ */ React.createElement(Heart, { size: ICON_SIZE }),
|
|
16
|
+
neutral: /* @__PURE__ */ React.createElement(Compass, { size: ICON_SIZE }),
|
|
17
|
+
friendly: /* @__PURE__ */ React.createElement(Smile, { size: ICON_SIZE }),
|
|
18
|
+
firm: /* @__PURE__ */ React.createElement(ThumbsUp, { size: ICON_SIZE }),
|
|
19
|
+
apologetic: /* @__PURE__ */ React.createElement(Frown, { size: ICON_SIZE })
|
|
20
|
+
};
|
|
21
|
+
const LENGTH_ICONS = {
|
|
22
|
+
short: /* @__PURE__ */ React.createElement(Scissors, { size: ICON_SIZE }),
|
|
23
|
+
medium: /* @__PURE__ */ React.createElement(AlignJustify, { size: ICON_SIZE }),
|
|
24
|
+
long: /* @__PURE__ */ React.createElement(FileText, { size: ICON_SIZE }),
|
|
25
|
+
one_liner: /* @__PURE__ */ React.createElement(Zap, { size: ICON_SIZE })
|
|
26
|
+
};
|
|
27
|
+
export {
|
|
28
|
+
LENGTH_ICONS,
|
|
29
|
+
TONE_ICONS
|
|
30
|
+
};
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { LabelValue } from '
|
|
1
|
+
import { LabelValue } from '../../../types';
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
interface SettingPopperProps {
|
|
4
4
|
lang: LabelValue | null;
|
|
5
5
|
setLang: (lang: LabelValue | null) => void;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
tone: LabelValue | null;
|
|
7
|
+
setTone: (tone: LabelValue | null) => void;
|
|
8
|
+
length: LabelValue | null;
|
|
9
|
+
setLength: (length: LabelValue | null) => void;
|
|
9
10
|
parentRef?: React.RefObject<HTMLDivElement>;
|
|
10
11
|
}
|
|
11
12
|
interface SettingPopperState {
|
|
@@ -21,7 +22,6 @@ declare class SettingPopper extends React.Component<SettingPopperProps, SettingP
|
|
|
21
22
|
getLanguageOptions: () => Promise<void>;
|
|
22
23
|
handleClickOutside: (event: MouseEvent) => void;
|
|
23
24
|
togglePopper: () => void;
|
|
24
|
-
handleLangChange: (e: React.ChangeEvent<HTMLSelectElement>) => void;
|
|
25
25
|
render(): React.JSX.Element;
|
|
26
26
|
}
|
|
27
27
|
export default SettingPopper;
|