@react-spectrum/s2
Version:
Spectrum 2 UI components in React
48 lines (40 loc) • 2.15 kB
JavaScript
import {mergeStyles as $feb886035e0d4633$export$e618dc39ac9ad607} from "./runtime.mjs";
import {useMemo as $ac2Kv$useMemo} from "react";
import {useSlottedContext as $ac2Kv$useSlottedContext} from "react-aria-components";
import {useObjectRef as $ac2Kv$useObjectRef, mergeProps as $ac2Kv$mergeProps} from "react-aria";
import {mergeRefs as $ac2Kv$mergeRefs} from "@react-aria/utils";
/*
* Copyright 2024 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
function $5ce63c423902f47d$export$764f6146fadd77f7(props, ref, context) {
let ctx = (0, $ac2Kv$useSlottedContext)(context, props.slot) || {};
let { ref: contextRef, ...contextProps } = ctx;
let mergedRef = (0, $ac2Kv$useObjectRef)((0, $ac2Kv$useMemo)(()=>(0, $ac2Kv$mergeRefs)(ref, contextRef), [
ref,
contextRef
]));
let mergedProps = (0, $ac2Kv$mergeProps)(contextProps, props);
// mergeProps does not merge `UNSAFE_style`
if ('UNSAFE_style' in contextProps && contextProps.UNSAFE_style && 'UNSAFE_style' in props && props.UNSAFE_style) // @ts-ignore
mergedProps.UNSAFE_style = {
...contextProps.UNSAFE_style,
...props.UNSAFE_style
};
// Merge macro styles.
if ('styles' in contextProps && contextProps.styles && 'styles' in props && props.styles) // @ts-ignore
mergedProps.styles = (0, $feb886035e0d4633$export$e618dc39ac9ad607)(contextProps.styles, props.styles);
return [
mergedProps,
mergedRef
];
}
export {$5ce63c423902f47d$export$764f6146fadd77f7 as useSpectrumContextProps};
//# sourceMappingURL=useSpectrumContextProps.mjs.map