MCPcopy Create free account
hub / github.com/adobe/react-spectrum / moveRecords

Function moveRecords

perf/app/workflows.tsx:101–110  ·  view source on GitHub ↗
(rows: RecordItem[], keys: Set<Key>, target: DropTarget)

Source from the content-addressed store, hash-verified

99}
100
101function moveRecords(rows: RecordItem[], keys: Set<Key>, target: DropTarget) {
102 if (target.type !== 'item') {
103 return rows;
104 }
105 let moved = rows.filter(row => keys.has(row.id));
106 let remaining = rows.filter(row => !keys.has(row.id));
107 let index = remaining.findIndex(row => row.id === target.key);
108 remaining.splice(target.dropPosition === 'after' ? index + 1 : index, 0, ...moved);
109 return remaining;
110}
111
112export function ReorderFixture({items}: {items: RecordItem[]}) {
113 let [rows, setRows] = useState(items);

Callers 1

ReorderFixtureFunction · 0.85

Calls 2

filterMethod · 0.65
hasMethod · 0.65

Tested by

no test coverage detected