@nolwenture/formik-jsonschema-form 0.4.2 → 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 (88) hide show
  1. package/README.md +187 -0
  2. package/dist/Form.d.ts +2 -2
  3. package/dist/Form.js +15 -26
  4. package/dist/Form.stories.d.ts +12 -11
  5. package/dist/Form.stories.js +134 -101
  6. package/dist/Form.test.js +3 -3
  7. package/dist/FormEditor.d.ts +3 -3
  8. package/dist/FormEditor.js +14 -59
  9. package/dist/FormEditor.stories.d.ts +5 -4
  10. package/dist/FormEditor.stories.js +3 -16
  11. package/dist/fields/AnyField.d.ts +3 -3
  12. package/dist/fields/AnyField.js +12 -24
  13. package/dist/fields/ArrayField.d.ts +3 -3
  14. package/dist/fields/ArrayField.js +42 -64
  15. package/dist/fields/BooleanField.d.ts +3 -3
  16. package/dist/fields/BooleanField.js +7 -18
  17. package/dist/fields/DateField.d.ts +3 -3
  18. package/dist/fields/DateField.js +7 -18
  19. package/dist/fields/NullField.d.ts +3 -3
  20. package/dist/fields/NullField.js +5 -16
  21. package/dist/fields/NumberField.d.ts +3 -3
  22. package/dist/fields/NumberField.js +3 -14
  23. package/dist/fields/ObjectField.d.ts +3 -3
  24. package/dist/fields/ObjectField.js +43 -46
  25. package/dist/fields/RadioField.d.ts +3 -0
  26. package/dist/fields/RadioField.js +11 -0
  27. package/dist/fields/SchemaField.d.ts +3 -3
  28. package/dist/fields/SchemaField.js +13 -23
  29. package/dist/fields/SearchMultiTagSelectField.d.ts +3 -0
  30. package/dist/fields/SearchMultiTagSelectField.js +14 -0
  31. package/dist/fields/StringField.d.ts +3 -3
  32. package/dist/fields/StringField.js +13 -51
  33. package/dist/fields/ToggleField.d.ts +3 -0
  34. package/dist/fields/ToggleField.js +11 -0
  35. package/dist/fields/index.d.ts +3 -0
  36. package/dist/fields/index.js +3 -0
  37. package/dist/fields/types.js +1 -1
  38. package/dist/formEditorSchemas.d.ts +1 -1
  39. package/dist/formEditorSchemas.js +3 -3
  40. package/dist/hooks/index.d.ts +2 -0
  41. package/dist/hooks/index.js +2 -0
  42. package/dist/hooks/useExtractUiSchema.d.ts +8 -0
  43. package/dist/hooks/useExtractUiSchema.js +22 -0
  44. package/dist/hooks/useSetDefault.d.ts +2 -0
  45. package/dist/hooks/useSetDefault.js +16 -0
  46. package/dist/sampleData/completeSchema.d.ts +3 -0
  47. package/dist/{_sampleData.js → sampleData/completeSchema.js} +28 -97
  48. package/dist/sampleData/conditionsSchema.d.ts +3 -0
  49. package/dist/sampleData/conditionsSchema.js +80 -0
  50. package/dist/sampleData/generatedSchema.d.ts +2 -0
  51. package/dist/sampleData/generatedSchema.js +19 -0
  52. package/dist/sampleData/index.d.ts +5 -0
  53. package/dist/sampleData/index.js +5 -0
  54. package/dist/sampleData/requiredInputSchema.d.ts +3 -0
  55. package/dist/sampleData/requiredInputSchema.js +72 -0
  56. package/dist/sampleData/simpleData.d.ts +7 -0
  57. package/dist/sampleData/simpleData.js +16 -0
  58. package/dist/styledComponents.d.ts +193 -47
  59. package/dist/styledComponents.js +342 -138
  60. package/dist/templates/ArrayFieldTemplate.d.ts +3 -3
  61. package/dist/templates/ArrayFieldTemplate.js +11 -23
  62. package/dist/templates/FieldTemplate.d.ts +3 -3
  63. package/dist/templates/FieldTemplate.js +11 -23
  64. package/dist/templates/ObjectFieldTemplate.d.ts +3 -3
  65. package/dist/templates/ObjectFieldTemplate.js +13 -23
  66. package/dist/types.d.ts +34 -3
  67. package/dist/utils/__tests/getEnums.test.d.ts +1 -0
  68. package/dist/utils/__tests/getEnums.test.js +64 -0
  69. package/dist/utils/__tests/resolveSchema.test.d.ts +1 -0
  70. package/dist/utils/__tests/resolveSchema.test.js +106 -0
  71. package/dist/utils/deepEqual.d.ts +1 -0
  72. package/dist/utils/deepEqual.js +18 -0
  73. package/dist/utils/getEnums.d.ts +10 -0
  74. package/dist/utils/getEnums.js +30 -0
  75. package/dist/utils/getTitleAndDescription.d.ts +12 -0
  76. package/dist/utils/getTitleAndDescription.js +15 -0
  77. package/dist/utils/getTypes.d.ts +5 -0
  78. package/dist/utils/getTypes.js +53 -0
  79. package/dist/utils/index.d.ts +7 -0
  80. package/dist/utils/index.js +14 -0
  81. package/dist/utils/mergeSchemas.d.ts +1 -0
  82. package/dist/utils/mergeSchemas.js +26 -0
  83. package/dist/utils/resolveSchema.d.ts +2 -0
  84. package/dist/utils/resolveSchema.js +68 -0
  85. package/package.json +32 -37
  86. package/dist/_sampleData.d.ts +0 -11
  87. package/dist/utils.d.ts +0 -25
  88. package/dist/utils.js +0 -125
@@ -0,0 +1,11 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useContext } from "react";
3
+ import { FormRegistry } from "../Form";
4
+ import { useExtractUiSchema, useSetDefault } from "../hooks";
5
+ export const RadioField = (props) => {
6
+ const { templates: { FieldTemplate }, components: { RadioButtonField }, } = useContext(FormRegistry);
7
+ useSetDefault(props);
8
+ const { name, uiSchema } = props;
9
+ const { label, props: inputProps } = useExtractUiSchema(uiSchema);
10
+ return (_jsx(FieldTemplate, Object.assign({}, props, { children: _jsx(RadioButtonField, { inputProps: inputProps, label: label, name: name }) })));
11
+ };
@@ -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,39 +1,29 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
1
  import { jsx as _jsx } from "react/jsx-runtime";
13
2
  import { useContext } from "react";
14
- import { useExtractUiSchema, getSchemaType } from "../utils";
3
+ import { getSchemaType } from "../utils";
4
+ import { useExtractUiSchema } from "../hooks";
15
5
  import { FormRegistry } from "../Form";
16
6
  import { COMPONENT_TYPES } from "./types";
17
- function useFieldComponent(schema, uiSchema, fields) {
18
- var field = useExtractUiSchema(uiSchema).field;
7
+ const useFieldComponent = (schema, uiSchema, fields) => {
8
+ const { field } = useExtractUiSchema(uiSchema);
19
9
  if (typeof field === "function") {
20
10
  return field;
21
11
  }
22
12
  if (typeof field === "string" && field in fields) {
23
13
  return fields[field];
24
14
  }
25
- var schemaType = getSchemaType(schema);
15
+ let schemaType = getSchemaType(schema);
26
16
  if (Array.isArray(schemaType)) {
27
17
  schemaType = schemaType[0];
28
18
  }
29
- var componentName = COMPONENT_TYPES[schemaType || "any"];
19
+ const componentName = COMPONENT_TYPES[schemaType || "any"];
30
20
  return componentName in fields
31
21
  ? fields[componentName]
32
22
  : fields.UnsupportedField;
33
- }
34
- export function SchemaField(props) {
35
- var schema = props.schema, uiSchema = props.uiSchema;
36
- var fields = useContext(FormRegistry).fields;
37
- var FieldComponent = useFieldComponent(schema, uiSchema, fields);
38
- return _jsx(FieldComponent, __assign({}, props));
39
- }
23
+ };
24
+ export const SchemaField = (props) => {
25
+ const { schema, uiSchema } = props;
26
+ const { fields } = useContext(FormRegistry);
27
+ const FieldComponent = useFieldComponent(schema, uiSchema, fields);
28
+ return _jsx(FieldComponent, Object.assign({}, props));
29
+ };
@@ -0,0 +1,3 @@
1
+ import type { FieldProps } from "../types";
2
+ import React from "react";
3
+ export declare const SearchMultiTagSelectField: React.FC<FieldProps>;
@@ -0,0 +1,14 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useContext, useMemo } from "react";
3
+ import { FormRegistry } from "../Form";
4
+ import { getEnums } from "../utils";
5
+ import { useExtractUiSchema, useSetDefault } from "../hooks";
6
+ import { SearchableMultiTagSelectField } from "../styledComponents";
7
+ export const SearchMultiTagSelectField = (props) => {
8
+ const { templates: { FieldTemplate }, } = useContext(FormRegistry);
9
+ useSetDefault(props);
10
+ const { name, uiSchema } = props;
11
+ const { placeholder, emptySearchMessage, props: inputProps, } = useExtractUiSchema(uiSchema);
12
+ const enums = useMemo(() => getEnums(props), [props]);
13
+ return (_jsx(FieldTemplate, Object.assign({}, props, { children: _jsx(SearchableMultiTagSelectField, Object.assign({}, inputProps, { name: name, placeholder: placeholder, emptySearchMessage: emptySearchMessage, enums: enums })) })));
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,60 +1,22 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
2
  import { useContext, useMemo } from "react";
14
3
  import { FormRegistry } from "../Form";
15
- import { useExtractUiSchema, useSetDefault } from "../utils";
16
- function getEnums(_a) {
17
- var schema = _a.schema;
18
- var numberOfDefined = [schema.enum, schema.oneOf, schema.anyOf].filter(function (x) { return x; }).length;
19
- if (numberOfDefined === 0) {
20
- return;
21
- }
22
- if (numberOfDefined > 1) {
23
- throw new Error('Only one of "enum", "oneOf" or "anyOf" can be defined!');
24
- }
25
- if (schema.enum) {
26
- return {
27
- type: "select",
28
- values: schema.enum.map(function (option) { return ({
29
- const: option,
30
- title: "".concat(option),
31
- }); }),
32
- };
33
- }
34
- if (schema.oneOf) {
35
- return {
36
- type: "select",
37
- values: schema.oneOf,
38
- };
39
- }
40
- if (schema.anyOf) {
41
- return {
42
- type: "multiSelect",
43
- values: schema.anyOf,
44
- };
45
- }
46
- }
47
- export function StringField(props) {
48
- var _a = useContext(FormRegistry), FieldTemplate = _a.templates.FieldTemplate, FieldInput = _a.components.FieldInput;
4
+ import { getEnums } from "../utils";
5
+ import { useExtractUiSchema, useSetDefault } from "../hooks";
6
+ export const StringField = (props) => {
7
+ var _a;
8
+ const { templates: { FieldTemplate }, components: { FieldInput }, } = useContext(FormRegistry);
49
9
  useSetDefault(props);
50
- var name = props.name, schema = props.schema, uiSchema = props.uiSchema;
51
- var _b = useExtractUiSchema(uiSchema), type = _b.type, placeholder = _b.placeholder, inputProps = _b.props;
52
- var enums = useMemo(function () { return getEnums(props); }, [props]);
10
+ const { name, uiSchema = {}, schema } = props;
11
+ const { type, placeholder, props: inputProps } = useExtractUiSchema(uiSchema);
12
+ const enums = useMemo(() => getEnums(props), [props]);
53
13
  switch (enums === null || enums === void 0 ? void 0 : enums.type) {
54
14
  case "select":
55
15
  case "multiSelect":
56
- return (_jsx(FieldTemplate, __assign({}, props, { children: _jsxs(FieldInput, __assign({}, __assign({ type: type, placeholder: placeholder }, inputProps), { name: name, formikAs: "select", multiple: enums.type === "multiSelect" }, { children: [enums.type !== "multiSelect" && (_jsx("option", __assign({ value: "", disabled: true, selected: true, hidden: true }, { children: placeholder }))), enums === null || enums === void 0 ? void 0 : enums.values.map(function (option, index) { return (_jsx("option", __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)))] })) })));
57
18
  default:
58
- return (_jsx(FieldTemplate, __assign({}, props, { children: _jsx(FieldInput, __assign({}, __assign({ type: type, placeholder: placeholder }, inputProps), { name: name })) })));
19
+ return (_jsx(FieldTemplate, Object.assign({}, props, { children: _jsx(FieldInput, Object.assign({ type,
20
+ placeholder }, inputProps, { name: name })) })));
59
21
  }
60
- }
22
+ };
@@ -0,0 +1,3 @@
1
+ import type { FieldProps } from "../types";
2
+ import React from "react";
3
+ export declare const ToggleField: React.FC<FieldProps>;
@@ -0,0 +1,11 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useContext } from "react";
3
+ import { FormRegistry } from "../Form";
4
+ import { useExtractUiSchema, useSetDefault } from "../hooks";
5
+ export const ToggleField = (props) => {
6
+ const { templates: { FieldTemplate }, components: { ToggleSwitchField }, } = useContext(FormRegistry);
7
+ useSetDefault(props);
8
+ const { name, uiSchema } = props;
9
+ const { props: inputProps } = useExtractUiSchema(uiSchema);
10
+ return (_jsx(FieldTemplate, Object.assign({}, props, { children: _jsx(ToggleSwitchField, Object.assign({}, inputProps, { name: name })) })));
11
+ };
@@ -7,3 +7,6 @@ export * from "./ObjectField";
7
7
  export * from "./SchemaField";
8
8
  export * from "./StringField";
9
9
  export * from "./AnyField";
10
+ export * from "./RadioField";
11
+ export * from "./ToggleField";
12
+ export * from "./SearchMultiTagSelectField";
@@ -7,3 +7,6 @@ export * from "./ObjectField";
7
7
  export * from "./SchemaField";
8
8
  export * from "./StringField";
9
9
  export * from "./AnyField";
10
+ export * from "./RadioField";
11
+ export * from "./ToggleField";
12
+ export * from "./SearchMultiTagSelectField";
@@ -1,4 +1,4 @@
1
- export var COMPONENT_TYPES = {
1
+ export const COMPONENT_TYPES = {
2
2
  array: "ArrayField",
3
3
  boolean: "BooleanField",
4
4
  integer: "NumberField",
@@ -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;
@@ -1,4 +1,4 @@
1
- var field = {
1
+ const field = {
2
2
  type: "object",
3
3
  properties: {
4
4
  type: {
@@ -17,7 +17,7 @@ var field = {
17
17
  },
18
18
  },
19
19
  };
20
- export var schema = {
20
+ export const schema = {
21
21
  type: "object",
22
22
  properties: {
23
23
  "schema.type": {
@@ -31,6 +31,6 @@ export var schema = {
31
31
  },
32
32
  additionalProperties: field,
33
33
  };
34
- export var uiSchema = {
34
+ export const uiSchema = {
35
35
  "schema.type": { props: { type: "hidden" } },
36
36
  };
@@ -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,21 +1,5 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- export var 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 var simpleUiSchema = {
11
- "ui:description": "Description text",
12
- firstName: {
13
- "ui:info": {
14
- content: "A small info",
15
- },
16
- },
17
- };
18
- export var completeSchema = {
2
+ export const completeSchema = {
19
3
  title: "Inventory",
20
4
  type: "object",
21
5
  required: ["string", "number", "boolean", "enum"],
@@ -46,6 +30,7 @@ export var completeSchema = {
46
30
  title: "Enum",
47
31
  description: "Enum description",
48
32
  enum: [1, 2, 3, 4],
33
+ default: 1,
49
34
  },
50
35
  enumOneOf: {
51
36
  type: "number",
@@ -69,6 +54,20 @@ export var completeSchema = {
69
54
  { const: 4, title: "four" },
70
55
  ],
71
56
  },
57
+ enumTagSelectAnyOf: {
58
+ type: "string",
59
+ title: "Enum searchable tag select anyOf",
60
+ description: "Enum searchable tag select anyOf description",
61
+ anyOf: [
62
+ { const: "cat", title: "cat" },
63
+ { const: "dog", title: "dog" },
64
+ { const: "bunny", title: "bunny" },
65
+ { const: "canary", title: "canary" },
66
+ { const: "hamster", title: "hamster" },
67
+ { const: "goldfish", title: "goldfish" },
68
+ { const: "dragon", title: "dragon" },
69
+ ],
70
+ },
72
71
  null: { type: "null", title: "Null", description: "Null description" },
73
72
  nested: {
74
73
  type: "object",
@@ -189,7 +188,7 @@ export var completeSchema = {
189
188
  },
190
189
  },
191
190
  };
192
- export var completeUiSchema = {
191
+ export const completeUiSchema = {
193
192
  string: {
194
193
  "ui:help": "String help",
195
194
  "ui:options": {
@@ -214,8 +213,13 @@ export var completeUiSchema = {
214
213
  },
215
214
  enum: {
216
215
  "ui:help": "Enum help",
216
+ "ui:placeholderOptionOptions": {
217
+ props: { disabled: false, hidden: false },
218
+ },
219
+ },
220
+ enumOneOf: {
221
+ placeholder: "Select one",
217
222
  },
218
- enumOneOf: { placeholder: "Select one" },
219
223
  null: {
220
224
  "ui:help": "Null help",
221
225
  },
@@ -277,84 +281,11 @@ export var completeUiSchema = {
277
281
  },
278
282
  },
279
283
  },
280
- };
281
- export var generatedSchema = {
282
- type: "object",
283
- properties: {
284
- object: {
285
- type: "object",
286
- additionalProperties: {},
287
- },
288
- value: {},
289
- array: {
290
- type: "array",
291
- items: {},
292
- },
293
- property: {
294
- type: "string",
295
- },
296
- },
297
- required: ["object", "value", "property"],
298
- additionalProperties: false,
299
- };
300
- export var requiredInputSchema = {
301
- title: "TITLE",
302
- required: ["lastName", "requiredNestedObject", "requiredArray"],
303
- properties: {
304
- firstName: { type: "string", title: "First name" },
305
- lastName: { type: "string", title: "Last name" },
306
- arrayOfObject: {
307
- type: "array",
308
- title: "Array of objects",
309
- items: {
310
- type: "object",
311
- title: "Favourites",
312
- required: ["favouriteFood"],
313
- properties: {
314
- favouriteFood: { type: "string", title: "Favourite food" },
315
- favouriteSong: { type: "string", title: "Favourite song" },
316
- },
317
- },
318
- additionalItems: {
319
- type: "object",
320
- title: "Second favourites",
321
- required: ["secondFavouriteSong"],
322
- properties: {
323
- anotherFavouriteFood: {
324
- type: "string",
325
- title: "Another favourite food",
326
- },
327
- anotherFavouriteSong: {
328
- type: "string",
329
- title: "Another favourite song",
330
- },
331
- },
332
- },
333
- },
334
- nestedObject: {
335
- type: "object",
336
- title: "Nested Object",
337
- required: ["tasks"],
338
- properties: {
339
- hobbies: { type: "string", title: "Hobbies" },
340
- tasks: { type: "string", title: "Tasks" },
341
- },
342
- },
343
- requiredNestedObject: {
344
- type: "object",
345
- title: "Required Nested Object",
346
- properties: {
347
- plans: { type: "string", title: "Future plans" },
348
- past: { type: "string", title: "Past achievements" },
349
- },
350
- },
351
- requiredArray: {
352
- type: "array",
353
- title: "Required Array",
354
- description: "Array description for required array",
355
- additionalItems: {
356
- type: "string",
357
- },
284
+ enumTagSelectAnyOf: {
285
+ "ui:field": "SearchMultiTagSelectField",
286
+ "ui:options": {
287
+ placeholder: "Search...",
288
+ emptySearchMessage: "...no matching results found",
358
289
  },
359
290
  },
360
291
  };
@@ -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;