@orbe-agro/client-core 5.6.350 → 5.6.352
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/@ecme/assets/styles/app.css +3 -0
- package/dist/@ecme/assets/styles/tailwind/index.css +3 -0
- package/dist/@ecme/components/template/Footer.js +1 -1
- package/dist/@ecme/components/ui/Input/Input.js +1 -3
- package/dist/@ecme/components/ui/Input/Input.js.map +1 -1
- package/dist/@ecme/components/view/ChatBox/ChatBox.js +1 -7
- package/dist/@ecme/components/view/ChatBox/ChatBox.js.map +1 -1
- package/dist/@ecme/components/view/ChatBox/components/ChatInput.js +30 -63
- package/dist/@ecme/components/view/ChatBox/components/ChatInput.js.map +1 -1
- package/dist/@ecme/locales/lang/en/nav.js +2 -1
- package/dist/@ecme/locales/lang/en/nav.js.map +1 -1
- package/dist/@ecme/views/concepts/ai/Chat/components/AiChatBox.js +75 -0
- package/dist/@ecme/views/concepts/ai/Chat/components/AiChatBox.js.map +1 -0
- package/dist/@ecme/views/concepts/ai/Chat/components/AiChatInput.js +121 -0
- package/dist/@ecme/views/concepts/ai/Chat/components/AiChatInput.js.map +1 -0
- package/dist/@ecme/views/concepts/ai/Chat/components/ChatView.js +2 -3
- package/dist/@ecme/views/concepts/ai/Chat/components/ChatView.js.map +1 -1
- package/dist/@ecme/views/concepts/chat/Chat/components/ChatBody.js +1 -1
- package/dist/@ecme/views/concepts/chat/Chat/components/ChatBody.js.map +1 -1
- package/dist/@types/@ecme/components/ui/Input/Input.d.ts.map +1 -1
- package/dist/@types/@ecme/components/view/ChatBox/ChatBox.d.ts.map +1 -1
- package/dist/@types/@ecme/components/view/ChatBox/components/ChatInput.d.ts +1 -12
- package/dist/@types/@ecme/components/view/ChatBox/components/ChatInput.d.ts.map +1 -1
- package/dist/@types/@ecme/locales/lang/en/index.d.ts +1 -0
- package/dist/@types/@ecme/locales/lang/en/index.d.ts.map +1 -1
- package/dist/@types/@ecme/locales/lang/en/nav.d.ts +1 -0
- package/dist/@types/@ecme/locales/lang/en/nav.d.ts.map +1 -1
- package/dist/@types/@ecme/locales/lang/ptBR/index.d.ts +1 -0
- package/dist/@types/@ecme/locales/lang/ptBR/index.d.ts.map +1 -1
- package/dist/@types/@ecme/views/concepts/ai/Chat/components/AiChatBox.d.ts +25 -0
- package/dist/@types/@ecme/views/concepts/ai/Chat/components/AiChatBox.d.ts.map +1 -0
- package/dist/@types/@ecme/views/concepts/ai/Chat/components/AiChatInput.d.ts +38 -0
- package/dist/@types/@ecme/views/concepts/ai/Chat/components/AiChatInput.d.ts.map +1 -0
- package/dist/@types/base/@types/api/request/dm/TConfiguracaoNotificacaoRequest.d.ts +12 -0
- package/dist/@types/base/@types/api/request/dm/TConfiguracaoNotificacaoRequest.d.ts.map +1 -0
- package/dist/@types/base/@types/api/response/dadosMestres/TConfiguracaoNotificacaoResponse.d.ts +18 -0
- package/dist/@types/base/@types/api/response/dadosMestres/TConfiguracaoNotificacaoResponse.d.ts.map +1 -0
- package/dist/@types/base/configs/endpoints.config/dm/config/configuracaoNotificacao.d.ts +28 -0
- package/dist/@types/base/configs/endpoints.config/dm/config/configuracaoNotificacao.d.ts.map +1 -0
- package/dist/@types/base/configs/endpoints.config/dm/dm.d.ts +26 -0
- package/dist/@types/base/configs/endpoints.config/dm/dm.d.ts.map +1 -1
- package/dist/@types/base/configs/endpoints.config/endpoints.navigation.d.ts +26 -0
- package/dist/@types/base/configs/endpoints.config/endpoints.navigation.d.ts.map +1 -1
- package/dist/@types/base/configs/navigation.config/submenu/dadosMestres/cadastros.submenu.d.ts.map +1 -1
- package/dist/@types/base/configs/navigation.config/submenu/dadosMestres/config/configuracaoNotificacao.submenu.d.ts +4 -0
- package/dist/@types/base/configs/navigation.config/submenu/dadosMestres/config/configuracaoNotificacao.submenu.d.ts.map +1 -0
- package/dist/@types/base/locales/lang/ptBR/modules/DadosMestres/dadosMestres.nav.d.ts +1 -0
- package/dist/@types/base/locales/lang/ptBR/modules/DadosMestres/dadosMestres.nav.d.ts.map +1 -1
- package/dist/@types/base/services/modules/dm/configuracaoNotificacao/ConfiguracaoNotificacaoService.d.ts +10 -0
- package/dist/@types/base/services/modules/dm/configuracaoNotificacao/ConfiguracaoNotificacaoService.d.ts.map +1 -0
- package/dist/base/@types/api/request/dm/TConfiguracaoNotificacaoRequest.js +2 -0
- package/dist/base/@types/api/request/dm/TConfiguracaoNotificacaoRequest.js.map +1 -0
- package/dist/base/@types/api/response/dadosMestres/TConfiguracaoNotificacaoResponse.js +2 -0
- package/dist/base/@types/api/response/dadosMestres/TConfiguracaoNotificacaoResponse.js.map +1 -0
- package/dist/base/assets/styles/init.css +3 -0
- package/dist/base/configs/endpoints.config/dm/config/configuracaoNotificacao.js +13 -0
- package/dist/base/configs/endpoints.config/dm/config/configuracaoNotificacao.js.map +1 -0
- package/dist/base/configs/endpoints.config/dm/dm.js +3 -1
- package/dist/base/configs/endpoints.config/dm/dm.js.map +1 -1
- package/dist/base/configs/navigation.config/submenu/dadosMestres/cadastros.submenu.js +3 -1
- package/dist/base/configs/navigation.config/submenu/dadosMestres/cadastros.submenu.js.map +1 -1
- package/dist/base/configs/navigation.config/submenu/dadosMestres/config/configuracaoNotificacao.submenu.js +16 -0
- package/dist/base/configs/navigation.config/submenu/dadosMestres/config/configuracaoNotificacao.submenu.js.map +1 -0
- package/dist/base/locales/lang/ptBR/modules/DadosMestres/dadosMestres.nav.js +1 -0
- package/dist/base/locales/lang/ptBR/modules/DadosMestres/dadosMestres.nav.js.map +1 -1
- package/dist/base/services/modules/dm/configuracaoNotificacao/ConfiguracaoNotificacaoService.js +52 -0
- package/dist/base/services/modules/dm/configuracaoNotificacao/ConfiguracaoNotificacaoService.js.map +1 -0
- package/lib/@ecme/components/ui/Input/Input.tsx +1 -3
- package/lib/@ecme/components/view/ChatBox/ChatBox.tsx +0 -6
- package/lib/@ecme/components/view/ChatBox/components/ChatInput.tsx +35 -100
- package/lib/@ecme/locales/lang/en/nav.ts +1 -0
- package/lib/@ecme/views/concepts/ai/Chat/components/AiChatBox.tsx +96 -0
- package/lib/@ecme/views/concepts/ai/Chat/components/AiChatInput.tsx +173 -0
- package/lib/@ecme/views/concepts/ai/Chat/components/ChatView.tsx +3 -3
- package/lib/@ecme/views/concepts/chat/Chat/components/ChatBody.tsx +1 -1
- package/lib/base/@types/api/request/dm/TConfiguracaoNotificacaoRequest.ts +13 -0
- package/lib/base/@types/api/response/dadosMestres/TConfiguracaoNotificacaoResponse.ts +19 -0
- package/lib/base/configs/endpoints.config/dm/config/configuracaoNotificacao.ts +12 -0
- package/lib/base/configs/endpoints.config/dm/dm.ts +3 -1
- package/lib/base/configs/navigation.config/submenu/dadosMestres/cadastros.submenu.ts +2 -0
- package/lib/base/configs/navigation.config/submenu/dadosMestres/config/configuracaoNotificacao.submenu.ts +16 -0
- package/lib/base/locales/lang/ptBR/modules/DadosMestres/dadosMestres.nav.ts +1 -0
- package/lib/base/services/modules/dm/configuracaoNotificacao/ConfiguracaoNotificacaoService.ts +58 -0
- package/package.json +1 -1
|
@@ -24,6 +24,7 @@ import municipio from "./config/municipio.js";
|
|
|
24
24
|
import frete from "./config/frete.js";
|
|
25
25
|
import safra from "./config/safra.js";
|
|
26
26
|
import area from "./config/area.js";
|
|
27
|
+
import configuracaoNotificacao from "./config/configuracaoNotificacao.js";
|
|
27
28
|
const dm = {
|
|
28
29
|
businessPartner,
|
|
29
30
|
canalDistribuicao,
|
|
@@ -50,7 +51,8 @@ const dm = {
|
|
|
50
51
|
municipio,
|
|
51
52
|
frete,
|
|
52
53
|
safra,
|
|
53
|
-
area
|
|
54
|
+
area,
|
|
55
|
+
configuracaoNotificacao
|
|
54
56
|
};
|
|
55
57
|
export {
|
|
56
58
|
dm as default
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dm.js","sources":["../../../../../lib/base/configs/endpoints.config/dm/dm.ts"],"sourcesContent":["import businessPartner from \"./config/businessPartner\";\nimport canalDistribuicao from \"./config/canalDistribuicao\";\nimport centro from \"./config/centro\";\nimport condicaoPagamento from \"./config/condicaoPagamento\";\nimport equipeVenda from \"./config/equipeVenda\";\nimport escritorioVenda from \"./config/escritorioVenda\";\nimport formaPagamento from \"./config/formaPagamento\";\nimport incoterms from \"./config/incoterms\";\nimport produto from \"./config/produto\";\nimport setorAtividade from \"./config/setorAtividade\";\nimport centroCusto from \"./config/centroCusto\";\nimport imobilizado from \"./config/imobilizado\";\nimport contaContabil from \"./config/contaContabil\";\nimport deposito from \"./config/deposito\";\nimport user from \"./config/user\";\nimport departamento from \"./config/departamento.endpoint.config\";\nimport tipoDocumentoVenda from \"./config/tipoDocumentoVenda\";\nimport grupoVenda from \"./config/grupoVenda\";\nimport tipoOrdemVenda from \"./config/tipoOrdemVenda\";\nimport iva from \"./config/iva\";\nimport grupoComprador from \"./config/grupoComprador\";\nimport tipoVeiculo from \"./config/tipoVeiculo\";\nimport municipio from \"./config/municipio\";\nimport frete from \"./config/frete\";\nimport safra from \"./config/safra\";\nimport area from \"./config/area\";\n\nconst dm = {\n businessPartner,\n canalDistribuicao,\n centro,\n condicaoPagamento,\n equipeVenda,\n escritorioVenda,\n formaPagamento,\n incoterms,\n produto,\n setorAtividade,\n centroCusto,\n imobilizado,\n contaContabil,\n deposito,\n user,\n departamento,\n grupoVenda,\n tipoDocumentoVenda,\n tipoOrdemVenda,\n iva,\n grupoComprador,\n tipoVeiculo,\n municipio,\n frete,\n safra,\n area\n}\n\nexport default dm;"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dm.js","sources":["../../../../../lib/base/configs/endpoints.config/dm/dm.ts"],"sourcesContent":["import businessPartner from \"./config/businessPartner\";\nimport canalDistribuicao from \"./config/canalDistribuicao\";\nimport centro from \"./config/centro\";\nimport condicaoPagamento from \"./config/condicaoPagamento\";\nimport equipeVenda from \"./config/equipeVenda\";\nimport escritorioVenda from \"./config/escritorioVenda\";\nimport formaPagamento from \"./config/formaPagamento\";\nimport incoterms from \"./config/incoterms\";\nimport produto from \"./config/produto\";\nimport setorAtividade from \"./config/setorAtividade\";\nimport centroCusto from \"./config/centroCusto\";\nimport imobilizado from \"./config/imobilizado\";\nimport contaContabil from \"./config/contaContabil\";\nimport deposito from \"./config/deposito\";\nimport user from \"./config/user\";\nimport departamento from \"./config/departamento.endpoint.config\";\nimport tipoDocumentoVenda from \"./config/tipoDocumentoVenda\";\nimport grupoVenda from \"./config/grupoVenda\";\nimport tipoOrdemVenda from \"./config/tipoOrdemVenda\";\nimport iva from \"./config/iva\";\nimport grupoComprador from \"./config/grupoComprador\";\nimport tipoVeiculo from \"./config/tipoVeiculo\";\nimport municipio from \"./config/municipio\";\nimport frete from \"./config/frete\";\nimport safra from \"./config/safra\";\nimport area from \"./config/area\";\nimport configuracaoNotificacao from \"./config/configuracaoNotificacao\";\n\nconst dm = {\n businessPartner,\n canalDistribuicao,\n centro,\n condicaoPagamento,\n equipeVenda,\n escritorioVenda,\n formaPagamento,\n incoterms,\n produto,\n setorAtividade,\n centroCusto,\n imobilizado,\n contaContabil,\n deposito,\n user,\n departamento,\n grupoVenda,\n tipoDocumentoVenda,\n tipoOrdemVenda,\n iva,\n grupoComprador,\n tipoVeiculo,\n municipio,\n frete,\n safra,\n area,\n configuracaoNotificacao\n}\n\nexport default dm;"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,MAAM,KAAK;AAAA,EACP;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACJ;"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import areaSubmenu from "./config/area.submenu.js";
|
|
2
|
+
import configuracaoNotificacaoSubmenu from "./config/configuracaoNotificacao.submenu.js";
|
|
2
3
|
const cadastrosSubmenu = [
|
|
3
|
-
areaSubmenu
|
|
4
|
+
areaSubmenu,
|
|
5
|
+
configuracaoNotificacaoSubmenu
|
|
4
6
|
];
|
|
5
7
|
export {
|
|
6
8
|
cadastrosSubmenu as default
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cadastros.submenu.js","sources":["../../../../../../lib/base/configs/navigation.config/submenu/dadosMestres/cadastros.submenu.ts"],"sourcesContent":["import { NavigationTree } from \"@/@types/navigation\"\nimport areaSubmenu from \"./config/area.submenu\"\n\nconst cadastrosSubmenu: NavigationTree[] = [\n areaSubmenu,\n]\n\nexport default cadastrosSubmenu\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cadastros.submenu.js","sources":["../../../../../../lib/base/configs/navigation.config/submenu/dadosMestres/cadastros.submenu.ts"],"sourcesContent":["import { NavigationTree } from \"@/@types/navigation\"\nimport areaSubmenu from \"./config/area.submenu\"\nimport configuracaoNotificacaoSubmenu from \"./config/configuracaoNotificacao.submenu\"\n\nconst cadastrosSubmenu: NavigationTree[] = [\n areaSubmenu,\n configuracaoNotificacaoSubmenu,\n]\n\nexport default cadastrosSubmenu\n"],"names":[],"mappings":";;AAIA,MAAM,mBAAqC;AAAA,EACvC;AAAA,EACA;AACJ;"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { NAV_ITEM_TYPE_ITEM } from "../../../../../../@ecme/constants/navigation.constant.js";
|
|
2
|
+
import { ADMIN } from "../../../../../../@ecme/constants/roles.constant.js";
|
|
3
|
+
const configuracaoNotificacaoSubmenu = {
|
|
4
|
+
key: "dadosMestres.configuracaoNotificacao",
|
|
5
|
+
path: "/dados-mestres/configuracao-notificacao",
|
|
6
|
+
title: "Configuração de Notificações",
|
|
7
|
+
translateKey: "nav.modules.dadosMestres.configuracaoNotificacao",
|
|
8
|
+
icon: "",
|
|
9
|
+
type: NAV_ITEM_TYPE_ITEM,
|
|
10
|
+
authority: [ADMIN],
|
|
11
|
+
subMenu: []
|
|
12
|
+
};
|
|
13
|
+
export {
|
|
14
|
+
configuracaoNotificacaoSubmenu as default
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=configuracaoNotificacao.submenu.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configuracaoNotificacao.submenu.js","sources":["../../../../../../../lib/base/configs/navigation.config/submenu/dadosMestres/config/configuracaoNotificacao.submenu.ts"],"sourcesContent":["import { NAV_ITEM_TYPE_ITEM } from '@/constants/navigation.constant'\nimport { ADMIN } from '@/constants/roles.constant'\nimport { NavigationTree } from '@/@types/navigation'\n\nconst configuracaoNotificacaoSubmenu: NavigationTree = {\n key: 'dadosMestres.configuracaoNotificacao',\n path: '/dados-mestres/configuracao-notificacao',\n title: 'Configuração de Notificações',\n translateKey: 'nav.modules.dadosMestres.configuracaoNotificacao',\n icon: '',\n type: NAV_ITEM_TYPE_ITEM,\n authority: [ADMIN],\n subMenu: [],\n}\n\nexport default configuracaoNotificacaoSubmenu\n"],"names":[],"mappings":";;AAIA,MAAM,iCAAiD;AAAA,EACnD,KAAK;AAAA,EACL,MAAM;AAAA,EACN,OAAO;AAAA,EACP,cAAc;AAAA,EACd,MAAM;AAAA,EACN,MAAM;AAAA,EACN,WAAW,CAAC,KAAK;AAAA,EACjB,SAAS,CAAA;AACb;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dadosMestres.nav.js","sources":["../../../../../../../lib/base/locales/lang/ptBR/modules/DadosMestres/dadosMestres.nav.ts"],"sourcesContent":["\nexport default {\n dadosMestres: {\n title: 'Dados Mestres',\n safra: 'Safra',\n veiculo: 'Veículo',\n tipoVeiculo: 'Tipo de Veículo',\n motorista: 'Motorista',\n area: 'Area',\n infoProdutor: 'Registro Info',\n centroDeposito: 'Centro/Deposito',\n fornecedor: 'Business Partner',\n },\n}"],"names":[],"mappings":"AACA,MAAA,eAAe;AAAA,EACX,cAAc;AAAA,IACV,OAAO;AAAA,IACP,OAAO;AAAA,IACP,SAAS;AAAA,IACT,aAAa;AAAA,IACb,WAAW;AAAA,IACX,MAAM;AAAA,IACN,cAAc;AAAA,IACd,gBAAgB;AAAA,IAChB,YAAY;AAAA,EAAA;AAEpB;"}
|
|
1
|
+
{"version":3,"file":"dadosMestres.nav.js","sources":["../../../../../../../lib/base/locales/lang/ptBR/modules/DadosMestres/dadosMestres.nav.ts"],"sourcesContent":["\nexport default {\n dadosMestres: {\n title: 'Dados Mestres',\n safra: 'Safra',\n veiculo: 'Veículo',\n tipoVeiculo: 'Tipo de Veículo',\n motorista: 'Motorista',\n area: 'Area',\n configuracaoNotificacao: 'Configuração de Notificações',\n infoProdutor: 'Registro Info',\n centroDeposito: 'Centro/Deposito',\n fornecedor: 'Business Partner',\n },\n}"],"names":[],"mappings":"AACA,MAAA,eAAe;AAAA,EACX,cAAc;AAAA,IACV,OAAO;AAAA,IACP,OAAO;AAAA,IACP,SAAS;AAAA,IACT,aAAa;AAAA,IACb,WAAW;AAAA,IACX,MAAM;AAAA,IACN,yBAAyB;AAAA,IACzB,cAAc;AAAA,IACd,gBAAgB;AAAA,IAChB,YAAY;AAAA,EAAA;AAEpB;"}
|
package/dist/base/services/modules/dm/configuracaoNotificacao/ConfiguracaoNotificacaoService.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import ApiService from "../../../../../@ecme/services/ApiService.js";
|
|
2
|
+
import "../../../../configs/index.js";
|
|
3
|
+
import endpointNavigationConfig from "../../../../configs/endpoints.config/endpoints.navigation.js";
|
|
4
|
+
const CONFIGURACAO_NOTIFICACAO_ENDPOINT = endpointNavigationConfig.dm.configuracaoNotificacao;
|
|
5
|
+
async function apiCreateConfiguracaoNotificacao(body) {
|
|
6
|
+
return ApiService.fetchDataWithAxios({
|
|
7
|
+
url: CONFIGURACAO_NOTIFICACAO_ENDPOINT.create.endpoint,
|
|
8
|
+
method: CONFIGURACAO_NOTIFICACAO_ENDPOINT.create.method,
|
|
9
|
+
data: body
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
async function apiUpdateConfiguracaoNotificacao(id, body) {
|
|
13
|
+
return ApiService.fetchDataWithAxios({
|
|
14
|
+
url: CONFIGURACAO_NOTIFICACAO_ENDPOINT.update.endpoint(id),
|
|
15
|
+
method: CONFIGURACAO_NOTIFICACAO_ENDPOINT.update.method,
|
|
16
|
+
data: body
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
async function apiDeleteConfiguracaoNotificacao(id) {
|
|
20
|
+
return ApiService.fetchDataWithAxios({
|
|
21
|
+
url: CONFIGURACAO_NOTIFICACAO_ENDPOINT.delete.endpoint(id),
|
|
22
|
+
method: CONFIGURACAO_NOTIFICACAO_ENDPOINT.delete.method
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
async function apiFindConfiguracaoNotificacaoById(id) {
|
|
26
|
+
return ApiService.fetchDataWithAxios({
|
|
27
|
+
url: CONFIGURACAO_NOTIFICACAO_ENDPOINT.findOne.endpoint(id),
|
|
28
|
+
method: CONFIGURACAO_NOTIFICACAO_ENDPOINT.findOne.method
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
async function apiFindMonitorConfiguracaoNotificacao(body) {
|
|
32
|
+
return ApiService.fetchDataWithAxios({
|
|
33
|
+
url: CONFIGURACAO_NOTIFICACAO_ENDPOINT.findMonitor.endpoint,
|
|
34
|
+
method: CONFIGURACAO_NOTIFICACAO_ENDPOINT.findMonitor.method,
|
|
35
|
+
data: body
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
async function apiFindTiposNotificacao() {
|
|
39
|
+
return ApiService.fetchDataWithAxios({
|
|
40
|
+
url: CONFIGURACAO_NOTIFICACAO_ENDPOINT.tipos.endpoint,
|
|
41
|
+
method: CONFIGURACAO_NOTIFICACAO_ENDPOINT.tipos.method
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
export {
|
|
45
|
+
apiCreateConfiguracaoNotificacao,
|
|
46
|
+
apiDeleteConfiguracaoNotificacao,
|
|
47
|
+
apiFindConfiguracaoNotificacaoById,
|
|
48
|
+
apiFindMonitorConfiguracaoNotificacao,
|
|
49
|
+
apiFindTiposNotificacao,
|
|
50
|
+
apiUpdateConfiguracaoNotificacao
|
|
51
|
+
};
|
|
52
|
+
//# sourceMappingURL=ConfiguracaoNotificacaoService.js.map
|
package/dist/base/services/modules/dm/configuracaoNotificacao/ConfiguracaoNotificacaoService.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConfiguracaoNotificacaoService.js","sources":["../../../../../../lib/base/services/modules/dm/configuracaoNotificacao/ConfiguracaoNotificacaoService.ts"],"sourcesContent":["import ApiService from \"@/services/ApiService\";\nimport { IFilterParams, TQueryResponse } from \"@base/@types/api\";\nimport {\n TCreateConfiguracaoNotificacaoRequest,\n TUpdateConfiguracaoNotificacaoRequest,\n} from \"@base/@types/api/request/dm/TConfiguracaoNotificacaoRequest\";\nimport {\n TGetConfiguracaoNotificacaoResponse,\n TGetTipoNotificacaoResponse,\n} from \"@base/@types/api/response/dadosMestres/TConfiguracaoNotificacaoResponse\";\nimport { endpointsConfig } from \"@base/configs\";\n\nconst CONFIGURACAO_NOTIFICACAO_ENDPOINT = endpointsConfig.dm.configuracaoNotificacao;\n\nexport async function apiCreateConfiguracaoNotificacao(body: TCreateConfiguracaoNotificacaoRequest) {\n return ApiService.fetchDataWithAxios<TGetConfiguracaoNotificacaoResponse>({\n url: CONFIGURACAO_NOTIFICACAO_ENDPOINT.create.endpoint,\n method: CONFIGURACAO_NOTIFICACAO_ENDPOINT.create.method,\n data: body,\n })\n}\n\nexport async function apiUpdateConfiguracaoNotificacao(id: number, body: TUpdateConfiguracaoNotificacaoRequest) {\n return ApiService.fetchDataWithAxios<TGetConfiguracaoNotificacaoResponse>({\n url: CONFIGURACAO_NOTIFICACAO_ENDPOINT.update.endpoint(id),\n method: CONFIGURACAO_NOTIFICACAO_ENDPOINT.update.method,\n data: body,\n })\n}\n\nexport async function apiDeleteConfiguracaoNotificacao(id: number) {\n return ApiService.fetchDataWithAxios<void>({\n url: CONFIGURACAO_NOTIFICACAO_ENDPOINT.delete.endpoint(id),\n method: CONFIGURACAO_NOTIFICACAO_ENDPOINT.delete.method,\n })\n}\n\nexport async function apiFindConfiguracaoNotificacaoById(id: number) {\n return ApiService.fetchDataWithAxios<TGetConfiguracaoNotificacaoResponse>({\n url: CONFIGURACAO_NOTIFICACAO_ENDPOINT.findOne.endpoint(id),\n method: CONFIGURACAO_NOTIFICACAO_ENDPOINT.findOne.method,\n })\n}\n\nexport async function apiFindMonitorConfiguracaoNotificacao(body?: IFilterParams) {\n return ApiService.fetchDataWithAxios<TQueryResponse<TGetConfiguracaoNotificacaoResponse>>({\n url: CONFIGURACAO_NOTIFICACAO_ENDPOINT.findMonitor.endpoint,\n method: CONFIGURACAO_NOTIFICACAO_ENDPOINT.findMonitor.method,\n data: body,\n })\n}\n\nexport async function apiFindTiposNotificacao() {\n return ApiService.fetchDataWithAxios<TGetTipoNotificacaoResponse[]>({\n url: CONFIGURACAO_NOTIFICACAO_ENDPOINT.tipos.endpoint,\n method: CONFIGURACAO_NOTIFICACAO_ENDPOINT.tipos.method,\n })\n}\n"],"names":["endpointsConfig"],"mappings":";;;AAYA,MAAM,oCAAoCA,yBAAgB,GAAG;AAE7D,eAAsB,iCAAiC,MAA6C;AAChG,SAAO,WAAW,mBAAwD;AAAA,IACtE,KAAK,kCAAkC,OAAO;AAAA,IAC9C,QAAQ,kCAAkC,OAAO;AAAA,IACjD,MAAM;AAAA,EAAA,CACT;AACL;AAEA,eAAsB,iCAAiC,IAAY,MAA6C;AAC5G,SAAO,WAAW,mBAAwD;AAAA,IACtE,KAAK,kCAAkC,OAAO,SAAS,EAAE;AAAA,IACzD,QAAQ,kCAAkC,OAAO;AAAA,IACjD,MAAM;AAAA,EAAA,CACT;AACL;AAEA,eAAsB,iCAAiC,IAAY;AAC/D,SAAO,WAAW,mBAAyB;AAAA,IACvC,KAAK,kCAAkC,OAAO,SAAS,EAAE;AAAA,IACzD,QAAQ,kCAAkC,OAAO;AAAA,EAAA,CACpD;AACL;AAEA,eAAsB,mCAAmC,IAAY;AACjE,SAAO,WAAW,mBAAwD;AAAA,IACtE,KAAK,kCAAkC,QAAQ,SAAS,EAAE;AAAA,IAC1D,QAAQ,kCAAkC,QAAQ;AAAA,EAAA,CACrD;AACL;AAEA,eAAsB,sCAAsC,MAAsB;AAC9E,SAAO,WAAW,mBAAwE;AAAA,IACtF,KAAK,kCAAkC,YAAY;AAAA,IACnD,QAAQ,kCAAkC,YAAY;AAAA,IACtD,MAAM;AAAA,EAAA,CACT;AACL;AAEA,eAAsB,0BAA0B;AAC5C,SAAO,WAAW,mBAAkD;AAAA,IAChE,KAAK,kCAAkC,MAAM;AAAA,IAC7C,QAAQ,kCAAkC,MAAM;AAAA,EAAA,CACnD;AACL;"}
|
|
@@ -158,9 +158,7 @@ const Input = (props: InputProps) => {
|
|
|
158
158
|
};
|
|
159
159
|
|
|
160
160
|
const inputProps = {
|
|
161
|
-
|
|
162
|
-
// remove a aparência padrão, não o className.
|
|
163
|
-
className: !unstyle ? inputClass : className,
|
|
161
|
+
className: !unstyle ? inputClass : "",
|
|
164
162
|
disabled,
|
|
165
163
|
type,
|
|
166
164
|
ref,
|
|
@@ -28,9 +28,6 @@ const ChatBox = forwardRef<ScrollBarRef, ChatBoxProps>((props, ref) => {
|
|
|
28
28
|
placeholder,
|
|
29
29
|
onInputChange,
|
|
30
30
|
inputActions,
|
|
31
|
-
uploadProps,
|
|
32
|
-
executando,
|
|
33
|
-
onStop,
|
|
34
31
|
showAvatar,
|
|
35
32
|
avatarGap,
|
|
36
33
|
customRenderer,
|
|
@@ -54,9 +51,6 @@ const ChatBox = forwardRef<ScrollBarRef, ChatBoxProps>((props, ref) => {
|
|
|
54
51
|
placeholder={placeholder}
|
|
55
52
|
onInputChange={onInputChange}
|
|
56
53
|
inputActions={inputActions}
|
|
57
|
-
uploadProps={uploadProps}
|
|
58
|
-
executando={executando}
|
|
59
|
-
onStop={onStop}
|
|
60
54
|
/>
|
|
61
55
|
}
|
|
62
56
|
>
|
|
@@ -1,158 +1,93 @@
|
|
|
1
1
|
import { useState, useRef } from 'react'
|
|
2
2
|
import Button from '@/components/ui/Button'
|
|
3
|
-
import Input from '@/components/ui/Input'
|
|
4
3
|
import Upload from '@/components/ui/Upload'
|
|
5
4
|
import hooks from '@/components/ui/hooks'
|
|
6
|
-
import { TbPhotoPlus, TbArrowRight
|
|
7
|
-
import type { UploadProps } from '@/components/ui/Upload'
|
|
5
|
+
import { TbPhotoPlus, TbArrowRight } from 'react-icons/tb'
|
|
8
6
|
import type { KeyboardEvent, ReactNode, Ref } from 'react'
|
|
9
7
|
|
|
10
8
|
export type ChatInputProps = {
|
|
11
9
|
placeholder?: string
|
|
12
10
|
onInputChange?: (payload: { value: string; attachments: File[] }) => void
|
|
13
|
-
ref?: Ref<
|
|
11
|
+
ref?: Ref<HTMLInputElement>
|
|
14
12
|
/** Controles extras dentro da caixa, logo antes do botão de enviar. */
|
|
15
13
|
inputActions?: ReactNode
|
|
16
|
-
/** Restrições do seletor de anexos (tipos aceitos, validação e bloqueio). */
|
|
17
|
-
uploadProps?: Pick<UploadProps, 'accept' | 'beforeUpload' | 'disabled'>
|
|
18
|
-
/**
|
|
19
|
-
* Uma resposta está chegando: o botão de enviar vira o de parar, e o Enter
|
|
20
|
-
* não envia — senão abriria uma segunda resposta na mesma conversa. O texto
|
|
21
|
-
* digitado fica na caixa para depois.
|
|
22
|
-
*/
|
|
23
|
-
executando?: boolean
|
|
24
|
-
/** Para a resposta que está chegando. */
|
|
25
|
-
onStop?: () => void
|
|
26
14
|
}
|
|
27
15
|
|
|
28
16
|
const { useMergeRef } = hooks
|
|
29
17
|
|
|
30
|
-
/**
|
|
31
|
-
* A altura inicial é `rows={1}`. Daí cresce com o conteúdo até o `max-h` de
|
|
32
|
-
* 5 linhas de 20px (`leading-5`, o ritmo do texto de 14px do app); passando
|
|
33
|
-
* disso, o próprio textarea rola.
|
|
34
|
-
*/
|
|
35
|
-
const CLASSES_DO_TEXTAREA =
|
|
36
|
-
'w-full max-h-[6.25rem] resize-none overflow-y-auto bg-transparent p-0 leading-5 heading-text placeholder:text-gray-400 focus:outline-none'
|
|
37
|
-
|
|
38
18
|
const ChatInput = (props: ChatInputProps) => {
|
|
39
19
|
const [attachments, setAttachments] = useState<File[]>([])
|
|
40
20
|
|
|
41
|
-
const {
|
|
42
|
-
placeholder,
|
|
43
|
-
onInputChange,
|
|
44
|
-
ref = null,
|
|
45
|
-
inputActions,
|
|
46
|
-
uploadProps,
|
|
47
|
-
executando = false,
|
|
48
|
-
onStop,
|
|
49
|
-
} = props
|
|
50
|
-
|
|
51
|
-
const inputRef = useRef<HTMLTextAreaElement>(null)
|
|
21
|
+
const { placeholder, onInputChange, ref = null, inputActions } = props
|
|
52
22
|
|
|
53
|
-
|
|
54
|
-
const ajustarAltura = (el: HTMLInputElement | HTMLTextAreaElement) => {
|
|
55
|
-
el.style.height = 'auto'
|
|
56
|
-
el.style.height = `${el.scrollHeight}px`
|
|
57
|
-
}
|
|
23
|
+
const inputRef = useRef<HTMLInputElement>(null)
|
|
58
24
|
|
|
59
25
|
const handleInputClear = () => {
|
|
60
26
|
if (inputRef.current) {
|
|
61
27
|
inputRef.current.value = ''
|
|
62
|
-
// Volta para a altura de uma linha.
|
|
63
|
-
inputRef.current.style.height = ''
|
|
64
28
|
}
|
|
65
29
|
setAttachments([])
|
|
66
30
|
}
|
|
67
31
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
32
|
+
const handleChange = () => {
|
|
33
|
+
if (inputRef.current?.value) {
|
|
34
|
+
onInputChange?.({
|
|
35
|
+
value: inputRef.current?.value || '',
|
|
36
|
+
attachments,
|
|
37
|
+
})
|
|
38
|
+
handleInputClear()
|
|
73
39
|
}
|
|
74
|
-
onInputChange?.({ value, attachments })
|
|
75
|
-
handleInputClear()
|
|
76
40
|
}
|
|
77
41
|
|
|
78
|
-
const handleKeyDown = (
|
|
79
|
-
event
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
!event.shiftKey &&
|
|
86
|
-
!event.nativeEvent.isComposing
|
|
87
|
-
) {
|
|
88
|
-
event.preventDefault()
|
|
89
|
-
if (!executando) {
|
|
90
|
-
enviar()
|
|
91
|
-
}
|
|
42
|
+
const handleKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {
|
|
43
|
+
if (event.key === 'Enter') {
|
|
44
|
+
onInputChange?.({
|
|
45
|
+
value: inputRef.current?.value || '',
|
|
46
|
+
attachments,
|
|
47
|
+
})
|
|
48
|
+
handleInputClear()
|
|
92
49
|
}
|
|
93
50
|
}
|
|
94
51
|
|
|
95
52
|
return (
|
|
96
|
-
<div className="
|
|
53
|
+
<div className="border-2 border-gray-200 dark:border-gray-700 rounded-xl min-h-[50px] px-3 flex flex-col">
|
|
97
54
|
{attachments.length > 0 && (
|
|
98
55
|
<Upload
|
|
99
56
|
fileList={attachments}
|
|
100
|
-
fileListClass="
|
|
57
|
+
fileListClass="flex gap-4"
|
|
101
58
|
fileItemClass="flex gap-8"
|
|
102
59
|
onFileRemove={setAttachments}
|
|
103
60
|
>
|
|
104
61
|
<></>
|
|
105
62
|
</Upload>
|
|
106
63
|
)}
|
|
107
|
-
<
|
|
108
|
-
ref={useMergeRef(inputRef, ref)}
|
|
109
|
-
textArea
|
|
110
|
-
unstyle
|
|
111
|
-
rows={1}
|
|
112
|
-
placeholder={placeholder}
|
|
113
|
-
onKeyDown={handleKeyDown}
|
|
114
|
-
onChange={(event) => ajustarAltura(event.currentTarget)}
|
|
115
|
-
className={CLASSES_DO_TEXTAREA}
|
|
116
|
-
/>
|
|
117
|
-
<div className="flex items-center gap-2 w-full">
|
|
64
|
+
<div className="flex items-center gap-2 w-full h-[50px]">
|
|
118
65
|
<Upload
|
|
119
|
-
{...uploadProps}
|
|
120
66
|
fileList={attachments}
|
|
121
67
|
showList={false}
|
|
122
68
|
onChange={setAttachments}
|
|
123
69
|
>
|
|
124
70
|
<button
|
|
125
|
-
className="text-xl heading-text
|
|
71
|
+
className="text-xl heading-text hover:text-primary px-1 py-2"
|
|
126
72
|
type="button"
|
|
127
|
-
disabled={uploadProps?.disabled}
|
|
128
73
|
>
|
|
129
74
|
<TbPhotoPlus />
|
|
130
75
|
</button>
|
|
131
76
|
</Upload>
|
|
77
|
+
<input
|
|
78
|
+
ref={useMergeRef(inputRef, ref)}
|
|
79
|
+
className="flex-1 h-full placeholder:text-gray-400 bg-transparent focus:outline-none heading-text"
|
|
80
|
+
placeholder={placeholder}
|
|
81
|
+
onKeyDown={handleKeyDown}
|
|
82
|
+
/>
|
|
132
83
|
{inputActions}
|
|
133
|
-
<
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
aria-label="Parar a resposta"
|
|
141
|
-
title="Parar a resposta"
|
|
142
|
-
onClick={onStop}
|
|
143
|
-
/>
|
|
144
|
-
) : (
|
|
145
|
-
<Button
|
|
146
|
-
size="xs"
|
|
147
|
-
shape="circle"
|
|
148
|
-
variant="solid"
|
|
149
|
-
icon={<TbArrowRight />}
|
|
150
|
-
aria-label="Enviar"
|
|
151
|
-
title="Enviar"
|
|
152
|
-
onClick={enviar}
|
|
153
|
-
/>
|
|
154
|
-
)}
|
|
155
|
-
</div>
|
|
84
|
+
<Button
|
|
85
|
+
size="xs"
|
|
86
|
+
shape="circle"
|
|
87
|
+
variant="solid"
|
|
88
|
+
icon={<TbArrowRight />}
|
|
89
|
+
onClick={handleChange}
|
|
90
|
+
/>
|
|
156
91
|
</div>
|
|
157
92
|
</div>
|
|
158
93
|
)
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { forwardRef } from 'react'
|
|
2
|
+
import ChatContainer from '@/components/view/ChatBox/components/ChatContainer'
|
|
3
|
+
import MessageList from '@/components/view/ChatBox/components/MessageList'
|
|
4
|
+
import AiChatInput from './AiChatInput'
|
|
5
|
+
import type { ReactNode } from 'react'
|
|
6
|
+
import type { ChatContainerProps } from '@/components/view/ChatBox/components/ChatContainer'
|
|
7
|
+
import type { MessageListProps } from '@/components/view/ChatBox/components/MessageList'
|
|
8
|
+
import type { ScrollBarRef } from '@/components/ui/ScrollBar'
|
|
9
|
+
import type { AiChatInputProps } from './AiChatInput'
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* O ChatBox do Orbe AI: a lista de mensagens com a caixa de mensagem própria.
|
|
13
|
+
*
|
|
14
|
+
* Cópia do `ChatBox` (`@/components/view/ChatBox`) que troca só a caixa de
|
|
15
|
+
* mensagem pela `AiChatInput`. O container (`ChatContainer`) e a lista
|
|
16
|
+
* (`MessageList`) continuam sendo os originais, sem alteração.
|
|
17
|
+
*
|
|
18
|
+
* É uma cópia de propósito: o ChatBox original é usado fora do chat (o chat de
|
|
19
|
+
* template e os microfrontends que consomem o client-core) e não pode mudar
|
|
20
|
+
* por causa do Orbe AI.
|
|
21
|
+
*/
|
|
22
|
+
export type AiChatBoxProps = {
|
|
23
|
+
messageList: MessageListProps['list']
|
|
24
|
+
header?: ChatContainerProps['header']
|
|
25
|
+
showMessageList?: boolean
|
|
26
|
+
children?: ReactNode
|
|
27
|
+
containerClass?: string
|
|
28
|
+
} & Omit<MessageListProps, 'list'> &
|
|
29
|
+
AiChatInputProps
|
|
30
|
+
|
|
31
|
+
const AiChatBox = forwardRef<ScrollBarRef, AiChatBoxProps>((props, ref) => {
|
|
32
|
+
const {
|
|
33
|
+
messageList,
|
|
34
|
+
showMessageList = true,
|
|
35
|
+
children,
|
|
36
|
+
header,
|
|
37
|
+
placeholder,
|
|
38
|
+
onInputChange,
|
|
39
|
+
inputActions,
|
|
40
|
+
uploadProps,
|
|
41
|
+
executando,
|
|
42
|
+
onStop,
|
|
43
|
+
showAvatar,
|
|
44
|
+
avatarGap,
|
|
45
|
+
customRenderer,
|
|
46
|
+
customAction,
|
|
47
|
+
bubbleClass,
|
|
48
|
+
myBubbleClass,
|
|
49
|
+
botBubbleClass,
|
|
50
|
+
errorBubbleClass,
|
|
51
|
+
renderTyping,
|
|
52
|
+
typing,
|
|
53
|
+
messageListClass,
|
|
54
|
+
containerClass,
|
|
55
|
+
} = props
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<ChatContainer
|
|
59
|
+
className={containerClass}
|
|
60
|
+
header={header}
|
|
61
|
+
input={
|
|
62
|
+
<AiChatInput
|
|
63
|
+
placeholder={placeholder}
|
|
64
|
+
onInputChange={onInputChange}
|
|
65
|
+
inputActions={inputActions}
|
|
66
|
+
uploadProps={uploadProps}
|
|
67
|
+
executando={executando}
|
|
68
|
+
onStop={onStop}
|
|
69
|
+
/>
|
|
70
|
+
}
|
|
71
|
+
>
|
|
72
|
+
{showMessageList && (
|
|
73
|
+
<MessageList
|
|
74
|
+
ref={ref}
|
|
75
|
+
list={messageList}
|
|
76
|
+
showAvatar={showAvatar}
|
|
77
|
+
avatarGap={avatarGap}
|
|
78
|
+
customRenderer={customRenderer}
|
|
79
|
+
customAction={customAction}
|
|
80
|
+
typing={typing}
|
|
81
|
+
messageListClass={messageListClass}
|
|
82
|
+
bubbleClass={bubbleClass}
|
|
83
|
+
myBubbleClass={myBubbleClass}
|
|
84
|
+
botBubbleClass={botBubbleClass}
|
|
85
|
+
errorBubbleClass={errorBubbleClass}
|
|
86
|
+
renderTyping={renderTyping}
|
|
87
|
+
/>
|
|
88
|
+
)}
|
|
89
|
+
{children}
|
|
90
|
+
</ChatContainer>
|
|
91
|
+
)
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
AiChatBox.displayName = 'AiChatBox'
|
|
95
|
+
|
|
96
|
+
export default AiChatBox
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { useState, useRef } from 'react'
|
|
2
|
+
import Button from '@/components/ui/Button'
|
|
3
|
+
import Upload from '@/components/ui/Upload'
|
|
4
|
+
import hooks from '@/components/ui/hooks'
|
|
5
|
+
import { TbPhotoPlus, TbArrowRight, TbPlayerStopFilled } from 'react-icons/tb'
|
|
6
|
+
import type { UploadProps } from '@/components/ui/Upload'
|
|
7
|
+
import type { KeyboardEvent, ReactNode, Ref } from 'react'
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Caixa de mensagem do Orbe AI.
|
|
11
|
+
*
|
|
12
|
+
* Cópia do `ChatInput` do ChatBox (`@/components/view/ChatBox/components/
|
|
13
|
+
* ChatInput`), alterada só para o chat: textarea que cresce com o texto, Enter
|
|
14
|
+
* envia e Shift+Enter quebra linha, botão de parar a resposta e restrições de
|
|
15
|
+
* upload por modelo.
|
|
16
|
+
*
|
|
17
|
+
* É uma cópia de propósito: o ChatBox original é usado em outros lugares do
|
|
18
|
+
* projeto e pelos microfrontends que consomem o client-core, e as mudanças do
|
|
19
|
+
* chat não podem alterar a aparência nem o comportamento deles. Mudança na
|
|
20
|
+
* caixa do Orbe AI vem aqui, não no original.
|
|
21
|
+
*/
|
|
22
|
+
export type AiChatInputProps = {
|
|
23
|
+
placeholder?: string
|
|
24
|
+
onInputChange?: (payload: { value: string; attachments: File[] }) => void
|
|
25
|
+
ref?: Ref<HTMLTextAreaElement>
|
|
26
|
+
/** Controles extras dentro da caixa, logo antes do botão de enviar. */
|
|
27
|
+
inputActions?: ReactNode
|
|
28
|
+
/** Restrições do seletor de anexos (tipos aceitos, validação e bloqueio). */
|
|
29
|
+
uploadProps?: Pick<UploadProps, 'accept' | 'beforeUpload' | 'disabled'>
|
|
30
|
+
/**
|
|
31
|
+
* Uma resposta está chegando: o botão de enviar vira o de parar, e o Enter
|
|
32
|
+
* não envia — senão abriria uma segunda resposta na mesma conversa. O texto
|
|
33
|
+
* digitado fica na caixa para depois.
|
|
34
|
+
*/
|
|
35
|
+
executando?: boolean
|
|
36
|
+
/** Para a resposta que está chegando. */
|
|
37
|
+
onStop?: () => void
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const { useMergeRef } = hooks
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* A altura inicial é `rows={1}`. Daí cresce com o conteúdo até o `max-h` de
|
|
44
|
+
* 5 linhas de 20px (`leading-5`, o ritmo do texto de 14px do app); passando
|
|
45
|
+
* disso, o próprio textarea rola.
|
|
46
|
+
*
|
|
47
|
+
* Textarea nativo, e não o `Input` do template com `unstyle`: o `Input`
|
|
48
|
+
* descarta o `className` quando está sem estilo, e mudar isso nele alteraria
|
|
49
|
+
* todos os inputs do projeto.
|
|
50
|
+
*/
|
|
51
|
+
const CLASSES_DO_TEXTAREA =
|
|
52
|
+
'w-full max-h-[6.25rem] resize-none overflow-y-auto bg-transparent p-0 leading-5 heading-text placeholder:text-gray-400 focus:outline-none'
|
|
53
|
+
|
|
54
|
+
const AiChatInput = (props: AiChatInputProps) => {
|
|
55
|
+
const [attachments, setAttachments] = useState<File[]>([])
|
|
56
|
+
|
|
57
|
+
const {
|
|
58
|
+
placeholder,
|
|
59
|
+
onInputChange,
|
|
60
|
+
ref = null,
|
|
61
|
+
inputActions,
|
|
62
|
+
uploadProps,
|
|
63
|
+
executando = false,
|
|
64
|
+
onStop,
|
|
65
|
+
} = props
|
|
66
|
+
|
|
67
|
+
const inputRef = useRef<HTMLTextAreaElement>(null)
|
|
68
|
+
|
|
69
|
+
/** Cresce com o conteúdo; o `max-h` do textarea é o limite. */
|
|
70
|
+
const ajustarAltura = (el: HTMLTextAreaElement) => {
|
|
71
|
+
el.style.height = 'auto'
|
|
72
|
+
el.style.height = `${el.scrollHeight}px`
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const handleInputClear = () => {
|
|
76
|
+
if (inputRef.current) {
|
|
77
|
+
inputRef.current.value = ''
|
|
78
|
+
// Volta para a altura de uma linha.
|
|
79
|
+
inputRef.current.style.height = ''
|
|
80
|
+
}
|
|
81
|
+
setAttachments([])
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** Envia texto, anexos ou os dois; com a caixa vazia não faz nada. */
|
|
85
|
+
const enviar = () => {
|
|
86
|
+
const value = inputRef.current?.value ?? ''
|
|
87
|
+
if (!value.trim() && attachments.length === 0) {
|
|
88
|
+
return
|
|
89
|
+
}
|
|
90
|
+
onInputChange?.({ value, attachments })
|
|
91
|
+
handleInputClear()
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const handleKeyDown = (event: KeyboardEvent<HTMLTextAreaElement>) => {
|
|
95
|
+
// Enter envia; Shift+Enter quebra linha. Composição de IME (acentos)
|
|
96
|
+
// não envia: o Enter ali está confirmando o caractere.
|
|
97
|
+
if (
|
|
98
|
+
event.key === 'Enter' &&
|
|
99
|
+
!event.shiftKey &&
|
|
100
|
+
!event.nativeEvent.isComposing
|
|
101
|
+
) {
|
|
102
|
+
event.preventDefault()
|
|
103
|
+
if (!executando) {
|
|
104
|
+
enviar()
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return (
|
|
110
|
+
<div className="shrink-0 border-2 border-gray-200 dark:border-gray-700 rounded-xl px-3 py-2 flex flex-col gap-1.5 transition-colors focus-within:border-gray-400 dark:focus-within:border-gray-500">
|
|
111
|
+
{attachments.length > 0 && (
|
|
112
|
+
<Upload
|
|
113
|
+
fileList={attachments}
|
|
114
|
+
fileListClass="mt-0 flex flex-wrap gap-2"
|
|
115
|
+
fileItemClass="flex gap-8"
|
|
116
|
+
onFileRemove={setAttachments}
|
|
117
|
+
>
|
|
118
|
+
<></>
|
|
119
|
+
</Upload>
|
|
120
|
+
)}
|
|
121
|
+
<textarea
|
|
122
|
+
ref={useMergeRef(inputRef, ref)}
|
|
123
|
+
rows={1}
|
|
124
|
+
placeholder={placeholder}
|
|
125
|
+
onKeyDown={handleKeyDown}
|
|
126
|
+
onChange={(event) => ajustarAltura(event.currentTarget)}
|
|
127
|
+
className={CLASSES_DO_TEXTAREA}
|
|
128
|
+
/>
|
|
129
|
+
<div className="flex items-center gap-2 w-full">
|
|
130
|
+
<Upload
|
|
131
|
+
{...uploadProps}
|
|
132
|
+
fileList={attachments}
|
|
133
|
+
showList={false}
|
|
134
|
+
onChange={setAttachments}
|
|
135
|
+
>
|
|
136
|
+
<button
|
|
137
|
+
className="text-xl heading-text enabled:hover:text-primary disabled:cursor-not-allowed disabled:opacity-40 px-1 py-2"
|
|
138
|
+
type="button"
|
|
139
|
+
disabled={uploadProps?.disabled}
|
|
140
|
+
>
|
|
141
|
+
<TbPhotoPlus />
|
|
142
|
+
</button>
|
|
143
|
+
</Upload>
|
|
144
|
+
{inputActions}
|
|
145
|
+
<div className="ltr:ml-auto rtl:mr-auto shrink-0">
|
|
146
|
+
{executando ? (
|
|
147
|
+
<Button
|
|
148
|
+
size="xs"
|
|
149
|
+
shape="circle"
|
|
150
|
+
variant="solid"
|
|
151
|
+
icon={<TbPlayerStopFilled />}
|
|
152
|
+
aria-label="Parar a resposta"
|
|
153
|
+
title="Parar a resposta"
|
|
154
|
+
onClick={onStop}
|
|
155
|
+
/>
|
|
156
|
+
) : (
|
|
157
|
+
<Button
|
|
158
|
+
size="xs"
|
|
159
|
+
shape="circle"
|
|
160
|
+
variant="solid"
|
|
161
|
+
icon={<TbArrowRight />}
|
|
162
|
+
aria-label="Enviar"
|
|
163
|
+
title="Enviar"
|
|
164
|
+
onClick={enviar}
|
|
165
|
+
/>
|
|
166
|
+
)}
|
|
167
|
+
</div>
|
|
168
|
+
</div>
|
|
169
|
+
</div>
|
|
170
|
+
)
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export default AiChatInput
|