fuma 2.0.37 → 2.0.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
<script lang="ts" generics="RelationItem extends {id: string | number}">
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
createEventDispatcher,
|
|
4
|
+
tick,
|
|
5
|
+
type Component,
|
|
6
|
+
type ComponentProps,
|
|
7
|
+
type Snippet
|
|
8
|
+
} from 'svelte'
|
|
3
9
|
import type { HTMLInputAttributes } from 'svelte/elements'
|
|
4
10
|
import debounce from 'debounce'
|
|
5
11
|
import { toast } from 'svelte-sonner'
|
|
6
12
|
|
|
7
13
|
import { USE_COERCE_JSON } from '../../utils/constant.js'
|
|
8
|
-
import { Icon } from '../icon/index.js'
|
|
9
14
|
import { DropDown } from '../menu/index.js'
|
|
10
15
|
import { FormControl, SelectorList } from './index.js'
|
|
11
16
|
import type { TippyProps } from '../../utils/tippy.js'
|
|
@@ -31,6 +36,8 @@
|
|
|
31
36
|
export let input: HTMLInputAttributes | undefined = undefined
|
|
32
37
|
export let append: Snippet | undefined = undefined
|
|
33
38
|
export let disabled = false
|
|
39
|
+
export let shortcutKey = ''
|
|
40
|
+
export let Icon: Component<{ class: string }> | undefined = undefined
|
|
34
41
|
|
|
35
42
|
let klass = ''
|
|
36
43
|
export { klass as class }
|
|
@@ -95,26 +102,30 @@
|
|
|
95
102
|
<div class="contents" slot="activator">
|
|
96
103
|
<FormControl {key} {label} {error} class={klass}>
|
|
97
104
|
{#snippet children({ key })}
|
|
98
|
-
<
|
|
99
|
-
<
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
105
|
+
<label class="input" class:hidden={item}>
|
|
106
|
+
<svelte:component this={Icon} class="h-5 w-5 shrink-0 opacity-70" />
|
|
107
|
+
<input
|
|
108
|
+
type="text"
|
|
109
|
+
id={key}
|
|
110
|
+
bind:this={inputElement}
|
|
111
|
+
bind:value={searchValue}
|
|
112
|
+
on:input={(e) => searchItemsDebounce(e.currentTarget.value)}
|
|
113
|
+
on:focus={handleFocus}
|
|
114
|
+
on:blur={handleBlur}
|
|
115
|
+
autocomplete="off"
|
|
116
|
+
{placeholder}
|
|
117
|
+
class="grow"
|
|
118
|
+
size={8}
|
|
119
|
+
{...input}
|
|
120
|
+
/>
|
|
121
|
+
<RelationAfter {isLoading} {createUrl} {createTitle} {createIcon} />
|
|
122
|
+
{#if shortcutKey}
|
|
123
|
+
<kbd class="kbd kbd-xs text-base-content/50 shrink-0">
|
|
124
|
+
{shortcutKey}
|
|
125
|
+
</kbd>
|
|
126
|
+
{/if}
|
|
127
|
+
</label>
|
|
128
|
+
{@render append?.()}
|
|
118
129
|
|
|
119
130
|
{#if item}
|
|
120
131
|
{#if noSlotItemWrapper}
|
|
@@ -126,7 +137,11 @@
|
|
|
126
137
|
on:click|stopPropagation={() => clear()}
|
|
127
138
|
class="input h-auto min-h-10 w-full grow items-start pt-2 pr-2"
|
|
128
139
|
>
|
|
140
|
+
<svelte:component this={Icon} class="h-5 opacity-70" />
|
|
129
141
|
{@render slotItem(item)}
|
|
142
|
+
{#if shortcutKey}
|
|
143
|
+
<kbd class="kbd kbd-xs text-base-content/50">{shortcutKey}</kbd>
|
|
144
|
+
{/if}
|
|
130
145
|
</button>
|
|
131
146
|
{/if}
|
|
132
147
|
<input
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ComponentProps, type Snippet } from 'svelte';
|
|
1
|
+
import { type Component, type ComponentProps, type Snippet } from 'svelte';
|
|
2
2
|
import type { HTMLInputAttributes } from 'svelte/elements';
|
|
3
3
|
import { DropDown } from '../menu/index.js';
|
|
4
4
|
import type { TippyProps } from '../../utils/tippy.js';
|
|
@@ -25,6 +25,10 @@ declare class __sveltets_Render<RelationItem extends {
|
|
|
25
25
|
input?: HTMLInputAttributes | undefined;
|
|
26
26
|
append?: Snippet | undefined;
|
|
27
27
|
disabled?: boolean;
|
|
28
|
+
shortcutKey?: string;
|
|
29
|
+
Icon?: Component<{
|
|
30
|
+
class: string;
|
|
31
|
+
}, {}, string> | undefined;
|
|
28
32
|
class?: string;
|
|
29
33
|
classList?: string;
|
|
30
34
|
inputElement?: HTMLInputElement | undefined;
|