bits-ui 1.4.6 → 1.4.8
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.js +6 -4
- package/dist/bits/checkbox/components/checkbox-group.svelte +2 -2
- package/dist/bits/checkbox/components/checkbox.svelte +14 -0
- package/dist/bits/utilities/text-selection-layer/text-selection-layer.svelte +1 -2
- package/dist/bits/utilities/text-selection-layer/use-text-selection-layer.svelte.d.ts +4 -4
- package/package.json +1 -1
|
@@ -16,8 +16,9 @@ class CheckboxGroupState {
|
|
|
16
16
|
if (!checkboxValue)
|
|
17
17
|
return;
|
|
18
18
|
if (!this.opts.value.current.includes(checkboxValue)) {
|
|
19
|
-
this.opts.value.current
|
|
20
|
-
this.opts.
|
|
19
|
+
const newValue = [...$state.snapshot(this.opts.value.current), checkboxValue];
|
|
20
|
+
this.opts.value.current = newValue;
|
|
21
|
+
this.opts.onValueChange.current(newValue);
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
24
|
removeValue(checkboxValue) {
|
|
@@ -26,8 +27,9 @@ class CheckboxGroupState {
|
|
|
26
27
|
const index = this.opts.value.current.indexOf(checkboxValue);
|
|
27
28
|
if (index === -1)
|
|
28
29
|
return;
|
|
29
|
-
this.opts.value.current.
|
|
30
|
-
this.opts.
|
|
30
|
+
const newValue = this.opts.value.current.filter((v) => v !== checkboxValue);
|
|
31
|
+
this.opts.value.current = newValue;
|
|
32
|
+
this.opts.onValueChange.current(newValue);
|
|
31
33
|
}
|
|
32
34
|
props = $derived.by(() => ({
|
|
33
35
|
id: this.opts.id.current,
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import { CheckboxGroupContext, useCheckboxRoot } from "../checkbox.svelte.js";
|
|
5
5
|
import CheckboxInput from "./checkbox-input.svelte";
|
|
6
6
|
import { useId } from "../../../internal/use-id.js";
|
|
7
|
+
import { watch } from "runed";
|
|
7
8
|
|
|
8
9
|
let {
|
|
9
10
|
checked = $bindable(false),
|
|
@@ -32,6 +33,19 @@
|
|
|
32
33
|
}
|
|
33
34
|
}
|
|
34
35
|
|
|
36
|
+
watch.pre(
|
|
37
|
+
() => value,
|
|
38
|
+
() => {
|
|
39
|
+
if (group && value) {
|
|
40
|
+
if (group.opts.value.current.includes(value)) {
|
|
41
|
+
checked = true;
|
|
42
|
+
} else {
|
|
43
|
+
checked = false;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
|
|
35
49
|
const rootState = useCheckboxRoot(
|
|
36
50
|
{
|
|
37
51
|
checked: box.with(
|
|
@@ -15,10 +15,9 @@
|
|
|
15
15
|
|
|
16
16
|
useTextSelectionLayer({
|
|
17
17
|
id: box.with(() => id),
|
|
18
|
-
preventOverflowTextSelection: box.with(() => preventOverflowTextSelection),
|
|
19
18
|
onPointerDown: box.with(() => onPointerDown),
|
|
20
19
|
onPointerUp: box.with(() => onPointerUp),
|
|
21
|
-
enabled: box.with(() => enabled),
|
|
20
|
+
enabled: box.with(() => enabled && preventOverflowTextSelection),
|
|
22
21
|
});
|
|
23
22
|
</script>
|
|
24
23
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { TextSelectionLayerImplProps } from "./types.js";
|
|
2
2
|
import type { ReadableBoxedValues } from "../../../internal/box.svelte.js";
|
|
3
|
-
type
|
|
3
|
+
type TextSelectionLayerStateProps = ReadableBoxedValues<Required<Omit<TextSelectionLayerImplProps, "children" | "preventOverflowTextSelection">>>;
|
|
4
4
|
export declare class TextSelectionLayerState {
|
|
5
5
|
#private;
|
|
6
|
-
readonly opts:
|
|
7
|
-
constructor(opts:
|
|
6
|
+
readonly opts: TextSelectionLayerStateProps;
|
|
7
|
+
constructor(opts: TextSelectionLayerStateProps);
|
|
8
8
|
}
|
|
9
|
-
export declare function useTextSelectionLayer(props:
|
|
9
|
+
export declare function useTextSelectionLayer(props: TextSelectionLayerStateProps): TextSelectionLayerState;
|
|
10
10
|
export {};
|