@lumx/react 4.20.0-next.0 → 4.20.0-next.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.
@@ -210,12 +210,15 @@ const InfiniteScroll = ({
210
210
  const {
211
211
  current: element
212
212
  } = elementRef;
213
- if (!element) {
213
+ if (!element || !callback) {
214
214
  return undefined;
215
215
  }
216
216
  return setupInfiniteScrollObserver(element, callback, options);
217
+ // `options?.root` starts as `null` (before the scrollable list's ref attaches) and is
218
+ // then set to the real element — must be a dep, or the observer gets stuck watching
219
+ // the wrong root (falling back to the viewport) for the component's whole lifetime.
217
220
  // eslint-disable-next-line react-hooks/exhaustive-deps
218
- }, [elementRef.current, callback]);
221
+ }, [elementRef.current, callback, options?.root]);
219
222
  return InfiniteScroll$1({
220
223
  ref: elementRef
221
224
  });
@@ -259,4 +262,4 @@ const Portal = ({
259
262
  };
260
263
 
261
264
  export { ClickAwayProvider as C, DisabledStateProvider as D, InfiniteScroll as I, Portal as P, PortalProvider as a, useDisabledStateContext as u };
262
- //# sourceMappingURL=BvaFEHZn.js.map
265
+ //# sourceMappingURL=CcLi-Wuu.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CcLi-Wuu.js","sources":["../../src/utils/disabled/DisabledStateContext.tsx","../../../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"],"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) => 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 { 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","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"],"names":["DisabledStateContext","React","createContext","state","DisabledStateProvider","children","value","_jsx","Provider","useDisabledStateContext","useContext","CLICK_AWAY_EVENT_TYPES","isClickAway","targets","elements","some","element","Node","target","contains","setupClickAway","getElements","callback","undefined","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"],"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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MG,aAAa,gBAAGxE,cAAK,CAACC,aAAa,CAAa,OAAO;EAAEwE,SAAS,EAAE3C,QAAQ,CAAC4C;AAAK,CAAC,CAAC,CAAC;AAOlG;AACA;AACA;AACO,MAAMC,cAAkD,GAAGH,aAAa,CAACjE;;ACJhF;AACA;AACA;AACA;AACO,MAAMqE,MAAkC,GAAGA,CAAC;EAAExE,QAAQ;AAAEyE,EAAAA,OAAO,GAAG;AAAK,CAAC,KAAK;AAChF,EAAA,MAAMC,IAAI,GAAG9E,cAAK,CAACS,UAAU,CAAC+D,aAAa,CAAC;AAC5C,EAAA,MAAMzB,OAAO,GAAG/C,cAAK,CAAC8C,OAAO,CACzB,MAAM;AACF,IAAA,OAAO+B,OAAO,GAAGC,IAAI,EAAE,GAAG,IAAI;EAClC,CAAC;AACD;AACA;EACA,CAACD,OAAO,CACZ,CAAC;EAED7E,cAAK,CAAC+E,eAAe,CAAC,MAAM;IACxB,OAAOhC,OAAO,EAAEiC,QAAQ;EAC5B,CAAC,EAAE,CAACjC,OAAO,EAAEiC,QAAQ,EAAEH,OAAO,CAAC,CAAC;EAEhC,MAAM;AAAEJ,IAAAA;AAAU,GAAC,GAAG1B,OAAO,IAAI,EAAE;AACnC,EAAA,IAAI,CAAC0B,SAAS,IAAI,OAAOA,SAAS,KAAK,QAAQ,EAAE;IAC7C,oBAAOnE,GAAA,CAAA2E,QAAA,EAAA;AAAA7E,MAAAA,QAAA,EAAGA;AAAQ,KAAG,CAAC;AAC1B,EAAA;AACA,EAAA,oBAAO8E,YAAY,CAAC9E,QAAQ,EAAEqE,SAAS,CAAC;AAC5C;;;;"}
package/index.js CHANGED
@@ -9,7 +9,7 @@ import ReactDOM__default from 'react-dom';
9
9
  import { classNames, onEscapePressed, onEnterPressed as onEnterPressed$1, detectHorizontalSwipe } from '@lumx/core/js/utils';
10
10
  import last from 'lodash/last.js';
11
11
  import pull from 'lodash/pull.js';
12
- import { u as useDisabledStateContext, P as Portal, C as ClickAwayProvider, I as InfiniteScroll } from './_internal/BvaFEHZn.js';
12
+ import { u as useDisabledStateContext, P as Portal, C as ClickAwayProvider, I as InfiniteScroll } from './_internal/CcLi-Wuu.js';
13
13
  import isEmpty from 'lodash/isEmpty.js';
14
14
  import get from 'lodash/get.js';
15
15
  import { getDisabledState as getDisabledState$1 } from '@lumx/core/js/utils/disabledState';
@@ -17991,6 +17991,8 @@ const SelectButton$2 = (props, {
17991
17991
  const isLoadingMore = listStatus === 'loadingMore';
17992
17992
  const isError = listStatus === 'error';
17993
17993
  const isMultiselectable = selectionType === 'multiple';
17994
+ // Prevent firing during loading or error states to avoid duplicate fetches.
17995
+ const isInfiniteScrollEnabled = !listStatus || listStatus === 'idle';
17994
17996
 
17995
17997
  /*
17996
17998
  * Display value: castArray normalizes single/multi value to an array, then resolve
@@ -18029,11 +18031,7 @@ const SelectButton$2 = (props, {
18029
18031
  }, {
18030
18032
  Combobox
18031
18033
  }), onLoadMore && InfiniteScroll && /*#__PURE__*/jsx(InfiniteScroll, {
18032
- callback: () => {
18033
- // Guard: prevent firing during loading or error states to avoid duplicate fetches.
18034
- if (listStatus && listStatus !== 'idle') return;
18035
- onLoadMore();
18036
- },
18034
+ callback: isInfiniteScrollEnabled ? onLoadMore : undefined,
18037
18035
  options: infiniteScrollOptions
18038
18036
  }), isLoadingMore && /*#__PURE__*/jsx(Combobox.OptionSkeleton, {
18039
18037
  count: 1
@@ -18177,7 +18175,13 @@ const SelectButton$1 = React__default.forwardRef((props, ref) => {
18177
18175
  as,
18178
18176
  ...buttonProps
18179
18177
  } = props;
18180
- const [listElement, setListElement] = useState(null);
18178
+ // The list itself doesn't scroll — its ancestor `__scroll` wrapper does. The
18179
+ // IntersectionObserver root must be the actual scrolling/clipping element, or the
18180
+ // sentinel is trivially always "intersecting" its non-clipping `<ul>` parent.
18181
+ const [scrollContainer, setScrollContainer] = useState(null);
18182
+ const setListElement = useCallback(listElement => {
18183
+ setScrollContainer(listElement?.closest(`.${CLASSNAME$17}__scroll`) ?? null);
18184
+ }, []);
18181
18185
  const isMultiple = selectionType === 'multiple';
18182
18186
 
18183
18187
  // Inject core-computed props into the consumer's renderOption result.
@@ -18218,7 +18222,7 @@ const SelectButton$1 = React__default.forwardRef((props, ref) => {
18218
18222
  translations,
18219
18223
  onLoadMore,
18220
18224
  infiniteScrollOptions: {
18221
- root: listElement,
18225
+ root: scrollContainer,
18222
18226
  rootMargin: '100px'
18223
18227
  }
18224
18228
  }, {
@@ -18291,6 +18295,8 @@ const SelectTextField$2 = (props, {
18291
18295
  const isFullLoading = listStatus === 'loading';
18292
18296
  const isLoadingMore = listStatus === 'loadingMore';
18293
18297
  const isError = listStatus === 'error';
18298
+ // Prevent firing during loading or error states to avoid duplicate fetches.
18299
+ const isInfiniteScrollEnabled = !listStatus || listStatus === 'idle';
18294
18300
  return /*#__PURE__*/jsxs(Combobox.Provider, {
18295
18301
  onOpen: onOpen,
18296
18302
  children: [/*#__PURE__*/jsx(Combobox.Input, {
@@ -18321,11 +18327,7 @@ const SelectTextField$2 = (props, {
18321
18327
  }, {
18322
18328
  Combobox
18323
18329
  }), afterOptions, onLoadMore && InfiniteScroll && /*#__PURE__*/jsx(InfiniteScroll, {
18324
- callback: () => {
18325
- // Guard: prevent firing during loading or error states to avoid duplicate fetches.
18326
- if (listStatus && listStatus !== 'idle') return;
18327
- onLoadMore();
18328
- },
18330
+ callback: isInfiniteScrollEnabled ? onLoadMore : undefined,
18329
18331
  options: infiniteScrollOptions
18330
18332
  }), isLoadingMore && /*#__PURE__*/jsx(Combobox.OptionSkeleton, {
18331
18333
  count: 1
@@ -18413,7 +18415,14 @@ const SelectTextField$1 = props => {
18413
18415
  // Wrap the consumer's renderOption to inject core-computed props
18414
18416
  // (`value`, `isSelected`, `description`, `key`) into the returned <Combobox.Option>.
18415
18417
  const wrappedRenderOption = wrapRenderOption(renderOption);
18416
- const [listElement, setListElement] = useState(null);
18418
+
18419
+ // The list itself doesn't scroll — its ancestor `__scroll` wrapper does. The
18420
+ // IntersectionObserver root must be the actual scrolling/clipping element, or the
18421
+ // sentinel is trivially always "intersecting" its non-clipping `<ul>` parent.
18422
+ const [scrollContainer, setScrollContainer] = useState(null);
18423
+ const setListElement = useCallback(listElement => {
18424
+ setScrollContainer(listElement?.closest(`.${CLASSNAME$17}__scroll`) ?? null);
18425
+ }, []);
18417
18426
  const localInputRef = useRef(null);
18418
18427
  const mergedInputRef = useMergeRefs(localInputRef, externalInputRef);
18419
18428
 
@@ -18563,7 +18572,7 @@ const SelectTextField$1 = props => {
18563
18572
  beforeOptions,
18564
18573
  onLoadMore,
18565
18574
  infiniteScrollOptions: {
18566
- root: listElement,
18575
+ root: scrollContainer,
18567
18576
  rootMargin: '100px'
18568
18577
  }
18569
18578
  }, {