Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
3b4b145
add selectionStyle prop
yihuiliao Mar 13, 2026
9adcfb2
current state of highlight which sorta works but idk if i like the im…
yihuiliao Mar 18, 2026
6a79fa6
fix lint
yihuiliao Mar 18, 2026
e38fa30
Merge branch 'main' into highlight-selection-tableview
yihuiliao Mar 18, 2026
7ae2ed2
Merge branch 'main' into highlight-selection-tableview
yihuiliao Mar 23, 2026
e59fe39
code cleanup + comments
yihuiliao Mar 24, 2026
0cb910e
fix lint
yihuiliao Mar 24, 2026
33cbc66
add highlight selection to the docs
yihuiliao Mar 24, 2026
8646952
add jsdoc comment
yihuiliao Mar 24, 2026
042ce49
update hcm
yihuiliao Mar 24, 2026
a31ba79
add chromatic stories
yihuiliao Mar 24, 2026
54cf8ad
Merge branch 'main' into highlight-selection-tableview
yihuiliao Mar 24, 2026
d7be568
add ids to table with links to fix styles
yihuiliao Mar 25, 2026
8a2ea10
minor cleanup
yihuiliao Mar 25, 2026
8f98eef
Merge branch 'main' into highlight-selection-tableview
yihuiliao Mar 30, 2026
76da66f
fix import
yihuiliao Mar 30, 2026
c0a8752
Merge branch 'main' into highlight-selection-tableview
yihuiliao Apr 3, 2026
13ee518
prototype different version of highlight selection
yihuiliao Apr 6, 2026
a12ae63
add a comment with my new brilliant idea so i don't forget
yihuiliao Apr 7, 2026
dd13674
Merge branch 'main' into design-prototype
yihuiliao Apr 14, 2026
83a37a5
fix rounded borders, focus ring
yihuiliao Apr 14, 2026
489ef00
Merge branch 'main' into design-prototype
yihuiliao Apr 24, 2026
896f6ba
support gray dividers between rows
yihuiliao Apr 24, 2026
24bf07a
use borders (mainly) for highlight selection over box shadow
yihuiliao May 4, 2026
f186db5
Merge branch 'main' into design-prototype
yihuiliao May 4, 2026
4b0b5dc
fix hcm to match v3 and cleanup
yihuiliao May 7, 2026
8866523
thanks copilot
yihuiliao May 7, 2026
5b37c63
cleanup
yihuiliao May 7, 2026
3a4c7aa
Merge branch 'main' into design-prototype
yihuiliao May 7, 2026
aa9833f
Merge branch 'main' into design-prototype
yihuiliao May 8, 2026
7508ef7
format
yihuiliao May 8, 2026
7acee0d
more formatting
yihuiliao May 9, 2026
caa8942
fix ts error
yihuiliao May 9, 2026
c66bf9b
hcm fixes
yihuiliao May 12, 2026
09ca445
adjust z index
yihuiliao May 12, 2026
f532770
cleanup cell styles
yihuiliao May 12, 2026
a5a3023
update utils
yihuiliao May 12, 2026
e758d36
format
yihuiliao May 12, 2026
bfcbbd6
Merge branch 'main' into design-prototype
yihuiliao May 12, 2026
2487380
format
yihuiliao May 12, 2026
25683b2
address review comments
yihuiliao May 15, 2026
0f22642
fix formatting
yihuiliao May 15, 2026
5d04f42
fix lint
yihuiliao May 15, 2026
c4d747c
Merge branch 'main' into design-prototype
yihuiliao May 18, 2026
7ec644b
fix
yihuiliao May 18, 2026
ca13c53
fix dnd with highlight selection
yihuiliao May 18, 2026
dd8c7b2
fix lint
yihuiliao May 18, 2026
5bbbb47
fix typecheck
yihuiliao May 18, 2026
dc6b649
formating....
yihuiliao May 18, 2026
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
30 changes: 29 additions & 1 deletion packages/@react-spectrum/s2/chromatic/TableView.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const meta: Meta<typeof TableView> = {
export default meta;

const StaticTable = (args: TableViewProps): ReactElement => (
<TableView aria-label="Files" {...args} styles={style({width: 320, height: 320})}>
<TableView aria-label="Files" styles={style({width: 320, height: 320})} {...args}>
<TableHeader>
<Column isRowHeader>Name</Column>
<Column>Type</Column>
Expand Down Expand Up @@ -117,6 +117,34 @@ let items = [
{id: 10, foo: 'Foo 10', bar: 'Bar 10', baz: 'Baz 10', yah: 'Yah long long long 10'}
];

export const CheckboxSelection: StoryObj<typeof StaticTable> = {
render: StaticTable,
args: {
selectionMode: 'multiple',
selectionStyle: 'checkbox',
selectedKeys: ['1', '2'],
styles: style({width: 500}),
onResize: undefined,
onResizeStart: undefined,
onResizeEnd: undefined,
onLoadMore: undefined
}
};

export const HighlightSelection: StoryObj<typeof StaticTable> = {
...Example,
args: {
selectionMode: 'multiple',
selectionStyle: 'highlight',
selectedKeys: ['1', '2'],
styles: style({width: 500}),
onResize: undefined,
onResizeStart: undefined,
onResizeEnd: undefined,
onLoadMore: undefined
}
};

const DynamicTable = (args: TableViewProps): ReactElement => (
<TableView aria-label="Dynamic table" {...args} styles={style({width: 320, height: 208})}>
<TableHeader columns={columns}>
Expand Down
65 changes: 35 additions & 30 deletions packages/@react-spectrum/s2/src/ListView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ import {Key} from '@react-types/shared';
import {LayoutInfo, Virtualizer} from 'react-aria-components/Virtualizer';
import LinkOutIcon from '../ui-icons/LinkOut';
import {ListLayout} from 'react-stately/useVirtualizerState';
// @ts-ignore
Comment thread
yihuiliao marked this conversation as resolved.
import {ListState} from 'react-stately/useListState';
import type {ListState} from 'react-stately/useListState';
import {ProgressCircle} from './ProgressCircle';
import {Text, TextContext} from './Content';
import {useActionBarContainer} from './ActionBar';
Expand Down Expand Up @@ -959,34 +958,6 @@ function ListSelectionCheckbox({isDisabled}: {isDisabled: boolean}) {
);
}

function isNextSelected(id: Key | undefined, state: ListState<unknown>) {
if (id == null || !state) {
return false;
}
let keyAfter = state.collection.getKeyAfter(id);
return keyAfter != null && state.selectionManager.isSelected(keyAfter);
}
export function isPrevSelected(id: Key | undefined, state: ListState<unknown>) {
if (id == null || !state) {
return false;
}
let keyBefore = state.collection.getKeyBefore(id);
return keyBefore != null && state.selectionManager.isSelected(keyBefore);
}

export function isFirstItem(id: Key | undefined, state: ListState<unknown>) {
if (id == null || !state) {
return false;
}
return state.collection.getFirstKey() === id;
}
function isLastItem(id: Key | undefined, state: ListState<unknown>) {
if (id == null || !state) {
return false;
}
return state.collection.getLastKey() === id;
}

export function ListViewItem(props: ListViewItemProps): ReactNode {
let ref = useRef(null);
let {hasChildItems, ...otherProps} = props;
Expand Down Expand Up @@ -1175,3 +1146,37 @@ export function ListViewItem(props: ListViewItemProps): ReactNode {
</GridListItem>
);
}

function isNextSelected(id: Key | undefined, state: ListState<unknown>) {
if (id == null || !state) {
return false;
}
let keyAfter = state.collection.getKeyAfter(id);
return keyAfter != null && state.selectionManager.isSelected(keyAfter);
}

function isPrevSelected(id: Key | undefined, state: ListState<unknown>) {
if (id == null || !state) {
return false;
}
let keyBefore = state.collection.getKeyBefore(id);
return keyBefore != null && state.selectionManager.isSelected(keyBefore);
}

function isFirstItem(id: Key | undefined, state: ListState<unknown>) {
if (id == null || !state) {
return false;
}
return state.collection.getFirstKey() === id;
}

function isLastItem(id: Key | undefined, state: ListState<unknown>) {
if (id == null || !state) {
return false;
}

let key = state.collection.getLastKey();
let node = key ? state.collection.getItem(key) : null;

return node ? node.key === id : false;
}
Loading