bits-ui 1.3.3 → 1.3.4

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.
@@ -84,8 +84,6 @@ declare class CheckboxInputState {
84
84
  readonly required: boolean;
85
85
  readonly name: string | undefined;
86
86
  readonly value: string | undefined;
87
- readonly "aria-hidden": "true";
88
- readonly style: string;
89
87
  };
90
88
  }
91
89
  export declare function useCheckboxGroup(props: CheckboxGroupStateProps): CheckboxGroupState;
@@ -1,4 +1,4 @@
1
- import { srOnlyStyles, styleToString, useRefById } from "svelte-toolbelt";
1
+ import { useRefById } from "svelte-toolbelt";
2
2
  import { Context, watch } from "runed";
3
3
  import { getAriaChecked, getAriaRequired, getDataDisabled } from "../../internal/attrs.js";
4
4
  import { kbd } from "../../internal/kbd.js";
@@ -175,8 +175,6 @@ class CheckboxInputState {
175
175
  required: this.root.trueRequired,
176
176
  name: this.root.trueName,
177
177
  value: this.root.opts.value.current,
178
- "aria-hidden": "true",
179
- style: styleToString(srOnlyStyles),
180
178
  }));
181
179
  }
182
180
  function getCheckboxDataState(checked, indeterminate) {
@@ -1,12 +1,10 @@
1
1
  <script lang="ts">
2
2
  import { useCheckboxInput } from "../checkbox.svelte.js";
3
- import VisuallyHidden from "../../utilities/visually-hidden/visually-hidden.svelte";
3
+ import HiddenInput from "../../utilities/hidden-input.svelte";
4
4
 
5
5
  const inputState = useCheckboxInput();
6
6
  </script>
7
7
 
8
8
  {#if inputState.shouldRender}
9
- <VisuallyHidden aria-hidden="true">
10
- <input {...inputState.props} type="checkbox" style="display: none !important;" />
11
- </VisuallyHidden>
9
+ <HiddenInput {...inputState.props} />
12
10
  {/if}
@@ -1,14 +1,10 @@
1
1
  <script lang="ts">
2
2
  import { useDateFieldHiddenInput } from "../date-field.svelte.js";
3
- import VisuallyHidden from "../../utilities/visually-hidden/visually-hidden.svelte";
3
+ import HiddenInput from "../../utilities/hidden-input.svelte";
4
4
 
5
5
  const hiddenInputState = useDateFieldHiddenInput();
6
6
  </script>
7
7
 
8
8
  {#if hiddenInputState.shouldRender}
9
- <VisuallyHidden>
10
- {#snippet child({ props })}
11
- <input {...props} {...hiddenInputState.props} />
12
- {/snippet}
13
- </VisuallyHidden>
9
+ <HiddenInput {...hiddenInputState.props} />
14
10
  {/if}
@@ -169,7 +169,6 @@ declare class DateFieldHiddenInputState {
169
169
  name: string;
170
170
  value: string;
171
171
  required: boolean;
172
- "aria-hidden": "true" | undefined;
173
172
  };
174
173
  }
175
174
  type DateFieldLabelStateProps = WithRefProps;
@@ -545,7 +545,6 @@ class DateFieldHiddenInputState {
545
545
  name: this.root.name,
546
546
  value: this.isoValue,
547
547
  required: this.root.required.current,
548
- "aria-hidden": getAriaHidden(true),
549
548
  };
550
549
  });
551
550
  }
@@ -1,9 +1,10 @@
1
1
  <script lang="ts">
2
+ import HiddenInput from "../../utilities/hidden-input.svelte";
2
3
  import { useRadioGroupInput } from "../radio-group.svelte.js";
3
4
 
4
5
  const inputState = useRadioGroupInput();
5
6
  </script>
6
7
 
7
8
  {#if inputState.shouldRender}
8
- <input {...inputState.props} />
9
+ <HiddenInput {...inputState.props} />
9
10
  {/if}
@@ -68,10 +68,6 @@ declare class RadioGroupInputState {
68
68
  readonly value: string;
69
69
  readonly required: boolean;
70
70
  readonly disabled: boolean;
71
- readonly "aria-hidden": "true";
72
- readonly hidden: true;
73
- readonly style: string;
74
- readonly tabIndex: -1;
75
71
  };
76
72
  constructor(root: RadioGroupRootState);
77
73
  }
@@ -1,4 +1,4 @@
1
- import { srOnlyStyles, styleToString, useRefById } from "svelte-toolbelt";
1
+ import { useRefById } from "svelte-toolbelt";
2
2
  import { Context } from "runed";
3
3
  import { getAriaChecked, getAriaRequired, getDataDisabled } from "../../internal/attrs.js";
4
4
  import { useRovingFocus, } from "../../internal/use-roving-focus.svelte.js";
@@ -46,10 +46,7 @@ class RadioGroupItemState {
46
46
  constructor(opts, root) {
47
47
  this.opts = opts;
48
48
  this.root = root;
49
- useRefById({
50
- id: this.opts.id,
51
- ref: this.opts.ref,
52
- });
49
+ useRefById(opts);
53
50
  if (this.opts.value.current === this.root.opts.value.current) {
54
51
  this.root.rovingFocusGroup.setCurrentTabStopId(this.opts.id.current);
55
52
  this.#tabIndex = 0;
@@ -115,10 +112,6 @@ class RadioGroupInputState {
115
112
  value: this.root.opts.value.current,
116
113
  required: this.root.opts.required.current,
117
114
  disabled: this.root.opts.disabled.current,
118
- "aria-hidden": "true",
119
- hidden: true,
120
- style: styleToString(srOnlyStyles),
121
- tabIndex: -1,
122
115
  }));
123
116
  constructor(root) {
124
117
  this.root = root;
@@ -1,21 +1,15 @@
1
1
  <script lang="ts">
2
2
  import { box } from "svelte-toolbelt";
3
3
  import { useSelectHiddenInput } from "../select.svelte.js";
4
- import VisuallyHidden from "../../utilities/visually-hidden/visually-hidden.svelte";
4
+ import HiddenInput from "../../utilities/hidden-input.svelte";
5
5
 
6
- type Props = {
7
- value?: string;
8
- };
9
-
10
- let { value = $bindable("") }: Props = $props();
6
+ let { value = $bindable("") }: { value?: string } = $props();
11
7
 
12
8
  const hiddenInputState = useSelectHiddenInput({
13
9
  value: box.with(() => value),
14
10
  });
15
11
  </script>
16
12
 
17
- <VisuallyHidden>
18
- {#if hiddenInputState.shouldRender}
19
- <input {...hiddenInputState.props} bind:value />
20
- {/if}
21
- </VisuallyHidden>
13
+ {#if hiddenInputState.shouldRender}
14
+ <HiddenInput {...hiddenInputState.props} bind:value />
15
+ {/if}
@@ -1,6 +1,6 @@
1
- type Props = {
1
+ type $$ComponentProps = {
2
2
  value?: string;
3
3
  };
4
- declare const SelectHiddenInput: import("svelte").Component<Props, {}, "value">;
4
+ declare const SelectHiddenInput: import("svelte").Component<$$ComponentProps, {}, "value">;
5
5
  type SelectHiddenInput = ReturnType<typeof SelectHiddenInput>;
6
6
  export default SelectHiddenInput;
@@ -276,8 +276,6 @@ declare class SelectHiddenInputState {
276
276
  readonly required: true | undefined;
277
277
  readonly name: string;
278
278
  readonly value: string;
279
- readonly style: string;
280
- readonly tabindex: -1;
281
279
  readonly onfocus: (e: BitsFocusEvent) => void;
282
280
  };
283
281
  }
@@ -1,5 +1,5 @@
1
1
  import { Context, Previous, watch } from "runed";
2
- import { afterSleep, afterTick, onDestroyEffect, srOnlyStyles, styleToString, useRefById, } from "svelte-toolbelt";
2
+ import { afterSleep, afterTick, onDestroyEffect, useRefById } from "svelte-toolbelt";
3
3
  import { on } from "svelte/events";
4
4
  import { backward, forward, next, prev } from "../../internal/arrays.js";
5
5
  import { getAriaExpanded, getAriaHidden, getDataDisabled, getDataOpenClosed, getDisabled, getRequired, } from "../../internal/attrs.js";
@@ -861,8 +861,6 @@ class SelectHiddenInputState {
861
861
  required: getRequired(this.root.opts.required.current),
862
862
  name: this.root.opts.name.current,
863
863
  value: this.opts.value.current,
864
- style: styleToString(srOnlyStyles),
865
- tabindex: -1,
866
864
  onfocus: this.onfocus,
867
865
  }));
868
866
  }
@@ -1,9 +1,10 @@
1
1
  <script lang="ts">
2
+ import HiddenInput from "../../utilities/hidden-input.svelte";
2
3
  import { useSwitchInput } from "../switch.svelte.js";
3
4
 
4
5
  const inputState = useSwitchInput();
5
6
  </script>
6
7
 
7
8
  {#if inputState.shouldRender}
8
- <input {...inputState.props} />
9
+ <HiddenInput {...inputState.props} />
9
10
  {/if}
@@ -47,9 +47,6 @@ declare class SwitchInputState {
47
47
  readonly checked: boolean;
48
48
  readonly disabled: boolean;
49
49
  readonly required: boolean;
50
- readonly "aria-hidden": "true" | undefined;
51
- readonly style: string;
52
- readonly tabindex: -1;
53
50
  };
54
51
  }
55
52
  type SwitchThumbStateProps = WithRefProps;
@@ -1,6 +1,6 @@
1
- import { srOnlyStyles, styleToString, useRefById } from "svelte-toolbelt";
1
+ import { useRefById } from "svelte-toolbelt";
2
2
  import { Context } from "runed";
3
- import { getAriaChecked, getAriaHidden, getAriaRequired, getDataChecked, getDataDisabled, getDataRequired, getDisabled, } from "../../internal/attrs.js";
3
+ import { getAriaChecked, getAriaRequired, getDataChecked, getDataDisabled, getDataRequired, getDisabled, } from "../../internal/attrs.js";
4
4
  import { kbd } from "../../internal/kbd.js";
5
5
  const SWITCH_ROOT_ATTR = "data-switch-root";
6
6
  const SWITCH_THUMB_ATTR = "data-switch-thumb";
@@ -60,9 +60,6 @@ class SwitchInputState {
60
60
  checked: this.root.opts.checked.current,
61
61
  disabled: this.root.opts.disabled.current,
62
62
  required: this.root.opts.required.current,
63
- "aria-hidden": getAriaHidden(true),
64
- style: styleToString(srOnlyStyles),
65
- tabindex: -1,
66
63
  }));
67
64
  }
68
65
  class SwitchThumbState {
@@ -0,0 +1,20 @@
1
+ <script lang="ts">
2
+ import { mergeProps, srOnlyStylesString } from "svelte-toolbelt";
3
+ import type { HTMLInputAttributes } from "svelte/elements";
4
+
5
+ let { value = $bindable(), ...restProps }: HTMLInputAttributes = $props();
6
+
7
+ const mergedProps = $derived(
8
+ mergeProps(restProps, {
9
+ "aria-hidden": "true",
10
+ tabindex: -1,
11
+ style: srOnlyStylesString,
12
+ })
13
+ );
14
+ </script>
15
+
16
+ {#if mergedProps.type === "checkbox"}
17
+ <input {...mergedProps} {value} />
18
+ {:else}
19
+ <input bind:value {...mergedProps} />
20
+ {/if}
@@ -0,0 +1,4 @@
1
+ import type { HTMLInputAttributes } from "svelte/elements";
2
+ declare const HiddenInput: import("svelte").Component<HTMLInputAttributes, {}, "value">;
3
+ type HiddenInput = ReturnType<typeof HiddenInput>;
4
+ export default HiddenInput;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bits-ui",
3
- "version": "1.3.3",
3
+ "version": "1.3.4",
4
4
  "license": "MIT",
5
5
  "repository": "github:huntabyte/bits-ui",
6
6
  "funding": "https://github.com/sponsors/huntabyte",