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.
- package/dist/bits/checkbox/checkbox.svelte.d.ts +0 -2
- package/dist/bits/checkbox/checkbox.svelte.js +1 -3
- package/dist/bits/checkbox/components/checkbox-input.svelte +2 -4
- package/dist/bits/date-field/components/date-field-hidden-input.svelte +2 -6
- package/dist/bits/date-field/date-field.svelte.d.ts +0 -1
- package/dist/bits/date-field/date-field.svelte.js +0 -1
- package/dist/bits/radio-group/components/radio-group-input.svelte +2 -1
- package/dist/bits/radio-group/radio-group.svelte.d.ts +0 -4
- package/dist/bits/radio-group/radio-group.svelte.js +2 -9
- package/dist/bits/select/components/select-hidden-input.svelte +5 -11
- package/dist/bits/select/components/select-hidden-input.svelte.d.ts +2 -2
- package/dist/bits/select/select.svelte.d.ts +0 -2
- package/dist/bits/select/select.svelte.js +1 -3
- package/dist/bits/switch/components/switch-input.svelte +2 -1
- package/dist/bits/switch/switch.svelte.d.ts +0 -3
- package/dist/bits/switch/switch.svelte.js +2 -5
- package/dist/bits/utilities/hidden-input.svelte +20 -0
- package/dist/bits/utilities/hidden-input.svelte.d.ts +4 -0
- package/package.json +1 -1
|
@@ -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 {
|
|
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
|
|
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
|
-
<
|
|
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
|
|
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
|
-
<
|
|
10
|
-
{#snippet child({ props })}
|
|
11
|
-
<input {...props} {...hiddenInputState.props} />
|
|
12
|
-
{/snippet}
|
|
13
|
-
</VisuallyHidden>
|
|
9
|
+
<HiddenInput {...hiddenInputState.props} />
|
|
14
10
|
{/if}
|
|
@@ -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
|
-
<
|
|
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 {
|
|
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
|
|
4
|
+
import HiddenInput from "../../utilities/hidden-input.svelte";
|
|
5
5
|
|
|
6
|
-
|
|
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
|
-
|
|
18
|
-
{
|
|
19
|
-
|
|
20
|
-
{/if}
|
|
21
|
-
</VisuallyHidden>
|
|
13
|
+
{#if hiddenInputState.shouldRender}
|
|
14
|
+
<HiddenInput {...hiddenInputState.props} bind:value />
|
|
15
|
+
{/if}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
type
|
|
1
|
+
type $$ComponentProps = {
|
|
2
2
|
value?: string;
|
|
3
3
|
};
|
|
4
|
-
declare const SelectHiddenInput: import("svelte").Component
|
|
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,
|
|
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
|
-
<
|
|
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 {
|
|
1
|
+
import { useRefById } from "svelte-toolbelt";
|
|
2
2
|
import { Context } from "runed";
|
|
3
|
-
import { getAriaChecked,
|
|
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}
|