@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
|
@@ -5,7 +5,7 @@ import { Icon, Size, Text, Orientation, Popover, Placement, Theme } from '@lumx/
|
|
|
5
5
|
import classNames from 'classnames';
|
|
6
6
|
import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
|
|
7
7
|
import { HasClassName } from '@lumx/react/utils/type';
|
|
8
|
-
import {
|
|
8
|
+
import { ThemeProvider, useTheme } from '@lumx/react/utils/theme/ThemeContext';
|
|
9
9
|
import { useId } from '@lumx/react/hooks/useId';
|
|
10
10
|
|
|
11
11
|
import { CLASSNAME as ITEM_CLASSNAME } from './NavigationItem';
|
|
@@ -37,7 +37,7 @@ export const NavigationSection = Object.assign(
|
|
|
37
37
|
const buttonRef = useRef<HTMLButtonElement>(null);
|
|
38
38
|
const sectionId = useId();
|
|
39
39
|
const { orientation } = useContext(NavigationContext) || {};
|
|
40
|
-
const theme =
|
|
40
|
+
const theme = useTheme();
|
|
41
41
|
const isDropdown = orientation === Orientation.horizontal;
|
|
42
42
|
return (
|
|
43
43
|
<li
|
|
@@ -87,13 +87,13 @@ export const NavigationSection = Object.assign(
|
|
|
87
87
|
onClose={() => setIsOpen(false)}
|
|
88
88
|
zIndex={996}
|
|
89
89
|
>
|
|
90
|
-
<
|
|
90
|
+
<ThemeProvider value={Theme.light}>
|
|
91
91
|
<ul className={`${CLASSNAME}__drawer--popover`} id={sectionId}>
|
|
92
92
|
<NavigationContext.Provider value={{ orientation: Orientation.vertical }}>
|
|
93
93
|
{children}
|
|
94
94
|
</NavigationContext.Provider>
|
|
95
95
|
</ul>
|
|
96
|
-
</
|
|
96
|
+
</ThemeProvider>
|
|
97
97
|
</Popover>
|
|
98
98
|
) : (
|
|
99
99
|
<ul className={`${CLASSNAME}__drawer`} id={sectionId}>
|
|
@@ -1,19 +1,18 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useRef } from 'react';
|
|
2
2
|
import { createPortal } from 'react-dom';
|
|
3
3
|
|
|
4
4
|
import classNames from 'classnames';
|
|
5
|
-
|
|
6
5
|
import isFunction from 'lodash/isFunction';
|
|
7
6
|
|
|
8
7
|
import { Button, Emphasis, Icon, Kind, Size, Theme } from '@lumx/react';
|
|
9
|
-
|
|
10
8
|
import { DOCUMENT, NOTIFICATION_TRANSITION_DURATION } from '@lumx/react/constants';
|
|
11
9
|
import { NOTIFICATION_CONFIGURATION } from '@lumx/react/components/notification/constants';
|
|
12
|
-
import {
|
|
10
|
+
import { GenericProps, HasTheme } from '@lumx/react/utils/type';
|
|
13
11
|
import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
|
|
14
|
-
|
|
15
12
|
import { useTransitionVisibility } from '@lumx/react/hooks/useTransitionVisibility';
|
|
16
13
|
import { mergeRefs } from '@lumx/react/utils/mergeRefs';
|
|
14
|
+
import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
|
|
15
|
+
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
17
16
|
|
|
18
17
|
/**
|
|
19
18
|
* Defines the props of the component.
|
|
@@ -51,7 +50,6 @@ const CLASSNAME = getRootClassName(COMPONENT_NAME);
|
|
|
51
50
|
* Component default props.
|
|
52
51
|
*/
|
|
53
52
|
const DEFAULT_PROPS: Partial<NotificationProps> = {
|
|
54
|
-
theme: Theme.light,
|
|
55
53
|
zIndex: 9999,
|
|
56
54
|
usePortal: true,
|
|
57
55
|
};
|
|
@@ -64,7 +62,8 @@ const DEFAULT_PROPS: Partial<NotificationProps> = {
|
|
|
64
62
|
* @param ref Component ref.
|
|
65
63
|
* @return React element.
|
|
66
64
|
*/
|
|
67
|
-
export const Notification
|
|
65
|
+
export const Notification = forwardRef<NotificationProps, HTMLDivElement>((props, ref) => {
|
|
66
|
+
const defaultTheme = useTheme() || Theme.light;
|
|
68
67
|
const {
|
|
69
68
|
actionLabel,
|
|
70
69
|
className,
|
|
@@ -72,7 +71,7 @@ export const Notification: Comp<NotificationProps, HTMLDivElement> = forwardRef(
|
|
|
72
71
|
isOpen,
|
|
73
72
|
onActionClick,
|
|
74
73
|
onClick,
|
|
75
|
-
theme,
|
|
74
|
+
theme = defaultTheme,
|
|
76
75
|
type,
|
|
77
76
|
zIndex,
|
|
78
77
|
usePortal,
|
|
@@ -1,18 +1,27 @@
|
|
|
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, screen } from '@testing-library/react';
|
|
5
|
+
import { ThemeSentinel } from '@lumx/react/testing/utils/ThemeSentinel';
|
|
5
6
|
import { Popover, PopoverProps } from './Popover';
|
|
6
7
|
|
|
7
8
|
const CLASSNAME = Popover.className as string;
|
|
8
9
|
|
|
9
|
-
const setup = (props: Partial<PopoverProps> = {}) => {
|
|
10
|
+
const setup = (props: Partial<PopoverProps> = {}, { wrapper }: SetupRenderOptions = {}) => {
|
|
10
11
|
const { container } = render(
|
|
11
12
|
<Popover isOpen anchorRef={{ current: null }} usePortal={false} {...props} data-testid="popover">
|
|
12
|
-
{props.children ||
|
|
13
|
+
{props.children || (
|
|
14
|
+
<>
|
|
15
|
+
Popover content
|
|
16
|
+
<ThemeSentinel />
|
|
17
|
+
</>
|
|
18
|
+
)}
|
|
13
19
|
</Popover>,
|
|
20
|
+
{ wrapper },
|
|
14
21
|
);
|
|
15
|
-
|
|
22
|
+
const element = screen.getByTestId('popover');
|
|
23
|
+
const themeSentinel = screen.getByTestId(ThemeSentinel.testId);
|
|
24
|
+
return { props, container, element, themeSentinel };
|
|
16
25
|
};
|
|
17
26
|
|
|
18
27
|
describe(`<${Popover.displayName}>`, () => {
|
|
@@ -41,5 +50,10 @@ describe(`<${Popover.displayName}>`, () => {
|
|
|
41
50
|
baseClassName: CLASSNAME,
|
|
42
51
|
forwardClassName: 'element',
|
|
43
52
|
forwardAttributes: 'element',
|
|
53
|
+
applyTheme: {
|
|
54
|
+
affects: [{ element: 'element' }, { not: { element: 'themeSentinel' } }],
|
|
55
|
+
viaProp: true,
|
|
56
|
+
viaContext: false,
|
|
57
|
+
},
|
|
44
58
|
});
|
|
45
59
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { ReactNode, RefObject, useRef } from 'react';
|
|
2
2
|
import { createPortal } from 'react-dom';
|
|
3
3
|
|
|
4
4
|
import classNames from 'classnames';
|
|
@@ -12,7 +12,9 @@ import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/classNam
|
|
|
12
12
|
import { useMergeRefs } from '@lumx/react/utils/mergeRefs';
|
|
13
13
|
import { useFocusTrap } from '@lumx/react/hooks/useFocusTrap';
|
|
14
14
|
import { skipRender } from '@lumx/react/utils/skipRender';
|
|
15
|
+
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
15
16
|
|
|
17
|
+
import { ThemeProvider } from '@lumx/react/utils/theme/ThemeContext';
|
|
16
18
|
import { useRestoreFocusOnClose } from './useRestoreFocusOnClose';
|
|
17
19
|
import { usePopoverStyle } from './usePopoverStyle';
|
|
18
20
|
import { Elevation, FitAnchorWidth, Offset, Placement, POPOVER_ZINDEX } from './constants';
|
|
@@ -97,7 +99,7 @@ const renderPopover = (children: ReactNode, usePortal?: boolean): any => {
|
|
|
97
99
|
};
|
|
98
100
|
|
|
99
101
|
// Inner component (must be wrapped before export)
|
|
100
|
-
const _InnerPopover
|
|
102
|
+
const _InnerPopover = forwardRef<PopoverProps, HTMLDivElement>((props, ref) => {
|
|
101
103
|
const {
|
|
102
104
|
anchorRef,
|
|
103
105
|
as: Component = 'div',
|
|
@@ -179,7 +181,7 @@ const _InnerPopover: Comp<PopoverProps, HTMLDivElement> = forwardRef((props, ref
|
|
|
179
181
|
</svg>
|
|
180
182
|
</div>
|
|
181
183
|
)}
|
|
182
|
-
{children}
|
|
184
|
+
<ThemeProvider value={undefined}>{children}</ThemeProvider>
|
|
183
185
|
</ClickAwayProvider>
|
|
184
186
|
</Component>,
|
|
185
187
|
usePortal,
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
2
3
|
import classNames from 'classnames';
|
|
3
4
|
|
|
4
|
-
import {
|
|
5
|
+
import { HasAriaLabelOrLabelledBy } from '@lumx/react/utils/type';
|
|
5
6
|
import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
|
|
7
|
+
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
6
8
|
|
|
7
9
|
import { Popover, PopoverProps } from '../popover/Popover';
|
|
8
10
|
|
|
@@ -34,7 +36,7 @@ const DEFAULT_PROPS: Partial<PopoverDialogProps> = {};
|
|
|
34
36
|
* * Sets a focus trap within the popover
|
|
35
37
|
* * Closes on click away and escape.
|
|
36
38
|
*/
|
|
37
|
-
export const PopoverDialog
|
|
39
|
+
export const PopoverDialog = forwardRef<PopoverDialogProps, HTMLDivElement>((props, ref) => {
|
|
38
40
|
const {
|
|
39
41
|
children,
|
|
40
42
|
isOpen,
|
|
@@ -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 { PostBlock, PostBlockProps } from './PostBlock';
|
|
7
7
|
|
|
8
8
|
const CLASSNAME = PostBlock.className as string;
|
|
9
9
|
|
|
10
|
-
const setup = (props: Partial<PostBlockProps> = {}) => {
|
|
11
|
-
render(<PostBlock {...(props as any)}
|
|
10
|
+
const setup = (props: Partial<PostBlockProps> = {}, { wrapper }: SetupRenderOptions = {}) => {
|
|
11
|
+
render(<PostBlock {...(props as any)} />, { wrapper });
|
|
12
12
|
const postBlock = queryByClassName(document.body, CLASSNAME);
|
|
13
13
|
return { props, postBlock };
|
|
14
14
|
};
|
|
@@ -19,5 +19,11 @@ describe(`<${PostBlock.displayName}>`, () => {
|
|
|
19
19
|
baseClassName: CLASSNAME,
|
|
20
20
|
forwardClassName: 'postBlock',
|
|
21
21
|
forwardAttributes: 'postBlock',
|
|
22
|
+
applyTheme: {
|
|
23
|
+
affects: [{ element: 'postBlock' }],
|
|
24
|
+
viaProp: true,
|
|
25
|
+
viaContext: true,
|
|
26
|
+
defaultTheme: 'light',
|
|
27
|
+
},
|
|
22
28
|
});
|
|
23
29
|
});
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
2
|
|
|
3
3
|
import classNames from 'classnames';
|
|
4
|
-
|
|
5
4
|
import isObject from 'lodash/isObject';
|
|
6
5
|
|
|
7
6
|
import { Orientation, Theme, Thumbnail, ThumbnailProps, ThumbnailVariant } from '@lumx/react';
|
|
8
|
-
|
|
9
|
-
import { Comp, GenericProps, HasTheme } from '@lumx/react/utils/type';
|
|
7
|
+
import { GenericProps, HasTheme } from '@lumx/react/utils/type';
|
|
10
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';
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Defines the props of the component.
|
|
@@ -50,7 +50,6 @@ const CLASSNAME = getRootClassName(COMPONENT_NAME);
|
|
|
50
50
|
*/
|
|
51
51
|
const DEFAULT_PROPS: Partial<PostBlockProps> = {
|
|
52
52
|
orientation: Orientation.horizontal,
|
|
53
|
-
theme: Theme.light,
|
|
54
53
|
};
|
|
55
54
|
|
|
56
55
|
/**
|
|
@@ -60,7 +59,8 @@ const DEFAULT_PROPS: Partial<PostBlockProps> = {
|
|
|
60
59
|
* @param ref Component ref.
|
|
61
60
|
* @return React element.
|
|
62
61
|
*/
|
|
63
|
-
export const PostBlock
|
|
62
|
+
export const PostBlock = forwardRef<PostBlockProps, HTMLDivElement>((props, ref) => {
|
|
63
|
+
const defaultTheme = useTheme() || Theme.light;
|
|
64
64
|
const {
|
|
65
65
|
actions,
|
|
66
66
|
attachments,
|
|
@@ -71,7 +71,7 @@ export const PostBlock: Comp<PostBlockProps, HTMLDivElement> = forwardRef((props
|
|
|
71
71
|
orientation,
|
|
72
72
|
tags,
|
|
73
73
|
text,
|
|
74
|
-
theme,
|
|
74
|
+
theme = defaultTheme,
|
|
75
75
|
thumbnailProps,
|
|
76
76
|
title,
|
|
77
77
|
...forwardedProps
|
|
@@ -88,7 +88,6 @@ export const PostBlock: Comp<PostBlockProps, HTMLDivElement> = forwardRef((props
|
|
|
88
88
|
<Thumbnail {...thumbnailProps} theme={theme} variant={ThumbnailVariant.rounded} />
|
|
89
89
|
</div>
|
|
90
90
|
)}
|
|
91
|
-
|
|
92
91
|
<div className={`${CLASSNAME}__wrapper`}>
|
|
93
92
|
{author && <div className={`${CLASSNAME}__author`}>{author}</div>}
|
|
94
93
|
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
|
|
5
5
|
import { Theme } from '@lumx/react';
|
|
6
|
-
|
|
7
|
-
import { Comp, GenericProps, HasTheme, ValueOf } from '@lumx/react/utils/type';
|
|
6
|
+
import { GenericProps, HasTheme, ValueOf } from '@lumx/react/utils/type';
|
|
8
7
|
import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
|
|
8
|
+
import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
|
|
9
|
+
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
10
|
+
|
|
9
11
|
import { ProgressLinear } from './ProgressLinear';
|
|
10
12
|
import { ProgressCircular } from './ProgressCircular';
|
|
11
13
|
|
|
@@ -37,7 +39,6 @@ const CLASSNAME = getRootClassName(COMPONENT_NAME);
|
|
|
37
39
|
* Component default props.
|
|
38
40
|
*/
|
|
39
41
|
const DEFAULT_PROPS: Partial<ProgressProps> = {
|
|
40
|
-
theme: Theme.light,
|
|
41
42
|
variant: ProgressVariant.circular,
|
|
42
43
|
};
|
|
43
44
|
|
|
@@ -49,8 +50,9 @@ const DEFAULT_PROPS: Partial<ProgressProps> = {
|
|
|
49
50
|
* @param ref Component ref.
|
|
50
51
|
* @return React element.
|
|
51
52
|
*/
|
|
52
|
-
export const Progress
|
|
53
|
-
const
|
|
53
|
+
export const Progress = forwardRef<ProgressProps, HTMLDivElement>((props, ref) => {
|
|
54
|
+
const defaultTheme = useTheme() || Theme.light;
|
|
55
|
+
const { className, theme = defaultTheme, variant, ...forwardedProps } = props;
|
|
54
56
|
|
|
55
57
|
return (
|
|
56
58
|
<div
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
3
|
import { getByClassName } from '@lumx/react/testing/utils/queries';
|
|
4
|
-
import { commonTestsSuiteRTL } from '@lumx/react/testing/utils';
|
|
4
|
+
import { commonTestsSuiteRTL, SetupRenderOptions } from '@lumx/react/testing/utils';
|
|
5
5
|
import { render } from '@testing-library/react';
|
|
6
|
-
import { Theme } from '@lumx/react';
|
|
7
6
|
|
|
8
7
|
import { ProgressCircular, ProgressCircularProps } from './ProgressCircular';
|
|
9
8
|
|
|
@@ -12,8 +11,8 @@ const CLASSNAME = ProgressCircular.className as string;
|
|
|
12
11
|
/**
|
|
13
12
|
* Mounts the component and returns common DOM elements / data needed in multiple tests further down.
|
|
14
13
|
*/
|
|
15
|
-
const setup = (props: Partial<ProgressCircularProps> = {}) => {
|
|
16
|
-
const { container } = render(<ProgressCircular {...(props as any)}
|
|
14
|
+
const setup = (props: Partial<ProgressCircularProps> = {}, { wrapper }: SetupRenderOptions = {}) => {
|
|
15
|
+
const { container } = render(<ProgressCircular {...(props as any)} />, { wrapper });
|
|
17
16
|
const element = getByClassName(container, CLASSNAME);
|
|
18
17
|
return { container, element, props };
|
|
19
18
|
};
|
|
@@ -21,23 +20,11 @@ const setup = (props: Partial<ProgressCircularProps> = {}) => {
|
|
|
21
20
|
describe(`<${ProgressCircular.displayName}>`, () => {
|
|
22
21
|
it('should render default', () => {
|
|
23
22
|
const { element } = setup();
|
|
24
|
-
expect(element).toBeInTheDocument();
|
|
25
|
-
expect(element).toHaveClass(CLASSNAME);
|
|
26
|
-
expect(element).toHaveClass(`${CLASSNAME}--theme-light`);
|
|
27
23
|
expect(element).toHaveClass(`${CLASSNAME}--size-m`);
|
|
28
24
|
});
|
|
29
25
|
|
|
30
|
-
it('should render dark theme', () => {
|
|
31
|
-
const { element } = setup({ theme: Theme.dark });
|
|
32
|
-
expect(element).toBeInTheDocument();
|
|
33
|
-
expect(element).toHaveClass(CLASSNAME);
|
|
34
|
-
expect(element).toHaveClass(`${CLASSNAME}--theme-dark`);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
26
|
it('should render size xs', () => {
|
|
38
27
|
const { element } = setup({ size: 'xs' });
|
|
39
|
-
expect(element).toBeInTheDocument();
|
|
40
|
-
expect(element).toHaveClass(CLASSNAME);
|
|
41
28
|
expect(element).toHaveClass(`${CLASSNAME}--size-xs`);
|
|
42
29
|
});
|
|
43
30
|
|
|
@@ -45,5 +32,11 @@ describe(`<${ProgressCircular.displayName}>`, () => {
|
|
|
45
32
|
baseClassName: CLASSNAME,
|
|
46
33
|
forwardClassName: 'element',
|
|
47
34
|
forwardAttributes: 'element',
|
|
35
|
+
applyTheme: {
|
|
36
|
+
affects: [{ element: 'element' }],
|
|
37
|
+
viaProp: true,
|
|
38
|
+
viaContext: true,
|
|
39
|
+
defaultTheme: 'light',
|
|
40
|
+
},
|
|
48
41
|
});
|
|
49
42
|
});
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
|
|
5
5
|
import { Theme, Size } from '@lumx/react';
|
|
6
|
-
|
|
7
|
-
import { Comp, GenericProps, HasTheme } from '@lumx/react/utils/type';
|
|
6
|
+
import { GenericProps, HasTheme } from '@lumx/react/utils/type';
|
|
8
7
|
import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
|
|
8
|
+
import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
|
|
9
|
+
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Progress sizes.
|
|
@@ -34,7 +35,6 @@ const CLASSNAME = getRootClassName(COMPONENT_NAME);
|
|
|
34
35
|
* Component default props.
|
|
35
36
|
*/
|
|
36
37
|
const DEFAULT_PROPS: Partial<ProgressCircularProps> = {
|
|
37
|
-
theme: Theme.light,
|
|
38
38
|
size: Size.m,
|
|
39
39
|
};
|
|
40
40
|
|
|
@@ -45,8 +45,9 @@ const DEFAULT_PROPS: Partial<ProgressCircularProps> = {
|
|
|
45
45
|
* @param ref Component ref.
|
|
46
46
|
* @return React element.
|
|
47
47
|
*/
|
|
48
|
-
export const ProgressCircular
|
|
49
|
-
const
|
|
48
|
+
export const ProgressCircular = forwardRef<ProgressCircularProps, HTMLDivElement>((props, ref) => {
|
|
49
|
+
const defaultTheme = useTheme() || Theme.light;
|
|
50
|
+
const { className, theme = defaultTheme, size, ...forwardedProps } = props;
|
|
50
51
|
|
|
51
52
|
return (
|
|
52
53
|
<div
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
3
|
import { getByClassName } from '@lumx/react/testing/utils/queries';
|
|
4
|
-
import { commonTestsSuiteRTL } from '@lumx/react/testing/utils';
|
|
4
|
+
import { commonTestsSuiteRTL, SetupRenderOptions } from '@lumx/react/testing/utils';
|
|
5
5
|
import { render } from '@testing-library/react';
|
|
6
|
-
import { Theme } from '@lumx/react';
|
|
7
6
|
|
|
8
7
|
import { ProgressLinear, ProgressLinearProps } from './ProgressLinear';
|
|
9
8
|
|
|
@@ -12,26 +11,22 @@ const CLASSNAME = ProgressLinear.className as string;
|
|
|
12
11
|
/**
|
|
13
12
|
* Mounts the component and returns common DOM elements / data needed in multiple tests further down.
|
|
14
13
|
*/
|
|
15
|
-
const setup = (props: Partial<ProgressLinearProps> = {}) => {
|
|
16
|
-
const { container } = render(<ProgressLinear {...(props as any)}
|
|
14
|
+
const setup = (props: Partial<ProgressLinearProps> = {}, { wrapper }: SetupRenderOptions = {}) => {
|
|
15
|
+
const { container } = render(<ProgressLinear {...(props as any)} />, { wrapper });
|
|
17
16
|
const element = getByClassName(container, CLASSNAME);
|
|
18
17
|
return { container, element, props };
|
|
19
18
|
};
|
|
20
19
|
|
|
21
20
|
describe(`<${ProgressLinear.displayName}>`, () => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
commonTestsSuiteRTL(setup, {
|
|
22
|
+
baseClassName: CLASSNAME,
|
|
23
|
+
forwardClassName: 'element',
|
|
24
|
+
forwardAttributes: 'element',
|
|
25
|
+
applyTheme: {
|
|
26
|
+
affects: [{ element: 'element' }],
|
|
27
|
+
viaProp: true,
|
|
28
|
+
viaContext: true,
|
|
29
|
+
defaultTheme: 'light',
|
|
30
|
+
},
|
|
27
31
|
});
|
|
28
|
-
|
|
29
|
-
it('should render dark theme', () => {
|
|
30
|
-
const { element } = setup({ theme: Theme.dark });
|
|
31
|
-
expect(element).toBeInTheDocument();
|
|
32
|
-
expect(element).toHaveClass(CLASSNAME);
|
|
33
|
-
expect(element).toHaveClass(`${CLASSNAME}--theme-dark`);
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
commonTestsSuiteRTL(setup, { baseClassName: CLASSNAME, forwardClassName: 'element', forwardAttributes: 'element' });
|
|
37
32
|
});
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
|
|
5
5
|
import { Theme } from '@lumx/react';
|
|
6
|
-
|
|
7
|
-
import { Comp, GenericProps, HasTheme } from '@lumx/react/utils/type';
|
|
6
|
+
import { GenericProps, HasTheme } from '@lumx/react/utils/type';
|
|
8
7
|
import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
|
|
8
|
+
import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
|
|
9
|
+
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
9
10
|
|
|
10
11
|
export interface ProgressLinearProps extends GenericProps, HasTheme {}
|
|
11
12
|
|
|
@@ -22,9 +23,7 @@ const CLASSNAME = getRootClassName(COMPONENT_NAME);
|
|
|
22
23
|
/**
|
|
23
24
|
* Component default props.
|
|
24
25
|
*/
|
|
25
|
-
const DEFAULT_PROPS: Partial<ProgressLinearProps> = {
|
|
26
|
-
theme: Theme.light,
|
|
27
|
-
};
|
|
26
|
+
const DEFAULT_PROPS: Partial<ProgressLinearProps> = {};
|
|
28
27
|
|
|
29
28
|
/**
|
|
30
29
|
* ProgressLinear component.
|
|
@@ -33,8 +32,9 @@ const DEFAULT_PROPS: Partial<ProgressLinearProps> = {
|
|
|
33
32
|
* @param ref Component ref.
|
|
34
33
|
* @return React element.
|
|
35
34
|
*/
|
|
36
|
-
export const ProgressLinear
|
|
37
|
-
const
|
|
35
|
+
export const ProgressLinear = forwardRef<ProgressLinearProps, HTMLDivElement>((props, ref) => {
|
|
36
|
+
const defaultTheme = useTheme() || Theme.light;
|
|
37
|
+
const { className, theme = defaultTheme, ...forwardedProps } = props;
|
|
38
38
|
|
|
39
39
|
return (
|
|
40
40
|
<div
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { ReactNode } 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, handleBasicClasses } from '@lumx/react/utils/className';
|
|
7
7
|
import { mergeRefs } from '@lumx/react/utils/mergeRefs';
|
|
8
|
+
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
9
|
+
|
|
8
10
|
import { useRovingTabIndex } from '../../hooks/useRovingTabIndex';
|
|
9
11
|
import { useTabProviderContextState } from '../tabs/state';
|
|
10
12
|
|
|
@@ -42,7 +44,7 @@ const DEFAULT_PROPS: Partial<ProgressTrackerProps> = {};
|
|
|
42
44
|
* @param ref Component ref.
|
|
43
45
|
* @return React element.
|
|
44
46
|
*/
|
|
45
|
-
export const ProgressTracker
|
|
47
|
+
export const ProgressTracker = forwardRef<ProgressTrackerProps, HTMLDivElement>((props, ref) => {
|
|
46
48
|
const { 'aria-label': ariaLabel, children, className, ...forwardedProps } = props;
|
|
47
49
|
const stepListRef = React.useRef(null);
|
|
48
50
|
useRovingTabIndex({
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import React, { FocusEventHandler,
|
|
1
|
+
import React, { FocusEventHandler, KeyboardEventHandler, useCallback } from 'react';
|
|
2
2
|
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
|
|
5
|
+
import { mdiAlertCircle, mdiCheckCircle, mdiRadioboxBlank, mdiRadioboxMarked } from '@lumx/icons';
|
|
5
6
|
import { Icon, InputHelper, InputLabel, Kind, Size } from '@lumx/react';
|
|
6
|
-
|
|
7
|
-
import { Comp, GenericProps } from '@lumx/react/utils/type';
|
|
7
|
+
import { GenericProps } from '@lumx/react/utils/type';
|
|
8
8
|
import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
|
|
9
|
+
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
9
10
|
|
|
10
|
-
import { mdiAlertCircle, mdiCheckCircle, mdiRadioboxBlank, mdiRadioboxMarked } from '@lumx/icons';
|
|
11
11
|
import { useTabProviderContext } from '../tabs/state';
|
|
12
12
|
|
|
13
13
|
/**
|
|
@@ -56,7 +56,7 @@ const DEFAULT_PROPS: Partial<ProgressTrackerStepProps> = {};
|
|
|
56
56
|
* @param ref Component ref.
|
|
57
57
|
* @return React element.
|
|
58
58
|
*/
|
|
59
|
-
export const ProgressTrackerStep
|
|
59
|
+
export const ProgressTrackerStep = forwardRef<ProgressTrackerStepProps, HTMLButtonElement>((props, ref) => {
|
|
60
60
|
const {
|
|
61
61
|
className,
|
|
62
62
|
disabled,
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
|
|
1
5
|
import { useTabProviderContext } from '@lumx/react/components/tabs/state';
|
|
2
6
|
import { CSS_PREFIX } from '@lumx/react/constants';
|
|
3
|
-
import {
|
|
7
|
+
import { GenericProps } from '@lumx/react/utils/type';
|
|
4
8
|
import { handleBasicClasses } from '@lumx/react/utils/className';
|
|
5
|
-
|
|
6
|
-
import classNames from 'classnames';
|
|
7
|
-
import React, { forwardRef } from 'react';
|
|
9
|
+
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
8
10
|
|
|
9
11
|
/**
|
|
10
12
|
* Defines the props of the component.
|
|
@@ -40,28 +42,26 @@ const DEFAULT_PROPS: Partial<ProgressTrackerStepPanelProps> = {};
|
|
|
40
42
|
* @param ref Component ref.
|
|
41
43
|
* @return React element.
|
|
42
44
|
*/
|
|
43
|
-
export const ProgressTrackerStepPanel
|
|
44
|
-
|
|
45
|
-
const { children, id, className, isActive: propIsActive, ...forwardedProps } = props;
|
|
45
|
+
export const ProgressTrackerStepPanel = forwardRef<ProgressTrackerStepPanelProps, HTMLDivElement>((props, ref) => {
|
|
46
|
+
const { children, id, className, isActive: propIsActive, ...forwardedProps } = props;
|
|
46
47
|
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
const state = useTabProviderContext('tabPanel', id);
|
|
49
|
+
const isActive = propIsActive || state?.isActive;
|
|
49
50
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
);
|
|
51
|
+
return (
|
|
52
|
+
<div
|
|
53
|
+
ref={ref}
|
|
54
|
+
{...forwardedProps}
|
|
55
|
+
id={state?.tabPanelId}
|
|
56
|
+
className={classNames(className, handleBasicClasses({ prefix: CLASSNAME, isActive }))}
|
|
57
|
+
role="tabpanel"
|
|
58
|
+
tabIndex={isActive ? 0 : -1}
|
|
59
|
+
aria-labelledby={state?.tabId}
|
|
60
|
+
>
|
|
61
|
+
{(!state?.isLazy || isActive) && children}
|
|
62
|
+
</div>
|
|
63
|
+
);
|
|
64
|
+
});
|
|
65
65
|
ProgressTrackerStepPanel.displayName = COMPONENT_NAME;
|
|
66
66
|
ProgressTrackerStepPanel.className = CLASSNAME;
|
|
67
67
|
ProgressTrackerStepPanel.defaultProps = DEFAULT_PROPS;
|
|
@@ -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 { getByClassName, getByTagName, queryByClassName } from '@lumx/react/testing/utils/queries';
|
|
5
5
|
import { render } from '@testing-library/react';
|
|
6
6
|
import userEvent from '@testing-library/user-event';
|
|
@@ -14,9 +14,9 @@ type SetupProps = Partial<RadioButtonProps>;
|
|
|
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(<RadioButton {...props}
|
|
19
|
+
render(<RadioButton {...props} />, { wrapper });
|
|
20
20
|
|
|
21
21
|
const radioButton = getByClassName(document.body, CLASSNAME);
|
|
22
22
|
const helper = queryByClassName(radioButton, `${CLASSNAME}__helper`);
|
|
@@ -105,5 +105,11 @@ describe(`<${RadioButton.displayName}>`, () => {
|
|
|
105
105
|
baseClassName: CLASSNAME,
|
|
106
106
|
forwardClassName: 'radioButton',
|
|
107
107
|
forwardAttributes: 'radioButton',
|
|
108
|
+
applyTheme: {
|
|
109
|
+
affects: [{ element: 'radioButton' }],
|
|
110
|
+
viaProp: true,
|
|
111
|
+
viaContext: true,
|
|
112
|
+
defaultTheme: 'light',
|
|
113
|
+
},
|
|
108
114
|
});
|
|
109
115
|
});
|