@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
|
@@ -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, handleBasicClasses } 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.
|
|
@@ -39,7 +40,7 @@ const DEFAULT_PROPS: Partial<TableRowProps> = {};
|
|
|
39
40
|
* @param ref Component ref.
|
|
40
41
|
* @return React element.
|
|
41
42
|
*/
|
|
42
|
-
export const TableRow
|
|
43
|
+
export const TableRow = forwardRef<TableRowProps, HTMLTableRowElement>((props, ref) => {
|
|
43
44
|
const { children, className, disabled, isClickable, isDisabled = disabled, isSelected, ...forwardedProps } = props;
|
|
44
45
|
|
|
45
46
|
return (
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import React, { FocusEventHandler,
|
|
1
|
+
import React, { FocusEventHandler, KeyboardEventHandler, ReactNode, useCallback } from 'react';
|
|
2
2
|
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
|
|
5
5
|
import { Icon, IconProps, Size, Text } from '@lumx/react';
|
|
6
6
|
import { CSS_PREFIX } from '@lumx/react/constants';
|
|
7
|
-
import {
|
|
7
|
+
import { GenericProps } from '@lumx/react/utils/type';
|
|
8
8
|
import { handleBasicClasses } from '@lumx/react/utils/className';
|
|
9
|
+
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
9
10
|
|
|
10
11
|
import { useTabProviderContext } from './state';
|
|
11
12
|
|
|
@@ -53,7 +54,7 @@ const DEFAULT_PROPS: Partial<TabProps> = {};
|
|
|
53
54
|
* @param ref Component ref.
|
|
54
55
|
* @return React element.
|
|
55
56
|
*/
|
|
56
|
-
export const Tab
|
|
57
|
+
export const Tab = forwardRef<TabProps, HTMLButtonElement>((props, ref) => {
|
|
57
58
|
const {
|
|
58
59
|
className,
|
|
59
60
|
disabled,
|
|
@@ -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
|
});
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
|
|
1
5
|
import { Alignment, Theme } from '@lumx/react';
|
|
2
6
|
import { CSS_PREFIX } from '@lumx/react/constants';
|
|
3
|
-
import {
|
|
7
|
+
import { GenericProps, HasTheme } from '@lumx/react/utils/type';
|
|
4
8
|
import { handleBasicClasses } from '@lumx/react/utils/className';
|
|
5
9
|
import { mergeRefs } from '@lumx/react/utils/mergeRefs';
|
|
10
|
+
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
11
|
+
import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
|
|
6
12
|
|
|
7
|
-
import classNames from 'classnames';
|
|
8
|
-
import React, { forwardRef, ReactNode } from 'react';
|
|
9
13
|
import { useRovingTabIndex } from '../../hooks/useRovingTabIndex';
|
|
10
14
|
|
|
11
15
|
export enum TabListLayout {
|
|
@@ -43,7 +47,6 @@ const CLASSNAME = `${CSS_PREFIX}-tabs`;
|
|
|
43
47
|
const DEFAULT_PROPS: Partial<TabListProps> = {
|
|
44
48
|
layout: TabListLayout.fixed,
|
|
45
49
|
position: Alignment.left,
|
|
46
|
-
theme: Theme.light,
|
|
47
50
|
};
|
|
48
51
|
|
|
49
52
|
/**
|
|
@@ -55,8 +58,17 @@ const DEFAULT_PROPS: Partial<TabListProps> = {
|
|
|
55
58
|
* @param ref Component ref.
|
|
56
59
|
* @return React element.
|
|
57
60
|
*/
|
|
58
|
-
export const TabList
|
|
59
|
-
const
|
|
61
|
+
export const TabList = forwardRef<TabListProps, HTMLDivElement>((props, ref) => {
|
|
62
|
+
const defaultTheme = useTheme() || Theme.light;
|
|
63
|
+
const {
|
|
64
|
+
'aria-label': ariaLabel,
|
|
65
|
+
children,
|
|
66
|
+
className,
|
|
67
|
+
layout,
|
|
68
|
+
position,
|
|
69
|
+
theme = defaultTheme,
|
|
70
|
+
...forwardedProps
|
|
71
|
+
} = props;
|
|
60
72
|
const tabListRef = React.useRef(null);
|
|
61
73
|
useRovingTabIndex({
|
|
62
74
|
parentRef: tabListRef,
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
|
|
5
|
+
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
1
6
|
import { useTabProviderContext } from '@lumx/react/components/tabs/state';
|
|
2
7
|
import { CSS_PREFIX } from '@lumx/react/constants';
|
|
3
|
-
import {
|
|
8
|
+
import { GenericProps } from '@lumx/react/utils/type';
|
|
4
9
|
import { handleBasicClasses } from '@lumx/react/utils/className';
|
|
5
10
|
|
|
6
|
-
import classNames from 'classnames';
|
|
7
|
-
import React, { forwardRef } from 'react';
|
|
8
|
-
|
|
9
11
|
/**
|
|
10
12
|
* Defines the props of the component.
|
|
11
13
|
*/
|
|
@@ -40,7 +42,7 @@ const DEFAULT_PROPS: Partial<TabPanelProps> = {};
|
|
|
40
42
|
* @param ref Component ref.
|
|
41
43
|
* @return React element.
|
|
42
44
|
*/
|
|
43
|
-
export const TabPanel
|
|
45
|
+
export const TabPanel = forwardRef<TabPanelProps, HTMLDivElement>((props, ref) => {
|
|
44
46
|
const { children, id, className, isActive: propIsActive, ...forwardedProps } = props;
|
|
45
47
|
|
|
46
48
|
const state = useTabProviderContext('tabPanel', id);
|
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
import React, { Children, Fragment
|
|
1
|
+
import React, { Children, Fragment } from 'react';
|
|
2
|
+
|
|
3
|
+
import classNames from 'classnames';
|
|
2
4
|
|
|
3
5
|
import { Icon, ColorPalette, ColorVariant, Typography, WhiteSpace } from '@lumx/react';
|
|
4
|
-
import {
|
|
6
|
+
import { GenericProps, TextElement, isComponent } from '@lumx/react/utils/type';
|
|
5
7
|
import {
|
|
6
8
|
getFontColorClassName,
|
|
7
9
|
getRootClassName,
|
|
8
10
|
handleBasicClasses,
|
|
9
11
|
getTypographyClassName,
|
|
10
12
|
} from '@lumx/react/utils/className';
|
|
11
|
-
import classNames from 'classnames';
|
|
12
13
|
import { useOverflowTooltipLabel } from '@lumx/react/hooks/useOverflowTooltipLabel';
|
|
13
14
|
import { useMergeRefs } from '@lumx/react/utils/mergeRefs';
|
|
15
|
+
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
14
16
|
|
|
15
17
|
/**
|
|
16
18
|
* Defines the props of the component.
|
|
@@ -73,7 +75,7 @@ const DEFAULT_PROPS = {} as const;
|
|
|
73
75
|
* @param ref Component ref.
|
|
74
76
|
* @return React element.
|
|
75
77
|
*/
|
|
76
|
-
export const Text
|
|
78
|
+
export const Text = forwardRef<TextProps>((props, ref) => {
|
|
77
79
|
const {
|
|
78
80
|
as: Component,
|
|
79
81
|
children,
|
|
@@ -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
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { ReactNode, Ref, RefObject, SyntheticEvent, useEffect, useRef, useState } from 'react';
|
|
2
2
|
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
import get from 'lodash/get';
|
|
@@ -16,10 +16,12 @@ import {
|
|
|
16
16
|
Size,
|
|
17
17
|
Theme,
|
|
18
18
|
} from '@lumx/react';
|
|
19
|
-
import {
|
|
19
|
+
import { 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';
|
|
24
|
+
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
23
25
|
|
|
24
26
|
/**
|
|
25
27
|
* Defines the props of the component.
|
|
@@ -101,7 +103,6 @@ const DEFAULT_MIN_ROWS = 2;
|
|
|
101
103
|
* Component default props.
|
|
102
104
|
*/
|
|
103
105
|
const DEFAULT_PROPS: Partial<TextFieldProps> = {
|
|
104
|
-
theme: Theme.light,
|
|
105
106
|
type: 'text',
|
|
106
107
|
};
|
|
107
108
|
|
|
@@ -254,7 +255,8 @@ const renderInputNative: React.FC<InputNativeProps> = (props) => {
|
|
|
254
255
|
* @param ref Component ref.
|
|
255
256
|
* @return React element.
|
|
256
257
|
*/
|
|
257
|
-
export const TextField
|
|
258
|
+
export const TextField = forwardRef<TextFieldProps, HTMLDivElement>((props, ref) => {
|
|
259
|
+
const defaultTheme = useTheme() || Theme.light;
|
|
258
260
|
const {
|
|
259
261
|
chips,
|
|
260
262
|
className,
|
|
@@ -282,7 +284,7 @@ export const TextField: Comp<TextFieldProps, HTMLDivElement> = forwardRef((props
|
|
|
282
284
|
onFocus,
|
|
283
285
|
placeholder,
|
|
284
286
|
textFieldRef,
|
|
285
|
-
theme,
|
|
287
|
+
theme = defaultTheme,
|
|
286
288
|
type,
|
|
287
289
|
value,
|
|
288
290
|
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
|
});
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React, {
|
|
2
2
|
CSSProperties,
|
|
3
|
-
forwardRef,
|
|
4
3
|
ImgHTMLAttributes,
|
|
5
4
|
KeyboardEventHandler,
|
|
6
5
|
MouseEventHandler,
|
|
@@ -9,17 +8,19 @@ import React, {
|
|
|
9
8
|
Ref,
|
|
10
9
|
useState,
|
|
11
10
|
} from 'react';
|
|
11
|
+
|
|
12
12
|
import classNames from 'classnames';
|
|
13
13
|
|
|
14
14
|
import { AspectRatio, HorizontalAlignment, Icon, Size, Theme, ThumbnailObjectFit } from '@lumx/react';
|
|
15
|
-
|
|
16
|
-
import { Comp, Falsy, GenericProps, HasTheme } from '@lumx/react/utils/type';
|
|
15
|
+
import { Falsy, GenericProps, HasTheme } from '@lumx/react/utils/type';
|
|
17
16
|
import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
|
|
18
|
-
|
|
19
17
|
import { mdiImageBroken } from '@lumx/icons';
|
|
20
18
|
import { useMergeRefs } from '@lumx/react/utils/mergeRefs';
|
|
21
19
|
import { useImageLoad } from '@lumx/react/components/thumbnail/useImageLoad';
|
|
22
20
|
import { useFocusPointStyle } from '@lumx/react/components/thumbnail/useFocusPointStyle';
|
|
21
|
+
import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
|
|
22
|
+
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
23
|
+
|
|
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
|
/**
|
|
@@ -98,7 +98,8 @@ const DEFAULT_PROPS: Partial<ThumbnailProps> = {
|
|
|
98
98
|
* @param ref Component ref.
|
|
99
99
|
* @return React element.
|
|
100
100
|
*/
|
|
101
|
-
export const Thumbnail
|
|
101
|
+
export const Thumbnail = forwardRef<ThumbnailProps>((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,9 +1,10 @@
|
|
|
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
|
+
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Defines the props of the component.
|
|
@@ -39,7 +40,7 @@ const DEFAULT_PROPS: Partial<ToolbarProps> = {};
|
|
|
39
40
|
* @param ref Component ref.
|
|
40
41
|
* @return React element.
|
|
41
42
|
*/
|
|
42
|
-
export const Toolbar
|
|
43
|
+
export const Toolbar = forwardRef<ToolbarProps, HTMLDivElement>((props, ref) => {
|
|
43
44
|
const { after, before, className, label, ...forwardedProps } = props;
|
|
44
45
|
|
|
45
46
|
return (
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
/* eslint-disable react-hooks/rules-of-hooks */
|
|
2
|
-
import React, {
|
|
2
|
+
import React, { ReactNode, useState } from 'react';
|
|
3
3
|
import { createPortal } from 'react-dom';
|
|
4
4
|
|
|
5
5
|
import classNames from 'classnames';
|
|
6
6
|
|
|
7
7
|
import { DOCUMENT, VISUALLY_HIDDEN } from '@lumx/react/constants';
|
|
8
|
-
import {
|
|
8
|
+
import { GenericProps, HasCloseMode } from '@lumx/react/utils/type';
|
|
9
9
|
import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
|
|
10
10
|
import { useMergeRefs } from '@lumx/react/utils/mergeRefs';
|
|
11
11
|
import { Placement } from '@lumx/react/components/popover';
|
|
12
12
|
import { TooltipContextProvider } from '@lumx/react/components/tooltip/context';
|
|
13
13
|
import { useId } from '@lumx/react/hooks/useId';
|
|
14
14
|
import { usePopper } from '@lumx/react/hooks/usePopper';
|
|
15
|
+
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
15
16
|
|
|
16
17
|
import { ARIA_LINK_MODES, TOOLTIP_ZINDEX } from '@lumx/react/components/tooltip/constants';
|
|
17
18
|
import { useInjectTooltipRef } from './useInjectTooltipRef';
|
|
@@ -70,7 +71,7 @@ const ARROW_SIZE = 8;
|
|
|
70
71
|
* @param ref Component ref.
|
|
71
72
|
* @return React element.
|
|
72
73
|
*/
|
|
73
|
-
export const Tooltip
|
|
74
|
+
export const Tooltip = forwardRef<TooltipProps, HTMLDivElement>((props, ref) => {
|
|
74
75
|
const {
|
|
75
76
|
label,
|
|
76
77
|
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
|
|
|
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
|
});
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { MouseEventHandler } from 'react';
|
|
2
|
+
|
|
2
3
|
import classNames from 'classnames';
|
|
3
4
|
|
|
4
5
|
import { AspectRatio, Icon, Size, Theme } from '@lumx/react';
|
|
5
|
-
import {
|
|
6
|
+
import { GenericProps, HasTheme, ValueOf } from '@lumx/react/utils/type';
|
|
6
7
|
import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
|
|
7
8
|
import { useBooleanState } from '@lumx/react/hooks/useBooleanState';
|
|
8
9
|
import { useId } from '@lumx/react/hooks/useId';
|
|
10
|
+
import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
|
|
11
|
+
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
9
12
|
|
|
10
13
|
/**
|
|
11
14
|
* Uploader variants.
|
|
@@ -65,7 +68,6 @@ const CLASSNAME = getRootClassName(COMPONENT_NAME);
|
|
|
65
68
|
const DEFAULT_PROPS: Partial<UploaderProps> = {
|
|
66
69
|
aspectRatio: AspectRatio.horizontal,
|
|
67
70
|
size: Size.xl,
|
|
68
|
-
theme: Theme.light,
|
|
69
71
|
variant: UploaderVariant.square,
|
|
70
72
|
};
|
|
71
73
|
|
|
@@ -76,8 +78,19 @@ const DEFAULT_PROPS: Partial<UploaderProps> = {
|
|
|
76
78
|
* @param ref Component ref.
|
|
77
79
|
* @return React element.
|
|
78
80
|
*/
|
|
79
|
-
export const Uploader
|
|
80
|
-
const
|
|
81
|
+
export const Uploader = forwardRef<UploaderProps>((props, ref) => {
|
|
82
|
+
const defaultTheme = useTheme() || Theme.light;
|
|
83
|
+
const {
|
|
84
|
+
aspectRatio,
|
|
85
|
+
className,
|
|
86
|
+
label,
|
|
87
|
+
icon,
|
|
88
|
+
size,
|
|
89
|
+
theme = defaultTheme,
|
|
90
|
+
variant,
|
|
91
|
+
fileInputProps,
|
|
92
|
+
...forwardedProps
|
|
93
|
+
} = props;
|
|
81
94
|
// Adjust to square aspect ratio when using circle variants.
|
|
82
95
|
const adjustedAspectRatio = variant === UploaderVariant.circle ? AspectRatio.square : aspectRatio;
|
|
83
96
|
|
|
@@ -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, within } from '@testing-library/react';
|
|
5
5
|
import { getByClassName, queryByClassName } from '@lumx/react/testing/utils/queries';
|
|
6
6
|
import { Thumbnail } from '@lumx/react';
|
|
@@ -13,10 +13,10 @@ const CLASSNAME = UserBlock.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 = (propsOverride: Partial<UserBlockProps> = {}) => {
|
|
16
|
+
const setup = (propsOverride: Partial<UserBlockProps> = {}, { wrapper }: SetupRenderOptions = {}) => {
|
|
17
17
|
const props: UserBlockProps = { ...propsOverride };
|
|
18
18
|
|
|
19
|
-
render(<UserBlock {...props}
|
|
19
|
+
render(<UserBlock {...props} />, { wrapper });
|
|
20
20
|
const userBlock = getByClassName(document.body, CLASSNAME);
|
|
21
21
|
const name = queryByClassName(userBlock, `${CLASSNAME}__name`);
|
|
22
22
|
const avatar = queryByClassName(userBlock, `${CLASSNAME}__avatar`);
|
|
@@ -86,5 +86,11 @@ describe(`<${UserBlock.displayName}>`, () => {
|
|
|
86
86
|
forwardClassName: 'userBlock',
|
|
87
87
|
forwardAttributes: 'userBlock',
|
|
88
88
|
forwardRef: 'userBlock',
|
|
89
|
+
applyTheme: {
|
|
90
|
+
affects: [{ element: 'userBlock' }],
|
|
91
|
+
viaProp: true,
|
|
92
|
+
viaContext: true,
|
|
93
|
+
defaultTheme: 'light',
|
|
94
|
+
},
|
|
89
95
|
});
|
|
90
96
|
});
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
|
|
3
3
|
import classNames from 'classnames';
|
|
4
|
+
import isEmpty from 'lodash/isEmpty';
|
|
4
5
|
import set from 'lodash/set';
|
|
5
6
|
|
|
6
7
|
import { Avatar, ColorPalette, Link, Orientation, Size, Theme } from '@lumx/react';
|
|
7
|
-
import {
|
|
8
|
+
import { GenericProps, HasTheme } from '@lumx/react/utils/type';
|
|
8
9
|
import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
|
|
10
|
+
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
9
11
|
|
|
12
|
+
import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
|
|
10
13
|
import { AvatarProps } from '../avatar/Avatar';
|
|
11
14
|
|
|
12
15
|
/**
|
|
@@ -62,7 +65,6 @@ const CLASSNAME = getRootClassName(COMPONENT_NAME);
|
|
|
62
65
|
const DEFAULT_PROPS: Partial<UserBlockProps> = {
|
|
63
66
|
orientation: Orientation.horizontal,
|
|
64
67
|
size: Size.m,
|
|
65
|
-
theme: Theme.light,
|
|
66
68
|
};
|
|
67
69
|
|
|
68
70
|
/**
|
|
@@ -72,7 +74,8 @@ const DEFAULT_PROPS: Partial<UserBlockProps> = {
|
|
|
72
74
|
* @param ref Component ref.
|
|
73
75
|
* @return React element.
|
|
74
76
|
*/
|
|
75
|
-
export const UserBlock
|
|
77
|
+
export const UserBlock = forwardRef<UserBlockProps, HTMLDivElement>((props, ref) => {
|
|
78
|
+
const defaultTheme = useTheme() || Theme.light;
|
|
76
79
|
const {
|
|
77
80
|
avatarProps,
|
|
78
81
|
className,
|
|
@@ -88,7 +91,7 @@ export const UserBlock: Comp<UserBlockProps, HTMLDivElement> = forwardRef((props
|
|
|
88
91
|
orientation,
|
|
89
92
|
simpleAction,
|
|
90
93
|
size,
|
|
91
|
-
theme,
|
|
94
|
+
theme = defaultTheme,
|
|
92
95
|
...forwardedProps
|
|
93
96
|
} = props;
|
|
94
97
|
let componentSize = size;
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
|
|
3
|
+
|
|
4
|
+
const TEST_ID = 'theme-sentinel';
|
|
5
|
+
|
|
6
|
+
/** Test component used as sentinel to detect the value of the theme context */
|
|
7
|
+
export function ThemeSentinel() {
|
|
8
|
+
const theme = useTheme();
|
|
9
|
+
return <div data-testid={TEST_ID} className={`--theme-${theme}`} />;
|
|
10
|
+
}
|
|
11
|
+
ThemeSentinel.testId = TEST_ID;
|