@trap_stevo/legendarybuilderproreact-ui
Version:
The legendary UI & utility API that makes your application a legendary application. ~ Created by Steven Compton
160 lines • 9.16 kB
JavaScript
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 } from "react";
import { HUDUniversalHUDUtilityManager, ConvertNumberToMoneyFormat } from "@trap_stevo/legendarybuilderproreact-ui";
import { HUDInput, HUDTyper } from "@trap_stevo/legendarybuilderproreact-ui";
function HUDGridCell(hudGridCellConfigurationSettings) {
var _hudGridCellConfigura = hudGridCellConfigurationSettings.gridCellDisplayBodyConfigurationSettings,
gridCellDisplayBodyConfigurationSettings = _hudGridCellConfigura === void 0 ? {} : _hudGridCellConfigura,
_hudGridCellConfigura2 = hudGridCellConfigurationSettings.gridCellTitleConfigurationSettings,
gridCellTitleConfigurationSettings = _hudGridCellConfigura2 === void 0 ? {} : _hudGridCellConfigura2,
_hudGridCellConfigura3 = hudGridCellConfigurationSettings.gridCellConfigurationSettings,
gridCellConfigurationSettings = _hudGridCellConfigura3 === void 0 ? {} : _hudGridCellConfigura3,
_hudGridCellConfigura4 = hudGridCellConfigurationSettings.gridCellPlaceholder,
gridCellPlaceholder = _hudGridCellConfigura4 === void 0 ? "" : _hudGridCellConfigura4,
_hudGridCellConfigura5 = hudGridCellConfigurationSettings.gridCellTitle,
gridCellTitle = _hudGridCellConfigura5 === void 0 ? "" : _hudGridCellConfigura5,
_hudGridCellConfigura6 = hudGridCellConfigurationSettings.acceptsPureInput,
acceptsPureInput = _hudGridCellConfigura6 === void 0 ? false : _hudGridCellConfigura6,
_hudGridCellConfigura7 = hudGridCellConfigurationSettings.inputFocus,
inputFocus = _hudGridCellConfigura7 === void 0 ? false : _hudGridCellConfigura7,
_hudGridCellConfigura8 = hudGridCellConfigurationSettings.inputValue,
inputValue = _hudGridCellConfigura8 === void 0 ? "" : _hudGridCellConfigura8,
inputRef = hudGridCellConfigurationSettings.inputRef,
_hudGridCellConfigura9 = hudGridCellConfigurationSettings.showDollarSign,
showDollarSign = _hudGridCellConfigura9 === void 0 ? false : _hudGridCellConfigura9,
_hudGridCellConfigura10 = hudGridCellConfigurationSettings.showDecimals,
showDecimals = _hudGridCellConfigura10 === void 0 ? true : _hudGridCellConfigura10,
_hudGridCellConfigura11 = hudGridCellConfigurationSettings.maximumDecimals,
maximumDecimals = _hudGridCellConfigura11 === void 0 ? 2 : _hudGridCellConfigura11,
_hudGridCellConfigura12 = hudGridCellConfigurationSettings.minimumDecimals,
minimumDecimals = _hudGridCellConfigura12 === void 0 ? 2 : _hudGridCellConfigura12,
_hudGridCellConfigura13 = hudGridCellConfigurationSettings.financial,
financial = _hudGridCellConfigura13 === void 0 ? false : _hudGridCellConfigura13,
_hudGridCellConfigura14 = hudGridCellConfigurationSettings.editable,
editable = _hudGridCellConfigura14 === void 0 ? true : _hudGridCellConfigura14,
handleInputUpdate = hudGridCellConfigurationSettings.handleInputUpdate,
setCurrentIndex = hudGridCellConfigurationSettings.setCurrentIndex,
setInputFocus = hudGridCellConfigurationSettings.setInputFocus,
setInputValue = hudGridCellConfigurationSettings.setInputValue,
onInputKeyUpdated = hudGridCellConfigurationSettings.onInputKeyUpdated,
onCellClick = hudGridCellConfigurationSettings.onCellClick,
_hudGridCellConfigura15 = hudGridCellConfigurationSettings.currentIndex,
currentIndex = _hudGridCellConfigura15 === void 0 ? 0 : _hudGridCellConfigura15,
_hudGridCellConfigura16 = hudGridCellConfigurationSettings.index,
index = _hudGridCellConfigura16 === void 0 ? 0 : _hudGridCellConfigura16,
_hudGridCellConfigura17 = hudGridCellConfigurationSettings.dataDisplayID,
dataDisplayID = _hudGridCellConfigura17 === void 0 ? "" : _hudGridCellConfigura17,
data = hudGridCellConfigurationSettings.data;
var handleBodyDisplayValue = function handleBodyDisplayValue(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);
};
return /*#__PURE__*/React.createElement("div", {
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;
}
}, index === 0 ? /*#__PURE__*/React.createElement("div", {
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)
}, gridCellTitle) : /*#__PURE__*/React.createElement(React.Fragment, null), editable ? /*#__PURE__*/React.createElement(HUDInput, {
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
}, gridCellDisplayBodyConfigurationSettings),
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
}) : /*#__PURE__*/React.createElement("label", {
style: _objectSpread({
position: "relative",
display: "flex",
userSelect: "none",
alignItems: "center",
textAlign: "left",
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",
paddingLeft: "0.69rem",
marginBottom: "0.69rem",
marginLeft: "0.469rem",
marginTop: index > 0 ? "0.69rem" : null
}, gridCellDisplayBodyConfigurationSettings)
}, /*#__PURE__*/React.createElement(HUDTyper, {
speed: 2.69
}, handleBodyDisplayValue(inputValue))));
}
export default HUDGridCell;