diff --git a/package.json b/package.json
index c2848cd..048ffa7 100644
--- a/package.json
+++ b/package.json
@@ -2,7 +2,15 @@
"name": "react-jsonschema-form-pagination",
"description": "Extension of react-jsonschema-form with support for multi-nav forms",
"private": false,
- "author": "mavarazy@gmail.com",
+ "authors": [
+ "mavarazy@gmail.com"
+ ],
+ "contributors": [
+ {
+ "name": "Ayush",
+ "url": "https://github.com/Ayush1959"
+ }
+ ],
"version": "0.4.1",
"scripts": {
"build:lib": "rimraf lib && cross-env NODE_ENV=production babel -d lib/ src/",
@@ -13,6 +21,7 @@
"dist": "npm run build:lib && npm run build:dist",
"lint": "eslint src test playground --fix",
"precommit": "lint-staged",
+ "prepare": "npm run build:lib",
"publish-to-gh-pages": "npm run build:playground && gh-pages --dist build/",
"publish-to-npm": "npm run dist && npm publish && npm version patch",
"start": "webpack-dev-server",
diff --git a/src/render/utils.js b/src/render/utils.js
index 8899971..466861c 100644
--- a/src/render/utils.js
+++ b/src/render/utils.js
@@ -6,6 +6,7 @@ const COMPONENT_TYPES = {
integer: "NumberField",
number: "NumberField",
object: "ObjectField",
+ undefined: "StringField",
string: "StringField",
};
@@ -17,13 +18,20 @@ export function getFieldComponent(schema, uiSchema, fields) {
if (typeof field === "string" && field in fields) {
return fields[field];
}
- const componentName = COMPONENT_TYPES[schema.type];
+ let componentName = COMPONENT_TYPES[schema.type];
+ if (
+ Array.isArray(schema.type) &&
+ schema.type.includes("string") &&
+ schema.type.includes("object")
+ ) {
+ componentName = "StringField";
+ }
return componentName in fields
? fields[componentName]
: () =>
Unknown field type {schema.type}
;
}
-const REQUIRED_FIELD_SYMBOL = "*";
+const REQUIRED_FIELD_SYMBOL = "* ";
function DefaultLabel(props) {
const { label, required, id } = props;
@@ -33,7 +41,10 @@ function DefaultLabel(props) {
}
return (
);
}
@@ -53,7 +64,9 @@ export function Label({
if (type === "boolean" && !uiSchema["ui:widget"]) {
displayLabel = false;
}
-
+ if (uiSchema["ui:widget"] && uiSchema["ui:widget"] === "hidden") {
+ displayLabel = false;
+ }
if (displayLabel) {
return (
diff --git a/src/splitter/NavTree.js b/src/splitter/NavTree.js
index 9631b9a..f082d33 100644
--- a/src/splitter/NavTree.js
+++ b/src/splitter/NavTree.js
@@ -41,8 +41,10 @@ export default class NavTree {
extractSubUiSchema(fields, aliases, this.uiSchema, uiSchema, this.schema);
+ const firstInUi = activeNav[0] && uiSchema && uiSchema[activeNav[0]] && uiSchema[activeNav[0]]['ui:order'] && uiSchema[activeNav[0]]['ui:order'][0];
+ const firstField = firstInUi ? activeNav[0] + '.' + firstInUi : null;
if (navConfs.length > 0) {
- asNavField(fields[0], navConfs, uiSchema);
+ asNavField(firstField || fields[0], navConfs, uiSchema);
}
navConfs = [];
}
diff --git a/src/splitter/extractTree.js b/src/splitter/extractTree.js
index 199d322..50c8a83 100644
--- a/src/splitter/extractTree.js
+++ b/src/splitter/extractTree.js
@@ -3,7 +3,7 @@ import {
toArray,
getNavAliases,
findFieldNavs,
- UI_ORDER,
+ UI_ORDER
} from "../utils";
export function findRelTree(tree, navs) {
@@ -19,7 +19,7 @@ function pushField(tree, field, uiAlias) {
if (tree[GENERIC_NAV] === undefined) {
tree[GENERIC_NAV] = {
fields: [],
- aliases: {},
+ aliases: {}
};
}
tree[GENERIC_NAV].fields.push(field);
@@ -33,7 +33,12 @@ function fillSchemaConf(tree, schema, uiSchema, prefix = "") {
const fieldSchema = schema.properties[field];
const fieldUiSchema = uiSchema[field];
if (fieldSchema.type === "object" && fieldUiSchema) {
- fillSchemaConf(tree, fieldSchema, fieldUiSchema, field + ".");
+ fillSchemaConf(
+ tree,
+ fieldSchema,
+ fieldUiSchema,
+ prefix.length ? prefix + field + "." : field + "."
+ );
} else {
let navs = findFieldNavs(field, uiSchema);
let subTree = findRelTree(tree, navs);
diff --git a/src/splitter/util.js b/src/splitter/util.js
index 0b8b91f..5213397 100644
--- a/src/splitter/util.js
+++ b/src/splitter/util.js
@@ -4,7 +4,7 @@ export const asNavField = (field, navConfs, uiSchema) => {
uiSchema[field] = {
navConfs,
"ui:field": "nav",
- origUiSchema: uiSchema[field],
+ origUiSchema: uiSchema[field]
};
} else {
const parentField = field.substr(0, separatorIndex);
@@ -17,13 +17,22 @@ export const asNavField = (field, navConfs, uiSchema) => {
function asHiddenField(field, uiSchema) {
uiSchema[field] = {
"ui:widget": "hidden",
- "ui:field": "hidden",
+ "ui:field": "hidden"
};
}
export const toHiddenUiSchema = ({ properties }, uiSchema) => {
let cleanUiSchema = Object.keys(properties).reduce((agg, field) => {
asHiddenField(field, agg);
+ if (typeof properties[field] == "object") {
+ if ("properties" in properties[field]) {
+ Object.assign(
+ agg[field],
+ agg[field],
+ toHiddenUiSchema(properties[field], agg[field])
+ );
+ }
+ }
return agg;
}, Object.assign({}, uiSchema));
return cleanUiSchema;