@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,299 +1,333 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
2
|
+
import { onDestroy } from 'svelte';
|
|
3
|
+
import { Input, StepperButton } from '@widgetic/design-system/components';
|
|
4
|
+
import { useEditorLanguage } from '../../i18n/language';
|
|
5
|
+
|
|
6
|
+
const { t } = useEditorLanguage();
|
|
7
|
+
|
|
8
|
+
export let value: number;
|
|
9
|
+
export let onChange: (newValue: number) => void;
|
|
10
|
+
export let min: number;
|
|
11
|
+
export let max: number;
|
|
12
|
+
export let step: number = 1;
|
|
13
|
+
export let isLocked: boolean = false;
|
|
14
|
+
export let onFocus: () => void = () => {};
|
|
15
|
+
export let customInputClass: string = '';
|
|
16
|
+
export let wrapAround: boolean = false;
|
|
17
|
+
export let suffix: string = '';
|
|
18
|
+
/** Extra classes on the outer control surface (default full width of the control column). */
|
|
19
|
+
let className = '';
|
|
20
|
+
export { className as class };
|
|
21
|
+
export let disabled: boolean = false;
|
|
22
|
+
/** Padding on the accent surface (Figma IC Number vs IC Angle field). */
|
|
23
|
+
export let surfacePaddingClass: string = 'pe-1 ps-3';
|
|
24
|
+
/** @deprecated use `class` — kept for Angle layout width. */
|
|
25
|
+
export let width: string | undefined = undefined;
|
|
26
|
+
|
|
27
|
+
let inputValue = String(value);
|
|
28
|
+
let isEditing = false;
|
|
29
|
+
let isPressed = false;
|
|
30
|
+
|
|
31
|
+
let autoRepeatTimer: ReturnType<typeof setTimeout> | null = null;
|
|
32
|
+
let autoRepeatInterval: ReturnType<typeof setInterval> | null = null;
|
|
33
|
+
|
|
34
|
+
const HOLD_DELAY = 400;
|
|
35
|
+
const REPEAT_INTERVAL = 80;
|
|
29
36
|
|
|
30
37
|
// Add unique ID generation
|
|
31
|
-
|
|
38
|
+
const inputId = `number-input-${Math.random().toString(36).substr(2, 9)}`;
|
|
32
39
|
|
|
33
|
-
|
|
34
|
-
|
|
40
|
+
$: isAtMin = !wrapAround && value <= min;
|
|
41
|
+
$: isAtMax = !wrapAround && value >= max;
|
|
42
|
+
$: isDisabled = disabled || isLocked;
|
|
35
43
|
|
|
36
44
|
// Update inputValue when value prop changes and we're not editing
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
45
|
+
$: if (!isEditing) {
|
|
46
|
+
inputValue = String(value);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const surfaceBaseClass =
|
|
50
|
+
'number-controls-surface flex h-9 w-full min-w-0 items-center gap-1 rounded-lg bg-accent transition-colors duration-fast hover:bg-accent-hover focus-within:outline-hidden focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2 focus-within:ring-offset-background disabled:pointer-events-none disabled:opacity-50';
|
|
51
|
+
|
|
52
|
+
function handleValueChange(adjustment: number) {
|
|
53
|
+
try {
|
|
54
|
+
let newValue = value + adjustment;
|
|
55
|
+
|
|
56
|
+
if (wrapAround) {
|
|
57
|
+
if (newValue >= 360) newValue -= 360;
|
|
58
|
+
if (newValue < 0) newValue += 360;
|
|
59
|
+
} else {
|
|
60
|
+
if (min !== undefined && newValue < min) {
|
|
61
|
+
newValue = min;
|
|
62
|
+
}
|
|
63
|
+
if (max !== undefined && newValue > max) {
|
|
64
|
+
newValue = max;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
value = newValue;
|
|
69
|
+
onChange(newValue);
|
|
70
|
+
} catch (error) {
|
|
71
|
+
console.error('Error in handleValueChange:', error);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function handleInput(e: Event) {
|
|
76
|
+
const input = e.currentTarget as HTMLInputElement;
|
|
77
|
+
inputValue = input.value;
|
|
78
|
+
|
|
79
|
+
if (inputValue === '') {
|
|
80
|
+
isEditing = true;
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
72
83
|
|
|
73
84
|
// Handle special cases
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
85
|
+
if (inputValue === '-0') {
|
|
86
|
+
inputValue = '0';
|
|
87
|
+
input.value = '0';
|
|
88
|
+
value = 0;
|
|
89
|
+
onChange(0);
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
81
92
|
|
|
82
93
|
// If starts with 0 and has more digits, remove the leading 0
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
94
|
+
if (inputValue.startsWith('0') && inputValue.length > 1 && !inputValue.startsWith('-')) {
|
|
95
|
+
inputValue = inputValue.substring(1);
|
|
96
|
+
input.value = inputValue;
|
|
97
|
+
}
|
|
87
98
|
|
|
88
99
|
// Don't allow minus sign if:
|
|
89
100
|
// 1. min >= 0
|
|
90
101
|
// 2. there's already a minus sign
|
|
91
102
|
// 3. there are numbers before it
|
|
92
|
-
|
|
93
|
-
|
|
103
|
+
if (inputValue.includes('-')) {
|
|
104
|
+
if (min >= 0 || inputValue.indexOf('-') > 0 || inputValue.split('-').length > 2) {
|
|
94
105
|
// Remove all minus signs or keep only the first one if allowed
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
}
|
|
106
|
+
inputValue = min >= 0 ? inputValue.replace(/-/g, '') : '-' + inputValue.replace(/-/g, '');
|
|
107
|
+
input.value = inputValue;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
101
110
|
|
|
102
111
|
// Update regex to prevent minus sign if min >= 0
|
|
103
112
|
// Only allow minus at the start of the string
|
|
104
|
-
|
|
105
|
-
|
|
113
|
+
const validNumberRegex = min >= 0 ? /^\d*$/ : /^-?\d*$/;
|
|
114
|
+
if (!validNumberRegex.test(inputValue)) {
|
|
106
115
|
// Remove any invalid characters
|
|
107
|
-
|
|
116
|
+
input.value = inputValue.replace(min >= 0 ? /[^\d]/g : /[^\d-]/g, '');
|
|
108
117
|
// If there's a minus, ensure it's at the start
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
118
|
+
if (input.value.includes('-') && input.value.indexOf('-') > 0) {
|
|
119
|
+
input.value = input.value.replace(/-/g, '');
|
|
120
|
+
}
|
|
121
|
+
inputValue = input.value;
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const numValue = parseFloat(inputValue);
|
|
126
|
+
if (!isNaN(numValue)) {
|
|
127
|
+
isEditing = true;
|
|
128
|
+
|
|
120
129
|
// Validate both min and max during typing
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
130
|
+
if (wrapAround && max === 360) {
|
|
131
|
+
if (numValue >= 360) {
|
|
132
|
+
inputValue = '359';
|
|
133
|
+
value = 359;
|
|
134
|
+
onChange(359);
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
} else if (!wrapAround) {
|
|
138
|
+
if (numValue > max) {
|
|
139
|
+
inputValue = String(max);
|
|
140
|
+
value = max;
|
|
141
|
+
onChange(max);
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
if (numValue < min) {
|
|
145
|
+
inputValue = String(min);
|
|
146
|
+
value = min;
|
|
147
|
+
onChange(min);
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
143
152
|
// Value is within range
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
153
|
+
value = numValue;
|
|
154
|
+
onChange(numValue);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function handleBlur() {
|
|
159
|
+
isEditing = false;
|
|
160
|
+
const finalValue = parseFloat(inputValue);
|
|
161
|
+
|
|
162
|
+
if (isNaN(finalValue) || inputValue === '' || inputValue === '-') {
|
|
163
|
+
value = min;
|
|
164
|
+
inputValue = String(min);
|
|
165
|
+
onChange(min);
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
159
168
|
|
|
160
169
|
// Apply validation on blur
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
170
|
+
let validatedValue = finalValue;
|
|
171
|
+
if (!wrapAround) {
|
|
172
|
+
if (finalValue < min) validatedValue = min;
|
|
173
|
+
if (finalValue > max) validatedValue = max;
|
|
174
|
+
} else {
|
|
175
|
+
validatedValue = ((finalValue % 360) + 360) % 360;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
value = validatedValue;
|
|
179
|
+
inputValue = String(validatedValue);
|
|
180
|
+
onChange(validatedValue);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function startAutoRepeat(operation: 'increment' | 'decrement', event: MouseEvent) {
|
|
184
|
+
event.preventDefault();
|
|
185
|
+
stopAutoRepeat();
|
|
186
|
+
|
|
187
|
+
const adjustment = operation === 'increment' ? step : -step;
|
|
188
|
+
isPressed = true;
|
|
189
|
+
handleValueChange(adjustment);
|
|
190
|
+
|
|
191
|
+
autoRepeatTimer = setTimeout(() => {
|
|
192
|
+
if (isPressed) {
|
|
193
|
+
autoRepeatInterval = setInterval(() => {
|
|
194
|
+
if (isPressed) {
|
|
195
|
+
handleValueChange(adjustment);
|
|
196
|
+
}
|
|
197
|
+
}, REPEAT_INTERVAL);
|
|
198
|
+
}
|
|
199
|
+
}, HOLD_DELAY);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
function stopAutoRepeat(event?: MouseEvent | FocusEvent) {
|
|
203
|
+
if (event) {
|
|
204
|
+
event.preventDefault();
|
|
205
|
+
event.stopPropagation();
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
if (autoRepeatTimer !== null) {
|
|
209
|
+
clearTimeout(autoRepeatTimer);
|
|
210
|
+
autoRepeatTimer = null;
|
|
211
|
+
}
|
|
212
|
+
if (autoRepeatInterval !== null) {
|
|
213
|
+
clearInterval(autoRepeatInterval);
|
|
214
|
+
autoRepeatInterval = null;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
isPressed = false;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
function handleKeyDown(e: KeyboardEvent) {
|
|
221
|
+
if ((e.metaKey || e.ctrlKey) && e.key === 'a') {
|
|
222
|
+
isEditing = true;
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
if (
|
|
227
|
+
e.key === 'Backspace' ||
|
|
228
|
+
e.key === 'Delete' ||
|
|
229
|
+
e.key === 'ArrowLeft' ||
|
|
230
|
+
e.key === 'ArrowRight' ||
|
|
231
|
+
e.key === 'Tab'
|
|
232
|
+
) {
|
|
233
|
+
isEditing = true;
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
if (e.metaKey || e.ctrlKey) {
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
if (e.key === 'ArrowUp') {
|
|
242
|
+
e.preventDefault();
|
|
243
|
+
handleValueChange(step);
|
|
244
|
+
} else if (e.key === 'ArrowDown') {
|
|
245
|
+
e.preventDefault();
|
|
246
|
+
handleValueChange(-step);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
onDestroy(() => {
|
|
251
|
+
stopAutoRepeat();
|
|
252
|
+
});
|
|
222
253
|
</script>
|
|
223
254
|
|
|
224
|
-
<div
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
255
|
+
<div
|
|
256
|
+
class="{surfaceBaseClass} {surfacePaddingClass} {className}"
|
|
257
|
+
style={width ? `width: ${width}` : undefined}
|
|
258
|
+
class:opacity-50={disabled}
|
|
259
|
+
class:pointer-events-none={disabled}
|
|
260
|
+
>
|
|
261
|
+
<div
|
|
262
|
+
class="flex min-w-0 flex-1 items-center {suffix
|
|
263
|
+
? 'justify-start gap-0'
|
|
264
|
+
: ''}"
|
|
265
|
+
>
|
|
266
|
+
{#if suffix}
|
|
267
|
+
<div class="number-controls-value inline-flex max-w-full min-w-0 items-baseline gap-0">
|
|
268
|
+
<Input
|
|
269
|
+
id={inputId}
|
|
270
|
+
type="text"
|
|
271
|
+
value={inputValue}
|
|
272
|
+
onfocus={onFocus}
|
|
273
|
+
oninput={handleInput}
|
|
274
|
+
onblur={handleBlur}
|
|
275
|
+
onkeydown={handleKeyDown}
|
|
276
|
+
readonly={isLocked}
|
|
277
|
+
{disabled}
|
|
278
|
+
size={Math.max(1, inputValue.length)}
|
|
279
|
+
class="number-controls-input number-controls-input-with-suffix h-full w-auto min-w-[1ch] max-w-full shrink border-0 bg-transparent px-0 text-start text-body text-foreground shadow-none focus-visible:ring-0 focus-visible:ring-offset-0 {customInputClass}"
|
|
280
|
+
/>
|
|
281
|
+
<span class="pointer-events-none shrink-0 text-body text-foreground">{suffix}</span>
|
|
282
|
+
</div>
|
|
283
|
+
{:else}
|
|
284
|
+
<Input
|
|
285
|
+
id={inputId}
|
|
286
|
+
type="text"
|
|
287
|
+
value={inputValue}
|
|
288
|
+
onfocus={onFocus}
|
|
289
|
+
oninput={handleInput}
|
|
290
|
+
onblur={handleBlur}
|
|
291
|
+
onkeydown={handleKeyDown}
|
|
292
|
+
readonly={isLocked}
|
|
293
|
+
{disabled}
|
|
294
|
+
class="number-controls-input h-full min-w-0 flex-1 border-0 bg-transparent px-0 text-body text-foreground shadow-none focus-visible:ring-0 focus-visible:ring-offset-0 {customInputClass}"
|
|
295
|
+
/>
|
|
296
|
+
{/if}
|
|
297
|
+
</div>
|
|
298
|
+
|
|
299
|
+
<div class="flex shrink-0 items-center gap-0">
|
|
300
|
+
<StepperButton
|
|
301
|
+
kind="minus"
|
|
302
|
+
label={$t('editor.stepper.decrease')}
|
|
303
|
+
disabled={isDisabled || isAtMin}
|
|
304
|
+
onmousedown={(e: MouseEvent) => startAutoRepeat('decrement', e)}
|
|
305
|
+
onmouseup={stopAutoRepeat}
|
|
306
|
+
onmouseleave={stopAutoRepeat}
|
|
307
|
+
/>
|
|
308
|
+
<StepperButton
|
|
309
|
+
kind="plus"
|
|
310
|
+
label={$t('editor.stepper.increase')}
|
|
311
|
+
disabled={isDisabled || isAtMax}
|
|
312
|
+
onmousedown={(e: MouseEvent) => startAutoRepeat('increment', e)}
|
|
313
|
+
onmouseup={stopAutoRepeat}
|
|
314
|
+
onmouseleave={stopAutoRepeat}
|
|
315
|
+
/>
|
|
316
|
+
</div>
|
|
278
317
|
</div>
|
|
279
318
|
|
|
280
319
|
<style>
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
:global(.number-input-button:focus-visible) {
|
|
296
|
-
outline: none !important;
|
|
297
|
-
box-shadow: none !important;
|
|
298
|
-
}
|
|
299
|
-
</style>
|
|
320
|
+
:global(.number-controls-input) {
|
|
321
|
+
text-align: start;
|
|
322
|
+
appearance: textfield;
|
|
323
|
+
-moz-appearance: textfield;
|
|
324
|
+
padding-inline-end: 0 !important;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
:global(.number-controls-input::-webkit-outer-spin-button),
|
|
328
|
+
:global(.number-controls-input::-webkit-inner-spin-button) {
|
|
329
|
+
-webkit-appearance: none;
|
|
330
|
+
appearance: none;
|
|
331
|
+
margin: 0;
|
|
332
|
+
}
|
|
333
|
+
</style>
|
|
@@ -22,7 +22,10 @@ declare const NumberControls: $$__sveltets_2_IsomorphicComponent<{
|
|
|
22
22
|
customInputClass?: string;
|
|
23
23
|
wrapAround?: boolean;
|
|
24
24
|
suffix?: string;
|
|
25
|
-
width?: string;
|
|
25
|
+
/** Extra classes on the outer control surface (default full width of the control column). */ class?: string;
|
|
26
|
+
disabled?: boolean;
|
|
27
|
+
/** Padding on the accent surface (Figma IC Number vs IC Angle field). */ surfacePaddingClass?: string;
|
|
28
|
+
/** @deprecated use `class` — kept for Angle layout width. */ width?: string | undefined;
|
|
26
29
|
}, {
|
|
27
30
|
[evt: string]: CustomEvent<any>;
|
|
28
31
|
}, {}, {}, string>;
|