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