UNPKG

@eccenca/gui-elements

Version:

GUI elements based on other libraries, usable in React application, written in Typescript.

47 lines 2.35 kB
var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; var __read = (this && this.__read) || function (o, n) { var m = typeof Symbol === "function" && o[Symbol.iterator]; if (!m) return o; var i = m.call(o), r, ar = [], e; try { while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); } catch (error) { e = { error: error }; } finally { try { if (r && !r.done && (m = i["return"])) m.call(i); } finally { if (e) throw e.error; } } return ar; }; import React from "react"; import { ContextMenu, MenuItem } from "../../../components/index.js"; /** * Returns a simple context menu that provides switches to control the editor appearance. */ export function EditorAppearanceConfigMenu(_a) { var _b; var config = _a.config, _c = _a.configLocked, configLocked = _c === void 0 ? {} : _c, _d = _a.configPropertyTranslate, configPropertyTranslate = _d === void 0 ? function (s) { return s; } : _d, setConfig = _a.setConfig, contextMenuProps = _a.contextMenuProps; return (React.createElement(ContextMenu, __assign({ togglerElement: "item-settings" }, contextMenuProps, { disabled: (_b = contextMenuProps === null || contextMenuProps === void 0 ? void 0 : contextMenuProps.disabled) !== null && _b !== void 0 ? _b : Object.values(config).length === Object.values(configLocked).filter(function (value) { return typeof value !== "undefined"; }).length }), Object.entries(config).map(function (_a) { var _b = __read(_a, 2), key = _b[0], value = _b[1]; return (React.createElement(MenuItem, { key: key, roleStructure: "listoption", selected: value, text: configPropertyTranslate(key) || key, disabled: typeof configLocked[key] !== "undefined", onClick: function () { var _a; setConfig(__assign(__assign({}, config), (_a = {}, _a[key] = !value, _a))); } })); }))); } //# sourceMappingURL=EditorAppearanceConfigMenu.js.map