UNPKG

@deephaven/golden-layout

Version:

A multi-screen javascript Layout manager

91 lines (90 loc) 3.81 kB
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; } function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; } function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } import $ from 'jquery'; import AbstractContentItem from "./AbstractContentItem.js"; import { ConfigurationError } from "../errors/index.js"; import ItemContainer from "../container/ItemContainer.js"; /** * @param layoutManager * @param config * @param parent */ export default class Component extends AbstractContentItem { constructor(layoutManager, config, parent) { var _layoutManager$config; // Extend before super so the AbstractContentItem defualts aren't applied first Object.entries((_layoutManager$config = layoutManager.config.settings.defaultComponentConfig) !== null && _layoutManager$config !== void 0 ? _layoutManager$config : {}).forEach(_ref => { var [k, v] = _ref; // @ts-ignore if (config[k] === undefined) { // @ts-ignore config[k] = v; } }); super(layoutManager, config, parent, $()); _defineProperty(this, "config", void 0); _defineProperty(this, "componentName", void 0); _defineProperty(this, "container", void 0); _defineProperty(this, "parent", void 0); _defineProperty(this, "instance", void 0); this.config = config; this.parent = parent; var ComponentConstructor = layoutManager.getComponent(this.config.componentName) || layoutManager.getFallbackComponent(), componentConfig = $.extend(true, {}, this.config.componentState || {}); if (ComponentConstructor == null) { throw new ConfigurationError('Unknown component "' + this.config.componentName + '"'); } componentConfig.componentName = this.config.componentName; this.componentName = this.config.componentName; if (this.config.title === '') { this.config.title = this.config.componentName; } this.isComponent = true; this.container = new ItemContainer(this.config, this, layoutManager); this.instance = new ComponentConstructor(this.container, componentConfig); this.element = this.container._element; } close() { var _this$parent; (_this$parent = this.parent) === null || _this$parent === void 0 ? void 0 : _this$parent.removeChild(this); } setSize() { if (this.element.is(':visible')) { // Do not update size of hidden components to prevent unwanted reflows this.container._$setSize(this.element.width(), this.element.height()); } } _$init() { AbstractContentItem.prototype._$init.call(this); this.container.emit('open'); } _$hide() { this.container.hide(); AbstractContentItem.prototype._$hide.call(this); } _$show(forceFocus) { this.container.show(); if (this.container._config.isFocusOnShow || forceFocus) { // focus the shown container element on show // preventScroll isn't supported in safari, but also doesn't matter for illumon when 100% window this.container._contentElement[0].focus({ preventScroll: true }); } AbstractContentItem.prototype._$show.call(this); } _$destroy() { this.container.emit('destroy', this); AbstractContentItem.prototype._$destroy.call(this); } /** * Dragging onto a component directly is not an option * * @returns null */ _$getArea() { return null; } } //# sourceMappingURL=Component.js.map