@lumx/react 4.27.0 → 4.27.1-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/index.js +34 -3
  2. package/index.js.map +1 -1
  3. package/package.json +9 -8
package/index.js CHANGED
@@ -6425,13 +6425,14 @@ const DEFAULT_PROPS$13 = {};
6425
6425
  */
6426
6426
  const List$1 = props => {
6427
6427
  const {
6428
+ as: Element = 'ul',
6428
6429
  children,
6429
6430
  className,
6430
6431
  itemPadding,
6431
6432
  ref,
6432
6433
  ...forwardedProps
6433
6434
  } = props;
6434
- return /*#__PURE__*/jsx("ul", {
6435
+ return /*#__PURE__*/jsx(Element, {
6435
6436
  ...forwardedProps,
6436
6437
  className: classnames(className, block$11({
6437
6438
  [`item-padding-${itemPadding}`]: Boolean(itemPadding)
@@ -6848,6 +6849,7 @@ const DEFAULT_PROPS$12 = {
6848
6849
  */
6849
6850
  const ListItem$1 = props => {
6850
6851
  const {
6852
+ as: Element = 'li',
6851
6853
  after,
6852
6854
  before,
6853
6855
  children,
@@ -6865,7 +6867,7 @@ const ListItem$1 = props => {
6865
6867
  ...forwardedProps
6866
6868
  } = props;
6867
6869
  const clickable = !!linkAs || linkProps?.href || handleClick;
6868
- return /*#__PURE__*/jsx("li", {
6870
+ return /*#__PURE__*/jsx(Element, {
6869
6871
  ref: ref,
6870
6872
  ...forwardedProps,
6871
6873
  className: classnames(className, block$10({
@@ -9421,6 +9423,28 @@ function setupListbox(options = {}) {
9421
9423
  return filterLower.length > 0 && !getOptionValue(option).toLowerCase().includes(filterLower);
9422
9424
  }
9423
9425
 
9426
+ /** Whether the listbox has visible options or skeletons (something to show). */
9427
+ const hasVisibleContent = () => getVisibleOptionCount() > 0 || skeletonCount > 0;
9428
+
9429
+ /**
9430
+ * Whether the mounted element holds a status (the live region, e.g. a `Combobox.State` inside the list),
9431
+ * outside of a hidden subtree. The status is always rendered (visually hidden when it shows no message), so
9432
+ * that the live region stays in the accessibility tree: the element must not hide it. (Read when the options
9433
+ * or the skeletons change: a status is rendered with the list, not later.)
9434
+ */
9435
+ function hasStatus(container) {
9436
+ return Array.from(container.querySelectorAll(`.${CLASSNAME$19}`)).some(status => {
9437
+ const hiddenAncestor = status.parentElement?.closest('[hidden]');
9438
+ return !hiddenAncestor || hiddenAncestor === container || !container.contains(hiddenAncestor);
9439
+ });
9440
+ }
9441
+
9442
+ /** Hide the mounted element (`hidden`) when it has no visible content and no status. */
9443
+ function syncHidden() {
9444
+ if (!element) return;
9445
+ element.toggleAttribute('hidden', !hasVisibleContent() && !hasStatus(element));
9446
+ }
9447
+
9424
9448
  /**
9425
9449
  * Notify sections, then fire `optionsChange` when the visible count changed (or when the input
9426
9450
  * value changed while empty).
@@ -9429,6 +9453,7 @@ function setupListbox(options = {}) {
9429
9453
  for (const [sectionElement] of sectionRegistrations) {
9430
9454
  notifySection(sectionElement, sectionRegistrations, optionRegistrations);
9431
9455
  }
9456
+ syncHidden();
9432
9457
  const visibleCount = getVisibleOptionCount();
9433
9458
  const inputValue = link?.getInputValue?.() ?? '';
9434
9459
  const isEmpty = visibleCount === 0;
@@ -9468,6 +9493,7 @@ function setupListbox(options = {}) {
9468
9493
 
9469
9494
  /** Called when the skeleton count transitions between 0 and >0 (or vice versa). */
9470
9495
  function onSkeletonCountChange() {
9496
+ syncHidden();
9471
9497
  const isLoading = skeletonCount > 0;
9472
9498
  lastLoadingState = isLoading;
9473
9499
  notify('loadingChange', isLoading);
@@ -9531,6 +9557,7 @@ function setupListbox(options = {}) {
9531
9557
  focusNav,
9532
9558
  cellSelector
9533
9559
  } = nav;
9560
+ syncHidden();
9534
9561
  link?.onMount?.(listbox);
9535
9562
  typeaheadController = createTypeahead(() => createSelectorTreeWalker(listbox, cellSelector), getOptionLabel, signal);
9536
9563
 
@@ -9621,7 +9648,7 @@ function setupListbox(options = {}) {
9621
9648
  return skeletonCount > 0;
9622
9649
  },
9623
9650
  get hasVisibleContent() {
9624
- return getVisibleOptionCount() > 0 || skeletonCount > 0;
9651
+ return hasVisibleContent();
9625
9652
  },
9626
9653
  mount,
9627
9654
  setOpen(open) {
@@ -13556,7 +13583,9 @@ const useKeyboardListNavigation = (items, ref, onListItemSelected, onListItemNav
13556
13583
  * @return React element.
13557
13584
  */
13558
13585
  const InternalList = forwardRef((props, ref) => {
13586
+ // `as` is a core-only prop (not exposed by the React component).
13559
13587
  const {
13588
+ as: _as,
13560
13589
  children,
13561
13590
  isClickable,
13562
13591
  onListItemSelected,
@@ -15851,7 +15880,9 @@ const _ListItem = forwardRef((props, ref) => {
15851
15880
  disabledStateProps,
15852
15881
  otherProps
15853
15882
  } = useDisableStateProps(props);
15883
+ // `as` is a core-only prop (not exposed by the React component).
15854
15884
  const {
15885
+ as: _as,
15855
15886
  onItemSelected,
15856
15887
  onClick,
15857
15888
  linkRef,