UNPKG

@eccenca/gui-elements

Version:

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

48 lines 2.54 kB
"use strict"; var __rest = (this && this.__rest) || function (s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Tab = exports.transformTabProperties = void 0; const react_1 = __importDefault(require("react")); const core_1 = require("@blueprintjs/core"); const color_1 = __importDefault(require("color")); const constants_1 = require("../../configuration/constants"); const colorDecideContrastvalue_1 = __importDefault(require("./../../common/utils/colorDecideContrastvalue")); const TabTitle_1 = __importDefault(require("./TabTitle")); const transformTabProperties = (_a) => { var { title, dontShrink = false, className = "", backgroundColor } = _a, otherBlueprintTabProperties = __rest(_a, ["title", "dontShrink", "className", "backgroundColor"]); const flexStyles = dontShrink ? { flexShrink: 0 } : {}; let colorStyles = {}; if (backgroundColor) { let color = (0, color_1.default)("#ffffff"); try { color = (0, color_1.default)(backgroundColor); } catch (_b) { // eslint-disable-next-line no-console console.warn("Tag received invalid backgroundColor property: " + backgroundColor); } colorStyles = { backgroundColor: `${color.rgb().toString()}`, color: (0, colorDecideContrastvalue_1.default)({ testColor: color }), }; } const extraStyles = dontShrink || !!backgroundColor ? { style: Object.assign(Object.assign({}, flexStyles), colorStyles) } : {}; return Object.assign(Object.assign({ key: otherBlueprintTabProperties.id, className: className + ` ${constants_1.CLASSPREFIX}-tabs`, title: typeof title === "string" ? react_1.default.createElement(TabTitle_1.default, { text: title }) : title }, otherBlueprintTabProperties), extraStyles); }; exports.transformTabProperties = transformTabProperties; exports.Tab = core_1.Tab; exports.default = exports.Tab; //# sourceMappingURL=Tab.js.map