@3mo/date-time-fields 0.0.15 → 0.1.1
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/DateParser.js +21 -21
- package/dist/DateRangeParser.js +6 -6
- package/dist/FieldDate.d.ts +5 -15
- package/dist/FieldDate.d.ts.map +1 -1
- package/dist/FieldDate.js +6 -34
- package/dist/FieldDateRange.d.ts +5 -27
- package/dist/FieldDateRange.d.ts.map +1 -1
- package/dist/FieldDateRange.js +7 -113
- package/dist/FieldDateTime.d.ts +17 -0
- package/dist/FieldDateTime.d.ts.map +1 -0
- package/dist/FieldDateTime.js +36 -0
- package/dist/FieldDateTimeBase.d.ts +50 -0
- package/dist/FieldDateTimeBase.d.ts.map +1 -0
- package/dist/FieldDateTimeBase.js +236 -0
- package/dist/FieldDateTimeRange.d.ts +35 -0
- package/dist/FieldDateTimeRange.d.ts.map +1 -0
- package/dist/FieldDateTimeRange.js +91 -0
- package/dist/FieldTime.d.ts.map +1 -1
- package/dist/FieldTime.js +1 -0
- package/dist/index.d.ts +8 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -2
- package/dist/selection/DateList.d.ts +18 -0
- package/dist/selection/DateList.d.ts.map +1 -0
- package/dist/selection/DateList.js +69 -0
- package/dist/selection/HourList.d.ts +10 -0
- package/dist/selection/HourList.d.ts.map +1 -0
- package/dist/selection/HourList.js +23 -0
- package/dist/selection/MinuteList.d.ts +10 -0
- package/dist/selection/MinuteList.d.ts.map +1 -0
- package/dist/selection/MinuteList.js +23 -0
- package/dist/selection/MonthList.d.ts +12 -0
- package/dist/selection/MonthList.d.ts.map +1 -0
- package/dist/selection/MonthList.js +38 -0
- package/dist/selection/SecondList.d.ts +10 -0
- package/dist/selection/SecondList.d.ts.map +1 -0
- package/dist/selection/SecondList.js +23 -0
- package/dist/selection/YearList.d.ts +11 -0
- package/dist/selection/YearList.d.ts.map +1 -0
- package/dist/selection/YearList.js +27 -0
- package/dist/selection/calendar/Calendar.d.ts +18 -0
- package/dist/selection/calendar/Calendar.d.ts.map +1 -0
- package/dist/selection/calendar/Calendar.js +123 -0
- package/dist/selection/calendar/SelectableCalendar.d.ts +18 -0
- package/dist/selection/calendar/SelectableCalendar.d.ts.map +1 -0
- package/dist/selection/calendar/SelectableCalendar.js +34 -0
- package/dist/selection/calendar/SelectableRangeCalendar.d.ts +19 -0
- package/dist/selection/calendar/SelectableRangeCalendar.d.ts.map +1 -0
- package/dist/selection/calendar/SelectableRangeCalendar.js +45 -0
- package/dist/selection/calendar/index.d.ts +4 -0
- package/dist/selection/calendar/index.d.ts.map +1 -0
- package/dist/{calendar → selection/calendar}/index.js +1 -1
- package/dist/selection/index.d.ts +7 -0
- package/dist/selection/index.d.ts.map +1 -0
- package/dist/selection/index.js +6 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +12 -7
- package/dist/FieldDateBase.d.ts +0 -29
- package/dist/FieldDateBase.d.ts.map +0 -1
- package/dist/FieldDateBase.js +0 -111
- package/dist/calendar/Calendar.d.ts +0 -30
- package/dist/calendar/Calendar.d.ts.map +0 -1
- package/dist/calendar/Calendar.js +0 -203
- package/dist/calendar/CalendarSelectionAdapter.d.ts +0 -11
- package/dist/calendar/CalendarSelectionAdapter.d.ts.map +0 -1
- package/dist/calendar/CalendarSelectionAdapter.js +0 -11
- package/dist/calendar/SelectableCalendar.d.ts +0 -17
- package/dist/calendar/SelectableCalendar.d.ts.map +0 -1
- package/dist/calendar/SelectableCalendar.js +0 -35
- package/dist/calendar/index.d.ts +0 -4
- package/dist/calendar/index.d.ts.map +0 -1
package/dist/DateParser.js
CHANGED
|
@@ -43,13 +43,13 @@ export class DateParser {
|
|
|
43
43
|
let num;
|
|
44
44
|
if (!isNaN(Number(lastChar))) {
|
|
45
45
|
num = parseInt(dateText.substring(0, dateText.length));
|
|
46
|
-
return referenceDate.
|
|
46
|
+
return referenceDate.add({ days: num });
|
|
47
47
|
}
|
|
48
48
|
else {
|
|
49
49
|
num = parseInt(dateText.substring(0, dateText.length - 1));
|
|
50
50
|
switch (lastChar) {
|
|
51
|
-
case 'y': return referenceDate.
|
|
52
|
-
case 'm': return referenceDate.
|
|
51
|
+
case 'y': return referenceDate.add({ years: num });
|
|
52
|
+
case 'm': return referenceDate.add({ months: num });
|
|
53
53
|
default: return undefined;
|
|
54
54
|
}
|
|
55
55
|
}
|
|
@@ -63,30 +63,30 @@ export class DateParser {
|
|
|
63
63
|
static parseDateFromKeyword(keyword, referenceDate = new DateTime) {
|
|
64
64
|
switch (keyword) {
|
|
65
65
|
case 'h': return new DateTime(referenceDate);
|
|
66
|
-
case 'üm': return referenceDate.
|
|
67
|
-
case 'm': return referenceDate.
|
|
68
|
-
case 'üüm': return referenceDate.
|
|
69
|
-
case 'g': return referenceDate.
|
|
70
|
-
case 'vg': return referenceDate.
|
|
71
|
-
case 'vvg': return referenceDate.
|
|
66
|
+
case 'üm': return referenceDate.add({ days: +2 });
|
|
67
|
+
case 'm': return referenceDate.add({ days: +1 });
|
|
68
|
+
case 'üüm': return referenceDate.add({ days: +3 });
|
|
69
|
+
case 'g': return referenceDate.add({ days: -1 });
|
|
70
|
+
case 'vg': return referenceDate.add({ days: -2 });
|
|
71
|
+
case 'vvg': return referenceDate.add({ days: -3 });
|
|
72
72
|
case 'adw': return referenceDate.weekStart;
|
|
73
73
|
case 'edw': return referenceDate.weekEnd;
|
|
74
|
-
case 'anw': return referenceDate.
|
|
75
|
-
case 'enw': return referenceDate.
|
|
76
|
-
case 'alw': return referenceDate.
|
|
77
|
-
case 'elw': return referenceDate.
|
|
74
|
+
case 'anw': return referenceDate.add({ weeks: +1 }).weekStart;
|
|
75
|
+
case 'enw': return referenceDate.add({ weeks: +1 }).weekEnd;
|
|
76
|
+
case 'alw': return referenceDate.add({ weeks: -1 }).weekStart;
|
|
77
|
+
case 'elw': return referenceDate.add({ weeks: -1 }).weekEnd;
|
|
78
78
|
case 'adm': return referenceDate.monthStart;
|
|
79
79
|
case 'edm': return referenceDate.monthEnd;
|
|
80
|
-
case 'anm': return referenceDate.
|
|
81
|
-
case 'enm': return referenceDate.
|
|
82
|
-
case 'alm': return referenceDate.
|
|
83
|
-
case 'elm': return referenceDate.
|
|
80
|
+
case 'anm': return referenceDate.add({ months: +1 }).monthStart;
|
|
81
|
+
case 'enm': return referenceDate.add({ months: +1 }).monthEnd;
|
|
82
|
+
case 'alm': return referenceDate.add({ months: -1 }).monthStart;
|
|
83
|
+
case 'elm': return referenceDate.add({ months: -1 }).monthEnd;
|
|
84
84
|
case 'adj': return referenceDate.yearStart;
|
|
85
85
|
case 'edj': return referenceDate.yearEnd;
|
|
86
|
-
case 'anj': return referenceDate.
|
|
87
|
-
case 'enj': return referenceDate.
|
|
88
|
-
case 'alj': return referenceDate.
|
|
89
|
-
case 'elj': return referenceDate.
|
|
86
|
+
case 'anj': return referenceDate.add({ years: +1 }).yearStart;
|
|
87
|
+
case 'enj': return referenceDate.add({ years: +1 }).yearEnd;
|
|
88
|
+
case 'alj': return referenceDate.add({ years: -1 }).yearStart;
|
|
89
|
+
case 'elj': return referenceDate.add({ years: -1 }).yearEnd;
|
|
90
90
|
default: return undefined;
|
|
91
91
|
}
|
|
92
92
|
}
|
package/dist/DateRangeParser.js
CHANGED
|
@@ -19,16 +19,16 @@ class DateRangeParser {
|
|
|
19
19
|
switch (keyword) {
|
|
20
20
|
case 'w':
|
|
21
21
|
case 'dw': return new DateTimeRange(referenceDate.weekStart, referenceDate.weekEnd);
|
|
22
|
-
case 'nw': return new DateTimeRange(referenceDate.
|
|
23
|
-
case 'lw': return new DateTimeRange(referenceDate.
|
|
22
|
+
case 'nw': return new DateTimeRange(referenceDate.add({ weeks: +1 }).weekStart, referenceDate.add({ weeks: +1 }).weekEnd);
|
|
23
|
+
case 'lw': return new DateTimeRange(referenceDate.add({ weeks: -1 }).weekStart, referenceDate.add({ weeks: -1 }).weekEnd);
|
|
24
24
|
case 'm':
|
|
25
25
|
case 'dm': return new DateTimeRange(referenceDate.monthStart, referenceDate.monthEnd);
|
|
26
|
-
case 'lm': return new DateTimeRange(referenceDate.
|
|
27
|
-
case 'nm': return new DateTimeRange(referenceDate.
|
|
26
|
+
case 'lm': return new DateTimeRange(referenceDate.add({ months: -1 }).monthStart, referenceDate.add({ months: -1 }).monthEnd);
|
|
27
|
+
case 'nm': return new DateTimeRange(referenceDate.add({ months: +1 }).monthStart, referenceDate.add({ months: +1 }).monthEnd);
|
|
28
28
|
case 'j':
|
|
29
29
|
case 'dj': return new DateTimeRange(referenceDate.yearStart, referenceDate.yearEnd);
|
|
30
|
-
case 'lj': return new DateTimeRange(referenceDate.
|
|
31
|
-
case 'nj': return new DateTimeRange(referenceDate.
|
|
30
|
+
case 'lj': return new DateTimeRange(referenceDate.add({ years: -1 }).yearStart, referenceDate.add({ years: -1 }).yearEnd);
|
|
31
|
+
case 'nj': return new DateTimeRange(referenceDate.add({ years: +1 }).yearStart, referenceDate.add({ years: +1 }).yearEnd);
|
|
32
32
|
default: return undefined;
|
|
33
33
|
}
|
|
34
34
|
}
|
package/dist/FieldDate.d.ts
CHANGED
|
@@ -1,22 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { FieldDateBase } from './FieldDateBase.js';
|
|
4
|
-
declare class DateCalendarSelectionAdapter extends CalendarSelectionAdapter<DateTime> {
|
|
5
|
-
getDayTemplate(day: DateTime, classInfo: ClassInfo): import("lit-html").TemplateResult<1>;
|
|
6
|
-
getNavigatingDate(value?: DateTime): import("@3mo/date-time/DateTime.js").DateTime;
|
|
7
|
-
}
|
|
1
|
+
import { FieldDateTime } from './FieldDateTime.js';
|
|
2
|
+
import { FieldDateTimePrecision } from './FieldDateTimeBase.js';
|
|
8
3
|
/** @element mo-field-date */
|
|
9
|
-
export declare class FieldDate extends
|
|
10
|
-
|
|
11
|
-
value?: Date;
|
|
12
|
-
protected handleCalendarChange(value?: Date): void;
|
|
13
|
-
protected valueToInputValue(value: Date | undefined): string;
|
|
14
|
-
protected inputValueToValue(value: string): import("@3mo/date-time/DateTime.js").DateTime | undefined;
|
|
4
|
+
export declare class FieldDate extends FieldDateTime {
|
|
5
|
+
precision: FieldDateTimePrecision;
|
|
15
6
|
}
|
|
16
7
|
declare global {
|
|
17
8
|
interface HTMLElementTagNameMap {
|
|
18
|
-
'mo-field-date':
|
|
9
|
+
'mo-field-date': FieldDateTime;
|
|
19
10
|
}
|
|
20
11
|
}
|
|
21
|
-
export {};
|
|
22
12
|
//# sourceMappingURL=FieldDate.d.ts.map
|
package/dist/FieldDate.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldDate.d.ts","sourceRoot":"","sources":["../FieldDate.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FieldDate.d.ts","sourceRoot":"","sources":["../FieldDate.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAA;AAE/D,6BAA6B;AAC7B,qBACa,SAAU,SAAQ,aAAa;IACtB,SAAS,yBAA6B;CAC3D;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,eAAe,EAAE,aAAa,CAAA;KAC9B;CACD"}
|
package/dist/FieldDate.js
CHANGED
|
@@ -1,44 +1,16 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { CalendarSelectionAdapter } from './calendar/index.js';
|
|
5
|
-
import { FieldDateBase } from './FieldDateBase.js';
|
|
6
|
-
class DateCalendarSelectionAdapter extends CalendarSelectionAdapter {
|
|
7
|
-
getDayTemplate(day, classInfo) {
|
|
8
|
-
var _a, _b;
|
|
9
|
-
return html `
|
|
10
|
-
<mo-flex
|
|
11
|
-
class=${classMap(Object.assign(Object.assign({}, classInfo), { selected: (_b = (_a = this.calendar.value) === null || _a === void 0 ? void 0 : _a.equals(day)) !== null && _b !== void 0 ? _b : false }))}
|
|
12
|
-
@click=${() => this.select(day)}
|
|
13
|
-
>${day.format({ day: 'numeric' })}</mo-flex>
|
|
14
|
-
`;
|
|
15
|
-
}
|
|
16
|
-
getNavigatingDate(value) {
|
|
17
|
-
const date = value !== null && value !== void 0 ? value : new DateTime();
|
|
18
|
-
return new DateTime(date.year, date.month);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
2
|
+
import { component, property } from '@a11d/lit';
|
|
3
|
+
import { FieldDateTime } from './FieldDateTime.js';
|
|
21
4
|
/** @element mo-field-date */
|
|
22
|
-
let FieldDate = class FieldDate extends
|
|
5
|
+
let FieldDate = class FieldDate extends FieldDateTime {
|
|
23
6
|
constructor() {
|
|
24
7
|
super(...arguments);
|
|
25
|
-
this.
|
|
26
|
-
}
|
|
27
|
-
handleCalendarChange(value) {
|
|
28
|
-
super.handleCalendarChange(value);
|
|
29
|
-
this.open = false;
|
|
30
|
-
}
|
|
31
|
-
valueToInputValue(value) {
|
|
32
|
-
var _a;
|
|
33
|
-
return value ? (_a = value.formatAsDate()) !== null && _a !== void 0 ? _a : '' : '';
|
|
34
|
-
}
|
|
35
|
-
inputValueToValue(value) {
|
|
36
|
-
return value ? DateParser.parse(value, this.shortcutReferenceDate) : undefined;
|
|
8
|
+
this.precision = "day" /* FieldDateTimePrecision.Day */;
|
|
37
9
|
}
|
|
38
10
|
};
|
|
39
11
|
__decorate([
|
|
40
|
-
property(
|
|
41
|
-
], FieldDate.prototype, "
|
|
12
|
+
property()
|
|
13
|
+
], FieldDate.prototype, "precision", void 0);
|
|
42
14
|
FieldDate = __decorate([
|
|
43
15
|
component('mo-field-date')
|
|
44
16
|
], FieldDate);
|
package/dist/FieldDateRange.d.ts
CHANGED
|
@@ -1,34 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
StartDate = 0,
|
|
7
|
-
EndDate = 1
|
|
8
|
-
}
|
|
9
|
-
declare class DateRangeCalendarSelectionAdapter extends CalendarSelectionAdapter<DateTimeRange> {
|
|
10
|
-
currentSelection: DateRangeCalendarSelectionAdapterCurrentSelection;
|
|
11
|
-
get styles(): import("@a11d/lit").CSSResult;
|
|
12
|
-
getDayTemplate(day: DateTime, classInfo: ClassInfo): import("lit-html").TemplateResult<1>;
|
|
13
|
-
getNavigatingDate(value?: DateTimeRange): import("@3mo/date-time/DateTime.js").DateTime;
|
|
14
|
-
private handleClick;
|
|
15
|
-
}
|
|
16
|
-
/** @element mo-field-date-range */
|
|
17
|
-
export declare class FieldDateRange extends FieldDateBase<DateTimeRange | undefined> {
|
|
18
|
-
private get currentSelection();
|
|
19
|
-
private set currentSelection(value);
|
|
20
|
-
protected calendarSelectionAdapterConstructor: typeof DateRangeCalendarSelectionAdapter;
|
|
21
|
-
value?: DateTimeRange;
|
|
22
|
-
protected calendarIconButtonIcon: MaterialIcon;
|
|
23
|
-
protected handleCalendarChange(value?: DateTimeRange): void;
|
|
24
|
-
protected get calendarTemplate(): import("lit-html").TemplateResult<1>;
|
|
25
|
-
protected valueToInputValue(value: DateTimeRange | undefined): string;
|
|
26
|
-
protected inputValueToValue(value: string): import("@3mo/date-time/DateTimeRange.js").DateTimeRange | undefined;
|
|
1
|
+
import { FieldDateTimePrecision } from './FieldDateTimeBase.js';
|
|
2
|
+
import { FieldDateTimeRange } from './FieldDateTimeRange.js';
|
|
3
|
+
/** @element mo-field-date */
|
|
4
|
+
export declare class FieldDateRange extends FieldDateTimeRange {
|
|
5
|
+
precision: FieldDateTimePrecision;
|
|
27
6
|
}
|
|
28
7
|
declare global {
|
|
29
8
|
interface HTMLElementTagNameMap {
|
|
30
9
|
'mo-field-date-range': FieldDateRange;
|
|
31
10
|
}
|
|
32
11
|
}
|
|
33
|
-
export {};
|
|
34
12
|
//# sourceMappingURL=FieldDateRange.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldDateRange.d.ts","sourceRoot":"","sources":["../FieldDateRange.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FieldDateRange.d.ts","sourceRoot":"","sources":["../FieldDateRange.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAA;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAE5D,6BAA6B;AAC7B,qBACa,cAAe,SAAQ,kBAAkB;IAChC,SAAS,yBAA6B;CAC3D;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,qBAAqB,EAAE,cAAc,CAAA;KACrC;CACD"}
|
package/dist/FieldDateRange.js
CHANGED
|
@@ -1,122 +1,16 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
-
import { component, property
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
class DateRangeCalendarSelectionAdapter extends CalendarSelectionAdapter {
|
|
2
|
+
import { component, property } from '@a11d/lit';
|
|
3
|
+
import { FieldDateTimeRange } from './FieldDateTimeRange.js';
|
|
4
|
+
/** @element mo-field-date */
|
|
5
|
+
let FieldDateRange = class FieldDateRange extends FieldDateTimeRange {
|
|
7
6
|
constructor() {
|
|
8
7
|
super(...arguments);
|
|
9
|
-
this.
|
|
10
|
-
}
|
|
11
|
-
get styles() {
|
|
12
|
-
return css `
|
|
13
|
-
.day.inSelectionRange:not(.selected) {
|
|
14
|
-
background: var(--mo-color-accent-transparent);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
.day.inSelectionRange {
|
|
18
|
-
border-radius: 0px;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
.day.selected.first {
|
|
22
|
-
border-radius: 100px 0 0 100px;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
.day.selected.last {
|
|
26
|
-
border-radius: 0 100px 100px 0;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
.day.selected.first.last {
|
|
30
|
-
border-radius: 100px;
|
|
31
|
-
}
|
|
32
|
-
`;
|
|
33
|
-
}
|
|
34
|
-
getDayTemplate(day, classInfo) {
|
|
35
|
-
const dateRange = this.calendar.value;
|
|
36
|
-
const firstEquals = !(dateRange === null || dateRange === void 0 ? void 0 : dateRange.start) ? false : day.equals(dateRange.start);
|
|
37
|
-
const lastEquals = !(dateRange === null || dateRange === void 0 ? void 0 : dateRange.end) ? false : day.equals(dateRange.end);
|
|
38
|
-
const classes = Object.assign(Object.assign({}, classInfo), { inSelectionRange: !dateRange ? false : dateRange.includes(day), selected: firstEquals || lastEquals, first: firstEquals, last: lastEquals });
|
|
39
|
-
return html `
|
|
40
|
-
<mo-flex
|
|
41
|
-
class=${classMap(classes)}
|
|
42
|
-
@click=${() => this.handleClick(day)}
|
|
43
|
-
>${day.format({ day: 'numeric' })}</mo-flex>
|
|
44
|
-
`;
|
|
45
|
-
}
|
|
46
|
-
getNavigatingDate(value) {
|
|
47
|
-
var _a;
|
|
48
|
-
const date = (_a = value === null || value === void 0 ? void 0 : value.start) !== null && _a !== void 0 ? _a : new DateTime();
|
|
49
|
-
return new DateTime(date.year, date.month);
|
|
50
|
-
}
|
|
51
|
-
handleClick(date) {
|
|
52
|
-
const dateRange = this.calendar.value;
|
|
53
|
-
const shallReset = !!(dateRange === null || dateRange === void 0 ? void 0 : dateRange.start) && !!dateRange.end;
|
|
54
|
-
const value = this.currentSelection === 0 /* DateRangeCalendarSelectionAdapterCurrentSelection.StartDate */
|
|
55
|
-
? new DateTimeRange(date, shallReset ? undefined : dateRange === null || dateRange === void 0 ? void 0 : dateRange.end)
|
|
56
|
-
: new DateTimeRange(shallReset ? undefined : dateRange === null || dateRange === void 0 ? void 0 : dateRange.start, date);
|
|
57
|
-
this.currentSelection = value.start
|
|
58
|
-
? 1 /* DateRangeCalendarSelectionAdapterCurrentSelection.EndDate */
|
|
59
|
-
: 0 /* DateRangeCalendarSelectionAdapterCurrentSelection.StartDate */;
|
|
60
|
-
this.select(value);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
/** @element mo-field-date-range */
|
|
64
|
-
let FieldDateRange = class FieldDateRange extends FieldDateBase {
|
|
65
|
-
constructor() {
|
|
66
|
-
super(...arguments);
|
|
67
|
-
this.calendarSelectionAdapterConstructor = DateRangeCalendarSelectionAdapter;
|
|
68
|
-
this.calendarIconButtonIcon = 'date_range';
|
|
69
|
-
}
|
|
70
|
-
get currentSelection() { var _a, _b, _c; return (_c = (_b = (_a = this.calendarElement) === null || _a === void 0 ? void 0 : _a.selectionAdapter) === null || _b === void 0 ? void 0 : _b.currentSelection) !== null && _c !== void 0 ? _c : 0 /* DateRangeCalendarSelectionAdapterCurrentSelection.StartDate */; }
|
|
71
|
-
set currentSelection(value) {
|
|
72
|
-
var _a;
|
|
73
|
-
const selectionAdapter = (_a = this.calendarElement) === null || _a === void 0 ? void 0 : _a.selectionAdapter;
|
|
74
|
-
if (selectionAdapter) {
|
|
75
|
-
selectionAdapter.currentSelection = value;
|
|
76
|
-
this.requestUpdate();
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
handleCalendarChange(value) {
|
|
80
|
-
super.handleCalendarChange(value);
|
|
81
|
-
if ((value === null || value === void 0 ? void 0 : value.start) && value.end) {
|
|
82
|
-
this.open = false;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
get calendarTemplate() {
|
|
86
|
-
var _a, _b;
|
|
87
|
-
return html `
|
|
88
|
-
<mo-flex>
|
|
89
|
-
<mo-flex direction='horizontal' alignItems='center' ${style({ textAlign: 'center', height: '30px' })}>
|
|
90
|
-
<div ${style({ width: '*', fontWeight: '500', cursor: 'pointer' })}
|
|
91
|
-
${style({ color: this.currentSelection === 0 /* DateRangeCalendarSelectionAdapterCurrentSelection.StartDate */ ? 'var(--mo-color-accent)' : 'unset' })}
|
|
92
|
-
@click=${() => this.currentSelection = 0 /* DateRangeCalendarSelectionAdapterCurrentSelection.StartDate */}
|
|
93
|
-
>${!((_a = this.value) === null || _a === void 0 ? void 0 : _a.start) ? 'Start' : this.value.start.formatAsDate()}</div>
|
|
94
|
-
|
|
95
|
-
<div ${style({ color: 'var(--mo-color-gray)' })}>bis</div>
|
|
96
|
-
|
|
97
|
-
<div ${style({ width: '*', fontWeight: '500', cursor: 'pointer' })}
|
|
98
|
-
${style({ color: this.currentSelection === 1 /* DateRangeCalendarSelectionAdapterCurrentSelection.EndDate */ ? 'var(--mo-color-accent)' : 'unset' })}
|
|
99
|
-
@click=${() => this.currentSelection = 1 /* DateRangeCalendarSelectionAdapterCurrentSelection.EndDate */}
|
|
100
|
-
>${!((_b = this.value) === null || _b === void 0 ? void 0 : _b.end) ? 'Ende' : this.value.end.formatAsDate()}</div>
|
|
101
|
-
</mo-flex>
|
|
102
|
-
${super.calendarTemplate}
|
|
103
|
-
</mo-flex>
|
|
104
|
-
`;
|
|
105
|
-
}
|
|
106
|
-
valueToInputValue(value) {
|
|
107
|
-
var _a;
|
|
108
|
-
return value ? (_a = value.format()) !== null && _a !== void 0 ? _a : '' : '';
|
|
109
|
-
}
|
|
110
|
-
inputValueToValue(value) {
|
|
111
|
-
return value ? DateRangeParser.parse(value, this.shortcutReferenceDate) : undefined;
|
|
8
|
+
this.precision = "day" /* FieldDateTimePrecision.Day */;
|
|
112
9
|
}
|
|
113
10
|
};
|
|
114
11
|
__decorate([
|
|
115
|
-
|
|
116
|
-
], FieldDateRange.prototype, "
|
|
117
|
-
__decorate([
|
|
118
|
-
property({ type: Object })
|
|
119
|
-
], FieldDateRange.prototype, "value", void 0);
|
|
12
|
+
property()
|
|
13
|
+
], FieldDateRange.prototype, "precision", void 0);
|
|
120
14
|
FieldDateRange = __decorate([
|
|
121
15
|
component('mo-field-date-range')
|
|
122
16
|
], FieldDateRange);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { FieldDateTimeBase, FieldDateTimePrecision } from './FieldDateTimeBase.js';
|
|
2
|
+
/** @element mo-field-date-time */
|
|
3
|
+
export declare class FieldDateTime extends FieldDateTimeBase<Date | undefined> {
|
|
4
|
+
protected get navigatingDate(): import("@3mo/date-time/DateTime.js").DateTime;
|
|
5
|
+
protected get selectedDate(): import("@3mo/date-time/DateTime.js").DateTime | undefined;
|
|
6
|
+
value?: Date;
|
|
7
|
+
protected get calendarTemplate(): import("lit-html").TemplateResult<1>;
|
|
8
|
+
protected handleSelectedDateChange(date: DateTime, precision: FieldDateTimePrecision): void;
|
|
9
|
+
protected valueToInputValue(value: Date | undefined): string;
|
|
10
|
+
protected inputValueToValue(value: string): import("@3mo/date-time/DateTime.js").DateTime | undefined;
|
|
11
|
+
}
|
|
12
|
+
declare global {
|
|
13
|
+
interface HTMLElementTagNameMap {
|
|
14
|
+
'mo-field-date-time': FieldDateTime;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=FieldDateTime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FieldDateTime.d.ts","sourceRoot":"","sources":["../FieldDateTime.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAA;AAElF,kCAAkC;AAClC,qBACa,aAAc,SAAQ,iBAAiB,CAAC,IAAI,GAAG,SAAS,CAAC;IACrE,SAAS,KAAK,cAAc,kDAAoE;IAChG,SAAS,KAAK,YAAY,8DAA+D;IAE7D,KAAK,CAAC,EAAE,IAAI,CAAA;IAExC,SAAS,KAAK,gBAAgB,yCAQ7B;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"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { component, html, property } from '@a11d/lit';
|
|
3
|
+
import { DateParser } from './DateParser.js';
|
|
4
|
+
import { FieldDateTimeBase } from './FieldDateTimeBase.js';
|
|
5
|
+
/** @element mo-field-date-time */
|
|
6
|
+
let FieldDateTime = class FieldDateTime extends FieldDateTimeBase {
|
|
7
|
+
get navigatingDate() { return this.value ? new DateTime(this.value) : new DateTime(); }
|
|
8
|
+
get selectedDate() { return this.value ? new DateTime(this.value) : undefined; }
|
|
9
|
+
get calendarTemplate() {
|
|
10
|
+
return html `
|
|
11
|
+
<mo-selectable-calendar
|
|
12
|
+
.navigatingValue=${this.navigatingDate}
|
|
13
|
+
.value=${this.selectedDate}
|
|
14
|
+
@change=${(e) => this.handleSelectedDateChange(e.detail, "day" /* FieldDateTimePrecision.Day */)}
|
|
15
|
+
></mo-selectable-calendar>
|
|
16
|
+
`;
|
|
17
|
+
}
|
|
18
|
+
handleSelectedDateChange(date, precision) {
|
|
19
|
+
this.value = !date ? undefined : this.roundToPrecision(date);
|
|
20
|
+
super.handleSelectedDateChange(date, precision);
|
|
21
|
+
}
|
|
22
|
+
valueToInputValue(value) {
|
|
23
|
+
var _a;
|
|
24
|
+
return value ? (_a = value.format(this.formatOptions)) !== null && _a !== void 0 ? _a : '' : '';
|
|
25
|
+
}
|
|
26
|
+
inputValueToValue(value) {
|
|
27
|
+
return value ? DateParser.parse(value, this.shortcutReferenceDate) : undefined;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
__decorate([
|
|
31
|
+
property({ type: Object })
|
|
32
|
+
], FieldDateTime.prototype, "value", void 0);
|
|
33
|
+
FieldDateTime = __decorate([
|
|
34
|
+
component('mo-field-date-time')
|
|
35
|
+
], FieldDateTime);
|
|
36
|
+
export { FieldDateTime };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { HTMLTemplateResult } from '@a11d/lit';
|
|
2
|
+
import { InputFieldComponent } from '@3mo/field';
|
|
3
|
+
import type { MaterialIcon } from '@3mo/icon';
|
|
4
|
+
export declare const enum FieldDateTimePrecision {
|
|
5
|
+
Year = "year",
|
|
6
|
+
Month = "month",
|
|
7
|
+
Day = "day",
|
|
8
|
+
Hour = "hour",
|
|
9
|
+
Minute = "minute",
|
|
10
|
+
Second = "second"
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* @attr open - Whether the date picker is open
|
|
14
|
+
* @attr hideDatePicker - Hide the date picker
|
|
15
|
+
* @attr shortcutReferenceDate - The date to use as a reference for shortcuts
|
|
16
|
+
* @attr precision - The precision of the date picker. Defaults to 'minute'
|
|
17
|
+
*/
|
|
18
|
+
export declare abstract class FieldDateTimeBase<T> extends InputFieldComponent<T> {
|
|
19
|
+
open: boolean;
|
|
20
|
+
hideDatePicker: boolean;
|
|
21
|
+
shortcutReferenceDate: import("@3mo/date-time/DateTime.js").DateTime;
|
|
22
|
+
precision: FieldDateTimePrecision;
|
|
23
|
+
protected readonly calendarIconButtonIcon: MaterialIcon;
|
|
24
|
+
protected abstract get navigatingDate(): DateTime;
|
|
25
|
+
protected abstract get selectedDate(): DateTime | undefined;
|
|
26
|
+
protected get formatOptions(): Intl.DateTimeFormatOptions;
|
|
27
|
+
protected roundToPrecision(date: DateTime): import("@3mo/date-time/DateTime.js").DateTime;
|
|
28
|
+
protected handleChange(value?: T, e?: Event): void;
|
|
29
|
+
protected get isActive(): boolean;
|
|
30
|
+
static get styles(): import("@a11d/lit").CSSResult;
|
|
31
|
+
protected get template(): import("lit-html").TemplateResult<1>;
|
|
32
|
+
protected get endSlotTemplate(): import("lit-html").TemplateResult<1>;
|
|
33
|
+
protected get inputTemplate(): import("lit-html").TemplateResult<1>;
|
|
34
|
+
protected abstract inputValueToValue(value: string): T | undefined;
|
|
35
|
+
protected abstract valueToInputValue(value: T | undefined): string;
|
|
36
|
+
protected get calendarIconButtonTemplate(): HTMLTemplateResult;
|
|
37
|
+
protected get popoverTemplate(): HTMLTemplateResult;
|
|
38
|
+
protected get popoverContentTemplate(): import("lit-html").TemplateResult<1>;
|
|
39
|
+
protected get dateTemplate(): import("lit-html").TemplateResult<1>;
|
|
40
|
+
private get yearListTemplate();
|
|
41
|
+
private get monthListTemplate();
|
|
42
|
+
private get dayTemplate();
|
|
43
|
+
protected abstract get calendarTemplate(): HTMLTemplateResult;
|
|
44
|
+
private get timeTemplate();
|
|
45
|
+
private get hourListTemplate();
|
|
46
|
+
private get minuteListTemplate();
|
|
47
|
+
private get secondListTemplate();
|
|
48
|
+
protected handleSelectedDateChange(date: DateTime, precision: FieldDateTimePrecision): void;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=FieldDateTimeBase.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FieldDateTimeBase.d.ts","sourceRoot":"","sources":["../FieldDateTimeBase.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAoD,MAAM,WAAW,CAAA;AAChG,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAChD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAE7C,0BAAkB,sBAAsB;IACvC,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;IASrE,IAAI,UAAQ;IACc,cAAc,UAAQ;IACvB,qBAAqB,gDAAe;IACpD,SAAS,yBAAgC;IAErD,SAAS,CAAC,QAAQ,CAAC,sBAAsB,EAAE,YAAY,CAAU;IAEjE,SAAS,CAAC,QAAQ,KAAK,cAAc,IAAI,QAAQ,CAAA;IAEjD,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;cAWtB,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK;IAKpD,cAAuB,QAAQ,YAE9B;IAED,WAAoB,MAAM,kCA2BzB;IAED,cAAuB,QAAQ,yCAK9B;IAED,cAAuB,eAAe,yCAKrC;IAED,cAAuB,aAAa,yCAYnC;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,uBAQvC;IAED,SAAS,KAAK,eAAe,uBAQ5B;IAED,SAAS,KAAK,sBAAsB,yCAOnC;IAED,SAAS,KAAK,YAAY,yCAMzB;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"}
|