UNPKG

@trap_stevo/legendarybuilderproreact-ui

Version:

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

157 lines 8.84 kB
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties"; import _extends from "@babel/runtime/helpers/extends"; import _defineProperty from "@babel/runtime/helpers/defineProperty"; import _slicedToArray from "@babel/runtime/helpers/slicedToArray"; var _excluded = ["archiveTreeConfigurationSettings", "archiveTreeConfigurations", "tree"]; 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 { motion, AnimatePresence } from "framer-motion"; import HUDIcon from "./HUDIcon.js"; function ArchiveEntry(_ref) { var _entry$children; var _ref$entryContentAnim = _ref.entryContentAnimationTransitionConfigurationSettings, entryContentAnimationTransitionConfigurationSettings = _ref$entryContentAnim === void 0 ? {} : _ref$entryContentAnim, _ref$entryContentInit = _ref.entryContentInitialAnimationConfigurationSettings, entryContentInitialAnimationConfigurationSettings = _ref$entryContentInit === void 0 ? {} : _ref$entryContentInit, _ref$entryContentExit = _ref.entryContentExitAnimationConfigurationSettings, entryContentExitAnimationConfigurationSettings = _ref$entryContentExit === void 0 ? {} : _ref$entryContentExit, _ref$entryContentAnim2 = _ref.entryContentAnimationConfigurationSettings, entryContentAnimationConfigurationSettings = _ref$entryContentAnim2 === void 0 ? {} : _ref$entryContentAnim2, _ref$entryContainerCo = _ref.entryContainerConfigurationSettings, entryContainerConfigurationSettings = _ref$entryContainerCo === void 0 ? {} : _ref$entryContainerCo, _ref$entryContentConf = _ref.entryContentConfigurationSettings, entryContentConfigurationSettings = _ref$entryContentConf === void 0 ? {} : _ref$entryContentConf, _ref$entryLineConfigu = _ref.entryLineConfigurationSettings, entryLineConfigurationSettings = _ref$entryLineConfigu === void 0 ? {} : _ref$entryLineConfigu, _ref$entryConfigurati = _ref.entryConfigurationSettings, entryConfigurationSettings = _ref$entryConfigurati === void 0 ? {} : _ref$entryConfigurati, _ref$entryContainerCo2 = _ref.entryContainerConfigurations, entryContainerConfigurations = _ref$entryContainerCo2 === void 0 ? {} : _ref$entryContainerCo2, _ref$entryAnimationCo = _ref.entryAnimationConfigurations, entryAnimationConfigurations = _ref$entryAnimationCo === void 0 ? {} : _ref$entryAnimationCo, _ref$entryContentConf2 = _ref.entryContentConfigurations, entryContentConfigurations = _ref$entryContentConf2 === void 0 ? {} : _ref$entryContentConf2, _ref$entryLineConfigu2 = _ref.entryLineConfigurations, entryLineConfigurations = _ref$entryLineConfigu2 === void 0 ? {} : _ref$entryLineConfigu2, _ref$entryIconConfigu = _ref.entryIconConfigurations, entryIconConfigurations = _ref$entryIconConfigu === void 0 ? {} : _ref$entryIconConfigu, _ref$entryNameConfigu = _ref.entryNameConfigurations, entryNameConfigurations = _ref$entryNameConfigu === void 0 ? {} : _ref$entryNameConfigu, _ref$entryConfigurati2 = _ref.entryConfigurations, entryConfigurations = _ref$entryConfigurati2 === void 0 ? {} : _ref$entryConfigurati2, _ref$depth = _ref.depth, depth = _ref$depth === void 0 ? 0 : _ref$depth, entry = _ref.entry; var _useState = useState(true), _useState2 = _slicedToArray(_useState, 2), open = _useState2[0], setOpen = _useState2[1]; var toggle = function toggle() { if (entry.type === "folder") { setOpen(function (prev) { return !prev; }); } }; return /*#__PURE__*/React.createElement("div", _extends({ style: _objectSpread({ position: "relative" }, entryContainerConfigurationSettings) }, entryContainerConfigurations), /*#__PURE__*/React.createElement("div", _extends({ style: _objectSpread({ position: "relative", display: "flex", alignItems: "center", cursor: entry.type === "folder" ? "pointer" : "default", userSelect: "none", fontFamily: "monospace", fontWeight: entry.type === "folder" ? "600" : "normal", fontSize: entry.type === "folder" ? "1rem" : "0.95rem", gap: "0.5rem", paddingLeft: "".concat(depth * 1.5, "rem") }, entryConfigurationSettings), onClick: toggle }, entryConfigurations), /*#__PURE__*/React.createElement("div", _extends({ style: _objectSpread({ position: "absolute", background: "rgba(0, 0, 0, 0.169)", width: "1px", bottom: 0, left: "".concat(depth * 1.5 - 0.75, "rem"), top: 0 }, entryLineConfigurationSettings) }, entryLineConfigurations)), /*#__PURE__*/React.createElement(HUDIcon, _extends({ name: entry.type === "folder" ? open ? "folder-open" : "folder" : "file" }, entryIconConfigurations)), /*#__PURE__*/React.createElement("span", entryNameConfigurations, entry.name, entry.type === "folder" ? "/" : "")), /*#__PURE__*/React.createElement(AnimatePresence, _extends({ initial: false }, entryAnimationConfigurations), entry.type === "folder" && open && ((_entry$children = entry.children) === null || _entry$children === void 0 ? void 0 : _entry$children.length) > 0 && /*#__PURE__*/React.createElement(motion.div, _extends({ key: "children", initial: _objectSpread({ opacity: 0, height: 0 }, entryContentInitialAnimationConfigurationSettings), animate: _objectSpread({ opacity: 1, height: "auto" }, entryContentAnimationConfigurationSettings), exit: _objectSpread({ opacity: 0, height: 0 }, entryContentExitAnimationConfigurationSettings), transition: _objectSpread({ duration: 0.3, ease: "easeInOut" }, entryContentAnimationTransitionConfigurationSettings), style: _objectSpread({ marginBottom: "0.169rem", marginTop: "0.169rem" }, entryContentConfigurationSettings) }, entryContentConfigurations), entry.children.map(function (child) { return /*#__PURE__*/React.createElement(ArchiveEntry, { entryContentAnimationTransitionConfigurationSettings: entryContentAnimationTransitionConfigurationSettings, entryContentInitialAnimationConfigurationSettings: entryContentInitialAnimationConfigurationSettings, entryContentExitAnimationConfigurationSettings: entryContentExitAnimationConfigurationSettings, entryContentAnimationConfigurationSettings: entryContentAnimationConfigurationSettings, entryContainerConfigurationSettings: entryContainerConfigurationSettings, entryContentConfigurationSettings: entryContentConfigurationSettings, entryLineConfigurationSettings: entryLineConfigurationSettings, entryConfigurationSettings: entryConfigurationSettings, entryContainerConfigurations: entryContainerConfigurations, entryAnimationConfigurations: entryAnimationConfigurations, entryContentConfigurations: entryContentConfigurations, entryLineConfigurations: entryLineConfigurations, entryIconConfigurations: entryIconConfigurations, entryNameConfigurations: entryNameConfigurations, entryConfigurations: entryConfigurations, key: child.name + depth, depth: depth + 1, entry: child }); })))); } ; function HUDArchiveTree(_ref2) { var _ref2$archiveTreeConf = _ref2.archiveTreeConfigurationSettings, archiveTreeConfigurationSettings = _ref2$archiveTreeConf === void 0 ? {} : _ref2$archiveTreeConf, _ref2$archiveTreeConf2 = _ref2.archiveTreeConfigurations, archiveTreeConfigurations = _ref2$archiveTreeConf2 === void 0 ? {} : _ref2$archiveTreeConf2, _ref2$tree = _ref2.tree, tree = _ref2$tree === void 0 ? [] : _ref2$tree, rest = _objectWithoutProperties(_ref2, _excluded); return /*#__PURE__*/React.createElement("div", _extends({ style: _objectSpread({ display: "flex", flexDirection: "column", gap: "0.69rem" }, archiveTreeConfigurationSettings) }, archiveTreeConfigurations), tree && Array.isArray(tree) && tree.map(function (entry) { return /*#__PURE__*/React.createElement(ArchiveEntry, _extends({ key: entry.name, entry: entry }, rest)); })); } ; export default HUDArchiveTree;