@carbon-labs/wc-date-picker 0.2.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 (156) hide show
  1. package/LICENSE +201 -0
  2. package/es/__stories__/date-picker.stories.d.ts +949 -0
  3. package/es/components/date-picker/calendar-renderer.d.ts +147 -0
  4. package/es/components/date-picker/calendar-renderer.js +406 -0
  5. package/es/components/date-picker/calendar-renderer.js.map +1 -0
  6. package/es/components/date-picker/date-picker-input-skeleton.d.ts +34 -0
  7. package/es/components/date-picker/date-picker-input-skeleton.js +77 -0
  8. package/es/components/date-picker/date-picker-input-skeleton.js.map +1 -0
  9. package/es/components/date-picker/date-picker-input.d.ts +539 -0
  10. package/es/components/date-picker/date-picker-input.js +413 -0
  11. package/es/components/date-picker/date-picker-input.js.map +1 -0
  12. package/es/components/date-picker/date-picker.d.ts +977 -0
  13. package/es/components/date-picker/date-picker.js +1047 -0
  14. package/es/components/date-picker/date-picker.js.map +1 -0
  15. package/es/components/date-picker/date-picker.scss.js +6 -0
  16. package/es/components/date-picker/date-picker.scss.js.map +1 -0
  17. package/es/components/date-picker/defs.d.ts +45 -0
  18. package/es/components/date-picker/defs.js +51 -0
  19. package/es/components/date-picker/defs.js.map +1 -0
  20. package/es/index.d.ts +10 -0
  21. package/es/index.js +5 -0
  22. package/es/index.js.map +1 -0
  23. package/es/state-machine/actions.d.ts +35 -0
  24. package/es/state-machine/actions.js +860 -0
  25. package/es/state-machine/actions.js.map +1 -0
  26. package/es/state-machine/adapters/web-component-adapter.d.ts +142 -0
  27. package/es/state-machine/adapters/web-component-adapter.js +269 -0
  28. package/es/state-machine/adapters/web-component-adapter.js.map +1 -0
  29. package/es/state-machine/effects.d.ts +35 -0
  30. package/es/state-machine/effects.js +92 -0
  31. package/es/state-machine/effects.js.map +1 -0
  32. package/es/state-machine/guards.d.ts +41 -0
  33. package/es/state-machine/guards.js +143 -0
  34. package/es/state-machine/guards.js.map +1 -0
  35. package/es/state-machine/index.d.ts +12 -0
  36. package/es/state-machine/machine.d.ts +92 -0
  37. package/es/state-machine/machine.js +272 -0
  38. package/es/state-machine/machine.js.map +1 -0
  39. package/es/state-machine/states.d.ts +89 -0
  40. package/es/state-machine/states.js +105 -0
  41. package/es/state-machine/states.js.map +1 -0
  42. package/es/state-machine/temporal-utils.d.ts +203 -0
  43. package/es/state-machine/temporal-utils.js +128 -0
  44. package/es/state-machine/temporal-utils.js.map +1 -0
  45. package/es/state-machine/types.d.ts +163 -0
  46. package/es/temp-imports/.storybook/templates/with-layer.d.ts +26 -0
  47. package/es/temp-imports/globals/decorators/carbon-element.d.ts +45 -0
  48. package/es/temp-imports/globals/decorators/carbon-element.js +63 -0
  49. package/es/temp-imports/globals/decorators/carbon-element.js.map +1 -0
  50. package/es/temp-imports/globals/decorators/host-listener.d.ts +17 -0
  51. package/es/temp-imports/globals/decorators/host-listener.js +62 -0
  52. package/es/temp-imports/globals/decorators/host-listener.js.map +1 -0
  53. package/es/temp-imports/globals/internal/collection-helpers.d.ts +41 -0
  54. package/es/temp-imports/globals/internal/handle.d.ts +16 -0
  55. package/es/temp-imports/globals/internal/icon-loader-utils.d.ts +31 -0
  56. package/es/temp-imports/globals/internal/icon-loader-utils.js +69 -0
  57. package/es/temp-imports/globals/internal/icon-loader-utils.js.map +1 -0
  58. package/es/temp-imports/globals/internal/icon-loader.d.ts +28 -0
  59. package/es/temp-imports/globals/internal/icon-loader.js +43 -0
  60. package/es/temp-imports/globals/internal/icon-loader.js.map +1 -0
  61. package/es/temp-imports/globals/mixins/focus.d.ts +369 -0
  62. package/es/temp-imports/globals/mixins/focus.js +38 -0
  63. package/es/temp-imports/globals/mixins/focus.js.map +1 -0
  64. package/es/temp-imports/globals/mixins/form.d.ts +379 -0
  65. package/es/temp-imports/globals/mixins/form.js +49 -0
  66. package/es/temp-imports/globals/mixins/form.js.map +1 -0
  67. package/es/temp-imports/globals/mixins/host-listener.d.ts +387 -0
  68. package/es/temp-imports/globals/mixins/host-listener.js +76 -0
  69. package/es/temp-imports/globals/mixins/host-listener.js.map +1 -0
  70. package/es/temp-imports/globals/mixins/on.d.ts +9 -0
  71. package/es/temp-imports/globals/mixins/on.js +19 -0
  72. package/es/temp-imports/globals/mixins/on.js.map +1 -0
  73. package/es/temp-imports/globals/settings.d.ts +13 -0
  74. package/es/temp-imports/globals/settings.js +76 -0
  75. package/es/temp-imports/globals/settings.js.map +1 -0
  76. package/es/temp-imports/globals/shared-enums.d.ts +19 -0
  77. package/es/temp-imports/globals/shared-enums.js +23 -0
  78. package/es/temp-imports/globals/shared-enums.js.map +1 -0
  79. package/lib/__stories__/date-picker.stories.d.ts +949 -0
  80. package/lib/components/date-picker/calendar-renderer.d.ts +147 -0
  81. package/lib/components/date-picker/calendar-renderer.js +408 -0
  82. package/lib/components/date-picker/calendar-renderer.js.map +1 -0
  83. package/lib/components/date-picker/date-picker-input-skeleton.d.ts +34 -0
  84. package/lib/components/date-picker/date-picker-input-skeleton.js +79 -0
  85. package/lib/components/date-picker/date-picker-input-skeleton.js.map +1 -0
  86. package/lib/components/date-picker/date-picker-input.d.ts +539 -0
  87. package/lib/components/date-picker/date-picker-input.js +422 -0
  88. package/lib/components/date-picker/date-picker-input.js.map +1 -0
  89. package/lib/components/date-picker/date-picker.d.ts +977 -0
  90. package/lib/components/date-picker/date-picker.js +1049 -0
  91. package/lib/components/date-picker/date-picker.js.map +1 -0
  92. package/lib/components/date-picker/date-picker.scss.js +10 -0
  93. package/lib/components/date-picker/date-picker.scss.js.map +1 -0
  94. package/lib/components/date-picker/defs.d.ts +45 -0
  95. package/lib/components/date-picker/defs.js +56 -0
  96. package/lib/components/date-picker/defs.js.map +1 -0
  97. package/lib/index.d.ts +10 -0
  98. package/lib/index.js +8 -0
  99. package/lib/index.js.map +1 -0
  100. package/lib/state-machine/actions.d.ts +35 -0
  101. package/lib/state-machine/actions.js +864 -0
  102. package/lib/state-machine/actions.js.map +1 -0
  103. package/lib/state-machine/adapters/web-component-adapter.d.ts +142 -0
  104. package/lib/state-machine/adapters/web-component-adapter.js +271 -0
  105. package/lib/state-machine/adapters/web-component-adapter.js.map +1 -0
  106. package/lib/state-machine/effects.d.ts +35 -0
  107. package/lib/state-machine/effects.js +96 -0
  108. package/lib/state-machine/effects.js.map +1 -0
  109. package/lib/state-machine/guards.d.ts +41 -0
  110. package/lib/state-machine/guards.js +147 -0
  111. package/lib/state-machine/guards.js.map +1 -0
  112. package/lib/state-machine/index.d.ts +12 -0
  113. package/lib/state-machine/machine.d.ts +92 -0
  114. package/lib/state-machine/machine.js +274 -0
  115. package/lib/state-machine/machine.js.map +1 -0
  116. package/lib/state-machine/states.d.ts +89 -0
  117. package/lib/state-machine/states.js +105 -0
  118. package/lib/state-machine/states.js.map +1 -0
  119. package/lib/state-machine/temporal-utils.d.ts +203 -0
  120. package/lib/state-machine/temporal-utils.js +136 -0
  121. package/lib/state-machine/temporal-utils.js.map +1 -0
  122. package/lib/state-machine/types.d.ts +163 -0
  123. package/lib/temp-imports/.storybook/templates/with-layer.d.ts +26 -0
  124. package/lib/temp-imports/globals/decorators/carbon-element.d.ts +45 -0
  125. package/lib/temp-imports/globals/decorators/carbon-element.js +65 -0
  126. package/lib/temp-imports/globals/decorators/carbon-element.js.map +1 -0
  127. package/lib/temp-imports/globals/decorators/host-listener.d.ts +17 -0
  128. package/lib/temp-imports/globals/decorators/host-listener.js +66 -0
  129. package/lib/temp-imports/globals/decorators/host-listener.js.map +1 -0
  130. package/lib/temp-imports/globals/internal/collection-helpers.d.ts +41 -0
  131. package/lib/temp-imports/globals/internal/handle.d.ts +16 -0
  132. package/lib/temp-imports/globals/internal/icon-loader-utils.d.ts +31 -0
  133. package/lib/temp-imports/globals/internal/icon-loader-utils.js +72 -0
  134. package/lib/temp-imports/globals/internal/icon-loader-utils.js.map +1 -0
  135. package/lib/temp-imports/globals/internal/icon-loader.d.ts +28 -0
  136. package/lib/temp-imports/globals/internal/icon-loader.js +45 -0
  137. package/lib/temp-imports/globals/internal/icon-loader.js.map +1 -0
  138. package/lib/temp-imports/globals/mixins/focus.d.ts +369 -0
  139. package/lib/temp-imports/globals/mixins/focus.js +42 -0
  140. package/lib/temp-imports/globals/mixins/focus.js.map +1 -0
  141. package/lib/temp-imports/globals/mixins/form.d.ts +379 -0
  142. package/lib/temp-imports/globals/mixins/form.js +53 -0
  143. package/lib/temp-imports/globals/mixins/form.js.map +1 -0
  144. package/lib/temp-imports/globals/mixins/host-listener.d.ts +387 -0
  145. package/lib/temp-imports/globals/mixins/host-listener.js +80 -0
  146. package/lib/temp-imports/globals/mixins/host-listener.js.map +1 -0
  147. package/lib/temp-imports/globals/mixins/on.d.ts +9 -0
  148. package/lib/temp-imports/globals/mixins/on.js +23 -0
  149. package/lib/temp-imports/globals/mixins/on.js.map +1 -0
  150. package/lib/temp-imports/globals/settings.d.ts +13 -0
  151. package/lib/temp-imports/globals/settings.js +79 -0
  152. package/lib/temp-imports/globals/settings.js.map +1 -0
  153. package/lib/temp-imports/globals/shared-enums.d.ts +19 -0
  154. package/lib/temp-imports/globals/shared-enums.js +23 -0
  155. package/lib/temp-imports/globals/shared-enums.js.map +1 -0
  156. package/package.json +44 -0
@@ -0,0 +1,1047 @@
1
+ import { __decorate, __metadata } from 'tslib';
2
+ import { html, LitElement } from 'lit';
3
+ import { property } from 'lit/decorators.js';
4
+ import { prefix } from '../../temp-imports/globals/settings.js';
5
+ import FormMixin from '../../temp-imports/globals/mixins/form.js';
6
+ import HostListenerMixin from '../../temp-imports/globals/mixins/host-listener.js';
7
+ import HostListener from '../../temp-imports/globals/decorators/host-listener.js';
8
+ import { WebComponentAdapter } from '../../state-machine/adapters/web-component-adapter.js';
9
+ import '../../state-machine/machine.js';
10
+ import { DatePickerEvent, DatePickerState } from '../../state-machine/states.js';
11
+ import '../../state-machine/guards.js';
12
+ import '../../state-machine/actions.js';
13
+ import '../../state-machine/effects.js';
14
+ import { parseDateToPlainDate, parseISOToPlainDate } from '../../state-machine/temporal-utils.js';
15
+ import styles from './date-picker.scss.js';
16
+ import { carbonElement } from '../../temp-imports/globals/decorators/carbon-element.js';
17
+
18
+ /**
19
+ * Copyright IBM Corp. 2019, 2026
20
+ *
21
+ * This source code is licensed under the Apache-2.0 license found in the
22
+ * LICENSE file in the root directory of this source tree.
23
+ */
24
+ /**
25
+ * Date picker modes.
26
+ */
27
+ var DATE_PICKER_MODE;
28
+ (function (DATE_PICKER_MODE) {
29
+ /**
30
+ * Simple mode, without calendar dropdown.
31
+ */
32
+ DATE_PICKER_MODE["SIMPLE"] = "simple";
33
+ /**
34
+ * Single date mode.
35
+ */
36
+ DATE_PICKER_MODE["SINGLE"] = "single";
37
+ /**
38
+ * Range mode.
39
+ */
40
+ DATE_PICKER_MODE["RANGE"] = "range";
41
+ })(DATE_PICKER_MODE || (DATE_PICKER_MODE = {}));
42
+ /**
43
+ * Date picker.
44
+ *
45
+ * @element cds-date-picker
46
+ * @fires cds-date-picker-changed - The custom event fired when the date selection changes.
47
+ * @fires cds-date-picker-error - The custom event fired when an error occurs.
48
+ */
49
+ // @ts-expect-error - Mixin inheritance not fully recognized by TypeScript
50
+ let CDSDatePicker = class CDSDatePicker extends HostListenerMixin(FormMixin(LitElement)) {
51
+ constructor() {
52
+ super(...arguments);
53
+ /**
54
+ * The slotted `<cds-date-input kind="from">`.
55
+ */
56
+ this._dateInteractNode = null;
57
+ /**
58
+ * The adapter for Web Component integration.
59
+ */
60
+ this._adapter = null;
61
+ /**
62
+ * Timestamp of when calendar was last closed via Tab key
63
+ */
64
+ this._lastTabCloseTime = 0;
65
+ /**
66
+ * Handles `${prefix}-date-picker-changed` event on this element.
67
+ *
68
+ * @param {CustomEvent} root0 - The event object
69
+ * @param {object} root0.detail - The event detail
70
+ */
71
+ this._handleChange = ({ detail }) => {
72
+ const { selectedDates } = detail;
73
+ if (selectedDates && Array.isArray(selectedDates)) {
74
+ this._value = selectedDates
75
+ .filter((date) => date != null) // Filter out null/undefined values
76
+ .map((date) => {
77
+ if (typeof date === 'string') {
78
+ return date;
79
+ }
80
+ // Handle Temporal.PlainDate
81
+ return date.toString();
82
+ })
83
+ .join('/');
84
+ }
85
+ };
86
+ /**
87
+ * Handles calendar icon click event from date-picker-input
88
+ *
89
+ * @param {CustomEvent} _event - The icon click event
90
+ */
91
+ this._handleIconClick = (_event) => {
92
+ if (this._adapter && !this.disabled && !this.readonly) {
93
+ this._adapter.send(DatePickerEvent.CALENDAR_ICON_CLICK);
94
+ }
95
+ };
96
+ /**
97
+ * Handles input focus event from date-picker-input
98
+ *
99
+ * @param {CustomEvent} event - The focus event
100
+ */
101
+ this._handleInputFocus = (event) => {
102
+ if (this._adapter && !this.disabled && !this.readonly) {
103
+ const { inputType } = event.detail || {};
104
+ this._adapter.send(DatePickerEvent.INPUT_FOCUS, { inputType });
105
+ // Don't auto-open calendar if we JUST closed it via Tab key (within 100ms)
106
+ // This prevents the immediate reopen when Tab moves focus to input,
107
+ // but allows normal opening after that brief window
108
+ const timeSinceTabClose = Date.now() - this._lastTabCloseTime;
109
+ const shouldSkipOpen = timeSinceTabClose < 100;
110
+ if (!shouldSkipOpen) {
111
+ // Open calendar when input is focused (matching current Carbon behavior)
112
+ this._adapter.send(DatePickerEvent.CALENDAR_OPEN);
113
+ }
114
+ }
115
+ };
116
+ /**
117
+ * Handles input blur event from date-picker-input
118
+ *
119
+ * @param {CustomEvent} event - The blur event
120
+ */
121
+ this._handleInputBlur = (event) => {
122
+ if (this._adapter) {
123
+ const { inputType } = event.detail || {};
124
+ this._adapter.send(DatePickerEvent.INPUT_BLUR, { inputType });
125
+ }
126
+ };
127
+ /**
128
+ * Handles state machine state changes
129
+ *
130
+ * @param {StateTransition} transition - The state transition
131
+ * @param {DatePickerState} transition.from - Previous state
132
+ * @param {DatePickerState} transition.to - New state
133
+ * @param {DatePickerContext} transition.context - Current context
134
+ */
135
+ this._handleStateChange = (transition) => {
136
+ var _a, _b;
137
+ const { to, from, context } = transition;
138
+ const newState = to;
139
+ // Update open property based on state
140
+ if (newState === DatePickerState.CALENDAR_OPEN) {
141
+ this.open = true;
142
+ // If we're staying in CALENDAR_OPEN state (keyboard navigation),
143
+ // trigger a re-render to update the calendar with new focusedDate/viewDate
144
+ if (from === DatePickerState.CALENDAR_OPEN) {
145
+ this.requestUpdate();
146
+ }
147
+ }
148
+ else if (newState === DatePickerState.SELECTING_END) {
149
+ // Keep calendar open while selecting end date in range mode
150
+ this.open = true;
151
+ // If we're staying in SELECTING_END state (keyboard navigation),
152
+ // trigger a re-render to update the calendar with new focusedDate/viewDate
153
+ if (from === DatePickerState.SELECTING_END) {
154
+ this.requestUpdate();
155
+ }
156
+ }
157
+ else if (newState === DatePickerState.IDLE) {
158
+ this.open = false;
159
+ }
160
+ else if (newState === DatePickerState.FOCUSED) {
161
+ // Only close calendar if not coming from CALENDAR_OPEN (Enter key)
162
+ // When coming from CALENDAR_OPEN, the action sets context.isOpen
163
+ if (from !== DatePickerState.CALENDAR_OPEN &&
164
+ from !== DatePickerState.SELECTING_END) {
165
+ this.open = false;
166
+ }
167
+ else {
168
+ // Use the isOpen value from context (set by ENTER_KEY action)
169
+ this.open = (_a = context.isOpen) !== null && _a !== void 0 ? _a : false;
170
+ }
171
+ }
172
+ else if (newState === DatePickerState.DATE_SELECTED) {
173
+ // Update open property based on context
174
+ this.open = (_b = context.isOpen) !== null && _b !== void 0 ? _b : false;
175
+ // Trigger re-render to update the calendar visibility
176
+ this.requestUpdate();
177
+ }
178
+ // Dispatch change event and update input when dates are selected
179
+ // This handles DATE_SELECTED state, FOCUSED state (from ENTER_KEY), and SELECTING_END state (after start date selected)
180
+ const shouldUpdateInput = newState === DatePickerState.DATE_SELECTED ||
181
+ newState === DatePickerState.SELECTING_END ||
182
+ (newState === DatePickerState.FOCUSED &&
183
+ from === DatePickerState.CALENDAR_OPEN &&
184
+ context.startDate);
185
+ if (shouldUpdateInput) {
186
+ // Only include non-null dates in selectedDates array
187
+ const selectedDates = context.endDate
188
+ ? [context.startDate, context.endDate].filter((date) => date != null)
189
+ : context.startDate
190
+ ? [context.startDate]
191
+ : [];
192
+ // Update input field value with formatted date
193
+ /**
194
+ * Format date as MM/DD/YYYY (matching Carbon's default format)
195
+ *
196
+ * @param {Temporal.PlainDate} date - The date to format
197
+ * @returns {string} Formatted date string
198
+ */
199
+ const formatDate = (date) => {
200
+ // Safety check - ensure date is a valid Temporal.PlainDate
201
+ if (!date ||
202
+ typeof date !== 'object' ||
203
+ !('month' in date) ||
204
+ !('day' in date) ||
205
+ !('year' in date)) {
206
+ console.error('formatDate received invalid date:', date);
207
+ return '';
208
+ }
209
+ const month = String(date.month).padStart(2, '0');
210
+ const day = String(date.day).padStart(2, '0');
211
+ const year = date.year;
212
+ return `${month}/${day}/${year}`;
213
+ };
214
+ // For range mode, update the correct input based on state
215
+ if (this._mode === DATE_PICKER_MODE.RANGE) {
216
+ const { selectorInputFrom, selectorInputTo } = this
217
+ .constructor;
218
+ // @ts-expect-error - querySelector is available from HTMLElement
219
+ const inputFrom = this.querySelector(selectorInputFrom);
220
+ // @ts-expect-error - querySelector is available from HTMLElement
221
+ const inputTo = this.querySelector(selectorInputTo);
222
+ // If we're in DATE_SELECTED state with both dates, update both inputs
223
+ if (newState === DatePickerState.DATE_SELECTED &&
224
+ context.startDate &&
225
+ context.endDate) {
226
+ if (inputFrom) {
227
+ inputFrom.value = formatDate(context.startDate);
228
+ }
229
+ if (inputTo) {
230
+ inputTo.value = formatDate(context.endDate);
231
+ }
232
+ }
233
+ else if (context.lastFocusedInput === 'to' &&
234
+ inputTo &&
235
+ context.endDate) {
236
+ // Otherwise, update based on lastFocusedInput
237
+ inputTo.value = formatDate(context.endDate);
238
+ }
239
+ else if (inputFrom && context.startDate) {
240
+ inputFrom.value = formatDate(context.startDate);
241
+ }
242
+ }
243
+ else {
244
+ // For single mode, update the single input
245
+ if (this._dateInteractNode && context.startDate) {
246
+ this._dateInteractNode.value = formatDate(context.startDate);
247
+ }
248
+ }
249
+ this.dispatchEvent(new CustomEvent(this.constructor.eventChange, {
250
+ bubbles: true,
251
+ composed: true,
252
+ detail: {
253
+ selectedDates,
254
+ value: this._value,
255
+ },
256
+ }));
257
+ }
258
+ };
259
+ /**
260
+ * Handles calendar date selection
261
+ *
262
+ * @param {CustomEvent} event - The date select event
263
+ */
264
+ this._handleCalendarDateSelect = (event) => {
265
+ const { date } = event.detail;
266
+ if (!this._adapter || !date) {
267
+ return;
268
+ }
269
+ const { _mode: mode } = this;
270
+ const context = this._adapter.getContext();
271
+ if (mode === DATE_PICKER_MODE.RANGE) {
272
+ // Range mode: select start or end date
273
+ if (!context.startDate || context.endDate) {
274
+ // Select start date (or restart selection)
275
+ this._adapter.send(DatePickerEvent.RANGE_START_SELECT, { date });
276
+ }
277
+ else {
278
+ // Select end date
279
+ this._adapter.send(DatePickerEvent.RANGE_END_SELECT, { date });
280
+ }
281
+ }
282
+ else {
283
+ // Single mode: select date
284
+ this._adapter.send(DatePickerEvent.DATE_SELECT, { date });
285
+ }
286
+ };
287
+ /**
288
+ * Handles calendar month change
289
+ *
290
+ * @param {CustomEvent} event - The month change event
291
+ */
292
+ this._handleCalendarMonthChange = (event) => {
293
+ const { month } = event.detail;
294
+ if (!this._adapter || !month) {
295
+ return;
296
+ }
297
+ // Update viewDate in context
298
+ const firstDayOfMonth = month.toPlainDate({ day: 1 });
299
+ this._adapter.updateContext({ viewDate: firstDayOfMonth });
300
+ };
301
+ /**
302
+ * Allows the user to enter a date directly into the input field
303
+ */
304
+ this.allowInput = true;
305
+ /**
306
+ * Controls whether the calendar dropdown closes upon selection.
307
+ */
308
+ this.closeOnSelect = true;
309
+ /**
310
+ * Controls the disabled state of the input
311
+ */
312
+ this.disabled = false;
313
+ /**
314
+ * Name for the input in the `FormData`
315
+ */
316
+ this.name = '';
317
+ /**
318
+ * `true` if the date picker should be open.
319
+ */
320
+ this.open = false;
321
+ /**
322
+ * Specify if the component should be read-only
323
+ */
324
+ this.readonly = false;
325
+ /**
326
+ * Handle clicks outside the date picker to close the calendar
327
+ *
328
+ * @param {MouseEvent} event - The click event
329
+ */
330
+ this._handleOutsideClick = (event) => {
331
+ var _a;
332
+ if (!this.open) {
333
+ return;
334
+ }
335
+ const target = event.target;
336
+ // Check if click is outside the date picker component
337
+ if (!this.contains(target) && !((_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.contains(target))) {
338
+ this.open = false;
339
+ if (this._adapter) {
340
+ this._adapter.send(DatePickerEvent.OUTSIDE_CLICK);
341
+ }
342
+ }
343
+ };
344
+ /**
345
+ * Handle keyboard events for calendar navigation
346
+ *
347
+ * @param {KeyboardEvent} event - The keyboard event
348
+ */
349
+ this._handleKeyDown = (event) => {
350
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
351
+ if (!this._adapter) {
352
+ return;
353
+ }
354
+ const { key } = event;
355
+ // Handle Tab key
356
+ if (key === 'Tab') {
357
+ const composedPath = event.composedPath();
358
+ const target = composedPath[0];
359
+ // Get input elements
360
+ const { selectorInputFrom, selectorInputTo } = this
361
+ .constructor;
362
+ const inputFrom = this.querySelector(selectorInputFrom);
363
+ const inputTo = this.querySelector(selectorInputTo);
364
+ // Check if focus is on input fields
365
+ const isOnFirstInput = inputFrom && composedPath.includes(inputFrom);
366
+ const isOnSecondInput = inputTo && composedPath.includes(inputTo);
367
+ // Check if the target is the calendar element or within it
368
+ const calendar = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('cds-date-picker-calendar');
369
+ const isFocusInCalendar = target === calendar ||
370
+ ((_b = target.closest) === null || _b === void 0 ? void 0 : _b.call(target, 'cds-date-picker-calendar')) !== null ||
371
+ composedPath.includes(calendar);
372
+ // Case 1: Tab FROM first input -> Focus calendar (if open)
373
+ if (this.open && isOnFirstInput && !event.shiftKey) {
374
+ event.preventDefault();
375
+ event.stopPropagation();
376
+ const calendarElement = (_c = this.shadowRoot) === null || _c === void 0 ? void 0 : _c.querySelector('cds-date-picker-calendar');
377
+ const calendarDiv = (_d = calendarElement === null || calendarElement === void 0 ? void 0 : calendarElement.shadowRoot) === null || _d === void 0 ? void 0 : _d.querySelector('.cds--date-picker__calendar');
378
+ if (calendarDiv) {
379
+ setTimeout(() => {
380
+ calendarDiv.focus();
381
+ }, 0);
382
+ }
383
+ return;
384
+ }
385
+ // Case 2: Tab FROM second input (range mode) -> Focus calendar (if open)
386
+ if (this.open &&
387
+ isOnSecondInput &&
388
+ !event.shiftKey &&
389
+ this._mode === DATE_PICKER_MODE.RANGE) {
390
+ event.preventDefault();
391
+ event.stopPropagation(); // Prevent input from handling the event
392
+ const calendarElement = (_e = this.shadowRoot) === null || _e === void 0 ? void 0 : _e.querySelector('cds-date-picker-calendar');
393
+ const calendarDiv = (_f = calendarElement === null || calendarElement === void 0 ? void 0 : calendarElement.shadowRoot) === null || _f === void 0 ? void 0 : _f.querySelector('.cds--date-picker__calendar');
394
+ if (calendarDiv) {
395
+ // Use setTimeout to ensure focus happens after event processing
396
+ setTimeout(() => {
397
+ calendarDiv.focus();
398
+ }, 0);
399
+ }
400
+ return;
401
+ }
402
+ // Case 3: Shift+Tab FROM calendar -> Move to appropriate input
403
+ if (this.open && isFocusInCalendar && event.shiftKey) {
404
+ event.preventDefault();
405
+ // In range mode, check which input was last focused
406
+ if (this._mode === DATE_PICKER_MODE.RANGE) {
407
+ const context = (_g = this._adapter) === null || _g === void 0 ? void 0 : _g.getContext();
408
+ const lastFocused = context === null || context === void 0 ? void 0 : context.lastFocusedInput;
409
+ // If we were on the second input, go back to it
410
+ if (lastFocused === 'to' && inputTo) {
411
+ (_h = inputTo.input) === null || _h === void 0 ? void 0 : _h.focus();
412
+ }
413
+ else if (inputFrom) {
414
+ // Otherwise go to first input
415
+ (_j = inputFrom.input) === null || _j === void 0 ? void 0 : _j.focus();
416
+ }
417
+ }
418
+ else {
419
+ // Single mode: go to first input
420
+ if (inputFrom) {
421
+ (_k = inputFrom.input) === null || _k === void 0 ? void 0 : _k.focus();
422
+ }
423
+ }
424
+ return;
425
+ }
426
+ // Case 4: Tab FROM calendar -> Move to second input (range) or close (single)
427
+ if (this.open && isFocusInCalendar && !event.shiftKey) {
428
+ event.preventDefault();
429
+ // In range mode, check which input was last focused
430
+ if (this._mode === DATE_PICKER_MODE.RANGE) {
431
+ const context = (_l = this._adapter) === null || _l === void 0 ? void 0 : _l.getContext();
432
+ const lastFocused = context === null || context === void 0 ? void 0 : context.lastFocusedInput;
433
+ // If we were on the first input, move to second input
434
+ if (lastFocused === 'from' && inputTo) {
435
+ (_m = inputTo.input) === null || _m === void 0 ? void 0 : _m.focus();
436
+ return;
437
+ }
438
+ }
439
+ // Otherwise (single mode or after second input in range mode), close and move to next element
440
+ // Record the time when calendar was closed via Tab
441
+ this._lastTabCloseTime = Date.now();
442
+ this._adapter.send(DatePickerEvent.TAB_KEY);
443
+ // Find and focus the next tabbable element after this date picker
444
+ this._focusNextElement(false);
445
+ return;
446
+ }
447
+ }
448
+ // Only handle other keyboard events when calendar is open AND focus is in calendar
449
+ if (!this.open) {
450
+ return;
451
+ }
452
+ // Get the actual target from the composed path (handles shadow DOM)
453
+ const composedPath = event.composedPath();
454
+ const target = composedPath[0];
455
+ const input = (_o = this.shadowRoot) === null || _o === void 0 ? void 0 : _o.querySelector('input');
456
+ // Only handle arrow keys, Page Up/Down, Home/End when focus is in calendar, not on input
457
+ if (target === input) {
458
+ return;
459
+ }
460
+ // Check if the target has the calendar class or is within an element with that class
461
+ // The calendar div is inside the calendar renderer's shadow DOM
462
+ const isFocusInCalendar = ((_p = target.classList) === null || _p === void 0 ? void 0 : _p.contains('cds--date-picker__calendar')) ||
463
+ ((_q = target.closest) === null || _q === void 0 ? void 0 : _q.call(target, '.cds--date-picker__calendar')) !== null;
464
+ if (!isFocusInCalendar) {
465
+ return;
466
+ }
467
+ // Handle Escape key - close calendar
468
+ if (key === 'Escape') {
469
+ event.preventDefault();
470
+ this.open = false;
471
+ this._adapter.send(DatePickerEvent.ESCAPE_KEY);
472
+ return;
473
+ }
474
+ // Handle Enter key - select focused date
475
+ if (key === 'Enter') {
476
+ event.preventDefault();
477
+ // Get the focused date from context
478
+ const context = this._adapter.getContext();
479
+ const focusedDate = context.focusedDate;
480
+ if (!focusedDate) {
481
+ return;
482
+ }
483
+ // Dispatch the appropriate event based on mode and current state
484
+ const currentState = this._adapter.getState();
485
+ if (this._mode === DATE_PICKER_MODE.RANGE) {
486
+ // In range mode, check if we're selecting start or end date
487
+ if (currentState === 'selecting_end') {
488
+ // Selecting end date
489
+ this._adapter.send(DatePickerEvent.RANGE_END_SELECT, {
490
+ date: focusedDate,
491
+ });
492
+ }
493
+ else {
494
+ // Selecting start date
495
+ this._adapter.send(DatePickerEvent.RANGE_START_SELECT, {
496
+ date: focusedDate,
497
+ });
498
+ }
499
+ }
500
+ else {
501
+ // Single mode - just select the date
502
+ this._adapter.send(DatePickerEvent.DATE_SELECT, {
503
+ date: focusedDate,
504
+ });
505
+ }
506
+ return;
507
+ }
508
+ // Handle arrow keys - navigate dates
509
+ if (key === 'ArrowUp') {
510
+ event.preventDefault();
511
+ this._adapter.send(DatePickerEvent.ARROW_UP);
512
+ return;
513
+ }
514
+ if (key === 'ArrowDown') {
515
+ event.preventDefault();
516
+ this._adapter.send(DatePickerEvent.ARROW_DOWN);
517
+ return;
518
+ }
519
+ if (key === 'ArrowLeft') {
520
+ event.preventDefault();
521
+ this._adapter.send(DatePickerEvent.ARROW_LEFT);
522
+ return;
523
+ }
524
+ if (key === 'ArrowRight') {
525
+ event.preventDefault();
526
+ this._adapter.send(DatePickerEvent.ARROW_RIGHT);
527
+ return;
528
+ }
529
+ // Handle Page Up/Down - navigate months
530
+ if (key === 'PageUp') {
531
+ event.preventDefault();
532
+ this._adapter.send(DatePickerEvent.PAGE_UP);
533
+ return;
534
+ }
535
+ if (key === 'PageDown') {
536
+ event.preventDefault();
537
+ this._adapter.send(DatePickerEvent.PAGE_DOWN);
538
+ return;
539
+ }
540
+ // Handle Home/End - navigate to start/end of week
541
+ if (key === 'Home') {
542
+ event.preventDefault();
543
+ this._adapter.send(DatePickerEvent.HOME_KEY);
544
+ return;
545
+ }
546
+ if (key === 'End') {
547
+ event.preventDefault();
548
+ this._adapter.send(DatePickerEvent.END_KEY);
549
+ return;
550
+ }
551
+ };
552
+ }
553
+ /**
554
+ * @returns The effective date picker mode, determined by the child `<cds-date-picker-input>`.
555
+ */
556
+ get _mode() {
557
+ const { selectorInputTo } = this.constructor;
558
+ // @ts-expect-error - querySelector from mixin
559
+ if (this.querySelector(selectorInputTo)) {
560
+ return DATE_PICKER_MODE.RANGE;
561
+ }
562
+ // @ts-expect-error - querySelector from mixin
563
+ if (this.querySelector(`${prefix}-date-picker-input[kind="single"]`)) {
564
+ return DATE_PICKER_MODE.SINGLE;
565
+ }
566
+ return DATE_PICKER_MODE.SIMPLE;
567
+ }
568
+ /**
569
+ * Handles form data event
570
+ *
571
+ * @param {FormDataEvent} event - The form data event
572
+ */
573
+ _handleFormdata(event) {
574
+ const { formData } = event;
575
+ const { disabled, name, value } = this;
576
+ if (!disabled) {
577
+ formData.append(name, value);
578
+ }
579
+ }
580
+ /**
581
+ * Handles `slotchange` event in the `<slot>`.
582
+ *
583
+ * @param {Event} root0 - The event object
584
+ * @param {EventTarget} root0.target - The event target
585
+ */
586
+ _handleSlotChange({ target }) {
587
+ const { _dateInteractNode: oldDateInteractNode } = this;
588
+ const dateInteractNode = target
589
+ .assignedNodes()
590
+ .find((node) => node.nodeType === Node.ELEMENT_NODE &&
591
+ node.matches(this.constructor.selectorInputFrom));
592
+ // @ts-expect-error - Type comparison between mixin types
593
+ if (oldDateInteractNode !== dateInteractNode) {
594
+ this._dateInteractNode =
595
+ dateInteractNode;
596
+ this._initializeDatePicker();
597
+ }
598
+ }
599
+ /**
600
+ * Show the calendar popover using Popover API
601
+ */
602
+ _showCalendarPopover() {
603
+ var _a;
604
+ const popover = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector(`#${prefix}-date-picker-calendar-popover`);
605
+ if (popover && typeof popover.showPopover === 'function') {
606
+ try {
607
+ popover.showPopover();
608
+ }
609
+ catch (e) {
610
+ // Popover might already be showing
611
+ console.warn('Could not show popover:', e);
612
+ }
613
+ }
614
+ }
615
+ /**
616
+ * Hide the calendar popover using Popover API
617
+ */
618
+ _hideCalendarPopover() {
619
+ var _a;
620
+ const popover = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector(`#${prefix}-date-picker-calendar-popover`);
621
+ if (popover && typeof popover.hidePopover === 'function') {
622
+ try {
623
+ popover.hidePopover();
624
+ }
625
+ catch (e) {
626
+ // Popover might already be hidden
627
+ console.warn('Could not hide popover:', e);
628
+ }
629
+ }
630
+ }
631
+ /**
632
+ * Initializes the date picker with a state machine.
633
+ */
634
+ _initializeDatePicker() {
635
+ this._releaseDatePicker();
636
+ const { _dateInteractNode: dateInteractNode, _mode: mode } = this;
637
+ // Don't instantiate in simple mode
638
+ if (!dateInteractNode || !dateInteractNode.input || mode === 'simple') {
639
+ return;
640
+ }
641
+ // Create adapter with configuration
642
+ this._adapter = new WebComponentAdapter({
643
+ component: this,
644
+ initialContext: {
645
+ mode: mode === DATE_PICKER_MODE.RANGE ? 'range' : 'single',
646
+ dateFormat: this.dateFormat || 'm/d/Y',
647
+ allowInput: this.allowInput,
648
+ closeOnSelect: this.closeOnSelect,
649
+ value: this.value || '',
650
+ startDate: null,
651
+ endDate: null,
652
+ isOpen: false,
653
+ isFocused: false,
654
+ isDisabled: this.disabled,
655
+ isReadonly: this.readonly,
656
+ isInvalid: false,
657
+ lastFocusedInput: null,
658
+ minDate: parseDateToPlainDate(this.minDate),
659
+ maxDate: parseDateToPlainDate(this.maxDate),
660
+ },
661
+ onStateChange: this._handleStateChange,
662
+ });
663
+ // Set initial value if provided
664
+ if (this.value) {
665
+ const dates = this.value.split('/').filter(Boolean);
666
+ if (dates.length > 0) {
667
+ this._adapter.send(mode === DATE_PICKER_MODE.RANGE
668
+ ? DatePickerEvent.RANGE_START_SELECT
669
+ : DatePickerEvent.DATE_SELECT, { date: dates[0] });
670
+ if (mode === DATE_PICKER_MODE.RANGE && dates.length > 1) {
671
+ this._adapter.send(DatePickerEvent.RANGE_END_SELECT, {
672
+ date: dates[1],
673
+ });
674
+ }
675
+ }
676
+ }
677
+ }
678
+ /**
679
+ * Releases the date picker state machine.
680
+ */
681
+ _releaseDatePicker() {
682
+ if (this._adapter) {
683
+ this._adapter.destroy();
684
+ this._adapter = null;
685
+ }
686
+ }
687
+ /**
688
+ * The date(s) in ISO8601 format (date portion only), for range mode, '/' is used for separate start/end dates.
689
+ */
690
+ get value() {
691
+ return this._value;
692
+ }
693
+ /**
694
+ * Sets the value
695
+ *
696
+ * @param {string} value - The new value
697
+ */
698
+ set value(value) {
699
+ const { _value: oldValue } = this;
700
+ this._value = value;
701
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
702
+ // @ts-expect-error - requestUpdate is available from LitElement
703
+ this.requestUpdate('value', oldValue);
704
+ }
705
+ /**
706
+ * Find and focus the next tabbable element after the date picker
707
+ * @param {boolean} backwards - Whether to tab backwards (Shift+Tab)
708
+ */
709
+ _focusNextElement(backwards = false) {
710
+ // Get all tabbable elements in the document
711
+ const tabbableSelector = 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
712
+ const allTabbable = Array.from(document.querySelectorAll(tabbableSelector));
713
+ // Find the index of this date picker component
714
+ const currentIndex = allTabbable.findIndex((el) => this.contains(el) || el === this);
715
+ if (currentIndex === -1) {
716
+ return; // Couldn't find current element
717
+ }
718
+ // Find the next element after all elements within this date picker
719
+ let nextIndex = currentIndex;
720
+ if (backwards) {
721
+ // Tab backwards - find previous element before this date picker
722
+ for (let i = currentIndex - 1; i >= 0; i--) {
723
+ if (!this.contains(allTabbable[i])) {
724
+ nextIndex = i;
725
+ break;
726
+ }
727
+ }
728
+ }
729
+ else {
730
+ // Tab forwards - find next element after this date picker
731
+ for (let i = currentIndex + 1; i < allTabbable.length; i++) {
732
+ if (!this.contains(allTabbable[i])) {
733
+ nextIndex = i;
734
+ break;
735
+ }
736
+ }
737
+ }
738
+ // Focus the next element
739
+ if (nextIndex !== currentIndex && allTabbable[nextIndex]) {
740
+ allTabbable[nextIndex].focus();
741
+ }
742
+ }
743
+ /**
744
+ * Lifecycle callback when element is connected
745
+ */
746
+ connectedCallback() {
747
+ super.connectedCallback();
748
+ this._initializeDatePicker();
749
+ // Add outside click listener
750
+ document.addEventListener('click', this._handleOutsideClick, true);
751
+ // Add keyboard event listener
752
+ document.addEventListener('keydown', this._handleKeyDown, true);
753
+ }
754
+ /**
755
+ * Lifecycle callback when element is disconnected
756
+ */
757
+ disconnectedCallback() {
758
+ // Remove outside click listener
759
+ document.removeEventListener('click', this._handleOutsideClick, true);
760
+ // Remove keyboard event listener
761
+ document.removeEventListener('keydown', this._handleKeyDown, true);
762
+ this._releaseDatePicker();
763
+ super.disconnectedCallback();
764
+ }
765
+ /**
766
+ * Lifecycle callback when properties change
767
+ *
768
+ * @param {Map<string, any>} changedProperties - Map of changed properties
769
+ */
770
+ updated(changedProperties) {
771
+ if (this._adapter) {
772
+ if (changedProperties.has('minDate') ||
773
+ changedProperties.has('maxDate')) {
774
+ // Update context
775
+ this._adapter.updateContext({
776
+ minDate: this.minDate ? Temporal.PlainDate.from(this.minDate) : null,
777
+ maxDate: this.maxDate ? Temporal.PlainDate.from(this.maxDate) : null,
778
+ });
779
+ }
780
+ if (changedProperties.has('open')) {
781
+ if (this.open && !this.readonly) {
782
+ this._adapter.send(DatePickerEvent.CALENDAR_OPEN);
783
+ // Show popover using Popover API
784
+ this._showCalendarPopover();
785
+ }
786
+ else if (!this.open) {
787
+ this._adapter.send(DatePickerEvent.CALENDAR_CLOSE);
788
+ // Hide popover using Popover API
789
+ this._hideCalendarPopover();
790
+ }
791
+ }
792
+ if (changedProperties.has('disabled') ||
793
+ changedProperties.has('readonly')) {
794
+ const { selectorInputFrom, selectorInputTo } = this
795
+ .constructor;
796
+ const inputFrom = this.querySelector(selectorInputFrom);
797
+ const inputTo = this.querySelector(selectorInputTo);
798
+ [inputFrom, inputTo].forEach((input) => {
799
+ if (input) {
800
+ input.disabled = this.disabled;
801
+ input.readonly = this.readonly;
802
+ }
803
+ });
804
+ this._adapter.updateContext({
805
+ isDisabled: this.disabled,
806
+ isReadonly: this.readonly,
807
+ });
808
+ }
809
+ if (changedProperties.has('value') && this.value) {
810
+ const dates = this.value.split('/').filter(Boolean);
811
+ if (dates.length > 0) {
812
+ // Convert ISO string to Temporal.PlainDate
813
+ const startDate = parseISOToPlainDate(dates[0]);
814
+ if (startDate) {
815
+ this._adapter.send(this._mode === DATE_PICKER_MODE.RANGE
816
+ ? DatePickerEvent.RANGE_START_SELECT
817
+ : DatePickerEvent.DATE_SELECT, { date: startDate });
818
+ if (this._mode === DATE_PICKER_MODE.RANGE && dates.length > 1) {
819
+ const endDate = parseISOToPlainDate(dates[1]);
820
+ if (endDate) {
821
+ this._adapter.send(DatePickerEvent.RANGE_END_SELECT, {
822
+ date: endDate,
823
+ });
824
+ }
825
+ }
826
+ }
827
+ }
828
+ }
829
+ }
830
+ }
831
+ /**
832
+ * Renders the component
833
+ */
834
+ render() {
835
+ var _a;
836
+ const { _handleSlotChange: handleSlotChange, _mode: mode, open } = this;
837
+ const context = (_a = this._adapter) === null || _a === void 0 ? void 0 : _a.getContext();
838
+ const selectedDates = (context === null || context === void 0 ? void 0 : context.endDate)
839
+ ? [context.startDate, context.endDate].filter(Boolean)
840
+ : (context === null || context === void 0 ? void 0 : context.startDate)
841
+ ? [context.startDate]
842
+ : [];
843
+ return html `
844
+ <a
845
+ class="${prefix}--visually-hidden"
846
+ href="javascript:void 0"
847
+ role="navigation"
848
+ tabindex="-1"></a>
849
+ <slot @slotchange="${handleSlotChange}"></slot>
850
+ <div
851
+ id="floating-menu-container"
852
+ class="${prefix}--date-picker__calendar-container">
853
+ ${mode !== DATE_PICKER_MODE.SIMPLE && open
854
+ ? html `
855
+ <cds-date-picker-calendar
856
+ .rangeMode="${mode === DATE_PICKER_MODE.RANGE}"
857
+ .dateFormat="${this.dateFormat || 'm/d/Y'}"
858
+ .minDate="${this.minDate
859
+ ? Temporal.PlainDate.from(this.minDate)
860
+ : undefined}"
861
+ .maxDate="${this.maxDate
862
+ ? Temporal.PlainDate.from(this.maxDate)
863
+ : undefined}"
864
+ .selectedDates="${selectedDates}"
865
+ .viewDate="${(context === null || context === void 0 ? void 0 : context.viewDate) || null}"
866
+ .focusedDate="${(context === null || context === void 0 ? void 0 : context.focusedDate) || null}"
867
+ @cds-date-picker-calendar-date-select="${this
868
+ ._handleCalendarDateSelect}"
869
+ @cds-date-picker-calendar-month-change="${this
870
+ ._handleCalendarMonthChange}">
871
+ </cds-date-picker-calendar>
872
+ `
873
+ : ''}
874
+ </div>
875
+ <a
876
+ class="${prefix}--visually-hidden"
877
+ href="javascript:void 0"
878
+ role="navigation"
879
+ tabindex="-1"></a>
880
+ `;
881
+ }
882
+ /**
883
+ * The CSS class for the calendar dropdown.
884
+ */
885
+ static get classCalendarContainer() {
886
+ return `${prefix}--date-picker__calendar`;
887
+ }
888
+ /**
889
+ * The CSS class for the month navigator.
890
+ */
891
+ static get classMonth() {
892
+ return `${prefix}--date-picker__month`;
893
+ }
894
+ /**
895
+ * The CSS class for the container of the weekdays.
896
+ */
897
+ static get classWeekdays() {
898
+ return `${prefix}--date-picker__weekdays`;
899
+ }
900
+ /**
901
+ * The CSS class for the container of the days.
902
+ */
903
+ static get classDays() {
904
+ return `${prefix}--date-picker__days`;
905
+ }
906
+ /**
907
+ * The CSS class applied to each weekdays.
908
+ */
909
+ static get classWeekday() {
910
+ return `${prefix}--date-picker__weekday`;
911
+ }
912
+ /**
913
+ * The CSS class applied to each days.
914
+ */
915
+ static get classDay() {
916
+ return `${prefix}--date-picker__day`;
917
+ }
918
+ /**
919
+ * A selector that will return the `<input>` to enter starting date.
920
+ */
921
+ static get selectorInputFrom() {
922
+ return `${prefix}-date-picker-input,${prefix}-date-picker-input[kind="from"]`;
923
+ }
924
+ /**
925
+ * A selector that will return the `<input>` to enter end date.
926
+ */
927
+ static get selectorInputTo() {
928
+ return `${prefix}-date-picker-input[kind="to"]`;
929
+ }
930
+ /**
931
+ * The name of the custom event when an error occurs.
932
+ */
933
+ static get eventError() {
934
+ return `${prefix}-date-picker-error`;
935
+ }
936
+ /**
937
+ * The name of the custom event fired when the date selection changes.
938
+ */
939
+ static get eventChange() {
940
+ return `${prefix}-date-picker-changed`;
941
+ }
942
+ /**
943
+ * The name of the custom event fired when the calendar icon is clicked.
944
+ */
945
+ static get eventIconClick() {
946
+ return `${prefix}-date-picker-icon-click`;
947
+ }
948
+ /**
949
+ * The name of the custom event fired when an input receives focus.
950
+ */
951
+ static get eventInputFocus() {
952
+ return `${prefix}-date-picker-input-focus`;
953
+ }
954
+ /**
955
+ * The name of the custom event fired when an input loses focus.
956
+ */
957
+ static get eventInputBlur() {
958
+ return `${prefix}-date-picker-input-blur`;
959
+ }
960
+ };
961
+ /**
962
+ * The CSS class applied to the "today" highlight if there are any dates selected.
963
+ */
964
+ CDSDatePicker.classNoBorder = 'no-border';
965
+ /**
966
+ * The default date format.
967
+ */
968
+ CDSDatePicker.defaultDateFormat = 'm/d/Y';
969
+ CDSDatePicker.styles = styles;
970
+ __decorate([
971
+ HostListener('eventChange')
972
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
973
+ // @ts-ignore: The decorator refers to this method, but TS thinks this method is not referred to
974
+ ,
975
+ __metadata("design:type", Object)
976
+ ], CDSDatePicker.prototype, "_handleChange", void 0);
977
+ __decorate([
978
+ HostListener('eventIconClick')
979
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
980
+ // @ts-ignore: The decorator refers to this method, but TS thinks this method is not referred to
981
+ ,
982
+ __metadata("design:type", Object)
983
+ ], CDSDatePicker.prototype, "_handleIconClick", void 0);
984
+ __decorate([
985
+ HostListener('eventInputFocus')
986
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
987
+ // @ts-ignore: The decorator refers to this method, but TS thinks this method is not referred to
988
+ ,
989
+ __metadata("design:type", Object)
990
+ ], CDSDatePicker.prototype, "_handleInputFocus", void 0);
991
+ __decorate([
992
+ HostListener('eventInputBlur')
993
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
994
+ // @ts-ignore: The decorator refers to this method, but TS thinks this method is not referred to
995
+ ,
996
+ __metadata("design:type", Object)
997
+ ], CDSDatePicker.prototype, "_handleInputBlur", void 0);
998
+ __decorate([
999
+ property({ type: Boolean, reflect: true, attribute: 'allow-input' }),
1000
+ __metadata("design:type", Object)
1001
+ ], CDSDatePicker.prototype, "allowInput", void 0);
1002
+ __decorate([
1003
+ property({ type: Boolean, reflect: true, attribute: 'close-on-select' }),
1004
+ __metadata("design:type", Object)
1005
+ ], CDSDatePicker.prototype, "closeOnSelect", void 0);
1006
+ __decorate([
1007
+ property({ attribute: 'date-format' }),
1008
+ __metadata("design:type", String)
1009
+ ], CDSDatePicker.prototype, "dateFormat", void 0);
1010
+ __decorate([
1011
+ property({ type: Boolean, reflect: true }),
1012
+ __metadata("design:type", Object)
1013
+ ], CDSDatePicker.prototype, "disabled", void 0);
1014
+ __decorate([
1015
+ property({ attribute: 'enabled-range' }),
1016
+ __metadata("design:type", String)
1017
+ ], CDSDatePicker.prototype, "enabledRange", void 0);
1018
+ __decorate([
1019
+ property({ attribute: 'max-date' }),
1020
+ __metadata("design:type", String)
1021
+ ], CDSDatePicker.prototype, "maxDate", void 0);
1022
+ __decorate([
1023
+ property({ attribute: 'min-date' }),
1024
+ __metadata("design:type", String)
1025
+ ], CDSDatePicker.prototype, "minDate", void 0);
1026
+ __decorate([
1027
+ property(),
1028
+ __metadata("design:type", Object)
1029
+ ], CDSDatePicker.prototype, "name", void 0);
1030
+ __decorate([
1031
+ property({ type: Boolean, reflect: true }),
1032
+ __metadata("design:type", Object)
1033
+ ], CDSDatePicker.prototype, "open", void 0);
1034
+ __decorate([
1035
+ property({ type: Boolean, reflect: true }),
1036
+ __metadata("design:type", Object)
1037
+ ], CDSDatePicker.prototype, "readonly", void 0);
1038
+ __decorate([
1039
+ property(),
1040
+ __metadata("design:type", String),
1041
+ __metadata("design:paramtypes", [String])
1042
+ ], CDSDatePicker.prototype, "value", null);
1043
+ CDSDatePicker = __decorate([
1044
+ carbonElement(`${prefix}-date-picker`)
1045
+ ], CDSDatePicker);
1046
+ // Made with Bob
1047
+ //# sourceMappingURL=date-picker.js.map