openlaw-elements
Advanced tools
Comparing version 1.0.0-beta.4 to 1.0.0-beta.5
@@ -175,3 +175,3 @@ "use strict"; | ||
return React.createElement("div", { | ||
className: 'contract-variable collection-variable' + cleanName | ||
className: "contract-variable collection-variable ".concat(cleanName) | ||
}, React.createElement("div", { | ||
@@ -178,0 +178,0 @@ className: "collection-variable-description" |
@@ -12,4 +12,8 @@ "use strict"; | ||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); | ||
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread")); | ||
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties")); | ||
var React = _interopRequireWildcard(require("react")); | ||
@@ -25,4 +29,2 @@ | ||
var _Collapsible = _interopRequireDefault(require("./Collapsible")); | ||
var _propTypes = _interopRequireDefault(require("prop-types")); | ||
@@ -97,3 +99,13 @@ | ||
}), | ||
renderSections: _propTypes.default.func, | ||
sections: _propTypes.default.arrayOf(function (props, propName, componentName) { | ||
if (!Object.prototype.hasOwnProperty.call(props, propName)) { | ||
throw new Error("Prop `".concat(propName, "` has type 'any' or 'mixed', but was not provided to `").concat(componentName, "`. Pass undefined or any other value.")); | ||
} | ||
}), | ||
sectionTransform: _propTypes.default.func, | ||
sectionVariablesMap: _propTypes.default.func, | ||
textLikeInputClass: _propTypes.default.string, | ||
triggerDisabled: _propTypes.default.bool, | ||
unsectionedTitle: _propTypes.default.string, | ||
variables: _propTypes.default.arrayOf(_propTypes.default.shape({}).isRequired), | ||
@@ -103,24 +115,48 @@ variable: _propTypes.default.shape({}).isRequired | ||
var renderSections = function renderSections(props) { | ||
var renderSectionsAndInputs = function renderSectionsAndInputs(props) { | ||
var executionResult = props.executionResult, | ||
_props$openLaw2 = props.openLaw, | ||
openLaw = _props$openLaw2 === void 0 ? {} : _props$openLaw2, | ||
renderSections = props.renderSections, | ||
sections = props.sections, | ||
sectionTransform = props.sectionTransform, | ||
sectionVariablesMap = props.sectionVariablesMap, | ||
unsectionedTitle = props.unsectionedTitle, | ||
variablesMap = props.variablesMap, | ||
variableObjects = props.variableObjects; | ||
var sectionVariables = openLaw.getVariableSections(executionResult); | ||
var variableNames = variableObjects.map(function (variable) { | ||
return openLaw.getName(variable); | ||
var variableNames = variableObjects.map(function (v) { | ||
return openLaw.getName(v); | ||
}); | ||
return (0, _sectionUtil.GetSections)(variableNames, sectionVariables, sections).map(function (collapsible) { | ||
var section = collapsible.section; | ||
var currentVariables = collapsible.variables.map(function (name) { | ||
var getSectionsConfig = { | ||
sectionTransform: sectionTransform, | ||
sectionVariablesMap: sectionVariablesMap, | ||
unsectionedTitle: unsectionedTitle | ||
}; | ||
return (0, _sectionUtil.GetSections)(variableNames, sectionVariables, sections, getSectionsConfig).map(function (_ref, index) { | ||
var variables = _ref.variables, | ||
sectionData = (0, _objectWithoutProperties2.default)(_ref, ["variables"]); | ||
if (renderSections) { | ||
var inputsChildrenComponent = function inputsChildrenComponent() { | ||
return variables.map(function (name) { | ||
return variablesMap[name]; | ||
}).map(function (variable) { | ||
return renderInputs((0, _objectSpread2.default)({ | ||
variable: variable | ||
}, props)); | ||
}); | ||
}; | ||
return renderSections((0, _objectSpread2.default)({ | ||
children: inputsChildrenComponent | ||
}, sectionData)); | ||
} | ||
return React.createElement("div", { | ||
className: "contract-section", | ||
key: "".concat(sectionData.section, "-").concat(index) | ||
}, React.createElement("span", null, sectionData.section), variables.map(function (name) { | ||
return variablesMap[name]; | ||
}); | ||
return React.createElement(_Collapsible.default, { | ||
key: "section-".concat(section), | ||
open: true, | ||
overflowWhenOpen: "visible", | ||
trigger: section | ||
}, currentVariables.map(function (variable) { | ||
}).map(function (variable) { | ||
return renderInputs((0, _objectSpread2.default)({ | ||
@@ -133,3 +169,3 @@ variable: variable | ||
renderSections.propTypes = process.env.NODE_ENV === 'production' ? null : { | ||
renderSectionsAndInputs.propTypes = process.env.NODE_ENV === 'production' ? null : (0, _defineProperty2.default)({ | ||
apiClient: _propTypes.default.object, | ||
@@ -144,8 +180,17 @@ executionResult: _propTypes.default.shape({}), | ||
}), | ||
renderSections: _propTypes.default.func, | ||
sections: _propTypes.default.arrayOf(function (props, propName, componentName) { | ||
if (!Object.prototype.hasOwnProperty.call(props, propName)) { | ||
throw new Error("Prop `".concat(propName, "` has type 'any' or 'mixed', but was not provided to `").concat(componentName, "`. Pass undefined or any other value.")); | ||
} | ||
}), | ||
sectionTransform: _propTypes.default.func, | ||
sectionVariablesMap: _propTypes.default.func, | ||
textLikeInputClass: _propTypes.default.string, | ||
triggerDisabled: _propTypes.default.bool, | ||
unsectionedTitle: _propTypes.default.string, | ||
variables: _propTypes.default.arrayOf(_propTypes.default.shape({}).isRequired), | ||
variablesMap: _propTypes.default.objectOf(_propTypes.default.object.isRequired).isRequired, | ||
variableObjects: _propTypes.default.arrayOf(_propTypes.default.object.isRequired).isRequired, | ||
sections: _propTypes.default.arrayOf(_propTypes.default.object.isRequired).isRequired | ||
}; | ||
variableObjects: _propTypes.default.arrayOf(_propTypes.default.object.isRequired).isRequired | ||
}, "sections", _propTypes.default.arrayOf(_propTypes.default.object.isRequired).isRequired); | ||
@@ -155,2 +200,3 @@ var OpenLawForm = function OpenLawForm(props) { | ||
openLaw = props.openLaw, | ||
sectionsProp = props.sections, | ||
variables = props.variables; | ||
@@ -161,3 +207,3 @@ var allVariables = openLaw.getVariables(executionResult, {}); | ||
}); | ||
var sections = openLaw.getSections(executionResult); | ||
var sections = sectionsProp ? sectionsProp : openLaw.getSections(executionResult); | ||
var variableObjects = allVariables.filter(function (variable) { | ||
@@ -175,3 +221,3 @@ return openLaw.showInForm(variable, executionResult); | ||
if (sections.length > 0) { | ||
formContent = renderSections((0, _objectSpread2.default)({ | ||
formContent = renderSectionsAndInputs((0, _objectSpread2.default)({ | ||
sections: sections, | ||
@@ -209,4 +255,14 @@ variablesMap: variablesMap, | ||
}), | ||
renderSections: _propTypes.default.func, | ||
sections: _propTypes.default.arrayOf(function (props, propName, componentName) { | ||
if (!Object.prototype.hasOwnProperty.call(props, propName)) { | ||
throw new Error("Prop `".concat(propName, "` has type 'any' or 'mixed', but was not provided to `").concat(componentName, "`. Pass undefined or any other value.")); | ||
} | ||
}), | ||
sectionTransform: _propTypes.default.func, | ||
sectionVariablesMap: _propTypes.default.func, | ||
textLikeInputClass: _propTypes.default.string, | ||
triggerDisabled: _propTypes.default.bool, | ||
unsectionedTitle: _propTypes.default.string, | ||
variables: _propTypes.default.arrayOf(_propTypes.default.shape({}).isRequired) | ||
}; |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -8,35 +10,66 @@ value: true | ||
var getVariablesForSection = function getVariablesForSection(section, variables, sectionVariables, addedVariables) { | ||
return sectionVariables[section].map(function (name) { | ||
return variables.filter(function (variable) { | ||
return variable === name; | ||
})[0]; | ||
}).filter(function (variable) { | ||
return !!variable && addedVariables.indexOf(variable) === -1; | ||
}); | ||
}; | ||
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread")); | ||
var getVariablesWithNoSection = function getVariablesWithNoSection(variables, addedVariables) { | ||
return variables.filter(function (variable) { | ||
return addedVariables.indexOf(variable) === -1; | ||
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray")); | ||
var getVariablesForSection = function getVariablesForSection(sectionVariables, variables) { | ||
return sectionVariables.map(function (name) { | ||
return variables[variables.indexOf(name)]; | ||
}) // get rid of any `undefined` slots | ||
.filter(function (section) { | ||
return section && true; | ||
}); | ||
}; | ||
var GetSections = function GetSections(variables, sectionVariables, sections) { | ||
var addedVariables = []; | ||
var collapsibles = sections.filter(function (section) { | ||
return getVariablesForSection(section, variables, sectionVariables, addedVariables).length > 0; | ||
}).map(function (section) { | ||
var currentVariables = getVariablesForSection(section, variables, sectionVariables, addedVariables); | ||
addedVariables = addedVariables.concat(currentVariables); | ||
return { | ||
section: section, | ||
variables: currentVariables | ||
}; | ||
var GetSections = function GetSections(variables, sectionVariables, sections, config) { | ||
var getUnsectionedTitle = function getUnsectionedTitle() { | ||
var unsectionedTitle = config.unsectionedTitle; // set to string null value by the user | ||
if (unsectionedTitle === '') return ''; // there's a value set by the user | ||
if (unsectionedTitle) return unsectionedTitle; // default | ||
return 'Miscellaneous'; | ||
}; | ||
var mappedSections = sections.map(function (section, index) { | ||
var sectionTransform = config.sectionTransform, | ||
sectionVariablesMap = config.sectionVariablesMap; | ||
var sectionVariablesFromConfig = sectionVariablesMap && sectionVariablesMap(section, index); | ||
var _ref = sectionVariablesFromConfig ? Object.keys(sectionVariablesFromConfig) : [], | ||
_ref2 = (0, _slicedToArray2.default)(_ref, 1), | ||
userSectionKey = _ref2[0]; | ||
var currentSectionVariables = sectionVariablesFromConfig && Object.keys(sectionVariablesFromConfig).length ? // user provided an object with the same shape via props | ||
getVariablesForSection(sectionVariablesFromConfig[userSectionKey], variables) // normal | ||
: getVariablesForSection(sectionVariables[section], variables); | ||
if (currentSectionVariables.length) { | ||
// user has a desired section data shape for display purposes | ||
if (sectionTransform) { | ||
return (0, _objectSpread2.default)({}, sectionTransform(section, index), { | ||
variables: currentSectionVariables | ||
}); | ||
} | ||
return { | ||
section: section, | ||
variables: currentSectionVariables | ||
}; | ||
} | ||
}) // get rid of any `undefined` slots | ||
.filter(function (section) { | ||
return section && true; | ||
}); | ||
var orphanVariables = getVariablesWithNoSection(variables, addedVariables); | ||
var orphanVariables = variables.filter(function (v) { | ||
var flattedSectionVariables = mappedSections.reduce(function (acc, o) { | ||
return acc.concat(o.variables); | ||
}, []); | ||
return flattedSectionVariables.indexOf(v) === -1; | ||
}); | ||
if (orphanVariables.length > 0) { | ||
collapsibles.push({ | ||
section: 'Misc.', | ||
mappedSections.push({ | ||
section: getUnsectionedTitle(), | ||
variables: orphanVariables | ||
@@ -46,5 +79,5 @@ }); | ||
return collapsibles; | ||
return mappedSections; | ||
}; | ||
exports.GetSections = GetSections; |
@@ -57,4 +57,4 @@ "use strict"; | ||
value: function generateInput(subVariable) { | ||
var currentValue = this.props.savedValue === '' ? undefined : this.props.savedValue; | ||
var savedValue = this.openLaw.getStructureFieldValue(this.props.variable, subVariable, currentValue, this.props.executionResult); | ||
var savedValueProp = this.props.savedValue === '' ? undefined : this.props.savedValue; | ||
var structureFieldValue = this.openLaw.getStructureFieldValue(this.props.variable, subVariable, savedValueProp, this.props.executionResult); | ||
return React.createElement("div", { | ||
@@ -68,3 +68,3 @@ className: "structure-variable-row", | ||
openLaw: this.openLaw, | ||
savedValue: savedValue, | ||
savedValue: structureFieldValue || '', | ||
textLikeInputClass: this.props.textLikeInputClass, | ||
@@ -71,0 +71,0 @@ variable: subVariable |
@@ -86,15 +86,15 @@ "use strict"; | ||
}, React.createElement("input", { | ||
className: cleanName, | ||
onChange: this.onChange, | ||
name: cleanName, | ||
type: "radio", | ||
onChange: this.onChange, | ||
value: "true", | ||
checked: this.state.currentValue === 'true', | ||
className: cleanName | ||
value: "true" | ||
}), React.createElement("span", null, "Yes")), React.createElement("label", { | ||
className: "radio-label" | ||
}, React.createElement("input", { | ||
className: cleanName, | ||
name: cleanName, | ||
onChange: this.onChange, | ||
type: "radio", | ||
onChange: this.onChange, | ||
value: "false", | ||
checked: this.state.currentValue !== 'true', | ||
className: cleanName | ||
value: "false" | ||
}), React.createElement("span", null, "No")))); | ||
@@ -101,0 +101,0 @@ } |
@@ -156,3 +156,3 @@ import _extends from "@babel/runtime/helpers/extends"; | ||
return React.createElement("div", { | ||
className: 'contract-variable collection-variable' + cleanName | ||
className: "contract-variable collection-variable ".concat(cleanName) | ||
}, React.createElement("div", { | ||
@@ -159,0 +159,0 @@ className: "collection-variable-description" |
@@ -0,2 +1,4 @@ | ||
import _defineProperty from "@babel/runtime/helpers/defineProperty"; | ||
import _objectSpread from "@babel/runtime/helpers/objectSpread"; | ||
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties"; | ||
import * as React from 'react'; | ||
@@ -7,3 +9,2 @@ import { Collection } from './Collection'; | ||
import { Structure } from './Structure'; | ||
import Collapsible from './Collapsible'; | ||
@@ -77,3 +78,13 @@ var renderInputs = function renderInputs(props) { | ||
}), | ||
renderSections: PropTypes.func, | ||
sections: PropTypes.arrayOf(function (props, propName, componentName) { | ||
if (!Object.prototype.hasOwnProperty.call(props, propName)) { | ||
throw new Error("Prop `".concat(propName, "` has type 'any' or 'mixed', but was not provided to `").concat(componentName, "`. Pass undefined or any other value.")); | ||
} | ||
}), | ||
sectionTransform: PropTypes.func, | ||
sectionVariablesMap: PropTypes.func, | ||
textLikeInputClass: PropTypes.string, | ||
triggerDisabled: PropTypes.bool, | ||
unsectionedTitle: PropTypes.string, | ||
variables: PropTypes.arrayOf(PropTypes.shape({}).isRequired), | ||
@@ -83,24 +94,48 @@ variable: PropTypes.shape({}).isRequired | ||
var renderSections = function renderSections(props) { | ||
var renderSectionsAndInputs = function renderSectionsAndInputs(props) { | ||
var executionResult = props.executionResult, | ||
_props$openLaw2 = props.openLaw, | ||
openLaw = _props$openLaw2 === void 0 ? {} : _props$openLaw2, | ||
renderSections = props.renderSections, | ||
sections = props.sections, | ||
sectionTransform = props.sectionTransform, | ||
sectionVariablesMap = props.sectionVariablesMap, | ||
unsectionedTitle = props.unsectionedTitle, | ||
variablesMap = props.variablesMap, | ||
variableObjects = props.variableObjects; | ||
var sectionVariables = openLaw.getVariableSections(executionResult); | ||
var variableNames = variableObjects.map(function (variable) { | ||
return openLaw.getName(variable); | ||
var variableNames = variableObjects.map(function (v) { | ||
return openLaw.getName(v); | ||
}); | ||
return GetSections(variableNames, sectionVariables, sections).map(function (collapsible) { | ||
var section = collapsible.section; | ||
var currentVariables = collapsible.variables.map(function (name) { | ||
var getSectionsConfig = { | ||
sectionTransform: sectionTransform, | ||
sectionVariablesMap: sectionVariablesMap, | ||
unsectionedTitle: unsectionedTitle | ||
}; | ||
return GetSections(variableNames, sectionVariables, sections, getSectionsConfig).map(function (_ref, index) { | ||
var variables = _ref.variables, | ||
sectionData = _objectWithoutProperties(_ref, ["variables"]); | ||
if (renderSections) { | ||
var inputsChildrenComponent = function inputsChildrenComponent() { | ||
return variables.map(function (name) { | ||
return variablesMap[name]; | ||
}).map(function (variable) { | ||
return renderInputs(_objectSpread({ | ||
variable: variable | ||
}, props)); | ||
}); | ||
}; | ||
return renderSections(_objectSpread({ | ||
children: inputsChildrenComponent | ||
}, sectionData)); | ||
} | ||
return React.createElement("div", { | ||
className: "contract-section", | ||
key: "".concat(sectionData.section, "-").concat(index) | ||
}, React.createElement("span", null, sectionData.section), variables.map(function (name) { | ||
return variablesMap[name]; | ||
}); | ||
return React.createElement(Collapsible, { | ||
key: "section-".concat(section), | ||
open: true, | ||
overflowWhenOpen: "visible", | ||
trigger: section | ||
}, currentVariables.map(function (variable) { | ||
}).map(function (variable) { | ||
return renderInputs(_objectSpread({ | ||
@@ -113,3 +148,3 @@ variable: variable | ||
renderSections.propTypes = process.env.NODE_ENV === 'production' ? null : { | ||
renderSectionsAndInputs.propTypes = process.env.NODE_ENV === 'production' ? null : _defineProperty({ | ||
apiClient: PropTypes.object, | ||
@@ -124,11 +159,21 @@ executionResult: PropTypes.shape({}), | ||
}), | ||
renderSections: PropTypes.func, | ||
sections: PropTypes.arrayOf(function (props, propName, componentName) { | ||
if (!Object.prototype.hasOwnProperty.call(props, propName)) { | ||
throw new Error("Prop `".concat(propName, "` has type 'any' or 'mixed', but was not provided to `").concat(componentName, "`. Pass undefined or any other value.")); | ||
} | ||
}), | ||
sectionTransform: PropTypes.func, | ||
sectionVariablesMap: PropTypes.func, | ||
textLikeInputClass: PropTypes.string, | ||
triggerDisabled: PropTypes.bool, | ||
unsectionedTitle: PropTypes.string, | ||
variables: PropTypes.arrayOf(PropTypes.shape({}).isRequired), | ||
variablesMap: PropTypes.objectOf(PropTypes.object.isRequired).isRequired, | ||
variableObjects: PropTypes.arrayOf(PropTypes.object.isRequired).isRequired, | ||
sections: PropTypes.arrayOf(PropTypes.object.isRequired).isRequired | ||
}; | ||
variableObjects: PropTypes.arrayOf(PropTypes.object.isRequired).isRequired | ||
}, "sections", PropTypes.arrayOf(PropTypes.object.isRequired).isRequired); | ||
export var OpenLawForm = function OpenLawForm(props) { | ||
var executionResult = props.executionResult, | ||
openLaw = props.openLaw, | ||
sectionsProp = props.sections, | ||
variables = props.variables; | ||
@@ -139,3 +184,3 @@ var allVariables = openLaw.getVariables(executionResult, {}); | ||
}); | ||
var sections = openLaw.getSections(executionResult); | ||
var sections = sectionsProp ? sectionsProp : openLaw.getSections(executionResult); | ||
var variableObjects = allVariables.filter(function (variable) { | ||
@@ -153,3 +198,3 @@ return openLaw.showInForm(variable, executionResult); | ||
if (sections.length > 0) { | ||
formContent = renderSections(_objectSpread({ | ||
formContent = renderSectionsAndInputs(_objectSpread({ | ||
sections: sections, | ||
@@ -185,5 +230,15 @@ variablesMap: variablesMap, | ||
}), | ||
renderSections: PropTypes.func, | ||
sections: PropTypes.arrayOf(function (props, propName, componentName) { | ||
if (!Object.prototype.hasOwnProperty.call(props, propName)) { | ||
throw new Error("Prop `".concat(propName, "` has type 'any' or 'mixed', but was not provided to `").concat(componentName, "`. Pass undefined or any other value.")); | ||
} | ||
}), | ||
sectionTransform: PropTypes.func, | ||
sectionVariablesMap: PropTypes.func, | ||
textLikeInputClass: PropTypes.string, | ||
triggerDisabled: PropTypes.bool, | ||
unsectionedTitle: PropTypes.string, | ||
variables: PropTypes.arrayOf(PropTypes.shape({}).isRequired) | ||
}; | ||
import PropTypes from "prop-types"; |
@@ -1,34 +0,64 @@ | ||
var getVariablesForSection = function getVariablesForSection(section, variables, sectionVariables, addedVariables) { | ||
return sectionVariables[section].map(function (name) { | ||
return variables.filter(function (variable) { | ||
return variable === name; | ||
})[0]; | ||
}).filter(function (variable) { | ||
return !!variable && addedVariables.indexOf(variable) === -1; | ||
}); | ||
}; | ||
import _objectSpread from "@babel/runtime/helpers/objectSpread"; | ||
import _slicedToArray from "@babel/runtime/helpers/slicedToArray"; | ||
var getVariablesWithNoSection = function getVariablesWithNoSection(variables, addedVariables) { | ||
return variables.filter(function (variable) { | ||
return addedVariables.indexOf(variable) === -1; | ||
var getVariablesForSection = function getVariablesForSection(sectionVariables, variables) { | ||
return sectionVariables.map(function (name) { | ||
return variables[variables.indexOf(name)]; | ||
}) // get rid of any `undefined` slots | ||
.filter(function (section) { | ||
return section && true; | ||
}); | ||
}; | ||
export var GetSections = function GetSections(variables, sectionVariables, sections) { | ||
var addedVariables = []; | ||
var collapsibles = sections.filter(function (section) { | ||
return getVariablesForSection(section, variables, sectionVariables, addedVariables).length > 0; | ||
}).map(function (section) { | ||
var currentVariables = getVariablesForSection(section, variables, sectionVariables, addedVariables); | ||
addedVariables = addedVariables.concat(currentVariables); | ||
return { | ||
section: section, | ||
variables: currentVariables | ||
}; | ||
export var GetSections = function GetSections(variables, sectionVariables, sections, config) { | ||
var getUnsectionedTitle = function getUnsectionedTitle() { | ||
var unsectionedTitle = config.unsectionedTitle; // set to string null value by the user | ||
if (unsectionedTitle === '') return ''; // there's a value set by the user | ||
if (unsectionedTitle) return unsectionedTitle; // default | ||
return 'Miscellaneous'; | ||
}; | ||
var mappedSections = sections.map(function (section, index) { | ||
var sectionTransform = config.sectionTransform, | ||
sectionVariablesMap = config.sectionVariablesMap; | ||
var sectionVariablesFromConfig = sectionVariablesMap && sectionVariablesMap(section, index); | ||
var _ref = sectionVariablesFromConfig ? Object.keys(sectionVariablesFromConfig) : [], | ||
_ref2 = _slicedToArray(_ref, 1), | ||
userSectionKey = _ref2[0]; | ||
var currentSectionVariables = sectionVariablesFromConfig && Object.keys(sectionVariablesFromConfig).length ? // user provided an object with the same shape via props | ||
getVariablesForSection(sectionVariablesFromConfig[userSectionKey], variables) // normal | ||
: getVariablesForSection(sectionVariables[section], variables); | ||
if (currentSectionVariables.length) { | ||
// user has a desired section data shape for display purposes | ||
if (sectionTransform) { | ||
return _objectSpread({}, sectionTransform(section, index), { | ||
variables: currentSectionVariables | ||
}); | ||
} | ||
return { | ||
section: section, | ||
variables: currentSectionVariables | ||
}; | ||
} | ||
}) // get rid of any `undefined` slots | ||
.filter(function (section) { | ||
return section && true; | ||
}); | ||
var orphanVariables = getVariablesWithNoSection(variables, addedVariables); | ||
var orphanVariables = variables.filter(function (v) { | ||
var flattedSectionVariables = mappedSections.reduce(function (acc, o) { | ||
return acc.concat(o.variables); | ||
}, []); | ||
return flattedSectionVariables.indexOf(v) === -1; | ||
}); | ||
if (orphanVariables.length > 0) { | ||
collapsibles.push({ | ||
section: 'Misc.', | ||
mappedSections.push({ | ||
section: getUnsectionedTitle(), | ||
variables: orphanVariables | ||
@@ -38,3 +68,3 @@ }); | ||
return collapsibles; | ||
return mappedSections; | ||
}; |
@@ -40,4 +40,4 @@ import _classCallCheck from "@babel/runtime/helpers/classCallCheck"; | ||
value: function generateInput(subVariable) { | ||
var currentValue = this.props.savedValue === '' ? undefined : this.props.savedValue; | ||
var savedValue = this.openLaw.getStructureFieldValue(this.props.variable, subVariable, currentValue, this.props.executionResult); | ||
var savedValueProp = this.props.savedValue === '' ? undefined : this.props.savedValue; | ||
var structureFieldValue = this.openLaw.getStructureFieldValue(this.props.variable, subVariable, savedValueProp, this.props.executionResult); | ||
return React.createElement("div", { | ||
@@ -51,3 +51,3 @@ className: "structure-variable-row", | ||
openLaw: this.openLaw, | ||
savedValue: savedValue, | ||
savedValue: structureFieldValue || '', | ||
textLikeInputClass: this.props.textLikeInputClass, | ||
@@ -54,0 +54,0 @@ variable: subVariable |
@@ -70,15 +70,15 @@ import _classCallCheck from "@babel/runtime/helpers/classCallCheck"; | ||
}, React.createElement("input", { | ||
className: cleanName, | ||
onChange: this.onChange, | ||
name: cleanName, | ||
type: "radio", | ||
onChange: this.onChange, | ||
value: "true", | ||
checked: this.state.currentValue === 'true', | ||
className: cleanName | ||
value: "true" | ||
}), React.createElement("span", null, "Yes")), React.createElement("label", { | ||
className: "radio-label" | ||
}, React.createElement("input", { | ||
className: cleanName, | ||
name: cleanName, | ||
onChange: this.onChange, | ||
type: "radio", | ||
onChange: this.onChange, | ||
value: "false", | ||
checked: this.state.currentValue !== 'true', | ||
className: cleanName | ||
value: "false" | ||
}), React.createElement("span", null, "No")))); | ||
@@ -85,0 +85,0 @@ } |
{ | ||
"name": "openlaw-elements", | ||
"version": "1.0.0-beta.4", | ||
"version": "1.0.0-beta.5", | ||
"description": "Dynamically render React form components from an OpenLaw template.", | ||
@@ -5,0 +5,0 @@ "author": "OpenLaw Team <opensource@openlaw.io>", |
@@ -71,2 +71,5 @@ # OpenLaw Elements | ||
textLikeInputClass="input" | ||
// Optional: This will disable collapsible behavior on Collapsible elements when true | ||
// https://docs.openlaw.io/markup-language/#groupings | ||
triggerDisabled={false} | ||
variables={variables} | ||
@@ -73,0 +76,0 @@ /> |
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 not supported yet
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 not supported yet
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 not supported yet
Sorry, the diff of this file is too big to display
116
36
436567
52
5160