migrate: switch to callbacks instead of events
This commit is contained in:
1 parent
c7e2963390
commit
b291aeebf8
67 files changed
+332
-357
No files matched your search
@@ -64,7 +64,7 @@
|
||||
{/each}
|
||||
</div>
|
||||
<Button
|
||||
on:click={() => clearErrorScope(scope)}
|
||||
onclick={() => clearErrorScope(scope)}
|
||||
color="tertiary"
|
||||
size="square-sm"
|
||||
class="ml-auto"
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
{#snippet noresults()}
|
||||
<div class="w-full h-full">
|
||||
{#if q == '' && showWhenEmpty}
|
||||
<MenuButton on:click={() => dispatcher('select', undefined)}>
|
||||
<MenuButton onclick={() => dispatcher('select', undefined)}>
|
||||
<Icon src={XCircle} size="16" mini />
|
||||
<div class="flex flex-col text-left">
|
||||
<span>None</span>
|
||||
@@ -66,7 +66,7 @@
|
||||
{/snippet}
|
||||
{#snippet children({ item, select })}
|
||||
<div in:fly|global={{ y: -4, opacity: 0 }}>
|
||||
<MenuButton on:click={() => select(item)}>
|
||||
<MenuButton onclick={() => select(item)}>
|
||||
<Avatar url={item.icon} alt={item.title} width={24} />
|
||||
<div class="flex flex-col text-left">
|
||||
<span>{item.title}</span>
|
||||
@@ -98,7 +98,7 @@
|
||||
{#snippet noresults()}
|
||||
<div class="w-full h-full">
|
||||
{#if q == '' && showWhenEmpty}
|
||||
<MenuButton on:click={() => dispatcher('select', undefined)}>
|
||||
<MenuButton onclick={() => dispatcher('select', undefined)}>
|
||||
<div class="flex flex-col text-left">
|
||||
<span>None (Start typing to search)</span>
|
||||
</div>
|
||||
@@ -110,7 +110,7 @@
|
||||
{/snippet}
|
||||
{#snippet children({ item, select })}
|
||||
<div in:fly|global={{ y: -4, opacity: 0 }}>
|
||||
<MenuButton on:click={() => select(item)}>
|
||||
<MenuButton onclick={() => select(item)}>
|
||||
<Icon src={ServerStack} size="16" mini />
|
||||
<div class="flex flex-col text-left">
|
||||
<span>{item.domain}</span>
|
||||
|
||||
@@ -67,7 +67,7 @@
|
||||
color="tertiary"
|
||||
rounding="pill"
|
||||
class="text-slate-700 dark:text-zinc-300"
|
||||
on:click={() => (replying = !replying)}
|
||||
onclick={() => (replying = !replying)}
|
||||
disabled={comment.post.locked || disabled}
|
||||
>
|
||||
<Icon src={ChatBubbleOvalLeft} size="14" micro />
|
||||
@@ -92,7 +92,7 @@
|
||||
{/snippet}
|
||||
<MenuDivider>{$t('comment.actions.label')}</MenuDivider>
|
||||
<MenuButton
|
||||
on:click={() => {
|
||||
onclick={() => {
|
||||
navigator.share?.({
|
||||
url: comment.comment.ap_id,
|
||||
}) ?? navigator.clipboard.writeText(comment.comment.ap_id)
|
||||
@@ -103,7 +103,7 @@
|
||||
</MenuButton>
|
||||
{#if settings.translator}
|
||||
<MenuButton
|
||||
on:click={() => {
|
||||
onclick={() => {
|
||||
// @ts-ignore
|
||||
text.set(comment.comment.content)
|
||||
translating = !translating
|
||||
@@ -117,13 +117,13 @@
|
||||
{/if}
|
||||
{#if $profile?.jwt}
|
||||
{#if comment.creator.id == $profile.user?.local_user_view.person.id}
|
||||
<MenuButton on:click={() => dispatcher('edit', comment)}>
|
||||
<MenuButton onclick={() => dispatcher('edit', comment)}>
|
||||
<Icon src={PencilSquare} mini size="16" />
|
||||
<span>{$t('post.actions.more.edit')}</span>
|
||||
</MenuButton>
|
||||
{/if}
|
||||
<MenuButton
|
||||
on:click={async () => {
|
||||
onclick={async () => {
|
||||
if ($profile?.jwt)
|
||||
comment.saved = await save(comment, !comment.saved, $profile.jwt)
|
||||
}}
|
||||
@@ -136,7 +136,7 @@
|
||||
{#if $profile?.user && $profile.jwt && $profile.user.local_user_view.person.id == comment.creator.id}
|
||||
<MenuButton
|
||||
color="danger-subtle"
|
||||
on:click={async () => {
|
||||
onclick={async () => {
|
||||
if ($profile?.jwt)
|
||||
comment.comment.deleted = await deleteItem(
|
||||
comment,
|
||||
@@ -154,7 +154,7 @@
|
||||
</MenuButton>
|
||||
{/if}
|
||||
{#if $profile.jwt && $profile.user?.local_user_view.person.id != comment.creator.id}
|
||||
<MenuButton on:click={() => report(comment)} color="danger-subtle">
|
||||
<MenuButton onclick={() => report(comment)} color="danger-subtle">
|
||||
<Icon src={Flag} mini size="16" />
|
||||
<span>{$t('moderation.report')}</span>
|
||||
</MenuButton>
|
||||
|
||||
@@ -106,7 +106,7 @@
|
||||
<Button
|
||||
size="custom"
|
||||
title={$t('common.cancel')}
|
||||
on:click={() => dispatch('cancel', true)}
|
||||
onclick={() => dispatch('cancel', true)}
|
||||
color="tertiary"
|
||||
class="w-8 h-8"
|
||||
rounding="xl"
|
||||
@@ -114,7 +114,7 @@
|
||||
<Icon src={XMark} size="16" micro />
|
||||
</Button>
|
||||
<Button
|
||||
on:click={submit}
|
||||
onclick={submit}
|
||||
color="primary"
|
||||
{loading}
|
||||
disabled={locked || loading || banned}
|
||||
|
||||
@@ -137,7 +137,7 @@
|
||||
color="tertiary"
|
||||
class="font-normal text-slate-600 dark:text-zinc-400"
|
||||
loaderWidth={16}
|
||||
on:click={() => {
|
||||
onclick={() => {
|
||||
if (node.depth > 4) {
|
||||
goto(
|
||||
`/comment/${$page.params.instance}/${node.comment_view.comment.id}#comments`,
|
||||
|
||||
@@ -234,7 +234,7 @@
|
||||
color={community_view.subscribed == 'Subscribed'
|
||||
? 'secondary'
|
||||
: 'primary'}
|
||||
on:click={subscribe}
|
||||
onclick={subscribe}
|
||||
class="flex-1 relative z-[inherit]"
|
||||
>
|
||||
{#snippet prefix()}
|
||||
@@ -279,7 +279,7 @@
|
||||
<MenuButton
|
||||
color="danger-subtle"
|
||||
size="lg"
|
||||
on:click={() =>
|
||||
onclick={() =>
|
||||
block(community_view.community.id, !community_view.blocked)}
|
||||
>
|
||||
{#snippet prefix()}
|
||||
@@ -293,7 +293,7 @@
|
||||
<MenuButton
|
||||
color="danger-subtle"
|
||||
size="lg"
|
||||
on:click={() => blockInstance(community_view.community.instance_id)}
|
||||
onclick={() => blockInstance(community_view.community.instance_id)}
|
||||
>
|
||||
{#snippet prefix()}
|
||||
<Icon src={BuildingOffice2} size="16" mini />
|
||||
@@ -304,7 +304,7 @@
|
||||
{#if $profile?.user && isAdmin($profile.user)}
|
||||
<MenuButton
|
||||
color="danger-subtle"
|
||||
on:click={() =>
|
||||
onclick={() =>
|
||||
modal({
|
||||
title: $t('admin.purgeCommunity.title'),
|
||||
body: `${community_view.community.title}: ${$t('admin.purgeCommunity.warning')}`,
|
||||
|
||||
@@ -132,7 +132,7 @@ dark:border-zinc-800 border-slate-300 border-opacity-50 text-slate-700 dark:text
|
||||
loading={subscribing}
|
||||
size="lg"
|
||||
color={subscribed == 'NotSubscribed' ? 'primary' : 'secondary'}
|
||||
on:click={async () => {
|
||||
onclick={async () => {
|
||||
subscribed =
|
||||
(await subscribe())?.community_view.subscribed ??
|
||||
'NotSubscribed'
|
||||
@@ -186,7 +186,7 @@ dark:border-zinc-800 border-slate-300 border-opacity-50 text-slate-700 dark:text
|
||||
<MenuButton
|
||||
color="danger-subtle"
|
||||
size="lg"
|
||||
on:click={() => block(community.id, !blocked)}
|
||||
onclick={() => block(community.id, !blocked)}
|
||||
>
|
||||
{#snippet prefix()}
|
||||
<Icon src={NoSymbol} size="16" mini />
|
||||
@@ -199,7 +199,7 @@ dark:border-zinc-800 border-slate-300 border-opacity-50 text-slate-700 dark:text
|
||||
<MenuButton
|
||||
color="danger-subtle"
|
||||
size="lg"
|
||||
on:click={() => blockInstance(community.instance_id)}
|
||||
onclick={() => blockInstance(community.instance_id)}
|
||||
>
|
||||
{#snippet prefix()}
|
||||
<Icon src={BuildingOffice2} size="16" mini />
|
||||
@@ -210,7 +210,7 @@ dark:border-zinc-800 border-slate-300 border-opacity-50 text-slate-700 dark:text
|
||||
{#if $profile?.user && isAdmin($profile.user)}
|
||||
<MenuButton
|
||||
color="danger-subtle"
|
||||
on:click={() =>
|
||||
onclick={() =>
|
||||
modal({
|
||||
title: $t('admin.purgeCommunity.title'),
|
||||
body: `${community.title}: ${$t('admin.purgeCommunity.warning')}`,
|
||||
|
||||
@@ -98,7 +98,7 @@
|
||||
</div>
|
||||
</a>
|
||||
<div class="flex flex-row items-center gap-2">
|
||||
<Button size="square-md" on:click={() => (showInfo = !showInfo)}>
|
||||
<Button size="square-md" onclick={() => (showInfo = !showInfo)}>
|
||||
<Icon src={InformationCircle} size="16" micro />
|
||||
</Button>
|
||||
<Subscribe {community}>
|
||||
@@ -106,7 +106,7 @@
|
||||
<Button
|
||||
disabled={subscribing || !$profile?.jwt}
|
||||
loading={subscribing}
|
||||
on:click={async () => {
|
||||
onclick={async () => {
|
||||
const res = await subscribe()
|
||||
|
||||
if (res) {
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
{$t('moderation.label')}
|
||||
{/if}
|
||||
</MenuDivider>
|
||||
<MenuButton color="danger-subtle" on:click={() => remove(item)}>
|
||||
<MenuButton color="danger-subtle" onclick={() => remove(item)}>
|
||||
{#snippet prefix()}
|
||||
<Icon src={Trash} size="16" mini />
|
||||
{/snippet}
|
||||
@@ -57,7 +57,7 @@
|
||||
<!--Comment made by someone else-->
|
||||
<MenuButton
|
||||
color="danger-subtle"
|
||||
on:click={() =>
|
||||
onclick={() =>
|
||||
ban(item.creator_banned_from_community, item.creator, item.community)}
|
||||
>
|
||||
{#snippet prefix()}
|
||||
@@ -71,7 +71,7 @@
|
||||
<!--Comment made by self-->
|
||||
<MenuButton
|
||||
color="success-subtle"
|
||||
on:click={async () => {
|
||||
onclick={async () => {
|
||||
if (!$profile.jwt) return
|
||||
item.comment = (
|
||||
await feature(
|
||||
@@ -94,7 +94,7 @@
|
||||
|
||||
{#if $profile?.user && isAdmin($profile.user)}
|
||||
<MenuDivider>{$t('admin.label')}</MenuDivider>
|
||||
<MenuButton color="danger-subtle" on:click={() => remove(item, true)}>
|
||||
<MenuButton color="danger-subtle" onclick={() => remove(item, true)}>
|
||||
{#snippet prefix()}
|
||||
<Icon src={Fire} size="16" mini />
|
||||
{/snippet}
|
||||
|
||||
@@ -97,7 +97,7 @@
|
||||
</MenuDivider>
|
||||
<MenuButton
|
||||
color="warning-subtle"
|
||||
on:click={() => lock(!item.post.locked)}
|
||||
onclick={() => lock(!item.post.locked)}
|
||||
loading={locking}
|
||||
disabled={locking}
|
||||
>
|
||||
@@ -109,7 +109,7 @@
|
||||
|
||||
<MenuButton
|
||||
color="success-subtle"
|
||||
on:click={() =>
|
||||
onclick={() =>
|
||||
pin(isPostView(item) ? !item.post.featured_community : false)}
|
||||
loading={pinning}
|
||||
disabled={pinning}
|
||||
@@ -128,7 +128,7 @@
|
||||
{/if}
|
||||
</div>
|
||||
</MenuButton>
|
||||
<MenuButton color="danger-subtle" on:click={() => remove(item)}>
|
||||
<MenuButton color="danger-subtle" onclick={() => remove(item)}>
|
||||
<Icon src={Trash} size="16" mini />
|
||||
{#if isCommentView(item)}
|
||||
{item.comment.removed
|
||||
@@ -141,7 +141,7 @@
|
||||
{#if $profile?.user && $profile.user.local_user_view.person.id != item.creator.id}
|
||||
<MenuButton
|
||||
color="danger-subtle"
|
||||
on:click={() =>
|
||||
onclick={() =>
|
||||
ban(item.creator_banned_from_community, item.creator, item.community)}
|
||||
>
|
||||
<Icon src={ShieldExclamation} size="16" mini />
|
||||
@@ -155,7 +155,7 @@
|
||||
<MenuDivider>{$t('admin.label')}</MenuDivider>
|
||||
<MenuButton
|
||||
color="success-subtle"
|
||||
on:click={() =>
|
||||
onclick={() =>
|
||||
pin(isPostView(item) ? !item.post.featured_local : false, true)}
|
||||
>
|
||||
<Icon src={Megaphone} size="16" mini />
|
||||
@@ -170,7 +170,7 @@
|
||||
<span class="text-xs opacity-80">{$t('admin.instance')}</span>
|
||||
</div>
|
||||
</MenuButton>
|
||||
<MenuButton color="danger-subtle" on:click={() => remove(item, true)}>
|
||||
<MenuButton color="danger-subtle" onclick={() => remove(item, true)}>
|
||||
<Icon src={Fire} size="16" mini />
|
||||
{$t('admin.purge')}
|
||||
</MenuButton>
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
item?: PostView | CommentView | PrivateMessageView | undefined
|
||||
}
|
||||
|
||||
let { open = $bindable(), item = undefined }: Props = $props()
|
||||
let { open = $bindable(), item = $bindable() }: Props = $props()
|
||||
|
||||
const isComment = (
|
||||
item: PostView | CommentView | PrivateMessageView,
|
||||
|
||||
@@ -170,7 +170,7 @@
|
||||
{/await}
|
||||
{/if}
|
||||
<Button
|
||||
on:click={() => (debug = true)}
|
||||
onclick={() => (debug = true)}
|
||||
title="Debug"
|
||||
size="custom"
|
||||
color="ghost"
|
||||
@@ -196,7 +196,7 @@
|
||||
|
||||
{#if $profile?.jwt}
|
||||
<Button
|
||||
on:click={async () => {
|
||||
onclick={async () => {
|
||||
if (!$profile?.jwt) return
|
||||
saving = true
|
||||
post.saved = await save(post, !post.saved, $profile?.jwt)
|
||||
@@ -312,7 +312,7 @@
|
||||
{$t('post.actions.more.actions')}
|
||||
</MenuDivider>
|
||||
{#if $profile?.user && $profile?.jwt && $profile.user.local_user_view.person.id == post.creator.id}
|
||||
<MenuButton on:click={() => (editing = true)}>
|
||||
<MenuButton onclick={() => (editing = true)}>
|
||||
{#snippet prefix()}
|
||||
<Icon src={PencilSquare} size="16" micro />
|
||||
{/snippet}
|
||||
@@ -321,7 +321,7 @@
|
||||
{/if}
|
||||
{#if $profile?.jwt}
|
||||
<MenuButton
|
||||
on:click={async () => {
|
||||
onclick={async () => {
|
||||
if ($profile?.jwt)
|
||||
post.read = await markAsRead(post.post, !post.read, $profile.jwt)
|
||||
}}
|
||||
@@ -335,7 +335,7 @@
|
||||
</MenuButton>
|
||||
{/if}
|
||||
<MenuButton
|
||||
on:click={() => {
|
||||
onclick={() => {
|
||||
navigator.share?.({
|
||||
url: localShare
|
||||
? `${instanceToURL(getInstance())}/post/${post.post.id}`
|
||||
@@ -361,7 +361,7 @@
|
||||
color={!localShare ? 'primary' : 'secondary'}
|
||||
size="square-md"
|
||||
roundingSide="left"
|
||||
on:click={() => (localShare = false)}
|
||||
onclick={() => (localShare = false)}
|
||||
title={$t('filter.location.global')}
|
||||
>
|
||||
<Icon src={GlobeAmericas} size="16" micro />
|
||||
@@ -370,7 +370,7 @@
|
||||
color={localShare ? 'primary' : 'secondary'}
|
||||
size="square-md"
|
||||
roundingSide="right"
|
||||
on:click={() => (localShare = true)}
|
||||
onclick={() => (localShare = true)}
|
||||
title={$t('filter.location.local')}
|
||||
>
|
||||
<Icon src={MapPin} size="16" micro />
|
||||
@@ -380,7 +380,7 @@
|
||||
</MenuButton>
|
||||
{#if post.post.body && settings.translator}
|
||||
<MenuButton
|
||||
on:click={() => {
|
||||
onclick={() => {
|
||||
// @ts-ignore
|
||||
text.set(post.post.body)
|
||||
translating = !translating
|
||||
@@ -394,7 +394,7 @@
|
||||
{/if}
|
||||
{#if $profile?.jwt}
|
||||
<MenuButton
|
||||
on:click={() => {
|
||||
onclick={() => {
|
||||
setSessionStorage('postDraft', {
|
||||
body: `${
|
||||
settings.crosspostOriginalLink
|
||||
@@ -423,7 +423,7 @@
|
||||
</MenuButton>
|
||||
{#if $profile.user && post.creator.id == $profile.user.local_user_view.person.id}
|
||||
<MenuButton
|
||||
on:click={async () => {
|
||||
onclick={async () => {
|
||||
if ($profile?.jwt)
|
||||
post.post.deleted = await deleteItem(
|
||||
post,
|
||||
@@ -444,7 +444,7 @@
|
||||
{#if $profile.user?.local_user_view.person.id != post.creator.id}
|
||||
{#if feature('hidePosts', $site?.version)}
|
||||
<MenuButton
|
||||
on:click={async () => {
|
||||
onclick={async () => {
|
||||
if (!$profile?.jwt) return
|
||||
const hidden = await hidePost(
|
||||
post.post.id,
|
||||
@@ -466,7 +466,7 @@
|
||||
: $t('post.actions.more.hide')}
|
||||
</MenuButton>
|
||||
{/if}
|
||||
<MenuButton on:click={() => report(post)} color="danger-subtle">
|
||||
<MenuButton onclick={() => report(post)} color="danger-subtle">
|
||||
{#snippet prefix()}
|
||||
<Icon src={Flag} width={16} micro />
|
||||
{/snippet}
|
||||
|
||||
@@ -51,7 +51,7 @@ ${view == 'list' ? `max-h-24` : 'max-h-48'}`
|
||||
<Markdown inline={!expanded} source={expanded ? body : body.slice(0, 1000)} />
|
||||
{#if overflows}
|
||||
<Button
|
||||
on:click={() => (expanded = !expanded)}
|
||||
onclick={() => (expanded = !expanded)}
|
||||
size="square-sm"
|
||||
color="tertiary"
|
||||
class="text-black dark:text-white absolute z-10 isolate pointer-events-auto bottom-0 {expanded
|
||||
|
||||
@@ -278,7 +278,7 @@
|
||||
color="primary"
|
||||
{loading}
|
||||
disabled={loading}
|
||||
on:click={() => loadMore()}
|
||||
onclick={() => loadMore()}
|
||||
>
|
||||
{$t('message.retry')}
|
||||
</Button>
|
||||
|
||||
@@ -295,7 +295,7 @@
|
||||
<span class="font-medium text-sm">{$t('form.post.community')}</span>
|
||||
<Button
|
||||
class="w-full !bg-white dark:!bg-black h-[38px]"
|
||||
on:click={() => (data.community = null)}
|
||||
onclick={() => (data.community = null)}
|
||||
alignment="left"
|
||||
size="sm"
|
||||
>
|
||||
@@ -347,7 +347,7 @@
|
||||
</div>
|
||||
{#if data.url}
|
||||
<Button
|
||||
on:click={() => (addAltText = !addAltText)}
|
||||
onclick={() => (addAltText = !addAltText)}
|
||||
rounding="pill"
|
||||
size="sm"
|
||||
color="ghost"
|
||||
@@ -359,7 +359,7 @@
|
||||
</Button>
|
||||
{/if}
|
||||
<Button
|
||||
on:click={() => (uploadingImage = !uploadingImage)}
|
||||
onclick={() => (uploadingImage = !uploadingImage)}
|
||||
rounding="pill"
|
||||
size="sm"
|
||||
color="ghost"
|
||||
@@ -372,7 +372,7 @@
|
||||
</Button>
|
||||
{#if generation.generatable}
|
||||
<Button
|
||||
on:click={() => generateTitle(data.url)}
|
||||
onclick={() => generateTitle(data.url)}
|
||||
loading={generation.loading}
|
||||
rounding="pill"
|
||||
size="sm"
|
||||
@@ -391,7 +391,7 @@
|
||||
<div class="flex flex-row gap-2 flex-wrap">
|
||||
{#if data.url === undefined}
|
||||
<Button
|
||||
on:click={async () => {
|
||||
onclick={async () => {
|
||||
data.url = ''
|
||||
try {
|
||||
const url = new URL(await navigator.clipboard.readText())
|
||||
@@ -406,7 +406,7 @@
|
||||
{$t('form.post.addUrl')}
|
||||
</Button>
|
||||
<Button
|
||||
on:click={() => {
|
||||
onclick={() => {
|
||||
data.url = ''
|
||||
uploadingImage = true
|
||||
}}
|
||||
@@ -418,7 +418,7 @@
|
||||
</Button>
|
||||
{/if}
|
||||
{#if data.language_id === undefined}
|
||||
<Button size="sm" rounding="pill" on:click={() => (data.language_id = 0)}>
|
||||
<Button size="sm" rounding="pill" onclick={() => (data.language_id = 0)}>
|
||||
<Icon src={Language} size="16" micro />
|
||||
{$t('form.post.setLanguage')}
|
||||
</Button>
|
||||
@@ -466,7 +466,7 @@
|
||||
|
||||
{#if !edit}
|
||||
<Button
|
||||
on:click={() => {
|
||||
onclick={() => {
|
||||
toast({ content: $t('toast.restoredFromDraft') })
|
||||
const draft = getSessionStorage('postDraft')
|
||||
if (draft && !edit) {
|
||||
|
||||
@@ -68,7 +68,7 @@
|
||||
{/each}
|
||||
<MenuDivider>{$t('post.actions.link.actions')}</MenuDivider>
|
||||
<MenuButton
|
||||
on:click={() => {
|
||||
onclick={() => {
|
||||
navigator?.share?.({ url: url }) ?? navigator?.clipboard?.writeText?.(url)
|
||||
|
||||
toast({ content: $t('toast.copied') })
|
||||
|
||||
@@ -82,7 +82,7 @@
|
||||
>
|
||||
{#if post.alt_text}
|
||||
<Button
|
||||
on:click={(e) => {
|
||||
onclick={(e) => {
|
||||
e.stopPropagation()
|
||||
modal({
|
||||
title: 'Alt',
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
{#snippet noresults()}
|
||||
<div class="w-full h-full">
|
||||
{#if showWhenEmpty}
|
||||
<MenuButton on:click={() => dispatcher('select', undefined)}>
|
||||
<MenuButton onclick={() => dispatcher('select', undefined)}>
|
||||
<Icon src={XCircle} size="16" mini />
|
||||
<div class="flex flex-col text-left">
|
||||
<span>None</span>
|
||||
@@ -60,7 +60,7 @@
|
||||
{/snippet}
|
||||
{#snippet children({ item, select })}
|
||||
<div in:fly|global={{ y: -4, opacity: 0 }}>
|
||||
<MenuButton on:click={() => select(item)}>
|
||||
<MenuButton onclick={() => select(item)}>
|
||||
<Avatar url={item.avatar} alt={item.name} width={24} />
|
||||
<div class="flex flex-col text-left">
|
||||
<span>{item.name}</span>
|
||||
|
||||
@@ -165,63 +165,63 @@ overflow-hidden transition-colors {clazz}"
|
||||
: ''}"
|
||||
>
|
||||
<Button
|
||||
on:click={() => wrapSelection('**', '**')}
|
||||
onclick={() => wrapSelection('**', '**')}
|
||||
title="Bold"
|
||||
size="square-md"
|
||||
>
|
||||
<Icon src={Bold} size="16" mini />
|
||||
</Button>
|
||||
<Button
|
||||
on:click={() => wrapSelection('*', '*')}
|
||||
onclick={() => wrapSelection('*', '*')}
|
||||
title="Italic"
|
||||
size="square-md"
|
||||
>
|
||||
<Icon src={Italic} size="16" micro />
|
||||
</Button>
|
||||
<Button
|
||||
on:click={() => wrapSelection('[', '](https://example.com)')}
|
||||
onclick={() => wrapSelection('[', '](https://example.com)')}
|
||||
title="Link"
|
||||
size="square-md"
|
||||
>
|
||||
<Icon src={Link} size="16" micro />
|
||||
</Button>
|
||||
<Button
|
||||
on:click={() => wrapSelection('\n# ', '')}
|
||||
onclick={() => wrapSelection('\n# ', '')}
|
||||
title="Header"
|
||||
size="square-md"
|
||||
>
|
||||
<Icon src={H1} size="16" micro />
|
||||
</Button>
|
||||
<Button
|
||||
on:click={() => wrapSelection('~~', '~~')}
|
||||
onclick={() => wrapSelection('~~', '~~')}
|
||||
title="Strikethrough"
|
||||
size="square-md"
|
||||
>
|
||||
<Icon src={Strikethrough} size="16" micro />
|
||||
</Button>
|
||||
<Button
|
||||
on:click={() => wrapSelection('\n> ', '')}
|
||||
onclick={() => wrapSelection('\n> ', '')}
|
||||
title="Quote"
|
||||
size="square-md"
|
||||
>
|
||||
<span class="font-bold font-serif text-lg">"</span>
|
||||
</Button>
|
||||
<Button
|
||||
on:click={() => wrapSelection('\n- ', '')}
|
||||
onclick={() => wrapSelection('\n- ', '')}
|
||||
title="List"
|
||||
size="square-md"
|
||||
>
|
||||
<Icon src={ListBullet} micro size="16" />
|
||||
</Button>
|
||||
<Button
|
||||
on:click={() => wrapSelection('`', '`')}
|
||||
onclick={() => wrapSelection('`', '`')}
|
||||
title="Code"
|
||||
size="square-md"
|
||||
>
|
||||
<Icon src={CodeBracket} micro size="16" />
|
||||
</Button>
|
||||
<Button
|
||||
on:click={() =>
|
||||
onclick={() =>
|
||||
wrapSelection('::: spoiler <spoiler title>\n', '\n:::')}
|
||||
title="Spoiler"
|
||||
size="square-md"
|
||||
@@ -229,7 +229,7 @@ overflow-hidden transition-colors {clazz}"
|
||||
<Icon src={ExclamationTriangle} micro size="16" />
|
||||
</Button>
|
||||
<Button
|
||||
on:click={() => wrapSelection('~', '~')}
|
||||
onclick={() => wrapSelection('~', '~')}
|
||||
title="Subscript"
|
||||
size="square-md"
|
||||
>
|
||||
@@ -239,7 +239,7 @@ overflow-hidden transition-colors {clazz}"
|
||||
</span>
|
||||
</Button>
|
||||
<Button
|
||||
on:click={() => wrapSelection('^', '^')}
|
||||
onclick={() => wrapSelection('^', '^')}
|
||||
title="Superscript"
|
||||
size="square-md"
|
||||
>
|
||||
@@ -250,7 +250,7 @@ overflow-hidden transition-colors {clazz}"
|
||||
</Button>
|
||||
{#if images}
|
||||
<Button
|
||||
on:click={() => (uploadingImage = !uploadingImage)}
|
||||
onclick={() => (uploadingImage = !uploadingImage)}
|
||||
title="Image"
|
||||
size="square-md"
|
||||
>
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
<Button
|
||||
size="square-sm"
|
||||
color="tertiary"
|
||||
on:click={() => {
|
||||
onclick={() => {
|
||||
navigator?.clipboard?.writeText(codeblock.code)
|
||||
toast({ content: $t('toast.copied') })
|
||||
}}
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
<Modal title={$t('post.actions.more.translate')} bind:open>
|
||||
<TextArea bind:value={$text} rows={2}>
|
||||
{#snippet suffix()}
|
||||
<Button on:click={() => translate($text)} color="primary">
|
||||
<Button onclick={() => translate($text)} color="primary">
|
||||
{$t('post.actions.more.translate')}
|
||||
</Button>
|
||||
{/snippet}
|
||||
|
||||
@@ -89,7 +89,7 @@
|
||||
rounding="full"
|
||||
padding="none"
|
||||
color="uniform"
|
||||
on:click={(e) => e.stopPropagation()}
|
||||
onclick={(e) => e.stopPropagation()}
|
||||
>
|
||||
<Button
|
||||
download
|
||||
@@ -102,7 +102,7 @@
|
||||
<Icon src={ArrowDownTray} size="20" micro />
|
||||
</Button>
|
||||
<Button
|
||||
on:click={async () => {
|
||||
onclick={async () => {
|
||||
if (navigator.share) {
|
||||
const file = await downloadImage($page.state.openImage)
|
||||
|
||||
@@ -125,7 +125,7 @@
|
||||
{/snippet}
|
||||
</Button>
|
||||
<Button
|
||||
on:click={() => {
|
||||
onclick={() => {
|
||||
zoomed = !zoomed
|
||||
}}
|
||||
color="tertiary"
|
||||
@@ -140,7 +140,7 @@
|
||||
/>
|
||||
</Button>
|
||||
<Button
|
||||
on:click={() => history.back()}
|
||||
onclick={() => history.back()}
|
||||
color="tertiary"
|
||||
size="square-lg"
|
||||
rounding="pill"
|
||||
|
||||
@@ -13,18 +13,18 @@
|
||||
import { fly } from 'svelte/transition'
|
||||
|
||||
interface Props {
|
||||
page?: number;
|
||||
cursor?: { next?: string; back?: string } | undefined;
|
||||
hasMore?: boolean;
|
||||
children?: import('svelte').Snippet;
|
||||
page?: number
|
||||
cursor?: { next?: string; back?: string } | undefined
|
||||
hasMore?: boolean
|
||||
children?: import('svelte').Snippet
|
||||
}
|
||||
|
||||
let {
|
||||
page = $bindable(0),
|
||||
cursor = undefined,
|
||||
hasMore = true,
|
||||
children
|
||||
}: Props = $props();
|
||||
children,
|
||||
}: Props = $props()
|
||||
|
||||
const dispatcher = createEventDispatcher<{ change: number; cursor: string }>()
|
||||
</script>
|
||||
@@ -41,7 +41,7 @@
|
||||
{/if}
|
||||
<Button
|
||||
color="ghost"
|
||||
on:click={() => {
|
||||
onclick={() => {
|
||||
if (cursor?.back) dispatcher('cursor', cursor?.back)
|
||||
else dispatcher('change', --page)
|
||||
}}
|
||||
@@ -52,8 +52,8 @@
|
||||
disabled={(!cursor?.back && cursor?.next) || page <= 1}
|
||||
>
|
||||
{#snippet suffix()}
|
||||
<Icon src={ChevronLeft} size="24" mini />
|
||||
{/snippet}
|
||||
<Icon src={ChevronLeft} size="24" mini />
|
||||
{/snippet}
|
||||
</Button>
|
||||
|
||||
{#if page}
|
||||
@@ -73,7 +73,7 @@
|
||||
|
||||
<Button
|
||||
color="ghost"
|
||||
on:click={() => {
|
||||
onclick={() => {
|
||||
if (cursor?.next) dispatcher('cursor', cursor?.next)
|
||||
else dispatcher('change', ++page)
|
||||
}}
|
||||
@@ -84,7 +84,7 @@
|
||||
disabled={!hasMore}
|
||||
>
|
||||
{#snippet suffix()}
|
||||
<Icon src={ChevronRight} size="24" mini />
|
||||
{/snippet}
|
||||
<Icon src={ChevronRight} size="24" mini />
|
||||
{/snippet}
|
||||
</Button>
|
||||
</nav>
|
||||
@@ -4,18 +4,15 @@
|
||||
import { Icon, type IconSource } from 'svelte-hero-icons'
|
||||
import { dockProps } from '../layout/Shell.svelte'
|
||||
|
||||
|
||||
|
||||
|
||||
interface Props {
|
||||
label: string;
|
||||
icon?: IconSource | undefined;
|
||||
href?: string | undefined;
|
||||
adaptive?: boolean;
|
||||
isSelectedFilter?: (path: string) => boolean;
|
||||
class?: string;
|
||||
customIcon?: import('svelte').Snippet<[any]>;
|
||||
children?: import('svelte').Snippet;
|
||||
label: string
|
||||
icon?: IconSource | undefined
|
||||
href?: string | undefined
|
||||
adaptive?: boolean
|
||||
isSelectedFilter?: (path: string) => boolean
|
||||
class?: string
|
||||
customIcon?: import('svelte').Snippet<[any]>
|
||||
children?: import('svelte').Snippet
|
||||
[key: string]: any
|
||||
}
|
||||
|
||||
@@ -24,14 +21,13 @@
|
||||
icon = undefined,
|
||||
href = undefined,
|
||||
adaptive = true,
|
||||
isSelectedFilter = (path) =>
|
||||
href != undefined && path == href,
|
||||
isSelectedFilter = (path) => href != undefined && path == href,
|
||||
class: clazz = '',
|
||||
customIcon,
|
||||
children,
|
||||
...rest
|
||||
}: Props = $props();
|
||||
|
||||
}: Props = $props()
|
||||
|
||||
let isSelected = $derived(isSelectedFilter($page.url.pathname))
|
||||
let isPanel = $derived(adaptive ? $dockProps.noGap : false)
|
||||
</script>
|
||||
@@ -39,7 +35,7 @@
|
||||
<Button
|
||||
color={isPanel ? 'secondary' : 'tertiary'}
|
||||
{...rest}
|
||||
on:click
|
||||
onclick
|
||||
on:contextmenu
|
||||
class="rounded-full w-10 h-10 flex-shrink-0 {adaptive
|
||||
? '@3xl:h-8 @3xl:px-3 @3xl:rounded-[10px] @3xl:w-auto'
|
||||
@@ -60,7 +56,7 @@
|
||||
size={isPanel ? '16' : '18'}
|
||||
/>
|
||||
{:else}
|
||||
{@render customIcon?.({ size: isPanel ? 16 : 18, isSelected, })}
|
||||
{@render customIcon?.({ size: isPanel ? 16 : 18, isSelected })}
|
||||
{/if}
|
||||
<span class="hidden {adaptive ? '@3xl:block' : ''}">{label}</span>
|
||||
{@render children?.()}
|
||||
|
||||
@@ -209,7 +209,7 @@
|
||||
</button>
|
||||
</div>
|
||||
<Button
|
||||
on:click={() => (showInstance = !showInstance)}
|
||||
onclick={() => (showInstance = !showInstance)}
|
||||
color="tertiary"
|
||||
title={$t('nav.menu.instance')}
|
||||
size="square-md"
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
<Button
|
||||
href={action.href}
|
||||
on:click
|
||||
onclick
|
||||
alignment="left"
|
||||
color="tertiary"
|
||||
size="lg"
|
||||
|
||||
@@ -278,7 +278,7 @@
|
||||
<li>
|
||||
<CommandItem
|
||||
{action}
|
||||
on:click={(e) => {
|
||||
onclick={(e) => {
|
||||
if (action.href) {
|
||||
togglePalette()
|
||||
return
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
class="hidden group-hover:inline-flex opacity-0 group-hover:opacity-100 transition-all z-20
|
||||
items-center justify-center box-border w-7 h-7"
|
||||
style="grid-column: 1; grid-row: 1;"
|
||||
on:click={() => addFavorite(follow)}
|
||||
onclick={() => addFavorite(follow)}
|
||||
>
|
||||
<Icon src={Star} size="16" mini />
|
||||
</Button>
|
||||
@@ -43,7 +43,7 @@
|
||||
class="hidden group-hover:inline-flex opacity-0 group-hover:opacity-100 transition-all z-20
|
||||
items-center justify-center box-border w-7 h-7"
|
||||
style="grid-column: 1; grid-row: 1;"
|
||||
on:click={() => addFavorite(follow, false)}
|
||||
onclick={() => addFavorite(follow, false)}
|
||||
>
|
||||
<Icon src={Trash} size="16" mini />
|
||||
</Button>
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
loading={switching}
|
||||
loaderWidth={20}
|
||||
selected={$profile?.id == prof.id}
|
||||
on:click={async () => {
|
||||
onclick={async () => {
|
||||
switching = true
|
||||
|
||||
if ($profile?.id != prof.id) {
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
{#each settings.dock.pins as pin}
|
||||
<SidebarButton
|
||||
icon={iconOfLink(pin.url)}
|
||||
on:click={() => goto(pin.url)}
|
||||
onclick={() => goto(pin.url)}
|
||||
alignment="center"
|
||||
selected={`${$page.url.pathname}${$page.url.search}` == pin.url}
|
||||
on:contextmenu={(e) => {
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
alignment="left"
|
||||
{...rest}
|
||||
{href}
|
||||
on:click
|
||||
onclick
|
||||
on:contextmenu
|
||||
class="font-normal block !origin-left border border-transparent {!selected
|
||||
? 'text-slate-600 dark:text-zinc-400'
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
in:fly={{ duration: 300, easing: expoOut, y: 6, delay: 100 }}
|
||||
>
|
||||
<Button
|
||||
on:click={() => {
|
||||
onclick={() => {
|
||||
filters.clear()
|
||||
filters = filters
|
||||
}}
|
||||
@@ -51,7 +51,7 @@
|
||||
{/if}
|
||||
{#each uniqueIds as id}
|
||||
<Button
|
||||
on:click={() => {
|
||||
onclick={() => {
|
||||
if (filters.has(id)) filters.delete(id)
|
||||
else filters.add(id)
|
||||
filters = filters
|
||||
|
||||
@@ -65,9 +65,6 @@
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import { createBubbler } from 'svelte/legacy';
|
||||
|
||||
const bubble = createBubbler();
|
||||
import Spinner from '../loader/Spinner.svelte'
|
||||
|
||||
type ButtonRoundness = 'pill' | 'xl' | 'lg' | 'md' | 'none'
|
||||
@@ -115,27 +112,23 @@
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
interface Props {
|
||||
loading?: boolean;
|
||||
submit?: boolean;
|
||||
color?: ButtonColor;
|
||||
size?: ButtonSize;
|
||||
rounding?: ButtonRoundness;
|
||||
roundingSide?: ButtonRoundingSide;
|
||||
alignment?: ButtonAlignment;
|
||||
shadow?: ButtonShadow;
|
||||
column?: boolean;
|
||||
animations?: any;
|
||||
loaderWidth?: number | undefined;
|
||||
href?: string | undefined;
|
||||
class?: string;
|
||||
prefix?: import('svelte').Snippet;
|
||||
children?: import('svelte').Snippet;
|
||||
suffix?: import('svelte').Snippet;
|
||||
loading?: boolean
|
||||
submit?: boolean
|
||||
color?: ButtonColor
|
||||
size?: ButtonSize
|
||||
rounding?: ButtonRoundness
|
||||
roundingSide?: ButtonRoundingSide
|
||||
alignment?: ButtonAlignment
|
||||
shadow?: ButtonShadow
|
||||
column?: boolean
|
||||
animations?: any
|
||||
loaderWidth?: number | undefined
|
||||
href?: string | undefined
|
||||
class?: string
|
||||
prefix?: import('svelte').Snippet
|
||||
children?: import('svelte').Snippet
|
||||
suffix?: import('svelte').Snippet
|
||||
[key: string]: any
|
||||
}
|
||||
|
||||
@@ -150,9 +143,9 @@
|
||||
shadow = 'none',
|
||||
column = false,
|
||||
animations = {
|
||||
scale: false,
|
||||
large: false,
|
||||
},
|
||||
scale: false,
|
||||
large: false,
|
||||
},
|
||||
loaderWidth = undefined,
|
||||
href = undefined,
|
||||
class: clazz = '',
|
||||
@@ -160,8 +153,7 @@
|
||||
children,
|
||||
suffix,
|
||||
...rest
|
||||
}: Props = $props();
|
||||
|
||||
}: Props = $props()
|
||||
</script>
|
||||
|
||||
<svelte:element
|
||||
@@ -169,12 +161,6 @@
|
||||
role={href ? 'link' : 'button'}
|
||||
{href}
|
||||
{...rest}
|
||||
onclick={bubble('click')}
|
||||
oncontextmenu={bubble('contextmenu')}
|
||||
ondrag={bubble('drag')}
|
||||
ondrop={bubble('drop')}
|
||||
ondragstart={bubble('dragstart')}
|
||||
ondragend={bubble('dragend')}
|
||||
class="
|
||||
{loading ? buttonColor.secondary : buttonColor[color]}
|
||||
{buttonSize[size]}
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
import { Check, Icon, Clipboard } from 'svelte-hero-icons'
|
||||
import { scale } from 'svelte/transition'
|
||||
|
||||
|
||||
let copied = $state(false)
|
||||
|
||||
let pre: HTMLPreElement = $state()
|
||||
@@ -18,11 +17,11 @@
|
||||
}
|
||||
|
||||
interface Props {
|
||||
src: string;
|
||||
filename?: string | undefined;
|
||||
htmlSrc?: string | undefined;
|
||||
children?: import('svelte').Snippet;
|
||||
class?: string;
|
||||
src: string
|
||||
filename?: string | undefined
|
||||
htmlSrc?: string | undefined
|
||||
children?: import('svelte').Snippet
|
||||
class?: string
|
||||
[key: string]: any
|
||||
}
|
||||
|
||||
@@ -33,8 +32,7 @@
|
||||
children,
|
||||
class: clazz = '',
|
||||
...rest
|
||||
}: Props = $props();
|
||||
|
||||
}: Props = $props()
|
||||
</script>
|
||||
|
||||
<Material
|
||||
@@ -51,7 +49,7 @@
|
||||
size="square-sm"
|
||||
color="tertiary"
|
||||
aria-label="Copy"
|
||||
on:click={() => {
|
||||
onclick={() => {
|
||||
copied = true
|
||||
copy()
|
||||
setTimeout(() => (copied = false), 2000)
|
||||
|
||||
@@ -3,21 +3,18 @@
|
||||
import { Check, Icon, Clipboard } from 'svelte-hero-icons'
|
||||
import { scale } from 'svelte/transition'
|
||||
|
||||
|
||||
|
||||
let copied = $state(false)
|
||||
|
||||
interface Props {
|
||||
/**
|
||||
* Show a copy button.
|
||||
*/
|
||||
value: string;
|
||||
copy?: boolean;
|
||||
class?: string;
|
||||
* Show a copy button.
|
||||
*/
|
||||
value: string
|
||||
copy?: boolean
|
||||
class?: string
|
||||
}
|
||||
|
||||
let { value, copy = true, class: clazz = '' }: Props = $props();
|
||||
|
||||
let { value, copy = true, class: clazz = '' }: Props = $props()
|
||||
</script>
|
||||
|
||||
<div
|
||||
@@ -32,7 +29,7 @@
|
||||
size="square-md"
|
||||
color="tertiary"
|
||||
aria-label="Copy"
|
||||
on:click={() => {
|
||||
onclick={() => {
|
||||
copied = true
|
||||
navigator.clipboard.writeText(value)
|
||||
setTimeout(() => (copied = false), 2000)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { run, createBubbler } from 'svelte/legacy';
|
||||
import { run, createBubbler } from 'svelte/legacy'
|
||||
|
||||
const bubble = createBubbler();
|
||||
const bubble = createBubbler()
|
||||
import {
|
||||
buttonColor,
|
||||
buttonSize,
|
||||
@@ -24,12 +24,11 @@
|
||||
|
||||
type T = $$Generic
|
||||
|
||||
|
||||
|
||||
let open = $state(false)
|
||||
let element: HTMLSelectElement | undefined = $state()
|
||||
|
||||
let options: { value: any; label: string | null; disabled: boolean }[] = $state([])
|
||||
let options: { value: any; label: string | null; disabled: boolean }[] =
|
||||
$state([])
|
||||
|
||||
// Capture all options from the select element
|
||||
run(() => {
|
||||
@@ -40,7 +39,7 @@
|
||||
disabled: option.disabled,
|
||||
}))
|
||||
: []
|
||||
});
|
||||
})
|
||||
|
||||
const dispatcher = createEventDispatcher<{
|
||||
change: any
|
||||
@@ -48,16 +47,16 @@
|
||||
input: any
|
||||
}>()
|
||||
interface Props {
|
||||
value?: T | undefined;
|
||||
placeholder?: string | undefined;
|
||||
label?: string | undefined;
|
||||
size?: ButtonSize;
|
||||
shadow?: ButtonShadow;
|
||||
id?: string;
|
||||
class?: string;
|
||||
customLabel?: import('svelte').Snippet;
|
||||
children?: import('svelte').Snippet;
|
||||
customOption?: import('svelte').Snippet<[any]>;
|
||||
value?: T | undefined
|
||||
placeholder?: string | undefined
|
||||
label?: string | undefined
|
||||
size?: ButtonSize
|
||||
shadow?: ButtonShadow
|
||||
id?: string
|
||||
class?: string
|
||||
customLabel?: import('svelte').Snippet
|
||||
children?: import('svelte').Snippet
|
||||
customOption?: import('svelte').Snippet<[any]>
|
||||
}
|
||||
|
||||
let {
|
||||
@@ -70,9 +69,8 @@
|
||||
class: clazz = '',
|
||||
customLabel,
|
||||
children,
|
||||
customOption
|
||||
}: Props = $props();
|
||||
|
||||
customOption,
|
||||
}: Props = $props()
|
||||
</script>
|
||||
|
||||
<div class="flex flex-col gap-1 {clazz}">
|
||||
@@ -85,8 +83,7 @@
|
||||
<div class="w-full relative">
|
||||
<Menu bind:open>
|
||||
{#snippet target()}
|
||||
<select
|
||||
|
||||
<select
|
||||
{id}
|
||||
bind:this={element}
|
||||
class="{buttonSize[size]} {buttonShadow[
|
||||
@@ -96,12 +93,12 @@
|
||||
{clazz}"
|
||||
bind:value
|
||||
onmousedown={(e) => {
|
||||
e.preventDefault()
|
||||
}}
|
||||
e.preventDefault()
|
||||
}}
|
||||
onkeypress={(e) => {
|
||||
e.preventDefault()
|
||||
open = !open
|
||||
}}
|
||||
e.preventDefault()
|
||||
open = !open
|
||||
}}
|
||||
onchange={bubble('change')}
|
||||
oncontextmenu={bubble('contextmenu')}
|
||||
{placeholder}
|
||||
@@ -111,13 +108,16 @@
|
||||
{/if}
|
||||
{@render children?.()}
|
||||
</select>
|
||||
{/snippet}
|
||||
{/snippet}
|
||||
|
||||
{#each options as option}
|
||||
{#if customOption}{@render customOption({ option, selected: option.value == value, })}{:else}
|
||||
{#if customOption}{@render customOption({
|
||||
option,
|
||||
selected: option.value == value,
|
||||
})}{:else}
|
||||
<MenuButton
|
||||
on:contextmenu={() => dispatcher('contextmenu')}
|
||||
on:click={() => {
|
||||
onclick={() => {
|
||||
value = option.value
|
||||
dispatcher('change')
|
||||
}}
|
||||
|
||||
@@ -8,13 +8,13 @@
|
||||
import Portal from '../popover/Portal.svelte'
|
||||
|
||||
interface Props {
|
||||
action?: string | undefined;
|
||||
open?: boolean;
|
||||
title?: string | undefined;
|
||||
dismissable?: boolean;
|
||||
customTitle?: import('svelte').Snippet;
|
||||
children?: import('svelte').Snippet;
|
||||
actions?: import('svelte').Snippet<[any]>;
|
||||
action?: string | undefined
|
||||
open?: boolean
|
||||
title?: string | undefined
|
||||
dismissable?: boolean
|
||||
customTitle?: import('svelte').Snippet
|
||||
children?: import('svelte').Snippet
|
||||
actions?: import('svelte').Snippet<[any]>
|
||||
}
|
||||
|
||||
let {
|
||||
@@ -24,8 +24,8 @@
|
||||
dismissable = true,
|
||||
customTitle,
|
||||
children,
|
||||
actions
|
||||
}: Props = $props();
|
||||
actions,
|
||||
}: Props = $props()
|
||||
|
||||
let el: any = $state()
|
||||
|
||||
@@ -70,14 +70,14 @@ bg-white/50 dark:bg-black/50 box-border p-4"
|
||||
class="absolute top-0 right-0 m-2 text-slate-600 dark:text-zinc-400"
|
||||
color="tertiary"
|
||||
size="square-sm"
|
||||
on:click={() => {
|
||||
onclick={() => {
|
||||
open = false
|
||||
dispatcher('dismissed')
|
||||
}}
|
||||
>
|
||||
{#snippet prefix()}
|
||||
<Icon src={XMark} size="20" mini />
|
||||
{/snippet}
|
||||
<Icon src={XMark} size="20" mini />
|
||||
{/snippet}
|
||||
</Button>
|
||||
{/if}
|
||||
<h1 class="font-semibold text-xl max-w-full">
|
||||
@@ -90,10 +90,10 @@ bg-white/50 dark:bg-black/50 box-border p-4"
|
||||
{@render children?.()}
|
||||
{#if action}
|
||||
<div class="mt-2 flex w-full">
|
||||
{#if actions}{@render actions({ action, })}{:else}
|
||||
{#if actions}{@render actions({ action })}{:else}
|
||||
<Button
|
||||
class="w-full"
|
||||
on:click={(e) => {
|
||||
onclick={(e) => {
|
||||
dispatcher('action', e)
|
||||
open = false
|
||||
dispatcher('dismissed')
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { run } from 'svelte/legacy';
|
||||
import { run } from 'svelte/legacy'
|
||||
|
||||
import Button from '../button/Button.svelte'
|
||||
import Modal from '../modal/Modal.svelte'
|
||||
@@ -11,7 +11,7 @@
|
||||
// reactivity hack
|
||||
run(() => {
|
||||
open = $shownModal ? true : false
|
||||
});
|
||||
})
|
||||
</script>
|
||||
|
||||
{#if $shownModal}
|
||||
@@ -32,7 +32,7 @@
|
||||
<Button
|
||||
size="lg"
|
||||
class="flex-1 w-full"
|
||||
on:click={action.action}
|
||||
onclick={action.action}
|
||||
color={action.type}
|
||||
>
|
||||
{#if action.icon}
|
||||
|
||||
@@ -34,7 +34,6 @@
|
||||
|
||||
<Button
|
||||
{...rest}
|
||||
on:click
|
||||
{color}
|
||||
rounding="none"
|
||||
class="w-full px-2 rounded-lg min-h-[36px] font-normal {disabled
|
||||
|
||||
@@ -4,12 +4,9 @@
|
||||
import { createEventDispatcher } from 'svelte'
|
||||
import { Icon, MagnifyingGlass } from 'svelte-hero-icons'
|
||||
|
||||
|
||||
type T = $$Generic
|
||||
let items: T[] = $state([])
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This is here so that the menu doesn't open as soon as it's mounted.
|
||||
*/
|
||||
@@ -22,14 +19,14 @@
|
||||
}>()
|
||||
|
||||
interface Props {
|
||||
query?: string;
|
||||
selected?: T | undefined;
|
||||
search: (query: string) => Promise<T[]>;
|
||||
extractName: (item: T) => string;
|
||||
select?: any;
|
||||
input?: import('svelte').Snippet;
|
||||
noresults?: import('svelte').Snippet;
|
||||
children?: import('svelte').Snippet<[any]>;
|
||||
query?: string
|
||||
selected?: T | undefined
|
||||
search: (query: string) => Promise<T[]>
|
||||
extractName: (item: T) => string
|
||||
select?: any
|
||||
input?: import('svelte').Snippet
|
||||
noresults?: import('svelte').Snippet
|
||||
children?: import('svelte').Snippet<[any]>
|
||||
[key: string]: any
|
||||
}
|
||||
|
||||
@@ -39,15 +36,15 @@
|
||||
search,
|
||||
extractName,
|
||||
select = (item: T) => {
|
||||
selected = item
|
||||
query = extractName(item)
|
||||
dispatcher('select', item)
|
||||
},
|
||||
selected = item
|
||||
query = extractName(item)
|
||||
dispatcher('select', item)
|
||||
},
|
||||
input,
|
||||
noresults,
|
||||
children,
|
||||
...rest
|
||||
}: Props = $props();
|
||||
}: Props = $props()
|
||||
|
||||
const debounceFunc = debounce(async () => {
|
||||
searching = true
|
||||
@@ -60,7 +57,7 @@
|
||||
<div class="relative">
|
||||
<Menu bind:open={openMenu}>
|
||||
{#snippet target()}
|
||||
{#if input}{@render input()}{:else}
|
||||
{#if input}{@render input()}{:else}
|
||||
<TextInput
|
||||
bind:value={query}
|
||||
on:input={(e) => {
|
||||
@@ -79,13 +76,13 @@
|
||||
inlineAffixes
|
||||
>
|
||||
{#snippet prefix()}
|
||||
<div class="h-5 flex items-center">
|
||||
<div class="h-5 flex items-center">
|
||||
<Icon src={MagnifyingGlass} mini size="16" />
|
||||
</div>
|
||||
{/snippet}
|
||||
{/snippet}
|
||||
</TextInput>
|
||||
{/if}
|
||||
{/snippet}
|
||||
{/snippet}
|
||||
{#if searching}
|
||||
<div class="w-full h-24 grid place-items-center">
|
||||
<Spinner width={24} />
|
||||
@@ -96,8 +93,13 @@
|
||||
</div>
|
||||
{:else}
|
||||
{#each items as item}
|
||||
{#if children}{@render children({ extractName, item, dispatcher, select, })}{:else}
|
||||
<MenuButton on:click={() => select(item)}>
|
||||
{#if children}{@render children({
|
||||
extractName,
|
||||
item,
|
||||
dispatcher,
|
||||
select,
|
||||
})}{:else}
|
||||
<MenuButton onclick={() => select(item)}>
|
||||
{extractName(item)}
|
||||
</MenuButton>
|
||||
{/if}
|
||||
|
||||
Reference in new issue
Block a user