Skip to content

Commit

Permalink
next: update svelte and cleanup (#577)
Browse files Browse the repository at this point in the history
  • Loading branch information
huntabyte authored Jun 17, 2024
1 parent b136913 commit 2a506ba
Show file tree
Hide file tree
Showing 54 changed files with 878 additions and 521 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"prettier": "^3.2.5",
"prettier-plugin-svelte": "^3.2.2",
"prettier-plugin-tailwindcss": "0.5.13",
"svelte": "5.0.0-next.143",
"svelte": "^5.0.0-next.157",
"svelte-eslint-parser": "^0.34.1",
"wrangler": "^3.44.0"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/bits-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"jsdom": "^24.0.0",
"publint": "^0.2.7",
"resize-observer-polyfill": "^1.5.1",
"svelte": "5.0.0-next.143",
"svelte": "5.0.0-next.157",
"svelte-check": "^3.6.9",
"tslib": "^2.6.2",
"typescript": "^5.3.3",
Expand Down
3 changes: 1 addition & 2 deletions packages/bits-ui/src/lib/bits/dialog/dialog.svelte.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { box } from "svelte-toolbelt";
import { getAriaExpanded, getDataOpenClosed } from "$lib/internal/attrs.js";
import type { ReadableBoxedValues, WritableBoxedValues } from "$lib/internal/box.svelte.js";
import { useRefById } from "$lib/internal/useNodeById.svelte.js";
import { useRefById } from "$lib/internal/useRefById.svelte.js";
import { createContext } from "$lib/internal/createContext.js";
import type { WithRefProps } from "$lib/internal/types.js";

Expand Down
2 changes: 1 addition & 1 deletion packages/bits-ui/src/lib/bits/label/label.svelte.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { WithRefProps } from "$lib/internal/types.js";
import { useRefById } from "$lib/internal/useNodeById.svelte.js";
import { useRefById } from "$lib/internal/useRefById.svelte.js";

const ROOT_ATTR = "data-label-root";

Expand Down
2 changes: 1 addition & 1 deletion packages/bits-ui/src/lib/bits/menu/menu.svelte.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import { mergeProps } from "$lib/internal/mergeProps.js";
import { createContext } from "$lib/internal/createContext.js";
import type { Direction } from "$lib/shared/index.js";
import { afterTick } from "$lib/internal/afterTick.js";
import { useRefById } from "$lib/internal/useNodeById.svelte.js";
import { useRefById } from "$lib/internal/useRefById.svelte.js";
import { isPointerInGraceArea, makeHullFromElements } from "$lib/internal/polygon.js";

const TRIGGER_ATTR = "data-menu-trigger";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { useId } from "$lib/internal/useId.svelte.js";
import { kbd } from "$lib/internal/kbd.js";
import { useArrowNavigation } from "$lib/internal/useArrowNavigation.js";
import { boxAutoReset } from "$lib/internal/boxAutoReset.svelte.js";
import { useRefById } from "$lib/internal/useNodeById.svelte.js";
import { useRefById } from "$lib/internal/useRefById.svelte.js";
import type { ElementRef } from "$lib/internal/types.js";
import { afterTick } from "$lib/internal/afterTick.js";
import { getTabbableCandidates } from "../utilities/focus-scope/utils.js";
Expand Down
2 changes: 1 addition & 1 deletion packages/bits-ui/src/lib/bits/popover/popover.svelte.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { box } from "svelte-toolbelt";
import type { ReadableBoxedValues, WritableBoxedValues } from "$lib/internal/box.svelte.js";
import { useRefById } from "$lib/internal/useNodeById.svelte.js";
import { useRefById } from "$lib/internal/useRefById.svelte.js";
import { kbd } from "$lib/internal/kbd.js";
import { getAriaExpanded, getDataOpenClosed } from "$lib/internal/attrs.js";
import { createContext } from "$lib/internal/createContext.js";
Expand Down
2 changes: 1 addition & 1 deletion packages/bits-ui/src/lib/bits/progress/progress.svelte.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { ReadableBoxedValues } from "$lib/internal/box.svelte.js";
import type { WithRefProps } from "$lib/internal/types.js";
import { useRefById } from "$lib/internal/useNodeById.svelte.js";
import { useRefById } from "$lib/internal/useRefById.svelte.js";

const ROOT_ATTR = "data-progress-root";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,20 @@
import { useSelectArrow } from "../select.svelte.js";
import { FloatingLayer } from "$lib/bits/utilities/floating-layer/index.js";
import { mergeProps } from "$lib/internal/mergeProps.js";
import { useId } from "$lib/internal/useId.svelte.js";
import { box } from "svelte-toolbelt";
let { ref = $bindable(), ...restProps }: ArrowProps = $props();
let { id = useId(), ref = $bindable(null), ...restProps }: ArrowProps = $props();
const arrowState = useSelectArrow();
const arrowState = useSelectArrow({
id: box.with(() => id),
ref: box.with(
() => ref,
(v) => (ref = v)
),
});
const mergedProps = $derived(mergeProps(restProps, arrowState.props as any));
</script>

<FloatingLayer.Arrow bind:ref {...mergedProps} />
<FloatingLayer.Arrow {...mergedProps} />
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
child,
align = "start",
collisionPadding = CONTENT_MARGIN,
ref = $bindable(),
enabled = false,
...restProps
}: WithoutChildren<PopperLayerImplProps> &
Expand All @@ -32,7 +31,7 @@
{#if asChild}
{@render child?.({ props: finalProps })}
{:else}
<div {...finalProps} bind:this={ref}>
<div {...finalProps}>
{@render children?.()}
</div>
{/if}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,12 @@
<SelectContentFloating
{...restProps}
{...mergedProps}
bind:ref
onPlaced={() => (contentState.isPositioned.value = true)}
/>
{:else}
<SelectContentItemAligned
{...restProps}
{...mergedProps}
bind:ref
onPlaced={() => (contentState.isPositioned.value = true)}
/>
{/if}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
child,
children,
asChild,
ref = $bindable(),
preventScroll = true,
onPlaced,
...restProps
Expand All @@ -32,7 +31,7 @@
{#if asChild}
{@render child?.({ props: mergedProps })}
{:else}
<div bind:this={ref} {...mergedProps}>
<div {...mergedProps}>
{@render children?.()}
</div>
{/if}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,21 @@
let {
id = useId(),
ref = $bindable(),
ref = $bindable(null),
forceMount = false,
position = "floating",
...restProps
}: ContentProps = $props();
const contentState = useSelectContentFrag({ id: box.with(() => id) });
const contentState = useSelectContentFrag();
const contentContext = useSelectContent({
id: box.with(() => id),
position: box.with(() => position),
ref: box.with(
() => ref,
(v) => (ref = v)
),
});
const isPresent = $derived(contentState.root.open.value || forceMount);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@
asChild,
children,
child,
ref = $bindable(),
ref = $bindable(null),
id = useId(),
...restProps
}: GroupLabelProps = $props();
const groupLabelState = useSelectGroupLabel({
id: box.with(() => id),
ref: box.with(
() => ref,
(v) => (ref = v)
),
});
const mergedProps = $derived(mergeProps(restProps, groupLabelState.props));
Expand All @@ -24,7 +28,7 @@
{#if asChild}
{@render child?.({ props: mergedProps })}
{:else}
<div {...mergedProps} bind:this={ref}>
<div {...mergedProps}>
{@render children?.()}
</div>
{/if}
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,32 @@
import type { GroupProps } from "../index.js";
import { useSelectGroup } from "../select.svelte.js";
import { mergeProps } from "$lib/internal/mergeProps.js";
import { useId } from "$lib/internal/useId.svelte.js";
import { box } from "svelte-toolbelt";
let { asChild, children, child, ref = $bindable(), ...restProps }: GroupProps = $props();
let {
asChild,
children,
child,
id = useId(),
ref = $bindable(null),
...restProps
}: GroupProps = $props();
const groupState = useSelectGroup();
const groupState = useSelectGroup({
id: box.with(() => id),
ref: box.with(
() => ref,
(v) => (ref = v)
),
});
const mergedProps = $derived(mergeProps(restProps, groupState.props));
</script>

{#if asChild}
{@render child?.({ props: mergedProps })}
{:else}
<div {...mergedProps} bind:this={ref}>
<div {...mergedProps}>
{@render children?.()}
</div>
{/if}
19 changes: 17 additions & 2 deletions packages/bits-ui/src/lib/bits/select/components/select-icon.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,25 @@
import type { IconProps } from "../index.js";
import { useSelectIcon } from "../select.svelte.js";
import { mergeProps } from "$lib/internal/mergeProps.js";
import { useId } from "$lib/internal/useId.svelte.js";
import { box } from "svelte-toolbelt";
let { asChild, children, child, ref = $bindable(), ...restProps }: IconProps = $props();
let {
asChild,
children,
child,
id = useId(),
ref = $bindable(null),
...restProps
}: IconProps = $props();
const iconState = useSelectIcon();
const iconState = useSelectIcon({
id: box.with(() => id),
ref: box.with(
() => ref,
(v) => (ref = v)
),
});
const mergedProps = $derived(mergeProps(restProps, iconState.props));
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
let {
id = useId(),
ref = $bindable(),
ref = $bindable(null),
asChild,
children,
child,
Expand All @@ -17,6 +17,10 @@
const itemTextState = useSelectItemText({
id: box.with(() => id),
ref: box.with(
() => ref,
(v) => (ref = v)
),
});
const mergedProps = $derived(mergeProps(restProps, itemTextState.props));
Expand All @@ -31,7 +35,7 @@
{#if asChild}
{@render child?.({ props: mergedProps })}
{:else}
<span {...mergedProps} bind:this={ref}>
<span {...mergedProps}>
{@render children?.()}
</span>
{/if}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
id = useId(),
value,
textValue = "",
ref = $bindable(),
ref = $bindable(null),
asChild,
children,
child,
Expand All @@ -22,6 +22,10 @@
disabled: box.with(() => disabled),
value: box.with(() => value),
textValue: box.with(() => textValue),
ref: box.with(
() => ref,
(v) => (ref = v)
),
});
const mergedProps = $derived(mergeProps(restProps, itemState.props));
Expand All @@ -30,7 +34,7 @@
{#if asChild}
{@render child?.({ props: mergedProps, selected: itemState.isSelected })}
{:else}
<div bind:this={ref} {...mergedProps}>
<div {...mergedProps}>
{@render children?.({ selected: itemState.isSelected })}
</div>
{/if}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
asChild,
children,
child,
ref = $bindable(),
mounted,
...restProps
}: ScrollDownButtonProps & {
Expand All @@ -29,7 +28,7 @@
{#if asChild}
{@render child?.({ props: restProps })}
{:else}
<div {...restProps} bind:this={ref}>
<div {...restProps}>
{@render children?.()}
</div>
{/if}
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@
import { useId } from "$lib/internal/useId.svelte.js";
import { mergeProps } from "$lib/internal/mergeProps.js";
let { id = useId(), ref = $bindable(), ...restProps }: ScrollUpButtonProps = $props();
let { id = useId(), ref = $bindable(null), ...restProps }: ScrollUpButtonProps = $props();
const mounted = box(false);
const scrollDownButtonState = useSelectScrollDownButton({
id: box.with(() => id),
mounted: box.from(mounted),
ref: box.with(
() => ref,
(v) => (ref = v)
),
});
// eslint-disable-next-line unused-imports/no-unused-vars, ts/no-unused-vars
Expand All @@ -23,5 +27,5 @@
</script>

{#if scrollDownButtonState.canScrollDown}
<SelectScrollDownButtonMounted bind:ref {mounted} {...restWithoutStyle} {...mergedProps} />
<SelectScrollDownButtonMounted {mounted} {...restWithoutStyle} {...mergedProps} />
{/if}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
asChild,
children,
child,
ref = $bindable(),
mounted,
...restProps
}: ScrollUpButtonProps & {
Expand All @@ -29,7 +28,7 @@
{#if asChild}
{@render child?.({ props: restProps })}
{:else}
<div {...restProps} bind:this={ref}>
<div {...restProps}>
{@render children?.()}
</div>
{/if}
Loading

0 comments on commit 2a506ba

Please sign in to comment.