@lumx/react 3.10.0 → 3.10.1-alpha.1
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.d.ts +1 -1
- package/index.d.ts +24 -16
- package/index.js +313 -293
- package/index.js.map +1 -1
- package/package.json +3 -3
- package/src/components/alert-dialog/AlertDialog.tsx +3 -4
- package/src/components/autocomplete/Autocomplete.test.tsx +9 -2
- package/src/components/autocomplete/Autocomplete.tsx +7 -4
- package/src/components/autocomplete/AutocompleteMultiple.test.tsx +9 -2
- package/src/components/autocomplete/AutocompleteMultiple.tsx +10 -7
- package/src/components/avatar/Avatar.test.tsx +14 -4
- package/src/components/avatar/Avatar.tsx +7 -5
- package/src/components/badge/Badge.tsx +7 -4
- package/src/components/badge/BadgeWrapper.tsx +7 -4
- package/src/components/button/Button.test.tsx +9 -3
- package/src/components/button/Button.tsx +8 -5
- package/src/components/button/ButtonGroup.tsx +4 -3
- package/src/components/button/ButtonRoot.tsx +4 -3
- package/src/components/button/IconButton.test.tsx +9 -3
- package/src/components/button/IconButton.tsx +16 -5
- package/src/components/checkbox/Checkbox.test.tsx +9 -3
- package/src/components/checkbox/Checkbox.tsx +8 -7
- package/src/components/chip/Chip.test.tsx +14 -4
- package/src/components/chip/Chip.tsx +11 -11
- package/src/components/chip/ChipGroup.tsx +5 -4
- package/src/components/comment-block/CommentBlock.test.tsx +9 -3
- package/src/components/comment-block/CommentBlock.tsx +7 -6
- package/src/components/date-picker/DatePicker.tsx +5 -3
- package/src/components/date-picker/DatePickerControlled.tsx +6 -3
- package/src/components/date-picker/DatePickerField.test.tsx +9 -3
- package/src/components/date-picker/DatePickerField.tsx +4 -3
- package/src/components/dialog/Dialog.test.tsx +17 -4
- package/src/components/dialog/Dialog.tsx +65 -61
- package/src/components/divider/Divider.test.tsx +9 -3
- package/src/components/divider/Divider.tsx +8 -7
- package/src/components/drag-handle/DragHandle.test.tsx +38 -0
- package/src/components/drag-handle/DragHandle.tsx +7 -4
- package/src/components/dropdown/Dropdown.tsx +4 -3
- package/src/components/expansion-panel/ExpansionPanel.test.tsx +12 -3
- package/src/components/expansion-panel/ExpansionPanel.tsx +8 -7
- package/src/components/flag/Flag.test.tsx +14 -4
- package/src/components/flag/Flag.tsx +9 -7
- package/src/components/flex-box/FlexBox.tsx +8 -5
- package/src/components/generic-block/GenericBlock.tsx +4 -1
- package/src/components/grid/Grid.tsx +4 -3
- package/src/components/grid/GridItem.tsx +4 -3
- package/src/components/grid-column/GridColumn.tsx +5 -5
- package/src/components/heading/Heading.tsx +8 -4
- package/src/components/icon/Icon.test.tsx +13 -4
- package/src/components/icon/Icon.tsx +18 -5
- package/src/components/image-block/ImageBlock.test.tsx +12 -4
- package/src/components/image-block/ImageBlock.tsx +7 -5
- package/src/components/image-lightbox/ImageLightbox.tsx +4 -3
- package/src/components/inline-list/InlineList.tsx +4 -3
- package/src/components/input-helper/InputHelper.test.tsx +14 -4
- package/src/components/input-helper/InputHelper.tsx +10 -6
- package/src/components/input-label/InputLabel.test.tsx +14 -4
- package/src/components/input-label/InputLabel.tsx +11 -8
- package/src/components/lightbox/Lightbox.test.tsx +17 -6
- package/src/components/lightbox/Lightbox.tsx +12 -8
- package/src/components/link/Link.tsx +4 -3
- package/src/components/link-preview/LinkPreview.test.tsx +9 -3
- package/src/components/link-preview/LinkPreview.tsx +7 -5
- package/src/components/list/List.tsx +7 -5
- package/src/components/list/ListDivider.tsx +4 -3
- package/src/components/list/ListItem.tsx +4 -3
- package/src/components/list/ListSubheader.tsx +4 -3
- package/src/components/message/Message.tsx +7 -4
- package/src/components/mosaic/Mosaic.test.tsx +9 -3
- package/src/components/mosaic/Mosaic.tsx +11 -9
- package/src/components/navigation/Navigation.test.tsx +18 -9
- package/src/components/navigation/Navigation.tsx +13 -5
- package/src/components/navigation/NavigationItem.tsx +4 -4
- package/src/components/navigation/NavigationSection.test.tsx +19 -6
- package/src/components/navigation/NavigationSection.tsx +4 -4
- package/src/components/notification/Notification.tsx +7 -8
- package/src/components/popover/Popover.test.tsx +18 -4
- package/src/components/popover/Popover.tsx +5 -3
- package/src/components/popover-dialog/PopoverDialog.tsx +5 -3
- package/src/components/post-block/PostBlock.test.tsx +9 -3
- package/src/components/post-block/PostBlock.tsx +7 -8
- package/src/components/progress/Progress.tsx +8 -6
- package/src/components/progress/ProgressCircular.test.tsx +9 -16
- package/src/components/progress/ProgressCircular.tsx +7 -6
- package/src/components/progress/ProgressLinear.test.tsx +13 -18
- package/src/components/progress/ProgressLinear.tsx +8 -8
- package/src/components/progress-tracker/ProgressTracker.tsx +5 -3
- package/src/components/progress-tracker/ProgressTrackerStep.tsx +5 -5
- package/src/components/progress-tracker/ProgressTrackerStepPanel.tsx +24 -24
- package/src/components/radio-button/RadioButton.test.tsx +9 -3
- package/src/components/radio-button/RadioButton.tsx +8 -8
- package/src/components/radio-button/RadioGroup.tsx +4 -3
- package/src/components/select/Select.test.tsx +9 -3
- package/src/components/select/Select.tsx +30 -28
- package/src/components/select/SelectMultiple.test.tsx +9 -3
- package/src/components/select/SelectMultiple.tsx +112 -108
- package/src/components/select/WithSelectContext.tsx +8 -6
- package/src/components/side-navigation/SideNavigation.tsx +7 -5
- package/src/components/side-navigation/SideNavigationItem.tsx +4 -5
- package/src/components/skeleton/SkeletonCircle.test.tsx +9 -3
- package/src/components/skeleton/SkeletonCircle.tsx +9 -7
- package/src/components/skeleton/SkeletonRectangle.test.tsx +9 -3
- package/src/components/skeleton/SkeletonRectangle.tsx +8 -5
- package/src/components/skeleton/SkeletonTypography.test.tsx +9 -3
- package/src/components/skeleton/SkeletonTypography.tsx +9 -7
- package/src/components/slider/Slider.test.tsx +9 -3
- package/src/components/slider/Slider.tsx +7 -7
- package/src/components/slideshow/Slides.tsx +9 -5
- package/src/components/slideshow/Slideshow.test.tsx +9 -3
- package/src/components/slideshow/Slideshow.tsx +8 -5
- package/src/components/slideshow/SlideshowControls.tsx +7 -5
- package/src/components/slideshow/SlideshowItem.tsx +4 -3
- package/src/components/slideshow/SlideshowItemGroup.tsx +5 -4
- package/src/components/switch/Switch.test.tsx +9 -3
- package/src/components/switch/Switch.tsx +7 -7
- package/src/components/table/Table.test.tsx +9 -3
- package/src/components/table/Table.tsx +8 -8
- package/src/components/table/TableBody.tsx +4 -3
- package/src/components/table/TableCell.tsx +5 -5
- package/src/components/table/TableHeader.tsx +4 -3
- package/src/components/table/TableRow.tsx +4 -3
- package/src/components/tabs/Tab.tsx +4 -3
- package/src/components/tabs/TabList.test.tsx +9 -3
- package/src/components/tabs/TabList.tsx +18 -6
- package/src/components/tabs/TabPanel.tsx +7 -5
- package/src/components/text/Text.tsx +6 -4
- package/src/components/text-field/TextField.test.tsx +9 -3
- package/src/components/text-field/TextField.tsx +7 -5
- package/src/components/thumbnail/Thumbnail.test.tsx +9 -3
- package/src/components/thumbnail/Thumbnail.tsx +8 -7
- package/src/components/toolbar/Toolbar.tsx +4 -3
- package/src/components/tooltip/Tooltip.tsx +4 -3
- package/src/components/uploader/Uploader.test.tsx +9 -3
- package/src/components/uploader/Uploader.tsx +18 -5
- package/src/components/user-block/UserBlock.test.tsx +9 -3
- package/src/components/user-block/UserBlock.tsx +9 -6
- package/src/index.ts +1 -0
- package/src/testing/utils/ThemeSentinel.tsx +11 -0
- package/src/testing/utils/commonTestsSuiteRTL.tsx +191 -0
- package/src/utils/react/forwardRef.ts +10 -0
- package/src/utils/react/forwardRefPolymorphic.ts +10 -0
- package/src/utils/theme/ThemeContext.ts +16 -0
- package/src/utils/theme/invertTheme.ts +4 -0
- package/src/testing/utils/commonTestsSuiteRTL.ts +0 -64
- package/src/utils/ThemeContext.ts +0 -4
- package/src/utils/forwardRefPolymorphic.ts +0 -9
package/package.json
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
"url": "https://github.com/lumapps/design-system/issues"
|
|
7
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@lumx/core": "^3.10.
|
|
10
|
-
"@lumx/icons": "^3.10.
|
|
9
|
+
"@lumx/core": "^3.10.1-alpha.1",
|
|
10
|
+
"@lumx/icons": "^3.10.1-alpha.1",
|
|
11
11
|
"@popperjs/core": "^2.5.4",
|
|
12
12
|
"body-scroll-lock": "^3.1.5",
|
|
13
13
|
"classnames": "^2.3.2",
|
|
@@ -110,5 +110,5 @@
|
|
|
110
110
|
"build:storybook": "storybook build"
|
|
111
111
|
},
|
|
112
112
|
"sideEffects": false,
|
|
113
|
-
"version": "3.10.
|
|
113
|
+
"version": "3.10.1-alpha.1"
|
|
114
114
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
|
|
@@ -14,11 +14,10 @@ import {
|
|
|
14
14
|
Toolbar,
|
|
15
15
|
ButtonProps,
|
|
16
16
|
} from '@lumx/react';
|
|
17
|
-
|
|
18
17
|
import { mdiAlert, mdiAlertCircle, mdiCheckCircle, mdiInformation } from '@lumx/icons';
|
|
19
|
-
import { Comp } from '@lumx/react/utils/type';
|
|
20
18
|
import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
|
|
21
19
|
import { useId } from '@lumx/react/hooks/useId';
|
|
20
|
+
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
22
21
|
|
|
23
22
|
export interface AlertDialogProps extends Omit<DialogProps, 'header' | 'footer'> {
|
|
24
23
|
/** Message variant. */
|
|
@@ -77,7 +76,7 @@ const DEFAULT_PROPS: Partial<DialogProps> = {
|
|
|
77
76
|
* It should not have a complex content.
|
|
78
77
|
* Children of this component should only be strings, paragraphs or links.
|
|
79
78
|
*/
|
|
80
|
-
export const AlertDialog
|
|
79
|
+
export const AlertDialog = forwardRef<AlertDialogProps, HTMLDivElement>((props, ref) => {
|
|
81
80
|
const { id, title, className, cancelProps, confirmProps, kind, size, dialogProps, children, ...forwardedProps } =
|
|
82
81
|
props;
|
|
83
82
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
3
|
import { Dropdown, List, ListItem, Size, TextField } from '@lumx/react';
|
|
4
|
-
import { commonTestsSuiteRTL } from '@lumx/react/testing/utils';
|
|
4
|
+
import { commonTestsSuiteRTL, SetupRenderOptions } from '@lumx/react/testing/utils';
|
|
5
5
|
import { getByClassName, getByTagName, queryByClassName } from '@lumx/react/testing/utils/queries';
|
|
6
6
|
import { render } from '@testing-library/react';
|
|
7
7
|
import userEvent from '@testing-library/user-event';
|
|
@@ -14,7 +14,7 @@ const CLASSNAME = Autocomplete.className as string;
|
|
|
14
14
|
/**
|
|
15
15
|
* Mounts the component and returns common DOM elements / data needed in multiple tests further down.
|
|
16
16
|
*/
|
|
17
|
-
const setup = (props: Partial<AutocompleteProps> = {}) => {
|
|
17
|
+
const setup = (props: Partial<AutocompleteProps> = {}, { wrapper }: SetupRenderOptions = {}) => {
|
|
18
18
|
render(
|
|
19
19
|
<Autocomplete {...(props as any)}>
|
|
20
20
|
<List>
|
|
@@ -25,6 +25,7 @@ const setup = (props: Partial<AutocompleteProps> = {}) => {
|
|
|
25
25
|
))}
|
|
26
26
|
</List>
|
|
27
27
|
</Autocomplete>,
|
|
28
|
+
{ wrapper },
|
|
28
29
|
);
|
|
29
30
|
const autocomplete = getByClassName(document.body, CLASSNAME);
|
|
30
31
|
const textField = getByClassName(autocomplete, TextField.className as string);
|
|
@@ -90,5 +91,11 @@ describe(`<${Autocomplete.displayName}>`, () => {
|
|
|
90
91
|
forwardClassName: 'autocomplete',
|
|
91
92
|
forwardAttributes: 'autocomplete',
|
|
92
93
|
forwardRef: 'autocomplete',
|
|
94
|
+
applyTheme: {
|
|
95
|
+
affects: [{ element: 'textField' }],
|
|
96
|
+
viaProp: true,
|
|
97
|
+
viaContext: true,
|
|
98
|
+
defaultTheme: 'light',
|
|
99
|
+
},
|
|
93
100
|
});
|
|
94
101
|
});
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { ReactNode, SyntheticEvent, useRef } from 'react';
|
|
2
2
|
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
|
|
5
5
|
import { Dropdown, DropdownProps, IconButtonProps, Offset, Placement, TextField, TextFieldProps } from '@lumx/react';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { GenericProps, HasTheme } from '@lumx/react/utils/type';
|
|
8
8
|
import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
|
|
9
9
|
import { useFocus } from '@lumx/react/hooks/useFocus';
|
|
10
10
|
import { mergeRefs } from '@lumx/react/utils/mergeRefs';
|
|
11
|
+
import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
|
|
12
|
+
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
11
13
|
|
|
12
14
|
/**
|
|
13
15
|
* Defines the props of the component.
|
|
@@ -199,7 +201,8 @@ const DEFAULT_PROPS: Partial<AutocompleteProps> = {
|
|
|
199
201
|
* @param ref Component ref.
|
|
200
202
|
* @return React element.
|
|
201
203
|
*/
|
|
202
|
-
export const Autocomplete
|
|
204
|
+
export const Autocomplete = forwardRef<AutocompleteProps, HTMLDivElement>((props, ref) => {
|
|
205
|
+
const defaultTheme = useTheme();
|
|
203
206
|
const {
|
|
204
207
|
anchorToInput,
|
|
205
208
|
children,
|
|
@@ -231,7 +234,7 @@ export const Autocomplete: Comp<AutocompleteProps, HTMLDivElement> = forwardRef(
|
|
|
231
234
|
placeholder,
|
|
232
235
|
placement,
|
|
233
236
|
shouldFocusOnClose,
|
|
234
|
-
theme,
|
|
237
|
+
theme = defaultTheme,
|
|
235
238
|
value,
|
|
236
239
|
textFieldProps = {},
|
|
237
240
|
focusAnchorOnClose,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
3
|
import { Dropdown, List, ListItem, Size, TextField } from '@lumx/react';
|
|
4
|
-
import { commonTestsSuiteRTL } from '@lumx/react/testing/utils';
|
|
4
|
+
import { commonTestsSuiteRTL, SetupRenderOptions } from '@lumx/react/testing/utils';
|
|
5
5
|
import { getByClassName, queryByClassName } from '@lumx/react/testing/utils/queries';
|
|
6
6
|
import { render } from '@testing-library/react';
|
|
7
7
|
|
|
@@ -13,7 +13,7 @@ const CLASSNAME = AutocompleteMultiple.className as string;
|
|
|
13
13
|
/**
|
|
14
14
|
* Mounts the component and returns common DOM elements / data needed in multiple tests further down.
|
|
15
15
|
*/
|
|
16
|
-
const setup = (props: Partial<AutocompleteMultipleProps> = {}) => {
|
|
16
|
+
const setup = (props: Partial<AutocompleteMultipleProps> = {}, { wrapper }: SetupRenderOptions = {}) => {
|
|
17
17
|
render(
|
|
18
18
|
<AutocompleteMultiple {...(props as any)}>
|
|
19
19
|
<List>
|
|
@@ -24,6 +24,7 @@ const setup = (props: Partial<AutocompleteMultipleProps> = {}) => {
|
|
|
24
24
|
))}
|
|
25
25
|
</List>
|
|
26
26
|
</AutocompleteMultiple>,
|
|
27
|
+
{ wrapper },
|
|
27
28
|
);
|
|
28
29
|
const autocompleteMultiple = getByClassName(document.body, CLASSNAME);
|
|
29
30
|
const textField = getByClassName(autocompleteMultiple, TextField.className as string);
|
|
@@ -52,5 +53,11 @@ describe(`<${AutocompleteMultiple.displayName}>`, () => {
|
|
|
52
53
|
forwardClassName: 'autocompleteMultiple',
|
|
53
54
|
forwardRef: 'autocompleteMultiple',
|
|
54
55
|
forwardAttributes: 'autocompleteMultiple',
|
|
56
|
+
applyTheme: {
|
|
57
|
+
affects: [{ element: 'textField' }],
|
|
58
|
+
viaProp: true,
|
|
59
|
+
viaContext: true,
|
|
60
|
+
defaultTheme: 'light',
|
|
61
|
+
},
|
|
55
62
|
});
|
|
56
63
|
});
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
|
|
1
5
|
import { mdiClose } from '@lumx/icons';
|
|
2
|
-
import { Autocomplete, AutocompleteProps, Chip, HorizontalAlignment, Icon, Size } from '@lumx/react';
|
|
3
6
|
|
|
4
|
-
import {
|
|
7
|
+
import { Autocomplete, AutocompleteProps, Chip, HorizontalAlignment, Icon, Size } from '@lumx/react';
|
|
5
8
|
import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
|
|
6
|
-
|
|
7
|
-
import
|
|
8
|
-
import React, { forwardRef, ReactNode } from 'react';
|
|
9
|
+
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
10
|
+
import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
|
|
9
11
|
|
|
10
12
|
/**
|
|
11
13
|
* Defines the props of the component.
|
|
@@ -65,7 +67,8 @@ const DEFAULT_PROPS: Partial<AutocompleteMultipleProps> = {
|
|
|
65
67
|
* @param ref Component ref.
|
|
66
68
|
* @return React element.
|
|
67
69
|
*/
|
|
68
|
-
export const AutocompleteMultiple
|
|
70
|
+
export const AutocompleteMultiple = forwardRef<AutocompleteMultipleProps, HTMLDivElement>((props, ref) => {
|
|
71
|
+
const defaultTheme = useTheme();
|
|
69
72
|
const {
|
|
70
73
|
anchorToInput,
|
|
71
74
|
children,
|
|
@@ -99,7 +102,7 @@ export const AutocompleteMultiple: Comp<AutocompleteMultipleProps, HTMLDivElemen
|
|
|
99
102
|
placement,
|
|
100
103
|
selectedChipRender,
|
|
101
104
|
shouldFocusOnClose,
|
|
102
|
-
theme,
|
|
105
|
+
theme = defaultTheme,
|
|
103
106
|
type,
|
|
104
107
|
value,
|
|
105
108
|
values,
|
|
@@ -1,24 +1,34 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
|
-
import { commonTestsSuiteRTL } from '@lumx/react/testing/utils';
|
|
3
|
+
import { commonTestsSuiteRTL, SetupRenderOptions } from '@lumx/react/testing/utils';
|
|
4
4
|
import { render } from '@testing-library/react';
|
|
5
5
|
import { queryByClassName } from '@lumx/react/testing/utils/queries';
|
|
6
6
|
import { Avatar, AvatarProps } from './Avatar';
|
|
7
7
|
|
|
8
8
|
const CLASSNAME = Avatar.className as string;
|
|
9
9
|
|
|
10
|
-
const setup = (propsOverride: Partial<AvatarProps> = {}) => {
|
|
10
|
+
const setup = (propsOverride: Partial<AvatarProps> = {}, { wrapper }: SetupRenderOptions = {}) => {
|
|
11
11
|
const props: AvatarProps = {
|
|
12
12
|
image: 'path/to/avatar/image.png',
|
|
13
13
|
alt: 'Image',
|
|
14
14
|
...propsOverride,
|
|
15
15
|
};
|
|
16
|
-
render(<Avatar {...props}
|
|
16
|
+
render(<Avatar {...props} />, { wrapper });
|
|
17
17
|
const avatar = queryByClassName(document.body, CLASSNAME);
|
|
18
18
|
return { avatar, props };
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
describe(`<${Avatar.displayName}>`, () => {
|
|
22
22
|
// Common tests suite.
|
|
23
|
-
commonTestsSuiteRTL(setup, {
|
|
23
|
+
commonTestsSuiteRTL(setup, {
|
|
24
|
+
baseClassName: CLASSNAME,
|
|
25
|
+
forwardClassName: 'avatar',
|
|
26
|
+
forwardAttributes: 'avatar',
|
|
27
|
+
applyTheme: {
|
|
28
|
+
affects: [{ element: 'avatar' }],
|
|
29
|
+
viaProp: true,
|
|
30
|
+
viaContext: true,
|
|
31
|
+
defaultTheme: 'light',
|
|
32
|
+
},
|
|
33
|
+
});
|
|
24
34
|
});
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { KeyboardEventHandler, MouseEventHandler, ReactElement, ReactNode } from 'react';
|
|
2
2
|
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
|
|
5
5
|
import { AspectRatio, Size, Theme, Thumbnail, ThumbnailProps } from '@lumx/react';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { GenericProps, HasTheme } from '@lumx/react/utils/type';
|
|
8
8
|
import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
|
|
9
|
+
import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
|
|
10
|
+
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
9
11
|
|
|
10
12
|
/**
|
|
11
13
|
* Avatar sizes.
|
|
@@ -56,7 +58,6 @@ const CLASSNAME = getRootClassName(COMPONENT_NAME);
|
|
|
56
58
|
*/
|
|
57
59
|
const DEFAULT_PROPS: Partial<AvatarProps> = {
|
|
58
60
|
size: Size.m,
|
|
59
|
-
theme: Theme.light,
|
|
60
61
|
};
|
|
61
62
|
|
|
62
63
|
/**
|
|
@@ -66,7 +67,8 @@ const DEFAULT_PROPS: Partial<AvatarProps> = {
|
|
|
66
67
|
* @param ref Component ref.
|
|
67
68
|
* @return React element.
|
|
68
69
|
*/
|
|
69
|
-
export const Avatar
|
|
70
|
+
export const Avatar = forwardRef<AvatarProps, HTMLDivElement>((props, ref) => {
|
|
71
|
+
const defaultTheme = useTheme() || Theme.light;
|
|
70
72
|
const {
|
|
71
73
|
actions,
|
|
72
74
|
alt,
|
|
@@ -78,7 +80,7 @@ export const Avatar: Comp<AvatarProps, HTMLDivElement> = forwardRef((props, ref)
|
|
|
78
80
|
onClick,
|
|
79
81
|
onKeyPress,
|
|
80
82
|
size,
|
|
81
|
-
theme,
|
|
83
|
+
theme = defaultTheme,
|
|
82
84
|
thumbnailProps,
|
|
83
85
|
...forwardedProps
|
|
84
86
|
} = props;
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
|
|
1
5
|
import { ColorPalette } from '@lumx/react';
|
|
2
|
-
import {
|
|
6
|
+
import { GenericProps } from '@lumx/react/utils/type';
|
|
3
7
|
import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
|
|
4
|
-
import
|
|
5
|
-
import React, { forwardRef, ReactNode } from 'react';
|
|
8
|
+
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
6
9
|
|
|
7
10
|
/**
|
|
8
11
|
* Defines the props of the component.
|
|
@@ -38,7 +41,7 @@ const DEFAULT_PROPS: Partial<BadgeProps> = {
|
|
|
38
41
|
* @param ref Component ref.
|
|
39
42
|
* @return React element.
|
|
40
43
|
*/
|
|
41
|
-
export const Badge
|
|
44
|
+
export const Badge = forwardRef<BadgeProps, HTMLDivElement>((props, ref) => {
|
|
42
45
|
const { children, className, color, ...forwardedProps } = props;
|
|
43
46
|
return (
|
|
44
47
|
<div
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
import React, { ReactElement, ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
|
|
1
5
|
import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
|
|
2
6
|
import { DEFAULT_PROPS } from '@lumx/react/components/select/WithSelectContext';
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import React, { forwardRef, ReactElement, ReactNode } from 'react';
|
|
7
|
+
import { GenericProps } from '@lumx/react/utils/type';
|
|
8
|
+
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
6
9
|
|
|
7
10
|
export interface BadgeWrapperProps extends GenericProps {
|
|
8
11
|
/** Badge. */
|
|
@@ -21,7 +24,7 @@ const COMPONENT_NAME = 'BadgeWrapper';
|
|
|
21
24
|
*/
|
|
22
25
|
const CLASSNAME = getRootClassName(COMPONENT_NAME);
|
|
23
26
|
|
|
24
|
-
export const BadgeWrapper
|
|
27
|
+
export const BadgeWrapper = forwardRef<BadgeWrapperProps, HTMLDivElement>((props, ref) => {
|
|
25
28
|
const { badge, children, className, ...forwardedProps } = props;
|
|
26
29
|
|
|
27
30
|
return (
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
3
|
import { mdiCheck, mdiPlus } from '@lumx/icons';
|
|
4
|
-
import { commonTestsSuiteRTL } from '@lumx/react/testing/utils';
|
|
4
|
+
import { commonTestsSuiteRTL, SetupRenderOptions } from '@lumx/react/testing/utils';
|
|
5
5
|
import { render, screen, within } from '@testing-library/react';
|
|
6
6
|
import { getByClassName, queryAllByClassName, queryByClassName } from '@lumx/react/testing/utils/queries';
|
|
7
7
|
import { Emphasis, Icon } from '@lumx/react';
|
|
@@ -15,9 +15,9 @@ type SetupProps = Partial<ButtonProps>;
|
|
|
15
15
|
/**
|
|
16
16
|
* Mounts the component and returns common DOM elements / data needed in multiple tests further down.
|
|
17
17
|
*/
|
|
18
|
-
const setup = (propsOverride: SetupProps = {}) => {
|
|
18
|
+
const setup = (propsOverride: SetupProps = {}, { wrapper }: SetupRenderOptions = {}) => {
|
|
19
19
|
const props: any = { ...propsOverride };
|
|
20
|
-
render(<Button {...props}
|
|
20
|
+
render(<Button {...props} />, { wrapper });
|
|
21
21
|
const button = getByClassName(document.body, CLASSNAME);
|
|
22
22
|
const buttonWrapper = queryByClassName(document.body, 'lumx-button-wrapper');
|
|
23
23
|
const icons = queryAllByClassName(button, Icon.className as string);
|
|
@@ -71,5 +71,11 @@ describe(`<${Button.displayName}>`, () => {
|
|
|
71
71
|
forwardClassName: 'button',
|
|
72
72
|
forwardAttributes: 'button',
|
|
73
73
|
forwardRef: 'button',
|
|
74
|
+
applyTheme: {
|
|
75
|
+
affects: [{ element: 'button' }],
|
|
76
|
+
viaProp: true,
|
|
77
|
+
viaContext: true,
|
|
78
|
+
defaultTheme: 'light',
|
|
79
|
+
},
|
|
74
80
|
});
|
|
75
81
|
});
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
2
|
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
import isEmpty from 'lodash/isEmpty';
|
|
5
5
|
|
|
6
6
|
import { Emphasis, Icon, Size, Theme, Text } from '@lumx/react';
|
|
7
|
-
import {
|
|
7
|
+
import { isComponent } from '@lumx/react/utils/type';
|
|
8
8
|
import { getBasicClass, getRootClassName } from '@lumx/react/utils/className';
|
|
9
|
+
import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
|
|
10
|
+
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
11
|
+
|
|
9
12
|
import { BaseButtonProps, ButtonRoot } from './ButtonRoot';
|
|
10
13
|
|
|
11
14
|
/**
|
|
@@ -44,7 +47,6 @@ const CLASSNAME = getRootClassName(COMPONENT_NAME);
|
|
|
44
47
|
const DEFAULT_PROPS: Partial<ButtonProps> = {
|
|
45
48
|
emphasis: Emphasis.high,
|
|
46
49
|
size: Size.m,
|
|
47
|
-
theme: Theme.light,
|
|
48
50
|
};
|
|
49
51
|
|
|
50
52
|
/**
|
|
@@ -54,8 +56,9 @@ const DEFAULT_PROPS: Partial<ButtonProps> = {
|
|
|
54
56
|
* @param ref Component ref.
|
|
55
57
|
* @return React element.
|
|
56
58
|
*/
|
|
57
|
-
export const Button
|
|
58
|
-
const
|
|
59
|
+
export const Button = forwardRef<ButtonProps, HTMLButtonElement | HTMLAnchorElement>((props, ref) => {
|
|
60
|
+
const defaultTheme = useTheme() || Theme.light;
|
|
61
|
+
const { children, className, emphasis, leftIcon, rightIcon, size, theme = defaultTheme, ...forwardedProps } = props;
|
|
59
62
|
|
|
60
63
|
const buttonClassName = classNames(
|
|
61
64
|
className,
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { GenericProps } from '@lumx/react/utils/type';
|
|
6
6
|
import { getRootClassName } from '@lumx/react/utils/className';
|
|
7
|
+
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Defines the props of the component
|
|
@@ -32,7 +33,7 @@ const DEFAULT_PROPS: Partial<ButtonGroupProps> = {};
|
|
|
32
33
|
* @param ref Component ref.
|
|
33
34
|
* @return React element.
|
|
34
35
|
*/
|
|
35
|
-
export const ButtonGroup
|
|
36
|
+
export const ButtonGroup = forwardRef<ButtonGroupProps, HTMLDivElement>((props, ref) => {
|
|
36
37
|
const { children, className, ...forwardedProps } = props;
|
|
37
38
|
|
|
38
39
|
return (
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { AriaAttributes, ButtonHTMLAttributes, DetailedHTMLProps,
|
|
1
|
+
import React, { AriaAttributes, ButtonHTMLAttributes, DetailedHTMLProps, RefObject } from 'react';
|
|
2
2
|
|
|
3
3
|
import isEmpty from 'lodash/isEmpty';
|
|
4
4
|
|
|
@@ -6,9 +6,10 @@ import classNames from 'classnames';
|
|
|
6
6
|
|
|
7
7
|
import { ColorPalette, Emphasis, Size, Theme } from '@lumx/react';
|
|
8
8
|
import { CSS_PREFIX } from '@lumx/react/constants';
|
|
9
|
-
import {
|
|
9
|
+
import { GenericProps, HasTheme } from '@lumx/react/utils/type';
|
|
10
10
|
import { handleBasicClasses } from '@lumx/react/utils/className';
|
|
11
11
|
import { renderLink } from '@lumx/react/utils/renderLink';
|
|
12
|
+
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
12
13
|
|
|
13
14
|
type HTMLButtonProps = DetailedHTMLProps<ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>;
|
|
14
15
|
|
|
@@ -94,7 +95,7 @@ const renderButtonWrapper: React.FC<ButtonRootProps> = (props) => {
|
|
|
94
95
|
* @param ref Component ref.
|
|
95
96
|
* @return React element.
|
|
96
97
|
*/
|
|
97
|
-
export const ButtonRoot
|
|
98
|
+
export const ButtonRoot = forwardRef<ButtonRootProps, HTMLButtonElement | HTMLAnchorElement>((props, ref) => {
|
|
98
99
|
const {
|
|
99
100
|
'aria-label': ariaLabel,
|
|
100
101
|
children,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
|
-
import { commonTestsSuiteRTL } from '@lumx/react/testing/utils';
|
|
3
|
+
import { commonTestsSuiteRTL, SetupRenderOptions } from '@lumx/react/testing/utils';
|
|
4
4
|
import { Button } from '@lumx/react';
|
|
5
5
|
import { render, screen } from '@testing-library/react';
|
|
6
6
|
import { getByClassName, queryByClassName, queryByTagName } from '@lumx/react/testing/utils/queries';
|
|
@@ -14,9 +14,9 @@ type SetupProps = Partial<IconButtonProps>;
|
|
|
14
14
|
/**
|
|
15
15
|
* Mounts the component and returns common DOM elements / data needed in multiple tests further down.
|
|
16
16
|
*/
|
|
17
|
-
const setup = (propsOverride: SetupProps = {}) => {
|
|
17
|
+
const setup = (propsOverride: SetupProps = {}, { wrapper }: SetupRenderOptions = {}) => {
|
|
18
18
|
const props: any = { ...propsOverride };
|
|
19
|
-
render(<IconButton {...props}
|
|
19
|
+
render(<IconButton {...props} />, { wrapper });
|
|
20
20
|
const iconButton = getByClassName(document.body, CLASSNAME);
|
|
21
21
|
const icon = queryByClassName(iconButton, 'lumx-icon');
|
|
22
22
|
const img = queryByTagName(iconButton, 'IMG');
|
|
@@ -58,5 +58,11 @@ describe(`<${IconButton.displayName}>`, () => {
|
|
|
58
58
|
forwardClassName: 'iconButton',
|
|
59
59
|
forwardAttributes: 'iconButton',
|
|
60
60
|
forwardRef: 'iconButton',
|
|
61
|
+
applyTheme: {
|
|
62
|
+
affects: [{ element: 'iconButton' }],
|
|
63
|
+
viaProp: true,
|
|
64
|
+
viaContext: true,
|
|
65
|
+
defaultTheme: 'light',
|
|
66
|
+
},
|
|
61
67
|
});
|
|
62
68
|
});
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
|
|
3
3
|
import { Emphasis, Icon, Size, Theme, Tooltip, TooltipProps } from '@lumx/react';
|
|
4
4
|
import { BaseButtonProps, ButtonRoot } from '@lumx/react/components/button/ButtonRoot';
|
|
5
|
-
import { Comp } from '@lumx/react/utils/type';
|
|
6
5
|
import { getRootClassName } from '@lumx/react/utils/className';
|
|
6
|
+
import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
|
|
7
|
+
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
7
8
|
|
|
8
9
|
export interface IconButtonProps extends BaseButtonProps {
|
|
9
10
|
/**
|
|
@@ -46,7 +47,6 @@ const CLASSNAME = getRootClassName(COMPONENT_NAME);
|
|
|
46
47
|
const DEFAULT_PROPS: Partial<IconButtonProps> = {
|
|
47
48
|
emphasis: Emphasis.high,
|
|
48
49
|
size: Size.m,
|
|
49
|
-
theme: Theme.light,
|
|
50
50
|
};
|
|
51
51
|
|
|
52
52
|
/**
|
|
@@ -56,8 +56,19 @@ const DEFAULT_PROPS: Partial<IconButtonProps> = {
|
|
|
56
56
|
* @param ref Component ref.
|
|
57
57
|
* @return React element.
|
|
58
58
|
*/
|
|
59
|
-
export const IconButton
|
|
60
|
-
const
|
|
59
|
+
export const IconButton = forwardRef<IconButtonProps, HTMLButtonElement>((props, ref) => {
|
|
60
|
+
const defaultTheme = useTheme() || Theme.light;
|
|
61
|
+
const {
|
|
62
|
+
emphasis,
|
|
63
|
+
image,
|
|
64
|
+
icon,
|
|
65
|
+
label,
|
|
66
|
+
size,
|
|
67
|
+
theme = defaultTheme,
|
|
68
|
+
tooltipProps,
|
|
69
|
+
hideTooltip,
|
|
70
|
+
...forwardedProps
|
|
71
|
+
} = props;
|
|
61
72
|
|
|
62
73
|
return (
|
|
63
74
|
<Tooltip label={hideTooltip ? '' : label} {...tooltipProps}>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
|
-
import { commonTestsSuiteRTL } from '@lumx/react/testing/utils';
|
|
3
|
+
import { commonTestsSuiteRTL, SetupRenderOptions } from '@lumx/react/testing/utils';
|
|
4
4
|
|
|
5
5
|
import { getByClassName, getByTagName, queryByClassName } from '@lumx/react/testing/utils/queries';
|
|
6
6
|
import { render } from '@testing-library/react';
|
|
@@ -14,9 +14,9 @@ type SetupProps = Partial<CheckboxProps>;
|
|
|
14
14
|
/**
|
|
15
15
|
* Mounts the component and returns common DOM elements / data needed in multiple tests further down.
|
|
16
16
|
*/
|
|
17
|
-
const setup = (propsOverride: SetupProps = {}) => {
|
|
17
|
+
const setup = (propsOverride: SetupProps = {}, { wrapper }: SetupRenderOptions = {}) => {
|
|
18
18
|
const props: any = { id: 'fixedId', ...propsOverride };
|
|
19
|
-
render(<Checkbox {...props}
|
|
19
|
+
render(<Checkbox {...props} />, { wrapper });
|
|
20
20
|
|
|
21
21
|
const checkbox = getByClassName(document.body, CLASSNAME);
|
|
22
22
|
const helper = queryByClassName(checkbox, `${CLASSNAME}__helper`);
|
|
@@ -117,5 +117,11 @@ describe(`<${Checkbox.displayName}>`, () => {
|
|
|
117
117
|
baseClassName: CLASSNAME,
|
|
118
118
|
forwardClassName: 'checkbox',
|
|
119
119
|
forwardAttributes: 'checkbox',
|
|
120
|
+
applyTheme: {
|
|
121
|
+
affects: [{ element: 'checkbox' }],
|
|
122
|
+
viaProp: true,
|
|
123
|
+
viaContext: true,
|
|
124
|
+
defaultTheme: 'light',
|
|
125
|
+
},
|
|
120
126
|
});
|
|
121
127
|
});
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { InputHTMLAttributes, ReactNode, SyntheticEvent } from 'react';
|
|
2
2
|
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
|
|
5
5
|
import { mdiCheck, mdiMinus } from '@lumx/icons';
|
|
6
6
|
|
|
7
7
|
import { Icon, InputHelper, InputLabel, Theme } from '@lumx/react';
|
|
8
|
-
import {
|
|
8
|
+
import { GenericProps, HasTheme } from '@lumx/react/utils/type';
|
|
9
9
|
import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
|
|
10
10
|
import { useId } from '@lumx/react/hooks/useId';
|
|
11
11
|
import { useMergeRefs } from '@lumx/react/utils/mergeRefs';
|
|
12
|
+
import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
|
|
13
|
+
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
12
14
|
|
|
13
15
|
/**
|
|
14
16
|
* Intermediate state of checkbox.
|
|
@@ -54,9 +56,7 @@ const CLASSNAME = getRootClassName(COMPONENT_NAME);
|
|
|
54
56
|
/**
|
|
55
57
|
* Component default props.
|
|
56
58
|
*/
|
|
57
|
-
const DEFAULT_PROPS: Partial<CheckboxProps> = {
|
|
58
|
-
theme: Theme.light,
|
|
59
|
-
};
|
|
59
|
+
const DEFAULT_PROPS: Partial<CheckboxProps> = {};
|
|
60
60
|
|
|
61
61
|
/**
|
|
62
62
|
* Checkbox component.
|
|
@@ -65,7 +65,8 @@ const DEFAULT_PROPS: Partial<CheckboxProps> = {
|
|
|
65
65
|
* @param ref Component ref.
|
|
66
66
|
* @return React element.
|
|
67
67
|
*/
|
|
68
|
-
export const Checkbox
|
|
68
|
+
export const Checkbox = forwardRef<CheckboxProps, HTMLDivElement>((props, ref) => {
|
|
69
|
+
const defaultTheme = useTheme() || Theme.light;
|
|
69
70
|
const {
|
|
70
71
|
checked,
|
|
71
72
|
className,
|
|
@@ -78,7 +79,7 @@ export const Checkbox: Comp<CheckboxProps, HTMLDivElement> = forwardRef((props,
|
|
|
78
79
|
label,
|
|
79
80
|
name,
|
|
80
81
|
onChange,
|
|
81
|
-
theme,
|
|
82
|
+
theme = defaultTheme,
|
|
82
83
|
value,
|
|
83
84
|
inputProps = {},
|
|
84
85
|
...forwardedProps
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
3
|
import { Theme } from '@lumx/react';
|
|
4
|
-
import { commonTestsSuiteRTL } from '@lumx/react/testing/utils';
|
|
4
|
+
import { commonTestsSuiteRTL, SetupRenderOptions } from '@lumx/react/testing/utils';
|
|
5
5
|
import { fireEvent, render, screen } from '@testing-library/react';
|
|
6
6
|
import { getByClassName, queryByClassName } from '@lumx/react/testing/utils/queries';
|
|
7
7
|
import userEvent from '@testing-library/user-event';
|
|
@@ -12,12 +12,12 @@ const CLASSNAME = Chip.className as string;
|
|
|
12
12
|
/**
|
|
13
13
|
* Mounts the component and returns common DOM elements / data needed in multiple tests further down.
|
|
14
14
|
*/
|
|
15
|
-
const setup = (propOverrides: Partial<ChipProps> = {}) => {
|
|
15
|
+
const setup = (propOverrides: Partial<ChipProps> = {}, { wrapper }: SetupRenderOptions = {}) => {
|
|
16
16
|
const props = {
|
|
17
17
|
...propOverrides,
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
-
render(<Chip {...props}
|
|
20
|
+
render(<Chip {...props} />, { wrapper });
|
|
21
21
|
const chip = getByClassName(document.body, CLASSNAME);
|
|
22
22
|
const before = queryByClassName(chip, `${CLASSNAME}__before`);
|
|
23
23
|
const after = queryByClassName(chip, `${CLASSNAME}__after`);
|
|
@@ -185,5 +185,15 @@ describe('<Chip />', () => {
|
|
|
185
185
|
});
|
|
186
186
|
});
|
|
187
187
|
|
|
188
|
-
commonTestsSuiteRTL(setup, {
|
|
188
|
+
commonTestsSuiteRTL(setup, {
|
|
189
|
+
baseClassName: CLASSNAME,
|
|
190
|
+
forwardClassName: 'chip',
|
|
191
|
+
forwardAttributes: 'chip',
|
|
192
|
+
applyTheme: {
|
|
193
|
+
affects: [{ element: 'chip', classModifier: 'color', inverted: true }],
|
|
194
|
+
viaProp: true,
|
|
195
|
+
viaContext: true,
|
|
196
|
+
defaultTheme: 'light',
|
|
197
|
+
},
|
|
198
|
+
});
|
|
189
199
|
});
|