@lumx/react 3.19.1-alpha.1 → 3.19.1-alpha.11
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/index.js +99 -56
- package/index.js.map +1 -1
- package/package.json +8 -10
- package/src/components/alert-dialog/AlertDialog.test.tsx +3 -2
- package/src/components/autocomplete/Autocomplete.test.tsx +3 -3
- package/src/components/button/Button.test.tsx +4 -4
- package/src/components/checkbox/Checkbox.test.tsx +3 -3
- package/src/components/chip/Chip.test.tsx +19 -17
- package/src/components/date-picker/DatePicker.test.tsx +3 -3
- package/src/components/date-picker/DatePickerControlled.test.tsx +6 -6
- package/src/components/date-picker/DatePickerField.test.tsx +3 -3
- package/src/components/dialog/Dialog.test.tsx +4 -4
- package/src/components/dropdown/Dropdown.test.tsx +3 -3
- package/src/components/expansion-panel/ExpansionPanel.test.tsx +6 -5
- package/src/components/image-lightbox/ImageLightbox.test.tsx +11 -7
- package/src/components/link/Link.test.tsx +5 -5
- package/src/components/list/ListItem.test.tsx +8 -6
- package/src/components/list/ListItem.tsx +32 -19
- package/src/components/message/Message.test.tsx +1 -1
- package/src/components/mosaic/Mosaic.test.tsx +3 -3
- package/src/components/notification/Notification.test.tsx +4 -3
- package/src/components/popover-dialog/PopoverDialog.test.tsx +1 -1
- package/src/components/radio-button/RadioButton.test.tsx +3 -3
- package/src/components/select/Select.test.tsx +8 -7
- package/src/components/select/SelectMultiple.test.tsx +5 -5
- package/src/components/side-navigation/SideNavigationItem.test.tsx +2 -2
- package/src/components/slider/Slider.test.tsx +1 -1
- package/src/components/switch/Switch.test.tsx +5 -5
- package/src/components/table/TableCell.test.tsx +1 -1
- package/src/components/text-field/TextField.test.tsx +9 -8
- package/src/components/thumbnail/Thumbnail.test.tsx +4 -4
- package/src/components/thumbnail/Thumbnail.tsx +4 -3
- package/src/components/tooltip/Tooltip.test.tsx +14 -8
- package/src/components/uploader/Uploader.test.tsx +2 -2
- package/src/components/user-block/UserBlock.test.tsx +1 -1
- package/src/untypped-modules.d.ts +4 -0
- package/src/utils/Portal/PortalProvider.test.tsx +1 -1
- package/src/utils/date/getYearDisplayName.test.ts +1 -1
- package/src/utils/disabled/useDisableStateProps.test.tsx +2 -2
- package/src/utils/react/RawClickable.test.tsx +11 -11
- package/src/utils/react/RawClickable.tsx +1 -1
- package/src/utils/react/renderLink.tsx +17 -0
|
@@ -23,14 +23,14 @@ describe(`<RawClickable>`, () => {
|
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
it('should trigger onClick', async () => {
|
|
26
|
-
const onClick =
|
|
26
|
+
const onClick = vi.fn();
|
|
27
27
|
const { element } = setup({ as: 'button', children: 'Click me', onClick });
|
|
28
28
|
await userEvent.click(element);
|
|
29
29
|
expect(onClick).toHaveBeenCalledTimes(1);
|
|
30
30
|
});
|
|
31
31
|
|
|
32
32
|
it('should be disabled with `disabled` prop', async () => {
|
|
33
|
-
const onClick =
|
|
33
|
+
const onClick = vi.fn();
|
|
34
34
|
const { element } = setup({ as: 'button', children: 'Click me', onClick, disabled: true });
|
|
35
35
|
expect(element).toBeDisabled();
|
|
36
36
|
await userEvent.click(element);
|
|
@@ -38,7 +38,7 @@ describe(`<RawClickable>`, () => {
|
|
|
38
38
|
});
|
|
39
39
|
|
|
40
40
|
it('should be disabled with `isDisabled` prop', async () => {
|
|
41
|
-
const onClick =
|
|
41
|
+
const onClick = vi.fn();
|
|
42
42
|
const { element } = setup({ as: 'button', children: 'Click me', onClick, isDisabled: true });
|
|
43
43
|
expect(element).toBeDisabled();
|
|
44
44
|
await userEvent.click(element);
|
|
@@ -46,7 +46,7 @@ describe(`<RawClickable>`, () => {
|
|
|
46
46
|
});
|
|
47
47
|
|
|
48
48
|
it('should be aria-disabled with `aria-disabled` prop', async () => {
|
|
49
|
-
const onClick =
|
|
49
|
+
const onClick = vi.fn();
|
|
50
50
|
const { element } = setup({ as: 'button', children: 'Click me', onClick, 'aria-disabled': true });
|
|
51
51
|
expect(element).not.toBeDisabled();
|
|
52
52
|
expect(element).toHaveAttribute('aria-disabled', 'true');
|
|
@@ -66,14 +66,14 @@ describe(`<RawClickable>`, () => {
|
|
|
66
66
|
});
|
|
67
67
|
|
|
68
68
|
it('should trigger onClick', async () => {
|
|
69
|
-
const onClick =
|
|
69
|
+
const onClick = vi.fn((evt: any) => evt.preventDefault());
|
|
70
70
|
const { element } = setup({ as: 'a', children: 'Click me', href, onClick });
|
|
71
71
|
await userEvent.click(element);
|
|
72
72
|
expect(onClick).toHaveBeenCalledTimes(1);
|
|
73
73
|
});
|
|
74
74
|
|
|
75
75
|
it('should be disabled with `disabled` prop', async () => {
|
|
76
|
-
const onClick =
|
|
76
|
+
const onClick = vi.fn();
|
|
77
77
|
const { element } = setup({ as: 'a', children: 'Click me', href, onClick, disabled: true });
|
|
78
78
|
expect(element).toHaveAttribute('aria-disabled', 'true');
|
|
79
79
|
expect(element).toHaveAttribute('tabindex', '-1');
|
|
@@ -82,7 +82,7 @@ describe(`<RawClickable>`, () => {
|
|
|
82
82
|
});
|
|
83
83
|
|
|
84
84
|
it('should be disabled with `isDisabled` prop', async () => {
|
|
85
|
-
const onClick =
|
|
85
|
+
const onClick = vi.fn();
|
|
86
86
|
const { element } = setup({ as: 'a', children: 'Click me', href, onClick, isDisabled: true });
|
|
87
87
|
expect(element).toHaveAttribute('aria-disabled', 'true');
|
|
88
88
|
expect(element).toHaveAttribute('tabindex', '-1');
|
|
@@ -91,7 +91,7 @@ describe(`<RawClickable>`, () => {
|
|
|
91
91
|
});
|
|
92
92
|
|
|
93
93
|
it('should be aria-disabled with `aria-disabled` prop', async () => {
|
|
94
|
-
const onClick =
|
|
94
|
+
const onClick = vi.fn();
|
|
95
95
|
const { element } = setup({ as: 'a', children: 'Click me', href, onClick, 'aria-disabled': true });
|
|
96
96
|
expect(element).toHaveAttribute('aria-disabled', 'true');
|
|
97
97
|
await userEvent.click(element);
|
|
@@ -106,7 +106,7 @@ describe(`<RawClickable>`, () => {
|
|
|
106
106
|
});
|
|
107
107
|
|
|
108
108
|
it('should trigger onClick', async () => {
|
|
109
|
-
const onClick =
|
|
109
|
+
const onClick = vi.fn();
|
|
110
110
|
const { element } = setup({ as: CustomLink, children: 'Click me', onClick });
|
|
111
111
|
expect(element).toHaveAttribute('data-custom-link');
|
|
112
112
|
await userEvent.click(element);
|
|
@@ -114,7 +114,7 @@ describe(`<RawClickable>`, () => {
|
|
|
114
114
|
});
|
|
115
115
|
|
|
116
116
|
it('should be disabled with `disabled` prop', async () => {
|
|
117
|
-
const onClick =
|
|
117
|
+
const onClick = vi.fn();
|
|
118
118
|
const { element } = setup({ as: CustomLink, children: 'Click me', onClick, disabled: true });
|
|
119
119
|
expect(element).toHaveAttribute('data-custom-link');
|
|
120
120
|
expect(element).toHaveAttribute('aria-disabled', 'true');
|
|
@@ -126,7 +126,7 @@ describe(`<RawClickable>`, () => {
|
|
|
126
126
|
|
|
127
127
|
describe('prop forwarding', () => {
|
|
128
128
|
it('should forward className', () => {
|
|
129
|
-
const { element } = setup({ as:'button', className: 'foo bar' });
|
|
129
|
+
const { element } = setup({ as: 'button', className: 'foo bar' });
|
|
130
130
|
expect(element).toHaveClass('foo bar');
|
|
131
131
|
});
|
|
132
132
|
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React, { ReactElement, ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
interface Props {
|
|
4
|
+
linkAs?: any;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Render link with default <a> HTML component or a custom one provided by `linkAs`.
|
|
9
|
+
*
|
|
10
|
+
* Can be used to inject the `Link` component from `react-router` and provide better a11y on LumX components.
|
|
11
|
+
*
|
|
12
|
+
* @param linkAs Custom link component.
|
|
13
|
+
* @param children Link children.
|
|
14
|
+
* @return A link.
|
|
15
|
+
*/
|
|
16
|
+
export const renderLink = <P extends Props>({ linkAs, ...forwardedProps }: P, ...children: ReactNode[]): ReactElement =>
|
|
17
|
+
React.createElement(linkAs || 'a', forwardedProps, ...children);
|