Assorted fixes

Type fixes, support a couple more classes as functions for the examples, and switch TabPanels to registering ids instead of refs
This commit is contained in:
Ryan Gossiaux
2021-12-17 14:22:19 -08:00
parent 6076a60837
commit c5ed870827
6 changed files with 37 additions and 19 deletions

View File

@@ -5,14 +5,13 @@
let api = useTabsContext("TabPanel");
let id = `headlessui-tabs-panel-${useId()}`;
let panelRef = null;
onMount(() => {
$api.registerPanel(panelRef);
return () => $api.unregisterPanel(panelRef);
$api.registerPanel(id);
return () => $api.unregisterPanel(id);
});
$: myIndex = $api.panels.indexOf(panelRef);
$: myIndex = $api.panels.indexOf(id);
$: selected = myIndex === $api.selectedIndex;
$: propsWeControl = {
@@ -23,8 +22,8 @@
};
</script>
<div {...{ ...$$restProps, ...propsWeControl }} bind:this={panelRef}>
{#if selected}
{#if selected}
<div {...{ ...$$restProps, ...propsWeControl }}>
<slot />
{/if}
</div>
</div>
{/if}