Skip to content

Commit e6bd6fb

Browse files
committed
chore: rename onValueChange to onChange
1 parent 93b71a2 commit e6bd6fb

File tree

8 files changed

+17
-17
lines changed

8 files changed

+17
-17
lines changed

apps/website/src/routes/docs/headless/toggle-group/examples/test-disabled-value-multiple.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default component$(() => {
1212
<ToggleGroup.Root
1313
multiple
1414
value={['left', 'center']}
15-
onValueChange$={(v) => (valueSelected.value = v)}
15+
onChange$={(v) => (valueSelected.value = v)}
1616
disabled
1717
>
1818
<ToggleGroup.Item value="left" aria-label="Left aligned" class="toggle">

apps/website/src/routes/docs/headless/toggle-group/examples/test-disabled-value.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default component$(() => {
1212
<div class="toggle-container">
1313
<ToggleGroup.Root
1414
value={'left'}
15-
onValueChange$={(v: string) => {
15+
onChange$={(v: string) => {
1616
valueSelected.value = v;
1717
}}
1818
disabled

apps/website/src/routes/docs/headless/toggle-group/examples/test-value-multiple.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default component$(() => {
1212
<ToggleGroup.Root
1313
multiple
1414
value={['left', 'center']}
15-
onValueChange$={(v) => (valueSelected.value = v)}
15+
onChange$={(v) => (valueSelected.value = v)}
1616
>
1717
<ToggleGroup.Item value="left" aria-label="Left aligned" class="toggle">
1818
Left

apps/website/src/routes/docs/headless/toggle-group/examples/value.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default component$(() => {
1212
<div class="toggle-container">
1313
<ToggleGroup.Root
1414
value={'left'}
15-
onValueChange$={(v: string) => {
15+
onChange$={(v: string) => {
1616
valueSelected.value = v;
1717
}}
1818
>

apps/website/src/routes/docs/headless/toggle-group/index.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ An initial, uncontrolled value can be provided using the `value` prop.
5959
<Showcase name="initialValue" />
6060

6161
If you want to have some control when an item is selected, like making some side effect you can use
62-
the `onValueChange$`. The event is fired when the user toggle the button, and receives the new value.
62+
the `onChange$`. The event is fired when the user toggle the button, and receives the new value.
6363

6464
<Showcase name="value" />
6565

@@ -153,10 +153,10 @@ Pass the `direction` prop to `rtl`.
153153
name: 'value',
154154
type: 'string | string[]',
155155
description:
156-
'Initial value to make the pressed state uncontrolled. Use in conjunction with `onValueChange$` to have some reactivity.',
156+
'Initial value to make the pressed state uncontrolled. Use in conjunction with `onChange$` to have some reactivity.',
157157
},
158158
{
159-
name: 'onValueChange$',
159+
name: 'onChange$',
160160
type: 'function',
161161
info: 'PropFunction<() => void>',
162162
description: 'Called when the state changes.',

packages/kit-headless/src/components/toggle-group/toggle-group-root.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@ export type ToggleGroupSingleProps = {
4242
multiple?: false;
4343
/**
4444
* The initial value of the pressed item (uncontrolled).
45-
* Can be used in conjunction with onValueChange.
45+
* Can be used in conjunction with onChange$.
4646
*/
4747
value?: string;
4848

4949
/**
5050
* The callback that fires when the value of the toggle group changes.
5151
* Event handler called when the pressed state of an item changes.
5252
*/
53-
onValueChange$?: QRL<(value: string) => void>;
53+
onChange$?: QRL<(value: string) => void>;
5454
/**
5555
* The reactive value (a signal) of the pressed item (the signal is the controlled value).
5656
* Controlling the pressed state with a bounded value.
@@ -65,14 +65,14 @@ export type ToggleGroupMultipleProps = {
6565
multiple?: true;
6666
/**
6767
* The initial value of the pressed item (uncontrolled).
68-
* Can be used in conjunction with onValueChange.
68+
* Can be used in conjunction with onChange$.
6969
*/
7070
value?: string[];
7171
/**
7272
* The callback that fires when the value of the toggle group changes.
7373
* Event handler called when the pressed state of an item changes.
7474
*/
75-
onValueChange$?: QRL<(value: string[]) => void>;
75+
onChange$?: QRL<(value: string[]) => void>;
7676
/**
7777
* The reactive value (a signal) of the pressed item (the signal is the controlled value).
7878
* Controlling the pressed state with a bounded value.
@@ -88,7 +88,7 @@ export type ToggleGroupRootProps = PropsOf<'div'> & ToggleGroupApiProps;
8888

8989
export const HToggleGroupRoot = component$<ToggleGroupRootProps>((props) => {
9090
const {
91-
onValueChange$: _,
91+
onChange$: _,
9292
disabled = false,
9393
orientation = 'horizontal',
9494
direction = 'ltr',

packages/kit-headless/src/components/toggle-group/toggle-group.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ test.describe('Mouse Behavior', () => {
215215
await expect(centerItem).toHaveAttribute('aria-pressed', 'false');
216216
});
217217

218-
//Some control (value + onValueChange)
218+
//Some control (value + onChange$)
219219
//single
220220
test(`GIVEN a toggle-group with 'value' = 'left'
221221
WHEN the 'center' item is clicked

packages/kit-headless/src/components/toggle-group/use-toggle.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@ function useRootItemsRepo() {
4242
}
4343

4444
function useCreateSingleToggleGroup(props: ToggleGroupSingleProps) {
45-
const { multiple = false, value, onValueChange$, 'bind:value': givenValueSig } = props;
45+
const { multiple = false, value, onChange$, 'bind:value': givenValueSig } = props;
4646

4747
const pressedValuesSig = useBoundSignal(givenValueSig, value);
4848
const rootItemsRepo = useRootItemsRepo();
4949

5050
const handleValueChange$ = $((newValue: string) => {
5151
pressedValuesSig.value = newValue;
5252

53-
if (onValueChange$) onValueChange$(pressedValuesSig.value);
53+
if (onChange$) onChange$(pressedValuesSig.value);
5454
});
5555

5656
const activateItem$ = $((itemValue: string) => handleValueChange$(itemValue));
@@ -70,7 +70,7 @@ function useCreateSingleToggleGroup(props: ToggleGroupSingleProps) {
7070
}
7171

7272
function useCreateMultipleToggleGroup(props: ToggleGroupMultipleProps) {
73-
const { multiple = true, 'bind:value': givenValueSig, value, onValueChange$ } = props;
73+
const { multiple = true, 'bind:value': givenValueSig, value, onChange$ } = props;
7474

7575
/*
7676
Need to pass an empty array if not I got: TypeError when toggle
@@ -83,7 +83,7 @@ function useCreateMultipleToggleGroup(props: ToggleGroupMultipleProps) {
8383
const handleValueChange$ = $((newValue: string[]) => {
8484
pressedValuesSig.value = newValue;
8585

86-
if (onValueChange$) onValueChange$(pressedValuesSig.value);
86+
if (onChange$) onChange$(pressedValuesSig.value);
8787
});
8888

8989
const activateItem$ = $((itemValue: string) =>

0 commit comments

Comments
 (0)