Skip to content

request: support mapping external types to internal input types #106

@sandrina-p

Description

@sandrina-p

Problem

Reported at #73 by @juicycleff

Json Schema Form supports internal types and treats them quite differently eg. group-array. If a system requires multiple kind of components to be treated internally as group-array, this would be impossible.

Proposals

Proposal 1

Adds support for mapping external input types as group array eg.

const headlessFormOutput = createHeadlessForm(schema, {
    ...,
    presentationMapping: {
      groupArray: ["array", "conditions"],
    }
  })

Proposal 2 (final solution)

To make sure I understood, you have a JSON Schema with a different presentation.inputType (let's say "conditions") and you want it to be treated as if it was "group-array", is that it?
Let me give another example to double-check, imagine a JSON Schema with a field of "inputType: "digits" that we want to treat as "number", like this:

{
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "age": {
      "title": "Your age",
      "x-jsf-presentation": {
        "inputType": "digits" // <-- note how it's "digits" instead of "number"
      }
    }
  }
}

Is that the type of customization you are trying to support? f so, we could reuse the existing config inputTypes and create a new attr "altName" (or any other name) to map the alternative names, like this:

const headlessFormOutput = createHeadlessForm(schema, {
    inputTypes: {
      "group-array": {
         altName: ["array", "conditions"] // <!-- New!
     },
      "number": {
         altName: ["digits"] // <!-- New!
     },
    }
  })

Metadata

Metadata

Assignees

No one assigned

    Labels

    new featureNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions