openlaw-elements
Advanced tools
Comparing version 1.0.0-beta.7 to 1.0.0-beta.8
@@ -131,3 +131,4 @@ "use strict"; | ||
}; | ||
return (0, _sectionUtil.GetSections)(variableNames, sectionVariables, sections, getSectionsConfig).map(function (_ref, index) { | ||
return (0, _sectionUtil.GetSections)(variableNames, sectionVariables, sections, getSectionsConfig).map(function (_ref, index, _ref2) { | ||
var sectionCount = _ref2.length; | ||
var variables = _ref.variables, | ||
@@ -149,3 +150,5 @@ sectionData = (0, _objectWithoutProperties2.default)(_ref, ["variables"]); | ||
children: inputsChildrenComponent | ||
}, sectionData)); | ||
}, sectionData, { | ||
sectionCount: sectionCount | ||
})); | ||
} | ||
@@ -212,3 +215,3 @@ | ||
if (sections.length > 0) { | ||
if (sections.length) { | ||
formContent = renderSectionsAndInputs((0, _objectSpread2.default)({ | ||
@@ -215,0 +218,0 @@ sections: sections, |
@@ -34,6 +34,6 @@ "use strict"; | ||
var sectionTransform = config.sectionTransform, | ||
sectionVariablesMap = config.sectionVariablesMap; | ||
var mappedSections = sections.map(function (section, index) { | ||
var sectionTransform = config.sectionTransform, | ||
sectionVariablesMap = config.sectionVariablesMap; | ||
var sectionVariablesFromConfig = sectionVariablesMap && sectionVariablesMap(section, index); | ||
var sectionVariablesFromConfig = sectionVariablesMap && sectionVariablesMap(section, index, variables); | ||
@@ -65,3 +65,3 @@ var _ref = sectionVariablesFromConfig ? Object.keys(sectionVariablesFromConfig) : [], | ||
}); | ||
var orphanVariables = variables.filter(function (v) { | ||
var unsectionedVariables = variables.filter(function (v) { | ||
var flattedSectionVariables = mappedSections.reduce(function (acc, o) { | ||
@@ -71,9 +71,20 @@ return acc.concat(o.variables); | ||
return flattedSectionVariables.indexOf(v) === -1; | ||
}); | ||
}); // give the unsectioned variables a home in their own section | ||
if (orphanVariables.length > 0) { | ||
mappedSections.push({ | ||
section: getUnsectionedTitle(), | ||
variables: orphanVariables | ||
}); | ||
if (unsectionedVariables.length) { | ||
var sectionData; // user has a desired section data shape for display purposes | ||
if (sectionTransform) { | ||
var index = mappedSections.length; | ||
sectionData = (0, _objectSpread2.default)({}, sectionTransform(getUnsectionedTitle(), index), { | ||
variables: unsectionedVariables | ||
}); | ||
} else { | ||
sectionData = { | ||
section: getUnsectionedTitle(), | ||
variables: unsectionedVariables | ||
}; | ||
} | ||
mappedSections.push(sectionData); | ||
} | ||
@@ -80,0 +91,0 @@ |
@@ -111,3 +111,5 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty"; | ||
}; | ||
return GetSections(variableNames, sectionVariables, sections, getSectionsConfig).map(function (_ref, index) { | ||
return GetSections(variableNames, sectionVariables, sections, getSectionsConfig).map(function (_ref, index, _ref2) { | ||
var sectionCount = _ref2.length; | ||
var variables = _ref.variables, | ||
@@ -129,3 +131,5 @@ sectionData = _objectWithoutProperties(_ref, ["variables"]); | ||
children: inputsChildrenComponent | ||
}, sectionData)); | ||
}, sectionData, { | ||
sectionCount: sectionCount | ||
})); | ||
} | ||
@@ -191,3 +195,3 @@ | ||
if (sections.length > 0) { | ||
if (sections.length) { | ||
formContent = renderSectionsAndInputs(_objectSpread({ | ||
@@ -194,0 +198,0 @@ sections: sections, |
@@ -24,6 +24,6 @@ import _objectSpread from "@babel/runtime/helpers/objectSpread"; | ||
var sectionTransform = config.sectionTransform, | ||
sectionVariablesMap = config.sectionVariablesMap; | ||
var mappedSections = sections.map(function (section, index) { | ||
var sectionTransform = config.sectionTransform, | ||
sectionVariablesMap = config.sectionVariablesMap; | ||
var sectionVariablesFromConfig = sectionVariablesMap && sectionVariablesMap(section, index); | ||
var sectionVariablesFromConfig = sectionVariablesMap && sectionVariablesMap(section, index, variables); | ||
@@ -55,3 +55,3 @@ var _ref = sectionVariablesFromConfig ? Object.keys(sectionVariablesFromConfig) : [], | ||
}); | ||
var orphanVariables = variables.filter(function (v) { | ||
var unsectionedVariables = variables.filter(function (v) { | ||
var flattedSectionVariables = mappedSections.reduce(function (acc, o) { | ||
@@ -61,9 +61,20 @@ return acc.concat(o.variables); | ||
return flattedSectionVariables.indexOf(v) === -1; | ||
}); | ||
}); // give the unsectioned variables a home in their own section | ||
if (orphanVariables.length > 0) { | ||
mappedSections.push({ | ||
section: getUnsectionedTitle(), | ||
variables: orphanVariables | ||
}); | ||
if (unsectionedVariables.length) { | ||
var sectionData; // user has a desired section data shape for display purposes | ||
if (sectionTransform) { | ||
var index = mappedSections.length; | ||
sectionData = _objectSpread({}, sectionTransform(getUnsectionedTitle(), index), { | ||
variables: unsectionedVariables | ||
}); | ||
} else { | ||
sectionData = { | ||
section: getUnsectionedTitle(), | ||
variables: unsectionedVariables | ||
}; | ||
} | ||
mappedSections.push(sectionData); | ||
} | ||
@@ -70,0 +81,0 @@ |
{ | ||
"name": "openlaw-elements", | ||
"version": "1.0.0-beta.7", | ||
"version": "1.0.0-beta.8", | ||
"description": "Dynamically render React form components from an OpenLaw template.", | ||
@@ -5,0 +5,0 @@ "author": "OpenLaw Team <opensource@openlaw.io>", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
436176
5142