@nu-art/thunder
Version:
Thunder - React & Typescript based frontend framework
181 lines • 6.6 kB
JavaScript
"use strict";
/*
* A typescript & react boilerplate with api call example
*
* Copyright (C) 2018 Adam van der Kruk aka TacB0sS
*
* 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.
*/
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __spreadArrays = (this && this.__spreadArrays) || function () {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
};
Object.defineProperty(exports, "__esModule", { value: true });
var ts_common_1 = require("@nu-art/ts-common");
// noinspection TypeScriptPreferShortImport
var Thunder_1 = require("../core/Thunder");
var DialogModule_Class = /** @class */ (function (_super) {
__extends(DialogModule_Class, _super);
function DialogModule_Class() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.showDialog = new Thunder_1.UIDispatcher("showDialog");
_this.close = function () {
_this.showDialog.dispatch([]);
};
_this.show = function (params) {
_this.showDialog.dispatch([params]);
};
return _this;
}
return DialogModule_Class;
}(ts_common_1.Module));
exports.DialogModule_Class = DialogModule_Class;
exports.DialogModule = new DialogModule_Class();
var StylableBuilder = /** @class */ (function () {
function StylableBuilder() {
}
StylableBuilder.prototype.setStyle = function (style) {
this.style = style;
return this;
};
StylableBuilder.prototype.clearInlineStyle = function () {
this.style = {};
return this;
};
StylableBuilder.prototype.addStyle = function (style) {
if (!this.style)
return this.setStyle(style);
this.style = __assign(__assign({}, this.style), style);
return this;
};
StylableBuilder.prototype.setClassName = function (className) {
this.className = className;
return this;
};
return StylableBuilder;
}());
exports.StylableBuilder = StylableBuilder;
var DialogButton_Builder = /** @class */ (function (_super) {
__extends(DialogButton_Builder, _super);
function DialogButton_Builder() {
return _super !== null && _super.apply(this, arguments) || this;
}
DialogButton_Builder.prototype.setContent = function (content) {
this.content = content;
return this;
};
DialogButton_Builder.prototype.setAction = function (action) {
this.action = action;
return this;
};
DialogButton_Builder.prototype.build = function () {
return {
style: this.style,
className: this.className,
content: this.content,
action: this.action,
};
};
return DialogButton_Builder;
}(StylableBuilder));
exports.DialogButton_Builder = DialogButton_Builder;
var Dialog_Builder = /** @class */ (function (_super) {
__extends(Dialog_Builder, _super);
function Dialog_Builder(content) {
var _this = _super.call(this) || this;
_this.zIndex = 100;
_this.buttons = [];
_this.overlayColor = "rgba(29, 29, 48, 0.6)";
_this.allowIndirectClosing = false;
_this.actionsStyle = {};
_this.content = content;
return _this;
}
Dialog_Builder.prototype.setAllowIndirectClosing = function (allowIndirectClosing) {
this.allowIndirectClosing = allowIndirectClosing;
return this;
};
Dialog_Builder.prototype.setOverlayColor = function (overlayColor) {
this.overlayColor = overlayColor;
return this;
};
Dialog_Builder.prototype.setActionsStyle = function (actionsStyle) {
this.actionsStyle = actionsStyle;
return this;
};
Dialog_Builder.prototype.setTitle = function (title) {
this.title = title;
return this;
};
Dialog_Builder.prototype.setButtons = function () {
var buttons = [];
for (var _i = 0; _i < arguments.length; _i++) {
buttons[_i] = arguments[_i];
}
this.buttons = buttons;
return this;
};
Dialog_Builder.prototype.addButton = function (button) {
this.buttons = __spreadArrays(this.buttons, [button]);
return this;
};
Dialog_Builder.prototype.setZIndex = function (zIndex) {
if (zIndex === void 0) { zIndex = 100; }
this.zIndex = zIndex;
return this;
};
Dialog_Builder.prototype.show = function () {
var 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
};
exports.DialogModule.show(model);
};
return Dialog_Builder;
}(StylableBuilder));
exports.Dialog_Builder = Dialog_Builder;
//# sourceMappingURL=dialog-module.js.map