@lumx/react 4.29.0 → 4.29.1-alpha.1
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/{CcLi-Wuu.js → Dx4QtHFB.js} +52 -3
- package/_internal/Dx4QtHFB.js.map +1 -0
- package/index.d.ts +30 -7
- package/index.js +155 -146
- package/index.js.map +1 -1
- package/package.json +4 -4
- package/utils/index.d.ts +14 -1
- package/utils/index.js +1 -1
- package/_internal/CcLi-Wuu.js.map +0 -1
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
import React__default, { useContext, useEffect, useMemo, useRef, createContext } from 'react';
|
|
1
|
+
import React__default, { useContext, useEffect, useMemo, useRef, createContext, useCallback } from 'react';
|
|
2
2
|
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
3
3
|
import { createPortal } from 'react-dom';
|
|
4
|
+
import { VISUALLY_HIDDEN } from '@lumx/core/js/constants';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Visually hidden class name.
|
|
8
|
+
* Used to hide elements from view but keep them readable from screen readers
|
|
9
|
+
*/
|
|
10
|
+
const visuallyHidden = () => VISUALLY_HIDDEN;
|
|
4
11
|
|
|
5
12
|
const DisabledStateContext = /*#__PURE__*/React__default.createContext({
|
|
6
13
|
state: null
|
|
@@ -26,6 +33,31 @@ function useDisabledStateContext() {
|
|
|
26
33
|
return useContext(DisabledStateContext);
|
|
27
34
|
}
|
|
28
35
|
|
|
36
|
+
const DEFAULT_VALUE = {};
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Tooltip react context simply used as a marker to know when parent react node have a tooltip
|
|
40
|
+
*/
|
|
41
|
+
const TooltipContext = /*#__PURE__*/React__default.createContext(undefined);
|
|
42
|
+
const TooltipContextProvider = ({
|
|
43
|
+
children
|
|
44
|
+
}) => /*#__PURE__*/jsx(TooltipContext.Provider, {
|
|
45
|
+
value: DEFAULT_VALUE,
|
|
46
|
+
children: children
|
|
47
|
+
});
|
|
48
|
+
const useTooltipContext = () => React__default.useContext(TooltipContext);
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Get the text of an element when it overflows, else `undefined`.
|
|
52
|
+
*/
|
|
53
|
+
const getOverflowingText = element => {
|
|
54
|
+
// A visually hidden element measures 1px, so it would count as overflowing.
|
|
55
|
+
if (!element || element.closest(`.${visuallyHidden()}`)) return undefined;
|
|
56
|
+
// A hidden element measures 0, so it would count as overflowing.
|
|
57
|
+
if (element.offsetWidth === 0 || element.offsetWidth >= element.scrollWidth) return undefined;
|
|
58
|
+
return element.innerText;
|
|
59
|
+
};
|
|
60
|
+
|
|
29
61
|
/**
|
|
30
62
|
* Shared types and logic for ClickAway detection.
|
|
31
63
|
*
|
|
@@ -261,5 +293,22 @@ const Portal = ({
|
|
|
261
293
|
return /*#__PURE__*/createPortal(children, container);
|
|
262
294
|
};
|
|
263
295
|
|
|
264
|
-
|
|
265
|
-
|
|
296
|
+
/**
|
|
297
|
+
* Get a function tooltip label that gives the text of the label element only when it overflows.
|
|
298
|
+
*
|
|
299
|
+
* @example
|
|
300
|
+
* const { labelRef, tooltipLabel } = useOverflowTooltipLabel();
|
|
301
|
+
* <Tooltip label={tooltipLabel}><Text ref={labelRef} truncate>{text}</Text></Tooltip>
|
|
302
|
+
*/
|
|
303
|
+
const useOverflowTooltipLabel = () => {
|
|
304
|
+
const parentTooltip = useTooltipContext();
|
|
305
|
+
const labelRef = useRef(null);
|
|
306
|
+
const tooltipLabel = useCallback(() => parentTooltip ? undefined : getOverflowingText(labelRef.current), [parentTooltip]);
|
|
307
|
+
return {
|
|
308
|
+
labelRef,
|
|
309
|
+
tooltipLabel
|
|
310
|
+
};
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
export { ClickAwayProvider as C, DisabledStateProvider as D, InfiniteScroll as I, Portal as P, TooltipContextProvider as T, useTooltipContext as a, useOverflowTooltipLabel as b, PortalProvider as c, getOverflowingText as g, useDisabledStateContext as u, visuallyHidden as v };
|
|
314
|
+
//# sourceMappingURL=Dx4QtHFB.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Dx4QtHFB.js","sources":["../../../lumx-core/src/js/utils/classNames/visually-hidden/index.ts","../../src/utils/disabled/DisabledStateContext.tsx","../../src/components/tooltip/context.tsx","../../../lumx-core/src/js/utils/browser/getOverflowingText.ts","../../../lumx-core/src/js/utils/ClickAway/index.ts","../../src/hooks/useClickAway.tsx","../../src/utils/ClickAwayProvider/ClickAwayProvider.tsx","../../../lumx-core/src/js/utils/InfiniteScroll/setupInfiniteScrollObserver.ts","../../../lumx-core/src/js/utils/InfiniteScroll/index.tsx","../../src/utils/InfiniteScroll/InfiniteScroll.tsx","../../src/utils/Portal/PortalProvider.tsx","../../src/utils/Portal/Portal.tsx","../../src/hooks/useOverflowTooltipLabel.tsx"],"sourcesContent":["import { VISUALLY_HIDDEN } from '@lumx/core/js/constants';\n\n/**\n * Visually hidden class name.\n * Used to hide elements from view but keep them readable from screen readers\n */\nexport const visuallyHidden = () => VISUALLY_HIDDEN;\n","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","import React from 'react';\n\n/** Empty object */\ntype TooltipContextValue = NonNullable<unknown>;\n\nconst DEFAULT_VALUE = {};\n\n/**\n * Tooltip react context simply used as a marker to know when parent react node have a tooltip\n */\nconst TooltipContext = React.createContext<TooltipContextValue | undefined>(undefined);\n\nexport const TooltipContextProvider: React.FC<{ children?: React.ReactNode }> = ({ children }) => (\n <TooltipContext.Provider value={DEFAULT_VALUE}>{children}</TooltipContext.Provider>\n);\n\nexport const useTooltipContext = () => React.useContext(TooltipContext);\n","import { visuallyHidden } from '../classNames/visually-hidden';\n\n/**\n * Get the text of an element when it overflows, else `undefined`.\n */\nexport const getOverflowingText = (element?: HTMLElement | null): string | undefined => {\n // A visually hidden element measures 1px, so it would count as overflowing.\n if (!element || element.closest(`.${visuallyHidden()}`)) return undefined;\n // A hidden element measures 0, so it would count as overflowing.\n if (element.offsetWidth === 0 || element.offsetWidth >= element.scrollWidth) return undefined;\n return element.innerText;\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) => element instanceof Node && 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 * Note: when `getElements` returns an empty array, any click is considered a click away.\n * Callers should guard against calling `setupClickAway` when no refs are registered.\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].filter((t): t is HTMLElement => t instanceof Node);\n const elements = getElements();\n if (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 type { Falsy } from '@lumx/core/js/types';\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","type EventCallback = (evt?: Event) => void;\n\n/**\n * Sets up an IntersectionObserver on the given element.\n * Calls `callback` when at least one observed entry is intersecting.\n * Returns a cleanup function that unobserves the element.\n */\nexport function setupInfiniteScrollObserver(\n element: Element,\n callback: EventCallback,\n options?: IntersectionObserverInit,\n): () => void {\n const observer = new IntersectionObserver((entries = []) => {\n const hasIntersection = entries.some((entry) => entry.isIntersecting);\n\n if (!hasIntersection) {\n return;\n }\n\n callback();\n }, options);\n\n observer.observe(element);\n\n return () => {\n observer.unobserve(element);\n };\n}\n","import type { CommonRef } from '../../types';\n\nexport { setupInfiniteScrollObserver } from './setupInfiniteScrollObserver';\n\nexport const INFINITE_SCROLL_CLASSNAME = 'lumx-infinite-scroll-anchor';\n\nexport interface InfiniteScrollProps {\n /**\n * Callback when infinite scroll component is in view.\n * Omit (e.g. while loading) to temporarily disable without changing the callback's\n * identity when re-enabled — keeps the underlying observer stable.\n */\n // eslint-disable-next-line react/no-unused-prop-types\n callback?(evt?: Event): void;\n /** Customize intersection observer option */\n // eslint-disable-next-line react/no-unused-prop-types\n options?: IntersectionObserverInit;\n}\n\n/**\n * Framework-agnostic InfiniteScroll sentinel component.\n *\n * Renders a tiny invisible div that triggers a callback when it enters the viewport\n * (or intersects its root element) via IntersectionObserver.\n *\n * The div has a small height (4px) to avoid issues when a browser zoom is applied,\n * where a zero-height element might not trigger IntersectionObserver reliably.\n */\nexport const InfiniteScroll = ({ ref }: { ref?: CommonRef }) => (\n // In order to avoid issues when a zoom is added to the browser, we add a small height to the div so that\n // the intersection has a higher chance of working correctly.\n <div ref={ref} aria-hidden=\"true\" className={INFINITE_SCROLL_CLASSNAME} style={{ height: '4px' }} />\n);\n","import React, { useEffect } from 'react';\nimport {\n InfiniteScroll as UI,\n type InfiniteScrollProps,\n setupInfiniteScrollObserver,\n} from '@lumx/core/js/utils/InfiniteScroll';\n\nexport type { InfiniteScrollProps };\n\n/**\n * Handles basic callback pattern by using intersection observers.\n */\nexport const InfiniteScroll: React.FC<InfiniteScrollProps> = ({ callback, options }) => {\n const elementRef = React.useRef<HTMLDivElement | null>(null);\n\n useEffect(() => {\n const { current: element } = elementRef;\n if (!element || !callback) {\n return undefined;\n }\n\n return setupInfiniteScrollObserver(element, callback, options);\n // `options?.root` starts as `null` (before the scrollable list's ref attaches) and is\n // then set to the real element — must be a dep, or the observer gets stuck watching\n // the wrong root (falling back to the viewport) for the component's whole lifetime.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [elementRef.current, callback, options?.root]);\n\n return UI({ ref: elementRef });\n};\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","import { useCallback, useRef } from 'react';\nimport { useTooltipContext } from '@lumx/react/components/tooltip/context';\nimport { getOverflowingText } from '@lumx/core/js/utils/browser/getOverflowingText';\n\n/**\n * Get a function tooltip label that gives the text of the label element only when it overflows.\n *\n * @example\n * const { labelRef, tooltipLabel } = useOverflowTooltipLabel();\n * <Tooltip label={tooltipLabel}><Text ref={labelRef} truncate>{text}</Text></Tooltip>\n */\nexport const useOverflowTooltipLabel = () => {\n const parentTooltip = useTooltipContext();\n const labelRef = useRef<HTMLElement | null>(null);\n\n const tooltipLabel = useCallback(\n () => (parentTooltip ? undefined : getOverflowingText(labelRef.current)),\n [parentTooltip],\n );\n\n return { labelRef, tooltipLabel };\n};\n"],"names":["visuallyHidden","VISUALLY_HIDDEN","DisabledStateContext","React","createContext","state","DisabledStateProvider","children","value","_jsx","Provider","useDisabledStateContext","useContext","DEFAULT_VALUE","TooltipContext","undefined","TooltipContextProvider","useTooltipContext","getOverflowingText","element","closest","offsetWidth","scrollWidth","innerText","CLICK_AWAY_EVENT_TYPES","isClickAway","targets","elements","some","Node","target","contains","setupClickAway","getElements","callback","listener","evt","composedPath","filter","t","forEach","evtType","document","addEventListener","removeEventListener","useClickAway","childrenRefs","useEffect","refs","current","map","ref","Boolean","ClickAwayAncestorContext","ClickAwayProvider","parentRef","parentContext","currentContext","useMemo","context","addRefs","newChildrenRefs","push","currentRefs","useRef","displayName","setupInfiniteScrollObserver","options","observer","IntersectionObserver","entries","hasIntersection","entry","isIntersecting","observe","unobserve","INFINITE_SCROLL_CLASSNAME","InfiniteScroll","className","style","height","elementRef","root","UI","PortalContext","container","body","PortalProvider","Portal","enabled","init","useLayoutEffect","teardown","_Fragment","createPortal","useOverflowTooltipLabel","parentTooltip","labelRef","tooltipLabel","useCallback"],"mappings":";;;;;AAEA;AACA;AACA;AACA;AACO,MAAMA,cAAc,GAAGA,MAAMC;;ACF7B,MAAMC,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,KAAM;AAAAD,IAAAA,QAAA,EAAEA;AAAQ,GAAgC,CAAC;AAClG;;AAEA;AACA;AACA;AACO,SAASI,uBAAuBA,GAA8B;EACjE,OAAOC,UAAU,CAACV,oBAAoB,CAAC;AAC3C;;AClBA,MAAMW,aAAa,GAAG,EAAE;;AAExB;AACA;AACA;AACA,MAAMC,cAAc,gBAAGX,cAAK,CAACC,aAAa,CAAkCW,SAAS,CAAC;AAE/E,MAAMC,sBAAgE,GAAGA,CAAC;AAAET,EAAAA;AAAS,CAAC,kBACzFE,GAAA,CAACK,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ACA,EAAA,oBAAOuF,YAAY,CAACvF,QAAQ,EAAE8E,SAAS,CAAC;AAC5C;;AC/BA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMU,uBAAuB,GAAGA,MAAM;AACzC,EAAA,MAAMC,aAAa,GAAG/E,iBAAiB,EAAE;AACzC,EAAA,MAAMgF,QAAQ,GAAGjC,MAAM,CAAqB,IAAI,CAAC;AAEjD,EAAA,MAAMkC,YAAY,GAAGC,WAAW,CAC5B,MAAOH,aAAa,GAAGjF,SAAS,GAAGG,kBAAkB,CAAC+E,QAAQ,CAAChD,OAAO,CAAE,EACxE,CAAC+C,aAAa,CAClB,CAAC;EAED,OAAO;IAAEC,QAAQ;AAAEC,IAAAA;GAAc;AACrC;;;;"}
|
package/index.d.ts
CHANGED
|
@@ -1830,6 +1830,11 @@ interface TextFieldProps$1 extends HasClassName, HasTheme, HasAriaDisabled, HasD
|
|
|
1830
1830
|
hasError?: boolean;
|
|
1831
1831
|
/** Additional element to put at the end of the text field. */
|
|
1832
1832
|
afterElement?: JSXElement;
|
|
1833
|
+
/**
|
|
1834
|
+
* Element to display at the start of the field, after the icon.
|
|
1835
|
+
* Mark it as decorative (`aria-hidden`) when the input text gives the same information.
|
|
1836
|
+
*/
|
|
1837
|
+
beforeElement?: JSXElement;
|
|
1833
1838
|
/** Helper text. */
|
|
1834
1839
|
helper?: string | JSXElement;
|
|
1835
1840
|
/** Icon (SVG path). */
|
|
@@ -2168,8 +2173,11 @@ interface TooltipProps$1 extends HasCloseMode {
|
|
|
2168
2173
|
delay?: number;
|
|
2169
2174
|
/** Whether the tooltip is displayed even without the mouse hovering the anchor. */
|
|
2170
2175
|
forceOpen?: boolean;
|
|
2171
|
-
/**
|
|
2172
|
-
|
|
2176
|
+
/**
|
|
2177
|
+
* Label text, or a cheap function that returns it, called on open and on each render while open.
|
|
2178
|
+
* A function label needs `closeMode="unmount"`. See `useOverflowTooltipLabel`.
|
|
2179
|
+
*/
|
|
2180
|
+
label?: string | null | false | (() => string | null | false | undefined);
|
|
2173
2181
|
/** Placement of the tooltip relative to the anchor. */
|
|
2174
2182
|
placement?: TooltipPlacement;
|
|
2175
2183
|
/** Choose how the tooltip text should link to the anchor */
|
|
@@ -4615,12 +4623,16 @@ interface BaseSelectTextFieldWrapperProps<O> extends Pick<BaseSelectProps<O>, 'o
|
|
|
4615
4623
|
filter: 'auto' | 'manual' | 'off';
|
|
4616
4624
|
/**
|
|
4617
4625
|
* Controlled search input value.
|
|
4618
|
-
* When provided, this value seeds
|
|
4619
|
-
*
|
|
4626
|
+
* When provided, this value seeds the visible search text in the input. In multiple selection,
|
|
4627
|
+
* `''` resets it.
|
|
4628
|
+
* In single selection, `''` (empty string) keeps the input empty while the option stays selected:
|
|
4629
|
+
* the input shows only the text the user types. When you copy `onSearch` into this prop, pass
|
|
4630
|
+
* `search || undefined` so that the input shows the name of the selected option when idle.
|
|
4620
4631
|
*/
|
|
4621
4632
|
searchInputValue?: string;
|
|
4622
4633
|
/**
|
|
4623
|
-
* Whether
|
|
4634
|
+
* Whether the selection can be cleared (single selection): with a clear button, when the user
|
|
4635
|
+
* erases the input text, and with Escape. When `false`, the selection stays.
|
|
4624
4636
|
* @default true
|
|
4625
4637
|
*/
|
|
4626
4638
|
hasClearButton?: boolean;
|
|
@@ -4861,6 +4873,11 @@ interface BaseSelectTextFieldProps<O = any> extends BaseSelectTextFieldWrapperPr
|
|
|
4861
4873
|
onLoadMore?: () => void;
|
|
4862
4874
|
/** Content to render before the options list. */
|
|
4863
4875
|
beforeOptions?: React__default.ReactNode;
|
|
4876
|
+
/**
|
|
4877
|
+
* Element to display at the start of the field, after the icon.
|
|
4878
|
+
* Mark it as decorative (`aria-hidden`) when the input text gives the same information.
|
|
4879
|
+
*/
|
|
4880
|
+
beforeElement?: React__default.ReactNode;
|
|
4864
4881
|
/**
|
|
4865
4882
|
* Props forwarded to the Combobox.Popover.
|
|
4866
4883
|
* Set to `false` to render the list inline below the text field, with no popover (the list is always visible).
|
|
@@ -6073,6 +6090,12 @@ interface TreeListItemProps extends GenericProps$1, ReactToJSX<TreeListItemProps
|
|
|
6073
6090
|
* In a combobox, the open state resets on each popup open: cache the loaded sub-items.
|
|
6074
6091
|
*/
|
|
6075
6092
|
hasSubItems?: boolean;
|
|
6093
|
+
/**
|
|
6094
|
+
* Open the item at mount. Uncontrolled: it applies at each mount (in a combobox, at each popup
|
|
6095
|
+
* open), it does not call `onOpenChange`, and a change after mount does nothing.
|
|
6096
|
+
* With `hasSubItems`, `onOpenChange` does not fire at mount: load the sub-items yourself.
|
|
6097
|
+
*/
|
|
6098
|
+
defaultOpen?: boolean;
|
|
6076
6099
|
/**
|
|
6077
6100
|
* Called on every open and close by the user (expand toggle, Right, Left, Enter or a click on a
|
|
6078
6101
|
* non-selectable parent item). Not called for the initial state or for the filter.
|
|
@@ -6096,8 +6119,8 @@ interface TreeListItemProps extends GenericProps$1, ReactToJSX<TreeListItemProps
|
|
|
6096
6119
|
* tree `value` holds it. Without, it is not selectable: Enter or a click on a non-selectable parent item
|
|
6097
6120
|
* opens or closes it, and on a non-selectable leaf item only calls `onClick` (e.g. an action such as
|
|
6098
6121
|
* "Create a new list…").
|
|
6099
|
-
* - The open state is internal: a parent item starts open when a sub-item at
|
|
6100
|
-
* In a combobox, it resets on each popup open.
|
|
6122
|
+
* - The open state is internal: a parent item starts open with `defaultOpen`, or when a sub-item at
|
|
6123
|
+
* any depth is selected. In a combobox, it resets on each popup open.
|
|
6101
6124
|
* - Touch screen readers: TalkBack (Chrome) can open and close the parent items. On iOS, a user can
|
|
6102
6125
|
* only reach the sub-items of a selectable parent item through the filter. To support it, use a
|
|
6103
6126
|
* non-selectable parent item with an "All <name>" leaf item that carries the parent value.
|