bits-ui 1.0.0-next.55 → 1.0.0-next.56

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.
@@ -20,6 +20,7 @@ declare class RadioGroupRootState {
20
20
  name: RadioGroupRootStateProps["name"];
21
21
  value: RadioGroupRootStateProps["value"];
22
22
  rovingFocusGroup: UseRovingFocusReturn;
23
+ hasValue: boolean;
23
24
  constructor(props: RadioGroupRootStateProps);
24
25
  isChecked: (value: string) => boolean;
25
26
  setValue: (value: string) => void;
@@ -2,6 +2,7 @@ import { srOnlyStyles, styleToString, useRefById } from "svelte-toolbelt";
2
2
  import { getAriaChecked, getAriaRequired, getDataDisabled } from "../../internal/attrs.js";
3
3
  import { useRovingFocus, } from "../../internal/use-roving-focus.svelte.js";
4
4
  import { createContext } from "../../internal/create-context.js";
5
+ import { kbd } from "../../internal/kbd.js";
5
6
  const RADIO_GROUP_ROOT_ATTR = "data-radio-group-root";
6
7
  const RADIO_GROUP_ITEM_ATTR = "data-radio-group-item";
7
8
  class RadioGroupRootState {
@@ -14,6 +15,7 @@ class RadioGroupRootState {
14
15
  name;
15
16
  value;
16
17
  rovingFocusGroup;
18
+ hasValue = $derived.by(() => this.value.current !== "");
17
19
  constructor(props) {
18
20
  this.#id = props.id;
19
21
  this.disabled = props.disabled;
@@ -88,9 +90,18 @@ class RadioGroupItemState {
88
90
  }
89
91
  };
90
92
  #onfocus = () => {
93
+ if (!this.#root.hasValue)
94
+ return;
91
95
  this.#root.setValue(this.#value.current);
92
96
  };
93
97
  #onkeydown = (e) => {
98
+ if (this.#isDisabled)
99
+ return;
100
+ if (e.key === kbd.SPACE) {
101
+ e.preventDefault();
102
+ this.#root.setValue(this.#value.current);
103
+ return;
104
+ }
94
105
  this.#root.rovingFocusGroup.handleKeydown(this.#ref.current, e, true);
95
106
  };
96
107
  #tabIndex = $state(0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bits-ui",
3
- "version": "1.0.0-next.55",
3
+ "version": "1.0.0-next.56",
4
4
  "license": "MIT",
5
5
  "repository": "github:huntabyte/bits-ui",
6
6
  "funding": "https://github.com/sponsors/huntabyte",