Debian Codegraph @

node/@patternfly/react-core/src/components/DataList/DataListItemRow.tsx

raw
1 import { Children, cloneElement, isValidElement } from 'react';
2 import { css } from '@patternfly/react-styles';
3 import styles from '@patternfly/react-styles/css/components/DataList/data-list';
4 import { DataListWrapModifier } from './DataList';
5
6 export interface DataListItemRowProps extends Omit<React.HTMLProps<HTMLDivElement>, 'children'> {
7 /** Content rendered inside the DataListItemRow */
8 children: React.ReactNode;
9 /** Additional classes added to the DataListItemRow */
10 className?: string;
11 /** Id for the row item */
12 rowid?: string;
13 /** Determines which wrapping modifier to apply to the DataListItemRow */
14 wrapModifier?: DataListWrapModifier | 'nowrap' | 'truncate' | 'breakWord';
15 }
16
17 export const DataListItemRow: React.FunctionComponent<DataListItemRowProps> = ({
18 children,
19 className = '',
20 rowid = '',
21 wrapModifier = null,
22 ...props
23 }: DataListItemRowProps) => (
24 <div className={css(styles.dataListItemRow, className, wrapModifier && styles.modifiers[wrapModifier])} {...props}>
25 {Children.map(
26 children,
27 (child) =>
28 isValidElement(child) &&
29 cloneElement(child as React.ReactElement<any>, {
30 rowid
31 })
32 )}
33 </div>
34 );
35 DataListItemRow.displayName = 'DataListItemRow';