@3mo/date-time-fields 0.10.3 → 0.11.0-preview.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.
Files changed (39) hide show
  1. package/dist/FieldDateTime.d.ts +1 -1
  2. package/dist/FieldDateTime.d.ts.map +1 -1
  3. package/dist/FieldDateTime.js +6 -5
  4. package/dist/FieldDateTimeBase.d.ts +2 -3
  5. package/dist/FieldDateTimeBase.d.ts.map +1 -1
  6. package/dist/FieldDateTimeBase.js +15 -35
  7. package/dist/FieldDateTimeRange.d.ts +1 -1
  8. package/dist/FieldDateTimeRange.d.ts.map +1 -1
  9. package/dist/FieldDateTimeRange.js +6 -6
  10. package/dist/custom-elements.json +49 -256
  11. package/dist/selection/Calendar.d.ts +40 -0
  12. package/dist/selection/Calendar.d.ts.map +1 -0
  13. package/dist/selection/Calendar.js +344 -0
  14. package/dist/selection/CalendarDatesController.d.ts +20 -0
  15. package/dist/selection/CalendarDatesController.d.ts.map +1 -0
  16. package/dist/selection/CalendarDatesController.js +74 -0
  17. package/dist/selection/DateList.d.ts +1 -1
  18. package/dist/selection/DateList.d.ts.map +1 -1
  19. package/dist/selection/DateList.js +8 -4
  20. package/dist/selection/index.d.ts +1 -3
  21. package/dist/selection/index.d.ts.map +1 -1
  22. package/dist/selection/index.js +1 -3
  23. package/dist/tsconfig.tsbuildinfo +1 -1
  24. package/package.json +2 -2
  25. package/dist/selection/MonthList.d.ts +0 -12
  26. package/dist/selection/MonthList.d.ts.map +0 -1
  27. package/dist/selection/MonthList.js +0 -36
  28. package/dist/selection/YearList.d.ts +0 -12
  29. package/dist/selection/YearList.d.ts.map +0 -1
  30. package/dist/selection/YearList.js +0 -28
  31. package/dist/selection/calendar/Calendar.d.ts +0 -24
  32. package/dist/selection/calendar/Calendar.d.ts.map +0 -1
  33. package/dist/selection/calendar/Calendar.js +0 -160
  34. package/dist/selection/calendar/SelectableCalendar.d.ts +0 -20
  35. package/dist/selection/calendar/SelectableCalendar.d.ts.map +0 -1
  36. package/dist/selection/calendar/SelectableCalendar.js +0 -76
  37. package/dist/selection/calendar/index.d.ts +0 -3
  38. package/dist/selection/calendar/index.d.ts.map +0 -1
  39. package/dist/selection/calendar/index.js +0 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@3mo/date-time-fields",
3
- "version": "0.10.3",
3
+ "version": "0.11.0-preview.0",
4
4
  "description": "Date time fields let people select dates, date-ranges, and times.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -33,13 +33,13 @@
33
33
  "@3mo/icon-button": "x",
34
34
  "@3mo/interval-controller": "x",
35
35
  "@3mo/focus-controller": "x",
36
+ "@3mo/intersection-observer": "x",
36
37
  "@3mo/list": "x",
37
38
  "@3mo/localization": "x",
38
39
  "@3mo/popover": ">=0.9.x",
39
40
  "@3mo/scroller": "x",
40
41
  "@3mo/tab": "x",
41
42
  "@3mo/text-fields": "x",
42
- "@a11d/array.prototype.group": "x",
43
43
  "@a11d/lit": "x",
44
44
  "tslib": "x",
45
45
  "typescript-memoize": "1.x"
@@ -1,12 +0,0 @@
1
- import { DateList } from './DateList.js';
2
- export declare class MonthList extends DateList {
3
- static get styles(): import("@a11d/lit").CSSResult;
4
- private get monthNames();
5
- protected get listItemsTemplate(): import("lit-html").HTMLTemplateResult;
6
- }
7
- declare global {
8
- interface HTMLElementTagNameMap {
9
- 'mo-month-list': MonthList;
10
- }
11
- }
12
- //# sourceMappingURL=MonthList.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MonthList.d.ts","sourceRoot":"","sources":["../../selection/MonthList.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,qBACa,SAAU,SAAQ,QAAQ;IACtC,WAAoB,MAAM,kCAQzB;IAED,OAAO,KAAK,UAAU,GAKrB;IAED,cAAuB,iBAAiB,0CAWvC;CACD;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,eAAe,EAAE,SAAS,CAAA;KAC1B;CACD"}
@@ -1,36 +0,0 @@
1
- import { __decorate } from "tslib";
2
- import { component, css, html } from '@a11d/lit';
3
- import { DateList } from './DateList.js';
4
- let MonthList = class MonthList extends DateList {
5
- static get styles() {
6
- return css `
7
- ${super.styles}
8
-
9
- mo-scroller {
10
- min-width: 125px;
11
- }
12
- `;
13
- }
14
- get monthNames() {
15
- return new Array(this.navigatingValue.monthsInYear)
16
- .fill(undefined)
17
- .map((_, i) => this.navigatingValue.yearStart.add({ months: i }))
18
- .map(date => [date.month, date.format({ month: 'long' })]);
19
- }
20
- get listItemsTemplate() {
21
- return html `
22
- ${this.monthNames.map(([month, name]) => html `
23
- <mo-selectable-list-item
24
- ?selected=${this.value?.month === month}
25
- ?data-navigating=${this.navigatingValue.month === month}
26
- @navigate=${() => this.navigate.dispatch(this.navigatingValue.with({ month }))}
27
- @change=${(e) => !e.selected ? void 0 : this.change.dispatch((this.value ?? new DateTime).with({ month }))}
28
- >${name}</mo-selectable-list-item>
29
- `)}
30
- `;
31
- }
32
- };
33
- MonthList = __decorate([
34
- component('mo-month-list')
35
- ], MonthList);
36
- export { MonthList };
@@ -1,12 +0,0 @@
1
- import { DateList } from './DateList.js';
2
- export declare class YearList extends DateList {
3
- private readonly nowYear;
4
- private years;
5
- protected get listItemsTemplate(): import("lit-html").HTMLTemplateResult;
6
- }
7
- declare global {
8
- interface HTMLElementTagNameMap {
9
- 'mo-year-list': YearList;
10
- }
11
- }
12
- //# sourceMappingURL=YearList.d.ts.map
@@ -1 +0,0 @@
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,0CAWvC;CACD;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,cAAc,EAAE,QAAQ,CAAA;KACxB;CACD"}
@@ -1,28 +0,0 @@
1
- import { __decorate } from "tslib";
2
- import { component, html } from '@a11d/lit';
3
- import { DateList } from './DateList.js';
4
- let YearList = class YearList extends DateList {
5
- constructor() {
6
- super(...arguments);
7
- this.nowYear = new DateTime().year;
8
- this.years = new Array(150)
9
- .fill(undefined)
10
- .map((_, i) => this.nowYear - 100 + i);
11
- }
12
- get listItemsTemplate() {
13
- return html `
14
- ${this.years.map(year => html `
15
- <mo-selectable-list-item
16
- ?selected=${this.value?.year === year}
17
- ?data-navigating=${this.navigatingValue.year === year}
18
- @navigate=${() => this.navigate.dispatch(this.navigatingValue.with({ year }))}
19
- @change=${(e) => !e.selected ? void 0 : this.change.dispatch((this.value ?? new DateTime).with({ year }))}
20
- >${year.format()}</mo-selectable-list-item>
21
- `)}
22
- `;
23
- }
24
- };
25
- YearList = __decorate([
26
- component('mo-year-list')
27
- ], YearList);
28
- export { YearList };
@@ -1,24 +0,0 @@
1
- import { Component, type ClassInfo } from '@a11d/lit';
2
- import '@a11d/array.prototype.group';
3
- /**
4
- * @fires dayClick - Dispatched when a day is clicked, with the clicked date as detail.
5
- */
6
- export declare class Calendar extends Component {
7
- readonly dayClick: EventDispatcher<DateTime>;
8
- private static rangeOf;
9
- includeWeek: boolean;
10
- navigatingValue: import("@3mo/date-time/DateTime.js").DateTime;
11
- private days;
12
- static get styles(): import("@a11d/lit").CSSResult;
13
- private get columns();
14
- private getColumnName;
15
- protected get template(): import("lit-html").HTMLTemplateResult;
16
- protected getDayElementClasses(day: DateTime): ClassInfo;
17
- private get today();
18
- }
19
- declare global {
20
- interface HTMLElementTagNameMap {
21
- 'mo-calendar': Calendar;
22
- }
23
- }
24
- //# sourceMappingURL=Calendar.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Calendar.d.ts","sourceRoot":"","sources":["../../../selection/calendar/Calendar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAA4C,KAAK,SAAS,EAAgB,MAAM,WAAW,CAAA;AAC7G,OAAO,6BAA6B,CAAA;AAGpC;;GAEG;AACH,qBACa,QAAS,SAAQ,SAAS;IAC7B,QAAQ,CAAC,QAAQ,EAAG,eAAe,CAAC,QAAQ,CAAC,CAAA;IAEtD,OAAO,CAAC,MAAM,CAAE,OAAO;IAOqB,WAAW,UAAQ;IAQ5D,eAAe,gDAAe;IAExB,OAAO,CAAC,IAAI,CAAwB;IAE7C,WAAoB,MAAM,kCA2DzB;IAED,OAAO,KAAK,OAAO,GAMlB;IAED,OAAO,CAAC,aAAa;IAIrB,cAAuB,QAAQ,0CAkC9B;IAED,SAAS,CAAC,oBAAoB,CAAC,GAAG,EAAE,QAAQ,GAAG,SAAS;IASxD,OAAO,KAAK,KAAK,GAAqC;CACtD;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,aAAa,EAAE,QAAQ,CAAA;KACvB;CACD"}
@@ -1,160 +0,0 @@
1
- import { __decorate } from "tslib";
2
- import { Component, css, component, html, property, classMap, state, event } from '@a11d/lit';
3
- import '@a11d/array.prototype.group';
4
- import { MemoizeExpiring as memoizeExpiring } from 'typescript-memoize';
5
- /**
6
- * @fires dayClick - Dispatched when a day is clicked, with the clicked date as detail.
7
- */
8
- let Calendar = class Calendar extends Component {
9
- constructor() {
10
- super(...arguments);
11
- this.includeWeek = false;
12
- this.navigatingValue = new DateTime;
13
- this.days = new Array();
14
- }
15
- static *rangeOf(start, end) {
16
- while (!start.isAfter(end)) {
17
- yield start;
18
- start = start.add({ days: 1 });
19
- }
20
- }
21
- static get styles() {
22
- return css `
23
- :host {
24
- --mo-calendar-day-size: 36px;
25
- --mo-calendar-week-number-width: var(--mo-calendar-day-size);
26
- padding: 0.5rem;
27
- }
28
-
29
- .month {
30
- place-items: center;
31
-
32
- .heading {
33
- font-weight: 500;
34
- font-size: 16px;
35
- grid-column: 1 / -1;
36
- place-self: stretch;
37
- display: flex;
38
- align-items: center;
39
- padding-inline-start: 6px;
40
- padding-block-end: 0.5rem;
41
- }
42
-
43
- .header {
44
- text-align: center;
45
- color: var(--mo-color-gray);
46
- padding-block: 0.25rem
47
- }
48
- }
49
-
50
- .week {
51
- color: var(--mo-color-gray);
52
- }
53
-
54
- .day {
55
- text-align: center;
56
- border-radius: var(--mo-border-radius);
57
- cursor: pointer;
58
- font-weight: 500;
59
- user-select: none;
60
- font-size: medium;
61
- width: var(--mo-calendar-day-size);
62
- -webkit-user-select: none;
63
- align-items: center;
64
- justify-content: center;
65
- height: var(--mo-calendar-day-size);
66
-
67
- &:hover {
68
- background: var(--mo-color-transparent-gray-3);
69
- }
70
-
71
- &.outsideMonth {
72
- color: var(--mo-color-gray);
73
- }
74
-
75
- &.today {
76
- outline: 2px dashed var(--mo-color-gray-transparent);
77
- }
78
- }
79
- `;
80
- }
81
- get columns() {
82
- const daysInWeek = this.days[0]?.daysInWeek ?? 7;
83
- return [
84
- !this.includeWeek ? undefined : '[week] var(--mo-calendar-week-number-width)',
85
- ...this.days.slice(0, daysInWeek).map(day => `[${this.getColumnName(day)}] var(--mo-calendar-day-size)`),
86
- ].join(' ');
87
- }
88
- getColumnName(date) {
89
- return `day-${date.dayOfWeek}`;
90
- }
91
- get template() {
92
- return html `
93
- <mo-grid class='month'
94
- rows='repeat(auto-fill, var(--mo-calendar-day-size))'
95
- columns=${this.columns}
96
- >
97
- <div class='heading' style='grid-column: 1 / -1'>
98
- ${this.navigatingValue.format({ year: 'numeric' })}
99
- ${this.navigatingValue.format({ month: 'long' })}
100
- </div>
101
-
102
- <mo-grid class='header' columns='subgrid' style='grid-column: 1 / -1'>
103
- ${this.includeWeek === false ? html.nothing : html `<div></div>`}
104
- ${this.days.slice(0, this.days[0]?.daysInWeek).map(day => html `
105
- <span style='grid-column: ${this.getColumnName(day)}' title=${day.format({ weekday: 'long' })}>
106
- ${day.format({ weekday: 'narrow' })}
107
- </span>
108
- `)}
109
- </mo-grid>
110
-
111
- ${this.days.map(day => html `
112
- ${this.includeWeek === false || day.dayOfWeek !== 1 ? html.nothing : html `
113
- <div class='week' style='grid-column: week'>${day.weekOfYear}</div>
114
- `}
115
- <mo-flex tabindex='0'
116
- style='grid-column: ${this.getColumnName(day)}'
117
- class=${classMap(this.getDayElementClasses(day))}
118
- @click=${() => this.dayClick.dispatch(day)}
119
- >
120
- ${day.format({ day: 'numeric' })}
121
- </mo-flex>
122
- `)}
123
- </mo-grid>
124
- `;
125
- }
126
- getDayElementClasses(day) {
127
- return {
128
- day: true,
129
- today: this.today.equals(day.dayStart),
130
- outsideMonth: day.month !== this.navigatingValue.month
131
- };
132
- }
133
- get today() { return new DateTime().dayStart; }
134
- };
135
- __decorate([
136
- event()
137
- ], Calendar.prototype, "dayClick", void 0);
138
- __decorate([
139
- property({ type: Boolean, reflect: true })
140
- ], Calendar.prototype, "includeWeek", void 0);
141
- __decorate([
142
- property({
143
- type: Object,
144
- updated() {
145
- const start = this.navigatingValue.monthStart.weekStart;
146
- const end = this.navigatingValue.monthEnd.weekEnd;
147
- this.days = [...Calendar.rangeOf(start, end)];
148
- }
149
- })
150
- ], Calendar.prototype, "navigatingValue", void 0);
151
- __decorate([
152
- state()
153
- ], Calendar.prototype, "days", void 0);
154
- __decorate([
155
- memoizeExpiring(60000)
156
- ], Calendar.prototype, "today", null);
157
- Calendar = __decorate([
158
- component('mo-calendar')
159
- ], Calendar);
160
- export { Calendar };
@@ -1,20 +0,0 @@
1
- import { type PropertyValues } from '@a11d/lit';
2
- import { Calendar } from './Calendar.js';
3
- import { type DateTime } from '@3mo/date-time';
4
- export declare class SelectableCalendar extends Calendar {
5
- value?: DateTimeRange;
6
- private readonly monthElement;
7
- protected updated(pops: PropertyValues<this>): void;
8
- static get styles(): import("@a11d/lit").CSSResult;
9
- protected getDayElementClasses(day: DateTime): {
10
- start: boolean;
11
- end: boolean;
12
- selected: boolean;
13
- };
14
- }
15
- declare global {
16
- interface HTMLElementTagNameMap {
17
- 'mo-selectable-calendar': SelectableCalendar;
18
- }
19
- }
20
- //# sourceMappingURL=SelectableCalendar.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SelectableCalendar.d.ts","sourceRoot":"","sources":["../../../selection/calendar/SelectableCalendar.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8C,KAAK,cAAc,EAAE,MAAM,WAAW,CAAA;AAC3F,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAE9C,qBACa,kBAAmB,SAAQ,QAAQ;IACnB,KAAK,CAAC,EAAE,aAAa,CAAA;IAEhC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAc;cAEzC,OAAO,CAAC,IAAI,EAAE,cAAc,CAAC,IAAI,CAAC;IASrD,WAAoB,MAAM,kCA0CzB;cAEkB,oBAAoB,CAAC,GAAG,EAAE,QAAQ;;;;;CAUrD;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,wBAAwB,EAAE,kBAAkB,CAAA;KAC5C;CACD"}
@@ -1,76 +0,0 @@
1
- import { __decorate } from "tslib";
2
- import { component, css, property, query, unsafeCSS } from '@a11d/lit';
3
- import { Calendar } from './Calendar.js';
4
- let SelectableCalendar = class SelectableCalendar extends Calendar {
5
- updated(pops) {
6
- super.updated(pops);
7
- this.monthElement.dataset.selection = this.dataset.selection;
8
- this.monthElement.toggleAttribute('data-start-exists', !!this.value?.start);
9
- this.monthElement.toggleAttribute('data-end-exists', !!this.value?.end);
10
- this.monthElement.toggleAttribute('data-start-behind', this.value?.start?.isBefore(this.navigatingValue.monthEnd.weekEnd) ?? false);
11
- this.monthElement.toggleAttribute('data-end-ahead', this.value?.end?.isAfter(this.navigatingValue.monthEnd.weekEnd) ?? false);
12
- }
13
- static get styles() {
14
- const getRangeStyles = ({ start, end }) => {
15
- return css `
16
- .day${unsafeCSS(start)}, .day${unsafeCSS(end)} {
17
- background: var(--mo-color-accent-transparent) !important;
18
- color: color-mix(in srgb, var(--mo-color-accent), var(--mo-color-foreground));
19
- }
20
-
21
- .day${unsafeCSS(start)} ~ :not(${unsafeCSS(end)}):not(${unsafeCSS(end)} ~ *), /* Start is visible, end is visible or not */
22
- &[data-start-exists]:has(${unsafeCSS(end)}):not(:has(${unsafeCSS(start)})) .day:not(${unsafeCSS(end)}):not(${unsafeCSS(end)} ~ *), /* Start is not visible, end is visible */
23
- &[data-start-before][data-end-ahead] .day /* Start is before, end is after */
24
- {
25
- background: color-mix(in srgb, var(--mo-color-accent), transparent 92%);
26
- }
27
- `;
28
- };
29
- return css `
30
- ${super.styles}
31
-
32
- .day.selected {
33
- background: var(--mo-color-accent-transparent);
34
- color: color-mix(in srgb, var(--mo-color-accent), var(--mo-color-foreground)) !important;
35
- }
36
-
37
- .month {
38
- &:not(:hover) {
39
- ${getRangeStyles({ start: '.selected.start', end: '.selected.end' })};
40
- }
41
-
42
- &:hover {
43
- /* After start is selected: */
44
- &[data-selection=end] {
45
- ${getRangeStyles({ start: '.selected.start', end: ':hover' })};
46
- }
47
-
48
- /* After end is selected: */
49
- &[data-selection=start] {
50
- ${getRangeStyles({ start: ':hover', end: '.selected.end' })};
51
- }
52
- }
53
- }
54
- `;
55
- }
56
- getDayElementClasses(day) {
57
- const start = this.value?.start?.dayStart.equals(day.dayStart) ?? false;
58
- const end = this.value?.end?.dayStart.equals(day.dayStart) ?? false;
59
- return {
60
- ...super.getDayElementClasses(day),
61
- start,
62
- end,
63
- selected: start || end,
64
- };
65
- }
66
- };
67
- __decorate([
68
- property({ type: Object })
69
- ], SelectableCalendar.prototype, "value", void 0);
70
- __decorate([
71
- query('.month')
72
- ], SelectableCalendar.prototype, "monthElement", void 0);
73
- SelectableCalendar = __decorate([
74
- component('mo-selectable-calendar')
75
- ], SelectableCalendar);
76
- export { SelectableCalendar };
@@ -1,3 +0,0 @@
1
- export * from './Calendar.js';
2
- export * from './SelectableCalendar.js';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../selection/calendar/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA;AAC7B,cAAc,yBAAyB,CAAA"}
@@ -1,2 +0,0 @@
1
- export * from './Calendar.js';
2
- export * from './SelectableCalendar.js';