@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.
Files changed (84) hide show
  1. package/README.md +74 -0
  2. package/dist/Form.d.ts +2 -2
  3. package/dist/Form.js +4 -4
  4. package/dist/Form.stories.d.ts +12 -11
  5. package/dist/Form.stories.js +65 -38
  6. package/dist/Form.test.js +1 -1
  7. package/dist/FormEditor.d.ts +3 -3
  8. package/dist/FormEditor.js +6 -6
  9. package/dist/FormEditor.stories.d.ts +5 -4
  10. package/dist/FormEditor.stories.js +3 -5
  11. package/dist/fields/AnyField.d.ts +3 -3
  12. package/dist/fields/AnyField.js +5 -6
  13. package/dist/fields/ArrayField.d.ts +3 -3
  14. package/dist/fields/ArrayField.js +10 -10
  15. package/dist/fields/BooleanField.d.ts +3 -3
  16. package/dist/fields/BooleanField.js +3 -3
  17. package/dist/fields/DateField.d.ts +3 -3
  18. package/dist/fields/DateField.js +3 -3
  19. package/dist/fields/NullField.d.ts +3 -3
  20. package/dist/fields/NullField.js +2 -2
  21. package/dist/fields/NumberField.d.ts +3 -3
  22. package/dist/fields/NumberField.js +2 -2
  23. package/dist/fields/ObjectField.d.ts +3 -3
  24. package/dist/fields/ObjectField.js +27 -7
  25. package/dist/fields/RadioField.d.ts +3 -3
  26. package/dist/fields/RadioField.js +3 -3
  27. package/dist/fields/SchemaField.d.ts +3 -3
  28. package/dist/fields/SchemaField.js +6 -5
  29. package/dist/fields/SearchMultiTagSelectField.d.ts +3 -3
  30. package/dist/fields/SearchMultiTagSelectField.js +4 -3
  31. package/dist/fields/StringField.d.ts +3 -3
  32. package/dist/fields/StringField.js +9 -7
  33. package/dist/fields/ToggleField.d.ts +3 -3
  34. package/dist/fields/ToggleField.js +3 -3
  35. package/dist/formEditorSchemas.d.ts +1 -1
  36. package/dist/hooks/index.d.ts +2 -0
  37. package/dist/hooks/index.js +2 -0
  38. package/dist/hooks/useExtractUiSchema.d.ts +8 -0
  39. package/dist/hooks/useExtractUiSchema.js +22 -0
  40. package/dist/hooks/useSetDefault.d.ts +2 -0
  41. package/dist/hooks/useSetDefault.js +16 -0
  42. package/dist/sampleData/completeSchema.d.ts +3 -0
  43. package/dist/{_sampleData.js → sampleData/completeSchema.js} +0 -107
  44. package/dist/sampleData/conditionsSchema.d.ts +3 -0
  45. package/dist/sampleData/conditionsSchema.js +80 -0
  46. package/dist/sampleData/generatedSchema.d.ts +2 -0
  47. package/dist/sampleData/generatedSchema.js +19 -0
  48. package/dist/sampleData/index.d.ts +5 -0
  49. package/dist/sampleData/index.js +5 -0
  50. package/dist/sampleData/requiredInputSchema.d.ts +3 -0
  51. package/dist/sampleData/requiredInputSchema.js +72 -0
  52. package/dist/sampleData/simpleData.d.ts +7 -0
  53. package/dist/sampleData/simpleData.js +16 -0
  54. package/dist/styledComponents.d.ts +181 -84
  55. package/dist/styledComponents.js +28 -29
  56. package/dist/templates/ArrayFieldTemplate.d.ts +3 -3
  57. package/dist/templates/ArrayFieldTemplate.js +5 -4
  58. package/dist/templates/FieldTemplate.d.ts +3 -3
  59. package/dist/templates/FieldTemplate.js +6 -5
  60. package/dist/templates/ObjectFieldTemplate.d.ts +3 -3
  61. package/dist/templates/ObjectFieldTemplate.js +4 -3
  62. package/dist/types.d.ts +2 -2
  63. package/dist/utils/__tests/getEnums.test.d.ts +1 -0
  64. package/dist/utils/__tests/getEnums.test.js +64 -0
  65. package/dist/utils/__tests/resolveSchema.test.d.ts +1 -0
  66. package/dist/utils/__tests/resolveSchema.test.js +106 -0
  67. package/dist/utils/deepEqual.d.ts +1 -0
  68. package/dist/utils/deepEqual.js +18 -0
  69. package/dist/utils/getEnums.d.ts +10 -0
  70. package/dist/utils/getEnums.js +30 -0
  71. package/dist/utils/getTitleAndDescription.d.ts +12 -0
  72. package/dist/utils/getTitleAndDescription.js +15 -0
  73. package/dist/utils/getTypes.d.ts +5 -0
  74. package/dist/utils/getTypes.js +53 -0
  75. package/dist/utils/index.d.ts +7 -0
  76. package/dist/utils/index.js +14 -0
  77. package/dist/utils/mergeSchemas.d.ts +1 -0
  78. package/dist/utils/mergeSchemas.js +26 -0
  79. package/dist/utils/resolveSchema.d.ts +2 -0
  80. package/dist/utils/resolveSchema.js +68 -0
  81. package/package.json +32 -37
  82. package/dist/_sampleData.d.ts +0 -12
  83. package/dist/utils.d.ts +0 -32
  84. package/dist/utils.js +0 -138
@@ -1,3 +1,3 @@
1
- /// <reference types="react" />
2
- import { FieldProps } from "../types";
3
- export declare function SchemaField(props: FieldProps): JSX.Element;
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 { useExtractUiSchema, getSchemaType } from "../utils";
3
+ import { getSchemaType } from "../utils";
4
+ import { useExtractUiSchema } from "../hooks";
4
5
  import { FormRegistry } from "../Form";
5
6
  import { COMPONENT_TYPES } from "./types";
6
- function useFieldComponent(schema, uiSchema, fields) {
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 function SchemaField(props) {
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
- /// <reference types="react" />
2
- import { FieldProps } from "../types";
3
- export declare function SearchMultiTagSelectField(props: FieldProps): JSX.Element;
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, useExtractUiSchema, useSetDefault } from "../utils";
4
+ import { getEnums } from "../utils";
5
+ import { useExtractUiSchema, useSetDefault } from "../hooks";
5
6
  import { SearchableMultiTagSelectField } from "../styledComponents";
6
- export function SearchMultiTagSelectField(props) {
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
- /// <reference types="react" />
2
- import { FieldProps } from "../types";
3
- export declare function StringField(props: FieldProps): JSX.Element;
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, useExtractUiSchema, useSetDefault } from "../utils";
5
- export function StringField(props) {
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({}, 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: "" }, Object.assign({ disabled: true, 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", Object.assign({ value: option.const }, { children: option.title }), index)))] })) })));
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({}, Object.assign({ type,
18
- placeholder }, inputProps), { name: name })) })));
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
- /// <reference types="react" />
2
- import { FieldProps } from "../types";
3
- export declare function ToggleField(props: FieldProps): JSX.Element;
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 "../utils";
5
- export function ToggleField(props) {
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
+ };
@@ -1,3 +1,3 @@
1
- import { Schema, UiSchema } from "./types";
1
+ import type { Schema, UiSchema } from "./types";
2
2
  export declare const schema: Schema;
3
3
  export declare const uiSchema: UiSchema;
@@ -0,0 +1,2 @@
1
+ export * from "./useExtractUiSchema";
2
+ export * from "./useSetDefault";
@@ -0,0 +1,2 @@
1
+ export * from "./useExtractUiSchema";
2
+ export * from "./useSetDefault";
@@ -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,2 @@
1
+ import type { FieldProps } from "../types";
2
+ export declare const useSetDefault: (props: FieldProps) => void;
@@ -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
+ };
@@ -0,0 +1,3 @@
1
+ import type { Schema, UiSchema } from "../types";
2
+ export declare const completeSchema: Schema;
3
+ export declare const completeUiSchema: UiSchema;
@@ -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,3 @@
1
+ import type { Schema, UiSchema } from "../types";
2
+ export declare const conditionsSchema: Schema;
3
+ export declare const conditionsUiSchema: UiSchema;
@@ -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,2 @@
1
+ import type { Schema } from "../types";
2
+ export declare const generatedSchema: Schema;
@@ -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,5 @@
1
+ export * from "./simpleData";
2
+ export * from "./completeSchema";
3
+ export * from "./generatedSchema";
4
+ export * from "./requiredInputSchema";
5
+ export * from "./conditionsSchema";
@@ -0,0 +1,5 @@
1
+ export * from "./simpleData";
2
+ export * from "./completeSchema";
3
+ export * from "./generatedSchema";
4
+ export * from "./requiredInputSchema";
5
+ export * from "./conditionsSchema";
@@ -0,0 +1,3 @@
1
+ import type { Schema, UiSchema } from "../types";
2
+ export declare const requiredInputSchema: Schema;
3
+ export declare const requiredInputUiSchema: UiSchema;
@@ -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,7 @@
1
+ import type { Schema, UiSchema } from "../types";
2
+ export type SimpleFormDataType = {
3
+ firstName: string;
4
+ lastName: string;
5
+ };
6
+ export declare const simpleSchema: Schema;
7
+ export declare const simpleUiSchema: UiSchema;
@@ -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
+ };