@widgetic/editor 4.1.23 → 4.1.24

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.
@@ -616,32 +616,61 @@
616
616
  * - Prevents event bubbling
617
617
  * @param event - Mouse event
618
618
  */
619
- function handleOpacityMouseDown(event: MouseEvent) {
619
+ function sliderRelativeX(event: PointerEvent, slider: HTMLElement): number {
620
+ if (event.target === slider && typeof event.offsetX === 'number') {
621
+ return event.offsetX;
622
+ }
623
+ const rect = slider.getBoundingClientRect();
624
+ const viewportX = event.clientX - rect.left;
625
+ if (viewportX >= -1 && viewportX <= rect.width + 1) return viewportX;
626
+ const rootNode = slider.getRootNode();
627
+ if (rootNode instanceof ShadowRoot && rootNode.host) {
628
+ const hostRect = rootNode.host.getBoundingClientRect();
629
+ return event.clientX - hostRect.left - rect.left;
630
+ }
631
+ return viewportX;
632
+ }
633
+
634
+ function handleOpacityPointerDown(event: PointerEvent) {
635
+ const slider = event.currentTarget as HTMLDivElement | null;
636
+ if (!slider) return;
637
+ event.preventDefault();
638
+ event.stopPropagation();
620
639
  isDragging = true;
621
- // The cursor is shown on the host of the shadow root the picker is in, and on <body> only on a normal page: the
622
- // <body> of a customer's page is not the editor's to change.
640
+ opacitySliderRef = slider;
641
+ try {
642
+ slider.setPointerCapture(event.pointerId);
643
+ } catch (error) {
644
+ console.warn('[ColorPicker] Could not capture the opacity pointer:', error);
645
+ }
623
646
  releaseOpacityPointerStyle?.();
624
- releaseOpacityPointerStyle = lockPointerStyle(event.currentTarget ?? event.target, 'grabbing', {
647
+ releaseOpacityPointerStyle = lockPointerStyle(slider, 'grabbing', {
625
648
  blockTextSelection: false
626
649
  });
627
- updateOpacity(event);
650
+ updateOpacityFromSlider(slider, event);
628
651
 
629
- const handleMouseMove = (e: MouseEvent) => {
630
- if (isDragging) {
631
- updateOpacity(e);
632
- }
652
+ const handlePointerMove = (moveEvent: PointerEvent) => {
653
+ if (isDragging) updateOpacityFromSlider(slider, moveEvent);
633
654
  };
634
-
635
- const handleMouseUp = () => {
655
+ const handlePointerUp = () => {
636
656
  isDragging = false;
637
657
  releaseOpacityPointerStyle?.();
638
658
  releaseOpacityPointerStyle = null;
639
- window.removeEventListener('mousemove', handleMouseMove);
640
- window.removeEventListener('mouseup', handleMouseUp);
659
+ slider.removeEventListener('pointermove', handlePointerMove);
660
+ slider.removeEventListener('pointerup', handlePointerUp);
661
+ slider.removeEventListener('pointercancel', handlePointerUp);
662
+ try {
663
+ if (slider.hasPointerCapture(event.pointerId)) {
664
+ slider.releasePointerCapture(event.pointerId);
665
+ }
666
+ } catch {
667
+ /* capture already released */
668
+ }
641
669
  };
642
670
 
643
- window.addEventListener('mousemove', handleMouseMove);
644
- window.addEventListener('mouseup', handleMouseUp);
671
+ slider.addEventListener('pointermove', handlePointerMove);
672
+ slider.addEventListener('pointerup', handlePointerUp);
673
+ slider.addEventListener('pointercancel', handlePointerUp);
645
674
  }
646
675
 
647
676
  // Reactive statement to handle external value changes
@@ -694,33 +723,21 @@
694
723
  * - Handles edge cases
695
724
  * @param event - Mouse event from slider interaction
696
725
  */
697
- function updateOpacity(event: MouseEvent) {
698
- if (!opacitySliderRef) return;
699
-
700
- const rect = opacitySliderRef.getBoundingClientRect();
701
- const x = event.clientX - rect.left;
702
- const width = rect.width;
726
+ function updateOpacityFromSlider(slider: HTMLElement, event: PointerEvent) {
727
+ const width = slider.clientWidth || slider.getBoundingClientRect().width;
728
+ if (!width) return;
703
729
 
730
+ const x = sliderRelativeX(event, slider);
704
731
  let newOpacity = Math.max(0, Math.min(x, width)) / width;
705
732
  newOpacity = Math.round(newOpacity * 100) / 100;
706
733
 
707
734
  try {
708
735
  isInternalUpdate = true;
709
- opacity = newOpacity; // This will trigger the reactive statement
736
+ opacity = newOpacity;
710
737
  rgb = { ...rgb, a: newOpacity };
711
738
  lastKnownOpacity = newOpacity;
712
- const hexValue = `#${Math.round(rgb.r * 255)
713
- .toString(16)
714
- .padStart(2, '0')}${Math.round(rgb.g * 255)
715
- .toString(16)
716
- .padStart(2, '0')}${Math.round(rgb.b * 255)
717
- .toString(16)
718
- .padStart(2, '0')}`;
719
- value = hexValue;
720
- hexInput = hexValue;
721
739
  previewColor = getRgbaColor();
722
- onChange(hexValue);
723
- onOpacityChange(newOpacity); // Call the opacity change handler
740
+ onOpacityChange(newOpacity);
724
741
  } finally {
725
742
  isInternalUpdate = false;
726
743
  }
@@ -1042,14 +1059,19 @@
1042
1059
 
1043
1060
  function handlePointerDownOutside(event: MouseEvent) {
1044
1061
  if (!open) return;
1045
- const target = event.target;
1046
- if (!(target instanceof Element)) return;
1047
- if (
1048
- target.closest('.color-picker-popover-content') ||
1049
- target.closest('.color-preview-button') ||
1050
- target.closest('.color-input-main-container')
1051
- ) {
1052
- return;
1062
+ const path = typeof event.composedPath === 'function' ? event.composedPath() : [event.target];
1063
+ for (const node of path) {
1064
+ if (!(node instanceof Element)) continue;
1065
+ if (
1066
+ node === popoverContentRef ||
1067
+ node === triggerRef ||
1068
+ node === inputRef ||
1069
+ node.closest?.('.color-picker-popover-content') ||
1070
+ node.closest?.('.color-preview-button') ||
1071
+ node.closest?.('.color-input-main-container')
1072
+ ) {
1073
+ return;
1074
+ }
1053
1075
  }
1054
1076
  handleToggle(false);
1055
1077
  }
@@ -1293,15 +1315,24 @@
1293
1315
  const spaceBelow = window.innerHeight - swatchRect.bottom;
1294
1316
  const spaceAbove = swatchRect.top;
1295
1317
  const openAbove = spaceBelow < popoverHeight + popoverGapPx && spaceAbove > spaceBelow;
1296
- const top = openAbove
1318
+ const viewportTop = openAbove
1297
1319
  ? Math.round(swatchRect.top - popoverHeight - popoverGapPx)
1298
1320
  : Math.round(swatchRect.bottom + popoverGapPx);
1299
1321
  // Anchor horizontally to the swatch: centered when it fits, clamped inside the viewport otherwise.
1300
- let left = Math.round(swatchRect.left + swatchRect.width / 2 - popoverWidthPx / 2);
1322
+ let viewportLeft = Math.round(swatchRect.left + swatchRect.width / 2 - popoverWidthPx / 2);
1301
1323
  const horizontalMargin = 8;
1302
1324
  const maxLeft = window.innerWidth - popoverWidthPx - horizontalMargin;
1303
- left = Math.max(horizontalMargin, Math.min(left, maxLeft));
1304
- popoverStyle = `top: ${top}px; left: ${left}px;`; /* rtl-ok: viewport coords from getBoundingClientRect; popover is dir=ltr */
1325
+ viewportLeft = Math.max(horizontalMargin, Math.min(viewportLeft, maxLeft));
1326
+ // Inside a ShadowRoot with `contain: layout` on `:host`, `position: fixed` is relative to the host box
1327
+ // rather than the viewport, so convert viewport coordinates into host-relative coordinates.
1328
+ const rootNode = (popoverContentRef ?? triggerRef).getRootNode?.();
1329
+ const hostRect =
1330
+ rootNode && typeof ShadowRoot !== 'undefined' && rootNode instanceof ShadowRoot
1331
+ ? rootNode.host.getBoundingClientRect()
1332
+ : { left: 0, top: 0 };
1333
+ const top = Math.round(viewportTop - hostRect.top);
1334
+ const left = Math.round(viewportLeft - hostRect.left);
1335
+ popoverStyle = `top: ${top}px; left: ${left}px;`; /* rtl-ok: viewport coords from getBoundingClientRect adjusted for ShadowRoot host; popover is dir=ltr */
1305
1336
  }
1306
1337
 
1307
1338
  // Position is calculated in handleToggle after tick()
@@ -1594,13 +1625,13 @@
1594
1625
  <div
1595
1626
  bind:this={opacitySliderRef}
1596
1627
  class="opacity-slider relative h-6 cursor-pointer overflow-visible rounded-lg"
1597
- style="width: {opacityBarContentWidth}px;"
1598
- onmousedown={handleOpacityMouseDown}
1628
+ style="width: {opacityBarContentWidth}px; touch-action: none;"
1629
+ onpointerdown={handleOpacityPointerDown}
1599
1630
  >
1600
- <div class="absolute inset-0 overflow-hidden rounded-[inherit]">
1631
+ <div class="pointer-events-none absolute inset-0 overflow-hidden rounded-[inherit]">
1601
1632
  <CheckerBoardBackground className="rounded-[inherit]" />
1602
1633
  <div
1603
- class="absolute inset-0"
1634
+ class="pointer-events-none absolute inset-0"
1604
1635
  style="background: linear-gradient(to right,
1605
1636
  rgba({Math.round(rgb.r * 255)}, {Math.round(
1606
1637
  rgb.g * 255
@@ -1672,6 +1703,7 @@
1672
1703
  .opacity-slider {
1673
1704
  cursor: grab !important;
1674
1705
  user-select: none !important;
1706
+ touch-action: none;
1675
1707
  }
1676
1708
 
1677
1709
  :global(.color-picker-wrapper canvas:active),
@@ -25,7 +25,8 @@
25
25
  export interface DatePickerInputControllerProps {
26
26
  label: string;
27
27
  value?: any;
28
- onChange: (newValue: CalendarDate) => void;
28
+ /** Widgets and compositions store the day as `YYYY-MM-DD`. */
29
+ onChange: (newValue: string) => void;
29
30
  description?: string;
30
31
  controllerId: string;
31
32
  openDropdowns: Writable<Set<string>>;
@@ -37,7 +38,7 @@
37
38
  <script lang="ts">
38
39
  // Svelte imports
39
40
  import { onMount, onDestroy } from 'svelte';
40
- import { listenForScroll } from '../../utils/shadowDom';
41
+ import { acquirePortalHost, isEventInside, listenForScroll, releasePortalHost } from '../../utils/shadowDom';
41
42
  import { useEditorLanguage } from '../../i18n/language';
42
43
  import type { EditorMessageKey } from '../../i18n/messages';
43
44
  import type { Translate } from '@widgetic/design-system/i18n';
@@ -52,7 +53,13 @@
52
53
  import { Calendar } from '@widgetic/design-system/components';
53
54
 
54
55
  // Internationalized date imports
55
- import { CalendarDate, getLocalTimeZone, today, DateFormatter } from '@internationalized/date';
56
+ import {
57
+ CalendarDate,
58
+ DateFormatter,
59
+ getLocalTimeZone,
60
+ parseDate,
61
+ today
62
+ } from '@internationalized/date';
56
63
  import type { DateValue } from '@internationalized/date';
57
64
 
58
65
  // Lucide Icons
@@ -86,10 +93,16 @@
86
93
  label: monthFmt.format(new Date(2021, monthIndex, 1))
87
94
  }));
88
95
 
89
- const yearOptions = Array.from({ length: 100 }, (_, i) => {
90
- const year = String(new Date().getFullYear() - i);
91
- return { label: year, value: year };
92
- });
96
+ const YEAR_PAST_COUNT = 80;
97
+ const YEAR_FUTURE_COUNT = 50;
98
+ const yearNow = new Date().getFullYear();
99
+ const calendarMinValue = new CalendarDate(yearNow - YEAR_PAST_COUNT, 1, 1);
100
+ const calendarMaxValue = new CalendarDate(yearNow + YEAR_FUTURE_COUNT, 12, 31);
101
+ const yearOptions = [
102
+ yearNow,
103
+ ...Array.from({ length: YEAR_FUTURE_COUNT }, (_, i) => yearNow + 1 + i),
104
+ ...Array.from({ length: YEAR_PAST_COUNT }, (_, i) => yearNow - 1 - i)
105
+ ].map((year) => ({ label: String(year), value: String(year) }));
93
106
 
94
107
  $: defaultYear = placeholder
95
108
  ? {
@@ -105,48 +118,67 @@
105
118
  }
106
119
  : undefined;
107
120
 
121
+ /**
122
+ * Reads a stored day into a CalendarDate this file constructed.
123
+ * Widgets keep `YYYY-MM-DD`; bits-ui may hand over a date from another copy of
124
+ * `@internationalized/date`, so `instanceof CalendarDate` is not enough.
125
+ */
126
+ function calendarDateFromUnknown(raw: unknown): CalendarDate | undefined {
127
+ if (raw == null || raw === '') return undefined;
128
+ try {
129
+ if (typeof raw === 'string') {
130
+ const isoDay = raw.match(/^(\d{4}-\d{2}-\d{2})/);
131
+ if (isoDay) return parseDate(isoDay[1]);
132
+ const asDate = new Date(raw);
133
+ if (!Number.isNaN(asDate.getTime())) {
134
+ return new CalendarDate(asDate.getFullYear(), asDate.getMonth() + 1, asDate.getDate());
135
+ }
136
+ return undefined;
137
+ }
138
+ if (raw instanceof Date && !Number.isNaN(raw.getTime())) {
139
+ return new CalendarDate(raw.getFullYear(), raw.getMonth() + 1, raw.getDate());
140
+ }
141
+ if (typeof raw === 'object') {
142
+ const record = raw as Record<string, unknown>;
143
+ if (typeof record.date === 'string') return calendarDateFromUnknown(record.date);
144
+ if ('year' in record && 'month' in record && 'day' in record) {
145
+ return new CalendarDate(Number(record.year), Number(record.month), Number(record.day));
146
+ }
147
+ }
148
+ } catch (error) {
149
+ console.warn('[DatePicker] Could not read date value:', raw, error);
150
+ }
151
+ return undefined;
152
+ }
153
+
154
+ function commitSelectedDate(date: CalendarDate) {
155
+ currentValue = date;
156
+ placeholder = date;
157
+ onChange(date.toString());
158
+ }
159
+
108
160
  /**
109
161
  * Updates the current value when the external value changes
110
162
  * Handles initialization and updates of the date state
111
163
  * Creates a new CalendarDate instance to prevent reference issues
112
164
  */
113
165
  function updateCurrentValue() {
114
- // console.log('🔄 [DatePicker] updateCurrentValue called with:', { value, type: typeof value });
115
-
116
166
  if (!value) {
117
167
  currentValue = undefined;
118
168
  placeholder = today(getLocalTimeZone());
119
- // console.log('✅ [DatePicker] Set to undefined, placeholder:', placeholder);
120
169
  return;
121
170
  }
122
171
 
123
- if (value instanceof CalendarDate) {
124
- currentValue = value;
125
- // console.log('✅ [DatePicker] Already CalendarDate:', currentValue);
126
- } else if (
127
- typeof value === 'object' &&
128
- value !== null &&
129
- 'year' in value &&
130
- 'month' in value &&
131
- 'day' in value
132
- ) {
133
- try {
134
- currentValue = new CalendarDate(value.year, value.month, value.day);
135
- // console.log('✅ [DatePicker] Created CalendarDate from object:', { original: value, created: currentValue });
136
- } catch (error) {
137
- console.error('❌ [DatePicker] Failed to create CalendarDate from object:', {
138
- value,
139
- error
140
- });
141
- currentValue = undefined;
142
- }
143
- } else {
144
- console.warn('⚠️ [DatePicker] Invalid date value provided:', value);
172
+ const parsed = calendarDateFromUnknown(value);
173
+ if (!parsed) {
174
+ console.warn('[DatePicker] Invalid date value provided:', value);
145
175
  currentValue = undefined;
176
+ placeholder = today(getLocalTimeZone());
177
+ return;
146
178
  }
147
179
 
148
- placeholder = currentValue ?? today(getLocalTimeZone());
149
- // console.log('🎯 [DatePicker] Final state:', { currentValue, placeholder });
180
+ currentValue = parsed;
181
+ placeholder = parsed;
150
182
  }
151
183
 
152
184
  // Track dropdown state through store subscription
@@ -165,7 +197,9 @@
165
197
  languageTag: string,
166
198
  translate: Translate<EditorMessageKey>
167
199
  ): string {
168
- if (!date || !(date instanceof CalendarDate)) return translate('editor.date.pick');
200
+ if (!date || typeof date.year !== 'number' || typeof date.month !== 'number' || typeof date.day !== 'number') {
201
+ return translate('editor.date.pick');
202
+ }
169
203
  try {
170
204
  // Convert to JavaScript Date for localized formatting
171
205
  const jsDate = new Date(date.year, date.month - 1, date.day);
@@ -183,10 +217,10 @@
183
217
  * @param newValue - The newly selected date
184
218
  */
185
219
  function handleSelect(newValue: DateValue | undefined) {
186
- if (newValue instanceof CalendarDate) {
187
- onChange(newValue);
188
- toggleDropdown(controllerId);
189
- }
220
+ const selected = calendarDateFromUnknown(newValue);
221
+ if (!selected) return;
222
+ commitSelectedDate(selected);
223
+ toggleDropdown(controllerId);
190
224
  }
191
225
 
192
226
  /**
@@ -219,40 +253,63 @@
219
253
  * Closes the dropdown when scrolling occurs outside the dropdowns
220
254
  */
221
255
  function handleScroll(event: Event) {
222
- // Ensure target is an HTMLElement
223
- if (!(event.target instanceof HTMLElement)) {
224
- return;
225
- }
226
-
227
- const target = event.target;
228
-
229
- // Check if scroll happened inside our dropdowns
230
- const isInsideDropdown = target.closest('.month-year-dropdown-content');
256
+ if (isEventInside(event, datePickerPortalHost)) return;
257
+ if (open) closeDropdown();
258
+ }
231
259
 
232
- // If scrolling is inside our dropdowns, don't close
233
- if (isInsideDropdown) {
234
- return;
260
+ function handlePopoverInteractOutside(event: Event) {
261
+ if (isEventInside(event, datePickerPortalHost) || isEventInside(event, controllerElement)) {
262
+ event.preventDefault();
235
263
  }
264
+ }
236
265
 
237
- // If scrolling outside our dropdowns, close
238
- if (open) {
266
+ function handlePointerDownOutside(event: PointerEvent) {
267
+ if (!open) return;
268
+ if (isEventInside(event, datePickerPortalHost) || isEventInside(event, controllerElement)) return;
269
+ closeDropdown();
270
+ }
271
+
272
+ /**
273
+ * Shopify's module loads `@internationalized/date` twice, so bits-ui's calendar throws
274
+ * `Unknown date type` on a day click and never calls `onValueChange`. The day cell still
275
+ * has `data-value="YYYY-MM-DD"`: read that here, before bits-ui handles the pointer.
276
+ */
277
+ function handleCalendarDayPointerDown(event: PointerEvent) {
278
+ const path = typeof event.composedPath === 'function' ? event.composedPath() : [event.target];
279
+ for (const node of path) {
280
+ if (!(node instanceof Element)) continue;
281
+ if (node.hasAttribute('data-disabled') || node.hasAttribute('data-unavailable')) continue;
282
+ const iso = node.getAttribute('data-value');
283
+ if (!iso || !/^\d{4}-\d{2}-\d{2}$/.test(iso)) continue;
284
+ const selected = calendarDateFromUnknown(iso);
285
+ if (!selected) return;
286
+ event.preventDefault();
287
+ event.stopPropagation();
288
+ commitSelectedDate(selected);
239
289
  closeDropdown();
290
+ return;
240
291
  }
241
292
  }
242
293
 
243
294
  // The control's own element, which says which tree (the page or a module's shadow root) to listen for scrolling in
244
295
  let controllerElement: HTMLDivElement | undefined;
245
296
  let stopListeningForScroll: () => void = () => {};
297
+ let datePickerPortalHost: HTMLElement | undefined = undefined;
246
298
 
247
299
  // Setup scroll event listener on mount (the page and, inside a module, the module's own panels: a scroll never
248
300
  // leaves a shadow root, so a listener on the window alone does not hear about those)
249
301
  onMount(() => {
302
+ datePickerPortalHost = acquirePortalHost(controllerElement, 'widgetic-date-picker-portal') ?? undefined;
250
303
  stopListeningForScroll = listenForScroll(controllerElement, handleScroll);
304
+ window.addEventListener('pointerdown', handlePointerDownOutside, true);
251
305
  });
252
306
 
253
307
  // Cleanup scroll event listener on destroy
254
308
  onDestroy(() => {
255
309
  stopListeningForScroll();
310
+ window.removeEventListener('pointerdown', handlePointerDownOutside, true);
311
+ releasePortalHost(datePickerPortalHost);
312
+ datePickerPortalHost = undefined;
256
313
  });
257
314
  </script>
258
315
 
@@ -283,6 +340,11 @@
283
340
  class="date-picker-popover z-50 w-[15.625rem] border border-border p-3 shadow-none"
284
341
  align="end"
285
342
  sideOffset={8}
343
+ portalProps={datePickerPortalHost ? { to: datePickerPortalHost } : undefined}
344
+ interactOutsideBehavior="ignore"
345
+ trapFocus={false}
346
+ onInteractOutside={handlePopoverInteractOutside}
347
+ onFocusOutside={handlePopoverInteractOutside}
286
348
  >
287
349
  <div class="flex w-full flex-col gap-3">
288
350
  <div class="flex w-full items-center gap-2">
@@ -297,13 +359,9 @@
297
359
  // we pass a plain CalendarDate instance that the Calendar component can recognise.
298
360
  placeholder = new CalendarDate(placeholder.year, monthValue, placeholder.day);
299
361
  if (currentValue) {
300
- const newValue = new CalendarDate(
301
- currentValue.year,
302
- monthValue,
303
- currentValue.day
362
+ commitSelectedDate(
363
+ new CalendarDate(currentValue.year, monthValue, currentValue.day)
304
364
  );
305
- currentValue = newValue;
306
- onChange(newValue);
307
365
  }
308
366
  }}
309
367
  >
@@ -314,7 +372,10 @@
314
372
  <span class="truncate">{defaultMonth?.label || $t('editor.date.selectMonth')}</span>
315
373
  </Select.Trigger>
316
374
  <!-- No overflow-y-auto of its own (round 26): the list scrolls inside its viewport with the arrow buttons, which show the hand cursor; a second scroller here could only add a double scrollbar -->
317
- <Select.Content class="month-year-dropdown-content max-h-[200px]">
375
+ <Select.Content
376
+ class="month-year-dropdown-content max-h-[200px]"
377
+ portalProps={datePickerPortalHost ? { to: datePickerPortalHost } : undefined}
378
+ >
318
379
  {#each monthOptions as { value, label }}
319
380
  <Select.Item {value} {label}>
320
381
  {label}
@@ -332,13 +393,9 @@
332
393
  // Same fix as above – ensure a clean CalendarDate instance.
333
394
  placeholder = new CalendarDate(yearValue, placeholder.month, placeholder.day);
334
395
  if (currentValue) {
335
- const newValue = new CalendarDate(
336
- yearValue,
337
- currentValue.month,
338
- currentValue.day
396
+ commitSelectedDate(
397
+ new CalendarDate(yearValue, currentValue.month, currentValue.day)
339
398
  );
340
- currentValue = newValue;
341
- onChange(newValue);
342
399
  }
343
400
  }}
344
401
  >
@@ -349,7 +406,10 @@
349
406
  <span class="truncate">{defaultYear?.label || $t('editor.date.selectYear')}</span>
350
407
  </Select.Trigger>
351
408
  <!-- Same as the month list: the viewport scrolls, with the arrow buttons (round 26) -->
352
- <Select.Content class="month-year-dropdown-content max-h-[200px]">
409
+ <Select.Content
410
+ class="month-year-dropdown-content max-h-[200px]"
411
+ portalProps={datePickerPortalHost ? { to: datePickerPortalHost } : undefined}
412
+ >
353
413
  {#each yearOptions as { value, label }}
354
414
  <Select.Item {value} {label}>
355
415
  {label}
@@ -359,22 +419,22 @@
359
419
  </Select.Root>
360
420
  </div>
361
421
  <!-- Style the calendar content -->
362
- <div class="calendar-no-header">
422
+ <div class="calendar-no-header" onpointerdowncapture={handleCalendarDayPointerDown}>
363
423
  <Calendar
364
424
  mode="single"
365
425
  locale={$locale}
366
426
  bind:placeholder
367
427
  value={currentValue}
428
+ minValue={calendarMinValue}
429
+ maxValue={calendarMaxValue}
368
430
  calendarLabel={$t('editor.date.calendarLabel')}
369
431
  previousLabel={$t('editor.date.previousMonth')}
370
432
  nextLabel={$t('editor.date.nextMonth')}
371
433
  onValueChange={(date: DateValue | undefined) => {
372
- if (date instanceof CalendarDate) {
373
- currentValue = date;
374
- placeholder = date;
375
- onChange(date);
376
- closeDropdown();
377
- }
434
+ const selected = calendarDateFromUnknown(date);
435
+ if (!selected) return;
436
+ commitSelectedDate(selected);
437
+ closeDropdown();
378
438
  }}
379
439
  fixedWeeks
380
440
  class="calendar-editor-fit p-0"
@@ -4,14 +4,14 @@ import type { Writable } from 'svelte/store';
4
4
  export interface DatePickerInputControllerProps {
5
5
  label: string;
6
6
  value?: any;
7
- onChange: (newValue: CalendarDate) => void;
7
+ /** Widgets and compositions store the day as `YYYY-MM-DD`. */
8
+ onChange: (newValue: string) => void;
8
9
  description?: string;
9
10
  controllerId: string;
10
11
  openDropdowns: Writable<Set<string>>;
11
12
  toggleDropdown: (id: string) => void;
12
13
  onFocus?: () => void;
13
14
  }
14
- import { CalendarDate } from '@internationalized/date';
15
15
  interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
16
16
  new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
17
17
  $$bindings?: Bindings;
@@ -1,9 +1,11 @@
1
1
  <script lang="ts">
2
2
  /**
3
- * The File Browser of the editor, laid over the props panel: the white surface of the panel, a header with the title
4
- * and the X that closes it (at the end, centred in the height of the header, as in Figma), and the File Browser under
5
- * it. Every control that picks a file (a file, an image, a vector) opens its browser through this, so they look and
6
- * behave the same.
3
+ * The File Browser of the editor, laid over the props panel: the white surface of the panel and the File Browser on it. There is
4
+ * no title bar and no line above it (owner, 20 Nov 2026: "we don't have to have that area at the top that says select image. We
5
+ * could actually move the breadcrumbs there"): the browser draws the crumbs as the first row (`dialogHeader`), and the X that
6
+ * closes the overlay is laid over the end of that row, 16px from the top and from the end, as the X of the design system dialogs.
7
+ * The title stays for a screen reader. Every control that picks a file (a file, an image, a vector) opens its browser through
8
+ * this, so they look and behave the same.
7
9
  *
8
10
  * The control fixes the type of file (`fileFilter`): the browser then draws no "Filter by" (the user cannot change the
9
11
  * type) and the upload takes only that type. `fileFilter="all"` (any file) keeps the filter.
@@ -49,6 +51,13 @@
49
51
  /** Flat host libraries have no folders; partner pages must not use our localStorage keys. */
50
52
  const rememberEditorFolder = getEditorMediaLibrary() == null;
51
53
 
54
+ /**
55
+ * What a File Browser release that is newer than the installed one knows: `dialogHeader`, the browser draws the top of the overlay
56
+ * itself (the crumbs up to the X, the search as an icon so that the filter fits, no title bar and no line). Spread from a plain
57
+ * object, so the editor also builds with the older release (which ignores it).
58
+ */
59
+ const newerFileBrowserProps = { dialogHeader: true };
60
+
52
61
  /** The top-most dialog when this overlay opened: a dialog with a higher generation was opened inside the browser. */
53
62
  const generationWhenOverlayOpened = get(modalState).generation ?? 0;
54
63
 
@@ -112,20 +121,8 @@
112
121
  class:rounded-xl={!fillEditorPanel}
113
122
  class:shadow-md={!fillEditorPanel}
114
123
  >
115
- <div
116
- class="editor-file-browser-header relative flex h-[47px] shrink-0 items-center border-b border-border ps-4 pe-12"
117
- >
118
- <span class="text-body-medium text-foreground">{$t('editor.file.dialogTitle')}</span>
119
- <!-- Figma: the X is a 24px button 12px from the end, centred in the height of the header -->
120
- <button
121
- type="button"
122
- class="editor-file-browser-close press-feedback absolute top-1/2 end-3 flex size-6 -translate-y-1/2 items-center justify-center rounded-lg p-0 transition-colors duration-fast hover:bg-accent focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring"
123
- on:click={onClose}
124
- aria-label={$t('editor.file.closeDialog')}
125
- >
126
- <IconX class="size-4 stroke-2" />
127
- </button>
128
- </div>
124
+ <!-- No title bar and no line: the File Browser draws the top row (`dialogHeader`). The title stays for a screen reader. -->
125
+ <h2 class="sr-only">{$t('editor.file.dialogTitle')}</h2>
129
126
 
130
127
  <div class="editor-file-browser-body flex min-h-0 flex-1 flex-col overflow-hidden">
131
128
  <!-- With a host media library (flat list) we remember nothing in localStorage. With Widgetic folders we
@@ -148,9 +145,20 @@
148
145
  {addToEditorLabel}
149
146
  locale={$fileBrowserLanguage.locale ?? undefined}
150
147
  messages={$fileBrowserLanguage.messages ?? null}
148
+ {...newerFileBrowserProps}
151
149
  on:select
152
150
  />
153
151
  </div>
152
+
153
+ <!-- The X is laid over the end of the first row of the browser: 32px, 16px from the top and the end (the X of the design system dialogs), on the line of the crumbs. -->
154
+ <button
155
+ type="button"
156
+ class="editor-file-browser-close press-feedback text-foreground absolute end-4 top-4 z-[70] inline-flex size-8 items-center justify-center rounded-lg p-0 transition-colors duration-fast hover:bg-accent focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring"
157
+ on:click={onClose}
158
+ aria-label={$t('editor.file.closeDialog')}
159
+ >
160
+ <IconX class="size-4 stroke-2" />
161
+ </button>
154
162
  </div>
155
163
  </div>
156
164
  </Portal>
@@ -350,6 +350,8 @@ export declare const EDITOR_CATALOGS: {
350
350
  readonly 'search.placeholder': "Search\u2026";
351
351
  readonly 'search.recentSearches': "Recent searches";
352
352
  readonly 'search.clearRecentSearches': "Clear";
353
+ readonly 'search.open': "Search";
354
+ readonly 'search.close': "Close search";
353
355
  readonly 'filter.by': "Filter by {type}";
354
356
  readonly 'filterName.all': "All";
355
357
  readonly 'filterName.image': "Image";
@@ -462,6 +464,7 @@ export declare const EDITOR_CATALOGS: {
462
464
  readonly 'upload.filesTotal': "{count, plural, one {# file} other {# files}}";
463
465
  readonly 'upload.completeCount': "{done}/{total} complete";
464
466
  readonly 'upload.failed': "Upload failed";
467
+ readonly 'upload.interrupted': "Interrupted. Try again";
465
468
  readonly 'upload.rowMeta': "{size} \u00B7 {detail}";
466
469
  readonly 'dialog.delete.folderTitle': "Delete folder";
467
470
  readonly 'dialog.delete.itemsTitle': "Delete items";
@@ -485,10 +488,8 @@ export declare const EDITOR_CATALOGS: {
485
488
  readonly 'dialog.rename.tooShort': "Name must be at least 1 character long";
486
489
  readonly 'dialog.rename.tooLong': "Name must be {max} characters or less";
487
490
  readonly 'dialog.close': "Close modal";
488
- readonly 'toast.rename.started': "Renaming \"{name}\"\u2026";
489
491
  readonly 'toast.rename.done': "File renamed";
490
492
  readonly 'toast.rename.folderDone': "Folder renamed";
491
- readonly 'toast.rename.doneDetail': "Successfully renamed \"{oldName}\" to \"{newName}\"";
492
493
  readonly 'toast.rename.failed': "Rename failed";
493
494
  readonly 'toast.rename.noChange': "No changes were made";
494
495
  readonly 'toast.rename.noItem': "No valid item selected";
@@ -687,7 +688,7 @@ export declare const ALL_EDITOR_MESSAGES: Readonly<Record<string, string>>;
687
688
  * the nearest real one), a value that is not text, a template that does not parse, or one that asks for a value the message
688
689
  * is never given. An empty list means every message will be used. For a test or a build step of the page.
689
690
  */
690
- export declare const checkEditorMessages: (messages: import("@widgetic/design-system/i18n").MessageOverrides) => import("@widgetic/design-system/i18n").MessageProblem[];
691
+ export declare const checkEditorMessages: (messages: import("@widgetic/file-browser").MessageOverrides) => import("@widgetic/file-browser").MessageProblem[];
691
692
  /**
692
693
  * Called by the root component of an editor while it is created, so everything inside it speaks the page's language.
693
694
  * The context belongs to one root component, so two editors on a page can speak two languages.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@widgetic/editor",
3
- "version": "4.1.23",
3
+ "version": "4.1.24",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -55,7 +55,7 @@
55
55
  "@widgetic/cache-layer": "^0.1.1",
56
56
  "@widgetic/chat": ">=0.1.42",
57
57
  "@widgetic/design-system": ">=0.5.28",
58
- "@widgetic/file-browser": "^0.5.41",
58
+ "@widgetic/file-browser": "^0.5.54",
59
59
  "svelte": "^5.27.0"
60
60
  },
61
61
  "devDependencies": {
@@ -74,7 +74,7 @@
74
74
  "@widgetic/chat": "^0.1.42",
75
75
  "@widgetic/design-system": "^0.5.28",
76
76
  "@widgetic/dev-tools": "^0.2.0",
77
- "@widgetic/file-browser": "^0.5.41",
77
+ "@widgetic/file-browser": "^0.5.54",
78
78
  "eslint": "^9.0.0",
79
79
  "eslint-config-prettier": "^9.1.0",
80
80
  "eslint-plugin-svelte": "^2.36.0",