mirror of
https://github.com/gpxstudio/gpx.studio.git
synced 2026-10-19 09:22:12 +00:00
cleaning
This commit is contained in:
1 parent
8fd47d8b18
commit
5373d0f0d4
15 files changed
+339
-408
No files matched your search
@@ -0,0 +1,41 @@
|
||||
<script lang="ts">
|
||||
let {
|
||||
value = '',
|
||||
placeholder,
|
||||
oncommit,
|
||||
oncancel,
|
||||
}: {
|
||||
value?: string;
|
||||
placeholder?: string;
|
||||
/** The name is given: with Enter (`enter`), or by leaving the field. */
|
||||
oncommit: (value: string, enter: boolean) => void;
|
||||
/** Escape: no name is given. */
|
||||
oncancel: () => void;
|
||||
} = $props();
|
||||
|
||||
function onkeydown(event: KeyboardEvent) {
|
||||
// not for the row or the explorer it is in (a folder opens with Enter or Space, the selected
|
||||
// files open with Enter)
|
||||
event.stopPropagation();
|
||||
if (event.key === 'Enter') {
|
||||
oncommit((event.currentTarget as HTMLInputElement).value, true);
|
||||
} else if (event.key === 'Escape') {
|
||||
oncancel();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- the name of a file or a folder of the explorer, being given or changed -->
|
||||
<input
|
||||
class="h-6 grow min-w-0 px-1 text-sm font-normal not-italic bg-background border rounded outline-none"
|
||||
{value}
|
||||
{placeholder}
|
||||
{@attach (input) => {
|
||||
input.focus();
|
||||
input.select();
|
||||
}}
|
||||
{onkeydown}
|
||||
onkeyup={(event) => event.stopPropagation()}
|
||||
onclick={(event) => event.stopPropagation()}
|
||||
onblur={(event) => oncommit(event.currentTarget.value, false)}
|
||||
/>
|
||||
Reference in new issue
Block a user