@api-client/ui 0.5.5 → 0.5.6
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.
- package/build/src/elements/highlight/MarkdownStyles.d.ts.map +1 -1
- package/build/src/elements/highlight/MarkdownStyles.js +0 -13
- package/build/src/elements/highlight/MarkdownStyles.js.map +1 -1
- package/build/src/elements/http/BodyEditor.d.ts +0 -13
- package/build/src/elements/http/BodyEditor.d.ts.map +1 -1
- package/build/src/elements/http/BodyEditor.js +0 -13
- package/build/src/elements/http/BodyEditor.js.map +1 -1
- package/build/src/elements/http/BodyTextEditor.d.ts +0 -13
- package/build/src/elements/http/BodyTextEditor.d.ts.map +1 -1
- package/build/src/elements/http/BodyTextEditor.js +0 -13
- package/build/src/elements/http/BodyTextEditor.js.map +1 -1
- package/build/src/elements/http/BodyUrlEncodedEditor.d.ts +0 -13
- package/build/src/elements/http/BodyUrlEncodedEditor.d.ts.map +1 -1
- package/build/src/elements/http/BodyUrlEncodedEditor.js +0 -13
- package/build/src/elements/http/BodyUrlEncodedEditor.js.map +1 -1
- package/build/src/elements/http/UrlInput.d.ts +0 -13
- package/build/src/elements/http/UrlInput.d.ts.map +1 -1
- package/build/src/elements/http/UrlInput.js +0 -13
- package/build/src/elements/http/UrlInput.js.map +1 -1
- package/build/src/index.d.ts +2 -0
- package/build/src/index.d.ts.map +1 -1
- package/build/src/index.js +2 -0
- package/build/src/index.js.map +1 -1
- package/build/src/md/button/internals/button.styles.js +1 -1
- package/build/src/md/button/internals/button.styles.js.map +1 -1
- package/build/src/md/date/internals/DateTime.d.ts +0 -13
- package/build/src/md/date/internals/DateTime.d.ts.map +1 -1
- package/build/src/md/date/internals/DateTime.js +0 -13
- package/build/src/md/date/internals/DateTime.js.map +1 -1
- package/build/src/md/date-picker/index.d.ts +13 -0
- package/build/src/md/date-picker/index.d.ts.map +1 -0
- package/build/src/md/date-picker/index.js +13 -0
- package/build/src/md/date-picker/index.js.map +1 -0
- package/build/src/md/date-picker/internals/DatePicker.styles.d.ts +4 -0
- package/build/src/md/date-picker/internals/DatePicker.styles.d.ts.map +1 -0
- package/build/src/md/date-picker/internals/DatePicker.styles.js +336 -0
- package/build/src/md/date-picker/internals/DatePicker.styles.js.map +1 -0
- package/build/src/md/date-picker/internals/DatePickerCalendar.d.ts +159 -0
- package/build/src/md/date-picker/internals/DatePickerCalendar.d.ts.map +1 -0
- package/build/src/md/date-picker/internals/DatePickerCalendar.js +770 -0
- package/build/src/md/date-picker/internals/DatePickerCalendar.js.map +1 -0
- package/build/src/md/date-picker/internals/DatePickerUtils.d.ts +93 -0
- package/build/src/md/date-picker/internals/DatePickerUtils.d.ts.map +1 -0
- package/build/src/md/date-picker/internals/DatePickerUtils.js +221 -0
- package/build/src/md/date-picker/internals/DatePickerUtils.js.map +1 -0
- package/build/src/md/date-picker/ui-date-picker-input.d.ts +108 -0
- package/build/src/md/date-picker/ui-date-picker-input.d.ts.map +1 -0
- package/build/src/md/date-picker/ui-date-picker-input.js +397 -0
- package/build/src/md/date-picker/ui-date-picker-input.js.map +1 -0
- package/build/src/md/date-picker/ui-date-picker-modal-input.d.ts +119 -0
- package/build/src/md/date-picker/ui-date-picker-modal-input.d.ts.map +1 -0
- package/build/src/md/date-picker/ui-date-picker-modal-input.js +473 -0
- package/build/src/md/date-picker/ui-date-picker-modal-input.js.map +1 -0
- package/build/src/md/date-picker/ui-date-picker-modal.d.ts +108 -0
- package/build/src/md/date-picker/ui-date-picker-modal.d.ts.map +1 -0
- package/build/src/md/date-picker/ui-date-picker-modal.js +344 -0
- package/build/src/md/date-picker/ui-date-picker-modal.js.map +1 -0
- package/build/src/md/dialog/internals/Dialog.styles.d.ts.map +1 -1
- package/build/src/md/dialog/internals/Dialog.styles.js +1 -0
- package/build/src/md/dialog/internals/Dialog.styles.js.map +1 -1
- package/demo/elements/har/har2.json +1 -1
- package/demo/md/date-picker/date-picker.ts +301 -0
- package/demo/md/date-picker/index.html +171 -0
- package/demo/md/index.html +2 -0
- package/package.json +1 -1
- package/src/elements/highlight/MarkdownStyles.ts +0 -13
- package/src/elements/http/BodyEditor.ts +0 -13
- package/src/elements/http/BodyTextEditor.ts +0 -13
- package/src/elements/http/BodyUrlEncodedEditor.ts +0 -13
- package/src/elements/http/UrlInput.ts +0 -13
- package/src/index.ts +17 -0
- package/src/md/button/internals/button.styles.ts +1 -1
- package/src/md/date/internals/DateTime.ts +0 -14
- package/src/md/date-picker/README.md +184 -0
- package/src/md/date-picker/index.ts +17 -0
- package/src/md/date-picker/internals/DatePicker.styles.ts +338 -0
- package/src/md/date-picker/internals/DatePickerCalendar.ts +697 -0
- package/src/md/date-picker/internals/DatePickerUtils.ts +288 -0
- package/src/md/date-picker/ui-date-picker-input.ts +272 -0
- package/src/md/date-picker/ui-date-picker-modal-input.ts +371 -0
- package/src/md/date-picker/ui-date-picker-modal.ts +263 -0
- package/src/md/dialog/internals/Dialog.styles.ts +1 -0
|
@@ -0,0 +1,770 @@
|
|
|
1
|
+
import { __esDecorate, __runInitializers } from "tslib";
|
|
2
|
+
import { LitElement, html, nothing } from 'lit';
|
|
3
|
+
import { customElement, property, state } from 'lit/decorators.js';
|
|
4
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
5
|
+
import { calendarStyles } from './DatePicker.styles.js';
|
|
6
|
+
import { generateCalendarMonth, addMonths, getMonthNames, isSameDay, formatDate, } from './DatePickerUtils.js';
|
|
7
|
+
import '../../../md/icons/ui-icon.js';
|
|
8
|
+
import '../../../md/button/ui-button.js';
|
|
9
|
+
import '../../../md/icon-button/ui-icon-button.js';
|
|
10
|
+
/**
|
|
11
|
+
* A calendar grid component for date selection.
|
|
12
|
+
* Supports single date selection and date range selection.
|
|
13
|
+
*
|
|
14
|
+
* ## Usage
|
|
15
|
+
*
|
|
16
|
+
* ```html
|
|
17
|
+
* <ui-date-picker-calendar></ui-date-picker-calendar>
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* ### Single date selection
|
|
21
|
+
* ```html
|
|
22
|
+
* <ui-date-picker-calendar
|
|
23
|
+
* .selectedDate=${new Date()}
|
|
24
|
+
* @date-select=${this.handleDateSelect}
|
|
25
|
+
* ></ui-date-picker-calendar>
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* ### Date range selection
|
|
29
|
+
* ```html
|
|
30
|
+
* <ui-date-picker-calendar
|
|
31
|
+
* .rangeSelection=${true}
|
|
32
|
+
* .selectedRange=${{ start: new Date(), end: null }}
|
|
33
|
+
* @date-range-select=${this.handleRangeSelect}
|
|
34
|
+
* ></ui-date-picker-calendar>
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
let UiDatePickerCalendar = (() => {
|
|
38
|
+
let _classDecorators = [customElement('ui-date-picker-calendar')];
|
|
39
|
+
let _classDescriptor;
|
|
40
|
+
let _classExtraInitializers = [];
|
|
41
|
+
let _classThis;
|
|
42
|
+
let _classSuper = LitElement;
|
|
43
|
+
let _year_decorators;
|
|
44
|
+
let _year_initializers = [];
|
|
45
|
+
let _year_extraInitializers = [];
|
|
46
|
+
let _month_decorators;
|
|
47
|
+
let _month_initializers = [];
|
|
48
|
+
let _month_extraInitializers = [];
|
|
49
|
+
let _selectedDate_decorators;
|
|
50
|
+
let _selectedDate_initializers = [];
|
|
51
|
+
let _selectedDate_extraInitializers = [];
|
|
52
|
+
let _selectedRange_decorators;
|
|
53
|
+
let _selectedRange_initializers = [];
|
|
54
|
+
let _selectedRange_extraInitializers = [];
|
|
55
|
+
let _rangeSelection_decorators;
|
|
56
|
+
let _rangeSelection_initializers = [];
|
|
57
|
+
let _rangeSelection_extraInitializers = [];
|
|
58
|
+
let _minDate_decorators;
|
|
59
|
+
let _minDate_initializers = [];
|
|
60
|
+
let _minDate_extraInitializers = [];
|
|
61
|
+
let _maxDate_decorators;
|
|
62
|
+
let _maxDate_initializers = [];
|
|
63
|
+
let _maxDate_extraInitializers = [];
|
|
64
|
+
let _disabledDates_decorators;
|
|
65
|
+
let _disabledDates_initializers = [];
|
|
66
|
+
let _disabledDates_extraInitializers = [];
|
|
67
|
+
let _locale_decorators;
|
|
68
|
+
let _locale_initializers = [];
|
|
69
|
+
let _locale_extraInitializers = [];
|
|
70
|
+
let _showNavigation_decorators;
|
|
71
|
+
let _showNavigation_initializers = [];
|
|
72
|
+
let _showNavigation_extraInitializers = [];
|
|
73
|
+
let _showActions_decorators;
|
|
74
|
+
let _showActions_initializers = [];
|
|
75
|
+
let _showActions_extraInitializers = [];
|
|
76
|
+
let _okButtonText_decorators;
|
|
77
|
+
let _okButtonText_initializers = [];
|
|
78
|
+
let _okButtonText_extraInitializers = [];
|
|
79
|
+
let _cancelButtonText_decorators;
|
|
80
|
+
let _cancelButtonText_initializers = [];
|
|
81
|
+
let _cancelButtonText_extraInitializers = [];
|
|
82
|
+
let __calendarData_decorators;
|
|
83
|
+
let __calendarData_initializers = [];
|
|
84
|
+
let __calendarData_extraInitializers = [];
|
|
85
|
+
let __rangeStart_decorators;
|
|
86
|
+
let __rangeStart_initializers = [];
|
|
87
|
+
let __rangeStart_extraInitializers = [];
|
|
88
|
+
let __monthNames_decorators;
|
|
89
|
+
let __monthNames_initializers = [];
|
|
90
|
+
let __monthNames_extraInitializers = [];
|
|
91
|
+
let __showMonthDropdown_decorators;
|
|
92
|
+
let __showMonthDropdown_initializers = [];
|
|
93
|
+
let __showMonthDropdown_extraInitializers = [];
|
|
94
|
+
let __showYearDropdown_decorators;
|
|
95
|
+
let __showYearDropdown_initializers = [];
|
|
96
|
+
let __showYearDropdown_extraInitializers = [];
|
|
97
|
+
let __pendingDate_decorators;
|
|
98
|
+
let __pendingDate_initializers = [];
|
|
99
|
+
let __pendingDate_extraInitializers = [];
|
|
100
|
+
let __pendingRange_decorators;
|
|
101
|
+
let __pendingRange_initializers = [];
|
|
102
|
+
let __pendingRange_extraInitializers = [];
|
|
103
|
+
var UiDatePickerCalendar = class extends _classSuper {
|
|
104
|
+
static { _classThis = this; }
|
|
105
|
+
static {
|
|
106
|
+
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
107
|
+
_year_decorators = [property({ type: Number })];
|
|
108
|
+
_month_decorators = [property({ type: Number })];
|
|
109
|
+
_selectedDate_decorators = [property({ type: Object })];
|
|
110
|
+
_selectedRange_decorators = [property({ type: Object })];
|
|
111
|
+
_rangeSelection_decorators = [property({ type: Boolean })];
|
|
112
|
+
_minDate_decorators = [property({ type: Object })];
|
|
113
|
+
_maxDate_decorators = [property({ type: Object })];
|
|
114
|
+
_disabledDates_decorators = [property({ type: Array })];
|
|
115
|
+
_locale_decorators = [property({ type: String })];
|
|
116
|
+
_showNavigation_decorators = [property({ type: Boolean })];
|
|
117
|
+
_showActions_decorators = [property({ type: Boolean })];
|
|
118
|
+
_okButtonText_decorators = [property({ type: String })];
|
|
119
|
+
_cancelButtonText_decorators = [property({ type: String })];
|
|
120
|
+
__calendarData_decorators = [state()];
|
|
121
|
+
__rangeStart_decorators = [state()];
|
|
122
|
+
__monthNames_decorators = [state()];
|
|
123
|
+
__showMonthDropdown_decorators = [state()];
|
|
124
|
+
__showYearDropdown_decorators = [state()];
|
|
125
|
+
__pendingDate_decorators = [state()];
|
|
126
|
+
__pendingRange_decorators = [state()];
|
|
127
|
+
__esDecorate(this, null, _year_decorators, { kind: "accessor", name: "year", static: false, private: false, access: { has: obj => "year" in obj, get: obj => obj.year, set: (obj, value) => { obj.year = value; } }, metadata: _metadata }, _year_initializers, _year_extraInitializers);
|
|
128
|
+
__esDecorate(this, null, _month_decorators, { kind: "accessor", name: "month", static: false, private: false, access: { has: obj => "month" in obj, get: obj => obj.month, set: (obj, value) => { obj.month = value; } }, metadata: _metadata }, _month_initializers, _month_extraInitializers);
|
|
129
|
+
__esDecorate(this, null, _selectedDate_decorators, { kind: "accessor", name: "selectedDate", static: false, private: false, access: { has: obj => "selectedDate" in obj, get: obj => obj.selectedDate, set: (obj, value) => { obj.selectedDate = value; } }, metadata: _metadata }, _selectedDate_initializers, _selectedDate_extraInitializers);
|
|
130
|
+
__esDecorate(this, null, _selectedRange_decorators, { kind: "accessor", name: "selectedRange", static: false, private: false, access: { has: obj => "selectedRange" in obj, get: obj => obj.selectedRange, set: (obj, value) => { obj.selectedRange = value; } }, metadata: _metadata }, _selectedRange_initializers, _selectedRange_extraInitializers);
|
|
131
|
+
__esDecorate(this, null, _rangeSelection_decorators, { kind: "accessor", name: "rangeSelection", static: false, private: false, access: { has: obj => "rangeSelection" in obj, get: obj => obj.rangeSelection, set: (obj, value) => { obj.rangeSelection = value; } }, metadata: _metadata }, _rangeSelection_initializers, _rangeSelection_extraInitializers);
|
|
132
|
+
__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);
|
|
133
|
+
__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);
|
|
134
|
+
__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);
|
|
135
|
+
__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);
|
|
136
|
+
__esDecorate(this, null, _showNavigation_decorators, { kind: "accessor", name: "showNavigation", static: false, private: false, access: { has: obj => "showNavigation" in obj, get: obj => obj.showNavigation, set: (obj, value) => { obj.showNavigation = value; } }, metadata: _metadata }, _showNavigation_initializers, _showNavigation_extraInitializers);
|
|
137
|
+
__esDecorate(this, null, _showActions_decorators, { kind: "accessor", name: "showActions", static: false, private: false, access: { has: obj => "showActions" in obj, get: obj => obj.showActions, set: (obj, value) => { obj.showActions = value; } }, metadata: _metadata }, _showActions_initializers, _showActions_extraInitializers);
|
|
138
|
+
__esDecorate(this, null, _okButtonText_decorators, { kind: "accessor", name: "okButtonText", static: false, private: false, access: { has: obj => "okButtonText" in obj, get: obj => obj.okButtonText, set: (obj, value) => { obj.okButtonText = value; } }, metadata: _metadata }, _okButtonText_initializers, _okButtonText_extraInitializers);
|
|
139
|
+
__esDecorate(this, null, _cancelButtonText_decorators, { kind: "accessor", name: "cancelButtonText", static: false, private: false, access: { has: obj => "cancelButtonText" in obj, get: obj => obj.cancelButtonText, set: (obj, value) => { obj.cancelButtonText = value; } }, metadata: _metadata }, _cancelButtonText_initializers, _cancelButtonText_extraInitializers);
|
|
140
|
+
__esDecorate(this, null, __calendarData_decorators, { kind: "accessor", name: "_calendarData", static: false, private: false, access: { has: obj => "_calendarData" in obj, get: obj => obj._calendarData, set: (obj, value) => { obj._calendarData = value; } }, metadata: _metadata }, __calendarData_initializers, __calendarData_extraInitializers);
|
|
141
|
+
__esDecorate(this, null, __rangeStart_decorators, { kind: "accessor", name: "_rangeStart", static: false, private: false, access: { has: obj => "_rangeStart" in obj, get: obj => obj._rangeStart, set: (obj, value) => { obj._rangeStart = value; } }, metadata: _metadata }, __rangeStart_initializers, __rangeStart_extraInitializers);
|
|
142
|
+
__esDecorate(this, null, __monthNames_decorators, { kind: "accessor", name: "_monthNames", static: false, private: false, access: { has: obj => "_monthNames" in obj, get: obj => obj._monthNames, set: (obj, value) => { obj._monthNames = value; } }, metadata: _metadata }, __monthNames_initializers, __monthNames_extraInitializers);
|
|
143
|
+
__esDecorate(this, null, __showMonthDropdown_decorators, { kind: "accessor", name: "_showMonthDropdown", static: false, private: false, access: { has: obj => "_showMonthDropdown" in obj, get: obj => obj._showMonthDropdown, set: (obj, value) => { obj._showMonthDropdown = value; } }, metadata: _metadata }, __showMonthDropdown_initializers, __showMonthDropdown_extraInitializers);
|
|
144
|
+
__esDecorate(this, null, __showYearDropdown_decorators, { kind: "accessor", name: "_showYearDropdown", static: false, private: false, access: { has: obj => "_showYearDropdown" in obj, get: obj => obj._showYearDropdown, set: (obj, value) => { obj._showYearDropdown = value; } }, metadata: _metadata }, __showYearDropdown_initializers, __showYearDropdown_extraInitializers);
|
|
145
|
+
__esDecorate(this, null, __pendingDate_decorators, { kind: "accessor", name: "_pendingDate", static: false, private: false, access: { has: obj => "_pendingDate" in obj, get: obj => obj._pendingDate, set: (obj, value) => { obj._pendingDate = value; } }, metadata: _metadata }, __pendingDate_initializers, __pendingDate_extraInitializers);
|
|
146
|
+
__esDecorate(this, null, __pendingRange_decorators, { kind: "accessor", name: "_pendingRange", static: false, private: false, access: { has: obj => "_pendingRange" in obj, get: obj => obj._pendingRange, set: (obj, value) => { obj._pendingRange = value; } }, metadata: _metadata }, __pendingRange_initializers, __pendingRange_extraInitializers);
|
|
147
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
148
|
+
UiDatePickerCalendar = _classThis = _classDescriptor.value;
|
|
149
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
150
|
+
}
|
|
151
|
+
static styles = calendarStyles;
|
|
152
|
+
#year_accessor_storage = __runInitializers(this, _year_initializers, new Date().getFullYear()
|
|
153
|
+
/**
|
|
154
|
+
* The currently displayed month (0-indexed)
|
|
155
|
+
*/
|
|
156
|
+
);
|
|
157
|
+
/**
|
|
158
|
+
* The currently displayed year
|
|
159
|
+
*/
|
|
160
|
+
get year() { return this.#year_accessor_storage; }
|
|
161
|
+
set year(value) { this.#year_accessor_storage = value; }
|
|
162
|
+
#month_accessor_storage = (__runInitializers(this, _year_extraInitializers), __runInitializers(this, _month_initializers, new Date().getMonth()
|
|
163
|
+
/**
|
|
164
|
+
* The currently selected date for single selection mode
|
|
165
|
+
*/
|
|
166
|
+
));
|
|
167
|
+
/**
|
|
168
|
+
* The currently displayed month (0-indexed)
|
|
169
|
+
*/
|
|
170
|
+
get month() { return this.#month_accessor_storage; }
|
|
171
|
+
set month(value) { this.#month_accessor_storage = value; }
|
|
172
|
+
#selectedDate_accessor_storage = (__runInitializers(this, _month_extraInitializers), __runInitializers(this, _selectedDate_initializers, null
|
|
173
|
+
/**
|
|
174
|
+
* The selected date range for range selection mode
|
|
175
|
+
*/
|
|
176
|
+
));
|
|
177
|
+
/**
|
|
178
|
+
* The currently selected date for single selection mode
|
|
179
|
+
*/
|
|
180
|
+
get selectedDate() { return this.#selectedDate_accessor_storage; }
|
|
181
|
+
set selectedDate(value) { this.#selectedDate_accessor_storage = value; }
|
|
182
|
+
#selectedRange_accessor_storage = (__runInitializers(this, _selectedDate_extraInitializers), __runInitializers(this, _selectedRange_initializers, null
|
|
183
|
+
/**
|
|
184
|
+
* Enable range selection mode
|
|
185
|
+
*/
|
|
186
|
+
));
|
|
187
|
+
/**
|
|
188
|
+
* The selected date range for range selection mode
|
|
189
|
+
*/
|
|
190
|
+
get selectedRange() { return this.#selectedRange_accessor_storage; }
|
|
191
|
+
set selectedRange(value) { this.#selectedRange_accessor_storage = value; }
|
|
192
|
+
#rangeSelection_accessor_storage = (__runInitializers(this, _selectedRange_extraInitializers), __runInitializers(this, _rangeSelection_initializers, false
|
|
193
|
+
/**
|
|
194
|
+
* Minimum selectable date
|
|
195
|
+
*/
|
|
196
|
+
));
|
|
197
|
+
/**
|
|
198
|
+
* Enable range selection mode
|
|
199
|
+
*/
|
|
200
|
+
get rangeSelection() { return this.#rangeSelection_accessor_storage; }
|
|
201
|
+
set rangeSelection(value) { this.#rangeSelection_accessor_storage = value; }
|
|
202
|
+
#minDate_accessor_storage = (__runInitializers(this, _rangeSelection_extraInitializers), __runInitializers(this, _minDate_initializers, undefined
|
|
203
|
+
/**
|
|
204
|
+
* Maximum selectable date
|
|
205
|
+
*/
|
|
206
|
+
));
|
|
207
|
+
/**
|
|
208
|
+
* Minimum selectable date
|
|
209
|
+
*/
|
|
210
|
+
get minDate() { return this.#minDate_accessor_storage; }
|
|
211
|
+
set minDate(value) { this.#minDate_accessor_storage = value; }
|
|
212
|
+
#maxDate_accessor_storage = (__runInitializers(this, _minDate_extraInitializers), __runInitializers(this, _maxDate_initializers, undefined
|
|
213
|
+
/**
|
|
214
|
+
* Array of disabled dates
|
|
215
|
+
*/
|
|
216
|
+
));
|
|
217
|
+
/**
|
|
218
|
+
* Maximum selectable date
|
|
219
|
+
*/
|
|
220
|
+
get maxDate() { return this.#maxDate_accessor_storage; }
|
|
221
|
+
set maxDate(value) { this.#maxDate_accessor_storage = value; }
|
|
222
|
+
#disabledDates_accessor_storage = (__runInitializers(this, _maxDate_extraInitializers), __runInitializers(this, _disabledDates_initializers, undefined
|
|
223
|
+
/**
|
|
224
|
+
* Locale for date formatting and month/day names
|
|
225
|
+
*/
|
|
226
|
+
));
|
|
227
|
+
/**
|
|
228
|
+
* Array of disabled dates
|
|
229
|
+
*/
|
|
230
|
+
get disabledDates() { return this.#disabledDates_accessor_storage; }
|
|
231
|
+
set disabledDates(value) { this.#disabledDates_accessor_storage = value; }
|
|
232
|
+
#locale_accessor_storage = (__runInitializers(this, _disabledDates_extraInitializers), __runInitializers(this, _locale_initializers, undefined
|
|
233
|
+
/**
|
|
234
|
+
* Whether to show navigation controls
|
|
235
|
+
*/
|
|
236
|
+
));
|
|
237
|
+
/**
|
|
238
|
+
* Locale for date formatting and month/day names
|
|
239
|
+
*/
|
|
240
|
+
get locale() { return this.#locale_accessor_storage; }
|
|
241
|
+
set locale(value) { this.#locale_accessor_storage = value; }
|
|
242
|
+
#showNavigation_accessor_storage = (__runInitializers(this, _locale_extraInitializers), __runInitializers(this, _showNavigation_initializers, true
|
|
243
|
+
/**
|
|
244
|
+
* Whether to show action buttons (OK/Cancel)
|
|
245
|
+
*/
|
|
246
|
+
));
|
|
247
|
+
/**
|
|
248
|
+
* Whether to show navigation controls
|
|
249
|
+
*/
|
|
250
|
+
get showNavigation() { return this.#showNavigation_accessor_storage; }
|
|
251
|
+
set showNavigation(value) { this.#showNavigation_accessor_storage = value; }
|
|
252
|
+
#showActions_accessor_storage = (__runInitializers(this, _showNavigation_extraInitializers), __runInitializers(this, _showActions_initializers, false
|
|
253
|
+
/**
|
|
254
|
+
* Text for the OK button
|
|
255
|
+
*/
|
|
256
|
+
));
|
|
257
|
+
/**
|
|
258
|
+
* Whether to show action buttons (OK/Cancel)
|
|
259
|
+
*/
|
|
260
|
+
get showActions() { return this.#showActions_accessor_storage; }
|
|
261
|
+
set showActions(value) { this.#showActions_accessor_storage = value; }
|
|
262
|
+
#okButtonText_accessor_storage = (__runInitializers(this, _showActions_extraInitializers), __runInitializers(this, _okButtonText_initializers, 'OK'
|
|
263
|
+
/**
|
|
264
|
+
* Text for the Cancel button
|
|
265
|
+
*/
|
|
266
|
+
));
|
|
267
|
+
/**
|
|
268
|
+
* Text for the OK button
|
|
269
|
+
*/
|
|
270
|
+
get okButtonText() { return this.#okButtonText_accessor_storage; }
|
|
271
|
+
set okButtonText(value) { this.#okButtonText_accessor_storage = value; }
|
|
272
|
+
#cancelButtonText_accessor_storage = (__runInitializers(this, _okButtonText_extraInitializers), __runInitializers(this, _cancelButtonText_initializers, 'Cancel'));
|
|
273
|
+
/**
|
|
274
|
+
* Text for the Cancel button
|
|
275
|
+
*/
|
|
276
|
+
get cancelButtonText() { return this.#cancelButtonText_accessor_storage; }
|
|
277
|
+
set cancelButtonText(value) { this.#cancelButtonText_accessor_storage = value; }
|
|
278
|
+
#_calendarData_accessor_storage = (__runInitializers(this, _cancelButtonText_extraInitializers), __runInitializers(this, __calendarData_initializers, undefined));
|
|
279
|
+
get _calendarData() { return this.#_calendarData_accessor_storage; }
|
|
280
|
+
set _calendarData(value) { this.#_calendarData_accessor_storage = value; }
|
|
281
|
+
#_rangeStart_accessor_storage = (__runInitializers(this, __calendarData_extraInitializers), __runInitializers(this, __rangeStart_initializers, undefined));
|
|
282
|
+
get _rangeStart() { return this.#_rangeStart_accessor_storage; }
|
|
283
|
+
set _rangeStart(value) { this.#_rangeStart_accessor_storage = value; }
|
|
284
|
+
#_monthNames_accessor_storage = (__runInitializers(this, __rangeStart_extraInitializers), __runInitializers(this, __monthNames_initializers, []));
|
|
285
|
+
get _monthNames() { return this.#_monthNames_accessor_storage; }
|
|
286
|
+
set _monthNames(value) { this.#_monthNames_accessor_storage = value; }
|
|
287
|
+
#_showMonthDropdown_accessor_storage = (__runInitializers(this, __monthNames_extraInitializers), __runInitializers(this, __showMonthDropdown_initializers, false));
|
|
288
|
+
get _showMonthDropdown() { return this.#_showMonthDropdown_accessor_storage; }
|
|
289
|
+
set _showMonthDropdown(value) { this.#_showMonthDropdown_accessor_storage = value; }
|
|
290
|
+
#_showYearDropdown_accessor_storage = (__runInitializers(this, __showMonthDropdown_extraInitializers), __runInitializers(this, __showYearDropdown_initializers, false));
|
|
291
|
+
get _showYearDropdown() { return this.#_showYearDropdown_accessor_storage; }
|
|
292
|
+
set _showYearDropdown(value) { this.#_showYearDropdown_accessor_storage = value; }
|
|
293
|
+
#_pendingDate_accessor_storage = (__runInitializers(this, __showYearDropdown_extraInitializers), __runInitializers(this, __pendingDate_initializers, null));
|
|
294
|
+
get _pendingDate() { return this.#_pendingDate_accessor_storage; }
|
|
295
|
+
set _pendingDate(value) { this.#_pendingDate_accessor_storage = value; }
|
|
296
|
+
#_pendingRange_accessor_storage = (__runInitializers(this, __pendingDate_extraInitializers), __runInitializers(this, __pendingRange_initializers, null));
|
|
297
|
+
get _pendingRange() { return this.#_pendingRange_accessor_storage; }
|
|
298
|
+
set _pendingRange(value) { this.#_pendingRange_accessor_storage = value; }
|
|
299
|
+
connectedCallback() {
|
|
300
|
+
super.connectedCallback();
|
|
301
|
+
this._updateCalendar();
|
|
302
|
+
this._updateMonthNames();
|
|
303
|
+
document.addEventListener('keydown', this._handleDocumentKeyDown.bind(this));
|
|
304
|
+
}
|
|
305
|
+
disconnectedCallback() {
|
|
306
|
+
super.disconnectedCallback();
|
|
307
|
+
document.removeEventListener('keydown', this._handleDocumentKeyDown.bind(this));
|
|
308
|
+
}
|
|
309
|
+
updated(changedProperties) {
|
|
310
|
+
if (changedProperties.has('_showYearDropdown') && this._showYearDropdown) {
|
|
311
|
+
// Scroll selected year into view
|
|
312
|
+
this._scrollSelectedYearIntoView();
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
_scrollSelectedYearIntoView() {
|
|
316
|
+
// Wait for next frame to ensure DOM is updated
|
|
317
|
+
requestAnimationFrame(() => {
|
|
318
|
+
const selectedYearButton = this.shadowRoot?.querySelector('.year-option.selected');
|
|
319
|
+
if (selectedYearButton) {
|
|
320
|
+
selectedYearButton.scrollIntoView({
|
|
321
|
+
behavior: 'auto',
|
|
322
|
+
block: 'center',
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
willUpdate(changedProperties) {
|
|
328
|
+
if (changedProperties.has('year') ||
|
|
329
|
+
changedProperties.has('month') ||
|
|
330
|
+
changedProperties.has('selectedDate') ||
|
|
331
|
+
changedProperties.has('selectedRange') ||
|
|
332
|
+
changedProperties.has('disabledDates') ||
|
|
333
|
+
changedProperties.has('locale')) {
|
|
334
|
+
this._updateCalendar();
|
|
335
|
+
}
|
|
336
|
+
if (changedProperties.has('locale')) {
|
|
337
|
+
this._updateMonthNames();
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
_updateCalendar() {
|
|
341
|
+
this._calendarData = generateCalendarMonth(this.year, this.month, this.selectedDate, this.selectedRange, this.disabledDates, this.locale);
|
|
342
|
+
}
|
|
343
|
+
_updateMonthNames() {
|
|
344
|
+
this._monthNames = getMonthNames(this.locale);
|
|
345
|
+
}
|
|
346
|
+
_navigateMonth(delta) {
|
|
347
|
+
const newDate = addMonths(new Date(this.year, this.month), delta);
|
|
348
|
+
this.year = newDate.getFullYear();
|
|
349
|
+
this.month = newDate.getMonth();
|
|
350
|
+
}
|
|
351
|
+
_handlePrevMonth() {
|
|
352
|
+
this._navigateMonth(-1);
|
|
353
|
+
}
|
|
354
|
+
_handleNextMonth() {
|
|
355
|
+
this._navigateMonth(1);
|
|
356
|
+
}
|
|
357
|
+
_handlePrevYear() {
|
|
358
|
+
this.year = this.year - 1;
|
|
359
|
+
}
|
|
360
|
+
_handleNextYear() {
|
|
361
|
+
this.year = this.year + 1;
|
|
362
|
+
}
|
|
363
|
+
_handleMonthClick() {
|
|
364
|
+
this._showMonthDropdown = !this._showMonthDropdown;
|
|
365
|
+
this._showYearDropdown = false;
|
|
366
|
+
}
|
|
367
|
+
_handleYearClick() {
|
|
368
|
+
this._showYearDropdown = !this._showYearDropdown;
|
|
369
|
+
this._showMonthDropdown = false;
|
|
370
|
+
}
|
|
371
|
+
_handleMonthSelect(selectedMonth) {
|
|
372
|
+
this.month = selectedMonth;
|
|
373
|
+
this._showMonthDropdown = false;
|
|
374
|
+
}
|
|
375
|
+
_handleYearSelect(selectedYear) {
|
|
376
|
+
this.year = selectedYear;
|
|
377
|
+
this._showYearDropdown = false;
|
|
378
|
+
}
|
|
379
|
+
_closeDropdowns() {
|
|
380
|
+
this._showMonthDropdown = false;
|
|
381
|
+
this._showYearDropdown = false;
|
|
382
|
+
}
|
|
383
|
+
_handleDocumentKeyDown(event) {
|
|
384
|
+
if (event.key === 'Escape') {
|
|
385
|
+
this._closeDropdowns();
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
_handleDayClick(day) {
|
|
389
|
+
if (day.isDisabled)
|
|
390
|
+
return;
|
|
391
|
+
if (this.rangeSelection) {
|
|
392
|
+
this._handleRangeSelection(day.date);
|
|
393
|
+
}
|
|
394
|
+
else {
|
|
395
|
+
this._handleSingleSelection(day.date);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
_handleSingleSelection(date) {
|
|
399
|
+
if (this.showActions) {
|
|
400
|
+
// Use pending state when actions are enabled
|
|
401
|
+
this._pendingDate = date;
|
|
402
|
+
}
|
|
403
|
+
else {
|
|
404
|
+
// Immediate selection when no actions
|
|
405
|
+
this.selectedDate = date;
|
|
406
|
+
const event = {
|
|
407
|
+
date,
|
|
408
|
+
formattedDate: formatDate(date, this.locale),
|
|
409
|
+
};
|
|
410
|
+
this.dispatchEvent(new CustomEvent('date-select', {
|
|
411
|
+
detail: event,
|
|
412
|
+
bubbles: true,
|
|
413
|
+
composed: true,
|
|
414
|
+
}));
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
_handleRangeSelection(date) {
|
|
418
|
+
if (!this._rangeStart || (this.selectedRange?.start && this.selectedRange?.end)) {
|
|
419
|
+
// Start new range
|
|
420
|
+
this._rangeStart = date;
|
|
421
|
+
const newRange = { start: date, end: null };
|
|
422
|
+
if (this.showActions) {
|
|
423
|
+
// Use pending state when actions are enabled
|
|
424
|
+
this._pendingRange = newRange;
|
|
425
|
+
}
|
|
426
|
+
else {
|
|
427
|
+
this.selectedRange = newRange;
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
else {
|
|
431
|
+
// Complete range
|
|
432
|
+
const start = this._rangeStart;
|
|
433
|
+
const end = date;
|
|
434
|
+
// Ensure start is before end
|
|
435
|
+
const sortedRange = start <= end ? { start, end } : { start: end, end: start };
|
|
436
|
+
this._rangeStart = undefined;
|
|
437
|
+
if (this.showActions) {
|
|
438
|
+
// Use pending state when actions are enabled
|
|
439
|
+
this._pendingRange = sortedRange;
|
|
440
|
+
}
|
|
441
|
+
else {
|
|
442
|
+
// Immediate selection when no actions
|
|
443
|
+
this.selectedRange = sortedRange;
|
|
444
|
+
const event = {
|
|
445
|
+
range: sortedRange,
|
|
446
|
+
formattedRange: {
|
|
447
|
+
start: sortedRange.start ? formatDate(sortedRange.start, this.locale) : null,
|
|
448
|
+
end: sortedRange.end ? formatDate(sortedRange.end, this.locale) : null,
|
|
449
|
+
},
|
|
450
|
+
};
|
|
451
|
+
this.dispatchEvent(new CustomEvent('date-range-select', {
|
|
452
|
+
detail: event,
|
|
453
|
+
bubbles: true,
|
|
454
|
+
composed: true,
|
|
455
|
+
}));
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
_isDateDisabled(date) {
|
|
460
|
+
if (this.minDate && date < this.minDate)
|
|
461
|
+
return true;
|
|
462
|
+
if (this.maxDate && date > this.maxDate)
|
|
463
|
+
return true;
|
|
464
|
+
if (this.disabledDates?.some((disabledDate) => isSameDay(date, disabledDate)))
|
|
465
|
+
return true;
|
|
466
|
+
return false;
|
|
467
|
+
}
|
|
468
|
+
_handleConfirm() {
|
|
469
|
+
if (this.rangeSelection) {
|
|
470
|
+
if (this._pendingRange) {
|
|
471
|
+
this.selectedRange = this._pendingRange;
|
|
472
|
+
const event = {
|
|
473
|
+
range: this._pendingRange,
|
|
474
|
+
formattedRange: {
|
|
475
|
+
start: this._pendingRange.start ? formatDate(this._pendingRange.start, this.locale) : null,
|
|
476
|
+
end: this._pendingRange.end ? formatDate(this._pendingRange.end, this.locale) : null,
|
|
477
|
+
},
|
|
478
|
+
};
|
|
479
|
+
this.dispatchEvent(new CustomEvent('date-range-confirm', {
|
|
480
|
+
detail: event,
|
|
481
|
+
bubbles: true,
|
|
482
|
+
composed: true,
|
|
483
|
+
}));
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
else {
|
|
487
|
+
if (this._pendingDate) {
|
|
488
|
+
this.selectedDate = this._pendingDate;
|
|
489
|
+
const event = {
|
|
490
|
+
date: this._pendingDate,
|
|
491
|
+
formattedDate: formatDate(this._pendingDate, this.locale),
|
|
492
|
+
};
|
|
493
|
+
this.dispatchEvent(new CustomEvent('date-select', {
|
|
494
|
+
detail: event,
|
|
495
|
+
bubbles: true,
|
|
496
|
+
composed: true,
|
|
497
|
+
}));
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
_handleCancel() {
|
|
502
|
+
// Reset pending state
|
|
503
|
+
this._pendingDate = null;
|
|
504
|
+
this._pendingRange = null;
|
|
505
|
+
this._rangeStart = undefined;
|
|
506
|
+
const event = {
|
|
507
|
+
reason: 'user_cancelled',
|
|
508
|
+
};
|
|
509
|
+
this.dispatchEvent(new CustomEvent('date-cancel', {
|
|
510
|
+
detail: event,
|
|
511
|
+
bubbles: true,
|
|
512
|
+
composed: true,
|
|
513
|
+
}));
|
|
514
|
+
}
|
|
515
|
+
_renderNavigation() {
|
|
516
|
+
const monthName = this._monthNames[this.month] || '';
|
|
517
|
+
return html `
|
|
518
|
+
<div class="header">
|
|
519
|
+
<div class="month-year">
|
|
520
|
+
<div class="month-selector">
|
|
521
|
+
${this.showNavigation && !this._showMonthDropdown && !this._showYearDropdown
|
|
522
|
+
? html `
|
|
523
|
+
<ui-icon-button
|
|
524
|
+
class="nav-button month-nav"
|
|
525
|
+
size="xs"
|
|
526
|
+
@click=${this._handlePrevMonth}
|
|
527
|
+
aria-label="Previous month"
|
|
528
|
+
title="Previous month"
|
|
529
|
+
>
|
|
530
|
+
<ui-icon icon="chevronLeft"></ui-icon>
|
|
531
|
+
</ui-icon-button>
|
|
532
|
+
`
|
|
533
|
+
: ''}
|
|
534
|
+
<ui-button
|
|
535
|
+
class="month-button"
|
|
536
|
+
color="text"
|
|
537
|
+
size="xs"
|
|
538
|
+
@click=${this._handleMonthClick}
|
|
539
|
+
aria-label="Select month"
|
|
540
|
+
aria-expanded=${this._showMonthDropdown}
|
|
541
|
+
trailingIcon
|
|
542
|
+
>
|
|
543
|
+
${monthName}
|
|
544
|
+
<ui-icon icon="arrowDropDown" slot="icon"></ui-icon>
|
|
545
|
+
</ui-button>
|
|
546
|
+
${this.showNavigation && !this._showMonthDropdown && !this._showYearDropdown
|
|
547
|
+
? html `
|
|
548
|
+
<ui-icon-button
|
|
549
|
+
class="nav-button month-nav"
|
|
550
|
+
size="xs"
|
|
551
|
+
@click=${this._handleNextMonth}
|
|
552
|
+
aria-label="Next month"
|
|
553
|
+
title="Next month"
|
|
554
|
+
>
|
|
555
|
+
<ui-icon icon="chevronRight"></ui-icon>
|
|
556
|
+
</ui-icon-button>
|
|
557
|
+
`
|
|
558
|
+
: ''}
|
|
559
|
+
</div>
|
|
560
|
+
<div class="year-selector">
|
|
561
|
+
${this.showNavigation && !this._showMonthDropdown && !this._showYearDropdown
|
|
562
|
+
? html `
|
|
563
|
+
<ui-icon-button
|
|
564
|
+
class="nav-button year-nav"
|
|
565
|
+
size="xs"
|
|
566
|
+
@click=${this._handlePrevYear}
|
|
567
|
+
aria-label="Previous year"
|
|
568
|
+
title="Previous year"
|
|
569
|
+
>
|
|
570
|
+
<ui-icon icon="chevronLeft"></ui-icon>
|
|
571
|
+
</ui-icon-button>
|
|
572
|
+
`
|
|
573
|
+
: ''}
|
|
574
|
+
<ui-button
|
|
575
|
+
class="year-button"
|
|
576
|
+
color="text"
|
|
577
|
+
size="xs"
|
|
578
|
+
@click=${this._handleYearClick}
|
|
579
|
+
aria-label="Select year"
|
|
580
|
+
aria-expanded=${this._showYearDropdown}
|
|
581
|
+
trailingIcon
|
|
582
|
+
>
|
|
583
|
+
${this.year}
|
|
584
|
+
<ui-icon icon="arrowDropDown" slot="icon"></ui-icon>
|
|
585
|
+
</ui-button>
|
|
586
|
+
${this.showNavigation && !this._showMonthDropdown && !this._showYearDropdown
|
|
587
|
+
? html `
|
|
588
|
+
<ui-icon-button
|
|
589
|
+
class="nav-button year-nav"
|
|
590
|
+
size="xs"
|
|
591
|
+
@click=${this._handleNextYear}
|
|
592
|
+
aria-label="Next year"
|
|
593
|
+
title="Next year"
|
|
594
|
+
>
|
|
595
|
+
<ui-icon icon="chevronRight"></ui-icon>
|
|
596
|
+
</ui-icon-button>
|
|
597
|
+
`
|
|
598
|
+
: ''}
|
|
599
|
+
</div>
|
|
600
|
+
</div>
|
|
601
|
+
</div>
|
|
602
|
+
`;
|
|
603
|
+
}
|
|
604
|
+
_renderWeekdays() {
|
|
605
|
+
if (!this._calendarData)
|
|
606
|
+
return html ``;
|
|
607
|
+
return html `
|
|
608
|
+
<div class="weekdays">
|
|
609
|
+
${this._calendarData.weekdays.map((weekday) => html `<div class="weekday">${weekday}</div>`)}
|
|
610
|
+
</div>
|
|
611
|
+
`;
|
|
612
|
+
}
|
|
613
|
+
_renderDay(day) {
|
|
614
|
+
const isPendingSelected = this.showActions && this._pendingDate && isSameDay(day.date, this._pendingDate);
|
|
615
|
+
const isPendingRangeStart = this.showActions && this._pendingRange?.start && isSameDay(day.date, this._pendingRange.start);
|
|
616
|
+
const isPendingRangeEnd = this.showActions && this._pendingRange?.end && isSameDay(day.date, this._pendingRange.end);
|
|
617
|
+
const isPendingInRange = this.showActions &&
|
|
618
|
+
this._pendingRange?.start &&
|
|
619
|
+
this._pendingRange?.end &&
|
|
620
|
+
day.date >= this._pendingRange.start &&
|
|
621
|
+
day.date <= this._pendingRange.end &&
|
|
622
|
+
!isPendingRangeStart &&
|
|
623
|
+
!isPendingRangeEnd;
|
|
624
|
+
// Determine button color based on selection state
|
|
625
|
+
let color = 'text';
|
|
626
|
+
if (this.showActions) {
|
|
627
|
+
if (isPendingRangeStart || isPendingRangeEnd || isPendingSelected) {
|
|
628
|
+
color = 'filled';
|
|
629
|
+
}
|
|
630
|
+
else if (isPendingInRange) {
|
|
631
|
+
color = 'text';
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
else {
|
|
635
|
+
if (day.isRangeStart || day.isRangeEnd || day.isSelected) {
|
|
636
|
+
color = 'filled';
|
|
637
|
+
}
|
|
638
|
+
else if (day.isInRange) {
|
|
639
|
+
color = 'text';
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
if (day.isToday && color === 'text') {
|
|
643
|
+
color = 'outlined';
|
|
644
|
+
}
|
|
645
|
+
const classes = {
|
|
646
|
+
'day-cell': true,
|
|
647
|
+
'other-month': !day.isCurrentMonth,
|
|
648
|
+
'today': day.isToday,
|
|
649
|
+
'in-range': this.showActions ? !!isPendingInRange : day.isInRange,
|
|
650
|
+
'range-start': this.showActions ? !!isPendingRangeStart : day.isRangeStart,
|
|
651
|
+
'range-end': this.showActions ? !!isPendingRangeEnd : day.isRangeEnd,
|
|
652
|
+
'has-complete-range': this.showActions
|
|
653
|
+
? !!(this._pendingRange?.start && this._pendingRange?.end)
|
|
654
|
+
: !!(this.selectedRange?.start && this.selectedRange?.end),
|
|
655
|
+
};
|
|
656
|
+
return html `
|
|
657
|
+
<div class=${classMap(classes)}>
|
|
658
|
+
<ui-button
|
|
659
|
+
class="day-button"
|
|
660
|
+
color=${color}
|
|
661
|
+
size="s"
|
|
662
|
+
data-date=${day.date.toISOString().split('T')[0]}
|
|
663
|
+
tabindex=${day.isToday && !(day.isDisabled || this._isDateDisabled(day.date)) ? '0' : '-1'}
|
|
664
|
+
aria-label=${formatDate(day.date, this.locale)}
|
|
665
|
+
@click=${() => this._handleDayClick(day)}
|
|
666
|
+
?disabled=${day.isDisabled || this._isDateDisabled(day.date)}
|
|
667
|
+
>
|
|
668
|
+
${day.date.getDate()}
|
|
669
|
+
</ui-button>
|
|
670
|
+
</div>
|
|
671
|
+
`;
|
|
672
|
+
}
|
|
673
|
+
_renderDays() {
|
|
674
|
+
if (!this._calendarData)
|
|
675
|
+
return html ``;
|
|
676
|
+
return html `<div class="days">${this._calendarData.days.map((day) => this._renderDay(day))}</div>`;
|
|
677
|
+
}
|
|
678
|
+
_renderActions() {
|
|
679
|
+
if (!this.showActions)
|
|
680
|
+
return nothing;
|
|
681
|
+
const hasSelection = this.rangeSelection ? this._pendingRange?.start : this._pendingDate;
|
|
682
|
+
return html `
|
|
683
|
+
<div class="actions">
|
|
684
|
+
<ui-button size="s" color="text" @click=${this._handleCancel}>${this.cancelButtonText}</ui-button>
|
|
685
|
+
<ui-button size="s" color="text" @click=${this._handleConfirm} ?disabled=${!hasSelection}>
|
|
686
|
+
${this.okButtonText}
|
|
687
|
+
</ui-button>
|
|
688
|
+
</div>
|
|
689
|
+
`;
|
|
690
|
+
}
|
|
691
|
+
_renderMonthDropdown() {
|
|
692
|
+
return html `
|
|
693
|
+
<div class="dropdown-view">
|
|
694
|
+
<div class="month-list">
|
|
695
|
+
${this._monthNames.map((monthName, index) => html `
|
|
696
|
+
<ui-button
|
|
697
|
+
class="month-option ${index === this.month ? 'selected' : ''}"
|
|
698
|
+
color=${index === this.month ? 'filled' : 'text'}
|
|
699
|
+
size="s"
|
|
700
|
+
@click=${() => this._handleMonthSelect(index)}
|
|
701
|
+
aria-label=${monthName}
|
|
702
|
+
>
|
|
703
|
+
${monthName}
|
|
704
|
+
</ui-button>
|
|
705
|
+
`)}
|
|
706
|
+
</div>
|
|
707
|
+
</div>
|
|
708
|
+
`;
|
|
709
|
+
}
|
|
710
|
+
_renderYearDropdown() {
|
|
711
|
+
const currentYear = this.year;
|
|
712
|
+
const startYear = currentYear - 50;
|
|
713
|
+
const endYear = currentYear + 50;
|
|
714
|
+
const years = [];
|
|
715
|
+
for (let year = startYear; year <= endYear; year++) {
|
|
716
|
+
years.push(year);
|
|
717
|
+
}
|
|
718
|
+
return html `
|
|
719
|
+
<div class="dropdown-view">
|
|
720
|
+
<div class="year-grid">
|
|
721
|
+
${years.map((year) => html `
|
|
722
|
+
<ui-button
|
|
723
|
+
class="year-option ${year === this.year ? 'selected' : ''}"
|
|
724
|
+
color=${year === this.year ? 'filled' : 'text'}
|
|
725
|
+
size="s"
|
|
726
|
+
@click=${() => this._handleYearSelect(year)}
|
|
727
|
+
aria-label=${year.toString()}
|
|
728
|
+
>
|
|
729
|
+
${year}
|
|
730
|
+
</ui-button>
|
|
731
|
+
`)}
|
|
732
|
+
</div>
|
|
733
|
+
</div>
|
|
734
|
+
`;
|
|
735
|
+
}
|
|
736
|
+
render() {
|
|
737
|
+
// Show dropdown views instead of calendar when dropdowns are open
|
|
738
|
+
if (this._showMonthDropdown) {
|
|
739
|
+
return html `
|
|
740
|
+
<div class="calendar" role="grid" aria-label="Calendar">
|
|
741
|
+
${this._renderNavigation()} ${this._renderMonthDropdown()}
|
|
742
|
+
</div>
|
|
743
|
+
`;
|
|
744
|
+
}
|
|
745
|
+
if (this._showYearDropdown) {
|
|
746
|
+
return html `
|
|
747
|
+
<div class="calendar" role="grid" aria-label="Calendar">
|
|
748
|
+
${this._renderNavigation()} ${this._renderYearDropdown()}
|
|
749
|
+
</div>
|
|
750
|
+
`;
|
|
751
|
+
}
|
|
752
|
+
// Default calendar view
|
|
753
|
+
return html `
|
|
754
|
+
<div class="calendar" role="grid" aria-label="Calendar">
|
|
755
|
+
${this._renderNavigation()} ${this._renderWeekdays()} ${this._renderDays()} ${this._renderActions()}
|
|
756
|
+
</div>
|
|
757
|
+
`;
|
|
758
|
+
}
|
|
759
|
+
constructor() {
|
|
760
|
+
super(...arguments);
|
|
761
|
+
__runInitializers(this, __pendingRange_extraInitializers);
|
|
762
|
+
}
|
|
763
|
+
static {
|
|
764
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
765
|
+
}
|
|
766
|
+
};
|
|
767
|
+
return UiDatePickerCalendar = _classThis;
|
|
768
|
+
})();
|
|
769
|
+
export { UiDatePickerCalendar };
|
|
770
|
+
//# sourceMappingURL=DatePickerCalendar.js.map
|