Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return omit(changes, (value, key) => {
if (isArray(value)) {
if (key === 'selectedItems') {
return (
value.length !== state.selectedItems.length ||
(value as GItem[]).some((item, index) => getItemId(item) !== getItemId(state.selectedItems[index]))
);
}
if (key === 'highlightedIndexes') {
return (
value.length !== state.highlightedIndexes.length ||
(value as number[]).some((val, index) => val !== state.highlightedIndexes[index])
);
}
}
return value !== state[key];
styles.map(style =>
isArray(style)
? sx(...style)(theme)
: isFunction(style)
? css(style(theme))(theme)
: isSerializedStyle(style)
? style
: isPlainObject(style)
? css(style as WithVariants)(theme)
: style,
),
extensionSuggesters.forEach(suggester => {
suggestions.push(...(isArray(suggester) ? suggester : [suggester]));
});
return cloneSSRElement(element, children => {
if (!isArray(children)) {
return children;
}
return Children.map(children, child => {
if (!(isReactDOMElement(child) && elementIsEmpty(child) && elementIsOfType(child, 'p'))) {
return child;
}
const props = getElementProps(child);
return cloneElement(child, props, jsx('br'));
});
});
};
const convertHSLToObject = (value: HSLObject | NamedHSLObject | HSLTuple | string): HSLObject => {
if (isHSLObject(value)) {
return value;
}
if (isNamedHSLObject(value)) {
const { hue: h, saturation: s, lightness: l, alpha: a } = value;
return { h, s, l, a };
}
if (isArray(value)) {
return hslArrayToObject(value);
}
if (isString(value)) {
return hslStringToObject(value);
}
throw new Error(`Invalid HSL input value passed: ${isPlainObject(value) ? JSON.stringify(value) : value}`);
};
export const cloneElement = }> = any>(
element: ReactElement,
props: GProps,
...rest: ReactNode[]
) => {
const children = uniqueArray([
...(isArray(props.children) ? props.children : props.children ? [props.children] : []),
...rest,
]);
return jsx(
element.type,
{
key: element.key,
ref: element.props.ref,
...element.props,
...props,
},
...children,
);
};