@placeholderco/placeholder-ui 2.6.1 → 2.6.3
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.
package/dist/form/Number.svelte
CHANGED
|
@@ -45,6 +45,10 @@
|
|
|
45
45
|
errorText?: string;
|
|
46
46
|
/** Position of the tooltip */
|
|
47
47
|
tooltipLocation?: 'top' | 'bottom' | 'left' | 'right';
|
|
48
|
+
/** Rich tooltip content using a Svelte snippet */
|
|
49
|
+
tooltipContent?: Snippet;
|
|
50
|
+
/** Tooltip text on hover */
|
|
51
|
+
tooltipText?: string;
|
|
48
52
|
/** Minimum allowed value */
|
|
49
53
|
min?: number;
|
|
50
54
|
/** Maximum allowed value */
|
|
@@ -93,6 +97,8 @@
|
|
|
93
97
|
showError = false,
|
|
94
98
|
errorText = '',
|
|
95
99
|
tooltipLocation = 'top',
|
|
100
|
+
tooltipContent = undefined,
|
|
101
|
+
tooltipText = undefined,
|
|
96
102
|
min = undefined,
|
|
97
103
|
max = undefined,
|
|
98
104
|
step = undefined,
|
|
@@ -152,7 +158,15 @@
|
|
|
152
158
|
</script>
|
|
153
159
|
|
|
154
160
|
<div class="number-container {containerClass}">
|
|
155
|
-
<FormGroup
|
|
161
|
+
<FormGroup
|
|
162
|
+
{label}
|
|
163
|
+
{required}
|
|
164
|
+
{id}
|
|
165
|
+
class={groupClass}
|
|
166
|
+
{tooltipLocation}
|
|
167
|
+
{tooltipContent}
|
|
168
|
+
{tooltipText}
|
|
169
|
+
>
|
|
156
170
|
<div class="number-input">
|
|
157
171
|
<!-- svelte-ignore a11y_autofocus -->
|
|
158
172
|
<input
|
|
@@ -38,6 +38,10 @@ export interface NumberProps {
|
|
|
38
38
|
errorText?: string;
|
|
39
39
|
/** Position of the tooltip */
|
|
40
40
|
tooltipLocation?: 'top' | 'bottom' | 'left' | 'right';
|
|
41
|
+
/** Rich tooltip content using a Svelte snippet */
|
|
42
|
+
tooltipContent?: Snippet;
|
|
43
|
+
/** Tooltip text on hover */
|
|
44
|
+
tooltipText?: string;
|
|
41
45
|
/** Minimum allowed value */
|
|
42
46
|
min?: number;
|
|
43
47
|
/** Maximum allowed value */
|
|
@@ -33,11 +33,27 @@
|
|
|
33
33
|
// Calculate selected index for background positioning using derived state
|
|
34
34
|
const selectedIndex = $derived(options.findIndex((option) => option.value === value));
|
|
35
35
|
|
|
36
|
+
// Pending timers, cleared on destroy so they never read state after the component is gone
|
|
37
|
+
const pendingTimers = new Set<ReturnType<typeof setTimeout>>();
|
|
38
|
+
|
|
39
|
+
function scheduleRecalculate(delay: number) {
|
|
40
|
+
const id = setTimeout(() => {
|
|
41
|
+
pendingTimers.delete(id);
|
|
42
|
+
recalculateBackground();
|
|
43
|
+
}, delay);
|
|
44
|
+
pendingTimers.add(id);
|
|
45
|
+
}
|
|
46
|
+
|
|
36
47
|
onMount(() => {
|
|
37
48
|
// recalculate 10 times on startup to ensure background is positioned correctly
|
|
38
49
|
for (let i = 0; i < 10; i++) {
|
|
39
|
-
|
|
50
|
+
scheduleRecalculate(100 * i);
|
|
40
51
|
}
|
|
52
|
+
|
|
53
|
+
return () => {
|
|
54
|
+
for (const id of pendingTimers) clearTimeout(id);
|
|
55
|
+
pendingTimers.clear();
|
|
56
|
+
};
|
|
41
57
|
});
|
|
42
58
|
|
|
43
59
|
// Update background position and size based on selected element
|
|
@@ -60,7 +76,7 @@
|
|
|
60
76
|
*/
|
|
61
77
|
export function recalculateBackground(delay?: number) {
|
|
62
78
|
if (delay) {
|
|
63
|
-
|
|
79
|
+
scheduleRecalculate(delay);
|
|
64
80
|
return;
|
|
65
81
|
}
|
|
66
82
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@placeholderco/placeholder-ui",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.3",
|
|
4
4
|
"description": "A modern, customizable Svelte 5 UI component library with comprehensive theming support. Re-brand it with a single config object.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Placeholderco",
|