@dso-toolkit/core 62.2.2 → 62.3.0-ghi-2431.1

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 (127) 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 +16 -0
  4. package/dist/cjs/dso-accordion-section.cjs.entry.js.map +1 -1
  5. package/dist/cjs/dso-alert_7.cjs.entry.js +22 -4
  6. package/dist/cjs/dso-alert_7.cjs.entry.js.map +1 -1
  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-highlight-box.cjs.entry.js +1 -1
  12. package/dist/cjs/dso-highlight-box.cjs.entry.js.map +1 -1
  13. package/dist/cjs/dso-info_2.cjs.entry.js +2 -15
  14. package/dist/cjs/dso-info_2.cjs.entry.js.map +1 -1
  15. package/dist/cjs/dso-toolkit.cjs.js +1 -1
  16. package/dist/cjs/loader.cjs.js +1 -1
  17. package/dist/collection/collection-manifest.json +1 -0
  18. package/dist/collection/components/accordion/components/accordion-section.js +16 -0
  19. package/dist/collection/components/accordion/components/accordion-section.js.map +1 -1
  20. package/dist/collection/components/annotation-button/annotation-button.js +1 -1
  21. package/dist/collection/components/annotation-output/annotation-output.js +1 -1
  22. package/dist/collection/components/date-picker-legacy/date-localization.js +30 -0
  23. package/dist/collection/components/date-picker-legacy/date-localization.js.map +1 -0
  24. package/dist/collection/components/date-picker-legacy/date-picker-day.js +20 -0
  25. package/dist/collection/components/date-picker-legacy/date-picker-day.js.map +1 -0
  26. package/dist/collection/components/date-picker-legacy/date-picker-legacy.css +487 -0
  27. package/dist/collection/components/date-picker-legacy/date-picker-legacy.interfaces.js +2 -0
  28. package/dist/collection/components/date-picker-legacy/date-picker-legacy.interfaces.js.map +1 -0
  29. package/dist/collection/components/date-picker-legacy/date-picker-legacy.js +849 -0
  30. package/dist/collection/components/date-picker-legacy/date-picker-legacy.js.map +1 -0
  31. package/dist/collection/components/date-picker-legacy/date-picker-month.js +26 -0
  32. package/dist/collection/components/date-picker-legacy/date-picker-month.js.map +1 -0
  33. package/dist/collection/components/date-picker-legacy/date-utils.js +155 -0
  34. package/dist/collection/components/date-picker-legacy/date-utils.js.map +1 -0
  35. package/dist/collection/components/date-picker-legacy/utils/month-range.js +28 -0
  36. package/dist/collection/components/date-picker-legacy/utils/month-range.js.map +1 -0
  37. package/dist/collection/components/date-picker-legacy/utils/range.js +8 -0
  38. package/dist/collection/components/date-picker-legacy/utils/range.js.map +1 -0
  39. package/dist/collection/components/document-component/document-component.js +44 -1
  40. package/dist/collection/components/document-component/document-component.js.map +1 -1
  41. package/dist/collection/components/document-component/document-component.models.js.map +1 -1
  42. package/dist/collection/components/expandable/expandable.js +2 -2
  43. package/dist/collection/components/highlight-box/highlight-box.css +2 -0
  44. package/dist/collection/components/ozon-content/nodes/text.node.js +11 -2
  45. package/dist/collection/components/ozon-content/nodes/text.node.js.map +1 -1
  46. package/dist/collection/components/ozon-content/ozon-content-context.interface.js.map +1 -1
  47. package/dist/collection/components/ozon-content/ozon-content-mapper.js +2 -0
  48. package/dist/collection/components/ozon-content/ozon-content-mapper.js.map +1 -1
  49. package/dist/collection/components/ozon-content/ozon-content-node-context.interface.js.map +1 -1
  50. package/dist/collection/components/ozon-content/ozon-content.css +9 -0
  51. package/dist/collection/components/ozon-content/ozon-content.interfaces.js.map +1 -1
  52. package/dist/collection/components/ozon-content/ozon-content.js +49 -1
  53. package/dist/collection/components/ozon-content/ozon-content.js.map +1 -1
  54. package/dist/components/create-identifier.js +17 -0
  55. package/dist/components/create-identifier.js.map +1 -0
  56. package/dist/components/document-component.js +5 -2
  57. package/dist/components/document-component.js.map +1 -1
  58. package/dist/components/dso-accordion-section.js +16 -0
  59. package/dist/components/dso-accordion-section.js.map +1 -1
  60. package/dist/components/dso-date-picker-legacy.d.ts +11 -0
  61. package/dist/components/dso-date-picker-legacy.js +743 -0
  62. package/dist/components/dso-date-picker-legacy.js.map +1 -0
  63. package/dist/components/dso-highlight-box.js +1 -1
  64. package/dist/components/dso-highlight-box.js.map +1 -1
  65. package/dist/components/index.d.ts +2 -0
  66. package/dist/components/index.js +1 -0
  67. package/dist/components/index.js.map +1 -1
  68. package/dist/components/ozon-content.js +23 -4
  69. package/dist/components/ozon-content.js.map +1 -1
  70. package/dist/components/selectable.js +1 -14
  71. package/dist/components/selectable.js.map +1 -1
  72. package/dist/dso-toolkit/dso-toolkit.esm.js +1 -1
  73. package/dist/dso-toolkit/dso-toolkit.esm.js.map +1 -1
  74. package/dist/dso-toolkit/p-0fbddb1a.entry.js +2 -0
  75. package/dist/dso-toolkit/p-0fbddb1a.entry.js.map +1 -0
  76. package/dist/dso-toolkit/p-1db9f4a4.entry.js +2 -0
  77. package/dist/dso-toolkit/p-1db9f4a4.entry.js.map +1 -0
  78. package/dist/dso-toolkit/p-4423c2b5.entry.js +2 -0
  79. package/dist/dso-toolkit/{p-e88590a7.entry.js.map → p-4423c2b5.entry.js.map} +1 -1
  80. package/dist/dso-toolkit/{p-47e77e24.entry.js → p-76c0fc1b.entry.js} +2 -2
  81. package/dist/dso-toolkit/p-76c0fc1b.entry.js.map +1 -0
  82. package/dist/dso-toolkit/p-a377846a.entry.js +2 -0
  83. package/dist/dso-toolkit/p-a377846a.entry.js.map +1 -0
  84. package/dist/dso-toolkit/p-c19cfe3f.js +2 -0
  85. package/dist/dso-toolkit/p-c19cfe3f.js.map +1 -0
  86. package/dist/dso-toolkit/{p-000f7731.entry.js → p-e95bf0f4.entry.js} +2 -2
  87. package/dist/dso-toolkit/p-e95bf0f4.entry.js.map +1 -0
  88. package/dist/esm/create-identifier-479a4699.js +17 -0
  89. package/dist/esm/create-identifier-479a4699.js.map +1 -0
  90. package/dist/esm/dso-accordion-section.entry.js +16 -0
  91. package/dist/esm/dso-accordion-section.entry.js.map +1 -1
  92. package/dist/esm/dso-alert_7.entry.js +22 -4
  93. package/dist/esm/dso-alert_7.entry.js.map +1 -1
  94. package/dist/esm/dso-annotation-output_3.entry.js +3 -1
  95. package/dist/esm/dso-annotation-output_3.entry.js.map +1 -1
  96. package/dist/esm/dso-date-picker-legacy.entry.js +700 -0
  97. package/dist/esm/dso-date-picker-legacy.entry.js.map +1 -0
  98. package/dist/esm/dso-highlight-box.entry.js +1 -1
  99. package/dist/esm/dso-highlight-box.entry.js.map +1 -1
  100. package/dist/esm/dso-info_2.entry.js +1 -14
  101. package/dist/esm/dso-info_2.entry.js.map +1 -1
  102. package/dist/esm/dso-toolkit.js +1 -1
  103. package/dist/esm/loader.js +1 -1
  104. package/dist/types/components/date-picker-legacy/date-localization.d.ts +19 -0
  105. package/dist/types/components/date-picker-legacy/date-picker-day.d.ts +11 -0
  106. package/dist/types/components/date-picker-legacy/date-picker-legacy.d.ts +172 -0
  107. package/dist/types/components/date-picker-legacy/date-picker-legacy.interfaces.d.ts +14 -0
  108. package/dist/types/components/date-picker-legacy/date-picker-month.d.ts +20 -0
  109. package/dist/types/components/date-picker-legacy/date-utils.d.ts +46 -0
  110. package/dist/types/components/date-picker-legacy/utils/month-range.d.ts +2 -0
  111. package/dist/types/components/date-picker-legacy/utils/range.d.ts +1 -0
  112. package/dist/types/components/document-component/document-component.d.ts +9 -1
  113. package/dist/types/components/document-component/document-component.models.d.ts +8 -1
  114. package/dist/types/components/ozon-content/nodes/text.node.d.ts +2 -1
  115. package/dist/types/components/ozon-content/ozon-content-context.interface.d.ts +3 -1
  116. package/dist/types/components/ozon-content/ozon-content-node-context.interface.d.ts +3 -1
  117. package/dist/types/components/ozon-content/ozon-content.d.ts +10 -1
  118. package/dist/types/components/ozon-content/ozon-content.interfaces.d.ts +10 -0
  119. package/dist/types/components.d.ts +175 -4
  120. package/package.json +2 -2
  121. package/dist/dso-toolkit/p-000f7731.entry.js.map +0 -1
  122. package/dist/dso-toolkit/p-18152675.entry.js +0 -2
  123. package/dist/dso-toolkit/p-18152675.entry.js.map +0 -1
  124. package/dist/dso-toolkit/p-47e77e24.entry.js.map +0 -1
  125. package/dist/dso-toolkit/p-938f47d3.entry.js +0 -2
  126. package/dist/dso-toolkit/p-938f47d3.entry.js.map +0 -1
  127. package/dist/dso-toolkit/p-e88590a7.entry.js +0 -2
@@ -0,0 +1,849 @@
1
+ import { Host, h, } from "@stencil/core";
2
+ import { createIdentifier } from "../../utils/create-identifier";
3
+ import { addDays, startOfWeek, endOfWeek, setMonth, setYear, clamp, inRange, endOfMonth, startOfMonth, printDutchDate, parseDutchDate, DaysOfWeek, } from "./date-utils";
4
+ import { DatePickerLegacyMonth } from "./date-picker-month";
5
+ import defaultLocalization from "./date-localization";
6
+ import { monthRange } from "./utils/month-range";
7
+ import { range } from "./utils/range";
8
+ const keyCode = {
9
+ TAB: 9,
10
+ ESC: 27,
11
+ SPACE: 32,
12
+ PAGE_UP: 33,
13
+ PAGE_DOWN: 34,
14
+ END: 35,
15
+ HOME: 36,
16
+ LEFT: 37,
17
+ UP: 38,
18
+ RIGHT: 39,
19
+ DOWN: 40,
20
+ };
21
+ const DISALLOWED_CHARACTERS = /[^0-9-]+/g;
22
+ const TRANSITION_MS = 300;
23
+ function cleanValue(input, regex) {
24
+ const value = input.value;
25
+ const cursor = input.selectionStart;
26
+ if (!cursor) {
27
+ return value;
28
+ }
29
+ const beforeCursor = value.slice(0, cursor);
30
+ const afterCursor = value.slice(cursor, value.length);
31
+ const filteredBeforeCursor = beforeCursor.replace(regex, "");
32
+ const filterAfterCursor = afterCursor.replace(regex, "");
33
+ const newValue = filteredBeforeCursor + filterAfterCursor;
34
+ const newCursor = filteredBeforeCursor.length;
35
+ input.value = newValue;
36
+ input.selectionStart = input.selectionEnd = newCursor;
37
+ return newValue;
38
+ }
39
+ export class DsoDatePickerLegacy {
40
+ constructor() {
41
+ /**
42
+ * Own Properties
43
+ */
44
+ this.monthSelectId = createIdentifier("DsoDateMonth");
45
+ this.yearSelectId = createIdentifier("DsoDateYear");
46
+ this.dialogLabelId = createIdentifier("DsoDateLabel");
47
+ this.localization = defaultLocalization;
48
+ this.firstDayOfWeek = DaysOfWeek.Monday;
49
+ /**
50
+ * Local methods.
51
+ */
52
+ this.enableActiveFocus = () => {
53
+ this.activeFocus = true;
54
+ };
55
+ this.disableActiveFocus = () => {
56
+ this.activeFocus = false;
57
+ };
58
+ this.toggleOpen = (e) => {
59
+ e.preventDefault();
60
+ this.open ? this.hide(false) : this.show();
61
+ };
62
+ this.handleEscKey = (event) => {
63
+ if (event.keyCode === keyCode.ESC) {
64
+ this.hide();
65
+ }
66
+ };
67
+ this.handleBlur = (event) => {
68
+ event.stopPropagation();
69
+ this.dsoBlur.emit({
70
+ component: "dso-date-picker-legacy",
71
+ });
72
+ };
73
+ this.handleKeyUp = (event) => {
74
+ event.stopPropagation();
75
+ this.dsoKeyUp.emit({
76
+ component: "dso-date-picker-legacy",
77
+ originalEvent: event,
78
+ });
79
+ };
80
+ this.handleKeyDown = (event) => {
81
+ event.stopPropagation();
82
+ this.dsoKeyDown.emit({
83
+ component: "dso-date-picker-legacy",
84
+ originalEvent: event,
85
+ });
86
+ };
87
+ this.handleFocus = (event) => {
88
+ event.stopPropagation();
89
+ this.dsoFocus.emit({
90
+ component: "dso-date-picker-legacy",
91
+ });
92
+ };
93
+ this.handleTouchStart = (event) => {
94
+ const touch = event.changedTouches[0];
95
+ if (!touch) {
96
+ throw new Error("No touch found");
97
+ }
98
+ this.initialTouchX = touch.pageX;
99
+ this.initialTouchY = touch.pageY;
100
+ };
101
+ this.handleTouchMove = (event) => {
102
+ event.preventDefault();
103
+ };
104
+ this.handleTouchEnd = (event) => {
105
+ var _a, _b;
106
+ const touch = event.changedTouches[0];
107
+ if (!touch) {
108
+ throw new Error("No touch found");
109
+ }
110
+ const distX = touch.pageX - ((_a = this.initialTouchX) !== null && _a !== void 0 ? _a : 0); // get horizontal dist traveled
111
+ const distY = touch.pageY - ((_b = this.initialTouchY) !== null && _b !== void 0 ? _b : 0); // get vertical dist traveled
112
+ const threshold = 70;
113
+ const isHorizontalSwipe = Math.abs(distX) >= threshold && Math.abs(distY) <= threshold;
114
+ const isDownwardsSwipe = Math.abs(distY) >= threshold && Math.abs(distX) <= threshold && distY > 0;
115
+ if (isHorizontalSwipe) {
116
+ this.addMonths(distX < 0 ? 1 : -1);
117
+ }
118
+ else if (isDownwardsSwipe) {
119
+ this.hide(false);
120
+ event.preventDefault();
121
+ }
122
+ this.initialTouchY = undefined;
123
+ this.initialTouchX = undefined;
124
+ };
125
+ this.handleNextMonthClick = (event) => {
126
+ event.preventDefault();
127
+ this.addMonths(1);
128
+ };
129
+ this.handlePreviousMonthClick = (event) => {
130
+ event.preventDefault();
131
+ this.addMonths(-1);
132
+ };
133
+ this.handleFirstFocusableKeydown = (event) => {
134
+ var _a;
135
+ // this ensures focus is trapped inside the dialog
136
+ if (event.keyCode === keyCode.TAB && event.shiftKey) {
137
+ (_a = this.focusedDayNode) === null || _a === void 0 ? void 0 : _a.focus();
138
+ event.preventDefault();
139
+ }
140
+ };
141
+ this.handleKeyboardNavigation = (event) => {
142
+ var _a;
143
+ // handle tab separately, since it needs to be treated
144
+ // differently to other keyboard interactions
145
+ if (event.keyCode === keyCode.TAB && !event.shiftKey) {
146
+ event.preventDefault();
147
+ (_a = this.firstFocusableElement) === null || _a === void 0 ? void 0 : _a.focus();
148
+ return;
149
+ }
150
+ let handled = true;
151
+ switch (event.keyCode) {
152
+ case keyCode.RIGHT:
153
+ this.addDays(1);
154
+ break;
155
+ case keyCode.LEFT:
156
+ this.addDays(-1);
157
+ break;
158
+ case keyCode.DOWN:
159
+ this.addDays(7);
160
+ break;
161
+ case keyCode.UP:
162
+ this.addDays(-7);
163
+ break;
164
+ case keyCode.PAGE_UP:
165
+ if (event.shiftKey) {
166
+ this.addYears(-1);
167
+ }
168
+ else {
169
+ this.addMonths(-1);
170
+ }
171
+ break;
172
+ case keyCode.PAGE_DOWN:
173
+ if (event.shiftKey) {
174
+ this.addYears(1);
175
+ }
176
+ else {
177
+ this.addMonths(1);
178
+ }
179
+ break;
180
+ case keyCode.HOME:
181
+ this.startOfWeek();
182
+ break;
183
+ case keyCode.END:
184
+ this.endOfWeek();
185
+ break;
186
+ default:
187
+ handled = false;
188
+ }
189
+ if (handled) {
190
+ event.preventDefault();
191
+ this.enableActiveFocus();
192
+ }
193
+ };
194
+ this.handleDaySelect = (_event, day) => {
195
+ if (!inRange(day, parseDutchDate(this.min), parseDutchDate(this.max))) {
196
+ return;
197
+ }
198
+ if (day.getMonth() === this.focusedDay.getMonth()) {
199
+ this.setValue(day);
200
+ this.hide();
201
+ }
202
+ else {
203
+ this.setFocusedDay(day);
204
+ }
205
+ };
206
+ this.handleMonthSelect = (e) => {
207
+ // Todo
208
+ if (e.target instanceof HTMLSelectElement) {
209
+ this.setMonth(parseInt(e.target.value, 10));
210
+ }
211
+ };
212
+ this.handleYearSelect = (e) => {
213
+ if (e.target instanceof HTMLSelectElement) {
214
+ this.setYear(parseInt(e.target.value, 10));
215
+ }
216
+ };
217
+ this.handleInputChange = (e) => {
218
+ const target = e.target;
219
+ const cleanedValue = cleanValue(target, DISALLOWED_CHARACTERS);
220
+ this.setValue(cleanedValue);
221
+ };
222
+ this.prepareEvent = (value) => {
223
+ const event = {
224
+ component: "dso-date-picker-legacy",
225
+ value: "",
226
+ valueAsDate: undefined,
227
+ };
228
+ if (value instanceof Date) {
229
+ event.valueAsDate = value;
230
+ }
231
+ else {
232
+ event.value = value;
233
+ event.valueAsDate = parseDutchDate(value);
234
+ }
235
+ if (event.valueAsDate) {
236
+ event.value = printDutchDate(event.valueAsDate);
237
+ }
238
+ if (!event.valueAsDate && this.required) {
239
+ event.error = "required";
240
+ }
241
+ if (event.value && !event.valueAsDate) {
242
+ event.error = "invalid";
243
+ }
244
+ if (event.valueAsDate && (this.min || this.max)) {
245
+ const min = parseDutchDate(this.min);
246
+ const max = parseDutchDate(this.max);
247
+ const clampValue = clamp(event.valueAsDate, min, max);
248
+ if (clampValue !== event.valueAsDate && clampValue === min) {
249
+ event.valueAsDate = undefined;
250
+ event.error = "min-range";
251
+ }
252
+ else if (clampValue !== event.valueAsDate && clampValue === max) {
253
+ event.valueAsDate = undefined;
254
+ event.error = "max-range";
255
+ }
256
+ }
257
+ return event;
258
+ };
259
+ this.processFocusedDayNode = (element) => {
260
+ this.focusedDayNode = element;
261
+ if (this.activeFocus && this.open) {
262
+ setTimeout(() => element.focus(), 0);
263
+ }
264
+ };
265
+ this.activeFocus = false;
266
+ this.focusedDay = new Date();
267
+ this.open = false;
268
+ this.visible = false;
269
+ this.name = "date";
270
+ this.identifier = undefined;
271
+ this.disabled = false;
272
+ this.role = null;
273
+ this.direction = "right";
274
+ this.required = false;
275
+ this.invalid = undefined;
276
+ this.describedBy = undefined;
277
+ this.dsoAutofocus = false;
278
+ this.value = "";
279
+ this.min = undefined;
280
+ this.max = undefined;
281
+ }
282
+ /**
283
+ * Component event handling.
284
+ */
285
+ handleDocumentClick(e) {
286
+ if (!this.open) {
287
+ return;
288
+ }
289
+ const path = e.composedPath();
290
+ for (const target of path) {
291
+ if (target instanceof Node && this.element.contains(target)) {
292
+ return;
293
+ }
294
+ }
295
+ this.hide(false);
296
+ }
297
+ /**
298
+ * Sets focus on the date picker's input. Use this method instead of the global `focus()`.
299
+ */
300
+ async setFocus() {
301
+ var _a;
302
+ return (_a = this.datePickerLegacyInput) === null || _a === void 0 ? void 0 : _a.focus();
303
+ }
304
+ /**
305
+ * Public methods API
306
+ */
307
+ /**
308
+ * Show the calendar modal, moving focus to the calendar inside.
309
+ */
310
+ async show() {
311
+ if (typeof this.hideTimeoutId !== "undefined") {
312
+ clearTimeout(this.hideTimeoutId);
313
+ }
314
+ this.visible = true;
315
+ setTimeout(() => {
316
+ this.open = true;
317
+ this.setFocusedDay(parseDutchDate(this.value) || new Date());
318
+ if (typeof this.focusTimeoutId !== "undefined") {
319
+ clearTimeout(this.focusTimeoutId);
320
+ }
321
+ this.focusTimeoutId = setTimeout(() => { var _a; return (_a = this.monthSelectNode) === null || _a === void 0 ? void 0 : _a.focus(); }, TRANSITION_MS);
322
+ });
323
+ }
324
+ /**
325
+ * Hide the calendar modal. Set `moveFocusToButton` to false to prevent focus
326
+ * returning to the date picker's button. Default is true.
327
+ */
328
+ async hide(moveFocusToButton = true) {
329
+ this.open = false;
330
+ // in cases where calendar is quickly shown and hidden
331
+ // we should avoid moving focus to the button
332
+ if (typeof this.focusTimeoutId !== "undefined") {
333
+ clearTimeout(this.focusTimeoutId);
334
+ }
335
+ this.hideTimeoutId = setTimeout(() => {
336
+ if (moveFocusToButton && this.datePickerLegacyButton) {
337
+ this.datePickerLegacyButton.focus();
338
+ }
339
+ this.visible = false;
340
+ }, TRANSITION_MS + 200);
341
+ }
342
+ addDays(days) {
343
+ this.setFocusedDay(addDays(this.focusedDay, days));
344
+ }
345
+ addMonths(months) {
346
+ this.setMonth(this.focusedDay.getMonth() + months);
347
+ }
348
+ addYears(years) {
349
+ this.setYear(this.focusedDay.getFullYear() + years);
350
+ }
351
+ startOfWeek() {
352
+ this.setFocusedDay(startOfWeek(this.focusedDay, this.firstDayOfWeek));
353
+ }
354
+ endOfWeek() {
355
+ this.setFocusedDay(endOfWeek(this.focusedDay, this.firstDayOfWeek));
356
+ }
357
+ setMonth(month) {
358
+ const min = setMonth(startOfMonth(this.focusedDay), month);
359
+ const max = endOfMonth(min);
360
+ const date = setMonth(this.focusedDay, month);
361
+ this.setFocusedDay(clamp(date, min, max));
362
+ }
363
+ setYear(year) {
364
+ const min = setYear(startOfMonth(this.focusedDay), year);
365
+ const max = endOfMonth(min);
366
+ const date = setYear(this.focusedDay, year);
367
+ this.setFocusedDay(clamp(date, min, max));
368
+ }
369
+ setFocusedDay(day) {
370
+ this.focusedDay = clamp(day, parseDutchDate(this.min), parseDutchDate(this.max));
371
+ }
372
+ setValue(value) {
373
+ const event = this.prepareEvent(value);
374
+ this.value = typeof value === "string" ? value : event.value;
375
+ if (this.value !== this.previousValue) {
376
+ this.dsoDateChange.emit(event);
377
+ this.previousValue = this.value;
378
+ }
379
+ }
380
+ componentWillLoad() {
381
+ const minDate = parseDutchDate(this.min);
382
+ const maxDate = parseDutchDate(this.max);
383
+ if (minDate && minDate > this.focusedDay) {
384
+ this.focusedDay = minDate;
385
+ }
386
+ if (maxDate && maxDate < this.focusedDay) {
387
+ this.focusedDay = maxDate;
388
+ }
389
+ }
390
+ componentDidLoad() {
391
+ const valueAsDate = parseDutchDate(this.value);
392
+ if (valueAsDate) {
393
+ this.previousValue = this.value = printDutchDate(valueAsDate);
394
+ }
395
+ if (this.dsoAutofocus) {
396
+ this.setFocus();
397
+ }
398
+ }
399
+ /**
400
+ * render() function
401
+ * Always the last one in the class.
402
+ */
403
+ render() {
404
+ var _a, _b;
405
+ const valueAsDate = parseDutchDate(this.value);
406
+ const formattedDate = valueAsDate && printDutchDate(valueAsDate);
407
+ const selectedYear = (valueAsDate || this.focusedDay).getFullYear();
408
+ const focusedMonth = this.focusedDay.getMonth();
409
+ const focusedYear = this.focusedDay.getFullYear();
410
+ const minDate = parseDutchDate(this.min);
411
+ const maxDate = parseDutchDate(this.max);
412
+ const prevMonthDisabled = minDate && minDate.getMonth() === focusedMonth && minDate.getFullYear() === focusedYear;
413
+ const nextMonthDisabled = maxDate && maxDate.getMonth() === focusedMonth && maxDate.getFullYear() === focusedYear;
414
+ let minYear = selectedYear - 10;
415
+ let maxYear = selectedYear + 10;
416
+ if (minDate) {
417
+ minYear = Math.max(minYear, minDate.getFullYear());
418
+ }
419
+ if (maxDate) {
420
+ maxYear = Math.min(maxYear, maxDate.getFullYear());
421
+ }
422
+ 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: {
423
+ "dso-date__dialog": true,
424
+ "is-left": this.direction === "left",
425
+ "is-active": this.open,
426
+ }, 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) => {
427
+ const index = this.localization.monthNames.indexOf(month);
428
+ return (h("option", { key: month, value: index, selected: index === focusedMonth }, month));
429
+ })), 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 }))))));
430
+ }
431
+ static get is() { return "dso-date-picker-legacy"; }
432
+ static get encapsulation() { return "scoped"; }
433
+ static get originalStyleUrls() {
434
+ return {
435
+ "$": ["date-picker-legacy.scss"]
436
+ };
437
+ }
438
+ static get styleUrls() {
439
+ return {
440
+ "$": ["date-picker-legacy.css"]
441
+ };
442
+ }
443
+ static get properties() {
444
+ return {
445
+ "name": {
446
+ "type": "string",
447
+ "mutable": false,
448
+ "complexType": {
449
+ "original": "string",
450
+ "resolved": "string",
451
+ "references": {}
452
+ },
453
+ "required": false,
454
+ "optional": false,
455
+ "docs": {
456
+ "tags": [],
457
+ "text": "Name of the date picker input."
458
+ },
459
+ "attribute": "name",
460
+ "reflect": false,
461
+ "defaultValue": "\"date\""
462
+ },
463
+ "identifier": {
464
+ "type": "string",
465
+ "mutable": false,
466
+ "complexType": {
467
+ "original": "string | undefined",
468
+ "resolved": "string | undefined",
469
+ "references": {}
470
+ },
471
+ "required": false,
472
+ "optional": false,
473
+ "docs": {
474
+ "tags": [],
475
+ "text": "Adds a unique identifier for the date picker input. Use this instead of html `id` attribute."
476
+ },
477
+ "attribute": "identifier",
478
+ "reflect": false
479
+ },
480
+ "disabled": {
481
+ "type": "boolean",
482
+ "mutable": false,
483
+ "complexType": {
484
+ "original": "boolean",
485
+ "resolved": "boolean",
486
+ "references": {}
487
+ },
488
+ "required": false,
489
+ "optional": false,
490
+ "docs": {
491
+ "tags": [],
492
+ "text": "Makes the date picker input component disabled. This prevents users from being able to\r\ninteract with the input, and conveys its inactive state to assistive technologies."
493
+ },
494
+ "attribute": "disabled",
495
+ "reflect": true,
496
+ "defaultValue": "false"
497
+ },
498
+ "role": {
499
+ "type": "string",
500
+ "mutable": false,
501
+ "complexType": {
502
+ "original": "string | null",
503
+ "resolved": "null | string",
504
+ "references": {}
505
+ },
506
+ "required": false,
507
+ "optional": false,
508
+ "docs": {
509
+ "tags": [],
510
+ "text": "Defines a specific role attribute for the date picker input."
511
+ },
512
+ "attribute": "role",
513
+ "reflect": false,
514
+ "defaultValue": "null"
515
+ },
516
+ "direction": {
517
+ "type": "string",
518
+ "mutable": false,
519
+ "complexType": {
520
+ "original": "DsoDatePickerLegacyDirection",
521
+ "resolved": "\"left\" | \"right\"",
522
+ "references": {
523
+ "DsoDatePickerLegacyDirection": {
524
+ "location": "import",
525
+ "path": "./date-picker-legacy.interfaces",
526
+ "id": "src/components/date-picker-legacy/date-picker-legacy.interfaces.ts::DsoDatePickerLegacyDirection"
527
+ }
528
+ }
529
+ },
530
+ "required": false,
531
+ "optional": false,
532
+ "docs": {
533
+ "tags": [],
534
+ "text": "Forces the opening direction of the calendar modal to be always left or right.\r\nThis setting can be useful when the input is smaller than the opening date picker\r\nwould be as by default the picker always opens towards right."
535
+ },
536
+ "attribute": "direction",
537
+ "reflect": false,
538
+ "defaultValue": "\"right\""
539
+ },
540
+ "required": {
541
+ "type": "boolean",
542
+ "mutable": false,
543
+ "complexType": {
544
+ "original": "boolean",
545
+ "resolved": "boolean",
546
+ "references": {}
547
+ },
548
+ "required": false,
549
+ "optional": false,
550
+ "docs": {
551
+ "tags": [],
552
+ "text": "Should the input be marked as required?"
553
+ },
554
+ "attribute": "required",
555
+ "reflect": false,
556
+ "defaultValue": "false"
557
+ },
558
+ "invalid": {
559
+ "type": "boolean",
560
+ "mutable": false,
561
+ "complexType": {
562
+ "original": "boolean",
563
+ "resolved": "boolean | undefined",
564
+ "references": {}
565
+ },
566
+ "required": false,
567
+ "optional": true,
568
+ "docs": {
569
+ "tags": [],
570
+ "text": "Is input invalid?"
571
+ },
572
+ "attribute": "invalid",
573
+ "reflect": true
574
+ },
575
+ "describedBy": {
576
+ "type": "string",
577
+ "mutable": false,
578
+ "complexType": {
579
+ "original": "string",
580
+ "resolved": "string | undefined",
581
+ "references": {}
582
+ },
583
+ "required": false,
584
+ "optional": true,
585
+ "docs": {
586
+ "tags": [],
587
+ "text": "ID of element that describes the input element"
588
+ },
589
+ "attribute": "described-by",
590
+ "reflect": false
591
+ },
592
+ "dsoAutofocus": {
593
+ "type": "boolean",
594
+ "mutable": false,
595
+ "complexType": {
596
+ "original": "boolean",
597
+ "resolved": "boolean",
598
+ "references": {}
599
+ },
600
+ "required": false,
601
+ "optional": false,
602
+ "docs": {
603
+ "tags": [],
604
+ "text": "Should the input be focused on load?"
605
+ },
606
+ "attribute": "dso-autofocus",
607
+ "reflect": false,
608
+ "defaultValue": "false"
609
+ },
610
+ "value": {
611
+ "type": "string",
612
+ "mutable": true,
613
+ "complexType": {
614
+ "original": "string",
615
+ "resolved": "string",
616
+ "references": {}
617
+ },
618
+ "required": false,
619
+ "optional": false,
620
+ "docs": {
621
+ "tags": [],
622
+ "text": "Date value. Must be in Dutch date format: DD-MM-YYYY."
623
+ },
624
+ "attribute": "value",
625
+ "reflect": true,
626
+ "defaultValue": "\"\""
627
+ },
628
+ "min": {
629
+ "type": "string",
630
+ "mutable": false,
631
+ "complexType": {
632
+ "original": "string | undefined",
633
+ "resolved": "string | undefined",
634
+ "references": {}
635
+ },
636
+ "required": false,
637
+ "optional": false,
638
+ "docs": {
639
+ "tags": [],
640
+ "text": "Minimum date allowed to be picked. Must be in Dutch date format: DD-MM-YYYY.\r\nThis setting can be used alone or together with the max property."
641
+ },
642
+ "attribute": "min",
643
+ "reflect": false
644
+ },
645
+ "max": {
646
+ "type": "string",
647
+ "mutable": false,
648
+ "complexType": {
649
+ "original": "string | undefined",
650
+ "resolved": "string | undefined",
651
+ "references": {}
652
+ },
653
+ "required": false,
654
+ "optional": false,
655
+ "docs": {
656
+ "tags": [],
657
+ "text": "Maximum date allowed to be picked. Must be in Dutch date format: DD-MM-YYYY.\r\nThis setting can be used alone or together with the min property."
658
+ },
659
+ "attribute": "max",
660
+ "reflect": false
661
+ }
662
+ };
663
+ }
664
+ static get states() {
665
+ return {
666
+ "activeFocus": {},
667
+ "focusedDay": {},
668
+ "open": {},
669
+ "visible": {}
670
+ };
671
+ }
672
+ static get events() {
673
+ return [{
674
+ "method": "dsoDateChange",
675
+ "name": "dsoDateChange",
676
+ "bubbles": true,
677
+ "cancelable": true,
678
+ "composed": true,
679
+ "docs": {
680
+ "tags": [],
681
+ "text": "Event emitted when a date is selected."
682
+ },
683
+ "complexType": {
684
+ "original": "DsoDatePickerLegacyChangeEvent",
685
+ "resolved": "{ component: \"dso-date-picker-legacy\"; valueAsDate: Date | undefined; value: string; error?: \"required\" | \"min-range\" | \"max-range\" | \"invalid\" | undefined; }",
686
+ "references": {
687
+ "DsoDatePickerLegacyChangeEvent": {
688
+ "location": "import",
689
+ "path": "./date-picker-legacy.interfaces",
690
+ "id": "src/components/date-picker-legacy/date-picker-legacy.interfaces.ts::DsoDatePickerLegacyChangeEvent"
691
+ }
692
+ }
693
+ }
694
+ }, {
695
+ "method": "dsoBlur",
696
+ "name": "dsoBlur",
697
+ "bubbles": true,
698
+ "cancelable": true,
699
+ "composed": true,
700
+ "docs": {
701
+ "tags": [],
702
+ "text": "Event emitted the date picker input is blurred."
703
+ },
704
+ "complexType": {
705
+ "original": "DsoDatePickerLegacyFocusEvent",
706
+ "resolved": "{ component: \"dso-date-picker-legacy\"; }",
707
+ "references": {
708
+ "DsoDatePickerLegacyFocusEvent": {
709
+ "location": "import",
710
+ "path": "./date-picker-legacy.interfaces",
711
+ "id": "src/components/date-picker-legacy/date-picker-legacy.interfaces.ts::DsoDatePickerLegacyFocusEvent"
712
+ }
713
+ }
714
+ }
715
+ }, {
716
+ "method": "dsoKeyUp",
717
+ "name": "dsoKeyUp",
718
+ "bubbles": true,
719
+ "cancelable": true,
720
+ "composed": true,
721
+ "docs": {
722
+ "tags": [],
723
+ "text": "Event emitted on key up in the date picker input."
724
+ },
725
+ "complexType": {
726
+ "original": "DsoDatePickerLegacyKeyboardEvent",
727
+ "resolved": "{ component: \"dso-date-picker-legacy\"; originalEvent: KeyboardEvent; }",
728
+ "references": {
729
+ "DsoDatePickerLegacyKeyboardEvent": {
730
+ "location": "import",
731
+ "path": "./date-picker-legacy.interfaces",
732
+ "id": "src/components/date-picker-legacy/date-picker-legacy.interfaces.ts::DsoDatePickerLegacyKeyboardEvent"
733
+ }
734
+ }
735
+ }
736
+ }, {
737
+ "method": "dsoKeyDown",
738
+ "name": "dsoKeyDown",
739
+ "bubbles": true,
740
+ "cancelable": true,
741
+ "composed": true,
742
+ "docs": {
743
+ "tags": [],
744
+ "text": "Event emitted on key down in the date picker input."
745
+ },
746
+ "complexType": {
747
+ "original": "DsoDatePickerLegacyKeyboardEvent",
748
+ "resolved": "{ component: \"dso-date-picker-legacy\"; originalEvent: KeyboardEvent; }",
749
+ "references": {
750
+ "DsoDatePickerLegacyKeyboardEvent": {
751
+ "location": "import",
752
+ "path": "./date-picker-legacy.interfaces",
753
+ "id": "src/components/date-picker-legacy/date-picker-legacy.interfaces.ts::DsoDatePickerLegacyKeyboardEvent"
754
+ }
755
+ }
756
+ }
757
+ }, {
758
+ "method": "dsoFocus",
759
+ "name": "dsoFocus",
760
+ "bubbles": true,
761
+ "cancelable": true,
762
+ "composed": true,
763
+ "docs": {
764
+ "tags": [],
765
+ "text": "Event emitted the date picker input is focused."
766
+ },
767
+ "complexType": {
768
+ "original": "DsoDatePickerLegacyFocusEvent",
769
+ "resolved": "{ component: \"dso-date-picker-legacy\"; }",
770
+ "references": {
771
+ "DsoDatePickerLegacyFocusEvent": {
772
+ "location": "import",
773
+ "path": "./date-picker-legacy.interfaces",
774
+ "id": "src/components/date-picker-legacy/date-picker-legacy.interfaces.ts::DsoDatePickerLegacyFocusEvent"
775
+ }
776
+ }
777
+ }
778
+ }];
779
+ }
780
+ static get methods() {
781
+ return {
782
+ "setFocus": {
783
+ "complexType": {
784
+ "signature": "() => Promise<void | undefined>",
785
+ "parameters": [],
786
+ "references": {
787
+ "Promise": {
788
+ "location": "global",
789
+ "id": "global::Promise"
790
+ }
791
+ },
792
+ "return": "Promise<void | undefined>"
793
+ },
794
+ "docs": {
795
+ "text": "Sets focus on the date picker's input. Use this method instead of the global `focus()`.",
796
+ "tags": []
797
+ }
798
+ },
799
+ "show": {
800
+ "complexType": {
801
+ "signature": "() => Promise<void>",
802
+ "parameters": [],
803
+ "references": {
804
+ "Promise": {
805
+ "location": "global",
806
+ "id": "global::Promise"
807
+ }
808
+ },
809
+ "return": "Promise<void>"
810
+ },
811
+ "docs": {
812
+ "text": "Show the calendar modal, moving focus to the calendar inside.",
813
+ "tags": []
814
+ }
815
+ },
816
+ "hide": {
817
+ "complexType": {
818
+ "signature": "(moveFocusToButton?: boolean) => Promise<void>",
819
+ "parameters": [{
820
+ "tags": [],
821
+ "text": ""
822
+ }],
823
+ "references": {
824
+ "Promise": {
825
+ "location": "global",
826
+ "id": "global::Promise"
827
+ }
828
+ },
829
+ "return": "Promise<void>"
830
+ },
831
+ "docs": {
832
+ "text": "Hide the calendar modal. Set `moveFocusToButton` to false to prevent focus\r\nreturning to the date picker's button. Default is true.",
833
+ "tags": []
834
+ }
835
+ }
836
+ };
837
+ }
838
+ static get elementRef() { return "element"; }
839
+ static get listeners() {
840
+ return [{
841
+ "name": "click",
842
+ "method": "handleDocumentClick",
843
+ "target": "document",
844
+ "capture": true,
845
+ "passive": false
846
+ }];
847
+ }
848
+ }
849
+ //# sourceMappingURL=date-picker-legacy.js.map