This repository has been archived by the owner on Aug 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9b2c38c
commit ab15f10
Showing
24 changed files
with
1,012 additions
and
720 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
src/lib/editor/overlay/variables-list/ArrayEditorModal.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<script lang="ts"> | ||
import { getModalStore } from '@skeletonlabs/skeleton'; | ||
import { assignControl } from '$rete/customization/utils'; | ||
import { InputControl, type InputControlTypes } from '$rete/control/Control'; | ||
import InputControlComponent from '$rete/customization/presets/classic/components/InputControl.svelte'; | ||
const modalStore = getModalStore(); | ||
let { array, title, type } = $modalStore[0].meta; | ||
let controls: InputControl<'unknown'>[] = []; | ||
for (const [i, x] of array.entries()) { | ||
addControl(i, x); | ||
} | ||
console.log(array); | ||
function addControl(i: number, initial: unknown) { | ||
const controlType = assignControl(type); | ||
if (!controlType) throw new Error(`Control type not found for ${type}`); | ||
const inputControl = new InputControl<'unknown', unknown>(controlType, { | ||
initial, | ||
change: (val) => { | ||
console.log('change', val); | ||
array[i] = val; | ||
} | ||
}); | ||
controls = [...controls, inputControl]; | ||
} | ||
function addItem() { | ||
array = [...array, undefined]; | ||
addControl(array.length - 1, undefined); | ||
} | ||
function validate() { | ||
if ($modalStore[0].response) $modalStore[0].response(array); | ||
modalStore.close(); | ||
} | ||
</script> | ||
|
||
<section class="p-8 space-y-8 bg-surface-200-700-token rounded-container-token"> | ||
<h2 class="h2">{title}</h2> | ||
<ol class="space-y-2 max-h-[70vh] overflow-y-auto p-0.5"> | ||
{#each controls as control} | ||
<InputControlComponent data={control} /> | ||
{/each} | ||
</ol> | ||
<div class="flex justify-end border-t-2 pt-4 gap-2 border-black"> | ||
<button type="button" class="btn variant-filled-tertiary" on:click={() => addItem()}>Add</button | ||
> | ||
<button type="button" class="btn variant-filled-primary" on:click={() => validate()} | ||
>Validate</button | ||
> | ||
</div> | ||
</section> |
Oops, something went wrong.