@ -9,16 +9,6 @@ const ctx = $derived(sel.kind === 'sec-atts'
? { objId : sel.objId , secId : sel.secId , sec : editor.findSec ( sel . objId , sel . secId ), attId : sel.attId }
: null)
const domainBadge: Record< string , string > = {
string: 'bg-blue-900/40 text-blue-400',
number: 'bg-green-900/40 text-green-400',
currency: 'bg-emerald-900/40 text-emerald-400',
boolean: 'bg-purple-900/40 text-purple-400',
option: 'bg-amber-900/40 text-amber-400',
date: 'bg-rose-900/40 text-rose-400',
time: 'bg-rose-900/40 text-rose-400',
datetime: 'bg-rose-900/40 text-rose-400',
}
let creating = $state(false)
let newAttName = $state('')
@ -75,30 +65,34 @@ function cancelAdd() {
{ : else }
{ #each sec . atts as att ( att . id )}
{ @const isActive = attId === att . id }
< div
role="button" tabindex="0"
< button
onclick={() => editor . select ({ kind : 'sec-atts' , objId , secId , attId : att.id })}
onkeydown={ e => e . key === 'Enter' && editor . select ({ kind : 'sec-atts' , objId , secId , attId : att.id })}
class="px-4 py-2.5 flex items-center gap-2 text-sm cursor-pointer
transition-colors group border-l-2
class="w-full text-left px-4 py-2.5 flex items-center justify-between
cursor-pointer transition-colors border-l-2
{ isActive
? 'bg-indigo-600/20 text-indigo-300 border-indigo -500'
: 'text-gray-400 hover:bg-gray-800 hover:text-gray-200 border-transparent '}"
? 'bg-gray-800 border-blue -500'
: 'border-transparent hover:bg-gray-800 '}"
>
< span class = "text-xs px-1 . 5 py-0 . 5 rounded shrink-0
{ domainBadge [ att . value . domain . kind ] ?? 'bg-gray-800 text-gray-500' } ">
{ att . value . domain . kind . slice ( 0 , 3 ) }
< div class = "flex flex-col gap-0.5 min-w-0" >
< span class = "text-sm truncate { isActive ? 'text-gray-100' : 'text-gray-300' } " >
{ att . name || 'Sin nombre' }
< / span >
< span class = "flex-1 truncate" >
{ #if att . name }{ att . name }{ : else } < span class = "italic text-gray-600" > Sin nombre</ span > { /if }
< span class = "text-xs text-gray-600 font-mono truncate" > { att . id } </ span >
< / div >
< div class = "flex items-center gap-1 shrink-0 ml-2" >
< span class = "text-xs px-1 py-0.5 rounded bg-gray-800 text-gray-500 border border-gray-700" >
{ att . value . domain . kind }
< / span >
{ #if att . rules ? . rules ? . length }
< span class = "w-1.5 h-1.5 rounded-full bg-indigo-500 shrink-0" > < / span >
< span class = " text-xs text-blue-400" title = "Tiene reglas" > ⚡ < / span >
{ /if }
< / div >
< / button >
< div class = "px-4 pb-1 flex justify-end" >
< button
onclick={ e => { e . stopPropagation (); editor . removeAtt ( objId , secId , att . id ) }}
class="opacity-0 group-hover:opacity-100 text-gray-600 hover:text-red-400 transition-opacity text-xs"
>✕ < / button >
onclick={ () => editor . removeAtt ( objId , secId , att . id ) }
class="text-xs text-gray-700 hover:text-red-400 transition-color s"
>eliminar < / button >
< / div >
{ /each }
{ /if }