@3mo/date-time-fields 0.5.2 → 0.5.3

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.
@@ -10,12 +10,12 @@ let FieldDateTime = class FieldDateTime extends FieldDateTimeBase {
10
10
  return new DateTime().format(this.formatOptions);
11
11
  }
12
12
  get calendarTemplate() {
13
- return html `
14
- <mo-selectable-calendar
15
- .navigatingValue=${this.navigatingDate}
16
- .value=${this.selectedDate}
17
- @change=${(e) => this.handleSelectedDateChange(e.detail, FieldDateTimePrecision.Day)}
18
- ></mo-selectable-calendar>
13
+ return html `
14
+ <mo-selectable-calendar
15
+ .navigatingValue=${this.navigatingDate}
16
+ .value=${this.selectedDate}
17
+ @change=${(e) => this.handleSelectedDateChange(e.detail, FieldDateTimePrecision.Day)}
18
+ ></mo-selectable-calendar>
19
19
  `;
20
20
  }
21
21
  handleSelectedDateChange(date, precision) {
@@ -80,73 +80,73 @@ export class FieldDateTimeBase extends InputFieldComponent {
80
80
  return '';
81
81
  }
82
82
  static get styles() {
83
- return css `
84
- ${super.styles}
85
-
86
- :host {
87
- position: relative;
88
- }
89
-
90
- mo-popover {
91
- background: var(--mo-color-background);
92
- box-shadow: var(--mo-shadow);
93
- border-radius: var(--mo-border-radius);
94
- color: var(--mo-color-foreground);
95
- }
96
-
97
- #selector {
98
- min-height: 175px;
99
- }
100
-
101
- .timezone {
102
- padding: 3px;
103
- font-size: small;
104
- text-align: end;
105
- font-weight: 500;
106
- color: var(--mo-color-gray);
107
- }
108
-
109
- input::placeholder {
110
- color: transparent;
111
- }
112
-
113
- mo-field[active]:not([dense]) input::placeholder {
114
- color: var(--mo-color-gray);
115
- }
83
+ return css `
84
+ ${super.styles}
85
+
86
+ :host {
87
+ position: relative;
88
+ }
89
+
90
+ mo-popover {
91
+ background: var(--mo-color-background);
92
+ box-shadow: var(--mo-shadow);
93
+ border-radius: var(--mo-border-radius);
94
+ color: var(--mo-color-foreground);
95
+ }
96
+
97
+ #selector {
98
+ min-height: 175px;
99
+ }
100
+
101
+ .timezone {
102
+ padding: 3px;
103
+ font-size: small;
104
+ text-align: end;
105
+ font-weight: 500;
106
+ color: var(--mo-color-gray);
107
+ }
108
+
109
+ input::placeholder {
110
+ color: transparent;
111
+ }
112
+
113
+ mo-field[active]:not([dense]) input::placeholder {
114
+ color: var(--mo-color-gray);
115
+ }
116
116
  `;
117
117
  }
118
118
  get template() {
119
- return html `
120
- ${super.template}
121
- ${this.popoverTemplate}
119
+ return html `
120
+ ${super.template}
121
+ ${this.popoverTemplate}
122
122
  `;
123
123
  }
124
124
  get endSlotTemplate() {
125
- return html `
126
- ${super.endSlotTemplate}
127
- ${this.calendarIconButtonTemplate}
125
+ return html `
126
+ ${super.endSlotTemplate}
127
+ ${this.calendarIconButtonTemplate}
128
128
  `;
129
129
  }
130
130
  get inputTemplate() {
131
- return html `
132
- <input
133
- part='input'
134
- ?readonly=${this.readonly}
135
- ?required=${this.required}
136
- ?disabled=${this.disabled}
137
- placeholder=${this.placeholder}
138
- .value=${live(this.inputStringValue || '')}
139
- @input=${(e) => this.handleInput(this.inputValueToValue(this.inputElement.value || ''), e)}
140
- @change=${(e) => this.handleChange(this.inputValueToValue(this.inputElement.value || ''), e)}
141
- >
131
+ return html `
132
+ <input
133
+ part='input'
134
+ ?readonly=${this.readonly}
135
+ ?required=${this.required}
136
+ ?disabled=${this.disabled}
137
+ placeholder=${this.placeholder}
138
+ .value=${live(this.inputStringValue || '')}
139
+ @input=${(e) => this.handleInput(this.inputValueToValue(this.inputElement.value || ''), e)}
140
+ @change=${(e) => this.handleChange(this.inputValueToValue(this.inputElement.value || ''), e)}
141
+ >
142
142
  `;
143
143
  }
144
144
  get calendarIconButtonTemplate() {
145
- return this.pickerHidden ? html.nothing : html `
146
- <mo-icon tabindex='-1' dense slot='end'
147
- icon=${this.calendarIconButtonIcon}
148
- ${style({ color: this.isActive ? 'var(--mo-color-accent)' : 'var(--mo-color-gray)', fontSize: '22px', marginTop: '2px', cursor: 'pointer', userSelect: 'none' })}
149
- ></mo-icon>
145
+ return this.pickerHidden ? html.nothing : html `
146
+ <mo-icon tabindex='-1' dense slot='end'
147
+ icon=${this.calendarIconButtonIcon}
148
+ ${style({ color: this.isActive ? 'var(--mo-color-accent)' : 'var(--mo-color-gray)', fontSize: '22px', marginTop: '2px', cursor: 'pointer', userSelect: 'none' })}
149
+ ></mo-icon>
150
150
  `;
151
151
  }
152
152
  handleFocus(bubbled, method) {
@@ -160,90 +160,90 @@ export class FieldDateTimeBase extends InputFieldComponent {
160
160
  this.open = false;
161
161
  }
162
162
  get popoverTemplate() {
163
- return this.pickerHidden ? html.nothing : html `
164
- <mo-popover tabindex='-1' fixed manual
165
- .anchor=${this}
166
- ?open=${this.open}
167
- @openChange=${(e) => this.open = e.detail}
168
- >${cache(!this.open ? html.nothing : this.popoverContentTemplate)}</mo-popover>
163
+ return this.pickerHidden ? html.nothing : html `
164
+ <mo-popover tabindex='-1' fixed manual
165
+ .anchor=${this}
166
+ ?open=${this.open}
167
+ @openChange=${(e) => this.open = e.detail}
168
+ >${cache(!this.open ? html.nothing : this.popoverContentTemplate)}</mo-popover>
169
169
  `;
170
170
  }
171
171
  get popoverContentTemplate() {
172
- return html `
173
- <mo-flex id='selector' direction='horizontal' style='height: 100%'>
174
- ${this.dateTemplate}
175
- ${this.timeTemplate}
176
- </mo-flex>
172
+ return html `
173
+ <mo-flex id='selector' direction='horizontal' style='height: 100%'>
174
+ ${this.dateTemplate}
175
+ ${this.timeTemplate}
176
+ </mo-flex>
177
177
  `;
178
178
  }
179
179
  get dateTemplate() {
180
- return html `
181
- ${this.yearListTemplate}
182
- ${this.monthListTemplate}
183
- ${this.dayTemplate}
180
+ return html `
181
+ ${this.yearListTemplate}
182
+ ${this.monthListTemplate}
183
+ ${this.dayTemplate}
184
184
  `;
185
185
  }
186
186
  get yearListTemplate() {
187
- return html `
188
- <mo-year-list
189
- .navigatingValue=${this.navigatingDate}
190
- .value=${this.selectedDate}
191
- @change=${(e) => this.handleSelectedDateChange(e.detail, FieldDateTimePrecision.Year)}
192
- ></mo-year-list>
187
+ return html `
188
+ <mo-year-list
189
+ .navigatingValue=${this.navigatingDate}
190
+ .value=${this.selectedDate}
191
+ @change=${(e) => this.handleSelectedDateChange(e.detail, FieldDateTimePrecision.Year)}
192
+ ></mo-year-list>
193
193
  `;
194
194
  }
195
195
  get monthListTemplate() {
196
- return [FieldDateTimePrecision.Year].includes(this.precision) ? html.nothing : html `
197
- <mo-month-list
198
- .navigatingValue=${this.navigatingDate}
199
- .value=${this.selectedDate}
200
- @change=${(e) => this.handleSelectedDateChange(e.detail, FieldDateTimePrecision.Month)}
201
- ></mo-month-list>
196
+ return [FieldDateTimePrecision.Year].includes(this.precision) ? html.nothing : html `
197
+ <mo-month-list
198
+ .navigatingValue=${this.navigatingDate}
199
+ .value=${this.selectedDate}
200
+ @change=${(e) => this.handleSelectedDateChange(e.detail, FieldDateTimePrecision.Month)}
201
+ ></mo-month-list>
202
202
  `;
203
203
  }
204
204
  get dayTemplate() {
205
205
  return [FieldDateTimePrecision.Year, FieldDateTimePrecision.Month].includes(this.precision) ? html.nothing : this.calendarTemplate;
206
206
  }
207
207
  get timeTemplate() {
208
- return [FieldDateTimePrecision.Year, FieldDateTimePrecision.Month, FieldDateTimePrecision.Day].includes(this.precision) ? html.nothing : html `
209
- <mo-flex gap='6px'>
210
- <div class='timezone'>
211
- ${this.navigatingDate?.formatToParts({ timeZoneName: 'long' }).find(x => x.type === 'timeZoneName')?.value}
212
- (${this.navigatingDate?.formatToParts({ timeZoneName: 'shortOffset' }).find(x => x.type === 'timeZoneName')?.value})
213
- </div>
214
- <mo-flex direction='horizontal' style='flex: 1'>
215
- ${this.hourListTemplate}
216
- ${this.minuteListTemplate}
217
- ${this.secondListTemplate}
218
- </mo-flex>
219
- </mo-flex>
208
+ return [FieldDateTimePrecision.Year, FieldDateTimePrecision.Month, FieldDateTimePrecision.Day].includes(this.precision) ? html.nothing : html `
209
+ <mo-flex gap='6px'>
210
+ <div class='timezone'>
211
+ ${this.navigatingDate?.formatToParts({ timeZoneName: 'long' }).find(x => x.type === 'timeZoneName')?.value}
212
+ (${this.navigatingDate?.formatToParts({ timeZoneName: 'shortOffset' }).find(x => x.type === 'timeZoneName')?.value})
213
+ </div>
214
+ <mo-flex direction='horizontal' style='flex: 1'>
215
+ ${this.hourListTemplate}
216
+ ${this.minuteListTemplate}
217
+ ${this.secondListTemplate}
218
+ </mo-flex>
219
+ </mo-flex>
220
220
  `;
221
221
  }
222
222
  get hourListTemplate() {
223
- return html `
224
- <mo-hour-list style='flex: 1'
225
- .navigatingValue=${this.navigatingDate}
226
- .value=${this.selectedDate}
227
- @change=${(e) => this.handleSelectedDateChange(e.detail, FieldDateTimePrecision.Hour)}
228
- ></mo-hour-list>
223
+ return html `
224
+ <mo-hour-list style='flex: 1'
225
+ .navigatingValue=${this.navigatingDate}
226
+ .value=${this.selectedDate}
227
+ @change=${(e) => this.handleSelectedDateChange(e.detail, FieldDateTimePrecision.Hour)}
228
+ ></mo-hour-list>
229
229
  `;
230
230
  }
231
231
  get minuteListTemplate() {
232
- return [FieldDateTimePrecision.Hour].includes(this.precision) ? html.nothing : html `
233
- <mo-minute-list style='flex: 1'
234
- .navigatingValue=${this.navigatingDate}
235
- .value=${this.selectedDate}
236
- @change=${(e) => this.handleSelectedDateChange(e.detail, FieldDateTimePrecision.Minute)}
237
- ></mo-minute-list>
232
+ return [FieldDateTimePrecision.Hour].includes(this.precision) ? html.nothing : html `
233
+ <mo-minute-list style='flex: 1'
234
+ .navigatingValue=${this.navigatingDate}
235
+ .value=${this.selectedDate}
236
+ @change=${(e) => this.handleSelectedDateChange(e.detail, FieldDateTimePrecision.Minute)}
237
+ ></mo-minute-list>
238
238
  `;
239
239
  }
240
240
  get secondListTemplate() {
241
- return [FieldDateTimePrecision.Hour, FieldDateTimePrecision.Minute].includes(this.precision) ? html.nothing : html `
242
- <mo-second-list style='flex: 1'
243
- .navigatingValue=${this.navigatingDate}
244
- .value=${this.selectedDate}
245
- @change=${(e) => this.handleSelectedDateChange(e.detail, FieldDateTimePrecision.Second)}
246
- ></mo-second-list>
241
+ return [FieldDateTimePrecision.Hour, FieldDateTimePrecision.Minute].includes(this.precision) ? html.nothing : html `
242
+ <mo-second-list style='flex: 1'
243
+ .navigatingValue=${this.navigatingDate}
244
+ .value=${this.selectedDate}
245
+ @change=${(e) => this.handleSelectedDateChange(e.detail, FieldDateTimePrecision.Second)}
246
+ ></mo-second-list>
247
247
  `;
248
248
  }
249
249
  handleSelectedDateChange(date, precision) {
@@ -31,55 +31,55 @@ let FieldDateTimeRange = class FieldDateTimeRange extends FieldDateTimeBase {
31
31
  get navigatingDate() { return (this.selection === FieldDateRangeSelection.Start ? this.value?.start : this.value?.end) ?? new DateTime(); }
32
32
  get selectedDate() { return this.selection === FieldDateRangeSelection.Start ? this.value?.start : this.value?.end; }
33
33
  static get styles() {
34
- return css `
35
- ${super.styles}
36
-
37
- mo-tab-bar {
38
- max-width: 200px;
39
- place-self: center;
40
- padding-block: 4px;
41
- }
42
-
43
- mo-tab {
44
- --mdc-tab-height: 40px;
45
- }
46
-
47
- mo-tab:not([active]) {
48
- opacity: 0.5;
49
- }
34
+ return css `
35
+ ${super.styles}
36
+
37
+ mo-tab-bar {
38
+ max-width: 200px;
39
+ place-self: center;
40
+ padding-block: 4px;
41
+ }
42
+
43
+ mo-tab {
44
+ --mdc-tab-height: 40px;
45
+ }
46
+
47
+ mo-tab:not([active]) {
48
+ opacity: 0.5;
49
+ }
50
50
  `;
51
51
  }
52
52
  get placeholder() {
53
53
  return new DateTimeRange(new DateTime().subtract({ years: 1 }), new DateTime()).format(this.formatOptions);
54
54
  }
55
55
  get calendarTemplate() {
56
- return html `
57
- <mo-selectable-range-calendar
58
- .navigatingValue=${this.navigatingDate}
59
- .dateRange=${this.value}
60
- @change=${(e) => this.handleSelectedDateChange(e.detail, FieldDateTimePrecision.Day)}
61
- ></mo-selectable-range-calendar>
56
+ return html `
57
+ <mo-selectable-range-calendar
58
+ .navigatingValue=${this.navigatingDate}
59
+ .dateRange=${this.value}
60
+ @change=${(e) => this.handleSelectedDateChange(e.detail, FieldDateTimePrecision.Day)}
61
+ ></mo-selectable-range-calendar>
62
62
  `;
63
63
  }
64
64
  get popoverContentTemplate() {
65
- return html `
66
- ${this.popoverToolbarTemplate}
67
- ${super.popoverContentTemplate}
65
+ return html `
66
+ ${this.popoverToolbarTemplate}
67
+ ${super.popoverContentTemplate}
68
68
  `;
69
69
  }
70
70
  get popoverToolbarTemplate() {
71
- return html `
72
- ${this.startEndTabBarTemplate}
71
+ return html `
72
+ ${this.startEndTabBarTemplate}
73
73
  `;
74
74
  }
75
75
  get startEndTabBarTemplate() {
76
- return html `
77
- <mo-flex>
78
- <mo-tab-bar ${bind(this, 'selection')}>
79
- <mo-tab value=${FieldDateRangeSelection.Start}>${t('Start')}</mo-tab>
80
- <mo-tab value=${FieldDateRangeSelection.End}>${t('End')}</mo-tab>
81
- </mo-tab-bar>
82
- </mo-flex>
76
+ return html `
77
+ <mo-flex>
78
+ <mo-tab-bar ${bind(this, 'selection')}>
79
+ <mo-tab value=${FieldDateRangeSelection.Start}>${t('Start')}</mo-tab>
80
+ <mo-tab value=${FieldDateRangeSelection.End}>${t('End')}</mo-tab>
81
+ </mo-tab-bar>
82
+ </mo-flex>
83
83
  `;
84
84
  }
85
85
  handleSelectedDateChange(date, precision) {
package/dist/FieldTime.js CHANGED
@@ -7,9 +7,9 @@ let FieldTime = class FieldTime extends FieldText {
7
7
  return 'time';
8
8
  }
9
9
  get startSlotTemplate() {
10
- return html `
11
- <mo-icon slot='start' @click=${() => this.focus()} icon='schedule' ${style({ color: 'var(--mo-color-gray)' })}></mo-icon>
12
- ${super.startSlotTemplate}
10
+ return html `
11
+ <mo-icon slot='start' @click=${() => this.focus()} icon='schedule' ${style({ color: 'var(--mo-color-gray)' })}></mo-icon>
12
+ ${super.startSlotTemplate}
13
13
  `;
14
14
  }
15
15
  };
@@ -19,16 +19,16 @@ let FieldToggleableDateTimeRange = class FieldToggleableDateTimeRange extends Fi
19
19
  get includeTime() { return this.precision === FieldDateTimePrecision.Minute; }
20
20
  set includeTime(includeTime) { this.precision = includeTime ? FieldDateTimePrecision.Minute : FieldDateTimePrecision.Day; }
21
21
  get popoverToolbarTemplate() {
22
- return html `
23
- <mo-grid style='width: calc(100% - 16px); padding-inline: 8px;' columns='* auto'>
24
- ${super.popoverToolbarTemplate}
25
- ${this.toggleTemplate}
26
- </mo-grid>
22
+ return html `
23
+ <mo-grid style='width: calc(100% - 16px); padding-inline: 8px;' columns='* auto'>
24
+ ${super.popoverToolbarTemplate}
25
+ ${this.toggleTemplate}
26
+ </mo-grid>
27
27
  `;
28
28
  }
29
29
  get toggleTemplate() {
30
- return html `
31
- <mo-switch label=${t('Include time')} ${bind(this, 'includeTime')}></mo-switch>
30
+ return html `
31
+ <mo-switch label=${t('Include time')} ${bind(this, 'includeTime')}></mo-switch>
32
32
  `;
33
33
  }
34
34
  };