@jsenv/dom 0.8.6 → 0.8.8
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/jsenv_dom.js +107 -60
- package/package.json +9 -4
package/dist/jsenv_dom.js
CHANGED
|
@@ -422,6 +422,40 @@ const parseCSSColor = (color, element) => {
|
|
|
422
422
|
return parseCSSColor(resolvedColor, element);
|
|
423
423
|
}
|
|
424
424
|
|
|
425
|
+
if (color.startsWith("color-mix(")) {
|
|
426
|
+
return color;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
// Pass through CSS functions that we don't want to resolve
|
|
430
|
+
if (
|
|
431
|
+
color.includes("calc(") ||
|
|
432
|
+
color.includes("min(") ||
|
|
433
|
+
color.includes("max(") ||
|
|
434
|
+
color.includes("clamp(") ||
|
|
435
|
+
color.includes("env(") ||
|
|
436
|
+
color.includes("attr(")
|
|
437
|
+
) {
|
|
438
|
+
return color;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
// Pass through CSS color functions we don't handle
|
|
442
|
+
if (
|
|
443
|
+
color.startsWith("color(") ||
|
|
444
|
+
color.startsWith("lch(") ||
|
|
445
|
+
color.startsWith("oklch(") ||
|
|
446
|
+
color.startsWith("lab(") ||
|
|
447
|
+
color.startsWith("oklab(") ||
|
|
448
|
+
color.startsWith("hwb(") ||
|
|
449
|
+
color.includes("color-contrast(")
|
|
450
|
+
) {
|
|
451
|
+
return color;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
// Pass through relative color syntax (CSS Color Module Level 5)
|
|
455
|
+
if (color.includes(" from ")) {
|
|
456
|
+
return color;
|
|
457
|
+
}
|
|
458
|
+
|
|
425
459
|
// If it's a CSS custom property, resolve it using getComputedStyle
|
|
426
460
|
if (resolvedColor.includes("var(")) {
|
|
427
461
|
if (!element) {
|
|
@@ -3671,26 +3705,29 @@ const createPreviousNodeIterator = (fromNode, rootNode, skipRoot = null) => {
|
|
|
3671
3705
|
};
|
|
3672
3706
|
};
|
|
3673
3707
|
|
|
3674
|
-
const activeElementSignal = signal(
|
|
3675
|
-
|
|
3676
|
-
document.addEventListener(
|
|
3677
|
-
"focus",
|
|
3678
|
-
() => {
|
|
3679
|
-
activeElementSignal.value = document.activeElement;
|
|
3680
|
-
},
|
|
3681
|
-
{ capture: true },
|
|
3708
|
+
const activeElementSignal = signal(
|
|
3709
|
+
typeof document === "object" ? document.activeElement : undefined,
|
|
3682
3710
|
);
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
(e) => {
|
|
3688
|
-
if (!e.relatedTarget) {
|
|
3711
|
+
if (typeof document === "object") {
|
|
3712
|
+
document.addEventListener(
|
|
3713
|
+
"focus",
|
|
3714
|
+
() => {
|
|
3689
3715
|
activeElementSignal.value = document.activeElement;
|
|
3690
|
-
}
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
3716
|
+
},
|
|
3717
|
+
{ capture: true },
|
|
3718
|
+
);
|
|
3719
|
+
// When clicking on document there is no "focus" event dispatched on the document
|
|
3720
|
+
// We can detect that with "blur" event when relatedTarget is null
|
|
3721
|
+
document.addEventListener(
|
|
3722
|
+
"blur",
|
|
3723
|
+
(e) => {
|
|
3724
|
+
if (!e.relatedTarget) {
|
|
3725
|
+
activeElementSignal.value = document.activeElement;
|
|
3726
|
+
}
|
|
3727
|
+
},
|
|
3728
|
+
{ capture: true },
|
|
3729
|
+
);
|
|
3730
|
+
}
|
|
3694
3731
|
|
|
3695
3732
|
const useActiveElement = () => {
|
|
3696
3733
|
return activeElementSignal.value;
|
|
@@ -5059,7 +5096,8 @@ const bodyIsScrollable = (body) => {
|
|
|
5059
5096
|
// https://developer.mozilla.org/en-US/docs/Glossary/Scroll_container
|
|
5060
5097
|
|
|
5061
5098
|
|
|
5062
|
-
const { documentElement: documentElement$2 } =
|
|
5099
|
+
const { documentElement: documentElement$2 } =
|
|
5100
|
+
typeof document === "object" ? document : { documentElement: null };
|
|
5063
5101
|
|
|
5064
5102
|
const getScrollContainer = (arg, { includeHidden } = {}) => {
|
|
5065
5103
|
if (typeof arg !== "object" || arg.nodeType !== 1) {
|
|
@@ -5300,7 +5338,8 @@ const getBorderSizes = (element) => {
|
|
|
5300
5338
|
*/
|
|
5301
5339
|
|
|
5302
5340
|
|
|
5303
|
-
const { documentElement: documentElement$1 } =
|
|
5341
|
+
const { documentElement: documentElement$1 } =
|
|
5342
|
+
typeof document === "object" ? document : { documentElement: null };
|
|
5304
5343
|
|
|
5305
5344
|
/**
|
|
5306
5345
|
* Get element rectangle relative to its scroll container
|
|
@@ -6163,7 +6202,9 @@ const isOverlayOf = (element, potentialTarget) => {
|
|
|
6163
6202
|
return false;
|
|
6164
6203
|
};
|
|
6165
6204
|
|
|
6166
|
-
const { documentElement } =
|
|
6205
|
+
const { documentElement } =
|
|
6206
|
+
typeof document === "object" ? document : { documentElement: null };
|
|
6207
|
+
|
|
6167
6208
|
const createGetScrollOffsets = (
|
|
6168
6209
|
scrollContainer,
|
|
6169
6210
|
referenceScrollContainer,
|
|
@@ -7037,12 +7078,12 @@ const createConstraintFeedbackLine = () => {
|
|
|
7037
7078
|
import.meta.css = /* css */ `
|
|
7038
7079
|
.navi_constraint_feedback_line {
|
|
7039
7080
|
position: fixed;
|
|
7040
|
-
pointer-events: none;
|
|
7041
7081
|
z-index: 9998;
|
|
7082
|
+
border-top: 2px dotted rgba(59, 130, 246, 0.7);
|
|
7042
7083
|
visibility: hidden;
|
|
7043
|
-
transition: opacity 0.15s ease;
|
|
7044
7084
|
transform-origin: left center;
|
|
7045
|
-
|
|
7085
|
+
transition: opacity 0.15s ease;
|
|
7086
|
+
pointer-events: none;
|
|
7046
7087
|
}
|
|
7047
7088
|
|
|
7048
7089
|
.navi_constraint_feedback_line[data-visible] {
|
|
@@ -7483,11 +7524,11 @@ import.meta.css = /* css */ `
|
|
|
7483
7524
|
position: fixed;
|
|
7484
7525
|
top: 0;
|
|
7485
7526
|
left: 0;
|
|
7527
|
+
z-index: 999998;
|
|
7486
7528
|
width: 100vw;
|
|
7487
7529
|
height: 100vh;
|
|
7488
|
-
overflow: hidden;
|
|
7489
7530
|
pointer-events: none;
|
|
7490
|
-
|
|
7531
|
+
overflow: hidden;
|
|
7491
7532
|
--marker-size: ${MARKER_SIZE}px;
|
|
7492
7533
|
}
|
|
7493
7534
|
|
|
@@ -7552,33 +7593,33 @@ import.meta.css = /* css */ `
|
|
|
7552
7593
|
|
|
7553
7594
|
.navi_debug_marker_label {
|
|
7554
7595
|
position: absolute;
|
|
7555
|
-
|
|
7596
|
+
padding: 2px 6px;
|
|
7597
|
+
color: rgb(from var(--marker-color) r g b / 1);
|
|
7556
7598
|
font-weight: bold;
|
|
7599
|
+
font-size: 12px;
|
|
7600
|
+
white-space: nowrap;
|
|
7557
7601
|
background: rgba(255, 255, 255, 0.9);
|
|
7558
|
-
padding: 2px 6px;
|
|
7559
|
-
border-radius: 3px;
|
|
7560
7602
|
border: 1px solid;
|
|
7561
|
-
white-space: nowrap;
|
|
7562
|
-
pointer-events: none;
|
|
7563
|
-
color: rgb(from var(--marker-color) r g b / 1);
|
|
7564
7603
|
border-color: rgb(from var(--marker-color) r g b / 1);
|
|
7604
|
+
border-radius: 3px;
|
|
7605
|
+
pointer-events: none;
|
|
7565
7606
|
}
|
|
7566
7607
|
|
|
7567
7608
|
/* Label positioning based on side data attributes */
|
|
7568
7609
|
|
|
7569
7610
|
/* Left side markers - vertical with 90° rotation */
|
|
7570
7611
|
.navi_debug_marker[data-left] .navi_debug_marker_label {
|
|
7571
|
-
left: 10px;
|
|
7572
7612
|
top: 20px;
|
|
7613
|
+
left: 10px;
|
|
7573
7614
|
transform: rotate(90deg);
|
|
7574
7615
|
transform-origin: left center;
|
|
7575
7616
|
}
|
|
7576
7617
|
|
|
7577
7618
|
/* Right side markers - vertical with -90° rotation */
|
|
7578
7619
|
.navi_debug_marker[data-right] .navi_debug_marker_label {
|
|
7620
|
+
top: 20px;
|
|
7579
7621
|
right: 10px;
|
|
7580
7622
|
left: auto;
|
|
7581
|
-
top: 20px;
|
|
7582
7623
|
transform: rotate(-90deg);
|
|
7583
7624
|
transform-origin: right center;
|
|
7584
7625
|
}
|
|
@@ -7591,16 +7632,16 @@ import.meta.css = /* css */ `
|
|
|
7591
7632
|
|
|
7592
7633
|
/* Bottom side markers - horizontal, label on the line */
|
|
7593
7634
|
.navi_debug_marker[data-bottom] .navi_debug_marker_label {
|
|
7594
|
-
bottom: 0px;
|
|
7595
7635
|
top: auto;
|
|
7636
|
+
bottom: 0px;
|
|
7596
7637
|
left: 20px;
|
|
7597
7638
|
}
|
|
7598
7639
|
|
|
7599
7640
|
.navi_obstacle_marker {
|
|
7600
7641
|
position: absolute;
|
|
7642
|
+
z-index: 9999;
|
|
7601
7643
|
background-color: orange;
|
|
7602
7644
|
opacity: 0.6;
|
|
7603
|
-
z-index: 9999;
|
|
7604
7645
|
pointer-events: none;
|
|
7605
7646
|
}
|
|
7606
7647
|
|
|
@@ -7608,20 +7649,20 @@ import.meta.css = /* css */ `
|
|
|
7608
7649
|
position: absolute;
|
|
7609
7650
|
top: 50%;
|
|
7610
7651
|
left: 50%;
|
|
7611
|
-
transform: translate(-50%, -50%);
|
|
7612
|
-
font-size: 12px;
|
|
7613
|
-
font-weight: bold;
|
|
7614
7652
|
color: white;
|
|
7653
|
+
font-weight: bold;
|
|
7654
|
+
font-size: 12px;
|
|
7615
7655
|
text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.8);
|
|
7656
|
+
transform: translate(-50%, -50%);
|
|
7616
7657
|
pointer-events: none;
|
|
7617
7658
|
}
|
|
7618
7659
|
|
|
7619
7660
|
.navi_element_marker {
|
|
7620
7661
|
position: absolute;
|
|
7662
|
+
z-index: 9997;
|
|
7621
7663
|
background-color: var(--element-color-alpha, rgba(255, 0, 150, 0.3));
|
|
7622
7664
|
border: 2px solid var(--element-color, rgb(255, 0, 150));
|
|
7623
7665
|
opacity: 0.9;
|
|
7624
|
-
z-index: 9997;
|
|
7625
7666
|
pointer-events: none;
|
|
7626
7667
|
}
|
|
7627
7668
|
|
|
@@ -7629,23 +7670,23 @@ import.meta.css = /* css */ `
|
|
|
7629
7670
|
position: absolute;
|
|
7630
7671
|
top: -25px;
|
|
7631
7672
|
right: 0;
|
|
7632
|
-
|
|
7633
|
-
font-weight: bold;
|
|
7673
|
+
padding: 2px 6px;
|
|
7634
7674
|
color: var(--element-color, rgb(255, 0, 150));
|
|
7675
|
+
font-weight: bold;
|
|
7676
|
+
font-size: 11px;
|
|
7677
|
+
white-space: nowrap;
|
|
7635
7678
|
background: rgba(255, 255, 255, 0.9);
|
|
7636
|
-
padding: 2px 6px;
|
|
7637
|
-
border-radius: 3px;
|
|
7638
7679
|
border: 1px solid var(--element-color, rgb(255, 0, 150));
|
|
7639
|
-
|
|
7680
|
+
border-radius: 3px;
|
|
7640
7681
|
pointer-events: none;
|
|
7641
7682
|
}
|
|
7642
7683
|
|
|
7643
7684
|
.navi_reference_element_marker {
|
|
7644
7685
|
position: absolute;
|
|
7686
|
+
z-index: 9998;
|
|
7645
7687
|
background-color: rgba(0, 150, 255, 0.3);
|
|
7646
7688
|
border: 2px dashed rgba(0, 150, 255, 0.7);
|
|
7647
7689
|
opacity: 0.8;
|
|
7648
|
-
z-index: 9998;
|
|
7649
7690
|
pointer-events: none;
|
|
7650
7691
|
}
|
|
7651
7692
|
|
|
@@ -7653,14 +7694,14 @@ import.meta.css = /* css */ `
|
|
|
7653
7694
|
position: absolute;
|
|
7654
7695
|
top: -25px;
|
|
7655
7696
|
left: 0;
|
|
7656
|
-
|
|
7657
|
-
font-weight: bold;
|
|
7697
|
+
padding: 2px 6px;
|
|
7658
7698
|
color: rgba(0, 150, 255, 1);
|
|
7699
|
+
font-weight: bold;
|
|
7700
|
+
font-size: 11px;
|
|
7701
|
+
white-space: nowrap;
|
|
7659
7702
|
background: rgba(255, 255, 255, 0.9);
|
|
7660
|
-
padding: 2px 6px;
|
|
7661
|
-
border-radius: 3px;
|
|
7662
7703
|
border: 1px solid rgba(0, 150, 255, 0.7);
|
|
7663
|
-
|
|
7704
|
+
border-radius: 3px;
|
|
7664
7705
|
pointer-events: none;
|
|
7665
7706
|
}
|
|
7666
7707
|
`;
|
|
@@ -8318,7 +8359,7 @@ const createDragToMoveGestureController = ({
|
|
|
8318
8359
|
{ element, referenceElement, elementToMove, convertScrollablePosition },
|
|
8319
8360
|
) => {
|
|
8320
8361
|
const direction = dragGesture.gestureInfo.direction;
|
|
8321
|
-
dragGesture.gestureInfo.name;
|
|
8362
|
+
// const dragGestureName = dragGesture.gestureInfo.name;
|
|
8322
8363
|
const scrollContainer = dragGesture.gestureInfo.scrollContainer;
|
|
8323
8364
|
const elementImpacted = elementToMove || element;
|
|
8324
8365
|
const translateXAtGrab = dragStyleController.getUnderlyingValue(
|
|
@@ -8375,7 +8416,9 @@ const createDragToMoveGestureController = ({
|
|
|
8375
8416
|
autoScrollArea,
|
|
8376
8417
|
{
|
|
8377
8418
|
scrollContainer,
|
|
8378
|
-
direction
|
|
8419
|
+
direction,
|
|
8420
|
+
// dragGestureName,
|
|
8421
|
+
},
|
|
8379
8422
|
);
|
|
8380
8423
|
}
|
|
8381
8424
|
if (autoScrollAreaPadding > 0) {
|
|
@@ -8828,10 +8871,10 @@ const getWidth = (element) => {
|
|
|
8828
8871
|
installImportMetaCss(import.meta);
|
|
8829
8872
|
import.meta.css = /* css */ `
|
|
8830
8873
|
[data-position-sticky-placeholder] {
|
|
8831
|
-
opacity: 0 !important;
|
|
8832
8874
|
position: static !important;
|
|
8833
8875
|
width: auto !important;
|
|
8834
8876
|
height: auto !important;
|
|
8877
|
+
opacity: 0 !important;
|
|
8835
8878
|
}
|
|
8836
8879
|
`;
|
|
8837
8880
|
|
|
@@ -9665,7 +9708,9 @@ const startTimeline = () => {
|
|
|
9665
9708
|
backgroundUpdateLoop.start();
|
|
9666
9709
|
animationUpdateLoop.start();
|
|
9667
9710
|
};
|
|
9668
|
-
|
|
9711
|
+
if (typeof document === "object") {
|
|
9712
|
+
startTimeline();
|
|
9713
|
+
}
|
|
9669
9714
|
|
|
9670
9715
|
// Default lifecycle methods that do nothing
|
|
9671
9716
|
const LIFECYCLE_DEFAULT = {
|
|
@@ -9685,11 +9730,13 @@ const onTransitionPausedByBreakpoint = (transition) => {
|
|
|
9685
9730
|
const cleanupTransitionPausedByBreakpoint = (transition) => {
|
|
9686
9731
|
transitionPausedByBreakpointWeakSet.delete(transition);
|
|
9687
9732
|
};
|
|
9688
|
-
window
|
|
9689
|
-
|
|
9690
|
-
transition
|
|
9691
|
-
|
|
9692
|
-
}
|
|
9733
|
+
if (typeof window !== "undefined") {
|
|
9734
|
+
window.resumeTransitions = () => {
|
|
9735
|
+
for (const transition of transitionPausedByBreakpointWeakSet) {
|
|
9736
|
+
transition.play();
|
|
9737
|
+
}
|
|
9738
|
+
};
|
|
9739
|
+
}
|
|
9693
9740
|
|
|
9694
9741
|
const combineTwoLifecycle = (lifecycleA, lifecycleB) => {
|
|
9695
9742
|
if (!lifecycleA && !lifecycleB) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/dom",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.8",
|
|
4
4
|
"description": "DOM utilities for writing frontend code",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -18,8 +18,13 @@
|
|
|
18
18
|
"type": "module",
|
|
19
19
|
"exports": {
|
|
20
20
|
".": {
|
|
21
|
-
"
|
|
22
|
-
|
|
21
|
+
"node": {
|
|
22
|
+
"default": "./index_node.js"
|
|
23
|
+
},
|
|
24
|
+
"browser": {
|
|
25
|
+
"dev:jsenv": "./index.js",
|
|
26
|
+
"default": "./dist/jsenv_dom.js"
|
|
27
|
+
}
|
|
23
28
|
},
|
|
24
29
|
"./details_content_full_height": "./src/size/details_content_full_height.js",
|
|
25
30
|
"./details_toggle_animation": "./src/details_toggle_animation.js",
|
|
@@ -37,7 +42,7 @@
|
|
|
37
42
|
"@jsenv/core": "../../../",
|
|
38
43
|
"@jsenv/navi": "../navi",
|
|
39
44
|
"@jsenv/snapshot": "../../tooling/snapshot",
|
|
40
|
-
"@preact/signals": "2.5.
|
|
45
|
+
"@preact/signals": "2.5.1",
|
|
41
46
|
"preact": "11.0.0-beta.0"
|
|
42
47
|
},
|
|
43
48
|
"publishConfig": {
|