@lumx/react 3.18.2-alpha.4 → 3.19.1-alpha.0
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 +201 -117
- package/index.js +470 -480
- package/index.js.map +1 -1
- package/package.json +3 -3
- package/src/components/alert-dialog/AlertDialog.tsx +1 -1
- package/src/components/autocomplete/Autocomplete.tsx +1 -1
- package/src/components/autocomplete/AutocompleteMultiple.tsx +1 -1
- package/src/components/avatar/Avatar.tsx +1 -1
- package/src/components/badge/Badge.tsx +1 -1
- package/src/components/badge/BadgeWrapper.tsx +1 -1
- package/src/components/button/Button.test.tsx +5 -5
- package/src/components/button/Button.tsx +1 -1
- package/src/components/button/ButtonGroup.tsx +1 -1
- package/src/components/button/ButtonRoot.tsx +7 -37
- package/src/components/button/IconButton.tsx +1 -1
- package/src/components/checkbox/Checkbox.tsx +1 -1
- package/src/components/chip/Chip.tsx +2 -2
- package/src/components/chip/ChipGroup.tsx +2 -2
- package/src/components/comment-block/CommentBlock.tsx +1 -1
- package/src/components/date-picker/DatePickerControlled.tsx +1 -1
- package/src/components/date-picker/constants.ts +1 -1
- package/src/components/dialog/Dialog.tsx +1 -1
- package/src/components/divider/Divider.tsx +1 -1
- package/src/components/drag-handle/DragHandle.tsx +1 -1
- package/src/components/dropdown/Dropdown.tsx +1 -1
- package/src/components/expansion-panel/ExpansionPanel.tsx +1 -1
- package/src/components/flag/Flag.tsx +1 -1
- package/src/components/flex-box/FlexBox.tsx +2 -3
- package/src/components/generic-block/GenericBlock.tsx +1 -1
- package/src/components/grid/Grid.tsx +1 -1
- package/src/components/grid/GridItem.tsx +1 -1
- package/src/components/grid-column/GridColumn.tsx +1 -1
- package/src/components/heading/Heading.tsx +1 -1
- package/src/components/heading/constants.ts +1 -1
- package/src/components/icon/Icon.tsx +1 -1
- package/src/components/image-block/ImageBlock.tsx +1 -1
- package/src/components/image-lightbox/constants.ts +1 -1
- package/src/components/inline-list/InlineList.tsx +1 -1
- package/src/components/input-helper/InputHelper.tsx +1 -1
- package/src/components/input-label/InputLabel.test.tsx +1 -1
- package/src/components/input-label/InputLabel.tsx +1 -1
- package/src/components/lightbox/Lightbox.tsx +1 -1
- package/src/components/link/Link.test.tsx +8 -6
- package/src/components/link/Link.tsx +10 -21
- package/src/components/link-preview/LinkPreview.stories.tsx +1 -1
- package/src/components/link-preview/LinkPreview.test.tsx +1 -1
- package/src/components/link-preview/LinkPreview.tsx +1 -1
- package/src/components/list/List.tsx +1 -1
- package/src/components/list/ListDivider.tsx +1 -1
- package/src/components/list/ListItem.test.tsx +1 -3
- package/src/components/list/ListItem.tsx +20 -33
- package/src/components/list/ListSubheader.tsx +1 -1
- package/src/components/message/Message.tsx +1 -1
- package/src/components/mosaic/Mosaic.tsx +1 -1
- package/src/components/navigation/Navigation.test.tsx +1 -1
- package/src/components/navigation/Navigation.tsx +1 -1
- package/src/components/navigation/NavigationItem.tsx +8 -12
- package/src/components/navigation/NavigationSection.test.tsx +2 -1
- package/src/components/navigation/NavigationSection.tsx +5 -4
- package/src/components/navigation/context.tsx +2 -1
- package/src/components/notification/Notification.tsx +1 -1
- package/src/components/popover/Popover.tsx +1 -1
- package/src/components/popover-dialog/PopoverDialog.tsx +1 -1
- package/src/components/post-block/PostBlock.tsx +1 -1
- package/src/components/progress/Progress.tsx +1 -1
- package/src/components/progress/ProgressCircular.tsx +1 -1
- package/src/components/progress/ProgressLinear.tsx +1 -1
- package/src/components/progress-tracker/ProgressTracker.tsx +1 -1
- package/src/components/progress-tracker/ProgressTrackerStep.tsx +1 -1
- package/src/components/progress-tracker/ProgressTrackerStepPanel.tsx +1 -1
- package/src/components/radio-button/RadioButton.tsx +1 -1
- package/src/components/radio-button/RadioGroup.tsx +1 -1
- package/src/components/select/Select.test.tsx +1 -1
- package/src/components/select/Select.tsx +2 -2
- package/src/components/select/SelectMultiple.test.tsx +1 -1
- package/src/components/select/SelectMultiple.tsx +2 -2
- package/src/components/select/WithSelectContext.tsx +2 -2
- package/src/components/side-navigation/SideNavigation.tsx +1 -1
- package/src/components/side-navigation/SideNavigationItem.tsx +23 -28
- package/src/components/skeleton/SkeletonCircle.tsx +1 -1
- package/src/components/skeleton/SkeletonRectangle.tsx +1 -1
- package/src/components/skeleton/SkeletonTypography.tsx +1 -1
- package/src/components/slider/Slider.tsx +1 -1
- package/src/components/slideshow/Slides.tsx +1 -1
- package/src/components/slideshow/SlideshowControls.tsx +1 -1
- package/src/components/slideshow/SlideshowItem.tsx +1 -1
- package/src/components/slideshow/SlideshowItemGroup.tsx +1 -1
- package/src/components/switch/Switch.tsx +1 -1
- package/src/components/table/Table.tsx +1 -1
- package/src/components/table/TableBody.tsx +1 -1
- package/src/components/table/TableCell.tsx +1 -1
- package/src/components/table/TableHeader.tsx +1 -1
- package/src/components/table/TableRow.tsx +1 -1
- package/src/components/tabs/Tab.tsx +1 -1
- package/src/components/tabs/TabList.tsx +1 -1
- package/src/components/tabs/TabPanel.tsx +1 -1
- package/src/components/text/Text.stories.tsx +23 -1
- package/src/components/text/Text.tsx +2 -2
- package/src/components/text-field/TextField.test.tsx +1 -1
- package/src/components/text-field/TextField.tsx +1 -1
- package/src/components/thumbnail/Thumbnail.tsx +7 -12
- package/src/components/thumbnail/useFocusPointStyle.tsx +1 -1
- package/src/components/toolbar/Toolbar.tsx +1 -1
- package/src/components/tooltip/Tooltip.tsx +1 -1
- package/src/components/uploader/Uploader.tsx +1 -1
- package/src/components/user-block/UserBlock.tsx +1 -1
- package/src/hooks/useCallbackOnEscape.ts +1 -1
- package/src/hooks/useOverflowTooltipLabel.tsx +21 -18
- package/src/index.ts +3 -1
- package/src/utils/partitionMulti.ts +2 -1
- package/src/utils/react/RawClickable.test.tsx +153 -0
- package/src/utils/react/RawClickable.tsx +65 -0
- package/src/utils/type/HasRequiredLinkHref.ts +1 -0
- package/src/utils/type/index.ts +3 -13
- package/src/components/index.ts +0 -160
- package/src/utils/browser/event.ts +0 -1
- package/src/utils/className/fontColorClass.test.ts +0 -15
- package/src/utils/className/fontColorClass.ts +0 -12
- package/src/utils/className/getBasicClass.test.ts +0 -20
- package/src/utils/className/getRootClassName.test.ts +0 -11
- package/src/utils/className/getRootClassName.ts +0 -24
- package/src/utils/className/getTypographyClassName.test.ts +0 -7
- package/src/utils/className/getTypographyClassName.ts +0 -9
- package/src/utils/className/handleBasicClasses.test.ts +0 -28
- package/src/utils/className/index.ts +0 -5
- package/src/utils/className/resolveColorWithVariants.test.ts +0 -33
- package/src/utils/className/resolveColorWithVariants.ts +0 -11
- package/src/utils/react/renderButtonOrLink.tsx +0 -16
- package/src/utils/react/renderLink.tsx +0 -17
- package/src/utils/type/Callback.ts +0 -4
- package/src/utils/type/Falsy.ts +0 -5
- package/src/utils/type/GenericProps.ts +0 -11
- package/src/utils/type/HasAriaLabelOrLabelledBy.ts +0 -19
- package/src/utils/type/HasClassName.ts +0 -6
- package/src/utils/type/HasCloseMode.ts +0 -7
- package/src/utils/type/HasTheme.ts +0 -8
- package/src/utils/type/HeadingElement.ts +0 -2
- package/src/utils/type/Point.ts +0 -4
- package/src/utils/type/Predicate.ts +0 -2
- package/src/utils/type/RectSize.ts +0 -4
- package/src/utils/type/TextElement.ts +0 -4
- package/src/utils/type/ValueOf.ts +0 -2
- package/src/utils/type/color/index.ts +0 -43
|
@@ -6,11 +6,10 @@ import isEmpty from 'lodash/isEmpty';
|
|
|
6
6
|
import { mdiChevronDown, mdiChevronUp } from '@lumx/icons';
|
|
7
7
|
import { Emphasis, Icon, Size, IconButton, IconButtonProps } from '@lumx/react';
|
|
8
8
|
import { GenericProps, HasCloseMode, isComponent } from '@lumx/react/utils/type';
|
|
9
|
-
import { getRootClassName, handleBasicClasses } from '@lumx/
|
|
10
|
-
import { renderLink } from '@lumx/react/utils/react/renderLink';
|
|
11
|
-
import { renderButtonOrLink } from '@lumx/react/utils/react/renderButtonOrLink';
|
|
9
|
+
import { getRootClassName, handleBasicClasses } from '@lumx/core/js/utils/className';
|
|
12
10
|
import { useId } from '@lumx/react/hooks/useId';
|
|
13
11
|
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
12
|
+
import { RawClickable } from '@lumx/react/utils/react/RawClickable';
|
|
14
13
|
|
|
15
14
|
/**
|
|
16
15
|
* Defines the props of the component.
|
|
@@ -113,17 +112,15 @@ export const SideNavigationItem = forwardRef<SideNavigationItemProps, HTMLLIElem
|
|
|
113
112
|
>
|
|
114
113
|
{shouldSplitActions ? (
|
|
115
114
|
<div className={`${CLASSNAME}__wrapper`}>
|
|
116
|
-
|
|
117
|
-
{
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
<span>{label}</span>,
|
|
126
|
-
)}
|
|
115
|
+
<RawClickable
|
|
116
|
+
as={linkAs || linkProps?.href ? 'a' : 'button'}
|
|
117
|
+
{...(linkProps as any)}
|
|
118
|
+
className={`${CLASSNAME}__link`}
|
|
119
|
+
onClick={onClick}
|
|
120
|
+
>
|
|
121
|
+
{icon && <Icon className={`${CLASSNAME}__icon`} icon={icon} size={Size.xs} />}
|
|
122
|
+
<span>{label}</span>
|
|
123
|
+
</RawClickable>
|
|
127
124
|
|
|
128
125
|
<IconButton
|
|
129
126
|
{...toggleButtonProps}
|
|
@@ -136,25 +133,23 @@ export const SideNavigationItem = forwardRef<SideNavigationItemProps, HTMLLIElem
|
|
|
136
133
|
/>
|
|
137
134
|
</div>
|
|
138
135
|
) : (
|
|
139
|
-
|
|
140
|
-
{
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
<span>{label}</span>,
|
|
150
|
-
hasContent && (
|
|
136
|
+
<RawClickable
|
|
137
|
+
as={linkAs || linkProps?.href ? 'a' : 'button'}
|
|
138
|
+
{...linkProps}
|
|
139
|
+
className={`${CLASSNAME}__link`}
|
|
140
|
+
onClick={onClick}
|
|
141
|
+
{...ariaProps}
|
|
142
|
+
>
|
|
143
|
+
{icon && <Icon className={`${CLASSNAME}__icon`} icon={icon} size={Size.xs} />}
|
|
144
|
+
<span>{label}</span>
|
|
145
|
+
{hasContent && (
|
|
151
146
|
<Icon
|
|
152
147
|
className={`${CLASSNAME}__chevron`}
|
|
153
148
|
icon={isOpen ? mdiChevronUp : mdiChevronDown}
|
|
154
149
|
size={Size.xs}
|
|
155
150
|
/>
|
|
156
|
-
)
|
|
157
|
-
|
|
151
|
+
)}
|
|
152
|
+
</RawClickable>
|
|
158
153
|
)}
|
|
159
154
|
|
|
160
155
|
{(closeMode === 'hide' || showChildren) && (
|
|
@@ -4,7 +4,7 @@ import classNames from 'classnames';
|
|
|
4
4
|
|
|
5
5
|
import { GlobalSize, Theme, ColorPalette } from '@lumx/react';
|
|
6
6
|
import { GenericProps, HasTheme } from '@lumx/react/utils/type';
|
|
7
|
-
import { getRootClassName, handleBasicClasses } from '@lumx/
|
|
7
|
+
import { getRootClassName, handleBasicClasses } from '@lumx/core/js/utils/className';
|
|
8
8
|
import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
|
|
9
9
|
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
10
10
|
|
|
@@ -4,7 +4,7 @@ import classNames from 'classnames';
|
|
|
4
4
|
|
|
5
5
|
import { AspectRatio, GlobalSize, Theme, ColorPalette } from '@lumx/react';
|
|
6
6
|
import { GenericProps, HasTheme, ValueOf } from '@lumx/react/utils/type';
|
|
7
|
-
import { getRootClassName, handleBasicClasses } from '@lumx/
|
|
7
|
+
import { getRootClassName, handleBasicClasses } from '@lumx/core/js/utils/className';
|
|
8
8
|
import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
|
|
9
9
|
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
10
10
|
|
|
@@ -4,7 +4,7 @@ import classNames from 'classnames';
|
|
|
4
4
|
|
|
5
5
|
import { Theme, TypographyInterface, ColorPalette } from '@lumx/react';
|
|
6
6
|
import { GenericProps, HasTheme } from '@lumx/react/utils/type';
|
|
7
|
-
import { getRootClassName, handleBasicClasses } from '@lumx/
|
|
7
|
+
import { getRootClassName, handleBasicClasses } from '@lumx/core/js/utils/className';
|
|
8
8
|
import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
|
|
9
9
|
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
10
10
|
|
|
@@ -6,7 +6,7 @@ import classNames from 'classnames';
|
|
|
6
6
|
import { InputHelper, InputLabel, Theme } from '@lumx/react';
|
|
7
7
|
import useEventCallback from '@lumx/react/hooks/useEventCallback';
|
|
8
8
|
import { GenericProps, HasTheme } from '@lumx/react/utils/type';
|
|
9
|
-
import { getRootClassName, handleBasicClasses } from '@lumx/
|
|
9
|
+
import { getRootClassName, handleBasicClasses } from '@lumx/core/js/utils/className';
|
|
10
10
|
import { clamp } from '@lumx/react/utils/number/clamp';
|
|
11
11
|
import { useId } from '@lumx/react/hooks/useId';
|
|
12
12
|
import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
|
|
@@ -5,7 +5,7 @@ import classNames from 'classnames';
|
|
|
5
5
|
|
|
6
6
|
import { FULL_WIDTH_PERCENT } from '@lumx/react/components/slideshow/constants';
|
|
7
7
|
import { GenericProps, HasTheme } from '@lumx/react/utils/type';
|
|
8
|
-
import { getRootClassName, handleBasicClasses } from '@lumx/
|
|
8
|
+
import { getRootClassName, handleBasicClasses } from '@lumx/core/js/utils/className';
|
|
9
9
|
import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
|
|
10
10
|
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
11
11
|
|
|
@@ -6,7 +6,7 @@ import range from 'lodash/range';
|
|
|
6
6
|
import { mdiChevronLeft, mdiChevronRight, mdiPlayCircleOutline, mdiPauseCircleOutline } from '@lumx/icons';
|
|
7
7
|
import { Emphasis, IconButton, IconButtonProps, Theme } from '@lumx/react';
|
|
8
8
|
import { GenericProps, HasTheme } from '@lumx/react/utils/type';
|
|
9
|
-
import { getRootClassName, handleBasicClasses } from '@lumx/
|
|
9
|
+
import { getRootClassName, handleBasicClasses } from '@lumx/core/js/utils/className';
|
|
10
10
|
import { WINDOW } from '@lumx/react/constants';
|
|
11
11
|
import { useSlideshowControls, DEFAULT_OPTIONS } from '@lumx/react/hooks/useSlideshowControls';
|
|
12
12
|
import { useRovingTabIndex } from '@lumx/react/hooks/useRovingTabIndex';
|
|
@@ -3,7 +3,7 @@ import React from 'react';
|
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
|
|
5
5
|
import { GenericProps } from '@lumx/react/utils/type';
|
|
6
|
-
import { getRootClassName } from '@lumx/
|
|
6
|
+
import { getRootClassName } from '@lumx/core/js/utils/className';
|
|
7
7
|
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -3,7 +3,7 @@ import React from 'react';
|
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
import { mergeRefs } from '@lumx/react/utils/react/mergeRefs';
|
|
5
5
|
import { GenericProps } from '@lumx/react/utils/type';
|
|
6
|
-
import { getRootClassName } from '@lumx/
|
|
6
|
+
import { getRootClassName } from '@lumx/core/js/utils/className';
|
|
7
7
|
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
8
8
|
import { useSlideFocusManagement } from './useSlideFocusManagement';
|
|
9
9
|
|
|
@@ -5,7 +5,7 @@ import isEmpty from 'lodash/isEmpty';
|
|
|
5
5
|
|
|
6
6
|
import { Alignment, InputHelper, InputLabel, Theme } from '@lumx/react';
|
|
7
7
|
import { GenericProps, HasTheme } from '@lumx/react/utils/type';
|
|
8
|
-
import { getRootClassName, handleBasicClasses } from '@lumx/
|
|
8
|
+
import { getRootClassName, handleBasicClasses } from '@lumx/core/js/utils/className';
|
|
9
9
|
import { useId } from '@lumx/react/hooks/useId';
|
|
10
10
|
import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
|
|
11
11
|
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
@@ -4,7 +4,7 @@ import classNames from 'classnames';
|
|
|
4
4
|
|
|
5
5
|
import { Theme } from '@lumx/react';
|
|
6
6
|
import { GenericProps, HasTheme } from '@lumx/react/utils/type';
|
|
7
|
-
import { getRootClassName, handleBasicClasses } from '@lumx/
|
|
7
|
+
import { getRootClassName, handleBasicClasses } from '@lumx/core/js/utils/className';
|
|
8
8
|
import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
|
|
9
9
|
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
10
10
|
|
|
@@ -3,7 +3,7 @@ import React from 'react';
|
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
|
|
5
5
|
import { GenericProps } from '@lumx/react/utils/type';
|
|
6
|
-
import { getRootClassName } from '@lumx/
|
|
6
|
+
import { getRootClassName } from '@lumx/core/js/utils/className';
|
|
7
7
|
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -5,7 +5,7 @@ import classNames from 'classnames';
|
|
|
5
5
|
import { mdiArrowDown, mdiArrowUp } from '@lumx/icons';
|
|
6
6
|
import { Icon, Size } from '@lumx/react';
|
|
7
7
|
import { GenericProps, ValueOf } from '@lumx/react/utils/type';
|
|
8
|
-
import { getRootClassName, handleBasicClasses } from '@lumx/
|
|
8
|
+
import { getRootClassName, handleBasicClasses } from '@lumx/core/js/utils/className';
|
|
9
9
|
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
10
10
|
|
|
11
11
|
/**
|
|
@@ -3,7 +3,7 @@ import React from 'react';
|
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
|
|
5
5
|
import { GenericProps } from '@lumx/react/utils/type';
|
|
6
|
-
import { getRootClassName } from '@lumx/
|
|
6
|
+
import { getRootClassName } from '@lumx/core/js/utils/className';
|
|
7
7
|
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -3,7 +3,7 @@ import React from 'react';
|
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
|
|
5
5
|
import { GenericProps } from '@lumx/react/utils/type';
|
|
6
|
-
import { getRootClassName, handleBasicClasses } from '@lumx/
|
|
6
|
+
import { getRootClassName, handleBasicClasses } from '@lumx/core/js/utils/className';
|
|
7
7
|
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
8
8
|
import { useDisableStateProps } from '@lumx/react/utils/disabled/useDisableStateProps';
|
|
9
9
|
|
|
@@ -5,7 +5,7 @@ import classNames from 'classnames';
|
|
|
5
5
|
import { Icon, IconProps, Size, Text } from '@lumx/react';
|
|
6
6
|
import { CSS_PREFIX } from '@lumx/react/constants';
|
|
7
7
|
import { GenericProps } from '@lumx/react/utils/type';
|
|
8
|
-
import { handleBasicClasses } from '@lumx/
|
|
8
|
+
import { handleBasicClasses } from '@lumx/core/js/utils/className';
|
|
9
9
|
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
10
10
|
|
|
11
11
|
import { useDisableStateProps } from '@lumx/react/utils/disabled/useDisableStateProps';
|
|
@@ -5,7 +5,7 @@ import classNames from 'classnames';
|
|
|
5
5
|
import { Alignment, Theme } from '@lumx/react';
|
|
6
6
|
import { CSS_PREFIX } from '@lumx/react/constants';
|
|
7
7
|
import { GenericProps, HasTheme } from '@lumx/react/utils/type';
|
|
8
|
-
import { handleBasicClasses } from '@lumx/
|
|
8
|
+
import { handleBasicClasses } from '@lumx/core/js/utils/className';
|
|
9
9
|
import { mergeRefs } from '@lumx/react/utils/react/mergeRefs';
|
|
10
10
|
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
11
11
|
import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
|
|
@@ -6,7 +6,7 @@ import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
|
6
6
|
import { useTabProviderContext } from '@lumx/react/components/tabs/state';
|
|
7
7
|
import { CSS_PREFIX } from '@lumx/react/constants';
|
|
8
8
|
import { GenericProps } from '@lumx/react/utils/type';
|
|
9
|
-
import { handleBasicClasses } from '@lumx/
|
|
9
|
+
import { handleBasicClasses } from '@lumx/core/js/utils/className';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Defines the props of the component.
|
|
@@ -6,7 +6,7 @@ import { textElementArgType } from '@lumx/react/stories/controls/element';
|
|
|
6
6
|
import { withUndefined } from '@lumx/react/stories/controls/withUndefined';
|
|
7
7
|
import { loremIpsum } from '@lumx/react/stories/utils/lorem';
|
|
8
8
|
import { withCombinations } from '@lumx/react/stories/decorators/withCombinations';
|
|
9
|
-
import { ColorPalette, ColorVariant, Icon, WhiteSpace } from '@lumx/react';
|
|
9
|
+
import { Button, ColorPalette, ColorVariant, Icon, WhiteSpace } from '@lumx/react';
|
|
10
10
|
import { mdiEarth, mdiHeart } from '@lumx/icons';
|
|
11
11
|
import { withResizableBox } from '@lumx/react/stories/decorators/withResizableBox';
|
|
12
12
|
import { getSelectArgType } from '@lumx/react/stories/controls/selectArgType';
|
|
@@ -107,6 +107,28 @@ export const Truncate = {
|
|
|
107
107
|
},
|
|
108
108
|
};
|
|
109
109
|
|
|
110
|
+
/**
|
|
111
|
+
* Test the update of the `title` attribute when text overflows
|
|
112
|
+
*/
|
|
113
|
+
export const TestUpdateTruncateTitleLabel = {
|
|
114
|
+
render(args: any) {
|
|
115
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
116
|
+
const [content, setContent] = React.useState<string>('Some text');
|
|
117
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
118
|
+
const lengthen = React.useCallback(() => setContent((prevContent) => `${prevContent} ${prevContent}`), []);
|
|
119
|
+
return (
|
|
120
|
+
<>
|
|
121
|
+
<Button onClick={lengthen}>Lengthen text</Button>
|
|
122
|
+
<Text as="p" truncate style={{ maxWidth: 300 }} {...args}>
|
|
123
|
+
{content}
|
|
124
|
+
</Text>
|
|
125
|
+
</>
|
|
126
|
+
);
|
|
127
|
+
},
|
|
128
|
+
// Disables Chromatic snapshot (not relevant for this story).
|
|
129
|
+
parameters: { chromatic: { disable: true } },
|
|
130
|
+
};
|
|
131
|
+
|
|
110
132
|
/**
|
|
111
133
|
* Long text with multi line truncate ellipsis
|
|
112
134
|
*/
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
getRootClassName,
|
|
10
10
|
handleBasicClasses,
|
|
11
11
|
getTypographyClassName,
|
|
12
|
-
} from '@lumx/
|
|
12
|
+
} from '@lumx/core/js/utils/className';
|
|
13
13
|
import { useOverflowTooltipLabel } from '@lumx/react/hooks/useOverflowTooltipLabel';
|
|
14
14
|
import { useMergeRefs } from '@lumx/react/utils/react/mergeRefs';
|
|
15
15
|
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
@@ -112,7 +112,7 @@ export const Text = forwardRef<TextProps>((props, ref) => {
|
|
|
112
112
|
!(isTruncated && !isTruncatedMultiline) &&
|
|
113
113
|
whiteSpace && { '--lumx-text-white-space': whiteSpace };
|
|
114
114
|
|
|
115
|
-
const { tooltipLabel, labelRef } = useOverflowTooltipLabel();
|
|
115
|
+
const { tooltipLabel, labelRef } = useOverflowTooltipLabel(children);
|
|
116
116
|
|
|
117
117
|
return (
|
|
118
118
|
<Component
|
|
@@ -3,7 +3,7 @@ import React from 'react';
|
|
|
3
3
|
import camelCase from 'lodash/camelCase';
|
|
4
4
|
|
|
5
5
|
import { commonTestsSuiteRTL, SetupRenderOptions } from '@lumx/react/testing/utils';
|
|
6
|
-
import { getBasicClass } from '@lumx/
|
|
6
|
+
import { getBasicClass } from '@lumx/core/js/utils/className';
|
|
7
7
|
import { render } from '@testing-library/react';
|
|
8
8
|
import {
|
|
9
9
|
getByClassName,
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
Theme,
|
|
18
18
|
} from '@lumx/react';
|
|
19
19
|
import { GenericProps, HasTheme } from '@lumx/react/utils/type';
|
|
20
|
-
import { getRootClassName, handleBasicClasses } from '@lumx/
|
|
20
|
+
import { getRootClassName, handleBasicClasses } from '@lumx/core/js/utils/className';
|
|
21
21
|
import { mergeRefs } from '@lumx/react/utils/react/mergeRefs';
|
|
22
22
|
import { useId } from '@lumx/react/hooks/useId';
|
|
23
23
|
import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
|
|
@@ -13,7 +13,7 @@ import classNames from 'classnames';
|
|
|
13
13
|
|
|
14
14
|
import { AspectRatio, HorizontalAlignment, Icon, Size, Theme, ThumbnailObjectFit } from '@lumx/react';
|
|
15
15
|
import { Falsy, GenericProps, HasTheme } from '@lumx/react/utils/type';
|
|
16
|
-
import { getRootClassName, handleBasicClasses } from '@lumx/
|
|
16
|
+
import { getRootClassName, handleBasicClasses } from '@lumx/core/js/utils/className';
|
|
17
17
|
import { mdiImageBroken } from '@lumx/icons';
|
|
18
18
|
import { useMergeRefs } from '@lumx/react/utils/react/mergeRefs';
|
|
19
19
|
import { useImageLoad } from '@lumx/react/components/thumbnail/useImageLoad';
|
|
@@ -22,6 +22,7 @@ import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
|
|
|
22
22
|
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
23
23
|
|
|
24
24
|
import { useDisableStateProps } from '@lumx/react/utils/disabled';
|
|
25
|
+
import { RawClickable } from '@lumx/react/utils/react/RawClickable';
|
|
25
26
|
import { FocusPoint, ThumbnailSize, ThumbnailVariant } from './types';
|
|
26
27
|
|
|
27
28
|
type ImgHTMLProps = ImgHTMLAttributes<HTMLImageElement>;
|
|
@@ -100,7 +101,7 @@ const DEFAULT_PROPS: Partial<ThumbnailProps> = {
|
|
|
100
101
|
* @return React element.
|
|
101
102
|
*/
|
|
102
103
|
export const Thumbnail = forwardRef<ThumbnailProps>((props, ref) => {
|
|
103
|
-
const { isAnyDisabled, otherProps } = useDisableStateProps(props);
|
|
104
|
+
const { isAnyDisabled, otherProps, disabledStateProps } = useDisableStateProps(props);
|
|
104
105
|
const defaultTheme = useTheme() || Theme.light;
|
|
105
106
|
const {
|
|
106
107
|
align,
|
|
@@ -150,18 +151,12 @@ export const Thumbnail = forwardRef<ThumbnailProps>((props, ref) => {
|
|
|
150
151
|
imageErrorStyle.display = 'none';
|
|
151
152
|
}
|
|
152
153
|
|
|
153
|
-
const
|
|
154
|
-
const isButton = !!forwardedProps.onClick;
|
|
155
|
-
const isClickable = !isAnyDisabled && (isButton || isLink);
|
|
154
|
+
const isClickable = !isAnyDisabled && (linkProps?.href || linkAs || forwardedProps.onClick);
|
|
156
155
|
|
|
157
|
-
|
|
156
|
+
const Wrapper: any = isClickable ? RawClickable : 'div';
|
|
158
157
|
const wrapperProps = { ...forwardedProps };
|
|
159
|
-
if (
|
|
160
|
-
|
|
161
|
-
Object.assign(wrapperProps, linkProps);
|
|
162
|
-
} else if (!isAnyDisabled && isButton) {
|
|
163
|
-
Wrapper = 'button';
|
|
164
|
-
wrapperProps.type = forwardedProps.type || 'button';
|
|
158
|
+
if (isClickable) {
|
|
159
|
+
Object.assign(wrapperProps, linkProps, { as: linkAs || linkProps?.href ? 'a' : 'button' }, disabledStateProps);
|
|
165
160
|
wrapperProps['aria-label'] = forwardedProps['aria-label'] || alt;
|
|
166
161
|
}
|
|
167
162
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CSSProperties, useEffect, useMemo, useState } from 'react';
|
|
2
|
-
import { AspectRatio } from '@lumx/
|
|
2
|
+
import { AspectRatio } from '@lumx/core/js/constants';
|
|
3
3
|
import { ThumbnailProps } from '@lumx/react/components/thumbnail/Thumbnail';
|
|
4
4
|
import { RectSize } from '@lumx/react/utils/type';
|
|
5
5
|
|
|
@@ -3,7 +3,7 @@ import React, { ReactNode } from 'react';
|
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
|
|
5
5
|
import { GenericProps } from '@lumx/react/utils/type';
|
|
6
|
-
import { getRootClassName, handleBasicClasses } from '@lumx/
|
|
6
|
+
import { getRootClassName, handleBasicClasses } from '@lumx/core/js/utils/className';
|
|
7
7
|
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -5,7 +5,7 @@ import classNames from 'classnames';
|
|
|
5
5
|
|
|
6
6
|
import { DOCUMENT, VISUALLY_HIDDEN } from '@lumx/react/constants';
|
|
7
7
|
import { GenericProps, HasCloseMode } from '@lumx/react/utils/type';
|
|
8
|
-
import { getRootClassName, handleBasicClasses } from '@lumx/
|
|
8
|
+
import { getRootClassName, handleBasicClasses } from '@lumx/core/js/utils/className';
|
|
9
9
|
import { useMergeRefs } from '@lumx/react/utils/react/mergeRefs';
|
|
10
10
|
import { Placement } from '@lumx/react/components/popover';
|
|
11
11
|
import { TooltipContextProvider } from '@lumx/react/components/tooltip/context';
|
|
@@ -4,7 +4,7 @@ import classNames from 'classnames';
|
|
|
4
4
|
|
|
5
5
|
import { AspectRatio, Icon, Size, Theme } from '@lumx/react';
|
|
6
6
|
import { GenericProps, HasTheme, ValueOf } from '@lumx/react/utils/type';
|
|
7
|
-
import { getRootClassName, handleBasicClasses } from '@lumx/
|
|
7
|
+
import { getRootClassName, handleBasicClasses } from '@lumx/core/js/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';
|
|
@@ -6,7 +6,7 @@ import set from 'lodash/set';
|
|
|
6
6
|
|
|
7
7
|
import { Avatar, ColorPalette, Link, Orientation, Size, Theme } from '@lumx/react';
|
|
8
8
|
import { GenericProps, HasTheme } from '@lumx/react/utils/type';
|
|
9
|
-
import { getRootClassName, handleBasicClasses } from '@lumx/
|
|
9
|
+
import { getRootClassName, handleBasicClasses } from '@lumx/core/js/utils/className';
|
|
10
10
|
import { forwardRef } from '@lumx/react/utils/react/forwardRef';
|
|
11
11
|
|
|
12
12
|
import { useTheme } from '@lumx/react/utils/theme/ThemeContext';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DOCUMENT } from '@lumx/react/constants';
|
|
2
2
|
import { Callback } from '@lumx/react/utils/type';
|
|
3
|
-
import { onEscapePressed } from '@lumx/
|
|
3
|
+
import { onEscapePressed } from '@lumx/core/js/utils';
|
|
4
4
|
import { useEffect } from 'react';
|
|
5
5
|
import { Listener, makeListenerTowerContext } from '@lumx/react/utils/function/makeListenerTowerContext';
|
|
6
6
|
|
|
@@ -1,29 +1,32 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { useTooltipContext } from '@lumx/react/components/tooltip/context';
|
|
3
|
+
import { VISUALLY_HIDDEN } from '@lumx/react/constants';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Compute a tooltip label based on a label element `innerText` if the text overflows.
|
|
6
|
-
*
|
|
7
|
-
* Warning: only works on first render, does not update on label element resize.
|
|
7
|
+
* Updates dynamically on content changes (but not on resize!)
|
|
8
8
|
*/
|
|
9
|
-
export const useOverflowTooltipLabel = () => {
|
|
9
|
+
export const useOverflowTooltipLabel = (content: React.ReactNode) => {
|
|
10
10
|
const parentTooltip = useTooltipContext();
|
|
11
11
|
const [tooltipLabel, setTooltipLabel] = React.useState<string | undefined>(undefined);
|
|
12
|
-
const
|
|
13
|
-
(labelElement: HTMLElement | null) => {
|
|
14
|
-
if (!labelElement || !!parentTooltip) {
|
|
15
|
-
// Skip if label element is unknown
|
|
16
|
-
// Skip if the parent has a tooltip
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
12
|
+
const [labelElement, setLabelElement] = React.useState<HTMLElement | null>(null);
|
|
19
13
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
14
|
+
React.useLayoutEffect(() => {
|
|
15
|
+
if (
|
|
16
|
+
// Not inside a tooltip
|
|
17
|
+
!parentTooltip &&
|
|
18
|
+
labelElement &&
|
|
19
|
+
// Not inside a visually hidden
|
|
20
|
+
!labelElement?.closest(`.${VISUALLY_HIDDEN}`) &&
|
|
21
|
+
// Text overflows
|
|
22
|
+
labelElement.offsetWidth < labelElement.scrollWidth
|
|
23
|
+
) {
|
|
24
|
+
// Set tooltip label
|
|
25
|
+
setTooltipLabel(labelElement.innerText);
|
|
26
|
+
} else {
|
|
27
|
+
setTooltipLabel(undefined);
|
|
28
|
+
}
|
|
29
|
+
}, [labelElement, parentTooltip, content]);
|
|
27
30
|
|
|
28
|
-
return { labelRef, tooltipLabel };
|
|
31
|
+
return { labelRef: setLabelElement, tooltipLabel };
|
|
29
32
|
};
|
package/src/index.ts
CHANGED
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
* Components listed here will be exposed to NPM in '@lumx/react'.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
|
-
export * from '
|
|
5
|
+
export * from '@lumx/core/js/constants';
|
|
6
|
+
export * from '@lumx/core/js/types';
|
|
7
|
+
|
|
6
8
|
export * from './components/alert-dialog';
|
|
7
9
|
export * from './components/autocomplete';
|
|
8
10
|
export * from './components/avatar';
|
|
@@ -3,7 +3,8 @@ import dropRight from 'lodash/dropRight';
|
|
|
3
3
|
import last from 'lodash/last';
|
|
4
4
|
import partition from 'lodash/partition';
|
|
5
5
|
import reduce from 'lodash/reduce';
|
|
6
|
-
|
|
6
|
+
|
|
7
|
+
import { Predicate } from '@lumx/core/js/types';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Similar to lodash `partition` function but working with multiple predicates.
|