@veracity/vui 1.4.0-rc.0 → 1.5.0-beta.0

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 (85) hide show
  1. package/dist/cjs/accordion/accordion.d.ts +6 -0
  2. package/dist/cjs/accordion/accordion.d.ts.map +1 -0
  3. package/dist/cjs/accordion/accordion.js +39 -0
  4. package/dist/cjs/accordion/accordion.types.d.ts +25 -0
  5. package/dist/cjs/accordion/accordion.types.d.ts.map +1 -0
  6. package/dist/cjs/accordion/accordion.types.js +2 -0
  7. package/dist/cjs/accordion/accordionItem.d.ts +5 -0
  8. package/dist/cjs/accordion/accordionItem.d.ts.map +1 -0
  9. package/dist/cjs/accordion/accordionItem.js +68 -0
  10. package/dist/cjs/accordion/accordionItemArrow.d.ts +5 -0
  11. package/dist/cjs/accordion/accordionItemArrow.d.ts.map +1 -0
  12. package/dist/cjs/accordion/accordionItemArrow.js +12 -0
  13. package/dist/cjs/accordion/index.d.ts +5 -0
  14. package/dist/cjs/accordion/index.d.ts.map +1 -0
  15. package/dist/cjs/accordion/index.js +25 -0
  16. package/dist/cjs/accordion/theme.d.ts +8 -0
  17. package/dist/cjs/accordion/theme.d.ts.map +1 -0
  18. package/dist/cjs/accordion/theme.js +12 -0
  19. package/dist/cjs/index.d.ts +1 -0
  20. package/dist/cjs/index.d.ts.map +1 -1
  21. package/dist/cjs/index.js +1 -0
  22. package/dist/cjs/select/select.types.d.ts +1 -1
  23. package/dist/cjs/select/select.types.d.ts.map +1 -1
  24. package/dist/cjs/theme/components.d.ts +6 -0
  25. package/dist/cjs/theme/components.d.ts.map +1 -1
  26. package/dist/cjs/theme/components.js +72 -70
  27. package/dist/cjs/theme/defaultTheme.d.ts +6 -0
  28. package/dist/cjs/theme/defaultTheme.d.ts.map +1 -1
  29. package/dist/cjs/toast/toast.d.ts +1 -0
  30. package/dist/cjs/toast/toast.d.ts.map +1 -1
  31. package/dist/cjs/toast/toast.js +3 -1
  32. package/dist/cjs/toast/toast.types.d.ts +3 -1
  33. package/dist/cjs/toast/toast.types.d.ts.map +1 -1
  34. package/dist/cjs/toast/useToast.d.ts +9 -6
  35. package/dist/cjs/toast/useToast.d.ts.map +1 -1
  36. package/dist/cjs/toast/useToast.js +14 -12
  37. package/dist/esm/accordion/accordion.d.ts +6 -0
  38. package/dist/esm/accordion/accordion.d.ts.map +1 -0
  39. package/dist/esm/accordion/accordion.js +21 -0
  40. package/dist/esm/accordion/accordion.types.d.ts +25 -0
  41. package/dist/esm/accordion/accordion.types.d.ts.map +1 -0
  42. package/dist/esm/accordion/accordion.types.js +1 -0
  43. package/dist/esm/accordion/accordionItem.d.ts +5 -0
  44. package/dist/esm/accordion/accordionItem.d.ts.map +1 -0
  45. package/dist/esm/accordion/accordionItem.js +27 -0
  46. package/dist/esm/accordion/accordionItemArrow.d.ts +5 -0
  47. package/dist/esm/accordion/accordionItemArrow.d.ts.map +1 -0
  48. package/dist/esm/accordion/accordionItemArrow.js +7 -0
  49. package/dist/esm/accordion/index.d.ts +5 -0
  50. package/dist/esm/accordion/index.d.ts.map +1 -0
  51. package/dist/esm/accordion/index.js +4 -0
  52. package/dist/esm/accordion/theme.d.ts +8 -0
  53. package/dist/esm/accordion/theme.d.ts.map +1 -0
  54. package/dist/esm/accordion/theme.js +10 -0
  55. package/dist/esm/index.d.ts +1 -0
  56. package/dist/esm/index.d.ts.map +1 -1
  57. package/dist/esm/index.js +1 -0
  58. package/dist/esm/select/select.types.d.ts +1 -1
  59. package/dist/esm/select/select.types.d.ts.map +1 -1
  60. package/dist/esm/theme/components.d.ts +6 -0
  61. package/dist/esm/theme/components.d.ts.map +1 -1
  62. package/dist/esm/theme/components.js +2 -0
  63. package/dist/esm/theme/defaultTheme.d.ts +6 -0
  64. package/dist/esm/theme/defaultTheme.d.ts.map +1 -1
  65. package/dist/esm/toast/toast.d.ts +1 -0
  66. package/dist/esm/toast/toast.d.ts.map +1 -1
  67. package/dist/esm/toast/toast.js +2 -1
  68. package/dist/esm/toast/toast.types.d.ts +3 -1
  69. package/dist/esm/toast/toast.types.d.ts.map +1 -1
  70. package/dist/esm/toast/useToast.d.ts +9 -6
  71. package/dist/esm/toast/useToast.d.ts.map +1 -1
  72. package/dist/esm/toast/useToast.js +13 -11
  73. package/package.json +1 -1
  74. package/src/accordion/accordion.tsx +33 -0
  75. package/src/accordion/accordion.types.ts +38 -0
  76. package/src/accordion/accordionItem.tsx +59 -0
  77. package/src/accordion/accordionItemArrow.tsx +11 -0
  78. package/src/accordion/index.ts +4 -0
  79. package/src/accordion/theme.ts +14 -0
  80. package/src/index.ts +1 -0
  81. package/src/select/select.types.ts +1 -1
  82. package/src/theme/components.ts +2 -0
  83. package/src/toast/toast.tsx +4 -2
  84. package/src/toast/toast.types.ts +4 -1
  85. package/src/toast/useToast.tsx +20 -11
@@ -0,0 +1,14 @@
1
+ const baseStyle = {}
2
+
3
+ const defaultProps = {}
4
+
5
+ const sizes = {}
6
+
7
+ const variants = {}
8
+
9
+ export default {
10
+ baseStyle,
11
+ defaultProps,
12
+ sizes,
13
+ variants
14
+ }
package/src/index.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export * from './accordion'
1
2
  export * from './avatar'
2
3
  export * from './box'
3
4
  export * from './button'
@@ -29,7 +29,7 @@ export type SelectProps = ThemingProps<'Select'> &
29
29
  /** Name of the input. Used in custom change event to support form library integration. */
30
30
  name?: string
31
31
  /** Data prop to display an array of options in the popover. */
32
- options: SelectOptionData[]
32
+ options?: SelectOptionData[]
33
33
  /** Displayed inside the trigger when no value is selected. */
34
34
  placeholder?: string
35
35
  /** Select cannot be opened and is styled accordingly. */
@@ -1,3 +1,4 @@
1
+ import Accordion from '../accordion/theme'
1
2
  import Avatar from '../avatar/theme'
2
3
  import Box from '../box/theme'
3
4
  import Button from '../button/theme'
@@ -35,6 +36,7 @@ import Tag from '../tag/theme'
35
36
  import Textarea from '../textarea/theme'
36
37
 
37
38
  export default {
39
+ Accordion,
38
40
  Avatar,
39
41
  Box,
40
42
  Button,
@@ -5,6 +5,8 @@ import { useVuiContext } from '../core'
5
5
  import { zIndices } from '../theme'
6
6
  import { ToastListItem } from './toast.types'
7
7
 
8
+ export const toasterWidth = 420
9
+
8
10
  const Toaster = () => {
9
11
  const { toasts } = useVuiContext()
10
12
 
@@ -12,8 +14,8 @@ const Toaster = () => {
12
14
  <Box
13
15
  bottom="1rem"
14
16
  display="block"
15
- maxW="100%"
16
- minW={{ md: 600, sm: 600, xs: '100%' }}
17
+ maxW={{ md: toasterWidth, sm: toasterWidth, xs: '100%' }}
18
+ minW={{ md: toasterWidth, sm: toasterWidth, xs: '100%' }}
17
19
  p={{ md: '16px', sm: '4px', xs: '2px' }}
18
20
  position="fixed"
19
21
  right={{ md: '1rem', sm: 0, xs: 0 }}
@@ -2,6 +2,8 @@ import { ReactNode } from 'react'
2
2
 
3
3
  import { NotificationProps } from '../notification'
4
4
 
5
+ export type ToastDuration = 'fast' | 'slow' | 'sticky'
6
+
5
7
  export interface ToastListItem {
6
8
  id: string
7
9
  component?: ReactNode
@@ -14,6 +16,7 @@ export interface ToastSetup {
14
16
 
15
17
  export interface ToastOptions extends NotificationProps {
16
18
  id?: string
17
- duration?: number
19
+ duration?: ToastDuration
20
+ /** @deprecated According to new UX requirements all toasts should be dismissible */
18
21
  dismissible?: boolean
19
22
  }
@@ -3,16 +3,21 @@ import React, { ReactNode } from 'react'
3
3
  import { useVuiContext } from '../core'
4
4
  import { Notification, NotificationStatus } from '../notification'
5
5
  import { uid } from '../utils'
6
- import { ToastOptions, ToastSetup } from './toast.types'
6
+ import { ToastDuration, ToastOptions, ToastSetup } from './toast.types'
7
+
8
+ export const defaultDuration = 'fast'
9
+ export const fastToastDuration = 4000
10
+ export const slowToastDuration = 8000
7
11
 
8
12
  const setup: ToastSetup = {
9
13
  options: {
10
- duration: 5000,
11
- dismissible: true
14
+ duration: defaultDuration
12
15
  },
13
16
  componentList: []
14
17
  }
15
18
 
19
+ const getDurationTime = (duration: ToastDuration) => (duration === 'fast' ? fastToastDuration : slowToastDuration)
20
+
16
21
  export const useToast = () => {
17
22
  const { addToast, removeToast } = useVuiContext()
18
23
 
@@ -21,7 +26,6 @@ export const useToast = () => {
21
26
  const showToast = (options?: ToastOptions): void => {
22
27
  const id = options?.id ? options.id : uid('toast')
23
28
  const { duration = setup.options.duration } = options || {}
24
- const { dismissible = setup.options.dismissible } = options || {}
25
29
  const { status = setup.options.duration } = options || {}
26
30
  const { action } = options || {}
27
31
  const { icon } = options || {}
@@ -38,7 +42,7 @@ export const useToast = () => {
38
42
  animation="fadeDown"
39
43
  icon={icon}
40
44
  mt={{ md: 1, sm: '4px', xs: '4px' }}
41
- onClose={dismissible ? onClose : undefined}
45
+ onClose={onClose}
42
46
  shadow={1}
43
47
  status={status as NotificationStatus}
44
48
  text={text}
@@ -50,14 +54,19 @@ export const useToast = () => {
50
54
 
51
55
  addToast(toast)
52
56
 
53
- if (duration !== 0) window.setTimeout(() => hideToast(id), duration)
57
+ if (duration && duration !== 'sticky') window.setTimeout(() => hideToast(id), getDurationTime(duration))
54
58
  }
55
59
 
56
- const showInfo = (text: ReactNode) => showToast({ text, status: 'info' })
57
- const showSuccess = (text: ReactNode) => showToast({ text, status: 'success' })
58
- const showWarning = (text: ReactNode) => showToast({ text, status: 'warning' })
59
- const showError = (text: ReactNode) => showToast({ text, status: 'error' })
60
- const showLoading = (text: ReactNode) => showToast({ text, status: 'loading' })
60
+ const showInfo = (text: ReactNode, duration: ToastDuration = defaultDuration) =>
61
+ showToast({ text, status: 'info', duration })
62
+ const showSuccess = (text: ReactNode, duration: ToastDuration = defaultDuration) =>
63
+ showToast({ text, status: 'success', duration })
64
+ const showWarning = (text: ReactNode, duration: ToastDuration = defaultDuration) =>
65
+ showToast({ text, status: 'warning', duration })
66
+ const showError = (text: ReactNode, duration: ToastDuration = defaultDuration) =>
67
+ showToast({ text, status: 'error', duration })
68
+ const showLoading = (text: ReactNode, duration: ToastDuration = defaultDuration) =>
69
+ showToast({ text, status: 'loading', duration })
61
70
 
62
71
  return { showToast, hideToast, showInfo, showSuccess, showWarning, showError, showLoading }
63
72
  }