2019-08-02 15:54:10 +02:00
|
|
|
<script>
|
2020-01-28 22:17:04 +01:00
|
|
|
import { some, includes, filter } from "lodash/fp";
|
|
|
|
import Textbox from "../common/Textbox.svelte";
|
|
|
|
import Dropdown from "../common/Dropdown.svelte";
|
|
|
|
import PropControl from "./PropControl.svelte";
|
|
|
|
import IconButton from "../common/IconButton.svelte";
|
2019-08-02 15:54:10 +02:00
|
|
|
|
2020-01-28 22:17:04 +01:00
|
|
|
export let componentInfo;
|
|
|
|
export let onPropChanged = () => {};
|
|
|
|
export let components;
|
2019-08-07 10:03:49 +02:00
|
|
|
|
2020-01-28 22:17:04 +01:00
|
|
|
let errors = [];
|
|
|
|
let props = {};
|
|
|
|
|
2020-02-01 00:11:50 +01:00
|
|
|
const props_to_ignore = ['_component','_children', '_styles', '_code', '_id'];
|
2020-01-28 22:17:04 +01:00
|
|
|
|
|
|
|
$: propDefs = componentInfo && Object.entries(componentInfo).filter(([name])=> !props_to_ignore.includes(name));
|
|
|
|
|
|
|
|
function find_type(prop_name) {
|
|
|
|
if(!componentInfo._component) return;
|
|
|
|
return components.find(({name}) => name === componentInfo._component).props[prop_name];
|
|
|
|
}
|
|
|
|
|
|
|
|
let setProp = (name, value) => {
|
|
|
|
onPropChanged(name, value);
|
|
|
|
}
|
|
|
|
|
|
|
|
const fieldHasError = (propName) =>
|
|
|
|
some(e => e.propName === propName)(errors);
|
2019-08-02 15:54:10 +02:00
|
|
|
</script>
|
|
|
|
|
2019-08-04 23:21:16 +02:00
|
|
|
<div class="root">
|
|
|
|
|
2020-01-18 00:06:42 +01:00
|
|
|
<form class="uk-form-stacked form-root">
|
2020-01-24 15:30:17 +01:00
|
|
|
{#each propDefs as [prop_name, prop_value], index}
|
2020-01-20 13:28:05 +01:00
|
|
|
|
2020-01-24 15:30:17 +01:00
|
|
|
<div class="prop-container">
|
2019-08-16 16:48:45 +02:00
|
|
|
|
2020-01-24 15:30:17 +01:00
|
|
|
<PropControl {setProp}
|
|
|
|
{prop_name}
|
|
|
|
{prop_value}
|
|
|
|
prop_type={find_type(prop_name)}
|
|
|
|
{index}
|
|
|
|
disabled={false} />
|
2019-08-16 16:48:45 +02:00
|
|
|
|
2020-01-24 15:30:17 +01:00
|
|
|
</div>
|
2020-01-20 13:28:05 +01:00
|
|
|
|
2020-01-18 00:06:42 +01:00
|
|
|
{/each}
|
|
|
|
|
2019-08-07 10:03:49 +02:00
|
|
|
</form>
|
2019-08-16 16:48:45 +02:00
|
|
|
|
2019-08-04 23:21:16 +02:00
|
|
|
</div>
|
2019-08-02 15:54:10 +02:00
|
|
|
|
|
|
|
|
|
|
|
<style>
|
2020-01-28 22:17:04 +01:00
|
|
|
.root {
|
|
|
|
font-size:10pt;
|
|
|
|
width: 100%;
|
|
|
|
}
|
|
|
|
|
|
|
|
.form-root {
|
|
|
|
display: flex;
|
|
|
|
flex-wrap: wrap;
|
|
|
|
}
|
|
|
|
|
|
|
|
.prop-container {
|
|
|
|
flex: 1 1 auto;
|
|
|
|
min-width: 250px;
|
|
|
|
}
|
2020-01-20 13:28:05 +01:00
|
|
|
</style>
|