@r2digisolutions/components 0.8.5 → 0.8.6
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.
|
@@ -62,7 +62,22 @@
|
|
|
62
62
|
const today = new Date();
|
|
63
63
|
const todayIso = `${today.getFullYear()}-${String(today.getMonth() + 1).padStart(2, '0')}-${String(today.getDate()).padStart(2, '0')}`;
|
|
64
64
|
|
|
65
|
-
|
|
65
|
+
function monthFromIso(iso: string | undefined) {
|
|
66
|
+
if (!iso) return null;
|
|
67
|
+
const [y, m] = iso.split('-').map(Number);
|
|
68
|
+
if (!Number.isFinite(y) || !Number.isFinite(m)) return null;
|
|
69
|
+
return new Date(y, m - 1, 1);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function selectionIso() {
|
|
73
|
+
if (mode === 'range') return start;
|
|
74
|
+
if (mode === 'multiple') return values[0];
|
|
75
|
+
return value;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
let view = $state(
|
|
79
|
+
monthFromIso(selectionIso()) ?? new Date(today.getFullYear(), today.getMonth(), 1)
|
|
80
|
+
);
|
|
66
81
|
let panel = $state<Panel>('days');
|
|
67
82
|
/** Which month column owns the month/year picker when months=2. */
|
|
68
83
|
let pickerOffset = $state(0);
|
|
@@ -433,50 +433,52 @@
|
|
|
433
433
|
months === 2 ? 'max-w-[min(42rem,calc(100vw-1rem))]' : 'max-w-[20rem]'
|
|
434
434
|
]}
|
|
435
435
|
>
|
|
436
|
-
{#
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
436
|
+
{#key `${open}:${start}:${value}`}
|
|
437
|
+
{#if mode === 'single'}
|
|
438
|
+
<Calendar
|
|
439
|
+
mode="single"
|
|
440
|
+
{months}
|
|
441
|
+
bind:value
|
|
442
|
+
{min}
|
|
443
|
+
{max}
|
|
444
|
+
{disabledDates}
|
|
445
|
+
{enabledDates}
|
|
446
|
+
{dots}
|
|
447
|
+
framed={false}
|
|
448
|
+
locale={dateLocale}
|
|
449
|
+
onchange={handleChange}
|
|
450
|
+
/>
|
|
451
|
+
{:else if mode === 'multiple'}
|
|
452
|
+
<Calendar
|
|
453
|
+
mode="multiple"
|
|
454
|
+
{months}
|
|
455
|
+
bind:values
|
|
456
|
+
{min}
|
|
457
|
+
{max}
|
|
458
|
+
{disabledDates}
|
|
459
|
+
{enabledDates}
|
|
460
|
+
{dots}
|
|
461
|
+
framed={false}
|
|
462
|
+
locale={dateLocale}
|
|
463
|
+
onchange={handleChange}
|
|
464
|
+
/>
|
|
465
|
+
{:else}
|
|
466
|
+
<Calendar
|
|
467
|
+
mode="range"
|
|
468
|
+
{months}
|
|
469
|
+
bind:start
|
|
470
|
+
bind:end
|
|
471
|
+
{min}
|
|
472
|
+
{max}
|
|
473
|
+
{disabledDates}
|
|
474
|
+
{enabledDates}
|
|
475
|
+
{dots}
|
|
476
|
+
framed={false}
|
|
477
|
+
locale={dateLocale}
|
|
478
|
+
onchange={handleChange}
|
|
479
|
+
/>
|
|
480
|
+
{/if}
|
|
481
|
+
{/key}
|
|
480
482
|
</div>
|
|
481
483
|
</div>
|
|
482
484
|
|