@3mo/date-time-fields 0.5.12-preview.1 → 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 +19 -141
- 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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AED,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);
|
|
@@ -138,10 +141,10 @@ export class FieldDateTimeBase extends InputFieldComponent {
|
|
|
138
141
|
return html `
|
|
139
142
|
<input
|
|
140
143
|
part='input'
|
|
141
|
-
?readonly=${this.readonly
|
|
144
|
+
?readonly=${this.readonly}
|
|
142
145
|
?required=${this.required}
|
|
143
146
|
?disabled=${this.disabled}
|
|
144
|
-
placeholder=${
|
|
147
|
+
placeholder=${this.placeholder}
|
|
145
148
|
.value=${live(this.inputStringValue || '')}
|
|
146
149
|
@input=${(e) => this.handleInput(this.inputValueToValue(this.inputElement.value || ''), e)}
|
|
147
150
|
@change=${(e) => this.handleChange(this.inputValueToValue(this.inputElement.value || ''), e)}
|
|
@@ -164,25 +167,13 @@ export class FieldDateTimeBase extends InputFieldComponent {
|
|
|
164
167
|
`;
|
|
165
168
|
}
|
|
166
169
|
get popoverContentTemplate() {
|
|
167
|
-
return
|
|
170
|
+
return html `
|
|
168
171
|
<mo-flex id='selector' direction='horizontal' style='height: 100%'>
|
|
169
172
|
${this.dateTemplate}
|
|
170
173
|
${this.timeTemplate}
|
|
171
174
|
</mo-flex>
|
|
172
175
|
`;
|
|
173
176
|
}
|
|
174
|
-
get compactPopoverContentTemplate() {
|
|
175
|
-
return html `
|
|
176
|
-
<mo-flex alignItems='center' ${style({ paddingBlock: '10px' })}>
|
|
177
|
-
<mo-flex direction='horizontal' gap='8px' ${style({ width: 'calc(100% - 20px)' })}>
|
|
178
|
-
${this.monthListTemplate}
|
|
179
|
-
${this.yearListTemplate}
|
|
180
|
-
</mo-flex>
|
|
181
|
-
${this.dayTemplate}
|
|
182
|
-
${this.timeTemplate}
|
|
183
|
-
</mo-flex>
|
|
184
|
-
`;
|
|
185
|
-
}
|
|
186
177
|
get dateTemplate() {
|
|
187
178
|
return html `
|
|
188
179
|
${this.yearListTemplate}
|
|
@@ -191,46 +182,18 @@ export class FieldDateTimeBase extends InputFieldComponent {
|
|
|
191
182
|
`;
|
|
192
183
|
}
|
|
193
184
|
get yearListTemplate() {
|
|
194
|
-
if (this.smQuery.matches) {
|
|
195
|
-
return html `
|
|
196
|
-
<mo-field-year ${style({ width: '80px' })}
|
|
197
|
-
.value=${this.selectedDate?.getFullYear()}
|
|
198
|
-
@change=${(e) => {
|
|
199
|
-
const currentDate = this.selectedDate ?? new DateTime();
|
|
200
|
-
currentDate.setFullYear(e.detail);
|
|
201
|
-
this.handleSelectedDateChange(currentDate, FieldDateTimePrecision.Year);
|
|
202
|
-
}}
|
|
203
|
-
></mo-field-year>
|
|
204
|
-
`;
|
|
205
|
-
}
|
|
206
185
|
return html `
|
|
207
186
|
<mo-year-list
|
|
208
|
-
.navigatingValue=${this
|
|
187
|
+
.navigatingValue=${bind(this, 'navigatingDate')}
|
|
209
188
|
.value=${this.selectedDate}
|
|
210
189
|
@change=${(e) => this.handleSelectedDateChange(e.detail, FieldDateTimePrecision.Year)}
|
|
211
190
|
></mo-year-list>
|
|
212
191
|
`;
|
|
213
192
|
}
|
|
214
193
|
get monthListTemplate() {
|
|
215
|
-
|
|
216
|
-
return html.nothing;
|
|
217
|
-
}
|
|
218
|
-
if (this.smQuery.matches) {
|
|
219
|
-
return html `
|
|
220
|
-
<mo-field-month ${style({ flexGrow: '1' })}
|
|
221
|
-
.navigatingDate=${this.navigatingDate}
|
|
222
|
-
.value=${this.selectedDate?.getMonth()}
|
|
223
|
-
@change=${(e) => {
|
|
224
|
-
const currentDate = this.selectedDate ?? new DateTime();
|
|
225
|
-
currentDate.setMonth(e.detail);
|
|
226
|
-
this.handleSelectedDateChange(currentDate, FieldDateTimePrecision.Month);
|
|
227
|
-
}}
|
|
228
|
-
></mo-field-month>
|
|
229
|
-
`;
|
|
230
|
-
}
|
|
231
|
-
return html `
|
|
194
|
+
return [FieldDateTimePrecision.Year].includes(this.precision) ? html.nothing : html `
|
|
232
195
|
<mo-month-list
|
|
233
|
-
.navigatingValue=${this
|
|
196
|
+
.navigatingValue=${bind(this, 'navigatingDate')}
|
|
234
197
|
.value=${this.selectedDate}
|
|
235
198
|
@change=${(e) => this.handleSelectedDateChange(e.detail, FieldDateTimePrecision.Month)}
|
|
236
199
|
></mo-month-list>
|
|
@@ -240,95 +203,7 @@ export class FieldDateTimeBase extends InputFieldComponent {
|
|
|
240
203
|
return [FieldDateTimePrecision.Year, FieldDateTimePrecision.Month].includes(this.precision) ? html.nothing : this.calendarTemplate;
|
|
241
204
|
}
|
|
242
205
|
get timeTemplate() {
|
|
243
|
-
|
|
244
|
-
return html.nothing;
|
|
245
|
-
}
|
|
246
|
-
if (this.smQuery.matches) {
|
|
247
|
-
const hours = (this.selectedDate ?? this.navigatingDate).getHours();
|
|
248
|
-
const minutes = (this.selectedDate ?? this.navigatingDate).getMinutes();
|
|
249
|
-
const setHours = (hours) => {
|
|
250
|
-
const currentDate = this.selectedDate ?? new DateTime();
|
|
251
|
-
currentDate.setHours(hours);
|
|
252
|
-
this.handleSelectedDateChange(currentDate, FieldDateTimePrecision.Hour);
|
|
253
|
-
};
|
|
254
|
-
const setMinutes = (minutes) => {
|
|
255
|
-
const currentDate = this.selectedDate ?? new DateTime();
|
|
256
|
-
currentDate.setMinutes(minutes);
|
|
257
|
-
this.handleSelectedDateChange(currentDate, FieldDateTimePrecision.Minute);
|
|
258
|
-
};
|
|
259
|
-
return html `
|
|
260
|
-
<mo-flex direction='horizontal' alignItems='center'>
|
|
261
|
-
<mo-flex alignItems='center'>
|
|
262
|
-
<mo-icon-button icon='keyboard_arrow_up'
|
|
263
|
-
${style({ color: 'var(--mo-color-gray)' })}
|
|
264
|
-
@click=${() => setHours(hours - 1)}
|
|
265
|
-
></mo-icon-button>
|
|
266
|
-
<span contenteditable inputmode='decimal' ${style({ fontSize: '1.5em' })}
|
|
267
|
-
@keydown=${(e) => {
|
|
268
|
-
if (e.key.length === 1 && isNaN(Number(e.key))) {
|
|
269
|
-
e.preventDefault();
|
|
270
|
-
}
|
|
271
|
-
if (e.key === 'Enter') {
|
|
272
|
-
e.target?.blur();
|
|
273
|
-
}
|
|
274
|
-
}}
|
|
275
|
-
@change=${(e) => {
|
|
276
|
-
const textNode = e.target;
|
|
277
|
-
const value = Number(textNode?.innerText);
|
|
278
|
-
if (isNaN(value) || value < 0 || value > 23) {
|
|
279
|
-
textNode.innerText = hours.toString();
|
|
280
|
-
}
|
|
281
|
-
else {
|
|
282
|
-
setHours(value);
|
|
283
|
-
}
|
|
284
|
-
}}
|
|
285
|
-
>
|
|
286
|
-
${hours}
|
|
287
|
-
</span>
|
|
288
|
-
<mo-icon-button icon='keyboard_arrow_down'
|
|
289
|
-
${style({ color: 'var(--mo-color-gray)' })}
|
|
290
|
-
@click=${() => setHours(hours + 1)}
|
|
291
|
-
></mo-icon-button>
|
|
292
|
-
</mo-flex>
|
|
293
|
-
|
|
294
|
-
<span ${style({ fontSize: '1.5em' })}>:</span>
|
|
295
|
-
|
|
296
|
-
<mo-flex alignItems='center'>
|
|
297
|
-
<mo-icon-button icon='keyboard_arrow_up'
|
|
298
|
-
${style({ color: 'var(--mo-color-gray)' })}
|
|
299
|
-
@click=${() => setMinutes(minutes - 1)}
|
|
300
|
-
></mo-icon-button>
|
|
301
|
-
<span contenteditable inputmode='decimal' ${style({ fontSize: '1.5em' })}
|
|
302
|
-
@keydown=${(e) => {
|
|
303
|
-
if (e.key.length === 1 && isNaN(Number(e.key))) {
|
|
304
|
-
e.preventDefault();
|
|
305
|
-
}
|
|
306
|
-
if (e.key === 'Enter') {
|
|
307
|
-
e.target?.blur();
|
|
308
|
-
}
|
|
309
|
-
}}
|
|
310
|
-
@change=${(e) => {
|
|
311
|
-
const textNode = e.target;
|
|
312
|
-
const value = Number(textNode?.innerText);
|
|
313
|
-
if (isNaN(value) || value < 0 || value > 59) {
|
|
314
|
-
textNode.innerText = minutes < 10 ? `0${minutes}` : minutes.toString();
|
|
315
|
-
}
|
|
316
|
-
else {
|
|
317
|
-
setMinutes(value);
|
|
318
|
-
}
|
|
319
|
-
}}
|
|
320
|
-
>
|
|
321
|
-
${minutes < 10 ? `0${minutes}` : minutes}
|
|
322
|
-
</span>
|
|
323
|
-
<mo-icon-button icon='keyboard_arrow_down'
|
|
324
|
-
${style({ color: 'var(--mo-color-gray)' })}
|
|
325
|
-
@click=${() => setMinutes(minutes + 1)}
|
|
326
|
-
></mo-icon-button>
|
|
327
|
-
</mo-flex>
|
|
328
|
-
</mo-flex>
|
|
329
|
-
`;
|
|
330
|
-
}
|
|
331
|
-
return html `
|
|
206
|
+
return [FieldDateTimePrecision.Year, FieldDateTimePrecision.Month, FieldDateTimePrecision.Day].includes(this.precision) ? html.nothing : html `
|
|
332
207
|
<mo-flex gap='6px'>
|
|
333
208
|
<div class='timezone'>
|
|
334
209
|
${this.navigatingDate?.formatToParts({ timeZoneName: 'long' }).find(x => x.type === 'timeZoneName')?.value}
|
|
@@ -345,7 +220,7 @@ export class FieldDateTimeBase extends InputFieldComponent {
|
|
|
345
220
|
get hourListTemplate() {
|
|
346
221
|
return html `
|
|
347
222
|
<mo-hour-list style='flex: 1'
|
|
348
|
-
.navigatingValue=${this
|
|
223
|
+
.navigatingValue=${bind(this, 'navigatingDate')}
|
|
349
224
|
.value=${this.selectedDate}
|
|
350
225
|
@change=${(e) => this.handleSelectedDateChange(e.detail, FieldDateTimePrecision.Hour)}
|
|
351
226
|
></mo-hour-list>
|
|
@@ -354,7 +229,7 @@ export class FieldDateTimeBase extends InputFieldComponent {
|
|
|
354
229
|
get minuteListTemplate() {
|
|
355
230
|
return [FieldDateTimePrecision.Hour].includes(this.precision) ? html.nothing : html `
|
|
356
231
|
<mo-minute-list style='flex: 1'
|
|
357
|
-
.navigatingValue=${this
|
|
232
|
+
.navigatingValue=${bind(this, 'navigatingDate')}
|
|
358
233
|
.value=${this.selectedDate}
|
|
359
234
|
@change=${(e) => this.handleSelectedDateChange(e.detail, FieldDateTimePrecision.Minute)}
|
|
360
235
|
></mo-minute-list>
|
|
@@ -363,7 +238,7 @@ export class FieldDateTimeBase extends InputFieldComponent {
|
|
|
363
238
|
get secondListTemplate() {
|
|
364
239
|
return [FieldDateTimePrecision.Hour, FieldDateTimePrecision.Minute].includes(this.precision) ? html.nothing : html `
|
|
365
240
|
<mo-second-list style='flex: 1'
|
|
366
|
-
.navigatingValue=${this
|
|
241
|
+
.navigatingValue=${bind(this, 'navigatingDate')}
|
|
367
242
|
.value=${this.selectedDate}
|
|
368
243
|
@change=${(e) => this.handleSelectedDateChange(e.detail, FieldDateTimePrecision.Second)}
|
|
369
244
|
></mo-second-list>
|
|
@@ -398,3 +273,6 @@ __decorate([
|
|
|
398
273
|
__decorate([
|
|
399
274
|
property()
|
|
400
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,MA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9B,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>
|