@3mo/date-time-fields 0.1.6 → 0.2.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/DateRangeParser.d.ts.map +1 -1
- package/dist/DateRangeParser.js +2 -3
- package/dist/FieldDate.js +2 -1
- package/dist/FieldDateRange.js +2 -1
- package/dist/FieldDateTime.d.ts +1 -0
- package/dist/FieldDateTime.d.ts.map +1 -1
- package/dist/FieldDateTime.js +10 -4
- package/dist/FieldDateTimeBase.d.ts +2 -1
- package/dist/FieldDateTimeBase.d.ts.map +1 -1
- package/dist/FieldDateTimeBase.js +48 -27
- package/dist/FieldDateTimeRange.d.ts +2 -1
- package/dist/FieldDateTimeRange.d.ts.map +1 -1
- package/dist/FieldDateTimeRange.js +23 -11
- package/dist/selection/YearList.d.ts.map +1 -1
- package/dist/selection/YearList.js +2 -1
- package/dist/selection/calendar/Calendar.d.ts +2 -0
- package/dist/selection/calendar/Calendar.d.ts.map +1 -1
- package/dist/selection/calendar/Calendar.js +22 -10
- package/dist/selection/calendar/SelectableCalendar.js +1 -2
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -5
- package/dist/DateParser.d.ts +0 -9
- package/dist/DateParser.d.ts.map +0 -1
- package/dist/DateParser.js +0 -93
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateRangeParser.d.ts","sourceRoot":"","sources":["../DateRangeParser.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DateRangeParser.d.ts","sourceRoot":"","sources":["../DateRangeParser.ts"],"names":[],"mappings":"AAAA,qBAAa,eAAe;IAC3B,MAAM,CAAC,QAAQ,CAAC,kBAAkB,cAAQ;IAC1C,MAAM,CAAC,QAAQ,CAAC,uBAAuB,WAAsD;IAE7F,MAAM,CAAC,KAAK,CAAC,aAAa,EAAE,MAAM,EAAE,aAAa,gDAAe;IAqBhE,OAAO,CAAC,MAAM,CAAC,yBAAyB;CAiBxC"}
|
package/dist/DateRangeParser.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { DateParser } from './DateParser.js';
|
|
2
1
|
class DateRangeParser {
|
|
3
2
|
static parse(dateRangeText, referenceDate = new DateTime) {
|
|
4
3
|
const keywordResult = DateRangeParser.parseDateRangeFromKeyword(dateRangeText, referenceDate);
|
|
@@ -11,8 +10,8 @@ class DateRangeParser {
|
|
|
11
10
|
separator = DateRangeParser.dateRangeSeparator;
|
|
12
11
|
}
|
|
13
12
|
const [startDateText, endDateText] = dateRangeText.toLowerCase().split(separator);
|
|
14
|
-
const startDate =
|
|
15
|
-
const endDate =
|
|
13
|
+
const startDate = DateTime.parseAsDateTime(startDateText, referenceDate);
|
|
14
|
+
const endDate = DateTime.parseAsDateTime(endDateText, referenceDate);
|
|
16
15
|
return new DateTimeRange(startDate, endDate);
|
|
17
16
|
}
|
|
18
17
|
static parseDateRangeFromKeyword(keyword, referenceDate = new DateTime) {
|
package/dist/FieldDate.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { component, property } from '@a11d/lit';
|
|
3
3
|
import { FieldDateTime } from './FieldDateTime.js';
|
|
4
|
+
import { FieldDateTimePrecision } from './FieldDateTimeBase.js';
|
|
4
5
|
/** @element mo-field-date */
|
|
5
6
|
let FieldDate = class FieldDate extends FieldDateTime {
|
|
6
7
|
constructor() {
|
|
7
8
|
super(...arguments);
|
|
8
|
-
this.precision =
|
|
9
|
+
this.precision = FieldDateTimePrecision.Day;
|
|
9
10
|
}
|
|
10
11
|
};
|
|
11
12
|
__decorate([
|
package/dist/FieldDateRange.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { component, property } from '@a11d/lit';
|
|
3
|
+
import { FieldDateTimePrecision } from './FieldDateTimeBase.js';
|
|
3
4
|
import { FieldDateTimeRange } from './FieldDateTimeRange.js';
|
|
4
5
|
/** @element mo-field-date */
|
|
5
6
|
let FieldDateRange = class FieldDateRange extends FieldDateTimeRange {
|
|
6
7
|
constructor() {
|
|
7
8
|
super(...arguments);
|
|
8
|
-
this.precision =
|
|
9
|
+
this.precision = FieldDateTimePrecision.Day;
|
|
9
10
|
}
|
|
10
11
|
};
|
|
11
12
|
__decorate([
|
package/dist/FieldDateTime.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export declare class FieldDateTime extends FieldDateTimeBase<Date | undefined> {
|
|
|
4
4
|
protected get navigatingDate(): import("@3mo/date-time/DateTime.js").DateTime;
|
|
5
5
|
protected get selectedDate(): import("@3mo/date-time/DateTime.js").DateTime | undefined;
|
|
6
6
|
value?: Date;
|
|
7
|
+
protected get placeholder(): string;
|
|
7
8
|
protected get calendarTemplate(): import("lit-html").TemplateResult<1>;
|
|
8
9
|
protected handleSelectedDateChange(date: DateTime, precision: FieldDateTimePrecision): void;
|
|
9
10
|
protected valueToInputValue(value: Date | undefined): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldDateTime.d.ts","sourceRoot":"","sources":["../FieldDateTime.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FieldDateTime.d.ts","sourceRoot":"","sources":["../FieldDateTime.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAA;AAGlF,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,cACuB,WAAW,WAEjC;IAED,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"}
|
package/dist/FieldDateTime.js
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { component, html, property } from '@a11d/lit';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { FieldDateTimeBase, FieldDateTimePrecision } from './FieldDateTimeBase.js';
|
|
4
|
+
import { Memoize as memoize } from 'typescript-memoize';
|
|
5
5
|
/** @element mo-field-date-time */
|
|
6
6
|
let FieldDateTime = class FieldDateTime extends FieldDateTimeBase {
|
|
7
7
|
get navigatingDate() { return this.value ? new DateTime(this.value) : new DateTime(); }
|
|
8
8
|
get selectedDate() { return this.value ? new DateTime(this.value) : undefined; }
|
|
9
|
+
get placeholder() {
|
|
10
|
+
return new DateTime().format(this.formatOptions);
|
|
11
|
+
}
|
|
9
12
|
get calendarTemplate() {
|
|
10
13
|
return html `
|
|
11
14
|
<mo-selectable-calendar
|
|
12
15
|
.navigatingValue=${this.navigatingDate}
|
|
13
16
|
.value=${this.selectedDate}
|
|
14
|
-
@change=${(e) => this.handleSelectedDateChange(e.detail,
|
|
17
|
+
@change=${(e) => this.handleSelectedDateChange(e.detail, FieldDateTimePrecision.Day)}
|
|
15
18
|
></mo-selectable-calendar>
|
|
16
19
|
`;
|
|
17
20
|
}
|
|
@@ -24,12 +27,15 @@ let FieldDateTime = class FieldDateTime extends FieldDateTimeBase {
|
|
|
24
27
|
return value ? (_a = value.format(this.formatOptions)) !== null && _a !== void 0 ? _a : '' : '';
|
|
25
28
|
}
|
|
26
29
|
inputValueToValue(value) {
|
|
27
|
-
return value ?
|
|
30
|
+
return value ? DateTime.parseAsDateTime(value, this.shortcutReferenceDate) : undefined;
|
|
28
31
|
}
|
|
29
32
|
};
|
|
30
33
|
__decorate([
|
|
31
34
|
property({ type: Object })
|
|
32
35
|
], FieldDateTime.prototype, "value", void 0);
|
|
36
|
+
__decorate([
|
|
37
|
+
memoize()
|
|
38
|
+
], FieldDateTime.prototype, "placeholder", null);
|
|
33
39
|
FieldDateTime = __decorate([
|
|
34
40
|
component('mo-field-date-time')
|
|
35
41
|
], FieldDateTime);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { HTMLTemplateResult } from '@a11d/lit';
|
|
2
2
|
import { InputFieldComponent } from '@3mo/field';
|
|
3
3
|
import type { MaterialIcon } from '@3mo/icon';
|
|
4
|
-
export declare
|
|
4
|
+
export declare enum FieldDateTimePrecision {
|
|
5
5
|
Year = "year",
|
|
6
6
|
Month = "month",
|
|
7
7
|
Day = "day",
|
|
@@ -27,6 +27,7 @@ export declare abstract class FieldDateTimeBase<T> extends InputFieldComponent<T
|
|
|
27
27
|
protected roundToPrecision(date: DateTime): import("@3mo/date-time/DateTime.js").DateTime;
|
|
28
28
|
protected handleChange(value?: T, e?: Event): void;
|
|
29
29
|
protected get isActive(): boolean;
|
|
30
|
+
protected get placeholder(): string;
|
|
30
31
|
static get styles(): import("@a11d/lit").CSSResult;
|
|
31
32
|
protected get template(): import("lit-html").TemplateResult<1>;
|
|
32
33
|
protected get endSlotTemplate(): import("lit-html").TemplateResult<1>;
|
|
@@ -1 +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,
|
|
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,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;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,SAAS,KAAK,WAAW,WAExB;IAED,WAAoB,MAAM,kCAmCzB;IAED,cAAuB,QAAQ,yCAK9B;IAED,cAAuB,eAAe,yCAKrC;IAED,cAAuB,aAAa,yCAanC;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,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"}
|
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { cache, css, html, live, nothing, property, style } from '@a11d/lit';
|
|
3
3
|
import { InputFieldComponent } from '@3mo/field';
|
|
4
|
+
export var FieldDateTimePrecision;
|
|
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 || (FieldDateTimePrecision = {}));
|
|
4
13
|
function isDateTimePrecisionSmaller(precision, other) {
|
|
5
14
|
const precisions = [
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
15
|
+
FieldDateTimePrecision.Year,
|
|
16
|
+
FieldDateTimePrecision.Month,
|
|
17
|
+
FieldDateTimePrecision.Day,
|
|
18
|
+
FieldDateTimePrecision.Hour,
|
|
19
|
+
FieldDateTimePrecision.Minute,
|
|
20
|
+
FieldDateTimePrecision.Second,
|
|
12
21
|
];
|
|
13
22
|
return precisions.indexOf(precision) < precisions.indexOf(other);
|
|
14
23
|
}
|
|
@@ -24,7 +33,7 @@ export class FieldDateTimeBase extends InputFieldComponent {
|
|
|
24
33
|
this.open = false;
|
|
25
34
|
this.hideDatePicker = false;
|
|
26
35
|
this.shortcutReferenceDate = new DateTime;
|
|
27
|
-
this.precision =
|
|
36
|
+
this.precision = FieldDateTimePrecision.Minute;
|
|
28
37
|
this.calendarIconButtonIcon = 'today';
|
|
29
38
|
}
|
|
30
39
|
get formatOptions() {
|
|
@@ -33,22 +42,22 @@ export class FieldDateTimeBase extends InputFieldComponent {
|
|
|
33
42
|
calendar: (_a = this.selectedDate) === null || _a === void 0 ? void 0 : _a.calendarId,
|
|
34
43
|
timeZone: (_b = this.selectedDate) === null || _b === void 0 ? void 0 : _b.timeZoneId,
|
|
35
44
|
year: 'numeric',
|
|
36
|
-
month: isDateTimePrecisionSmaller(this.precision,
|
|
37
|
-
day: isDateTimePrecisionSmaller(this.precision,
|
|
38
|
-
hour: isDateTimePrecisionSmaller(this.precision,
|
|
39
|
-
minute: isDateTimePrecisionSmaller(this.precision,
|
|
40
|
-
second: isDateTimePrecisionSmaller(this.precision,
|
|
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',
|
|
41
50
|
hourCycle: 'h23',
|
|
42
51
|
};
|
|
43
52
|
}
|
|
44
53
|
roundToPrecision(date) {
|
|
45
54
|
return date.with({
|
|
46
55
|
year: date.year,
|
|
47
|
-
month: isDateTimePrecisionSmaller(this.precision,
|
|
48
|
-
day: isDateTimePrecisionSmaller(this.precision,
|
|
49
|
-
hour: isDateTimePrecisionSmaller(this.precision,
|
|
50
|
-
minute: isDateTimePrecisionSmaller(this.precision,
|
|
51
|
-
second: isDateTimePrecisionSmaller(this.precision,
|
|
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,
|
|
52
61
|
});
|
|
53
62
|
}
|
|
54
63
|
handleChange(value, e) {
|
|
@@ -58,6 +67,9 @@ export class FieldDateTimeBase extends InputFieldComponent {
|
|
|
58
67
|
get isActive() {
|
|
59
68
|
return super.isActive || this.open;
|
|
60
69
|
}
|
|
70
|
+
get placeholder() {
|
|
71
|
+
return '';
|
|
72
|
+
}
|
|
61
73
|
static get styles() {
|
|
62
74
|
return css `
|
|
63
75
|
${super.styles}
|
|
@@ -84,6 +96,14 @@ export class FieldDateTimeBase extends InputFieldComponent {
|
|
|
84
96
|
font-weight: 500;
|
|
85
97
|
color: var(--mo-color-gray);
|
|
86
98
|
}
|
|
99
|
+
|
|
100
|
+
input::placeholder {
|
|
101
|
+
color: transparent;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
mo-field[active] input::placeholder {
|
|
105
|
+
color: var(--mo-color-gray);
|
|
106
|
+
}
|
|
87
107
|
`;
|
|
88
108
|
}
|
|
89
109
|
get template() {
|
|
@@ -105,6 +125,7 @@ export class FieldDateTimeBase extends InputFieldComponent {
|
|
|
105
125
|
?readonly=${this.readonly}
|
|
106
126
|
?required=${this.required}
|
|
107
127
|
?disabled=${this.disabled}
|
|
128
|
+
placeholder=${this.placeholder}
|
|
108
129
|
.value=${live(this.inputStringValue || '')}
|
|
109
130
|
@input=${(e) => this.handleInput(this.inputValueToValue(this.inputElement.value || ''), e)}
|
|
110
131
|
@change=${(e) => this.handleChange(this.inputValueToValue(this.inputElement.value || ''), e)}
|
|
@@ -148,25 +169,25 @@ export class FieldDateTimeBase extends InputFieldComponent {
|
|
|
148
169
|
<mo-year-list
|
|
149
170
|
.navigatingValue=${this.navigatingDate}
|
|
150
171
|
.value=${this.selectedDate}
|
|
151
|
-
@change=${(e) => this.handleSelectedDateChange(e.detail,
|
|
172
|
+
@change=${(e) => this.handleSelectedDateChange(e.detail, FieldDateTimePrecision.Year)}
|
|
152
173
|
></mo-year-list>
|
|
153
174
|
`;
|
|
154
175
|
}
|
|
155
176
|
get monthListTemplate() {
|
|
156
|
-
return [
|
|
177
|
+
return [FieldDateTimePrecision.Year].includes(this.precision) ? nothing : html `
|
|
157
178
|
<mo-month-list
|
|
158
179
|
.navigatingValue=${this.navigatingDate}
|
|
159
180
|
.value=${this.selectedDate}
|
|
160
|
-
@change=${(e) => this.handleSelectedDateChange(e.detail,
|
|
181
|
+
@change=${(e) => this.handleSelectedDateChange(e.detail, FieldDateTimePrecision.Month)}
|
|
161
182
|
></mo-month-list>
|
|
162
183
|
`;
|
|
163
184
|
}
|
|
164
185
|
get dayTemplate() {
|
|
165
|
-
return [
|
|
186
|
+
return [FieldDateTimePrecision.Year, FieldDateTimePrecision.Month].includes(this.precision) ? nothing : this.calendarTemplate;
|
|
166
187
|
}
|
|
167
188
|
get timeTemplate() {
|
|
168
189
|
var _a, _b, _c, _d;
|
|
169
|
-
return [
|
|
190
|
+
return [FieldDateTimePrecision.Year, FieldDateTimePrecision.Month, FieldDateTimePrecision.Day].includes(this.precision) ? nothing : html `
|
|
170
191
|
<mo-flex gap='6px'>
|
|
171
192
|
<div class='timezone'>
|
|
172
193
|
${(_b = (_a = this.navigatingDate) === null || _a === void 0 ? void 0 : _a.formatToParts({ timeZoneName: 'long' }).find(x => x.type === 'timeZoneName')) === null || _b === void 0 ? void 0 : _b.value}
|
|
@@ -185,25 +206,25 @@ export class FieldDateTimeBase extends InputFieldComponent {
|
|
|
185
206
|
<mo-hour-list style='flex: 1'
|
|
186
207
|
.navigatingValue=${this.navigatingDate}
|
|
187
208
|
.value=${this.selectedDate}
|
|
188
|
-
@change=${(e) => this.handleSelectedDateChange(e.detail,
|
|
209
|
+
@change=${(e) => this.handleSelectedDateChange(e.detail, FieldDateTimePrecision.Hour)}
|
|
189
210
|
></mo-hour-list>
|
|
190
211
|
`;
|
|
191
212
|
}
|
|
192
213
|
get minuteListTemplate() {
|
|
193
|
-
return [
|
|
214
|
+
return [FieldDateTimePrecision.Hour].includes(this.precision) ? nothing : html `
|
|
194
215
|
<mo-minute-list style='flex: 1'
|
|
195
216
|
.navigatingValue=${this.navigatingDate}
|
|
196
217
|
.value=${this.selectedDate}
|
|
197
|
-
@change=${(e) => this.handleSelectedDateChange(e.detail,
|
|
218
|
+
@change=${(e) => this.handleSelectedDateChange(e.detail, FieldDateTimePrecision.Minute)}
|
|
198
219
|
></mo-minute-list>
|
|
199
220
|
`;
|
|
200
221
|
}
|
|
201
222
|
get secondListTemplate() {
|
|
202
|
-
return [
|
|
223
|
+
return [FieldDateTimePrecision.Hour, FieldDateTimePrecision.Minute].includes(this.precision) ? nothing : html `
|
|
203
224
|
<mo-second-list style='flex: 1'
|
|
204
225
|
.navigatingValue=${this.navigatingDate}
|
|
205
226
|
.value=${this.selectedDate}
|
|
206
|
-
@change=${(e) => this.handleSelectedDateChange(e.detail,
|
|
227
|
+
@change=${(e) => this.handleSelectedDateChange(e.detail, FieldDateTimePrecision.Second)}
|
|
207
228
|
></mo-second-list>
|
|
208
229
|
`;
|
|
209
230
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MaterialIcon } from '@3mo/icon';
|
|
2
2
|
import { FieldDateTimeBase as FieldDateTimeBase, FieldDateTimePrecision } from './FieldDateTimeBase.js';
|
|
3
|
-
declare
|
|
3
|
+
declare enum FieldDateRangeSelection {
|
|
4
4
|
Start = "start",
|
|
5
5
|
End = "end"
|
|
6
6
|
}
|
|
@@ -20,6 +20,7 @@ export declare class FieldDateTimeRange extends FieldDateTimeBase<DateTimeRange
|
|
|
20
20
|
value?: DateTimeRange;
|
|
21
21
|
static get styles(): import("@a11d/lit").CSSResult;
|
|
22
22
|
protected calendarIconButtonIcon: MaterialIcon;
|
|
23
|
+
protected get placeholder(): string;
|
|
23
24
|
protected get calendarTemplate(): import("lit-html").TemplateResult<1>;
|
|
24
25
|
protected get popoverContentTemplate(): import("lit-html").TemplateResult<1>;
|
|
25
26
|
handleSelectedDateChange(date: DateTime, precision: FieldDateTimePrecision): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldDateTimeRange.d.ts","sourceRoot":"","sources":["../FieldDateTimeRange.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AACxC,OAAO,EAAE,iBAAiB,IAAI,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAA;
|
|
1
|
+
{"version":3,"file":"FieldDateTimeRange.d.ts","sourceRoot":"","sources":["../FieldDateTimeRange.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AACxC,OAAO,EAAE,iBAAiB,IAAI,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAA;AAIvG,aAAK,uBAAuB;IAC3B,KAAK,UAAU;IACf,GAAG,QAAQ;CACX;AAED;;;;;;;;GAQG;AACH,qBACa,kBAAmB,SAAQ,iBAAiB,CAAC,aAAa,GAAG,SAAS,CAAC;IACnF,SAAS,KAAK,cAAc,kDAAwH;IAEpJ,SAAS,KAAK,YAAY,8DAAoG;IAElH,SAAS,0BAAgC;IACzB,KAAK,CAAC,EAAE,aAAa,CAAA;IAEjD,WAAoB,MAAM,kCAkBzB;IAED,UAAmB,sBAAsB,EAAE,YAAY,CAAe;IAEtE,cACuB,WAAW,WAEjC;IAED,SAAS,KAAK,gBAAgB,yCAQ7B;IAED,cAAuB,sBAAsB,yCAW5C;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"}
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { component, css, html, property } from '@a11d/lit';
|
|
3
|
-
import { FieldDateTimeBase as FieldDateTimeBase } from './FieldDateTimeBase.js';
|
|
3
|
+
import { FieldDateTimeBase as FieldDateTimeBase, FieldDateTimePrecision } from './FieldDateTimeBase.js';
|
|
4
4
|
import { DateRangeParser } from './DateRangeParser.js';
|
|
5
|
+
import { Memoize as memoize } from 'typescript-memoize';
|
|
6
|
+
var FieldDateRangeSelection;
|
|
7
|
+
(function (FieldDateRangeSelection) {
|
|
8
|
+
FieldDateRangeSelection["Start"] = "start";
|
|
9
|
+
FieldDateRangeSelection["End"] = "end";
|
|
10
|
+
})(FieldDateRangeSelection || (FieldDateRangeSelection = {}));
|
|
5
11
|
/**
|
|
6
12
|
* @element mo-field-date-range
|
|
7
13
|
*
|
|
@@ -14,11 +20,11 @@ import { DateRangeParser } from './DateRangeParser.js';
|
|
|
14
20
|
let FieldDateTimeRange = class FieldDateTimeRange extends FieldDateTimeBase {
|
|
15
21
|
constructor() {
|
|
16
22
|
super(...arguments);
|
|
17
|
-
this.selection =
|
|
23
|
+
this.selection = FieldDateRangeSelection.Start;
|
|
18
24
|
this.calendarIconButtonIcon = 'date_range';
|
|
19
25
|
}
|
|
20
|
-
get navigatingDate() { var _a, _b, _c; return (_c = (this.selection ===
|
|
21
|
-
get selectedDate() { var _a, _b; return this.selection ===
|
|
26
|
+
get navigatingDate() { var _a, _b, _c; return (_c = (this.selection === FieldDateRangeSelection.Start ? (_a = this.value) === null || _a === void 0 ? void 0 : _a.start : (_b = this.value) === null || _b === void 0 ? void 0 : _b.end)) !== null && _c !== void 0 ? _c : new DateTime(); }
|
|
27
|
+
get selectedDate() { var _a, _b; return this.selection === FieldDateRangeSelection.Start ? (_a = this.value) === null || _a === void 0 ? void 0 : _a.start : (_b = this.value) === null || _b === void 0 ? void 0 : _b.end; }
|
|
22
28
|
static get styles() {
|
|
23
29
|
return css `
|
|
24
30
|
${super.styles}
|
|
@@ -38,12 +44,15 @@ let FieldDateTimeRange = class FieldDateTimeRange extends FieldDateTimeBase {
|
|
|
38
44
|
}
|
|
39
45
|
`;
|
|
40
46
|
}
|
|
47
|
+
get placeholder() {
|
|
48
|
+
return new DateTimeRange(new DateTime().subtract({ years: 1 }), new DateTime()).format(this.formatOptions);
|
|
49
|
+
}
|
|
41
50
|
get calendarTemplate() {
|
|
42
51
|
return html `
|
|
43
52
|
<mo-selectable-range-calendar
|
|
44
53
|
.navigatingValue=${this.navigatingDate}
|
|
45
54
|
.dateRange=${this.value}
|
|
46
|
-
@change=${(e) => this.handleSelectedDateChange(e.detail,
|
|
55
|
+
@change=${(e) => this.handleSelectedDateChange(e.detail, FieldDateTimePrecision.Day)}
|
|
47
56
|
></mo-selectable-range-calendar>
|
|
48
57
|
`;
|
|
49
58
|
}
|
|
@@ -51,8 +60,8 @@ let FieldDateTimeRange = class FieldDateTimeRange extends FieldDateTimeBase {
|
|
|
51
60
|
return html `
|
|
52
61
|
<mo-flex>
|
|
53
62
|
<mo-tab-bar value=${this.selection} @change=${(e) => this.selection = e.detail}>
|
|
54
|
-
<mo-tab value=${
|
|
55
|
-
<mo-tab value=${
|
|
63
|
+
<mo-tab value=${FieldDateRangeSelection.Start} label=${t('Start')}></mo-tab>
|
|
64
|
+
<mo-tab value=${FieldDateRangeSelection.End} label=${t('End')}></mo-tab>
|
|
56
65
|
</mo-tab-bar>
|
|
57
66
|
</mo-flex>
|
|
58
67
|
|
|
@@ -61,13 +70,13 @@ let FieldDateTimeRange = class FieldDateTimeRange extends FieldDateTimeBase {
|
|
|
61
70
|
}
|
|
62
71
|
handleSelectedDateChange(date, precision) {
|
|
63
72
|
var _a, _b;
|
|
64
|
-
this.value = this.selection ===
|
|
73
|
+
this.value = this.selection === FieldDateRangeSelection.Start
|
|
65
74
|
? new DateTimeRange(this.roundToPrecision(date), (_a = this.value) === null || _a === void 0 ? void 0 : _a.end)
|
|
66
75
|
: new DateTimeRange((_b = this.value) === null || _b === void 0 ? void 0 : _b.start, this.roundToPrecision(date));
|
|
67
76
|
if (this.precision === precision) {
|
|
68
|
-
this.selection = this.selection ===
|
|
69
|
-
?
|
|
70
|
-
:
|
|
77
|
+
this.selection = this.selection === FieldDateRangeSelection.Start
|
|
78
|
+
? FieldDateRangeSelection.End
|
|
79
|
+
: FieldDateRangeSelection.Start;
|
|
71
80
|
}
|
|
72
81
|
super.handleSelectedDateChange(date, precision);
|
|
73
82
|
}
|
|
@@ -85,6 +94,9 @@ __decorate([
|
|
|
85
94
|
__decorate([
|
|
86
95
|
property({ type: Object })
|
|
87
96
|
], FieldDateTimeRange.prototype, "value", void 0);
|
|
97
|
+
__decorate([
|
|
98
|
+
memoize()
|
|
99
|
+
], FieldDateTimeRange.prototype, "placeholder", null);
|
|
88
100
|
FieldDateTimeRange = __decorate([
|
|
89
101
|
component('mo-field-date-time-range')
|
|
90
102
|
], FieldDateTimeRange);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"YearList.d.ts","sourceRoot":"","sources":["../../selection/YearList.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,qBACa,QAAS,SAAQ,QAAQ;IACrC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAsB;IAC9C,OAAO,CAAC,KAAK,CAE0B;IAEvC,cAAuB,iBAAiB,
|
|
1
|
+
{"version":3,"file":"YearList.d.ts","sourceRoot":"","sources":["../../selection/YearList.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,qBACa,QAAS,SAAQ,QAAQ;IACrC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAsB;IAC9C,OAAO,CAAC,KAAK,CAE0B;IAEvC,cAAuB,iBAAiB,yCAWvC;CACD;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,cAAc,EAAE,QAAQ,CAAA;KACxB;CACD"}
|
|
@@ -10,13 +10,14 @@ let YearList = class YearList extends DateList {
|
|
|
10
10
|
.map((_, i) => this.nowYear - 100 + i);
|
|
11
11
|
}
|
|
12
12
|
get listItemsTemplate() {
|
|
13
|
+
const now = this.now;
|
|
13
14
|
return html `
|
|
14
15
|
${this.years.map(year => {
|
|
15
16
|
var _a;
|
|
16
17
|
return html `
|
|
17
18
|
<mo-selectable-list-item
|
|
18
19
|
?selected=${((_a = this.value) === null || _a === void 0 ? void 0 : _a.year) === year}
|
|
19
|
-
?data-now=${
|
|
20
|
+
?data-now=${now.year === year}
|
|
20
21
|
@change=${(e) => { var _a; return !e.selected ? void 0 : this.change.dispatch(((_a = this.value) !== null && _a !== void 0 ? _a : new DateTime).with({ year })); }}
|
|
21
22
|
>${year.format()}</mo-selectable-list-item>
|
|
22
23
|
`;
|
|
@@ -3,11 +3,13 @@ import '@a11d/array.prototype.group';
|
|
|
3
3
|
export declare class Calendar extends Component {
|
|
4
4
|
includeWeekNumbers: boolean;
|
|
5
5
|
navigatingValue: import("@3mo/date-time/DateTime.js").DateTime;
|
|
6
|
+
private days;
|
|
6
7
|
static get styles(): import("@a11d/lit").CSSResult;
|
|
7
8
|
protected get template(): import("lit-html").TemplateResult<1>;
|
|
8
9
|
private rangeOf;
|
|
9
10
|
protected getDayTemplate(day: DateTime): import("lit-html").TemplateResult<1>;
|
|
10
11
|
protected handleDayClick(day: DateTime): void;
|
|
12
|
+
private get now();
|
|
11
13
|
protected getDayElementClasses(day: DateTime): ClassInfo;
|
|
12
14
|
}
|
|
13
15
|
declare global {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Calendar.d.ts","sourceRoot":"","sources":["../../../selection/calendar/Calendar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAA4D,SAAS,
|
|
1
|
+
{"version":3,"file":"Calendar.d.ts","sourceRoot":"","sources":["../../../selection/calendar/Calendar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAA4D,SAAS,EAAS,MAAM,WAAW,CAAA;AACjH,OAAO,6BAA6B,CAAA;AAGpC,qBACa,QAAS,SAAQ,SAAS;IACM,kBAAkB,UAAQ;IAUnE,eAAe,gDAAe;IAExB,OAAO,CAAC,IAAI,CAA2D;IAEhF,WAAoB,MAAM,kCAmDzB;IAED,cAAuB,QAAQ,yCAqB9B;IAED,OAAO,CAAG,OAAO;IAOjB,SAAS,CAAC,cAAc,CAAC,GAAG,EAAE,QAAQ;IAQtC,SAAS,CAAC,cAAc,CAAC,GAAG,EAAE,QAAQ;IAKtC,OAAO,KAAK,GAAG,GAA0B;IAEzC,SAAS,CAAC,oBAAoB,CAAC,GAAG,EAAE,QAAQ,GAAG,SAAS;CAOxD;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,aAAa,EAAE,QAAQ,CAAA;KACvB;CACD"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
|
-
import { Component, css, component, html, nothing, property, classMap, style } from '@a11d/lit';
|
|
2
|
+
import { Component, css, component, html, nothing, property, classMap, style, state } from '@a11d/lit';
|
|
3
3
|
import '@a11d/array.prototype.group';
|
|
4
|
+
import { MemoizeExpiring as memoizeExpiring } from 'typescript-memoize';
|
|
4
5
|
let Calendar = class Calendar extends Component {
|
|
5
6
|
constructor() {
|
|
6
7
|
super(...arguments);
|
|
7
8
|
this.includeWeekNumbers = false;
|
|
8
9
|
this.navigatingValue = new DateTime;
|
|
10
|
+
this.days = new Array();
|
|
9
11
|
}
|
|
10
12
|
static get styles() {
|
|
11
13
|
return css `
|
|
@@ -60,11 +62,6 @@ let Calendar = class Calendar extends Component {
|
|
|
60
62
|
`;
|
|
61
63
|
}
|
|
62
64
|
get template() {
|
|
63
|
-
const start = this.navigatingValue.monthStart.weekStart;
|
|
64
|
-
const end = this.navigatingValue.monthEnd.weekEnd;
|
|
65
|
-
const range = [...this.rangeOf(start, end)];
|
|
66
|
-
const weekDaysInMonth = [...range.groupToMap(d => String(d.weekOfYear))]
|
|
67
|
-
.sort(([, dates1], [, dates2]) => { var _a; return ((_a = dates1[0]) === null || _a === void 0 ? void 0 : _a.isBefore(dates2[0])) ? -1 : +1; });
|
|
68
65
|
return html `
|
|
69
66
|
<mo-grid class='month'
|
|
70
67
|
rows='repeat(auto-fill, var(--mo-calendar-day-size))'
|
|
@@ -79,7 +76,7 @@ let Calendar = class Calendar extends Component {
|
|
|
79
76
|
</div>
|
|
80
77
|
`)}
|
|
81
78
|
|
|
82
|
-
${
|
|
79
|
+
${this.days.map(([weekNumber, days]) => html `
|
|
83
80
|
${this.includeWeekNumbers === false ? nothing : html `<div class='week'>${weekNumber}</div>`}
|
|
84
81
|
${days.map(day => this.getDayTemplate(day))}
|
|
85
82
|
`)}
|
|
@@ -102,11 +99,11 @@ let Calendar = class Calendar extends Component {
|
|
|
102
99
|
handleDayClick(day) {
|
|
103
100
|
day;
|
|
104
101
|
}
|
|
102
|
+
get now() { return new DateTime; }
|
|
105
103
|
getDayElementClasses(day) {
|
|
106
|
-
const now = new DateTime();
|
|
107
104
|
return {
|
|
108
105
|
day: true,
|
|
109
|
-
today: now.
|
|
106
|
+
today: this.now.year === day.year && this.now.month === day.month && this.now.day === day.day,
|
|
110
107
|
isInMonth: day.month === this.navigatingValue.month
|
|
111
108
|
};
|
|
112
109
|
}
|
|
@@ -115,8 +112,23 @@ __decorate([
|
|
|
115
112
|
property({ type: Boolean, reflect: true })
|
|
116
113
|
], Calendar.prototype, "includeWeekNumbers", void 0);
|
|
117
114
|
__decorate([
|
|
118
|
-
property({
|
|
115
|
+
property({
|
|
116
|
+
type: Object,
|
|
117
|
+
updated() {
|
|
118
|
+
const start = this.navigatingValue.monthStart.weekStart;
|
|
119
|
+
const end = this.navigatingValue.monthEnd.weekEnd;
|
|
120
|
+
const range = [...this.rangeOf(start, end)];
|
|
121
|
+
this.days = [...range.groupToMap(d => String(d.weekOfYear))]
|
|
122
|
+
.sort(([, dates1], [, dates2]) => { var _a; return ((_a = dates1[0]) === null || _a === void 0 ? void 0 : _a.isBefore(dates2[0])) ? -1 : +1; });
|
|
123
|
+
}
|
|
124
|
+
})
|
|
119
125
|
], Calendar.prototype, "navigatingValue", void 0);
|
|
126
|
+
__decorate([
|
|
127
|
+
state()
|
|
128
|
+
], Calendar.prototype, "days", void 0);
|
|
129
|
+
__decorate([
|
|
130
|
+
memoizeExpiring(60000)
|
|
131
|
+
], Calendar.prototype, "now", null);
|
|
120
132
|
Calendar = __decorate([
|
|
121
133
|
component('mo-calendar')
|
|
122
134
|
], Calendar);
|
|
@@ -18,8 +18,7 @@ let SelectableCalendar = class SelectableCalendar extends Calendar {
|
|
|
18
18
|
this.change.dispatch(day);
|
|
19
19
|
}
|
|
20
20
|
getDayElementClasses(day) {
|
|
21
|
-
|
|
22
|
-
return Object.assign(Object.assign({}, super.getDayElementClasses(day)), { selected: !!this.value && day.dayStart.equals((_a = this.value) === null || _a === void 0 ? void 0 : _a.dayStart) });
|
|
21
|
+
return Object.assign(Object.assign({}, super.getDayElementClasses(day)), { selected: !!this.value && day.year === this.value.year && day.month === this.value.month && day.day === this.value.day });
|
|
23
22
|
}
|
|
24
23
|
};
|
|
25
24
|
__decorate([
|