@gpa-gemstone/common-pages
Version:
Common UI pages for GPA products
74 lines (73 loc) • 4.13 kB
JavaScript
;
//******************************************************************************************************
// WindowForm.tsx - Gbtc
//
// Copyright © 2025, 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:
// ----------------------------------------------------------------------------------------------------
// 07/14/2025 - Preston Crawford
// Generated original version of source code.
//******************************************************************************************************
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
var react_forms_1 = require("@gpa-gemstone/react-forms");
var React = __importStar(require("react"));
var TimeFilter_1 = require("../TimeFilter");
var TimeWindowUtils_1 = require("../TimeWindowUtils");
var WindowForm = function (props) {
var setter = React.useCallback(function (record) {
if (props.Window === 'start') {
props.SetFilter((0, TimeFilter_1.getTimeWindowFromFilter)({ start: record.start, duration: record.duration, unit: record.unit }, props.Format));
props.SetActiveQP(-1);
}
else {
props.SetFilter((0, TimeFilter_1.getTimeWindowFromFilter)({ end: record.end, duration: record.duration, unit: record.unit }, props.Format));
props.SetActiveQP(-1);
}
}, [props.Window, props.Format, props.SetActiveQP, props.SetActiveQP]);
return (React.createElement("div", { className: 'form-group' },
React.createElement("label", { style: { width: '100%', position: 'relative', float: "left" } },
"Span(",
props.Window === 'start' ? '+' : '-',
")"),
React.createElement("div", { className: 'row' },
React.createElement("div", { className: 'col-6' },
React.createElement(react_forms_1.Input, { Record: props.Filter, Field: 'duration', Label: '', Valid: function () { return true; }, Type: 'number', Setter: setter })),
React.createElement("div", { className: 'col-6' },
React.createElement(react_forms_1.Select, { Record: props.Filter, Label: '', Field: 'unit', Options: TimeWindowUtils_1.units.map(function (unit) { return ({ Value: unit, Label: (0, TimeWindowUtils_1.readableUnit)(unit) }); }), Setter: setter })))));
};
exports.default = WindowForm;