@lumx/react 3.10.1-alpha.5 → 3.10.1-alpha.7
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.
- package/_internal/Falsy.d.ts +7 -0
- package/index.d.ts +291 -5
- package/index.js +167 -267
- package/index.js.map +1 -1
- package/package.json +3 -3
- package/src/components/alert-dialog/AlertDialog.tsx +3 -2
- package/src/components/autocomplete/Autocomplete.tsx +2 -2
- package/src/components/autocomplete/AutocompleteMultiple.tsx +2 -2
- package/src/components/avatar/Avatar.tsx +3 -3
- package/src/components/badge/Badge.tsx +3 -3
- package/src/components/badge/BadgeWrapper.tsx +2 -3
- package/src/components/button/Button.tsx +4 -4
- package/src/components/button/ButtonGroup.tsx +2 -3
- package/src/components/button/IconButton.tsx +2 -2
- package/src/components/checkbox/Checkbox.tsx +3 -3
- package/src/components/chip/Chip.tsx +3 -3
- package/src/components/chip/ChipGroup.tsx +2 -3
- package/src/components/comment-block/CommentBlock.tsx +3 -3
- package/src/components/date-picker/constants.ts +2 -2
- package/src/components/dialog/Dialog.tsx +5 -5
- package/src/components/divider/Divider.tsx +3 -3
- package/src/components/drag-handle/DragHandle.tsx +3 -3
- package/src/components/dropdown/Dropdown.tsx +3 -4
- package/src/components/expansion-panel/ExpansionPanel.tsx +6 -6
- package/src/components/flag/Flag.tsx +3 -3
- package/src/components/flex-box/FlexBox.tsx +3 -3
- package/src/components/generic-block/GenericBlock.tsx +2 -3
- package/src/components/grid/Grid.tsx +3 -3
- package/src/components/grid/GridItem.tsx +3 -3
- package/src/components/grid-column/GridColumn.tsx +2 -3
- package/src/components/heading/Heading.tsx +2 -3
- package/src/components/icon/Icon.tsx +3 -3
- package/src/components/image-block/ImageBlock.tsx +3 -3
- package/src/components/image-lightbox/constants.ts +2 -2
- package/src/components/inline-list/InlineList.tsx +3 -3
- package/src/components/input-helper/InputHelper.tsx +3 -3
- package/src/components/input-label/InputLabel.tsx +3 -3
- package/src/components/lightbox/Lightbox.tsx +3 -3
- package/src/components/link/Link.tsx +3 -3
- package/src/components/link-preview/LinkPreview.tsx +3 -3
- package/src/components/list/List.tsx +3 -3
- package/src/components/list/ListDivider.tsx +2 -3
- package/src/components/list/ListItem.tsx +3 -3
- package/src/components/list/ListSubheader.tsx +2 -3
- package/src/components/list/useInteractiveList.tsx +3 -3
- package/src/components/message/Message.tsx +3 -3
- package/src/components/mosaic/Mosaic.tsx +3 -3
- package/src/components/navigation/Navigation.tsx +3 -3
- package/src/components/navigation/NavigationItem.tsx +9 -3
- package/src/components/navigation/NavigationSection.tsx +3 -3
- package/src/components/notification/Notification.tsx +3 -3
- package/src/components/popover/Popover.tsx +3 -3
- package/src/components/popover-dialog/PopoverDialog.tsx +2 -3
- package/src/components/post-block/PostBlock.tsx +3 -3
- package/src/components/progress/Progress.tsx +3 -3
- package/src/components/progress/ProgressCircular.tsx +3 -3
- package/src/components/progress/ProgressLinear.tsx +3 -3
- package/src/components/progress-tracker/ProgressTracker.tsx +2 -3
- package/src/components/progress-tracker/ProgressTrackerStep.tsx +3 -3
- package/src/components/radio-button/RadioButton.tsx +3 -3
- package/src/components/radio-button/RadioGroup.tsx +2 -3
- package/src/components/select/Select.tsx +3 -2
- package/src/components/select/SelectMultiple.tsx +3 -2
- package/src/components/select/WithSelectContext.tsx +3 -2
- package/src/components/side-navigation/SideNavigation.tsx +3 -4
- package/src/components/side-navigation/SideNavigationItem.tsx +4 -4
- package/src/components/skeleton/SkeletonCircle.tsx +3 -3
- package/src/components/skeleton/SkeletonRectangle.tsx +3 -3
- package/src/components/skeleton/SkeletonTypography.tsx +3 -3
- package/src/components/slider/Slider.tsx +3 -3
- package/src/components/slideshow/Slides.tsx +3 -3
- package/src/components/slideshow/SlideshowControls.tsx +3 -3
- package/src/components/slideshow/SlideshowItem.tsx +2 -3
- package/src/components/slideshow/SlideshowItemGroup.tsx +2 -3
- package/src/components/switch/Switch.tsx +3 -3
- package/src/components/table/Table.tsx +3 -3
- package/src/components/table/TableBody.tsx +2 -3
- package/src/components/table/TableCell.tsx +3 -3
- package/src/components/table/TableHeader.tsx +2 -3
- package/src/components/table/TableRow.tsx +3 -3
- package/src/components/text/Text.tsx +4 -9
- package/src/components/text-field/TextField.tsx +3 -3
- package/src/components/thumbnail/Thumbnail.tsx +3 -3
- package/src/components/toolbar/Toolbar.tsx +3 -3
- package/src/components/tooltip/Tooltip.tsx +3 -3
- package/src/components/uploader/Uploader.tsx +3 -3
- package/src/components/user-block/UserBlock.tsx +3 -3
- package/src/utils/className/index.ts +0 -1
- package/src/utils/className.test.js +41 -0
- package/src/utils/type/Callback.ts +4 -0
- package/src/utils/type/Comp.ts +14 -0
- package/src/utils/type/ComponentClassName.ts +7 -0
- package/src/utils/type/ComponentRef.ts +16 -0
- package/src/utils/type/Falsy.ts +5 -0
- package/src/utils/type/GenericProps.ts +11 -0
- package/src/utils/type/HasAriaLabelOrLabelledBy.ts +19 -0
- package/src/utils/type/HasClassName.ts +6 -0
- package/src/utils/type/HasCloseMode.ts +7 -0
- package/src/utils/type/HasPolymorphicAs.ts +8 -0
- package/src/utils/type/HasTheme.ts +8 -0
- package/src/utils/type/HeadingElement.ts +2 -0
- package/src/utils/type/KebabCase.ts +6 -0
- package/src/utils/type/MaybeElementOrRef.ts +6 -0
- package/src/utils/type/Point.ts +4 -0
- package/src/utils/type/Predicate.ts +2 -0
- package/src/utils/type/RectSize.ts +4 -0
- package/src/utils/type/TextElement.ts +4 -0
- package/src/utils/type/ValueOf.ts +2 -0
- package/src/utils/type/index.ts +19 -0
- package/src/utils/type/isComponentType.ts +9 -0
- package/utils/index.d.ts +1 -1
- package/_internal/index.d.ts +0 -285
- package/src/utils/className/getRootClassName.test.ts +0 -11
- package/src/utils/className/getRootClassName.ts +0 -24
- package/src/utils/type.ts +0 -164
|
@@ -7,8 +7,9 @@ import { Dropdown } from '@lumx/react/components/dropdown/Dropdown';
|
|
|
7
7
|
import { InputHelper } from '@lumx/react/components/input-helper/InputHelper';
|
|
8
8
|
import { useFocusTrap } from '@lumx/react/hooks/useFocusTrap';
|
|
9
9
|
import { useListenFocus } from '@lumx/react/hooks/useListenFocus';
|
|
10
|
-
import {
|
|
10
|
+
import { handleBasicClasses } from '@lumx/react/utils/className';
|
|
11
11
|
import { mergeRefs } from '@lumx/react/utils/mergeRefs';
|
|
12
|
+
import type { ComponentClassName } from '@lumx/react/utils/type';
|
|
12
13
|
|
|
13
14
|
import { useId } from '@lumx/react/hooks/useId';
|
|
14
15
|
import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
|
|
@@ -18,7 +19,7 @@ import { CoreSelectProps, SelectVariant } from './constants';
|
|
|
18
19
|
const COMPONENT_NAME = 'Select';
|
|
19
20
|
|
|
20
21
|
/** The default class name and classes prefix for this component. */
|
|
21
|
-
const CLASSNAME =
|
|
22
|
+
const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-select';
|
|
22
23
|
|
|
23
24
|
/** The default value of props. */
|
|
24
25
|
export const DEFAULT_PROPS: Partial<CoreSelectProps> = {
|
|
@@ -3,8 +3,7 @@ import React, { Children, ReactNode } from 'react';
|
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
|
|
5
5
|
import { SideNavigationItem, Theme } from '@lumx/react';
|
|
6
|
-
import { GenericProps, HasTheme,
|
|
7
|
-
import { getRootClassName } from '@lumx/react/utils/className';
|
|
6
|
+
import { type GenericProps, type HasTheme, isComponentType, type ComponentClassName } from '@lumx/react/utils/type';
|
|
8
7
|
import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
|
|
9
8
|
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
10
9
|
|
|
@@ -24,7 +23,7 @@ const COMPONENT_NAME = 'SideNavigation';
|
|
|
24
23
|
/**
|
|
25
24
|
* Component default class name and class prefix.
|
|
26
25
|
*/
|
|
27
|
-
const CLASSNAME =
|
|
26
|
+
const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-side-navigation';
|
|
28
27
|
|
|
29
28
|
/**
|
|
30
29
|
* SideNavigation component.
|
|
@@ -36,7 +35,7 @@ const CLASSNAME = getRootClassName(COMPONENT_NAME);
|
|
|
36
35
|
export const SideNavigation = forwardRef<SideNavigationProps, HTMLUListElement>((props, ref) => {
|
|
37
36
|
const defaultTheme = useTheme();
|
|
38
37
|
const { children, className, theme = defaultTheme, ...forwardedProps } = props;
|
|
39
|
-
const content = Children.toArray(children).filter(
|
|
38
|
+
const content = Children.toArray(children).filter(isComponentType(SideNavigationItem));
|
|
40
39
|
|
|
41
40
|
return (
|
|
42
41
|
<ul
|
|
@@ -4,8 +4,8 @@ import classNames from 'classnames';
|
|
|
4
4
|
|
|
5
5
|
import { mdiChevronDown, mdiChevronUp } from '@lumx/icons';
|
|
6
6
|
import { Emphasis, Icon, Size, IconButton, IconButtonProps } from '@lumx/react';
|
|
7
|
-
import { GenericProps, HasCloseMode,
|
|
8
|
-
import {
|
|
7
|
+
import { type GenericProps, type HasCloseMode, isComponentType, type ComponentClassName } from '@lumx/react/utils/type';
|
|
8
|
+
import { handleBasicClasses } from '@lumx/react/utils/className';
|
|
9
9
|
import { renderLink } from '@lumx/react/utils/renderLink';
|
|
10
10
|
import { renderButtonOrLink } from '@lumx/react/utils/renderButtonOrLink';
|
|
11
11
|
import { useId } from '@lumx/react/hooks/useId';
|
|
@@ -49,7 +49,7 @@ const COMPONENT_NAME = 'SideNavigationItem';
|
|
|
49
49
|
/**
|
|
50
50
|
* Component default class name and class prefix.
|
|
51
51
|
*/
|
|
52
|
-
const CLASSNAME =
|
|
52
|
+
const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-side-navigation-item';
|
|
53
53
|
|
|
54
54
|
/**
|
|
55
55
|
* Component default props.
|
|
@@ -84,7 +84,7 @@ export const SideNavigationItem = forwardRef<SideNavigationItemProps, HTMLLIElem
|
|
|
84
84
|
...forwardedProps
|
|
85
85
|
} = props;
|
|
86
86
|
|
|
87
|
-
const content = children && Children.toArray(children).filter(
|
|
87
|
+
const content = children && Children.toArray(children).filter(isComponentType(SideNavigationItem));
|
|
88
88
|
const hasContent = !isEmpty(content);
|
|
89
89
|
const shouldSplitActions = Boolean(onActionClick);
|
|
90
90
|
const showChildren = hasContent && isOpen;
|
|
@@ -3,8 +3,8 @@ import React from 'react';
|
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
|
|
5
5
|
import { GlobalSize, Theme, ColorPalette } from '@lumx/react';
|
|
6
|
-
import { GenericProps, HasTheme } from '@lumx/react/utils/type';
|
|
7
|
-
import {
|
|
6
|
+
import type { GenericProps, HasTheme, ComponentClassName } from '@lumx/react/utils/type';
|
|
7
|
+
import { 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
|
|
|
@@ -28,7 +28,7 @@ const COMPONENT_NAME = 'SkeletonCircle';
|
|
|
28
28
|
/**
|
|
29
29
|
* Component default class name and class prefix.
|
|
30
30
|
*/
|
|
31
|
-
const CLASSNAME =
|
|
31
|
+
const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-skeleton-circle';
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
34
|
* SkeletonCircle component.
|
|
@@ -3,8 +3,8 @@ import React from 'react';
|
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
|
|
5
5
|
import { AspectRatio, GlobalSize, Theme, ColorPalette } from '@lumx/react';
|
|
6
|
-
import { GenericProps, HasTheme, ValueOf } from '@lumx/react/utils/type';
|
|
7
|
-
import {
|
|
6
|
+
import type { GenericProps, HasTheme, ValueOf, ComponentClassName } from '@lumx/react/utils/type';
|
|
7
|
+
import { 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
|
|
|
@@ -42,7 +42,7 @@ const COMPONENT_NAME = 'SkeletonRectangle';
|
|
|
42
42
|
/**
|
|
43
43
|
* Component default class name and class prefix.
|
|
44
44
|
*/
|
|
45
|
-
const CLASSNAME =
|
|
45
|
+
const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-skeleton-rectangle';
|
|
46
46
|
|
|
47
47
|
/**
|
|
48
48
|
* SkeletonRectangle component.
|
|
@@ -3,8 +3,8 @@ import React, { CSSProperties } from 'react';
|
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
|
|
5
5
|
import { Theme, TypographyInterface, ColorPalette } from '@lumx/react';
|
|
6
|
-
import { GenericProps, HasTheme } from '@lumx/react/utils/type';
|
|
7
|
-
import {
|
|
6
|
+
import type { GenericProps, HasTheme, ComponentClassName } from '@lumx/react/utils/type';
|
|
7
|
+
import { 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
|
|
|
@@ -30,7 +30,7 @@ const COMPONENT_NAME = 'SkeletonTypography';
|
|
|
30
30
|
/**
|
|
31
31
|
* Component default class name and class prefix.
|
|
32
32
|
*/
|
|
33
|
-
const CLASSNAME =
|
|
33
|
+
const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-skeleton-typography';
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
36
|
* SkeletonTypography component.
|
|
@@ -5,8 +5,8 @@ import classNames from 'classnames';
|
|
|
5
5
|
|
|
6
6
|
import { InputHelper, InputLabel, Theme } from '@lumx/react';
|
|
7
7
|
import useEventCallback from '@lumx/react/hooks/useEventCallback';
|
|
8
|
-
import { GenericProps, HasTheme } from '@lumx/react/utils/type';
|
|
9
|
-
import {
|
|
8
|
+
import type { GenericProps, HasTheme, ComponentClassName } from '@lumx/react/utils/type';
|
|
9
|
+
import { handleBasicClasses } from '@lumx/react/utils/className';
|
|
10
10
|
import { clamp } from '@lumx/react/utils/clamp';
|
|
11
11
|
import { useId } from '@lumx/react/hooks/useId';
|
|
12
12
|
import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
|
|
@@ -50,7 +50,7 @@ const COMPONENT_NAME = 'Slider';
|
|
|
50
50
|
/**
|
|
51
51
|
* Component default class name and class prefix.
|
|
52
52
|
*/
|
|
53
|
-
const CLASSNAME =
|
|
53
|
+
const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-slider';
|
|
54
54
|
|
|
55
55
|
/**
|
|
56
56
|
* Component default props.
|
|
@@ -3,8 +3,8 @@ import React, { Children, CSSProperties } from 'react';
|
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
|
|
5
5
|
import { FULL_WIDTH_PERCENT } from '@lumx/react/components/slideshow/constants';
|
|
6
|
-
import { GenericProps, HasTheme } from '@lumx/react/utils/type';
|
|
7
|
-
import {
|
|
6
|
+
import type { GenericProps, HasTheme, ComponentClassName } from '@lumx/react/utils/type';
|
|
7
|
+
import { 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
|
import { chunk } from '@lumx/react/utils/collection/chunk';
|
|
@@ -47,7 +47,7 @@ const COMPONENT_NAME = 'Slideshow';
|
|
|
47
47
|
/**
|
|
48
48
|
* Component default class name and class prefix.
|
|
49
49
|
*/
|
|
50
|
-
const CLASSNAME =
|
|
50
|
+
const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-slideshow';
|
|
51
51
|
|
|
52
52
|
/**
|
|
53
53
|
* Slides component.
|
|
@@ -4,8 +4,8 @@ import classNames from 'classnames';
|
|
|
4
4
|
|
|
5
5
|
import { mdiChevronLeft, mdiChevronRight, mdiPlayCircleOutline, mdiPauseCircleOutline } from '@lumx/icons';
|
|
6
6
|
import { Emphasis, IconButton, IconButtonProps, Theme } from '@lumx/react';
|
|
7
|
-
import { GenericProps, HasTheme } from '@lumx/react/utils/type';
|
|
8
|
-
import {
|
|
7
|
+
import type { GenericProps, HasTheme, ComponentClassName } from '@lumx/react/utils/type';
|
|
8
|
+
import { handleBasicClasses } from '@lumx/react/utils/className';
|
|
9
9
|
import { WINDOW } from '@lumx/react/constants';
|
|
10
10
|
import { useSlideshowControls, DEFAULT_OPTIONS } from '@lumx/react/hooks/useSlideshowControls';
|
|
11
11
|
import { useRovingTabIndex } from '@lumx/react/hooks/useRovingTabIndex';
|
|
@@ -65,7 +65,7 @@ const COMPONENT_NAME = 'SlideshowControls';
|
|
|
65
65
|
/**
|
|
66
66
|
* Component default class name and class prefix.
|
|
67
67
|
*/
|
|
68
|
-
const CLASSNAME =
|
|
68
|
+
const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-slideshow-controls';
|
|
69
69
|
|
|
70
70
|
/**
|
|
71
71
|
* Component default props.
|
|
@@ -2,8 +2,7 @@ import React from 'react';
|
|
|
2
2
|
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
|
|
5
|
-
import { GenericProps } from '@lumx/react/utils/type';
|
|
6
|
-
import { getRootClassName } from '@lumx/react/utils/className';
|
|
5
|
+
import type { GenericProps, ComponentClassName } from '@lumx/react/utils/type';
|
|
7
6
|
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
8
7
|
|
|
9
8
|
/**
|
|
@@ -22,7 +21,7 @@ const COMPONENT_NAME = 'SlideshowItem';
|
|
|
22
21
|
/**
|
|
23
22
|
* Component default class name and class prefix.
|
|
24
23
|
*/
|
|
25
|
-
const CLASSNAME =
|
|
24
|
+
const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-slideshow-item';
|
|
26
25
|
|
|
27
26
|
/**
|
|
28
27
|
* SlideshowItem component.
|
|
@@ -2,8 +2,7 @@ import React from 'react';
|
|
|
2
2
|
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
import { mergeRefs } from '@lumx/react/utils/mergeRefs';
|
|
5
|
-
import { GenericProps } from '@lumx/react/utils/type';
|
|
6
|
-
import { getRootClassName } from '@lumx/react/utils/className';
|
|
5
|
+
import type { GenericProps, ComponentClassName } from '@lumx/react/utils/type';
|
|
7
6
|
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
8
7
|
import { useSlideFocusManagement } from './useSlideFocusManagement';
|
|
9
8
|
|
|
@@ -24,7 +23,7 @@ const COMPONENT_NAME = 'SlideshowItemGroup';
|
|
|
24
23
|
/**
|
|
25
24
|
* Component default class name and class prefix.
|
|
26
25
|
*/
|
|
27
|
-
export const CLASSNAME =
|
|
26
|
+
export const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-slideshow-item-group';
|
|
28
27
|
|
|
29
28
|
export const buildSlideShowGroupId = (slidesId: string, index: number) => `${slidesId}-slide-${index}`;
|
|
30
29
|
|
|
@@ -3,8 +3,8 @@ import React, { Children, InputHTMLAttributes, SyntheticEvent } from 'react';
|
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
|
|
5
5
|
import { Alignment, InputHelper, InputLabel, Theme } from '@lumx/react';
|
|
6
|
-
import { GenericProps, HasTheme } from '@lumx/react/utils/type';
|
|
7
|
-
import {
|
|
6
|
+
import type { GenericProps, HasTheme, ComponentClassName } from '@lumx/react/utils/type';
|
|
7
|
+
import { handleBasicClasses } from '@lumx/react/utils/className';
|
|
8
8
|
import { useId } from '@lumx/react/hooks/useId';
|
|
9
9
|
import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
|
|
10
10
|
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
@@ -39,7 +39,7 @@ const COMPONENT_NAME = 'Switch';
|
|
|
39
39
|
/**
|
|
40
40
|
* Component default class name and class prefix.
|
|
41
41
|
*/
|
|
42
|
-
const CLASSNAME =
|
|
42
|
+
const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-switch';
|
|
43
43
|
|
|
44
44
|
/**
|
|
45
45
|
* 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 { GenericProps, HasTheme } from '@lumx/react/utils/type';
|
|
7
|
-
import {
|
|
6
|
+
import type { GenericProps, HasTheme, ComponentClassName } from '@lumx/react/utils/type';
|
|
7
|
+
import { 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
|
|
|
@@ -26,7 +26,7 @@ const COMPONENT_NAME = 'Table';
|
|
|
26
26
|
/**
|
|
27
27
|
* Component default class name and class prefix.
|
|
28
28
|
*/
|
|
29
|
-
const CLASSNAME =
|
|
29
|
+
const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-table';
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
32
|
* Component default props.
|
|
@@ -2,8 +2,7 @@ import React from 'react';
|
|
|
2
2
|
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
|
|
5
|
-
import { GenericProps } from '@lumx/react/utils/type';
|
|
6
|
-
import { getRootClassName } from '@lumx/react/utils/className';
|
|
5
|
+
import type { ComponentClassName, GenericProps } from '@lumx/react/utils/type';
|
|
7
6
|
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
8
7
|
|
|
9
8
|
/**
|
|
@@ -19,7 +18,7 @@ const COMPONENT_NAME = 'TableBody';
|
|
|
19
18
|
/**
|
|
20
19
|
* Component default class name and class prefix.
|
|
21
20
|
*/
|
|
22
|
-
const CLASSNAME
|
|
21
|
+
const CLASSNAME: ComponentClassName<'Table', typeof COMPONENT_NAME> = 'lumx-table__body';
|
|
23
22
|
|
|
24
23
|
/**
|
|
25
24
|
* TableBody component.
|
|
@@ -4,8 +4,8 @@ import classNames from 'classnames';
|
|
|
4
4
|
|
|
5
5
|
import { mdiArrowDown, mdiArrowUp } from '@lumx/icons';
|
|
6
6
|
import { Icon, Size } from '@lumx/react';
|
|
7
|
-
import { GenericProps, ValueOf } from '@lumx/react/utils/type';
|
|
8
|
-
import {
|
|
7
|
+
import type { ComponentClassName, GenericProps, ValueOf } from '@lumx/react/utils/type';
|
|
8
|
+
import { handleBasicClasses } from '@lumx/react/utils/className';
|
|
9
9
|
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
10
10
|
|
|
11
11
|
/**
|
|
@@ -44,7 +44,7 @@ const COMPONENT_NAME = 'TableCell';
|
|
|
44
44
|
/**
|
|
45
45
|
* Component default class name and class prefix.
|
|
46
46
|
*/
|
|
47
|
-
const CLASSNAME
|
|
47
|
+
const CLASSNAME: ComponentClassName<'Table', typeof COMPONENT_NAME> = 'lumx-table__cell';
|
|
48
48
|
|
|
49
49
|
/**
|
|
50
50
|
* Component default props.
|
|
@@ -2,8 +2,7 @@ import React from 'react';
|
|
|
2
2
|
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
|
|
5
|
-
import { GenericProps } from '@lumx/react/utils/type';
|
|
6
|
-
import { getRootClassName } from '@lumx/react/utils/className';
|
|
5
|
+
import type { ComponentClassName, GenericProps } from '@lumx/react/utils/type';
|
|
7
6
|
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
8
7
|
|
|
9
8
|
/**
|
|
@@ -19,7 +18,7 @@ const COMPONENT_NAME = 'TableHeader';
|
|
|
19
18
|
/**
|
|
20
19
|
* Component default class name and class prefix.
|
|
21
20
|
*/
|
|
22
|
-
const CLASSNAME
|
|
21
|
+
const CLASSNAME: ComponentClassName<'Table', typeof COMPONENT_NAME> = 'lumx-table__header';
|
|
23
22
|
|
|
24
23
|
/**
|
|
25
24
|
* Component default props.
|
|
@@ -2,8 +2,8 @@ import React from 'react';
|
|
|
2
2
|
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
|
|
5
|
-
import { GenericProps } from '@lumx/react/utils/type';
|
|
6
|
-
import {
|
|
5
|
+
import type { ComponentClassName, GenericProps } from '@lumx/react/utils/type';
|
|
6
|
+
import { handleBasicClasses } from '@lumx/react/utils/className';
|
|
7
7
|
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -26,7 +26,7 @@ const COMPONENT_NAME = 'TableRow';
|
|
|
26
26
|
/**
|
|
27
27
|
* Component default class name and class prefix.
|
|
28
28
|
*/
|
|
29
|
-
const CLASSNAME
|
|
29
|
+
const CLASSNAME: ComponentClassName<'Table', typeof COMPONENT_NAME> = 'lumx-table__row';
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
32
|
* Component default props.
|
|
@@ -3,13 +3,8 @@ import React, { Children, Fragment } from 'react';
|
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
|
|
5
5
|
import { Icon, ColorPalette, ColorVariant, Typography, WhiteSpace } from '@lumx/react';
|
|
6
|
-
import { GenericProps, TextElement,
|
|
7
|
-
import {
|
|
8
|
-
getFontColorClassName,
|
|
9
|
-
getRootClassName,
|
|
10
|
-
handleBasicClasses,
|
|
11
|
-
getTypographyClassName,
|
|
12
|
-
} from '@lumx/react/utils/className';
|
|
6
|
+
import { type GenericProps, type TextElement, isComponentType, type ComponentClassName } from '@lumx/react/utils/type';
|
|
7
|
+
import { getFontColorClassName, handleBasicClasses, getTypographyClassName } from '@lumx/react/utils/className';
|
|
13
8
|
import { useOverflowTooltipLabel } from '@lumx/react/hooks/useOverflowTooltipLabel';
|
|
14
9
|
import { useMergeRefs } from '@lumx/react/utils/mergeRefs';
|
|
15
10
|
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
@@ -61,7 +56,7 @@ const COMPONENT_NAME = 'Text';
|
|
|
61
56
|
/**
|
|
62
57
|
* Component default class name and class prefix.
|
|
63
58
|
*/
|
|
64
|
-
const CLASSNAME =
|
|
59
|
+
const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-text';
|
|
65
60
|
|
|
66
61
|
/**
|
|
67
62
|
* Component default props.
|
|
@@ -131,7 +126,7 @@ export const Text = forwardRef<TextProps>((props, ref) => {
|
|
|
131
126
|
{children &&
|
|
132
127
|
Children.toArray(children).map((child, index) => {
|
|
133
128
|
// Force wrap spaces around icons to make sure they are never stuck against text.
|
|
134
|
-
if (
|
|
129
|
+
if (isComponentType(Icon)(child)) {
|
|
135
130
|
return <Fragment key={child.key || index}> {child} </Fragment>;
|
|
136
131
|
}
|
|
137
132
|
return child;
|
|
@@ -15,8 +15,8 @@ import {
|
|
|
15
15
|
Size,
|
|
16
16
|
Theme,
|
|
17
17
|
} from '@lumx/react';
|
|
18
|
-
import { GenericProps, HasTheme } from '@lumx/react/utils/type';
|
|
19
|
-
import {
|
|
18
|
+
import type { GenericProps, HasTheme, ComponentClassName } from '@lumx/react/utils/type';
|
|
19
|
+
import { handleBasicClasses } from '@lumx/react/utils/className';
|
|
20
20
|
import { mergeRefs } from '@lumx/react/utils/mergeRefs';
|
|
21
21
|
import { useId } from '@lumx/react/hooks/useId';
|
|
22
22
|
import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
|
|
@@ -91,7 +91,7 @@ const COMPONENT_NAME = 'TextField';
|
|
|
91
91
|
/**
|
|
92
92
|
* Component default class name and class prefix.
|
|
93
93
|
*/
|
|
94
|
-
const CLASSNAME =
|
|
94
|
+
const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-text-field';
|
|
95
95
|
|
|
96
96
|
/**
|
|
97
97
|
* Default minimum number of rows in the multiline mode.
|
|
@@ -12,8 +12,8 @@ import React, {
|
|
|
12
12
|
import classNames from 'classnames';
|
|
13
13
|
|
|
14
14
|
import { AspectRatio, HorizontalAlignment, Icon, Size, Theme, ThumbnailObjectFit } from '@lumx/react';
|
|
15
|
-
import { Falsy, GenericProps, HasTheme } from '@lumx/react/utils/type';
|
|
16
|
-
import {
|
|
15
|
+
import type { Falsy, GenericProps, HasTheme, ComponentClassName } from '@lumx/react/utils/type';
|
|
16
|
+
import { handleBasicClasses } from '@lumx/react/utils/className';
|
|
17
17
|
import { mdiImageBroken } from '@lumx/icons';
|
|
18
18
|
import { useMergeRefs } from '@lumx/react/utils/mergeRefs';
|
|
19
19
|
import { useImageLoad } from '@lumx/react/components/thumbnail/useImageLoad';
|
|
@@ -81,7 +81,7 @@ const COMPONENT_NAME = 'Thumbnail';
|
|
|
81
81
|
/**
|
|
82
82
|
* Component default class name and class prefix.
|
|
83
83
|
*/
|
|
84
|
-
const CLASSNAME =
|
|
84
|
+
const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-thumbnail';
|
|
85
85
|
|
|
86
86
|
/**
|
|
87
87
|
* Component default props.
|
|
@@ -2,8 +2,8 @@ import React, { ReactNode } from 'react';
|
|
|
2
2
|
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
|
|
5
|
-
import { GenericProps } from '@lumx/react/utils/type';
|
|
6
|
-
import {
|
|
5
|
+
import { GenericProps, ComponentClassName } from '@lumx/react/utils/type';
|
|
6
|
+
import { handleBasicClasses } from '@lumx/react/utils/className';
|
|
7
7
|
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -26,7 +26,7 @@ const COMPONENT_NAME = 'Toolbar';
|
|
|
26
26
|
/**
|
|
27
27
|
* Component default class name and class prefix.
|
|
28
28
|
*/
|
|
29
|
-
const CLASSNAME =
|
|
29
|
+
const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-toolbar';
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
32
|
* Component default props.
|
|
@@ -5,8 +5,8 @@ import { createPortal } from 'react-dom';
|
|
|
5
5
|
import classNames from 'classnames';
|
|
6
6
|
|
|
7
7
|
import { DOCUMENT, VISUALLY_HIDDEN } from '@lumx/react/constants';
|
|
8
|
-
import { GenericProps, HasCloseMode } from '@lumx/react/utils/type';
|
|
9
|
-
import {
|
|
8
|
+
import type { GenericProps, HasCloseMode, ComponentClassName } from '@lumx/react/utils/type';
|
|
9
|
+
import { handleBasicClasses } from '@lumx/react/utils/className';
|
|
10
10
|
import { useMergeRefs } from '@lumx/react/utils/mergeRefs';
|
|
11
11
|
import { Placement } from '@lumx/react/components/popover';
|
|
12
12
|
import { TooltipContextProvider } from '@lumx/react/components/tooltip/context';
|
|
@@ -47,7 +47,7 @@ const COMPONENT_NAME = 'Tooltip';
|
|
|
47
47
|
/**
|
|
48
48
|
* Component default class name and class prefix.
|
|
49
49
|
*/
|
|
50
|
-
const CLASSNAME =
|
|
50
|
+
const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-tooltip';
|
|
51
51
|
|
|
52
52
|
/**
|
|
53
53
|
* Component default props.
|
|
@@ -3,8 +3,8 @@ import React, { MouseEventHandler } from 'react';
|
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
|
|
5
5
|
import { AspectRatio, Icon, Size, Theme } from '@lumx/react';
|
|
6
|
-
import { GenericProps, HasTheme, ValueOf } from '@lumx/react/utils/type';
|
|
7
|
-
import {
|
|
6
|
+
import type { GenericProps, HasTheme, ValueOf, ComponentClassName } from '@lumx/react/utils/type';
|
|
7
|
+
import { handleBasicClasses } from '@lumx/react/utils/className';
|
|
8
8
|
import { useBooleanState } from '@lumx/react/hooks/useBooleanState';
|
|
9
9
|
import { useId } from '@lumx/react/hooks/useId';
|
|
10
10
|
import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
|
|
@@ -60,7 +60,7 @@ const COMPONENT_NAME = 'Uploader';
|
|
|
60
60
|
/**
|
|
61
61
|
* Component default class name and class prefix.
|
|
62
62
|
*/
|
|
63
|
-
const CLASSNAME =
|
|
63
|
+
const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-uploader';
|
|
64
64
|
|
|
65
65
|
/**
|
|
66
66
|
* Component default props.
|
|
@@ -2,8 +2,8 @@ import React, { ReactNode } from 'react';
|
|
|
2
2
|
import classNames from 'classnames';
|
|
3
3
|
|
|
4
4
|
import { Avatar, ColorPalette, Link, Orientation, Size, Theme } from '@lumx/react';
|
|
5
|
-
import { GenericProps, HasTheme } from '@lumx/react/utils/type';
|
|
6
|
-
import {
|
|
5
|
+
import type { GenericProps, HasTheme, ComponentClassName } from '@lumx/react/utils/type';
|
|
6
|
+
import { handleBasicClasses } from '@lumx/react/utils/className';
|
|
7
7
|
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
8
8
|
|
|
9
9
|
import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
|
|
@@ -54,7 +54,7 @@ const COMPONENT_NAME = 'UserBlock';
|
|
|
54
54
|
/**
|
|
55
55
|
* Component default class name and class prefix.
|
|
56
56
|
*/
|
|
57
|
-
const CLASSNAME =
|
|
57
|
+
const CLASSNAME: ComponentClassName<typeof COMPONENT_NAME> = 'lumx-user-block';
|
|
58
58
|
|
|
59
59
|
/**
|
|
60
60
|
* Component default props.
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { getBasicClass, handleBasicClasses } from './className';
|
|
2
|
+
|
|
3
|
+
describe(getBasicClass, () => {
|
|
4
|
+
it('should generate boolean modifier name with boolean prefix', () => {
|
|
5
|
+
expect(getBasicClass({ prefix: 'prefix', type: 'foo', value: true })).toEqual('prefix--is-foo');
|
|
6
|
+
});
|
|
7
|
+
it('should generate boolean modifier name keeping the existing boolean prefix', () => {
|
|
8
|
+
expect(getBasicClass({ prefix: 'prefix', type: 'isFoo', value: true })).toEqual('prefix--is-foo');
|
|
9
|
+
expect(getBasicClass({ prefix: 'prefix', type: 'hasFoo', value: true })).toEqual('prefix--has-foo');
|
|
10
|
+
});
|
|
11
|
+
it(`should generate string modifier name`, () => {
|
|
12
|
+
expect(getBasicClass({ prefix: 'prefix', type: 'foo', value: 'bar' })).toEqual('prefix--foo-bar');
|
|
13
|
+
});
|
|
14
|
+
it(`should generate number modifier name`, () => {
|
|
15
|
+
expect(getBasicClass({ prefix: 'prefix', type: 'foo', value: 2 })).toEqual('prefix--foo-2');
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
describe(handleBasicClasses, () => {
|
|
20
|
+
it('should use prefix if there is no modifier', () => {
|
|
21
|
+
expect(
|
|
22
|
+
handleBasicClasses({
|
|
23
|
+
prefix: 'prefix',
|
|
24
|
+
}),
|
|
25
|
+
).toEqual('prefix');
|
|
26
|
+
});
|
|
27
|
+
it('should filter falsy modifiers', () => {
|
|
28
|
+
expect(
|
|
29
|
+
handleBasicClasses({
|
|
30
|
+
prefix: 'prefix',
|
|
31
|
+
theme: 'dark',
|
|
32
|
+
isModifier: true,
|
|
33
|
+
isEmpty: '',
|
|
34
|
+
isNull: null,
|
|
35
|
+
isUndefined: undefined,
|
|
36
|
+
isZero: 0,
|
|
37
|
+
isNumberNotZero: 2,
|
|
38
|
+
}),
|
|
39
|
+
).toEqual('prefix prefix--theme-dark prefix--is-modifier prefix--is-number-not-zero-2');
|
|
40
|
+
});
|
|
41
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ReactElement, Ref } from 'react';
|
|
2
|
+
|
|
3
|
+
/** LumX Component Type. */
|
|
4
|
+
export type Comp<P, T = HTMLElement> = {
|
|
5
|
+
(props: P & { ref?: Ref<T> }): ReactElement | null;
|
|
6
|
+
/** React component type. */
|
|
7
|
+
readonly $$typeof: symbol;
|
|
8
|
+
/** Component default props. */
|
|
9
|
+
defaultProps?: Partial<P>;
|
|
10
|
+
/** Component name. */
|
|
11
|
+
displayName?: string;
|
|
12
|
+
/** Component base class name. */
|
|
13
|
+
className?: string;
|
|
14
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { KebabCase } from './KebabCase';
|
|
2
|
+
|
|
3
|
+
/** Transform the component name into the lumx class name. */
|
|
4
|
+
export type ComponentClassName<
|
|
5
|
+
TComponentName extends string,
|
|
6
|
+
TSubComponentName extends string = '',
|
|
7
|
+
> = `lumx-${KebabCase<TComponentName>}${TSubComponentName extends `${TComponentName}${infer TSubName}` ? `__${KebabCase<TSubName>}` : ''}`;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
import type { Comp } from './Comp';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Extract ref type for a component or JSX intrinsic element
|
|
6
|
+
*
|
|
7
|
+
* @example ComponentRef<'div'> => React.Ref<HTMLDivElement>
|
|
8
|
+
* @example ComponentRef<Button> => React.Ref<HTMLButtonElement
|
|
9
|
+
*/
|
|
10
|
+
export type ComponentRef<C> = C extends keyof JSX.IntrinsicElements
|
|
11
|
+
? JSX.IntrinsicElements[C]['ref']
|
|
12
|
+
: C extends Comp<any, infer T>
|
|
13
|
+
? React.Ref<T>
|
|
14
|
+
: C extends React.JSXElementConstructor<{ ref?: infer R }>
|
|
15
|
+
? R
|
|
16
|
+
: never;
|