@lumx/react 4.4.1-alpha.1 → 4.4.1-alpha.2
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/{DpdvhbTO.js → BfgxEBp6.js} +61 -28
- package/_internal/BfgxEBp6.js.map +1 -0
- package/index.d.ts +24 -8
- package/index.js +271 -169
- package/index.js.map +1 -1
- package/package.json +4 -6
- package/utils/index.d.ts +22 -5
- package/utils/index.js +1 -1
- package/_internal/DpdvhbTO.js.map +0 -1
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React__default, { useContext, useEffect, useMemo, useRef, createContext } from 'react';
|
|
2
2
|
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
3
|
-
import isEmpty from 'lodash/isEmpty.js';
|
|
4
3
|
import { createPortal } from 'react-dom';
|
|
5
4
|
|
|
6
5
|
const DisabledStateContext = /*#__PURE__*/React__default.createContext({
|
|
@@ -27,11 +26,57 @@ function useDisabledStateContext() {
|
|
|
27
26
|
return useContext(DisabledStateContext);
|
|
28
27
|
}
|
|
29
28
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
/**
|
|
30
|
+
* Shared types and logic for ClickAway detection.
|
|
31
|
+
*
|
|
32
|
+
* ClickAway detects clicks outside a set of elements and triggers a callback.
|
|
33
|
+
* The core logic (event listening + target checking) is framework-agnostic.
|
|
34
|
+
* Framework-specific wrappers (React hook, Vue composable) and context providers
|
|
35
|
+
* (React context, Vue provide/inject) are implemented in each framework package.
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
/** Event types that trigger click away detection. */
|
|
39
|
+
const CLICK_AWAY_EVENT_TYPES = ['mousedown', 'touchstart'];
|
|
40
|
+
|
|
41
|
+
/** Callback triggered when a click away is detected. */
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Check if the click event targets are outside all the given elements.
|
|
45
|
+
*
|
|
46
|
+
* @param targets - The event target elements (from `event.target` and `event.composedPath()`).
|
|
47
|
+
* @param elements - The elements considered "inside" the click away context.
|
|
48
|
+
* @returns `true` if the click is outside all elements (i.e. a click away).
|
|
49
|
+
*/
|
|
50
|
+
function isClickAway(targets, elements) {
|
|
51
|
+
return !elements.some(element => targets.some(target => element?.contains(target)));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Imperative setup for click away detection.
|
|
56
|
+
* Adds mousedown/touchstart listeners on `document` and calls the callback when a click
|
|
57
|
+
* occurs outside the elements returned by `getElements`.
|
|
58
|
+
*
|
|
59
|
+
* @param getElements - Getter returning the current list of elements considered "inside".
|
|
60
|
+
* @param callback - Callback to invoke on click away.
|
|
61
|
+
* @returns A teardown function that removes the event listeners.
|
|
62
|
+
*/
|
|
63
|
+
function setupClickAway(getElements, callback) {
|
|
64
|
+
if (!callback) {
|
|
65
|
+
return undefined;
|
|
66
|
+
}
|
|
67
|
+
const listener = evt => {
|
|
68
|
+
const targets = [evt.composedPath?.()[0], evt.target];
|
|
69
|
+
const elements = getElements();
|
|
70
|
+
if (elements.length > 0 && isClickAway(targets, elements)) {
|
|
71
|
+
callback(evt);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
CLICK_AWAY_EVENT_TYPES.forEach(evtType => document.addEventListener(evtType, listener));
|
|
75
|
+
return () => {
|
|
76
|
+
CLICK_AWAY_EVENT_TYPES.forEach(evtType => document.removeEventListener(evtType, listener));
|
|
77
|
+
};
|
|
34
78
|
}
|
|
79
|
+
|
|
35
80
|
/**
|
|
36
81
|
* Listen to clicks away from the given elements and callback the passed in function.
|
|
37
82
|
*
|
|
@@ -42,22 +87,12 @@ function useClickAway({
|
|
|
42
87
|
childrenRefs
|
|
43
88
|
}) {
|
|
44
89
|
useEffect(() => {
|
|
45
|
-
const {
|
|
46
|
-
current
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
return undefined;
|
|
50
|
-
}
|
|
51
|
-
const listener = evt => {
|
|
52
|
-
const targets = [evt.composedPath?.()[0], evt.target];
|
|
53
|
-
if (isClickAway(targets, currentRefs)) {
|
|
54
|
-
callback(evt);
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
EVENT_TYPES.forEach(evtType => document.addEventListener(evtType, listener));
|
|
58
|
-
return () => {
|
|
59
|
-
EVENT_TYPES.forEach(evtType => document.removeEventListener(evtType, listener));
|
|
90
|
+
const getElements = () => {
|
|
91
|
+
const refs = childrenRefs.current;
|
|
92
|
+
if (!refs) return [];
|
|
93
|
+
return refs.map(ref => ref?.current).filter(Boolean);
|
|
60
94
|
};
|
|
95
|
+
return setupClickAway(getElements, callback);
|
|
61
96
|
}, [callback, childrenRefs]);
|
|
62
97
|
}
|
|
63
98
|
|
|
@@ -116,11 +151,6 @@ const ClickAwayProvider = ({
|
|
|
116
151
|
};
|
|
117
152
|
ClickAwayProvider.displayName = 'ClickAwayProvider';
|
|
118
153
|
|
|
119
|
-
/**
|
|
120
|
-
* Portal initializing function.
|
|
121
|
-
* If it does not provide a container, the Portal children will render in classic React tree and not in a portal.
|
|
122
|
-
*/
|
|
123
|
-
|
|
124
154
|
const PortalContext = /*#__PURE__*/React__default.createContext(() => ({
|
|
125
155
|
container: document.body
|
|
126
156
|
}));
|
|
@@ -147,13 +177,16 @@ const Portal = ({
|
|
|
147
177
|
React__default.useLayoutEffect(() => {
|
|
148
178
|
return context?.teardown;
|
|
149
179
|
}, [context?.teardown, enabled]);
|
|
150
|
-
|
|
180
|
+
const {
|
|
181
|
+
container
|
|
182
|
+
} = context ?? {};
|
|
183
|
+
if (!container || typeof container === 'string') {
|
|
151
184
|
return /*#__PURE__*/jsx(Fragment, {
|
|
152
185
|
children: children
|
|
153
186
|
});
|
|
154
187
|
}
|
|
155
|
-
return /*#__PURE__*/createPortal(children,
|
|
188
|
+
return /*#__PURE__*/createPortal(children, container);
|
|
156
189
|
};
|
|
157
190
|
|
|
158
191
|
export { ClickAwayProvider as C, DisabledStateProvider as D, Portal as P, PortalProvider as a, useDisabledStateContext as u };
|
|
159
|
-
//# sourceMappingURL=
|
|
192
|
+
//# sourceMappingURL=BfgxEBp6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BfgxEBp6.js","sources":["../../src/utils/disabled/DisabledStateContext.tsx","../../../lumx-core/src/js/utils/ClickAway/index.ts","../../src/hooks/useClickAway.tsx","../../src/utils/ClickAwayProvider/ClickAwayProvider.tsx","../../src/utils/Portal/PortalProvider.tsx","../../src/utils/Portal/Portal.tsx"],"sourcesContent":["import React, { useContext } from 'react';\n\nimport { DisabledStateContextValue } from '@lumx/core/js/utils/disabledState';\n\nexport const DisabledStateContext = React.createContext<DisabledStateContextValue>({ state: null });\n\nexport type DisabledStateProviderProps = DisabledStateContextValue & {\n children: React.ReactNode;\n};\n\n/**\n * Disabled state provider.\n * All nested LumX Design System components inherit this disabled state.\n */\nexport function DisabledStateProvider({ children, ...value }: DisabledStateProviderProps) {\n return <DisabledStateContext.Provider value={value}>{children}</DisabledStateContext.Provider>;\n}\n\n/**\n * Get DisabledState context value\n */\nexport function useDisabledStateContext(): DisabledStateContextValue {\n return useContext(DisabledStateContext);\n}\n","/**\n * Shared types and logic for ClickAway detection.\n *\n * ClickAway detects clicks outside a set of elements and triggers a callback.\n * The core logic (event listening + target checking) is framework-agnostic.\n * Framework-specific wrappers (React hook, Vue composable) and context providers\n * (React context, Vue provide/inject) are implemented in each framework package.\n */\n\nimport type { Falsy } from '@lumx/core/js/types';\n\n/** Event types that trigger click away detection. */\nexport const CLICK_AWAY_EVENT_TYPES = ['mousedown', 'touchstart'] as const;\n\n/** Callback triggered when a click away is detected. */\nexport type ClickAwayCallback = EventListener | Falsy;\n\n/**\n * Check if the click event targets are outside all the given elements.\n *\n * @param targets - The event target elements (from `event.target` and `event.composedPath()`).\n * @param elements - The elements considered \"inside\" the click away context.\n * @returns `true` if the click is outside all elements (i.e. a click away).\n */\nexport function isClickAway(targets: HTMLElement[], elements: HTMLElement[]): boolean {\n return !elements.some((element) => targets.some((target) => element?.contains(target)));\n}\n\n/**\n * Imperative setup for click away detection.\n * Adds mousedown/touchstart listeners on `document` and calls the callback when a click\n * occurs outside the elements returned by `getElements`.\n *\n * @param getElements - Getter returning the current list of elements considered \"inside\".\n * @param callback - Callback to invoke on click away.\n * @returns A teardown function that removes the event listeners.\n */\nexport function setupClickAway(\n getElements: () => HTMLElement[],\n callback: ClickAwayCallback,\n): (() => void) | undefined {\n if (!callback) {\n return undefined;\n }\n\n const listener: EventListener = (evt) => {\n const targets = [evt.composedPath?.()[0], evt.target] as HTMLElement[];\n const elements = getElements();\n if (elements.length > 0 && isClickAway(targets, elements)) {\n callback(evt);\n }\n };\n\n CLICK_AWAY_EVENT_TYPES.forEach((evtType) => document.addEventListener(evtType, listener));\n return () => {\n CLICK_AWAY_EVENT_TYPES.forEach((evtType) => document.removeEventListener(evtType, listener));\n };\n}\n","import { RefObject, useEffect } from 'react';\n\nimport { Falsy } from '@lumx/react/utils/type';\nimport { setupClickAway } from '@lumx/core/js/utils/ClickAway';\n\nexport interface ClickAwayParameters {\n /**\n * A callback function to call when the user clicks away from the elements.\n */\n callback: EventListener | Falsy;\n /**\n * Elements considered within the click away context (clicking outside them will trigger the click away callback).\n */\n childrenRefs: RefObject<Array<RefObject<HTMLElement>>>;\n}\n\n/**\n * Listen to clicks away from the given elements and callback the passed in function.\n *\n * Warning: If you need to detect click away on nested React portals, please use the `ClickAwayProvider` component.\n */\nexport function useClickAway({ callback, childrenRefs }: ClickAwayParameters): void {\n useEffect(() => {\n const getElements = () => {\n const refs = childrenRefs.current;\n if (!refs) return [];\n return refs.map((ref) => ref?.current).filter(Boolean) as HTMLElement[];\n };\n return setupClickAway(getElements, callback);\n }, [callback, childrenRefs]);\n}\n","import { createContext, RefObject, useContext, useEffect, useMemo, useRef } from 'react';\nimport { ClickAwayParameters, useClickAway } from '@lumx/react/hooks/useClickAway';\n\ninterface ContextValue {\n childrenRefs: Array<RefObject<HTMLElement>>;\n addRefs(...newChildrenRefs: Array<RefObject<HTMLElement>>): void;\n}\n\nconst ClickAwayAncestorContext = createContext<ContextValue | null>(null);\n\ninterface ClickAwayProviderProps extends ClickAwayParameters {\n /**\n * (Optional) Element that should be considered as part of the parent\n */\n parentRef?: RefObject<HTMLElement>;\n /**\n * Children\n */\n children?: React.ReactNode;\n}\n\n/**\n * Component combining the `useClickAway` hook with a React context to hook into the React component tree and make sure\n * we take into account both the DOM tree and the React tree to detect click away.\n *\n * @return the react component.\n */\nexport const ClickAwayProvider: React.FC<ClickAwayProviderProps> = ({\n children,\n callback,\n childrenRefs,\n parentRef,\n}) => {\n const parentContext = useContext(ClickAwayAncestorContext);\n const currentContext = useMemo(() => {\n const context: ContextValue = {\n childrenRefs: [],\n /**\n * Add element refs to the current context and propagate to the parent context.\n */\n addRefs(...newChildrenRefs) {\n // Add element refs that should be considered as inside the click away context.\n context.childrenRefs.push(...newChildrenRefs);\n\n if (parentContext) {\n // Also add then to the parent context\n parentContext.addRefs(...newChildrenRefs);\n if (parentRef) {\n // The parent element is also considered as inside the parent click away context but not inside the current context\n parentContext.addRefs(parentRef);\n }\n }\n },\n };\n return context;\n }, [parentContext, parentRef]);\n\n useEffect(() => {\n const { current: currentRefs } = childrenRefs;\n if (!currentRefs) {\n return;\n }\n currentContext.addRefs(...currentRefs);\n }, [currentContext, childrenRefs]);\n\n useClickAway({ callback, childrenRefs: useRef(currentContext.childrenRefs) });\n return <ClickAwayAncestorContext.Provider value={currentContext}>{children}</ClickAwayAncestorContext.Provider>;\n};\nClickAwayProvider.displayName = 'ClickAwayProvider';\n","import React from 'react';\nimport type { PortalInit } from '@lumx/core/js/utils/Portal';\n\nexport type { PortalInit, PortalProviderProps } from '@lumx/core/js/utils/Portal';\n\nexport const PortalContext = React.createContext<PortalInit>(() => ({ container: document.body }));\n\nexport interface ReactPortalProviderProps {\n children?: React.ReactNode;\n value: PortalInit;\n}\n\n/**\n * Customize where <Portal> wrapped elements render (tooltip, popover, dialog, etc.)\n */\nexport const PortalProvider: React.FC<ReactPortalProviderProps> = PortalContext.Provider;\n","import React from 'react';\nimport { createPortal } from 'react-dom';\nimport { PortalContext } from './PortalProvider';\n\nexport type { PortalProps } from '@lumx/core/js/utils/Portal';\n\nexport interface ReactPortalProps {\n enabled?: boolean;\n children: React.ReactNode;\n}\n\n/**\n * Render children in a portal outside the current DOM position\n * (defaults to `document.body` but can be customized with the PortalContextProvider)\n */\nexport const Portal: React.FC<ReactPortalProps> = ({ children, enabled = true }) => {\n const init = React.useContext(PortalContext);\n const context = React.useMemo(\n () => {\n return enabled ? init() : null;\n },\n // Only update on 'enabled'\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [enabled],\n );\n\n React.useLayoutEffect(() => {\n return context?.teardown;\n }, [context?.teardown, enabled]);\n\n const { container } = context ?? {};\n if (!container || typeof container === 'string') {\n return <>{children}</>;\n }\n return createPortal(children, container);\n};\n"],"names":["DisabledStateContext","React","createContext","state","DisabledStateProvider","children","value","_jsx","Provider","useDisabledStateContext","useContext","CLICK_AWAY_EVENT_TYPES","isClickAway","targets","elements","some","element","target","contains","setupClickAway","getElements","callback","undefined","listener","evt","composedPath","length","forEach","evtType","document","addEventListener","removeEventListener","useClickAway","childrenRefs","useEffect","refs","current","map","ref","filter","Boolean","ClickAwayAncestorContext","ClickAwayProvider","parentRef","parentContext","currentContext","useMemo","context","addRefs","newChildrenRefs","push","currentRefs","useRef","displayName","PortalContext","container","body","PortalProvider","Portal","enabled","init","useLayoutEffect","teardown","_Fragment","createPortal"],"mappings":";;;;AAIO,MAAMA,oBAAoB,gBAAGC,cAAK,CAACC,aAAa,CAA4B;AAAEC,EAAAA,KAAK,EAAE;AAAK,CAAC,CAAC;AAMnG;AACA;AACA;AACA;AACO,SAASC,qBAAqBA,CAAC;EAAEC,QAAQ;EAAE,GAAGC;AAAkC,CAAC,EAAE;AACtF,EAAA,oBAAOC,GAAA,CAACP,oBAAoB,CAACQ,QAAQ,EAAA;AAACF,IAAAA,KAAK,EAAEA,K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AI,EAAE,GAAG,IAAI;EAClC,CAAC;AACD;AACA;EACA,CAACD,OAAO,CACZ,CAAC;EAED1D,cAAK,CAAC4D,eAAe,CAAC,MAAM;IACxB,OAAOd,OAAO,EAAEe,QAAQ;EAC5B,CAAC,EAAE,CAACf,OAAO,EAAEe,QAAQ,EAAEH,OAAO,CAAC,CAAC;EAEhC,MAAM;AAAEJ,IAAAA;AAAU,GAAC,GAAGR,OAAO,IAAI,EAAE;AACnC,EAAA,IAAI,CAACQ,SAAS,IAAI,OAAOA,SAAS,KAAK,QAAQ,EAAE;IAC7C,oBAAOhD,GAAA,CAAAwD,QAAA,EAAA;AAAA1D,MAAAA,QAAA,EAAGA;AAAQ,KAAG,CAAC;AAC1B,EAAA;AACA,EAAA,oBAAO2D,YAAY,CAAC3D,QAAQ,EAAEkD,SAAS,CAAC;AAC5C;;;;"}
|
package/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Kind as Kind$1, HorizontalAlignment as HorizontalAlignment$1, ColorPalette as ColorPalette$1, Size as Size$1, Theme as Theme$1, Orientation as Orientation$1, Alignment as Alignment$1, AspectRatio as AspectRatio$1, ColorWithVariants as ColorWithVariants$1, ColorVariant as ColorVariant$1, Typography as Typography$1, Emphasis as Emphasis$1 } from '@lumx/core/js/constants';
|
|
2
2
|
export * from '@lumx/core/js/constants';
|
|
3
3
|
import * as _lumx_core_js_types from '@lumx/core/js/types';
|
|
4
|
-
import { GenericProps as GenericProps$1, HasTheme as HasTheme$1, ValueOf as ValueOf$1, PropsToOverride, HasAriaDisabled as HasAriaDisabled$1, HasCloseMode, HasClassName as HasClassName$1, JSXElement as JSXElement$1, CommonRef as CommonRef$1, Falsy, HeadingElement as HeadingElement$1, HasRequiredLinkHref, HasAriaLabelOrLabelledBy } from '@lumx/core/js/types';
|
|
4
|
+
import { GenericProps as GenericProps$1, HasTheme as HasTheme$1, ValueOf as ValueOf$1, PropsToOverride, HasAriaDisabled as HasAriaDisabled$1, HasCloseMode as HasCloseMode$1, HasClassName as HasClassName$1, JSXElement as JSXElement$1, CommonRef as CommonRef$1, Falsy, HeadingElement as HeadingElement$1, HasRequiredLinkHref, HasAriaLabelOrLabelledBy } from '@lumx/core/js/types';
|
|
5
5
|
export * from '@lumx/core/js/types';
|
|
6
6
|
import * as React$1 from 'react';
|
|
7
7
|
import React__default, { Ref, ReactElement, ReactNode, SyntheticEvent, MouseEventHandler, KeyboardEventHandler, RefObject, CSSProperties, ImgHTMLAttributes, AriaAttributes as AriaAttributes$1, SetStateAction, Key, ElementType, ComponentProps } from 'react';
|
|
@@ -260,6 +260,14 @@ interface HasClassName {
|
|
|
260
260
|
className?: string;
|
|
261
261
|
}
|
|
262
262
|
|
|
263
|
+
interface HasCloseMode {
|
|
264
|
+
/**
|
|
265
|
+
* Choose how the children are hidden when closed
|
|
266
|
+
* ('hide' keeps the children in DOM but hide them, 'unmount' remove the children from the DOM).
|
|
267
|
+
*/
|
|
268
|
+
closeMode?: 'hide' | 'unmount';
|
|
269
|
+
}
|
|
270
|
+
|
|
263
271
|
/**
|
|
264
272
|
* Alignments.
|
|
265
273
|
*/
|
|
@@ -1400,7 +1408,7 @@ declare const Dropdown: Comp<DropdownProps, HTMLDivElement>;
|
|
|
1400
1408
|
/**
|
|
1401
1409
|
* Defines the props of the component.
|
|
1402
1410
|
*/
|
|
1403
|
-
interface ExpansionPanelProps extends GenericProps$1, HasCloseMode, HasTheme$1 {
|
|
1411
|
+
interface ExpansionPanelProps extends GenericProps$1, HasCloseMode$1, HasTheme$1 {
|
|
1404
1412
|
/** Whether the expansion panel has a background. */
|
|
1405
1413
|
hasBackground?: boolean;
|
|
1406
1414
|
/** Whether the header has a divider. */
|
|
@@ -2927,7 +2935,7 @@ declare const SideNavigation: Comp<SideNavigationProps, HTMLUListElement>;
|
|
|
2927
2935
|
/**
|
|
2928
2936
|
* Defines the props of the component.
|
|
2929
2937
|
*/
|
|
2930
|
-
interface SideNavigationItemProps extends GenericProps$1, HasCloseMode {
|
|
2938
|
+
interface SideNavigationItemProps extends GenericProps$1, HasCloseMode$1 {
|
|
2931
2939
|
/** SideNavigationItem elements. */
|
|
2932
2940
|
children?: ReactNode;
|
|
2933
2941
|
/** Emphasis variant. */
|
|
@@ -3764,13 +3772,11 @@ declare const Toolbar: Comp<ToolbarProps, HTMLDivElement>;
|
|
|
3764
3772
|
declare const ARIA_LINK_MODES: readonly ["aria-describedby", "aria-labelledby"];
|
|
3765
3773
|
|
|
3766
3774
|
/** Position of the tooltip relative to the anchor element. */
|
|
3767
|
-
type TooltipPlacement =
|
|
3775
|
+
type TooltipPlacement = 'top' | 'right' | 'bottom' | 'left';
|
|
3768
3776
|
/**
|
|
3769
|
-
*
|
|
3777
|
+
* Framework-agnostic tooltip props (shared between React and Vue wrappers).
|
|
3770
3778
|
*/
|
|
3771
|
-
interface TooltipProps extends
|
|
3772
|
-
/** Anchor (element on which we activate the tooltip). */
|
|
3773
|
-
children: ReactNode;
|
|
3779
|
+
interface TooltipProps$1 extends HasCloseMode {
|
|
3774
3780
|
/** Delay (in ms) before closing the tooltip. */
|
|
3775
3781
|
delay?: number;
|
|
3776
3782
|
/** Whether the tooltip is displayed even without the mouse hovering the anchor. */
|
|
@@ -3781,6 +3787,16 @@ interface TooltipProps extends GenericProps$1, HasCloseMode {
|
|
|
3781
3787
|
placement?: TooltipPlacement;
|
|
3782
3788
|
/** Choose how the tooltip text should link to the anchor */
|
|
3783
3789
|
ariaLinkMode?: (typeof ARIA_LINK_MODES)[number];
|
|
3790
|
+
/** Z-index for the tooltip */
|
|
3791
|
+
zIndex?: number;
|
|
3792
|
+
}
|
|
3793
|
+
|
|
3794
|
+
/**
|
|
3795
|
+
* Defines the props of the component.
|
|
3796
|
+
*/
|
|
3797
|
+
interface TooltipProps extends GenericProps$1, TooltipProps$1 {
|
|
3798
|
+
/** Anchor (element on which we activate the tooltip). */
|
|
3799
|
+
children: ReactNode;
|
|
3784
3800
|
}
|
|
3785
3801
|
/**
|
|
3786
3802
|
* Tooltip component.
|