@intuitionrobotics/thunderstorm
Version:
124 lines • 3.56 kB
JavaScript
/*
* 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.
*/
import * as React from "react";
import { Module } from "@intuitionrobotics/ts-common";
import { ThunderDispatcher } from "../../core/thunder-dispatcher.js";
import { StylableBuilder } from "../../tools/Stylable.js";
import {} from "../../components/types.js";
const dispatch_showDialog = new ThunderDispatcher("__showDialog");
const dispatch_hideDialog = new ThunderDispatcher("__hideDialog");
export class DialogModule_Class extends Module {
constructor() {
super("DialogModule");
}
init() {
}
close = (id) => {
dispatch_hideDialog.dispatchUI(id);
};
show = (params) => {
dispatch_showDialog.dispatchUI(params);
};
}
export class DialogButton_Builder extends StylableBuilder {
content;
action;
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,
};
}
}
export class Dialog_Builder extends StylableBuilder {
content;
zIndex = 100;
title;
buttons = [];
overlayColor = "rgba(29, 29, 48, 0.6)";
allowIndirectClosing = false;
actionsStyle = {};
id;
constructor(content, id) {
super();
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
};
DialogModule.show(model);
}
}
export const DialogModule = new DialogModule_Class();
//# sourceMappingURL=DialogModule.js.map