diff --git a/package.json b/package.json
index 7a9fbf95..206c80c0 100644
--- a/package.json
+++ b/package.json
@@ -20,12 +20,13 @@
"linkify-it": "^5.0.0",
"marked": "^5.1.2",
"marked-linkify-it": "^3.1.10",
- "mono-svelte": "latest",
"nprogress": "^0.2.0",
"postcss": "^8.4.30",
"rollup-plugin-visualizer": "^5.9.2",
"svelte": "^4.2.18",
"svelte-check": "^3.0.1",
+ "svelte-floating-ui": "^1.5.9",
+ "svelte-focus-trap": "^1.2.0",
"svelte-hero-icons": "^5.2.0",
"svelte-infinite-scroll": "^2.0.1",
"svelte-markdown": "^0.4.1",
diff --git a/src/lib/mono/badge/Badge.svelte b/src/lib/mono/badge/Badge.svelte
new file mode 100644
index 00000000..21c88139
--- /dev/null
+++ b/src/lib/mono/badge/Badge.svelte
@@ -0,0 +1,52 @@
+
+
+
+
+
+
+
+
diff --git a/src/lib/mono/button/Button.svelte b/src/lib/mono/button/Button.svelte
new file mode 100644
index 00000000..03a514ee
--- /dev/null
+++ b/src/lib/mono/button/Button.svelte
@@ -0,0 +1,183 @@
+
+
+
+
+
+
+ {#if loading}
+
+ {:else if $$slots.prefix}
+
+ {/if}
+
+
+
+
+
+
diff --git a/src/lib/mono/code/Codeblock.svelte b/src/lib/mono/code/Codeblock.svelte
new file mode 100644
index 00000000..efbc7b1f
--- /dev/null
+++ b/src/lib/mono/code/Codeblock.svelte
@@ -0,0 +1,76 @@
+
+
+
+ {#if filename}
+
+
+ {filename}
+
+
{
+ copied = true
+ copy()
+ setTimeout(() => (copied = false), 2000)
+ }}
+ >
+
+ {#if !copied}
+
+
+
+ {:else}
+
+
+
+ {/if}
+
+
+
+ {/if}
+
+ {#if htmlSrc}
+ {@html htmlSrc}
+ {:else if $$slots.default}
+
+ {:else if src}
+ {src}
+ {/if}
+
+
diff --git a/src/lib/mono/code/Snippet.svelte b/src/lib/mono/code/Snippet.svelte
new file mode 100644
index 00000000..7db0cb67
--- /dev/null
+++ b/src/lib/mono/code/Snippet.svelte
@@ -0,0 +1,54 @@
+
+
+
+
+ {value}
+
+ {#if copy}
+
{
+ copied = true
+ navigator.clipboard.writeText(value)
+ setTimeout(() => (copied = false), 2000)
+ }}
+ >
+
+ {#if !copied}
+
+
+
+ {:else}
+
+
+
+ {/if}
+
+
+ {/if}
+
diff --git a/src/lib/mono/disclosure/Disclosure.svelte b/src/lib/mono/disclosure/Disclosure.svelte
new file mode 100644
index 00000000..9e30fc00
--- /dev/null
+++ b/src/lib/mono/disclosure/Disclosure.svelte
@@ -0,0 +1,17 @@
+
+
+
+
(open = !open)} class="w-full">
+
+
+ {#if open}
+
+
+
+ {/if}
+
diff --git a/src/lib/mono/forms/Checkbox.svelte b/src/lib/mono/forms/Checkbox.svelte
new file mode 100644
index 00000000..f0b3dd32
--- /dev/null
+++ b/src/lib/mono/forms/Checkbox.svelte
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+ {#if $$slots.description}
+
+ {/if}
+
+
diff --git a/src/lib/mono/forms/Choicebox.svelte b/src/lib/mono/forms/Choicebox.svelte
new file mode 100644
index 00000000..bb4d4b31
--- /dev/null
+++ b/src/lib/mono/forms/Choicebox.svelte
@@ -0,0 +1,74 @@
+
+
+
+
+ {#if type == 'radio'}
+
+ {:else if type == 'checkbox'}
+
+ {/if}
+
+ {#if $$slots.title || title}
+
+ {#if $$slots.title}
+
+ {:else if title}
+ {title}
+ {/if}
+
+ {/if}
+ {#if $$slots.description || description}
+
+ {#if $$slots.description}
+
+ {:else if description}
+ {description}
+ {/if}
+
+ {/if}
+
+
+
diff --git a/src/lib/mono/forms/ChoiceboxGroup.svelte b/src/lib/mono/forms/ChoiceboxGroup.svelte
new file mode 100644
index 00000000..7a70f596
--- /dev/null
+++ b/src/lib/mono/forms/ChoiceboxGroup.svelte
@@ -0,0 +1,16 @@
+
+
+
diff --git a/src/lib/mono/forms/FileInput.svelte b/src/lib/mono/forms/FileInput.svelte
new file mode 100644
index 00000000..4c875d33
--- /dev/null
+++ b/src/lib/mono/forms/FileInput.svelte
@@ -0,0 +1,64 @@
+
+
+
+ {#if $$slots.label || label}
+
+
+
+ {/if}
+
+
+ Browse
+
+ {#if previewURLs}
+
+ {#each previewURLs as file}
+
+
URL.revokeObjectURL(file)}
+ alt={file}
+ class="w-8 h-8 object-cover rounded-full hover:w-16
+ hover:h-16 transition-all border border-slate-200 ring-1
+ ring-slate-50 dark:ring-zinc-950 bg-white dark:bg-zinc-950"
+ />
+ {/each}
+
+ {/if}
+
+
+ {#if (files ?? []).length == 0}
+ No file selected.
+ {:else}
+ {(files ?? []).length} files selected
+ {/if}
+
+
+
+
+
diff --git a/src/lib/mono/forms/Form.svelte b/src/lib/mono/forms/Form.svelte
new file mode 100644
index 00000000..f1e8491b
--- /dev/null
+++ b/src/lib/mono/forms/Form.svelte
@@ -0,0 +1,22 @@
+
+
+
diff --git a/src/lib/mono/forms/ImageInput.svelte b/src/lib/mono/forms/ImageInput.svelte
new file mode 100644
index 00000000..aba5a02d
--- /dev/null
+++ b/src/lib/mono/forms/ImageInput.svelte
@@ -0,0 +1,62 @@
+
+
+
+ {#if $$slots.label || label}
+
+
+
+ {/if}
+
(files = event.dataTransfer?.files)}
+ on:dragover|preventDefault={(event) => {
+ if (event.dataTransfer) {
+ event.dataTransfer.dropEffect = 'copy'
+ dragover = true
+ }
+ }}
+ on:dragleave|preventDefault={() => (dragover = false)}
+ >
+ {#if files}
+
+ {
+ if (previewURL) URL.revokeObjectURL(previewURL)
+ }}
+ class="w-full max-w-sm h-full rounded-lg"
+ />
+ {:else}
+
+ Attach a file
+ {/if}
+
+
+ {#if url != undefined}
+
+ {/if}
+
diff --git a/src/lib/mono/forms/Label.svelte b/src/lib/mono/forms/Label.svelte
new file mode 100644
index 00000000..db40093b
--- /dev/null
+++ b/src/lib/mono/forms/Label.svelte
@@ -0,0 +1,21 @@
+
+
+
+ {#if text}
+ {text}
+ {:else if $$slots.default}
+
+ {/if}
+
diff --git a/src/lib/mono/forms/Radio.svelte b/src/lib/mono/forms/Radio.svelte
new file mode 100644
index 00000000..5b03e64b
--- /dev/null
+++ b/src/lib/mono/forms/Radio.svelte
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+ {#if $$slots.description}
+
+
+
+ {/if}
+
+
diff --git a/src/lib/mono/forms/RadioGroup.svelte b/src/lib/mono/forms/RadioGroup.svelte
new file mode 100644
index 00000000..593168e7
--- /dev/null
+++ b/src/lib/mono/forms/RadioGroup.svelte
@@ -0,0 +1,16 @@
+
+
+
diff --git a/src/lib/mono/forms/Select.svelte b/src/lib/mono/forms/Select.svelte
new file mode 100644
index 00000000..7a91fd6c
--- /dev/null
+++ b/src/lib/mono/forms/Select.svelte
@@ -0,0 +1,123 @@
+
+
+
+ {#if $$slots.label || label}
+
+
+
+ {/if}
+
+
+
+ {
+ e.preventDefault()
+ }}
+ on:keypress={(e) => {
+ e.preventDefault()
+ open = !open
+ }}
+ on:change
+ on:contextmenu
+ {placeholder}
+ >
+ {#if placeholder}
+ {placeholder}
+ {/if}
+
+
+
+ {#each options as option}
+
+ dispatcher('contextmenu')}
+ on:click={() => {
+ value = option.value
+ dispatcher('change')
+ }}
+ size="custom"
+ disabled={option.disabled}
+ class="!min-h-0 !py-[5px] {option.value == value
+ ? '!bg-slate-100 dark:!bg-zinc-800'
+ : ''}"
+ >
+ {@html option.label}
+ {#if option.value == value}
+
+ {/if}
+
+
+ {/each}
+
+
+
+
diff --git a/src/lib/mono/forms/Switch.svelte b/src/lib/mono/forms/Switch.svelte
new file mode 100644
index 00000000..050e5012
--- /dev/null
+++ b/src/lib/mono/forms/Switch.svelte
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+ {#if $$slots.description}
+
+
+
+ {/if}
+
+
+
+
diff --git a/src/lib/mono/forms/TextArea.svelte b/src/lib/mono/forms/TextArea.svelte
new file mode 100644
index 00000000..c4031049
--- /dev/null
+++ b/src/lib/mono/forms/TextArea.svelte
@@ -0,0 +1,81 @@
+
+
+
+
+
+ {#if $$slots.label || label}
+
+
+
+ {/if}
+
+
+ {#if $$slots.suffix}
+
+
+
+ {/if}
+
+
+
diff --git a/src/lib/mono/forms/TextInput.svelte b/src/lib/mono/forms/TextInput.svelte
new file mode 100644
index 00000000..9b97a64f
--- /dev/null
+++ b/src/lib/mono/forms/TextInput.svelte
@@ -0,0 +1,96 @@
+
+
+
+
+
+ {#if $$slots.label || label}
+
+
+
+ {/if}
+
+ {#if $$slots.prefix}
+
+
+
+ {/if}
+
+ {#if $$slots.suffix}
+
+
+
+ {/if}
+
+
+
diff --git a/src/lib/mono/forms/helper.ts b/src/lib/mono/forms/helper.ts
new file mode 100644
index 00000000..3f0b314b
--- /dev/null
+++ b/src/lib/mono/forms/helper.ts
@@ -0,0 +1 @@
+export const generateID = () => Math.floor(Math.random() * 1000000).toString()
diff --git a/src/lib/mono/index.ts b/src/lib/mono/index.ts
new file mode 100644
index 00000000..c624471b
--- /dev/null
+++ b/src/lib/mono/index.ts
@@ -0,0 +1,42 @@
+// Reexport your entry components here
+
+export { default as Button } from './button/Button.svelte'
+export { buttonColor, buttonSize, buttonShadow } from './button/Button.svelte'
+export { default as Codeblock } from './code/Codeblock.svelte'
+export { default as Snippet } from './code/Snippet.svelte'
+export { default as Spinner } from './loader/Spinner.svelte'
+export { default as Routebar } from './nav/Routebar.svelte'
+export { default as Material } from './materials/Material.svelte'
+
+export { default as Form } from './forms/Form.svelte'
+export { default as Label } from './forms/Label.svelte'
+export { default as FileInput } from './forms/FileInput.svelte'
+export { default as TextInput } from './forms/TextInput.svelte'
+export { default as TextArea } from './forms/TextArea.svelte'
+export { default as Select } from './forms/Select.svelte'
+export { default as ImageInput } from './forms/ImageInput.svelte'
+
+export { default as Checkbox } from './forms/Checkbox.svelte'
+export { default as Switch } from './forms/Switch.svelte'
+
+export { default as Radio } from './forms/Radio.svelte'
+export { default as RadioGroup } from './forms/RadioGroup.svelte'
+export { default as Choicebox } from './forms/Choicebox.svelte'
+export { default as ChoiceboxGroup } from './forms/ChoiceboxGroup.svelte'
+
+export { default as Popover } from './popover/Popover.svelte'
+export { default as Menu } from './popover/Menu.svelte'
+export { default as MenuDivider } from './popover/MenuDivider.svelte'
+export { default as MenuButton } from './popover/MenuButton.svelte'
+export { default as Disclosure } from './disclosure/Disclosure.svelte'
+export { default as Modal } from './modal/Modal.svelte'
+export { modal, action } from './modal/modal.js'
+export { default as ModalContainer } from './modal/ModalContainer.svelte'
+
+export { toast, removeToast, toasts, toastColors } from './toast/toasts.js'
+export { default as ToastContainer } from './toast/ToastContainer.svelte'
+
+export { default as Note } from './note/Note.svelte'
+export { default as Badge } from './badge/Badge.svelte'
+export { default as Placeholder } from './placeholder/Placeholder.svelte'
+export { default as Search } from './search/Search.svelte'
diff --git a/src/lib/mono/loader/Spinner.svelte b/src/lib/mono/loader/Spinner.svelte
new file mode 100644
index 00000000..97a564d0
--- /dev/null
+++ b/src/lib/mono/loader/Spinner.svelte
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
+
diff --git a/src/lib/mono/materials/Material.svelte b/src/lib/mono/materials/Material.svelte
new file mode 100644
index 00000000..9b0d4a3a
--- /dev/null
+++ b/src/lib/mono/materials/Material.svelte
@@ -0,0 +1,69 @@
+
+
+
+
+
diff --git a/src/lib/mono/modal/Modal.svelte b/src/lib/mono/modal/Modal.svelte
new file mode 100644
index 00000000..ba69b8bf
--- /dev/null
+++ b/src/lib/mono/modal/Modal.svelte
@@ -0,0 +1,96 @@
+
+
+
+ {#if open}
+
+
+ {
+ if (!el.contains(e.target)) {
+ open = false
+
+ dispatcher('dismissed')
+ }
+ }}
+ >
+
+
+
+ {/if}
+
diff --git a/src/lib/mono/modal/ModalContainer.svelte b/src/lib/mono/modal/ModalContainer.svelte
new file mode 100644
index 00000000..00e919f5
--- /dev/null
+++ b/src/lib/mono/modal/ModalContainer.svelte
@@ -0,0 +1,43 @@
+
+
+{#if $shownModal}
+ shownModal.set(undefined)}
+ bind:open
+ >
+ {$shownModal.body}
+ {#if $shownModal.actions}
+
+ {#each $shownModal.actions as action}
+
+ {#if action.icon}
+
+ {/if}
+ {action.content}
+
+ {/each}
+
+ {/if}
+
+{/if}
diff --git a/src/lib/mono/modal/modal.ts b/src/lib/mono/modal/modal.ts
new file mode 100644
index 00000000..892c2e4b
--- /dev/null
+++ b/src/lib/mono/modal/modal.ts
@@ -0,0 +1,65 @@
+import type { IconSource } from 'svelte-hero-icons'
+import { writable } from 'svelte/store'
+
+export let shownModal = writable(undefined)
+
+interface Modal {
+ actions: Action[]
+ title: string
+ body?: string
+ /**
+ * Whether the modal has a close button or not
+ */
+ dismissable: boolean
+ type: 'error' | 'info' | 'success'
+}
+
+type Action = {
+ /**
+ * What function to run when this action is clicked. If undefined, it'll close the window.
+ */
+ action: () => any
+ type: 'danger' | 'secondary' | 'primary'
+ content: string
+ icon?: IconSource
+ close: boolean
+}
+
+export const action = (action?: {
+ action?: () => any
+ type?: 'danger' | 'secondary' | 'primary'
+ content?: string
+ icon?: IconSource
+ close?: boolean
+}): Action => ({
+ action: action?.action
+ ? () => {
+ action?.action?.()
+ if (action.close) shownModal.set(undefined)
+ }
+ : () => shownModal.set(undefined),
+ type: action?.type ?? 'secondary',
+ content: action?.content || 'OK',
+ close: action?.close ?? true
+})
+
+export function modal(inputModal: {
+ actions?: Action[]
+ title: string
+ body: string
+ /**
+ * Whether the modal has a close button or not
+ */
+ dismissable?: boolean
+ type?: 'error' | 'info' | 'success'
+}) {
+ const modal: Modal = {
+ actions: inputModal.actions ?? [action()],
+ dismissable: inputModal.dismissable ?? true,
+ title: inputModal.title,
+ body: inputModal.body,
+ type: inputModal.type ?? 'info'
+ }
+
+ shownModal.set(modal)
+}
diff --git a/src/lib/mono/nav/Routebar.svelte b/src/lib/mono/nav/Routebar.svelte
new file mode 100644
index 00000000..5867ee52
--- /dev/null
+++ b/src/lib/mono/nav/Routebar.svelte
@@ -0,0 +1,60 @@
+
+
+
+ {#each routes as route}
+ {#if route.children}
+
+ {route.name}
+
+
+ {:else}
+
+ {route.name}
+
+ {/if}
+ {/each}
+
diff --git a/src/lib/mono/note/Note.svelte b/src/lib/mono/note/Note.svelte
new file mode 100644
index 00000000..50c3d87e
--- /dev/null
+++ b/src/lib/mono/note/Note.svelte
@@ -0,0 +1,17 @@
+
+
+
+
+
+ {#if $$slots.default}
+
+ {:else if content}
+ {content}
+ {/if}
+
+
diff --git a/src/lib/mono/placeholder/Placeholder.svelte b/src/lib/mono/placeholder/Placeholder.svelte
new file mode 100644
index 00000000..153920b2
--- /dev/null
+++ b/src/lib/mono/placeholder/Placeholder.svelte
@@ -0,0 +1,37 @@
+
+
+
+ {#if icon || $$slots.icon}
+
+ {#if $$slots.icon}
+
+ {:else if icon}
+
+ {/if}
+
+ {/if}
+
+
+ {#if $$slots.title}
+
+ {:else if title}
+ {title}
+ {/if}
+
+ {#if description || $$slots.description}
+
+ {#if $$slots.description}
+
+ {:else if description}
+ {description}
+ {/if}
+
+ {/if}
+
+
+
diff --git a/src/lib/mono/popover/Menu.svelte b/src/lib/mono/popover/Menu.svelte
new file mode 100644
index 00000000..ed3531c9
--- /dev/null
+++ b/src/lib/mono/popover/Menu.svelte
@@ -0,0 +1,52 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/src/lib/mono/popover/MenuButton.svelte b/src/lib/mono/popover/MenuButton.svelte
new file mode 100644
index 00000000..1322f30e
--- /dev/null
+++ b/src/lib/mono/popover/MenuButton.svelte
@@ -0,0 +1,38 @@
+
+
+
+
+
+
+
+
+
diff --git a/src/lib/mono/popover/MenuDivider.svelte b/src/lib/mono/popover/MenuDivider.svelte
new file mode 100644
index 00000000..d41b430a
--- /dev/null
+++ b/src/lib/mono/popover/MenuDivider.svelte
@@ -0,0 +1,6 @@
+
diff --git a/src/lib/mono/popover/Popover.svelte b/src/lib/mono/popover/Popover.svelte
new file mode 100644
index 00000000..25b53822
--- /dev/null
+++ b/src/lib/mono/popover/Popover.svelte
@@ -0,0 +1,120 @@
+
+
+
+
+ {
+ if (openOnHover) return
+
+ if (!el?.contains(e.target)) {
+ open = false
+ }
+ }}
+ on:keydown={async (e) => {
+ if (open && e.key == 'Escape') {
+ open = false
+ el?.firstChild.focus()
+ }
+ }}
+/>
+
+{#if $$slots.target}
+ (openOnHover ? (open = true) : false)}
+ on:mouseleave={() => (openOnHover ? (open = false) : false)}
+ on:focus={() => (openOnHover ? (open = true) : false)}
+ on:focusout={() => (openOnHover ? (open = false) : false)}
+ on:click={() => (!openOnHover && !manual ? (open = !open) : false)}
+ on:keydown={(e) => {
+ if (e.key == 'Escape') open = false
+ }}
+ role="menu"
+ type="button"
+ class="{canUseContents
+ ? 'contents text-left'
+ : 'w-max h-max'} {$$props.class}"
+ bind:this={el}
+ use:customFloatingRef
+ >
+
+
+{/if}
+
+{#if open}
+
+
+
+
+
+
+
+
+
+{/if}
diff --git a/src/lib/mono/popover/Portal.svelte b/src/lib/mono/popover/Portal.svelte
new file mode 100644
index 00000000..20020ea0
--- /dev/null
+++ b/src/lib/mono/popover/Portal.svelte
@@ -0,0 +1,34 @@
+
+
+
+
+
diff --git a/src/lib/mono/search/Search.svelte b/src/lib/mono/search/Search.svelte
new file mode 100644
index 00000000..1d2730dc
--- /dev/null
+++ b/src/lib/mono/search/Search.svelte
@@ -0,0 +1,86 @@
+
+
+
+
+
+ {
+ searching = true
+ openMenu = true
+ dispatcher('input', e)
+ debounceFunc()
+ }}
+ on:focus={(e) => {
+ searching = true
+ openMenu = true
+ dispatcher('input', e)
+ debounceFunc()
+ }}
+ {...$$restProps}
+ inlineAffixes
+ slot="target"
+ >
+
+
+
+
+
+ {#if searching}
+
+
+
+ {:else if items.length == 0}
+
+ No results found.
+
+ {:else}
+ {#each items as item}
+
+ select(item)}>
+ {extractName(item)}
+
+
+ {/each}
+ {/if}
+
+
diff --git a/src/lib/mono/toast/Toast.svelte b/src/lib/mono/toast/Toast.svelte
new file mode 100644
index 00000000..f31275e2
--- /dev/null
+++ b/src/lib/mono/toast/Toast.svelte
@@ -0,0 +1,76 @@
+
+
+
+ {#if toast.loading}
+
+
+
+ {:else}
+
+ {/if}
+
+ {#if toast.title}
+
{toast.title}
+ {/if}
+
{toast.content}
+
+
+ {#if toast.action}
+ {
+ toast.action?.()
+ toasts.update((toasts) => toasts.filter((t) => t.id != toast.id))
+ }}
+ class="rounded-lg w-max transition-colors hover:bg-black/20 hover:dark:bg-white/20 p-2"
+ >
+
+
+ {/if}
+ {
+ toasts.update((toasts) => toasts.filter((t) => t.id != toast.id))
+ }}
+ class="rounded-lg w-max transition-colors hover:bg-black/20 hover:dark:bg-white/20 p-2"
+ >
+
+
+
+
diff --git a/src/lib/mono/toast/ToastContainer.svelte b/src/lib/mono/toast/ToastContainer.svelte
new file mode 100644
index 00000000..f30f8cba
--- /dev/null
+++ b/src/lib/mono/toast/ToastContainer.svelte
@@ -0,0 +1,21 @@
+
+
+
+ {#each $toasts as toast, index (toast.id)}
+
+
+
+ {/each}
+
diff --git a/src/lib/mono/toast/toasts.ts b/src/lib/mono/toast/toasts.ts
new file mode 100644
index 00000000..2745e6b9
--- /dev/null
+++ b/src/lib/mono/toast/toasts.ts
@@ -0,0 +1,65 @@
+import { writable } from 'svelte/store'
+
+type ToastType = keyof typeof toastColors
+
+export const toastColors = {
+ error: 'bg-white dark:bg-zinc-950 text-red-600 dark:text-red-400 border border-red-700',
+ warning:
+ 'bg-white dark:bg-zinc-950 text-yellow-600 dark:text-yellow-400 border border-yellow-600',
+ success: 'bg-white dark:bg-zinc-950 text-green-700 dark:text-green-400 border border-green-500',
+ info: 'dark:bg-zinc-950 bg-white border border-slate-200 dark:border-zinc-800 shadow-lg'
+}
+
+export interface Toast {
+ id: number
+ title?: string
+ content: string
+ type: ToastType
+ loading?: boolean
+ action?: () => any
+}
+
+export const toasts = writable([])
+
+export function toast({
+ title,
+ content,
+ type = 'info',
+ duration = 5000,
+ loading = false,
+ action
+}: {
+ title?: string
+ content: string
+ type?: ToastType
+ duration?: number
+ loading?: boolean
+ action?: () => any
+}) {
+ let id = 0
+
+ toasts.update((toasts) => {
+ id = Math.floor(Math.random() * 10000)
+
+ return [
+ ...toasts,
+ {
+ id: id,
+ content: content,
+ title: title,
+ type: type,
+ loading: loading,
+ action: action
+ }
+ ]
+ })
+
+ setTimeout(() => {
+ toasts.update((toasts) => toasts.filter((toast) => toast.id != id))
+ }, duration)
+
+ return id
+}
+
+export const removeToast = (id: number) =>
+ toasts.update((toasts) => toasts.filter((toast) => toast.id != id))
diff --git a/src/lib/mono/util/time.ts b/src/lib/mono/util/time.ts
new file mode 100644
index 00000000..28ea0b66
--- /dev/null
+++ b/src/lib/mono/util/time.ts
@@ -0,0 +1,7 @@
+export const debounce = (fn: Function, ms = 300) => {
+ let timeoutId: ReturnType
+ return function (this: any, ...args: any[]) {
+ clearTimeout(timeoutId)
+ timeoutId = setTimeout(() => fn.apply(this, args), ms)
+ }
+}
diff --git a/svelte.config.js b/svelte.config.js
index d64c67d3..ab32a3dd 100644
--- a/svelte.config.js
+++ b/svelte.config.js
@@ -29,6 +29,9 @@ const config = {
// },
// mode: 'nonce'
// }
+ alias: {
+ 'mono-svelte': 'src/lib/mono',
+ },
},
}