1
0
mirror of https://github.com/garraflavatra/rolens.git synced 2025-07-13 20:24:06 +00:00

Moved text input dialog to frontend

This commit is contained in:
2023-06-18 21:40:39 +02:00
parent a1456b3987
commit 0a3f99fa32
7 changed files with 61 additions and 24 deletions

View File

@ -0,0 +1,38 @@
<script>
import Modal from '$components/modal.svelte';
import { createEventDispatcher, onMount, tick } from 'svelte';
export let title = '';
export let description = '';
export let value = '';
const dispatch = createEventDispatcher();
let input;
function submit() {
dispatch('submit', { value });
}
function close() {
dispatch('close');
}
onMount(() => tick().then(() => input.select()));
</script>
<Modal {title} on:close width="350px">
{#if description}
<p>{description}</p>
{/if}
<form on:submit|preventDefault={submit}>
<label class="field">
<input type="text" bind:value bind:this={input} spellcheck="false" />
</label>
</form>
<svelte:fragment slot="footer">
<button on:click={submit} class="btn">OK</button>
<button on:click={close} class="btn secondary">Cancel</button>
</svelte:fragment>
</Modal>

View File

@ -1,3 +1,5 @@
import InputDialog from '../dialogs/input.svelte';
function newDialog(dialogComponent, data = {}) {
const outlet = document.createElement('div');
outlet.className = 'dialogoutlet';
@ -15,6 +17,17 @@ function newDialog(dialogComponent, data = {}) {
return instance;
}
const dialogs = { new: newDialog };
function enterText(title = '', description = '', value = '') {
const instance = newDialog(InputDialog, { title, description, value });
return new Promise(resolve => {
instance.$on('submit', event => {
instance.$close();
resolve(event.detail.value);
});
});
}
const dialogs = { new: newDialog, enterText };
export default dialogs;

2
frontend/wailsjs/go/ui/UI.d.ts generated vendored
View File

@ -4,8 +4,6 @@ import {context} from '../models';
export function Beep():Promise<void>;
export function EnterText(arg1:string,arg2:string,arg3:string):Promise<string>;
export function OpenDirectory(arg1:string):Promise<string>;
export function Reveal(arg1:string):Promise<void>;

View File

@ -6,10 +6,6 @@ export function Beep() {
return window['go']['ui']['UI']['Beep']();
}
export function EnterText(arg1, arg2, arg3) {
return window['go']['ui']['UI']['EnterText'](arg1, arg2, arg3);
}
export function OpenDirectory(arg1) {
return window['go']['ui']['UI']['OpenDirectory'](arg1);
}