UNPKG

@gpa-gemstone/common-pages

Version:
98 lines (97 loc) 6.36 kB
"use strict"; //****************************************************************************************************** // DateFilter.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; }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); var React = __importStar(require("react")); var react_forms_1 = require("@gpa-gemstone/react-forms"); var TimeFilter_1 = require("../TimeFilter"); var QuickSelects_1 = __importDefault(require("../QuickSelects")); var DateFilter = function (props) { var FirstFallbackBreakpoint = 1050; var SecondFallbackBreakpoint = 541; var FirstFallbackBreakpointNoQS = 375; var handleSetTimeWindowFilter = React.useCallback(function (record) { var flt = (0, TimeFilter_1.getTimeWindowFromFilter)({ start: record.start, end: record.end }, props.Format); props.SetTimeWindowFilter(flt); props.SetActiveQP(-1); }, [props.Format]); var startEndCol = React.useMemo(function () { if (props.ShowQuickSelects && props.ContainerWidth > FirstFallbackBreakpoint) return 'col-2'; if (!props.ShowQuickSelects && props.ContainerWidth > FirstFallbackBreakpointNoQS) return 'col-6'; else return 'col-12'; }, [props.ShowQuickSelects, props.ContainerWidth]); var quickSelectClass = React.useMemo(function () { if (props.ContainerWidth > FirstFallbackBreakpoint) return 'col-8'; else return 'col-12'; }, [props.ContainerWidth]); if (props.ContainerWidth > FirstFallbackBreakpoint) return (React.createElement("div", { className: 'row m-0' }, React.createElement("div", { className: startEndCol }, React.createElement(react_forms_1.DatePicker, { Record: props.TimeWindowFilter, Field: "start", Help: props.HelpMessage, Setter: handleSetTimeWindowFilter, Label: 'Start', Type: props.DateUnit, Valid: function () { return true; }, Format: props.Format, Accuracy: props.Accuracy })), React.createElement("div", { className: startEndCol }, React.createElement(react_forms_1.DatePicker, { Record: props.TimeWindowFilter, Field: "end", Help: props.HelpMessage, Setter: handleSetTimeWindowFilter, Label: 'End', Type: props.DateUnit, Valid: function () { return true; }, Format: props.Format, Accuracy: props.Accuracy })), props.ShowQuickSelects ? React.createElement("div", { className: quickSelectClass }, React.createElement(QuickSelects_1.default, { DateTimeSetting: 'startEnd', Timezone: props.Timezone, ActiveQP: props.ActiveQP, SetActiveQP: props.SetActiveQP, SetFilter: props.SetFilter, Format: props.Format, DateUnit: props.DateUnit })) : null)); else return (React.createElement(React.Fragment, null, React.createElement("div", { className: 'row m-0' }, React.createElement("div", { className: startEndCol }, React.createElement(react_forms_1.DatePicker, { Record: props.TimeWindowFilter, Field: "start", Help: props.HelpMessage, Setter: handleSetTimeWindowFilter, Label: 'Start', Type: props.DateUnit, Valid: function () { return true; }, Format: props.Format, Accuracy: props.Accuracy })), React.createElement("div", { className: startEndCol }, React.createElement(react_forms_1.DatePicker, { Record: props.TimeWindowFilter, Field: "end", Help: props.HelpMessage, Setter: handleSetTimeWindowFilter, Label: 'End', Type: props.DateUnit, Valid: function () { return true; }, Format: props.Format, Accuracy: props.Accuracy }))), props.ShowQuickSelects ? React.createElement("div", { className: quickSelectClass }, React.createElement(QuickSelects_1.default, { DateTimeSetting: 'startEnd', Timezone: props.Timezone, ActiveQP: props.ActiveQP, SetActiveQP: props.SetActiveQP, SetFilter: props.SetFilter, Format: props.Format, DateUnit: props.DateUnit, SplitSelects: props.ContainerWidth < SecondFallbackBreakpoint })) : null)); }; exports.default = DateFilter;