@veracity/vui 2.24.2 → 2.25.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 (123) hide show
  1. package/dist/cjs/core/vuiProvider/animations.d.ts +4 -4
  2. package/dist/cjs/core/vuiProvider/animations.d.ts.map +1 -1
  3. package/dist/cjs/core/vuiProvider/animations.js +12 -8
  4. package/dist/cjs/core/vuiProvider/animations.js.map +1 -1
  5. package/dist/cjs/core/vuiProvider/globalStyle.d.ts.map +1 -1
  6. package/dist/cjs/core/vuiProvider/globalStyle.js +13 -4
  7. package/dist/cjs/core/vuiProvider/globalStyle.js.map +1 -1
  8. package/dist/cjs/dialog/consts.d.ts +10 -0
  9. package/dist/cjs/dialog/consts.d.ts.map +1 -1
  10. package/dist/cjs/dialog/consts.js +11 -1
  11. package/dist/cjs/dialog/consts.js.map +1 -1
  12. package/dist/cjs/dialog/dialog.d.ts.map +1 -1
  13. package/dist/cjs/dialog/dialog.js +5 -6
  14. package/dist/cjs/dialog/dialog.js.map +1 -1
  15. package/dist/cjs/dialog/dialog.types.d.ts +5 -2
  16. package/dist/cjs/dialog/dialog.types.d.ts.map +1 -1
  17. package/dist/cjs/drawer/drawer.d.ts +5 -0
  18. package/dist/cjs/drawer/drawer.d.ts.map +1 -0
  19. package/dist/cjs/drawer/drawer.js +21 -0
  20. package/dist/cjs/drawer/drawer.js.map +1 -0
  21. package/dist/cjs/drawer/drawer.types.d.ts +14 -0
  22. package/dist/cjs/drawer/drawer.types.d.ts.map +1 -0
  23. package/dist/cjs/drawer/drawer.types.js +3 -0
  24. package/dist/cjs/drawer/drawer.types.js.map +1 -0
  25. package/dist/cjs/drawer/index.d.ts +4 -0
  26. package/dist/cjs/drawer/index.d.ts.map +1 -0
  27. package/dist/cjs/drawer/index.js +25 -0
  28. package/dist/cjs/drawer/index.js.map +1 -0
  29. package/dist/cjs/drawer/theme.d.ts +8 -0
  30. package/dist/cjs/drawer/theme.d.ts.map +1 -0
  31. package/dist/cjs/drawer/theme.js +13 -0
  32. package/dist/cjs/drawer/theme.js.map +1 -0
  33. package/dist/cjs/index.d.ts +1 -0
  34. package/dist/cjs/index.d.ts.map +1 -1
  35. package/dist/cjs/index.js +1 -0
  36. package/dist/cjs/index.js.map +1 -1
  37. package/dist/cjs/modal/modal.d.ts.map +1 -1
  38. package/dist/cjs/modal/modal.js +2 -2
  39. package/dist/cjs/modal/modal.js.map +1 -1
  40. package/dist/cjs/modal/modal.types.d.ts +3 -1
  41. package/dist/cjs/modal/modal.types.d.ts.map +1 -1
  42. package/dist/cjs/theme/components.d.ts +6 -0
  43. package/dist/cjs/theme/components.d.ts.map +1 -1
  44. package/dist/cjs/theme/components.js +74 -72
  45. package/dist/cjs/theme/components.js.map +1 -1
  46. package/dist/cjs/theme/defaultTheme.d.ts +9 -0
  47. package/dist/cjs/theme/defaultTheme.d.ts.map +1 -1
  48. package/dist/cjs/theme/foundations/animations.d.ts +3 -0
  49. package/dist/cjs/theme/foundations/animations.d.ts.map +1 -1
  50. package/dist/cjs/theme/foundations/animations.js +3 -0
  51. package/dist/cjs/theme/foundations/animations.js.map +1 -1
  52. package/dist/cjs/theme/foundations/index.d.ts +3 -0
  53. package/dist/cjs/theme/foundations/index.d.ts.map +1 -1
  54. package/dist/esm/core/vuiProvider/animations.d.ts +4 -4
  55. package/dist/esm/core/vuiProvider/animations.d.ts.map +1 -1
  56. package/dist/esm/core/vuiProvider/animations.js +8 -8
  57. package/dist/esm/core/vuiProvider/animations.js.map +1 -1
  58. package/dist/esm/core/vuiProvider/globalStyle.d.ts.map +1 -1
  59. package/dist/esm/core/vuiProvider/globalStyle.js +13 -4
  60. package/dist/esm/core/vuiProvider/globalStyle.js.map +1 -1
  61. package/dist/esm/dialog/consts.d.ts +10 -0
  62. package/dist/esm/dialog/consts.d.ts.map +1 -1
  63. package/dist/esm/dialog/consts.js +10 -0
  64. package/dist/esm/dialog/consts.js.map +1 -1
  65. package/dist/esm/dialog/dialog.d.ts.map +1 -1
  66. package/dist/esm/dialog/dialog.js +10 -6
  67. package/dist/esm/dialog/dialog.js.map +1 -1
  68. package/dist/esm/dialog/dialog.types.d.ts +5 -2
  69. package/dist/esm/dialog/dialog.types.d.ts.map +1 -1
  70. package/dist/esm/drawer/drawer.d.ts +5 -0
  71. package/dist/esm/drawer/drawer.d.ts.map +1 -0
  72. package/dist/esm/drawer/drawer.js +15 -0
  73. package/dist/esm/drawer/drawer.js.map +1 -0
  74. package/dist/esm/drawer/drawer.types.d.ts +14 -0
  75. package/dist/esm/drawer/drawer.types.d.ts.map +1 -0
  76. package/dist/esm/drawer/drawer.types.js +2 -0
  77. package/dist/esm/drawer/drawer.types.js.map +1 -0
  78. package/dist/esm/drawer/index.d.ts +4 -0
  79. package/dist/esm/drawer/index.d.ts.map +1 -0
  80. package/dist/esm/drawer/index.js +4 -0
  81. package/dist/esm/drawer/index.js.map +1 -0
  82. package/dist/esm/drawer/theme.d.ts +8 -0
  83. package/dist/esm/drawer/theme.d.ts.map +1 -0
  84. package/dist/esm/drawer/theme.js +11 -0
  85. package/dist/esm/drawer/theme.js.map +1 -0
  86. package/dist/esm/index.d.ts +1 -0
  87. package/dist/esm/index.d.ts.map +1 -1
  88. package/dist/esm/index.js +1 -0
  89. package/dist/esm/index.js.map +1 -1
  90. package/dist/esm/modal/modal.d.ts.map +1 -1
  91. package/dist/esm/modal/modal.js +2 -2
  92. package/dist/esm/modal/modal.js.map +1 -1
  93. package/dist/esm/modal/modal.types.d.ts +3 -1
  94. package/dist/esm/modal/modal.types.d.ts.map +1 -1
  95. package/dist/esm/theme/components.d.ts +6 -0
  96. package/dist/esm/theme/components.d.ts.map +1 -1
  97. package/dist/esm/theme/components.js +2 -0
  98. package/dist/esm/theme/components.js.map +1 -1
  99. package/dist/esm/theme/defaultTheme.d.ts +9 -0
  100. package/dist/esm/theme/defaultTheme.d.ts.map +1 -1
  101. package/dist/esm/theme/foundations/animations.d.ts +3 -0
  102. package/dist/esm/theme/foundations/animations.d.ts.map +1 -1
  103. package/dist/esm/theme/foundations/animations.js +3 -0
  104. package/dist/esm/theme/foundations/animations.js.map +1 -1
  105. package/dist/esm/theme/foundations/index.d.ts +3 -0
  106. package/dist/esm/theme/foundations/index.d.ts.map +1 -1
  107. package/dist/tsconfig.legacy.tsbuildinfo +1 -1
  108. package/dist/tsconfig.tsbuildinfo +1 -1
  109. package/package.json +1 -1
  110. package/src/core/vuiProvider/animations.ts +8 -8
  111. package/src/core/vuiProvider/globalStyle.tsx +13 -4
  112. package/src/dialog/consts.ts +12 -0
  113. package/src/dialog/dialog.tsx +11 -5
  114. package/src/dialog/dialog.types.ts +5 -3
  115. package/src/drawer/drawer.tsx +24 -0
  116. package/src/drawer/drawer.types.ts +15 -0
  117. package/src/drawer/index.ts +3 -0
  118. package/src/drawer/theme.ts +14 -0
  119. package/src/index.ts +1 -0
  120. package/src/modal/modal.tsx +2 -1
  121. package/src/modal/modal.types.ts +3 -1
  122. package/src/theme/components.ts +2 -0
  123. package/src/theme/foundations/animations.ts +3 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veracity/vui",
3
- "version": "2.24.2",
3
+ "version": "2.25.0-beta.0",
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",
@@ -9,10 +9,10 @@ export const bounce = `
9
9
  }
10
10
  `
11
11
 
12
- export const fadeDown = `
12
+ export const fadeDown = (distance: number) => `
13
13
  from {
14
14
  opacity: 0;
15
- transform: translateY(-20px)
15
+ transform: translateY(-${distance}px)
16
16
  }
17
17
  to {
18
18
  opacity: 1;
@@ -29,10 +29,10 @@ export const fadeIn = `
29
29
  }
30
30
  `
31
31
 
32
- export const fadeLeft = `
32
+ export const fadeLeft = (distance: number) => `
33
33
  from {
34
34
  opacity: 0;
35
- transform: translateX(20px)
35
+ transform: translateX(${distance}px)
36
36
  }
37
37
  to {
38
38
  opacity: 1;
@@ -49,10 +49,10 @@ export const fadeOut = `
49
49
  }
50
50
  `
51
51
 
52
- export const fadeRight = `
52
+ export const fadeRight = (distance: number) => `
53
53
  from {
54
54
  opacity: 0;
55
- transform: translateX(-20px)
55
+ transform: translateX(-${distance}px)
56
56
  }
57
57
  to {
58
58
  opacity: 1;
@@ -60,10 +60,10 @@ export const fadeRight = `
60
60
  }
61
61
  `
62
62
 
63
- export const fadeUp = `
63
+ export const fadeUp = (distance: number) => `
64
64
  from {
65
65
  opacity: 0;
66
- transform: translateY(20px)
66
+ transform: translateY(${distance}px)
67
67
  }
68
68
  to {
69
69
  opacity: 1;
@@ -77,7 +77,7 @@ export default createGlobalStyle<GlobalStyleProps>`
77
77
  }
78
78
 
79
79
  @keyframes vui-fadeDown {
80
- ${fadeDown}
80
+ ${fadeDown(20)}
81
81
  }
82
82
 
83
83
  @keyframes vui-fadeIn {
@@ -85,19 +85,28 @@ export default createGlobalStyle<GlobalStyleProps>`
85
85
  }
86
86
 
87
87
  @keyframes vui-fadeLeft {
88
- ${fadeLeft}
88
+ ${fadeLeft(20)}
89
+ }
90
+
91
+ @keyframes vui-fadeLeftLong {
92
+ ${fadeLeft(600)}
89
93
  }
90
94
 
91
95
  @keyframes vui-fadeOut {
92
96
  ${fadeOut}
93
97
  }
94
98
 
99
+
95
100
  @keyframes vui-fadeRight {
96
- ${fadeRight}
101
+ ${fadeRight(20)}
102
+ }
103
+
104
+ @keyframes vui-fadeRightLong {
105
+ ${fadeRight(600)}
97
106
  }
98
107
 
99
108
  @keyframes vui-fadeUp {
100
- ${fadeUp}
109
+ ${fadeUp(20)}
101
110
  }
102
111
 
103
112
  @keyframes vui-pulse {
@@ -28,6 +28,18 @@ export const dialogStatusMapping: DialogStatusMapping = {
28
28
  },
29
29
  }
30
30
 
31
+ export const modalAnimation = {
32
+ left: 'fadeRightLong',
33
+ center: 'fadeDown',
34
+ right: 'fadeLeftLong',
35
+ }
36
+
37
+ export const modalJustifyContent = {
38
+ left: 'start',
39
+ center: 'center',
40
+ right: 'end',
41
+ }
42
+
31
43
  export const containerId = 'vui-dynamic-container'
32
44
 
33
45
  export const modalClass = 'vui-modal'
@@ -1,8 +1,9 @@
1
- import React, { useRef } from 'react'
1
+ import { useRef } from 'react'
2
2
 
3
3
  import { styled, useStyleConfig, vui, VuiComponent } from '../core'
4
4
  import { Modal } from '../modal'
5
5
  import { cs, isJsx, isReactText, random, useIds } from '../utils'
6
+ import { modalAnimation, modalJustifyContent } from './consts'
6
7
  import { DialogProvider } from './context'
7
8
  import { DialogProps } from './dialog.types'
8
9
  import DialogBody from './dialogBody'
@@ -20,8 +21,6 @@ export const DialogBase = styled.divBox`
20
21
  box-shadow: modal;
21
22
  display: flex;
22
23
  flex-direction: column;
23
- margin: 16px;
24
- max-height: calc(100vh - 32px); // full height - margin top/bottom
25
24
  width: 100%;
26
25
  `
27
26
 
@@ -46,6 +45,7 @@ export const Dialog = vui<'div', DialogProps>((props, ref) => {
46
45
  id,
47
46
  isOpen,
48
47
  modalProps: modalPropsProp,
48
+ placement = 'center',
49
49
  onClose,
50
50
  size,
51
51
  status,
@@ -60,8 +60,8 @@ export const Dialog = vui<'div', DialogProps>((props, ref) => {
60
60
  const [dialogId, bodyId, titleId] = useIds(idRef.current, ['dialog', 'dialog-body', 'dialog-title'])
61
61
 
62
62
  const body = isReactText(bodyProp) ? { children: bodyProp } : bodyProp
63
- const showFooter = Boolean(footer || cancelButton || submitButton)
64
63
  const showHeader = Boolean(header || closeButton || icon || title)
64
+ const showFooter = Boolean(footer || cancelButton || submitButton)
65
65
 
66
66
  const ariaProps = {
67
67
  'aria-describedby': bodyId,
@@ -69,8 +69,13 @@ export const Dialog = vui<'div', DialogProps>((props, ref) => {
69
69
  }
70
70
 
71
71
  const modalProps = {
72
+ animation: modalAnimation[placement as keyof typeof modalAnimation],
73
+ contentProps: {
74
+ alignItems: placement === 'center' ? 'center' : 'auto',
75
+ justifyContent: modalJustifyContent[placement as keyof typeof modalJustifyContent],
76
+ ...modalPropsProp?.contentProps,
77
+ },
72
78
  ...modalPropsProp,
73
- contentProps: { alignItems: 'center', justifyContent: 'center', ...modalPropsProp?.contentProps },
74
79
  }
75
80
 
76
81
  const context = { bodyId, icon, isOpen, onClose, size, status, titleId, variant }
@@ -81,6 +86,7 @@ export const Dialog = vui<'div', DialogProps>((props, ref) => {
81
86
  <DialogBase
82
87
  className={cs('vui-dialog', className)}
83
88
  id={dialogId}
89
+ maxH={placement === 'center' ? 'calc(100vh - 32px)' : '100%'}
84
90
  ref={ref}
85
91
  role="dialog"
86
92
  {...ariaProps}
@@ -1,5 +1,3 @@
1
- import { ReactText } from 'react'
2
-
3
1
  import { BoxProps } from '../box'
4
2
  import { ButtonProps, IconButtonProps } from '../button'
5
3
  import { HeadingProps } from '../heading'
@@ -26,11 +24,13 @@ export type DialogHeaderProps = PropsOf<'div', BoxProps & Pick<DialogProps, 'clo
26
24
 
27
25
  export type DialogIconProps = PropsOf<'svg', IconProps>
28
26
 
27
+ export type DialogPlacement = 'left' | 'center' | 'right'
28
+
29
29
  export type DialogProps = SystemProps &
30
30
  ThemingProps<'Dialog'> &
31
31
  Pick<ModalProps, 'isOpen' | 'onClose'> & {
32
32
  /** Socket for the main Dialog content. */
33
- body?: ReactText | DialogBodyProps | JSX.Element
33
+ body?: string | number | DialogBodyProps | JSX.Element
34
34
  /** Socket for a cancel button in the Dialog Footer. */
35
35
  cancelButton?: DialogCancelButtonProps | JSX.Element
36
36
  /** Socket for a close icon button in the Dialog Header. */
@@ -45,6 +45,8 @@ export type DialogProps = SystemProps &
45
45
  icon?: IconProp | DialogIconProps | JSX.Element
46
46
  /** The props being passed into the internal Modal component. */
47
47
  modalProps?: ModalProps
48
+ /** Position of the dialog @default center */
49
+ placement?: DialogPlacement
48
50
  /** Adds an icon for a given status, such as error or warning. */
49
51
  status?: DialogStatus
50
52
  /** Socket for a submit button in the Dialog Footer. */
@@ -0,0 +1,24 @@
1
+ import Box from '../box'
2
+ import { omitThemingProps, useStyleConfig, vui } from '../core'
3
+ import { Dialog } from '../dialog'
4
+ import { cs } from '../utils'
5
+ import { DrawerProps } from './drawer.types'
6
+
7
+ /** Drawer component based on Dialog. */
8
+ export const Drawer = vui<'div', DrawerProps>((props, ref) => {
9
+ const { children, className, dialogProps, isLeft, isOpen, onClose } = omitThemingProps(props)
10
+ const styles = useStyleConfig('Drawer', props)
11
+
12
+ const placement = isLeft ? 'left' : 'right'
13
+
14
+ return (
15
+ <Dialog isOpen={isOpen} onClose={onClose} placement={placement} ref={ref} {...dialogProps}>
16
+ <Box className={cs('vui-drawer', className)} column p={3} {...styles} h="100vh" overflow="hidden">
17
+ {children}
18
+ </Box>
19
+ </Dialog>
20
+ )
21
+ })
22
+
23
+ Drawer.displayName = 'Drawer'
24
+ export default Drawer
@@ -0,0 +1,15 @@
1
+ import { DialogProps } from '../dialog'
2
+ import { SystemProps } from '../system'
3
+ import { ThemingProps } from '../theme'
4
+
5
+ export type DrawerProps = SystemProps &
6
+ ThemingProps<'Drawer'> & {
7
+ /** The props being passed into the internal Dialog component. */
8
+ dialogProps?: DialogProps
9
+ /** Determines if the drawer is on the left side of the screen. @default false */
10
+ isLeft?: boolean
11
+ /** Determines if the drawer is open. @default false */
12
+ isOpen?: boolean
13
+ /** Function to be called when the drawer is closed */
14
+ onClose?: () => void
15
+ }
@@ -0,0 +1,3 @@
1
+ export * from './drawer'
2
+ export { default } from './drawer'
3
+ export * from './drawer.types'
@@ -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
@@ -16,6 +16,7 @@ export * from './datePicker'
16
16
  export * from './dialog'
17
17
  export * from './divider'
18
18
  export * from './dragAndDrop'
19
+ export * from './drawer'
19
20
  export * from './focusLock'
20
21
  export * from './footer'
21
22
  export * from './grid'
@@ -20,6 +20,7 @@ import { manager, useModalManager } from './modalManager'
20
20
  export const Modal = vui<'div', ModalProps>((props, ref) => {
21
21
  const {
22
22
  allowPinchZoom,
23
+ animation = 'fadeDown',
23
24
  children,
24
25
  className,
25
26
  contentProps,
@@ -103,7 +104,7 @@ export const Modal = vui<'div', ModalProps>((props, ref) => {
103
104
  isDisabled={disableTrapFocus}
104
105
  returnFocus={!disableReturnFocus}
105
106
  >
106
- <ModalContent animation="fadeDown" {...contentProps}>
107
+ <ModalContent animation={animation} {...contentProps}>
107
108
  {cloneElement(children, childProps)}
108
109
  </ModalContent>
109
110
  </FocusLock>
@@ -1,7 +1,7 @@
1
1
  import { ReactElement } from 'react'
2
2
 
3
3
  import { FocusableElement } from '../focusLock/focusLock.types'
4
- import { SystemProps } from '../system'
4
+ import { AnimationProp, SystemProps } from '../system'
5
5
  import { ThemingProps } from '../theme'
6
6
  import { MouseEvent } from '../utils'
7
7
 
@@ -15,6 +15,8 @@ export type ModalProps = SystemProps &
15
15
  ThemingProps<'Modal'> & {
16
16
  /** Handle zoom/pinch gestures on iOS devices when scroll locking is enabled. */
17
17
  allowPinchZoom?: boolean
18
+ /** The animation to use when the Modal is open. @default fadeDown */
19
+ animation?: AnimationProp
18
20
  /** A single child content element. */
19
21
  children: ReactElement
20
22
  /** Props passed to internal ModalContent component. */
@@ -13,6 +13,7 @@ import Definition from '../definition/theme'
13
13
  import Dialog from '../dialog/theme'
14
14
  import Divider from '../divider/theme'
15
15
  import DragAndDrop from '../dragAndDrop/theme'
16
+ import Drawer from '../drawer/theme'
16
17
  import Footer from '../footer/theme'
17
18
  import Grid from '../grid/theme'
18
19
  import Header from '../header/theme'
@@ -70,6 +71,7 @@ export default {
70
71
  Dialog,
71
72
  Divider,
72
73
  DragAndDrop,
74
+ Drawer,
73
75
  Footer,
74
76
  Grid,
75
77
  Header,
@@ -1,10 +1,13 @@
1
1
  export default {
2
+ none: 'none',
2
3
  bounce: 'vui-bounce 1s infinite',
3
4
  fadeDown: 'vui-fadeDown 0.2s ease-in-out',
4
5
  fadeIn: 'vui-fadeIn 0.2s ease-in-out',
5
6
  fadeLeft: 'vui-fadeLeft 0.2s ease-in-out',
7
+ fadeLeftLong: 'vui-fadeLeftLong 0.3s ease-out',
6
8
  fadeOut: 'vui-fadeOut 0.2s ease-in-out',
7
9
  fadeRight: 'vui-fadeRight 0.2s ease-in-out',
10
+ fadeRightLong: 'vui-fadeRightLong 0.3s ease-out',
8
11
  fadeUp: 'vui-fadeUp 0.2s ease-in-out',
9
12
  pulse: 'vui-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite',
10
13
  spin: 'vui-spin 1s linear infinite',