@lumx/react 3.20.1-alpha.5 → 3.20.1-alpha.6
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/_internal/index.js.map +1 -1
- package/index.d.ts +35 -34
- package/index.js +778 -651
- package/index.js.map +1 -1
- package/package.json +13 -12
- package/src/components/alert-dialog/AlertDialog.stories.tsx +1 -1
- package/src/components/alert-dialog/AlertDialog.test.tsx +3 -4
- package/src/components/autocomplete/Autocomplete.stories.tsx +1 -1
- package/src/components/autocomplete/Autocomplete.test.tsx +3 -5
- package/src/components/autocomplete/Autocomplete.tsx +1 -1
- package/src/components/autocomplete/AutocompleteMultiple.stories.tsx +1 -1
- package/src/components/autocomplete/AutocompleteMultiple.test.tsx +0 -2
- package/src/components/autocomplete/AutocompleteMultiple.tsx +1 -1
- package/src/components/avatar/Avatar.stories.tsx +0 -2
- package/src/components/avatar/Avatar.test.tsx +0 -2
- package/src/components/avatar/Avatar.tsx +1 -1
- package/src/components/badge/Badge.stories.tsx +0 -1
- package/src/components/badge/Badge.test.tsx +0 -2
- package/src/components/badge/Badge.tsx +1 -1
- package/src/components/badge/BadgeWrapper.stories.tsx +0 -1
- package/src/components/badge/BadgeWrapper.test.tsx +0 -2
- package/src/components/badge/BadgeWrapper.tsx +1 -1
- package/src/components/button/Button.stories.tsx +0 -1
- package/src/components/button/Button.test.tsx +9 -11
- package/src/components/button/Button.tsx +0 -2
- package/src/components/button/ButtonGroup.stories.tsx +0 -2
- package/src/components/button/ButtonGroup.test.tsx +0 -2
- package/src/components/button/ButtonGroup.tsx +0 -2
- package/src/components/button/ButtonRoot.tsx +7 -37
- package/src/components/button/IconButton.test.tsx +0 -2
- package/src/components/button/IconButton.tsx +0 -2
- package/src/components/checkbox/Checkbox.test.tsx +3 -5
- package/src/components/chip/Chip.stories.tsx +0 -2
- package/src/components/chip/Chip.test.tsx +19 -19
- package/src/components/chip/Chip.tsx +1 -1
- package/src/components/chip/ChipGroup.stories.tsx +0 -2
- package/src/components/chip/ChipGroup.test.tsx +0 -2
- package/src/components/chip/ChipGroup.tsx +1 -1
- package/src/components/comment-block/CommentBlock.stories.tsx +0 -1
- package/src/components/comment-block/CommentBlock.test.tsx +0 -1
- package/src/components/comment-block/CommentBlock.tsx +1 -1
- package/src/components/date-picker/DatePicker.test.tsx +3 -5
- package/src/components/date-picker/DatePicker.tsx +1 -1
- package/src/components/date-picker/DatePickerControlled.test.tsx +6 -8
- package/src/components/date-picker/DatePickerField.test.tsx +3 -5
- package/src/components/dialog/Dialog.test.tsx +4 -6
- package/src/components/divider/Divider.test.tsx +0 -2
- package/src/components/divider/Divider.tsx +0 -2
- package/src/components/drag-handle/DragHandle.test.tsx +0 -2
- package/src/components/drag-handle/DragHandle.tsx +0 -2
- package/src/components/dropdown/Dropdown.stories.tsx +1 -1
- package/src/components/dropdown/Dropdown.test.tsx +3 -3
- package/src/components/dropdown/Dropdown.tsx +1 -1
- package/src/components/expansion-panel/ExpansionPanel.test.tsx +6 -7
- package/src/components/flag/Flag.test.tsx +0 -2
- package/src/components/flag/Flag.tsx +0 -2
- package/src/components/flex-box/FlexBox.stories.tsx +0 -2
- package/src/components/flex-box/FlexBox.test.tsx +0 -1
- package/src/components/flex-box/FlexBox.tsx +1 -1
- package/src/components/generic-block/GenericBlock.test.tsx +1 -1
- package/src/components/grid/Grid.tsx +0 -2
- package/src/components/grid/GridItem.tsx +0 -2
- package/src/components/grid-column/GridColumn.stories.tsx +0 -1
- package/src/components/grid-column/GridColumn.test.jsx +0 -2
- package/src/components/grid-column/GridColumn.tsx +1 -1
- package/src/components/heading/Heading.stories.tsx +0 -1
- package/src/components/heading/Heading.test.tsx +0 -2
- package/src/components/heading/Heading.tsx +0 -2
- package/src/components/heading/HeadingLevelProvider.tsx +1 -1
- package/src/components/icon/Icon.stories.tsx +30 -4
- package/src/components/icon/Icon.test.tsx +85 -4
- package/src/components/icon/Icon.tsx +0 -2
- package/src/components/image-block/ImageBlock.stories.tsx +0 -2
- package/src/components/image-block/ImageBlock.test.tsx +0 -1
- package/src/components/image-block/ImageBlock.tsx +1 -1
- package/src/components/image-block/ImageCaption.tsx +1 -1
- package/src/components/image-lightbox/ImageLightbox.stories.tsx +0 -1
- package/src/components/image-lightbox/ImageLightbox.test.tsx +11 -9
- package/src/components/image-lightbox/types.ts +0 -2
- package/src/components/inline-list/InlineList.stories.tsx +0 -1
- package/src/components/inline-list/InlineList.test.tsx +0 -2
- package/src/components/inline-list/InlineList.tsx +1 -1
- package/src/components/input-helper/InputHelper.test.tsx +0 -2
- package/src/components/input-helper/InputHelper.tsx +1 -1
- package/src/components/input-label/InputLabel.stories.tsx +0 -2
- package/src/components/input-label/InputLabel.test.tsx +0 -2
- package/src/components/input-label/InputLabel.tsx +1 -1
- package/src/components/lightbox/Lightbox.test.tsx +0 -2
- package/src/components/lightbox/Lightbox.tsx +1 -1
- package/src/components/link/Link.stories.tsx +0 -1
- package/src/components/link/Link.test.tsx +13 -13
- package/src/components/link/Link.tsx +9 -22
- package/src/components/link-preview/LinkPreview.test.tsx +0 -2
- package/src/components/link-preview/LinkPreview.tsx +0 -2
- package/src/components/list/List.stories.tsx +1 -1
- package/src/components/list/List.test.tsx +0 -2
- package/src/components/list/List.tsx +1 -1
- package/src/components/list/ListDivider.test.tsx +0 -2
- package/src/components/list/ListDivider.tsx +0 -2
- package/src/components/list/ListItem.test.tsx +5 -7
- package/src/components/list/ListItem.tsx +1 -1
- package/src/components/list/ListSubheader.test.tsx +0 -2
- package/src/components/list/ListSubheader.tsx +1 -1
- package/src/components/message/Message.test.tsx +1 -2
- package/src/components/message/Message.tsx +1 -1
- package/src/components/mosaic/Mosaic.test.tsx +3 -5
- package/src/components/mosaic/Mosaic.tsx +1 -1
- package/src/components/navigation/Navigation.stories.tsx +0 -2
- package/src/components/navigation/Navigation.test.tsx +0 -2
- package/src/components/navigation/Navigation.tsx +0 -2
- package/src/components/navigation/NavigationItem.test.tsx +0 -2
- package/src/components/navigation/NavigationItem.tsx +7 -11
- package/src/components/navigation/NavigationSection.test.tsx +0 -2
- package/src/components/navigation/NavigationSection.tsx +5 -4
- package/src/components/notification/Notification.test.tsx +4 -5
- package/src/components/notification/Notification.tsx +1 -1
- package/src/components/popover/Popover.test.tsx +0 -2
- package/src/components/popover/Popover.tsx +1 -1
- package/src/components/popover/usePopoverStyle.tsx +1 -1
- package/src/components/popover-dialog/PopoverDialog.test.tsx +1 -2
- package/src/components/popover-dialog/PopoverDialog.tsx +0 -2
- package/src/components/post-block/PostBlock.test.tsx +0 -2
- package/src/components/post-block/PostBlock.tsx +1 -1
- package/src/components/progress/Progress.tsx +0 -2
- package/src/components/progress/ProgressCircular.stories.tsx +0 -1
- package/src/components/progress/ProgressCircular.test.tsx +0 -2
- package/src/components/progress/ProgressCircular.tsx +0 -2
- package/src/components/progress/ProgressLinear.test.tsx +0 -2
- package/src/components/progress/ProgressLinear.tsx +0 -2
- package/src/components/progress-tracker/ProgressTracker.stories.tsx +1 -1
- package/src/components/progress-tracker/ProgressTracker.test.tsx +0 -2
- package/src/components/progress-tracker/ProgressTrackerProvider.test.tsx +0 -2
- package/src/components/progress-tracker/ProgressTrackerProvider.tsx +1 -1
- package/src/components/progress-tracker/ProgressTrackerStep.test.tsx +0 -2
- package/src/components/progress-tracker/ProgressTrackerStep.tsx +1 -1
- package/src/components/progress-tracker/ProgressTrackerStepPanel.test.tsx +0 -2
- package/src/components/progress-tracker/ProgressTrackerStepPanel.tsx +0 -2
- package/src/components/radio-button/RadioButton.test.tsx +3 -5
- package/src/components/radio-button/RadioButton.tsx +1 -1
- package/src/components/radio-button/RadioGroup.stories.tsx +1 -1
- package/src/components/radio-button/RadioGroup.test.tsx +0 -2
- package/src/components/radio-button/RadioGroup.tsx +1 -1
- package/src/components/select/Select.stories.tsx +1 -1
- package/src/components/select/Select.test.tsx +8 -9
- package/src/components/select/Select.tsx +1 -1
- package/src/components/select/SelectMultiple.stories.tsx +1 -1
- package/src/components/select/SelectMultiple.test.tsx +5 -7
- package/src/components/select/SelectMultiple.tsx +1 -1
- package/src/components/select/WithSelectContext.tsx +1 -1
- package/src/components/select/constants.ts +1 -1
- package/src/components/side-navigation/SideNavigation.test.tsx +0 -2
- package/src/components/side-navigation/SideNavigation.tsx +1 -1
- package/src/components/side-navigation/SideNavigationItem.test.tsx +2 -4
- package/src/components/side-navigation/SideNavigationItem.tsx +23 -28
- package/src/components/skeleton/SkeletonCircle.test.tsx +0 -2
- package/src/components/skeleton/SkeletonCircle.tsx +0 -2
- package/src/components/skeleton/SkeletonRectangle.test.tsx +0 -2
- package/src/components/skeleton/SkeletonRectangle.tsx +0 -2
- package/src/components/skeleton/SkeletonTypography.stories.tsx +0 -2
- package/src/components/skeleton/SkeletonTypography.test.tsx +0 -2
- package/src/components/skeleton/SkeletonTypography.tsx +1 -1
- package/src/components/slider/Slider.test.tsx +1 -3
- package/src/components/slider/Slider.tsx +1 -1
- package/src/components/slideshow/Slideshow.stories.tsx +0 -1
- package/src/components/slideshow/Slideshow.test.tsx +0 -2
- package/src/components/slideshow/SlideshowControls.stories.tsx +0 -2
- package/src/components/slideshow/SlideshowItem.tsx +0 -2
- package/src/components/slideshow/useSlideFocusManagement.tsx +1 -1
- package/src/components/switch/Switch.test.tsx +5 -7
- package/src/components/switch/Switch.tsx +1 -1
- package/src/components/table/Table.test.tsx +0 -2
- package/src/components/table/Table.tsx +0 -2
- package/src/components/table/TableBody.test.tsx +0 -2
- package/src/components/table/TableBody.tsx +0 -2
- package/src/components/table/TableCell.test.tsx +1 -3
- package/src/components/table/TableCell.tsx +0 -2
- package/src/components/table/TableHeader.test.tsx +0 -2
- package/src/components/table/TableHeader.tsx +0 -2
- package/src/components/table/TableRow.test.tsx +0 -2
- package/src/components/table/TableRow.tsx +0 -2
- package/src/components/tabs/Tab.test.tsx +0 -2
- package/src/components/tabs/Tab.tsx +1 -1
- package/src/components/tabs/TabList.test.tsx +0 -2
- package/src/components/tabs/TabPanel.test.tsx +0 -2
- package/src/components/tabs/TabPanel.tsx +0 -2
- package/src/components/tabs/TabProvider.test.tsx +0 -2
- package/src/components/tabs/TabProvider.tsx +1 -1
- package/src/components/tabs/Tabs.stories.tsx +1 -1
- package/src/components/text/Text.stories.tsx +1 -1
- package/src/components/text/Text.test.tsx +0 -2
- package/src/components/text/Text.tsx +0 -2
- package/src/components/text-field/TextField.test.tsx +9 -10
- package/src/components/text-field/TextField.tsx +1 -1
- package/src/components/thumbnail/Thumbnail.test.tsx +29 -7
- package/src/components/thumbnail/Thumbnail.tsx +11 -11
- package/src/components/toolbar/Toolbar.tsx +1 -1
- package/src/components/tooltip/Tooltip.stories.tsx +2 -1
- package/src/components/tooltip/Tooltip.test.tsx +14 -8
- package/src/components/uploader/Uploader.test.tsx +2 -4
- package/src/components/user-block/UserBlock.stories.tsx +0 -2
- package/src/components/user-block/UserBlock.test.tsx +1 -3
- package/src/hooks/useId.test.tsx +0 -1
- package/src/hooks/useInfiniteScroll.tsx +1 -1
- package/src/hooks/usePreviousValue.ts +0 -1
- package/src/stories/decorators/withChromaticForceScreenSize.tsx +0 -1
- package/src/stories/decorators/withNestedProps.tsx +0 -1
- package/src/stories/decorators/withThemedBackground.tsx +0 -2
- package/src/stories/decorators/withWrapper.tsx +0 -2
- package/src/stories/utils/CustomLink.tsx +0 -1
- package/src/testing/utils/ThemeSentinel.tsx +0 -1
- package/src/untypped-modules.d.ts +4 -0
- package/src/utils/ClickAwayProvider/ClickAwayProvider.stories.jsx +1 -1
- package/src/utils/ClickAwayProvider/ClickAwayProvider.tsx +1 -1
- package/src/utils/MaterialThemeSwitcher/MaterialThemeSwitcher.tsx +1 -1
- package/src/utils/Portal/Portal.test.tsx +0 -1
- package/src/utils/Portal/PortalProvider.stories.jsx +0 -1
- package/src/utils/Portal/PortalProvider.test.tsx +1 -2
- package/src/utils/date/getYearDisplayName.test.ts +1 -1
- package/src/utils/disabled/DisabledStateProvider.stories.tsx +0 -2
- package/src/utils/disabled/useDisableStateProps.test.tsx +2 -2
- package/src/utils/react/OnBeforeUnmount.tsx +1 -1
- package/src/utils/react/RawClickable.test.tsx +153 -0
- package/src/utils/react/RawClickable.tsx +65 -0
- package/src/utils/react/skipRender.tsx +2 -2
- package/src/utils/react/wrapChildrenIconWithSpaces.test.tsx +1 -1
- package/src/utils/type/HasPolymorphicAs.ts +0 -2
- package/src/utils/type/HasRequiredLinkHref.ts +1 -0
- package/src/utils/type/index.ts +1 -0
- package/utils/index.d.ts +6 -6
- package/src/utils/react/renderButtonOrLink.tsx +0 -16
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
1
|
import { DatePickerProps } from '@lumx/react';
|
|
4
2
|
import { commonTestsSuiteRTL } from '@lumx/react/testing/utils';
|
|
5
3
|
import { getByClassName } from '@lumx/react/testing/utils/queries';
|
|
@@ -9,15 +7,15 @@ import { DatePicker } from '.';
|
|
|
9
7
|
import { CLASSNAME } from './constants';
|
|
10
8
|
|
|
11
9
|
const mockedDate = new Date(1487721600000);
|
|
12
|
-
Date.now =
|
|
13
|
-
|
|
10
|
+
Date.now = vi.fn(() => mockedDate.valueOf());
|
|
11
|
+
vi.mock('@lumx/react/utils/date/getYearDisplayName', () => ({
|
|
14
12
|
getYearDisplayName: () => 'année',
|
|
15
13
|
}));
|
|
16
14
|
|
|
17
15
|
const setup = (propsOverride: Partial<DatePickerProps> = {}) => {
|
|
18
16
|
const props: DatePickerProps = {
|
|
19
17
|
locale: 'fr',
|
|
20
|
-
onChange:
|
|
18
|
+
onChange: vi.fn(),
|
|
21
19
|
value: mockedDate,
|
|
22
20
|
nextButtonProps: { label: 'Next month' },
|
|
23
21
|
previousButtonProps: { label: 'Previous month' },
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
1
|
import { render, screen, waitFor } from '@testing-library/react';
|
|
4
2
|
import { getByClassName, queryByClassName } from '@lumx/react/testing/utils/queries';
|
|
5
3
|
import { commonTestsSuiteRTL } from '@lumx/react/testing/utils';
|
|
@@ -10,8 +8,8 @@ import { DatePickerControlled, DatePickerControlledProps } from './DatePickerCon
|
|
|
10
8
|
import { CLASSNAME } from './constants';
|
|
11
9
|
|
|
12
10
|
const mockedDate = new Date(1487721600000);
|
|
13
|
-
Date.now =
|
|
14
|
-
|
|
11
|
+
Date.now = vi.fn(() => mockedDate.valueOf());
|
|
12
|
+
vi.mock('@lumx/react/utils/date/getYearDisplayName', () => ({
|
|
15
13
|
getYearDisplayName: () => 'année',
|
|
16
14
|
}));
|
|
17
15
|
|
|
@@ -20,14 +18,14 @@ type SetupProps = Partial<DatePickerControlledProps>;
|
|
|
20
18
|
const setup = (propsOverride: SetupProps = {}) => {
|
|
21
19
|
const props: DatePickerControlledProps = {
|
|
22
20
|
locale: 'fr',
|
|
23
|
-
onChange:
|
|
24
|
-
onNextMonthChange:
|
|
25
|
-
onPrevMonthChange:
|
|
21
|
+
onChange: vi.fn(),
|
|
22
|
+
onNextMonthChange: vi.fn(),
|
|
23
|
+
onPrevMonthChange: vi.fn(),
|
|
26
24
|
selectedMonth: mockedDate,
|
|
27
25
|
value: mockedDate,
|
|
28
26
|
nextButtonProps: { label: 'Next month' },
|
|
29
27
|
previousButtonProps: { label: 'Previous month' },
|
|
30
|
-
onMonthChange:
|
|
28
|
+
onMonthChange: vi.fn(),
|
|
31
29
|
...propsOverride,
|
|
32
30
|
};
|
|
33
31
|
render(<DatePickerControlled {...props} />);
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
1
|
import { commonTestsSuiteRTL, SetupRenderOptions } from '@lumx/react/testing/utils';
|
|
4
2
|
import { render, screen } from '@testing-library/react';
|
|
5
3
|
import { getByClassName, getByTagName, queryByClassName } from '@lumx/react/testing/utils/queries';
|
|
@@ -10,8 +8,8 @@ import { DatePickerField, DatePickerFieldProps } from './DatePickerField';
|
|
|
10
8
|
import { CLASSNAME } from './constants';
|
|
11
9
|
|
|
12
10
|
const mockedDate = new Date(1487721600000);
|
|
13
|
-
Date.now =
|
|
14
|
-
|
|
11
|
+
Date.now = vi.fn(() => mockedDate.valueOf());
|
|
12
|
+
vi.mock('@lumx/react/utils/date/getYearDisplayName', () => ({
|
|
15
13
|
getYearDisplayName: () => 'année',
|
|
16
14
|
}));
|
|
17
15
|
|
|
@@ -19,7 +17,7 @@ const setup = (propsOverride: Partial<DatePickerFieldProps> = {}, { wrapper }: S
|
|
|
19
17
|
const props: DatePickerFieldProps = {
|
|
20
18
|
label: 'DatePickerField',
|
|
21
19
|
locale: 'fr',
|
|
22
|
-
onChange:
|
|
20
|
+
onChange: vi.fn(),
|
|
23
21
|
value: mockedDate,
|
|
24
22
|
nextButtonProps: { label: 'Next month' },
|
|
25
23
|
previousButtonProps: { label: 'Previous month' },
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
1
|
import { Dialog, DialogProps } from '@lumx/react/components/dialog/Dialog';
|
|
4
2
|
import { queryByClassName } from '@lumx/react/testing/utils/queries';
|
|
5
3
|
import { render, screen } from '@testing-library/react';
|
|
@@ -51,7 +49,7 @@ describe(`<${Dialog.displayName}>`, () => {
|
|
|
51
49
|
|
|
52
50
|
describe('Events', () => {
|
|
53
51
|
it('should trigger `onClose` when pressing `escape` key', async () => {
|
|
54
|
-
const onClose =
|
|
52
|
+
const onClose = vi.fn();
|
|
55
53
|
setup({ isOpen: true, onClose });
|
|
56
54
|
|
|
57
55
|
await userEvent.keyboard('[Escape]');
|
|
@@ -59,7 +57,7 @@ describe(`<${Dialog.displayName}>`, () => {
|
|
|
59
57
|
});
|
|
60
58
|
|
|
61
59
|
it('should not trigger `onClose` when pressing any other key', async () => {
|
|
62
|
-
const onClose =
|
|
60
|
+
const onClose = vi.fn();
|
|
63
61
|
setup({ isOpen: true, onClose });
|
|
64
62
|
|
|
65
63
|
await userEvent.keyboard('a');
|
|
@@ -67,7 +65,7 @@ describe(`<${Dialog.displayName}>`, () => {
|
|
|
67
65
|
});
|
|
68
66
|
|
|
69
67
|
it('should not trigger `onClose` when pressing `escape` key with `preventAutoClose` set to `true`', async () => {
|
|
70
|
-
const onClose =
|
|
68
|
+
const onClose = vi.fn();
|
|
71
69
|
setup({ isOpen: true, onClose, preventAutoClose: true });
|
|
72
70
|
|
|
73
71
|
await userEvent.keyboard('[Escape]');
|
|
@@ -75,7 +73,7 @@ describe(`<${Dialog.displayName}>`, () => {
|
|
|
75
73
|
});
|
|
76
74
|
|
|
77
75
|
it('should not trigger `onClose` when pressing `escape` key with `preventCloseOnEscape` set to `true`', async () => {
|
|
78
|
-
const onClose =
|
|
76
|
+
const onClose = vi.fn();
|
|
79
77
|
setup({ isOpen: true, onClose, preventCloseOnEscape: true });
|
|
80
78
|
|
|
81
79
|
await userEvent.keyboard('[Escape]');
|
|
@@ -28,7 +28,7 @@ const setup = (propsOverride: Partial<DropdownProps> = {}) => {
|
|
|
28
28
|
describe(`<${Dropdown.displayName}>`, () => {
|
|
29
29
|
describe('Events', () => {
|
|
30
30
|
it('should trigger `onClose` when pressing `escape` key', async () => {
|
|
31
|
-
const onClose =
|
|
31
|
+
const onClose = vi.fn();
|
|
32
32
|
setup({
|
|
33
33
|
closeOnEscape: true,
|
|
34
34
|
onClose,
|
|
@@ -40,7 +40,7 @@ describe(`<${Dropdown.displayName}>`, () => {
|
|
|
40
40
|
});
|
|
41
41
|
|
|
42
42
|
it('should not trigger `onClose` when pressing any other key', async () => {
|
|
43
|
-
const onClose =
|
|
43
|
+
const onClose = vi.fn();
|
|
44
44
|
setup({ isOpen: true, onClose, closeOnEscape: true });
|
|
45
45
|
|
|
46
46
|
await userEvent.keyboard('a');
|
|
@@ -48,7 +48,7 @@ describe(`<${Dropdown.displayName}>`, () => {
|
|
|
48
48
|
});
|
|
49
49
|
|
|
50
50
|
it('should not trigger `onClose` when pressing `escape` key with `closeOnEscape` set to `false`', async () => {
|
|
51
|
-
const onClose =
|
|
51
|
+
const onClose = vi.fn();
|
|
52
52
|
setup({ isOpen: true, onClose, closeOnEscape: false });
|
|
53
53
|
|
|
54
54
|
await userEvent.keyboard('[Escape]');
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { Mock } from 'vitest';
|
|
3
2
|
import { commonTestsSuiteRTL, SetupRenderOptions } from '@lumx/react/testing/utils';
|
|
4
3
|
import { queryByRole, render, screen } from '@testing-library/react';
|
|
5
4
|
import { getByClassName, queryByClassName } from '@lumx/react/testing/utils/queries';
|
|
@@ -11,7 +10,7 @@ import { ExpansionPanel, ExpansionPanelProps } from '.';
|
|
|
11
10
|
|
|
12
11
|
const CLASSNAME = ExpansionPanel.className as string;
|
|
13
12
|
|
|
14
|
-
|
|
13
|
+
vi.mock('@lumx/react/utils/browser/isFocusVisible');
|
|
15
14
|
|
|
16
15
|
const mockChildrenContent = 'children content';
|
|
17
16
|
|
|
@@ -55,7 +54,7 @@ const setup = (
|
|
|
55
54
|
};
|
|
56
55
|
|
|
57
56
|
describe(`<${ExpansionPanel.displayName}>`, () => {
|
|
58
|
-
(isFocusVisible as
|
|
57
|
+
(isFocusVisible as Mock).mockReturnValue(false);
|
|
59
58
|
|
|
60
59
|
describe('Render', () => {
|
|
61
60
|
it('should render default', () => {
|
|
@@ -100,9 +99,9 @@ describe(`<${ExpansionPanel.displayName}>`, () => {
|
|
|
100
99
|
});
|
|
101
100
|
|
|
102
101
|
describe('Events', () => {
|
|
103
|
-
const onOpen =
|
|
104
|
-
const onClose =
|
|
105
|
-
const onToggleOpen =
|
|
102
|
+
const onOpen = vi.fn();
|
|
103
|
+
const onClose = vi.fn();
|
|
104
|
+
const onToggleOpen = vi.fn();
|
|
106
105
|
|
|
107
106
|
beforeEach(onOpen.mockClear);
|
|
108
107
|
beforeEach(onClose.mockClear);
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import { headingElementArgType, HEADING_ELEMENTS } from '@lumx/react/stories/controls/element';
|
|
3
2
|
import { withCombinations } from '@lumx/react/stories/decorators/withCombinations';
|
|
4
3
|
import { ALL_TYPOGRAPHY } from '@lumx/react/stories/controls/typography';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { HeadingElement } from '@lumx/react/utils/type';
|
|
2
|
-
import
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
3
|
import { MAX_HEADING_LEVEL } from './constants';
|
|
4
4
|
import { HeadingLevelContext } from './context';
|
|
5
5
|
import { useHeadingLevel } from './useHeadingLevel';
|
|
@@ -1,21 +1,47 @@
|
|
|
1
|
-
import DefaultStory, { SizeAndShape as DefaultSizeAndShape } from '@lumx/core/js/components/Icon/Stories';
|
|
2
1
|
import { mdiEmail } from '@lumx/icons';
|
|
3
|
-
import { ColorPalette, ColorVariant, GridColumn, Icon, Size } from '@lumx/react';
|
|
2
|
+
import { ColorPalette, ColorVariant, GridColumn, Icon, IconSizes, Size } from '@lumx/react';
|
|
4
3
|
import { withCombinations } from '@lumx/react/stories/decorators/withCombinations';
|
|
5
4
|
import { withUndefined } from '@lumx/react/stories/controls/withUndefined';
|
|
5
|
+
import { iconArgType } from '@lumx/react/stories/controls/icons';
|
|
6
|
+
import { colorArgType, colorVariantArgType } from '@lumx/react/stories/controls/color';
|
|
6
7
|
import { withWrapper } from '@lumx/react/stories/decorators/withWrapper';
|
|
7
8
|
|
|
9
|
+
const iconSizes: Array<IconSizes> = [Size.xxs, Size.xs, Size.s, Size.m, Size.l, Size.xl, Size.xxl];
|
|
10
|
+
|
|
8
11
|
export default {
|
|
9
12
|
title: 'LumX components/icon/Icon',
|
|
10
13
|
component: Icon,
|
|
11
|
-
|
|
14
|
+
args: Icon.defaultProps,
|
|
15
|
+
argTypes: {
|
|
16
|
+
icon: iconArgType,
|
|
17
|
+
hasShape: { control: 'boolean' },
|
|
18
|
+
color: colorArgType,
|
|
19
|
+
colorVariant: colorVariantArgType,
|
|
20
|
+
},
|
|
12
21
|
};
|
|
13
22
|
|
|
14
23
|
/**
|
|
15
24
|
* All combinations of size and shape
|
|
16
25
|
*/
|
|
17
26
|
export const SizeAndShape = {
|
|
18
|
-
|
|
27
|
+
args: {
|
|
28
|
+
icon: mdiEmail,
|
|
29
|
+
},
|
|
30
|
+
argTypes: {
|
|
31
|
+
hasShape: { control: false },
|
|
32
|
+
size: { control: false },
|
|
33
|
+
},
|
|
34
|
+
decorators: [
|
|
35
|
+
withCombinations({
|
|
36
|
+
combinations: {
|
|
37
|
+
cols: { key: 'size', options: withUndefined(iconSizes) },
|
|
38
|
+
rows: {
|
|
39
|
+
Default: {},
|
|
40
|
+
'Has shape': { hasShape: true },
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
}),
|
|
44
|
+
],
|
|
19
45
|
};
|
|
20
46
|
|
|
21
47
|
/**
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { mdiAlertCircle } from '@lumx/icons';
|
|
2
|
+
import { ColorPalette, ColorVariant, Size, Theme } from '@lumx/react';
|
|
3
3
|
import { commonTestsSuiteRTL, SetupRenderOptions } from '@lumx/react/testing/utils';
|
|
4
4
|
|
|
5
5
|
import { getByClassName, getByTagName } from '@lumx/react/testing/utils/queries';
|
|
6
6
|
import { render } from '@testing-library/react';
|
|
7
|
-
import Tests from '@lumx/core/js/components/Icon/Tests';
|
|
8
7
|
import { Icon, IconProps } from './Icon';
|
|
9
8
|
|
|
10
9
|
const CLASSNAME = Icon.className as string;
|
|
@@ -28,7 +27,89 @@ const setup = (propsOverride: SetupProps = {}, { wrapper }: SetupRenderOptions =
|
|
|
28
27
|
};
|
|
29
28
|
|
|
30
29
|
describe(`<${Icon.displayName}>`, () => {
|
|
31
|
-
|
|
30
|
+
describe('Props', () => {
|
|
31
|
+
it('should render default', () => {
|
|
32
|
+
const { i, svg, path, props } = setup();
|
|
33
|
+
|
|
34
|
+
expect(i).toBeInTheDocument();
|
|
35
|
+
expect(i).toHaveClass(CLASSNAME);
|
|
36
|
+
expect(i?.className).toMatchInlineSnapshot('"lumx-icon lumx-icon--no-shape lumx-icon--path"');
|
|
37
|
+
|
|
38
|
+
expect(svg).toBeInTheDocument();
|
|
39
|
+
expect(svg).toHaveAttribute('aria-hidden', 'true');
|
|
40
|
+
expect(svg).not.toHaveAttribute('role');
|
|
41
|
+
|
|
42
|
+
expect(path).toBeInTheDocument();
|
|
43
|
+
expect(path).toHaveAttribute('d', props.icon);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('should adapt svg with alternate text', () => {
|
|
47
|
+
const { svg, props } = setup({ alt: 'Alternate text' });
|
|
48
|
+
expect(svg).toHaveAttribute('aria-label', props.alt);
|
|
49
|
+
expect(svg).not.toHaveAttribute('aria-hidden');
|
|
50
|
+
expect(svg).toHaveAttribute('role');
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
describe('size', () => {
|
|
54
|
+
it('should render size', () => {
|
|
55
|
+
const { i } = setup({ size: Size.s });
|
|
56
|
+
expect(i).toHaveClass('lumx-icon--size-s');
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it('should adapt xxs size with hasShape', () => {
|
|
60
|
+
const { i } = setup({ hasShape: true, size: Size.xxs });
|
|
61
|
+
expect(i).toHaveClass('lumx-icon--size-s');
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it('should adapt xs size with hasShape', () => {
|
|
65
|
+
const { i } = setup({ hasShape: true, size: Size.xs });
|
|
66
|
+
expect(i).toHaveClass('lumx-icon--size-s');
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it('should adapt xxl size with hasShape', () => {
|
|
70
|
+
const { i } = setup({ hasShape: true, size: Size.xxl });
|
|
71
|
+
expect(i).toHaveClass('lumx-icon--size-xl');
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it('should add default size with hasShape', () => {
|
|
75
|
+
const { i } = setup({ hasShape: true });
|
|
76
|
+
expect(i).toHaveClass('lumx-icon--size-m');
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
describe('color', () => {
|
|
81
|
+
it('should render color and color variant', () => {
|
|
82
|
+
const { i } = setup({
|
|
83
|
+
color: ColorPalette.primary,
|
|
84
|
+
colorVariant: ColorVariant.D1,
|
|
85
|
+
});
|
|
86
|
+
expect(i).toHaveClass('lumx-icon--color-primary lumx-icon--color-variant-D1');
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it('should improve yellow icon color contrast with alert circle icon', () => {
|
|
90
|
+
const { i } = setup({
|
|
91
|
+
color: ColorPalette.yellow,
|
|
92
|
+
icon: mdiAlertCircle,
|
|
93
|
+
});
|
|
94
|
+
expect(i).toHaveClass('lumx-icon--color-yellow lumx-icon--has-dark-layer');
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it('should set a default color on dark theme', () => {
|
|
98
|
+
const { i } = setup({ theme: Theme.dark });
|
|
99
|
+
expect(i).toHaveClass('lumx-icon--color-light lumx-icon--theme-dark');
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it('should set a default color on has shape', () => {
|
|
103
|
+
const { i } = setup({ hasShape: true });
|
|
104
|
+
expect(i).toHaveClass('lumx-icon--color-dark lumx-icon--has-shape');
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it('should set a default color variant on has shape & dark color', () => {
|
|
108
|
+
const { i } = setup({ color: ColorPalette.dark, hasShape: true });
|
|
109
|
+
expect(i).toHaveClass('lumx-icon--color-variant-L2 lumx-icon--color-dark lumx-icon--has-shape');
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
});
|
|
32
113
|
|
|
33
114
|
// Common tests suite.
|
|
34
115
|
commonTestsSuiteRTL(setup, {
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
1
|
import { commonTestsSuiteRTL } from '@lumx/react/testing/utils';
|
|
4
|
-
import { render, within, screen } from '@testing-library/react';
|
|
2
|
+
import { render, within, screen, waitFor } from '@testing-library/react';
|
|
5
3
|
import { getByClassName, queryByClassName } from '@lumx/react/testing/utils/queries';
|
|
6
4
|
import userEvent from '@testing-library/user-event';
|
|
7
5
|
import { useImageSize } from '@lumx/react/hooks/useImageSize';
|
|
@@ -18,8 +16,8 @@ import Meta, {
|
|
|
18
16
|
WithMosaicTrigger,
|
|
19
17
|
} from './ImageLightbox.stories';
|
|
20
18
|
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
vi.mock('@lumx/react/hooks/useImageSize');
|
|
20
|
+
vi.mock('@lumx/react/hooks/useSizeOnWindowResize');
|
|
23
21
|
|
|
24
22
|
const CLASSNAME = ImageLightbox.className as string;
|
|
25
23
|
const baseProps = Meta.args;
|
|
@@ -56,7 +54,7 @@ const queries = {
|
|
|
56
54
|
describe(`<${ImageLightbox.displayName}>`, () => {
|
|
57
55
|
beforeEach(() => {
|
|
58
56
|
(useImageSize as any).mockReturnValue(null);
|
|
59
|
-
(useSizeOnWindowResize as any).mockReturnValue([null,
|
|
57
|
+
(useSizeOnWindowResize as any).mockReturnValue([null, vi.fn()]);
|
|
60
58
|
});
|
|
61
59
|
|
|
62
60
|
describe('render', () => {
|
|
@@ -159,7 +157,9 @@ describe(`<${ImageLightbox.displayName}>`, () => {
|
|
|
159
157
|
|
|
160
158
|
// Close on escape
|
|
161
159
|
await userEvent.keyboard('{escape}');
|
|
162
|
-
|
|
160
|
+
await waitFor(() => {
|
|
161
|
+
expect(imageLightbox).not.toBeInTheDocument();
|
|
162
|
+
});
|
|
163
163
|
|
|
164
164
|
// Focus moved back to the trigger button
|
|
165
165
|
expect(buttonTrigger).toHaveFocus();
|
|
@@ -185,7 +185,9 @@ describe(`<${ImageLightbox.displayName}>`, () => {
|
|
|
185
185
|
|
|
186
186
|
// Close on escape
|
|
187
187
|
await userEvent.keyboard('{escape}');
|
|
188
|
-
|
|
188
|
+
await waitFor(() => {
|
|
189
|
+
expect(imageLightbox).not.toBeInTheDocument();
|
|
190
|
+
});
|
|
189
191
|
|
|
190
192
|
// Focus moved back to the trigger button
|
|
191
193
|
expect(buttonTrigger).toHaveFocus();
|
|
@@ -196,7 +198,7 @@ describe(`<${ImageLightbox.displayName}>`, () => {
|
|
|
196
198
|
const scrollAreaSize = { width: 600, height: 600 };
|
|
197
199
|
beforeEach(() => {
|
|
198
200
|
(useImageSize as any).mockImplementation((_: any, getInitialSize: any) => getInitialSize?.() || null);
|
|
199
|
-
(useSizeOnWindowResize as any).mockReturnValue([scrollAreaSize,
|
|
201
|
+
(useSizeOnWindowResize as any).mockReturnValue([scrollAreaSize, vi.fn()]);
|
|
200
202
|
});
|
|
201
203
|
|
|
202
204
|
it('should use the image initial size', () => {
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
1
|
import type { IconButtonProps, LightboxProps, SlideshowProps, ThumbnailProps } from '@lumx/react';
|
|
4
2
|
import type { HasClassName } from '@lumx/react/utils/type';
|
|
5
3
|
import type { ImageCaptionMetadata } from '@lumx/react/components/image-block/ImageCaption';
|