@m3e/web 2.5.16 → 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 +1565 -6
- 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/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/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,3605 @@
|
|
|
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 { isServer, nothing, noChange, unsafeCSS, css, LitElement, html } from 'lit';
|
|
7
|
+
import { directive, Directive, PartType } from 'lit/directive.js';
|
|
8
|
+
import { __classPrivateFieldGet, __classPrivateFieldSet, __decorate } from 'tslib';
|
|
9
|
+
import { property, query } from 'lit/decorators.js';
|
|
10
|
+
import 'lit/directives/if-defined.js';
|
|
11
|
+
|
|
12
|
+
var _AnimationLoopController_frameId, _AnimationLoopController_lastTime, _AnimationLoopController_running, _AnimationLoopController_callback, _AnimationLoopController_loop;
|
|
13
|
+
/** A `ReactiveController` used to execute a function in an animation loop. */
|
|
14
|
+
class AnimationLoopController {
|
|
15
|
+
constructor(host, callback) {
|
|
16
|
+
/** @private */_AnimationLoopController_frameId.set(this, null);
|
|
17
|
+
/** @private */
|
|
18
|
+
_AnimationLoopController_lastTime.set(this, 0);
|
|
19
|
+
/** @private */
|
|
20
|
+
_AnimationLoopController_running.set(this, false);
|
|
21
|
+
/** @private */
|
|
22
|
+
_AnimationLoopController_callback.set(this, void 0);
|
|
23
|
+
/** @private */
|
|
24
|
+
_AnimationLoopController_loop.set(this, () => {
|
|
25
|
+
if (!__classPrivateFieldGet(this, _AnimationLoopController_running, "f")) return;
|
|
26
|
+
const now = performance.now();
|
|
27
|
+
__classPrivateFieldGet(this, _AnimationLoopController_callback, "f").call(this, (now - __classPrivateFieldGet(this, _AnimationLoopController_lastTime, "f")) / 1000, now / 1000);
|
|
28
|
+
__classPrivateFieldSet(this, _AnimationLoopController_lastTime, now, "f");
|
|
29
|
+
__classPrivateFieldSet(this, _AnimationLoopController_frameId, requestAnimationFrame(__classPrivateFieldGet(this, _AnimationLoopController_loop, "f")), "f");
|
|
30
|
+
});
|
|
31
|
+
__classPrivateFieldSet(this, _AnimationLoopController_callback, callback, "f");
|
|
32
|
+
host.addController(this);
|
|
33
|
+
}
|
|
34
|
+
/** @inheritdoc */
|
|
35
|
+
hostDisconnected() {
|
|
36
|
+
this.stop();
|
|
37
|
+
}
|
|
38
|
+
/** Starts the animation loop. */
|
|
39
|
+
start() {
|
|
40
|
+
if (__classPrivateFieldGet(this, _AnimationLoopController_running, "f")) return;
|
|
41
|
+
__classPrivateFieldSet(this, _AnimationLoopController_running, true, "f");
|
|
42
|
+
__classPrivateFieldSet(this, _AnimationLoopController_lastTime, performance.now(), "f");
|
|
43
|
+
__classPrivateFieldGet(this, _AnimationLoopController_loop, "f").call(this);
|
|
44
|
+
}
|
|
45
|
+
/** Stops the animation loop. */
|
|
46
|
+
stop() {
|
|
47
|
+
if (!__classPrivateFieldGet(this, _AnimationLoopController_running, "f")) return;
|
|
48
|
+
__classPrivateFieldSet(this, _AnimationLoopController_running, false, "f");
|
|
49
|
+
if (__classPrivateFieldGet(this, _AnimationLoopController_frameId, "f") !== null) {
|
|
50
|
+
cancelAnimationFrame(__classPrivateFieldGet(this, _AnimationLoopController_frameId, "f"));
|
|
51
|
+
__classPrivateFieldSet(this, _AnimationLoopController_frameId, null, "f");
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
_AnimationLoopController_frameId = new WeakMap(), _AnimationLoopController_lastTime = new WeakMap(), _AnimationLoopController_running = new WeakMap(), _AnimationLoopController_callback = new WeakMap(), _AnimationLoopController_loop = new WeakMap();
|
|
56
|
+
|
|
57
|
+
var _MonitorControllerBase_host, _MonitorControllerBase_target, _MonitorControllerBase_targets;
|
|
58
|
+
/**
|
|
59
|
+
* A base implementation for a `ReactiveController` used to monitor the state of one
|
|
60
|
+
* or more elements. This class must be inherited.
|
|
61
|
+
*/
|
|
62
|
+
class MonitorControllerBase {
|
|
63
|
+
/**
|
|
64
|
+
* Initializes the `MonitorControllerBase` base class values when called by a derived class.
|
|
65
|
+
* @param {ReactiveControllerHost & HTMLElement} host The host element to which this controller will be added.
|
|
66
|
+
* @param {MonitorControllerOptions} options Options used to configure this controller.
|
|
67
|
+
*/
|
|
68
|
+
constructor(host, options) {
|
|
69
|
+
/** @private */_MonitorControllerBase_host.set(this, void 0);
|
|
70
|
+
/** @private */
|
|
71
|
+
_MonitorControllerBase_target.set(this, void 0);
|
|
72
|
+
/** @private */
|
|
73
|
+
_MonitorControllerBase_targets.set(this, new Set());
|
|
74
|
+
__classPrivateFieldSet(this, _MonitorControllerBase_host, host, "f");
|
|
75
|
+
__classPrivateFieldSet(this, _MonitorControllerBase_target, options.target, "f");
|
|
76
|
+
__classPrivateFieldGet(this, _MonitorControllerBase_host, "f").addController(this);
|
|
77
|
+
}
|
|
78
|
+
/** The targets being observed. */
|
|
79
|
+
get targets() {
|
|
80
|
+
return __classPrivateFieldGet(this, _MonitorControllerBase_targets, "f").values();
|
|
81
|
+
}
|
|
82
|
+
/** Whether one or more targets are being monitored. */
|
|
83
|
+
get hasTargets() {
|
|
84
|
+
return __classPrivateFieldGet(this, _MonitorControllerBase_targets, "f").size > 0;
|
|
85
|
+
}
|
|
86
|
+
/** @inheritdoc */
|
|
87
|
+
hostConnected() {
|
|
88
|
+
// Target defaults to host unless explicitly null.
|
|
89
|
+
if (__classPrivateFieldGet(this, _MonitorControllerBase_target, "f") !== null) {
|
|
90
|
+
this.observe(__classPrivateFieldGet(this, _MonitorControllerBase_target, "f") ?? __classPrivateFieldGet(this, _MonitorControllerBase_host, "f"));
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/** @inheritdoc */
|
|
94
|
+
hostDisconnected() {
|
|
95
|
+
this.unobserveAll();
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Starts observing the specified element.
|
|
99
|
+
* @param {HTMLElement} target The element to start observing.
|
|
100
|
+
*/
|
|
101
|
+
observe(target) {
|
|
102
|
+
if (__classPrivateFieldGet(this, _MonitorControllerBase_targets, "f").has(target)) return;
|
|
103
|
+
__classPrivateFieldGet(this, _MonitorControllerBase_targets, "f").add(target);
|
|
104
|
+
this._observe(target);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Determines whether the specified element is being observed.
|
|
108
|
+
* @param {HTMLElement} target The element to test.
|
|
109
|
+
* @returns {boolean} Whether `target` is being observed.
|
|
110
|
+
*/
|
|
111
|
+
isObserving(target) {
|
|
112
|
+
return __classPrivateFieldGet(this, _MonitorControllerBase_targets, "f").has(target);
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Stops observing the specified element.
|
|
116
|
+
* @param {HTMLElement} target The element to stop observing.
|
|
117
|
+
*/
|
|
118
|
+
unobserve(target) {
|
|
119
|
+
if (!__classPrivateFieldGet(this, _MonitorControllerBase_targets, "f").delete(target)) return;
|
|
120
|
+
this._unobserve(target);
|
|
121
|
+
}
|
|
122
|
+
/** Stops observing all targets. */
|
|
123
|
+
unobserveAll() {
|
|
124
|
+
__classPrivateFieldGet(this, _MonitorControllerBase_targets, "f").forEach(x => this.unobserve(x));
|
|
125
|
+
__classPrivateFieldGet(this, _MonitorControllerBase_targets, "f").clear();
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
_MonitorControllerBase_host = new WeakMap(), _MonitorControllerBase_target = new WeakMap(), _MonitorControllerBase_targets = new WeakMap();
|
|
129
|
+
|
|
130
|
+
var _ClickOutsideController_instances, _ClickOutsideController_callback, _ClickOutsideController_documentClickHandler, _ClickOutsideController_listening, _ClickOutsideController_handleDocumentClick;
|
|
131
|
+
/** A `ReactiveController` used to monitor whether the user clicks outside all observed elements. */
|
|
132
|
+
class ClickOutsideController extends MonitorControllerBase {
|
|
133
|
+
/**
|
|
134
|
+
* Initializes a new instance of this class.
|
|
135
|
+
* @param {ReactiveControllerHost & HTMLElement} host The host element to which this controller will be added.
|
|
136
|
+
* @param {FocusControllerOptions} options Options used to configure this controller.
|
|
137
|
+
*/
|
|
138
|
+
constructor(host, options) {
|
|
139
|
+
super(host, options);
|
|
140
|
+
_ClickOutsideController_instances.add(this);
|
|
141
|
+
/** @private */
|
|
142
|
+
_ClickOutsideController_callback.set(this, void 0);
|
|
143
|
+
/** @private */
|
|
144
|
+
_ClickOutsideController_documentClickHandler.set(this, e => __classPrivateFieldGet(this, _ClickOutsideController_instances, "m", _ClickOutsideController_handleDocumentClick).call(this, e));
|
|
145
|
+
/** @private */
|
|
146
|
+
_ClickOutsideController_listening.set(this, false);
|
|
147
|
+
__classPrivateFieldSet(this, _ClickOutsideController_callback, options.callback, "f");
|
|
148
|
+
}
|
|
149
|
+
/** @inheritdoc */
|
|
150
|
+
_observe() {
|
|
151
|
+
if (!__classPrivateFieldGet(this, _ClickOutsideController_listening, "f")) {
|
|
152
|
+
document.addEventListener("click", __classPrivateFieldGet(this, _ClickOutsideController_documentClickHandler, "f"));
|
|
153
|
+
__classPrivateFieldSet(this, _ClickOutsideController_listening, true, "f");
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
/** @inheritdoc */
|
|
157
|
+
_unobserve() {
|
|
158
|
+
if (!this.hasTargets && __classPrivateFieldGet(this, _ClickOutsideController_listening, "f")) {
|
|
159
|
+
document.removeEventListener("click", __classPrivateFieldGet(this, _ClickOutsideController_documentClickHandler, "f"));
|
|
160
|
+
__classPrivateFieldSet(this, _ClickOutsideController_listening, false, "f");
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
_ClickOutsideController_callback = new WeakMap(), _ClickOutsideController_documentClickHandler = new WeakMap(), _ClickOutsideController_listening = new WeakMap(), _ClickOutsideController_instances = new WeakSet(), _ClickOutsideController_handleDocumentClick = function _ClickOutsideController_handleDocumentClick(e) {
|
|
165
|
+
const composedPath = e.composedPath();
|
|
166
|
+
if (!composedPath.some(x => x instanceof HTMLElement && this.isObserving(x))) {
|
|
167
|
+
__classPrivateFieldGet(this, _ClickOutsideController_callback, "f").call(this, composedPath);
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Determines whether forced colors are active.
|
|
173
|
+
* @returns {boolean} Whether forced colors are active.
|
|
174
|
+
*/
|
|
175
|
+
function forcedColorsActive() {
|
|
176
|
+
return !isServer && matchMedia("(forced-colors: active)").matches;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Determines whether reduced motion is preferred.
|
|
181
|
+
* @returns {boolean} Whether reduced motion is preferred.
|
|
182
|
+
*/
|
|
183
|
+
function prefersReducedMotion() {
|
|
184
|
+
return isServer || matchMedia("(prefers-reduced-motion)").matches;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Resolves an element by ID, waiting for document readiness if needed.
|
|
189
|
+
* @param {string} id - The element ID to resolve.
|
|
190
|
+
* @param {ParentNode} root - Optional root node to query from (defaults to document).
|
|
191
|
+
* @returns {Promise<T | null>} A promise that resolves with the element or `null` if not found.
|
|
192
|
+
*/
|
|
193
|
+
function resolveElementById(id, root = document) {
|
|
194
|
+
return new Promise(resolve => {
|
|
195
|
+
const element = root.querySelector(`#${id}`);
|
|
196
|
+
if (element) {
|
|
197
|
+
resolve(element);
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
if (document.readyState === "complete" || document.readyState === "interactive") {
|
|
201
|
+
resolve(root.querySelector(`#${id}`));
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
document.addEventListener("DOMContentLoaded", () => resolve(root.querySelector(`#${id}`)), {
|
|
205
|
+
once: true
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
var _VelocityTracker_samples, _VelocityTracker_windowMs;
|
|
211
|
+
/** Utility for computing gesture velocity over a rolling time window. */
|
|
212
|
+
class VelocityTracker {
|
|
213
|
+
/**
|
|
214
|
+
* @param {number} [windowMs = 100] The size of the rolling sampling window in milliseconds.
|
|
215
|
+
*/
|
|
216
|
+
constructor(windowMs = 100) {
|
|
217
|
+
/** @private */_VelocityTracker_samples.set(this, []);
|
|
218
|
+
/** @private */
|
|
219
|
+
_VelocityTracker_windowMs.set(this, void 0);
|
|
220
|
+
__classPrivateFieldSet(this, _VelocityTracker_windowMs, windowMs, "f");
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Adds a new sample to the tracker.
|
|
224
|
+
* @param {number} value The value in pixels.
|
|
225
|
+
* @param {number} [timestamp=performance.now()] The timestamp when `value` changed.
|
|
226
|
+
*/
|
|
227
|
+
add(value, timestamp = performance.now()) {
|
|
228
|
+
__classPrivateFieldGet(this, _VelocityTracker_samples, "f").push({
|
|
229
|
+
y: value,
|
|
230
|
+
t: timestamp
|
|
231
|
+
});
|
|
232
|
+
const cutoff = timestamp - __classPrivateFieldGet(this, _VelocityTracker_windowMs, "f");
|
|
233
|
+
while (__classPrivateFieldGet(this, _VelocityTracker_samples, "f").length > 1 && __classPrivateFieldGet(this, _VelocityTracker_samples, "f")[0].t < cutoff) {
|
|
234
|
+
__classPrivateFieldGet(this, _VelocityTracker_samples, "f").shift();
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Computes the current velocity in px/s.
|
|
239
|
+
* @returns The vertical velocity in pixels per second.
|
|
240
|
+
*/
|
|
241
|
+
getVelocity() {
|
|
242
|
+
if (__classPrivateFieldGet(this, _VelocityTracker_samples, "f").length < 2) return 0;
|
|
243
|
+
const first = __classPrivateFieldGet(this, _VelocityTracker_samples, "f")[0];
|
|
244
|
+
const last = __classPrivateFieldGet(this, _VelocityTracker_samples, "f")[__classPrivateFieldGet(this, _VelocityTracker_samples, "f").length - 1];
|
|
245
|
+
const dy = last.y - first.y;
|
|
246
|
+
const dt = (last.t - first.t) / 1000;
|
|
247
|
+
return dt > 0 ? dy / dt : 0;
|
|
248
|
+
}
|
|
249
|
+
/** Clears all stored samples. */
|
|
250
|
+
reset() {
|
|
251
|
+
__classPrivateFieldGet(this, _VelocityTracker_samples, "f").length = 0;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
_VelocityTracker_samples = new WeakMap(), _VelocityTracker_windowMs = new WeakMap();
|
|
255
|
+
|
|
256
|
+
var _FocusController_instances, _a, _FocusController_touch, _FocusController_callback, _FocusController_filter, _FocusController_keyDownHandler, _FocusController_focusInHandler, _FocusController_focusOutHandler, _FocusController_touchStartHandler, _FocusController_touchEndHandler, _FocusController_hadKeydown, _FocusController_handleKeyDown, _FocusController_handleFocusIn, _FocusController_handleFocusOut;
|
|
257
|
+
/** A `ReactiveController` used to monitor the focused state of one or more elements. */
|
|
258
|
+
class FocusController extends MonitorControllerBase {
|
|
259
|
+
/**
|
|
260
|
+
* Initializes a new instance of this class.
|
|
261
|
+
* @param {ReactiveControllerHost & HTMLElement} host The host element to which this controller will be added.
|
|
262
|
+
* @param {FocusControllerOptions} options Options used to configure this controller.
|
|
263
|
+
*/
|
|
264
|
+
constructor(host, options) {
|
|
265
|
+
super(host, options);
|
|
266
|
+
_FocusController_instances.add(this);
|
|
267
|
+
/** @private */
|
|
268
|
+
_FocusController_touch.set(this, false);
|
|
269
|
+
/** @private */
|
|
270
|
+
_FocusController_callback.set(this, void 0);
|
|
271
|
+
/** @private */
|
|
272
|
+
_FocusController_filter.set(this, void 0);
|
|
273
|
+
/** @private */
|
|
274
|
+
_FocusController_keyDownHandler.set(this, e => __classPrivateFieldGet(this, _FocusController_instances, "m", _FocusController_handleKeyDown).call(this, e));
|
|
275
|
+
/** @private */
|
|
276
|
+
_FocusController_focusInHandler.set(this, e => __classPrivateFieldGet(this, _FocusController_instances, "m", _FocusController_handleFocusIn).call(this, e));
|
|
277
|
+
/** @private */
|
|
278
|
+
_FocusController_focusOutHandler.set(this, e => __classPrivateFieldGet(this, _FocusController_instances, "m", _FocusController_handleFocusOut).call(this, e));
|
|
279
|
+
/** @private */
|
|
280
|
+
_FocusController_touchStartHandler.set(this, () => __classPrivateFieldSet(this, _FocusController_touch, true, "f"));
|
|
281
|
+
/** @private */
|
|
282
|
+
_FocusController_touchEndHandler.set(this, () => __classPrivateFieldSet(this, _FocusController_touch, false, "f"));
|
|
283
|
+
__classPrivateFieldSet(this, _FocusController_callback, options.callback, "f");
|
|
284
|
+
__classPrivateFieldSet(this, _FocusController_filter, options.filter, "f");
|
|
285
|
+
}
|
|
286
|
+
/** @inheritdoc */
|
|
287
|
+
_observe(target) {
|
|
288
|
+
target.addEventListener("keydown", __classPrivateFieldGet(this, _FocusController_keyDownHandler, "f"));
|
|
289
|
+
target.addEventListener("focusin", __classPrivateFieldGet(this, _FocusController_focusInHandler, "f"));
|
|
290
|
+
target.addEventListener("focusout", __classPrivateFieldGet(this, _FocusController_focusOutHandler, "f"));
|
|
291
|
+
target.addEventListener("touchstart", __classPrivateFieldGet(this, _FocusController_touchStartHandler, "f"), {
|
|
292
|
+
passive: true
|
|
293
|
+
});
|
|
294
|
+
target.addEventListener("touchend", __classPrivateFieldGet(this, _FocusController_touchEndHandler, "f"));
|
|
295
|
+
target.addEventListener("touchcancel", __classPrivateFieldGet(this, _FocusController_touchEndHandler, "f"));
|
|
296
|
+
}
|
|
297
|
+
/** @inheritdoc */
|
|
298
|
+
_unobserve(target) {
|
|
299
|
+
target.removeEventListener("keydown", __classPrivateFieldGet(this, _FocusController_keyDownHandler, "f"));
|
|
300
|
+
target.removeEventListener("focusin", __classPrivateFieldGet(this, _FocusController_focusInHandler, "f"));
|
|
301
|
+
target.removeEventListener("focusout", __classPrivateFieldGet(this, _FocusController_focusOutHandler, "f"));
|
|
302
|
+
target.removeEventListener("touchstart", __classPrivateFieldGet(this, _FocusController_touchStartHandler, "f"));
|
|
303
|
+
target.removeEventListener("touchend", __classPrivateFieldGet(this, _FocusController_touchEndHandler, "f"));
|
|
304
|
+
target.removeEventListener("touchcancel", __classPrivateFieldGet(this, _FocusController_touchEndHandler, "f"));
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
_a = FocusController, _FocusController_touch = new WeakMap(), _FocusController_callback = new WeakMap(), _FocusController_filter = new WeakMap(), _FocusController_keyDownHandler = new WeakMap(), _FocusController_focusInHandler = new WeakMap(), _FocusController_focusOutHandler = new WeakMap(), _FocusController_touchStartHandler = new WeakMap(), _FocusController_touchEndHandler = new WeakMap(), _FocusController_instances = new WeakSet(), _FocusController_handleKeyDown = function _FocusController_handleKeyDown(e) {
|
|
308
|
+
if (__classPrivateFieldGet(this, _FocusController_filter, "f")?.call(this, e)) return;
|
|
309
|
+
const target = e.currentTarget;
|
|
310
|
+
if (target.matches(":focus-within")) {
|
|
311
|
+
__classPrivateFieldGet(this, _FocusController_instances, "m", _FocusController_handleFocusIn).call(this, e);
|
|
312
|
+
}
|
|
313
|
+
}, _FocusController_handleFocusIn = function _FocusController_handleFocusIn(e) {
|
|
314
|
+
if (__classPrivateFieldGet(this, _FocusController_filter, "f")?.call(this, e)) return;
|
|
315
|
+
if (__classPrivateFieldGet(this, _FocusController_touch, "f")) return;
|
|
316
|
+
const target = e.currentTarget;
|
|
317
|
+
__classPrivateFieldGet(this, _FocusController_callback, "f").call(this, true, target.matches(":focus-visible") || __classPrivateFieldGet(_a, _a, "f", _FocusController_hadKeydown) || forcedColorsActive(), target);
|
|
318
|
+
}, _FocusController_handleFocusOut = function _FocusController_handleFocusOut(e) {
|
|
319
|
+
if (__classPrivateFieldGet(this, _FocusController_filter, "f")?.call(this, e)) return;
|
|
320
|
+
if (__classPrivateFieldGet(this, _FocusController_touch, "f")) return;
|
|
321
|
+
__classPrivateFieldGet(this, _FocusController_callback, "f").call(this, false, false, e.currentTarget);
|
|
322
|
+
};
|
|
323
|
+
(() => {
|
|
324
|
+
if (typeof window !== "undefined") {
|
|
325
|
+
window.addEventListener("keydown", () => __classPrivateFieldSet(_a, _a, true, "f", _FocusController_hadKeydown), {
|
|
326
|
+
capture: true,
|
|
327
|
+
passive: true
|
|
328
|
+
});
|
|
329
|
+
window.addEventListener("pointerdown", () => __classPrivateFieldSet(_a, _a, false, "f", _FocusController_hadKeydown), {
|
|
330
|
+
capture: true
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
})();
|
|
334
|
+
/** @private */
|
|
335
|
+
_FocusController_hadKeydown = {
|
|
336
|
+
value: false
|
|
337
|
+
};
|
|
338
|
+
|
|
339
|
+
var _HoverController_instances, _HoverController_callback, _HoverController_startDelays, _HoverController_endDelays, _HoverController_pointerInHandler, _HoverController_pointerLeaveHandler, _HoverController_clearDelays, _HoverController_clearStartDelay, _HoverController_clearEndDelay, _HoverController_handlePointerEnter, _HoverController_handlePointerLeave;
|
|
340
|
+
/** A `ReactiveController` used to monitor the hover state of one or more elements. */
|
|
341
|
+
class HoverController extends MonitorControllerBase {
|
|
342
|
+
/**
|
|
343
|
+
* Initializes a new instance of this class.
|
|
344
|
+
* @param {ReactiveControllerHost & HTMLElement} host The host element to which this controller will be added.
|
|
345
|
+
* @param {HoverControllerOptions} options Options used to configure this controller.
|
|
346
|
+
*/
|
|
347
|
+
constructor(host, options) {
|
|
348
|
+
super(host, options);
|
|
349
|
+
_HoverController_instances.add(this);
|
|
350
|
+
/** @private */
|
|
351
|
+
_HoverController_callback.set(this, void 0);
|
|
352
|
+
/** @private */
|
|
353
|
+
_HoverController_startDelays.set(this, new Map());
|
|
354
|
+
/** @private */
|
|
355
|
+
_HoverController_endDelays.set(this, new Map());
|
|
356
|
+
/** @private */
|
|
357
|
+
_HoverController_pointerInHandler.set(this, e => __classPrivateFieldGet(this, _HoverController_instances, "m", _HoverController_handlePointerEnter).call(this, e));
|
|
358
|
+
/** @private */
|
|
359
|
+
_HoverController_pointerLeaveHandler.set(this, e => __classPrivateFieldGet(this, _HoverController_instances, "m", _HoverController_handlePointerLeave).call(this, e));
|
|
360
|
+
__classPrivateFieldSet(this, _HoverController_callback, options.callback, "f");
|
|
361
|
+
this.startDelay = options.startDelay ?? 0;
|
|
362
|
+
this.endDelay = options.endDelay ?? 0;
|
|
363
|
+
}
|
|
364
|
+
/** Clears any hover delays for all targets. */
|
|
365
|
+
clearDelays() {
|
|
366
|
+
for (const target of this.targets) {
|
|
367
|
+
__classPrivateFieldGet(this, _HoverController_instances, "m", _HoverController_clearDelays).call(this, target);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
/** @inheritdoc */
|
|
371
|
+
_observe(target) {
|
|
372
|
+
target.addEventListener("pointerenter", __classPrivateFieldGet(this, _HoverController_pointerInHandler, "f"));
|
|
373
|
+
target.addEventListener("pointerleave", __classPrivateFieldGet(this, _HoverController_pointerLeaveHandler, "f"));
|
|
374
|
+
target.addEventListener("touchend", __classPrivateFieldGet(this, _HoverController_pointerLeaveHandler, "f"));
|
|
375
|
+
}
|
|
376
|
+
/** @inheritdoc */
|
|
377
|
+
_unobserve(target) {
|
|
378
|
+
target.removeEventListener("pointerenter", __classPrivateFieldGet(this, _HoverController_pointerInHandler, "f"));
|
|
379
|
+
target.removeEventListener("pointerleave", __classPrivateFieldGet(this, _HoverController_pointerLeaveHandler, "f"));
|
|
380
|
+
target.removeEventListener("touchend", __classPrivateFieldGet(this, _HoverController_pointerLeaveHandler, "f"));
|
|
381
|
+
__classPrivateFieldGet(this, _HoverController_instances, "m", _HoverController_clearDelays).call(this, target);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
_HoverController_callback = new WeakMap(), _HoverController_startDelays = new WeakMap(), _HoverController_endDelays = new WeakMap(), _HoverController_pointerInHandler = new WeakMap(), _HoverController_pointerLeaveHandler = new WeakMap(), _HoverController_instances = new WeakSet(), _HoverController_clearDelays = function _HoverController_clearDelays(target) {
|
|
385
|
+
__classPrivateFieldGet(this, _HoverController_instances, "m", _HoverController_clearStartDelay).call(this, target);
|
|
386
|
+
__classPrivateFieldGet(this, _HoverController_instances, "m", _HoverController_clearEndDelay).call(this, target);
|
|
387
|
+
}, _HoverController_clearStartDelay = function _HoverController_clearStartDelay(target) {
|
|
388
|
+
if (__classPrivateFieldGet(this, _HoverController_startDelays, "f").has(target)) {
|
|
389
|
+
clearTimeout(__classPrivateFieldGet(this, _HoverController_startDelays, "f").get(target));
|
|
390
|
+
return __classPrivateFieldGet(this, _HoverController_startDelays, "f").delete(target);
|
|
391
|
+
}
|
|
392
|
+
return false;
|
|
393
|
+
}, _HoverController_clearEndDelay = function _HoverController_clearEndDelay(target) {
|
|
394
|
+
if (__classPrivateFieldGet(this, _HoverController_endDelays, "f").has(target)) {
|
|
395
|
+
clearTimeout(__classPrivateFieldGet(this, _HoverController_endDelays, "f").get(target));
|
|
396
|
+
return __classPrivateFieldGet(this, _HoverController_endDelays, "f").delete(target);
|
|
397
|
+
}
|
|
398
|
+
return false;
|
|
399
|
+
}, _HoverController_handlePointerEnter = function _HoverController_handlePointerEnter(e) {
|
|
400
|
+
const target = e.target;
|
|
401
|
+
// If there is a pending end delay, cancel it.
|
|
402
|
+
__classPrivateFieldGet(this, _HoverController_instances, "m", _HoverController_clearEndDelay).call(this, target);
|
|
403
|
+
// Otherwise, if there is a pending start delay, cancel it and start a new one.
|
|
404
|
+
if (this.startDelay > 0) {
|
|
405
|
+
__classPrivateFieldGet(this, _HoverController_instances, "m", _HoverController_clearStartDelay).call(this, target);
|
|
406
|
+
__classPrivateFieldGet(this, _HoverController_startDelays, "f").set(target, setTimeout(() => {
|
|
407
|
+
__classPrivateFieldGet(this, _HoverController_startDelays, "f").delete(target);
|
|
408
|
+
__classPrivateFieldGet(this, _HoverController_callback, "f").call(this, true, target);
|
|
409
|
+
}, this.startDelay));
|
|
410
|
+
} else {
|
|
411
|
+
// Otherwise, report the start.
|
|
412
|
+
__classPrivateFieldGet(this, _HoverController_callback, "f").call(this, true, target);
|
|
413
|
+
}
|
|
414
|
+
}, _HoverController_handlePointerLeave = function _HoverController_handlePointerLeave(e) {
|
|
415
|
+
const target = e.target;
|
|
416
|
+
// If there is a pending start delay, cancel it and do not report the end.
|
|
417
|
+
if (__classPrivateFieldGet(this, _HoverController_instances, "m", _HoverController_clearStartDelay).call(this, target)) return;
|
|
418
|
+
// Otherwise, if there is a pending end delay, cancel it and start a new one.
|
|
419
|
+
if (this.endDelay > 0) {
|
|
420
|
+
__classPrivateFieldGet(this, _HoverController_instances, "m", _HoverController_clearEndDelay).call(this, target);
|
|
421
|
+
__classPrivateFieldGet(this, _HoverController_endDelays, "f").set(target, setTimeout(() => {
|
|
422
|
+
__classPrivateFieldGet(this, _HoverController_endDelays, "f").delete(target);
|
|
423
|
+
__classPrivateFieldGet(this, _HoverController_callback, "f").call(this, false, target);
|
|
424
|
+
}, this.endDelay));
|
|
425
|
+
} else {
|
|
426
|
+
// Otherwise, report the end.
|
|
427
|
+
__classPrivateFieldGet(this, _HoverController_callback, "f").call(this, false, target);
|
|
428
|
+
}
|
|
429
|
+
};
|
|
430
|
+
|
|
431
|
+
var _InertController_host, _InertController_inerts;
|
|
432
|
+
/**
|
|
433
|
+
* A `ReactiveController` that provides safe, predictable inerting of background
|
|
434
|
+
* content for modal UI surfaces (dialogs, date pickers, fullscreen search views).
|
|
435
|
+
*/
|
|
436
|
+
class InertController {
|
|
437
|
+
constructor(host) {
|
|
438
|
+
/** @private */_InertController_host.set(this, void 0);
|
|
439
|
+
/** @private */
|
|
440
|
+
_InertController_inerts.set(this, new Array());
|
|
441
|
+
__classPrivateFieldSet(this, _InertController_host, host, "f");
|
|
442
|
+
host.addController(this);
|
|
443
|
+
}
|
|
444
|
+
/**
|
|
445
|
+
* Locks background content by applying inertness to all non‑modal elements,
|
|
446
|
+
* isolating the active surface from pointer and keyboard interaction.
|
|
447
|
+
*/
|
|
448
|
+
lock() {
|
|
449
|
+
this.unlock();
|
|
450
|
+
for (let current = __classPrivateFieldGet(this, _InertController_host, "f"); current.parentNode && current.parentNode !== document.documentElement; current = current.parentNode) {
|
|
451
|
+
for (const sibling of current.parentNode.children) {
|
|
452
|
+
if (sibling instanceof HTMLElement && sibling !== current && !sibling.inert) {
|
|
453
|
+
sibling.inert = true;
|
|
454
|
+
__classPrivateFieldGet(this, _InertController_inerts, "f").push(sibling);
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
/** Restores background interactivity by removing inertness previously applied during `lock()`. */
|
|
460
|
+
unlock() {
|
|
461
|
+
__classPrivateFieldGet(this, _InertController_inerts, "f").forEach(x => x.inert = false);
|
|
462
|
+
__classPrivateFieldGet(this, _InertController_inerts, "f").length = 0;
|
|
463
|
+
}
|
|
464
|
+
/** @inheritdoc */
|
|
465
|
+
hostDisconnected() {
|
|
466
|
+
this.unlock();
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
_InertController_host = new WeakMap(), _InertController_inerts = new WeakMap();
|
|
470
|
+
|
|
471
|
+
var _IntersectionController_callback, _IntersectionController_skipInitial, _IntersectionController_observer, _IntersectionController_unobservedUpdate;
|
|
472
|
+
/** A `ReactiveController` used to monitor changes in the intersection of a target element with an ancestor element. */
|
|
473
|
+
class IntersectionController extends MonitorControllerBase {
|
|
474
|
+
/**
|
|
475
|
+
* Initializes a new instance of the `IntersectionController` class.
|
|
476
|
+
* @param {ReactiveControllerHost & HTMLElement} host The host element to which this controller will be added.
|
|
477
|
+
* @param {IntersectionControllerOptions} options Options used to configure this controller.
|
|
478
|
+
*/
|
|
479
|
+
constructor(host, options) {
|
|
480
|
+
super(host, options);
|
|
481
|
+
/** @private */
|
|
482
|
+
_IntersectionController_callback.set(this, void 0);
|
|
483
|
+
/** @private */
|
|
484
|
+
_IntersectionController_skipInitial.set(this, false);
|
|
485
|
+
/** @private */
|
|
486
|
+
_IntersectionController_observer.set(this, void 0);
|
|
487
|
+
/** @private */
|
|
488
|
+
_IntersectionController_unobservedUpdate.set(this, true);
|
|
489
|
+
__classPrivateFieldSet(this, _IntersectionController_callback, options.callback, "f");
|
|
490
|
+
__classPrivateFieldSet(this, _IntersectionController_skipInitial, options.skipInitial ?? false, "f");
|
|
491
|
+
if (isServer) return;
|
|
492
|
+
if (!window.IntersectionObserver) {
|
|
493
|
+
console.warn("IntersectionController error: the browser does not support IntersectionObserver.");
|
|
494
|
+
return;
|
|
495
|
+
}
|
|
496
|
+
__classPrivateFieldSet(this, _IntersectionController_observer, new IntersectionObserver((entries, observer) => {
|
|
497
|
+
__classPrivateFieldGet(this, _IntersectionController_callback, "f").call(this, entries, observer);
|
|
498
|
+
}, options.init), "f");
|
|
499
|
+
}
|
|
500
|
+
/** @inheritdoc */
|
|
501
|
+
async hostUpdated() {
|
|
502
|
+
if (__classPrivateFieldGet(this, _IntersectionController_observer, "f") && !__classPrivateFieldGet(this, _IntersectionController_skipInitial, "f") && __classPrivateFieldGet(this, _IntersectionController_unobservedUpdate, "f")) {
|
|
503
|
+
__classPrivateFieldGet(this, _IntersectionController_callback, "f").call(this, [], __classPrivateFieldGet(this, _IntersectionController_observer, "f"));
|
|
504
|
+
}
|
|
505
|
+
__classPrivateFieldSet(this, _IntersectionController_unobservedUpdate, false, "f");
|
|
506
|
+
}
|
|
507
|
+
/** @inheritdoc */
|
|
508
|
+
_observe(target) {
|
|
509
|
+
__classPrivateFieldGet(this, _IntersectionController_observer, "f")?.observe(target);
|
|
510
|
+
__classPrivateFieldSet(this, _IntersectionController_unobservedUpdate, true, "f");
|
|
511
|
+
}
|
|
512
|
+
/** @inheritdoc */
|
|
513
|
+
_unobserve(target) {
|
|
514
|
+
__classPrivateFieldGet(this, _IntersectionController_observer, "f")?.unobserve(target);
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
_IntersectionController_callback = new WeakMap(), _IntersectionController_skipInitial = new WeakMap(), _IntersectionController_observer = new WeakMap(), _IntersectionController_unobservedUpdate = new WeakMap();
|
|
518
|
+
|
|
519
|
+
var _LongPressController_instances, _LongPressController_callback, _LongPressController_threshold, _LongPressController_pressedTargets, _LongPressController_pressedTimeouts, _LongPressController_touchStartHandler, _LongPressController_touchEndOrCancelHandler, _LongPressController_handleTouchStart, _LongPressController_handleTouchEndOrCancel;
|
|
520
|
+
/** A `ReactiveController` used to detect a long press gesture. */
|
|
521
|
+
class LongPressController extends MonitorControllerBase {
|
|
522
|
+
/**
|
|
523
|
+
* Initializes a new instance of this class.
|
|
524
|
+
* @param {ReactiveControllerHost & HTMLElement} host The host element to which this controller will be added.
|
|
525
|
+
* @param {LongPressControllerOptions} options Options used to configure this controller.
|
|
526
|
+
*/
|
|
527
|
+
constructor(host, options) {
|
|
528
|
+
super(host, options);
|
|
529
|
+
_LongPressController_instances.add(this);
|
|
530
|
+
/** @private */
|
|
531
|
+
_LongPressController_callback.set(this, void 0);
|
|
532
|
+
/** @private */
|
|
533
|
+
_LongPressController_threshold.set(this, void 0);
|
|
534
|
+
/** @private */
|
|
535
|
+
_LongPressController_pressedTargets.set(this, new Set());
|
|
536
|
+
/** @private */
|
|
537
|
+
_LongPressController_pressedTimeouts.set(this, new Map());
|
|
538
|
+
/** @private */
|
|
539
|
+
_LongPressController_touchStartHandler.set(this, e => __classPrivateFieldGet(this, _LongPressController_instances, "m", _LongPressController_handleTouchStart).call(this, e));
|
|
540
|
+
/** @private */
|
|
541
|
+
_LongPressController_touchEndOrCancelHandler.set(this, e => __classPrivateFieldGet(this, _LongPressController_instances, "m", _LongPressController_handleTouchEndOrCancel).call(this, e));
|
|
542
|
+
__classPrivateFieldSet(this, _LongPressController_callback, options.callback, "f");
|
|
543
|
+
__classPrivateFieldSet(this, _LongPressController_threshold, options.threshold ?? 500, "f");
|
|
544
|
+
}
|
|
545
|
+
/** @inheritdoc */
|
|
546
|
+
_observe(target) {
|
|
547
|
+
target.addEventListener("touchstart", __classPrivateFieldGet(this, _LongPressController_touchStartHandler, "f"), {
|
|
548
|
+
passive: true
|
|
549
|
+
});
|
|
550
|
+
target.addEventListener("touchend", __classPrivateFieldGet(this, _LongPressController_touchEndOrCancelHandler, "f"));
|
|
551
|
+
target.addEventListener("touchcancel", __classPrivateFieldGet(this, _LongPressController_touchEndOrCancelHandler, "f"));
|
|
552
|
+
}
|
|
553
|
+
/** @inheritdoc */
|
|
554
|
+
_unobserve(target) {
|
|
555
|
+
target.removeEventListener("touchstart", __classPrivateFieldGet(this, _LongPressController_touchStartHandler, "f"));
|
|
556
|
+
target.removeEventListener("touchend", __classPrivateFieldGet(this, _LongPressController_touchEndOrCancelHandler, "f"));
|
|
557
|
+
target.removeEventListener("touchcancel", __classPrivateFieldGet(this, _LongPressController_touchEndOrCancelHandler, "f"));
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
_LongPressController_callback = new WeakMap(), _LongPressController_threshold = new WeakMap(), _LongPressController_pressedTargets = new WeakMap(), _LongPressController_pressedTimeouts = new WeakMap(), _LongPressController_touchStartHandler = new WeakMap(), _LongPressController_touchEndOrCancelHandler = new WeakMap(), _LongPressController_instances = new WeakSet(), _LongPressController_handleTouchStart = function _LongPressController_handleTouchStart(e) {
|
|
561
|
+
if (e.currentTarget instanceof HTMLElement && this.isObserving(e.currentTarget)) {
|
|
562
|
+
const target = e.currentTarget;
|
|
563
|
+
__classPrivateFieldGet(this, _LongPressController_pressedTimeouts, "f").set(target, setTimeout(() => {
|
|
564
|
+
__classPrivateFieldGet(this, _LongPressController_pressedTargets, "f").add(target);
|
|
565
|
+
__classPrivateFieldGet(this, _LongPressController_pressedTimeouts, "f").delete(target);
|
|
566
|
+
__classPrivateFieldGet(this, _LongPressController_callback, "f").call(this, true, target);
|
|
567
|
+
}, __classPrivateFieldGet(this, _LongPressController_threshold, "f")));
|
|
568
|
+
}
|
|
569
|
+
}, _LongPressController_handleTouchEndOrCancel = function _LongPressController_handleTouchEndOrCancel(e) {
|
|
570
|
+
if (e.currentTarget instanceof HTMLElement && this.isObserving(e.currentTarget)) {
|
|
571
|
+
const target = e.currentTarget;
|
|
572
|
+
if (__classPrivateFieldGet(this, _LongPressController_pressedTargets, "f").has(target)) {
|
|
573
|
+
__classPrivateFieldGet(this, _LongPressController_callback, "f").call(this, false, target);
|
|
574
|
+
__classPrivateFieldGet(this, _LongPressController_pressedTargets, "f").delete(target);
|
|
575
|
+
}
|
|
576
|
+
if (__classPrivateFieldGet(this, _LongPressController_pressedTimeouts, "f").has(target)) {
|
|
577
|
+
clearTimeout(__classPrivateFieldGet(this, _LongPressController_pressedTimeouts, "f").get(target));
|
|
578
|
+
__classPrivateFieldGet(this, _LongPressController_pressedTimeouts, "f").delete(target);
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
};
|
|
582
|
+
|
|
583
|
+
var _MutationController_callback, _MutationController_skipInitial, _MutationController_config, _MutationController_observer, _MutationController_unobservedUpdate;
|
|
584
|
+
/**
|
|
585
|
+
* A `ReactiveController` that integrates a `MutationObserver` with an element's reactive update lifecycle
|
|
586
|
+
* to detect arbitrary changes to DOM, including nodes being added or removed and attributes changing.
|
|
587
|
+
*/
|
|
588
|
+
class MutationController extends MonitorControllerBase {
|
|
589
|
+
/**
|
|
590
|
+
* Initializes a new instance of the `MutationController` class.
|
|
591
|
+
* @param {ReactiveControllerHost & HTMLElement} host The host element to which this controller will be added.
|
|
592
|
+
* @param {MutationControllerOptions} options Options used to configure this controller.
|
|
593
|
+
*/
|
|
594
|
+
constructor(host, options) {
|
|
595
|
+
super(host, options);
|
|
596
|
+
/** @private */
|
|
597
|
+
_MutationController_callback.set(this, void 0);
|
|
598
|
+
/** @private */
|
|
599
|
+
_MutationController_skipInitial.set(this, false);
|
|
600
|
+
/** @private */
|
|
601
|
+
_MutationController_config.set(this, void 0);
|
|
602
|
+
/** @private */
|
|
603
|
+
_MutationController_observer.set(this, void 0);
|
|
604
|
+
/** @private */
|
|
605
|
+
_MutationController_unobservedUpdate.set(this, true);
|
|
606
|
+
__classPrivateFieldSet(this, _MutationController_callback, options.callback, "f");
|
|
607
|
+
__classPrivateFieldSet(this, _MutationController_skipInitial, options.skipInitial ?? false, "f");
|
|
608
|
+
__classPrivateFieldSet(this, _MutationController_config, options.config, "f");
|
|
609
|
+
if (isServer) return;
|
|
610
|
+
if (!window.MutationObserver) {
|
|
611
|
+
console.warn("MutationController error: the browser does not support MutationObserver.");
|
|
612
|
+
return;
|
|
613
|
+
}
|
|
614
|
+
__classPrivateFieldSet(this, _MutationController_observer, new MutationObserver((records, observer) => __classPrivateFieldGet(this, _MutationController_callback, "f").call(this, records, observer)), "f");
|
|
615
|
+
}
|
|
616
|
+
/** @inheritdoc */
|
|
617
|
+
async hostUpdated() {
|
|
618
|
+
if (__classPrivateFieldGet(this, _MutationController_observer, "f") && !__classPrivateFieldGet(this, _MutationController_skipInitial, "f") && __classPrivateFieldGet(this, _MutationController_unobservedUpdate, "f")) {
|
|
619
|
+
const records = __classPrivateFieldGet(this, _MutationController_observer, "f").takeRecords();
|
|
620
|
+
if (records.length > 0) {
|
|
621
|
+
__classPrivateFieldGet(this, _MutationController_callback, "f").call(this, records, __classPrivateFieldGet(this, _MutationController_observer, "f"));
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
__classPrivateFieldSet(this, _MutationController_unobservedUpdate, false, "f");
|
|
625
|
+
}
|
|
626
|
+
/** @inheritdoc */
|
|
627
|
+
hostDisconnected() {
|
|
628
|
+
super.hostDisconnected();
|
|
629
|
+
__classPrivateFieldGet(this, _MutationController_observer, "f")?.disconnect();
|
|
630
|
+
}
|
|
631
|
+
/** @inheritdoc */
|
|
632
|
+
_observe(target) {
|
|
633
|
+
__classPrivateFieldGet(this, _MutationController_observer, "f")?.observe(target, __classPrivateFieldGet(this, _MutationController_config, "f"));
|
|
634
|
+
__classPrivateFieldSet(this, _MutationController_unobservedUpdate, true, "f");
|
|
635
|
+
}
|
|
636
|
+
/** @inheritdoc */
|
|
637
|
+
_unobserve() {
|
|
638
|
+
__classPrivateFieldGet(this, _MutationController_observer, "f")?.disconnect();
|
|
639
|
+
for (const target of this.targets) {
|
|
640
|
+
__classPrivateFieldGet(this, _MutationController_observer, "f")?.observe(target, __classPrivateFieldGet(this, _MutationController_config, "f"));
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
_MutationController_callback = new WeakMap(), _MutationController_skipInitial = new WeakMap(), _MutationController_config = new WeakMap(), _MutationController_observer = new WeakMap(), _MutationController_unobservedUpdate = new WeakMap();
|
|
645
|
+
|
|
646
|
+
var _PressedController_instances, _PressedController_capture, _PressedController_callback, _PressedController_filter, _PressedController_isPressedKey, _PressedController_pressedTargets, _PressedController_minPressedDuration, _PressedController_pointerDownHandler, _PressedController_pointerUpHandler, _PressedController_touchEndHandler, _PressedController_keyDownHandler, _PressedController_keyUpHandler, _PressedController_handlePointerDown, _PressedController_handlePointerUp, _PressedController_handleTouchEnd, _PressedController_handleKeyDown, _PressedController_handleKeyUp, _PressedController_clearPressedTargets;
|
|
647
|
+
/** A `ReactiveController` used to monitor the pressed state of one or more elements. */
|
|
648
|
+
class PressedController extends MonitorControllerBase {
|
|
649
|
+
/**
|
|
650
|
+
* Initializes a new instance of this class.
|
|
651
|
+
* @param {ReactiveControllerHost & HTMLElement} host The host element to which this controller will be added.
|
|
652
|
+
* @param {PressedControllerOptions} options Options used to configure this controller.
|
|
653
|
+
*/
|
|
654
|
+
constructor(host, options) {
|
|
655
|
+
super(host, options);
|
|
656
|
+
_PressedController_instances.add(this);
|
|
657
|
+
/** @private */
|
|
658
|
+
_PressedController_capture.set(this, void 0);
|
|
659
|
+
/** @private */
|
|
660
|
+
_PressedController_callback.set(this, void 0);
|
|
661
|
+
/** @private */
|
|
662
|
+
_PressedController_filter.set(this, void 0);
|
|
663
|
+
/** @private */
|
|
664
|
+
_PressedController_isPressedKey.set(this, void 0);
|
|
665
|
+
/** @private */
|
|
666
|
+
_PressedController_pressedTargets.set(this, new Map());
|
|
667
|
+
/** @private */
|
|
668
|
+
_PressedController_minPressedDuration.set(this, void 0);
|
|
669
|
+
/** @private */
|
|
670
|
+
_PressedController_pointerDownHandler.set(this, e => __classPrivateFieldGet(this, _PressedController_instances, "m", _PressedController_handlePointerDown).call(this, e));
|
|
671
|
+
/** @private */
|
|
672
|
+
_PressedController_pointerUpHandler.set(this, e => __classPrivateFieldGet(this, _PressedController_instances, "m", _PressedController_handlePointerUp).call(this, e));
|
|
673
|
+
/** @private */
|
|
674
|
+
_PressedController_touchEndHandler.set(this, e => __classPrivateFieldGet(this, _PressedController_instances, "m", _PressedController_handleTouchEnd).call(this, e));
|
|
675
|
+
/** @private */
|
|
676
|
+
_PressedController_keyDownHandler.set(this, e => __classPrivateFieldGet(this, _PressedController_instances, "m", _PressedController_handleKeyDown).call(this, e));
|
|
677
|
+
/** @private */
|
|
678
|
+
_PressedController_keyUpHandler.set(this, e => __classPrivateFieldGet(this, _PressedController_instances, "m", _PressedController_handleKeyUp).call(this, e));
|
|
679
|
+
__classPrivateFieldSet(this, _PressedController_capture, options.capture, "f");
|
|
680
|
+
__classPrivateFieldSet(this, _PressedController_callback, options.callback, "f");
|
|
681
|
+
__classPrivateFieldSet(this, _PressedController_filter, options.filter, "f");
|
|
682
|
+
__classPrivateFieldSet(this, _PressedController_isPressedKey, options.isPressedKey, "f");
|
|
683
|
+
__classPrivateFieldSet(this, _PressedController_minPressedDuration, options.minPressedDuration ?? 0, "f");
|
|
684
|
+
}
|
|
685
|
+
/** @inheritdoc */
|
|
686
|
+
hostConnected() {
|
|
687
|
+
document.addEventListener("pointerup", __classPrivateFieldGet(this, _PressedController_pointerUpHandler, "f"), {
|
|
688
|
+
capture: __classPrivateFieldGet(this, _PressedController_capture, "f")
|
|
689
|
+
});
|
|
690
|
+
document.addEventListener("touchend", __classPrivateFieldGet(this, _PressedController_touchEndHandler, "f"), {
|
|
691
|
+
capture: __classPrivateFieldGet(this, _PressedController_capture, "f")
|
|
692
|
+
});
|
|
693
|
+
document.addEventListener("touchcancel", __classPrivateFieldGet(this, _PressedController_touchEndHandler, "f"), {
|
|
694
|
+
capture: __classPrivateFieldGet(this, _PressedController_capture, "f")
|
|
695
|
+
});
|
|
696
|
+
super.hostConnected();
|
|
697
|
+
}
|
|
698
|
+
/** @inheritdoc */
|
|
699
|
+
hostDisconnected() {
|
|
700
|
+
document.removeEventListener("pointerup", __classPrivateFieldGet(this, _PressedController_pointerUpHandler, "f"), {
|
|
701
|
+
capture: __classPrivateFieldGet(this, _PressedController_capture, "f")
|
|
702
|
+
});
|
|
703
|
+
document.removeEventListener("touchend", __classPrivateFieldGet(this, _PressedController_touchEndHandler, "f"), {
|
|
704
|
+
capture: __classPrivateFieldGet(this, _PressedController_capture, "f")
|
|
705
|
+
});
|
|
706
|
+
document.removeEventListener("touchcancel", __classPrivateFieldGet(this, _PressedController_touchEndHandler, "f"), {
|
|
707
|
+
capture: __classPrivateFieldGet(this, _PressedController_capture, "f")
|
|
708
|
+
});
|
|
709
|
+
super.hostDisconnected();
|
|
710
|
+
__classPrivateFieldGet(this, _PressedController_pressedTargets, "f").clear();
|
|
711
|
+
}
|
|
712
|
+
/** @inheritdoc */
|
|
713
|
+
_observe(target) {
|
|
714
|
+
target.addEventListener("pointerdown", __classPrivateFieldGet(this, _PressedController_pointerDownHandler, "f"), {
|
|
715
|
+
capture: __classPrivateFieldGet(this, _PressedController_capture, "f")
|
|
716
|
+
});
|
|
717
|
+
if (__classPrivateFieldGet(this, _PressedController_isPressedKey, "f")) {
|
|
718
|
+
target.addEventListener("keydown", __classPrivateFieldGet(this, _PressedController_keyDownHandler, "f"), {
|
|
719
|
+
capture: __classPrivateFieldGet(this, _PressedController_capture, "f")
|
|
720
|
+
});
|
|
721
|
+
target.addEventListener("keyup", __classPrivateFieldGet(this, _PressedController_keyUpHandler, "f"), {
|
|
722
|
+
capture: __classPrivateFieldGet(this, _PressedController_capture, "f")
|
|
723
|
+
});
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
/** @inheritdoc */
|
|
727
|
+
_unobserve(target) {
|
|
728
|
+
target.removeEventListener("pointerdown", __classPrivateFieldGet(this, _PressedController_pointerDownHandler, "f"), {
|
|
729
|
+
capture: __classPrivateFieldGet(this, _PressedController_capture, "f")
|
|
730
|
+
});
|
|
731
|
+
if (__classPrivateFieldGet(this, _PressedController_isPressedKey, "f")) {
|
|
732
|
+
target.removeEventListener("keydown", __classPrivateFieldGet(this, _PressedController_keyDownHandler, "f"), {
|
|
733
|
+
capture: __classPrivateFieldGet(this, _PressedController_capture, "f")
|
|
734
|
+
});
|
|
735
|
+
target.removeEventListener("keyup", __classPrivateFieldGet(this, _PressedController_keyUpHandler, "f"), {
|
|
736
|
+
capture: __classPrivateFieldGet(this, _PressedController_capture, "f")
|
|
737
|
+
});
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
_PressedController_capture = new WeakMap(), _PressedController_callback = new WeakMap(), _PressedController_filter = new WeakMap(), _PressedController_isPressedKey = new WeakMap(), _PressedController_pressedTargets = new WeakMap(), _PressedController_minPressedDuration = new WeakMap(), _PressedController_pointerDownHandler = new WeakMap(), _PressedController_pointerUpHandler = new WeakMap(), _PressedController_touchEndHandler = new WeakMap(), _PressedController_keyDownHandler = new WeakMap(), _PressedController_keyUpHandler = new WeakMap(), _PressedController_instances = new WeakSet(), _PressedController_handlePointerDown = function _PressedController_handlePointerDown(e) {
|
|
742
|
+
if (__classPrivateFieldGet(this, _PressedController_filter, "f")?.call(this, e)) return;
|
|
743
|
+
if (e.pointerType === "mouse" && e.button > 1) return;
|
|
744
|
+
for (const target of e.composedPath()) {
|
|
745
|
+
if (target instanceof HTMLElement && this.isObserving(target)) {
|
|
746
|
+
if (!__classPrivateFieldGet(this, _PressedController_pressedTargets, "f").has(target)) {
|
|
747
|
+
__classPrivateFieldGet(this, _PressedController_pressedTargets, "f").set(target, performance.now());
|
|
748
|
+
__classPrivateFieldGet(this, _PressedController_callback, "f").call(this, true, {
|
|
749
|
+
x: e.x,
|
|
750
|
+
y: e.y
|
|
751
|
+
}, target);
|
|
752
|
+
}
|
|
753
|
+
break;
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
}, _PressedController_handlePointerUp = function _PressedController_handlePointerUp(e) {
|
|
757
|
+
if (e.pointerType === "mouse" && e.button > 1) return;
|
|
758
|
+
__classPrivateFieldGet(this, _PressedController_instances, "m", _PressedController_clearPressedTargets).call(this, e.x, e.y);
|
|
759
|
+
}, _PressedController_handleTouchEnd = function _PressedController_handleTouchEnd(e) {
|
|
760
|
+
__classPrivateFieldGet(this, _PressedController_instances, "m", _PressedController_clearPressedTargets).call(this, e.changedTouches[0]?.clientX ?? 0, e.changedTouches[0]?.clientY ?? 0);
|
|
761
|
+
}, _PressedController_handleKeyDown = function _PressedController_handleKeyDown(e) {
|
|
762
|
+
if (__classPrivateFieldGet(this, _PressedController_filter, "f")?.call(this, e)) return;
|
|
763
|
+
if (e.target !== e.currentTarget) return;
|
|
764
|
+
const target = e.currentTarget;
|
|
765
|
+
if (__classPrivateFieldGet(this, _PressedController_isPressedKey, "f")?.call(this, e.key)) {
|
|
766
|
+
if (e.key === " ") {
|
|
767
|
+
e.preventDefault();
|
|
768
|
+
}
|
|
769
|
+
if (!__classPrivateFieldGet(this, _PressedController_pressedTargets, "f").has(target)) {
|
|
770
|
+
__classPrivateFieldGet(this, _PressedController_pressedTargets, "f").set(target, performance.now());
|
|
771
|
+
const bounds = target.getBoundingClientRect();
|
|
772
|
+
__classPrivateFieldGet(this, _PressedController_callback, "f").call(this, true, {
|
|
773
|
+
x: bounds.x + bounds.width / 2,
|
|
774
|
+
y: bounds.y + bounds.height / 2
|
|
775
|
+
}, target);
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
}, _PressedController_handleKeyUp = function _PressedController_handleKeyUp(e) {
|
|
779
|
+
const target = e.target;
|
|
780
|
+
if (__classPrivateFieldGet(this, _PressedController_pressedTargets, "f").has(target) && __classPrivateFieldGet(this, _PressedController_isPressedKey, "f")?.call(this, e.key)) {
|
|
781
|
+
const remainingTime = __classPrivateFieldGet(this, _PressedController_minPressedDuration, "f") - (performance.now() - __classPrivateFieldGet(this, _PressedController_pressedTargets, "f").get(target));
|
|
782
|
+
const bounds = target.getBoundingClientRect();
|
|
783
|
+
if (remainingTime > 0) {
|
|
784
|
+
setTimeout(() => {
|
|
785
|
+
__classPrivateFieldGet(this, _PressedController_pressedTargets, "f").delete(target);
|
|
786
|
+
__classPrivateFieldGet(this, _PressedController_callback, "f").call(this, false, {
|
|
787
|
+
x: bounds.x + bounds.width / 2,
|
|
788
|
+
y: bounds.y + bounds.height / 2
|
|
789
|
+
}, target);
|
|
790
|
+
}, remainingTime);
|
|
791
|
+
} else {
|
|
792
|
+
__classPrivateFieldGet(this, _PressedController_pressedTargets, "f").delete(target);
|
|
793
|
+
__classPrivateFieldGet(this, _PressedController_callback, "f").call(this, false, {
|
|
794
|
+
x: bounds.x + bounds.width / 2,
|
|
795
|
+
y: bounds.y + bounds.height / 2
|
|
796
|
+
}, target);
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
}, _PressedController_clearPressedTargets = function _PressedController_clearPressedTargets(x, y) {
|
|
800
|
+
for (const target of __classPrivateFieldGet(this, _PressedController_pressedTargets, "f")) {
|
|
801
|
+
const remainingTime = __classPrivateFieldGet(this, _PressedController_minPressedDuration, "f") - (performance.now() - target[1]);
|
|
802
|
+
if (remainingTime > 0) {
|
|
803
|
+
setTimeout(() => {
|
|
804
|
+
__classPrivateFieldGet(this, _PressedController_pressedTargets, "f").delete(target[0]);
|
|
805
|
+
__classPrivateFieldGet(this, _PressedController_callback, "f").call(this, false, {
|
|
806
|
+
x,
|
|
807
|
+
y
|
|
808
|
+
}, target[0]);
|
|
809
|
+
}, remainingTime);
|
|
810
|
+
} else {
|
|
811
|
+
__classPrivateFieldGet(this, _PressedController_pressedTargets, "f").delete(target[0]);
|
|
812
|
+
__classPrivateFieldGet(this, _PressedController_callback, "f").call(this, false, {
|
|
813
|
+
x,
|
|
814
|
+
y
|
|
815
|
+
}, target[0]);
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
};
|
|
819
|
+
|
|
820
|
+
var _ResizeController_callback, _ResizeController_skipInitial, _ResizeController_config, _ResizeController_observer, _ResizeController_unobservedUpdate;
|
|
821
|
+
/** A `ReactiveController` used to monitor when an element is resized. */
|
|
822
|
+
class ResizeController extends MonitorControllerBase {
|
|
823
|
+
/**
|
|
824
|
+
* Initializes a new instance of the `ResizeController` class.
|
|
825
|
+
* @param {ReactiveControllerHost & HTMLElement} host The host element to which this controller will be added.
|
|
826
|
+
* @param {ResizeControllerOptions} options Options used to configure this controller.
|
|
827
|
+
*/
|
|
828
|
+
constructor(host, options) {
|
|
829
|
+
super(host, options);
|
|
830
|
+
/** @private */
|
|
831
|
+
_ResizeController_callback.set(this, void 0);
|
|
832
|
+
/** @private */
|
|
833
|
+
_ResizeController_skipInitial.set(this, void 0);
|
|
834
|
+
/** @private */
|
|
835
|
+
_ResizeController_config.set(this, void 0);
|
|
836
|
+
/** @private */
|
|
837
|
+
_ResizeController_observer.set(this, void 0);
|
|
838
|
+
/** @private */
|
|
839
|
+
_ResizeController_unobservedUpdate.set(this, true);
|
|
840
|
+
__classPrivateFieldSet(this, _ResizeController_callback, options.callback, "f");
|
|
841
|
+
__classPrivateFieldSet(this, _ResizeController_skipInitial, options.skipInitial ?? false, "f");
|
|
842
|
+
__classPrivateFieldSet(this, _ResizeController_config, options.config, "f");
|
|
843
|
+
if (isServer) return;
|
|
844
|
+
if (!window.ResizeObserver) {
|
|
845
|
+
console.warn("ResizeController error: the browser does not support ResizeObserver.");
|
|
846
|
+
return;
|
|
847
|
+
}
|
|
848
|
+
__classPrivateFieldSet(this, _ResizeController_observer, new ResizeObserver((entries, observer) => __classPrivateFieldGet(this, _ResizeController_callback, "f").call(this, entries, observer)), "f");
|
|
849
|
+
}
|
|
850
|
+
/** @inheritdoc */
|
|
851
|
+
async hostUpdated() {
|
|
852
|
+
if (__classPrivateFieldGet(this, _ResizeController_observer, "f") && !__classPrivateFieldGet(this, _ResizeController_skipInitial, "f") && __classPrivateFieldGet(this, _ResizeController_unobservedUpdate, "f")) {
|
|
853
|
+
__classPrivateFieldGet(this, _ResizeController_callback, "f").call(this, [], __classPrivateFieldGet(this, _ResizeController_observer, "f"));
|
|
854
|
+
}
|
|
855
|
+
__classPrivateFieldSet(this, _ResizeController_unobservedUpdate, false, "f");
|
|
856
|
+
}
|
|
857
|
+
/** @inheritdoc */
|
|
858
|
+
_observe(target) {
|
|
859
|
+
__classPrivateFieldGet(this, _ResizeController_observer, "f")?.observe(target, __classPrivateFieldGet(this, _ResizeController_config, "f"));
|
|
860
|
+
__classPrivateFieldSet(this, _ResizeController_unobservedUpdate, true, "f");
|
|
861
|
+
}
|
|
862
|
+
/** @inheritdoc */
|
|
863
|
+
_unobserve(target) {
|
|
864
|
+
__classPrivateFieldGet(this, _ResizeController_observer, "f")?.unobserve(target);
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
_ResizeController_callback = new WeakMap(), _ResizeController_skipInitial = new WeakMap(), _ResizeController_config = new WeakMap(), _ResizeController_observer = new WeakMap(), _ResizeController_unobservedUpdate = new WeakMap();
|
|
868
|
+
|
|
869
|
+
/**
|
|
870
|
+
* Class decorator factory that defines the decorated class as a custom element.
|
|
871
|
+
*
|
|
872
|
+
* ```js
|
|
873
|
+
* @customElement('my-element')
|
|
874
|
+
* class MyElement extends LitElement {
|
|
875
|
+
* render() {
|
|
876
|
+
* return html``;
|
|
877
|
+
* }
|
|
878
|
+
* }
|
|
879
|
+
* ```
|
|
880
|
+
* @param {string} tagName The tag name of the custom element to define.
|
|
881
|
+
*/
|
|
882
|
+
const customElement = tagName => (classOrTarget, context) => {
|
|
883
|
+
const define = () => {
|
|
884
|
+
if (typeof window !== "undefined" && !customElements.get(tagName)) {
|
|
885
|
+
customElements.define(tagName, classOrTarget);
|
|
886
|
+
}
|
|
887
|
+
};
|
|
888
|
+
if (context) {
|
|
889
|
+
context.addInitializer(define);
|
|
890
|
+
} else {
|
|
891
|
+
define();
|
|
892
|
+
}
|
|
893
|
+
};
|
|
894
|
+
|
|
895
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
896
|
+
/**
|
|
897
|
+
* A decorator that runs a function once after a given "cooldown" period.
|
|
898
|
+
* @param {number} timeout The timeout, in milliseconds, after which the function is invoked.
|
|
899
|
+
* @returns {MethodDecorator} The decorator that runs a function once after a given "cooldown" period.
|
|
900
|
+
*/
|
|
901
|
+
function debounce(timeout) {
|
|
902
|
+
const _id = Symbol("_id");
|
|
903
|
+
return (_, __, descriptor) => {
|
|
904
|
+
const orig = descriptor.value;
|
|
905
|
+
descriptor.value = function (...args) {
|
|
906
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
907
|
+
const self = this;
|
|
908
|
+
clearTimeout(self[_id]);
|
|
909
|
+
self[_id] = setTimeout(() => orig.apply(this, args), timeout);
|
|
910
|
+
};
|
|
911
|
+
return descriptor;
|
|
912
|
+
};
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
var _ScrollController_instances, _ScrollController_debounce, _ScrollController_callback, _ScrollController_scrollHandler, _ScrollController_scrollContainers, _ScrollController_getShadowScrollContainer, _ScrollController_isScrollable, _ScrollController_getScrollContainers, _ScrollController_handleScroll;
|
|
916
|
+
/** A `ReactiveController` used to monitor when a scroll event is emitted from a scrollable ancestor. */
|
|
917
|
+
class ScrollController extends MonitorControllerBase {
|
|
918
|
+
/**
|
|
919
|
+
* Initializes a new instance of the `ScrollController` class.
|
|
920
|
+
* @param {ReactiveControllerHost & HTMLElement} host The host element to which this controller will be added.
|
|
921
|
+
* @param {ScrollControllerOptions} options Options used to configure this controller.
|
|
922
|
+
*/
|
|
923
|
+
constructor(host, options) {
|
|
924
|
+
super(host, options);
|
|
925
|
+
_ScrollController_instances.add(this);
|
|
926
|
+
/** @private */
|
|
927
|
+
_ScrollController_debounce.set(this, void 0);
|
|
928
|
+
/** @private */
|
|
929
|
+
_ScrollController_callback.set(this, void 0);
|
|
930
|
+
/** @private */
|
|
931
|
+
_ScrollController_scrollHandler.set(this, e => __classPrivateFieldGet(this, _ScrollController_instances, "m", _ScrollController_handleScroll).call(this, e));
|
|
932
|
+
/** @private */
|
|
933
|
+
_ScrollController_scrollContainers.set(this, new Map());
|
|
934
|
+
__classPrivateFieldSet(this, _ScrollController_debounce, options.debounce === true, "f");
|
|
935
|
+
__classPrivateFieldSet(this, _ScrollController_callback, options.callback, "f");
|
|
936
|
+
}
|
|
937
|
+
/**
|
|
938
|
+
* Returns the scrollable ancestors for a target element currently being observed by this controller.
|
|
939
|
+
* @param target The element whose scroll containers are currently being observed.
|
|
940
|
+
* @returns {Element[] | undefined} The scrollable ancestors, or `undefined` if `target` is not being observed.
|
|
941
|
+
*/
|
|
942
|
+
getScrollContainers(target) {
|
|
943
|
+
return __classPrivateFieldGet(this, _ScrollController_scrollContainers, "f").get(target);
|
|
944
|
+
}
|
|
945
|
+
/** @inheritdoc */
|
|
946
|
+
_observe(target) {
|
|
947
|
+
const scrollableAncestors = __classPrivateFieldGet(this, _ScrollController_instances, "m", _ScrollController_getScrollContainers).call(this, target);
|
|
948
|
+
if (scrollableAncestors.length > 0) {
|
|
949
|
+
__classPrivateFieldGet(this, _ScrollController_scrollContainers, "f").set(target, scrollableAncestors);
|
|
950
|
+
for (const ancestor of scrollableAncestors) {
|
|
951
|
+
(ancestor === document.documentElement ? document : ancestor).addEventListener("scroll", __classPrivateFieldGet(this, _ScrollController_scrollHandler, "f"), {
|
|
952
|
+
passive: true
|
|
953
|
+
});
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
/** @inheritdoc */
|
|
958
|
+
_unobserve(target) {
|
|
959
|
+
if (__classPrivateFieldGet(this, _ScrollController_scrollContainers, "f").has(target)) {
|
|
960
|
+
for (const ancestor of __classPrivateFieldGet(this, _ScrollController_scrollContainers, "f").get(target)) {
|
|
961
|
+
(ancestor === document.documentElement ? document : ancestor).removeEventListener("scroll", __classPrivateFieldGet(this, _ScrollController_scrollHandler, "f"));
|
|
962
|
+
}
|
|
963
|
+
__classPrivateFieldGet(this, _ScrollController_scrollContainers, "f").delete(target);
|
|
964
|
+
}
|
|
965
|
+
}
|
|
966
|
+
/** @private */
|
|
967
|
+
_debounceCallback(target) {
|
|
968
|
+
__classPrivateFieldGet(this, _ScrollController_callback, "f").call(this, target);
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
_ScrollController_debounce = new WeakMap(), _ScrollController_callback = new WeakMap(), _ScrollController_scrollHandler = new WeakMap(), _ScrollController_scrollContainers = new WeakMap(), _ScrollController_instances = new WeakSet(), _ScrollController_getShadowScrollContainer = function _ScrollController_getShadowScrollContainer(element) {
|
|
972
|
+
const root = element.shadowRoot;
|
|
973
|
+
if (!root) return null;
|
|
974
|
+
const walker = document.createTreeWalker(root, NodeFilter.SHOW_ELEMENT);
|
|
975
|
+
let node = walker.currentNode;
|
|
976
|
+
while (node) {
|
|
977
|
+
if (node instanceof Element && __classPrivateFieldGet(this, _ScrollController_instances, "m", _ScrollController_isScrollable).call(this, node)) return node;
|
|
978
|
+
node = walker.nextNode();
|
|
979
|
+
}
|
|
980
|
+
return null;
|
|
981
|
+
}, _ScrollController_isScrollable = function _ScrollController_isScrollable(element) {
|
|
982
|
+
const style = getComputedStyle(element);
|
|
983
|
+
return /(auto|scroll)/.test(style.overflow + style.overflowY + style.overflowX);
|
|
984
|
+
}, _ScrollController_getScrollContainers = function _ScrollController_getScrollContainers(element) {
|
|
985
|
+
const ancestors = new Array();
|
|
986
|
+
const shadowScrollContainer = __classPrivateFieldGet(this, _ScrollController_instances, "m", _ScrollController_getShadowScrollContainer).call(this, element);
|
|
987
|
+
if (shadowScrollContainer) {
|
|
988
|
+
ancestors.push(shadowScrollContainer);
|
|
989
|
+
}
|
|
990
|
+
let ancestor = element;
|
|
991
|
+
while (ancestor) {
|
|
992
|
+
if (__classPrivateFieldGet(this, _ScrollController_instances, "m", _ScrollController_isScrollable).call(this, ancestor)) {
|
|
993
|
+
ancestors.push(ancestor);
|
|
994
|
+
}
|
|
995
|
+
ancestor = ancestor.parentElement;
|
|
996
|
+
}
|
|
997
|
+
return ancestors;
|
|
998
|
+
}, _ScrollController_handleScroll = function _ScrollController_handleScroll(e) {
|
|
999
|
+
const target = e.target === document ? document.documentElement : e.target;
|
|
1000
|
+
if (__classPrivateFieldGet(this, _ScrollController_debounce, "f")) {
|
|
1001
|
+
this._debounceCallback(target);
|
|
1002
|
+
} else {
|
|
1003
|
+
__classPrivateFieldGet(this, _ScrollController_callback, "f").call(this, target);
|
|
1004
|
+
}
|
|
1005
|
+
};
|
|
1006
|
+
__decorate([debounce(40)], ScrollController.prototype, "_debounceCallback", null);
|
|
1007
|
+
|
|
1008
|
+
var _ScrollLockController_instances, _ScrollLockController_locked, _ScrollLockController_scrollTop, _ScrollLockController_scrollLeft, _ScrollLockController_previousOverflow, _ScrollLockController_previousScrollbarGutter, _ScrollLockController_isVerticallyScrollable;
|
|
1009
|
+
/**
|
|
1010
|
+
* A `ReactiveController` that provides safe, predictable scroll locking for modal UI
|
|
1011
|
+
* surfaces (dialogs, bottom sheets, overlays).
|
|
1012
|
+
*/
|
|
1013
|
+
class ScrollLockController {
|
|
1014
|
+
constructor(host) {
|
|
1015
|
+
_ScrollLockController_instances.add(this);
|
|
1016
|
+
/** @private */
|
|
1017
|
+
_ScrollLockController_locked.set(this, false);
|
|
1018
|
+
/** @private */
|
|
1019
|
+
_ScrollLockController_scrollTop.set(this, 0);
|
|
1020
|
+
/** @private */
|
|
1021
|
+
_ScrollLockController_scrollLeft.set(this, 0);
|
|
1022
|
+
/** @private */
|
|
1023
|
+
_ScrollLockController_previousOverflow.set(this, "");
|
|
1024
|
+
/** @private */
|
|
1025
|
+
_ScrollLockController_previousScrollbarGutter.set(this, "");
|
|
1026
|
+
host.addController(this);
|
|
1027
|
+
}
|
|
1028
|
+
/** Locks document scrolling only if scroll actually exists. */
|
|
1029
|
+
lock() {
|
|
1030
|
+
if (__classPrivateFieldGet(this, _ScrollLockController_locked, "f")) return;
|
|
1031
|
+
__classPrivateFieldSet(this, _ScrollLockController_locked, true, "f");
|
|
1032
|
+
// Save scroll position
|
|
1033
|
+
__classPrivateFieldSet(this, _ScrollLockController_scrollTop, window.scrollY, "f");
|
|
1034
|
+
__classPrivateFieldSet(this, _ScrollLockController_scrollLeft, window.scrollX, "f");
|
|
1035
|
+
// Save existing inline styles
|
|
1036
|
+
__classPrivateFieldSet(this, _ScrollLockController_previousOverflow, document.documentElement.style.overflow, "f");
|
|
1037
|
+
__classPrivateFieldSet(this, _ScrollLockController_previousScrollbarGutter, document.documentElement.style.scrollbarGutter, "f");
|
|
1038
|
+
// Only apply gutter if vertical scroll exists
|
|
1039
|
+
if (__classPrivateFieldGet(this, _ScrollLockController_instances, "m", _ScrollLockController_isVerticallyScrollable).call(this)) {
|
|
1040
|
+
document.documentElement.style.scrollbarGutter = "stable";
|
|
1041
|
+
}
|
|
1042
|
+
// Lock scroll
|
|
1043
|
+
document.documentElement.style.overflow = "hidden";
|
|
1044
|
+
// Freeze scroll position
|
|
1045
|
+
window.scrollTo(__classPrivateFieldGet(this, _ScrollLockController_scrollLeft, "f"), __classPrivateFieldGet(this, _ScrollLockController_scrollTop, "f"));
|
|
1046
|
+
}
|
|
1047
|
+
/** Unlocks document scrolling and restores the previous state. */
|
|
1048
|
+
unlock() {
|
|
1049
|
+
if (!__classPrivateFieldGet(this, _ScrollLockController_locked, "f")) return;
|
|
1050
|
+
__classPrivateFieldSet(this, _ScrollLockController_locked, false, "f");
|
|
1051
|
+
// Restore previous inline styles
|
|
1052
|
+
document.documentElement.style.overflow = __classPrivateFieldGet(this, _ScrollLockController_previousOverflow, "f");
|
|
1053
|
+
document.documentElement.style.scrollbarGutter = __classPrivateFieldGet(this, _ScrollLockController_previousScrollbarGutter, "f");
|
|
1054
|
+
// Restore scroll position
|
|
1055
|
+
window.scrollTo(__classPrivateFieldGet(this, _ScrollLockController_scrollLeft, "f"), __classPrivateFieldGet(this, _ScrollLockController_scrollTop, "f"));
|
|
1056
|
+
}
|
|
1057
|
+
/** @inheritdoc */
|
|
1058
|
+
hostDisconnected() {
|
|
1059
|
+
this.unlock();
|
|
1060
|
+
}
|
|
1061
|
+
}
|
|
1062
|
+
_ScrollLockController_locked = new WeakMap(), _ScrollLockController_scrollTop = new WeakMap(), _ScrollLockController_scrollLeft = new WeakMap(), _ScrollLockController_previousOverflow = new WeakMap(), _ScrollLockController_previousScrollbarGutter = new WeakMap(), _ScrollLockController_instances = new WeakSet(), _ScrollLockController_isVerticallyScrollable = function _ScrollLockController_isVerticallyScrollable() {
|
|
1063
|
+
return document.documentElement.scrollHeight > document.documentElement.clientHeight;
|
|
1064
|
+
};
|
|
1065
|
+
|
|
1066
|
+
/** Converts a time string (24h "HH:mm" or 12h "h:mm am/pm") to and from a { hours, minutes } object. */
|
|
1067
|
+
const timeConverter = {
|
|
1068
|
+
fromAttribute(value) {
|
|
1069
|
+
if (!value) return null;
|
|
1070
|
+
value = value.trim().toLowerCase();
|
|
1071
|
+
// 24‑hour: "HH:mm"
|
|
1072
|
+
let m = /^([01]\d|2[0-3]):([0-5]\d)$/.exec(value);
|
|
1073
|
+
if (m) {
|
|
1074
|
+
return {
|
|
1075
|
+
hour: Number(m[1]),
|
|
1076
|
+
minute: Number(m[2])
|
|
1077
|
+
};
|
|
1078
|
+
}
|
|
1079
|
+
// 12‑hour: "h:mm am" / "h:mm pm"
|
|
1080
|
+
m = /^(\d{1,2}):([0-5]\d)\s*(am|pm)$/.exec(value);
|
|
1081
|
+
if (m) {
|
|
1082
|
+
const h = Number(m[1]);
|
|
1083
|
+
const min = Number(m[2]);
|
|
1084
|
+
const period = m[3];
|
|
1085
|
+
if (h < 1 || h > 12) return null;
|
|
1086
|
+
// convert to 24‑hour
|
|
1087
|
+
const base = h % 12; // 12 → 0
|
|
1088
|
+
const hour = period === "pm" ? base + 12 : base;
|
|
1089
|
+
return {
|
|
1090
|
+
hour,
|
|
1091
|
+
minute: min
|
|
1092
|
+
};
|
|
1093
|
+
}
|
|
1094
|
+
return null;
|
|
1095
|
+
},
|
|
1096
|
+
toAttribute(value) {
|
|
1097
|
+
if (!value) return null;
|
|
1098
|
+
const hh = String(value.hour).padStart(2, "0");
|
|
1099
|
+
const mm = String(value.minute).padStart(2, "0");
|
|
1100
|
+
return `${hh}:${mm}`; // always serialize as 24‑hour
|
|
1101
|
+
}
|
|
1102
|
+
};
|
|
1103
|
+
|
|
1104
|
+
const important = "important";
|
|
1105
|
+
// The leading space is important
|
|
1106
|
+
const importantFlag = " !" + important;
|
|
1107
|
+
// How many characters to remove from a value, as a negative number
|
|
1108
|
+
const flagTrim = 0 - importantFlag.length;
|
|
1109
|
+
class SafeStyleMapDirective extends Directive {
|
|
1110
|
+
constructor(partInfo) {
|
|
1111
|
+
super(partInfo);
|
|
1112
|
+
if (partInfo.type !== PartType.ATTRIBUTE || partInfo.name !== "style" || partInfo.strings?.length > 2) {
|
|
1113
|
+
throw new Error("The `styleMap` directive must be used in the `style` attribute " + "and must be the only part in the attribute.");
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
1116
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1117
|
+
render(_) {
|
|
1118
|
+
return nothing;
|
|
1119
|
+
}
|
|
1120
|
+
update(part, [styleInfo]) {
|
|
1121
|
+
const {
|
|
1122
|
+
style
|
|
1123
|
+
} = part.element;
|
|
1124
|
+
if (this._previousStyleProperties === undefined) {
|
|
1125
|
+
this._previousStyleProperties = new Set(Object.keys(styleInfo));
|
|
1126
|
+
}
|
|
1127
|
+
// Remove old properties that no longer exist in styleInfo
|
|
1128
|
+
for (const name of this._previousStyleProperties) {
|
|
1129
|
+
// If the name isn't in styleInfo or it's null/undefined
|
|
1130
|
+
if (styleInfo[name] == null) {
|
|
1131
|
+
this._previousStyleProperties.delete(name);
|
|
1132
|
+
if (name.includes("-")) {
|
|
1133
|
+
style.removeProperty(name);
|
|
1134
|
+
} else {
|
|
1135
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1136
|
+
style[name] = null;
|
|
1137
|
+
}
|
|
1138
|
+
}
|
|
1139
|
+
}
|
|
1140
|
+
// Add or update properties
|
|
1141
|
+
for (const name in styleInfo) {
|
|
1142
|
+
const value = styleInfo[name];
|
|
1143
|
+
if (value != null) {
|
|
1144
|
+
this._previousStyleProperties.add(name);
|
|
1145
|
+
const isImportant = typeof value === "string" && value.endsWith(importantFlag);
|
|
1146
|
+
if (name.includes("-") || isImportant) {
|
|
1147
|
+
style.setProperty(name, isImportant ? value.slice(0, flagTrim) : value, isImportant ? important : "");
|
|
1148
|
+
} else {
|
|
1149
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1150
|
+
style[name] = value;
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1153
|
+
}
|
|
1154
|
+
return noChange;
|
|
1155
|
+
}
|
|
1156
|
+
}
|
|
1157
|
+
/**
|
|
1158
|
+
* A directive that applies CSS properties to an element.
|
|
1159
|
+
*
|
|
1160
|
+
* `safeStyleMap` can only be used in the `style` attribute and must be the only
|
|
1161
|
+
* expression in the attribute. It takes the property names in the
|
|
1162
|
+
* {@link StyleInfo styleInfo} object and adds the properties to the inline
|
|
1163
|
+
* style of the element.
|
|
1164
|
+
*
|
|
1165
|
+
* Property names with dashes (`-`) are assumed to be valid CSS
|
|
1166
|
+
* property names and set on the element's style object using `setProperty()`.
|
|
1167
|
+
* Names without dashes are assumed to be camelCased JavaScript property names
|
|
1168
|
+
* and set on the element's style object using property assignment, allowing the
|
|
1169
|
+
* style object to translate JavaScript-style names to CSS property names.
|
|
1170
|
+
*
|
|
1171
|
+
* For example `safeStyleMap({backgroundColor: 'red', 'border-top': '5px', '--size':
|
|
1172
|
+
* '0'})` sets the `background-color`, `border-top` and `--size` properties.
|
|
1173
|
+
*
|
|
1174
|
+
* @param styleInfo
|
|
1175
|
+
* @see {@link https://lit.dev/docs/templates/directives/#stylemap styleMap code samples on Lit.dev}
|
|
1176
|
+
*/
|
|
1177
|
+
const safeStyleMap = directive(SafeStyleMapDirective);
|
|
1178
|
+
|
|
1179
|
+
/**
|
|
1180
|
+
* Determines whether an object has keys for a given type.
|
|
1181
|
+
* @template T The type to test.
|
|
1182
|
+
* @param {unknown} value The value to test.
|
|
1183
|
+
* @param {...keys: Array<keyof T>} keys The keys of `T` to test.
|
|
1184
|
+
* @returns {boolean} Whether `value` has all `keys`.
|
|
1185
|
+
*/
|
|
1186
|
+
function hasKeys(value, ...keys) {
|
|
1187
|
+
return typeof value === "object" && value !== null && keys.every(x => x in value);
|
|
1188
|
+
}
|
|
1189
|
+
|
|
1190
|
+
/** A symbol through which to access the `ElementInternals` attached to an element. */
|
|
1191
|
+
const internals = Symbol("internals");
|
|
1192
|
+
/**
|
|
1193
|
+
* Determines whether a value is an `AttachInternalsMixin`.
|
|
1194
|
+
* @param {unknown} value The value to test.
|
|
1195
|
+
* @returns Whether `value` is an `AttachInternalsMixin`.
|
|
1196
|
+
*/
|
|
1197
|
+
function isAttachInternalsMixin(value) {
|
|
1198
|
+
return hasKeys(value, internals);
|
|
1199
|
+
}
|
|
1200
|
+
const _internals = Symbol("_internals");
|
|
1201
|
+
// Since flushing custom state doesn't flush in Safari (affecting all iOS browsers),
|
|
1202
|
+
// a copy of custom state is retained locally so components can correctly read after write.
|
|
1203
|
+
const _customState = Symbol("_customState");
|
|
1204
|
+
/**
|
|
1205
|
+
* Mixin to augment an element with behavior that attaches to `ElementInternals`.
|
|
1206
|
+
* @template T The type of the base class.
|
|
1207
|
+
* @param {T} base The base class.
|
|
1208
|
+
* @param {boolean | undefined} formAssociated Whether the element is "Form Associated".
|
|
1209
|
+
* @returns {Constructor<AttachInternalsMixin> & T} A constructor that implements `AttachInternalsMixin`.
|
|
1210
|
+
*/
|
|
1211
|
+
function AttachInternals(base, formAssociated) {
|
|
1212
|
+
var _a;
|
|
1213
|
+
class _AttachInternals extends base {
|
|
1214
|
+
constructor() {
|
|
1215
|
+
super(...arguments);
|
|
1216
|
+
// Since flushing custom state doesn't flush in Safari (affecting all iOS browsers),
|
|
1217
|
+
// a copy of custom state is retained locally so components can correctly read after write.
|
|
1218
|
+
/** @private */
|
|
1219
|
+
this[_a] = new Set();
|
|
1220
|
+
}
|
|
1221
|
+
/** @internal */
|
|
1222
|
+
get [(_a = _customState, internals)]() {
|
|
1223
|
+
return this[_internals] ?? (this[_internals] = this.attachInternals());
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1226
|
+
/** Indicates that this custom element participates in form submission, validation, and form state restoration. */
|
|
1227
|
+
_AttachInternals.formAssociated = formAssociated;
|
|
1228
|
+
return _AttachInternals;
|
|
1229
|
+
}
|
|
1230
|
+
/**
|
|
1231
|
+
* Convenience function used to test whether an element has a given custom state.
|
|
1232
|
+
* @param {AttachInternalsMixin} element The element to test.
|
|
1233
|
+
* @param {string} state The custom state to test.
|
|
1234
|
+
* @returns {boolean} Whether `element` has `state`.
|
|
1235
|
+
*/
|
|
1236
|
+
function hasCustomState(element, state) {
|
|
1237
|
+
// Since flushing custom state doesn't flush in Safari (affecting all iOS browsers),
|
|
1238
|
+
// a copy of custom state is retained locally so components can correctly read after write.
|
|
1239
|
+
if (_customState in element) {
|
|
1240
|
+
return element[_customState].has(state);
|
|
1241
|
+
}
|
|
1242
|
+
// This should never get called due to needing a local copy of custom state
|
|
1243
|
+
// since reading after write to flush doesn't work in Safari (affecting all iOS browsers).
|
|
1244
|
+
return element[internals].states.has(state);
|
|
1245
|
+
}
|
|
1246
|
+
/**
|
|
1247
|
+
* Convenience function used to add custom state to an element.
|
|
1248
|
+
* @param {AttachInternalsMixin} element The element to which to add custom state.
|
|
1249
|
+
* @param {string} state The custom state to add.
|
|
1250
|
+
*/
|
|
1251
|
+
function addCustomState(element, state) {
|
|
1252
|
+
// Avoid style recalculation when element already has state.
|
|
1253
|
+
if (hasCustomState(element, state)) return;
|
|
1254
|
+
// Since flushing custom state doesn't flush in Safari (affecting all iOS browsers),
|
|
1255
|
+
// a copy of custom state is retained locally so components can correctly read after write.
|
|
1256
|
+
if (_customState in element) {
|
|
1257
|
+
element[_customState].add(state);
|
|
1258
|
+
}
|
|
1259
|
+
element[internals]?.states.add(state);
|
|
1260
|
+
element[internals]?.states.has(state); // flush (even though this doesn't work in Safari)
|
|
1261
|
+
}
|
|
1262
|
+
/**
|
|
1263
|
+
* Convenience function used to delete custom state from an element.
|
|
1264
|
+
* @param {AttachInternalsMixin} element The element from which to delete custom state.
|
|
1265
|
+
* @param {string} state The custom state to delete.
|
|
1266
|
+
* @returns {boolean} Whether `state` was removed from `element`.
|
|
1267
|
+
*/
|
|
1268
|
+
function deleteCustomState(element, state) {
|
|
1269
|
+
// Since flushing custom state doesn't flush in Safari (affecting all iOS browsers),
|
|
1270
|
+
// a copy of custom state is retained locally so components can correctly read after write.
|
|
1271
|
+
if (_customState in element) {
|
|
1272
|
+
element[_customState].delete(state);
|
|
1273
|
+
}
|
|
1274
|
+
if (element[internals]?.states.delete(state)) {
|
|
1275
|
+
element[internals]?.states.has(state); // flush (even though this doesn't work in Safari)
|
|
1276
|
+
return true;
|
|
1277
|
+
}
|
|
1278
|
+
return false;
|
|
1279
|
+
}
|
|
1280
|
+
/**
|
|
1281
|
+
* Convenience function used to add or delete custom state for an element.
|
|
1282
|
+
* @param {AttachInternalsMixin} element The element for which to add or delete custom state.
|
|
1283
|
+
* @param {string} state The custom state to add or delete.
|
|
1284
|
+
* @param {boolean} value Whether to add or delete `state` from `element`.
|
|
1285
|
+
*/
|
|
1286
|
+
function setCustomState(element, state, value) {
|
|
1287
|
+
if (value) {
|
|
1288
|
+
addCustomState(element, state);
|
|
1289
|
+
} else {
|
|
1290
|
+
deleteCustomState(element, state);
|
|
1291
|
+
}
|
|
1292
|
+
}
|
|
1293
|
+
|
|
1294
|
+
/**
|
|
1295
|
+
* Determines whether a value is a `CheckedMixin`.
|
|
1296
|
+
* @param {unknown} value The value to test.
|
|
1297
|
+
* @returns Whether `value` is a `CheckedMixin`.
|
|
1298
|
+
*/
|
|
1299
|
+
function isCheckedMixin(value) {
|
|
1300
|
+
return hasKeys(value, "checked");
|
|
1301
|
+
}
|
|
1302
|
+
/**
|
|
1303
|
+
* Mixin to augment an element with behavior that supports a checked state.
|
|
1304
|
+
* @template T The type of the base class.
|
|
1305
|
+
* @param {T} base The base class.
|
|
1306
|
+
* @returns {Constructor<CheckedMixin> & T} A constructor that implements `CheckedMixin`.
|
|
1307
|
+
*/
|
|
1308
|
+
function Checked(base) {
|
|
1309
|
+
class _CheckedMixin extends base {
|
|
1310
|
+
constructor() {
|
|
1311
|
+
super(...arguments);
|
|
1312
|
+
/**
|
|
1313
|
+
* Whether the element is checked.
|
|
1314
|
+
* @default false
|
|
1315
|
+
*/
|
|
1316
|
+
this.checked = false;
|
|
1317
|
+
}
|
|
1318
|
+
/** @inheritdoc */
|
|
1319
|
+
update(changedProperties) {
|
|
1320
|
+
super.update(changedProperties);
|
|
1321
|
+
if (changedProperties.has("checked")) {
|
|
1322
|
+
if (this.role === "button") {
|
|
1323
|
+
this.ariaPressed = `${this.checked}`;
|
|
1324
|
+
this.ariaChecked = null;
|
|
1325
|
+
} else if (this.role && this.role !== "none" && this.role !== "presentation") {
|
|
1326
|
+
this.ariaChecked = `${this.checked}`;
|
|
1327
|
+
this.ariaPressed = null;
|
|
1328
|
+
}
|
|
1329
|
+
}
|
|
1330
|
+
}
|
|
1331
|
+
}
|
|
1332
|
+
__decorate([property({
|
|
1333
|
+
type: Boolean,
|
|
1334
|
+
reflect: true
|
|
1335
|
+
})], _CheckedMixin.prototype, "checked", void 0);
|
|
1336
|
+
return _CheckedMixin;
|
|
1337
|
+
}
|
|
1338
|
+
|
|
1339
|
+
/**
|
|
1340
|
+
* Determines whether a value is a `CheckedIndeterminateMixin`.
|
|
1341
|
+
* @param {unknown} value The value to test.
|
|
1342
|
+
* @returns Whether `value` is a `CheckedIndeterminateMixin`.
|
|
1343
|
+
*/
|
|
1344
|
+
function isCheckedIndeterminateMixin(value) {
|
|
1345
|
+
return hasKeys(value, "indeterminate") && isCheckedMixin(value);
|
|
1346
|
+
}
|
|
1347
|
+
/**
|
|
1348
|
+
* Mixin to augment an element with behavior that supports a mixed checked state.
|
|
1349
|
+
* @template T The type of the base class.
|
|
1350
|
+
* @param {T} base The base class.
|
|
1351
|
+
* @returns {Constructor<CheckedIndeterminateMixin> & T} A constructor that implements `CheckedIndeterminateMixin`.
|
|
1352
|
+
*/
|
|
1353
|
+
function CheckedIndeterminate(base) {
|
|
1354
|
+
class _CheckedIndeterminateMixin extends Checked(base) {
|
|
1355
|
+
constructor() {
|
|
1356
|
+
super(...arguments);
|
|
1357
|
+
/**
|
|
1358
|
+
* Whether the element's checked state is indeterminate.
|
|
1359
|
+
* @default false
|
|
1360
|
+
*/
|
|
1361
|
+
this.indeterminate = false;
|
|
1362
|
+
}
|
|
1363
|
+
/** @inheritdoc */
|
|
1364
|
+
update(changedProperties) {
|
|
1365
|
+
super.update(changedProperties);
|
|
1366
|
+
if (changedProperties.has("indeterminate") && this.role && this.role !== "none" && this.role !== "presentation") {
|
|
1367
|
+
this.ariaChecked = !this.checked && this.indeterminate ? "mixed" : `${this.checked}`;
|
|
1368
|
+
}
|
|
1369
|
+
}
|
|
1370
|
+
}
|
|
1371
|
+
__decorate([property({
|
|
1372
|
+
type: Boolean,
|
|
1373
|
+
reflect: true
|
|
1374
|
+
})], _CheckedIndeterminateMixin.prototype, "indeterminate", void 0);
|
|
1375
|
+
return _CheckedIndeterminateMixin;
|
|
1376
|
+
}
|
|
1377
|
+
|
|
1378
|
+
/** Design tokens that control color. */
|
|
1379
|
+
const ColorToken = {
|
|
1380
|
+
/** High-emphasis fills, texts, and icons against surface. */
|
|
1381
|
+
primary: unsafeCSS("var(--md-sys-color-primary, #6750A4)"),
|
|
1382
|
+
/** Text and icons against primary. */
|
|
1383
|
+
onPrimary: unsafeCSS("var(--md-sys-color-on-primary, #FFFFFF)"),
|
|
1384
|
+
/** Standout fill color against surface, for key components. */
|
|
1385
|
+
primaryContainer: unsafeCSS("var(--md-sys-color-primary-container, #EADDFF)"),
|
|
1386
|
+
/** Text and icons against primary container. */
|
|
1387
|
+
onPrimaryContainer: unsafeCSS("var(--md-sys-color-on-primary-container, #4F378B)"),
|
|
1388
|
+
/** High-emphasis fills, texts, and icons that maintain the same tone in light and dark themes. */
|
|
1389
|
+
primaryFixed: unsafeCSS("var(--md-sys-color-primary-fixed, #EADDFF)"),
|
|
1390
|
+
/** High-emphasis fills, texts, and icons that maintain the same stronger tone in light and dark themes. */
|
|
1391
|
+
primaryFixedDim: unsafeCSS("var(--md-sys-color-primary-fixed-dim, #D0BCFF)"),
|
|
1392
|
+
/** Text and icons against fixed primary. */
|
|
1393
|
+
onPrimaryFixed: unsafeCSS("var(--md-sys-color-on-primary-fixed, #21005D)"),
|
|
1394
|
+
/** Lower-emphasis text and icons against fixed primary. */
|
|
1395
|
+
onPrimaryFixedVariant: unsafeCSS("var(--md-sys-color-on-primary-fixed-variant, #4F378B)"),
|
|
1396
|
+
/** Less prominent fills, text, and icons against surface. */
|
|
1397
|
+
secondary: unsafeCSS("var(--md-sys-color-secondary, #625B71)"),
|
|
1398
|
+
/** Text and icons against secondary. */
|
|
1399
|
+
onSecondary: unsafeCSS("var(--md-sys-color-on-secondary, #FFFFFF)"),
|
|
1400
|
+
/** Less prominent fill color against surface, for recessive components. */
|
|
1401
|
+
secondaryContainer: unsafeCSS("var(--md-sys-color-secondary-container, #E8DEF8)"),
|
|
1402
|
+
/** Text and icons against secondary container. */
|
|
1403
|
+
onSecondaryContainer: unsafeCSS("var(--md-sys-color-on-secondary-container, #4A4458)"),
|
|
1404
|
+
/** Less prominent fills, texts, and icons that maintain the same tone in light and dark themes. */
|
|
1405
|
+
secondaryFixed: unsafeCSS("var(--md-sys-color-secondary-fixed, #E8DEF8)"),
|
|
1406
|
+
/** Less prominent fills, texts, and icons that maintain the same stronger tone in light and dark themes. */
|
|
1407
|
+
secondaryFixedDim: unsafeCSS("var(--md-sys-color-secondary-fixed-dim, #CCC2DC)"),
|
|
1408
|
+
/** Text and icons against fixed secondary. */
|
|
1409
|
+
onSecondaryFixed: unsafeCSS("var(--md-sys-color-on-secondary-fixed, #1D192B)"),
|
|
1410
|
+
/** Lower-emphasis text and icons against fixed secondary. */
|
|
1411
|
+
onSecondaryFixedVariant: unsafeCSS("var(--md-sys-color-on-secondary-fixed-variant, #4A4458)"),
|
|
1412
|
+
/** Complementary fills, text, and icons against surface. */
|
|
1413
|
+
tertiary: unsafeCSS("var(--md-sys-color-tertiary, #7D5260)"),
|
|
1414
|
+
/** Text and icons against tertiary. */
|
|
1415
|
+
onTertiary: unsafeCSS("var(--md-sys-color-on-tertiary, #FFFFFF)"),
|
|
1416
|
+
/** Complementary container color against surface. */
|
|
1417
|
+
tertiaryContainer: unsafeCSS("var(--md-sys-color-tertiary-container, #FFD8E4)"),
|
|
1418
|
+
/** Text and icons against tertiary container. */
|
|
1419
|
+
onTertiaryContainer: unsafeCSS("var(--md-sys-color-on-tertiary-container, #633B48)"),
|
|
1420
|
+
/** Complementary fills, texts, and icons that maintain the same tone in light and dark themes. */
|
|
1421
|
+
tertiaryFixed: unsafeCSS("var(--md-sys-color-tertiary-fixed, #FFD8E4)"),
|
|
1422
|
+
/** Complementary fills, texts, and icons that maintain the same stronger tone in light and dark themes. */
|
|
1423
|
+
tertiaryFixedDim: unsafeCSS("var(--md-sys-color-tertiary-fixed-dim, #EFB8C8)"),
|
|
1424
|
+
/** Text and icons against fixed tertiary. */
|
|
1425
|
+
onTertiaryFixed: unsafeCSS("var(--md-sys-color-on-tertiary-fixed, #31111D)"),
|
|
1426
|
+
/** Lower-emphasis text and icons against fixed tertiary. */
|
|
1427
|
+
onTertiaryFixedVariant: unsafeCSS("var(--md-sys-color-on-tertiary-fixed-variant, #633B48)"),
|
|
1428
|
+
/** Attention-grabbing color against surface for fills, icons, and text, indicating urgency. */
|
|
1429
|
+
error: unsafeCSS("var(--md-sys-color-error, #B3261E)"),
|
|
1430
|
+
/** Text and icons against error. */
|
|
1431
|
+
onError: unsafeCSS("var(--md-sys-color-on-error, #FFFFFF)"),
|
|
1432
|
+
/** Attention-grabbing fill color against surface. */
|
|
1433
|
+
errorContainer: unsafeCSS("var(--md-sys-color-error-container, #F9DEDC)"),
|
|
1434
|
+
/** Text and icons against error container. */
|
|
1435
|
+
onErrorContainer: unsafeCSS("var(--md-sys-color-on-error-container, #8C1D18)"),
|
|
1436
|
+
/** Default color for backgrounds. */
|
|
1437
|
+
surface: unsafeCSS("var(--md-sys-color-surface, #FEF7FF)"),
|
|
1438
|
+
/** Text and icons against any surface color. */
|
|
1439
|
+
onSurface: unsafeCSS("var(--md-sys-color-on-surface, #1D1B20)"),
|
|
1440
|
+
/** Lower-emphasis color for text and icons against any surface color. */
|
|
1441
|
+
onSurfaceVariant: unsafeCSS("var(--md-sys-color-on-surface-variant, #49454F)"),
|
|
1442
|
+
/** Lowest-emphasis container color. */
|
|
1443
|
+
surfaceContainerLowest: unsafeCSS("var(--md-sys-color-surface-container-lowest, #FFFFFF)"),
|
|
1444
|
+
/** Low-emphasis container color. */
|
|
1445
|
+
surfaceContainerLow: unsafeCSS("var(--md-sys-color-surface-container-low, #F7F2FA)"),
|
|
1446
|
+
/** Default container color. */
|
|
1447
|
+
surfaceContainer: unsafeCSS("var(--md-sys-color-surface-container, #F3EDF7)"),
|
|
1448
|
+
/** High-emphasis container color. */
|
|
1449
|
+
surfaceContainerHigh: unsafeCSS("var(--md-sys-color-surface-container-high, #ECE6F0)"),
|
|
1450
|
+
/** Highest-emphasis container color. */
|
|
1451
|
+
surfaceContainerHighest: unsafeCSS("var(--md-sys-color-surface-container-highest, #E6E0E9)"),
|
|
1452
|
+
/** Dimmest surface color in light and dark themes. */
|
|
1453
|
+
surfaceDim: unsafeCSS("var(--md-sys-color-surface-dim, #DED8E1)"),
|
|
1454
|
+
/** Brightest surface color in light and dark themes. */
|
|
1455
|
+
surfaceBright: unsafeCSS("var(--md-sys-color-surface-bright, #FEF7FF)"),
|
|
1456
|
+
/** Alternate surface color, can be used for active states. */
|
|
1457
|
+
surfaceVariant: unsafeCSS("var(--md-sys-color-surface-variant, #E7E0EC)"),
|
|
1458
|
+
/** Background fills for elements which contrast against surface. */
|
|
1459
|
+
inverseSurface: unsafeCSS("var(--md-sys-color-inverse-surface, #322F35)"),
|
|
1460
|
+
/** Text and icons against inverse surface. */
|
|
1461
|
+
inverseOnSurface: unsafeCSS("var(--md-sys-color-inverse-on-surface, #F5EFF7)"),
|
|
1462
|
+
/** Primary text and icons against inverse surface. */
|
|
1463
|
+
inversePrimary: unsafeCSS("var(--md-sys-color-inverse-primary, #D0BCFF)"),
|
|
1464
|
+
/** Important boundaries, such as a text field outline. */
|
|
1465
|
+
outline: unsafeCSS("var(--md-sys-color-outline, #79747E)"),
|
|
1466
|
+
/** Decorative elements, such as dividers. */
|
|
1467
|
+
outlineVariant: unsafeCSS("var(--md-sys-color-outline-variant, #CAC4D0)"),
|
|
1468
|
+
/** Elevation shadow color. */
|
|
1469
|
+
shadow: unsafeCSS("var(--md-sys-color-shadow, #000000)"),
|
|
1470
|
+
/** Backdrop which obscures underlying content. */
|
|
1471
|
+
scrim: unsafeCSS("var(--md-sys-color-scrim, #000000)")
|
|
1472
|
+
};
|
|
1473
|
+
|
|
1474
|
+
const _DensityToken = {
|
|
1475
|
+
/** Base density multiplier. */
|
|
1476
|
+
scale: unsafeCSS("var(--md-sys-density-scale, 0)"),
|
|
1477
|
+
/** Spatial unit used to scale component dimensions based on density. */
|
|
1478
|
+
size: unsafeCSS("var(--md-sys-density-size, 0.25rem)")
|
|
1479
|
+
};
|
|
1480
|
+
/** Design tokens that control density. */
|
|
1481
|
+
const DensityToken = {
|
|
1482
|
+
..._DensityToken,
|
|
1483
|
+
/**
|
|
1484
|
+
* Creates a CSS `calc` that calculates a dimension based on density.
|
|
1485
|
+
* @param {number} minScale The minimum supported scale.
|
|
1486
|
+
* @returns {CSSResult} A CSS `calc` used to calculate a dimension based on density.
|
|
1487
|
+
*/
|
|
1488
|
+
calc(minScale) {
|
|
1489
|
+
return unsafeCSS(`calc(max(${minScale}, ${_DensityToken.scale}) * ${_DensityToken.size})`);
|
|
1490
|
+
}
|
|
1491
|
+
};
|
|
1492
|
+
|
|
1493
|
+
const UMBRA_COLOR = `color-mix(in srgb, var(--m3e-elevation-color, ${ColorToken.shadow}) 20%, transparent)`;
|
|
1494
|
+
const UMBRA = ["0px 0px 0px 0px", "0px 2px 1px -1px", "0px 3px 1px -2px", "0px 3px 3px -2px", "0px 2px 4px -1px", "0px 3px 5px -1px", "0px 3px 5px -1px", "0px 4px 5px -2px", "0px 5px 5px -3px", "0px 5px 6px -3px", "0px 6px 6px -3px", "0px 6px 7px -4px", "0px 7px 8px -4px", "0px 7px 8px -4px", "0px 7px 9px -4px", "0px 8px 9px -5px", "0px 8px 10px -5px", "0px 8px 11px -5px", "0px 9px 11px -5px", "0px 9px 12px -6px", "0px 10px 13px -6px", "0px 10px 13px -6px", "0px 10px 14px -6px", "0px 11px 14px -7px", "0px 11px 15px -7px"];
|
|
1495
|
+
const PENUMBRA_COLOR = `color-mix(in srgb, var(--m3e-elevation-color, ${ColorToken.shadow}) 14%, transparent)`;
|
|
1496
|
+
const PENUMBRA = ["0px 0px 0px 0px", "0px 1px 1px 0px", "0px 2px 2px 0px", "0px 3px 4px 0px", "0px 4px 5px 0px", "0px 5px 8px 0px", "0px 6px 10px 0px", "0px 7px 10px 1px", "0px 8px 10px 1px", "0px 9px 12px 1px", "0px 10px 14px 1px", "0px 11px 15px 1px", "0px 12px 17px 2px", "0px 13px 19px 2px", "0px 14px 21px 2px", "0px 15px 22px 2px", "0px 16px 24px 2px", "0px 17px 26px 2px", "0px 18px 28px 2px", "0px 19px 29px 2px", "0px 20px 31px 3px", "0px 21px 33px 3px", "0px 22px 35px 3px", "0px 23px 36px 3px", "0px 24px 38px 3px"];
|
|
1497
|
+
const AMBIENT_COLOR = `color-mix(in srgb, var(--m3e-elevation-color, ${ColorToken.shadow}) 12%, transparent)`;
|
|
1498
|
+
const AMBIENT = ["0px 0px 0px 0px", "0px 1px 3px 0px", "0px 1px 5px 0px", "0px 1px 8px 0px", "0px 1px 10px 0px", "0px 1px 14px 0px", "0px 1px 18px 0px", "0px 2px 16px 1px", "0px 3px 14px 2px", "0px 3px 16px 2px", "0px 4px 18px 3px", "0px 4px 20px 3px", "0px 5px 22px 4px", "0px 5px 24px 4px", "0px 5px 26px 4px", "0px 6px 28px 5px", "0px 6px 30px 5px", "0px 6px 32px 5px", "0px 7px 34px 6px", "0px 7px 36px 6px", "0px 8px 38px 7px", "0px 8px 40px 7px", "0px 8px 42px 7px", "0px 9px 44px 8px", "0px 9px 46px 8px"];
|
|
1499
|
+
function elevation(z) {
|
|
1500
|
+
return `${UMBRA_COLOR} ${UMBRA[z]},${PENUMBRA_COLOR} ${PENUMBRA[z]},${AMBIENT_COLOR} ${AMBIENT[z]}`;
|
|
1501
|
+
}
|
|
1502
|
+
/** Design tokens that control elevation. */
|
|
1503
|
+
const ElevationToken$1 = {
|
|
1504
|
+
/** Level 0 elevation. */
|
|
1505
|
+
level0: unsafeCSS(`var(--md-sys-elevation-level0, ${elevation(0)})`),
|
|
1506
|
+
/** Level 1 elevation. */
|
|
1507
|
+
level1: unsafeCSS(`var(--md-sys-elevation-level1, ${elevation(1)})`),
|
|
1508
|
+
/** Level 2 elevation. */
|
|
1509
|
+
level2: unsafeCSS(`var(--md-sys-elevation-level2, ${elevation(3)})`),
|
|
1510
|
+
/** Level 3 elevation. */
|
|
1511
|
+
level3: unsafeCSS(`var(--md-sys-elevation-level3, ${elevation(6)})`),
|
|
1512
|
+
/** Level 4 elevation. */
|
|
1513
|
+
level4: unsafeCSS(`var(--md-sys-elevation-level4, ${elevation(8)})`),
|
|
1514
|
+
/** Level 5 elevation. */
|
|
1515
|
+
level5: unsafeCSS(`var(--md-sys-elevation-level5, ${elevation(12)})`)
|
|
1516
|
+
};
|
|
1517
|
+
|
|
1518
|
+
function space(unit) {
|
|
1519
|
+
return unsafeCSS(`var(--md-sys-measurement-space${unit}, ${0.5 * (unit / 100)}rem)`);
|
|
1520
|
+
}
|
|
1521
|
+
/** Design tokens that control measurements. */
|
|
1522
|
+
const MeasurementToken = {
|
|
1523
|
+
/** Zero spacing. */
|
|
1524
|
+
space0: space(0),
|
|
1525
|
+
/** 2dp spacing. */
|
|
1526
|
+
space25: space(25),
|
|
1527
|
+
/** 4dp spacing. */
|
|
1528
|
+
space50: space(50),
|
|
1529
|
+
/** 6dp spacing. */
|
|
1530
|
+
space75: space(75),
|
|
1531
|
+
/** 8dp spacing. */
|
|
1532
|
+
space100: space(100),
|
|
1533
|
+
/** 10dp spacing. */
|
|
1534
|
+
space125: space(125),
|
|
1535
|
+
/** 12dp spacing. */
|
|
1536
|
+
space150: space(150),
|
|
1537
|
+
/** 14dp spacing. */
|
|
1538
|
+
space175: space(175),
|
|
1539
|
+
/** 16dp spacing. */
|
|
1540
|
+
space200: space(200),
|
|
1541
|
+
/** 20dp spacing. */
|
|
1542
|
+
space250: space(250),
|
|
1543
|
+
/** 24dp spacing. */
|
|
1544
|
+
space300: space(300),
|
|
1545
|
+
/** 32dp spacing. */
|
|
1546
|
+
space400: space(400),
|
|
1547
|
+
/** 36dp spacing. */
|
|
1548
|
+
space450: space(450),
|
|
1549
|
+
/** 40dp spacing. */
|
|
1550
|
+
space500: space(500),
|
|
1551
|
+
/** 48dp spacing. */
|
|
1552
|
+
space600: space(600),
|
|
1553
|
+
/** 56dp spacing. */
|
|
1554
|
+
space700: space(700),
|
|
1555
|
+
/** 64dp spacing. */
|
|
1556
|
+
space800: space(800),
|
|
1557
|
+
/** 72dp spacing. */
|
|
1558
|
+
space900: space(900)
|
|
1559
|
+
};
|
|
1560
|
+
|
|
1561
|
+
const EasingToken = {
|
|
1562
|
+
/** Emphasized transition. */
|
|
1563
|
+
emphasized: unsafeCSS("var(--md-sys-motion-easing-emphasized, cubic-bezier(0.2, 0.0, 0, 1.0))"),
|
|
1564
|
+
/** Decelerated emphasized transition. */
|
|
1565
|
+
emphasizedDecelerate: unsafeCSS("var(--md-sys-motion-easing-emphasized-decelerate, cubic-bezier(0.05, 0.7, 0.1, 1.0))"),
|
|
1566
|
+
/** Accelerated emphasized transition. */
|
|
1567
|
+
emphasizedAccelerate: unsafeCSS("var(--md-sys-motion-easing-emphasized-accelerate, cubic-bezier(0.3, 0.0, 0.8, 0.15))"),
|
|
1568
|
+
/** Simple, small, or utility-focused transition. */
|
|
1569
|
+
standard: unsafeCSS("var(--md-sys-motion-easing-standard, cubic-bezier(0.2, 0.0, 0, 1.0))"),
|
|
1570
|
+
/** Decelerated standard transition. */
|
|
1571
|
+
standardDecelerate: unsafeCSS("var(--md-sys-motion-easing-standard-decelerate, cubic-bezier(0, 0, 0, 1))"),
|
|
1572
|
+
/** Accelerated standard transition. */
|
|
1573
|
+
standardAccelerate: unsafeCSS("var(--md-sys-motion-easing-standard-accelerate, cubic-bezier(0.3, 0, 1, 1))")
|
|
1574
|
+
};
|
|
1575
|
+
const SpringToken = {
|
|
1576
|
+
/** Fast spatial spring. */
|
|
1577
|
+
fastSpatial: unsafeCSS("var(--md-sys-motion-spring-fast-spatial, 350ms cubic-bezier(0.27, 1.06, 0.18, 1.00))"),
|
|
1578
|
+
/** Default spatial spring. */
|
|
1579
|
+
defaultSpatial: unsafeCSS("var(--md-sys-motion-spring-default-spatial, 500ms cubic-bezier(0.27, 1.06, 0.18, 1.00))"),
|
|
1580
|
+
/** Slow spatial spring. */
|
|
1581
|
+
slowSpatial: unsafeCSS("var(--md-sys-motion-spring-slow-spatial, 750ms cubic-bezier(0.27, 1.06, 0.18, 1.00))"),
|
|
1582
|
+
/** Fast effects spring. */
|
|
1583
|
+
fastEffects: unsafeCSS("var(--md-sys-motion-spring-fast-effects, 150ms cubic-bezier(0.31, 0.94, 0.34, 1.00))"),
|
|
1584
|
+
/** Default effects spring. */
|
|
1585
|
+
defaultEffects: unsafeCSS("var(--md-sys-motion-spring-default-effects, 200ms cubic-bezier(0.34, 0.80, 0.34, 1.00))"),
|
|
1586
|
+
/** Slow effects spring. */
|
|
1587
|
+
slowEffects: unsafeCSS("var(--md-sys-motion-spring-slow-effects, 200ms cubic-bezier(0.34, 0.88, 0.34, 1.00))")
|
|
1588
|
+
};
|
|
1589
|
+
const DurationToken = {
|
|
1590
|
+
/** Small utility-focused transition duration. */
|
|
1591
|
+
short1: unsafeCSS("var(--md-sys-motion-duration-short-1, 50ms)"),
|
|
1592
|
+
/** Small utility-focused transition duration. */
|
|
1593
|
+
short2: unsafeCSS("var(--md-sys-motion-duration-short-2, 100ms)"),
|
|
1594
|
+
/** Small utility-focused transition duration. */
|
|
1595
|
+
short3: unsafeCSS("var(--md-sys-motion-duration-short-3, 150ms)"),
|
|
1596
|
+
/** Small utility-focused transition duration. */
|
|
1597
|
+
short4: unsafeCSS("var(--md-sys-motion-duration-short-4, 200ms)"),
|
|
1598
|
+
/** Duration for transitions that traverse a medium area of the screen. */
|
|
1599
|
+
medium1: unsafeCSS("var(--md-sys-motion-duration-medium-1, 250ms)"),
|
|
1600
|
+
/** Duration for transitions that traverse a medium area of the screen. */
|
|
1601
|
+
medium2: unsafeCSS("var(--md-sys-motion-duration-medium-2, 300ms)"),
|
|
1602
|
+
/** Duration for transitions that traverse a medium area of the screen. */
|
|
1603
|
+
medium3: unsafeCSS("var(--md-sys-motion-duration-medium-3, 350ms)"),
|
|
1604
|
+
/** Duration for transitions that traverse a medium area of the screen. */
|
|
1605
|
+
medium4: unsafeCSS("var(--md-sys-motion-duration-medium-4, 400ms)"),
|
|
1606
|
+
/** Duration for large expressive transitions. */
|
|
1607
|
+
long1: unsafeCSS("var(--md-sys-motion-duration-long-1, 450ms)"),
|
|
1608
|
+
/** Duration for large expressive transitions. */
|
|
1609
|
+
long2: unsafeCSS("var(--md-sys-motion-duration-long-2, 500ms)"),
|
|
1610
|
+
/** Duration for large expressive transitions. */
|
|
1611
|
+
long3: unsafeCSS("var(--md-sys-motion-duration-long-3, 550ms)"),
|
|
1612
|
+
/** Duration for large expressive transitions. */
|
|
1613
|
+
long4: unsafeCSS("var(--md-sys-motion-duration-long-4, 600ms)"),
|
|
1614
|
+
/** Extra long duration for ambient transitions. */
|
|
1615
|
+
extraLong1: unsafeCSS("var(--md-sys-motion-duration-extra-long-1, 700ms)"),
|
|
1616
|
+
/** Extra long duration for ambient transitions. */
|
|
1617
|
+
extraLong2: unsafeCSS("var(--md-sys-motion-duration-extra-long-2, 800ms)"),
|
|
1618
|
+
/** Extra long duration for ambient transitions. */
|
|
1619
|
+
extraLong3: unsafeCSS("var(--md-sys-motion-duration-extra-long-3, 900ms)"),
|
|
1620
|
+
/** Extra long duration for ambient transitions. */
|
|
1621
|
+
extraLong4: unsafeCSS("var(--md-sys-motion-duration-extra-long-4, 1000ms)")
|
|
1622
|
+
};
|
|
1623
|
+
/** Design tokens that control motion. */
|
|
1624
|
+
const MotionToken = {
|
|
1625
|
+
/** Design tokens that control transition effects. */
|
|
1626
|
+
easing: EasingToken,
|
|
1627
|
+
/** Design tokens that control transition duration. */
|
|
1628
|
+
duration: DurationToken,
|
|
1629
|
+
/** Design tokens that control spring effects. */
|
|
1630
|
+
spring: SpringToken
|
|
1631
|
+
};
|
|
1632
|
+
|
|
1633
|
+
/** Design tokens that control scrollbars. */
|
|
1634
|
+
const ScrollbarToken = {
|
|
1635
|
+
/** Width of a standard scrollbar. */
|
|
1636
|
+
width: unsafeCSS(`var(--m3e-scrollbar-width, auto)`),
|
|
1637
|
+
/** Width of a thin scrollbar. */
|
|
1638
|
+
thinWidth: unsafeCSS(`var(--m3e-scrollbar-thin-width, thin)`),
|
|
1639
|
+
/** Color of a scrollbar. */
|
|
1640
|
+
color: unsafeCSS(`var(--m3e-scrollbar-thumb-color, #938f94) var(--m3e-scrollbar-track-color, transparent)`)
|
|
1641
|
+
};
|
|
1642
|
+
|
|
1643
|
+
const CornerValue = {
|
|
1644
|
+
/** No rounding. */
|
|
1645
|
+
none: unsafeCSS("var(--md-sys-shape-corner-value-none, 0)"),
|
|
1646
|
+
/** Extra small rounded corner. */
|
|
1647
|
+
extraSmall: unsafeCSS("var(--md-sys-shape-corner-value-extra-small, 0.25rem)"),
|
|
1648
|
+
/** Small rounded corner. */
|
|
1649
|
+
small: unsafeCSS("var(--md-sys-shape-corner-value-small, 0.5rem)"),
|
|
1650
|
+
/** Medium rounded corner. */
|
|
1651
|
+
medium: unsafeCSS("var(--md-sys-shape-corner-value-medium, 0.75rem)"),
|
|
1652
|
+
/** Large rounded corner. */
|
|
1653
|
+
large: unsafeCSS("var(--md-sys-shape-corner-value-large, 1rem)"),
|
|
1654
|
+
/** Increased large rounded corner. */
|
|
1655
|
+
largeIncreased: unsafeCSS("var(--md-sys-shape-corner-value-large-increased, 1.25rem)"),
|
|
1656
|
+
/** Extra large rounded corner. */
|
|
1657
|
+
extraLarge: unsafeCSS("var(--md-sys-shape-corner-value-extra-large, 1.75rem)"),
|
|
1658
|
+
/** Increased extra large rounded corner. */
|
|
1659
|
+
extraLargeIncreased: unsafeCSS("var(--md-sys-shape-corner-value-extra-large-increased, 2rem)"),
|
|
1660
|
+
/** Extra extra large rounded corner. */
|
|
1661
|
+
extraExtraLarge: unsafeCSS("var(--md-sys-shape-corner-value-extra-extra-large, 3rem)")
|
|
1662
|
+
};
|
|
1663
|
+
/** Design tokens that control shape. */
|
|
1664
|
+
const ShapeToken = {
|
|
1665
|
+
corner: {
|
|
1666
|
+
/** Fully rounded symmetric shape. */
|
|
1667
|
+
full: unsafeCSS("var(--md-sys-shape-corner-full, 624.9375rem)"),
|
|
1668
|
+
/** Extra large rounded asymmetric shape directed towards the top. */
|
|
1669
|
+
extraLargeTop: unsafeCSS(`var(--md-sys-shape-corner-extra-large-top, ${CornerValue.extraLarge} ${CornerValue.extraLarge} ${CornerValue.none} ${CornerValue.none})`),
|
|
1670
|
+
/** Extra large rounded symmetric shape. */
|
|
1671
|
+
extraLarge: unsafeCSS(`var(--md-sys-shape-corner-extra-large, ${CornerValue.extraLarge})`),
|
|
1672
|
+
/** Extra large rounded asymmetric shape directed towards the end. */
|
|
1673
|
+
extraLargeEnd: unsafeCSS(`${CornerValue.none} ${CornerValue.extraLarge} ${CornerValue.extraLarge} ${CornerValue.none}`),
|
|
1674
|
+
/** Extra large rounded asymmetric shape directed towards the start. */
|
|
1675
|
+
extraLargeStart: unsafeCSS(`${CornerValue.extraLarge} ${CornerValue.none} ${CornerValue.none} ${CornerValue.extraLarge}`),
|
|
1676
|
+
/** Large rounded asymmetric shape directed towards the top. */
|
|
1677
|
+
largeTop: unsafeCSS(`var(--md-sys-shape-corner-large-top, ${CornerValue.large} ${CornerValue.large} ${CornerValue.none} ${CornerValue.none})`),
|
|
1678
|
+
/** Large rounded asymmetric shape directed towards the end. */
|
|
1679
|
+
largeEnd: unsafeCSS(`var(--md-sys-shape-corner-large-end, ${CornerValue.none} ${CornerValue.large} ${CornerValue.large} ${CornerValue.none})`),
|
|
1680
|
+
/** Large rounded asymmetric shape directed towards the start. */
|
|
1681
|
+
largeStart: unsafeCSS(`var(--md-sys-shape-corner-large-start, ${CornerValue.large} ${CornerValue.none} ${CornerValue.none} ${CornerValue.large})`),
|
|
1682
|
+
/** Large rounded symmetric shape. */
|
|
1683
|
+
large: unsafeCSS(`var(--md-sys-shape-corner-large, ${CornerValue.large})`),
|
|
1684
|
+
/** Medium rounded symmetric shape. */
|
|
1685
|
+
medium: unsafeCSS(`var(--md-sys-shape-corner-medium, ${CornerValue.medium})`),
|
|
1686
|
+
/** Medium rounded asymmetric shape directed towards the top. */
|
|
1687
|
+
mediumTop: unsafeCSS(`${CornerValue.medium} ${CornerValue.medium} ${CornerValue.none} ${CornerValue.none}`),
|
|
1688
|
+
/** Medium rounded asymmetric shape directed towards the end. */
|
|
1689
|
+
mediumEnd: unsafeCSS(`${CornerValue.none} ${CornerValue.medium} ${CornerValue.medium} ${CornerValue.none}`),
|
|
1690
|
+
/** Medium rounded asymmetric shape directed towards the start. */
|
|
1691
|
+
mediumStart: unsafeCSS(`${CornerValue.medium} ${CornerValue.none} ${CornerValue.none} ${CornerValue.medium}`),
|
|
1692
|
+
/** Small rounded symmetric shape. */
|
|
1693
|
+
small: unsafeCSS(`var(--md-sys-shape-corner-small, ${CornerValue.small})`),
|
|
1694
|
+
/** Small rounded asymmetric shape directed towards the top. */
|
|
1695
|
+
smallTop: unsafeCSS(`${CornerValue.small} ${CornerValue.small} ${CornerValue.none} ${CornerValue.none}`),
|
|
1696
|
+
/** Small rounded asymmetric shape directed towards the end. */
|
|
1697
|
+
smallEnd: unsafeCSS(`${CornerValue.none} ${CornerValue.small} ${CornerValue.small} ${CornerValue.none}`),
|
|
1698
|
+
/** Small rounded asymmetric shape directed towards the start. */
|
|
1699
|
+
smallStart: unsafeCSS(`${CornerValue.small} ${CornerValue.none} ${CornerValue.none} ${CornerValue.small}`),
|
|
1700
|
+
/** Extra small rounded asymmetric shape directed towards the top. */
|
|
1701
|
+
extraSmallTop: unsafeCSS(`var(--md-sys-shape-corner-extra-small-top, ${CornerValue.extraSmall} ${CornerValue.extraSmall} ${CornerValue.none} ${CornerValue.none})`),
|
|
1702
|
+
/** Extra small rounded symmetric shape. */
|
|
1703
|
+
extraSmall: unsafeCSS(`var(--md-sys-shape-corner-extra-small, ${CornerValue.extraSmall})`),
|
|
1704
|
+
/** Extra small rounded asymmetric shape directed towards the end. */
|
|
1705
|
+
extraSmallEnd: unsafeCSS(`${CornerValue.none} ${CornerValue.extraSmall} ${CornerValue.extraSmall} ${CornerValue.none}`),
|
|
1706
|
+
/** Extra small rounded asymmetric shape directed towards the start. */
|
|
1707
|
+
extraSmallStart: unsafeCSS(`${CornerValue.extraSmall} ${CornerValue.none} ${CornerValue.none} ${CornerValue.extraSmall}`),
|
|
1708
|
+
/** Extra small rounded asymmetric shape directed towards the bottom. */
|
|
1709
|
+
extraSmallBottom: unsafeCSS(`${CornerValue.none} ${CornerValue.none} ${CornerValue.extraSmall} ${CornerValue.extraSmall}`),
|
|
1710
|
+
/** No rounding. */
|
|
1711
|
+
none: unsafeCSS(`var(--md-sys-shape-corner-none, ${CornerValue.none})`),
|
|
1712
|
+
/** Increased large rounded symmetric shape. */
|
|
1713
|
+
largeIncreased: unsafeCSS(`var(--md-sys-shape-corner-large-increased, ${CornerValue.largeIncreased})`),
|
|
1714
|
+
/** Increased extra large rounded symmetric shape. */
|
|
1715
|
+
extraLargeIncreased: unsafeCSS(`var(--md-sys-shape-corner-extra-large-increased, ${CornerValue.extraLargeIncreased})`),
|
|
1716
|
+
/** Extra extra large rounded symmetric shape. */
|
|
1717
|
+
extraExtraLarge: unsafeCSS(`var(--md-sys-shape-corner-extra-extra-large, ${CornerValue.extraExtraLarge})`),
|
|
1718
|
+
/** Design tokens that control specific corners. */
|
|
1719
|
+
value: CornerValue
|
|
1720
|
+
}
|
|
1721
|
+
};
|
|
1722
|
+
|
|
1723
|
+
/** Design tokens that control state layer. */
|
|
1724
|
+
const StateToken = {
|
|
1725
|
+
/** Opacity of the state layer on focus. */
|
|
1726
|
+
focusStateLayerOpacity: unsafeCSS("var(--md-sys-state-focus-state-layer-opacity, 10%)"),
|
|
1727
|
+
/** Opacity of the state layer on hover. */
|
|
1728
|
+
hoverStateLayerOpacity: unsafeCSS("var(--md-sys-state-hover-state-layer-opacity, 8%)"),
|
|
1729
|
+
/** Opacity of the state layer on pressed. */
|
|
1730
|
+
pressedStateLayerOpacity: unsafeCSS("var(--md-sys-state-pressed-state-layer-opacity, 10%)")
|
|
1731
|
+
};
|
|
1732
|
+
|
|
1733
|
+
/** Design tokens that control typescale. */
|
|
1734
|
+
const TypescaleToken = {
|
|
1735
|
+
/** Standard typescale variant. */
|
|
1736
|
+
standard: {
|
|
1737
|
+
/** Short, important text or numerals. */
|
|
1738
|
+
display: {
|
|
1739
|
+
large: {
|
|
1740
|
+
fontSize: unsafeCSS("var(--md-sys-typescale-display-large-font-size, 3.5625rem)"),
|
|
1741
|
+
fontWeight: unsafeCSS("var(--md-sys-typescale-display-large-font-weight, 400)"),
|
|
1742
|
+
lineHeight: unsafeCSS("var(--md-sys-typescale-display-large-line-height, 4rem)"),
|
|
1743
|
+
tracking: unsafeCSS("var(--md-sys-typescale-display-large-tracking, 0.015625rem)")
|
|
1744
|
+
},
|
|
1745
|
+
medium: {
|
|
1746
|
+
fontSize: unsafeCSS("var(--md-sys-typescale-display-medium-font-size, 2.8125rem)"),
|
|
1747
|
+
fontWeight: unsafeCSS("var(--md-sys-typescale-display-medium-font-weight, 400)"),
|
|
1748
|
+
lineHeight: unsafeCSS("var(--md-sys-typescale-display-medium-line-height, 3.25rem)"),
|
|
1749
|
+
tracking: unsafeCSS("var(--md-sys-typescale-display-medium-tracking, 0)")
|
|
1750
|
+
},
|
|
1751
|
+
small: {
|
|
1752
|
+
fontSize: unsafeCSS("var(--md-sys-typescale-display-small-font-size, 2.25rem)"),
|
|
1753
|
+
fontWeight: unsafeCSS("var(--md-sys-typescale-display-small-font-weight, 400)"),
|
|
1754
|
+
lineHeight: unsafeCSS("var(--md-sys-typescale-display-small-line-height, 2.75rem)"),
|
|
1755
|
+
tracking: unsafeCSS("var(--md-sys-typescale-display-small-tracking, 0)")
|
|
1756
|
+
}
|
|
1757
|
+
},
|
|
1758
|
+
/** Short, high-emphasis text on smaller screens. */
|
|
1759
|
+
headline: {
|
|
1760
|
+
large: {
|
|
1761
|
+
fontSize: unsafeCSS("var(--md-sys-typescale-headline-large-font-size, 2rem)"),
|
|
1762
|
+
fontWeight: unsafeCSS("var(--md-sys-typescale-headline-large-font-weight, 400)"),
|
|
1763
|
+
lineHeight: unsafeCSS("var(--md-sys-typescale-headline-large-line-height, 2.5rem)"),
|
|
1764
|
+
tracking: unsafeCSS("var(--md-sys-typescale-headline-large-tracking, 0)")
|
|
1765
|
+
},
|
|
1766
|
+
medium: {
|
|
1767
|
+
fontSize: unsafeCSS("var(--md-sys-typescale-headline-medium-font-size, 1.75rem)"),
|
|
1768
|
+
fontWeight: unsafeCSS("var(--md-sys-typescale-headline-medium-font-weight, 400)"),
|
|
1769
|
+
lineHeight: unsafeCSS("var(--md-sys-typescale-headline-medium-line-height, 2.25rem)"),
|
|
1770
|
+
tracking: unsafeCSS("var(--md-sys-typescale-headline-medium-tracking, 0)")
|
|
1771
|
+
},
|
|
1772
|
+
small: {
|
|
1773
|
+
fontSize: unsafeCSS("var(--md-sys-typescale-headline-small-font-size, 1.5rem)"),
|
|
1774
|
+
fontWeight: unsafeCSS("var(--md-sys-typescale-headline-small-font-weight, 400)"),
|
|
1775
|
+
lineHeight: unsafeCSS("var(--md-sys-typescale-headline-small-line-height, 2rem)"),
|
|
1776
|
+
tracking: unsafeCSS("var(--md-sys-typescale-headline-small-tracking, 0)")
|
|
1777
|
+
}
|
|
1778
|
+
},
|
|
1779
|
+
/** Medium-emphasis text that remains relatively short. */
|
|
1780
|
+
title: {
|
|
1781
|
+
large: {
|
|
1782
|
+
fontSize: unsafeCSS("var(--md-sys-typescale-title-large-font-size, 1.375rem)"),
|
|
1783
|
+
fontWeight: unsafeCSS("var(--md-sys-typescale-title-large-font-weight, 400)"),
|
|
1784
|
+
lineHeight: unsafeCSS("var(--md-sys-typescale-title-large-line-height, 1.75rem)"),
|
|
1785
|
+
tracking: unsafeCSS("var(--md-sys-typescale-title-large-tracking, 0)")
|
|
1786
|
+
},
|
|
1787
|
+
medium: {
|
|
1788
|
+
fontSize: unsafeCSS("var(--md-sys-typescale-title-medium-font-size, 1rem)"),
|
|
1789
|
+
fontWeight: unsafeCSS("var(--md-sys-typescale-title-medium-font-weight, 500)"),
|
|
1790
|
+
lineHeight: unsafeCSS("var(--md-sys-typescale-title-medium-line-height, 1.5rem)"),
|
|
1791
|
+
tracking: unsafeCSS("var(--md-sys-typescale-title-medium-tracking, 0.009375rem)")
|
|
1792
|
+
},
|
|
1793
|
+
small: {
|
|
1794
|
+
fontSize: unsafeCSS("var(--md-sys-typescale-title-small-font-size, 0.875rem)"),
|
|
1795
|
+
fontWeight: unsafeCSS("var(--md-sys-typescale-title-small-font-weight, 500)"),
|
|
1796
|
+
lineHeight: unsafeCSS("var(--md-sys-typescale-title-small-line-height, 1.25rem)"),
|
|
1797
|
+
tracking: unsafeCSS("var(--md-sys-typescale-title-small-tracking, 0.00625rem)")
|
|
1798
|
+
}
|
|
1799
|
+
},
|
|
1800
|
+
/** Longer passages of text. */
|
|
1801
|
+
body: {
|
|
1802
|
+
large: {
|
|
1803
|
+
fontSize: unsafeCSS("var(--md-sys-typescale-body-large-font-size, 1rem)"),
|
|
1804
|
+
fontWeight: unsafeCSS("var(--md-sys-typescale-body-large-font-weight, 400)"),
|
|
1805
|
+
lineHeight: unsafeCSS("var(--md-sys-typescale-body-large-line-height, 1.5rem)"),
|
|
1806
|
+
tracking: unsafeCSS("var(--md-sys-typescale-body-large-tracking, 0.03125rem)")
|
|
1807
|
+
},
|
|
1808
|
+
medium: {
|
|
1809
|
+
fontSize: unsafeCSS("var(--md-sys-typescale-body-medium-font-size, 0.875rem)"),
|
|
1810
|
+
fontWeight: unsafeCSS("var(--md-sys-typescale-body-medium-font-weight, 400)"),
|
|
1811
|
+
lineHeight: unsafeCSS("var(--md-sys-typescale-body-medium-line-height, 1.25rem)"),
|
|
1812
|
+
tracking: unsafeCSS("var(--md-sys-typescale-body-medium-tracking, 0.015625rem)")
|
|
1813
|
+
},
|
|
1814
|
+
small: {
|
|
1815
|
+
fontSize: unsafeCSS("var(--md-sys-typescale-body-small-font-size, 0.75rem)"),
|
|
1816
|
+
fontWeight: unsafeCSS("var(--md-sys-typescale-body-small-font-weight, 400)"),
|
|
1817
|
+
lineHeight: unsafeCSS("var(--md-sys-typescale-body-small-line-height, 1rem)"),
|
|
1818
|
+
tracking: unsafeCSS("var(--md-sys-typescale-body-small-tracking, 0.025rem)")
|
|
1819
|
+
}
|
|
1820
|
+
},
|
|
1821
|
+
/** Smaller, utilitarian text. */
|
|
1822
|
+
label: {
|
|
1823
|
+
large: {
|
|
1824
|
+
fontSize: unsafeCSS("var(--md-sys-typescale-label-large-font-size, 0.875rem)"),
|
|
1825
|
+
fontWeight: unsafeCSS("var(--md-sys-typescale-label-large-font-weight, 500)"),
|
|
1826
|
+
lineHeight: unsafeCSS("var(--md-sys-typescale-label-large-line-height, 1.25rem)"),
|
|
1827
|
+
tracking: unsafeCSS("var(--md-sys-typescale-label-large-tracking, 0.00625rem)")
|
|
1828
|
+
},
|
|
1829
|
+
medium: {
|
|
1830
|
+
fontSize: unsafeCSS("var(--md-sys-typescale-label-medium-font-size, 0.75rem)"),
|
|
1831
|
+
fontWeight: unsafeCSS("var(--md-sys-typescale-label-medium-font-weight, 500)"),
|
|
1832
|
+
lineHeight: unsafeCSS("var(--md-sys-typescale-label-medium-line-height, 1rem)"),
|
|
1833
|
+
tracking: unsafeCSS("var(--md-sys-typescale-label-medium-tracking, 0.03125rem)")
|
|
1834
|
+
},
|
|
1835
|
+
small: {
|
|
1836
|
+
fontSize: unsafeCSS("var(--md-sys-typescale-label-small-font-size, 0.6875rem)"),
|
|
1837
|
+
fontWeight: unsafeCSS("var(--md-sys-typescale-label-small-font-weight, 500)"),
|
|
1838
|
+
lineHeight: unsafeCSS("var(--md-sys-typescale-label-small-line-height, 1rem)"),
|
|
1839
|
+
tracking: unsafeCSS("var(--md-sys-typescale-label-small-tracking, 0.03125rem)")
|
|
1840
|
+
}
|
|
1841
|
+
}
|
|
1842
|
+
},
|
|
1843
|
+
/** Emphasized typescale variant. */
|
|
1844
|
+
emphasized: {
|
|
1845
|
+
/** Short, important text or numerals. */
|
|
1846
|
+
display: {
|
|
1847
|
+
large: {
|
|
1848
|
+
fontSize: unsafeCSS("var(--md-sys-typescale-emphasized-display-large-font-size, 3.5625rem)"),
|
|
1849
|
+
fontWeight: unsafeCSS("var(--md-sys-typescale-emphasized-display-large-font-weight, 500)"),
|
|
1850
|
+
lineHeight: unsafeCSS("var(--md-sys-typescale-emphasized-display-large-line-height, 4rem)"),
|
|
1851
|
+
tracking: unsafeCSS("var(--md-sys-typescale-emphasized-display-large-tracking, 0.015625rem)")
|
|
1852
|
+
},
|
|
1853
|
+
medium: {
|
|
1854
|
+
fontSize: unsafeCSS("var(--md-sys-typescale-emphasized-display-medium-font-size, 2.8125rem)"),
|
|
1855
|
+
fontWeight: unsafeCSS("var(--md-sys-typescale-emphasized-display-medium-font-weight, 500)"),
|
|
1856
|
+
lineHeight: unsafeCSS("var(--md-sys-typescale-emphasized-display-medium-line-height, 3.25rem)"),
|
|
1857
|
+
tracking: unsafeCSS("var(--md-sys-typescale-emphasized-display-medium-tracking, 0)")
|
|
1858
|
+
},
|
|
1859
|
+
small: {
|
|
1860
|
+
fontSize: unsafeCSS("var(--md-sys-typescale-emphasized-display-small-font-size, 2.25rem)"),
|
|
1861
|
+
fontWeight: unsafeCSS("var(--md-sys-typescale-emphasized-display-small-font-weight, 500)"),
|
|
1862
|
+
lineHeight: unsafeCSS("var(--md-sys-typescale-emphasized-display-small-line-height, 2.75rem)"),
|
|
1863
|
+
tracking: unsafeCSS("var(--md-sys-typescale-emphasized-display-small-tracking, 0)")
|
|
1864
|
+
}
|
|
1865
|
+
},
|
|
1866
|
+
/** Short, high-emphasis text on smaller screens. */
|
|
1867
|
+
headline: {
|
|
1868
|
+
large: {
|
|
1869
|
+
fontSize: unsafeCSS("var(--md-sys-typescale-emphasized-headline-large-font-size, 2rem)"),
|
|
1870
|
+
fontWeight: unsafeCSS("var(--md-sys-typescale-emphasized-headline-large-font-weight, 500)"),
|
|
1871
|
+
lineHeight: unsafeCSS("var(--md-sys-typescale-emphasized-headline-large-line-height, 2.5rem)"),
|
|
1872
|
+
tracking: unsafeCSS("var(--md-sys-typescale-emphasized-headline-large-tracking, 0)")
|
|
1873
|
+
},
|
|
1874
|
+
medium: {
|
|
1875
|
+
fontSize: unsafeCSS("var(--md-sys-typescale-emphasized-headline-medium-font-size, 1.75rem)"),
|
|
1876
|
+
fontWeight: unsafeCSS("var(--md-sys-typescale-emphasized-headline-medium-font-weight, 500)"),
|
|
1877
|
+
lineHeight: unsafeCSS("var(--md-sys-typescale-emphasized-headline-medium-line-height, 2.25rem)"),
|
|
1878
|
+
tracking: unsafeCSS("var(--md-sys-typescale-emphasized-headline-medium-tracking, 0)")
|
|
1879
|
+
},
|
|
1880
|
+
small: {
|
|
1881
|
+
fontSize: unsafeCSS("var(--md-sys-typescale-emphasized-headline-small-font-size, 1.5rem)"),
|
|
1882
|
+
fontWeight: unsafeCSS("var(--md-sys-typescale-emphasized-headline-small-font-weight, 500)"),
|
|
1883
|
+
lineHeight: unsafeCSS("var(--md-sys-typescale-emphasized-headline-small-line-height, 2rem)"),
|
|
1884
|
+
tracking: unsafeCSS("var(--md-sys-typescale-emphasized-headline-small-tracking, 0)")
|
|
1885
|
+
}
|
|
1886
|
+
},
|
|
1887
|
+
/** Medium-emphasis text that remains relatively short. */
|
|
1888
|
+
title: {
|
|
1889
|
+
large: {
|
|
1890
|
+
fontSize: unsafeCSS("var(--md-sys-typescale-emphasized-title-large-font-size, 1.375rem)"),
|
|
1891
|
+
fontWeight: unsafeCSS("var(--md-sys-typescale-emphasized-title-large-font-weight, 500)"),
|
|
1892
|
+
lineHeight: unsafeCSS("var(--md-sys-typescale-emphasized-title-large-line-height, 1.75rem)"),
|
|
1893
|
+
tracking: unsafeCSS("var(--md-sys-typescale-emphasized-title-large-tracking, 0)")
|
|
1894
|
+
},
|
|
1895
|
+
medium: {
|
|
1896
|
+
fontSize: unsafeCSS("var(--md-sys-typescale-emphasized-title-medium-font-size, 1rem)"),
|
|
1897
|
+
fontWeight: unsafeCSS("var(--md-sys-typescale-emphasized-title-medium-font-weight, 700)"),
|
|
1898
|
+
lineHeight: unsafeCSS("var(--md-sys-typescale-emphasized-title-medium-line-height, 3.5rem)"),
|
|
1899
|
+
tracking: unsafeCSS("var(--md-sys-typescale-emphasized-title-medium-tracking, 0.009375rem)")
|
|
1900
|
+
},
|
|
1901
|
+
small: {
|
|
1902
|
+
fontSize: unsafeCSS("var(--md-sys-typescale-emphasized-title-small-font-size, 0.875rem)"),
|
|
1903
|
+
fontWeight: unsafeCSS("var(--md-sys-typescale-emphasized-title-small-font-weight, 700)"),
|
|
1904
|
+
lineHeight: unsafeCSS("var(--md-sys-typescale-emphasized-title-small-line-height, 1.25rem)"),
|
|
1905
|
+
tracking: unsafeCSS("var(--md-sys-typescale-emphasized-title-small-tracking, 0.00625rem)")
|
|
1906
|
+
}
|
|
1907
|
+
},
|
|
1908
|
+
/** Longer passages of text. */
|
|
1909
|
+
body: {
|
|
1910
|
+
large: {
|
|
1911
|
+
fontSize: unsafeCSS("var(--md-sys-typescale-emphasized-body-large-font-size, 1rem)"),
|
|
1912
|
+
fontWeight: unsafeCSS("var(--md-sys-typescale-emphasized-body-large-font-weight, 500)"),
|
|
1913
|
+
lineHeight: unsafeCSS("var(--md-sys-typescale-emphasized-body-large-line-height, 1.5rem)"),
|
|
1914
|
+
tracking: unsafeCSS("var(--md-sys-typescale-emphasized-body-large-tracking, 0.03125rem)")
|
|
1915
|
+
},
|
|
1916
|
+
medium: {
|
|
1917
|
+
fontSize: unsafeCSS("var(--md-sys-typescale-emphasized-body-medium-font-size, 0.875rem)"),
|
|
1918
|
+
fontWeight: unsafeCSS("var(--md-sys-typescale-emphasized-body-medium-font-weight, 500)"),
|
|
1919
|
+
lineHeight: unsafeCSS("var(--md-sys-typescale-emphasized-body-medium-line-height, 1.25rem)"),
|
|
1920
|
+
tracking: unsafeCSS("var(--md-sys-typescale-emphasized-body-medium-tracking, 0.015625rem)")
|
|
1921
|
+
},
|
|
1922
|
+
small: {
|
|
1923
|
+
fontSize: unsafeCSS("var(--md-sys-typescale-emphasized-body-small-font-size, 0.75rem)"),
|
|
1924
|
+
fontWeight: unsafeCSS("var(--md-sys-typescale-emphasized-body-small-font-weight, 500)"),
|
|
1925
|
+
lineHeight: unsafeCSS("var(--md-sys-typescale-emphasized-body-small-line-height, 1rem)"),
|
|
1926
|
+
tracking: unsafeCSS("var(--md-sys-typescale-emphasized-body-small-tracking, 0.025rem)")
|
|
1927
|
+
}
|
|
1928
|
+
},
|
|
1929
|
+
/** Smaller, utilitarian text. */
|
|
1930
|
+
label: {
|
|
1931
|
+
large: {
|
|
1932
|
+
fontSize: unsafeCSS("var(--md-sys-typescale-emphasized-label-large-font-size, 0.875rem)"),
|
|
1933
|
+
fontWeight: unsafeCSS("var(--md-sys-typescale-emphasized-label-large-font-weight, 700)"),
|
|
1934
|
+
lineHeight: unsafeCSS("var(--md-sys-typescale-emphasized-label-large-line-height, 1.25rem)"),
|
|
1935
|
+
tracking: unsafeCSS("var(--md-sys-typescale-emphasized-label-large-tracking, 0.00625rem)")
|
|
1936
|
+
},
|
|
1937
|
+
medium: {
|
|
1938
|
+
fontSize: unsafeCSS("var(--md-sys-typescale-emphasized-label-medium-font-size, 0.75rem)"),
|
|
1939
|
+
fontWeight: unsafeCSS("var(--md-sys-typescale-emphasized-label-medium-font-weight, 700)"),
|
|
1940
|
+
lineHeight: unsafeCSS("var(--md-sys-typescale-emphasized-label-medium-line-height, 1rem)"),
|
|
1941
|
+
tracking: unsafeCSS("var(--md-sys-typescale-emphasized-label-medium-tracking, 0.03125rem)")
|
|
1942
|
+
},
|
|
1943
|
+
small: {
|
|
1944
|
+
fontSize: unsafeCSS("var(--md-sys-typescale-emphasized-label-small-font-size, 0.6875rem)"),
|
|
1945
|
+
fontWeight: unsafeCSS("var(--md-sys-typescale-emphasized-label-small-font-weight, 700)"),
|
|
1946
|
+
lineHeight: unsafeCSS("var(--md-sys-typescale-emphasized-label-small-line-height, 1rem)"),
|
|
1947
|
+
tracking: unsafeCSS("var(--md-sys-typescale-emphasized-label-small-tracking, 0.03125rem)")
|
|
1948
|
+
}
|
|
1949
|
+
}
|
|
1950
|
+
}
|
|
1951
|
+
};
|
|
1952
|
+
|
|
1953
|
+
/** Design tokens used to style components. */
|
|
1954
|
+
const DesignToken = {
|
|
1955
|
+
/** Design tokens that control color. */
|
|
1956
|
+
color: ColorToken,
|
|
1957
|
+
/** Design tokens that control elevation. */
|
|
1958
|
+
elevation: ElevationToken$1,
|
|
1959
|
+
/** Design tokens that control motion. */
|
|
1960
|
+
motion: MotionToken,
|
|
1961
|
+
/** Design tokens that control shape. */
|
|
1962
|
+
shape: ShapeToken,
|
|
1963
|
+
/** Design tokens that control state layer. */
|
|
1964
|
+
state: StateToken,
|
|
1965
|
+
/** Design tokens that control typescale. */
|
|
1966
|
+
typescale: TypescaleToken,
|
|
1967
|
+
/** Design tokens that control scrollbars. */
|
|
1968
|
+
scrollbar: ScrollbarToken,
|
|
1969
|
+
/** Design tokens that control density. */
|
|
1970
|
+
density: DensityToken,
|
|
1971
|
+
/** Design tokens that control measurement. */
|
|
1972
|
+
measurement: MeasurementToken
|
|
1973
|
+
};
|
|
1974
|
+
|
|
1975
|
+
/**
|
|
1976
|
+
* Determines whether a value is a `DisabledMixin`.
|
|
1977
|
+
* @param {unknown} value The value to test.
|
|
1978
|
+
* @returns {value is DisabledMixin} Whether `value` is a `DisabledMixin`.
|
|
1979
|
+
*/
|
|
1980
|
+
function isDisabledMixin(value) {
|
|
1981
|
+
return hasKeys(value, "disabled");
|
|
1982
|
+
}
|
|
1983
|
+
/**
|
|
1984
|
+
* Mixin to augment an element with behavior that supports a disabled state.
|
|
1985
|
+
* @template T The type of the base class.
|
|
1986
|
+
* @param {T} base The base class.
|
|
1987
|
+
* @param {boolean} [reflect=true] Whether the disabled property is reflected as an attribute.
|
|
1988
|
+
* @returns {Constructor<DisabledMixin> & T} A constructor that implements `DisabledMixin`.
|
|
1989
|
+
*/
|
|
1990
|
+
function Disabled(base, reflect = true) {
|
|
1991
|
+
class _DisabledMixin extends base {
|
|
1992
|
+
constructor() {
|
|
1993
|
+
super(...arguments);
|
|
1994
|
+
/**
|
|
1995
|
+
* Whether the element is disabled.
|
|
1996
|
+
* @default false
|
|
1997
|
+
*/
|
|
1998
|
+
this.disabled = false;
|
|
1999
|
+
}
|
|
2000
|
+
/** @inheritdoc */
|
|
2001
|
+
update(changedProperties) {
|
|
2002
|
+
super.update(changedProperties);
|
|
2003
|
+
if (changedProperties.has("disabled") && this.role && this.role !== "none" && this.role !== "presentation") {
|
|
2004
|
+
this.ariaDisabled = this.disabled ? "true" : null;
|
|
2005
|
+
}
|
|
2006
|
+
}
|
|
2007
|
+
}
|
|
2008
|
+
__decorate([property({
|
|
2009
|
+
type: Boolean,
|
|
2010
|
+
reflect: reflect
|
|
2011
|
+
})], _DisabledMixin.prototype, "disabled", void 0);
|
|
2012
|
+
return _DisabledMixin;
|
|
2013
|
+
}
|
|
2014
|
+
|
|
2015
|
+
/**
|
|
2016
|
+
* Determines whether a value is a `HtmlForMixin`.
|
|
2017
|
+
* @param {unknown} value The value to test.
|
|
2018
|
+
* @returns {value is HtmlForMixin} Whether `value` is a `HtmlForMixin`.
|
|
2019
|
+
*/
|
|
2020
|
+
function isHtmlForMixin(value) {
|
|
2021
|
+
return hasKeys(value, "htmlFor", "control", "attach", "detach");
|
|
2022
|
+
}
|
|
2023
|
+
const _control = Symbol("_control");
|
|
2024
|
+
const _firstUpdated = Symbol("_firstUpdated");
|
|
2025
|
+
/**
|
|
2026
|
+
* Mixin that creates an attached element associated with an interactive control.
|
|
2027
|
+
* @template T The type of the base class.
|
|
2028
|
+
* @param {T} base The base class.
|
|
2029
|
+
* @returns {Constructor<HtmlForMixin> & T} A constructor extends `base` and implements `HtmlForMixin`.
|
|
2030
|
+
*/
|
|
2031
|
+
function HtmlFor(base) {
|
|
2032
|
+
var _a;
|
|
2033
|
+
class _HtmlForMixin extends base {
|
|
2034
|
+
constructor() {
|
|
2035
|
+
super(...arguments);
|
|
2036
|
+
/** @private */
|
|
2037
|
+
this[_a] = false;
|
|
2038
|
+
/** The identifier of the interactive control to which this element is attached. */
|
|
2039
|
+
this.htmlFor = null;
|
|
2040
|
+
}
|
|
2041
|
+
/** The interactive element to which this element is attached. */
|
|
2042
|
+
get control() {
|
|
2043
|
+
return this[_control]?.deref() ?? null;
|
|
2044
|
+
}
|
|
2045
|
+
/** @inheritdoc */
|
|
2046
|
+
connectedCallback() {
|
|
2047
|
+
super.connectedCallback();
|
|
2048
|
+
const control = this[_control]?.deref();
|
|
2049
|
+
if (control) {
|
|
2050
|
+
this.attach(control);
|
|
2051
|
+
}
|
|
2052
|
+
}
|
|
2053
|
+
/** @inheritdoc */
|
|
2054
|
+
disconnectedCallback() {
|
|
2055
|
+
super.disconnectedCallback();
|
|
2056
|
+
const control = this[_control];
|
|
2057
|
+
if (control) {
|
|
2058
|
+
this.detach();
|
|
2059
|
+
this[_control] = control;
|
|
2060
|
+
}
|
|
2061
|
+
}
|
|
2062
|
+
/** @inheritdoc */
|
|
2063
|
+
firstUpdated(_changedProperties) {
|
|
2064
|
+
super.firstUpdated(_changedProperties);
|
|
2065
|
+
this[_firstUpdated] = true;
|
|
2066
|
+
}
|
|
2067
|
+
/** @inheritdoc */
|
|
2068
|
+
update(changedProperties) {
|
|
2069
|
+
super.update(changedProperties);
|
|
2070
|
+
if (changedProperties.has("htmlFor")) {
|
|
2071
|
+
if (this.htmlFor) {
|
|
2072
|
+
const root = this.getRootNode();
|
|
2073
|
+
if (root) {
|
|
2074
|
+
resolveElementById(this.htmlFor, root).then(control => {
|
|
2075
|
+
if (control !== this.control) {
|
|
2076
|
+
if (this.control) {
|
|
2077
|
+
this.detach();
|
|
2078
|
+
}
|
|
2079
|
+
if (control instanceof HTMLElement) {
|
|
2080
|
+
this.attach(control);
|
|
2081
|
+
}
|
|
2082
|
+
}
|
|
2083
|
+
});
|
|
2084
|
+
}
|
|
2085
|
+
} else if (this.control && this[_firstUpdated]) {
|
|
2086
|
+
this.detach();
|
|
2087
|
+
}
|
|
2088
|
+
}
|
|
2089
|
+
}
|
|
2090
|
+
/**
|
|
2091
|
+
* Attaches the element to an interactive control.
|
|
2092
|
+
* @param {HTMLElement} control The element that controls the attachable element.
|
|
2093
|
+
*/
|
|
2094
|
+
attach(control) {
|
|
2095
|
+
this[_control] = new WeakRef(control);
|
|
2096
|
+
}
|
|
2097
|
+
/** Detaches the element from its current interactive control. */
|
|
2098
|
+
detach() {
|
|
2099
|
+
this[_control] = undefined;
|
|
2100
|
+
}
|
|
2101
|
+
}
|
|
2102
|
+
_a = _firstUpdated;
|
|
2103
|
+
__decorate([property({
|
|
2104
|
+
attribute: "for"
|
|
2105
|
+
})], _HtmlForMixin.prototype, "htmlFor", void 0);
|
|
2106
|
+
return _HtmlForMixin;
|
|
2107
|
+
}
|
|
2108
|
+
|
|
2109
|
+
/**
|
|
2110
|
+
* Mixin to augment an element with an ARIA role.
|
|
2111
|
+
* @template T The type of the base class.
|
|
2112
|
+
* @param {T} base The base class.
|
|
2113
|
+
* @param {ARIARole} role The ARIA role.
|
|
2114
|
+
* @returns {Constructor & T} A constructor that implements focusable behavior.
|
|
2115
|
+
*/
|
|
2116
|
+
function Role(base, role) {
|
|
2117
|
+
class _RoleMixin extends base {
|
|
2118
|
+
/** @inheritdoc */
|
|
2119
|
+
connectedCallback() {
|
|
2120
|
+
this.role = this.role || role;
|
|
2121
|
+
super.connectedCallback();
|
|
2122
|
+
}
|
|
2123
|
+
}
|
|
2124
|
+
return _RoleMixin;
|
|
2125
|
+
}
|
|
2126
|
+
|
|
2127
|
+
var _ActionElementBase_clickHandler;
|
|
2128
|
+
/**
|
|
2129
|
+
* A base implementation for an element, nested within a clickable element, used to
|
|
2130
|
+
* perform an action. This class must be inherited.
|
|
2131
|
+
*/
|
|
2132
|
+
class ActionElementBase extends LitElement {
|
|
2133
|
+
constructor() {
|
|
2134
|
+
super(...arguments);
|
|
2135
|
+
/** @private */
|
|
2136
|
+
_ActionElementBase_clickHandler.set(this, e => {
|
|
2137
|
+
if (!e.defaultPrevented) {
|
|
2138
|
+
this._onClick(e);
|
|
2139
|
+
}
|
|
2140
|
+
});
|
|
2141
|
+
}
|
|
2142
|
+
/** @inheritdoc */
|
|
2143
|
+
connectedCallback() {
|
|
2144
|
+
super.connectedCallback();
|
|
2145
|
+
this.parentElement?.addEventListener("click", __classPrivateFieldGet(this, _ActionElementBase_clickHandler, "f"));
|
|
2146
|
+
}
|
|
2147
|
+
/** @inheritdoc */
|
|
2148
|
+
disconnectedCallback() {
|
|
2149
|
+
super.disconnectedCallback();
|
|
2150
|
+
this.parentElement?.removeEventListener("click", __classPrivateFieldGet(this, _ActionElementBase_clickHandler, "f"));
|
|
2151
|
+
}
|
|
2152
|
+
/** @inheritdoc */
|
|
2153
|
+
render() {
|
|
2154
|
+
return html`<slot></slot>`;
|
|
2155
|
+
}
|
|
2156
|
+
}
|
|
2157
|
+
_ActionElementBase_clickHandler = new WeakMap();
|
|
2158
|
+
/** The styles of the element. */
|
|
2159
|
+
ActionElementBase.styles = css`:host { display: contents; } ::slotted(.material-icons) { font-size: inherit !important; }`;
|
|
2160
|
+
|
|
2161
|
+
/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */
|
|
2162
|
+
var _M3eCollapsibleElement_instances, _M3eCollapsibleElement_slotChanged, _M3eCollapsibleElement_hasOpened, _M3eCollapsibleElement_handleSlotChange, _M3eCollapsibleElement_autoSize, _M3eCollapsibleElement_clearSize, _M3eCollapsibleElement_actualSize;
|
|
2163
|
+
/**
|
|
2164
|
+
* A container used to expand and collapse content.
|
|
2165
|
+
*
|
|
2166
|
+
* @example
|
|
2167
|
+
* ```html
|
|
2168
|
+
* <m3e-collapsible>
|
|
2169
|
+
* <!-- Collapsible content -->
|
|
2170
|
+
* </m3e-collapsible>
|
|
2171
|
+
* ```
|
|
2172
|
+
*
|
|
2173
|
+
* @tag m3e-collapsible
|
|
2174
|
+
*
|
|
2175
|
+
* @slot - Renders the collapsible content.
|
|
2176
|
+
*
|
|
2177
|
+
* @attr open - Whether content is visible.
|
|
2178
|
+
* @attr orientation - Orientation of collapsible content.
|
|
2179
|
+
* @attr no-animate - Whether to disable animation.
|
|
2180
|
+
*
|
|
2181
|
+
* @fires opening - Dispatched when the collapsible begins to open.
|
|
2182
|
+
* @fires opened - Dispatched when the collapsible has opened.
|
|
2183
|
+
* @fires closing - Dispatched when the collapsible begins to close.
|
|
2184
|
+
* @fires closed - Dispatched when the collapsible has closed.
|
|
2185
|
+
*
|
|
2186
|
+
* @cssprop --m3e-collapsible-animation-duration - The duration of the expand / collapse animation.
|
|
2187
|
+
*/
|
|
2188
|
+
let M3eCollapsibleElement = class M3eCollapsibleElement extends AttachInternals(LitElement) {
|
|
2189
|
+
constructor() {
|
|
2190
|
+
super(...arguments);
|
|
2191
|
+
_M3eCollapsibleElement_instances.add(this);
|
|
2192
|
+
/** @private */
|
|
2193
|
+
_M3eCollapsibleElement_slotChanged.set(this, false);
|
|
2194
|
+
/** @private */
|
|
2195
|
+
_M3eCollapsibleElement_hasOpened.set(this, false);
|
|
2196
|
+
/**
|
|
2197
|
+
* Whether content is visible.
|
|
2198
|
+
* @default false
|
|
2199
|
+
*/
|
|
2200
|
+
this.open = false;
|
|
2201
|
+
/**
|
|
2202
|
+
* Orientation of collapsible content.
|
|
2203
|
+
* @default "vertical"
|
|
2204
|
+
*/
|
|
2205
|
+
this.orientation = "vertical";
|
|
2206
|
+
/**
|
|
2207
|
+
* Whether to disable animation.
|
|
2208
|
+
* @default false
|
|
2209
|
+
*/
|
|
2210
|
+
this.noAnimate = false;
|
|
2211
|
+
}
|
|
2212
|
+
/** @inheritdoc */
|
|
2213
|
+
update(changedProperties) {
|
|
2214
|
+
super.update(changedProperties);
|
|
2215
|
+
const noAnimate = this.noAnimate || changedProperties.has("orientation") && !changedProperties.has("open");
|
|
2216
|
+
addCustomState(this, "--no-animate");
|
|
2217
|
+
if (!__classPrivateFieldGet(this, _M3eCollapsibleElement_slotChanged, "f")) {
|
|
2218
|
+
if (this.open) {
|
|
2219
|
+
__classPrivateFieldSet(this, _M3eCollapsibleElement_hasOpened, true, "f");
|
|
2220
|
+
__classPrivateFieldGet(this, _M3eCollapsibleElement_instances, "m", _M3eCollapsibleElement_autoSize).call(this);
|
|
2221
|
+
}
|
|
2222
|
+
__classPrivateFieldSet(this, _M3eCollapsibleElement_slotChanged, true, "f");
|
|
2223
|
+
return;
|
|
2224
|
+
}
|
|
2225
|
+
this.toggleAttribute("inert", !this.open);
|
|
2226
|
+
if (this.open) {
|
|
2227
|
+
__classPrivateFieldSet(this, _M3eCollapsibleElement_hasOpened, true, "f");
|
|
2228
|
+
if (!(noAnimate || prefersReducedMotion())) {
|
|
2229
|
+
__classPrivateFieldGet(this, _M3eCollapsibleElement_instances, "m", _M3eCollapsibleElement_autoSize).call(this);
|
|
2230
|
+
setCustomState(this, "--overflows", this.orientation === "vertical" ? this.clientHeight < this.scrollHeight : this.orientation === "horizontal" ? this.clientWidth < this.scrollWidth : this.clientHeight < this.scrollHeight || this.clientWidth < this.scrollWidth);
|
|
2231
|
+
__classPrivateFieldGet(this, _M3eCollapsibleElement_instances, "m", _M3eCollapsibleElement_clearSize).call(this);
|
|
2232
|
+
}
|
|
2233
|
+
deleteCustomState(this, "--closing");
|
|
2234
|
+
addCustomState(this, "--opening");
|
|
2235
|
+
this.dispatchEvent(new Event("opening"));
|
|
2236
|
+
__classPrivateFieldGet(this, _M3eCollapsibleElement_instances, "m", _M3eCollapsibleElement_clearSize).call(this);
|
|
2237
|
+
deleteCustomState(this, "--no-animate");
|
|
2238
|
+
__classPrivateFieldGet(this, _M3eCollapsibleElement_instances, "m", _M3eCollapsibleElement_actualSize).call(this);
|
|
2239
|
+
if (noAnimate || prefersReducedMotion()) {
|
|
2240
|
+
__classPrivateFieldGet(this, _M3eCollapsibleElement_instances, "m", _M3eCollapsibleElement_autoSize).call(this);
|
|
2241
|
+
deleteCustomState(this, "--opening");
|
|
2242
|
+
this.dispatchEvent(new Event("opened"));
|
|
2243
|
+
} else {
|
|
2244
|
+
this.addEventListener("transitionend", () => {
|
|
2245
|
+
if (this.open) {
|
|
2246
|
+
__classPrivateFieldGet(this, _M3eCollapsibleElement_instances, "m", _M3eCollapsibleElement_autoSize).call(this);
|
|
2247
|
+
deleteCustomState(this, "--opening");
|
|
2248
|
+
this.dispatchEvent(new Event("opened"));
|
|
2249
|
+
}
|
|
2250
|
+
}, {
|
|
2251
|
+
once: true
|
|
2252
|
+
});
|
|
2253
|
+
}
|
|
2254
|
+
} else {
|
|
2255
|
+
deleteCustomState(this, "--opening");
|
|
2256
|
+
addCustomState(this, "--closing");
|
|
2257
|
+
this.dispatchEvent(new Event("closing"));
|
|
2258
|
+
__classPrivateFieldGet(this, _M3eCollapsibleElement_instances, "m", _M3eCollapsibleElement_actualSize).call(this);
|
|
2259
|
+
if (__classPrivateFieldGet(this, _M3eCollapsibleElement_hasOpened, "f")) {
|
|
2260
|
+
deleteCustomState(this, "--no-animate");
|
|
2261
|
+
}
|
|
2262
|
+
if (noAnimate || prefersReducedMotion()) {
|
|
2263
|
+
__classPrivateFieldGet(this, _M3eCollapsibleElement_instances, "m", _M3eCollapsibleElement_clearSize).call(this);
|
|
2264
|
+
deleteCustomState(this, "--closing");
|
|
2265
|
+
this.dispatchEvent(new Event("closed"));
|
|
2266
|
+
} else {
|
|
2267
|
+
requestAnimationFrame(() => {
|
|
2268
|
+
__classPrivateFieldGet(this, _M3eCollapsibleElement_instances, "m", _M3eCollapsibleElement_clearSize).call(this);
|
|
2269
|
+
this.addEventListener("transitionend", () => {
|
|
2270
|
+
if (!this.open) {
|
|
2271
|
+
deleteCustomState(this, "--closing");
|
|
2272
|
+
this.dispatchEvent(new Event("closed"));
|
|
2273
|
+
}
|
|
2274
|
+
}, {
|
|
2275
|
+
once: true
|
|
2276
|
+
});
|
|
2277
|
+
});
|
|
2278
|
+
}
|
|
2279
|
+
}
|
|
2280
|
+
}
|
|
2281
|
+
/** @inheritdoc */
|
|
2282
|
+
render() {
|
|
2283
|
+
return html`<slot @slotchange="${__classPrivateFieldGet(this, _M3eCollapsibleElement_instances, "m", _M3eCollapsibleElement_handleSlotChange)}"></slot>`;
|
|
2284
|
+
}
|
|
2285
|
+
};
|
|
2286
|
+
_M3eCollapsibleElement_slotChanged = new WeakMap();
|
|
2287
|
+
_M3eCollapsibleElement_hasOpened = new WeakMap();
|
|
2288
|
+
_M3eCollapsibleElement_instances = new WeakSet();
|
|
2289
|
+
_M3eCollapsibleElement_handleSlotChange = function _M3eCollapsibleElement_handleSlotChange() {
|
|
2290
|
+
__classPrivateFieldSet(this, _M3eCollapsibleElement_slotChanged, true, "f");
|
|
2291
|
+
};
|
|
2292
|
+
_M3eCollapsibleElement_autoSize = function _M3eCollapsibleElement_autoSize() {
|
|
2293
|
+
switch (this.orientation) {
|
|
2294
|
+
case "vertical":
|
|
2295
|
+
this.style.height = "auto";
|
|
2296
|
+
break;
|
|
2297
|
+
case "horizontal":
|
|
2298
|
+
this.style.width = "auto";
|
|
2299
|
+
break;
|
|
2300
|
+
case "both":
|
|
2301
|
+
this.style.height = this.style.width = "auto";
|
|
2302
|
+
break;
|
|
2303
|
+
}
|
|
2304
|
+
};
|
|
2305
|
+
_M3eCollapsibleElement_clearSize = function _M3eCollapsibleElement_clearSize() {
|
|
2306
|
+
switch (this.orientation) {
|
|
2307
|
+
case "vertical":
|
|
2308
|
+
this.style.height = "";
|
|
2309
|
+
break;
|
|
2310
|
+
case "horizontal":
|
|
2311
|
+
this.style.width = "";
|
|
2312
|
+
break;
|
|
2313
|
+
case "both":
|
|
2314
|
+
this.style.height = this.style.width = "";
|
|
2315
|
+
break;
|
|
2316
|
+
}
|
|
2317
|
+
};
|
|
2318
|
+
_M3eCollapsibleElement_actualSize = function _M3eCollapsibleElement_actualSize() {
|
|
2319
|
+
switch (this.orientation) {
|
|
2320
|
+
case "vertical":
|
|
2321
|
+
this.style.height = `${this.scrollHeight}px`;
|
|
2322
|
+
break;
|
|
2323
|
+
case "horizontal":
|
|
2324
|
+
this.style.width = `${this.scrollWidth}px`;
|
|
2325
|
+
break;
|
|
2326
|
+
case "both":
|
|
2327
|
+
this.style.height = `${this.scrollHeight}px`;
|
|
2328
|
+
this.style.width = `${this.scrollWidth}px`;
|
|
2329
|
+
break;
|
|
2330
|
+
}
|
|
2331
|
+
};
|
|
2332
|
+
/** The styles of the element. */
|
|
2333
|
+
M3eCollapsibleElement.styles = css`:host { display: block; overflow: hidden; } :host([orientation="vertical"]) { height: 0px; transition: ${unsafeCSS(`visibility var(--m3e-collapsible-animation-duration, ${DesignToken.motion.duration.medium1})
|
|
2334
|
+
${DesignToken.motion.easing.standard},
|
|
2335
|
+
height var(--m3e-collapsible-animation-duration, ${DesignToken.motion.duration.medium1})
|
|
2336
|
+
${DesignToken.motion.easing.standard},
|
|
2337
|
+
padding-top var(--m3e-collapsible-animation-duration, ${DesignToken.motion.duration.medium1})
|
|
2338
|
+
${DesignToken.motion.easing.standard},
|
|
2339
|
+
padding-bottom var(--m3e-collapsible-animation-duration, ${DesignToken.motion.duration.medium1})
|
|
2340
|
+
${DesignToken.motion.easing.standard}`)}; } :host([orientation="horizontal"]) { width: 0px; transition: ${unsafeCSS(`visibility var(--m3e-collapsible-animation-duration, ${DesignToken.motion.duration.medium1})
|
|
2341
|
+
${DesignToken.motion.easing.standard},
|
|
2342
|
+
width var(--m3e-collapsible-animation-duration, ${DesignToken.motion.duration.medium1})
|
|
2343
|
+
${DesignToken.motion.easing.standard},
|
|
2344
|
+
padding-left var(--m3e-collapsible-animation-duration, ${DesignToken.motion.duration.medium1})
|
|
2345
|
+
${DesignToken.motion.easing.standard},
|
|
2346
|
+
padding-right var(--m3e-collapsible-animation-duration, ${DesignToken.motion.duration.medium1})
|
|
2347
|
+
${DesignToken.motion.easing.standard}`)}; } :host([orientation="both"]) { height: 0px; width: 0px; transition: ${unsafeCSS(`visibility var(--m3e-collapsible-animation-duration, ${DesignToken.motion.duration.medium1})
|
|
2348
|
+
${DesignToken.motion.easing.standard},
|
|
2349
|
+
width var(--m3e-collapsible-animation-duration, ${DesignToken.motion.duration.medium1})
|
|
2350
|
+
${DesignToken.motion.easing.standard},
|
|
2351
|
+
height var(--m3e-collapsible-animation-duration, ${DesignToken.motion.duration.medium1})
|
|
2352
|
+
${DesignToken.motion.easing.standard},
|
|
2353
|
+
padding var(--m3e-collapsible-animation-duration, ${DesignToken.motion.duration.medium1})
|
|
2354
|
+
${DesignToken.motion.easing.standard}`)}; } :host(:not(:is(:state(--closing), :--closing)):not([open])) { visibility: hidden; } :host([orientation="vertical"]:not([open])) { min-height: unset !important; padding-top: 0px !important; padding-bottom: 0px !important; } :host([orientation="horizontal"]:not([open])) { min-width: unset !important; padding-left: 0px !important; padding-right: 0px !important; } :host([orientation="both"]:not([open])) { min-height: unset !important; min-width: unset !important; padding: 0px !important; } :host([no-animate]), :host(:is(:state(--no-animate), :--no-animate)) { transition-duration: 0ms; } :host([orientation="vertical"]:is(:state(--opening), :--opening)), :host([orientation="vertical"]:is(:state(--closing), :--closing)) { overflow-y: hidden !important; } :host([orientation="horizontal"]:is(:state(--opening), :--opening)), :host([orientation="horizontal"]:is(:state(--closing), :--closing)) { overflow-x: hidden !important; } :host([orientation="both"]:is(:state(--opening), :--opening)), :host([orientation="both"]:is(:state(--closing), :--closing)) { overflow-y: hidden !important; overflow-x: hidden !important; } :host(:is(:state(--overflows), :--overflows)) { scrollbar-gutter: stable; } ::slotted(*) { --m3e-collapsible-animation-duration: initial; } @media (prefers-reduced-motion) { :host { transition: none; } }`;
|
|
2355
|
+
__decorate([property({
|
|
2356
|
+
type: Boolean,
|
|
2357
|
+
reflect: true
|
|
2358
|
+
})], M3eCollapsibleElement.prototype, "open", void 0);
|
|
2359
|
+
__decorate([property({
|
|
2360
|
+
reflect: true
|
|
2361
|
+
})], M3eCollapsibleElement.prototype, "orientation", void 0);
|
|
2362
|
+
__decorate([property({
|
|
2363
|
+
attribute: "no-animate",
|
|
2364
|
+
type: Boolean,
|
|
2365
|
+
reflect: true
|
|
2366
|
+
})], M3eCollapsibleElement.prototype, "noAnimate", void 0);
|
|
2367
|
+
M3eCollapsibleElement = __decorate([customElement("m3e-collapsible")], M3eCollapsibleElement);
|
|
2368
|
+
|
|
2369
|
+
/**
|
|
2370
|
+
* Component design tokens that control the `M3eElevationElement`.
|
|
2371
|
+
* @internal
|
|
2372
|
+
*/
|
|
2373
|
+
const ElevationToken = {
|
|
2374
|
+
liftDuration: unsafeCSS(`var(--m3e-elevation-lift-duration, ${DesignToken.motion.duration.short4})`),
|
|
2375
|
+
liftEasing: unsafeCSS(`var(--m3e-elevation-lift-easing, ${DesignToken.motion.easing.standard})`),
|
|
2376
|
+
settleDuration: unsafeCSS(`var(--m3e-elevation-settle-duration, ${DesignToken.motion.duration.short3})`),
|
|
2377
|
+
settleEasing: unsafeCSS(`var(--m3e-elevation-settle-easing, ${DesignToken.motion.easing.standardAccelerate})`),
|
|
2378
|
+
level: unsafeCSS(`var(--m3e-elevation-level, ${DesignToken.elevation.level0})`),
|
|
2379
|
+
hoverLevel: unsafeCSS(`var(--m3e-elevation-hover-level, ${DesignToken.elevation.level0})`),
|
|
2380
|
+
focusLevel: unsafeCSS(`var(--m3e-elevation-focus-level, ${DesignToken.elevation.level0})`),
|
|
2381
|
+
pressedLevel: unsafeCSS(`var(--m3e-elevation-pressed-level, ${DesignToken.elevation.level0})`)
|
|
2382
|
+
};
|
|
2383
|
+
|
|
2384
|
+
var _M3eElevationElement_instances, _M3eElevationElement_hoverController, _M3eElevationElement_focusController, _M3eElevationElement_pressedController, _M3eElevationElement_handleHoverChange, _M3eElevationElement_handleFocusChange, _M3eElevationElement_handlePressedChange;
|
|
2385
|
+
/**
|
|
2386
|
+
* Visually depicts elevation using a shadow.
|
|
2387
|
+
*
|
|
2388
|
+
* @description
|
|
2389
|
+
* The `m3e-elevation` component is an absolute positioned element used to depict elevation using a shadow.
|
|
2390
|
+
* The parenting element must be a relative positioned element and allow for overflow. Use the `level` attribute
|
|
2391
|
+
* to specify the elevation level.
|
|
2392
|
+
*
|
|
2393
|
+
* The component can also be attached to another element using the `for` attribute. When attached, elevation will
|
|
2394
|
+
* be lifted by 1 level on hover. This can be disabled using the `disabled` attribute.
|
|
2395
|
+
*
|
|
2396
|
+
* Alternatively, use the `attach` and `detach` methods to programmatically attach and detach this element to another.
|
|
2397
|
+
*
|
|
2398
|
+
* @example
|
|
2399
|
+
* The following example illustrates basic markup. Note how the parenting element's position is `relative`. A parenting
|
|
2400
|
+
* element's position must be `relative` and overflow must be visible.
|
|
2401
|
+
*
|
|
2402
|
+
* ```html
|
|
2403
|
+
* <div style="position: relative;">
|
|
2404
|
+
* <m3e-elevation level="1"></m3e-elevation>
|
|
2405
|
+
* <div>
|
|
2406
|
+
* ```
|
|
2407
|
+
* @example
|
|
2408
|
+
* The following example illustrates attaching elevation to an interactive element. In this example, the parenting div
|
|
2409
|
+
* is given an `id` referenced by `m3e-elevation` using the `for` attribute. Note that `#myDiv` is not used when
|
|
2410
|
+
* specifying the attached element's identifier. The `#` is inferred.
|
|
2411
|
+
*
|
|
2412
|
+
* ```html
|
|
2413
|
+
* <div id="myDiv" style="position: relative;">
|
|
2414
|
+
* <m3e-elevation for="myDiv" level="1"></m3e-elevation>
|
|
2415
|
+
* <div>
|
|
2416
|
+
* ```
|
|
2417
|
+
*
|
|
2418
|
+
* @tag m3e-elevation
|
|
2419
|
+
*
|
|
2420
|
+
* @attr disabled - Whether hover and press events will not trigger changes in elevation, when attached to an interactive element.
|
|
2421
|
+
* @attr for - The identifier of the interactive control to which this element is attached.
|
|
2422
|
+
* @attr level - The level at which to visually depict elevation.
|
|
2423
|
+
*
|
|
2424
|
+
* @cssprop --m3e-elevation-color - Color used to depict elevation.
|
|
2425
|
+
* @cssprop --m3e-elevation-lift-duration - Duration when lifting.
|
|
2426
|
+
* @cssprop --m3e-elevation-lift-easing - Easing curve when lifting.
|
|
2427
|
+
* @cssprop --m3e-elevation-settle-duration - Duration when settling.
|
|
2428
|
+
* @cssprop --m3e-elevation-settle-easing - Easing curve when settling.
|
|
2429
|
+
* @cssprop --m3e-elevation-level - Elevation when resting (box-shadow).
|
|
2430
|
+
* @cssprop --m3e-elevation-hover-level - Elevation on hover (box-shadow).
|
|
2431
|
+
* @cssprop --m3e-elevation-focus-level - Elevation on focus (box-shadow).
|
|
2432
|
+
* @cssprop --m3e-elevation-pressed-level - Elevation on pressed (box-shadow).
|
|
2433
|
+
*/
|
|
2434
|
+
let M3eElevationElement = class M3eElevationElement extends HtmlFor(Role(LitElement, "none")) {
|
|
2435
|
+
constructor() {
|
|
2436
|
+
super(...arguments);
|
|
2437
|
+
_M3eElevationElement_instances.add(this);
|
|
2438
|
+
/** @private */
|
|
2439
|
+
_M3eElevationElement_hoverController.set(this, new HoverController(this, {
|
|
2440
|
+
target: null,
|
|
2441
|
+
callback: hovering => __classPrivateFieldGet(this, _M3eElevationElement_instances, "m", _M3eElevationElement_handleHoverChange).call(this, hovering)
|
|
2442
|
+
}));
|
|
2443
|
+
/** @private */
|
|
2444
|
+
_M3eElevationElement_focusController.set(this, new FocusController(this, {
|
|
2445
|
+
target: null,
|
|
2446
|
+
callback: focused => __classPrivateFieldGet(this, _M3eElevationElement_instances, "m", _M3eElevationElement_handleFocusChange).call(this, focused)
|
|
2447
|
+
}));
|
|
2448
|
+
/** @private */
|
|
2449
|
+
_M3eElevationElement_pressedController.set(this, new PressedController(this, {
|
|
2450
|
+
target: null,
|
|
2451
|
+
callback: pressed => __classPrivateFieldGet(this, _M3eElevationElement_instances, "m", _M3eElevationElement_handlePressedChange).call(this, pressed)
|
|
2452
|
+
}));
|
|
2453
|
+
/**
|
|
2454
|
+
* Whether hover and press events will not trigger changes in elevation, when attached to an interactive element.
|
|
2455
|
+
* @default false
|
|
2456
|
+
*/
|
|
2457
|
+
this.disabled = false;
|
|
2458
|
+
/**
|
|
2459
|
+
* The level at which to visually depict elevation.
|
|
2460
|
+
* @default null
|
|
2461
|
+
*/
|
|
2462
|
+
this.level = null;
|
|
2463
|
+
}
|
|
2464
|
+
/** @inheritdoc */
|
|
2465
|
+
attach(control) {
|
|
2466
|
+
super.attach(control);
|
|
2467
|
+
__classPrivateFieldGet(this, _M3eElevationElement_hoverController, "f").observe(control);
|
|
2468
|
+
__classPrivateFieldGet(this, _M3eElevationElement_focusController, "f").observe(control);
|
|
2469
|
+
__classPrivateFieldGet(this, _M3eElevationElement_pressedController, "f").observe(control);
|
|
2470
|
+
}
|
|
2471
|
+
/** @inheritdoc */
|
|
2472
|
+
detach() {
|
|
2473
|
+
if (this.control) {
|
|
2474
|
+
__classPrivateFieldGet(this, _M3eElevationElement_hoverController, "f").unobserve(this.control);
|
|
2475
|
+
__classPrivateFieldGet(this, _M3eElevationElement_focusController, "f").unobserve(this.control);
|
|
2476
|
+
__classPrivateFieldGet(this, _M3eElevationElement_pressedController, "f").unobserve(this.control);
|
|
2477
|
+
}
|
|
2478
|
+
super.detach();
|
|
2479
|
+
}
|
|
2480
|
+
/** @inheritdoc */
|
|
2481
|
+
connectedCallback() {
|
|
2482
|
+
this.ariaHidden = "true";
|
|
2483
|
+
super.connectedCallback();
|
|
2484
|
+
}
|
|
2485
|
+
/** @inheritdoc */
|
|
2486
|
+
disconnectedCallback() {
|
|
2487
|
+
super.disconnectedCallback();
|
|
2488
|
+
this._shadow?.classList.toggle("hover", false);
|
|
2489
|
+
this._shadow?.classList.toggle("focus", false);
|
|
2490
|
+
this._shadow?.classList.toggle("pressed", false);
|
|
2491
|
+
this._shadow?.classList.toggle("resting", false);
|
|
2492
|
+
}
|
|
2493
|
+
/** @inheritdoc */
|
|
2494
|
+
updated(_changedProperties) {
|
|
2495
|
+
super.updated(_changedProperties);
|
|
2496
|
+
if (_changedProperties.has("disabled") && this.disabled) {
|
|
2497
|
+
this._shadow?.classList.toggle("hover", false);
|
|
2498
|
+
this._shadow?.classList.toggle("focus", false);
|
|
2499
|
+
this._shadow?.classList.toggle("pressed", false);
|
|
2500
|
+
this._shadow?.classList.toggle("resting", true);
|
|
2501
|
+
}
|
|
2502
|
+
}
|
|
2503
|
+
/** @inheritdoc */
|
|
2504
|
+
render() {
|
|
2505
|
+
return html`<div class="shadow"></div>`;
|
|
2506
|
+
}
|
|
2507
|
+
};
|
|
2508
|
+
_M3eElevationElement_hoverController = new WeakMap();
|
|
2509
|
+
_M3eElevationElement_focusController = new WeakMap();
|
|
2510
|
+
_M3eElevationElement_pressedController = new WeakMap();
|
|
2511
|
+
_M3eElevationElement_instances = new WeakSet();
|
|
2512
|
+
_M3eElevationElement_handleHoverChange = function _M3eElevationElement_handleHoverChange(hovering) {
|
|
2513
|
+
if (!this.disabled) {
|
|
2514
|
+
this._shadow?.classList.toggle("hover", hovering);
|
|
2515
|
+
this._shadow?.classList.toggle("resting", !hovering);
|
|
2516
|
+
}
|
|
2517
|
+
};
|
|
2518
|
+
_M3eElevationElement_handleFocusChange = function _M3eElevationElement_handleFocusChange(focused) {
|
|
2519
|
+
if (!this.disabled) {
|
|
2520
|
+
this._shadow?.classList.toggle("focus", focused);
|
|
2521
|
+
}
|
|
2522
|
+
};
|
|
2523
|
+
_M3eElevationElement_handlePressedChange = function _M3eElevationElement_handlePressedChange(pressed) {
|
|
2524
|
+
if (!this.disabled) {
|
|
2525
|
+
this._shadow?.classList.toggle("pressed", pressed);
|
|
2526
|
+
}
|
|
2527
|
+
};
|
|
2528
|
+
/** The styles of the element. */
|
|
2529
|
+
M3eElevationElement.styles = css`:host { display: block; } :host, .shadow { position: absolute; left: 0; top: 0; right: 0; bottom: 0; pointer-events: none; border-radius: inherit; } .shadow.resting, .shadow.focus, .shadow.pressed { will-change: box-shadow; transition: ${unsafeCSS(`box-shadow ${ElevationToken.settleDuration} ${ElevationToken.settleEasing};`)}; } .shadow.hover { will-change: box-shadow; transition: ${unsafeCSS(`box-shadow ${ElevationToken.liftDuration} ${ElevationToken.liftEasing};`)}; } .shadow { box-shadow: ${ElevationToken.level}; } .shadow.focus { box-shadow: ${ElevationToken.focusLevel}; } .shadow.hover { box-shadow: ${ElevationToken.hoverLevel}; } .shadow.pressed { box-shadow: ${ElevationToken.pressedLevel}; } :host([level="0"]) .shadow { --m3e-elevation-level: ${DesignToken.elevation.level0}; --m3e-elevation-hover-level: ${DesignToken.elevation.level1}; } :host([level="1"]) .shadow { --m3e-elevation-level: ${DesignToken.elevation.level1}; --m3e-elevation-hover-level: ${DesignToken.elevation.level2}; } :host([level="2"]) .shadow { --m3e-elevation-level: ${DesignToken.elevation.level2}; --m3e-elevation-hover-level: ${DesignToken.elevation.level3}; } :host([level="3"]) .shadow { --m3e-elevation-level: ${DesignToken.elevation.level3}; --m3e-elevation-hover-level: ${DesignToken.elevation.level4}; } :host([level="4"]) .shadow { --m3e-elevation-level: ${DesignToken.elevation.level4}; --m3e-elevation-hover-level: ${DesignToken.elevation.level5}; } :host([level="5"]) .shadow { --m3e-elevation-level: ${DesignToken.elevation.level5}; --m3e-elevation-hover-level: ${ElevationToken.level}; } :host([level]) .shadow { --m3e-elevation-focus-level: ${ElevationToken.level}; --m3e-elevation-pressed-level: ${ElevationToken.level}; } @media (prefers-reduced-motion) { .shadow.resting, .shadow.pressed, .shadow.focus, .shadow.hover { transition: none; } } @media (forced-colors: active) { .shadow { display: none; } }`;
|
|
2530
|
+
__decorate([query(".shadow")], M3eElevationElement.prototype, "_shadow", void 0);
|
|
2531
|
+
__decorate([property({
|
|
2532
|
+
type: Boolean,
|
|
2533
|
+
reflect: true
|
|
2534
|
+
})], M3eElevationElement.prototype, "disabled", void 0);
|
|
2535
|
+
__decorate([property({
|
|
2536
|
+
type: Number,
|
|
2537
|
+
reflect: true
|
|
2538
|
+
})], M3eElevationElement.prototype, "level", void 0);
|
|
2539
|
+
M3eElevationElement = __decorate([customElement("m3e-elevation")], M3eElevationElement);
|
|
2540
|
+
|
|
2541
|
+
/**
|
|
2542
|
+
* Component design tokens that control the `M3eFocusRingElement`.
|
|
2543
|
+
* @internal
|
|
2544
|
+
*/
|
|
2545
|
+
const FocusRingToken = {
|
|
2546
|
+
/** The color of the focus ring. */
|
|
2547
|
+
color: unsafeCSS(`var(--m3e-focus-ring-color, ${DesignToken.color.secondary})`),
|
|
2548
|
+
/** The duration of the focus ring animation. */
|
|
2549
|
+
duration: unsafeCSS(`var(--m3e-focus-ring-duration, ${DesignToken.motion.duration.long2})`),
|
|
2550
|
+
/** The thickness of the focus ring. */
|
|
2551
|
+
thickness: unsafeCSS("var(--m3e-focus-ring-thickness, 3px)"),
|
|
2552
|
+
/** Offset of an outward focus ring. */
|
|
2553
|
+
outwardOffset: unsafeCSS("var(--m3e-focus-ring-outward-offset, 2px)"),
|
|
2554
|
+
/** Offset of an inward focus ring. */
|
|
2555
|
+
inwardOffset: unsafeCSS("var(--m3e-focus-ring-inward-offset, 0px)"),
|
|
2556
|
+
/** The visibility of the focus ring. */
|
|
2557
|
+
visibility: unsafeCSS("var(--m3e-focus-ring-visibility, visible)"),
|
|
2558
|
+
/** The factor by which the focus ring grows. */
|
|
2559
|
+
growthFactor: unsafeCSS("var(--m3e-focus-ring-growth-factor, 2)")
|
|
2560
|
+
};
|
|
2561
|
+
|
|
2562
|
+
var _M3eFocusRingElement_instances, _M3eFocusRingElement_focusController, _M3eFocusRingElement_handleFocusChange;
|
|
2563
|
+
/**
|
|
2564
|
+
* A focus ring used to depict a strong focus indicator.
|
|
2565
|
+
*
|
|
2566
|
+
* @description
|
|
2567
|
+
* The `m3e-focus-ring` component is an absolute positioned element used to provide a strong focus indicator.
|
|
2568
|
+
* The parenting element must be a relative positioned focusable element and allow for overflow.
|
|
2569
|
+
*
|
|
2570
|
+
* The component can be attached to an interactive element using the `for` attribute or programmatically using the `attach` method.
|
|
2571
|
+
* The focus ring is displayed when the interactive element receives visible focus and hidden when focus is lost.
|
|
2572
|
+
* This can be disabled using the `disabled` attribute.
|
|
2573
|
+
*
|
|
2574
|
+
* Alternatively, you can use the `show` and `hide` methods to programmatically control the focus ring.
|
|
2575
|
+
*
|
|
2576
|
+
* @example
|
|
2577
|
+
* The following example illustrates attaching a focus ring to an interactive element. In this example, the parenting div
|
|
2578
|
+
* has relative positioning and is given an `id` referenced by `m3e-focus-ring` using the `for` attribute. Note that `#myDiv`
|
|
2579
|
+
* is not used when specifying the attached element's identifier. The `#` is inferred.
|
|
2580
|
+
*
|
|
2581
|
+
* ```html
|
|
2582
|
+
* <div id="myDiv" tabindex="0" style="position: relative;">
|
|
2583
|
+
* <m3e-focus-ring for="myDiv"></m3e-focus-ring>
|
|
2584
|
+
* <div>
|
|
2585
|
+
* ```
|
|
2586
|
+
*
|
|
2587
|
+
* @tag m3e-focus-ring
|
|
2588
|
+
*
|
|
2589
|
+
* @attr disabled - Whether the focus events will not trigger the focus ring. Focus rings can be still controlled manually by using the `show` and `hide` methods.
|
|
2590
|
+
* @attr inward - Whether the focus ring animates inward instead of outward.
|
|
2591
|
+
*
|
|
2592
|
+
* @cssprop --m3e-focus-ring-color - The color of the focus ring.
|
|
2593
|
+
* @cssprop --m3e-focus-ring-duration - The duration of the focus ring animation.
|
|
2594
|
+
* @cssprop --m3e-focus-ring-growth-factor - The factor by which the focus ring grows.
|
|
2595
|
+
* @cssprop --m3e-focus-ring-thickness - The thickness of the focus ring.
|
|
2596
|
+
* @cssprop --m3e-focus-ring-visibility - The visibility of the focus ring.
|
|
2597
|
+
* @cssprop --m3e-focus-ring-outward-offset - Offset of an outward focus ring.
|
|
2598
|
+
* @cssprop --m3e-focus-ring-inward-offset - Offset of an inward focus ring.
|
|
2599
|
+
*/
|
|
2600
|
+
let M3eFocusRingElement = class M3eFocusRingElement extends HtmlFor(Role(LitElement, "none")) {
|
|
2601
|
+
constructor() {
|
|
2602
|
+
super(...arguments);
|
|
2603
|
+
_M3eFocusRingElement_instances.add(this);
|
|
2604
|
+
/** @private */
|
|
2605
|
+
_M3eFocusRingElement_focusController.set(this, new FocusController(this, {
|
|
2606
|
+
target: null,
|
|
2607
|
+
callback: (_, focusVisible) => __classPrivateFieldGet(this, _M3eFocusRingElement_instances, "m", _M3eFocusRingElement_handleFocusChange).call(this, focusVisible)
|
|
2608
|
+
}));
|
|
2609
|
+
/**
|
|
2610
|
+
* Whether the focus ring animates inward instead of outward.
|
|
2611
|
+
* @default false
|
|
2612
|
+
*/
|
|
2613
|
+
this.inward = false;
|
|
2614
|
+
/**
|
|
2615
|
+
* Whether the focus events will not trigger the focus ring.
|
|
2616
|
+
* Focus rings can be still controlled manually by using the `show` and `hide` methods.
|
|
2617
|
+
* @default false
|
|
2618
|
+
*/
|
|
2619
|
+
this.disabled = false;
|
|
2620
|
+
}
|
|
2621
|
+
/** Launches a manual focus ring. */
|
|
2622
|
+
show() {
|
|
2623
|
+
this._outline?.classList.toggle("visible", true);
|
|
2624
|
+
}
|
|
2625
|
+
/** Hides the focus ring. */
|
|
2626
|
+
hide() {
|
|
2627
|
+
this._outline?.classList.toggle("visible", false);
|
|
2628
|
+
}
|
|
2629
|
+
/** @inheritdoc */
|
|
2630
|
+
attach(control) {
|
|
2631
|
+
super.attach(control);
|
|
2632
|
+
__classPrivateFieldGet(this, _M3eFocusRingElement_focusController, "f").observe(control);
|
|
2633
|
+
}
|
|
2634
|
+
/** @inheritdoc */
|
|
2635
|
+
detach() {
|
|
2636
|
+
if (this.control) {
|
|
2637
|
+
__classPrivateFieldGet(this, _M3eFocusRingElement_focusController, "f").unobserve(this.control);
|
|
2638
|
+
}
|
|
2639
|
+
super.detach();
|
|
2640
|
+
}
|
|
2641
|
+
/** @inheritdoc */
|
|
2642
|
+
connectedCallback() {
|
|
2643
|
+
this.ariaHidden = "true";
|
|
2644
|
+
super.connectedCallback();
|
|
2645
|
+
}
|
|
2646
|
+
/** @inheritdoc */
|
|
2647
|
+
disconnectedCallback() {
|
|
2648
|
+
super.disconnectedCallback();
|
|
2649
|
+
this.hide();
|
|
2650
|
+
}
|
|
2651
|
+
/** @inheritdoc */
|
|
2652
|
+
render() {
|
|
2653
|
+
return html`<div class="outline"></div>`;
|
|
2654
|
+
}
|
|
2655
|
+
/** @inheritdoc */
|
|
2656
|
+
updated(_changedProperties) {
|
|
2657
|
+
super.updated(_changedProperties);
|
|
2658
|
+
if (_changedProperties.has("disabled") && this.disabled) {
|
|
2659
|
+
this.hide();
|
|
2660
|
+
}
|
|
2661
|
+
}
|
|
2662
|
+
};
|
|
2663
|
+
_M3eFocusRingElement_focusController = new WeakMap();
|
|
2664
|
+
_M3eFocusRingElement_instances = new WeakSet();
|
|
2665
|
+
_M3eFocusRingElement_handleFocusChange = function _M3eFocusRingElement_handleFocusChange(focusVisible) {
|
|
2666
|
+
if (!this.disabled) {
|
|
2667
|
+
if (focusVisible) {
|
|
2668
|
+
this.show();
|
|
2669
|
+
} else {
|
|
2670
|
+
this.hide();
|
|
2671
|
+
}
|
|
2672
|
+
}
|
|
2673
|
+
};
|
|
2674
|
+
/** The styles of the element. */
|
|
2675
|
+
M3eFocusRingElement.styles = css`:host { display: block; position: absolute; left: 0; top: 0; right: 0; bottom: 0; pointer-events: none; border-radius: inherit; outline: none; } .outline { contain: layout style; position: absolute; left: 0; top: 0; right: 0; bottom: 0; pointer-events: none; border-radius: inherit; z-index: 1; outline-color: ${FocusRingToken.color}; outline-width: ${FocusRingToken.thickness}; visibility: ${FocusRingToken.visibility}; } .outline.visible { outline-style: solid; } :host(:not([inward])) .outline { outline-offset: ${FocusRingToken.outwardOffset}; } :host([inward]) .outline { outline-offset: calc(${FocusRingToken.inwardOffset} - ${FocusRingToken.thickness}); } :host(:not([inward])) .outline.visible { animation: grow-shrink ${FocusRingToken.duration}; } :host([inward]) .outline.visible { animation: shrink-grow ${FocusRingToken.duration}; } @keyframes grow-shrink { 50% { outline-width: calc(${FocusRingToken.thickness} * ${FocusRingToken.growthFactor}); } } @keyframes shrink-grow { 50% { outline-offset: calc( ${FocusRingToken.inwardOffset} - calc(${FocusRingToken.thickness} * ${FocusRingToken.growthFactor}) ); outline-width: calc(${FocusRingToken.thickness} * ${FocusRingToken.growthFactor}); } } @media (prefers-reduced-motion) { :host(:not([inward])) .outline.visible, :host([inward]) .outline.visible { animation: none; } } @media (forced-colors: active) { .outline { outline-color: Highlight; } }`;
|
|
2676
|
+
__decorate([query(".outline")], M3eFocusRingElement.prototype, "_outline", void 0);
|
|
2677
|
+
__decorate([property({
|
|
2678
|
+
type: Boolean,
|
|
2679
|
+
reflect: true
|
|
2680
|
+
})], M3eFocusRingElement.prototype, "inward", void 0);
|
|
2681
|
+
__decorate([property({
|
|
2682
|
+
type: Boolean,
|
|
2683
|
+
reflect: true
|
|
2684
|
+
})], M3eFocusRingElement.prototype, "disabled", void 0);
|
|
2685
|
+
M3eFocusRingElement = __decorate([customElement("m3e-focus-ring")], M3eFocusRingElement);
|
|
2686
|
+
|
|
2687
|
+
/**
|
|
2688
|
+
* An element which looks like a checkbox.
|
|
2689
|
+
*
|
|
2690
|
+
* @description
|
|
2691
|
+
* The `m3e-pseudo-checkbox` component is a pseudo-checkbox supporting checked, indeterminate, and disabled
|
|
2692
|
+
* states. It is customizable via CSS properties for expressive, accessible UI design.
|
|
2693
|
+
*
|
|
2694
|
+
* @example
|
|
2695
|
+
* The following example illustrates how to render a checked pseudo-checkbox.
|
|
2696
|
+
* ```html
|
|
2697
|
+
* <m3e-pseudo-checkbox checked></m3e-pseudo-checkbox>
|
|
2698
|
+
* ```
|
|
2699
|
+
*
|
|
2700
|
+
* @tag m3e-pseudo-checkbox
|
|
2701
|
+
*
|
|
2702
|
+
* @attr checked - A value indicating whether the element is checked.
|
|
2703
|
+
* @attr disabled - A value indicating whether the element is disabled.
|
|
2704
|
+
* @attr indeterminate - A value indicating whether the element's checked state is indeterminate.
|
|
2705
|
+
*
|
|
2706
|
+
* @cssprop --m3e-checkbox-icon-size - Size of the checkbox icon.
|
|
2707
|
+
* @cssprop --m3e-checkbox-container-shape - Border radius of the checkbox container.
|
|
2708
|
+
* @cssprop --m3e-checkbox-unselected-outline-thickness - Outline thickness for unselected state.
|
|
2709
|
+
* @cssprop --m3e-checkbox-unselected-outline-color - Outline color for unselected state.
|
|
2710
|
+
* @cssprop --m3e-checkbox-selected-container-color - Background color for selected state.
|
|
2711
|
+
* @cssprop --m3e-checkbox-selected-icon-color - Icon color for selected state.
|
|
2712
|
+
* @cssprop --m3e-checkbox-unselected-disabled-outline-color - Outline color for unselected disabled state.
|
|
2713
|
+
* @cssprop --m3e-checkbox-unselected-disabled-outline-opacity - Outline opacity for unselected disabled state.
|
|
2714
|
+
* @cssprop --m3e-checkbox-selected-disabled-container-color - Background color for selected disabled state.
|
|
2715
|
+
* @cssprop --m3e-checkbox-selected-disabled-container-opacity - Background opacity for selected disabled state.
|
|
2716
|
+
* @cssprop --m3e-checkbox-selected-disabled-icon-color - Icon color for selected disabled state.
|
|
2717
|
+
* @cssprop --m3e-checkbox-selected-disabled-icon-opacity - Icon opacity for selected disabled state.
|
|
2718
|
+
*/
|
|
2719
|
+
let M3ePseudoCheckboxElement = class M3ePseudoCheckboxElement extends CheckedIndeterminate(Disabled(Role(LitElement, "none"))) {
|
|
2720
|
+
/** @inheritdoc */
|
|
2721
|
+
connectedCallback() {
|
|
2722
|
+
super.connectedCallback();
|
|
2723
|
+
this.ariaHidden = "true";
|
|
2724
|
+
}
|
|
2725
|
+
/** @inheritdoc */
|
|
2726
|
+
render() {
|
|
2727
|
+
if (this.indeterminate) {
|
|
2728
|
+
return html`<svg viewBox="0 -960 960 960" fill="currentColor"><path Required d="M240-440v-80h480v80H240Z"/></svg>`;
|
|
2729
|
+
}
|
|
2730
|
+
if (this.checked) {
|
|
2731
|
+
return html`<svg viewBox="0 -960 960 960" fill="currentColor"><path d="M382-240 154-468l57-57 171 171 367-367 57 57-424 424Z"/></svg>`;
|
|
2732
|
+
}
|
|
2733
|
+
return nothing;
|
|
2734
|
+
}
|
|
2735
|
+
};
|
|
2736
|
+
/** The styles of the element. */
|
|
2737
|
+
M3ePseudoCheckboxElement.styles = css`:host { display: inline-block; vertical-align: middle; width: var(--m3e-checkbox-icon-size, 1.125rem); height: var(--m3e-checkbox-icon-size, 1.125rem); border-radius: var(--m3e-checkbox-container-shape, 2px); box-sizing: border-box; flex: none; contain: layout style paint; } :host(:not([checked]):not([indeterminate])) { border-width: var(--m3e-checkbox-unselected-outline-thickness, 2px); border-style: solid; } :host(:not([disabled])[checked]), :host(:not([disabled])[indeterminate]) { background-color: var(--m3e-checkbox-selected-container-color, ${DesignToken.color.primary}); color: var(--m3e-checkbox-selected-icon-color, ${DesignToken.color.onPrimary}); } :host(:not([disabled]):not([checked]):not([indeterminate])) { border-color: var(--m3e-checkbox-unselected-outline-color, ${DesignToken.color.onSurfaceVariant}); } :host([disabled]:not([checked]):not([indeterminate])) { border-color: color-mix( in srgb, var(--m3e-checkbox-unselected-disabled-outline-color, ${DesignToken.color.onSurface}) var(--m3e-checkbox-unselected-disabled-outline-opacity, 38%), transparent ); } :host([disabled][checked]), :host([disabled][indeterminate]) { background-color: color-mix( in srgb, var(--m3e-checkbox-selected-disabled-container-color, ${DesignToken.color.onSurface}) var(--m3e-checkbox-selected-disabled-container-opacity, 38%), transparent ); color: color-mix( in srgb, var(--m3e-checkbox-selected-disabled-icon-color, ${DesignToken.color.surface}) var(--m3e-checkbox-selected-disabled-icon-opacity, 100%), transparent ); } svg { pointer-events: none; } @media (forced-colors: active) { :host(:not([disabled])[checked]), :host(:not([disabled])[indeterminate]) { border-color: Highlight; background-color: Highlight; color: HighlightText; } :host(:not([disabled]):not([checked]):not([indeterminate])) { border-color: CanvasText; background: Canvas; } :host([disabled]:not([checked]):not([indeterminate])) { border-color: GrayText; background-color: Canvas; } :host([disabled][checked]), :host([disabled][indeterminate]) { background-color: GrayText; color: Canvas; } }`;
|
|
2738
|
+
M3ePseudoCheckboxElement = __decorate([customElement("m3e-pseudo-checkbox")], M3ePseudoCheckboxElement);
|
|
2739
|
+
|
|
2740
|
+
/**
|
|
2741
|
+
* An element which looks like a radio button.
|
|
2742
|
+
*
|
|
2743
|
+
* @description
|
|
2744
|
+
* The `m3e-pseudo-radio` component is a pseudo-radio supporting checked and disabled
|
|
2745
|
+
* states. It is customizable via CSS properties for expressive, accessible UI design.
|
|
2746
|
+
*
|
|
2747
|
+
* @example
|
|
2748
|
+
* The following example illustrates how to render a checked pseudo-radio.
|
|
2749
|
+
* ```html
|
|
2750
|
+
* <m3e-pseudo-radio checked></m3e-pseudo-radio>
|
|
2751
|
+
* ```
|
|
2752
|
+
*
|
|
2753
|
+
* @tag m3e-pseudo-radio
|
|
2754
|
+
*
|
|
2755
|
+
* @attr checked - A value indicating whether the element is checked.
|
|
2756
|
+
* @attr disabled - A value indicating whether the element is disabled.
|
|
2757
|
+
*
|
|
2758
|
+
* @cssprop --m3e-radio-icon-size - Size of the radio icon.
|
|
2759
|
+
* @cssprop --m3e-radio-unselected-icon-color - Color of the unselected radio icon.
|
|
2760
|
+
* @cssprop --m3e-radio-selected-icon-color - Color of the selected radio icon.
|
|
2761
|
+
* @cssprop --m3e-radio-disabled-icon-color - Color of the disabled radio icon.
|
|
2762
|
+
*/
|
|
2763
|
+
let M3ePseudoRadioElement = class M3ePseudoRadioElement extends Checked(Disabled(Role(LitElement, "none"))) {
|
|
2764
|
+
/** @inheritdoc */
|
|
2765
|
+
connectedCallback() {
|
|
2766
|
+
super.connectedCallback();
|
|
2767
|
+
this.ariaHidden = "true";
|
|
2768
|
+
}
|
|
2769
|
+
/** @inheritdoc */
|
|
2770
|
+
render() {
|
|
2771
|
+
return html`<svg class="icon" viewBox="0 0 20 20"><mask id="cutout2"><rect width="100%" height="100%" fill="white"></rect><circle cx="10" cy="10" r="8" fill="black"></circle></mask><circle class="outer circle" cx="10" cy="10" r="10" mask="url(#cutout2)"></circle><circle class="inner circle" cx="10" cy="10" r="5"></circle></svg>`;
|
|
2772
|
+
}
|
|
2773
|
+
};
|
|
2774
|
+
/** The styles of the element. */
|
|
2775
|
+
M3ePseudoRadioElement.styles = css`:host { display: inline-block; vertical-align: middle; box-sizing: border-box; width: var(--m3e-radio-icon-size, 1.25rem); height: var(--m3e-radio-icon-size, 1.25rem); flex: none; contain: layout style paint; } .circle { fill: currentColor; } :host(:not([checked])) .circle.inner { opacity: 0; } :host(:not([checked])) { color: var(--m3e-radio-unselected-icon-color, ${DesignToken.color.onSurfaceVariant}); } :host([checked]) { color: var(--m3e-radio-selected-icon-color, ${DesignToken.color.primary}); } :host([disabled]) { color: color-mix(in srgb, var(--m3e-radio-disabled-icon-color, ${DesignToken.color.onSurface}) 38%, transparent); } @media (forced-colors: active) { :host { border-radius: 50%; } :host(:not([checked])) { color: CanvasText; background-color: Canvas; } :host([checked]) { color: HighlightText; background-color: Highlight; } :host([disabled]) { color: GrayText; background-color: Canvas; } }`;
|
|
2776
|
+
M3ePseudoRadioElement = __decorate([customElement("m3e-pseudo-radio")], M3ePseudoRadioElement);
|
|
2777
|
+
|
|
2778
|
+
/**
|
|
2779
|
+
* Component design tokens that control the `M3eRippleElement`.
|
|
2780
|
+
* @internal
|
|
2781
|
+
*/
|
|
2782
|
+
const RippleToken = {
|
|
2783
|
+
color: unsafeCSS(`var(--m3e-ripple-color, ${DesignToken.color.onSurface})`),
|
|
2784
|
+
opacity: unsafeCSS(`var(--m3e-ripple-opacity, ${DesignToken.state.pressedStateLayerOpacity})`),
|
|
2785
|
+
enterDuration: unsafeCSS(`var(--m3e-ripple-enter-duration, ${DesignToken.motion.duration.long4})`),
|
|
2786
|
+
exitDuration: unsafeCSS(`var(--m3e-ripple-exit-duration, ${DesignToken.motion.duration.short2})`),
|
|
2787
|
+
scaleFactor: unsafeCSS(`var(--m3e-ripple-scale-factor, 2.5)`)
|
|
2788
|
+
};
|
|
2789
|
+
|
|
2790
|
+
var _M3eRippleElement_instances, _M3eRippleElement_ripple, _M3eRippleElement_pressedController, _M3eRippleElement_destroyRipple, _M3eRippleElement_handleAnimationEnd, _M3eRippleElement_handlePressedChange;
|
|
2791
|
+
/**
|
|
2792
|
+
* Connects user input to screen reactions using ripples.
|
|
2793
|
+
*
|
|
2794
|
+
* @description
|
|
2795
|
+
* The `m3e-ripple` component is an absolute positioned element used to depict a ripple.
|
|
2796
|
+
* The parenting element must be a relative positioned element.
|
|
2797
|
+
*
|
|
2798
|
+
* The component can be attached to an interactive element using the `for` attribute or programmatically using the `attach` method.
|
|
2799
|
+
* The ripple is displayed when the interactive element is pressed and hidden when released. This can be disabled using the `disabled` attribute.
|
|
2800
|
+
*
|
|
2801
|
+
* The pressed state actives either using both pointer and keyboard events. For keyboard events, `SPACE` activate a ripple.
|
|
2802
|
+
*
|
|
2803
|
+
* Alternatively, you can use the `show` and `hide` methods to programmatically control the ripple.
|
|
2804
|
+
*
|
|
2805
|
+
* @example
|
|
2806
|
+
* The following example illustrates attaching a ripple to an interactive element. In this example, the parenting div
|
|
2807
|
+
* has relative positioning and is given an `id` referenced by `m3e-ripple` using the `for` attribute. Note that `#myDiv`
|
|
2808
|
+
* is not used when specifying the attached element's identifier. The `#` is inferred.
|
|
2809
|
+
*
|
|
2810
|
+
* ```html
|
|
2811
|
+
* <div id="myDiv" tabindex="0" style="position: relative;">
|
|
2812
|
+
* <m3e-ripple for="myDiv"></m3e-ripple>
|
|
2813
|
+
* <div>
|
|
2814
|
+
* ```
|
|
2815
|
+
*
|
|
2816
|
+
* @tag m3e-ripple
|
|
2817
|
+
*
|
|
2818
|
+
* @attr centered - Whether the ripple always originates from the center of the element's bounds, rather than originating from the location of the click event.
|
|
2819
|
+
* @attr disabled - Whether click events will not trigger the ripple. Ripples can be still controlled manually by using the `show` and 'hide' methods.
|
|
2820
|
+
* @attr for - The identifier of the interactive control to which this element is attached.
|
|
2821
|
+
* @attr radius - The radius, in pixels, of the ripple.
|
|
2822
|
+
* @attr unbounded - Whether the ripple is visible outside the element's bounds.
|
|
2823
|
+
*
|
|
2824
|
+
* @cssprop --m3e-ripple-color - The color of the ripple.
|
|
2825
|
+
* @cssprop --m3e-ripple-enter-duration - The duration for the enter animation (expansion from point of contact).
|
|
2826
|
+
* @cssprop --m3e-ripple-exit-duration - The duration for the exit animation (fade-out).
|
|
2827
|
+
* @cssprop --m3e-ripple-opacity - The opacity of the ripple.
|
|
2828
|
+
* @cssprop --m3e-ripple-scale-factor - The factor by which to scale the ripple.
|
|
2829
|
+
* @cssprop --m3e-ripple-shape - The shape of the ripple.
|
|
2830
|
+
*/
|
|
2831
|
+
let M3eRippleElement = class M3eRippleElement extends HtmlFor(Role(LitElement, "none")) {
|
|
2832
|
+
constructor() {
|
|
2833
|
+
super(...arguments);
|
|
2834
|
+
_M3eRippleElement_instances.add(this);
|
|
2835
|
+
/** @private */
|
|
2836
|
+
_M3eRippleElement_ripple.set(this, null);
|
|
2837
|
+
/** @private */
|
|
2838
|
+
_M3eRippleElement_pressedController.set(this, new PressedController(this, {
|
|
2839
|
+
target: null,
|
|
2840
|
+
minPressedDuration: 150,
|
|
2841
|
+
isPressedKey: key => key === " ",
|
|
2842
|
+
callback: (pressed, {
|
|
2843
|
+
x,
|
|
2844
|
+
y
|
|
2845
|
+
}) => __classPrivateFieldGet(this, _M3eRippleElement_instances, "m", _M3eRippleElement_handlePressedChange).call(this, pressed, x, y)
|
|
2846
|
+
}));
|
|
2847
|
+
/**
|
|
2848
|
+
* Whether click events will not trigger the ripple.
|
|
2849
|
+
* Ripples can be still controlled manually by using the `show` and 'hide' methods.
|
|
2850
|
+
* @default false
|
|
2851
|
+
*/
|
|
2852
|
+
this.disabled = false;
|
|
2853
|
+
/**
|
|
2854
|
+
* Whether the ripple always originates from the center of the element's bounds, rather
|
|
2855
|
+
* than originating from the location of the click event.
|
|
2856
|
+
* @default false
|
|
2857
|
+
*/
|
|
2858
|
+
this.centered = false;
|
|
2859
|
+
/**
|
|
2860
|
+
* Whether the ripple is visible outside the element's bounds.
|
|
2861
|
+
* @default false
|
|
2862
|
+
*/
|
|
2863
|
+
this.unbounded = false;
|
|
2864
|
+
/**
|
|
2865
|
+
* The radius, in pixels, of the ripple.
|
|
2866
|
+
* @default null
|
|
2867
|
+
*/
|
|
2868
|
+
this.radius = null;
|
|
2869
|
+
}
|
|
2870
|
+
/** Whether the ripple is currently visible to the user. */
|
|
2871
|
+
get visible() {
|
|
2872
|
+
return __classPrivateFieldGet(this, _M3eRippleElement_ripple, "f") !== null;
|
|
2873
|
+
}
|
|
2874
|
+
/**
|
|
2875
|
+
* Launches a manual ripple.
|
|
2876
|
+
* @param {number} x The x-coordinate, relative to the viewport, at which to present the ripple.
|
|
2877
|
+
* @param {number} y The y-coordinate, relative to the viewport, at which to present the ripple.
|
|
2878
|
+
* @param {boolean} [persistent=false] Whether the ripple will persist until hidden.
|
|
2879
|
+
*/
|
|
2880
|
+
show(x, y, persistent = false) {
|
|
2881
|
+
__classPrivateFieldGet(this, _M3eRippleElement_instances, "m", _M3eRippleElement_destroyRipple).call(this);
|
|
2882
|
+
const bounds = this.getBoundingClientRect();
|
|
2883
|
+
if (this.centered) {
|
|
2884
|
+
x = bounds.left + bounds.width / 2;
|
|
2885
|
+
y = bounds.top + bounds.height / 2;
|
|
2886
|
+
}
|
|
2887
|
+
let radius = this.radius;
|
|
2888
|
+
if (!radius || isNaN(radius)) {
|
|
2889
|
+
const distX = Math.max(Math.abs(x - bounds.left), Math.abs(x - bounds.right));
|
|
2890
|
+
const distY = Math.max(Math.abs(y - bounds.top), Math.abs(y - bounds.bottom));
|
|
2891
|
+
radius = Math.sqrt(distX * distX + distY * distY);
|
|
2892
|
+
}
|
|
2893
|
+
const offsetX = x - bounds.left;
|
|
2894
|
+
const offsetY = y - bounds.top;
|
|
2895
|
+
__classPrivateFieldSet(this, _M3eRippleElement_ripple, document.createElement("div"), "f");
|
|
2896
|
+
__classPrivateFieldGet(this, _M3eRippleElement_ripple, "f").classList.add("ripple");
|
|
2897
|
+
if (persistent) {
|
|
2898
|
+
__classPrivateFieldGet(this, _M3eRippleElement_ripple, "f").classList.add("persistent");
|
|
2899
|
+
}
|
|
2900
|
+
__classPrivateFieldGet(this, _M3eRippleElement_ripple, "f").style.left = `${offsetX - radius}px`;
|
|
2901
|
+
__classPrivateFieldGet(this, _M3eRippleElement_ripple, "f").style.top = `${offsetY - radius}px`;
|
|
2902
|
+
__classPrivateFieldGet(this, _M3eRippleElement_ripple, "f").style.width = `${radius * 2}px`;
|
|
2903
|
+
__classPrivateFieldGet(this, _M3eRippleElement_ripple, "f").style.height = `${radius * 2}px`;
|
|
2904
|
+
__classPrivateFieldGet(this, _M3eRippleElement_ripple, "f").addEventListener("animationend", () => __classPrivateFieldGet(this, _M3eRippleElement_instances, "m", _M3eRippleElement_handleAnimationEnd).call(this, persistent), {
|
|
2905
|
+
once: true
|
|
2906
|
+
});
|
|
2907
|
+
__classPrivateFieldGet(this, _M3eRippleElement_ripple, "f").addEventListener("transitionend", () => __classPrivateFieldGet(this, _M3eRippleElement_instances, "m", _M3eRippleElement_destroyRipple).call(this), {
|
|
2908
|
+
once: true
|
|
2909
|
+
});
|
|
2910
|
+
this.shadowRoot?.appendChild(__classPrivateFieldGet(this, _M3eRippleElement_ripple, "f"));
|
|
2911
|
+
}
|
|
2912
|
+
/** Manually hides the ripple. */
|
|
2913
|
+
hide() {
|
|
2914
|
+
__classPrivateFieldGet(this, _M3eRippleElement_ripple, "f")?.classList.add("exit");
|
|
2915
|
+
}
|
|
2916
|
+
/** @inheritdoc */
|
|
2917
|
+
attach(control) {
|
|
2918
|
+
super.attach(control);
|
|
2919
|
+
__classPrivateFieldGet(this, _M3eRippleElement_pressedController, "f").observe(control);
|
|
2920
|
+
}
|
|
2921
|
+
/** @inheritdoc */
|
|
2922
|
+
detach() {
|
|
2923
|
+
if (this.control) {
|
|
2924
|
+
__classPrivateFieldGet(this, _M3eRippleElement_pressedController, "f").unobserve(this.control);
|
|
2925
|
+
}
|
|
2926
|
+
super.detach();
|
|
2927
|
+
}
|
|
2928
|
+
/** @inheritdoc */
|
|
2929
|
+
connectedCallback() {
|
|
2930
|
+
this.ariaHidden = "true";
|
|
2931
|
+
super.connectedCallback();
|
|
2932
|
+
}
|
|
2933
|
+
/** @inheritdoc */
|
|
2934
|
+
disconnectedCallback() {
|
|
2935
|
+
super.disconnectedCallback();
|
|
2936
|
+
__classPrivateFieldGet(this, _M3eRippleElement_instances, "m", _M3eRippleElement_destroyRipple).call(this);
|
|
2937
|
+
}
|
|
2938
|
+
/** @inheritdoc */
|
|
2939
|
+
updated(_changedProperties) {
|
|
2940
|
+
super.updated(_changedProperties);
|
|
2941
|
+
if (_changedProperties.has("disabled") && this.disabled) {
|
|
2942
|
+
this.hide();
|
|
2943
|
+
}
|
|
2944
|
+
}
|
|
2945
|
+
};
|
|
2946
|
+
_M3eRippleElement_ripple = new WeakMap();
|
|
2947
|
+
_M3eRippleElement_pressedController = new WeakMap();
|
|
2948
|
+
_M3eRippleElement_instances = new WeakSet();
|
|
2949
|
+
_M3eRippleElement_destroyRipple = function _M3eRippleElement_destroyRipple() {
|
|
2950
|
+
__classPrivateFieldGet(this, _M3eRippleElement_ripple, "f")?.remove();
|
|
2951
|
+
__classPrivateFieldSet(this, _M3eRippleElement_ripple, null, "f");
|
|
2952
|
+
};
|
|
2953
|
+
_M3eRippleElement_handleAnimationEnd = function _M3eRippleElement_handleAnimationEnd(persistent) {
|
|
2954
|
+
if (persistent) {
|
|
2955
|
+
__classPrivateFieldGet(this, _M3eRippleElement_ripple, "f")?.classList.add("pressed");
|
|
2956
|
+
} else {
|
|
2957
|
+
this.hide();
|
|
2958
|
+
}
|
|
2959
|
+
};
|
|
2960
|
+
_M3eRippleElement_handlePressedChange = function _M3eRippleElement_handlePressedChange(pressed, x, y) {
|
|
2961
|
+
if (!this.disabled) {
|
|
2962
|
+
if (pressed) {
|
|
2963
|
+
this.show(x, y, true);
|
|
2964
|
+
} else {
|
|
2965
|
+
this.hide();
|
|
2966
|
+
}
|
|
2967
|
+
}
|
|
2968
|
+
};
|
|
2969
|
+
/** The styles of the element. */
|
|
2970
|
+
M3eRippleElement.styles = css`:host { display: block; position: absolute; left: 0; top: 0; right: 0; bottom: 0; pointer-events: none; border-radius: inherit; } :host(:not([unbounded])) { overflow: hidden; } :host(:not([unbounded])) .ripple { contain: layout style paint; } :host([unbounded]) .ripple { contain: layout style; } .ripple { display: block; position: absolute; left: 0; top: 0; right: 0; bottom: 0; pointer-events: none; transform: scale(0); border-radius: ${DesignToken.shape.corner.full}; background-color: color-mix(in srgb, ${RippleToken.color} ${RippleToken.opacity}, transparent); will-change: background-color, opacity; animation: ripple ${RippleToken.enterDuration} linear; } .ripple.persistent.pressed { transform: scale(${RippleToken.scaleFactor}); } .ripple.exit { transition: opacity ${RippleToken.exitDuration} cubic-bezier(0, 0, 0.2, 0.1); opacity: 0; } @keyframes ripple { to { transform: scale(${RippleToken.scaleFactor}); } } @media (prefers-reduced-motion) { .ripple { transform: scale(${RippleToken.scaleFactor}); animation-duration: 90ms; } .ripple.exit { transition-duration: 10ms; } } @media (forced-colors: active) { .ripple { display: none; } }`;
|
|
2971
|
+
__decorate([property({
|
|
2972
|
+
type: Boolean,
|
|
2973
|
+
reflect: true
|
|
2974
|
+
})], M3eRippleElement.prototype, "disabled", void 0);
|
|
2975
|
+
__decorate([property({
|
|
2976
|
+
type: Boolean,
|
|
2977
|
+
reflect: true
|
|
2978
|
+
})], M3eRippleElement.prototype, "centered", void 0);
|
|
2979
|
+
__decorate([property({
|
|
2980
|
+
type: Boolean,
|
|
2981
|
+
reflect: true
|
|
2982
|
+
})], M3eRippleElement.prototype, "unbounded", void 0);
|
|
2983
|
+
__decorate([property({
|
|
2984
|
+
type: Number
|
|
2985
|
+
})], M3eRippleElement.prototype, "radius", void 0);
|
|
2986
|
+
M3eRippleElement = __decorate([customElement("m3e-ripple")], M3eRippleElement);
|
|
2987
|
+
|
|
2988
|
+
var _M3eScrollContainerElement_scrollHandler;
|
|
2989
|
+
/**
|
|
2990
|
+
* A vertically oriented content container which presents dividers above and below content when scrolled.
|
|
2991
|
+
*
|
|
2992
|
+
* @description
|
|
2993
|
+
* The `m3e-scroll-container` component provides a vertically oriented scrollable container with dynamic
|
|
2994
|
+
* dividers above and below content. Designed according to Material 3 principles, it supports custom scrollbar
|
|
2995
|
+
* thickness, divider styling, and focus ring theming via CSS custom properties.
|
|
2996
|
+
*
|
|
2997
|
+
* @example
|
|
2998
|
+
* This example shows a scrollable container with dividers above and below the content, and thin scrollbars enabled.
|
|
2999
|
+
* ```html
|
|
3000
|
+
* <m3e-scroll-container dividers="above-below" thin>
|
|
3001
|
+
* <div>Scrollable content goes here</div>
|
|
3002
|
+
* </m3e-scroll-container>
|
|
3003
|
+
* ```
|
|
3004
|
+
*
|
|
3005
|
+
* @tag m3e-scroll-container
|
|
3006
|
+
*
|
|
3007
|
+
* @slot - Renders the scrollable content.
|
|
3008
|
+
*
|
|
3009
|
+
* @attr dividers - The dividers used to separate scrollable content.
|
|
3010
|
+
* @attr thin - Whether to present thin scrollbars.
|
|
3011
|
+
*
|
|
3012
|
+
* @cssprop --m3e-divider-thickness - Thickness of the divider lines above and below content.
|
|
3013
|
+
* @cssprop --m3e-divider-color - Color of the divider lines when visible.
|
|
3014
|
+
* @cssprop --m3e-focus-ring-color - Color of the focus ring outline.
|
|
3015
|
+
* @cssprop --m3e-focus-ring-thickness - Thickness of the focus ring outline.
|
|
3016
|
+
* @cssprop --m3e-focus-ring-factor - Animation factor for focus ring thickness.
|
|
3017
|
+
* @cssprop --m3e-focus-ring-duration - Duration of the focus ring animation.
|
|
3018
|
+
*/
|
|
3019
|
+
let M3eScrollContainerElement = class M3eScrollContainerElement extends AttachInternals(LitElement) {
|
|
3020
|
+
constructor() {
|
|
3021
|
+
super(...arguments);
|
|
3022
|
+
/** @private */
|
|
3023
|
+
_M3eScrollContainerElement_scrollHandler.set(this, () => this._updateScroll());
|
|
3024
|
+
/**
|
|
3025
|
+
* The dividers used to separate scrollable content.
|
|
3026
|
+
* @default "above-below"
|
|
3027
|
+
*/
|
|
3028
|
+
this.dividers = "above-below";
|
|
3029
|
+
/**
|
|
3030
|
+
* Whether to present thin scrollbars.
|
|
3031
|
+
* @default false
|
|
3032
|
+
*/
|
|
3033
|
+
this.thin = false;
|
|
3034
|
+
}
|
|
3035
|
+
/** @inheritdoc */
|
|
3036
|
+
disconnectedCallback() {
|
|
3037
|
+
super.disconnectedCallback();
|
|
3038
|
+
this.removeEventListener("scroll", __classPrivateFieldGet(this, _M3eScrollContainerElement_scrollHandler, "f"));
|
|
3039
|
+
}
|
|
3040
|
+
/** @inheritdoc */
|
|
3041
|
+
update(changedProperties) {
|
|
3042
|
+
super.update(changedProperties);
|
|
3043
|
+
if (changedProperties.has("dividers")) {
|
|
3044
|
+
this.removeEventListener("scroll", __classPrivateFieldGet(this, _M3eScrollContainerElement_scrollHandler, "f"));
|
|
3045
|
+
if (this.dividers !== "none") {
|
|
3046
|
+
this.addEventListener("scroll", __classPrivateFieldGet(this, _M3eScrollContainerElement_scrollHandler, "f"), {
|
|
3047
|
+
passive: true
|
|
3048
|
+
});
|
|
3049
|
+
}
|
|
3050
|
+
}
|
|
3051
|
+
}
|
|
3052
|
+
/** @inheritdoc */
|
|
3053
|
+
render() {
|
|
3054
|
+
return html`<slot @slotchange="${this._updateScroll}"></slot>`;
|
|
3055
|
+
}
|
|
3056
|
+
/** @private */
|
|
3057
|
+
_updateScroll() {
|
|
3058
|
+
const before = (this.dividers === "above" || this.dividers === "above-below") && this.scrollTop > 0;
|
|
3059
|
+
const after = (this.dividers === "below" || this.dividers === "above-below") && this.scrollHeight - this.scrollTop - this.clientHeight > 1;
|
|
3060
|
+
setCustomState(this, "--above", before);
|
|
3061
|
+
setCustomState(this, "--below", after);
|
|
3062
|
+
}
|
|
3063
|
+
};
|
|
3064
|
+
_M3eScrollContainerElement_scrollHandler = new WeakMap();
|
|
3065
|
+
/** The styles of the element. */
|
|
3066
|
+
M3eScrollContainerElement.styles = css`:host { display: block; overflow-y: auto; position: relative; box-sizing: border-box; scrollbar-color: ${DesignToken.scrollbar.color}; border-top: var(--m3e-divider-thickness, 1px) solid transparent; border-bottom: var(--m3e-divider-thickness, 1px) solid transparent; outline-color: ${FocusRingToken.color}; outline-width: ${FocusRingToken.thickness}; outline-offset: ${FocusRingToken.outwardOffset}; } :host([thin]) { scrollbar-width: ${DesignToken.scrollbar.thinWidth}; } :host(:not([thin])) { scrollbar-width: ${DesignToken.scrollbar.width}; } :host(:not(:focus-visible):is(:state(--above), :--above)) { border-top-color: var(--m3e-divider-color, ${DesignToken.color.outlineVariant}); } :host(:not(:focus-visible):is(:state(--below), :--below)) { border-bottom-color: var(--m3e-divider-color, ${DesignToken.color.outlineVariant}); } :host(:focus-visible) { outline-style: solid; animation: grow-shrink ${FocusRingToken.duration}; } @keyframes grow-shrink { 50% { outline-width: calc(${FocusRingToken.thickness} * ${FocusRingToken.growthFactor}); } } @media (forced-colors: active) { :host { border-top: var(--m3e-divider-thickness, 1px) solid Canvas; border-bottom: var(--m3e-divider-thickness, 1px) solid Canvas; } :host(:not(:focus-visible):is(:state(--above), :--above)) { border-top-color: GrayText; } :host(:not(:focus-visible):is(:state(--below), :--below)) { border-bottom-color: GrayText; } } @media (prefers-reduced-motion) { :host(:focus-visible) { animation: none; } }`;
|
|
3067
|
+
__decorate([property()], M3eScrollContainerElement.prototype, "dividers", void 0);
|
|
3068
|
+
__decorate([property({
|
|
3069
|
+
type: Boolean,
|
|
3070
|
+
reflect: true
|
|
3071
|
+
})], M3eScrollContainerElement.prototype, "thin", void 0);
|
|
3072
|
+
__decorate([debounce(40)], M3eScrollContainerElement.prototype, "_updateScroll", null);
|
|
3073
|
+
M3eScrollContainerElement = __decorate([customElement("m3e-scroll-container")], M3eScrollContainerElement);
|
|
3074
|
+
|
|
3075
|
+
var _M3eSlideElement_instances, _M3eSlideElement_items, _M3eSlideElement_handleSlotChange, _M3eSlideElement_updateItems;
|
|
3076
|
+
/**
|
|
3077
|
+
* A carousel-like container used to horizontally cycle through slotted items.
|
|
3078
|
+
*
|
|
3079
|
+
* @example
|
|
3080
|
+
* The following example illustrates the use of `m3e-slide` to cycle through content.
|
|
3081
|
+
* In this example, `selected-index` is set to `1` so that "Content at index 1" is presented
|
|
3082
|
+
* by the component.
|
|
3083
|
+
* ```html
|
|
3084
|
+
* <m3e-slide selected-index="1">
|
|
3085
|
+
* <div>Content at index 0</div>
|
|
3086
|
+
* <div>Content at index 1</div>
|
|
3087
|
+
* <div>Content at index 2</div>
|
|
3088
|
+
* <div>Content at index 3</div>
|
|
3089
|
+
* </m3e-slide>
|
|
3090
|
+
* ```
|
|
3091
|
+
*
|
|
3092
|
+
* @tag m3e-slide
|
|
3093
|
+
*
|
|
3094
|
+
* @slot - Renders the items through which to cycle.
|
|
3095
|
+
*
|
|
3096
|
+
* @attr selected-index - The zero-based index of the visible item.
|
|
3097
|
+
*
|
|
3098
|
+
* @cssprop --m3e-slide-animation-duration - The duration of transitions between slotted items.
|
|
3099
|
+
*/
|
|
3100
|
+
let M3eSlideElement = class M3eSlideElement extends AttachInternals(LitElement) {
|
|
3101
|
+
constructor() {
|
|
3102
|
+
super(...arguments);
|
|
3103
|
+
_M3eSlideElement_instances.add(this);
|
|
3104
|
+
/** @private */
|
|
3105
|
+
_M3eSlideElement_items.set(this, new Array());
|
|
3106
|
+
/**
|
|
3107
|
+
* The zero-based index of the visible item.
|
|
3108
|
+
* @default null
|
|
3109
|
+
*/
|
|
3110
|
+
this.selectedIndex = null;
|
|
3111
|
+
}
|
|
3112
|
+
/** @inheritdoc */
|
|
3113
|
+
connectedCallback() {
|
|
3114
|
+
super.connectedCallback();
|
|
3115
|
+
addCustomState(this, "--no-animate");
|
|
3116
|
+
}
|
|
3117
|
+
/** @inheritdoc */
|
|
3118
|
+
update(changedProperties) {
|
|
3119
|
+
super.update(changedProperties);
|
|
3120
|
+
if (changedProperties.has("selectedIndex")) {
|
|
3121
|
+
if (this.selectedIndex === null) {
|
|
3122
|
+
addCustomState(this, "--no-animate");
|
|
3123
|
+
}
|
|
3124
|
+
__classPrivateFieldGet(this, _M3eSlideElement_instances, "m", _M3eSlideElement_updateItems).call(this);
|
|
3125
|
+
if (this.selectedIndex !== null && hasCustomState(this, "--no-animate")) {
|
|
3126
|
+
requestAnimationFrame(() => {
|
|
3127
|
+
if (this.selectedIndex !== null) {
|
|
3128
|
+
deleteCustomState(this, "--no-animate");
|
|
3129
|
+
}
|
|
3130
|
+
});
|
|
3131
|
+
}
|
|
3132
|
+
}
|
|
3133
|
+
}
|
|
3134
|
+
/** @inheritdoc */
|
|
3135
|
+
render() {
|
|
3136
|
+
return html`<slot @slotchange="${__classPrivateFieldGet(this, _M3eSlideElement_instances, "m", _M3eSlideElement_handleSlotChange)}"></slot>`;
|
|
3137
|
+
}
|
|
3138
|
+
};
|
|
3139
|
+
_M3eSlideElement_items = new WeakMap();
|
|
3140
|
+
_M3eSlideElement_instances = new WeakSet();
|
|
3141
|
+
_M3eSlideElement_handleSlotChange = function _M3eSlideElement_handleSlotChange(e) {
|
|
3142
|
+
const items = [...e.target.assignedElements({
|
|
3143
|
+
flatten: true
|
|
3144
|
+
})];
|
|
3145
|
+
for (const removed of __classPrivateFieldGet(this, _M3eSlideElement_items, "f").filter(x => !items.includes(x))) {
|
|
3146
|
+
removed.classList.remove("-before");
|
|
3147
|
+
removed.classList.remove("-after");
|
|
3148
|
+
removed.removeAttribute("inert");
|
|
3149
|
+
}
|
|
3150
|
+
__classPrivateFieldSet(this, _M3eSlideElement_items, items, "f");
|
|
3151
|
+
__classPrivateFieldGet(this, _M3eSlideElement_instances, "m", _M3eSlideElement_updateItems).call(this);
|
|
3152
|
+
};
|
|
3153
|
+
_M3eSlideElement_updateItems = function _M3eSlideElement_updateItems() {
|
|
3154
|
+
const selectedIndex = this.selectedIndex ?? __classPrivateFieldGet(this, _M3eSlideElement_items, "f").length;
|
|
3155
|
+
for (let i = 0; i < __classPrivateFieldGet(this, _M3eSlideElement_items, "f").length; i++) {
|
|
3156
|
+
const item = __classPrivateFieldGet(this, _M3eSlideElement_items, "f")[i];
|
|
3157
|
+
item.classList.toggle("-before", i < selectedIndex);
|
|
3158
|
+
item.classList.toggle("-after", i > selectedIndex);
|
|
3159
|
+
item.toggleAttribute("inert", i !== selectedIndex);
|
|
3160
|
+
}
|
|
3161
|
+
};
|
|
3162
|
+
/** The styles of the element. */
|
|
3163
|
+
M3eSlideElement.styles = css`:host { display: flex; position: relative; overflow: hidden; } ::slotted(*) { width: 100%; top: 0; transition: ${unsafeCSS(`inset-inline-start var(--m3e-slide-animation-duration, ${DesignToken.motion.duration.long2}) ${DesignToken.motion.easing.standard},
|
|
3164
|
+
visibility var(--m3e-slide-animation-duration, ${DesignToken.motion.duration.long2}) ${DesignToken.motion.easing.standard} allow-discrete`)}; } ::slotted(.-before), ::slotted(.-after) { visibility: hidden; position: absolute; } ::slotted(.-before) { inset-inline-start: -100%; } ::slotted(.-after) { inset-inline-start: 100%; } ::slotted(:not(.-before):not(.-after)) { position: relative; inset-inline-start: 0; } :host(:is(:state(--no-animate), :--no-animate)) ::slotted(*) { transition: none; } @media (prefers-reduced-motion) { ::slotted(*) { transition: none; } }`;
|
|
3165
|
+
__decorate([property({
|
|
3166
|
+
attribute: "selected-index",
|
|
3167
|
+
type: Number,
|
|
3168
|
+
reflect: true
|
|
3169
|
+
})], M3eSlideElement.prototype, "selectedIndex", void 0);
|
|
3170
|
+
M3eSlideElement = __decorate([customElement("m3e-slide")], M3eSlideElement);
|
|
3171
|
+
|
|
3172
|
+
/**
|
|
3173
|
+
* Component design tokens that control the `M3eStateLayerElement`.
|
|
3174
|
+
* @internal
|
|
3175
|
+
*/
|
|
3176
|
+
const StateLayerToken = {
|
|
3177
|
+
hoverColor: unsafeCSS(`var(--m3e-state-layer-hover-color, ${DesignToken.color.onSurface})`),
|
|
3178
|
+
hoverOpacity: unsafeCSS(`var(--m3e-state-layer-hover-opacity, ${DesignToken.state.hoverStateLayerOpacity})`),
|
|
3179
|
+
focusColor: unsafeCSS(`var(--m3e-state-layer-focus-color, ${DesignToken.color.onSurface})`),
|
|
3180
|
+
focusOpacity: unsafeCSS(`var(--m3e-state-layer-focus-opacity, ${DesignToken.state.focusStateLayerOpacity})`),
|
|
3181
|
+
duration: unsafeCSS(`var(--m3e-state-layer-duration, ${DesignToken.motion.duration.medium1})`),
|
|
3182
|
+
easing: unsafeCSS(`var(--m3e-state-layer-easing, ${DesignToken.motion.easing.standard})`)
|
|
3183
|
+
};
|
|
3184
|
+
|
|
3185
|
+
var _M3eStateLayerElement_instances, _M3eStateLayerElement_hoverController, _M3eStateLayerElement_focusController, _M3eStateLayerElement_handleHoverChange, _M3eStateLayerElement_handleFocusChange;
|
|
3186
|
+
/**
|
|
3187
|
+
* Provides focus and hover state layer treatment for an interactive element.
|
|
3188
|
+
*
|
|
3189
|
+
* @description
|
|
3190
|
+
* The `m3e-state-layer` component is an absolute positioned element used to depict hover and focus overlays.
|
|
3191
|
+
* The parenting element must be a relative positioned element.
|
|
3192
|
+
*
|
|
3193
|
+
* This element can be attached to an interactive element using the `for` attribute or programmatically using the `attach` method.
|
|
3194
|
+
* The state layer is displayed when the interactive element is either hovered or focused. This can be disabled using
|
|
3195
|
+
* the `disabled` attribute.
|
|
3196
|
+
*
|
|
3197
|
+
* @example
|
|
3198
|
+
* The following example illustrates attaching a state layer to an interactive element. In this example, the parenting div
|
|
3199
|
+
* has relative positioning and is given an `id` referenced by `m3e-state-layer` using the `for` attribute. Note that `#myDiv`
|
|
3200
|
+
* is not used when specifying the attached element's identifier. The `#` is inferred.
|
|
3201
|
+
*
|
|
3202
|
+
* ```html
|
|
3203
|
+
* <div id="myDiv" tabindex="0" style="position: relative;">
|
|
3204
|
+
* <m3e-state-layer for="myDiv"></m3e-state-layer>
|
|
3205
|
+
* <div>
|
|
3206
|
+
* ```
|
|
3207
|
+
*
|
|
3208
|
+
* @tag m3e-state-layer
|
|
3209
|
+
*
|
|
3210
|
+
* @attr disabled - Whether hover and focus events will not trigger the state layer. State layers can still be controlled manually using the `show` and `hide` methods.
|
|
3211
|
+
* @attr disable-hover - Whether hover events will not trigger the state layer. State layers can still be controlled manually using the `show` and `hide` methods.
|
|
3212
|
+
*
|
|
3213
|
+
* @cssprop --m3e-state-layer-duration - Duration of state layer changes.
|
|
3214
|
+
* @cssprop --m3e-state-layer-easing - Easing curve of state layer changes.
|
|
3215
|
+
* @cssprop --m3e-state-layer-focus-color - Color on hover.
|
|
3216
|
+
* @cssprop --m3e-state-layer-focus-opacity - Opacity on focus.
|
|
3217
|
+
* @cssprop --m3e-state-layer-hover-color - Color on hover.
|
|
3218
|
+
* @cssprop --m3e-state-layer-hover-opacity - Opacity on hover.
|
|
3219
|
+
*/
|
|
3220
|
+
let M3eStateLayerElement = class M3eStateLayerElement extends HtmlFor(Role(LitElement, "none")) {
|
|
3221
|
+
constructor() {
|
|
3222
|
+
super(...arguments);
|
|
3223
|
+
_M3eStateLayerElement_instances.add(this);
|
|
3224
|
+
/** @private */
|
|
3225
|
+
_M3eStateLayerElement_hoverController.set(this, new HoverController(this, {
|
|
3226
|
+
target: null,
|
|
3227
|
+
callback: hovering => __classPrivateFieldGet(this, _M3eStateLayerElement_instances, "m", _M3eStateLayerElement_handleHoverChange).call(this, hovering)
|
|
3228
|
+
}));
|
|
3229
|
+
/** @private */
|
|
3230
|
+
_M3eStateLayerElement_focusController.set(this, new FocusController(this, {
|
|
3231
|
+
target: null,
|
|
3232
|
+
callback: (_, focusVisible) => __classPrivateFieldGet(this, _M3eStateLayerElement_instances, "m", _M3eStateLayerElement_handleFocusChange).call(this, focusVisible)
|
|
3233
|
+
}));
|
|
3234
|
+
/**
|
|
3235
|
+
* Whether hover and focus events will not trigger the state layer. State layers can still
|
|
3236
|
+
* be controlled manually using the `show` and `hide` methods.
|
|
3237
|
+
* @default false
|
|
3238
|
+
*/
|
|
3239
|
+
this.disabled = false;
|
|
3240
|
+
/**
|
|
3241
|
+
* Whether hover events will not trigger the state layer. State layers can still
|
|
3242
|
+
* be controlled manually using the `show` and `hide` methods.
|
|
3243
|
+
* @default false
|
|
3244
|
+
*/
|
|
3245
|
+
this.disableHover = false;
|
|
3246
|
+
}
|
|
3247
|
+
/**
|
|
3248
|
+
* Launches a manual state layer.
|
|
3249
|
+
* @param {"hover" | "focused"} state The state of the layer to show.
|
|
3250
|
+
*/
|
|
3251
|
+
show(state) {
|
|
3252
|
+
this._layer?.classList.toggle(state, true);
|
|
3253
|
+
}
|
|
3254
|
+
/**
|
|
3255
|
+
* Hides the state layer.
|
|
3256
|
+
* @param {"hover" | "focused"} state The state of the layer to hide.
|
|
3257
|
+
*/
|
|
3258
|
+
hide(state) {
|
|
3259
|
+
this._layer?.classList.toggle(state, false);
|
|
3260
|
+
}
|
|
3261
|
+
/** @inheritdoc */
|
|
3262
|
+
attach(control) {
|
|
3263
|
+
super.attach(control);
|
|
3264
|
+
__classPrivateFieldGet(this, _M3eStateLayerElement_hoverController, "f").observe(control);
|
|
3265
|
+
__classPrivateFieldGet(this, _M3eStateLayerElement_focusController, "f").observe(control);
|
|
3266
|
+
}
|
|
3267
|
+
/** @inheritdoc */
|
|
3268
|
+
detach() {
|
|
3269
|
+
if (this.control) {
|
|
3270
|
+
__classPrivateFieldGet(this, _M3eStateLayerElement_hoverController, "f").unobserve(this.control);
|
|
3271
|
+
__classPrivateFieldGet(this, _M3eStateLayerElement_focusController, "f").unobserve(this.control);
|
|
3272
|
+
}
|
|
3273
|
+
super.detach();
|
|
3274
|
+
}
|
|
3275
|
+
/** @inheritdoc */
|
|
3276
|
+
connectedCallback() {
|
|
3277
|
+
this.ariaHidden = "true";
|
|
3278
|
+
super.connectedCallback();
|
|
3279
|
+
}
|
|
3280
|
+
/** @inheritdoc */
|
|
3281
|
+
disconnectedCallback() {
|
|
3282
|
+
super.disconnectedCallback();
|
|
3283
|
+
this.hide("hover");
|
|
3284
|
+
this.hide("focused");
|
|
3285
|
+
}
|
|
3286
|
+
/** @inheritdoc */
|
|
3287
|
+
updated(_changedProperties) {
|
|
3288
|
+
super.updated(_changedProperties);
|
|
3289
|
+
if (_changedProperties.has("disabled") && this.disabled) {
|
|
3290
|
+
this.hide("hover");
|
|
3291
|
+
this.hide("focused");
|
|
3292
|
+
}
|
|
3293
|
+
if (_changedProperties.has("disableHover") && this.disableHover) {
|
|
3294
|
+
this.hide("hover");
|
|
3295
|
+
}
|
|
3296
|
+
}
|
|
3297
|
+
/** @inheritdoc */
|
|
3298
|
+
render() {
|
|
3299
|
+
return html`<div class="layer"></div>`;
|
|
3300
|
+
}
|
|
3301
|
+
};
|
|
3302
|
+
_M3eStateLayerElement_hoverController = new WeakMap();
|
|
3303
|
+
_M3eStateLayerElement_focusController = new WeakMap();
|
|
3304
|
+
_M3eStateLayerElement_instances = new WeakSet();
|
|
3305
|
+
_M3eStateLayerElement_handleHoverChange = function _M3eStateLayerElement_handleHoverChange(hovering) {
|
|
3306
|
+
if (!this.disabled && !this.disableHover) {
|
|
3307
|
+
if (hovering) {
|
|
3308
|
+
this.show("hover");
|
|
3309
|
+
} else {
|
|
3310
|
+
this.hide("hover");
|
|
3311
|
+
}
|
|
3312
|
+
}
|
|
3313
|
+
};
|
|
3314
|
+
_M3eStateLayerElement_handleFocusChange = function _M3eStateLayerElement_handleFocusChange(focusVisible) {
|
|
3315
|
+
if (!this.disabled) {
|
|
3316
|
+
if (focusVisible) {
|
|
3317
|
+
this.show("focused");
|
|
3318
|
+
} else {
|
|
3319
|
+
this.hide("focused");
|
|
3320
|
+
}
|
|
3321
|
+
}
|
|
3322
|
+
};
|
|
3323
|
+
/** The styles of the element. */
|
|
3324
|
+
M3eStateLayerElement.styles = css`:host { display: block; } :host, .layer { position: absolute; left: 0; top: 0; right: 0; bottom: 0; pointer-events: none; border-radius: inherit; } .layer { contain: layout style paint; will-change: background-color; transition: ${unsafeCSS(`background-color ${StateLayerToken.duration} ${StateLayerToken.easing}`)}; } .layer.focused { background-color: color-mix(in srgb, ${StateLayerToken.focusColor} ${StateLayerToken.focusOpacity}, transparent); } .layer.hover { background-color: color-mix(in srgb, ${StateLayerToken.hoverColor} ${StateLayerToken.hoverOpacity}, transparent); } @media (prefers-reduced-motion) { .layer { transition: none; } } @media (forced-colors: active) { .layer { display: none; } }`;
|
|
3325
|
+
__decorate([query(".layer")], M3eStateLayerElement.prototype, "_layer", void 0);
|
|
3326
|
+
__decorate([property({
|
|
3327
|
+
type: Boolean,
|
|
3328
|
+
reflect: true
|
|
3329
|
+
})], M3eStateLayerElement.prototype, "disabled", void 0);
|
|
3330
|
+
__decorate([property({
|
|
3331
|
+
attribute: "disable-hover",
|
|
3332
|
+
type: Boolean,
|
|
3333
|
+
reflect: true
|
|
3334
|
+
})], M3eStateLayerElement.prototype, "disableHover", void 0);
|
|
3335
|
+
M3eStateLayerElement = __decorate([customElement("m3e-state-layer")], M3eStateLayerElement);
|
|
3336
|
+
|
|
3337
|
+
var _M3eTextHighlightElement_instances, _M3eTextHighlightElement_id, _M3eTextHighlightElement_ranges, _M3eTextHighlightElement_styles, _M3eTextHighlightElement_isTextNode, _M3eTextHighlightElement_findTextNodes, _M3eTextHighlightElement_highlight;
|
|
3338
|
+
var M3eTextHighlightElement_1;
|
|
3339
|
+
/**
|
|
3340
|
+
* Highlights text which matches a given search term.
|
|
3341
|
+
*
|
|
3342
|
+
* @description
|
|
3343
|
+
* Highlights all text ranges in slotted content that match a given search term using the CSS Custom Highlight API.
|
|
3344
|
+
*
|
|
3345
|
+
* @example
|
|
3346
|
+
* The following example illustrates highlighting "Lor".
|
|
3347
|
+
* ```html
|
|
3348
|
+
* <m3e-text-highlight term="Lor">
|
|
3349
|
+
* <p>
|
|
3350
|
+
* Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt
|
|
3351
|
+
* ut labore et dolore magna aliqua.
|
|
3352
|
+
* </p>
|
|
3353
|
+
* </m3e-text-highlight>
|
|
3354
|
+
* ```
|
|
3355
|
+
*
|
|
3356
|
+
* @tag m3e-text-highlight
|
|
3357
|
+
*
|
|
3358
|
+
* @slot - Renders the content to highlight.
|
|
3359
|
+
*
|
|
3360
|
+
* @attr case-sensitive - Whether matching is case sensitive.
|
|
3361
|
+
* @attr disabled - A value indicating whether text highlighting is disabled.
|
|
3362
|
+
* @attr mode - The mode in which to highlight text.
|
|
3363
|
+
* @attr term - The term to highlight.
|
|
3364
|
+
*
|
|
3365
|
+
* @fires highlight - Dispatched when content is highlighted.
|
|
3366
|
+
*
|
|
3367
|
+
* @cssprop --m3e-text-highlight-container-color - Background color applied to highlighted text ranges.
|
|
3368
|
+
* @cssprop --m3e-text-highlight-color - Foreground color of highlighted text content.
|
|
3369
|
+
* @cssprop --m3e-text-highlight-decoration - Optional text decoration (e.g., underline, line-through) for highlighted text.
|
|
3370
|
+
* @cssprop --m3e-text-highlight-shadow - Optional text shadow for emphasis or contrast.
|
|
3371
|
+
*/
|
|
3372
|
+
let M3eTextHighlightElement = M3eTextHighlightElement_1 = class M3eTextHighlightElement extends LitElement {
|
|
3373
|
+
constructor() {
|
|
3374
|
+
super();
|
|
3375
|
+
_M3eTextHighlightElement_instances.add(this);
|
|
3376
|
+
/** @private */
|
|
3377
|
+
_M3eTextHighlightElement_id.set(this, `m3e-text-highlight-${M3eTextHighlightElement_1.__nextId++}`);
|
|
3378
|
+
/** @private */
|
|
3379
|
+
_M3eTextHighlightElement_ranges.set(this, new Array());
|
|
3380
|
+
/** @private */
|
|
3381
|
+
_M3eTextHighlightElement_styles.set(this, null);
|
|
3382
|
+
/**
|
|
3383
|
+
* A value indicating whether text highlighting is disabled.
|
|
3384
|
+
* @default false
|
|
3385
|
+
*/
|
|
3386
|
+
this.disabled = false;
|
|
3387
|
+
/**
|
|
3388
|
+
* The term to highlight.
|
|
3389
|
+
* @default ""
|
|
3390
|
+
*/
|
|
3391
|
+
this.term = "";
|
|
3392
|
+
/**
|
|
3393
|
+
* Whether matching is case sensitive.
|
|
3394
|
+
* @default false
|
|
3395
|
+
*/
|
|
3396
|
+
this.caseSensitive = false;
|
|
3397
|
+
/**
|
|
3398
|
+
* The mode in which to highlight text.
|
|
3399
|
+
* @default "contains"
|
|
3400
|
+
*/
|
|
3401
|
+
this.mode = "contains";
|
|
3402
|
+
if (this.isSupported) {
|
|
3403
|
+
__classPrivateFieldSet(this, _M3eTextHighlightElement_styles, new CSSStyleSheet(), "f");
|
|
3404
|
+
__classPrivateFieldGet(this, _M3eTextHighlightElement_styles, "f").replaceSync(css`::highlight(${unsafeCSS(__classPrivateFieldGet(this, _M3eTextHighlightElement_id, "f"))}) { background-color: var(--m3e-text-highlight-container-color, ${DesignToken.color.secondaryContainer}); color: var(--m3e-text-highlight-color, ${DesignToken.color.onSecondaryContainer}); text-decoration: var(--m3e-text-highlight-decoration); text-shadow: var(--m3e-text-highlight-shadow); }`.toString());
|
|
3405
|
+
}
|
|
3406
|
+
}
|
|
3407
|
+
/** A value indicating whether text highlighting is supported by the browser. */
|
|
3408
|
+
get isSupported() {
|
|
3409
|
+
return !isServer && CSS.highlights ? true : false;
|
|
3410
|
+
}
|
|
3411
|
+
/** The ranges that match the current term. */
|
|
3412
|
+
get ranges() {
|
|
3413
|
+
return __classPrivateFieldGet(this, _M3eTextHighlightElement_ranges, "f");
|
|
3414
|
+
}
|
|
3415
|
+
/** @inheritdoc */
|
|
3416
|
+
firstUpdated(_changedProperties) {
|
|
3417
|
+
super.firstUpdated(_changedProperties);
|
|
3418
|
+
if (this.shadowRoot && __classPrivateFieldGet(this, _M3eTextHighlightElement_styles, "f") && !this.shadowRoot.adoptedStyleSheets.includes(__classPrivateFieldGet(this, _M3eTextHighlightElement_styles, "f"))) {
|
|
3419
|
+
this.shadowRoot.adoptedStyleSheets.push(__classPrivateFieldGet(this, _M3eTextHighlightElement_styles, "f"));
|
|
3420
|
+
}
|
|
3421
|
+
}
|
|
3422
|
+
/** @inheritdoc */
|
|
3423
|
+
updated(_changedProperties) {
|
|
3424
|
+
super.updated(_changedProperties);
|
|
3425
|
+
if (_changedProperties.has("term") || _changedProperties.has("caseSensitive") || _changedProperties.has("disabled")) {
|
|
3426
|
+
__classPrivateFieldGet(this, _M3eTextHighlightElement_instances, "m", _M3eTextHighlightElement_highlight).call(this);
|
|
3427
|
+
}
|
|
3428
|
+
}
|
|
3429
|
+
/** @inheritdoc */
|
|
3430
|
+
render() {
|
|
3431
|
+
return html`<slot @slotchange="${__classPrivateFieldGet(this, _M3eTextHighlightElement_instances, "m", _M3eTextHighlightElement_highlight)}"></slot>`;
|
|
3432
|
+
}
|
|
3433
|
+
};
|
|
3434
|
+
_M3eTextHighlightElement_id = new WeakMap();
|
|
3435
|
+
_M3eTextHighlightElement_ranges = new WeakMap();
|
|
3436
|
+
_M3eTextHighlightElement_styles = new WeakMap();
|
|
3437
|
+
_M3eTextHighlightElement_instances = new WeakSet();
|
|
3438
|
+
_M3eTextHighlightElement_isTextNode = function _M3eTextHighlightElement_isTextNode(node) {
|
|
3439
|
+
return !/^\s*$/.test(node.data);
|
|
3440
|
+
};
|
|
3441
|
+
_M3eTextHighlightElement_findTextNodes = function _M3eTextHighlightElement_findTextNodes(parent, nodes) {
|
|
3442
|
+
if (parent instanceof HTMLSlotElement) {
|
|
3443
|
+
parent.assignedNodes({
|
|
3444
|
+
flatten: true
|
|
3445
|
+
}).forEach(x => {
|
|
3446
|
+
switch (x.nodeType) {
|
|
3447
|
+
case Node.TEXT_NODE:
|
|
3448
|
+
if (__classPrivateFieldGet(this, _M3eTextHighlightElement_instances, "m", _M3eTextHighlightElement_isTextNode).call(this, x)) {
|
|
3449
|
+
nodes.push(x);
|
|
3450
|
+
}
|
|
3451
|
+
break;
|
|
3452
|
+
case Node.ELEMENT_NODE:
|
|
3453
|
+
__classPrivateFieldGet(this, _M3eTextHighlightElement_instances, "m", _M3eTextHighlightElement_findTextNodes).call(this, x, nodes);
|
|
3454
|
+
break;
|
|
3455
|
+
}
|
|
3456
|
+
});
|
|
3457
|
+
} else {
|
|
3458
|
+
parent.childNodes.forEach(x => {
|
|
3459
|
+
switch (x.nodeType) {
|
|
3460
|
+
case Node.TEXT_NODE:
|
|
3461
|
+
if (__classPrivateFieldGet(this, _M3eTextHighlightElement_instances, "m", _M3eTextHighlightElement_isTextNode).call(this, x)) {
|
|
3462
|
+
nodes.push(x);
|
|
3463
|
+
}
|
|
3464
|
+
break;
|
|
3465
|
+
case Node.ELEMENT_NODE:
|
|
3466
|
+
__classPrivateFieldGet(this, _M3eTextHighlightElement_instances, "m", _M3eTextHighlightElement_findTextNodes).call(this, x, nodes);
|
|
3467
|
+
break;
|
|
3468
|
+
}
|
|
3469
|
+
});
|
|
3470
|
+
}
|
|
3471
|
+
};
|
|
3472
|
+
_M3eTextHighlightElement_highlight = function _M3eTextHighlightElement_highlight() {
|
|
3473
|
+
if (!this.isSupported || !this.isConnected) return;
|
|
3474
|
+
CSS.highlights.delete(__classPrivateFieldGet(this, _M3eTextHighlightElement_id, "f"));
|
|
3475
|
+
__classPrivateFieldGet(this, _M3eTextHighlightElement_ranges, "f").length = 0;
|
|
3476
|
+
if (this.disabled) return;
|
|
3477
|
+
if (!this.term) {
|
|
3478
|
+
this.dispatchEvent(new CustomEvent("highlight", {
|
|
3479
|
+
detail: [...__classPrivateFieldGet(this, _M3eTextHighlightElement_ranges, "f")],
|
|
3480
|
+
bubbles: false,
|
|
3481
|
+
composed: false
|
|
3482
|
+
}));
|
|
3483
|
+
return;
|
|
3484
|
+
}
|
|
3485
|
+
const texts = new Array();
|
|
3486
|
+
__classPrivateFieldGet(this, _M3eTextHighlightElement_instances, "m", _M3eTextHighlightElement_findTextNodes).call(this, this, texts);
|
|
3487
|
+
if (texts.length > 0) {
|
|
3488
|
+
const term = !this.caseSensitive ? this.term.toLowerCase() : this.term;
|
|
3489
|
+
switch (this.mode) {
|
|
3490
|
+
case "starts-with":
|
|
3491
|
+
{
|
|
3492
|
+
const first = texts[0];
|
|
3493
|
+
const text = (this.caseSensitive ? first.textContent : first.textContent?.toLowerCase()) ?? "";
|
|
3494
|
+
if (text.startsWith(term)) {
|
|
3495
|
+
const range = new Range();
|
|
3496
|
+
range.setStart(first, 0);
|
|
3497
|
+
range.setEnd(first, term.length);
|
|
3498
|
+
__classPrivateFieldGet(this, _M3eTextHighlightElement_ranges, "f").push(range);
|
|
3499
|
+
}
|
|
3500
|
+
}
|
|
3501
|
+
break;
|
|
3502
|
+
case "ends-with":
|
|
3503
|
+
{
|
|
3504
|
+
const last = texts[texts.length - 1];
|
|
3505
|
+
const text = (this.caseSensitive ? last.textContent : last.textContent?.toLowerCase()) ?? "";
|
|
3506
|
+
if (text.endsWith(term)) {
|
|
3507
|
+
const start = text.length - term.length;
|
|
3508
|
+
const end = start + term.length;
|
|
3509
|
+
const range = new Range();
|
|
3510
|
+
range.setStart(last, start);
|
|
3511
|
+
range.setEnd(last, end);
|
|
3512
|
+
__classPrivateFieldGet(this, _M3eTextHighlightElement_ranges, "f").push(range);
|
|
3513
|
+
}
|
|
3514
|
+
}
|
|
3515
|
+
break;
|
|
3516
|
+
case "contains":
|
|
3517
|
+
__classPrivateFieldSet(this, _M3eTextHighlightElement_ranges, texts.map(x => {
|
|
3518
|
+
return {
|
|
3519
|
+
el: x,
|
|
3520
|
+
text: (!this.caseSensitive ? x.textContent?.toLowerCase() : x.textContent) ?? ""
|
|
3521
|
+
};
|
|
3522
|
+
}).map(({
|
|
3523
|
+
el,
|
|
3524
|
+
text
|
|
3525
|
+
}) => {
|
|
3526
|
+
const indices = new Array();
|
|
3527
|
+
let startPos = 0;
|
|
3528
|
+
while (startPos < text.length) {
|
|
3529
|
+
const index = text.indexOf(term, startPos);
|
|
3530
|
+
if (index === -1) break;
|
|
3531
|
+
indices.push(index);
|
|
3532
|
+
startPos = index + term.length;
|
|
3533
|
+
}
|
|
3534
|
+
return indices.map(index => {
|
|
3535
|
+
const range = new Range();
|
|
3536
|
+
range.setStart(el, index);
|
|
3537
|
+
range.setEnd(el, index + term.length);
|
|
3538
|
+
return range;
|
|
3539
|
+
});
|
|
3540
|
+
}).flat(), "f");
|
|
3541
|
+
break;
|
|
3542
|
+
}
|
|
3543
|
+
if (__classPrivateFieldGet(this, _M3eTextHighlightElement_ranges, "f").length > 0) {
|
|
3544
|
+
CSS.highlights.set(__classPrivateFieldGet(this, _M3eTextHighlightElement_id, "f"), new Highlight(...__classPrivateFieldGet(this, _M3eTextHighlightElement_ranges, "f")));
|
|
3545
|
+
}
|
|
3546
|
+
}
|
|
3547
|
+
this.dispatchEvent(new CustomEvent("highlight", {
|
|
3548
|
+
detail: [...__classPrivateFieldGet(this, _M3eTextHighlightElement_ranges, "f")],
|
|
3549
|
+
bubbles: false,
|
|
3550
|
+
composed: false
|
|
3551
|
+
}));
|
|
3552
|
+
};
|
|
3553
|
+
/** The styles of the element. */
|
|
3554
|
+
M3eTextHighlightElement.styles = css`:host { display: contents; }`;
|
|
3555
|
+
/** @private */
|
|
3556
|
+
M3eTextHighlightElement.__nextId = 0;
|
|
3557
|
+
__decorate([property({
|
|
3558
|
+
type: Boolean,
|
|
3559
|
+
reflect: true
|
|
3560
|
+
})], M3eTextHighlightElement.prototype, "disabled", void 0);
|
|
3561
|
+
__decorate([property()], M3eTextHighlightElement.prototype, "term", void 0);
|
|
3562
|
+
__decorate([property({
|
|
3563
|
+
attribute: "case-sensitive",
|
|
3564
|
+
type: Boolean
|
|
3565
|
+
})], M3eTextHighlightElement.prototype, "caseSensitive", void 0);
|
|
3566
|
+
__decorate([property()], M3eTextHighlightElement.prototype, "mode", void 0);
|
|
3567
|
+
M3eTextHighlightElement = M3eTextHighlightElement_1 = __decorate([customElement("m3e-text-highlight")], M3eTextHighlightElement);
|
|
3568
|
+
|
|
3569
|
+
/**
|
|
3570
|
+
* An inline container which presents an ellipsis when content overflows.
|
|
3571
|
+
*
|
|
3572
|
+
* @description
|
|
3573
|
+
* The `m3e-text-overflow` component truncates inline content with an ellipsis when it
|
|
3574
|
+
* exceeds the available width. It's intended for use inside flex or otherwise
|
|
3575
|
+
* constrained containers to preserve layout while providing predictable, single-line
|
|
3576
|
+
* truncation behavior for long text.
|
|
3577
|
+
*
|
|
3578
|
+
* @example
|
|
3579
|
+
* A typical usage inside a flex container where the heading and trailing actions are
|
|
3580
|
+
* constrained, allowing the center text to truncate with an ellipsis.
|
|
3581
|
+
*
|
|
3582
|
+
* ```html
|
|
3583
|
+
* <div style="display:flex;align-items:center;gap:12px;">
|
|
3584
|
+
* <m3e-icon name="menu"></m3e-icon>
|
|
3585
|
+
* <m3e-text-overflow>Very long title or breadcrumb that should truncate gracefully</m3e-text-overflow>
|
|
3586
|
+
* <m3e-icon name="more_vert"></m3e-icon>
|
|
3587
|
+
* </div>
|
|
3588
|
+
* ```
|
|
3589
|
+
*
|
|
3590
|
+
* @tag m3e-text-overflow
|
|
3591
|
+
*
|
|
3592
|
+
* @slot - Renders the content to truncate with an ellipsis.
|
|
3593
|
+
*/
|
|
3594
|
+
let M3eTextOverflowElement = class M3eTextOverflowElement extends LitElement {
|
|
3595
|
+
/** @inheritdoc */
|
|
3596
|
+
render() {
|
|
3597
|
+
return html`<span class="base"><slot></slot></span>`;
|
|
3598
|
+
}
|
|
3599
|
+
};
|
|
3600
|
+
/** The styles of the element. */
|
|
3601
|
+
M3eTextOverflowElement.styles = css`:host { flex: 1 1 auto; display: inline-flex; align-items: center; flex-wrap: nowrap; min-width: 0; } .base { flex: 1 1 auto; display: inline; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }`;
|
|
3602
|
+
M3eTextOverflowElement = __decorate([customElement("m3e-text-overflow")], M3eTextOverflowElement);
|
|
3603
|
+
|
|
3604
|
+
export { ActionElementBase, AnimationLoopController, AttachInternals, Checked, CheckedIndeterminate, ClickOutsideController, DesignToken, Disabled, FocusController, HoverController, HtmlFor, InertController, IntersectionController, LongPressController, M3eCollapsibleElement, M3eElevationElement, M3eFocusRingElement, M3ePseudoCheckboxElement, M3ePseudoRadioElement, M3eRippleElement, M3eScrollContainerElement, M3eSlideElement, M3eStateLayerElement, M3eTextHighlightElement, M3eTextOverflowElement, MutationController, PressedController, ResizeController, Role, ScrollController, ScrollLockController, VelocityTracker, addCustomState, customElement, debounce, deleteCustomState, forcedColorsActive, hasCustomState, hasKeys, internals, isAttachInternalsMixin, isCheckedIndeterminateMixin, isCheckedMixin, isDisabledMixin, isHtmlForMixin, prefersReducedMotion, resolveElementById, safeStyleMap, setCustomState, timeConverter };
|
|
3605
|
+
//# sourceMappingURL=TextOverflowElement.js.map
|