@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,14 +1,16 @@
|
|
|
1
|
+
import React, { MouseEventHandler, ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
import isFunction from 'lodash/isFunction';
|
|
5
|
+
|
|
1
6
|
import { ColorPalette, Size, Theme } from '@lumx/react';
|
|
2
7
|
import { useStopPropagation } from '@lumx/react/hooks/useStopPropagation';
|
|
3
8
|
|
|
4
|
-
import {
|
|
9
|
+
import { GenericProps, HasTheme } from '@lumx/react/utils/type';
|
|
5
10
|
import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
|
|
6
11
|
import { onEnterPressed } from '@lumx/react/utils/event';
|
|
7
|
-
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
import isFunction from 'lodash/isFunction';
|
|
11
|
-
import React, { forwardRef, MouseEventHandler, ReactNode } from 'react';
|
|
12
|
+
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
13
|
+
import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
|
|
12
14
|
|
|
13
15
|
/**
|
|
14
16
|
* Chip sizes.
|
|
@@ -56,7 +58,6 @@ const CLASSNAME = getRootClassName(COMPONENT_NAME);
|
|
|
56
58
|
*/
|
|
57
59
|
const DEFAULT_PROPS: Partial<ChipProps> = {
|
|
58
60
|
size: Size.m,
|
|
59
|
-
theme: Theme.light,
|
|
60
61
|
};
|
|
61
62
|
|
|
62
63
|
/**
|
|
@@ -66,7 +67,8 @@ const DEFAULT_PROPS: Partial<ChipProps> = {
|
|
|
66
67
|
* @param ref Component ref.
|
|
67
68
|
* @return React element.
|
|
68
69
|
*/
|
|
69
|
-
export const Chip
|
|
70
|
+
export const Chip = forwardRef<ChipProps, HTMLAnchorElement>((props, ref) => {
|
|
71
|
+
const defaultTheme = useTheme() || Theme.light;
|
|
70
72
|
const {
|
|
71
73
|
after,
|
|
72
74
|
before,
|
|
@@ -82,7 +84,7 @@ export const Chip: Comp<ChipProps, HTMLAnchorElement> = forwardRef((props, ref)
|
|
|
82
84
|
onBeforeClick,
|
|
83
85
|
onClick,
|
|
84
86
|
size,
|
|
85
|
-
theme,
|
|
87
|
+
theme = defaultTheme,
|
|
86
88
|
href,
|
|
87
89
|
onKeyDown,
|
|
88
90
|
...forwardedProps
|
|
@@ -143,9 +145,7 @@ export const Chip: Comp<ChipProps, HTMLAnchorElement> = forwardRef((props, ref)
|
|
|
143
145
|
{before}
|
|
144
146
|
</div>
|
|
145
147
|
)}
|
|
146
|
-
|
|
147
148
|
<div className={`${CLASSNAME}__label`}>{children}</div>
|
|
148
|
-
|
|
149
149
|
{after && (
|
|
150
150
|
// eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions
|
|
151
151
|
<div
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import React, { forwardRef, ReactNode } from 'react';
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
3
2
|
|
|
4
3
|
import classNames from 'classnames';
|
|
5
4
|
|
|
6
|
-
import {
|
|
5
|
+
import { HorizontalAlignment } from '@lumx/react/components';
|
|
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
|
import { useChipGroupNavigation } from '@lumx/react/hooks/useChipGroupNavigation';
|
|
10
11
|
|
|
@@ -43,7 +44,7 @@ const CLASSNAME = getRootClassName(COMPONENT_NAME);
|
|
|
43
44
|
* @param ref Component ref.
|
|
44
45
|
* @return React element.
|
|
45
46
|
*/
|
|
46
|
-
const InternalChipGroup
|
|
47
|
+
const InternalChipGroup = forwardRef<ChipGroupProps, HTMLDivElement>((props, ref) => {
|
|
47
48
|
const { align, children, className, ...forwardedProps } = props;
|
|
48
49
|
const chipGroupClassName = handleBasicClasses({
|
|
49
50
|
prefix: CLASSNAME,
|
|
@@ -1,5 +1,5 @@
|
|
|
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';
|
|
@@ -7,8 +7,8 @@ import { CommentBlock, CommentBlockProps } from './CommentBlock';
|
|
|
7
7
|
|
|
8
8
|
const CLASSNAME = CommentBlock.className as string;
|
|
9
9
|
|
|
10
|
-
const setup = (props: Partial<CommentBlockProps> = {}) => {
|
|
11
|
-
render(<CommentBlock {...(props as any)}
|
|
10
|
+
const setup = (props: Partial<CommentBlockProps> = {}, { wrapper }: SetupRenderOptions = {}) => {
|
|
11
|
+
render(<CommentBlock {...(props as any)} />, { wrapper });
|
|
12
12
|
const commentBlock = queryByClassName(document.body, CLASSNAME);
|
|
13
13
|
return { props, commentBlock };
|
|
14
14
|
};
|
|
@@ -19,5 +19,11 @@ describe(`<${CommentBlock.displayName}>`, () => {
|
|
|
19
19
|
baseClassName: CLASSNAME,
|
|
20
20
|
forwardClassName: 'commentBlock',
|
|
21
21
|
forwardAttributes: 'commentBlock',
|
|
22
|
+
applyTheme: {
|
|
23
|
+
affects: [{ element: 'commentBlock' }],
|
|
24
|
+
viaProp: true,
|
|
25
|
+
viaContext: true,
|
|
26
|
+
defaultTheme: 'light',
|
|
27
|
+
},
|
|
22
28
|
});
|
|
23
29
|
});
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import React, { Children,
|
|
1
|
+
import React, { Children, ReactNode } from 'react';
|
|
2
2
|
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
|
|
5
5
|
import { Avatar, Size, Theme, Tooltip } from '@lumx/react';
|
|
6
|
-
import {
|
|
6
|
+
import { GenericProps, HasTheme, ValueOf } 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
|
|
|
10
|
+
import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
|
|
9
11
|
import { AvatarProps } from '../avatar/Avatar';
|
|
10
12
|
|
|
11
13
|
/**
|
|
@@ -76,7 +78,6 @@ const CLASSNAME = getRootClassName(COMPONENT_NAME);
|
|
|
76
78
|
* Component default props.
|
|
77
79
|
*/
|
|
78
80
|
const DEFAULT_PROPS: Partial<CommentBlockProps> = {
|
|
79
|
-
theme: Theme.light,
|
|
80
81
|
variant: CommentBlockVariant.indented,
|
|
81
82
|
};
|
|
82
83
|
|
|
@@ -87,7 +88,8 @@ const DEFAULT_PROPS: Partial<CommentBlockProps> = {
|
|
|
87
88
|
* @param ref Component ref.
|
|
88
89
|
* @return React element.
|
|
89
90
|
*/
|
|
90
|
-
export const CommentBlock
|
|
91
|
+
export const CommentBlock = forwardRef<CommentBlockProps, HTMLDivElement>((props, ref) => {
|
|
92
|
+
const defaultTheme = useTheme() || Theme.light;
|
|
91
93
|
const {
|
|
92
94
|
actions,
|
|
93
95
|
avatarProps,
|
|
@@ -104,7 +106,7 @@ export const CommentBlock: Comp<CommentBlockProps, HTMLDivElement> = forwardRef(
|
|
|
104
106
|
onMouseEnter,
|
|
105
107
|
onMouseLeave,
|
|
106
108
|
text,
|
|
107
|
-
theme,
|
|
109
|
+
theme = defaultTheme,
|
|
108
110
|
variant,
|
|
109
111
|
...forwardedProps
|
|
110
112
|
} = props;
|
|
@@ -161,7 +163,6 @@ export const CommentBlock: Comp<CommentBlockProps, HTMLDivElement> = forwardRef(
|
|
|
161
163
|
{hasActions && <div className={`${CLASSNAME}__actions`}>{actions}</div>}
|
|
162
164
|
</div>
|
|
163
165
|
</div>
|
|
164
|
-
|
|
165
166
|
{hasChildren && isOpen && <div className={`${CLASSNAME}__children`}>{children}</div>}
|
|
166
167
|
</div>
|
|
167
168
|
);
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
|
|
3
3
|
import { addMonthResetDay } from '@lumx/react/utils/date/addMonthResetDay';
|
|
4
4
|
import { isDateValid } from '@lumx/react/utils/date/isDateValid';
|
|
5
|
+
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
6
|
+
|
|
5
7
|
import { CLASSNAME, COMPONENT_NAME } from './constants';
|
|
6
8
|
import { DatePickerControlled } from './DatePickerControlled';
|
|
7
9
|
import { DatePickerProps } from './types';
|
|
@@ -13,7 +15,7 @@ import { DatePickerProps } from './types';
|
|
|
13
15
|
* @param ref Component ref.
|
|
14
16
|
* @return React element.
|
|
15
17
|
*/
|
|
16
|
-
export const DatePicker
|
|
18
|
+
export const DatePicker = forwardRef<DatePickerProps, HTMLDivElement>((props, ref) => {
|
|
17
19
|
const { defaultMonth, locale, value, onChange, ...forwardedProps } = props;
|
|
18
20
|
|
|
19
21
|
let referenceDate = value || defaultMonth || new Date();
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import React, { KeyboardEventHandler
|
|
1
|
+
import React, { KeyboardEventHandler } from 'react';
|
|
2
|
+
|
|
2
3
|
import classNames from 'classnames';
|
|
4
|
+
|
|
3
5
|
import {
|
|
4
6
|
Button,
|
|
5
7
|
DatePickerProps,
|
|
@@ -12,7 +14,6 @@ import {
|
|
|
12
14
|
Toolbar,
|
|
13
15
|
} from '@lumx/react';
|
|
14
16
|
import { mdiChevronLeft, mdiChevronRight } from '@lumx/icons';
|
|
15
|
-
import { Comp } from '@lumx/react/utils/type';
|
|
16
17
|
import { getMonthCalendar } from '@lumx/react/utils/date/getMonthCalendar';
|
|
17
18
|
import { isSameDay } from '@lumx/react/utils/date/isSameDay';
|
|
18
19
|
import { getCurrentLocale } from '@lumx/react/utils/locale/getCurrentLocale';
|
|
@@ -24,6 +25,8 @@ import { onEnterPressed } from '@lumx/react/utils/event';
|
|
|
24
25
|
import { addMonthResetDay } from '@lumx/react/utils/date/addMonthResetDay';
|
|
25
26
|
import { formatDayNumber } from '@lumx/react/utils/date/formatDayNumber';
|
|
26
27
|
import { VISUALLY_HIDDEN } from '@lumx/react/constants';
|
|
28
|
+
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
29
|
+
|
|
27
30
|
import { CLASSNAME } from './constants';
|
|
28
31
|
|
|
29
32
|
/**
|
|
@@ -52,7 +55,7 @@ const COMPONENT_NAME = 'DatePickerControlled';
|
|
|
52
55
|
* @param ref Component ref.
|
|
53
56
|
* @return React element.
|
|
54
57
|
*/
|
|
55
|
-
export const DatePickerControlled
|
|
58
|
+
export const DatePickerControlled = forwardRef<DatePickerControlledProps, HTMLDivElement>((props, ref) => {
|
|
56
59
|
const {
|
|
57
60
|
locale = getCurrentLocale(),
|
|
58
61
|
maxDate,
|
|
@@ -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, screen } from '@testing-library/react';
|
|
5
5
|
import { getByClassName, getByTagName, queryByClassName } from '@lumx/react/testing/utils/queries';
|
|
6
6
|
import { TextField } from '@lumx/react';
|
|
@@ -15,7 +15,7 @@ jest.mock('@lumx/react/utils/date/getYearDisplayName', () => ({
|
|
|
15
15
|
getYearDisplayName: () => 'année',
|
|
16
16
|
}));
|
|
17
17
|
|
|
18
|
-
const setup = (propsOverride: Partial<DatePickerFieldProps> = {}) => {
|
|
18
|
+
const setup = (propsOverride: Partial<DatePickerFieldProps> = {}, { wrapper }: SetupRenderOptions = {}) => {
|
|
19
19
|
const props: DatePickerFieldProps = {
|
|
20
20
|
label: 'DatePickerField',
|
|
21
21
|
locale: 'fr',
|
|
@@ -25,7 +25,7 @@ const setup = (propsOverride: Partial<DatePickerFieldProps> = {}) => {
|
|
|
25
25
|
previousButtonProps: { label: 'Previous month' },
|
|
26
26
|
...propsOverride,
|
|
27
27
|
};
|
|
28
|
-
render(<DatePickerField {...props}
|
|
28
|
+
render(<DatePickerField {...props} />, { wrapper });
|
|
29
29
|
const textField = getByClassName(document.body, TextField.className as string);
|
|
30
30
|
const inputNative = getByTagName(textField, 'input');
|
|
31
31
|
const getDatePicker = () => queryByClassName(document.body, CLASSNAME);
|
|
@@ -62,5 +62,11 @@ describe(`<${DatePickerField.displayName}>`, () => {
|
|
|
62
62
|
forwardRef: 'textField',
|
|
63
63
|
forwardAttributes: 'inputNative',
|
|
64
64
|
forwardClassName: 'textField',
|
|
65
|
+
applyTheme: {
|
|
66
|
+
affects: [{ element: 'textField' }],
|
|
67
|
+
viaProp: true,
|
|
68
|
+
viaContext: true,
|
|
69
|
+
defaultTheme: 'light',
|
|
70
|
+
},
|
|
65
71
|
});
|
|
66
72
|
});
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { SyntheticEvent, useCallback, useRef } from 'react';
|
|
2
2
|
|
|
3
3
|
import { DatePicker, IconButtonProps, Placement, PopoverDialog, TextField, TextFieldProps } from '@lumx/react';
|
|
4
|
-
import {
|
|
4
|
+
import { GenericProps } from '@lumx/react/utils/type';
|
|
5
5
|
import { getCurrentLocale } from '@lumx/react/utils/locale/getCurrentLocale';
|
|
6
6
|
import { useBooleanState } from '@lumx/react/hooks/useBooleanState';
|
|
7
|
+
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Defines the props of the component.
|
|
@@ -40,7 +41,7 @@ const COMPONENT_NAME = 'DatePickerField';
|
|
|
40
41
|
* @param ref Component ref.
|
|
41
42
|
* @return React element.
|
|
42
43
|
*/
|
|
43
|
-
export const DatePickerField
|
|
44
|
+
export const DatePickerField = forwardRef<DatePickerFieldProps, HTMLDivElement>((props, ref) => {
|
|
44
45
|
const {
|
|
45
46
|
defaultMonth,
|
|
46
47
|
disabled,
|
|
@@ -3,19 +3,26 @@ import React from 'react';
|
|
|
3
3
|
import { Dialog, DialogProps } from '@lumx/react/components/dialog/Dialog';
|
|
4
4
|
import { queryByClassName } from '@lumx/react/testing/utils/queries';
|
|
5
5
|
import { render, screen } from '@testing-library/react';
|
|
6
|
-
import { commonTestsSuiteRTL } from '@lumx/react/testing/utils';
|
|
6
|
+
import { commonTestsSuiteRTL, SetupRenderOptions } from '@lumx/react/testing/utils';
|
|
7
7
|
import userEvent from '@testing-library/user-event';
|
|
8
|
+
import { ThemeSentinel } from '@lumx/react/testing/utils/ThemeSentinel';
|
|
8
9
|
|
|
9
10
|
const CLASSNAME = Dialog.className as string;
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* Mounts the component and returns common DOM elements / data needed in multiple tests further down.
|
|
13
14
|
*/
|
|
14
|
-
const setup = (props: Partial<DialogProps> = {}) => {
|
|
15
|
-
render(
|
|
15
|
+
const setup = (props: Partial<DialogProps> = {}, { wrapper }: SetupRenderOptions = {}) => {
|
|
16
|
+
render(
|
|
17
|
+
<Dialog isOpen {...props}>
|
|
18
|
+
{props.children || <ThemeSentinel />}
|
|
19
|
+
</Dialog>,
|
|
20
|
+
{ wrapper },
|
|
21
|
+
);
|
|
16
22
|
const dialog = queryByClassName(document.body, CLASSNAME);
|
|
17
23
|
const container = dialog && queryByClassName(dialog, `${CLASSNAME}__container`);
|
|
18
|
-
|
|
24
|
+
const themeSentinel = screen.queryByTestId(ThemeSentinel.testId);
|
|
25
|
+
return { props, dialog, container, themeSentinel };
|
|
19
26
|
};
|
|
20
27
|
|
|
21
28
|
describe(`<${Dialog.displayName}>`, () => {
|
|
@@ -66,5 +73,11 @@ describe(`<${Dialog.displayName}>`, () => {
|
|
|
66
73
|
forwardAttributes: 'dialog',
|
|
67
74
|
forwardRef: 'dialog',
|
|
68
75
|
forwardClassName: 'dialog',
|
|
76
|
+
applyTheme: {
|
|
77
|
+
// Theme should not affect the children components
|
|
78
|
+
affects: [{ not: { element: 'themeSentinel' } }],
|
|
79
|
+
viaProp: true,
|
|
80
|
+
viaContext: true,
|
|
81
|
+
},
|
|
69
82
|
});
|
|
70
83
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { Children,
|
|
1
|
+
import React, { Children, ReactElement, ReactNode, Ref, RefObject, useMemo, useRef, useState } from 'react';
|
|
2
2
|
import { createPortal } from 'react-dom';
|
|
3
3
|
|
|
4
4
|
import classNames from 'classnames';
|
|
@@ -10,14 +10,16 @@ import { useCallbackOnEscape } from '@lumx/react/hooks/useCallbackOnEscape';
|
|
|
10
10
|
import { useFocusTrap } from '@lumx/react/hooks/useFocusTrap';
|
|
11
11
|
import { useIntersectionObserver } from '@lumx/react/hooks/useIntersectionObserver';
|
|
12
12
|
|
|
13
|
-
import {
|
|
13
|
+
import { GenericProps, isComponent } from '@lumx/react/utils/type';
|
|
14
14
|
import { partitionMulti } from '@lumx/react/utils/partitionMulti';
|
|
15
15
|
import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
|
|
16
16
|
import { ClickAwayProvider } from '@lumx/react/utils/ClickAwayProvider';
|
|
17
17
|
import { mergeRefs } from '@lumx/react/utils/mergeRefs';
|
|
18
|
+
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
18
19
|
|
|
19
20
|
import { useDisableBodyScroll } from '@lumx/react/hooks/useDisableBodyScroll';
|
|
20
21
|
import { useTransitionVisibility } from '@lumx/react/hooks/useTransitionVisibility';
|
|
22
|
+
import { ThemeProvider } from '@lumx/react/utils/theme/ThemeContext';
|
|
21
23
|
|
|
22
24
|
/**
|
|
23
25
|
* Defines the props of the component.
|
|
@@ -91,7 +93,7 @@ const DEFAULT_PROPS: Partial<DialogProps> = {
|
|
|
91
93
|
* @param ref Component ref.
|
|
92
94
|
* @return React element.
|
|
93
95
|
*/
|
|
94
|
-
export const Dialog
|
|
96
|
+
export const Dialog = forwardRef<DialogProps, HTMLDivElement>((props, ref) => {
|
|
95
97
|
if (!DOCUMENT) {
|
|
96
98
|
// Can't render in SSR.
|
|
97
99
|
return null;
|
|
@@ -208,65 +210,67 @@ export const Dialog: Comp<DialogProps, HTMLDivElement> = forwardRef((props, ref)
|
|
|
208
210
|
>
|
|
209
211
|
<div className={`${CLASSNAME}__overlay`} />
|
|
210
212
|
|
|
211
|
-
<
|
|
212
|
-
<
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
{
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
<div
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
{(footer || footerChildContent) && (
|
|
248
|
-
<footer
|
|
249
|
-
{...footerChildProps}
|
|
250
|
-
className={classNames(
|
|
251
|
-
`${CLASSNAME}__footer`,
|
|
252
|
-
(forceFooterDivider || hasBottomIntersection) &&
|
|
253
|
-
`${CLASSNAME}__footer--has-divider`,
|
|
254
|
-
footerChildProps?.className,
|
|
255
|
-
)}
|
|
256
|
-
>
|
|
257
|
-
{footer}
|
|
258
|
-
{footerChildContent}
|
|
259
|
-
</footer>
|
|
260
|
-
)}
|
|
261
|
-
|
|
262
|
-
{isLoading && (
|
|
263
|
-
<div className={`${CLASSNAME}__progress-overlay`}>
|
|
264
|
-
<Progress variant={ProgressVariant.circular} />
|
|
213
|
+
<ThemeProvider value={undefined}>
|
|
214
|
+
<section className={`${CLASSNAME}__container`} role="dialog" aria-modal="true" {...dialogProps}>
|
|
215
|
+
<ClickAwayProvider
|
|
216
|
+
callback={!shouldPreventCloseOnClickAway && onClose}
|
|
217
|
+
childrenRefs={clickAwayRefs}
|
|
218
|
+
parentRef={rootRef}
|
|
219
|
+
>
|
|
220
|
+
<div className={`${CLASSNAME}__wrapper`} ref={wrapperRef}>
|
|
221
|
+
{(header || headerChildContent) && (
|
|
222
|
+
<header
|
|
223
|
+
{...headerChildProps}
|
|
224
|
+
className={classNames(
|
|
225
|
+
`${CLASSNAME}__header`,
|
|
226
|
+
(forceHeaderDivider || hasTopIntersection) &&
|
|
227
|
+
`${CLASSNAME}__header--has-divider`,
|
|
228
|
+
headerChildProps?.className,
|
|
229
|
+
)}
|
|
230
|
+
>
|
|
231
|
+
{header}
|
|
232
|
+
{headerChildContent}
|
|
233
|
+
</header>
|
|
234
|
+
)}
|
|
235
|
+
|
|
236
|
+
<div ref={mergeRefs(contentRef, localContentRef)} className={`${CLASSNAME}__content`}>
|
|
237
|
+
<div
|
|
238
|
+
className={`${CLASSNAME}__sentinel ${CLASSNAME}__sentinel--top`}
|
|
239
|
+
ref={setSentinelTop}
|
|
240
|
+
/>
|
|
241
|
+
|
|
242
|
+
{content}
|
|
243
|
+
|
|
244
|
+
<div
|
|
245
|
+
className={`${CLASSNAME}__sentinel ${CLASSNAME}__sentinel--bottom`}
|
|
246
|
+
ref={setSentinelBottom}
|
|
247
|
+
/>
|
|
265
248
|
</div>
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
249
|
+
|
|
250
|
+
{(footer || footerChildContent) && (
|
|
251
|
+
<footer
|
|
252
|
+
{...footerChildProps}
|
|
253
|
+
className={classNames(
|
|
254
|
+
`${CLASSNAME}__footer`,
|
|
255
|
+
(forceFooterDivider || hasBottomIntersection) &&
|
|
256
|
+
`${CLASSNAME}__footer--has-divider`,
|
|
257
|
+
footerChildProps?.className,
|
|
258
|
+
)}
|
|
259
|
+
>
|
|
260
|
+
{footer}
|
|
261
|
+
{footerChildContent}
|
|
262
|
+
</footer>
|
|
263
|
+
)}
|
|
264
|
+
|
|
265
|
+
{isLoading && (
|
|
266
|
+
<div className={`${CLASSNAME}__progress-overlay`}>
|
|
267
|
+
<Progress variant={ProgressVariant.circular} />
|
|
268
|
+
</div>
|
|
269
|
+
)}
|
|
270
|
+
</div>
|
|
271
|
+
</ClickAwayProvider>
|
|
272
|
+
</section>
|
|
273
|
+
</ThemeProvider>
|
|
270
274
|
</div>,
|
|
271
275
|
document.body,
|
|
272
276
|
)
|
|
@@ -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 { Theme } from '@lumx/react';
|
|
6
6
|
import { render, screen } from '@testing-library/react';
|
|
@@ -13,10 +13,10 @@ type SetupProps = Partial<DividerProps>;
|
|
|
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: DividerProps = { ...propsOverride };
|
|
18
18
|
|
|
19
|
-
render(<Divider {...props}
|
|
19
|
+
render(<Divider {...props} />, { wrapper });
|
|
20
20
|
const divider = screen.queryByRole('separator');
|
|
21
21
|
|
|
22
22
|
return { props, divider };
|
|
@@ -43,5 +43,11 @@ describe(`<${Divider.displayName}>`, () => {
|
|
|
43
43
|
forwardClassName: 'divider',
|
|
44
44
|
forwardAttributes: 'divider',
|
|
45
45
|
forwardRef: 'divider',
|
|
46
|
+
applyTheme: {
|
|
47
|
+
affects: [{ element: 'divider' }],
|
|
48
|
+
viaProp: true,
|
|
49
|
+
viaContext: true,
|
|
50
|
+
defaultTheme: 'light',
|
|
51
|
+
},
|
|
46
52
|
});
|
|
47
53
|
});
|
|
@@ -1,10 +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
|
-
import {
|
|
6
|
+
import { GenericProps, HasTheme } from '@lumx/react/utils/type';
|
|
7
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';
|
|
8
10
|
|
|
9
11
|
/**
|
|
10
12
|
* Defines the props of the component.
|
|
@@ -24,9 +26,7 @@ const CLASSNAME = getRootClassName(COMPONENT_NAME);
|
|
|
24
26
|
/**
|
|
25
27
|
* Component default props.
|
|
26
28
|
*/
|
|
27
|
-
const DEFAULT_PROPS: Partial<DividerProps> = {
|
|
28
|
-
theme: Theme.light,
|
|
29
|
-
};
|
|
29
|
+
const DEFAULT_PROPS: Partial<DividerProps> = {};
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
32
|
* Divider component.
|
|
@@ -35,8 +35,9 @@ const DEFAULT_PROPS: Partial<DividerProps> = {
|
|
|
35
35
|
* @param ref Component ref.
|
|
36
36
|
* @return React element.
|
|
37
37
|
*/
|
|
38
|
-
export const Divider
|
|
39
|
-
const
|
|
38
|
+
export const Divider = forwardRef<DividerProps, HTMLHRElement>((props, ref) => {
|
|
39
|
+
const defaultTheme = useTheme() || Theme.light;
|
|
40
|
+
const { className, theme = defaultTheme, ...forwardedProps } = props;
|
|
40
41
|
|
|
41
42
|
return (
|
|
42
43
|
<hr
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { commonTestsSuiteRTL, SetupRenderOptions } from '@lumx/react/testing/utils';
|
|
4
|
+
|
|
5
|
+
import { render } from '@testing-library/react';
|
|
6
|
+
import { queryByClassName } from '@lumx/react/testing/utils/queries';
|
|
7
|
+
import { DragHandle, DragHandleProps } from './DragHandle';
|
|
8
|
+
|
|
9
|
+
const CLASSNAME = DragHandle.className as string;
|
|
10
|
+
|
|
11
|
+
type SetupProps = Partial<DragHandleProps>;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Mounts the component and returns common DOM elements / data needed in multiple tests further down.
|
|
15
|
+
*/
|
|
16
|
+
const setup = (propsOverride: SetupProps = {}, { wrapper }: SetupRenderOptions = {}) => {
|
|
17
|
+
const props: DragHandleProps = { ...propsOverride };
|
|
18
|
+
|
|
19
|
+
const { container } = render(<DragHandle {...props} />, { wrapper });
|
|
20
|
+
const handle = queryByClassName(container, CLASSNAME);
|
|
21
|
+
|
|
22
|
+
return { props, handle };
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
describe(`<${DragHandle.displayName}>`, () => {
|
|
26
|
+
// Common tests suite.
|
|
27
|
+
commonTestsSuiteRTL(setup, {
|
|
28
|
+
baseClassName: CLASSNAME,
|
|
29
|
+
forwardClassName: 'handle',
|
|
30
|
+
forwardAttributes: 'handle',
|
|
31
|
+
forwardRef: 'handle',
|
|
32
|
+
applyTheme: {
|
|
33
|
+
affects: [{ element: 'handle' }],
|
|
34
|
+
viaProp: true,
|
|
35
|
+
viaContext: true,
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
});
|
|
@@ -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 { mdiDragVertical } from '@lumx/icons';
|
|
6
6
|
import { ColorPalette, Icon, Size, Theme } from '@lumx/react';
|
|
7
|
-
import {
|
|
7
|
+
import { GenericProps, HasTheme } from '@lumx/react/utils/type';
|
|
8
8
|
import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
|
|
9
|
+
import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
|
|
10
|
+
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
9
11
|
|
|
10
12
|
/**
|
|
11
13
|
* Defines the props of the component.
|
|
@@ -29,8 +31,9 @@ const CLASSNAME = getRootClassName(COMPONENT_NAME);
|
|
|
29
31
|
* @param ref Component ref.
|
|
30
32
|
* @return React element.
|
|
31
33
|
*/
|
|
32
|
-
export const DragHandle
|
|
33
|
-
const
|
|
34
|
+
export const DragHandle = forwardRef<DragHandleProps, HTMLDivElement>((props, ref) => {
|
|
35
|
+
const defaultTheme = useTheme();
|
|
36
|
+
const { className, theme = defaultTheme, ...forwardedProps } = props;
|
|
34
37
|
|
|
35
38
|
return (
|
|
36
39
|
<div
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import React, { cloneElement,
|
|
1
|
+
import React, { cloneElement, useMemo, useRef } from 'react';
|
|
2
2
|
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
|
|
5
5
|
import { List, ListProps } from '@lumx/react/components/list/List';
|
|
6
6
|
import { Popover, PopoverProps } from '@lumx/react/components/popover/Popover';
|
|
7
7
|
import { useInfiniteScroll } from '@lumx/react/hooks/useInfiniteScroll';
|
|
8
|
-
import {
|
|
8
|
+
import { GenericProps, isComponent } from '@lumx/react/utils/type';
|
|
9
9
|
import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
|
|
10
10
|
import { Offset, Placement } from '@lumx/react/components/popover/constants';
|
|
11
|
+
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* Defines the props of the component.
|
|
@@ -113,7 +114,7 @@ const DEFAULT_PROPS: Partial<DropdownProps> = {
|
|
|
113
114
|
* @param ref Component ref.
|
|
114
115
|
* @return React element.
|
|
115
116
|
*/
|
|
116
|
-
export const Dropdown
|
|
117
|
+
export const Dropdown = forwardRef<DropdownProps, HTMLDivElement>((props, ref) => {
|
|
117
118
|
const {
|
|
118
119
|
anchorRef,
|
|
119
120
|
children,
|