2021-04-12 06:18:30 +02:00
|
|
|
<!--
|
|
|
|
Copyright: Ankitects Pty Ltd and contributors
|
|
|
|
License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|
|
|
-->
|
|
|
|
<script lang="ts">
|
2021-05-16 13:41:40 +02:00
|
|
|
import marked from "marked";
|
2021-04-25 13:10:53 +02:00
|
|
|
import { slide } from "svelte/transition";
|
2021-04-25 10:31:13 +02:00
|
|
|
import RevertButton from "./RevertButton.svelte";
|
2021-04-22 07:39:50 +02:00
|
|
|
import HelpPopup from "./HelpPopup.svelte";
|
2021-04-12 06:18:30 +02:00
|
|
|
|
|
|
|
export let label: string;
|
2021-04-25 13:37:21 +02:00
|
|
|
export let tooltip = "";
|
2021-04-12 06:18:30 +02:00
|
|
|
export let value: any;
|
|
|
|
export let defaultValue: any;
|
2021-04-17 14:53:47 +02:00
|
|
|
/// empty strings will be ignored
|
|
|
|
export let warnings: string[] = [];
|
2021-04-22 08:47:10 +02:00
|
|
|
export let wholeLine = false;
|
2021-04-26 15:34:33 +02:00
|
|
|
export let id: string | undefined = undefined;
|
2021-05-16 13:41:40 +02:00
|
|
|
|
|
|
|
let renderedTooltip: string;
|
|
|
|
$: renderedTooltip = marked(tooltip);
|
2021-04-12 06:18:30 +02:00
|
|
|
</script>
|
|
|
|
|
2021-05-26 01:21:33 +02:00
|
|
|
<div {id} class="outer">
|
|
|
|
{#if label}
|
|
|
|
<div class="table">
|
|
|
|
<span class="vcenter">
|
|
|
|
{label}
|
|
|
|
{#if renderedTooltip}
|
|
|
|
<HelpPopup html={renderedTooltip} />
|
|
|
|
{/if}
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
{/if}
|
|
|
|
|
|
|
|
<div class="input-grid" class:full-grid-width={wholeLine}>
|
|
|
|
<slot />
|
|
|
|
<RevertButton bind:value {defaultValue} on:revert />
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="full-grid-width">
|
|
|
|
{#each warnings as warning}
|
|
|
|
{#if warning}
|
|
|
|
<div class="alert alert-warning" in:slide out:slide>{warning}</div>
|
|
|
|
{/if}
|
|
|
|
{/each}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2021-04-12 06:18:30 +02:00
|
|
|
<style lang="scss">
|
|
|
|
.outer {
|
2021-04-22 07:39:50 +02:00
|
|
|
display: grid;
|
2021-05-19 09:18:28 +02:00
|
|
|
grid-template-columns: 7fr 3fr;
|
2021-04-22 10:11:27 +02:00
|
|
|
grid-row-gap: 0.5em;
|
2021-04-12 06:18:30 +02:00
|
|
|
}
|
|
|
|
|
2021-04-22 07:39:50 +02:00
|
|
|
.full-grid-width {
|
2021-05-19 08:41:19 +02:00
|
|
|
grid-column: 1 / 6;
|
2021-04-22 07:39:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
.table {
|
|
|
|
display: table;
|
|
|
|
height: 100%;
|
|
|
|
}
|
|
|
|
|
|
|
|
.vcenter {
|
|
|
|
display: table-cell;
|
|
|
|
vertical-align: middle;
|
|
|
|
}
|
|
|
|
|
|
|
|
.alert {
|
|
|
|
margin-top: 0.5em;
|
|
|
|
}
|
|
|
|
|
|
|
|
.input-grid {
|
|
|
|
display: grid;
|
|
|
|
grid-column-gap: 0.5em;
|
2021-04-22 08:47:10 +02:00
|
|
|
grid-template-columns: 10fr 16px;
|
2021-04-12 06:18:30 +02:00
|
|
|
}
|
|
|
|
</style>
|