@intuitionrobotics/thunderstorm
Version:
123 lines • 3.9 kB
JavaScript
"use strict";
/*
* Thunderstorm is a full web app framework!
*
* Typescript & Express backend infrastructure that natively runs on firebase function
* Typescript & React frontend infrastructure
*
* Copyright (C) 2020 Intuition Robotics
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.DialogModule = exports.Dialog_Builder = exports.DialogButton_Builder = exports.DialogModule_Class = void 0;
const ts_common_1 = require("@intuitionrobotics/ts-common");
const thunder_dispatcher_1 = require("../../core/thunder-dispatcher");
const Stylable_1 = require("../../tools/Stylable");
const dispatch_showDialog = new thunder_dispatcher_1.ThunderDispatcher("__showDialog");
const dispatch_hideDialog = new thunder_dispatcher_1.ThunderDispatcher("__hideDialog");
class DialogModule_Class extends ts_common_1.Module {
constructor() {
super("DialogModule");
this.close = (id) => {
dispatch_hideDialog.dispatchUI(id);
};
this.show = (params) => {
dispatch_showDialog.dispatchUI(params);
};
}
init() {
}
}
exports.DialogModule_Class = DialogModule_Class;
class DialogButton_Builder extends Stylable_1.StylableBuilder {
setContent(content) {
this.content = content;
return this;
}
setAction(action) {
this.action = action;
return this;
}
build() {
return {
style: this.style,
className: this.className,
content: this.content,
action: this.action,
};
}
}
exports.DialogButton_Builder = DialogButton_Builder;
class Dialog_Builder extends Stylable_1.StylableBuilder {
constructor(content, id) {
super();
this.zIndex = 100;
this.buttons = [];
this.overlayColor = "rgba(29, 29, 48, 0.6)";
this.allowIndirectClosing = false;
this.actionsStyle = {};
this.content = content;
this.id = id;
}
setAllowIndirectClosing(allowIndirectClosing) {
this.allowIndirectClosing = allowIndirectClosing;
return this;
}
setOverlayColor(overlayColor) {
this.overlayColor = overlayColor;
return this;
}
setActionsStyle(actionsStyle) {
this.actionsStyle = actionsStyle;
return this;
}
setTitle(title) {
this.title = title;
return this;
}
setButtons(...buttons) {
this.buttons = buttons;
return this;
}
addButton(button) {
this.buttons = [...this.buttons, button];
return this;
}
setZIndex(zIndex = 100) {
this.zIndex = zIndex;
return this;
}
setId(id) {
this.id = id;
return this;
}
show() {
const model = {
style: this.style,
className: this.className,
buttons: this.buttons,
allowIndirectClosing: this.allowIndirectClosing,
content: this.content,
title: this.title,
zIndex: this.zIndex,
overlayColor: this.overlayColor,
actionsStyle: this.actionsStyle,
id: this.id
};
exports.DialogModule.show(model);
}
}
exports.Dialog_Builder = Dialog_Builder;
exports.DialogModule = new DialogModule_Class();
//# sourceMappingURL=DialogModule.js.map