svelte-comp 1.3.3 → 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 (138) hide show
  1. package/LICENSE.md +21 -21
  2. package/README.md +101 -100
  3. package/dist/App.svelte +507 -507
  4. package/dist/Container.svelte +59 -59
  5. package/dist/app.css +234 -235
  6. package/dist/app.d.ts +10 -0
  7. package/dist/lib/Accordion.svelte +155 -155
  8. package/dist/lib/Badge.svelte +44 -44
  9. package/dist/lib/Button.svelte +185 -170
  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/Carousel.svelte.d.ts +1 -1
  14. package/dist/lib/CheckBox.svelte +210 -210
  15. package/dist/lib/CodeView.svelte +308 -307
  16. package/dist/lib/ColorPicker.svelte +159 -159
  17. package/dist/lib/ContextMenu.svelte +328 -322
  18. package/dist/lib/DatePicker.svelte +246 -246
  19. package/dist/lib/Dialog.svelte +233 -233
  20. package/dist/lib/Field.svelte +299 -299
  21. package/dist/lib/FilePicker.svelte +295 -240
  22. package/dist/lib/FilePicker.svelte.d.ts +6 -1
  23. package/dist/lib/Form.svelte +438 -438
  24. package/dist/lib/Hamburger.svelte +217 -217
  25. package/dist/lib/InstallPWA.svelte +94 -94
  26. package/dist/lib/Menu.svelte +623 -623
  27. package/dist/lib/NoticeBase.svelte +140 -140
  28. package/dist/lib/PaginatedCard.svelte +73 -73
  29. package/dist/lib/Pagination.svelte +119 -119
  30. package/dist/lib/PrimaryColorSelect.svelte +111 -111
  31. package/dist/lib/ProgressBar.svelte +141 -141
  32. package/dist/lib/ProgressCircle.svelte +190 -190
  33. package/dist/lib/Radio.svelte +189 -189
  34. package/dist/lib/SearchInput.svelte +104 -104
  35. package/dist/lib/Select.svelte +524 -524
  36. package/dist/lib/Slider.svelte +253 -253
  37. package/dist/lib/Splitter.svelte +159 -150
  38. package/dist/lib/Switch.svelte +168 -167
  39. package/dist/lib/Table.svelte +299 -299
  40. package/dist/lib/Tabs.svelte +213 -213
  41. package/dist/lib/ThemeToggle.svelte +128 -127
  42. package/dist/lib/TimePicker.svelte +312 -312
  43. package/dist/lib/TimePickerNew.svelte +634 -0
  44. package/dist/lib/TimePickerNew.svelte.d.ts +49 -0
  45. package/dist/lib/Toast.svelte +123 -123
  46. package/dist/lib/Tooltip.svelte +110 -110
  47. package/dist/lib/Topbar.svelte +107 -107
  48. package/dist/lib/__tests__/Accordion.test.d.ts +1 -0
  49. package/dist/lib/__tests__/Accordion.test.js +171 -0
  50. package/dist/lib/__tests__/Badge.test.d.ts +1 -0
  51. package/dist/lib/__tests__/Badge.test.js +41 -0
  52. package/dist/lib/__tests__/Button.test.d.ts +1 -0
  53. package/dist/lib/__tests__/Button.test.js +269 -0
  54. package/dist/lib/__tests__/Calendar.test.d.ts +1 -0
  55. package/dist/lib/__tests__/Calendar.test.js +171 -0
  56. package/dist/lib/__tests__/Card.test.d.ts +1 -0
  57. package/dist/lib/__tests__/Card.test.js +148 -0
  58. package/dist/lib/__tests__/Carousel.test.d.ts +1 -0
  59. package/dist/lib/__tests__/Carousel.test.js +439 -0
  60. package/dist/lib/__tests__/CheckBox.test.d.ts +1 -0
  61. package/dist/lib/__tests__/CheckBox.test.js +152 -0
  62. package/dist/lib/__tests__/CodeView.test.d.ts +1 -0
  63. package/dist/lib/__tests__/CodeView.test.js +157 -0
  64. package/dist/lib/__tests__/ColorPicker.test.d.ts +1 -0
  65. package/dist/lib/__tests__/ColorPicker.test.js +93 -0
  66. package/dist/lib/__tests__/ContextMenu.test.d.ts +1 -0
  67. package/dist/lib/__tests__/ContextMenu.test.js +67 -0
  68. package/dist/lib/__tests__/DatePicker.test.d.ts +1 -0
  69. package/dist/lib/__tests__/DatePicker.test.js +108 -0
  70. package/dist/lib/__tests__/Dialog.test.d.ts +1 -0
  71. package/dist/lib/__tests__/Dialog.test.js +183 -0
  72. package/dist/lib/__tests__/Field.test.d.ts +1 -0
  73. package/dist/lib/__tests__/Field.test.js +190 -0
  74. package/dist/lib/__tests__/FilePicker.test.d.ts +1 -0
  75. package/dist/lib/__tests__/FilePicker.test.js +179 -0
  76. package/dist/lib/__tests__/Form.integration.test.d.ts +1 -0
  77. package/dist/lib/__tests__/Form.integration.test.js +158 -0
  78. package/dist/lib/__tests__/Form.test.d.ts +1 -0
  79. package/dist/lib/__tests__/Form.test.js +463 -0
  80. package/dist/lib/__tests__/Hamburger.test.d.ts +1 -0
  81. package/dist/lib/__tests__/Hamburger.test.js +161 -0
  82. package/dist/lib/__tests__/InstallPWA.test.d.ts +1 -0
  83. package/dist/lib/__tests__/InstallPWA.test.js +15 -0
  84. package/dist/lib/__tests__/Menu.test.d.ts +1 -0
  85. package/dist/lib/__tests__/Menu.test.js +285 -0
  86. package/dist/lib/__tests__/NoticeBase.test.d.ts +1 -0
  87. package/dist/lib/__tests__/NoticeBase.test.js +60 -0
  88. package/dist/lib/__tests__/PaginatedCard.test.d.ts +1 -0
  89. package/dist/lib/__tests__/PaginatedCard.test.js +89 -0
  90. package/dist/lib/__tests__/Pagination.test.d.ts +1 -0
  91. package/dist/lib/__tests__/Pagination.test.js +168 -0
  92. package/dist/lib/__tests__/PrimaryColorSelect.test.d.ts +1 -0
  93. package/dist/lib/__tests__/PrimaryColorSelect.test.js +92 -0
  94. package/dist/lib/__tests__/ProgressBar.test.d.ts +1 -0
  95. package/dist/lib/__tests__/ProgressBar.test.js +69 -0
  96. package/dist/lib/__tests__/ProgressCircle.test.d.ts +1 -0
  97. package/dist/lib/__tests__/ProgressCircle.test.js +71 -0
  98. package/dist/lib/__tests__/Radio.test.d.ts +1 -0
  99. package/dist/lib/__tests__/Radio.test.js +127 -0
  100. package/dist/lib/__tests__/SearchInput.test.d.ts +1 -0
  101. package/dist/lib/__tests__/SearchInput.test.js +80 -0
  102. package/dist/lib/__tests__/Select.test.d.ts +1 -0
  103. package/dist/lib/__tests__/Select.test.js +408 -0
  104. package/dist/lib/__tests__/Slider.test.d.ts +1 -0
  105. package/dist/lib/__tests__/Slider.test.js +213 -0
  106. package/dist/lib/__tests__/Splitter.test.d.ts +1 -0
  107. package/dist/lib/__tests__/Splitter.test.js +87 -0
  108. package/dist/lib/__tests__/Switch.test.d.ts +1 -0
  109. package/dist/lib/__tests__/Switch.test.js +97 -0
  110. package/dist/lib/__tests__/Table.test.d.ts +1 -0
  111. package/dist/lib/__tests__/Table.test.js +349 -0
  112. package/dist/lib/__tests__/Tabs.test.d.ts +1 -0
  113. package/dist/lib/__tests__/Tabs.test.js +262 -0
  114. package/dist/lib/__tests__/ThemeToggle.test.d.ts +1 -0
  115. package/dist/lib/__tests__/ThemeToggle.test.js +84 -0
  116. package/dist/lib/__tests__/TimePicker.test.d.ts +1 -0
  117. package/dist/lib/__tests__/TimePicker.test.js +146 -0
  118. package/dist/lib/__tests__/TimePickerNew.test.d.ts +1 -0
  119. package/dist/lib/__tests__/TimePickerNew.test.js +322 -0
  120. package/dist/lib/__tests__/Toast.test.d.ts +1 -0
  121. package/dist/lib/__tests__/Toast.test.js +135 -0
  122. package/dist/lib/__tests__/Tooltip.test.d.ts +1 -0
  123. package/dist/lib/__tests__/Tooltip.test.js +171 -0
  124. package/dist/lib/__tests__/Topbar.test.d.ts +1 -0
  125. package/dist/lib/__tests__/Topbar.test.js +25 -0
  126. package/dist/lib/__tests__/setupLangContext.d.ts +1 -0
  127. package/dist/lib/__tests__/setupLangContext.js +65 -0
  128. package/dist/lib/__tests__/storage.test.d.ts +1 -0
  129. package/dist/lib/__tests__/storage.test.js +124 -0
  130. package/dist/lib/__tests__/utils.test.d.ts +1 -0
  131. package/dist/lib/__tests__/utils.test.js +11 -0
  132. package/dist/lib/index.d.ts +1 -0
  133. package/dist/lib/index.js +1 -0
  134. package/dist/lib/lang.d.ts +4 -0
  135. package/dist/lib/lang.js +4 -0
  136. package/dist/styles.css +234 -232
  137. package/dist/utils/index.js +15 -4
  138. 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>