Skip to content

Commit 4d8a72d

Browse files
committed
Add validation mode to examples
1 parent fcef896 commit 4d8a72d

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

packages/examples-react/src/App.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ body {
3131
justify-content: center;
3232
align-items: center;
3333
margin-top: 20px;
34+
gap: 20px;
3435
}
3536
.tools .example-selector h4 {
3637
margin: 0 10px 0 0;

packages/examples-react/src/App.tsx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import { ExampleDescription } from '@jsonforms/examples';
2929
import {
3030
JsonFormsCellRendererRegistryEntry,
3131
JsonFormsRendererRegistryEntry,
32+
ValidationMode,
3233
} from '@jsonforms/core';
3334
import { Tab, Tabs, TabList, TabPanel } from 'react-tabs';
3435
import Highlight from 'react-highlight';
@@ -85,6 +86,9 @@ const App = ({
8586
getProps(currentExample, cells, renderers)
8687
);
8788
const [showPanel, setShowPanel] = useState<boolean>(true);
89+
const [validationMode, setValidationMode] = useState<
90+
ValidationMode | undefined
91+
>(undefined);
8892
const schemaAsString = useMemo(
8993
() => JSON.stringify(exampleProps.schema, null, 2),
9094
[exampleProps.schema]
@@ -145,6 +149,28 @@ const App = ({
145149
)
146150
)}
147151
</select>
152+
<h4>Select ValidationMode:</h4>
153+
<select
154+
value={validationMode}
155+
onChange={(ev) =>
156+
setValidationMode(
157+
ev.currentTarget.value as ValidationMode | undefined
158+
)
159+
}
160+
>
161+
<option value={undefined} label='Default'>
162+
Default
163+
</option>
164+
<option value='NoValidation' label='NoValidation'>
165+
NoValidation
166+
</option>
167+
<option value='ValidateAndHide' label='ValidateAndHide'>
168+
ValidateAndHide
169+
</option>
170+
<option value='ValidateAndShow' label='ValidateAndShow'>
171+
ValidateAndShow
172+
</option>
173+
</select>
148174
</div>
149175
<div className='toggle-panel'>
150176
<input
@@ -202,6 +228,7 @@ const App = ({
202228
<JsonForms
203229
key={currentIndex}
204230
{...exampleProps}
231+
validationMode={validationMode}
205232
onChange={({ data }) => changeData(data)}
206233
/>
207234
</Wrapper>

0 commit comments

Comments
 (0)