x4js 1.4.4 → 1.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/application.d.ts +96 -0
- package/lib/application.js +146 -0
- package/lib/base64.d.ts +31 -0
- package/lib/base64.js +139 -0
- package/lib/base_component.d.ts +64 -0
- package/lib/base_component.js +81 -0
- package/lib/button.d.ts +145 -0
- package/lib/button.js +241 -0
- package/lib/calendar.d.ts +77 -0
- package/lib/calendar.js +241 -0
- package/lib/canvas.d.ts +88 -0
- package/lib/canvas.js +358 -0
- package/lib/cardview.d.ts +83 -0
- package/lib/cardview.js +156 -0
- package/lib/checkbox.d.ts +72 -0
- package/lib/checkbox.js +130 -0
- package/lib/color.d.ts +144 -0
- package/lib/color.js +588 -0
- package/lib/colorpicker.js +86 -80
- package/lib/combobox.js +26 -22
- package/lib/component.d.ts +572 -0
- package/lib/component.js +1729 -0
- package/lib/datastore.js +29 -20
- package/lib/dialog.js +41 -36
- package/lib/dom_events.d.ts +284 -0
- package/lib/dom_events.js +14 -0
- package/lib/drag_manager.js +4 -1
- package/lib/drawtext.js +9 -5
- package/lib/fileupload.js +19 -12
- package/lib/form.js +29 -25
- package/lib/formatters.js +19 -10
- package/lib/gridview.js +40 -35
- package/lib/hosts/host.d.ts +44 -0
- package/lib/hosts/host.js +73 -0
- package/lib/i18n.d.ts +67 -0
- package/lib/i18n.js +175 -0
- package/lib/icon.d.ts +56 -0
- package/lib/icon.js +178 -0
- package/lib/image.js +7 -3
- package/lib/index.js +71 -55
- package/lib/input.d.ts +86 -0
- package/lib/input.js +176 -0
- package/lib/label.d.ts +54 -0
- package/lib/label.js +90 -0
- package/lib/layout.d.ts +77 -0
- package/lib/layout.js +271 -0
- package/lib/link.js +9 -5
- package/lib/listview.js +34 -27
- package/lib/md5.js +5 -1
- package/lib/menu.d.ts +122 -0
- package/lib/menu.js +284 -0
- package/lib/messagebox.js +22 -17
- package/lib/panel.js +13 -9
- package/lib/popup.d.ts +71 -0
- package/lib/popup.js +378 -0
- package/lib/property_editor.js +20 -16
- package/lib/radiobtn.js +13 -9
- package/lib/rating.js +13 -9
- package/lib/request.js +16 -9
- package/lib/router.js +5 -1
- package/lib/settings.d.ts +33 -0
- package/lib/settings.js +67 -0
- package/lib/sidebarview.js +12 -8
- package/lib/smartedit.js +16 -11
- package/lib/spreadsheet.js +35 -31
- package/lib/styles.d.ts +81 -0
- package/lib/styles.js +268 -0
- package/lib/svgcomponent.js +8 -3
- package/lib/tabbar.js +10 -6
- package/lib/tabview.js +10 -6
- package/lib/textarea.js +10 -6
- package/lib/textedit.js +39 -35
- package/lib/texthiliter.js +8 -4
- package/lib/toaster.js +8 -4
- package/lib/tools.d.ts +382 -0
- package/lib/tools.js +1142 -0
- package/lib/tooltips.js +14 -9
- package/lib/treeview.js +30 -26
- package/lib/x4_events.d.ts +253 -0
- package/lib/x4_events.js +375 -0
- package/package.json +1 -1
- package/src/application.ts +9 -4
- package/src/x4.less +143 -107
- package/tsconfig.json +1 -1
- package/x4.css +1541 -0
package/lib/menu.js
ADDED
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* ___ ___ __
|
|
4
|
+
* \ \_/ / / _
|
|
5
|
+
* \ / /_| |_
|
|
6
|
+
* / _ \____ _|
|
|
7
|
+
* /__/ \__\ |_|
|
|
8
|
+
*
|
|
9
|
+
* @file menu.ts
|
|
10
|
+
* @author Etienne Cochard
|
|
11
|
+
* @license
|
|
12
|
+
* Copyright (c) 2019-2021 R-libre ingenierie
|
|
13
|
+
*
|
|
14
|
+
* This program is free software; you can redistribute it and/or modify
|
|
15
|
+
* it under the terms of the GNU General Public License as published by
|
|
16
|
+
* the Free Software Foundation; either version 3 of the License, or
|
|
17
|
+
* (at your option) any later version.
|
|
18
|
+
*
|
|
19
|
+
* This program is distributed in the hope that it will be useful,
|
|
20
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
21
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
22
|
+
* GNU General Public License for more details.
|
|
23
|
+
*
|
|
24
|
+
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
25
|
+
**/
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
exports.MenuBar = exports.MenuItem = exports.Menu = exports.MenuTitle = exports.MenuSeparator = void 0;
|
|
28
|
+
const component_1 = require("./component");
|
|
29
|
+
const x4_events_1 = require("./x4_events");
|
|
30
|
+
const popup_1 = require("./popup");
|
|
31
|
+
const icon_1 = require("./icon");
|
|
32
|
+
const label_1 = require("./label");
|
|
33
|
+
const layout_1 = require("./layout");
|
|
34
|
+
const tools_1 = require("./tools");
|
|
35
|
+
// ============================================================================
|
|
36
|
+
// [MENU]
|
|
37
|
+
// ============================================================================
|
|
38
|
+
class MenuSeparator extends component_1.Component {
|
|
39
|
+
}
|
|
40
|
+
exports.MenuSeparator = MenuSeparator;
|
|
41
|
+
class MenuTitle extends label_1.Label {
|
|
42
|
+
}
|
|
43
|
+
exports.MenuTitle = MenuTitle;
|
|
44
|
+
class Menu extends popup_1.Popup {
|
|
45
|
+
static watchCount = 0;
|
|
46
|
+
static rootMenu = null;
|
|
47
|
+
m_subMenu;
|
|
48
|
+
m_opener;
|
|
49
|
+
m_virtual;
|
|
50
|
+
m_lock;
|
|
51
|
+
constructor(props, opener) {
|
|
52
|
+
super(props);
|
|
53
|
+
this.addClass('@shadow');
|
|
54
|
+
this.m_opener = opener;
|
|
55
|
+
this.m_virtual = false;
|
|
56
|
+
this.m_lock = 0;
|
|
57
|
+
this.enableMask(false);
|
|
58
|
+
}
|
|
59
|
+
lock(yes) {
|
|
60
|
+
this.m_lock += yes ? 1 : -1;
|
|
61
|
+
}
|
|
62
|
+
setVirtual() {
|
|
63
|
+
this.m_virtual = true;
|
|
64
|
+
}
|
|
65
|
+
setSubMenu(menu) {
|
|
66
|
+
this.m_subMenu = menu;
|
|
67
|
+
}
|
|
68
|
+
hideSubMenu() {
|
|
69
|
+
if (this.m_subMenu) {
|
|
70
|
+
this.m_subMenu.m_opener._close();
|
|
71
|
+
this.m_subMenu.hide();
|
|
72
|
+
this.m_subMenu = null;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/** @ignore */
|
|
76
|
+
render(props) {
|
|
77
|
+
this.setContent(props.items);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
*
|
|
81
|
+
*/
|
|
82
|
+
show() {
|
|
83
|
+
if (!this.m_virtual) {
|
|
84
|
+
Menu._addMenu(this);
|
|
85
|
+
}
|
|
86
|
+
super.show();
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
*
|
|
90
|
+
*/
|
|
91
|
+
close() {
|
|
92
|
+
if (!this.dom && !this.m_virtual) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
if (this.m_opener) {
|
|
96
|
+
this.m_opener._close();
|
|
97
|
+
}
|
|
98
|
+
if (this.m_subMenu) {
|
|
99
|
+
this.m_subMenu.close();
|
|
100
|
+
this.m_subMenu = null;
|
|
101
|
+
}
|
|
102
|
+
super.close();
|
|
103
|
+
Menu._removeMenu();
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
*
|
|
107
|
+
*/
|
|
108
|
+
clear() {
|
|
109
|
+
this.m_props.items = [];
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* @internal
|
|
113
|
+
*/
|
|
114
|
+
static _addMenu(menu) {
|
|
115
|
+
//console.log( 'addmenu' );
|
|
116
|
+
if (Menu.watchCount == 0) {
|
|
117
|
+
Menu.rootMenu = menu;
|
|
118
|
+
document.addEventListener('mousedown', Menu._mouseWatcher);
|
|
119
|
+
}
|
|
120
|
+
Menu.watchCount++;
|
|
121
|
+
}
|
|
122
|
+
static _removeMenu() {
|
|
123
|
+
//console.log( 'removemenu' );
|
|
124
|
+
console.assert(Menu.watchCount > 0);
|
|
125
|
+
Menu.watchCount--;
|
|
126
|
+
if (Menu.watchCount == 0) {
|
|
127
|
+
document.removeEventListener('mousedown', Menu._mouseWatcher);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
static _mouseWatcher(ev) {
|
|
131
|
+
if (ev.defaultPrevented) {
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
let elOn = ev.target;
|
|
135
|
+
while (elOn) {
|
|
136
|
+
// is mouse on a menu
|
|
137
|
+
let mouseon = component_1.Component.getElement(elOn);
|
|
138
|
+
if (mouseon && (mouseon instanceof Menu /*|| elOn.$el instanceof Menubar*/)) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
elOn = elOn.parentElement;
|
|
142
|
+
}
|
|
143
|
+
Menu._discardAll();
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* hide all the visible menus
|
|
147
|
+
*/
|
|
148
|
+
static _discardAll() {
|
|
149
|
+
if (Menu.rootMenu) {
|
|
150
|
+
Menu.rootMenu.close();
|
|
151
|
+
Menu.rootMenu = null;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
displayAt(...args) {
|
|
155
|
+
if (!this.m_lock) {
|
|
156
|
+
Menu._discardAll();
|
|
157
|
+
}
|
|
158
|
+
let x, y, align, offset;
|
|
159
|
+
if (args.length == 1) {
|
|
160
|
+
({ x, y } = (0, tools_1.getMousePos)(args[0], true));
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
[x, y, align, offset] = args;
|
|
164
|
+
}
|
|
165
|
+
if (!align) {
|
|
166
|
+
align = 'top left';
|
|
167
|
+
}
|
|
168
|
+
super.displayAt(x, y, align, offset);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
exports.Menu = Menu;
|
|
172
|
+
class MenuItem extends component_1.Component {
|
|
173
|
+
m_menu;
|
|
174
|
+
m_isOpen;
|
|
175
|
+
constructor(a, b) {
|
|
176
|
+
if ((0, tools_1.isString)(a)) {
|
|
177
|
+
super({
|
|
178
|
+
text: a,
|
|
179
|
+
click: b
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
super(a);
|
|
184
|
+
}
|
|
185
|
+
this.mapPropEvents(this.m_props, 'click');
|
|
186
|
+
this.m_menu = null;
|
|
187
|
+
this.m_isOpen = false;
|
|
188
|
+
this.setDomEvent('mousedown', (e) => this._mousedown(e));
|
|
189
|
+
this.setDomEvent('click', (e) => this._click(e));
|
|
190
|
+
}
|
|
191
|
+
/** @ignore */
|
|
192
|
+
render(props) {
|
|
193
|
+
let icon = props.icon ?? 0x20;
|
|
194
|
+
let text = props.text;
|
|
195
|
+
if (props.checked !== undefined) {
|
|
196
|
+
icon = props.checked ? 'cls(far fa-check)' : 0; //todo: use stylesheet
|
|
197
|
+
}
|
|
198
|
+
if (this.isPopup) {
|
|
199
|
+
this.addClass('@popup-menu-item');
|
|
200
|
+
}
|
|
201
|
+
if (!text && !icon) {
|
|
202
|
+
this.addClass('@separator');
|
|
203
|
+
}
|
|
204
|
+
if (props.cls) {
|
|
205
|
+
this.addClass(props.cls);
|
|
206
|
+
}
|
|
207
|
+
this.setProp('tag', 'a');
|
|
208
|
+
//@bug: do not kill focus on click
|
|
209
|
+
// this.setAttribute( 'tabindex', '0' );
|
|
210
|
+
this.setContent([
|
|
211
|
+
icon < 0 ? null : new icon_1.Icon({ icon }),
|
|
212
|
+
new label_1.Label({ flex: 1, text })
|
|
213
|
+
]);
|
|
214
|
+
}
|
|
215
|
+
get id() {
|
|
216
|
+
return this.m_props.itemId;
|
|
217
|
+
}
|
|
218
|
+
get text() {
|
|
219
|
+
return this.m_props.text;
|
|
220
|
+
}
|
|
221
|
+
get isPopup() {
|
|
222
|
+
return !!this.m_props.items;
|
|
223
|
+
}
|
|
224
|
+
_close() {
|
|
225
|
+
this.removeClass('@opened');
|
|
226
|
+
this.m_isOpen = false;
|
|
227
|
+
}
|
|
228
|
+
_click(ev) {
|
|
229
|
+
if (!this.isPopup) {
|
|
230
|
+
this.emit('click', (0, x4_events_1.EvClick)());
|
|
231
|
+
Menu._discardAll();
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
_mousedown(ev) {
|
|
235
|
+
if (this.isPopup) {
|
|
236
|
+
if (!this.m_menu) {
|
|
237
|
+
this.m_menu = new Menu({ items: this.m_props.items }, this);
|
|
238
|
+
}
|
|
239
|
+
let doClose = this.m_isOpen;
|
|
240
|
+
// if parent menu has an opened sub menu, close it
|
|
241
|
+
let parent_menu = component_1.Component.getElement(this.dom, Menu);
|
|
242
|
+
if (parent_menu) {
|
|
243
|
+
parent_menu.hideSubMenu();
|
|
244
|
+
}
|
|
245
|
+
if (!doClose) {
|
|
246
|
+
if (parent_menu) {
|
|
247
|
+
parent_menu.setSubMenu(this.m_menu);
|
|
248
|
+
}
|
|
249
|
+
this.m_isOpen = true;
|
|
250
|
+
let rc = this.getBoundingRect();
|
|
251
|
+
this.m_menu.lock(true);
|
|
252
|
+
if (parent_menu) {
|
|
253
|
+
// standard menu
|
|
254
|
+
this.m_menu.displayAt(rc.right, rc.top);
|
|
255
|
+
}
|
|
256
|
+
else {
|
|
257
|
+
// menubar / menubutton
|
|
258
|
+
this.m_menu.displayAt(rc.left, rc.bottom);
|
|
259
|
+
}
|
|
260
|
+
this.m_menu.lock(false);
|
|
261
|
+
this.addClass('@opened');
|
|
262
|
+
}
|
|
263
|
+
ev.preventDefault();
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
exports.MenuItem = MenuItem;
|
|
268
|
+
/**
|
|
269
|
+
*
|
|
270
|
+
*/
|
|
271
|
+
class MenuBar extends layout_1.HLayout {
|
|
272
|
+
m_items;
|
|
273
|
+
constructor(props, opener) {
|
|
274
|
+
super(props);
|
|
275
|
+
console.assert(false, 'not imp');
|
|
276
|
+
this.addClass('@shadow');
|
|
277
|
+
this.m_items = props.items;
|
|
278
|
+
}
|
|
279
|
+
/** @ignore */
|
|
280
|
+
render() {
|
|
281
|
+
this.setContent(this.m_items);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
exports.MenuBar = MenuBar;
|
package/lib/messagebox.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* ___ ___ __
|
|
3
4
|
* \ \_/ / / _
|
|
@@ -22,13 +23,15 @@
|
|
|
22
23
|
*
|
|
23
24
|
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
24
25
|
**/
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
exports.PromptDialogBox = exports.MessageBox = void 0;
|
|
28
|
+
const dialog_1 = require("./dialog");
|
|
29
|
+
const tools_1 = require("./tools");
|
|
30
|
+
const layout_1 = require("./layout");
|
|
31
|
+
const icon_1 = require("./icon");
|
|
32
|
+
const label_1 = require("./label");
|
|
33
|
+
const textedit_1 = require("./textedit");
|
|
34
|
+
class MessageBox extends dialog_1.Dialog {
|
|
32
35
|
m_label;
|
|
33
36
|
constructor(props) {
|
|
34
37
|
// remove overloaded elements from DialogBoxProps
|
|
@@ -38,11 +41,11 @@ export class MessageBox extends Dialog {
|
|
|
38
41
|
props.buttons = undefined;
|
|
39
42
|
super(props);
|
|
40
43
|
let msg = props.message;
|
|
41
|
-
this.form.updateContent(new HLayout({
|
|
44
|
+
this.form.updateContent(new layout_1.HLayout({
|
|
42
45
|
style: { padding: 8 },
|
|
43
46
|
content: [
|
|
44
|
-
new Icon({ cls: 'icon', icon }),
|
|
45
|
-
this.m_label = new Label({ cls: 'text', text: msg, multiline: true })
|
|
47
|
+
new icon_1.Icon({ cls: 'icon', icon }),
|
|
48
|
+
this.m_label = new label_1.Label({ cls: 'text', text: msg, multiline: true })
|
|
46
49
|
]
|
|
47
50
|
}), buttons);
|
|
48
51
|
this.on('btnClick', (ev) => {
|
|
@@ -50,7 +53,7 @@ export class MessageBox extends Dialog {
|
|
|
50
53
|
if (!this.m_props.click) {
|
|
51
54
|
return;
|
|
52
55
|
}
|
|
53
|
-
asap(() => {
|
|
56
|
+
(0, tools_1.asap)(() => {
|
|
54
57
|
this.m_props.click(ev.button);
|
|
55
58
|
});
|
|
56
59
|
});
|
|
@@ -63,7 +66,7 @@ export class MessageBox extends Dialog {
|
|
|
63
66
|
*/
|
|
64
67
|
static show(props) {
|
|
65
68
|
let msg;
|
|
66
|
-
if (isString(props) || isHtmlString(props)) {
|
|
69
|
+
if ((0, tools_1.isString)(props) || (0, tools_1.isHtmlString)(props)) {
|
|
67
70
|
msg = new MessageBox({ message: props, click: () => { } });
|
|
68
71
|
}
|
|
69
72
|
else {
|
|
@@ -85,7 +88,8 @@ export class MessageBox extends Dialog {
|
|
|
85
88
|
}).show();
|
|
86
89
|
}
|
|
87
90
|
}
|
|
88
|
-
|
|
91
|
+
exports.MessageBox = MessageBox;
|
|
92
|
+
class PromptDialogBox extends dialog_1.Dialog {
|
|
89
93
|
m_edit;
|
|
90
94
|
constructor(props) {
|
|
91
95
|
// remove overloaded elements from DialogBoxProps
|
|
@@ -94,14 +98,14 @@ export class PromptDialogBox extends Dialog {
|
|
|
94
98
|
props.buttons = undefined;
|
|
95
99
|
props.width = props.width ?? 500;
|
|
96
100
|
super(props);
|
|
97
|
-
this.form.updateContent(new HLayout({
|
|
101
|
+
this.form.updateContent(new layout_1.HLayout({
|
|
98
102
|
cls: 'panel',
|
|
99
103
|
content: [
|
|
100
104
|
//icon ? new Icon({
|
|
101
105
|
// cls: 'icon',
|
|
102
106
|
// icon: icon
|
|
103
107
|
//}) : null,
|
|
104
|
-
this.m_edit = new TextEdit({
|
|
108
|
+
this.m_edit = new textedit_1.TextEdit({
|
|
105
109
|
flex: 1,
|
|
106
110
|
autoFocus: true,
|
|
107
111
|
label: props.message,
|
|
@@ -114,7 +118,7 @@ export class PromptDialogBox extends Dialog {
|
|
|
114
118
|
if (ev.button === 'ok') {
|
|
115
119
|
// no prevent default -> always close the messagebox
|
|
116
120
|
// asap to allow
|
|
117
|
-
asap(() => {
|
|
121
|
+
(0, tools_1.asap)(() => {
|
|
118
122
|
this.m_props.click(this.m_edit.value);
|
|
119
123
|
});
|
|
120
124
|
}
|
|
@@ -129,7 +133,7 @@ export class PromptDialogBox extends Dialog {
|
|
|
129
133
|
*/
|
|
130
134
|
static show(props, inputCallback) {
|
|
131
135
|
let msg;
|
|
132
|
-
if (isString(props) || isHtmlString(props)) {
|
|
136
|
+
if ((0, tools_1.isString)(props) || (0, tools_1.isHtmlString)(props)) {
|
|
133
137
|
msg = new PromptDialogBox({ message: props, click: inputCallback });
|
|
134
138
|
}
|
|
135
139
|
else {
|
|
@@ -139,3 +143,4 @@ export class PromptDialogBox extends Dialog {
|
|
|
139
143
|
return msg;
|
|
140
144
|
}
|
|
141
145
|
}
|
|
146
|
+
exports.PromptDialogBox = PromptDialogBox;
|
package/lib/panel.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* ___ ___ __
|
|
3
4
|
* \ \_/ / / _
|
|
@@ -22,26 +23,28 @@
|
|
|
22
23
|
*
|
|
23
24
|
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
24
25
|
**/
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
exports.Panel = void 0;
|
|
28
|
+
const component_1 = require("./component");
|
|
29
|
+
const layout_1 = require("./layout");
|
|
30
|
+
const label_1 = require("./label");
|
|
31
|
+
const icon_1 = require("./icon");
|
|
32
|
+
class Panel extends layout_1.VLayout {
|
|
30
33
|
m_ui_title;
|
|
31
34
|
m_ui_body;
|
|
32
35
|
constructor(props) {
|
|
33
36
|
super(props);
|
|
34
37
|
const sens = props?.sens == 'horizontal' ? '@hlayout' : '@vlayout';
|
|
35
38
|
//todo: cannot be called twice do to content overload
|
|
36
|
-
this.m_ui_title = new Label({ cls: 'title', text: this.m_props.title });
|
|
37
|
-
this.m_ui_body = new Component({ cls: 'body ' + sens, content: this.m_props.content });
|
|
39
|
+
this.m_ui_title = new label_1.Label({ cls: 'title', text: this.m_props.title });
|
|
40
|
+
this.m_ui_body = new component_1.Component({ cls: 'body ' + sens, content: this.m_props.content });
|
|
38
41
|
}
|
|
39
42
|
/** @ignore */
|
|
40
43
|
render() {
|
|
41
44
|
const gadgets = this.m_props.gadgets ?? [];
|
|
42
|
-
const icon = this.m_props.icon ? new Icon({ icon: this.m_props.icon }) : null;
|
|
45
|
+
const icon = this.m_props.icon ? new icon_1.Icon({ icon: this.m_props.icon }) : null;
|
|
43
46
|
super.setContent([
|
|
44
|
-
new HLayout({
|
|
47
|
+
new layout_1.HLayout({
|
|
45
48
|
cls: 'title',
|
|
46
49
|
content: [
|
|
47
50
|
icon,
|
|
@@ -59,3 +62,4 @@ export class Panel extends VLayout {
|
|
|
59
62
|
this.m_ui_title.text = text;
|
|
60
63
|
}
|
|
61
64
|
}
|
|
65
|
+
exports.Panel = Panel;
|
package/lib/popup.d.ts
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ___ ___ __
|
|
3
|
+
* \ \_/ / / _
|
|
4
|
+
* \ / /_| |_
|
|
5
|
+
* / _ \____ _|
|
|
6
|
+
* /__/ \__\ |_|
|
|
7
|
+
*
|
|
8
|
+
* @file popup.ts
|
|
9
|
+
* @author Etienne Cochard
|
|
10
|
+
* @license
|
|
11
|
+
* Copyright (c) 2019-2021 R-libre ingenierie
|
|
12
|
+
*
|
|
13
|
+
* This program is free software; you can redistribute it and/or modify
|
|
14
|
+
* it under the terms of the GNU General Public License as published by
|
|
15
|
+
* the Free Software Foundation; either version 3 of the License, or
|
|
16
|
+
* (at your option) any later version.
|
|
17
|
+
*
|
|
18
|
+
* This program is distributed in the hope that it will be useful,
|
|
19
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
20
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
21
|
+
* GNU General Public License for more details.
|
|
22
|
+
*
|
|
23
|
+
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
24
|
+
**/
|
|
25
|
+
import { Container, CProps, ContainerEventMap, EvSize } from './component';
|
|
26
|
+
import { Point } from './tools';
|
|
27
|
+
import { BasicEvent } from './x4_events';
|
|
28
|
+
export interface EvMove extends BasicEvent {
|
|
29
|
+
pos: Point;
|
|
30
|
+
}
|
|
31
|
+
export declare function EvMove(pos: Point): EvMove;
|
|
32
|
+
export interface PopupEventMap extends ContainerEventMap {
|
|
33
|
+
size: EvSize;
|
|
34
|
+
move: EvMove;
|
|
35
|
+
}
|
|
36
|
+
export interface PopupProps<E extends PopupEventMap = PopupEventMap> extends CProps<E> {
|
|
37
|
+
sizable?: boolean;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* base class for all popup elements
|
|
41
|
+
*/
|
|
42
|
+
export declare class Popup<P extends PopupProps = PopupProps, E extends PopupEventMap = PopupEventMap> extends Container<P, E> {
|
|
43
|
+
protected m_ui_mask: HTMLElement;
|
|
44
|
+
private m_hasMask;
|
|
45
|
+
static modal_stack: HTMLElement[];
|
|
46
|
+
constructor(props: P);
|
|
47
|
+
enableMask(enable?: boolean): void;
|
|
48
|
+
/**
|
|
49
|
+
* display the popup on screen
|
|
50
|
+
*/
|
|
51
|
+
show(modal?: boolean): void;
|
|
52
|
+
centerOnScreen(): void;
|
|
53
|
+
/**
|
|
54
|
+
* display the popup at a specific position
|
|
55
|
+
* @param x
|
|
56
|
+
* @param y
|
|
57
|
+
*/
|
|
58
|
+
displayAt(x: number, y: number, align?: string, offset?: {
|
|
59
|
+
x: any;
|
|
60
|
+
y: any;
|
|
61
|
+
}): void;
|
|
62
|
+
/**
|
|
63
|
+
* close the popup
|
|
64
|
+
*/
|
|
65
|
+
close(): void;
|
|
66
|
+
componentCreated(): void;
|
|
67
|
+
/**
|
|
68
|
+
* resize for 'all' resize attribute
|
|
69
|
+
*/
|
|
70
|
+
private _mouseResize;
|
|
71
|
+
}
|