Skip to content

Commit

Permalink
fix: id synchronization (huntabyte#165)
Browse files Browse the repository at this point in the history
  • Loading branch information
huntabyte authored Nov 10, 2023
1 parent 5245385 commit b227c7a
Show file tree
Hide file tree
Showing 101 changed files with 351 additions and 163 deletions.
5 changes: 5 additions & 0 deletions .changeset/tasty-lobsters-obey.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"bits-ui": patch
---

fix: id synchronization
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
"types": "./dist/index.d.ts",
"type": "module",
"dependencies": {
"@melt-ui/svelte": "0.60.1",
"@melt-ui/svelte": "0.61.1",
"nanoid": "^5.0.3"
},
"peerDependencies": {
Expand Down
26 changes: 18 additions & 8 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 5 additions & 6 deletions src/lib/bits/accordion/components/Accordion.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@
export let multiple: $$Props["multiple"] = false as Multiple;
export let value: $$Props["value"] = undefined;
export let onValueChange: $$Props["onValueChange"] = undefined;
export let disabled = false;
export let asChild = false;
export let disabled: $$Props["disabled"] = false;
export let asChild: $$Props["asChild"] = false;
const {
elements: { root },
states: { value: localValue },
updateOption,
ids
updateOption
} = setCtx({
multiple,
disabled,
Expand All @@ -43,9 +42,9 @@
</script>

{#if asChild}
<slot {builder} {attrs} {ids} />
<slot {builder} {attrs} />
{:else}
<div use:melt={builder} {...$$restProps} {...attrs}>
<slot {builder} {attrs} {ids} />
<slot {builder} {attrs} />
</div>
{/if}
2 changes: 1 addition & 1 deletion src/lib/bits/accordion/components/AccordionContent.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
export let outTransition: $$Props["outTransition"] = undefined;
export let outTransitionConfig: $$Props["outTransitionConfig"] = undefined;
export let asChild = false;
export let asChild: $$Props["asChild"] = false;
const { content, isSelected, props } = getContent();
Expand Down
2 changes: 1 addition & 1 deletion src/lib/bits/accordion/components/AccordionHeader.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
type $$Props = HeaderProps;
export let level = 3;
export let asChild = false;
export let asChild: $$Props["asChild"] = false;
const {
elements: { heading: header }
} = getCtx();
Expand Down
2 changes: 1 addition & 1 deletion src/lib/bits/accordion/components/AccordionItem.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
export let value: $$Props["value"];
export let disabled: $$Props["disabled"] = undefined;
export let asChild = false;
export let asChild: $$Props["asChild"] = false;
const { item, props } = setItem({ value, disabled });
$: builder = $item(props);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
type $$Props = ActionProps;
type $$Events = ActionEvents;
export let asChild = false;
export let asChild: $$Props["asChild"] = false;
const {
elements: { close }
} = getCtx();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
type $$Props = CancelProps;
type $$Events = CancelEvents;
export let asChild = false;
export let asChild: $$Props["asChild"] = false;
const {
elements: { close }
} = getCtx();
Expand Down
11 changes: 8 additions & 3 deletions src/lib/bits/alert-dialog/components/AlertDialogContent.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,19 @@
export let inTransitionConfig: $$Props["inTransitionConfig"] = undefined;
export let outTransition: $$Props["outTransition"] = undefined;
export let outTransitionConfig: $$Props["outTransitionConfig"] = undefined;
export let asChild = false;
export let id: $$Props["id"] = undefined;
export let asChild: $$Props["asChild"] = false;
const {
elements: { content },
states: { open }
states: { open },
ids
} = getCtx();
$: if (id) {
ids.content.set(id);
}
$: builder = $content;
const attrs = getAttrs("content");
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,18 @@
import type { DescriptionProps } from "../types.js";
type $$Props = DescriptionProps;
export let asChild = false;
export let asChild: $$Props["asChild"] = false;
export let id: $$Props["id"] = undefined;
const {
elements: { description }
elements: { description },
ids
} = getCtx();
$: if (id) {
ids.description.set(id);
}
$: builder = $description;
const attrs = getAttrs("description");
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
export let outTransition: $$Props["outTransition"] = undefined;
export let outTransitionConfig: $$Props["outTransitionConfig"] = undefined;
export let asChild = false;
export let asChild: $$Props["asChild"] = false;
const {
elements: { overlay },
states: { open }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import type { PortalProps } from "../types.js";
type $$Props = PortalProps;
export let asChild = false;
export let asChild: $$Props["asChild"] = false;
const {
elements: { portalled }
} = getCtx();
Expand Down
13 changes: 10 additions & 3 deletions src/lib/bits/alert-dialog/components/AlertDialogTitle.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,19 @@
import type { TitleProps } from "../types.js";
type $$Props = TitleProps;
export let level: TitleProps["level"] = "h2";
export let asChild = false;
export let level: $$Props["level"] = "h2";
export let asChild: $$Props["asChild"] = false;
export let id: $$Props["id"] = undefined;
const {
elements: { title }
elements: { title },
ids
} = getCtx();
$: if (id) {
ids.title.set(id);
}
$: builder = $title;
const attrs = getAttrs("title");
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
type $$Props = TriggerProps;
type $$Events = TriggerEvents;
export let asChild = false;
export let asChild: $$Props["asChild"] = false;
const {
elements: { trigger }
} = getCtx();
Expand Down
2 changes: 1 addition & 1 deletion src/lib/bits/avatar/components/Avatar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
export let delayMs: $$Props["delayMs"] = undefined;
export let loadingStatus: $$Props["loadingStatus"] = undefined;
export let onLoadingStatusChange: $$Props["onLoadingStatusChange"] = undefined;
export let asChild = false;
export let asChild: $$Props["asChild"] = false;
const {
states: { loadingStatus: localLoadingStatus },
Expand Down
2 changes: 1 addition & 1 deletion src/lib/bits/avatar/components/AvatarFallback.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import type { FallbackProps } from "../types.js";
type $$Props = FallbackProps;
export let asChild = false;
export let asChild: $$Props["asChild"] = false;
const {
elements: { fallback }
} = getCtx();
Expand Down
2 changes: 1 addition & 1 deletion src/lib/bits/avatar/components/AvatarImage.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
type $$Props = ImageProps;
export let src: $$Props["src"] = undefined;
export let alt: $$Props["alt"] = undefined;
export let asChild = false;
export let asChild: $$Props["asChild"] = false;
$: image = getImage(src).elements.image;
$: builder = $image;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/bits/checkbox/components/Checkbox.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
export let required: $$Props["required"] = undefined;
export let value: $$Props["value"] = undefined;
export let onCheckedChange: $$Props["onCheckedChange"] = undefined;
export let asChild = false;
export let asChild: $$Props["asChild"] = false;
const {
elements: { root },
Expand Down
2 changes: 1 addition & 1 deletion src/lib/bits/collapsible/components/Collapsible.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
export let disabled: $$Props["disabled"] = undefined;
export let open: $$Props["open"] = undefined;
export let onOpenChange: $$Props["onOpenChange"] = undefined;
export let asChild = false;
export let asChild: $$Props["asChild"] = false;
const {
elements: { root },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
export let inTransitionConfig: $$Props["inTransitionConfig"] = undefined;
export let outTransition: $$Props["outTransition"] = undefined;
export let outTransitionConfig: $$Props["outTransitionConfig"] = undefined;
export let asChild = false;
export let asChild: $$Props["asChild"] = false;
const {
elements: { content },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
type $$Props = TriggerProps;
type $$Events = TriggerEvents;
export let asChild = false;
export let asChild: $$Props["asChild"] = false;
const {
elements: { trigger }
} = getCtx();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
type $$Props = ArrowProps;
export let size = 8;
export let asChild = false;
export let asChild: $$Props["asChild"] = false;
const {
elements: { arrow }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
export let checked: $$Props["checked"] = undefined;
export let disabled: $$Props["disabled"] = undefined;
export let onCheckedChange: $$Props["onCheckedChange"] = undefined;
export let asChild = false;
export let asChild: $$Props["asChild"] = false;
const {
elements: { checkboxItem },
states: { checked: localChecked },
Expand Down
11 changes: 9 additions & 2 deletions src/lib/bits/context-menu/components/ContextMenuContent.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,21 @@
export let inTransitionConfig: $$Props["inTransitionConfig"] = undefined;
export let outTransition: $$Props["outTransition"] = undefined;
export let outTransitionConfig: $$Props["outTransitionConfig"] = undefined;
export let asChild: $$Props["asChild"] = false;
export let id: $$Props["id"] = undefined;
export let asChild = false;
const {
elements: { menu },
states: { open }
states: { open },
ids
} = getContent(sideOffset);
const dispatch = createDispatcher();
$: if (id) {
ids.menu.set(id);
}
$: builder = $menu;
const attrs = getAttrs("content");
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { setGroup, getAttrs } from "../ctx.js";
import type { GroupProps } from "../types.js";
type $$Props = GroupProps;
export let asChild = false;
export let asChild: $$Props["asChild"] = false;
const { group, id } = setGroup();
$: builder = $group(id);
const attrs = getAttrs("group");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { getGroupLabel, getAttrs } from "../ctx.js";
import type { LabelProps } from "../types.js";
type $$Props = LabelProps;
export let asChild = false;
export let asChild: $$Props["asChild"] = false;
const { groupLabel, id } = getGroupLabel();
$: builder = $groupLabel(id);
const attrs = getAttrs("label");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
type $$Props = RadioGroupProps;
export let value: $$Props["value"] = undefined;
export let onValueChange: $$Props["onValueChange"] = undefined;
export let asChild = false;
export let asChild: $$Props["asChild"] = false;
const {
elements: { radioGroup },
Expand Down
Loading

0 comments on commit b227c7a

Please sign in to comment.