bits-ui 1.5.0 → 1.5.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.
@@ -173,8 +173,7 @@ class NavigationMenuListState {
173
173
  });
174
174
  this.rovingFocusGroup = useRovingFocus({
175
175
  rootNodeId: opts.id,
176
- candidateAttr: NAVIGATION_MENU_ITEM_ATTR,
177
- candidateSelector: `:is([${NAVIGATION_MENU_TRIGGER_ATTR}], [data-list-link]):not([data-disabled])`,
176
+ candidateSelector: `:is([${NAVIGATION_MENU_TRIGGER_ATTR}], [${NAVIGATION_MENU_LINK_ATTR}]):not([data-disabled])`,
178
177
  loop: box.with(() => false),
179
178
  orientation: this.context.opts.orientation,
180
179
  });
@@ -1,14 +1,18 @@
1
1
  import { type ReadableBox } from "svelte-toolbelt";
2
2
  import type { Orientation } from "../shared/index.js";
3
- type UseRovingFocusProps = {
3
+ type UseRovingFocusProps = ({
4
4
  /**
5
5
  * The selector used to find the focusable candidates.
6
6
  */
7
7
  candidateAttr: string;
8
+ candidateSelector?: undefined;
9
+ } | {
8
10
  /**
9
11
  * Custom candidate selector
10
12
  */
11
- candidateSelector?: string;
13
+ candidateSelector: string;
14
+ candidateAttr?: undefined;
15
+ }) & {
12
16
  /**
13
17
  * The id of the root node
14
18
  */
@@ -15,10 +15,11 @@ export function useRovingFocus(props) {
15
15
  const candidates = Array.from(node.querySelectorAll(props.candidateSelector));
16
16
  return candidates;
17
17
  }
18
- else {
18
+ else if (props.candidateAttr) {
19
19
  const candidates = Array.from(node.querySelectorAll(`[${props.candidateAttr}]:not([data-disabled])`));
20
20
  return candidates;
21
21
  }
22
+ return [];
22
23
  }
23
24
  function focusFirstCandidate() {
24
25
  const items = getCandidateNodes();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bits-ui",
3
- "version": "1.5.0",
3
+ "version": "1.5.1",
4
4
  "license": "MIT",
5
5
  "repository": "github:huntabyte/bits-ui",
6
6
  "funding": "https://github.com/sponsors/huntabyte",