@zag-js/utils
Advanced tools
Comparing version 0.0.0-dev-20220604091934 to 0.0.0-dev-20220604123458
export declare const isDev: () => boolean; | ||
export declare const isDom: () => boolean; | ||
export declare const isMac: () => boolean; | ||
export declare const isIPhone: () => boolean; | ||
export declare const isIPad: () => boolean; | ||
export declare const isIos: () => boolean; | ||
export declare const isSafari: () => boolean; | ||
export declare const isFirefox: () => boolean; | ||
export declare const isWebkit: () => boolean; | ||
export declare const isApple: () => boolean; | ||
export declare const isArray: (v: any) => v is any[]; | ||
@@ -18,15 +10,2 @@ export declare const isBoolean: (v: any) => v is boolean; | ||
export declare const hasProp: <T extends string>(obj: any, prop: T) => obj is Record<T, any>; | ||
export declare const supportsPointerEvent: () => boolean; | ||
export declare const supportsTouchEvent: () => boolean; | ||
export declare const supportsMouseEvent: () => boolean; | ||
export declare const isMouseEvent: (v: any) => v is MouseEvent; | ||
export declare const isTouchEvent: (v: any) => v is TouchEvent; | ||
export declare const isLeftClick: (v: { | ||
button: number; | ||
}) => boolean; | ||
export declare const isRightClick: (v: { | ||
button: number; | ||
}) => boolean; | ||
export declare const isModifiedEvent: (v: Pick<KeyboardEvent, "ctrlKey" | "metaKey" | "altKey">) => boolean; | ||
export declare const isCtrlKey: (v: Pick<KeyboardEvent, "ctrlKey" | "metaKey">) => boolean; | ||
//# sourceMappingURL=guard.d.ts.map |
export * from "./array"; | ||
export * from "./events"; | ||
export * from "./functions"; | ||
export * from "./guard"; | ||
export * from "./platform"; | ||
export * from "./warning"; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -29,2 +29,3 @@ var __defProp = Object.defineProperty; | ||
fromLength: () => fromLength, | ||
getPlatform: () => getPlatform, | ||
has: () => has, | ||
@@ -42,3 +43,2 @@ hasProp: () => hasProp, | ||
isFunction: () => isFunction, | ||
isIPad: () => isIPad, | ||
isIPhone: () => isIPhone, | ||
@@ -55,4 +55,4 @@ isIos: () => isIos, | ||
isString: () => isString, | ||
isTouchDevice: () => isTouchDevice, | ||
isTouchEvent: () => isTouchEvent, | ||
isWebkit: () => isWebkit, | ||
last: () => last, | ||
@@ -136,2 +136,41 @@ merge: () => merge, | ||
// src/guard.ts | ||
var isDev = () => void 0 !== "production"; | ||
var isDom = () => typeof window !== "undefined"; | ||
var isArray = (v) => Array.isArray(v); | ||
var isBoolean = (v) => v === true || v === false; | ||
var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v)); | ||
var isNumber = (v) => typeof v === "number" && !Number.isNaN(v); | ||
var isString = (v) => typeof v === "string"; | ||
var isFunction = (v) => typeof v === "function"; | ||
var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop); | ||
// src/platform.ts | ||
function getPlatform() { | ||
var _a; | ||
const agent = navigator.userAgentData; | ||
return (_a = agent == null ? void 0 : agent.platform) != null ? _a : navigator.platform; | ||
} | ||
var pt = (v) => isDom() && v.test(getPlatform()); | ||
var ua = (v) => isDom() && v.test(navigator.userAgent); | ||
var vn = (v) => isDom() && v.test(navigator.vendor); | ||
var isTouchDevice = isDom() && !!navigator.maxTouchPoints; | ||
var isMac = () => pt(/^Mac/) && !isTouchDevice; | ||
var isIPhone = () => pt(/^iPhone/); | ||
var isSafari = () => isApple() && vn(/apple/i); | ||
var isFirefox = () => ua(/firefox\//i); | ||
var isApple = () => pt(/mac|iphone|ipad|ipod/i); | ||
var isIos = () => isApple() && !isMac(); | ||
// src/events.ts | ||
var supportsPointerEvent = () => isDom() && window.onpointerdown === null; | ||
var supportsTouchEvent = () => isDom() && window.ontouchstart === null; | ||
var supportsMouseEvent = () => isDom() && window.onmousedown === null; | ||
var isMouseEvent = (v) => isObject(v) && hasProp(v, "button"); | ||
var isTouchEvent = (v) => isObject(v) && hasProp(v, "touches"); | ||
var isLeftClick = (v) => v.button === 0; | ||
var isRightClick = (v) => v.button === 2; | ||
var isModifiedEvent = (v) => v.ctrlKey || v.altKey || v.metaKey; | ||
var isCtrlKey = (v) => isMac() ? v.metaKey && !v.ctrlKey : v.ctrlKey && !v.metaKey; | ||
// src/functions.ts | ||
@@ -175,32 +214,2 @@ var runIfFn = (v, ...a) => { | ||
// src/guard.ts | ||
var platform = (v) => isDom() && v.test(navigator.platform); | ||
var ua = (v) => isDom() && v.test(navigator.userAgent); | ||
var isDev = () => void 0 !== "production"; | ||
var isDom = () => typeof window !== "undefined"; | ||
var isMac = () => platform(/^Mac/); | ||
var isIPhone = () => platform(/^iPhone/); | ||
var isIPad = () => platform(/^iPad/) || isMac() && navigator.maxTouchPoints > 1; | ||
var isIos = () => isIPhone() || isIPad(); | ||
var isSafari = () => ua(/^((?!chrome|android).)*safari/i); | ||
var isFirefox = () => ua(/^Firefox/); | ||
var isWebkit = () => ua(/^WebKit/) && !ua(/Chrome/); | ||
var isApple = () => isMac() || isIos(); | ||
var isArray = (v) => Array.isArray(v); | ||
var isBoolean = (v) => v === true || v === false; | ||
var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v)); | ||
var isNumber = (v) => typeof v === "number" && !Number.isNaN(v); | ||
var isString = (v) => typeof v === "string"; | ||
var isFunction = (v) => typeof v === "function"; | ||
var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop); | ||
var supportsPointerEvent = () => isDom() && window.onpointerdown === null; | ||
var supportsTouchEvent = () => isDom() && window.ontouchstart === null; | ||
var supportsMouseEvent = () => isDom() && window.onmousedown === null; | ||
var isMouseEvent = (v) => isObject(v) && hasProp(v, "button"); | ||
var isTouchEvent = (v) => isObject(v) && hasProp(v, "touches"); | ||
var isLeftClick = (v) => v.button === 0; | ||
var isRightClick = (v) => v.button === 2; | ||
var isModifiedEvent = (v) => v.ctrlKey || v.altKey || v.metaKey; | ||
var isCtrlKey = (v) => isMac() ? v.metaKey && !v.ctrlKey : v.ctrlKey && !v.metaKey; | ||
// src/warning.ts | ||
@@ -207,0 +216,0 @@ function warn(...a) { |
{ | ||
"name": "@zag-js/utils", | ||
"version": "0.0.0-dev-20220604091934", | ||
"version": "0.0.0-dev-20220604123458", | ||
"description": "", | ||
@@ -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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
42152
19
482