@gpa-gemstone/react-forms
Version:
React Form modules for gpa webapps
56 lines (55 loc) • 3.53 kB
JavaScript
;
// ******************************************************************************************************
// DoubleInput.tsx - Gbtc
//
// Copyright © 2020, Grid Protection Alliance. All Rights Reserved.
//
// Licensed to the Grid Protection Alliance (GPA) under one or more contributor license agreements. See
// the NOTICE file distributed with this work for additional information regarding copyright ownership.
// The GPA licenses this file to you under the MIT License (MIT), the "License"; you may not use this
// file except in compliance with the License. You may obtain a copy of the License at:
//
// http://opensource.org/licenses/MIT
//
// Unless agreed to in writing, the subject software distributed under the License is distributed on an
// "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Refer to the
// License for the specific language governing permissions and limitations.
//
// Code Modification History:
// ----------------------------------------------------------------------------------------------------
// 01/07/2021 - C. Lackner
// Generated original version of source code.
//
// ******************************************************************************************************
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);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = DoubleInput;
var React = require("react");
/**
* DoubleInput Component.
* A component that renders two input fields, allowing input for two related fields in a single record.
*/
function DoubleInput(props) {
return (React.createElement("div", { className: "form-group" },
React.createElement("label", null, props.Label == null ? (props.Field1 + ' ' + props.Field2) : props.Label),
React.createElement("div", { className: "input-group" },
React.createElement("input", { type: props.Type === undefined ? 'text' : props.Type, className: props.Valid(props.Field1) ? 'form-control' : 'form-control is-invalid', onChange: function (evt) {
var _a;
return props.Setter(__assign(__assign({}, props.Record), (_a = {}, _a[props.Field1] = evt.target.value !== '' ? evt.target.value : null, _a)));
}, value: props.Record[props.Field1] == null ? '' : props.Record[props.Field1].toString(), disabled: props.Disabled == null ? false : props.Disabled }),
React.createElement("input", { type: props.Type === undefined ? 'text' : props.Type, className: props.Valid(props.Field2) ? 'form-control' : 'form-control is-invalid', onChange: function (evt) {
var _a;
return props.Setter(__assign(__assign({}, props.Record), (_a = {}, _a[props.Field2] = evt.target.value !== '' ? evt.target.value : null, _a)));
}, value: props.Record[props.Field2] == null ? '' : props.Record[props.Field2].toString(), disabled: props.Disabled == null ? false : props.Disabled })),
React.createElement("div", { className: "invalid-feedback" }, props.Feedback == null ? (props.Field1 + ' ' + props.Field2 + ' is a required field.') : props.Feedback)));
}