@r2digisolutions/components 0.25.10 → 0.25.12
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.
- package/dist/components/molecules/DateTimePicker/DateTimePicker.svelte +23 -7
- package/dist/components/molecules/DateTimePicker/DateTimePicker.svelte.d.ts +6 -0
- package/dist/components/molecules/FormDatePicker/FormDatePicker.svelte +4 -0
- package/dist/components/molecules/FormDatePicker/FormDatePicker.svelte.d.ts +2 -0
- package/dist/components/molecules/FormDateTimePicker/FormDateTimePicker.svelte +14 -1
- package/dist/components/molecules/FormDateTimePicker/FormDateTimePicker.svelte.d.ts +5 -0
- package/dist/components/molecules/Tabs/Tabs.svelte +11 -9
- package/dist/utils/i18n.d.ts +4 -0
- package/dist/utils/i18n.js +18 -0
- package/package.json +1 -1
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import type { CalendarDot } from '../Calendar/Calendar.svelte';
|
|
6
6
|
import type { TimeFormat } from '../TimePicker/TimePicker.svelte';
|
|
7
7
|
import { i18n } from '../../../utils/i18n.svelte.js';
|
|
8
|
+
import { getDictionary, resolveLocaleTag, type MessageKey } from '../../../utils/i18n.js';
|
|
8
9
|
import { createId } from '../../../utils/id.js';
|
|
9
10
|
import { popoverInvokerToggle } from '../../../utils/popoverInvoker.js';
|
|
10
11
|
|
|
@@ -32,6 +33,12 @@
|
|
|
32
33
|
closeOnSelect?: boolean;
|
|
33
34
|
cancelLabel?: string;
|
|
34
35
|
saveLabel?: string;
|
|
36
|
+
/** BCP 47 locale for the calendar and displayed date. Defaults to the components i18n locale. */
|
|
37
|
+
locale?: string;
|
|
38
|
+
/** Heading of the time column. Defaults to the locale's "Time". */
|
|
39
|
+
timeLabel?: string;
|
|
40
|
+
/** Accessible name of the clear button. Defaults to the locale's "Clear". */
|
|
41
|
+
clearLabel?: string;
|
|
35
42
|
class?: string;
|
|
36
43
|
onchange?: (detail: { date: string; time: string; value: string }) => void;
|
|
37
44
|
}
|
|
@@ -43,7 +50,7 @@
|
|
|
43
50
|
open = $bindable(false),
|
|
44
51
|
disabled = false,
|
|
45
52
|
label = '',
|
|
46
|
-
placeholder
|
|
53
|
+
placeholder,
|
|
47
54
|
min,
|
|
48
55
|
max,
|
|
49
56
|
disabledDates = [],
|
|
@@ -53,6 +60,9 @@
|
|
|
53
60
|
closeOnSelect = false,
|
|
54
61
|
cancelLabel,
|
|
55
62
|
saveLabel,
|
|
63
|
+
locale,
|
|
64
|
+
timeLabel,
|
|
65
|
+
clearLabel,
|
|
56
66
|
class: className = '',
|
|
57
67
|
onchange
|
|
58
68
|
}: DateTimePickerProps = $props();
|
|
@@ -66,8 +76,13 @@
|
|
|
66
76
|
let draftDate = $state('');
|
|
67
77
|
let draftTime = $state('');
|
|
68
78
|
|
|
69
|
-
const
|
|
70
|
-
|
|
79
|
+
const dateLocale = $derived(locale || resolveLocaleTag(i18n.locale));
|
|
80
|
+
// An explicit locale wins over the shared i18n store (e.g. apps with their own i18n).
|
|
81
|
+
const localMessages = $derived(locale ? getDictionary(locale) : null);
|
|
82
|
+
const message = (key: MessageKey) => localMessages?.[key] ?? i18n.t(key);
|
|
83
|
+
const resolvedCancelLabel = $derived(cancelLabel ?? message('cancel'));
|
|
84
|
+
const resolvedSaveLabel = $derived(saveLabel ?? message('save'));
|
|
85
|
+
const resolvedPlaceholder = $derived(placeholder ?? message('selectDateTime'));
|
|
71
86
|
const confirmMode = $derived(!closeOnSelect);
|
|
72
87
|
const panelDate = $derived(confirmMode ? draftDate : date);
|
|
73
88
|
const panelTime = $derived(confirmMode ? draftTime : time);
|
|
@@ -191,7 +206,7 @@
|
|
|
191
206
|
function formatIso(iso: string) {
|
|
192
207
|
if (!iso) return '';
|
|
193
208
|
const [y, m, d] = iso.split('-').map(Number);
|
|
194
|
-
return new Date(y, m - 1, d).toLocaleDateString(
|
|
209
|
+
return new Date(y, m - 1, d).toLocaleDateString(dateLocale, {
|
|
195
210
|
month: 'short',
|
|
196
211
|
day: 'numeric',
|
|
197
212
|
year: 'numeric'
|
|
@@ -207,7 +222,7 @@
|
|
|
207
222
|
}
|
|
208
223
|
|
|
209
224
|
const fieldLabel = $derived.by(() => {
|
|
210
|
-
if (!date && !time) return
|
|
225
|
+
if (!date && !time) return resolvedPlaceholder;
|
|
211
226
|
if (date && time) return `${formatIso(date)} · ${formatTimeDisplay(time)}`;
|
|
212
227
|
if (date) return `${formatIso(date)} · …`;
|
|
213
228
|
return formatTimeDisplay(time);
|
|
@@ -466,7 +481,7 @@
|
|
|
466
481
|
type="button"
|
|
467
482
|
onclick={clear}
|
|
468
483
|
class="px-3 text-muted hover:bg-surface-overlay hover:text-primary h-full"
|
|
469
|
-
aria-label=
|
|
484
|
+
aria-label={clearLabel ?? message('clear')}
|
|
470
485
|
>
|
|
471
486
|
<svg
|
|
472
487
|
class="h-3.5 w-3.5"
|
|
@@ -503,6 +518,7 @@
|
|
|
503
518
|
disabledDates={calendarDisabled}
|
|
504
519
|
{dots}
|
|
505
520
|
framed={false}
|
|
521
|
+
locale={dateLocale}
|
|
506
522
|
class="w-full"
|
|
507
523
|
onchange={handleDateChange}
|
|
508
524
|
/>
|
|
@@ -513,7 +529,7 @@
|
|
|
513
529
|
<span
|
|
514
530
|
class="border-border px-3 py-2.5 font-medium tracking-wide text-muted shrink-0 border-b text-center text-[11px] uppercase"
|
|
515
531
|
>
|
|
516
|
-
|
|
532
|
+
{timeLabel ?? message('time')}
|
|
517
533
|
</span>
|
|
518
534
|
<div class="min-h-0 divide-border grid flex-1 grid-cols-2 divide-x">
|
|
519
535
|
<div
|
|
@@ -24,6 +24,12 @@ interface DateTimePickerProps {
|
|
|
24
24
|
closeOnSelect?: boolean;
|
|
25
25
|
cancelLabel?: string;
|
|
26
26
|
saveLabel?: string;
|
|
27
|
+
/** BCP 47 locale for the calendar and displayed date. Defaults to the components i18n locale. */
|
|
28
|
+
locale?: string;
|
|
29
|
+
/** Heading of the time column. Defaults to the locale's "Time". */
|
|
30
|
+
timeLabel?: string;
|
|
31
|
+
/** Accessible name of the clear button. Defaults to the locale's "Clear". */
|
|
32
|
+
clearLabel?: string;
|
|
27
33
|
class?: string;
|
|
28
34
|
onchange?: (detail: {
|
|
29
35
|
date: string;
|
|
@@ -19,6 +19,8 @@
|
|
|
19
19
|
errorMessage?: string;
|
|
20
20
|
disabled?: boolean;
|
|
21
21
|
bindData?: boolean;
|
|
22
|
+
/** BCP 47 locale for the calendar and displayed date. */
|
|
23
|
+
locale?: string;
|
|
22
24
|
class?: string;
|
|
23
25
|
onchange?: (value: string) => void;
|
|
24
26
|
}
|
|
@@ -34,6 +36,7 @@
|
|
|
34
36
|
errorMessage,
|
|
35
37
|
disabled = false,
|
|
36
38
|
bindData = false,
|
|
39
|
+
locale,
|
|
37
40
|
class: className = '',
|
|
38
41
|
onchange
|
|
39
42
|
}: FormDatePickerProps = $props();
|
|
@@ -71,6 +74,7 @@
|
|
|
71
74
|
{placeholder}
|
|
72
75
|
{min}
|
|
73
76
|
{max}
|
|
77
|
+
{locale}
|
|
74
78
|
disabled={resolved.disabled}
|
|
75
79
|
bind:value
|
|
76
80
|
onchange={handleChange}
|
|
@@ -21,6 +21,11 @@
|
|
|
21
21
|
errorMessage?: string;
|
|
22
22
|
disabled?: boolean;
|
|
23
23
|
bindData?: boolean;
|
|
24
|
+
/** BCP 47 locale for the calendar, displayed date and built-in labels. */
|
|
25
|
+
locale?: string;
|
|
26
|
+
cancelLabel?: string;
|
|
27
|
+
saveLabel?: string;
|
|
28
|
+
minuteStep?: number;
|
|
24
29
|
class?: string;
|
|
25
30
|
onchange?: (detail: { date: string; time: string; value: string }) => void;
|
|
26
31
|
}
|
|
@@ -28,7 +33,7 @@
|
|
|
28
33
|
let {
|
|
29
34
|
name,
|
|
30
35
|
label,
|
|
31
|
-
placeholder
|
|
36
|
+
placeholder,
|
|
32
37
|
value = $bindable(''),
|
|
33
38
|
date = $bindable(''),
|
|
34
39
|
time = $bindable(''),
|
|
@@ -38,6 +43,10 @@
|
|
|
38
43
|
errorMessage,
|
|
39
44
|
disabled = false,
|
|
40
45
|
bindData = false,
|
|
46
|
+
locale,
|
|
47
|
+
cancelLabel,
|
|
48
|
+
saveLabel,
|
|
49
|
+
minuteStep,
|
|
41
50
|
class: className = '',
|
|
42
51
|
onchange
|
|
43
52
|
}: FormDateTimePickerProps = $props();
|
|
@@ -77,6 +86,10 @@
|
|
|
77
86
|
{placeholder}
|
|
78
87
|
{min}
|
|
79
88
|
{max}
|
|
89
|
+
{locale}
|
|
90
|
+
{cancelLabel}
|
|
91
|
+
{saveLabel}
|
|
92
|
+
{minuteStep}
|
|
80
93
|
disabled={resolved.disabled}
|
|
81
94
|
bind:value
|
|
82
95
|
bind:date
|
|
@@ -11,6 +11,11 @@ interface FormDateTimePickerProps {
|
|
|
11
11
|
errorMessage?: string;
|
|
12
12
|
disabled?: boolean;
|
|
13
13
|
bindData?: boolean;
|
|
14
|
+
/** BCP 47 locale for the calendar, displayed date and built-in labels. */
|
|
15
|
+
locale?: string;
|
|
16
|
+
cancelLabel?: string;
|
|
17
|
+
saveLabel?: string;
|
|
18
|
+
minuteStep?: number;
|
|
14
19
|
class?: string;
|
|
15
20
|
onchange?: (detail: {
|
|
16
21
|
date: string;
|
|
@@ -75,14 +75,15 @@
|
|
|
75
75
|
fullWidth && 'w-full'
|
|
76
76
|
]}
|
|
77
77
|
>
|
|
78
|
-
{#each items as item, index (item
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
78
|
+
{#each items as item, index (item?.id ?? index)}
|
|
79
|
+
{#if item}
|
|
80
|
+
<button
|
|
81
|
+
type="button"
|
|
82
|
+
id={`tab-${item.id}`}
|
|
83
|
+
role="tab"
|
|
84
|
+
aria-selected={activeId === item.id}
|
|
85
|
+
aria-controls={`panel-${item.id}`}
|
|
86
|
+
tabindex={activeId === item.id ? 0 : -1}
|
|
86
87
|
disabled={item.disabled}
|
|
87
88
|
onclick={() => select(item.id, item.disabled)}
|
|
88
89
|
onkeydown={(e) => onKeydown(e, index)}
|
|
@@ -108,6 +109,7 @@
|
|
|
108
109
|
></span>
|
|
109
110
|
{/if}
|
|
110
111
|
</button>
|
|
111
|
-
{/
|
|
112
|
+
{/if}
|
|
113
|
+
{/each}
|
|
112
114
|
</div>
|
|
113
115
|
</div>
|
package/dist/utils/i18n.d.ts
CHANGED
package/dist/utils/i18n.js
CHANGED
|
@@ -5,6 +5,9 @@ const en = {
|
|
|
5
5
|
reset: 'Reset',
|
|
6
6
|
submit: 'Submit',
|
|
7
7
|
close: 'Close',
|
|
8
|
+
time: 'Time',
|
|
9
|
+
clear: 'Clear',
|
|
10
|
+
selectDateTime: 'Select date & time',
|
|
8
11
|
optional: 'Optional',
|
|
9
12
|
required: 'Required',
|
|
10
13
|
loading: 'Loading…',
|
|
@@ -52,6 +55,9 @@ const es = {
|
|
|
52
55
|
reset: 'Restablecer',
|
|
53
56
|
submit: 'Enviar',
|
|
54
57
|
close: 'Cerrar',
|
|
58
|
+
time: 'Hora',
|
|
59
|
+
clear: 'Borrar',
|
|
60
|
+
selectDateTime: 'Selecciona fecha y hora',
|
|
55
61
|
optional: 'Opcional',
|
|
56
62
|
required: 'Obligatorio',
|
|
57
63
|
loading: 'Cargando…',
|
|
@@ -99,6 +105,9 @@ const pt = {
|
|
|
99
105
|
reset: 'Repor',
|
|
100
106
|
submit: 'Enviar',
|
|
101
107
|
close: 'Fechar',
|
|
108
|
+
time: 'Hora',
|
|
109
|
+
clear: 'Limpar',
|
|
110
|
+
selectDateTime: 'Selecione data e hora',
|
|
102
111
|
optional: 'Opcional',
|
|
103
112
|
required: 'Obrigatório',
|
|
104
113
|
loading: 'A carregar…',
|
|
@@ -146,6 +155,9 @@ const fr = {
|
|
|
146
155
|
reset: 'Réinitialiser',
|
|
147
156
|
submit: 'Envoyer',
|
|
148
157
|
close: 'Fermer',
|
|
158
|
+
time: 'Heure',
|
|
159
|
+
clear: 'Effacer',
|
|
160
|
+
selectDateTime: 'Choisir la date et l’heure',
|
|
149
161
|
optional: 'Facultatif',
|
|
150
162
|
required: 'Obligatoire',
|
|
151
163
|
loading: 'Chargement…',
|
|
@@ -193,6 +205,9 @@ const de = {
|
|
|
193
205
|
reset: 'Zurücksetzen',
|
|
194
206
|
submit: 'Senden',
|
|
195
207
|
close: 'Schließen',
|
|
208
|
+
time: 'Uhrzeit',
|
|
209
|
+
clear: 'Löschen',
|
|
210
|
+
selectDateTime: 'Datum und Uhrzeit wählen',
|
|
196
211
|
optional: 'Optional',
|
|
197
212
|
required: 'Pflichtfeld',
|
|
198
213
|
loading: 'Wird geladen…',
|
|
@@ -240,6 +255,9 @@ const ca = {
|
|
|
240
255
|
reset: 'Restablir',
|
|
241
256
|
submit: 'Enviar',
|
|
242
257
|
close: 'Tancar',
|
|
258
|
+
time: 'Hora',
|
|
259
|
+
clear: 'Esborra',
|
|
260
|
+
selectDateTime: 'Tria data i hora',
|
|
243
261
|
optional: 'Opcional',
|
|
244
262
|
required: 'Obligatori',
|
|
245
263
|
loading: 'S’està carregant…',
|