@yamada-ui/utils
Advanced tools
Comparing version 1.0.0 to 1.0.1-next-20231228211945
@@ -17,2 +17,3 @@ import React__default from 'react'; | ||
declare const isContains: (parent: HTMLElement | null, child: HTMLElement | null) => boolean | undefined; | ||
declare const getPx: (value: string | number | undefined) => number; | ||
declare const getEventRelatedTarget: (ev: React__default.FocusEvent | React__default.MouseEvent) => HTMLElement | null; | ||
@@ -34,2 +35,2 @@ type Booleanish = boolean | "true" | "false"; | ||
export { type FocusableElement, ariaAttr, createdDom, dataAttr, getActiveElement, getAllFocusable, getEventRelatedTarget, getOwnerDocument, getOwnerWindow, getPlatform, hasNegativeTabIndex, hasTabIndex, isActiveElement, isApple, isContains, isContentEditable, isDisabled, isElement, isFocusable, isHTMLElement, isHidden, isMac, isSafari, isTabbable, platform, vendor }; | ||
export { type FocusableElement, ariaAttr, createdDom, dataAttr, getActiveElement, getAllFocusable, getEventRelatedTarget, getOwnerDocument, getOwnerWindow, getPlatform, getPx, hasNegativeTabIndex, hasTabIndex, isActiveElement, isApple, isContains, isContentEditable, isDisabled, isElement, isFocusable, isHTMLElement, isHidden, isMac, isSafari, isTabbable, platform, vendor }; |
@@ -32,2 +32,3 @@ "use strict"; | ||
getPlatform: () => getPlatform, | ||
getPx: () => getPx, | ||
hasNegativeTabIndex: () => hasNegativeTabIndex, | ||
@@ -51,2 +52,8 @@ hasTabIndex: () => hasTabIndex, | ||
module.exports = __toCommonJS(dom_exports); | ||
// src/assertion.ts | ||
var isNumber = (value) => typeof value === "number"; | ||
var isUndefined = (value) => typeof value === "undefined" && value === void 0; | ||
// src/dom.ts | ||
var createdDom = () => !!(typeof window !== "undefined" && window.document && window.document.createElement); | ||
@@ -85,2 +92,17 @@ var getPlatform = () => { | ||
}; | ||
var getPx = (value) => { | ||
if (isNumber(value)) | ||
return value; | ||
if (isUndefined(value)) | ||
return 0; | ||
if (value.includes("px")) | ||
return parseFloat(value); | ||
const isBrowser = createdDom(); | ||
let fontSize = 16; | ||
if (isBrowser) { | ||
const style = window.getComputedStyle(document.documentElement); | ||
fontSize = parseFloat(style.fontSize); | ||
} | ||
return parseFloat(value) * fontSize; | ||
}; | ||
var getEventRelatedTarget = (ev) => { | ||
@@ -157,2 +179,3 @@ var _a; | ||
getPlatform, | ||
getPx, | ||
hasNegativeTabIndex, | ||
@@ -159,0 +182,0 @@ hasTabIndex, |
@@ -6,3 +6,3 @@ export { Dict, Length, Merge, Path, Primitive, StringLiteral, Union } from './index.types.js'; | ||
export { AsyncFnReturn, AsyncState, AsyncStateRetry, DOMAttributes, FunctionReturningPromise, MaybeRenderProp, PromiseType, PropGetter, RequiredPropGetter, UseIsMountedProps, UseIsMountedReturn, assignRef, createContext, createId, cx, findChildren, getValidChildren, includesChildren, isRefObject, isValidElement, mergeRefs, omitChildren, pickChildren, useAsync, useAsyncFunc, useAsyncRetry, useCallbackRef, useIsMounted, useMergeRefs, useSafeLayoutEffect, useUnmountEffect, useUpdateEffect } from './react.js'; | ||
export { FocusableElement, ariaAttr, createdDom, dataAttr, getActiveElement, getAllFocusable, getEventRelatedTarget, getOwnerDocument, getOwnerWindow, getPlatform, hasNegativeTabIndex, hasTabIndex, isActiveElement, isApple, isContains, isContentEditable, isDisabled, isElement, isFocusable, isHTMLElement, isHidden, isMac, isSafari, isTabbable, platform, vendor } from './dom.js'; | ||
export { FocusableElement, ariaAttr, createdDom, dataAttr, getActiveElement, getAllFocusable, getEventRelatedTarget, getOwnerDocument, getOwnerWindow, getPlatform, getPx, hasNegativeTabIndex, hasTabIndex, isActiveElement, isApple, isContains, isContentEditable, isDisabled, isElement, isFocusable, isHTMLElement, isHidden, isMac, isSafari, isTabbable, platform, vendor } from './dom.js'; | ||
export { escape } from './string.js'; | ||
@@ -9,0 +9,0 @@ export { Operand, calc } from './calc.js'; |
@@ -66,2 +66,3 @@ "use strict"; | ||
getPlatform: () => getPlatform, | ||
getPx: () => getPx, | ||
getValidChildren: () => getValidChildren, | ||
@@ -514,2 +515,17 @@ handlerAll: () => handlerAll, | ||
}; | ||
var getPx = (value) => { | ||
if (isNumber(value)) | ||
return value; | ||
if (isUndefined(value)) | ||
return 0; | ||
if (value.includes("px")) | ||
return parseFloat(value); | ||
const isBrowser = createdDom(); | ||
let fontSize = 16; | ||
if (isBrowser) { | ||
const style = window.getComputedStyle(document.documentElement); | ||
fontSize = parseFloat(style.fontSize); | ||
} | ||
return parseFloat(value) * fontSize; | ||
}; | ||
var getEventRelatedTarget = (ev) => { | ||
@@ -847,2 +863,3 @@ var _a; | ||
getPlatform, | ||
getPx, | ||
getValidChildren, | ||
@@ -849,0 +866,0 @@ handlerAll, |
{ | ||
"name": "@yamada-ui/utils", | ||
"version": "1.0.0", | ||
"version": "1.0.1-next-20231228211945", | ||
"description": "Yamada UI utils", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
321065
3833
105
1