@lumx/react 3.10.1-alpha.4 → 3.10.1-alpha.6
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 +172 -298
- 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 +3 -12
- package/src/components/autocomplete/AutocompleteMultiple.tsx +3 -8
- package/src/components/avatar/Avatar.tsx +3 -3
- package/src/components/badge/Badge.tsx +3 -3
- package/src/components/badge/BadgeWrapper.tsx +3 -4
- 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 +3 -7
- 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 +4 -5
- 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 +3 -9
- package/src/components/heading/Heading.tsx +3 -9
- 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 +3 -10
- package/src/components/list/ListItem.tsx +3 -3
- package/src/components/list/ListSubheader.tsx +3 -4
- 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 +3 -4
- 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 +3 -8
- 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 +3 -13
- 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 +4 -9
- 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 +3 -13
- package/src/components/slideshow/SlideshowItemGroup.tsx +3 -10
- package/src/components/switch/Switch.tsx +3 -3
- package/src/components/table/Table.tsx +3 -3
- package/src/components/table/TableBody.tsx +3 -8
- package/src/components/table/TableCell.tsx +4 -7
- package/src/components/table/TableHeader.tsx +3 -8
- 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/getBasicClass.test.ts +20 -0
- package/src/utils/className/getFontColorClassName.test.ts +11 -0
- package/src/utils/className/getTypographyClassName.test.ts +7 -0
- package/src/utils/className/handleBasicClasses.test.ts +28 -0
- package/src/utils/className/index.ts +0 -1
- 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.ts +0 -24
- package/src/utils/type.ts +0 -164
|
@@ -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,20 @@
|
|
|
1
|
+
import { getBasicClass } from '@lumx/core/js/utils';
|
|
2
|
+
|
|
3
|
+
describe(getBasicClass, () => {
|
|
4
|
+
it('should return correct basic CSS class for different types and values', () => {
|
|
5
|
+
// Test cases with different inputs
|
|
6
|
+
expect(getBasicClass({ prefix: 'test', type: 'color', value: 'primary' })).toBe('test--color-primary');
|
|
7
|
+
expect(getBasicClass({ prefix: 'test', type: 'variant', value: 'button' })).toBe('test--variant-button');
|
|
8
|
+
expect(getBasicClass({ prefix: 'test', type: 'isDark', value: true })).toBe('test--is-dark');
|
|
9
|
+
expect(getBasicClass({ prefix: 'test', type: 'dark', value: true })).toBe('test--is-dark');
|
|
10
|
+
expect(getBasicClass({ prefix: 'test', type: 'hasDark', value: true })).toBe('test--has-dark');
|
|
11
|
+
expect(getBasicClass({ prefix: 'test', type: 'isActive', value: false })).toBe('');
|
|
12
|
+
|
|
13
|
+
// Additional tests for boolean types
|
|
14
|
+
expect(getBasicClass({ prefix: 'test', type: 'hasBorder', value: true })).toBe('test--has-border');
|
|
15
|
+
expect(getBasicClass({ prefix: 'test', type: 'isVisible', value: false })).toBe('');
|
|
16
|
+
|
|
17
|
+
// Tests for undefined
|
|
18
|
+
expect(getBasicClass({ prefix: 'test', type: 'variant', value: undefined })).toBe('test--variant-undefined');
|
|
19
|
+
});
|
|
20
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { getFontColorClassName } from '@lumx/react/utils/className/getFontColorClassName';
|
|
2
|
+
|
|
3
|
+
describe(getFontColorClassName, () => {
|
|
4
|
+
it('should get lumx class for font color', () => {
|
|
5
|
+
expect(getFontColorClassName('dark')).toBe('lumx-color-font-dark-N');
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
it('should get lumx class for font color with variant', () => {
|
|
9
|
+
expect(getFontColorClassName('red', 'L2')).toBe('lumx-color-font-red-L2');
|
|
10
|
+
});
|
|
11
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { getTypographyClassName } from '@lumx/react/utils/className/getTypographyClassName';
|
|
2
|
+
|
|
3
|
+
describe(getTypographyClassName, () => {
|
|
4
|
+
it('should generate lumx typography class', () => {
|
|
5
|
+
expect(getTypographyClassName('title')).toBe('lumx-typography-title');
|
|
6
|
+
});
|
|
7
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { handleBasicClasses } from '@lumx/core/js/utils';
|
|
2
|
+
|
|
3
|
+
describe(handleBasicClasses, () => {
|
|
4
|
+
it('should return correct combined CSS classes based on props', () => {
|
|
5
|
+
const className = handleBasicClasses({
|
|
6
|
+
prefix: 'test',
|
|
7
|
+
// Undefined
|
|
8
|
+
undefined,
|
|
9
|
+
// Null
|
|
10
|
+
null: null,
|
|
11
|
+
// Empty string
|
|
12
|
+
emptyString: '',
|
|
13
|
+
// Empty array
|
|
14
|
+
emptyArray: [],
|
|
15
|
+
// Empty object
|
|
16
|
+
emptyObject: {},
|
|
17
|
+
// String
|
|
18
|
+
color: 'red',
|
|
19
|
+
// False property
|
|
20
|
+
isDisabled: false,
|
|
21
|
+
// Boolean without a prefix (is or has)
|
|
22
|
+
visible: true,
|
|
23
|
+
// Has prefix
|
|
24
|
+
hasButton: true,
|
|
25
|
+
});
|
|
26
|
+
expect(className).toBe('test test--color-red test--is-visible test--has-button');
|
|
27
|
+
});
|
|
28
|
+
});
|
|
@@ -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;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { HasClassName } from './HasClassName';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Define a generic props types.
|
|
5
|
+
*/
|
|
6
|
+
export interface GenericProps extends HasClassName {
|
|
7
|
+
/**
|
|
8
|
+
* Any prop (particularly any supported prop for a HTML element).
|
|
9
|
+
*/
|
|
10
|
+
[propName: string]: any;
|
|
11
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Require either `aria-label` or `arial-labelledby` prop.
|
|
3
|
+
* If none are set, the order will prioritize `aria-labelledby` over `aria-label` as it
|
|
4
|
+
* needs a visible element.
|
|
5
|
+
*/
|
|
6
|
+
export type HasAriaLabelOrLabelledBy<T = string | undefined> = T extends string
|
|
7
|
+
? {
|
|
8
|
+
/**
|
|
9
|
+
* The id of the element to use as title of the dialog. Can be within or out of the dialog.
|
|
10
|
+
* Although it is not recommended, aria-label can be used instead if no visible element is available.
|
|
11
|
+
*/
|
|
12
|
+
'aria-labelledby': T;
|
|
13
|
+
/** The label of the dialog. */
|
|
14
|
+
'aria-label'?: undefined;
|
|
15
|
+
}
|
|
16
|
+
: {
|
|
17
|
+
'aria-label': string;
|
|
18
|
+
'aria-labelledby'?: undefined;
|
|
19
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export { Callback } from './Callback';
|
|
2
|
+
export { Comp } from './Comp';
|
|
3
|
+
export { ComponentRef } from './ComponentRef';
|
|
4
|
+
export { Falsy } from './Falsy';
|
|
5
|
+
export { GenericProps } from './GenericProps';
|
|
6
|
+
export { HasAriaLabelOrLabelledBy } from './HasAriaLabelOrLabelledBy';
|
|
7
|
+
export { HasClassName } from './HasClassName';
|
|
8
|
+
export { HasCloseMode } from './HasCloseMode';
|
|
9
|
+
export { HasPolymorphicAs } from './HasPolymorphicAs';
|
|
10
|
+
export { HasTheme } from './HasTheme';
|
|
11
|
+
export { HeadingElement } from './HeadingElement';
|
|
12
|
+
export { isComponentType } from './isComponentType';
|
|
13
|
+
export { MaybeElementOrRef } from './MaybeElementOrRef';
|
|
14
|
+
export { Point } from './Point';
|
|
15
|
+
export { Predicate } from './Predicate';
|
|
16
|
+
export { RectSize } from './RectSize';
|
|
17
|
+
export { TextElement } from './TextElement';
|
|
18
|
+
export { ValueOf } from './ValueOf';
|
|
19
|
+
export { ComponentClassName } from './ComponentClassName';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React, { ReactElement, ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Similar to `isComponent` but more precise as it's not based on the component `displayName` but on the component function reference.
|
|
5
|
+
*/
|
|
6
|
+
export const isComponentType =
|
|
7
|
+
(type: ReactElement['type']) =>
|
|
8
|
+
(node: ReactNode): node is ReactElement =>
|
|
9
|
+
React.isValidElement(node) && node.type === type;
|
package/utils/index.d.ts
CHANGED