@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,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 { queryByRole, render, screen } from '@testing-library/react';
|
|
5
5
|
import { getByClassName, queryByClassName } from '@lumx/react/testing/utils/queries';
|
|
6
6
|
import userEvent from '@testing-library/user-event';
|
|
@@ -29,7 +29,10 @@ const ControlledComponent = (props: ExpansionPanelProps) => {
|
|
|
29
29
|
/**
|
|
30
30
|
* Mounts the component and returns common DOM elements / data needed in multiple tests further down.
|
|
31
31
|
*/
|
|
32
|
-
const setup = (
|
|
32
|
+
const setup = (
|
|
33
|
+
propsOverride: Partial<ExpansionPanelProps> = {},
|
|
34
|
+
options: { controlled?: boolean; wrapper?: SetupRenderOptions['wrapper'] } = {},
|
|
35
|
+
) => {
|
|
33
36
|
const props = {
|
|
34
37
|
toggleButtonProps: { label: 'Toggle' },
|
|
35
38
|
children: mockChildrenContent,
|
|
@@ -37,7 +40,7 @@ const setup = (propsOverride: Partial<ExpansionPanelProps> = {}, options: { cont
|
|
|
37
40
|
};
|
|
38
41
|
|
|
39
42
|
const Component = options.controlled ? ControlledComponent : ExpansionPanel;
|
|
40
|
-
const { container } = render(<Component {...props}
|
|
43
|
+
const { container } = render(<Component {...props} />, { wrapper: options.wrapper });
|
|
41
44
|
|
|
42
45
|
return {
|
|
43
46
|
container,
|
|
@@ -154,5 +157,11 @@ describe(`<${ExpansionPanel.displayName}>`, () => {
|
|
|
154
157
|
forwardClassName: 'element',
|
|
155
158
|
forwardAttributes: 'element',
|
|
156
159
|
forwardRef: 'element',
|
|
160
|
+
applyTheme: {
|
|
161
|
+
affects: [{ element: 'element' }],
|
|
162
|
+
viaProp: true,
|
|
163
|
+
viaContext: true,
|
|
164
|
+
defaultTheme: 'light',
|
|
165
|
+
},
|
|
157
166
|
});
|
|
158
167
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { Children,
|
|
1
|
+
import React, { Children, PropsWithChildren, ReactNode, useEffect, useRef, useState } from 'react';
|
|
2
2
|
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
|
|
@@ -9,11 +9,13 @@ import isEmpty from 'lodash/isEmpty';
|
|
|
9
9
|
import isFunction from 'lodash/isFunction';
|
|
10
10
|
|
|
11
11
|
import { ColorPalette, DragHandle, Emphasis, IconButton, IconButtonProps, Theme } from '@lumx/react';
|
|
12
|
-
import {
|
|
12
|
+
import { GenericProps, HasTheme, isComponent } from '@lumx/react/utils/type';
|
|
13
13
|
import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
|
|
14
14
|
import { partitionMulti } from '@lumx/react/utils/partitionMulti';
|
|
15
15
|
import { useTransitionVisibility } from '@lumx/react/hooks/useTransitionVisibility';
|
|
16
16
|
import { EXPANSION_PANEL_TRANSITION_DURATION } from '@lumx/core/js/constants';
|
|
17
|
+
import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
|
|
18
|
+
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
17
19
|
|
|
18
20
|
/**
|
|
19
21
|
* Defines the props of the component.
|
|
@@ -51,9 +53,7 @@ const CLASSNAME = getRootClassName(COMPONENT_NAME);
|
|
|
51
53
|
/**
|
|
52
54
|
* Component default props.
|
|
53
55
|
*/
|
|
54
|
-
const DEFAULT_PROPS: Partial<ExpansionPanelProps> = {
|
|
55
|
-
theme: Theme.light,
|
|
56
|
-
};
|
|
56
|
+
const DEFAULT_PROPS: Partial<ExpansionPanelProps> = {};
|
|
57
57
|
|
|
58
58
|
const isDragHandle = isComponent(DragHandle);
|
|
59
59
|
const isHeader = isComponent('header');
|
|
@@ -66,7 +66,8 @@ const isFooter = isComponent('footer');
|
|
|
66
66
|
* @param ref Component ref.
|
|
67
67
|
* @return React element.
|
|
68
68
|
*/
|
|
69
|
-
export const ExpansionPanel
|
|
69
|
+
export const ExpansionPanel = forwardRef<ExpansionPanelProps, HTMLDivElement>((props, ref) => {
|
|
70
|
+
const defaultTheme = useTheme() || Theme.light;
|
|
70
71
|
const {
|
|
71
72
|
className,
|
|
72
73
|
children: anyChildren,
|
|
@@ -77,7 +78,7 @@ export const ExpansionPanel: Comp<ExpansionPanelProps, HTMLDivElement> = forward
|
|
|
77
78
|
onClose,
|
|
78
79
|
onOpen,
|
|
79
80
|
onToggleOpen,
|
|
80
|
-
theme,
|
|
81
|
+
theme = defaultTheme,
|
|
81
82
|
toggleButtonProps,
|
|
82
83
|
...forwardedProps
|
|
83
84
|
} = props;
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
|
|
3
3
|
import { ColorPalette, Theme } from '@lumx/react';
|
|
4
4
|
import { mdiAbTesting } from '@lumx/icons';
|
|
5
|
-
import { commonTestsSuiteRTL } from '@lumx/react/testing/utils';
|
|
5
|
+
import { commonTestsSuiteRTL, SetupRenderOptions } from '@lumx/react/testing/utils';
|
|
6
6
|
import { getByClassName, queryByClassName } from '@lumx/react/testing/utils/queries';
|
|
7
7
|
import { render } from '@testing-library/react';
|
|
8
8
|
|
|
@@ -13,10 +13,10 @@ const CLASSNAME = Flag.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 = (propOverrides: Partial<FlagProps> = {}) => {
|
|
16
|
+
const setup = (propOverrides: Partial<FlagProps> = {}, { wrapper }: SetupRenderOptions = {}) => {
|
|
17
17
|
const props = { label: 'default', ...propOverrides };
|
|
18
18
|
|
|
19
|
-
render(<Flag {...props}
|
|
19
|
+
render(<Flag {...props} />, { wrapper });
|
|
20
20
|
const flag = getByClassName(document.body, CLASSNAME);
|
|
21
21
|
const icon = queryByClassName(flag, `${CLASSNAME}__icon`);
|
|
22
22
|
|
|
@@ -50,5 +50,15 @@ describe(`<${Flag.displayName} />`, () => {
|
|
|
50
50
|
});
|
|
51
51
|
|
|
52
52
|
// Common tests suite.
|
|
53
|
-
commonTestsSuiteRTL(setup, {
|
|
53
|
+
commonTestsSuiteRTL(setup, {
|
|
54
|
+
baseClassName: CLASSNAME,
|
|
55
|
+
forwardClassName: 'flag',
|
|
56
|
+
forwardAttributes: 'flag',
|
|
57
|
+
applyTheme: {
|
|
58
|
+
affects: [{ element: 'flag', classModifier: 'color', inverted: true }],
|
|
59
|
+
viaProp: true,
|
|
60
|
+
viaContext: true,
|
|
61
|
+
defaultTheme: 'light',
|
|
62
|
+
},
|
|
63
|
+
});
|
|
54
64
|
});
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
2
3
|
import classNames from 'classnames';
|
|
3
4
|
|
|
4
5
|
import { ColorPalette, Icon, Size, Theme, Text } from '@lumx/react';
|
|
5
|
-
import {
|
|
6
|
+
import { GenericProps, HasTheme } from '@lumx/react/utils/type';
|
|
6
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';
|
|
7
10
|
|
|
8
11
|
export interface FlagProps extends GenericProps, HasTheme {
|
|
9
12
|
/** Color of the component. */
|
|
@@ -18,9 +21,7 @@ export interface FlagProps extends GenericProps, HasTheme {
|
|
|
18
21
|
|
|
19
22
|
const COMPONENT_NAME = 'Flag';
|
|
20
23
|
const CLASSNAME = getRootClassName(COMPONENT_NAME);
|
|
21
|
-
const DEFAULT_PROPS: Partial<FlagProps> = {
|
|
22
|
-
theme: Theme.light,
|
|
23
|
-
};
|
|
24
|
+
const DEFAULT_PROPS: Partial<FlagProps> = {};
|
|
24
25
|
|
|
25
26
|
/**
|
|
26
27
|
* Flag component.
|
|
@@ -29,8 +30,9 @@ const DEFAULT_PROPS: Partial<FlagProps> = {
|
|
|
29
30
|
* @param ref Component ref.
|
|
30
31
|
* @return React element.
|
|
31
32
|
*/
|
|
32
|
-
export const Flag
|
|
33
|
-
const
|
|
33
|
+
export const Flag = forwardRef<FlagProps, HTMLDivElement>((props, ref) => {
|
|
34
|
+
const defaultTheme = useTheme() || Theme.light;
|
|
35
|
+
const { label, icon, color, className, theme = defaultTheme, truncate, ...forwardedProps } = props;
|
|
34
36
|
const flagColor = color || (theme === Theme.light ? ColorPalette.dark : ColorPalette.light);
|
|
35
37
|
const isTruncated = !!truncate;
|
|
36
38
|
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
|
|
4
3
|
import classNames from 'classnames';
|
|
5
4
|
import castArray from 'lodash/castArray';
|
|
6
|
-
|
|
5
|
+
|
|
6
|
+
import { Alignment, Orientation } from '@lumx/react';
|
|
7
|
+
import { GenericProps } from '@lumx/react/utils/type';
|
|
8
|
+
import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
|
|
9
|
+
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
7
10
|
import { HorizontalAlignment, Size, VerticalAlignment } from '..';
|
|
8
11
|
|
|
9
12
|
export type MarginAutoAlignment = Extract<Alignment, 'top' | 'bottom' | 'right' | 'left'>;
|
|
@@ -55,7 +58,7 @@ const CLASSNAME = getRootClassName(COMPONENT_NAME);
|
|
|
55
58
|
* @param ref Component ref.
|
|
56
59
|
* @return React element.
|
|
57
60
|
*/
|
|
58
|
-
export const FlexBox
|
|
61
|
+
export const FlexBox = forwardRef<FlexBoxProps, HTMLDivElement>((props, ref) => {
|
|
59
62
|
const {
|
|
60
63
|
as: Component = 'div',
|
|
61
64
|
children,
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import React, { Children,
|
|
1
|
+
import React, { Children, ReactElement, ReactNode } from 'react';
|
|
2
|
+
|
|
2
3
|
import classNames from 'classnames';
|
|
3
4
|
import isEmpty from 'lodash/isEmpty';
|
|
4
5
|
import noop from 'lodash/noop';
|
|
6
|
+
|
|
5
7
|
import { Comp, isComponentType } from '@lumx/react/utils/type';
|
|
6
8
|
import { getRootClassName } from '@lumx/react/utils/className';
|
|
7
9
|
import { partitionMulti } from '@lumx/react/utils/partitionMulti';
|
|
8
10
|
import { Orientation, Size, FlexBox, FlexBoxProps } from '@lumx/react';
|
|
9
11
|
import { GenericBlockGapSize } from '@lumx/react/components/generic-block/constants';
|
|
12
|
+
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
10
13
|
|
|
11
14
|
export interface GenericBlockProps extends FlexBoxProps {
|
|
12
15
|
/**
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
|
|
5
5
|
import { Alignment, Orientation, Size } from '@lumx/react';
|
|
6
|
-
import {
|
|
6
|
+
import { GenericProps } from '@lumx/react/utils/type';
|
|
7
7
|
import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
|
|
8
|
+
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
8
9
|
|
|
9
10
|
type GridGutterSize = Extract<Size, 'regular' | 'big' | 'huge'>;
|
|
10
11
|
|
|
@@ -49,7 +50,7 @@ const DEFAULT_PROPS: Partial<GridProps> = {
|
|
|
49
50
|
* @param ref Component ref.
|
|
50
51
|
* @return React element.
|
|
51
52
|
*/
|
|
52
|
-
export const Grid
|
|
53
|
+
export const Grid = forwardRef<GridProps, HTMLDivElement>((props, ref) => {
|
|
53
54
|
const { children, className, gutter, hAlign, orientation, vAlign, wrap, ...forwardedProps } = props;
|
|
54
55
|
|
|
55
56
|
return (
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
|
|
5
5
|
import { Alignment } from '@lumx/react';
|
|
6
|
-
import {
|
|
6
|
+
import { GenericProps } from '@lumx/react/utils/type';
|
|
7
7
|
import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
|
|
8
|
+
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
8
9
|
|
|
9
10
|
type Columns = '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' | '10' | '11' | '12';
|
|
10
11
|
|
|
@@ -37,7 +38,7 @@ const CLASSNAME = getRootClassName(COMPONENT_NAME);
|
|
|
37
38
|
* @param ref Component ref.
|
|
38
39
|
* @return React element.
|
|
39
40
|
*/
|
|
40
|
-
export const GridItem
|
|
41
|
+
export const GridItem = forwardRef<GridItemProps, HTMLDivElement>((props, ref) => {
|
|
41
42
|
const { children, className, width, align, order, ...forwardedProps } = props;
|
|
42
43
|
|
|
43
44
|
return (
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { ReactElement, ReactNode } from 'react';
|
|
2
2
|
|
|
3
3
|
import isInteger from 'lodash/isInteger';
|
|
4
|
-
|
|
5
4
|
import classNames from 'classnames';
|
|
6
5
|
|
|
7
|
-
import { Comp, GenericProps } from '@lumx/react/utils/type';
|
|
8
|
-
import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
|
|
9
6
|
import { Size } from '@lumx/react';
|
|
7
|
+
import { GenericProps } from '@lumx/react/utils/type';
|
|
8
|
+
import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
|
|
9
|
+
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
10
10
|
|
|
11
11
|
export type GridColumnGapSize = Extract<Size, 'tiny' | 'regular' | 'big' | 'huge'>;
|
|
12
12
|
|
|
@@ -50,7 +50,7 @@ const DEFAULT_PROPS: Partial<GridColumnProps> = {};
|
|
|
50
50
|
* @param ref Component ref.
|
|
51
51
|
* @return React element.
|
|
52
52
|
*/
|
|
53
|
-
export const GridColumn
|
|
53
|
+
export const GridColumn = forwardRef<GridColumnProps>((props, ref): ReactElement => {
|
|
54
54
|
const {
|
|
55
55
|
as: Component = 'div',
|
|
56
56
|
gap,
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
3
|
import classNames from 'classnames';
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
import { HeadingElement } from '@lumx/react/utils/type';
|
|
6
|
+
import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
|
|
7
|
+
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
8
|
+
|
|
5
9
|
import { Text, TextProps } from '../text';
|
|
6
10
|
import { DEFAULT_TYPOGRAPHY_BY_LEVEL } from './constants';
|
|
7
11
|
import { useHeadingLevel } from './useHeadingLevel';
|
|
@@ -36,7 +40,7 @@ const DEFAULT_PROPS = {} as const;
|
|
|
36
40
|
* Extends the `Text` Component with the heading level automatically computed based on
|
|
37
41
|
* the current level provided by the context.
|
|
38
42
|
*/
|
|
39
|
-
export const Heading
|
|
43
|
+
export const Heading = forwardRef<HeadingProps>((props, ref) => {
|
|
40
44
|
const { children, as, className, ...forwardedProps } = props;
|
|
41
45
|
const { headingElement } = useHeadingLevel();
|
|
42
46
|
|
|
@@ -2,7 +2,7 @@ import React from 'react';
|
|
|
2
2
|
|
|
3
3
|
import { mdiAlertCircle } from '@lumx/icons';
|
|
4
4
|
import { ColorPalette, ColorVariant, Size, Theme } from '@lumx/react';
|
|
5
|
-
import { commonTestsSuiteRTL } from '@lumx/react/testing/utils';
|
|
5
|
+
import { commonTestsSuiteRTL, SetupRenderOptions } from '@lumx/react/testing/utils';
|
|
6
6
|
|
|
7
7
|
import { getByClassName, getByTagName } from '@lumx/react/testing/utils/queries';
|
|
8
8
|
import { render } from '@testing-library/react';
|
|
@@ -15,12 +15,12 @@ type SetupProps = Partial<IconProps>;
|
|
|
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: IconProps = {
|
|
20
20
|
icon: 'mdiPlus',
|
|
21
21
|
...propsOverride,
|
|
22
22
|
};
|
|
23
|
-
render(<Icon {...props}
|
|
23
|
+
render(<Icon {...props} />, { wrapper });
|
|
24
24
|
const i = getByClassName(document.body, CLASSNAME);
|
|
25
25
|
const svg = getByTagName(i, 'svg');
|
|
26
26
|
const path = getByTagName(svg, 'path');
|
|
@@ -114,5 +114,14 @@ describe(`<${Icon.displayName}>`, () => {
|
|
|
114
114
|
});
|
|
115
115
|
|
|
116
116
|
// Common tests suite.
|
|
117
|
-
commonTestsSuiteRTL(setup, {
|
|
117
|
+
commonTestsSuiteRTL(setup, {
|
|
118
|
+
baseClassName: CLASSNAME,
|
|
119
|
+
forwardClassName: 'i',
|
|
120
|
+
forwardAttributes: 'i',
|
|
121
|
+
applyTheme: {
|
|
122
|
+
affects: [{ element: 'i', classModifier: 'color', inverted: true }],
|
|
123
|
+
viaProp: true,
|
|
124
|
+
viaContext: true,
|
|
125
|
+
},
|
|
126
|
+
});
|
|
118
127
|
});
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
|
|
5
|
+
import { mdiAlertCircle } from '@lumx/icons';
|
|
5
6
|
import { ColorPalette, ColorVariant, Size, Theme } from '@lumx/react';
|
|
6
|
-
import {
|
|
7
|
+
import { GenericProps, HasTheme } from '@lumx/react/utils/type';
|
|
7
8
|
import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
|
|
8
|
-
import {
|
|
9
|
+
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
10
|
+
import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
|
|
9
11
|
|
|
10
12
|
export type IconSizes = Extract<Size, 'xxs' | 'xs' | 's' | 'm' | 'l' | 'xl' | 'xxl'>;
|
|
11
13
|
|
|
@@ -52,8 +54,19 @@ const DEFAULT_PROPS: Partial<IconProps> = {};
|
|
|
52
54
|
* @param ref Component ref.
|
|
53
55
|
* @return React element.
|
|
54
56
|
*/
|
|
55
|
-
export const Icon
|
|
56
|
-
const
|
|
57
|
+
export const Icon = forwardRef<IconProps, HTMLElement>((props, ref) => {
|
|
58
|
+
const defaultTheme = useTheme();
|
|
59
|
+
const {
|
|
60
|
+
className,
|
|
61
|
+
color,
|
|
62
|
+
colorVariant,
|
|
63
|
+
hasShape,
|
|
64
|
+
icon,
|
|
65
|
+
size,
|
|
66
|
+
theme = defaultTheme,
|
|
67
|
+
alt,
|
|
68
|
+
...forwardedProps
|
|
69
|
+
} = props;
|
|
57
70
|
|
|
58
71
|
// Color
|
|
59
72
|
let iconColor = color;
|
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { commonTestsSuiteRTL } from '@lumx/react/testing/utils';
|
|
2
|
+
import { commonTestsSuiteRTL, SetupRenderOptions } from '@lumx/react/testing/utils';
|
|
3
3
|
|
|
4
4
|
import { render } from '@testing-library/react';
|
|
5
5
|
import { queryByClassName } from '@lumx/react/testing/utils/queries';
|
|
6
6
|
import { toNestedProps } from '@lumx/react/stories/decorators/withNestedProps';
|
|
7
7
|
|
|
8
|
+
import { Thumbnail } from '@lumx/react';
|
|
8
9
|
import { ImageBlock, ImageBlockProps } from './ImageBlock';
|
|
9
10
|
import { FullFeatured } from './ImageBlock.stories';
|
|
10
11
|
|
|
11
12
|
const CLASSNAME = ImageBlock.className as string;
|
|
12
13
|
|
|
13
|
-
const setup = (props: Partial<ImageBlockProps> = {}) => {
|
|
14
|
-
render(<ImageBlock {...(props as any)}
|
|
14
|
+
const setup = (props: Partial<ImageBlockProps> = {}, { wrapper }: SetupRenderOptions = {}) => {
|
|
15
|
+
render(<ImageBlock {...(props as any)} />, { wrapper });
|
|
15
16
|
const imageBlock = queryByClassName(document.body, CLASSNAME);
|
|
16
|
-
|
|
17
|
+
const thumbnail = queryByClassName(imageBlock as any, Thumbnail.className as string);
|
|
18
|
+
return { props, imageBlock, thumbnail };
|
|
17
19
|
};
|
|
18
20
|
|
|
19
21
|
describe(`<${ImageBlock.displayName}>`, () => {
|
|
@@ -47,5 +49,11 @@ describe(`<${ImageBlock.displayName}>`, () => {
|
|
|
47
49
|
baseClassName: CLASSNAME,
|
|
48
50
|
forwardClassName: 'imageBlock',
|
|
49
51
|
forwardAttributes: 'imageBlock',
|
|
52
|
+
applyTheme: {
|
|
53
|
+
affects: [{ element: 'imageBlock' }, { element: 'thumbnail' }],
|
|
54
|
+
viaProp: true,
|
|
55
|
+
viaContext: true,
|
|
56
|
+
defaultTheme: 'light',
|
|
57
|
+
},
|
|
50
58
|
});
|
|
51
59
|
});
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
2
|
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
|
|
5
5
|
import { Alignment, HorizontalAlignment, Size, Theme, Thumbnail } from '@lumx/react';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import { GenericProps, HasTheme, ValueOf } 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
|
|
|
11
|
+
import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
|
|
10
12
|
import { ThumbnailProps } from '../thumbnail/Thumbnail';
|
|
11
13
|
import { ImageCaption, ImageCaptionMetadata } from './ImageCaption';
|
|
12
14
|
|
|
@@ -61,7 +63,6 @@ const CLASSNAME = getRootClassName(COMPONENT_NAME);
|
|
|
61
63
|
*/
|
|
62
64
|
const DEFAULT_PROPS: Partial<ImageBlockProps> = {
|
|
63
65
|
captionPosition: ImageBlockCaptionPosition.below,
|
|
64
|
-
theme: Theme.light,
|
|
65
66
|
align: Alignment.left,
|
|
66
67
|
};
|
|
67
68
|
|
|
@@ -72,7 +73,8 @@ const DEFAULT_PROPS: Partial<ImageBlockProps> = {
|
|
|
72
73
|
* @param ref Component ref.
|
|
73
74
|
* @return React element.
|
|
74
75
|
*/
|
|
75
|
-
export const ImageBlock
|
|
76
|
+
export const ImageBlock = forwardRef<ImageBlockProps, HTMLDivElement>((props, ref) => {
|
|
77
|
+
const defaultTheme = useTheme() || Theme.light;
|
|
76
78
|
const {
|
|
77
79
|
actions,
|
|
78
80
|
align,
|
|
@@ -86,7 +88,7 @@ export const ImageBlock: Comp<ImageBlockProps, HTMLDivElement> = forwardRef((pro
|
|
|
86
88
|
image,
|
|
87
89
|
size,
|
|
88
90
|
tags,
|
|
89
|
-
theme,
|
|
91
|
+
theme = defaultTheme,
|
|
90
92
|
thumbnailProps,
|
|
91
93
|
title,
|
|
92
94
|
titleProps,
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
|
|
3
3
|
import classNames from 'classnames';
|
|
4
|
+
|
|
4
5
|
import { Lightbox } from '@lumx/react';
|
|
5
6
|
import { ClickAwayProvider } from '@lumx/react/utils';
|
|
6
|
-
import type { Comp } from '@lumx/react/utils/type';
|
|
7
7
|
import { useMergeRefs } from '@lumx/react/utils/mergeRefs';
|
|
8
|
+
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
8
9
|
|
|
9
10
|
import { ImageSlideshow } from './internal/ImageSlideshow';
|
|
10
11
|
import { useImageLightbox } from './useImageLightbox';
|
|
11
12
|
import type { ImageLightboxProps } from './types';
|
|
12
13
|
import { CLASSNAME, COMPONENT_NAME } from './constants';
|
|
13
14
|
|
|
14
|
-
const Inner
|
|
15
|
+
const Inner = forwardRef<ImageLightboxProps, HTMLDivElement>((props, ref) => {
|
|
15
16
|
const {
|
|
16
17
|
className,
|
|
17
18
|
isOpen,
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import React, { Children,
|
|
1
|
+
import React, { Children, isValidElement } from 'react';
|
|
2
2
|
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
|
|
5
5
|
import { ColorPalette, ColorVariant, Typography } from '@lumx/react';
|
|
6
|
-
import {
|
|
6
|
+
import { GenericProps } from '@lumx/react/utils/type';
|
|
7
7
|
import { getFontColorClassName, getRootClassName, getTypographyClassName } from '@lumx/react/utils/className';
|
|
8
|
+
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Defines the props of the component.
|
|
@@ -50,7 +51,7 @@ const DEFAULT_PROPS = {} as const;
|
|
|
50
51
|
* @param ref Component ref.
|
|
51
52
|
* @return React element.
|
|
52
53
|
*/
|
|
53
|
-
export const InlineList
|
|
54
|
+
export const InlineList = forwardRef<InlineListProps>((props, ref) => {
|
|
54
55
|
const { className, color, colorVariant, typography, children, wrap, ...forwardedProps } = props;
|
|
55
56
|
const fontColorClassName = color && getFontColorClassName(color, colorVariant);
|
|
56
57
|
const typographyClassName = typography && getTypographyClassName(typography);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
3
|
import { Kind, Theme } from '@lumx/react';
|
|
4
|
-
import { commonTestsSuiteRTL } from '@lumx/react/testing/utils';
|
|
4
|
+
import { commonTestsSuiteRTL, SetupRenderOptions } from '@lumx/react/testing/utils';
|
|
5
5
|
import { getByClassName } from '@lumx/react/testing/utils/queries';
|
|
6
6
|
import { render } from '@testing-library/react';
|
|
7
7
|
import { INPUT_HELPER_CONFIGURATION } from '@lumx/react/components/input-helper/constants';
|
|
@@ -14,9 +14,9 @@ type SetupProps = Partial<InputHelperProps>;
|
|
|
14
14
|
/**
|
|
15
15
|
* Mounts the component and returns common DOM elements / data needed in multiple tests further down.
|
|
16
16
|
*/
|
|
17
|
-
const setup = (propsOverride: SetupProps = {}) => {
|
|
17
|
+
const setup = (propsOverride: SetupProps = {}, { wrapper }: SetupRenderOptions = {}) => {
|
|
18
18
|
const props: any = { ...propsOverride };
|
|
19
|
-
render(<InputHelper {...props}
|
|
19
|
+
render(<InputHelper {...props} />, { wrapper });
|
|
20
20
|
const helper = getByClassName(document.body, CLASSNAME);
|
|
21
21
|
|
|
22
22
|
return { helper, props };
|
|
@@ -43,5 +43,15 @@ describe(`<${InputHelper.displayName}>`, () => {
|
|
|
43
43
|
});
|
|
44
44
|
});
|
|
45
45
|
|
|
46
|
-
commonTestsSuiteRTL(setup, {
|
|
46
|
+
commonTestsSuiteRTL(setup, {
|
|
47
|
+
baseClassName: CLASSNAME,
|
|
48
|
+
forwardClassName: 'helper',
|
|
49
|
+
forwardAttributes: 'helper',
|
|
50
|
+
applyTheme: {
|
|
51
|
+
affects: [{ element: 'helper' }],
|
|
52
|
+
viaProp: true,
|
|
53
|
+
viaContext: true,
|
|
54
|
+
defaultTheme: 'light',
|
|
55
|
+
},
|
|
56
|
+
});
|
|
47
57
|
});
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
|
|
1
5
|
import { Kind, Theme } from '@lumx/react';
|
|
2
|
-
import {
|
|
6
|
+
import { GenericProps, HasTheme } from '@lumx/react/utils/type';
|
|
3
7
|
import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
|
|
4
|
-
import
|
|
5
|
-
import React, { forwardRef, ReactNode } from 'react';
|
|
8
|
+
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
6
9
|
|
|
10
|
+
import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
|
|
7
11
|
import { INPUT_HELPER_CONFIGURATION } from './constants';
|
|
8
12
|
|
|
9
13
|
/**
|
|
@@ -31,7 +35,6 @@ const CLASSNAME = getRootClassName(COMPONENT_NAME);
|
|
|
31
35
|
*/
|
|
32
36
|
const DEFAULT_PROPS: Partial<InputHelperProps> = {
|
|
33
37
|
kind: Kind.info,
|
|
34
|
-
theme: Theme.light,
|
|
35
38
|
};
|
|
36
39
|
|
|
37
40
|
/**
|
|
@@ -41,8 +44,9 @@ const DEFAULT_PROPS: Partial<InputHelperProps> = {
|
|
|
41
44
|
* @param ref Component ref.
|
|
42
45
|
* @return React element.
|
|
43
46
|
*/
|
|
44
|
-
export const InputHelper
|
|
45
|
-
const
|
|
47
|
+
export const InputHelper = forwardRef<InputHelperProps, HTMLParagraphElement>((props, ref) => {
|
|
48
|
+
const defaultTheme = useTheme() || Theme.light;
|
|
49
|
+
const { children, className, kind, theme = defaultTheme, ...forwardedProps } = props;
|
|
46
50
|
const { color } = INPUT_HELPER_CONFIGURATION[kind as any] || {};
|
|
47
51
|
|
|
48
52
|
return (
|
|
@@ -3,7 +3,7 @@ import React from 'react';
|
|
|
3
3
|
import { Theme } from '@lumx/react';
|
|
4
4
|
import { getByClassName } from '@lumx/react/testing/utils/queries';
|
|
5
5
|
import { render } from '@testing-library/react';
|
|
6
|
-
import { commonTestsSuiteRTL } from '@lumx/react/testing/utils';
|
|
6
|
+
import { commonTestsSuiteRTL, SetupRenderOptions } from '@lumx/react/testing/utils';
|
|
7
7
|
import { InputLabel, InputLabelProps } from './InputLabel';
|
|
8
8
|
|
|
9
9
|
const CLASSNAME = InputLabel.className as string;
|
|
@@ -13,9 +13,9 @@ type SetupProps = Partial<InputLabelProps>;
|
|
|
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: SetupProps = {}) => {
|
|
16
|
+
const setup = (propsOverride: SetupProps = {}, { wrapper }: SetupRenderOptions = {}) => {
|
|
17
17
|
const props: any = { htmlFor: 'id', ...propsOverride };
|
|
18
|
-
render(<InputLabel {...props}
|
|
18
|
+
render(<InputLabel {...props} />, { wrapper });
|
|
19
19
|
const label = getByClassName(document.body, CLASSNAME);
|
|
20
20
|
|
|
21
21
|
return { label, props };
|
|
@@ -40,5 +40,15 @@ describe(`<${InputLabel.displayName}>`, () => {
|
|
|
40
40
|
});
|
|
41
41
|
});
|
|
42
42
|
|
|
43
|
-
commonTestsSuiteRTL(setup, {
|
|
43
|
+
commonTestsSuiteRTL(setup, {
|
|
44
|
+
baseClassName: CLASSNAME,
|
|
45
|
+
forwardClassName: 'label',
|
|
46
|
+
forwardAttributes: 'label',
|
|
47
|
+
applyTheme: {
|
|
48
|
+
affects: [{ element: 'label' }],
|
|
49
|
+
viaProp: true,
|
|
50
|
+
viaContext: true,
|
|
51
|
+
defaultTheme: 'light',
|
|
52
|
+
},
|
|
53
|
+
});
|
|
44
54
|
});
|