@lumx/react 3.10.1-alpha.6 → 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 (166) hide show
  1. package/index.d.ts +86 -12
  2. package/index.js +299 -296
  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/collection/castArray.test.ts +0 -15
  148. package/src/utils/collection/castArray.ts +0 -3
  149. package/src/utils/collection/chunk.test.ts +0 -15
  150. package/src/utils/collection/chunk.ts +0 -6
  151. package/src/utils/collection/isEmpty.test.js +0 -20
  152. package/src/utils/collection/isEmpty.ts +0 -4
  153. package/src/utils/collection/last.ts +0 -2
  154. package/src/utils/collection/partitionMulti.test.ts +0 -35
  155. package/src/utils/collection/pull.test.ts +0 -17
  156. package/src/utils/collection/pull.ts +0 -7
  157. package/src/utils/collection/range.test.js +0 -9
  158. package/src/utils/collection/range.ts +0 -2
  159. package/src/utils/function/memoize.test.ts +0 -36
  160. package/src/utils/function/memoize.ts +0 -13
  161. package/src/utils/type/ComponentClassName.ts +0 -7
  162. package/src/utils/type/KebabCase.ts +0 -6
  163. /package/src/utils/{clamp.ts → number/clamp.ts} +0 -0
  164. /package/src/utils/{OnBeforeUnmount.tsx → react/OnBeforeUnmount.tsx} +0 -0
  165. /package/src/utils/{mergeRefs.ts → react/mergeRefs.ts} +0 -0
  166. /package/src/utils/{renderLink.tsx → react/renderLink.tsx} +0 -0
@@ -4,15 +4,18 @@ import classNames from 'classnames';
4
4
 
5
5
  import { mdiChevronDown, mdiChevronUp } from '@lumx/icons';
6
6
 
7
+ import get from 'lodash/get';
8
+ import isEmpty from 'lodash/isEmpty';
9
+ import isFunction from 'lodash/isFunction';
10
+
7
11
  import { ColorPalette, DragHandle, Emphasis, IconButton, IconButtonProps, Theme } from '@lumx/react';
8
- import { type GenericProps, type HasTheme, type ComponentClassName, isComponentType } from '@lumx/react/utils/type';
9
- import { handleBasicClasses } from '@lumx/react/utils/className';
10
- import { partitionMulti } from '@lumx/react/utils/collection/partitionMulti';
12
+ import { GenericProps, HasTheme, isComponent } from '@lumx/react/utils/type';
13
+ import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
14
+ import { partitionMulti } from '@lumx/react/utils/partitionMulti';
11
15
  import { useTransitionVisibility } from '@lumx/react/hooks/useTransitionVisibility';
12
16
  import { EXPANSION_PANEL_TRANSITION_DURATION } from '@lumx/core/js/constants';
13
17
  import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
14
18
  import { forwardRef } from '@lumx/react/utils/react/forwardRef';
15
- import { isEmpty } from '@lumx/react/utils/collection/isEmpty';
16
19
 
17
20
  /**
18
21
  * Defines the props of the component.
@@ -35,6 +38,8 @@ export interface ExpansionPanelProps extends GenericProps, HasTheme {
35
38
  Omit<IconButtonProps, 'label' | 'onClick' | 'icon' | 'emphasis' | 'color'>;
36
39
  /** On toggle open or close callback. */
37
40
  onToggleOpen?(shouldOpen: boolean, event: React.MouseEvent): void;
41
+ /** Children */
42
+ children?: React.ReactNode;
38
43
  }
39
44
 
40
45
  /**
@@ -45,16 +50,16 @@ const COMPONENT_NAME = 'ExpansionPanel';
45
50
  /**
46
51
  * Component default class name and class prefix.
47
52
  */
48
- const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-expansion-panel';
53
+ const CLASSNAME = getRootClassName(COMPONENT_NAME);
49
54
 
50
55
  /**
51
56
  * Component default props.
52
57
  */
53
58
  const DEFAULT_PROPS: Partial<ExpansionPanelProps> = {};
54
59
 
55
- const isDragHandle = isComponentType(DragHandle);
56
- const isHeader = isComponentType('header');
57
- const isFooter = isComponentType('footer');
60
+ const isDragHandle = isComponent(DragHandle);
61
+ const isHeader = isComponent('header');
62
+ const isFooter = isComponent('footer');
58
63
 
59
64
  /**
60
65
  * ExpansionPanel component.
@@ -87,23 +92,24 @@ export const ExpansionPanel = forwardRef<ExpansionPanelProps, HTMLDivElement>((p
87
92
 
88
93
  // Either take the header in children or create one with the label.
89
94
  const headerProps: PropsWithChildren<any> = React.isValidElement(header) ? header.props : {};
90
- const headerContent =
91
- React.Children.count(headerProps.children) > 0 ? (
92
- headerProps.children
93
- ) : (
94
- <span className={`${CLASSNAME}__label`}>{label}</span>
95
- );
95
+ const headerContent = !isEmpty(headerProps.children) ? (
96
+ headerProps.children
97
+ ) : (
98
+ <span className={`${CLASSNAME}__label`}>{label}</span>
99
+ );
96
100
 
97
101
  const toggleOpen = (event: React.MouseEvent) => {
98
102
  const shouldOpen = !isOpen;
99
103
 
100
- if (shouldOpen) {
101
- onOpen?.(event);
104
+ if (isFunction(onOpen) && shouldOpen) {
105
+ onOpen(event);
106
+ }
107
+ if (isFunction(onClose) && !shouldOpen) {
108
+ onClose(event);
102
109
  }
103
- if (!shouldOpen) {
104
- onClose?.(event);
110
+ if (isFunction(onToggleOpen)) {
111
+ onToggleOpen(shouldOpen, event);
105
112
  }
106
- onToggleOpen?.(shouldOpen, event);
107
113
  };
108
114
 
109
115
  const color = theme === Theme.dark ? ColorPalette.light : ColorPalette.dark;
@@ -130,7 +136,7 @@ export const ExpansionPanel = forwardRef<ExpansionPanelProps, HTMLDivElement>((p
130
136
  // Switch max height on/off to activate the CSS transition (updates when children changes).
131
137
  const [maxHeight, setMaxHeight] = useState('0');
132
138
  useEffect(() => {
133
- const height = isOpen ? wrapperRef.current?.offsetHeight ?? 0 : 0;
139
+ const height = isOpen ? get(wrapperRef.current, 'offsetHeight', 0) : 0;
134
140
  setMaxHeight(`${height}px`);
135
141
  }, [children, isOpen]);
136
142
 
@@ -3,8 +3,8 @@ import React from 'react';
3
3
  import classNames from 'classnames';
4
4
 
5
5
  import { ColorPalette, Icon, Size, Theme, Text } 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
 
@@ -20,7 +20,7 @@ export interface FlagProps extends GenericProps, HasTheme {
20
20
  }
21
21
 
22
22
  const COMPONENT_NAME = 'Flag';
23
- const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-flag';
23
+ const CLASSNAME = getRootClassName(COMPONENT_NAME);
24
24
  const DEFAULT_PROPS: Partial<FlagProps> = {};
25
25
 
26
26
  /**
@@ -1,11 +1,11 @@
1
1
  import React, { ReactNode } from 'react';
2
2
 
3
3
  import classNames from 'classnames';
4
+ import castArray from 'lodash/castArray';
4
5
 
5
6
  import { Alignment, Orientation } from '@lumx/react';
6
- import { castArray } from '@lumx/react/utils/collection/castArray';
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
  import { HorizontalAlignment, Size, VerticalAlignment } from '..';
11
11
 
@@ -49,7 +49,7 @@ const COMPONENT_NAME = 'FlexBox';
49
49
  /**
50
50
  * Component default class name and class prefix.
51
51
  */
52
- const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-flex-box';
52
+ const CLASSNAME = getRootClassName(COMPONENT_NAME);
53
53
 
54
54
  /**
55
55
  * FlexBox component.
@@ -1,9 +1,12 @@
1
1
  import React, { Children, ReactElement, ReactNode } from 'react';
2
2
 
3
3
  import classNames from 'classnames';
4
+ import isEmpty from 'lodash/isEmpty';
5
+ import noop from 'lodash/noop';
4
6
 
5
- import { type ComponentClassName, type Comp, isComponentType } from '@lumx/react/utils/type';
6
- import { partitionMulti } from '@lumx/react/utils/collection/partitionMulti';
7
+ import { Comp, isComponentType } from '@lumx/react/utils/type';
8
+ import { getRootClassName } from '@lumx/react/utils/className';
9
+ import { partitionMulti } from '@lumx/react/utils/partitionMulti';
7
10
  import { Orientation, Size, FlexBox, FlexBoxProps } from '@lumx/react';
8
11
  import { GenericBlockGapSize } from '@lumx/react/components/generic-block/constants';
9
12
  import { forwardRef } from '@lumx/react/utils/react/forwardRef';
@@ -61,7 +64,7 @@ const COMPONENT_NAME = 'GenericBlock';
61
64
  /**
62
65
  * Component default class name and class prefix.
63
66
  */
64
- const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-generic-block';
67
+ const CLASSNAME = getRootClassName(COMPONENT_NAME);
65
68
 
66
69
  /**
67
70
  * Component default props.
@@ -98,13 +101,13 @@ interface GenericBlock extends BaseGenericBlock {
98
101
  Actions: Comp<GenericBlockSectionProps>;
99
102
  }
100
103
 
101
- const Figure = (() => {}) as unknown as Comp<FlexBoxProps>;
104
+ const Figure = noop.bind({}) as Comp<FlexBoxProps>;
102
105
  const isFigure = isComponentType(Figure);
103
106
 
104
- const Content = (() => {}) as unknown as Comp<FlexBoxProps>;
107
+ const Content = noop.bind({}) as Comp<FlexBoxProps>;
105
108
  const isContent = isComponentType(Content);
106
109
 
107
- const Actions = (() => {}) as unknown as Comp<FlexBoxProps>;
110
+ const Actions = noop.bind({}) as Comp<FlexBoxProps>;
108
111
  const isActions = isComponentType(Actions);
109
112
 
110
113
  /**
@@ -145,8 +148,7 @@ const BaseGenericBlock: BaseGenericBlock = forwardRef((props, ref) => {
145
148
  contentChildProps: (contentChild as ReactElement)?.props,
146
149
  actionsChild,
147
150
  actionsChildProps: (actionsChild as ReactElement)?.props,
148
- // TODO: check this is working
149
- otherChildren: otherChildren.filter((child) => React.Children.count(child) > 0),
151
+ otherChildren: otherChildren.filter((child) => !isEmpty(child)),
150
152
  };
151
153
  }, [children]);
152
154
 
@@ -1,14 +1,9 @@
1
+ import pick from 'lodash/pick';
1
2
  import { Size } from '@lumx/react';
2
-
3
- export type GenericBlockGapSize = Extract<Size, 'tiny' | 'regular' | 'medium' | 'big' | 'huge'>;
3
+ import { ValueOf } from '@lumx/react/utils/type';
4
4
 
5
5
  /**
6
6
  * Accepted gap sizes for the generic block.
7
7
  */
8
- export const GenericBlockGapSize: { [S in GenericBlockGapSize]: S } = {
9
- tiny: Size.tiny,
10
- regular: Size.regular,
11
- medium: Size.medium,
12
- big: Size.big,
13
- huge: Size.huge,
14
- };
8
+ export const GenericBlockGapSize = pick(Size, ['tiny', 'regular', 'medium', 'big', 'huge']);
9
+ export type GenericBlockGapSize = ValueOf<typeof GenericBlockGapSize>;
@@ -3,8 +3,8 @@ import React from 'react';
3
3
  import classNames from 'classnames';
4
4
 
5
5
  import { Alignment, Orientation, Size } 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
  type GridGutterSize = Extract<Size, 'regular' | 'big' | 'huge'>;
@@ -23,6 +23,8 @@ export interface GridProps extends GenericProps {
23
23
  hAlign?: Alignment;
24
24
  /** Gutter size. */
25
25
  gutter?: GridGutterSize;
26
+ /** Children */
27
+ children?: React.ReactNode;
26
28
  }
27
29
 
28
30
  /**
@@ -33,7 +35,7 @@ const COMPONENT_NAME = 'Grid';
33
35
  /**
34
36
  * Component default class name and class prefix.
35
37
  */
36
- const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-grid';
38
+ const CLASSNAME = getRootClassName(COMPONENT_NAME);
37
39
 
38
40
  /**
39
41
  * Component default props.
@@ -3,8 +3,8 @@ import React from 'react';
3
3
  import classNames from 'classnames';
4
4
 
5
5
  import { Alignment } 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
  type Columns = '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' | '10' | '11' | '12';
@@ -19,6 +19,8 @@ export interface GridItemProps extends GenericProps {
19
19
  order?: Columns;
20
20
  /** Width. */
21
21
  width?: Columns;
22
+ /** Children */
23
+ children?: React.ReactNode;
22
24
  }
23
25
 
24
26
  /**
@@ -29,7 +31,7 @@ const COMPONENT_NAME = 'GridItem';
29
31
  /**
30
32
  * Component default class name and class prefix.
31
33
  */
32
- const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-grid-item';
34
+ const CLASSNAME = getRootClassName(COMPONENT_NAME);
33
35
 
34
36
  /**
35
37
  * GridItem component.
@@ -1,9 +1,11 @@
1
1
  import React, { ReactElement, ReactNode } from 'react';
2
2
 
3
+ import isInteger from 'lodash/isInteger';
3
4
  import classNames from 'classnames';
4
5
 
5
6
  import { Size } from '@lumx/react';
6
- import type { GenericProps, ComponentClassName } from '@lumx/react/utils/type';
7
+ import { GenericProps } from '@lumx/react/utils/type';
8
+ import { getRootClassName } from '@lumx/react/utils/className';
7
9
  import { forwardRef } from '@lumx/react/utils/react/forwardRef';
8
10
 
9
11
  export type GridColumnGapSize = Extract<Size, 'tiny' | 'regular' | 'big' | 'huge'>;
@@ -32,7 +34,7 @@ const COMPONENT_NAME = 'GridColumn';
32
34
  /**
33
35
  * Component default class name and class prefix.
34
36
  */
35
- const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-grid-column';
37
+ const CLASSNAME = getRootClassName(COMPONENT_NAME);
36
38
 
37
39
  /**
38
40
  * Component default props.
@@ -67,7 +69,7 @@ export const GridColumn = forwardRef<GridColumnProps>((props, ref): ReactElement
67
69
  className={classNames(className, CLASSNAME)}
68
70
  style={{
69
71
  ...style,
70
- ['--lumx-grid-column-item-min-width' as any]: Number.isInteger(itemMinWidth) && `${itemMinWidth}px`,
72
+ ['--lumx-grid-column-item-min-width' as any]: isInteger(itemMinWidth) && `${itemMinWidth}px`,
71
73
  ['--lumx-grid-column-columns' as any]: maxColumns,
72
74
  ['--lumx-grid-column-gap' as any]: gap && `var(--lumx-spacing-unit-${gap})`,
73
75
  }}
@@ -2,7 +2,8 @@ import React from 'react';
2
2
 
3
3
  import classNames from 'classnames';
4
4
 
5
- import type { HeadingElement, ComponentClassName } from '@lumx/react/utils/type';
5
+ import { HeadingElement } 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 { Text, TextProps } from '../text';
@@ -17,6 +18,10 @@ export interface HeadingProps extends Partial<TextProps> {
17
18
  * Display a specific heading level instead of the one provided by parent context provider.
18
19
  */
19
20
  as?: HeadingElement;
21
+ /**
22
+ * Children
23
+ */
24
+ children?: React.ReactNode;
20
25
  }
21
26
 
22
27
  /**
@@ -27,7 +32,7 @@ const COMPONENT_NAME = 'Heading';
27
32
  /**
28
33
  * Component default class name and class prefix.
29
34
  */
30
- const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-heading';
35
+ const CLASSNAME = getRootClassName(COMPONENT_NAME);
31
36
 
32
37
  /**
33
38
  * Component default props.
@@ -4,8 +4,8 @@ import classNames from 'classnames';
4
4
 
5
5
  import { mdiAlertCircle } from '@lumx/icons';
6
6
  import { ColorPalette, ColorVariant, 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 { forwardRef } from '@lumx/react/utils/react/forwardRef';
10
10
  import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
11
11
 
@@ -40,7 +40,7 @@ const COMPONENT_NAME = 'Icon';
40
40
  /**
41
41
  * Component default class name and class prefix.
42
42
  */
43
- const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-icon';
43
+ const CLASSNAME = getRootClassName(COMPONENT_NAME);
44
44
 
45
45
  /**
46
46
  * Component default props.
@@ -4,8 +4,8 @@ import classNames from 'classnames';
4
4
 
5
5
  import { Alignment, HorizontalAlignment, Size, Theme, Thumbnail } from '@lumx/react';
6
6
 
7
- import type { GenericProps, HasTheme, ValueOf, ComponentClassName } from '@lumx/react/utils/type';
8
- import { handleBasicClasses } from '@lumx/react/utils/className';
7
+ import { GenericProps, HasTheme, ValueOf } 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
  import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
@@ -56,7 +56,7 @@ const COMPONENT_NAME = 'ImageBlock';
56
56
  /**
57
57
  * Component default class name and class prefix.
58
58
  */
59
- const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-image-block';
59
+ const CLASSNAME = getRootClassName(COMPONENT_NAME);
60
60
 
61
61
  /**
62
62
  * Component default props.
@@ -4,7 +4,7 @@ import classNames from 'classnames';
4
4
 
5
5
  import { Lightbox } from '@lumx/react';
6
6
  import { ClickAwayProvider } from '@lumx/react/utils';
7
- import { useMergeRefs } from '@lumx/react/utils/mergeRefs';
7
+ import { useMergeRefs } from '@lumx/react/utils/react/mergeRefs';
8
8
  import { forwardRef } from '@lumx/react/utils/react/forwardRef';
9
9
 
10
10
  import { ImageSlideshow } from './internal/ImageSlideshow';
@@ -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 = 'ImageLightbox';
8
8
  /**
9
9
  * Component default class name and class prefix.
10
10
  */
11
- export const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-image-lightbox';
11
+ export const CLASSNAME = getRootClassName(COMPONENT_NAME);
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
 
3
3
  import { SlideshowItem, Thumbnail } from '@lumx/react';
4
- import { useMergeRefs } from '@lumx/react/utils/mergeRefs';
4
+ import { useMergeRefs } from '@lumx/react/utils/react/mergeRefs';
5
5
  import { useSizeOnWindowResize } from '@lumx/react/hooks/useSizeOnWindowResize';
6
6
  import { useImageSize } from '@lumx/react/hooks/useImageSize';
7
7
  import { isReducedMotion } from '@lumx/react/utils/browser/isReducedMotion';
@@ -2,9 +2,9 @@ import React from 'react';
2
2
 
3
3
  import { mdiMagnifyMinusOutline, mdiMagnifyPlusOutline } from '@lumx/icons';
4
4
  import { FlexBox, IconButton, Slides, SlideshowControls } from '@lumx/react';
5
- import { mergeRefs } from '@lumx/react/utils/mergeRefs';
6
- import { memoize } from '@lumx/react/utils/function/memoize';
5
+ import { mergeRefs } from '@lumx/react/utils/react/mergeRefs';
7
6
 
7
+ import memoize from 'lodash/memoize';
8
8
  import { ImageCaption } from '../../image-block/ImageCaption';
9
9
  import { CLASSNAME } from '../constants';
10
10
  import type { ImagesProps, InheritedSlideShowProps, ZoomButtonProps } from '../types';
@@ -113,9 +113,13 @@ export const ImageSlideshow: React.FC<ImageSlideshowProps> = ({
113
113
 
114
114
  const getImgRef = React.useMemo(
115
115
  () =>
116
- memoize((index: number, isActive: boolean) => {
117
- return mergeRefs(images?.[index].imgRef, isActive ? activeImageRef : undefined);
118
- }),
116
+ memoize(
117
+ (index: number, isActive: boolean) => {
118
+ return mergeRefs(images?.[index].imgRef, isActive ? activeImageRef : undefined);
119
+ },
120
+ // memoize based on both arguments
121
+ (...args) => args.join(),
122
+ ),
119
123
  [images, activeImageRef],
120
124
  );
121
125
 
@@ -1,8 +1,9 @@
1
1
  import React from 'react';
2
2
 
3
+ import memoize from 'lodash/memoize';
4
+
3
5
  import { startViewTransition } from '@lumx/react/utils/browser/DOM/startViewTransition';
4
6
  import { findImage } from '@lumx/react/utils/browser/DOM/findImage';
5
- import { memoize } from '@lumx/react/utils/function/memoize';
6
7
 
7
8
  import type { ImageLightboxProps } from './types';
8
9
  import { CLASSNAME } from './constants';
@@ -3,8 +3,8 @@ import React, { Children, isValidElement } from 'react';
3
3
  import classNames from 'classnames';
4
4
 
5
5
  import { ColorPalette, ColorVariant, Typography } from '@lumx/react';
6
- import type { GenericProps, ComponentClassName } from '@lumx/react/utils/type';
7
- import { getFontColorClassName, getTypographyClassName } from '@lumx/react/utils/className';
6
+ import { GenericProps } from '@lumx/react/utils/type';
7
+ import { getFontColorClassName, getRootClassName, getTypographyClassName } from '@lumx/react/utils/className';
8
8
  import { forwardRef } from '@lumx/react/utils/react/forwardRef';
9
9
 
10
10
  /**
@@ -27,6 +27,10 @@ export interface InlineListProps extends GenericProps {
27
27
  * Activate line wrap on overflow.
28
28
  */
29
29
  wrap?: boolean;
30
+ /**
31
+ * Children
32
+ */
33
+ children?: React.ReactNode;
30
34
  }
31
35
 
32
36
  /**
@@ -37,7 +41,7 @@ const COMPONENT_NAME = 'InlineList';
37
41
  /**
38
42
  * Component default class name and class prefix.
39
43
  */
40
- const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-inline-list';
44
+ const CLASSNAME = getRootClassName(COMPONENT_NAME);
41
45
 
42
46
  /**
43
47
  * Component default props.
@@ -3,8 +3,8 @@ import React, { ReactNode } from 'react';
3
3
  import classNames from 'classnames';
4
4
 
5
5
  import { Kind, 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 { forwardRef } from '@lumx/react/utils/react/forwardRef';
9
9
 
10
10
  import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
@@ -28,7 +28,7 @@ const COMPONENT_NAME = 'InputHelper';
28
28
  /**
29
29
  * Component default class name and class prefix.
30
30
  */
31
- const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-input-helper';
31
+ const CLASSNAME = getRootClassName(COMPONENT_NAME);
32
32
 
33
33
  /**
34
34
  * Component default props.
@@ -3,8 +3,8 @@ import React, { ReactNode } 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 { forwardRef } from '@lumx/react/utils/react/forwardRef';
9
9
  import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
10
10
 
@@ -28,7 +28,7 @@ const COMPONENT_NAME = 'InputLabel';
28
28
  /**
29
29
  * Component default class name and class prefix.
30
30
  */
31
- const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-input-label';
31
+ const CLASSNAME = getRootClassName(COMPONENT_NAME);
32
32
 
33
33
  /**
34
34
  * Component default props.
@@ -6,13 +6,13 @@ import { createPortal } from 'react-dom';
6
6
  import { mdiClose } from '@lumx/icons';
7
7
  import { IconButton, IconButtonProps } from '@lumx/react';
8
8
  import { DIALOG_TRANSITION_DURATION, DOCUMENT } from '@lumx/react/constants';
9
- import type { GenericProps, HasTheme, ComponentClassName } from '@lumx/react/utils/type';
10
- 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';
11
11
 
12
12
  import { useFocusTrap } from '@lumx/react/hooks/useFocusTrap';
13
13
  import { useDisableBodyScroll } from '@lumx/react/hooks/useDisableBodyScroll';
14
14
  import { ClickAwayProvider } from '@lumx/react/utils/ClickAwayProvider';
15
- import { mergeRefs } from '@lumx/react/utils/mergeRefs';
15
+ import { mergeRefs } from '@lumx/react/utils/react/mergeRefs';
16
16
  import { useCallbackOnEscape } from '@lumx/react/hooks/useCallbackOnEscape';
17
17
  import { useTransitionVisibility } from '@lumx/react/hooks/useTransitionVisibility';
18
18
  import { ThemeProvider } from '@lumx/react/utils/theme/ThemeContext';
@@ -37,6 +37,8 @@ export interface LightboxProps extends GenericProps, HasTheme, Pick<AriaAttribut
37
37
  zIndex?: number;
38
38
  /** On close callback. */
39
39
  onClose?(): void;
40
+ /** Children */
41
+ children?: React.ReactNode;
40
42
  }
41
43
 
42
44
  /**
@@ -47,7 +49,7 @@ const COMPONENT_NAME = 'Lightbox';
47
49
  /**
48
50
  * Component default class name and class prefix.
49
51
  */
50
- const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-lightbox';
52
+ const CLASSNAME = getRootClassName(COMPONENT_NAME);
51
53
 
52
54
  /**
53
55
  * Lightbox component.
@@ -1,11 +1,13 @@
1
1
  import React, { RefObject, useMemo } from 'react';
2
2
 
3
+ import isEmpty from 'lodash/isEmpty';
4
+
3
5
  import classNames from 'classnames';
4
6
 
5
7
  import { ColorPalette, ColorVariant, Icon, Size, Typography } from '@lumx/react';
6
- import type { GenericProps, ComponentClassName } from '@lumx/react/utils/type';
7
- import { handleBasicClasses } from '@lumx/react/utils/className';
8
- import { renderLink } from '@lumx/react/utils/renderLink';
8
+ import { GenericProps } from '@lumx/react/utils/type';
9
+ import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
10
+ import { renderLink } from '@lumx/react/utils/react/renderLink';
9
11
  import { forwardRef } from '@lumx/react/utils/react/forwardRef';
10
12
 
11
13
  type HTMLAnchorProps = React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>;
@@ -32,6 +34,8 @@ export interface LinkProps extends GenericProps {
32
34
  target?: HTMLAnchorProps['target'];
33
35
  /** Typography variant. */
34
36
  typography?: Typography;
37
+ /** Children */
38
+ children?: React.ReactNode;
35
39
  }
36
40
 
37
41
  /**
@@ -42,7 +46,7 @@ const COMPONENT_NAME = 'Link';
42
46
  /**
43
47
  * Component default class name and class prefix.
44
48
  */
45
- const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-link';
49
+ const CLASSNAME = getRootClassName(COMPONENT_NAME);
46
50
 
47
51
  const getIconSize = (typography?: Typography) => {
48
52
  switch (typography) {
@@ -100,7 +104,7 @@ export const Link = forwardRef<LinkProps, HTMLAnchorElement | HTMLButtonElement>
100
104
  const renderedChildren = useMemo(
101
105
  () => (
102
106
  <>
103
- {leftIcon && (
107
+ {leftIcon && !isEmpty(leftIcon) && (
104
108
  <Icon icon={leftIcon} className={`${CLASSNAME}__left-icon`} size={getIconSize(typography)} />
105
109
  )}
106
110
 
@@ -114,7 +118,7 @@ export const Link = forwardRef<LinkProps, HTMLAnchorElement | HTMLButtonElement>
114
118
  </span>
115
119
  )}
116
120
 
117
- {rightIcon && (
121
+ {rightIcon && !isEmpty(rightIcon) && (
118
122
  <Icon icon={rightIcon} className={`${CLASSNAME}__right-icon`} size={getIconSize(typography)} />
119
123
  )}
120
124
  </>
@@ -126,7 +130,7 @@ export const Link = forwardRef<LinkProps, HTMLAnchorElement | HTMLButtonElement>
126
130
  * If there is no linkAs prop and no href, we returned a <button> instead of a <a>.
127
131
  * If the component is disabled, we also returned a <button> since disabled is not compatible with <a>.
128
132
  */
129
- if ((!linkAs && href) || isDisabled) {
133
+ if ((!linkAs && isEmpty(href)) || isDisabled) {
130
134
  return (
131
135
  <button
132
136
  type="button"
@@ -14,8 +14,8 @@ import {
14
14
  ThumbnailProps,
15
15
  } from '@lumx/react';
16
16
 
17
- import type { GenericProps, HeadingElement, HasTheme, ComponentClassName } from '@lumx/react/utils/type';
18
- import { handleBasicClasses } from '@lumx/react/utils/className';
17
+ import { GenericProps, HeadingElement, HasTheme } from '@lumx/react/utils/type';
18
+ import { getRootClassName, handleBasicClasses } from '@lumx/react/utils/className';
19
19
  import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
20
20
  import { forwardRef } from '@lumx/react/utils/react/forwardRef';
21
21
 
@@ -49,7 +49,7 @@ const COMPONENT_NAME = 'LinkPreview';
49
49
  /**
50
50
  * Component default class name and class prefix.
51
51
  */
52
- const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-link-preview';
52
+ const CLASSNAME = getRootClassName(COMPONENT_NAME);
53
53
 
54
54
  /**
55
55
  * Component default props.