@m3e/web 2.5.15 → 2.6.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.
- package/dist/TextOverflowElement.js +3605 -0
- package/dist/TextOverflowElement.js.map +1 -0
- package/dist/TextOverflowElement.min.js +7 -0
- package/dist/TextOverflowElement.min.js.map +1 -0
- package/dist/all.js +1566 -7
- package/dist/all.js.map +1 -1
- package/dist/all.min.js +89 -81
- package/dist/all.min.js.map +1 -1
- package/dist/badge.js +2 -1
- package/dist/badge.js.map +1 -1
- package/dist/badge.min.js +1 -1
- package/dist/badge.min.js.map +1 -1
- package/dist/core.js +415 -3968
- package/dist/core.js.map +1 -1
- package/dist/core.min.js +1 -1
- package/dist/core.min.js.map +1 -1
- package/dist/css-custom-data.json +590 -0
- package/dist/custom-elements.json +4385 -611
- package/dist/html-custom-data.json +251 -0
- package/dist/list.js +12 -4
- package/dist/list.js.map +1 -1
- package/dist/list.min.js +1 -1
- package/dist/list.min.js.map +1 -1
- package/dist/nav-bar.js +1 -1
- package/dist/nav-bar.js.map +1 -1
- package/dist/nav-bar.min.js +1 -1
- package/dist/nav-bar.min.js.map +1 -1
- package/dist/src/all.d.ts +1 -0
- package/dist/src/all.d.ts.map +1 -1
- package/dist/src/badge/BadgeElement.d.ts.map +1 -1
- package/dist/src/core/shared/converters/index.d.ts +1 -0
- package/dist/src/core/shared/converters/index.d.ts.map +1 -1
- package/dist/src/core/shared/converters/timeConverter.d.ts +11 -0
- package/dist/src/core/shared/converters/timeConverter.d.ts.map +1 -0
- package/dist/src/list/ListItemElement.d.ts.map +1 -1
- package/dist/src/nav-bar/NavItemElement.d.ts.map +1 -1
- package/dist/src/timepicker/TimepickerDialElement.d.ts +76 -0
- package/dist/src/timepicker/TimepickerDialElement.d.ts.map +1 -0
- package/dist/src/timepicker/TimepickerElement.d.ts +266 -0
- package/dist/src/timepicker/TimepickerElement.d.ts.map +1 -0
- package/dist/src/timepicker/TimepickerFormat.d.ts +3 -0
- package/dist/src/timepicker/TimepickerFormat.d.ts.map +1 -0
- package/dist/src/timepicker/TimepickerInputElement.d.ts +110 -0
- package/dist/src/timepicker/TimepickerInputElement.d.ts.map +1 -0
- package/dist/src/timepicker/TimepickerInputElementBase.d.ts +69 -0
- package/dist/src/timepicker/TimepickerInputElementBase.d.ts.map +1 -0
- package/dist/src/timepicker/TimepickerInputPeriodToggleElement.d.ts +18 -0
- package/dist/src/timepicker/TimepickerInputPeriodToggleElement.d.ts.map +1 -0
- package/dist/src/timepicker/TimepickerMode.d.ts +3 -0
- package/dist/src/timepicker/TimepickerMode.d.ts.map +1 -0
- package/dist/src/timepicker/TimepickerOrientation.d.ts +3 -0
- package/dist/src/timepicker/TimepickerOrientation.d.ts.map +1 -0
- package/dist/src/timepicker/TimepickerPeriod.d.ts +8 -0
- package/dist/src/timepicker/TimepickerPeriod.d.ts.map +1 -0
- package/dist/src/timepicker/TimepickerToggleElement.d.ts +21 -0
- package/dist/src/timepicker/TimepickerToggleElement.d.ts.map +1 -0
- package/dist/src/timepicker/TimepickerVariant.d.ts +3 -0
- package/dist/src/timepicker/TimepickerVariant.d.ts.map +1 -0
- package/dist/src/timepicker/TimepickerView.d.ts +3 -0
- package/dist/src/timepicker/TimepickerView.d.ts.map +1 -0
- package/dist/src/timepicker/index.d.ts +11 -0
- package/dist/src/timepicker/index.d.ts.map +1 -0
- package/dist/timepicker.js +1533 -0
- package/dist/timepicker.js.map +1 -0
- package/dist/timepicker.min.js +15 -0
- package/dist/timepicker.min.js.map +1 -0
- package/package.json +6 -1
|
@@ -0,0 +1,1533 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license MIT
|
|
3
|
+
* Copyright (c) 2025–2026 matraic
|
|
4
|
+
* See LICENSE file in the project root for full license text.
|
|
5
|
+
*/
|
|
6
|
+
import { __decorate, __classPrivateFieldGet, __classPrivateFieldSet } from 'tslib';
|
|
7
|
+
import { LitElement, html, nothing, unsafeCSS, css, svg } from 'lit';
|
|
8
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
9
|
+
import { SuppressInitialAnimation, AttachInternals, Role, safeStyleMap, computeCssSize, DesignToken, customElement, HtmlFor, ReconnectedCallback, ScrollLockController, InertController, deleteCustomState, prefersReducedMotion, addCustomState, setCustomState, dateConverter, timeConverter as timeConverter$1, ActionElementBase } from '@m3e/web/core';
|
|
10
|
+
import { property, state, query } from 'lit/decorators.js';
|
|
11
|
+
import { timeConverter } from './TextOverflowElement.js';
|
|
12
|
+
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
13
|
+
import { positionAnchor } from '@m3e/web/core/anchoring';
|
|
14
|
+
import { M3eDirectionality } from '@m3e/web/core/bidi';
|
|
15
|
+
import { M3eBreakpointObserver, Breakpoint } from '@m3e/web/core/layout';
|
|
16
|
+
import '@m3e/web/core/a11y';
|
|
17
|
+
import '@m3e/web/button';
|
|
18
|
+
import '@m3e/web/icon-button';
|
|
19
|
+
|
|
20
|
+
var _TimepickerInputElementBase_hour, _TimepickerInputElementBase_minute, _TimepickerInputElementBase_format;
|
|
21
|
+
/** A base implementation for an element used to input time. This class must be inherited. */
|
|
22
|
+
class TimepickerInputElementBase extends LitElement {
|
|
23
|
+
constructor() {
|
|
24
|
+
super(...arguments);
|
|
25
|
+
/** @private */
|
|
26
|
+
_TimepickerInputElementBase_hour.set(this, null);
|
|
27
|
+
/** @private */
|
|
28
|
+
_TimepickerInputElementBase_minute.set(this, null);
|
|
29
|
+
/** @private */
|
|
30
|
+
_TimepickerInputElementBase_format.set(this, "12");
|
|
31
|
+
/**
|
|
32
|
+
* Whether to use a 12‑hour or 24‑hour clock.
|
|
33
|
+
* @default "12"
|
|
34
|
+
*/
|
|
35
|
+
this.format = "12";
|
|
36
|
+
/**
|
|
37
|
+
* The view used to input time.
|
|
38
|
+
* @default "hour"
|
|
39
|
+
*/
|
|
40
|
+
this.view = "hour";
|
|
41
|
+
/**
|
|
42
|
+
* The 12-hour time period.
|
|
43
|
+
* @default "am"
|
|
44
|
+
*/
|
|
45
|
+
this.period = "am";
|
|
46
|
+
/**
|
|
47
|
+
* The minimum time that can be selected.
|
|
48
|
+
* @default null
|
|
49
|
+
*/
|
|
50
|
+
this.minTime = null;
|
|
51
|
+
/**
|
|
52
|
+
* The maximum time that can be selected.
|
|
53
|
+
* @default null
|
|
54
|
+
*/
|
|
55
|
+
this.maxTime = null;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* The hour, in 24-hour time, from 0..23.
|
|
59
|
+
* @default null
|
|
60
|
+
*/
|
|
61
|
+
get hour() {
|
|
62
|
+
return __classPrivateFieldGet(this, _TimepickerInputElementBase_hour, "f");
|
|
63
|
+
}
|
|
64
|
+
set hour(value) {
|
|
65
|
+
__classPrivateFieldSet(this, _TimepickerInputElementBase_hour, value === null ? null : Math.max(0, Math.min(value, 23)), "f");
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* The minute, from 0..59.
|
|
69
|
+
* @default null
|
|
70
|
+
*/
|
|
71
|
+
get minute() {
|
|
72
|
+
return __classPrivateFieldGet(this, _TimepickerInputElementBase_minute, "f");
|
|
73
|
+
}
|
|
74
|
+
set minute(value) {
|
|
75
|
+
__classPrivateFieldSet(this, _TimepickerInputElementBase_minute, value === null ? null : Math.max(0, Math.min(value, 59)), "f");
|
|
76
|
+
}
|
|
77
|
+
/** The hour in 12‑hour time from 1..12. */
|
|
78
|
+
get hourOfPeriod() {
|
|
79
|
+
if (this.hour === null) return null;
|
|
80
|
+
const h = this.hour % 12;
|
|
81
|
+
return h === 0 ? 12 : h;
|
|
82
|
+
}
|
|
83
|
+
set hourOfPeriod(value) {
|
|
84
|
+
if (value === null) {
|
|
85
|
+
this.hour = null;
|
|
86
|
+
} else {
|
|
87
|
+
const h = Math.max(1, Math.min(value, 12));
|
|
88
|
+
this.hour = this.period === "am" ? h === 12 ? 0 : h : h === 12 ? 12 : h + 12;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
/** The current time format. */
|
|
92
|
+
get currentFormat() {
|
|
93
|
+
return __classPrivateFieldGet(this, _TimepickerInputElementBase_format, "f");
|
|
94
|
+
}
|
|
95
|
+
/** @inheritdoc */
|
|
96
|
+
willUpdate(_changedProperties) {
|
|
97
|
+
super.willUpdate(_changedProperties);
|
|
98
|
+
if (_changedProperties.has("format")) {
|
|
99
|
+
__classPrivateFieldSet(this, _TimepickerInputElementBase_format, this.format !== "auto" ? this.format : new Intl.DateTimeFormat(undefined, {
|
|
100
|
+
hour: "numeric"
|
|
101
|
+
}).resolvedOptions().hour12 ? "12" : "24", "f");
|
|
102
|
+
}
|
|
103
|
+
// If the hour changes, ensure the correct period; otherwise, if period changes, adjust hour.
|
|
104
|
+
if (_changedProperties.has("hour")) {
|
|
105
|
+
this.period = this.hour !== null && this.hour >= 12 ? "pm" : "am";
|
|
106
|
+
} else if (_changedProperties.has("period")) {
|
|
107
|
+
if (this.hour !== null) {
|
|
108
|
+
const h = this.hour % 12 || 12;
|
|
109
|
+
this.hour = this.period === "am" ? h === 12 ? 0 : h : h === 12 ? 12 : h + 12;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Determines whether the given hour is disabled.
|
|
115
|
+
* @param {number} hour The hour to test.
|
|
116
|
+
* @returns Whether `hour` is disabled.
|
|
117
|
+
*/
|
|
118
|
+
isHourDisabled(hour) {
|
|
119
|
+
if (this.minTime && hour < this.minTime.hour || this.maxTime && hour > this.maxTime.hour) {
|
|
120
|
+
return true;
|
|
121
|
+
}
|
|
122
|
+
if (this.blackoutTimes) {
|
|
123
|
+
for (let minute = 0; minute < 60; minute++) {
|
|
124
|
+
if (!this.blackoutTimes({
|
|
125
|
+
hour,
|
|
126
|
+
minute
|
|
127
|
+
})) {
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return true;
|
|
132
|
+
}
|
|
133
|
+
return false;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Determines whether the given minute of an hour is disabled.
|
|
137
|
+
* @param {number} hour The hour to test.
|
|
138
|
+
* @param {number} minute The minute to test.
|
|
139
|
+
* @returns Whether `minute` is disabled for `hour`.
|
|
140
|
+
*/
|
|
141
|
+
isMinuteDisabled(hour, minute) {
|
|
142
|
+
if (this.minTime) {
|
|
143
|
+
if (hour < this.minTime.hour || hour === this.minTime.hour && minute < this.minTime.minute) {
|
|
144
|
+
return true;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
if (this.maxTime) {
|
|
148
|
+
if (hour > this.maxTime.hour || hour === this.maxTime.hour && minute > this.maxTime.minute) {
|
|
149
|
+
return true;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
if (this.blackoutTimes?.({
|
|
153
|
+
hour,
|
|
154
|
+
minute
|
|
155
|
+
})) {
|
|
156
|
+
return true;
|
|
157
|
+
}
|
|
158
|
+
return false;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
_TimepickerInputElementBase_hour = new WeakMap(), _TimepickerInputElementBase_minute = new WeakMap(), _TimepickerInputElementBase_format = new WeakMap();
|
|
162
|
+
__decorate([property({
|
|
163
|
+
type: Number
|
|
164
|
+
})], TimepickerInputElementBase.prototype, "hour", null);
|
|
165
|
+
__decorate([property({
|
|
166
|
+
type: Number
|
|
167
|
+
})], TimepickerInputElementBase.prototype, "minute", null);
|
|
168
|
+
__decorate([property()], TimepickerInputElementBase.prototype, "format", void 0);
|
|
169
|
+
__decorate([property()], TimepickerInputElementBase.prototype, "view", void 0);
|
|
170
|
+
__decorate([property()], TimepickerInputElementBase.prototype, "period", void 0);
|
|
171
|
+
__decorate([property({
|
|
172
|
+
attribute: "min-time",
|
|
173
|
+
converter: timeConverter
|
|
174
|
+
})], TimepickerInputElementBase.prototype, "minTime", void 0);
|
|
175
|
+
__decorate([property({
|
|
176
|
+
attribute: "max-time",
|
|
177
|
+
converter: timeConverter
|
|
178
|
+
})], TimepickerInputElementBase.prototype, "maxTime", void 0);
|
|
179
|
+
__decorate([property()], TimepickerInputElementBase.prototype, "blackoutTimes", void 0);
|
|
180
|
+
|
|
181
|
+
var _M3eTimepickerDialElement_instances, _M3eTimepickerDialElement_dragState, _M3eTimepickerDialElement_renderHandle, _M3eTimepickerDialElement_renderHourFace, _M3eTimepickerDialElement_renderMinuteFace, _M3eTimepickerDialElement_renderNumeral, _M3eTimepickerDialElement_updateHand, _M3eTimepickerDialElement_handlePointerDown, _M3eTimepickerDialElement_handlePointerMove, _M3eTimepickerDialElement_handlePointerUp, _M3eTimepickerDialElement_angleFromPointer, _M3eTimepickerDialElement_radiusFromPointer, _M3eTimepickerDialElement_isPointerInsideInnerRing, _M3eTimepickerDialElement_hourFromAngle, _M3eTimepickerDialElement_minuteFromAngle, _M3eTimepickerDialElement_changeHour, _M3eTimepickerDialElement_changeMinute;
|
|
182
|
+
/**
|
|
183
|
+
* A clock‑face surface for selecting hours and minutes using a movable hand.
|
|
184
|
+
* @description
|
|
185
|
+
* The `m3e-timepicker-dial` component provides a clock-face experience
|
|
186
|
+
* for selecting hours and minutes. It supports both 12- and 24-hour formats,
|
|
187
|
+
* and exposes view changes through accessible events.
|
|
188
|
+
*
|
|
189
|
+
* @tag m3e-timepicker-dial
|
|
190
|
+
*
|
|
191
|
+
* @attr format - Whether to use a 12‑hour or 24‑hour clock.
|
|
192
|
+
* @attr hour - The hour, in 24-hour time, from 0..23.
|
|
193
|
+
* @attr max-time - The maximum time that can be selected.
|
|
194
|
+
* @attr min-time - The minimum time that can be selected.
|
|
195
|
+
* @attr minute - The minute, from 0..59.
|
|
196
|
+
* @attr period - The 12-hour time period.
|
|
197
|
+
* @attr view - The view used to input time.
|
|
198
|
+
*
|
|
199
|
+
* @fires change - Dispatched when the selected time changes.
|
|
200
|
+
* @fires view-change - Dispatched when the view changes.
|
|
201
|
+
*
|
|
202
|
+
* @cssprop --m3e-timepicker-dial-container-size - Size of the dial container.
|
|
203
|
+
* @cssprop --m3e-timepicker-dial-container-shape - Corner radius of the dial container.
|
|
204
|
+
* @cssprop --m3e-timepicker-dial-container-color - Background color of the dial container.
|
|
205
|
+
* @cssprop --m3e-timepicker-dial-inset - Inset offset applied to the dial surface.
|
|
206
|
+
* @cssprop --m3e-timepicker-dial-center-size - Size of the dial center.
|
|
207
|
+
* @cssprop --m3e-timepicker-dial-handle-color - Color of the active handle.
|
|
208
|
+
* @cssprop --m3e-timepicker-dial-handle-size - Size of the handle.
|
|
209
|
+
* @cssprop --m3e-timepicker-dial-handle-disabled-color - Color of a disabled handle.
|
|
210
|
+
* @cssprop --m3e-timepicker-dial-handle-disabled-opacity - Opacity of a disabled handle.
|
|
211
|
+
* @cssprop --m3e-timepicker-dial-dial-inset - Inset applied to the handle area.
|
|
212
|
+
* @cssprop --m3e-timepicker-dial-numeral-size - Size of the dial numerals.
|
|
213
|
+
* @cssprop --m3e-timepicker-dial-numeral-color - Text color of inactive numerals.
|
|
214
|
+
* @cssprop --m3e-timepicker-dial-numeral-shape - Corner radius of the numerals.
|
|
215
|
+
* @cssprop --m3e-timepicker-dial-numeral-font-size - Font size of the outer numerals.
|
|
216
|
+
* @cssprop --m3e-timepicker-dial-numeral-font-weight - Font weight of the outer numerals.
|
|
217
|
+
* @cssprop --m3e-timepicker-dial-numeral-line-height - Line height of the outer numerals.
|
|
218
|
+
* @cssprop --m3e-timepicker-dial-numeral-tracking - Letter spacing of the outer numerals.
|
|
219
|
+
* @cssprop --m3e-timepicker-dial-inner-numeral-font-size - Font size of the inner numerals.
|
|
220
|
+
* @cssprop --m3e-timepicker-dial-inner-numeral-font-weight - Font weight of the inner numerals.
|
|
221
|
+
* @cssprop --m3e-timepicker-dial-inner-numeral-line-height - Line height of the inner numerals.
|
|
222
|
+
* @cssprop --m3e-timepicker-dial-inner-numeral-tracking - Letter spacing of the inner numerals.
|
|
223
|
+
* @cssprop --m3e-timepicker-dial-numeral-active-color - Color of active numerals.
|
|
224
|
+
* @cssprop --m3e-timepicker-dial-numeral-disabled-color - Color of disabled numerals.
|
|
225
|
+
* @cssprop --m3e-timepicker-dial-numeral-disabled-opacity - Opacity of disabled numerals.
|
|
226
|
+
* @cssprop --m3e-timepicker-dial-handle-center-size - Size of the handle center indicator.
|
|
227
|
+
*/
|
|
228
|
+
let M3eTimepickerDialElement = class M3eTimepickerDialElement extends SuppressInitialAnimation(AttachInternals(Role(TimepickerInputElementBase, "none"))) {
|
|
229
|
+
constructor() {
|
|
230
|
+
super(...arguments);
|
|
231
|
+
_M3eTimepickerDialElement_instances.add(this);
|
|
232
|
+
/** @private */
|
|
233
|
+
_M3eTimepickerDialElement_dragState.set(this, void 0);
|
|
234
|
+
}
|
|
235
|
+
/** @inheritdoc */
|
|
236
|
+
connectedCallback() {
|
|
237
|
+
this.ariaHidden = "true";
|
|
238
|
+
super.connectedCallback();
|
|
239
|
+
}
|
|
240
|
+
/** @inheritdoc */
|
|
241
|
+
updated(_changedProperties) {
|
|
242
|
+
super.updated(_changedProperties);
|
|
243
|
+
if (_changedProperties.has("hour") || _changedProperties.has("minute") || _changedProperties.has("view") || _changedProperties.has("period") || _changedProperties.has("minTime") || _changedProperties.has("maxTime") || _changedProperties.has("blackoutTimes")) {
|
|
244
|
+
__classPrivateFieldGet(this, _M3eTimepickerDialElement_instances, "m", _M3eTimepickerDialElement_updateHand).call(this);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
/** @inheritdoc */
|
|
248
|
+
render() {
|
|
249
|
+
return html`<div class="base" @pointerdown="${__classPrivateFieldGet(this, _M3eTimepickerDialElement_instances, "m", _M3eTimepickerDialElement_handlePointerDown)}" @pointermove="${__classPrivateFieldGet(this, _M3eTimepickerDialElement_instances, "m", _M3eTimepickerDialElement_handlePointerMove)}" @pointerup="${__classPrivateFieldGet(this, _M3eTimepickerDialElement_instances, "m", _M3eTimepickerDialElement_handlePointerUp)}">${__classPrivateFieldGet(this, _M3eTimepickerDialElement_instances, "m", _M3eTimepickerDialElement_renderHandle).call(this)} ${__classPrivateFieldGet(this, _M3eTimepickerDialElement_instances, "m", _M3eTimepickerDialElement_renderHourFace).call(this)} ${__classPrivateFieldGet(this, _M3eTimepickerDialElement_instances, "m", _M3eTimepickerDialElement_renderMinuteFace).call(this)}<div class="center"></div></div>`;
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
_M3eTimepickerDialElement_dragState = new WeakMap();
|
|
253
|
+
_M3eTimepickerDialElement_instances = new WeakSet();
|
|
254
|
+
_M3eTimepickerDialElement_renderHandle = function _M3eTimepickerDialElement_renderHandle() {
|
|
255
|
+
const showHand = this.view === "hour" && this.hour !== null || this.view === "minute" && this.minute !== null;
|
|
256
|
+
return showHand ? html`<div class="handle"></div>` : nothing;
|
|
257
|
+
};
|
|
258
|
+
_M3eTimepickerDialElement_renderHourFace = function _M3eTimepickerDialElement_renderHourFace() {
|
|
259
|
+
const use24 = this.currentFormat === "24";
|
|
260
|
+
const step = 30;
|
|
261
|
+
const outer = Array.from({
|
|
262
|
+
length: 12
|
|
263
|
+
}, (_, i) => {
|
|
264
|
+
const hour = i === 0 ? 12 : i;
|
|
265
|
+
const angle = i * step;
|
|
266
|
+
const active = this.hour === null ? false : !use24 ? this.hour % 12 === i : this.hour < 13 && this.hour > 0 && this.hour % 12 === i;
|
|
267
|
+
const disabled = this.isHourDisabled(use24 ? hour : this.period === "pm" ? hour % 12 + 12 : hour % 12);
|
|
268
|
+
return __classPrivateFieldGet(this, _M3eTimepickerDialElement_instances, "m", _M3eTimepickerDialElement_renderNumeral).call(this, `${hour}`, angle, active, disabled);
|
|
269
|
+
});
|
|
270
|
+
const inner = !use24 ? nothing : Array.from({
|
|
271
|
+
length: 12
|
|
272
|
+
}, (_, i) => {
|
|
273
|
+
const hour = i + 13;
|
|
274
|
+
const angle = (i + 1) * step;
|
|
275
|
+
const active = this.hour === 0 && hour === 24 || this.hour === hour;
|
|
276
|
+
const disabled = this.isHourDisabled(hour === 24 ? 0 : hour);
|
|
277
|
+
return __classPrivateFieldGet(this, _M3eTimepickerDialElement_instances, "m", _M3eTimepickerDialElement_renderNumeral).call(this, hour == 24 ? "00" : `${hour}`, angle, active, disabled, true);
|
|
278
|
+
});
|
|
279
|
+
return html`<div class="${classMap({
|
|
280
|
+
dial: true,
|
|
281
|
+
hour: true,
|
|
282
|
+
hidden: this.view !== "hour"
|
|
283
|
+
})}">${outer}${inner}</div>`;
|
|
284
|
+
};
|
|
285
|
+
_M3eTimepickerDialElement_renderMinuteFace = function _M3eTimepickerDialElement_renderMinuteFace() {
|
|
286
|
+
return html`<div class="${classMap({
|
|
287
|
+
dial: true,
|
|
288
|
+
minute: true,
|
|
289
|
+
hidden: this.view !== "minute"
|
|
290
|
+
})}">${Array.from({
|
|
291
|
+
length: 60
|
|
292
|
+
}, (_, i) => {
|
|
293
|
+
if (i % 5 !== 0) return;
|
|
294
|
+
const angle = i * 6;
|
|
295
|
+
const label = i % 5 === 0 ? i.toString().padStart(2, "0") : "";
|
|
296
|
+
const active = i === this.minute;
|
|
297
|
+
const disabled = this.hour !== null && this.isMinuteDisabled(this.hour, i);
|
|
298
|
+
return __classPrivateFieldGet(this, _M3eTimepickerDialElement_instances, "m", _M3eTimepickerDialElement_renderNumeral).call(this, label, angle, active, disabled);
|
|
299
|
+
})}</div>`;
|
|
300
|
+
};
|
|
301
|
+
_M3eTimepickerDialElement_renderNumeral = function _M3eTimepickerDialElement_renderNumeral(label, angle, active, disabled, inner = false) {
|
|
302
|
+
return html`<div class="${classMap({
|
|
303
|
+
numeral: true,
|
|
304
|
+
inner,
|
|
305
|
+
active,
|
|
306
|
+
disabled
|
|
307
|
+
})}" style="${safeStyleMap({
|
|
308
|
+
"--_numeral-angle": `${angle}deg`
|
|
309
|
+
})}">${label}</div>`;
|
|
310
|
+
};
|
|
311
|
+
_M3eTimepickerDialElement_updateHand = function _M3eTimepickerDialElement_updateHand() {
|
|
312
|
+
const hand = this.shadowRoot?.querySelector(".handle");
|
|
313
|
+
const center = this.shadowRoot?.querySelector(".center");
|
|
314
|
+
if (!hand || !center) return;
|
|
315
|
+
let active = false;
|
|
316
|
+
let inner = false;
|
|
317
|
+
let angle = null;
|
|
318
|
+
let disabled = false;
|
|
319
|
+
switch (this.view) {
|
|
320
|
+
case "hour":
|
|
321
|
+
if (this.hour !== null) {
|
|
322
|
+
active = true;
|
|
323
|
+
angle = this.hour % 12 * 30;
|
|
324
|
+
inner = this.currentFormat === "24" && (this.hour < 1 || this.hour > 12);
|
|
325
|
+
disabled = this.isHourDisabled(this.hour);
|
|
326
|
+
}
|
|
327
|
+
break;
|
|
328
|
+
case "minute":
|
|
329
|
+
if (this.minute !== null) {
|
|
330
|
+
angle = this.minute * 6;
|
|
331
|
+
active = this.minute % 5 === 0;
|
|
332
|
+
disabled = this.hour !== null && this.isMinuteDisabled(this.hour, this.minute);
|
|
333
|
+
}
|
|
334
|
+
break;
|
|
335
|
+
}
|
|
336
|
+
hand.classList.toggle("active", active);
|
|
337
|
+
hand.classList.toggle("inner", inner);
|
|
338
|
+
hand.classList.toggle("disabled", disabled);
|
|
339
|
+
center.classList.toggle("disabled", disabled);
|
|
340
|
+
if (angle != null) {
|
|
341
|
+
hand.style.setProperty("--_hand-angle", `${angle}`);
|
|
342
|
+
} else {
|
|
343
|
+
hand.style.removeProperty("--_hand-angle");
|
|
344
|
+
}
|
|
345
|
+
};
|
|
346
|
+
_M3eTimepickerDialElement_handlePointerDown = function _M3eTimepickerDialElement_handlePointerDown(e) {
|
|
347
|
+
if (e.pointerType === "mouse" && e.button > 1 || !(e.currentTarget instanceof HTMLElement)) return;
|
|
348
|
+
e.currentTarget.setPointerCapture(e.pointerId);
|
|
349
|
+
e.currentTarget.classList.add("dragging");
|
|
350
|
+
__classPrivateFieldSet(this, _M3eTimepickerDialElement_dragState, {
|
|
351
|
+
timeChanged: false,
|
|
352
|
+
cachedRect: e.currentTarget.getBoundingClientRect(),
|
|
353
|
+
cachedInnerInset: this.view === "hour" && this.currentFormat === "24" ? computeCssSize(e.currentTarget, "calc(var(--m3e-timepicker-dial-numeral-size, 2.5rem) + var(--m3e-timepicker-dial-inset, 4px))") : 0
|
|
354
|
+
}, "f");
|
|
355
|
+
__classPrivateFieldGet(this, _M3eTimepickerDialElement_dragState, "f").timeChanged = this.view === "hour" ? __classPrivateFieldGet(this, _M3eTimepickerDialElement_instances, "m", _M3eTimepickerDialElement_changeHour).call(this, __classPrivateFieldGet(this, _M3eTimepickerDialElement_instances, "m", _M3eTimepickerDialElement_hourFromAngle).call(this, __classPrivateFieldGet(this, _M3eTimepickerDialElement_instances, "m", _M3eTimepickerDialElement_angleFromPointer).call(this, e, __classPrivateFieldGet(this, _M3eTimepickerDialElement_dragState, "f")), __classPrivateFieldGet(this, _M3eTimepickerDialElement_instances, "m", _M3eTimepickerDialElement_isPointerInsideInnerRing).call(this, e, __classPrivateFieldGet(this, _M3eTimepickerDialElement_dragState, "f")))) : __classPrivateFieldGet(this, _M3eTimepickerDialElement_instances, "m", _M3eTimepickerDialElement_changeMinute).call(this, __classPrivateFieldGet(this, _M3eTimepickerDialElement_instances, "m", _M3eTimepickerDialElement_minuteFromAngle).call(this, __classPrivateFieldGet(this, _M3eTimepickerDialElement_instances, "m", _M3eTimepickerDialElement_angleFromPointer).call(this, e, __classPrivateFieldGet(this, _M3eTimepickerDialElement_dragState, "f"))));
|
|
356
|
+
};
|
|
357
|
+
_M3eTimepickerDialElement_handlePointerMove = function _M3eTimepickerDialElement_handlePointerMove(e) {
|
|
358
|
+
if (!(e.currentTarget instanceof HTMLElement) || !e.currentTarget.hasPointerCapture(e.pointerId) || !__classPrivateFieldGet(this, _M3eTimepickerDialElement_dragState, "f")) return;
|
|
359
|
+
__classPrivateFieldGet(this, _M3eTimepickerDialElement_dragState, "f").timeChanged = (this.view === "hour" ? __classPrivateFieldGet(this, _M3eTimepickerDialElement_instances, "m", _M3eTimepickerDialElement_changeHour).call(this, __classPrivateFieldGet(this, _M3eTimepickerDialElement_instances, "m", _M3eTimepickerDialElement_hourFromAngle).call(this, __classPrivateFieldGet(this, _M3eTimepickerDialElement_instances, "m", _M3eTimepickerDialElement_angleFromPointer).call(this, e, __classPrivateFieldGet(this, _M3eTimepickerDialElement_dragState, "f")), __classPrivateFieldGet(this, _M3eTimepickerDialElement_instances, "m", _M3eTimepickerDialElement_isPointerInsideInnerRing).call(this, e, __classPrivateFieldGet(this, _M3eTimepickerDialElement_dragState, "f")))) : __classPrivateFieldGet(this, _M3eTimepickerDialElement_instances, "m", _M3eTimepickerDialElement_changeMinute).call(this, __classPrivateFieldGet(this, _M3eTimepickerDialElement_instances, "m", _M3eTimepickerDialElement_minuteFromAngle).call(this, __classPrivateFieldGet(this, _M3eTimepickerDialElement_instances, "m", _M3eTimepickerDialElement_angleFromPointer).call(this, e, __classPrivateFieldGet(this, _M3eTimepickerDialElement_dragState, "f"))))) || __classPrivateFieldGet(this, _M3eTimepickerDialElement_dragState, "f").timeChanged;
|
|
360
|
+
};
|
|
361
|
+
_M3eTimepickerDialElement_handlePointerUp = function _M3eTimepickerDialElement_handlePointerUp(e) {
|
|
362
|
+
if (!(e.currentTarget instanceof HTMLElement) || !e.currentTarget.hasPointerCapture(e.pointerId) || !__classPrivateFieldGet(this, _M3eTimepickerDialElement_dragState, "f")) return;
|
|
363
|
+
e.currentTarget.releasePointerCapture(e.pointerId);
|
|
364
|
+
e.currentTarget.classList.remove("dragging");
|
|
365
|
+
if (__classPrivateFieldGet(this, _M3eTimepickerDialElement_dragState, "f").timeChanged) {
|
|
366
|
+
this.dispatchEvent(new Event("change", {
|
|
367
|
+
bubbles: true
|
|
368
|
+
}));
|
|
369
|
+
}
|
|
370
|
+
if (this.view === "hour" && (__classPrivateFieldGet(this, _M3eTimepickerDialElement_dragState, "f").timeChanged || this.isHourDisabled(__classPrivateFieldGet(this, _M3eTimepickerDialElement_instances, "m", _M3eTimepickerDialElement_hourFromAngle).call(this, __classPrivateFieldGet(this, _M3eTimepickerDialElement_instances, "m", _M3eTimepickerDialElement_angleFromPointer).call(this, e, __classPrivateFieldGet(this, _M3eTimepickerDialElement_dragState, "f")), __classPrivateFieldGet(this, _M3eTimepickerDialElement_instances, "m", _M3eTimepickerDialElement_isPointerInsideInnerRing).call(this, e, __classPrivateFieldGet(this, _M3eTimepickerDialElement_dragState, "f")))) !== true)) {
|
|
371
|
+
this.view = "minute";
|
|
372
|
+
this.dispatchEvent(new CustomEvent("view-change"));
|
|
373
|
+
}
|
|
374
|
+
__classPrivateFieldSet(this, _M3eTimepickerDialElement_dragState, undefined, "f");
|
|
375
|
+
};
|
|
376
|
+
_M3eTimepickerDialElement_angleFromPointer = function _M3eTimepickerDialElement_angleFromPointer(e, state) {
|
|
377
|
+
const cx = state.cachedRect.left + state.cachedRect.width / 2;
|
|
378
|
+
const cy = state.cachedRect.top + state.cachedRect.height / 2;
|
|
379
|
+
return (Math.atan2(e.clientY - cy, e.clientX - cx) * 180 / Math.PI + 450) % 360;
|
|
380
|
+
};
|
|
381
|
+
_M3eTimepickerDialElement_radiusFromPointer = function _M3eTimepickerDialElement_radiusFromPointer(e, state) {
|
|
382
|
+
const cx = state.cachedRect.left + state.cachedRect.width / 2;
|
|
383
|
+
const cy = state.cachedRect.top + state.cachedRect.height / 2;
|
|
384
|
+
const dx = e.clientX - cx;
|
|
385
|
+
const dy = e.clientY - cy;
|
|
386
|
+
return Math.sqrt(dx * dx + dy * dy);
|
|
387
|
+
};
|
|
388
|
+
_M3eTimepickerDialElement_isPointerInsideInnerRing = function _M3eTimepickerDialElement_isPointerInsideInnerRing(e, state) {
|
|
389
|
+
if (state.cachedInnerInset <= 0) return false;
|
|
390
|
+
return __classPrivateFieldGet(this, _M3eTimepickerDialElement_instances, "m", _M3eTimepickerDialElement_radiusFromPointer).call(this, e, state) < state.cachedRect.width / 2 - state.cachedInnerInset;
|
|
391
|
+
};
|
|
392
|
+
_M3eTimepickerDialElement_hourFromAngle = function _M3eTimepickerDialElement_hourFromAngle(angle, inner) {
|
|
393
|
+
const index = Math.round(angle / 30) % 12;
|
|
394
|
+
const hour = inner ? index === 0 ? 0 : index + 12 : index === 0 ? 12 : index;
|
|
395
|
+
return this.currentFormat === "24" ? hour : this.period === "pm" ? hour % 12 + 12 : hour % 12;
|
|
396
|
+
};
|
|
397
|
+
_M3eTimepickerDialElement_minuteFromAngle = function _M3eTimepickerDialElement_minuteFromAngle(angle) {
|
|
398
|
+
return Math.round(angle / 6) % 60;
|
|
399
|
+
};
|
|
400
|
+
_M3eTimepickerDialElement_changeHour = function _M3eTimepickerDialElement_changeHour(hour) {
|
|
401
|
+
if (this.hour !== hour && !this.isHourDisabled(hour)) {
|
|
402
|
+
this.hour = hour;
|
|
403
|
+
return true;
|
|
404
|
+
}
|
|
405
|
+
return false;
|
|
406
|
+
};
|
|
407
|
+
_M3eTimepickerDialElement_changeMinute = function _M3eTimepickerDialElement_changeMinute(minute) {
|
|
408
|
+
if (this.hour !== null && this.isMinuteDisabled(this.hour, minute)) return false;
|
|
409
|
+
if (this.minute !== minute) {
|
|
410
|
+
this.minute = minute;
|
|
411
|
+
return true;
|
|
412
|
+
}
|
|
413
|
+
return false;
|
|
414
|
+
};
|
|
415
|
+
/** The styles of the element. */
|
|
416
|
+
M3eTimepickerDialElement.styles = css`:host { display: block; width: var(--m3e-timepicker-dial-container-size, 16rem); aspect-ratio: 1 / 1; } .base { contain: layout style paint; position: relative; width: 100%; height: 100%; touch-action: none; border-radius: var(--m3e-timepicker-dial-container-shape, ${DesignToken.shape.corner.full}); background-color: var(--m3e-timepicker-dial-container-color, ${DesignToken.color.surfaceContainerHighest}); } .base:not(.dragging) { cursor: grab; } .base.dragging { cursor: grabbing; } .dial { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: inherit; pointer-events: none; border-radius: inherit; --_numeral-radius: calc( calc(var(--m3e-timepicker-dial-container-size, 16rem) / 2) - calc( var(--m3e-timepicker-dial-numeral-size, 2.5rem) / 2 ) - var(--m3e-timepicker-dial-inset, 4px) ); } :host(:not(:is(:state(--no-animate), :--no-animate))) .dial { transition: ${unsafeCSS(`opacity ${DesignToken.motion.duration.medium1} ${DesignToken.motion.easing.standard},
|
|
417
|
+
transform ${DesignToken.motion.duration.medium1} ${DesignToken.motion.easing.standard}`)}; } .dial:not(.hidden) { opacity: 1; transform: scale(1); } .dial.hidden { opacity: 0; } .dial.hour.hidden { transform: scale(1.2); } .dial.minute.hidden { transform: scale(0.8); } .center { position: absolute; box-sizing: border-box; bottom: calc(50% - calc(var(--m3e-timepicker-dial-center-size, 8px) / 2)); left: calc(50% - calc(var(--m3e-timepicker-dial-center-size, 8px) / 2)); width: var(--m3e-timepicker-dial-center-size, 8px); height: var(--m3e-timepicker-dial-center-size, 8px); touch-action: inherit; pointer-events: none; border-radius: 50%; } .center::before, .center::after { content: ""; position: absolute; inset: 0; width: 100%; height: 100%; border-radius: inherit; } .center::before { background-color: var(--m3e-timepicker-dial-container-color, ${DesignToken.color.surfaceContainerHighest}); } .center:not(.disabled)::after { background-color: var(--m3e-timepicker-dial-handle-color, ${DesignToken.color.primary}); } .center.disabled::after { background-color: color-mix( in srgb, var(--m3e-timepicker-dial-handle-disabled-color, ${DesignToken.color.onSurface}) var(--m3e-timepicker-dial-handle-disabled-opacity, 10%), transparent ); } .handle { position: absolute; touch-action: inherit; left: calc(50% - calc(var(--m3e-timepicker-dial-handle-size, 2px) / 2)); width: var(--m3e-timepicker-dial-handle-size, 2px); transform: rotate(calc(var(--_hand-angle, 0) * 1deg)); transform-origin: bottom; } .handle:not(.disabled) { background-color: var(--m3e-timepicker-dial-handle-color, ${DesignToken.color.primary}); } .handle.disabled { background-color: color-mix( in srgb, var(--m3e-timepicker-dial-handle-disabled-color, ${DesignToken.color.onSurface}) var(--m3e-timepicker-dial-handle-disabled-opacity, 10%), transparent ); } :host(:not(:is(:state(--no-animate), :--no-animate))) .base:not(.dragging) .handle { transition: ${unsafeCSS(`transform ${DesignToken.motion.duration.medium1} ${DesignToken.motion.easing.standard}`)}; } .handle:not(.inner) { top: calc(var(--m3e-timepicker-dial-dial-inset, 4px) + var(--m3e-timepicker-dial-numeral-size, 2.5rem)); height: calc(50% - var(--m3e-timepicker-dial-dial-inset, 4px) - var(--m3e-timepicker-dial-numeral-size, 2.5rem)); } .handle.inner { top: calc( var(--m3e-timepicker-dial-numeral-size, 2.5rem) + var(--m3e-timepicker-dial-dial-inset, 4px) + var(--m3e-timepicker-dial-numeral-size, 2.5rem) ); height: calc( 50% - calc( var(--m3e-timepicker-dial-numeral-size, 2.5rem) + var(--m3e-timepicker-dial-dial-inset, 4px) + var(--m3e-timepicker-dial-numeral-size, 2.5rem) ) ); } .handle::before { content: ""; position: absolute; touch-action: inherit; width: var(--m3e-timepicker-dial-numeral-size, 2.5rem); height: var(--m3e-timepicker-dial-numeral-size, 2.5rem); top: calc(0px - var(--m3e-timepicker-dial-numeral-size, 2.5rem)); left: calc( 0px - calc(var(--m3e-timepicker-dial-numeral-size, 2.5rem) / 2) + calc(var(--m3e-timepicker-dial-handle-size, 2px) / 2) ); border-radius: 50%; box-sizing: border-box; } .handle:not(.disabled)::before { background-color: var(--m3e-timepicker-dial-handle-color, ${DesignToken.color.primary}); } .handle.disabled::before { background-color: color-mix( in srgb, var(--m3e-timepicker-dial-handle-disabled-color, ${DesignToken.color.onSurface}) var(--m3e-timepicker-dial-handle-disabled-opacity, 10%), transparent ); } .handle:not(.active)::after { content: ""; position: absolute; touch-action: inherit; width: var(--m3e-timepicker-dial-handle-center-size, 4px); height: var(--m3e-timepicker-dial-handle-center-size, 4px); top: calc( 0px - calc(var(--m3e-timepicker-dial-numeral-size, 2.5rem) / 2) - calc( var(--m3e-timepicker-dial-handle-center-size, 4px) / 2 ) ); left: calc(50% - calc(var(--m3e-timepicker-dial-handle-center-size, 4px) / 2)); border-radius: 50%; box-sizing: border-box; } .handle:not(.active):not(.disabled)::after { background-color: var(--m3e-timepicker-dial-numeral-active-color, ${DesignToken.color.onPrimary}); } .handle:not(.active).disabled::after { background-color: color-mix( in srgb, var(--m3e-timepicker-dial-numeral-disabled-color, ${DesignToken.color.onSurface}) var(--m3e-timepicker-dial-numeral-disabled-opacity, 38%), transparent ); } .numeral { user-select: none; touch-action: inherit; position: absolute; inset: 50%; translate: -50% -50%; width: var(--m3e-timepicker-dial-numeral-size, 2.5rem); aspect-ratio: 1 / 1; display: flex; align-items: center; justify-content: center; border-radius: var(--m3e-timepicker-dial-numeral-shape, ${DesignToken.shape.corner.full}); } :host(:not(:is(:state(--no-animate), :--no-animate))) .numeral.active { transition-delay: ${DesignToken.motion.duration.medium1}; transition: ${unsafeCSS(`color ${DesignToken.motion.duration.short1} ${DesignToken.motion.easing.standard}`)}; } .numeral:not(.active):not(.disabled) { color: var(--m3e-timepicker-dial-numeral-color, ${DesignToken.color.onSurface}); } .numeral.active:not(.disabled) { color: var(--m3e-timepicker-dial-numeral-active-color, ${DesignToken.color.onPrimary}); } .numeral.disabled { color: color-mix( in srgb, var(--m3e-timepicker-dial-numeral-disabled-color, ${DesignToken.color.onSurface}) var(--m3e-timepicker-dial-numeral-disabled-opacity, 38%), transparent ); } .numeral:not(.inner) { transform: rotate(var(--_numeral-angle)) translateY(calc(-1 * var(--_numeral-radius))) rotate(calc(-1 * var(--_numeral-angle))); font-size: var(--m3e-timepicker-dial-numeral-font-size, ${DesignToken.typescale.standard.body.large.fontSize}); font-weight: var( --m3e-timepicker-dial-numeral-font-weight, ${DesignToken.typescale.standard.body.large.fontWeight} ); line-height: var( --m3e-timepicker-dial-numeral-line-height, ${DesignToken.typescale.standard.body.large.lineHeight} ); letter-spacing: var( --m3e-timepicker-dial-numeral-tracking, ${DesignToken.typescale.standard.body.large.tracking} ); } .numeral.inner { transform: rotate(var(--_numeral-angle)) translateY(calc(calc(-1 * var(--_numeral-radius)) + var(--m3e-timepicker-dial-numeral-size, 2.5rem))) rotate(calc(-1 * var(--_numeral-angle))); font-size: var( --m3e-timepicker-dial-inner-numeral-font-size, ${DesignToken.typescale.standard.body.small.fontSize} ); font-weight: var( --m3e-timepicker-dial-inner-numeral-font-weight, ${DesignToken.typescale.standard.body.small.fontWeight} ); line-height: var( --m3e-timepicker-dial-inner-numeral-line-height, ${DesignToken.typescale.standard.body.small.lineHeight} ); letter-spacing: var( --m3e-timepicker-dial-inner-numeral-tracking, ${DesignToken.typescale.standard.body.small.tracking} ); } @media (forced-colors: active) { .base, .center::before { background-color: Canvas; } .numeral:not(.active):not(.disabled) { color: CanvasText; } .center:not(.disabled)::after, .handle:not(.disabled) { background-color: Highlight; } .handle:not(.disabled)::before { background-color: unset; outline: var(--m3e-timepicker-dial-handle-size, 2px) solid Highlight; } .handle:not(.active):not(.disabled)::after { background-color: Highlight; } .numeral.active:not(.disabled) { color: Highlight; } .center.disabled::after, .handle:not(.active).disabled::after, .handle.disabled { background-color: GrayText; } .handle.disabled::before { background-color: unset; outline: var(--m3e-timepicker-dial-handle-size, 2px) solid GrayText; } .numeral.disabled:not(.active), .numeral.disabled.active { color: GrayText; } .numeral { forced-color-adjust: none; background-color: transparent; } .base { outline: 1px solid CanvasText; } } @media (prefers-reduced-motion) { :host(:not(:is(:state(--no-animate), :--no-animate))) .dial, :host(:not(:is(:state(--no-animate), :--no-animate))) .base:not(.dragging) .handle, :host(:not(:is(:state(--no-animate), :--no-animate))) .numeral.active { transition: none; } }`;
|
|
418
|
+
M3eTimepickerDialElement = __decorate([customElement("m3e-timepicker-dial")], M3eTimepickerDialElement);
|
|
419
|
+
|
|
420
|
+
var _M3eTimepickerInputPeriodToggleElement_instances, _M3eTimepickerInputPeriodToggleElement_handleKeyDown, _M3eTimepickerInputPeriodToggleElement_handleClick;
|
|
421
|
+
/** @internal An internal element responsible for selecting a time period (AM/PM). */
|
|
422
|
+
let M3eTimepickerInputPeriodToggleElement = class M3eTimepickerInputPeriodToggleElement extends Role(LitElement, "radiogroup") {
|
|
423
|
+
constructor() {
|
|
424
|
+
super(...arguments);
|
|
425
|
+
_M3eTimepickerInputPeriodToggleElement_instances.add(this);
|
|
426
|
+
/** The 12-hour time period. */
|
|
427
|
+
this.period = "am";
|
|
428
|
+
/** The orientation of the toggle. */
|
|
429
|
+
this.orientation = "vertical";
|
|
430
|
+
}
|
|
431
|
+
/** @inheritdoc */
|
|
432
|
+
render() {
|
|
433
|
+
const format = new Intl.DateTimeFormat(navigator.language, {
|
|
434
|
+
hour: "numeric",
|
|
435
|
+
hour12: true
|
|
436
|
+
});
|
|
437
|
+
return html`<div class="base" tabindex="-1" @keydown="${__classPrivateFieldGet(this, _M3eTimepickerInputPeriodToggleElement_instances, "m", _M3eTimepickerInputPeriodToggleElement_handleKeyDown)}"><div id="am" class="period-button" role="radio" aria-checked="${this.period === "am" ? "true" : "false"}" tabindex="${this.period === "am" ? "0" : "-1"}" @click="${__classPrivateFieldGet(this, _M3eTimepickerInputPeriodToggleElement_instances, "m", _M3eTimepickerInputPeriodToggleElement_handleClick)}"><m3e-focus-ring class="focus-ring" for="am"></m3e-focus-ring><m3e-state-layer class="state-layer" for="am"></m3e-state-layer><m3e-ripple class="ripple" centered for="am"></m3e-ripple>${format.formatToParts(new Date(2020, 0, 1, 9)).find(p => p.type === "dayPeriod")?.value ?? "AM"}</div><div class="divider" aria-hidden="true"></div><div id="pm" class="period-button" role="radio" aria-checked="${this.period === "pm" ? "true" : "false"}" tabindex="${this.period === "pm" ? "0" : "-1"}" @click="${__classPrivateFieldGet(this, _M3eTimepickerInputPeriodToggleElement_instances, "m", _M3eTimepickerInputPeriodToggleElement_handleClick)}"><m3e-focus-ring class="focus-ring" for="pm"></m3e-focus-ring><m3e-state-layer class="state-layer" for="pm"></m3e-state-layer><m3e-ripple class="ripple" centered for="pm"></m3e-ripple>${format.formatToParts(new Date(2020, 0, 1, 21)).find(p => p.type === "dayPeriod")?.value ?? "PM"}</div></div>`;
|
|
438
|
+
}
|
|
439
|
+
};
|
|
440
|
+
_M3eTimepickerInputPeriodToggleElement_instances = new WeakSet();
|
|
441
|
+
_M3eTimepickerInputPeriodToggleElement_handleKeyDown = function _M3eTimepickerInputPeriodToggleElement_handleKeyDown(e) {
|
|
442
|
+
if (e.defaultPrevented) return;
|
|
443
|
+
const changePeriod = (prev, next) => {
|
|
444
|
+
if (this.period === prev) {
|
|
445
|
+
this.period = next;
|
|
446
|
+
this.shadowRoot?.querySelector(`#${this.period}`)?.focus();
|
|
447
|
+
this.dispatchEvent(new Event("change", {
|
|
448
|
+
bubbles: true
|
|
449
|
+
}));
|
|
450
|
+
}
|
|
451
|
+
};
|
|
452
|
+
switch (e.key) {
|
|
453
|
+
case "Left":
|
|
454
|
+
case "ArrowLeft":
|
|
455
|
+
e.preventDefault();
|
|
456
|
+
if (this.orientation === "horizontal") {
|
|
457
|
+
if (M3eDirectionality.current === "rtl") {
|
|
458
|
+
changePeriod("am", "pm");
|
|
459
|
+
} else {
|
|
460
|
+
changePeriod("pm", "am");
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
break;
|
|
464
|
+
case "Right":
|
|
465
|
+
case "ArrowRight":
|
|
466
|
+
e.preventDefault();
|
|
467
|
+
if (this.orientation === "horizontal") {
|
|
468
|
+
if (M3eDirectionality.current === "rtl") {
|
|
469
|
+
changePeriod("pm", "am");
|
|
470
|
+
} else {
|
|
471
|
+
changePeriod("am", "pm");
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
break;
|
|
475
|
+
case "Up":
|
|
476
|
+
case "ArrowUp":
|
|
477
|
+
e.preventDefault();
|
|
478
|
+
if (this.orientation === "vertical") {
|
|
479
|
+
changePeriod("pm", "am");
|
|
480
|
+
}
|
|
481
|
+
break;
|
|
482
|
+
case "Down":
|
|
483
|
+
case "ArrowDown":
|
|
484
|
+
e.preventDefault();
|
|
485
|
+
if (this.orientation === "vertical") {
|
|
486
|
+
changePeriod("am", "pm");
|
|
487
|
+
}
|
|
488
|
+
break;
|
|
489
|
+
}
|
|
490
|
+
};
|
|
491
|
+
_M3eTimepickerInputPeriodToggleElement_handleClick = function _M3eTimepickerInputPeriodToggleElement_handleClick(e) {
|
|
492
|
+
const period = e.currentTarget.id;
|
|
493
|
+
if (period !== this.period) {
|
|
494
|
+
this.period = period;
|
|
495
|
+
this.dispatchEvent(new Event("change", {
|
|
496
|
+
bubbles: true
|
|
497
|
+
}));
|
|
498
|
+
}
|
|
499
|
+
};
|
|
500
|
+
/** The styles of the element. */
|
|
501
|
+
M3eTimepickerInputPeriodToggleElement.styles = css`:host { display: block; } .base { contain: layout style; display: flex; align-items: center; justify-content: center; box-sizing: border-box; width: 100%; height: 100%; border-radius: var(--m3e-timepicker-input-period-toggle-shape, ${DesignToken.shape.corner.small}); border: var(--m3e-timepicker-input-period-toggle-outline-thickness, 1px) solid var(--m3e-timepicker-input-period-toggle-outline-color, ${DesignToken.color.outline}); } :host([orientation="vertical"]) { height: var(--m3e-timepicker-input-period-toggle-vertical-height, 5rem); width: var(--m3e-timepicker-input-period-toggle-vertical-width, 3.25rem); } :host([orientation="vertical"]) .base { flex-direction: column; } :host([orientation="horizontal"]) { height: var(--m3e-timepicker-input-period-toggle-horizontal-height, 2.375rem); width: var(--m3e-timepicker-input-period-toggle-horizontal-width, 13.5rem); } .period-button { display: flex; align-items: center; justify-content: center; outline: none; user-select: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); cursor: pointer; position: relative; transition: ${unsafeCSS(`background-color color ${DesignToken.motion.duration.short4} ${DesignToken.motion.easing.standard},
|
|
502
|
+
color ${DesignToken.motion.duration.short4} ${DesignToken.motion.easing.standard}`)}; font-size: var( --m3e-timepicker-input-period-toggle-label-font-size, ${DesignToken.typescale.standard.title.medium.fontSize} ); font-weight: var( --m3e-timepicker-input-period-toggle-label-font-weight, ${DesignToken.typescale.standard.title.medium.fontWeight} ); line-height: var( --m3e-timepicker-input-period-toggle-label-line-height, ${DesignToken.typescale.standard.title.medium.lineHeight} ); letter-spacing: var( --m3e-timepicker-input-period-toggle-label-tracking, ${DesignToken.typescale.standard.title.medium.tracking} ); } :host([orientation="vertical"]) .period-button { height: 50%; width: 100%; } :host([orientation="horizontal"]) .period-button { height: 100%; width: 50%; } :host([orientation="vertical"]) .period-button:first-child { border-start-start-radius: inherit; border-start-end-radius: inherit; } :host([orientation="horizontal"]) .period-button:first-child { border-start-start-radius: inherit; border-end-start-radius: inherit; } .divider { flex: none; } :host([orientation="vertical"]) .divider { width: 100%; border-bottom: var(--m3e-timepicker-input-period-toggle-outline-thickness, 1px) solid var(--m3e-timepicker-input-period-toggle-outline-color, ${DesignToken.color.outline}); } :host([orientation="horizontal"]) .divider { height: 100%; border-inline-end: var(--m3e-timepicker-input-period-toggle-outline-thickness, 1px) solid var(--m3e-timepicker-input-period-toggle-outline-color, ${DesignToken.color.outline}); } :host([orientation="vertical"]) .period-button:last-child { border-end-start-radius: inherit; border-end-end-radius: inherit; } :host([orientation="horizontal"]) .period-button:last-child { border-start-end-radius: inherit; border-end-end-radius: inherit; } .period-button[aria-checked="true"] { background-color: var( --m3e-timepicker-input-period-toggle-selected-container-color, ${DesignToken.color.tertiaryContainer} ); color: var(--m3e-timepicker-input-period-toggle-selected-label-color, ${DesignToken.color.onTertiaryContainer}); --m3e-state-layer-hover-color: var( --m3e-timepicker-input-period-toggle-selected-hover-state-layer-color, ${DesignToken.color.onTertiaryContainer} ); --m3e-state-layer-focus-color: var( --m3e-timepicker-input-period-toggle-selected-focus-state-layer-color, ${DesignToken.color.onTertiaryContainer} ); --m3e-ripple-color: var( --m3e-timepicker-input-period-toggle-selected-pressed-state-layer-color, ${DesignToken.color.onTertiaryContainer} ); } .period-button[aria-checked="false"] { color: var(--m3e-timepicker-input-period-toggle-unselected-label-color, ${DesignToken.color.onSurfaceVariant}); --m3e-state-layer-hover-color: var( --m3e-timepicker-input-period-toggle-unselected-hover-state-layer-color, ${DesignToken.color.onSurfaceVariant} ); --m3e-state-layer-focus-color: var( --m3e-timepicker-input-period-toggle-unselected-focus-state-layer-color, ${DesignToken.color.onSurfaceVariant} ); --m3e-ripple-color: var( --m3e-timepicker-input-period-toggle-unselected-pressed-state-layer-color, ${DesignToken.color.onSurfaceVariant} ); }`;
|
|
503
|
+
__decorate([property()], M3eTimepickerInputPeriodToggleElement.prototype, "period", void 0);
|
|
504
|
+
__decorate([property({
|
|
505
|
+
reflect: true
|
|
506
|
+
})], M3eTimepickerInputPeriodToggleElement.prototype, "orientation", void 0);
|
|
507
|
+
M3eTimepickerInputPeriodToggleElement = __decorate([customElement("m3e-timepicker-input-period-toggle")], M3eTimepickerInputPeriodToggleElement);
|
|
508
|
+
|
|
509
|
+
var _M3eTimepickerInputElement_instances, _M3eTimepickerInputElement_clockChangeHandler, _M3eTimepickerInputElement_clockViewChangeHandler, _M3eTimepickerInputElement_syncControl, _M3eTimepickerInputElement_renderField, _M3eTimepickerInputElement_handleFieldFocus, _M3eTimepickerInputElement_handleFieldKeyDown, _M3eTimepickerInputElement_handleFieldInput, _M3eTimepickerInputElement_increment, _M3eTimepickerInputElement_handlePeriodChange, _M3eTimepickerInputElement_handleClockChange, _M3eTimepickerInputElement_handleClockViewChange, _M3eTimepickerInputElement_isDisabled;
|
|
510
|
+
/**
|
|
511
|
+
* A keyboard‑based time surface for choosing hours and minutes.
|
|
512
|
+
* @description
|
|
513
|
+
* The `m3e-timepicker-input` component provides a keyboard-focused time
|
|
514
|
+
* entry surface, allowing users to type or navigate hour and minute fields,
|
|
515
|
+
* toggle AM/PM, and receive accessible validation feedback.
|
|
516
|
+
*
|
|
517
|
+
* @tag m3e-timepicker-input
|
|
518
|
+
*
|
|
519
|
+
* @attr format - Whether to use a 12‑hour or 24‑hour clock.
|
|
520
|
+
* @attr hide-labels - Whether to hide field labels.
|
|
521
|
+
* @attr hour - The hour, in 24-hour time, from 0..23.
|
|
522
|
+
* @attr max-time - The maximum time that can be selected.
|
|
523
|
+
* @attr min-time - The minimum time that can be selected.
|
|
524
|
+
* @attr minute - The minute, from 0..59.
|
|
525
|
+
* @attr orientation - The orientation of the input.
|
|
526
|
+
* @attr period - The 12-hour time period.
|
|
527
|
+
* @attr view - The view used to input time.
|
|
528
|
+
* @attr hour-label - The label for the hour field.
|
|
529
|
+
* @attr minute-label - The label for the minute field.
|
|
530
|
+
* @attr period-toggle-label - The accessible label given to the period toggle.
|
|
531
|
+
*
|
|
532
|
+
* @fires change - Dispatched when the selected time changes.
|
|
533
|
+
* @fires view-change - Dispatched when the view changes.
|
|
534
|
+
*
|
|
535
|
+
* @cssprop --m3e-timepicker-input-field-container-width - Width of the input field container.
|
|
536
|
+
* @cssprop --m3e-timepicker-input-field-height - Height of the input fields.
|
|
537
|
+
* @cssprop --m3e-timepicker-input-field-container-shape - Corner radius of the input field container.
|
|
538
|
+
* @cssprop --m3e-timepicker-input-field-font-size - Font size of the input field text.
|
|
539
|
+
* @cssprop --m3e-timepicker-input-field-font-weight - Font weight of the input field text.
|
|
540
|
+
* @cssprop --m3e-timepicker-input-field-line-height - Line height of the input field text.
|
|
541
|
+
* @cssprop --m3e-timepicker-input-field-tracking - Letter spacing of the input field text.
|
|
542
|
+
* @cssprop --m3e-timepicker-input-field-label-unselected-color - Text color of unselected input field labels.
|
|
543
|
+
* @cssprop --m3e-timepicker-input-field-unselected-container-color - Background color of unselected input fields.
|
|
544
|
+
* @cssprop --m3e-timepicker-input-field-label-selected-color - Text color of selected input field labels.
|
|
545
|
+
* @cssprop --m3e-timepicker-input-field-selected-container-color - Background color of selected input fields.
|
|
546
|
+
* @cssprop --m3e-timepicker-input-field-label-invalid-color - Text color of invalid input field labels.
|
|
547
|
+
* @cssprop --m3e-timepicker-input-field-invalid-container-color - Background color of invalid input fields.
|
|
548
|
+
* @cssprop --m3e-timepicker-input-field-supporting-text-color - Text color of supporting labels.
|
|
549
|
+
* @cssprop --m3e-timepicker-input-field-supporting-text-font-size - Font size of supporting labels.
|
|
550
|
+
* @cssprop --m3e-timepicker-input-field-supporting-text-font-weight - Font weight of supporting labels.
|
|
551
|
+
* @cssprop --m3e-timepicker-input-field-supporting-text-line-height - Line height of supporting labels.
|
|
552
|
+
* @cssprop --m3e-timepicker-input-field-supporting-text-tracking - Letter spacing of supporting labels.
|
|
553
|
+
* @cssprop --m3e-timepicker-input-field-separator-width - Width of the field separator.
|
|
554
|
+
* @cssprop --m3e-timepicker-input-field-separator-color - Color of the field separator.
|
|
555
|
+
* @cssprop --m3e-timepicker-input-field-separator-font-size - Font size of the field separator.
|
|
556
|
+
* @cssprop --m3e-timepicker-input-field-separator-font-weight - Font weight of the field separator.
|
|
557
|
+
* @cssprop --m3e-timepicker-input-field-separator-tracking - Letter spacing of the field separator.
|
|
558
|
+
* @cssprop --m3e-timepicker-input-horizontal-period-toggle-space - Space between the fields and period toggle in horizontal orientation.
|
|
559
|
+
* @cssprop --m3e-timepicker-input-vertical-period-toggle-space - Space between the fields and period toggle in vertical orientation.
|
|
560
|
+
*/
|
|
561
|
+
let M3eTimepickerInputElement = class M3eTimepickerInputElement extends HtmlFor(TimepickerInputElementBase) {
|
|
562
|
+
constructor() {
|
|
563
|
+
super(...arguments);
|
|
564
|
+
_M3eTimepickerInputElement_instances.add(this);
|
|
565
|
+
/** @private */
|
|
566
|
+
_M3eTimepickerInputElement_clockChangeHandler.set(this, () => __classPrivateFieldGet(this, _M3eTimepickerInputElement_instances, "m", _M3eTimepickerInputElement_handleClockChange).call(this));
|
|
567
|
+
/** @private */
|
|
568
|
+
_M3eTimepickerInputElement_clockViewChangeHandler.set(this, () => __classPrivateFieldGet(this, _M3eTimepickerInputElement_instances, "m", _M3eTimepickerInputElement_handleClockViewChange).call(this));
|
|
569
|
+
/**
|
|
570
|
+
* The orientation of the input.
|
|
571
|
+
* @default "horizontal"
|
|
572
|
+
*/
|
|
573
|
+
this.orientation = "horizontal";
|
|
574
|
+
/**
|
|
575
|
+
* Whether to hide field labels.
|
|
576
|
+
* @default false
|
|
577
|
+
*/
|
|
578
|
+
this.hideLabels = false;
|
|
579
|
+
/**
|
|
580
|
+
* The label for the hour field.
|
|
581
|
+
* @default "Hour"
|
|
582
|
+
*/
|
|
583
|
+
this.hourLabel = "Hour";
|
|
584
|
+
/**
|
|
585
|
+
* The label for the minute field.
|
|
586
|
+
* @default "Minute"
|
|
587
|
+
*/
|
|
588
|
+
this.minuteLabel = "Minute";
|
|
589
|
+
/**
|
|
590
|
+
* The accessible label given to the period toggle.
|
|
591
|
+
* @default "AM or PM"
|
|
592
|
+
*/
|
|
593
|
+
this.periodToggleLabel = "AM or PM";
|
|
594
|
+
}
|
|
595
|
+
/** @inheritdoc */
|
|
596
|
+
attach(control) {
|
|
597
|
+
super.attach(control);
|
|
598
|
+
if (this.control instanceof M3eTimepickerDialElement) {
|
|
599
|
+
__classPrivateFieldGet(this, _M3eTimepickerInputElement_instances, "m", _M3eTimepickerInputElement_syncControl).call(this);
|
|
600
|
+
this.control.addEventListener("change", __classPrivateFieldGet(this, _M3eTimepickerInputElement_clockChangeHandler, "f"));
|
|
601
|
+
this.control.addEventListener("view-change", __classPrivateFieldGet(this, _M3eTimepickerInputElement_clockViewChangeHandler, "f"));
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
/** @inheritdoc */
|
|
605
|
+
detach() {
|
|
606
|
+
if (this.control instanceof M3eTimepickerDialElement) {
|
|
607
|
+
this.control.removeEventListener("change", __classPrivateFieldGet(this, _M3eTimepickerInputElement_clockChangeHandler, "f"));
|
|
608
|
+
this.control.removeEventListener("view-change", __classPrivateFieldGet(this, _M3eTimepickerInputElement_clockViewChangeHandler, "f"));
|
|
609
|
+
}
|
|
610
|
+
super.detach();
|
|
611
|
+
}
|
|
612
|
+
/** @inheritdoc */
|
|
613
|
+
willUpdate(_changedProperties) {
|
|
614
|
+
super.willUpdate(_changedProperties);
|
|
615
|
+
if (_changedProperties.has("hour") || _changedProperties.has("minute") || _changedProperties.has("view") || _changedProperties.has("period") || _changedProperties.has("format") || _changedProperties.has("minTime") || _changedProperties.has("maxTime") || _changedProperties.has("blackoutTimes")) {
|
|
616
|
+
__classPrivateFieldGet(this, _M3eTimepickerInputElement_instances, "m", _M3eTimepickerInputElement_syncControl).call(this);
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
/** @inheritdoc */
|
|
620
|
+
render() {
|
|
621
|
+
return html`<div class="base">${__classPrivateFieldGet(this, _M3eTimepickerInputElement_instances, "m", _M3eTimepickerInputElement_renderField).call(this, "hour")}<div class="field-separator">:</div>${__classPrivateFieldGet(this, _M3eTimepickerInputElement_instances, "m", _M3eTimepickerInputElement_renderField).call(this, "minute")} ${this.currentFormat === "12" && this.orientation === "horizontal" ? html`<m3e-timepicker-input-period-toggle class="period-toggle" period="${this.period}" orientation="vertical" aria-label="${this.periodToggleLabel}" @change="${__classPrivateFieldGet(this, _M3eTimepickerInputElement_instances, "m", _M3eTimepickerInputElement_handlePeriodChange)}"></m3e-timepicker-input-period-toggle>` : nothing}</div>${this.currentFormat === "12" && this.orientation === "vertical" ? html`<m3e-timepicker-input-period-toggle class="period-toggle" period="${this.period}" orientation="horizontal" @change="${__classPrivateFieldGet(this, _M3eTimepickerInputElement_instances, "m", _M3eTimepickerInputElement_handlePeriodChange)}"></m3e-timepicker-input-period-toggle>` : nothing}`;
|
|
622
|
+
}
|
|
623
|
+
};
|
|
624
|
+
_M3eTimepickerInputElement_clockChangeHandler = new WeakMap();
|
|
625
|
+
_M3eTimepickerInputElement_clockViewChangeHandler = new WeakMap();
|
|
626
|
+
_M3eTimepickerInputElement_instances = new WeakSet();
|
|
627
|
+
_M3eTimepickerInputElement_syncControl = function _M3eTimepickerInputElement_syncControl() {
|
|
628
|
+
if (this.control instanceof M3eTimepickerDialElement) {
|
|
629
|
+
this.control.view = this.view;
|
|
630
|
+
this.control.format = this.currentFormat;
|
|
631
|
+
this.control.hour = this.hour;
|
|
632
|
+
this.control.minute = this.minute;
|
|
633
|
+
this.control.minTime = this.minTime;
|
|
634
|
+
this.control.maxTime = this.maxTime;
|
|
635
|
+
this.control.blackoutTimes = this.blackoutTimes;
|
|
636
|
+
this.control.period = this.period;
|
|
637
|
+
}
|
|
638
|
+
};
|
|
639
|
+
_M3eTimepickerInputElement_renderField = function _M3eTimepickerInputElement_renderField(view) {
|
|
640
|
+
const pad = n => n === null ? "" : n < 10 ? "0" + n : String(n);
|
|
641
|
+
const label = view === "hour" ? this.hourLabel : this.minuteLabel;
|
|
642
|
+
const invalid = __classPrivateFieldGet(this, _M3eTimepickerInputElement_instances, "m", _M3eTimepickerInputElement_isDisabled).call(this, this[view], view);
|
|
643
|
+
let valueText;
|
|
644
|
+
if (this[view] !== null) {
|
|
645
|
+
const date = new Date();
|
|
646
|
+
date.setHours(this.hour ?? 0, this.minute ?? 0, 0, 0);
|
|
647
|
+
valueText = new Intl.DateTimeFormat(navigator.language, view === "hour" ? {
|
|
648
|
+
hour: "numeric",
|
|
649
|
+
hour12: this.currentFormat === "12"
|
|
650
|
+
} : {
|
|
651
|
+
minute: "2-digit"
|
|
652
|
+
}).format(date);
|
|
653
|
+
}
|
|
654
|
+
return html`<div class="field-wrapper"><input id="${view}" class="${classMap({
|
|
655
|
+
field: true,
|
|
656
|
+
selected: this.view === view,
|
|
657
|
+
invalid
|
|
658
|
+
})}" role="spinbutton" placeholder="––" inputmode="numeric" autocomplete="off" aria-label="${label}" aria-valuemin="0" aria-valuemax="${view === "hour" ? 23 : 59}" aria-valuenow="${ifDefined(valueText ? pad(this[view]) : undefined)}" aria-valuetext="${ifDefined(valueText)}" @focus="${__classPrivateFieldGet(this, _M3eTimepickerInputElement_instances, "m", _M3eTimepickerInputElement_handleFieldFocus)}" @keydown="${__classPrivateFieldGet(this, _M3eTimepickerInputElement_instances, "m", _M3eTimepickerInputElement_handleFieldKeyDown)}" @input="${__classPrivateFieldGet(this, _M3eTimepickerInputElement_instances, "m", _M3eTimepickerInputElement_handleFieldInput)}" .value="${pad(view === "hour" ? this.currentFormat === "12" ? this.hourOfPeriod : this.hour : this.minute)}"><m3e-collapsible aria-hidden="true" ?open="${!this.hideLabels}"><span class="label">${label}</span></m3e-collapsible><m3e-focus-ring class="focus-ring" for="${view}"></m3e-focus-ring></div>`;
|
|
659
|
+
};
|
|
660
|
+
_M3eTimepickerInputElement_handleFieldFocus = function _M3eTimepickerInputElement_handleFieldFocus(e) {
|
|
661
|
+
const input = e.target;
|
|
662
|
+
const view = input.id;
|
|
663
|
+
if (this.view !== view) {
|
|
664
|
+
this.view = view;
|
|
665
|
+
this.dispatchEvent(new CustomEvent("view-change"));
|
|
666
|
+
}
|
|
667
|
+
};
|
|
668
|
+
_M3eTimepickerInputElement_handleFieldKeyDown = function _M3eTimepickerInputElement_handleFieldKeyDown(e) {
|
|
669
|
+
const input = e.target;
|
|
670
|
+
const view = input.id;
|
|
671
|
+
switch (e.key) {
|
|
672
|
+
case "Up":
|
|
673
|
+
case "ArrowUp":
|
|
674
|
+
e.preventDefault();
|
|
675
|
+
__classPrivateFieldGet(this, _M3eTimepickerInputElement_instances, "m", _M3eTimepickerInputElement_increment).call(this, view, 1, true);
|
|
676
|
+
this.dispatchEvent(new Event("change", {
|
|
677
|
+
bubbles: true
|
|
678
|
+
}));
|
|
679
|
+
return;
|
|
680
|
+
case "PageUp":
|
|
681
|
+
e.preventDefault();
|
|
682
|
+
__classPrivateFieldGet(this, _M3eTimepickerInputElement_instances, "m", _M3eTimepickerInputElement_increment).call(this, view, view === "hour" ? 1 : 5);
|
|
683
|
+
this.dispatchEvent(new Event("change", {
|
|
684
|
+
bubbles: true
|
|
685
|
+
}));
|
|
686
|
+
return;
|
|
687
|
+
case "Down":
|
|
688
|
+
case "ArrowDown":
|
|
689
|
+
e.preventDefault();
|
|
690
|
+
__classPrivateFieldGet(this, _M3eTimepickerInputElement_instances, "m", _M3eTimepickerInputElement_increment).call(this, view, -1, true);
|
|
691
|
+
this.dispatchEvent(new Event("change", {
|
|
692
|
+
bubbles: true
|
|
693
|
+
}));
|
|
694
|
+
return;
|
|
695
|
+
case "PageDown":
|
|
696
|
+
e.preventDefault();
|
|
697
|
+
__classPrivateFieldGet(this, _M3eTimepickerInputElement_instances, "m", _M3eTimepickerInputElement_increment).call(this, view, view === "hour" ? -1 : -5);
|
|
698
|
+
this.dispatchEvent(new Event("change", {
|
|
699
|
+
bubbles: true
|
|
700
|
+
}));
|
|
701
|
+
return;
|
|
702
|
+
case "Backspace":
|
|
703
|
+
case "Delete":
|
|
704
|
+
e.preventDefault();
|
|
705
|
+
this[view] = null;
|
|
706
|
+
input.value = "";
|
|
707
|
+
this.dispatchEvent(new Event("change", {
|
|
708
|
+
bubbles: true
|
|
709
|
+
}));
|
|
710
|
+
break;
|
|
711
|
+
case "Tab":
|
|
712
|
+
case "ArrowLeft":
|
|
713
|
+
case "Left":
|
|
714
|
+
case "ArrowRight":
|
|
715
|
+
case "Right":
|
|
716
|
+
return;
|
|
717
|
+
}
|
|
718
|
+
if (e.ctrlKey || e.metaKey) {
|
|
719
|
+
return;
|
|
720
|
+
}
|
|
721
|
+
if (!/^\d$/.test(e.key)) {
|
|
722
|
+
e.preventDefault();
|
|
723
|
+
}
|
|
724
|
+
};
|
|
725
|
+
_M3eTimepickerInputElement_handleFieldInput = function _M3eTimepickerInputElement_handleFieldInput(e) {
|
|
726
|
+
if (e.isComposing) return;
|
|
727
|
+
const input = e.target;
|
|
728
|
+
const view = input.id;
|
|
729
|
+
const raw = input.value.replace(/\D/g, "");
|
|
730
|
+
if (raw.length === 0) {
|
|
731
|
+
this[view] = null;
|
|
732
|
+
input.value = "";
|
|
733
|
+
this.requestUpdate();
|
|
734
|
+
this.dispatchEvent(new Event("change", {
|
|
735
|
+
bubbles: true
|
|
736
|
+
}));
|
|
737
|
+
return;
|
|
738
|
+
}
|
|
739
|
+
const isValid = v => view === "hour" ? this.currentFormat === "12" ? v >= 1 && v <= 12 : v >= 0 && v <= 23 : v >= 0 && v <= 59;
|
|
740
|
+
const cursor = input.selectionStart ?? input.value.length;
|
|
741
|
+
const atEnd = cursor === input.value.length;
|
|
742
|
+
// Typed digit (only valid for insertText)
|
|
743
|
+
const typedDigit = typeof e.data === "string" && /^\d$/.test(e.data) ? Number(e.data) : null;
|
|
744
|
+
let value;
|
|
745
|
+
if (typedDigit !== null && !atEnd) {
|
|
746
|
+
// Cursor not at end, always treat as fresh single-digit overwrite
|
|
747
|
+
value = typedDigit;
|
|
748
|
+
} else if (raw.length >= 2 && atEnd && raw.startsWith("0")) {
|
|
749
|
+
// Natural 2-digit typing or paste
|
|
750
|
+
const candidate = parseInt(raw.slice(-2));
|
|
751
|
+
value = isValid(candidate) ? candidate : Number(raw.slice(-1));
|
|
752
|
+
} else {
|
|
753
|
+
// Single-digit typing or fallback
|
|
754
|
+
value = typedDigit !== null ? typedDigit : Number(raw.slice(-1));
|
|
755
|
+
}
|
|
756
|
+
// 12-hour correction
|
|
757
|
+
if (view === "hour" && this.currentFormat === "12" && value === 0) {
|
|
758
|
+
value = 12;
|
|
759
|
+
}
|
|
760
|
+
input.value = value < 10 ? `0${value}` : String(value);
|
|
761
|
+
try {
|
|
762
|
+
input.setSelectionRange(input.value.length, input.value.length);
|
|
763
|
+
} catch {
|
|
764
|
+
// ignore
|
|
765
|
+
}
|
|
766
|
+
if (view === "hour" && this.currentFormat === "12") {
|
|
767
|
+
this.hourOfPeriod = value;
|
|
768
|
+
} else {
|
|
769
|
+
this[view] = value;
|
|
770
|
+
}
|
|
771
|
+
this.requestUpdate();
|
|
772
|
+
this.dispatchEvent(new Event("change", {
|
|
773
|
+
bubbles: true
|
|
774
|
+
}));
|
|
775
|
+
};
|
|
776
|
+
_M3eTimepickerInputElement_increment = function _M3eTimepickerInputElement_increment(view, by, wrap = false) {
|
|
777
|
+
const max = view === "hour" ? 24 : 60;
|
|
778
|
+
const step = Math.sign(by);
|
|
779
|
+
let candidate = this[view] ?? 0;
|
|
780
|
+
let remaining = Math.abs(by);
|
|
781
|
+
while (remaining > 0) {
|
|
782
|
+
candidate += step;
|
|
783
|
+
if (!wrap) {
|
|
784
|
+
if (candidate < 0) {
|
|
785
|
+
candidate = 0;
|
|
786
|
+
break;
|
|
787
|
+
}
|
|
788
|
+
if (candidate >= max) {
|
|
789
|
+
candidate = max - 1;
|
|
790
|
+
break;
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
candidate = (candidate % max + max) % max;
|
|
794
|
+
remaining--;
|
|
795
|
+
}
|
|
796
|
+
let skipStep = step;
|
|
797
|
+
if (!wrap) {
|
|
798
|
+
if (candidate === 0) skipStep = 1;else if (candidate === max - 1) skipStep = -1;
|
|
799
|
+
}
|
|
800
|
+
if (__classPrivateFieldGet(this, _M3eTimepickerInputElement_instances, "m", _M3eTimepickerInputElement_isDisabled).call(this, candidate, view)) {
|
|
801
|
+
let attempts = 0;
|
|
802
|
+
while (__classPrivateFieldGet(this, _M3eTimepickerInputElement_instances, "m", _M3eTimepickerInputElement_isDisabled).call(this, candidate, view)) {
|
|
803
|
+
candidate += skipStep;
|
|
804
|
+
if (!wrap) {
|
|
805
|
+
if (candidate < 0 || candidate >= max) return;
|
|
806
|
+
}
|
|
807
|
+
candidate = (candidate % max + max) % max;
|
|
808
|
+
if (++attempts > max) return;
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
this[view] = candidate;
|
|
812
|
+
};
|
|
813
|
+
_M3eTimepickerInputElement_handlePeriodChange = function _M3eTimepickerInputElement_handlePeriodChange(e) {
|
|
814
|
+
e.stopPropagation();
|
|
815
|
+
this.period = e.currentTarget.period;
|
|
816
|
+
if (this.hour !== null) {
|
|
817
|
+
const h = this.hour % 12 || 12;
|
|
818
|
+
this.hour = this.period === "am" ? h === 12 ? 0 : h : h === 12 ? 12 : h + 12;
|
|
819
|
+
this.dispatchEvent(new Event("change", {
|
|
820
|
+
bubbles: true
|
|
821
|
+
}));
|
|
822
|
+
}
|
|
823
|
+
};
|
|
824
|
+
_M3eTimepickerInputElement_handleClockChange = function _M3eTimepickerInputElement_handleClockChange() {
|
|
825
|
+
if (!this.control) return;
|
|
826
|
+
this.hour = this.control.hour;
|
|
827
|
+
this.minute = this.control.minute;
|
|
828
|
+
this.dispatchEvent(new Event("change", {
|
|
829
|
+
bubbles: true
|
|
830
|
+
}));
|
|
831
|
+
};
|
|
832
|
+
_M3eTimepickerInputElement_handleClockViewChange = function _M3eTimepickerInputElement_handleClockViewChange() {
|
|
833
|
+
if (!this.control) return;
|
|
834
|
+
this.view = this.control.view;
|
|
835
|
+
this.dispatchEvent(new CustomEvent("view-change"));
|
|
836
|
+
};
|
|
837
|
+
_M3eTimepickerInputElement_isDisabled = function _M3eTimepickerInputElement_isDisabled(value, view) {
|
|
838
|
+
if (value === null) return false;
|
|
839
|
+
switch (view) {
|
|
840
|
+
case "hour":
|
|
841
|
+
return this.isHourDisabled(value);
|
|
842
|
+
case "minute":
|
|
843
|
+
return this.hour != null && this.isMinuteDisabled(this.hour, value);
|
|
844
|
+
}
|
|
845
|
+
};
|
|
846
|
+
/** The styles of the element. */
|
|
847
|
+
M3eTimepickerInputElement.styles = css`:host { display: block; } .base { display: flex; align-items: flex-start; height: 100%; } .field-wrapper { display: flex; flex-direction: column; justify-content: stretch; position: relative; } .field, .focus-ring { width: var(--m3e-timepicker-input-field-container-width, 6rem); height: var(--m3e-timepicker-input-field-height, 5rem); border-radius: var(--m3e-timepicker-input-field-container-shape, ${DesignToken.shape.corner.small}); } .field { display: block; text-align: center; cursor: text; outline: none; border: unset; box-shadow: none; padding: unset; font-size: var(--m3e-timepicker-input-field-font-size, ${DesignToken.typescale.standard.display.medium.fontSize}); font-weight: var( --m3e-timepicker-input-field-font-weight, ${DesignToken.typescale.standard.display.medium.fontWeight} ); line-height: var( --m3e-timepicker-input-field-line-height, ${DesignToken.typescale.standard.display.medium.lineHeight} ); letter-spacing: var( --m3e-timepicker-input-field-tracking, ${DesignToken.typescale.standard.display.medium.tracking} ); } .field:not(.selected):not(.invalid) { color: var(--m3e-timepicker-input-field-label-unselected-color, ${DesignToken.color.onSurface}); background-color: var( --m3e-timepicker-input-field-unselected-container-color, ${DesignToken.color.surfaceContainerHighest} ); } .field.selected:not(.invalid) { color: var(--m3e-timepicker-input-field-label-selected-color, ${DesignToken.color.onPrimaryContainer}); background-color: var( --m3e-timepicker-input-field-selected-container-color, ${DesignToken.color.primaryContainer} ); } .field.invalid { color: var(--m3e-timepicker-input-field-label-invalid-color, ${DesignToken.color.onErrorContainer}); background-color: var(--m3e-timepicker-input-field-invalid-container-color, ${DesignToken.color.errorContainer}); } .field::placeholder { user-select: none; color: currentColor; transition: opacity ${DesignToken.motion.duration.short4}; } .field:focus::placeholder { opacity: 0; } .label { user-select: none; margin-top: 0.25rem; color: var(--m3e-timepicker-input-field-supporting-text-color, ${DesignToken.color.onSurfaceVariant}); font-size: var( --m3e-timepicker-input-field-supporting-text-font-size, ${DesignToken.typescale.standard.body.small.fontSize} ); font-weight: var( --m3e-timepicker-input-field-supporting-text-font-weight, ${DesignToken.typescale.standard.body.small.fontWeight} ); line-height: var( --m3e-timepicker-input-field-supporting-text-line-height, ${DesignToken.typescale.standard.body.small.lineHeight} ); letter-spacing: var( --m3e-timepicker-input-field-supporting-text-tracking, ${DesignToken.typescale.standard.body.small.tracking} ); } .field-separator { user-select: none; display: flex; align-items: center; justify-content: center; width: var(--m3e-timepicker-input-field-separator-width, 1.5rem); height: var(--m3e-timepicker-input-field-height, 5rem); color: var(--m3e-timepicker-input-field-separator-color, ${DesignToken.color.onSurface}); font-size: var( --m3e-timepicker-input-field-separator-font-size, ${DesignToken.typescale.standard.display.large.fontSize} ); font-weight: var( --m3e-timepicker-input-field-separator-font-weight, ${DesignToken.typescale.standard.display.large.fontWeight} ); letter-spacing: var( --m3e-timepicker-input-field-separator-tracking, ${DesignToken.typescale.standard.display.large.tracking} ); } :host([orientation="horizontal"]) .period-toggle { margin-inline-start: var(--m3e-timepicker-input-horizontal-period-toggle-space, 0.75rem); } :host([orientation="vertical"]) .period-toggle { margin-block-start: var(--m3e-timepicker-input-vertical-period-toggle-space, 1rem); }`;
|
|
848
|
+
__decorate([property({
|
|
849
|
+
reflect: true
|
|
850
|
+
})], M3eTimepickerInputElement.prototype, "orientation", void 0);
|
|
851
|
+
__decorate([property({
|
|
852
|
+
attribute: "hide-labels",
|
|
853
|
+
type: Boolean
|
|
854
|
+
})], M3eTimepickerInputElement.prototype, "hideLabels", void 0);
|
|
855
|
+
__decorate([property({
|
|
856
|
+
attribute: "hour-label"
|
|
857
|
+
})], M3eTimepickerInputElement.prototype, "hourLabel", void 0);
|
|
858
|
+
__decorate([property({
|
|
859
|
+
attribute: "minute-label"
|
|
860
|
+
})], M3eTimepickerInputElement.prototype, "minuteLabel", void 0);
|
|
861
|
+
__decorate([property({
|
|
862
|
+
attribute: "period-toggle-label"
|
|
863
|
+
})], M3eTimepickerInputElement.prototype, "periodToggleLabel", void 0);
|
|
864
|
+
M3eTimepickerInputElement = __decorate([customElement("m3e-timepicker-input")], M3eTimepickerInputElement);
|
|
865
|
+
|
|
866
|
+
var _M3eTimepickerElement_instances, _M3eTimepickerElement_closeTimeout, _M3eTimepickerElement_date, _M3eTimepickerElement_breakpointUnobserve, _M3eTimepickerElement_trigger, _M3eTimepickerElement_anchor, _M3eTimepickerElement_anchorCleanup, _M3eTimepickerElement_anchorLastPosition, _M3eTimepickerElement_scrollLockController, _M3eTimepickerElement_inertController, _M3eTimepickerElement_documentClickHandler, _M3eTimepickerElement_documentKeyDownHandler, _M3eTimepickerElement_toggleHandler, _M3eTimepickerElement_renderHeader, _M3eTimepickerElement_renderPicker, _M3eTimepickerElement_renderActions, _M3eTimepickerElement_renderModeToggleButton, _M3eTimepickerElement_handleModeClick, _M3eTimepickerElement_handleDocumentClick, _M3eTimepickerElement_handleInputChange, _M3eTimepickerElement_handleDismissClick, _M3eTimepickerElement_handleConfirmClick, _M3eTimepickerElement_handleDocumentKeyDown, _M3eTimepickerElement_handleToggle, _M3eTimepickerElement_initBreakpointMonitoring, _M3eTimepickerElement_updateVariant, _M3eTimepickerElement_updateOrientation, _M3eTimepickerElement_updatePosition, _M3eTimepickerElement_clearAnchoring, _M3eTimepickerElement_clearSelectionState, _M3eTimepickerElement_validate;
|
|
867
|
+
/**
|
|
868
|
+
* Presents a time picker on a temporary surface.
|
|
869
|
+
* @description
|
|
870
|
+
* The `m3e-timepicker` component provides a time-selection experience consistent
|
|
871
|
+
* with Material 3 guidance for layout, motion, and accessibility. It displays a
|
|
872
|
+
* temporary surface that allows users to choose a time using both keyboard-based
|
|
873
|
+
* input and clock-face dial controls.
|
|
874
|
+
*
|
|
875
|
+
* While open, the picker ensures users can review their selection and complete
|
|
876
|
+
* the interaction through confirm, dismiss, or toggle actions, making updates
|
|
877
|
+
* intentional and accessible.
|
|
878
|
+
*
|
|
879
|
+
* It accepts and emits plain `Date` values, allowing applications to apply their
|
|
880
|
+
* own formatting, parsing, and localization.
|
|
881
|
+
*
|
|
882
|
+
* @tag m3e-timepicker
|
|
883
|
+
*
|
|
884
|
+
* @attr variant - The appearance variant of the picker.
|
|
885
|
+
* @attr mode - The mode in which to select time.
|
|
886
|
+
* @attr orientation - The orientation of the picker.
|
|
887
|
+
* @attr date - The selected date.
|
|
888
|
+
* @attr format - Whether to use a 12‑hour or 24‑hour clock.
|
|
889
|
+
* @attr max-time - The maximum time that can be selected.
|
|
890
|
+
* @attr min-time - The minimum time that can be selected.
|
|
891
|
+
* @attr confirm-label - Label given to the button used apply the selected date and close the picker.
|
|
892
|
+
* @attr dismiss-label - Label given to the button used discard the selected date and close the picker.
|
|
893
|
+
* @attr dial-label - Label given to the the picker when in dial mode.
|
|
894
|
+
* @attr input-label - Label given to the the picker when in input mode.
|
|
895
|
+
* @attr hour-label - Label for the hour field.
|
|
896
|
+
* @attr minute-label - Label for the minute field.
|
|
897
|
+
* @attr mode-toggle-label - The accessible label given to the mode toggle button.
|
|
898
|
+
* @attr hide-mode-toggle - Whether to hide the mode toggle button.
|
|
899
|
+
* @attr period-toggle-label - The accessible label given to the period toggle.
|
|
900
|
+
*
|
|
901
|
+
* @fires change - Dispatched when the selected time is confirmed.
|
|
902
|
+
* @fires beforetoggle - Dispatched before the picker toggles.
|
|
903
|
+
* @fires toggle - Dispatched when the picker toggles.
|
|
904
|
+
*
|
|
905
|
+
* @cssprop --m3e-timepicker-container-padding-block - Block padding inside the picker container.
|
|
906
|
+
* @cssprop --m3e-timepicker-container-padding-inline - Inline padding inside the picker container.
|
|
907
|
+
* @cssprop --m3e-timepicker-container-color - Background color of the picker container.
|
|
908
|
+
* @cssprop --m3e-timepicker-container-elevation - Box shadow / elevation of the picker container.
|
|
909
|
+
* @cssprop --m3e-timepicker-docked-container-color - Background color of the docked picker container.
|
|
910
|
+
* @cssprop --m3e-timepicker-docked-container-shape - Border radius of the docked picker container.
|
|
911
|
+
* @cssprop --m3e-timepicker-modal-container-color - Background color of the modal picker container.
|
|
912
|
+
* @cssprop --m3e-timepicker-modal-container-shape - Border radius of the modal picker container.
|
|
913
|
+
* @cssprop --m3e-timepicker-headline-color - Color of the headline.
|
|
914
|
+
* @cssprop --m3e-timepicker-headline-font-size - Font size of the headline.
|
|
915
|
+
* @cssprop --m3e-timepicker-headline-font-weight - Font weight of the headline.
|
|
916
|
+
* @cssprop --m3e-timepicker-headline-line-height - Line height of the headline.
|
|
917
|
+
* @cssprop --m3e-timepicker-headline-tracking - Letter spacing of the headline.
|
|
918
|
+
* @cssprop --m3e-timepicker-headline-top-space - Top margin above the headline.
|
|
919
|
+
* @cssprop --m3e-timepicker-actions-space - Space above the action buttons.
|
|
920
|
+
* @cssprop --m3e-timepicker-label-input-space - Space between Label and the input.
|
|
921
|
+
* @cssprop --m3e-timepicker-vertical-input-dial-space - Space between the input and dial in vertical orientation.
|
|
922
|
+
* @cssprop --m3e-timepicker-horizontal-input-dial-space - Space between the input and dial in horizontal orientation.
|
|
923
|
+
* @cssprop --m3e-timepicker-input-field-container-width - Width of the input field container.
|
|
924
|
+
* @cssprop --m3e-timepicker-input-field-height - Height of the input fields.
|
|
925
|
+
* @cssprop --m3e-timepicker-input-field-container-shape - Corner radius of the input field container.
|
|
926
|
+
* @cssprop --m3e-timepicker-input-field-font-size - Font size of the input field text.
|
|
927
|
+
* @cssprop --m3e-timepicker-input-field-font-weight - Font weight of the input field text.
|
|
928
|
+
* @cssprop --m3e-timepicker-input-field-line-height - Line height of the input field text.
|
|
929
|
+
* @cssprop --m3e-timepicker-input-field-tracking - Letter spacing of the input field text.
|
|
930
|
+
* @cssprop --m3e-timepicker-input-field-label-unselected-color - Text color of unselected input field labels.
|
|
931
|
+
* @cssprop --m3e-timepicker-input-field-unselected-container-color - Background color of unselected input fields.
|
|
932
|
+
* @cssprop --m3e-timepicker-input-field-label-selected-color - Text color of selected input field labels.
|
|
933
|
+
* @cssprop --m3e-timepicker-input-field-selected-container-color - Background color of selected input fields.
|
|
934
|
+
* @cssprop --m3e-timepicker-input-field-label-invalid-color - Text color of invalid input field labels.
|
|
935
|
+
* @cssprop --m3e-timepicker-input-field-invalid-container-color - Background color of invalid input fields.
|
|
936
|
+
* @cssprop --m3e-timepicker-input-field-supporting-text-color - Text color of supporting labels.
|
|
937
|
+
* @cssprop --m3e-timepicker-input-field-supporting-text-font-size - Font size of supporting labels.
|
|
938
|
+
* @cssprop --m3e-timepicker-input-field-supporting-text-font-weight - Font weight of supporting labels.
|
|
939
|
+
* @cssprop --m3e-timepicker-input-field-supporting-text-line-height - Line height of supporting labels.
|
|
940
|
+
* @cssprop --m3e-timepicker-input-field-supporting-text-tracking - Letter spacing of supporting labels.
|
|
941
|
+
* @cssprop --m3e-timepicker-input-field-separator-width - Width of the field separator.
|
|
942
|
+
* @cssprop --m3e-timepicker-input-field-separator-color - Color of the field separator.
|
|
943
|
+
* @cssprop --m3e-timepicker-input-field-separator-font-size - Font size of the field separator.
|
|
944
|
+
* @cssprop --m3e-timepicker-input-field-separator-font-weight - Font weight of the field separator.
|
|
945
|
+
* @cssprop --m3e-timepicker-input-field-separator-tracking - Letter spacing of the field separator.
|
|
946
|
+
* @cssprop --m3e-timepicker-input-horizontal-period-toggle-space - Space between the fields and period toggle in horizontal orientation.
|
|
947
|
+
* @cssprop --m3e-timepicker-input-vertical-period-toggle-space - Space between the fields and period toggle in vertical orientation.
|
|
948
|
+
* @cssprop --m3e-timepicker-dial-container-size - Size of the dial container.
|
|
949
|
+
* @cssprop --m3e-timepicker-dial-container-shape - Corner radius of the dial container.
|
|
950
|
+
* @cssprop --m3e-timepicker-dial-container-color - Background color of the dial container.
|
|
951
|
+
* @cssprop --m3e-timepicker-dial-inset - Inset offset applied to the dial surface.
|
|
952
|
+
* @cssprop --m3e-timepicker-dial-center-size - Size of the dial center.
|
|
953
|
+
* @cssprop --m3e-timepicker-dial-handle-color - Color of the active handle.
|
|
954
|
+
* @cssprop --m3e-timepicker-dial-handle-size - Size of the handle.
|
|
955
|
+
* @cssprop --m3e-timepicker-dial-handle-disabled-color - Color of a disabled handle.
|
|
956
|
+
* @cssprop --m3e-timepicker-dial-handle-disabled-opacity - Opacity of a disabled handle.
|
|
957
|
+
* @cssprop --m3e-timepicker-dial-dial-inset - Inset applied to the handle area.
|
|
958
|
+
* @cssprop --m3e-timepicker-dial-numeral-size - Size of the dial numerals.
|
|
959
|
+
* @cssprop --m3e-timepicker-dial-numeral-color - Text color of inactive numerals.
|
|
960
|
+
* @cssprop --m3e-timepicker-dial-numeral-shape - Corner radius of the numerals.
|
|
961
|
+
* @cssprop --m3e-timepicker-dial-numeral-font-size - Font size of the outer numerals.
|
|
962
|
+
* @cssprop --m3e-timepicker-dial-numeral-font-weight - Font weight of the outer numerals.
|
|
963
|
+
* @cssprop --m3e-timepicker-dial-numeral-line-height - Line height of the outer numerals.
|
|
964
|
+
* @cssprop --m3e-timepicker-dial-numeral-tracking - Letter spacing of the outer numerals.
|
|
965
|
+
* @cssprop --m3e-timepicker-dial-inner-numeral-font-size - Font size of the inner numerals.
|
|
966
|
+
* @cssprop --m3e-timepicker-dial-inner-numeral-font-weight - Font weight of the inner numerals.
|
|
967
|
+
* @cssprop --m3e-timepicker-dial-inner-numeral-line-height - Line height of the inner numerals.
|
|
968
|
+
* @cssprop --m3e-timepicker-dial-inner-numeral-tracking - Letter spacing of the inner numerals.
|
|
969
|
+
* @cssprop --m3e-timepicker-dial-numeral-active-color - Color of active numerals.
|
|
970
|
+
* @cssprop --m3e-timepicker-dial-numeral-disabled-color - Color of disabled numerals.
|
|
971
|
+
* @cssprop --m3e-timepicker-dial-numeral-disabled-opacity - Opacity of disabled numerals.
|
|
972
|
+
* @cssprop --m3e-timepicker-dial-handle-center-size - Size of the handle center indicator.
|
|
973
|
+
*/
|
|
974
|
+
let M3eTimepickerElement = class M3eTimepickerElement extends SuppressInitialAnimation(ReconnectedCallback(AttachInternals(Role(LitElement, "dialog")))) {
|
|
975
|
+
constructor() {
|
|
976
|
+
super(...arguments);
|
|
977
|
+
_M3eTimepickerElement_instances.add(this);
|
|
978
|
+
/** @private */
|
|
979
|
+
_M3eTimepickerElement_closeTimeout.set(this, -1);
|
|
980
|
+
/** @private */
|
|
981
|
+
_M3eTimepickerElement_date.set(this, void 0);
|
|
982
|
+
/** @private */
|
|
983
|
+
this._open = false;
|
|
984
|
+
/** @private */
|
|
985
|
+
this._invalid = false;
|
|
986
|
+
/** @private */
|
|
987
|
+
_M3eTimepickerElement_breakpointUnobserve.set(this, void 0);
|
|
988
|
+
/** @private */
|
|
989
|
+
_M3eTimepickerElement_trigger.set(this, void 0);
|
|
990
|
+
/** @private */
|
|
991
|
+
_M3eTimepickerElement_anchor.set(this, void 0);
|
|
992
|
+
/** @private */
|
|
993
|
+
_M3eTimepickerElement_anchorCleanup.set(this, void 0);
|
|
994
|
+
/** @private */
|
|
995
|
+
_M3eTimepickerElement_anchorLastPosition.set(this, void 0);
|
|
996
|
+
/** @private */
|
|
997
|
+
_M3eTimepickerElement_scrollLockController.set(this, new ScrollLockController(this));
|
|
998
|
+
/** @private */
|
|
999
|
+
_M3eTimepickerElement_inertController.set(this, new InertController(this));
|
|
1000
|
+
/** @private */
|
|
1001
|
+
_M3eTimepickerElement_documentClickHandler.set(this, e => __classPrivateFieldGet(this, _M3eTimepickerElement_instances, "m", _M3eTimepickerElement_handleDocumentClick).call(this, e));
|
|
1002
|
+
/** @private */
|
|
1003
|
+
_M3eTimepickerElement_documentKeyDownHandler.set(this, e => __classPrivateFieldGet(this, _M3eTimepickerElement_instances, "m", _M3eTimepickerElement_handleDocumentKeyDown).call(this, e));
|
|
1004
|
+
/** @private */
|
|
1005
|
+
_M3eTimepickerElement_toggleHandler.set(this, e => __classPrivateFieldGet(this, _M3eTimepickerElement_instances, "m", _M3eTimepickerElement_handleToggle).call(this, e));
|
|
1006
|
+
/**
|
|
1007
|
+
* The appearance variant of the picker.
|
|
1008
|
+
* @default "docked"
|
|
1009
|
+
*/
|
|
1010
|
+
this.variant = "docked";
|
|
1011
|
+
/**
|
|
1012
|
+
* The mode in which to select time.
|
|
1013
|
+
* @default "dial"
|
|
1014
|
+
*/
|
|
1015
|
+
this.mode = "dial";
|
|
1016
|
+
/**
|
|
1017
|
+
* The orientation of the picker.
|
|
1018
|
+
* @default "vertical"
|
|
1019
|
+
*/
|
|
1020
|
+
this.orientation = "vertical";
|
|
1021
|
+
/**
|
|
1022
|
+
* The selected date.
|
|
1023
|
+
* @default null
|
|
1024
|
+
*/
|
|
1025
|
+
this.date = null;
|
|
1026
|
+
/**
|
|
1027
|
+
* Whether to use a 12‑hour or 24‑hour clock.
|
|
1028
|
+
* @default "12"
|
|
1029
|
+
*/
|
|
1030
|
+
this.format = "12";
|
|
1031
|
+
/**
|
|
1032
|
+
* The minimum time that can be selected.
|
|
1033
|
+
* @default null
|
|
1034
|
+
*/
|
|
1035
|
+
this.minTime = null;
|
|
1036
|
+
/**
|
|
1037
|
+
* The maximum time that can be selected.
|
|
1038
|
+
* @default null
|
|
1039
|
+
*/
|
|
1040
|
+
this.maxTime = null;
|
|
1041
|
+
/**
|
|
1042
|
+
* Whether to hide the mode toggle button.
|
|
1043
|
+
* @default false
|
|
1044
|
+
*/
|
|
1045
|
+
this.hideModeToggle = false;
|
|
1046
|
+
/**
|
|
1047
|
+
* Label given to the button used apply the selected date and close the picker.
|
|
1048
|
+
* @default "OK"
|
|
1049
|
+
*/
|
|
1050
|
+
this.confirmLabel = "OK";
|
|
1051
|
+
/**
|
|
1052
|
+
* Label given to the button used discard the selected date and close the picker.
|
|
1053
|
+
* @default "Cancel"
|
|
1054
|
+
*/
|
|
1055
|
+
this.dismissLabel = "Cancel";
|
|
1056
|
+
/**
|
|
1057
|
+
* Label given to the the picker when in dial mode.
|
|
1058
|
+
* @default "Select time"
|
|
1059
|
+
*/
|
|
1060
|
+
this.dialLabel = "Select time";
|
|
1061
|
+
/**
|
|
1062
|
+
* Label given to the the picker when in input mode.
|
|
1063
|
+
* @default "Edit time"
|
|
1064
|
+
*/
|
|
1065
|
+
this.inputLabel = "Edit time";
|
|
1066
|
+
/**
|
|
1067
|
+
* Label for the hour field.
|
|
1068
|
+
* @default "Hour"
|
|
1069
|
+
*/
|
|
1070
|
+
this.hourLabel = "Hour";
|
|
1071
|
+
/**
|
|
1072
|
+
* Label for the minute field.
|
|
1073
|
+
* @default "Minute"
|
|
1074
|
+
*/
|
|
1075
|
+
this.minuteLabel = "Minute";
|
|
1076
|
+
/**
|
|
1077
|
+
* The accessible label given to the mode toggle button.
|
|
1078
|
+
* @default "Toggle input picker"
|
|
1079
|
+
*/
|
|
1080
|
+
this.modeToggleLabel = "Toggle input picker";
|
|
1081
|
+
/**
|
|
1082
|
+
* The accessible label given to the period toggle.
|
|
1083
|
+
* @default "AM or PM"
|
|
1084
|
+
*/
|
|
1085
|
+
this.periodToggleLabel = "AM or PM";
|
|
1086
|
+
}
|
|
1087
|
+
/** Whether the picker is open. */
|
|
1088
|
+
get isOpen() {
|
|
1089
|
+
return __classPrivateFieldGet(this, _M3eTimepickerElement_trigger, "f") !== undefined;
|
|
1090
|
+
}
|
|
1091
|
+
/** The current variant applied to the picker. */
|
|
1092
|
+
get currentVariant() {
|
|
1093
|
+
return this._variant ?? (this.variant !== "modal" ? "docked" : "modal");
|
|
1094
|
+
}
|
|
1095
|
+
/** The current orientation applied to the picker. */
|
|
1096
|
+
get currentOrientation() {
|
|
1097
|
+
return this._orientation ?? (this.orientation !== "horizontal" ? "vertical" : "horizontal");
|
|
1098
|
+
}
|
|
1099
|
+
/** The current input mode applied to the picker. */
|
|
1100
|
+
get currentMode() {
|
|
1101
|
+
return this._mode ?? this.mode;
|
|
1102
|
+
}
|
|
1103
|
+
/** @inheritdoc */
|
|
1104
|
+
connectedCallback() {
|
|
1105
|
+
super.connectedCallback();
|
|
1106
|
+
this.setAttribute("popover", "manual");
|
|
1107
|
+
this.addEventListener("toggle", __classPrivateFieldGet(this, _M3eTimepickerElement_toggleHandler, "f"));
|
|
1108
|
+
}
|
|
1109
|
+
/** @inheritdoc */
|
|
1110
|
+
disconnectedCallback() {
|
|
1111
|
+
super.disconnectedCallback();
|
|
1112
|
+
this._variant = undefined;
|
|
1113
|
+
__classPrivateFieldGet(this, _M3eTimepickerElement_breakpointUnobserve, "f")?.call(this);
|
|
1114
|
+
__classPrivateFieldGet(this, _M3eTimepickerElement_instances, "m", _M3eTimepickerElement_clearAnchoring).call(this);
|
|
1115
|
+
deleteCustomState(this, "--docked");
|
|
1116
|
+
deleteCustomState(this, "--modal");
|
|
1117
|
+
this.removeEventListener("toggle", __classPrivateFieldGet(this, _M3eTimepickerElement_toggleHandler, "f"));
|
|
1118
|
+
document.removeEventListener("click", __classPrivateFieldGet(this, _M3eTimepickerElement_documentClickHandler, "f"));
|
|
1119
|
+
document.removeEventListener("keydown", __classPrivateFieldGet(this, _M3eTimepickerElement_documentKeyDownHandler, "f"));
|
|
1120
|
+
}
|
|
1121
|
+
/** @inheritdoc */
|
|
1122
|
+
reconnectedCallback() {
|
|
1123
|
+
super.reconnectedCallback();
|
|
1124
|
+
if (this.variant === "auto" || this.orientation === "auto") {
|
|
1125
|
+
__classPrivateFieldGet(this, _M3eTimepickerElement_instances, "m", _M3eTimepickerElement_initBreakpointMonitoring).call(this);
|
|
1126
|
+
}
|
|
1127
|
+
}
|
|
1128
|
+
/**
|
|
1129
|
+
* Opens the picker.
|
|
1130
|
+
* @param {HTMLElement} trigger The element that triggered the picker.
|
|
1131
|
+
* @param {HTMLElement | undefined} anchor The element used to position the picker.
|
|
1132
|
+
* @returns {Promise<void>} A `Promise` that resolves when the picker is opened.
|
|
1133
|
+
*/
|
|
1134
|
+
async show(trigger, anchor) {
|
|
1135
|
+
if (__classPrivateFieldGet(this, _M3eTimepickerElement_trigger, "f") && __classPrivateFieldGet(this, _M3eTimepickerElement_trigger, "f") !== trigger) {
|
|
1136
|
+
this.hide();
|
|
1137
|
+
}
|
|
1138
|
+
clearTimeout(__classPrivateFieldGet(this, _M3eTimepickerElement_closeTimeout, "f"));
|
|
1139
|
+
if (this.currentVariant === "modal") {
|
|
1140
|
+
__classPrivateFieldGet(this, _M3eTimepickerElement_scrollLockController, "f").lock();
|
|
1141
|
+
__classPrivateFieldGet(this, _M3eTimepickerElement_inertController, "f").lock();
|
|
1142
|
+
}
|
|
1143
|
+
// Validate the current value prior to opening
|
|
1144
|
+
__classPrivateFieldGet(this, _M3eTimepickerElement_instances, "m", _M3eTimepickerElement_validate).call(this);
|
|
1145
|
+
// The picker is rendered on demand
|
|
1146
|
+
this._open = true;
|
|
1147
|
+
// Wait for the picker to render
|
|
1148
|
+
if (this.isUpdatePending) {
|
|
1149
|
+
await this.updateComplete;
|
|
1150
|
+
}
|
|
1151
|
+
const input = this._input;
|
|
1152
|
+
input.hour = this.date?.getHours() ?? null;
|
|
1153
|
+
input.minute = this.date?.getMinutes() ?? null;
|
|
1154
|
+
input.minTime = this.minTime;
|
|
1155
|
+
input.maxTime = this.maxTime;
|
|
1156
|
+
input.blackoutTimes = this.blackoutTimes;
|
|
1157
|
+
if (input.isUpdatePending) {
|
|
1158
|
+
await input.updateComplete;
|
|
1159
|
+
}
|
|
1160
|
+
__classPrivateFieldSet(this, _M3eTimepickerElement_date, undefined, "f");
|
|
1161
|
+
__classPrivateFieldSet(this, _M3eTimepickerElement_trigger, trigger, "f");
|
|
1162
|
+
__classPrivateFieldGet(this, _M3eTimepickerElement_trigger, "f").ariaExpanded = "true";
|
|
1163
|
+
__classPrivateFieldSet(this, _M3eTimepickerElement_anchor, anchor, "f");
|
|
1164
|
+
await __classPrivateFieldGet(this, _M3eTimepickerElement_instances, "m", _M3eTimepickerElement_updatePosition).call(this);
|
|
1165
|
+
this.showPopover();
|
|
1166
|
+
document.addEventListener("click", __classPrivateFieldGet(this, _M3eTimepickerElement_documentClickHandler, "f"));
|
|
1167
|
+
document.addEventListener("keydown", __classPrivateFieldGet(this, _M3eTimepickerElement_documentKeyDownHandler, "f"));
|
|
1168
|
+
}
|
|
1169
|
+
/**
|
|
1170
|
+
* Hides the picker.
|
|
1171
|
+
* @param {boolean} [restoreFocus=false] Whether to restore focus to the picker's trigger.
|
|
1172
|
+
*/
|
|
1173
|
+
hide(restoreFocus = false) {
|
|
1174
|
+
if (!this.isOpen) return;
|
|
1175
|
+
document.removeEventListener("click", __classPrivateFieldGet(this, _M3eTimepickerElement_documentClickHandler, "f"));
|
|
1176
|
+
document.removeEventListener("keydown", __classPrivateFieldGet(this, _M3eTimepickerElement_documentKeyDownHandler, "f"));
|
|
1177
|
+
if (this.currentVariant === "modal") {
|
|
1178
|
+
__classPrivateFieldGet(this, _M3eTimepickerElement_scrollLockController, "f").unlock();
|
|
1179
|
+
__classPrivateFieldGet(this, _M3eTimepickerElement_inertController, "f").unlock();
|
|
1180
|
+
}
|
|
1181
|
+
this.hidePopover();
|
|
1182
|
+
if (__classPrivateFieldGet(this, _M3eTimepickerElement_trigger, "f")) {
|
|
1183
|
+
__classPrivateFieldGet(this, _M3eTimepickerElement_trigger, "f").ariaExpanded = "false";
|
|
1184
|
+
if (restoreFocus) {
|
|
1185
|
+
__classPrivateFieldGet(this, _M3eTimepickerElement_trigger, "f").focus();
|
|
1186
|
+
}
|
|
1187
|
+
__classPrivateFieldSet(this, _M3eTimepickerElement_trigger, undefined, "f");
|
|
1188
|
+
}
|
|
1189
|
+
}
|
|
1190
|
+
/**
|
|
1191
|
+
* Toggles the picker.
|
|
1192
|
+
* @param {HTMLElement} trigger The element that triggered the picker.
|
|
1193
|
+
* @param {HTMLElement | undefined} anchor The element used to position the picker.
|
|
1194
|
+
* @returns {Promise<void>} A `Promise` that resolves when the picker is opened or closed.
|
|
1195
|
+
*/
|
|
1196
|
+
async toggle(trigger, anchor) {
|
|
1197
|
+
if (__classPrivateFieldGet(this, _M3eTimepickerElement_trigger, "f")) {
|
|
1198
|
+
this.hide();
|
|
1199
|
+
} else {
|
|
1200
|
+
await this.show(trigger, anchor);
|
|
1201
|
+
}
|
|
1202
|
+
}
|
|
1203
|
+
/** @inheritdoc */
|
|
1204
|
+
render() {
|
|
1205
|
+
return html`<m3e-focus-trap ?disabled="${!this._open}">${__classPrivateFieldGet(this, _M3eTimepickerElement_instances, "m", _M3eTimepickerElement_renderHeader).call(this)}${__classPrivateFieldGet(this, _M3eTimepickerElement_instances, "m", _M3eTimepickerElement_renderPicker).call(this)}${__classPrivateFieldGet(this, _M3eTimepickerElement_instances, "m", _M3eTimepickerElement_renderActions).call(this)}</m3e-focus-trap>`;
|
|
1206
|
+
}
|
|
1207
|
+
/** @inheritdoc */
|
|
1208
|
+
willUpdate(changedProperties) {
|
|
1209
|
+
super.willUpdate(changedProperties);
|
|
1210
|
+
if (changedProperties.has("date")) {
|
|
1211
|
+
__classPrivateFieldGet(this, _M3eTimepickerElement_instances, "m", _M3eTimepickerElement_clearSelectionState).call(this);
|
|
1212
|
+
}
|
|
1213
|
+
if (changedProperties.has("variant") || changedProperties.has("orientation")) {
|
|
1214
|
+
__classPrivateFieldGet(this, _M3eTimepickerElement_breakpointUnobserve, "f")?.call(this);
|
|
1215
|
+
if (this.variant !== "auto") {
|
|
1216
|
+
this._variant = undefined;
|
|
1217
|
+
__classPrivateFieldGet(this, _M3eTimepickerElement_instances, "m", _M3eTimepickerElement_updateVariant).call(this);
|
|
1218
|
+
}
|
|
1219
|
+
if (this.orientation !== "auto") {
|
|
1220
|
+
this._orientation = undefined;
|
|
1221
|
+
__classPrivateFieldGet(this, _M3eTimepickerElement_instances, "m", _M3eTimepickerElement_updateOrientation).call(this);
|
|
1222
|
+
}
|
|
1223
|
+
if (this.variant === "auto" || this.orientation === "auto") {
|
|
1224
|
+
__classPrivateFieldGet(this, _M3eTimepickerElement_instances, "m", _M3eTimepickerElement_initBreakpointMonitoring).call(this);
|
|
1225
|
+
}
|
|
1226
|
+
}
|
|
1227
|
+
}
|
|
1228
|
+
};
|
|
1229
|
+
_M3eTimepickerElement_closeTimeout = new WeakMap();
|
|
1230
|
+
_M3eTimepickerElement_date = new WeakMap();
|
|
1231
|
+
_M3eTimepickerElement_breakpointUnobserve = new WeakMap();
|
|
1232
|
+
_M3eTimepickerElement_trigger = new WeakMap();
|
|
1233
|
+
_M3eTimepickerElement_anchor = new WeakMap();
|
|
1234
|
+
_M3eTimepickerElement_anchorCleanup = new WeakMap();
|
|
1235
|
+
_M3eTimepickerElement_anchorLastPosition = new WeakMap();
|
|
1236
|
+
_M3eTimepickerElement_scrollLockController = new WeakMap();
|
|
1237
|
+
_M3eTimepickerElement_inertController = new WeakMap();
|
|
1238
|
+
_M3eTimepickerElement_documentClickHandler = new WeakMap();
|
|
1239
|
+
_M3eTimepickerElement_documentKeyDownHandler = new WeakMap();
|
|
1240
|
+
_M3eTimepickerElement_toggleHandler = new WeakMap();
|
|
1241
|
+
_M3eTimepickerElement_instances = new WeakSet();
|
|
1242
|
+
_M3eTimepickerElement_renderHeader = function _M3eTimepickerElement_renderHeader() {
|
|
1243
|
+
return html`<div class="headline">${this.currentMode === "dial" ? this.dialLabel : this.inputLabel}</div>`;
|
|
1244
|
+
};
|
|
1245
|
+
_M3eTimepickerElement_renderPicker = function _M3eTimepickerElement_renderPicker() {
|
|
1246
|
+
// Picker is rendered only when open
|
|
1247
|
+
return this._open ? html`<div class="base"><m3e-timepicker-input class="input" for="${ifDefined(this.currentMode === "input" ? undefined : "dial")}" ?hide-labels="${this.currentMode === "dial"}" period-toggle-label="${this.periodToggleLabel}" hour-label="${this.hourLabel}" minute-label="${this.minuteLabel}" orientation="${this.currentOrientation === "vertical" ? "horizontal" : "vertical"}" format="${this.format}" @change="${__classPrivateFieldGet(this, _M3eTimepickerElement_instances, "m", _M3eTimepickerElement_handleInputChange)}"></m3e-timepicker-input><m3e-collapsible orientation="${this.currentOrientation === "horizontal" ? "both" : "vertical"}" ?open="${this.currentMode === "dial"}"><div class="dial-wrapper"><div class="dial-spacer"></div><m3e-timepicker-dial id="dial" class="dial"></m3e-timepicker-dial></div></m3e-collapsible></div>` : nothing;
|
|
1248
|
+
};
|
|
1249
|
+
_M3eTimepickerElement_renderActions = function _M3eTimepickerElement_renderActions() {
|
|
1250
|
+
return html`<div class="actions">${__classPrivateFieldGet(this, _M3eTimepickerElement_instances, "m", _M3eTimepickerElement_renderModeToggleButton).call(this)}<div class="spacer" aria-hidden="true"></div><m3e-button @click="${__classPrivateFieldGet(this, _M3eTimepickerElement_instances, "m", _M3eTimepickerElement_handleDismissClick)}">${this.dismissLabel}</m3e-button><m3e-button ?disabled="${this._invalid}" @click="${__classPrivateFieldGet(this, _M3eTimepickerElement_instances, "m", _M3eTimepickerElement_handleConfirmClick)}">${this.confirmLabel}</m3e-button></div>`;
|
|
1251
|
+
};
|
|
1252
|
+
_M3eTimepickerElement_renderModeToggleButton = function _M3eTimepickerElement_renderModeToggleButton() {
|
|
1253
|
+
if (this.hideModeToggle) return nothing;
|
|
1254
|
+
return html`<m3e-icon-button aria-label="${this.modeToggleLabel}" aria-expanded="${this.currentMode === "dial"}" aria-controls="dial" @click="${__classPrivateFieldGet(this, _M3eTimepickerElement_instances, "m", _M3eTimepickerElement_handleModeClick)}">${this.currentMode === "dial" ? svg`<svg viewBox="0 -960 960 960" fill="currentColor">
|
|
1255
|
+
<path
|
|
1256
|
+
d="M160-200q-33 0-56.5-23.5T80-280v-400q0-33 23.5-56.5T160-760h640q33 0 56.5 23.5T880-680v400q0 33-23.5 56.5T800-200H160Zm0-80h640v-400H160v400Zm160-40h320v-80H320v80ZM200-440h80v-80h-80v80Zm120 0h80v-80h-80v80Zm120 0h80v-80h-80v80Zm120 0h80v-80h-80v80Zm120 0h80v-80h-80v80ZM200-560h80v-80h-80v80Zm120 0h80v-80h-80v80Zm120 0h80v-80h-80v80Zm120 0h80v-80h-80v80Zm120 0h80v-80h-80v80ZM160-280v-400 400Z"
|
|
1257
|
+
/>
|
|
1258
|
+
</svg>` : svg`<svg viewBox="0 -960 960 960" fill="currentColor">
|
|
1259
|
+
<path
|
|
1260
|
+
d="m612-292 56-56-148-148v-184h-80v216l172 172ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-400Zm0 320q133 0 226.5-93.5T800-480q0-133-93.5-226.5T480-800q-133 0-226.5 93.5T160-480q0 133 93.5 226.5T480-160Z"
|
|
1261
|
+
/>
|
|
1262
|
+
</svg>`}</m3e-icon-button>`;
|
|
1263
|
+
};
|
|
1264
|
+
_M3eTimepickerElement_handleModeClick = function _M3eTimepickerElement_handleModeClick() {
|
|
1265
|
+
this._mode = this.currentMode === "dial" ? "input" : "dial";
|
|
1266
|
+
};
|
|
1267
|
+
_M3eTimepickerElement_handleDocumentClick = function _M3eTimepickerElement_handleDocumentClick(e) {
|
|
1268
|
+
if (this.isOpen && !e.composedPath().some(x => x === this || x === __classPrivateFieldGet(this, _M3eTimepickerElement_trigger, "f"))) {
|
|
1269
|
+
this.hide();
|
|
1270
|
+
}
|
|
1271
|
+
};
|
|
1272
|
+
_M3eTimepickerElement_handleInputChange = function _M3eTimepickerElement_handleInputChange(e) {
|
|
1273
|
+
const input = e.target;
|
|
1274
|
+
if (input.hour === null || input.minute === null) {
|
|
1275
|
+
__classPrivateFieldSet(this, _M3eTimepickerElement_date, null, "f");
|
|
1276
|
+
} else {
|
|
1277
|
+
__classPrivateFieldSet(this, _M3eTimepickerElement_date, new Date(this.date ?? Date.now()), "f");
|
|
1278
|
+
__classPrivateFieldGet(this, _M3eTimepickerElement_date, "f").setHours(input.hour);
|
|
1279
|
+
__classPrivateFieldGet(this, _M3eTimepickerElement_date, "f").setMinutes(input.minute);
|
|
1280
|
+
}
|
|
1281
|
+
__classPrivateFieldGet(this, _M3eTimepickerElement_instances, "m", _M3eTimepickerElement_validate).call(this);
|
|
1282
|
+
};
|
|
1283
|
+
_M3eTimepickerElement_handleDismissClick = function _M3eTimepickerElement_handleDismissClick() {
|
|
1284
|
+
this.hide(true);
|
|
1285
|
+
};
|
|
1286
|
+
_M3eTimepickerElement_handleConfirmClick = function _M3eTimepickerElement_handleConfirmClick() {
|
|
1287
|
+
if (__classPrivateFieldGet(this, _M3eTimepickerElement_date, "f") !== undefined) {
|
|
1288
|
+
this.date = __classPrivateFieldGet(this, _M3eTimepickerElement_date, "f");
|
|
1289
|
+
}
|
|
1290
|
+
this.hide(true);
|
|
1291
|
+
this.dispatchEvent(new Event("change", {
|
|
1292
|
+
bubbles: true
|
|
1293
|
+
}));
|
|
1294
|
+
};
|
|
1295
|
+
_M3eTimepickerElement_handleDocumentKeyDown = function _M3eTimepickerElement_handleDocumentKeyDown(e) {
|
|
1296
|
+
if (this.isOpen && this.currentVariant === "modal" && e.key === "Escape" && !e.shiftKey && !e.ctrlKey) {
|
|
1297
|
+
e.preventDefault();
|
|
1298
|
+
this.hide(true);
|
|
1299
|
+
}
|
|
1300
|
+
};
|
|
1301
|
+
_M3eTimepickerElement_handleToggle = function _M3eTimepickerElement_handleToggle(e) {
|
|
1302
|
+
if (e.newState === "closed") {
|
|
1303
|
+
__classPrivateFieldGet(this, _M3eTimepickerElement_instances, "m", _M3eTimepickerElement_clearSelectionState).call(this);
|
|
1304
|
+
__classPrivateFieldGet(this, _M3eTimepickerElement_anchorCleanup, "f")?.call(this);
|
|
1305
|
+
__classPrivateFieldSet(this, _M3eTimepickerElement_anchorCleanup, undefined, "f");
|
|
1306
|
+
__classPrivateFieldSet(this, _M3eTimepickerElement_anchorLastPosition, undefined, "f");
|
|
1307
|
+
clearTimeout(__classPrivateFieldGet(this, _M3eTimepickerElement_closeTimeout, "f"));
|
|
1308
|
+
if (!prefersReducedMotion()) {
|
|
1309
|
+
__classPrivateFieldSet(this, _M3eTimepickerElement_closeTimeout, setTimeout(() => this._open = false, 100), "f");
|
|
1310
|
+
} else {
|
|
1311
|
+
this._open = false;
|
|
1312
|
+
}
|
|
1313
|
+
}
|
|
1314
|
+
};
|
|
1315
|
+
_M3eTimepickerElement_initBreakpointMonitoring = function _M3eTimepickerElement_initBreakpointMonitoring() {
|
|
1316
|
+
__classPrivateFieldSet(this, _M3eTimepickerElement_breakpointUnobserve, M3eBreakpointObserver.observe([Breakpoint.XSmall, Breakpoint.Small], matches => {
|
|
1317
|
+
if (this.variant === "auto") {
|
|
1318
|
+
this._variant = matches.get(Breakpoint.XSmall) || matches.get(Breakpoint.Small) ? "modal" : "docked";
|
|
1319
|
+
__classPrivateFieldGet(this, _M3eTimepickerElement_instances, "m", _M3eTimepickerElement_updateVariant).call(this);
|
|
1320
|
+
}
|
|
1321
|
+
if (this.orientation === "auto") {
|
|
1322
|
+
this._orientation = matches.get(Breakpoint.Small) ? "horizontal" : "vertical";
|
|
1323
|
+
__classPrivateFieldGet(this, _M3eTimepickerElement_instances, "m", _M3eTimepickerElement_updateOrientation).call(this);
|
|
1324
|
+
}
|
|
1325
|
+
}), "f");
|
|
1326
|
+
};
|
|
1327
|
+
_M3eTimepickerElement_updateVariant = function _M3eTimepickerElement_updateVariant() {
|
|
1328
|
+
switch (this.currentVariant) {
|
|
1329
|
+
case "docked":
|
|
1330
|
+
this.ariaModal = null;
|
|
1331
|
+
deleteCustomState(this, "--modal");
|
|
1332
|
+
addCustomState(this, "--docked");
|
|
1333
|
+
__classPrivateFieldGet(this, _M3eTimepickerElement_scrollLockController, "f").unlock();
|
|
1334
|
+
__classPrivateFieldGet(this, _M3eTimepickerElement_inertController, "f").unlock();
|
|
1335
|
+
break;
|
|
1336
|
+
case "modal":
|
|
1337
|
+
this.ariaModal = "true";
|
|
1338
|
+
deleteCustomState(this, "--docked");
|
|
1339
|
+
addCustomState(this, "--modal");
|
|
1340
|
+
if (this.isOpen) {
|
|
1341
|
+
__classPrivateFieldGet(this, _M3eTimepickerElement_scrollLockController, "f").lock();
|
|
1342
|
+
__classPrivateFieldGet(this, _M3eTimepickerElement_inertController, "f").lock();
|
|
1343
|
+
}
|
|
1344
|
+
break;
|
|
1345
|
+
}
|
|
1346
|
+
if (this.isOpen) {
|
|
1347
|
+
__classPrivateFieldGet(this, _M3eTimepickerElement_instances, "m", _M3eTimepickerElement_updatePosition).call(this);
|
|
1348
|
+
}
|
|
1349
|
+
};
|
|
1350
|
+
_M3eTimepickerElement_updateOrientation = function _M3eTimepickerElement_updateOrientation() {
|
|
1351
|
+
switch (this.currentOrientation) {
|
|
1352
|
+
case "horizontal":
|
|
1353
|
+
addCustomState(this, "--horizontal");
|
|
1354
|
+
break;
|
|
1355
|
+
case "vertical":
|
|
1356
|
+
deleteCustomState(this, "--horizontal");
|
|
1357
|
+
break;
|
|
1358
|
+
}
|
|
1359
|
+
};
|
|
1360
|
+
_M3eTimepickerElement_updatePosition = /** @private */
|
|
1361
|
+
async function _M3eTimepickerElement_updatePosition() {
|
|
1362
|
+
if (this.currentVariant === "docked" && __classPrivateFieldGet(this, _M3eTimepickerElement_trigger, "f")) {
|
|
1363
|
+
__classPrivateFieldGet(this, _M3eTimepickerElement_anchorCleanup, "f")?.call(this);
|
|
1364
|
+
__classPrivateFieldSet(this, _M3eTimepickerElement_anchorLastPosition, undefined, "f");
|
|
1365
|
+
__classPrivateFieldSet(this, _M3eTimepickerElement_anchorCleanup, await positionAnchor(this, __classPrivateFieldGet(this, _M3eTimepickerElement_anchor, "f") ?? __classPrivateFieldGet(this, _M3eTimepickerElement_trigger, "f"), {
|
|
1366
|
+
position: "bottom-start",
|
|
1367
|
+
inline: true,
|
|
1368
|
+
flip: true,
|
|
1369
|
+
shift: "both"
|
|
1370
|
+
}, (x, y, position) => {
|
|
1371
|
+
setCustomState(this, "--top", position.includes("top"));
|
|
1372
|
+
setCustomState(this, "--bottom", position.includes("bottom"));
|
|
1373
|
+
if (__classPrivateFieldGet(this, _M3eTimepickerElement_anchorLastPosition, "f")?.dir !== M3eDirectionality.current || __classPrivateFieldGet(this, _M3eTimepickerElement_anchorLastPosition, "f")?.x !== x) {
|
|
1374
|
+
if (M3eDirectionality.current === "rtl") {
|
|
1375
|
+
this.style.right = `${window.innerWidth - x - this.clientWidth}px`;
|
|
1376
|
+
this.style.left = "";
|
|
1377
|
+
} else {
|
|
1378
|
+
this.style.left = `${x}px`;
|
|
1379
|
+
this.style.right = "";
|
|
1380
|
+
}
|
|
1381
|
+
}
|
|
1382
|
+
if (__classPrivateFieldGet(this, _M3eTimepickerElement_anchorLastPosition, "f")?.y !== y) {
|
|
1383
|
+
this.style.top = `${y}px`;
|
|
1384
|
+
}
|
|
1385
|
+
__classPrivateFieldSet(this, _M3eTimepickerElement_anchorLastPosition, {
|
|
1386
|
+
x,
|
|
1387
|
+
y,
|
|
1388
|
+
dir: M3eDirectionality.current
|
|
1389
|
+
}, "f");
|
|
1390
|
+
}), "f");
|
|
1391
|
+
} else {
|
|
1392
|
+
__classPrivateFieldGet(this, _M3eTimepickerElement_instances, "m", _M3eTimepickerElement_clearAnchoring).call(this);
|
|
1393
|
+
}
|
|
1394
|
+
};
|
|
1395
|
+
_M3eTimepickerElement_clearAnchoring = function _M3eTimepickerElement_clearAnchoring() {
|
|
1396
|
+
__classPrivateFieldGet(this, _M3eTimepickerElement_anchorCleanup, "f")?.call(this);
|
|
1397
|
+
__classPrivateFieldSet(this, _M3eTimepickerElement_anchorCleanup, undefined, "f");
|
|
1398
|
+
__classPrivateFieldSet(this, _M3eTimepickerElement_anchorLastPosition, undefined, "f");
|
|
1399
|
+
this.style.left = "";
|
|
1400
|
+
this.style.right = "";
|
|
1401
|
+
this.style.top = "";
|
|
1402
|
+
};
|
|
1403
|
+
_M3eTimepickerElement_clearSelectionState = function _M3eTimepickerElement_clearSelectionState() {
|
|
1404
|
+
__classPrivateFieldSet(this, _M3eTimepickerElement_date, undefined, "f");
|
|
1405
|
+
};
|
|
1406
|
+
_M3eTimepickerElement_validate = function _M3eTimepickerElement_validate() {
|
|
1407
|
+
if (__classPrivateFieldGet(this, _M3eTimepickerElement_date, "f") === undefined && this.date) {
|
|
1408
|
+
// There is a value, but the value didn't change
|
|
1409
|
+
this._invalid = false;
|
|
1410
|
+
return;
|
|
1411
|
+
}
|
|
1412
|
+
if (__classPrivateFieldGet(this, _M3eTimepickerElement_date, "f") === null || __classPrivateFieldGet(this, _M3eTimepickerElement_date, "f") === undefined) {
|
|
1413
|
+
this._invalid = true;
|
|
1414
|
+
return;
|
|
1415
|
+
}
|
|
1416
|
+
const hour = __classPrivateFieldGet(this, _M3eTimepickerElement_date, "f").getHours();
|
|
1417
|
+
const minute = __classPrivateFieldGet(this, _M3eTimepickerElement_date, "f").getMinutes();
|
|
1418
|
+
if (this.minTime) {
|
|
1419
|
+
if (hour < this.minTime.hour || hour === this.minTime.hour && minute < this.minTime.minute) {
|
|
1420
|
+
this._invalid = true;
|
|
1421
|
+
return;
|
|
1422
|
+
}
|
|
1423
|
+
}
|
|
1424
|
+
if (this.maxTime) {
|
|
1425
|
+
if (hour > this.maxTime.hour || hour === this.maxTime.hour && minute > this.maxTime.minute) {
|
|
1426
|
+
this._invalid = true;
|
|
1427
|
+
return;
|
|
1428
|
+
}
|
|
1429
|
+
}
|
|
1430
|
+
if (this.blackoutTimes?.({
|
|
1431
|
+
hour,
|
|
1432
|
+
minute
|
|
1433
|
+
})) {
|
|
1434
|
+
this._invalid = true;
|
|
1435
|
+
return;
|
|
1436
|
+
}
|
|
1437
|
+
this._invalid = false;
|
|
1438
|
+
};
|
|
1439
|
+
/** The styles of the element. */
|
|
1440
|
+
M3eTimepickerElement.styles = css`:host { flex-direction: column; margin: unset; border: unset; padding-block: var(--m3e-timepicker-container-padding-block, 0.75rem); padding-inline: var(--m3e-timepicker-container-padding-inline, 1.75rem); background-color: var(--m3e-timepicker-container-color, ${DesignToken.color.surfaceContainer}); box-shadow: var(--m3e-timepicker-container-elevation, ${DesignToken.elevation.level3}); opacity: 0; display: none; } .headline { color: var(--m3e-timepicker-headline-color, ${DesignToken.color.onSurfaceVariant}); font-size: var(--m3e-timepicker-headline-font-size, ${DesignToken.typescale.standard.label.large.fontSize}); font-weight: var(--m3e-timepicker-headline-font-weight, ${DesignToken.typescale.standard.label.large.fontWeight}); line-height: var(--m3e-timepicker-headline-line-height, ${DesignToken.typescale.standard.label.large.lineHeight}); letter-spacing: var(--m3e-timepicker-headline-tracking, ${DesignToken.typescale.standard.label.large.tracking}); margin-block-start: var(--m3e-timepicker-headline-top-space, 1rem); } .actions { margin-block-start: var(--m3e-timepicker-actions-space, 1.5rem); display: flex; align-items: center; column-gap: 0.5rem; } .spacer { flex: 1 1 auto; } :host(:is(:state(--docked), :--docked)) { position: absolute; background-color: var(--m3e-timepicker-docked-container-color, ${DesignToken.color.surfaceContainer}); border-radius: var(--m3e-timepicker-docked-container-shape, ${DesignToken.shape.corner.large}); } :host(:is(:state(--modal), :--modal)) { position: fixed; inset: 0; margin: auto; transform-origin: top; background-color: var(--m3e-timepicker-modal-container-color, ${DesignToken.color.surfaceContainerHigh}); border-radius: var(--m3e-timepicker-modal-container-shape, ${DesignToken.shape.corner.extraLarge}); } :host(:not(:is(:state(--no-animate), :--no-animate))) { transition: ${unsafeCSS(`opacity ${DesignToken.motion.duration.short2} ${DesignToken.motion.easing.standard},
|
|
1441
|
+
transform ${DesignToken.motion.duration.short2} ${DesignToken.motion.easing.standard},
|
|
1442
|
+
overlay ${DesignToken.motion.duration.short2} ${DesignToken.motion.easing.standard} allow-discrete,
|
|
1443
|
+
display ${DesignToken.motion.duration.short2} ${DesignToken.motion.easing.standard} allow-discrete`)}; } :host { transform: scaleY(0.8); } :host(:popover-open) { transform: scaleY(1); display: inline-flex; opacity: 1; } :host(:is(:state(--docked), :--docked))::backdrop { background-color: transparent; } :host(:is(:state(--modal), :--modal))::backdrop { background-color: color-mix(in srgb, var(--m3e-dialog-scrim-color, ${DesignToken.color.scrim}) 0%, transparent); margin-inline-end: -20px; } :host(:is(:state(--modal), :--modal):not(:popover-open))::backdrop { transition: ${unsafeCSS(`background-color ${DesignToken.motion.duration.short3} ${DesignToken.motion.easing.standard},
|
|
1444
|
+
overlay ${DesignToken.motion.duration.short3} ${DesignToken.motion.easing.standard} allow-discrete,
|
|
1445
|
+
visibility ${DesignToken.motion.duration.short3} ${DesignToken.motion.easing.standard} allow-discrete`)}; } :host(:is(:state(--modal), :--modal):popover-open)::backdrop { background-color: color-mix( in srgb, var(--m3e-dialog-scrim-color, ${DesignToken.color.scrim}) var(--m3e-dialog-scrim-opacity, 32%), transparent ); transition: ${unsafeCSS(`background-color ${DesignToken.motion.duration.long2} ${DesignToken.motion.easing.standard},
|
|
1446
|
+
overlay ${DesignToken.motion.duration.long2} ${DesignToken.motion.easing.standard} allow-discrete,
|
|
1447
|
+
visibility ${DesignToken.motion.duration.long2} ${DesignToken.motion.easing.standard} allow-discrete`)}; } :host(:is(:state(--bottom), :--bottom)) { transform-origin: top; } :host(:is(:state(--top), :--top)) { transform-origin: bottom; } @starting-style { :host(:popover-open) { transform: scaleY(0.8); } :host(:is(:state(--modal), :--modal):popover-open)::backdrop { background-color: color-mix(in srgb, var(--m3e-dialog-scrim-color, ${DesignToken.color.scrim}) 0%, transparent); } } .base { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; } :host(:not(:is(:state(--horizontal), :--horizontal))) .base { flex-direction: column; } .input { margin-top: var(--m3e-timepicker-label-input-space, 1.25rem); } .dial-wrapper { display: flex; transition: ${unsafeCSS(`opacity var(--m3e-collapsible-animation-duration, ${DesignToken.motion.duration.medium1}) ${DesignToken.motion.easing.standard}`)}; } .dial-spacer, .dial { flex: none; } :host(:not([mode="dial"])) .dial-wrapper { opacity: 0; } :host([mode="dial"]) .dial-wrapper { opacity: 1; } :host(:not(:is(:state(--horizontal), :--horizontal))) .dial-wrapper { flex-direction: column; } :host(:not(:is(:state(--horizontal), :--horizontal))) .dial-spacer { height: var(--m3e-timepicker-vertical-input-dial-space, 2.25rem); } :host(:is(:state(--horizontal), :--horizontal)) .dial-spacer { width: var(--m3e-timepicker-horizontal-input-dial-space, 3.25rem); } @media (prefers-reduced-motion) { :host(:not(:is(:state(--no-animate), :--no-animate))) { transition: none; } } @media (forced-colors: active) { :host { background-color: Menu; color: MenuText; border: 1px solid CanvasText; } }`;
|
|
1448
|
+
__decorate([state()], M3eTimepickerElement.prototype, "_open", void 0);
|
|
1449
|
+
__decorate([query("m3e-timepicker-input")], M3eTimepickerElement.prototype, "_input", void 0);
|
|
1450
|
+
__decorate([state()], M3eTimepickerElement.prototype, "_invalid", void 0);
|
|
1451
|
+
__decorate([state()], M3eTimepickerElement.prototype, "_variant", void 0);
|
|
1452
|
+
__decorate([state()], M3eTimepickerElement.prototype, "_orientation", void 0);
|
|
1453
|
+
__decorate([state()], M3eTimepickerElement.prototype, "_mode", void 0);
|
|
1454
|
+
__decorate([property()], M3eTimepickerElement.prototype, "variant", void 0);
|
|
1455
|
+
__decorate([property({
|
|
1456
|
+
reflect: true
|
|
1457
|
+
})], M3eTimepickerElement.prototype, "mode", void 0);
|
|
1458
|
+
__decorate([property({
|
|
1459
|
+
reflect: true
|
|
1460
|
+
})], M3eTimepickerElement.prototype, "orientation", void 0);
|
|
1461
|
+
__decorate([property({
|
|
1462
|
+
converter: dateConverter
|
|
1463
|
+
})], M3eTimepickerElement.prototype, "date", void 0);
|
|
1464
|
+
__decorate([property()], M3eTimepickerElement.prototype, "format", void 0);
|
|
1465
|
+
__decorate([property({
|
|
1466
|
+
attribute: "min-time",
|
|
1467
|
+
converter: timeConverter$1
|
|
1468
|
+
})], M3eTimepickerElement.prototype, "minTime", void 0);
|
|
1469
|
+
__decorate([property({
|
|
1470
|
+
attribute: "max-time",
|
|
1471
|
+
converter: timeConverter$1
|
|
1472
|
+
})], M3eTimepickerElement.prototype, "maxTime", void 0);
|
|
1473
|
+
__decorate([property()], M3eTimepickerElement.prototype, "blackoutTimes", void 0);
|
|
1474
|
+
__decorate([property({
|
|
1475
|
+
attribute: "hide-mode-toggle",
|
|
1476
|
+
type: Boolean
|
|
1477
|
+
})], M3eTimepickerElement.prototype, "hideModeToggle", void 0);
|
|
1478
|
+
__decorate([property({
|
|
1479
|
+
attribute: "confirm-label"
|
|
1480
|
+
})], M3eTimepickerElement.prototype, "confirmLabel", void 0);
|
|
1481
|
+
__decorate([property({
|
|
1482
|
+
attribute: "dismiss-label"
|
|
1483
|
+
})], M3eTimepickerElement.prototype, "dismissLabel", void 0);
|
|
1484
|
+
__decorate([property({
|
|
1485
|
+
attribute: "dial-label"
|
|
1486
|
+
})], M3eTimepickerElement.prototype, "dialLabel", void 0);
|
|
1487
|
+
__decorate([property({
|
|
1488
|
+
attribute: "input-label"
|
|
1489
|
+
})], M3eTimepickerElement.prototype, "inputLabel", void 0);
|
|
1490
|
+
__decorate([property({
|
|
1491
|
+
attribute: "hour-label"
|
|
1492
|
+
})], M3eTimepickerElement.prototype, "hourLabel", void 0);
|
|
1493
|
+
__decorate([property({
|
|
1494
|
+
attribute: "minute-label"
|
|
1495
|
+
})], M3eTimepickerElement.prototype, "minuteLabel", void 0);
|
|
1496
|
+
__decorate([property({
|
|
1497
|
+
attribute: "mode-toggle-label"
|
|
1498
|
+
})], M3eTimepickerElement.prototype, "modeToggleLabel", void 0);
|
|
1499
|
+
__decorate([property({
|
|
1500
|
+
attribute: "period-toggle-label"
|
|
1501
|
+
})], M3eTimepickerElement.prototype, "periodToggleLabel", void 0);
|
|
1502
|
+
M3eTimepickerElement = __decorate([customElement("m3e-timepicker")], M3eTimepickerElement);
|
|
1503
|
+
|
|
1504
|
+
/**
|
|
1505
|
+
* An element, nested within a clickable element, used to toggle a timepicker.
|
|
1506
|
+
* @tag m3e-timepicker-toggle
|
|
1507
|
+
*/
|
|
1508
|
+
let M3eTimepickerToggleElement = class M3eTimepickerToggleElement extends HtmlFor(ActionElementBase) {
|
|
1509
|
+
/** @inheritdoc */
|
|
1510
|
+
connectedCallback() {
|
|
1511
|
+
super.connectedCallback();
|
|
1512
|
+
if (this.parentElement) {
|
|
1513
|
+
this.parentElement.ariaHasPopup = "dialog";
|
|
1514
|
+
}
|
|
1515
|
+
}
|
|
1516
|
+
/** @inheritdoc */
|
|
1517
|
+
disconnectedCallback() {
|
|
1518
|
+
super.disconnectedCallback();
|
|
1519
|
+
if (this.parentElement) {
|
|
1520
|
+
this.parentElement.ariaHasPopup = null;
|
|
1521
|
+
}
|
|
1522
|
+
}
|
|
1523
|
+
/** @inheritdoc */
|
|
1524
|
+
_onClick() {
|
|
1525
|
+
if (this.control instanceof M3eTimepickerElement && this.parentElement) {
|
|
1526
|
+
this.control.toggle(this.parentElement, this.closest("m3e-form-field") ?? undefined);
|
|
1527
|
+
}
|
|
1528
|
+
}
|
|
1529
|
+
};
|
|
1530
|
+
M3eTimepickerToggleElement = __decorate([customElement("m3e-timepicker-toggle")], M3eTimepickerToggleElement);
|
|
1531
|
+
|
|
1532
|
+
export { M3eTimepickerDialElement, M3eTimepickerElement, M3eTimepickerInputElement, M3eTimepickerToggleElement };
|
|
1533
|
+
//# sourceMappingURL=timepicker.js.map
|