@pine-ds/core 4.9.1 → 4.11.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.
- package/components/pds-checkbox2.js +1 -1
- package/components/pds-chip2.js +1 -1
- package/components/pds-combobox.js +2 -2
- package/components/pds-datepicker.js +1 -1
- package/components/pds-dropdown-menu.js +1 -1
- package/components/truncation-tooltip.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/pds-checkbox.cjs.entry.js +1 -1
- package/dist/cjs/pds-chip.cjs.entry.js +5 -3
- package/dist/cjs/pds-combobox.cjs.entry.js +101 -15
- package/dist/cjs/pds-copytext.cjs.entry.js +1 -1
- package/dist/cjs/pds-datepicker.cjs.entry.js +253 -75
- package/dist/cjs/pds-dropdown-menu.cjs.entry.js +58 -46
- package/dist/cjs/pds-table-cell.cjs.entry.js +1 -1
- package/dist/cjs/pds-text.cjs.entry.js +1 -1
- package/dist/cjs/pine-core.cjs.js +1 -1
- package/dist/cjs/{truncation-tooltip-DdB78RIe.js → truncation-tooltip-Bikp7n9I.js} +1 -1
- package/dist/collection/components/pds-checkbox/pds-checkbox.css +20 -14
- package/dist/collection/components/pds-chip/pds-chip.js +4 -2
- package/dist/collection/components/pds-combobox/grouped-options-panel.js +39 -1
- package/dist/collection/components/pds-combobox/pds-combobox.css +37 -1
- package/dist/collection/components/pds-combobox/pds-combobox.js +62 -14
- package/dist/collection/components/pds-combobox/stories/pds-combobox.stories.js +48 -0
- package/dist/collection/components/pds-datepicker/date-utils.js +42 -0
- package/dist/collection/components/pds-datepicker/pds-datepicker.js +163 -64
- package/dist/collection/components/pds-datepicker/stories/pds-datepicker.stories.js +11 -0
- package/dist/collection/components/pds-datepicker/value.js +76 -18
- package/dist/collection/components/pds-dropdown-menu/pds-dropdown-menu.js +64 -46
- package/dist/collection/utils/truncation-tooltip.js +1 -1
- package/dist/docs.json +42 -7
- package/dist/esm/loader.js +1 -1
- package/dist/esm/pds-checkbox.entry.js +1 -1
- package/dist/esm/pds-chip.entry.js +5 -3
- package/dist/esm/pds-combobox.entry.js +101 -15
- package/dist/esm/pds-copytext.entry.js +1 -1
- package/dist/esm/pds-datepicker.entry.js +253 -75
- package/dist/esm/pds-dropdown-menu.entry.js +58 -46
- package/dist/esm/pds-table-cell.entry.js +1 -1
- package/dist/esm/pds-text.entry.js +1 -1
- package/dist/esm/pine-core.js +1 -1
- package/dist/esm/{truncation-tooltip-CRSdYzpA.js → truncation-tooltip-DBcPipr9.js} +1 -1
- package/dist/esm-es5/loader.js +1 -1
- package/dist/esm-es5/pds-checkbox.entry.js +1 -1
- package/dist/esm-es5/pds-chip.entry.js +1 -1
- package/dist/esm-es5/pds-combobox.entry.js +1 -1
- package/dist/esm-es5/pds-copytext.entry.js +1 -1
- package/dist/esm-es5/pds-datepicker.entry.js +1 -1
- package/dist/esm-es5/pds-dropdown-menu.entry.js +1 -1
- package/dist/esm-es5/pds-table-cell.entry.js +1 -1
- package/dist/esm-es5/pds-text.entry.js +1 -1
- package/dist/esm-es5/pine-core.js +1 -1
- package/dist/esm-es5/truncation-tooltip-DBcPipr9.js +1 -0
- package/dist/pine-core/p-0b7b3fc2.system.entry.js +3 -0
- package/dist/pine-core/{p-9a776443.entry.js → p-124a0a24.entry.js} +1 -1
- package/dist/pine-core/p-128c04e7.entry.js +1 -0
- package/dist/pine-core/p-3359a935.entry.js +1 -0
- package/dist/pine-core/{p-3d34b967.system.entry.js → p-3a1dc752.system.entry.js} +1 -1
- package/dist/pine-core/{p-20079552.system.entry.js → p-639acef8.system.entry.js} +1 -1
- package/dist/pine-core/{p-beb7a430.entry.js → p-97356d4b.entry.js} +1 -1
- package/dist/pine-core/p-BZVUD2on.js +1 -0
- package/dist/pine-core/p-Dj-z_ugg.system.js +1 -0
- package/dist/pine-core/p-XK45dzWR.system.js +1 -1
- package/dist/pine-core/{p-4d1a8803.entry.js → p-afc2f165.entry.js} +1 -1
- package/dist/pine-core/p-c6a9e62c.system.entry.js +1 -0
- package/dist/pine-core/p-d4968f9d.system.entry.js +1 -0
- package/dist/pine-core/p-da8b864a.entry.js +2 -0
- package/dist/pine-core/p-dd7ded84.entry.js +1 -0
- package/dist/pine-core/p-de455073.system.entry.js +1 -0
- package/dist/pine-core/{p-1cc39908.system.entry.js → p-eb56af4a.system.entry.js} +1 -1
- package/dist/pine-core/p-f354dbac.entry.js +1 -0
- package/dist/pine-core/{p-93fd7dd8.system.entry.js → p-f834cb07.system.entry.js} +1 -1
- package/dist/pine-core/pine-core.esm.js +1 -1
- package/dist/types/components/pds-combobox/combobox-interface.d.ts +26 -0
- package/dist/types/components/pds-combobox/grouped-options-panel.d.ts +17 -0
- package/dist/types/components/pds-combobox/pds-combobox.d.ts +12 -2
- package/dist/types/components/pds-datepicker/date-utils.d.ts +19 -0
- package/dist/types/components/pds-datepicker/datepicker-interface.d.ts +2 -1
- package/dist/types/components/pds-datepicker/pds-datepicker.d.ts +30 -5
- package/dist/types/components/pds-datepicker/value.d.ts +14 -2
- package/dist/types/components/pds-dropdown-menu/pds-dropdown-menu.d.ts +4 -0
- package/dist/types/components.d.ts +25 -10
- package/dist/types/utils/truncation-tooltip.d.ts +1 -1
- package/dist/vscode.html-data.json +11 -4
- package/hydrate/index.js +422 -142
- package/hydrate/index.mjs +422 -142
- package/package.json +2 -2
- package/dist/esm-es5/truncation-tooltip-CRSdYzpA.js +0 -1
- package/dist/pine-core/p-37718637.entry.js +0 -1
- package/dist/pine-core/p-383d84f4.entry.js +0 -2
- package/dist/pine-core/p-3e30a761.entry.js +0 -1
- package/dist/pine-core/p-54f1e86f.system.entry.js +0 -1
- package/dist/pine-core/p-73efb1ed.system.entry.js +0 -1
- package/dist/pine-core/p-8436cbfb.entry.js +0 -1
- package/dist/pine-core/p-DQyF6v9Q.system.js +0 -1
- package/dist/pine-core/p-DwQ5Tjis.js +0 -1
- package/dist/pine-core/p-b3d4f97a.system.entry.js +0 -3
- package/dist/pine-core/p-d47b2a6a.system.entry.js +0 -1
- package/dist/pine-core/p-f018af99.entry.js +0 -1
|
@@ -3,11 +3,13 @@ import { autoUpdate, computePosition, flip, hide, offset, shift, size } from "@f
|
|
|
3
3
|
import { calendarSimple, caretDown, caretLeft, caretRight, check, remove } from "@pine-ds/icons/icons";
|
|
4
4
|
import { isSpecTest } from "../../utils/form";
|
|
5
5
|
import { formatMessage, resolveLocale } from "../../i18n";
|
|
6
|
-
import { addDays, addMonths, clampDate, dateFormatter, formatDate, isOutOfRange, isSameDay, localeFirstDayOfWeek, monthWeeks, parseIsoDate, supportedLocale, toIsoDate, today, weekdayColumn, weekdayNames, } from "./date-utils";
|
|
6
|
+
import { addDays, addMonths, clampDate, dateFormatter, daysInMonth, formatDate, isOutOfRange, isSameDay, localeFirstDayOfWeek, inMonthDayYear, monthDayRows, monthWeeks, parseIsoDate, parseMonthDay, supportedLocale, toIsoDate, toMonthDay, today, weekdayColumn, weekdayNames, } from "./date-utils";
|
|
7
7
|
import { CalendarPortal } from "./calendar-portal";
|
|
8
8
|
import { matchPreset, presetInRange, resolvePresets } from "./presets";
|
|
9
|
-
import { RANGE_SEPARATOR, clockFor, compareDateTime, fieldFormat, joinTime, parseDateTime, parseFieldText, parseRangeText, splitTime, toFieldText, toValueString, } from "./value";
|
|
9
|
+
import { RANGE_SEPARATOR, clockFor, compareDateTime, fieldFormat, joinTime, monthDayFormat, parseDateTime, parseFieldText, parseMonthDayText, parseRangeText, splitTime, formatWith, toFieldText, toValueString, } from "./value";
|
|
10
10
|
const FULL_DATE = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' };
|
|
11
|
+
/** A day in month-day mode, which has no year and so no weekday. */
|
|
12
|
+
const MONTH_AND_DAY = { month: 'long', day: 'numeric' };
|
|
11
13
|
const DEFAULT_START_TIME = '00:00';
|
|
12
14
|
const DEFAULT_END_TIME = '23:59';
|
|
13
15
|
/** Ids for datepickers without a `component-id`, so their calendars' ids stay unique. */
|
|
@@ -35,7 +37,8 @@ const dayNumberText = (formatter, date) => { var _a, _b; return (_b = (_a = form
|
|
|
35
37
|
/**
|
|
36
38
|
* A field for one date, or in range mode a start and end date, with a calendar to pick from.
|
|
37
39
|
* The value is `YYYY-MM-DD`, or `YYYY-MM-DD/YYYY-MM-DD` for a range; with the time picker, each
|
|
38
|
-
* date carries a time, as `YYYY-MM-DDTHH:mm`.
|
|
40
|
+
* date carries a time, as `YYYY-MM-DDTHH:mm`. In month-day mode, for a date that comes round every
|
|
41
|
+
* year such as a birthday, it's a month and day with no year, as `--MM-DD`.
|
|
39
42
|
*
|
|
40
43
|
* @part calendar - The open calendar. It's portaled out of the datepicker, so style it with `.pds-datepicker-calendar-portal::part(calendar)`.
|
|
41
44
|
* @part presets - The list of preset ranges in the calendar, styled with `.pds-datepicker-calendar-portal::part(presets)`.
|
|
@@ -90,8 +93,10 @@ export class PdsDatepicker {
|
|
|
90
93
|
* in the locale), `MM` or `M` (month), `DD` or `D` (day), and with the time picker `HH` or `H`
|
|
91
94
|
* (24-hour), `hh` or `h` (12-hour), `mm` and `A` (AM/PM, in the locale), as `MM/DD/YYYY`,
|
|
92
95
|
* `MMM D, YYYY` or `D.M.YYYY h:mm A`. Put literal text in brackets, as `[Due] D/M/YYYY`. The value
|
|
93
|
-
* and the change event stay ISO (`YYYY-MM-DD`), whatever the format.
|
|
94
|
-
* accepted too.
|
|
96
|
+
* and the change event stay ISO (`YYYY-MM-DD`; `--MM-DD` with `month-day`), whatever the format.
|
|
97
|
+
* Typed ISO dates are always accepted too. With `month-day`, a format without `YYYY` is taken as a
|
|
98
|
+
* month-and-day format and used as given, rather than reordered for the locale; leave it unset to
|
|
99
|
+
* follow the locale instead.
|
|
95
100
|
*/
|
|
96
101
|
this.format = 'YYYY-MM-DD';
|
|
97
102
|
/**
|
|
@@ -124,6 +129,15 @@ export class PdsDatepicker {
|
|
|
124
129
|
* Accessible label for the month dropdown, when `show-dropdowns` is set.
|
|
125
130
|
*/
|
|
126
131
|
this.monthLabel = 'Month';
|
|
132
|
+
/**
|
|
133
|
+
* Picks a month and day with no year, for a date that comes round every year, such as a birthday.
|
|
134
|
+
* The value is `--MM-DD` (ISO 8601 without a year), the field shows the date as the locale writes
|
|
135
|
+
* a month and day, and the calendar shows each month without a year or weekdays, with February
|
|
136
|
+
* always having its 29th. Turns off `range`, `time-picker`, `show-dropdowns`, `min` and `max`, and
|
|
137
|
+
* has no effect with `auto-apply`, `presets`, `first-day-of-week`, `min-date-message` or
|
|
138
|
+
* `max-date-message`, which all depend on them.
|
|
139
|
+
*/
|
|
140
|
+
this.monthDay = false;
|
|
127
141
|
/**
|
|
128
142
|
* Accessible label for the button that shows the next month.
|
|
129
143
|
*/
|
|
@@ -172,7 +186,9 @@ export class PdsDatepicker {
|
|
|
172
186
|
this.triggerLabel = 'Choose date';
|
|
173
187
|
/**
|
|
174
188
|
* The selected date as `YYYY-MM-DD`, or in range mode the range as `YYYY-MM-DD/YYYY-MM-DD`; with
|
|
175
|
-
* the time picker, each date as `YYYY-MM-DDTHH:mm
|
|
189
|
+
* the time picker, each date as `YYYY-MM-DDTHH:mm`; with `month-day`, the month and day with no
|
|
190
|
+
* year, as `--MM-DD` (a full date is read too, as that month and day, and rewritten to it). An
|
|
191
|
+
* empty string when nothing is selected.
|
|
176
192
|
*/
|
|
177
193
|
this.value = '';
|
|
178
194
|
/**
|
|
@@ -363,17 +379,17 @@ export class PdsDatepicker {
|
|
|
363
379
|
// The times before the typed text changed them, for a pick in the calendar to go back to.
|
|
364
380
|
(_b = this.timesBeforeTyping) !== null && _b !== void 0 ? _b : (this.timesBeforeTyping = [startTime, endTime]);
|
|
365
381
|
this.loadDraft(parts);
|
|
366
|
-
if (this.
|
|
382
|
+
if (this.hasTime) {
|
|
367
383
|
// A time picked in the calendar survives typing that doesn't change the time: text with no
|
|
368
384
|
// time, as a date part-way typed, or with the time as committed.
|
|
369
385
|
const format = this.resolvedFormat;
|
|
370
386
|
const locale = this.resolvedLocale;
|
|
371
|
-
const typed = this.
|
|
387
|
+
const typed = this.isRange ? parseRangeText(this.text, format, locale) : [parseFieldText(this.text, format, locale)];
|
|
372
388
|
const committed = this.parsedValue();
|
|
373
389
|
const keeps = (i) => { var _a, _b, _c; return !((_a = typed === null || typed === void 0 ? void 0 : typed[i]) === null || _a === void 0 ? void 0 : _a.time) || ((_b = typed[i]) === null || _b === void 0 ? void 0 : _b.time) === ((_c = committed === null || committed === void 0 ? void 0 : committed[i]) === null || _c === void 0 ? void 0 : _c.time); };
|
|
374
390
|
if (keeps(0))
|
|
375
391
|
this.startTime = startTime;
|
|
376
|
-
if (this.
|
|
392
|
+
if (this.isRange && keeps(1))
|
|
377
393
|
this.endTime = endTime;
|
|
378
394
|
}
|
|
379
395
|
this.showDate(parts[parts.length - 1].date);
|
|
@@ -482,7 +498,8 @@ export class PdsDatepicker {
|
|
|
482
498
|
if (!active)
|
|
483
499
|
return;
|
|
484
500
|
const rtl = getComputedStyle(this.el).direction === 'rtl';
|
|
485
|
-
|
|
501
|
+
// Month-day mode's rows start on the 1st, not on a weekday.
|
|
502
|
+
const column = this.monthDay ? (active.getUTCDate() - 1) % 7 : weekdayColumn(active, this.weekStart);
|
|
486
503
|
let next = null;
|
|
487
504
|
switch (event.key) {
|
|
488
505
|
case 'ArrowLeft':
|
|
@@ -500,14 +517,21 @@ export class PdsDatepicker {
|
|
|
500
517
|
case 'Home':
|
|
501
518
|
next = addDays(active, -column);
|
|
502
519
|
break;
|
|
503
|
-
case 'End':
|
|
504
|
-
next
|
|
520
|
+
case 'End': {
|
|
521
|
+
// Month-day mode's rows don't carry into the next month, so End stops at the month's last day.
|
|
522
|
+
const lastColumn = this.monthDay
|
|
523
|
+
? Math.min(6, daysInMonth(active.getUTCFullYear(), active.getUTCMonth()) - active.getUTCDate() + column)
|
|
524
|
+
: 6;
|
|
525
|
+
next = addDays(active, lastColumn - column);
|
|
505
526
|
break;
|
|
527
|
+
}
|
|
506
528
|
case 'PageUp':
|
|
507
|
-
|
|
529
|
+
// Month-day mode has no year to jump by, so Shift+PageUp stays put rather than passing
|
|
530
|
+
// through a real, possibly non-leap year and clamping Feb 29 to the 28th.
|
|
531
|
+
next = event.shiftKey && this.monthDay ? active : addMonths(active, event.shiftKey ? -12 : -1);
|
|
508
532
|
break;
|
|
509
533
|
case 'PageDown':
|
|
510
|
-
next = addMonths(active, event.shiftKey ? 12 : 1);
|
|
534
|
+
next = event.shiftKey && this.monthDay ? active : addMonths(active, event.shiftKey ? 12 : 1);
|
|
511
535
|
break;
|
|
512
536
|
case 'Enter':
|
|
513
537
|
case ' ':
|
|
@@ -520,9 +544,9 @@ export class PdsDatepicker {
|
|
|
520
544
|
return;
|
|
521
545
|
}
|
|
522
546
|
event.preventDefault();
|
|
523
|
-
const target = clampDate(next, this.minDate, this.maxDate);
|
|
547
|
+
const target = clampDate(this.inView(next), this.minDate, this.maxDate);
|
|
524
548
|
this.showDate(target);
|
|
525
|
-
if (this.
|
|
549
|
+
if (this.isRange)
|
|
526
550
|
this.previewDate = toIsoDate(target);
|
|
527
551
|
this.focusActiveDay = true;
|
|
528
552
|
};
|
|
@@ -533,7 +557,7 @@ export class PdsDatepicker {
|
|
|
533
557
|
this.pickDate(date);
|
|
534
558
|
};
|
|
535
559
|
this.onGridPointerOver = (event) => {
|
|
536
|
-
if (!this.
|
|
560
|
+
if (!this.isRange || !this.draftStart || this.draftEnd)
|
|
537
561
|
return;
|
|
538
562
|
const date = this.dayFromEvent(event);
|
|
539
563
|
const iso = date && toIsoDate(date);
|
|
@@ -582,19 +606,28 @@ export class PdsDatepicker {
|
|
|
582
606
|
var _a;
|
|
583
607
|
this.text = this.fieldText();
|
|
584
608
|
this.textError = '';
|
|
609
|
+
const parts = this.parsedValue();
|
|
610
|
+
// A full date reads as its month and day; keep what's submitted in step with what's shown,
|
|
611
|
+
// rather than passing through whichever spelling was set until the next pick rewrites it.
|
|
612
|
+
if (this.monthDay && parts) {
|
|
613
|
+
const normalized = this.dayValue(parts[0].date);
|
|
614
|
+
if (this.value !== normalized)
|
|
615
|
+
this.value = normalized;
|
|
616
|
+
}
|
|
585
617
|
this.updateFormValue();
|
|
586
618
|
if (!this.isOpen)
|
|
587
619
|
return;
|
|
588
|
-
const parts = this.parsedValue();
|
|
589
620
|
this.loadDraft(parts);
|
|
590
|
-
const day = (_a = (parts && parts[parts.length - 1].date)) !== null && _a !== void 0 ? _a :
|
|
621
|
+
const day = (_a = (parts && parts[parts.length - 1].date)) !== null && _a !== void 0 ? _a : this.now;
|
|
591
622
|
this.showDate(clampDate(day, this.minDate, this.maxDate), true);
|
|
592
623
|
}
|
|
593
624
|
requiredChanged() {
|
|
594
625
|
this.updateFormValue();
|
|
595
626
|
}
|
|
596
627
|
componentWillLoad() {
|
|
597
|
-
|
|
628
|
+
// Through the same path a later value/context change takes, so an initial full date in
|
|
629
|
+
// month-day mode submits normalized too, not only after the first pick rewrites it.
|
|
630
|
+
this.refreshFromValue();
|
|
598
631
|
}
|
|
599
632
|
connectedCallback() {
|
|
600
633
|
if (this.el.attachInternals && !this.internals) {
|
|
@@ -644,10 +677,30 @@ export class PdsDatepicker {
|
|
|
644
677
|
return localeFirstDayOfWeek(this.resolvedLocale);
|
|
645
678
|
}
|
|
646
679
|
get minDate() {
|
|
647
|
-
return parseIsoDate(this.min);
|
|
680
|
+
return this.monthDay ? null : parseIsoDate(this.min);
|
|
648
681
|
}
|
|
649
682
|
get maxDate() {
|
|
650
|
-
return parseIsoDate(this.max);
|
|
683
|
+
return this.monthDay ? null : parseIsoDate(this.max);
|
|
684
|
+
}
|
|
685
|
+
/** Range mode, which month-day mode turns off. */
|
|
686
|
+
get isRange() {
|
|
687
|
+
return this.range && !this.monthDay;
|
|
688
|
+
}
|
|
689
|
+
/** The time picker, which month-day mode turns off. */
|
|
690
|
+
get hasTime() {
|
|
691
|
+
return this.timePicker && !this.monthDay;
|
|
692
|
+
}
|
|
693
|
+
/** Today, or in month-day mode today's month and day. */
|
|
694
|
+
get now() {
|
|
695
|
+
return this.monthDay ? inMonthDayYear(today()) : today();
|
|
696
|
+
}
|
|
697
|
+
/** In month-day mode, a date moved to the mode's year, as when the calendar wraps past December. */
|
|
698
|
+
inView(date) {
|
|
699
|
+
return this.monthDay ? inMonthDayYear(date) : date;
|
|
700
|
+
}
|
|
701
|
+
/** One day as the value holds it: `YYYY-MM-DD`, or `--MM-DD` in month-day mode. */
|
|
702
|
+
dayValue(date) {
|
|
703
|
+
return this.monthDay ? toMonthDay(date) : toIsoDate(date);
|
|
651
704
|
}
|
|
652
705
|
get isInteractive() {
|
|
653
706
|
return !this.disabled && !this.readonly;
|
|
@@ -655,22 +708,22 @@ export class PdsDatepicker {
|
|
|
655
708
|
/** How many months the calendar shows side by side. */
|
|
656
709
|
get monthCount() {
|
|
657
710
|
const narrow = typeof window !== 'undefined' && window.innerWidth < TWO_MONTHS_MIN_WIDTH;
|
|
658
|
-
return this.
|
|
711
|
+
return this.isRange && !narrow ? 2 : 1;
|
|
659
712
|
}
|
|
660
713
|
/** Whether picks apply at once, without the footer: `auto-apply` in range mode, without times. */
|
|
661
714
|
get appliesOnPick() {
|
|
662
|
-
return this.
|
|
715
|
+
return this.isRange && this.autoApply && !this.hasTime;
|
|
663
716
|
}
|
|
664
717
|
/** Whether picks wait for Apply: for a range, unless it auto-applies, and for a date with a time. */
|
|
665
718
|
get hasFooter() {
|
|
666
|
-
return (this.
|
|
719
|
+
return (this.isRange || this.hasTime) && !this.appliesOnPick;
|
|
667
720
|
}
|
|
668
721
|
get resolvedPresets() {
|
|
669
|
-
return this.
|
|
722
|
+
return this.isRange ? resolvePresets(this.presets, today()) : [];
|
|
670
723
|
}
|
|
671
724
|
/** The committed value, parsed: one date, or a range's start and end. */
|
|
672
725
|
parsedValue(value = this.value) {
|
|
673
|
-
if (this.
|
|
726
|
+
if (this.isRange) {
|
|
674
727
|
const [start, end, extra] = (value !== null && value !== void 0 ? value : '').split('/');
|
|
675
728
|
const startValue = parseDateTime(start);
|
|
676
729
|
const endValue = parseDateTime(end);
|
|
@@ -678,12 +731,22 @@ export class PdsDatepicker {
|
|
|
678
731
|
? [startValue, endValue]
|
|
679
732
|
: null;
|
|
680
733
|
}
|
|
734
|
+
if (this.monthDay) {
|
|
735
|
+
const date = parseMonthDay(value);
|
|
736
|
+
return date ? [{ date, time: null }] : null;
|
|
737
|
+
}
|
|
681
738
|
const single = parseDateTime(value);
|
|
682
739
|
return single ? [single] : null;
|
|
683
740
|
}
|
|
684
741
|
/** The format the field shows and reads, with a time when the time picker is on. */
|
|
685
742
|
get resolvedFormat() {
|
|
686
|
-
|
|
743
|
+
var _a, _b;
|
|
744
|
+
if (this.monthDay) {
|
|
745
|
+
// A format with a year is the default, or one for full dates: use the locale's month and day.
|
|
746
|
+
const format = (_b = (_a = this.format) === null || _a === void 0 ? void 0 : _a.trim()) !== null && _b !== void 0 ? _b : '';
|
|
747
|
+
return format !== '' && !/YYYY/.test(format.replace(/\[[^\]]*\]/g, '')) ? format : monthDayFormat(this.resolvedLocale);
|
|
748
|
+
}
|
|
749
|
+
return fieldFormat(this.format, this.hasTime, this.hasTime && clockFor(this.resolvedLocale).hour12);
|
|
687
750
|
}
|
|
688
751
|
/** What the field shows for the committed value. */
|
|
689
752
|
fieldText() {
|
|
@@ -699,20 +762,24 @@ export class PdsDatepicker {
|
|
|
699
762
|
/** Drops a time the time picker doesn't show, or adds the default one it does. */
|
|
700
763
|
withTimePicker(value, fallback = DEFAULT_START_TIME) {
|
|
701
764
|
var _a;
|
|
702
|
-
return { date: value.date, time: this.
|
|
765
|
+
return { date: value.date, time: this.hasTime ? ((_a = value.time) !== null && _a !== void 0 ? _a : fallback) : null };
|
|
703
766
|
}
|
|
704
767
|
get fieldPlaceholder() {
|
|
705
768
|
if (this.placeholder)
|
|
706
769
|
return this.placeholder;
|
|
770
|
+
// Month-day tokens, as `MMMM D`, don't read as a hint; an example date does.
|
|
771
|
+
if (this.monthDay) {
|
|
772
|
+
return formatWith({ date: parseMonthDay('--12-31'), time: null }, this.resolvedFormat, this.resolvedLocale);
|
|
773
|
+
}
|
|
707
774
|
const one = this.resolvedFormat;
|
|
708
|
-
return this.
|
|
775
|
+
return this.isRange ? `${one}${RANGE_SEPARATOR}${one}` : one;
|
|
709
776
|
}
|
|
710
777
|
/** Loads the committed value into the draft the calendar edits. */
|
|
711
778
|
loadDraft(parts) {
|
|
712
779
|
var _a, _b;
|
|
713
780
|
const [start, end] = parts !== null && parts !== void 0 ? parts : [];
|
|
714
781
|
this.draftStart = start ? toIsoDate(start.date) : '';
|
|
715
|
-
this.draftEnd = this.
|
|
782
|
+
this.draftEnd = this.isRange && end ? toIsoDate(end.date) : '';
|
|
716
783
|
this.startTime = (_a = start === null || start === void 0 ? void 0 : start.time) !== null && _a !== void 0 ? _a : DEFAULT_START_TIME;
|
|
717
784
|
this.endTime = (_b = end === null || end === void 0 ? void 0 : end.time) !== null && _b !== void 0 ? _b : DEFAULT_END_TIME;
|
|
718
785
|
this.previewDate = '';
|
|
@@ -728,7 +795,7 @@ export class PdsDatepicker {
|
|
|
728
795
|
const parts = this.parsedValue();
|
|
729
796
|
this.loadDraft(parts);
|
|
730
797
|
this.valueAtOpen = (_a = this.value) !== null && _a !== void 0 ? _a : '';
|
|
731
|
-
const start = (_b = (parts && parts[parts.length - 1].date)) !== null && _b !== void 0 ? _b :
|
|
798
|
+
const start = (_b = (parts && parts[parts.length - 1].date)) !== null && _b !== void 0 ? _b : this.now;
|
|
732
799
|
this.showDate(clampDate(start, this.minDate, this.maxDate), true);
|
|
733
800
|
this.focusActiveDay = focusDay;
|
|
734
801
|
this.isOpen = true;
|
|
@@ -750,7 +817,8 @@ export class PdsDatepicker {
|
|
|
750
817
|
* Makes a day the active one and brings it into view. With two months, a day already on view
|
|
751
818
|
* doesn't move the view; `reset` lines the view up so the day is in the last month shown.
|
|
752
819
|
*/
|
|
753
|
-
showDate(
|
|
820
|
+
showDate(day, reset = false) {
|
|
821
|
+
const date = this.inView(day);
|
|
754
822
|
const first = firstOfMonth(date);
|
|
755
823
|
const view = parseIsoDate(this.viewMonth);
|
|
756
824
|
const lastView = view && addMonths(view, this.monthCount - 1);
|
|
@@ -768,15 +836,15 @@ export class PdsDatepicker {
|
|
|
768
836
|
// A pick in the calendar takes over from typed text, so dismissing afterwards commits nothing,
|
|
769
837
|
// as when nothing was typed.
|
|
770
838
|
this.dropTypedText();
|
|
771
|
-
if (this.
|
|
839
|
+
if (this.isRange) {
|
|
772
840
|
this.pickRangeDay(date);
|
|
773
841
|
}
|
|
774
|
-
else if (this.
|
|
842
|
+
else if (this.hasTime) {
|
|
775
843
|
this.draftStart = toIsoDate(date);
|
|
776
844
|
this.activeDate = this.draftStart;
|
|
777
845
|
}
|
|
778
846
|
else {
|
|
779
|
-
this.commitValue(
|
|
847
|
+
this.commitValue(this.dayValue(date));
|
|
780
848
|
this.closeCalendar(true);
|
|
781
849
|
}
|
|
782
850
|
}
|
|
@@ -820,7 +888,11 @@ export class PdsDatepicker {
|
|
|
820
888
|
}
|
|
821
889
|
/** Commits one date, or a range with its start, end and matching preset. */
|
|
822
890
|
commitParts(parts) {
|
|
823
|
-
if (
|
|
891
|
+
if (this.monthDay) {
|
|
892
|
+
this.commitValue(toMonthDay(parts[0].date));
|
|
893
|
+
return;
|
|
894
|
+
}
|
|
895
|
+
if (!this.isRange) {
|
|
824
896
|
this.commitValue(toValueString(parts[0]));
|
|
825
897
|
return;
|
|
826
898
|
}
|
|
@@ -835,7 +907,7 @@ export class PdsDatepicker {
|
|
|
835
907
|
if (!startDate)
|
|
836
908
|
return null;
|
|
837
909
|
const start = this.withTimePicker({ date: startDate, time: this.startTime });
|
|
838
|
-
if (!this.
|
|
910
|
+
if (!this.isRange)
|
|
839
911
|
return [start];
|
|
840
912
|
const end = this.withTimePicker({ date: (_a = parseIsoDate(this.draftEnd)) !== null && _a !== void 0 ? _a : startDate, time: this.endTime });
|
|
841
913
|
// An end time before the start time on the same day ends at the start.
|
|
@@ -961,7 +1033,11 @@ export class PdsDatepicker {
|
|
|
961
1033
|
readText(text) {
|
|
962
1034
|
const format = this.resolvedFormat;
|
|
963
1035
|
const locale = this.resolvedLocale;
|
|
964
|
-
const parts = this.
|
|
1036
|
+
const parts = this.monthDay
|
|
1037
|
+
? [parseMonthDayText(text, format, locale)]
|
|
1038
|
+
: this.isRange
|
|
1039
|
+
? parseRangeText(text, format, locale)
|
|
1040
|
+
: [parseFieldText(text, format, locale)];
|
|
965
1041
|
if (!parts || parts.some((part) => !part))
|
|
966
1042
|
return null;
|
|
967
1043
|
return parts.map((part, i) => this.withTimePicker(part, i === 1 ? DEFAULT_END_TIME : DEFAULT_START_TIME));
|
|
@@ -1005,17 +1081,17 @@ export class PdsDatepicker {
|
|
|
1005
1081
|
/** Whether the month before (`-1`) or after (`1`) the ones on view has a day in range. */
|
|
1006
1082
|
canShowMonth(direction) {
|
|
1007
1083
|
var _a;
|
|
1008
|
-
const view = (_a = parseIsoDate(this.viewMonth)) !== null && _a !== void 0 ? _a :
|
|
1084
|
+
const view = (_a = parseIsoDate(this.viewMonth)) !== null && _a !== void 0 ? _a : this.now;
|
|
1009
1085
|
if (direction < 0)
|
|
1010
1086
|
return !this.minDate || addDays(view, -1) >= this.minDate;
|
|
1011
1087
|
return !this.maxDate || addMonths(view, this.monthCount) <= this.maxDate;
|
|
1012
1088
|
}
|
|
1013
1089
|
showMonth(event, direction) {
|
|
1014
1090
|
var _a, _b;
|
|
1015
|
-
const view = (_a = parseIsoDate(this.viewMonth)) !== null && _a !== void 0 ? _a :
|
|
1016
|
-
const active = (_b = parseIsoDate(this.activeDate)) !== null && _b !== void 0 ? _b :
|
|
1017
|
-
this.viewMonth = toIsoDate(addMonths(view, direction));
|
|
1018
|
-
this.activeDate = toIsoDate(clampDate(addMonths(active, direction), this.minDate, this.maxDate));
|
|
1091
|
+
const view = (_a = parseIsoDate(this.viewMonth)) !== null && _a !== void 0 ? _a : this.now;
|
|
1092
|
+
const active = (_b = parseIsoDate(this.activeDate)) !== null && _b !== void 0 ? _b : this.now;
|
|
1093
|
+
this.viewMonth = toIsoDate(this.inView(addMonths(view, direction)));
|
|
1094
|
+
this.activeDate = toIsoDate(clampDate(this.inView(addMonths(active, direction)), this.minDate, this.maxDate));
|
|
1019
1095
|
if (this.canShowMonth(direction)) {
|
|
1020
1096
|
// Safari doesn't focus a clicked button; without this, focus falls to the page and Escape and
|
|
1021
1097
|
// the Tab trap stop working.
|
|
@@ -1137,7 +1213,7 @@ export class PdsDatepicker {
|
|
|
1137
1213
|
const parts = this.parsedValue();
|
|
1138
1214
|
if (!parts)
|
|
1139
1215
|
return this.triggerLabel;
|
|
1140
|
-
const dates = parts.map((part) => formatDate(part.date, locale, FULL_DATE));
|
|
1216
|
+
const dates = parts.map((part) => formatDate(part.date, locale, this.monthDay ? MONTH_AND_DAY : FULL_DATE));
|
|
1141
1217
|
return `${this.triggerLabel}, ${dates.join(RANGE_SEPARATOR)}`;
|
|
1142
1218
|
}
|
|
1143
1219
|
/** The range to highlight: the chosen one, or the start to the previewed day while picking the end. */
|
|
@@ -1151,15 +1227,15 @@ export class PdsDatepicker {
|
|
|
1151
1227
|
}
|
|
1152
1228
|
/** The day shown as selected: the draft, which opens as the committed day and follows typing. */
|
|
1153
1229
|
selectedDay() {
|
|
1154
|
-
if (this.
|
|
1230
|
+
if (this.isRange)
|
|
1155
1231
|
return null;
|
|
1156
1232
|
return parseIsoDate(this.draftStart);
|
|
1157
1233
|
}
|
|
1158
1234
|
renderMonthHeading(view, index, locale, headingId) {
|
|
1159
|
-
const heading = formatDate(view, locale, { month: 'long', year: 'numeric' });
|
|
1235
|
+
const heading = formatDate(view, locale, this.monthDay ? { month: 'long' } : { month: 'long', year: 'numeric' });
|
|
1160
1236
|
// Only the first month announces itself as it changes; two months move together.
|
|
1161
1237
|
const live = index === 0 ? 'polite' : null;
|
|
1162
|
-
if (!this.showDropdowns) {
|
|
1238
|
+
if (!this.showDropdowns || this.monthDay) {
|
|
1163
1239
|
return (h("div", { class: "pds-datepicker__heading", id: headingId, "aria-live": live }, heading));
|
|
1164
1240
|
}
|
|
1165
1241
|
const year = view.getUTCFullYear();
|
|
@@ -1185,14 +1261,14 @@ export class PdsDatepicker {
|
|
|
1185
1261
|
const min = this.minDate;
|
|
1186
1262
|
const max = this.maxDate;
|
|
1187
1263
|
const selected = this.selectedDay();
|
|
1188
|
-
const [rangeStart, rangeEnd] = this.
|
|
1189
|
-
const now =
|
|
1190
|
-
const fullDate = dateFormatter(locale, FULL_DATE);
|
|
1264
|
+
const [rangeStart, rangeEnd] = this.isRange ? this.highlightedRange() : [null, null];
|
|
1265
|
+
const now = this.now;
|
|
1266
|
+
const fullDate = dateFormatter(locale, this.monthDay ? MONTH_AND_DAY : FULL_DATE);
|
|
1191
1267
|
const dayNumber = dateFormatter(locale, { day: 'numeric' });
|
|
1192
1268
|
const headingId = `${this.baseId}-calendar-heading-${index}`;
|
|
1193
1269
|
const isFirst = index === 0;
|
|
1194
1270
|
const isLast = index === this.monthCount - 1;
|
|
1195
|
-
return (h("div", { class: "pds-datepicker__month" }, h("div", { class: "pds-datepicker__header" }, isFirst ? (h("button", { type: "button", class: "pds-datepicker__nav pds-datepicker__nav--previous", "aria-label": this.previousMonthLabel, disabled: !this.canShowMonth(-1), onClick: (event) => this.showMonth(event, -1) }, h("pds-icon", { icon: caretLeft, "aria-hidden": "true" }))) : (h("span", { class: "pds-datepicker__nav-spacer" })), this.renderMonthHeading(view, index, locale, headingId), isLast ? (h("button", { type: "button", class: "pds-datepicker__nav pds-datepicker__nav--next", "aria-label": this.nextMonthLabel, disabled: !this.canShowMonth(1), onClick: (event) => this.showMonth(event, 1) }, h("pds-icon", { icon: caretRight, "aria-hidden": "true" }))) : (h("span", { class: "pds-datepicker__nav-spacer" }))), h("table", { class: "pds-datepicker__grid", role: "grid", "aria-labelledby": headingId, "aria-multiselectable": this.
|
|
1271
|
+
return (h("div", { class: "pds-datepicker__month" }, h("div", { class: "pds-datepicker__header" }, isFirst ? (h("button", { type: "button", class: "pds-datepicker__nav pds-datepicker__nav--previous", "aria-label": this.previousMonthLabel, disabled: !this.canShowMonth(-1), onClick: (event) => this.showMonth(event, -1) }, h("pds-icon", { icon: caretLeft, "aria-hidden": "true" }))) : (h("span", { class: "pds-datepicker__nav-spacer" })), this.renderMonthHeading(view, index, locale, headingId), isLast ? (h("button", { type: "button", class: "pds-datepicker__nav pds-datepicker__nav--next", "aria-label": this.nextMonthLabel, disabled: !this.canShowMonth(1), onClick: (event) => this.showMonth(event, 1) }, h("pds-icon", { icon: caretRight, "aria-hidden": "true" }))) : (h("span", { class: "pds-datepicker__nav-spacer" }))), h("table", { class: "pds-datepicker__grid", role: "grid", "aria-labelledby": headingId, "aria-multiselectable": this.isRange ? 'true' : null, onKeyDown: this.onGridKeyDown, onClick: this.onGridClick, onPointerOver: this.onGridPointerOver }, !this.monthDay && (h("thead", null, h("tr", null, weekdayNames(locale, this.weekStart).map((name) => (h("th", { scope: "col", class: "pds-datepicker__weekday" }, h("span", { "aria-hidden": "true" }, name.short), h("span", { class: "visually-hidden" }, name.long))))))), h("tbody", null, (this.monthDay ? monthDayRows(month) : monthWeeks(year, month, this.weekStart)).map((week) => (h("tr", null, week.map((date, column) => {
|
|
1196
1272
|
if (!date)
|
|
1197
1273
|
return h("td", { class: "pds-datepicker__day pds-datepicker__day--empty" });
|
|
1198
1274
|
const iso = toIsoDate(date);
|
|
@@ -1214,14 +1290,14 @@ export class PdsDatepicker {
|
|
|
1214
1290
|
'pds-datepicker__day--today': isToday,
|
|
1215
1291
|
'pds-datepicker__day--disabled': unavailable,
|
|
1216
1292
|
}, "data-date": iso, tabindex: iso === this.activeDate ? '0' : '-1', "aria-label": fullDate.format(date), "aria-selected": isSelected ? 'true' : null, "aria-current": isToday ? 'date' : null, "aria-disabled": unavailable ? 'true' : null }, dayNumberText(dayNumber, date)));
|
|
1217
|
-
})))))), this.
|
|
1293
|
+
})))))), this.hasTime && this.timesUnderMonth(index).map((which) => this.renderTime(which, locale))));
|
|
1218
1294
|
}
|
|
1219
1295
|
/**
|
|
1220
1296
|
* The time pickers under a month: the start time under the first and the end time under the
|
|
1221
1297
|
* second, or both under the one month a narrow range shows.
|
|
1222
1298
|
*/
|
|
1223
1299
|
timesUnderMonth(index) {
|
|
1224
|
-
if (!this.
|
|
1300
|
+
if (!this.isRange)
|
|
1225
1301
|
return ['start'];
|
|
1226
1302
|
if (this.monthCount === 1)
|
|
1227
1303
|
return ['start', 'end'];
|
|
@@ -1246,7 +1322,7 @@ export class PdsDatepicker {
|
|
|
1246
1322
|
if (this.timesBeforeTyping)
|
|
1247
1323
|
this.timesBeforeTyping[which === 'start' ? 0 : 1] = time;
|
|
1248
1324
|
};
|
|
1249
|
-
const groupLabel = !this.
|
|
1325
|
+
const groupLabel = !this.isRange ? this.timeLabel : which === 'start' ? this.startTimeLabel : this.endTimeLabel;
|
|
1250
1326
|
const isPm = hours >= 12;
|
|
1251
1327
|
const hourOptions = clock.hour12 ? Array.from({ length: 12 }, (_, i) => i + 1) : Array.from({ length: 24 }, (_, i) => i);
|
|
1252
1328
|
const shownHour = clock.hour12 ? hours % 12 || 12 : hours;
|
|
@@ -1287,7 +1363,7 @@ export class PdsDatepicker {
|
|
|
1287
1363
|
return '';
|
|
1288
1364
|
const format = this.resolvedFormat;
|
|
1289
1365
|
const locale = this.resolvedLocale;
|
|
1290
|
-
if (this.
|
|
1366
|
+
if (this.isRange && !this.draftEnd)
|
|
1291
1367
|
return `${toFieldText(parts[0], format, locale)}${RANGE_SEPARATOR}`;
|
|
1292
1368
|
return parts.map((part) => toFieldText(part, format, locale)).join(RANGE_SEPARATOR);
|
|
1293
1369
|
}
|
|
@@ -1298,25 +1374,25 @@ export class PdsDatepicker {
|
|
|
1298
1374
|
}
|
|
1299
1375
|
renderCalendar(locale) {
|
|
1300
1376
|
var _a;
|
|
1301
|
-
const view = (_a = parseIsoDate(this.viewMonth)) !== null && _a !== void 0 ? _a :
|
|
1377
|
+
const view = (_a = parseIsoDate(this.viewMonth)) !== null && _a !== void 0 ? _a : this.now;
|
|
1302
1378
|
const months = Array.from({ length: this.monthCount }, (_, i) => addMonths(view, i));
|
|
1303
|
-
return (h("div", { class: { 'pds-datepicker__dialog': true, 'pds-datepicker__dialog--range': this.
|
|
1379
|
+
return (h("div", { class: { 'pds-datepicker__dialog': true, 'pds-datepicker__dialog--range': this.isRange }, id: `${this.baseId}-calendar`, role: "dialog",
|
|
1304
1380
|
// A click on a part that can't take focus, as the month heading, focuses the dialog
|
|
1305
1381
|
// rather than dropping focus to the page, which would report blur mid-selection.
|
|
1306
|
-
tabindex: "-1", "aria-labelledby": this.
|
|
1382
|
+
tabindex: "-1", "aria-labelledby": this.isRange ? null : `${this.baseId}-calendar-heading-0`, "aria-label": this.isRange ? this.label || this.triggerLabel : null, part: "calendar", ref: (el) => (this.dialogEl = el), onKeyDown: this.onDialogKeyDown, onFocusin: this.onCalendarFocusIn, onFocusout: this.onCalendarFocusOut }, this.isRange && this.renderPresets(), h("div", { class: "pds-datepicker__panel" }, h("div", { class: "pds-datepicker__months" }, months.map((month, index) => this.renderMonth(month, index, locale))), this.hasFooter && this.renderFooter(), this.appliesOnPick && (
|
|
1307
1383
|
// With no footer, still announce the start once it's picked, so it's clear an end comes next.
|
|
1308
1384
|
h("span", { class: "visually-hidden", "aria-live": "polite" }, this.selectionText())))));
|
|
1309
1385
|
}
|
|
1310
1386
|
render() {
|
|
1311
1387
|
const locale = this.resolvedLocale;
|
|
1312
|
-
return (h(Host, { key: '
|
|
1388
|
+
return (h(Host, { key: '7c5388369fe78becfd26b0807f1c6cb54c7934a1', class: { 'pds-datepicker--range': this.isRange, 'pds-datepicker--time': this.hasTime }, "full-width": this.fullWidth ? 'true' : null, onFocusin: this.onHostFocusIn, onFocusout: this.onHostFocusOut }, h("pds-input", { key: 'fc565c99359715415886ae63ef1bcbf8671569c9', ref: (el) => (this.inputEl = el), componentId: this.baseId, label: this.label, hideLabel: this.hideLabel, helperMessage: this.helperMessage, errorMessage: this.errorMessage, invalid: this.invalid || !!this.textError || !!this.valueError(), disabled: this.disabled, readonly: this.readonly, required: this.required, placeholder: this.fieldPlaceholder, fullWidth: this.fullWidth, autocomplete: "off", value: this.text, onClick: this.onFieldClick, onPdsInput: this.onTextInput, onPdsChange: this.onTextChange, onPdsKeyDown: this.onTextKeyDown, onPdsFocus: this.stopInnerEvent, onPdsBlur: this.stopInnerEvent }, this.clearable && !!this.value && this.isInteractive && (h("button", {
|
|
1313
1389
|
// Keyed, as is the calendar button: when Clear appears after a pick, the focused
|
|
1314
1390
|
// calendar button must stay that button rather than be reused as Clear.
|
|
1315
1391
|
key: "clear", slot: "suffix", type: "button", class: "pds-datepicker__clear", ref: (el) => (this.clearEl = el), "aria-label": this.label ? `${this.clearLabel} ${this.label}` : this.clearLabel,
|
|
1316
1392
|
// Out of the tab order, as a native search field's clear button is: Tab from a field
|
|
1317
1393
|
// just emptied would land on it as the change removes it, dropping focus to the page.
|
|
1318
1394
|
tabindex: "-1", onMouseDown: this.onClearMouseDown, onClick: this.onClearClick
|
|
1319
|
-
}, h("pds-icon", { key: '
|
|
1395
|
+
}, h("pds-icon", { key: '6a7da726d86654d3598f84b8ea7a8ed244a8e5da', icon: remove, "aria-hidden": "true" }))), h("button", { key: "trigger", slot: "suffix", type: "button", class: "pds-datepicker__trigger", ref: (el) => (this.triggerEl = el), "aria-label": this.triggerAccessibleName(locale), "aria-haspopup": "dialog", "aria-expanded": this.isOpen ? 'true' : 'false', disabled: !this.isInteractive, onClick: this.onTriggerClick, onKeyDown: this.onTriggerKeyDown }, h("pds-icon", { key: '92af87e66b7bb2e95861b873077a7bfb0268c2e0', icon: calendarSimple, "aria-hidden": "true" }))), this.isOpen && this.renderCalendar(locale)));
|
|
1320
1396
|
}
|
|
1321
1397
|
static get is() { return "pds-datepicker"; }
|
|
1322
1398
|
static get encapsulation() { return "shadow"; }
|
|
@@ -1561,7 +1637,7 @@ export class PdsDatepicker {
|
|
|
1561
1637
|
"optional": false,
|
|
1562
1638
|
"docs": {
|
|
1563
1639
|
"tags": [],
|
|
1564
|
-
"text": "How the field shows dates and reads typed ones, as tokens: `YYYY`, `MMMM` or `MMM` (month name,\nin the locale), `MM` or `M` (month), `DD` or `D` (day), and with the time picker `HH` or `H`\n(24-hour), `hh` or `h` (12-hour), `mm` and `A` (AM/PM, in the locale), as `MM/DD/YYYY`,\n`MMM D, YYYY` or `D.M.YYYY h:mm A`. Put literal text in brackets, as `[Due] D/M/YYYY`. The value\nand the change event stay ISO (`YYYY-MM-DD`), whatever the format
|
|
1640
|
+
"text": "How the field shows dates and reads typed ones, as tokens: `YYYY`, `MMMM` or `MMM` (month name,\nin the locale), `MM` or `M` (month), `DD` or `D` (day), and with the time picker `HH` or `H`\n(24-hour), `hh` or `h` (12-hour), `mm` and `A` (AM/PM, in the locale), as `MM/DD/YYYY`,\n`MMM D, YYYY` or `D.M.YYYY h:mm A`. Put literal text in brackets, as `[Due] D/M/YYYY`. The value\nand the change event stay ISO (`YYYY-MM-DD`; `--MM-DD` with `month-day`), whatever the format.\nTyped ISO dates are always accepted too. With `month-day`, a format without `YYYY` is taken as a\nmonth-and-day format and used as given, rather than reordered for the locale; leave it unset to\nfollow the locale instead."
|
|
1565
1641
|
},
|
|
1566
1642
|
"getter": false,
|
|
1567
1643
|
"setter": false,
|
|
@@ -1861,6 +1937,26 @@ export class PdsDatepicker {
|
|
|
1861
1937
|
"attribute": "month-label",
|
|
1862
1938
|
"defaultValue": "'Month'"
|
|
1863
1939
|
},
|
|
1940
|
+
"monthDay": {
|
|
1941
|
+
"type": "boolean",
|
|
1942
|
+
"mutable": false,
|
|
1943
|
+
"complexType": {
|
|
1944
|
+
"original": "boolean",
|
|
1945
|
+
"resolved": "boolean",
|
|
1946
|
+
"references": {}
|
|
1947
|
+
},
|
|
1948
|
+
"required": false,
|
|
1949
|
+
"optional": false,
|
|
1950
|
+
"docs": {
|
|
1951
|
+
"tags": [],
|
|
1952
|
+
"text": "Picks a month and day with no year, for a date that comes round every year, such as a birthday.\nThe value is `--MM-DD` (ISO 8601 without a year), the field shows the date as the locale writes\na month and day, and the calendar shows each month without a year or weekdays, with February\nalways having its 29th. Turns off `range`, `time-picker`, `show-dropdowns`, `min` and `max`, and\nhas no effect with `auto-apply`, `presets`, `first-day-of-week`, `min-date-message` or\n`max-date-message`, which all depend on them."
|
|
1953
|
+
},
|
|
1954
|
+
"getter": false,
|
|
1955
|
+
"setter": false,
|
|
1956
|
+
"reflect": false,
|
|
1957
|
+
"attribute": "month-day",
|
|
1958
|
+
"defaultValue": "false"
|
|
1959
|
+
},
|
|
1864
1960
|
"name": {
|
|
1865
1961
|
"type": "string",
|
|
1866
1962
|
"mutable": false,
|
|
@@ -1932,7 +2028,7 @@ export class PdsDatepicker {
|
|
|
1932
2028
|
"optional": true,
|
|
1933
2029
|
"docs": {
|
|
1934
2030
|
"tags": [],
|
|
1935
|
-
"text": "Specifies a short hint that describes the expected value of the field. Defaults to the format\nthe field takes, such as `YYYY-MM-DD`."
|
|
2031
|
+
"text": "Specifies a short hint that describes the expected value of the field. Defaults to the format\nthe field takes, such as `YYYY-MM-DD`; with `month-day`, to an example date instead, such as\n`December 31`."
|
|
1936
2032
|
},
|
|
1937
2033
|
"getter": false,
|
|
1938
2034
|
"setter": false,
|
|
@@ -2202,7 +2298,7 @@ export class PdsDatepicker {
|
|
|
2202
2298
|
"optional": true,
|
|
2203
2299
|
"docs": {
|
|
2204
2300
|
"tags": [],
|
|
2205
|
-
"text": "The selected date as `YYYY-MM-DD`, or in range mode the range as `YYYY-MM-DD/YYYY-MM-DD`; with\nthe time picker, each date as `YYYY-MM-DDTHH:mm
|
|
2301
|
+
"text": "The selected date as `YYYY-MM-DD`, or in range mode the range as `YYYY-MM-DD/YYYY-MM-DD`; with\nthe time picker, each date as `YYYY-MM-DDTHH:mm`; with `month-day`, the month and day with no\nyear, as `--MM-DD` (a full date is read too, as that month and day, and rewritten to it). An\nempty string when nothing is selected."
|
|
2206
2302
|
},
|
|
2207
2303
|
"getter": false,
|
|
2208
2304
|
"setter": false,
|
|
@@ -2383,6 +2479,9 @@ export class PdsDatepicker {
|
|
|
2383
2479
|
}, {
|
|
2384
2480
|
"propName": "range",
|
|
2385
2481
|
"methodName": "contextChanged"
|
|
2482
|
+
}, {
|
|
2483
|
+
"propName": "monthDay",
|
|
2484
|
+
"methodName": "contextChanged"
|
|
2386
2485
|
}, {
|
|
2387
2486
|
"propName": "min",
|
|
2388
2487
|
"methodName": "contextChanged"
|
|
@@ -17,6 +17,7 @@ export default {
|
|
|
17
17
|
max: null,
|
|
18
18
|
min: null,
|
|
19
19
|
minuteIncrement: 1,
|
|
20
|
+
monthDay: false,
|
|
20
21
|
name: null,
|
|
21
22
|
presets: null,
|
|
22
23
|
range: false,
|
|
@@ -66,6 +67,7 @@ const BaseTemplate = (args) => html`<pds-datepicker
|
|
|
66
67
|
max=${ifDefined(args.max ?? undefined)}
|
|
67
68
|
min=${ifDefined(args.min ?? undefined)}
|
|
68
69
|
minute-increment=${ifDefined(args.minuteIncrement ?? undefined)}
|
|
70
|
+
?month-day=${args.monthDay}
|
|
69
71
|
name=${ifDefined(args.name ?? undefined)}
|
|
70
72
|
placeholder=${ifDefined(args.placeholder ?? undefined)}
|
|
71
73
|
placement=${ifDefined(args.placement ?? undefined)}
|
|
@@ -161,6 +163,15 @@ MonthAndYearDropdowns.args = {
|
|
|
161
163
|
showDropdowns: true,
|
|
162
164
|
};
|
|
163
165
|
|
|
166
|
+
export const MonthDay = BaseTemplate.bind({});
|
|
167
|
+
MonthDay.args = {
|
|
168
|
+
componentId: 'pds-datepicker-month-day-example',
|
|
169
|
+
format: null,
|
|
170
|
+
label: 'Birthday',
|
|
171
|
+
monthDay: true,
|
|
172
|
+
value: '--11-07',
|
|
173
|
+
};
|
|
174
|
+
|
|
164
175
|
export const InitiallyEmptyWithClear = BaseTemplate.bind({});
|
|
165
176
|
InitiallyEmptyWithClear.args = {
|
|
166
177
|
clearable: true,
|