fuma 0.1.11 → 0.1.13

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.
@@ -2,7 +2,7 @@
2
2
  import { onMount } from "svelte";
3
3
  export let path;
4
4
  export let title = "";
5
- export let size = 24;
5
+ export let size = 22;
6
6
  let klass = "";
7
7
  export { klass as class };
8
8
  export let style = "";
@@ -30,7 +30,7 @@ async function select(index = focusIndex) {
30
30
  }
31
31
  </script>
32
32
 
33
- <DropDown {tippyProps}>
33
+ <DropDown {tippyProps} isWidthOfActivator>
34
34
  <div class="contents" slot="activator">
35
35
  <FormControl {...props} let:key>
36
36
  <div class="flex grow gap-2" class:hidden={selectedOption}>
@@ -4,11 +4,11 @@ import { toast } from "svelte-sonner";
4
4
  import { mdiClose } from "@mdi/js";
5
5
  import { FormControl, DropDown, Icon, SelectorList, Slot } from "../index.js";
6
6
  import RelationAfter from "./RelationAfter.svelte";
7
- export let key = "";
7
+ export let key = Math.random().toString();
8
8
  export let label = "";
9
9
  export let search;
10
10
  export let createUrl = "";
11
- export let createTitle = "";
11
+ export let createTitle = "Nouveau";
12
12
  let item = null;
13
13
  export { item as value };
14
14
  export let error = "";
@@ -60,15 +60,15 @@ async function handleBlur() {
60
60
  }
61
61
  </script>
62
62
 
63
- <DropDown {tippyProps} disable={flatMode}>
63
+ <DropDown {tippyProps} disable={flatMode} isWidthOfActivator>
64
64
  <div class="contents" slot="activator">
65
65
  <FormControl {key} {label} {error} class={klass} let:key>
66
66
  <div class="flex grow gap-2" class:hidden={item}>
67
- <div class="relative flex grow items-center gap-2">
67
+ <div class="input input-bordered flex grow items-center pr-2">
68
68
  <input
69
69
  type="text"
70
- id={key}
71
70
  name={key}
71
+ id={key}
72
72
  bind:this={inputElement}
73
73
  bind:value={searchValue}
74
74
  on:input={(e) => searchItemsDebounce(e.currentTarget.value)}
@@ -76,7 +76,7 @@ async function handleBlur() {
76
76
  on:blur={handleBlur}
77
77
  autocomplete="off"
78
78
  {placeholder}
79
- class="input input-bordered grow"
79
+ class="grow"
80
80
  />
81
81
 
82
82
  <RelationAfter {isLoading} {createUrl} {createTitle} />
@@ -73,7 +73,7 @@ async function handleBlur() {
73
73
  }
74
74
  </script>
75
75
 
76
- <DropDown bind:this={dropdown} disable={flatMode}>
76
+ <DropDown bind:this={dropdown} disable={flatMode} isWidthOfActivator>
77
77
  <div slot="activator">
78
78
  <FormControl {key} {label} {error} class={klass}>
79
79
  <div class="flex flex-col gap-2">
@@ -103,7 +103,7 @@ async function handleBlur() {
103
103
  </div>
104
104
  {/if}
105
105
  <div class="flex grow gap-2">
106
- <div class="relative flex grow items-center gap-2">
106
+ <div class="input input-bordered flex grow items-center pr-2">
107
107
  <input
108
108
  type="text"
109
109
  id={key}
@@ -115,7 +115,7 @@ async function handleBlur() {
115
115
  on:blur={handleBlur}
116
116
  autocomplete="off"
117
117
  {placeholder}
118
- class="input input-bordered grow"
118
+ class="grow"
119
119
  />
120
120
 
121
121
  <RelationAfter {isLoading} {createUrl} {createTitle} />
@@ -25,7 +25,7 @@ function onSelect(index) {
25
25
  }
26
26
  </script>
27
27
 
28
- <DropDown bind:this={dropDown}>
28
+ <DropDown bind:this={dropDown} isWidthOfActivator>
29
29
  <div class="contents" slot="activator">
30
30
  <FormControl {...props} let:key>
31
31
  <button
@@ -1,16 +1,15 @@
1
1
  <script>import { fade } from "svelte/transition";
2
2
  import { createEventDispatcher } from "svelte";
3
- import { mdiClose, mdiLoading, mdiPlus } from "@mdi/js";
3
+ import { mdiLoading, mdiPlus } from "@mdi/js";
4
4
  import Icon from "../Icon.svelte";
5
5
  export let isLoading;
6
- export let isUnselectable = false;
7
6
  export let createUrl = "";
8
7
  export let createTitle = "";
9
8
  const dispatch = createEventDispatcher();
10
9
  </script>
11
10
 
12
11
  {#if isLoading}
13
- <div class="absolute right-1" class:right-10={createUrl} transition:fade|local>
12
+ <div class:right-10={createUrl} transition:fade|local>
14
13
  <Icon
15
14
  path={mdiLoading}
16
15
  class="w-9"
@@ -19,24 +18,8 @@ const dispatch = createEventDispatcher();
19
18
  </div>
20
19
  {/if}
21
20
 
22
- {#if isUnselectable}
23
- <div class="ml-[4px] hidden -translate-x-[2px] group-hover:block">
24
- <Icon
25
- path={mdiClose}
26
- on:click={() => dispatch('unselect')}
27
- title="Supprimer la sélection"
28
- class="outline-primary-light outline outline-2 hover:bg-primary"
29
- />
30
- </div>
31
- {/if}
32
-
33
21
  {#if createUrl}
34
- <div class="ml-[4px] -translate-x-[2px]">
35
- <Icon
36
- path={mdiPlus}
37
- on:click={() => dispatch('create')}
38
- title={createTitle}
39
- class="btn btn-square"
40
- />
41
- </div>
22
+ <a href={createUrl} class="btn btn-square btn-sm">
23
+ <Icon path={mdiPlus} on:click={() => dispatch('create')} title={createTitle} />
24
+ </a>
42
25
  {/if}
@@ -2,7 +2,6 @@ import { SvelteComponent } from "svelte";
2
2
  declare const __propDef: {
3
3
  props: {
4
4
  isLoading: boolean;
5
- isUnselectable?: boolean | undefined;
6
5
  createUrl?: string | undefined;
7
6
  createTitle?: string | undefined;
8
7
  };
@@ -26,6 +26,7 @@ export let hideOnNav = true;
26
26
  export let tip = void 0;
27
27
  export let disable = false;
28
28
  export let content = void 0;
29
+ export let isWidthOfActivator = false;
29
30
  let activator;
30
31
  beforeNavigate(() => hideOnNav && hide());
31
32
  onMount(() => {
@@ -47,6 +48,7 @@ onMount(() => {
47
48
  interactive: true,
48
49
  interactiveDebounce: 50,
49
50
  appendTo: "parent",
51
+ hideOnClick: false,
50
52
  onShown() {
51
53
  if (autofocus)
52
54
  focusables[0]?.select();
@@ -93,6 +95,7 @@ export function setTippyProps(props) {
93
95
 
94
96
  <div class="hidden">
95
97
  <div
98
+ style={isWidthOfActivator ? `width: ${activator?.offsetWidth}px;` : ''}
96
99
  class="{klass} max-h-80 overflow-auto rounded-lg border bg-base-100 p-1 shadow-lg"
97
100
  bind:this={content}
98
101
  >
@@ -15,6 +15,7 @@ declare const __propDef: {
15
15
  tip?: TippyInstance | undefined;
16
16
  disable?: boolean | undefined;
17
17
  content?: HTMLDivElement | undefined;
18
+ isWidthOfActivator?: boolean | undefined;
18
19
  hide?: (() => void) | undefined;
19
20
  show?: (() => void) | undefined;
20
21
  setTippyProps?: ((props: Partial<TippyProps>) => void) | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fuma",
3
- "version": "0.1.11",
3
+ "version": "0.1.13",
4
4
  "description": "My fullstack material build with sveltekit, daisyui, zod and more",
5
5
  "author": {
6
6
  "name": "Jonas Voisard",