React with Native

Bringing together React and React Native

GitHub

README

Simplified schema form

simplified-schema-form (

OperationClassification

TODO: Ensure embedding this will embed the actual docs in my markdown renderer. I guess it might already do so!

TODO: It would be great to learn more about this topic and see if I can make more cross-environment packages. A great use case would be to create a wrapper around the current fs-orm to enable using it at the frontend too.

OperationClassification ui-cjs)

component that generates a form using react-with-native and a

SimplifiedSchema

JSONSchema7 derivative that has the following capabilities and and characteristics...

  • does not include objects in objects that are also referenced to using xxxSlug or xxxId
  • recursively finds the references and expands them, unless the references are circular
  • easier to read
  • has all the information we need
  • is able to generate an object with values in the exact format the function needs it
  • is able to easily generate a form
SimplifiedSchema. Can obtain any JSON object from the user.

Api reference
<FormContainer />

A

FormContainer

A FormContainer is a simple container that can wrap your SimplifiedSchemaForm to give it a button that also sends when hitting enter on your keyboard. To achieve this, a <form> is created in this component.

Besides this, you can also add some texts, but styling is not possible to change for this component at this point (except for the form className). If you want a completely different style, it's probably better to build it yourself.

NB: TODO: There is a bug now where onSubmit gets called too often. Not sure how to fix this. Because of this, I'll simply remove the onSubmit action in the onsubmit for now, and prevent the default.

FormContainer is a simple container that can wrap your SimplifiedSchemaForm to give it a button that also sends when hitting enter on your keyboard. To achieve this, a <form> is created in this component.

Besides this, you can also add some texts, but styling is not possible to change for this component at this point (except for the form className). If you want a completely different style, it's probably better to build it yourself.

NB: TODO: There is a bug now where onSubmit gets called too often. Not sure how to fix this. Because of this, I'll simply remove the onSubmit action in the onsubmit for now, and prevent the default.

Input
-
OutputJSX.Element
<SimplifiedSchemaForm />

Recursive component that renders a form for a SimplifiedSchema

Input
-
OutputJSX.Element
📄 FormContainer (exported const)

A

FormContainer

A FormContainer is a simple container that can wrap your SimplifiedSchemaForm to give it a button that also sends when hitting enter on your keyboard. To achieve this, a <form> is created in this component.

Besides this, you can also add some texts, but styling is not possible to change for this component at this point (except for the form className). If you want a completely different style, it's probably better to build it yourself.

NB: TODO: There is a bug now where onSubmit gets called too often. Not sure how to fix this. Because of this, I'll simply remove the onSubmit action in the onsubmit for now, and prevent the default.

FormContainer is a simple container that can wrap your SimplifiedSchemaForm to give it a button that also sends when hitting enter on your keyboard. To achieve this, a <form> is created in this component.

Besides this, you can also add some texts, but styling is not possible to change for this component at this point (except for the form className). If you want a completely different style, it's probably better to build it yourself.

NB: TODO: There is a bug now where onSubmit gets called too often. Not sure how to fix this. Because of this, I'll simply remove the onSubmit action in the onsubmit for now, and prevent the default.

📄 SimplifiedSchemaForm (exported const)

Recursive component that renders a form for a SimplifiedSchema

useReferencableModelData()

Hook to retreive ReferencableModelData to supply to

SimplifiedSchemaForm

Recursive component that renders a form for a SimplifiedSchema

SimplifiedSchemaForm.

Underwater, this calculates all referencableModelNames for a schema, and then it fetches the ReferencableItem[] for every one of those models, using react-query useQuery hooks

NB: be careful, not to change the simplifiedSchema after using this hook for the first time. This will change the amount of hooks and this can break react!

(it will give Error: Rendered more hooks than during the previous render)

Input
simplifiedSchemaSimplifiedSchema
Output{ }
📄 useReferencableModelData (exported const)

Hook to retreive ReferencableModelData to supply to

SimplifiedSchemaForm

Recursive component that renders a form for a SimplifiedSchema

SimplifiedSchemaForm.

Underwater, this calculates all referencableModelNames for a schema, and then it fetches the ReferencableItem[] for every one of those models, using react-query useQuery hooks

NB: be careful, not to change the simplifiedSchema after using this hook for the first time. This will change the amount of hooks and this can break react!

(it will give Error: Rendered more hooks than during the previous render)

useTsInterfaceForm()

hook to create a form for a TsInterface

Usage
import { useTsInterfaceForm } from "simplified-schema-form";
import DatasetConfigJson from "code-types/db/ts-interfaces/datasetconfig.json";
import { DatasetConfig, TsInterface } from "code-types";
import { Storing } from "model-types";

in your component:
const initialValue:DatasetConfig = {} as any;
const [Form, value, onChange] = useTsInterfaceForm(DatasetConfigJson as Storing<TsInterface>,initialValue);
Input
-
Output
📄 useTsInterfaceForm (exported const)

hook to create a form for a TsInterface

Usage
import { useTsInterfaceForm } from "simplified-schema-form";
import DatasetConfigJson from "code-types/db/ts-interfaces/datasetconfig.json";
import { DatasetConfig, TsInterface } from "code-types";
import { Storing } from "model-types";

in your component:
const initialValue:DatasetConfig = {} as any;
const [Form, value, onChange] = useTsInterfaceForm(DatasetConfigJson as Storing<TsInterface>,initialValue);
Internal
Show internal (13)
<ArrayForm />

Component to render a parameter that holds an array

This is simply a wrapper around another

SimplifiedSchemaForm

Recursive component that renders a form for a SimplifiedSchema

SimplifiedSchemaForm where the onChange and values are slightly different

This component renders a

SimplifiedSchemaForm

Recursive component that renders a form for a SimplifiedSchema

SimplifiedSchemaForm for every item in the array, and adds buttons to insert/remove new items.

Input
-
OutputJSX.Element
getReferencedModelDataItem()
Input
parameterNamestring
Output
<ObjectForm />

Component to render a parameter that holds an object

This is simply a wrapper around another SimplifiedSchemaForm where the onChange and values are slightly different

Input
-
OutputJSX.Element
<ReferenceInput />

This component renders an input to select an item to reference from another model (or multiple)

Input
-
OutputJSX.Element
renderParameterTitle()
Input
-
OutputJSX.Element
🔹 ReferencedModelDataItem

Properties:

NameTypeDescription
data (optional)array
isLoading (optional)boolean
parameterNamestring
dataParameterName (optional)string
descriptor (optional)string
keyInModel (optional)string
interfaceName (optional)string
isReferenceMultipleParameterboolean
isReferenceSingleParameterboolean
isReferenceParameterboolean
🔹 ReferenceItem

Properties:

NameTypeDescription
idstring
slug (optional)string
name (optional)string
categoryStackCalculated (optional)array
🔹 ReferenceItemsObject

Properties:

NameTypeDescription
data (optional)array
isLoading (optional)boolean
📄 ArrayForm (exported const)

Component to render a parameter that holds an array

This is simply a wrapper around another

SimplifiedSchemaForm

Recursive component that renders a form for a SimplifiedSchema

SimplifiedSchemaForm where the onChange and values are slightly different

This component renders a

SimplifiedSchemaForm

Recursive component that renders a form for a SimplifiedSchema

SimplifiedSchemaForm for every item in the array, and adds buttons to insert/remove new items.

📄 getReferencedModelDataItem (exported const)
📄 ObjectForm (exported const)

Component to render a parameter that holds an object

This is simply a wrapper around another SimplifiedSchemaForm where the onChange and values are slightly different

📄 ReferenceInput (exported const)

This component renders an input to select an item to reference from another model (or multiple)

📄 renderParameterTitle (exported const)