49 lines
3.5 KiB
JavaScript
49 lines
3.5 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.Checkbox = exports.Select = exports.Textarea = exports.TextInput = exports.Field = exports.FormGrid = void 0;
|
|
exports.RadioGroup = RadioGroup;
|
|
var tslib_1 = require("tslib");
|
|
var React = tslib_1.__importStar(require("react"));
|
|
var FormField_module_scss_1 = tslib_1.__importDefault(require("./FormField.module.scss"));
|
|
var FormGrid = function (_a) {
|
|
var children = _a.children;
|
|
return (React.createElement("div", { className: FormField_module_scss_1.default.grid }, children));
|
|
};
|
|
exports.FormGrid = FormGrid;
|
|
var Field = function (_a) {
|
|
var label = _a.label, required = _a.required, full = _a.full, error = _a.error, hint = _a.hint, children = _a.children;
|
|
return (React.createElement("div", { className: "".concat(FormField_module_scss_1.default.field, " ").concat(full ? FormField_module_scss_1.default.full : '') },
|
|
React.createElement("span", { className: FormField_module_scss_1.default.label },
|
|
label,
|
|
" ",
|
|
required && React.createElement("span", { className: FormField_module_scss_1.default.req }, "*")),
|
|
children,
|
|
error && React.createElement("span", { className: FormField_module_scss_1.default.errorText }, error),
|
|
!error && hint && React.createElement("span", { className: FormField_module_scss_1.default.hint }, hint)));
|
|
};
|
|
exports.Field = Field;
|
|
var TextInput = function (props) { return (React.createElement("input", tslib_1.__assign({}, props, { className: FormField_module_scss_1.default.input }))); };
|
|
exports.TextInput = TextInput;
|
|
var Textarea = function (props) { return (React.createElement("textarea", tslib_1.__assign({}, props, { className: FormField_module_scss_1.default.textarea }))); };
|
|
exports.Textarea = Textarea;
|
|
var Select = function (_a) {
|
|
var options = _a.options, placeholder = _a.placeholder, rest = tslib_1.__rest(_a, ["options", "placeholder"]);
|
|
return (React.createElement("select", tslib_1.__assign({}, rest, { className: FormField_module_scss_1.default.select }),
|
|
placeholder && React.createElement("option", { value: "" }, placeholder),
|
|
options.map(function (opt) { return (React.createElement("option", { key: opt.value, value: opt.value }, opt.label)); })));
|
|
};
|
|
exports.Select = Select;
|
|
var Checkbox = function (_a) {
|
|
var label = _a.label, checked = _a.checked, onChange = _a.onChange, disabled = _a.disabled;
|
|
return (React.createElement("label", { className: FormField_module_scss_1.default.checkboxRow },
|
|
React.createElement("input", { type: "checkbox", className: FormField_module_scss_1.default.checkbox, checked: checked, disabled: disabled, onChange: function (e) { return onChange(e.target.checked); } }),
|
|
label));
|
|
};
|
|
exports.Checkbox = Checkbox;
|
|
function RadioGroup(_a) {
|
|
var name = _a.name, value = _a.value, options = _a.options, onChange = _a.onChange;
|
|
return (React.createElement("div", { className: FormField_module_scss_1.default.radioGroup }, options.map(function (opt) { return (React.createElement("label", { key: opt.value, className: "".concat(FormField_module_scss_1.default.radioRow, " ").concat(opt.disabled ? FormField_module_scss_1.default.disabled : ''), title: opt.disabled ? opt.disabledHint : undefined },
|
|
React.createElement("input", { type: "radio", className: FormField_module_scss_1.default.radio, name: name, checked: value === opt.value, disabled: opt.disabled, onChange: function () { return onChange(opt.value); } }),
|
|
opt.label)); })));
|
|
}
|
|
//# sourceMappingURL=FormField.js.map
|