@onewelcome/react-lib-components 0.1.0-alpha → 0.1.3-alpha

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 (240) hide show
  1. package/README.md +16 -1
  2. package/dist/Breadcrumbs/Breadcrumbs.d.ts +3 -3
  3. package/dist/Button/BaseButton.d.ts +3 -4
  4. package/dist/Button/Button.d.ts +3 -4
  5. package/dist/Button/IconButton.d.ts +4 -5
  6. package/dist/ContextMenu/ContextMenu.d.ts +3 -3
  7. package/dist/Form/Checkbox/Checkbox.d.ts +5 -5
  8. package/dist/Form/Fieldset/Fieldset.d.ts +9 -7
  9. package/dist/Form/FormControl/FormControl.d.ts +6 -5
  10. package/dist/Form/FormGroup/FormGroup.d.ts +4 -4
  11. package/dist/Form/FormHelperText/FormHelperText.d.ts +4 -5
  12. package/dist/Form/FormSelectorWrapper/FormSelectorWrapper.d.ts +8 -12
  13. package/dist/Form/Input/Input.d.ts +7 -6
  14. package/dist/Form/Label/Label.d.ts +4 -5
  15. package/dist/Form/Radio/Radio.d.ts +5 -5
  16. package/dist/Form/Select/Option.d.ts +3 -4
  17. package/dist/Form/Select/Select.d.ts +4 -4
  18. package/dist/Form/Textarea/Textarea.d.ts +9 -5
  19. package/dist/Form/Toggle/Toggle.d.ts +3 -3
  20. package/dist/Form/Wrapper/CheckboxWrapper/CheckboxWrapper.d.ts +4 -3
  21. package/dist/Form/Wrapper/InputWrapper/InputWrapper.d.ts +5 -5
  22. package/dist/Form/Wrapper/RadioWrapper/RadioWrapper.d.ts +4 -4
  23. package/dist/Form/Wrapper/SelectWrapper/SelectWrapper.d.ts +8 -4
  24. package/dist/Form/Wrapper/TextareaWrapper/TextareaWrapper.d.ts +3 -3
  25. package/dist/Form/Wrapper/Wrapper/Wrapper.d.ts +6 -6
  26. package/dist/Form/form.interfaces.d.ts +4 -3
  27. package/dist/Icon/Icon.d.ts +4 -4
  28. package/dist/Link/Link.d.ts +3 -5
  29. package/dist/Notifications/BaseModal/BaseModal.d.ts +17 -0
  30. package/dist/Notifications/BaseModal/BaseModalActions/BaseModalActions.d.ts +5 -0
  31. package/dist/Notifications/BaseModal/BaseModalContent/BaseModalContent.d.ts +8 -0
  32. package/dist/{BaseModal → Notifications/BaseModal}/BaseModalContext.d.ts +0 -0
  33. package/dist/Notifications/BaseModal/BaseModalHeader/BaseModalHeader.d.ts +8 -0
  34. package/dist/Notifications/Dialog/Dialog.d.ts +19 -0
  35. package/dist/Notifications/Dialog/DialogActions/DialogActions.d.ts +6 -0
  36. package/dist/Notifications/Dialog/DialogTitle/DialogTitle.d.ts +6 -0
  37. package/dist/Notifications/DiscardChangesModal/DiscardChangesDialog/DiscardChangesDialog.d.ts +13 -0
  38. package/dist/Notifications/DiscardChangesModal/DiscardChangesModal.d.ts +13 -0
  39. package/dist/{Modal → Notifications/Modal}/Modal.d.ts +0 -0
  40. package/dist/{Modal → Notifications/Modal}/ModalActions/ModalActions.d.ts +0 -0
  41. package/dist/{Modal → Notifications/Modal}/ModalContent/ModalContent.d.ts +0 -0
  42. package/dist/{Modal → Notifications/Modal}/ModalHeader/ModalHeader.d.ts +0 -0
  43. package/dist/{Snackbar → Notifications/Snackbar}/SnackbarContainer/SnackbarContainer.d.ts +0 -0
  44. package/dist/{Snackbar → Notifications/Snackbar}/SnackbarItem/SnackbarItem.d.ts +0 -0
  45. package/dist/{Snackbar → Notifications/Snackbar}/SnackbarProvider/SnackbarProvider.d.ts +1 -1
  46. package/dist/{Snackbar → Notifications/Snackbar}/SnackbarProvider/SnackbarStateProvider.d.ts +0 -0
  47. package/dist/{Snackbar → Notifications/Snackbar}/interfaces.d.ts +0 -0
  48. package/dist/{Snackbar → Notifications/Snackbar}/useSnackbar.d.ts +0 -0
  49. package/dist/Pagination/Pagination.d.ts +19 -0
  50. package/dist/Popover/Popover.d.ts +3 -3
  51. package/dist/Tabs/Tab.d.ts +11 -0
  52. package/dist/Tabs/TabButton.d.ts +10 -0
  53. package/dist/Tabs/TabPanel.d.ts +8 -0
  54. package/dist/Tabs/Tabs.d.ts +9 -0
  55. package/dist/TextEllipsis/TextEllipsis.d.ts +6 -0
  56. package/dist/Tiles/Tile.d.ts +6 -7
  57. package/dist/Tiles/Tiles.d.ts +3 -3
  58. package/dist/Tooltip/Tooltip.d.ts +3 -3
  59. package/dist/Typography/Typography.d.ts +6 -4
  60. package/dist/Wizard/BaseWizardSteps/BaseWizardSteps.d.ts +3 -3
  61. package/dist/Wizard/WizardSteps/WizardSteps.d.ts +3 -3
  62. package/dist/_BaseStyling_/BaseStyling.d.ts +9 -0
  63. package/dist/hooks/useRepeater.d.ts +10 -0
  64. package/dist/hooks/useSpacing.d.ts +2 -2
  65. package/dist/hooks/useWrapper.d.ts +1 -1
  66. package/dist/index.d.ts +12 -7
  67. package/dist/interfaces.d.ts +2 -11
  68. package/dist/react-lib-components.cjs.development.js +1861 -1287
  69. package/dist/react-lib-components.cjs.development.js.map +1 -1
  70. package/dist/react-lib-components.cjs.production.min.js +1 -1
  71. package/dist/react-lib-components.cjs.production.min.js.map +1 -1
  72. package/dist/react-lib-components.esm.js +1858 -1289
  73. package/dist/react-lib-components.esm.js.map +1 -1
  74. package/dist/util/helper.d.ts +6 -1
  75. package/package.json +30 -24
  76. package/src/Breadcrumbs/Breadcrumbs.tsx +39 -37
  77. package/src/Button/BaseButton.test.tsx +65 -19
  78. package/src/Button/BaseButton.tsx +2 -3
  79. package/src/Button/Button.test.tsx +63 -17
  80. package/src/Button/Button.tsx +15 -4
  81. package/src/Button/IconButton.test.tsx +57 -22
  82. package/src/Button/IconButton.tsx +21 -12
  83. package/src/ContextMenu/ContextMenu.test.tsx +27 -1
  84. package/src/ContextMenu/ContextMenu.tsx +70 -65
  85. package/src/Form/Checkbox/Checkbox.module.scss +4 -0
  86. package/src/Form/Checkbox/Checkbox.test.tsx +28 -2
  87. package/src/Form/Checkbox/Checkbox.tsx +132 -117
  88. package/src/Form/Fieldset/Fieldset.module.scss +11 -1
  89. package/src/Form/Fieldset/Fieldset.test.tsx +30 -4
  90. package/src/Form/Fieldset/Fieldset.tsx +101 -43
  91. package/src/Form/FormControl/FormControl.test.tsx +27 -1
  92. package/src/Form/FormControl/FormControl.tsx +37 -37
  93. package/src/Form/FormGroup/FormGroup.test.tsx +27 -1
  94. package/src/Form/FormGroup/FormGroup.tsx +64 -58
  95. package/src/Form/FormHelperText/FormHelperText.test.tsx +27 -1
  96. package/src/Form/FormHelperText/FormHelperText.tsx +20 -16
  97. package/src/Form/FormSelectorWrapper/FormSelectorWrapper.test.tsx +78 -0
  98. package/src/Form/FormSelectorWrapper/FormSelectorWrapper.tsx +61 -55
  99. package/src/Form/Input/Input.module.scss +34 -15
  100. package/src/Form/Input/Input.test.tsx +27 -1
  101. package/src/Form/Input/Input.tsx +88 -47
  102. package/src/Form/Label/Label.test.tsx +27 -1
  103. package/src/Form/Label/Label.tsx +18 -14
  104. package/src/Form/Radio/Radio.module.scss +4 -0
  105. package/src/Form/Radio/Radio.test.tsx +28 -2
  106. package/src/Form/Radio/Radio.tsx +98 -80
  107. package/src/Form/Select/Option.test.tsx +27 -1
  108. package/src/Form/Select/Option.tsx +49 -42
  109. package/src/Form/Select/Select.module.scss +5 -1
  110. package/src/Form/Select/Select.test.tsx +224 -30
  111. package/src/Form/Select/Select.tsx +248 -182
  112. package/src/Form/Textarea/Textarea.module.scss +2 -1
  113. package/src/Form/Textarea/Textarea.test.tsx +28 -2
  114. package/src/Form/Textarea/Textarea.tsx +44 -29
  115. package/src/Form/Toggle/Toggle.module.scss +9 -0
  116. package/src/Form/Toggle/Toggle.test.tsx +27 -1
  117. package/src/Form/Toggle/Toggle.tsx +25 -12
  118. package/src/Form/Wrapper/CheckboxWrapper/CheckboxWrapper.test.tsx +28 -2
  119. package/src/Form/Wrapper/CheckboxWrapper/CheckboxWrapper.tsx +45 -48
  120. package/src/Form/Wrapper/InputWrapper/InputWrapper.module.scss +17 -1
  121. package/src/Form/Wrapper/InputWrapper/InputWrapper.test.tsx +89 -1
  122. package/src/Form/Wrapper/InputWrapper/InputWrapper.tsx +134 -74
  123. package/src/Form/Wrapper/RadioWrapper/RadioWrapper.test.tsx +1 -1
  124. package/src/Form/Wrapper/RadioWrapper/RadioWrapper.tsx +64 -59
  125. package/src/Form/Wrapper/SelectWrapper/SelectWrapper.module.scss +1 -1
  126. package/src/Form/Wrapper/SelectWrapper/SelectWrapper.test.tsx +43 -1
  127. package/src/Form/Wrapper/SelectWrapper/SelectWrapper.tsx +55 -44
  128. package/src/Form/Wrapper/TextareaWrapper/TextareaWrapper.module.scss +5 -7
  129. package/src/Form/Wrapper/TextareaWrapper/TextareaWrapper.test.tsx +43 -1
  130. package/src/Form/Wrapper/TextareaWrapper/TextareaWrapper.tsx +100 -85
  131. package/src/Form/Wrapper/Wrapper/Wrapper.module.scss +1 -1
  132. package/src/Form/Wrapper/Wrapper/Wrapper.test.tsx +27 -1
  133. package/src/Form/Wrapper/Wrapper/Wrapper.tsx +76 -71
  134. package/src/Form/form.interfaces.ts +4 -3
  135. package/src/Icon/Icon.module.scss +4 -0
  136. package/src/Icon/Icon.test.tsx +30 -2
  137. package/src/Icon/Icon.tsx +5 -5
  138. package/src/Link/Link.test.tsx +27 -1
  139. package/src/Link/Link.tsx +4 -6
  140. package/src/{BaseModal → Notifications/BaseModal}/BaseModal.module.scss +0 -0
  141. package/src/{BaseModal → Notifications/BaseModal}/BaseModal.test.tsx +35 -16
  142. package/src/Notifications/BaseModal/BaseModal.tsx +105 -0
  143. package/src/{BaseModal → Notifications/BaseModal}/BaseModalActions/BaseModalActions.module.scss +0 -0
  144. package/src/Notifications/BaseModal/BaseModalActions/BaseModalActions.test.tsx +42 -0
  145. package/src/Notifications/BaseModal/BaseModalActions/BaseModalActions.tsx +16 -0
  146. package/src/{BaseModal → Notifications/BaseModal}/BaseModalContent/BaseModalContent.module.scss +0 -0
  147. package/src/{BaseModal → Notifications/BaseModal}/BaseModalContent/BaseModalContent.test.tsx +27 -1
  148. package/src/Notifications/BaseModal/BaseModalContent/BaseModalContent.tsx +36 -0
  149. package/src/{BaseModal → Notifications/BaseModal}/BaseModalContext.ts +0 -0
  150. package/src/{BaseModal → Notifications/BaseModal}/BaseModalHeader/BaseModalHeader.module.scss +0 -0
  151. package/src/{BaseModal → Notifications/BaseModal}/BaseModalHeader/BaseModalHeader.test.tsx +29 -1
  152. package/src/Notifications/BaseModal/BaseModalHeader/BaseModalHeader.tsx +30 -0
  153. package/src/{Dialog → Notifications/Dialog}/Dialog.module.scss +0 -0
  154. package/src/{Dialog → Notifications/Dialog}/Dialog.test.tsx +52 -17
  155. package/src/Notifications/Dialog/Dialog.tsx +113 -0
  156. package/src/{Dialog → Notifications/Dialog}/DialogActions/DialogActions.module.scss +0 -0
  157. package/src/Notifications/Dialog/DialogActions/DialogActions.test.tsx +51 -0
  158. package/src/Notifications/Dialog/DialogActions/DialogActions.tsx +24 -0
  159. package/src/{Dialog → Notifications/Dialog}/DialogTitle/DialogTitle.module.scss +0 -0
  160. package/src/Notifications/Dialog/DialogTitle/DialogTitle.test.tsx +44 -0
  161. package/src/Notifications/Dialog/DialogTitle/DialogTitle.tsx +20 -0
  162. package/src/Notifications/DiscardChangesModal/DiscardChangesDialog/DiscardChangesDialog.test.tsx +95 -0
  163. package/src/Notifications/DiscardChangesModal/DiscardChangesDialog/DiscardChangesDialog.tsx +55 -0
  164. package/src/Notifications/DiscardChangesModal/DiscardChangesModal.test.tsx +162 -0
  165. package/src/Notifications/DiscardChangesModal/DiscardChangesModal.tsx +61 -0
  166. package/src/{Modal → Notifications/Modal}/Modal.test.tsx +0 -0
  167. package/src/{Modal → Notifications/Modal}/Modal.tsx +0 -0
  168. package/src/{Modal → Notifications/Modal}/ModalActions/ModalActions.tsx +0 -0
  169. package/src/{Modal → Notifications/Modal}/ModalContent/ModalContent.tsx +0 -0
  170. package/src/{Modal → Notifications/Modal}/ModalHeader/ModalHeader.tsx +0 -0
  171. package/src/{Snackbar → Notifications/Snackbar}/SnackbarContainer/SnackbarContainer.module.scss +0 -0
  172. package/src/{Snackbar → Notifications/Snackbar}/SnackbarContainer/SnackbarContainer.test.tsx +0 -0
  173. package/src/{Snackbar → Notifications/Snackbar}/SnackbarContainer/SnackbarContainer.tsx +0 -0
  174. package/src/{Snackbar → Notifications/Snackbar}/SnackbarItem/SnackbarItem.module.scss +1 -1
  175. package/src/{Snackbar → Notifications/Snackbar}/SnackbarItem/SnackbarItem.test.tsx +0 -0
  176. package/src/{Snackbar → Notifications/Snackbar}/SnackbarItem/SnackbarItem.tsx +6 -7
  177. package/src/{Snackbar → Notifications/Snackbar}/SnackbarProvider/SnackbarProvider.test.tsx +0 -0
  178. package/src/{Snackbar → Notifications/Snackbar}/SnackbarProvider/SnackbarProvider.tsx +2 -2
  179. package/src/{Snackbar → Notifications/Snackbar}/SnackbarProvider/SnackbarStateProvider.tsx +0 -0
  180. package/src/{Snackbar → Notifications/Snackbar}/interfaces.ts +0 -0
  181. package/src/{Snackbar → Notifications/Snackbar}/useSnackbar.ts +0 -0
  182. package/src/Pagination/Pagination.module.scss +120 -0
  183. package/src/Pagination/Pagination.test.tsx +176 -0
  184. package/src/Pagination/Pagination.tsx +205 -0
  185. package/src/Popover/Popover.test.tsx +3 -3
  186. package/src/Popover/Popover.tsx +3 -3
  187. package/src/Tabs/Tab.test.tsx +71 -0
  188. package/src/Tabs/Tab.tsx +17 -0
  189. package/src/Tabs/TabButton.module.scss +36 -0
  190. package/src/Tabs/TabButton.test.tsx +77 -0
  191. package/src/Tabs/TabButton.tsx +58 -0
  192. package/src/Tabs/TabPanel.module.scss +7 -0
  193. package/src/Tabs/TabPanel.test.tsx +76 -0
  194. package/src/Tabs/TabPanel.tsx +27 -0
  195. package/src/Tabs/Tabs.module.scss +41 -0
  196. package/src/Tabs/Tabs.test.tsx +268 -0
  197. package/src/Tabs/Tabs.tsx +149 -0
  198. package/src/TextEllipsis/TextEllipsis.module.scss +18 -0
  199. package/src/TextEllipsis/TextEllipsis.test.tsx +80 -0
  200. package/src/TextEllipsis/TextEllipsis.tsx +55 -0
  201. package/src/Tiles/Tile.module.scss +1 -1
  202. package/src/Tiles/Tile.test.tsx +48 -12
  203. package/src/Tiles/Tile.tsx +68 -34
  204. package/src/Tiles/Tiles.test.tsx +38 -10
  205. package/src/Tiles/Tiles.tsx +42 -39
  206. package/src/Tooltip/Tooltip.test.tsx +27 -1
  207. package/src/Tooltip/Tooltip.tsx +104 -92
  208. package/src/Typography/Typography.test.tsx +27 -1
  209. package/src/Typography/Typography.tsx +66 -68
  210. package/src/Wizard/BaseWizardSteps/BaseWizardSteps.tsx +67 -62
  211. package/src/Wizard/Wizard.tsx +2 -2
  212. package/src/Wizard/WizardActions/WizardActions.tsx +3 -3
  213. package/src/Wizard/WizardSteps/WizardSteps.tsx +24 -21
  214. package/src/_BaseStyling_/BaseStyling.tsx +19 -1
  215. package/src/hooks/usePosition.test.tsx +3 -3
  216. package/src/hooks/useRepeater.test.tsx +139 -0
  217. package/src/hooks/useRepeater.ts +34 -0
  218. package/src/hooks/useSpacing.ts +1 -1
  219. package/src/hooks/useWrapper.ts +7 -2
  220. package/src/index.ts +20 -8
  221. package/src/interfaces.ts +2 -12
  222. package/src/util/helper.test.tsx +38 -1
  223. package/src/util/helper.tsx +21 -0
  224. package/dist/BaseModal/BaseModal.d.ts +0 -16
  225. package/dist/BaseModal/BaseModalActions/BaseModalActions.d.ts +0 -5
  226. package/dist/BaseModal/BaseModalContent/BaseModalContent.d.ts +0 -8
  227. package/dist/BaseModal/BaseModalHeader/BaseModalHeader.d.ts +0 -8
  228. package/dist/Dialog/Dialog.d.ts +0 -18
  229. package/dist/Dialog/DialogActions/DialogActions.d.ts +0 -6
  230. package/dist/Dialog/DialogTitle/DialogTitle.d.ts +0 -6
  231. package/src/BaseModal/BaseModal.tsx +0 -113
  232. package/src/BaseModal/BaseModalActions/BaseModalActions.test.tsx +0 -17
  233. package/src/BaseModal/BaseModalActions/BaseModalActions.tsx +0 -14
  234. package/src/BaseModal/BaseModalContent/BaseModalContent.tsx +0 -35
  235. package/src/BaseModal/BaseModalHeader/BaseModalHeader.tsx +0 -28
  236. package/src/Dialog/Dialog.tsx +0 -96
  237. package/src/Dialog/DialogActions/DialogActions.test.tsx +0 -25
  238. package/src/Dialog/DialogActions/DialogActions.tsx +0 -21
  239. package/src/Dialog/DialogTitle/DialogTitle.test.tsx +0 -18
  240. package/src/Dialog/DialogTitle/DialogTitle.tsx +0 -18
@@ -1,11 +1,11 @@
1
- import React, { ReactElement } from 'react';
1
+ import React, { ComponentPropsWithRef, ReactElement } from 'react';
2
2
  import { FormGroup, Props as FormGroupProps } from '../../FormGroup/FormGroup';
3
3
  import { Label, Props as LabelProps } from '../../Label/Label';
4
4
  import classes from './Wrapper.module.scss';
5
5
  import { Props as HelperProps } from '../../FormHelperText/FormHelperText';
6
- import { HTMLProps } from '../../../interfaces';
6
+ import { FormElement } from '../../form.interfaces';
7
7
 
8
- export interface Props extends Omit<FormGroupProps, 'children'> {
8
+ export interface Props extends ComponentPropsWithRef<'div'>, FormGroupProps {
9
9
  children: ReactElement | ReactElement[];
10
10
  floatingLabelActive?: boolean;
11
11
  floatingLabel?: boolean;
@@ -19,83 +19,88 @@ export interface Props extends Omit<FormGroupProps, 'children'> {
19
19
  }
20
20
 
21
21
  /** For components that extend this component we create an interface (InputWrapper, SelectWrapper, etc.) */
22
- export interface WrapperProps extends HTMLProps<HTMLDivElement> {
22
+ export interface WrapperProps extends FormElement {
23
23
  errorMessage?: string;
24
- error: boolean;
25
24
  helperText?: string;
26
25
  helperProps?: HelperProps;
27
26
  label?: string;
28
27
  name: string;
29
28
  required?: boolean;
29
+ disabled?: boolean;
30
30
  }
31
31
 
32
- export const Wrapper = ({
33
- children,
34
- className,
35
- error,
36
- errorMessage,
37
- errorId,
38
- errorMessageIcon,
39
- errorMessageIconPosition,
40
- helperText,
41
- helperId,
42
- floatingLabel = true,
43
- floatingLabelActive,
44
- required,
45
- helperProps,
46
- helperIndent,
47
- labelProps,
48
- label,
49
- disabled,
50
- name,
51
- innerClassName,
52
- ...rest
53
- }: Props) => {
54
- const renderChildren = () =>
55
- React.Children.map(children, (child) =>
56
- React.cloneElement(child, {
57
- disabled,
58
- })
59
- );
32
+ export const Wrapper = React.forwardRef<HTMLDivElement, Props>(
33
+ (
34
+ {
35
+ children,
36
+ className,
37
+ error,
38
+ errorMessage,
39
+ errorId,
40
+ errorMessageIcon,
41
+ errorMessageIconPosition,
42
+ helperText,
43
+ helperId,
44
+ floatingLabel = true,
45
+ floatingLabelActive,
46
+ required,
47
+ helperProps,
48
+ helperIndent,
49
+ labelProps,
50
+ label,
51
+ disabled,
52
+ name,
53
+ innerClassName,
54
+ ...rest
55
+ }: Props,
56
+ ref
57
+ ) => {
58
+ const renderChildren = () =>
59
+ React.Children.map(children, (child) =>
60
+ React.cloneElement(child, {
61
+ disabled,
62
+ })
63
+ );
60
64
 
61
- const labelClasses = [];
65
+ const labelClasses = [];
62
66
 
63
- floatingLabel && labelClasses.push(classes['floating-label']);
64
- floatingLabel && floatingLabelActive && labelClasses.push(classes['floating-label-active']);
65
- labelProps?.className && labelClasses.push(labelProps.className);
66
- required && labelClasses.push(classes['required']);
67
- error && labelClasses.push(classes['error']);
67
+ floatingLabel && labelClasses.push(classes['floating-label']);
68
+ floatingLabel && floatingLabelActive && labelClasses.push(classes['floating-label-active']);
69
+ labelProps?.className && labelClasses.push(labelProps.className);
70
+ required && labelClasses.push(classes['required']);
71
+ error && labelClasses.push(classes['error']);
68
72
 
69
- return (
70
- <div {...rest} className={`${classes.wrapper} ${className ? className : ''}`}>
71
- <FormGroup
72
- error={error}
73
- errorMessage={errorMessage}
74
- errorId={errorId}
75
- errorMessageIcon={errorMessageIcon}
76
- errorMessageIconPosition={errorMessageIconPosition}
77
- helperText={helperText}
78
- helperId={helperId}
79
- helperProps={helperProps}
80
- helperIndent={helperIndent}
81
- >
82
- <div
83
- className={`${floatingLabel ? classes['floating-wrapper'] : ''} ${
84
- innerClassName ? innerClassName : ''
85
- }`}
73
+ return (
74
+ <div {...rest} ref={ref} className={`${classes.wrapper} ${className ? className : ''}`}>
75
+ <FormGroup
76
+ error={error}
77
+ errorMessage={errorMessage}
78
+ errorId={errorId}
79
+ errorMessageIcon={errorMessageIcon}
80
+ errorMessageIconPosition={errorMessageIconPosition}
81
+ helperText={helperText}
82
+ helperId={helperId}
83
+ helperProps={helperProps}
84
+ helperIndent={helperIndent}
86
85
  >
87
- {label && (
88
- <Label
89
- {...labelProps}
90
- className={`${classes.label} ${labelClasses.join(' ')}`}
91
- htmlFor={name}
92
- >
93
- {label}
94
- </Label>
95
- )}
96
- {renderChildren()}
97
- </div>
98
- </FormGroup>
99
- </div>
100
- );
101
- };
86
+ <div
87
+ className={`${floatingLabel ? classes['floating-wrapper'] : ''} ${
88
+ innerClassName ? innerClassName : ''
89
+ }`}
90
+ >
91
+ {label && (
92
+ <Label
93
+ {...labelProps}
94
+ className={`${classes.label} ${labelClasses.join(' ')}`}
95
+ htmlFor={name}
96
+ >
97
+ {label}
98
+ </Label>
99
+ )}
100
+ {renderChildren()}
101
+ </div>
102
+ </FormGroup>
103
+ </div>
104
+ );
105
+ }
106
+ );
@@ -1,7 +1,7 @@
1
- import { HTMLProps } from '../interfaces';
1
+ import { DataAttributeKey } from '../interfaces';
2
2
 
3
3
  /** Radios */
4
- export interface FormSelector<T> extends FormElement<T> {
4
+ export interface FormSelector extends FormElement {
5
5
  helperText?: string;
6
6
  errorMessage?: string;
7
7
  parentHelperId?: string;
@@ -9,6 +9,7 @@ export interface FormSelector<T> extends FormElement<T> {
9
9
  }
10
10
 
11
11
  /** Default form elements */
12
- export interface FormElement<T> extends HTMLProps<T> {
12
+ export interface FormElement {
13
13
  error?: boolean;
14
+ [dataAttribute: DataAttributeKey]: any;
14
15
  }
@@ -272,6 +272,10 @@
272
272
  content: '\e93c';
273
273
  @include fontProperties();
274
274
  }
275
+ .icon-error-circle:before {
276
+ content: '\e93d';
277
+ @include fontProperties();
278
+ }
275
279
  .icon-circle:before {
276
280
  content: '\e93e';
277
281
  @include fontProperties();
@@ -1,8 +1,10 @@
1
- import React from 'react';
1
+ import React, { useEffect, useRef } from 'react';
2
2
  import { Icon, Props, Icons } from './Icon';
3
3
  import { render } from '@testing-library/react';
4
4
 
5
- const initParams: Props = {
5
+ interface PartialProps extends Omit<Props, 'ref'> {}
6
+
7
+ const initParams: PartialProps = {
6
8
  icon: Icons.Calendar,
7
9
  color: 'rgb(26, 153, 60)',
8
10
  };
@@ -37,3 +39,29 @@ describe('Icon', () => {
37
39
  expect(icon.tagName.toLowerCase()).toBe(tag);
38
40
  });
39
41
  });
42
+
43
+ describe('ref should work', () => {
44
+ it('should give back the proper data prop, this also checks if the component propagates ...rest properly', () => {
45
+ const ExampleComponent = ({
46
+ propagateRef,
47
+ }: {
48
+ propagateRef?: (ref: React.RefObject<HTMLElement>) => void;
49
+ }) => {
50
+ const ref = useRef(null);
51
+
52
+ useEffect(() => {
53
+ if (ref.current) {
54
+ propagateRef && propagateRef(ref);
55
+ }
56
+ }, [ref]);
57
+
58
+ return <Icon {...initParams} data-ref="testing" ref={ref} />;
59
+ };
60
+
61
+ const refCheck = (ref: React.RefObject<HTMLElement>) => {
62
+ expect(ref.current).toHaveAttribute('data-ref', 'testing');
63
+ };
64
+
65
+ render(<ExampleComponent propagateRef={refCheck} />);
66
+ });
67
+ });
package/src/Icon/Icon.tsx CHANGED
@@ -1,6 +1,5 @@
1
- import React from 'react';
1
+ import React, { ComponentPropsWithRef } from 'react';
2
2
  import classes from './Icon.module.scss';
3
- import { HTMLAttributes } from '../interfaces';
4
3
 
5
4
  export enum Icons {
6
5
  Bell = 'bell',
@@ -26,6 +25,7 @@ export enum Icons {
26
25
  Ellipsis = 'ellipsis',
27
26
  EllipsisAlt = 'ellipsis-alt',
28
27
  Equal = 'equal',
28
+ Error = 'error-circle',
29
29
  Eye = 'eye',
30
30
  Filter = 'filter',
31
31
  FilterAlt = 'filter-alt',
@@ -69,21 +69,21 @@ export enum Icons {
69
69
 
70
70
  type Tag = 'span' | 'div' | 'i';
71
71
 
72
- export interface Props extends Omit<HTMLAttributes<HTMLOrSVGElement>, 'size'> {
72
+ export interface Props extends ComponentPropsWithRef<'div'> {
73
73
  icon: Icons;
74
74
  color?: string;
75
75
  size?: string;
76
76
  tag?: Tag;
77
77
  }
78
78
 
79
- export const Icon = React.forwardRef(
79
+ export const Icon = React.forwardRef<HTMLDivElement, Props>(
80
80
  ({ icon, color, className, style, size, tag = 'span', ...rest }: Props, ref) => {
81
81
  const Component = tag;
82
82
 
83
83
  return (
84
84
  <Component
85
85
  {...rest}
86
- ref={ref as React.LegacyRef<HTMLDivElement>}
86
+ ref={ref}
87
87
  style={{ color: color, ...style, fontSize: size }}
88
88
  data-icon
89
89
  aria-hidden="true"
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { useEffect, useRef } from 'react';
2
2
  import { Link, Props } from './Link';
3
3
  import { render } from '@testing-library/react';
4
4
  import { BrowserRouter, Link as RouterLink } from 'react-router-dom';
@@ -101,6 +101,32 @@ describe('Link should render', () => {
101
101
  });
102
102
  });
103
103
 
104
+ describe('ref should work', () => {
105
+ it('should give back the proper data prop, this also checks if the component propagates ...rest properly', () => {
106
+ const ExampleComponent = ({
107
+ propagateRef,
108
+ }: {
109
+ propagateRef?: (ref: React.RefObject<HTMLElement>) => void;
110
+ }) => {
111
+ const ref = useRef(null);
112
+
113
+ useEffect(() => {
114
+ if (ref.current) {
115
+ propagateRef && propagateRef(ref);
116
+ }
117
+ }, [ref]);
118
+
119
+ return <Link {...defaultParams} data-ref="testing" ref={ref} />;
120
+ };
121
+
122
+ const refCheck = (ref: React.RefObject<HTMLElement>) => {
123
+ expect(ref.current).toHaveAttribute('data-ref', 'testing');
124
+ };
125
+
126
+ render(<ExampleComponent propagateRef={refCheck} />);
127
+ });
128
+ });
129
+
104
130
  describe('colors', () => {
105
131
  it('should be color primary', () => {
106
132
  const { link } = createLink((defaultParams) => ({ ...defaultParams, color: 'primary' }));
package/src/Link/Link.tsx CHANGED
@@ -1,21 +1,19 @@
1
- import React, { ForwardRefExoticComponent, Ref, RefAttributes } from 'react';
2
- import { HTMLProps } from '../interfaces';
1
+ import React, { ComponentPropsWithRef, ForwardRefExoticComponent, RefAttributes } from 'react';
3
2
  import classes from './Link.module.scss';
4
3
  import { LinkProps } from './types';
5
4
 
6
5
  type AnchorType = 'external' | 'internal' | 'download';
7
6
 
8
- export interface Props extends HTMLProps<HTMLAnchorElement> {
7
+ export interface Props extends ComponentPropsWithRef<'a'> {
9
8
  children?: string;
10
9
  color?: 'primary' | 'secondary' | 'tertiary';
11
10
  type?: AnchorType;
12
11
  to: string;
13
12
  disabled?: boolean;
14
13
  component?: ForwardRefExoticComponent<LinkProps & RefAttributes<HTMLAnchorElement>>;
15
- ref?: Ref<HTMLAnchorElement>;
16
14
  }
17
15
 
18
- export const Link = React.forwardRef(
16
+ export const Link = React.forwardRef<HTMLAnchorElement, Props>(
19
17
  (
20
18
  {
21
19
  children,
@@ -27,7 +25,7 @@ export const Link = React.forwardRef(
27
25
  component,
28
26
  ...rest
29
27
  }: Props,
30
- ref: Ref<HTMLAnchorElement>
28
+ ref
31
29
  ) => {
32
30
  const determineTarget = () => {
33
31
  if (rest.target) {
@@ -1,13 +1,6 @@
1
- import React from 'react';
1
+ import React, { useEffect, useRef } from 'react';
2
2
  import { BaseModal, Props } from './BaseModal';
3
- import {
4
- render,
5
- getByRole,
6
- getByText,
7
- queryByText,
8
- queryByRole,
9
- fireEvent,
10
- } from '@testing-library/react';
3
+ import { render, getByText, queryByText, fireEvent } from '@testing-library/react';
11
4
  import userEvent from '@testing-library/user-event';
12
5
 
13
6
  const classNames = ['class11', 'class12'];
@@ -24,8 +17,8 @@ const initParams: Props = {
24
17
 
25
18
  describe('BaseModal', () => {
26
19
  it('renders without crashing', () => {
27
- const { container } = render(<BaseModal {...initParams} />);
28
- const dialog = getByRole(container, 'dialog');
20
+ const { getByRole } = render(<BaseModal {...initParams} />);
21
+ const dialog = getByRole('dialog');
29
22
  expect(dialog).toHaveAttribute('aria-modal', 'true');
30
23
  expect(dialog).toHaveAttribute('aria-labelledby', 'modal-label');
31
24
  expect(dialog).toHaveAttribute('aria-describedby', 'modal-description');
@@ -36,17 +29,17 @@ describe('BaseModal', () => {
36
29
  });
37
30
 
38
31
  it('should render close modal without content', () => {
39
- const { container } = render(<BaseModal {...initParams} open={false} />);
40
- const dialogByRole = queryByRole(container, 'dialog');
41
- const dialog = container.children[0] as HTMLElement;
32
+ const { queryByRole } = render(<BaseModal {...initParams} open={false} />);
33
+ const dialogByRole = queryByRole('dialog');
34
+ const dialog = document.body.children[1] as HTMLElement;
42
35
  expect(dialogByRole).toBeNull();
43
36
  expect(dialog).toHaveAttribute('aria-hidden', 'true');
44
37
  expect(queryByText(dialog, initParams.children as string)).toBeNull();
45
38
  });
46
39
 
47
40
  it('should handle clicking on backdrop & ESC key', () => {
48
- const { container } = render(<BaseModal {...initParams} />);
49
- const modal = getByRole(container, 'dialog');
41
+ const { getByRole } = render(<BaseModal {...initParams} />);
42
+ const modal = getByRole('dialog');
50
43
  const backdrop = modal.querySelector('.backdrop') as HTMLElement;
51
44
  expect(initParams.onClose).toHaveBeenCalledTimes(0);
52
45
 
@@ -57,3 +50,29 @@ describe('BaseModal', () => {
57
50
  expect(initParams.onClose).toHaveBeenCalledTimes(2);
58
51
  });
59
52
  });
53
+
54
+ describe('ref should work', () => {
55
+ it('should give back the proper data prop, this also checks if the component propagates ...rest properly', () => {
56
+ const ExampleComponent = ({
57
+ propagateRef,
58
+ }: {
59
+ propagateRef?: (ref: React.RefObject<HTMLElement>) => void;
60
+ }) => {
61
+ const ref = useRef(null);
62
+
63
+ useEffect(() => {
64
+ if (ref.current) {
65
+ propagateRef && propagateRef(ref);
66
+ }
67
+ }, [ref]);
68
+
69
+ return <BaseModal id="test" children="test" open={true} data-ref="testing" ref={ref} />;
70
+ };
71
+
72
+ const refCheck = (ref: React.RefObject<HTMLElement>) => {
73
+ expect(ref.current).toHaveAttribute('data-ref', 'testing');
74
+ };
75
+
76
+ render(<ExampleComponent propagateRef={refCheck} />);
77
+ });
78
+ });
@@ -0,0 +1,105 @@
1
+ import React, { ComponentPropsWithRef, useEffect } from 'react';
2
+ import { createPortal } from 'react-dom';
3
+ import classes from './BaseModal.module.scss';
4
+ import { labelId, descriptionId } from './BaseModalContext';
5
+
6
+ const SCROLL_PROPERTY_NAME = 'overflow';
7
+ const SCROLL_PROPERTY_VALUE = 'hidden';
8
+
9
+ export interface Props extends ComponentPropsWithRef<'div'> {
10
+ id: string;
11
+ children: React.ReactNode;
12
+ open: boolean;
13
+ onClose?: (event?: React.MouseEvent<HTMLElement>) => unknown;
14
+ className?: string;
15
+ containerClassName?: string;
16
+ labelledby?: string;
17
+ describedby?: string;
18
+ disableEscapeKeyDown?: boolean;
19
+ disableBackdrop?: boolean;
20
+ zIndex?: number;
21
+ domRoot?: HTMLElement;
22
+ }
23
+
24
+ export const useSetBodyScroll = (open: boolean) => {
25
+ const hideBodyScroll = () => {
26
+ document.body.style[SCROLL_PROPERTY_NAME] = SCROLL_PROPERTY_VALUE;
27
+ };
28
+
29
+ const showBodyScroll = () => {
30
+ const allModalsClosed =
31
+ document.querySelectorAll('[role=dialog][data-hidden=false]').length === 0;
32
+ if (allModalsClosed) {
33
+ document.body.style.removeProperty(SCROLL_PROPERTY_NAME);
34
+ }
35
+ };
36
+
37
+ useEffect(() => {
38
+ if (open) {
39
+ hideBodyScroll();
40
+ } else {
41
+ showBodyScroll();
42
+ }
43
+ }, [open]);
44
+ };
45
+
46
+ export const BaseModal = React.forwardRef<HTMLDivElement, Props>(
47
+ (
48
+ {
49
+ id,
50
+ children,
51
+ open,
52
+ onClose,
53
+ className = '',
54
+ containerClassName = '',
55
+ labelledby,
56
+ describedby,
57
+ disableEscapeKeyDown = false,
58
+ disableBackdrop = false,
59
+ zIndex,
60
+ domRoot = document.body,
61
+ ...rest
62
+ }: Props,
63
+ ref
64
+ ) => {
65
+ useSetBodyScroll(open);
66
+
67
+ const handleEscKeyPress = (event: React.KeyboardEvent<HTMLDivElement>) => {
68
+ if (!disableEscapeKeyDown && event.key === 'Escape') {
69
+ event.stopPropagation();
70
+ onClose && onClose();
71
+ }
72
+ };
73
+
74
+ const handleBackdropClick = () => !disableBackdrop && onClose && onClose();
75
+
76
+ return createPortal(
77
+ <div
78
+ {...rest}
79
+ ref={ref}
80
+ id={id}
81
+ className={`${classes['modal']} ${open && classes['visible']} ${className}`}
82
+ role="dialog"
83
+ aria-modal="true"
84
+ aria-labelledby={labelledby || labelId(id)}
85
+ aria-describedby={describedby || descriptionId(id)}
86
+ aria-hidden={!open}
87
+ tabIndex={-1}
88
+ data-hidden={!open}
89
+ onKeyDown={handleEscKeyPress}
90
+ style={{ zIndex }}
91
+ >
92
+ <div className={classes['backdrop']} onClick={handleBackdropClick}></div>
93
+ {open && (
94
+ <div
95
+ style={{ zIndex: zIndex && zIndex + 1 }}
96
+ className={`${classes['container']} ${containerClassName}`}
97
+ >
98
+ {children}
99
+ </div>
100
+ )}
101
+ </div>,
102
+ domRoot
103
+ );
104
+ }
105
+ );
@@ -0,0 +1,42 @@
1
+ import React, { useEffect, useRef } from 'react';
2
+ import { BaseModalActions } from './BaseModalActions';
3
+ import { render } from '@testing-library/react';
4
+
5
+ describe('BaseModalActions', () => {
6
+ it('renders without crashing', () => {
7
+ const children = 'Content';
8
+ const classNames = ['class1', 'class2'];
9
+ const { container } = render(
10
+ <BaseModalActions className={classNames.join(' ')}>{children}</BaseModalActions>
11
+ );
12
+
13
+ const dialogActionsContainer = container.children[0];
14
+ expect(dialogActionsContainer).toHaveClass('actions', classNames[0], classNames[1]);
15
+ expect(dialogActionsContainer).toHaveTextContent(children);
16
+ });
17
+ });
18
+ describe('ref should work', () => {
19
+ it('should give back the proper data prop, this also checks if the component propagates ...rest properly', () => {
20
+ const ExampleComponent = ({
21
+ propagateRef,
22
+ }: {
23
+ propagateRef?: (ref: React.RefObject<HTMLElement>) => void;
24
+ }) => {
25
+ const ref = useRef(null);
26
+
27
+ useEffect(() => {
28
+ if (ref.current) {
29
+ propagateRef && propagateRef(ref);
30
+ }
31
+ }, [ref]);
32
+
33
+ return <BaseModalActions data-ref="testing" ref={ref} />;
34
+ };
35
+
36
+ const refCheck = (ref: React.RefObject<HTMLElement>) => {
37
+ expect(ref.current).toHaveAttribute('data-ref', 'testing');
38
+ };
39
+
40
+ render(<ExampleComponent propagateRef={refCheck} />);
41
+ });
42
+ });
@@ -0,0 +1,16 @@
1
+ import React, { ComponentPropsWithRef } from 'react';
2
+ import classes from './BaseModalActions.module.scss';
3
+
4
+ export interface Props extends ComponentPropsWithRef<'footer'> {
5
+ children?: React.ReactNode;
6
+ }
7
+
8
+ export const BaseModalActions = React.forwardRef<HTMLElement, Props>(
9
+ ({ children, className = '', ...rest }: Props, ref) => {
10
+ return (
11
+ <footer {...rest} ref={ref} className={`${classes['actions']} ${className}`}>
12
+ {children}
13
+ </footer>
14
+ );
15
+ }
16
+ );
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { useEffect, useRef } from 'react';
2
2
  import { BaseModalContent, Props } from './BaseModalContent';
3
3
  import { render } from '@testing-library/react';
4
4
  import { descriptionId } from '../BaseModalContext';
@@ -20,6 +20,32 @@ describe('BaseModalContent', () => {
20
20
  expect(dialogContentContainer).toEqual(document.activeElement);
21
21
  });
22
22
 
23
+ describe('ref should work', () => {
24
+ it('should give back the proper data prop, this also checks if the component propagates ...rest properly', () => {
25
+ const ExampleComponent = ({
26
+ propagateRef,
27
+ }: {
28
+ propagateRef?: (ref: React.RefObject<HTMLElement>) => void;
29
+ }) => {
30
+ const ref = useRef(null);
31
+
32
+ useEffect(() => {
33
+ if (ref.current) {
34
+ propagateRef && propagateRef(ref);
35
+ }
36
+ }, [ref]);
37
+
38
+ return <BaseModalContent children="test" data-ref="testing" ref={ref} />;
39
+ };
40
+
41
+ const refCheck = (ref: React.RefObject<HTMLElement>) => {
42
+ expect(ref.current).toHaveAttribute('data-ref', 'testing');
43
+ };
44
+
45
+ render(<ExampleComponent propagateRef={refCheck} />);
46
+ });
47
+ });
48
+
23
49
  it('should renders not focused div', () => {
24
50
  const { container } = render(<BaseModalContent {...initParams} disableAutoFocus />);
25
51