@jsenv/dom 0.8.3 → 0.8.5
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 +16 -4
- package/package.json +1 -1
package/dist/jsenv_dom.js
CHANGED
|
@@ -415,6 +415,10 @@ const parseCSSColor = (color, element) => {
|
|
|
415
415
|
|
|
416
416
|
// If it's a CSS custom property, resolve it using getComputedStyle
|
|
417
417
|
if (resolvedColor.includes("var(")) {
|
|
418
|
+
if (!element) {
|
|
419
|
+
// console.warn(`"${resolvedColor}" cannot be resolved without element.`);
|
|
420
|
+
return resolvedColor;
|
|
421
|
+
}
|
|
418
422
|
const computedStyle = getComputedStyle(element);
|
|
419
423
|
|
|
420
424
|
// Handle var() syntax
|
|
@@ -563,11 +567,15 @@ const convertColorToRgba = (color) => {
|
|
|
563
567
|
* @param {Array<number>} rgba - [r, g, b, a] values
|
|
564
568
|
* @returns {string|null} CSS color string or null if invalid input
|
|
565
569
|
*/
|
|
566
|
-
const stringifyCSSColor = (
|
|
567
|
-
if (
|
|
570
|
+
const stringifyCSSColor = (value) => {
|
|
571
|
+
if (typeof value === "string") {
|
|
572
|
+
// can happen for css variables that we can't resolve
|
|
573
|
+
return value;
|
|
574
|
+
}
|
|
575
|
+
if (!Array.isArray(value) || value.length < 3) {
|
|
568
576
|
return null;
|
|
569
577
|
}
|
|
570
|
-
|
|
578
|
+
const rgba = value;
|
|
571
579
|
const [r, g, b, a = 1] = rgba;
|
|
572
580
|
|
|
573
581
|
// Validate RGB values
|
|
@@ -1956,6 +1964,7 @@ const getUnit = (value) => {
|
|
|
1956
1964
|
};
|
|
1957
1965
|
// Check if value already has a unit
|
|
1958
1966
|
const isUnitless = (value) => getUnit(value) === "";
|
|
1967
|
+
const hasCSSSizeUnit = (value) => cssSizeUnitSet.has(getUnit(value));
|
|
1959
1968
|
|
|
1960
1969
|
// url(
|
|
1961
1970
|
// linear-gradient(
|
|
@@ -2369,6 +2378,9 @@ const mergeTwoStyles = (stylesA, stylesB, context = "js") => {
|
|
|
2369
2378
|
const aKeys = Object.keys(stylesA);
|
|
2370
2379
|
// in case stylesB is a string we first parse it
|
|
2371
2380
|
stylesB = normalizeStyles(stylesB, context);
|
|
2381
|
+
if (aKeys.length === 0) {
|
|
2382
|
+
return stylesB;
|
|
2383
|
+
}
|
|
2372
2384
|
const bKeyToVisitSet = new Set(Object.keys(stylesB));
|
|
2373
2385
|
for (const aKey of aKeys) {
|
|
2374
2386
|
const bHasKey = bKeyToVisitSet.has(aKey);
|
|
@@ -12600,4 +12612,4 @@ const useResizeStatus = (elementRef, { as = "number" } = {}) => {
|
|
|
12600
12612
|
};
|
|
12601
12613
|
};
|
|
12602
12614
|
|
|
12603
|
-
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 };
|
|
12615
|
+
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 };
|