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>
|
|
|
|
|
|
|
|
<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>
|
|
|
|
|
2021-04-26 15:34:33 +02:00
|
|
|
<div {id} class="outer">
|
2021-04-22 08:47:10 +02:00
|
|
|
{#if label}
|
|
|
|
<div class="table">
|
|
|
|
<span class="vcenter">
|
|
|
|
{label}
|
2021-05-16 13:41:40 +02:00
|
|
|
{#if renderedTooltip}
|
|
|
|
<HelpPopup html={renderedTooltip} />
|
2021-04-22 08:47:10 +02:00
|
|
|
{/if}
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
{/if}
|
2021-04-12 06:18:30 +02:00
|
|
|
|
2021-04-22 08:47:10 +02:00
|
|
|
<div class="input-grid" class:full-grid-width={wholeLine}>
|
2021-04-12 06:18:30 +02:00
|
|
|
<slot />
|
2021-04-25 10:31:13 +02:00
|
|
|
<RevertButton bind:value {defaultValue} on:revert />
|
2021-04-12 06:18:30 +02:00
|
|
|
</div>
|
2021-04-17 14:53:47 +02:00
|
|
|
|
2021-04-22 07:39:50 +02:00
|
|
|
<div class="full-grid-width">
|
|
|
|
{#each warnings as warning}
|
|
|
|
{#if warning}
|
2021-04-25 13:10:53 +02:00
|
|
|
<div class="alert alert-warning" in:slide out:slide>{warning}</div>
|
2021-04-22 07:39:50 +02:00
|
|
|
{/if}
|
|
|
|
{/each}
|
|
|
|
</div>
|
2021-04-12 06:18:30 +02:00
|
|
|
</div>
|