@jsenv/dom 0.7.0 → 0.7.2
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 +103 -24
- package/package.json +1 -1
package/dist/jsenv_dom.js
CHANGED
|
@@ -544,6 +544,9 @@ const normalizeNumber = (value, { unit, propertyName, preferedType }) => {
|
|
|
544
544
|
if (typeof value === "string") {
|
|
545
545
|
// Keep strings as-is (including %, em, rem, auto, none, etc.)
|
|
546
546
|
if (preferedType === "string") {
|
|
547
|
+
if (unit && !value.endsWith(unit)) {
|
|
548
|
+
return `${value}${unit}`;
|
|
549
|
+
}
|
|
547
550
|
return value;
|
|
548
551
|
}
|
|
549
552
|
// convert to number if possible (font-size: "12px" -> fontSize:12, opacity: "0.5" -> opacity: 0.5)
|
|
@@ -570,14 +573,21 @@ const normalizeNumber = (value, { unit, propertyName, preferedType }) => {
|
|
|
570
573
|
};
|
|
571
574
|
|
|
572
575
|
// Normalize styles for DOM application
|
|
573
|
-
const normalizeStyles = (styles, context = "js") => {
|
|
576
|
+
const normalizeStyles = (styles, context = "js", mutate = false) => {
|
|
574
577
|
if (!styles) {
|
|
575
|
-
return {};
|
|
578
|
+
return mutate ? styles : {};
|
|
576
579
|
}
|
|
577
580
|
if (typeof styles === "string") {
|
|
578
581
|
styles = parseStyleString(styles);
|
|
579
582
|
return styles;
|
|
580
583
|
}
|
|
584
|
+
if (mutate) {
|
|
585
|
+
for (const key of Object.keys(styles)) {
|
|
586
|
+
const value = styles[key];
|
|
587
|
+
styles[key] = normalizeStyle(value, key, context);
|
|
588
|
+
}
|
|
589
|
+
return styles;
|
|
590
|
+
}
|
|
581
591
|
const normalized = {};
|
|
582
592
|
for (const key of Object.keys(styles)) {
|
|
583
593
|
const value = styles[key];
|
|
@@ -8317,7 +8327,7 @@ const createTransition = ({
|
|
|
8317
8327
|
transition.value = value;
|
|
8318
8328
|
transition.timing = isLast ? "end" : isFirstUpdate ? "start" : "progress";
|
|
8319
8329
|
isFirstUpdate = false;
|
|
8320
|
-
executionLifecycle.update(transition);
|
|
8330
|
+
executionLifecycle.update?.(transition);
|
|
8321
8331
|
executeUpdateCallbacks(transition);
|
|
8322
8332
|
},
|
|
8323
8333
|
|
|
@@ -8339,8 +8349,8 @@ const createTransition = ({
|
|
|
8339
8349
|
cancel: () => {
|
|
8340
8350
|
if (executionLifecycle) {
|
|
8341
8351
|
lifecycle.cancel(transition);
|
|
8342
|
-
executionLifecycle.teardown();
|
|
8343
|
-
executionLifecycle.restore();
|
|
8352
|
+
executionLifecycle.teardown?.();
|
|
8353
|
+
executionLifecycle.restore?.();
|
|
8344
8354
|
}
|
|
8345
8355
|
resume = null;
|
|
8346
8356
|
playState = "idle";
|
|
@@ -8357,7 +8367,7 @@ const createTransition = ({
|
|
|
8357
8367
|
}
|
|
8358
8368
|
// "running" or "paused"
|
|
8359
8369
|
lifecycle.finish(transition);
|
|
8360
|
-
executionLifecycle.teardown();
|
|
8370
|
+
executionLifecycle.teardown?.();
|
|
8361
8371
|
resume = null;
|
|
8362
8372
|
playState = "finished";
|
|
8363
8373
|
executeFinishCallbacks();
|
|
@@ -8589,9 +8599,6 @@ const createHeightTransition = (element, to, options) => {
|
|
|
8589
8599
|
teardown: () => {
|
|
8590
8600
|
transitionStyleController.delete(element, "height");
|
|
8591
8601
|
},
|
|
8592
|
-
restore: () => {
|
|
8593
|
-
transitionStyleController.delete(element, "height");
|
|
8594
|
-
},
|
|
8595
8602
|
};
|
|
8596
8603
|
},
|
|
8597
8604
|
},
|
|
@@ -8616,9 +8623,6 @@ const createWidthTransition = (element, to, options) => {
|
|
|
8616
8623
|
teardown: () => {
|
|
8617
8624
|
transitionStyleController.delete(element, "width");
|
|
8618
8625
|
},
|
|
8619
|
-
restore: () => {
|
|
8620
|
-
transitionStyleController.delete(element, "width");
|
|
8621
|
-
},
|
|
8622
8626
|
};
|
|
8623
8627
|
},
|
|
8624
8628
|
},
|
|
@@ -8643,9 +8647,6 @@ const createOpacityTransition = (element, to, options = {}) => {
|
|
|
8643
8647
|
teardown: () => {
|
|
8644
8648
|
transitionStyleController.delete(element, "opacity");
|
|
8645
8649
|
},
|
|
8646
|
-
restore: () => {
|
|
8647
|
-
transitionStyleController.delete(element, "opacity");
|
|
8648
|
-
},
|
|
8649
8650
|
};
|
|
8650
8651
|
},
|
|
8651
8652
|
},
|
|
@@ -8653,9 +8654,10 @@ const createOpacityTransition = (element, to, options = {}) => {
|
|
|
8653
8654
|
return opacityTransition;
|
|
8654
8655
|
};
|
|
8655
8656
|
|
|
8656
|
-
const createTranslateXTransition = (element, to, options) => {
|
|
8657
|
+
const createTranslateXTransition = (element, to, options = {}) => {
|
|
8658
|
+
const { setup, ...rest } = options;
|
|
8657
8659
|
const translateXTransition = createTimelineTransition({
|
|
8658
|
-
...
|
|
8660
|
+
...rest,
|
|
8659
8661
|
constructor: createTranslateXTransition,
|
|
8660
8662
|
key: element,
|
|
8661
8663
|
to,
|
|
@@ -8663,6 +8665,7 @@ const createTranslateXTransition = (element, to, options) => {
|
|
|
8663
8665
|
isVisual: true,
|
|
8664
8666
|
lifecycle: {
|
|
8665
8667
|
setup: () => {
|
|
8668
|
+
const teardown = setup?.();
|
|
8666
8669
|
return {
|
|
8667
8670
|
from: getTranslateX(element),
|
|
8668
8671
|
update: ({ value }) => {
|
|
@@ -8673,9 +8676,7 @@ const createTranslateXTransition = (element, to, options) => {
|
|
|
8673
8676
|
});
|
|
8674
8677
|
},
|
|
8675
8678
|
teardown: () => {
|
|
8676
|
-
|
|
8677
|
-
},
|
|
8678
|
-
restore: () => {
|
|
8679
|
+
teardown?.();
|
|
8679
8680
|
transitionStyleController.delete(element, "transform.translateX");
|
|
8680
8681
|
},
|
|
8681
8682
|
};
|
|
@@ -10276,15 +10277,26 @@ const useResizeStatus = (elementRef, { as = "number" } = {}) => {
|
|
|
10276
10277
|
|
|
10277
10278
|
installImportMetaCss(import.meta);
|
|
10278
10279
|
import.meta.css = /* css */ `
|
|
10280
|
+
.ui_transition_container[data-transition-overflow] {
|
|
10281
|
+
overflow: hidden;
|
|
10282
|
+
}
|
|
10283
|
+
|
|
10279
10284
|
.ui_transition_container,
|
|
10280
10285
|
.ui_transition_outer_wrapper,
|
|
10281
10286
|
.ui_transition_measure_wrapper,
|
|
10282
10287
|
.ui_transition_slot,
|
|
10283
10288
|
.ui_transition_phase_overlay,
|
|
10284
10289
|
.ui_transition_content_overlay {
|
|
10285
|
-
display:
|
|
10286
|
-
width:
|
|
10287
|
-
|
|
10290
|
+
display: flex;
|
|
10291
|
+
width: fit-content;
|
|
10292
|
+
min-width: 100%;
|
|
10293
|
+
height: fit-content;
|
|
10294
|
+
min-height: 100%;
|
|
10295
|
+
flex-direction: inherit;
|
|
10296
|
+
align-items: inherit;
|
|
10297
|
+
justify-content: inherit;
|
|
10298
|
+
border-radius: inherit;
|
|
10299
|
+
cursor: inherit;
|
|
10288
10300
|
}
|
|
10289
10301
|
|
|
10290
10302
|
.ui_transition_measure_wrapper[data-transition-translate-x] {
|
|
@@ -10376,6 +10388,39 @@ const initUITransition = (container) => {
|
|
|
10376
10388
|
return { cleanup: () => {} };
|
|
10377
10389
|
}
|
|
10378
10390
|
|
|
10391
|
+
const [teardown, addTeardown] = createPubSub();
|
|
10392
|
+
|
|
10393
|
+
{
|
|
10394
|
+
const transitionOverflowSet = new Set();
|
|
10395
|
+
const updateTransitionOverflowAttribute = () => {
|
|
10396
|
+
if (transitionOverflowSet.size > 0) {
|
|
10397
|
+
container.setAttribute("data-transition-overflow", "");
|
|
10398
|
+
} else {
|
|
10399
|
+
container.removeAttribute("data-transition-overflow");
|
|
10400
|
+
}
|
|
10401
|
+
};
|
|
10402
|
+
const onOverflowStart = (event) => {
|
|
10403
|
+
transitionOverflowSet.add(event.detail.transitionId);
|
|
10404
|
+
updateTransitionOverflowAttribute();
|
|
10405
|
+
};
|
|
10406
|
+
const onOverflowEnd = (event) => {
|
|
10407
|
+
transitionOverflowSet.delete(event.detail.transitionId);
|
|
10408
|
+
updateTransitionOverflowAttribute();
|
|
10409
|
+
};
|
|
10410
|
+
container.addEventListener("ui_transition_overflow_start", onOverflowStart);
|
|
10411
|
+
container.addEventListener("ui_transition_overflow_end", onOverflowEnd);
|
|
10412
|
+
addTeardown(() => {
|
|
10413
|
+
container.removeEventListener(
|
|
10414
|
+
"ui_transition_overflow_start",
|
|
10415
|
+
onOverflowStart,
|
|
10416
|
+
);
|
|
10417
|
+
container.removeEventListener(
|
|
10418
|
+
"ui_transition_overflow_end",
|
|
10419
|
+
onOverflowEnd,
|
|
10420
|
+
);
|
|
10421
|
+
});
|
|
10422
|
+
}
|
|
10423
|
+
|
|
10379
10424
|
const transitionController = createGroupTransitionController();
|
|
10380
10425
|
|
|
10381
10426
|
// Transition state
|
|
@@ -11312,6 +11357,7 @@ const initUITransition = (container) => {
|
|
|
11312
11357
|
slot,
|
|
11313
11358
|
|
|
11314
11359
|
cleanup: () => {
|
|
11360
|
+
teardown();
|
|
11315
11361
|
mutationObserver.disconnect();
|
|
11316
11362
|
stopResizeObserver();
|
|
11317
11363
|
if (sizeTransition) {
|
|
@@ -11443,6 +11489,8 @@ const slideLeft = {
|
|
|
11443
11489
|
|
|
11444
11490
|
return [
|
|
11445
11491
|
createTranslateXTransition(oldElement, to, {
|
|
11492
|
+
setup: () =>
|
|
11493
|
+
notifyTransitionOverflow(newElement, "slide_out_old_content"),
|
|
11446
11494
|
from,
|
|
11447
11495
|
duration,
|
|
11448
11496
|
startProgress,
|
|
@@ -11464,6 +11512,8 @@ const slideLeft = {
|
|
|
11464
11512
|
debug("transition", "Slide in from empty:", { from, to });
|
|
11465
11513
|
return [
|
|
11466
11514
|
createTranslateXTransition(newElement, to, {
|
|
11515
|
+
setup: () =>
|
|
11516
|
+
notifyTransitionOverflow(newElement, "slice_in_new_content"),
|
|
11467
11517
|
from,
|
|
11468
11518
|
duration,
|
|
11469
11519
|
startProgress,
|
|
@@ -11516,6 +11566,8 @@ const slideLeft = {
|
|
|
11516
11566
|
// Slide old content out
|
|
11517
11567
|
transitions.push(
|
|
11518
11568
|
createTranslateXTransition(oldElement, -containerWidth, {
|
|
11569
|
+
setup: () =>
|
|
11570
|
+
notifyTransitionOverflow(newElement, "slide_out_old_content"),
|
|
11519
11571
|
from: oldContentPosition,
|
|
11520
11572
|
duration,
|
|
11521
11573
|
startProgress,
|
|
@@ -11528,6 +11580,8 @@ const slideLeft = {
|
|
|
11528
11580
|
// Slide new content in
|
|
11529
11581
|
transitions.push(
|
|
11530
11582
|
createTranslateXTransition(newElement, naturalNewPosition, {
|
|
11583
|
+
setup: () =>
|
|
11584
|
+
notifyTransitionOverflow(newElement, "slide_in_new_content"),
|
|
11531
11585
|
from: effectiveFromPosition,
|
|
11532
11586
|
duration,
|
|
11533
11587
|
startProgress,
|
|
@@ -11651,4 +11705,29 @@ const crossFade = {
|
|
|
11651
11705
|
},
|
|
11652
11706
|
};
|
|
11653
11707
|
|
|
11654
|
-
|
|
11708
|
+
const dispatchTransitionOverflowStartCustomEvent = (element, transitionId) => {
|
|
11709
|
+
const customEvent = new CustomEvent("ui_transition_overflow_start", {
|
|
11710
|
+
bubbles: true,
|
|
11711
|
+
detail: {
|
|
11712
|
+
transitionId,
|
|
11713
|
+
},
|
|
11714
|
+
});
|
|
11715
|
+
element.dispatchEvent(customEvent);
|
|
11716
|
+
};
|
|
11717
|
+
const dispatchTransitionOverflowEndCustomEvent = (element, transitionId) => {
|
|
11718
|
+
const customEvent = new CustomEvent("ui_transition_overflow_end", {
|
|
11719
|
+
bubbles: true,
|
|
11720
|
+
detail: {
|
|
11721
|
+
transitionId,
|
|
11722
|
+
},
|
|
11723
|
+
});
|
|
11724
|
+
element.dispatchEvent(customEvent);
|
|
11725
|
+
};
|
|
11726
|
+
const notifyTransitionOverflow = (element, transitionId) => {
|
|
11727
|
+
dispatchTransitionOverflowStartCustomEvent(element, transitionId);
|
|
11728
|
+
return () => {
|
|
11729
|
+
dispatchTransitionOverflowEndCustomEvent(element, transitionId);
|
|
11730
|
+
};
|
|
11731
|
+
};
|
|
11732
|
+
|
|
11733
|
+
export { EASING, activeElementSignal, addActiveElementEffect, addAttributeEffect, addWillChange, allowWheelThrough, appendStyles, canInterceptKeys, captureScrollState, createDragGestureController, createDragToMoveGestureController, createHeightTransition, createIterableWeakSet, createOpacityTransition, createPubSub, createStyleController, createTimelineTransition, createTransition, createTranslateXTransition, createValueEffect, createWidthTransition, cubicBezier, dragAfterThreshold, elementIsFocusable, elementIsVisibleForFocus, elementIsVisuallyVisible, findAfter, findAncestor, findBefore, findDescendant, findFocusable, getAvailableHeight, getAvailableWidth, getBorderSizes, getContrastRatio, getDefaultStyles, getDragCoordinates, getDropTargetInfo, getElementSignature, getFirstVisuallyVisibleAncestor, getFocusVisibilityInfo, getHeight, getInnerHeight, getInnerWidth, getMarginSizes, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getOpacity, getPaddingSizes, getPositionedParent, getPreferedColorScheme, getScrollContainer, getScrollContainerSet, getScrollRelativeRect, getSelfAndAncestorScrolls, getStyle, getTranslateX, getTranslateY, getVisuallyVisibleInfo, getWidth, initFlexDetailsSet, initFocusGroup, initPositionSticky, initUITransition, isScrollable, mergeStyles, normalizeStyle, normalizeStyles, parseCSSColor, pickLightOrDark, pickPositionRelativeTo, prefersDarkColors, prefersLightColors, preventFocusNav, preventFocusNavViaKeyboard, resolveCSSColor, resolveCSSSize, setAttribute, setAttributes, setStyles, startDragToResizeGesture, stickyAsRelativeCoords, stringifyCSSColor, trapFocusInside, trapScrollInside, useActiveElement, useAvailableHeight, useAvailableWidth, useMaxHeight, useMaxWidth, useResizeStatus, visibleRectEffect };
|