2019-08-07 10:03:49 +02:00
|
|
|
<script>
|
|
|
|
|
2019-10-07 07:03:41 +02:00
|
|
|
import ComponentSelector from "./ComponentSelector.svelte";
|
2019-08-07 10:03:49 +02:00
|
|
|
import { store } from "../builderStore";
|
|
|
|
import PropsView from "./PropsView.svelte";
|
|
|
|
import Textbox from "../common/Textbox.svelte";
|
2019-08-14 23:11:59 +02:00
|
|
|
import Button from "../common/Button.svelte";
|
|
|
|
import ButtonGroup from "../common/ButtonGroup.svelte";
|
|
|
|
import { pipe } from "../common/core";
|
|
|
|
import UIkit from "uikit";
|
|
|
|
import {
|
|
|
|
getNewComponentInfo
|
|
|
|
} from "./pagesParsing/createProps";
|
|
|
|
import { isRootComponent } from "./pagesParsing/searchComponents";
|
2019-10-07 07:03:41 +02:00
|
|
|
import GeneratedComponents from "./GeneratedComponents.svelte";
|
2019-08-07 10:03:49 +02:00
|
|
|
|
2019-08-14 23:11:59 +02:00
|
|
|
import {
|
|
|
|
cloneDeep,
|
|
|
|
join,
|
|
|
|
split,
|
|
|
|
map,
|
|
|
|
keys,
|
|
|
|
isUndefined
|
|
|
|
} from "lodash/fp";
|
|
|
|
import { assign } from "lodash";
|
2019-08-07 10:03:49 +02:00
|
|
|
|
2019-08-14 23:11:59 +02:00
|
|
|
|
|
|
|
|
2019-10-07 07:03:41 +02:00
|
|
|
let componentSelectorModal;
|
|
|
|
let generatorOptionsModal;
|
2019-08-16 16:48:45 +02:00
|
|
|
let allComponents;
|
2019-10-07 07:03:41 +02:00
|
|
|
let generator;
|
2019-08-14 23:11:59 +02:00
|
|
|
|
2019-08-16 16:48:45 +02:00
|
|
|
store.subscribe(s => {
|
|
|
|
allComponents = s.allComponents;
|
|
|
|
})
|
2019-08-14 23:11:59 +02:00
|
|
|
|
2019-08-16 16:48:45 +02:00
|
|
|
export const close = () => {
|
2019-10-07 07:03:41 +02:00
|
|
|
UIkit.modal(componentSelectorModal).hide();
|
|
|
|
if(generatorOptionsModal) UIkit.modal(generatorOptionsModal).hide();
|
|
|
|
generator = null;
|
2019-08-14 23:11:59 +02:00
|
|
|
}
|
|
|
|
|
2019-08-16 16:48:45 +02:00
|
|
|
export const show = () => {
|
2019-10-07 07:03:41 +02:00
|
|
|
UIkit.modal(componentSelectorModal).show();
|
2019-08-14 23:11:59 +02:00
|
|
|
}
|
|
|
|
|
2019-08-16 16:48:45 +02:00
|
|
|
const onComponentChosen = (c) => {
|
|
|
|
store.createDerivedComponent(c.name);
|
|
|
|
close();
|
2019-08-07 10:03:49 +02:00
|
|
|
}
|
|
|
|
|
2019-10-07 07:03:41 +02:00
|
|
|
const onGeneratorChosen = (g) => {
|
|
|
|
generator = g;
|
|
|
|
UIkit.modal(componentSelectorModal).hide();
|
|
|
|
UIkit.modal(generatorOptionsModal).show();
|
|
|
|
}
|
|
|
|
|
|
|
|
const onConfirmGenerate = (components) => {
|
|
|
|
store.createGeneratedComponents(components);
|
2019-10-10 11:41:31 +02:00
|
|
|
UIkit.modal(generatorOptionsModal).hide();
|
2019-10-07 07:03:41 +02:00
|
|
|
generator = null;
|
|
|
|
}
|
|
|
|
|
2019-08-07 10:03:49 +02:00
|
|
|
</script>
|
|
|
|
|
2019-10-07 07:03:41 +02:00
|
|
|
<div bind:this={componentSelectorModal} id="new-component-modal" uk-modal>
|
|
|
|
<div class="uk-modal-dialog" uk-overflow-auto>
|
2019-08-14 23:11:59 +02:00
|
|
|
|
|
|
|
<div class="uk-modal-header">
|
|
|
|
<h1>New Component</h1>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="uk-modal-body">
|
2019-10-07 07:03:41 +02:00
|
|
|
<ComponentSelector onComponentChosen={onComponentChosen}
|
2019-10-10 11:41:31 +02:00
|
|
|
onGeneratorChosen={onGeneratorChosen}
|
|
|
|
allowGenerators={true} />
|
2019-10-07 07:03:41 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div bind:this={generatorOptionsModal} uk-modal>
|
|
|
|
<div class="uk-modal-dialog" uk-overflow-auto>
|
|
|
|
|
|
|
|
{#if generator}
|
|
|
|
|
|
|
|
<div class="uk-modal-header">
|
|
|
|
<h1>Generator - {generator ? generator.name : ""}</h1>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="uk-modal-body">
|
|
|
|
<GeneratedComponents generator={generator}
|
|
|
|
onConfirmGenerate={onConfirmGenerate} />
|
2019-08-14 23:11:59 +02:00
|
|
|
</div>
|
2019-10-07 07:03:41 +02:00
|
|
|
|
|
|
|
{/if}
|
2019-08-07 10:03:49 +02:00
|
|
|
</div>
|
2019-08-14 23:11:59 +02:00
|
|
|
</div>
|
2019-08-07 10:03:49 +02:00
|
|
|
|
2019-10-07 07:03:41 +02:00
|
|
|
|
2019-08-07 10:03:49 +02:00
|
|
|
<style>
|
2019-08-14 23:11:59 +02:00
|
|
|
h1 {
|
|
|
|
font-size:1.2em;
|
|
|
|
}
|
|
|
|
|
2019-08-07 10:03:49 +02:00
|
|
|
</style>
|