@jsenv/dom 0.7.0 → 0.7.1

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.
Files changed (2) hide show
  1. package/dist/jsenv_dom.js +88 -21
  2. package/package.json +1 -1
package/dist/jsenv_dom.js CHANGED
@@ -8317,7 +8317,7 @@ const createTransition = ({
8317
8317
  transition.value = value;
8318
8318
  transition.timing = isLast ? "end" : isFirstUpdate ? "start" : "progress";
8319
8319
  isFirstUpdate = false;
8320
- executionLifecycle.update(transition);
8320
+ executionLifecycle.update?.(transition);
8321
8321
  executeUpdateCallbacks(transition);
8322
8322
  },
8323
8323
 
@@ -8339,8 +8339,8 @@ const createTransition = ({
8339
8339
  cancel: () => {
8340
8340
  if (executionLifecycle) {
8341
8341
  lifecycle.cancel(transition);
8342
- executionLifecycle.teardown();
8343
- executionLifecycle.restore();
8342
+ executionLifecycle.teardown?.();
8343
+ executionLifecycle.restore?.();
8344
8344
  }
8345
8345
  resume = null;
8346
8346
  playState = "idle";
@@ -8357,7 +8357,7 @@ const createTransition = ({
8357
8357
  }
8358
8358
  // "running" or "paused"
8359
8359
  lifecycle.finish(transition);
8360
- executionLifecycle.teardown();
8360
+ executionLifecycle.teardown?.();
8361
8361
  resume = null;
8362
8362
  playState = "finished";
8363
8363
  executeFinishCallbacks();
@@ -8589,9 +8589,6 @@ const createHeightTransition = (element, to, options) => {
8589
8589
  teardown: () => {
8590
8590
  transitionStyleController.delete(element, "height");
8591
8591
  },
8592
- restore: () => {
8593
- transitionStyleController.delete(element, "height");
8594
- },
8595
8592
  };
8596
8593
  },
8597
8594
  },
@@ -8616,9 +8613,6 @@ const createWidthTransition = (element, to, options) => {
8616
8613
  teardown: () => {
8617
8614
  transitionStyleController.delete(element, "width");
8618
8615
  },
8619
- restore: () => {
8620
- transitionStyleController.delete(element, "width");
8621
- },
8622
8616
  };
8623
8617
  },
8624
8618
  },
@@ -8643,9 +8637,6 @@ const createOpacityTransition = (element, to, options = {}) => {
8643
8637
  teardown: () => {
8644
8638
  transitionStyleController.delete(element, "opacity");
8645
8639
  },
8646
- restore: () => {
8647
- transitionStyleController.delete(element, "opacity");
8648
- },
8649
8640
  };
8650
8641
  },
8651
8642
  },
@@ -8653,9 +8644,10 @@ const createOpacityTransition = (element, to, options = {}) => {
8653
8644
  return opacityTransition;
8654
8645
  };
8655
8646
 
8656
- const createTranslateXTransition = (element, to, options) => {
8647
+ const createTranslateXTransition = (element, to, options = {}) => {
8648
+ const { setup, ...rest } = options;
8657
8649
  const translateXTransition = createTimelineTransition({
8658
- ...options,
8650
+ ...rest,
8659
8651
  constructor: createTranslateXTransition,
8660
8652
  key: element,
8661
8653
  to,
@@ -8663,6 +8655,7 @@ const createTranslateXTransition = (element, to, options) => {
8663
8655
  isVisual: true,
8664
8656
  lifecycle: {
8665
8657
  setup: () => {
8658
+ const teardown = setup?.();
8666
8659
  return {
8667
8660
  from: getTranslateX(element),
8668
8661
  update: ({ value }) => {
@@ -8673,9 +8666,7 @@ const createTranslateXTransition = (element, to, options) => {
8673
8666
  });
8674
8667
  },
8675
8668
  teardown: () => {
8676
- transitionStyleController.delete(element, "transform.translateX");
8677
- },
8678
- restore: () => {
8669
+ teardown?.();
8679
8670
  transitionStyleController.delete(element, "transform.translateX");
8680
8671
  },
8681
8672
  };
@@ -10276,15 +10267,24 @@ const useResizeStatus = (elementRef, { as = "number" } = {}) => {
10276
10267
 
10277
10268
  installImportMetaCss(import.meta);
10278
10269
  import.meta.css = /* css */ `
10270
+ .ui_transition_container[data-transition-overflow] {
10271
+ overflow: hidden;
10272
+ }
10273
+
10279
10274
  .ui_transition_container,
10280
10275
  .ui_transition_outer_wrapper,
10281
10276
  .ui_transition_measure_wrapper,
10282
10277
  .ui_transition_slot,
10283
10278
  .ui_transition_phase_overlay,
10284
10279
  .ui_transition_content_overlay {
10285
- display: inline-flex;
10286
- width: 100%;
10287
- height: 100%;
10280
+ display: flex;
10281
+ width: fit-content;
10282
+ min-width: 100%;
10283
+ height: fit-content;
10284
+ min-height: 100%;
10285
+ flex-direction: inherit;
10286
+ align-items: inherit;
10287
+ justify-content: inherit;
10288
10288
  }
10289
10289
 
10290
10290
  .ui_transition_measure_wrapper[data-transition-translate-x] {
@@ -10376,6 +10376,39 @@ const initUITransition = (container) => {
10376
10376
  return { cleanup: () => {} };
10377
10377
  }
10378
10378
 
10379
+ const [teardown, addTeardown] = createPubSub();
10380
+
10381
+ {
10382
+ const transitionOverflowSet = new Set();
10383
+ const updateTransitionOverflowAttribute = () => {
10384
+ if (transitionOverflowSet.size > 0) {
10385
+ container.setAttribute("data-transition-overflow", "");
10386
+ } else {
10387
+ container.removeAttribute("data-transition-overflow");
10388
+ }
10389
+ };
10390
+ const onOverflowStart = (event) => {
10391
+ transitionOverflowSet.add(event.detail.transitionId);
10392
+ updateTransitionOverflowAttribute();
10393
+ };
10394
+ const onOverflowEnd = (event) => {
10395
+ transitionOverflowSet.delete(event.detail.transitionId);
10396
+ updateTransitionOverflowAttribute();
10397
+ };
10398
+ container.addEventListener("ui_transition_overflow_start", onOverflowStart);
10399
+ container.addEventListener("ui_transition_overflow_end", onOverflowEnd);
10400
+ addTeardown(() => {
10401
+ container.removeEventListener(
10402
+ "ui_transition_overflow_start",
10403
+ onOverflowStart,
10404
+ );
10405
+ container.removeEventListener(
10406
+ "ui_transition_overflow_end",
10407
+ onOverflowEnd,
10408
+ );
10409
+ });
10410
+ }
10411
+
10379
10412
  const transitionController = createGroupTransitionController();
10380
10413
 
10381
10414
  // Transition state
@@ -11312,6 +11345,7 @@ const initUITransition = (container) => {
11312
11345
  slot,
11313
11346
 
11314
11347
  cleanup: () => {
11348
+ teardown();
11315
11349
  mutationObserver.disconnect();
11316
11350
  stopResizeObserver();
11317
11351
  if (sizeTransition) {
@@ -11443,6 +11477,8 @@ const slideLeft = {
11443
11477
 
11444
11478
  return [
11445
11479
  createTranslateXTransition(oldElement, to, {
11480
+ setup: () =>
11481
+ notifyTransitionOverflow(newElement, "slide_out_old_content"),
11446
11482
  from,
11447
11483
  duration,
11448
11484
  startProgress,
@@ -11464,6 +11500,8 @@ const slideLeft = {
11464
11500
  debug("transition", "Slide in from empty:", { from, to });
11465
11501
  return [
11466
11502
  createTranslateXTransition(newElement, to, {
11503
+ setup: () =>
11504
+ notifyTransitionOverflow(newElement, "slice_in_new_content"),
11467
11505
  from,
11468
11506
  duration,
11469
11507
  startProgress,
@@ -11516,6 +11554,8 @@ const slideLeft = {
11516
11554
  // Slide old content out
11517
11555
  transitions.push(
11518
11556
  createTranslateXTransition(oldElement, -containerWidth, {
11557
+ setup: () =>
11558
+ notifyTransitionOverflow(newElement, "slide_out_old_content"),
11519
11559
  from: oldContentPosition,
11520
11560
  duration,
11521
11561
  startProgress,
@@ -11528,6 +11568,8 @@ const slideLeft = {
11528
11568
  // Slide new content in
11529
11569
  transitions.push(
11530
11570
  createTranslateXTransition(newElement, naturalNewPosition, {
11571
+ setup: () =>
11572
+ notifyTransitionOverflow(newElement, "slide_in_new_content"),
11531
11573
  from: effectiveFromPosition,
11532
11574
  duration,
11533
11575
  startProgress,
@@ -11651,4 +11693,29 @@ const crossFade = {
11651
11693
  },
11652
11694
  };
11653
11695
 
11696
+ const dispatchTransitionOverflowStartCustomEvent = (element, transitionId) => {
11697
+ const customEvent = new CustomEvent("ui_transition_overflow_start", {
11698
+ bubbles: true,
11699
+ detail: {
11700
+ transitionId,
11701
+ },
11702
+ });
11703
+ element.dispatchEvent(customEvent);
11704
+ };
11705
+ const dispatchTransitionOverflowEndCustomEvent = (element, transitionId) => {
11706
+ const customEvent = new CustomEvent("ui_transition_overflow_end", {
11707
+ bubbles: true,
11708
+ detail: {
11709
+ transitionId,
11710
+ },
11711
+ });
11712
+ element.dispatchEvent(customEvent);
11713
+ };
11714
+ const notifyTransitionOverflow = (element, transitionId) => {
11715
+ dispatchTransitionOverflowStartCustomEvent(element, transitionId);
11716
+ return () => {
11717
+ dispatchTransitionOverflowEndCustomEvent(element, transitionId);
11718
+ };
11719
+ };
11720
+
11654
11721
  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, 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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/dom",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "description": "DOM utilities for writing frontend code",
5
5
  "repository": {
6
6
  "type": "git",