From c9bd155ed654a1eb599f2b69e73a5c22a2a5824c Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Mon, 15 Sep 2025 04:08:11 -0700 Subject: [PATCH] Update unit components with editing context --- src/lib/components/units/CharacterUnit.svelte | 198 ++++++++++----- src/lib/components/units/SummonUnit.svelte | 226 +++++++++++++----- src/lib/components/units/WeaponUnit.svelte | 208 +++++++++++----- 3 files changed, 455 insertions(+), 177 deletions(-) diff --git a/src/lib/components/units/CharacterUnit.svelte b/src/lib/components/units/CharacterUnit.svelte index 334daec3..8eb5dc0c 100644 --- a/src/lib/components/units/CharacterUnit.svelte +++ b/src/lib/components/units/CharacterUnit.svelte @@ -1,16 +1,23 @@ -
- {item -
{item ? displayName(item.object) : '—'}
- {#if ctx.canEdit() && !item} - - {/if} - {#if ctx.canEdit() && item?.id} -
- - +
+ {#key (item ? (item as any).id ?? position : `empty-${position}`)} +
ctx?.openPicker && ctx.openPicker({ type: 'character', position, item })} + > + {item + {#if !item && ctx?.canEdit()} + + + + {/if} + {#if ctx.canEdit() && item?.id} +
+ +
+ {/if}
- {/if} - {#if ctx.canEdit() && item?.id} - - {/if} + {/key} +
{item ? displayName(item?.character || (item as any)?.object) : ''}
diff --git a/src/lib/components/units/SummonUnit.svelte b/src/lib/components/units/SummonUnit.svelte index f36b2537..5c4643bc 100644 --- a/src/lib/components/units/SummonUnit.svelte +++ b/src/lib/components/units/SummonUnit.svelte @@ -1,14 +1,21 @@ -
- {item -
{item ? displayName(item.object) : '—'}
- {#if ctx.canEdit() && !item} - - {/if} - {#if ctx.canEdit() && item?.id} -
- - +
+ {#key (item ? (item as any).id ?? position : `empty-${position}`)} +
ctx?.openPicker && ctx.openPicker({ type: 'summon', position, item })} + > + {item + {#if !item && ctx?.canEdit()} + + + + {/if} + {#if ctx.canEdit() && item?.id} +
+ +
+ {/if} + {#if item?.main || position === -1} + Main + {/if} + {#if item?.friend || position === 6} + Friend + {/if}
- {/if} - {#if ctx.canEdit() && item?.id} - - {/if} - {#if item?.main || position === -1} - Main - {/if} - {#if item?.friend || position === 6} - Friend - {/if} + {/key} +
{item ? displayName(item?.summon || (item as any)?.object) : ''}
diff --git a/src/lib/components/units/WeaponUnit.svelte b/src/lib/components/units/WeaponUnit.svelte index 9d9c9d79..43a2aa05 100644 --- a/src/lib/components/units/WeaponUnit.svelte +++ b/src/lib/components/units/WeaponUnit.svelte @@ -1,14 +1,21 @@ -
- {item -
{item ? displayName(item.object) : '—'}
- {#if ctx.canEdit() && !item} - - {/if} - {#if ctx.canEdit() && item?.id} -
- - +
+ {#key (item ? (item as any).id ?? position : `empty-${position}`)} +
ctx?.openPicker && ctx.openPicker({ type: 'weapon', position, item })} + > + {item + {#if !item && ctx?.canEdit()} + + + + {/if} + {#if ctx.canEdit() && item?.id} +
+ +
+ {/if} + {#if item?.mainhand || position === -1} + Main + {/if}
- {/if} - {#if (item as any)?.mainhand || position === -1} - Main - {/if} + {/key} +
{item ? displayName(item?.weapon || (item as any)?.object) : ''}