@nolwenture/formik-jsonschema-form 0.4.0 → 0.4.2
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/dist/Form.js
CHANGED
|
@@ -36,6 +36,8 @@ export function Form(props) {
|
|
|
36
36
|
"children",
|
|
37
37
|
"fields",
|
|
38
38
|
"formContext",
|
|
39
|
+
"components",
|
|
40
|
+
"hideUnmarkedAdditionalProperties",
|
|
39
41
|
]);
|
|
40
42
|
var isSubmitting = useFormikContext().isSubmitting;
|
|
41
43
|
var schema = props.schema, _a = props.uiSchema, uiSchema = _a === void 0 ? {} : _a, className = props.className, children = props.children, _b = props.fields, fields = _b === void 0 ? {} : _b, _c = props.templates, templates = _c === void 0 ? {} : _c, _d = props.components, components = _d === void 0 ? {} : _d, _e = props.formContext, formContext = _e === void 0 ? {} : _e, _f = props.useItemsAsAdditionalItems, useItemsAsAdditionalItems = _f === void 0 ? false : _f, _g = props.hideUnmarkedAdditionalProperties, hideUnmarkedAdditionalProperties = _g === void 0 ? false : _g;
|
package/dist/Form.stories.js
CHANGED
|
@@ -118,6 +118,13 @@ export var StylesCustomized = function () {
|
|
|
118
118
|
return [2 /*return*/];
|
|
119
119
|
});
|
|
120
120
|
}); } }, { children: _jsx(CustomizedForm, { schema: simpleSchema, uiSchema: {
|
|
121
|
+
age: {
|
|
122
|
+
props: {
|
|
123
|
+
wrapper: {
|
|
124
|
+
title: "ABC",
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
},
|
|
121
128
|
firstName: {
|
|
122
129
|
props: {
|
|
123
130
|
wrapper: {
|
package/dist/_sampleData.js
CHANGED
|
@@ -4,6 +4,7 @@ export var simpleSchema = {
|
|
|
4
4
|
properties: {
|
|
5
5
|
firstName: { type: "string", title: "First name" },
|
|
6
6
|
lastName: { type: "string", title: "Last name" },
|
|
7
|
+
age: { type: "number", title: "Age" },
|
|
7
8
|
},
|
|
8
9
|
};
|
|
9
10
|
export var simpleUiSchema = {
|
|
@@ -298,7 +299,7 @@ export var generatedSchema = {
|
|
|
298
299
|
};
|
|
299
300
|
export var requiredInputSchema = {
|
|
300
301
|
title: "TITLE",
|
|
301
|
-
required: ["lastName"],
|
|
302
|
+
required: ["lastName", "requiredNestedObject", "requiredArray"],
|
|
302
303
|
properties: {
|
|
303
304
|
firstName: { type: "string", title: "First name" },
|
|
304
305
|
lastName: { type: "string", title: "Last name" },
|
|
@@ -319,13 +320,13 @@ export var requiredInputSchema = {
|
|
|
319
320
|
title: "Second favourites",
|
|
320
321
|
required: ["secondFavouriteSong"],
|
|
321
322
|
properties: {
|
|
322
|
-
|
|
323
|
+
anotherFavouriteFood: {
|
|
323
324
|
type: "string",
|
|
324
|
-
title: "
|
|
325
|
+
title: "Another favourite food",
|
|
325
326
|
},
|
|
326
|
-
|
|
327
|
+
anotherFavouriteSong: {
|
|
327
328
|
type: "string",
|
|
328
|
-
title: "
|
|
329
|
+
title: "Another favourite song",
|
|
329
330
|
},
|
|
330
331
|
},
|
|
331
332
|
},
|
|
@@ -339,5 +340,21 @@ export var requiredInputSchema = {
|
|
|
339
340
|
tasks: { type: "string", title: "Tasks" },
|
|
340
341
|
},
|
|
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
|
+
},
|
|
358
|
+
},
|
|
342
359
|
},
|
|
343
360
|
};
|
|
@@ -13,6 +13,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
13
13
|
import { useContext } from "react";
|
|
14
14
|
import { FormRegistry } from "../Form";
|
|
15
15
|
import { useExtractUiSchema, getDescription, getTitle } from "../utils";
|
|
16
|
+
import { RequiredIndicator } from "../styledComponents";
|
|
16
17
|
export function ArrayFieldTemplate(props) {
|
|
17
18
|
var _a = useContext(FormRegistry).components, ArrayFieldWrapper = _a.ArrayFieldWrapper, ArrayFieldTitle = _a.ArrayFieldTitle, FieldDescription = _a.FieldDescription, ErrorMessage = _a.ErrorMessage, FieldHelp = _a.FieldHelp, InfoFieldButton = _a.InfoFieldButton;
|
|
18
19
|
var name = props.name, uiSchema = props.uiSchema, children = props.children;
|
|
@@ -23,5 +24,5 @@ export function ArrayFieldTemplate(props) {
|
|
|
23
24
|
_c = _b.props,
|
|
24
25
|
//TODO: This is not right
|
|
25
26
|
_d = _c === void 0 ? {} : _c, wrappertProps = _d.wrapper, titleProps = _d.title, descriptionProps = _d.description, helpProps = _d.help, errorProps = _d.error;
|
|
26
|
-
return (_jsxs(ArrayFieldWrapper, __assign({}, wrappertProps, { children: [title && (
|
|
27
|
+
return (_jsxs(ArrayFieldWrapper, __assign({}, wrappertProps, { children: [title && (_jsxs(ArrayFieldTitle, __assign({}, titleProps, { htmlFor: name }, { children: [title, (props === null || props === void 0 ? void 0 : props.required) && _jsx(RequiredIndicator, { children: "*" })] }))), info && _jsx(InfoFieldButton, __assign({}, info)), description && (_jsx(FieldDescription, __assign({}, descriptionProps, { children: description }))), children, help && _jsx(FieldHelp, __assign({}, helpProps, { children: help })), _jsx(ErrorMessage, __assign({}, errorProps, { name: name }))] })));
|
|
27
28
|
}
|
|
@@ -13,6 +13,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
13
13
|
import { useContext } from "react";
|
|
14
14
|
import { FormRegistry } from "../Form";
|
|
15
15
|
import { getDescription, getTitle, useExtractUiSchema } from "../utils";
|
|
16
|
+
import { RequiredIndicator } from "../styledComponents";
|
|
16
17
|
export function ObjectFieldTemplate(props) {
|
|
17
18
|
var _a = useContext(FormRegistry).components, FieldDescription = _a.FieldDescription, ObjectFieldTitle = _a.ObjectFieldTitle, ObjectFieldWrapper = _a.ObjectFieldWrapper, FieldHelp = _a.FieldHelp, InfoFieldButton = _a.InfoFieldButton;
|
|
18
19
|
var children = props.children, uiSchema = props.uiSchema;
|
|
@@ -23,5 +24,5 @@ export function ObjectFieldTemplate(props) {
|
|
|
23
24
|
_c = _b.props,
|
|
24
25
|
//TODO: This is not right
|
|
25
26
|
_d = _c === void 0 ? {} : _c, wrapperProps = _d.wrapper, titleProps = _d.title, descriptionProps = _d.description, helpProps = _d.help;
|
|
26
|
-
return (_jsxs(ObjectFieldWrapper, __assign({}, wrapperProps, { children: [title &&
|
|
27
|
+
return (_jsxs(ObjectFieldWrapper, __assign({}, wrapperProps, { children: [title && (_jsxs(ObjectFieldTitle, __assign({}, titleProps, { children: [title, (props === null || props === void 0 ? void 0 : props.required) && _jsx(RequiredIndicator, { children: "*" })] }))), info && _jsx(InfoFieldButton, __assign({}, info)), description && (_jsx(FieldDescription, __assign({}, descriptionProps, { children: description }))), children, help && _jsx(FieldHelp, __assign({}, helpProps, { children: help }))] })));
|
|
27
28
|
}
|
package/dist/utils.js
CHANGED
|
@@ -63,6 +63,9 @@ export function useSetDefault(props) {
|
|
|
63
63
|
}
|
|
64
64
|
export function useExtractUiSchema(props) {
|
|
65
65
|
if (props === void 0) { props = {}; }
|
|
66
|
+
if (props.props !== undefined) {
|
|
67
|
+
props["ui:props"] = __assign(__assign({}, props["ui:props"]), props.props);
|
|
68
|
+
}
|
|
66
69
|
return useMemo(function () {
|
|
67
70
|
var _a = props["ui:options"], options = _a === void 0 ? {} : _a, uiSchema = __rest(props, ["ui:options"]);
|
|
68
71
|
return __assign(__assign({}, Object.keys(uiSchema || {}).reduce(function (result, key) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nolwenture/formik-jsonschema-form",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"description": "Formik form generation from json schema",
|
|
5
5
|
"author": "Antti Vikman <antti.vikman@nolwenture.com>",
|
|
6
6
|
"contributors": [
|
|
@@ -22,7 +22,11 @@
|
|
|
22
22
|
],
|
|
23
23
|
"main": "./dist/index.js",
|
|
24
24
|
"types": "./dist/index.d.ts",
|
|
25
|
-
"files": [
|
|
25
|
+
"files": [
|
|
26
|
+
"dist",
|
|
27
|
+
"package.json",
|
|
28
|
+
"LICENSE"
|
|
29
|
+
],
|
|
26
30
|
"dependencies": {
|
|
27
31
|
"@testing-library/jest-dom": "^5.16.4",
|
|
28
32
|
"@testing-library/react": "^13.3.0",
|