Mishig commited on
[Assisntans filter] More UX fixes (#908)
Browse files* [Assisntans filter] More UX fixes
* rm unused
Files changed (3)
12341 unmodified line67891011121314159 unmodified lines252627282930311 unmodified line3334353637383940414243444546<script lang="ts">import { createEventDispatcher, onMount } from "svelte";export let value = "";1 unmodified lineexport let maxRows: null | number = null;export let placeholder = "";export let disabled = false;// Approximate width from which we disable autofocusconst TABLET_VIEWPORT_WIDTH = 768;let innerWidth = 0;let textareaElement: HTMLTextAreaElement;let isCompositionOn = false;9 unmodified lines// blur to close keyboard on mobiletextareaElement.blur();// refocus so that user on desktop can start typing without needing to reclick on textareaif (innerWidth > TABLET_VIEWPORT_WIDTH) {textareaElement.focus();}dispatch("submit"); // use a custom event instead of `event.target.form.requestSubmit()` as it does not work on Safari 141 unmodified line}onMount(() => {if (innerWidth > TABLET_VIEWPORT_WIDTH) {textareaElement.focus();}});</script><svelte:window bind:innerWidth /><div class="relative min-w-0 flex-1"><preclass="scrollbar-custom invisible overflow-x-hidden overflow-y-scroll whitespace-pre-wrap break-words p-3"123451 unmodified line789101112139 unmodified lines232425262728291 unmodified line313233343536373839404142<script lang="ts">import { isDesktop } from "$lib/utils/isDesktop";import { createEventDispatcher, onMount } from "svelte";export let value = "";1 unmodified lineexport let maxRows: null | number = null;export let placeholder = "";export let disabled = false;let textareaElement: HTMLTextAreaElement;let isCompositionOn = false;9 unmodified lines// blur to close keyboard on mobiletextareaElement.blur();// refocus so that user on desktop can start typing without needing to reclick on textareaif (isDesktop(window)) {textareaElement.focus();}dispatch("submit"); // use a custom event instead of `event.target.form.requestSubmit()` as it does not work on Safari 141 unmodified line}onMount(() => {if (isDesktop(window)) {textareaElement.focus();}});</script><div class="relative min-w-0 flex-1"><preclass="scrollbar-custom invisible overflow-x-hidden overflow-y-scroll whitespace-pre-wrap break-words p-3"
1234567// Approximate width from which we disable autofocusconst TABLET_VIEWPORT_WIDTH = 768;
export function isDesktop(window: Window) { const { innerWidth } = window; return innerWidth > TABLET_VIEWPORT_WIDTH;}19 unmodified lines20212223242510 unmodified lines3637383940414243447 unmodified lines5253545556575871 unmodified lines13013113213313413514 unmodified lines1501511521531541557 unmodified lines16316416516616716819 unmodified linesimport { getHref } from "$lib/utils/getHref";import { debounce } from "$lib/utils/debounce";import { useSettingsStore } from "$lib/stores/settings";export let data: PageData;10 unmodified linesnewKeys: { modelId: (e.target as HTMLSelectElement).value },existingKeys: { behaviour: "delete_except", keys: ["user"] },});goto(newUrl);};const filterOnName = debounce(async (value: string) => {filterValue = value;7 unmodified linesexistingKeys: { behaviour: "delete", keys: ["p"] },});await goto(newUrl);setTimeout(() => filterInputEl.focus(), 0);isFilterInPorgress = false;// there was a new filter query before server returned response71 unmodified lineshref={getHref($page.url, {existingKeys: { behaviour: "delete", keys: ["user", "modelId", "p", "q"] },})}class="group"><CarbonCloseclass="text-xs group-hover:text-gray-800 dark:group-hover:text-gray-300"14 unmodified lineshref={getHref($page.url, {existingKeys: { behaviour: "delete", keys: ["user", "modelId", "p", "q"] },})}class="flex items-center gap-1.5 rounded-full border px-3 py-1 {!assistantsCreator? 'border-gray-300 bg-gray-50 dark:border-gray-600 dark:bg-gray-700 dark:text-white': 'border-transparent text-gray-400 hover:text-gray-800 dark:hover:text-gray-300'}"7 unmodified linesnewKeys: { user: data.user.username },existingKeys: { behaviour: "delete", keys: ["modelId", "p", "q"] },})}class="flex items-center gap-1.5 truncate rounded-full border px-3 py-1 {assistantsCreator &&createdByMe? 'border-gray-300 bg-gray-50 dark:border-gray-600 dark:bg-gray-700 dark:text-white'19 unmodified lines2021222324252610 unmodified lines3738394041424344454647484950517 unmodified lines59606162636465666771 unmodified lines13914014114214314414514 unmodified lines1601611621631641651667 unmodified lines17417517617717817918019 unmodified linesimport { getHref } from "$lib/utils/getHref";import { debounce } from "$lib/utils/debounce";import { useSettingsStore } from "$lib/stores/settings";import { isDesktop } from "$lib/utils/isDesktop";export let data: PageData;10 unmodified linesnewKeys: { modelId: (e.target as HTMLSelectElement).value },existingKeys: { behaviour: "delete_except", keys: ["user"] },});resetFilter();goto(newUrl);};const resetFilter = () => {filterValue = "";isFilterInPorgress = false;};const filterOnName = debounce(async (value: string) => {filterValue = value;7 unmodified linesexistingKeys: { behaviour: "delete", keys: ["p"] },});await goto(newUrl);if (isDesktop(window)) {setTimeout(() => filterInputEl.focus(), 0);}isFilterInPorgress = false;// there was a new filter query before server returned response71 unmodified lineshref={getHref($page.url, {existingKeys: { behaviour: "delete", keys: ["user", "modelId", "p", "q"] },})}on:click={resetFilter}class="group"><CarbonCloseclass="text-xs group-hover:text-gray-800 dark:group-hover:text-gray-300"14 unmodified lineshref={getHref($page.url, {existingKeys: { behaviour: "delete", keys: ["user", "modelId", "p", "q"] },})}on:click={resetFilter}class="flex items-center gap-1.5 rounded-full border px-3 py-1 {!assistantsCreator? 'border-gray-300 bg-gray-50 dark:border-gray-600 dark:bg-gray-700 dark:text-white': 'border-transparent text-gray-400 hover:text-gray-800 dark:hover:text-gray-300'}"7 unmodified linesnewKeys: { user: data.user.username },existingKeys: { behaviour: "delete", keys: ["modelId", "p", "q"] },})}on:click={resetFilter}class="flex items-center gap-1.5 truncate rounded-full border px-3 py-1 {assistantsCreator &&createdByMe? 'border-gray-300 bg-gray-50 dark:border-gray-600 dark:bg-gray-700 dark:text-white'
src/lib/components/chat/ChatInput.svelte+3-7
src/lib/utils/isDesktop.tsAdded+7
src/routes/assistants/+page.svelte+13-1