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,159 +1,159 @@
1
- <!-- src/lib/ColorPicker.svelte -->
2
- <script lang="ts">
3
- /**
4
- * @component ColorPicker
5
- * @description Accessible wrapper around the native `<input type="color">` with a trigger button and preview card.
6
- *
7
- * @prop value {string | null} - Selected color value (hex)
8
- * @default null
9
- *
10
- * @prop label {string} - Label displayed above the control
11
- *
12
- * @prop placeholder {string} - Placeholder text when no color is chosen
13
- *
14
- * @prop disabled {boolean} - Disables all interactions
15
- * @default false
16
- *
17
- * @prop clearable {boolean} - Shows a clear/reset button
18
- * @default true
19
- *
20
- * @prop onChange {(value: string | null) => void} - Fired when the color changes
21
- *
22
- * @prop class {string} - Additional classes for the wrapper element
23
- * @default ""
24
- *
25
- * @note Uses the new `HTMLInputElement.showPicker()` API when available; falls back to focusing/clicking the hidden input.
26
- * @note Keeps the hidden color input in sync with controlled `value` through `$effect`.
27
- * @note Preview swatch mirrors the current color and announces via `aria-label`.
28
- * @note `clearable=false` hides the clear button; when `disabled`, pointer/keyboard handlers are skipped.
29
- */
30
- import type { HTMLAttributes } from "svelte/elements";
31
- import Button from "./Button.svelte";
32
- import { cx } from "../utils";
33
- import { getComponentText, getLangContext, getLangKey } from "./lang-context";
34
-
35
- type Props = HTMLAttributes<HTMLDivElement> & {
36
- value?: string | null;
37
- label?: string;
38
- placeholder?: string;
39
- disabled?: boolean;
40
- clearable?: boolean;
41
- onChange?: (value: string | null) => void;
42
- class?: string;
43
- };
44
-
45
- let {
46
- value = $bindable<string | null>(null),
47
- label,
48
- placeholder,
49
- disabled = false,
50
- clearable = true,
51
- onChange,
52
- class: externalClass = "",
53
- ...rest
54
- }: Props = $props();
55
-
56
- const langCtx = getLangContext();
57
- const langKey = $derived(getLangKey(langCtx));
58
- const L = $derived(getComponentText("colorPicker", langKey));
59
-
60
- const labelFinal = $derived(label ?? L.text);
61
- const placeholderFinal = $derived(placeholder ?? L.placeholder);
62
-
63
- let inputEl: HTMLInputElement;
64
-
65
- const base = "inline-block w-full";
66
- const pickerClass = $derived(cx(base, externalClass));
67
-
68
- const hasValue = $derived(Boolean(value));
69
- const previewColor = $derived(value ?? "transparent");
70
-
71
- $effect(() => {
72
- if (inputEl) {
73
- inputEl.value = value || "#000000";
74
- }
75
- });
76
-
77
- function openPicker() {
78
- if (disabled) return;
79
- if (typeof inputEl?.showPicker === "function") {
80
- inputEl.showPicker();
81
- } else {
82
- inputEl?.focus();
83
- inputEl?.click();
84
- }
85
- }
86
-
87
- function handleInput(event: Event) {
88
- const target = event.target as HTMLInputElement;
89
- const nextValue = target.value || null;
90
- value = nextValue;
91
- onChange?.(nextValue);
92
- }
93
-
94
- function clearSelection() {
95
- if (!clearable) return;
96
- value = null;
97
- if (inputEl) {
98
- inputEl.value = "#000000";
99
- }
100
- onChange?.(null);
101
- }
102
- </script>
103
-
104
- <div class={pickerClass} {...rest}>
105
- <div class="text-md font-medium mb-2 [color:var(--color-text-default)]">
106
- {labelFinal}:
107
- </div>
108
- <div class="flex flex-wrap items-center gap-x-3 gap-y-2">
109
- <Button onClick={openPicker} {disabled} sz="xs">
110
- {L.color}
111
- </Button>
112
-
113
- {#if clearable}
114
- <Button
115
- onClick={clearSelection}
116
- variant="danger"
117
- disabled={!hasValue || disabled}
118
- sz="xs"
119
- >
120
- {L.clear}
121
- </Button>
122
- {/if}
123
- </div>
124
-
125
- <input
126
- bind:this={inputEl}
127
- type="color"
128
- {disabled}
129
- class="invisible absolute w-px h-px"
130
- onchange={handleInput}
131
- value="#000000"
132
- />
133
-
134
- <div
135
- class="mt-3 p-4 border border-dashed border-[var(--border-color-default)] rounded-[var(--radius-md)] bg-[var(--color-bg-surface)] flex items-center justify-between gap-3"
136
- aria-live="polite"
137
- >
138
- <div>
139
- <p
140
- class="text-xs uppercase tracking-wide [color:var(--color-text-muted)]"
141
- >
142
- {L.selectedColor}
143
- </p>
144
- <p class="text-sm font-semibold mt-1 [color:var(--color-text-default)]">
145
- {#if hasValue}
146
- {value}
147
- {:else}
148
- {placeholderFinal}
149
- {/if}
150
- </p>
151
- </div>
152
-
153
- <div
154
- class="w-12 h-12 rounded-[var(--radius-sm)] border border-[var(--border-color-default)] shadow-inner"
155
- aria-label={hasValue ? `Preview of ${value}` : "No color selected"}
156
- style={`background:${previewColor}`}
157
- ></div>
158
- </div>
159
- </div>
1
+ <!-- src/lib/ColorPicker.svelte -->
2
+ <script lang="ts">
3
+ /**
4
+ * @component ColorPicker
5
+ * @description Accessible wrapper around the native `<input type="color">` with a trigger button and preview card.
6
+ *
7
+ * @prop value {string | null} - Selected color value (hex)
8
+ * @default null
9
+ *
10
+ * @prop label {string} - Label displayed above the control
11
+ *
12
+ * @prop placeholder {string} - Placeholder text when no color is chosen
13
+ *
14
+ * @prop disabled {boolean} - Disables all interactions
15
+ * @default false
16
+ *
17
+ * @prop clearable {boolean} - Shows a clear/reset button
18
+ * @default true
19
+ *
20
+ * @prop onChange {(value: string | null) => void} - Fired when the color changes
21
+ *
22
+ * @prop class {string} - Additional classes for the wrapper element
23
+ * @default ""
24
+ *
25
+ * @note Uses the new `HTMLInputElement.showPicker()` API when available; falls back to focusing/clicking the hidden input.
26
+ * @note Keeps the hidden color input in sync with controlled `value` through `$effect`.
27
+ * @note Preview swatch mirrors the current color and announces via `aria-label`.
28
+ * @note `clearable=false` hides the clear button; when `disabled`, pointer/keyboard handlers are skipped.
29
+ */
30
+ import type { HTMLAttributes } from "svelte/elements";
31
+ import Button from "./Button.svelte";
32
+ import { cx } from "../utils";
33
+ import { getComponentText, getLangContext, getLangKey } from "./lang-context";
34
+
35
+ type Props = HTMLAttributes<HTMLDivElement> & {
36
+ value?: string | null;
37
+ label?: string;
38
+ placeholder?: string;
39
+ disabled?: boolean;
40
+ clearable?: boolean;
41
+ onChange?: (value: string | null) => void;
42
+ class?: string;
43
+ };
44
+
45
+ let {
46
+ value = $bindable<string | null>(null),
47
+ label,
48
+ placeholder,
49
+ disabled = false,
50
+ clearable = true,
51
+ onChange,
52
+ class: externalClass = "",
53
+ ...rest
54
+ }: Props = $props();
55
+
56
+ const langCtx = getLangContext();
57
+ const langKey = $derived(getLangKey(langCtx));
58
+ const L = $derived(getComponentText("colorPicker", langKey));
59
+
60
+ const labelFinal = $derived(label ?? L.text);
61
+ const placeholderFinal = $derived(placeholder ?? L.placeholder);
62
+
63
+ let inputEl: HTMLInputElement;
64
+
65
+ const base = "inline-block w-full";
66
+ const pickerClass = $derived(cx(base, externalClass));
67
+
68
+ const hasValue = $derived(Boolean(value));
69
+ const previewColor = $derived(value ?? "transparent");
70
+
71
+ $effect(() => {
72
+ if (inputEl) {
73
+ inputEl.value = value || "#000000";
74
+ }
75
+ });
76
+
77
+ function openPicker() {
78
+ if (disabled) return;
79
+ if (typeof inputEl?.showPicker === "function") {
80
+ inputEl.showPicker();
81
+ } else {
82
+ inputEl?.focus();
83
+ inputEl?.click();
84
+ }
85
+ }
86
+
87
+ function handleInput(event: Event) {
88
+ const target = event.target as HTMLInputElement;
89
+ const nextValue = target.value || null;
90
+ value = nextValue;
91
+ onChange?.(nextValue);
92
+ }
93
+
94
+ function clearSelection() {
95
+ if (!clearable) return;
96
+ value = null;
97
+ if (inputEl) {
98
+ inputEl.value = "#000000";
99
+ }
100
+ onChange?.(null);
101
+ }
102
+ </script>
103
+
104
+ <div class={pickerClass} {...rest}>
105
+ <div class="text-md font-medium mb-2 [color:var(--color-text-default)]">
106
+ {labelFinal}:
107
+ </div>
108
+ <div class="flex flex-wrap items-center gap-x-3 gap-y-2">
109
+ <Button onClick={openPicker} {disabled} sz="xs">
110
+ {L.color}
111
+ </Button>
112
+
113
+ {#if clearable}
114
+ <Button
115
+ onClick={clearSelection}
116
+ variant="danger"
117
+ disabled={!hasValue || disabled}
118
+ sz="xs"
119
+ >
120
+ {L.clear}
121
+ </Button>
122
+ {/if}
123
+ </div>
124
+
125
+ <input
126
+ bind:this={inputEl}
127
+ type="color"
128
+ {disabled}
129
+ class="invisible absolute w-px h-px"
130
+ onchange={handleInput}
131
+ value="#000000"
132
+ />
133
+
134
+ <div
135
+ class="mt-3 p-4 border border-dashed border-[var(--border-color-default)] rounded-[var(--radius-md)] bg-[var(--color-bg-surface)] flex items-center justify-between gap-3"
136
+ aria-live="polite"
137
+ >
138
+ <div>
139
+ <p
140
+ class="text-xs uppercase tracking-wide [color:var(--color-text-muted)]"
141
+ >
142
+ {L.selectedColor}
143
+ </p>
144
+ <p class="text-sm font-semibold mt-1 [color:var(--color-text-default)]">
145
+ {#if hasValue}
146
+ {value}
147
+ {:else}
148
+ {placeholderFinal}
149
+ {/if}
150
+ </p>
151
+ </div>
152
+
153
+ <div
154
+ class="w-12 h-12 rounded-[var(--radius-sm)] border border-[var(--border-color-default)] shadow-inner"
155
+ aria-label={hasValue ? `Preview of ${value}` : "No color selected"}
156
+ style={`background:${previewColor}`}
157
+ ></div>
158
+ </div>
159
+ </div>