Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions packages/@react-spectrum/s2/src/TableView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* governing permissions and limitations under the License.
*/

import {baseColor, colorMix, focusRing, fontRelative, lightDark, space, style} from '../style' with {type: 'macro'};
import {baseColor, colorMix, focusRing, fontRelative, lightDark, space, style, StyleString} from '../style' with {type: 'macro'};
import {
Button,
CellRenderProps,
Expand Down Expand Up @@ -1008,7 +1008,8 @@ export interface CellProps extends RACCellProps, Pick<ColumnProps, 'align' | 'sh
/** @private */
isSticky?: boolean,
/** The content to render as the cell children. */
children: ReactNode
children: ReactNode,
styles?: StyleString
}

/**
Expand All @@ -1026,11 +1027,11 @@ export const Cell = forwardRef(function Cell(props: CellProps, ref: DOMRef<HTMLD
// Also isSticky prop is applied just for the layout, will decide what the RAC api should be later
// @ts-ignore
isSticky={isSticky}
className={renderProps => cell({
className={renderProps => mergeStyles(cell({
...renderProps,
...tableVisualOptions,
isDivider: showDivider
})}
}), props.styles)}
textValue={textValue}
{...otherProps}>
{({isFocusVisible}) => (
Expand Down
46 changes: 46 additions & 0 deletions packages/@react-spectrum/s2/stories/TableView.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,52 @@ export const DisabledRows: StoryObj<typeof StaticTable> = {
}
};

export const WrappingCells: StoryObj<typeof StaticTable> = {
render: (args: any) => (
<TableView aria-label="Files" {...args} styles={style({width: 320, height: 320})}>
<TableHeader>
<Column isRowHeader>Name</Column>
<Column>Type</Column>
<Column>Date Modified</Column>
<Column>Size</Column>
<Column>B</Column>
</TableHeader>
<TableBody>
<Row id="1">
<Cell styles={style({alignItems: 'start'})}>Games</Cell>
<Cell>File folder</Cell>
<Cell>6/7/2020</Cell>
<Cell>74 GB</Cell>
<Cell>Long long long long long long long cell</Cell>
</Row>
<Row id="2">
<Cell>Program Files</Cell>
<Cell>File folder</Cell>
<Cell>4/7/2021</Cell>
<Cell>1.2 GB</Cell>
<Cell>Long long long long long long long cell</Cell>
</Row>
<Row id="3">
<Cell>bootmgr</Cell>
<Cell>System file</Cell>
<Cell>11/20/2010</Cell>
<Cell>0.2 GB</Cell>
<Cell>Long long long long long long long cell</Cell>
</Row>
</TableBody>
</TableView>
),
args: {
...Example.args,
overflowMode: 'wrap'
},
parameters: {
docs: {
disable: true
}
}
};

let columns = [
{name: 'Foo', id: 'foo', isRowHeader: true},
{name: 'Bar', id: 'bar'},
Expand Down