// Copyright 2017-2023 @polkadot/react-components authors & contributors // SPDX-License-Identifier: Apache-2.0 import type { Props as ExpanderProps } from './Expander'; import React, { useCallback, useMemo } from 'react'; import styled from 'styled-components'; import Expander from './Expander'; import Table from './Table'; interface Props extends ExpanderProps { empty?: string; renderChildren?: () => React.ReactNode[]; } function mapRow (row: React.ReactNode, key: number): React.ReactNode { return ( {row} ); } function ExpanderScroll ({ children, className, empty, help, helpIcon, renderChildren, summary }: Props): React.ReactElement { const hasContent = useMemo( () => !!(renderChildren || children), [children, renderChildren] ); const innerRender = useCallback( (): React.ReactNode => (renderChildren || children) && (
{renderChildren ? renderChildren().map(mapRow) : Array.isArray(children) ? children.map(mapRow) : }
{children}
), [children, empty, renderChildren] ); return ( ); } export default React.memo(styled(ExpanderScroll)` .tableContainer { overflow-y: scroll; display: block; margin: 0 0 0 auto; max-height: 13.75rem; max-width: 25rem; overflow-x: hidden; } `);