@lumx/react 3.20.1-alpha.4 → 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
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
} from '@lumx/react';
|
|
11
11
|
import cloneDeep from 'lodash/cloneDeep';
|
|
12
12
|
import set from 'lodash/set';
|
|
13
|
-
import
|
|
13
|
+
import { useState } from 'react';
|
|
14
14
|
|
|
15
15
|
export default { title: 'LumX components/progress-tracker/Progress Tracker' };
|
|
16
16
|
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
1
|
import { commonTestsSuiteRTL, SetupRenderOptions } from '@lumx/react/testing/utils';
|
|
4
2
|
import { getByClassName, getByTagName, queryByClassName } from '@lumx/react/testing/utils/queries';
|
|
5
3
|
import { render } from '@testing-library/react';
|
|
@@ -86,7 +84,7 @@ describe(`<${RadioButton.displayName}>`, () => {
|
|
|
86
84
|
});
|
|
87
85
|
|
|
88
86
|
describe('Events', () => {
|
|
89
|
-
const onChange =
|
|
87
|
+
const onChange = vi.fn();
|
|
90
88
|
|
|
91
89
|
it('should trigger `onChange` when radioButton is clicked', async () => {
|
|
92
90
|
const value = 'value';
|
|
@@ -102,7 +100,7 @@ describe(`<${RadioButton.displayName}>`, () => {
|
|
|
102
100
|
|
|
103
101
|
describe('Disabled state', () => {
|
|
104
102
|
it('should be disabled with isDisabled', async () => {
|
|
105
|
-
const onChange =
|
|
103
|
+
const onChange = vi.fn();
|
|
106
104
|
const { radioButton, input } = setup({ isDisabled: true, onChange });
|
|
107
105
|
|
|
108
106
|
expect(radioButton).toHaveClass('lumx-radio-button--is-disabled');
|
|
@@ -115,7 +113,7 @@ describe(`<${RadioButton.displayName}>`, () => {
|
|
|
115
113
|
});
|
|
116
114
|
|
|
117
115
|
it('should be disabled with aria-disabled', async () => {
|
|
118
|
-
const onChange =
|
|
116
|
+
const onChange = vi.fn();
|
|
119
117
|
const { radioButton, input } = setup({ 'aria-disabled': true, onChange });
|
|
120
118
|
|
|
121
119
|
expect(radioButton).toHaveClass('lumx-radio-button--is-disabled');
|
|
@@ -3,7 +3,7 @@ import { List, ListItem, Select, Size, TextField } from '@lumx/react';
|
|
|
3
3
|
import { useBooleanState } from '@lumx/react/hooks/useBooleanState';
|
|
4
4
|
import noop from 'lodash/noop';
|
|
5
5
|
import range from 'lodash/range';
|
|
6
|
-
import
|
|
6
|
+
import { SyntheticEvent, useState } from 'react';
|
|
7
7
|
import { SelectVariant } from './constants';
|
|
8
8
|
|
|
9
9
|
export default {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { Mock } from 'vitest';
|
|
3
2
|
import { Theme } from '@lumx/core/js/constants';
|
|
4
3
|
import { Chip } from '@lumx/react/components/chip/Chip';
|
|
5
4
|
import { Dropdown } from '@lumx/react/components/dropdown/Dropdown';
|
|
@@ -13,8 +12,8 @@ import { Select, SelectProps, SelectVariant } from './Select';
|
|
|
13
12
|
|
|
14
13
|
const CLASSNAME = Select.className as string;
|
|
15
14
|
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
vi.mock('@lumx/react/utils/browser/isFocusVisible');
|
|
16
|
+
vi.mock('@lumx/react/hooks/useId', () => ({ useId: () => ':r1:' }));
|
|
18
17
|
|
|
19
18
|
/**
|
|
20
19
|
* Mounts the component and returns common DOM elements / data needed in multiple tests further down.
|
|
@@ -35,7 +34,7 @@ const setup = (propsOverride: Partial<SelectProps> = {}, { wrapper }: SetupRende
|
|
|
35
34
|
};
|
|
36
35
|
|
|
37
36
|
describe(`<${Select.displayName}>`, () => {
|
|
38
|
-
(isFocusVisible as
|
|
37
|
+
(isFocusVisible as Mock).mockReturnValue(false);
|
|
39
38
|
|
|
40
39
|
describe('Props', () => {
|
|
41
40
|
it('should have default classNames', () => {
|
|
@@ -144,7 +143,7 @@ describe(`<${Select.displayName}>`, () => {
|
|
|
144
143
|
|
|
145
144
|
describe('Events', () => {
|
|
146
145
|
it('should trigger `onDropdownClose` on escape', async () => {
|
|
147
|
-
const onDropdownClose =
|
|
146
|
+
const onDropdownClose = vi.fn();
|
|
148
147
|
const { getDropdown } = setup({ isOpen: true, onDropdownClose });
|
|
149
148
|
|
|
150
149
|
const dropdown = getDropdown();
|
|
@@ -156,7 +155,7 @@ describe(`<${Select.displayName}>`, () => {
|
|
|
156
155
|
|
|
157
156
|
describe('should trigger `onInputClick` when the select button is clicked', () => {
|
|
158
157
|
it('with input variant', async () => {
|
|
159
|
-
const onClick =
|
|
158
|
+
const onClick = vi.fn();
|
|
160
159
|
const { inputWrapper } = setup({ onInputClick: onClick, variant: SelectVariant.input });
|
|
161
160
|
|
|
162
161
|
await userEvent.click(inputWrapper as any);
|
|
@@ -164,7 +163,7 @@ describe(`<${Select.displayName}>`, () => {
|
|
|
164
163
|
});
|
|
165
164
|
|
|
166
165
|
it('with chip variant', async () => {
|
|
167
|
-
const onClick =
|
|
166
|
+
const onClick = vi.fn();
|
|
168
167
|
const { chip } = setup({ onInputClick: onClick, variant: SelectVariant.chip });
|
|
169
168
|
|
|
170
169
|
await userEvent.click(chip as any);
|
|
@@ -174,7 +173,7 @@ describe(`<${Select.displayName}>`, () => {
|
|
|
174
173
|
|
|
175
174
|
it('should call onClear when clear icon is clicked in select input', async () => {
|
|
176
175
|
const value = 'Value';
|
|
177
|
-
const onClear =
|
|
176
|
+
const onClear = vi.fn();
|
|
178
177
|
const { select, props } = setup({ value, onClear, clearButtonProps: { label: 'Clear' } });
|
|
179
178
|
|
|
180
179
|
const clearButton = within(select).getByRole('button', { name: props.clearButtonProps?.label });
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
} from '@lumx/react';
|
|
15
15
|
import { useBooleanState } from '@lumx/react/hooks/useBooleanState';
|
|
16
16
|
import noop from 'lodash/noop';
|
|
17
|
-
import
|
|
17
|
+
import { MouseEventHandler, SyntheticEvent, useRef, useState } from 'react';
|
|
18
18
|
import { SelectVariant } from './constants';
|
|
19
19
|
|
|
20
20
|
export default { title: 'LumX components/select/Select Multiple' };
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
1
|
import { Theme } from '@lumx/core/js/constants';
|
|
4
2
|
import { Chip } from '@lumx/react/components/chip/Chip';
|
|
5
3
|
import { Dropdown } from '@lumx/react/components/dropdown/Dropdown';
|
|
@@ -18,7 +16,7 @@ import { SelectVariant } from './constants';
|
|
|
18
16
|
|
|
19
17
|
const CLASSNAME = SelectMultiple.className as string;
|
|
20
18
|
|
|
21
|
-
|
|
19
|
+
vi.mock('@lumx/react/hooks/useId', () => ({ useId: () => ':r1:' }));
|
|
22
20
|
|
|
23
21
|
/**
|
|
24
22
|
* Mounts the component and returns common DOM elements / data needed in multiple tests further down.
|
|
@@ -144,7 +142,7 @@ describe('<SelectMultiple>', () => {
|
|
|
144
142
|
describe('Events', () => {
|
|
145
143
|
describe('should trigger `onInputClick` when the select button is clicked', () => {
|
|
146
144
|
it('with input variant', async () => {
|
|
147
|
-
const onClick =
|
|
145
|
+
const onClick = vi.fn();
|
|
148
146
|
const { inputWrapper } = setup({ onInputClick: onClick, variant: SelectVariant.input });
|
|
149
147
|
|
|
150
148
|
await userEvent.click(inputWrapper as any);
|
|
@@ -152,7 +150,7 @@ describe('<SelectMultiple>', () => {
|
|
|
152
150
|
});
|
|
153
151
|
|
|
154
152
|
it('with chip variant', async () => {
|
|
155
|
-
const onClick =
|
|
153
|
+
const onClick = vi.fn();
|
|
156
154
|
const { chip } = setup({ onInputClick: onClick, variant: SelectVariant.chip });
|
|
157
155
|
|
|
158
156
|
await userEvent.click(chip as any);
|
|
@@ -161,7 +159,7 @@ describe('<SelectMultiple>', () => {
|
|
|
161
159
|
});
|
|
162
160
|
|
|
163
161
|
it('should call onClear when an item is clicked with the correct value', async () => {
|
|
164
|
-
const onClear =
|
|
162
|
+
const onClear = vi.fn();
|
|
165
163
|
const { valueChips } = setup({
|
|
166
164
|
onClear,
|
|
167
165
|
value: ['val 1', 'val 2'],
|
|
@@ -184,7 +182,7 @@ describe('<SelectMultiple>', () => {
|
|
|
184
182
|
const value1 = 'Value 1';
|
|
185
183
|
const value2 = 'Value 2';
|
|
186
184
|
|
|
187
|
-
const onClear =
|
|
185
|
+
const onClear = vi.fn();
|
|
188
186
|
const { chip } = setup({
|
|
189
187
|
onClear,
|
|
190
188
|
value: [value1, value2],
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
1
|
import { getAllByClassName, queryAllByClassName } from '@lumx/react/testing/utils/queries';
|
|
4
2
|
import { render, screen } from '@testing-library/react';
|
|
5
3
|
import { commonTestsSuiteRTL } from '@lumx/react/testing/utils';
|
|
@@ -10,7 +8,7 @@ const CLASSNAME = SideNavigationItem.className as string;
|
|
|
10
8
|
|
|
11
9
|
const toggleButtonProps = { label: 'Toggle' };
|
|
12
10
|
|
|
13
|
-
|
|
11
|
+
vi.mock('@lumx/react/hooks/useId', () => ({ useId: () => ':r1:' }));
|
|
14
12
|
|
|
15
13
|
/**
|
|
16
14
|
* Mounts the component and returns common DOM elements / data needed in multiple tests further down.
|
|
@@ -106,7 +104,7 @@ describe(`<${SideNavigationItem.displayName}>`, () => {
|
|
|
106
104
|
|
|
107
105
|
describe('children and link', () => {
|
|
108
106
|
it('should render with children and link', () => {
|
|
109
|
-
const onActionClick =
|
|
107
|
+
const onActionClick = vi.fn();
|
|
110
108
|
const label = 'Side navigation item';
|
|
111
109
|
const { props, toggle, link } = setup({
|
|
112
110
|
label,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Children, ReactNode } from 'react';
|
|
2
2
|
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
import isEmpty from 'lodash/isEmpty';
|
|
@@ -7,10 +7,9 @@ import { mdiChevronDown, mdiChevronUp } from '@lumx/icons';
|
|
|
7
7
|
import { Emphasis, Icon, Size, IconButton, IconButtonProps } from '@lumx/react';
|
|
8
8
|
import { GenericProps, HasCloseMode, isComponent } from '@lumx/react/utils/type';
|
|
9
9
|
import { getRootClassName, handleBasicClasses } from '@lumx/core/js/utils/className';
|
|
10
|
-
import { renderLink } from '@lumx/react/utils/react/renderLink';
|
|
11
|
-
import { renderButtonOrLink } from '@lumx/react/utils/react/renderButtonOrLink';
|
|
12
10
|
import { useId } from '@lumx/react/hooks/useId';
|
|
13
11
|
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
12
|
+
import { RawClickable } from '@lumx/react/utils/react/RawClickable';
|
|
14
13
|
|
|
15
14
|
/**
|
|
16
15
|
* Defines the props of the component.
|
|
@@ -113,17 +112,15 @@ export const SideNavigationItem = forwardRef<SideNavigationItemProps, HTMLLIElem
|
|
|
113
112
|
>
|
|
114
113
|
{shouldSplitActions ? (
|
|
115
114
|
<div className={`${CLASSNAME}__wrapper`}>
|
|
116
|
-
|
|
117
|
-
{
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
<span>{label}</span>,
|
|
126
|
-
)}
|
|
115
|
+
<RawClickable
|
|
116
|
+
as={linkAs || (linkProps?.href ? 'a' : 'button')}
|
|
117
|
+
{...(linkProps as any)}
|
|
118
|
+
className={`${CLASSNAME}__link`}
|
|
119
|
+
onClick={onClick}
|
|
120
|
+
>
|
|
121
|
+
{icon && <Icon className={`${CLASSNAME}__icon`} icon={icon} size={Size.xs} />}
|
|
122
|
+
<span>{label}</span>
|
|
123
|
+
</RawClickable>
|
|
127
124
|
|
|
128
125
|
<IconButton
|
|
129
126
|
{...toggleButtonProps}
|
|
@@ -136,25 +133,23 @@ export const SideNavigationItem = forwardRef<SideNavigationItemProps, HTMLLIElem
|
|
|
136
133
|
/>
|
|
137
134
|
</div>
|
|
138
135
|
) : (
|
|
139
|
-
|
|
140
|
-
{
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
<span>{label}</span>,
|
|
150
|
-
hasContent && (
|
|
136
|
+
<RawClickable
|
|
137
|
+
as={linkAs || (linkProps?.href ? 'a' : 'button')}
|
|
138
|
+
{...linkProps}
|
|
139
|
+
className={`${CLASSNAME}__link`}
|
|
140
|
+
onClick={onClick}
|
|
141
|
+
{...ariaProps}
|
|
142
|
+
>
|
|
143
|
+
{icon && <Icon className={`${CLASSNAME}__icon`} icon={icon} size={Size.xs} />}
|
|
144
|
+
<span>{label}</span>
|
|
145
|
+
{hasContent && (
|
|
151
146
|
<Icon
|
|
152
147
|
className={`${CLASSNAME}__chevron`}
|
|
153
148
|
icon={isOpen ? mdiChevronUp : mdiChevronDown}
|
|
154
149
|
size={Size.xs}
|
|
155
150
|
/>
|
|
156
|
-
)
|
|
157
|
-
|
|
151
|
+
)}
|
|
152
|
+
</RawClickable>
|
|
158
153
|
)}
|
|
159
154
|
|
|
160
155
|
{(closeMode === 'hide' || showChildren) && (
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
1
|
import { commonTestsSuiteRTL, SetupRenderOptions } from '@lumx/react/testing/utils';
|
|
4
2
|
import { render } from '@testing-library/react';
|
|
5
3
|
import { queryByClassName } from '@lumx/react/testing/utils/queries';
|
|
@@ -7,7 +5,7 @@ import { Slider, SliderProps } from './Slider';
|
|
|
7
5
|
|
|
8
6
|
const CLASSNAME = Slider.className as string;
|
|
9
7
|
|
|
10
|
-
|
|
8
|
+
vi.mock('@lumx/react/hooks/useId', () => ({ useId: () => ':r1:' }));
|
|
11
9
|
|
|
12
10
|
const setup = (props: Partial<SliderProps> = {}, { wrapper }: SetupRenderOptions = {}) => {
|
|
13
11
|
render(<Slider {...(props as any)} />, { wrapper });
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
1
|
import { commonTestsSuiteRTL, SetupRenderOptions } from '@lumx/react/testing/utils';
|
|
4
2
|
import { render } from '@testing-library/react';
|
|
5
3
|
import { getByClassName, getByTagName, queryByClassName } from '@lumx/react/testing/utils/queries';
|
|
6
|
-
import userEvent from '@testing-library/user-event
|
|
4
|
+
import userEvent from '@testing-library/user-event';
|
|
7
5
|
|
|
8
6
|
import { Switch, SwitchProps } from './Switch';
|
|
9
7
|
|
|
@@ -24,7 +22,7 @@ const setup = (propsOverride: SetupProps = {}, { wrapper }: SetupRenderOptions =
|
|
|
24
22
|
return { switchWrapper, input, helper, label, props };
|
|
25
23
|
};
|
|
26
24
|
|
|
27
|
-
|
|
25
|
+
vi.mock('@lumx/react/hooks/useId', () => ({ useId: () => ':r1:' }));
|
|
28
26
|
|
|
29
27
|
describe(`<${Switch.displayName}>`, () => {
|
|
30
28
|
describe('Props', () => {
|
|
@@ -86,7 +84,7 @@ describe(`<${Switch.displayName}>`, () => {
|
|
|
86
84
|
});
|
|
87
85
|
|
|
88
86
|
describe('Events', () => {
|
|
89
|
-
const onChange =
|
|
87
|
+
const onChange = vi.fn();
|
|
90
88
|
|
|
91
89
|
it('should trigger `onChange` when switchWrapper is clicked', async () => {
|
|
92
90
|
const value = 'value';
|
|
@@ -102,7 +100,7 @@ describe(`<${Switch.displayName}>`, () => {
|
|
|
102
100
|
|
|
103
101
|
describe('Disabled state', () => {
|
|
104
102
|
it('should be disabled with isDisabled', async () => {
|
|
105
|
-
const onChange =
|
|
103
|
+
const onChange = vi.fn();
|
|
106
104
|
const { switchWrapper, input } = setup({ isDisabled: true, onChange });
|
|
107
105
|
|
|
108
106
|
expect(switchWrapper).toHaveClass('lumx-switch--is-disabled');
|
|
@@ -115,7 +113,7 @@ describe(`<${Switch.displayName}>`, () => {
|
|
|
115
113
|
});
|
|
116
114
|
|
|
117
115
|
it('should be disabled with aria-disabled', async () => {
|
|
118
|
-
const onChange =
|
|
116
|
+
const onChange = vi.fn();
|
|
119
117
|
const { switchWrapper, input } = setup({ 'aria-disabled': true, onChange });
|
|
120
118
|
|
|
121
119
|
expect(switchWrapper).toHaveClass('lumx-switch--is-disabled');
|