@dso-toolkit/core 59.0.0 → 60.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. package/dist/cjs/dso-date-picker.cjs.entry.js +49 -568
  2. package/dist/cjs/dso-date-picker.cjs.entry.js.map +1 -1
  3. package/dist/cjs/dso-dropdown-menu.cjs.entry.js +4 -2
  4. package/dist/cjs/dso-dropdown-menu.cjs.entry.js.map +1 -1
  5. package/dist/cjs/dso-expandable.cjs.entry.js +1 -1
  6. package/dist/cjs/dso-expandable.cjs.entry.js.map +1 -1
  7. package/dist/cjs/dso-header.cjs.entry.js +1 -1
  8. package/dist/cjs/dso-header.cjs.entry.js.map +1 -1
  9. package/dist/cjs/dso-info_2.cjs.entry.js +15 -2
  10. package/dist/cjs/dso-info_2.cjs.entry.js.map +1 -1
  11. package/dist/cjs/dso-toggletip.cjs.entry.js +1 -1
  12. package/dist/cjs/dso-toggletip.cjs.entry.js.map +1 -1
  13. package/dist/cjs/dso-toolkit.cjs.js +1 -1
  14. package/dist/cjs/dso-tooltip.cjs.entry.js +1 -1
  15. package/dist/cjs/dso-tooltip.cjs.entry.js.map +1 -1
  16. package/dist/cjs/dso-viewer-grid.cjs.entry.js +177 -65
  17. package/dist/cjs/dso-viewer-grid.cjs.entry.js.map +1 -1
  18. package/dist/cjs/loader.cjs.js +1 -1
  19. package/dist/collection/components/date-picker/date-picker.css +4 -425
  20. package/dist/collection/components/date-picker/date-picker.interfaces.js.map +1 -1
  21. package/dist/collection/components/date-picker/date-picker.js +50 -510
  22. package/dist/collection/components/date-picker/date-picker.js.map +1 -1
  23. package/dist/collection/components/date-picker/date-utils.js +24 -100
  24. package/dist/collection/components/date-picker/date-utils.js.map +1 -1
  25. package/dist/collection/components/dropdown-menu/dropdown-menu.js +29 -2
  26. package/dist/collection/components/dropdown-menu/dropdown-menu.js.map +1 -1
  27. package/dist/collection/components/expandable/expandable.css +1 -0
  28. package/dist/collection/components/header/header.js +1 -1
  29. package/dist/collection/components/header/header.js.map +1 -1
  30. package/dist/collection/components/toggletip/toggletip.css +1 -0
  31. package/dist/collection/components/tooltip/tooltip.css +35 -26
  32. package/dist/collection/components/viewer-grid/components/document-panel.js +8 -0
  33. package/dist/collection/components/viewer-grid/components/document-panel.js.map +1 -0
  34. package/dist/collection/components/viewer-grid/components/index.js +1 -0
  35. package/dist/collection/components/viewer-grid/components/index.js.map +1 -1
  36. package/dist/collection/components/viewer-grid/components/main-panel.js +12 -8
  37. package/dist/collection/components/viewer-grid/components/main-panel.js.map +1 -1
  38. package/dist/collection/components/viewer-grid/viewer-grid.css +237 -48
  39. package/dist/collection/components/viewer-grid/viewer-grid.interfaces.js +13 -1
  40. package/dist/collection/components/viewer-grid/viewer-grid.interfaces.js.map +1 -1
  41. package/dist/collection/components/viewer-grid/viewer-grid.js +402 -59
  42. package/dist/collection/components/viewer-grid/viewer-grid.js.map +1 -1
  43. package/dist/components/dropdown-menu.js +5 -2
  44. package/dist/components/dropdown-menu.js.map +1 -1
  45. package/dist/components/dso-date-picker.js +55 -589
  46. package/dist/components/dso-date-picker.js.map +1 -1
  47. package/dist/components/dso-header.js +1 -1
  48. package/dist/components/dso-header.js.map +1 -1
  49. package/dist/components/dso-toggletip.js +1 -1
  50. package/dist/components/dso-toggletip.js.map +1 -1
  51. package/dist/components/dso-viewer-grid.js +186 -69
  52. package/dist/components/dso-viewer-grid.js.map +1 -1
  53. package/dist/components/expandable.js +1 -1
  54. package/dist/components/expandable.js.map +1 -1
  55. package/dist/components/selectable.js +14 -1
  56. package/dist/components/selectable.js.map +1 -1
  57. package/dist/components/tooltip.js +1 -1
  58. package/dist/components/tooltip.js.map +1 -1
  59. package/dist/dso-toolkit/dso-toolkit.esm.js +1 -1
  60. package/dist/dso-toolkit/dso-toolkit.esm.js.map +1 -1
  61. package/dist/dso-toolkit/p-0c14a2e5.entry.js +2 -0
  62. package/dist/dso-toolkit/p-0c14a2e5.entry.js.map +1 -0
  63. package/dist/dso-toolkit/p-4e2407bf.entry.js +2 -0
  64. package/dist/dso-toolkit/p-4e2407bf.entry.js.map +1 -0
  65. package/dist/dso-toolkit/{p-dc6e37dd.entry.js → p-51cfeed4.entry.js} +2 -2
  66. package/dist/dso-toolkit/p-51cfeed4.entry.js.map +1 -0
  67. package/dist/dso-toolkit/{p-298453a9.entry.js → p-7d90b3b2.entry.js} +2 -2
  68. package/dist/dso-toolkit/{p-298453a9.entry.js.map → p-7d90b3b2.entry.js.map} +1 -1
  69. package/dist/dso-toolkit/p-8b24f933.entry.js +2 -0
  70. package/dist/dso-toolkit/p-8b24f933.entry.js.map +1 -0
  71. package/dist/dso-toolkit/p-dbea5bbd.entry.js +2 -0
  72. package/dist/dso-toolkit/p-dbea5bbd.entry.js.map +1 -0
  73. package/dist/dso-toolkit/p-ebda3d53.entry.js +2 -0
  74. package/dist/dso-toolkit/p-ebda3d53.entry.js.map +1 -0
  75. package/dist/dso-toolkit/p-f55b3647.entry.js +2 -0
  76. package/dist/dso-toolkit/{p-3631ce14.entry.js.map → p-f55b3647.entry.js.map} +1 -1
  77. package/dist/esm/dso-date-picker.entry.js +50 -569
  78. package/dist/esm/dso-date-picker.entry.js.map +1 -1
  79. package/dist/esm/dso-dropdown-menu.entry.js +4 -2
  80. package/dist/esm/dso-dropdown-menu.entry.js.map +1 -1
  81. package/dist/esm/dso-expandable.entry.js +1 -1
  82. package/dist/esm/dso-expandable.entry.js.map +1 -1
  83. package/dist/esm/dso-header.entry.js +1 -1
  84. package/dist/esm/dso-header.entry.js.map +1 -1
  85. package/dist/esm/dso-info_2.entry.js +14 -1
  86. package/dist/esm/dso-info_2.entry.js.map +1 -1
  87. package/dist/esm/dso-toggletip.entry.js +1 -1
  88. package/dist/esm/dso-toggletip.entry.js.map +1 -1
  89. package/dist/esm/dso-toolkit.js +1 -1
  90. package/dist/esm/dso-tooltip.entry.js +1 -1
  91. package/dist/esm/dso-tooltip.entry.js.map +1 -1
  92. package/dist/esm/dso-viewer-grid.entry.js +178 -66
  93. package/dist/esm/dso-viewer-grid.entry.js.map +1 -1
  94. package/dist/esm/loader.js +1 -1
  95. package/dist/types/components/date-picker/date-picker.d.ts +8 -99
  96. package/dist/types/components/date-picker/date-picker.interfaces.d.ts +9 -8
  97. package/dist/types/components/date-picker/date-utils.d.ts +6 -34
  98. package/dist/types/components/dropdown-menu/dropdown-menu.d.ts +7 -0
  99. package/dist/types/components/viewer-grid/components/document-panel.d.ts +10 -0
  100. package/dist/types/components/viewer-grid/components/index.d.ts +1 -0
  101. package/dist/types/components/viewer-grid/components/main-panel.d.ts +10 -4
  102. package/dist/types/components/viewer-grid/viewer-grid.d.ts +82 -17
  103. package/dist/types/components/viewer-grid/viewer-grid.interfaces.d.ts +27 -13
  104. package/dist/types/components.d.ts +97 -42
  105. package/package.json +2 -2
  106. package/dist/cjs/create-identifier-5900c27b.js +0 -19
  107. package/dist/cjs/create-identifier-5900c27b.js.map +0 -1
  108. package/dist/collection/components/date-picker/date-localization.js +0 -30
  109. package/dist/collection/components/date-picker/date-localization.js.map +0 -1
  110. package/dist/collection/components/date-picker/date-picker-day.js +0 -20
  111. package/dist/collection/components/date-picker/date-picker-day.js.map +0 -1
  112. package/dist/collection/components/date-picker/date-picker-month.js +0 -26
  113. package/dist/collection/components/date-picker/date-picker-month.js.map +0 -1
  114. package/dist/collection/components/date-picker/utils/month-range.js +0 -28
  115. package/dist/collection/components/date-picker/utils/month-range.js.map +0 -1
  116. package/dist/collection/components/date-picker/utils/range.js +0 -8
  117. package/dist/collection/components/date-picker/utils/range.js.map +0 -1
  118. package/dist/components/create-identifier.js +0 -17
  119. package/dist/components/create-identifier.js.map +0 -1
  120. package/dist/dso-toolkit/p-3631ce14.entry.js +0 -2
  121. package/dist/dso-toolkit/p-41066f6f.entry.js +0 -2
  122. package/dist/dso-toolkit/p-41066f6f.entry.js.map +0 -1
  123. package/dist/dso-toolkit/p-95b70498.entry.js +0 -2
  124. package/dist/dso-toolkit/p-95b70498.entry.js.map +0 -1
  125. package/dist/dso-toolkit/p-9dbe2931.entry.js +0 -2
  126. package/dist/dso-toolkit/p-9dbe2931.entry.js.map +0 -1
  127. package/dist/dso-toolkit/p-ad44136d.entry.js +0 -2
  128. package/dist/dso-toolkit/p-ad44136d.entry.js.map +0 -1
  129. package/dist/dso-toolkit/p-c19cfe3f.js +0 -2
  130. package/dist/dso-toolkit/p-c19cfe3f.js.map +0 -1
  131. package/dist/dso-toolkit/p-dc6e37dd.entry.js.map +0 -1
  132. package/dist/dso-toolkit/p-f08a5a06.entry.js +0 -2
  133. package/dist/dso-toolkit/p-f08a5a06.entry.js.map +0 -1
  134. package/dist/esm/create-identifier-479a4699.js +0 -17
  135. package/dist/esm/create-identifier-479a4699.js.map +0 -1
  136. package/dist/types/components/date-picker/date-localization.d.ts +0 -19
  137. package/dist/types/components/date-picker/date-picker-day.d.ts +0 -11
  138. package/dist/types/components/date-picker/date-picker-month.d.ts +0 -20
  139. package/dist/types/components/date-picker/utils/month-range.d.ts +0 -2
  140. package/dist/types/components/date-picker/utils/range.d.ts +0 -1
@@ -1,72 +1,18 @@
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 { DatePickerMonth } 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
- }
1
+ import { h } from "@stencil/core";
2
+ import { clamp, parseDate, parseToValueFormat, printDutchDate } from "./date-utils";
39
3
  export class DsoDatePicker {
40
4
  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
5
  this.handleBlur = (event) => {
68
6
  event.stopPropagation();
69
7
  this.dsoBlur.emit({
8
+ originalEvent: event,
9
+ component: "dso-date-picker",
10
+ });
11
+ };
12
+ this.handleFocus = (event) => {
13
+ event.stopPropagation();
14
+ this.dsoFocus.emit({
15
+ originalEvent: event,
70
16
  component: "dso-date-picker",
71
17
  });
72
18
  };
@@ -84,154 +30,18 @@ export class DsoDatePicker {
84
30
  originalEvent: event,
85
31
  });
86
32
  };
87
- this.handleFocus = (event) => {
88
- event.stopPropagation();
89
- this.dsoFocus.emit({
90
- component: "dso-date-picker",
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
33
  this.handleInputChange = (e) => {
218
34
  const target = e.target;
219
- const cleanedValue = cleanValue(target, DISALLOWED_CHARACTERS);
220
- this.setValue(cleanedValue);
221
- };
222
- this.prepareEvent = (value) => {
35
+ if (!(target instanceof HTMLInputElement)) {
36
+ return;
37
+ }
38
+ const { value } = target;
223
39
  const event = {
40
+ originalEvent: e,
224
41
  component: "dso-date-picker",
225
- value: "",
226
- valueAsDate: undefined,
42
+ value,
43
+ valueAsDate: parseDate(value),
227
44
  };
228
- if (value instanceof Date) {
229
- event.valueAsDate = value;
230
- }
231
- else {
232
- event.value = value;
233
- event.valueAsDate = parseDutchDate(value);
234
- }
235
45
  if (event.valueAsDate) {
236
46
  event.value = printDutchDate(event.valueAsDate);
237
47
  }
@@ -242,8 +52,8 @@ export class DsoDatePicker {
242
52
  event.error = "invalid";
243
53
  }
244
54
  if (event.valueAsDate && (this.min || this.max)) {
245
- const min = parseDutchDate(this.min);
246
- const max = parseDutchDate(this.max);
55
+ const min = parseDate(this.min);
56
+ const max = parseDate(this.max);
247
57
  const clampValue = clamp(event.valueAsDate, min, max);
248
58
  if (clampValue !== event.valueAsDate && clampValue === min) {
249
59
  event.valueAsDate = undefined;
@@ -254,23 +64,15 @@ export class DsoDatePicker {
254
64
  event.error = "max-range";
255
65
  }
256
66
  }
257
- return event;
258
- };
259
- this.processFocusedDayNode = (element) => {
260
- this.focusedDayNode = element;
261
- if (this.activeFocus && this.open) {
262
- setTimeout(() => element.focus(), 0);
67
+ this.value = typeof value === "string" ? value : event.value;
68
+ if (this.value !== this.previousValue) {
69
+ this.dsoDateChange.emit(event);
70
+ this.previousValue = this.value;
263
71
  }
264
72
  };
265
- this.activeFocus = false;
266
- this.focusedDay = new Date();
267
- this.open = false;
268
- this.visible = false;
269
- this.name = "date";
73
+ this.name = "dso-date";
270
74
  this.identifier = undefined;
271
75
  this.disabled = false;
272
- this.role = null;
273
- this.direction = "right";
274
76
  this.required = false;
275
77
  this.invalid = undefined;
276
78
  this.describedBy = undefined;
@@ -279,154 +81,9 @@ export class DsoDatePicker {
279
81
  this.min = undefined;
280
82
  this.max = undefined;
281
83
  }
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.datePickerInput) === 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.datePickerButton) {
337
- this.datePickerButton.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
84
  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.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: {
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(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 }))))));
85
+ var _a;
86
+ return (h("input", { type: "date", id: this.identifier, class: "dso-date__input", value: parseToValueFormat(this.value), name: this.name, min: parseToValueFormat(this.min), max: parseToValueFormat(this.max), disabled: this.disabled || undefined, required: this.required || undefined, "aria-autocomplete": "none", "aria-invalid": (_a = this.invalid) === null || _a === void 0 ? void 0 : _a.toString(), "aria-describedby": this.describedBy, autoComplete: "off", autofocus: this.dsoAutofocus || undefined, onBlur: this.handleBlur, onFocus: this.handleFocus, onKeyUp: this.handleKeyUp, onKeyDown: this.handleKeyDown, onChange: this.handleInputChange }));
430
87
  }
431
88
  static get is() { return "dso-date-picker"; }
432
89
  static get encapsulation() { return "scoped"; }
@@ -458,7 +115,7 @@ export class DsoDatePicker {
458
115
  },
459
116
  "attribute": "name",
460
117
  "reflect": false,
461
- "defaultValue": "\"date\""
118
+ "defaultValue": "\"dso-date\""
462
119
  },
463
120
  "identifier": {
464
121
  "type": "string",
@@ -495,48 +152,6 @@ export class DsoDatePicker {
495
152
  "reflect": true,
496
153
  "defaultValue": "false"
497
154
  },
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": "DsoDatePickerDirection",
521
- "resolved": "\"left\" | \"right\"",
522
- "references": {
523
- "DsoDatePickerDirection": {
524
- "location": "import",
525
- "path": "./date-picker.interfaces",
526
- "id": "src/components/date-picker/date-picker.interfaces.ts::DsoDatePickerDirection"
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
155
  "required": {
541
156
  "type": "boolean",
542
157
  "mutable": false,
@@ -552,7 +167,7 @@ export class DsoDatePicker {
552
167
  "text": "Should the input be marked as required?"
553
168
  },
554
169
  "attribute": "required",
555
- "reflect": false,
170
+ "reflect": true,
556
171
  "defaultValue": "false"
557
172
  },
558
173
  "invalid": {
@@ -609,7 +224,7 @@ export class DsoDatePicker {
609
224
  },
610
225
  "value": {
611
226
  "type": "string",
612
- "mutable": true,
227
+ "mutable": false,
613
228
  "complexType": {
614
229
  "original": "string",
615
230
  "resolved": "string",
@@ -622,7 +237,7 @@ export class DsoDatePicker {
622
237
  "text": "Date value. Must be in Dutch date format: DD-MM-YYYY."
623
238
  },
624
239
  "attribute": "value",
625
- "reflect": true,
240
+ "reflect": false,
626
241
  "defaultValue": "\"\""
627
242
  },
628
243
  "min": {
@@ -661,14 +276,6 @@ export class DsoDatePicker {
661
276
  }
662
277
  };
663
278
  }
664
- static get states() {
665
- return {
666
- "activeFocus": {},
667
- "focusedDay": {},
668
- "open": {},
669
- "visible": {}
670
- };
671
- }
672
279
  static get events() {
673
280
  return [{
674
281
  "method": "dsoDateChange",
@@ -681,13 +288,13 @@ export class DsoDatePicker {
681
288
  "text": "Event emitted when a date is selected."
682
289
  },
683
290
  "complexType": {
684
- "original": "DsoDatePickerChangeEvent",
685
- "resolved": "{ component: \"dso-date-picker\"; valueAsDate: Date | undefined; value: string; error?: \"invalid\" | \"required\" | \"min-range\" | \"max-range\" | undefined; }",
291
+ "original": "DatePickerChangeEvent",
292
+ "resolved": "DatePickerChangeEvent",
686
293
  "references": {
687
- "DsoDatePickerChangeEvent": {
294
+ "DatePickerChangeEvent": {
688
295
  "location": "import",
689
296
  "path": "./date-picker.interfaces",
690
- "id": "src/components/date-picker/date-picker.interfaces.ts::DsoDatePickerChangeEvent"
297
+ "id": "src/components/date-picker/date-picker.interfaces.ts::DatePickerChangeEvent"
691
298
  }
692
299
  }
693
300
  }
@@ -702,13 +309,13 @@ export class DsoDatePicker {
702
309
  "text": "Event emitted the date picker input is blurred."
703
310
  },
704
311
  "complexType": {
705
- "original": "DsoDatePickerFocusEvent",
706
- "resolved": "{ component: \"dso-date-picker\"; }",
312
+ "original": "DatePickerFocusEvent",
313
+ "resolved": "DatePickerFocusEvent",
707
314
  "references": {
708
- "DsoDatePickerFocusEvent": {
315
+ "DatePickerFocusEvent": {
709
316
  "location": "import",
710
317
  "path": "./date-picker.interfaces",
711
- "id": "src/components/date-picker/date-picker.interfaces.ts::DsoDatePickerFocusEvent"
318
+ "id": "src/components/date-picker/date-picker.interfaces.ts::DatePickerFocusEvent"
712
319
  }
713
320
  }
714
321
  }
@@ -723,13 +330,13 @@ export class DsoDatePicker {
723
330
  "text": "Event emitted on key up in the date picker input."
724
331
  },
725
332
  "complexType": {
726
- "original": "DsoDatePickerKeyboardEvent",
727
- "resolved": "{ component: \"dso-date-picker\"; originalEvent: KeyboardEvent; }",
333
+ "original": "DatePickerKeyboardEvent",
334
+ "resolved": "DatePickerKeyboardEvent",
728
335
  "references": {
729
- "DsoDatePickerKeyboardEvent": {
336
+ "DatePickerKeyboardEvent": {
730
337
  "location": "import",
731
338
  "path": "./date-picker.interfaces",
732
- "id": "src/components/date-picker/date-picker.interfaces.ts::DsoDatePickerKeyboardEvent"
339
+ "id": "src/components/date-picker/date-picker.interfaces.ts::DatePickerKeyboardEvent"
733
340
  }
734
341
  }
735
342
  }
@@ -744,13 +351,13 @@ export class DsoDatePicker {
744
351
  "text": "Event emitted on key down in the date picker input."
745
352
  },
746
353
  "complexType": {
747
- "original": "DsoDatePickerKeyboardEvent",
748
- "resolved": "{ component: \"dso-date-picker\"; originalEvent: KeyboardEvent; }",
354
+ "original": "DatePickerKeyboardEvent",
355
+ "resolved": "DatePickerKeyboardEvent",
749
356
  "references": {
750
- "DsoDatePickerKeyboardEvent": {
357
+ "DatePickerKeyboardEvent": {
751
358
  "location": "import",
752
359
  "path": "./date-picker.interfaces",
753
- "id": "src/components/date-picker/date-picker.interfaces.ts::DsoDatePickerKeyboardEvent"
360
+ "id": "src/components/date-picker/date-picker.interfaces.ts::DatePickerKeyboardEvent"
754
361
  }
755
362
  }
756
363
  }
@@ -765,85 +372,18 @@ export class DsoDatePicker {
765
372
  "text": "Event emitted the date picker input is focused."
766
373
  },
767
374
  "complexType": {
768
- "original": "DsoDatePickerFocusEvent",
769
- "resolved": "{ component: \"dso-date-picker\"; }",
375
+ "original": "DatePickerFocusEvent",
376
+ "resolved": "DatePickerFocusEvent",
770
377
  "references": {
771
- "DsoDatePickerFocusEvent": {
378
+ "DatePickerFocusEvent": {
772
379
  "location": "import",
773
380
  "path": "./date-picker.interfaces",
774
- "id": "src/components/date-picker/date-picker.interfaces.ts::DsoDatePickerFocusEvent"
381
+ "id": "src/components/date-picker/date-picker.interfaces.ts::DatePickerFocusEvent"
775
382
  }
776
383
  }
777
384
  }
778
385
  }];
779
386
  }
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
387
  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
388
  }
849
389
  //# sourceMappingURL=date-picker.js.map