// Copyright 2020 Blue Static // This program is free software licensed under the GNU General Public License, // version 3.0. The full text of the license can be found in LICENSE.txt. // SPDX-License-Identifier: GPL-3.0-only import { createDependentEffect, createMemo, createState } from 'solid-js'; import { For, Show } from 'solid-js/dom'; import { TaxReturn, Form, Line } from 'ustaxlib/core'; import { getLastTraceList } from 'ustaxlib/core/Trace'; const S = require('./FormView.css'); interface FormProps { tr: TaxReturn; form: Form; } export default function FormView(props: FormProps) { const lines = createMemo(() => { const keys = Object.keys(props.form.lines); keys.sort((a, b) => a.localeCompare(b, undefined, { numeric: true })); return keys.map(k => props.form.lines[k]); }); return ( <>

Form {props.form.name}

{line => }
); } interface LineProps { tr: TaxReturn; line: Line; } function LineView(props: LineProps) { const { tr, line } = props; const value = createMemo(() => { try { return JSON.stringify(line.value(tr), null, 1); } catch (e) { return {e.message}; } }); const [ state, setState ] = createState({ trace: "", showTrace: false }); createDependentEffect(() => setState('trace', JSON.stringify(getLastTraceList(), null, ' ')), [value]); const toggleTrace = () => setState('showTrace', !state.showTrace); return ( {line.id} {line.description} {value()} ); } interface TraceProps { line: Line; trace: string; } function TraceViewer(props: TraceProps) { return (

Trace {props.line.id}

{props.trace}
); }