@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.
Files changed (146) hide show
  1. package/_internal/index.d.ts +1 -1
  2. package/index.d.ts +24 -16
  3. package/index.js +313 -293
  4. package/index.js.map +1 -1
  5. package/package.json +3 -3
  6. package/src/components/alert-dialog/AlertDialog.tsx +3 -4
  7. package/src/components/autocomplete/Autocomplete.test.tsx +9 -2
  8. package/src/components/autocomplete/Autocomplete.tsx +7 -4
  9. package/src/components/autocomplete/AutocompleteMultiple.test.tsx +9 -2
  10. package/src/components/autocomplete/AutocompleteMultiple.tsx +10 -7
  11. package/src/components/avatar/Avatar.test.tsx +14 -4
  12. package/src/components/avatar/Avatar.tsx +7 -5
  13. package/src/components/badge/Badge.tsx +7 -4
  14. package/src/components/badge/BadgeWrapper.tsx +7 -4
  15. package/src/components/button/Button.test.tsx +9 -3
  16. package/src/components/button/Button.tsx +8 -5
  17. package/src/components/button/ButtonGroup.tsx +4 -3
  18. package/src/components/button/ButtonRoot.tsx +4 -3
  19. package/src/components/button/IconButton.test.tsx +9 -3
  20. package/src/components/button/IconButton.tsx +16 -5
  21. package/src/components/checkbox/Checkbox.test.tsx +9 -3
  22. package/src/components/checkbox/Checkbox.tsx +8 -7
  23. package/src/components/chip/Chip.test.tsx +14 -4
  24. package/src/components/chip/Chip.tsx +11 -11
  25. package/src/components/chip/ChipGroup.tsx +5 -4
  26. package/src/components/comment-block/CommentBlock.test.tsx +9 -3
  27. package/src/components/comment-block/CommentBlock.tsx +7 -6
  28. package/src/components/date-picker/DatePicker.tsx +5 -3
  29. package/src/components/date-picker/DatePickerControlled.tsx +6 -3
  30. package/src/components/date-picker/DatePickerField.test.tsx +9 -3
  31. package/src/components/date-picker/DatePickerField.tsx +4 -3
  32. package/src/components/dialog/Dialog.test.tsx +17 -4
  33. package/src/components/dialog/Dialog.tsx +65 -61
  34. package/src/components/divider/Divider.test.tsx +9 -3
  35. package/src/components/divider/Divider.tsx +8 -7
  36. package/src/components/drag-handle/DragHandle.test.tsx +38 -0
  37. package/src/components/drag-handle/DragHandle.tsx +7 -4
  38. package/src/components/dropdown/Dropdown.tsx +4 -3
  39. package/src/components/expansion-panel/ExpansionPanel.test.tsx +12 -3
  40. package/src/components/expansion-panel/ExpansionPanel.tsx +8 -7
  41. package/src/components/flag/Flag.test.tsx +14 -4
  42. package/src/components/flag/Flag.tsx +9 -7
  43. package/src/components/flex-box/FlexBox.tsx +8 -5
  44. package/src/components/generic-block/GenericBlock.tsx +4 -1
  45. package/src/components/grid/Grid.tsx +4 -3
  46. package/src/components/grid/GridItem.tsx +4 -3
  47. package/src/components/grid-column/GridColumn.tsx +5 -5
  48. package/src/components/heading/Heading.tsx +8 -4
  49. package/src/components/icon/Icon.test.tsx +13 -4
  50. package/src/components/icon/Icon.tsx +18 -5
  51. package/src/components/image-block/ImageBlock.test.tsx +12 -4
  52. package/src/components/image-block/ImageBlock.tsx +7 -5
  53. package/src/components/image-lightbox/ImageLightbox.tsx +4 -3
  54. package/src/components/inline-list/InlineList.tsx +4 -3
  55. package/src/components/input-helper/InputHelper.test.tsx +14 -4
  56. package/src/components/input-helper/InputHelper.tsx +10 -6
  57. package/src/components/input-label/InputLabel.test.tsx +14 -4
  58. package/src/components/input-label/InputLabel.tsx +11 -8
  59. package/src/components/lightbox/Lightbox.test.tsx +17 -6
  60. package/src/components/lightbox/Lightbox.tsx +12 -8
  61. package/src/components/link/Link.tsx +4 -3
  62. package/src/components/link-preview/LinkPreview.test.tsx +9 -3
  63. package/src/components/link-preview/LinkPreview.tsx +7 -5
  64. package/src/components/list/List.tsx +7 -5
  65. package/src/components/list/ListDivider.tsx +4 -3
  66. package/src/components/list/ListItem.tsx +4 -3
  67. package/src/components/list/ListSubheader.tsx +4 -3
  68. package/src/components/message/Message.tsx +7 -4
  69. package/src/components/mosaic/Mosaic.test.tsx +9 -3
  70. package/src/components/mosaic/Mosaic.tsx +11 -9
  71. package/src/components/navigation/Navigation.test.tsx +18 -9
  72. package/src/components/navigation/Navigation.tsx +13 -5
  73. package/src/components/navigation/NavigationItem.tsx +4 -4
  74. package/src/components/navigation/NavigationSection.test.tsx +19 -6
  75. package/src/components/navigation/NavigationSection.tsx +4 -4
  76. package/src/components/notification/Notification.tsx +7 -8
  77. package/src/components/popover/Popover.test.tsx +18 -4
  78. package/src/components/popover/Popover.tsx +5 -3
  79. package/src/components/popover-dialog/PopoverDialog.tsx +5 -3
  80. package/src/components/post-block/PostBlock.test.tsx +9 -3
  81. package/src/components/post-block/PostBlock.tsx +7 -8
  82. package/src/components/progress/Progress.tsx +8 -6
  83. package/src/components/progress/ProgressCircular.test.tsx +9 -16
  84. package/src/components/progress/ProgressCircular.tsx +7 -6
  85. package/src/components/progress/ProgressLinear.test.tsx +13 -18
  86. package/src/components/progress/ProgressLinear.tsx +8 -8
  87. package/src/components/progress-tracker/ProgressTracker.tsx +5 -3
  88. package/src/components/progress-tracker/ProgressTrackerStep.tsx +5 -5
  89. package/src/components/progress-tracker/ProgressTrackerStepPanel.tsx +24 -24
  90. package/src/components/radio-button/RadioButton.test.tsx +9 -3
  91. package/src/components/radio-button/RadioButton.tsx +8 -8
  92. package/src/components/radio-button/RadioGroup.tsx +4 -3
  93. package/src/components/select/Select.test.tsx +9 -3
  94. package/src/components/select/Select.tsx +30 -28
  95. package/src/components/select/SelectMultiple.test.tsx +9 -3
  96. package/src/components/select/SelectMultiple.tsx +112 -108
  97. package/src/components/select/WithSelectContext.tsx +8 -6
  98. package/src/components/side-navigation/SideNavigation.tsx +7 -5
  99. package/src/components/side-navigation/SideNavigationItem.tsx +4 -5
  100. package/src/components/skeleton/SkeletonCircle.test.tsx +9 -3
  101. package/src/components/skeleton/SkeletonCircle.tsx +9 -7
  102. package/src/components/skeleton/SkeletonRectangle.test.tsx +9 -3
  103. package/src/components/skeleton/SkeletonRectangle.tsx +8 -5
  104. package/src/components/skeleton/SkeletonTypography.test.tsx +9 -3
  105. package/src/components/skeleton/SkeletonTypography.tsx +9 -7
  106. package/src/components/slider/Slider.test.tsx +9 -3
  107. package/src/components/slider/Slider.tsx +7 -7
  108. package/src/components/slideshow/Slides.tsx +9 -5
  109. package/src/components/slideshow/Slideshow.test.tsx +9 -3
  110. package/src/components/slideshow/Slideshow.tsx +8 -5
  111. package/src/components/slideshow/SlideshowControls.tsx +7 -5
  112. package/src/components/slideshow/SlideshowItem.tsx +4 -3
  113. package/src/components/slideshow/SlideshowItemGroup.tsx +5 -4
  114. package/src/components/switch/Switch.test.tsx +9 -3
  115. package/src/components/switch/Switch.tsx +7 -7
  116. package/src/components/table/Table.test.tsx +9 -3
  117. package/src/components/table/Table.tsx +8 -8
  118. package/src/components/table/TableBody.tsx +4 -3
  119. package/src/components/table/TableCell.tsx +5 -5
  120. package/src/components/table/TableHeader.tsx +4 -3
  121. package/src/components/table/TableRow.tsx +4 -3
  122. package/src/components/tabs/Tab.tsx +4 -3
  123. package/src/components/tabs/TabList.test.tsx +9 -3
  124. package/src/components/tabs/TabList.tsx +18 -6
  125. package/src/components/tabs/TabPanel.tsx +7 -5
  126. package/src/components/text/Text.tsx +6 -4
  127. package/src/components/text-field/TextField.test.tsx +9 -3
  128. package/src/components/text-field/TextField.tsx +7 -5
  129. package/src/components/thumbnail/Thumbnail.test.tsx +9 -3
  130. package/src/components/thumbnail/Thumbnail.tsx +8 -7
  131. package/src/components/toolbar/Toolbar.tsx +4 -3
  132. package/src/components/tooltip/Tooltip.tsx +4 -3
  133. package/src/components/uploader/Uploader.test.tsx +9 -3
  134. package/src/components/uploader/Uploader.tsx +18 -5
  135. package/src/components/user-block/UserBlock.test.tsx +9 -3
  136. package/src/components/user-block/UserBlock.tsx +9 -6
  137. package/src/index.ts +1 -0
  138. package/src/testing/utils/ThemeSentinel.tsx +11 -0
  139. package/src/testing/utils/commonTestsSuiteRTL.tsx +191 -0
  140. package/src/utils/react/forwardRef.ts +10 -0
  141. package/src/utils/react/forwardRefPolymorphic.ts +10 -0
  142. package/src/utils/theme/ThemeContext.ts +16 -0
  143. package/src/utils/theme/invertTheme.ts +4 -0
  144. package/src/testing/utils/commonTestsSuiteRTL.ts +0 -64
  145. package/src/utils/ThemeContext.ts +0 -4
  146. package/src/utils/forwardRefPolymorphic.ts +0 -9
@@ -1,14 +1,14 @@
1
1
  import React from 'react';
2
2
 
3
- import { commonTestsSuiteRTL } from '@lumx/react/testing/utils';
3
+ import { commonTestsSuiteRTL, SetupRenderOptions } from '@lumx/react/testing/utils';
4
4
  import { render } from '@testing-library/react';
5
5
  import { queryByClassName } from '@lumx/react/testing/utils/queries';
6
6
  import { SkeletonRectangle, SkeletonRectangleProps } from './SkeletonRectangle';
7
7
 
8
8
  const CLASSNAME = SkeletonRectangle.className as string;
9
9
 
10
- const setup = (props: Partial<SkeletonRectangleProps> = {}) => {
11
- render(<SkeletonRectangle {...(props as any)} />);
10
+ const setup = (props: Partial<SkeletonRectangleProps> = {}, { wrapper }: SetupRenderOptions = {}) => {
11
+ render(<SkeletonRectangle {...(props as any)} />, { wrapper });
12
12
  const skeletonRectangle = queryByClassName(document.body, CLASSNAME);
13
13
  return { props, skeletonRectangle };
14
14
  };
@@ -19,5 +19,11 @@ describe(`<${SkeletonRectangle.displayName}>`, () => {
19
19
  baseClassName: CLASSNAME,
20
20
  forwardClassName: 'skeletonRectangle',
21
21
  forwardAttributes: 'skeletonRectangle',
22
+ applyTheme: {
23
+ affects: [{ element: 'skeletonRectangle' }],
24
+ viaProp: true,
25
+ viaContext: true,
26
+ defaultTheme: 'light',
27
+ },
22
28
  });
23
29
  });
@@ -1,9 +1,12 @@
1
+ import React from 'react';
2
+
1
3
  import classNames from 'classnames';
2
- import React, { forwardRef } from 'react';
3
4
 
4
5
  import { AspectRatio, GlobalSize, Theme, ColorPalette } from '@lumx/react';
5
- import { Comp, GenericProps, HasTheme, ValueOf } from '@lumx/react/utils/type';
6
+ import { GenericProps, HasTheme, ValueOf } 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
  /**
9
12
  * Skeleton variants.
@@ -28,7 +31,6 @@ export interface SkeletonRectangleProps extends GenericProps, HasTheme {
28
31
  }
29
32
 
30
33
  const DEFAULT_PROPS: Partial<SkeletonRectangleProps> = {
31
- theme: Theme.light,
32
34
  variant: SkeletonRectangleVariant.squared,
33
35
  };
34
36
 
@@ -49,8 +51,9 @@ const CLASSNAME = getRootClassName(COMPONENT_NAME);
49
51
  * @param ref Component ref.
50
52
  * @return React element.
51
53
  */
52
- export const SkeletonRectangle: Comp<SkeletonRectangleProps, HTMLDivElement> = forwardRef((props, ref) => {
53
- const { aspectRatio, className, height, theme, variant, width, color, ...forwardedProps } = props;
54
+ export const SkeletonRectangle = forwardRef<SkeletonRectangleProps, HTMLDivElement>((props, ref) => {
55
+ const defaultTheme = useTheme() || Theme.light;
56
+ const { aspectRatio, className, height, theme = defaultTheme, variant, width, color, ...forwardedProps } = props;
54
57
 
55
58
  return (
56
59
  <div
@@ -1,14 +1,14 @@
1
1
  import React from 'react';
2
2
 
3
- import { commonTestsSuiteRTL } from '@lumx/react/testing/utils';
3
+ import { commonTestsSuiteRTL, SetupRenderOptions } from '@lumx/react/testing/utils';
4
4
  import { render } from '@testing-library/react';
5
5
  import { queryByClassName } from '@lumx/react/testing/utils/queries';
6
6
  import { SkeletonTypography, SkeletonTypographyProps } from './SkeletonTypography';
7
7
 
8
8
  const CLASSNAME = SkeletonTypography.className as string;
9
9
 
10
- const setup = (props: Partial<SkeletonTypographyProps> = {}) => {
11
- render(<SkeletonTypography {...(props as any)} />);
10
+ const setup = (props: Partial<SkeletonTypographyProps> = {}, { wrapper }: SetupRenderOptions = {}) => {
11
+ render(<SkeletonTypography {...(props as any)} />, { wrapper });
12
12
  const skeletonTypography = queryByClassName(document.body, CLASSNAME);
13
13
  return { props, skeletonTypography };
14
14
  };
@@ -19,5 +19,11 @@ describe(`<${SkeletonTypography.displayName}>`, () => {
19
19
  baseClassName: CLASSNAME,
20
20
  forwardClassName: 'skeletonTypography',
21
21
  forwardAttributes: 'skeletonTypography',
22
+ applyTheme: {
23
+ affects: [{ element: 'skeletonTypography' }],
24
+ viaProp: true,
25
+ viaContext: true,
26
+ defaultTheme: 'light',
27
+ },
22
28
  });
23
29
  });
@@ -1,9 +1,12 @@
1
+ import React, { CSSProperties } from 'react';
2
+
1
3
  import classNames from 'classnames';
2
- import React, { CSSProperties, forwardRef } from 'react';
3
4
 
4
5
  import { Theme, TypographyInterface, ColorPalette } from '@lumx/react';
5
- import { Comp, GenericProps, HasTheme } from '@lumx/react/utils/type';
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
  /**
9
12
  * Defines the props of the component.
@@ -17,9 +20,7 @@ export interface SkeletonTypographyProps extends GenericProps, HasTheme {
17
20
  color?: ColorPalette;
18
21
  }
19
22
 
20
- const DEFAULT_PROPS: Partial<SkeletonTypographyProps> = {
21
- theme: Theme.light,
22
- };
23
+ const DEFAULT_PROPS: Partial<SkeletonTypographyProps> = {};
23
24
 
24
25
  /**
25
26
  * Component display name.
@@ -38,8 +39,9 @@ const CLASSNAME = getRootClassName(COMPONENT_NAME);
38
39
  * @param ref Component ref.
39
40
  * @return React element.
40
41
  */
41
- export const SkeletonTypography: Comp<SkeletonTypographyProps, HTMLDivElement> = forwardRef((props, ref) => {
42
- const { className, theme, typography, width, color, ...forwardedProps } = props;
42
+ export const SkeletonTypography = forwardRef<SkeletonTypographyProps, HTMLDivElement>((props, ref) => {
43
+ const defaultTheme = useTheme() || Theme.light;
44
+ const { className, theme = defaultTheme, typography, width, color, ...forwardedProps } = props;
43
45
 
44
46
  return (
45
47
  <div
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
 
3
- import { commonTestsSuiteRTL } from '@lumx/react/testing/utils';
3
+ import { commonTestsSuiteRTL, SetupRenderOptions } from '@lumx/react/testing/utils';
4
4
  import { render } from '@testing-library/react';
5
5
  import { queryByClassName } from '@lumx/react/testing/utils/queries';
6
6
  import { Slider, SliderProps } from './Slider';
@@ -9,8 +9,8 @@ const CLASSNAME = Slider.className as string;
9
9
 
10
10
  jest.mock('@lumx/react/hooks/useId', () => ({ useId: () => ':r1:' }));
11
11
 
12
- const setup = (props: Partial<SliderProps> = {}) => {
13
- render(<Slider {...(props as any)} />);
12
+ const setup = (props: Partial<SliderProps> = {}, { wrapper }: SetupRenderOptions = {}) => {
13
+ render(<Slider {...(props as any)} />, { wrapper });
14
14
  const slider = queryByClassName(document.body, CLASSNAME);
15
15
  return { props, slider };
16
16
  };
@@ -21,5 +21,11 @@ describe(`<${Slider.displayName}>`, () => {
21
21
  baseClassName: CLASSNAME,
22
22
  forwardClassName: 'slider',
23
23
  forwardAttributes: 'slider',
24
+ applyTheme: {
25
+ affects: [{ element: 'slider' }],
26
+ viaProp: true,
27
+ viaContext: true,
28
+ defaultTheme: 'light',
29
+ },
24
30
  });
25
31
  });
@@ -1,16 +1,16 @@
1
1
  /* eslint-disable jsx-a11y/no-static-element-interactions */
2
- import React, { forwardRef, SyntheticEvent, useMemo, useRef } from 'react';
2
+ import React, { SyntheticEvent, useMemo, useRef } from 'react';
3
3
 
4
4
  import classNames from 'classnames';
5
5
 
6
6
  import { InputHelper, InputLabel, Theme } from '@lumx/react';
7
-
8
7
  import useEventCallback from '@lumx/react/hooks/useEventCallback';
9
- import { Comp, GenericProps, HasTheme } from '@lumx/react/utils/type';
8
+ import { GenericProps, HasTheme } from '@lumx/react/utils/type';
10
9
  import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
11
-
12
10
  import { clamp } from '@lumx/react/utils/clamp';
13
11
  import { useId } from '@lumx/react/hooks/useId';
12
+ import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
13
+ import { forwardRef } from '@lumx/react/utils/react/forwardRef';
14
14
 
15
15
  /**
16
16
  * Defines the props of the component.
@@ -58,7 +58,6 @@ const CLASSNAME = getRootClassName(COMPONENT_NAME);
58
58
  const DEFAULT_PROPS: Partial<SliderProps> = {
59
59
  precision: 0,
60
60
  steps: 0,
61
- theme: Theme.light,
62
61
  };
63
62
 
64
63
  /**
@@ -91,7 +90,8 @@ const computePercentFromValue = (value: number, min: number, max: number): numbe
91
90
  * @param ref Component ref.
92
91
  * @return React element.
93
92
  */
94
- export const Slider: Comp<SliderProps, HTMLDivElement> = forwardRef((props, ref) => {
93
+ export const Slider = forwardRef<SliderProps, HTMLDivElement>((props, ref) => {
94
+ const defaultTheme = useTheme() || Theme.light;
95
95
  const {
96
96
  className,
97
97
  disabled,
@@ -107,7 +107,7 @@ export const Slider: Comp<SliderProps, HTMLDivElement> = forwardRef((props, ref)
107
107
  onMouseDown,
108
108
  precision,
109
109
  steps,
110
- theme,
110
+ theme = defaultTheme,
111
111
  value,
112
112
  ...forwardedProps
113
113
  } = props;
@@ -1,11 +1,14 @@
1
- import React, { Children, CSSProperties, forwardRef } from 'react';
2
- import chunk from 'lodash/chunk';
1
+ import React, { Children, CSSProperties } from 'react';
3
2
 
3
+ import chunk from 'lodash/chunk';
4
4
  import classNames from 'classnames';
5
5
 
6
6
  import { FULL_WIDTH_PERCENT } from '@lumx/react/components/slideshow/constants';
7
- import { Comp, GenericProps, HasTheme } from '@lumx/react/utils/type';
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';
11
+
9
12
  import { buildSlideShowGroupId, SlideshowItemGroup } from './SlideshowItemGroup';
10
13
 
11
14
  export interface SlidesProps extends GenericProps, HasTheme {
@@ -53,12 +56,13 @@ const CLASSNAME = getRootClassName(COMPONENT_NAME);
53
56
  * @param ref Component ref.
54
57
  * @return React element.
55
58
  */
56
- export const Slides: Comp<SlidesProps, HTMLDivElement> = forwardRef((props, ref) => {
59
+ export const Slides = forwardRef<SlidesProps, HTMLDivElement>((props, ref) => {
60
+ const defaultTheme = useTheme();
57
61
  const {
58
62
  activeIndex,
59
63
  id,
60
64
  className,
61
- theme,
65
+ theme = defaultTheme,
62
66
  fillHeight,
63
67
  groupBy,
64
68
  isAutoPlaying,
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
 
3
- import { commonTestsSuiteRTL } from '@lumx/react/testing/utils';
3
+ import { commonTestsSuiteRTL, SetupRenderOptions } from '@lumx/react/testing/utils';
4
4
  import { render } from '@testing-library/react';
5
5
  import { queryByClassName } from '@lumx/react/testing/utils/queries';
6
6
  import { Slideshow, SlideshowProps } from './Slideshow';
@@ -8,7 +8,7 @@ import { Slides } from './Slides';
8
8
 
9
9
  const CLASSNAME = Slides.className as string;
10
10
 
11
- const setup = (propsOverride: Partial<SlideshowProps> = {}) => {
11
+ const setup = (propsOverride: Partial<SlideshowProps> = {}, { wrapper }: SetupRenderOptions = {}) => {
12
12
  const props: SlideshowProps = {
13
13
  slideshowControlsProps: {
14
14
  nextButtonProps: { label: 'Next' },
@@ -16,7 +16,7 @@ const setup = (propsOverride: Partial<SlideshowProps> = {}) => {
16
16
  },
17
17
  ...propsOverride,
18
18
  };
19
- render(<Slideshow {...props} />);
19
+ render(<Slideshow {...props} />, { wrapper });
20
20
  const slideShow = queryByClassName(document.body, CLASSNAME);
21
21
  return { props, slideShow };
22
22
  };
@@ -27,5 +27,11 @@ describe(`<${Slideshow.displayName}>`, () => {
27
27
  baseClassName: CLASSNAME,
28
28
  forwardClassName: 'slideShow',
29
29
  forwardAttributes: 'slideShow',
30
+ applyTheme: {
31
+ affects: [{ element: 'slideShow' }],
32
+ viaProp: true,
33
+ viaContext: true,
34
+ defaultTheme: 'light',
35
+ },
30
36
  });
31
37
  });
@@ -1,10 +1,13 @@
1
- import React, { forwardRef } from 'react';
1
+ import React from 'react';
2
2
 
3
3
  import { SlideshowControls, SlideshowControlsProps, Theme, Slides, SlidesProps } from '@lumx/react';
4
4
  import { DEFAULT_OPTIONS } from '@lumx/react/hooks/useSlideshowControls';
5
- import { Comp, GenericProps } from '@lumx/react/utils/type';
5
+ import { GenericProps } from '@lumx/react/utils/type';
6
6
  import { useFocusWithin } from '@lumx/react/hooks/useFocusWithin';
7
7
  import { mergeRefs } from '@lumx/react/utils/mergeRefs';
8
+ import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
9
+ import { forwardRef } from '@lumx/react/utils/react/forwardRef';
10
+
8
11
  import { buildSlideShowGroupId } from './SlideshowItemGroup';
9
12
 
10
13
  /**
@@ -41,7 +44,6 @@ export interface SlideshowProps
41
44
  */
42
45
  const DEFAULT_PROPS: Partial<SlideshowProps> = {
43
46
  ...DEFAULT_OPTIONS,
44
- theme: Theme.light,
45
47
  };
46
48
 
47
49
  /**
@@ -51,7 +53,8 @@ const DEFAULT_PROPS: Partial<SlideshowProps> = {
51
53
  * @param ref Component ref.
52
54
  * @return React element.
53
55
  */
54
- export const Slideshow: Comp<SlideshowProps, HTMLDivElement> = forwardRef((props, ref) => {
56
+ export const Slideshow = forwardRef<SlideshowProps, HTMLDivElement>((props, ref) => {
57
+ const defaultTheme = useTheme() || Theme.light;
55
58
  const {
56
59
  activeIndex,
57
60
  autoPlay,
@@ -62,7 +65,7 @@ export const Slideshow: Comp<SlideshowProps, HTMLDivElement> = forwardRef((props
62
65
  interval,
63
66
  onChange,
64
67
  slideshowControlsProps,
65
- theme,
68
+ theme = defaultTheme,
66
69
  id,
67
70
  slidesId,
68
71
  slideGroupLabel,
@@ -1,16 +1,18 @@
1
- import React, { forwardRef, RefObject, useCallback, useMemo } from 'react';
1
+ import React, { RefObject, useCallback, useMemo } from 'react';
2
2
 
3
3
  import classNames from 'classnames';
4
4
  import range from 'lodash/range';
5
5
 
6
6
  import { mdiChevronLeft, mdiChevronRight, mdiPlayCircleOutline, mdiPauseCircleOutline } from '@lumx/icons';
7
7
  import { Emphasis, IconButton, IconButtonProps, Theme } from '@lumx/react';
8
- import { Comp, GenericProps, HasTheme } from '@lumx/react/utils/type';
8
+ import { GenericProps, HasTheme } from '@lumx/react/utils/type';
9
9
  import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
10
10
  import { WINDOW } from '@lumx/react/constants';
11
11
  import { useSlideshowControls, DEFAULT_OPTIONS } from '@lumx/react/hooks/useSlideshowControls';
12
12
  import { useRovingTabIndex } from '@lumx/react/hooks/useRovingTabIndex';
13
+ import { forwardRef } from '@lumx/react/utils/react/forwardRef';
13
14
 
15
+ import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
14
16
  import { useSwipeNavigate } from './useSwipeNavigate';
15
17
  import { PAGINATION_ITEM_SIZE, PAGINATION_ITEMS_MAX } from './constants';
16
18
  import { usePaginationVisibleRange } from './usePaginationVisibleRange';
@@ -70,7 +72,6 @@ const CLASSNAME = getRootClassName(COMPONENT_NAME);
70
72
  */
71
73
  const DEFAULT_PROPS: Partial<SlideshowControlsProps> = {
72
74
  activeIndex: 0,
73
- theme: Theme.light,
74
75
  };
75
76
 
76
77
  /**
@@ -80,7 +81,8 @@ const DEFAULT_PROPS: Partial<SlideshowControlsProps> = {
80
81
  * @param ref Component ref.
81
82
  * @return React element.
82
83
  */
83
- const InternalSlideshowControls: Comp<SlideshowControlsProps, HTMLDivElement> = forwardRef((props, ref) => {
84
+ const InternalSlideshowControls = forwardRef<SlideshowControlsProps, HTMLDivElement>((props, ref) => {
85
+ const defaultTheme = useTheme() || Theme.light;
84
86
  const {
85
87
  activeIndex,
86
88
  className,
@@ -92,7 +94,7 @@ const InternalSlideshowControls: Comp<SlideshowControlsProps, HTMLDivElement> =
92
94
  previousButtonProps,
93
95
  paginationProps,
94
96
  slidesCount,
95
- theme,
97
+ theme = defaultTheme,
96
98
  isAutoPlaying = false,
97
99
  playButtonProps,
98
100
  paginationItemLabel,
@@ -1,9 +1,10 @@
1
- import React, { forwardRef } from 'react';
1
+ import React from 'react';
2
2
 
3
3
  import classNames from 'classnames';
4
4
 
5
- import { Comp, GenericProps } from '@lumx/react/utils/type';
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.
@@ -30,7 +31,7 @@ const CLASSNAME = getRootClassName(COMPONENT_NAME);
30
31
  * @param ref Component ref.
31
32
  * @return React element.
32
33
  */
33
- export const SlideshowItem: Comp<SlideshowItemProps, HTMLDivElement> = forwardRef((props, ref) => {
34
+ export const SlideshowItem = forwardRef<SlideshowItemProps, HTMLDivElement>((props, ref) => {
34
35
  const { className, children, ...forwardedProps } = props;
35
36
  return (
36
37
  <div
@@ -1,10 +1,11 @@
1
- import React, { forwardRef } from 'react';
1
+ import React from 'react';
2
2
 
3
3
  import classNames from 'classnames';
4
4
  import { mergeRefs } from '@lumx/react/utils/mergeRefs';
5
-
6
- import { Comp, GenericProps } from '@lumx/react/utils/type';
5
+ import { GenericProps } from '@lumx/react/utils/type';
7
6
  import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
7
+ import { forwardRef } from '@lumx/react/utils/react/forwardRef';
8
+
8
9
  import { useSlideFocusManagement } from './useSlideFocusManagement';
9
10
 
10
11
  /**
@@ -35,7 +36,7 @@ export const buildSlideShowGroupId = (slidesId: string, index: number) => `${sli
35
36
  * @param ref Component ref.
36
37
  * @return React element.
37
38
  */
38
- export const SlideshowItemGroup: Comp<SlideshowItemGroupProps, HTMLDivElement> = forwardRef((props, ref) => {
39
+ export const SlideshowItemGroup = forwardRef<SlideshowItemGroupProps, HTMLDivElement>((props, ref) => {
39
40
  const { className, children, role = 'group', label, isDisplayed, ...forwardedProps } = props;
40
41
  const groupRef = React.useRef<HTMLDivElement>(null);
41
42
 
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
 
3
- import { commonTestsSuiteRTL } from '@lumx/react/testing/utils';
3
+ import { commonTestsSuiteRTL, SetupRenderOptions } from '@lumx/react/testing/utils';
4
4
  import { render } from '@testing-library/react';
5
5
  import { getByClassName, getByTagName, queryByClassName } from '@lumx/react/testing/utils/queries';
6
6
  import userEvent from '@testing-library/user-event/';
@@ -14,9 +14,9 @@ type SetupProps = Partial<SwitchProps>;
14
14
  /**
15
15
  * Mounts the component and returns common DOM elements / data needed in multiple tests further down.
16
16
  */
17
- const setup = (propsOverride: SetupProps = {}) => {
17
+ const setup = (propsOverride: SetupProps = {}, { wrapper }: SetupRenderOptions = {}) => {
18
18
  const props = { ...propsOverride };
19
- render(<Switch {...props} />);
19
+ render(<Switch {...props} />, { wrapper });
20
20
  const switchWrapper = getByClassName(document.body, CLASSNAME);
21
21
  const input = getByTagName(switchWrapper, 'input');
22
22
  const helper = queryByClassName(switchWrapper, `${CLASSNAME}__helper`);
@@ -106,5 +106,11 @@ describe(`<${Switch.displayName}>`, () => {
106
106
  forwardClassName: 'switchWrapper',
107
107
  forwardAttributes: 'switchWrapper',
108
108
  forwardRef: 'switchWrapper',
109
+ applyTheme: {
110
+ affects: [{ element: 'switchWrapper' }],
111
+ viaProp: true,
112
+ viaContext: true,
113
+ defaultTheme: 'light',
114
+ },
109
115
  });
110
116
  });
@@ -1,14 +1,14 @@
1
- import React, { Children, forwardRef, InputHTMLAttributes, SyntheticEvent } from 'react';
1
+ import React, { Children, InputHTMLAttributes, SyntheticEvent } from 'react';
2
2
 
3
3
  import classNames from 'classnames';
4
-
5
4
  import isEmpty from 'lodash/isEmpty';
6
5
 
7
6
  import { Alignment, InputHelper, InputLabel, Theme } from '@lumx/react';
8
-
9
- import { Comp, GenericProps, HasTheme } from '@lumx/react/utils/type';
7
+ import { GenericProps, HasTheme } from '@lumx/react/utils/type';
10
8
  import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
11
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';
12
12
 
13
13
  /**
14
14
  * Defines the props of the component.
@@ -47,7 +47,6 @@ const CLASSNAME = getRootClassName(COMPONENT_NAME);
47
47
  */
48
48
  const DEFAULT_PROPS: Partial<SwitchProps> = {
49
49
  position: Alignment.left,
50
- theme: Theme.light,
51
50
  };
52
51
 
53
52
  /**
@@ -57,7 +56,8 @@ const DEFAULT_PROPS: Partial<SwitchProps> = {
57
56
  * @param ref Component ref.
58
57
  * @return React element.
59
58
  */
60
- export const Switch: Comp<SwitchProps, HTMLDivElement> = forwardRef((props, ref) => {
59
+ export const Switch = forwardRef<SwitchProps, HTMLDivElement>((props, ref) => {
60
+ const defaultTheme = useTheme() || Theme.light;
61
61
  const {
62
62
  checked,
63
63
  children,
@@ -70,7 +70,7 @@ export const Switch: Comp<SwitchProps, HTMLDivElement> = forwardRef((props, ref)
70
70
  name,
71
71
  onChange,
72
72
  position,
73
- theme,
73
+ theme = defaultTheme,
74
74
  value,
75
75
  inputProps = {},
76
76
  ...forwardedProps
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
 
3
- import { commonTestsSuiteRTL } from '@lumx/react/testing/utils';
3
+ import { commonTestsSuiteRTL, SetupRenderOptions } from '@lumx/react/testing/utils';
4
4
  import { queryByClassName } from '@lumx/react/testing/utils/queries';
5
5
  import { render } from '@testing-library/react';
6
6
 
@@ -8,8 +8,8 @@ import { Table, TableProps } from './Table';
8
8
 
9
9
  const CLASSNAME = Table.className as string;
10
10
 
11
- const setup = (props: Partial<TableProps> = {}) => {
12
- render(<Table {...(props as any)} />);
11
+ const setup = (props: Partial<TableProps> = {}, { wrapper }: SetupRenderOptions = {}) => {
12
+ render(<Table {...(props as any)} />, { wrapper });
13
13
  const table = queryByClassName(document.body, CLASSNAME);
14
14
  return { props, table };
15
15
  };
@@ -21,5 +21,11 @@ describe(`<${Table.displayName}>`, () => {
21
21
  forwardClassName: 'table',
22
22
  forwardAttributes: 'table',
23
23
  forwardRef: 'table',
24
+ applyTheme: {
25
+ affects: [{ element: 'table' }],
26
+ viaProp: true,
27
+ viaContext: true,
28
+ defaultTheme: 'light',
29
+ },
24
30
  });
25
31
  });
@@ -1,11 +1,12 @@
1
- import React, { forwardRef } from 'react';
1
+ import React from 'react';
2
2
 
3
3
  import classNames from 'classnames';
4
4
 
5
5
  import { Theme } from '@lumx/react';
6
-
7
- import { Comp, GenericProps, HasTheme } from '@lumx/react/utils/type';
6
+ import { GenericProps, HasTheme } from '@lumx/react/utils/type';
8
7
  import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
8
+ import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
9
+ import { forwardRef } from '@lumx/react/utils/react/forwardRef';
9
10
 
10
11
  /**
11
12
  * Defines the props of the component.
@@ -30,9 +31,7 @@ const CLASSNAME = getRootClassName(COMPONENT_NAME);
30
31
  /**
31
32
  * Component default props.
32
33
  */
33
- const DEFAULT_PROPS: Partial<TableProps> = {
34
- theme: Theme.light,
35
- };
34
+ const DEFAULT_PROPS: Partial<TableProps> = {};
36
35
 
37
36
  /**
38
37
  * Table component.
@@ -41,8 +40,9 @@ const DEFAULT_PROPS: Partial<TableProps> = {
41
40
  * @param ref Component ref.
42
41
  * @return React element.
43
42
  */
44
- export const Table: Comp<TableProps, HTMLTableElement> = forwardRef((props, ref) => {
45
- const { children, className, hasBefore, hasDividers, theme, ...forwardedProps } = props;
43
+ export const Table = forwardRef<TableProps, HTMLTableElement>((props, ref) => {
44
+ const defaultTheme = useTheme() || Theme.light;
45
+ const { children, className, hasBefore, hasDividers, theme = defaultTheme, ...forwardedProps } = props;
46
46
 
47
47
  return (
48
48
  <table
@@ -1,9 +1,10 @@
1
- import React, { forwardRef } from 'react';
1
+ import React from 'react';
2
2
 
3
3
  import classNames from 'classnames';
4
4
 
5
- import { Comp, GenericProps } from '@lumx/react/utils/type';
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.
@@ -27,7 +28,7 @@ const CLASSNAME = getRootClassName(COMPONENT_NAME, true);
27
28
  * @param ref Component ref.
28
29
  * @return React element.
29
30
  */
30
- export const TableBody: Comp<TableBodyProps, HTMLTableSectionElement> = forwardRef((props, ref) => {
31
+ export const TableBody = forwardRef<TableBodyProps, HTMLTableSectionElement>((props, ref) => {
31
32
  const { children, className, ...forwardedProps } = props;
32
33
 
33
34
  return (
@@ -1,12 +1,12 @@
1
- import React, { forwardRef } from 'react';
1
+ import React from 'react';
2
2
 
3
3
  import classNames from 'classnames';
4
4
 
5
+ import { mdiArrowDown, mdiArrowUp } from '@lumx/icons';
5
6
  import { Icon, Size } from '@lumx/react';
6
- import { Comp, GenericProps, ValueOf } from '@lumx/react/utils/type';
7
+ import { GenericProps, ValueOf } from '@lumx/react/utils/type';
7
8
  import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
8
-
9
- import { mdiArrowDown, mdiArrowUp } from '@lumx/icons';
9
+ import { forwardRef } from '@lumx/react/utils/react/forwardRef';
10
10
 
11
11
  /**
12
12
  * Table head cell sort order.
@@ -60,7 +60,7 @@ const DEFAULT_PROPS: Partial<TableCellProps> = {
60
60
  * @param ref Component ref.
61
61
  * @return React element.
62
62
  */
63
- export const TableCell: Comp<TableCellProps, HTMLTableCellElement> = forwardRef((props, ref) => {
63
+ export const TableCell = forwardRef<TableCellProps, HTMLTableCellElement>((props, ref) => {
64
64
  const { children, className, icon, isSortable, onHeaderClick, sortOrder, variant, ...forwardedProps } = props;
65
65
 
66
66
  // Use button if clickable
@@ -1,9 +1,10 @@
1
- import React, { forwardRef } from 'react';
1
+ import React from 'react';
2
2
 
3
3
  import classNames from 'classnames';
4
4
 
5
- import { Comp, GenericProps } from '@lumx/react/utils/type';
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.
@@ -32,7 +33,7 @@ const DEFAULT_PROPS: Partial<TableHeaderProps> = {};
32
33
  * @param ref Component ref.
33
34
  * @return React element.
34
35
  */
35
- export const TableHeader: Comp<TableHeaderProps, HTMLTableSectionElement> = forwardRef((props, ref) => {
36
+ export const TableHeader = forwardRef<TableHeaderProps, HTMLTableSectionElement>((props, ref) => {
36
37
  const { children, className, ...forwardedProps } = props;
37
38
 
38
39
  return (