feat: add more moderator actions
This commit is contained in:
1 parent
5507cf8254
commit
22ce7bf39e
6 files changed
+96
-6
No files matched your search
@@ -13,6 +13,8 @@
|
||||
export let extractSelected: (item: T | null) => any
|
||||
export let extractName: (item: T) => string
|
||||
export let showWhenEmpty: boolean = false
|
||||
let canSearch: boolean = false
|
||||
export { canSearch as searchOnMount }
|
||||
|
||||
const debounce = (fn: Function, ms = 300) => {
|
||||
let timeoutId: ReturnType<typeof setTimeout>
|
||||
@@ -25,6 +27,7 @@
|
||||
const dispatcher = createEventDispatcher<{ search: string }>()
|
||||
|
||||
const debounceFunc = debounce(() => {
|
||||
canSearch = true
|
||||
dispatcher('search', query)
|
||||
}, debounceTime)
|
||||
</script>
|
||||
@@ -38,8 +41,11 @@
|
||||
}}
|
||||
{...$$restProps}
|
||||
/>
|
||||
<Menu open={options.length != 0 || showWhenEmpty} alignment="bottom-left">
|
||||
{#if query == ''}
|
||||
<Menu
|
||||
open={(options.length != 0 || showWhenEmpty) && canSearch}
|
||||
alignment="bottom-left"
|
||||
>
|
||||
{#if query == '' && showWhenEmpty}
|
||||
<slot {extractName} {extractSelected} {query} />
|
||||
{:else}
|
||||
{#each options as option}
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
on:keydown={(e) => dispatcher('keydown', e)}
|
||||
on:input={(e) => dispatcher('input', e)}
|
||||
on:change={(e) => dispatcher('change', e)}
|
||||
on:focus
|
||||
{...$$restProps}
|
||||
class={className}
|
||||
{required}
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
export let jwt: string | undefined = undefined
|
||||
export let listing_type: ListingType = 'Subscribed'
|
||||
export let items: Community[] | undefined = undefined
|
||||
export let showWhenEmpty: boolean = false
|
||||
let showNone: boolean = false
|
||||
|
||||
const dispatcher = createEventDispatcher<{ select: Community }>()
|
||||
@@ -45,11 +46,11 @@
|
||||
let:extractName
|
||||
let:extractSelected
|
||||
let:option
|
||||
showWhenEmpty
|
||||
{showWhenEmpty}
|
||||
{...$$restProps}
|
||||
let:query
|
||||
>
|
||||
{#if query == ''}
|
||||
{#if query == '' && showWhenEmpty}
|
||||
<MenuButton on:click={() => dispatcher('select', undefined)}>
|
||||
<Icon src={XCircle} size="16" mini />
|
||||
<div class="flex flex-col text-left">
|
||||
|
||||
Reference in new issue
Block a user