@onewelcome/react-lib-components 0.1.3-alpha → 0.1.4-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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onewelcome/react-lib-components",
3
- "version": "0.1.3-alpha",
3
+ "version": "0.1.4-alpha",
4
4
  "license": "Apache-2.0",
5
5
  "author": "OneWelcome B.V.",
6
6
  "main": "dist/index.js",
@@ -85,3 +85,27 @@ describe('Correct error state', () => {
85
85
  expect(errorMessage?.querySelector('#error_id')).toHaveTextContent('example error message');
86
86
  });
87
87
  });
88
+
89
+ describe('no helpertext, but errorMessage is defined', () => {
90
+ it("doesn't show the div with 'default-helper' class when there's no error and no helpertext defined", () => {
91
+ const { formgroup } = createFormGroup((defaultParams) => ({
92
+ ...defaultParams,
93
+ error: false,
94
+ helperText: undefined,
95
+ errorMessage: 'example error message',
96
+ }));
97
+
98
+ expect(formgroup.querySelector('.default-helper')).toBeFalsy();
99
+ });
100
+
101
+ it("does show the div with 'default-helper' class when there's an error and no helpertext defined", () => {
102
+ const { formgroup } = createFormGroup((defaultParams) => ({
103
+ ...defaultParams,
104
+ error: true,
105
+ helperText: undefined,
106
+ errorMessage: 'example error message',
107
+ }));
108
+
109
+ expect(formgroup.querySelector('.default-helper')).toBeTruthy();
110
+ });
111
+ });
@@ -45,7 +45,7 @@ export const FormGroup = React.forwardRef<HTMLDivElement, Props>(
45
45
  >
46
46
  {children}
47
47
 
48
- {(helperText || errorMessage) && (
48
+ {(helperText || (errorMessage && error)) && (
49
49
  <div
50
50
  style={{ marginLeft: `${helperIndent}px` }}
51
51
  className={`${classes['default-helper']} ${
package/src/Link/Link.tsx CHANGED
@@ -1,11 +1,16 @@
1
- import React, { ComponentPropsWithRef, ForwardRefExoticComponent, RefAttributes } from 'react';
1
+ import React, {
2
+ ComponentPropsWithRef,
3
+ ForwardRefExoticComponent,
4
+ ReactNode,
5
+ RefAttributes,
6
+ } from 'react';
2
7
  import classes from './Link.module.scss';
3
8
  import { LinkProps } from './types';
4
9
 
5
10
  type AnchorType = 'external' | 'internal' | 'download';
6
11
 
7
12
  export interface Props extends ComponentPropsWithRef<'a'> {
8
- children?: string;
13
+ children?: ReactNode;
9
14
  color?: 'primary' | 'secondary' | 'tertiary';
10
15
  type?: AnchorType;
11
16
  to: string;
package/src/index.ts CHANGED
@@ -13,6 +13,9 @@ export {
13
13
  } from './Pagination/Pagination';
14
14
  export { Icon, Icons } from './Icon/Icon';
15
15
 
16
+ export { Tabs, Props as TabsProps } from './Tabs/Tabs';
17
+ export { Tab, Props as TabProps } from './Tabs/Tab';
18
+
16
19
  export { Dialog } from './Notifications/Dialog/Dialog';
17
20
  export { Modal } from './Notifications/Modal/Modal';
18
21
  export { ModalActions } from './Notifications/Modal/ModalActions/ModalActions';