lithesome 0.10.3 → 0.12.0

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.
Files changed (38) hide show
  1. package/dist/components/Accordion/Accordion.svelte +14 -14
  2. package/dist/components/Accordion/AccordionButton.svelte +18 -18
  3. package/dist/components/Accordion/AccordionButton.svelte.d.ts +5 -4
  4. package/dist/components/Checkbox/Checkbox.svelte +18 -19
  5. package/dist/components/Combobox/ComboboxContent.svelte +35 -35
  6. package/dist/components/Hovercard/HovercardContent.svelte +47 -47
  7. package/dist/components/Menu/MenuContent.svelte +29 -29
  8. package/dist/components/Modal/ModalContent.svelte +21 -21
  9. package/dist/components/Popover/PopoverContent.svelte +51 -51
  10. package/dist/components/Portal/Portal.svelte +5 -5
  11. package/dist/components/Select/SelectContent.svelte +29 -29
  12. package/dist/components/Switch/Switch.svelte +37 -0
  13. package/dist/components/Switch/Switch.svelte.d.ts +15 -0
  14. package/dist/components/Switch/index.d.ts +2 -0
  15. package/dist/components/Switch/index.js +1 -0
  16. package/dist/components/Switch/types.d.ts +17 -0
  17. package/dist/components/Switch/types.js +1 -0
  18. package/dist/components/Toast/Toast.svelte +26 -0
  19. package/dist/components/Toast/Toast.svelte.d.ts +17 -0
  20. package/dist/components/Toast/ToastMessage.svelte +16 -0
  21. package/dist/components/Toast/ToastMessage.svelte.d.ts +15 -0
  22. package/dist/components/Toast/ToastTitle.svelte +9 -0
  23. package/dist/components/Toast/ToastTitle.svelte.d.ts +15 -0
  24. package/dist/components/Toast/Toaster.svelte +23 -0
  25. package/dist/components/Toast/Toaster.svelte.d.ts +15 -0
  26. package/dist/components/Toast/context.svelte.d.ts +11 -0
  27. package/dist/components/Toast/context.svelte.js +37 -0
  28. package/dist/components/Toast/index.d.ts +6 -0
  29. package/dist/components/Toast/index.js +5 -0
  30. package/dist/components/Toast/types.d.ts +31 -0
  31. package/dist/components/Toast/types.js +1 -0
  32. package/dist/index.d.ts +2 -0
  33. package/dist/index.js +2 -0
  34. package/dist/internal/components/FloatingArrow.svelte +3 -3
  35. package/dist/internal/helpers/context.svelte.js +4 -1
  36. package/dist/internal/helpers/utils.svelte.d.ts +7 -0
  37. package/dist/internal/helpers/utils.svelte.js +17 -0
  38. package/package.json +4 -4
@@ -1,8 +1,8 @@
1
1
  <script lang="ts" context="module">import { setupContext } from "../../internal/index.js";
2
2
  import { AccordionContext } from "./context.svelte.js";
3
3
  export const { context, contextName } = setupContext();
4
- </script>
5
-
4
+ </script>
5
+
6
6
  <script lang="ts">import { useActions, classProp } from "../../internal/index.js";
7
7
  import { setContext } from "svelte";
8
8
  let {
@@ -19,15 +19,15 @@ setContext(contextName, ctx);
19
19
  $effect(() => {
20
20
  ctx.single = single;
21
21
  });
22
- </script>
23
-
24
- <div
25
- bind:this={self}
26
- use:useActions={use}
27
- id={ctx.uid()}
28
- class={classProp(klass, { active })}
29
- data-accordion=""
30
- {...props}
31
- >
32
- {@render children({ active })}
33
- </div>
22
+ </script>
23
+
24
+ <div
25
+ bind:this={self}
26
+ use:useActions={use}
27
+ id={ctx.uid()}
28
+ class={classProp(klass, { active })}
29
+ data-accordion=""
30
+ {...props}
31
+ >
32
+ {@render children({ active })}
33
+ </div>
@@ -11,21 +11,21 @@ const handleClick = (e) => {
11
11
  if (!item?.disabled)
12
12
  ctx.toggle(itemId);
13
13
  };
14
- </script>
15
-
16
- <button
17
- type="button"
18
- bind:this={self}
19
- use:useActions={use}
20
- class={classProp(klass, { active, disabled: item?.disabled || false })}
21
- aria-expanded={active}
22
- aria-disabled={item?.disabled}
23
- aria-controls={active ? ctx.uid('content') : undefined}
24
- tabindex={item?.disabled ? -1 : 0}
25
- data-accordionbutton=""
26
- data-active={active || undefined}
27
- onclick={handleClick}
28
- {...props}
29
- >
30
- {@render children({ active, disabled: item?.disabled || false })}
31
- </button>
14
+ </script>
15
+
16
+ <button
17
+ type="button"
18
+ bind:this={self}
19
+ use:useActions={use}
20
+ class={classProp(klass, { active, disabled: item?.disabled || false })}
21
+ aria-expanded={active}
22
+ aria-disabled={item?.disabled}
23
+ aria-controls={active ? ctx.uid('content') : undefined}
24
+ tabindex={item?.disabled ? -1 : 0}
25
+ data-accordionbutton=""
26
+ data-active={active || undefined}
27
+ onclick={handleClick}
28
+ {...props}
29
+ >
30
+ {@render children({ active, disabled: item?.disabled || false })}
31
+ </button>
@@ -1,14 +1,15 @@
1
1
  import { SvelteComponent } from "svelte";
2
+ import type { AccordionButtonProps } from './types.js';
2
3
  declare const __propDef: {
3
- props: any;
4
+ props: AccordionButtonProps;
4
5
  events: {
5
6
  [evt: string]: CustomEvent<any>;
6
7
  };
7
8
  slots: {};
8
9
  };
9
- export type AccordionButtonProps = typeof __propDef.props;
10
+ type AccordionButtonProps_ = typeof __propDef.props;
11
+ export { AccordionButtonProps_ as AccordionButtonProps };
10
12
  export type AccordionButtonEvents = typeof __propDef.events;
11
13
  export type AccordionButtonSlots = typeof __propDef.slots;
12
- export default class AccordionButton extends SvelteComponent<AccordionButtonProps, AccordionButtonEvents, AccordionButtonSlots> {
14
+ export default class AccordionButton extends SvelteComponent<AccordionButtonProps_, AccordionButtonEvents, AccordionButtonSlots> {
13
15
  }
14
- export {};
@@ -16,22 +16,21 @@ const handleClick = (e) => {
16
16
  return;
17
17
  checked = checked === "mixed" ? true : !checked;
18
18
  };
19
- </script>
20
-
21
- <button
22
- type="button"
23
- bind:this={self}
24
- use:useActions={use}
25
- class={classProp(klass, { checked })}
26
- role="checkbox"
27
- aria-checked={checked}
28
- aria-required={required}
29
- data-state={checked ? 'checked' : 'unchecked'}
30
- data-checkbox=""
31
- onclick={handleClick}
32
- {...props}
33
- >
34
- {#if children}
35
- {@render children({ checked })}
36
- {/if}
37
- </button>
19
+ </script>
20
+
21
+ <button
22
+ type="button"
23
+ bind:this={self}
24
+ use:useActions={use}
25
+ class={classProp(klass, { checked })}
26
+ role="checkbox"
27
+ aria-checked={checked}
28
+ aria-required={required}
29
+ disabled={disabled || undefined}
30
+ data-state={checked ? 'checked' : 'unchecked'}
31
+ data-checkbox=""
32
+ onclick={handleClick}
33
+ {...props}
34
+ >
35
+ {@render children?.({ checked })}
36
+ </button>
@@ -52,38 +52,38 @@ $effect(() => {
52
52
  contentCleanup?.();
53
53
  };
54
54
  });
55
- </script>
56
-
57
- {#if inTransition && outTransition && ctx.visible}
58
- {@const { config: inConf, transition: inFn } = inTransition}
59
- {@const { config: outConf, transition: outFn } = outTransition}
60
- <div
61
- bind:this={self}
62
- use:useOutside={{
63
- exclude: ctx.trigger,
64
- callback: () => ctx.close()
65
- }}
66
- use:usePortal={portalTarget}
67
- use:useActions={use}
68
- in:inFn={inConf}
69
- out:outFn={outConf}
70
- {...attrs}
71
- {...props}
72
- >
73
- {@render children({ visible: ctx.visible })}
74
- </div>
75
- {:else if ctx.visible}
76
- <div
77
- bind:this={self}
78
- use:useOutside={{
79
- exclude: ctx.trigger,
80
- callback: () => ctx.close()
81
- }}
82
- use:usePortal={portalTarget}
83
- use:useActions={use}
84
- {...attrs}
85
- {...props}
86
- >
87
- {@render children({ visible: ctx.visible })}
88
- </div>
89
- {/if}
55
+ </script>
56
+
57
+ {#if inTransition && outTransition && ctx.visible}
58
+ {@const { config: inConf, transition: inFn } = inTransition}
59
+ {@const { config: outConf, transition: outFn } = outTransition}
60
+ <div
61
+ bind:this={self}
62
+ use:useOutside={{
63
+ exclude: ctx.trigger,
64
+ callback: () => ctx.close()
65
+ }}
66
+ use:usePortal={portalTarget}
67
+ use:useActions={use}
68
+ in:inFn={inConf}
69
+ out:outFn={outConf}
70
+ {...attrs}
71
+ {...props}
72
+ >
73
+ {@render children({ visible: ctx.visible })}
74
+ </div>
75
+ {:else if ctx.visible}
76
+ <div
77
+ bind:this={self}
78
+ use:useOutside={{
79
+ exclude: ctx.trigger,
80
+ callback: () => ctx.close()
81
+ }}
82
+ use:usePortal={portalTarget}
83
+ use:useActions={use}
84
+ {...attrs}
85
+ {...props}
86
+ >
87
+ {@render children({ visible: ctx.visible })}
88
+ </div>
89
+ {/if}
@@ -62,50 +62,50 @@ const handleMouseleave = (e) => {
62
62
  ctx.hovered = false;
63
63
  ctx.close();
64
64
  };
65
- </script>
66
-
67
- {#if inTransition && outTransition && ctx.visible}
68
- {@const { config: inConf, transition: inFn } = inTransition}
69
- {@const { config: outConf, transition: outFn } = outTransition}
70
- <div
71
- bind:this={self}
72
- use:useOutside={{
73
- exclude: ctx.trigger,
74
- callback: () => {
75
- ctx.visible = false;
76
- }
77
- }}
78
- use:usePortal={portalTarget}
79
- use:useActions={use}
80
- in:inFn={inConf}
81
- out:outFn={outConf}
82
- onmouseenter={handleMouseenter}
83
- onmouseleave={handleMouseleave}
84
- role="menu"
85
- tabindex={-1}
86
- {...attrs}
87
- {...props}
88
- >
89
- {@render children({ visible: ctx.visible })}
90
- </div>
91
- {:else if ctx.visible}
92
- <div
93
- bind:this={self}
94
- use:useOutside={{
95
- exclude: ctx.trigger,
96
- callback: () => {
97
- ctx.visible = false;
98
- }
99
- }}
100
- use:usePortal={portalTarget}
101
- use:useActions={use}
102
- onmouseenter={handleMouseenter}
103
- onmouseleave={handleMouseleave}
104
- role="menu"
105
- tabindex={-1}
106
- {...attrs}
107
- {...props}
108
- >
109
- {@render children({ visible: ctx.visible })}
110
- </div>
111
- {/if}
65
+ </script>
66
+
67
+ {#if inTransition && outTransition && ctx.visible}
68
+ {@const { config: inConf, transition: inFn } = inTransition}
69
+ {@const { config: outConf, transition: outFn } = outTransition}
70
+ <div
71
+ bind:this={self}
72
+ use:useOutside={{
73
+ exclude: ctx.trigger,
74
+ callback: () => {
75
+ ctx.visible = false;
76
+ }
77
+ }}
78
+ use:usePortal={portalTarget}
79
+ use:useActions={use}
80
+ in:inFn={inConf}
81
+ out:outFn={outConf}
82
+ onmouseenter={handleMouseenter}
83
+ onmouseleave={handleMouseleave}
84
+ role="menu"
85
+ tabindex={-1}
86
+ {...attrs}
87
+ {...props}
88
+ >
89
+ {@render children({ visible: ctx.visible })}
90
+ </div>
91
+ {:else if ctx.visible}
92
+ <div
93
+ bind:this={self}
94
+ use:useOutside={{
95
+ exclude: ctx.trigger,
96
+ callback: () => {
97
+ ctx.visible = false;
98
+ }
99
+ }}
100
+ use:usePortal={portalTarget}
101
+ use:useActions={use}
102
+ onmouseenter={handleMouseenter}
103
+ onmouseleave={handleMouseleave}
104
+ role="menu"
105
+ tabindex={-1}
106
+ {...attrs}
107
+ {...props}
108
+ >
109
+ {@render children({ visible: ctx.visible })}
110
+ </div>
111
+ {/if}
@@ -51,32 +51,32 @@ $effect(() => {
51
51
  contentCleanup?.();
52
52
  };
53
53
  });
54
- </script>
55
-
56
- {#if inTransition && outTransition && ctx.visible}
57
- {@const { config: inConf, transition: inFn } = inTransition}
58
- {@const { config: outConf, transition: outFn } = outTransition}
59
- <div
60
- bind:this={self}
61
- use:useOutside={{ exclude: ctx.trigger, callback: () => ctx.close() }}
62
- use:usePortal={portalTarget}
63
- use:useActions={use}
64
- in:inFn={inConf}
65
- out:outFn={outConf}
66
- {...attrs}
67
- {...props}
68
- >
69
- {@render children({ visible: ctx.visible })}
70
- </div>
71
- {:else if ctx.visible}
72
- <div
73
- bind:this={self}
74
- use:useOutside={{ exclude: ctx.trigger, callback: () => ctx.close() }}
75
- use:usePortal={portalTarget}
76
- use:useActions={use}
77
- {...attrs}
78
- {...props}
79
- >
80
- {@render children({ visible: ctx.visible })}
81
- </div>
82
- {/if}
54
+ </script>
55
+
56
+ {#if inTransition && outTransition && ctx.visible}
57
+ {@const { config: inConf, transition: inFn } = inTransition}
58
+ {@const { config: outConf, transition: outFn } = outTransition}
59
+ <div
60
+ bind:this={self}
61
+ use:useOutside={{ exclude: ctx.trigger, callback: () => ctx.close() }}
62
+ use:usePortal={portalTarget}
63
+ use:useActions={use}
64
+ in:inFn={inConf}
65
+ out:outFn={outConf}
66
+ {...attrs}
67
+ {...props}
68
+ >
69
+ {@render children({ visible: ctx.visible })}
70
+ </div>
71
+ {:else if ctx.visible}
72
+ <div
73
+ bind:this={self}
74
+ use:useOutside={{ exclude: ctx.trigger, callback: () => ctx.close() }}
75
+ use:usePortal={portalTarget}
76
+ use:useActions={use}
77
+ {...attrs}
78
+ {...props}
79
+ >
80
+ {@render children({ visible: ctx.visible })}
81
+ </div>
82
+ {/if}
@@ -14,24 +14,24 @@ const attrs = $derived({
14
14
  "aria-labelledby": ctx.uid("title"),
15
15
  "data-modalcontent": ""
16
16
  });
17
- </script>
18
-
19
- {#if inTransition && outTransition && ctx.visible}
20
- {@const { config: inConf, transition: inFn } = inTransition}
21
- {@const { config: outConf, transition: outFn } = outTransition}
22
- <div
23
- bind:this={self}
24
- use:useTrap={{ allowOutsideClick: true }}
25
- use:useActions={use}
26
- in:inFn|global={inConf}
27
- out:outFn|global={outConf}
28
- {...props}
29
- {...attrs}
30
- >
31
- {@render children({})}
32
- </div>
33
- {:else if ctx.visible}
34
- <div bind:this={self} use:useTrap={{ allowOutsideClick: true }} use:useActions={use} {...props} {...attrs}>
35
- {@render children({})}
36
- </div>
37
- {/if}
17
+ </script>
18
+
19
+ {#if inTransition && outTransition && ctx.visible}
20
+ {@const { config: inConf, transition: inFn } = inTransition}
21
+ {@const { config: outConf, transition: outFn } = outTransition}
22
+ <div
23
+ bind:this={self}
24
+ use:useTrap={{ allowOutsideClick: true }}
25
+ use:useActions={use}
26
+ in:inFn|global={inConf}
27
+ out:outFn|global={outConf}
28
+ {...props}
29
+ {...attrs}
30
+ >
31
+ {@render children({})}
32
+ </div>
33
+ {:else if ctx.visible}
34
+ <div bind:this={self} use:useTrap={{ allowOutsideClick: true }} use:useActions={use} {...props} {...attrs}>
35
+ {@render children({})}
36
+ </div>
37
+ {/if}
@@ -51,54 +51,54 @@ $effect(() => {
51
51
  contentCleanup?.();
52
52
  };
53
53
  });
54
- </script>
55
-
56
- {#if inTransition && outTransition && ctx.visible}
57
- {@const { config: inConf, transition: inFn } = inTransition}
58
- {@const { config: outConf, transition: outFn } = outTransition}
59
- <div
60
- bind:this={self}
61
- use:useOutside={{
62
- exclude: ctx.trigger,
63
- callback: () => {
64
- ctx.close();
65
- }
66
- }}
67
- use:usePortal={portalTarget}
68
- use:useActions={use}
69
- use:useTrap={{
70
- allowOutsideClick: true,
71
- onDeactivate: () => {
72
- ctx.visible = false;
73
- }
74
- }}
75
- in:inFn={inConf}
76
- out:outFn={outConf}
77
- {...attrs}
78
- {...props}
79
- >
80
- {@render children({ visible: ctx.visible })}
81
- </div>
82
- {:else if ctx.visible}
83
- <div
84
- bind:this={self}
85
- use:useOutside={{
86
- exclude: ctx.trigger,
87
- callback: () => {
88
- ctx.close();
89
- }
90
- }}
91
- use:usePortal={portalTarget}
92
- use:useActions={use}
93
- use:useTrap={{
94
- allowOutsideClick: true,
95
- onDeactivate: () => {
96
- ctx.visible = false;
97
- }
98
- }}
99
- {...attrs}
100
- {...props}
101
- >
102
- {@render children({ visible: ctx.visible })}
103
- </div>
104
- {/if}
54
+ </script>
55
+
56
+ {#if inTransition && outTransition && ctx.visible}
57
+ {@const { config: inConf, transition: inFn } = inTransition}
58
+ {@const { config: outConf, transition: outFn } = outTransition}
59
+ <div
60
+ bind:this={self}
61
+ use:useOutside={{
62
+ exclude: ctx.trigger,
63
+ callback: () => {
64
+ ctx.close();
65
+ }
66
+ }}
67
+ use:usePortal={portalTarget}
68
+ use:useActions={use}
69
+ use:useTrap={{
70
+ allowOutsideClick: true,
71
+ onDeactivate: () => {
72
+ ctx.visible = false;
73
+ }
74
+ }}
75
+ in:inFn={inConf}
76
+ out:outFn={outConf}
77
+ {...attrs}
78
+ {...props}
79
+ >
80
+ {@render children({ visible: ctx.visible })}
81
+ </div>
82
+ {:else if ctx.visible}
83
+ <div
84
+ bind:this={self}
85
+ use:useOutside={{
86
+ exclude: ctx.trigger,
87
+ callback: () => {
88
+ ctx.close();
89
+ }
90
+ }}
91
+ use:usePortal={portalTarget}
92
+ use:useActions={use}
93
+ use:useTrap={{
94
+ allowOutsideClick: true,
95
+ onDeactivate: () => {
96
+ ctx.visible = false;
97
+ }
98
+ }}
99
+ {...attrs}
100
+ {...props}
101
+ >
102
+ {@render children({ visible: ctx.visible })}
103
+ </div>
104
+ {/if}
@@ -8,8 +8,8 @@ let {
8
8
  target = $bindable("body"),
9
9
  ...props
10
10
  } = $props();
11
- </script>
12
-
13
- <div bind:this={self} use:useActions={use} use:usePortal={target} class={classProp(klass)} data-portal="" {...props}>
14
- {@render children({})}
15
- </div>
11
+ </script>
12
+
13
+ <div bind:this={self} use:useActions={use} use:usePortal={target} class={classProp(klass)} data-portal="" {...props}>
14
+ {@render children({})}
15
+ </div>
@@ -52,32 +52,32 @@ $effect(() => {
52
52
  contentCleanup?.();
53
53
  };
54
54
  });
55
- </script>
56
-
57
- {#if inTransition && outTransition && ctx.visible}
58
- {@const { config: inConf, transition: inFn } = inTransition}
59
- {@const { config: outConf, transition: outFn } = outTransition}
60
- <div
61
- bind:this={self}
62
- use:useOutside={{ exclude: ctx.trigger, callback: () => ctx.close() }}
63
- use:usePortal={portalTarget}
64
- use:useActions={use}
65
- in:inFn={inConf}
66
- out:outFn={outConf}
67
- {...attrs}
68
- {...props}
69
- >
70
- {@render children({ visible: ctx.visible })}
71
- </div>
72
- {:else if ctx.visible}
73
- <div
74
- bind:this={self}
75
- use:useOutside={{ exclude: ctx.trigger, callback: () => ctx.close() }}
76
- use:usePortal={portalTarget}
77
- use:useActions={use}
78
- {...attrs}
79
- {...props}
80
- >
81
- {@render children({ visible: ctx.visible })}
82
- </div>
83
- {/if}
55
+ </script>
56
+
57
+ {#if inTransition && outTransition && ctx.visible}
58
+ {@const { config: inConf, transition: inFn } = inTransition}
59
+ {@const { config: outConf, transition: outFn } = outTransition}
60
+ <div
61
+ bind:this={self}
62
+ use:useOutside={{ exclude: ctx.trigger, callback: () => ctx.close() }}
63
+ use:usePortal={portalTarget}
64
+ use:useActions={use}
65
+ in:inFn={inConf}
66
+ out:outFn={outConf}
67
+ {...attrs}
68
+ {...props}
69
+ >
70
+ {@render children({ visible: ctx.visible })}
71
+ </div>
72
+ {:else if ctx.visible}
73
+ <div
74
+ bind:this={self}
75
+ use:useOutside={{ exclude: ctx.trigger, callback: () => ctx.close() }}
76
+ use:usePortal={portalTarget}
77
+ use:useActions={use}
78
+ {...attrs}
79
+ {...props}
80
+ >
81
+ {@render children({ visible: ctx.visible })}
82
+ </div>
83
+ {/if}
@@ -0,0 +1,37 @@
1
+ <script lang="ts">import { useActions, classProp } from "../../internal/index.js";
2
+ let {
3
+ children,
4
+ class: klass,
5
+ use = [],
6
+ self = $bindable(),
7
+ checked = $bindable(false),
8
+ required = false,
9
+ disabled = $bindable(false),
10
+ onClick,
11
+ ...props
12
+ } = $props();
13
+ const handleClick = (e) => {
14
+ onClick?.(e);
15
+ if (disabled)
16
+ return;
17
+ checked = !checked;
18
+ };
19
+ </script>
20
+
21
+ <button
22
+ type="button"
23
+ bind:this={self}
24
+ use:useActions={use}
25
+ class={classProp(klass, { checked, disabled })}
26
+ role="switch"
27
+ aria-checked={checked}
28
+ aria-required={required}
29
+ aria-readonly={disabled || undefined}
30
+ disabled={disabled || undefined}
31
+ data-state={checked ? 'checked' : 'unchecked'}
32
+ data-switch=""
33
+ onclick={handleClick}
34
+ {...props}
35
+ >
36
+ {@render children?.({ checked, disabled })}
37
+ </button>
@@ -0,0 +1,15 @@
1
+ import { SvelteComponent } from "svelte";
2
+ import type { SwitchProps } from './types.js';
3
+ declare const __propDef: {
4
+ props: SwitchProps;
5
+ events: {
6
+ [evt: string]: CustomEvent<any>;
7
+ };
8
+ slots: {};
9
+ };
10
+ type SwitchProps_ = typeof __propDef.props;
11
+ export { SwitchProps_ as SwitchProps };
12
+ export type SwitchEvents = typeof __propDef.events;
13
+ export type SwitchSlots = typeof __propDef.slots;
14
+ export default class Switch extends SvelteComponent<SwitchProps_, SwitchEvents, SwitchSlots> {
15
+ }
@@ -0,0 +1,2 @@
1
+ export { default as Switch } from './Switch.svelte';
2
+ export type * from './types.js';
@@ -0,0 +1 @@
1
+ export { default as Switch } from './Switch.svelte';
@@ -0,0 +1,17 @@
1
+ import type { Handler, PropsMaybeChildren } from '../../internal/types.js';
2
+ interface SwitchState {
3
+ /** If the Switch is checked or not. */
4
+ checked: boolean;
5
+ /** If the Switch is disabled or not. */
6
+ disabled: boolean;
7
+ }
8
+ export interface SwitchProps extends PropsMaybeChildren<HTMLButtonElement, SwitchState> {
9
+ /** If the switch is checked or not. */
10
+ checked?: boolean;
11
+ /** Adds aria attributes. */
12
+ required?: boolean;
13
+ /** Disabled the switch, disallowing the internal events. */
14
+ disabled?: boolean;
15
+ onClick?: Handler<MouseEvent, HTMLButtonElement>;
16
+ }
17
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,26 @@
1
+ <script lang="ts" context="module">import { setupContext } from "../../internal/index.js";
2
+ import { ToastContext } from "./context.svelte.js";
3
+ export const { context, contextName } = setupContext();
4
+ </script>
5
+
6
+ <script lang="ts">import { useActions, classProp } from "../../internal/index.js";
7
+ import { setContext } from "svelte";
8
+ let { children, use = [], class: klass, self = $bindable(), ...props } = $props();
9
+ const ctx = new ToastContext();
10
+ setContext(contextName, ctx);
11
+ </script>
12
+
13
+ <div
14
+ bind:this={self}
15
+ use:useActions={use}
16
+ class={classProp(klass)}
17
+ role="alert"
18
+ aria-labelledby={ctx.uid('title')}
19
+ aria-describedby={ctx.uid('description')}
20
+ aria-live="assertive"
21
+ tabindex="-1"
22
+ data-toast=""
23
+ {...props}
24
+ >
25
+ {@render children({})}
26
+ </div>
@@ -0,0 +1,17 @@
1
+ import { SvelteComponent } from "svelte";
2
+ import { ToastContext } from './context.svelte.js';
3
+ export declare const context: () => ToastContext, contextName: string;
4
+ import type { ToastProps } from './types.js';
5
+ declare const __propDef: {
6
+ props: ToastProps;
7
+ events: {
8
+ [evt: string]: CustomEvent<any>;
9
+ };
10
+ slots: {};
11
+ };
12
+ type ToastProps_ = typeof __propDef.props;
13
+ export { ToastProps_ as ToastProps };
14
+ export type ToastEvents = typeof __propDef.events;
15
+ export type ToastSlots = typeof __propDef.slots;
16
+ export default class Toast extends SvelteComponent<ToastProps_, ToastEvents, ToastSlots> {
17
+ }
@@ -0,0 +1,16 @@
1
+ <script lang="ts">import { useActions, classProp } from "../../internal/index.js";
2
+ import { context } from "./Toast.svelte";
3
+ let { children, use = [], class: klass, self = $bindable(), ...props } = $props();
4
+ const ctx = context();
5
+ </script>
6
+
7
+ <p
8
+ bind:this={self}
9
+ use:useActions={use}
10
+ id={ctx.uid('description')}
11
+ class={classProp(klass)}
12
+ data-toastdescription=""
13
+ {...props}
14
+ >
15
+ {@render children({})}
16
+ </p>
@@ -0,0 +1,15 @@
1
+ import { SvelteComponent } from "svelte";
2
+ import type { ToastMessageProps } from './types.js';
3
+ declare const __propDef: {
4
+ props: ToastMessageProps;
5
+ events: {
6
+ [evt: string]: CustomEvent<any>;
7
+ };
8
+ slots: {};
9
+ };
10
+ type ToastMessageProps_ = typeof __propDef.props;
11
+ export { ToastMessageProps_ as ToastMessageProps };
12
+ export type ToastMessageEvents = typeof __propDef.events;
13
+ export type ToastMessageSlots = typeof __propDef.slots;
14
+ export default class ToastMessage extends SvelteComponent<ToastMessageProps_, ToastMessageEvents, ToastMessageSlots> {
15
+ }
@@ -0,0 +1,9 @@
1
+ <script lang="ts">import { useActions, classProp } from "../../internal/index.js";
2
+ import { context } from "./Toast.svelte";
3
+ let { children, use = [], class: klass, self = $bindable(), ...props } = $props();
4
+ const ctx = context();
5
+ </script>
6
+
7
+ <h3 bind:this={self} use:useActions={use} id={ctx.uid('title')} class={classProp(klass)} data-toasttitle="" {...props}>
8
+ {@render children({})}
9
+ </h3>
@@ -0,0 +1,15 @@
1
+ import { SvelteComponent } from "svelte";
2
+ import type { ToastTitleProps } from './types.js';
3
+ declare const __propDef: {
4
+ props: ToastTitleProps;
5
+ events: {
6
+ [evt: string]: CustomEvent<any>;
7
+ };
8
+ slots: {};
9
+ };
10
+ type ToastTitleProps_ = typeof __propDef.props;
11
+ export { ToastTitleProps_ as ToastTitleProps };
12
+ export type ToastTitleEvents = typeof __propDef.events;
13
+ export type ToastTitleSlots = typeof __propDef.slots;
14
+ export default class ToastTitle extends SvelteComponent<ToastTitleProps_, ToastTitleEvents, ToastTitleSlots> {
15
+ }
@@ -0,0 +1,23 @@
1
+ <script lang="ts">import { useActions, classProp } from "../../internal/index.js";
2
+ import { usePortal } from "../../index.js";
3
+ import { toasts } from "./context.svelte.js";
4
+ let {
5
+ children,
6
+ use = [],
7
+ class: klass,
8
+ self = $bindable(),
9
+ portalTarget = "body",
10
+ ...props
11
+ } = $props();
12
+ </script>
13
+
14
+ <div
15
+ bind:this={self}
16
+ use:useActions={use}
17
+ use:usePortal={portalTarget}
18
+ class={classProp(klass)}
19
+ data-toaster=""
20
+ {...props}
21
+ >
22
+ {@render children(toasts)}
23
+ </div>
@@ -0,0 +1,15 @@
1
+ import { SvelteComponent } from "svelte";
2
+ import type { ToasterProps } from './types.js';
3
+ declare const __propDef: {
4
+ props: ToasterProps;
5
+ events: {
6
+ [evt: string]: CustomEvent<any>;
7
+ };
8
+ slots: {};
9
+ };
10
+ type ToasterProps_ = typeof __propDef.props;
11
+ export { ToasterProps_ as ToasterProps };
12
+ export type ToasterEvents = typeof __propDef.events;
13
+ export type ToasterSlots = typeof __propDef.slots;
14
+ export default class Toaster extends SvelteComponent<ToasterProps_, ToasterEvents, ToasterSlots> {
15
+ }
@@ -0,0 +1,11 @@
1
+ import { Context } from '../../internal/index.js';
2
+ import type { Toast, ToastConfig, ToastType } from './types.js';
3
+ export declare let toasts: Toast[];
4
+ export declare class ToastContext extends Context {
5
+ constructor();
6
+ }
7
+ export declare class Toaster {
8
+ add(type: ToastType, config: ToastConfig): void;
9
+ removeById(toastId: string): void;
10
+ }
11
+ export declare const toaster: Toaster;
@@ -0,0 +1,37 @@
1
+ import { Context, createUID, log, parseDuration, defaultConfig } from '../../internal/index.js';
2
+ export let toasts = $state([]);
3
+ export class ToastContext extends Context {
4
+ constructor() {
5
+ super('toast');
6
+ }
7
+ }
8
+ export class Toaster {
9
+ add(type, config) {
10
+ if (!config.title || !config.message)
11
+ throw log.error('`title` and `message` must be provided.');
12
+ const duration = parseDuration(config.duration || '5s');
13
+ const { uid } = createUID('toast');
14
+ const toast = {
15
+ id: uid(),
16
+ type,
17
+ config: defaultConfig(config, {
18
+ title: '',
19
+ message: '',
20
+ dismissable: false,
21
+ duration,
22
+ props: {}
23
+ })
24
+ };
25
+ toasts.push(toast);
26
+ setTimeout(() => {
27
+ if (toasts.find((el) => el.id === toast.id)) {
28
+ this.removeById(toast.id);
29
+ }
30
+ }, duration);
31
+ }
32
+ removeById(toastId) {
33
+ const i = toasts.findIndex((el) => el.id === toastId);
34
+ toasts.splice(i, 1);
35
+ }
36
+ }
37
+ export const toaster = new Toaster();
@@ -0,0 +1,6 @@
1
+ export { default as Toaster } from './Toaster.svelte';
2
+ export { default as Toast } from './Toast.svelte';
3
+ export { default as ToastTitle } from './ToastTitle.svelte';
4
+ export { default as ToastMessage } from './ToastMessage.svelte';
5
+ export { toaster } from './context.svelte.js';
6
+ export type * from './types.js';
@@ -0,0 +1,5 @@
1
+ export { default as Toaster } from './Toaster.svelte';
2
+ export { default as Toast } from './Toast.svelte';
3
+ export { default as ToastTitle } from './ToastTitle.svelte';
4
+ export { default as ToastMessage } from './ToastMessage.svelte';
5
+ export { toaster } from './context.svelte.js';
@@ -0,0 +1,31 @@
1
+ import type { Props } from '../../internal/index.js';
2
+ export type ToastType = 'success' | 'warning' | 'error' | 'info' | 'attention';
3
+ export interface ToastConfig {
4
+ /** The title of the toast. */
5
+ title: string;
6
+ /** The message to be displayed. */
7
+ message: string;
8
+ /** The durtation of the toast to be visible. */
9
+ duration?: string | number;
10
+ /** Allows the toast to be removed early. */
11
+ dismissable?: boolean;
12
+ /** Any custom props that you wish to pass down. */
13
+ props?: Record<string, any>;
14
+ }
15
+ export interface Toast {
16
+ /** The unique ID ofthe toast. */
17
+ id: string;
18
+ /** The type of the toast. */
19
+ type: ToastType;
20
+ config: ToastConfig;
21
+ }
22
+ export interface ToasterProps extends Props<HTMLDivElement, Toast[]> {
23
+ /** The element to portal the content menu to. */
24
+ portalTarget?: string | HTMLElement;
25
+ }
26
+ export interface ToastProps extends Props<HTMLDivElement> {
27
+ }
28
+ export interface ToastTitleProps extends Props<HTMLHeadingElement> {
29
+ }
30
+ export interface ToastMessageProps extends Props<HTMLParagraphElement> {
31
+ }
@@ -0,0 +1 @@
1
+ export {};
package/dist/index.d.ts CHANGED
@@ -10,6 +10,8 @@ export * from './components/Popover/index.js';
10
10
  export * from './components/Combobox/index.js';
11
11
  export * from './components/Hovercard/index.js';
12
12
  export * from './components/Portal/index.js';
13
+ export * from './components/Switch/index.js';
14
+ export * from './components/Toast/index.js';
13
15
  export * from './actions/portal.js';
14
16
  export * from './actions/outside.js';
15
17
  export * from './actions/trap.js';
package/dist/index.js CHANGED
@@ -10,6 +10,8 @@ export * from './components/Popover/index.js';
10
10
  export * from './components/Combobox/index.js';
11
11
  export * from './components/Hovercard/index.js';
12
12
  export * from './components/Portal/index.js';
13
+ export * from './components/Switch/index.js';
14
+ export * from './components/Toast/index.js';
13
15
  export * from './actions/portal.js';
14
16
  export * from './actions/outside.js';
15
17
  export * from './actions/trap.js';
@@ -19,6 +19,6 @@ onMount(() => {
19
19
  throw log.error(`Cannot initialize arrow node of <${component}Arrow />.`);
20
20
  ctx.arrow = self;
21
21
  });
22
- </script>
23
-
24
- <div bind:this={self} use:useActions={use} class={classProp(klass, state)} {...dataProps} {...props}></div>
22
+ </script>
23
+
24
+ <div bind:this={self} use:useActions={use} class={classProp(klass, state)} {...dataProps} {...props}></div>
@@ -40,6 +40,7 @@ export const setupContext = () => {
40
40
  */
41
41
  export const effects = (fn) => {
42
42
  let cleanUp = null;
43
+ let mounted = false;
43
44
  const destroy = () => {
44
45
  if (cleanUp === null)
45
46
  return;
@@ -47,8 +48,10 @@ export const effects = (fn) => {
47
48
  cleanUp = null;
48
49
  };
49
50
  onMount(() => {
50
- cleanUp = $effect.root(fn);
51
+ mounted = true;
51
52
  });
53
+ if (mounted)
54
+ $effect.root(fn);
52
55
  onDestroy(destroy);
53
56
  return destroy;
54
57
  };
@@ -39,3 +39,10 @@ export declare const parseDelay: (delay: number | [number, number]) => {
39
39
  in: number;
40
40
  out: number;
41
41
  };
42
+ /**
43
+ * Transforms the string value to a number.
44
+ *
45
+ * Supported identifiers: `ms`, `s`
46
+ * @param value The value to be transformed.
47
+ */
48
+ export declare const parseDuration: (value: number | string) => number;
@@ -1,3 +1,4 @@
1
+ import { log } from './log.js';
1
2
  /**
2
3
  * Calculates the index position of the action given.
3
4
  * @param action Which direction to navigate the index.
@@ -86,3 +87,19 @@ export const parseDelay = (delay) => {
86
87
  out: Array.isArray(delay) ? delay[1] : delay
87
88
  };
88
89
  };
90
+ /**
91
+ * Transforms the string value to a number.
92
+ *
93
+ * Supported identifiers: `ms`, `s`
94
+ * @param value The value to be transformed.
95
+ */
96
+ export const parseDuration = (value) => {
97
+ if (typeof value === 'number')
98
+ return value;
99
+ if (!/ms|s$/.test(value))
100
+ throw log.error('`duration` prop was given a string but not a leading identifier (ms/s).');
101
+ const duration = parseFloat(value.split(/ms|s/)[0]);
102
+ if (/(?=ms)(?!s)/.test(value))
103
+ return duration;
104
+ return duration * 1000;
105
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lithesome",
3
- "version": "0.10.3",
3
+ "version": "0.12.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/Gibbu/lithesome.git"
@@ -21,10 +21,10 @@
21
21
  "!dist/**/*.spec.*"
22
22
  ],
23
23
  "peerDependencies": {
24
- "svelte": "5.0.0-next.120"
24
+ "svelte": "5.0.0-next.137"
25
25
  },
26
26
  "devDependencies": {
27
- "@bitmachina/highlighter": "1.0.0-alpha.7",
27
+ "@bitmachina/highlighter": "1.0.0-alpha",
28
28
  "@steeze-ui/lucide-icons": "^1.2.0",
29
29
  "@steeze-ui/svelte-icon": "^1.5.0",
30
30
  "@sveltejs/adapter-vercel": "^5.1.1",
@@ -48,7 +48,7 @@
48
48
  "rehype-slug": "^6.0.0",
49
49
  "remark-external-links": "^9.0.1",
50
50
  "shiki": "^1.2.0",
51
- "svelte": "5.0.0-next.120",
51
+ "svelte": "5.0.0-next.137",
52
52
  "svelte-check": "^3.6.6",
53
53
  "tailwind-merge": "^2.2.1",
54
54
  "tailwindcss": "^3.4.1",