@lumx/react 2.2.21 → 2.2.22-alpha-fix-generic-block.2

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 (109) hide show
  1. package/esm/_internal/AutocompleteMultiple.js.map +1 -1
  2. package/esm/_internal/Avatar2.js.map +1 -1
  3. package/esm/_internal/ButtonRoot.js.map +1 -1
  4. package/esm/_internal/Checkbox2.js.map +1 -1
  5. package/esm/_internal/Chip2.js.map +1 -1
  6. package/esm/_internal/ClickAwayProvider.js +43 -24
  7. package/esm/_internal/ClickAwayProvider.js.map +1 -1
  8. package/esm/_internal/CommentBlock.js.map +1 -1
  9. package/esm/_internal/Dialog2.js +6 -3
  10. package/esm/_internal/Dialog2.js.map +1 -1
  11. package/esm/_internal/Divider2.js.map +1 -1
  12. package/esm/_internal/DragHandle.js.map +1 -1
  13. package/esm/_internal/Dropdown2.js.map +1 -1
  14. package/esm/_internal/ExpansionPanel.js.map +1 -1
  15. package/esm/_internal/Flag2.js.map +1 -1
  16. package/esm/_internal/FlexBox.js.map +1 -1
  17. package/esm/_internal/GenericBlock.js +72 -37
  18. package/esm/_internal/GenericBlock.js.map +1 -1
  19. package/esm/_internal/Icon2.js.map +1 -1
  20. package/esm/_internal/ImageBlock.js.map +1 -1
  21. package/esm/_internal/InputHelper.js.map +1 -1
  22. package/esm/_internal/InputLabel.js.map +1 -1
  23. package/esm/_internal/Lightbox2.js +1 -1
  24. package/esm/_internal/Lightbox2.js.map +1 -1
  25. package/esm/_internal/LinkPreview.js.map +1 -1
  26. package/esm/_internal/Mosaic2.js.map +1 -1
  27. package/esm/_internal/Notification2.js.map +1 -1
  28. package/esm/_internal/Popover2.js +1 -1
  29. package/esm/_internal/Popover2.js.map +1 -1
  30. package/esm/_internal/PostBlock.js.map +1 -1
  31. package/esm/_internal/Progress2.js.map +1 -1
  32. package/esm/_internal/RadioGroup.js.map +1 -1
  33. package/esm/_internal/SelectMultiple.js.map +1 -1
  34. package/esm/_internal/SideNavigationItem.js.map +1 -1
  35. package/esm/_internal/SkeletonTypography.js.map +1 -1
  36. package/esm/_internal/Slider2.js.map +1 -1
  37. package/esm/_internal/Slides.js.map +1 -1
  38. package/esm/_internal/Switch2.js.map +1 -1
  39. package/esm/_internal/TabPanel.js.map +1 -1
  40. package/esm/_internal/TableRow.js.map +1 -1
  41. package/esm/_internal/TextField.js.map +1 -1
  42. package/esm/_internal/Thumbnail2.js.map +1 -1
  43. package/esm/_internal/Uploader2.js.map +1 -1
  44. package/esm/_internal/UserBlock.js.map +1 -1
  45. package/esm/_internal/_rollupPluginBabelHelpers.js +5 -1
  46. package/esm/_internal/_rollupPluginBabelHelpers.js.map +1 -1
  47. package/esm/_internal/generic-block.js +8 -0
  48. package/esm/_internal/generic-block.js.map +1 -1
  49. package/esm/_internal/type.js +11 -1
  50. package/esm/_internal/type.js.map +1 -1
  51. package/package.json +4 -4
  52. package/src/components/autocomplete/Autocomplete.tsx +6 -8
  53. package/src/components/avatar/Avatar.tsx +2 -4
  54. package/src/components/button/Button.test.tsx +1 -1
  55. package/src/components/button/ButtonRoot.tsx +3 -4
  56. package/src/components/button/IconButton.test.tsx +1 -1
  57. package/src/components/checkbox/Checkbox.tsx +2 -4
  58. package/src/components/chip/Chip.tsx +2 -4
  59. package/src/components/comment-block/CommentBlock.tsx +2 -4
  60. package/src/components/dialog/Dialog.stories.tsx +3 -3
  61. package/src/components/dialog/Dialog.tsx +11 -4
  62. package/src/components/divider/Divider.tsx +2 -5
  63. package/src/components/drag-handle/DragHandle.tsx +2 -5
  64. package/src/components/dropdown/Dropdown.tsx +4 -3
  65. package/src/components/expansion-panel/ExpansionPanel.tsx +2 -3
  66. package/src/components/flag/Flag.tsx +2 -4
  67. package/src/components/flex-box/FlexBox.stories.tsx +1 -1
  68. package/src/components/flex-box/FlexBox.tsx +1 -1
  69. package/src/components/generic-block/GenericBlock.stories.jsx +106 -0
  70. package/src/components/generic-block/GenericBlock.test.tsx +129 -5
  71. package/src/components/generic-block/GenericBlock.tsx +132 -44
  72. package/src/components/icon/Icon.tsx +2 -4
  73. package/src/components/image-block/ImageBlock.tsx +2 -4
  74. package/src/components/input-helper/InputHelper.tsx +2 -4
  75. package/src/components/input-label/InputLabel.tsx +2 -4
  76. package/src/components/lightbox/Lightbox.tsx +4 -6
  77. package/src/components/lightbox/__snapshots__/Lightbox.test.tsx.snap +1 -1
  78. package/src/components/link-preview/LinkPreview.tsx +2 -4
  79. package/src/components/mosaic/Mosaic.tsx +2 -4
  80. package/src/components/notification/Notification.tsx +2 -4
  81. package/src/components/popover/Popover.tsx +1 -1
  82. package/src/components/popover/__snapshots__/Popover.test.tsx.snap +10 -10
  83. package/src/components/post-block/PostBlock.tsx +2 -4
  84. package/src/components/progress/Progress.tsx +2 -4
  85. package/src/components/radio-button/RadioButton.tsx +2 -4
  86. package/src/components/select/constants.ts +2 -5
  87. package/src/components/side-navigation/SideNavigation.tsx +2 -4
  88. package/src/components/skeleton/SkeletonCircle.tsx +2 -4
  89. package/src/components/skeleton/SkeletonRectangle.tsx +2 -4
  90. package/src/components/skeleton/SkeletonTypography.tsx +2 -4
  91. package/src/components/slider/Slider.tsx +2 -4
  92. package/src/components/slideshow/Slides.tsx +2 -7
  93. package/src/components/slideshow/SlideshowControls.tsx +2 -4
  94. package/src/components/switch/Switch.tsx +2 -4
  95. package/src/components/table/Table.tsx +2 -4
  96. package/src/components/tabs/TabList.tsx +2 -4
  97. package/src/components/text-field/TextField.tsx +6 -8
  98. package/src/components/thumbnail/Thumbnail.tsx +3 -5
  99. package/src/components/uploader/Uploader.tsx +2 -4
  100. package/src/components/user-block/UserBlock.tsx +2 -4
  101. package/src/hooks/useClickAway.tsx +5 -5
  102. package/src/testing/utils/commonTestsSuite.ts +2 -2
  103. package/src/utils/ClickAwayProvider/ClickAwayProvider.stories.jsx +58 -0
  104. package/src/utils/ClickAwayProvider/ClickAwayProvider.tsx +51 -19
  105. package/src/utils/type.ts +19 -2
  106. package/types.d.ts +105 -139
  107. package/src/components/generic-block/GenericBlock.stories.tsx +0 -149
  108. package/src/components/generic-block/__snapshots__/GenericBlock.test.tsx.snap +0 -92
  109. package/src/utils/ClickAwayProvider/ClickAwayProvider.stories.tsx +0 -75
@@ -1,29 +1,48 @@
1
- import React, { forwardRef, ReactNode } from 'react';
1
+ import React, { Children, forwardRef, ReactElement, ReactNode } from 'react';
2
2
  import classNames from 'classnames';
3
- import { Comp, getRootClassName } from '@lumx/react/utils';
4
- import { Orientation, Size, FlexBox, FlexBoxProps, Alignment, HorizontalAlignment } from '@lumx/react';
3
+ import isEmpty from 'lodash/isEmpty';
4
+ import noop from 'lodash/noop';
5
+ import { Comp, getRootClassName, isComponentType, partitionMulti } from '@lumx/react/utils';
6
+ import { Orientation, Size, FlexBox, FlexBoxProps } from '@lumx/react';
5
7
 
6
8
  export interface GenericBlockProps extends FlexBoxProps {
7
- /** Component to use as visual element. */
9
+ /**
10
+ * Component to use as visual element.
11
+ */
8
12
  figure?: ReactNode;
9
- /** Actions to set after the main content. */
13
+ /**
14
+ * Actions to set after the main content.
15
+ */
10
16
  actions?: ReactNode;
11
- /** Main content to display */
17
+ /**
18
+ * Main content to display or sections components
19
+ * ({@see GenericBlock.Figure}, {@see GenericBlock.Content} & {@see GenericBlock.Actions})
20
+ */
12
21
  children: ReactNode;
13
- /** Orientation of the 3 sections */
22
+ /**
23
+ * Orientation of the 3 sections
24
+ */
14
25
  orientation?: FlexBoxProps['orientation'];
15
- /** Horizontal alignment. */
26
+ /**
27
+ * Horizontal alignment.
28
+ */
16
29
  hAlign?: FlexBoxProps['hAlign'];
17
- /** Vertical alignment. */
30
+ /**
31
+ * Vertical alignment.
32
+ */
18
33
  vAlign?: FlexBoxProps['vAlign'];
19
34
  /**
20
35
  * The props to forward to the content.
21
36
  * By default, the content will have the same alignment as wrapper.
22
37
  */
23
38
  contentProps?: Omit<FlexBoxProps, 'children'>;
24
- /** props to forward to the actions element. */
39
+ /**
40
+ * props to forward to the actions element.
41
+ */
25
42
  actionsProps?: Omit<FlexBoxProps, 'children'>;
26
- /** props to forward to the figure element. */
43
+ /**
44
+ * props to forward to the figure element.
45
+ */
27
46
  figureProps?: Omit<FlexBoxProps, 'children'>;
28
47
  }
29
48
 
@@ -41,24 +60,51 @@ const CLASSNAME = getRootClassName(COMPONENT_NAME);
41
60
  * Component default props.
42
61
  */
43
62
  const DEFAULT_PROPS: Partial<GenericBlockProps> = {
44
- gap: Size.regular,
45
- orientation: Orientation.vertical,
46
- hAlign: Alignment.center,
47
- vAlign: Alignment.center,
63
+ gap: Size.big,
64
+ orientation: Orientation.horizontal,
48
65
  };
49
66
 
67
+ type BaseGenericBlock = Comp<GenericBlockProps, HTMLDivElement>;
68
+
69
+ interface GenericBlock extends BaseGenericBlock {
70
+ /**
71
+ * Use `GenericBlock.Figure` component as children of the `GenericBlock` component as an alternative way to inject
72
+ * the "figure" section of the block (instead of using `figure` and `figureProps` props).
73
+ */
74
+ Figure: Comp<FlexBoxProps>;
75
+ /**
76
+ * Use `GenericBlock.Content` component as children of the `GenericBlock` component as an alternative way to inject
77
+ * the "content" section of the block (instead of using `content` and `contentProps` props).
78
+ */
79
+ Content: Comp<FlexBoxProps>;
80
+ /**
81
+ * Use `GenericBlock.Actions` component as children of the `GenericBlock` component as an alternative way to inject
82
+ * the "actions" section of the block (instead of using `actions` and `actionsProps` props).
83
+ */
84
+ Actions: Comp<FlexBoxProps>;
85
+ }
86
+
87
+ const Figure = noop.bind({}) as Comp<FlexBoxProps>;
88
+ const isFigure = isComponentType(Figure);
89
+
90
+ const Content = noop.bind({}) as Comp<FlexBoxProps>;
91
+ const isContent = isComponentType(Content);
92
+
93
+ const Actions = noop.bind({}) as Comp<FlexBoxProps>;
94
+ const isActions = isComponentType(Actions);
95
+
50
96
  /**
51
97
  * The GenericBlock is a layout component made of 3 sections that can be
52
98
  * displayed either horizontally of vertically with the same gap between each section.
53
99
  *
54
100
  * The sections are:
55
- * * (Optional) `Figure` => A visual element to display before the main content.
56
- * * (Required) `Content` => The main content displayed
57
- * * (Optional) `Actions` => One or more actions to set after the element.
101
+ * - `Figure` => A visual element to display before the main content.
102
+ * - `Content` => The main content displayed
103
+ * - `Actions` => One or more actions to set after the element.
58
104
  *
59
105
  * @see https://www.figma.com/file/lzzrQmsfaXRaOyRfoEogPZ/DS%3A-playground?node-id=1%3A4076
60
106
  */
61
- export const GenericBlock: Comp<GenericBlockProps, HTMLDivElement> = forwardRef((props, ref) => {
107
+ const BaseGenericBlock: BaseGenericBlock = forwardRef((props, ref) => {
62
108
  const {
63
109
  className,
64
110
  figure,
@@ -72,14 +118,22 @@ export const GenericBlock: Comp<GenericBlockProps, HTMLDivElement> = forwardRef(
72
118
  ...forwardedProps
73
119
  } = props;
74
120
 
75
- let actionsVAlign: HorizontalAlignment = Alignment.center;
76
- if (orientation === Orientation.horizontal) {
77
- actionsVAlign = Alignment.right;
78
- }
79
- let contentVAlign: HorizontalAlignment = Alignment.center;
80
- if (orientation === Orientation.horizontal) {
81
- contentVAlign = Alignment.left;
82
- }
121
+ const sections = React.useMemo(() => {
122
+ // Split children by section type
123
+ const [[figureChild], [contentChild], [actionsChild], ...otherChildren] = partitionMulti(
124
+ Children.toArray(children),
125
+ [isFigure, isContent, isActions],
126
+ );
127
+ return {
128
+ figureChild,
129
+ figureChildProps: (figureChild as ReactElement)?.props,
130
+ contentChild,
131
+ contentChildProps: (contentChild as ReactElement)?.props,
132
+ actionsChild,
133
+ actionsChildProps: (actionsChild as ReactElement)?.props,
134
+ otherChildren: otherChildren.filter((child) => !isEmpty(child)),
135
+ };
136
+ }, [children]);
83
137
 
84
138
  return (
85
139
  <FlexBox
@@ -89,32 +143,66 @@ export const GenericBlock: Comp<GenericBlockProps, HTMLDivElement> = forwardRef(
89
143
  orientation={orientation}
90
144
  {...forwardedProps}
91
145
  >
92
- <FlexBox {...figureProps} className={classNames(figureProps?.className, `${CLASSNAME}__figure`)}>
93
- {figure}
94
- </FlexBox>
146
+ {(figure || sections.figureChildProps?.children) && (
147
+ <FlexBox
148
+ ref={(sections.figureChild as any)?.ref}
149
+ vAlign={forwardedProps.vAlign}
150
+ hAlign={forwardedProps.hAlign}
151
+ {...figureProps}
152
+ {...sections.figureChildProps}
153
+ className={classNames(
154
+ figureProps?.className,
155
+ sections.figureChildProps?.className,
156
+ `${CLASSNAME}__figure`,
157
+ )}
158
+ >
159
+ {figure}
160
+ {sections.figureChildProps?.children}
161
+ </FlexBox>
162
+ )}
95
163
 
96
- {children && (
164
+ {(sections.contentChildProps?.children || sections.otherChildren.length > 0) && (
97
165
  <FlexBox
166
+ ref={(sections.contentChild as any)?.ref}
98
167
  orientation={Orientation.vertical}
99
168
  fillSpace
100
- vAlign={contentVAlign}
169
+ vAlign={forwardedProps.vAlign}
170
+ hAlign={forwardedProps.hAlign}
101
171
  {...contentProps}
102
- className={classNames(contentProps?.className, `${CLASSNAME}__content`)}
172
+ {...sections.contentChildProps}
173
+ className={classNames(
174
+ contentProps?.className,
175
+ sections.contentChildProps?.className,
176
+ `${CLASSNAME}__content`,
177
+ )}
103
178
  >
104
- {children}
179
+ {sections.contentChildProps?.children}
180
+ {sections.otherChildren}
105
181
  </FlexBox>
106
182
  )}
107
183
 
108
- <FlexBox
109
- vAlign={actionsVAlign}
110
- {...actionsProps}
111
- className={classNames(actionsProps?.className, `${CLASSNAME}__actions`)}
112
- >
113
- {actions}
114
- </FlexBox>
184
+ {(actions || sections.actionsChildProps?.children) && (
185
+ <FlexBox
186
+ ref={(sections.actionsChild as any)?.ref}
187
+ vAlign={forwardedProps.vAlign}
188
+ hAlign={forwardedProps.hAlign}
189
+ {...actionsProps}
190
+ {...sections.actionsChildProps}
191
+ className={classNames(
192
+ actionsProps?.className,
193
+ sections.actionsChildProps?.className,
194
+ `${CLASSNAME}__actions`,
195
+ )}
196
+ >
197
+ {actions}
198
+ {sections.actionsChildProps?.children}
199
+ </FlexBox>
200
+ )}
115
201
  </FlexBox>
116
202
  );
117
203
  });
118
- GenericBlock.displayName = COMPONENT_NAME;
119
- GenericBlock.className = CLASSNAME;
120
- GenericBlock.defaultProps = DEFAULT_PROPS;
204
+ BaseGenericBlock.displayName = COMPONENT_NAME;
205
+ BaseGenericBlock.className = CLASSNAME;
206
+ BaseGenericBlock.defaultProps = DEFAULT_PROPS;
207
+
208
+ export const GenericBlock: GenericBlock = Object.assign(BaseGenericBlock, { Figure, Content, Actions });
@@ -3,7 +3,7 @@ import React, { forwardRef } from 'react';
3
3
  import classNames from 'classnames';
4
4
 
5
5
  import { Color, ColorPalette, ColorVariant, Size, Theme } from '@lumx/react';
6
- import { Comp, GenericProps, getRootClassName, handleBasicClasses } from '@lumx/react/utils';
6
+ import { Comp, GenericProps, getRootClassName, handleBasicClasses, HasTheme } from '@lumx/react/utils';
7
7
  import { mdiAlertCircle } from '@lumx/icons';
8
8
 
9
9
  export type IconSizes = Extract<Size, 'xxs' | 'xs' | 's' | 'm' | 'l' | 'xl' | 'xxl'>;
@@ -11,7 +11,7 @@ export type IconSizes = Extract<Size, 'xxs' | 'xs' | 's' | 'm' | 'l' | 'xl' | 'x
11
11
  /**
12
12
  * Defines the props of the component.
13
13
  */
14
- export interface IconProps extends GenericProps {
14
+ export interface IconProps extends GenericProps, HasTheme {
15
15
  /** Color variant. */
16
16
  color?: Color;
17
17
  /** Lightened or darkened variant of the selected icon color. */
@@ -25,8 +25,6 @@ export interface IconProps extends GenericProps {
25
25
  icon: string;
26
26
  /** Size variant. */
27
27
  size?: IconSizes;
28
- /** Theme adapting the component to light or dark background. */
29
- theme?: Theme;
30
28
  /** Sets an alternative text on the svg. Will set an `img` role to the svg. */
31
29
  alt?: string;
32
30
  }
@@ -6,7 +6,7 @@ import isObject from 'lodash/isObject';
6
6
 
7
7
  import { Alignment, HorizontalAlignment, Size, Theme, Thumbnail } from '@lumx/react';
8
8
 
9
- import { Comp, GenericProps, getRootClassName, handleBasicClasses, ValueOf } from '@lumx/react/utils';
9
+ import { Comp, GenericProps, getRootClassName, handleBasicClasses, HasTheme, ValueOf } from '@lumx/react/utils';
10
10
  import { ThumbnailProps } from '../thumbnail/Thumbnail';
11
11
 
12
12
  /**
@@ -26,7 +26,7 @@ export type ImageBlockSize = Extract<Size, 'xl' | 'xxl'>;
26
26
  /**
27
27
  * Defines the props of the component.
28
28
  */
29
- export interface ImageBlockProps extends GenericProps {
29
+ export interface ImageBlockProps extends GenericProps, HasTheme {
30
30
  /** Action toolbar content. */
31
31
  actions?: ReactNode;
32
32
  /** Alignment. */
@@ -47,8 +47,6 @@ export interface ImageBlockProps extends GenericProps {
47
47
  size?: ImageBlockSize;
48
48
  /** Tag content. */
49
49
  tags?: ReactNode;
50
- /** Theme adapting the component to light or dark background. */
51
- theme?: Theme;
52
50
  /** Props to pass to the thumbnail (minus those already set by the ImageBlock props). */
53
51
  thumbnailProps?: Omit<ThumbnailProps, 'image' | 'size' | 'theme' | 'align' | 'fillHeight'>;
54
52
  /** Image title to display in the caption. */
@@ -1,5 +1,5 @@
1
1
  import { Kind, Theme } from '@lumx/react';
2
- import { Comp, GenericProps, getRootClassName, handleBasicClasses } from '@lumx/react/utils';
2
+ import { Comp, GenericProps, getRootClassName, handleBasicClasses, HasTheme } from '@lumx/react/utils';
3
3
  import classNames from 'classnames';
4
4
  import React, { forwardRef, ReactNode } from 'react';
5
5
 
@@ -8,13 +8,11 @@ import { INPUT_HELPER_CONFIGURATION } from './constants';
8
8
  /**
9
9
  * Defines the props of the component.
10
10
  */
11
- export interface InputHelperProps extends GenericProps {
11
+ export interface InputHelperProps extends GenericProps, HasTheme {
12
12
  /** Helper content. */
13
13
  children: string | ReactNode;
14
14
  /** Helper variant. */
15
15
  kind?: Kind;
16
- /** Theme adapting the component to light or dark background. */
17
- theme?: Theme;
18
16
  }
19
17
 
20
18
  /**
@@ -1,20 +1,18 @@
1
1
  import { Theme } from '@lumx/react';
2
- import { Comp, GenericProps, getRootClassName, handleBasicClasses } from '@lumx/react/utils';
2
+ import { Comp, GenericProps, getRootClassName, handleBasicClasses, HasTheme } from '@lumx/react/utils';
3
3
  import classNames from 'classnames';
4
4
  import React, { forwardRef, ReactNode } from 'react';
5
5
 
6
6
  /**
7
7
  * Defines the props of the component.
8
8
  */
9
- export interface InputLabelProps extends GenericProps {
9
+ export interface InputLabelProps extends GenericProps, HasTheme {
10
10
  /** Label content. */
11
11
  children: string | ReactNode;
12
12
  /** Native htmlFor property. */
13
13
  htmlFor: string;
14
14
  /** Whether the component is required or not. */
15
15
  isRequired?: boolean;
16
- /** Theme adapting the component to light or dark background. */
17
- theme?: Theme;
18
16
  }
19
17
 
20
18
  /**
@@ -4,9 +4,9 @@ import classNames from 'classnames';
4
4
  import { createPortal } from 'react-dom';
5
5
 
6
6
  import { mdiClose } from '@lumx/icons';
7
- import { ColorPalette, Emphasis, IconButton, IconButtonProps, Theme } from '@lumx/react';
7
+ import { ColorPalette, Emphasis, IconButton, IconButtonProps } from '@lumx/react';
8
8
  import { DOCUMENT } from '@lumx/react/constants';
9
- import { Comp, GenericProps, getRootClassName, handleBasicClasses } from '@lumx/react/utils';
9
+ import { Comp, GenericProps, getRootClassName, handleBasicClasses, HasTheme } from '@lumx/react/utils';
10
10
 
11
11
  import { useFocusTrap } from '@lumx/react/hooks/useFocusTrap';
12
12
  import { useDelayedVisibility } from '@lumx/react/hooks/useDelayedVisibility';
@@ -20,7 +20,7 @@ const LIGHTBOX_TRANSITION_DURATION = 400;
20
20
  /**
21
21
  * Defines the props of the component.
22
22
  */
23
- export interface LightboxProps extends GenericProps {
23
+ export interface LightboxProps extends GenericProps, HasTheme {
24
24
  /** Props to pass to the close button (minus those already set by the Lightbox props). */
25
25
  closeButtonProps?: Pick<IconButtonProps, 'label'> &
26
26
  Omit<IconButtonProps, 'label' | 'onClick' | 'icon' | 'emphasis' | 'color'>;
@@ -30,8 +30,6 @@ export interface LightboxProps extends GenericProps {
30
30
  parentElement: RefObject<any>;
31
31
  /** Whether to keep the dialog open on clickaway or escape press. */
32
32
  preventAutoClose?: boolean;
33
- /** Theme adapting the component to light or dark background. */
34
- theme?: Theme;
35
33
  /** Z-axis position. */
36
34
  zIndex?: number;
37
35
  /** On close callback. */
@@ -143,7 +141,7 @@ export const Lightbox: Comp<LightboxProps, HTMLDivElement> = forwardRef((props,
143
141
  onClick={onClose}
144
142
  />
145
143
  )}
146
- <ClickAwayProvider callback={!preventAutoClose && onClose} refs={clickAwayRefs}>
144
+ <ClickAwayProvider callback={!preventAutoClose && onClose} childrenRefs={clickAwayRefs}>
147
145
  <div ref={childrenRef} className={`${CLASSNAME}__wrapper`} role="presentation">
148
146
  {children}
149
147
  </div>
@@ -26,7 +26,7 @@ exports[`<Lightbox> Snapshots and structure should render story 'Default' 1`] =
26
26
  />
27
27
  <ClickAwayProvider
28
28
  callback={[Function]}
29
- refs={
29
+ childrenRefs={
30
30
  Object {
31
31
  "current": Array [
32
32
  Object {
@@ -14,12 +14,12 @@ import {
14
14
  ThumbnailProps,
15
15
  } from '@lumx/react';
16
16
 
17
- import { Comp, GenericProps, getRootClassName, handleBasicClasses, HeadingElement } from '@lumx/react/utils';
17
+ import { Comp, GenericProps, getRootClassName, handleBasicClasses, HeadingElement, HasTheme } from '@lumx/react/utils';
18
18
 
19
19
  /**
20
20
  * Defines the props of the component.
21
21
  */
22
- export interface LinkPreviewProps extends GenericProps {
22
+ export interface LinkPreviewProps extends GenericProps, HasTheme {
23
23
  /** Description. */
24
24
  description?: string;
25
25
  /** Link URL. */
@@ -30,8 +30,6 @@ export interface LinkPreviewProps extends GenericProps {
30
30
  linkProps?: Omit<LinkProps, 'color' | 'colorVariant' | 'href' | 'target'>;
31
31
  /** Size variant. */
32
32
  size?: Extract<Size, 'regular' | 'big'>;
33
- /** Theme adapting the component to light or dark background. */
34
- theme?: Theme;
35
33
  /** Thumbnail for the link preview. */
36
34
  thumbnailProps?: ThumbnailProps;
37
35
  /** Title. */
@@ -1,16 +1,14 @@
1
1
  import React, { forwardRef, MouseEventHandler, useMemo } from 'react';
2
2
 
3
3
  import { Alignment, AspectRatio, Theme, Thumbnail, ThumbnailProps } from '@lumx/react';
4
- import { Comp, GenericProps, getRootClassName, handleBasicClasses } from '@lumx/react/utils';
4
+ import { Comp, GenericProps, getRootClassName, handleBasicClasses, HasTheme } from '@lumx/react/utils';
5
5
  import classNames from 'classnames';
6
6
  import take from 'lodash/take';
7
7
 
8
8
  /**
9
9
  * Defines the props of the component.
10
10
  */
11
- export interface MosaicProps extends GenericProps {
12
- /** Theme adapting the component to light or dark background. */
13
- theme?: Theme;
11
+ export interface MosaicProps extends GenericProps, HasTheme {
14
12
  /** Thumbnails. */
15
13
  thumbnails: ThumbnailProps[];
16
14
  /** On image click callback. */
@@ -9,22 +9,20 @@ import { Button, Emphasis, Icon, Kind, Size, Theme } from '@lumx/react';
9
9
 
10
10
  import { DOCUMENT, NOTIFICATION_TRANSITION_DURATION } from '@lumx/react/constants';
11
11
  import { NOTIFICATION_CONFIGURATION } from '@lumx/react/components/notification/constants';
12
- import { Comp, GenericProps, getRootClassName, handleBasicClasses } from '@lumx/react/utils';
12
+ import { Comp, GenericProps, getRootClassName, handleBasicClasses, HasTheme } from '@lumx/react/utils';
13
13
 
14
14
  import { useDelayedVisibility } from '@lumx/react/hooks/useDelayedVisibility';
15
15
 
16
16
  /**
17
17
  * Defines the props of the component.
18
18
  */
19
- export interface NotificationProps extends GenericProps {
19
+ export interface NotificationProps extends GenericProps, HasTheme {
20
20
  /** Action button label. */
21
21
  actionLabel?: string;
22
22
  /** Content. */
23
23
  content?: React.ReactNode;
24
24
  /** Whether the component is open or not. */
25
25
  isOpen?: boolean;
26
- /** Theme adapting the component to light or dark background. */
27
- theme?: Theme;
28
26
  /** Notification type. */
29
27
  type?: Kind;
30
28
  /** Z-axis position. */
@@ -342,7 +342,7 @@ export const Popover: Comp<PopoverProps, HTMLDivElement> = forwardRef((props, re
342
342
  style={popoverStyle}
343
343
  {...attributes.popper}
344
344
  >
345
- <ClickAwayProvider callback={closeOnClickAway && handleClose} refs={clickAwayRefs}>
345
+ <ClickAwayProvider callback={closeOnClickAway && handleClose} childrenRefs={clickAwayRefs}>
346
346
  {hasArrow && <div ref={setArrowElement} className={`${CLASSNAME}__arrow`} style={styles.arrow} />}
347
347
  {children}
348
348
  </ClickAwayProvider>
@@ -17,7 +17,7 @@ Array [
17
17
  }
18
18
  >
19
19
  <ClickAwayProvider
20
- refs={
20
+ childrenRefs={
21
21
  Object {
22
22
  "current": Array [
23
23
  Object {
@@ -49,7 +49,7 @@ Array [
49
49
  }
50
50
  >
51
51
  <ClickAwayProvider
52
- refs={
52
+ childrenRefs={
53
53
  Object {
54
54
  "current": Array [
55
55
  Object {
@@ -85,7 +85,7 @@ exports[`<Popover> Snapshots and structure should render story 'Auto' 1`] = `
85
85
  }
86
86
  >
87
87
  <ClickAwayProvider
88
- refs={
88
+ childrenRefs={
89
89
  Object {
90
90
  "current": Array [
91
91
  Object {
@@ -120,7 +120,7 @@ exports[`<Popover> Snapshots and structure should render story 'Default' 1`] = `
120
120
  }
121
121
  >
122
122
  <ClickAwayProvider
123
- refs={
123
+ childrenRefs={
124
124
  Object {
125
125
  "current": Array [
126
126
  Object {
@@ -155,7 +155,7 @@ exports[`<Popover> Snapshots and structure should render story 'MatchingWidth' 1
155
155
  }
156
156
  >
157
157
  <ClickAwayProvider
158
- refs={
158
+ childrenRefs={
159
159
  Object {
160
160
  "current": Array [
161
161
  Object {
@@ -190,7 +190,7 @@ exports[`<Popover> Snapshots and structure should render story 'Offset' 1`] = `
190
190
  }
191
191
  >
192
192
  <ClickAwayProvider
193
- refs={
193
+ childrenRefs={
194
194
  Object {
195
195
  "current": Array [
196
196
  Object {
@@ -226,7 +226,7 @@ Array [
226
226
  }
227
227
  >
228
228
  <ClickAwayProvider
229
- refs={
229
+ childrenRefs={
230
230
  Object {
231
231
  "current": Array [
232
232
  Object {
@@ -258,7 +258,7 @@ Array [
258
258
  }
259
259
  >
260
260
  <ClickAwayProvider
261
- refs={
261
+ childrenRefs={
262
262
  Object {
263
263
  "current": Array [
264
264
  Object {
@@ -290,7 +290,7 @@ Array [
290
290
  }
291
291
  >
292
292
  <ClickAwayProvider
293
- refs={
293
+ childrenRefs={
294
294
  Object {
295
295
  "current": Array [
296
296
  Object {
@@ -322,7 +322,7 @@ Array [
322
322
  }
323
323
  >
324
324
  <ClickAwayProvider
325
- refs={
325
+ childrenRefs={
326
326
  Object {
327
327
  "current": Array [
328
328
  Object {
@@ -6,12 +6,12 @@ import isObject from 'lodash/isObject';
6
6
 
7
7
  import { Orientation, Theme, Thumbnail, ThumbnailProps, ThumbnailVariant } from '@lumx/react';
8
8
 
9
- import { Comp, GenericProps, getRootClassName, handleBasicClasses } from '@lumx/react/utils';
9
+ import { Comp, GenericProps, getRootClassName, handleBasicClasses, HasTheme } from '@lumx/react/utils';
10
10
 
11
11
  /**
12
12
  * Defines the props of the component.
13
13
  */
14
- export interface PostBlockProps extends GenericProps {
14
+ export interface PostBlockProps extends GenericProps, HasTheme {
15
15
  /** Action toolbar content. */
16
16
  actions?: ReactNode;
17
17
  /** Attachment content. */
@@ -26,8 +26,6 @@ export interface PostBlockProps extends GenericProps {
26
26
  tags?: ReactNode;
27
27
  /** Content (string, or sanitized html). */
28
28
  text?: string | { __html: string };
29
- /** Theme adapting the component to light or dark background. */
30
- theme?: Theme;
31
29
  /** Thumbnail. */
32
30
  thumbnailProps?: ThumbnailProps;
33
31
  /** Title. */
@@ -4,7 +4,7 @@ import classNames from 'classnames';
4
4
 
5
5
  import { Theme } from '@lumx/react';
6
6
 
7
- import { Comp, GenericProps, getRootClassName, handleBasicClasses, ValueOf } from '@lumx/react/utils';
7
+ import { Comp, GenericProps, getRootClassName, handleBasicClasses, HasTheme, ValueOf } from '@lumx/react/utils';
8
8
 
9
9
  /**
10
10
  * Progress variants.
@@ -15,9 +15,7 @@ export type ProgressVariant = ValueOf<typeof ProgressVariant>;
15
15
  /**
16
16
  * Defines the props of the component.
17
17
  */
18
- export interface ProgressProps extends GenericProps {
19
- /** Theme adapting the component to light or dark background. */
20
- theme?: Theme;
18
+ export interface ProgressProps extends GenericProps, HasTheme {
21
19
  /** Progress variant. */
22
20
  variant?: ProgressVariant;
23
21
  }
@@ -5,12 +5,12 @@ import { uid } from 'uid';
5
5
 
6
6
  import { InputHelper, InputLabel, Theme } from '@lumx/react';
7
7
 
8
- import { Comp, GenericProps, getRootClassName, handleBasicClasses } from '@lumx/react/utils';
8
+ import { Comp, GenericProps, getRootClassName, handleBasicClasses, HasTheme } from '@lumx/react/utils';
9
9
 
10
10
  /**
11
11
  * Defines the props of the component.
12
12
  */
13
- export interface RadioButtonProps extends GenericProps {
13
+ export interface RadioButtonProps extends GenericProps, HasTheme {
14
14
  /** Helper text. */
15
15
  helper?: string;
16
16
  /** Native input id property. */
@@ -25,8 +25,6 @@ export interface RadioButtonProps extends GenericProps {
25
25
  label?: ReactNode;
26
26
  /** Native input name property. */
27
27
  name?: string;
28
- /** Theme adapting the component to light or dark background. */
29
- theme?: Theme;
30
28
  /** Native input value property. */
31
29
  value?: string;
32
30
  /** On change callback. */
@@ -1,6 +1,5 @@
1
1
  import { IconButtonProps } from '@lumx/react';
2
- import { Theme } from '@lumx/react/components';
3
- import { GenericProps, ValueOf } from '@lumx/react/utils';
2
+ import { GenericProps, HasTheme, ValueOf } from '@lumx/react/utils';
4
3
  import { ReactNode, SyntheticEvent } from 'react';
5
4
 
6
5
  /**
@@ -9,7 +8,7 @@ import { ReactNode, SyntheticEvent } from 'react';
9
8
  export const SelectVariant = { input: 'input', chip: 'chip' } as const;
10
9
  export type SelectVariant = ValueOf<typeof SelectVariant>;
11
10
 
12
- export interface CoreSelectProps extends GenericProps {
11
+ export interface CoreSelectProps extends GenericProps, HasTheme {
13
12
  /** Props to pass to the clear button (minus those already set by the Select props). If not specified, the button won't be displayed. */
14
13
  clearButtonProps?: Pick<IconButtonProps, 'label'> &
15
14
  Omit<IconButtonProps, 'label' | 'onClick' | 'icon' | 'emphasis'>;
@@ -35,8 +34,6 @@ export interface CoreSelectProps extends GenericProps {
35
34
  label?: string;
36
35
  /** Placeholder input text. */
37
36
  placeholder?: string;
38
- /** Theme adapting the component to light or dark background. */
39
- theme?: Theme;
40
37
  /** Select variant. */
41
38
  variant?: SelectVariant;
42
39
  /** On clear callback. */