wca-designsystem 1.0.42 → 1.0.44
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 +3 -7
- package/src/components/modules/Cabecalho/Cabecalho.stories.tsx +19 -9
- package/src/components/molecules/Chat/Chat.stories.tsx +20 -19
- package/src/components/molecules/Chat/index.tsx +82 -81
- package/src/components/molecules/Chat/styles.ts +5 -4
- package/src/styles/global.tsx +19 -16
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.0.
|
|
2
|
+
"version": "1.0.44",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"typings": "dist/index.d.ts",
|
|
@@ -30,12 +30,6 @@
|
|
|
30
30
|
"pre-commit": "tsdx lint"
|
|
31
31
|
}
|
|
32
32
|
},
|
|
33
|
-
"prettier": {
|
|
34
|
-
"printWidth": 80,
|
|
35
|
-
"semi": true,
|
|
36
|
-
"singleQuote": true,
|
|
37
|
-
"trailingComma": "es5"
|
|
38
|
-
},
|
|
39
33
|
"name": "wca-designsystem",
|
|
40
34
|
"author": "wca.dev",
|
|
41
35
|
"module": "dist/components.esm.js",
|
|
@@ -70,6 +64,7 @@
|
|
|
70
64
|
"@types/jest": "^29.5.12",
|
|
71
65
|
"@types/react": "^18.3.3",
|
|
72
66
|
"@types/react-dom": "^18.3.0",
|
|
67
|
+
"@typescript-eslint/parser": "^8.33.0",
|
|
73
68
|
"babel-jest": "^29.0.0",
|
|
74
69
|
"babel-loader": "^9.1.3",
|
|
75
70
|
"husky": "^9.0.11",
|
|
@@ -77,6 +72,7 @@
|
|
|
77
72
|
"jest": "^29.7.0",
|
|
78
73
|
"jest-environment-jsdom": "^29.7.0",
|
|
79
74
|
"postcss-preset-mantine": "1.13.0",
|
|
75
|
+
"prettier": "^3.5.3",
|
|
80
76
|
"react": "^18.3.1",
|
|
81
77
|
"react-dom": "^18.3.1",
|
|
82
78
|
"react-is": "^18.3.1",
|
|
@@ -1,19 +1,22 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/react'
|
|
2
|
-
import Cabecalho from '.'
|
|
3
|
-
import { NotificacaoProp } from '../../atomos/UsuarioNotification';
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react'
|
|
2
|
+
import Cabecalho from '.'
|
|
4
3
|
import iconExample from '../../../assets/imagens/icons/PrevisaoVendas.svg'
|
|
4
|
+
import { NotificacaoProp } from '../../atomos/UsuarioNotification'
|
|
5
5
|
|
|
6
6
|
const meta: Meta<typeof Cabecalho> = {
|
|
7
7
|
component: Cabecalho,
|
|
8
|
-
}
|
|
8
|
+
}
|
|
9
9
|
|
|
10
|
-
export default meta
|
|
10
|
+
export default meta
|
|
11
11
|
|
|
12
|
-
type Story = StoryObj<typeof Cabecalho
|
|
12
|
+
type Story = StoryObj<typeof Cabecalho>
|
|
13
13
|
|
|
14
14
|
export const Primary: Story = {
|
|
15
15
|
args: {
|
|
16
|
-
subTitulo:
|
|
16
|
+
subTitulo:
|
|
17
|
+
'Lorem Ipsum is simply dummy text of the printing and typesetting industry.' +
|
|
18
|
+
'Lorem Ipsum has been the industrys standard dummy text ever since the 1500s,' +
|
|
19
|
+
'when an unknown printer took a galley of type and scrambled it to make a type specimen book.',
|
|
17
20
|
temNotificacoes: false,
|
|
18
21
|
temChatBot: true,
|
|
19
22
|
icone: iconExample,
|
|
@@ -28,7 +31,14 @@ export const Primary: Story = {
|
|
|
28
31
|
setAbre: (state: boolean) => console.log(state),
|
|
29
32
|
setNotificacao: (state: NotificacaoProp) => console.log(state),
|
|
30
33
|
setNotificacoes: (state: NotificacaoProp[]) => console.log(state),
|
|
31
|
-
notificacoes: [
|
|
34
|
+
notificacoes: [
|
|
35
|
+
{
|
|
36
|
+
mensagem: 'Exemplo de mensagem de alerta',
|
|
37
|
+
tipo: 'warning',
|
|
38
|
+
titulo: 'Exemplo',
|
|
39
|
+
tempo: '10:00:00 pm',
|
|
40
|
+
},
|
|
41
|
+
],
|
|
32
42
|
},
|
|
33
43
|
},
|
|
34
|
-
}
|
|
44
|
+
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import React, { useState } from 'react'
|
|
2
|
-
import { Meta } from '@storybook/react'
|
|
3
|
-
import ChatBot, { MensagemChat } from '.'
|
|
4
|
-
import '@chatscope/chat-ui-kit-styles/dist/default/styles.min.css'
|
|
5
|
-
import ModalCustom from '../Modal'
|
|
6
|
-
import { theme } from '../../../styles/theme'
|
|
1
|
+
import React, { useState } from 'react'
|
|
2
|
+
import { Meta } from '@storybook/react'
|
|
3
|
+
import ChatBot, { MensagemChat } from '.'
|
|
4
|
+
import '@chatscope/chat-ui-kit-styles/dist/default/styles.min.css'
|
|
5
|
+
import ModalCustom from '../Modal'
|
|
6
|
+
import { theme } from '../../../styles/theme'
|
|
7
7
|
|
|
8
8
|
export default {
|
|
9
9
|
title: 'Components/modules/ChatBot',
|
|
10
10
|
component: ChatBot,
|
|
11
|
-
} as Meta
|
|
11
|
+
} as Meta
|
|
12
12
|
|
|
13
|
-
const props = {}
|
|
13
|
+
const props = {}
|
|
14
14
|
|
|
15
15
|
const Template: any = (args: any) => {
|
|
16
16
|
const [messages, setMessages] = useState<MensagemChat[]>([
|
|
@@ -38,9 +38,9 @@ const Template: any = (args: any) => {
|
|
|
38
38
|
'Outra',
|
|
39
39
|
],
|
|
40
40
|
},
|
|
41
|
-
])
|
|
42
|
-
const [respostaUser, setRespostaUser] = useState<string>('')
|
|
43
|
-
const [isTyping, setIsTyping] = useState<boolean>(false)
|
|
41
|
+
])
|
|
42
|
+
const [respostaUser, setRespostaUser] = useState<string>('')
|
|
43
|
+
const [isTyping, setIsTyping] = useState<boolean>(false)
|
|
44
44
|
|
|
45
45
|
return (
|
|
46
46
|
<ModalCustom
|
|
@@ -50,30 +50,31 @@ const Template: any = (args: any) => {
|
|
|
50
50
|
hasClose={true}
|
|
51
51
|
modalTitle={'CHATBOT'}
|
|
52
52
|
color={theme.colors.yellowWca}
|
|
53
|
-
close={function(): void {
|
|
54
|
-
throw new Error('Function not implemented.')
|
|
53
|
+
close={function (): void {
|
|
54
|
+
throw new Error('Function not implemented.')
|
|
55
55
|
}}
|
|
56
|
-
onClose={function(): void {
|
|
57
|
-
throw new Error('Function not implemented.')
|
|
56
|
+
onClose={function (): void {
|
|
57
|
+
throw new Error('Function not implemented.')
|
|
58
58
|
}}
|
|
59
59
|
>
|
|
60
60
|
<ChatBot
|
|
61
61
|
{...args}
|
|
62
62
|
messages={messages}
|
|
63
63
|
isTyping={isTyping}
|
|
64
|
+
disabledInputUser={true}
|
|
64
65
|
setMessages={setMessages}
|
|
65
66
|
setIsTyping={setIsTyping}
|
|
66
67
|
respostaUser={respostaUser}
|
|
67
68
|
setRespostaUser={setRespostaUser}
|
|
68
69
|
/>
|
|
69
70
|
</ModalCustom>
|
|
70
|
-
)
|
|
71
|
-
}
|
|
71
|
+
)
|
|
72
|
+
}
|
|
72
73
|
|
|
73
74
|
export const ChatBotStory = Template.bind({
|
|
74
75
|
...props,
|
|
75
|
-
})
|
|
76
|
+
})
|
|
76
77
|
|
|
77
78
|
ChatBotStory.args = {
|
|
78
79
|
...props,
|
|
79
|
-
}
|
|
80
|
+
}
|
|
@@ -5,59 +5,62 @@ import {
|
|
|
5
5
|
ChatContainer,
|
|
6
6
|
TypingIndicator,
|
|
7
7
|
Avatar,
|
|
8
|
-
} from '@chatscope/chat-ui-kit-react'
|
|
9
|
-
import React from 'react'
|
|
10
|
-
import { BotaoChat, ChatWrapper } from './styles'
|
|
11
|
-
import { Flex } from '@mantine/core'
|
|
12
|
-
import icon from '../../../assets/imagens/WCA/wca_inteligencia_comercial_logo.png'
|
|
8
|
+
} from '@chatscope/chat-ui-kit-react'
|
|
9
|
+
import React from 'react'
|
|
10
|
+
import { BotaoChat, ChatWrapper } from './styles'
|
|
11
|
+
import { Flex } from '@mantine/core'
|
|
12
|
+
import icon from '../../../assets/imagens/WCA/wca_inteligencia_comercial_logo.png'
|
|
13
|
+
import '@chatscope/chat-ui-kit-styles/dist/default/styles.min.css'
|
|
13
14
|
|
|
14
15
|
export type MensagemChat = {
|
|
15
|
-
idChat: string
|
|
16
|
-
text: string
|
|
17
|
-
options?: string[]
|
|
18
|
-
type: 'bot' | 'user'
|
|
19
|
-
}
|
|
16
|
+
idChat: string
|
|
17
|
+
text: string
|
|
18
|
+
options?: string[]
|
|
19
|
+
type: 'bot' | 'user'
|
|
20
|
+
}
|
|
20
21
|
|
|
21
22
|
type ChatBotProps = {
|
|
22
|
-
isTyping: boolean
|
|
23
|
-
setIsTyping: React.Dispatch<React.SetStateAction<boolean
|
|
24
|
-
respostaUser: string
|
|
25
|
-
setRespostaUser: React.Dispatch<React.SetStateAction<string
|
|
26
|
-
messages: MensagemChat[]
|
|
27
|
-
setMessages: React.Dispatch<React.SetStateAction<MensagemChat[]
|
|
28
|
-
|
|
23
|
+
isTyping: boolean
|
|
24
|
+
setIsTyping: React.Dispatch<React.SetStateAction<boolean>>
|
|
25
|
+
respostaUser: string
|
|
26
|
+
setRespostaUser: React.Dispatch<React.SetStateAction<string>>
|
|
27
|
+
messages: MensagemChat[]
|
|
28
|
+
setMessages: React.Dispatch<React.SetStateAction<MensagemChat[]>>
|
|
29
|
+
disabledInputUser?: boolean
|
|
30
|
+
}
|
|
29
31
|
|
|
30
32
|
const ChatBot = ({
|
|
33
|
+
messages,
|
|
31
34
|
isTyping,
|
|
35
|
+
setMessages,
|
|
32
36
|
setIsTyping,
|
|
33
37
|
respostaUser,
|
|
34
38
|
setRespostaUser,
|
|
35
|
-
|
|
36
|
-
setMessages,
|
|
39
|
+
disabledInputUser = false,
|
|
37
40
|
}: ChatBotProps) => {
|
|
38
41
|
const handleOptionSelect = (option: any) => {
|
|
39
|
-
const indexWithOptions = messages.findIndex((msg: any) => msg.options)
|
|
42
|
+
const indexWithOptions = messages.findIndex((msg: any) => msg.options)
|
|
40
43
|
|
|
41
44
|
if (indexWithOptions !== -1) {
|
|
42
45
|
const updatedMessages = messages.map((msg: any, i: number) => {
|
|
43
46
|
if (i === indexWithOptions) {
|
|
44
|
-
const { options, ...rest } = msg
|
|
45
|
-
return rest
|
|
47
|
+
const { options, ...rest } = msg
|
|
48
|
+
return rest
|
|
46
49
|
}
|
|
47
|
-
return msg
|
|
48
|
-
})
|
|
50
|
+
return msg
|
|
51
|
+
})
|
|
49
52
|
|
|
50
|
-
updatedMessages.push({ type: 'user', text: option })
|
|
51
|
-
setMessages(updatedMessages)
|
|
52
|
-
setIsTyping(true)
|
|
53
|
+
updatedMessages.push({ type: 'user', text: option })
|
|
54
|
+
setMessages(updatedMessages)
|
|
55
|
+
setIsTyping(true)
|
|
53
56
|
}
|
|
54
|
-
}
|
|
57
|
+
}
|
|
55
58
|
|
|
56
59
|
const handleSend = (innerHtml: string) => {
|
|
57
|
-
setMessages((prev: any) => [...prev, { type: 'user', text: innerHtml }])
|
|
58
|
-
setRespostaUser('')
|
|
59
|
-
setIsTyping(true)
|
|
60
|
-
}
|
|
60
|
+
setMessages((prev: any) => [...prev, { type: 'user', text: innerHtml }])
|
|
61
|
+
setRespostaUser('')
|
|
62
|
+
setIsTyping(true)
|
|
63
|
+
}
|
|
61
64
|
|
|
62
65
|
return (
|
|
63
66
|
<ChatWrapper>
|
|
@@ -71,66 +74,64 @@ const ChatBot = ({
|
|
|
71
74
|
>
|
|
72
75
|
{messages.map((msg: any, index: number) =>
|
|
73
76
|
msg.options ? (
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
<Avatar src={icon} name="ChatBot" />
|
|
77
|
+
<Message
|
|
78
|
+
avatarPosition="top-left"
|
|
79
|
+
key={index}
|
|
80
|
+
model={{
|
|
81
|
+
direction: msg.type === 'user' ? 'outgoing' : 'incoming',
|
|
82
|
+
position: 'single',
|
|
83
|
+
}}
|
|
84
|
+
>
|
|
85
|
+
<Avatar src={icon} name="ChatBot" />
|
|
84
86
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
87
|
+
<Message.CustomContent>
|
|
88
|
+
<div style={{ fontSize: '13px' }}>{msg.text}</div>
|
|
89
|
+
</Message.CustomContent>
|
|
88
90
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
</Message.Footer>
|
|
103
|
-
</Message>
|
|
104
|
-
</>
|
|
91
|
+
<Message.Footer>
|
|
92
|
+
<Flex mt={5} gap={5} direction={'column'}>
|
|
93
|
+
{msg.options.map((opt: any, i: number) => (
|
|
94
|
+
<BotaoChat
|
|
95
|
+
key={opt}
|
|
96
|
+
onClick={() => handleOptionSelect(opt)}
|
|
97
|
+
>
|
|
98
|
+
{i + 1}. {opt}
|
|
99
|
+
</BotaoChat>
|
|
100
|
+
))}
|
|
101
|
+
</Flex>
|
|
102
|
+
</Message.Footer>
|
|
103
|
+
</Message>
|
|
105
104
|
) : (
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
</Message>
|
|
118
|
-
</>
|
|
105
|
+
<Message
|
|
106
|
+
key={index}
|
|
107
|
+
style={{ fontSize: '13px' }}
|
|
108
|
+
model={{
|
|
109
|
+
message: msg.text,
|
|
110
|
+
direction: msg.type === 'user' ? 'outgoing' : 'incoming',
|
|
111
|
+
position: 'single',
|
|
112
|
+
}}
|
|
113
|
+
>
|
|
114
|
+
{msg.type == 'bot' && <Avatar src={icon} name="ChatBot" />}
|
|
115
|
+
</Message>
|
|
119
116
|
)
|
|
120
117
|
)}
|
|
121
118
|
</MessageList>
|
|
122
119
|
|
|
123
120
|
<MessageInput
|
|
124
121
|
value={respostaUser}
|
|
125
|
-
onChange={val => setRespostaUser(val)}
|
|
126
|
-
onSend={msg => handleSend(msg)}
|
|
122
|
+
onChange={(val) => setRespostaUser(val)}
|
|
123
|
+
onSend={(msg) => handleSend(msg)}
|
|
127
124
|
attachButton={false}
|
|
128
|
-
placeholder=
|
|
129
|
-
|
|
125
|
+
placeholder={
|
|
126
|
+
disabledInputUser
|
|
127
|
+
? 'Indisponível no momento'
|
|
128
|
+
: 'Escreva sua dúvida aqui'
|
|
129
|
+
}
|
|
130
|
+
disabled={disabledInputUser}
|
|
130
131
|
/>
|
|
131
132
|
</ChatContainer>
|
|
132
133
|
</ChatWrapper>
|
|
133
|
-
)
|
|
134
|
-
}
|
|
134
|
+
)
|
|
135
|
+
}
|
|
135
136
|
|
|
136
|
-
export default ChatBot
|
|
137
|
+
export default ChatBot
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import styled from 'styled-components'
|
|
2
|
-
import fundo from '../../../assets/imagens/novos-icones/STI_iconePreto.svg'
|
|
1
|
+
import styled from 'styled-components'
|
|
2
|
+
import fundo from '../../../assets/imagens/novos-icones/STI_iconePreto.svg'
|
|
3
3
|
|
|
4
4
|
export const BotaoChat = styled.button`
|
|
5
5
|
width: fit-content;
|
|
6
6
|
max-width: 250px;
|
|
7
7
|
border-radius: 5px;
|
|
8
8
|
background: #6ea9d7;
|
|
9
|
-
|
|
9
|
+
padding: 1px 6px;
|
|
10
|
+
`
|
|
10
11
|
|
|
11
12
|
export const ChatWrapper = styled.div`
|
|
12
13
|
margin: 20px 5px;
|
|
@@ -17,4 +18,4 @@ export const ChatWrapper = styled.div`
|
|
|
17
18
|
background-position: center;
|
|
18
19
|
background-blend-mode: exclusion;
|
|
19
20
|
}
|
|
20
|
-
|
|
21
|
+
`
|
package/src/styles/global.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createGlobalStyle } from
|
|
2
|
-
import { theme } from
|
|
1
|
+
import { createGlobalStyle } from 'styled-components';
|
|
2
|
+
import { theme } from './theme';
|
|
3
3
|
|
|
4
4
|
export const GlobalStyles = createGlobalStyle`
|
|
5
5
|
html,
|
|
@@ -39,22 +39,25 @@ export const GlobalStyles = createGlobalStyle`
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
* {
|
|
42
|
+
margin: 0;
|
|
43
|
+
padding: 0;
|
|
42
44
|
box-sizing: border-box;
|
|
43
|
-
|
|
45
|
+
|
|
44
46
|
|
|
45
47
|
&::-webkit-scrollbar {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
48
|
+
background-color: ${theme.colors.white};
|
|
49
|
+
width: 10px;
|
|
50
|
+
height: 10px;
|
|
51
|
+
border-radius: 5px;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
&::-webkit-scrollbar-thumb {
|
|
55
|
+
background: ${theme.colors.blue}; /* Cor do indicador */
|
|
56
|
+
border-radius: 5px;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
&::-webkit-scrollbar-thumb:hover {
|
|
60
|
+
background: rgba(53, 50, 164, 0.7); /* Cor do indicador quando hover */
|
|
61
|
+
}
|
|
59
62
|
}
|
|
60
63
|
`;
|