wip: render custom control based on schema matching #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This example shows how custom schema extensions can be matched and used to render a custom control. For the sake of example, a builtin "MaterialBooleanControl" is rendered, but in practice this would be our own custom control component, which would have access to the custom
schemapassed via props.To test:
npm run devand navigate to this URLhttp://localhost:3000/?schema=N4KABGBEAOBOD20CmsAuBLJBnSAuMoEEkAtgJ4C0JAhtBQGaYA2AJngeEcamcu5FlSx0AOwDmkADScukevFgksAOhEAjMsvgikAegDGAV0HwSFfdqHwm7QlyKQeffAIAW1FkhYVUieACssbSkZe0c-QOD8O3sHIMNYfSQAYW0dfQwoqAsRdMyRChFqEiQKAHd0VFdRcyZ4Q29aOhEcUK4AX2lY4hZqVGpbNrD4xJS0pAz0LMgcvKmCopLyyuqC-TqGiibC1u6wdqGDjs4D9qA&uiSchema=N4KABBYEQC4J4AcCmUBc0BqSBOMCWAxgIYA2AMkXAPYCuMUANOJFEiUgLZIB2MAzmjABtZpEigxklvGSCoAYSq9sVEo1FSWfAlVnooAYgD0CFclx4kfIxzgBaDkQR2AZpZIATdZslRd%2BJQF0YABfDTEwsQBdEBCgA
or equivalently, use the following values.schema.json:
{ "properties": { "my-map-field": { "type": "string", "forms.nby.one/custom-control": { "type": "shaded-topojson", "topojson": { "sourceConnection": "connection-name-within-cloud-app-ns" }, "data": { "sourceConnection": "connection-name-within-cloud-app-ns" } } } } }and any UI Schema referencing "my-map-field", e.g.
{ "type": "VerticalLayout", "elements": [ { "type": "Control", "scope": "#/properties/my-map-field", "options": {} } ] }