2019-08-02 15:54:10 +02:00
|
|
|
<script>
|
|
|
|
|
|
|
|
import {
|
|
|
|
keys,
|
|
|
|
map,
|
|
|
|
} from "lodash/fp";
|
|
|
|
import {
|
|
|
|
pipe
|
|
|
|
} from "../common/core";
|
2019-08-04 23:21:16 +02:00
|
|
|
import {
|
|
|
|
createPropDefinitionForDerived
|
|
|
|
} from "./pagesParsing/createProps";
|
|
|
|
import {
|
|
|
|
getExactComponent
|
|
|
|
} from "./pagesParsing/searchComponents";
|
2019-08-07 10:03:49 +02:00
|
|
|
import Checkbox from "../common/Checkbox.svelte";
|
|
|
|
import Textbox from "../common/Textbox.svelte";
|
|
|
|
import Dropdown from "../common/Dropdown.svelte";
|
2019-08-02 15:54:10 +02:00
|
|
|
|
|
|
|
export let props;
|
2019-08-04 23:21:16 +02:00
|
|
|
export let allComponents;
|
|
|
|
|
|
|
|
let propsDefinition = createPropDefinitionForDerived(allComponents, props._component);
|
2019-08-02 15:54:10 +02:00
|
|
|
|
|
|
|
let fields = pipe(propsDefinition,[
|
|
|
|
keys,
|
|
|
|
map(k => propsDefinition[k])
|
|
|
|
]);
|
|
|
|
|
2019-08-04 23:21:16 +02:00
|
|
|
let component = getExactComponent(allComponents, props._component);
|
|
|
|
|
2019-08-07 10:03:49 +02:00
|
|
|
let setProp = (name) => (ev) =>
|
|
|
|
props[name] = ev.target.checked !== undefined
|
|
|
|
? ev.target.checked
|
|
|
|
: ev.target.value;
|
|
|
|
|
2019-08-02 15:54:10 +02:00
|
|
|
</script>
|
|
|
|
|
2019-08-04 23:21:16 +02:00
|
|
|
<div class="root">
|
|
|
|
|
2019-08-07 10:03:49 +02:00
|
|
|
<div class="title">{component.name}</div>
|
|
|
|
<div class="component-description">{component.description || ""}</div>
|
2019-08-04 23:21:16 +02:00
|
|
|
{#each propsDefinition as propDef}
|
2019-08-07 10:03:49 +02:00
|
|
|
<form class="uk-form-horizontal prop-row ">
|
2019-08-04 23:21:16 +02:00
|
|
|
{#if propDef.type === "bool"}
|
2019-08-07 10:03:49 +02:00
|
|
|
<Checkbox label={propDef.name}
|
|
|
|
checked={props[propDef.name]}
|
|
|
|
on:change={setProp(propDef.name)} />
|
|
|
|
{:else if propDef.type === "options"}
|
|
|
|
<Dropdown label={propDef.name}
|
|
|
|
selected={props[propDef.name]}
|
|
|
|
options={propDef.options}
|
|
|
|
on:change={setProp(propDef.name)}/>
|
2019-08-04 23:21:16 +02:00
|
|
|
{:else}
|
2019-08-07 10:03:49 +02:00
|
|
|
<Textbox label={propDef.name}
|
|
|
|
bind:text={props[propDef.name]} />
|
2019-08-04 23:21:16 +02:00
|
|
|
{/if}
|
2019-08-07 10:03:49 +02:00
|
|
|
</form>
|
2019-08-04 23:21:16 +02:00
|
|
|
{/each}
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
2019-08-02 15:54:10 +02:00
|
|
|
|
|
|
|
|
|
|
|
<style>
|
2019-08-04 23:21:16 +02:00
|
|
|
|
|
|
|
.root {
|
|
|
|
padding: 10px;
|
2019-08-07 10:03:49 +02:00
|
|
|
font-size:10pt;
|
|
|
|
}
|
|
|
|
|
|
|
|
.title {
|
|
|
|
font: var(--smallheavybodytext);
|
|
|
|
}
|
|
|
|
|
|
|
|
.prop-row {
|
|
|
|
padding: 7px 3px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.component-description {
|
|
|
|
font: var(--lightbodytext);
|
2019-08-04 23:21:16 +02:00
|
|
|
}
|
|
|
|
|
2019-08-02 15:54:10 +02:00
|
|
|
</style>
|