@lumx/react 3.9.1-alpha.2 → 3.9.2-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/_internal/types.d.ts +8 -1
- package/index.d.ts +4 -9
- package/index.js +16 -11
- package/index.js.map +1 -1
- package/package.json +3 -3
- package/src/components/side-navigation/SideNavigationItem.tsx +2 -7
- package/src/components/tooltip/Tooltip.stories.tsx +8 -0
- package/src/components/tooltip/Tooltip.test.tsx +14 -0
- package/src/components/tooltip/Tooltip.tsx +22 -11
- package/src/utils/type.ts +9 -0
package/_internal/types.d.ts
CHANGED
|
@@ -32,6 +32,13 @@ interface HasClassName {
|
|
|
32
32
|
*/
|
|
33
33
|
className?: string;
|
|
34
34
|
}
|
|
35
|
+
interface HasCloseMode {
|
|
36
|
+
/**
|
|
37
|
+
* Choose how the children are hidden when closed
|
|
38
|
+
* ('hide' keeps the children in DOM but hide them, 'unmount' remove the children from the DOM).
|
|
39
|
+
*/
|
|
40
|
+
closeMode?: 'hide' | 'unmount';
|
|
41
|
+
}
|
|
35
42
|
/**
|
|
36
43
|
* Define a generic props types.
|
|
37
44
|
*/
|
|
@@ -318,4 +325,4 @@ declare const ThumbnailObjectFit: {
|
|
|
318
325
|
};
|
|
319
326
|
type ThumbnailObjectFit = ValueOf<typeof ThumbnailObjectFit>;
|
|
320
327
|
|
|
321
|
-
export { Alignment as A, Comp as C, Emphasis as E, Falsy as F, GenericProps as G, HasTheme as H, Kind as K, Orientation as O, Size as S, Typography as T, ValueOf as V, WhiteSpace as W, HorizontalAlignment as a, ColorPalette as b, VerticalAlignment as c, ColorVariant as d, TextElement as e, HeadingElement as f, AspectRatio as g, FocusPoint as h, ThumbnailObjectFit as i, ThumbnailSize as j, ThumbnailVariant as k, HasClassName as l, HasAriaLabelOrLabelledBy as m, ComponentRef as n,
|
|
328
|
+
export { Alignment as A, Comp as C, Emphasis as E, Falsy as F, GenericProps as G, HasTheme as H, Kind as K, Orientation as O, Size as S, Typography as T, ValueOf as V, WhiteSpace as W, HorizontalAlignment as a, ColorPalette as b, VerticalAlignment as c, ColorVariant as d, TextElement as e, HeadingElement as f, AspectRatio as g, FocusPoint as h, ThumbnailObjectFit as i, ThumbnailSize as j, ThumbnailVariant as k, HasClassName as l, HasAriaLabelOrLabelledBy as m, ComponentRef as n, HasCloseMode as o, GlobalSize as p, TypographyInterface as q, Color as r, Theme as s, TypographyTitleCustom as t, TypographyCustom as u, Callback as v, ThumbnailAspectRatio as w };
|
package/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { ReactNode, SyntheticEvent, ReactElement, MouseEventHandler, KeyboardEventHandler, AriaAttributes, DetailedHTMLProps, ButtonHTMLAttributes, InputHTMLAttributes, Ref, RefObject, ImgHTMLAttributes, CSSProperties, SetStateAction, Key } from 'react';
|
|
2
|
-
import { K as Kind, C as Comp, G as GenericProps, H as HasTheme, a as HorizontalAlignment, S as Size, b as ColorPalette, E as Emphasis, V as ValueOf, A as Alignment, c as VerticalAlignment, O as Orientation, d as ColorVariant, T as Typography, e as TextElement, W as WhiteSpace, f as HeadingElement, g as AspectRatio, F as Falsy, h as FocusPoint, i as ThumbnailObjectFit, j as ThumbnailSize, k as ThumbnailVariant, l as HasClassName, m as HasAriaLabelOrLabelledBy, n as ComponentRef, o as
|
|
3
|
-
export { A as Alignment, g as AspectRatio,
|
|
2
|
+
import { K as Kind, C as Comp, G as GenericProps, H as HasTheme, a as HorizontalAlignment, S as Size, b as ColorPalette, E as Emphasis, V as ValueOf, A as Alignment, c as VerticalAlignment, O as Orientation, d as ColorVariant, T as Typography, e as TextElement, W as WhiteSpace, f as HeadingElement, g as AspectRatio, F as Falsy, h as FocusPoint, i as ThumbnailObjectFit, j as ThumbnailSize, k as ThumbnailVariant, l as HasClassName, m as HasAriaLabelOrLabelledBy, n as ComponentRef, o as HasCloseMode, p as GlobalSize, q as TypographyInterface } from './_internal/types.js';
|
|
3
|
+
export { A as Alignment, g as AspectRatio, v as Callback, r as Color, b as ColorPalette, d as ColorVariant, E as Emphasis, h as FocusPoint, G as GenericProps, p as GlobalSize, f as HeadingElement, a as HorizontalAlignment, K as Kind, O as Orientation, S as Size, e as TextElement, s as Theme, w as ThumbnailAspectRatio, i as ThumbnailObjectFit, j as ThumbnailSize, k as ThumbnailVariant, T as Typography, u as TypographyCustom, q as TypographyInterface, t as TypographyTitleCustom, c as VerticalAlignment, W as WhiteSpace } from './_internal/types.js';
|
|
4
4
|
|
|
5
5
|
interface AlertDialogProps extends Omit<DialogProps, 'header' | 'footer'> {
|
|
6
6
|
/** Message variant. */
|
|
@@ -2209,7 +2209,7 @@ declare const SideNavigation: Comp<SideNavigationProps, HTMLUListElement>;
|
|
|
2209
2209
|
/**
|
|
2210
2210
|
* Defines the props of the component.
|
|
2211
2211
|
*/
|
|
2212
|
-
interface SideNavigationItemProps extends GenericProps {
|
|
2212
|
+
interface SideNavigationItemProps extends GenericProps, HasCloseMode {
|
|
2213
2213
|
/** SideNavigationItem elements. */
|
|
2214
2214
|
children?: ReactNode;
|
|
2215
2215
|
/** Emphasis variant. */
|
|
@@ -2228,11 +2228,6 @@ interface SideNavigationItemProps extends GenericProps {
|
|
|
2228
2228
|
linkProps?: React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>;
|
|
2229
2229
|
/** Props to pass to the toggle button (minus those already set by the SideNavigationItem props). */
|
|
2230
2230
|
toggleButtonProps: Pick<IconButtonProps, 'label'> & Omit<IconButtonProps, 'label' | 'onClick' | 'icon' | 'emphasis' | 'color' | 'size'>;
|
|
2231
|
-
/**
|
|
2232
|
-
* Choose how the children are hidden when closed
|
|
2233
|
-
* ('hide' keeps the children in DOM but hide them, 'unmount' remove the children from the DOM).
|
|
2234
|
-
*/
|
|
2235
|
-
closeMode?: 'hide' | 'unmount';
|
|
2236
2231
|
/** On action button click callback. */
|
|
2237
2232
|
onActionClick?(evt: React.MouseEvent): void;
|
|
2238
2233
|
/** On click callback. */
|
|
@@ -2872,7 +2867,7 @@ type TooltipPlacement = Extract<Placement, 'top' | 'right' | 'bottom' | 'left'>;
|
|
|
2872
2867
|
/**
|
|
2873
2868
|
* Defines the props of the component.
|
|
2874
2869
|
*/
|
|
2875
|
-
interface TooltipProps extends GenericProps {
|
|
2870
|
+
interface TooltipProps extends GenericProps, HasCloseMode {
|
|
2876
2871
|
/** Anchor (element on which we activate the tooltip). */
|
|
2877
2872
|
children: ReactNode;
|
|
2878
2873
|
/** Delay (in ms) before closing the tooltip. */
|
package/index.js
CHANGED
|
@@ -14080,7 +14080,7 @@ function useTooltipOpen(delay, anchorElement) {
|
|
|
14080
14080
|
};
|
|
14081
14081
|
}
|
|
14082
14082
|
|
|
14083
|
-
const _excluded$1q = ["label", "children", "className", "delay", "placement", "forceOpen"];
|
|
14083
|
+
const _excluded$1q = ["label", "children", "className", "delay", "placement", "forceOpen", "closeMode"];
|
|
14084
14084
|
|
|
14085
14085
|
/** Position of the tooltip relative to the anchor element. */
|
|
14086
14086
|
|
|
@@ -14102,7 +14102,8 @@ const CLASSNAME$1h = getRootClassName(COMPONENT_NAME$1k);
|
|
|
14102
14102
|
* Component default props.
|
|
14103
14103
|
*/
|
|
14104
14104
|
const DEFAULT_PROPS$11 = {
|
|
14105
|
-
placement: Placement.BOTTOM
|
|
14105
|
+
placement: Placement.BOTTOM,
|
|
14106
|
+
closeMode: 'hide'
|
|
14106
14107
|
};
|
|
14107
14108
|
|
|
14108
14109
|
/**
|
|
@@ -14125,11 +14126,12 @@ const Tooltip = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
14125
14126
|
className,
|
|
14126
14127
|
delay,
|
|
14127
14128
|
placement,
|
|
14128
|
-
forceOpen
|
|
14129
|
+
forceOpen,
|
|
14130
|
+
closeMode
|
|
14129
14131
|
} = props,
|
|
14130
14132
|
forwardedProps = _objectWithoutProperties(props, _excluded$1q);
|
|
14131
14133
|
// Disable in SSR.
|
|
14132
|
-
if (!DOCUMENT) {
|
|
14134
|
+
if (!DOCUMENT && closeMode === 'unmount') {
|
|
14133
14135
|
return /*#__PURE__*/React.createElement(React.Fragment, null, children);
|
|
14134
14136
|
}
|
|
14135
14137
|
const id = useId();
|
|
@@ -14153,25 +14155,28 @@ const Tooltip = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
14153
14155
|
onPopperMount
|
|
14154
14156
|
} = useTooltipOpen(delay, anchorElement);
|
|
14155
14157
|
const isOpen = (isActivated || forceOpen) && !!label;
|
|
14156
|
-
const
|
|
14157
|
-
|
|
14158
|
+
const isMounted = isOpen || closeMode === 'hide';
|
|
14159
|
+
const wrappedChildren = useInjectTooltipRef(children, setAnchorElement, isMounted, id, label);
|
|
14160
|
+
const labelLines = label ? label.split('\n') : [];
|
|
14161
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(TooltipContextProvider, null, wrappedChildren), isMounted && /*#__PURE__*/createPortal( /*#__PURE__*/React.createElement("div", _extends({
|
|
14158
14162
|
ref: mergeRefs(ref, setPopperElement, onPopperMount)
|
|
14159
14163
|
}, forwardedProps, {
|
|
14160
14164
|
id: id,
|
|
14161
14165
|
role: "tooltip",
|
|
14162
|
-
"aria-label": label,
|
|
14166
|
+
"aria-label": label || '',
|
|
14163
14167
|
className: classnames(className, handleBasicClasses({
|
|
14164
14168
|
prefix: CLASSNAME$1h,
|
|
14165
|
-
position
|
|
14169
|
+
position,
|
|
14170
|
+
hidden: !isOpen && closeMode === 'hide'
|
|
14166
14171
|
})),
|
|
14167
14172
|
style: styles.popper
|
|
14168
14173
|
}, attributes.popper), /*#__PURE__*/React.createElement("div", {
|
|
14169
14174
|
className: `${CLASSNAME$1h}__arrow`
|
|
14170
14175
|
}), /*#__PURE__*/React.createElement("div", {
|
|
14171
14176
|
className: `${CLASSNAME$1h}__inner`
|
|
14172
|
-
},
|
|
14173
|
-
key:
|
|
14174
|
-
},
|
|
14177
|
+
}, labelLines.map(line => /*#__PURE__*/React.createElement("p", {
|
|
14178
|
+
key: line
|
|
14179
|
+
}, line)))), document.body));
|
|
14175
14180
|
});
|
|
14176
14181
|
Tooltip.displayName = COMPONENT_NAME$1k;
|
|
14177
14182
|
Tooltip.className = CLASSNAME$1h;
|