@3mo/date-time-fields 0.13.0 → 0.14.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/FieldDate.d.ts +0 -3
- package/dist/FieldDate.d.ts.map +1 -1
- package/dist/FieldDate.js +0 -7
- package/dist/FieldDateTime.d.ts +6 -1
- package/dist/FieldDateTime.d.ts.map +1 -1
- package/dist/FieldDateTime.js +20 -7
- package/dist/FieldDateTimeBase.d.ts +7 -0
- package/dist/FieldDateTimeBase.d.ts.map +1 -1
- package/dist/FieldDateTimeBase.js +178 -140
- package/dist/FieldDateTimeRange.d.ts +1 -1
- package/dist/FieldDateTimeRange.d.ts.map +1 -1
- package/dist/FieldDateTimeRange.js +3 -4
- package/dist/custom-elements.json +529 -28
- package/dist/selection/Calendar.d.ts +4 -0
- package/dist/selection/Calendar.d.ts.map +1 -1
- package/dist/selection/Calendar.js +264 -236
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +49 -48
package/dist/FieldDate.d.ts
CHANGED
|
@@ -2,12 +2,9 @@ import { FieldDateTime } from './FieldDateTime.js';
|
|
|
2
2
|
import { FieldDateTimePrecision } from './FieldDateTimePrecision.js';
|
|
3
3
|
/**
|
|
4
4
|
* @element mo-field-date
|
|
5
|
-
*
|
|
6
|
-
* @i18n "Date"
|
|
7
5
|
*/
|
|
8
6
|
export declare class FieldDate extends FieldDateTime {
|
|
9
7
|
precision: FieldDateTimePrecision;
|
|
10
|
-
label: string;
|
|
11
8
|
}
|
|
12
9
|
declare global {
|
|
13
10
|
interface HTMLElementTagNameMap {
|
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,6BAA6B,CAAA;AAEpE;;GAEG;AACH,qBACa,SAAU,SAAQ,aAAa;IAClC,SAAS,yBAA6B;CAC/C;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,eAAe,EAAE,aAAa,CAAA;KAC9B;CACD"}
|
package/dist/FieldDate.js
CHANGED
|
@@ -1,21 +1,14 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { component } from '@a11d/lit';
|
|
3
|
-
import { Localizer } from '@3mo/localization';
|
|
4
3
|
import { FieldDateTime } from './FieldDateTime.js';
|
|
5
4
|
import { FieldDateTimePrecision } from './FieldDateTimePrecision.js';
|
|
6
|
-
Localizer.dictionaries.add('de', {
|
|
7
|
-
'Date': 'Datum',
|
|
8
|
-
});
|
|
9
5
|
/**
|
|
10
6
|
* @element mo-field-date
|
|
11
|
-
*
|
|
12
|
-
* @i18n "Date"
|
|
13
7
|
*/
|
|
14
8
|
let FieldDate = class FieldDate extends FieldDateTime {
|
|
15
9
|
constructor() {
|
|
16
10
|
super(...arguments);
|
|
17
11
|
this.precision = FieldDateTimePrecision.Day;
|
|
18
|
-
this.label = t('Date');
|
|
19
12
|
}
|
|
20
13
|
};
|
|
21
14
|
FieldDate = __decorate([
|
package/dist/FieldDateTime.d.ts
CHANGED
|
@@ -5,6 +5,10 @@ import { FieldDateTimePrecision } from './FieldDateTimePrecision.js';
|
|
|
5
5
|
* @element mo-field-date-time
|
|
6
6
|
*
|
|
7
7
|
* @i18n "Date & Time"
|
|
8
|
+
* @i18n "Date"
|
|
9
|
+
* @i18n "Year"
|
|
10
|
+
* @i18n "Month"
|
|
11
|
+
* @i18n "Week"
|
|
8
12
|
* @i18n "Today"
|
|
9
13
|
* @i18n "Yesterday"
|
|
10
14
|
* @i18n "Tomorrow"
|
|
@@ -17,7 +21,8 @@ import { FieldDateTimePrecision } from './FieldDateTimePrecision.js';
|
|
|
17
21
|
*/
|
|
18
22
|
export declare class FieldDateTime extends FieldDateTimeBase<Date | undefined> {
|
|
19
23
|
protected get selectedDate(): import("@3mo/date-time/DateTime.js").DateTime | undefined;
|
|
20
|
-
|
|
24
|
+
protected get _label(): string;
|
|
25
|
+
private get defaultLabel();
|
|
21
26
|
value?: Date;
|
|
22
27
|
protected get placeholder(): string;
|
|
23
28
|
protected resetNavigationDate(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldDateTime.d.ts","sourceRoot":"","sources":["../FieldDateTime.ts"],"names":[],"mappings":"AACA,OAAO,EAAmC,KAAK,kBAAkB,EAAE,MAAM,WAAW,CAAA;AAEpF,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;
|
|
1
|
+
{"version":3,"file":"FieldDateTime.d.ts","sourceRoot":"","sources":["../FieldDateTime.ts"],"names":[],"mappings":"AACA,OAAO,EAAmC,KAAK,kBAAkB,EAAE,MAAM,WAAW,CAAA;AAEpF,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AAoBpE;;;;;;;;;;;;;;;;;GAiBG;AACH,qBACa,aAAc,SAAQ,iBAAiB,CAAC,IAAI,GAAG,SAAS,CAAC;IACrE,SAAS,KAAK,YAAY,8DAQzB;IAED,cAAuB,MAAM,WAE5B;IAED,OAAO,KAAK,YAAY,GAQvB;IAE2B,KAAK,CAAC,EAAE,IAAI,CAAA;IAExC,cACuB,WAAW,WAEjC;IAED,SAAS,CAAC,mBAAmB;IAI7B,SAAS,KAAK,aAAa,4DAE1B;IAED,cAAuB,eAAe,IAcoB,kBAAkB,CAC3E;cAEkB,wBAAwB,CAAC,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,sBAAsB;IAO7F,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
|
@@ -6,6 +6,10 @@ import { FieldDateTimePrecision } from './FieldDateTimePrecision.js';
|
|
|
6
6
|
import { Memoize as memoize } from 'typescript-memoize';
|
|
7
7
|
Localizer.dictionaries.add('de', {
|
|
8
8
|
'Date & Time': 'Datum & Uhrzeit',
|
|
9
|
+
'Date': 'Datum',
|
|
10
|
+
'Year': 'Jahr',
|
|
11
|
+
'Month': 'Monat',
|
|
12
|
+
'Week': 'Woche',
|
|
9
13
|
'Today': 'Heute',
|
|
10
14
|
'Yesterday': 'Gestern',
|
|
11
15
|
'Tomorrow': 'Morgen',
|
|
@@ -20,6 +24,10 @@ Localizer.dictionaries.add('de', {
|
|
|
20
24
|
* @element mo-field-date-time
|
|
21
25
|
*
|
|
22
26
|
* @i18n "Date & Time"
|
|
27
|
+
* @i18n "Date"
|
|
28
|
+
* @i18n "Year"
|
|
29
|
+
* @i18n "Month"
|
|
30
|
+
* @i18n "Week"
|
|
23
31
|
* @i18n "Today"
|
|
24
32
|
* @i18n "Yesterday"
|
|
25
33
|
* @i18n "Tomorrow"
|
|
@@ -31,10 +39,6 @@ Localizer.dictionaries.add('de', {
|
|
|
31
39
|
* @i18n "Year end"
|
|
32
40
|
*/
|
|
33
41
|
let FieldDateTime = class FieldDateTime extends FieldDateTimeBase {
|
|
34
|
-
constructor() {
|
|
35
|
-
super(...arguments);
|
|
36
|
-
this.label = t('Date & Time');
|
|
37
|
-
}
|
|
38
42
|
get selectedDate() {
|
|
39
43
|
if (!this.value) {
|
|
40
44
|
return undefined;
|
|
@@ -44,6 +48,18 @@ let FieldDateTime = class FieldDateTime extends FieldDateTimeBase {
|
|
|
44
48
|
}
|
|
45
49
|
return this.value;
|
|
46
50
|
}
|
|
51
|
+
get _label() {
|
|
52
|
+
return super._label || this.defaultLabel;
|
|
53
|
+
}
|
|
54
|
+
get defaultLabel() {
|
|
55
|
+
switch (this.precision) {
|
|
56
|
+
case FieldDateTimePrecision.Year: return t('Year');
|
|
57
|
+
case FieldDateTimePrecision.Month: return t('Month');
|
|
58
|
+
case FieldDateTimePrecision.Week: return t('Week');
|
|
59
|
+
case FieldDateTimePrecision.Day: return t('Date');
|
|
60
|
+
default: return t('Date & Time');
|
|
61
|
+
}
|
|
62
|
+
}
|
|
47
63
|
get placeholder() {
|
|
48
64
|
return new DateTime().format(this.formatOptions);
|
|
49
65
|
}
|
|
@@ -82,9 +98,6 @@ let FieldDateTime = class FieldDateTime extends FieldDateTimeBase {
|
|
|
82
98
|
return value ? DateTime.parseAsDateTime(value, this.shortcutReferenceDate) : undefined;
|
|
83
99
|
}
|
|
84
100
|
};
|
|
85
|
-
__decorate([
|
|
86
|
-
property()
|
|
87
|
-
], FieldDateTime.prototype, "label", void 0);
|
|
88
101
|
__decorate([
|
|
89
102
|
property({ type: Object })
|
|
90
103
|
], FieldDateTime.prototype, "value", void 0);
|
|
@@ -8,12 +8,18 @@ import type { Calendar } from './selection/index.js';
|
|
|
8
8
|
* @attr pickerHidden - Hide the date picker
|
|
9
9
|
* @attr shortcutReferenceDate - The date to use as a reference for shortcuts
|
|
10
10
|
* @attr precision - The precision of the date picker. Defaults to 'minute'
|
|
11
|
+
* @attr min - The minimum selectable date (inclusive). Dates before this are disabled.
|
|
12
|
+
* @attr max - The maximum selectable date (inclusive). Dates after this are disabled.
|
|
13
|
+
* @attr dateDisabled - A function that determines whether a date should be disabled. Receives a DateTime object and should return a boolean.
|
|
11
14
|
*/
|
|
12
15
|
export declare abstract class FieldDateTimeBase<T> extends InputFieldComponent<T> {
|
|
13
16
|
open: boolean;
|
|
14
17
|
pickerHidden: boolean;
|
|
15
18
|
shortcutReferenceDate: import("@3mo/date-time/DateTime.js").DateTime;
|
|
16
19
|
precision: FieldDateTimePrecision;
|
|
20
|
+
min?: DateTime;
|
|
21
|
+
max?: DateTime;
|
|
22
|
+
dateDisabled?: (date: DateTime) => boolean;
|
|
17
23
|
navigationDate: import("@3mo/date-time/DateTime.js").DateTime;
|
|
18
24
|
protected readonly calendar?: Calendar;
|
|
19
25
|
protected connected(): void;
|
|
@@ -39,6 +45,7 @@ export declare abstract class FieldDateTimeBase<T> extends InputFieldComponent<T
|
|
|
39
45
|
protected get popoverSelectionTemplate(): HTMLTemplateResult;
|
|
40
46
|
protected abstract get presetsTemplate(): HTMLTemplateResult;
|
|
41
47
|
protected getPresetTemplate(label: string, value: () => T): HTMLTemplateResult;
|
|
48
|
+
private isPresetDisabled;
|
|
42
49
|
protected get dateTemplate(): HTMLTemplateResult;
|
|
43
50
|
protected get calendarTemplate(): HTMLTemplateResult;
|
|
44
51
|
protected abstract get calendarValue(): DateTimeRange | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldDateTimeBase.d.ts","sourceRoot":"","sources":["../FieldDateTimeBase.ts"],"names":[],"mappings":"AACA,OAAO,EAA0E,KAAK,kBAAkB,EAAE,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"FieldDateTimeBase.d.ts","sourceRoot":"","sources":["../FieldDateTimeBase.ts"],"names":[],"mappings":"AACA,OAAO,EAA0E,KAAK,kBAAkB,EAAE,MAAM,WAAW,CAAA;AAE3H,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAChD,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,WAAW,CAAA;AAC7C,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AACpE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAepD;;;;;;;;GAQG;AACH,8BAAsB,iBAAiB,CAAC,CAAC,CAAE,SAAQ,mBAAmB,CAAC,CAAC,CAAC;IAC5B,IAAI,UAAQ;IAC3B,YAAY,UAAQ;IACS,qBAAqB,gDAAiB;IACE,SAAS,yBAAgC;IACjF,GAAG,CAAC,EAAE,QAAQ,CAAA;IACd,GAAG,CAAC,EAAE,QAAQ,CAAA;IAChC,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,OAAO,CAAA;IAEzE,cAAc,gDAAiB;IAElB,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAA;cAEzC,SAAS;cAIT,YAAY;IAI/B,OAAO,CAAC,oBAAoB,CAE3B;IAED,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,kCAuDzB;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,uBAkB5B;IAED,SAAS,KAAK,wBAAwB,uBAOrC;IAED,SAAS,CAAC,QAAQ,KAAK,eAAe,IAAI,kBAAkB,CAAA;IAE5D,SAAS,CAAC,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC;IAYzD,OAAO,CAAC,gBAAgB;IAaxB,SAAS,KAAK,YAAY,uBAEzB;IAED,SAAS,KAAK,gBAAgB,uBAW7B;IAED,SAAS,CAAC,QAAQ,KAAK,aAAa,IAAI,aAAa,GAAG,SAAS,CAAA;IAEjE,OAAO,KAAK,YAAY,GAavB;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,19 +1,33 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { cache, css, html, live, property, style, bind, state, query, ifDefined } from '@a11d/lit';
|
|
3
|
+
import { hasChanged } from '@a11d/equals';
|
|
3
4
|
import { InputFieldComponent } from '@3mo/field';
|
|
4
5
|
import { FieldDateTimePrecision } from './FieldDateTimePrecision.js';
|
|
6
|
+
const dateTimeConverter = (value) => {
|
|
7
|
+
if (value instanceof DateTime) {
|
|
8
|
+
return value;
|
|
9
|
+
}
|
|
10
|
+
if (value instanceof Date || typeof value === 'string' || typeof value === 'number') {
|
|
11
|
+
const date = new DateTime(value);
|
|
12
|
+
return isNaN(date.getTime()) ? undefined : date;
|
|
13
|
+
}
|
|
14
|
+
return undefined;
|
|
15
|
+
};
|
|
5
16
|
/**
|
|
6
17
|
* @attr open - Whether the date picker is open
|
|
7
18
|
* @attr pickerHidden - Hide the date picker
|
|
8
19
|
* @attr shortcutReferenceDate - The date to use as a reference for shortcuts
|
|
9
20
|
* @attr precision - The precision of the date picker. Defaults to 'minute'
|
|
21
|
+
* @attr min - The minimum selectable date (inclusive). Dates before this are disabled.
|
|
22
|
+
* @attr max - The maximum selectable date (inclusive). Dates after this are disabled.
|
|
23
|
+
* @attr dateDisabled - A function that determines whether a date should be disabled. Receives a DateTime object and should return a boolean.
|
|
10
24
|
*/
|
|
11
25
|
export class FieldDateTimeBase extends InputFieldComponent {
|
|
12
26
|
constructor() {
|
|
13
27
|
super(...arguments);
|
|
14
28
|
this.open = false;
|
|
15
29
|
this.pickerHidden = false;
|
|
16
|
-
this.shortcutReferenceDate = new DateTime;
|
|
30
|
+
this.shortcutReferenceDate = new DateTime();
|
|
17
31
|
this.precision = FieldDateTimePrecision.Minute;
|
|
18
32
|
this.navigationDate = new DateTime();
|
|
19
33
|
this.handleLanguageChange = () => {
|
|
@@ -49,86 +63,86 @@ export class FieldDateTimeBase extends InputFieldComponent {
|
|
|
49
63
|
return '';
|
|
50
64
|
}
|
|
51
65
|
static get styles() {
|
|
52
|
-
return css `
|
|
53
|
-
${super.styles}
|
|
54
|
-
|
|
55
|
-
:host {
|
|
56
|
-
position: relative;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
:host([disabled]) {
|
|
60
|
-
pointer-events: none;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
mo-field {
|
|
64
|
-
anchor-name: --mo-field-date-time;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
mo-popover {
|
|
68
|
-
position-anchor: --mo-field-date-time;
|
|
69
|
-
position-visibility: anchors-visible;
|
|
70
|
-
background: var(--mo-color-background);
|
|
71
|
-
box-shadow: var(--mo-shadow);
|
|
72
|
-
border-radius: var(--mo-border-radius);
|
|
73
|
-
color: var(--mo-color-foreground);
|
|
74
|
-
font-size: 0.875em;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
#selector {
|
|
78
|
-
min-height: 175px;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
.timezone {
|
|
82
|
-
padding: 0.4rem;
|
|
83
|
-
font-size: small;
|
|
84
|
-
text-align: center;
|
|
85
|
-
font-weight: 500;
|
|
86
|
-
color: var(--mo-color-gray);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
input::placeholder {
|
|
90
|
-
color: transparent;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
mo-field[active]:not([dense]) input::placeholder {
|
|
94
|
-
color: var(--mo-color-gray);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
#presets {
|
|
98
|
-
background-color: var(--mo-color-transparent-gray-1);
|
|
99
|
-
mo-list-item {
|
|
100
|
-
padding-block: 0.5rem;
|
|
101
|
-
min-height: auto;
|
|
102
|
-
opacity: 0.9;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
66
|
+
return css `
|
|
67
|
+
${super.styles}
|
|
68
|
+
|
|
69
|
+
:host {
|
|
70
|
+
position: relative;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
:host([disabled]) {
|
|
74
|
+
pointer-events: none;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
mo-field {
|
|
78
|
+
anchor-name: --mo-field-date-time;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
mo-popover {
|
|
82
|
+
position-anchor: --mo-field-date-time;
|
|
83
|
+
position-visibility: anchors-visible;
|
|
84
|
+
background: var(--mo-color-background);
|
|
85
|
+
box-shadow: var(--mo-shadow);
|
|
86
|
+
border-radius: var(--mo-border-radius);
|
|
87
|
+
color: var(--mo-color-foreground);
|
|
88
|
+
font-size: 0.875em;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
#selector {
|
|
92
|
+
min-height: 175px;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.timezone {
|
|
96
|
+
padding: 0.4rem;
|
|
97
|
+
font-size: small;
|
|
98
|
+
text-align: center;
|
|
99
|
+
font-weight: 500;
|
|
100
|
+
color: var(--mo-color-gray);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
input::placeholder {
|
|
104
|
+
color: transparent;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
mo-field[active]:not([dense]) input::placeholder {
|
|
108
|
+
color: var(--mo-color-gray);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
#presets {
|
|
112
|
+
background-color: var(--mo-color-transparent-gray-1);
|
|
113
|
+
mo-list-item {
|
|
114
|
+
padding-block: 0.5rem;
|
|
115
|
+
min-height: auto;
|
|
116
|
+
opacity: 0.9;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
105
119
|
`;
|
|
106
120
|
}
|
|
107
121
|
get template() {
|
|
108
|
-
return html `
|
|
109
|
-
${super.template}
|
|
110
|
-
${this.popoverTemplate}
|
|
122
|
+
return html `
|
|
123
|
+
${super.template}
|
|
124
|
+
${this.popoverTemplate}
|
|
111
125
|
`;
|
|
112
126
|
}
|
|
113
127
|
get endSlotTemplate() {
|
|
114
|
-
return html `
|
|
115
|
-
${super.endSlotTemplate}
|
|
116
|
-
${this.clearIconButtonTemplate}
|
|
117
|
-
${this.calendarIconButtonTemplate}
|
|
128
|
+
return html `
|
|
129
|
+
${super.endSlotTemplate}
|
|
130
|
+
${this.clearIconButtonTemplate}
|
|
131
|
+
${this.calendarIconButtonTemplate}
|
|
118
132
|
`;
|
|
119
133
|
}
|
|
120
134
|
get inputTemplate() {
|
|
121
|
-
return html `
|
|
122
|
-
<input
|
|
123
|
-
part='input'
|
|
124
|
-
?readonly=${this.readonly}
|
|
125
|
-
?required=${this.required}
|
|
126
|
-
?disabled=${this.disabled}
|
|
127
|
-
placeholder=${this.placeholder}
|
|
128
|
-
.value=${live(this.inputStringValue || '')}
|
|
129
|
-
@input=${(e) => this.handleInput(this.inputValueToValue(this.inputElement.value || ''), e)}
|
|
130
|
-
@change=${(e) => this.handleChange(this.inputValueToValue(this.inputElement.value || ''), e)}
|
|
131
|
-
>
|
|
135
|
+
return html `
|
|
136
|
+
<input
|
|
137
|
+
part='input'
|
|
138
|
+
?readonly=${this.readonly}
|
|
139
|
+
?required=${this.required}
|
|
140
|
+
?disabled=${this.disabled}
|
|
141
|
+
placeholder=${this.placeholder}
|
|
142
|
+
.value=${live(this.inputStringValue || '')}
|
|
143
|
+
@input=${(e) => this.handleInput(this.inputValueToValue(this.inputElement.value || ''), e)}
|
|
144
|
+
@change=${(e) => this.handleChange(this.inputValueToValue(this.inputElement.value || ''), e)}
|
|
145
|
+
>
|
|
132
146
|
`;
|
|
133
147
|
}
|
|
134
148
|
get clearIconButtonTemplate() {
|
|
@@ -137,107 +151,122 @@ export class FieldDateTimeBase extends InputFieldComponent {
|
|
|
137
151
|
this.handleInput(undefined);
|
|
138
152
|
this.handleChange(undefined);
|
|
139
153
|
};
|
|
140
|
-
return !this.value || !this.focusController.focused ? html.nothing : html `
|
|
141
|
-
<mo-icon-button tabindex='-1' dense slot='end' icon='cancel'
|
|
142
|
-
@click=${clear}
|
|
143
|
-
${style({ color: 'var(--mo-color-gray)', fontSize: '20px', cursor: 'pointer', userSelect: 'none', marginBlockStart: '2.75px', marginInlineEnd: '5px' })}
|
|
144
|
-
></mo-icon-button>
|
|
154
|
+
return !this.value || !this.focusController.focused ? html.nothing : html `
|
|
155
|
+
<mo-icon-button tabindex='-1' dense slot='end' icon='cancel'
|
|
156
|
+
@click=${clear}
|
|
157
|
+
${style({ color: 'var(--mo-color-gray)', fontSize: '20px', cursor: 'pointer', userSelect: 'none', marginBlockStart: '2.75px', marginInlineEnd: '5px' })}
|
|
158
|
+
></mo-icon-button>
|
|
145
159
|
`;
|
|
146
160
|
}
|
|
147
161
|
get calendarIconButtonTemplate() {
|
|
148
|
-
return this.pickerHidden ? html.nothing : html `
|
|
149
|
-
<mo-icon tabindex='-1' slot='end'
|
|
150
|
-
icon=${this.calendarIconButtonIcon}
|
|
151
|
-
${style({ color: this.isActive ? 'var(--mo-color-accent)' : 'var(--mo-color-gray)', fontSize: '22px', marginBlockStart: '2px', cursor: 'pointer', userSelect: 'none' })}
|
|
152
|
-
></mo-icon>
|
|
162
|
+
return this.pickerHidden ? html.nothing : html `
|
|
163
|
+
<mo-icon tabindex='-1' slot='end'
|
|
164
|
+
icon=${this.calendarIconButtonIcon}
|
|
165
|
+
${style({ color: this.isActive ? 'var(--mo-color-accent)' : 'var(--mo-color-gray)', fontSize: '22px', marginBlockStart: '2px', cursor: 'pointer', userSelect: 'none' })}
|
|
166
|
+
></mo-icon>
|
|
153
167
|
`;
|
|
154
168
|
}
|
|
155
169
|
get popoverTemplate() {
|
|
156
|
-
return this.pickerHidden ? html.nothing : html `
|
|
157
|
-
<mo-popover tabindex='-1'
|
|
158
|
-
.anchor=${this} target='field'
|
|
159
|
-
?open=${bind(this, 'open', { sourceUpdated: () => setTimeout(() => this.calendar?.setNavigatingValue(this.navigationDate)) })}
|
|
160
|
-
>
|
|
161
|
-
${cache(!this.open ? html.nothing : html `
|
|
162
|
-
<mo-flex direction='horizontal'>
|
|
163
|
-
${this.presetsTemplate === html.nothing ? html.nothing : html `
|
|
164
|
-
<mo-flex id='presets'>
|
|
165
|
-
${this.presetsTemplate}
|
|
166
|
-
</mo-flex>
|
|
167
|
-
`}
|
|
168
|
-
${this.popoverSelectionTemplate}
|
|
169
|
-
</mo-flex>
|
|
170
|
-
`)}
|
|
171
|
-
</mo-popover>
|
|
170
|
+
return this.pickerHidden ? html.nothing : html `
|
|
171
|
+
<mo-popover tabindex='-1'
|
|
172
|
+
.anchor=${this} target='field'
|
|
173
|
+
?open=${bind(this, 'open', { sourceUpdated: () => setTimeout(() => this.calendar?.setNavigatingValue(this.navigationDate)) })}
|
|
174
|
+
>
|
|
175
|
+
${cache(!this.open ? html.nothing : html `
|
|
176
|
+
<mo-flex direction='horizontal'>
|
|
177
|
+
${this.presetsTemplate === html.nothing ? html.nothing : html `
|
|
178
|
+
<mo-flex id='presets'>
|
|
179
|
+
${this.presetsTemplate}
|
|
180
|
+
</mo-flex>
|
|
181
|
+
`}
|
|
182
|
+
${this.popoverSelectionTemplate}
|
|
183
|
+
</mo-flex>
|
|
184
|
+
`)}
|
|
185
|
+
</mo-popover>
|
|
172
186
|
`;
|
|
173
187
|
}
|
|
174
188
|
get popoverSelectionTemplate() {
|
|
175
|
-
return html `
|
|
176
|
-
<mo-flex id='selector' direction='horizontal' style='height: 100%; flex: 1'>
|
|
177
|
-
${this.dateTemplate}
|
|
178
|
-
${this.timeTemplate}
|
|
179
|
-
</mo-flex>
|
|
189
|
+
return html `
|
|
190
|
+
<mo-flex id='selector' direction='horizontal' style='height: 100%; flex: 1'>
|
|
191
|
+
${this.dateTemplate}
|
|
192
|
+
${this.timeTemplate}
|
|
193
|
+
</mo-flex>
|
|
180
194
|
`;
|
|
181
195
|
}
|
|
182
196
|
getPresetTemplate(label, value) {
|
|
197
|
+
const v = value();
|
|
198
|
+
if (this.isPresetDisabled(v)) {
|
|
199
|
+
return html.nothing;
|
|
200
|
+
}
|
|
183
201
|
const handlePresetClick = () => {
|
|
184
|
-
const v = value();
|
|
185
202
|
this.handleChange(v);
|
|
186
203
|
this.calendar?.setNavigatingValue(v instanceof DateTimeRange ? v.start : v instanceof DateTime ? v : undefined, 'smooth');
|
|
187
204
|
};
|
|
188
205
|
return html `<mo-list-item @click=${handlePresetClick}>${label}</mo-list-item>`;
|
|
189
206
|
}
|
|
207
|
+
isPresetDisabled(value) {
|
|
208
|
+
const dates = value instanceof DateTimeRange
|
|
209
|
+
? [value.start, value.end].filter((d) => !!d)
|
|
210
|
+
: value instanceof DateTime ? [value] : [];
|
|
211
|
+
const precision = this.precision > FieldDateTimePrecision.Day ? FieldDateTimePrecision.Day : this.precision;
|
|
212
|
+
return dates.some(date => (!!this.min && precision.isSmallerThan(date, this.min) && !precision.equals(date, this.min))
|
|
213
|
+
|| (!!this.max && precision.isSmallerThan(this.max, date) && !precision.equals(this.max, date))
|
|
214
|
+
|| (this.dateDisabled?.(date) ?? false));
|
|
215
|
+
}
|
|
190
216
|
get dateTemplate() {
|
|
191
217
|
return this.calendarTemplate;
|
|
192
218
|
}
|
|
193
219
|
get calendarTemplate() {
|
|
194
|
-
return html `
|
|
195
|
-
<mo-calendar
|
|
196
|
-
.precision=${this.precision > FieldDateTimePrecision.Day ? FieldDateTimePrecision.Day : this.precision}
|
|
197
|
-
.value=${this.calendarValue}
|
|
198
|
-
|
|
199
|
-
|
|
220
|
+
return html `
|
|
221
|
+
<mo-calendar
|
|
222
|
+
.precision=${this.precision > FieldDateTimePrecision.Day ? FieldDateTimePrecision.Day : this.precision}
|
|
223
|
+
.value=${this.calendarValue}
|
|
224
|
+
.min=${this.min}
|
|
225
|
+
.max=${this.max}
|
|
226
|
+
.dateDisabled=${this.dateDisabled}
|
|
227
|
+
@dateClick=${(e) => this.handleSelectedDateChange(e.detail, this.precision)}
|
|
228
|
+
></mo-calendar>
|
|
200
229
|
`;
|
|
201
230
|
}
|
|
202
231
|
get timeTemplate() {
|
|
203
|
-
return this.precision <= FieldDateTimePrecision.Day ? html.nothing : html `
|
|
204
|
-
<mo-flex gap='0.5rem' style='border-inline-start: 1px solid var(--mo-color-transparent-gray-3)'>
|
|
205
|
-
<mo-flex direction='horizontal' style='flex: 1'>
|
|
206
|
-
${this.hourListTemplate}
|
|
207
|
-
${this.minuteListTemplate}
|
|
208
|
-
${this.secondListTemplate}
|
|
209
|
-
</mo-flex>
|
|
210
|
-
<div class='timezone' title=${ifDefined(this.navigationDate?.formatToParts({ timeZoneName: 'long' }).find(x => x.type === 'timeZoneName')?.value)}>
|
|
211
|
-
${this.navigationDate?.formatToParts({ timeZoneName: 'shortOffset' }).find(x => x.type === 'timeZoneName')?.value}
|
|
212
|
-
</div>
|
|
213
|
-
</mo-flex>
|
|
232
|
+
return this.precision <= FieldDateTimePrecision.Day ? html.nothing : html `
|
|
233
|
+
<mo-flex gap='0.5rem' style='border-inline-start: 1px solid var(--mo-color-transparent-gray-3)'>
|
|
234
|
+
<mo-flex direction='horizontal' style='flex: 1'>
|
|
235
|
+
${this.hourListTemplate}
|
|
236
|
+
${this.minuteListTemplate}
|
|
237
|
+
${this.secondListTemplate}
|
|
238
|
+
</mo-flex>
|
|
239
|
+
<div class='timezone' title=${ifDefined(this.navigationDate?.formatToParts({ timeZoneName: 'long' }).find(x => x.type === 'timeZoneName')?.value)}>
|
|
240
|
+
${this.navigationDate?.formatToParts({ timeZoneName: 'shortOffset' }).find(x => x.type === 'timeZoneName')?.value}
|
|
241
|
+
</div>
|
|
242
|
+
</mo-flex>
|
|
214
243
|
`;
|
|
215
244
|
}
|
|
216
245
|
get hourListTemplate() {
|
|
217
|
-
return this.precision < FieldDateTimePrecision.Hour ? html.nothing : html `
|
|
218
|
-
<mo-hour-list style='flex: 1'
|
|
219
|
-
.navigationDate=${bind(this, 'navigationDate')}
|
|
220
|
-
.value=${this.selectedDate}
|
|
221
|
-
@change=${(e) => this.handleSelectedDateChange(e.detail, FieldDateTimePrecision.Hour)}
|
|
222
|
-
></mo-hour-list>
|
|
246
|
+
return this.precision < FieldDateTimePrecision.Hour ? html.nothing : html `
|
|
247
|
+
<mo-hour-list style='flex: 1'
|
|
248
|
+
.navigationDate=${bind(this, 'navigationDate')}
|
|
249
|
+
.value=${this.selectedDate}
|
|
250
|
+
@change=${(e) => this.handleSelectedDateChange(e.detail, FieldDateTimePrecision.Hour)}
|
|
251
|
+
></mo-hour-list>
|
|
223
252
|
`;
|
|
224
253
|
}
|
|
225
254
|
get minuteListTemplate() {
|
|
226
|
-
return this.precision < FieldDateTimePrecision.Minute ? html.nothing : html `
|
|
227
|
-
<mo-minute-list style='flex: 1'
|
|
228
|
-
.navigationDate=${bind(this, 'navigationDate')}
|
|
229
|
-
.value=${this.selectedDate}
|
|
230
|
-
@change=${(e) => this.handleSelectedDateChange(e.detail, FieldDateTimePrecision.Minute)}
|
|
231
|
-
></mo-minute-list>
|
|
255
|
+
return this.precision < FieldDateTimePrecision.Minute ? html.nothing : html `
|
|
256
|
+
<mo-minute-list style='flex: 1'
|
|
257
|
+
.navigationDate=${bind(this, 'navigationDate')}
|
|
258
|
+
.value=${this.selectedDate}
|
|
259
|
+
@change=${(e) => this.handleSelectedDateChange(e.detail, FieldDateTimePrecision.Minute)}
|
|
260
|
+
></mo-minute-list>
|
|
232
261
|
`;
|
|
233
262
|
}
|
|
234
263
|
get secondListTemplate() {
|
|
235
|
-
return this.precision < FieldDateTimePrecision.Second ? html.nothing : html `
|
|
236
|
-
<mo-second-list style='flex: 1'
|
|
237
|
-
.navigationDate=${bind(this, 'navigationDate')}
|
|
238
|
-
.value=${this.selectedDate}
|
|
239
|
-
@change=${(e) => this.handleSelectedDateChange(e.detail, FieldDateTimePrecision.Second)}
|
|
240
|
-
></mo-second-list>
|
|
264
|
+
return this.precision < FieldDateTimePrecision.Second ? html.nothing : html `
|
|
265
|
+
<mo-second-list style='flex: 1'
|
|
266
|
+
.navigationDate=${bind(this, 'navigationDate')}
|
|
267
|
+
.value=${this.selectedDate}
|
|
268
|
+
@change=${(e) => this.handleSelectedDateChange(e.detail, FieldDateTimePrecision.Second)}
|
|
269
|
+
></mo-second-list>
|
|
241
270
|
`;
|
|
242
271
|
}
|
|
243
272
|
handleSelectedDateChange(date, precision) {
|
|
@@ -254,11 +283,20 @@ __decorate([
|
|
|
254
283
|
property({ type: Boolean })
|
|
255
284
|
], FieldDateTimeBase.prototype, "pickerHidden", void 0);
|
|
256
285
|
__decorate([
|
|
257
|
-
property({ type: Object })
|
|
286
|
+
property({ type: Object, converter: dateTimeConverter })
|
|
258
287
|
], FieldDateTimeBase.prototype, "shortcutReferenceDate", void 0);
|
|
259
288
|
__decorate([
|
|
260
289
|
property({ type: String, converter: value => FieldDateTimePrecision.parse(value || undefined) })
|
|
261
290
|
], FieldDateTimeBase.prototype, "precision", void 0);
|
|
291
|
+
__decorate([
|
|
292
|
+
property({ type: Object, converter: dateTimeConverter })
|
|
293
|
+
], FieldDateTimeBase.prototype, "min", void 0);
|
|
294
|
+
__decorate([
|
|
295
|
+
property({ type: Object, converter: dateTimeConverter })
|
|
296
|
+
], FieldDateTimeBase.prototype, "max", void 0);
|
|
297
|
+
__decorate([
|
|
298
|
+
property({ type: Object, hasChanged })
|
|
299
|
+
], FieldDateTimeBase.prototype, "dateDisabled", void 0);
|
|
262
300
|
__decorate([
|
|
263
301
|
state()
|
|
264
302
|
], FieldDateTimeBase.prototype, "navigationDate", void 0);
|
|
@@ -28,10 +28,10 @@ declare enum FieldDateRangeSelection {
|
|
|
28
28
|
*/
|
|
29
29
|
export declare class FieldDateTimeRange extends FieldDateTimeBase<DateTimeRange | undefined> {
|
|
30
30
|
protected get selectedDate(): import("@3mo/date-time/DateTime.js").DateTime | undefined;
|
|
31
|
-
label: string;
|
|
32
31
|
selection: FieldDateRangeSelection;
|
|
33
32
|
value?: DateTimeRange;
|
|
34
33
|
protected resetNavigationDate(): void;
|
|
34
|
+
protected get _label(): string;
|
|
35
35
|
protected get presetsTemplate(): HTMLTemplateResult;
|
|
36
36
|
static get styles(): import("@a11d/lit").CSSResult;
|
|
37
37
|
protected calendarIconButtonIcon: MaterialIcon;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldDateTimeRange.d.ts","sourceRoot":"","sources":["../FieldDateTimeRange.ts"],"names":[],"mappings":"AACA,OAAO,EAA8C,KAAK,kBAAkB,EAAE,MAAM,WAAW,CAAA;AAC/F,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;AAmBpE,aAAK,uBAAuB;IAC3B,KAAK,UAAU;IACf,GAAG,QAAQ;CACX;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBACa,kBAAmB,SAAQ,iBAAiB,CAAC,aAAa,GAAG,SAAS,CAAC;IACnF,SAAS,KAAK,YAAY,8DAAoG;
|
|
1
|
+
{"version":3,"file":"FieldDateTimeRange.d.ts","sourceRoot":"","sources":["../FieldDateTimeRange.ts"],"names":[],"mappings":"AACA,OAAO,EAA8C,KAAK,kBAAkB,EAAE,MAAM,WAAW,CAAA;AAC/F,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;AAmBpE,aAAK,uBAAuB;IAC3B,KAAK,UAAU;IACf,GAAG,QAAQ;CACX;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBACa,kBAAmB,SAAQ,iBAAiB,CAAC,aAAa,GAAG,SAAS,CAAC;IACnF,SAAS,KAAK,YAAY,8DAAoG;IAElH,SAAS,0BAAgC;IACzB,KAAK,CAAC,EAAE,aAAa,CAAA;IAEjD,SAAS,CAAC,mBAAmB;IAM7B,cAAuB,MAAM,WAE5B;IAED,cAAuB,eAAe,IAoBuB,kBAAkB,CAC9E;IAED,WAAoB,MAAM,kCAezB;IAED,UAAmB,sBAAsB,EAAE,YAAY,CAAe;IAEtE,cACuB,WAAW,WAEjC;IAED,SAAS,KAAK,aAAa,wEAE1B;IAED,cAAuB,wBAAwB,uBAO9C;IAED,SAAS,KAAK,sBAAsB,uBAInC;IAED,OAAO,KAAK,sBAAsB,GASjC;IAEQ,wBAAwB,CAAC,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,sBAAsB;IAiBnF,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"}
|
|
@@ -48,7 +48,6 @@ var FieldDateRangeSelection;
|
|
|
48
48
|
let FieldDateTimeRange = class FieldDateTimeRange extends FieldDateTimeBase {
|
|
49
49
|
constructor() {
|
|
50
50
|
super(...arguments);
|
|
51
|
-
this.label = t('Period');
|
|
52
51
|
this.selection = FieldDateRangeSelection.Start;
|
|
53
52
|
this.calendarIconButtonIcon = 'date_range';
|
|
54
53
|
}
|
|
@@ -58,6 +57,9 @@ let FieldDateTimeRange = class FieldDateTimeRange extends FieldDateTimeBase {
|
|
|
58
57
|
? this.value?.start ?? this.navigationDate
|
|
59
58
|
: this.value?.end ?? this.navigationDate;
|
|
60
59
|
}
|
|
60
|
+
get _label() {
|
|
61
|
+
return super._label || t('Period');
|
|
62
|
+
}
|
|
61
63
|
get presetsTemplate() {
|
|
62
64
|
return join([
|
|
63
65
|
this.precision < FieldDateTimePrecision.Day ? undefined : html `
|
|
@@ -146,9 +148,6 @@ let FieldDateTimeRange = class FieldDateTimeRange extends FieldDateTimeBase {
|
|
|
146
148
|
return value ? DateRangeParser.parse(value, this.shortcutReferenceDate) : undefined;
|
|
147
149
|
}
|
|
148
150
|
};
|
|
149
|
-
__decorate([
|
|
150
|
-
property()
|
|
151
|
-
], FieldDateTimeRange.prototype, "label", void 0);
|
|
152
151
|
__decorate([
|
|
153
152
|
property()
|
|
154
153
|
], FieldDateTimeRange.prototype, "selection", void 0);
|