fix: bind inspector props to resolve ownership_invalid_mutation warnings

This commit is contained in:
HorizonCode committed 2026-10-31 12:36:27 +01:00
1 parent 4dc6cb1721
commit e3abea8d83
4 files changed
+35 -23

No files matched your search

@@ -34,7 +34,7 @@
import { SvelteSet } from 'svelte/reactivity'; import { SvelteSet } from 'svelte/reactivity';
let { let {
behavior, behavior = $bindable(),
elements, elements,
groups = [], groups = [],
variables = [], variables = [],
@@ -335,12 +335,22 @@
...themeScriptInitialVariables(definition), ...themeScriptInitialVariables(definition),
...themeClockValues(new Date(previewClock)), ...themeClockValues(new Date(previewClock)),
}); });
const selectedGroupIndex = $derived(
selectedGroupId
? (definition.groups ?? []).findIndex((group) => group.id === selectedGroupId)
: -1
);
const selectedGroup = $derived( const selectedGroup = $derived(
selectedGroupId ? groups.find((group) => group.id === selectedGroupId) : undefined selectedGroupIndex >= 0 && definition.groups ? definition.groups[selectedGroupIndex] : undefined
);
const selectedBehaviorIndex = $derived(
selectedBehaviorId
? (definition.behaviors ?? []).findIndex((behavior) => behavior.id === selectedBehaviorId)
: -1
); );
const selectedBehavior = $derived( const selectedBehavior = $derived(
selectedBehaviorId selectedBehaviorIndex >= 0 && definition.behaviors
? behaviors.find((behavior) => behavior.id === selectedBehaviorId) ? definition.behaviors[selectedBehaviorIndex]
: undefined : undefined
); );
function buildLayerRows(includeCollapsed: boolean): LayerRow[] { function buildLayerRows(includeCollapsed: boolean): LayerRow[] {
@@ -5114,10 +5124,10 @@
<aside class="flex min-h-0 flex-col border-l border-theme-800 bg-theme-900/35"> <aside class="flex min-h-0 flex-col border-l border-theme-800 bg-theme-900/35">
{#if leftTab === 'logic'} {#if leftTab === 'logic'}
{#if selectedBehavior} {#if selectedBehavior && selectedBehaviorIndex >= 0 && definition.behaviors}
<div class="min-h-0 flex-1 overflow-y-auto"> <div class="min-h-0 flex-1 overflow-y-auto">
<ThemeBehaviorInspector <ThemeBehaviorInspector
behavior={selectedBehavior} bind:behavior={definition.behaviors[selectedBehaviorIndex]}
{elements} {elements}
{groups} {groups}
variables={scriptVariables} variables={scriptVariables}
@@ -5310,20 +5320,22 @@
</Button> </Button>
</div> </div>
<div class="min-h-0 flex-1 overflow-y-auto"> <div class="min-h-0 flex-1 overflow-y-auto">
<ThemeGroupInspector {#if selectedGroupIndex >= 0 && definition.groups}
group={selectedGroup} <ThemeGroupInspector
{behaviors} bind:group={definition.groups[selectedGroupIndex]}
{elements} {behaviors}
{groups} {elements}
variables={scriptVariables} {groups}
focusToken={logicFocusKey === `group:${selectedGroup.id}` ? logicFocusToken : 0} variables={scriptVariables}
onungroup={() => ungroupGroup()} focusToken={logicFocusKey === `group:${selectedGroup.id}` ? logicFocusToken : 0}
onpickmask={pickGroupMask} onungroup={() => ungroupGroup()}
onaddbehavior={createBehavior} onpickmask={pickGroupMask}
ondeleterule={deleteBehavior} onaddbehavior={createBehavior}
/> ondeleterule={deleteBehavior}
/>
{/if}
</div> </div>
{:else if selectedElement} {:else if selectedElement && selectedIndex >= 0 && definition.elements}
<div class="flex shrink-0 items-center gap-1 border-b border-theme-800 p-2"> <div class="flex shrink-0 items-center gap-1 border-b border-theme-800 p-2">
<Button <Button
variant="secondary" variant="secondary"
@@ -5366,7 +5378,7 @@
</div> </div>
<div class="min-h-0 flex-1 overflow-y-auto"> <div class="min-h-0 flex-1 overflow-y-auto">
<ThemeElementInspector <ThemeElementInspector
element={selectedElement} bind:element={definition.elements[selectedIndex]}
{fontOptions} {fontOptions}
{elements} {elements}
{behaviors} {behaviors}
@@ -43,7 +43,7 @@
} from '@lucide/svelte'; } from '@lucide/svelte';
let { let {
element, element = $bindable(),
fontOptions, fontOptions,
elements, elements,
behaviors, behaviors,
@@ -8,8 +8,8 @@
import { Checkbox } from '$lib/components/ui/checkbox'; import { Checkbox } from '$lib/components/ui/checkbox';
import Input from '$lib/components/ui/input/input.svelte'; import Input from '$lib/components/ui/input/input.svelte';
import Label from '$lib/components/ui/label/label.svelte'; import Label from '$lib/components/ui/label/label.svelte';
import Slider from '$lib/components/ui/slider/slider.svelte';
import * as Select from '$lib/components/ui/select'; import * as Select from '$lib/components/ui/select';
import Slider from '$lib/components/ui/slider/slider.svelte';
import { import {
type ThemeV2Behavior, type ThemeV2Behavior,
type ThemeV2BehaviorTarget, type ThemeV2BehaviorTarget,
@@ -20,7 +20,7 @@
import { Boxes, RefreshCw, Ungroup } from '@lucide/svelte'; import { Boxes, RefreshCw, Ungroup } from '@lucide/svelte';
let { let {
group, group = $bindable(),
behaviors, behaviors,
elements, elements,
groups, groups,