@3mo/date-time-fields 0.5.12-preview.2 → 0.6.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.
- package/dist/FieldDateTime.d.ts +1 -1
- package/dist/FieldDateTime.d.ts.map +1 -1
- package/dist/FieldDateTime.js +3 -1
- package/dist/FieldDateTimeBase.d.ts +4 -4
- package/dist/FieldDateTimeBase.d.ts.map +1 -1
- package/dist/FieldDateTimeBase.js +20 -178
- package/dist/FieldDateTimeRange.d.ts +1 -1
- package/dist/FieldDateTimeRange.d.ts.map +1 -1
- package/dist/FieldDateTimeRange.js +9 -6
- package/dist/custom-elements.json +2319 -8
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/selection/DateList.d.ts +10 -7
- package/dist/selection/DateList.d.ts.map +1 -1
- package/dist/selection/DateList.js +68 -27
- package/dist/selection/HourList.d.ts.map +1 -1
- package/dist/selection/HourList.js +2 -1
- package/dist/selection/MinuteList.d.ts.map +1 -1
- package/dist/selection/MinuteList.js +2 -1
- package/dist/selection/MonthList.d.ts.map +1 -1
- package/dist/selection/MonthList.js +2 -1
- package/dist/selection/SecondList.d.ts.map +1 -1
- package/dist/selection/SecondList.js +2 -1
- package/dist/selection/YearList.js +2 -2
- package/dist/selection/calendar/Calendar.d.ts.map +1 -1
- package/dist/selection/calendar/Calendar.js +36 -21
- package/dist/selection/calendar/SelectableRangeCalendar.d.ts.map +1 -1
- package/dist/selection/calendar/SelectableRangeCalendar.js +23 -22
- package/dist/selection/index.d.ts +0 -2
- package/dist/selection/index.d.ts.map +1 -1
- package/dist/selection/index.js +0 -2
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/dist/selection/FieldSelectMonth.d.ts +0 -17
- package/dist/selection/FieldSelectMonth.d.ts.map +0 -1
- package/dist/selection/FieldSelectMonth.js +0 -54
- package/dist/selection/FieldSelectYear.d.ts +0 -18
- package/dist/selection/FieldSelectYear.d.ts.map +0 -1
- package/dist/selection/FieldSelectYear.js +0 -52
package/dist/FieldDateTime.d.ts
CHANGED
|
@@ -5,11 +5,11 @@ import { FieldDateTimeBase, FieldDateTimePrecision } from './FieldDateTimeBase.j
|
|
|
5
5
|
* @i18n "Date & Time"
|
|
6
6
|
*/
|
|
7
7
|
export declare class FieldDateTime extends FieldDateTimeBase<Date | undefined> {
|
|
8
|
-
protected get navigatingDate(): import("@3mo/date-time/DateTime.js").DateTime;
|
|
9
8
|
protected get selectedDate(): import("@3mo/date-time/DateTime.js").DateTime | undefined;
|
|
10
9
|
label: string;
|
|
11
10
|
value?: Date;
|
|
12
11
|
protected get placeholder(): string;
|
|
12
|
+
protected resetNavigatingDate(): void;
|
|
13
13
|
protected get calendarTemplate(): import("lit-html").HTMLTemplateResult;
|
|
14
14
|
protected handleSelectedDateChange(date: DateTime, precision: FieldDateTimePrecision): void;
|
|
15
15
|
protected valueToInputValue(value: Date | undefined): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldDateTime.d.ts","sourceRoot":"","sources":["../FieldDateTime.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAA;AAOlF;;;;GAIG;AACH,qBACa,aAAc,SAAQ,iBAAiB,CAAC,IAAI,GAAG,SAAS,CAAC;IACrE,SAAS,KAAK,
|
|
1
|
+
{"version":3,"file":"FieldDateTime.d.ts","sourceRoot":"","sources":["../FieldDateTime.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAA;AAOlF;;;;GAIG;AACH,qBACa,aAAc,SAAQ,iBAAiB,CAAC,IAAI,GAAG,SAAS,CAAC;IACrE,SAAS,KAAK,YAAY,8DAA+D;IAEpE,KAAK,SAAmB;IACjB,KAAK,CAAC,EAAE,IAAI,CAAA;IAExC,cACuB,WAAW,WAEjC;IAED,SAAS,CAAC,mBAAmB;IAI7B,SAAS,KAAK,gBAAgB,0CAQ7B;cAEkB,wBAAwB,CAAC,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,sBAAsB;IAK7F,SAAS,CAAC,iBAAiB,CAAC,KAAK,EAAE,IAAI,GAAG,SAAS;IAInD,SAAS,CAAC,iBAAiB,CAAC,KAAK,EAAE,MAAM;CAGzC;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,oBAAoB,EAAE,aAAa,CAAA;KACnC;CACD"}
|
package/dist/FieldDateTime.js
CHANGED
|
@@ -16,11 +16,13 @@ let FieldDateTime = class FieldDateTime extends FieldDateTimeBase {
|
|
|
16
16
|
super(...arguments);
|
|
17
17
|
this.label = t('Date & Time');
|
|
18
18
|
}
|
|
19
|
-
get navigatingDate() { return this.value ? new DateTime(this.value) : new DateTime(); }
|
|
20
19
|
get selectedDate() { return this.value ? new DateTime(this.value) : undefined; }
|
|
21
20
|
get placeholder() {
|
|
22
21
|
return new DateTime().format(this.formatOptions);
|
|
23
22
|
}
|
|
23
|
+
resetNavigatingDate() {
|
|
24
|
+
this.navigatingDate = this.selectedDate ?? new DateTime();
|
|
25
|
+
}
|
|
24
26
|
get calendarTemplate() {
|
|
25
27
|
return html `
|
|
26
28
|
<mo-selectable-calendar
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type HTMLTemplateResult } from '@a11d/lit';
|
|
2
2
|
import { InputFieldComponent } from '@3mo/field';
|
|
3
|
-
import type
|
|
3
|
+
import { type MaterialIcon } from '@3mo/icon';
|
|
4
4
|
export declare enum FieldDateTimePrecision {
|
|
5
5
|
Year = "year",
|
|
6
6
|
Month = "month",
|
|
@@ -20,14 +20,15 @@ export declare abstract class FieldDateTimeBase<T> extends InputFieldComponent<T
|
|
|
20
20
|
pickerHidden: boolean;
|
|
21
21
|
shortcutReferenceDate: import("@3mo/date-time/DateTime.js").DateTime;
|
|
22
22
|
precision: FieldDateTimePrecision;
|
|
23
|
-
|
|
23
|
+
navigatingDate: import("@3mo/date-time/DateTime.js").DateTime;
|
|
24
24
|
private lastValue?;
|
|
25
25
|
protected readonly calendarIconButtonIcon: MaterialIcon;
|
|
26
|
-
protected abstract get navigatingDate(): DateTime;
|
|
27
26
|
protected abstract get selectedDate(): DateTime | undefined;
|
|
28
27
|
protected get formatOptions(): Intl.DateTimeFormatOptions;
|
|
29
28
|
protected floorToPrecision(date: DateTime): import("@3mo/date-time/DateTime.js").DateTime;
|
|
30
29
|
protected ceilToPrecision(date: DateTime): import("@3mo/date-time/DateTime.js").DateTime;
|
|
30
|
+
protected valueUpdated(): void;
|
|
31
|
+
protected abstract resetNavigatingDate(): void;
|
|
31
32
|
protected handleChange(value?: T, e?: Event): void;
|
|
32
33
|
protected get isActive(): boolean;
|
|
33
34
|
protected get placeholder(): string;
|
|
@@ -40,7 +41,6 @@ export declare abstract class FieldDateTimeBase<T> extends InputFieldComponent<T
|
|
|
40
41
|
protected get calendarIconButtonTemplate(): HTMLTemplateResult;
|
|
41
42
|
protected get popoverTemplate(): HTMLTemplateResult;
|
|
42
43
|
protected get popoverContentTemplate(): HTMLTemplateResult;
|
|
43
|
-
protected get compactPopoverContentTemplate(): HTMLTemplateResult;
|
|
44
44
|
protected get dateTemplate(): HTMLTemplateResult;
|
|
45
45
|
private get yearListTemplate();
|
|
46
46
|
private get monthListTemplate();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldDateTimeBase.d.ts","sourceRoot":"","sources":["../FieldDateTimeBase.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,kBAAkB,
|
|
1
|
+
{"version":3,"file":"FieldDateTimeBase.d.ts","sourceRoot":"","sources":["../FieldDateTimeBase.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,kBAAkB,EAAwD,MAAM,WAAW,CAAA;AACzG,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAChD,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,WAAW,CAAA;AAE7C,oBAAY,sBAAsB;IACjC,IAAI,SAAS;IACb,KAAK,UAAU;IACf,GAAG,QAAQ;IACX,IAAI,SAAS;IACb,MAAM,WAAW;IACjB,MAAM,WAAW;CACjB;AAcD;;;;;GAKG;AACH,8BAAsB,iBAAiB,CAAC,CAAC,CAAE,SAAQ,mBAAmB,CAAC,CAAC,CAAC;IAWrE,IAAI,UAAQ;IACc,YAAY,UAAQ;IACrB,qBAAqB,gDAAe;IACpD,SAAS,yBAAgC;IAE5C,cAAc,gDAAiB;IAExC,OAAO,CAAC,SAAS,CAAC,CAAG;IAErB,SAAS,CAAC,QAAQ,CAAC,sBAAsB,EAAE,YAAY,CAAU;IAEjE,SAAS,CAAC,QAAQ,KAAK,YAAY,IAAI,QAAQ,GAAG,SAAS,CAAA;IAE3D,SAAS,KAAK,aAAa,IAAI,IAAI,CAAC,qBAAqB,CAYxD;IAED,SAAS,CAAC,gBAAgB,CAAC,IAAI,EAAE,QAAQ;IAWzC,SAAS,CAAC,eAAe,CAAC,IAAI,EAAE,QAAQ;cAWrB,YAAY;IAK/B,SAAS,CAAC,QAAQ,CAAC,mBAAmB,IAAI,IAAI;cAE3B,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK;IAKpD,cAAuB,QAAQ,YAE9B;IAED,SAAS,KAAK,WAAW,WAExB;IAED,WAAoB,MAAM,kCAwCzB;IAED,cAAuB,QAAQ,uBAK9B;IAED,cAAuB,eAAe,uBAKrC;IAED,cAAuB,aAAa,uBAanC;IAED,SAAS,CAAC,QAAQ,CAAC,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;uBACtC,iBAAiB,CAAC,KAAK,EAAE,CAAC,GAAG,SAAS,GAAG,MAAM;IAE3E,SAAS,KAAK,0BAA0B,uBAOvC;IAED,SAAS,KAAK,eAAe,uBAM5B;IAED,SAAS,KAAK,sBAAsB,uBAOnC;IAED,SAAS,KAAK,YAAY,uBAMzB;IAED,OAAO,KAAK,gBAAgB,GAQ3B;IAED,OAAO,KAAK,iBAAiB,GAQ5B;IAED,OAAO,KAAK,WAAW,GAEtB;IAED,SAAS,CAAC,QAAQ,KAAK,gBAAgB,IAAI,kBAAkB,CAAA;IAE7D,OAAO,KAAK,YAAY,GAcvB;IAED,OAAO,KAAK,gBAAgB,GAQ3B;IAED,OAAO,KAAK,kBAAkB,GAQ7B;IAED,OAAO,KAAK,kBAAkB,GAQ7B;IAED,SAAS,CAAC,wBAAwB,CAAC,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,sBAAsB;CAKpF"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
-
import { cache, css, html, live, property, style, bind,
|
|
3
|
-
import { MediaQueryController } from '@3mo/media-query-observer';
|
|
2
|
+
import { cache, css, html, live, property, style, bind, state } from '@a11d/lit';
|
|
4
3
|
import { InputFieldComponent } from '@3mo/field';
|
|
5
4
|
export var FieldDateTimePrecision;
|
|
6
5
|
(function (FieldDateTimePrecision) {
|
|
@@ -35,7 +34,7 @@ export class FieldDateTimeBase extends InputFieldComponent {
|
|
|
35
34
|
this.pickerHidden = false;
|
|
36
35
|
this.shortcutReferenceDate = new DateTime;
|
|
37
36
|
this.precision = FieldDateTimePrecision.Minute;
|
|
38
|
-
this.
|
|
37
|
+
this.navigatingDate = new DateTime();
|
|
39
38
|
this.calendarIconButtonIcon = 'today';
|
|
40
39
|
}
|
|
41
40
|
get formatOptions() {
|
|
@@ -71,6 +70,10 @@ export class FieldDateTimeBase extends InputFieldComponent {
|
|
|
71
70
|
.with({ day: isDateTimePrecisionSmaller(this.precision, FieldDateTimePrecision.Day) ? date.daysInMonth : date.day })
|
|
72
71
|
.with({ hour: isDateTimePrecisionSmaller(this.precision, FieldDateTimePrecision.Hour) ? date.hoursInDay : date.hour });
|
|
73
72
|
}
|
|
73
|
+
valueUpdated() {
|
|
74
|
+
super.valueUpdated();
|
|
75
|
+
this.resetNavigatingDate();
|
|
76
|
+
}
|
|
74
77
|
handleChange(value, e) {
|
|
75
78
|
super.handleChange(value, e);
|
|
76
79
|
this.inputStringValue = this.valueToInputValue(value);
|
|
@@ -120,22 +123,6 @@ export class FieldDateTimeBase extends InputFieldComponent {
|
|
|
120
123
|
mo-field[active]:not([dense]) input::placeholder {
|
|
121
124
|
color: var(--mo-color-gray);
|
|
122
125
|
}
|
|
123
|
-
|
|
124
|
-
@media (width <= 576px) {
|
|
125
|
-
mo-popover {
|
|
126
|
-
left: 0 !important;
|
|
127
|
-
bottom: 0 !important;
|
|
128
|
-
top: unset !important;
|
|
129
|
-
right: unset !important;
|
|
130
|
-
width: 100% !important;
|
|
131
|
-
border-radius: 12px 12px 0 0;
|
|
132
|
-
|
|
133
|
-
mo-selectable-calendar,
|
|
134
|
-
mo-selectable-range-calendar {
|
|
135
|
-
--mo-calendar-day-size: calc((100vw - 20px) / 7);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
126
|
`;
|
|
140
127
|
}
|
|
141
128
|
get template() {
|
|
@@ -154,10 +141,10 @@ export class FieldDateTimeBase extends InputFieldComponent {
|
|
|
154
141
|
return html `
|
|
155
142
|
<input
|
|
156
143
|
part='input'
|
|
157
|
-
?readonly=${this.readonly
|
|
144
|
+
?readonly=${this.readonly}
|
|
158
145
|
?required=${this.required}
|
|
159
146
|
?disabled=${this.disabled}
|
|
160
|
-
placeholder=${
|
|
147
|
+
placeholder=${this.placeholder}
|
|
161
148
|
.value=${live(this.inputStringValue || '')}
|
|
162
149
|
@input=${(e) => this.handleInput(this.inputValueToValue(this.inputElement.value || ''), e)}
|
|
163
150
|
@change=${(e) => this.handleChange(this.inputValueToValue(this.inputElement.value || ''), e)}
|
|
@@ -173,52 +160,20 @@ export class FieldDateTimeBase extends InputFieldComponent {
|
|
|
173
160
|
`;
|
|
174
161
|
}
|
|
175
162
|
get popoverTemplate() {
|
|
176
|
-
|
|
177
|
-
return html.nothing;
|
|
178
|
-
}
|
|
179
|
-
if (this.smQuery.matches) {
|
|
180
|
-
return html `
|
|
181
|
-
<mo-popover tabindex='-1' fixed .anchor=${this} ?open=${bind(this, 'open')}>
|
|
182
|
-
<mo-flex>
|
|
183
|
-
<mo-icon-button icon='close'
|
|
184
|
-
${style({ color: 'var(--mo-color-gray)', margin: '12px 16px -8px auto' })}
|
|
185
|
-
@click=${() => {
|
|
186
|
-
this.pickerHidden = true;
|
|
187
|
-
this.open = false;
|
|
188
|
-
setTimeout(() => this.pickerHidden = false, 0);
|
|
189
|
-
}}
|
|
190
|
-
></mo-icon-button>
|
|
191
|
-
${cache(!this.open ? html.nothing : this.popoverContentTemplate)}
|
|
192
|
-
</mo-flex>
|
|
193
|
-
</mo-popover>
|
|
194
|
-
`;
|
|
195
|
-
}
|
|
196
|
-
return html `
|
|
163
|
+
return this.pickerHidden ? html.nothing : html `
|
|
197
164
|
<mo-popover tabindex='-1' fixed .anchor=${this} ?open=${bind(this, 'open')}>
|
|
198
165
|
${cache(!this.open ? html.nothing : this.popoverContentTemplate)}
|
|
199
166
|
</mo-popover>
|
|
200
167
|
`;
|
|
201
168
|
}
|
|
202
169
|
get popoverContentTemplate() {
|
|
203
|
-
return
|
|
170
|
+
return html `
|
|
204
171
|
<mo-flex id='selector' direction='horizontal' style='height: 100%'>
|
|
205
172
|
${this.dateTemplate}
|
|
206
173
|
${this.timeTemplate}
|
|
207
174
|
</mo-flex>
|
|
208
175
|
`;
|
|
209
176
|
}
|
|
210
|
-
get compactPopoverContentTemplate() {
|
|
211
|
-
return html `
|
|
212
|
-
<mo-flex alignItems='center' ${style({ paddingBlock: '10px' })}>
|
|
213
|
-
<mo-flex direction='horizontal' gap='8px' ${style({ width: 'calc(100% - 20px)' })}>
|
|
214
|
-
${this.monthListTemplate}
|
|
215
|
-
${this.yearListTemplate}
|
|
216
|
-
</mo-flex>
|
|
217
|
-
${this.dayTemplate}
|
|
218
|
-
${this.timeTemplate}
|
|
219
|
-
</mo-flex>
|
|
220
|
-
`;
|
|
221
|
-
}
|
|
222
177
|
get dateTemplate() {
|
|
223
178
|
return html `
|
|
224
179
|
${this.yearListTemplate}
|
|
@@ -227,46 +182,18 @@ export class FieldDateTimeBase extends InputFieldComponent {
|
|
|
227
182
|
`;
|
|
228
183
|
}
|
|
229
184
|
get yearListTemplate() {
|
|
230
|
-
if (this.smQuery.matches) {
|
|
231
|
-
return html `
|
|
232
|
-
<mo-field-year ${style({ width: '80px' })}
|
|
233
|
-
.value=${this.selectedDate?.getFullYear()}
|
|
234
|
-
@change=${(e) => {
|
|
235
|
-
const currentDate = this.selectedDate ?? new DateTime();
|
|
236
|
-
currentDate.setFullYear(e.detail);
|
|
237
|
-
this.handleSelectedDateChange(currentDate, FieldDateTimePrecision.Year);
|
|
238
|
-
}}
|
|
239
|
-
></mo-field-year>
|
|
240
|
-
`;
|
|
241
|
-
}
|
|
242
185
|
return html `
|
|
243
186
|
<mo-year-list
|
|
244
|
-
.navigatingValue=${this
|
|
187
|
+
.navigatingValue=${bind(this, 'navigatingDate')}
|
|
245
188
|
.value=${this.selectedDate}
|
|
246
189
|
@change=${(e) => this.handleSelectedDateChange(e.detail, FieldDateTimePrecision.Year)}
|
|
247
190
|
></mo-year-list>
|
|
248
191
|
`;
|
|
249
192
|
}
|
|
250
193
|
get monthListTemplate() {
|
|
251
|
-
|
|
252
|
-
return html.nothing;
|
|
253
|
-
}
|
|
254
|
-
if (this.smQuery.matches) {
|
|
255
|
-
return html `
|
|
256
|
-
<mo-field-month ${style({ flexGrow: '1' })}
|
|
257
|
-
.navigatingDate=${this.navigatingDate}
|
|
258
|
-
.value=${this.selectedDate?.getMonth()}
|
|
259
|
-
@change=${(e) => {
|
|
260
|
-
const currentDate = this.selectedDate ?? new DateTime();
|
|
261
|
-
currentDate.setMonth(e.detail);
|
|
262
|
-
this.handleSelectedDateChange(currentDate, FieldDateTimePrecision.Month);
|
|
263
|
-
}}
|
|
264
|
-
></mo-field-month>
|
|
265
|
-
`;
|
|
266
|
-
}
|
|
267
|
-
return html `
|
|
194
|
+
return [FieldDateTimePrecision.Year].includes(this.precision) ? html.nothing : html `
|
|
268
195
|
<mo-month-list
|
|
269
|
-
.navigatingValue=${this
|
|
196
|
+
.navigatingValue=${bind(this, 'navigatingDate')}
|
|
270
197
|
.value=${this.selectedDate}
|
|
271
198
|
@change=${(e) => this.handleSelectedDateChange(e.detail, FieldDateTimePrecision.Month)}
|
|
272
199
|
></mo-month-list>
|
|
@@ -276,95 +203,7 @@ export class FieldDateTimeBase extends InputFieldComponent {
|
|
|
276
203
|
return [FieldDateTimePrecision.Year, FieldDateTimePrecision.Month].includes(this.precision) ? html.nothing : this.calendarTemplate;
|
|
277
204
|
}
|
|
278
205
|
get timeTemplate() {
|
|
279
|
-
|
|
280
|
-
return html.nothing;
|
|
281
|
-
}
|
|
282
|
-
if (this.smQuery.matches) {
|
|
283
|
-
const hours = (this.selectedDate ?? this.navigatingDate).getHours();
|
|
284
|
-
const minutes = (this.selectedDate ?? this.navigatingDate).getMinutes();
|
|
285
|
-
const setHours = (hours) => {
|
|
286
|
-
const currentDate = this.selectedDate ?? new DateTime();
|
|
287
|
-
currentDate.setHours(hours);
|
|
288
|
-
this.handleSelectedDateChange(currentDate, FieldDateTimePrecision.Hour);
|
|
289
|
-
};
|
|
290
|
-
const setMinutes = (minutes) => {
|
|
291
|
-
const currentDate = this.selectedDate ?? new DateTime();
|
|
292
|
-
currentDate.setMinutes(minutes);
|
|
293
|
-
this.handleSelectedDateChange(currentDate, FieldDateTimePrecision.Minute);
|
|
294
|
-
};
|
|
295
|
-
return html `
|
|
296
|
-
<mo-flex direction='horizontal' alignItems='center'>
|
|
297
|
-
<mo-flex alignItems='center'>
|
|
298
|
-
<mo-icon-button icon='keyboard_arrow_up'
|
|
299
|
-
${style({ color: 'var(--mo-color-gray)' })}
|
|
300
|
-
@click=${() => setHours(hours - 1)}
|
|
301
|
-
></mo-icon-button>
|
|
302
|
-
<span contenteditable inputmode='decimal' ${style({ fontSize: '1.5em' })}
|
|
303
|
-
@keydown=${(e) => {
|
|
304
|
-
if (e.key.length === 1 && isNaN(Number(e.key))) {
|
|
305
|
-
e.preventDefault();
|
|
306
|
-
}
|
|
307
|
-
if (e.key === 'Enter') {
|
|
308
|
-
e.target?.blur();
|
|
309
|
-
}
|
|
310
|
-
}}
|
|
311
|
-
@change=${(e) => {
|
|
312
|
-
const textNode = e.target;
|
|
313
|
-
const value = Number(textNode?.innerText);
|
|
314
|
-
if (isNaN(value) || value < 0 || value > 23) {
|
|
315
|
-
textNode.innerText = hours.toString();
|
|
316
|
-
}
|
|
317
|
-
else {
|
|
318
|
-
setHours(value);
|
|
319
|
-
}
|
|
320
|
-
}}
|
|
321
|
-
>
|
|
322
|
-
${hours}
|
|
323
|
-
</span>
|
|
324
|
-
<mo-icon-button icon='keyboard_arrow_down'
|
|
325
|
-
${style({ color: 'var(--mo-color-gray)' })}
|
|
326
|
-
@click=${() => setHours(hours + 1)}
|
|
327
|
-
></mo-icon-button>
|
|
328
|
-
</mo-flex>
|
|
329
|
-
|
|
330
|
-
<span ${style({ fontSize: '1.5em' })}>:</span>
|
|
331
|
-
|
|
332
|
-
<mo-flex alignItems='center'>
|
|
333
|
-
<mo-icon-button icon='keyboard_arrow_up'
|
|
334
|
-
${style({ color: 'var(--mo-color-gray)' })}
|
|
335
|
-
@click=${() => setMinutes(minutes - 1)}
|
|
336
|
-
></mo-icon-button>
|
|
337
|
-
<span contenteditable inputmode='decimal' ${style({ fontSize: '1.5em' })}
|
|
338
|
-
@keydown=${(e) => {
|
|
339
|
-
if (e.key.length === 1 && isNaN(Number(e.key))) {
|
|
340
|
-
e.preventDefault();
|
|
341
|
-
}
|
|
342
|
-
if (e.key === 'Enter') {
|
|
343
|
-
e.target?.blur();
|
|
344
|
-
}
|
|
345
|
-
}}
|
|
346
|
-
@change=${(e) => {
|
|
347
|
-
const textNode = e.target;
|
|
348
|
-
const value = Number(textNode?.innerText);
|
|
349
|
-
if (isNaN(value) || value < 0 || value > 59) {
|
|
350
|
-
textNode.innerText = minutes < 10 ? `0${minutes}` : minutes.toString();
|
|
351
|
-
}
|
|
352
|
-
else {
|
|
353
|
-
setMinutes(value);
|
|
354
|
-
}
|
|
355
|
-
}}
|
|
356
|
-
>
|
|
357
|
-
${minutes < 10 ? `0${minutes}` : minutes}
|
|
358
|
-
</span>
|
|
359
|
-
<mo-icon-button icon='keyboard_arrow_down'
|
|
360
|
-
${style({ color: 'var(--mo-color-gray)' })}
|
|
361
|
-
@click=${() => setMinutes(minutes + 1)}
|
|
362
|
-
></mo-icon-button>
|
|
363
|
-
</mo-flex>
|
|
364
|
-
</mo-flex>
|
|
365
|
-
`;
|
|
366
|
-
}
|
|
367
|
-
return html `
|
|
206
|
+
return [FieldDateTimePrecision.Year, FieldDateTimePrecision.Month, FieldDateTimePrecision.Day].includes(this.precision) ? html.nothing : html `
|
|
368
207
|
<mo-flex gap='6px'>
|
|
369
208
|
<div class='timezone'>
|
|
370
209
|
${this.navigatingDate?.formatToParts({ timeZoneName: 'long' }).find(x => x.type === 'timeZoneName')?.value}
|
|
@@ -381,7 +220,7 @@ export class FieldDateTimeBase extends InputFieldComponent {
|
|
|
381
220
|
get hourListTemplate() {
|
|
382
221
|
return html `
|
|
383
222
|
<mo-hour-list style='flex: 1'
|
|
384
|
-
.navigatingValue=${this
|
|
223
|
+
.navigatingValue=${bind(this, 'navigatingDate')}
|
|
385
224
|
.value=${this.selectedDate}
|
|
386
225
|
@change=${(e) => this.handleSelectedDateChange(e.detail, FieldDateTimePrecision.Hour)}
|
|
387
226
|
></mo-hour-list>
|
|
@@ -390,7 +229,7 @@ export class FieldDateTimeBase extends InputFieldComponent {
|
|
|
390
229
|
get minuteListTemplate() {
|
|
391
230
|
return [FieldDateTimePrecision.Hour].includes(this.precision) ? html.nothing : html `
|
|
392
231
|
<mo-minute-list style='flex: 1'
|
|
393
|
-
.navigatingValue=${this
|
|
232
|
+
.navigatingValue=${bind(this, 'navigatingDate')}
|
|
394
233
|
.value=${this.selectedDate}
|
|
395
234
|
@change=${(e) => this.handleSelectedDateChange(e.detail, FieldDateTimePrecision.Minute)}
|
|
396
235
|
></mo-minute-list>
|
|
@@ -399,7 +238,7 @@ export class FieldDateTimeBase extends InputFieldComponent {
|
|
|
399
238
|
get secondListTemplate() {
|
|
400
239
|
return [FieldDateTimePrecision.Hour, FieldDateTimePrecision.Minute].includes(this.precision) ? html.nothing : html `
|
|
401
240
|
<mo-second-list style='flex: 1'
|
|
402
|
-
.navigatingValue=${this
|
|
241
|
+
.navigatingValue=${bind(this, 'navigatingDate')}
|
|
403
242
|
.value=${this.selectedDate}
|
|
404
243
|
@change=${(e) => this.handleSelectedDateChange(e.detail, FieldDateTimePrecision.Second)}
|
|
405
244
|
></mo-second-list>
|
|
@@ -434,3 +273,6 @@ __decorate([
|
|
|
434
273
|
__decorate([
|
|
435
274
|
property()
|
|
436
275
|
], FieldDateTimeBase.prototype, "precision", void 0);
|
|
276
|
+
__decorate([
|
|
277
|
+
state()
|
|
278
|
+
], FieldDateTimeBase.prototype, "navigatingDate", void 0);
|
|
@@ -15,11 +15,11 @@ declare enum FieldDateRangeSelection {
|
|
|
15
15
|
* @i18n "End"
|
|
16
16
|
*/
|
|
17
17
|
export declare class FieldDateTimeRange extends FieldDateTimeBase<DateTimeRange | undefined> {
|
|
18
|
-
protected get navigatingDate(): import("@3mo/date-time/DateTime.js").DateTime;
|
|
19
18
|
protected get selectedDate(): import("@3mo/date-time/DateTime.js").DateTime | undefined;
|
|
20
19
|
label: string;
|
|
21
20
|
selection: FieldDateRangeSelection;
|
|
22
21
|
value?: DateTimeRange;
|
|
22
|
+
protected resetNavigatingDate(): void;
|
|
23
23
|
static get styles(): import("@a11d/lit").CSSResult;
|
|
24
24
|
protected calendarIconButtonIcon: MaterialIcon;
|
|
25
25
|
protected get placeholder(): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldDateTimeRange.d.ts","sourceRoot":"","sources":["../FieldDateTimeRange.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,WAAW,CAAA;AAC7C,OAAO,EAAE,iBAAiB,IAAI,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAA;AAWvG,aAAK,uBAAuB;IAC3B,KAAK,UAAU;IACf,GAAG,QAAQ;CACX;AAED;;;;;;;;;GASG;AACH,qBACa,kBAAmB,SAAQ,iBAAiB,CAAC,aAAa,GAAG,SAAS,CAAC;IACnF,SAAS,KAAK,
|
|
1
|
+
{"version":3,"file":"FieldDateTimeRange.d.ts","sourceRoot":"","sources":["../FieldDateTimeRange.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,WAAW,CAAA;AAC7C,OAAO,EAAE,iBAAiB,IAAI,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAA;AAWvG,aAAK,uBAAuB;IAC3B,KAAK,UAAU;IACf,GAAG,QAAQ;CACX;AAED;;;;;;;;;GASG;AACH,qBACa,kBAAmB,SAAQ,iBAAiB,CAAC,aAAa,GAAG,SAAS,CAAC;IACnF,SAAS,KAAK,YAAY,8DAAoG;IAEzG,KAAK,SAAc;IAC5B,SAAS,0BAAgC;IACzB,KAAK,CAAC,EAAE,aAAa,CAAA;IAEjD,SAAS,CAAC,mBAAmB;IAM7B,WAAoB,MAAM,kCAiBzB;IAED,UAAmB,sBAAsB,EAAE,YAAY,CAAe;IAEtE,cACuB,WAAW,WAEjC;IAED,SAAS,KAAK,gBAAgB,0CAQ7B;IAED,cAAuB,sBAAsB,0CAK5C;IAED,SAAS,KAAK,sBAAsB,0CAInC;IAED,OAAO,KAAK,sBAAsB,GASjC;IAEQ,wBAAwB,CAAC,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,sBAAsB;IAcnF,SAAS,CAAC,iBAAiB,CAAC,KAAK,EAAE,aAAa,GAAG,SAAS;cAIzC,iBAAiB,CAAC,KAAK,EAAE,MAAM;CAGlD;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,0BAA0B,EAAE,kBAAkB,CAAA;KAC9C;CACD"}
|
|
@@ -31,8 +31,12 @@ let FieldDateTimeRange = class FieldDateTimeRange extends FieldDateTimeBase {
|
|
|
31
31
|
this.selection = FieldDateRangeSelection.Start;
|
|
32
32
|
this.calendarIconButtonIcon = 'date_range';
|
|
33
33
|
}
|
|
34
|
-
get navigatingDate() { return (this.selection === FieldDateRangeSelection.Start ? this.value?.start : this.value?.end) ?? new DateTime(); }
|
|
35
34
|
get selectedDate() { return this.selection === FieldDateRangeSelection.Start ? this.value?.start : this.value?.end; }
|
|
35
|
+
resetNavigatingDate() {
|
|
36
|
+
this.navigatingDate = this.selection === FieldDateRangeSelection.Start
|
|
37
|
+
? this.value?.start ?? this.navigatingDate
|
|
38
|
+
: this.value?.end ?? this.navigatingDate;
|
|
39
|
+
}
|
|
36
40
|
static get styles() {
|
|
37
41
|
return css `
|
|
38
42
|
${super.styles}
|
|
@@ -45,10 +49,9 @@ let FieldDateTimeRange = class FieldDateTimeRange extends FieldDateTimeBase {
|
|
|
45
49
|
|
|
46
50
|
mo-tab {
|
|
47
51
|
--mdc-tab-height: 40px;
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
opacity: 0.5;
|
|
52
|
+
&:not([active]) {
|
|
53
|
+
opacity: 0.5;
|
|
54
|
+
}
|
|
52
55
|
}
|
|
53
56
|
`;
|
|
54
57
|
}
|
|
@@ -78,7 +81,7 @@ let FieldDateTimeRange = class FieldDateTimeRange extends FieldDateTimeBase {
|
|
|
78
81
|
get startEndTabBarTemplate() {
|
|
79
82
|
return html `
|
|
80
83
|
<mo-flex>
|
|
81
|
-
<mo-tab-bar ${bind(this, 'selection')}>
|
|
84
|
+
<mo-tab-bar ${bind(this, 'selection', { sourceUpdated: () => this.resetNavigatingDate() })}>
|
|
82
85
|
<mo-tab value=${FieldDateRangeSelection.Start}>${t('Start')}</mo-tab>
|
|
83
86
|
<mo-tab value=${FieldDateRangeSelection.End}>${t('End')}</mo-tab>
|
|
84
87
|
</mo-tab-bar>
|