Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-bsonschema-form

Package Overview
Dependencies
Maintainers
1
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-bsonschema-form - npm Package Compare versions

Comparing version 0.40.7 to 0.41.1

lib/components/fields/index.js

221

lib/components/fields/ArrayField.js

@@ -28,6 +28,6 @@ "use strict";

function ArrayFieldTitle(_ref) {
var TitleField = _ref.TitleField;
var idSchema = _ref.idSchema;
var title = _ref.title;
var required = _ref.required;
var TitleField = _ref.TitleField,
idSchema = _ref.idSchema,
title = _ref.title,
required = _ref.required;

@@ -43,5 +43,5 @@ if (!title) {

function ArrayFieldDescription(_ref2) {
var DescriptionField = _ref2.DescriptionField;
var idSchema = _ref2.idSchema;
var description = _ref2.description;
var DescriptionField = _ref2.DescriptionField,
idSchema = _ref2.idSchema,
description = _ref2.description;

@@ -57,9 +57,8 @@ if (!description) {

function IconBtn(props) {
var _props$type = props.type;
var type = _props$type === undefined ? "default" : _props$type;
var icon = props.icon;
var className = props.className;
var _props$type = props.type,
type = _props$type === undefined ? "default" : _props$type,
icon = props.icon,
className = props.className,
otherProps = _objectWithoutProperties(props, ["type", "icon", "className"]);
var otherProps = _objectWithoutProperties(props, ["type", "icon", "className"]);
return _react2.default.createElement(

@@ -83,5 +82,5 @@ "button",

var items = _this.state.items;
var _this$props = _this.props;
var schema = _this$props.schema;
var registry = _this$props.registry;
var _this$props = _this.props,
schema = _this$props.schema,
registry = _this$props.registry;
var definitions = registry.definitions;

@@ -177,3 +176,3 @@

var options = arguments.length <= 1 || arguments[1] === undefined ? { validate: false } : arguments[1];
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { validate: false };

@@ -187,5 +186,5 @@ (0, _utils.setState)(this, state, function () {

value: function render() {
var _props = this.props;
var schema = _props.schema;
var uiSchema = _props.uiSchema;
var _props = this.props,
schema = _props.schema,
uiSchema = _props.uiSchema;

@@ -208,30 +207,27 @@ if ((0, _utils.isFilesArray)(schema, uiSchema)) {

var _props2 = this.props;
var schema = _props2.schema;
var uiSchema = _props2.uiSchema;
var errorSchema = _props2.errorSchema;
var idSchema = _props2.idSchema;
var name = _props2.name;
var required = _props2.required;
var disabled = _props2.disabled;
var readonly = _props2.readonly;
var autofocus = _props2.autofocus;
var _props2 = this.props,
schema = _props2.schema,
uiSchema = _props2.uiSchema,
errorSchema = _props2.errorSchema,
idSchema = _props2.idSchema,
name = _props2.name,
required = _props2.required,
disabled = _props2.disabled,
readonly = _props2.readonly,
autofocus = _props2.autofocus;
var title = schema.title === undefined ? name : schema.title;
var items = this.state.items;
var _props$registry = this.props.registry;
var definitions = _props$registry.definitions;
var fields = _props$registry.fields;
var TitleField = fields.TitleField;
var DescriptionField = fields.DescriptionField;
var _props$registry = this.props.registry,
definitions = _props$registry.definitions,
fields = _props$registry.fields;
var TitleField = fields.TitleField,
DescriptionField = fields.DescriptionField;
var itemsSchema = (0, _utils.retrieveSchema)(schema.items, definitions);
var _addable$uiSchema$ui = _extends({
addable: true
}, uiSchema["ui:options"]);
var _getUiOptions = (0, _utils.getUiOptions)(uiSchema),
_getUiOptions$addable = _getUiOptions.addable,
addable = _getUiOptions$addable === undefined ? true : _getUiOptions$addable;
var addable = _addable$uiSchema$ui.addable;
return _react2.default.createElement(

@@ -278,17 +274,23 @@ "fieldset",

value: function renderMultiSelect() {
var _props3 = this.props;
var schema = _props3.schema;
var idSchema = _props3.idSchema;
var uiSchema = _props3.uiSchema;
var disabled = _props3.disabled;
var readonly = _props3.readonly;
var autofocus = _props3.autofocus;
var _props3 = this.props,
schema = _props3.schema,
idSchema = _props3.idSchema,
uiSchema = _props3.uiSchema,
disabled = _props3.disabled,
readonly = _props3.readonly,
autofocus = _props3.autofocus;
var items = this.state.items;
var _props$registry2 = this.props.registry;
var widgets = _props$registry2.widgets;
var definitions = _props$registry2.definitions;
var _props$registry2 = this.props.registry,
widgets = _props$registry2.widgets,
definitions = _props$registry2.definitions;
var itemsSchema = (0, _utils.retrieveSchema)(schema.items, definitions);
var enumOptions = (0, _utils.optionsList)(itemsSchema);
var Widget = (0, _utils.getAlternativeWidget)(schema, uiSchema["ui:widget"] || "select", widgets);
var _getUiOptions$enumOpt = _extends({}, (0, _utils.getUiOptions)(uiSchema), { enumOptions: enumOptions }),
_getUiOptions$enumOpt2 = _getUiOptions$enumOpt.widget,
widget = _getUiOptions$enumOpt2 === undefined ? "select" : _getUiOptions$enumOpt2,
options = _objectWithoutProperties(_getUiOptions$enumOpt, ["widget"]);
var Widget = (0, _utils.getWidget)(schema, widget, widgets);
return _react2.default.createElement(Widget, {

@@ -298,5 +300,3 @@ id: idSchema && idSchema.$id,

onChange: this.onSelectChange,
options: _extends({}, Widget.defaultProps.options, {
enumOptions: (0, _utils.optionsList)(itemsSchema)
}),
options: options,
schema: schema,

@@ -311,15 +311,23 @@ value: items,

value: function renderFiles() {
var _props4 = this.props;
var schema = _props4.schema;
var idSchema = _props4.idSchema;
var name = _props4.name;
var disabled = _props4.disabled;
var readonly = _props4.readonly;
var autofocus = _props4.autofocus;
var _props4 = this.props,
schema = _props4.schema,
uiSchema = _props4.uiSchema,
idSchema = _props4.idSchema,
name = _props4.name,
disabled = _props4.disabled,
readonly = _props4.readonly,
autofocus = _props4.autofocus;
var title = schema.title || name;
var items = this.state.items;
var FileWidget = this.props.registry.widgets.FileWidget;
var widgets = this.props.registry.widgets;
return _react2.default.createElement(FileWidget, {
var _getUiOptions2 = (0, _utils.getUiOptions)(uiSchema),
_getUiOptions2$widget = _getUiOptions2.widget,
widget = _getUiOptions2$widget === undefined ? "files" : _getUiOptions2$widget,
options = _objectWithoutProperties(_getUiOptions2, ["widget"]);
var Widget = (0, _utils.getWidget)(schema, widget, widgets);
return _react2.default.createElement(Widget, {
options: options,
id: idSchema && idSchema.$id,

@@ -340,18 +348,18 @@ multiple: true,

var _props5 = this.props;
var schema = _props5.schema;
var uiSchema = _props5.uiSchema;
var errorSchema = _props5.errorSchema;
var idSchema = _props5.idSchema;
var name = _props5.name;
var required = _props5.required;
var disabled = _props5.disabled;
var readonly = _props5.readonly;
var autofocus = _props5.autofocus;
var _props5 = this.props,
schema = _props5.schema,
uiSchema = _props5.uiSchema,
errorSchema = _props5.errorSchema,
idSchema = _props5.idSchema,
name = _props5.name,
required = _props5.required,
disabled = _props5.disabled,
readonly = _props5.readonly,
autofocus = _props5.autofocus;
var title = schema.title || name;
var items = this.state.items;
var _props$registry3 = this.props.registry;
var definitions = _props$registry3.definitions;
var fields = _props$registry3.fields;
var _props$registry3 = this.props.registry,
definitions = _props$registry3.definitions,
fields = _props$registry3.fields;
var TitleField = fields.TitleField;

@@ -364,8 +372,6 @@

var _addable$uiSchema$ui2 = _extends({
addable: true
}, uiSchema["ui:options"]);
var _getUiOptions3 = (0, _utils.getUiOptions)(uiSchema),
_getUiOptions3$addabl = _getUiOptions3.addable,
addable = _getUiOptions3$addabl === undefined ? true : _getUiOptions3$addabl;
var addable = _addable$uiSchema$ui2.addable;
var canAdd = addable && additionalSchema;

@@ -425,20 +431,20 @@

value: function renderArrayFieldItem(_ref3) {
var index = _ref3.index;
var _ref3$canRemove = _ref3.canRemove;
var canRemove = _ref3$canRemove === undefined ? true : _ref3$canRemove;
var _ref3$canMoveUp = _ref3.canMoveUp;
var canMoveUp = _ref3$canMoveUp === undefined ? true : _ref3$canMoveUp;
var _ref3$canMoveDown = _ref3.canMoveDown;
var canMoveDown = _ref3$canMoveDown === undefined ? true : _ref3$canMoveDown;
var itemSchema = _ref3.itemSchema;
var itemData = _ref3.itemData;
var itemUiSchema = _ref3.itemUiSchema;
var itemIdSchema = _ref3.itemIdSchema;
var itemErrorSchema = _ref3.itemErrorSchema;
var autofocus = _ref3.autofocus;
var index = _ref3.index,
_ref3$canRemove = _ref3.canRemove,
canRemove = _ref3$canRemove === undefined ? true : _ref3$canRemove,
_ref3$canMoveUp = _ref3.canMoveUp,
canMoveUp = _ref3$canMoveUp === undefined ? true : _ref3$canMoveUp,
_ref3$canMoveDown = _ref3.canMoveDown,
canMoveDown = _ref3$canMoveDown === undefined ? true : _ref3$canMoveDown,
itemSchema = _ref3.itemSchema,
itemData = _ref3.itemData,
itemUiSchema = _ref3.itemUiSchema,
itemIdSchema = _ref3.itemIdSchema,
itemErrorSchema = _ref3.itemErrorSchema,
autofocus = _ref3.autofocus;
var SchemaField = this.props.registry.fields.SchemaField;
var _props6 = this.props;
var disabled = _props6.disabled;
var readonly = _props6.readonly;
var uiSchema = _props6.uiSchema;
var _props6 = this.props,
disabled = _props6.disabled,
readonly = _props6.readonly,
uiSchema = _props6.uiSchema;

@@ -448,7 +454,6 @@ var _orderable$removable$ = _extends({

removable: true
}, uiSchema["ui:options"]);
}, uiSchema["ui:options"]),
orderable = _orderable$removable$.orderable,
removable = _orderable$removable$.removable;
var orderable = _orderable$removable$.orderable;
var removable = _orderable$removable$.removable;
var has = {

@@ -532,4 +537,4 @@ moveUp: orderable && canMoveUp,

function AddButton(_ref4) {
var onClick = _ref4.onClick;
var disabled = _ref4.disabled;
var onClick = _ref4.onClick,
disabled = _ref4.disabled;

@@ -543,3 +548,3 @@ return _react2.default.createElement(

_react2.default.createElement(IconBtn, { type: "info", icon: "plus", className: "btn-add col-xs-12",
tabIndex: "-1", onClick: onClick,
tabIndex: "0", onClick: onClick,
disabled: disabled })

@@ -555,3 +560,5 @@ )

"ui:options": _react.PropTypes.shape({
orderable: _react.PropTypes.bool
addable: _react.PropTypes.bool,
orderable: _react.PropTypes.bool,
removable: _react.PropTypes.bool
})

@@ -558,0 +565,0 @@ }),

@@ -17,32 +17,32 @@ "use strict";

function buildOptions(schema, uiWidget) {
// Note: uiWidget can be undefined, a string or an object; we only deal with
// the inline option when we're provided a definition object.
return {
inline: (0, _utils.isObject)(uiWidget) && (0, _utils.isObject)(uiWidget.options) && uiWidget.options.inline,
enumOptions: (0, _utils.optionsList)(Object.assign({
enumNames: ["true", "false"],
enum: [true, false]
}, { enumNames: schema.enumNames }))
};
}
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
function BooleanField(props) {
var schema = props.schema;
var name = props.name;
var uiSchema = props.uiSchema;
var idSchema = props.idSchema;
var formData = props.formData;
var registry = props.registry;
var required = props.required;
var disabled = props.disabled;
var readonly = props.readonly;
var autofocus = props.autofocus;
var onChange = props.onChange;
var schema = props.schema,
name = props.name,
uiSchema = props.uiSchema,
idSchema = props.idSchema,
formData = props.formData,
registry = props.registry,
required = props.required,
disabled = props.disabled,
readonly = props.readonly,
autofocus = props.autofocus,
onChange = props.onChange;
var title = schema.title;
var widgets = registry.widgets;
var formContext = registry.formContext;
var widgets = registry.widgets,
formContext = registry.formContext;
var widget = uiSchema["ui:widget"];
var commonProps = {
var _getUiOptions = (0, _utils.getUiOptions)(uiSchema),
_getUiOptions$widget = _getUiOptions.widget,
widget = _getUiOptions$widget === undefined ? "checkbox" : _getUiOptions$widget,
options = _objectWithoutProperties(_getUiOptions, ["widget"]);
var Widget = (0, _utils.getWidget)(schema, widget, widgets);
var enumOptions = (0, _utils.optionsList)({
enum: [true, false],
enumNames: schema.enumNames || ["yes", "no"]
});
return _react2.default.createElement(Widget, {
options: _extends({}, options, { enumOptions: enumOptions }),
schema: schema,

@@ -58,11 +58,3 @@ id: idSchema && idSchema.$id,

formContext: formContext,
autofocus: autofocus
};
if (widget) {
var Widget = (0, _utils.getAlternativeWidget)(schema, widget, widgets);
return _react2.default.createElement(Widget, _extends({ options: buildOptions(schema, uiSchema["ui:widget"]) }, commonProps));
}
var CheckboxWidget = registry.widgets.CheckboxWidget;
return _react2.default.createElement(CheckboxWidget, commonProps);
autofocus: autofocus });
}

@@ -69,0 +61,0 @@

@@ -1,2 +0,2 @@

"use strict";
'use strict';

@@ -9,39 +9,51 @@ Object.defineProperty(exports, "__esModule", {

var _react = require("react");
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _reactDatetime = require("react-datetime");
var _reactDatetime = require('react-datetime');
var _reactDatetime2 = _interopRequireDefault(_reactDatetime);
var _BaseInput = require("../widgets/BaseInput");
var _moment = require('moment');
var _moment2 = _interopRequireDefault(_moment);
var _BaseInput = require('../widgets/BaseInput');
var _BaseInput2 = _interopRequireDefault(_BaseInput);
require("react-datetime/css/react-datetime.css");
require('react-datetime/css/react-datetime.css');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function cleanValue(value) {
if (!value) {
return undefined;
} else if (typeof value.toDate === 'function') {
return value.toDate();
} else {
return value;
}
}
function DateField(props) {
var _onChange = props.onChange;
var formData = props.formData;
var _onChange = props.onChange,
formData = props.formData,
readonly = props.readonly,
disabled = props.disabled;
var StringField = props.registry.fields.StringField;
var cleanValue = function cleanValue(value) {
if (!value) {
return undefined;
} else if (typeof value.toDate === 'function') {
return value.toDate();
} else {
return value;
}
};
return _react2.default.createElement(_reactDatetime2.default, _extends({}, props, {
value: formData,
onChange: function onChange(value) {
return _onChange(cleanValue(value));
}
}));
if (readonly || disabled) {
return _react2.default.createElement(StringField, _extends({}, props, {
formData: formData && (0, _moment2.default)(formData).format('L LT') }));
} else {
return _react2.default.createElement(_reactDatetime2.default, _extends({}, props, {
value: formData,
onChange: function onChange(value) {
return _onChange(cleanValue(value));
}
}));
}
}

@@ -48,0 +60,0 @@

@@ -14,4 +14,4 @@ "use strict";

function DescriptionField(props) {
var id = props.id;
var description = props.description;
var id = props.id,
description = props.description;

@@ -18,0 +18,0 @@ if (!description) {

@@ -25,5 +25,5 @@ "use strict";

var Int32 = _bson2.default.Int32;
var BSON_INT32_MAX = _bson2.default.BSON_INT32_MAX;
var BSON_INT32_MIN = _bson2.default.BSON_INT32_MIN;
var Int32 = _bson2.default.Int32,
BSON_INT32_MAX = _bson2.default.BSON_INT32_MAX,
BSON_INT32_MIN = _bson2.default.BSON_INT32_MIN;

@@ -30,0 +30,0 @@

@@ -25,5 +25,5 @@ "use strict";

var Long = _bson2.default.Long;
var BSON_INT64_MAX = _bson2.default.BSON_INT64_MAX;
var BSON_INT64_MIN = _bson2.default.BSON_INT64_MIN;
var Long = _bson2.default.Long,
BSON_INT64_MAX = _bson2.default.BSON_INT64_MAX,
BSON_INT64_MIN = _bson2.default.BSON_INT64_MIN;

@@ -30,0 +30,0 @@

@@ -75,5 +75,5 @@ "use strict";

value: function getStateFromProps(props) {
var schema = props.schema;
var formData = props.formData;
var registry = props.registry;
var schema = props.schema,
formData = props.formData,
registry = props.registry;

@@ -98,3 +98,3 @@ return (0, _utils.getDefaultFormState)(schema, formData, registry.definitions) || {};

var options = arguments.length <= 1 || arguments[1] === undefined ? { validate: false } : arguments[1];
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { validate: false };

@@ -110,17 +110,17 @@ (0, _utils.setState)(this, state, function () {

var _props = this.props;
var uiSchema = _props.uiSchema;
var errorSchema = _props.errorSchema;
var idSchema = _props.idSchema;
var name = _props.name;
var required = _props.required;
var disabled = _props.disabled;
var readonly = _props.readonly;
var _props$registry = this.props.registry;
var definitions = _props$registry.definitions;
var fields = _props$registry.fields;
var formContext = _props$registry.formContext;
var SchemaField = fields.SchemaField;
var TitleField = fields.TitleField;
var DescriptionField = fields.DescriptionField;
var _props = this.props,
uiSchema = _props.uiSchema,
errorSchema = _props.errorSchema,
idSchema = _props.idSchema,
name = _props.name,
required = _props.required,
disabled = _props.disabled,
readonly = _props.readonly;
var _props$registry = this.props.registry,
definitions = _props$registry.definitions,
fields = _props$registry.fields,
formContext = _props$registry.formContext;
var SchemaField = fields.SchemaField,
TitleField = fields.TitleField,
DescriptionField = fields.DescriptionField;

@@ -127,0 +127,0 @@ var schema = (0, _utils.retrieveSchema)(this.props.schema, definitions);

@@ -21,2 +21,4 @@ "use strict";

function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
var REQUIRED_FIELD_SYMBOL = "*";

@@ -31,4 +33,4 @@ var COMPONENT_TYPES = {

// bson specific fields
bool: "BooleanField",
objectId: "ObjectIdField",
bool: "BooleanField",
date: "DateField",

@@ -53,5 +55,5 @@ int: "IntField",

function Label(props) {
var label = props.label;
var required = props.required;
var id = props.id;
var label = props.label,
required = props.required,
id = props.id;

@@ -91,4 +93,4 @@ if (!label) {

function ErrorList(props) {
var _props$errors = props.errors;
var errors = _props$errors === undefined ? [] : _props$errors;
var _props$errors = props.errors,
errors = _props$errors === undefined ? [] : _props$errors;

@@ -117,12 +119,12 @@ if (errors.length === 0) {

function DefaultTemplate(props) {
var id = props.id;
var classNames = props.classNames;
var label = props.label;
var children = props.children;
var errors = props.errors;
var help = props.help;
var description = props.description;
var hidden = props.hidden;
var required = props.required;
var displayLabel = props.displayLabel;
var id = props.id,
classNames = props.classNames,
label = props.label,
children = props.children,
errors = props.errors,
help = props.help,
description = props.description,
hidden = props.hidden,
required = props.required,
displayLabel = props.displayLabel;

@@ -153,5 +155,5 @@ if (hidden) {

help: _react.PropTypes.element,
rawHelp: _react.PropTypes.string,
rawHelp: _react.PropTypes.oneOfType([_react.PropTypes.string, _react.PropTypes.element]),
description: _react.PropTypes.element,
rawDescription: _react.PropTypes.string,
rawDescription: _react.PropTypes.oneOfType([_react.PropTypes.string, _react.PropTypes.element]),
hidden: _react.PropTypes.bool,

@@ -174,13 +176,13 @@ required: _react.PropTypes.bool,

function SchemaField(props) {
var uiSchema = props.uiSchema;
var errorSchema = props.errorSchema;
var idSchema = props.idSchema;
var name = props.name;
var required = props.required;
var registry = props.registry;
var definitions = registry.definitions;
var fields = registry.fields;
var formContext = registry.formContext;
var _registry$FieldTempla = registry.FieldTemplate;
var FieldTemplate = _registry$FieldTempla === undefined ? DefaultTemplate : _registry$FieldTempla;
var uiSchema = props.uiSchema,
errorSchema = props.errorSchema,
idSchema = props.idSchema,
name = props.name,
required = props.required,
registry = props.registry;
var definitions = registry.definitions,
fields = registry.fields,
formContext = registry.formContext,
_registry$FieldTempla = registry.FieldTemplate,
FieldTemplate = _registry$FieldTempla === undefined ? DefaultTemplate : _registry$FieldTempla;

@@ -214,2 +216,5 @@ var schema = (0, _utils.retrieveSchema)(props.schema, definitions);

var __errors = errorSchema.__errors,
fieldErrorSchema = _objectWithoutProperties(errorSchema, ["__errors"]);
var field = _react2.default.createElement(FieldComponent, _extends({}, props, {

@@ -220,2 +225,3 @@ schema: schema,

autofocus: autofocus,
errorSchema: fieldErrorSchema,
formContext: formContext }));

@@ -228,3 +234,3 @@

var description = props.schema.description || schema.description;
var errors = errorSchema.__errors;
var errors = __errors;
var help = uiSchema["ui:help"];

@@ -251,3 +257,5 @@ var hidden = uiSchema["ui:widget"] === "hidden";

formContext: formContext,
fields: fields
fields: fields,
schema: schema,
uiSchema: uiSchema
};

@@ -254,0 +262,0 @@

@@ -17,21 +17,35 @@ "use strict";

function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
function StringField(props) {
var schema = props.schema;
var name = props.name;
var uiSchema = props.uiSchema;
var idSchema = props.idSchema;
var formData = props.formData;
var registry = props.registry;
var required = props.required;
var disabled = props.disabled;
var readonly = props.readonly;
var autofocus = props.autofocus;
var onChange = props.onChange;
var title = schema.title;
var widgets = registry.widgets;
var formContext = registry.formContext;
var schema = props.schema,
name = props.name,
uiSchema = props.uiSchema,
idSchema = props.idSchema,
formData = props.formData,
required = props.required,
disabled = props.disabled,
readonly = props.readonly,
autofocus = props.autofocus,
registry = props.registry,
onChange = props.onChange;
var title = schema.title,
format = schema.format;
var widgets = registry.widgets,
formContext = registry.formContext;
var widget = uiSchema["ui:widget"] || schema.format;
var placeholder = uiSchema["ui:placeholder"] || "";
var commonProps = {
var enumOptions = Array.isArray(schema.enum) && (0, _utils.optionsList)(schema);
var defaultWidget = format || (enumOptions ? "select" : "text");
var _getUiOptions = (0, _utils.getUiOptions)(uiSchema),
_getUiOptions$widget = _getUiOptions.widget,
widget = _getUiOptions$widget === undefined ? defaultWidget : _getUiOptions$widget,
_getUiOptions$placeho = _getUiOptions.placeholder,
placeholder = _getUiOptions$placeho === undefined ? "" : _getUiOptions$placeho,
options = _objectWithoutProperties(_getUiOptions, ["widget", "placeholder"]);
var Widget = (0, _utils.getWidget)(schema, widget, widgets);
return _react2.default.createElement(Widget, {
options: _extends({}, options, { enumOptions: enumOptions }),
schema: schema,

@@ -47,22 +61,4 @@ id: idSchema && idSchema.$id,

autofocus: autofocus,
registry: registry
};
var TextWidget = widgets.TextWidget;
var SelectWidget = widgets.SelectWidget;
if (Array.isArray(schema.enum)) {
var enumOptions = (0, _utils.optionsList)(schema);
if (widget) {
var Widget = (0, _utils.getAlternativeWidget)(schema, widget, widgets, { enumOptions: enumOptions });
return _react2.default.createElement(Widget, commonProps);
}
return _react2.default.createElement(SelectWidget, _extends({ options: { enumOptions: enumOptions } }, commonProps));
}
if (widget) {
var _Widget = (0, _utils.getAlternativeWidget)(schema, widget, widgets);
return _react2.default.createElement(_Widget, _extends({}, commonProps, { placeholder: placeholder }));
}
return _react2.default.createElement(TextWidget, _extends({}, commonProps, { placeholder: placeholder }));
registry: registry,
placeholder: placeholder });
}

@@ -69,0 +65,0 @@

@@ -16,5 +16,5 @@ "use strict";

function TitleField(props) {
var id = props.id;
var title = props.title;
var required = props.required;
var id = props.id,
title = props.title,
required = props.required;

@@ -21,0 +21,0 @@ var legend = required ? title + REQUIRED_FIELD_SYMBOL : title;

@@ -7,3 +7,3 @@ "use strict";

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };

@@ -18,126 +18,2 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

var _SchemaField2 = require("./fields/SchemaField");
var _SchemaField3 = _interopRequireDefault(_SchemaField2);
var _ArrayField = require("./fields/ArrayField");
var _ArrayField2 = _interopRequireDefault(_ArrayField);
var _ObjectField = require("./fields/ObjectField");
var _ObjectField2 = _interopRequireDefault(_ObjectField);
var _StringField = require("./fields/StringField");
var _StringField2 = _interopRequireDefault(_StringField);
var _NumberField = require("./fields/NumberField");
var _NumberField2 = _interopRequireDefault(_NumberField);
var _TitleField = require("./fields/TitleField");
var _TitleField2 = _interopRequireDefault(_TitleField);
var _DescriptionField = require("./fields/DescriptionField");
var _DescriptionField2 = _interopRequireDefault(_DescriptionField);
var _ObjectIdField = require("./fields/ObjectIdField");
var _ObjectIdField2 = _interopRequireDefault(_ObjectIdField);
var _BooleanField = require("./fields/BooleanField");
var _BooleanField2 = _interopRequireDefault(_BooleanField);
var _DateField = require("./fields/DateField");
var _DateField2 = _interopRequireDefault(_DateField);
var _IntField = require("./fields/IntField");
var _IntField2 = _interopRequireDefault(_IntField);
var _LongField = require("./fields/LongField");
var _LongField2 = _interopRequireDefault(_LongField);
var _DoubleField = require("./fields/DoubleField");
var _DoubleField2 = _interopRequireDefault(_DoubleField);
var _PasswordWidget = require("./widgets/PasswordWidget");
var _PasswordWidget2 = _interopRequireDefault(_PasswordWidget);
var _RadioWidget = require("./widgets/RadioWidget");
var _RadioWidget2 = _interopRequireDefault(_RadioWidget);
var _UpDownWidget = require("./widgets/UpDownWidget");
var _UpDownWidget2 = _interopRequireDefault(_UpDownWidget);
var _RangeWidget = require("./widgets/RangeWidget");
var _RangeWidget2 = _interopRequireDefault(_RangeWidget);
var _SelectWidget = require("./widgets/SelectWidget");
var _SelectWidget2 = _interopRequireDefault(_SelectWidget);
var _TextWidget = require("./widgets/TextWidget");
var _TextWidget2 = _interopRequireDefault(_TextWidget);
var _DateWidget = require("./widgets/DateWidget");
var _DateWidget2 = _interopRequireDefault(_DateWidget);
var _DateTimeWidget = require("./widgets/DateTimeWidget");
var _DateTimeWidget2 = _interopRequireDefault(_DateTimeWidget);
var _AltDateWidget = require("./widgets/AltDateWidget");
var _AltDateWidget2 = _interopRequireDefault(_AltDateWidget);
var _AltDateTimeWidget = require("./widgets/AltDateTimeWidget");
var _AltDateTimeWidget2 = _interopRequireDefault(_AltDateTimeWidget);
var _EmailWidget = require("./widgets/EmailWidget");
var _EmailWidget2 = _interopRequireDefault(_EmailWidget);
var _URLWidget = require("./widgets/URLWidget");
var _URLWidget2 = _interopRequireDefault(_URLWidget);
var _TextareaWidget = require("./widgets/TextareaWidget");
var _TextareaWidget2 = _interopRequireDefault(_TextareaWidget);
var _HiddenWidget = require("./widgets/HiddenWidget");
var _HiddenWidget2 = _interopRequireDefault(_HiddenWidget);
var _ColorWidget = require("./widgets/ColorWidget");
var _ColorWidget2 = _interopRequireDefault(_ColorWidget);
var _FileWidget = require("./widgets/FileWidget");
var _FileWidget2 = _interopRequireDefault(_FileWidget);
var _CheckboxWidget = require("./widgets/CheckboxWidget");
var _CheckboxWidget2 = _interopRequireDefault(_CheckboxWidget);
var _CheckboxesWidget = require("./widgets/CheckboxesWidget");
var _CheckboxesWidget2 = _interopRequireDefault(_CheckboxesWidget);
var _ErrorList = require("./ErrorList");

@@ -160,52 +36,3 @@

function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
// bson specific fields
(function initializeDefaultRegistry() {
var fields = {
SchemaField: _SchemaField3.default,
ArrayField: _ArrayField2.default,
BooleanField: _BooleanField2.default,
ObjectField: _ObjectField2.default,
StringField: _StringField2.default,
NumberField: _NumberField2.default,
TitleField: _TitleField2.default,
DescriptionField: _DescriptionField2.default,
// bson specific fields
ObjectIdField: _ObjectIdField2.default,
DateField: _DateField2.default,
IntField: _IntField2.default,
LongField: _LongField2.default,
DoubleField: _DoubleField2.default
};
var widgets = {
PasswordWidget: _PasswordWidget2.default,
RadioWidget: _RadioWidget2.default,
UpDownWidget: _UpDownWidget2.default,
RangeWidget: _RangeWidget2.default,
SelectWidget: _SelectWidget2.default,
TextWidget: _TextWidget2.default,
DateWidget: _DateWidget2.default,
DateTimeWidget: _DateTimeWidget2.default,
AltDateWidget: _AltDateWidget2.default,
AltDateTimeWidget: _AltDateTimeWidget2.default,
EmailWidget: _EmailWidget2.default,
URLWidget: _URLWidget2.default,
TextareaWidget: _TextareaWidget2.default,
HiddenWidget: _HiddenWidget2.default,
ColorWidget: _ColorWidget2.default,
FileWidget: _FileWidget2.default,
CheckboxWidget: _CheckboxWidget2.default,
CheckboxesWidget: _CheckboxesWidget2.default
};
Object.assign((0, _utils.getDefaultRegistry)(), {
fields: fields,
widgets: widgets,
definitions: {},
formContext: {}
});
})();
var Form = function (_Component) {

@@ -220,3 +47,3 @@ _inherits(Form, _Component);

_this.onChange = function (formData) {
var options = arguments.length <= 1 || arguments[1] === undefined ? { validate: false } : arguments[1];
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : { validate: false };

@@ -226,7 +53,6 @@ var mustValidate = !_this.props.noValidate && (_this.props.liveValidate || options.validate);

if (mustValidate) {
var _this$validate = _this.validate(formData);
var _this$validate = _this.validate(formData),
errors = _this$validate.errors,
errorSchema = _this$validate.errorSchema;
var errors = _this$validate.errors;
var errorSchema = _this$validate.errorSchema;
state = _extends({}, state, { errors: errors, errorSchema: errorSchema });

@@ -247,7 +73,6 @@ }

var _ret = function () {
var _this$validate2 = _this.validate(_this.state.formData);
var _this$validate2 = _this.validate(_this.state.formData),
errors = _this$validate2.errors,
errorSchema = _this$validate2.errorSchema;
var errors = _this$validate2.errors;
var errorSchema = _this$validate2.errorSchema;
if (Object.keys(errors).length > 0) {

@@ -301,7 +126,6 @@ (0, _utils.setState)(_this, { errors: errors, errorSchema: errorSchema }, function () {

errorSchema: state.errorSchema || {}
};
},
errors = _ref.errors,
errorSchema = _ref.errorSchema;
var errors = _ref.errors;
var errorSchema = _ref.errorSchema;
var idSchema = (0, _utils.toIdSchema)(schema, uiSchema["ui:rootFieldId"], definitions);

@@ -334,5 +158,5 @@ return {

value: function renderErrors() {
var _state = this.state;
var status = _state.status;
var errors = _state.errors;
var _state = this.state,
status = _state.status,
errors = _state.errors;
var showErrorList = this.props.showErrorList;

@@ -351,7 +175,6 @@

// the "fields" registry one.
var _getDefaultRegistry = (0, _utils.getDefaultRegistry)();
var _getDefaultRegistry = (0, _utils.getDefaultRegistry)(),
fields = _getDefaultRegistry.fields,
widgets = _getDefaultRegistry.widgets;
var fields = _getDefaultRegistry.fields;
var widgets = _getDefaultRegistry.widgets;
return {

@@ -368,20 +191,20 @@ fields: _extends({}, fields, this.props.fields),

value: function render() {
var _props = this.props;
var children = _props.children;
var safeRenderCompletion = _props.safeRenderCompletion;
var id = _props.id;
var className = _props.className;
var name = _props.name;
var method = _props.method;
var target = _props.target;
var action = _props.action;
var autocomplete = _props.autocomplete;
var enctype = _props.enctype;
var acceptcharset = _props.acceptcharset;
var _state2 = this.state;
var schema = _state2.schema;
var uiSchema = _state2.uiSchema;
var formData = _state2.formData;
var errorSchema = _state2.errorSchema;
var idSchema = _state2.idSchema;
var _props = this.props,
children = _props.children,
safeRenderCompletion = _props.safeRenderCompletion,
id = _props.id,
className = _props.className,
name = _props.name,
method = _props.method,
target = _props.target,
action = _props.action,
autocomplete = _props.autocomplete,
enctype = _props.enctype,
acceptcharset = _props.acceptcharset;
var _state2 = this.state,
schema = _state2.schema,
uiSchema = _state2.uiSchema,
formData = _state2.formData,
errorSchema = _state2.errorSchema,
idSchema = _state2.idSchema;

@@ -388,0 +211,0 @@ var registry = this.getRegistry();

@@ -42,11 +42,11 @@ "use strict";

function DateElement(props) {
var type = props.type;
var range = props.range;
var value = props.value;
var select = props.select;
var rootId = props.rootId;
var disabled = props.disabled;
var readonly = props.readonly;
var autofocus = props.autofocus;
var registry = props.registry;
var type = props.type,
range = props.range,
value = props.value,
select = props.select,
rootId = props.rootId,
disabled = props.disabled,
readonly = props.readonly,
autofocus = props.autofocus,
registry = props.registry;

@@ -89,7 +89,7 @@ var id = rootId + "_" + type;

event.preventDefault();
var _this$props = _this.props;
var time = _this$props.time;
var disabled = _this$props.disabled;
var readonly = _this$props.readonly;
var onChange = _this$props.onChange;
var _this$props = _this.props,
time = _this$props.time,
disabled = _this$props.disabled,
readonly = _this$props.readonly,
onChange = _this$props.onChange;

@@ -107,7 +107,7 @@ if (disabled || readonly) {

event.preventDefault();
var _this$props2 = _this.props;
var time = _this$props2.time;
var disabled = _this$props2.disabled;
var readonly = _this$props2.readonly;
var onChange = _this$props2.onChange;
var _this$props2 = _this.props,
time = _this$props2.time,
disabled = _this$props2.disabled,
readonly = _this$props2.readonly,
onChange = _this$props2.onChange;

@@ -141,8 +141,8 @@ if (disabled || readonly) {

var _props = this.props;
var id = _props.id;
var disabled = _props.disabled;
var readonly = _props.readonly;
var autofocus = _props.autofocus;
var registry = _props.registry;
var _props = this.props,
id = _props.id,
disabled = _props.disabled,
readonly = _props.readonly,
autofocus = _props.autofocus,
registry = _props.registry;

@@ -192,9 +192,9 @@ return _react2.default.createElement(

var time = this.props.time;
var _state = this.state;
var year = _state.year;
var month = _state.month;
var day = _state.day;
var hour = _state.hour;
var minute = _state.minute;
var second = _state.second;
var _state = this.state,
year = _state.year,
month = _state.month,
day = _state.day,
hour = _state.hour,
minute = _state.minute,
second = _state.second;

@@ -201,0 +201,0 @@ var data = [{ type: "year", range: [1900, 2020], value: year }, { type: "month", range: [1, 12], value: month }, { type: "day", range: [1, 31], value: day }];

@@ -20,13 +20,12 @@ "use strict";

// exclude the "options" and "schema" ones here.
var value = props.value;
var readonly = props.readonly;
var autofocus = props.autofocus;
var _onChange = props.onChange;
var options = props.options;
var schema = props.schema;
var formContext = props.formContext;
var registry = props.registry;
var value = props.value,
readonly = props.readonly,
autofocus = props.autofocus,
_onChange = props.onChange,
options = props.options,
schema = props.schema,
formContext = props.formContext,
registry = props.registry,
inputProps = _objectWithoutProperties(props, ["value", "readonly", "autofocus", "onChange", "options", "schema", "formContext", "registry"]);
var inputProps = _objectWithoutProperties(props, ["value", "readonly", "autofocus", "onChange", "options", "schema", "formContext", "registry"]);
return _react2.default.createElement("input", _extends({}, inputProps, {

@@ -33,0 +32,0 @@ className: "form-control",

@@ -30,10 +30,10 @@ "use strict";

function CheckboxesWidget(props) {
var id = props.id;
var disabled = props.disabled;
var options = props.options;
var value = props.value;
var autofocus = props.autofocus;
var _onChange = props.onChange;
var enumOptions = options.enumOptions;
var inline = options.inline;
var id = props.id,
disabled = props.disabled,
options = props.options,
value = props.value,
autofocus = props.autofocus,
_onChange = props.onChange;
var enumOptions = options.enumOptions,
inline = options.inline;

@@ -40,0 +40,0 @@ return _react2.default.createElement(

@@ -14,10 +14,10 @@ "use strict";

function CheckboxWidget(_ref) {
var schema = _ref.schema;
var id = _ref.id;
var value = _ref.value;
var required = _ref.required;
var disabled = _ref.disabled;
var label = _ref.label;
var autofocus = _ref.autofocus;
var _onChange = _ref.onChange;
var schema = _ref.schema,
id = _ref.id,
value = _ref.value,
required = _ref.required,
disabled = _ref.disabled,
label = _ref.label,
autofocus = _ref.autofocus,
_onChange = _ref.onChange;

@@ -24,0 +24,0 @@ return _react2.default.createElement(

@@ -30,4 +30,4 @@ "use strict";

function DateTimeWidget(props) {
var value = props.value;
var _onChange = props.onChange;
var value = props.value,
_onChange = props.onChange;

@@ -34,0 +34,0 @@ return _react2.default.createElement(_BaseInput2.default, _extends({

@@ -28,5 +28,5 @@ "use strict";

function processFile(file) {
var name = file.name;
var size = file.size;
var type = file.type;
var name = file.name,
size = file.size,
type = file.type;

@@ -61,5 +61,5 @@ return new Promise(function (resolve, reject) {

filesInfo.map(function (fileInfo, key) {
var name = fileInfo.name;
var size = fileInfo.size;
var type = fileInfo.type;
var name = fileInfo.name,
size = fileInfo.size,
type = fileInfo.type;

@@ -88,7 +88,6 @@ return _react2.default.createElement(

}).map(function (dataURL) {
var _dataURItoBlob = (0, _utils.dataURItoBlob)(dataURL);
var _dataURItoBlob = (0, _utils.dataURItoBlob)(dataURL),
blob = _dataURItoBlob.blob,
name = _dataURItoBlob.name;
var blob = _dataURItoBlob.blob;
var name = _dataURItoBlob.name;
return {

@@ -115,5 +114,5 @@ name: name,

_this.onChange = function (event) {
var _this$props = _this.props;
var multiple = _this$props.multiple;
var onChange = _this$props.onChange;
var _this$props = _this.props,
multiple = _this$props.multiple,
onChange = _this$props.onChange;

@@ -154,8 +153,8 @@ processFiles(event.target.files).then(function (filesInfo) {

var _props = this.props;
var multiple = _props.multiple;
var id = _props.id;
var readonly = _props.readonly;
var disabled = _props.disabled;
var autofocus = _props.autofocus;
var _props = this.props,
multiple = _props.multiple,
id = _props.id,
readonly = _props.readonly,
disabled = _props.disabled,
autofocus = _props.autofocus;
var filesInfo = this.state.filesInfo;

@@ -162,0 +161,0 @@

@@ -14,4 +14,4 @@ "use strict";

function HiddenWidget(_ref) {
var id = _ref.id;
var value = _ref.value;
var id = _ref.id,
value = _ref.value;

@@ -18,0 +18,0 @@ return _react2.default.createElement("input", { type: "hidden", id: id, value: typeof value === "undefined" ? "" : value });

@@ -14,14 +14,14 @@ "use strict";

function RadioWidget(_ref) {
var schema = _ref.schema;
var options = _ref.options;
var value = _ref.value;
var required = _ref.required;
var disabled = _ref.disabled;
var autofocus = _ref.autofocus;
var _onChange = _ref.onChange;
var schema = _ref.schema,
options = _ref.options,
value = _ref.value,
required = _ref.required,
disabled = _ref.disabled,
autofocus = _ref.autofocus,
_onChange = _ref.onChange;
// Generating a unique field name to identify this set of radio buttons
var name = Math.random().toString();
var enumOptions = options.enumOptions;
var inline = options.inline;
var enumOptions = options.enumOptions,
inline = options.inline;

@@ -28,0 +28,0 @@ return _react2.default.createElement(

@@ -22,4 +22,4 @@ "use strict";

function RangeWidget(props) {
var schema = props.schema;
var value = props.value;
var schema = props.schema,
value = props.value;

@@ -26,0 +26,0 @@ return _react2.default.createElement(

@@ -20,4 +20,4 @@ "use strict";

function processValue(_ref, value) {
var type = _ref.type;
var items = _ref.items;
var type = _ref.type,
items = _ref.items;

@@ -35,12 +35,12 @@ if (type === "array" && items && ["number", "integer"].includes(items.type)) {

function SelectWidget(_ref2) {
var schema = _ref2.schema;
var id = _ref2.id;
var options = _ref2.options;
var value = _ref2.value;
var required = _ref2.required;
var disabled = _ref2.disabled;
var readonly = _ref2.readonly;
var multiple = _ref2.multiple;
var autofocus = _ref2.autofocus;
var _onChange = _ref2.onChange;
var schema = _ref2.schema,
id = _ref2.id,
options = _ref2.options,
value = _ref2.value,
required = _ref2.required,
disabled = _ref2.disabled,
readonly = _ref2.readonly,
multiple = _ref2.multiple,
autofocus = _ref2.autofocus,
_onChange = _ref2.onChange;
var enumOptions = options.enumOptions;

@@ -73,4 +73,4 @@

enumOptions.map(function (_ref3, i) {
var value = _ref3.value;
var label = _ref3.label;
var value = _ref3.value,
label = _ref3.label;

@@ -77,0 +77,0 @@ return _react2.default.createElement(

@@ -14,11 +14,11 @@ "use strict";

function TextareaWidget(_ref) {
var schema = _ref.schema;
var id = _ref.id;
var placeholder = _ref.placeholder;
var value = _ref.value;
var required = _ref.required;
var disabled = _ref.disabled;
var readonly = _ref.readonly;
var autofocus = _ref.autofocus;
var _onChange = _ref.onChange;
var schema = _ref.schema,
id = _ref.id,
placeholder = _ref.placeholder,
value = _ref.value,
required = _ref.required,
disabled = _ref.disabled,
readonly = _ref.readonly,
autofocus = _ref.autofocus,
_onChange = _ref.onChange;

@@ -25,0 +25,0 @@ return _react2.default.createElement("textarea", {

@@ -7,11 +7,11 @@ "use strict";

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
exports.isInteger = isInteger;
exports.getDefaultRegistry = getDefaultRegistry;
exports.defaultFieldValue = defaultFieldValue;
exports.getAlternativeWidget = getAlternativeWidget;
exports.getWidget = getWidget;
exports.getDefaultFormState = getDefaultFormState;
exports.getUiOptions = getUiOptions;
exports.isObject = isObject;

@@ -37,10 +37,19 @@ exports.mergeObjects = mergeObjects;

var _react = require("react");
var _react2 = _interopRequireDefault(_react);
require("setimmediate");
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
var altWidgetMap = {
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
var widgetMap = {
boolean: {
checkbox: "CheckboxWidget",
radio: "RadioWidget",

@@ -51,3 +60,10 @@ select: "SelectWidget",

string: {
text: "TextWidget",
password: "PasswordWidget",
email: "EmailWidget",
hostname: "TextWidget",
ipv4: "TextWidget",
ipv6: "TextWidget",
uri: "URLWidget",
"data-url": "FileWidget",
radio: "RadioWidget",

@@ -59,2 +75,3 @@ select: "SelectWidget",

datetime: "DateTimeWidget",
"date-time": "DateTimeWidget",
"alt-date": "AltDateWidget",

@@ -66,2 +83,4 @@ "alt-datetime": "AltDateTimeWidget",

number: {
text: "TextWidget",
select: "SelectWidget",
updown: "UpDownWidget",

@@ -73,2 +92,4 @@ range: "RangeWidget",

integer: {
text: "TextWidget",
select: "SelectWidget",
updown: "UpDownWidget",

@@ -81,23 +102,36 @@ range: "RangeWidget",

select: "SelectWidget",
checkboxes: "CheckboxesWidget"
checkboxes: "CheckboxesWidget",
files: "FileWidget"
},
// bson specific fields
bool: {
checkbox: "CheckboxWidget",
radio: "RadioWidget",
select: "SelectWidget",
hidden: "HiddenWidget"
},
date: {
text: "TextWidget"
},
objectId: {
text: "TextWidget"
},
long: {
text: "TextWidget"
},
int: {
text: "TextWidget"
},
double: {
text: "TextWidget"
}
};
var stringFormatWidgets = {
"date-time": "DateTimeWidget",
"date": "DateWidget",
"email": "EmailWidget",
"hostname": "TextWidget",
"ipv4": "TextWidget",
"ipv6": "TextWidget",
"uri": "URLWidget",
"data-url": "FileWidget"
var defaultRegistry = {
fields: require("./components/fields").default,
widgets: require("./components/widgets").default,
definitions: {},
formContext: {}
};
function isInteger(value) {
// http://stackoverflow.com/questions/14636536/how-to-check-if-a-variable-is-an-integer-in-javascript
return !isNaN(value) && parseInt(Number(value)) == value && !isNaN(parseInt(value, 10));
}
var defaultRegistry = {};
function getDefaultRegistry() {

@@ -111,31 +145,28 @@ return defaultRegistry;

function getAlternativeWidget(schema, widget) {
var registeredWidgets = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
var widgetOptions = arguments.length <= 3 || arguments[3] === undefined ? {} : arguments[3];
function getWidget(schema, widget) {
var registeredWidgets = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
var type = schema.type;
var format = schema.format;
function setDefaultOptions(widget) {
var _widget$defaultProps = widget.defaultProps;
var defaultProps = _widget$defaultProps === undefined ? {} : _widget$defaultProps;
function mergeOptions(Widget) {
// cache return value as property of widget for proper react reconciliation
if (!Widget.MergedWidget) {
(function () {
var defaultOptions = Widget.defaultProps && Widget.defaultProps.options || {};
Widget.MergedWidget = function (_ref) {
var _ref$options = _ref.options,
options = _ref$options === undefined ? {} : _ref$options,
props = _objectWithoutProperties(_ref, ["options"]);
widget.defaultProps = _extends({}, defaultProps, {
options: _extends({}, defaultProps.options, widgetOptions)
});
return widget;
return _react2.default.createElement(Widget, _extends({ options: _extends({}, defaultOptions, options) }, props));
};
})();
}
return Widget.MergedWidget;
}
if (typeof widget === "function") {
return setDefaultOptions(widget);
return mergeOptions(widget);
}
if (isObject(widget)) {
var component = widget.component;
var options = widget.options;
var mergedOptions = _extends({}, options, widgetOptions);
return getAlternativeWidget(schema, component, registeredWidgets, mergedOptions);
}
if (typeof widget !== "string") {

@@ -147,25 +178,19 @@ throw new Error("Unsupported widget definition: " + (typeof widget === "undefined" ? "undefined" : _typeof(widget)));

var registeredWidget = registeredWidgets[widget];
return getAlternativeWidget(schema, registeredWidget, registeredWidgets, widgetOptions);
return getWidget(schema, registeredWidget, registeredWidgets);
}
if (!altWidgetMap.hasOwnProperty(type)) {
throw new Error("No alternative widget for type " + type);
if (!widgetMap.hasOwnProperty(type)) {
throw new Error("No widget for type \"" + type + "\"");
}
if (altWidgetMap[type].hasOwnProperty(widget)) {
var altWidget = registeredWidgets[altWidgetMap[type][widget]];
return getAlternativeWidget(schema, altWidget, registeredWidgets, widgetOptions);
if (widgetMap[type].hasOwnProperty(widget)) {
var _registeredWidget = registeredWidgets[widgetMap[type][widget]];
return getWidget(schema, _registeredWidget, registeredWidgets);
}
if (type === "string" && stringFormatWidgets.hasOwnProperty(format)) {
var stringFormatWidget = registeredWidgets[stringFormatWidgets[format]];
return getAlternativeWidget(schema, stringFormatWidget, registeredWidgets, widgetOptions);
}
var info = type === "string" && format ? "/" + format : "";
throw new Error("No alternative widget \"" + widget + "\" for type " + type + info);
throw new Error("No widget \"" + widget + "\" for type \"" + type + "\"");
}
function computeDefaults(schema, parentDefaults) {
var definitions = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
var definitions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};

@@ -210,3 +235,3 @@ // Compute the defaults recursively: give highest priority to deepest nodes.

function getDefaultFormState(_schema, formData) {
var definitions = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
var definitions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};

@@ -231,2 +256,20 @@ if (!isObject(_schema)) {

function getUiOptions(uiSchema) {
// get all passed options from ui:widget, ui:options, and ui:<optionName>
return Object.keys(uiSchema).filter(function (key) {
return key.indexOf("ui:") === 0;
}).reduce(function (options, key) {
var value = uiSchema[key];
if (key === "ui:widget" && isObject(value)) {
console.warn("Setting options via ui:widget object is deprecated, use ui:options instead");
return _extends({}, options, value.options || {}, { widget: value.component });
}
if (key === "ui:options" && isObject(value)) {
return _extends({}, options, value);
}
return _extends({}, options, _defineProperty({}, key.substring(3), value));
}, {});
}
function isObject(thing) {

@@ -237,3 +280,3 @@ return (typeof thing === "undefined" ? "undefined" : _typeof(thing)) === "object" && thing !== null && !Array.isArray(thing);

function mergeObjects(obj1, obj2) {
var concatArrays = arguments.length <= 2 || arguments[2] === undefined ? false : arguments[2];
var concatArrays = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;

@@ -357,3 +400,3 @@ // Recursively merge deeply nested objects.

function findSchemaDefinition($ref) {
var definitions = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var definitions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};

@@ -370,3 +413,3 @@ // Extract and use the referenced definition if we have it.

function retrieveSchema(schema) {
var definitions = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1];
var definitions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};

@@ -380,5 +423,5 @@ // No $ref attribute found, returning the original schema.

// Drop the $ref property of the source schema.
var $ref = schema.$ref;
var localSchema = _objectWithoutProperties(schema, ["$ref"]); // eslint-disable-line no-unused-vars
var $ref = schema.$ref,
localSchema = _objectWithoutProperties(schema, ["$ref"]); // eslint-disable-line no-unused-vars
// Update referenced schema definition with local schema properties.

@@ -395,4 +438,4 @@

function deepEquals(a, b) {
var ca = arguments.length <= 2 || arguments[2] === undefined ? [] : arguments[2];
var cb = arguments.length <= 3 || arguments[3] === undefined ? [] : arguments[3];
var ca = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
var cb = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];

@@ -470,4 +513,4 @@ // Partially extracted from node-deeper and adapted to exclude comparison

function shouldRender(comp, nextProps, nextState) {
var props = comp.props;
var state = comp.state;
var props = comp.props,
state = comp.state;

@@ -500,3 +543,3 @@ return !deepEquals(props, nextProps) || !deepEquals(state, nextState);

function parseDateString(dateString) {
var includeTime = arguments.length <= 1 || arguments[1] === undefined ? true : arguments[1];
var includeTime = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;

@@ -527,13 +570,13 @@ if (!dateString) {

function toDateString(_ref) {
var year = _ref.year;
var month = _ref.month;
var day = _ref.day;
var _ref$hour = _ref.hour;
var hour = _ref$hour === undefined ? 0 : _ref$hour;
var _ref$minute = _ref.minute;
var minute = _ref$minute === undefined ? 0 : _ref$minute;
var _ref$second = _ref.second;
var second = _ref$second === undefined ? 0 : _ref$second;
var time = arguments.length <= 1 || arguments[1] === undefined ? true : arguments[1];
function toDateString(_ref2) {
var year = _ref2.year,
month = _ref2.month,
day = _ref2.day,
_ref2$hour = _ref2.hour,
hour = _ref2$hour === undefined ? 0 : _ref2$hour,
_ref2$minute = _ref2.minute,
minute = _ref2$minute === undefined ? 0 : _ref2$minute,
_ref2$second = _ref2.second,
second = _ref2$second === undefined ? 0 : _ref2$second;
var time = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;

@@ -540,0 +583,0 @@ var utcTime = Date.UTC(year, month - 1, day, hour, minute, second);

@@ -9,3 +9,3 @@ "use strict";

var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };

@@ -76,4 +76,4 @@ exports.toErrorList = toErrorList;

return errors.reduce(function (errorSchema, error) {
var property = error.property;
var message = error.message;
var property = error.property,
message = error.message;

@@ -123,3 +123,3 @@ var path = errorPropertyToPath(property);

function toErrorList(errorSchema) {
var fieldName = arguments.length <= 1 || arguments[1] === undefined ? "root" : arguments[1];
var fieldName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "root";

@@ -178,6 +178,5 @@ // XXX: We should transform fieldName as a full field path string.

function validateFormData(formData, schema, customValidate) {
var _bsonValidate = bsonValidate(formData, schema);
var _bsonValidate = bsonValidate(formData, schema),
errors = _bsonValidate.errors;
var errors = _bsonValidate.errors;
var errorSchema = toErrorSchema(errors);

@@ -184,0 +183,0 @@

{
"name": "react-bsonschema-form",
"version": "0.40.7",
"version": "0.41.1",
"description": "A simple React component capable of building HTML forms out of a JSON schema.",

@@ -36,18 +36,19 @@ "scripts": {

"react-datetime": "^2.6.0",
"setimmediate": "^1.0.4"
"setimmediate": "^1.0.5"
},
"devDependencies": {
"atob": "^2.0.3",
"babel-cli": "^6.6.5",
"babel-core": "^6.7.4",
"babel-eslint": "^6.0.2",
"babel-loader": "^6.2.4",
"babel-cli": "^6.18.0",
"babel-core": "^6.18.2",
"babel-eslint": "^6.1.2",
"babel-loader": "^6.2.7",
"babel-plugin-react-transform": "^2.0.2",
"babel-plugin-transform-class-properties": "^6.6.0",
"babel-plugin-transform-object-rest-spread": "^6.6.5",
"babel-preset-es2015": "^6.6.0",
"babel-preset-react": "^6.5.0",
"babel-register": "^6.14.0",
"babel-plugin-transform-class-properties": "^6.18.0",
"babel-plugin-transform-object-rest-spread": "^6.16.0",
"babel-preset-es2015": "^6.18.0",
"babel-preset-react": "^6.16.0",
"babel-register": "^6.18.0",
"codemirror": "^5.20.2",
"eslint": "^2.13.1",
"chai": "^3.3.0",
"codemirror": "^5.13.2",
"cross-env": "^2.0.1",

@@ -59,3 +60,3 @@ "css-loader": "^0.23.1",

"estraverse-fb": "^1.3.1",
"express": "^4.13.3",
"express": "^4.14.0",
"extract-text-webpack-plugin": "^1.0.1",

@@ -67,15 +68,15 @@ "gh-pages": "^0.11.0",

"react": "^15.0.0",
"react-addons-test-utils": "^15.0.1",
"react-addons-test-utils": "^15.3.2",
"react-codemirror": "^0.2.3",
"react-dom": "^15.0.0",
"react-dom": "^15.3.2",
"react-transform-catch-errors": "^1.0.0",
"react-transform-hmr": "^1.0.1",
"redbox-react": "^1.2.3",
"rimraf": "^2.4.4",
"sinon": "^1.17.2",
"redbox-react": "^1.3.3",
"rimraf": "^2.5.4",
"sinon": "^1.17.6",
"style-loader": "^0.13.1",
"toctoc": "^0.2.3",
"webpack": "^1.10.5",
"webpack-dev-middleware": "^1.6.1",
"webpack-hot-middleware": "^2.6.0"
"webpack": "^1.13.3",
"webpack-dev-middleware": "^1.8.4",
"webpack-hot-middleware": "^2.13.2"
},

@@ -82,0 +83,0 @@ "directories": {

@@ -38,5 +38,5 @@ react-jsonschema-form

- [Array item options](#array-item-options)
- [Orderable option](#orderable-option)
- [Addable option](#addable-option)
- [Removable option](#removable-option)
- [orderable option](#orderable-option)
- [addable option](#addable-option)
- [removable option](#removable-option)
- [Custom CSS class names](#custom-css-class-names)

@@ -63,3 +63,3 @@ - [Custom labels for enum fields](#custom-labels-for-enum-fields)

- [Custom SchemaField](#custom-schemafield)
- [Customizing the fields and widgets](#customizing-the-default-fields-and-widgets)
- [Customizing the default fields and widgets](#customizing-the-default-fields-and-widgets)
- [Custom titles](#custom-titles)

@@ -555,7 +555,5 @@ - [Custom descriptions](#custom-descriptions)

const uiSchema = {
"ui:widget": {
component: "checkboxes",
options: {
inline: true
}
"ui:widget": "checkboxes",
"ui:options": {
inline: true
}

@@ -702,2 +700,4 @@ };

- `fields`: An array containing all Form's fields including your [custom fields](#custom-field-components) and the built-in fields.
- `schema`: The schema object for this field.
- `uiSchema`: The uiSchema object for this field.
- `formContext`: The `formContext` object that you passed to Form.

@@ -792,5 +792,7 @@

> Note: Until 0.40.0 it was possible to register a widget as object with shape `{ component: MyCustomWidget, options: {...} }`. This undocumented API has been removed. Instead, you can register a custom widget with a React `defaultProps` property. `defaultProps.options` can be an object containing your custom options.
#### Custom widget options
If you need to pass options to your custom widget, change your `ui:widget` value to be an object having the following structure:
If you need to pass options to your custom widget, you can add a `ui:options` object containing those properties. If the widget has `defaultProps`, the options will be merged with the (optional) options object from `defaultProps`:

@@ -804,14 +806,20 @@ ```jsx

const {options} = props;
return <input style={{options.backgroundColor}} />;
const {color, backgroundColor} = options;
return <input style={{color, backgroundColor}} />;
}
MyCustomWidget.defaultProps = {
options: {
color: "red"
}
};
const uiSchema = {
"ui:widget": {
options: {
backgroundColor: "yellow",
},
component: MyCustomWidget
"ui:widget": MyCustomWidget,
"ui:options": {
backgroundColor: "yellow"
}
};
// renders red on yellow input
render((

@@ -825,2 +833,4 @@ <Form schema={schema}

> Note: Since v0.41.0, the `ui:widget` object API, where a widget and options were specified with `"ui:widget": {component, options}` shape, is deprecated. It will be removed in a future release.
### Custom field components

@@ -827,0 +837,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc