@gravel-form/blueprintjs
Version:
A flexible middlewares driven json schema form with Blueprintjs
49 lines (46 loc) • 2.14 kB
JavaScript
;
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result["default"] = mod;
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
var React = __importStar(require("react"));
var core_1 = require("../core");
var core_2 = require("@blueprintjs/core");
exports.FormGroupTemplateBaseMw = function (props) {
var schema = props.schema, dataPath = props.dataPath, next = props.next, errors = props.errors;
if (typeof schema === 'boolean')
return next(props);
var id = core_1.toJSONSchemaPath(dataPath);
var error = errors && errors.find(function (_a) {
var dataPath = _a.dataPath;
return dataPath === id;
});
return (React.createElement(core_2.FormGroup, { label: schema.title || dataPath[dataPath.length - 1], helperText: error ? error.message : schema.description, labelInfo: core_1.isRequired(props) ? '(required)' : '', intent: error ? core_2.Intent.DANGER : core_2.Intent.NONE }, next(props)));
};
exports.FormGroupTemplateMw = function (props) {
var schema = props.schema, parent = props.parent, next = props.next;
if (typeof schema === 'boolean' ||
schema.type === 'object' ||
schema.type === 'array' ||
(parent && typeof parent.schema !== 'boolean' && parent.schema.type === 'array'))
return next(props);
return React.createElement(exports.FormGroupTemplateBaseMw, __assign({}, props));
};
exports.default = exports.FormGroupTemplateMw;
//# sourceMappingURL=FormGroupTemplateMw.js.map
//# sourceMappingURL=FormGroupTemplateMw.js.map