UNPKG

@awsui/components-react

Version:

On July 19th, 2022, we launched [Cloudscape Design System](https://cloudscape.design). Cloudscape is an evolution of AWS-UI. It consists of user interface guidelines, front-end components, design resources, and development tools for building intuitive, en

23 lines 1.49 kB
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 import React, { forwardRef } from 'react'; import flattenChildren from 'react-keyed-flatten-children'; import clsx from 'clsx'; import { useMergeRefs } from '@awsui/component-toolkit/internal'; import { getBaseProps } from '../internal/base-component'; import WithNativeAttributes from '../internal/utils/with-native-attributes'; import styles from './styles.css.js'; const InternalSpaceBetween = forwardRef(({ direction = 'vertical', size, children, alignItems, nativeAttributes, __internalRootRef, ...props }, ref) => { const mergedRef = useMergeRefs(ref, __internalRootRef); const baseProps = getBaseProps(props); /* Flattening the children allows us to "see through" React Fragments and nested arrays. */ const flattenedChildren = flattenChildren(children); return (React.createElement(WithNativeAttributes, { ...baseProps, tag: "div", componentName: "SpaceBetween", nativeAttributes: nativeAttributes, className: clsx(baseProps.className, styles.root, styles[direction], styles[`${direction}-${size}`], alignItems && styles[`align-${alignItems}`]), ref: mergedRef }, flattenedChildren.map(child => { const key = typeof child === 'object' ? child.key : undefined; return (React.createElement("div", { key: key, className: styles.child }, child)); }))); }); export default InternalSpaceBetween; //# sourceMappingURL=internal.js.map