@lumx/react 3.10.0 → 3.10.1-alpha.0
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 +13 -5
- package/index.js +217 -202
- package/index.js.map +1 -1
- package/package.json +3 -3
- package/src/components/autocomplete/Autocomplete.test.tsx +9 -2
- package/src/components/autocomplete/Autocomplete.tsx +3 -1
- package/src/components/autocomplete/AutocompleteMultiple.test.tsx +9 -2
- package/src/components/autocomplete/AutocompleteMultiple.tsx +3 -1
- package/src/components/avatar/Avatar.test.tsx +14 -4
- package/src/components/avatar/Avatar.tsx +3 -2
- package/src/components/button/Button.test.tsx +9 -3
- package/src/components/button/Button.tsx +3 -2
- package/src/components/button/IconButton.test.tsx +9 -3
- package/src/components/button/IconButton.tsx +13 -2
- package/src/components/checkbox/Checkbox.test.tsx +9 -3
- package/src/components/checkbox/Checkbox.tsx +4 -4
- package/src/components/chip/Chip.test.tsx +14 -4
- package/src/components/chip/Chip.tsx +3 -2
- package/src/components/comment-block/CommentBlock.test.tsx +9 -3
- package/src/components/comment-block/CommentBlock.tsx +3 -2
- package/src/components/date-picker/DatePickerField.test.tsx +9 -3
- package/src/components/dialog/Dialog.test.tsx +17 -4
- package/src/components/dialog/Dialog.tsx +61 -58
- package/src/components/divider/Divider.test.tsx +9 -3
- package/src/components/divider/Divider.tsx +4 -4
- package/src/components/drag-handle/DragHandle.test.tsx +38 -0
- package/src/components/drag-handle/DragHandle.tsx +3 -1
- package/src/components/expansion-panel/ExpansionPanel.test.tsx +12 -3
- package/src/components/expansion-panel/ExpansionPanel.tsx +4 -4
- package/src/components/flag/Flag.test.tsx +14 -4
- package/src/components/flag/Flag.tsx +4 -4
- package/src/components/icon/Icon.test.tsx +13 -4
- package/src/components/icon/Icon.tsx +13 -1
- package/src/components/image-block/ImageBlock.test.tsx +12 -4
- package/src/components/image-block/ImageBlock.tsx +3 -2
- package/src/components/input-helper/InputHelper.test.tsx +14 -4
- package/src/components/input-helper/InputHelper.tsx +3 -2
- package/src/components/input-label/InputLabel.test.tsx +14 -4
- package/src/components/input-label/InputLabel.tsx +4 -4
- package/src/components/lightbox/Lightbox.test.tsx +17 -6
- package/src/components/lightbox/Lightbox.tsx +8 -5
- package/src/components/link-preview/LinkPreview.test.tsx +9 -3
- package/src/components/link-preview/LinkPreview.tsx +3 -2
- package/src/components/mosaic/Mosaic.test.tsx +9 -3
- package/src/components/mosaic/Mosaic.tsx +4 -4
- package/src/components/navigation/Navigation.test.tsx +18 -9
- package/src/components/navigation/Navigation.tsx +13 -5
- package/src/components/navigation/NavigationItem.tsx +3 -3
- package/src/components/navigation/NavigationSection.tsx +4 -4
- package/src/components/notification/Notification.tsx +3 -2
- package/src/components/popover/Popover.test.tsx +18 -4
- package/src/components/popover/Popover.tsx +2 -1
- package/src/components/post-block/PostBlock.test.tsx +9 -3
- package/src/components/post-block/PostBlock.tsx +3 -2
- package/src/components/progress/Progress.tsx +3 -2
- package/src/components/progress/ProgressCircular.test.tsx +9 -16
- package/src/components/progress/ProgressCircular.tsx +3 -2
- package/src/components/progress/ProgressLinear.test.tsx +13 -18
- package/src/components/progress/ProgressLinear.tsx +4 -4
- package/src/components/radio-button/RadioButton.test.tsx +9 -3
- package/src/components/radio-button/RadioButton.tsx +4 -4
- package/src/components/select/Select.test.tsx +9 -3
- package/src/components/select/Select.tsx +27 -23
- package/src/components/select/SelectMultiple.test.tsx +9 -3
- package/src/components/select/SelectMultiple.tsx +109 -103
- package/src/components/select/WithSelectContext.tsx +8 -6
- package/src/components/side-navigation/SideNavigation.tsx +3 -1
- package/src/components/skeleton/SkeletonCircle.test.tsx +9 -3
- package/src/components/skeleton/SkeletonCircle.tsx +4 -4
- package/src/components/skeleton/SkeletonRectangle.test.tsx +9 -3
- package/src/components/skeleton/SkeletonRectangle.tsx +3 -2
- package/src/components/skeleton/SkeletonTypography.test.tsx +9 -3
- package/src/components/skeleton/SkeletonTypography.tsx +4 -4
- package/src/components/slider/Slider.test.tsx +9 -3
- package/src/components/slider/Slider.tsx +3 -2
- package/src/components/slideshow/Slides.tsx +3 -1
- package/src/components/slideshow/Slideshow.test.tsx +9 -3
- package/src/components/slideshow/Slideshow.tsx +3 -2
- package/src/components/slideshow/SlideshowControls.tsx +3 -2
- package/src/components/switch/Switch.test.tsx +9 -3
- package/src/components/switch/Switch.tsx +3 -2
- package/src/components/table/Table.test.tsx +9 -3
- package/src/components/table/Table.tsx +4 -4
- package/src/components/tabs/TabList.test.tsx +9 -3
- package/src/components/tabs/TabList.tsx +11 -2
- package/src/components/text-field/TextField.test.tsx +9 -3
- package/src/components/text-field/TextField.tsx +3 -2
- package/src/components/thumbnail/Thumbnail.test.tsx +9 -3
- package/src/components/thumbnail/Thumbnail.tsx +3 -2
- package/src/components/uploader/Uploader.test.tsx +9 -3
- package/src/components/uploader/Uploader.tsx +13 -2
- package/src/components/user-block/UserBlock.test.tsx +9 -3
- package/src/components/user-block/UserBlock.tsx +3 -2
- package/src/index.ts +1 -0
- package/src/testing/utils/ThemeSentinel.tsx +11 -0
- package/src/testing/utils/commonTestsSuiteRTL.tsx +190 -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
|
@@ -1,14 +1,14 @@
|
|
|
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 { SkeletonRectangle, SkeletonRectangleProps } from './SkeletonRectangle';
|
|
7
7
|
|
|
8
8
|
const CLASSNAME = SkeletonRectangle.className as string;
|
|
9
9
|
|
|
10
|
-
const setup = (props: Partial<SkeletonRectangleProps> = {}) => {
|
|
11
|
-
render(<SkeletonRectangle {...(props as any)}
|
|
10
|
+
const setup = (props: Partial<SkeletonRectangleProps> = {}, { wrapper }: SetupRenderOptions = {}) => {
|
|
11
|
+
render(<SkeletonRectangle {...(props as any)} />, { wrapper });
|
|
12
12
|
const skeletonRectangle = queryByClassName(document.body, CLASSNAME);
|
|
13
13
|
return { props, skeletonRectangle };
|
|
14
14
|
};
|
|
@@ -19,5 +19,11 @@ describe(`<${SkeletonRectangle.displayName}>`, () => {
|
|
|
19
19
|
baseClassName: CLASSNAME,
|
|
20
20
|
forwardClassName: 'skeletonRectangle',
|
|
21
21
|
forwardAttributes: 'skeletonRectangle',
|
|
22
|
+
applyTheme: {
|
|
23
|
+
affects: [{ element: 'skeletonRectangle' }],
|
|
24
|
+
viaProp: true,
|
|
25
|
+
viaContext: true,
|
|
26
|
+
defaultTheme: 'light',
|
|
27
|
+
},
|
|
22
28
|
});
|
|
23
29
|
});
|
|
@@ -4,6 +4,7 @@ import React, { forwardRef } from 'react';
|
|
|
4
4
|
import { AspectRatio, GlobalSize, Theme, ColorPalette } from '@lumx/react';
|
|
5
5
|
import { Comp, GenericProps, HasTheme, ValueOf } from '@lumx/react/utils/type';
|
|
6
6
|
import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
|
|
7
|
+
import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Skeleton variants.
|
|
@@ -28,7 +29,6 @@ export interface SkeletonRectangleProps extends GenericProps, HasTheme {
|
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
const DEFAULT_PROPS: Partial<SkeletonRectangleProps> = {
|
|
31
|
-
theme: Theme.light,
|
|
32
32
|
variant: SkeletonRectangleVariant.squared,
|
|
33
33
|
};
|
|
34
34
|
|
|
@@ -50,7 +50,8 @@ const CLASSNAME = getRootClassName(COMPONENT_NAME);
|
|
|
50
50
|
* @return React element.
|
|
51
51
|
*/
|
|
52
52
|
export const SkeletonRectangle: Comp<SkeletonRectangleProps, HTMLDivElement> = forwardRef((props, ref) => {
|
|
53
|
-
const
|
|
53
|
+
const defaultTheme = useTheme() || Theme.light;
|
|
54
|
+
const { aspectRatio, className, height, theme = defaultTheme, variant, width, color, ...forwardedProps } = props;
|
|
54
55
|
|
|
55
56
|
return (
|
|
56
57
|
<div
|
|
@@ -1,14 +1,14 @@
|
|
|
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 { SkeletonTypography, SkeletonTypographyProps } from './SkeletonTypography';
|
|
7
7
|
|
|
8
8
|
const CLASSNAME = SkeletonTypography.className as string;
|
|
9
9
|
|
|
10
|
-
const setup = (props: Partial<SkeletonTypographyProps> = {}) => {
|
|
11
|
-
render(<SkeletonTypography {...(props as any)}
|
|
10
|
+
const setup = (props: Partial<SkeletonTypographyProps> = {}, { wrapper }: SetupRenderOptions = {}) => {
|
|
11
|
+
render(<SkeletonTypography {...(props as any)} />, { wrapper });
|
|
12
12
|
const skeletonTypography = queryByClassName(document.body, CLASSNAME);
|
|
13
13
|
return { props, skeletonTypography };
|
|
14
14
|
};
|
|
@@ -19,5 +19,11 @@ describe(`<${SkeletonTypography.displayName}>`, () => {
|
|
|
19
19
|
baseClassName: CLASSNAME,
|
|
20
20
|
forwardClassName: 'skeletonTypography',
|
|
21
21
|
forwardAttributes: 'skeletonTypography',
|
|
22
|
+
applyTheme: {
|
|
23
|
+
affects: [{ element: 'skeletonTypography' }],
|
|
24
|
+
viaProp: true,
|
|
25
|
+
viaContext: true,
|
|
26
|
+
defaultTheme: 'light',
|
|
27
|
+
},
|
|
22
28
|
});
|
|
23
29
|
});
|
|
@@ -4,6 +4,7 @@ import React, { CSSProperties, forwardRef } from 'react';
|
|
|
4
4
|
import { Theme, TypographyInterface, ColorPalette } from '@lumx/react';
|
|
5
5
|
import { Comp, GenericProps, HasTheme } from '@lumx/react/utils/type';
|
|
6
6
|
import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
|
|
7
|
+
import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Defines the props of the component.
|
|
@@ -17,9 +18,7 @@ export interface SkeletonTypographyProps extends GenericProps, HasTheme {
|
|
|
17
18
|
color?: ColorPalette;
|
|
18
19
|
}
|
|
19
20
|
|
|
20
|
-
const DEFAULT_PROPS: Partial<SkeletonTypographyProps> = {
|
|
21
|
-
theme: Theme.light,
|
|
22
|
-
};
|
|
21
|
+
const DEFAULT_PROPS: Partial<SkeletonTypographyProps> = {};
|
|
23
22
|
|
|
24
23
|
/**
|
|
25
24
|
* Component display name.
|
|
@@ -39,7 +38,8 @@ const CLASSNAME = getRootClassName(COMPONENT_NAME);
|
|
|
39
38
|
* @return React element.
|
|
40
39
|
*/
|
|
41
40
|
export const SkeletonTypography: Comp<SkeletonTypographyProps, HTMLDivElement> = forwardRef((props, ref) => {
|
|
42
|
-
const
|
|
41
|
+
const defaultTheme = useTheme() || Theme.light;
|
|
42
|
+
const { className, theme = defaultTheme, typography, width, color, ...forwardedProps } = props;
|
|
43
43
|
|
|
44
44
|
return (
|
|
45
45
|
<div
|
|
@@ -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 { render } from '@testing-library/react';
|
|
5
5
|
import { queryByClassName } from '@lumx/react/testing/utils/queries';
|
|
6
6
|
import { Slider, SliderProps } from './Slider';
|
|
@@ -9,8 +9,8 @@ const CLASSNAME = Slider.className as string;
|
|
|
9
9
|
|
|
10
10
|
jest.mock('@lumx/react/hooks/useId', () => ({ useId: () => ':r1:' }));
|
|
11
11
|
|
|
12
|
-
const setup = (props: Partial<SliderProps> = {}) => {
|
|
13
|
-
render(<Slider {...(props as any)}
|
|
12
|
+
const setup = (props: Partial<SliderProps> = {}, { wrapper }: SetupRenderOptions = {}) => {
|
|
13
|
+
render(<Slider {...(props as any)} />, { wrapper });
|
|
14
14
|
const slider = queryByClassName(document.body, CLASSNAME);
|
|
15
15
|
return { props, slider };
|
|
16
16
|
};
|
|
@@ -21,5 +21,11 @@ describe(`<${Slider.displayName}>`, () => {
|
|
|
21
21
|
baseClassName: CLASSNAME,
|
|
22
22
|
forwardClassName: 'slider',
|
|
23
23
|
forwardAttributes: 'slider',
|
|
24
|
+
applyTheme: {
|
|
25
|
+
affects: [{ element: 'slider' }],
|
|
26
|
+
viaProp: true,
|
|
27
|
+
viaContext: true,
|
|
28
|
+
defaultTheme: 'light',
|
|
29
|
+
},
|
|
24
30
|
});
|
|
25
31
|
});
|
|
@@ -11,6 +11,7 @@ import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/classNam
|
|
|
11
11
|
|
|
12
12
|
import { clamp } from '@lumx/react/utils/clamp';
|
|
13
13
|
import { useId } from '@lumx/react/hooks/useId';
|
|
14
|
+
import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* Defines the props of the component.
|
|
@@ -58,7 +59,6 @@ const CLASSNAME = getRootClassName(COMPONENT_NAME);
|
|
|
58
59
|
const DEFAULT_PROPS: Partial<SliderProps> = {
|
|
59
60
|
precision: 0,
|
|
60
61
|
steps: 0,
|
|
61
|
-
theme: Theme.light,
|
|
62
62
|
};
|
|
63
63
|
|
|
64
64
|
/**
|
|
@@ -92,6 +92,7 @@ const computePercentFromValue = (value: number, min: number, max: number): numbe
|
|
|
92
92
|
* @return React element.
|
|
93
93
|
*/
|
|
94
94
|
export const Slider: Comp<SliderProps, HTMLDivElement> = forwardRef((props, ref) => {
|
|
95
|
+
const defaultTheme = useTheme() || Theme.light;
|
|
95
96
|
const {
|
|
96
97
|
className,
|
|
97
98
|
disabled,
|
|
@@ -107,7 +108,7 @@ export const Slider: Comp<SliderProps, HTMLDivElement> = forwardRef((props, ref)
|
|
|
107
108
|
onMouseDown,
|
|
108
109
|
precision,
|
|
109
110
|
steps,
|
|
110
|
-
theme,
|
|
111
|
+
theme = defaultTheme,
|
|
111
112
|
value,
|
|
112
113
|
...forwardedProps
|
|
113
114
|
} = props;
|
|
@@ -6,6 +6,7 @@ import classNames from 'classnames';
|
|
|
6
6
|
import { FULL_WIDTH_PERCENT } from '@lumx/react/components/slideshow/constants';
|
|
7
7
|
import { Comp, 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';
|
|
9
10
|
import { buildSlideShowGroupId, SlideshowItemGroup } from './SlideshowItemGroup';
|
|
10
11
|
|
|
11
12
|
export interface SlidesProps extends GenericProps, HasTheme {
|
|
@@ -54,11 +55,12 @@ const CLASSNAME = getRootClassName(COMPONENT_NAME);
|
|
|
54
55
|
* @return React element.
|
|
55
56
|
*/
|
|
56
57
|
export const Slides: Comp<SlidesProps, HTMLDivElement> = forwardRef((props, ref) => {
|
|
58
|
+
const defaultTheme = useTheme();
|
|
57
59
|
const {
|
|
58
60
|
activeIndex,
|
|
59
61
|
id,
|
|
60
62
|
className,
|
|
61
|
-
theme,
|
|
63
|
+
theme = defaultTheme,
|
|
62
64
|
fillHeight,
|
|
63
65
|
groupBy,
|
|
64
66
|
isAutoPlaying,
|
|
@@ -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 { render } from '@testing-library/react';
|
|
5
5
|
import { queryByClassName } from '@lumx/react/testing/utils/queries';
|
|
6
6
|
import { Slideshow, SlideshowProps } from './Slideshow';
|
|
@@ -8,7 +8,7 @@ import { Slides } from './Slides';
|
|
|
8
8
|
|
|
9
9
|
const CLASSNAME = Slides.className as string;
|
|
10
10
|
|
|
11
|
-
const setup = (propsOverride: Partial<SlideshowProps> = {}) => {
|
|
11
|
+
const setup = (propsOverride: Partial<SlideshowProps> = {}, { wrapper }: SetupRenderOptions = {}) => {
|
|
12
12
|
const props: SlideshowProps = {
|
|
13
13
|
slideshowControlsProps: {
|
|
14
14
|
nextButtonProps: { label: 'Next' },
|
|
@@ -16,7 +16,7 @@ const setup = (propsOverride: Partial<SlideshowProps> = {}) => {
|
|
|
16
16
|
},
|
|
17
17
|
...propsOverride,
|
|
18
18
|
};
|
|
19
|
-
render(<Slideshow {...props}
|
|
19
|
+
render(<Slideshow {...props} />, { wrapper });
|
|
20
20
|
const slideShow = queryByClassName(document.body, CLASSNAME);
|
|
21
21
|
return { props, slideShow };
|
|
22
22
|
};
|
|
@@ -27,5 +27,11 @@ describe(`<${Slideshow.displayName}>`, () => {
|
|
|
27
27
|
baseClassName: CLASSNAME,
|
|
28
28
|
forwardClassName: 'slideShow',
|
|
29
29
|
forwardAttributes: 'slideShow',
|
|
30
|
+
applyTheme: {
|
|
31
|
+
affects: [{ element: 'slideShow' }],
|
|
32
|
+
viaProp: true,
|
|
33
|
+
viaContext: true,
|
|
34
|
+
defaultTheme: 'light',
|
|
35
|
+
},
|
|
30
36
|
});
|
|
31
37
|
});
|
|
@@ -5,6 +5,7 @@ import { DEFAULT_OPTIONS } from '@lumx/react/hooks/useSlideshowControls';
|
|
|
5
5
|
import { Comp, GenericProps } from '@lumx/react/utils/type';
|
|
6
6
|
import { useFocusWithin } from '@lumx/react/hooks/useFocusWithin';
|
|
7
7
|
import { mergeRefs } from '@lumx/react/utils/mergeRefs';
|
|
8
|
+
import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
|
|
8
9
|
import { buildSlideShowGroupId } from './SlideshowItemGroup';
|
|
9
10
|
|
|
10
11
|
/**
|
|
@@ -41,7 +42,6 @@ export interface SlideshowProps
|
|
|
41
42
|
*/
|
|
42
43
|
const DEFAULT_PROPS: Partial<SlideshowProps> = {
|
|
43
44
|
...DEFAULT_OPTIONS,
|
|
44
|
-
theme: Theme.light,
|
|
45
45
|
};
|
|
46
46
|
|
|
47
47
|
/**
|
|
@@ -52,6 +52,7 @@ const DEFAULT_PROPS: Partial<SlideshowProps> = {
|
|
|
52
52
|
* @return React element.
|
|
53
53
|
*/
|
|
54
54
|
export const Slideshow: Comp<SlideshowProps, HTMLDivElement> = forwardRef((props, ref) => {
|
|
55
|
+
const defaultTheme = useTheme() || Theme.light;
|
|
55
56
|
const {
|
|
56
57
|
activeIndex,
|
|
57
58
|
autoPlay,
|
|
@@ -62,7 +63,7 @@ export const Slideshow: Comp<SlideshowProps, HTMLDivElement> = forwardRef((props
|
|
|
62
63
|
interval,
|
|
63
64
|
onChange,
|
|
64
65
|
slideshowControlsProps,
|
|
65
|
-
theme,
|
|
66
|
+
theme = defaultTheme,
|
|
66
67
|
id,
|
|
67
68
|
slidesId,
|
|
68
69
|
slideGroupLabel,
|
|
@@ -11,6 +11,7 @@ import { WINDOW } from '@lumx/react/constants';
|
|
|
11
11
|
import { useSlideshowControls, DEFAULT_OPTIONS } from '@lumx/react/hooks/useSlideshowControls';
|
|
12
12
|
import { useRovingTabIndex } from '@lumx/react/hooks/useRovingTabIndex';
|
|
13
13
|
|
|
14
|
+
import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
|
|
14
15
|
import { useSwipeNavigate } from './useSwipeNavigate';
|
|
15
16
|
import { PAGINATION_ITEM_SIZE, PAGINATION_ITEMS_MAX } from './constants';
|
|
16
17
|
import { usePaginationVisibleRange } from './usePaginationVisibleRange';
|
|
@@ -70,7 +71,6 @@ const CLASSNAME = getRootClassName(COMPONENT_NAME);
|
|
|
70
71
|
*/
|
|
71
72
|
const DEFAULT_PROPS: Partial<SlideshowControlsProps> = {
|
|
72
73
|
activeIndex: 0,
|
|
73
|
-
theme: Theme.light,
|
|
74
74
|
};
|
|
75
75
|
|
|
76
76
|
/**
|
|
@@ -81,6 +81,7 @@ const DEFAULT_PROPS: Partial<SlideshowControlsProps> = {
|
|
|
81
81
|
* @return React element.
|
|
82
82
|
*/
|
|
83
83
|
const InternalSlideshowControls: Comp<SlideshowControlsProps, HTMLDivElement> = forwardRef((props, ref) => {
|
|
84
|
+
const defaultTheme = useTheme() || Theme.light;
|
|
84
85
|
const {
|
|
85
86
|
activeIndex,
|
|
86
87
|
className,
|
|
@@ -92,7 +93,7 @@ const InternalSlideshowControls: Comp<SlideshowControlsProps, HTMLDivElement> =
|
|
|
92
93
|
previousButtonProps,
|
|
93
94
|
paginationProps,
|
|
94
95
|
slidesCount,
|
|
95
|
-
theme,
|
|
96
|
+
theme = defaultTheme,
|
|
96
97
|
isAutoPlaying = false,
|
|
97
98
|
playButtonProps,
|
|
98
99
|
paginationItemLabel,
|
|
@@ -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 { render } from '@testing-library/react';
|
|
5
5
|
import { getByClassName, getByTagName, queryByClassName } from '@lumx/react/testing/utils/queries';
|
|
6
6
|
import userEvent from '@testing-library/user-event/';
|
|
@@ -14,9 +14,9 @@ type SetupProps = Partial<SwitchProps>;
|
|
|
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 = { ...propsOverride };
|
|
19
|
-
render(<Switch {...props}
|
|
19
|
+
render(<Switch {...props} />, { wrapper });
|
|
20
20
|
const switchWrapper = getByClassName(document.body, CLASSNAME);
|
|
21
21
|
const input = getByTagName(switchWrapper, 'input');
|
|
22
22
|
const helper = queryByClassName(switchWrapper, `${CLASSNAME}__helper`);
|
|
@@ -106,5 +106,11 @@ describe(`<${Switch.displayName}>`, () => {
|
|
|
106
106
|
forwardClassName: 'switchWrapper',
|
|
107
107
|
forwardAttributes: 'switchWrapper',
|
|
108
108
|
forwardRef: 'switchWrapper',
|
|
109
|
+
applyTheme: {
|
|
110
|
+
affects: [{ element: 'switchWrapper' }],
|
|
111
|
+
viaProp: true,
|
|
112
|
+
viaContext: true,
|
|
113
|
+
defaultTheme: 'light',
|
|
114
|
+
},
|
|
109
115
|
});
|
|
110
116
|
});
|
|
@@ -9,6 +9,7 @@ import { Alignment, InputHelper, InputLabel, Theme } from '@lumx/react';
|
|
|
9
9
|
import { Comp, GenericProps, HasTheme } from '@lumx/react/utils/type';
|
|
10
10
|
import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
|
|
11
11
|
import { useId } from '@lumx/react/hooks/useId';
|
|
12
|
+
import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* Defines the props of the component.
|
|
@@ -47,7 +48,6 @@ const CLASSNAME = getRootClassName(COMPONENT_NAME);
|
|
|
47
48
|
*/
|
|
48
49
|
const DEFAULT_PROPS: Partial<SwitchProps> = {
|
|
49
50
|
position: Alignment.left,
|
|
50
|
-
theme: Theme.light,
|
|
51
51
|
};
|
|
52
52
|
|
|
53
53
|
/**
|
|
@@ -58,6 +58,7 @@ const DEFAULT_PROPS: Partial<SwitchProps> = {
|
|
|
58
58
|
* @return React element.
|
|
59
59
|
*/
|
|
60
60
|
export const Switch: Comp<SwitchProps, HTMLDivElement> = forwardRef((props, ref) => {
|
|
61
|
+
const defaultTheme = useTheme() || Theme.light;
|
|
61
62
|
const {
|
|
62
63
|
checked,
|
|
63
64
|
children,
|
|
@@ -70,7 +71,7 @@ export const Switch: Comp<SwitchProps, HTMLDivElement> = forwardRef((props, ref)
|
|
|
70
71
|
name,
|
|
71
72
|
onChange,
|
|
72
73
|
position,
|
|
73
|
-
theme,
|
|
74
|
+
theme = defaultTheme,
|
|
74
75
|
value,
|
|
75
76
|
inputProps = {},
|
|
76
77
|
...forwardedProps
|
|
@@ -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 { queryByClassName } from '@lumx/react/testing/utils/queries';
|
|
5
5
|
import { render } from '@testing-library/react';
|
|
6
6
|
|
|
@@ -8,8 +8,8 @@ import { Table, TableProps } from './Table';
|
|
|
8
8
|
|
|
9
9
|
const CLASSNAME = Table.className as string;
|
|
10
10
|
|
|
11
|
-
const setup = (props: Partial<TableProps> = {}) => {
|
|
12
|
-
render(<Table {...(props as any)}
|
|
11
|
+
const setup = (props: Partial<TableProps> = {}, { wrapper }: SetupRenderOptions = {}) => {
|
|
12
|
+
render(<Table {...(props as any)} />, { wrapper });
|
|
13
13
|
const table = queryByClassName(document.body, CLASSNAME);
|
|
14
14
|
return { props, table };
|
|
15
15
|
};
|
|
@@ -21,5 +21,11 @@ describe(`<${Table.displayName}>`, () => {
|
|
|
21
21
|
forwardClassName: 'table',
|
|
22
22
|
forwardAttributes: 'table',
|
|
23
23
|
forwardRef: 'table',
|
|
24
|
+
applyTheme: {
|
|
25
|
+
affects: [{ element: 'table' }],
|
|
26
|
+
viaProp: true,
|
|
27
|
+
viaContext: true,
|
|
28
|
+
defaultTheme: 'light',
|
|
29
|
+
},
|
|
24
30
|
});
|
|
25
31
|
});
|
|
@@ -6,6 +6,7 @@ import { Theme } from '@lumx/react';
|
|
|
6
6
|
|
|
7
7
|
import { Comp, 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';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Defines the props of the component.
|
|
@@ -30,9 +31,7 @@ const CLASSNAME = getRootClassName(COMPONENT_NAME);
|
|
|
30
31
|
/**
|
|
31
32
|
* Component default props.
|
|
32
33
|
*/
|
|
33
|
-
const DEFAULT_PROPS: Partial<TableProps> = {
|
|
34
|
-
theme: Theme.light,
|
|
35
|
-
};
|
|
34
|
+
const DEFAULT_PROPS: Partial<TableProps> = {};
|
|
36
35
|
|
|
37
36
|
/**
|
|
38
37
|
* Table component.
|
|
@@ -42,7 +41,8 @@ const DEFAULT_PROPS: Partial<TableProps> = {
|
|
|
42
41
|
* @return React element.
|
|
43
42
|
*/
|
|
44
43
|
export const Table: Comp<TableProps, HTMLTableElement> = forwardRef((props, ref) => {
|
|
45
|
-
const
|
|
44
|
+
const defaultTheme = useTheme() || Theme.light;
|
|
45
|
+
const { children, className, hasBefore, hasDividers, theme = defaultTheme, ...forwardedProps } = props;
|
|
46
46
|
|
|
47
47
|
return (
|
|
48
48
|
<table
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
3
|
import { Tab } from '@lumx/react';
|
|
4
|
-
import { commonTestsSuiteRTL } from '@lumx/react/testing/utils';
|
|
4
|
+
import { commonTestsSuiteRTL, SetupRenderOptions } from '@lumx/react/testing/utils';
|
|
5
5
|
import { render, screen } from '@testing-library/react';
|
|
6
6
|
import { getByClassName, queryByClassName } from '@lumx/react/testing/utils/queries';
|
|
7
7
|
|
|
@@ -14,7 +14,7 @@ type SetupProps = Partial<TabListProps>;
|
|
|
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 tabs = [<Tab key={0} label="Tab 0" />, <Tab key={1} label="Tab 1" />];
|
|
19
19
|
const props: TabListProps = {
|
|
20
20
|
children: tabs,
|
|
@@ -22,7 +22,7 @@ const setup = (propsOverride: SetupProps = {}) => {
|
|
|
22
22
|
...propsOverride,
|
|
23
23
|
};
|
|
24
24
|
|
|
25
|
-
render(<TabList {...props}
|
|
25
|
+
render(<TabList {...props} />, { wrapper });
|
|
26
26
|
const tabList = getByClassName(document.body, CLASSNAME);
|
|
27
27
|
const links = queryByClassName(tabList, `${CLASSNAME}__links`);
|
|
28
28
|
return { props, tabList, links };
|
|
@@ -41,5 +41,11 @@ describe(`<${TabList.displayName}>`, () => {
|
|
|
41
41
|
forwardClassName: 'tabList',
|
|
42
42
|
forwardAttributes: 'tabList',
|
|
43
43
|
forwardRef: 'tabList',
|
|
44
|
+
applyTheme: {
|
|
45
|
+
affects: [{ element: 'tabList' }],
|
|
46
|
+
viaProp: true,
|
|
47
|
+
viaContext: true,
|
|
48
|
+
defaultTheme: 'light',
|
|
49
|
+
},
|
|
44
50
|
});
|
|
45
51
|
});
|
|
@@ -6,6 +6,7 @@ import { mergeRefs } from '@lumx/react/utils/mergeRefs';
|
|
|
6
6
|
|
|
7
7
|
import classNames from 'classnames';
|
|
8
8
|
import React, { forwardRef, ReactNode } from 'react';
|
|
9
|
+
import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
|
|
9
10
|
import { useRovingTabIndex } from '../../hooks/useRovingTabIndex';
|
|
10
11
|
|
|
11
12
|
export enum TabListLayout {
|
|
@@ -43,7 +44,6 @@ const CLASSNAME = `${CSS_PREFIX}-tabs`;
|
|
|
43
44
|
const DEFAULT_PROPS: Partial<TabListProps> = {
|
|
44
45
|
layout: TabListLayout.fixed,
|
|
45
46
|
position: Alignment.left,
|
|
46
|
-
theme: Theme.light,
|
|
47
47
|
};
|
|
48
48
|
|
|
49
49
|
/**
|
|
@@ -56,7 +56,16 @@ const DEFAULT_PROPS: Partial<TabListProps> = {
|
|
|
56
56
|
* @return React element.
|
|
57
57
|
*/
|
|
58
58
|
export const TabList: Comp<TabListProps, HTMLDivElement> = forwardRef((props, ref) => {
|
|
59
|
-
const
|
|
59
|
+
const defaultTheme = useTheme() || Theme.light;
|
|
60
|
+
const {
|
|
61
|
+
'aria-label': ariaLabel,
|
|
62
|
+
children,
|
|
63
|
+
className,
|
|
64
|
+
layout,
|
|
65
|
+
position,
|
|
66
|
+
theme = defaultTheme,
|
|
67
|
+
...forwardedProps
|
|
68
|
+
} = props;
|
|
60
69
|
const tabListRef = React.useRef(null);
|
|
61
70
|
useRovingTabIndex({
|
|
62
71
|
parentRef: tabListRef,
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
|
|
3
3
|
import camelCase from 'lodash/camelCase';
|
|
4
4
|
|
|
5
|
-
import { commonTestsSuiteRTL } from '@lumx/react/testing/utils';
|
|
5
|
+
import { commonTestsSuiteRTL, SetupRenderOptions } from '@lumx/react/testing/utils';
|
|
6
6
|
import { getBasicClass } from '@lumx/react/utils/className';
|
|
7
7
|
import { render } from '@testing-library/react';
|
|
8
8
|
import {
|
|
@@ -25,9 +25,9 @@ jest.mock('@lumx/react/utils/isFocusVisible');
|
|
|
25
25
|
/**
|
|
26
26
|
* Mounts the component and returns common DOM elements / data needed in multiple tests further down.
|
|
27
27
|
*/
|
|
28
|
-
const setup = (propsOverride: Partial<TextFieldProps> = {}) => {
|
|
28
|
+
const setup = (propsOverride: Partial<TextFieldProps> = {}, { wrapper }: SetupRenderOptions = {}) => {
|
|
29
29
|
const props: any = { ...propsOverride };
|
|
30
|
-
const { container } = render(<TextField {...props}
|
|
30
|
+
const { container } = render(<TextField {...props} />, { wrapper });
|
|
31
31
|
|
|
32
32
|
const element = getByClassName(container, CLASSNAME);
|
|
33
33
|
const inputNative = (queryByTagName(container, 'textarea') || getByTagName(container, 'input')) as
|
|
@@ -233,5 +233,11 @@ describe(`<${TextField.displayName}>`, () => {
|
|
|
233
233
|
forwardClassName: 'element',
|
|
234
234
|
forwardAttributes: 'inputNative',
|
|
235
235
|
forwardRef: 'element',
|
|
236
|
+
applyTheme: {
|
|
237
|
+
affects: [{ element: 'element' }],
|
|
238
|
+
viaProp: true,
|
|
239
|
+
viaContext: true,
|
|
240
|
+
defaultTheme: 'light',
|
|
241
|
+
},
|
|
236
242
|
});
|
|
237
243
|
});
|
|
@@ -20,6 +20,7 @@ import { Comp, GenericProps, HasTheme } from '@lumx/react/utils/type';
|
|
|
20
20
|
import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
|
|
21
21
|
import { mergeRefs } from '@lumx/react/utils/mergeRefs';
|
|
22
22
|
import { useId } from '@lumx/react/hooks/useId';
|
|
23
|
+
import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
|
|
23
24
|
|
|
24
25
|
/**
|
|
25
26
|
* Defines the props of the component.
|
|
@@ -101,7 +102,6 @@ const DEFAULT_MIN_ROWS = 2;
|
|
|
101
102
|
* Component default props.
|
|
102
103
|
*/
|
|
103
104
|
const DEFAULT_PROPS: Partial<TextFieldProps> = {
|
|
104
|
-
theme: Theme.light,
|
|
105
105
|
type: 'text',
|
|
106
106
|
};
|
|
107
107
|
|
|
@@ -255,6 +255,7 @@ const renderInputNative: React.FC<InputNativeProps> = (props) => {
|
|
|
255
255
|
* @return React element.
|
|
256
256
|
*/
|
|
257
257
|
export const TextField: Comp<TextFieldProps, HTMLDivElement> = forwardRef((props, ref) => {
|
|
258
|
+
const defaultTheme = useTheme() || Theme.light;
|
|
258
259
|
const {
|
|
259
260
|
chips,
|
|
260
261
|
className,
|
|
@@ -282,7 +283,7 @@ export const TextField: Comp<TextFieldProps, HTMLDivElement> = forwardRef((props
|
|
|
282
283
|
onFocus,
|
|
283
284
|
placeholder,
|
|
284
285
|
textFieldRef,
|
|
285
|
-
theme,
|
|
286
|
+
theme = defaultTheme,
|
|
286
287
|
type,
|
|
287
288
|
value,
|
|
288
289
|
afterElement,
|
|
@@ -1,14 +1,14 @@
|
|
|
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 { queryByClassName } from '@lumx/react/testing/utils/queries';
|
|
5
5
|
import { render } from '@testing-library/react';
|
|
6
6
|
import { Thumbnail, ThumbnailProps } from './Thumbnail';
|
|
7
7
|
|
|
8
8
|
const CLASSNAME = Thumbnail.className as string;
|
|
9
9
|
|
|
10
|
-
const setup = (props: Partial<ThumbnailProps> = {}) => {
|
|
11
|
-
render(<Thumbnail {...(props as any)}
|
|
10
|
+
const setup = (props: Partial<ThumbnailProps> = {}, { wrapper }: SetupRenderOptions = {}) => {
|
|
11
|
+
render(<Thumbnail {...(props as any)} />, { wrapper });
|
|
12
12
|
const thumbnail = queryByClassName(document.body, CLASSNAME);
|
|
13
13
|
return { props, thumbnail };
|
|
14
14
|
};
|
|
@@ -19,5 +19,11 @@ describe(`<${Thumbnail.displayName}>`, () => {
|
|
|
19
19
|
baseClassName: CLASSNAME,
|
|
20
20
|
forwardClassName: 'thumbnail',
|
|
21
21
|
forwardAttributes: 'thumbnail',
|
|
22
|
+
applyTheme: {
|
|
23
|
+
affects: [{ element: 'thumbnail' }],
|
|
24
|
+
viaProp: true,
|
|
25
|
+
viaContext: true,
|
|
26
|
+
defaultTheme: 'light',
|
|
27
|
+
},
|
|
22
28
|
});
|
|
23
29
|
});
|
|
@@ -20,6 +20,7 @@ import { mdiImageBroken } from '@lumx/icons';
|
|
|
20
20
|
import { useMergeRefs } from '@lumx/react/utils/mergeRefs';
|
|
21
21
|
import { useImageLoad } from '@lumx/react/components/thumbnail/useImageLoad';
|
|
22
22
|
import { useFocusPointStyle } from '@lumx/react/components/thumbnail/useFocusPointStyle';
|
|
23
|
+
import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
|
|
23
24
|
import { FocusPoint, ThumbnailSize, ThumbnailVariant } from './types';
|
|
24
25
|
|
|
25
26
|
type ImgHTMLProps = ImgHTMLAttributes<HTMLImageElement>;
|
|
@@ -88,7 +89,6 @@ const CLASSNAME = getRootClassName(COMPONENT_NAME);
|
|
|
88
89
|
const DEFAULT_PROPS: Partial<ThumbnailProps> = {
|
|
89
90
|
fallback: mdiImageBroken,
|
|
90
91
|
loading: 'lazy',
|
|
91
|
-
theme: Theme.light,
|
|
92
92
|
};
|
|
93
93
|
|
|
94
94
|
/**
|
|
@@ -99,6 +99,7 @@ const DEFAULT_PROPS: Partial<ThumbnailProps> = {
|
|
|
99
99
|
* @return React element.
|
|
100
100
|
*/
|
|
101
101
|
export const Thumbnail: Comp<ThumbnailProps> = forwardRef((props, ref) => {
|
|
102
|
+
const defaultTheme = useTheme() || Theme.light;
|
|
102
103
|
const {
|
|
103
104
|
align,
|
|
104
105
|
alt,
|
|
@@ -119,7 +120,7 @@ export const Thumbnail: Comp<ThumbnailProps> = forwardRef((props, ref) => {
|
|
|
119
120
|
loading,
|
|
120
121
|
loadingPlaceholderImageRef,
|
|
121
122
|
size,
|
|
122
|
-
theme,
|
|
123
|
+
theme = defaultTheme,
|
|
123
124
|
variant,
|
|
124
125
|
linkProps,
|
|
125
126
|
linkAs,
|
|
@@ -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 { render, screen } from '@testing-library/react';
|
|
6
6
|
import { getByClassName, getByTagName, queryByClassName } from '@lumx/react/testing/utils/queries';
|
|
@@ -15,10 +15,10 @@ type SetupProps = Partial<UploaderProps>;
|
|
|
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
20
|
|
|
21
|
-
render(<Uploader {...props}
|
|
21
|
+
render(<Uploader {...props} />, { wrapper });
|
|
22
22
|
const uploader = getByClassName(document.body, CLASSNAME);
|
|
23
23
|
const label = queryByClassName(uploader, `${CLASSNAME}__label`);
|
|
24
24
|
const icon = queryByClassName(uploader, `${CLASSNAME}__icon`);
|
|
@@ -117,5 +117,11 @@ describe(`<${Uploader.displayName}>`, () => {
|
|
|
117
117
|
forwardClassName: 'uploader',
|
|
118
118
|
forwardAttributes: 'uploader',
|
|
119
119
|
forwardRef: 'uploader',
|
|
120
|
+
applyTheme: {
|
|
121
|
+
affects: [{ element: 'uploader' }],
|
|
122
|
+
viaProp: true,
|
|
123
|
+
viaContext: true,
|
|
124
|
+
defaultTheme: 'light',
|
|
125
|
+
},
|
|
120
126
|
});
|
|
121
127
|
});
|