@widgetic/editor 4.1.16 → 4.1.18

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 (41) hide show
  1. package/dist/components/PreviewChromeControls.svelte +2 -2
  2. package/dist/components/WidgetPreview.svelte +2 -2
  3. package/dist/components/editors/EmbedEditor.svelte +2 -1
  4. package/dist/components/editors/PropsEditor.svelte +127 -28
  5. package/dist/components/ic/AngleInputController.svelte +10 -6
  6. package/dist/components/ic/BrowserInputController.svelte +25 -112
  7. package/dist/components/ic/ColorPickerInputController.svelte +120 -48
  8. package/dist/components/ic/DatePickerInputController.svelte +18 -10
  9. package/dist/components/ic/DropdownInputController.svelte +2 -12
  10. package/dist/components/ic/FixedPositionInputController.svelte +1 -1
  11. package/dist/components/ic/FontInputController.svelte +42 -55
  12. package/dist/components/ic/InputControllerHeader.svelte +1 -1
  13. package/dist/components/ic/KnowledgeDocumentsInputController.svelte +7 -7
  14. package/dist/components/ic/NumberControls.svelte +92 -43
  15. package/dist/components/ic/NumberControls.svelte.d.ts +5 -1
  16. package/dist/components/ic/PositionInputController.svelte +24 -15
  17. package/dist/components/ic/RangeCalendarInputController.svelte +38 -18
  18. package/dist/components/ic/RoundedCornersInputController.svelte +2 -2
  19. package/dist/components/ic/SliderInputController.svelte +11 -4
  20. package/dist/components/ic/TextAreaInputController.svelte +40 -27
  21. package/dist/components/ic/TextAreaPreviewInputController.svelte +9 -8
  22. package/dist/components/ic/TextInputController.svelte +15 -2
  23. package/dist/components/ic/TimeInputController.svelte +1 -1
  24. package/dist/components/ic/VectorInputController.svelte +155 -27
  25. package/dist/components/ic/numberControlsSteps.d.ts +17 -0
  26. package/dist/components/ic/numberControlsSteps.js +23 -0
  27. package/dist/components/ic/shared/DropdownChevron.svelte +23 -0
  28. package/dist/components/ic/shared/DropdownChevron.svelte.d.ts +9 -0
  29. package/dist/components/ic/shared/EditorFileBrowserOverlay.svelte +132 -0
  30. package/dist/components/ic/shared/EditorFileBrowserOverlay.svelte.d.ts +27 -0
  31. package/dist/components/ic/shared/ItemGrid.svelte +2 -2
  32. package/dist/components/ic/shared/RecentItemsSection.svelte +6 -6
  33. package/dist/components/ic/shared/editableFieldClasses.d.ts +15 -0
  34. package/dist/components/ic/shared/editableFieldClasses.js +15 -0
  35. package/dist/components/ic/shared/index.d.ts +1 -0
  36. package/dist/components/ic/shared/index.js +1 -0
  37. package/dist/components/ui/calendar-editor-fit/EditorCalendarStyles.svelte +41 -9
  38. package/dist/i18n/language.d.ts +260 -2
  39. package/dist/utils/angleMath.d.ts +2 -0
  40. package/dist/utils/angleMath.js +6 -0
  41. package/package.json +4 -4
@@ -206,7 +206,7 @@
206
206
  <p class="text-body text-muted-foreground">{$t('editor.knowledge.unavailable')}</p>
207
207
  {:else if $panel.phase === 'loading'}
208
208
  <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" />
209
+ <IconLoader2 class="size-4 shrink-0 animate-spin stroke-2" aria-hidden="true" />
210
210
  <span>{$t('editor.knowledge.loading')}</span>
211
211
  </p>
212
212
  {:else if $panel.phase === 'failed'}
@@ -215,7 +215,7 @@
215
215
  role="alert"
216
216
  >
217
217
  <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" />
218
+ <IconAlertTriangle class="mt-0.5 size-4 shrink-0 stroke-2" aria-hidden="true" />
219
219
  <span
220
220
  >{$panel.loadFailure
221
221
  ? sentenceOf($panel.loadFailure)
@@ -236,7 +236,7 @@
236
236
  class="flex min-h-12 items-center gap-3 rounded-xl border border-border bg-accent py-2 ps-4 pe-2"
237
237
  >
238
238
  <IconFileText
239
- class="size-4 shrink-0 stroke-[1.333] text-muted-foreground"
239
+ class="size-4 shrink-0 stroke-2 text-muted-foreground"
240
240
  aria-hidden="true"
241
241
  />
242
242
  <div class="min-w-0 flex-1">
@@ -283,7 +283,7 @@
283
283
  disabled={isBusy}
284
284
  onclick={() => panel.askToRemove(document.id)}
285
285
  >
286
- <IconTrash class="size-4 stroke-[1.333]" aria-hidden="true" />
286
+ <IconTrash class="size-4 stroke-2" aria-hidden="true" />
287
287
  </IconButton>
288
288
  {/if}
289
289
  </li>
@@ -293,7 +293,7 @@
293
293
 
294
294
  {#if $panel.sending}
295
295
  <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" />
296
+ <IconLoader2 class="size-4 shrink-0 animate-spin stroke-2" aria-hidden="true" />
297
297
  <span class="truncate" dir={dirForUserText($textDirection)}>
298
298
  {#if $panel.sending.count > 1}
299
299
  {$t('editor.knowledge.sendingOf', {
@@ -317,7 +317,7 @@
317
317
  >
318
318
  {#each $panel.notices as notice (notice.id)}
319
319
  <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" />
320
+ <IconAlertTriangle class="mt-0.5 size-4 shrink-0 stroke-2" aria-hidden="true" />
321
321
  <span>{sentenceOf(notice.message)}</span>
322
322
  </p>
323
323
  {/each}
@@ -340,7 +340,7 @@
340
340
  onclick={openFileChooser}
341
341
  >
342
342
  <IconPlus
343
- class="size-4 shrink-0 stroke-[1.333] text-muted-foreground"
343
+ class="size-4 shrink-0 stroke-2 text-muted-foreground"
344
344
  aria-hidden="true"
345
345
  />
346
346
  <span class="text-body-medium truncate text-foreground group-hover:underline">
@@ -2,6 +2,7 @@
2
2
  import { onDestroy } from 'svelte';
3
3
  import { Input, StepperButton } from '@widgetic/design-system/components';
4
4
  import { useEditorLanguage } from '../../i18n/language';
5
+ import { steppedNumber } from './numberControlsSteps';
5
6
 
6
7
  const { t } = useEditorLanguage();
7
8
 
@@ -19,14 +20,20 @@
19
20
  let className = '';
20
21
  export { className as class };
21
22
  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';
23
+ /**
24
+ * Padding at the end of the accent surface, after the steppers (Figma IC Number vs IC Angle field).
25
+ * The padding at the start is not on the surface: it is inside the text hit area, so the hit area reaches the edge.
26
+ */
27
+ export let surfacePaddingClass: string = 'pe-1';
28
+ /** Padding at the start of the text hit area: it keeps the value 12px in from the edge (Figma IC Number: the value is at x=12). */
29
+ export let inputPaddingClass: string = 'ps-3';
24
30
  /** @deprecated use `class` — kept for Angle layout width. */
25
31
  export let width: string | undefined = undefined;
26
32
 
27
33
  let inputValue = String(value);
28
34
  let isEditing = false;
29
35
  let isPressed = false;
36
+ let pressedStepper: 'increment' | 'decrement' | null = null;
30
37
 
31
38
  let autoRepeatTimer: ReturnType<typeof setTimeout> | null = null;
32
39
  let autoRepeatInterval: ReturnType<typeof setInterval> | null = null;
@@ -34,14 +41,14 @@
34
41
  const HOLD_DELAY = 400;
35
42
  const REPEAT_INTERVAL = 80;
36
43
 
37
- // Add unique ID generation
44
+ // Add unique ID generation
38
45
  const inputId = `number-input-${Math.random().toString(36).substr(2, 9)}`;
39
46
 
40
47
  $: isAtMin = !wrapAround && value <= min;
41
48
  $: isAtMax = !wrapAround && value >= max;
42
49
  $: isDisabled = disabled || isLocked;
43
50
 
44
- // Update inputValue when value prop changes and we're not editing
51
+ // Update inputValue when value prop changes and we're not editing
45
52
  $: if (!isEditing) {
46
53
  inputValue = String(value);
47
54
  }
@@ -49,26 +56,30 @@
49
56
  const surfaceBaseClass =
50
57
  '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
58
 
52
- function handleValueChange(adjustment: number) {
59
+ /**
60
+ * One step of the stepper (button, hold or arrow key). Returns false when nothing was applied because the value is at a limit.
61
+ */
62
+ function handleValueChange(adjustment: number): boolean {
53
63
  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
- }
64
+ const newValue = steppedNumber(value, adjustment, { min, max, wrapAround });
65
+
66
+ // At a limit there is nothing to apply, and nothing to repeat: no event for the page, and a held button stops here
67
+ if (newValue === value) {
68
+ stopAutoRepeat();
69
+ return false;
66
70
  }
67
71
 
68
72
  value = newValue;
73
+ // The field shows the new number at once, also when the person has typed in it. It used to keep the typed text
74
+ // (`isEditing` stays true while the field has the focus, and a stepper button does not take the focus) and
75
+ // `handleBlur` then wrote that old text back over the number the stepper had set.
76
+ inputValue = String(newValue);
77
+ isEditing = false;
69
78
  onChange(newValue);
79
+ return true;
70
80
  } catch (error) {
71
81
  console.error('Error in handleValueChange:', error);
82
+ return false;
72
83
  }
73
84
  }
74
85
 
@@ -81,7 +92,7 @@
81
92
  return;
82
93
  }
83
94
 
84
- // Handle special cases
95
+ // Handle special cases
85
96
  if (inputValue === '-0') {
86
97
  inputValue = '0';
87
98
  input.value = '0';
@@ -90,31 +101,31 @@
90
101
  return;
91
102
  }
92
103
 
93
- // If starts with 0 and has more digits, remove the leading 0
104
+ // If starts with 0 and has more digits, remove the leading 0
94
105
  if (inputValue.startsWith('0') && inputValue.length > 1 && !inputValue.startsWith('-')) {
95
106
  inputValue = inputValue.substring(1);
96
107
  input.value = inputValue;
97
108
  }
98
109
 
99
- // Don't allow minus sign if:
100
- // 1. min >= 0
101
- // 2. there's already a minus sign
102
- // 3. there are numbers before it
110
+ // Don't allow minus sign if:
111
+ // 1. min >= 0
112
+ // 2. there's already a minus sign
113
+ // 3. there are numbers before it
103
114
  if (inputValue.includes('-')) {
104
115
  if (min >= 0 || inputValue.indexOf('-') > 0 || inputValue.split('-').length > 2) {
105
- // Remove all minus signs or keep only the first one if allowed
116
+ // Remove all minus signs or keep only the first one if allowed
106
117
  inputValue = min >= 0 ? inputValue.replace(/-/g, '') : '-' + inputValue.replace(/-/g, '');
107
118
  input.value = inputValue;
108
119
  }
109
120
  }
110
121
 
111
- // Update regex to prevent minus sign if min >= 0
112
- // Only allow minus at the start of the string
122
+ // Update regex to prevent minus sign if min >= 0
123
+ // Only allow minus at the start of the string
113
124
  const validNumberRegex = min >= 0 ? /^\d*$/ : /^-?\d*$/;
114
125
  if (!validNumberRegex.test(inputValue)) {
115
- // Remove any invalid characters
126
+ // Remove any invalid characters
116
127
  input.value = inputValue.replace(min >= 0 ? /[^\d]/g : /[^\d-]/g, '');
117
- // If there's a minus, ensure it's at the start
128
+ // If there's a minus, ensure it's at the start
118
129
  if (input.value.includes('-') && input.value.indexOf('-') > 0) {
119
130
  input.value = input.value.replace(/-/g, '');
120
131
  }
@@ -126,7 +137,7 @@
126
137
  if (!isNaN(numValue)) {
127
138
  isEditing = true;
128
139
 
129
- // Validate both min and max during typing
140
+ // Validate both min and max during typing
130
141
  if (wrapAround && max === 360) {
131
142
  if (numValue >= 360) {
132
143
  inputValue = '359';
@@ -149,7 +160,7 @@
149
160
  }
150
161
  }
151
162
 
152
- // Value is within range
163
+ // Value is within range
153
164
  value = numValue;
154
165
  onChange(numValue);
155
166
  }
@@ -166,7 +177,7 @@
166
177
  return;
167
178
  }
168
179
 
169
- // Apply validation on blur
180
+ // Apply validation on blur
170
181
  let validatedValue = finalValue;
171
182
  if (!wrapAround) {
172
183
  if (finalValue < min) validatedValue = min;
@@ -181,12 +192,22 @@
181
192
  }
182
193
 
183
194
  function startAutoRepeat(operation: 'increment' | 'decrement', event: MouseEvent) {
184
- event.preventDefault();
195
+ // Only the main button steps: a right or middle click must not
196
+ if (event.button !== 0) return;
197
+ // Do not preventDefault on mousedown: it suppresses the button :active state and breaks press-feedback scale.
185
198
  stopAutoRepeat();
186
199
 
187
200
  const adjustment = operation === 'increment' ? step : -step;
188
201
  isPressed = true;
189
- handleValueChange(adjustment);
202
+ pressedStepper = operation === 'increment' ? 'increment' : 'decrement';
203
+
204
+ // The button turns disabled when the value reaches a limit, and a disabled button gets no mouseup and no mouseleave:
205
+ // the release is watched on the window too, or the repeat would go on firing `onChange` at the limit until the next press.
206
+ window.addEventListener('mouseup', releasePress);
207
+ window.addEventListener('blur', releasePress);
208
+
209
+ // At a limit there is nothing to hold
210
+ if (!handleValueChange(adjustment)) return;
190
211
 
191
212
  autoRepeatTimer = setTimeout(() => {
192
213
  if (isPressed) {
@@ -199,12 +220,28 @@
199
220
  }, HOLD_DELAY);
200
221
  }
201
222
 
223
+ /** The release of a press, seen on the window (see `startAutoRepeat`). */
224
+ function releasePress() {
225
+ stopAutoRepeat();
226
+ }
227
+
228
+ /** A stepper button pressed with the keyboard (Enter or Space) clicks without a mouse down: `detail` is 0 then. */
229
+ function handleStepperClick(operation: 'increment' | 'decrement', event: MouseEvent) {
230
+ if (event.detail !== 0) return;
231
+ handleValueChange(operation === 'increment' ? step : -step);
232
+ }
233
+
202
234
  function stopAutoRepeat(event?: MouseEvent | FocusEvent) {
235
+ // Do not preventDefault on mouseup: it can shorten :active and weaken press-feedback on the steppers.
203
236
  if (event) {
204
- event.preventDefault();
205
237
  event.stopPropagation();
206
238
  }
207
239
 
240
+ if (typeof window !== 'undefined') {
241
+ window.removeEventListener('mouseup', releasePress);
242
+ window.removeEventListener('blur', releasePress);
243
+ }
244
+
208
245
  if (autoRepeatTimer !== null) {
209
246
  clearTimeout(autoRepeatTimer);
210
247
  autoRepeatTimer = null;
@@ -215,6 +252,7 @@
215
252
  }
216
253
 
217
254
  isPressed = false;
255
+ pressedStepper = null;
218
256
  }
219
257
 
220
258
  function handleKeyDown(e: KeyboardEvent) {
@@ -258,13 +296,20 @@
258
296
  class:opacity-50={disabled}
259
297
  class:pointer-events-none={disabled}
260
298
  >
261
- <div
262
- class="flex min-w-0 flex-1 items-center {suffix
263
- ? 'justify-start gap-0'
264
- : ''}"
299
+ <!--
300
+ The hit area of the text: from the start edge of the surface to the steppers, with the surface's own rounded corner at
301
+ the start edge, so the whole area reads as one field. A label focuses the input when the area is clicked, so nothing in
302
+ it is dead space (the padding that keeps the value 12px in used to sit on the surface, outside the input, and the input
303
+ drew its own square hover box inside the rounded surface, which looked cut out).
304
+ -->
305
+ <label
306
+ for={inputId}
307
+ class="number-controls-hit-area flex h-full min-w-0 flex-1 items-center rounded-s-lg {inputPaddingClass} {isDisabled
308
+ ? 'cursor-default'
309
+ : 'cursor-text'} {suffix ? 'justify-start gap-0' : ''}"
265
310
  >
266
311
  {#if suffix}
267
- <div class="number-controls-value inline-flex max-w-full min-w-0 items-baseline gap-0">
312
+ <span class="number-controls-value inline-flex max-w-full min-w-0 items-baseline gap-0">
268
313
  <Input
269
314
  id={inputId}
270
315
  type="text"
@@ -276,10 +321,10 @@
276
321
  readonly={isLocked}
277
322
  {disabled}
278
323
  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}"
324
+ 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}"
280
325
  />
281
326
  <span class="pointer-events-none shrink-0 text-body text-foreground">{suffix}</span>
282
- </div>
327
+ </span>
283
328
  {:else}
284
329
  <Input
285
330
  id={inputId}
@@ -291,27 +336,31 @@
291
336
  onkeydown={handleKeyDown}
292
337
  readonly={isLocked}
293
338
  {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}"
339
+ 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}"
295
340
  />
296
341
  {/if}
297
- </div>
342
+ </label>
298
343
 
299
344
  <div class="flex shrink-0 items-center gap-0">
300
345
  <StepperButton
301
346
  kind="minus"
302
347
  label={$t('editor.stepper.decrease')}
303
348
  disabled={isDisabled || isAtMin}
349
+ data-pressed={pressedStepper === 'decrement' ? 'true' : undefined}
304
350
  onmousedown={(e: MouseEvent) => startAutoRepeat('decrement', e)}
305
351
  onmouseup={stopAutoRepeat}
306
352
  onmouseleave={stopAutoRepeat}
353
+ onclick={(e: MouseEvent) => handleStepperClick('decrement', e)}
307
354
  />
308
355
  <StepperButton
309
356
  kind="plus"
310
357
  label={$t('editor.stepper.increase')}
311
358
  disabled={isDisabled || isAtMax}
359
+ data-pressed={pressedStepper === 'increment' ? 'true' : undefined}
312
360
  onmousedown={(e: MouseEvent) => startAutoRepeat('increment', e)}
313
361
  onmouseup={stopAutoRepeat}
314
362
  onmouseleave={stopAutoRepeat}
363
+ onclick={(e: MouseEvent) => handleStepperClick('increment', e)}
315
364
  />
316
365
  </div>
317
366
  </div>
@@ -24,7 +24,11 @@ declare const NumberControls: $$__sveltets_2_IsomorphicComponent<{
24
24
  suffix?: string;
25
25
  /** Extra classes on the outer control surface (default full width of the control column). */ class?: string;
26
26
  disabled?: boolean;
27
- /** Padding on the accent surface (Figma IC Number vs IC Angle field). */ surfacePaddingClass?: string;
27
+ /**
28
+ * Padding at the end of the accent surface, after the steppers (Figma IC Number vs IC Angle field).
29
+ * The padding at the start is not on the surface: it is inside the text hit area, so the hit area reaches the edge.
30
+ */ surfacePaddingClass?: string;
31
+ /** Padding at the start of the text hit area: it keeps the value 12px in from the edge (Figma IC Number: the value is at x=12). */ inputPaddingClass?: string;
28
32
  /** @deprecated use `class` — kept for Angle layout width. */ width?: string | undefined;
29
33
  }, {
30
34
  [evt: string]: CustomEvent<any>;
@@ -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>
@@ -81,6 +81,15 @@
81
81
  * Handles date range conversion and validation
82
82
  * Preserves timezone information during conversion
83
83
  */
84
+ function toCalendarDatePart(raw: unknown): CalendarDate | undefined {
85
+ if (raw instanceof CalendarDate) return raw;
86
+ if (typeof raw === 'object' && raw !== null && 'year' in raw && 'month' in raw && 'day' in raw) {
87
+ const part = raw as { year: number; month: number; day: number };
88
+ return new CalendarDate(part.year, part.month, part.day);
89
+ }
90
+ return undefined;
91
+ }
92
+
84
93
  function updateCurrentValue() {
85
94
  if (!value) {
86
95
  currentValue = undefined;
@@ -88,29 +97,33 @@
88
97
  }
89
98
 
90
99
  try {
91
- const newRange: DateRange = {};
92
- if (value.start && typeof value.start === 'object' && 'year' in value.start) {
93
- const start = value.start;
94
- newRange.start =
95
- start instanceof CalendarDate
96
- ? start
97
- : new CalendarDate(start.year, start.month, start.day);
98
- }
99
- if (value.end && typeof value.end === 'object' && 'year' in value.end) {
100
- const end = value.end;
101
- newRange.end =
102
- end instanceof CalendarDate ? end : new CalendarDate(end.year, end.month, end.day);
103
- }
104
- currentValue = newRange.start || newRange.end ? newRange : undefined;
100
+ const start = toCalendarDatePart(value.start);
101
+ const end = toCalendarDatePart(value.end);
102
+ currentValue = start || end ? { start, end } : undefined;
105
103
  } catch (error) {
106
104
  console.error('Error updating range value:', error);
107
105
  currentValue = undefined;
108
106
  }
109
107
  }
110
108
 
111
- // Watch for value changes and update internal state
109
+ // Watch for value changes and update internal state.
110
+ // It stays above `rangeCalendarValue` and `rangeCalendarPlaceholder`: `currentValue` is assigned inside
111
+ // `updateCurrentValue()`, which the compiler cannot see, so a statement written before this one would read the empty
112
+ // range of the first run and never run again (the calendar would open on today, with no range painted).
112
113
  $: (value, updateCurrentValue());
113
114
 
115
+ $: rangeCalendarValue =
116
+ currentValue?.start instanceof CalendarDate && currentValue?.end instanceof CalendarDate
117
+ ? { start: currentValue.start, end: currentValue.end }
118
+ : undefined;
119
+
120
+ $: rangeCalendarPlaceholder =
121
+ currentValue?.start instanceof CalendarDate
122
+ ? currentValue.start
123
+ : currentValue?.end instanceof CalendarDate
124
+ ? currentValue.end
125
+ : undefined;
126
+
114
127
  // Track dropdown state through store subscription
115
128
  $: open = $openDropdowns?.has(controllerId) || false;
116
129
 
@@ -174,6 +187,12 @@
174
187
  toggleDropdown(controllerId);
175
188
  }
176
189
 
190
+ function handleOpenChange(isOpen: boolean) {
191
+ if (isOpen !== open) {
192
+ toggleDropdown(controllerId);
193
+ }
194
+ }
195
+
177
196
  /**
178
197
  * Closes dropdown if currently open
179
198
  * Used for cleanup and external close triggers
@@ -213,7 +232,7 @@
213
232
  <!-- Range Calendar Container (Figma IC Date Range 172:504) -->
214
233
  <div bind:this={controllerElement} class="range-calendar-input-controller">
215
234
  <InputControllerRow {label} {helpText}>
216
- <Popover.Root {open} onOpenChange={handleToggle}>
235
+ <Popover.Root {open} onOpenChange={handleOpenChange}>
217
236
  <Popover.Trigger
218
237
  id="range-calendar"
219
238
  class="range-calendar-trigger group flex h-9 w-full items-center gap-2 rounded-lg bg-accent px-3 transition-colors duration-fast hover:bg-accent-hover focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background"
@@ -227,7 +246,7 @@
227
246
  {formatDateRange(currentValue, $locale, $t)}
228
247
  </span>
229
248
  <IconCalendar
230
- class="size-4 shrink-0 stroke-[1.333] text-muted-foreground transition-colors duration-fast group-hover:text-foreground"
249
+ class="size-4 shrink-0 stroke-2 text-muted-foreground transition-colors duration-fast group-hover:text-foreground"
231
250
  aria-hidden="true"
232
251
  />
233
252
  </Popover.Trigger>
@@ -239,7 +258,8 @@
239
258
  >
240
259
  <!-- Style the range calendar -->
241
260
  <RangeCalendar
242
- value={currentValue}
261
+ value={rangeCalendarValue}
262
+ placeholder={rangeCalendarPlaceholder}
243
263
  locale={$locale}
244
264
  calendarLabel={$t('editor.date.rangeCalendarLabel')}
245
265
  previousLabel={$t('editor.date.previousMonth')}
@@ -416,9 +416,9 @@
416
416
  aria-pressed={isLocked}
417
417
  >
418
418
  {#if isLocked}
419
- <IconLock class="size-4 stroke-[1.333]" aria-hidden="true" />
419
+ <IconLock class="size-4 stroke-2" aria-hidden="true" />
420
420
  {:else}
421
- <IconLockOpen class="size-4 stroke-[1.333]" aria-hidden="true" />
421
+ <IconLockOpen class="size-4 stroke-2" aria-hidden="true" />
422
422
  {/if}
423
423
  </button>
424
424
  </div>
@@ -75,6 +75,8 @@
75
75
 
76
76
  let sliderContainer: HTMLDivElement;
77
77
  let lastValue = value;
78
+ /** Keeps the readout in sync while dragging before the parent value prop updates. */
79
+ let liveValue: number | number[] = value;
78
80
  let isCurrentlyFocused = false;
79
81
  let isClickHandled = false;
80
82
 
@@ -140,6 +142,7 @@
140
142
  * @param newValue - New slider value(s)
141
143
  */
142
144
  function handleChange(newValue: number | number[]) {
145
+ liveValue = newValue;
143
146
  if (newValue !== lastValue && !isCurrentlyFocused) {
144
147
  handleFocus();
145
148
  isCurrentlyFocused = true;
@@ -235,13 +238,17 @@
235
238
  }
236
239
  }
237
240
 
241
+ $: if (value !== undefined) {
242
+ liveValue = value;
243
+ }
244
+
238
245
  $: sliderValue =
239
246
  sliderType === 'single'
240
- ? typeof value === 'number'
241
- ? value
247
+ ? typeof liveValue === 'number'
248
+ ? liveValue
242
249
  : min
243
- : Array.isArray(value)
244
- ? value
250
+ : Array.isArray(liveValue)
251
+ ? liveValue
245
252
  : [min, max];
246
253
 
247
254
  // Helper function to safely get array value