UNPKG

aws-cdk-lib

Version:

Version 2 of the AWS Cloud Development Kit library

2 lines (1 loc) 3.26 kB
"use strict";var _a,_b,_c;Object.defineProperty(exports,"__esModule",{value:!0}),exports.Spacer=exports.Column=exports.Row=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var widget_1=()=>{var tmp=require("./widget");return widget_1=()=>tmp,tmp};class Row{constructor(...widgets){this.offsets=[];try{jsiiDeprecationWarnings().aws_cdk_lib_aws_cloudwatch_IWidget(widgets)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,Row),error}this.widgets=widgets,this._width=0,this._height=0;let x=0,y=0;for(const widget of widgets)x+widget.width>widget_1().GRID_WIDTH&&(y=this._height,x=0),this.updateDimensions(x,y,widget),x+=widget.width}get width(){return this._width}get height(){return this._height}updateDimensions(x,y,widget){this.offsets.push({x,y}),this._width=Math.max(this.width,x+widget.width),this._height=Math.max(this.height,y+widget.height)}addWidget(w){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_cloudwatch_IWidget(w)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.addWidget),error}this.widgets.push(w);let x=this.width,y=this.height;x+w.width>widget_1().GRID_WIDTH&&(y=this.height,x=0),this.updateDimensions(x,y,w)}position(x,y){for(let i=0;i<this.widgets.length;i++)this.widgets[i].position(x+this.offsets[i].x,y+this.offsets[i].y)}toJson(){const ret=[];for(const widget of this.widgets)ret.push(...widget.toJson());return ret}}exports.Row=Row,_a=JSII_RTTI_SYMBOL_1,Row[_a]={fqn:"aws-cdk-lib.aws_cloudwatch.Row",version:"2.185.0"};class Column{constructor(...widgets){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_cloudwatch_IWidget(widgets)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,Column),error}this.widgets=widgets,this._width=Math.max(...this.widgets.map(w=>w.width)),this._height=sum(...this.widgets.map(w=>w.height))}get width(){return this._width}get height(){return this._height}addWidget(w){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_cloudwatch_IWidget(w)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.addWidget),error}this.widgets.push(w),this._width=Math.max(this.width,w.width),this._height+=w.height}position(x,y){let widgetY=y;for(const widget of this.widgets)widget.position(x,widgetY),widgetY+=widget.height}toJson(){const ret=[];for(const widget of this.widgets)ret.push(...widget.toJson());return ret}}exports.Column=Column,_b=JSII_RTTI_SYMBOL_1,Column[_b]={fqn:"aws-cdk-lib.aws_cloudwatch.Column",version:"2.185.0"};class Spacer{constructor(props={}){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_cloudwatch_SpacerProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,Spacer),error}this.width=props.width||1,this.height=props.height||1}position(_x,_y){}toJson(){return[]}}exports.Spacer=Spacer,_c=JSII_RTTI_SYMBOL_1,Spacer[_c]={fqn:"aws-cdk-lib.aws_cloudwatch.Spacer",version:"2.185.0"};function sum(...xs){let ret=0;for(const x of xs)ret+=x;return ret}