UNPKG

@eccenca/gui-elements

Version:

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

56 lines 3.03 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.Card = void 0; const react_1 = __importDefault(require("react")); const core_1 = require("@blueprintjs/core"); const constants_1 = require("../../configuration/constants"); /** * Element to separate content sections from each other. * Cards can include other cards but should not. */ const Card = (_a) => { var { children, className = "", elevation = 1, isOnlyLayout = false, fullHeight = false, elevated = false, scrollinOnFocus, whitespaceAmount = "medium", interactive } = _a, otherProps = __rest(_a, ["children", "className", "elevation", "isOnlyLayout", "fullHeight", "elevated", "scrollinOnFocus", "whitespaceAmount", "interactive"]); const scrollIn = scrollinOnFocus ? { tabIndex: 0, onFocus: (e) => { // FIXME: we should not have any hard relations to apps that using this lib const el = e.target.closest(".diapp-iframewindow__content"); setTimeout(() => { if (el) el.scrollIntoView({ behavior: "smooth", block: scrollinOnFocus, inline: scrollinOnFocus, }); }, 200); }, } : {}; const cardElement = (react_1.default.createElement(core_1.Card, Object.assign({ className: `${constants_1.CLASSPREFIX}-card` + (fullHeight ? ` ${constants_1.CLASSPREFIX}-card--fullheight` : "") + (elevated ? ` ${constants_1.CLASSPREFIX}-card--elevated` : "") + (scrollinOnFocus ? ` ${constants_1.CLASSPREFIX}-card--scrollonfocus` : "") + (whitespaceAmount !== "medium" ? ` ${constants_1.CLASSPREFIX}-card--whitespace-${whitespaceAmount}` : "") + (elevation < 0 ? ` ${constants_1.CLASSPREFIX}-card--whitespace-borderless` : "") + (className ? ` ${className}` : ""), elevation: Math.max(0, elevation), interactive: otherProps.onClick ? true : interactive }, scrollIn, otherProps), children)); // FIXME: improve Card element so it is itself a section html element return isOnlyLayout === false ? react_1.default.createElement("section", null, cardElement) : cardElement; }; exports.Card = Card; exports.default = exports.Card; //# sourceMappingURL=Card.js.map