fuma 2.0.22 → 2.0.23

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.
@@ -44,20 +44,21 @@
44
44
  let focusIndex = 0
45
45
  let searchValue = ''
46
46
 
47
- const dispatch = createEventDispatcher<{ input: { value: RelationItem | null } }>()
47
+ const dispatch = createEventDispatcher<{
48
+ input: { value: RelationItem | null; focus: () => void }
49
+ }>()
48
50
 
49
- export function clear() {
51
+ export async function clear() {
50
52
  searchValue = ''
51
53
  item = null
52
- dispatch('input', { value: item })
53
- return {
54
- focus: () => inputElement.focus()
55
- }
54
+ dispatch('input', { value: item, focus: () => inputElement.focus() })
55
+ await tick()
56
+ inputElement.focus()
56
57
  }
57
58
 
58
59
  export async function select(index = focusIndex) {
59
60
  item = proposedItems[index]
60
- dispatch('input', { value: item })
61
+ dispatch('input', { value: item, focus: () => inputElement.focus() })
61
62
  }
62
63
 
63
64
  export async function searchItems(searchValue = '') {
@@ -116,7 +117,7 @@
116
117
  {:else}
117
118
  <button
118
119
  type="button"
119
- on:click|stopPropagation={() => clear().focus()}
120
+ on:click|stopPropagation={() => clear()}
120
121
  class="input h-auto min-h-10 w-full grow items-start pt-2 pr-2"
121
122
  >
122
123
  {@render slotItem(item)}
@@ -27,15 +27,14 @@ declare class __sveltets_Render<RelationItem extends {
27
27
  class?: string;
28
28
  classList?: string;
29
29
  inputElement: HTMLInputElement;
30
- clear?: (() => {
31
- focus: () => void;
32
- }) | undefined;
30
+ clear?: (() => Promise<void>) | undefined;
33
31
  select?: ((index?: number) => Promise<void>) | undefined;
34
32
  searchItems?: ((searchValue?: string) => Promise<void>) | undefined;
35
33
  };
36
34
  events(): {
37
35
  input: CustomEvent<{
38
36
  value: RelationItem | null;
37
+ focus: () => void;
39
38
  }>;
40
39
  } & {
41
40
  [evt: string]: CustomEvent<any>;
@@ -43,9 +42,7 @@ declare class __sveltets_Render<RelationItem extends {
43
42
  slots(): {};
44
43
  bindings(): string;
45
44
  exports(): {
46
- clear: () => {
47
- focus: () => void;
48
- };
45
+ clear: () => Promise<void>;
49
46
  select: (index?: number) => Promise<void>;
50
47
  searchItems: (searchValue?: string) => Promise<void>;
51
48
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fuma",
3
- "version": "2.0.22",
3
+ "version": "2.0.23",
4
4
  "description": "My fullstack material build with sveltekit, daisyui, zod, prisma, lucia",
5
5
  "author": {
6
6
  "name": "Jonas Voisard",