@urbicon-ui/blocks 6.19.2 → 6.21.0

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 (30) hide show
  1. package/dist/components/Calendar/Calendar.svelte +8 -0
  2. package/dist/components/Calendar/CalendarGrid.svelte +19 -77
  3. package/dist/components/Calendar/calendar.context.d.ts +2 -0
  4. package/dist/components/Calendar/calendar.variants.d.ts +62 -62
  5. package/dist/i18n/index.d.ts +372 -2
  6. package/dist/icons/IconProvider.svelte +3 -0
  7. package/dist/mint/styles.css +1 -1
  8. package/dist/primitives/Accordion/Accordion.svelte +3 -0
  9. package/dist/primitives/Alert/alert.variants.d.ts +7 -7
  10. package/dist/primitives/Avatar/Avatar.svelte +74 -48
  11. package/dist/primitives/Avatar/avatar.variants.d.ts +32 -6
  12. package/dist/primitives/Avatar/avatar.variants.js +43 -18
  13. package/dist/primitives/Avatar/index.d.ts +6 -1
  14. package/dist/primitives/Checkbox/Checkbox.svelte +7 -4
  15. package/dist/primitives/Collapsible/Collapsible.svelte +3 -0
  16. package/dist/primitives/ConfirmDialog/index.d.ts +12 -0
  17. package/dist/primitives/Dialog/Dialog.svelte +2 -0
  18. package/dist/primitives/Drawer/Drawer.svelte +3 -1
  19. package/dist/primitives/JourneyTimeline/journey-timeline.variants.d.ts +21 -21
  20. package/dist/primitives/Menu/MenuSubmenu.svelte +1 -0
  21. package/dist/primitives/Select/Select.svelte +1 -1
  22. package/dist/primitives/Spinner/spinner.variants.d.ts +15 -15
  23. package/dist/primitives/Stepper/stepper.variants.d.ts +10 -10
  24. package/dist/primitives/Tab/Tab.svelte +3 -0
  25. package/dist/primitives/Toast/toast.variants.d.ts +8 -8
  26. package/dist/primitives/Toggle/Toggle.svelte +7 -4
  27. package/dist/primitives/Tooltip/tooltip.variants.d.ts +2 -2
  28. package/dist/style/interaction.css +1 -1
  29. package/dist/system/attachments/ContextIsolation.svelte +2 -0
  30. package/package.json +3 -3
@@ -161,6 +161,9 @@
161
161
  if (month == null && year == null) return today;
162
162
  return new Date(year ?? today.getFullYear(), month ?? today.getMonth(), 1);
163
163
  }
164
+ // Uncontrolled seed: capture only the initial default*; later changes to the
165
+ // default* props must not move the user's navigated month.
166
+ // svelte-ignore state_referenced_locally
164
167
  let referenceDate = $state(
165
168
  resolveInitialReference(value, defaultDate, defaultMonth, defaultYear)
166
169
  );
@@ -452,6 +455,10 @@
452
455
  controller.setFocusedDate(date);
453
456
  }
454
457
 
458
+ function moveFocus(deltaDays: number) {
459
+ controller.moveFocus(deltaDays);
460
+ }
461
+
455
462
  function setHoveredDate(date: Date | null) {
456
463
  controller.setHoveredDate(date);
457
464
  }
@@ -567,6 +574,7 @@
567
574
  goToMonth,
568
575
  selectDate,
569
576
  setFocusedDate,
577
+ moveFocus,
570
578
  setHoveredDate,
571
579
  setView,
572
580
  isDateDisabled: (date: Date) => controller.isDisabled(date),
@@ -4,6 +4,7 @@
4
4
  import { fly } from 'svelte/transition';
5
5
  import { getCalendarContext, createSlotHelper } from './calendar.context';
6
6
  import { getWeekNumber, toIso } from '../../date';
7
+ import { handleDateGridKeydown } from '../../internal/date-grid';
7
8
  import { getMultiDayEventLayout } from './calendar.engine';
8
9
  import { swipeable } from '../../utils/swipeable';
9
10
  import type { CalendarEvent, DayCellContext } from './calendar.types';
@@ -41,87 +42,28 @@
41
42
  const barHeight = $derived(ctx.size === 'sm' ? 16 : ctx.size === 'lg' ? 24 : 20);
42
43
  const barGap = 2;
43
44
 
44
- // Keyboard navigation handler
45
- // Local Date copies for keyboard navnot reactive state.
46
- function handleKeydown(e: KeyboardEvent) {
47
- const current = new Date(ctx.focusedDate);
48
- let newDate: Date | null = null;
49
-
50
- switch (e.key) {
51
- case 'ArrowRight':
52
- newDate = new Date(current);
53
- newDate.setDate(current.getDate() + 1);
54
- break;
55
- case 'ArrowLeft':
56
- newDate = new Date(current);
57
- newDate.setDate(current.getDate() - 1);
58
- break;
59
- case 'ArrowDown':
60
- newDate = new Date(current);
61
- newDate.setDate(current.getDate() + 7);
62
- break;
63
- case 'ArrowUp':
64
- newDate = new Date(current);
65
- newDate.setDate(current.getDate() - 7);
66
- break;
67
- case 'Home':
68
- if (e.ctrlKey || e.metaKey) {
69
- newDate = new Date(ctx.displayedYear, ctx.displayedMonth, 1);
70
- } else {
71
- newDate = new Date(current);
72
- newDate.setDate(current.getDate() - ((current.getDay() - ctx.weekStartsOn + 7) % 7));
73
- }
74
- break;
75
- case 'End':
76
- if (e.ctrlKey || e.metaKey) {
77
- newDate = new Date(ctx.displayedYear, ctx.displayedMonth + 1, 0);
78
- } else {
79
- newDate = new Date(current);
80
- newDate.setDate(
81
- current.getDate() + (6 - ((current.getDay() - ctx.weekStartsOn + 7) % 7))
82
- );
83
- }
84
- break;
85
- case 'PageDown':
86
- newDate = new Date(current);
87
- newDate.setMonth(current.getMonth() + 1);
88
- break;
89
- case 'PageUp':
90
- newDate = new Date(current);
91
- newDate.setMonth(current.getMonth() - 1);
92
- break;
93
- case 'Enter':
94
- case ' ':
95
- e.preventDefault();
96
- ctx.selectDate(ctx.focusedDate);
97
- return;
98
- case 'Escape':
99
- return;
100
- default:
101
- return;
102
- }
103
-
104
- if (newDate) {
105
- e.preventDefault();
106
- // Capture the grid while the event is still dispatching: `e.currentTarget` is
107
- // null inside the rAF callback a frame later (the browser clears it after
108
- // dispatch). CalendarDay uses pure roving tabindex with no isFocused-driven
109
- // .focus(), so this rAF is the only thing that moves real DOM focus onto the
110
- // landed day — mirrors DateGridScaffold's bound-ref approach.
111
- const grid = e.currentTarget as HTMLElement;
112
- ctx.setFocusedDate(newDate);
113
-
114
- requestAnimationFrame(() => {
115
- // setFocusedDate clamps to [minDate, maxDate], so focus the *landed* day (the
116
- // one that took roving tabindex), not the raw requested newDate.
117
- const dateStr = toIso(ctx.focusedDate);
118
- grid.querySelector<HTMLElement>(`[data-date="${dateStr}"]`)?.focus();
119
- });
120
- }
45
+ // Roving-focus keyboard nav runs through the shared date-grid handler (the same
46
+ // one Planner's DateGridScaffold uses) so the ARIA key map arrows, Home/End,
47
+ // Page(±month), Shift+Page(±year), Enter/Space — lives in one place. The
48
+ // CalendarContext satisfies DateGridKeyboardTarget (moveFocus/setFocusedDate/
49
+ // selectDate all delegate to the shared controller).
50
+ let gridEl = $state<HTMLElement | null>(null);
51
+
52
+ function handleKeydown(event: KeyboardEvent) {
53
+ if (!handleDateGridKeydown(event, ctx)) return;
54
+ // CalendarDay uses pure roving tabindex with no isFocused-driven .focus(), so
55
+ // this rAF is the only thing that moves real DOM focus onto the landed day.
56
+ // The controller clamps focus to [minDate, maxDate], so target the day that
57
+ // actually took the roving tabindex (ctx.focusedDate), not the raw key intent.
58
+ const target = toIso(ctx.focusedDate);
59
+ requestAnimationFrame(() => {
60
+ gridEl?.querySelector<HTMLElement>(`[data-date="${target}"]`)?.focus();
61
+ });
121
62
  }
122
63
  </script>
123
64
 
124
65
  <div
66
+ bind:this={gridEl}
125
67
  class={slot('grid', className)}
126
68
  role="grid"
127
69
  tabindex={0}
@@ -45,6 +45,8 @@ export interface CalendarContext {
45
45
  goToToday: () => void;
46
46
  selectDate: (date: Date) => void;
47
47
  setFocusedDate: (date: Date) => void;
48
+ /** Move the roving focus by whole days (keyboard arrows / page keys). */
49
+ moveFocus: (deltaDays: number) => void;
48
50
  setHoveredDate: (date: Date | null) => void;
49
51
  setView: (view: CalendarViewMode) => void;
50
52
  /** Navigate to a specific month (used by year grid drill-down). */