From 52325d008a3c2a1c304dc67c6923848115c0b05b Mon Sep 17 00:00:00 2001 From: Hunter Johnston Date: Mon, 22 Jul 2024 11:38:36 -0400 Subject: [PATCH] more tidying --- .../bits-ui/src/lib/bits/accordion/types.ts | 10 +--- .../components/alert-dialog-content.svelte | 2 +- .../src/lib/bits/aspect-ratio/types.ts | 3 +- packages/bits-ui/src/lib/bits/avatar/types.ts | 6 +-- .../calendar/components/calendar-cell.svelte | 2 +- .../bits-ui/src/lib/bits/calendar/types.ts | 8 ++- .../bits-ui/src/lib/bits/checkbox/types.ts | 8 +-- .../bits-ui/src/lib/bits/collapsible/types.ts | 9 +--- .../components/combobox-content.svelte | 2 +- .../components/combobox-group-label.svelte | 2 +- .../combobox/components/combobox-group.svelte | 2 +- .../bits-ui/src/lib/bits/combobox/types.ts | 7 +-- .../src/lib/bits/context-menu/types.ts | 3 +- .../bits-ui/src/lib/bits/date-field/types.ts | 9 +--- .../components/date-picker-calendar.svelte | 2 +- .../bits-ui/src/lib/bits/date-picker/types.ts | 9 +--- .../src/lib/bits/date-range-field/types.ts | 9 +--- .../date-range-picker-calendar.svelte | 2 +- .../components/date-range-picker.svelte | 2 +- .../src/lib/bits/date-range-picker/types.ts | 8 +-- .../dialog/components/dialog-close.svelte | 2 +- .../dialog/components/dialog-content.svelte | 2 +- .../components/dialog-description.svelte | 2 +- .../dialog/components/dialog-overlay.svelte | 2 +- .../dialog/components/dialog-title.svelte | 2 +- .../dialog/components/dialog-trigger.svelte | 2 +- packages/bits-ui/src/lib/bits/dialog/types.ts | 10 +--- packages/bits-ui/src/lib/bits/label/types.ts | 3 +- .../components/link-preview-content.svelte | 2 +- .../components/link-preview-trigger.svelte | 2 +- .../src/lib/bits/link-preview/types.ts | 11 +--- .../listbox/components/listbox-content.svelte | 2 +- .../components/listbox-group-label.svelte | 2 +- .../listbox/components/listbox-group.svelte | 2 +- .../listbox/components/listbox-item.svelte | 2 +- .../listbox/components/listbox-label.svelte | 2 +- .../bits-ui/src/lib/bits/listbox/types.ts | 9 +--- .../menu/components/menu-checkbox-item.svelte | 2 +- .../lib/bits/menu/components/menu-item.svelte | 2 +- packages/bits-ui/src/lib/bits/menu/types.ts | 10 +--- .../bits-ui/src/lib/bits/menubar/types.ts | 10 +--- .../components/navigation-menu-sub.svelte | 2 +- .../navigation-menu-viewport.svelte | 2 +- .../src/lib/bits/navigation-menu/types.ts | 6 +-- .../components/pagination-next-button.svelte | 2 +- .../components/pagination-page.svelte | 2 +- .../components/pagination-prev-button.svelte | 2 +- .../pagination/components/pagination.svelte | 13 ++--- .../lib/bits/pagination/pagination.svelte.ts | 6 ++- .../bits-ui/src/lib/bits/pagination/types.ts | 8 +-- .../bits-ui/src/lib/bits/pin-input/types.ts | 3 +- .../popover/components/popover-close.svelte | 2 +- .../popover/components/popover-content.svelte | 2 +- .../popover/components/popover-trigger.svelte | 2 +- .../bits-ui/src/lib/bits/popover/types.ts | 10 +--- .../bits/progress/components/progress.svelte | 2 +- .../bits-ui/src/lib/bits/progress/types.ts | 3 +- .../components/radio-group-item.svelte | 11 ++-- .../radio-group/components/radio-group.svelte | 2 +- .../bits-ui/src/lib/bits/radio-group/types.ts | 10 +--- .../components/range-calendar-cell.svelte | 2 +- .../components/range-calendar-day.svelte | 2 +- .../components/range-calendar.svelte | 2 +- .../src/lib/bits/range-calendar/types.ts | 8 +-- .../scroll-area-scrollbar-shared.svelte | 2 +- .../bits-ui/src/lib/bits/scroll-area/types.ts | 2 +- .../components/select-content-floating.svelte | 2 +- .../select-content-item-aligned.svelte | 5 +- .../components/select-group-label.svelte | 2 +- .../select/components/select-group.svelte | 2 +- .../bits/select/components/select-icon.svelte | 2 +- .../select/components/select-item-text.svelte | 2 +- .../bits/select/components/select-item.svelte | 2 +- .../select-scroll-down-button-mounted.svelte | 2 +- .../select-scroll-up-button-mounted.svelte | 2 +- .../select/components/select-separator.svelte | 2 +- .../select/components/select-trigger.svelte | 2 +- .../select/components/select-value.svelte | 2 +- .../select/components/select-viewport.svelte | 2 +- packages/bits-ui/src/lib/bits/select/types.ts | 7 +-- .../bits-ui/src/lib/bits/separator/types.ts | 3 +- packages/bits-ui/src/lib/bits/slider/types.ts | 8 +-- .../lib/bits/switch/components/switch.svelte | 2 +- packages/bits-ui/src/lib/bits/switch/types.ts | 10 +--- .../lib/bits/tabs/components/tabs-list.svelte | 2 +- .../bits/tabs/components/tabs-trigger.svelte | 2 +- .../src/lib/bits/tabs/components/tabs.svelte | 2 +- packages/bits-ui/src/lib/bits/tabs/types.ts | 9 +--- .../components/toggle-group-item.svelte | 2 +- .../components/toggle-group.svelte | 2 +- .../src/lib/bits/toggle-group/types.ts | 9 +--- .../lib/bits/toggle/components/toggle.svelte | 2 +- packages/bits-ui/src/lib/bits/toggle/types.ts | 8 +-- .../toolbar/components/toolbar-button.svelte | 2 +- .../components/toolbar-group-item.svelte | 2 +- .../toolbar/components/toolbar-group.svelte | 2 +- .../toolbar/components/toolbar-link.svelte | 2 +- .../bits/toolbar/components/toolbar.svelte | 2 +- .../bits-ui/src/lib/bits/toolbar/types.ts | 5 +- .../tooltip/components/tooltip-content.svelte | 2 +- .../tooltip/components/tooltip-trigger.svelte | 2 +- .../bits-ui/src/lib/bits/tooltip/types.ts | 10 +--- .../src/lib/bits/utilities/arrow/types.ts | 3 +- .../bits/utilities/floating-layer/types.ts | 4 +- .../floating-layer/useFloatingLayer.svelte.ts | 17 ++++--- .../bits/utilities/visually-hidden/types.ts | 3 +- packages/bits-ui/src/lib/internal/is.ts | 4 ++ packages/bits-ui/src/lib/internal/types.ts | 50 ++----------------- .../lib/internal/useBodyScrollLock.svelte.ts | 4 +- .../src/lib/internal/useTimeoutFn.svelte.ts | 4 +- packages/bits-ui/src/lib/shared/attributes.ts | 50 +++++++++++++++++++ packages/bits-ui/src/lib/shared/index.ts | 1 + .../tests/accordion/AccordionMultiTest.svelte | 3 +- .../AccordionMultiTestControlled.svelte | 3 +- packages/bits-ui/src/tests/utils.ts | 10 ++-- 115 files changed, 236 insertions(+), 342 deletions(-) create mode 100644 packages/bits-ui/src/lib/shared/attributes.ts diff --git a/packages/bits-ui/src/lib/bits/accordion/types.ts b/packages/bits-ui/src/lib/bits/accordion/types.ts index 3d213dc8b..776d426c7 100644 --- a/packages/bits-ui/src/lib/bits/accordion/types.ts +++ b/packages/bits-ui/src/lib/bits/accordion/types.ts @@ -1,11 +1,5 @@ -import type { - EventCallback, - OnChangeFn, - PrimitiveButtonAttributes, - PrimitiveDivAttributes, - WithChild, - Without, -} from "$lib/internal/index.js"; +import type { EventCallback, OnChangeFn, WithChild, Without } from "$lib/internal/index.js"; +import type { PrimitiveButtonAttributes, PrimitiveDivAttributes } from "$lib/shared/attributes.js"; import type { Orientation } from "$lib/shared/index.js"; export type BaseAccordionRootPropsWithoutHTML = { diff --git a/packages/bits-ui/src/lib/bits/alert-dialog/components/alert-dialog-content.svelte b/packages/bits-ui/src/lib/bits/alert-dialog/components/alert-dialog-content.svelte index 2b9a95330..2e2cd9536 100644 --- a/packages/bits-ui/src/lib/bits/alert-dialog/components/alert-dialog-content.svelte +++ b/packages/bits-ui/src/lib/bits/alert-dialog/components/alert-dialog-content.svelte @@ -66,7 +66,7 @@ {#if child} - {@render child?.({ + {@render child({ props: mergeProps(mergedProps, focusScopeProps, { hidden: !present.current, }), diff --git a/packages/bits-ui/src/lib/bits/aspect-ratio/types.ts b/packages/bits-ui/src/lib/bits/aspect-ratio/types.ts index b4d09c34d..8e57301e8 100644 --- a/packages/bits-ui/src/lib/bits/aspect-ratio/types.ts +++ b/packages/bits-ui/src/lib/bits/aspect-ratio/types.ts @@ -1,4 +1,5 @@ -import type { PrimitiveDivAttributes, WithChild, Without } from "$lib/internal/index.js"; +import type { WithChild, Without } from "$lib/internal/index.js"; +import type { PrimitiveDivAttributes } from "$lib/shared/attributes.js"; export type AspectRatioPropsWithoutHTML = WithChild<{ ratio?: number; diff --git a/packages/bits-ui/src/lib/bits/avatar/types.ts b/packages/bits-ui/src/lib/bits/avatar/types.ts index 7bf64acbc..a88d94372 100644 --- a/packages/bits-ui/src/lib/bits/avatar/types.ts +++ b/packages/bits-ui/src/lib/bits/avatar/types.ts @@ -1,11 +1,9 @@ +import type { OnChangeFn, WithChild, Without } from "$lib/internal/index.js"; import type { - OnChangeFn, PrimitiveDivAttributes, PrimitiveImgAttributes, PrimitiveSpanAttributes, - WithChild, - Without, -} from "$lib/internal/index.js"; +} from "$lib/shared/attributes.js"; export type AvatarImageLoadingStatus = "loading" | "loaded" | "error"; diff --git a/packages/bits-ui/src/lib/bits/calendar/components/calendar-cell.svelte b/packages/bits-ui/src/lib/bits/calendar/components/calendar-cell.svelte index 9d1c8b0e3..b11e12584 100644 --- a/packages/bits-ui/src/lib/bits/calendar/components/calendar-cell.svelte +++ b/packages/bits-ui/src/lib/bits/calendar/components/calendar-cell.svelte @@ -29,7 +29,7 @@ {#if child} - {@render child?.({ + {@render child({ props: mergedProps, ...cellState.snippetProps, })} diff --git a/packages/bits-ui/src/lib/bits/calendar/types.ts b/packages/bits-ui/src/lib/bits/calendar/types.ts index 1519e8d8f..3a20077c7 100644 --- a/packages/bits-ui/src/lib/bits/calendar/types.ts +++ b/packages/bits-ui/src/lib/bits/calendar/types.ts @@ -1,6 +1,7 @@ import type { DateValue } from "@internationalized/date"; +import type { OnChangeFn, WithChild, Without } from "$lib/internal/types.js"; +import type { DateMatcher, Month, WeekStartsOn } from "$lib/shared/date/types.js"; import type { - OnChangeFn, PrimitiveButtonAttributes, PrimitiveDivAttributes, PrimitiveHeaderAttributes, @@ -10,10 +11,7 @@ import type { PrimitiveThAttributes, PrimitiveTheadAttrbutes, PrimitiveTrAttributes, - WithChild, - Without, -} from "$lib/internal/types.js"; -import type { DateMatcher, Month, WeekStartsOn } from "$lib/shared/date/types.js"; +} from "$lib/shared/attributes.js"; export type CalendarRootSnippetProps = { months: Month[]; diff --git a/packages/bits-ui/src/lib/bits/checkbox/types.ts b/packages/bits-ui/src/lib/bits/checkbox/types.ts index 335a334bb..7a303d535 100644 --- a/packages/bits-ui/src/lib/bits/checkbox/types.ts +++ b/packages/bits-ui/src/lib/bits/checkbox/types.ts @@ -1,9 +1,5 @@ -import type { - OnChangeFn, - PrimitiveButtonAttributes, - WithChild, - Without, -} from "$lib/internal/index.js"; +import type { OnChangeFn, WithChild, Without } from "$lib/internal/index.js"; +import type { PrimitiveButtonAttributes } from "$lib/shared/attributes.js"; export type CheckboxRootSnippetProps = { checked: boolean | "indeterminate" }; diff --git a/packages/bits-ui/src/lib/bits/collapsible/types.ts b/packages/bits-ui/src/lib/bits/collapsible/types.ts index 9f3c514b8..4d803e942 100644 --- a/packages/bits-ui/src/lib/bits/collapsible/types.ts +++ b/packages/bits-ui/src/lib/bits/collapsible/types.ts @@ -1,10 +1,5 @@ -import type { - OnChangeFn, - PrimitiveButtonAttributes, - PrimitiveDivAttributes, - WithChild, - Without, -} from "$lib/internal/index.js"; +import type { OnChangeFn, WithChild, Without } from "$lib/internal/index.js"; +import type { PrimitiveButtonAttributes, PrimitiveDivAttributes } from "$lib/shared/attributes.js"; export type CollapsibleRootPropsWithoutHTML = WithChild<{ /** diff --git a/packages/bits-ui/src/lib/bits/combobox/components/combobox-content.svelte b/packages/bits-ui/src/lib/bits/combobox/components/combobox-content.svelte index c70aec477..30f754001 100644 --- a/packages/bits-ui/src/lib/bits/combobox/components/combobox-content.svelte +++ b/packages/bits-ui/src/lib/bits/combobox/components/combobox-content.svelte @@ -71,7 +71,7 @@ }, })} {#if child} - {@render child?.({ props: finalProps })} + {@render child({ props: finalProps })} {:else}
{@render children?.()} diff --git a/packages/bits-ui/src/lib/bits/combobox/components/combobox-group-label.svelte b/packages/bits-ui/src/lib/bits/combobox/components/combobox-group-label.svelte index 252854267..c3a810f2c 100644 --- a/packages/bits-ui/src/lib/bits/combobox/components/combobox-group-label.svelte +++ b/packages/bits-ui/src/lib/bits/combobox/components/combobox-group-label.svelte @@ -25,7 +25,7 @@ {#if child} - {@render child?.({ props: mergedProps })} + {@render child({ props: mergedProps })} {:else}
{@render children?.()} diff --git a/packages/bits-ui/src/lib/bits/combobox/components/combobox-group.svelte b/packages/bits-ui/src/lib/bits/combobox/components/combobox-group.svelte index c900e3ab0..e76efc9bd 100644 --- a/packages/bits-ui/src/lib/bits/combobox/components/combobox-group.svelte +++ b/packages/bits-ui/src/lib/bits/combobox/components/combobox-group.svelte @@ -25,7 +25,7 @@ {#if child} - {@render child?.({ props: mergedProps })} + {@render child({ props: mergedProps })} {:else}
{@render children?.()} diff --git a/packages/bits-ui/src/lib/bits/combobox/types.ts b/packages/bits-ui/src/lib/bits/combobox/types.ts index f0d82dea6..c322cf380 100644 --- a/packages/bits-ui/src/lib/bits/combobox/types.ts +++ b/packages/bits-ui/src/lib/bits/combobox/types.ts @@ -1,12 +1,9 @@ +import type { OnChangeFn, WithChild, WithChildren, Without } from "$lib/internal/types.js"; import type { - OnChangeFn, PrimitiveButtonAttributes, PrimitiveDivAttributes, PrimitiveInputAttributes, - WithChild, - WithChildren, - Without, -} from "$lib/internal/types.js"; +} from "$lib/shared/attributes.js"; import type { PortalProps } from "../utilities/portal/types.js"; import type { PopperLayerProps } from "../utilities/popper-layer/types.js"; import type { ArrowProps, ArrowPropsWithoutHTML } from "../utilities/arrow/types.js"; diff --git a/packages/bits-ui/src/lib/bits/context-menu/types.ts b/packages/bits-ui/src/lib/bits/context-menu/types.ts index ba3834d82..3c2a8a20b 100644 --- a/packages/bits-ui/src/lib/bits/context-menu/types.ts +++ b/packages/bits-ui/src/lib/bits/context-menu/types.ts @@ -1,5 +1,6 @@ import type { MenuContentProps, MenuContentPropsWithoutHTML } from "../menu/types.js"; -import type { PrimitiveDivAttributes, WithChild, Without } from "$lib/internal/types.js"; +import type { WithChild, Without } from "$lib/internal/types.js"; +import type { PrimitiveDivAttributes } from "$lib/shared/attributes.js"; export type ContextMenuContentPropsWithoutHTML = MenuContentPropsWithoutHTML; diff --git a/packages/bits-ui/src/lib/bits/date-field/types.ts b/packages/bits-ui/src/lib/bits/date-field/types.ts index da70f22c5..6e164319e 100644 --- a/packages/bits-ui/src/lib/bits/date-field/types.ts +++ b/packages/bits-ui/src/lib/bits/date-field/types.ts @@ -1,13 +1,8 @@ import type { DateValue } from "@internationalized/date"; import type { SegmentPart } from "$lib/shared/index.js"; import type { Snippet } from "svelte"; -import type { - OnChangeFn, - PrimitiveDivAttributes, - PrimitiveSpanAttributes, - WithChild, - Without, -} from "$lib/internal/types.js"; +import type { OnChangeFn, WithChild, Without } from "$lib/internal/types.js"; +import type { PrimitiveDivAttributes, PrimitiveSpanAttributes } from "$lib/shared/attributes.js"; import type { EditableSegmentPart } from "$lib/shared/date/field/types.js"; import type { DateMatcher, Granularity } from "$lib/shared/date/types.js"; diff --git a/packages/bits-ui/src/lib/bits/date-picker/components/date-picker-calendar.svelte b/packages/bits-ui/src/lib/bits/date-picker/components/date-picker-calendar.svelte index 98284cfb4..354293c43 100644 --- a/packages/bits-ui/src/lib/bits/date-picker/components/date-picker-calendar.svelte +++ b/packages/bits-ui/src/lib/bits/date-picker/components/date-picker-calendar.svelte @@ -47,7 +47,7 @@ {#if child} - {@render child?.({ props: mergedProps, ...calendarState.snippetProps })} + {@render child({ props: mergedProps, ...calendarState.snippetProps })} {:else}
{@render children?.(calendarState.snippetProps)} diff --git a/packages/bits-ui/src/lib/bits/date-picker/types.ts b/packages/bits-ui/src/lib/bits/date-picker/types.ts index 34c9b77e3..cbd18129f 100644 --- a/packages/bits-ui/src/lib/bits/date-picker/types.ts +++ b/packages/bits-ui/src/lib/bits/date-picker/types.ts @@ -1,11 +1,6 @@ import type { DateValue } from "@internationalized/date"; -import type { - OnChangeFn, - PrimitiveDivAttributes, - WithChild, - WithChildren, - Without, -} from "$lib/internal/types.js"; +import type { OnChangeFn, WithChild, WithChildren, Without } from "$lib/internal/types.js"; +import type { PrimitiveDivAttributes } from "$lib/shared/attributes.js"; import type { EditableSegmentPart } from "$lib/shared/date/field/types.js"; import type { DateMatcher, Granularity, WeekStartsOn } from "$lib/shared/date/types.js"; import type { CalendarRootSnippetProps } from "$lib/types.js"; diff --git a/packages/bits-ui/src/lib/bits/date-range-field/types.ts b/packages/bits-ui/src/lib/bits/date-range-field/types.ts index b5e895e21..4eb82035f 100644 --- a/packages/bits-ui/src/lib/bits/date-range-field/types.ts +++ b/packages/bits-ui/src/lib/bits/date-range-field/types.ts @@ -1,11 +1,6 @@ import type { DateValue } from "@internationalized/date"; -import type { - OnChangeFn, - PrimitiveDivAttributes, - PrimitiveSpanAttributes, - WithChild, - Without, -} from "$lib/internal/types.js"; +import type { OnChangeFn, WithChild, Without } from "$lib/internal/types.js"; +import type { PrimitiveDivAttributes, PrimitiveSpanAttributes } from "$lib/shared/attributes.js"; import type { DateMatcher, Granularity } from "$lib/shared/date/types.js"; import type { DateRange, EditableSegmentPart, SegmentPart } from "$lib/shared/index.js"; import type { DateFieldSegmentProps, DateFieldSegmentPropsWithoutHTML } from "$lib/types.js"; diff --git a/packages/bits-ui/src/lib/bits/date-range-picker/components/date-range-picker-calendar.svelte b/packages/bits-ui/src/lib/bits/date-range-picker/components/date-range-picker-calendar.svelte index 7d5e846b1..d20639300 100644 --- a/packages/bits-ui/src/lib/bits/date-range-picker/components/date-range-picker-calendar.svelte +++ b/packages/bits-ui/src/lib/bits/date-range-picker/components/date-range-picker-calendar.svelte @@ -48,7 +48,7 @@ {#if child} - {@render child?.({ props: mergedProps, ...rangeCalendarState.snippetProps })} + {@render child({ props: mergedProps, ...rangeCalendarState.snippetProps })} {:else}
{@render children?.(rangeCalendarState.snippetProps)} diff --git a/packages/bits-ui/src/lib/bits/date-range-picker/components/date-range-picker.svelte b/packages/bits-ui/src/lib/bits/date-range-picker/components/date-range-picker.svelte index 19ecc64c5..34e63e271 100644 --- a/packages/bits-ui/src/lib/bits/date-range-picker/components/date-range-picker.svelte +++ b/packages/bits-ui/src/lib/bits/date-range-picker/components/date-range-picker.svelte @@ -167,7 +167,7 @@ {#if child} - {@render child?.({ props: mergedProps })} + {@render child({ props: mergedProps })} {:else}
{@render children?.()} diff --git a/packages/bits-ui/src/lib/bits/date-range-picker/types.ts b/packages/bits-ui/src/lib/bits/date-range-picker/types.ts index dcef60a4f..9bdda241d 100644 --- a/packages/bits-ui/src/lib/bits/date-range-picker/types.ts +++ b/packages/bits-ui/src/lib/bits/date-range-picker/types.ts @@ -1,10 +1,6 @@ import type { DateValue } from "@internationalized/date"; -import type { - OnChangeFn, - PrimitiveDivAttributes, - WithChild, - Without, -} from "$lib/internal/types.js"; +import type { OnChangeFn, WithChild, Without } from "$lib/internal/types.js"; +import type { PrimitiveDivAttributes } from "$lib/shared/attributes.js"; import type { EditableSegmentPart } from "$lib/shared/date/field/types.js"; import type { DateMatcher, Granularity, WeekStartsOn } from "$lib/shared/date/types.js"; import type { DateRange } from "$lib/shared/index.js"; diff --git a/packages/bits-ui/src/lib/bits/dialog/components/dialog-close.svelte b/packages/bits-ui/src/lib/bits/dialog/components/dialog-close.svelte index a9c30b8f9..be9c6c538 100644 --- a/packages/bits-ui/src/lib/bits/dialog/components/dialog-close.svelte +++ b/packages/bits-ui/src/lib/bits/dialog/components/dialog-close.svelte @@ -25,7 +25,7 @@ {#if child} - {@render child?.({ props: mergedProps })} + {@render child({ props: mergedProps })} {:else}