@dso-toolkit/core 59.0.1 → 60.0.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/dist/cjs/dso-date-picker.cjs.entry.js +49 -568
- package/dist/cjs/dso-date-picker.cjs.entry.js.map +1 -1
- package/dist/cjs/dso-expandable.cjs.entry.js +1 -1
- package/dist/cjs/dso-expandable.cjs.entry.js.map +1 -1
- package/dist/cjs/dso-info_2.cjs.entry.js +15 -2
- package/dist/cjs/dso-info_2.cjs.entry.js.map +1 -1
- package/dist/cjs/dso-toggletip.cjs.entry.js +1 -1
- package/dist/cjs/dso-toggletip.cjs.entry.js.map +1 -1
- package/dist/cjs/dso-toolkit.cjs.js +1 -1
- package/dist/cjs/dso-tooltip.cjs.entry.js +1 -1
- package/dist/cjs/dso-tooltip.cjs.entry.js.map +1 -1
- package/dist/cjs/dso-viewer-grid.cjs.entry.js +177 -65
- package/dist/cjs/dso-viewer-grid.cjs.entry.js.map +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/components/date-picker/date-picker.css +4 -425
- package/dist/collection/components/date-picker/date-picker.interfaces.js.map +1 -1
- package/dist/collection/components/date-picker/date-picker.js +50 -510
- package/dist/collection/components/date-picker/date-picker.js.map +1 -1
- package/dist/collection/components/date-picker/date-utils.js +24 -100
- package/dist/collection/components/date-picker/date-utils.js.map +1 -1
- package/dist/collection/components/expandable/expandable.css +1 -0
- package/dist/collection/components/toggletip/toggletip.css +1 -0
- package/dist/collection/components/tooltip/tooltip.css +35 -26
- package/dist/collection/components/viewer-grid/components/document-panel.js +8 -0
- package/dist/collection/components/viewer-grid/components/document-panel.js.map +1 -0
- package/dist/collection/components/viewer-grid/components/index.js +1 -0
- package/dist/collection/components/viewer-grid/components/index.js.map +1 -1
- package/dist/collection/components/viewer-grid/components/main-panel.js +12 -8
- package/dist/collection/components/viewer-grid/components/main-panel.js.map +1 -1
- package/dist/collection/components/viewer-grid/viewer-grid.css +237 -48
- package/dist/collection/components/viewer-grid/viewer-grid.interfaces.js +13 -1
- package/dist/collection/components/viewer-grid/viewer-grid.interfaces.js.map +1 -1
- package/dist/collection/components/viewer-grid/viewer-grid.js +402 -59
- package/dist/collection/components/viewer-grid/viewer-grid.js.map +1 -1
- package/dist/components/dso-date-picker.js +55 -589
- package/dist/components/dso-date-picker.js.map +1 -1
- package/dist/components/dso-toggletip.js +1 -1
- package/dist/components/dso-toggletip.js.map +1 -1
- package/dist/components/dso-viewer-grid.js +186 -69
- package/dist/components/dso-viewer-grid.js.map +1 -1
- package/dist/components/expandable.js +1 -1
- package/dist/components/expandable.js.map +1 -1
- package/dist/components/selectable.js +14 -1
- package/dist/components/selectable.js.map +1 -1
- package/dist/components/tooltip.js +1 -1
- package/dist/components/tooltip.js.map +1 -1
- package/dist/dso-toolkit/dso-toolkit.esm.js +1 -1
- package/dist/dso-toolkit/dso-toolkit.esm.js.map +1 -1
- package/dist/dso-toolkit/p-0c14a2e5.entry.js +2 -0
- package/dist/dso-toolkit/p-0c14a2e5.entry.js.map +1 -0
- package/dist/dso-toolkit/{p-298453a9.entry.js → p-7d90b3b2.entry.js} +2 -2
- package/dist/dso-toolkit/{p-298453a9.entry.js.map → p-7d90b3b2.entry.js.map} +1 -1
- package/dist/dso-toolkit/p-8b24f933.entry.js +2 -0
- package/dist/dso-toolkit/p-8b24f933.entry.js.map +1 -0
- package/dist/dso-toolkit/p-dbea5bbd.entry.js +2 -0
- package/dist/dso-toolkit/p-dbea5bbd.entry.js.map +1 -0
- package/dist/dso-toolkit/p-ebda3d53.entry.js +2 -0
- package/dist/dso-toolkit/p-ebda3d53.entry.js.map +1 -0
- package/dist/dso-toolkit/p-f55b3647.entry.js +2 -0
- package/dist/dso-toolkit/{p-3631ce14.entry.js.map → p-f55b3647.entry.js.map} +1 -1
- package/dist/esm/dso-date-picker.entry.js +50 -569
- package/dist/esm/dso-date-picker.entry.js.map +1 -1
- package/dist/esm/dso-expandable.entry.js +1 -1
- package/dist/esm/dso-expandable.entry.js.map +1 -1
- package/dist/esm/dso-info_2.entry.js +14 -1
- package/dist/esm/dso-info_2.entry.js.map +1 -1
- package/dist/esm/dso-toggletip.entry.js +1 -1
- package/dist/esm/dso-toggletip.entry.js.map +1 -1
- package/dist/esm/dso-toolkit.js +1 -1
- package/dist/esm/dso-tooltip.entry.js +1 -1
- package/dist/esm/dso-tooltip.entry.js.map +1 -1
- package/dist/esm/dso-viewer-grid.entry.js +178 -66
- package/dist/esm/dso-viewer-grid.entry.js.map +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/types/components/date-picker/date-picker.d.ts +8 -99
- package/dist/types/components/date-picker/date-picker.interfaces.d.ts +9 -8
- package/dist/types/components/date-picker/date-utils.d.ts +6 -34
- package/dist/types/components/viewer-grid/components/document-panel.d.ts +10 -0
- package/dist/types/components/viewer-grid/components/index.d.ts +1 -0
- package/dist/types/components/viewer-grid/components/main-panel.d.ts +10 -4
- package/dist/types/components/viewer-grid/viewer-grid.d.ts +82 -17
- package/dist/types/components/viewer-grid/viewer-grid.interfaces.d.ts +27 -13
- package/dist/types/components.d.ts +87 -42
- package/package.json +2 -2
- package/dist/cjs/create-identifier-5900c27b.js +0 -19
- package/dist/cjs/create-identifier-5900c27b.js.map +0 -1
- package/dist/collection/components/date-picker/date-localization.js +0 -30
- package/dist/collection/components/date-picker/date-localization.js.map +0 -1
- package/dist/collection/components/date-picker/date-picker-day.js +0 -20
- package/dist/collection/components/date-picker/date-picker-day.js.map +0 -1
- package/dist/collection/components/date-picker/date-picker-month.js +0 -26
- package/dist/collection/components/date-picker/date-picker-month.js.map +0 -1
- package/dist/collection/components/date-picker/utils/month-range.js +0 -28
- package/dist/collection/components/date-picker/utils/month-range.js.map +0 -1
- package/dist/collection/components/date-picker/utils/range.js +0 -8
- package/dist/collection/components/date-picker/utils/range.js.map +0 -1
- package/dist/components/create-identifier.js +0 -17
- package/dist/components/create-identifier.js.map +0 -1
- package/dist/dso-toolkit/p-3631ce14.entry.js +0 -2
- package/dist/dso-toolkit/p-95b70498.entry.js +0 -2
- package/dist/dso-toolkit/p-95b70498.entry.js.map +0 -1
- package/dist/dso-toolkit/p-9dbe2931.entry.js +0 -2
- package/dist/dso-toolkit/p-9dbe2931.entry.js.map +0 -1
- package/dist/dso-toolkit/p-ad44136d.entry.js +0 -2
- package/dist/dso-toolkit/p-ad44136d.entry.js.map +0 -1
- package/dist/dso-toolkit/p-c19cfe3f.js +0 -2
- package/dist/dso-toolkit/p-c19cfe3f.js.map +0 -1
- package/dist/dso-toolkit/p-f08a5a06.entry.js +0 -2
- package/dist/dso-toolkit/p-f08a5a06.entry.js.map +0 -1
- package/dist/esm/create-identifier-479a4699.js +0 -17
- package/dist/esm/create-identifier-479a4699.js.map +0 -1
- package/dist/types/components/date-picker/date-localization.d.ts +0 -19
- package/dist/types/components/date-picker/date-picker-day.d.ts +0 -11
- package/dist/types/components/date-picker/date-picker-month.d.ts +0 -20
- package/dist/types/components/date-picker/utils/month-range.d.ts +0 -2
- package/dist/types/components/date-picker/utils/range.d.ts +0 -1
|
@@ -3,19 +3,27 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
const index = require('./index-d46ec033.js');
|
|
6
|
-
const createIdentifier = require('./create-identifier-5900c27b.js');
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
7
|
+
/**
|
|
8
|
+
* @param value date string in Dutch format DD-MM-YYYY
|
|
9
|
+
*/
|
|
10
|
+
function parseToValueFormat(value) {
|
|
11
|
+
if (!value) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
const matches = value.split("-");
|
|
15
|
+
if (matches.length === 3 &&
|
|
16
|
+
typeof matches[0] === "string" &&
|
|
17
|
+
typeof matches[1] === "string" &&
|
|
18
|
+
typeof matches[2] === "string" &&
|
|
19
|
+
matches[2].length === 4) {
|
|
20
|
+
return matches
|
|
21
|
+
.map((match) => (match.length === 1 ? `0${match}` : match))
|
|
22
|
+
.reverse()
|
|
23
|
+
.join("-");
|
|
24
|
+
}
|
|
25
|
+
return value;
|
|
26
|
+
}
|
|
19
27
|
function createDate(year, month, day) {
|
|
20
28
|
const dayInt = parseInt(day, 10);
|
|
21
29
|
const monthInt = parseInt(month, 10);
|
|
@@ -33,9 +41,9 @@ function createDate(year, month, day) {
|
|
|
33
41
|
}
|
|
34
42
|
}
|
|
35
43
|
/**
|
|
36
|
-
* @param value date string in
|
|
44
|
+
* @param value date string in format D-M-YYYY
|
|
37
45
|
*/
|
|
38
|
-
function
|
|
46
|
+
function parseDate(value) {
|
|
39
47
|
if (!value) {
|
|
40
48
|
return;
|
|
41
49
|
}
|
|
@@ -44,8 +52,8 @@ function parseDutchDate(value) {
|
|
|
44
52
|
typeof matches[0] === "string" &&
|
|
45
53
|
typeof matches[1] === "string" &&
|
|
46
54
|
typeof matches[2] === "string" &&
|
|
47
|
-
matches[
|
|
48
|
-
return createDate(matches[
|
|
55
|
+
matches[0].length === 4) {
|
|
56
|
+
return createDate(matches[0], matches[1], matches[2]);
|
|
49
57
|
}
|
|
50
58
|
}
|
|
51
59
|
/**
|
|
@@ -61,56 +69,6 @@ function printDutchDate(date) {
|
|
|
61
69
|
const y = date.getFullYear().toString(10).padStart(2, "0");
|
|
62
70
|
return `${d}-${m}-${y}`;
|
|
63
71
|
}
|
|
64
|
-
/**
|
|
65
|
-
* Compare if two dates are equal in terms of day, month, and year
|
|
66
|
-
*/
|
|
67
|
-
function isEqual(a, b) {
|
|
68
|
-
if (!a || !b) {
|
|
69
|
-
return false;
|
|
70
|
-
}
|
|
71
|
-
return a.getFullYear() === b.getFullYear() && a.getMonth() === b.getMonth() && a.getDate() === b.getDate();
|
|
72
|
-
}
|
|
73
|
-
function addDays(date, days) {
|
|
74
|
-
const d = new Date(date);
|
|
75
|
-
d.setDate(d.getDate() + days);
|
|
76
|
-
return d;
|
|
77
|
-
}
|
|
78
|
-
function startOfWeek(date, firstDayOfWeek = DaysOfWeek.Monday) {
|
|
79
|
-
const d = new Date(date);
|
|
80
|
-
const day = d.getDay();
|
|
81
|
-
const diff = (day < firstDayOfWeek ? 7 : 0) + day - firstDayOfWeek;
|
|
82
|
-
d.setDate(d.getDate() - diff);
|
|
83
|
-
return d;
|
|
84
|
-
}
|
|
85
|
-
function endOfWeek(date, firstDayOfWeek = DaysOfWeek.Monday) {
|
|
86
|
-
const d = new Date(date);
|
|
87
|
-
const day = d.getDay();
|
|
88
|
-
const diff = (day < firstDayOfWeek ? -7 : 0) + 6 - (day - firstDayOfWeek);
|
|
89
|
-
d.setDate(d.getDate() + diff);
|
|
90
|
-
return d;
|
|
91
|
-
}
|
|
92
|
-
function startOfMonth(date) {
|
|
93
|
-
return new Date(date.getFullYear(), date.getMonth(), 1);
|
|
94
|
-
}
|
|
95
|
-
function endOfMonth(date) {
|
|
96
|
-
return new Date(date.getFullYear(), date.getMonth() + 1, 0);
|
|
97
|
-
}
|
|
98
|
-
function setMonth(date, month) {
|
|
99
|
-
const d = new Date(date);
|
|
100
|
-
d.setMonth(month);
|
|
101
|
-
return d;
|
|
102
|
-
}
|
|
103
|
-
function setYear(date, year) {
|
|
104
|
-
const d = new Date(date);
|
|
105
|
-
d.setFullYear(year);
|
|
106
|
-
return d;
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Check if date is within a min and max
|
|
110
|
-
*/
|
|
111
|
-
function inRange(date, min, max) {
|
|
112
|
-
return clamp(date, min, max) === date;
|
|
113
|
-
}
|
|
114
72
|
/**
|
|
115
73
|
* Ensures date is within range, returns min or max if out of bounds
|
|
116
74
|
*/
|
|
@@ -124,179 +82,9 @@ function clamp(date, min, max) {
|
|
|
124
82
|
}
|
|
125
83
|
return date;
|
|
126
84
|
}
|
|
127
|
-
/**
|
|
128
|
-
* given start and end date, return an (inclusive) array of all dates in between
|
|
129
|
-
* @param start
|
|
130
|
-
* @param end
|
|
131
|
-
*/
|
|
132
|
-
function getDaysInRange(start, end) {
|
|
133
|
-
const days = [];
|
|
134
|
-
let current = start;
|
|
135
|
-
while (!isEqual(current, end)) {
|
|
136
|
-
days.push(current);
|
|
137
|
-
current = addDays(current, 1);
|
|
138
|
-
}
|
|
139
|
-
days.push(current);
|
|
140
|
-
return days;
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* given a date, return an array of dates from a calendar perspective
|
|
144
|
-
* @param date
|
|
145
|
-
* @param firstDayOfWeek
|
|
146
|
-
*/
|
|
147
|
-
function getViewOfMonth(date, firstDayOfWeek = DaysOfWeek.Monday) {
|
|
148
|
-
const start = startOfWeek(startOfMonth(date), firstDayOfWeek);
|
|
149
|
-
const end = endOfWeek(endOfMonth(date), firstDayOfWeek);
|
|
150
|
-
return getDaysInRange(start, end);
|
|
151
|
-
}
|
|
152
85
|
|
|
153
|
-
const
|
|
154
|
-
const isToday = isEqual(day, today);
|
|
155
|
-
const isFocused = isEqual(day, focusedDay);
|
|
156
|
-
const notCurrentMonth = day.getMonth() !== focusedDay.getMonth();
|
|
157
|
-
const isOutsideRange = !inRange;
|
|
158
|
-
function handleClick(e) {
|
|
159
|
-
onDaySelect(e, day);
|
|
160
|
-
}
|
|
161
|
-
return (index.h("button", { class: {
|
|
162
|
-
"dso-date__day": true,
|
|
163
|
-
"is-today": isToday,
|
|
164
|
-
}, tabIndex: isFocused ? 0 : -1, onClick: handleClick, onKeyDown: onKeyboardNavigation, disabled: isOutsideRange || notCurrentMonth, type: "button", ref: (el) => {
|
|
165
|
-
if (isFocused && el && focusedDayRef) {
|
|
166
|
-
focusedDayRef(el);
|
|
167
|
-
}
|
|
168
|
-
} },
|
|
169
|
-
index.h("span", { "aria-hidden": "true" }, day.getDate()),
|
|
170
|
-
index.h("span", { class: "dso-date__vhidden" }, printDutchDate(day))));
|
|
171
|
-
};
|
|
86
|
+
const datePickerCss = ".sc-dso-date-picker-h{display:block}[invalid].sc-dso-date-picker-h:not([invalid=false]) .dso-date__input.sc-dso-date-picker{border-color:#ce3f51}.dso-date__input.sc-dso-date-picker{display:block;width:100%;height:40px;padding:6px 14px;font-size:1rem;line-height:1.5;color:#191919;background-color:#fff;background-image:none;border:1px solid #275937;border-radius:4px;transition:border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s}.dso-date__input.sc-dso-date-picker::-moz-placeholder{color:#666;opacity:1}.dso-date__input.sc-dso-date-picker:-ms-input-placeholder{color:#666}.dso-date__input.sc-dso-date-picker::-webkit-input-placeholder{color:#666}.dso-date__input.sc-dso-date-picker::-ms-expand{background-color:transparent;border:0}.dso-date__input.sc-dso-date-picker:focus{border-color:#275937;outline:0;box-shadow:inset 0 0 0 1px #275937}.dso-date__input[disabled].sc-dso-date-picker,.dso-date__input[readonly].sc-dso-date-picker,fieldset[disabled].sc-dso-date-picker .dso-date__input.sc-dso-date-picker{background-color:#fff;opacity:1}.dso-date__input[disabled].sc-dso-date-picker,fieldset[disabled].sc-dso-date-picker .dso-date__input.sc-dso-date-picker{cursor:default}.dso-date__input[disabled].sc-dso-date-picker{border-color:#e5e5e5;color:#999}.dso-date__input[readonly].sc-dso-date-picker{border-width:1px}.dso-date__input[type=text].sc-dso-date-picker{line-height:40px}.dso-date__input[size].sc-dso-date-picker{width:auto}.dso-date__input.sc-dso-date-picker::-webkit-calendar-picker-indicator{position:relative;inset-inline-end:-8px;font-size:1.75rem;filter:invert(50%) sepia(66%) saturate(6528%) hue-rotate(71deg) brightness(94%) contrast(91%)}";
|
|
172
87
|
|
|
173
|
-
function chunk(array, chunkSize) {
|
|
174
|
-
const result = [];
|
|
175
|
-
for (let i = 0; i < array.length; i += chunkSize) {
|
|
176
|
-
result.push(array.slice(i, i + chunkSize));
|
|
177
|
-
}
|
|
178
|
-
return result;
|
|
179
|
-
}
|
|
180
|
-
function mapWithOffset(array, startingOffset, mapFn) {
|
|
181
|
-
return array.map((_, i) => {
|
|
182
|
-
const adjustedIndex = (i + startingOffset) % array.length;
|
|
183
|
-
const item = array[adjustedIndex];
|
|
184
|
-
if (!item) {
|
|
185
|
-
throw new Error("No item found");
|
|
186
|
-
}
|
|
187
|
-
return mapFn(item);
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
const DatePickerMonth = ({ selectedDate, focusedDate, labelledById, localization, firstDayOfWeek, min, max, onDateSelect, onKeyboardNavigation, focusedDayRef, onMouseDown, onFocusIn, }) => {
|
|
191
|
-
const today = new Date();
|
|
192
|
-
const days = getViewOfMonth(focusedDate, firstDayOfWeek);
|
|
193
|
-
return (index.h("table", { class: "dso-date__table", role: "grid", "aria-labelledby": labelledById, onFocusin: onFocusIn, onMouseDown: onMouseDown },
|
|
194
|
-
index.h("thead", null,
|
|
195
|
-
index.h("tr", null, mapWithOffset(localization.dayNames, firstDayOfWeek, (dayName) => (index.h("th", { class: "dso-date__table-header", scope: "col" },
|
|
196
|
-
index.h("span", { "aria-hidden": "true" }, dayName.substr(0, 2)),
|
|
197
|
-
index.h("span", { class: "dso-date__vhidden" }, dayName)))))),
|
|
198
|
-
index.h("tbody", null, chunk(days, 7).map((week) => (index.h("tr", { class: "dso-date__row" }, week.map((day) => (index.h("td", { class: "dso-date__cell", role: "gridcell", "aria-selected": isEqual(day, selectedDate) ? "true" : undefined, "aria-current": isEqual(day, today) ? "date" : undefined },
|
|
199
|
-
index.h(DatePickerDay, { day: day, today: today, focusedDay: focusedDate, inRange: inRange(day, min, max), onDaySelect: onDateSelect, onKeyboardNavigation: onKeyboardNavigation, focusedDayRef: focusedDayRef }))))))))));
|
|
200
|
-
};
|
|
201
|
-
|
|
202
|
-
const localization = {
|
|
203
|
-
buttonLabel: "Kies datum",
|
|
204
|
-
placeholder: "dd-mm-jjjj",
|
|
205
|
-
selectedDateMessage: "Geselecteerde datum is",
|
|
206
|
-
prevMonthLabel: "Vorige maand",
|
|
207
|
-
nextMonthLabel: "Volgende maand",
|
|
208
|
-
monthSelectLabel: "Maand",
|
|
209
|
-
yearSelectLabel: "Jaar",
|
|
210
|
-
closeLabel: "Sluiten",
|
|
211
|
-
keyboardInstruction: "Gebruik de pijltjestoetsen om een dag te kiezen",
|
|
212
|
-
calendarHeading: "Kies een datum",
|
|
213
|
-
dayNames: ["Zondag", "Maandag", "Dinsdag", "Woensdag", "Donderdag", "Vrijdag", "Zaterdag"],
|
|
214
|
-
monthNames: [
|
|
215
|
-
"Januari",
|
|
216
|
-
"Februari",
|
|
217
|
-
"Maart",
|
|
218
|
-
"April",
|
|
219
|
-
"Mei",
|
|
220
|
-
"Juni",
|
|
221
|
-
"Juli",
|
|
222
|
-
"Augustus",
|
|
223
|
-
"September",
|
|
224
|
-
"Oktober",
|
|
225
|
-
"November",
|
|
226
|
-
"December",
|
|
227
|
-
],
|
|
228
|
-
monthNamesShort: ["Jan", "Feb", "Mrt", "Apr", "Mei", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dec"],
|
|
229
|
-
};
|
|
230
|
-
|
|
231
|
-
function monthRange(localization, selectedYear, minDate, maxDate) {
|
|
232
|
-
if (minDate && maxDate) {
|
|
233
|
-
const { minYear, minMonth } = { minYear: minDate.getFullYear(), minMonth: minDate.getMonth() };
|
|
234
|
-
const { maxYear, maxMonth } = { maxYear: maxDate.getFullYear(), maxMonth: maxDate.getMonth() };
|
|
235
|
-
return localization.monthNames.filter((_month, index) => {
|
|
236
|
-
if (minYear === selectedYear && maxYear === selectedYear) {
|
|
237
|
-
return index >= minMonth && index >= maxMonth;
|
|
238
|
-
}
|
|
239
|
-
if (minYear === selectedYear) {
|
|
240
|
-
return index >= minMonth;
|
|
241
|
-
}
|
|
242
|
-
if (maxYear === selectedYear) {
|
|
243
|
-
return index <= maxMonth;
|
|
244
|
-
}
|
|
245
|
-
return true;
|
|
246
|
-
});
|
|
247
|
-
}
|
|
248
|
-
if (minDate) {
|
|
249
|
-
const { minYear, minMonth } = { minYear: minDate.getFullYear(), minMonth: minDate.getMonth() };
|
|
250
|
-
return localization.monthNames.filter((_month, index) => minYear === selectedYear && index >= minMonth);
|
|
251
|
-
}
|
|
252
|
-
if (maxDate) {
|
|
253
|
-
const { maxYear, maxMonth } = { maxYear: maxDate.getFullYear(), maxMonth: maxDate.getMonth() };
|
|
254
|
-
return localization.monthNames.filter((_month, index) => maxYear === selectedYear && index <= maxMonth);
|
|
255
|
-
}
|
|
256
|
-
return localization.monthNames;
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
function range(from, to) {
|
|
260
|
-
const result = [];
|
|
261
|
-
for (let i = from; i <= to; i++) {
|
|
262
|
-
result.push(i);
|
|
263
|
-
}
|
|
264
|
-
return result;
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
const datePickerCss = ".sc-dso-date-picker-h{display:block}[invalid].sc-dso-date-picker-h:not([invalid=false]) .dso-date__input.sc-dso-date-picker{border-color:#ce3f51}.dso-date.sc-dso-date-picker *.sc-dso-date-picker,.dso-date.sc-dso-date-picker *.sc-dso-date-picker::before,.dso-date.sc-dso-date-picker *.sc-dso-date-picker::after{box-sizing:border-box}.dso-date.sc-dso-date-picker{box-sizing:border-box;color:#191919;display:block;font-family:\"Asap\", sans-serif;margin:0;position:relative;text-align:left;width:100%}.dso-date.sc-dso-date-picker:not(.dso-visible) .dso-date__dialog.sc-dso-date-picker{display:none}.dso-date__input.sc-dso-date-picker{display:block;width:100%;height:40px;padding:6px 14px;font-size:1rem;line-height:1.5;color:#191919;background-color:#fff;background-image:none;border:1px solid #275937;border-radius:4px;transition:border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s}.dso-date__input.sc-dso-date-picker::-moz-placeholder{color:#666;opacity:1}.dso-date__input.sc-dso-date-picker:-ms-input-placeholder{color:#666}.dso-date__input.sc-dso-date-picker::-webkit-input-placeholder{color:#666}.dso-date__input.sc-dso-date-picker::-ms-expand{background-color:transparent;border:0}.dso-date__input.sc-dso-date-picker:focus{border-color:#275937;outline:0;box-shadow:inset 0 0 0 1px #275937}.dso-date__input[disabled].sc-dso-date-picker,.dso-date__input[readonly].sc-dso-date-picker,fieldset[disabled].sc-dso-date-picker .dso-date__input.sc-dso-date-picker{background-color:#fff;opacity:1}.dso-date__input[disabled].sc-dso-date-picker,fieldset[disabled].sc-dso-date-picker .dso-date__input.sc-dso-date-picker{cursor:default}.dso-date__input[disabled].sc-dso-date-picker{border-color:#e5e5e5;color:#999}.dso-date__input[readonly].sc-dso-date-picker{border-width:1px}.dso-date__input[type=text].sc-dso-date-picker{line-height:40px}.dso-date__input[size].sc-dso-date-picker{width:auto}.dso-date__toggle.sc-dso-date-picker{-moz-appearance:none;-webkit-appearance:none;-webkit-user-select:none;align-items:center;appearance:none;background:transparent;border:0;border-radius:0;border-bottom-right-radius:4px;border-top-right-radius:4px;color:#39870c;cursor:pointer;display:flex;height:38px;justify-content:center;padding:0;position:absolute;right:0;transform:translateY(-50%);top:50%;user-select:none;width:38px;z-index:101}.dso-date__toggle.sc-dso-date-picker:disabled{color:#afcf9d;cursor:default}.dso-date__dialog.sc-dso-date-picker{border-width:1px;display:flex;right:0;min-width:320px;opacity:0;position:absolute;top:100%;transform:scale(0.96) translateZ(0) translateY(-20px);transform-origin:top right;transition:transform 300ms ease, opacity 300ms ease, visibility 300ms ease;visibility:hidden;will-change:transform, opacity, visibility;z-index:210}@media (max-width: 35.9375em){.dso-date__dialog.sc-dso-date-picker{background:rgba(25, 25, 25, 0.5);bottom:0;position:fixed;left:0;right:0;top:0;transform:translateZ(0);transform-origin:bottom center}}.dso-date__dialog.is-left.sc-dso-date-picker{left:-11px;right:auto;width:auto}.dso-date__dialog.is-active.sc-dso-date-picker{opacity:1;transform:scale(1.0001) translateZ(0) translateY(0);visibility:visible}.dso-date__dialog-content.sc-dso-date-picker{background:#fff;border:1px solid rgba(0, 0, 0, 0.1);border-radius:4px;box-shadow:0 8px 10px 1px rgba(0, 0, 0, 0.4);margin-left:auto;margin-right:-1px;margin-top:8px;max-width:310px;min-width:290px;padding:16px;position:relative;transform:none;width:100%;z-index:210}@media (max-width: 35.9375em){.dso-date__dialog-content.sc-dso-date-picker{border:0;border-radius:0;border-top-left-radius:4px;border-top-right-radius:4px;bottom:0;left:0;margin:0;max-width:none;min-height:26em;opacity:0;padding:0 8% 20px;position:absolute;transform:translateZ(0) translateY(100%);transition:transform 400ms ease, opacity 400ms ease, visibility 400ms ease;visibility:hidden;will-change:transform, opacity, visibility}.is-active.sc-dso-date-picker .dso-date__dialog-content.sc-dso-date-picker{opacity:1;transform:translateZ(0) translateY(0);visibility:visible}}.dso-date__table.sc-dso-date-picker{border-collapse:collapse;border-spacing:0;color:#191919;font-size:1rem;font-weight:400;line-height:1.25;min-width:280px;table-layout:fixed;text-align:center;width:100%}.dso-date__table-header.sc-dso-date-picker{font-size:0.875em;font-weight:600;height:36px;line-height:36px;text-align:center;text-decoration:none;text-transform:uppercase}.dso-date__cell.sc-dso-date-picker{height:40px;padding:1px;text-align:center;width:40px}.dso-date__day.sc-dso-date-picker{-moz-appearance:none;-webkit-appearance:none;appearance:none;background:transparent;border:0;border-radius:50%;box-shadow:0 0 0 1px transparent;color:#191919;cursor:pointer;display:inline-block;font-family:\"Asap\", sans-serif;font-variant-numeric:tabular-nums;font-weight:400;height:38px;line-height:0;padding:0;position:relative;text-align:center;vertical-align:middle;width:38px;z-index:100}.dso-date__day.is-today.sc-dso-date-picker{background:transparent;height:36px;box-shadow:0 0 0 1px #39870c;width:36px}.dso-date__day.sc-dso-date-picker:hover,.dso-date__day.sc-dso-date-picker:active{background:#39870c;color:#fff}.dso-date__day.sc-dso-date-picker:focus{background:transparent;box-shadow:0 0 0 2px #275937;color:#191919;height:34px;outline:0;width:34px}[aria-selected=true].sc-dso-date-picker .dso-date__day.sc-dso-date-picker{background:#39870c;color:#fff}[aria-selected=true].sc-dso-date-picker .dso-date__day.sc-dso-date-picker:focus{background:transparent}[aria-selected=true].sc-dso-date-picker .dso-date__day.sc-dso-date-picker:focus span[aria-hidden=true].sc-dso-date-picker{background:#39870c;border:1px solid #fff;line-height:32px}.dso-date__day.sc-dso-date-picker:disabled{background:#fff;color:#ccc;cursor:default}.dso-date__day.sc-dso-date-picker span[aria-hidden=true].sc-dso-date-picker{border-radius:50%;display:inline-block;height:34px;line-height:34px;width:34px}.dso-date__header.sc-dso-date-picker{align-items:center;display:flex;justify-content:space-between;margin-bottom:16px;width:100%}.dso-date__header.sc-dso-date-picker span.sc-dso-date-picker{font-size:0.875rem}.dso-date__nav.sc-dso-date-picker{white-space:nowrap}.dso-date__prev.sc-dso-date-picker,.dso-date__next.sc-dso-date-picker{-moz-appearance:none;-webkit-appearance:none;align-items:center;appearance:none;background:transparent;border:1px solid #39870c;border-radius:4px;box-sizing:border-box;color:#39870c;cursor:pointer;display:inline-flex;font-size:1em;height:32px;justify-content:center;margin-left:8px;padding:0;width:32px}@media (max-width: 35.9375em){.dso-date__prev.sc-dso-date-picker,.dso-date__next.sc-dso-date-picker{height:40px;width:40px}}.dso-date__prev.sc-dso-date-picker:hover,.dso-date__prev.sc-dso-date-picker:active,.dso-date__next.sc-dso-date-picker:hover,.dso-date__next.sc-dso-date-picker:active{background-color:#39870c;color:#fff}.dso-date__prev.sc-dso-date-picker:focus,.dso-date__next.sc-dso-date-picker:focus{background:transparent;color:#39870c}.dso-date__prev.sc-dso-date-picker:disabled,.dso-date__prev.sc-dso-date-picker:disabled:hover,.dso-date__next.sc-dso-date-picker:disabled,.dso-date__next.sc-dso-date-picker:disabled:hover{background-color:#fff;border-color:#afcf9d;color:#afcf9d;opacity:1}.dso-date__prev.sc-dso-date-picker svg.sc-dso-date-picker,.dso-date__next.sc-dso-date-picker svg.sc-dso-date-picker{margin:0 auto}.dso-date__select.sc-dso-date-picker{display:inline-flex;height:28px;line-height:28px;position:relative}.dso-date__select.sc-dso-date-picker span.sc-dso-date-picker{margin-right:4px}.dso-date__select.sc-dso-date-picker select.sc-dso-date-picker{color:#275937;cursor:pointer;font-size:1rem;height:100%;left:0;opacity:0;position:absolute;top:0;width:100%;z-index:101}.dso-date__select.sc-dso-date-picker select.sc-dso-date-picker:focus+.dso-date__select-label.sc-dso-date-picker{box-shadow:0 0 0 2px #275937}.dso-date__select.sc-dso-date-picker select.sc-dso-date-picker:disabled{color:#afcf9d}.dso-date__select-label.sc-dso-date-picker{align-items:center;border-radius:4px;color:#39870c;display:flex;padding:0 4px 0 8px;pointer-events:none;position:relative;width:100%;z-index:100}.dso-date__select-label.sc-dso-date-picker span.sc-dso-date-picker{font-size:1.25rem;font-weight:600;line-height:1.25}.dso-date__select-label.sc-dso-date-picker svg.sc-dso-date-picker{width:16px;height:16px}.dso-date__mobile.sc-dso-date-picker{align-items:center;border-bottom:1px solid rgba(0, 0, 0, 0.12);display:flex;font-size:1em;justify-content:space-between;margin-bottom:20px;margin-left:-10%;overflow:hidden;padding:12px 20px;position:relative;text-overflow:ellipsis;white-space:nowrap;width:120%}@media (min-width: 36em){.dso-date__mobile.sc-dso-date-picker{border:0;margin:0;overflow:visible;padding:0;position:absolute;right:-16px;top:-16px;width:auto}}.dso-date__mobile-heading.sc-dso-date-picker{display:inline-block;font-weight:600;max-width:84%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}@media (min-width: 36em){.dso-date__mobile-heading.sc-dso-date-picker{display:none}}.dso-date__close.sc-dso-date-picker{-webkit-appearance:none;align-items:center;appearance:none;background-color:#fff;border:0;border-radius:50%;color:#39870c;cursor:pointer;display:flex;font-size:1em;height:32px;justify-content:center;margin-right:-4px;padding:0;width:32px}@media (min-width: 36em){.dso-date__close.sc-dso-date-picker{margin-right:0;opacity:0}}.dso-date__close.sc-dso-date-picker:focus{box-shadow:0 0 0 2px #275937;outline:none}@media (min-width: 36em){.dso-date__close.sc-dso-date-picker:focus{opacity:1}}.dso-date__vhidden.sc-dso-date-picker{border:0;clip:rect(1px, 1px, 1px, 1px);height:1px;overflow:hidden;padding:0;position:absolute;top:0;width:1px}";
|
|
268
|
-
|
|
269
|
-
const keyCode = {
|
|
270
|
-
TAB: 9,
|
|
271
|
-
ESC: 27,
|
|
272
|
-
SPACE: 32,
|
|
273
|
-
PAGE_UP: 33,
|
|
274
|
-
PAGE_DOWN: 34,
|
|
275
|
-
END: 35,
|
|
276
|
-
HOME: 36,
|
|
277
|
-
LEFT: 37,
|
|
278
|
-
UP: 38,
|
|
279
|
-
RIGHT: 39,
|
|
280
|
-
DOWN: 40,
|
|
281
|
-
};
|
|
282
|
-
const DISALLOWED_CHARACTERS = /[^0-9-]+/g;
|
|
283
|
-
const TRANSITION_MS = 300;
|
|
284
|
-
function cleanValue(input, regex) {
|
|
285
|
-
const value = input.value;
|
|
286
|
-
const cursor = input.selectionStart;
|
|
287
|
-
if (!cursor) {
|
|
288
|
-
return value;
|
|
289
|
-
}
|
|
290
|
-
const beforeCursor = value.slice(0, cursor);
|
|
291
|
-
const afterCursor = value.slice(cursor, value.length);
|
|
292
|
-
const filteredBeforeCursor = beforeCursor.replace(regex, "");
|
|
293
|
-
const filterAfterCursor = afterCursor.replace(regex, "");
|
|
294
|
-
const newValue = filteredBeforeCursor + filterAfterCursor;
|
|
295
|
-
const newCursor = filteredBeforeCursor.length;
|
|
296
|
-
input.value = newValue;
|
|
297
|
-
input.selectionStart = input.selectionEnd = newCursor;
|
|
298
|
-
return newValue;
|
|
299
|
-
}
|
|
300
88
|
const DsoDatePicker = class {
|
|
301
89
|
constructor(hostRef) {
|
|
302
90
|
index.registerInstance(this, hostRef);
|
|
@@ -305,35 +93,17 @@ const DsoDatePicker = class {
|
|
|
305
93
|
this.dsoKeyUp = index.createEvent(this, "dsoKeyUp", 7);
|
|
306
94
|
this.dsoKeyDown = index.createEvent(this, "dsoKeyDown", 7);
|
|
307
95
|
this.dsoFocus = index.createEvent(this, "dsoFocus", 7);
|
|
308
|
-
/**
|
|
309
|
-
* Own Properties
|
|
310
|
-
*/
|
|
311
|
-
this.monthSelectId = createIdentifier.createIdentifier("DsoDateMonth");
|
|
312
|
-
this.yearSelectId = createIdentifier.createIdentifier("DsoDateYear");
|
|
313
|
-
this.dialogLabelId = createIdentifier.createIdentifier("DsoDateLabel");
|
|
314
|
-
this.localization = localization;
|
|
315
|
-
this.firstDayOfWeek = DaysOfWeek.Monday;
|
|
316
|
-
/**
|
|
317
|
-
* Local methods.
|
|
318
|
-
*/
|
|
319
|
-
this.enableActiveFocus = () => {
|
|
320
|
-
this.activeFocus = true;
|
|
321
|
-
};
|
|
322
|
-
this.disableActiveFocus = () => {
|
|
323
|
-
this.activeFocus = false;
|
|
324
|
-
};
|
|
325
|
-
this.toggleOpen = (e) => {
|
|
326
|
-
e.preventDefault();
|
|
327
|
-
this.open ? this.hide(false) : this.show();
|
|
328
|
-
};
|
|
329
|
-
this.handleEscKey = (event) => {
|
|
330
|
-
if (event.keyCode === keyCode.ESC) {
|
|
331
|
-
this.hide();
|
|
332
|
-
}
|
|
333
|
-
};
|
|
334
96
|
this.handleBlur = (event) => {
|
|
335
97
|
event.stopPropagation();
|
|
336
98
|
this.dsoBlur.emit({
|
|
99
|
+
originalEvent: event,
|
|
100
|
+
component: "dso-date-picker",
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
this.handleFocus = (event) => {
|
|
104
|
+
event.stopPropagation();
|
|
105
|
+
this.dsoFocus.emit({
|
|
106
|
+
originalEvent: event,
|
|
337
107
|
component: "dso-date-picker",
|
|
338
108
|
});
|
|
339
109
|
};
|
|
@@ -351,154 +121,18 @@ const DsoDatePicker = class {
|
|
|
351
121
|
originalEvent: event,
|
|
352
122
|
});
|
|
353
123
|
};
|
|
354
|
-
this.handleFocus = (event) => {
|
|
355
|
-
event.stopPropagation();
|
|
356
|
-
this.dsoFocus.emit({
|
|
357
|
-
component: "dso-date-picker",
|
|
358
|
-
});
|
|
359
|
-
};
|
|
360
|
-
this.handleTouchStart = (event) => {
|
|
361
|
-
const touch = event.changedTouches[0];
|
|
362
|
-
if (!touch) {
|
|
363
|
-
throw new Error("No touch found");
|
|
364
|
-
}
|
|
365
|
-
this.initialTouchX = touch.pageX;
|
|
366
|
-
this.initialTouchY = touch.pageY;
|
|
367
|
-
};
|
|
368
|
-
this.handleTouchMove = (event) => {
|
|
369
|
-
event.preventDefault();
|
|
370
|
-
};
|
|
371
|
-
this.handleTouchEnd = (event) => {
|
|
372
|
-
var _a, _b;
|
|
373
|
-
const touch = event.changedTouches[0];
|
|
374
|
-
if (!touch) {
|
|
375
|
-
throw new Error("No touch found");
|
|
376
|
-
}
|
|
377
|
-
const distX = touch.pageX - ((_a = this.initialTouchX) !== null && _a !== void 0 ? _a : 0); // get horizontal dist traveled
|
|
378
|
-
const distY = touch.pageY - ((_b = this.initialTouchY) !== null && _b !== void 0 ? _b : 0); // get vertical dist traveled
|
|
379
|
-
const threshold = 70;
|
|
380
|
-
const isHorizontalSwipe = Math.abs(distX) >= threshold && Math.abs(distY) <= threshold;
|
|
381
|
-
const isDownwardsSwipe = Math.abs(distY) >= threshold && Math.abs(distX) <= threshold && distY > 0;
|
|
382
|
-
if (isHorizontalSwipe) {
|
|
383
|
-
this.addMonths(distX < 0 ? 1 : -1);
|
|
384
|
-
}
|
|
385
|
-
else if (isDownwardsSwipe) {
|
|
386
|
-
this.hide(false);
|
|
387
|
-
event.preventDefault();
|
|
388
|
-
}
|
|
389
|
-
this.initialTouchY = undefined;
|
|
390
|
-
this.initialTouchX = undefined;
|
|
391
|
-
};
|
|
392
|
-
this.handleNextMonthClick = (event) => {
|
|
393
|
-
event.preventDefault();
|
|
394
|
-
this.addMonths(1);
|
|
395
|
-
};
|
|
396
|
-
this.handlePreviousMonthClick = (event) => {
|
|
397
|
-
event.preventDefault();
|
|
398
|
-
this.addMonths(-1);
|
|
399
|
-
};
|
|
400
|
-
this.handleFirstFocusableKeydown = (event) => {
|
|
401
|
-
var _a;
|
|
402
|
-
// this ensures focus is trapped inside the dialog
|
|
403
|
-
if (event.keyCode === keyCode.TAB && event.shiftKey) {
|
|
404
|
-
(_a = this.focusedDayNode) === null || _a === void 0 ? void 0 : _a.focus();
|
|
405
|
-
event.preventDefault();
|
|
406
|
-
}
|
|
407
|
-
};
|
|
408
|
-
this.handleKeyboardNavigation = (event) => {
|
|
409
|
-
var _a;
|
|
410
|
-
// handle tab separately, since it needs to be treated
|
|
411
|
-
// differently to other keyboard interactions
|
|
412
|
-
if (event.keyCode === keyCode.TAB && !event.shiftKey) {
|
|
413
|
-
event.preventDefault();
|
|
414
|
-
(_a = this.firstFocusableElement) === null || _a === void 0 ? void 0 : _a.focus();
|
|
415
|
-
return;
|
|
416
|
-
}
|
|
417
|
-
let handled = true;
|
|
418
|
-
switch (event.keyCode) {
|
|
419
|
-
case keyCode.RIGHT:
|
|
420
|
-
this.addDays(1);
|
|
421
|
-
break;
|
|
422
|
-
case keyCode.LEFT:
|
|
423
|
-
this.addDays(-1);
|
|
424
|
-
break;
|
|
425
|
-
case keyCode.DOWN:
|
|
426
|
-
this.addDays(7);
|
|
427
|
-
break;
|
|
428
|
-
case keyCode.UP:
|
|
429
|
-
this.addDays(-7);
|
|
430
|
-
break;
|
|
431
|
-
case keyCode.PAGE_UP:
|
|
432
|
-
if (event.shiftKey) {
|
|
433
|
-
this.addYears(-1);
|
|
434
|
-
}
|
|
435
|
-
else {
|
|
436
|
-
this.addMonths(-1);
|
|
437
|
-
}
|
|
438
|
-
break;
|
|
439
|
-
case keyCode.PAGE_DOWN:
|
|
440
|
-
if (event.shiftKey) {
|
|
441
|
-
this.addYears(1);
|
|
442
|
-
}
|
|
443
|
-
else {
|
|
444
|
-
this.addMonths(1);
|
|
445
|
-
}
|
|
446
|
-
break;
|
|
447
|
-
case keyCode.HOME:
|
|
448
|
-
this.startOfWeek();
|
|
449
|
-
break;
|
|
450
|
-
case keyCode.END:
|
|
451
|
-
this.endOfWeek();
|
|
452
|
-
break;
|
|
453
|
-
default:
|
|
454
|
-
handled = false;
|
|
455
|
-
}
|
|
456
|
-
if (handled) {
|
|
457
|
-
event.preventDefault();
|
|
458
|
-
this.enableActiveFocus();
|
|
459
|
-
}
|
|
460
|
-
};
|
|
461
|
-
this.handleDaySelect = (_event, day) => {
|
|
462
|
-
if (!inRange(day, parseDutchDate(this.min), parseDutchDate(this.max))) {
|
|
463
|
-
return;
|
|
464
|
-
}
|
|
465
|
-
if (day.getMonth() === this.focusedDay.getMonth()) {
|
|
466
|
-
this.setValue(day);
|
|
467
|
-
this.hide();
|
|
468
|
-
}
|
|
469
|
-
else {
|
|
470
|
-
this.setFocusedDay(day);
|
|
471
|
-
}
|
|
472
|
-
};
|
|
473
|
-
this.handleMonthSelect = (e) => {
|
|
474
|
-
// Todo
|
|
475
|
-
if (e.target instanceof HTMLSelectElement) {
|
|
476
|
-
this.setMonth(parseInt(e.target.value, 10));
|
|
477
|
-
}
|
|
478
|
-
};
|
|
479
|
-
this.handleYearSelect = (e) => {
|
|
480
|
-
if (e.target instanceof HTMLSelectElement) {
|
|
481
|
-
this.setYear(parseInt(e.target.value, 10));
|
|
482
|
-
}
|
|
483
|
-
};
|
|
484
124
|
this.handleInputChange = (e) => {
|
|
485
125
|
const target = e.target;
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
126
|
+
if (!(target instanceof HTMLInputElement)) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
const { value } = target;
|
|
490
130
|
const event = {
|
|
131
|
+
originalEvent: e,
|
|
491
132
|
component: "dso-date-picker",
|
|
492
|
-
value
|
|
493
|
-
valueAsDate:
|
|
133
|
+
value,
|
|
134
|
+
valueAsDate: parseDate(value),
|
|
494
135
|
};
|
|
495
|
-
if (value instanceof Date) {
|
|
496
|
-
event.valueAsDate = value;
|
|
497
|
-
}
|
|
498
|
-
else {
|
|
499
|
-
event.value = value;
|
|
500
|
-
event.valueAsDate = parseDutchDate(value);
|
|
501
|
-
}
|
|
502
136
|
if (event.valueAsDate) {
|
|
503
137
|
event.value = printDutchDate(event.valueAsDate);
|
|
504
138
|
}
|
|
@@ -509,8 +143,8 @@ const DsoDatePicker = class {
|
|
|
509
143
|
event.error = "invalid";
|
|
510
144
|
}
|
|
511
145
|
if (event.valueAsDate && (this.min || this.max)) {
|
|
512
|
-
const min =
|
|
513
|
-
const max =
|
|
146
|
+
const min = parseDate(this.min);
|
|
147
|
+
const max = parseDate(this.max);
|
|
514
148
|
const clampValue = clamp(event.valueAsDate, min, max);
|
|
515
149
|
if (clampValue !== event.valueAsDate && clampValue === min) {
|
|
516
150
|
event.valueAsDate = undefined;
|
|
@@ -521,23 +155,15 @@ const DsoDatePicker = class {
|
|
|
521
155
|
event.error = "max-range";
|
|
522
156
|
}
|
|
523
157
|
}
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
if (this.activeFocus && this.open) {
|
|
529
|
-
setTimeout(() => element.focus(), 0);
|
|
158
|
+
this.value = typeof value === "string" ? value : event.value;
|
|
159
|
+
if (this.value !== this.previousValue) {
|
|
160
|
+
this.dsoDateChange.emit(event);
|
|
161
|
+
this.previousValue = this.value;
|
|
530
162
|
}
|
|
531
163
|
};
|
|
532
|
-
this.
|
|
533
|
-
this.focusedDay = new Date();
|
|
534
|
-
this.open = false;
|
|
535
|
-
this.visible = false;
|
|
536
|
-
this.name = "date";
|
|
164
|
+
this.name = "dso-date";
|
|
537
165
|
this.identifier = undefined;
|
|
538
166
|
this.disabled = false;
|
|
539
|
-
this.role = null;
|
|
540
|
-
this.direction = "right";
|
|
541
167
|
this.required = false;
|
|
542
168
|
this.invalid = undefined;
|
|
543
169
|
this.describedBy = undefined;
|
|
@@ -546,154 +172,9 @@ const DsoDatePicker = class {
|
|
|
546
172
|
this.min = undefined;
|
|
547
173
|
this.max = undefined;
|
|
548
174
|
}
|
|
549
|
-
/**
|
|
550
|
-
* Component event handling.
|
|
551
|
-
*/
|
|
552
|
-
handleDocumentClick(e) {
|
|
553
|
-
if (!this.open) {
|
|
554
|
-
return;
|
|
555
|
-
}
|
|
556
|
-
const path = e.composedPath();
|
|
557
|
-
for (const target of path) {
|
|
558
|
-
if (target instanceof Node && this.element.contains(target)) {
|
|
559
|
-
return;
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
|
-
this.hide(false);
|
|
563
|
-
}
|
|
564
|
-
/**
|
|
565
|
-
* Sets focus on the date picker's input. Use this method instead of the global `focus()`.
|
|
566
|
-
*/
|
|
567
|
-
async setFocus() {
|
|
568
|
-
var _a;
|
|
569
|
-
return (_a = this.datePickerInput) === null || _a === void 0 ? void 0 : _a.focus();
|
|
570
|
-
}
|
|
571
|
-
/**
|
|
572
|
-
* Public methods API
|
|
573
|
-
*/
|
|
574
|
-
/**
|
|
575
|
-
* Show the calendar modal, moving focus to the calendar inside.
|
|
576
|
-
*/
|
|
577
|
-
async show() {
|
|
578
|
-
if (typeof this.hideTimeoutId !== "undefined") {
|
|
579
|
-
clearTimeout(this.hideTimeoutId);
|
|
580
|
-
}
|
|
581
|
-
this.visible = true;
|
|
582
|
-
setTimeout(() => {
|
|
583
|
-
this.open = true;
|
|
584
|
-
this.setFocusedDay(parseDutchDate(this.value) || new Date());
|
|
585
|
-
if (typeof this.focusTimeoutId !== "undefined") {
|
|
586
|
-
clearTimeout(this.focusTimeoutId);
|
|
587
|
-
}
|
|
588
|
-
this.focusTimeoutId = setTimeout(() => { var _a; return (_a = this.monthSelectNode) === null || _a === void 0 ? void 0 : _a.focus(); }, TRANSITION_MS);
|
|
589
|
-
});
|
|
590
|
-
}
|
|
591
|
-
/**
|
|
592
|
-
* Hide the calendar modal. Set `moveFocusToButton` to false to prevent focus
|
|
593
|
-
* returning to the date picker's button. Default is true.
|
|
594
|
-
*/
|
|
595
|
-
async hide(moveFocusToButton = true) {
|
|
596
|
-
this.open = false;
|
|
597
|
-
// in cases where calendar is quickly shown and hidden
|
|
598
|
-
// we should avoid moving focus to the button
|
|
599
|
-
if (typeof this.focusTimeoutId !== "undefined") {
|
|
600
|
-
clearTimeout(this.focusTimeoutId);
|
|
601
|
-
}
|
|
602
|
-
this.hideTimeoutId = setTimeout(() => {
|
|
603
|
-
if (moveFocusToButton && this.datePickerButton) {
|
|
604
|
-
this.datePickerButton.focus();
|
|
605
|
-
}
|
|
606
|
-
this.visible = false;
|
|
607
|
-
}, TRANSITION_MS + 200);
|
|
608
|
-
}
|
|
609
|
-
addDays(days) {
|
|
610
|
-
this.setFocusedDay(addDays(this.focusedDay, days));
|
|
611
|
-
}
|
|
612
|
-
addMonths(months) {
|
|
613
|
-
this.setMonth(this.focusedDay.getMonth() + months);
|
|
614
|
-
}
|
|
615
|
-
addYears(years) {
|
|
616
|
-
this.setYear(this.focusedDay.getFullYear() + years);
|
|
617
|
-
}
|
|
618
|
-
startOfWeek() {
|
|
619
|
-
this.setFocusedDay(startOfWeek(this.focusedDay, this.firstDayOfWeek));
|
|
620
|
-
}
|
|
621
|
-
endOfWeek() {
|
|
622
|
-
this.setFocusedDay(endOfWeek(this.focusedDay, this.firstDayOfWeek));
|
|
623
|
-
}
|
|
624
|
-
setMonth(month) {
|
|
625
|
-
const min = setMonth(startOfMonth(this.focusedDay), month);
|
|
626
|
-
const max = endOfMonth(min);
|
|
627
|
-
const date = setMonth(this.focusedDay, month);
|
|
628
|
-
this.setFocusedDay(clamp(date, min, max));
|
|
629
|
-
}
|
|
630
|
-
setYear(year) {
|
|
631
|
-
const min = setYear(startOfMonth(this.focusedDay), year);
|
|
632
|
-
const max = endOfMonth(min);
|
|
633
|
-
const date = setYear(this.focusedDay, year);
|
|
634
|
-
this.setFocusedDay(clamp(date, min, max));
|
|
635
|
-
}
|
|
636
|
-
setFocusedDay(day) {
|
|
637
|
-
this.focusedDay = clamp(day, parseDutchDate(this.min), parseDutchDate(this.max));
|
|
638
|
-
}
|
|
639
|
-
setValue(value) {
|
|
640
|
-
const event = this.prepareEvent(value);
|
|
641
|
-
this.value = typeof value === "string" ? value : event.value;
|
|
642
|
-
if (this.value !== this.previousValue) {
|
|
643
|
-
this.dsoDateChange.emit(event);
|
|
644
|
-
this.previousValue = this.value;
|
|
645
|
-
}
|
|
646
|
-
}
|
|
647
|
-
componentWillLoad() {
|
|
648
|
-
const minDate = parseDutchDate(this.min);
|
|
649
|
-
const maxDate = parseDutchDate(this.max);
|
|
650
|
-
if (minDate && minDate > this.focusedDay) {
|
|
651
|
-
this.focusedDay = minDate;
|
|
652
|
-
}
|
|
653
|
-
if (maxDate && maxDate < this.focusedDay) {
|
|
654
|
-
this.focusedDay = maxDate;
|
|
655
|
-
}
|
|
656
|
-
}
|
|
657
|
-
componentDidLoad() {
|
|
658
|
-
const valueAsDate = parseDutchDate(this.value);
|
|
659
|
-
if (valueAsDate) {
|
|
660
|
-
this.previousValue = this.value = printDutchDate(valueAsDate);
|
|
661
|
-
}
|
|
662
|
-
if (this.dsoAutofocus) {
|
|
663
|
-
this.setFocus();
|
|
664
|
-
}
|
|
665
|
-
}
|
|
666
|
-
/**
|
|
667
|
-
* render() function
|
|
668
|
-
* Always the last one in the class.
|
|
669
|
-
*/
|
|
670
175
|
render() {
|
|
671
|
-
var _a
|
|
672
|
-
|
|
673
|
-
const formattedDate = valueAsDate && printDutchDate(valueAsDate);
|
|
674
|
-
const selectedYear = (valueAsDate || this.focusedDay).getFullYear();
|
|
675
|
-
const focusedMonth = this.focusedDay.getMonth();
|
|
676
|
-
const focusedYear = this.focusedDay.getFullYear();
|
|
677
|
-
const minDate = parseDutchDate(this.min);
|
|
678
|
-
const maxDate = parseDutchDate(this.max);
|
|
679
|
-
const prevMonthDisabled = minDate && minDate.getMonth() === focusedMonth && minDate.getFullYear() === focusedYear;
|
|
680
|
-
const nextMonthDisabled = maxDate && maxDate.getMonth() === focusedMonth && maxDate.getFullYear() === focusedYear;
|
|
681
|
-
let minYear = selectedYear - 10;
|
|
682
|
-
let maxYear = selectedYear + 10;
|
|
683
|
-
if (minDate) {
|
|
684
|
-
minYear = Math.max(minYear, minDate.getFullYear());
|
|
685
|
-
}
|
|
686
|
-
if (maxDate) {
|
|
687
|
-
maxYear = Math.min(maxYear, maxDate.getFullYear());
|
|
688
|
-
}
|
|
689
|
-
return (index.h(index.Host, null, index.h("div", { class: { "dso-date": true, "dso-visible": this.visible } }, index.h("div", { class: "dso-date__input-wrapper" }, index.h("input", { class: "dso-date__input", value: this.value, placeholder: this.localization.placeholder, id: this.identifier, disabled: this.disabled, role: (_a = this.role) !== null && _a !== void 0 ? _a : undefined, required: this.required ? true : undefined, "aria-autocomplete": "none", "aria-invalid": (_b = this.invalid) === null || _b === void 0 ? void 0 : _b.toString(), "aria-describedby": this.describedBy, onInput: this.handleInputChange, onFocus: this.handleFocus, onBlur: this.handleBlur, onKeyUp: this.handleKeyUp, onKeyDown: this.handleKeyDown, autoComplete: "off", ref: (element) => (this.datePickerInput = element) }), index.h("button", { type: "button", class: "dso-date__toggle", onClick: this.toggleOpen, disabled: this.disabled, ref: (element) => (this.datePickerButton = element) }, index.h("span", { class: "dso-date__toggle-icon" }, index.h("dso-icon", { icon: "calendar" })), index.h("span", { class: "dso-date__vhidden" }, this.localization.buttonLabel, formattedDate && (index.h("span", null, ", ", this.localization.selectedDateMessage, " ", formattedDate))))), index.h("div", { class: {
|
|
690
|
-
"dso-date__dialog": true,
|
|
691
|
-
"is-left": this.direction === "left",
|
|
692
|
-
"is-active": this.open,
|
|
693
|
-
}, role: "dialog", "aria-modal": "true", "aria-hidden": this.open ? "false" : "true", "aria-labelledby": this.dialogLabelId, onTouchMove: this.handleTouchMove, onTouchStart: this.handleTouchStart, onTouchEnd: this.handleTouchEnd }, index.h("div", { class: "dso-date__dialog-content", onKeyDown: this.handleEscKey }, index.h("div", { class: "dso-date__vhidden dso-date__instructions", "aria-live": "polite" }, this.localization.keyboardInstruction), index.h("div", { class: "dso-date__mobile", onFocusin: this.disableActiveFocus }, index.h("label", { class: "dso-date__mobile-heading" }, this.localization.calendarHeading), index.h("button", { class: "dso-date__close", ref: (element) => (this.firstFocusableElement = element), onKeyDown: this.handleFirstFocusableKeydown, onClick: () => this.hide(), type: "button" }, index.h("dso-icon", { icon: "times" }), index.h("span", { class: "dso-date__vhidden" }, this.localization.closeLabel))), index.h("div", { class: "dso-date__header", onFocusin: this.disableActiveFocus }, index.h("div", null, index.h("h2", { id: this.dialogLabelId, class: "dso-date__vhidden", "aria-live": "polite" }, this.localization.monthNames[focusedMonth], " ", this.focusedDay.getFullYear()), index.h("label", { htmlFor: this.monthSelectId, class: "dso-date__vhidden" }, this.localization.monthSelectLabel), index.h("div", { class: "dso-date__select" }, index.h("select", { id: this.monthSelectId, class: "dso-date__select--month", ref: (element) => (this.monthSelectNode = element), onChange: this.handleMonthSelect }, monthRange(this.localization, selectedYear, minDate, maxDate).map((month) => {
|
|
694
|
-
const index$1 = this.localization.monthNames.indexOf(month);
|
|
695
|
-
return (index.h("option", { key: month, value: index$1, selected: index$1 === focusedMonth }, month));
|
|
696
|
-
})), index.h("div", { class: "dso-date__select-label", "aria-hidden": "true" }, index.h("span", null, this.localization.monthNamesShort[focusedMonth]), index.h("dso-icon", { icon: "chevron-down" }))), index.h("label", { htmlFor: this.yearSelectId, class: "dso-date__vhidden" }, this.localization.yearSelectLabel), index.h("div", { class: "dso-date__select" }, index.h("select", { id: this.yearSelectId, class: "dso-date__select--year", onChange: this.handleYearSelect }, range(minYear, maxYear).map((year) => (index.h("option", { key: year, selected: year === focusedYear }, year)))), index.h("div", { class: "dso-date__select-label", "aria-hidden": "true" }, index.h("span", null, this.focusedDay.getFullYear()), index.h("dso-icon", { icon: "chevron-down" })))), index.h("div", { class: "dso-date__nav" }, index.h("button", { class: "dso-date__prev", onClick: this.handlePreviousMonthClick, disabled: prevMonthDisabled, type: "button" }, index.h("dso-icon", { icon: "chevron-left" }), index.h("span", { class: "dso-date__vhidden" }, this.localization.prevMonthLabel)), index.h("button", { class: "dso-date__next", onClick: this.handleNextMonthClick, disabled: nextMonthDisabled, type: "button" }, index.h("dso-icon", { icon: "chevron-right" }), index.h("span", { class: "dso-date__vhidden" }, this.localization.nextMonthLabel)))), index.h(DatePickerMonth, { selectedDate: valueAsDate, focusedDate: this.focusedDay, onDateSelect: this.handleDaySelect, onKeyboardNavigation: this.handleKeyboardNavigation, labelledById: this.dialogLabelId, localization: this.localization, firstDayOfWeek: this.firstDayOfWeek, focusedDayRef: this.processFocusedDayNode, min: minDate, max: maxDate }))))));
|
|
176
|
+
var _a;
|
|
177
|
+
return (index.h("input", { type: "date", id: this.identifier, class: "dso-date__input", value: parseToValueFormat(this.value), name: this.name, min: parseToValueFormat(this.min), max: parseToValueFormat(this.max), disabled: this.disabled || undefined, required: this.required || undefined, "aria-autocomplete": "none", "aria-invalid": (_a = this.invalid) === null || _a === void 0 ? void 0 : _a.toString(), "aria-describedby": this.describedBy, autoComplete: "off", autofocus: this.dsoAutofocus || undefined, onBlur: this.handleBlur, onFocus: this.handleFocus, onKeyUp: this.handleKeyUp, onKeyDown: this.handleKeyDown, onChange: this.handleInputChange }));
|
|
697
178
|
}
|
|
698
179
|
get element() { return index.getElement(this); }
|
|
699
180
|
};
|