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