svelte-comp 1.3.5 → 1.3.6

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 (46) hide show
  1. package/LICENSE.md +21 -21
  2. package/README.md +101 -101
  3. package/dist/App.svelte +1046 -1046
  4. package/dist/Container.svelte +59 -59
  5. package/dist/app.css +234 -234
  6. package/dist/app.d.ts +10 -10
  7. package/dist/lib/Accordion.svelte +155 -155
  8. package/dist/lib/Badge.svelte +44 -44
  9. package/dist/lib/Button.svelte +185 -185
  10. package/dist/lib/Calendar.svelte +384 -384
  11. package/dist/lib/Card.svelte +103 -103
  12. package/dist/lib/Carousel.svelte +293 -293
  13. package/dist/lib/CheckBox.svelte +210 -210
  14. package/dist/lib/CodeView.svelte +308 -308
  15. package/dist/lib/ColorPicker.svelte +159 -159
  16. package/dist/lib/ContextMenu.svelte +328 -328
  17. package/dist/lib/DatePicker.svelte +246 -246
  18. package/dist/lib/Dialog.svelte +233 -233
  19. package/dist/lib/Field.svelte +299 -299
  20. package/dist/lib/FilePicker.svelte +295 -295
  21. package/dist/lib/Form.svelte +438 -438
  22. package/dist/lib/Hamburger.svelte +217 -217
  23. package/dist/lib/InstallPWA.svelte +94 -94
  24. package/dist/lib/Menu.svelte +623 -623
  25. package/dist/lib/NoticeBase.svelte +140 -140
  26. package/dist/lib/PaginatedCard.svelte +73 -73
  27. package/dist/lib/Pagination.svelte +119 -119
  28. package/dist/lib/PrimaryColorSelect.svelte +111 -111
  29. package/dist/lib/ProgressBar.svelte +141 -141
  30. package/dist/lib/ProgressCircle.svelte +190 -190
  31. package/dist/lib/Radio.svelte +189 -189
  32. package/dist/lib/SearchInput.svelte +104 -104
  33. package/dist/lib/Select.svelte +524 -524
  34. package/dist/lib/Slider.svelte +253 -253
  35. package/dist/lib/Splitter.svelte +159 -159
  36. package/dist/lib/Switch.svelte +168 -168
  37. package/dist/lib/Table.svelte +299 -299
  38. package/dist/lib/Tabs.svelte +213 -213
  39. package/dist/lib/ThemeToggle.svelte +128 -128
  40. package/dist/lib/TimePicker.svelte +312 -312
  41. package/dist/lib/TimePickerNew.svelte +634 -634
  42. package/dist/lib/Toast.svelte +123 -123
  43. package/dist/lib/Tooltip.svelte +110 -110
  44. package/dist/lib/Topbar.svelte +112 -112
  45. package/dist/styles.css +234 -234
  46. package/package.json +52 -52
@@ -1,123 +1,123 @@
1
- <!-- src/lib/Toast.svelte -->
2
- <script lang="ts">
3
- /**
4
- * @component Toast
5
- * @description Lightweight notification component for transient messages.
6
- *
7
- * @prop title {string} - Optional title displayed above the message
8
- *
9
- * @prop message {string} - Toast message content
10
- *
11
- * @prop variant {ToastVariant} - Visual style
12
- * @options success|danger|warning|info
13
- * @default info
14
- *
15
- * @prop showIcon {boolean} - Shows an icon matching the variant
16
- * @default true
17
- *
18
- * @prop closable {boolean} - Shows a close button
19
- * @default true
20
- *
21
- * @prop timeout {number} - Auto-hide timeout in milliseconds
22
- * @default 3000
23
- *
24
- * @prop onClose {() => void} - Fired when the toast closes
25
- * @default () => {}
26
- *
27
- * @prop class {string} - Additional wrapper classes
28
- * @default ""
29
- *
30
- * @note Automatically hides after `timeout`.
31
- * @note Can be closed manually if `closable = true`.
32
- * @note Variant controls color and icon style.
33
- */
34
- import { fade } from "svelte/transition";
35
- import type { ToastVariant } from "./types";
36
- import NoticeBase from "./NoticeBase.svelte";
37
-
38
- type Props = {
39
- title?: string;
40
- message: string;
41
- variant?: ToastVariant;
42
- showIcon?: boolean;
43
- closable?: boolean;
44
- timeout?: number;
45
- onClose?: () => void;
46
- class?: string;
47
- };
48
-
49
- let {
50
- title,
51
- message,
52
- variant = "info",
53
- showIcon = true,
54
- closable = true,
55
- timeout = 3000,
56
- onClose = () => {},
57
- class: externalClass = "",
58
- }: Props = $props();
59
-
60
- let visible = $state(true);
61
-
62
- function variantClasses(v: ToastVariant) {
63
- switch (v) {
64
- case "success":
65
- return "bg-[var(--color-bg-success)] text-[var(--color-text-success)]";
66
- case "danger":
67
- return "bg-[var(--color-bg-danger)] text-[var(--color-text-danger)]";
68
- case "warning":
69
- return "bg-[var(--color-bg-warning)] text-[var(--color-text-warning)]";
70
- default:
71
- return "bg-[var(--color-bg-page)] text-[var(--color-text-default)]";
72
- }
73
- }
74
-
75
- function close() {
76
- visible = false;
77
- onClose();
78
- }
79
-
80
- $effect(() => {
81
- if (timeout > 0) {
82
- const id = setTimeout(() => close(), timeout);
83
- return () => clearTimeout(id);
84
- }
85
- });
86
-
87
- </script>
88
-
89
- {#if visible}
90
- {#snippet end()}
91
- {#if closable}
92
- <button
93
- class="opacity-70 hover:opacity-100 transition-opacity duration-[var(--transition-fast)] ml-3"
94
- aria-label="Close"
95
- onclick={close}
96
- >
97
- <svg width="24" height="24" viewBox="0 0 20 20" fill="none">
98
- <path
99
- d="M7 7l6 6M13 7l-6 6"
100
- stroke="currentColor"
101
- stroke-width="2"
102
- stroke-linecap="round"
103
- />
104
- </svg>
105
- </button>
106
- {/if}
107
- {/snippet}
108
-
109
- <div
110
- class={`fixed bottom-4 right-4 min-w-[220px] max-w-[calc(100vw-2rem)] ${variantClasses(variant)} ${externalClass}`}
111
- in:fade={{ duration: 200 }}
112
- out:fade={{ duration: 200 }}
113
- >
114
- <NoticeBase
115
- {title}
116
- {message}
117
- {variant}
118
- {showIcon}
119
- size="md"
120
- end={end}
121
- />
122
- </div>
123
- {/if}
1
+ <!-- src/lib/Toast.svelte -->
2
+ <script lang="ts">
3
+ /**
4
+ * @component Toast
5
+ * @description Lightweight notification component for transient messages.
6
+ *
7
+ * @prop title {string} - Optional title displayed above the message
8
+ *
9
+ * @prop message {string} - Toast message content
10
+ *
11
+ * @prop variant {ToastVariant} - Visual style
12
+ * @options success|danger|warning|info
13
+ * @default info
14
+ *
15
+ * @prop showIcon {boolean} - Shows an icon matching the variant
16
+ * @default true
17
+ *
18
+ * @prop closable {boolean} - Shows a close button
19
+ * @default true
20
+ *
21
+ * @prop timeout {number} - Auto-hide timeout in milliseconds
22
+ * @default 3000
23
+ *
24
+ * @prop onClose {() => void} - Fired when the toast closes
25
+ * @default () => {}
26
+ *
27
+ * @prop class {string} - Additional wrapper classes
28
+ * @default ""
29
+ *
30
+ * @note Automatically hides after `timeout`.
31
+ * @note Can be closed manually if `closable = true`.
32
+ * @note Variant controls color and icon style.
33
+ */
34
+ import { fade } from "svelte/transition";
35
+ import type { ToastVariant } from "./types";
36
+ import NoticeBase from "./NoticeBase.svelte";
37
+
38
+ type Props = {
39
+ title?: string;
40
+ message: string;
41
+ variant?: ToastVariant;
42
+ showIcon?: boolean;
43
+ closable?: boolean;
44
+ timeout?: number;
45
+ onClose?: () => void;
46
+ class?: string;
47
+ };
48
+
49
+ let {
50
+ title,
51
+ message,
52
+ variant = "info",
53
+ showIcon = true,
54
+ closable = true,
55
+ timeout = 3000,
56
+ onClose = () => {},
57
+ class: externalClass = "",
58
+ }: Props = $props();
59
+
60
+ let visible = $state(true);
61
+
62
+ function variantClasses(v: ToastVariant) {
63
+ switch (v) {
64
+ case "success":
65
+ return "bg-[var(--color-bg-success)] text-[var(--color-text-success)]";
66
+ case "danger":
67
+ return "bg-[var(--color-bg-danger)] text-[var(--color-text-danger)]";
68
+ case "warning":
69
+ return "bg-[var(--color-bg-warning)] text-[var(--color-text-warning)]";
70
+ default:
71
+ return "bg-[var(--color-bg-page)] text-[var(--color-text-default)]";
72
+ }
73
+ }
74
+
75
+ function close() {
76
+ visible = false;
77
+ onClose();
78
+ }
79
+
80
+ $effect(() => {
81
+ if (timeout > 0) {
82
+ const id = setTimeout(() => close(), timeout);
83
+ return () => clearTimeout(id);
84
+ }
85
+ });
86
+
87
+ </script>
88
+
89
+ {#if visible}
90
+ {#snippet end()}
91
+ {#if closable}
92
+ <button
93
+ class="opacity-70 hover:opacity-100 transition-opacity duration-[var(--transition-fast)] ml-3"
94
+ aria-label="Close"
95
+ onclick={close}
96
+ >
97
+ <svg width="24" height="24" viewBox="0 0 20 20" fill="none">
98
+ <path
99
+ d="M7 7l6 6M13 7l-6 6"
100
+ stroke="currentColor"
101
+ stroke-width="2"
102
+ stroke-linecap="round"
103
+ />
104
+ </svg>
105
+ </button>
106
+ {/if}
107
+ {/snippet}
108
+
109
+ <div
110
+ class={`fixed bottom-4 right-4 min-w-[220px] max-w-[calc(100vw-2rem)] ${variantClasses(variant)} ${externalClass}`}
111
+ in:fade={{ duration: 200 }}
112
+ out:fade={{ duration: 200 }}
113
+ >
114
+ <NoticeBase
115
+ {title}
116
+ {message}
117
+ {variant}
118
+ {showIcon}
119
+ size="md"
120
+ end={end}
121
+ />
122
+ </div>
123
+ {/if}
@@ -1,110 +1,110 @@
1
- <!-- src/lib/Tooltip.svelte -->
2
- <script lang="ts">
3
- /**
4
- * @component Tooltip
5
- * @description Context-aware hint for inline controls and labels.
6
- *
7
- * @prop children {Snippet} - Inline trigger content
8
- *
9
- * @prop text {string} - Tooltip text
10
- *
11
- * @prop position {"top" | "bottom" | "left" | "right"} - Tooltip placement
12
- * @default "top"
13
- *
14
- * @prop delay {number} - Delay before showing the tooltip (ms)
15
- * @default 300
16
- *
17
- * @prop open {boolean} - Forces visibility when true
18
- * @default false
19
- *
20
- * @prop class {string} - Wrapper classes
21
- * @default ""
22
- *
23
- * @note Wraps any inline element and shows a floating bubble with `text`.
24
- * @note `open` overrides hover/focus behavior when set to `true`.
25
- * @note `position` controls which side of the trigger the bubble appears on.
26
- * @note `delay` adds a small pause before showing the tooltip to avoid flicker.
27
- * @note `class` is applied to the root wrapper, useful for layout tweaks.
28
- */
29
- import type { Snippet } from "svelte";
30
- import type { HTMLAttributes } from "svelte/elements";
31
- import type { Position } from "./types";
32
- import { cx } from "../utils";
33
-
34
- type Props = HTMLAttributes<HTMLDivElement> & {
35
- children?: Snippet;
36
- position?: Position;
37
- delay?: number;
38
- open?: boolean;
39
- text?: string;
40
- class?: string;
41
- };
42
-
43
- let {
44
- children,
45
- position = "top",
46
- delay = 300,
47
- open = false,
48
- text = "",
49
- class: externalClass = "",
50
- ...rest
51
- }: Props = $props();
52
-
53
- let visible = $state(false);
54
- let isHover = $state(false);
55
- let isFocus = $state(false);
56
- let timeout: ReturnType<typeof setTimeout> | undefined;
57
-
58
- const show = $derived(open || isHover || isFocus);
59
-
60
- $effect(() => {
61
- if (timeout) clearTimeout(timeout);
62
-
63
- if (show) {
64
- timeout = setTimeout(() => {
65
- visible = true;
66
- }, delay);
67
- } else {
68
- visible = false;
69
- }
70
-
71
- return () => {
72
- if (timeout) clearTimeout(timeout);
73
- };
74
- });
75
-
76
- const positionClass: Record<Position, string> = {
77
- top: "bottom-full left-1/2 -translate-x-1/2 mb-[var(--spacing-sm)]",
78
- bottom: "top-full left-1/2 -translate-x-1/2 mt-[var(--spacing-sm)]",
79
- left: "right-full top-1/2 -translate-y-1/2 mr-[var(--spacing-sm)]",
80
- right: "left-full top-1/2 -translate-y-1/2 ml-[var(--spacing-sm)]",
81
- };
82
-
83
- const rootClass = $derived(cx("relative inline-block", externalClass));
84
-
85
- const bubbleClass = $derived(
86
- cx(
87
- "absolute z-20 p-[calc(var(--spacing-xs)/2)] italic [font-size:var(--text-xs)] font-medium whitespace-nowrap rounded-[var(--radius-sm)]",
88
- "bg-[var(--color-bg-surface)] text-[var(--color-text-default)] shadow-[0_8px_16px_var(--shadow-color)] border border-[var(--border-color-default)]",
89
- "transition-opacity duration-[var(--transition-fast)] ease-linear",
90
- visible ? "opacity-100" : "opacity-0 pointer-events-none"
91
- )
92
- );
93
- </script>
94
-
95
- <div
96
- class={rootClass}
97
- onmouseenter={() => (isHover = true)}
98
- onmouseleave={() => (isHover = false)}
99
- onfocus={() => (isFocus = true)}
100
- onblur={() => (isFocus = false)}
101
- {...rest}
102
- >
103
- {@render children?.()}
104
-
105
- {#if text && visible}
106
- <div role="tooltip" class={cx(bubbleClass, positionClass[position])}>
107
- {text}
108
- </div>
109
- {/if}
110
- </div>
1
+ <!-- src/lib/Tooltip.svelte -->
2
+ <script lang="ts">
3
+ /**
4
+ * @component Tooltip
5
+ * @description Context-aware hint for inline controls and labels.
6
+ *
7
+ * @prop children {Snippet} - Inline trigger content
8
+ *
9
+ * @prop text {string} - Tooltip text
10
+ *
11
+ * @prop position {"top" | "bottom" | "left" | "right"} - Tooltip placement
12
+ * @default "top"
13
+ *
14
+ * @prop delay {number} - Delay before showing the tooltip (ms)
15
+ * @default 300
16
+ *
17
+ * @prop open {boolean} - Forces visibility when true
18
+ * @default false
19
+ *
20
+ * @prop class {string} - Wrapper classes
21
+ * @default ""
22
+ *
23
+ * @note Wraps any inline element and shows a floating bubble with `text`.
24
+ * @note `open` overrides hover/focus behavior when set to `true`.
25
+ * @note `position` controls which side of the trigger the bubble appears on.
26
+ * @note `delay` adds a small pause before showing the tooltip to avoid flicker.
27
+ * @note `class` is applied to the root wrapper, useful for layout tweaks.
28
+ */
29
+ import type { Snippet } from "svelte";
30
+ import type { HTMLAttributes } from "svelte/elements";
31
+ import type { Position } from "./types";
32
+ import { cx } from "../utils";
33
+
34
+ type Props = HTMLAttributes<HTMLDivElement> & {
35
+ children?: Snippet;
36
+ position?: Position;
37
+ delay?: number;
38
+ open?: boolean;
39
+ text?: string;
40
+ class?: string;
41
+ };
42
+
43
+ let {
44
+ children,
45
+ position = "top",
46
+ delay = 300,
47
+ open = false,
48
+ text = "",
49
+ class: externalClass = "",
50
+ ...rest
51
+ }: Props = $props();
52
+
53
+ let visible = $state(false);
54
+ let isHover = $state(false);
55
+ let isFocus = $state(false);
56
+ let timeout: ReturnType<typeof setTimeout> | undefined;
57
+
58
+ const show = $derived(open || isHover || isFocus);
59
+
60
+ $effect(() => {
61
+ if (timeout) clearTimeout(timeout);
62
+
63
+ if (show) {
64
+ timeout = setTimeout(() => {
65
+ visible = true;
66
+ }, delay);
67
+ } else {
68
+ visible = false;
69
+ }
70
+
71
+ return () => {
72
+ if (timeout) clearTimeout(timeout);
73
+ };
74
+ });
75
+
76
+ const positionClass: Record<Position, string> = {
77
+ top: "bottom-full left-1/2 -translate-x-1/2 mb-[var(--spacing-sm)]",
78
+ bottom: "top-full left-1/2 -translate-x-1/2 mt-[var(--spacing-sm)]",
79
+ left: "right-full top-1/2 -translate-y-1/2 mr-[var(--spacing-sm)]",
80
+ right: "left-full top-1/2 -translate-y-1/2 ml-[var(--spacing-sm)]",
81
+ };
82
+
83
+ const rootClass = $derived(cx("relative inline-block", externalClass));
84
+
85
+ const bubbleClass = $derived(
86
+ cx(
87
+ "absolute z-20 p-[calc(var(--spacing-xs)/2)] italic [font-size:var(--text-xs)] font-medium whitespace-nowrap rounded-[var(--radius-sm)]",
88
+ "bg-[var(--color-bg-surface)] text-[var(--color-text-default)] shadow-[0_8px_16px_var(--shadow-color)] border border-[var(--border-color-default)]",
89
+ "transition-opacity duration-[var(--transition-fast)] ease-linear",
90
+ visible ? "opacity-100" : "opacity-0 pointer-events-none"
91
+ )
92
+ );
93
+ </script>
94
+
95
+ <div
96
+ class={rootClass}
97
+ onmouseenter={() => (isHover = true)}
98
+ onmouseleave={() => (isHover = false)}
99
+ onfocus={() => (isFocus = true)}
100
+ onblur={() => (isFocus = false)}
101
+ {...rest}
102
+ >
103
+ {@render children?.()}
104
+
105
+ {#if text && visible}
106
+ <div role="tooltip" class={cx(bubbleClass, positionClass[position])}>
107
+ {text}
108
+ </div>
109
+ {/if}
110
+ </div>