Standardize event names to be consistent with @headlessui-react
Was previously using Vue names since Vue was the primary reference while porting, but as the public API is closer to the React one it makes sense to use that. Fixes #8
This commit is contained in:
@@ -164,7 +164,7 @@
|
|||||||
},
|
},
|
||||||
select(value: unknown) {
|
select(value: unknown) {
|
||||||
if (disabled) return;
|
if (disabled) return;
|
||||||
dispatch("updateValue", { value });
|
dispatch("change", value);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
setContext(LISTBOX_CONTEXT_NAME, api);
|
setContext(LISTBOX_CONTEXT_NAME, api);
|
||||||
|
|||||||
@@ -70,7 +70,7 @@
|
|||||||
(option) => option.propsRef.value === nextValue
|
(option) => option.propsRef.value === nextValue
|
||||||
)?.propsRef;
|
)?.propsRef;
|
||||||
if (nextOption?.disabled) return false;
|
if (nextOption?.disabled) return false;
|
||||||
dispatch("updateValue", nextValue);
|
dispatch("change", nextValue);
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
registerOption(action: Option) {
|
registerOption(action: Option) {
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
$: switchStore = $api?.switchStore;
|
$: switchStore = $api?.switchStore;
|
||||||
|
|
||||||
function toggle() {
|
function toggle() {
|
||||||
dispatch("updateValue", !checked);
|
dispatch("change", !checked);
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleClick(event: MouseEvent) {
|
function handleClick(event: MouseEvent) {
|
||||||
|
|||||||
@@ -61,7 +61,7 @@
|
|||||||
setSelectedIndex(index: number) {
|
setSelectedIndex(index: number) {
|
||||||
if (selectedIndex === index) return;
|
if (selectedIndex === index) return;
|
||||||
selectedIndex = index;
|
selectedIndex = index;
|
||||||
dispatch("updateValue", index);
|
dispatch("change", index);
|
||||||
},
|
},
|
||||||
registerTab(tab: typeof tabs[number]) {
|
registerTab(tab: typeof tabs[number]) {
|
||||||
if (!tabs.includes(tab)) tabs = [...tabs, tab];
|
if (!tabs.includes(tab)) tabs = [...tabs, tab];
|
||||||
|
|||||||
@@ -36,9 +36,9 @@
|
|||||||
<div class="space-y-1">
|
<div class="space-y-1">
|
||||||
<Listbox
|
<Listbox
|
||||||
value={active}
|
value={active}
|
||||||
on:updateValue={(event) => {
|
on:change={(event) => {
|
||||||
console.log("value:", event.detail.value);
|
console.log("value:", event.detail);
|
||||||
active = event.detail.value;
|
active = event.detail;
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<ListboxLabel class="block text-sm font-medium leading-5 text-gray-700">
|
<ListboxLabel class="block text-sm font-medium leading-5 text-gray-700">
|
||||||
|
|||||||
@@ -7,8 +7,6 @@
|
|||||||
ListboxOptions,
|
ListboxOptions,
|
||||||
} from "$lib";
|
} from "$lib";
|
||||||
|
|
||||||
import { onMount } from "svelte";
|
|
||||||
|
|
||||||
function classNames(
|
function classNames(
|
||||||
...classes: (false | null | undefined | string)[]
|
...classes: (false | null | undefined | string)[]
|
||||||
): string {
|
): string {
|
||||||
@@ -36,8 +34,8 @@
|
|||||||
<div class="space-y-1">
|
<div class="space-y-1">
|
||||||
<Listbox
|
<Listbox
|
||||||
value={active}
|
value={active}
|
||||||
on:updateValue={(event) => {
|
on:change={(event) => {
|
||||||
active = event.detail.value;
|
active = event.detail;
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<ListboxLabel class="block text-sm font-medium leading-5 text-gray-700">
|
<ListboxLabel class="block text-sm font-medium leading-5 text-gray-700">
|
||||||
|
|||||||
@@ -20,15 +20,12 @@
|
|||||||
description: "You are the only one able to access this project",
|
description: "You are the only one able to access this project",
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
let active;
|
let active: typeof access[number];
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="p-12 max-w-xl">
|
<div class="p-12 max-w-xl">
|
||||||
<a href="/">Link before</a>
|
<a href="/">Link before</a>
|
||||||
<RadioGroup
|
<RadioGroup value={active} on:change={(event) => (active = event.detail)}>
|
||||||
value={active}
|
|
||||||
on:updateValue={(event) => (active = event.detail)}
|
|
||||||
>
|
|
||||||
<fieldset class="space-y-4">
|
<fieldset class="space-y-4">
|
||||||
<legend>
|
<legend>
|
||||||
<h2 class="text-xl">Privacy setting</h2>
|
<h2 class="text-xl">Privacy setting</h2>
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
<Switch
|
<Switch
|
||||||
as="button"
|
as="button"
|
||||||
checked={state}
|
checked={state}
|
||||||
on:updateValue={(event) => (state = event.detail)}
|
on:change={(event) => (state = event.detail)}
|
||||||
class={({ checked }) =>
|
class={({ checked }) =>
|
||||||
classNames(
|
classNames(
|
||||||
"relative inline-flex flex-shrink-0 h-6 border-2 border-transparent rounded-full cursor-pointer w-11 focus:outline-none focus:shadow-outline transition-colors ease-in-out duration-200",
|
"relative inline-flex flex-shrink-0 h-6 border-2 border-transparent rounded-full cursor-pointer w-11 focus:outline-none focus:shadow-outline transition-colors ease-in-out duration-200",
|
||||||
|
|||||||
@@ -33,7 +33,7 @@
|
|||||||
<Switch
|
<Switch
|
||||||
as="button"
|
as="button"
|
||||||
checked={manual}
|
checked={manual}
|
||||||
on:updateValue={(event) => (manual = event.detail)}
|
on:change={(event) => (manual = event.detail)}
|
||||||
class={({ checked }) =>
|
class={({ checked }) =>
|
||||||
classNames(
|
classNames(
|
||||||
"relative inline-flex flex-shrink-0 h-6 border-2 border-transparent rounded-full cursor-pointer w-11 focus:outline-none focus:shadow-outline transition-colors ease-in-out duration-200",
|
"relative inline-flex flex-shrink-0 h-6 border-2 border-transparent rounded-full cursor-pointer w-11 focus:outline-none focus:shadow-outline transition-colors ease-in-out duration-200",
|
||||||
|
|||||||
Reference in New Issue
Block a user