@veracity/vui 2.25.6 → 2.26.0-beta.1

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.
Files changed (156) hide show
  1. package/dist/cjs/accordion/accordion.d.ts.map +1 -1
  2. package/dist/cjs/accordion/accordion.js +1 -1
  3. package/dist/cjs/accordion/accordion.js.map +1 -1
  4. package/dist/cjs/chat/chat.d.ts +13 -0
  5. package/dist/cjs/chat/chat.d.ts.map +1 -0
  6. package/dist/cjs/chat/chat.js +42 -0
  7. package/dist/cjs/chat/chat.js.map +1 -0
  8. package/dist/cjs/chat/chat.types.d.ts +36 -0
  9. package/dist/cjs/chat/chat.types.d.ts.map +1 -0
  10. package/dist/cjs/chat/chat.types.js +10 -0
  11. package/dist/cjs/chat/chat.types.js.map +1 -0
  12. package/dist/cjs/chat/chatInput.d.ts +7 -0
  13. package/dist/cjs/chat/chatInput.d.ts.map +1 -0
  14. package/dist/cjs/chat/chatInput.js +66 -0
  15. package/dist/cjs/chat/chatInput.js.map +1 -0
  16. package/dist/cjs/chat/chatInputButton.d.ts +7 -0
  17. package/dist/cjs/chat/chatInputButton.d.ts.map +1 -0
  18. package/dist/cjs/chat/chatInputButton.js +19 -0
  19. package/dist/cjs/chat/chatInputButton.js.map +1 -0
  20. package/dist/cjs/chat/chatMessage.d.ts +7 -0
  21. package/dist/cjs/chat/chatMessage.d.ts.map +1 -0
  22. package/dist/cjs/chat/chatMessage.js +36 -0
  23. package/dist/cjs/chat/chatMessage.js.map +1 -0
  24. package/dist/cjs/chat/index.d.ts +6 -0
  25. package/dist/cjs/chat/index.d.ts.map +1 -0
  26. package/dist/cjs/chat/index.js +27 -0
  27. package/dist/cjs/chat/index.js.map +1 -0
  28. package/dist/cjs/chat/theme.d.ts +24 -0
  29. package/dist/cjs/chat/theme.d.ts.map +1 -0
  30. package/dist/cjs/chat/theme.js +18 -0
  31. package/dist/cjs/chat/theme.js.map +1 -0
  32. package/dist/cjs/core/types.d.ts +20 -0
  33. package/dist/cjs/core/types.d.ts.map +1 -1
  34. package/dist/cjs/core/types.js +22 -0
  35. package/dist/cjs/core/types.js.map +1 -1
  36. package/dist/cjs/icon/theme.d.ts +6 -1
  37. package/dist/cjs/icon/theme.d.ts.map +1 -1
  38. package/dist/cjs/icon/theme.js +6 -1
  39. package/dist/cjs/icon/theme.js.map +1 -1
  40. package/dist/cjs/index.d.ts +1 -0
  41. package/dist/cjs/index.d.ts.map +1 -1
  42. package/dist/cjs/index.js +1 -0
  43. package/dist/cjs/index.js.map +1 -1
  44. package/dist/cjs/message/message.d.ts.map +1 -1
  45. package/dist/cjs/message/message.js +3 -3
  46. package/dist/cjs/message/message.js.map +1 -1
  47. package/dist/cjs/message/message.types.d.ts +5 -2
  48. package/dist/cjs/message/message.types.d.ts.map +1 -1
  49. package/dist/cjs/modal/modal.d.ts.map +1 -1
  50. package/dist/cjs/modal/modal.js +1 -1
  51. package/dist/cjs/modal/modal.js.map +1 -1
  52. package/dist/cjs/notification/consts.js +2 -2
  53. package/dist/cjs/notification/consts.js.map +1 -1
  54. package/dist/cjs/notification/notificationIcon.d.ts.map +1 -1
  55. package/dist/cjs/notification/notificationIcon.js +1 -1
  56. package/dist/cjs/notification/notificationIcon.js.map +1 -1
  57. package/dist/cjs/popover/consts.d.ts.map +1 -1
  58. package/dist/cjs/popover/consts.js +2 -2
  59. package/dist/cjs/popover/consts.js.map +1 -1
  60. package/dist/cjs/select/selectOption.js +1 -1
  61. package/dist/cjs/select/selectOption.js.map +1 -1
  62. package/dist/cjs/theme/components.d.ts +28 -1
  63. package/dist/cjs/theme/components.d.ts.map +1 -1
  64. package/dist/cjs/theme/components.js +88 -86
  65. package/dist/cjs/theme/components.js.map +1 -1
  66. package/dist/cjs/theme/defaultTheme.d.ts +28 -1
  67. package/dist/cjs/theme/defaultTheme.d.ts.map +1 -1
  68. package/dist/esm/accordion/accordion.d.ts.map +1 -1
  69. package/dist/esm/accordion/accordion.js +1 -1
  70. package/dist/esm/accordion/accordion.js.map +1 -1
  71. package/dist/esm/chat/chat.d.ts +13 -0
  72. package/dist/esm/chat/chat.d.ts.map +1 -0
  73. package/dist/esm/chat/chat.js +25 -0
  74. package/dist/esm/chat/chat.js.map +1 -0
  75. package/dist/esm/chat/chat.types.d.ts +36 -0
  76. package/dist/esm/chat/chat.types.d.ts.map +1 -0
  77. package/dist/esm/chat/chat.types.js +7 -0
  78. package/dist/esm/chat/chat.types.js.map +1 -0
  79. package/dist/esm/chat/chatInput.d.ts +7 -0
  80. package/dist/esm/chat/chatInput.d.ts.map +1 -0
  81. package/dist/esm/chat/chatInput.js +49 -0
  82. package/dist/esm/chat/chatInput.js.map +1 -0
  83. package/dist/esm/chat/chatInputButton.d.ts +7 -0
  84. package/dist/esm/chat/chatInputButton.d.ts.map +1 -0
  85. package/dist/esm/chat/chatInputButton.js +16 -0
  86. package/dist/esm/chat/chatInputButton.js.map +1 -0
  87. package/dist/esm/chat/chatMessage.d.ts +7 -0
  88. package/dist/esm/chat/chatMessage.d.ts.map +1 -0
  89. package/dist/esm/chat/chatMessage.js +19 -0
  90. package/dist/esm/chat/chatMessage.js.map +1 -0
  91. package/dist/esm/chat/index.d.ts +6 -0
  92. package/dist/esm/chat/index.d.ts.map +1 -0
  93. package/dist/esm/chat/index.js +6 -0
  94. package/dist/esm/chat/index.js.map +1 -0
  95. package/dist/esm/chat/theme.d.ts +24 -0
  96. package/dist/esm/chat/theme.d.ts.map +1 -0
  97. package/dist/esm/chat/theme.js +16 -0
  98. package/dist/esm/chat/theme.js.map +1 -0
  99. package/dist/esm/core/types.d.ts +20 -0
  100. package/dist/esm/core/types.d.ts.map +1 -1
  101. package/dist/esm/core/types.js +21 -1
  102. package/dist/esm/core/types.js.map +1 -1
  103. package/dist/esm/icon/theme.d.ts +6 -1
  104. package/dist/esm/icon/theme.d.ts.map +1 -1
  105. package/dist/esm/icon/theme.js +6 -1
  106. package/dist/esm/icon/theme.js.map +1 -1
  107. package/dist/esm/index.d.ts +1 -0
  108. package/dist/esm/index.d.ts.map +1 -1
  109. package/dist/esm/index.js +1 -0
  110. package/dist/esm/index.js.map +1 -1
  111. package/dist/esm/message/message.d.ts.map +1 -1
  112. package/dist/esm/message/message.js +3 -3
  113. package/dist/esm/message/message.js.map +1 -1
  114. package/dist/esm/message/message.types.d.ts +5 -2
  115. package/dist/esm/message/message.types.d.ts.map +1 -1
  116. package/dist/esm/modal/modal.d.ts.map +1 -1
  117. package/dist/esm/modal/modal.js +2 -2
  118. package/dist/esm/modal/modal.js.map +1 -1
  119. package/dist/esm/notification/consts.js +2 -2
  120. package/dist/esm/notification/consts.js.map +1 -1
  121. package/dist/esm/notification/notificationIcon.d.ts.map +1 -1
  122. package/dist/esm/notification/notificationIcon.js +1 -1
  123. package/dist/esm/notification/notificationIcon.js.map +1 -1
  124. package/dist/esm/popover/consts.d.ts.map +1 -1
  125. package/dist/esm/popover/consts.js +2 -2
  126. package/dist/esm/popover/consts.js.map +1 -1
  127. package/dist/esm/select/selectOption.js +2 -2
  128. package/dist/esm/select/selectOption.js.map +1 -1
  129. package/dist/esm/theme/components.d.ts +28 -1
  130. package/dist/esm/theme/components.d.ts.map +1 -1
  131. package/dist/esm/theme/components.js +2 -0
  132. package/dist/esm/theme/components.js.map +1 -1
  133. package/dist/esm/theme/defaultTheme.d.ts +28 -1
  134. package/dist/esm/theme/defaultTheme.d.ts.map +1 -1
  135. package/dist/tsconfig.legacy.tsbuildinfo +1 -1
  136. package/dist/tsconfig.tsbuildinfo +1 -1
  137. package/package.json +1 -1
  138. package/src/accordion/accordion.tsx +1 -0
  139. package/src/chat/chat.tsx +86 -0
  140. package/src/chat/chat.types.ts +49 -0
  141. package/src/chat/chatInput.tsx +83 -0
  142. package/src/chat/chatInputButton.tsx +19 -0
  143. package/src/chat/chatMessage.tsx +33 -0
  144. package/src/chat/index.ts +5 -0
  145. package/src/chat/theme.ts +19 -0
  146. package/src/core/types.ts +21 -0
  147. package/src/icon/theme.ts +6 -1
  148. package/src/index.ts +1 -0
  149. package/src/message/message.tsx +10 -6
  150. package/src/message/message.types.ts +5 -2
  151. package/src/modal/modal.tsx +2 -2
  152. package/src/notification/consts.ts +2 -2
  153. package/src/notification/notificationIcon.tsx +1 -0
  154. package/src/popover/consts.ts +3 -3
  155. package/src/select/selectOption.tsx +2 -2
  156. package/src/theme/components.ts +2 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veracity/vui",
3
- "version": "2.25.6",
3
+ "version": "2.26.0-beta.1",
4
4
  "description": "Veracity UI is a React component library crafted for use within Veracity applications and pages. Based on Styled Components and @xstyled.",
5
5
  "module": "./dist/esm/index.js",
6
6
  "main": "./dist/cjs/index.js",
@@ -33,6 +33,7 @@ export const Accordion = vui<'div', AccordionProps>((props, ref) => {
33
33
  borderTop={isVertical ? `1px solid transparent` : undefined}
34
34
  className={cs('vui-accordion', className)}
35
35
  ref={ref}
36
+ w="100%"
36
37
  {...styles.container}
37
38
  {...aliasedProps}
38
39
  {...rest}
@@ -0,0 +1,86 @@
1
+ import { useEffect, useRef } from 'react'
2
+
3
+ import Box from '../box'
4
+ import { omitThemingProps, useStyleConfig, vui, VuiComponent } from '../core'
5
+ import { Tag } from '../tag'
6
+ import { cs } from '../utils'
7
+ import { ChatInputStatus, ChatProps } from './chat.types'
8
+ import ChatInput from './chatInput'
9
+ import ChatMessage from './chatMessage'
10
+
11
+ /**
12
+ * Displays a chat interface with messages and actions.
13
+ */
14
+ export const Chat = vui<'div', ChatProps>((props, ref) => {
15
+ const {
16
+ className,
17
+ children,
18
+ inputStatus = ChatInputStatus.Default,
19
+ messages,
20
+ processingMessage,
21
+ suggestions,
22
+ onNewTopicClick,
23
+ onSuggestionClick,
24
+ onSend,
25
+ onStop,
26
+ ...rest
27
+ } = omitThemingProps(props)
28
+
29
+ const styles = useStyleConfig('Chat', props)
30
+
31
+ const messagesEndRef = useRef<HTMLDivElement>(null)
32
+
33
+ const scrollDown = () => messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' })
34
+
35
+ useEffect(scrollDown, [messages, children])
36
+
37
+ return (
38
+ <Box
39
+ className={cs('vui-chat', className)}
40
+ ref={ref}
41
+ {...styles.chat}
42
+ h="100%"
43
+ justifyContent="space-between"
44
+ {...rest}
45
+ >
46
+ <Box className={cs('vui-chat-messages')} {...styles?.messages}>
47
+ {messages?.length ? messages.map((message, key) => <ChatMessage key={key} {...message} />) : children}
48
+ <div ref={messagesEndRef} />
49
+ </Box>
50
+ <Box column>
51
+ {!!suggestions?.length && (
52
+ <Box className={cs('vui-chat-suggestions')} {...styles?.suggestions} mb="24px" mt="8px">
53
+ {suggestions?.map(suggestion => (
54
+ <Tag
55
+ cursor={inputStatus === ChatInputStatus.Default ? 'pointer' : undefined}
56
+ disabled={inputStatus !== ChatInputStatus.Default}
57
+ key={suggestion}
58
+ mb="6px"
59
+ ml="6px"
60
+ onClick={() => onSuggestionClick?.(suggestion)}
61
+ >
62
+ {suggestion}
63
+ </Tag>
64
+ ))}
65
+ </Box>
66
+ )}
67
+ <ChatInput
68
+ onNewTopicClick={onNewTopicClick}
69
+ onSend={onSend}
70
+ onStop={onStop}
71
+ processingMessage={processingMessage}
72
+ status={inputStatus}
73
+ value=""
74
+ />
75
+ </Box>
76
+ </Box>
77
+ )
78
+ }) as VuiComponent<'div', ChatProps> & {
79
+ Message: typeof ChatMessage
80
+ Input: typeof ChatInput
81
+ }
82
+
83
+ Chat.Message = ChatMessage
84
+ Chat.Input = ChatInput
85
+ Chat.displayName = 'Chat'
86
+ export default Chat
@@ -0,0 +1,49 @@
1
+ import { AvatarProps } from '../avatar'
2
+ import { BoxProps } from '../box'
3
+ import { ButtonProps } from '../button'
4
+ import { MessageProps } from '../message'
5
+ import { ThemingProps } from '../theme'
6
+
7
+ export enum ChatInputStatus {
8
+ Default = 'default',
9
+ Processing = 'processing',
10
+ Disabled = 'disabled',
11
+ }
12
+
13
+ export type ChatProps = Omit<BoxProps, 'size' | 'variant'> &
14
+ ThemingProps<'Chat'> & {
15
+ // Status of the chat input @default 'default'
16
+ inputStatus?: ChatInputStatus
17
+ // An array of chat messages
18
+ messages?: ChatMessageProps[]
19
+ // Optional string indicating a message being processed
20
+ processingMessage?: string
21
+ // An array of suggestion strings
22
+ suggestions?: string[]
23
+ // Callback function for when a new topic is clicked
24
+ onNewTopicClick?: () => void
25
+ // Callback function for when a suggestion is clicked
26
+ onSuggestionClick?: (suggestion: string) => void
27
+ // Optional callback function for sending a message
28
+ onSend?: (message: string) => void
29
+ // Optional callback function for stopping an action
30
+ onStop?: () => void
31
+ }
32
+
33
+ export type ChatInputProps = Omit<BoxProps, 'size' | 'variant'> & {
34
+ placeholder?: string
35
+ status?: ChatInputStatus
36
+ /** @default 'Generating message' */
37
+ processingMessage?: string
38
+ onNewTopicClick?: () => void
39
+ onSend?: (message: string) => void
40
+ onStop?: () => void
41
+ }
42
+
43
+ export type ChatInputButtonProps = Omit<ButtonProps, 'size'> & {
44
+ status?: ChatInputStatus
45
+ }
46
+
47
+ export type ChatMessageProps = MessageProps & {
48
+ avatar?: AvatarProps
49
+ }
@@ -0,0 +1,83 @@
1
+ import { KeyboardEvent, useEffect, useState } from 'react'
2
+
3
+ import Box from '../box'
4
+ import Button from '../button'
5
+ import { KeyboardKeys, useStyleConfig, vui } from '../core'
6
+ import Icon from '../icon'
7
+ import Textarea from '../textarea'
8
+ import { cs } from '../utils'
9
+ import { ChatInputProps, ChatInputStatus } from './chat.types'
10
+ import ChatInputButton from './chatInputButton'
11
+
12
+ /**
13
+ * Displays a chat interface with messages and actions.
14
+ */
15
+ export const ChatInput = vui<'input', ChatInputProps>((props, ref) => {
16
+ const {
17
+ placeholder = 'Type your message',
18
+ status = ChatInputStatus.Default,
19
+ processingMessage = 'Generating message',
20
+ value: valueProp,
21
+ onNewTopicClick,
22
+ onSend,
23
+ onStop,
24
+ ...rest
25
+ } = props
26
+
27
+ const [value, setValue] = useState<string | undefined>(valueProp as string)
28
+ const styles = useStyleConfig('Chat', props)
29
+
30
+ useEffect(() => {
31
+ if (status === ChatInputStatus.Default) setValue(valueProp as string)
32
+ }, [status])
33
+
34
+ const onKeyDown = (e: KeyboardEvent<HTMLInputElement>) => {
35
+ if (e.key === KeyboardKeys.Enter && e.ctrlKey) {
36
+ e.stopPropagation()
37
+ if (value?.length && status === ChatInputStatus.Default) onSend?.(value)
38
+ }
39
+ if (e.key === KeyboardKeys.Escape) {
40
+ e.stopPropagation()
41
+ if (status === ChatInputStatus.Processing) onStop?.()
42
+ }
43
+ }
44
+
45
+ const isDisabled = status === ChatInputStatus.Disabled
46
+
47
+ return (
48
+ <Box className={cs('vui-chat-input')} justifyContent="space-between" ref={ref} {...styles?.input} {...rest}>
49
+ {!!onNewTopicClick && <Button icon="falPlus" mr={1} onClick={() => onNewTopicClick?.()} />}
50
+ {status === ChatInputStatus.Processing ? (
51
+ <Box borderColor="sandstone.79" borderWidth={1} center justifyContent="flex-start" py={0.5} w="100%">
52
+ <Icon mx={1} name="fadSpinnerThird" pathFill={['blue.40', 'blue.60']} size="lg" variant="spinning" />
53
+ <Box>{processingMessage}</Box>
54
+ </Box>
55
+ ) : (
56
+ <Textarea
57
+ disabled={isDisabled}
58
+ onChange={e => {
59
+ if (status === ChatInputStatus.Default) setValue(e.target.value)
60
+ }}
61
+ onKeyDown={onKeyDown}
62
+ placeholder={placeholder}
63
+ resize="vertical"
64
+ value={value}
65
+ w="100%"
66
+ />
67
+ )}
68
+
69
+ <ChatInputButton
70
+ disabled={!value?.length}
71
+ onClick={() => {
72
+ if (status === ChatInputStatus.Default) {
73
+ if (value?.length) onSend?.(value)
74
+ } else onStop?.()
75
+ }}
76
+ status={status as ChatInputStatus}
77
+ />
78
+ </Box>
79
+ )
80
+ })
81
+
82
+ ChatInput.displayName = 'ChatInput'
83
+ export default ChatInput
@@ -0,0 +1,19 @@
1
+ import { Button } from '../button'
2
+ import { useStyleConfig, vui } from '../core'
3
+ import { ChatInputButtonProps, ChatInputStatus } from './chat.types'
4
+
5
+ /**
6
+ * Displays a chat input button.
7
+ */
8
+ export const ChatInputButton = vui<'button', ChatInputButtonProps>((props, ref) => {
9
+ const styles = useStyleConfig('Chat', props)
10
+
11
+ const { status = 'default', onClick } = props
12
+
13
+ const icon = status === ChatInputStatus.Processing ? 'falStopCircle' : 'falChevronCircleRight'
14
+
15
+ return <Button icon={icon} onClick={onClick} ref={ref} variant="tertiaryDark" {...styles?.inputButton} />
16
+ })
17
+
18
+ ChatInputButton.displayName = 'ChatInputButton'
19
+ export default ChatInputButton
@@ -0,0 +1,33 @@
1
+ import { AvatarProps } from '../avatar'
2
+ import { useStyleConfig, vui } from '../core'
3
+ import Message from '../message'
4
+ import { cs } from '../utils'
5
+ import { ChatMessageProps } from './chat.types'
6
+
7
+ const defaultAvatar: AvatarProps = {
8
+ variant: 'solidDarkBlue',
9
+ icon: 'cubVeracity',
10
+ }
11
+
12
+ /**
13
+ * Displays a chat interface with messages and actions.
14
+ */
15
+ export const ChatMessage = vui<'div', ChatMessageProps>((props, ref) => {
16
+ const styles = useStyleConfig('Chat', props)
17
+ const { avatar = defaultAvatar, ...rest } = props
18
+
19
+ return (
20
+ <Message
21
+ avatar={avatar}
22
+ className={cs('vui-chat-message')}
23
+ h="100%"
24
+ my="16px"
25
+ ref={ref}
26
+ {...styles?.message}
27
+ {...rest}
28
+ />
29
+ )
30
+ })
31
+
32
+ ChatMessage.displayName = 'ChatMessage'
33
+ export default ChatMessage
@@ -0,0 +1,5 @@
1
+ export * from './chat'
2
+ export * from './chatInput'
3
+ export * from './chatMessage'
4
+ export { default } from './chat'
5
+ export * from './chat.types'
@@ -0,0 +1,19 @@
1
+ const baseStyle = {
2
+ chat: { flexDirection: 'column', w: '100%', height: '100%' },
3
+ messages: { flexDirection: 'column', overflowY: 'auto' },
4
+ suggestions: { display: 'block', textAlign: 'right', width: '100%' },
5
+ input: {},
6
+ }
7
+
8
+ const defaultProps = {}
9
+
10
+ const sizes = {}
11
+
12
+ const variants = {}
13
+
14
+ export default {
15
+ baseStyle,
16
+ defaultProps,
17
+ sizes,
18
+ variants,
19
+ }
package/src/core/types.ts CHANGED
@@ -12,3 +12,24 @@ export interface VuiContext {
12
12
  removeToast: (id: string) => void
13
13
  setPortalSlot: Dispatch<ReactNode>
14
14
  }
15
+
16
+ export enum KeyboardKeys {
17
+ Enter = 'Enter',
18
+ Escape = 'Escape',
19
+ ArrowUp = 'ArrowUp',
20
+ ArrowDown = 'ArrowDown',
21
+ ArrowLeft = 'ArrowLeft',
22
+ ArrowRight = 'ArrowRight',
23
+ Backspace = 'Backspace',
24
+ Tab = 'Tab',
25
+ Shift = 'Shift',
26
+ Control = 'Control',
27
+ Alt = 'Alt',
28
+ Meta = 'Meta',
29
+ Space = 'Space',
30
+ Delete = 'Delete',
31
+ Home = 'Home',
32
+ End = 'End',
33
+ PageUp = 'PageUp',
34
+ PageDown = 'PageDown',
35
+ }
package/src/icon/theme.ts CHANGED
@@ -34,7 +34,12 @@ const sizes = {
34
34
  },
35
35
  }
36
36
 
37
- const variants = {}
37
+ const variants = {
38
+ static: {},
39
+ spinning: {
40
+ animation: 'vui-spin 0.6s linear infinite',
41
+ },
42
+ }
38
43
 
39
44
  export default {
40
45
  baseStyle,
package/src/index.ts CHANGED
@@ -8,6 +8,7 @@ export * from './buttonGroup'
8
8
  export * from './buttonToggleGroup'
9
9
  export * from './calendar'
10
10
  export * from './card'
11
+ export * from './chat'
11
12
  export * from './checkbox'
12
13
  export * from './copyToClipboard'
13
14
  export * from './core'
@@ -1,9 +1,7 @@
1
- import React from 'react'
2
-
1
+ import { Avatar } from '../avatar'
3
2
  import { Box } from '../box'
4
3
  import { styled, useStyleConfig, vui } from '../core'
5
4
  import { Icon } from '../icon'
6
- import { T } from '../t'
7
5
  import { cs } from '../utils'
8
6
  import { iconDictionary, spacingDictionary } from './consts'
9
7
  import { MessageProps } from './message.types'
@@ -14,14 +12,20 @@ export const MessageBase = styled.divBox`
14
12
 
15
13
  /** Displays a simple message text. */
16
14
  export const Message = vui<'span', MessageProps>((props, ref) => {
17
- const { children, className, text, size = 'lg', variant = 'info', ...rest } = props
15
+ const { avatar, children, className, text, size = 'lg', variant = 'info', ...rest } = props
18
16
  const styles = useStyleConfig('Message', props)
19
17
 
20
18
  return (
21
19
  <MessageBase className={cs('vui-message', className)} ref={ref} {...styles} {...rest}>
22
20
  <Box>
23
- <Icon mr={`${spacingDictionary[size]}px`} name={iconDictionary[variant]} size={styles.fontSize} />
24
- <T size={styles.fontSize}>{children ?? text}</T>
21
+ {avatar ? (
22
+ <Avatar mr="8px" {...avatar} />
23
+ ) : (
24
+ <Icon mr={`${spacingDictionary[size]}px`} name={iconDictionary[variant]} size={styles.fontSize} />
25
+ )}
26
+ <Box mt={avatar ? '4px' : undefined} size={styles.fontSize} w="100%">
27
+ {children ?? text}
28
+ </Box>
25
29
  </Box>
26
30
  </MessageBase>
27
31
  )
@@ -1,10 +1,13 @@
1
- import { ReactText } from 'react'
1
+ import { ReactNode } from 'react'
2
2
 
3
+ import { AvatarProps } from '../avatar'
3
4
  import { SystemProps } from '../system'
4
5
  import { ThemingProps } from '../theme'
5
6
 
6
7
  export type MessageProps = SystemProps &
7
8
  ThemingProps<'Message'> & {
8
9
  /** Displays given text if no children are provided. */
9
- text?: ReactText
10
+ text?: ReactNode
11
+ /** If provided, it shows the avatar instead of the status icon */
12
+ avatar?: AvatarProps
10
13
  }
@@ -1,7 +1,7 @@
1
1
  import React, { cloneElement, useRef } from 'react'
2
2
 
3
3
  import Box from '../box'
4
- import { vui, VuiComponent } from '../core'
4
+ import { KeyboardKeys, vui, VuiComponent } from '../core'
5
5
  import FocusLock from '../focusLock'
6
6
  import Portal from '../portal'
7
7
  import { callAll, cs, KeyboardEvent, mergeRefs, MouseEvent } from '../utils'
@@ -65,7 +65,7 @@ export const Modal = vui<'div', ModalProps>((props, ref) => {
65
65
  }
66
66
 
67
67
  const onKeyDown = (e: KeyboardEvent<HTMLDivElement>) => {
68
- if (e.key === 'Escape') {
68
+ if (e.key === KeyboardKeys.Escape) {
69
69
  e.stopPropagation()
70
70
 
71
71
  !disableEscClose && onClose?.()
@@ -18,9 +18,9 @@ export const notificationStatusMapping: NotificationStatusMapping = {
18
18
  },
19
19
  loading: {
20
20
  iconProps: {
21
- animation: 'vui-spin 0.6s linear infinite',
22
21
  name: 'fadSpinnerThird',
23
22
  pathFill: ['blue.40', 'blue.60'],
23
+ variant: 'spinning',
24
24
  },
25
25
  variant: 'subtleBlue',
26
26
  },
@@ -50,9 +50,9 @@ export const notificationStatusMapping: NotificationStatusMapping = {
50
50
  },
51
51
  bannerLoading: {
52
52
  iconProps: {
53
- animation: 'vui-spin 0.6s linear infinite',
54
53
  name: 'fadSpinnerThird',
55
54
  pathFill: ['blue.40', 'blue.60'],
55
+ variant: 'spinning',
56
56
  },
57
57
  variant: 'bannerBlue',
58
58
  },
@@ -23,6 +23,7 @@ export const NotificationIcon = vui<'svg', IconProps>((props, ref) => {
23
23
  mt={marginTop}
24
24
  ref={ref}
25
25
  size="md"
26
+ variant="loading"
26
27
  {...styles.icon}
27
28
  {...iconProps}
28
29
  {...rest}
@@ -1,15 +1,15 @@
1
1
  import { Modifier } from '@popperjs/core'
2
2
  import { Plugin } from 'tippy.js'
3
3
 
4
+ import { KeyboardKeys } from '../core'
5
+
4
6
  /** Closes the popper if 'Escape' is pressed. Tippy plugin. */
5
7
  export const closeOnEscPlugin: Plugin = {
6
8
  name: 'closeOnEsc',
7
9
  defaultValue: true,
8
10
  fn({ hide }) {
9
11
  function onKeyDown(e: KeyboardEvent) {
10
- if (e.key === 'Escape') {
11
- hide()
12
- }
12
+ if (e.key === KeyboardKeys.Escape) hide()
13
13
  }
14
14
 
15
15
  return {
@@ -1,7 +1,7 @@
1
1
  import { useEffect } from 'react'
2
2
 
3
3
  import { Checkbox } from '../checkbox'
4
- import { useStyleConfig, vui } from '../core'
4
+ import { KeyboardKeys, useStyleConfig, vui } from '../core'
5
5
  import { List, ListItem } from '../list'
6
6
  import { usePopoverContext } from '../popover'
7
7
  import { cs, ellipsisOverflow, KeyboardEvent, MouseEvent, useCallbackRef } from '../utils'
@@ -37,7 +37,7 @@ export const SelectOption = vui<'li', SelectOptionProps>((props, ref) => {
37
37
  !isMultiple && hide()
38
38
  })
39
39
 
40
- const onKeyDown = useCallbackRef((e: KeyboardEvent<HTMLLIElement>) => e.key === 'Enter' && onClick(e))
40
+ const onKeyDown = useCallbackRef((e: KeyboardEvent<HTMLLIElement>) => e.key === KeyboardKeys.Enter && onClick(e))
41
41
 
42
42
  const onScroll = (e: Event) => !(e.target as HTMLElement)?.className?.includes('vui-allowScroll') && hide()
43
43
 
@@ -7,6 +7,7 @@ import Breadcrumbs from '../breadcrumbs/theme'
7
7
  import Button from '../button/theme'
8
8
  import Calendar from '../calendar/theme'
9
9
  import Card from '../card/theme'
10
+ import Chat from '../chat/theme'
10
11
  import Checkbox from '../checkbox/theme'
11
12
  import DatePicker from '../datePicker/theme'
12
13
  import Definition from '../definition/theme'
@@ -66,6 +67,7 @@ export default {
66
67
  Button,
67
68
  Calendar,
68
69
  Card,
70
+ Chat,
69
71
  Checkbox,
70
72
  DatePicker,
71
73
  Dialog,