fuma 0.1.27 → 0.1.29

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,20 +1,25 @@
1
- <script>import { component } from "../index.js";
1
+ <script>import {} from "svelte";
2
+ import { component } from "../index.js";
2
3
  import Span from "./Span.svelte";
3
4
  export let slot = void 0;
4
5
  export let args = void 0;
5
6
  function getComponentAndProps(_slot) {
7
+ if (typeof _slot === "function") {
8
+ if (isComponentType(_slot))
9
+ return { component: _slot, props: {} };
10
+ if (!args) {
11
+ console.error("args prop is required with slot as function");
12
+ return null;
13
+ }
14
+ const result = _slot(args);
15
+ return getComponentAndProps(result);
16
+ }
6
17
  if (typeof _slot === "object")
7
18
  return _slot;
8
- if (typeof _slot === "string")
9
- return component(Span, { content: _slot });
10
- if (!args) {
11
- console.error("args prop is required with slot as function");
12
- return null;
13
- }
14
- const result = _slot(args);
15
- if (typeof result === "string")
16
- return component(Span, { content: result });
17
- return result;
19
+ return component(Span, { content: _slot });
20
+ }
21
+ function isComponentType(fun) {
22
+ return !!fun.prototype?.constructor?.name;
18
23
  }
19
24
  </script>
20
25
 
@@ -1,6 +1,7 @@
1
1
  <script>import { slide } from "svelte/transition";
2
2
  import { onMount } from "svelte";
3
3
  import { formContext } from "../../validation/form.js";
4
+ import { Slot } from "../index.js";
4
5
  let klass = "";
5
6
  export { klass as class };
6
7
  export let classLabel = "";
@@ -40,10 +41,11 @@ onMount(() => {
40
41
  class:flex-row-reverse={labelPosition === 'right'}
41
42
  class:justify-end={labelPosition === 'right'}
42
43
  >
43
- {#if label || $$slots.label}
44
+ {#if label}
44
45
  <label for="{prefixFor}{_key}" class="label cursor-pointer {classLabel}">
45
- <span class="label-text">{label}</span>
46
- <slot name="label" />
46
+ <span class="label-text">
47
+ <Slot slot={label} />
48
+ </span>
47
49
  <slot name="label_append" />
48
50
  </label>
49
51
  {/if}
@@ -1,10 +1,12 @@
1
1
  import { SvelteComponent } from "svelte";
2
+ import { type ComponentType } from 'svelte';
3
+ import type { ComponentAndProps } from '../../utils/index.js';
2
4
  declare const __propDef: {
3
5
  props: {
4
6
  class?: string | undefined;
5
7
  classLabel?: string | undefined;
6
8
  key?: string | undefined;
7
- label?: string | undefined;
9
+ label?: string | ComponentType | ComponentAndProps | undefined;
8
10
  error?: string | undefined;
9
11
  hint?: string | undefined;
10
12
  prefix?: string | number | undefined;
@@ -16,7 +18,6 @@ declare const __propDef: {
16
18
  [evt: string]: CustomEvent<any>;
17
19
  };
18
20
  slots: {
19
- label: {};
20
21
  label_append: {};
21
22
  default: {
22
23
  key: string;
@@ -5,7 +5,7 @@ declare const __propDef: {
5
5
  class?: string | undefined;
6
6
  classLabel?: string | undefined;
7
7
  key?: string | undefined;
8
- label?: string | undefined;
8
+ label?: string | import("svelte").ComponentType | import("../../index.js").ComponentAndProps | undefined;
9
9
  error?: string | undefined;
10
10
  hint?: string | undefined;
11
11
  prefix?: string | number | undefined;
@@ -5,7 +5,7 @@ declare const __propDef: {
5
5
  class?: string | undefined;
6
6
  classLabel?: string | undefined;
7
7
  key?: string | undefined;
8
- label?: string | undefined;
8
+ label?: string | import("svelte").ComponentType | import("../../index.js").ComponentAndProps | undefined;
9
9
  error?: string | undefined;
10
10
  hint?: string | undefined;
11
11
  prefix?: string | number | undefined;
@@ -5,7 +5,7 @@ declare const __propDef: {
5
5
  class?: string | undefined;
6
6
  classLabel?: string | undefined;
7
7
  key?: string | undefined;
8
- label?: string | undefined;
8
+ label?: string | import("svelte").ComponentType | import("../../utils/index.js").ComponentAndProps | undefined;
9
9
  error?: string | undefined;
10
10
  hint?: string | undefined;
11
11
  prefix?: string | number | undefined;
@@ -8,7 +8,7 @@ declare const __propDef: {
8
8
  class?: string | undefined;
9
9
  classLabel?: string | undefined;
10
10
  key?: string | undefined;
11
- label?: string | undefined;
11
+ label?: string | import("svelte").ComponentType | import("../../index.js").ComponentAndProps | undefined;
12
12
  error?: string | undefined;
13
13
  hint?: string | undefined;
14
14
  prefix?: string | number | undefined;
@@ -4,7 +4,7 @@ declare const __propDef: {
4
4
  class?: string | undefined;
5
5
  classLabel?: string | undefined;
6
6
  key?: string | undefined;
7
- label?: string | undefined;
7
+ label?: string | import("svelte").ComponentType | import("../../index.js").ComponentAndProps | undefined;
8
8
  error?: string | undefined;
9
9
  hint?: string | undefined;
10
10
  prefix?: string | number | undefined;
@@ -5,7 +5,7 @@ declare const __propDef: {
5
5
  class?: string | undefined;
6
6
  classLabel?: string | undefined;
7
7
  key?: string | undefined;
8
- label?: string | undefined;
8
+ label?: string | import("svelte").ComponentType | import("../../index.js").ComponentAndProps | undefined;
9
9
  error?: string | undefined;
10
10
  hint?: string | undefined;
11
11
  prefix?: string | number | undefined;
@@ -4,7 +4,7 @@ declare const __propDef: {
4
4
  class?: string | undefined;
5
5
  classLabel?: string | undefined;
6
6
  key?: string | undefined;
7
- label?: string | undefined;
7
+ label?: string | import("svelte").ComponentType | import("../../..").ComponentAndProps | undefined;
8
8
  error?: string | undefined;
9
9
  hint?: string | undefined;
10
10
  prefix?: string | number | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fuma",
3
- "version": "0.1.27",
3
+ "version": "0.1.29",
4
4
  "description": "My fullstack material build with sveltekit, daisyui, zod and more",
5
5
  "author": {
6
6
  "name": "Jonas Voisard",