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