x4js 1.4.2

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.
Files changed (176) hide show
  1. package/lib/application.d.ts +95 -0
  2. package/lib/application.js +137 -0
  3. package/lib/base64.d.ts +31 -0
  4. package/lib/base64.js +135 -0
  5. package/lib/base_component.d.ts +64 -0
  6. package/lib/base_component.js +77 -0
  7. package/lib/button.d.ts +145 -0
  8. package/lib/button.js +235 -0
  9. package/lib/calendar.d.ts +77 -0
  10. package/lib/calendar.js +236 -0
  11. package/lib/canvas.d.ts +88 -0
  12. package/lib/canvas.js +354 -0
  13. package/lib/cardview.d.ts +83 -0
  14. package/lib/cardview.js +152 -0
  15. package/lib/checkbox.d.ts +72 -0
  16. package/lib/checkbox.js +126 -0
  17. package/lib/color.d.ts +144 -0
  18. package/lib/color.js +584 -0
  19. package/lib/colorpicker.d.ts +98 -0
  20. package/lib/colorpicker.js +1457 -0
  21. package/lib/combobox.d.ts +97 -0
  22. package/lib/combobox.js +246 -0
  23. package/lib/component.d.ts +572 -0
  24. package/lib/component.js +1712 -0
  25. package/lib/datastore.d.ts +392 -0
  26. package/lib/datastore.js +986 -0
  27. package/lib/dialog.d.ts +171 -0
  28. package/lib/dialog.js +468 -0
  29. package/lib/dom_events.d.ts +284 -0
  30. package/lib/dom_events.js +13 -0
  31. package/lib/drag_manager.d.ts +26 -0
  32. package/lib/drag_manager.js +118 -0
  33. package/lib/drawtext.d.ts +43 -0
  34. package/lib/drawtext.js +261 -0
  35. package/lib/fileupload.d.ts +60 -0
  36. package/lib/fileupload.js +158 -0
  37. package/lib/form.d.ts +122 -0
  38. package/lib/form.js +293 -0
  39. package/lib/formatters.d.ts +31 -0
  40. package/lib/formatters.js +75 -0
  41. package/lib/gridview.d.ts +171 -0
  42. package/lib/gridview.js +786 -0
  43. package/lib/hosts/host.d.ts +44 -0
  44. package/lib/hosts/host.js +69 -0
  45. package/lib/i18n.d.ts +67 -0
  46. package/lib/i18n.js +169 -0
  47. package/lib/icon.d.ts +56 -0
  48. package/lib/icon.js +173 -0
  49. package/lib/image.d.ts +51 -0
  50. package/lib/image.js +149 -0
  51. package/lib/index.js +1 -0
  52. package/lib/input.d.ts +86 -0
  53. package/lib/input.js +172 -0
  54. package/lib/label.d.ts +54 -0
  55. package/lib/label.js +86 -0
  56. package/lib/layout.d.ts +77 -0
  57. package/lib/layout.js +261 -0
  58. package/lib/link.d.ts +46 -0
  59. package/lib/link.js +55 -0
  60. package/lib/listview.d.ts +173 -0
  61. package/lib/listview.js +532 -0
  62. package/lib/md5.d.ts +56 -0
  63. package/lib/md5.js +397 -0
  64. package/lib/menu.d.ts +122 -0
  65. package/lib/menu.js +276 -0
  66. package/lib/messagebox.d.ts +64 -0
  67. package/lib/messagebox.js +141 -0
  68. package/lib/panel.d.ts +42 -0
  69. package/lib/panel.js +61 -0
  70. package/lib/popup.d.ts +71 -0
  71. package/lib/popup.js +373 -0
  72. package/lib/property_editor.d.ts +67 -0
  73. package/lib/property_editor.js +247 -0
  74. package/lib/radiobtn.d.ts +68 -0
  75. package/lib/radiobtn.js +131 -0
  76. package/lib/rating.d.ts +49 -0
  77. package/lib/rating.js +93 -0
  78. package/lib/request.d.ts +48 -0
  79. package/lib/request.js +220 -0
  80. package/lib/router.d.ts +13 -0
  81. package/lib/router.js +27 -0
  82. package/lib/settings.d.ts +33 -0
  83. package/lib/settings.js +63 -0
  84. package/lib/sidebarview.d.ts +44 -0
  85. package/lib/sidebarview.js +73 -0
  86. package/lib/smartedit.d.ts +103 -0
  87. package/lib/smartedit.js +381 -0
  88. package/lib/spreadsheet.d.ts +214 -0
  89. package/lib/spreadsheet.js +1073 -0
  90. package/lib/styles.d.ts +81 -0
  91. package/lib/styles.js +262 -0
  92. package/lib/svgcomponent.d.ts +165 -0
  93. package/lib/svgcomponent.js +350 -0
  94. package/lib/tabbar.d.ts +41 -0
  95. package/lib/tabbar.js +66 -0
  96. package/lib/tabview.d.ts +45 -0
  97. package/lib/tabview.js +79 -0
  98. package/lib/textarea.d.ts +59 -0
  99. package/lib/textarea.js +119 -0
  100. package/lib/textedit.d.ts +118 -0
  101. package/lib/textedit.js +406 -0
  102. package/lib/texthiliter.d.ts +56 -0
  103. package/lib/texthiliter.js +219 -0
  104. package/lib/toaster.d.ts +38 -0
  105. package/lib/toaster.js +58 -0
  106. package/lib/tools.d.ts +382 -0
  107. package/lib/tools.js +1096 -0
  108. package/lib/tooltips.d.ts +42 -0
  109. package/lib/tooltips.js +148 -0
  110. package/lib/treeview.d.ts +128 -0
  111. package/lib/treeview.js +490 -0
  112. package/lib/x4_events.d.ts +253 -0
  113. package/lib/x4_events.js +363 -0
  114. package/package.json +21 -0
  115. package/src/README.md +2 -0
  116. package/src/application.ts +191 -0
  117. package/src/base64.ts +162 -0
  118. package/src/base_component.ts +118 -0
  119. package/src/button.ts +327 -0
  120. package/src/calendar.ts +312 -0
  121. package/src/canvas.ts +501 -0
  122. package/src/cardview.ts +220 -0
  123. package/src/checkbox.ts +178 -0
  124. package/src/color.ts +748 -0
  125. package/src/colorpicker.ts +1618 -0
  126. package/src/combobox.ts +348 -0
  127. package/src/component.ts +2330 -0
  128. package/src/datastore.ts +1318 -0
  129. package/src/dialog.ts +631 -0
  130. package/src/dom_events.ts +297 -0
  131. package/src/drag_manager.ts +168 -0
  132. package/src/drawtext.ts +342 -0
  133. package/src/fileupload.ts +208 -0
  134. package/src/form.ts +362 -0
  135. package/src/formatters.ts +96 -0
  136. package/src/gridview.ts +1051 -0
  137. package/src/hosts/electron.ts +161 -0
  138. package/src/hosts/host.ts +100 -0
  139. package/src/hosts/nwjs.ts +141 -0
  140. package/src/hosts/nwjs_types.ts +339 -0
  141. package/src/i18n.ts +205 -0
  142. package/src/icon.ts +237 -0
  143. package/src/image.ts +198 -0
  144. package/src/input.ts +236 -0
  145. package/src/label.ts +124 -0
  146. package/src/layout.ts +366 -0
  147. package/src/link.ts +82 -0
  148. package/src/listview.ts +749 -0
  149. package/src/md5.ts +432 -0
  150. package/src/menu.ts +394 -0
  151. package/src/messagebox.ts +199 -0
  152. package/src/panel.ts +81 -0
  153. package/src/popup.ts +488 -0
  154. package/src/property_editor.ts +333 -0
  155. package/src/radiobtn.ts +190 -0
  156. package/src/rating.ts +131 -0
  157. package/src/request.ts +296 -0
  158. package/src/router.ts +43 -0
  159. package/src/settings.ts +75 -0
  160. package/src/sidebarview.ts +97 -0
  161. package/src/smartedit.ts +532 -0
  162. package/src/spreadsheet.ts +1423 -0
  163. package/src/styles.ts +332 -0
  164. package/src/svgcomponent.ts +440 -0
  165. package/src/tabbar.ts +105 -0
  166. package/src/tabview.ts +106 -0
  167. package/src/textarea.ts +183 -0
  168. package/src/textedit.ts +535 -0
  169. package/src/texthiliter.ts +284 -0
  170. package/src/toaster.ts +76 -0
  171. package/src/tools.ts +1391 -0
  172. package/src/tooltips.ts +185 -0
  173. package/src/treeview.ts +670 -0
  174. package/src/x4.less +1940 -0
  175. package/src/x4_events.ts +558 -0
  176. package/tsconfig.json +14 -0
package/lib/menu.js ADDED
@@ -0,0 +1,276 @@
1
+ /**
2
+ * ___ ___ __
3
+ * \ \_/ / / _
4
+ * \ / /_| |_
5
+ * / _ \____ _|
6
+ * /__/ \__\ |_|
7
+ *
8
+ * @file menu.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 { Component } from './component';
26
+ import { EvClick } from './x4_events';
27
+ import { Popup } from './popup';
28
+ import { Icon } from './icon';
29
+ import { Label } from './label';
30
+ import { HLayout } from './layout';
31
+ import { isString, getMousePos } from './tools';
32
+ // ============================================================================
33
+ // [MENU]
34
+ // ============================================================================
35
+ export class MenuSeparator extends Component {
36
+ }
37
+ export class MenuTitle extends Label {
38
+ }
39
+ export class Menu extends Popup {
40
+ static watchCount = 0;
41
+ static rootMenu = null;
42
+ m_subMenu;
43
+ m_opener;
44
+ m_virtual;
45
+ m_lock;
46
+ constructor(props, opener) {
47
+ super(props);
48
+ this.addClass('@shadow');
49
+ this.m_opener = opener;
50
+ this.m_virtual = false;
51
+ this.m_lock = 0;
52
+ this.enableMask(false);
53
+ }
54
+ lock(yes) {
55
+ this.m_lock += yes ? 1 : -1;
56
+ }
57
+ setVirtual() {
58
+ this.m_virtual = true;
59
+ }
60
+ setSubMenu(menu) {
61
+ this.m_subMenu = menu;
62
+ }
63
+ hideSubMenu() {
64
+ if (this.m_subMenu) {
65
+ this.m_subMenu.m_opener._close();
66
+ this.m_subMenu.hide();
67
+ this.m_subMenu = null;
68
+ }
69
+ }
70
+ /** @ignore */
71
+ render(props) {
72
+ this.setContent(props.items);
73
+ }
74
+ /**
75
+ *
76
+ */
77
+ show() {
78
+ if (!this.m_virtual) {
79
+ Menu._addMenu(this);
80
+ }
81
+ super.show();
82
+ }
83
+ /**
84
+ *
85
+ */
86
+ close() {
87
+ if (!this.dom && !this.m_virtual) {
88
+ return;
89
+ }
90
+ if (this.m_opener) {
91
+ this.m_opener._close();
92
+ }
93
+ if (this.m_subMenu) {
94
+ this.m_subMenu.close();
95
+ this.m_subMenu = null;
96
+ }
97
+ super.close();
98
+ Menu._removeMenu();
99
+ }
100
+ /**
101
+ *
102
+ */
103
+ clear() {
104
+ this.m_props.items = [];
105
+ }
106
+ /**
107
+ * @internal
108
+ */
109
+ static _addMenu(menu) {
110
+ //console.log( 'addmenu' );
111
+ if (Menu.watchCount == 0) {
112
+ Menu.rootMenu = menu;
113
+ document.addEventListener('mousedown', Menu._mouseWatcher);
114
+ }
115
+ Menu.watchCount++;
116
+ }
117
+ static _removeMenu() {
118
+ //console.log( 'removemenu' );
119
+ console.assert(Menu.watchCount > 0);
120
+ Menu.watchCount--;
121
+ if (Menu.watchCount == 0) {
122
+ document.removeEventListener('mousedown', Menu._mouseWatcher);
123
+ }
124
+ }
125
+ static _mouseWatcher(ev) {
126
+ if (ev.defaultPrevented) {
127
+ return;
128
+ }
129
+ let elOn = ev.target;
130
+ while (elOn) {
131
+ // is mouse on a menu
132
+ let mouseon = Component.getElement(elOn);
133
+ if (mouseon && (mouseon instanceof Menu /*|| elOn.$el instanceof Menubar*/)) {
134
+ return;
135
+ }
136
+ elOn = elOn.parentElement;
137
+ }
138
+ Menu._discardAll();
139
+ }
140
+ /**
141
+ * hide all the visible menus
142
+ */
143
+ static _discardAll() {
144
+ if (Menu.rootMenu) {
145
+ Menu.rootMenu.close();
146
+ Menu.rootMenu = null;
147
+ }
148
+ }
149
+ displayAt(...args) {
150
+ if (!this.m_lock) {
151
+ Menu._discardAll();
152
+ }
153
+ let x, y, align, offset;
154
+ if (args.length == 1) {
155
+ ({ x, y } = getMousePos(args[0], true));
156
+ }
157
+ else {
158
+ [x, y, align, offset] = args;
159
+ }
160
+ if (!align) {
161
+ align = 'top left';
162
+ }
163
+ super.displayAt(x, y, align, offset);
164
+ }
165
+ }
166
+ export class MenuItem extends Component {
167
+ m_menu;
168
+ m_isOpen;
169
+ constructor(a, b) {
170
+ if (isString(a)) {
171
+ super({
172
+ text: a,
173
+ click: b
174
+ });
175
+ }
176
+ else {
177
+ super(a);
178
+ }
179
+ this.mapPropEvents(this.m_props, 'click');
180
+ this.m_menu = null;
181
+ this.m_isOpen = false;
182
+ this.setDomEvent('mousedown', (e) => this._mousedown(e));
183
+ this.setDomEvent('click', (e) => this._click(e));
184
+ }
185
+ /** @ignore */
186
+ render(props) {
187
+ let icon = props.icon ?? 0x20;
188
+ let text = props.text;
189
+ if (props.checked !== undefined) {
190
+ icon = props.checked ? 'cls(far fa-check)' : 0; //todo: use stylesheet
191
+ }
192
+ if (this.isPopup) {
193
+ this.addClass('@popup-menu-item');
194
+ }
195
+ if (!text && !icon) {
196
+ this.addClass('@separator');
197
+ }
198
+ if (props.cls) {
199
+ this.addClass(props.cls);
200
+ }
201
+ this.setProp('tag', 'a');
202
+ //@bug: do not kill focus on click
203
+ // this.setAttribute( 'tabindex', '0' );
204
+ this.setContent([
205
+ icon < 0 ? null : new Icon({ icon }),
206
+ new Label({ flex: 1, text })
207
+ ]);
208
+ }
209
+ get id() {
210
+ return this.m_props.itemId;
211
+ }
212
+ get text() {
213
+ return this.m_props.text;
214
+ }
215
+ get isPopup() {
216
+ return !!this.m_props.items;
217
+ }
218
+ _close() {
219
+ this.removeClass('@opened');
220
+ this.m_isOpen = false;
221
+ }
222
+ _click(ev) {
223
+ if (!this.isPopup) {
224
+ this.emit('click', EvClick());
225
+ Menu._discardAll();
226
+ }
227
+ }
228
+ _mousedown(ev) {
229
+ if (this.isPopup) {
230
+ if (!this.m_menu) {
231
+ this.m_menu = new Menu({ items: this.m_props.items }, this);
232
+ }
233
+ let doClose = this.m_isOpen;
234
+ // if parent menu has an opened sub menu, close it
235
+ let parent_menu = Component.getElement(this.dom, Menu);
236
+ if (parent_menu) {
237
+ parent_menu.hideSubMenu();
238
+ }
239
+ if (!doClose) {
240
+ if (parent_menu) {
241
+ parent_menu.setSubMenu(this.m_menu);
242
+ }
243
+ this.m_isOpen = true;
244
+ let rc = this.getBoundingRect();
245
+ this.m_menu.lock(true);
246
+ if (parent_menu) {
247
+ // standard menu
248
+ this.m_menu.displayAt(rc.right, rc.top);
249
+ }
250
+ else {
251
+ // menubar / menubutton
252
+ this.m_menu.displayAt(rc.left, rc.bottom);
253
+ }
254
+ this.m_menu.lock(false);
255
+ this.addClass('@opened');
256
+ }
257
+ ev.preventDefault();
258
+ }
259
+ }
260
+ }
261
+ /**
262
+ *
263
+ */
264
+ export class MenuBar extends HLayout {
265
+ m_items;
266
+ constructor(props, opener) {
267
+ super(props);
268
+ console.assert(false, 'not imp');
269
+ this.addClass('@shadow');
270
+ this.m_items = props.items;
271
+ }
272
+ /** @ignore */
273
+ render() {
274
+ this.setContent(this.m_items);
275
+ }
276
+ }
@@ -0,0 +1,64 @@
1
+ /**
2
+ * ___ ___ __
3
+ * \ \_/ / / _
4
+ * \ / /_| |_
5
+ * / _ \____ _|
6
+ * /__/ \__\ |_|
7
+ *
8
+ * @file messagebox.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 { Dialog, DialogProps } from './dialog';
26
+ import { HtmlString } from './tools';
27
+ import { IconID } from './icon';
28
+ import { Label } from './label';
29
+ import { TextEdit } from './textedit';
30
+ /**
31
+ * [ MESSAGEBOX ] -----------------------------------------------------------------
32
+ */
33
+ export interface MessageBoxProps extends DialogProps {
34
+ message: string | HtmlString;
35
+ click: (button: string) => void;
36
+ }
37
+ export declare class MessageBox extends Dialog<MessageBoxProps> {
38
+ m_label: Label;
39
+ constructor(props: MessageBoxProps);
40
+ set text(txt: string | HtmlString);
41
+ /**
42
+ * display a messagebox
43
+ */
44
+ static show(props: string | HtmlString | MessageBoxProps): MessageBox;
45
+ /**
46
+ * display an alert message
47
+ */
48
+ static alert(text: string | HtmlString, title?: string): void;
49
+ }
50
+ export interface PromptBoxProps extends DialogProps {
51
+ message: string | HtmlString;
52
+ value?: string;
53
+ icon?: IconID;
54
+ click: (value: string) => void;
55
+ }
56
+ export declare class PromptDialogBox extends Dialog<PromptBoxProps> {
57
+ m_edit: TextEdit;
58
+ constructor(props: PromptBoxProps);
59
+ set text(txt: string | HtmlString);
60
+ /**
61
+ * display a messagebox
62
+ */
63
+ static show(props: string | HtmlString | PromptBoxProps, inputCallback?: (input: string) => void): PromptBoxProps;
64
+ }
@@ -0,0 +1,141 @@
1
+ /**
2
+ * ___ ___ __
3
+ * \ \_/ / / _
4
+ * \ / /_| |_
5
+ * / _ \____ _|
6
+ * /__/ \__\ |_|
7
+ *
8
+ * @file messagebox.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 { Dialog } from './dialog';
26
+ import { asap, isHtmlString, isString } from './tools';
27
+ import { HLayout } from './layout';
28
+ import { Icon } from './icon';
29
+ import { Label } from './label';
30
+ import { TextEdit } from './textedit';
31
+ export class MessageBox extends Dialog {
32
+ m_label;
33
+ constructor(props) {
34
+ // remove overloaded elements from DialogBoxProps
35
+ let icon = props.icon ?? 'cls(far fa-circle-exclamation)'; // todo: resolve that
36
+ props.icon = undefined;
37
+ let buttons = props.buttons === undefined ? ['ok'] : props.buttons;
38
+ props.buttons = undefined;
39
+ super(props);
40
+ let msg = props.message;
41
+ this.form.updateContent(new HLayout({
42
+ style: { padding: 8 },
43
+ content: [
44
+ new Icon({ cls: 'icon', icon }),
45
+ this.m_label = new Label({ cls: 'text', text: msg, multiline: true })
46
+ ]
47
+ }), buttons);
48
+ this.on('btnClick', (ev) => {
49
+ // no prevent default -> always close the messagebox
50
+ if (!this.m_props.click) {
51
+ return;
52
+ }
53
+ asap(() => {
54
+ this.m_props.click(ev.button);
55
+ });
56
+ });
57
+ }
58
+ set text(txt) {
59
+ this.m_label.text = txt;
60
+ }
61
+ /**
62
+ * display a messagebox
63
+ */
64
+ static show(props) {
65
+ let msg;
66
+ if (isString(props) || isHtmlString(props)) {
67
+ msg = new MessageBox({ message: props, click: () => { } });
68
+ }
69
+ else {
70
+ msg = new MessageBox(props);
71
+ }
72
+ msg.show();
73
+ return msg;
74
+ }
75
+ /**
76
+ * display an alert message
77
+ */
78
+ static alert(text, title = null) {
79
+ new MessageBox({
80
+ cls: 'warning',
81
+ title,
82
+ message: text,
83
+ buttons: ['ok'],
84
+ click: () => { },
85
+ }).show();
86
+ }
87
+ }
88
+ export class PromptDialogBox extends Dialog {
89
+ m_edit;
90
+ constructor(props) {
91
+ // remove overloaded elements from DialogBoxProps
92
+ //let icon = props.icon; // ?? 'cls(far fa-comment-check)'; // todo: resolve that
93
+ //props.icon = undefined;
94
+ props.buttons = undefined;
95
+ props.width = props.width ?? 500;
96
+ super(props);
97
+ this.form.updateContent(new HLayout({
98
+ cls: 'panel',
99
+ content: [
100
+ //icon ? new Icon({
101
+ // cls: 'icon',
102
+ // icon: icon
103
+ //}) : null,
104
+ this.m_edit = new TextEdit({
105
+ flex: 1,
106
+ autoFocus: true,
107
+ label: props.message,
108
+ value: props.value
109
+ }),
110
+ ]
111
+ }), ['ok', 'cancel']);
112
+ if (props.click) {
113
+ this.on('btnClick', (ev) => {
114
+ if (ev.button === 'ok') {
115
+ // no prevent default -> always close the messagebox
116
+ // asap to allow
117
+ asap(() => {
118
+ this.m_props.click(this.m_edit.value);
119
+ });
120
+ }
121
+ });
122
+ }
123
+ }
124
+ set text(txt) {
125
+ this.m_edit.label = txt;
126
+ }
127
+ /**
128
+ * display a messagebox
129
+ */
130
+ static show(props, inputCallback) {
131
+ let msg;
132
+ if (isString(props) || isHtmlString(props)) {
133
+ msg = new PromptDialogBox({ message: props, click: inputCallback });
134
+ }
135
+ else {
136
+ msg = new PromptDialogBox(props);
137
+ }
138
+ msg.show();
139
+ return msg;
140
+ }
141
+ }
package/lib/panel.d.ts ADDED
@@ -0,0 +1,42 @@
1
+ /**
2
+ * ___ ___ __
3
+ * \ \_/ / / _
4
+ * \ / /_| |_
5
+ * / _ \____ _|
6
+ * /__/ \__\ |_|
7
+ *
8
+ * @file panel.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 { Component, ComponentContent, ContainerProps, ContainerEventMap } from './component';
26
+ import { VLayout } from './layout';
27
+ import { IconID } from './icon';
28
+ export interface PanelProps<E extends ContainerEventMap = ContainerEventMap> extends ContainerProps<E> {
29
+ icon?: IconID;
30
+ title: string;
31
+ gadgets?: Component[];
32
+ sens?: 'horizontal' | 'vertical';
33
+ }
34
+ export declare class Panel<T extends PanelProps = PanelProps, E extends ContainerEventMap = ContainerEventMap> extends VLayout<T, E> {
35
+ private m_ui_title;
36
+ private m_ui_body;
37
+ constructor(props: T);
38
+ /** @ignore */
39
+ render(): void;
40
+ setContent(els: ComponentContent): void;
41
+ set title(text: string);
42
+ }
package/lib/panel.js ADDED
@@ -0,0 +1,61 @@
1
+ /**
2
+ * ___ ___ __
3
+ * \ \_/ / / _
4
+ * \ / /_| |_
5
+ * / _ \____ _|
6
+ * /__/ \__\ |_|
7
+ *
8
+ * @file panel.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 { Component } from './component';
26
+ import { VLayout, HLayout } from './layout';
27
+ import { Label } from './label';
28
+ import { Icon } from './icon';
29
+ export class Panel extends VLayout {
30
+ m_ui_title;
31
+ m_ui_body;
32
+ constructor(props) {
33
+ super(props);
34
+ const sens = props?.sens == 'horizontal' ? '@hlayout' : '@vlayout';
35
+ //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 });
38
+ }
39
+ /** @ignore */
40
+ render() {
41
+ const gadgets = this.m_props.gadgets ?? [];
42
+ const icon = this.m_props.icon ? new Icon({ icon: this.m_props.icon }) : null;
43
+ super.setContent([
44
+ new HLayout({
45
+ cls: 'title',
46
+ content: [
47
+ icon,
48
+ this.m_ui_title,
49
+ ...gadgets
50
+ ]
51
+ }),
52
+ this.m_ui_body
53
+ ]);
54
+ }
55
+ setContent(els) {
56
+ this.m_ui_body.setContent(els);
57
+ }
58
+ set title(text) {
59
+ this.m_ui_title.text = text;
60
+ }
61
+ }
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
+ }