Skip to content

Commit

Permalink
ref: roster-for-loop remove row
Browse files Browse the repository at this point in the history
  • Loading branch information
Grafikart committed Sep 27, 2023
1 parent 4e94afb commit 74cc1e5
Showing 1 changed file with 10 additions and 16 deletions.
26 changes: 10 additions & 16 deletions src/components/loop/roster-for-loop/roster-for-loop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export const RosterForLoop = createCustomizableLunaticField<
headers,
iterations,
id,
getComponents,
} = props;
const min = lines?.min || DEFAULT_MIN_ROWS;
const max = lines?.max || DEFAULT_MAX_ROWS;
Expand Down Expand Up @@ -68,7 +69,15 @@ export const RosterForLoop = createCustomizableLunaticField<
<TableHeader header={headers} id={id} />
<Tbody id={id}>
{times(nbRows, (n) => (
<Row {...props} key={n} row={n} />
<Tr id={props.id} row={n}>
<LunaticComponents
components={getComponents(n)}
componentProps={(c) => ({ ...props, ...c, id: `${c.id}-${n}` })}
wrapper={({ id, children }) => (
<Td id={`${id}-${n}`}>{children}</Td>
)}
/>
</Tr>
))}
</Tbody>
</Table>
Expand All @@ -86,18 +95,3 @@ export const RosterForLoop = createCustomizableLunaticField<
</>
);
}, 'RosterforLoop');

function Row(props: LunaticComponentProps<'RosterForLoop'> & { row: number }) {
const components = props.getComponents(props.row);
return (
<Tr id={props.id} row={props.row}>
<LunaticComponents
components={components}
componentProps={(c) => ({ ...props, ...c, id: `${c.id}-${props.row}` })}
wrapper={({ id, children }) => (
<Td id={`${id}-${props.row}`}>{children}</Td>
)}
/>
</Tr>
);
}

0 comments on commit 74cc1e5

Please sign in to comment.