bits-ui 1.0.0-next.22 → 1.0.0-next.24

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,7 +1,7 @@
1
1
  <script lang="ts">
2
2
  import type { ButtonRootProps } from "../types.js";
3
3
 
4
- let { href, type, children, ref, ...restProps }: ButtonRootProps = $props();
4
+ let { href, type, children, ref = $bindable(), ...restProps }: ButtonRootProps = $props();
5
5
  </script>
6
6
 
7
7
  <svelte:element
@@ -14,6 +14,6 @@ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> =
14
14
  }
15
15
  declare const Button: $$__sveltets_2_IsomorphicComponent<ButtonRootProps, {
16
16
  [evt: string]: CustomEvent<any>;
17
- }, {}, {}, "">;
17
+ }, {}, {}, "ref">;
18
18
  type Button = InstanceType<typeof Button>;
19
19
  export default Button;
@@ -9,6 +9,7 @@
9
9
  ref = $bindable(null),
10
10
  child,
11
11
  children,
12
+ type = "button",
12
13
  ...restProps
13
14
  }: ComboboxTriggerProps = $props();
14
15
 
@@ -20,7 +21,7 @@
20
21
  ),
21
22
  });
22
23
 
23
- const mergedProps = $derived(mergeProps(restProps, triggerState.props));
24
+ const mergedProps = $derived(mergeProps(restProps, triggerState.props, { type }));
24
25
  </script>
25
26
 
26
27
  {#if child}
@@ -68,6 +68,9 @@ class RadioGroupItemState {
68
68
  id: this.#id,
69
69
  ref: this.#ref,
70
70
  });
71
+ $effect(() => {
72
+ this.#tabIndex = this.#root.rovingFocusGroup.getTabIndex(this.#ref.current);
73
+ });
71
74
  }
72
75
  #onpointerdown = (e) => {
73
76
  if (this.#disabled.current)
@@ -90,7 +93,7 @@ class RadioGroupItemState {
90
93
  #onkeydown = (e) => {
91
94
  this.#root.rovingFocusGroup.handleKeydown(this.#ref.current, e, true);
92
95
  };
93
- #tabIndex = $derived.by(() => this.#root.rovingFocusGroup.getTabIndex(this.#ref.current));
96
+ #tabIndex = $state(0);
94
97
  snippetProps = $derived.by(() => ({ checked: this.#isChecked }));
95
98
  props = $derived.by(() => ({
96
99
  id: this.#id.current,
@@ -10,6 +10,7 @@
10
10
  ref = $bindable(null),
11
11
  child,
12
12
  children,
13
+ type = "button",
13
14
  ...restProps
14
15
  }: SelectTriggerProps = $props();
15
16
 
@@ -21,7 +22,7 @@
21
22
  ),
22
23
  });
23
24
 
24
- const mergedProps = $derived(mergeProps(restProps, triggerState.props));
25
+ const mergedProps = $derived(mergeProps(restProps, triggerState.props, { type }));
25
26
  </script>
26
27
 
27
28
  <FloatingLayer.Anchor {id}>
@@ -98,6 +98,14 @@ class ToggleGroupItemState {
98
98
  id: this.#id,
99
99
  ref: this.#ref,
100
100
  });
101
+ $effect(() => {
102
+ if (!this.#root.rovingFocus.current) {
103
+ this.#tabIndex = 0;
104
+ }
105
+ else {
106
+ this.#tabIndex = this.#root.rovingFocusGroup.getTabIndex(this.#ref.current);
107
+ }
108
+ });
101
109
  }
102
110
  toggleItem = () => {
103
111
  if (this.#isDisabled)
@@ -128,9 +136,7 @@ class ToggleGroupItemState {
128
136
  #ariaPressed = $derived.by(() => {
129
137
  return this.#root.isMulti ? getAriaPressed(this.isPressed) : undefined;
130
138
  });
131
- #tabIndex = $derived.by(() => !this.#root.rovingFocus.current
132
- ? 0
133
- : this.#root.rovingFocusGroup.getTabIndex(this.#ref.current));
139
+ #tabIndex = $state(0);
134
140
  props = $derived.by(() => ({
135
141
  id: this.#id.current,
136
142
  role: this.#root.isMulti ? undefined : "radio",
@@ -124,6 +124,9 @@ class ToolbarGroupItemState {
124
124
  id: this.#id,
125
125
  ref: this.#ref,
126
126
  });
127
+ $effect(() => {
128
+ this.#tabIndex = this.#root.rovingFocusGroup.getTabIndex(this.#ref.current);
129
+ });
127
130
  }
128
131
  toggleItem = () => {
129
132
  if (this.#isDisabled)
@@ -162,7 +165,7 @@ class ToolbarGroupItemState {
162
165
  #ariaPressed = $derived.by(() => {
163
166
  return this.#group.isMulti ? getAriaPressed(this.isPressed) : undefined;
164
167
  });
165
- #tabIndex = $derived.by(() => this.#root.rovingFocusGroup.getTabIndex(this.#ref.current));
168
+ #tabIndex = $state(0);
166
169
  props = $derived.by(() => ({
167
170
  id: this.#id.current,
168
171
  role: this.#group.isMulti ? undefined : "radio",
@@ -194,6 +197,9 @@ class ToolbarLinkState {
194
197
  id: this.#id,
195
198
  ref: this.#ref,
196
199
  });
200
+ $effect(() => {
201
+ this.#tabIndex = this.#root.rovingFocusGroup.getTabIndex(this.#ref.current);
202
+ });
197
203
  }
198
204
  #onkeydown = (e) => {
199
205
  this.#root.rovingFocusGroup.handleKeydown(this.#ref.current, e);
@@ -206,7 +212,7 @@ class ToolbarLinkState {
206
212
  return "link";
207
213
  return undefined;
208
214
  });
209
- #tabIndex = $derived.by(() => this.#root.rovingFocusGroup.getTabIndex(this.#ref.current));
215
+ #tabIndex = $state(0);
210
216
  props = $derived.by(() => ({
211
217
  id: this.#id.current,
212
218
  [LINK_ATTR]: "",
@@ -232,11 +238,14 @@ class ToolbarButtonState {
232
238
  id: this.#id,
233
239
  ref: this.#ref,
234
240
  });
241
+ $effect(() => {
242
+ this.#tabIndex = this.#root.rovingFocusGroup.getTabIndex(this.#ref.current);
243
+ });
235
244
  }
236
245
  #onkeydown = (e) => {
237
246
  this.#root.rovingFocusGroup.handleKeydown(this.#ref.current, e);
238
247
  };
239
- #tabIndex = $derived.by(() => this.#root.rovingFocusGroup.getTabIndex(this.#ref.current));
248
+ #tabIndex = $state(0);
240
249
  #role = $derived.by(() => {
241
250
  if (!this.#ref.current)
242
251
  return undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bits-ui",
3
- "version": "1.0.0-next.22",
3
+ "version": "1.0.0-next.24",
4
4
  "license": "MIT",
5
5
  "repository": "github:huntabyte/bits-ui",
6
6
  "funding": "https://github.com/sponsors/huntabyte",
@@ -27,7 +27,7 @@
27
27
  "jest-axe": "^9.0.0",
28
28
  "jsdom": "^24.1.0",
29
29
  "publint": "^0.2.11",
30
- "svelte": "^5.0.0",
30
+ "svelte": "^5.1.0",
31
31
  "svelte-check": "4.0.3",
32
32
  "tslib": "^2.7.0",
33
33
  "typescript": "^5.6.2",