@lumx/react 3.10.1-alpha.7 → 3.10.1-alpha.8

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
package/package.json CHANGED
@@ -6,8 +6,8 @@
6
6
  "url": "https://github.com/lumapps/design-system/issues"
7
7
  },
8
8
  "dependencies": {
9
- "@lumx/core": "^3.10.1-alpha.7",
10
- "@lumx/icons": "^3.10.1-alpha.7",
9
+ "@lumx/core": "^3.10.1-alpha.8",
10
+ "@lumx/icons": "^3.10.1-alpha.8",
11
11
  "@popperjs/core": "^2.5.4",
12
12
  "body-scroll-lock": "^3.1.5",
13
13
  "classnames": "^2.3.2",
@@ -110,5 +110,5 @@
110
110
  "build:storybook": "storybook build"
111
111
  },
112
112
  "sideEffects": false,
113
- "version": "3.10.1-alpha.7"
113
+ "version": "3.10.1-alpha.8"
114
114
  }
@@ -15,10 +15,9 @@ import {
15
15
  ButtonProps,
16
16
  } from '@lumx/react';
17
17
  import { mdiAlert, mdiAlertCircle, mdiCheckCircle, mdiInformation } from '@lumx/icons';
18
- import { handleBasicClasses } from '@lumx/react/utils/className';
18
+ import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
19
19
  import { useId } from '@lumx/react/hooks/useId';
20
20
  import { forwardRef } from '@lumx/react/utils/react/forwardRef';
21
- import type { ComponentClassName } from '@lumx/react/utils/type';
22
21
 
23
22
  export interface AlertDialogProps extends Omit<DialogProps, 'header' | 'footer'> {
24
23
  /** Message variant. */
@@ -38,6 +37,10 @@ export interface AlertDialogProps extends Omit<DialogProps, 'header' | 'footer'>
38
37
  onClick(): void;
39
38
  label: string;
40
39
  };
40
+ /**
41
+ * Children
42
+ */
43
+ children?: React.ReactNode;
41
44
  }
42
45
 
43
46
  /**
@@ -58,7 +61,7 @@ const COMPONENT_NAME = 'AlertDialog';
58
61
  /**
59
62
  * Component default class name and class prefix.
60
63
  */
61
- const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-alert-dialog';
64
+ const CLASSNAME = getRootClassName(COMPONENT_NAME);
62
65
 
63
66
  /**
64
67
  * Component default props.
@@ -8,7 +8,7 @@ export default { title: 'LumX components/autocomplete/Autocomplete' };
8
8
 
9
9
  const cityNames = CITIES.map((city) => city.text);
10
10
 
11
- export const Simple = ({ theme, ...args }: any) => {
11
+ export const Simple = (args: any) => {
12
12
  const [showSuggestions, setShowSuggestions] = useState(false);
13
13
  const [value, setValue] = useState('');
14
14
  const inputRef = useRef(null);
@@ -43,7 +43,6 @@ export const Simple = ({ theme, ...args }: any) => {
43
43
 
44
44
  return (
45
45
  <Autocomplete
46
- theme={theme}
47
46
  isOpen={showSuggestions && hasSuggestions}
48
47
  onClose={close}
49
48
  value={value}
@@ -5,11 +5,11 @@ import classNames from 'classnames';
5
5
  import { Dropdown, DropdownProps, IconButtonProps, Offset, Placement, TextField, TextFieldProps } from '@lumx/react';
6
6
 
7
7
  import { GenericProps, HasTheme } from '@lumx/react/utils/type';
8
+ import { getRootClassName } from '@lumx/react/utils/className';
8
9
  import { useFocus } from '@lumx/react/hooks/useFocus';
9
- import { mergeRefs } from '@lumx/react/utils/mergeRefs';
10
+ import { mergeRefs } from '@lumx/react/utils/react/mergeRefs';
10
11
  import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
11
12
  import { forwardRef } from '@lumx/react/utils/react/forwardRef';
12
- import type { ComponentClassName } from '@lumx/react/utils/type';
13
13
 
14
14
  /**
15
15
  * Defines the props of the component.
@@ -181,7 +181,7 @@ const COMPONENT_NAME = 'Autocomplete';
181
181
  /**
182
182
  * Component default class name and class prefix.
183
183
  */
184
- const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-autocomplete';
184
+ const CLASSNAME = getRootClassName(COMPONENT_NAME);
185
185
 
186
186
  /**
187
187
  * Component default props.
@@ -13,7 +13,7 @@ interface City {
13
13
  text: string;
14
14
  }
15
15
 
16
- export const Simple = ({ theme }: any) => {
16
+ export const Simple = () => {
17
17
  const INITIAL_STATE_SHOW_SUGGESTIONS = false;
18
18
  const INITIAL_STATE_NAVIGATION_SUGGESTION = '';
19
19
 
@@ -119,7 +119,6 @@ export const Simple = ({ theme }: any) => {
119
119
 
120
120
  const renderChip = (city: City, index: number) => (
121
121
  <Chip
122
- theme={theme}
123
122
  isClickable
124
123
  key={index}
125
124
  after={<Icon icon={mdiClose} size={Size.xxs} />}
@@ -134,7 +133,6 @@ export const Simple = ({ theme }: any) => {
134
133
 
135
134
  return (
136
135
  <AutocompleteMultiple
137
- theme={theme}
138
136
  isOpen={showSuggestions && hasSuggestions}
139
137
  onClose={closeAutocomplete}
140
138
  value={navigationSuggestionValue || filterValue}
@@ -149,13 +147,12 @@ export const Simple = ({ theme }: any) => {
149
147
  icon={mdiFlag}
150
148
  label="Label"
151
149
  >
152
- <List isClickable theme={theme}>
150
+ <List isClickable>
153
151
  {filteredCities.map((city, index) => {
154
152
  const onItemSelected = () => setSelectedCity(city);
155
153
  return (
156
154
  <ListItem
157
155
  size={Size.tiny}
158
- theme={theme}
159
156
  key={city.id}
160
157
  isHighlighted={index === activeItemIndex}
161
158
  onItemSelected={onItemSelected}
@@ -5,7 +5,7 @@ import classNames from 'classnames';
5
5
  import { mdiClose } from '@lumx/icons';
6
6
 
7
7
  import { Autocomplete, AutocompleteProps, Chip, HorizontalAlignment, Icon, Size } from '@lumx/react';
8
- import type { ComponentClassName } from '@lumx/react/utils/type';
8
+ import { getRootClassName } from '@lumx/react/utils/className';
9
9
  import { forwardRef } from '@lumx/react/utils/react/forwardRef';
10
10
  import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
11
11
 
@@ -34,7 +34,7 @@ const COMPONENT_NAME = 'AutocompleteMultiple';
34
34
  /**
35
35
  * Component default class name and class prefix.
36
36
  */
37
- const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-autocomplete-multiple';
37
+ const CLASSNAME = getRootClassName(COMPONENT_NAME);
38
38
 
39
39
  /**
40
40
  * Component default props.
@@ -4,8 +4,8 @@ import classNames from 'classnames';
4
4
 
5
5
  import { AspectRatio, Size, Theme, Thumbnail, ThumbnailProps } from '@lumx/react';
6
6
 
7
- import type { GenericProps, HasTheme, ComponentClassName } from '@lumx/react/utils/type';
8
- 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';
9
9
  import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
10
10
  import { forwardRef } from '@lumx/react/utils/react/forwardRef';
11
11
 
@@ -51,7 +51,7 @@ const COMPONENT_NAME = 'Avatar';
51
51
  /**
52
52
  * Component default class name and class prefix.
53
53
  */
54
- const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-avatar';
54
+ const CLASSNAME = getRootClassName(COMPONENT_NAME);
55
55
 
56
56
  /**
57
57
  * Component default props.
@@ -3,8 +3,8 @@ import React, { ReactNode } from 'react';
3
3
  import classNames from 'classnames';
4
4
 
5
5
  import { ColorPalette } from '@lumx/react';
6
- import type { GenericProps, ComponentClassName } from '@lumx/react/utils/type';
7
- import { handleBasicClasses } from '@lumx/react/utils/className';
6
+ import { GenericProps } from '@lumx/react/utils/type';
7
+ import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
8
8
  import { forwardRef } from '@lumx/react/utils/react/forwardRef';
9
9
 
10
10
  /**
@@ -25,7 +25,7 @@ const COMPONENT_NAME = 'Badge';
25
25
  /**
26
26
  * Component default class name and class prefix.
27
27
  */
28
- const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-badge';
28
+ const CLASSNAME = getRootClassName(COMPONENT_NAME);
29
29
 
30
30
  /**
31
31
  * Component default props.
@@ -2,8 +2,9 @@ import React, { ReactElement, ReactNode } from 'react';
2
2
 
3
3
  import classNames from 'classnames';
4
4
 
5
+ import { getRootClassName } from '@lumx/react/utils/className';
5
6
  import { DEFAULT_PROPS } from '@lumx/react/components/select/WithSelectContext';
6
- import type { GenericProps, ComponentClassName } from '@lumx/react/utils/type';
7
+ import { GenericProps } from '@lumx/react/utils/type';
7
8
  import { forwardRef } from '@lumx/react/utils/react/forwardRef';
8
9
 
9
10
  export interface BadgeWrapperProps extends GenericProps {
@@ -21,7 +22,7 @@ const COMPONENT_NAME = 'BadgeWrapper';
21
22
  /**
22
23
  * Component default class name and class prefix.
23
24
  */
24
- const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-badge-wrapper';
25
+ const CLASSNAME = getRootClassName(COMPONENT_NAME);
25
26
 
26
27
  export const BadgeWrapper = forwardRef<BadgeWrapperProps, HTMLDivElement>((props, ref) => {
27
28
  const { badge, children, className, ...forwardedProps } = props;
@@ -1,10 +1,11 @@
1
1
  import React, { ReactNode } from 'react';
2
2
 
3
3
  import classNames from 'classnames';
4
+ import isEmpty from 'lodash/isEmpty';
4
5
 
5
6
  import { Emphasis, Icon, Size, Theme, Text } from '@lumx/react';
6
- import { isComponentType, type ComponentClassName } from '@lumx/react/utils/type';
7
- import { getBasicClass } from '@lumx/react/utils/className';
7
+ import { isComponent } from '@lumx/react/utils/type';
8
+ import { getBasicClass, getRootClassName } from '@lumx/react/utils/className';
8
9
  import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
9
10
  import { forwardRef } from '@lumx/react/utils/react/forwardRef';
10
11
 
@@ -38,7 +39,7 @@ const COMPONENT_NAME = 'Button';
38
39
  /**
39
40
  * Component default class name and class prefix.
40
41
  */
41
- const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-button';
42
+ const CLASSNAME = getRootClassName(COMPONENT_NAME);
42
43
 
43
44
  /**
44
45
  * Component default props.
@@ -61,8 +62,8 @@ export const Button = forwardRef<ButtonProps, HTMLButtonElement | HTMLAnchorElem
61
62
 
62
63
  const buttonClassName = classNames(
63
64
  className,
64
- getBasicClass({ prefix: CLASSNAME, type: 'hasLeftIcon', value: !!leftIcon }),
65
- getBasicClass({ prefix: CLASSNAME, type: 'hasRightIcon', value: !!rightIcon }),
65
+ getBasicClass({ prefix: CLASSNAME, type: 'hasLeftIcon', value: !isEmpty(leftIcon) }),
66
+ getBasicClass({ prefix: CLASSNAME, type: 'hasRightIcon', value: !isEmpty(rightIcon) }),
66
67
  );
67
68
 
68
69
  return (
@@ -72,9 +73,9 @@ export const Button = forwardRef<ButtonProps, HTMLButtonElement | HTMLAnchorElem
72
73
  className={buttonClassName}
73
74
  variant="button"
74
75
  >
75
- {leftIcon && <Icon icon={leftIcon} />}
76
- {children && (isComponentType(Text)(children) ? children : <span>{children}</span>)}
77
- {rightIcon && <Icon icon={rightIcon} />}
76
+ {leftIcon && !isEmpty(leftIcon) && <Icon icon={leftIcon} />}
77
+ {children && (isComponent(Text)(children) ? children : <span>{children}</span>)}
78
+ {rightIcon && !isEmpty(rightIcon) && <Icon icon={rightIcon} />}
78
79
  </ButtonRoot>
79
80
  );
80
81
  });
@@ -2,13 +2,19 @@ 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
  /**
9
10
  * Defines the props of the component
10
11
  */
11
- export type ButtonGroupProps = GenericProps;
12
+ export interface ButtonGroupProps extends GenericProps {
13
+ /**
14
+ * Children
15
+ */
16
+ children?: React.ReactNode;
17
+ }
12
18
 
13
19
  /**
14
20
  * Component display name.
@@ -18,7 +24,7 @@ const COMPONENT_NAME = 'ButtonGroup';
18
24
  /**
19
25
  * Component default class name and class prefix.
20
26
  */
21
- const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-button-group';
27
+ const CLASSNAME = getRootClassName(COMPONENT_NAME);
22
28
 
23
29
  /**
24
30
  * Component default props.
@@ -1,12 +1,14 @@
1
1
  import React, { AriaAttributes, ButtonHTMLAttributes, DetailedHTMLProps, RefObject } from 'react';
2
2
 
3
+ import isEmpty from 'lodash/isEmpty';
4
+
3
5
  import classNames from 'classnames';
4
6
 
5
7
  import { ColorPalette, Emphasis, Size, Theme } from '@lumx/react';
6
8
  import { CSS_PREFIX } from '@lumx/react/constants';
7
9
  import { GenericProps, HasTheme } from '@lumx/react/utils/type';
8
10
  import { handleBasicClasses } from '@lumx/react/utils/className';
9
- import { renderLink } from '@lumx/react/utils/renderLink';
11
+ import { renderLink } from '@lumx/react/utils/react/renderLink';
10
12
  import { forwardRef } from '@lumx/react/utils/react/forwardRef';
11
13
 
12
14
  type HTMLButtonProps = DetailedHTMLProps<ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>;
@@ -42,6 +44,8 @@ export interface BaseButtonProps
42
44
  type?: HTMLButtonProps['type'];
43
45
  /** Custom react component for the link (can be used to inject react router Link). */
44
46
  linkAs?: 'a' | any;
47
+ /** Children */
48
+ children?: React.ReactNode;
45
49
  }
46
50
 
47
51
  export interface ButtonRootProps extends BaseButtonProps {
@@ -153,7 +157,7 @@ export const ButtonRoot = forwardRef<ButtonRootProps, HTMLButtonElement | HTMLAn
153
157
  *
154
158
  * However, in any case, if the component is disabled, we returned a <button> since disabled is not compatible with <a>.
155
159
  */
156
- if ((linkAs || props.href) && !isDisabled) {
160
+ if ((linkAs || !isEmpty(props.href)) && !isDisabled) {
157
161
  return renderLink(
158
162
  {
159
163
  linkAs,
@@ -2,9 +2,9 @@ import React from 'react';
2
2
 
3
3
  import { Emphasis, Icon, Size, Theme, Tooltip, TooltipProps } from '@lumx/react';
4
4
  import { BaseButtonProps, ButtonRoot } from '@lumx/react/components/button/ButtonRoot';
5
+ import { getRootClassName } from '@lumx/react/utils/className';
5
6
  import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
6
7
  import { forwardRef } from '@lumx/react/utils/react/forwardRef';
7
- import type { ComponentClassName } from '@lumx/react/utils/type';
8
8
 
9
9
  export interface IconButtonProps extends BaseButtonProps {
10
10
  /**
@@ -39,7 +39,7 @@ const COMPONENT_NAME = 'IconButton';
39
39
  /**
40
40
  * Component default class name and class prefix.
41
41
  */
42
- const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-icon-button';
42
+ const CLASSNAME = getRootClassName(COMPONENT_NAME);
43
43
 
44
44
  /**
45
45
  * Component default props.
@@ -5,10 +5,10 @@ import classNames from 'classnames';
5
5
  import { mdiCheck, mdiMinus } from '@lumx/icons';
6
6
 
7
7
  import { Icon, InputHelper, InputLabel, Theme } from '@lumx/react';
8
- import type { GenericProps, HasTheme, ComponentClassName } from '@lumx/react/utils/type';
9
- 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';
10
10
  import { useId } from '@lumx/react/hooks/useId';
11
- import { useMergeRefs } from '@lumx/react/utils/mergeRefs';
11
+ import { useMergeRefs } from '@lumx/react/utils/react/mergeRefs';
12
12
  import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
13
13
  import { forwardRef } from '@lumx/react/utils/react/forwardRef';
14
14
 
@@ -51,7 +51,7 @@ const COMPONENT_NAME = 'Checkbox';
51
51
  /**
52
52
  * Component default class name and class prefix.
53
53
  */
54
- const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-checkbox';
54
+ const CLASSNAME = getRootClassName(COMPONENT_NAME);
55
55
 
56
56
  /**
57
57
  * Component default props.
@@ -1,12 +1,13 @@
1
1
  import React, { MouseEventHandler, ReactNode } from 'react';
2
2
 
3
3
  import classNames from 'classnames';
4
+ import isFunction from 'lodash/isFunction';
4
5
 
5
6
  import { ColorPalette, Size, Theme } from '@lumx/react';
6
7
  import { useStopPropagation } from '@lumx/react/hooks/useStopPropagation';
7
8
 
8
- import type { GenericProps, HasTheme, ComponentClassName } from '@lumx/react/utils/type';
9
- import { handleBasicClasses } from '@lumx/react/utils/className';
9
+ import { GenericProps, HasTheme } from '@lumx/react/utils/type';
10
+ import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
10
11
  import { onEnterPressed } from '@lumx/react/utils/browser/event';
11
12
  import { forwardRef } from '@lumx/react/utils/react/forwardRef';
12
13
  import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
@@ -40,6 +41,8 @@ export interface ChipProps extends GenericProps, HasTheme {
40
41
  onAfterClick?: MouseEventHandler;
41
42
  /** On "before" element clicked callback. */
42
43
  onBeforeClick?: MouseEventHandler;
44
+ /** Children */
45
+ children?: React.ReactNode;
43
46
  }
44
47
 
45
48
  /**
@@ -50,7 +53,7 @@ const COMPONENT_NAME = 'Chip';
50
53
  /**
51
54
  * Component default class name and class prefix.
52
55
  */
53
- const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-chip';
56
+ const CLASSNAME = getRootClassName(COMPONENT_NAME);
54
57
 
55
58
  /**
56
59
  * Component default props.
@@ -88,8 +91,11 @@ export const Chip = forwardRef<ChipProps, HTMLAnchorElement>((props, ref) => {
88
91
  onKeyDown,
89
92
  ...forwardedProps
90
93
  } = props;
91
- const isButton = onClick && !href;
92
- const isClickable = Boolean(onClick) || Boolean(href) || propIsClickable;
94
+ const hasAfterClick = isFunction(onAfterClick);
95
+ const hasBeforeClick = isFunction(onBeforeClick);
96
+ const hasOnClick = isFunction(onClick);
97
+ const isButton = hasOnClick && !href;
98
+ const isClickable = Boolean(hasOnClick) || Boolean(href) || propIsClickable;
93
99
 
94
100
  // Adapt color to the theme.
95
101
  const chipColor = color || (theme === Theme.light ? ColorPalette.dark : ColorPalette.light);
@@ -98,7 +104,7 @@ export const Chip = forwardRef<ChipProps, HTMLAnchorElement>((props, ref) => {
98
104
  const handleOnAfterClick = useStopPropagation(onAfterClick);
99
105
  const handleKeyDown = (evt: React.KeyboardEvent) => {
100
106
  onKeyDown?.(evt);
101
- if (onClick) {
107
+ if (hasOnClick) {
102
108
  onEnterPressed(onClick)(evt);
103
109
  }
104
110
  };
@@ -127,14 +133,14 @@ export const Chip = forwardRef<ChipProps, HTMLAnchorElement>((props, ref) => {
127
133
  }),
128
134
  )}
129
135
  aria-disabled={(isClickable && isDisabled) || undefined}
130
- onClick={onClick || undefined}
136
+ onClick={hasOnClick ? onClick : undefined}
131
137
  onKeyDown={handleKeyDown}
132
138
  >
133
139
  {before && (
134
140
  // eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions
135
141
  <div
136
142
  className={classNames(`${CLASSNAME}__before`, {
137
- [`${CLASSNAME}__before--is-clickable`]: !!onBeforeClick,
143
+ [`${CLASSNAME}__before--is-clickable`]: hasBeforeClick,
138
144
  })}
139
145
  onClick={handleOnBeforeClick}
140
146
  >
@@ -146,7 +152,7 @@ export const Chip = forwardRef<ChipProps, HTMLAnchorElement>((props, ref) => {
146
152
  // eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions
147
153
  <div
148
154
  className={classNames(`${CLASSNAME}__after`, {
149
- [`${CLASSNAME}__after--is-clickable`]: !!onAfterClick,
155
+ [`${CLASSNAME}__after--is-clickable`]: hasAfterClick,
150
156
  })}
151
157
  onClick={handleOnAfterClick}
152
158
  >
@@ -3,7 +3,8 @@ import React, { ReactNode } from 'react';
3
3
  import classNames from 'classnames';
4
4
 
5
5
  import { HorizontalAlignment } from '@lumx/react/components';
6
- import type { GenericProps, ComponentClassName } from '@lumx/react/utils/type';
6
+ import { GenericProps } from '@lumx/react/utils/type';
7
+ import { getRootClassName } from '@lumx/react/utils/className';
7
8
  import { forwardRef } from '@lumx/react/utils/react/forwardRef';
8
9
 
9
10
  import { useChipGroupNavigation } from '@lumx/react/hooks/useChipGroupNavigation';
@@ -34,7 +35,7 @@ const COMPONENT_NAME = 'ChipGroup';
34
35
  /**
35
36
  * Component default class name and class prefix.
36
37
  */
37
- const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-chip-group';
38
+ const CLASSNAME = getRootClassName(COMPONENT_NAME);
38
39
 
39
40
  /**
40
41
  * ChipGroup component.
@@ -42,21 +42,18 @@ export const FullFeatured = {
42
42
  fullDate: 'Monday, March 30, 2021 at 4:06 PM',
43
43
  hasActions: true,
44
44
  },
45
- render: ({ theme, ...props }: any) => (
45
+ render: (props: any) => (
46
46
  <CommentBlock
47
- theme={theme}
48
47
  {...props}
49
48
  actions={[
50
- <Button theme={theme} emphasis="low" size="s" leftIcon={mdiHeart}>
49
+ <Button emphasis="low" size="s" leftIcon={mdiHeart}>
51
50
  24 likes
52
51
  </Button>,
53
- <Button theme={theme} emphasis="low" size="s" leftIcon={mdiReply}>
52
+ <Button emphasis="low" size="s" leftIcon={mdiReply}>
54
53
  Reply
55
54
  </Button>,
56
55
  ]}
57
- headerActions={
58
- <IconButton label="Actions" icon={mdiDotsHorizontal} theme={theme} emphasis="low" size="s" />
59
- }
56
+ headerActions={<IconButton label="Actions" icon={mdiDotsHorizontal} emphasis="low" size="s" />}
60
57
  />
61
58
  ),
62
59
  };
@@ -3,8 +3,8 @@ import React, { Children, ReactNode } from 'react';
3
3
  import classNames from 'classnames';
4
4
 
5
5
  import { Avatar, Size, Theme, Tooltip } 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 { forwardRef } from '@lumx/react/utils/react/forwardRef';
9
9
 
10
10
  import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
@@ -72,7 +72,7 @@ const COMPONENT_NAME = 'CommentBlock';
72
72
  /**
73
73
  * Component default class name and class prefix.
74
74
  */
75
- const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-comment-block';
75
+ const CLASSNAME = getRootClassName(COMPONENT_NAME);
76
76
 
77
77
  /**
78
78
  * Component default props.
@@ -1,4 +1,4 @@
1
- import type { ComponentClassName } from '@lumx/react/utils/type';
1
+ import { getRootClassName } from '@lumx/react/utils/className';
2
2
 
3
3
  /**
4
4
  * Component display name.
@@ -8,4 +8,4 @@ export const COMPONENT_NAME = 'DatePicker';
8
8
  /**
9
9
  * Component default class name and class prefix.
10
10
  */
11
- export const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-date-picker';
11
+ export const CLASSNAME = getRootClassName(COMPONENT_NAME);
@@ -10,11 +10,11 @@ import { useCallbackOnEscape } from '@lumx/react/hooks/useCallbackOnEscape';
10
10
  import { useFocusTrap } from '@lumx/react/hooks/useFocusTrap';
11
11
  import { useIntersectionObserver } from '@lumx/react/hooks/useIntersectionObserver';
12
12
 
13
- import { type GenericProps, isComponentType, type ComponentClassName } from '@lumx/react/utils/type';
14
- import { partitionMulti } from '@lumx/react/utils/collection/partitionMulti';
15
- import { handleBasicClasses } from '@lumx/react/utils/className';
13
+ import { GenericProps, isComponent } from '@lumx/react/utils/type';
14
+ import { partitionMulti } from '@lumx/react/utils/partitionMulti';
15
+ import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
16
16
  import { ClickAwayProvider } from '@lumx/react/utils/ClickAwayProvider';
17
- import { mergeRefs } from '@lumx/react/utils/mergeRefs';
17
+ import { mergeRefs } from '@lumx/react/utils/react/mergeRefs';
18
18
  import { forwardRef } from '@lumx/react/utils/react/forwardRef';
19
19
 
20
20
  import { useDisableBodyScroll } from '@lumx/react/hooks/useDisableBodyScroll';
@@ -61,12 +61,14 @@ export interface DialogProps extends GenericProps {
61
61
  onVisibilityChange?(isVisible: boolean): void;
62
62
  /** whether to disable the scroll on the body or not */
63
63
  disableBodyScroll?: boolean;
64
+ /** Children */
65
+ children?: React.ReactNode;
64
66
  }
65
67
 
66
68
  export type DialogSizes = Extract<Size, 'tiny' | 'regular' | 'big' | 'huge'>;
67
69
 
68
- const isHeader = isComponentType('header');
69
- const isFooter = isComponentType('footer');
70
+ const isHeader = isComponent('header');
71
+ const isFooter = isComponent('footer');
70
72
 
71
73
  /**
72
74
  * Component display name.
@@ -76,7 +78,7 @@ const COMPONENT_NAME = 'Dialog';
76
78
  /**
77
79
  * Component default class name and class prefix.
78
80
  */
79
- const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-dialog';
81
+ const CLASSNAME = getRootClassName(COMPONENT_NAME);
80
82
 
81
83
  /**
82
84
  * 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
 
@@ -21,7 +21,7 @@ const COMPONENT_NAME = 'Divider';
21
21
  /**
22
22
  * Component default class name and class prefix.
23
23
  */
24
- const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-divider';
24
+ const CLASSNAME = getRootClassName(COMPONENT_NAME);
25
25
 
26
26
  /**
27
27
  * Component default props.
@@ -4,8 +4,8 @@ import classNames from 'classnames';
4
4
 
5
5
  import { mdiDragVertical } from '@lumx/icons';
6
6
  import { ColorPalette, Icon, Size, Theme } from '@lumx/react';
7
- import type { GenericProps, HasTheme, ComponentClassName } from '@lumx/react/utils/type';
8
- 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';
9
9
  import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
10
10
  import { forwardRef } from '@lumx/react/utils/react/forwardRef';
11
11
 
@@ -22,7 +22,7 @@ const COMPONENT_NAME = 'DragHandle';
22
22
  /**
23
23
  * Component default class name and class prefix.
24
24
  */
25
- const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-drag-handle';
25
+ const CLASSNAME = getRootClassName(COMPONENT_NAME);
26
26
 
27
27
  /**
28
28
  * DragHandle component.
@@ -5,7 +5,8 @@ import classNames from 'classnames';
5
5
  import { List, ListProps } from '@lumx/react/components/list/List';
6
6
  import { Popover, PopoverProps } from '@lumx/react/components/popover/Popover';
7
7
  import { useInfiniteScroll } from '@lumx/react/hooks/useInfiniteScroll';
8
- import { type GenericProps, isComponentType, type ComponentClassName } from '@lumx/react/utils/type';
8
+ import { GenericProps, isComponent } from '@lumx/react/utils/type';
9
+ import { getRootClassName } from '@lumx/react/utils/className';
9
10
  import { Offset, Placement } from '@lumx/react/components/popover/constants';
10
11
  import { forwardRef } from '@lumx/react/utils/react/forwardRef';
11
12
 
@@ -90,7 +91,7 @@ const COMPONENT_NAME = 'Dropdown';
90
91
  /**
91
92
  * Component default class name and class prefix.
92
93
  */
93
- const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-dropdown';
94
+ const CLASSNAME = getRootClassName(COMPONENT_NAME);
94
95
 
95
96
  /**
96
97
  * Component default props.
@@ -139,7 +140,7 @@ export const Dropdown = forwardRef<DropdownProps, HTMLDivElement>((props, ref) =
139
140
  useInfiniteScroll(innerRef, onInfiniteScroll);
140
141
 
141
142
  const popperElement = useMemo(() => {
142
- return !Array.isArray(children) && isComponentType(List)(children)
143
+ return !Array.isArray(children) && isComponent(List)(children)
143
144
  ? cloneElement<ListProps>(children, {
144
145
  ...children.props,
145
146
  ref: listElement,