Socket
Socket
Sign inDemoInstall

@react-aria/utils

Package Overview
Dependencies
Maintainers
2
Versions
777
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@react-aria/utils - npm Package Compare versions

Comparing version 3.5.0 to 3.6.0

src/platform.ts

104

dist/main.js

@@ -0,1 +1,9 @@

var {
clamp,
snapValueToStep
} = require("@react-stately/utils");
exports.snapValueToStep = snapValueToStep;
exports.clamp = clamp;
var _clsx = $parcel$interopDefault(require("clsx"));

@@ -311,41 +319,2 @@

exports.getOffset = getOffset;
function clamp(value, min, max) {
if (min === void 0) {
min = -Infinity;
}
if (max === void 0) {
max = Infinity;
}
return Math.min(Math.max(value, min), max);
}
exports.clamp = clamp;
function snapValueToStep(value, min, max, step) {
let remainder = (value - min) % step;
let snappedValue = Math.abs(remainder) * 2 >= step ? value - Math.abs(remainder) + step : value - remainder;
if (snappedValue < min) {
snappedValue = min;
} else if (snappedValue > max) {
snappedValue = min + Math.floor((max - min) / step) * step;
} // correct floating point behavior by rounding to step precision
let string = step.toString();
let index = string.indexOf('.');
let precision = index >= 0 ? string.length - index : 0;
if (precision > 0) {
let pow = Math.pow(10, precision);
snappedValue = Math.round(snappedValue * pow) / pow;
}
return snappedValue;
}
exports.snapValueToStep = snapValueToStep;
// mapped to a set of CSS properties that are transitioning for that element.

@@ -814,2 +783,59 @@ // This is necessary rather than a simple count of transitions because of browser

}
function $ffc9ede5fda79bf280c1bec834e32f$var$testUserAgent(re) {
return typeof window !== 'undefined' && window.navigator != null ? re.test(window.navigator.userAgent) : false;
}
function $ffc9ede5fda79bf280c1bec834e32f$var$testPlatform(re) {
return typeof window !== 'undefined' && window.navigator != null ? re.test(window.navigator.platform) : false;
}
function isMac() {
return $ffc9ede5fda79bf280c1bec834e32f$var$testPlatform(/^Mac/);
}
exports.isMac = isMac;
function isIPhone() {
return $ffc9ede5fda79bf280c1bec834e32f$var$testPlatform(/^iPhone/);
}
exports.isIPhone = isIPhone;
function isIPad() {
return $ffc9ede5fda79bf280c1bec834e32f$var$testPlatform(/^iPad/) || // iPadOS 13 lies and says it's a Mac, but we can distinguish by detecting touch support.
isMac() && navigator.maxTouchPoints > 1;
}
exports.isIPad = isIPad;
function isIOS() {
return isIPhone() || isIPad();
}
exports.isIOS = isIOS;
function isAppleDevice() {
return isMac() || isIOS();
}
exports.isAppleDevice = isAppleDevice;
function isWebKit() {
return $ffc9ede5fda79bf280c1bec834e32f$var$testUserAgent(/AppleWebKit/) && !isChrome();
}
exports.isWebKit = isWebKit;
function isChrome() {
return $ffc9ede5fda79bf280c1bec834e32f$var$testUserAgent(/Chrome/);
}
exports.isChrome = isChrome;
function isAndroid() {
return $ffc9ede5fda79bf280c1bec834e32f$var$testUserAgent(/Android/);
}
exports.isAndroid = isAndroid;
//# sourceMappingURL=main.js.map

@@ -0,1 +1,3 @@

import { clamp, snapValueToStep } from "@react-stately/utils";
export { clamp, snapValueToStep };
import _clsx from "clsx";

@@ -273,35 +275,2 @@ import { useSSRSafeId } from "@react-aria/ssr";

}
export function clamp(value, min, max) {
if (min === void 0) {
min = -Infinity;
}
if (max === void 0) {
max = Infinity;
}
return Math.min(Math.max(value, min), max);
}
export function snapValueToStep(value, min, max, step) {
let remainder = (value - min) % step;
let snappedValue = Math.abs(remainder) * 2 >= step ? value - Math.abs(remainder) + step : value - remainder;
if (snappedValue < min) {
snappedValue = min;
} else if (snappedValue > max) {
snappedValue = min + Math.floor((max - min) / step) * step;
} // correct floating point behavior by rounding to step precision
let string = step.toString();
let index = string.indexOf('.');
let precision = index >= 0 ? string.length - index : 0;
if (precision > 0) {
let pow = Math.pow(10, precision);
snappedValue = Math.round(snappedValue * pow) / pow;
}
return snappedValue;
}
// mapped to a set of CSS properties that are transitioning for that element.

@@ -750,2 +719,36 @@ // This is necessary rather than a simple count of transitions because of browser

}
function $b0986c1243f71db8e992f67117a1ed9$var$testUserAgent(re) {
return typeof window !== 'undefined' && window.navigator != null ? re.test(window.navigator.userAgent) : false;
}
function $b0986c1243f71db8e992f67117a1ed9$var$testPlatform(re) {
return typeof window !== 'undefined' && window.navigator != null ? re.test(window.navigator.platform) : false;
}
export function isMac() {
return $b0986c1243f71db8e992f67117a1ed9$var$testPlatform(/^Mac/);
}
export function isIPhone() {
return $b0986c1243f71db8e992f67117a1ed9$var$testPlatform(/^iPhone/);
}
export function isIPad() {
return $b0986c1243f71db8e992f67117a1ed9$var$testPlatform(/^iPad/) || // iPadOS 13 lies and says it's a Mac, but we can distinguish by detecting touch support.
isMac() && navigator.maxTouchPoints > 1;
}
export function isIOS() {
return isIPhone() || isIPad();
}
export function isAppleDevice() {
return isMac() || isIOS();
}
export function isWebKit() {
return $b0986c1243f71db8e992f67117a1ed9$var$testUserAgent(/AppleWebKit/) && !isChrome();
}
export function isChrome() {
return $b0986c1243f71db8e992f67117a1ed9$var$testUserAgent(/Chrome/);
}
export function isAndroid() {
return $b0986c1243f71db8e992f67117a1ed9$var$testUserAgent(/Android/);
}
//# sourceMappingURL=module.js.map

@@ -56,7 +56,3 @@ import React, { HTMLAttributes, MutableRefObject, EffectCallback, RefObject } from "react";

export function getOffset(element: any, reverse: any, orientation?: string): any;
/**
* Takes a value and forces it to the closest min/max.
*/
export function clamp(value: number, min?: number, max?: number): number;
export function snapValueToStep(value: number, min: number, max: number, step: number): number;
export { clamp, snapValueToStep } from '@react-stately/utils';
export function runAfterTransition(fn: () => void): void;

@@ -102,3 +98,11 @@ interface UseDrag1DProps {

export function useViewportSize(): ViewportSize;
export function isMac(): boolean;
export function isIPhone(): boolean;
export function isIPad(): boolean;
export function isIOS(): boolean;
export function isAppleDevice(): boolean;
export function isWebKit(): boolean;
export function isChrome(): boolean;
export function isAndroid(): boolean;
//# sourceMappingURL=types.d.ts.map
{
"name": "@react-aria/utils",
"version": "3.5.0",
"version": "3.6.0",
"description": "Spectrum UI components in React",

@@ -22,3 +22,4 @@ "license": "Apache-2.0",

"@react-aria/ssr": "^3.0.1",
"@react-types/shared": "^3.3.0",
"@react-stately/utils": "^3.2.0",
"@react-types/shared": "^3.4.0",
"clsx": "^1.1.1"

@@ -32,3 +33,3 @@ },

},
"gitHead": "0159136997a4b18166b0e660b929fd8e243410c8"
"gitHead": "7f9dc7fa5144679d2dc733170cb5c1f40d0c5ee5"
}

@@ -29,1 +29,2 @@ /*

export * from './useViewportSize';
export * from './platform';

@@ -13,32 +13,2 @@ /*

/**
* Takes a value and forces it to the closest min/max.
*/
export function clamp(value: number, min: number = -Infinity, max: number = Infinity): number {
return Math.min(Math.max(value, min), max);
}
export function snapValueToStep(value: number, min: number, max: number, step: number): number {
let remainder = ((value - min) % step);
let snappedValue = Math.abs(remainder) * 2 >= step
? (value - Math.abs(remainder)) + step
: value - remainder;
if (snappedValue < min) {
snappedValue = min;
} else if (snappedValue > max) {
snappedValue = min + Math.floor((max - min) / step) * step;
}
// correct floating point behavior by rounding to step precision
let string = step.toString();
let index = string.indexOf('.');
let precision = index >= 0 ? string.length - index : 0;
if (precision > 0) {
let pow = Math.pow(10, precision);
snappedValue = Math.round(snappedValue * pow) / pow;
}
return snappedValue;
}
export {clamp, snapValueToStep} from '@react-stately/utils';

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc