code7-leia 1.0.17 → 1.0.21
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 +1 -0
- package/dist/index.es.js +2539 -2650
- package/package.json +1 -1
- package/src/components/Alert/index.tsx +59 -0
- package/src/components/Alert/styles.tsx +63 -0
- package/src/components/PersonasArea/index.tsx +30 -39
- package/src/components/PersonasArea/styles.ts +6 -5
- package/src/utils/languages/en.ts +2 -1
- package/src/utils/languages/es.ts +2 -1
- package/src/utils/languages/pt-br.ts +2 -1
package/package.json
CHANGED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styled, { css } from 'styled-components';
|
|
3
|
+
import * as S from './styles';
|
|
4
|
+
import {
|
|
5
|
+
FaCheckCircle,
|
|
6
|
+
FaExclamationTriangle,
|
|
7
|
+
FaTimesCircle,
|
|
8
|
+
FaInfoCircle,
|
|
9
|
+
} from 'react-icons/fa';
|
|
10
|
+
|
|
11
|
+
import { BsFillInfoSquareFill } from "react-icons/bs";
|
|
12
|
+
|
|
13
|
+
type AlertStatus = 'success' | 'warning' | 'error' | 'info';
|
|
14
|
+
|
|
15
|
+
interface AlertProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'title'> {
|
|
16
|
+
status?: AlertStatus;
|
|
17
|
+
title?: React.ReactNode;
|
|
18
|
+
message?: React.ReactNode | string[];
|
|
19
|
+
icon?: React.ReactNode;
|
|
20
|
+
children?: React.ReactNode;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const icons = {
|
|
24
|
+
success: <FaCheckCircle />,
|
|
25
|
+
warning: <FaExclamationTriangle />,
|
|
26
|
+
error: <FaTimesCircle />,
|
|
27
|
+
info: <BsFillInfoSquareFill />,
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export const Alert: React.FC<AlertProps> = ({
|
|
31
|
+
status = 'info',
|
|
32
|
+
title,
|
|
33
|
+
message,
|
|
34
|
+
icon,
|
|
35
|
+
children,
|
|
36
|
+
...rest
|
|
37
|
+
}) => {
|
|
38
|
+
const renderMessage = () => {
|
|
39
|
+
if (Array.isArray(message)) {
|
|
40
|
+
return message.map((m, i) => <p key={i}>- {m}</p>);
|
|
41
|
+
}
|
|
42
|
+
return message ? <p>{message}</p> : null;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<S.Container status={status} {...rest}>
|
|
47
|
+
<S.Content>
|
|
48
|
+
<S.Header>
|
|
49
|
+
<S.Icon>{icon || icons[status]}</S.Icon>
|
|
50
|
+
{title && <strong>{title}</strong>}
|
|
51
|
+
</S.Header>
|
|
52
|
+
<div>
|
|
53
|
+
{renderMessage()}
|
|
54
|
+
{children}
|
|
55
|
+
</div>
|
|
56
|
+
</S.Content>
|
|
57
|
+
</S.Container>
|
|
58
|
+
);
|
|
59
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import styled, { css } from 'styled-components';
|
|
2
|
+
|
|
3
|
+
type AlertStatus = 'success' | 'warning' | 'error' | 'info';
|
|
4
|
+
|
|
5
|
+
const statusStyles = {
|
|
6
|
+
success: css`
|
|
7
|
+
background: var(--semantic-green-100-light);
|
|
8
|
+
border-color: var(--semantic-green-600-light);
|
|
9
|
+
color: var(--semantic-green-600-light);
|
|
10
|
+
`,
|
|
11
|
+
warning: css`
|
|
12
|
+
background: var(--semantic-orange-100-light);
|
|
13
|
+
border-color: var(--semantic-orange-600-light);
|
|
14
|
+
color: var(--semantic-orange-600-light);
|
|
15
|
+
`,
|
|
16
|
+
error: css`
|
|
17
|
+
background: var(--semantic-red-100-light);
|
|
18
|
+
border-color: var(--semantic-red-600-light);
|
|
19
|
+
color: var(--semantic-red-600-light);
|
|
20
|
+
`,
|
|
21
|
+
info: css`
|
|
22
|
+
background: var(--semantic-cyan-100-light);
|
|
23
|
+
border-color: var(--semantic-cyan-600-light);
|
|
24
|
+
color: var(--semantic-cyan-600-light);
|
|
25
|
+
`,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export const Container = styled.div<{ status: AlertStatus }>`
|
|
29
|
+
padding: 16px 24px;
|
|
30
|
+
border: 1px solid;
|
|
31
|
+
border-radius: var(--radius-small);
|
|
32
|
+
margin-bottom: 14px;
|
|
33
|
+
|
|
34
|
+
${({ status }) => statusStyles[status]}
|
|
35
|
+
p {
|
|
36
|
+
font-size: 14px;
|
|
37
|
+
margin: 4px 0;
|
|
38
|
+
}
|
|
39
|
+
`;
|
|
40
|
+
|
|
41
|
+
export const Content = styled.div`
|
|
42
|
+
display: flex;
|
|
43
|
+
gap: 12px;
|
|
44
|
+
flex-direction: column;
|
|
45
|
+
`;
|
|
46
|
+
|
|
47
|
+
export const Header = styled.div `
|
|
48
|
+
display: flex;
|
|
49
|
+
align-items: center;
|
|
50
|
+
gap: 8px;
|
|
51
|
+
`;
|
|
52
|
+
|
|
53
|
+
export const Icon = styled.div`
|
|
54
|
+
display: flex;
|
|
55
|
+
align-items: center;
|
|
56
|
+
font-size: 18px;
|
|
57
|
+
|
|
58
|
+
svg {
|
|
59
|
+
width: 20px;
|
|
60
|
+
height: 20px;
|
|
61
|
+
}
|
|
62
|
+
`;
|
|
63
|
+
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { useState, useEffect } from "react";
|
|
2
|
-
import { getLanguage } from
|
|
3
|
-
import { FaPlus, FaCopy, FaEdit,
|
|
4
|
-
import Modal from
|
|
5
|
-
import Input from
|
|
6
|
-
import TextArea from
|
|
7
|
-
import Search from
|
|
8
|
-
import LengthCounter from
|
|
2
|
+
import { getLanguage } from "../../utils/getLanguage";
|
|
3
|
+
import { FaPlus, FaCopy, FaEdit, FaTrash } from "react-icons/fa";
|
|
4
|
+
import Modal from "../Modal";
|
|
5
|
+
import Input from "../TestArea/components/InputTest";
|
|
6
|
+
import TextArea from "../TestArea/components/TextArea";
|
|
7
|
+
import Search from "../FileArea/components/Search";
|
|
8
|
+
import LengthCounter from "../LengthCounter";
|
|
9
9
|
|
|
10
10
|
import { useLeia } from "../../contexts/LeiaProvider";
|
|
11
11
|
|
|
12
12
|
import * as S from "./styles";
|
|
13
|
-
import
|
|
13
|
+
import { Alert } from "../Alert";
|
|
14
14
|
|
|
15
15
|
interface Persona {
|
|
16
16
|
id: number;
|
|
@@ -22,7 +22,7 @@ interface Persona {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
export const PersonasArea = () => {
|
|
25
|
-
const { language } = useLeia();
|
|
25
|
+
const { language, readonly } = useLeia();
|
|
26
26
|
const t = getLanguage(language);
|
|
27
27
|
const { createPersona, personas, updatePersona, deletePersona } = useLeia();
|
|
28
28
|
|
|
@@ -115,25 +115,6 @@ export const PersonasArea = () => {
|
|
|
115
115
|
);
|
|
116
116
|
}, [personas]);
|
|
117
117
|
|
|
118
|
-
const ModalTitle = () => {
|
|
119
|
-
return (
|
|
120
|
-
<S.ModalTitleContainer className='modal-title'>
|
|
121
|
-
<h3>{t.personas?.modalTitle}</h3>
|
|
122
|
-
<Tooltip
|
|
123
|
-
position="right"
|
|
124
|
-
width={'200px'}
|
|
125
|
-
render={() =>
|
|
126
|
-
t.personas?.modalTooltip
|
|
127
|
-
}
|
|
128
|
-
>
|
|
129
|
-
<>
|
|
130
|
-
<FaQuestionCircle color = "#8D9CA1" size={16}/>
|
|
131
|
-
</>
|
|
132
|
-
</Tooltip>
|
|
133
|
-
</S.ModalTitleContainer>
|
|
134
|
-
)
|
|
135
|
-
}
|
|
136
|
-
|
|
137
118
|
return (
|
|
138
119
|
<S.Container>
|
|
139
120
|
<S.Header>
|
|
@@ -141,9 +122,11 @@ export const PersonasArea = () => {
|
|
|
141
122
|
<h2>{t.personas?.title}</h2>
|
|
142
123
|
<p>{t.personas?.description}</p>
|
|
143
124
|
</div>
|
|
144
|
-
|
|
145
|
-
<
|
|
146
|
-
|
|
125
|
+
{!readonly && (
|
|
126
|
+
<button onClick={openCreate}>
|
|
127
|
+
<FaPlus /> {t.personas?.add}
|
|
128
|
+
</button>
|
|
129
|
+
)}
|
|
147
130
|
</S.Header>
|
|
148
131
|
<S.Search>
|
|
149
132
|
<Search
|
|
@@ -165,7 +148,7 @@ export const PersonasArea = () => {
|
|
|
165
148
|
</div>
|
|
166
149
|
</td>
|
|
167
150
|
<td className="td-actions">
|
|
168
|
-
{persona.created_at && (
|
|
151
|
+
{!readonly && persona.created_at && (
|
|
169
152
|
<div className="actions">
|
|
170
153
|
<button onClick={() => openEdit(persona)}>
|
|
171
154
|
<FaEdit /> {t.edit}
|
|
@@ -188,7 +171,7 @@ export const PersonasArea = () => {
|
|
|
188
171
|
</S.TableContainer>
|
|
189
172
|
|
|
190
173
|
{isOpen && (
|
|
191
|
-
<Modal onClose={() => setIsOpen(false)} title={
|
|
174
|
+
<Modal onClose={() => setIsOpen(false)} title={t.personas?.modalTitle}>
|
|
192
175
|
<S.InputWrapper>
|
|
193
176
|
<Input
|
|
194
177
|
value={form.name}
|
|
@@ -205,13 +188,21 @@ export const PersonasArea = () => {
|
|
|
205
188
|
maxLength={200}
|
|
206
189
|
/>
|
|
207
190
|
</S.InputWrapper>
|
|
208
|
-
<
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
191
|
+
<div className="textarea-wrapper">
|
|
192
|
+
<TextArea
|
|
193
|
+
label={t.personas?.fields.prompt}
|
|
194
|
+
maxLength={10000}
|
|
195
|
+
value={form.prompt}
|
|
196
|
+
onChange={(e: any) =>
|
|
197
|
+
setForm({ ...form, prompt: e.target.value })
|
|
198
|
+
}
|
|
199
|
+
/>
|
|
200
|
+
<LengthCounter value={form.prompt} maxLength={10000} />
|
|
201
|
+
</div>
|
|
202
|
+
<Alert
|
|
203
|
+
title={t.personas?.alertTitle}
|
|
204
|
+
message={t.personas?.alertMessage}
|
|
213
205
|
/>
|
|
214
|
-
<LengthCounter value={form.prompt} maxLength={10000} />
|
|
215
206
|
|
|
216
207
|
<S.ModalActions>
|
|
217
208
|
<button onClick={() => setIsOpen(false)}>{t.buttons.cancel}</button>
|
|
@@ -3,6 +3,10 @@ import styled from 'styled-components';
|
|
|
3
3
|
export const Container = styled.div`
|
|
4
4
|
display: flex;
|
|
5
5
|
flex-direction: column;
|
|
6
|
+
|
|
7
|
+
.textarea-wrapper{
|
|
8
|
+
margin-bottom: 12px;
|
|
9
|
+
}
|
|
6
10
|
`;
|
|
7
11
|
|
|
8
12
|
export const Header = styled.div`
|
|
@@ -204,8 +208,5 @@ export const TableContainer = styled.table`
|
|
|
204
208
|
}
|
|
205
209
|
`;
|
|
206
210
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
gap: 8px;
|
|
210
|
-
align-items: center;
|
|
211
|
-
`;
|
|
211
|
+
|
|
212
|
+
|
|
@@ -17,7 +17,8 @@ export const enTranslation: Language = {
|
|
|
17
17
|
add: 'Add persona',
|
|
18
18
|
modalTitle: 'Persona',
|
|
19
19
|
modalAlert: 'Are you sure you want to delete',
|
|
20
|
-
|
|
20
|
+
alertTitle: 'Important',
|
|
21
|
+
alertMessage: "The AI-generated responses are based on the guidelines in this prompt; defining their content is the user's responsibility.",
|
|
21
22
|
|
|
22
23
|
fields: {
|
|
23
24
|
name: 'Name',
|
|
@@ -17,7 +17,8 @@ export const esTranslation: Language = {
|
|
|
17
17
|
add: 'Agregar persona',
|
|
18
18
|
modalTitle: 'Persona',
|
|
19
19
|
modalAlert: '¿Seguro que deseas eliminar',
|
|
20
|
-
|
|
20
|
+
alertTitle: 'Importante',
|
|
21
|
+
alertMessage: "Las respuestas generadas por IA se basan en las pautas de este mensaje; definir su contenido es responsabilidad del usuario.",
|
|
21
22
|
|
|
22
23
|
fields: {
|
|
23
24
|
name: 'Nombre',
|
|
@@ -17,7 +17,8 @@ export const ptTranslation: Language = {
|
|
|
17
17
|
add: 'Adicionar persona',
|
|
18
18
|
modalTitle: 'Persona',
|
|
19
19
|
modalAlert: 'Quer mesmo deletar',
|
|
20
|
-
|
|
20
|
+
alertTitle: 'Importante',
|
|
21
|
+
alertMessage: "As respostas geradas pela IA são baseadas nas orientações deste prompt, sendo responsabilidade do usuário a definição de seu conteúdo.",
|
|
21
22
|
|
|
22
23
|
fields: {
|
|
23
24
|
name: 'Nome',
|