mirror of
https://github.com/CharaChorder/DeviceManager.git
synced 2026-01-21 17:32:41 +00:00
@@ -22,6 +22,9 @@ const de = {
|
|||||||
PLACEHOLDER: "Nach Aktionen suchen",
|
PLACEHOLDER: "Nach Aktionen suchen",
|
||||||
CURRENT_ACTION: "Aktuelle Aktion",
|
CURRENT_ACTION: "Aktuelle Aktion",
|
||||||
DELETE: "Entfernen",
|
DELETE: "Entfernen",
|
||||||
|
filter: {
|
||||||
|
ALL: "Alle",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
share: {
|
share: {
|
||||||
URL_COPIED: "Teilbare URL kopiert!",
|
URL_COPIED: "Teilbare URL kopiert!",
|
||||||
|
|||||||
@@ -21,6 +21,9 @@ const en = {
|
|||||||
PLACEHOLDER: "Search for actions",
|
PLACEHOLDER: "Search for actions",
|
||||||
CURRENT_ACTION: "Current action",
|
CURRENT_ACTION: "Current action",
|
||||||
DELETE: "Remove",
|
DELETE: "Remove",
|
||||||
|
filter: {
|
||||||
|
ALL: "All",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
share: {
|
share: {
|
||||||
URL_COPIED: "Sharable URL copied!",
|
URL_COPIED: "Sharable URL copied!",
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {KEYMAP_CODES} from "$lib/serial/keymap-codes"
|
import {KEYMAP_CATEGORIES, KEYMAP_CODES} from "$lib/serial/keymap-codes"
|
||||||
import type {KeyInfo} from "$lib/serial/keymap-codes"
|
import type {KeyInfo} from "$lib/serial/keymap-codes"
|
||||||
import Index from "flexsearch"
|
import Index from "flexsearch"
|
||||||
import {createEventDispatcher} from "svelte"
|
import {createEventDispatcher} from "svelte"
|
||||||
import ActionListItem from "$lib/components/ActionListItem.svelte"
|
import ActionListItem from "$lib/components/ActionListItem.svelte"
|
||||||
import LL from "../../../i18n/i18n-svelte"
|
import LL from "../../../i18n/i18n-svelte"
|
||||||
import {action} from "$lib/title"
|
import {action} from "$lib/title"
|
||||||
|
import type {KeymapCategory} from "$lib/assets/keymaps/keymap"
|
||||||
|
|
||||||
export let currentAction: number
|
export let currentAction: number
|
||||||
|
|
||||||
@@ -59,24 +60,25 @@
|
|||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
}
|
}
|
||||||
|
|
||||||
let results: number[] = []
|
let results: number[] = Object.keys(KEYMAP_CODES).map(Number)
|
||||||
let exact: number | undefined = undefined
|
let exact: number | undefined = undefined
|
||||||
let code: number = Number.NaN
|
let code: number = Number.NaN
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
let searchBox: HTMLInputElement
|
let searchBox: HTMLInputElement
|
||||||
let resultList: HTMLUListElement
|
let resultList: HTMLUListElement
|
||||||
|
let filter: Set<number>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:window on:keydown={keyboardNavigation} />
|
<svelte:window on:keydown={keyboardNavigation} />
|
||||||
|
|
||||||
|
<!-- svelte-ignore a11y-click-events-have-key-events a11y-no-noninteractive-element-interactions -->
|
||||||
<dialog open on:click|self={() => dispatch("close")}>
|
<dialog open on:click|self={() => dispatch("close")}>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<div class="search-row">
|
<div class="search-row">
|
||||||
<input
|
<input
|
||||||
type="search"
|
type="search"
|
||||||
bind:this={searchBox}
|
bind:this={searchBox}
|
||||||
autofocus
|
|
||||||
on:input={search}
|
on:input={search}
|
||||||
on:keypress={event => {
|
on:keypress={event => {
|
||||||
if (event.key === "Enter") {
|
if (event.key === "Enter") {
|
||||||
@@ -94,6 +96,27 @@
|
|||||||
on:click={() => dispatch("close")}>close</button
|
on:click={() => dispatch("close")}>close</button
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
|
<fieldset class="filters">
|
||||||
|
<label
|
||||||
|
>{$LL.actionSearch.filter.ALL()}<input
|
||||||
|
checked
|
||||||
|
name="category"
|
||||||
|
type="radio"
|
||||||
|
value={undefined}
|
||||||
|
bind:group={filter}
|
||||||
|
/></label
|
||||||
|
>
|
||||||
|
{#each KEYMAP_CATEGORIES as category}
|
||||||
|
<label
|
||||||
|
>{category.name}<input
|
||||||
|
name="category"
|
||||||
|
type="radio"
|
||||||
|
value={new Set(Object.keys(category.actions).map(Number))}
|
||||||
|
bind:group={filter}
|
||||||
|
/></label
|
||||||
|
>
|
||||||
|
{/each}
|
||||||
|
</fieldset>
|
||||||
<aside>
|
<aside>
|
||||||
<h3>{$LL.actionSearch.CURRENT_ACTION()}</h3>
|
<h3>{$LL.actionSearch.CURRENT_ACTION()}</h3>
|
||||||
<ActionListItem id={currentAction} />
|
<ActionListItem id={currentAction} />
|
||||||
@@ -112,7 +135,7 @@
|
|||||||
<li>Action code is out of range</li>
|
<li>Action code is out of range</li>
|
||||||
{/if}
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
{#each results as id (id)}
|
{#each filter ? results.filter(it => filter.has(it)) : results as id (id)}
|
||||||
<li><ActionListItem {id} on:click={() => select(id)} /></li>
|
<li><ActionListItem {id} on:click={() => select(id)} /></li>
|
||||||
{/each}
|
{/each}
|
||||||
</ul>
|
</ul>
|
||||||
@@ -120,6 +143,32 @@
|
|||||||
</dialog>
|
</dialog>
|
||||||
|
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
|
.filters {
|
||||||
|
display: flex;
|
||||||
|
gap: 4px;
|
||||||
|
border: none;
|
||||||
|
|
||||||
|
label {
|
||||||
|
height: unset;
|
||||||
|
padding-block: 2px;
|
||||||
|
padding-inline: 4px;
|
||||||
|
|
||||||
|
font-size: 14px;
|
||||||
|
|
||||||
|
border: 1px solid currentcolor;
|
||||||
|
border-radius: 6px;
|
||||||
|
|
||||||
|
&:has(:checked) {
|
||||||
|
color: var(--md-sys-color-on-secondary);
|
||||||
|
background: var(--md-sys-color-secondary);
|
||||||
|
}
|
||||||
|
|
||||||
|
input {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
dialog {
|
dialog {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@@ -152,10 +201,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
h2 {
|
|
||||||
margin-inline: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.search-row {
|
.search-row {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 4px;
|
gap: 4px;
|
||||||
|
|||||||
@@ -5,14 +5,14 @@ export interface KeyInfo extends Partial<ActionInfo> {
|
|||||||
category: KeymapCategory
|
category: KeymapCategory
|
||||||
}
|
}
|
||||||
|
|
||||||
const keymaps = (await Promise.all(
|
export const KEYMAP_CATEGORIES = (await Promise.all(
|
||||||
Object.values(import.meta.glob("$lib/assets/keymaps/*.yml")).map(async load =>
|
Object.values(import.meta.glob("$lib/assets/keymaps/*.yml")).map(async load =>
|
||||||
load().then(it => (it as any).default),
|
load().then(it => (it as any).default),
|
||||||
),
|
),
|
||||||
)) as KeymapCategory[]
|
)) as KeymapCategory[]
|
||||||
|
|
||||||
export const KEYMAP_CODES: Record<number, KeyInfo> = Object.fromEntries(
|
export const KEYMAP_CODES: Record<number, KeyInfo> = Object.fromEntries(
|
||||||
keymaps.flatMap(category =>
|
KEYMAP_CATEGORIES.flatMap(category =>
|
||||||
Object.entries(category.actions).map(([code, action]) => [
|
Object.entries(category.actions).map(([code, action]) => [
|
||||||
Number(code),
|
Number(code),
|
||||||
{...action, code: Number(code), category},
|
{...action, code: Number(code), category},
|
||||||
@@ -21,13 +21,11 @@ export const KEYMAP_CODES: Record<number, KeyInfo> = Object.fromEntries(
|
|||||||
)
|
)
|
||||||
|
|
||||||
export const KEYMAP_IDS: Map<string, KeyInfo> = new Map(
|
export const KEYMAP_IDS: Map<string, KeyInfo> = new Map(
|
||||||
keymaps
|
KEYMAP_CATEGORIES.flatMap(category =>
|
||||||
.flatMap(category =>
|
|
||||||
Object.entries(category.actions).map(
|
Object.entries(category.actions).map(
|
||||||
([code, action]) => [action.id!, {...action, code: Number(code), category}] as const,
|
([code, action]) => [action.id!, {...action, code: Number(code), category}] as const,
|
||||||
),
|
),
|
||||||
)
|
).filter(([id]) => id !== undefined),
|
||||||
.filter(([id]) => id !== undefined),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
export const specialKeycodes = new Map([
|
export const specialKeycodes = new Map([
|
||||||
|
|||||||
Reference in New Issue
Block a user