fix toggle binding in app

This commit is contained in:
Ruben Fiszel
2023-05-25 19:04:02 +02:00
parent c8ff19befd
commit 8bf2ab349c
3 changed files with 17 additions and 24 deletions
+1 -1
View File
@@ -40,6 +40,7 @@
{options?.left}
</span>
{/if}
<!-- svelte-ignore a11y-click-events-have-key-events -->
<div class="relative" on:click|stopPropagation>
<input
@@ -47,7 +48,6 @@
on:click
{disabled}
type="checkbox"
value={false}
{id}
class="sr-only peer"
bind:checked
@@ -72,28 +72,22 @@
$: lastInput && $worldStore && debounce(handleConnection)
$: lastInput &&
lastInput.type == 'template' &&
$stateId &&
$state &&
debounce(async () => {
let nvalue = await getValue(lastInput)
if (!deepEqual(nvalue, value)) {
value = nvalue
}
dispatch('done')
})
const reEvalTemplate = async () => {
let nvalue = await getValue(lastInput)
if (!deepEqual(nvalue, value)) {
value = nvalue
}
}
$: lastInput &&
lastInput.type == 'eval' &&
$stateId &&
$state &&
debounce2(async () => {
let nvalue = await evalExpr(lastInput)
if (!deepEqual(nvalue, value)) {
value = nvalue
}
})
$: lastInput && lastInput.type == 'template' && $stateId && $state && debounce(reEvalTemplate)
const reEval = async () => {
let nvalue = await evalExpr(lastInput)
if (!deepEqual(nvalue, value)) {
value = nvalue
}
}
$: lastInput && lastInput.type == 'eval' && $stateId && $state && debounce2(reEval)
async function handleConnection() {
if (lastInput?.type === 'connected') {
@@ -57,11 +57,10 @@
{/each}
<InitializeComponent {id} />
<AlignWrapper {render} {horizontalAlignment} {verticalAlignment}>
<Toggle
size="sm"
checked={resolvedConfig.defaultValue}
bind:checked={resolvedConfig.defaultValue}
options={{ right: resolvedConfig.label }}
textClass={css?.text?.class ?? ''}
textStyle={css?.text?.style ?? ''}