@3mo/date-time-fields 0.10.0 → 0.10.2
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/FieldDate.d.ts +1 -1
- package/dist/FieldDate.d.ts.map +1 -1
- package/dist/FieldDate.js +2 -8
- package/dist/FieldDateRange.d.ts +1 -1
- package/dist/FieldDateRange.d.ts.map +1 -1
- package/dist/FieldDateRange.js +2 -5
- package/dist/FieldDateTime.d.ts +2 -1
- package/dist/FieldDateTime.d.ts.map +1 -1
- package/dist/FieldDateTime.js +14 -5
- package/dist/FieldDateTimeBase.d.ts +1 -10
- package/dist/FieldDateTimeBase.d.ts.map +1 -1
- package/dist/FieldDateTimeBase.js +9 -54
- package/dist/FieldDateTimePrecision.d.ts +20 -0
- package/dist/FieldDateTimePrecision.d.ts.map +1 -0
- package/dist/FieldDateTimePrecision.js +47 -0
- package/dist/FieldDateTimeRange.d.ts +2 -1
- package/dist/FieldDateTimeRange.d.ts.map +1 -1
- package/dist/FieldDateTimeRange.js +12 -10
- package/dist/FieldToggleableDateTimeRange.d.ts +1 -1
- package/dist/FieldToggleableDateTimeRange.d.ts.map +1 -1
- package/dist/FieldToggleableDateTimeRange.js +2 -2
- package/dist/custom-elements.json +42 -108
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/selection/calendar/Calendar.d.ts +9 -5
- package/dist/selection/calendar/Calendar.d.ts.map +1 -1
- package/dist/selection/calendar/Calendar.js +52 -37
- package/dist/selection/calendar/SelectableCalendar.d.ts +6 -5
- package/dist/selection/calendar/SelectableCalendar.d.ts.map +1 -1
- package/dist/selection/calendar/SelectableCalendar.js +52 -16
- package/dist/selection/calendar/index.d.ts +0 -1
- package/dist/selection/calendar/index.d.ts.map +1 -1
- package/dist/selection/calendar/index.js +0 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/dist/selection/calendar/SelectableRangeCalendar.d.ts +0 -22
- package/dist/selection/calendar/SelectableRangeCalendar.d.ts.map +0 -1
- package/dist/selection/calendar/SelectableRangeCalendar.js +0 -70
package/dist/FieldDate.d.ts
CHANGED
package/dist/FieldDate.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldDate.d.ts","sourceRoot":"","sources":["../FieldDate.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,sBAAsB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"FieldDate.d.ts","sourceRoot":"","sources":["../FieldDate.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AAMpE;;;;GAIG;AACH,qBACa,SAAU,SAAQ,aAAa;IAClC,SAAS,yBAA6B;IACtC,KAAK,SAAY;CAC1B;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,eAAe,EAAE,aAAa,CAAA;KAC9B;CACD"}
|
package/dist/FieldDate.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
-
import { component
|
|
2
|
+
import { component } from '@a11d/lit';
|
|
3
3
|
import { Localizer } from '@3mo/localization';
|
|
4
4
|
import { FieldDateTime } from './FieldDateTime.js';
|
|
5
|
-
import { FieldDateTimePrecision } from './
|
|
5
|
+
import { FieldDateTimePrecision } from './FieldDateTimePrecision.js';
|
|
6
6
|
Localizer.dictionaries.add('de', {
|
|
7
7
|
'Date': 'Datum',
|
|
8
8
|
});
|
|
@@ -18,12 +18,6 @@ let FieldDate = class FieldDate extends FieldDateTime {
|
|
|
18
18
|
this.label = t('Date');
|
|
19
19
|
}
|
|
20
20
|
};
|
|
21
|
-
__decorate([
|
|
22
|
-
property()
|
|
23
|
-
], FieldDate.prototype, "precision", void 0);
|
|
24
|
-
__decorate([
|
|
25
|
-
property()
|
|
26
|
-
], FieldDate.prototype, "label", void 0);
|
|
27
21
|
FieldDate = __decorate([
|
|
28
22
|
component('mo-field-date')
|
|
29
23
|
], FieldDate);
|
package/dist/FieldDateRange.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FieldDateTimePrecision } from './
|
|
1
|
+
import { FieldDateTimePrecision } from './FieldDateTimePrecision.js';
|
|
2
2
|
import { FieldDateTimeRange } from './FieldDateTimeRange.js';
|
|
3
3
|
/** @element mo-field-date */
|
|
4
4
|
export declare class FieldDateRange extends FieldDateTimeRange {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldDateRange.d.ts","sourceRoot":"","sources":["../FieldDateRange.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"FieldDateRange.d.ts","sourceRoot":"","sources":["../FieldDateRange.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AACpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAE5D,6BAA6B;AAC7B,qBACa,cAAe,SAAQ,kBAAkB;IAC5C,SAAS,yBAA6B;CAC/C;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,qBAAqB,EAAE,cAAc,CAAA;KACrC;CACD"}
|
package/dist/FieldDateRange.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
-
import { component
|
|
3
|
-
import { FieldDateTimePrecision } from './
|
|
2
|
+
import { component } from '@a11d/lit';
|
|
3
|
+
import { FieldDateTimePrecision } from './FieldDateTimePrecision.js';
|
|
4
4
|
import { FieldDateTimeRange } from './FieldDateTimeRange.js';
|
|
5
5
|
/** @element mo-field-date */
|
|
6
6
|
let FieldDateRange = class FieldDateRange extends FieldDateTimeRange {
|
|
@@ -9,9 +9,6 @@ let FieldDateRange = class FieldDateRange extends FieldDateTimeRange {
|
|
|
9
9
|
this.precision = FieldDateTimePrecision.Day;
|
|
10
10
|
}
|
|
11
11
|
};
|
|
12
|
-
__decorate([
|
|
13
|
-
property()
|
|
14
|
-
], FieldDateRange.prototype, "precision", void 0);
|
|
15
12
|
FieldDateRange = __decorate([
|
|
16
13
|
component('mo-field-date-range')
|
|
17
14
|
], FieldDateRange);
|
package/dist/FieldDateTime.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldDateTime.d.ts","sourceRoot":"","sources":["../FieldDateTime.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"FieldDateTime.d.ts","sourceRoot":"","sources":["../FieldDateTime.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AAOpE;;;;GAIG;AACH,qBACa,aAAc,SAAQ,iBAAiB,CAAC,IAAI,GAAG,SAAS,CAAC;IACrE,SAAS,KAAK,YAAY,8DAQzB;IAEoB,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
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { component, html, property } from '@a11d/lit';
|
|
3
3
|
import { Localizer } from '@3mo/localization';
|
|
4
|
-
import { FieldDateTimeBase
|
|
4
|
+
import { FieldDateTimeBase } from './FieldDateTimeBase.js';
|
|
5
|
+
import { FieldDateTimePrecision } from './FieldDateTimePrecision.js';
|
|
5
6
|
import { Memoize as memoize } from 'typescript-memoize';
|
|
6
7
|
Localizer.dictionaries.add('de', {
|
|
7
8
|
'Date & Time': 'Datum & Uhrzeit',
|
|
@@ -16,7 +17,15 @@ let FieldDateTime = class FieldDateTime extends FieldDateTimeBase {
|
|
|
16
17
|
super(...arguments);
|
|
17
18
|
this.label = t('Date & Time');
|
|
18
19
|
}
|
|
19
|
-
get selectedDate() {
|
|
20
|
+
get selectedDate() {
|
|
21
|
+
if (!this.value) {
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
if (this.value instanceof Date) {
|
|
25
|
+
return new DateTime(this.value);
|
|
26
|
+
}
|
|
27
|
+
return this.value;
|
|
28
|
+
}
|
|
20
29
|
get placeholder() {
|
|
21
30
|
return new DateTime().format(this.formatOptions);
|
|
22
31
|
}
|
|
@@ -27,13 +36,13 @@ let FieldDateTime = class FieldDateTime extends FieldDateTimeBase {
|
|
|
27
36
|
return html `
|
|
28
37
|
<mo-selectable-calendar
|
|
29
38
|
.navigatingValue=${this.navigatingDate}
|
|
30
|
-
.value=${this.selectedDate}
|
|
31
|
-
@
|
|
39
|
+
.value=${new DateTimeRange(this.selectedDate, this.selectedDate)}
|
|
40
|
+
@dayClick=${(e) => this.handleSelectedDateChange(e.detail, FieldDateTimePrecision.Day)}
|
|
32
41
|
></mo-selectable-calendar>
|
|
33
42
|
`;
|
|
34
43
|
}
|
|
35
44
|
handleSelectedDateChange(date, precision) {
|
|
36
|
-
this.value = !date ? undefined : this.
|
|
45
|
+
this.value = !date ? undefined : this.precision.getRange(date).start;
|
|
37
46
|
super.handleSelectedDateChange(date, precision);
|
|
38
47
|
}
|
|
39
48
|
valueToInputValue(value) {
|
|
@@ -1,14 +1,7 @@
|
|
|
1
1
|
import { type HTMLTemplateResult } from '@a11d/lit';
|
|
2
2
|
import { InputFieldComponent } from '@3mo/field';
|
|
3
3
|
import { type MaterialIcon } from '@3mo/icon';
|
|
4
|
-
|
|
5
|
-
Year = "year",
|
|
6
|
-
Month = "month",
|
|
7
|
-
Day = "day",
|
|
8
|
-
Hour = "hour",
|
|
9
|
-
Minute = "minute",
|
|
10
|
-
Second = "second"
|
|
11
|
-
}
|
|
4
|
+
import { FieldDateTimePrecision } from './FieldDateTimePrecision.js';
|
|
12
5
|
/**
|
|
13
6
|
* @attr open - Whether the date picker is open
|
|
14
7
|
* @attr pickerHidden - Hide the date picker
|
|
@@ -24,8 +17,6 @@ export declare abstract class FieldDateTimeBase<T> extends InputFieldComponent<T
|
|
|
24
17
|
protected readonly calendarIconButtonIcon: MaterialIcon;
|
|
25
18
|
protected abstract get selectedDate(): DateTime | undefined;
|
|
26
19
|
protected get formatOptions(): Intl.DateTimeFormatOptions;
|
|
27
|
-
protected floorToPrecision(date: DateTime): import("@3mo/date-time/DateTime.js").DateTime;
|
|
28
|
-
protected ceilToPrecision(date: DateTime): import("@3mo/date-time/DateTime.js").DateTime;
|
|
29
20
|
protected valueUpdated(): void;
|
|
30
21
|
protected abstract resetNavigatingDate(): void;
|
|
31
22
|
protected handleChange(value?: T, e?: Event): void;
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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;AAC7C,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AAEpE;;;;;GAKG;AACH,8BAAsB,iBAAiB,CAAC,CAAC,CAAE,SAAQ,mBAAmB,CAAC,CAAC,CAAC;IAC5B,IAAI,UAAQ;IAC3B,YAAY,UAAQ;IACrB,qBAAqB,gDAAe;IACkC,SAAS,yBAAgC;IAElI,cAAc,gDAAiB;IAExC,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,CAMxD;cAEkB,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,kCA8CzB;IAED,cAAuB,QAAQ,uBAK9B;IAED,cAAuB,eAAe,uBAMrC;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,OAAO,KAAK,uBAAuB,GAYlC;IAED,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;CAMpF"}
|
|
@@ -1,26 +1,7 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { cache, css, html, live, property, style, bind, state } from '@a11d/lit';
|
|
3
3
|
import { InputFieldComponent } from '@3mo/field';
|
|
4
|
-
|
|
5
|
-
(function (FieldDateTimePrecision) {
|
|
6
|
-
FieldDateTimePrecision["Year"] = "year";
|
|
7
|
-
FieldDateTimePrecision["Month"] = "month";
|
|
8
|
-
FieldDateTimePrecision["Day"] = "day";
|
|
9
|
-
FieldDateTimePrecision["Hour"] = "hour";
|
|
10
|
-
FieldDateTimePrecision["Minute"] = "minute";
|
|
11
|
-
FieldDateTimePrecision["Second"] = "second";
|
|
12
|
-
})(FieldDateTimePrecision || (FieldDateTimePrecision = {}));
|
|
13
|
-
function isDateTimePrecisionSmaller(precision, other) {
|
|
14
|
-
const precisions = [
|
|
15
|
-
FieldDateTimePrecision.Year,
|
|
16
|
-
FieldDateTimePrecision.Month,
|
|
17
|
-
FieldDateTimePrecision.Day,
|
|
18
|
-
FieldDateTimePrecision.Hour,
|
|
19
|
-
FieldDateTimePrecision.Minute,
|
|
20
|
-
FieldDateTimePrecision.Second,
|
|
21
|
-
];
|
|
22
|
-
return precisions.indexOf(precision) < precisions.indexOf(other);
|
|
23
|
-
}
|
|
4
|
+
import { FieldDateTimePrecision } from './FieldDateTimePrecision.js';
|
|
24
5
|
/**
|
|
25
6
|
* @attr open - Whether the date picker is open
|
|
26
7
|
* @attr pickerHidden - Hide the date picker
|
|
@@ -41,35 +22,9 @@ export class FieldDateTimeBase extends InputFieldComponent {
|
|
|
41
22
|
return {
|
|
42
23
|
calendar: this.selectedDate?.calendarId,
|
|
43
24
|
timeZone: this.selectedDate?.timeZoneId,
|
|
44
|
-
|
|
45
|
-
month: isDateTimePrecisionSmaller(this.precision, FieldDateTimePrecision.Month) ? undefined : '2-digit',
|
|
46
|
-
day: isDateTimePrecisionSmaller(this.precision, FieldDateTimePrecision.Day) ? undefined : '2-digit',
|
|
47
|
-
hour: isDateTimePrecisionSmaller(this.precision, FieldDateTimePrecision.Hour) ? undefined : '2-digit',
|
|
48
|
-
minute: isDateTimePrecisionSmaller(this.precision, FieldDateTimePrecision.Minute) ? undefined : '2-digit',
|
|
49
|
-
second: isDateTimePrecisionSmaller(this.precision, FieldDateTimePrecision.Second) ? undefined : '2-digit',
|
|
50
|
-
hourCycle: 'h23',
|
|
25
|
+
...this.precision.formatOptions,
|
|
51
26
|
};
|
|
52
27
|
}
|
|
53
|
-
floorToPrecision(date) {
|
|
54
|
-
return date.with({
|
|
55
|
-
year: date.year,
|
|
56
|
-
month: isDateTimePrecisionSmaller(this.precision, FieldDateTimePrecision.Month) ? 1 : date.month,
|
|
57
|
-
day: isDateTimePrecisionSmaller(this.precision, FieldDateTimePrecision.Day) ? 1 : date.day,
|
|
58
|
-
hour: isDateTimePrecisionSmaller(this.precision, FieldDateTimePrecision.Hour) ? 0 : date.hour,
|
|
59
|
-
minute: isDateTimePrecisionSmaller(this.precision, FieldDateTimePrecision.Minute) ? 0 : date.minute,
|
|
60
|
-
second: isDateTimePrecisionSmaller(this.precision, FieldDateTimePrecision.Second) ? 0 : date.second,
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
ceilToPrecision(date) {
|
|
64
|
-
return date.with({
|
|
65
|
-
year: date.year,
|
|
66
|
-
minute: isDateTimePrecisionSmaller(this.precision, FieldDateTimePrecision.Minute) ? 60 : date.minute,
|
|
67
|
-
second: isDateTimePrecisionSmaller(this.precision, FieldDateTimePrecision.Second) ? 60 : date.second,
|
|
68
|
-
})
|
|
69
|
-
.with({ month: isDateTimePrecisionSmaller(this.precision, FieldDateTimePrecision.Month) ? date.monthsInYear : date.month })
|
|
70
|
-
.with({ day: isDateTimePrecisionSmaller(this.precision, FieldDateTimePrecision.Day) ? date.daysInMonth : date.day })
|
|
71
|
-
.with({ hour: isDateTimePrecisionSmaller(this.precision, FieldDateTimePrecision.Hour) ? date.hoursInDay : date.hour });
|
|
72
|
-
}
|
|
73
28
|
valueUpdated() {
|
|
74
29
|
super.valueUpdated();
|
|
75
30
|
this.resetNavigatingDate();
|
|
@@ -211,7 +166,7 @@ export class FieldDateTimeBase extends InputFieldComponent {
|
|
|
211
166
|
`;
|
|
212
167
|
}
|
|
213
168
|
get monthListTemplate() {
|
|
214
|
-
return
|
|
169
|
+
return this.precision < FieldDateTimePrecision.Month ? html.nothing : html `
|
|
215
170
|
<mo-month-list
|
|
216
171
|
.navigatingValue=${bind(this, 'navigatingDate')}
|
|
217
172
|
.value=${this.selectedDate}
|
|
@@ -220,10 +175,10 @@ export class FieldDateTimeBase extends InputFieldComponent {
|
|
|
220
175
|
`;
|
|
221
176
|
}
|
|
222
177
|
get dayTemplate() {
|
|
223
|
-
return
|
|
178
|
+
return this.precision < FieldDateTimePrecision.Day ? html.nothing : this.calendarTemplate;
|
|
224
179
|
}
|
|
225
180
|
get timeTemplate() {
|
|
226
|
-
return
|
|
181
|
+
return this.precision <= FieldDateTimePrecision.Day ? html.nothing : html `
|
|
227
182
|
<mo-flex gap='6px'>
|
|
228
183
|
<div class='timezone'>
|
|
229
184
|
${this.navigatingDate?.formatToParts({ timeZoneName: 'long' }).find(x => x.type === 'timeZoneName')?.value}
|
|
@@ -238,7 +193,7 @@ export class FieldDateTimeBase extends InputFieldComponent {
|
|
|
238
193
|
`;
|
|
239
194
|
}
|
|
240
195
|
get hourListTemplate() {
|
|
241
|
-
return html `
|
|
196
|
+
return this.precision < FieldDateTimePrecision.Hour ? html.nothing : html `
|
|
242
197
|
<mo-hour-list style='flex: 1'
|
|
243
198
|
.navigatingValue=${bind(this, 'navigatingDate')}
|
|
244
199
|
.value=${this.selectedDate}
|
|
@@ -247,7 +202,7 @@ export class FieldDateTimeBase extends InputFieldComponent {
|
|
|
247
202
|
`;
|
|
248
203
|
}
|
|
249
204
|
get minuteListTemplate() {
|
|
250
|
-
return
|
|
205
|
+
return this.precision < FieldDateTimePrecision.Minute ? html.nothing : html `
|
|
251
206
|
<mo-minute-list style='flex: 1'
|
|
252
207
|
.navigatingValue=${bind(this, 'navigatingDate')}
|
|
253
208
|
.value=${this.selectedDate}
|
|
@@ -256,7 +211,7 @@ export class FieldDateTimeBase extends InputFieldComponent {
|
|
|
256
211
|
`;
|
|
257
212
|
}
|
|
258
213
|
get secondListTemplate() {
|
|
259
|
-
return
|
|
214
|
+
return this.precision < FieldDateTimePrecision.Second ? html.nothing : html `
|
|
260
215
|
<mo-second-list style='flex: 1'
|
|
261
216
|
.navigatingValue=${bind(this, 'navigatingDate')}
|
|
262
217
|
.value=${this.selectedDate}
|
|
@@ -281,7 +236,7 @@ __decorate([
|
|
|
281
236
|
property({ type: Object })
|
|
282
237
|
], FieldDateTimeBase.prototype, "shortcutReferenceDate", void 0);
|
|
283
238
|
__decorate([
|
|
284
|
-
property()
|
|
239
|
+
property({ type: String, converter: value => FieldDateTimePrecision.parse(value || undefined) })
|
|
285
240
|
], FieldDateTimeBase.prototype, "precision", void 0);
|
|
286
241
|
__decorate([
|
|
287
242
|
state()
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type FieldDateTimePrecisionKey = 'year' | 'month' | 'day' | 'hour' | 'minute' | 'second';
|
|
2
|
+
export declare class FieldDateTimePrecision {
|
|
3
|
+
readonly value: number;
|
|
4
|
+
readonly key: FieldDateTimePrecisionKey;
|
|
5
|
+
private static readonly _all;
|
|
6
|
+
static get all(): ReadonlyArray<FieldDateTimePrecision>;
|
|
7
|
+
static parse(value?: string): FieldDateTimePrecision | undefined;
|
|
8
|
+
static readonly Year: FieldDateTimePrecision;
|
|
9
|
+
static readonly Month: FieldDateTimePrecision;
|
|
10
|
+
static readonly Day: FieldDateTimePrecision;
|
|
11
|
+
static readonly Hour: FieldDateTimePrecision;
|
|
12
|
+
static readonly Minute: FieldDateTimePrecision;
|
|
13
|
+
static readonly Second: FieldDateTimePrecision;
|
|
14
|
+
private constructor();
|
|
15
|
+
get formatOptions(): Intl.DateTimeFormatOptions;
|
|
16
|
+
getRange(date: DateTime): import("@3mo/date-time/DateTimeRange.js").DateTimeRange;
|
|
17
|
+
valueOf(): number;
|
|
18
|
+
toString(): FieldDateTimePrecisionKey;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=FieldDateTimePrecision.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FieldDateTimePrecision.d.ts","sourceRoot":"","sources":["../FieldDateTimePrecision.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,yBAAyB,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,CAAA;AAE/F,qBAAa,sBAAsB;IAgBd,QAAQ,CAAC,KAAK,EAAE,MAAM;IAAE,QAAQ,CAAC,GAAG,EAAE,yBAAyB;IAfnF,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAsC;IAClE,MAAM,KAAK,GAAG,IAA2C,aAAa,CAAC,sBAAsB,CAAC,CAAE;IAEhG,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,sBAAsB,GAAG,SAAS;IAIhE,MAAM,CAAC,QAAQ,CAAC,IAAI,yBAAwC;IAE5D,MAAM,CAAC,QAAQ,CAAC,KAAK,yBAAyC;IAC9D,MAAM,CAAC,QAAQ,CAAC,GAAG,yBAAuC;IAC1D,MAAM,CAAC,QAAQ,CAAC,IAAI,yBAAwC;IAC5D,MAAM,CAAC,QAAQ,CAAC,MAAM,yBAA0C;IAChE,MAAM,CAAC,QAAQ,CAAC,MAAM,yBAA0C;IAEhE,OAAO;IAIP,IAAI,aAAa,IAAI,IAAI,CAAC,qBAAqB,CAU9C;IAED,QAAQ,CAAC,IAAI,EAAE,QAAQ;IAYvB,OAAO;IAIP,QAAQ;CAGR"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export class FieldDateTimePrecision {
|
|
2
|
+
static get all() { return FieldDateTimePrecision._all; }
|
|
3
|
+
static parse(value) {
|
|
4
|
+
return !value ? undefined : this._all.find(precision => precision.key === value);
|
|
5
|
+
}
|
|
6
|
+
constructor(value, key) {
|
|
7
|
+
this.value = value;
|
|
8
|
+
this.key = key;
|
|
9
|
+
FieldDateTimePrecision._all.push(this);
|
|
10
|
+
}
|
|
11
|
+
get formatOptions() {
|
|
12
|
+
return {
|
|
13
|
+
year: 'numeric',
|
|
14
|
+
month: this < FieldDateTimePrecision.Month ? undefined : '2-digit',
|
|
15
|
+
day: this < FieldDateTimePrecision.Day ? undefined : '2-digit',
|
|
16
|
+
hour: this < FieldDateTimePrecision.Hour ? undefined : '2-digit',
|
|
17
|
+
minute: this < FieldDateTimePrecision.Minute ? undefined : '2-digit',
|
|
18
|
+
second: this < FieldDateTimePrecision.Second ? undefined : '2-digit',
|
|
19
|
+
hourCycle: 'h23',
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
getRange(date) {
|
|
23
|
+
const start = date.with({
|
|
24
|
+
year: date.year,
|
|
25
|
+
month: this < FieldDateTimePrecision.Month ? 1 : date.month,
|
|
26
|
+
day: this < FieldDateTimePrecision.Day ? 1 : date.day,
|
|
27
|
+
hour: this < FieldDateTimePrecision.Hour ? 0 : date.hour,
|
|
28
|
+
minute: this < FieldDateTimePrecision.Minute ? 0 : date.minute,
|
|
29
|
+
second: this < FieldDateTimePrecision.Second ? 0 : date.second,
|
|
30
|
+
});
|
|
31
|
+
return new DateTimeRange(start, start.add({ [`${this.key}s`]: 1 }).subtract({ seconds: 1 }));
|
|
32
|
+
}
|
|
33
|
+
valueOf() {
|
|
34
|
+
return this.value;
|
|
35
|
+
}
|
|
36
|
+
toString() {
|
|
37
|
+
return this.key;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
FieldDateTimePrecision._all = new Array();
|
|
41
|
+
FieldDateTimePrecision.Year = new FieldDateTimePrecision(1, 'year');
|
|
42
|
+
// static readonly Week = new FieldDateTimePrecision(2, 'week')
|
|
43
|
+
FieldDateTimePrecision.Month = new FieldDateTimePrecision(3, 'month');
|
|
44
|
+
FieldDateTimePrecision.Day = new FieldDateTimePrecision(4, 'day');
|
|
45
|
+
FieldDateTimePrecision.Hour = new FieldDateTimePrecision(5, 'hour');
|
|
46
|
+
FieldDateTimePrecision.Minute = new FieldDateTimePrecision(6, 'minute');
|
|
47
|
+
FieldDateTimePrecision.Second = new FieldDateTimePrecision(7, 'second');
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type MaterialIcon } from '@3mo/icon';
|
|
2
|
-
import { FieldDateTimeBase as FieldDateTimeBase
|
|
2
|
+
import { FieldDateTimeBase as FieldDateTimeBase } from './FieldDateTimeBase.js';
|
|
3
|
+
import { FieldDateTimePrecision } from './FieldDateTimePrecision.js';
|
|
3
4
|
declare enum FieldDateRangeSelection {
|
|
4
5
|
Start = "start",
|
|
5
6
|
End = "end"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldDateTimeRange.d.ts","sourceRoot":"","sources":["../FieldDateTimeRange.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"FieldDateTimeRange.d.ts","sourceRoot":"","sources":["../FieldDateTimeRange.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,WAAW,CAAA;AAG7C,OAAO,EAAE,iBAAiB,IAAI,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC/E,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AASpE,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,kCAezB;IAED,UAAmB,sBAAsB,EAAE,YAAY,CAAe;IAEtE,cACuB,WAAW,WAEjC;IAED,SAAS,KAAK,gBAAgB,0CAS7B;IAED,cAAuB,sBAAsB,0CAK5C;IAED,SAAS,KAAK,sBAAsB,0CAInC;IAED,OAAO,KAAK,sBAAsB,GASjC;IAEQ,wBAAwB,CAAC,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,sBAAsB;IAenF,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"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { bind, component, css, html, property } from '@a11d/lit';
|
|
3
|
-
import { FieldDateTimeBase as FieldDateTimeBase, FieldDateTimePrecision } from './FieldDateTimeBase.js';
|
|
4
|
-
import { DateRangeParser } from './DateRangeParser.js';
|
|
5
|
-
import { Memoize as memoize } from 'typescript-memoize';
|
|
6
3
|
import { Localizer } from '@3mo/localization';
|
|
4
|
+
import { Memoize as memoize } from 'typescript-memoize';
|
|
5
|
+
import { FieldDateTimeBase as FieldDateTimeBase } from './FieldDateTimeBase.js';
|
|
6
|
+
import { FieldDateTimePrecision } from './FieldDateTimePrecision.js';
|
|
7
|
+
import { DateRangeParser } from './DateRangeParser.js';
|
|
7
8
|
Localizer.dictionaries.add('de', {
|
|
8
9
|
'Period': 'Zeitraum',
|
|
9
10
|
'Start': 'Start',
|
|
@@ -58,12 +59,12 @@ let FieldDateTimeRange = class FieldDateTimeRange extends FieldDateTimeBase {
|
|
|
58
59
|
}
|
|
59
60
|
get calendarTemplate() {
|
|
60
61
|
return html `
|
|
61
|
-
<mo-selectable-
|
|
62
|
+
<mo-selectable-calendar
|
|
62
63
|
data-selection=${this.selection}
|
|
63
64
|
.navigatingValue=${this.navigatingDate}
|
|
64
|
-
.
|
|
65
|
-
@
|
|
66
|
-
></mo-selectable-
|
|
65
|
+
.value=${this.value}
|
|
66
|
+
@dayClick=${(e) => this.handleSelectedDateChange(e.detail, FieldDateTimePrecision.Day)}
|
|
67
|
+
></mo-selectable-calendar>
|
|
67
68
|
`;
|
|
68
69
|
}
|
|
69
70
|
get popoverContentTemplate() {
|
|
@@ -88,9 +89,10 @@ let FieldDateTimeRange = class FieldDateTimeRange extends FieldDateTimeBase {
|
|
|
88
89
|
`;
|
|
89
90
|
}
|
|
90
91
|
handleSelectedDateChange(date, precision) {
|
|
92
|
+
const { start, end } = this.precision.getRange(date);
|
|
91
93
|
this.value = this.selection === FieldDateRangeSelection.Start
|
|
92
|
-
? new DateTimeRange(
|
|
93
|
-
: new DateTimeRange(this.value?.start,
|
|
94
|
+
? new DateTimeRange(start, this.value?.end)
|
|
95
|
+
: new DateTimeRange(this.value?.start, end);
|
|
94
96
|
if (this.precision === precision) {
|
|
95
97
|
this.selection = this.selection === FieldDateRangeSelection.Start
|
|
96
98
|
? FieldDateRangeSelection.End
|
|
@@ -99,7 +101,7 @@ let FieldDateTimeRange = class FieldDateTimeRange extends FieldDateTimeBase {
|
|
|
99
101
|
super.handleSelectedDateChange(date, precision);
|
|
100
102
|
}
|
|
101
103
|
valueToInputValue(value) {
|
|
102
|
-
return value
|
|
104
|
+
return value?.format(this.formatOptions) ?? '';
|
|
103
105
|
}
|
|
104
106
|
inputValueToValue(value) {
|
|
105
107
|
return value ? DateRangeParser.parse(value, this.shortcutReferenceDate) : undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldToggleableDateTimeRange.d.ts","sourceRoot":"","sources":["../FieldToggleableDateTimeRange.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FieldToggleableDateTimeRange.d.ts","sourceRoot":"","sources":["../FieldToggleableDateTimeRange.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AAMpE;;;;GAIG;AACH,qBACa,4BAA6B,SAAQ,kBAAkB;IAC1D,SAAS,yBAA6B;IAE/C,IAAI,WAAW,YAA8D;IAC7E,IAAI,WAAW,CAAC,WAAW,SAAA,EAA+F;IAE1H,cAAuB,sBAAsB,0CAO5C;IAED,OAAO,KAAK,cAAc,GAIzB;CACD"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { bind, component, html } from '@a11d/lit';
|
|
3
|
-
import { FieldDateTimeRange } from './FieldDateTimeRange.js';
|
|
4
|
-
import { FieldDateTimePrecision } from './FieldDateTimeBase.js';
|
|
5
3
|
import { Localizer } from '@3mo/localization';
|
|
4
|
+
import { FieldDateTimeRange } from './FieldDateTimeRange.js';
|
|
5
|
+
import { FieldDateTimePrecision } from './FieldDateTimePrecision.js';
|
|
6
6
|
Localizer.dictionaries.add('de', {
|
|
7
7
|
'Include time': 'Zeitauswahl',
|
|
8
8
|
});
|