@m3e/core 1.1.1 → 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/custom-elements.json +4075 -3618
- package/dist/html-custom-data.json +6 -1
- package/dist/index.js +275 -29
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +9 -9
- package/dist/index.min.js.map +1 -1
- package/dist/src/shared/controllers/AnimationLoopController.d.ts +13 -0
- package/dist/src/shared/controllers/AnimationLoopController.d.ts.map +1 -0
- package/dist/src/shared/controllers/FocusController.d.ts.map +1 -1
- package/dist/src/shared/controllers/index.d.ts +1 -0
- package/dist/src/shared/controllers/index.d.ts.map +1 -1
- package/dist/src/shared/mixins/HtmlFor.d.ts.map +1 -1
- package/dist/src/shared/mixins/KeyboardClick.d.ts.map +1 -1
- package/dist/src/shared/primitives/ActionElementBase.d.ts +22 -0
- package/dist/src/shared/primitives/ActionElementBase.d.ts.map +1 -0
- package/dist/src/shared/primitives/CollapsibleElement.d.ts.map +1 -1
- package/dist/src/shared/primitives/StateLayerElement.d.ts +9 -2
- package/dist/src/shared/primitives/StateLayerElement.d.ts.map +1 -1
- package/dist/src/shared/primitives/index.d.ts +1 -0
- package/dist/src/shared/primitives/index.d.ts.map +1 -1
- package/dist/src/shared/utils/focusWhenReady.d.ts +8 -0
- package/dist/src/shared/utils/focusWhenReady.d.ts.map +1 -0
- package/dist/src/shared/utils/index.d.ts +4 -0
- package/dist/src/shared/utils/index.d.ts.map +1 -1
- package/dist/src/shared/utils/interceptProperty.d.ts +17 -0
- package/dist/src/shared/utils/interceptProperty.d.ts.map +1 -0
- package/dist/src/shared/utils/resolveElementById.d.ts +8 -0
- package/dist/src/shared/utils/resolveElementById.d.ts.map +1 -0
- package/dist/src/shared/utils/resolveFragmentUrl.d.ts +22 -0
- package/dist/src/shared/utils/resolveFragmentUrl.d.ts.map +1 -0
- package/package.json +1 -1
|
@@ -176,7 +176,12 @@
|
|
|
176
176
|
"attributes": [
|
|
177
177
|
{
|
|
178
178
|
"name": "disabled",
|
|
179
|
-
"description": "Whether hover and focus
|
|
179
|
+
"description": "Whether hover and focus events will not trigger the state layer. State layers can still\r\nbe controlled manually using the `show` and `hide` methods.",
|
|
180
|
+
"values": []
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
"name": "disable-hover",
|
|
184
|
+
"description": "Whether hover events will not trigger the state layer. State layers can still\r\nbe controlled manually using the `show` and `hide` methods.",
|
|
180
185
|
"values": []
|
|
181
186
|
},
|
|
182
187
|
{
|
package/dist/index.js
CHANGED
|
@@ -44,6 +44,51 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
44
44
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
45
45
|
};
|
|
46
46
|
|
|
47
|
+
var _AnimationLoopController_frameId, _AnimationLoopController_lastTime, _AnimationLoopController_running, _AnimationLoopController_callback, _AnimationLoopController_loop;
|
|
48
|
+
/** A `ReactiveController` used to execute a function in an animation loop. */
|
|
49
|
+
class AnimationLoopController {
|
|
50
|
+
constructor(host, callback) {
|
|
51
|
+
/** @private */_AnimationLoopController_frameId.set(this, null);
|
|
52
|
+
/** @private */
|
|
53
|
+
_AnimationLoopController_lastTime.set(this, 0);
|
|
54
|
+
/** @private */
|
|
55
|
+
_AnimationLoopController_running.set(this, false);
|
|
56
|
+
/** @private */
|
|
57
|
+
_AnimationLoopController_callback.set(this, void 0);
|
|
58
|
+
/** @private */
|
|
59
|
+
_AnimationLoopController_loop.set(this, () => {
|
|
60
|
+
if (!__classPrivateFieldGet(this, _AnimationLoopController_running, "f")) return;
|
|
61
|
+
const now = performance.now();
|
|
62
|
+
__classPrivateFieldGet(this, _AnimationLoopController_callback, "f").call(this, (now - __classPrivateFieldGet(this, _AnimationLoopController_lastTime, "f")) / 1000, now / 1000);
|
|
63
|
+
__classPrivateFieldSet(this, _AnimationLoopController_lastTime, now, "f");
|
|
64
|
+
__classPrivateFieldSet(this, _AnimationLoopController_frameId, requestAnimationFrame(__classPrivateFieldGet(this, _AnimationLoopController_loop, "f")), "f");
|
|
65
|
+
});
|
|
66
|
+
__classPrivateFieldSet(this, _AnimationLoopController_callback, callback, "f");
|
|
67
|
+
host.addController(this);
|
|
68
|
+
}
|
|
69
|
+
/** @inheritdoc */
|
|
70
|
+
hostDisconnected() {
|
|
71
|
+
this.stop();
|
|
72
|
+
}
|
|
73
|
+
/** Starts the animation loop. */
|
|
74
|
+
start() {
|
|
75
|
+
if (__classPrivateFieldGet(this, _AnimationLoopController_running, "f")) return;
|
|
76
|
+
__classPrivateFieldSet(this, _AnimationLoopController_running, true, "f");
|
|
77
|
+
__classPrivateFieldSet(this, _AnimationLoopController_lastTime, performance.now(), "f");
|
|
78
|
+
__classPrivateFieldGet(this, _AnimationLoopController_loop, "f").call(this);
|
|
79
|
+
}
|
|
80
|
+
/** Stops the animation loop. */
|
|
81
|
+
stop() {
|
|
82
|
+
if (!__classPrivateFieldGet(this, _AnimationLoopController_running, "f")) return;
|
|
83
|
+
__classPrivateFieldSet(this, _AnimationLoopController_running, false, "f");
|
|
84
|
+
if (__classPrivateFieldGet(this, _AnimationLoopController_frameId, "f") !== null) {
|
|
85
|
+
cancelAnimationFrame(__classPrivateFieldGet(this, _AnimationLoopController_frameId, "f"));
|
|
86
|
+
__classPrivateFieldSet(this, _AnimationLoopController_frameId, null, "f");
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
_AnimationLoopController_frameId = new WeakMap(), _AnimationLoopController_lastTime = new WeakMap(), _AnimationLoopController_running = new WeakMap(), _AnimationLoopController_callback = new WeakMap(), _AnimationLoopController_loop = new WeakMap();
|
|
91
|
+
|
|
47
92
|
var _MonitorControllerBase_host, _MonitorControllerBase_target, _MonitorControllerBase_targets;
|
|
48
93
|
/**
|
|
49
94
|
* A base implementation for a `ReactiveController` used to monitor the state of one
|
|
@@ -109,6 +154,25 @@ class MonitorControllerBase {
|
|
|
109
154
|
}
|
|
110
155
|
_MonitorControllerBase_host = new WeakMap(), _MonitorControllerBase_target = new WeakMap(), _MonitorControllerBase_targets = new WeakMap();
|
|
111
156
|
|
|
157
|
+
/**
|
|
158
|
+
* Asynchronously attempts to focus an element once it becomes focusable.
|
|
159
|
+
* @param {HTMLElement} element The element to to focus.
|
|
160
|
+
* @param {number} [timeout=200] The maximum amount of time to attempt to focus `el`.
|
|
161
|
+
* @returns {Promise<boolean>} A `Promise` that resolves to whether `el` was focused.
|
|
162
|
+
*/
|
|
163
|
+
async function focusWhenReady(element, timeout = 200) {
|
|
164
|
+
element.focus();
|
|
165
|
+
const start = performance.now();
|
|
166
|
+
while (element.shadowRoot?.activeElement !== element) {
|
|
167
|
+
if (!element.isConnected || performance.now() - start > timeout) {
|
|
168
|
+
return false;
|
|
169
|
+
}
|
|
170
|
+
await new Promise(requestAnimationFrame);
|
|
171
|
+
element.focus();
|
|
172
|
+
}
|
|
173
|
+
return true;
|
|
174
|
+
}
|
|
175
|
+
|
|
112
176
|
/**
|
|
113
177
|
* Determines whether forced colors are active.
|
|
114
178
|
* @returns {boolean} Whether forced colors are active.
|
|
@@ -464,6 +528,42 @@ function hasAssignedNodes(slot) {
|
|
|
464
528
|
}).length > 0;
|
|
465
529
|
}
|
|
466
530
|
|
|
531
|
+
/**
|
|
532
|
+
* Intercepts property access and mutations on a target object, allowing custom logic
|
|
533
|
+
* to run when the property is read or written to.
|
|
534
|
+
*
|
|
535
|
+
* @template T - The type of the target object.
|
|
536
|
+
* @template K - The key of the property being intercepted (must be a valid key of T).
|
|
537
|
+
* @param target - The object whose property should be intercepted.
|
|
538
|
+
* @param prop - The property key to intercept.
|
|
539
|
+
* @param options - Configuration object for interceptor callbacks.
|
|
540
|
+
* @returns A cleanup function that removes the interceptors and restores the original property descriptor.
|
|
541
|
+
* @throws {Error} If the property does not exist on the target object or its prototype chain.
|
|
542
|
+
*/
|
|
543
|
+
function interceptProperty(target, prop, options) {
|
|
544
|
+
const descriptor = Object.getOwnPropertyDescriptor(target, prop) ?? Object.getOwnPropertyDescriptor(Object.getPrototypeOf(target), prop);
|
|
545
|
+
if (!descriptor) {
|
|
546
|
+
throw new Error(`Property ${String(prop)} not found on target.`);
|
|
547
|
+
}
|
|
548
|
+
const getter = descriptor.get?.bind(target);
|
|
549
|
+
const setter = descriptor.set?.bind(target);
|
|
550
|
+
Object.defineProperty(target, prop, {
|
|
551
|
+
configurable: true,
|
|
552
|
+
enumerable: descriptor.enumerable,
|
|
553
|
+
get() {
|
|
554
|
+
return options.get ? options.get(() => getter?.()) : getter?.();
|
|
555
|
+
},
|
|
556
|
+
set(v) {
|
|
557
|
+
if (options.set) {
|
|
558
|
+
options.set(v, val => setter?.(val));
|
|
559
|
+
} else {
|
|
560
|
+
setter?.(v);
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
});
|
|
564
|
+
return () => Object.defineProperty(target, prop, descriptor);
|
|
565
|
+
}
|
|
566
|
+
|
|
467
567
|
/**
|
|
468
568
|
* Determines whether reduced motion is preferred.
|
|
469
569
|
* @returns {boolean} Whether reduced motion is preferred.
|
|
@@ -472,6 +572,55 @@ function prefersReducedMotion() {
|
|
|
472
572
|
return isServer || matchMedia("(prefers-reduced-motion)").matches;
|
|
473
573
|
}
|
|
474
574
|
|
|
575
|
+
/**
|
|
576
|
+
* Resolves an element by ID, waiting for document readiness if needed.
|
|
577
|
+
* @param {string} id - The element ID to resolve.
|
|
578
|
+
* @param {ParentNode} root - Optional root node to query from (defaults to document).
|
|
579
|
+
* @returns {Promise<T | null>} A promise that resolves with the element or `null` if not found.
|
|
580
|
+
*/
|
|
581
|
+
function resolveElementById(id, root = document) {
|
|
582
|
+
return new Promise(resolve => {
|
|
583
|
+
const element = root.querySelector(`#${id}`);
|
|
584
|
+
if (element) {
|
|
585
|
+
resolve(element);
|
|
586
|
+
return;
|
|
587
|
+
}
|
|
588
|
+
if (document.readyState === "complete" || document.readyState === "interactive") {
|
|
589
|
+
resolve(root.querySelector(`#${id}`));
|
|
590
|
+
return;
|
|
591
|
+
}
|
|
592
|
+
document.addEventListener("DOMContentLoaded", () => resolve(root.querySelector(`#${id}`)), {
|
|
593
|
+
once: true
|
|
594
|
+
});
|
|
595
|
+
});
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
/**
|
|
599
|
+
* Resolves a URL fragment reference (`url(path#id)`) based on the current document location.
|
|
600
|
+
*
|
|
601
|
+
* This helper is typically used when constructing fragment-based URLs for SVG
|
|
602
|
+
* references (e.g., masks, clipPaths, filters) where the browser requires a fully
|
|
603
|
+
* qualified `url(...)` value that includes the current path.
|
|
604
|
+
*
|
|
605
|
+
* How it works:
|
|
606
|
+
* - Safely reads `document.location` (guarded for SSR environments).
|
|
607
|
+
* - Extracts the current page's path + query string.
|
|
608
|
+
* - Removes any existing hash fragment from the URL.
|
|
609
|
+
* - Appends `#${id}` to produce a stable fragment reference.
|
|
610
|
+
*
|
|
611
|
+
* Example:
|
|
612
|
+
* // If the current page is /viewer/page?mode=edit#section2
|
|
613
|
+
* resolveFragmentUrl("clip") → "url(/viewer/page?mode=edit#clip)"
|
|
614
|
+
*
|
|
615
|
+
* @param id - The fragment identifier to append (e.g., an SVG element's ID).
|
|
616
|
+
* @returns A `url(...)` string pointing to the fragment within the current document.
|
|
617
|
+
*/
|
|
618
|
+
function resolveFragmentUrl(id) {
|
|
619
|
+
const location = document?.location ?? null;
|
|
620
|
+
const path = location ? (location.pathname + location.search).split("#")[0] : "";
|
|
621
|
+
return `url(${path}#${id})`;
|
|
622
|
+
}
|
|
623
|
+
|
|
475
624
|
/**
|
|
476
625
|
* If needed, scrolls an element into view within a given scroll container.
|
|
477
626
|
* @param {HTMLElement} element The element to scroll into view.
|
|
@@ -486,7 +635,7 @@ function scrollIntoViewIfNeeded(element, scrollContainer, options) {
|
|
|
486
635
|
}
|
|
487
636
|
}
|
|
488
637
|
|
|
489
|
-
var _FocusController_instances, _FocusController_callback, _FocusController_focusInHandler, _FocusController_focusOutHandler, _FocusController_handleFocusIn, _FocusController_handleFocusOut;
|
|
638
|
+
var _FocusController_instances, _FocusController_touch, _FocusController_callback, _FocusController_keyDownHandler, _FocusController_focusInHandler, _FocusController_focusOutHandler, _FocusController_touchStartHandler, _FocusController_touchEndHandler, _FocusController_handleKeyDown, _FocusController_handleFocusIn, _FocusController_handleFocusOut;
|
|
490
639
|
/** A `ReactiveController` used to monitor the focused state of one or more elements. */
|
|
491
640
|
class FocusController extends MonitorControllerBase {
|
|
492
641
|
/**
|
|
@@ -498,11 +647,19 @@ class FocusController extends MonitorControllerBase {
|
|
|
498
647
|
super(host, options);
|
|
499
648
|
_FocusController_instances.add(this);
|
|
500
649
|
/** @private */
|
|
650
|
+
_FocusController_touch.set(this, false);
|
|
651
|
+
/** @private */
|
|
501
652
|
_FocusController_callback.set(this, void 0);
|
|
502
653
|
/** @private */
|
|
654
|
+
_FocusController_keyDownHandler.set(this, e => __classPrivateFieldGet(this, _FocusController_instances, "m", _FocusController_handleKeyDown).call(this, e));
|
|
655
|
+
/** @private */
|
|
503
656
|
_FocusController_focusInHandler.set(this, e => __classPrivateFieldGet(this, _FocusController_instances, "m", _FocusController_handleFocusIn).call(this, e));
|
|
504
657
|
/** @private */
|
|
505
658
|
_FocusController_focusOutHandler.set(this, e => __classPrivateFieldGet(this, _FocusController_instances, "m", _FocusController_handleFocusOut).call(this, e));
|
|
659
|
+
/** @private */
|
|
660
|
+
_FocusController_touchStartHandler.set(this, () => __classPrivateFieldSet(this, _FocusController_touch, true, "f"));
|
|
661
|
+
/** @private */
|
|
662
|
+
_FocusController_touchEndHandler.set(this, () => __classPrivateFieldSet(this, _FocusController_touch, false, "f"));
|
|
506
663
|
__classPrivateFieldSet(this, _FocusController_callback, options.callback, "f");
|
|
507
664
|
}
|
|
508
665
|
/**
|
|
@@ -510,25 +667,38 @@ class FocusController extends MonitorControllerBase {
|
|
|
510
667
|
* @param {HTMLElement} target The element to start observing.
|
|
511
668
|
*/
|
|
512
669
|
_observe(target) {
|
|
513
|
-
target.addEventListener("keydown", __classPrivateFieldGet(this,
|
|
670
|
+
target.addEventListener("keydown", __classPrivateFieldGet(this, _FocusController_keyDownHandler, "f"));
|
|
514
671
|
target.addEventListener("focusin", __classPrivateFieldGet(this, _FocusController_focusInHandler, "f"));
|
|
515
672
|
target.addEventListener("focusout", __classPrivateFieldGet(this, _FocusController_focusOutHandler, "f"));
|
|
673
|
+
target.addEventListener("touchstart", __classPrivateFieldGet(this, _FocusController_touchStartHandler, "f"));
|
|
674
|
+
target.addEventListener("touchend", __classPrivateFieldGet(this, _FocusController_touchEndHandler, "f"));
|
|
675
|
+
target.addEventListener("touchcancel", __classPrivateFieldGet(this, _FocusController_touchEndHandler, "f"));
|
|
516
676
|
}
|
|
517
677
|
/**
|
|
518
678
|
* Stops observing the specified element.
|
|
519
679
|
* @param {HTMLElement} target The element to stop observing.
|
|
520
680
|
*/
|
|
521
681
|
_unobserve(target) {
|
|
522
|
-
target.removeEventListener("keydown", __classPrivateFieldGet(this,
|
|
682
|
+
target.removeEventListener("keydown", __classPrivateFieldGet(this, _FocusController_keyDownHandler, "f"));
|
|
523
683
|
target.removeEventListener("focusin", __classPrivateFieldGet(this, _FocusController_focusInHandler, "f"));
|
|
524
684
|
target.removeEventListener("focusout", __classPrivateFieldGet(this, _FocusController_focusOutHandler, "f"));
|
|
685
|
+
target.removeEventListener("touchstart", __classPrivateFieldGet(this, _FocusController_touchStartHandler, "f"));
|
|
686
|
+
target.removeEventListener("touchend", __classPrivateFieldGet(this, _FocusController_touchEndHandler, "f"));
|
|
687
|
+
target.removeEventListener("touchcancel", __classPrivateFieldGet(this, _FocusController_touchEndHandler, "f"));
|
|
525
688
|
}
|
|
526
689
|
}
|
|
527
|
-
_FocusController_callback = new WeakMap(), _FocusController_focusInHandler = new WeakMap(), _FocusController_focusOutHandler = new WeakMap(), _FocusController_instances = new WeakSet(),
|
|
528
|
-
const target = e.
|
|
690
|
+
_FocusController_touch = new WeakMap(), _FocusController_callback = 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) {
|
|
691
|
+
const target = e.currentTarget;
|
|
692
|
+
if (target.matches(":focus-within")) {
|
|
693
|
+
__classPrivateFieldGet(this, _FocusController_instances, "m", _FocusController_handleFocusIn).call(this, e);
|
|
694
|
+
}
|
|
695
|
+
}, _FocusController_handleFocusIn = function _FocusController_handleFocusIn(e) {
|
|
696
|
+
if (__classPrivateFieldGet(this, _FocusController_touch, "f")) return;
|
|
697
|
+
const target = e.currentTarget;
|
|
529
698
|
__classPrivateFieldGet(this, _FocusController_callback, "f").call(this, true, target.matches(":focus-visible") || forcedColorsActive(), target);
|
|
530
699
|
}, _FocusController_handleFocusOut = function _FocusController_handleFocusOut(e) {
|
|
531
|
-
__classPrivateFieldGet(this,
|
|
700
|
+
if (__classPrivateFieldGet(this, _FocusController_touch, "f")) return;
|
|
701
|
+
__classPrivateFieldGet(this, _FocusController_callback, "f").call(this, false, false, e.currentTarget);
|
|
532
702
|
};
|
|
533
703
|
|
|
534
704
|
var _HoverController_instances, _HoverController_callback, _HoverController_startDelays, _HoverController_endDelays, _HoverController_pointerInHandler, _HoverController_pointerLeaveHandler, _HoverController_clearDelays, _HoverController_clearStartDelay, _HoverController_clearEndDelay, _HoverController_handlePointerEnter, _HoverController_handlePointerLeave;
|
|
@@ -716,7 +886,9 @@ class LongPressController extends MonitorControllerBase {
|
|
|
716
886
|
* @param {HTMLElement} target The element to start observing.
|
|
717
887
|
*/
|
|
718
888
|
_observe(target) {
|
|
719
|
-
target.addEventListener("touchstart", __classPrivateFieldGet(this, _LongPressController_touchStartHandler, "f")
|
|
889
|
+
target.addEventListener("touchstart", __classPrivateFieldGet(this, _LongPressController_touchStartHandler, "f"), {
|
|
890
|
+
passive: true
|
|
891
|
+
});
|
|
720
892
|
target.addEventListener("touchend", __classPrivateFieldGet(this, _LongPressController_touchEndOrCancelHandler, "f"));
|
|
721
893
|
target.addEventListener("touchcancel", __classPrivateFieldGet(this, _LongPressController_touchEndOrCancelHandler, "f"));
|
|
722
894
|
}
|
|
@@ -3217,14 +3389,18 @@ function HtmlFor(base) {
|
|
|
3217
3389
|
super.update(changedProperties);
|
|
3218
3390
|
if (changedProperties.has("htmlFor")) {
|
|
3219
3391
|
if (this.htmlFor) {
|
|
3220
|
-
const
|
|
3221
|
-
if (
|
|
3222
|
-
|
|
3223
|
-
this.
|
|
3224
|
-
|
|
3225
|
-
|
|
3226
|
-
|
|
3227
|
-
|
|
3392
|
+
const root = this.getRootNode();
|
|
3393
|
+
if (root) {
|
|
3394
|
+
resolveElementById(this.htmlFor, root).then(control => {
|
|
3395
|
+
if (control !== this.control) {
|
|
3396
|
+
if (this.control) {
|
|
3397
|
+
this.detach();
|
|
3398
|
+
}
|
|
3399
|
+
if (control instanceof HTMLElement) {
|
|
3400
|
+
this.attach(control);
|
|
3401
|
+
}
|
|
3402
|
+
}
|
|
3403
|
+
});
|
|
3228
3404
|
}
|
|
3229
3405
|
} else if (this.control && this[_firstUpdated]) {
|
|
3230
3406
|
this.detach();
|
|
@@ -3258,37 +3434,50 @@ function HtmlFor(base) {
|
|
|
3258
3434
|
* @returns {T} A class that extends `base` with keyboard click behavior.
|
|
3259
3435
|
*/
|
|
3260
3436
|
function KeyboardClick(base, allowEnter = true) {
|
|
3261
|
-
var __KeyboardClickMixin_instances, __KeyboardClickMixin_keyUpHandler, __KeyboardClickMixin_handleKeyUp;
|
|
3437
|
+
var __KeyboardClickMixin_instances, __KeyboardClickMixin_keyPressed, __KeyboardClickMixin_keyDownHandler, __KeyboardClickMixin_keyUpHandler, __KeyboardClickMixin_focusOutHandler, __KeyboardClickMixin_handleKeyDown, __KeyboardClickMixin_handleKeyUp;
|
|
3262
3438
|
class _KeyboardClickMixin extends base {
|
|
3263
3439
|
constructor() {
|
|
3264
3440
|
super(...arguments);
|
|
3265
3441
|
__KeyboardClickMixin_instances.add(this);
|
|
3266
3442
|
/** @private */
|
|
3443
|
+
__KeyboardClickMixin_keyPressed.set(this, false);
|
|
3444
|
+
/** @private */
|
|
3445
|
+
__KeyboardClickMixin_keyDownHandler.set(this, e => __classPrivateFieldGet(this, __KeyboardClickMixin_instances, "m", __KeyboardClickMixin_handleKeyDown).call(this, e));
|
|
3267
3446
|
__KeyboardClickMixin_keyUpHandler.set(this, e => __classPrivateFieldGet(this, __KeyboardClickMixin_instances, "m", __KeyboardClickMixin_handleKeyUp).call(this, e));
|
|
3447
|
+
__KeyboardClickMixin_focusOutHandler.set(this, () => __classPrivateFieldSet(this, __KeyboardClickMixin_keyPressed, false, "f"));
|
|
3268
3448
|
}
|
|
3269
3449
|
/** @inheritdoc */
|
|
3270
3450
|
connectedCallback() {
|
|
3271
3451
|
super.connectedCallback();
|
|
3452
|
+
this.addEventListener("keydown", __classPrivateFieldGet(this, __KeyboardClickMixin_keyDownHandler, "f"));
|
|
3272
3453
|
this.addEventListener("keyup", __classPrivateFieldGet(this, __KeyboardClickMixin_keyUpHandler, "f"));
|
|
3454
|
+
this.addEventListener("focusout", __classPrivateFieldGet(this, __KeyboardClickMixin_focusOutHandler, "f"));
|
|
3273
3455
|
}
|
|
3274
3456
|
/** @inheritdoc */
|
|
3275
3457
|
disconnectedCallback() {
|
|
3276
3458
|
super.disconnectedCallback();
|
|
3459
|
+
this.removeEventListener("keydown", __classPrivateFieldGet(this, __KeyboardClickMixin_keyDownHandler, "f"));
|
|
3277
3460
|
this.removeEventListener("keyup", __classPrivateFieldGet(this, __KeyboardClickMixin_keyUpHandler, "f"));
|
|
3461
|
+
this.removeEventListener("focusout", __classPrivateFieldGet(this, __KeyboardClickMixin_focusOutHandler, "f"));
|
|
3278
3462
|
}
|
|
3279
3463
|
}
|
|
3280
|
-
__KeyboardClickMixin_keyUpHandler = new WeakMap(), __KeyboardClickMixin_instances = new WeakSet(),
|
|
3464
|
+
__KeyboardClickMixin_keyPressed = new WeakMap(), __KeyboardClickMixin_keyDownHandler = new WeakMap(), __KeyboardClickMixin_keyUpHandler = new WeakMap(), __KeyboardClickMixin_focusOutHandler = new WeakMap(), __KeyboardClickMixin_instances = new WeakSet(), __KeyboardClickMixin_handleKeyDown = function __KeyboardClickMixin_handleKeyDown(e) {
|
|
3281
3465
|
if (e.defaultPrevented || e.target !== e.currentTarget || isDisabledMixin(this) && this.disabled || isDisabledInteractiveMixin(this) && this.disabledInteractive) {
|
|
3282
3466
|
return;
|
|
3283
3467
|
}
|
|
3284
3468
|
if (e.key === " " || allowEnter && e.key === "Enter") {
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
}));
|
|
3469
|
+
__classPrivateFieldSet(this, __KeyboardClickMixin_keyPressed, true, "f");
|
|
3470
|
+
}
|
|
3471
|
+
}, __KeyboardClickMixin_handleKeyUp = function __KeyboardClickMixin_handleKeyUp(e) {
|
|
3472
|
+
if (e.defaultPrevented || e.target !== e.currentTarget || isDisabledMixin(this) && this.disabled || isDisabledInteractiveMixin(this) && this.disabledInteractive || !__classPrivateFieldGet(this, __KeyboardClickMixin_keyPressed, "f")) {
|
|
3473
|
+
return;
|
|
3291
3474
|
}
|
|
3475
|
+
// NOTE: the dispatched click event will not be trusted since it is synthetic.
|
|
3476
|
+
this.dispatchEvent(new MouseEvent("click", {
|
|
3477
|
+
cancelable: true,
|
|
3478
|
+
bubbles: true,
|
|
3479
|
+
composed: true
|
|
3480
|
+
}));
|
|
3292
3481
|
};
|
|
3293
3482
|
return _KeyboardClickMixin;
|
|
3294
3483
|
}
|
|
@@ -3903,6 +4092,40 @@ function Vertical(base) {
|
|
|
3903
4092
|
return _VerticalMixin;
|
|
3904
4093
|
}
|
|
3905
4094
|
|
|
4095
|
+
var _ActionElementBase_clickHandler;
|
|
4096
|
+
/**
|
|
4097
|
+
* A base implementation for an element, nested within a clickable element, used to
|
|
4098
|
+
* perform an action. This class must be inherited.
|
|
4099
|
+
*/
|
|
4100
|
+
class ActionElementBase extends LitElement {
|
|
4101
|
+
constructor() {
|
|
4102
|
+
super(...arguments);
|
|
4103
|
+
/** @private */
|
|
4104
|
+
_ActionElementBase_clickHandler.set(this, e => {
|
|
4105
|
+
if (!e.defaultPrevented) {
|
|
4106
|
+
this._onClick(e);
|
|
4107
|
+
}
|
|
4108
|
+
});
|
|
4109
|
+
}
|
|
4110
|
+
/** @inheritdoc */
|
|
4111
|
+
connectedCallback() {
|
|
4112
|
+
super.connectedCallback();
|
|
4113
|
+
this.parentElement?.addEventListener("click", __classPrivateFieldGet(this, _ActionElementBase_clickHandler, "f"));
|
|
4114
|
+
}
|
|
4115
|
+
/** @inheritdoc */
|
|
4116
|
+
disconnectedCallback() {
|
|
4117
|
+
super.disconnectedCallback();
|
|
4118
|
+
this.parentElement?.removeEventListener("click", __classPrivateFieldGet(this, _ActionElementBase_clickHandler, "f"));
|
|
4119
|
+
}
|
|
4120
|
+
/** @inheritdoc */
|
|
4121
|
+
render() {
|
|
4122
|
+
return html`<slot></slot>`;
|
|
4123
|
+
}
|
|
4124
|
+
}
|
|
4125
|
+
_ActionElementBase_clickHandler = new WeakMap();
|
|
4126
|
+
/** The styles of the element. */
|
|
4127
|
+
ActionElementBase.styles = css`:host { display: contents; } ::slotted(.material-icons) { font-size: inherit !important; }`;
|
|
4128
|
+
|
|
3906
4129
|
/* eslint-disable @typescript-eslint/no-unsafe-declaration-merging */
|
|
3907
4130
|
var _M3eCollapsibleElement_instances, _M3eCollapsibleElement_slotChanged, _M3eCollapsibleElement_hasOpened, _M3eCollapsibleElement_handleSlotChange, _M3eCollapsibleElement_autoSize, _M3eCollapsibleElement_clearSize, _M3eCollapsibleElement_actualSize;
|
|
3908
4131
|
/**
|
|
@@ -3957,6 +4180,11 @@ let M3eCollapsibleElement = class M3eCollapsibleElement extends EventAttribute(L
|
|
|
3957
4180
|
this.toggleAttribute("inert", !this.open);
|
|
3958
4181
|
if (this.open) {
|
|
3959
4182
|
__classPrivateFieldSet(this, _M3eCollapsibleElement_hasOpened, true, "f");
|
|
4183
|
+
if (!prefersReducedMotion()) {
|
|
4184
|
+
__classPrivateFieldGet(this, _M3eCollapsibleElement_instances, "m", _M3eCollapsibleElement_autoSize).call(this);
|
|
4185
|
+
this.classList.toggle("-overflows", this.clientHeight < this.scrollHeight);
|
|
4186
|
+
__classPrivateFieldGet(this, _M3eCollapsibleElement_instances, "m", _M3eCollapsibleElement_clearSize).call(this);
|
|
4187
|
+
}
|
|
3960
4188
|
this.classList.toggle("-closing", false);
|
|
3961
4189
|
this.classList.toggle("-opening", true);
|
|
3962
4190
|
this.dispatchEvent(new Event("opening"));
|
|
@@ -3964,6 +4192,7 @@ let M3eCollapsibleElement = class M3eCollapsibleElement extends EventAttribute(L
|
|
|
3964
4192
|
this.classList.toggle("-no-animate", false);
|
|
3965
4193
|
__classPrivateFieldGet(this, _M3eCollapsibleElement_instances, "m", _M3eCollapsibleElement_actualSize).call(this);
|
|
3966
4194
|
if (prefersReducedMotion()) {
|
|
4195
|
+
__classPrivateFieldGet(this, _M3eCollapsibleElement_instances, "m", _M3eCollapsibleElement_autoSize).call(this);
|
|
3967
4196
|
this.classList.toggle("-opening", false);
|
|
3968
4197
|
this.dispatchEvent(new Event("opened"));
|
|
3969
4198
|
} else {
|
|
@@ -4032,7 +4261,7 @@ M3eCollapsibleElement.styles = css`:host { display: block; height: 0px; overflow
|
|
|
4032
4261
|
padding-top var(--m3e-collapsible-animation-duration, ${DesignToken.motion.duration.medium1})
|
|
4033
4262
|
${DesignToken.motion.easing.standard},
|
|
4034
4263
|
padding-bottom var(--m3e-collapsible-animation-duration, ${DesignToken.motion.duration.medium1})
|
|
4035
|
-
${DesignToken.motion.easing.standard}`)}; } :host(:not(.-closing):not([open])) { visibility: hidden; } :host(:not([open])) { min-height: unset !important; padding-top: 0px !important; padding-bottom: 0px !important; } :host(.-no-animate) { transition-duration: 0ms; } ::slotted(*) { --m3e-collapsible-animation-duration: initial; } @media (prefers-reduced-motion) { :host { transition: none; } }`;
|
|
4264
|
+
${DesignToken.motion.easing.standard}`)}; } :host(:not(.-closing):not([open])) { visibility: hidden; } :host(:not([open])) { min-height: unset !important; padding-top: 0px !important; padding-bottom: 0px !important; } :host(.-no-animate) { transition-duration: 0ms; } :host(.-opening), :host(.-closing) { overflow-y: hidden !important; } :host(.-overflows) { scrollbar-gutter: stable; } ::slotted(*) { --m3e-collapsible-animation-duration: initial; } @media (prefers-reduced-motion) { :host { transition: none; } }`;
|
|
4036
4265
|
__decorate([n$1({
|
|
4037
4266
|
type: Boolean,
|
|
4038
4267
|
reflect: true
|
|
@@ -4710,7 +4939,9 @@ let M3eScrollContainerElement = class M3eScrollContainerElement extends LitEleme
|
|
|
4710
4939
|
if (changedProperties.has("dividers")) {
|
|
4711
4940
|
this.removeEventListener("scroll", __classPrivateFieldGet(this, _M3eScrollContainerElement_scrollHandler, "f"));
|
|
4712
4941
|
if (this.dividers !== "none") {
|
|
4713
|
-
this.addEventListener("scroll", __classPrivateFieldGet(this, _M3eScrollContainerElement_scrollHandler, "f")
|
|
4942
|
+
this.addEventListener("scroll", __classPrivateFieldGet(this, _M3eScrollContainerElement_scrollHandler, "f"), {
|
|
4943
|
+
passive: true
|
|
4944
|
+
});
|
|
4714
4945
|
}
|
|
4715
4946
|
}
|
|
4716
4947
|
}
|
|
@@ -4870,7 +5101,8 @@ var _M3eStateLayerElement_instances, _M3eStateLayerElement_hoverController, _M3e
|
|
|
4870
5101
|
*
|
|
4871
5102
|
* @tag m3e-state-layer
|
|
4872
5103
|
*
|
|
4873
|
-
* @attr disabled - Whether hover and focus
|
|
5104
|
+
* @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.
|
|
5105
|
+
* @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.
|
|
4874
5106
|
*
|
|
4875
5107
|
* @cssprop --m3e-state-layer-duration - Duration of state layer changes.
|
|
4876
5108
|
* @cssprop --m3e-state-layer-easing - Easing curve of state layer changes.
|
|
@@ -4894,11 +5126,17 @@ let M3eStateLayerElement = class M3eStateLayerElement extends HtmlFor(Role(LitEl
|
|
|
4894
5126
|
callback: (focused, focusVisible) => __classPrivateFieldGet(this, _M3eStateLayerElement_instances, "m", _M3eStateLayerElement_handleFocusChange).call(this, focused && focusVisible)
|
|
4895
5127
|
}));
|
|
4896
5128
|
/**
|
|
4897
|
-
* Whether hover and focus
|
|
5129
|
+
* Whether hover and focus events will not trigger the state layer. State layers can still
|
|
4898
5130
|
* be controlled manually using the `show` and `hide` methods.
|
|
4899
5131
|
* @default false
|
|
4900
5132
|
*/
|
|
4901
5133
|
this.disabled = false;
|
|
5134
|
+
/**
|
|
5135
|
+
* Whether hover events will not trigger the state layer. State layers can still
|
|
5136
|
+
* be controlled manually using the `show` and `hide` methods.
|
|
5137
|
+
* @default false
|
|
5138
|
+
*/
|
|
5139
|
+
this.disableHover = false;
|
|
4902
5140
|
}
|
|
4903
5141
|
/**
|
|
4904
5142
|
* Launches a manual state layer.
|
|
@@ -4946,6 +5184,9 @@ let M3eStateLayerElement = class M3eStateLayerElement extends HtmlFor(Role(LitEl
|
|
|
4946
5184
|
this.hide("hover");
|
|
4947
5185
|
this.hide("focused");
|
|
4948
5186
|
}
|
|
5187
|
+
if (_changedProperties.has("disableHover") && this.disableHover) {
|
|
5188
|
+
this.hide("hover");
|
|
5189
|
+
}
|
|
4949
5190
|
}
|
|
4950
5191
|
/** @inheritdoc */
|
|
4951
5192
|
render() {
|
|
@@ -4956,7 +5197,7 @@ _M3eStateLayerElement_hoverController = new WeakMap();
|
|
|
4956
5197
|
_M3eStateLayerElement_focusController = new WeakMap();
|
|
4957
5198
|
_M3eStateLayerElement_instances = new WeakSet();
|
|
4958
5199
|
_M3eStateLayerElement_handleHoverChange = function _M3eStateLayerElement_handleHoverChange(hovering) {
|
|
4959
|
-
if (!this.disabled) {
|
|
5200
|
+
if (!this.disabled && !this.disableHover) {
|
|
4960
5201
|
if (hovering) {
|
|
4961
5202
|
this.show("hover");
|
|
4962
5203
|
} else {
|
|
@@ -4980,6 +5221,11 @@ __decorate([n$1({
|
|
|
4980
5221
|
type: Boolean,
|
|
4981
5222
|
reflect: true
|
|
4982
5223
|
})], M3eStateLayerElement.prototype, "disabled", void 0);
|
|
5224
|
+
__decorate([n$1({
|
|
5225
|
+
attribute: "disable-hover",
|
|
5226
|
+
type: Boolean,
|
|
5227
|
+
reflect: true
|
|
5228
|
+
})], M3eStateLayerElement.prototype, "disableHover", void 0);
|
|
4983
5229
|
M3eStateLayerElement = __decorate([t$2("m3e-state-layer")], M3eStateLayerElement);
|
|
4984
5230
|
|
|
4985
5231
|
/**
|
|
@@ -5210,5 +5456,5 @@ __decorate([n$1({
|
|
|
5210
5456
|
})], M3eTextHighlightElement.prototype, "caseSensitive", void 0);
|
|
5211
5457
|
M3eTextHighlightElement = M3eTextHighlightElement_1 = __decorate([t$2("m3e-text-highlight")], M3eTextHighlightElement);
|
|
5212
5458
|
|
|
5213
|
-
export { AttachInternals, Checked, CheckedIndeterminate, ConstraintValidation, DesignToken, Dirty, Disabled, DisabledInteractive, EventAttribute, FocusController, Focusable, FormAssociated, FormSubmitter, HoverController, HtmlFor, IntersectionController, KeyboardClick, Labelled, LinkButton, LongPressController, M3eCollapsibleElement, M3eElevationElement, M3eFocusRingElement, M3ePseudoCheckboxElement, M3ePseudoRadioElement, M3eRippleElement, M3eScrollContainerElement, M3eSlideElement, M3eStateLayerElement, M3eTextHighlightElement, M3eTextOverflowElement, MutationController, PressedController, ReadOnly, Required, RequiredConstraintValidation, ResizeController, Role, ScrollController, Selected, Touched, Vertical, checkOrSelect, debounce, defaultValue, forcedColorsActive, formValue, generateClipPaths, getTextContent, guid, hasAssignedNodes, hasKeys, internals, isAttachInternalsMixin, isCheckedIndeterminateMixin, isCheckedMixin, isCheckedOrSelected, isCheckedOrSelectedMixin, isConstraintValidationMixin, isDirtyMixin, isDisabledInteractiveMixin, isDisabledMixin, isFormAssociatedMixin, isFormSubmitterMixin, isHtmlForMixin, isLabelledMixin, isLinkButtonMixin, isReadOnlyMixin, isRequiredConstraintValidationMixin, isRequiredMixin, isSelectedMixin, isTouchedMixin, isVerticalMixin, prefersReducedMotion, renderPseudoLink, safeStyleMap, scrollIntoViewIfNeeded, updateLabels, validate };
|
|
5459
|
+
export { ActionElementBase, AnimationLoopController, AttachInternals, Checked, CheckedIndeterminate, ConstraintValidation, DesignToken, Dirty, Disabled, DisabledInteractive, EventAttribute, FocusController, Focusable, FormAssociated, FormSubmitter, HoverController, HtmlFor, IntersectionController, KeyboardClick, Labelled, LinkButton, LongPressController, M3eCollapsibleElement, M3eElevationElement, M3eFocusRingElement, M3ePseudoCheckboxElement, M3ePseudoRadioElement, M3eRippleElement, M3eScrollContainerElement, M3eSlideElement, M3eStateLayerElement, M3eTextHighlightElement, M3eTextOverflowElement, MutationController, PressedController, ReadOnly, Required, RequiredConstraintValidation, ResizeController, Role, ScrollController, Selected, Touched, Vertical, checkOrSelect, debounce, defaultValue, focusWhenReady, forcedColorsActive, formValue, generateClipPaths, getTextContent, guid, hasAssignedNodes, hasKeys, interceptProperty, internals, isAttachInternalsMixin, isCheckedIndeterminateMixin, isCheckedMixin, isCheckedOrSelected, isCheckedOrSelectedMixin, isConstraintValidationMixin, isDirtyMixin, isDisabledInteractiveMixin, isDisabledMixin, isFormAssociatedMixin, isFormSubmitterMixin, isHtmlForMixin, isLabelledMixin, isLinkButtonMixin, isReadOnlyMixin, isRequiredConstraintValidationMixin, isRequiredMixin, isSelectedMixin, isTouchedMixin, isVerticalMixin, prefersReducedMotion, renderPseudoLink, resolveElementById, resolveFragmentUrl, safeStyleMap, scrollIntoViewIfNeeded, updateLabels, validate };
|
|
5214
5460
|
//# sourceMappingURL=index.js.map
|