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