diff --git a/.changeset/lovely-phones-retire.md b/.changeset/lovely-phones-retire.md new file mode 100644 index 000000000..d69cac6b1 --- /dev/null +++ b/.changeset/lovely-phones-retire.md @@ -0,0 +1,5 @@ +--- +"bits-ui": patch +--- + +fix: Update `Builder` type to support all Melt UI builders diff --git a/src/lib/bits/calendar/components/calendar-date.svelte b/src/lib/bits/calendar/components/calendar-date.svelte index 48d3b22ed..a03578171 100644 --- a/src/lib/bits/calendar/components/calendar-date.svelte +++ b/src/lib/bits/calendar/components/calendar-date.svelte @@ -18,6 +18,7 @@ const attrs = getAttrs("date"); $: builder = $cell(date, month); + $: Object.assign(builder, attrs); const dispatch = createDispatcher(); diff --git a/src/lib/helpers/builders.ts b/src/lib/helpers/builders.ts index 060ad96f2..3e69dee78 100644 --- a/src/lib/helpers/builders.ts +++ b/src/lib/helpers/builders.ts @@ -1,13 +1,16 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ import type { Action, ActionReturn } from "svelte/action"; -export type Builder = { - [x: PropertyKey]: unknown; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - action: Action; +export type Builder< + Element = any, + Param = any, + Attributes extends Record = Record +> = Record & { + action: Action; }; type BuilderActionsParams = { - builders: Builder[]; + builders: Builder[]; }; type BuilderActionsReturn = { @@ -36,7 +39,7 @@ export function builderActions( }; } -export function getAttrs(builders: Builder[]) { +export function getAttrs(builders: Builder[]) { const attrs: Record = {}; builders.forEach((builder) => { Object.keys(builder).forEach((key) => {