@widgetic/editor 4.1.13 → 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 +55 -40
- package/dist/components/editors/EditLeaseNotice.svelte +44 -33
- package/dist/components/editors/EmbedEditor.svelte +133 -259
- package/dist/components/editors/PropsEditor.svelte +426 -1333
- 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/InputControllerRenderer.svelte +5 -1
- package/dist/components/ic/InputControllerRenderer.svelte.d.ts +2 -1
- package/dist/components/ic/InputControllerRow.svelte +74 -0
- package/dist/components/ic/InputControllerRow.svelte.d.ts +14 -0
- package/dist/components/ic/KnowledgeDocumentsInputController.svelte +401 -0
- package/dist/components/ic/KnowledgeDocumentsInputController.svelte.d.ts +11 -0
- package/dist/components/ic/KnowledgeTextForm.svelte +109 -0
- package/dist/components/ic/KnowledgeTextForm.svelte.d.ts +15 -0
- 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 +2 -0
- package/dist/components/ic/index.js +2 -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/composition/compositionApi.d.ts +21 -1
- package/dist/composition/compositionApi.js +64 -5
- package/dist/composition/knowledgeDocuments.d.ts +90 -0
- package/dist/composition/knowledgeDocuments.js +94 -0
- package/dist/composition/knowledgeDocumentsPanel.d.ts +152 -0
- package/dist/composition/knowledgeDocumentsPanel.js +443 -0
- package/dist/i18n/language.d.ts +86 -36
- package/dist/i18n/messages.d.ts +97 -34
- package/dist/i18n/messages.js +104 -34
- package/dist/i18n/translate.d.ts +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/knowledgeDocumentsContext.d.ts +10 -0
- package/dist/knowledgeDocumentsContext.js +31 -0
- package/dist/utils.d.ts +7 -0
- package/dist/utils.js +26 -2
- package/package.json +4 -4
|
@@ -13,474 +13,451 @@
|
|
|
13
13
|
-->
|
|
14
14
|
|
|
15
15
|
<script module lang="ts">
|
|
16
|
+
/** Declared props contract — export lets below are annotated from it so the
|
|
17
|
+
* interface cannot drift from what the component actually reads. */
|
|
16
18
|
/** Declared props contract — export lets below are annotated from it so the
|
|
17
19
|
* interface cannot drift from what the component actually reads. */
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
export interface RoundedCornersInputControllerProps {
|
|
21
|
+
value: { topLeft: number; topRight: number; bottomRight: number; bottomLeft: number };
|
|
22
|
+
onChange: (newValue: {
|
|
23
|
+
topLeft: number;
|
|
24
|
+
topRight: number;
|
|
25
|
+
bottomRight: number;
|
|
26
|
+
bottomLeft: number;
|
|
27
|
+
}) => void;
|
|
28
|
+
helpText?: string;
|
|
29
|
+
onFocus?: () => void;
|
|
30
|
+
}
|
|
24
31
|
</script>
|
|
25
32
|
|
|
26
33
|
<script lang="ts">
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
34
|
+
import { onMount } from 'svelte';
|
|
35
|
+
import { IconLock, IconLockOpen } from '@widgetic/design-system/icons';
|
|
36
|
+
import type { InputControllerConfig } from './index';
|
|
37
|
+
import { activeElementIn } from '../../utils/shadowDom';
|
|
38
|
+
import { useEditorLanguage } from '../../i18n/language';
|
|
39
|
+
|
|
40
|
+
// The words of the editor in the language of the page.
|
|
41
|
+
const { t } = useEditorLanguage();
|
|
42
|
+
|
|
43
|
+
// Constants
|
|
44
|
+
const MIN_RADIUS = 0;
|
|
45
|
+
const MAX_RADIUS = 120;
|
|
46
|
+
|
|
47
|
+
// Required props. `label`, `config` and `helpText` arrive through the
|
|
48
|
+
// dynamic-component props object but are never read here — export const
|
|
49
|
+
// keeps the init-set contract without the unused-reactive warning. A live
|
|
50
|
+
// no-op default: nothing reads these, so it can never mask a real value.
|
|
41
51
|
// Required props. `label`, `config` and `helpText` arrive through the
|
|
42
52
|
// dynamic-component props object but are never read here — export const
|
|
43
53
|
// keeps the init-set contract without the unused-reactive warning. A live
|
|
44
54
|
// no-op default: nothing reads these, so it can never mask a real value.
|
|
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
|
-
value = {
|
|
72
|
-
topLeft: newValue,
|
|
73
|
-
topRight: newValue,
|
|
74
|
-
bottomRight: newValue,
|
|
75
|
-
bottomLeft: newValue
|
|
76
|
-
};
|
|
77
|
-
} else {
|
|
55
|
+
export const label: string = '';
|
|
56
|
+
export let value: RoundedCornersInputControllerProps['value'];
|
|
57
|
+
export let onChange: RoundedCornersInputControllerProps['onChange'];
|
|
58
|
+
export let helpText: RoundedCornersInputControllerProps['helpText'] = undefined;
|
|
59
|
+
export let onFocus: RoundedCornersInputControllerProps['onFocus'] = () => {};
|
|
60
|
+
|
|
61
|
+
// Optional: Class prop for external styling
|
|
62
|
+
let className = '';
|
|
63
|
+
export { className as class };
|
|
64
|
+
|
|
65
|
+
// Internal state
|
|
66
|
+
let isLocked = true;
|
|
67
|
+
let focusedCorner: keyof typeof value | null = null;
|
|
68
|
+
let isEditing = false;
|
|
69
|
+
let isHovering = false;
|
|
70
|
+
|
|
71
|
+
// Reference to the input elements
|
|
72
|
+
let inputRefs: { [key in keyof typeof value]?: HTMLInputElement } = {};
|
|
73
|
+
|
|
74
|
+
// Helper function to update value while respecting lock state
|
|
75
|
+
function updateCorner(corner: keyof typeof value, newValue: number) {
|
|
76
|
+
// Ensure value is a non-negative integer within bounds
|
|
77
|
+
newValue = Math.max(MIN_RADIUS, Math.min(MAX_RADIUS, Math.floor(newValue)));
|
|
78
|
+
|
|
79
|
+
if (isLocked) {
|
|
80
|
+
// When locked, update all corners to the same value
|
|
78
81
|
// When unlocked, update only the specified corner
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
// When locked, update all corners to the same value
|
|
83
|
+
value = {
|
|
84
|
+
topLeft: newValue,
|
|
85
|
+
topRight: newValue,
|
|
86
|
+
bottomRight: newValue,
|
|
87
|
+
bottomLeft: newValue
|
|
88
|
+
};
|
|
89
|
+
} else {
|
|
90
|
+
// When unlocked, update only the specified corner
|
|
91
|
+
value = {
|
|
92
|
+
...value,
|
|
93
|
+
[corner]: newValue
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
// The fields show the change at once, in every corner it reached: the parent hands the value back only when it
|
|
97
|
+
// builds this control again, and until then the corners that were changed together kept showing the old number
|
|
84
98
|
// The fields show the change at once, in every corner it reached: the parent hands the value back only when it
|
|
85
99
|
// builds this control again, and until then the corners that were changed together kept showing the old number
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
100
|
+
onChange(value);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Handler for input changes
|
|
104
|
+
function handleInputChange(corner: keyof typeof value, e: Event) {
|
|
105
|
+
const target = e.target as HTMLInputElement;
|
|
106
|
+
const newValue = parseInt(target.value) || 0;
|
|
107
|
+
updateCorner(corner, newValue);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Handler for input
|
|
111
|
+
function handleInput(corner: keyof typeof value, e: Event) {
|
|
112
|
+
const input = e.target as HTMLInputElement;
|
|
113
|
+
const inputValue = input.value;
|
|
114
|
+
|
|
115
|
+
// Handle empty input
|
|
116
|
+
if (inputValue === '') {
|
|
117
|
+
isEditing = true;
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Prevent multiple minus signs or any minus sign (we only want positive integers)
|
|
122
|
+
if (inputValue.includes('-')) {
|
|
123
|
+
input.value = inputValue.replace(/-/g, '');
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// Validate numeric input - only allow digits
|
|
128
|
+
if (!/^\d*$/.test(inputValue)) {
|
|
129
|
+
input.value = inputValue.replace(/[^\d]/g, '');
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// Handle leading zeros - normalize the input value
|
|
134
|
+
if (inputValue.length > 1 && inputValue.startsWith('0')) {
|
|
135
|
+
// Convert to number and back to string to remove leading zeros
|
|
136
|
+
const normalizedValue = String(parseInt(inputValue, 10));
|
|
137
|
+
if (normalizedValue !== inputValue) {
|
|
138
|
+
input.value = normalizedValue;
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// Check if the value exceeds MAX_RADIUS during typing
|
|
144
|
+
const numValue = parseInt(inputValue);
|
|
145
|
+
if (!isNaN(numValue) && numValue > MAX_RADIUS) {
|
|
146
|
+
input.value = MAX_RADIUS.toString();
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (!isNaN(numValue)) {
|
|
151
|
+
// We're ok with temporarily having any positive integer during editing
|
|
152
|
+
if (corner === focusedCorner) {
|
|
153
|
+
isEditing = true;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// Handler for input focus
|
|
159
|
+
function handleInputFocus(corner: keyof typeof value) {
|
|
160
|
+
focusedCorner = corner;
|
|
161
|
+
isEditing = true;
|
|
162
|
+
onFocus();
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// Handler for input blur
|
|
166
|
+
function handleInputBlur(corner: keyof typeof value) {
|
|
167
|
+
const input = inputRefs[corner];
|
|
168
|
+
isEditing = false;
|
|
169
|
+
|
|
170
|
+
// Handle empty or invalid input
|
|
171
|
+
if (!input || input.value === '') {
|
|
172
|
+
const currentValue = value[corner];
|
|
173
|
+
input!.value = String(currentValue);
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// Validate and apply final value (ensure within bounds)
|
|
178
|
+
// This also normalizes the value (removing leading zeros)
|
|
163
179
|
// Validate and apply final value (ensure within bounds)
|
|
164
180
|
// This also normalizes the value (removing leading zeros)
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
181
|
+
const numValue = parseInt(input.value) || 0;
|
|
182
|
+
const finalValue = Math.max(MIN_RADIUS, Math.min(MAX_RADIUS, numValue));
|
|
183
|
+
|
|
184
|
+
// Always update the input with the normalized value (handles leading zeros)
|
|
185
|
+
input.value = finalValue.toString();
|
|
186
|
+
|
|
187
|
+
// Only trigger onChange if the value actually changed
|
|
188
|
+
if (value[corner] !== finalValue) {
|
|
189
|
+
updateCorner(corner, finalValue);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// Reset focused corner if we're not focusing another input immediately
|
|
193
|
+
setTimeout(() => {
|
|
194
|
+
// The focused element of the tree this control is in: inside a module `document.activeElement` is the module's
|
|
195
|
+
// host element, which is never one of the corners
|
|
178
196
|
// The focused element of the tree this control is in: inside a module `document.activeElement` is the module's
|
|
179
197
|
// host element, which is never one of the corners
|
|
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
|
-
|
|
198
|
+
const focusedElement = activeElementIn(input);
|
|
199
|
+
if (
|
|
200
|
+
!focusedElement ||
|
|
201
|
+
!(focusedElement instanceof HTMLInputElement) ||
|
|
202
|
+
!Object.values(inputRefs).includes(focusedElement)
|
|
203
|
+
) {
|
|
204
|
+
focusedCorner = null;
|
|
205
|
+
}
|
|
206
|
+
}, 0);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// Toggle the lock state
|
|
210
|
+
function toggleLock() {
|
|
211
|
+
isLocked = !isLocked;
|
|
212
|
+
|
|
213
|
+
// If locking, normalize all values to the first focused corner or top-left
|
|
214
|
+
if (isLocked && focusedCorner) {
|
|
215
|
+
const referenceValue = value[focusedCorner];
|
|
216
|
+
value = {
|
|
217
|
+
topLeft: referenceValue,
|
|
218
|
+
topRight: referenceValue,
|
|
219
|
+
bottomRight: referenceValue,
|
|
220
|
+
bottomLeft: referenceValue
|
|
221
|
+
};
|
|
222
|
+
onChange(value);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// The outer corner of the picture of the box that each of the four fields draws. The corners of a box are named by
|
|
227
|
+
// their place on the screen, whatever way the screen is read, so these stay physical.
|
|
206
228
|
// The outer corner of the picture of the box that each of the four fields draws. The corners of a box are named by
|
|
207
229
|
// their place on the screen, whatever way the screen is read, so these stay physical.
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
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
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
isHovering = true;
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
function handleMouseLeave() {
|
|
293
|
-
isHovering = false;
|
|
294
|
-
}
|
|
230
|
+
const CORNER_ROUNDING = {
|
|
231
|
+
topLeft: 'rounded-tl-[15px]', // rtl-ok: the corner of the picture of a box
|
|
232
|
+
topRight: 'rounded-tr-[15px]', // rtl-ok: the corner of the picture of a box
|
|
233
|
+
bottomLeft: 'rounded-bl-[15px]', // rtl-ok: the corner of the picture of a box
|
|
234
|
+
bottomRight: 'rounded-br-[15px]' // rtl-ok: the corner of the picture of a box
|
|
235
|
+
} as const;
|
|
236
|
+
|
|
237
|
+
// Get corner-specific CSS classes
|
|
238
|
+
function getCornerClasses(corner: keyof typeof value) {
|
|
239
|
+
const focused = focusedCorner === corner;
|
|
240
|
+
return {
|
|
241
|
+
container: `relative flex min-h-[38px] min-w-0 items-center justify-center transition-colors duration-fast ${CORNER_ROUNDING[corner]} ${focused ? 'bg-primary' : 'hover:bg-accent'}`,
|
|
242
|
+
input: `h-full w-full bg-transparent text-center text-body focus:outline-none ${focused ? 'text-primary-foreground' : 'text-foreground'}`
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
// Keyboard event handler
|
|
247
|
+
function handleKeyDown(corner: keyof typeof value, e: KeyboardEvent) {
|
|
248
|
+
const input = e.target as HTMLInputElement;
|
|
249
|
+
|
|
250
|
+
// Allow selection shortcuts
|
|
251
|
+
if ((e.metaKey || e.ctrlKey) && e.key === 'a') {
|
|
252
|
+
isEditing = true;
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
// Allow navigation keys
|
|
257
|
+
if (
|
|
258
|
+
e.key === 'Backspace' ||
|
|
259
|
+
e.key === 'Delete' ||
|
|
260
|
+
e.key === 'ArrowLeft' ||
|
|
261
|
+
e.key === 'ArrowRight' ||
|
|
262
|
+
e.key === 'Tab'
|
|
263
|
+
) {
|
|
264
|
+
isEditing = true;
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// Allow copy/paste operations
|
|
269
|
+
if (e.metaKey || e.ctrlKey) {
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
// Prevent leading zeros
|
|
274
|
+
if (e.key === '0') {
|
|
275
|
+
// If input is empty or the entire content is selected, just set to "0"
|
|
276
|
+
if (
|
|
277
|
+
input.value === '' ||
|
|
278
|
+
(input.selectionStart === 0 && input.selectionEnd === input.value.length)
|
|
279
|
+
) {
|
|
280
|
+
// Only set value if entering just a single 0
|
|
281
|
+
input.value = '0';
|
|
282
|
+
e.preventDefault();
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
// If cursor is at the start and there's already a digit, prevent additional leading zeros
|
|
287
|
+
if (input.selectionStart === 0 && /^\d/.test(input.value)) {
|
|
288
|
+
e.preventDefault();
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
// Prevent non-numeric inputs (except for navigation and editing keys)
|
|
294
|
+
if (
|
|
295
|
+
!/^\d$/.test(e.key) &&
|
|
296
|
+
!['Backspace', 'Delete', 'ArrowLeft', 'ArrowRight', 'Tab', 'Enter'].includes(e.key) &&
|
|
297
|
+
!(e.ctrlKey || e.metaKey)
|
|
298
|
+
) {
|
|
299
|
+
e.preventDefault();
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
// Mouse hover handlers for the controller
|
|
304
|
+
function handleMouseEnter() {
|
|
305
|
+
isHovering = true;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
function handleMouseLeave() {
|
|
309
|
+
isHovering = false;
|
|
310
|
+
}
|
|
295
311
|
</script>
|
|
296
312
|
|
|
297
313
|
<!-- Main corner radius grid component -->
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
314
|
+
<!-- Border overlay -->
|
|
315
|
+
<div
|
|
316
|
+
class="corners-container relative w-full max-w-editor-control 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 {className}"
|
|
317
|
+
role="group"
|
|
318
|
+
aria-label={label || $t('editor.corners.group')}
|
|
319
|
+
title={helpText}
|
|
320
|
+
on:mouseenter={handleMouseEnter}
|
|
321
|
+
on:mouseleave={handleMouseLeave}
|
|
322
|
+
on:focusin={onFocus}
|
|
323
|
+
>
|
|
324
|
+
<!-- Corner radius grid: four fields placed like the four corners of a box, top left first, so it is a left to right island -->
|
|
303
325
|
<!-- Corner radius grid: four fields placed like the four corners of a box, top left first, so it is a left to right island -->
|
|
304
|
-
|
|
326
|
+
<div class="corners-grid" dir="ltr">
|
|
327
|
+
<!-- Top Left -->
|
|
305
328
|
<!-- Top Left -->
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
329
|
+
<div class={getCornerClasses('topLeft').container}>
|
|
330
|
+
<input
|
|
331
|
+
type="text"
|
|
332
|
+
inputmode="numeric"
|
|
333
|
+
pattern="[0-9]*"
|
|
334
|
+
bind:this={inputRefs['topLeft']}
|
|
335
|
+
value={value.topLeft}
|
|
336
|
+
on:input={(e) => handleInput('topLeft', e)}
|
|
337
|
+
on:change={(e) => handleInputChange('topLeft', e)}
|
|
338
|
+
on:focus={() => handleInputFocus('topLeft')}
|
|
339
|
+
on:blur={() => handleInputBlur('topLeft')}
|
|
340
|
+
on:keydown={(e) => handleKeyDown('topLeft', e)}
|
|
341
|
+
class={getCornerClasses('topLeft').input}
|
|
342
|
+
aria-label={$t('editor.corners.topLeft')}
|
|
343
|
+
maxlength="3"
|
|
344
|
+
/>
|
|
345
|
+
</div>
|
|
346
|
+
|
|
347
|
+
<!-- Top Right -->
|
|
324
348
|
<!-- Top Right -->
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
349
|
+
<div class={getCornerClasses('topRight').container}>
|
|
350
|
+
<input
|
|
351
|
+
type="text"
|
|
352
|
+
inputmode="numeric"
|
|
353
|
+
pattern="[0-9]*"
|
|
354
|
+
bind:this={inputRefs['topRight']}
|
|
355
|
+
value={value.topRight}
|
|
356
|
+
on:input={(e) => handleInput('topRight', e)}
|
|
357
|
+
on:change={(e) => handleInputChange('topRight', e)}
|
|
358
|
+
on:focus={() => handleInputFocus('topRight')}
|
|
359
|
+
on:blur={() => handleInputBlur('topRight')}
|
|
360
|
+
on:keydown={(e) => handleKeyDown('topRight', e)}
|
|
361
|
+
class={getCornerClasses('topRight').input}
|
|
362
|
+
aria-label={$t('editor.corners.topRight')}
|
|
363
|
+
maxlength="3"
|
|
364
|
+
/>
|
|
365
|
+
</div>
|
|
366
|
+
|
|
367
|
+
<!-- Bottom Left -->
|
|
343
368
|
<!-- Bottom Left -->
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
369
|
+
<div class={getCornerClasses('bottomLeft').container}>
|
|
370
|
+
<input
|
|
371
|
+
type="text"
|
|
372
|
+
inputmode="numeric"
|
|
373
|
+
pattern="[0-9]*"
|
|
374
|
+
bind:this={inputRefs['bottomLeft']}
|
|
375
|
+
value={value.bottomLeft}
|
|
376
|
+
on:input={(e) => handleInput('bottomLeft', e)}
|
|
377
|
+
on:change={(e) => handleInputChange('bottomLeft', e)}
|
|
378
|
+
on:focus={() => handleInputFocus('bottomLeft')}
|
|
379
|
+
on:blur={() => handleInputBlur('bottomLeft')}
|
|
380
|
+
on:keydown={(e) => handleKeyDown('bottomLeft', e)}
|
|
381
|
+
class={getCornerClasses('bottomLeft').input}
|
|
382
|
+
aria-label={$t('editor.corners.bottomLeft')}
|
|
383
|
+
maxlength="3"
|
|
384
|
+
/>
|
|
385
|
+
</div>
|
|
386
|
+
|
|
387
|
+
<!-- Bottom Right -->
|
|
362
388
|
<!-- Bottom Right -->
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
389
|
+
<div class={getCornerClasses('bottomRight').container}>
|
|
390
|
+
<input
|
|
391
|
+
type="text"
|
|
392
|
+
inputmode="numeric"
|
|
393
|
+
pattern="[0-9]*"
|
|
394
|
+
bind:this={inputRefs['bottomRight']}
|
|
395
|
+
value={value.bottomRight}
|
|
396
|
+
on:input={(e) => handleInput('bottomRight', e)}
|
|
397
|
+
on:change={(e) => handleInputChange('bottomRight', e)}
|
|
398
|
+
on:focus={() => handleInputFocus('bottomRight')}
|
|
399
|
+
on:blur={() => handleInputBlur('bottomRight')}
|
|
400
|
+
on:keydown={(e) => handleKeyDown('bottomRight', e)}
|
|
401
|
+
class={getCornerClasses('bottomRight').input}
|
|
402
|
+
aria-label={$t('editor.corners.bottomRight')}
|
|
403
|
+
maxlength="3"
|
|
404
|
+
/>
|
|
405
|
+
</div>
|
|
406
|
+
|
|
407
|
+
<!-- Centered lock button -->
|
|
381
408
|
<!-- Centered lock button -->
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
<div
|
|
399
|
-
class="border-overlay {isHovering ? 'hovered' : ''}"
|
|
400
|
-
aria-hidden="true"
|
|
401
|
-
></div>
|
|
409
|
+
<button
|
|
410
|
+
type="button"
|
|
411
|
+
class="lock-button absolute left-1/2 top-1/2 z-10 flex size-7 -translate-x-1/2 -translate-y-1/2 items-center justify-center rounded-lg border border-border bg-background transition-colors duration-fast focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background {isLocked
|
|
412
|
+
? 'border-transparent bg-primary text-primary-foreground'
|
|
413
|
+
: 'text-foreground hover:bg-accent'}"
|
|
414
|
+
on:click={toggleLock}
|
|
415
|
+
aria-label={isLocked ? $t('editor.corners.unlock') : $t('editor.corners.lock')}
|
|
416
|
+
aria-pressed={isLocked}
|
|
417
|
+
>
|
|
418
|
+
{#if isLocked}
|
|
419
|
+
<IconLock class="size-4 stroke-[1.333]" aria-hidden="true" />
|
|
420
|
+
{:else}
|
|
421
|
+
<IconLockOpen class="size-4 stroke-[1.333]" aria-hidden="true" />
|
|
422
|
+
{/if}
|
|
423
|
+
</button>
|
|
424
|
+
</div>
|
|
402
425
|
</div>
|
|
403
426
|
|
|
404
427
|
<style>
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
428
|
+
input {
|
|
429
|
+
-moz-appearance: textfield;
|
|
430
|
+
appearance: textfield;
|
|
431
|
+
padding: 8px 4px;
|
|
432
|
+
font-size: 16px;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
/* Base corner container styles */
|
|
412
436
|
/* Base corner container styles */
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
437
|
+
.corners-grid > div {
|
|
438
|
+
min-width: 60px;
|
|
439
|
+
min-height: 40px;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
/* Focus states */
|
|
418
443
|
/* Focus states */
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
444
|
+
input:focus {
|
|
445
|
+
outline: none !important;
|
|
446
|
+
}
|
|
422
447
|
|
|
423
448
|
/* Main container */
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
height: 111px;
|
|
428
|
-
}
|
|
449
|
+
.corners-container {
|
|
450
|
+
min-height: 100px;
|
|
451
|
+
}
|
|
429
452
|
|
|
430
453
|
/* Grid styling */
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
/* Lock button styling */
|
|
444
|
-
.lock-button {
|
|
445
|
-
position: absolute;
|
|
446
|
-
width: 40px;
|
|
447
|
-
height: 40px;
|
|
448
|
-
border-radius: 50%;
|
|
449
|
-
background-color: white;
|
|
450
|
-
display: flex;
|
|
451
|
-
align-items: center;
|
|
452
|
-
justify-content: center;
|
|
453
|
-
z-index: 10;
|
|
454
|
-
box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.1);
|
|
455
|
-
transition: all 0.2s ease;
|
|
456
|
-
top: 50%;
|
|
457
|
-
left: 50%;
|
|
458
|
-
transform: translate(-50%, -50%);
|
|
459
|
-
outline: none !important;
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
.lock-button:focus-visible {
|
|
463
|
-
box-shadow: 0 0 0 2px hsl(var(--primary));
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
/* Border overlay */
|
|
467
|
-
.border-overlay {
|
|
468
|
-
position: absolute;
|
|
469
|
-
inset: 0;
|
|
470
|
-
pointer-events: none;
|
|
471
|
-
border-radius: 15px;
|
|
472
|
-
border: 1px solid hsl(var(--grey2));
|
|
473
|
-
transition: border-color 0.2s ease;
|
|
474
|
-
z-index: 5;
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
.border-overlay.hovered {
|
|
478
|
-
border-color: hsl(var(--forest-green));
|
|
479
|
-
}
|
|
480
|
-
|
|
481
|
-
:global(.subtext) {
|
|
482
|
-
font-size: 14px;
|
|
483
|
-
line-height: 1.5;
|
|
484
|
-
font-weight: 400;
|
|
485
|
-
}
|
|
486
|
-
</style>
|
|
454
|
+
.corners-grid {
|
|
455
|
+
position: relative;
|
|
456
|
+
display: grid;
|
|
457
|
+
width: 100%;
|
|
458
|
+
min-height: 100px;
|
|
459
|
+
grid-template-columns: 1fr 1fr;
|
|
460
|
+
grid-template-rows: 1fr 1fr;
|
|
461
|
+
gap: 0;
|
|
462
|
+
}
|
|
463
|
+
</style>
|