@jsenv/dom 0.8.4 → 0.8.6

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 +22 -7
  2. package/package.json +1 -1
package/dist/jsenv_dom.js CHANGED
@@ -92,16 +92,17 @@ const getElementSignature = (element) => {
92
92
  }
93
93
  return `[${functionLabel}]`;
94
94
  }
95
- if (element.nodeType === Node.TEXT_NODE) {
96
- return `#text(${getElementSignature(element.nodeValue)})`;
97
- }
98
95
  if (element.props) {
99
96
  const type = element.type;
97
+ const elementName = typeof type === "function" ? type.name : type;
100
98
  const id = element.props.id;
101
99
  if (id) {
102
- return `<${type} id="${id}" />`;
100
+ return `<${elementName} id="${id}" />`;
103
101
  }
104
- return `<${type} />`;
102
+ return `<${elementName} />`;
103
+ }
104
+ if (element.nodeType === Node.TEXT_NODE) {
105
+ return `#text(${getElementSignature(element.nodeValue)})`;
105
106
  }
106
107
 
107
108
  const tagName = element.tagName.toLowerCase();
@@ -399,6 +400,14 @@ const parseCSSColor = (color, element) => {
399
400
  if (typeof color !== "string") {
400
401
  return color;
401
402
  }
403
+ if (color === "inherit") {
404
+ if (!element) {
405
+ return color;
406
+ }
407
+ const computedStyle = getComputedStyle(element);
408
+ const resolvedColor = parseCSSColor(computedStyle.color, element);
409
+ return resolvedColor;
410
+ }
402
411
  let resolvedColor = color;
403
412
 
404
413
  // Handle light-dark() function
@@ -1964,6 +1973,7 @@ const getUnit = (value) => {
1964
1973
  };
1965
1974
  // Check if value already has a unit
1966
1975
  const isUnitless = (value) => getUnit(value) === "";
1976
+ const hasCSSSizeUnit = (value) => cssSizeUnitSet.has(getUnit(value));
1967
1977
 
1968
1978
  // url(
1969
1979
  // linear-gradient(
@@ -9371,6 +9381,7 @@ const pickPositionRelativeTo = (
9371
9381
  {
9372
9382
  alignToViewportEdgeWhenTargetNearEdge = 0,
9373
9383
  minLeft = 0,
9384
+ positionPreference,
9374
9385
  forcePosition,
9375
9386
  } = {},
9376
9387
  ) => {
@@ -9451,8 +9462,12 @@ const pickPositionRelativeTo = (
9451
9462
  position = forcePosition;
9452
9463
  break determine_position;
9453
9464
  }
9454
- const preferredPosition = element.getAttribute("data-position");
9465
+ const elementPreferredPosition = element.getAttribute("data-position");
9455
9466
  const minContentVisibilityRatio = 0.6; // 60% minimum visibility to keep position
9467
+
9468
+ // Check positionPreference parameter first, then element attribute
9469
+ const preferredPosition = positionPreference || elementPreferredPosition;
9470
+
9456
9471
  if (preferredPosition) {
9457
9472
  // Element has a preferred position - try to keep it unless we really struggle
9458
9473
  const visibleRatio =
@@ -12611,4 +12626,4 @@ const useResizeStatus = (elementRef, { as = "number" } = {}) => {
12611
12626
  };
12612
12627
  };
12613
12628
 
12614
- export { EASING, activeElementSignal, addActiveElementEffect, addAttributeEffect, allowWheelThrough, appendStyles, canInterceptKeys, captureScrollState, createBackgroundColorTransition, createBackgroundTransition, createBorderRadiusTransition, createBorderTransition, createDragGestureController, createDragToMoveGestureController, createGroupTransitionController, createHeightTransition, createIterableWeakSet, createOpacityTransition, createPubSub, createStyleController, createTimelineTransition, createTransition, createTranslateXTransition, createValueEffect, createWidthTransition, cubicBezier, dragAfterThreshold, elementIsFocusable, elementIsVisibleForFocus, elementIsVisuallyVisible, findAfter, findAncestor, findBefore, findDescendant, findFocusable, getAvailableHeight, getAvailableWidth, getBackground, getBackgroundColor, getBorder, getBorderRadius, getBorderSizes, getContrastRatio, getDefaultStyles, getDragCoordinates, getDropTargetInfo, getElementSignature, getFirstVisuallyVisibleAncestor, getFocusVisibilityInfo, getHeight, getHeightWithoutTransition, getInnerHeight, getInnerWidth, getLuminance, getMarginSizes, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getOpacity, getOpacityWithoutTransition, getPaddingSizes, getPositionedParent, getPreferedColorScheme, getScrollBox, getScrollContainer, getScrollContainerSet, getScrollRelativeRect, getSelfAndAncestorScrolls, getStyle, getTranslateX, getTranslateXWithoutTransition, getTranslateY, getVisuallyVisibleInfo, getWidth, getWidthWithoutTransition, initFlexDetailsSet, initFocusGroup, initPositionSticky, isScrollable, measureScrollbar, mergeOneStyle, mergeTwoStyles, normalizeStyles, parseStyle, pickLightOrDark, pickPositionRelativeTo, prefersDarkColors, prefersLightColors, preventFocusNav, preventFocusNavViaKeyboard, preventIntermediateScrollbar, resolveCSSColor, resolveCSSSize, resolveColorLuminance, setAttribute, setAttributes, setStyles, startDragToResizeGesture, stickyAsRelativeCoords, stringifyStyle, trapFocusInside, trapScrollInside, useActiveElement, useAvailableHeight, useAvailableWidth, useMaxHeight, useMaxWidth, useResizeStatus, visibleRectEffect };
12629
+ export { EASING, activeElementSignal, addActiveElementEffect, addAttributeEffect, allowWheelThrough, appendStyles, canInterceptKeys, captureScrollState, createBackgroundColorTransition, createBackgroundTransition, createBorderRadiusTransition, createBorderTransition, createDragGestureController, createDragToMoveGestureController, createGroupTransitionController, createHeightTransition, createIterableWeakSet, createOpacityTransition, createPubSub, createStyleController, createTimelineTransition, createTransition, createTranslateXTransition, createValueEffect, createWidthTransition, cubicBezier, dragAfterThreshold, elementIsFocusable, elementIsVisibleForFocus, elementIsVisuallyVisible, findAfter, findAncestor, findBefore, findDescendant, findFocusable, getAvailableHeight, getAvailableWidth, getBackground, getBackgroundColor, getBorder, getBorderRadius, getBorderSizes, getContrastRatio, getDefaultStyles, getDragCoordinates, getDropTargetInfo, getElementSignature, getFirstVisuallyVisibleAncestor, getFocusVisibilityInfo, getHeight, getHeightWithoutTransition, getInnerHeight, getInnerWidth, getLuminance, getMarginSizes, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getOpacity, getOpacityWithoutTransition, getPaddingSizes, getPositionedParent, getPreferedColorScheme, getScrollBox, getScrollContainer, getScrollContainerSet, getScrollRelativeRect, getSelfAndAncestorScrolls, getStyle, getTranslateX, getTranslateXWithoutTransition, getTranslateY, getVisuallyVisibleInfo, getWidth, getWidthWithoutTransition, hasCSSSizeUnit, initFlexDetailsSet, initFocusGroup, initPositionSticky, isScrollable, measureScrollbar, mergeOneStyle, mergeTwoStyles, normalizeStyles, parseStyle, pickLightOrDark, pickPositionRelativeTo, prefersDarkColors, prefersLightColors, preventFocusNav, preventFocusNavViaKeyboard, preventIntermediateScrollbar, resolveCSSColor, resolveCSSSize, resolveColorLuminance, setAttribute, setAttributes, setStyles, startDragToResizeGesture, stickyAsRelativeCoords, stringifyStyle, 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.8.4",
3
+ "version": "0.8.6",
4
4
  "description": "DOM utilities for writing frontend code",
5
5
  "repository": {
6
6
  "type": "git",