@nolwenture/formik-jsonschema-form 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +74 -0
- package/dist/Form.d.ts +2 -2
- package/dist/Form.js +4 -4
- package/dist/Form.stories.d.ts +12 -11
- package/dist/Form.stories.js +65 -38
- package/dist/Form.test.js +1 -1
- package/dist/FormEditor.d.ts +3 -3
- package/dist/FormEditor.js +6 -6
- package/dist/FormEditor.stories.d.ts +5 -4
- package/dist/FormEditor.stories.js +3 -5
- package/dist/fields/AnyField.d.ts +3 -3
- package/dist/fields/AnyField.js +5 -6
- package/dist/fields/ArrayField.d.ts +3 -3
- package/dist/fields/ArrayField.js +10 -10
- package/dist/fields/BooleanField.d.ts +3 -3
- package/dist/fields/BooleanField.js +3 -3
- package/dist/fields/DateField.d.ts +3 -3
- package/dist/fields/DateField.js +3 -3
- package/dist/fields/NullField.d.ts +3 -3
- package/dist/fields/NullField.js +2 -2
- package/dist/fields/NumberField.d.ts +3 -3
- package/dist/fields/NumberField.js +2 -2
- package/dist/fields/ObjectField.d.ts +3 -3
- package/dist/fields/ObjectField.js +27 -7
- package/dist/fields/RadioField.d.ts +3 -3
- package/dist/fields/RadioField.js +3 -3
- package/dist/fields/SchemaField.d.ts +3 -3
- package/dist/fields/SchemaField.js +6 -5
- package/dist/fields/SearchMultiTagSelectField.d.ts +3 -3
- package/dist/fields/SearchMultiTagSelectField.js +4 -3
- package/dist/fields/StringField.d.ts +3 -3
- package/dist/fields/StringField.js +9 -7
- package/dist/fields/ToggleField.d.ts +3 -3
- package/dist/fields/ToggleField.js +3 -3
- package/dist/formEditorSchemas.d.ts +1 -1
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/index.js +2 -0
- package/dist/hooks/useExtractUiSchema.d.ts +8 -0
- package/dist/hooks/useExtractUiSchema.js +22 -0
- package/dist/hooks/useSetDefault.d.ts +2 -0
- package/dist/hooks/useSetDefault.js +16 -0
- package/dist/sampleData/completeSchema.d.ts +3 -0
- package/dist/{_sampleData.js → sampleData/completeSchema.js} +0 -107
- package/dist/sampleData/conditionsSchema.d.ts +3 -0
- package/dist/sampleData/conditionsSchema.js +80 -0
- package/dist/sampleData/generatedSchema.d.ts +2 -0
- package/dist/sampleData/generatedSchema.js +19 -0
- package/dist/sampleData/index.d.ts +5 -0
- package/dist/sampleData/index.js +5 -0
- package/dist/sampleData/requiredInputSchema.d.ts +3 -0
- package/dist/sampleData/requiredInputSchema.js +72 -0
- package/dist/sampleData/simpleData.d.ts +7 -0
- package/dist/sampleData/simpleData.js +16 -0
- package/dist/styledComponents.d.ts +181 -84
- package/dist/styledComponents.js +28 -29
- package/dist/templates/ArrayFieldTemplate.d.ts +3 -3
- package/dist/templates/ArrayFieldTemplate.js +5 -4
- package/dist/templates/FieldTemplate.d.ts +3 -3
- package/dist/templates/FieldTemplate.js +6 -5
- package/dist/templates/ObjectFieldTemplate.d.ts +3 -3
- package/dist/templates/ObjectFieldTemplate.js +4 -3
- package/dist/types.d.ts +2 -2
- package/dist/utils/__tests/getEnums.test.d.ts +1 -0
- package/dist/utils/__tests/getEnums.test.js +64 -0
- package/dist/utils/__tests/resolveSchema.test.d.ts +1 -0
- package/dist/utils/__tests/resolveSchema.test.js +106 -0
- package/dist/utils/deepEqual.d.ts +1 -0
- package/dist/utils/deepEqual.js +18 -0
- package/dist/utils/getEnums.d.ts +10 -0
- package/dist/utils/getEnums.js +30 -0
- package/dist/utils/getTitleAndDescription.d.ts +12 -0
- package/dist/utils/getTitleAndDescription.js +15 -0
- package/dist/utils/getTypes.d.ts +5 -0
- package/dist/utils/getTypes.js +53 -0
- package/dist/utils/index.d.ts +7 -0
- package/dist/utils/index.js +14 -0
- package/dist/utils/mergeSchemas.d.ts +1 -0
- package/dist/utils/mergeSchemas.js +26 -0
- package/dist/utils/resolveSchema.d.ts +2 -0
- package/dist/utils/resolveSchema.js +68 -0
- package/package.json +32 -37
- package/dist/_sampleData.d.ts +0 -12
- package/dist/utils.d.ts +0 -32
- package/dist/utils.js +0 -138
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
export declare
|
|
1
|
+
import type { FieldProps } from "../types";
|
|
2
|
+
import React from "react";
|
|
3
|
+
export declare const SchemaField: React.FC<FieldProps>;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useContext } from "react";
|
|
3
|
-
import {
|
|
3
|
+
import { getSchemaType } from "../utils";
|
|
4
|
+
import { useExtractUiSchema } from "../hooks";
|
|
4
5
|
import { FormRegistry } from "../Form";
|
|
5
6
|
import { COMPONENT_TYPES } from "./types";
|
|
6
|
-
|
|
7
|
+
const useFieldComponent = (schema, uiSchema, fields) => {
|
|
7
8
|
const { field } = useExtractUiSchema(uiSchema);
|
|
8
9
|
if (typeof field === "function") {
|
|
9
10
|
return field;
|
|
@@ -19,10 +20,10 @@ function useFieldComponent(schema, uiSchema, fields) {
|
|
|
19
20
|
return componentName in fields
|
|
20
21
|
? fields[componentName]
|
|
21
22
|
: fields.UnsupportedField;
|
|
22
|
-
}
|
|
23
|
-
export
|
|
23
|
+
};
|
|
24
|
+
export const SchemaField = (props) => {
|
|
24
25
|
const { schema, uiSchema } = props;
|
|
25
26
|
const { fields } = useContext(FormRegistry);
|
|
26
27
|
const FieldComponent = useFieldComponent(schema, uiSchema, fields);
|
|
27
28
|
return _jsx(FieldComponent, Object.assign({}, props));
|
|
28
|
-
}
|
|
29
|
+
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
export declare
|
|
1
|
+
import type { FieldProps } from "../types";
|
|
2
|
+
import React from "react";
|
|
3
|
+
export declare const SearchMultiTagSelectField: React.FC<FieldProps>;
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useContext, useMemo } from "react";
|
|
3
3
|
import { FormRegistry } from "../Form";
|
|
4
|
-
import { getEnums
|
|
4
|
+
import { getEnums } from "../utils";
|
|
5
|
+
import { useExtractUiSchema, useSetDefault } from "../hooks";
|
|
5
6
|
import { SearchableMultiTagSelectField } from "../styledComponents";
|
|
6
|
-
export
|
|
7
|
+
export const SearchMultiTagSelectField = (props) => {
|
|
7
8
|
const { templates: { FieldTemplate }, } = useContext(FormRegistry);
|
|
8
9
|
useSetDefault(props);
|
|
9
10
|
const { name, uiSchema } = props;
|
|
10
11
|
const { placeholder, emptySearchMessage, props: inputProps, } = useExtractUiSchema(uiSchema);
|
|
11
12
|
const enums = useMemo(() => getEnums(props), [props]);
|
|
12
13
|
return (_jsx(FieldTemplate, Object.assign({}, props, { children: _jsx(SearchableMultiTagSelectField, Object.assign({}, inputProps, { name: name, placeholder: placeholder, emptySearchMessage: emptySearchMessage, enums: enums })) })));
|
|
13
|
-
}
|
|
14
|
+
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
export declare
|
|
1
|
+
import type { FieldProps } from "../types";
|
|
2
|
+
import React from "react";
|
|
3
|
+
export declare const StringField: React.FC<FieldProps>;
|
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useContext, useMemo } from "react";
|
|
3
3
|
import { FormRegistry } from "../Form";
|
|
4
|
-
import { getEnums
|
|
5
|
-
|
|
4
|
+
import { getEnums } from "../utils";
|
|
5
|
+
import { useExtractUiSchema, useSetDefault } from "../hooks";
|
|
6
|
+
export const StringField = (props) => {
|
|
6
7
|
var _a;
|
|
7
8
|
const { templates: { FieldTemplate }, components: { FieldInput }, } = useContext(FormRegistry);
|
|
8
9
|
useSetDefault(props);
|
|
9
|
-
const { name, uiSchema } = props;
|
|
10
|
+
const { name, uiSchema = {}, schema } = props;
|
|
10
11
|
const { type, placeholder, props: inputProps } = useExtractUiSchema(uiSchema);
|
|
11
12
|
const enums = useMemo(() => getEnums(props), [props]);
|
|
12
13
|
switch (enums === null || enums === void 0 ? void 0 : enums.type) {
|
|
13
14
|
case "select":
|
|
14
15
|
case "multiSelect":
|
|
15
|
-
return (_jsx(FieldTemplate, Object.assign({}, props, { children: _jsxs(FieldInput, Object.assign({
|
|
16
|
+
return (_jsx(FieldTemplate, Object.assign({}, props, { children: _jsxs(FieldInput, Object.assign({ type }, inputProps, { name: name, formikAs: "select", multiple: enums.type === "multiSelect" }, (enums.type !== "multiSelect" ? { defaultValue: "" } : {}), { children: [enums.type !== "multiSelect" && (_jsx("option", Object.assign({ value: "", disabled: true,
|
|
17
|
+
hidden: true }, (_a = uiSchema["ui:placeholderOptionOptions"]) === null || _a === void 0 ? void 0 : _a.props, { children: placeholder }))), enums === null || enums === void 0 ? void 0 : enums.values.map((option, index) => (_jsx("option", { value: option.const, children: option.title }, index)))] })) })));
|
|
16
18
|
default:
|
|
17
|
-
return (_jsx(FieldTemplate, Object.assign({}, props, { children: _jsx(FieldInput, Object.assign({
|
|
18
|
-
placeholder }, inputProps
|
|
19
|
+
return (_jsx(FieldTemplate, Object.assign({}, props, { children: _jsx(FieldInput, Object.assign({ type,
|
|
20
|
+
placeholder }, inputProps, { name: name })) })));
|
|
19
21
|
}
|
|
20
|
-
}
|
|
22
|
+
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
export declare
|
|
1
|
+
import type { FieldProps } from "../types";
|
|
2
|
+
import React from "react";
|
|
3
|
+
export declare const ToggleField: React.FC<FieldProps>;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useContext } from "react";
|
|
3
3
|
import { FormRegistry } from "../Form";
|
|
4
|
-
import { useExtractUiSchema, useSetDefault } from "../
|
|
5
|
-
export
|
|
4
|
+
import { useExtractUiSchema, useSetDefault } from "../hooks";
|
|
5
|
+
export const ToggleField = (props) => {
|
|
6
6
|
const { templates: { FieldTemplate }, components: { ToggleSwitchField }, } = useContext(FormRegistry);
|
|
7
7
|
useSetDefault(props);
|
|
8
8
|
const { name, uiSchema } = props;
|
|
9
9
|
const { props: inputProps } = useExtractUiSchema(uiSchema);
|
|
10
10
|
return (_jsx(FieldTemplate, Object.assign({}, props, { children: _jsx(ToggleSwitchField, Object.assign({}, inputProps, { name: name })) })));
|
|
11
|
-
}
|
|
11
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { UiSchema } from "../types";
|
|
2
|
+
export declare const useExtractUiSchema: (props?: UiSchema | undefined) => {
|
|
3
|
+
[name: string]: any;
|
|
4
|
+
field?: UiSchema["ui:field"];
|
|
5
|
+
props?: UiSchema["ui:props"];
|
|
6
|
+
help?: UiSchema["ui:help"];
|
|
7
|
+
info?: UiSchema["ui:info"];
|
|
8
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { useMemo } from "react";
|
|
13
|
+
export const useExtractUiSchema = (props = {}) => {
|
|
14
|
+
var _a, _b;
|
|
15
|
+
if (props.props !== undefined) {
|
|
16
|
+
props["ui:props"] = Object.assign(Object.assign({}, ((_a = props["ui:props"]) !== null && _a !== void 0 ? _a : {})), ((_b = props.props) !== null && _b !== void 0 ? _b : {}));
|
|
17
|
+
}
|
|
18
|
+
return useMemo(() => {
|
|
19
|
+
const { "ui:options": options = {} } = props, uiSchema = __rest(props, ["ui:options"]);
|
|
20
|
+
return Object.assign(Object.assign({}, Object.keys(uiSchema || {}).reduce((result, key) => (Object.assign(Object.assign({}, result), { [key.replace("ui:", "")]: uiSchema[key] })), {})), options);
|
|
21
|
+
}, [props]);
|
|
22
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
import { useField } from "formik";
|
|
3
|
+
import { getDefaultValueForType } from "../utils";
|
|
4
|
+
export const useSetDefault = (props) => {
|
|
5
|
+
const [{ value }, _, { setValue }] = useField(props.name);
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
if (!value) {
|
|
8
|
+
if (props.schema.default) {
|
|
9
|
+
setValue(props.schema.default);
|
|
10
|
+
}
|
|
11
|
+
else if (props.forceDefaultValue) {
|
|
12
|
+
setValue(getDefaultValueForType(props.schema.type));
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}, []);
|
|
16
|
+
};
|
|
@@ -1,20 +1,4 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
export const simpleSchema = {
|
|
3
|
-
title: "TITLE",
|
|
4
|
-
properties: {
|
|
5
|
-
firstName: { type: "string", title: "First name" },
|
|
6
|
-
lastName: { type: "string", title: "Last name" },
|
|
7
|
-
age: { type: "number", title: "Age" },
|
|
8
|
-
},
|
|
9
|
-
};
|
|
10
|
-
export const simpleUiSchema = {
|
|
11
|
-
"ui:description": "Description text",
|
|
12
|
-
firstName: {
|
|
13
|
-
"ui:info": {
|
|
14
|
-
content: "A small info",
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
};
|
|
18
2
|
export const completeSchema = {
|
|
19
3
|
title: "Inventory",
|
|
20
4
|
type: "object",
|
|
@@ -305,94 +289,3 @@ export const completeUiSchema = {
|
|
|
305
289
|
},
|
|
306
290
|
},
|
|
307
291
|
};
|
|
308
|
-
export const generatedSchema = {
|
|
309
|
-
type: "object",
|
|
310
|
-
properties: {
|
|
311
|
-
object: {
|
|
312
|
-
type: "object",
|
|
313
|
-
additionalProperties: {},
|
|
314
|
-
},
|
|
315
|
-
value: {},
|
|
316
|
-
array: {
|
|
317
|
-
type: "array",
|
|
318
|
-
items: {},
|
|
319
|
-
},
|
|
320
|
-
property: {
|
|
321
|
-
type: "string",
|
|
322
|
-
},
|
|
323
|
-
},
|
|
324
|
-
required: ["object", "value", "property"],
|
|
325
|
-
additionalProperties: false,
|
|
326
|
-
};
|
|
327
|
-
export const requiredInputSchema = {
|
|
328
|
-
title: "TITLE",
|
|
329
|
-
required: ["lastName", "requiredNestedObject", "requiredArray"],
|
|
330
|
-
properties: {
|
|
331
|
-
firstName: { type: "string", title: "First name" },
|
|
332
|
-
lastName: { type: "string", title: "Last name" },
|
|
333
|
-
feeling: { type: "boolean", title: "Feeling happy today?" },
|
|
334
|
-
vibes: { type: "boolean", title: "Turn on the good vibes" },
|
|
335
|
-
arrayOfObject: {
|
|
336
|
-
type: "array",
|
|
337
|
-
title: "Array of objects",
|
|
338
|
-
items: {
|
|
339
|
-
type: "object",
|
|
340
|
-
title: "Favourites",
|
|
341
|
-
required: ["favouriteFood"],
|
|
342
|
-
properties: {
|
|
343
|
-
favouriteFood: { type: "string", title: "Favourite food" },
|
|
344
|
-
favouriteSong: { type: "string", title: "Favourite song" },
|
|
345
|
-
},
|
|
346
|
-
},
|
|
347
|
-
additionalItems: {
|
|
348
|
-
type: "object",
|
|
349
|
-
title: "Second favourites",
|
|
350
|
-
required: ["secondFavouriteSong"],
|
|
351
|
-
properties: {
|
|
352
|
-
anotherFavouriteFood: {
|
|
353
|
-
type: "string",
|
|
354
|
-
title: "Another favourite food",
|
|
355
|
-
},
|
|
356
|
-
anotherFavouriteSong: {
|
|
357
|
-
type: "string",
|
|
358
|
-
title: "Another favourite song",
|
|
359
|
-
},
|
|
360
|
-
},
|
|
361
|
-
},
|
|
362
|
-
},
|
|
363
|
-
nestedObject: {
|
|
364
|
-
type: "object",
|
|
365
|
-
title: "Nested Object",
|
|
366
|
-
required: ["tasks"],
|
|
367
|
-
properties: {
|
|
368
|
-
hobbies: { type: "string", title: "Hobbies" },
|
|
369
|
-
tasks: { type: "string", title: "Tasks" },
|
|
370
|
-
},
|
|
371
|
-
},
|
|
372
|
-
requiredNestedObject: {
|
|
373
|
-
type: "object",
|
|
374
|
-
title: "Required Nested Object",
|
|
375
|
-
properties: {
|
|
376
|
-
plans: { type: "string", title: "Future plans" },
|
|
377
|
-
past: { type: "string", title: "Past achievements" },
|
|
378
|
-
},
|
|
379
|
-
},
|
|
380
|
-
requiredArray: {
|
|
381
|
-
type: "array",
|
|
382
|
-
title: "Required Array",
|
|
383
|
-
description: "Array description for required array",
|
|
384
|
-
additionalItems: {
|
|
385
|
-
type: "string",
|
|
386
|
-
},
|
|
387
|
-
},
|
|
388
|
-
},
|
|
389
|
-
};
|
|
390
|
-
export const requiredInputUiSchema = {
|
|
391
|
-
feeling: {
|
|
392
|
-
"ui:field": "RadioField",
|
|
393
|
-
"ui:label": { true: "yes", false: "no" },
|
|
394
|
-
},
|
|
395
|
-
vibes: {
|
|
396
|
-
"ui:field": "ToggleField",
|
|
397
|
-
},
|
|
398
|
-
};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
export const conditionsSchema = {
|
|
2
|
+
type: "object",
|
|
3
|
+
properties: {
|
|
4
|
+
animal: {
|
|
5
|
+
type: "string",
|
|
6
|
+
oneOf: [
|
|
7
|
+
{ const: "cat", title: "Cat" },
|
|
8
|
+
{ const: "fish", title: "Fish" },
|
|
9
|
+
{ const: "dog", title: "Dog" },
|
|
10
|
+
{ const: "horse", title: "Horse" },
|
|
11
|
+
{ const: "hamster", title: "Hamster" },
|
|
12
|
+
],
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
allOf: [
|
|
16
|
+
{
|
|
17
|
+
if: {
|
|
18
|
+
properties: {
|
|
19
|
+
animal: {
|
|
20
|
+
const: "cat",
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
then: {
|
|
25
|
+
properties: {
|
|
26
|
+
food: {
|
|
27
|
+
type: "string",
|
|
28
|
+
enum: ["meat", "grass", "fish"],
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
required: ["food"],
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
if: {
|
|
36
|
+
properties: {
|
|
37
|
+
animal: {
|
|
38
|
+
const: "fish",
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
then: {
|
|
43
|
+
properties: {
|
|
44
|
+
food: {
|
|
45
|
+
type: "string",
|
|
46
|
+
enum: ["insect", "worms"],
|
|
47
|
+
},
|
|
48
|
+
water: {
|
|
49
|
+
type: "string",
|
|
50
|
+
enum: ["lake", "sea"],
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
required: ["food", "water"],
|
|
54
|
+
},
|
|
55
|
+
// else: {
|
|
56
|
+
// properties: {
|
|
57
|
+
// likesWalkiesWhere: {
|
|
58
|
+
// type: "string",
|
|
59
|
+
// enum: ["park", "forest", "garden"],
|
|
60
|
+
// },
|
|
61
|
+
// },
|
|
62
|
+
// },
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
required: ["animal"],
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
};
|
|
69
|
+
export const conditionsUiSchema = {
|
|
70
|
+
animal: {
|
|
71
|
+
"ui:placeholderOptionOptions": {
|
|
72
|
+
props: { disabled: false, hidden: false },
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
food: {
|
|
76
|
+
"ui:placeholderOptionOptions": {
|
|
77
|
+
props: { disabled: false, hidden: false },
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export const generatedSchema = {
|
|
2
|
+
type: "object",
|
|
3
|
+
properties: {
|
|
4
|
+
object: {
|
|
5
|
+
type: "object",
|
|
6
|
+
additionalProperties: {},
|
|
7
|
+
},
|
|
8
|
+
value: {},
|
|
9
|
+
array: {
|
|
10
|
+
type: "array",
|
|
11
|
+
items: {},
|
|
12
|
+
},
|
|
13
|
+
property: {
|
|
14
|
+
type: "string",
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
required: ["object", "value", "property"],
|
|
18
|
+
additionalProperties: false,
|
|
19
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
export const requiredInputSchema = {
|
|
2
|
+
title: "TITLE",
|
|
3
|
+
required: ["lastName", "requiredNestedObject", "requiredArray"],
|
|
4
|
+
properties: {
|
|
5
|
+
firstName: { type: "string", title: "First name" },
|
|
6
|
+
lastName: { type: "string", title: "Last name" },
|
|
7
|
+
feeling: { type: "boolean", title: "Feeling happy today?" },
|
|
8
|
+
vibes: { type: "boolean", title: "Turn on the good vibes" },
|
|
9
|
+
arrayOfObject: {
|
|
10
|
+
type: "array",
|
|
11
|
+
title: "Array of objects",
|
|
12
|
+
items: {
|
|
13
|
+
type: "object",
|
|
14
|
+
title: "Favourites",
|
|
15
|
+
required: ["favouriteFood"],
|
|
16
|
+
properties: {
|
|
17
|
+
favouriteFood: { type: "string", title: "Favourite food" },
|
|
18
|
+
favouriteSong: { type: "string", title: "Favourite song" },
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
additionalItems: {
|
|
22
|
+
type: "object",
|
|
23
|
+
title: "Second favourites",
|
|
24
|
+
required: ["secondFavouriteSong"],
|
|
25
|
+
properties: {
|
|
26
|
+
anotherFavouriteFood: {
|
|
27
|
+
type: "string",
|
|
28
|
+
title: "Another favourite food",
|
|
29
|
+
},
|
|
30
|
+
anotherFavouriteSong: {
|
|
31
|
+
type: "string",
|
|
32
|
+
title: "Another favourite song",
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
nestedObject: {
|
|
38
|
+
type: "object",
|
|
39
|
+
title: "Nested Object",
|
|
40
|
+
required: ["tasks"],
|
|
41
|
+
properties: {
|
|
42
|
+
hobbies: { type: "string", title: "Hobbies" },
|
|
43
|
+
tasks: { type: "string", title: "Tasks" },
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
requiredNestedObject: {
|
|
47
|
+
type: "object",
|
|
48
|
+
title: "Required Nested Object",
|
|
49
|
+
properties: {
|
|
50
|
+
plans: { type: "string", title: "Future plans" },
|
|
51
|
+
past: { type: "string", title: "Past achievements" },
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
requiredArray: {
|
|
55
|
+
type: "array",
|
|
56
|
+
title: "Required Array",
|
|
57
|
+
description: "Array description for required array",
|
|
58
|
+
additionalItems: {
|
|
59
|
+
type: "string",
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
export const requiredInputUiSchema = {
|
|
65
|
+
feeling: {
|
|
66
|
+
"ui:field": "RadioField",
|
|
67
|
+
"ui:label": { true: "yes", false: "no" },
|
|
68
|
+
},
|
|
69
|
+
vibes: {
|
|
70
|
+
"ui:field": "ToggleField",
|
|
71
|
+
},
|
|
72
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const simpleSchema = {
|
|
2
|
+
title: "TITLE",
|
|
3
|
+
properties: {
|
|
4
|
+
firstName: { type: "string", title: "First name" },
|
|
5
|
+
lastName: { type: "string", title: "Last name" },
|
|
6
|
+
age: { type: "number", title: "Age" },
|
|
7
|
+
},
|
|
8
|
+
};
|
|
9
|
+
export const simpleUiSchema = {
|
|
10
|
+
"ui:description": "Description text",
|
|
11
|
+
firstName: {
|
|
12
|
+
"ui:info": {
|
|
13
|
+
content: "A small info",
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
};
|