@r2digisolutions/components 0.25.12 → 0.25.13

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.
@@ -1,4 +1,7 @@
1
1
  <script lang="ts">
2
+ import { i18n } from '../../../utils/i18n.svelte.js';
3
+ import { getDictionary, type MessageKey } from '../../../utils/i18n.js';
4
+
2
5
  export type CalendarMode = 'single' | 'multiple' | 'range';
3
6
 
4
7
  export type CalendarDot = string | { date: string; color?: string };
@@ -59,6 +62,9 @@
59
62
  onchange
60
63
  }: CalendarProps = $props();
61
64
 
65
+ // The calendar's locale names its controls; without one, the shared i18n store does.
66
+ const localMessages = $derived(locale && locale !== 'en' ? getDictionary(locale) : null);
67
+ const message = (key: MessageKey) => localMessages?.[key] ?? i18n.t(key);
62
68
  const today = new Date();
63
69
  const todayIso = `${today.getFullYear()}-${String(today.getMonth() + 1).padStart(2, '0')}-${String(today.getDate()).padStart(2, '0')}`;
64
70
 
@@ -75,8 +81,16 @@
75
81
  return value;
76
82
  }
77
83
 
84
+ /** First selectable month when it is in the future (e.g. an end date after a start). */
85
+ function minMonth() {
86
+ return min && min.slice(0, 10) > todayIso ? monthFromIso(min) : null;
87
+ }
88
+
89
+ // Without a selection, open on the first selectable month.
78
90
  let view = $state(
79
- monthFromIso(selectionIso()) ?? new Date(today.getFullYear(), today.getMonth(), 1)
91
+ monthFromIso(selectionIso()) ??
92
+ minMonth() ??
93
+ new Date(today.getFullYear(), today.getMonth(), 1)
80
94
  );
81
95
  let panel = $state<Panel>('days');
82
96
  /** Which month column owns the month/year picker when months=2. */
@@ -426,7 +440,7 @@
426
440
  type="button"
427
441
  onclick={() => shift(-1)}
428
442
  class="rounded-lg p-1.5 text-secondary hover:bg-surface-overlay hover:text-primary"
429
- aria-label="Previous month"
443
+ aria-label={message('previousMonth')}
430
444
  >
431
445
  <svg class="h-4 w-4" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
432
446
  <path stroke-linecap="round" stroke-linejoin="round" d="M15 19l-7-7 7-7" />
@@ -458,7 +472,7 @@
458
472
  type="button"
459
473
  onclick={() => shift(1)}
460
474
  class="rounded-lg p-1.5 text-secondary hover:bg-surface-overlay hover:text-primary"
461
- aria-label="Next month"
475
+ aria-label={message('nextMonth')}
462
476
  >
463
477
  <svg class="h-4 w-4" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
464
478
  <path stroke-linecap="round" stroke-linejoin="round" d="M9 5l7 7-7 7" />
@@ -525,7 +539,7 @@
525
539
  type="button"
526
540
  onclick={() => shift(-1)}
527
541
  class="rounded-lg p-1.5 text-secondary hover:bg-surface-overlay hover:text-primary"
528
- aria-label={panel === 'years' ? 'Previous years' : 'Previous year'}
542
+ aria-label={message(panel === 'years' ? 'previousYears' : 'previousYear')}
529
543
  >
530
544
  <svg class="h-4 w-4" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
531
545
  <path stroke-linecap="round" stroke-linejoin="round" d="M15 19l-7-7 7-7" />
@@ -550,7 +564,7 @@
550
564
  type="button"
551
565
  onclick={() => shift(1)}
552
566
  class="rounded-lg p-1.5 text-secondary hover:bg-surface-overlay hover:text-primary"
553
- aria-label={panel === 'years' ? 'Next years' : 'Next year'}
567
+ aria-label={message(panel === 'years' ? 'nextYears' : 'nextYear')}
554
568
  >
555
569
  <svg class="h-4 w-4" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
556
570
  <path stroke-linecap="round" stroke-linejoin="round" d="M9 5l7 7-7 7" />
@@ -501,7 +501,7 @@
501
501
  id={panelId}
502
502
  popover="auto"
503
503
  role="dialog"
504
- aria-label="Choose date and time"
504
+ aria-label={message('chooseDateTime')}
505
505
  onbeforetoggle={handleBeforeToggle}
506
506
  ontoggle={handleToggle}
507
507
  data-placed={placed ? true : undefined}
@@ -536,7 +536,7 @@
536
536
  bind:this={hourListEl}
537
537
  class="p-1.5 h-[18.5rem] overflow-y-auto"
538
538
  role="listbox"
539
- aria-label="Hours"
539
+ aria-label={message('hours')}
540
540
  >
541
541
  {#each hours24 as h (h)}
542
542
  <button
@@ -562,7 +562,7 @@
562
562
  bind:this={minuteListEl}
563
563
  class="p-1.5 h-[18.5rem] overflow-y-auto"
564
564
  role="listbox"
565
- aria-label="Minutes"
565
+ aria-label={message('minutes')}
566
566
  >
567
567
  {#each minutes as m (m)}
568
568
  <button
@@ -11,6 +11,15 @@ export interface UiMessages {
11
11
  time: string;
12
12
  clear: string;
13
13
  selectDateTime: string;
14
+ chooseDateTime: string;
15
+ hours: string;
16
+ minutes: string;
17
+ previousMonth: string;
18
+ nextMonth: string;
19
+ previousYear: string;
20
+ nextYear: string;
21
+ previousYears: string;
22
+ nextYears: string;
14
23
  optional: string;
15
24
  required: string;
16
25
  loading: string;
@@ -8,6 +8,15 @@ const en = {
8
8
  time: 'Time',
9
9
  clear: 'Clear',
10
10
  selectDateTime: 'Select date & time',
11
+ chooseDateTime: 'Choose date and time',
12
+ hours: 'Hours',
13
+ minutes: 'Minutes',
14
+ previousMonth: 'Previous month',
15
+ nextMonth: 'Next month',
16
+ previousYear: 'Previous year',
17
+ nextYear: 'Next year',
18
+ previousYears: 'Previous years',
19
+ nextYears: 'Next years',
11
20
  optional: 'Optional',
12
21
  required: 'Required',
13
22
  loading: 'Loading…',
@@ -58,6 +67,15 @@ const es = {
58
67
  time: 'Hora',
59
68
  clear: 'Borrar',
60
69
  selectDateTime: 'Selecciona fecha y hora',
70
+ chooseDateTime: 'Elegir fecha y hora',
71
+ hours: 'Horas',
72
+ minutes: 'Minutos',
73
+ previousMonth: 'Mes anterior',
74
+ nextMonth: 'Mes siguiente',
75
+ previousYear: 'Año anterior',
76
+ nextYear: 'Año siguiente',
77
+ previousYears: 'Años anteriores',
78
+ nextYears: 'Años siguientes',
61
79
  optional: 'Opcional',
62
80
  required: 'Obligatorio',
63
81
  loading: 'Cargando…',
@@ -108,6 +126,15 @@ const pt = {
108
126
  time: 'Hora',
109
127
  clear: 'Limpar',
110
128
  selectDateTime: 'Selecione data e hora',
129
+ chooseDateTime: 'Escolher data e hora',
130
+ hours: 'Horas',
131
+ minutes: 'Minutos',
132
+ previousMonth: 'Mês anterior',
133
+ nextMonth: 'Mês seguinte',
134
+ previousYear: 'Ano anterior',
135
+ nextYear: 'Ano seguinte',
136
+ previousYears: 'Anos anteriores',
137
+ nextYears: 'Anos seguintes',
111
138
  optional: 'Opcional',
112
139
  required: 'Obrigatório',
113
140
  loading: 'A carregar…',
@@ -158,6 +185,15 @@ const fr = {
158
185
  time: 'Heure',
159
186
  clear: 'Effacer',
160
187
  selectDateTime: 'Choisir la date et l’heure',
188
+ chooseDateTime: 'Choisir la date et l’heure',
189
+ hours: 'Heures',
190
+ minutes: 'Minutes',
191
+ previousMonth: 'Mois précédent',
192
+ nextMonth: 'Mois suivant',
193
+ previousYear: 'Année précédente',
194
+ nextYear: 'Année suivante',
195
+ previousYears: 'Années précédentes',
196
+ nextYears: 'Années suivantes',
161
197
  optional: 'Facultatif',
162
198
  required: 'Obligatoire',
163
199
  loading: 'Chargement…',
@@ -208,6 +244,15 @@ const de = {
208
244
  time: 'Uhrzeit',
209
245
  clear: 'Löschen',
210
246
  selectDateTime: 'Datum und Uhrzeit wählen',
247
+ chooseDateTime: 'Datum und Uhrzeit wählen',
248
+ hours: 'Stunden',
249
+ minutes: 'Minuten',
250
+ previousMonth: 'Vorheriger Monat',
251
+ nextMonth: 'Nächster Monat',
252
+ previousYear: 'Vorheriges Jahr',
253
+ nextYear: 'Nächstes Jahr',
254
+ previousYears: 'Vorherige Jahre',
255
+ nextYears: 'Nächste Jahre',
211
256
  optional: 'Optional',
212
257
  required: 'Pflichtfeld',
213
258
  loading: 'Wird geladen…',
@@ -258,6 +303,15 @@ const ca = {
258
303
  time: 'Hora',
259
304
  clear: 'Esborra',
260
305
  selectDateTime: 'Tria data i hora',
306
+ chooseDateTime: 'Tria data i hora',
307
+ hours: 'Hores',
308
+ minutes: 'Minuts',
309
+ previousMonth: 'Mes anterior',
310
+ nextMonth: 'Mes següent',
311
+ previousYear: 'Any anterior',
312
+ nextYear: 'Any següent',
313
+ previousYears: 'Anys anteriors',
314
+ nextYears: 'Anys següents',
261
315
  optional: 'Opcional',
262
316
  required: 'Obligatori',
263
317
  loading: 'S’està carregant…',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@r2digisolutions/components",
3
- "version": "0.25.12",
3
+ "version": "0.25.13",
4
4
  "private": false,
5
5
  "description": "R2DigiSolutions Svelte 5 component library — Atomic Design, Tailwind 4, Light/Dark mode",
6
6
  "license": "MIT",