UNPKG

@trap_stevo/legendarybuilderproreact-ui

Version:

The legendary UI & utility API that makes your application a legendary application. ~ Created by Steven Compton

189 lines 11.8 kB
import _extends from "@babel/runtime/helpers/extends"; import _defineProperty from "@babel/runtime/helpers/defineProperty"; function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } import * as React from "react"; import { useState, useCallback } from "react"; import { HUDUniversalHUDUtilityManager, ConvertNumberToMoneyFormat } from "../HUDManagers/HUDUniversalHUDUtilityManager.js"; import HUDInput from "./HUDInput.js"; import HUDTyper from "./HUDTyper.js"; function HUDGridCell(hudGridCellConfigurationSettings) { var _hudGridCellConfigura = hudGridCellConfigurationSettings.gridCellDisplayBodyEditModeConfigurationSettings, gridCellDisplayBodyEditModeConfigurationSettings = _hudGridCellConfigura === void 0 ? {} : _hudGridCellConfigura, _hudGridCellConfigura2 = hudGridCellConfigurationSettings.gridCellDisplayBodyLabelConfigurationSettings, gridCellDisplayBodyLabelConfigurationSettings = _hudGridCellConfigura2 === void 0 ? {} : _hudGridCellConfigura2, _hudGridCellConfigura3 = hudGridCellConfigurationSettings.gridCellDisplayBodyConfigurationSettings, gridCellDisplayBodyConfigurationSettings = _hudGridCellConfigura3 === void 0 ? {} : _hudGridCellConfigura3, _hudGridCellConfigura4 = hudGridCellConfigurationSettings.gridCellTitleConfigurationSettings, gridCellTitleConfigurationSettings = _hudGridCellConfigura4 === void 0 ? {} : _hudGridCellConfigura4, _hudGridCellConfigura5 = hudGridCellConfigurationSettings.gridCellConfigurationSettings, gridCellConfigurationSettings = _hudGridCellConfigura5 === void 0 ? {} : _hudGridCellConfigura5, _hudGridCellConfigura6 = hudGridCellConfigurationSettings.gridCellDisplayBodyLabelTyperConfigurations, gridCellDisplayBodyLabelTyperConfigurations = _hudGridCellConfigura6 === void 0 ? {} : _hudGridCellConfigura6, _hudGridCellConfigura7 = hudGridCellConfigurationSettings.gridCellDisplayBodyEditModeConfigurations, gridCellDisplayBodyEditModeConfigurations = _hudGridCellConfigura7 === void 0 ? {} : _hudGridCellConfigura7, _hudGridCellConfigura8 = hudGridCellConfigurationSettings.gridCellDisplayBodyLabelConfigurations, gridCellDisplayBodyLabelConfigurations = _hudGridCellConfigura8 === void 0 ? {} : _hudGridCellConfigura8, _hudGridCellConfigura9 = hudGridCellConfigurationSettings.gridCellDisplayBodyConfigurations, gridCellDisplayBodyConfigurations = _hudGridCellConfigura9 === void 0 ? {} : _hudGridCellConfigura9, _hudGridCellConfigura10 = hudGridCellConfigurationSettings.gridCellTitleConfigurations, gridCellTitleConfigurations = _hudGridCellConfigura10 === void 0 ? {} : _hudGridCellConfigura10, _hudGridCellConfigura11 = hudGridCellConfigurationSettings.gridCellConfigurations, gridCellConfigurations = _hudGridCellConfigura11 === void 0 ? {} : _hudGridCellConfigura11, _hudGridCellConfigura12 = hudGridCellConfigurationSettings.gridCellDisplayBodyContent, gridCellDisplayBodyContent = _hudGridCellConfigura12 === void 0 ? null : _hudGridCellConfigura12, _hudGridCellConfigura13 = hudGridCellConfigurationSettings.gridCellPlaceholder, gridCellPlaceholder = _hudGridCellConfigura13 === void 0 ? "" : _hudGridCellConfigura13, _hudGridCellConfigura14 = hudGridCellConfigurationSettings.gridCellTitle, gridCellTitle = _hudGridCellConfigura14 === void 0 ? "" : _hudGridCellConfigura14, _hudGridCellConfigura15 = hudGridCellConfigurationSettings.acceptsPureInput, acceptsPureInput = _hudGridCellConfigura15 === void 0 ? false : _hudGridCellConfigura15, _hudGridCellConfigura16 = hudGridCellConfigurationSettings.inputFocus, inputFocus = _hudGridCellConfigura16 === void 0 ? false : _hudGridCellConfigura16, _hudGridCellConfigura17 = hudGridCellConfigurationSettings.inputValue, inputValue = _hudGridCellConfigura17 === void 0 ? "" : _hudGridCellConfigura17, inputRef = hudGridCellConfigurationSettings.inputRef, _hudGridCellConfigura18 = hudGridCellConfigurationSettings.showDollarSign, showDollarSign = _hudGridCellConfigura18 === void 0 ? false : _hudGridCellConfigura18, _hudGridCellConfigura19 = hudGridCellConfigurationSettings.showDecimals, showDecimals = _hudGridCellConfigura19 === void 0 ? true : _hudGridCellConfigura19, _hudGridCellConfigura20 = hudGridCellConfigurationSettings.maximumDecimals, maximumDecimals = _hudGridCellConfigura20 === void 0 ? 2 : _hudGridCellConfigura20, _hudGridCellConfigura21 = hudGridCellConfigurationSettings.minimumDecimals, minimumDecimals = _hudGridCellConfigura21 === void 0 ? 2 : _hudGridCellConfigura21, _hudGridCellConfigura22 = hudGridCellConfigurationSettings.financial, financial = _hudGridCellConfigura22 === void 0 ? false : _hudGridCellConfigura22, _hudGridCellConfigura23 = hudGridCellConfigurationSettings.editable, editable = _hudGridCellConfigura23 === void 0 ? true : _hudGridCellConfigura23, handleInputUpdate = hudGridCellConfigurationSettings.handleInputUpdate, setCurrentIndex = hudGridCellConfigurationSettings.setCurrentIndex, setInputFocus = hudGridCellConfigurationSettings.setInputFocus, setInputValue = hudGridCellConfigurationSettings.setInputValue, onInputKeyUpdated = hudGridCellConfigurationSettings.onInputKeyUpdated, onCellClick = hudGridCellConfigurationSettings.onCellClick, _hudGridCellConfigura24 = hudGridCellConfigurationSettings.currentIndex, currentIndex = _hudGridCellConfigura24 === void 0 ? 0 : _hudGridCellConfigura24, _hudGridCellConfigura25 = hudGridCellConfigurationSettings.index, index = _hudGridCellConfigura25 === void 0 ? 0 : _hudGridCellConfigura25, _hudGridCellConfigura26 = hudGridCellConfigurationSettings.dataDisplayID, dataDisplayID = _hudGridCellConfigura26 === void 0 ? "" : _hudGridCellConfigura26, data = hudGridCellConfigurationSettings.data, children = hudGridCellConfigurationSettings.children; var handleBodyDisplayValue = useCallback(function (inputBody) { return "".concat(acceptsPureInput ? inputBody : inputBody === "" ? financial && showDollarSign === false ? ConvertNumberToMoneyFormat(inputValue, showDecimals, minimumDecimals, maximumDecimals) : financial && showDollarSign === true ? "$".concat(ConvertNumberToMoneyFormat(inputValue, showDecimals, minimumDecimals, maximumDecimals)) : !financial && inputValue.trim() !== "" && HUDUniversalHUDUtilityManager.CheckNumber(inputValue) ? HUDUniversalHUDUtilityManager.ConvertUTCDateToDateDisplay(inputValue) : inputValue : financial && showDollarSign === false ? ConvertNumberToMoneyFormat(inputBody, showDecimals, minimumDecimals, maximumDecimals) : financial && showDollarSign === true ? "$".concat(ConvertNumberToMoneyFormat(inputBody, showDecimals, minimumDecimals, maximumDecimals)) : !financial && inputBody.trim() !== "" && HUDUniversalHUDUtilityManager.CheckNumber(inputBody) ? HUDUniversalHUDUtilityManager.ConvertUTCDateToDateDisplay(inputBody) : inputBody); }, [inputValue, financial, showDollarSign, showDecimals, minimumDecimals, maximumDecimals, acceptsPureInput]); return /*#__PURE__*/React.createElement("div", _extends({ style: _objectSpread({ position: "relative", display: "flex", flexDirection: "column", flexShrink: 0, cursor: "pointer", background: "rgba(241.69, 235.69, 241.69, 1)", width: "227.69px" }, gridCellConfigurationSettings), onClick: function onClick() { if (onCellClick) { onCellClick(data, index, inputFocus); } return; } }, gridCellConfigurations), index === 0 ? /*#__PURE__*/React.createElement("div", _extends({ style: _objectSpread({ position: "relative", display: "flex", fontWeight: "637", fontSize: "0.969rem", background: "white", color: "rgba(69, 69, 87.69, 1)", width: "227.69px", paddingBottom: "0.69rem", paddingLeft: "1rem", marginLeft: "0rem", marginBottom: "0.69rem" }, gridCellTitleConfigurationSettings) }, gridCellTitleConfigurations), gridCellTitle) : /*#__PURE__*/React.createElement(React.Fragment, null), editable ? /*#__PURE__*/React.createElement(HUDInput, _extends({ ref: inputRef, inputContainerConfigurationSettings: _objectSpread({ position: "relative", display: "flex", textAlign: "left", pointerEvents: !editable ? "none" : null, boxShadow: currentIndex === index && inputFocus ? "5px 5px 5px -4.69px rgba(0, 0, 0, 0.469)" : "none", background: "rgba(255, 255, 255, 1)", borderRadius: "8px", border: "1px rgba(215, 215, 215, 1) solid", fontStyle: "normal", fontSize: "12px", height: "3rem", width: "215.69px", scale: currentIndex === index && inputFocus ? "1" : "1", paddingLeft: "0.69rem", marginBottom: "0.69rem", marginLeft: "0.469rem", marginTop: index > 0 ? "0.69rem" : null }, gridCellDisplayBodyEditModeConfigurationSettings), placeholder: handleBodyDisplayValue(gridCellPlaceholder), setInputFocus: setInputFocus, setInputValue: setInputValue, inputFocus: inputFocus, inputValue: handleBodyDisplayValue(inputValue), handleInputInFocusUpdate: function handleInputInFocusUpdate(e) { if (setInputFocus === undefined) { return; } if (setCurrentIndex !== undefined) { setCurrentIndex(index); } setInputFocus(true); return; }, handleInputBlurUpdate: function handleInputBlurUpdate(e) { if (setInputFocus === undefined) { return; } if (setCurrentIndex !== undefined) { setCurrentIndex(null); } setInputFocus(false); return; }, handleInputUpdate: handleInputUpdate, onKeyPress: currentIndex === index && inputFocus ? function (event) { if (event.key.trim() === "Enter" && inputValue.trim() !== "" && onInputKeyUpdated) { onInputKeyUpdated(event.key.trim(), inputValue.trim()); return; } } : null }, gridCellDisplayBodyEditModeConfigurations)) : /*#__PURE__*/React.createElement("div", _extends({ style: _objectSpread({ position: "relative", display: "flex", alignItems: "center", border: "1px rgba(215, 215, 215, 1) solid", borderRadius: "8px", background: "rgba(255, 255, 255, 1)", height: "3rem", width: "215.69px", paddingLeft: "0.69rem", marginBottom: "0.69rem", marginLeft: "0.469rem", marginTop: index > 0 ? "0.69rem" : null }, gridCellDisplayBodyConfigurationSettings) }, gridCellDisplayBodyConfigurations), /*#__PURE__*/React.createElement("label", _extends({ style: _objectSpread({ position: "relative", display: "flex", userSelect: "none", textAlign: "left", fontStyle: "normal", fontSize: "12px", height: "auto", width: "calc(100%)" }, gridCellDisplayBodyLabelConfigurationSettings) }, gridCellDisplayBodyLabelConfigurations), /*#__PURE__*/React.createElement(HUDTyper, _extends({ speed: 2.69 }, gridCellDisplayBodyLabelTyperConfigurations), handleBodyDisplayValue(inputValue))), gridCellDisplayBodyContent), children); } ; export default HUDGridCell;