@widgetic/editor 4.1.17 → 4.1.19

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 (112) hide show
  1. package/dist/components/PreviewChromeControls.svelte +2 -2
  2. package/dist/components/WidgetPreview.svelte +79 -16
  3. package/dist/components/editors/CompositionEditorApp.svelte +71 -35
  4. package/dist/components/editors/CompositionEditorApp.svelte.d.ts +3 -1
  5. package/dist/components/editors/ContentTabBulkDrop.svelte +268 -0
  6. package/dist/components/editors/ContentTabBulkDrop.svelte.d.ts +37 -0
  7. package/dist/components/editors/EmbedAssistantPanel.svelte +303 -0
  8. package/dist/components/editors/EmbedAssistantPanel.svelte.d.ts +29 -0
  9. package/dist/components/editors/EmbedEditor.svelte +221 -15
  10. package/dist/components/editors/EmbedEditor.svelte.d.ts +31 -3
  11. package/dist/components/editors/PropsEditor.svelte +326 -37
  12. package/dist/components/editors/PropsEditor.svelte.d.ts +11 -0
  13. package/dist/components/editors/propsEditorContentStateFlatten.d.ts +12 -0
  14. package/dist/components/editors/propsEditorContentStateFlatten.js +40 -0
  15. package/dist/components/ic/AngleInputController.svelte +9 -5
  16. package/dist/components/ic/BrowserInputController.svelte +208 -132
  17. package/dist/components/ic/BrowserInputController.svelte.d.ts +2 -0
  18. package/dist/components/ic/CheckboxInputController.svelte +11 -0
  19. package/dist/components/ic/ColorPickerInputController.svelte +122 -49
  20. package/dist/components/ic/DatePickerInputController.svelte +23 -13
  21. package/dist/components/ic/FixedPositionInputController.svelte +1 -1
  22. package/dist/components/ic/FontInputController.svelte +48 -47
  23. package/dist/components/ic/InputControllerHeader.svelte +5 -4
  24. package/dist/components/ic/KnowledgeDocumentsInputController.svelte +20 -7
  25. package/dist/components/ic/NumberControls.svelte +163 -35
  26. package/dist/components/ic/PositionInputController.svelte +24 -15
  27. package/dist/components/ic/RadioGroupInputController.svelte +11 -0
  28. package/dist/components/ic/RangeCalendarInputController.svelte +73 -28
  29. package/dist/components/ic/RoundedCornersInputController.svelte +2 -2
  30. package/dist/components/ic/SliderInputController.svelte +11 -4
  31. package/dist/components/ic/TextAreaInputController.svelte +620 -327
  32. package/dist/components/ic/TextAreaPreviewInputController.svelte +53 -64
  33. package/dist/components/ic/TextInputController.svelte +15 -2
  34. package/dist/components/ic/TimeInputController.svelte +1 -1
  35. package/dist/components/ic/VectorInputController.svelte +152 -20
  36. package/dist/components/ic/numberControlsValueArea.d.ts +29 -0
  37. package/dist/components/ic/numberControlsValueArea.js +51 -0
  38. package/dist/components/ic/optionGroupCardPointerDown.d.ts +9 -0
  39. package/dist/components/ic/optionGroupCardPointerDown.js +20 -0
  40. package/dist/components/ic/shared/DropdownChevron.svelte +2 -2
  41. package/dist/components/ic/shared/DropdownChevron.svelte.d.ts +1 -1
  42. package/dist/components/ic/shared/EditorFileBrowserOverlay.svelte +174 -0
  43. package/dist/components/ic/shared/EditorFileBrowserOverlay.svelte.d.ts +30 -0
  44. package/dist/components/ic/shared/EditorSelectedFilePreviewOverlay.svelte +34 -0
  45. package/dist/components/ic/shared/EditorSelectedFilePreviewOverlay.svelte.d.ts +24 -0
  46. package/dist/components/ic/shared/ItemGrid.svelte +2 -2
  47. package/dist/components/ic/shared/RecentItemsSection.svelte +6 -6
  48. package/dist/components/ic/shared/editableFieldClasses.d.ts +15 -0
  49. package/dist/components/ic/shared/editableFieldClasses.js +15 -0
  50. package/dist/components/ic/shared/fileBrowserOverlayEscape.d.ts +29 -0
  51. package/dist/components/ic/shared/fileBrowserOverlayEscape.js +21 -0
  52. package/dist/components/ic/shared/index.d.ts +1 -0
  53. package/dist/components/ic/shared/index.js +1 -0
  54. package/dist/components/ui/calendar-editor-fit/EditorCalendarStyles.svelte +41 -9
  55. package/dist/composition/compositionApi.d.ts +16 -0
  56. package/dist/composition/compositionApi.js +16 -1
  57. package/dist/composition/compositionEditorController.d.ts +46 -0
  58. package/dist/composition/compositionEditorController.js +277 -5
  59. package/dist/composition/compositionEditorSchemaCache.d.ts +35 -0
  60. package/dist/composition/compositionEditorSchemaCache.js +82 -0
  61. package/dist/contentBulkDrop/applyContentPlan.d.ts +18 -0
  62. package/dist/contentBulkDrop/applyContentPlan.js +55 -0
  63. package/dist/contentBulkDrop/bulkDropSummary.d.ts +4 -0
  64. package/dist/contentBulkDrop/bulkDropSummary.js +12 -0
  65. package/dist/contentBulkDrop/dragIntent.d.ts +7 -0
  66. package/dist/contentBulkDrop/dragIntent.js +24 -0
  67. package/dist/contentBulkDrop/filterDropFiles.d.ts +2 -0
  68. package/dist/contentBulkDrop/filterDropFiles.js +21 -0
  69. package/dist/contentBulkDrop/formatFileSize.d.ts +2 -0
  70. package/dist/contentBulkDrop/formatFileSize.js +13 -0
  71. package/dist/contentBulkDrop/types.d.ts +34 -0
  72. package/dist/contentBulkDrop/types.js +1 -0
  73. package/dist/contentBulkDrop/uploadQueue.d.ts +41 -0
  74. package/dist/contentBulkDrop/uploadQueue.js +114 -0
  75. package/dist/drafts/compositionDraft.d.ts +65 -0
  76. package/dist/drafts/compositionDraft.js +136 -0
  77. package/dist/drafts/compositionEditorViewState.d.ts +9 -0
  78. package/dist/drafts/compositionEditorViewState.js +33 -0
  79. package/dist/drafts/draftJournal.d.ts +59 -0
  80. package/dist/drafts/draftJournal.js +261 -0
  81. package/dist/embed/__fixtures__/gatewayGeneratedEmbedCodes.json +25 -0
  82. package/dist/embed/__fixtures__/generatedEmbedCodes.json +320 -0
  83. package/dist/embed/parseCompositionEmbedCode.d.ts +21 -0
  84. package/dist/embed/parseCompositionEmbedCode.js +376 -0
  85. package/dist/embedAssistant/embedAssistantEvents.d.ts +22 -0
  86. package/dist/embedAssistant/embedAssistantEvents.js +39 -0
  87. package/dist/embedAssistant/embedAssistantStream.d.ts +30 -0
  88. package/dist/embedAssistant/embedAssistantStream.js +125 -0
  89. package/dist/embedAssistant/highlightTiming.d.ts +1 -0
  90. package/dist/embedAssistant/highlightTiming.js +6 -0
  91. package/dist/embedAssistant/types.d.ts +27 -0
  92. package/dist/embedAssistant/types.js +1 -0
  93. package/dist/i18n/labels.js +8 -4
  94. package/dist/i18n/language.d.ts +297 -3
  95. package/dist/i18n/messages.d.ts +38 -1
  96. package/dist/i18n/messages.js +40 -1
  97. package/dist/i18n/translate.d.ts +1 -1
  98. package/dist/index.d.ts +3 -1
  99. package/dist/index.js +2 -0
  100. package/dist/utils/FontManager.d.ts +2 -0
  101. package/dist/utils/FontManager.js +16 -1
  102. package/dist/utils/angleMath.d.ts +2 -0
  103. package/dist/utils/angleMath.js +6 -0
  104. package/dist/utils/isEditableEventTarget.d.ts +5 -0
  105. package/dist/utils/isEditableEventTarget.js +25 -0
  106. package/dist/utils/linkUrlValidation.d.ts +17 -0
  107. package/dist/utils/linkUrlValidation.js +120 -0
  108. package/dist/utils/mediaFileValue.d.ts +12 -0
  109. package/dist/utils/mediaFileValue.js +24 -0
  110. package/dist/utils/placeRichTextCaretAtDocumentEnd.d.ts +11 -0
  111. package/dist/utils/placeRichTextCaretAtDocumentEnd.js +26 -0
  112. package/package.json +6 -6
@@ -112,21 +112,22 @@
112
112
  onmouseenter={handleMouseEnter}
113
113
  onmouseleave={handleMouseLeave}
114
114
  >
115
- <IconHelpCircle class="size-4 stroke-[1.333] text-muted-foreground" />
115
+ <IconHelpCircle class="size-4 stroke-2 text-muted-foreground" />
116
116
  </span>
117
117
  </Tooltip.Trigger>
118
118
 
119
119
  {#if showHelp && !isScrolling}
120
120
  <Portal target="editor-tooltips">
121
+ <!-- The floating wrapper is already position: fixed. A fixed content inside it takes the wrapper (zero wide) as its
122
+ containing block, which wrapped the help text one word per line, so the content stays in the flow. -->
121
123
  <Tooltip.Content
122
124
  side={sideAtEnd($textDirection)}
123
125
  sideOffset={5}
124
126
  align="center"
125
127
  alignOffset={-1}
126
- class="tooltip-content pointer-events-none fixed whitespace-nowrap select-none"
127
- style="z-index: 99999;"
128
+ class="tooltip-content pointer-events-none z-[99999] max-w-[min(18rem,calc(100vw-2rem))] text-balance whitespace-normal select-none"
128
129
  >
129
- <p class="text-caption">{helpText}</p>
130
+ <p class="text-caption text-pretty">{helpText}</p>
130
131
  </Tooltip.Content>
131
132
  </Portal>
132
133
  {/if}
@@ -84,6 +84,18 @@
84
84
  panel.destroy();
85
85
  });
86
86
 
87
+ // Warn before refresh/close while a knowledge file upload is still in flight (the bytes cannot be recovered).
88
+ $effect(() => {
89
+ if (typeof window === 'undefined') return;
90
+ if ($panel.sending === null) return;
91
+ const handler = (event: BeforeUnloadEvent) => {
92
+ event.preventDefault();
93
+ event.returnValue = '';
94
+ };
95
+ window.addEventListener('beforeunload', handler);
96
+ return () => window.removeEventListener('beforeunload', handler);
97
+ });
98
+
87
99
  /** True while the panel is sending a file or removing a document: nothing else can be started meanwhile. */
88
100
  const isBusy = $derived($panel.sending !== null || $panel.removing.length > 0);
89
101
 
@@ -196,6 +208,7 @@
196
208
  ? 'outline-2 outline-dashed outline-brand outline-offset-4'
197
209
  : ''}"
198
210
  data-knowledge-documents
211
+ data-content-field-file-drop
199
212
  onfocusin={() => onFocus()}
200
213
  ondragenter={handleDragEnter}
201
214
  ondragover={handleDragOver}
@@ -206,7 +219,7 @@
206
219
  <p class="text-body text-muted-foreground">{$t('editor.knowledge.unavailable')}</p>
207
220
  {:else if $panel.phase === 'loading'}
208
221
  <p class="text-body flex items-center gap-2 text-muted-foreground" role="status">
209
- <IconLoader2 class="size-4 shrink-0 animate-spin stroke-[1.333]" aria-hidden="true" />
222
+ <IconLoader2 class="size-4 shrink-0 animate-spin stroke-2" aria-hidden="true" />
210
223
  <span>{$t('editor.knowledge.loading')}</span>
211
224
  </p>
212
225
  {:else if $panel.phase === 'failed'}
@@ -215,7 +228,7 @@
215
228
  role="alert"
216
229
  >
217
230
  <p class="text-body flex gap-2 text-destructive">
218
- <IconAlertTriangle class="mt-0.5 size-4 shrink-0 stroke-[1.333]" aria-hidden="true" />
231
+ <IconAlertTriangle class="mt-0.5 size-4 shrink-0 stroke-2" aria-hidden="true" />
219
232
  <span
220
233
  >{$panel.loadFailure
221
234
  ? sentenceOf($panel.loadFailure)
@@ -236,7 +249,7 @@
236
249
  class="flex min-h-12 items-center gap-3 rounded-xl border border-border bg-accent py-2 ps-4 pe-2"
237
250
  >
238
251
  <IconFileText
239
- class="size-4 shrink-0 stroke-[1.333] text-muted-foreground"
252
+ class="size-4 shrink-0 stroke-2 text-muted-foreground"
240
253
  aria-hidden="true"
241
254
  />
242
255
  <div class="min-w-0 flex-1">
@@ -283,7 +296,7 @@
283
296
  disabled={isBusy}
284
297
  onclick={() => panel.askToRemove(document.id)}
285
298
  >
286
- <IconTrash class="size-4 stroke-[1.333]" aria-hidden="true" />
299
+ <IconTrash class="size-4 stroke-2" aria-hidden="true" />
287
300
  </IconButton>
288
301
  {/if}
289
302
  </li>
@@ -293,7 +306,7 @@
293
306
 
294
307
  {#if $panel.sending}
295
308
  <p class="text-body flex items-center gap-2 text-foreground" role="status">
296
- <IconLoader2 class="size-4 shrink-0 animate-spin stroke-[1.333]" aria-hidden="true" />
309
+ <IconLoader2 class="size-4 shrink-0 animate-spin stroke-2" aria-hidden="true" />
297
310
  <span class="truncate" dir={dirForUserText($textDirection)}>
298
311
  {#if $panel.sending.count > 1}
299
312
  {$t('editor.knowledge.sendingOf', {
@@ -317,7 +330,7 @@
317
330
  >
318
331
  {#each $panel.notices as notice (notice.id)}
319
332
  <p class="text-body flex gap-2 text-destructive">
320
- <IconAlertTriangle class="mt-0.5 size-4 shrink-0 stroke-[1.333]" aria-hidden="true" />
333
+ <IconAlertTriangle class="mt-0.5 size-4 shrink-0 stroke-2" aria-hidden="true" />
321
334
  <span>{sentenceOf(notice.message)}</span>
322
335
  </p>
323
336
  {/each}
@@ -340,7 +353,7 @@
340
353
  onclick={openFileChooser}
341
354
  >
342
355
  <IconPlus
343
- class="size-4 shrink-0 stroke-[1.333] text-muted-foreground"
356
+ class="size-4 shrink-0 stroke-2 text-muted-foreground"
344
357
  aria-hidden="true"
345
358
  />
346
359
  <span class="text-body-medium truncate text-foreground group-hover:underline">
@@ -3,6 +3,12 @@
3
3
  import { Input, StepperButton } from '@widgetic/design-system/components';
4
4
  import { useEditorLanguage } from '../../i18n/language';
5
5
  import { steppedNumber } from './numberControlsSteps';
6
+ import {
7
+ shouldRoutePointerToNumberInput,
8
+ selectionAfterValueAreaPress,
9
+ isPointerPastTextEnd,
10
+ selectionWhileDraggingFromValueChrome
11
+ } from './numberControlsValueArea';
6
12
 
7
13
  const { t } = useEditorLanguage();
8
14
 
@@ -33,21 +39,39 @@
33
39
  let inputValue = String(value);
34
40
  let isEditing = false;
35
41
  let isPressed = false;
42
+ let pressedStepper: 'increment' | 'decrement' | null = null;
36
43
 
37
44
  let autoRepeatTimer: ReturnType<typeof setTimeout> | null = null;
38
45
  let autoRepeatInterval: ReturnType<typeof setInterval> | null = null;
39
46
 
47
+ let numberInputEl: HTMLInputElement | null = null;
48
+ let valueAreaDragActive = false;
49
+
50
+ function measureTextWidth(text: string, font: string): number {
51
+ if (typeof document === 'undefined') return text.length * 8;
52
+ const canvas = document.createElement('canvas');
53
+ const context = canvas.getContext('2d');
54
+ if (!context) return text.length * 8;
55
+ context.font = font;
56
+ return context.measureText(text).width;
57
+ }
58
+
59
+ function textWidthOnInput(input: HTMLInputElement): number {
60
+ return measureTextWidth(input.value, getComputedStyle(input).font);
61
+ }
62
+
40
63
  const HOLD_DELAY = 400;
41
64
  const REPEAT_INTERVAL = 80;
42
65
 
43
- // Add unique ID generation
66
+ // Add unique ID generation
44
67
  const inputId = `number-input-${Math.random().toString(36).substr(2, 9)}`;
68
+ const suffixDescriptionId = suffix ? `${inputId}-suffix` : undefined;
45
69
 
46
70
  $: isAtMin = !wrapAround && value <= min;
47
71
  $: isAtMax = !wrapAround && value >= max;
48
72
  $: isDisabled = disabled || isLocked;
49
73
 
50
- // Update inputValue when value prop changes and we're not editing
74
+ // Update inputValue when value prop changes and we're not editing
51
75
  $: if (!isEditing) {
52
76
  inputValue = String(value);
53
77
  }
@@ -91,7 +115,7 @@
91
115
  return;
92
116
  }
93
117
 
94
- // Handle special cases
118
+ // Handle special cases
95
119
  if (inputValue === '-0') {
96
120
  inputValue = '0';
97
121
  input.value = '0';
@@ -100,31 +124,31 @@
100
124
  return;
101
125
  }
102
126
 
103
- // If starts with 0 and has more digits, remove the leading 0
127
+ // If starts with 0 and has more digits, remove the leading 0
104
128
  if (inputValue.startsWith('0') && inputValue.length > 1 && !inputValue.startsWith('-')) {
105
129
  inputValue = inputValue.substring(1);
106
130
  input.value = inputValue;
107
131
  }
108
132
 
109
- // Don't allow minus sign if:
110
- // 1. min >= 0
111
- // 2. there's already a minus sign
112
- // 3. there are numbers before it
133
+ // Don't allow minus sign if:
134
+ // 1. min >= 0
135
+ // 2. there's already a minus sign
136
+ // 3. there are numbers before it
113
137
  if (inputValue.includes('-')) {
114
138
  if (min >= 0 || inputValue.indexOf('-') > 0 || inputValue.split('-').length > 2) {
115
- // Remove all minus signs or keep only the first one if allowed
139
+ // Remove all minus signs or keep only the first one if allowed
116
140
  inputValue = min >= 0 ? inputValue.replace(/-/g, '') : '-' + inputValue.replace(/-/g, '');
117
141
  input.value = inputValue;
118
142
  }
119
143
  }
120
144
 
121
- // Update regex to prevent minus sign if min >= 0
122
- // Only allow minus at the start of the string
145
+ // Update regex to prevent minus sign if min >= 0
146
+ // Only allow minus at the start of the string
123
147
  const validNumberRegex = min >= 0 ? /^\d*$/ : /^-?\d*$/;
124
148
  if (!validNumberRegex.test(inputValue)) {
125
- // Remove any invalid characters
149
+ // Remove any invalid characters
126
150
  input.value = inputValue.replace(min >= 0 ? /[^\d]/g : /[^\d-]/g, '');
127
- // If there's a minus, ensure it's at the start
151
+ // If there's a minus, ensure it's at the start
128
152
  if (input.value.includes('-') && input.value.indexOf('-') > 0) {
129
153
  input.value = input.value.replace(/-/g, '');
130
154
  }
@@ -136,7 +160,7 @@
136
160
  if (!isNaN(numValue)) {
137
161
  isEditing = true;
138
162
 
139
- // Validate both min and max during typing
163
+ // Validate both min and max during typing
140
164
  if (wrapAround && max === 360) {
141
165
  if (numValue >= 360) {
142
166
  inputValue = '359';
@@ -159,7 +183,7 @@
159
183
  }
160
184
  }
161
185
 
162
- // Value is within range
186
+ // Value is within range
163
187
  value = numValue;
164
188
  onChange(numValue);
165
189
  }
@@ -176,7 +200,7 @@
176
200
  return;
177
201
  }
178
202
 
179
- // Apply validation on blur
203
+ // Apply validation on blur
180
204
  let validatedValue = finalValue;
181
205
  if (!wrapAround) {
182
206
  if (finalValue < min) validatedValue = min;
@@ -193,11 +217,12 @@
193
217
  function startAutoRepeat(operation: 'increment' | 'decrement', event: MouseEvent) {
194
218
  // Only the main button steps: a right or middle click must not
195
219
  if (event.button !== 0) return;
196
- event.preventDefault();
220
+ // Do not preventDefault on mousedown: it suppresses the button :active state and breaks press-feedback scale.
197
221
  stopAutoRepeat();
198
222
 
199
223
  const adjustment = operation === 'increment' ? step : -step;
200
224
  isPressed = true;
225
+ pressedStepper = operation === 'increment' ? 'increment' : 'decrement';
201
226
 
202
227
  // The button turns disabled when the value reaches a limit, and a disabled button gets no mouseup and no mouseleave:
203
228
  // the release is watched on the window too, or the repeat would go on firing `onChange` at the limit until the next press.
@@ -230,8 +255,8 @@
230
255
  }
231
256
 
232
257
  function stopAutoRepeat(event?: MouseEvent | FocusEvent) {
258
+ // Do not preventDefault on mouseup: it can shorten :active and weaken press-feedback on the steppers.
233
259
  if (event) {
234
- event.preventDefault();
235
260
  event.stopPropagation();
236
261
  }
237
262
 
@@ -250,10 +275,14 @@
250
275
  }
251
276
 
252
277
  isPressed = false;
278
+ pressedStepper = null;
253
279
  }
254
280
 
255
281
  function handleKeyDown(e: KeyboardEvent) {
256
282
  if ((e.metaKey || e.ctrlKey) && e.key === 'a') {
283
+ e.preventDefault();
284
+ const input = e.currentTarget as HTMLInputElement;
285
+ input.setSelectionRange(0, input.value.length);
257
286
  isEditing = true;
258
287
  return;
259
288
  }
@@ -282,8 +311,75 @@
282
311
  }
283
312
  }
284
313
 
314
+ function focusNumberInput(input: HTMLInputElement) {
315
+ input.focus({ preventScroll: true });
316
+ isEditing = true;
317
+ }
318
+
319
+ function endValueAreaDrag() {
320
+ valueAreaDragActive = false;
321
+ if (typeof window !== 'undefined') {
322
+ window.removeEventListener('mousemove', handleValueAreaMouseMove);
323
+ window.removeEventListener('mouseup', endValueAreaDrag);
324
+ }
325
+ }
326
+
327
+ function handleValueAreaMouseMove(event: MouseEvent) {
328
+ if (!valueAreaDragActive || isDisabled) return;
329
+ const input = numberInputEl ?? document.getElementById(inputId);
330
+ if (!(input instanceof HTMLInputElement)) return;
331
+ const pastEnd = isPointerPastTextEnd(
332
+ input.value,
333
+ input.getBoundingClientRect().left,
334
+ event.clientX,
335
+ textWidthOnInput(input)
336
+ );
337
+ const selection = selectionWhileDraggingFromValueChrome(
338
+ input.value.length,
339
+ pastEnd,
340
+ event.shiftKey
341
+ );
342
+ if (selection) {
343
+ input.setSelectionRange(selection.start, selection.end);
344
+ }
345
+ }
346
+
347
+ function handleValueAreaMouseDown(event: MouseEvent) {
348
+ if (isDisabled) return;
349
+ if (!shouldRoutePointerToNumberInput(event.target, inputId)) return;
350
+ const input = document.getElementById(inputId);
351
+ if (!(input instanceof HTMLInputElement)) return;
352
+ event.preventDefault();
353
+ focusNumberInput(input);
354
+ const { start, end } = selectionAfterValueAreaPress(inputValue, event.shiftKey);
355
+ input.setSelectionRange(start, end);
356
+ valueAreaDragActive = true;
357
+ window.addEventListener('mousemove', handleValueAreaMouseMove);
358
+ window.addEventListener('mouseup', endValueAreaDrag);
359
+ }
360
+
361
+ function handleInputMouseDown(event: MouseEvent) {
362
+ if (isDisabled || event.button !== 0) return;
363
+ const input = event.currentTarget as HTMLInputElement;
364
+ const pastEnd = isPointerPastTextEnd(
365
+ input.value,
366
+ input.getBoundingClientRect().left,
367
+ event.clientX,
368
+ textWidthOnInput(input)
369
+ );
370
+ if (!pastEnd) return;
371
+ event.preventDefault();
372
+ focusNumberInput(input);
373
+ const { start, end } = selectionAfterValueAreaPress(inputValue, event.shiftKey);
374
+ input.setSelectionRange(start, end);
375
+ valueAreaDragActive = true;
376
+ window.addEventListener('mousemove', handleValueAreaMouseMove);
377
+ window.addEventListener('mouseup', endValueAreaDrag);
378
+ }
379
+
285
380
  onDestroy(() => {
286
381
  stopAutoRepeat();
382
+ endValueAreaDrag();
287
383
  });
288
384
  </script>
289
385
 
@@ -299,42 +395,67 @@
299
395
  it is dead space (the padding that keeps the value 12px in used to sit on the surface, outside the input, and the input
300
396
  drew its own square hover box inside the rounded surface, which looked cut out).
301
397
  -->
398
+ <!-- svelte-ignore a11y_no_noninteractive_element_interactions -->
302
399
  <label
303
400
  for={inputId}
304
401
  class="number-controls-hit-area flex h-full min-w-0 flex-1 items-center rounded-s-lg {inputPaddingClass} {isDisabled
305
402
  ? 'cursor-default'
306
403
  : 'cursor-text'} {suffix ? 'justify-start gap-0' : ''}"
404
+ onmousedown={handleValueAreaMouseDown}
307
405
  >
308
406
  {#if suffix}
309
- <span class="number-controls-value inline-flex max-w-full min-w-0 items-baseline gap-0">
407
+ <span class="number-controls-value inline-flex w-fit max-w-full min-w-0 items-baseline gap-0">
408
+ <span class="number-controls-digit-sizer relative inline-block w-fit max-w-full">
409
+ <!-- The sizer is as wide as the digits themselves (no `ch` guess: a digit, a minus sign and a dot are not equally wide), so nothing is left after the number -->
410
+ <span class="invisible block whitespace-pre text-body tabular-nums" aria-hidden="true">
411
+ {inputValue || '0'}
412
+ </span>
413
+ <Input
414
+ id={inputId}
415
+ type="text"
416
+ bind:ref={numberInputEl}
417
+ value={inputValue}
418
+ aria-describedby={suffixDescriptionId}
419
+ onfocus={onFocus}
420
+ oninput={handleInput}
421
+ onblur={handleBlur}
422
+ onkeydown={handleKeyDown}
423
+ onmousedown={handleInputMouseDown}
424
+ readonly={isLocked}
425
+ {disabled}
426
+ class="number-controls-input number-controls-input-with-suffix select-text absolute inset-0 h-full w-full min-w-0 border-0 bg-transparent px-0 text-start text-body text-foreground shadow-none hover:bg-transparent focus-visible:ring-0 focus-visible:ring-offset-0 {customInputClass}"
427
+ />
428
+ </span>
429
+ {#if suffixDescriptionId}
430
+ <span id={suffixDescriptionId} class="sr-only">{suffix}</span>
431
+ {/if}
432
+ <span
433
+ class="pointer-events-none shrink-0 select-none text-body text-foreground"
434
+ aria-hidden="true"
435
+ >
436
+ {suffix}
437
+ </span>
438
+ </span>
439
+ {:else}
440
+ <span class="number-controls-digit-sizer relative inline-block w-fit max-w-full">
441
+ <span class="invisible block whitespace-pre text-body tabular-nums" aria-hidden="true">
442
+ {inputValue || '0'}
443
+ </span>
310
444
  <Input
311
445
  id={inputId}
312
446
  type="text"
447
+ bind:ref={numberInputEl}
313
448
  value={inputValue}
314
449
  onfocus={onFocus}
315
450
  oninput={handleInput}
316
451
  onblur={handleBlur}
317
452
  onkeydown={handleKeyDown}
453
+ onmousedown={handleInputMouseDown}
318
454
  readonly={isLocked}
319
455
  {disabled}
320
- size={Math.max(1, inputValue.length)}
321
- 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 hover:bg-transparent focus-visible:ring-0 focus-visible:ring-offset-0 {customInputClass}"
456
+ class="number-controls-input absolute inset-0 h-full w-full min-w-0 border-0 bg-transparent px-0 text-body text-foreground shadow-none hover:bg-transparent focus-visible:ring-0 focus-visible:ring-offset-0 {customInputClass}"
322
457
  />
323
- <span class="pointer-events-none shrink-0 text-body text-foreground">{suffix}</span>
324
458
  </span>
325
- {:else}
326
- <Input
327
- id={inputId}
328
- type="text"
329
- value={inputValue}
330
- onfocus={onFocus}
331
- oninput={handleInput}
332
- onblur={handleBlur}
333
- onkeydown={handleKeyDown}
334
- readonly={isLocked}
335
- {disabled}
336
- class="number-controls-input h-full min-w-0 flex-1 border-0 bg-transparent px-0 text-body text-foreground shadow-none hover:bg-transparent focus-visible:ring-0 focus-visible:ring-offset-0 {customInputClass}"
337
- />
338
459
  {/if}
339
460
  </label>
340
461
 
@@ -343,6 +464,7 @@
343
464
  kind="minus"
344
465
  label={$t('editor.stepper.decrease')}
345
466
  disabled={isDisabled || isAtMin}
467
+ data-pressed={pressedStepper === 'decrement' ? 'true' : undefined}
346
468
  onmousedown={(e: MouseEvent) => startAutoRepeat('decrement', e)}
347
469
  onmouseup={stopAutoRepeat}
348
470
  onmouseleave={stopAutoRepeat}
@@ -352,6 +474,7 @@
352
474
  kind="plus"
353
475
  label={$t('editor.stepper.increase')}
354
476
  disabled={isDisabled || isAtMax}
477
+ data-pressed={pressedStepper === 'increment' ? 'true' : undefined}
355
478
  onmousedown={(e: MouseEvent) => startAutoRepeat('increment', e)}
356
479
  onmouseup={stopAutoRepeat}
357
480
  onmouseleave={stopAutoRepeat}
@@ -362,6 +485,11 @@
362
485
 
363
486
  <style>
364
487
  :global(.number-controls-input) {
488
+ flex: none;
489
+ width: 100%;
490
+ min-width: 0;
491
+ max-width: 100%;
492
+ font-variant-numeric: tabular-nums;
365
493
  text-align: start;
366
494
  appearance: textfield;
367
495
  -moz-appearance: textfield;
@@ -250,7 +250,10 @@
250
250
  >
251
251
  <!-- Grid lines -->
252
252
  <!-- Grid lines -->
253
- <div class="absolute inset-0 grid-background"></div>
253
+ <div
254
+ class="absolute inset-0 grid-background"
255
+ class:grid-background-emphasis={isHovering || isDragging}
256
+ ></div>
254
257
 
255
258
  <!-- Position indicator thumb -->
256
259
  <!-- svelte-ignore element_invalid_self_closing_tag -->
@@ -299,51 +302,57 @@
299
302
  outline: none !important;
300
303
  }
301
304
 
302
- /* Grid lines at x/y 46, 93, 139 px on the 185px pad (Figma IC Position). */
303
- /* Grid background using gradients */
305
+ /* Grid lines at x/y 46, 93, 139 px on the 185px pad (Figma IC Position). The colour of the lines is a variable: the pad
306
+ greys out when it is hovered or dragged, and the light green lines would vanish on that grey, so then they turn to a
307
+ darker grey (the strong border at 40%) that stays visible on it. */
304
308
  .grid-background {
309
+ --position-grid-line: var(--brand-subtle);
305
310
  background-image:
306
311
  linear-gradient(
307
312
  to right,
308
313
  transparent calc(46px - 0.01px),
309
- var(--brand-subtle) 46px,
310
- var(--brand-subtle) calc(46px + 1px),
314
+ var(--position-grid-line) 46px,
315
+ var(--position-grid-line) calc(46px + 1px),
311
316
  transparent calc(46px + 1px)
312
317
  ),
313
318
  linear-gradient(
314
319
  to right,
315
320
  transparent calc(93px - 0.01px),
316
- var(--brand-subtle) 93px,
317
- var(--brand-subtle) calc(93px + 1px),
321
+ var(--position-grid-line) 93px,
322
+ var(--position-grid-line) calc(93px + 1px),
318
323
  transparent calc(93px + 1px)
319
324
  ),
320
325
  linear-gradient(
321
326
  to right,
322
327
  transparent calc(139px - 0.01px),
323
- var(--brand-subtle) 139px,
324
- var(--brand-subtle) calc(139px + 1px),
328
+ var(--position-grid-line) 139px,
329
+ var(--position-grid-line) calc(139px + 1px),
325
330
  transparent calc(139px + 1px)
326
331
  ),
327
332
  linear-gradient(
328
333
  to bottom,
329
334
  transparent calc(46px - 0.01px),
330
- var(--brand-subtle) 46px,
331
- var(--brand-subtle) calc(46px + 1px),
335
+ var(--position-grid-line) 46px,
336
+ var(--position-grid-line) calc(46px + 1px),
332
337
  transparent calc(46px + 1px)
333
338
  ),
334
339
  linear-gradient(
335
340
  to bottom,
336
341
  transparent calc(93px - 0.01px),
337
- var(--brand-subtle) 93px,
338
- var(--brand-subtle) calc(93px + 1px),
342
+ var(--position-grid-line) 93px,
343
+ var(--position-grid-line) calc(93px + 1px),
339
344
  transparent calc(93px + 1px)
340
345
  ),
341
346
  linear-gradient(
342
347
  to bottom,
343
348
  transparent calc(139px - 0.01px),
344
- var(--brand-subtle) 139px,
345
- var(--brand-subtle) calc(139px + 1px),
349
+ var(--position-grid-line) 139px,
350
+ var(--position-grid-line) calc(139px + 1px),
346
351
  transparent calc(139px + 1px)
347
352
  );
348
353
  }
354
+
355
+ .grid-background-emphasis {
356
+ --position-grid-line: color-mix(in oklab, var(--border-strong) 40%, transparent);
357
+ }
349
358
  </style>
@@ -19,6 +19,7 @@
19
19
  * Shadcn UI radio group components for consistent styling and behavior
20
20
  */
21
21
  import { Label, RadioGroup } from '@widgetic/design-system/components';
22
+ import { shouldPreventOptionGroupBackgroundFocusSteal } from './optionGroupCardPointerDown';
22
23
 
23
24
  export let value: RadioGroupInputControllerProps['value'];
24
25
  export let onChange: RadioGroupInputControllerProps['onChange'];
@@ -46,6 +47,14 @@
46
47
  * Handles click on the entire row
47
48
  * @param optionValue - The value to select
48
49
  */
50
+
51
+ /** `mousedown` default moves focus to `body` on non-focusable targets; cancel only that (not pointerdown). */
52
+ function handleCardMouseDown(event: MouseEvent) {
53
+ if (shouldPreventOptionGroupBackgroundFocusSteal(event.target)) {
54
+ event.preventDefault();
55
+ }
56
+ }
57
+
49
58
  function handleRowClick(optionValue: string) {
50
59
  if (localValue !== optionValue) {
51
60
  handleValueChange(optionValue);
@@ -71,9 +80,11 @@
71
80
  </script>
72
81
 
73
82
  <div class="flex flex-col gap-1">
83
+ <!-- svelte-ignore a11y_no_static_element_interactions -->
74
84
  <div
75
85
  class="flex w-full flex-col gap-2 rounded-lg bg-accent px-3 py-4 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"
76
86
  onfocusin={onFocus}
87
+ onmousedowncapture={handleCardMouseDown}
77
88
  >
78
89
  <RadioGroup.Root
79
90
  value={localValue}