fix: silence state_referenced_locally in vendored ui components

This commit is contained in:
2026-08-11 20:08:53 -04:00
parent ef8e5e7fba
commit 6366582498
4 changed files with 23 additions and 9 deletions
@@ -3,6 +3,7 @@
--> -->
<script lang="ts"> <script lang="ts">
import { untrack } from 'svelte';
import { cn } from '$lib/utils'; import { cn } from '$lib/utils';
import UploadIcon from '@lucide/svelte/icons/upload'; import UploadIcon from '@lucide/svelte/icons/upload';
import { displaySize } from '.'; import { displaySize } from '.';
@@ -26,11 +27,14 @@
...rest ...rest
}: FileDropZoneProps = $props(); }: FileDropZoneProps = $props();
// A one-off sanity check at init, not a reactive concern.
untrack(() => {
if (maxFiles !== undefined && fileCount === undefined) { if (maxFiles !== undefined && fileCount === undefined) {
console.warn( console.warn(
'Make sure to provide FileDropZone with `fileCount` when using the `maxFiles` prompt' 'Make sure to provide FileDropZone with `fileCount` when using the `maxFiles` prompt'
); );
} }
});
let uploading = $state(false); let uploading = $state(false);
@@ -9,6 +9,7 @@
SIDEBAR_WIDTH_ICON SIDEBAR_WIDTH_ICON
} from './constants.js'; } from './constants.js';
import { setSidebar } from './context.svelte.js'; import { setSidebar } from './context.svelte.js';
import { untrack } from 'svelte';
let { let {
ref = $bindable(null), ref = $bindable(null),
@@ -36,7 +37,7 @@
// This sets the cookie to keep the sidebar state. // This sets the cookie to keep the sidebar state.
document.cookie = `${SIDEBAR_COOKIE_NAME}_${contextKey}=${open}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`; document.cookie = `${SIDEBAR_COOKIE_NAME}_${contextKey}=${open}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`;
}, },
contextKey: contextKey contextKey: untrack(() => contextKey)
}); });
</script> </script>
@@ -2,6 +2,7 @@
import { cn, type WithElementRef } from '$lib/utils.js'; import { cn, type WithElementRef } from '$lib/utils.js';
import type { HTMLAttributes } from 'svelte/elements'; import type { HTMLAttributes } from 'svelte/elements';
import { useSidebar } from './context.svelte.js'; import { useSidebar } from './context.svelte.js';
import { untrack } from 'svelte';
let { let {
ref = $bindable(null), ref = $bindable(null),
@@ -13,7 +14,8 @@
contextKey?: string; contextKey?: string;
} = $props(); } = $props();
const sidebar = useSidebar(contextKey); // contextKey selects which sidebar this rail drives; fixed per instance.
const sidebar = useSidebar(untrack(() => contextKey));
</script> </script>
<button <button
@@ -23,9 +23,16 @@
...restProps ...restProps
}: ToggleGroupPrimitive.RootProps & ToggleVariants = $props(); }: ToggleGroupPrimitive.RootProps & ToggleVariants = $props();
// Getters rather than values: consumers read `ctx.variant` / `ctx.size` as
// plain properties, so this stays source-compatible while making the props
// actually reactive — passing them by value captured the initial ones.
setToggleGroupCtx({ setToggleGroupCtx({
variant, get variant() {
size return variant;
},
get size() {
return size;
}
}); });
</script> </script>