@lumx/react 3.10.1-alpha.7 → 3.11.0

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 (167) hide show
  1. package/index.d.ts +86 -12
  2. package/index.js +318 -304
  3. package/index.js.map +1 -1
  4. package/package.json +3 -3
  5. package/src/components/alert-dialog/AlertDialog.tsx +6 -3
  6. package/src/components/autocomplete/Autocomplete.stories.tsx +1 -2
  7. package/src/components/autocomplete/Autocomplete.tsx +3 -3
  8. package/src/components/autocomplete/AutocompleteMultiple.stories.tsx +2 -5
  9. package/src/components/autocomplete/AutocompleteMultiple.tsx +2 -2
  10. package/src/components/avatar/Avatar.tsx +3 -3
  11. package/src/components/badge/Badge.tsx +3 -3
  12. package/src/components/badge/BadgeWrapper.tsx +3 -2
  13. package/src/components/button/Button.tsx +9 -8
  14. package/src/components/button/ButtonGroup.tsx +9 -3
  15. package/src/components/button/ButtonRoot.tsx +6 -2
  16. package/src/components/button/IconButton.tsx +2 -2
  17. package/src/components/checkbox/Checkbox.tsx +4 -4
  18. package/src/components/chip/Chip.tsx +15 -9
  19. package/src/components/chip/ChipGroup.tsx +3 -2
  20. package/src/components/comment-block/CommentBlock.stories.tsx +4 -7
  21. package/src/components/comment-block/CommentBlock.tsx +3 -3
  22. package/src/components/date-picker/constants.ts +2 -2
  23. package/src/components/dialog/Dialog.tsx +9 -7
  24. package/src/components/divider/Divider.tsx +3 -3
  25. package/src/components/drag-handle/DragHandle.tsx +3 -3
  26. package/src/components/dropdown/Dropdown.tsx +4 -3
  27. package/src/components/expansion-panel/ExpansionPanel.tsx +26 -20
  28. package/src/components/flag/Flag.tsx +3 -3
  29. package/src/components/flex-box/FlexBox.tsx +4 -4
  30. package/src/components/generic-block/GenericBlock.tsx +10 -8
  31. package/src/components/generic-block/constants.ts +4 -9
  32. package/src/components/grid/Grid.tsx +5 -3
  33. package/src/components/grid/GridItem.tsx +5 -3
  34. package/src/components/grid-column/GridColumn.tsx +5 -3
  35. package/src/components/heading/Heading.tsx +7 -2
  36. package/src/components/icon/Icon.tsx +3 -3
  37. package/src/components/image-block/ImageBlock.tsx +3 -3
  38. package/src/components/image-lightbox/ImageLightbox.tsx +1 -1
  39. package/src/components/image-lightbox/constants.ts +2 -2
  40. package/src/components/image-lightbox/internal/ImageSlide.tsx +1 -1
  41. package/src/components/image-lightbox/internal/ImageSlideshow.tsx +9 -5
  42. package/src/components/image-lightbox/useImageLightbox.tsx +2 -1
  43. package/src/components/inline-list/InlineList.tsx +7 -3
  44. package/src/components/input-helper/InputHelper.tsx +3 -3
  45. package/src/components/input-label/InputLabel.tsx +3 -3
  46. package/src/components/lightbox/Lightbox.tsx +6 -4
  47. package/src/components/link/Link.tsx +11 -7
  48. package/src/components/link-preview/LinkPreview.tsx +3 -3
  49. package/src/components/list/List.tsx +4 -4
  50. package/src/components/list/ListDivider.tsx +3 -2
  51. package/src/components/list/ListItem.tsx +6 -5
  52. package/src/components/list/ListSubheader.tsx +3 -2
  53. package/src/components/list/useInteractiveList.tsx +7 -6
  54. package/src/components/message/Message.tsx +3 -3
  55. package/src/components/mosaic/Mosaic.test.tsx +3 -3
  56. package/src/components/mosaic/Mosaic.tsx +6 -5
  57. package/src/components/navigation/Navigation.stories.tsx +2 -2
  58. package/src/components/navigation/Navigation.tsx +3 -3
  59. package/src/components/navigation/NavigationItem.tsx +3 -9
  60. package/src/components/navigation/NavigationSection.tsx +3 -3
  61. package/src/components/notification/Notification.tsx +9 -5
  62. package/src/components/popover/Popover.stories.tsx +13 -15
  63. package/src/components/popover/Popover.test.tsx +6 -1
  64. package/src/components/popover/Popover.tsx +6 -6
  65. package/src/components/popover/usePopoverStyle.tsx +1 -3
  66. package/src/components/popover/useRestoreFocusOnClose.tsx +1 -1
  67. package/src/components/popover-dialog/PopoverDialog.tsx +3 -2
  68. package/src/components/post-block/PostBlock.tsx +11 -7
  69. package/src/components/progress/Progress.tsx +3 -3
  70. package/src/components/progress/ProgressCircular.tsx +3 -3
  71. package/src/components/progress/ProgressLinear.tsx +3 -3
  72. package/src/components/progress-tracker/ProgressTracker.stories.tsx +11 -11
  73. package/src/components/progress-tracker/ProgressTracker.tsx +4 -3
  74. package/src/components/progress-tracker/ProgressTrackerStep.tsx +3 -3
  75. package/src/components/progress-tracker/ProgressTrackerStepPanel.tsx +2 -0
  76. package/src/components/radio-button/RadioButton.tsx +3 -3
  77. package/src/components/radio-button/RadioGroup.stories.tsx +1 -4
  78. package/src/components/radio-button/RadioGroup.tsx +3 -2
  79. package/src/components/select/Select.stories.tsx +19 -38
  80. package/src/components/select/Select.tsx +5 -5
  81. package/src/components/select/SelectMultiple.stories.tsx +15 -30
  82. package/src/components/select/SelectMultiple.tsx +3 -4
  83. package/src/components/select/WithSelectContext.tsx +3 -4
  84. package/src/components/select/constants.ts +3 -1
  85. package/src/components/side-navigation/SideNavigation.stories.tsx +1 -1
  86. package/src/components/side-navigation/SideNavigation.tsx +4 -3
  87. package/src/components/side-navigation/SideNavigationItem.tsx +7 -7
  88. package/src/components/skeleton/SkeletonCircle.tsx +3 -3
  89. package/src/components/skeleton/SkeletonRectangle.tsx +3 -3
  90. package/src/components/skeleton/SkeletonTypography.stories.tsx +7 -12
  91. package/src/components/skeleton/SkeletonTypography.tsx +3 -3
  92. package/src/components/slider/Slider.tsx +4 -4
  93. package/src/components/slider/index.ts +1 -1
  94. package/src/components/slideshow/Slides.tsx +6 -4
  95. package/src/components/slideshow/Slideshow.stories.tsx +1 -3
  96. package/src/components/slideshow/Slideshow.tsx +3 -1
  97. package/src/components/slideshow/SlideshowControls.stories.tsx +1 -4
  98. package/src/components/slideshow/SlideshowControls.tsx +4 -4
  99. package/src/components/slideshow/SlideshowItem.tsx +5 -2
  100. package/src/components/slideshow/SlideshowItemGroup.tsx +5 -3
  101. package/src/components/switch/Switch.test.tsx +1 -1
  102. package/src/components/switch/Switch.tsx +7 -4
  103. package/src/components/table/Table.tsx +5 -3
  104. package/src/components/table/TableBody.tsx +7 -3
  105. package/src/components/table/TableCell.tsx +5 -3
  106. package/src/components/table/TableHeader.tsx +7 -3
  107. package/src/components/table/TableRow.tsx +5 -3
  108. package/src/components/tabs/TabList.tsx +1 -1
  109. package/src/components/tabs/TabPanel.tsx +2 -0
  110. package/src/components/tabs/Tabs.stories.tsx +12 -11
  111. package/src/components/text/Text.tsx +14 -5
  112. package/src/components/text-field/TextField.test.tsx +2 -2
  113. package/src/components/text-field/TextField.tsx +8 -7
  114. package/src/components/thumbnail/Thumbnail.tsx +4 -4
  115. package/src/components/toolbar/Toolbar.tsx +3 -3
  116. package/src/components/tooltip/Tooltip.tsx +4 -4
  117. package/src/components/tooltip/context.tsx +1 -1
  118. package/src/components/tooltip/useInjectTooltipRef.tsx +1 -1
  119. package/src/components/uploader/Uploader.tsx +3 -3
  120. package/src/components/user-block/UserBlock.tsx +12 -10
  121. package/src/hooks/useCallbackOnEscape.ts +1 -1
  122. package/src/hooks/useClickAway.tsx +2 -1
  123. package/src/hooks/useFocusTrap.ts +1 -1
  124. package/src/hooks/useInterval.tsx +4 -1
  125. package/src/hooks/useKeyboardListNavigation.tsx +4 -2
  126. package/src/hooks/useSizeOnWindowResize.ts +10 -14
  127. package/src/hooks/useStopPropagation.ts +2 -1
  128. package/src/stories/decorators/withCombinations.tsx +1 -1
  129. package/src/testing/utils/commonTestsSuiteRTL.tsx +2 -2
  130. package/src/utils/ClickAwayProvider/ClickAwayProvider.tsx +4 -0
  131. package/src/utils/className/getRootClassName.test.ts +11 -0
  132. package/src/utils/className/getRootClassName.ts +24 -0
  133. package/src/utils/className/index.ts +1 -0
  134. package/src/utils/date/getMonthCalendar.ts +4 -3
  135. package/src/utils/{makeListenerTowerContext.ts → function/makeListenerTowerContext.ts} +2 -2
  136. package/src/utils/{collection/partitionMulti.ts → partitionMulti.ts} +12 -13
  137. package/src/utils/{flattenChildren.ts → react/flattenChildren.ts} +3 -2
  138. package/src/utils/{renderButtonOrLink.tsx → react/renderButtonOrLink.tsx} +1 -1
  139. package/src/utils/{skipRender.tsx → react/skipRender.tsx} +1 -1
  140. package/src/utils/type/index.ts +18 -18
  141. package/src/utils/type/isComponent.ts +33 -0
  142. package/utils/index.d.ts +4 -0
  143. package/utils/index.js +96 -1
  144. package/utils/index.js.map +1 -1
  145. package/_internal/index.js +0 -99
  146. package/_internal/index.js.map +0 -1
  147. package/src/utils/className.test.js +0 -41
  148. package/src/utils/collection/castArray.test.ts +0 -15
  149. package/src/utils/collection/castArray.ts +0 -3
  150. package/src/utils/collection/chunk.test.ts +0 -15
  151. package/src/utils/collection/chunk.ts +0 -6
  152. package/src/utils/collection/isEmpty.test.js +0 -20
  153. package/src/utils/collection/isEmpty.ts +0 -4
  154. package/src/utils/collection/last.ts +0 -2
  155. package/src/utils/collection/partitionMulti.test.ts +0 -35
  156. package/src/utils/collection/pull.test.ts +0 -17
  157. package/src/utils/collection/pull.ts +0 -7
  158. package/src/utils/collection/range.test.js +0 -9
  159. package/src/utils/collection/range.ts +0 -2
  160. package/src/utils/function/memoize.test.ts +0 -36
  161. package/src/utils/function/memoize.ts +0 -13
  162. package/src/utils/type/ComponentClassName.ts +0 -7
  163. package/src/utils/type/KebabCase.ts +0 -6
  164. /package/src/utils/{clamp.ts → number/clamp.ts} +0 -0
  165. /package/src/utils/{OnBeforeUnmount.tsx → react/OnBeforeUnmount.tsx} +0 -0
  166. /package/src/utils/{mergeRefs.ts → react/mergeRefs.ts} +0 -0
  167. /package/src/utils/{renderLink.tsx → react/renderLink.tsx} +0 -0
@@ -4,9 +4,9 @@ import classNames from 'classnames';
4
4
 
5
5
  import { Size } from '@lumx/react';
6
6
  import { useKeyboardListNavigation } from '@lumx/react/hooks/useKeyboardListNavigation';
7
- import type { GenericProps, ComponentClassName } from '@lumx/react/utils/type';
8
- import { handleBasicClasses } from '@lumx/react/utils/className';
9
- import { mergeRefs } from '@lumx/react/utils/mergeRefs';
7
+ import { GenericProps } from '@lumx/react/utils/type';
8
+ import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
9
+ import { mergeRefs } from '@lumx/react/utils/react/mergeRefs';
10
10
  import { forwardRef } from '@lumx/react/utils/react/forwardRef';
11
11
 
12
12
  import { useInteractiveList } from './useInteractiveList';
@@ -44,7 +44,7 @@ const COMPONENT_NAME = 'List';
44
44
  /**
45
45
  * Component default class name and class prefix.
46
46
  */
47
- const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-list';
47
+ const CLASSNAME = getRootClassName(COMPONENT_NAME);
48
48
 
49
49
  /**
50
50
  * Component default props.
@@ -2,7 +2,8 @@ import React from 'react';
2
2
 
3
3
  import classNames from 'classnames';
4
4
 
5
- import type { GenericProps, ComponentClassName } from '@lumx/react/utils/type';
5
+ import { GenericProps } from '@lumx/react/utils/type';
6
+ import { getRootClassName } from '@lumx/react/utils/className';
6
7
  import { forwardRef } from '@lumx/react/utils/react/forwardRef';
7
8
 
8
9
  /**
@@ -18,7 +19,7 @@ const COMPONENT_NAME = 'ListDivider';
18
19
  /**
19
20
  * Component default class name and class prefix.
20
21
  */
21
- const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-list-divider';
22
+ const CLASSNAME = getRootClassName(COMPONENT_NAME);
22
23
 
23
24
  /**
24
25
  * ListDivider component.
@@ -1,12 +1,13 @@
1
1
  import React, { ReactNode, Ref, SyntheticEvent, useMemo } from 'react';
2
2
 
3
3
  import classNames from 'classnames';
4
+ import isEmpty from 'lodash/isEmpty';
4
5
 
5
6
  import { ListProps, Size } from '@lumx/react';
6
- import type { GenericProps, ComponentClassName } from '@lumx/react/utils/type';
7
+ import { GenericProps } from '@lumx/react/utils/type';
7
8
  import { onEnterPressed, onButtonPressed } from '@lumx/react/utils/browser/event';
8
- import { handleBasicClasses } from '@lumx/react/utils/className';
9
- import { renderLink } from '@lumx/react/utils/renderLink';
9
+ import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
10
+ import { renderLink } from '@lumx/react/utils/react/renderLink';
10
11
  import { forwardRef } from '@lumx/react/utils/react/forwardRef';
11
12
 
12
13
  export type ListItemSize = Extract<Size, 'tiny' | 'regular' | 'big' | 'huge'>;
@@ -50,7 +51,7 @@ const COMPONENT_NAME = 'ListItem';
50
51
  /**
51
52
  * Component default class name and class prefix.
52
53
  */
53
- const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-list-item';
54
+ const CLASSNAME = getRootClassName(COMPONENT_NAME);
54
55
 
55
56
  /**
56
57
  * Component default props.
@@ -64,7 +65,7 @@ const DEFAULT_PROPS: Partial<ListProps> = {
64
65
  * @return `true` if the list item is clickable; `false` otherwise.
65
66
  */
66
67
  export function isClickable({ linkProps, onItemSelected }: Partial<ListItemProps>): boolean {
67
- return !!linkProps?.href || !!onItemSelected;
68
+ return !isEmpty(linkProps?.href) || !!onItemSelected;
68
69
  }
69
70
 
70
71
  /**
@@ -2,7 +2,8 @@ import React, { ReactNode } from 'react';
2
2
 
3
3
  import classNames from 'classnames';
4
4
 
5
- import type { GenericProps, ComponentClassName } from '@lumx/react/utils/type';
5
+ import { GenericProps } from '@lumx/react/utils/type';
6
+ import { getRootClassName } from '@lumx/react/utils/className';
6
7
  import { forwardRef } from '@lumx/react/utils/react/forwardRef';
7
8
 
8
9
  /**
@@ -21,7 +22,7 @@ const COMPONENT_NAME = 'ListSubheader';
21
22
  /**
22
23
  * Component default class name and class prefix.
23
24
  */
24
- const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-list-subheader';
25
+ const CLASSNAME = getRootClassName(COMPONENT_NAME);
25
26
 
26
27
  /**
27
28
  * ListSubheader component.
@@ -1,9 +1,10 @@
1
- import { ListItem, ListItemProps } from '@lumx/react';
1
+ import { ListItemProps } from '@lumx/react';
2
2
  import { isClickable } from '@lumx/react/components/list/ListItem';
3
3
 
4
- import { isComponentType } from '@lumx/react/utils/type';
5
- import { flattenChildren } from '@lumx/react/utils/flattenChildren';
6
- import { mergeRefs } from '@lumx/react/utils/mergeRefs';
4
+ import { isComponent } from '@lumx/react/utils/type';
5
+ import { flattenChildren } from '@lumx/react/utils/react/flattenChildren';
6
+ import { mergeRefs } from '@lumx/react/utils/react/mergeRefs';
7
+ import get from 'lodash/get';
7
8
  import {
8
9
  cloneElement,
9
10
  Key,
@@ -74,7 +75,7 @@ function onKeyboardFocus(props: any, handler: (evt: FocusEvent) => void) {
74
75
  }
75
76
 
76
77
  const isNavigableItem = (node: ReactNode): node is ReactElement => {
77
- return isComponentType(ListItem)(node) && isClickable(node.props) && !node.props.isDisabled;
78
+ return isComponent('ListItem')(node) && isClickable(node.props) && !node.props.isDisabled;
78
79
  };
79
80
 
80
81
  /**
@@ -146,7 +147,7 @@ export const useInteractiveList: useInteractiveList = (options) => {
146
147
  setActiveItemIndex(nextIndex);
147
148
  evt.preventDefault();
148
149
  evt.stopPropagation();
149
- onListItemNavigated?.(nextIndex, (items[nextIndex] as ReactElement)?.key);
150
+ onListItemNavigated?.(nextIndex, get(items, [nextIndex, 'key']));
150
151
  };
151
152
 
152
153
  /**
@@ -4,8 +4,8 @@ import classNames from 'classnames';
4
4
 
5
5
  import { mdiAlert, mdiAlertCircle, mdiCheckCircle, mdiClose, mdiInformation } from '@lumx/icons';
6
6
  import { ColorPalette, Emphasis, Icon, IconButton, Kind, Size } from '@lumx/react';
7
- import type { GenericProps, ComponentClassName } from '@lumx/react/utils/type';
8
- import { handleBasicClasses } from '@lumx/react/utils/className';
7
+ import { GenericProps } from '@lumx/react/utils/type';
8
+ import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
9
9
  import { forwardRef } from '@lumx/react/utils/react/forwardRef';
10
10
 
11
11
  /**
@@ -41,7 +41,7 @@ const COMPONENT_NAME = 'Message';
41
41
  /**
42
42
  * Component default class name and class prefix.
43
43
  */
44
- const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-message';
44
+ const CLASSNAME = getRootClassName(COMPONENT_NAME);
45
45
 
46
46
  /**
47
47
  * Associative map from message kind to color and icon.
@@ -5,8 +5,8 @@ import { render, screen, within } from '@testing-library/react';
5
5
  import { getByClassName, queryAllByClassName, queryByClassName } from '@lumx/react/testing/utils/queries';
6
6
  import { Thumbnail } from '@lumx/react';
7
7
  import { commonTestsSuiteRTL, SetupRenderOptions } from '@lumx/react/testing/utils';
8
+ import range from 'lodash/range';
8
9
  import userEvent from '@testing-library/user-event';
9
- import { range } from '@lumx/react/utils/collection/range';
10
10
 
11
11
  const CLASSNAME = Mosaic.className as string;
12
12
 
@@ -19,8 +19,8 @@ const setup = (props: Partial<MosaicProps> = {}, { wrapper }: SetupRenderOptions
19
19
  };
20
20
 
21
21
  const generateThumbnails = (count: number) =>
22
- range(count).map((i) => ({
23
- image: `https://example.com/image${i + 1}.png`,
22
+ range(1, count + 1).map((i) => ({
23
+ image: `https://example.com/image${i}.png`,
24
24
  alt: '',
25
25
  }));
26
26
 
@@ -1,11 +1,12 @@
1
1
  import React, { MouseEventHandler, useMemo } from 'react';
2
2
 
3
3
  import classNames from 'classnames';
4
-
4
+ import take from 'lodash/take';
5
5
  import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
6
+
6
7
  import { Alignment, AspectRatio, Theme, Thumbnail, ThumbnailProps } from '@lumx/react';
7
- import type { GenericProps, HasTheme, ComponentClassName } from '@lumx/react/utils/type';
8
- import { handleBasicClasses } from '@lumx/react/utils/className';
8
+ import { GenericProps, HasTheme } from '@lumx/react/utils/type';
9
+ import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
9
10
  import { forwardRef } from '@lumx/react/utils/react/forwardRef';
10
11
 
11
12
  /**
@@ -26,7 +27,7 @@ const COMPONENT_NAME = 'Mosaic';
26
27
  /**
27
28
  * Component default class name and class prefix.
28
29
  */
29
- const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-mosaic';
30
+ const CLASSNAME = getRootClassName(COMPONENT_NAME);
30
31
 
31
32
  /**
32
33
  * Component default props.
@@ -65,7 +66,7 @@ export const Mosaic = forwardRef<MosaicProps, HTMLDivElement>((props, ref) => {
65
66
  })}
66
67
  >
67
68
  <div className={`${CLASSNAME}__wrapper`}>
68
- {thumbnails.slice(-4).map((thumbnail: any, index: number) => {
69
+ {take(thumbnails, 4).map((thumbnail: any, index: number) => {
69
70
  const { image, onClick, align, ...thumbnailProps } = thumbnail;
70
71
 
71
72
  return (
@@ -32,9 +32,9 @@ export default {
32
32
  * Demonstrate a full-featured navigation
33
33
  */
34
34
  export const FullFeatured = {
35
- render({ theme, itemProps, orientation }: any) {
35
+ render({ itemProps, orientation }: any) {
36
36
  return (
37
- <Navigation theme={theme} aria-label="navigation" orientation={orientation}>
37
+ <Navigation aria-label="navigation" orientation={orientation}>
38
38
  <Navigation.Item isCurrentPage label="Homepage" icon={mdiHome} href="#" {...itemProps} />
39
39
  <Navigation.Item
40
40
  label="Some very very very very very very very very very very very very very very very very very very very very very very very very very very very long text"
@@ -2,8 +2,8 @@ import React from 'react';
2
2
 
3
3
  import classNames from 'classnames';
4
4
 
5
- import type { HasAriaLabelOrLabelledBy, HasClassName, HasTheme, ComponentClassName } from '@lumx/react/utils/type';
6
- import { handleBasicClasses } from '@lumx/react/utils/className';
5
+ import { HasAriaLabelOrLabelledBy, HasClassName, HasTheme } from '@lumx/react/utils/type';
6
+ import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
7
7
  import { Orientation, Theme } from '@lumx/react';
8
8
  import { ThemeProvider, useTheme } from '@lumx/react/utils/theme/ThemeContext';
9
9
  import { forwardRef } from '@lumx/react/utils/react/forwardRef';
@@ -28,7 +28,7 @@ const COMPONENT_NAME = 'Navigation';
28
28
  /**
29
29
  * Component default class name and class prefix.
30
30
  */
31
- const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-navigation';
31
+ const CLASSNAME = getRootClassName(COMPONENT_NAME);
32
32
 
33
33
  /**
34
34
  * Component default props
@@ -1,13 +1,7 @@
1
1
  import React, { ElementType, ReactNode } from 'react';
2
2
  import { Icon, Placement, Size, Tooltip, Text } from '@lumx/react';
3
- import { handleBasicClasses } from '@lumx/react/utils/className';
4
- import type {
5
- ComponentRef,
6
- HasClassName,
7
- HasPolymorphicAs,
8
- HasTheme,
9
- ComponentClassName,
10
- } from '@lumx/react/utils/type';
3
+ import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
4
+ import { ComponentRef, HasClassName, HasPolymorphicAs, HasTheme } from '@lumx/react/utils/type';
11
5
  import classNames from 'classnames';
12
6
  import { forwardRefPolymorphic } from '@lumx/react/utils/react/forwardRefPolymorphic';
13
7
  import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
@@ -42,7 +36,7 @@ const COMPONENT_NAME = 'NavigationItem';
42
36
  /**
43
37
  * Component default class name and class prefix.
44
38
  */
45
- export const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-navigation-item';
39
+ export const CLASSNAME = getRootClassName(COMPONENT_NAME);
46
40
 
47
41
  export const NavigationItem = Object.assign(
48
42
  forwardRefPolymorphic(<E extends ElementType = 'a'>(props: NavigationItemProps<E>, ref: ComponentRef<E>) => {
@@ -3,8 +3,8 @@ import React, { useRef, useState, useContext } from 'react';
3
3
  import { mdiChevronDown, mdiChevronUp } from '@lumx/icons';
4
4
  import { Icon, Size, Text, Orientation, Popover, Placement, Theme } from '@lumx/react';
5
5
  import classNames from 'classnames';
6
- import { handleBasicClasses } from '@lumx/react/utils/className';
7
- import type { HasClassName, ComponentClassName } from '@lumx/react/utils/type';
6
+ import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
7
+ import { HasClassName } from '@lumx/react/utils/type';
8
8
  import { ThemeProvider, useTheme } from '@lumx/react/utils/theme/ThemeContext';
9
9
  import { useId } from '@lumx/react/hooks/useId';
10
10
  import { forwardRef } from '@lumx/react/utils/react/forwardRef';
@@ -29,7 +29,7 @@ const COMPONENT_NAME = 'NavigationSection';
29
29
  /**
30
30
  * Component default class name and class prefix.
31
31
  */
32
- const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-navigation-section';
32
+ const CLASSNAME = getRootClassName(COMPONENT_NAME);
33
33
 
34
34
  export const NavigationSection = forwardRef<NavigationSectionProps, HTMLLIElement>((props, ref) => {
35
35
  const { children, className, label, icon, ...forwardedProps } = props;
@@ -2,13 +2,15 @@ import React, { useRef } from 'react';
2
2
  import { createPortal } from 'react-dom';
3
3
 
4
4
  import classNames from 'classnames';
5
+ import isFunction from 'lodash/isFunction';
6
+
5
7
  import { Button, Emphasis, Icon, Kind, Size, Theme } from '@lumx/react';
6
8
  import { DOCUMENT, NOTIFICATION_TRANSITION_DURATION } from '@lumx/react/constants';
7
9
  import { NOTIFICATION_CONFIGURATION } from '@lumx/react/components/notification/constants';
8
- import type { GenericProps, HasTheme, ComponentClassName } from '@lumx/react/utils/type';
9
- import { handleBasicClasses } from '@lumx/react/utils/className';
10
+ import { GenericProps, HasTheme } from '@lumx/react/utils/type';
11
+ import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
10
12
  import { useTransitionVisibility } from '@lumx/react/hooks/useTransitionVisibility';
11
- import { mergeRefs } from '@lumx/react/utils/mergeRefs';
13
+ import { mergeRefs } from '@lumx/react/utils/react/mergeRefs';
12
14
  import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
13
15
  import { forwardRef } from '@lumx/react/utils/react/forwardRef';
14
16
 
@@ -42,7 +44,7 @@ const COMPONENT_NAME = 'Notification';
42
44
  /**
43
45
  * Component default class name and class prefix.
44
46
  */
45
- const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-notification';
47
+ const CLASSNAME = getRootClassName(COMPONENT_NAME);
46
48
 
47
49
  /**
48
50
  * Component default props.
@@ -86,7 +88,9 @@ export const Notification = forwardRef<NotificationProps, HTMLDivElement>((props
86
88
  const hasAction: boolean = Boolean(onActionClick) && Boolean(actionLabel);
87
89
 
88
90
  const handleCallback = (evt: React.MouseEvent) => {
89
- onActionClick?.();
91
+ if (isFunction(onActionClick)) {
92
+ onActionClick();
93
+ }
90
94
  evt.stopPropagation();
91
95
  };
92
96
 
@@ -110,7 +110,7 @@ export const Placements = {
110
110
  ],
111
111
  };
112
112
 
113
- export const WithUpdatingChildren = ({ theme }: any) => {
113
+ export const WithUpdatingChildren = () => {
114
114
  const anchorRef = useRef(null);
115
115
  const [isOpen, setIsOpen] = useState(false);
116
116
 
@@ -142,7 +142,6 @@ export const WithUpdatingChildren = ({ theme }: any) => {
142
142
  <Popover
143
143
  closeOnClickAway
144
144
  closeOnEscape
145
- theme={theme}
146
145
  isOpen={isOpen}
147
146
  anchorRef={anchorRef}
148
147
  placement={Placement.BOTTOM_END}
@@ -159,7 +158,7 @@ export const WithUpdatingChildren = ({ theme }: any) => {
159
158
  );
160
159
  };
161
160
 
162
- export const WithScrollingPopover = ({ theme }: any) => {
161
+ export const WithScrollingPopover = () => {
163
162
  const anchorRef = useRef(null);
164
163
  const [isOpen, setIsOpen] = useState(false);
165
164
 
@@ -179,7 +178,6 @@ export const WithScrollingPopover = ({ theme }: any) => {
179
178
  <Popover
180
179
  closeOnClickAway
181
180
  closeOnEscape
182
- theme={theme}
183
181
  isOpen={isOpen}
184
182
  anchorRef={anchorRef}
185
183
  placement={Placement.BOTTOM}
@@ -204,7 +202,7 @@ export const WithScrollingPopover = ({ theme }: any) => {
204
202
  );
205
203
  };
206
204
 
207
- export const FitToAnchorWidth = ({ theme }: any) => {
205
+ export const FitToAnchorWidth = () => {
208
206
  const demoPopperStyle = {
209
207
  alignItems: 'center',
210
208
  display: 'flex',
@@ -231,43 +229,43 @@ export const FitToAnchorWidth = ({ theme }: any) => {
231
229
  return (
232
230
  <div style={container}>
233
231
  <div>
234
- <Chip ref={maxWidthAnchorRef} theme={theme} size={Size.s}>
232
+ <Chip ref={maxWidthAnchorRef} size={Size.s}>
235
233
  Anchor
236
234
  </Chip>
237
235
  </div>
238
- <Popover theme={theme} anchorRef={maxWidthAnchorRef} fitToAnchorWidth="maxWidth" isOpen placement="top">
236
+ <Popover anchorRef={maxWidthAnchorRef} fitToAnchorWidth="maxWidth" isOpen placement="top">
239
237
  <div style={demoPopperStyle}>Popover maxWidth</div>
240
238
  </Popover>
241
239
  <div>
242
- <Chip ref={widthSmallAnchorRef} theme={theme} size={Size.s}>
240
+ <Chip ref={widthSmallAnchorRef} size={Size.s}>
243
241
  Anchor
244
242
  </Chip>
245
243
  </div>
246
- <Popover theme={theme} anchorRef={widthSmallAnchorRef} fitToAnchorWidth="width" isOpen placement="top">
244
+ <Popover anchorRef={widthSmallAnchorRef} fitToAnchorWidth="width" isOpen placement="top">
247
245
  <div style={demoPopperStyle}>Popover width small anchor</div>
248
246
  </Popover>
249
247
  <div>
250
- <Chip ref={widthLargeAnchorRef} theme={theme} size={Size.s}>
248
+ <Chip ref={widthLargeAnchorRef} size={Size.s}>
251
249
  VeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLargeAnchor
252
250
  </Chip>
253
251
  </div>
254
- <Popover theme={theme} anchorRef={widthLargeAnchorRef} fitToAnchorWidth="width" isOpen placement="top">
252
+ <Popover anchorRef={widthLargeAnchorRef} fitToAnchorWidth="width" isOpen placement="top">
255
253
  <div style={demoPopperStyle}>Popover width large anchor</div>
256
254
  </Popover>
257
255
  <div>
258
- <Chip ref={minWidthAnchorRef} theme={theme} size={Size.s}>
256
+ <Chip ref={minWidthAnchorRef} size={Size.s}>
259
257
  VeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLargeAnchor
260
258
  </Chip>
261
259
  </div>
262
- <Popover theme={theme} anchorRef={minWidthAnchorRef} fitToAnchorWidth="minWidth" isOpen placement="top">
260
+ <Popover anchorRef={minWidthAnchorRef} fitToAnchorWidth="minWidth" isOpen placement="top">
263
261
  <div style={demoPopperStyle}>Popover minWidth</div>
264
262
  </Popover>
265
263
  <div>
266
- <Chip ref={defaultWidthAnchorRef} theme={theme} size={Size.s}>
264
+ <Chip ref={defaultWidthAnchorRef} size={Size.s}>
267
265
  VeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryVeryLargeAnchor
268
266
  </Chip>
269
267
  </div>
270
- <Popover theme={theme} anchorRef={defaultWidthAnchorRef} isOpen placement="top">
268
+ <Popover anchorRef={defaultWidthAnchorRef} isOpen placement="top">
271
269
  <div style={demoPopperStyle}>Popover default</div>
272
270
  </Popover>
273
271
  </div>
@@ -51,8 +51,13 @@ describe(`<${Popover.displayName}>`, () => {
51
51
  forwardClassName: 'element',
52
52
  forwardAttributes: 'element',
53
53
  applyTheme: {
54
- affects: [{ element: 'element' }, { not: { element: 'themeSentinel' } }],
54
+ affects: [
55
+ { element: 'element' },
56
+ // Theme automatically transferred to the children
57
+ { element: 'themeSentinel' },
58
+ ],
55
59
  viaProp: true,
60
+ // Parent context does not affect the popover
56
61
  viaContext: false,
57
62
  },
58
63
  });
@@ -7,11 +7,11 @@ import { useCallbackOnEscape } from '@lumx/react/hooks/useCallbackOnEscape';
7
7
  import { useFocus } from '@lumx/react/hooks/useFocus';
8
8
  import { ClickAwayProvider } from '@lumx/react/utils/ClickAwayProvider';
9
9
  import { DOCUMENT } from '@lumx/react/constants';
10
- import type { Comp, GenericProps, HasTheme, ComponentClassName } from '@lumx/react/utils/type';
11
- import { handleBasicClasses } from '@lumx/react/utils/className';
12
- import { useMergeRefs } from '@lumx/react/utils/mergeRefs';
10
+ import { Comp, GenericProps, HasTheme } from '@lumx/react/utils/type';
11
+ import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
12
+ import { useMergeRefs } from '@lumx/react/utils/react/mergeRefs';
13
13
  import { useFocusTrap } from '@lumx/react/hooks/useFocusTrap';
14
- import { skipRender } from '@lumx/react/utils/skipRender';
14
+ import { skipRender } from '@lumx/react/utils/react/skipRender';
15
15
  import { forwardRef } from '@lumx/react/utils/react/forwardRef';
16
16
 
17
17
  import { ThemeProvider } from '@lumx/react/utils/theme/ThemeContext';
@@ -80,7 +80,7 @@ const COMPONENT_NAME = 'Popover';
80
80
  /**
81
81
  * Component default class name and class prefix.
82
82
  */
83
- const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-popover';
83
+ const CLASSNAME = getRootClassName(COMPONENT_NAME);
84
84
 
85
85
  /**
86
86
  * Component default props.
@@ -181,7 +181,7 @@ const _InnerPopover = forwardRef<PopoverProps, HTMLDivElement>((props, ref) => {
181
181
  </svg>
182
182
  </div>
183
183
  )}
184
- <ThemeProvider value={undefined}>{children}</ThemeProvider>
184
+ <ThemeProvider value={theme}>{children}</ThemeProvider>
185
185
  </ClickAwayProvider>
186
186
  </Component>,
187
187
  usePortal,
@@ -1,12 +1,10 @@
1
1
  import React, { useEffect, useMemo, useState } from 'react';
2
-
2
+ import memoize from 'lodash/memoize';
3
3
  import { detectOverflow } from '@popperjs/core';
4
4
 
5
5
  import { DOCUMENT, WINDOW } from '@lumx/react/constants';
6
6
  import { PopoverProps } from '@lumx/react/components/popover/Popover';
7
7
  import { usePopper } from '@lumx/react/hooks/usePopper';
8
- import { memoize } from '@lumx/react/utils/function/memoize';
9
-
10
8
  import { ARROW_SIZE, FitAnchorWidth, Placement } from './constants';
11
9
 
12
10
  /**
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { getFirstAndLastFocusable } from '@lumx/react/utils/browser/focus/getFirstAndLastFocusable';
3
- import { OnBeforeUnmount } from '@lumx/react/utils/OnBeforeUnmount';
3
+ import { OnBeforeUnmount } from '@lumx/react/utils/react/OnBeforeUnmount';
4
4
  import type { PopoverProps } from './Popover';
5
5
 
6
6
  /**
@@ -2,7 +2,8 @@ import React from 'react';
2
2
 
3
3
  import classNames from 'classnames';
4
4
 
5
- import { HasAriaLabelOrLabelledBy, ComponentClassName } from '@lumx/react/utils/type';
5
+ import { HasAriaLabelOrLabelledBy } from '@lumx/react/utils/type';
6
+ import { getRootClassName } from '@lumx/react/utils/className';
6
7
  import { forwardRef } from '@lumx/react/utils/react/forwardRef';
7
8
 
8
9
  import { Popover, PopoverProps } from '../popover/Popover';
@@ -21,7 +22,7 @@ const COMPONENT_NAME = 'PopoverDialog';
21
22
  /**
22
23
  * Component default class name and class prefix.
23
24
  */
24
- const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-popover-dialog';
25
+ const CLASSNAME = getRootClassName(COMPONENT_NAME);
25
26
 
26
27
  /**
27
28
  * Component default props.
@@ -1,9 +1,11 @@
1
1
  import React, { ReactNode } from 'react';
2
2
 
3
3
  import classNames from 'classnames';
4
+ import isObject from 'lodash/isObject';
5
+
4
6
  import { Orientation, Theme, Thumbnail, ThumbnailProps, ThumbnailVariant } from '@lumx/react';
5
- import type { GenericProps, HasTheme, ComponentClassName } from '@lumx/react/utils/type';
6
- import { handleBasicClasses } from '@lumx/react/utils/className';
7
+ import { GenericProps, HasTheme } from '@lumx/react/utils/type';
8
+ import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
7
9
  import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
8
10
  import { forwardRef } from '@lumx/react/utils/react/forwardRef';
9
11
 
@@ -41,7 +43,7 @@ const COMPONENT_NAME = 'PostBlock';
41
43
  /**
42
44
  * Component default class name and class prefix.
43
45
  */
44
- const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-post-block';
46
+ const CLASSNAME = getRootClassName(COMPONENT_NAME);
45
47
 
46
48
  /**
47
49
  * Component default props.
@@ -75,9 +77,6 @@ export const PostBlock = forwardRef<PostBlockProps, HTMLDivElement>((props, ref)
75
77
  ...forwardedProps
76
78
  } = props;
77
79
 
78
- // Display text as string or HTML
79
- const textContent = typeof text === 'string' ? { children: text } : { dangerouslySetInnerHTML: text };
80
-
81
80
  return (
82
81
  <div
83
82
  ref={ref}
@@ -100,7 +99,12 @@ export const PostBlock = forwardRef<PostBlockProps, HTMLDivElement>((props, ref)
100
99
 
101
100
  {meta && <span className={`${CLASSNAME}__meta`}>{meta}</span>}
102
101
 
103
- <p className={`${CLASSNAME}__text`} {...textContent} />
102
+ {isObject(text) && text.__html ? (
103
+ // eslint-disable-next-line react/no-danger
104
+ <p dangerouslySetInnerHTML={text} className={`${CLASSNAME}__text`} />
105
+ ) : (
106
+ <p className={`${CLASSNAME}__text`}>{text}</p>
107
+ )}
104
108
 
105
109
  {attachments && <div className={`${CLASSNAME}__attachments`}>{attachments}</div>}
106
110
  {(tags || actions) && (
@@ -3,8 +3,8 @@ import React from 'react';
3
3
  import classNames from 'classnames';
4
4
 
5
5
  import { Theme } from '@lumx/react';
6
- import type { GenericProps, HasTheme, ValueOf, ComponentClassName } from '@lumx/react/utils/type';
7
- import { handleBasicClasses } from '@lumx/react/utils/className';
6
+ import { GenericProps, HasTheme, ValueOf } from '@lumx/react/utils/type';
7
+ import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
8
8
  import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
9
9
  import { forwardRef } from '@lumx/react/utils/react/forwardRef';
10
10
 
@@ -33,7 +33,7 @@ const COMPONENT_NAME = 'Progress';
33
33
  /**
34
34
  * Component default class name and class prefix.
35
35
  */
36
- const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-progress';
36
+ const CLASSNAME = getRootClassName(COMPONENT_NAME);
37
37
 
38
38
  /**
39
39
  * Component default props.
@@ -3,8 +3,8 @@ import React from 'react';
3
3
  import classNames from 'classnames';
4
4
 
5
5
  import { Theme, Size } from '@lumx/react';
6
- import type { GenericProps, HasTheme, ComponentClassName } from '@lumx/react/utils/type';
7
- import { handleBasicClasses } from '@lumx/react/utils/className';
6
+ import { GenericProps, HasTheme } from '@lumx/react/utils/type';
7
+ import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
8
8
  import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
9
9
  import { forwardRef } from '@lumx/react/utils/react/forwardRef';
10
10
 
@@ -29,7 +29,7 @@ const COMPONENT_NAME = 'ProgressCircular';
29
29
  /**
30
30
  * Component default class name and class prefix.
31
31
  */
32
- const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-progress-circular';
32
+ const CLASSNAME = getRootClassName(COMPONENT_NAME);
33
33
 
34
34
  /**
35
35
  * Component default props.
@@ -3,8 +3,8 @@ import React from 'react';
3
3
  import classNames from 'classnames';
4
4
 
5
5
  import { Theme } from '@lumx/react';
6
- import type { GenericProps, HasTheme, ComponentClassName } from '@lumx/react/utils/type';
7
- import { handleBasicClasses } from '@lumx/react/utils/className';
6
+ import { GenericProps, HasTheme } from '@lumx/react/utils/type';
7
+ import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
8
8
  import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
9
9
  import { forwardRef } from '@lumx/react/utils/react/forwardRef';
10
10
 
@@ -18,7 +18,7 @@ const COMPONENT_NAME = 'ProgressLinear';
18
18
  /**
19
19
  * Component default class name and class prefix.
20
20
  */
21
- const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-progress-linear';
21
+ const CLASSNAME = getRootClassName(COMPONENT_NAME);
22
22
 
23
23
  /**
24
24
  * Component default props.