@widgetic/editor 4.1.14 → 4.1.15
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/components/PreviewChromeControls.svelte +15 -21
- package/dist/components/WidgetPreview.svelte +136 -105
- package/dist/components/color-select/ColorSelect.svelte +203 -224
- package/dist/components/color-select/constants.d.ts +4 -2
- package/dist/components/color-select/constants.js +4 -2
- package/dist/components/color-select/render.js +10 -9
- package/dist/components/editors/CompositionEditorApp.svelte +47 -40
- package/dist/components/editors/EditLeaseNotice.svelte +44 -33
- package/dist/components/editors/EmbedEditor.svelte +133 -259
- package/dist/components/editors/PropsEditor.svelte +418 -1338
- package/dist/components/editors/props-editor.css +5 -68
- package/dist/components/ic/AngleInputController.svelte +202 -277
- package/dist/components/ic/BrowserInputController.svelte +813 -803
- package/dist/components/ic/CheckboxInputController.svelte +92 -169
- package/dist/components/ic/CheckboxInputController.svelte.d.ts +2 -8
- package/dist/components/ic/ColorPickerInputController.svelte +1589 -1587
- package/dist/components/ic/ColorPickerInputController.svelte.d.ts +3 -3
- package/dist/components/ic/DateFieldInputController.svelte +455 -465
- package/dist/components/ic/DatePickerInputController.svelte +355 -368
- package/dist/components/ic/DatePickerInputController.svelte.d.ts +1 -1
- package/dist/components/ic/DropdownInputController.svelte +130 -200
- package/dist/components/ic/FixedPositionInputController.svelte +255 -276
- package/dist/components/ic/FixedPositionInputController.svelte.d.ts +5 -1
- package/dist/components/ic/FontInputController.svelte +2110 -2231
- package/dist/components/ic/FontInputController.svelte.d.ts +11 -11
- package/dist/components/ic/InputControllerHeader.svelte +141 -147
- package/dist/components/ic/InputControllerRow.svelte +74 -0
- package/dist/components/ic/InputControllerRow.svelte.d.ts +14 -0
- package/dist/components/ic/KnowledgeDocumentsInputController.svelte +84 -47
- package/dist/components/ic/KnowledgeTextForm.svelte +35 -33
- package/dist/components/ic/NumberControls.svelte +303 -269
- package/dist/components/ic/NumberControls.svelte.d.ts +4 -1
- package/dist/components/ic/NumberInputController.svelte +361 -301
- package/dist/components/ic/NumberInputController.svelte.d.ts +2 -0
- package/dist/components/ic/PositionInputController.svelte +253 -176
- package/dist/components/ic/PositionInputController.svelte.d.ts +2 -0
- package/dist/components/ic/RadioGroupInputController.svelte +71 -137
- package/dist/components/ic/RadioGroupInputController.svelte.d.ts +2 -8
- package/dist/components/ic/RangeCalendarInputController.svelte +233 -270
- package/dist/components/ic/RangeCalendarInputController.svelte.d.ts +2 -2
- package/dist/components/ic/RoundedCornersInputController.svelte +412 -435
- package/dist/components/ic/RoundedCornersInputController.svelte.d.ts +2 -0
- package/dist/components/ic/SliderInputController.svelte +263 -332
- package/dist/components/ic/SliderInputController.svelte.d.ts +1 -1
- package/dist/components/ic/SliderRangeInputController.svelte +140 -144
- package/dist/components/ic/SliderRangeInputController.svelte.d.ts +3 -3
- package/dist/components/ic/SwitchInputController.svelte +47 -109
- package/dist/components/ic/TagsInputController.svelte +95 -110
- package/dist/components/ic/TextAreaInputController.svelte +1794 -1935
- package/dist/components/ic/TextAreaPreviewInputController.svelte +436 -438
- package/dist/components/ic/TextAreaPreviewInputController.svelte.d.ts +2 -2
- package/dist/components/ic/TextInputController.svelte +65 -75
- package/dist/components/ic/TextInputController.svelte.d.ts +2 -0
- package/dist/components/ic/TimeInputController.svelte +433 -431
- package/dist/components/ic/VectorInputController.svelte +1833 -1831
- package/dist/components/ic/VectorInputController.svelte.d.ts +10 -10
- package/dist/components/ic/index.d.ts +1 -0
- package/dist/components/ic/index.js +1 -0
- package/dist/components/ic/shared/CategoryTabs.svelte +28 -35
- package/dist/components/ic/shared/ItemGrid.svelte +145 -179
- package/dist/components/ic/shared/RecentItemsSection.svelte +208 -271
- package/dist/components/ic/shared/RecentItemsSection.svelte.d.ts +1 -1
- package/dist/components/ui/arrows/OpacitySliderArrows.svelte +23 -38
- package/dist/components/ui/arrows/OpacitySliderArrows.svelte.d.ts +1 -4
- package/dist/components/ui/calendar-editor-fit/EditorCalendarStyles.svelte +45 -0
- package/dist/components/ui/calendar-editor-fit/EditorCalendarStyles.svelte.d.ts +26 -0
- package/dist/components/ui/checkerboard-background/CheckerboardBackground.svelte +20 -12
- package/dist/components/ui/shadow-picker-host/ShadowPickerHost.svelte +39 -0
- package/dist/components/ui/shadow-picker-host/ShadowPickerHost.svelte.d.ts +10 -0
- package/dist/i18n/language.d.ts +43 -36
- package/dist/i18n/messages.d.ts +41 -34
- package/dist/i18n/messages.js +47 -34
- package/dist/i18n/translate.d.ts +1 -1
- package/dist/utils.d.ts +7 -0
- package/dist/utils.js +26 -2
- package/package.json +4 -4
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
<script module lang="ts">
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import type { InputControllerConfig } from './index';
|
|
3
|
+
import type { SliderProps } from '@widgetic/design-system/components';
|
|
4
4
|
|
|
5
5
|
/** Declared props contract — export lets below are annotated from it so the
|
|
6
6
|
* interface cannot drift from what the component actually reads. */
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
7
|
+
export interface SliderInputControllerProps {
|
|
8
|
+
height?: number;
|
|
9
|
+
elementsGap?: number;
|
|
10
|
+
thumbSize?: number;
|
|
11
|
+
sliderType?: SliderProps['type'];
|
|
12
|
+
barHeight?: number;
|
|
13
|
+
label?: string;
|
|
14
|
+
value: number | number[];
|
|
15
|
+
onChange: (newValue: number | number[]) => void;
|
|
16
|
+
config?: InputControllerConfig;
|
|
17
|
+
helpText?: string;
|
|
18
|
+
min?: number;
|
|
19
|
+
max?: number;
|
|
20
|
+
step?: number;
|
|
21
|
+
onFocus?: () => void;
|
|
22
|
+
autofocus?: boolean;
|
|
23
|
+
}
|
|
24
24
|
</script>
|
|
25
25
|
|
|
26
26
|
<script lang="ts">
|
|
@@ -34,208 +34,183 @@
|
|
|
34
34
|
* - Value clamping and validation
|
|
35
35
|
* - Smart click positioning: center thumb at clicked position on track
|
|
36
36
|
*/
|
|
37
|
-
|
|
38
37
|
// Svelte imports
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
import { onMount, onDestroy } from 'svelte';
|
|
41
39
|
/**
|
|
42
40
|
* Shadcn UI components from Widgetic design-system package
|
|
43
41
|
*/
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
import { Slider } from '@widgetic/design-system/components';
|
|
43
|
+
import { useTextDirection } from '@widgetic/design-system/components/textDirection';
|
|
44
|
+
import InputControllerRow from './InputControllerRow.svelte';
|
|
47
45
|
|
|
48
46
|
// The way the screen is read: the slider of the design system starts at the right end on a right to left screen.
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
const textDirection = useTextDirection();
|
|
51
48
|
|
|
52
49
|
/**
|
|
53
50
|
* Component Props
|
|
54
51
|
* External properties that configure the slider's behavior
|
|
55
52
|
*/
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
53
|
+
let className = '';
|
|
54
|
+
export { className as class };
|
|
55
|
+
export let height: SliderInputControllerProps['height'] = 36;
|
|
56
|
+
export let elementsGap: SliderInputControllerProps['elementsGap'] | undefined = undefined;
|
|
57
|
+
export let thumbSize: SliderInputControllerProps['thumbSize'] = 24;
|
|
58
|
+
export let sliderType: SliderInputControllerProps['sliderType'] = 'single';
|
|
59
|
+
export let barHeight: SliderInputControllerProps['barHeight'] = 8;
|
|
60
|
+
export let label: SliderInputControllerProps['label'] = '';
|
|
61
|
+
export let value: SliderInputControllerProps['value'];
|
|
62
|
+
export let onChange: SliderInputControllerProps['onChange'];
|
|
63
|
+
export let config: SliderInputControllerProps['config'] = {};
|
|
64
|
+
export let helpText: SliderInputControllerProps['helpText'] = undefined;
|
|
65
|
+
|
|
69
66
|
/**
|
|
70
67
|
* Configuration Options
|
|
71
68
|
* Derived from config prop with fallbacks
|
|
72
69
|
*/
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
70
|
+
export let min: SliderInputControllerProps['min'] = config.min || 0;
|
|
71
|
+
export let max: SliderInputControllerProps['max'] = config.max || 100;
|
|
72
|
+
export let step: SliderInputControllerProps['step'] = config.step || 1;
|
|
73
|
+
export let onFocus: SliderInputControllerProps['onFocus'] = () => {};
|
|
74
|
+
export let autofocus: SliderInputControllerProps['autofocus'] = false;
|
|
78
75
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
let sliderContainer: HTMLDivElement; // Reference to container element
|
|
84
|
-
let sliderTrack: HTMLDivElement; // Reference to slider track element
|
|
85
|
-
let lastValue = value; // Previous value for change detection
|
|
86
|
-
let isCurrentlyFocused = false; // Current focus state
|
|
87
|
-
let isClickHandled = false; // Prevents double handling of clicks
|
|
76
|
+
let sliderContainer: HTMLDivElement;
|
|
77
|
+
let lastValue = value;
|
|
78
|
+
let isCurrentlyFocused = false;
|
|
79
|
+
let isClickHandled = false;
|
|
88
80
|
|
|
89
|
-
|
|
90
|
-
* Layout Constants
|
|
91
|
-
* Define dimensions for slider components
|
|
92
|
-
*/
|
|
93
|
-
const valueDisplayWidth = 26; // pixels
|
|
81
|
+
const valueDisplayWidth = 28;
|
|
94
82
|
|
|
95
|
-
|
|
96
83
|
/**
|
|
97
84
|
* Component Initialization
|
|
98
85
|
* Sets up focus handling and event listeners
|
|
99
86
|
*/
|
|
100
|
-
|
|
87
|
+
onMount(() => {
|
|
101
88
|
// console.log('SliderIC sliderType:', sliderType, sliderValue);
|
|
102
89
|
// Handle autofocus if enabled
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
90
|
+
if (autofocus && sliderContainer) {
|
|
91
|
+
const thumbElement = sliderContainer.querySelector('[role="slider"]');
|
|
92
|
+
if (thumbElement instanceof HTMLElement) {
|
|
93
|
+
thumbElement.focus();
|
|
94
|
+
// Focus the slider
|
|
95
|
+
handleFocus();
|
|
96
|
+
}
|
|
97
|
+
}
|
|
110
98
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
99
|
+
const sliderElement = sliderContainer?.querySelector('.slider-component');
|
|
100
|
+
// Clean up slider mousedown listener
|
|
101
|
+
if (sliderElement) {
|
|
102
|
+
sliderElement.addEventListener('mousedown', handleSliderMouseDown);
|
|
103
|
+
}
|
|
116
104
|
|
|
117
105
|
/**
|
|
118
106
|
* Blur Event Handler
|
|
119
107
|
* Resets focus state when focus leaves the component
|
|
120
108
|
*/
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
109
|
+
const handleBlur = (e: FocusEvent) => {
|
|
110
|
+
if (!sliderContainer.contains(e.relatedTarget as Node)) {
|
|
111
|
+
isCurrentlyFocused = false;
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
sliderContainer.addEventListener('blur', handleBlur, true);
|
|
116
|
+
|
|
129
117
|
// Add global mouse up handler to reset click state
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
};
|
|
145
|
-
});
|
|
118
|
+
const handleGlobalMouseUp = () => {
|
|
119
|
+
isClickHandled = false;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
document.addEventListener('mouseup', handleGlobalMouseUp);
|
|
123
|
+
|
|
124
|
+
return () => {
|
|
125
|
+
sliderContainer.removeEventListener('blur', handleBlur, true);
|
|
126
|
+
document.removeEventListener('mouseup', handleGlobalMouseUp);
|
|
127
|
+
if (sliderElement) {
|
|
128
|
+
sliderElement.removeEventListener('mousedown', handleSliderMouseDown);
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
});
|
|
146
132
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
133
|
+
onDestroy(() => {
|
|
134
|
+
isClickHandled = false;
|
|
135
|
+
});
|
|
150
136
|
|
|
151
137
|
/**
|
|
152
138
|
* Value Change Handler
|
|
153
139
|
* Updates value and manages focus state
|
|
154
140
|
* @param newValue - New slider value(s)
|
|
155
141
|
*/
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
}
|
|
162
|
-
|
|
142
|
+
function handleChange(newValue: number | number[]) {
|
|
143
|
+
if (newValue !== lastValue && !isCurrentlyFocused) {
|
|
144
|
+
handleFocus();
|
|
145
|
+
isCurrentlyFocused = true;
|
|
146
|
+
}
|
|
163
147
|
// call the onChange callback
|
|
164
|
-
|
|
165
|
-
|
|
148
|
+
onChange(newValue);
|
|
166
149
|
// update the lastValue
|
|
167
|
-
|
|
168
|
-
|
|
150
|
+
lastValue = newValue;
|
|
151
|
+
}
|
|
169
152
|
|
|
170
153
|
/**
|
|
171
154
|
* Custom Track Click Handler
|
|
172
155
|
* Positions the thumb so that the clicked point becomes the center of the thumb
|
|
173
156
|
* @param event - Mouse event (cast to MouseEvent internally)
|
|
174
157
|
*/
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
158
|
+
function handleSliderMouseDown(event: Event) {
|
|
159
|
+
// Click was on thumb, let it handle normally
|
|
160
|
+
if (isClickHandled) return;
|
|
161
|
+
|
|
178
162
|
// Cast event to MouseEvent
|
|
179
|
-
|
|
180
|
-
|
|
163
|
+
const mouseEvent = event as MouseEvent;
|
|
181
164
|
// Check if click was on the thumb itself
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
}
|
|
165
|
+
const target = mouseEvent.target as HTMLElement;
|
|
166
|
+
if (target.getAttribute('role') === 'slider') {
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
187
169
|
|
|
188
170
|
// This was a click on the track, so we'll position the thumb
|
|
189
|
-
|
|
190
|
-
|
|
171
|
+
// Add mousedown handler to the slider component for track click positioning
|
|
172
|
+
const sliderElement = sliderContainer.querySelector('.slider-component');
|
|
173
|
+
if (!sliderElement) return;
|
|
191
174
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
175
|
+
const rect = sliderElement.getBoundingClientRect();
|
|
176
|
+
const clickX =
|
|
177
|
+
$textDirection === 'rtl' ? rect.right - mouseEvent.clientX : mouseEvent.clientX - rect.left;
|
|
178
|
+
const trackWidth = rect.width;
|
|
196
179
|
|
|
197
180
|
// Calculate the percentage position of the click
|
|
198
|
-
|
|
199
|
-
|
|
181
|
+
let percentage = (clickX / trackWidth) * 100;
|
|
200
182
|
// Clamp to valid range
|
|
201
|
-
|
|
202
|
-
|
|
183
|
+
percentage = Math.max(0, Math.min(100, percentage));
|
|
184
|
+
|
|
203
185
|
// Convert percentage to value
|
|
204
|
-
|
|
205
|
-
|
|
186
|
+
const rawValue = min + (percentage / 100) * (max - min);
|
|
206
187
|
// Round to nearest step
|
|
207
|
-
|
|
208
|
-
|
|
188
|
+
const steppedValue = Math.round((rawValue - min) / step) * step + min;
|
|
209
189
|
// Ensure value is within bounds
|
|
210
|
-
|
|
190
|
+
const clampedValue = Math.max(min, Math.min(max, steppedValue));
|
|
211
191
|
|
|
212
192
|
// Handle different slider types
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
193
|
+
if (sliderType === 'single') {
|
|
194
|
+
handleChange(clampedValue);
|
|
195
|
+
} else if (sliderType === 'multiple' && Array.isArray(value)) {
|
|
216
196
|
// For range sliders, determine which thumb to move based on proximity
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
197
|
+
const currentValue = value as [number, number];
|
|
198
|
+
const distanceToStart = Math.abs(clampedValue - currentValue[0]);
|
|
199
|
+
const distanceToEnd = Math.abs(clampedValue - currentValue[1]);
|
|
200
|
+
|
|
201
|
+
if (distanceToStart < distanceToEnd) {
|
|
222
202
|
// Move start thumb
|
|
223
|
-
|
|
224
|
-
|
|
203
|
+
handleChange([clampedValue, currentValue[1]]);
|
|
204
|
+
} else {
|
|
225
205
|
// Move end thumb
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
206
|
+
handleChange([currentValue[0], clampedValue]);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
229
209
|
|
|
230
210
|
// Mark click as handled
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
handleFocus();
|
|
235
|
-
|
|
236
|
-
// Allow the event to continue to the slider component for drag handling
|
|
237
|
-
// Don't prevent default or stop propagation
|
|
238
|
-
}
|
|
211
|
+
isClickHandled = true;
|
|
212
|
+
handleFocus();
|
|
213
|
+
}
|
|
239
214
|
|
|
240
215
|
/**
|
|
241
216
|
* Value Formatting
|
|
@@ -243,197 +218,153 @@
|
|
|
243
218
|
* @param val - Number to format
|
|
244
219
|
* @returns Formatted string representation
|
|
245
220
|
*/
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
221
|
+
function formatValue(val: number | undefined): string {
|
|
222
|
+
if (val === undefined) return '';
|
|
223
|
+
return val % 1 === 0 ? val.toFixed(0) : val.toFixed(1);
|
|
224
|
+
}
|
|
250
225
|
|
|
251
226
|
/**
|
|
252
227
|
* Focus Handler
|
|
253
228
|
* Manages focus state and triggers focus callback
|
|
254
229
|
*/
|
|
255
|
-
|
|
256
|
-
|
|
230
|
+
function handleFocus() {
|
|
231
|
+
if (!isCurrentlyFocused) {
|
|
257
232
|
// console.log('Slider focused through interaction, value:', lastValue);
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
233
|
+
onFocus();
|
|
234
|
+
isCurrentlyFocused = true;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
$: sliderValue =
|
|
239
|
+
sliderType === 'single'
|
|
240
|
+
? typeof value === 'number'
|
|
241
|
+
? value
|
|
242
|
+
: min
|
|
243
|
+
: Array.isArray(value)
|
|
244
|
+
? value
|
|
245
|
+
: [min, max];
|
|
267
246
|
|
|
268
247
|
// Helper function to safely get array value
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
248
|
+
function getArrayValue(arr: number | number[], index: number): number {
|
|
249
|
+
if (Array.isArray(arr)) {
|
|
250
|
+
return arr[index] ?? min;
|
|
251
|
+
}
|
|
252
|
+
return arr;
|
|
253
|
+
}
|
|
275
254
|
|
|
276
255
|
// Update lastValue when prop changes
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
const input = event.target as HTMLInputElement;
|
|
287
|
-
let newValue = parseFloat(input.value);
|
|
288
|
-
|
|
289
|
-
// Validate input
|
|
290
|
-
if (input.value === '' || isNaN(newValue)) {
|
|
291
|
-
return;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
// Clamp value within bounds
|
|
295
|
-
newValue = Math.min(Math.max(newValue, min), max);
|
|
296
|
-
|
|
297
|
-
// update the input value
|
|
298
|
-
input.value = newValue.toString();
|
|
299
|
-
|
|
300
|
-
// call the onChange callback
|
|
301
|
-
handleChange(newValue);
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
/**
|
|
305
|
-
* Input Blur Handler
|
|
306
|
-
* Validates and normalizes input on blur
|
|
307
|
-
*/
|
|
308
|
-
function handleInputBlur(event: Event) {
|
|
309
|
-
const input = event.target as HTMLInputElement;
|
|
310
|
-
|
|
311
|
-
if (input.value === '') {
|
|
312
|
-
input.value = value?.toString() || min.toString();
|
|
313
|
-
return;
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
let newValue = parseFloat(input.value);
|
|
317
|
-
if (isNaN(newValue)) {
|
|
318
|
-
input.value = value?.toString() || min.toString();
|
|
319
|
-
} else {
|
|
320
|
-
newValue = Math.min(Math.max(newValue, min), max);
|
|
321
|
-
input.value = newValue.toString();
|
|
322
|
-
|
|
323
|
-
// call the handleChange function
|
|
324
|
-
handleChange(newValue);
|
|
325
|
-
}
|
|
326
|
-
}
|
|
256
|
+
$: if (value !== undefined) {
|
|
257
|
+
lastValue = value;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
$: displayIndex = sliderType === 'multiple' ? 1 : 0;
|
|
261
|
+
$: rowGap = elementsGap ?? (sliderType === 'multiple' ? 8 : 12);
|
|
262
|
+
$: rowClass =
|
|
263
|
+
'slider-input-controller slider-main-container flex h-9 w-full items-center transition-colors duration-fast disabled:pointer-events-none disabled:opacity-50 ' +
|
|
264
|
+
className;
|
|
327
265
|
</script>
|
|
328
266
|
|
|
329
|
-
<!-- Slider Input Controller -->
|
|
330
|
-
<div class="slider-input-controller{className ? className + ' ' : ''} w-full flex flex-col widgetic-colors" style="gap: {elementsGap}px;">
|
|
331
267
|
<!-- Header -->
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
268
|
+
{#if label}
|
|
269
|
+
<InputControllerRow {label} {helpText}>
|
|
270
|
+
<!-- Slider Container with Extensions -->
|
|
336
271
|
<!-- Main Container with subcomponents -->
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
272
|
+
<div
|
|
273
|
+
class={rowClass}
|
|
274
|
+
style="min-height: {height}px; gap: {rowGap}px;"
|
|
275
|
+
data-thumb-size={thumbSize}
|
|
276
|
+
data-bar-height={barHeight}
|
|
277
|
+
onfocusin={onFocus}
|
|
278
|
+
bind:this={sliderContainer}
|
|
279
|
+
>
|
|
343
280
|
<!-- Min Value Display -->
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
bind:this={sliderTrack}
|
|
355
|
-
>
|
|
281
|
+
{#if sliderType === 'multiple'}
|
|
282
|
+
<span
|
|
283
|
+
class="value-display shrink-0 text-center text-body text-foreground"
|
|
284
|
+
style="width: {valueDisplayWidth}px;"
|
|
285
|
+
>
|
|
286
|
+
{formatValue(getArrayValue(sliderValue, 0))}
|
|
287
|
+
</span>
|
|
288
|
+
{/if}
|
|
289
|
+
|
|
290
|
+
<div class="relative flex min-w-0 flex-1 items-center">
|
|
356
291
|
<!-- Slider Component -->
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
</
|
|
292
|
+
<svelte:component
|
|
293
|
+
this={Slider}
|
|
294
|
+
{...{
|
|
295
|
+
type: sliderType,
|
|
296
|
+
value: sliderValue,
|
|
297
|
+
onValueChange: handleChange,
|
|
298
|
+
min,
|
|
299
|
+
max,
|
|
300
|
+
step,
|
|
301
|
+
class: 'slider-component w-full',
|
|
302
|
+
tabindex: -1
|
|
303
|
+
} as SliderProps}
|
|
304
|
+
/>
|
|
305
|
+
</div>
|
|
306
|
+
|
|
307
|
+
<span
|
|
308
|
+
class="value-display shrink-0 text-end text-body text-foreground"
|
|
309
|
+
style="width: {valueDisplayWidth}px;"
|
|
310
|
+
>
|
|
311
|
+
{formatValue(getArrayValue(sliderValue, displayIndex))}
|
|
312
|
+
</span>
|
|
313
|
+
</div>
|
|
314
|
+
</InputControllerRow>
|
|
315
|
+
{:else}
|
|
316
|
+
<div
|
|
317
|
+
class={rowClass}
|
|
318
|
+
style="min-height: {height}px; gap: {rowGap}px;"
|
|
319
|
+
data-thumb-size={thumbSize}
|
|
320
|
+
data-bar-height={barHeight}
|
|
321
|
+
onfocusin={onFocus}
|
|
322
|
+
bind:this={sliderContainer}
|
|
323
|
+
>
|
|
324
|
+
{#if sliderType === 'multiple'}
|
|
325
|
+
<span
|
|
326
|
+
class="value-display shrink-0 text-center text-body text-foreground"
|
|
327
|
+
style="width: {valueDisplayWidth}px;"
|
|
328
|
+
>
|
|
329
|
+
{formatValue(getArrayValue(sliderValue, 0))}
|
|
330
|
+
</span>
|
|
331
|
+
{/if}
|
|
332
|
+
|
|
333
|
+
<div class="relative flex min-w-0 flex-1 items-center">
|
|
334
|
+
<svelte:component
|
|
335
|
+
this={Slider}
|
|
336
|
+
{...{
|
|
337
|
+
type: sliderType,
|
|
338
|
+
value: sliderValue,
|
|
339
|
+
onValueChange: handleChange,
|
|
340
|
+
min,
|
|
341
|
+
max,
|
|
342
|
+
step,
|
|
343
|
+
class: 'slider-component w-full',
|
|
344
|
+
tabindex: -1
|
|
345
|
+
} as SliderProps}
|
|
346
|
+
/>
|
|
347
|
+
</div>
|
|
348
|
+
|
|
349
|
+
<span
|
|
350
|
+
class="value-display shrink-0 text-end text-body text-foreground"
|
|
351
|
+
style="width: {valueDisplayWidth}px;"
|
|
352
|
+
>
|
|
353
|
+
{formatValue(getArrayValue(sliderValue, displayIndex))}
|
|
354
|
+
</span>
|
|
355
|
+
</div>
|
|
356
|
+
{/if}
|
|
380
357
|
|
|
381
358
|
<style>
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
cursor: grab;
|
|
394
|
-
width: var(--thumb-size) !important;
|
|
395
|
-
height: var(--thumb-size) !important;
|
|
396
|
-
background-color: white !important;
|
|
397
|
-
border: 2px solid hsl(var(--grey5)) !important;
|
|
398
|
-
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
|
|
399
|
-
pointer-events: auto !important;
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
:global(.slider-component [role="slider"]:active) {
|
|
403
|
-
cursor: grabbing;
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
:global(.slider-component [role="slider"]:hover) {
|
|
407
|
-
border-color: hsl(var(--grey7)) !important;
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
/* Remove focus outline while maintaining accessibility */
|
|
411
|
-
:global(.slider-component [role="slider"]:focus),
|
|
412
|
-
:global(.slider-component [role="slider"]:focus-visible) {
|
|
413
|
-
outline: none !important;
|
|
414
|
-
box-shadow: none !important;
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
/* TRACK BAR Styles */
|
|
418
|
-
:global(.slider-component .bg-secondary) {
|
|
419
|
-
background-color: hsl(var(--grey5)) !important;
|
|
420
|
-
height: var(--bar-height) !important;
|
|
421
|
-
border-radius: var(--bar-height) !important; /* rounded ends */
|
|
422
|
-
cursor: pointer !important;
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
/* PROGRESS BAR Styles */
|
|
426
|
-
:global(.slider-component [data-slider-range]) {
|
|
427
|
-
background-color: hsl(var(--grey7)) !important;
|
|
428
|
-
cursor: pointer !important;
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
/* Thumb should override track cursor when hovering */
|
|
432
|
-
:global(.slider-component [role="slider"]:hover) {
|
|
433
|
-
cursor: grab !important;
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
:global(.slider-component [role="slider"]:active) {
|
|
437
|
-
cursor: grabbing !important;
|
|
438
|
-
}
|
|
359
|
+
.value-display {
|
|
360
|
+
user-select: none;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
:global(.slider-component [role='slider']) {
|
|
364
|
+
cursor: grab;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
:global(.slider-component [role='slider']:active) {
|
|
368
|
+
cursor: grabbing;
|
|
369
|
+
}
|
|
439
370
|
</style>
|