@react-aria/utils
Advanced tools
Comparing version 3.0.0-nightly.1203 to 3.0.0-nightly.1204
@@ -11,2 +11,4 @@ var { | ||
var _babelRuntimeHelpersExtends = $parcel$interopDefault(require("@babel/runtime/helpers/extends")); | ||
var { | ||
@@ -171,29 +173,27 @@ useSSRSafeId | ||
function mergeProps() { | ||
let result = {}; | ||
// Start with a base clone of the first argument. This is a lot faster than starting | ||
// with an empty object and adding properties as we go. | ||
let result = _babelRuntimeHelpersExtends({}, arguments.length <= 0 ? undefined : arguments[0]); | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
for (let i = 1; i < arguments.length; i++) { | ||
let props = i < 0 || arguments.length <= i ? undefined : arguments[i]; | ||
for (let props of args) { | ||
for (let key in result) { | ||
// Chain events | ||
if (/^on[A-Z]/.test(key) && typeof result[key] === 'function' && typeof props[key] === 'function') { | ||
result[key] = chain(result[key], props[key]); // Merge classnames, sometimes classNames are empty string which eval to false, so we just need to do a type check | ||
} else if (key === 'className' && typeof result.className === 'string' && typeof props.className === 'string') { | ||
result[key] = _clsx(result.className, props.className); | ||
} else if (key === 'UNSAFE_className' && typeof result.UNSAFE_className === 'string' && typeof props.UNSAFE_className === 'string') { | ||
result[key] = _clsx(result.UNSAFE_className, props.UNSAFE_className); | ||
} else if (key === 'id' && result.id && props.id) { | ||
result.id = mergeIds(result.id, props.id); // Override others | ||
for (let key in props) { | ||
let a = result[key]; | ||
let b = props[key]; // Chain events | ||
if (typeof a === 'function' && typeof b === 'function' && // This is a lot faster than a regex. | ||
key[0] === 'o' && key[1] === 'n' && key.charCodeAt(2) >= | ||
/* 'A' */ | ||
65 && key.charCodeAt(2) <= | ||
/* 'Z' */ | ||
90) { | ||
result[key] = chain(a, b); // Merge classnames, sometimes classNames are empty string which eval to false, so we just need to do a type check | ||
} else if ((key === 'className' || key === 'UNSAFE_className') && typeof a === 'string' && typeof b === 'string') { | ||
result[key] = _clsx(a, b); | ||
} else if (key === 'id' && a && b) { | ||
result.id = mergeIds(a, b); // Override others | ||
} else { | ||
result[key] = props[key] !== undefined ? props[key] : result[key]; | ||
result[key] = b !== undefined ? b : a; | ||
} | ||
} // Add props from b that are not in a | ||
for (let key in props) { | ||
if (result[key] === undefined) { | ||
result[key] = props[key]; | ||
} | ||
} | ||
@@ -637,4 +637,3 @@ } | ||
}); | ||
}, [removeGlobalListener]); // eslint-disable-next-line arrow-body-style | ||
}, [removeGlobalListener]); | ||
useEffect(() => { | ||
@@ -641,0 +640,0 @@ return removeAllGlobalListeners; |
import { clamp, snapValueToStep } from "@react-stately/utils"; | ||
export { clamp, snapValueToStep }; | ||
import _clsx from "clsx"; | ||
import _babelRuntimeHelpersEsmExtends from "@babel/runtime/helpers/esm/extends"; | ||
import { useSSRSafeId } from "@react-aria/ssr"; | ||
@@ -134,29 +135,27 @@ import _react, { useEffect, useRef, useState, useCallback, useLayoutEffect as _useLayoutEffect } from "react"; | ||
export function mergeProps() { | ||
let result = {}; | ||
// Start with a base clone of the first argument. This is a lot faster than starting | ||
// with an empty object and adding properties as we go. | ||
let result = _babelRuntimeHelpersEsmExtends({}, arguments.length <= 0 ? undefined : arguments[0]); | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
for (let i = 1; i < arguments.length; i++) { | ||
let props = i < 0 || arguments.length <= i ? undefined : arguments[i]; | ||
for (let props of args) { | ||
for (let key in result) { | ||
// Chain events | ||
if (/^on[A-Z]/.test(key) && typeof result[key] === 'function' && typeof props[key] === 'function') { | ||
result[key] = chain(result[key], props[key]); // Merge classnames, sometimes classNames are empty string which eval to false, so we just need to do a type check | ||
} else if (key === 'className' && typeof result.className === 'string' && typeof props.className === 'string') { | ||
result[key] = _clsx(result.className, props.className); | ||
} else if (key === 'UNSAFE_className' && typeof result.UNSAFE_className === 'string' && typeof props.UNSAFE_className === 'string') { | ||
result[key] = _clsx(result.UNSAFE_className, props.UNSAFE_className); | ||
} else if (key === 'id' && result.id && props.id) { | ||
result.id = mergeIds(result.id, props.id); // Override others | ||
for (let key in props) { | ||
let a = result[key]; | ||
let b = props[key]; // Chain events | ||
if (typeof a === 'function' && typeof b === 'function' && // This is a lot faster than a regex. | ||
key[0] === 'o' && key[1] === 'n' && key.charCodeAt(2) >= | ||
/* 'A' */ | ||
65 && key.charCodeAt(2) <= | ||
/* 'Z' */ | ||
90) { | ||
result[key] = chain(a, b); // Merge classnames, sometimes classNames are empty string which eval to false, so we just need to do a type check | ||
} else if ((key === 'className' || key === 'UNSAFE_className') && typeof a === 'string' && typeof b === 'string') { | ||
result[key] = _clsx(a, b); | ||
} else if (key === 'id' && a && b) { | ||
result.id = mergeIds(a, b); // Override others | ||
} else { | ||
result[key] = props[key] !== undefined ? props[key] : result[key]; | ||
result[key] = b !== undefined ? b : a; | ||
} | ||
} // Add props from b that are not in a | ||
for (let key in props) { | ||
if (result[key] === undefined) { | ||
result[key] = props[key]; | ||
} | ||
} | ||
@@ -585,4 +584,3 @@ } | ||
}); | ||
}, [removeGlobalListener]); // eslint-disable-next-line arrow-body-style | ||
}, [removeGlobalListener]); | ||
useEffect(() => { | ||
@@ -589,0 +587,0 @@ return removeAllGlobalListeners; |
{ | ||
"name": "@react-aria/utils", | ||
"version": "3.0.0-nightly.1203+9b0ee02be", | ||
"version": "3.0.0-nightly.1204+2a0f66453", | ||
"description": "Spectrum UI components in React", | ||
@@ -21,5 +21,5 @@ "license": "Apache-2.0", | ||
"@babel/runtime": "^7.6.2", | ||
"@react-aria/ssr": "3.0.4-nightly.2888+9b0ee02be", | ||
"@react-stately/utils": "3.0.0-nightly.1203+9b0ee02be", | ||
"@react-types/shared": "3.0.0-nightly.1203+9b0ee02be", | ||
"@react-aria/ssr": "3.0.4-nightly.2889+2a0f66453", | ||
"@react-stately/utils": "3.0.0-nightly.1204+2a0f66453", | ||
"@react-types/shared": "3.0.0-nightly.1204+2a0f66453", | ||
"clsx": "^1.1.1" | ||
@@ -33,3 +33,3 @@ }, | ||
}, | ||
"gitHead": "9b0ee02becd1d295e470de0f216f39227319e135" | ||
"gitHead": "2a0f664534de576201ef1251d6982d83bbcd01d8" | ||
} |
@@ -34,40 +34,37 @@ /* | ||
export function mergeProps<T extends Props[]>(...args: T): UnionToIntersection<TupleTypes<T>> { | ||
let result: Props = {}; | ||
for (let props of args) { | ||
for (let key in result) { | ||
// Start with a base clone of the first argument. This is a lot faster than starting | ||
// with an empty object and adding properties as we go. | ||
let result: Props = {...args[0]}; | ||
for (let i = 1; i < args.length; i++) { | ||
let props = args[i]; | ||
for (let key in props) { | ||
let a = result[key]; | ||
let b = props[key]; | ||
// Chain events | ||
if ( | ||
/^on[A-Z]/.test(key) && | ||
typeof result[key] === 'function' && | ||
typeof props[key] === 'function' | ||
typeof a === 'function' && | ||
typeof b === 'function' && | ||
// This is a lot faster than a regex. | ||
key[0] === 'o' && | ||
key[1] === 'n' && | ||
key.charCodeAt(2) >= /* 'A' */ 65 && | ||
key.charCodeAt(2) <= /* 'Z' */ 90 | ||
) { | ||
result[key] = chain(result[key], props[key]); | ||
result[key] = chain(a, b); | ||
// Merge classnames, sometimes classNames are empty string which eval to false, so we just need to do a type check | ||
} else if ( | ||
key === 'className' && | ||
typeof result.className === 'string' && | ||
typeof props.className === 'string' | ||
(key === 'className' || key === 'UNSAFE_className') && | ||
typeof a === 'string' && | ||
typeof b === 'string' | ||
) { | ||
result[key] = clsx(result.className, props.className); | ||
} else if ( | ||
key === 'UNSAFE_className' && | ||
typeof result.UNSAFE_className === 'string' && | ||
typeof props.UNSAFE_className === 'string' | ||
) { | ||
result[key] = clsx(result.UNSAFE_className, props.UNSAFE_className); | ||
} else if (key === 'id' && result.id && props.id) { | ||
result.id = mergeIds(result.id, props.id); | ||
result[key] = clsx(a, b); | ||
} else if (key === 'id' && a && b) { | ||
result.id = mergeIds(a, b); | ||
// Override others | ||
} else { | ||
result[key] = props[key] !== undefined ? props[key] : result[key]; | ||
result[key] = b !== undefined ? b : a; | ||
} | ||
} | ||
// Add props from b that are not in a | ||
for (let key in props) { | ||
if (result[key] === undefined) { | ||
result[key] = props[key]; | ||
} | ||
} | ||
} | ||
@@ -74,0 +71,0 @@ |
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
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
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
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
244316
2600