@3mo/date-time-fields 0.0.15 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/dist/DateParser.js +21 -21
  2. package/dist/DateRangeParser.js +6 -6
  3. package/dist/FieldDate.d.ts +5 -15
  4. package/dist/FieldDate.d.ts.map +1 -1
  5. package/dist/FieldDate.js +6 -34
  6. package/dist/FieldDateRange.d.ts +5 -27
  7. package/dist/FieldDateRange.d.ts.map +1 -1
  8. package/dist/FieldDateRange.js +7 -113
  9. package/dist/FieldDateTime.d.ts +17 -0
  10. package/dist/FieldDateTime.d.ts.map +1 -0
  11. package/dist/FieldDateTime.js +36 -0
  12. package/dist/FieldDateTimeBase.d.ts +50 -0
  13. package/dist/FieldDateTimeBase.d.ts.map +1 -0
  14. package/dist/FieldDateTimeBase.js +236 -0
  15. package/dist/FieldDateTimeRange.d.ts +35 -0
  16. package/dist/FieldDateTimeRange.d.ts.map +1 -0
  17. package/dist/FieldDateTimeRange.js +91 -0
  18. package/dist/FieldTime.d.ts.map +1 -1
  19. package/dist/FieldTime.js +1 -0
  20. package/dist/index.d.ts +8 -2
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js +8 -2
  23. package/dist/selection/DateList.d.ts +18 -0
  24. package/dist/selection/DateList.d.ts.map +1 -0
  25. package/dist/selection/DateList.js +69 -0
  26. package/dist/selection/HourList.d.ts +10 -0
  27. package/dist/selection/HourList.d.ts.map +1 -0
  28. package/dist/selection/HourList.js +23 -0
  29. package/dist/selection/MinuteList.d.ts +10 -0
  30. package/dist/selection/MinuteList.d.ts.map +1 -0
  31. package/dist/selection/MinuteList.js +23 -0
  32. package/dist/selection/MonthList.d.ts +12 -0
  33. package/dist/selection/MonthList.d.ts.map +1 -0
  34. package/dist/selection/MonthList.js +38 -0
  35. package/dist/selection/SecondList.d.ts +10 -0
  36. package/dist/selection/SecondList.d.ts.map +1 -0
  37. package/dist/selection/SecondList.js +23 -0
  38. package/dist/selection/YearList.d.ts +11 -0
  39. package/dist/selection/YearList.d.ts.map +1 -0
  40. package/dist/selection/YearList.js +27 -0
  41. package/dist/selection/calendar/Calendar.d.ts +18 -0
  42. package/dist/selection/calendar/Calendar.d.ts.map +1 -0
  43. package/dist/selection/calendar/Calendar.js +123 -0
  44. package/dist/selection/calendar/SelectableCalendar.d.ts +18 -0
  45. package/dist/selection/calendar/SelectableCalendar.d.ts.map +1 -0
  46. package/dist/selection/calendar/SelectableCalendar.js +34 -0
  47. package/dist/selection/calendar/SelectableRangeCalendar.d.ts +19 -0
  48. package/dist/selection/calendar/SelectableRangeCalendar.d.ts.map +1 -0
  49. package/dist/selection/calendar/SelectableRangeCalendar.js +45 -0
  50. package/dist/selection/calendar/index.d.ts +4 -0
  51. package/dist/selection/calendar/index.d.ts.map +1 -0
  52. package/dist/{calendar → selection/calendar}/index.js +1 -1
  53. package/dist/selection/index.d.ts +7 -0
  54. package/dist/selection/index.d.ts.map +1 -0
  55. package/dist/selection/index.js +6 -0
  56. package/dist/tsconfig.tsbuildinfo +1 -1
  57. package/package.json +12 -7
  58. package/dist/FieldDateBase.d.ts +0 -29
  59. package/dist/FieldDateBase.d.ts.map +0 -1
  60. package/dist/FieldDateBase.js +0 -111
  61. package/dist/calendar/Calendar.d.ts +0 -30
  62. package/dist/calendar/Calendar.d.ts.map +0 -1
  63. package/dist/calendar/Calendar.js +0 -203
  64. package/dist/calendar/CalendarSelectionAdapter.d.ts +0 -11
  65. package/dist/calendar/CalendarSelectionAdapter.d.ts.map +0 -1
  66. package/dist/calendar/CalendarSelectionAdapter.js +0 -11
  67. package/dist/calendar/SelectableCalendar.d.ts +0 -17
  68. package/dist/calendar/SelectableCalendar.d.ts.map +0 -1
  69. package/dist/calendar/SelectableCalendar.js +0 -35
  70. package/dist/calendar/index.d.ts +0 -4
  71. package/dist/calendar/index.d.ts.map +0 -1
@@ -0,0 +1,236 @@
1
+ import { __decorate } from "tslib";
2
+ import { cache, css, html, live, nothing, property, style } from '@a11d/lit';
3
+ import { InputFieldComponent } from '@3mo/field';
4
+ function isDateTimePrecisionSmaller(precision, other) {
5
+ const precisions = [
6
+ "year" /* FieldDateTimePrecision.Year */,
7
+ "month" /* FieldDateTimePrecision.Month */,
8
+ "day" /* FieldDateTimePrecision.Day */,
9
+ "hour" /* FieldDateTimePrecision.Hour */,
10
+ "minute" /* FieldDateTimePrecision.Minute */,
11
+ "second" /* FieldDateTimePrecision.Second */,
12
+ ];
13
+ return precisions.indexOf(precision) < precisions.indexOf(other);
14
+ }
15
+ /**
16
+ * @attr open - Whether the date picker is open
17
+ * @attr hideDatePicker - Hide the date picker
18
+ * @attr shortcutReferenceDate - The date to use as a reference for shortcuts
19
+ * @attr precision - The precision of the date picker. Defaults to 'minute'
20
+ */
21
+ export class FieldDateTimeBase extends InputFieldComponent {
22
+ constructor() {
23
+ super(...arguments);
24
+ this.open = false;
25
+ this.hideDatePicker = false;
26
+ this.shortcutReferenceDate = new DateTime;
27
+ this.precision = "minute" /* FieldDateTimePrecision.Minute */;
28
+ this.calendarIconButtonIcon = 'today';
29
+ }
30
+ get formatOptions() {
31
+ var _a, _b;
32
+ return {
33
+ calendar: (_a = this.selectedDate) === null || _a === void 0 ? void 0 : _a.calendarId,
34
+ timeZone: (_b = this.selectedDate) === null || _b === void 0 ? void 0 : _b.timeZoneId,
35
+ year: 'numeric',
36
+ month: isDateTimePrecisionSmaller(this.precision, "month" /* FieldDateTimePrecision.Month */) ? undefined : '2-digit',
37
+ day: isDateTimePrecisionSmaller(this.precision, "day" /* FieldDateTimePrecision.Day */) ? undefined : '2-digit',
38
+ hour: isDateTimePrecisionSmaller(this.precision, "hour" /* FieldDateTimePrecision.Hour */) ? undefined : '2-digit',
39
+ minute: isDateTimePrecisionSmaller(this.precision, "minute" /* FieldDateTimePrecision.Minute */) ? undefined : '2-digit',
40
+ second: isDateTimePrecisionSmaller(this.precision, "second" /* FieldDateTimePrecision.Second */) ? undefined : '2-digit',
41
+ hourCycle: 'h23',
42
+ };
43
+ }
44
+ roundToPrecision(date) {
45
+ return date.with({
46
+ year: date.year,
47
+ month: isDateTimePrecisionSmaller(this.precision, "month" /* FieldDateTimePrecision.Month */) ? 1 : date.month,
48
+ day: isDateTimePrecisionSmaller(this.precision, "day" /* FieldDateTimePrecision.Day */) ? 1 : date.day,
49
+ hour: isDateTimePrecisionSmaller(this.precision, "hour" /* FieldDateTimePrecision.Hour */) ? 0 : date.hour,
50
+ minute: isDateTimePrecisionSmaller(this.precision, "minute" /* FieldDateTimePrecision.Minute */) ? 0 : date.minute,
51
+ second: isDateTimePrecisionSmaller(this.precision, "second" /* FieldDateTimePrecision.Second */) ? 0 : date.second,
52
+ });
53
+ }
54
+ handleChange(value, e) {
55
+ super.handleChange(value, e);
56
+ this.inputStringValue = this.valueToInputValue(value);
57
+ }
58
+ get isActive() {
59
+ return super.isActive || this.open;
60
+ }
61
+ static get styles() {
62
+ return css `
63
+ ${super.styles}
64
+
65
+ :host {
66
+ position: relative;
67
+ }
68
+
69
+ mo-popover {
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
+ }
75
+
76
+ #selector {
77
+ min-height: 175px;
78
+ }
79
+
80
+ .timezone {
81
+ padding: 3px;
82
+ font-size: small;
83
+ text-align: end;
84
+ font-weight: 500;
85
+ color: var(--mo-color-gray);
86
+ }
87
+ `;
88
+ }
89
+ get template() {
90
+ return html `
91
+ ${super.template}
92
+ ${this.popoverTemplate}
93
+ `;
94
+ }
95
+ get endSlotTemplate() {
96
+ return html `
97
+ ${super.endSlotTemplate}
98
+ ${this.calendarIconButtonTemplate}
99
+ `;
100
+ }
101
+ get inputTemplate() {
102
+ return html `
103
+ <input
104
+ part='input'
105
+ ?readonly=${this.readonly}
106
+ ?required=${this.required}
107
+ ?disabled=${this.disabled}
108
+ .value=${live(this.inputStringValue || '')}
109
+ @input=${(e) => this.handleInput(this.inputValueToValue(this.inputElement.value || ''), e)}
110
+ @change=${(e) => this.handleChange(this.inputValueToValue(this.inputElement.value || ''), e)}
111
+ >
112
+ `;
113
+ }
114
+ get calendarIconButtonTemplate() {
115
+ return this.hideDatePicker ? nothing : html `
116
+ <mo-icon-button tabindex='-1' dense slot='end'
117
+ icon=${this.calendarIconButtonIcon}
118
+ ${style({ color: this.isActive ? 'var(--mo-color-accent)' : 'var(--mo-color-gray)' })}
119
+ @click=${() => this.open = !this.open}>
120
+ </mo-icon-button>
121
+ `;
122
+ }
123
+ get popoverTemplate() {
124
+ return this.hideDatePicker ? nothing : html `
125
+ <mo-popover tabindex='-1' fixed openOnFocus
126
+ .anchor=${this}
127
+ ?open=${this.open}
128
+ @openChange=${(e) => this.open = e.detail}
129
+ >${cache(!this.open ? nothing : this.popoverContentTemplate)}</mo-popover>
130
+ `;
131
+ }
132
+ get popoverContentTemplate() {
133
+ return html `
134
+ <mo-flex id='selector' direction='horizontal' style='height: 100%'>
135
+ ${this.dateTemplate}
136
+ ${this.timeTemplate}
137
+ </mo-flex>
138
+ `;
139
+ }
140
+ get dateTemplate() {
141
+ return html `
142
+ ${this.yearListTemplate}
143
+ ${this.monthListTemplate}
144
+ ${this.dayTemplate}
145
+ `;
146
+ }
147
+ get yearListTemplate() {
148
+ return html `
149
+ <mo-year-list
150
+ .navigatingValue=${this.navigatingDate}
151
+ .value=${this.selectedDate}
152
+ @change=${(e) => this.handleSelectedDateChange(e.detail, "year" /* FieldDateTimePrecision.Year */)}
153
+ ></mo-year-list>
154
+ `;
155
+ }
156
+ get monthListTemplate() {
157
+ return ["year" /* FieldDateTimePrecision.Year */].includes(this.precision) ? nothing : html `
158
+ <mo-month-list
159
+ .navigatingValue=${this.navigatingDate}
160
+ .value=${this.selectedDate}
161
+ @change=${(e) => this.handleSelectedDateChange(e.detail, "month" /* FieldDateTimePrecision.Month */)}
162
+ ></mo-month-list>
163
+ `;
164
+ }
165
+ get dayTemplate() {
166
+ return ["year" /* FieldDateTimePrecision.Year */, "month" /* FieldDateTimePrecision.Month */].includes(this.precision) ? nothing : this.calendarTemplate;
167
+ }
168
+ get timeTemplate() {
169
+ var _a, _b, _c, _d;
170
+ return ["year" /* FieldDateTimePrecision.Year */, "month" /* FieldDateTimePrecision.Month */, "day" /* FieldDateTimePrecision.Day */].includes(this.precision) ? nothing : html `
171
+ <mo-flex gap='6px'>
172
+ <div class='timezone'>
173
+ ${(_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}
174
+ (${(_d = (_c = this.navigatingDate) === null || _c === void 0 ? void 0 : _c.formatToParts({ timeZoneName: 'shortOffset' }).find(x => x.type === 'timeZoneName')) === null || _d === void 0 ? void 0 : _d.value})
175
+ </div>
176
+ <mo-flex direction='horizontal' style='flex: 1'>
177
+ ${this.hourListTemplate}
178
+ ${this.minuteListTemplate}
179
+ ${this.secondListTemplate}
180
+ </mo-flex>
181
+ </mo-flex>
182
+ `;
183
+ }
184
+ get hourListTemplate() {
185
+ return html `
186
+ <mo-hour-list style='flex: 1'
187
+ .navigatingValue=${this.navigatingDate}
188
+ .value=${this.selectedDate}
189
+ @change=${(e) => this.handleSelectedDateChange(e.detail, "hour" /* FieldDateTimePrecision.Hour */)}
190
+ ></mo-hour-list>
191
+ `;
192
+ }
193
+ get minuteListTemplate() {
194
+ return ["hour" /* FieldDateTimePrecision.Hour */].includes(this.precision) ? nothing : html `
195
+ <mo-minute-list style='flex: 1'
196
+ .navigatingValue=${this.navigatingDate}
197
+ .value=${this.selectedDate}
198
+ @change=${(e) => this.handleSelectedDateChange(e.detail, "minute" /* FieldDateTimePrecision.Minute */)}
199
+ ></mo-minute-list>
200
+ `;
201
+ }
202
+ get secondListTemplate() {
203
+ return ["hour" /* FieldDateTimePrecision.Hour */, "minute" /* FieldDateTimePrecision.Minute */].includes(this.precision) ? nothing : html `
204
+ <mo-second-list style='flex: 1'
205
+ .navigatingValue=${this.navigatingDate}
206
+ .value=${this.selectedDate}
207
+ @change=${(e) => this.handleSelectedDateChange(e.detail, "second" /* FieldDateTimePrecision.Second */)}
208
+ ></mo-second-list>
209
+ `;
210
+ }
211
+ handleSelectedDateChange(date, precision) {
212
+ date;
213
+ precision;
214
+ this.requestUpdate();
215
+ }
216
+ }
217
+ __decorate([
218
+ property({
219
+ type: Boolean,
220
+ reflect: true,
221
+ updated(open, wasOpen) {
222
+ if (open === false && wasOpen === true) {
223
+ this.change.dispatch(this.value);
224
+ }
225
+ }
226
+ })
227
+ ], FieldDateTimeBase.prototype, "open", void 0);
228
+ __decorate([
229
+ property({ type: Boolean })
230
+ ], FieldDateTimeBase.prototype, "hideDatePicker", void 0);
231
+ __decorate([
232
+ property({ type: Object })
233
+ ], FieldDateTimeBase.prototype, "shortcutReferenceDate", void 0);
234
+ __decorate([
235
+ property()
236
+ ], FieldDateTimeBase.prototype, "precision", void 0);
@@ -0,0 +1,35 @@
1
+ import { MaterialIcon } from '@3mo/icon';
2
+ import { FieldDateTimeBase as FieldDateTimeBase, FieldDateTimePrecision } from './FieldDateTimeBase.js';
3
+ declare const enum FieldDateRangeSelection {
4
+ Start = "start",
5
+ End = "end"
6
+ }
7
+ /**
8
+ * @element mo-field-date-range
9
+ *
10
+ * @attr selection - The selected date range. Either "start" or "end". Defaults to "start".
11
+ * @attr value - The selected date range.
12
+ *
13
+ * @i18n "Start"
14
+ * @i18n "End"
15
+ */
16
+ export declare class FieldDateTimeRange extends FieldDateTimeBase<DateTimeRange | undefined> {
17
+ protected get navigatingDate(): import("@3mo/date-time/DateTime.js").DateTime;
18
+ protected get selectedDate(): import("@3mo/date-time/DateTime.js").DateTime | undefined;
19
+ selection: FieldDateRangeSelection;
20
+ value?: DateTimeRange;
21
+ static get styles(): import("@a11d/lit").CSSResult;
22
+ protected calendarIconButtonIcon: MaterialIcon;
23
+ protected get calendarTemplate(): import("lit-html").TemplateResult<1>;
24
+ protected get popoverContentTemplate(): import("lit-html").TemplateResult<1>;
25
+ handleSelectedDateChange(date: DateTime, precision: FieldDateTimePrecision): void;
26
+ protected valueToInputValue(value: DateTimeRange | undefined): string;
27
+ protected inputValueToValue(value: string): import("@3mo/date-time/DateTimeRange.js").DateTimeRange | undefined;
28
+ }
29
+ declare global {
30
+ interface HTMLElementTagNameMap {
31
+ 'mo-field-date-time-range': FieldDateTimeRange;
32
+ }
33
+ }
34
+ export {};
35
+ //# sourceMappingURL=FieldDateTimeRange.d.ts.map
@@ -0,0 +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;AAGvG,mBAAW,uBAAuB;IACjC,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,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"}
@@ -0,0 +1,91 @@
1
+ import { __decorate } from "tslib";
2
+ import { component, css, html, property } from '@a11d/lit';
3
+ import { FieldDateTimeBase as FieldDateTimeBase } from './FieldDateTimeBase.js';
4
+ import { DateRangeParser } from './DateRangeParser.js';
5
+ /**
6
+ * @element mo-field-date-range
7
+ *
8
+ * @attr selection - The selected date range. Either "start" or "end". Defaults to "start".
9
+ * @attr value - The selected date range.
10
+ *
11
+ * @i18n "Start"
12
+ * @i18n "End"
13
+ */
14
+ let FieldDateTimeRange = class FieldDateTimeRange extends FieldDateTimeBase {
15
+ constructor() {
16
+ super(...arguments);
17
+ this.selection = "start" /* FieldDateRangeSelection.Start */;
18
+ this.calendarIconButtonIcon = 'date_range';
19
+ }
20
+ get navigatingDate() { var _a, _b, _c; return (_c = (this.selection === "start" /* 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(); }
21
+ get selectedDate() { var _a, _b; return this.selection === "start" /* 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
+ static get styles() {
23
+ return css `
24
+ ${super.styles}
25
+
26
+ mo-tab-bar {
27
+ max-width: 200px;
28
+ place-self: center;
29
+ padding-block: 4px;
30
+ }
31
+
32
+ mo-tab {
33
+ --mdc-tab-height: 40px;
34
+ }
35
+
36
+ mo-tab:not([active]) {
37
+ opacity: 0.5;
38
+ }
39
+ `;
40
+ }
41
+ get calendarTemplate() {
42
+ return html `
43
+ <mo-selectable-range-calendar
44
+ .navigatingValue=${this.navigatingDate}
45
+ .dateRange=${this.value}
46
+ @change=${(e) => this.handleSelectedDateChange(e.detail, "day" /* FieldDateTimePrecision.Day */)}
47
+ ></mo-selectable-range-calendar>
48
+ `;
49
+ }
50
+ get popoverContentTemplate() {
51
+ return html `
52
+ <mo-flex>
53
+ <mo-tab-bar value=${this.selection} @change=${(e) => this.selection = e.detail}>
54
+ <mo-tab value=${"start" /* FieldDateRangeSelection.Start */} label=${t('Start')}></mo-tab>
55
+ <mo-tab value=${"end" /* FieldDateRangeSelection.End */} label=${t('End')}></mo-tab>
56
+ </mo-tab-bar>
57
+ </mo-flex>
58
+
59
+ ${super.popoverContentTemplate}
60
+ `;
61
+ }
62
+ handleSelectedDateChange(date, precision) {
63
+ var _a, _b;
64
+ this.value = this.selection === "start" /* FieldDateRangeSelection.Start */
65
+ ? new DateTimeRange(this.roundToPrecision(date), (_a = this.value) === null || _a === void 0 ? void 0 : _a.end)
66
+ : new DateTimeRange((_b = this.value) === null || _b === void 0 ? void 0 : _b.start, this.roundToPrecision(date));
67
+ if (this.precision === precision) {
68
+ this.selection = this.selection === "start" /* FieldDateRangeSelection.Start */
69
+ ? "end" /* FieldDateRangeSelection.End */
70
+ : "start" /* FieldDateRangeSelection.Start */;
71
+ }
72
+ super.handleSelectedDateChange(date, precision);
73
+ }
74
+ valueToInputValue(value) {
75
+ var _a;
76
+ return value ? (_a = value.format(this.formatOptions)) !== null && _a !== void 0 ? _a : '' : '';
77
+ }
78
+ inputValueToValue(value) {
79
+ return value ? DateRangeParser.parse(value, this.shortcutReferenceDate) : undefined;
80
+ }
81
+ };
82
+ __decorate([
83
+ property()
84
+ ], FieldDateTimeRange.prototype, "selection", void 0);
85
+ __decorate([
86
+ property({ type: Object })
87
+ ], FieldDateTimeRange.prototype, "value", void 0);
88
+ FieldDateTimeRange = __decorate([
89
+ component('mo-field-date-time-range')
90
+ ], FieldDateTimeRange);
91
+ export { FieldDateTimeRange };
@@ -1 +1 @@
1
- {"version":3,"file":"FieldTime.d.ts","sourceRoot":"","sources":["../FieldTime.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAE5C,qBACa,SAAU,SAAQ,SAAS;IACvC,SAAkB,SAAS,UAAS;IAEpC,cAAuB,iBAAiB,yCAKvC;CACD;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,eAAe,EAAE,SAAS,CAAA;KAC1B;CACD"}
1
+ {"version":3,"file":"FieldTime.d.ts","sourceRoot":"","sources":["../FieldTime.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAI5C,qBACa,SAAU,SAAQ,SAAS;IACvC,SAAkB,SAAS,UAAS;IAEpC,cAAuB,iBAAiB,yCAKvC;CACD;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,eAAe,EAAE,SAAS,CAAA;KAC1B;CACD"}
package/dist/FieldTime.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { __decorate } from "tslib";
2
2
  import { component, html, style } from '@a11d/lit';
3
3
  import { FieldText } from '@3mo/text-fields';
4
+ // TODO: Migrate to Temporal.PlainTime
4
5
  let FieldTime = class FieldTime extends FieldText {
5
6
  constructor() {
6
7
  super(...arguments);
package/dist/index.d.ts CHANGED
@@ -3,9 +3,15 @@ import '@3mo/icon';
3
3
  import '@3mo/icon-button';
4
4
  import '@3mo/popover';
5
5
  import '@3mo/flex';
6
+ import '@3mo/grid';
6
7
  import '@3mo/field';
8
+ import '@3mo/tab';
9
+ import '@3mo/scroller';
10
+ import '@3mo/list';
11
+ export * from './selection/index.js';
7
12
  export * from './FieldTime.js';
8
- export * from './calendar/index.js';
9
- export * from './FieldDate.js';
13
+ export * from './FieldDateTime.js';
14
+ export * from './FieldDateTimeRange.js';
10
15
  export * from './FieldDateRange.js';
16
+ export * from './FieldDate.js';
11
17
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,CAAA;AACvB,OAAO,WAAW,CAAA;AAClB,OAAO,kBAAkB,CAAA;AACzB,OAAO,cAAc,CAAA;AACrB,OAAO,WAAW,CAAA;AAClB,OAAO,YAAY,CAAA;AACnB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,qBAAqB,CAAA;AACnC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,qBAAqB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,CAAA;AACvB,OAAO,WAAW,CAAA;AAClB,OAAO,kBAAkB,CAAA;AACzB,OAAO,cAAc,CAAA;AACrB,OAAO,WAAW,CAAA;AAClB,OAAO,WAAW,CAAA;AAClB,OAAO,YAAY,CAAA;AACnB,OAAO,UAAU,CAAA;AACjB,OAAO,eAAe,CAAA;AACtB,OAAO,WAAW,CAAA;AAClB,cAAc,sBAAsB,CAAA;AACpC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,oBAAoB,CAAA;AAClC,cAAc,yBAAyB,CAAA;AACvC,cAAc,qBAAqB,CAAA;AACnC,cAAc,gBAAgB,CAAA"}
package/dist/index.js CHANGED
@@ -3,8 +3,14 @@ import '@3mo/icon';
3
3
  import '@3mo/icon-button';
4
4
  import '@3mo/popover';
5
5
  import '@3mo/flex';
6
+ import '@3mo/grid';
6
7
  import '@3mo/field';
8
+ import '@3mo/tab';
9
+ import '@3mo/scroller';
10
+ import '@3mo/list';
11
+ export * from './selection/index.js';
7
12
  export * from './FieldTime.js';
8
- export * from './calendar/index.js';
9
- export * from './FieldDate.js';
13
+ export * from './FieldDateTime.js';
14
+ export * from './FieldDateTimeRange.js';
10
15
  export * from './FieldDateRange.js';
16
+ export * from './FieldDate.js';
@@ -0,0 +1,18 @@
1
+ import { Component, HTMLTemplateResult } from '@a11d/lit';
2
+ import { IntervalController } from '@3mo/interval-controller';
3
+ export declare abstract class DateList extends Component {
4
+ readonly change: EventDispatcher<DateTime>;
5
+ navigatingValue: DateTime;
6
+ value?: DateTime;
7
+ private preventIntervalScrolling;
8
+ get now(): import("@3mo/date-time/DateTime.js").DateTime;
9
+ readonly intervalController: IntervalController;
10
+ static get styles(): import("@a11d/lit").CSSResult;
11
+ private readonly selectedListItem?;
12
+ private readonly nowListItem?;
13
+ protected connected(): void;
14
+ protected get template(): HTMLTemplateResult;
15
+ protected scrollIntoSelectedItem(): Promise<void>;
16
+ protected abstract get listItemsTemplate(): HTMLTemplateResult;
17
+ }
18
+ //# sourceMappingURL=DateList.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DateList.d.ts","sourceRoot":"","sources":["../../selection/DateList.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAA8C,MAAM,WAAW,CAAA;AACrG,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAG7D,8BAAsB,QAAS,SAAQ,SAAS;IACtC,QAAQ,CAAC,MAAM,EAAG,eAAe,CAAC,QAAQ,CAAC,CAAA;IAExB,eAAe,EAAG,QAAQ,CAAA;IACiC,KAAK,CAAC,EAAE,QAAQ,CAAA;IAEvG,OAAO,CAAC,wBAAwB,CAAQ;IAExC,IAAI,GAAG,kDAA4B;IAEnC,QAAQ,CAAC,kBAAkB,qBAKzB;IAEF,WAAoB,MAAM,kCAkBzB;IAE2C,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAoB;IACtD,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAoB;cAE1E,SAAS;IAI5B,cAAuB,QAAQ,uBAU9B;cAEe,sBAAsB;IAKtC,SAAS,CAAC,QAAQ,KAAK,iBAAiB,IAAI,kBAAkB,CAAA;CAC9D"}
@@ -0,0 +1,69 @@
1
+ import { __decorate } from "tslib";
2
+ import { Component, css, event, html, nothing, property, query } from '@a11d/lit';
3
+ import { IntervalController } from '@3mo/interval-controller';
4
+ export class DateList extends Component {
5
+ constructor() {
6
+ super(...arguments);
7
+ this.preventIntervalScrolling = false;
8
+ this.intervalController = new IntervalController(this, 1000, () => {
9
+ this.requestUpdate();
10
+ if (!this.value && this.preventIntervalScrolling === false) {
11
+ this.scrollIntoSelectedItem();
12
+ }
13
+ });
14
+ }
15
+ get now() { return new DateTime(); }
16
+ static get styles() {
17
+ return css `
18
+ mo-scroller {
19
+ min-width: 70px;
20
+ }
21
+
22
+ .pad {
23
+ height: 50px;
24
+ }
25
+
26
+ mo-selectable-list-item {
27
+ height: 32px;
28
+ }
29
+
30
+ mo-selectable-list-item[data-now] {
31
+ outline: 2px dashed var(--mo-color-gray-transparent);
32
+ }
33
+ `;
34
+ }
35
+ connected() {
36
+ this.scrollIntoSelectedItem();
37
+ }
38
+ get template() {
39
+ return this.navigatingValue === undefined ? nothing : html `
40
+ <mo-scroller @pointerenter=${() => this.preventIntervalScrolling = true} @pointerleave=${() => this.preventIntervalScrolling = false}>
41
+ <mo-selectable-list @change=${() => this.scrollIntoSelectedItem()}>
42
+ <div class='pad'></div>
43
+ ${this.listItemsTemplate}
44
+ <div class='pad'></div>
45
+ </mo-selectable-list>
46
+ </mo-scroller>
47
+ `;
48
+ }
49
+ async scrollIntoSelectedItem() {
50
+ var _a, _b;
51
+ await this.updateComplete;
52
+ (_b = ((_a = this.selectedListItem) !== null && _a !== void 0 ? _a : this.nowListItem)) === null || _b === void 0 ? void 0 : _b.scrollIntoView({ behavior: 'smooth', block: 'center' });
53
+ }
54
+ }
55
+ __decorate([
56
+ event()
57
+ ], DateList.prototype, "change", void 0);
58
+ __decorate([
59
+ property({ type: Object })
60
+ ], DateList.prototype, "navigatingValue", void 0);
61
+ __decorate([
62
+ property({ type: Object, updated() { this.scrollIntoSelectedItem(); } })
63
+ ], DateList.prototype, "value", void 0);
64
+ __decorate([
65
+ query('mo-selectable-list-item[selected]')
66
+ ], DateList.prototype, "selectedListItem", void 0);
67
+ __decorate([
68
+ query('mo-selectable-list-item[data-now]')
69
+ ], DateList.prototype, "nowListItem", void 0);
@@ -0,0 +1,10 @@
1
+ import { DateList } from './DateList.js';
2
+ export declare class HourList extends DateList {
3
+ protected get listItemsTemplate(): import("lit-html").TemplateResult<1>;
4
+ }
5
+ declare global {
6
+ interface HTMLElementTagNameMap {
7
+ 'mo-hour-list': HourList;
8
+ }
9
+ }
10
+ //# sourceMappingURL=HourList.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HourList.d.ts","sourceRoot":"","sources":["../../selection/HourList.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAGxC,qBACa,QAAS,SAAQ,QAAQ;IACrC,cAAuB,iBAAiB,yCAUvC;CACD;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,cAAc,EAAE,QAAQ,CAAA;KACxB;CACD"}
@@ -0,0 +1,23 @@
1
+ import { __decorate } from "tslib";
2
+ import { component, html, range } from '@a11d/lit';
3
+ import { DateList } from './DateList.js';
4
+ let HourList = class HourList extends DateList {
5
+ get listItemsTemplate() {
6
+ return html `
7
+ ${[...range(0, this.navigatingValue.hoursInDay)].map(hour => {
8
+ var _a;
9
+ return html `
10
+ <mo-selectable-list-item
11
+ ?selected=${((_a = this.value) === null || _a === void 0 ? void 0 : _a.hour) === hour}
12
+ ?data-now=${this.now.hour === hour}
13
+ @change=${(e) => { var _a; return !e.selected ? void 0 : this.change.dispatch(((_a = this.value) !== null && _a !== void 0 ? _a : new DateTime).with({ hour })); }}
14
+ >${hour.format().padStart(2, 0.0.format())}</mo-selectable-list-item>
15
+ `;
16
+ })}
17
+ `;
18
+ }
19
+ };
20
+ HourList = __decorate([
21
+ component('mo-hour-list')
22
+ ], HourList);
23
+ export { HourList };
@@ -0,0 +1,10 @@
1
+ import { DateList } from './DateList.js';
2
+ export declare class MinuteList extends DateList {
3
+ protected get listItemsTemplate(): import("lit-html").TemplateResult<1>;
4
+ }
5
+ declare global {
6
+ interface HTMLElementTagNameMap {
7
+ 'mo-minute-list': MinuteList;
8
+ }
9
+ }
10
+ //# sourceMappingURL=MinuteList.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MinuteList.d.ts","sourceRoot":"","sources":["../../selection/MinuteList.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,qBACa,UAAW,SAAQ,QAAQ;IACvC,cAAuB,iBAAiB,yCAUvC;CACD;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,gBAAgB,EAAE,UAAU,CAAA;KAC5B;CACD"}
@@ -0,0 +1,23 @@
1
+ import { __decorate } from "tslib";
2
+ import { component, html, range } from '@a11d/lit';
3
+ import { DateList } from './DateList.js';
4
+ let MinuteList = class MinuteList extends DateList {
5
+ get listItemsTemplate() {
6
+ return html `
7
+ ${[...range(0, 60)].map(minute => {
8
+ var _a;
9
+ return html `
10
+ <mo-selectable-list-item
11
+ ?selected=${((_a = this.value) === null || _a === void 0 ? void 0 : _a.minute) === minute}
12
+ ?data-now=${this.now.minute === minute}
13
+ @change=${(e) => { var _a; return !e.selected ? void 0 : this.change.dispatch(((_a = this.value) !== null && _a !== void 0 ? _a : new DateTime).with({ minute })); }}
14
+ >${minute.format().padStart(2, 0.0.format())}</mo-selectable-list-item>
15
+ `;
16
+ })}
17
+ `;
18
+ }
19
+ };
20
+ MinuteList = __decorate([
21
+ component('mo-minute-list')
22
+ ], MinuteList);
23
+ export { MinuteList };
@@ -0,0 +1,12 @@
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").TemplateResult<1>;
6
+ }
7
+ declare global {
8
+ interface HTMLElementTagNameMap {
9
+ 'mo-month-list': MonthList;
10
+ }
11
+ }
12
+ //# sourceMappingURL=MonthList.d.ts.map
@@ -0,0 +1 @@
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,yCAUvC;CACD;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,eAAe,EAAE,SAAS,CAAA;KAC1B;CACD"}
@@ -0,0 +1,38 @@
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]) => {
23
+ var _a;
24
+ return html `
25
+ <mo-selectable-list-item
26
+ ?selected=${((_a = this.value) === null || _a === void 0 ? void 0 : _a.month) === month}
27
+ ?data-now=${this.now.month === month}
28
+ @change=${(e) => { var _a; return !e.selected ? void 0 : this.change.dispatch(((_a = this.value) !== null && _a !== void 0 ? _a : new DateTime).with({ month })); }}
29
+ >${name}</mo-selectable-list-item>
30
+ `;
31
+ })}
32
+ `;
33
+ }
34
+ };
35
+ MonthList = __decorate([
36
+ component('mo-month-list')
37
+ ], MonthList);
38
+ export { MonthList };
@@ -0,0 +1,10 @@
1
+ import { DateList } from './DateList.js';
2
+ export declare class SecondList extends DateList {
3
+ protected get listItemsTemplate(): import("lit-html").TemplateResult<1>;
4
+ }
5
+ declare global {
6
+ interface HTMLElementTagNameMap {
7
+ 'mo-second-list': SecondList;
8
+ }
9
+ }
10
+ //# sourceMappingURL=SecondList.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SecondList.d.ts","sourceRoot":"","sources":["../../selection/SecondList.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,qBACa,UAAW,SAAQ,QAAQ;IACvC,cAAuB,iBAAiB,yCAUvC;CACD;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,gBAAgB,EAAE,UAAU,CAAA;KAC5B;CACD"}