@tomino/dynamic-form-semantic-ui
Version:
Semantic UI form renderer based on dynamic form generation
35 lines • 1.35 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const React = tslib_1.__importStar(require("react"));
const mobx_react_1 = require("mobx-react");
const semantic_ui_react_1 = require("semantic-ui-react");
function renderError(error, pointing) {
return (React.createElement(semantic_ui_react_1.Label, { pointing: pointing, color: "red" }, error));
}
exports.renderError = renderError;
const ErrorViewComponent = ({ owner, source, newLine, inline, pointing = true }) => {
if (!owner.getError) {
return null;
}
pointing = inline ? 'left' : pointing;
let error = source && owner.getError(source);
if (!error) {
return null;
}
if (newLine) {
return React.createElement("div", null, renderError(error, pointing));
}
return renderError(error, pointing);
};
ErrorViewComponent.displayName = 'ErrorView';
exports.ErrorView = mobx_react_1.observer(ErrorViewComponent);
const ErrorLabelComponent = ({ error, pointing = true }) => {
if (!error) {
return null;
}
return (React.createElement(semantic_ui_react_1.Label, { color: "red", pointing: pointing }, error));
};
ErrorLabelComponent.displayName = 'ErrorLabel';
exports.ErrorLabel = mobx_react_1.observer(ErrorLabelComponent);
//# sourceMappingURL=error_view.js.map