@websline/system-components 1.5.0 → 1.5.1

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.
@@ -4,6 +4,7 @@
4
4
 
5
5
  /**
6
6
  * @typedef {Object} Props
7
+ * @property {import('svelte').Snippet} [children] Children content – can be text, HTML, or other Svelte components
7
8
  * @property {string} [class=""] Additional CSS classes to apply to the component
8
9
  * @property {number} [durationInSeconds=6] Duration in seconds before auto-close triggers
9
10
  * @property {string} [message=""] Message to display in the toast
@@ -18,6 +19,7 @@
18
19
 
19
20
  /** @type {Props} */
20
21
  let {
22
+ children,
21
23
  class: className = "",
22
24
  durationInSeconds = 6,
23
25
  message = "",
@@ -48,4 +50,5 @@
48
50
  {/if}
49
51
  </div>
50
52
  <p class={styles.message()}>{message}</p>
53
+ {@render children?.()}
51
54
  </div>
@@ -4,6 +4,10 @@ type Toast = {
4
4
  $set?(props: Partial<Props>): void;
5
5
  };
6
6
  declare const Toast: import("svelte").Component<{
7
+ /**
8
+ * Children content – can be text, HTML, or other Svelte components
9
+ */
10
+ children?: import("svelte").Snippet<[]> | undefined;
7
11
  /**
8
12
  * Additional CSS classes to apply to the component
9
13
  */
@@ -26,6 +30,10 @@ declare const Toast: import("svelte").Component<{
26
30
  variant?: "error" | "loading" | "info" | undefined;
27
31
  }, {}, "">;
28
32
  type Props = {
33
+ /**
34
+ * Children content – can be text, HTML, or other Svelte components
35
+ */
36
+ children?: import("svelte").Snippet<[]> | undefined;
29
37
  /**
30
38
  * Additional CSS classes to apply to the component
31
39
  */
@@ -2,7 +2,7 @@ import { tv } from "../../../../utils/tailwind.js";
2
2
 
3
3
  const toastVariants = tv({
4
4
  slots: {
5
- base: "flex items-center gap-2 rounded-lg bg-neutral-900 px-4 py-2 text-neutral-200",
5
+ base: "dark flex items-center gap-2 rounded-lg bg-neutral-900 px-4 py-2 text-neutral-200",
6
6
  icon: "grid size-6 place-items-center",
7
7
  message: "ui-select-label font-medium",
8
8
  },
@@ -1,5 +1,4 @@
1
1
  <script>
2
- import { Dialog } from "bits-ui";
3
2
  import { Button } from "../../../index.js";
4
3
 
5
4
  /**
@@ -58,15 +57,12 @@
58
57
  );
59
58
  </script>
60
59
 
61
- <Dialog.Close
60
+ <Button
62
61
  class={className}
63
62
  color="secondary"
64
63
  data-role={role}
65
64
  size="large"
66
- {...rest}>
67
- {#snippet child({ props })}
68
- <Button {...props} onkeydown={null} {...buttonProps}>
69
- {@render children?.()}
70
- </Button>
71
- {/snippet}
72
- </Dialog.Close>
65
+ {...rest}
66
+ {...buttonProps}>
67
+ {@render children?.()}
68
+ </Button>
@@ -1,5 +1,6 @@
1
1
  <script>
2
2
  import { FormActions } from "../../../index.js";
3
+ import { Dialog } from "bits-ui";
3
4
  import { dialogVariants } from "./dialog.variants.js";
4
5
 
5
6
  /**
@@ -14,6 +15,20 @@
14
15
  let styles = $derived(dialogVariants());
15
16
  </script>
16
17
 
17
- <FormActions class={styles.formActions({ class: className })} customLayout {...rest}>
18
- {@render children?.()}
19
- </FormActions>
18
+ <Dialog.Close>
19
+ {#snippet child({ props: { onclick } })}
20
+ <FormActions
21
+ class={styles.formActions({ class: className })}
22
+ customLayout
23
+ onclick={(e) => {
24
+ if (e.button === 0 && e.target.role && e.target.tagName === "BUTTON") {
25
+ // Auto-close on main device-button click on UI-button with role.
26
+ // Use e.stopPropagation() on action click handler to prevent this.
27
+ onclick(e);
28
+ }
29
+ }}
30
+ {...rest}>
31
+ {@render children?.()}
32
+ </FormActions>
33
+ {/snippet}
34
+ </Dialog.Close>
@@ -56,7 +56,9 @@
56
56
  };
57
57
  </script>
58
58
 
59
- <svelte:body onnotification:show={handleShow} />
59
+ <svelte:body
60
+ onnotification:close={({ detail: id }) => handleClose(id)}
61
+ onnotification:show={handleShow} />
60
62
 
61
63
  {#snippet column(position, x = 0, y = 0)}
62
64
  {@const items = [...data.values()].filter((item) => item.position === position)}
@@ -66,7 +68,12 @@
66
68
  position,
67
69
  zOrder: zOrder.findIndex((key) => key === position),
68
70
  })}>
69
- {#each items as { id, el, props }, i (id)}
71
+ {#each items as { id, el: Comp, props }, i (id)}
72
+ {@const finalProps = {
73
+ ...props,
74
+ class: styles.item({ class: props.class }),
75
+ onClose: () => handleClose(id),
76
+ }}
70
77
  <div
71
78
  in:fly={{
72
79
  x,
@@ -83,11 +90,11 @@
83
90
  easing: cubicOut,
84
91
  }}
85
92
  onoutroend={data.size === 0 ? handleLastClose : null}>
86
- {@render el?.({
87
- ...props,
88
- class: styles.item({ class: props.class }),
89
- onClose: () => handleClose(id),
90
- })}
93
+ {#if Comp.name === "snippet"}
94
+ {@render Comp?.(finalProps)}
95
+ {:else}
96
+ <Comp {...finalProps} />
97
+ {/if}
91
98
  </div>
92
99
  {/each}
93
100
  </div>
@@ -3,4 +3,4 @@ export namespace NOTIFICATION_POSITIONS {
3
3
  let BOTTOM_LEFT: string;
4
4
  let BOTTOM_RIGHT: string;
5
5
  }
6
- export function showNotification(el: any, position?: string, props?: {}): string;
6
+ export function showNotification(el: any, position?: string, props?: {}): () => void;
@@ -19,7 +19,13 @@ const showNotification = (
19
19
  }),
20
20
  );
21
21
 
22
- return id;
22
+ return () => {
23
+ document.body.dispatchEvent(
24
+ new CustomEvent("notification:close", {
25
+ detail: id,
26
+ }),
27
+ );
28
+ };
23
29
  };
24
30
 
25
31
  export { NOTIFICATION_POSITIONS, showNotification };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@websline/system-components",
3
- "version": "1.5.0",
3
+ "version": "1.5.1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },