UNPKG

@react-spectrum/s2

Version:
53 lines (43 loc) 2.25 kB
var $308b180f49d82d28$exports = require("./runtime.cjs"); var $42M8u$react = require("react"); var $42M8u$reactariacomponents = require("react-aria-components"); var $42M8u$reactaria = require("react-aria"); var $42M8u$reactariautils = require("@react-aria/utils"); function $parcel$export(e, n, v, s) { Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true}); } $parcel$export(module.exports, "useSpectrumContextProps", () => $ac757a4c2bd72aee$export$764f6146fadd77f7); /* * 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 $ac757a4c2bd72aee$export$764f6146fadd77f7(props, ref, context) { let ctx = (0, $42M8u$reactariacomponents.useSlottedContext)(context, props.slot) || {}; let { ref: contextRef, ...contextProps } = ctx; let mergedRef = (0, $42M8u$reactaria.useObjectRef)((0, $42M8u$react.useMemo)(()=>(0, $42M8u$reactariautils.mergeRefs)(ref, contextRef), [ ref, contextRef ])); let mergedProps = (0, $42M8u$reactaria.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, $308b180f49d82d28$exports.mergeStyles)(contextProps.styles, props.styles); return [ mergedProps, mergedRef ]; } //# sourceMappingURL=useSpectrumContextProps.cjs.map