From 0825788e86809f10bb83d664084328dff0b47146 Mon Sep 17 00:00:00 2001 From: ivarlovlie Date: Sat, 15 Oct 2022 16:40:01 +0800 Subject: feat: Add combobox and textarea --- code/app/src/lib/components/combobox.svelte | 443 +++++++++++++++++++++++++++ code/app/src/lib/components/index.ts | 4 + code/app/src/lib/components/textarea.svelte | 64 ++++ code/app/src/lib/i18n/en/index.ts | 6 + code/app/src/lib/i18n/i18n-types.ts | 37 +++ code/app/src/routes/book/badges/+page.svelte | 4 +- code/app/src/routes/book/inputs/+page.svelte | 57 ++-- code/app/tailwind.config.cjs | 2 + 8 files changed, 597 insertions(+), 20 deletions(-) create mode 100644 code/app/src/lib/components/combobox.svelte create mode 100644 code/app/src/lib/components/textarea.svelte diff --git a/code/app/src/lib/components/combobox.svelte b/code/app/src/lib/components/combobox.svelte new file mode 100644 index 0000000..ee69917 --- /dev/null +++ b/code/app/src/lib/components/combobox.svelte @@ -0,0 +1,443 @@ + + + + + + +
+ {#if label} + + {/if} +
+
+ {#if multiple === true && hasSelection} +
+ {#each options.filter((c) => c.selected === true) as option} + methods.deselect_entry(e.detail.id)} + text={option.name} + /> + {/each} +
+ {/if} +
+ search.do()} + on:click={search.on_input_click} + on:focus={search.on_input_focus} + on:blur={search.on_input_focusout} + autocomplete="off" + /> + {#if hasSelection} + + {:else} + + + + {/if} +
+
+ {#if errorText} +

+ {errorText} +

+ {/if} +
+
    + {#if searchResults.length > 0} + {#each searchResults.filter((c) => !c.selected) as result} +
  • + {@html highlight(result, '', "")} +
  • + {/each} + {:else if options.length > 0} + {#each options as option} + +
  • + {option.name} + {#if option.selected} + + + + {/if} +
  • + {/each} + {:else} +

    {noResultsText}

    + {#if createable && !searchValue} +

    {$LL.combobox.createRecordHelpText()}

    + {/if} + {/if} +
+ {#if showCreationHint} +
+
+ {/if} +
+
+
+ + diff --git a/code/app/src/lib/components/index.ts b/code/app/src/lib/components/index.ts index 5ed1f09..d6abd4c 100644 --- a/code/app/src/lib/components/index.ts +++ b/code/app/src/lib/components/index.ts @@ -6,9 +6,13 @@ import LocaleSwitcher from "./locale-switcher.svelte"; import Switch from "./switch.svelte"; import Badge from "./badge.svelte"; import ProjectStatusBadge from "./project-status-badge.svelte"; +import TextArea from "./textarea.svelte"; +import Combobox from "./combobox.svelte"; export { Badge, + Combobox, + TextArea, ProjectStatusBadge, Alert, Button, diff --git a/code/app/src/lib/components/textarea.svelte b/code/app/src/lib/components/textarea.svelte new file mode 100644 index 0000000..65127af --- /dev/null +++ b/code/app/src/lib/components/textarea.svelte @@ -0,0 +1,64 @@ + + +
+ {#if label} + + {/if} +
+