@lumx/react 4.4.1-alpha.0 → 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.
@@ -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
- const EVENT_TYPES = ['mousedown', 'touchstart'];
31
- function isClickAway(targets, refs) {
32
- // The targets elements are not contained in any of the listed element references.
33
- return !refs.some(ref => targets.some(target => ref?.current?.contains(target)));
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: currentRefs
47
- } = childrenRefs;
48
- if (!callback || !currentRefs || isEmpty(currentRefs)) {
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
- if (!context?.container) {
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, context.container);
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=DpdvhbTO.js.map
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":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ACJhF;AACA;AACA;AACA;AACO,MAAMkD,MAAkC,GAAGA,CAAC;EAAErD,QAAQ;AAAEsD,EAAAA,OAAO,GAAG;AAAK,CAAC,KAAK;AAChF,EAAA,MAAMC,IAAI,GAAG3D,cAAK,CAACS,UAAU,CAAC4C,aAAa,CAAC;AAC5C,EAAA,MAAMP,OAAO,GAAG9C,cAAK,CAAC6C,OAAO,CACzB,MAAM;AACF,IAAA,OAAOa,OAAO,GAAGC,IAAI,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
- import { Kind as Kind$1, HorizontalAlignment as HorizontalAlignment$1, Size as Size$1, ColorPalette as ColorPalette$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';
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';
@@ -253,43 +253,20 @@ interface AutocompleteMultipleProps extends AutocompleteProps {
253
253
  */
254
254
  declare const AutocompleteMultiple: Comp<AutocompleteMultipleProps, HTMLDivElement>;
255
255
 
256
- /**
257
- * Avatar sizes.
258
- */
259
- type AvatarSize = Extract<Size$1, 'xxs' | 'xs' | 's' | 'm' | 'l' | 'xl' | 'xxl'>;
260
- /**
261
- * Defines the props of the component.
262
- */
263
- interface AvatarProps extends GenericProps$1, HasTheme$1 {
264
- /** Action toolbar content. */
265
- actions?: ReactNode;
266
- /** Image alternative text. */
267
- alt: string;
268
- /** Badge. */
269
- badge?: ReactElement;
270
- /** Image URL. */
271
- image: string;
272
- /** Props to pass to the link wrapping the thumbnail. */
273
- linkProps?: React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>;
274
- /** Custom react component for the link (can be used to inject react router Link). */
275
- linkAs?: 'a' | any;
276
- /** On click callback. */
277
- onClick?: MouseEventHandler<HTMLDivElement>;
278
- /** On key press callback. */
279
- onKeyPress?: KeyboardEventHandler<HTMLDivElement>;
280
- /** Size variant. */
281
- size?: AvatarSize;
282
- /** Props to pass to the thumbnail (minus those already set by the Avatar props). */
283
- thumbnailProps?: Omit<ThumbnailProps, 'image' | 'alt' | 'size' | 'theme' | 'align' | 'fillHeight' | 'variant' | 'aspectRatio'>;
256
+ interface HasClassName {
257
+ /**
258
+ * Class name forwarded to the root element of the component.
259
+ */
260
+ className?: string;
261
+ }
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';
284
269
  }
285
- /**
286
- * Avatar component.
287
- *
288
- * @param props Component props.
289
- * @param ref Component ref.
290
- * @return React element.
291
- */
292
- declare const Avatar: Comp<AvatarProps, HTMLDivElement>;
293
270
 
294
271
  /**
295
272
  * Alignments.
@@ -478,13 +455,6 @@ type ColorVariant = ValueOf$1<typeof ColorVariant>;
478
455
  /** ColorPalette with all possible color variant combination */
479
456
  type ColorWithVariants = ColorPalette | Exclude<`${ColorPalette}-${ColorVariant}`, `light-D${number}` | `dark-D${number}`>;
480
457
 
481
- interface HasClassName {
482
- /**
483
- * Class name forwarded to the root element of the component.
484
- */
485
- className?: string;
486
- }
487
-
488
458
  interface HasTheme {
489
459
  /**
490
460
  * Theme adapting the component to light or dark background.
@@ -589,15 +559,23 @@ type FieldSelector<TObject, TValue> = keyof {
589
559
  */
590
560
  type Selector<TObject, TValue = string> = FieldSelector<TObject, TValue> | FunctionSelector<TObject, TValue>;
591
561
 
562
+ /**
563
+ * Avatar sizes.
564
+ */
565
+ type AvatarSize = Extract<Size, 'xxs' | 'xs' | 's' | 'm' | 'l' | 'xl' | 'xxl'>;
592
566
  /**
593
567
  * Defines the props of the component.
594
568
  */
595
- interface BadgeProps$1 extends HasClassName {
596
- /** Badge content. */
597
- children?: JSXElement;
598
- /** Color variant. */
599
- color?: ColorPalette;
600
- /** reference to the root element */
569
+ interface AvatarProps$1 extends HasTheme, HasClassName {
570
+ /** Action toolbar content. */
571
+ actions?: JSXElement;
572
+ /** Badge. */
573
+ badge?: JSXElement;
574
+ /** Image URL. */
575
+ image: JSXElement;
576
+ /** Size variant. */
577
+ size?: AvatarSize;
578
+ /** Props to pass to the thumbnail (minus those already set by the Avatar props). */
601
579
  ref?: CommonRef;
602
580
  }
603
581
 
@@ -610,6 +588,46 @@ interface BadgeProps$1 extends HasClassName {
610
588
  */
611
589
  type ReactToJSX<Props, OmitProps extends keyof Props = never> = Omit<Props, PropsToOverride | OmitProps>;
612
590
 
591
+ /**
592
+ * Defines the props of the component.
593
+ */
594
+ interface AvatarProps extends GenericProps$1, ReactToJSX<AvatarProps$1, 'actions' | 'badge' | 'image'> {
595
+ /** Action toolbar content. */
596
+ actions?: ReactNode;
597
+ /** Props to pass to the link wrapping the thumbnail. */
598
+ linkProps?: React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement>;
599
+ /** Custom react component for the link (can be used to inject react router Link). */
600
+ linkAs?: 'a' | any;
601
+ /** On click callback. */
602
+ onClick?: MouseEventHandler<HTMLDivElement>;
603
+ /** On key press callback. */
604
+ onKeyPress?: KeyboardEventHandler<HTMLDivElement>;
605
+ /** Image alternative text. */
606
+ alt: string;
607
+ /** Props to pass to the thumbnail (minus those already set by the Avatar props). */
608
+ thumbnailProps?: Omit<ThumbnailProps, 'image' | 'alt' | 'size' | 'theme' | 'align' | 'fillHeight' | 'variant' | 'aspectRatio'>;
609
+ }
610
+ /**
611
+ * Avatar component.
612
+ *
613
+ * @param props Component props.
614
+ * @param ref Component ref.
615
+ * @return React element.
616
+ */
617
+ declare const Avatar: Comp<AvatarProps, HTMLDivElement>;
618
+
619
+ /**
620
+ * Defines the props of the component.
621
+ */
622
+ interface BadgeProps$1 extends HasClassName {
623
+ /** Badge content. */
624
+ children?: JSXElement;
625
+ /** Color variant. */
626
+ color?: ColorPalette;
627
+ /** reference to the root element */
628
+ ref?: CommonRef;
629
+ }
630
+
613
631
  /**
614
632
  * Defines the props of the component.
615
633
  */
@@ -1390,7 +1408,7 @@ declare const Dropdown: Comp<DropdownProps, HTMLDivElement>;
1390
1408
  /**
1391
1409
  * Defines the props of the component.
1392
1410
  */
1393
- interface ExpansionPanelProps extends GenericProps$1, HasCloseMode, HasTheme$1 {
1411
+ interface ExpansionPanelProps extends GenericProps$1, HasCloseMode$1, HasTheme$1 {
1394
1412
  /** Whether the expansion panel has a background. */
1395
1413
  hasBackground?: boolean;
1396
1414
  /** Whether the header has a divider. */
@@ -1556,7 +1574,7 @@ declare const GenericBlockGapSize: Pick<{
1556
1574
  readonly medium: "medium";
1557
1575
  readonly big: "big";
1558
1576
  readonly huge: "huge";
1559
- }, "medium" | "tiny" | "regular" | "big" | "huge">;
1577
+ }, "tiny" | "regular" | "medium" | "big" | "huge">;
1560
1578
  type GenericBlockGapSize = ValueOf$1<typeof GenericBlockGapSize>;
1561
1579
 
1562
1580
  interface GenericBlockProps extends FlexBoxProps {
@@ -2917,7 +2935,7 @@ declare const SideNavigation: Comp<SideNavigationProps, HTMLUListElement>;
2917
2935
  /**
2918
2936
  * Defines the props of the component.
2919
2937
  */
2920
- interface SideNavigationItemProps extends GenericProps$1, HasCloseMode {
2938
+ interface SideNavigationItemProps extends GenericProps$1, HasCloseMode$1 {
2921
2939
  /** SideNavigationItem elements. */
2922
2940
  children?: ReactNode;
2923
2941
  /** Emphasis variant. */
@@ -3754,13 +3772,11 @@ declare const Toolbar: Comp<ToolbarProps, HTMLDivElement>;
3754
3772
  declare const ARIA_LINK_MODES: readonly ["aria-describedby", "aria-labelledby"];
3755
3773
 
3756
3774
  /** Position of the tooltip relative to the anchor element. */
3757
- type TooltipPlacement = Extract<Placement, 'top' | 'right' | 'bottom' | 'left'>;
3775
+ type TooltipPlacement = 'top' | 'right' | 'bottom' | 'left';
3758
3776
  /**
3759
- * Defines the props of the component.
3777
+ * Framework-agnostic tooltip props (shared between React and Vue wrappers).
3760
3778
  */
3761
- interface TooltipProps extends GenericProps$1, HasCloseMode {
3762
- /** Anchor (element on which we activate the tooltip). */
3763
- children: ReactNode;
3779
+ interface TooltipProps$1 extends HasCloseMode {
3764
3780
  /** Delay (in ms) before closing the tooltip. */
3765
3781
  delay?: number;
3766
3782
  /** Whether the tooltip is displayed even without the mouse hovering the anchor. */
@@ -3771,6 +3787,16 @@ interface TooltipProps extends GenericProps$1, HasCloseMode {
3771
3787
  placement?: TooltipPlacement;
3772
3788
  /** Choose how the tooltip text should link to the anchor */
3773
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;
3774
3800
  }
3775
3801
  /**
3776
3802
  * Tooltip component.