This repository has been archived by the owner on Nov 22, 2022. It is now read-only.
forked from FelixHenninger/lab.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
07c214f
commit 8e3fd6e
Showing
1 changed file
with
32 additions
and
2 deletions.
There are no files selected for viewing
34 changes: 32 additions & 2 deletions
34
packages/builder/src/components/ComponentOptions/components/Content/Loop/Grid/index.js
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 |
---|---|---|
@@ -1,3 +1,33 @@ | ||
import React from 'react' | ||
import React, { Fragment } from 'react' | ||
|
||
export default () => <p>Foo bar</p> | ||
import { FastField, useFormikContext } from 'formik' | ||
|
||
import { Table, DefaultRow } from '../../../../../Form/table' | ||
|
||
const Row = ({ index: rowIndex, name, data, arrayHelpers }) => | ||
<DefaultRow | ||
index={ rowIndex } arrayHelpers={ arrayHelpers } | ||
wrapper={ Fragment } | ||
> | ||
{ data.map( | ||
(_, columnIndex) => | ||
<td key={ `${ name }[${ columnIndex }]` }> | ||
<FastField | ||
name={ `${ name }[${ columnIndex }]` } | ||
className="form-control text-monospace" | ||
/> | ||
</td> | ||
) } | ||
</DefaultRow> | ||
|
||
export default () => { | ||
const { values } = useFormikContext() | ||
const { templateParameters } = values | ||
|
||
return <Table | ||
name="templateParameters.rows" | ||
row={ Row } | ||
columns={ templateParameters.columns.length } | ||
className="border-top-0" | ||
/> | ||
} |