UNPKG

5.81 kBJavaScriptView Raw
1"use strict";
2var __extends = (this && this.__extends) || (function () {
3 var extendStatics = function (d, b) {
4 extendStatics = Object.setPrototypeOf ||
5 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7 return extendStatics(d, b);
8 }
9 return function (d, b) {
10 extendStatics(d, b);
11 function __() { this.constructor = d; }
12 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13 };
14})();
15Object.defineProperty(exports, "__esModule", { value: true });
16/*-----------------------------------------------------------------------------
17| Copyright (c) 2014-2017, PhosphorJS Contributors
18|
19| Distributed under the terms of the BSD 3-Clause License.
20|
21| The full license is in the file LICENSE, distributed with this software.
22|----------------------------------------------------------------------------*/
23var boxlayout_1 = require("./boxlayout");
24var panel_1 = require("./panel");
25/**
26 * A panel which arranges its widgets in a single row or column.
27 *
28 * #### Notes
29 * This class provides a convenience wrapper around a [[BoxLayout]].
30 */
31var BoxPanel = /** @class */ (function (_super) {
32 __extends(BoxPanel, _super);
33 /**
34 * Construct a new box panel.
35 *
36 * @param options - The options for initializing the box panel.
37 */
38 function BoxPanel(options) {
39 if (options === void 0) { options = {}; }
40 var _this = _super.call(this, { layout: Private.createLayout(options) }) || this;
41 _this.addClass('p-BoxPanel');
42 return _this;
43 }
44 Object.defineProperty(BoxPanel.prototype, "direction", {
45 /**
46 * Get the layout direction for the box panel.
47 */
48 get: function () {
49 return this.layout.direction;
50 },
51 /**
52 * Set the layout direction for the box panel.
53 */
54 set: function (value) {
55 this.layout.direction = value;
56 },
57 enumerable: true,
58 configurable: true
59 });
60 Object.defineProperty(BoxPanel.prototype, "alignment", {
61 /**
62 * Get the content alignment for the box panel.
63 *
64 * #### Notes
65 * This is the alignment of the widgets in the layout direction.
66 *
67 * The alignment has no effect if the widgets can expand to fill the
68 * entire box layout.
69 */
70 get: function () {
71 return this.layout.alignment;
72 },
73 /**
74 * Set the content alignment for the box panel.
75 *
76 * #### Notes
77 * This is the alignment of the widgets in the layout direction.
78 *
79 * The alignment has no effect if the widgets can expand to fill the
80 * entire box layout.
81 */
82 set: function (value) {
83 this.layout.alignment = value;
84 },
85 enumerable: true,
86 configurable: true
87 });
88 Object.defineProperty(BoxPanel.prototype, "spacing", {
89 /**
90 * Get the inter-element spacing for the box panel.
91 */
92 get: function () {
93 return this.layout.spacing;
94 },
95 /**
96 * Set the inter-element spacing for the box panel.
97 */
98 set: function (value) {
99 this.layout.spacing = value;
100 },
101 enumerable: true,
102 configurable: true
103 });
104 /**
105 * A message handler invoked on a `'child-added'` message.
106 */
107 BoxPanel.prototype.onChildAdded = function (msg) {
108 msg.child.addClass('p-BoxPanel-child');
109 };
110 /**
111 * A message handler invoked on a `'child-removed'` message.
112 */
113 BoxPanel.prototype.onChildRemoved = function (msg) {
114 msg.child.removeClass('p-BoxPanel-child');
115 };
116 return BoxPanel;
117}(panel_1.Panel));
118exports.BoxPanel = BoxPanel;
119/**
120 * The namespace for the `BoxPanel` class statics.
121 */
122(function (BoxPanel) {
123 /**
124 * Get the box panel stretch factor for the given widget.
125 *
126 * @param widget - The widget of interest.
127 *
128 * @returns The box panel stretch factor for the widget.
129 */
130 function getStretch(widget) {
131 return boxlayout_1.BoxLayout.getStretch(widget);
132 }
133 BoxPanel.getStretch = getStretch;
134 /**
135 * Set the box panel stretch factor for the given widget.
136 *
137 * @param widget - The widget of interest.
138 *
139 * @param value - The value for the stretch factor.
140 */
141 function setStretch(widget, value) {
142 boxlayout_1.BoxLayout.setStretch(widget, value);
143 }
144 BoxPanel.setStretch = setStretch;
145 /**
146 * Get the box panel size basis for the given widget.
147 *
148 * @param widget - The widget of interest.
149 *
150 * @returns The box panel size basis for the widget.
151 */
152 function getSizeBasis(widget) {
153 return boxlayout_1.BoxLayout.getSizeBasis(widget);
154 }
155 BoxPanel.getSizeBasis = getSizeBasis;
156 /**
157 * Set the box panel size basis for the given widget.
158 *
159 * @param widget - The widget of interest.
160 *
161 * @param value - The value for the size basis.
162 */
163 function setSizeBasis(widget, value) {
164 boxlayout_1.BoxLayout.setSizeBasis(widget, value);
165 }
166 BoxPanel.setSizeBasis = setSizeBasis;
167})(BoxPanel = exports.BoxPanel || (exports.BoxPanel = {}));
168exports.BoxPanel = BoxPanel;
169/**
170 * The namespace for the module implementation details.
171 */
172var Private;
173(function (Private) {
174 /**
175 * Create a box layout for the given panel options.
176 */
177 function createLayout(options) {
178 return options.layout || new boxlayout_1.BoxLayout(options);
179 }
180 Private.createLayout = createLayout;
181})(Private || (Private = {}));