@api-client/ui 0.5.5 → 0.5.7

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 (114) hide show
  1. package/.cursor/rules/html-and-css-best-practices.mdc +63 -0
  2. package/.cursor/rules/lit-best-practices.mdc +78 -0
  3. package/.github/instructions/html-and-css-best-practices.instructions.md +70 -0
  4. package/.github/instructions/lit-best-practices.instructions.md +86 -0
  5. package/build/src/elements/currency/currency-picker.d.ts +10 -0
  6. package/build/src/elements/currency/currency-picker.d.ts.map +1 -0
  7. package/build/src/elements/currency/currency-picker.js +27 -0
  8. package/build/src/elements/currency/currency-picker.js.map +1 -0
  9. package/build/src/elements/currency/internals/Picker.d.ts +311 -0
  10. package/build/src/elements/currency/internals/Picker.d.ts.map +1 -0
  11. package/build/src/elements/currency/internals/Picker.js +857 -0
  12. package/build/src/elements/currency/internals/Picker.js.map +1 -0
  13. package/build/src/elements/currency/internals/Picker.styles.d.ts +3 -0
  14. package/build/src/elements/currency/internals/Picker.styles.d.ts.map +1 -0
  15. package/build/src/elements/currency/internals/Picker.styles.js +58 -0
  16. package/build/src/elements/currency/internals/Picker.styles.js.map +1 -0
  17. package/build/src/elements/highlight/MarkdownStyles.d.ts.map +1 -1
  18. package/build/src/elements/highlight/MarkdownStyles.js +0 -13
  19. package/build/src/elements/highlight/MarkdownStyles.js.map +1 -1
  20. package/build/src/elements/http/BodyEditor.d.ts +0 -13
  21. package/build/src/elements/http/BodyEditor.d.ts.map +1 -1
  22. package/build/src/elements/http/BodyEditor.js +0 -13
  23. package/build/src/elements/http/BodyEditor.js.map +1 -1
  24. package/build/src/elements/http/BodyTextEditor.d.ts +0 -13
  25. package/build/src/elements/http/BodyTextEditor.d.ts.map +1 -1
  26. package/build/src/elements/http/BodyTextEditor.js +0 -13
  27. package/build/src/elements/http/BodyTextEditor.js.map +1 -1
  28. package/build/src/elements/http/BodyUrlEncodedEditor.d.ts +0 -13
  29. package/build/src/elements/http/BodyUrlEncodedEditor.d.ts.map +1 -1
  30. package/build/src/elements/http/BodyUrlEncodedEditor.js +0 -13
  31. package/build/src/elements/http/BodyUrlEncodedEditor.js.map +1 -1
  32. package/build/src/elements/http/UrlInput.d.ts +0 -13
  33. package/build/src/elements/http/UrlInput.d.ts.map +1 -1
  34. package/build/src/elements/http/UrlInput.js +0 -13
  35. package/build/src/elements/http/UrlInput.js.map +1 -1
  36. package/build/src/index.d.ts +2 -0
  37. package/build/src/index.d.ts.map +1 -1
  38. package/build/src/index.js +2 -0
  39. package/build/src/index.js.map +1 -1
  40. package/build/src/md/button/internals/base.d.ts +1 -0
  41. package/build/src/md/button/internals/base.d.ts.map +1 -1
  42. package/build/src/md/button/internals/base.js +7 -0
  43. package/build/src/md/button/internals/base.js.map +1 -1
  44. package/build/src/md/button/internals/button.styles.js +1 -1
  45. package/build/src/md/button/internals/button.styles.js.map +1 -1
  46. package/build/src/md/date/internals/DateTime.d.ts +0 -13
  47. package/build/src/md/date/internals/DateTime.d.ts.map +1 -1
  48. package/build/src/md/date/internals/DateTime.js +0 -13
  49. package/build/src/md/date/internals/DateTime.js.map +1 -1
  50. package/build/src/md/date-picker/index.d.ts +13 -0
  51. package/build/src/md/date-picker/index.d.ts.map +1 -0
  52. package/build/src/md/date-picker/index.js +13 -0
  53. package/build/src/md/date-picker/index.js.map +1 -0
  54. package/build/src/md/date-picker/internals/DatePicker.styles.d.ts +4 -0
  55. package/build/src/md/date-picker/internals/DatePicker.styles.d.ts.map +1 -0
  56. package/build/src/md/date-picker/internals/DatePicker.styles.js +409 -0
  57. package/build/src/md/date-picker/internals/DatePicker.styles.js.map +1 -0
  58. package/build/src/md/date-picker/internals/DatePickerCalendar.d.ts +272 -0
  59. package/build/src/md/date-picker/internals/DatePickerCalendar.d.ts.map +1 -0
  60. package/build/src/md/date-picker/internals/DatePickerCalendar.js +1062 -0
  61. package/build/src/md/date-picker/internals/DatePickerCalendar.js.map +1 -0
  62. package/build/src/md/date-picker/internals/DatePickerUtils.d.ts +93 -0
  63. package/build/src/md/date-picker/internals/DatePickerUtils.d.ts.map +1 -0
  64. package/build/src/md/date-picker/internals/DatePickerUtils.js +221 -0
  65. package/build/src/md/date-picker/internals/DatePickerUtils.js.map +1 -0
  66. package/build/src/md/date-picker/ui-date-picker-input.d.ts +160 -0
  67. package/build/src/md/date-picker/ui-date-picker-input.d.ts.map +1 -0
  68. package/build/src/md/date-picker/ui-date-picker-input.js +464 -0
  69. package/build/src/md/date-picker/ui-date-picker-input.js.map +1 -0
  70. package/build/src/md/date-picker/ui-date-picker-modal-input.d.ts +178 -0
  71. package/build/src/md/date-picker/ui-date-picker-modal-input.d.ts.map +1 -0
  72. package/build/src/md/date-picker/ui-date-picker-modal-input.js +538 -0
  73. package/build/src/md/date-picker/ui-date-picker-modal-input.js.map +1 -0
  74. package/build/src/md/date-picker/ui-date-picker-modal.d.ts +156 -0
  75. package/build/src/md/date-picker/ui-date-picker-modal.d.ts.map +1 -0
  76. package/build/src/md/date-picker/ui-date-picker-modal.js +423 -0
  77. package/build/src/md/date-picker/ui-date-picker-modal.js.map +1 -0
  78. package/build/src/md/dialog/internals/Dialog.styles.d.ts.map +1 -1
  79. package/build/src/md/dialog/internals/Dialog.styles.js +1 -0
  80. package/build/src/md/dialog/internals/Dialog.styles.js.map +1 -1
  81. package/demo/elements/currency/index.html +91 -0
  82. package/demo/elements/currency/index.ts +272 -0
  83. package/demo/elements/har/har2.json +1 -1
  84. package/demo/elements/index.html +3 -0
  85. package/demo/md/date-picker/date-picker.ts +336 -0
  86. package/demo/md/date-picker/index.html +171 -0
  87. package/demo/md/index.html +2 -0
  88. package/package.json +1 -1
  89. package/src/elements/currency/currency-picker.ts +14 -0
  90. package/src/elements/currency/internals/Picker.styles.ts +58 -0
  91. package/src/elements/currency/internals/Picker.ts +846 -0
  92. package/src/elements/highlight/MarkdownStyles.ts +0 -13
  93. package/src/elements/http/BodyEditor.ts +0 -13
  94. package/src/elements/http/BodyTextEditor.ts +0 -13
  95. package/src/elements/http/BodyUrlEncodedEditor.ts +0 -13
  96. package/src/elements/http/UrlInput.ts +0 -13
  97. package/src/index.ts +17 -0
  98. package/src/md/button/internals/base.ts +7 -0
  99. package/src/md/button/internals/button.styles.ts +1 -1
  100. package/src/md/date/internals/DateTime.ts +0 -14
  101. package/src/md/date-picker/README.md +184 -0
  102. package/src/md/date-picker/index.ts +17 -0
  103. package/src/md/date-picker/internals/DatePicker.styles.ts +411 -0
  104. package/src/md/date-picker/internals/DatePickerCalendar.ts +1031 -0
  105. package/src/md/date-picker/internals/DatePickerUtils.ts +288 -0
  106. package/src/md/date-picker/ui-date-picker-input.ts +333 -0
  107. package/src/md/date-picker/ui-date-picker-modal-input.ts +440 -0
  108. package/src/md/date-picker/ui-date-picker-modal.ts +346 -0
  109. package/src/md/dialog/internals/Dialog.styles.ts +1 -0
  110. package/test/README.md +3 -2
  111. package/test/elements/currency/CurrencyPicker.accessibility.test.ts +328 -0
  112. package/test/elements/currency/CurrencyPicker.core.test.ts +318 -0
  113. package/test/elements/currency/CurrencyPicker.integration.test.ts +482 -0
  114. package/test/elements/currency/CurrencyPicker.test.ts +486 -0
@@ -0,0 +1,464 @@
1
+ import { __esDecorate, __runInitializers } from "tslib";
2
+ import { LitElement, html } from 'lit';
3
+ import { customElement, property, state, query } from 'lit/decorators.js';
4
+ import { inputStyles } from './internals/DatePicker.styles.js';
5
+ import { formatDate, parseDate } from './internals/DatePickerUtils.js';
6
+ import './internals/DatePickerCalendar.js';
7
+ import '../../md/text-field/ui-outlined-text-field.js';
8
+ import '../../md/icons/ui-icon.js';
9
+ /**
10
+ * A docked date picker that opens from a text field input.
11
+ * Ideal for forms and date selection in medium to large layouts.
12
+ *
13
+ * ## Features
14
+ * - Text field input with calendar dropdown
15
+ * - Keyboard navigation support (Arrow Down, Enter, Escape)
16
+ * - Custom date formatting
17
+ * - Input validation and error handling
18
+ * - Min/max date constraints
19
+ * - Disabled dates support
20
+ * - Accessible design with proper ARIA attributes
21
+ * - CSS Anchor Positioning API for dropdown placement
22
+ *
23
+ * ## Events
24
+ *
25
+ * ### `change`
26
+ * Fired when the selected date changes.
27
+ *
28
+ * **Detail:**
29
+ * ```typescript
30
+ * {
31
+ * value: Date | null,
32
+ * formattedValue: string
33
+ * }
34
+ * ```
35
+ *
36
+ * ## Usage
37
+ *
38
+ * ### Basic usage
39
+ * ```html
40
+ * <ui-date-picker-input
41
+ * label="Select date"
42
+ * name="birthDate"
43
+ * placeholder="MM/DD/YYYY"
44
+ * .value=${new Date()}
45
+ * @change=${this.handleDateChange}
46
+ * ></ui-date-picker-input>
47
+ * ```
48
+ *
49
+ * ### With validation
50
+ * ```html
51
+ * <ui-date-picker-input
52
+ * label="Birth date"
53
+ * name="birthDate"
54
+ * required
55
+ * .error=${this.hasError}
56
+ * .errorMessage=${"Please select a valid date"}
57
+ * .minDate=${new Date('1900-01-01')}
58
+ * .maxDate=${new Date()}
59
+ * ></ui-date-picker-input>
60
+ * ```
61
+ *
62
+ * ### Custom date format
63
+ * ```html
64
+ * <ui-date-picker-input
65
+ * label="Birth date"
66
+ * .dateFormat=${date => date.toLocaleDateString('en-GB')}
67
+ * ></ui-date-picker-input>
68
+ * ```
69
+ *
70
+ * ### With disabled dates
71
+ * ```html
72
+ * <ui-date-picker-input
73
+ * label="Appointment date"
74
+ * .disabledDates=${[new Date('2024-12-25'), new Date('2024-01-01')]}
75
+ * ></ui-date-picker-input>
76
+ * ```
77
+ */
78
+ let UiDatePickerInput = (() => {
79
+ let _classDecorators = [customElement('ui-date-picker-input')];
80
+ let _classDescriptor;
81
+ let _classExtraInitializers = [];
82
+ let _classThis;
83
+ let _classSuper = LitElement;
84
+ let _label_decorators;
85
+ let _label_initializers = [];
86
+ let _label_extraInitializers = [];
87
+ let _name_decorators;
88
+ let _name_initializers = [];
89
+ let _name_extraInitializers = [];
90
+ let _placeholder_decorators;
91
+ let _placeholder_initializers = [];
92
+ let _placeholder_extraInitializers = [];
93
+ let _value_decorators;
94
+ let _value_initializers = [];
95
+ let _value_extraInitializers = [];
96
+ let _disabled_decorators;
97
+ let _disabled_initializers = [];
98
+ let _disabled_extraInitializers = [];
99
+ let _required_decorators;
100
+ let _required_initializers = [];
101
+ let _required_extraInitializers = [];
102
+ let _errorMessage_decorators;
103
+ let _errorMessage_initializers = [];
104
+ let _errorMessage_extraInitializers = [];
105
+ let _error_decorators;
106
+ let _error_initializers = [];
107
+ let _error_extraInitializers = [];
108
+ let _minDate_decorators;
109
+ let _minDate_initializers = [];
110
+ let _minDate_extraInitializers = [];
111
+ let _maxDate_decorators;
112
+ let _maxDate_initializers = [];
113
+ let _maxDate_extraInitializers = [];
114
+ let _disabledDates_decorators;
115
+ let _disabledDates_initializers = [];
116
+ let _disabledDates_extraInitializers = [];
117
+ let _locale_decorators;
118
+ let _locale_initializers = [];
119
+ let _locale_extraInitializers = [];
120
+ let _dateFormat_decorators;
121
+ let _dateFormat_initializers = [];
122
+ let _dateFormat_extraInitializers = [];
123
+ let _isOpen_decorators;
124
+ let _isOpen_initializers = [];
125
+ let _isOpen_extraInitializers = [];
126
+ let _inputValue_decorators;
127
+ let _inputValue_initializers = [];
128
+ let _inputValue_extraInitializers = [];
129
+ let _textField_decorators;
130
+ let _textField_initializers = [];
131
+ let _textField_extraInitializers = [];
132
+ var UiDatePickerInput = class extends _classSuper {
133
+ static { _classThis = this; }
134
+ static {
135
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
136
+ _label_decorators = [property({ type: String })];
137
+ _name_decorators = [property({ type: String })];
138
+ _placeholder_decorators = [property({ type: String })];
139
+ _value_decorators = [property({ type: Object })];
140
+ _disabled_decorators = [property({ type: Boolean })];
141
+ _required_decorators = [property({ type: Boolean })];
142
+ _errorMessage_decorators = [property({ type: String })];
143
+ _error_decorators = [property({ type: Boolean })];
144
+ _minDate_decorators = [property({ type: Object })];
145
+ _maxDate_decorators = [property({ type: Object })];
146
+ _disabledDates_decorators = [property({ type: Array })];
147
+ _locale_decorators = [property({ type: String })];
148
+ _dateFormat_decorators = [property({ type: Object })];
149
+ _isOpen_decorators = [state()];
150
+ _inputValue_decorators = [state()];
151
+ _textField_decorators = [query('ui-outlined-text-field')];
152
+ __esDecorate(this, null, _label_decorators, { kind: "accessor", name: "label", static: false, private: false, access: { has: obj => "label" in obj, get: obj => obj.label, set: (obj, value) => { obj.label = value; } }, metadata: _metadata }, _label_initializers, _label_extraInitializers);
153
+ __esDecorate(this, null, _name_decorators, { kind: "accessor", name: "name", static: false, private: false, access: { has: obj => "name" in obj, get: obj => obj.name, set: (obj, value) => { obj.name = value; } }, metadata: _metadata }, _name_initializers, _name_extraInitializers);
154
+ __esDecorate(this, null, _placeholder_decorators, { kind: "accessor", name: "placeholder", static: false, private: false, access: { has: obj => "placeholder" in obj, get: obj => obj.placeholder, set: (obj, value) => { obj.placeholder = value; } }, metadata: _metadata }, _placeholder_initializers, _placeholder_extraInitializers);
155
+ __esDecorate(this, null, _value_decorators, { kind: "accessor", name: "value", static: false, private: false, access: { has: obj => "value" in obj, get: obj => obj.value, set: (obj, value) => { obj.value = value; } }, metadata: _metadata }, _value_initializers, _value_extraInitializers);
156
+ __esDecorate(this, null, _disabled_decorators, { kind: "accessor", name: "disabled", static: false, private: false, access: { has: obj => "disabled" in obj, get: obj => obj.disabled, set: (obj, value) => { obj.disabled = value; } }, metadata: _metadata }, _disabled_initializers, _disabled_extraInitializers);
157
+ __esDecorate(this, null, _required_decorators, { kind: "accessor", name: "required", static: false, private: false, access: { has: obj => "required" in obj, get: obj => obj.required, set: (obj, value) => { obj.required = value; } }, metadata: _metadata }, _required_initializers, _required_extraInitializers);
158
+ __esDecorate(this, null, _errorMessage_decorators, { kind: "accessor", name: "errorMessage", static: false, private: false, access: { has: obj => "errorMessage" in obj, get: obj => obj.errorMessage, set: (obj, value) => { obj.errorMessage = value; } }, metadata: _metadata }, _errorMessage_initializers, _errorMessage_extraInitializers);
159
+ __esDecorate(this, null, _error_decorators, { kind: "accessor", name: "error", static: false, private: false, access: { has: obj => "error" in obj, get: obj => obj.error, set: (obj, value) => { obj.error = value; } }, metadata: _metadata }, _error_initializers, _error_extraInitializers);
160
+ __esDecorate(this, null, _minDate_decorators, { kind: "accessor", name: "minDate", static: false, private: false, access: { has: obj => "minDate" in obj, get: obj => obj.minDate, set: (obj, value) => { obj.minDate = value; } }, metadata: _metadata }, _minDate_initializers, _minDate_extraInitializers);
161
+ __esDecorate(this, null, _maxDate_decorators, { kind: "accessor", name: "maxDate", static: false, private: false, access: { has: obj => "maxDate" in obj, get: obj => obj.maxDate, set: (obj, value) => { obj.maxDate = value; } }, metadata: _metadata }, _maxDate_initializers, _maxDate_extraInitializers);
162
+ __esDecorate(this, null, _disabledDates_decorators, { kind: "accessor", name: "disabledDates", static: false, private: false, access: { has: obj => "disabledDates" in obj, get: obj => obj.disabledDates, set: (obj, value) => { obj.disabledDates = value; } }, metadata: _metadata }, _disabledDates_initializers, _disabledDates_extraInitializers);
163
+ __esDecorate(this, null, _locale_decorators, { kind: "accessor", name: "locale", static: false, private: false, access: { has: obj => "locale" in obj, get: obj => obj.locale, set: (obj, value) => { obj.locale = value; } }, metadata: _metadata }, _locale_initializers, _locale_extraInitializers);
164
+ __esDecorate(this, null, _dateFormat_decorators, { kind: "accessor", name: "dateFormat", static: false, private: false, access: { has: obj => "dateFormat" in obj, get: obj => obj.dateFormat, set: (obj, value) => { obj.dateFormat = value; } }, metadata: _metadata }, _dateFormat_initializers, _dateFormat_extraInitializers);
165
+ __esDecorate(this, null, _isOpen_decorators, { kind: "accessor", name: "isOpen", static: false, private: false, access: { has: obj => "isOpen" in obj, get: obj => obj.isOpen, set: (obj, value) => { obj.isOpen = value; } }, metadata: _metadata }, _isOpen_initializers, _isOpen_extraInitializers);
166
+ __esDecorate(this, null, _inputValue_decorators, { kind: "accessor", name: "inputValue", static: false, private: false, access: { has: obj => "inputValue" in obj, get: obj => obj.inputValue, set: (obj, value) => { obj.inputValue = value; } }, metadata: _metadata }, _inputValue_initializers, _inputValue_extraInitializers);
167
+ __esDecorate(this, null, _textField_decorators, { kind: "accessor", name: "textField", static: false, private: false, access: { has: obj => "textField" in obj, get: obj => obj.textField, set: (obj, value) => { obj.textField = value; } }, metadata: _metadata }, _textField_initializers, _textField_extraInitializers);
168
+ __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
169
+ UiDatePickerInput = _classThis = _classDescriptor.value;
170
+ if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
171
+ }
172
+ static styles = inputStyles;
173
+ static shadowRootOptions = {
174
+ mode: 'open',
175
+ delegatesFocus: true,
176
+ };
177
+ #label_accessor_storage = __runInitializers(this, _label_initializers, ''
178
+ /**
179
+ * The name attribute for the input field (for form handling)
180
+ */
181
+ );
182
+ /**
183
+ * The label for the input field
184
+ */
185
+ get label() { return this.#label_accessor_storage; }
186
+ set label(value) { this.#label_accessor_storage = value; }
187
+ #name_accessor_storage = (__runInitializers(this, _label_extraInitializers), __runInitializers(this, _name_initializers, ''
188
+ /**
189
+ * Placeholder text for the input
190
+ */
191
+ ));
192
+ /**
193
+ * The name attribute for the input field (for form handling)
194
+ */
195
+ get name() { return this.#name_accessor_storage; }
196
+ set name(value) { this.#name_accessor_storage = value; }
197
+ #placeholder_accessor_storage = (__runInitializers(this, _name_extraInitializers), __runInitializers(this, _placeholder_initializers, 'MM/DD/YYYY'
198
+ /**
199
+ * The currently selected date
200
+ */
201
+ ));
202
+ /**
203
+ * Placeholder text for the input
204
+ */
205
+ get placeholder() { return this.#placeholder_accessor_storage; }
206
+ set placeholder(value) { this.#placeholder_accessor_storage = value; }
207
+ #value_accessor_storage = (__runInitializers(this, _placeholder_extraInitializers), __runInitializers(this, _value_initializers, null
208
+ /**
209
+ * Whether the date picker is disabled
210
+ */
211
+ ));
212
+ /**
213
+ * The currently selected date
214
+ */
215
+ get value() { return this.#value_accessor_storage; }
216
+ set value(value) { this.#value_accessor_storage = value; }
217
+ #disabled_accessor_storage = (__runInitializers(this, _value_extraInitializers), __runInitializers(this, _disabled_initializers, false
218
+ /**
219
+ * Whether the input is required
220
+ */
221
+ ));
222
+ /**
223
+ * Whether the date picker is disabled
224
+ */
225
+ get disabled() { return this.#disabled_accessor_storage; }
226
+ set disabled(value) { this.#disabled_accessor_storage = value; }
227
+ #required_accessor_storage = (__runInitializers(this, _disabled_extraInitializers), __runInitializers(this, _required_initializers, false
228
+ /**
229
+ * Error message to display
230
+ */
231
+ ));
232
+ /**
233
+ * Whether the input is required
234
+ */
235
+ get required() { return this.#required_accessor_storage; }
236
+ set required(value) { this.#required_accessor_storage = value; }
237
+ #errorMessage_accessor_storage = (__runInitializers(this, _required_extraInitializers), __runInitializers(this, _errorMessage_initializers, ''
238
+ /**
239
+ * Whether the input has an error state
240
+ */
241
+ ));
242
+ /**
243
+ * Error message to display
244
+ */
245
+ get errorMessage() { return this.#errorMessage_accessor_storage; }
246
+ set errorMessage(value) { this.#errorMessage_accessor_storage = value; }
247
+ #error_accessor_storage = (__runInitializers(this, _errorMessage_extraInitializers), __runInitializers(this, _error_initializers, false
248
+ /**
249
+ * Minimum selectable date
250
+ */
251
+ ));
252
+ /**
253
+ * Whether the input has an error state
254
+ */
255
+ get error() { return this.#error_accessor_storage; }
256
+ set error(value) { this.#error_accessor_storage = value; }
257
+ #minDate_accessor_storage = (__runInitializers(this, _error_extraInitializers), __runInitializers(this, _minDate_initializers, undefined
258
+ /**
259
+ * Maximum selectable date
260
+ */
261
+ ));
262
+ /**
263
+ * Minimum selectable date
264
+ */
265
+ get minDate() { return this.#minDate_accessor_storage; }
266
+ set minDate(value) { this.#minDate_accessor_storage = value; }
267
+ #maxDate_accessor_storage = (__runInitializers(this, _minDate_extraInitializers), __runInitializers(this, _maxDate_initializers, undefined
268
+ /**
269
+ * Array of disabled dates
270
+ */
271
+ ));
272
+ /**
273
+ * Maximum selectable date
274
+ */
275
+ get maxDate() { return this.#maxDate_accessor_storage; }
276
+ set maxDate(value) { this.#maxDate_accessor_storage = value; }
277
+ #disabledDates_accessor_storage = (__runInitializers(this, _maxDate_extraInitializers), __runInitializers(this, _disabledDates_initializers, undefined
278
+ /**
279
+ * Locale for date formatting
280
+ */
281
+ ));
282
+ /**
283
+ * Array of disabled dates
284
+ */
285
+ get disabledDates() { return this.#disabledDates_accessor_storage; }
286
+ set disabledDates(value) { this.#disabledDates_accessor_storage = value; }
287
+ #locale_accessor_storage = (__runInitializers(this, _disabledDates_extraInitializers), __runInitializers(this, _locale_initializers, undefined
288
+ /**
289
+ * Custom date format function
290
+ */
291
+ ));
292
+ /**
293
+ * Locale for date formatting
294
+ */
295
+ get locale() { return this.#locale_accessor_storage; }
296
+ set locale(value) { this.#locale_accessor_storage = value; }
297
+ #dateFormat_accessor_storage = (__runInitializers(this, _locale_extraInitializers), __runInitializers(this, _dateFormat_initializers, undefined));
298
+ /**
299
+ * Custom date format function
300
+ */
301
+ get dateFormat() { return this.#dateFormat_accessor_storage; }
302
+ set dateFormat(value) { this.#dateFormat_accessor_storage = value; }
303
+ #isOpen_accessor_storage = (__runInitializers(this, _dateFormat_extraInitializers), __runInitializers(this, _isOpen_initializers, false));
304
+ get isOpen() { return this.#isOpen_accessor_storage; }
305
+ set isOpen(value) { this.#isOpen_accessor_storage = value; }
306
+ #inputValue_accessor_storage = (__runInitializers(this, _isOpen_extraInitializers), __runInitializers(this, _inputValue_initializers, ''));
307
+ get inputValue() { return this.#inputValue_accessor_storage; }
308
+ set inputValue(value) { this.#inputValue_accessor_storage = value; }
309
+ #textField_accessor_storage = (__runInitializers(this, _inputValue_extraInitializers), __runInitializers(this, _textField_initializers, void 0));
310
+ get textField() { return this.#textField_accessor_storage; }
311
+ set textField(value) { this.#textField_accessor_storage = value; }
312
+ constructor() {
313
+ super();
314
+ __runInitializers(this, _textField_extraInitializers);
315
+ // Initialize boolean properties to false as per Lit best practices
316
+ this.disabled = false;
317
+ this.required = false;
318
+ this.error = false;
319
+ }
320
+ connectedCallback() {
321
+ super.connectedCallback();
322
+ this.updateInputValue();
323
+ document.addEventListener('click', this.handleDocumentClick.bind(this));
324
+ }
325
+ disconnectedCallback() {
326
+ super.disconnectedCallback();
327
+ document.removeEventListener('click', this.handleDocumentClick.bind(this));
328
+ }
329
+ willUpdate(changedProperties) {
330
+ if (changedProperties.has('value')) {
331
+ this.updateInputValue();
332
+ }
333
+ }
334
+ updated(changedProperties) {
335
+ if (changedProperties.has('isOpen') && this.isOpen) {
336
+ // Set anchor name on text field for CSS Anchor Positioning API
337
+ if (this.textField) {
338
+ // Using setProperty since anchorName is not in TypeScript types yet
339
+ this.textField.style.setProperty('anchor-name', '--ui-date-picker-anchor');
340
+ }
341
+ }
342
+ }
343
+ updateInputValue() {
344
+ if (this.value) {
345
+ this.inputValue = this.dateFormat ? this.dateFormat(this.value) : formatDate(this.value, this.locale);
346
+ }
347
+ else {
348
+ this.inputValue = '';
349
+ }
350
+ }
351
+ handleDocumentClick(event) {
352
+ if (!this.contains(event.target)) {
353
+ this.isOpen = false;
354
+ }
355
+ }
356
+ handleInputClick() {
357
+ if (!this.disabled) {
358
+ this.isOpen = !this.isOpen;
359
+ }
360
+ }
361
+ handleInputChange(event) {
362
+ const target = event.target;
363
+ this.inputValue = target.value;
364
+ const parsedDate = parseDate(this.inputValue);
365
+ if (parsedDate) {
366
+ this.value = parsedDate;
367
+ this.dispatchChangeEvent();
368
+ }
369
+ }
370
+ handleCalendarDateSelect(event) {
371
+ this.value = event.detail.date;
372
+ this.isOpen = false;
373
+ this.dispatchChangeEvent();
374
+ }
375
+ handleCalendarDateCancel() {
376
+ this.isOpen = false;
377
+ }
378
+ handleKeyDown(event) {
379
+ switch (event.key) {
380
+ case 'Escape':
381
+ this.isOpen = false;
382
+ break;
383
+ case 'ArrowDown':
384
+ if (!this.isOpen) {
385
+ event.preventDefault();
386
+ this.isOpen = true;
387
+ }
388
+ break;
389
+ case 'Enter':
390
+ if (this.isOpen) {
391
+ event.preventDefault();
392
+ this.isOpen = false;
393
+ }
394
+ break;
395
+ }
396
+ }
397
+ dispatchChangeEvent() {
398
+ this.dispatchEvent(new CustomEvent('change', {
399
+ detail: {
400
+ value: this.value,
401
+ formattedValue: this.inputValue,
402
+ },
403
+ bubbles: true,
404
+ composed: true,
405
+ }));
406
+ }
407
+ renderCalendarIcon() {
408
+ return html `
409
+ <ui-icon slot="suffix" icon="calendarToday" @click=${this.handleInputClick} class="calendar-icon"></ui-icon>
410
+ `;
411
+ }
412
+ renderDropdown() {
413
+ if (!this.isOpen)
414
+ return null;
415
+ const currentDate = this.value || new Date();
416
+ return html `
417
+ <div class="dropdown-container">
418
+ <ui-date-picker-calendar
419
+ .year=${currentDate.getFullYear()}
420
+ .month=${currentDate.getMonth()}
421
+ .selectedDate=${this.value}
422
+ .minDate=${this.minDate}
423
+ .maxDate=${this.maxDate}
424
+ .disabledDates=${this.disabledDates}
425
+ .locale=${this.locale}
426
+ showActions
427
+ @date-select=${this.handleCalendarDateSelect}
428
+ @date-cancel=${this.handleCalendarDateCancel}
429
+ ></ui-date-picker-calendar>
430
+ </div>
431
+ `;
432
+ }
433
+ render() {
434
+ return html `
435
+ <div class="input-container">
436
+ ${this.isOpen ? html `<div class="backdrop" @click=${() => (this.isOpen = false)}></div>` : ''}
437
+ <ui-outlined-text-field
438
+ .label=${this.label}
439
+ .name=${this.name}
440
+ .placeholder=${this.placeholder}
441
+ .value=${this.inputValue}
442
+ .disabled=${this.disabled}
443
+ .required=${this.required}
444
+ ?invalid=${this.error}
445
+ .invalidText=${this.errorMessage}
446
+ readonly
447
+ @click=${this.handleInputClick}
448
+ @input=${this.handleInputChange}
449
+ @keydown=${this.handleKeyDown}
450
+ >
451
+ ${this.renderCalendarIcon()}
452
+ </ui-outlined-text-field>
453
+ ${this.renderDropdown()}
454
+ </div>
455
+ `;
456
+ }
457
+ static {
458
+ __runInitializers(_classThis, _classExtraInitializers);
459
+ }
460
+ };
461
+ return UiDatePickerInput = _classThis;
462
+ })();
463
+ export { UiDatePickerInput };
464
+ //# sourceMappingURL=ui-date-picker-input.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ui-date-picker-input.js","sourceRoot":"","sources":["../../../../src/md/date-picker/ui-date-picker-input.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAkB,MAAM,KAAK,CAAA;AACtD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAA;AAC9D,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAA;AAEtE,OAAO,mCAAmC,CAAA;AAC1C,OAAO,+CAA+C,CAAA;AACtD,OAAO,2BAA2B,CAAA;AAElC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoEG;IAEU,iBAAiB;4BAD7B,aAAa,CAAC,sBAAsB,CAAC;;;;sBACC,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iCAAlB,SAAQ,WAAU;;;;iCAU9C,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gCAK1B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uCAK1B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;iCAK1B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;oCAK1B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;oCAK3B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;wCAK3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;iCAK1B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,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,IAAI,IAAI,EAAE,CAAA;YAE5C,OAAO,IAAI,CAAA;;;kBAGG,WAAW,CAAC,WAAW,EAAE;mBACxB,WAAW,CAAC,QAAQ,EAAE;0BACf,IAAI,CAAC,KAAK;qBACf,IAAI,CAAC,OAAO;qBACZ,IAAI,CAAC,OAAO;2BACN,IAAI,CAAC,aAAa;oBACzB,IAAI,CAAC,MAAM;;yBAEN,IAAI,CAAC,wBAAwB;yBAC7B,IAAI,CAAC,wBAAwB;;;KAGjD,CAAA;QACH,CAAC;QAEQ,MAAM;YACb,OAAO,IAAI,CAAA;;UAEL,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAA,gCAAgC,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE;;mBAElF,IAAI,CAAC,KAAK;kBACX,IAAI,CAAC,IAAI;yBACF,IAAI,CAAC,WAAW;mBACtB,IAAI,CAAC,UAAU;sBACZ,IAAI,CAAC,QAAQ;sBACb,IAAI,CAAC,QAAQ;qBACd,IAAI,CAAC,KAAK;yBACN,IAAI,CAAC,YAAY;;mBAEvB,IAAI,CAAC,gBAAgB;mBACrB,IAAI,CAAC,iBAAiB;qBACpB,IAAI,CAAC,aAAa;;YAE3B,IAAI,CAAC,kBAAkB,EAAE;;UAE3B,IAAI,CAAC,cAAc,EAAE;;KAE1B,CAAA;QACH,CAAC;;YA/OU,uDAAiB;;;;;SAAjB,iBAAiB","sourcesContent":["import { LitElement, html, TemplateResult } from 'lit'\nimport { customElement, property, state, query } from 'lit/decorators.js'\nimport { inputStyles } from './internals/DatePicker.styles.js'\nimport { formatDate, parseDate } from './internals/DatePickerUtils.js'\nimport type { DateSelectEvent } from './internals/DatePickerCalendar.js'\nimport './internals/DatePickerCalendar.js'\nimport '../../md/text-field/ui-outlined-text-field.js'\nimport '../../md/icons/ui-icon.js'\n\n/**\n * A docked date picker that opens from a text field input.\n * Ideal for forms and date selection in medium to large layouts.\n *\n * ## Features\n * - Text field input with calendar dropdown\n * - Keyboard navigation support (Arrow Down, Enter, Escape)\n * - Custom date formatting\n * - Input validation and error handling\n * - Min/max date constraints\n * - Disabled dates support\n * - Accessible design with proper ARIA attributes\n * - CSS Anchor Positioning API for dropdown placement\n *\n * ## Events\n *\n * ### `change`\n * Fired when the selected date changes.\n *\n * **Detail:**\n * ```typescript\n * {\n * value: Date | null,\n * formattedValue: string\n * }\n * ```\n *\n * ## Usage\n *\n * ### Basic usage\n * ```html\n * <ui-date-picker-input\n * label=\"Select date\"\n * name=\"birthDate\"\n * placeholder=\"MM/DD/YYYY\"\n * .value=${new Date()}\n * @change=${this.handleDateChange}\n * ></ui-date-picker-input>\n * ```\n *\n * ### With validation\n * ```html\n * <ui-date-picker-input\n * label=\"Birth date\"\n * name=\"birthDate\"\n * required\n * .error=${this.hasError}\n * .errorMessage=${\"Please select a valid date\"}\n * .minDate=${new Date('1900-01-01')}\n * .maxDate=${new Date()}\n * ></ui-date-picker-input>\n * ```\n *\n * ### Custom date format\n * ```html\n * <ui-date-picker-input\n * label=\"Birth date\"\n * .dateFormat=${date => date.toLocaleDateString('en-GB')}\n * ></ui-date-picker-input>\n * ```\n *\n * ### With disabled dates\n * ```html\n * <ui-date-picker-input\n * label=\"Appointment date\"\n * .disabledDates=${[new Date('2024-12-25'), new Date('2024-01-01')]}\n * ></ui-date-picker-input>\n * ```\n */\n@customElement('ui-date-picker-input')\nexport class UiDatePickerInput extends LitElement {\n static override styles = inputStyles\n static override shadowRootOptions: ShadowRootInit = {\n mode: 'open',\n delegatesFocus: true,\n }\n\n /**\n * The label for the input field\n */\n @property({ type: String }) accessor label = ''\n\n /**\n * The name attribute for the input field (for form handling)\n */\n @property({ type: String }) accessor name = ''\n\n /**\n * Placeholder text for the input\n */\n @property({ type: String }) accessor placeholder = 'MM/DD/YYYY'\n\n /**\n * The currently selected date\n */\n @property({ type: Object }) accessor value: Date | null = null\n\n /**\n * Whether the date picker is disabled\n */\n @property({ type: Boolean }) accessor disabled = false\n\n /**\n * Whether the input is required\n */\n @property({ type: Boolean }) accessor required = false\n\n /**\n * Error message to display\n */\n @property({ type: String }) accessor errorMessage = ''\n\n /**\n * Whether the input has an error state\n */\n @property({ type: Boolean }) accessor error = false\n\n /**\n * Minimum selectable date\n */\n @property({ type: Object }) accessor minDate: Date | undefined = undefined\n\n /**\n * Maximum selectable date\n */\n @property({ type: Object }) accessor maxDate: Date | undefined = undefined\n\n /**\n * Array of disabled dates\n */\n @property({ type: Array }) accessor disabledDates: Date[] | undefined = undefined\n\n /**\n * Locale for date formatting\n */\n @property({ type: String }) accessor locale: string | undefined = undefined\n\n /**\n * Custom date format function\n */\n @property({ type: Object }) accessor dateFormat: ((date: Date) => string) | undefined = undefined\n\n @state() private accessor isOpen = false\n\n @state() private accessor inputValue = ''\n\n @query('ui-outlined-text-field') private accessor textField!: HTMLElement\n\n constructor() {\n super()\n // Initialize boolean properties to false as per Lit best practices\n this.disabled = false\n this.required = false\n this.error = false\n }\n\n override connectedCallback(): void {\n super.connectedCallback()\n this.updateInputValue()\n document.addEventListener('click', this.handleDocumentClick.bind(this))\n }\n\n override disconnectedCallback(): void {\n super.disconnectedCallback()\n document.removeEventListener('click', this.handleDocumentClick.bind(this))\n }\n\n override willUpdate(changedProperties: Map<string | number | symbol, unknown>): void {\n if (changedProperties.has('value')) {\n this.updateInputValue()\n }\n }\n\n override updated(changedProperties: Map<string | number | symbol, unknown>): void {\n if (changedProperties.has('isOpen') && this.isOpen) {\n // Set anchor name on text field for CSS Anchor Positioning API\n if (this.textField) {\n // Using setProperty since anchorName is not in TypeScript types yet\n this.textField.style.setProperty('anchor-name', '--ui-date-picker-anchor')\n }\n }\n }\n\n private updateInputValue(): void {\n if (this.value) {\n this.inputValue = this.dateFormat ? this.dateFormat(this.value) : formatDate(this.value, this.locale)\n } else {\n this.inputValue = ''\n }\n }\n\n private handleDocumentClick(event: Event): void {\n if (!this.contains(event.target as Node)) {\n this.isOpen = false\n }\n }\n\n private handleInputClick(): void {\n if (!this.disabled) {\n this.isOpen = !this.isOpen\n }\n }\n\n private handleInputChange(event: Event): void {\n const target = event.target as HTMLInputElement\n this.inputValue = target.value\n\n const parsedDate = parseDate(this.inputValue)\n if (parsedDate) {\n this.value = parsedDate\n this.dispatchChangeEvent()\n }\n }\n\n private handleCalendarDateSelect(event: CustomEvent<DateSelectEvent>): void {\n this.value = event.detail.date\n this.isOpen = false\n this.dispatchChangeEvent()\n }\n\n private handleCalendarDateCancel(): void {\n this.isOpen = false\n }\n\n private handleKeyDown(event: KeyboardEvent): void {\n switch (event.key) {\n case 'Escape':\n this.isOpen = false\n break\n case 'ArrowDown':\n if (!this.isOpen) {\n event.preventDefault()\n this.isOpen = true\n }\n break\n case 'Enter':\n if (this.isOpen) {\n event.preventDefault()\n this.isOpen = false\n }\n break\n }\n }\n\n private dispatchChangeEvent(): void {\n this.dispatchEvent(\n new CustomEvent('change', {\n detail: {\n value: this.value,\n formattedValue: this.inputValue,\n },\n bubbles: true,\n composed: true,\n })\n )\n }\n\n private renderCalendarIcon(): TemplateResult {\n return html`\n <ui-icon slot=\"suffix\" icon=\"calendarToday\" @click=${this.handleInputClick} class=\"calendar-icon\"></ui-icon>\n `\n }\n\n private renderDropdown(): TemplateResult | null {\n if (!this.isOpen) return null\n\n const currentDate = this.value || new Date()\n\n return html`\n <div class=\"dropdown-container\">\n <ui-date-picker-calendar\n .year=${currentDate.getFullYear()}\n .month=${currentDate.getMonth()}\n .selectedDate=${this.value}\n .minDate=${this.minDate}\n .maxDate=${this.maxDate}\n .disabledDates=${this.disabledDates}\n .locale=${this.locale}\n showActions\n @date-select=${this.handleCalendarDateSelect}\n @date-cancel=${this.handleCalendarDateCancel}\n ></ui-date-picker-calendar>\n </div>\n `\n }\n\n override render(): TemplateResult {\n return html`\n <div class=\"input-container\">\n ${this.isOpen ? html`<div class=\"backdrop\" @click=${() => (this.isOpen = false)}></div>` : ''}\n <ui-outlined-text-field\n .label=${this.label}\n .name=${this.name}\n .placeholder=${this.placeholder}\n .value=${this.inputValue}\n .disabled=${this.disabled}\n .required=${this.required}\n ?invalid=${this.error}\n .invalidText=${this.errorMessage}\n readonly\n @click=${this.handleInputClick}\n @input=${this.handleInputChange}\n @keydown=${this.handleKeyDown}\n >\n ${this.renderCalendarIcon()}\n </ui-outlined-text-field>\n ${this.renderDropdown()}\n </div>\n `\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'ui-date-picker-input': UiDatePickerInput\n }\n\n interface HTMLElementEventMap {\n change: CustomEvent<{\n value: Date | null\n formattedValue: string\n }>\n }\n}\n"]}
@@ -0,0 +1,178 @@
1
+ import { LitElement, TemplateResult } from 'lit';
2
+ import { DateRange } from './internals/DatePickerUtils.js';
3
+ import '../../md/dialog/ui-dialog.js';
4
+ import '../../md/button/ui-button.js';
5
+ import '../../md/icon-button/ui-icon-button.js';
6
+ import '../../md/text-field/ui-outlined-text-field.js';
7
+ import '../../md/icons/ui-icon.js';
8
+ export interface ModalInputDatePickerChangeEvent {
9
+ range: DateRange;
10
+ formattedRange: {
11
+ start: string | null;
12
+ end: string | null;
13
+ };
14
+ }
15
+ /**
16
+ * A modal date input picker for manual date entry using keyboard.
17
+ * Ideal for compact layouts and precise date entry. Supports both single
18
+ * date selection and date range selection modes.
19
+ *
20
+ * ## Features
21
+ * - Manual date entry with keyboard input
22
+ * - Single date and date range modes
23
+ * - Input validation with error messages
24
+ * - Min/max date constraints
25
+ * - Multiple date format support (MM/DD/YYYY, MM-DD-YYYY, YYYY-MM-DD)
26
+ * - Accessible design with proper ARIA labels and semantic HTML
27
+ * - Real-time validation feedback
28
+ *
29
+ * ## Events
30
+ *
31
+ * ### `date-input-change`
32
+ * Fired when a valid date is entered in the input fields.
33
+ *
34
+ * **Detail for range mode:**
35
+ * ```typescript
36
+ * {
37
+ * range: DateRange,
38
+ * formattedRange: {
39
+ * start: string | null,
40
+ * end: string | null
41
+ * }
42
+ * }
43
+ * ```
44
+ *
45
+ * **Detail for single date mode:**
46
+ * ```typescript
47
+ * {
48
+ * date: Date,
49
+ * formattedDate: string
50
+ * }
51
+ * ```
52
+ *
53
+ * ### `modal-input-close`
54
+ * Fired when the modal is closed, either by confirmation or cancellation.
55
+ *
56
+ * **Detail:**
57
+ * ```typescript
58
+ * {
59
+ * confirmed: boolean,
60
+ * date?: Date | null, // Available in single date mode
61
+ * range?: DateRange | null // Available in range mode
62
+ * }
63
+ * ```
64
+ *
65
+ * ## Usage
66
+ *
67
+ * ### Range mode (default)
68
+ * ```html
69
+ * <ui-date-picker-modal-input
70
+ * .open=${true}
71
+ * .selectedRange=${{ start: new Date(), end: null }}
72
+ * @date-input-change=${this.handleRangeChange}
73
+ * @modal-input-close=${this.handleClose}
74
+ * ></ui-date-picker-modal-input>
75
+ * ```
76
+ *
77
+ * ### Single date mode
78
+ * ```html
79
+ * <ui-date-picker-modal-input
80
+ * .rangeMode=${false}
81
+ * .selectedDate=${new Date()}
82
+ * @date-input-change=${this.handleDateChange}
83
+ * @modal-input-close=${this.handleClose}
84
+ * ></ui-date-picker-modal-input>
85
+ * ```
86
+ *
87
+ * ### With constraints
88
+ * ```html
89
+ * <ui-date-picker-modal-input
90
+ * .minDate=${new Date('2024-01-01')}
91
+ * .maxDate=${new Date('2024-12-31')}
92
+ * .locale=${'en-US'}
93
+ * ></ui-date-picker-modal-input>
94
+ * ```
95
+ */
96
+ export declare class UiDatePickerModalInput extends LitElement {
97
+ static styles: import("lit").CSSResult;
98
+ /**
99
+ * Whether the modal is open
100
+ */
101
+ accessor open: boolean;
102
+ /**
103
+ * The modal title
104
+ */
105
+ accessor title: string;
106
+ /**
107
+ * Whether to use range mode (two date inputs) or single date mode
108
+ */
109
+ accessor rangeMode: boolean;
110
+ /**
111
+ * Label for the start date (or single date)
112
+ */
113
+ accessor startLabel: string;
114
+ /**
115
+ * Label for the end date (only used in range mode)
116
+ */
117
+ accessor endLabel: string;
118
+ /**
119
+ * Placeholder for date inputs
120
+ */
121
+ accessor placeholder: string;
122
+ /**
123
+ * The selected date (single mode)
124
+ */
125
+ accessor selectedDate: Date | null;
126
+ /**
127
+ * The selected date range (range mode)
128
+ */
129
+ accessor selectedRange: DateRange | null;
130
+ /**
131
+ * Minimum selectable date
132
+ */
133
+ accessor minDate: Date | undefined;
134
+ /**
135
+ * Maximum selectable date
136
+ */
137
+ accessor maxDate: Date | undefined;
138
+ /**
139
+ * Locale for date formatting
140
+ */
141
+ accessor locale: string | undefined;
142
+ private accessor startInput;
143
+ private accessor endInput;
144
+ private accessor startError;
145
+ private accessor endError;
146
+ constructor();
147
+ connectedCallback(): void;
148
+ willUpdate(changedProperties: Map<string | number | symbol, unknown>): void;
149
+ private updateInputValues;
150
+ private validateDate;
151
+ private handleStartInput;
152
+ private handleEndInput;
153
+ private handleCancel;
154
+ private handleConfirm;
155
+ private dispatchChangeEvent;
156
+ private dispatchCloseEvent;
157
+ private renderHeader;
158
+ private renderInputs;
159
+ private renderActions;
160
+ render(): TemplateResult;
161
+ }
162
+ declare global {
163
+ interface HTMLElementTagNameMap {
164
+ 'ui-date-picker-modal-input': UiDatePickerModalInput;
165
+ }
166
+ interface HTMLElementEventMap {
167
+ 'date-input-change': CustomEvent<ModalInputDatePickerChangeEvent | {
168
+ date: Date;
169
+ formattedDate: string;
170
+ }>;
171
+ 'modal-input-close': CustomEvent<{
172
+ confirmed: boolean;
173
+ date?: Date | null;
174
+ range?: DateRange | null;
175
+ }>;
176
+ }
177
+ }
178
+ //# sourceMappingURL=ui-date-picker-modal-input.d.ts.map