@3mo/date-time-fields 0.11.0-preview.0 → 0.11.0-preview.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/FieldDateTime.d.ts +2 -2
- package/dist/FieldDateTime.d.ts.map +1 -1
- package/dist/FieldDateTime.js +6 -12
- package/dist/FieldDateTimeBase.d.ts +11 -11
- package/dist/FieldDateTimeBase.d.ts.map +1 -1
- package/dist/FieldDateTimeBase.js +19 -10
- package/dist/FieldDateTimeRange.d.ts +2 -2
- package/dist/FieldDateTimeRange.d.ts.map +1 -1
- package/dist/FieldDateTimeRange.js +8 -14
- package/dist/custom-elements.json +32 -32
- package/dist/selection/Calendar.d.ts +4 -6
- package/dist/selection/Calendar.d.ts.map +1 -1
- package/dist/selection/Calendar.js +70 -67
- package/dist/selection/CalendarDatesController.d.ts +4 -2
- package/dist/selection/CalendarDatesController.d.ts.map +1 -1
- package/dist/selection/CalendarDatesController.js +10 -8
- package/dist/selection/DateList.d.ts +1 -1
- package/dist/selection/DateList.d.ts.map +1 -1
- package/dist/selection/DateList.js +2 -2
- package/dist/selection/HourList.js +3 -3
- package/dist/selection/MinuteList.js +2 -2
- package/dist/selection/SecondList.js +2 -2
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
var Calendar_1;
|
|
2
2
|
import { __decorate } from "tslib";
|
|
3
|
-
import { Component, css, component, html, property, event, repeat, state } from '@a11d/lit';
|
|
3
|
+
import { Component, css, component, html, property, event, repeat, state, unsafeCSS } from '@a11d/lit';
|
|
4
4
|
import { CalendarDatesController } from './CalendarDatesController.js';
|
|
5
|
+
import { FieldDateTimePrecision } from '../FieldDateTimePrecision.js';
|
|
5
6
|
/**
|
|
6
7
|
* @fires dateClick - Dispatched when a date is clicked, with the clicked date as detail.
|
|
7
8
|
*/
|
|
@@ -9,7 +10,7 @@ let Calendar = Calendar_1 = class Calendar extends Component {
|
|
|
9
10
|
constructor() {
|
|
10
11
|
super(...arguments);
|
|
11
12
|
this.includeWeek = false;
|
|
12
|
-
this.view =
|
|
13
|
+
this.view = FieldDateTimePrecision.Day;
|
|
13
14
|
this.datesController = new CalendarDatesController(this);
|
|
14
15
|
this.handleItemClick = (date, precision) => {
|
|
15
16
|
return () => {
|
|
@@ -20,10 +21,10 @@ let Calendar = Calendar_1 = class Calendar extends Component {
|
|
|
20
21
|
else {
|
|
21
22
|
const nextView = this.view !== precision
|
|
22
23
|
? precision
|
|
23
|
-
: this.view ===
|
|
24
|
-
?
|
|
25
|
-
: this.view ===
|
|
26
|
-
?
|
|
24
|
+
: this.view === FieldDateTimePrecision.Year
|
|
25
|
+
? FieldDateTimePrecision.Month
|
|
26
|
+
: this.view === FieldDateTimePrecision.Month
|
|
27
|
+
? FieldDateTimePrecision.Day
|
|
27
28
|
: this.view;
|
|
28
29
|
this.setView(nextView, date);
|
|
29
30
|
}
|
|
@@ -32,45 +33,47 @@ let Calendar = Calendar_1 = class Calendar extends Component {
|
|
|
32
33
|
}
|
|
33
34
|
get navigationDate() { return this.datesController.navigationDate; }
|
|
34
35
|
async setNavigatingValue(date, behavior = 'instant') {
|
|
36
|
+
this.datesController.disableObservers = true;
|
|
35
37
|
this.datesController.navigationDate = date;
|
|
36
38
|
await this.updateComplete;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
scrollToNavigatingItem(behavior = 'instant') {
|
|
40
|
-
this.renderRoot
|
|
41
|
-
.querySelector(`.${this.view}[data-navigating]`)
|
|
39
|
+
await new Promise(r => setTimeout(r, 10));
|
|
40
|
+
this.renderRoot.querySelector(`.${this.view}[data-navigating]`)
|
|
42
41
|
?.scrollIntoView({ block: 'center', behavior });
|
|
42
|
+
await new Promise(r => setTimeout(r, behavior === 'instant' ? 10 : 100));
|
|
43
|
+
this.datesController.disableObservers = false;
|
|
43
44
|
}
|
|
44
|
-
setView(view,
|
|
45
|
+
setView(view, navigationDate = this.datesController.navigationDate) {
|
|
45
46
|
this.view = view;
|
|
46
|
-
this.setNavigatingValue(
|
|
47
|
+
this.setNavigatingValue(navigationDate);
|
|
47
48
|
}
|
|
48
49
|
static get styles() {
|
|
50
|
+
const year = unsafeCSS(FieldDateTimePrecision.Year.key);
|
|
51
|
+
const month = unsafeCSS(FieldDateTimePrecision.Month.key);
|
|
52
|
+
const day = unsafeCSS(FieldDateTimePrecision.Day.key);
|
|
49
53
|
return css `
|
|
50
54
|
:host {
|
|
51
55
|
--mo-calendar-item-size: 2.25rem;
|
|
56
|
+
flex: 1;
|
|
52
57
|
}
|
|
53
58
|
|
|
54
|
-
|
|
59
|
+
.scroller {
|
|
55
60
|
height: min(450px, 100vh);
|
|
56
61
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
scroll-behavior: smooth;
|
|
63
|
-
}
|
|
62
|
+
display: grid;
|
|
63
|
+
position: relative;
|
|
64
|
+
scrollbar-width: none;
|
|
65
|
+
overflow-x: hidden;
|
|
66
|
+
scroll-behavior: smooth;
|
|
64
67
|
|
|
65
|
-
&[data-view
|
|
68
|
+
&[data-view=${day}] {
|
|
66
69
|
grid-template-columns: repeat(1, 1fr);
|
|
67
70
|
}
|
|
68
71
|
|
|
69
|
-
&[data-view
|
|
72
|
+
&[data-view=${month}] {
|
|
70
73
|
grid-template-columns: repeat(3, 1fr);
|
|
71
74
|
}
|
|
72
75
|
|
|
73
|
-
&[data-view
|
|
76
|
+
&[data-view=${year}] {
|
|
74
77
|
grid-template-columns: repeat(5, 1fr);
|
|
75
78
|
}
|
|
76
79
|
}
|
|
@@ -108,7 +111,7 @@ let Calendar = Calendar_1 = class Calendar extends Component {
|
|
|
108
111
|
}
|
|
109
112
|
|
|
110
113
|
/* Headings */
|
|
111
|
-
.year[data-view
|
|
114
|
+
.year[data-view=${month}], .month[data-view=${day}] {
|
|
112
115
|
font-size: 1.125rem;
|
|
113
116
|
font-weight: 500;
|
|
114
117
|
height: 2rem;
|
|
@@ -116,7 +119,7 @@ let Calendar = Calendar_1 = class Calendar extends Component {
|
|
|
116
119
|
}
|
|
117
120
|
|
|
118
121
|
/* Selection */
|
|
119
|
-
.year[data-view
|
|
122
|
+
.year[data-view=${year}], .month[data-view=${month}], .day {
|
|
120
123
|
opacity: 0.875;
|
|
121
124
|
font-size: 0.94rem;
|
|
122
125
|
cursor: pointer;
|
|
@@ -124,10 +127,10 @@ let Calendar = Calendar_1 = class Calendar extends Component {
|
|
|
124
127
|
}
|
|
125
128
|
|
|
126
129
|
.year {
|
|
127
|
-
&[data-view
|
|
130
|
+
&[data-view=${day}] {
|
|
128
131
|
display: none;
|
|
129
132
|
}
|
|
130
|
-
&:not([data-view
|
|
133
|
+
&:not([data-view=${year}]) {
|
|
131
134
|
grid-column: -1 / 1;
|
|
132
135
|
border-block-start: 1px solid var(--mo-color-transparent-gray-3);
|
|
133
136
|
}
|
|
@@ -137,7 +140,7 @@ let Calendar = Calendar_1 = class Calendar extends Component {
|
|
|
137
140
|
.month-container {
|
|
138
141
|
width: 100%;
|
|
139
142
|
position: relative;
|
|
140
|
-
&[data-view
|
|
143
|
+
&[data-view=${day}] {
|
|
141
144
|
&::before {
|
|
142
145
|
content: ' ';
|
|
143
146
|
position: absolute;
|
|
@@ -164,7 +167,7 @@ let Calendar = Calendar_1 = class Calendar extends Component {
|
|
|
164
167
|
margin-block-start: -0.375rem;
|
|
165
168
|
}
|
|
166
169
|
|
|
167
|
-
&[data-view
|
|
170
|
+
&[data-view=${month}] {
|
|
168
171
|
& > mo-grid {
|
|
169
172
|
display: none;
|
|
170
173
|
}
|
|
@@ -210,25 +213,25 @@ let Calendar = Calendar_1 = class Calendar extends Component {
|
|
|
210
213
|
}
|
|
211
214
|
get template() {
|
|
212
215
|
return html `
|
|
213
|
-
<
|
|
216
|
+
<div class='scroller' data-view=${this.view.key}>
|
|
214
217
|
${repeat(this.datesController.data, d => d.toString(), d => html `
|
|
215
218
|
${this.getYearTemplate(d)}
|
|
216
219
|
${this.getMonthTemplate(d)}
|
|
217
220
|
`)}
|
|
218
|
-
</
|
|
221
|
+
</div>
|
|
219
222
|
`;
|
|
220
223
|
}
|
|
221
224
|
getYearTemplate(date) {
|
|
222
225
|
return date.dayOfYear !== 1 ? html.nothing : html `
|
|
223
226
|
<div class='year' role='button'
|
|
224
|
-
data-view=${this.view}
|
|
225
|
-
?data-navigating=${this.isNavigating(date,
|
|
226
|
-
?data-now=${this.isNow(date,
|
|
227
|
-
?data-start=${this.isStart(date,
|
|
228
|
-
?data-end=${this.isEnd(date,
|
|
229
|
-
?data-in-range=${this.isInRange(date,
|
|
230
|
-
@click=${this.handleItemClick(date,
|
|
231
|
-
${this.datesController.observerIntersectionNavigation(date,
|
|
227
|
+
data-view=${this.view.key}
|
|
228
|
+
?data-navigating=${this.isNavigating(date, FieldDateTimePrecision.Year)}
|
|
229
|
+
?data-now=${this.isNow(date, FieldDateTimePrecision.Year)}
|
|
230
|
+
?data-start=${this.isStart(date, FieldDateTimePrecision.Year)}
|
|
231
|
+
?data-end=${this.isEnd(date, FieldDateTimePrecision.Year)}
|
|
232
|
+
?data-in-range=${this.isInRange(date, FieldDateTimePrecision.Year)}
|
|
233
|
+
@click=${this.handleItemClick(date, FieldDateTimePrecision.Year)}
|
|
234
|
+
${this.datesController.observerIntersectionNavigation(date, FieldDateTimePrecision.Month, FieldDateTimePrecision.Year)}
|
|
232
235
|
>
|
|
233
236
|
${date.format({ year: 'numeric' })}
|
|
234
237
|
</div>
|
|
@@ -253,40 +256,40 @@ let Calendar = Calendar_1 = class Calendar extends Component {
|
|
|
253
256
|
`;
|
|
254
257
|
}
|
|
255
258
|
getMonthTemplate(date) {
|
|
256
|
-
return this.view ===
|
|
257
|
-
<mo-flex class='month-container' data-view=${this.view}>
|
|
259
|
+
return this.view === FieldDateTimePrecision.Year || date.day !== 1 ? html.nothing : html `
|
|
260
|
+
<mo-flex class='month-container' data-view=${this.view.key}>
|
|
258
261
|
<div class='month' role='button'
|
|
259
|
-
data-view=${this.view}
|
|
260
|
-
?data-navigating=${this.isNavigating(date,
|
|
261
|
-
?data-now=${this.isNow(date,
|
|
262
|
-
?data-start=${this.isStart(date,
|
|
263
|
-
?data-end=${this.isEnd(date,
|
|
264
|
-
?data-in-range=${this.isInRange(date,
|
|
265
|
-
@click=${this.handleItemClick(date,
|
|
266
|
-
${this.datesController.observerIntersectionNavigation(date,
|
|
262
|
+
data-view=${this.view.key}
|
|
263
|
+
?data-navigating=${this.isNavigating(date, FieldDateTimePrecision.Month)}
|
|
264
|
+
?data-now=${this.isNow(date, FieldDateTimePrecision.Month)}
|
|
265
|
+
?data-start=${this.isStart(date, FieldDateTimePrecision.Month)}
|
|
266
|
+
?data-end=${this.isEnd(date, FieldDateTimePrecision.Month)}
|
|
267
|
+
?data-in-range=${this.isInRange(date, FieldDateTimePrecision.Month)}
|
|
268
|
+
@click=${this.handleItemClick(date, FieldDateTimePrecision.Month)}
|
|
269
|
+
${this.datesController.observerIntersectionNavigation(date, FieldDateTimePrecision.Day)}
|
|
267
270
|
>
|
|
268
|
-
${this.view ===
|
|
271
|
+
${this.view === FieldDateTimePrecision.Day ? date.format({ year: 'numeric', month: 'long' }) : date.format({ month: 'long' })}
|
|
269
272
|
</div>
|
|
270
|
-
<mo-grid autoRows='var(--mo-calendar-item-size)' columns=${this.view ===
|
|
271
|
-
${this.view !==
|
|
273
|
+
<mo-grid justifyContent='center' autoRows='var(--mo-calendar-item-size)' columns=${this.view === FieldDateTimePrecision.Day ? this.columns : 'auto'}>
|
|
274
|
+
${this.view !== FieldDateTimePrecision.Day ? html.nothing : Calendar_1.weekDaysTemplate}
|
|
272
275
|
${this.datesController.data.filter(d => d.year === date.year && d.month === date.month).map(day => this.getDayTemplate(day))}
|
|
273
276
|
</mo-grid>
|
|
274
277
|
</mo-flex>
|
|
275
278
|
`;
|
|
276
279
|
}
|
|
277
280
|
getDayTemplate(day) {
|
|
278
|
-
return this.view ===
|
|
281
|
+
return this.view === FieldDateTimePrecision.Month ? html.nothing : html `
|
|
279
282
|
${this.includeWeek === false || day.dayOfWeek !== 1 ? html.nothing : html `
|
|
280
283
|
<div class='week' style='grid-column: week'>${day.weekOfYear}</div>
|
|
281
284
|
`}
|
|
282
285
|
<div tabindex='0' role='button' class='day'
|
|
283
286
|
style='grid-column: ${this.getColumnName(day)}'
|
|
284
|
-
?data-navigating=${this.isNavigating(day,
|
|
285
|
-
?data-now=${this.isNow(day,
|
|
286
|
-
?data-start=${this.isStart(day,
|
|
287
|
-
?data-end=${this.isEnd(day,
|
|
288
|
-
?data-in-range=${this.isInRange(day,
|
|
289
|
-
@click=${this.handleItemClick(day,
|
|
287
|
+
?data-navigating=${this.isNavigating(day, FieldDateTimePrecision.Day)}
|
|
288
|
+
?data-now=${this.isNow(day, FieldDateTimePrecision.Day)}
|
|
289
|
+
?data-start=${this.isStart(day, FieldDateTimePrecision.Day)}
|
|
290
|
+
?data-end=${this.isEnd(day, FieldDateTimePrecision.Day)}
|
|
291
|
+
?data-in-range=${this.isInRange(day, FieldDateTimePrecision.Day)}
|
|
292
|
+
@click=${this.handleItemClick(day, FieldDateTimePrecision.Day)}
|
|
290
293
|
>
|
|
291
294
|
${day.format({ day: 'numeric' })}
|
|
292
295
|
</div>
|
|
@@ -295,18 +298,18 @@ let Calendar = Calendar_1 = class Calendar extends Component {
|
|
|
295
298
|
isNavigating(date, precision) {
|
|
296
299
|
return this.view === precision
|
|
297
300
|
&& this.navigationDate.year === date.year
|
|
298
|
-
&& (precision ===
|
|
299
|
-
&& (precision !==
|
|
301
|
+
&& (precision === FieldDateTimePrecision.Year || this.navigationDate.month === date.month)
|
|
302
|
+
&& (precision !== FieldDateTimePrecision.Day || this.navigationDate.day === date.day);
|
|
300
303
|
}
|
|
301
304
|
isEqual(precision, left, right) {
|
|
302
305
|
return left.year === right.year
|
|
303
|
-
&& (precision ===
|
|
304
|
-
&& (precision !==
|
|
306
|
+
&& (precision === FieldDateTimePrecision.Year || left.month === right.month)
|
|
307
|
+
&& (precision !== FieldDateTimePrecision.Day || left.day === right.day);
|
|
305
308
|
}
|
|
306
309
|
isLower(precision, left, right) {
|
|
307
310
|
return left.year < right.year
|
|
308
|
-
|| (precision !==
|
|
309
|
-
|| (precision ===
|
|
311
|
+
|| (precision !== FieldDateTimePrecision.Year && left.year === right.year && left.month < right.month)
|
|
312
|
+
|| (precision === FieldDateTimePrecision.Day && left.year === right.year && left.month === right.month && left.day < right.day);
|
|
310
313
|
}
|
|
311
314
|
isNow(date, precision) {
|
|
312
315
|
return this.view === precision && this.isEqual(precision, date, CalendarDatesController.today);
|
|
@@ -330,7 +333,7 @@ __decorate([
|
|
|
330
333
|
property({ type: Object })
|
|
331
334
|
], Calendar.prototype, "value", void 0);
|
|
332
335
|
__decorate([
|
|
333
|
-
property({ updated() { this.setView(this.precision); } })
|
|
336
|
+
property({ type: Object, updated() { this.setView(this.precision); } })
|
|
334
337
|
], Calendar.prototype, "precision", void 0);
|
|
335
338
|
__decorate([
|
|
336
339
|
property({ type: Boolean, reflect: true })
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Controller, type DirectiveResult } from '@a11d/lit';
|
|
2
|
-
import type { Calendar
|
|
2
|
+
import type { Calendar } from './Calendar.js';
|
|
3
|
+
import { FieldDateTimePrecision } from '../FieldDateTimePrecision.js';
|
|
3
4
|
export declare class CalendarDatesController extends Controller {
|
|
4
5
|
readonly host: Calendar;
|
|
5
6
|
static get today(): import("@3mo/date-time/DateTime.js").DateTime;
|
|
@@ -7,7 +8,8 @@ export declare class CalendarDatesController extends Controller {
|
|
|
7
8
|
private static _sampleWeek;
|
|
8
9
|
static get sampleWeek(): ReadonlyArray<DateTime>;
|
|
9
10
|
private static generateWeek;
|
|
10
|
-
|
|
11
|
+
disableObservers: boolean;
|
|
12
|
+
observerIntersectionNavigation(date: DateTime, ...views: Array<FieldDateTimePrecision>): DirectiveResult<any>;
|
|
11
13
|
constructor(host: Calendar);
|
|
12
14
|
private days;
|
|
13
15
|
private months;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CalendarDatesController.d.ts","sourceRoot":"","sources":["../../selection/CalendarDatesController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAQ,KAAK,eAAe,EAAE,MAAM,WAAW,CAAA;AAGlE,OAAO,KAAK,EAAE,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"CalendarDatesController.d.ts","sourceRoot":"","sources":["../../selection/CalendarDatesController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAQ,KAAK,eAAe,EAAE,MAAM,WAAW,CAAA;AAGlE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAC7C,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAA;AAErE,qBAAa,uBAAwB,SAAQ,UAAU;aAkCxB,IAAI,EAAE,QAAQ;IAhC5C,MAAM,KAAK,KAAK,kDAAqC;IAErD,OAAO,CAAC,MAAM,CAAE,QAAQ;IAMxB,OAAO,CAAC,MAAM,CAAC,WAAW,CAAwB;IAClD,MAAM,KAAK,UAAU,IAAgC,aAAa,CAAC,QAAQ,CAAC,CAAE;IAE9E,OAAO,CAAC,MAAM,CAAC,YAAY;IAW3B,gBAAgB,UAAQ;IAExB,8BAA8B,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,KAAK,CAAC,sBAAsB,CAAC;gBAQxD,IAAI,EAAE,QAAQ;IAK5C,OAAO,CAAC,IAAI,CAAwB;IACpC,OAAO,CAAC,MAAM,CAAwB;IACtC,OAAO,CAAC,KAAK,CAAwB;IAErC,IAAI,IAAI,oDASP;IAED,OAAO,CAAC,eAAe,CAAW;IAClC,IAAI,cAAc,kDAAkC;IACpD,IAAI,cAAc,CAAC,KAAK,+CAAA,EAsCvB;CACD"}
|
|
@@ -2,23 +2,24 @@ import { __decorate } from "tslib";
|
|
|
2
2
|
import { Controller, html } from '@a11d/lit';
|
|
3
3
|
import { observeIntersection } from '@3mo/intersection-observer';
|
|
4
4
|
import { MemoizeExpiring as memoizeExpiring } from 'typescript-memoize';
|
|
5
|
+
import { FieldDateTimePrecision } from '../FieldDateTimePrecision.js';
|
|
5
6
|
export class CalendarDatesController extends Controller {
|
|
6
7
|
static get today() { return new DateTime().dayStart; }
|
|
7
|
-
static *generate(start, count, step
|
|
8
|
+
static *generate(start, count, step) {
|
|
8
9
|
for (let i = 0; i < count; i++) {
|
|
9
10
|
yield start.add({ [step]: i });
|
|
10
11
|
}
|
|
11
12
|
}
|
|
12
13
|
static get sampleWeek() { return this._sampleWeek; }
|
|
13
14
|
static generateWeek() {
|
|
14
|
-
const sample = [...CalendarDatesController.generate(CalendarDatesController.today, CalendarDatesController.today.daysInWeek * 2)];
|
|
15
|
+
const sample = [...CalendarDatesController.generate(CalendarDatesController.today, CalendarDatesController.today.daysInWeek * 2, 'days')];
|
|
15
16
|
const indexOfFirstWeekStart = sample.findIndex(d => d.dayOfWeek === 1);
|
|
16
17
|
const daysInWeek = sample[0].daysInWeek;
|
|
17
18
|
CalendarDatesController._sampleWeek = sample.slice(indexOfFirstWeekStart, indexOfFirstWeekStart + daysInWeek).map(d => d.dayStart);
|
|
18
19
|
}
|
|
19
20
|
observerIntersectionNavigation(date, ...views) {
|
|
20
21
|
return !views.includes(this.host.view) ? html.nothing : observeIntersection(data => {
|
|
21
|
-
if (data.some(entry => entry.isIntersecting)) {
|
|
22
|
+
if (!this.disableObservers && data.some(entry => entry.isIntersecting)) {
|
|
22
23
|
this.navigationDate = date;
|
|
23
24
|
}
|
|
24
25
|
});
|
|
@@ -26,6 +27,7 @@ export class CalendarDatesController extends Controller {
|
|
|
26
27
|
constructor(host) {
|
|
27
28
|
super(host);
|
|
28
29
|
this.host = host;
|
|
30
|
+
this.disableObservers = false;
|
|
29
31
|
this.days = new Array();
|
|
30
32
|
this.months = new Array();
|
|
31
33
|
this.years = new Array();
|
|
@@ -33,9 +35,9 @@ export class CalendarDatesController extends Controller {
|
|
|
33
35
|
}
|
|
34
36
|
get data() {
|
|
35
37
|
switch (this.host.view) {
|
|
36
|
-
case
|
|
38
|
+
case FieldDateTimePrecision.Year:
|
|
37
39
|
return this.years;
|
|
38
|
-
case
|
|
40
|
+
case FieldDateTimePrecision.Month:
|
|
39
41
|
return this.months;
|
|
40
42
|
default:
|
|
41
43
|
return this.days;
|
|
@@ -45,17 +47,17 @@ export class CalendarDatesController extends Controller {
|
|
|
45
47
|
set navigationDate(value) {
|
|
46
48
|
let changed = false;
|
|
47
49
|
const daysOffset = 75;
|
|
48
|
-
if (this.host.view ===
|
|
50
|
+
if (this.host.view === FieldDateTimePrecision.Day && (!this.days.length || value.isBefore(this.days.at(daysOffset)) || value.isAfter(this.days.at(-daysOffset)))) {
|
|
49
51
|
this.days = [...CalendarDatesController.generate(value.yearStart.add({ years: -1 }), value.daysInYear * 3, 'days')];
|
|
50
52
|
changed = true;
|
|
51
53
|
}
|
|
52
54
|
const monthsOffset = 25;
|
|
53
|
-
if (this.host.view ===
|
|
55
|
+
if (this.host.view === FieldDateTimePrecision.Month && (!this.months.length || value.isBefore(this.months.at(monthsOffset)) || value.isAfter(this.months.at(-monthsOffset)))) {
|
|
54
56
|
this.months = [...CalendarDatesController.generate(value.yearStart.add({ years: -10 }), value.monthsInYear * 20, 'months')];
|
|
55
57
|
changed = true;
|
|
56
58
|
}
|
|
57
59
|
const yearsOffset = 15;
|
|
58
|
-
if (this.host.view ===
|
|
60
|
+
if (this.host.view === FieldDateTimePrecision.Year && (!this.years.length || value.isBefore(this.years.at(yearsOffset)) || value.isAfter(this.years.at(-yearsOffset)))) {
|
|
59
61
|
this.years = [...CalendarDatesController.generate(value.yearStart.add({ years: -100 }), 200, 'years')];
|
|
60
62
|
changed = true;
|
|
61
63
|
}
|
|
@@ -2,7 +2,7 @@ import { Component, type HTMLTemplateResult } from '@a11d/lit';
|
|
|
2
2
|
export declare abstract class DateList extends Component {
|
|
3
3
|
readonly change: EventDispatcher<DateTime>;
|
|
4
4
|
readonly navigate: EventDispatcher<DateTime>;
|
|
5
|
-
|
|
5
|
+
navigationDate: DateTime;
|
|
6
6
|
value?: DateTime;
|
|
7
7
|
private readonly selector;
|
|
8
8
|
private readonly items;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateList.d.ts","sourceRoot":"","sources":["../../selection/DateList.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,kBAAkB,EAA6D,MAAM,WAAW,CAAA;AAGzH,8BAAsB,QAAS,SAAQ,SAAS;IACtC,QAAQ,CAAC,MAAM,EAAG,eAAe,CAAC,QAAQ,CAAC,CAAA;IAC3C,QAAQ,CAAC,QAAQ,EAAG,eAAe,CAAC,QAAQ,CAAC,CAAA;IAEP,
|
|
1
|
+
{"version":3,"file":"DateList.d.ts","sourceRoot":"","sources":["../../selection/DateList.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,kBAAkB,EAA6D,MAAM,WAAW,CAAA;AAGzH,8BAAsB,QAAS,SAAQ,SAAS;IACtC,QAAQ,CAAC,MAAM,EAAG,eAAe,CAAC,QAAQ,CAAC,CAAA;IAC3C,QAAQ,CAAC,QAAQ,EAAG,eAAe,CAAC,QAAQ,CAAC,CAAA;IAEP,cAAc,EAAG,QAAQ,CAAA;IAC5C,KAAK,CAAC,EAAE,QAAQ,CAAA;IAExB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAc;IACtB,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA4B;IACpC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAoB;IAC3D,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAoB;IAE9F,IAAI,IAAI,WAAe;IAEvB,WAAoB,MAAM,kCA+BzB;cAEkB,SAAS;IAI5B,cAAuB,QAAQ,uBAkB9B;YAEa,cAAc;IAM5B,OAAO,CAAC,iBAAiB,CAAQ;IACjC,IAAI,gBAAgB,YAAoC;IACxD,IAAI,gBAAgB,CAAC,KAAK,SAAA,EAMzB;IAID,SAAS,CAAC,YAAY,CAAC,CAAC,EAAE,KAAK;IAe/B,SAAS,CAAC,QAAQ,KAAK,iBAAiB,IAAI,kBAAkB,CAAA;CAC9D"}
|
|
@@ -42,7 +42,7 @@ export class DateList extends Component {
|
|
|
42
42
|
this.scrollIntoItem('navigating', 'instant');
|
|
43
43
|
}
|
|
44
44
|
get template() {
|
|
45
|
-
return this.
|
|
45
|
+
return this.navigationDate === undefined ? html.nothing : html `
|
|
46
46
|
<div class='selector'></div>
|
|
47
47
|
<mo-scroller snapType='y mandatory'
|
|
48
48
|
@scroll=${this.handleScroll}
|
|
@@ -97,7 +97,7 @@ __decorate([
|
|
|
97
97
|
], DateList.prototype, "navigate", void 0);
|
|
98
98
|
__decorate([
|
|
99
99
|
property({ type: Object, event: 'navigate' })
|
|
100
|
-
], DateList.prototype, "
|
|
100
|
+
], DateList.prototype, "navigationDate", void 0);
|
|
101
101
|
__decorate([
|
|
102
102
|
property({ type: Object })
|
|
103
103
|
], DateList.prototype, "value", void 0);
|
|
@@ -4,11 +4,11 @@ import { DateList } from './DateList.js';
|
|
|
4
4
|
let HourList = class HourList extends DateList {
|
|
5
5
|
get listItemsTemplate() {
|
|
6
6
|
return html `
|
|
7
|
-
${[...range(0, this.
|
|
7
|
+
${[...range(0, this.navigationDate.hoursInDay)].map(hour => html `
|
|
8
8
|
<mo-selectable-list-item
|
|
9
9
|
?selected=${this.value?.hour === hour}
|
|
10
|
-
?data-navigating=${this.
|
|
11
|
-
@navigate=${() => this.navigate.dispatch(this.
|
|
10
|
+
?data-navigating=${this.navigationDate.hour === hour}
|
|
11
|
+
@navigate=${() => this.navigate.dispatch(this.navigationDate.with({ hour }))}
|
|
12
12
|
@change=${(e) => !e.selected ? void 0 : this.change.dispatch((this.value ?? new DateTime).with({ hour }))}
|
|
13
13
|
>${hour.format().padStart(2, this.zero.format())}</mo-selectable-list-item>
|
|
14
14
|
`)}
|
|
@@ -7,8 +7,8 @@ let MinuteList = class MinuteList extends DateList {
|
|
|
7
7
|
${[...range(0, 60)].map(minute => html `
|
|
8
8
|
<mo-selectable-list-item
|
|
9
9
|
?selected=${this.value?.minute === minute}
|
|
10
|
-
?data-navigating=${this.
|
|
11
|
-
@navigate=${() => this.navigate.dispatch(this.
|
|
10
|
+
?data-navigating=${this.navigationDate.minute === minute}
|
|
11
|
+
@navigate=${() => this.navigate.dispatch(this.navigationDate.with({ minute }))}
|
|
12
12
|
@change=${(e) => !e.selected ? void 0 : this.change.dispatch((this.value ?? new DateTime).with({ minute }))}
|
|
13
13
|
>${minute.format().padStart(2, this.zero.format())}</mo-selectable-list-item>
|
|
14
14
|
`)}
|
|
@@ -7,8 +7,8 @@ let SecondList = class SecondList extends DateList {
|
|
|
7
7
|
${[...range(0, 60)].map(second => html `
|
|
8
8
|
<mo-selectable-list-item
|
|
9
9
|
?selected=${this.value?.second === second}
|
|
10
|
-
?data-navigating=${this.
|
|
11
|
-
@navigate=${() => this.navigate.dispatch(this.
|
|
10
|
+
?data-navigating=${this.navigationDate.second === second}
|
|
11
|
+
@navigate=${() => this.navigate.dispatch(this.navigationDate.with({ second }))}
|
|
12
12
|
@change=${(e) => !e.selected ? void 0 : this.change.dispatch((this.value ?? new DateTime).with({ second }))}
|
|
13
13
|
>${second.format().padStart(2, this.zero.format())}</mo-selectable-list-item>
|
|
14
14
|
`)}
|