42 lines
1.9 KiB
Vue
42 lines
1.9 KiB
Vue
<script setup lang="ts">
|
|
import { tableMarkdown } from '~/lib/logic/analyze'
|
|
|
|
const ed = useEditor()
|
|
const close = () => (ed.dialog.value = null)
|
|
|
|
const table = computed(() => {
|
|
void ed.sim.value
|
|
return ed.table()
|
|
})
|
|
</script>
|
|
|
|
<template>
|
|
<div class="modal-backdrop" @click.self="close">
|
|
<div class="modal table-modal" role="dialog" aria-labelledby="table-title">
|
|
<div class="flex items-start justify-between gap-4">
|
|
<div>
|
|
<h2 id="table-title">Truth table: {{ ed.def.value.name }}</h2>
|
|
<p v-if="!('error' in table)" class="hint mt-1">
|
|
{{ table.inputs.length }} input{{ table.inputs.length === 1 ? '' : 's' }}, {{ table.outputs.length }} output{{ table.outputs.length === 1 ? '' : 's' }},
|
|
{{ table.rows.length }} rows. The highlighted row is what the switches are set to now.
|
|
</p>
|
|
</div>
|
|
<div class="flex shrink-0 items-center gap-2">
|
|
<template v-if="!('error' in table)">
|
|
<button class="btn" title="Download as CSV, for spreadsheets" @click="ed.exportTable(table)"><Icon name="lucide:download" class="size-4" /> CSV</button>
|
|
<button class="btn" title="Copy as a Markdown table (pastes as plain text too)" @click="ed.copyText(tableMarkdown(table), 'Truth table copied')">
|
|
<Icon name="lucide:clipboard-copy" class="size-4" /> Copy
|
|
</button>
|
|
</template>
|
|
<button class="tb-btn" title="Close" @click="close"><Icon name="lucide:x" class="size-4" /></button>
|
|
</div>
|
|
</div>
|
|
<p v-if="'error' in table" class="hint">{{ table.error }}</p>
|
|
<template v-else>
|
|
<p v-if="ed.circuitStats.value.sequential" class="hint">This circuit stores state, so the table depends on the order the rows are tried in.</p>
|
|
<EditorTruthTable :table="table" large />
|
|
</template>
|
|
</div>
|
|
</div>
|
|
</template>
|