code7-leia 1.0.17 → 1.0.20

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "code7-leia",
3
- "version": "1.0.17",
3
+ "version": "1.0.20",
4
4
  "author": "code7-xlab",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.es.js",
@@ -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,6 +1,6 @@
1
1
  import { useState, useEffect } from "react";
2
2
  import { getLanguage } from '../../utils/getLanguage';
3
- import { FaPlus, FaCopy, FaEdit, FaQuestionCircle, FaTrash } from 'react-icons/fa';
3
+ import { FaPlus, FaCopy, FaEdit, FaTrash } from 'react-icons/fa';
4
4
  import Modal from '../Modal';
5
5
  import Input from '../TestArea/components/InputTest';
6
6
  import TextArea from '../TestArea/components/TextArea';
@@ -10,7 +10,7 @@ import LengthCounter from '../LengthCounter';
10
10
  import { useLeia } from "../../contexts/LeiaProvider";
11
11
 
12
12
  import * as S from "./styles";
13
- import Tooltip from "../Tootip";
13
+ import { Alert } from "../Alert";
14
14
 
15
15
  interface Persona {
16
16
  id: number;
@@ -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>
@@ -188,7 +169,7 @@ export const PersonasArea = () => {
188
169
  </S.TableContainer>
189
170
 
190
171
  {isOpen && (
191
- <Modal onClose={() => setIsOpen(false)} title={<ModalTitle/>}>
172
+ <Modal onClose={() => setIsOpen(false)} title={t.personas?.modalTitle}>
192
173
  <S.InputWrapper>
193
174
  <Input
194
175
  value={form.name}
@@ -205,13 +186,19 @@ export const PersonasArea = () => {
205
186
  maxLength={200}
206
187
  />
207
188
  </S.InputWrapper>
208
- <TextArea
209
- label={t.personas?.fields.prompt}
210
- maxLength={10000}
211
- value={form.prompt}
212
- onChange={(e: any) => setForm({ ...form, prompt: e.target.value })}
189
+ <div className="textarea-wrapper">
190
+ <TextArea
191
+ label={t.personas?.fields.prompt}
192
+ maxLength={10000}
193
+ value={form.prompt}
194
+ onChange={(e: any) => setForm({ ...form, prompt: e.target.value })}
195
+ />
196
+ <LengthCounter value={form.prompt} maxLength={10000} />
197
+ </div>
198
+ <Alert
199
+ title={t.personas?.alertTitle}
200
+ message={t.personas?.alertMessage}
213
201
  />
214
- <LengthCounter value={form.prompt} maxLength={10000} />
215
202
 
216
203
  <S.ModalActions>
217
204
  <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
- export const ModalTitleContainer = styled.div`
208
- display: flex;
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
- modalTooltip: "The AI will behave exactly as described in this prompt. Anything it says from here on is the responsibility of the user.",
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
- modalTooltip: "La IA se comportará exactamente según este prompt. Todo lo que diga a partir de aquí es responsabilidad del usuario.",
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
- modalTooltip: "A IA vai se comportar exatamente como este prompt descreve. Tudo o que ela disser a partir disso é responsabilidade do usuário.",
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',