Skip to content

Commit

Permalink
Merge 8833c24 into ab8215f
Browse files Browse the repository at this point in the history
  • Loading branch information
vojtechportes committed Feb 3, 2020
2 parents ab8215f + 8833c24 commit 291fb53
Show file tree
Hide file tree
Showing 47 changed files with 8,248 additions and 118 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ const components: BuilderComponentsProps = {

const MyBuilder: React.FC = () => (
<Builder
readOnly={false}
fields={fields}
data={data}
components={components}
Expand All @@ -90,7 +91,7 @@ const MyBuilder: React.FC = () => (

## Configuration

Since React Query Builder is highly configurable, you can define look of the Query Builder, you can define and use your own components and of course, you will need to set up fields Query Builder will be using.
Since React Query Builder is highly configurable, you can define look of the Query Builder, you can define and use your own components, set whether the Builder should be readOnly or not and of course, you will need to set up fields Query Builder will be using.

### Lets start with fields...

Expand Down Expand Up @@ -307,4 +308,5 @@ export const QueryBuiler:React.FC = () => {
* [ ] Drag and Drop user interface
* [ ] More examples and demos
* [x] Tests (after version 0.2.5)
* [x] Read only property on Buidler component
* [ ] Separate functionality to standalone API (in version 0.3.0)
14 changes: 9 additions & 5 deletions example/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import { Builder, BuilderFieldProps } from '../src';
import { colors } from '../src/constants/colors';

const Code = styled.pre`
background: ${colors.light};
border: 1px solid ${colors.darker};
padding: 1rem;
margin: 1rem 0;
padding: 1rem;
font-size: 0.7rem;
background: ${colors.light};
border: 1px solid ${colors.darker};
`;

export const queryTree = [
Expand Down Expand Up @@ -108,15 +108,19 @@ export const fields: BuilderFieldProps[] = [
];

const App = () => {
// const data = assignIDs(queryTree);
const [output, setOutput] = React.useState(queryTree);
const [readOnly, setReadOnly] = React.useState(false);

return (
<>
<a href="#" onClick={() => setReadOnly(!readOnly)}>
Read Only
</a>
<Builder
data={queryTree}
fields={fields}
onChange={data => setOutput(data)}
readOnly={readOnly}
onChange={setOutput}
/>

<h3>Output</h3>
Expand Down

0 comments on commit 291fb53

Please sign in to comment.