-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Made expandable content a separate component (#2240)
- Loading branch information
Showing
4 changed files
with
74 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
packages/itwinui-react/src/core/Table/TableExpandableContentMemoized.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Bentley Systems, Incorporated. All rights reserved. | ||
* See LICENSE.md in the project root for license terms and full copyright notice. | ||
*--------------------------------------------------------------------------------------------*/ | ||
import cx from 'classnames'; | ||
import * as React from 'react'; | ||
import { Box } from '../../utils/index.js'; | ||
import type { PolymorphicForwardRefComponent } from '../../utils/index.js'; | ||
|
||
type TableExpandableContentProps = { | ||
children: React.ReactNode; | ||
isDisabled?: boolean; | ||
}; | ||
|
||
const TableExpandableContent = React.forwardRef((props, ref) => { | ||
const { children, className, style, isDisabled, ...rest } = props; | ||
return ( | ||
<Box | ||
className={cx('iui-table-row', 'iui-table-expanded-content', className)} | ||
style={{ | ||
flex: '0 0 auto', | ||
minWidth: '100%', | ||
...style, | ||
}} | ||
aria-disabled={isDisabled} | ||
ref={ref} | ||
{...rest} | ||
> | ||
{children} | ||
</Box> | ||
); | ||
}) as PolymorphicForwardRefComponent<'div', TableExpandableContentProps>; | ||
|
||
export const TableExpandableContentMemoized = React.memo( | ||
TableExpandableContent, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters