1 | ;
|
2 | var _a, _b, _c;
|
3 | Object.defineProperty(exports, "__esModule", { value: true });
|
4 | exports.Spacer = exports.Column = exports.Row = void 0;
|
5 | const jsiiDeprecationWarnings = require("../.warnings.jsii.js");
|
6 | const JSII_RTTI_SYMBOL_1 = Symbol.for("jsii.rtti");
|
7 | const widget_1 = require("./widget");
|
8 | // This file contains widgets that exist for layout purposes
|
9 | /**
|
10 | * A widget that contains other widgets in a horizontal row
|
11 | *
|
12 | * Widgets will be laid out next to each other
|
13 | */
|
14 | class Row {
|
15 | constructor(...widgets) {
|
16 | /**
|
17 | * Relative position of each widget inside this row
|
18 | */
|
19 | this.offsets = [];
|
20 | try {
|
21 | jsiiDeprecationWarnings._aws_cdk_aws_cloudwatch_IWidget(widgets);
|
22 | }
|
23 | catch (error) {
|
24 | if (process.env.JSII_DEBUG !== "1" && error.name === "DeprecationError") {
|
25 | Error.captureStackTrace(error, Row);
|
26 | }
|
27 | throw error;
|
28 | }
|
29 | this.widgets = widgets;
|
30 | this.width = 0;
|
31 | this.height = 0;
|
32 | let x = 0;
|
33 | let y = 0;
|
34 | for (const widget of widgets) {
|
35 | // See if we need to horizontally wrap to add this widget
|
36 | if (x + widget.width > widget_1.GRID_WIDTH) {
|
37 | y = this.height;
|
38 | x = 0;
|
39 | }
|
40 | this.offsets.push({ x, y });
|
41 | this.width = Math.max(this.width, x + widget.width);
|
42 | this.height = Math.max(this.height, y + widget.height);
|
43 | x += widget.width;
|
44 | }
|
45 | }
|
46 | position(x, y) {
|
47 | for (let i = 0; i < this.widgets.length; i++) {
|
48 | this.widgets[i].position(x + this.offsets[i].x, y + this.offsets[i].y);
|
49 | }
|
50 | }
|
51 | toJson() {
|
52 | const ret = [];
|
53 | for (const widget of this.widgets) {
|
54 | ret.push(...widget.toJson());
|
55 | }
|
56 | return ret;
|
57 | }
|
58 | }
|
59 | exports.Row = Row;
|
60 | _a = JSII_RTTI_SYMBOL_1;
|
61 | Row[_a] = { fqn: "@aws-cdk/aws-cloudwatch.Row", version: "1.198.0" };
|
62 | /**
|
63 | * A widget that contains other widgets in a vertical column
|
64 | *
|
65 | * Widgets will be laid out next to each other
|
66 | */
|
67 | class Column {
|
68 | constructor(...widgets) {
|
69 | try {
|
70 | jsiiDeprecationWarnings._aws_cdk_aws_cloudwatch_IWidget(widgets);
|
71 | }
|
72 | catch (error) {
|
73 | if (process.env.JSII_DEBUG !== "1" && error.name === "DeprecationError") {
|
74 | Error.captureStackTrace(error, Column);
|
75 | }
|
76 | throw error;
|
77 | }
|
78 | this.widgets = widgets;
|
79 | // There's no vertical wrapping so this one's a lot easier
|
80 | this.width = Math.max(...this.widgets.map(w => w.width));
|
81 | this.height = sum(...this.widgets.map(w => w.height));
|
82 | }
|
83 | position(x, y) {
|
84 | let widgetY = y;
|
85 | for (const widget of this.widgets) {
|
86 | widget.position(x, widgetY);
|
87 | widgetY += widget.height;
|
88 | }
|
89 | }
|
90 | toJson() {
|
91 | const ret = [];
|
92 | for (const widget of this.widgets) {
|
93 | ret.push(...widget.toJson());
|
94 | }
|
95 | return ret;
|
96 | }
|
97 | }
|
98 | exports.Column = Column;
|
99 | _b = JSII_RTTI_SYMBOL_1;
|
100 | Column[_b] = { fqn: "@aws-cdk/aws-cloudwatch.Column", version: "1.198.0" };
|
101 | /**
|
102 | * A widget that doesn't display anything but takes up space
|
103 | */
|
104 | class Spacer {
|
105 | constructor(props = {}) {
|
106 | try {
|
107 | jsiiDeprecationWarnings._aws_cdk_aws_cloudwatch_SpacerProps(props);
|
108 | }
|
109 | catch (error) {
|
110 | if (process.env.JSII_DEBUG !== "1" && error.name === "DeprecationError") {
|
111 | Error.captureStackTrace(error, Spacer);
|
112 | }
|
113 | throw error;
|
114 | }
|
115 | this.width = props.width || 1;
|
116 | this.height = props.height || 1;
|
117 | }
|
118 | position(_x, _y) {
|
119 | }
|
120 | toJson() {
|
121 | return [];
|
122 | }
|
123 | }
|
124 | exports.Spacer = Spacer;
|
125 | _c = JSII_RTTI_SYMBOL_1;
|
126 | Spacer[_c] = { fqn: "@aws-cdk/aws-cloudwatch.Spacer", version: "1.198.0" };
|
127 | /**
|
128 | * Return the sum of a list of numbers
|
129 | */
|
130 | function sum(...xs) {
|
131 | let ret = 0;
|
132 | for (const x of xs) {
|
133 | ret += x;
|
134 | }
|
135 | return ret;
|
136 | }
|
137 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGF5b3V0LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsibGF5b3V0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7OztBQUFBLHFDQUErQztBQUUvQyw0REFBNEQ7QUFFNUQ7Ozs7R0FJRztBQUNILE1BQWEsR0FBRztJQWNkLFlBQVksR0FBRyxPQUFrQjtRQUxqQzs7V0FFRztRQUNjLFlBQU8sR0FBYSxFQUFFLENBQUM7Ozs7OzsrQ0FaN0IsR0FBRzs7OztRQWVaLElBQUksQ0FBQyxPQUFPLEdBQUcsT0FBTyxDQUFDO1FBRXZCLElBQUksQ0FBQyxLQUFLLEdBQUcsQ0FBQyxDQUFDO1FBQ2YsSUFBSSxDQUFDLE1BQU0sR0FBRyxDQUFDLENBQUM7UUFDaEIsSUFBSSxDQUFDLEdBQUcsQ0FBQyxDQUFDO1FBQ1YsSUFBSSxDQUFDLEdBQUcsQ0FBQyxDQUFDO1FBQ1YsS0FBSyxNQUFNLE1BQU0sSUFBSSxPQUFPLEVBQUU7WUFDNUIseURBQXlEO1lBQ3pELElBQUksQ0FBQyxHQUFHLE1BQU0sQ0FBQyxLQUFLLEdBQUcsbUJBQVUsRUFBRTtnQkFDakMsQ0FBQyxHQUFHLElBQUksQ0FBQyxNQUFNLENBQUM7Z0JBQ2hCLENBQUMsR0FBRyxDQUFDLENBQUM7YUFDUDtZQUVELElBQUksQ0FBQyxPQUFPLENBQUMsSUFBSSxDQUFDLEVBQUUsQ0FBQyxFQUFFLENBQUMsRUFBRSxDQUFDLENBQ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