@widgetic/editor 4.1.14 → 4.1.16

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 (76) hide show
  1. package/dist/components/PreviewChromeControls.svelte +15 -21
  2. package/dist/components/WidgetPreview.svelte +136 -105
  3. package/dist/components/color-select/ColorSelect.svelte +203 -224
  4. package/dist/components/color-select/constants.d.ts +4 -2
  5. package/dist/components/color-select/constants.js +4 -2
  6. package/dist/components/color-select/render.js +10 -9
  7. package/dist/components/editors/CompositionEditorApp.svelte +47 -40
  8. package/dist/components/editors/EditLeaseNotice.svelte +44 -33
  9. package/dist/components/editors/EmbedEditor.svelte +133 -259
  10. package/dist/components/editors/PropsEditor.svelte +418 -1338
  11. package/dist/components/editors/props-editor.css +5 -68
  12. package/dist/components/ic/AngleInputController.svelte +202 -277
  13. package/dist/components/ic/BrowserInputController.svelte +813 -803
  14. package/dist/components/ic/CheckboxInputController.svelte +92 -169
  15. package/dist/components/ic/CheckboxInputController.svelte.d.ts +2 -8
  16. package/dist/components/ic/ColorPickerInputController.svelte +1589 -1587
  17. package/dist/components/ic/ColorPickerInputController.svelte.d.ts +3 -3
  18. package/dist/components/ic/DateFieldInputController.svelte +455 -465
  19. package/dist/components/ic/DatePickerInputController.svelte +355 -368
  20. package/dist/components/ic/DatePickerInputController.svelte.d.ts +1 -1
  21. package/dist/components/ic/DropdownInputController.svelte +130 -200
  22. package/dist/components/ic/FixedPositionInputController.svelte +255 -276
  23. package/dist/components/ic/FixedPositionInputController.svelte.d.ts +5 -1
  24. package/dist/components/ic/FontInputController.svelte +2110 -2231
  25. package/dist/components/ic/FontInputController.svelte.d.ts +11 -11
  26. package/dist/components/ic/InputControllerHeader.svelte +141 -147
  27. package/dist/components/ic/InputControllerRow.svelte +74 -0
  28. package/dist/components/ic/InputControllerRow.svelte.d.ts +14 -0
  29. package/dist/components/ic/KnowledgeDocumentsInputController.svelte +84 -47
  30. package/dist/components/ic/KnowledgeTextForm.svelte +35 -33
  31. package/dist/components/ic/NumberControls.svelte +303 -269
  32. package/dist/components/ic/NumberControls.svelte.d.ts +4 -1
  33. package/dist/components/ic/NumberInputController.svelte +361 -301
  34. package/dist/components/ic/NumberInputController.svelte.d.ts +2 -0
  35. package/dist/components/ic/PositionInputController.svelte +253 -176
  36. package/dist/components/ic/PositionInputController.svelte.d.ts +2 -0
  37. package/dist/components/ic/RadioGroupInputController.svelte +71 -137
  38. package/dist/components/ic/RadioGroupInputController.svelte.d.ts +2 -8
  39. package/dist/components/ic/RangeCalendarInputController.svelte +233 -270
  40. package/dist/components/ic/RangeCalendarInputController.svelte.d.ts +2 -2
  41. package/dist/components/ic/RoundedCornersInputController.svelte +412 -435
  42. package/dist/components/ic/RoundedCornersInputController.svelte.d.ts +2 -0
  43. package/dist/components/ic/SliderInputController.svelte +263 -332
  44. package/dist/components/ic/SliderInputController.svelte.d.ts +1 -1
  45. package/dist/components/ic/SliderRangeInputController.svelte +140 -144
  46. package/dist/components/ic/SliderRangeInputController.svelte.d.ts +3 -3
  47. package/dist/components/ic/SwitchInputController.svelte +47 -109
  48. package/dist/components/ic/TagsInputController.svelte +95 -110
  49. package/dist/components/ic/TextAreaInputController.svelte +1794 -1935
  50. package/dist/components/ic/TextAreaPreviewInputController.svelte +436 -438
  51. package/dist/components/ic/TextAreaPreviewInputController.svelte.d.ts +2 -2
  52. package/dist/components/ic/TextInputController.svelte +65 -75
  53. package/dist/components/ic/TextInputController.svelte.d.ts +2 -0
  54. package/dist/components/ic/TimeInputController.svelte +433 -431
  55. package/dist/components/ic/VectorInputController.svelte +1833 -1831
  56. package/dist/components/ic/VectorInputController.svelte.d.ts +10 -10
  57. package/dist/components/ic/index.d.ts +1 -0
  58. package/dist/components/ic/index.js +1 -0
  59. package/dist/components/ic/shared/CategoryTabs.svelte +28 -35
  60. package/dist/components/ic/shared/ItemGrid.svelte +145 -179
  61. package/dist/components/ic/shared/RecentItemsSection.svelte +208 -271
  62. package/dist/components/ic/shared/RecentItemsSection.svelte.d.ts +1 -1
  63. package/dist/components/ui/arrows/OpacitySliderArrows.svelte +23 -38
  64. package/dist/components/ui/arrows/OpacitySliderArrows.svelte.d.ts +1 -4
  65. package/dist/components/ui/calendar-editor-fit/EditorCalendarStyles.svelte +45 -0
  66. package/dist/components/ui/calendar-editor-fit/EditorCalendarStyles.svelte.d.ts +26 -0
  67. package/dist/components/ui/checkerboard-background/CheckerboardBackground.svelte +20 -12
  68. package/dist/components/ui/shadow-picker-host/ShadowPickerHost.svelte +39 -0
  69. package/dist/components/ui/shadow-picker-host/ShadowPickerHost.svelte.d.ts +10 -0
  70. package/dist/i18n/language.d.ts +44 -281
  71. package/dist/i18n/messages.d.ts +41 -34
  72. package/dist/i18n/messages.js +47 -34
  73. package/dist/i18n/translate.d.ts +1 -1
  74. package/dist/utils.d.ts +7 -0
  75. package/dist/utils.js +26 -2
  76. package/package.json +5 -5
@@ -1,20 +1,33 @@
1
1
  <script module lang="ts">
2
- import type { InputControllerConfig } from './index';
2
+ import type { InputControllerConfig } from './index';
3
3
 
4
+ /** Declared props contract — export lets below are annotated from it so the
5
+ * interface cannot drift from what the component actually reads. */
4
6
  /** Declared props contract — export lets below are annotated from it so the
5
7
  * interface cannot drift from what the component actually reads. */
6
- export interface NumberInputControllerProps {
7
- label: string;
8
- value?: number;
9
- onChange: (newValue: number) => void;
10
- config?: InputControllerConfig;
11
- helpText?: string;
12
- description?: string;
13
- onFocus?: () => void;
14
- }
8
+ export interface NumberInputControllerProps {
9
+ label: string;
10
+ value?: number;
11
+ onChange: (newValue: number) => void;
12
+ config?: InputControllerConfig;
13
+ helpText?: string;
14
+ description?: string;
15
+ onFocus?: () => void;
16
+ }
15
17
  </script>
16
18
 
17
19
  <script lang="ts">
20
+ /**
21
+ * NumberInputController Component
22
+ * A specialized input controller for numeric values with increment/decrement buttons.
23
+ * Features:
24
+ * - Increment/decrement buttons with auto-repeat
25
+ * - Value validation and bounds checking
26
+ * - Support for negative numbers
27
+ * - Keyboard navigation and shortcuts
28
+ */
29
+
30
+ // Svelte imports
18
31
  /**
19
32
  * NumberInputController Component
20
33
  * A specialized input controller for numeric values with increment/decrement buttons.
@@ -24,128 +37,168 @@
24
37
  * - Support for negative numbers
25
38
  * - Keyboard navigation and shortcuts
26
39
  */
27
-
28
40
  // Svelte imports
29
- import { onDestroy } from 'svelte';
41
+ import { onDestroy } from 'svelte';
30
42
 
31
-
32
- import InputControllerHeader from './InputControllerHeader.svelte';
33
- import NumberControls from './NumberControls.svelte';
43
+ import InputControllerRow from './InputControllerRow.svelte';
44
+ import NumberControls from './NumberControls.svelte';
34
45
 
46
+ /**
47
+ * Component Props
48
+ * External properties that configure the number input's behavior
49
+ */
35
50
  /**
36
51
  * Component Props
37
52
  * External properties that configure the number input's behavior
38
53
  */
39
- export let label: NumberInputControllerProps['label'];
40
- export let value: NumberInputControllerProps['value'] = 0;
41
- export let onChange: NumberInputControllerProps['onChange'];
42
- export let config: NumberInputControllerProps['config'] = {};
43
- export let helpText: NumberInputControllerProps['helpText'] = undefined;
44
- export let description: NumberInputControllerProps['description'] = undefined;
45
- export let onFocus: NumberInputControllerProps['onFocus'] = () => {};
54
+ export let label: NumberInputControllerProps['label'];
55
+ export let value: NumberInputControllerProps['value'] = 0;
56
+ export let onChange: NumberInputControllerProps['onChange'];
57
+ export let config: NumberInputControllerProps['config'] = {};
58
+ export let helpText: NumberInputControllerProps['helpText'] = undefined;
59
+ export let description: NumberInputControllerProps['description'] = undefined;
60
+ export let onFocus: NumberInputControllerProps['onFocus'] = () => {};
46
61
 
62
+ /**
63
+ * Configuration Options
64
+ * Derived from config prop with fallbacks.
65
+ * When both min and max are unspecified, the input is unbounded (not locked).
66
+ */
47
67
  /**
48
68
  * Configuration Options
49
69
  * Derived from config prop with fallbacks.
50
70
  * When both min and max are unspecified, the input is unbounded (not locked).
51
71
  */
52
- const bothBoundsUndefined = config.min === undefined && config.max === undefined;
53
- $: min = config.min ?? 0;
54
- $: max = bothBoundsUndefined ? Number.MAX_SAFE_INTEGER : (config.max ?? 0);
55
- $: step = config.step || 1;
56
- $: isLocked = !bothBoundsUndefined && min === max;
57
- $: isAtMin = value <= min;
58
- $: isAtMax = value >= max;
72
+ const bothBoundsUndefined = config.min === undefined && config.max === undefined;
73
+ $: min = config.min ?? 0;
74
+ $: max = bothBoundsUndefined ? Number.MAX_SAFE_INTEGER : (config.max ?? 0);
75
+ $: step = config.step || 1;
76
+ $: isLocked = !bothBoundsUndefined && min === max;
77
+ $: isAtMin = value <= min;
78
+ $: isAtMax = value >= max;
59
79
 
80
+ /**
81
+ * Reactive Statements
82
+ * Handle min/max validation and value constraints
83
+ */
84
+ /**
85
+ * Step Validation
86
+ * Ensures step value is always positive
87
+ */
60
88
  /**
61
89
  * Reactive Statements
62
90
  * Handle min/max validation and value constraints
63
91
  */
64
- $: {
65
- if (min !== undefined && max !== undefined && min > max) {
66
- [min, max] = [max, min];
67
- }
92
+ $: {
93
+ if (min !== undefined && max !== undefined && min > max) {
94
+ [min, max] = [max, min];
95
+ }
68
96
 
69
- const minValue = min ?? 0;
70
- const maxValue = max ?? Number.MAX_SAFE_INTEGER;
97
+ const minValue = min ?? 0;
98
+ const maxValue = max ?? Number.MAX_SAFE_INTEGER;
71
99
 
72
- if (!isEditing && !bothBoundsUndefined) {
73
- if (value < minValue || value > maxValue) {
100
+ if (!isEditing && !bothBoundsUndefined) {
101
+ if (value < minValue || value > maxValue) {
102
+ // console.log('Value out of bounds, adjusting:', {
103
+ // value, minValue, maxValue, isEditing
104
+ // });
74
105
  // console.log('Value out of bounds, adjusting:', {
75
106
  // value, minValue, maxValue, isEditing
76
107
  // });
77
- const clampedValue = Math.max(minValue, Math.min(maxValue, value));
78
- value = clampedValue;
79
- if (typeof onChange === 'function') {
80
- setTimeout(() => onChange(clampedValue), 0);
81
- }
82
- }
83
- }
84
- }
108
+ const clampedValue = Math.max(minValue, Math.min(maxValue, value));
109
+ value = clampedValue;
110
+ if (typeof onChange === 'function') {
111
+ setTimeout(() => onChange(clampedValue), 0);
112
+ }
113
+ }
114
+ }
115
+ }
85
116
 
86
- /**
87
- * Step Validation
88
- * Ensures step value is always positive
89
- */
90
- $: {
91
- if (step < 0) {
92
- console.warn('Step value should be positive. Converting negative step to positive.');
93
- step = Math.abs(step);
94
- }
95
- }
117
+ /**
118
+ * Step Validation
119
+ * Ensures step value is always positive
120
+ */
121
+ $: {
122
+ if (step < 0) {
123
+ console.warn('Step value should be positive. Converting negative step to positive.');
124
+ step = Math.abs(step);
125
+ }
126
+ }
96
127
 
128
+ /**
129
+ * Internal State
130
+ * Manages component behavior and auto-repeat functionality
131
+ */
97
132
  /**
98
133
  * Internal State
99
134
  * Manages component behavior and auto-repeat functionality
100
135
  */
101
- let autoRepeatTimer: ReturnType<typeof setTimeout> | undefined;
102
- let autoRepeatInterval: ReturnType<typeof setInterval> | undefined;
103
- let isPressed = false;
104
- let isEditing = false; // Tracks if user is currently editing the input
105
- let disabledOpacity = 60;
106
- const HOLD_DELAY = 400;
107
- const REPEAT_INTERVAL = 80;
136
+ let autoRepeatTimer: ReturnType<typeof setTimeout> | undefined;
137
+ let autoRepeatInterval: ReturnType<typeof setInterval> | undefined;
138
+ let isPressed = false;
139
+ // console.log('handleBlur:', { value, isEditing, min, max });
140
+ let isEditing = false; // Tracks if user is currently editing the input
141
+ let disabledOpacity = 60;
142
+ const HOLD_DELAY = 400;
143
+ const REPEAT_INTERVAL = 80;
108
144
 
145
+ /**
146
+ * Value Change Handler
147
+ * Processes increment/decrement operations with bounds checking
148
+ */
109
149
  /**
110
150
  * Value Change Handler
111
151
  * Processes increment/decrement operations with bounds checking
112
152
  */
113
- function handleValueChange(adjustment: number) {
114
- try {
115
- // console.log('🔄 handleValueChange:', { currentValue: value, adjustment, min, max });
116
- const newValue = value + adjustment;
117
-
118
- if (min !== undefined && newValue < min) {
119
- // console.log('⚠️ Value would go below min, clamping to:', min);
120
- value = min;
121
- if (onChange) onChange(min);
122
- return;
123
- }
124
-
125
- if (max !== undefined && newValue > max) {
126
- // console.log('⚠️ Value would exceed max, clamping to:', max);
127
- value = max;
128
- if (onChange) onChange(max);
129
- return;
130
- }
131
-
132
- // console.log('✅ Setting new value:', newValue);
133
- value = newValue;
134
- if (onChange) onChange(newValue);
135
- } catch (error) {
136
- console.error('❌ Error in handleValueChange:', error);
137
- }
138
- }
153
+ function handleValueChange(adjustment: number) {
154
+ try {
155
+ // console.log('🔄 handleValueChange:', { currentValue: value, adjustment, min, max });
156
+ const newValue = value + adjustment;
157
+
158
+ if (min !== undefined && newValue < min) {
159
+ // console.log('⚠️ Value would go below min, clamping to:', min);
160
+ value = min;
161
+ if (onChange) onChange(min);
162
+ return;
163
+ }
139
164
 
165
+ if (max !== undefined && newValue > max) {
166
+ // console.log('⚠️ Value would exceed max, clamping to:', max);
167
+ value = max;
168
+ if (onChange) onChange(max);
169
+ return;
170
+ }
171
+
172
+ // console.log('✅ Setting new value:', newValue);
173
+ value = newValue;
174
+ if (onChange) onChange(newValue);
175
+ } catch (error) {
176
+ console.error('❌ Error in handleValueChange:', error);
177
+ }
178
+ }
179
+
180
+ /**
181
+ * Input Event Handler
182
+ * Manages direct user input with validation
183
+ */
140
184
  /**
141
185
  * Input Event Handler
142
186
  * Manages direct user input with validation
143
187
  */
144
- function handleInput(e: Event) {
145
- try {
146
- const input = e.currentTarget as HTMLInputElement;
147
- const inputValue = input.value;
148
-
188
+ function handleInput(e: Event) {
189
+ try {
190
+ const input = e.currentTarget as HTMLInputElement;
191
+ const inputValue = input.value;
192
+
193
+ // console.log('handleInput start:', {
194
+ // inputValue,
195
+ // isEditing,
196
+ // currentValue: value,
197
+ // min,
198
+ // max
199
+ // });
200
+
201
+ // Handle empty input
149
202
  // console.log('handleInput start:', {
150
203
  // inputValue,
151
204
  // isEditing,
@@ -153,261 +206,268 @@
153
206
  // min,
154
207
  // max
155
208
  // });
156
-
157
209
  // Handle empty input
158
- if (inputValue === '') {
159
- // console.log('Empty input detected - allowing editing');
160
- isEditing = true;
161
- return;
162
- }
163
-
164
- // Prevent multiple minus signs
165
- if (inputValue.split('-').length > 2) {
166
- // console.log('Multiple minus signs detected, preventing');
167
- input.value = inputValue.charAt(0) === '-' ?
168
- '-' + inputValue.replace(/-/g, '') :
169
- inputValue.replace(/-/g, '');
170
- return;
171
- }
172
-
173
- // Allow single minus sign for negative numbers
174
- if (inputValue === '-' && min! < 0) {
210
+ if (inputValue === '') {
211
+ // console.log('Empty input detected - allowing editing');
212
+ // console.log('CMD+A detected, setting editing mode');
175
213
  // console.log('Single minus sign detected');
176
- isEditing = true;
177
- return;
178
- }
179
-
180
- // Validate numeric input
181
- if (!/^-?\d*$/.test(inputValue)) {
182
- // console.log('Invalid character detected');
183
- input.value = inputValue.replace(/[^\d-]/g, '');
184
- return;
185
- }
186
-
187
- const numValue = parseFloat(inputValue);
188
- if (!isNaN(numValue)) {
189
- if (max !== undefined && numValue > max) {
190
- // console.log('Number exceeds max:', { numValue, max });
191
- input.value = String(max);
192
- value = max;
193
- return;
194
- }
195
- value = numValue;
196
- }
197
- } catch (error) {
198
- console.error('Error in handleInput:', error);
199
- }
200
- }
214
+ // console.log('Empty input detected - allowing editing');
215
+ isEditing = true;
216
+ return;
217
+ }
218
+
219
+ // Prevent multiple minus signs
220
+ if (inputValue.split('-').length > 2) {
221
+ // console.log('Multiple minus signs detected, preventing');
222
+ input.value =
223
+ inputValue.charAt(0) === '-'
224
+ ? '-' + inputValue.replace(/-/g, '')
225
+ : inputValue.replace(/-/g, '');
226
+ return;
227
+ }
228
+
229
+ // Allow single minus sign for negative numbers
230
+ if (inputValue === '-' && min! < 0) {
231
+ // console.log('Single minus sign detected');
232
+ isEditing = true;
233
+ return;
234
+ }
235
+
236
+ // Validate numeric input
237
+ if (!/^-?\d*$/.test(inputValue)) {
238
+ // console.log('Invalid character detected');
239
+ input.value = inputValue.replace(/[^\d-]/g, '');
240
+ return;
241
+ }
242
+
243
+ const numValue = parseFloat(inputValue);
244
+ if (!isNaN(numValue)) {
245
+ if (max !== undefined && numValue > max) {
246
+ // console.log('Number exceeds max:', { numValue, max });
247
+ input.value = String(max);
248
+ value = max;
249
+ return;
250
+ }
251
+ value = numValue;
252
+ }
253
+ } catch (error) {
254
+ console.error('Error in handleInput:', error);
255
+ }
256
+ }
201
257
 
258
+ /**
259
+ * Blur Event Handler
260
+ * Validates and normalizes input when focus is lost
261
+ */
202
262
  /**
203
263
  * Blur Event Handler
204
264
  * Validates and normalizes input when focus is lost
205
265
  */
206
- function handleBlur(event: FocusEvent) {
207
- // console.log('handleBlur:', { value, isEditing, min, max });
208
-
209
- isEditing = false;
266
+ function handleBlur(event: FocusEvent) {
267
+ // console.log('handleBlur:', { value, isEditing, min, max });
268
+
269
+ isEditing = false;
270
+ // The input that lost the focus. (It used to be looked up by the id "number-input" in the whole document, which is
271
+ // another input when there are several, and nothing inside a module's shadow root.)
210
272
  // The input that lost the focus. (It used to be looked up by the id "number-input" in the whole document, which is
211
273
  // another input when there are several, and nothing inside a module's shadow root.)
212
- const input = event.currentTarget as HTMLInputElement;
213
-
214
- // Handle empty or invalid input
215
- if (input.value === '' || input.value === '-') {
216
- value = min!;
217
- input.value = String(min!);
218
- if (onChange) onChange(min!);
219
- return;
220
- }
221
-
222
- // Validate and clamp final value
223
- const finalValue = parseFloat(input.value);
224
- if (isNaN(finalValue)) {
225
- value = min!;
226
- input.value = String(min!);
227
- if (onChange) onChange(min!);
228
- } else if (finalValue < min!) {
229
- value = min!;
230
- input.value = String(min!);
231
- if (onChange) onChange(min!);
232
- } else if (finalValue > max!) {
233
- value = max!;
234
- input.value = String(max!);
235
- if (onChange) onChange(max!);
236
- } else {
237
- value = finalValue;
238
- if (onChange) onChange(finalValue);
239
- }
240
- }
274
+ const input = event.currentTarget as HTMLInputElement;
275
+
276
+ // Handle empty or invalid input
277
+ if (input.value === '' || input.value === '-') {
278
+ value = min!;
279
+ input.value = String(min!);
280
+ if (onChange) onChange(min!);
281
+ return;
282
+ }
241
283
 
284
+ // Validate and clamp final value
285
+ const finalValue = parseFloat(input.value);
286
+ if (isNaN(finalValue)) {
287
+ value = min!;
288
+ input.value = String(min!);
289
+ if (onChange) onChange(min!);
290
+ } else if (finalValue < min!) {
291
+ value = min!;
292
+ input.value = String(min!);
293
+ if (onChange) onChange(min!);
294
+ } else if (finalValue > max!) {
295
+ value = max!;
296
+ input.value = String(max!);
297
+ if (onChange) onChange(max!);
298
+ } else {
299
+ value = finalValue;
300
+ if (onChange) onChange(finalValue);
301
+ }
302
+ }
303
+
304
+ /**
305
+ * Auto-Repeat Functionality
306
+ * Handles continuous increment/decrement while button is held
307
+ */
242
308
  /**
243
309
  * Auto-Repeat Functionality
244
310
  * Handles continuous increment/decrement while button is held
245
311
  */
246
- function startAutoRepeat(operation: 'increment' | 'decrement', event: MouseEvent) {
247
- // console.log('🎯 startAutoRepeat called:', { operation });
248
- event.preventDefault();
249
- event.stopPropagation();
250
-
312
+ function startAutoRepeat(operation: 'increment' | 'decrement', event: MouseEvent) {
313
+ // console.log('🎯 startAutoRepeat called:', { operation });
314
+ event.preventDefault();
315
+ event.stopPropagation();
316
+
317
+ // Clear any existing timers first
318
+ // console.log('♻️ Component destroying, cleaning up timers');
251
319
  // Clear any existing timers first
252
- stopAutoRepeat();
253
-
254
- const adjustment = operation === 'increment' ? step : -step;
255
- isPressed = true;
256
-
320
+ stopAutoRepeat();
321
+
322
+ const adjustment = operation === 'increment' ? step : -step;
323
+ isPressed = true;
324
+
325
+ // Handle initial click
326
+ // console.log('👆 Initial click, applying adjustment:', adjustment);
327
+ // console.log('⚡ Interval tick - applying adjustment:', adjustment);
257
328
  // Handle initial click
258
329
  // console.log('👆 Initial click, applying adjustment:', adjustment);
259
- handleValueChange(adjustment);
260
-
330
+ handleValueChange(adjustment);
331
+
332
+ // Set up auto-repeat
333
+ // console.log('⏳ Setting up auto-repeat timer for', HOLD_DELAY, 'ms');
334
+
335
+ // Start auto-repeat after hold delay
261
336
  // Set up auto-repeat
262
337
  // console.log('⏳ Setting up auto-repeat timer for', HOLD_DELAY, 'ms');
263
-
264
338
  // Start auto-repeat after hold delay
265
- autoRepeatTimer = setTimeout(() => {
266
- // console.log('⌛ Hold delay completed, isPressed:', isPressed);
267
- if (isPressed) {
268
- // console.log('🔄 Starting interval timer with delay:', REPEAT_INTERVAL);
269
- autoRepeatInterval = setInterval(() => {
270
- if (isPressed) {
271
- // console.log('⚡ Interval tick - applying adjustment:', adjustment);
272
- handleValueChange(adjustment);
273
- }
274
- }, REPEAT_INTERVAL);
275
- }
276
- }, HOLD_DELAY);
277
- }
339
+ autoRepeatTimer = setTimeout(() => {
340
+ // console.log('⌛ Hold delay completed, isPressed:', isPressed);
341
+ if (isPressed) {
342
+ // console.log('🔄 Starting interval timer with delay:', REPEAT_INTERVAL);
343
+ autoRepeatInterval = setInterval(() => {
344
+ if (isPressed) {
345
+ // console.log('⚡ Interval tick - applying adjustment:', adjustment);
346
+ handleValueChange(adjustment);
347
+ }
348
+ }, REPEAT_INTERVAL);
349
+ }
350
+ }, HOLD_DELAY);
351
+ }
278
352
 
353
+ /**
354
+ * Stop Auto-Repeat
355
+ * Cleans up auto-repeat timer and interval
356
+ */
279
357
  /**
280
358
  * Stop Auto-Repeat
281
359
  * Cleans up auto-repeat timer and interval
282
360
  */
283
- function stopAutoRepeat(event?: MouseEvent | FocusEvent) {
284
- if (event) {
285
- event.preventDefault();
286
- event.stopPropagation();
287
- }
288
-
361
+ function stopAutoRepeat(event?: MouseEvent | FocusEvent) {
362
+ if (event) {
363
+ event.preventDefault();
364
+ event.stopPropagation();
365
+ }
366
+
367
+ // console.log('🛑 stopAutoRepeat called');
368
+
289
369
  // console.log('🛑 stopAutoRepeat called');
290
-
291
- if (autoRepeatTimer) {
292
- // console.log('🧹 Clearing auto-repeat timer');
293
- clearTimeout(autoRepeatTimer);
294
- autoRepeatTimer = undefined;
295
- }
296
- if (autoRepeatInterval) {
297
- // console.log('🧹 Clearing auto-repeat interval');
298
- clearInterval(autoRepeatInterval);
299
- autoRepeatInterval = undefined;
300
- }
301
-
302
- isPressed = false;
303
- }
370
+ if (autoRepeatTimer) {
371
+ // console.log('🧹 Clearing auto-repeat timer');
372
+ clearTimeout(autoRepeatTimer);
373
+ autoRepeatTimer = undefined;
374
+ }
375
+ if (autoRepeatInterval) {
376
+ // console.log('🧹 Clearing auto-repeat interval');
377
+ clearInterval(autoRepeatInterval);
378
+ autoRepeatInterval = undefined;
379
+ }
380
+
381
+ isPressed = false;
382
+ }
304
383
 
384
+ /**
385
+ * Cleanup
386
+ * Ensures auto-repeat timer is cleared when component is destroyed
387
+ */
305
388
  /**
306
389
  * Cleanup
307
390
  * Ensures auto-repeat timer is cleared when component is destroyed
308
391
  */
309
- onDestroy(() => {
310
- // console.log('♻️ Component destroying, cleaning up timers');
311
- stopAutoRepeat();
312
- });
392
+ onDestroy(() => {
393
+ // console.log('♻️ Component destroying, cleaning up timers');
394
+ stopAutoRepeat();
395
+ });
313
396
 
397
+ /**
398
+ * Input Validation
399
+ * Validates numeric input format
400
+ */
314
401
  /**
315
402
  * Input Validation
316
403
  * Validates numeric input format
317
404
  */
318
- function isValidNumber(value: string): boolean {
319
- // Allow empty string during typing
320
- if (value === '') return true;
321
- // Allow single minus sign during typing if negatives are allowed
322
- if (value === '-' && (min === undefined || min < 0)) return true;
323
-
324
- // Strict number format validation
325
- const numberRegex = /^-?\d*\.?\d*$/;
326
- if (!numberRegex.test(value)) return false;
327
- // Prevent multiple decimal points
328
- if ((value.match(/\./g) || []).length > 1) return false;
329
- // Prevent multiple minus signs
330
- if ((value.match(/-/g) || []).length > 1) return false;
331
-
332
- return true;
333
- }
405
+ function isValidNumber(value: string): boolean {
406
+ // Allow empty string during typing
407
+ if (value === '') return true;
408
+ // Allow single minus sign during typing if negatives are allowed
409
+ if (value === '-' && (min === undefined || min < 0)) return true;
410
+
411
+ // Strict number format validation
412
+ const numberRegex = /^-?\d*\.?\d*$/;
413
+ if (!numberRegex.test(value)) return false;
414
+ // Prevent multiple decimal points
415
+ if ((value.match(/\./g) || []).length > 1) return false;
416
+ // Prevent multiple minus signs
417
+ if ((value.match(/-/g) || []).length > 1) return false;
418
+
419
+ return true;
420
+ }
334
421
 
422
+ /**
423
+ * Keyboard Event Handler
424
+ * Manages keyboard interactions and shortcuts
425
+ */
335
426
  /**
336
427
  * Keyboard Event Handler
337
428
  * Manages keyboard interactions and shortcuts
338
429
  */
339
- function handleKeyDown(e: KeyboardEvent) {
430
+ function handleKeyDown(e: KeyboardEvent) {
431
+ // console.log('handleKeyDown:', {
432
+ // key: e.key,
433
+ // metaKey: e.metaKey,
434
+ // ctrlKey: e.ctrlKey,
435
+ // isEditing
436
+ // });
437
+
438
+ // Handle selection shortcuts
340
439
  // console.log('handleKeyDown:', {
341
440
  // key: e.key,
342
441
  // metaKey: e.metaKey,
343
442
  // ctrlKey: e.ctrlKey,
344
443
  // isEditing
345
444
  // });
346
-
347
445
  // Handle selection shortcuts
348
- if ((e.metaKey || e.ctrlKey) && e.key === 'a') {
349
- // console.log('CMD+A detected, setting editing mode');
350
- isEditing = true;
351
- return;
352
- }
353
-
354
- // Allow navigation keys
355
- if (e.key === 'Backspace' || e.key === 'Delete' ||
356
- e.key === 'ArrowLeft' || e.key === 'ArrowRight' ||
357
- e.key === 'Tab') {
358
- isEditing = true;
359
- return;
360
- }
361
-
362
- // Allow copy/paste operations
363
- if (e.metaKey || e.ctrlKey) {
364
- return;
365
- }
366
- }
446
+ if ((e.metaKey || e.ctrlKey) && e.key === 'a') {
447
+ // console.log('CMD+A detected, setting editing mode');
448
+ isEditing = true;
449
+ return;
450
+ }
451
+
452
+ // Allow navigation keys
453
+ if (
454
+ e.key === 'Backspace' ||
455
+ e.key === 'Delete' ||
456
+ e.key === 'ArrowLeft' ||
457
+ e.key === 'ArrowRight' ||
458
+ e.key === 'Tab'
459
+ ) {
460
+ isEditing = true;
461
+ return;
462
+ }
463
+
464
+ // Allow copy/paste operations
465
+ if (e.metaKey || e.ctrlKey) {
466
+ return;
467
+ }
468
+ }
367
469
  </script>
368
470
 
369
- <!-- Number Input Container -->
370
- <div class="flex flex-col gap-2 widgetic-colors">
371
- <div class="flex items-center w-full relative">
372
- <div class="flex-1 min-w-0">
373
- <InputControllerHeader {label} helpText={helpText} />
374
- </div>
375
-
376
- <div class="absolute end-0">
377
- <NumberControls
378
- {value}
379
- {onChange}
380
- {min}
381
- {max}
382
- {step}
383
- {isLocked}
384
- {onFocus}
385
- />
386
- </div>
387
- </div>
388
-
389
- {#if description}
390
- <p class="subtext text-grey5">{description}</p>
391
- {/if}
392
- </div>
393
-
394
- <style>
395
- :global(#number-input) {
396
- text-align: start;
397
- appearance: textfield;
398
- -moz-appearance: textfield;
399
- }
400
-
401
- :global(#number-input::-webkit-outer-spin-button),
402
- :global(#number-input::-webkit-inner-spin-button) {
403
- -webkit-appearance: none;
404
- appearance: none;
405
- margin: 0;
406
- }
407
-
408
- /* Remove focus ring from buttons */
409
- :global(.number-input-button:focus-visible) {
410
- outline: none !important;
411
- box-shadow: none !important;
412
- }
413
- </style>
471
+ <InputControllerRow {label} {helpText} {description}>
472
+ <NumberControls {value} {onChange} {min} {max} {step} {isLocked} {onFocus} />
473
+ </InputControllerRow>