x4js 1.5.17 → 1.5.20

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 (242) hide show
  1. package/lib/{README.md → README.txt} +0 -0
  2. package/lib/cjs/index.js +39 -103
  3. package/lib/cjs/index.js.map +7 -0
  4. package/lib/esm/index.mjs +39 -87
  5. package/lib/esm/index.mjs.map +7 -0
  6. package/lib/{license.md → licence.md} +0 -0
  7. package/lib/src/MIT-license.md +14 -0
  8. package/lib/{types/action.d.ts → src/action.ts} +64 -33
  9. package/lib/src/alpha.jpg +0 -0
  10. package/lib/src/app_sockets.ts +81 -0
  11. package/lib/src/application.ts +251 -0
  12. package/lib/src/autocomplete.ts +197 -0
  13. package/lib/src/base64.ts +166 -0
  14. package/lib/src/base_component.ts +152 -0
  15. package/lib/src/button.ts +355 -0
  16. package/lib/src/calendar.ts +328 -0
  17. package/lib/src/canvas.ts +505 -0
  18. package/lib/src/cardview.ts +227 -0
  19. package/lib/src/checkbox.ts +188 -0
  20. package/lib/src/color.ts +752 -0
  21. package/lib/src/colorpicker.ts +1639 -0
  22. package/lib/src/combobox.ts +465 -0
  23. package/lib/src/component.ts +2329 -0
  24. package/lib/{esm/dom_events.js → src/copyright.txt} +27 -29
  25. package/lib/src/datastore.ts +1322 -0
  26. package/lib/src/dialog.ts +656 -0
  27. package/lib/src/dom_events.ts +315 -0
  28. package/lib/src/drag_manager.ts +199 -0
  29. package/lib/src/drawtext.ts +355 -0
  30. package/lib/src/fileupload.ts +213 -0
  31. package/lib/src/form.ts +375 -0
  32. package/lib/src/formatters.ts +105 -0
  33. package/lib/src/gridview.ts +1185 -0
  34. package/lib/src/i18n.ts +346 -0
  35. package/lib/src/icon.ts +335 -0
  36. package/lib/src/image.ts +204 -0
  37. package/lib/src/index.ts +89 -0
  38. package/lib/src/input.ts +249 -0
  39. package/lib/src/label.ts +128 -0
  40. package/lib/src/layout.ts +430 -0
  41. package/lib/src/link.ts +86 -0
  42. package/lib/src/listview.ts +765 -0
  43. package/lib/{esm/md5.js → src/md5.ts} +438 -403
  44. package/lib/src/menu.ts +425 -0
  45. package/lib/src/messagebox.ts +224 -0
  46. package/lib/src/panel.ts +86 -0
  47. package/lib/src/popup.ts +494 -0
  48. package/lib/src/property_editor.ts +337 -0
  49. package/lib/src/radiobtn.ts +197 -0
  50. package/lib/src/rating.ts +135 -0
  51. package/lib/src/request.ts +300 -0
  52. package/lib/src/router.ts +185 -0
  53. package/lib/src/settings.ts +77 -0
  54. package/lib/src/sidebarview.ts +103 -0
  55. package/lib/src/spreadsheet.ts +1449 -0
  56. package/lib/src/styles.ts +343 -0
  57. package/lib/src/svgcomponent.ts +577 -0
  58. package/lib/src/tabbar.ts +151 -0
  59. package/lib/src/tabview.ts +110 -0
  60. package/lib/src/textarea.ts +235 -0
  61. package/lib/src/textedit.ts +544 -0
  62. package/lib/src/toaster.ts +80 -0
  63. package/lib/src/tools.ts +1473 -0
  64. package/lib/src/tooltips.ts +191 -0
  65. package/lib/src/treeview.ts +716 -0
  66. package/lib/{esm/version.js → src/version.ts} +30 -29
  67. package/lib/{styles → src}/x4.less +0 -0
  68. package/lib/src/x4dom.ts +57 -0
  69. package/lib/src/x4events.ts +585 -0
  70. package/lib/src/x4react.ts +90 -0
  71. package/package.json +52 -49
  72. package/lib/cjs/action.js +0 -58
  73. package/lib/cjs/app_sockets.js +0 -74
  74. package/lib/cjs/application.js +0 -182
  75. package/lib/cjs/autocomplete.js +0 -155
  76. package/lib/cjs/base_component.js +0 -124
  77. package/lib/cjs/button.js +0 -263
  78. package/lib/cjs/calendar.js +0 -254
  79. package/lib/cjs/canvas.js +0 -361
  80. package/lib/cjs/cardview.js +0 -161
  81. package/lib/cjs/checkbox.js +0 -139
  82. package/lib/cjs/color.js +0 -591
  83. package/lib/cjs/colorpicker.js +0 -1468
  84. package/lib/cjs/combobox.js +0 -349
  85. package/lib/cjs/component.js +0 -1719
  86. package/lib/cjs/datastore.js +0 -985
  87. package/lib/cjs/dialog.js +0 -478
  88. package/lib/cjs/dom_events.js +0 -30
  89. package/lib/cjs/drag_manager.js +0 -145
  90. package/lib/cjs/drawtext.js +0 -276
  91. package/lib/cjs/fileupload.js +0 -167
  92. package/lib/cjs/form.js +0 -304
  93. package/lib/cjs/formatters.js +0 -90
  94. package/lib/cjs/gridview.js +0 -881
  95. package/lib/cjs/i18n.js +0 -266
  96. package/lib/cjs/icon.js +0 -272
  97. package/lib/cjs/image.js +0 -157
  98. package/lib/cjs/input.js +0 -174
  99. package/lib/cjs/label.js +0 -95
  100. package/lib/cjs/layout.js +0 -322
  101. package/lib/cjs/link.js +0 -64
  102. package/lib/cjs/listview.js +0 -546
  103. package/lib/cjs/md5.js +0 -403
  104. package/lib/cjs/menu.js +0 -301
  105. package/lib/cjs/messagebox.js +0 -177
  106. package/lib/cjs/panel.js +0 -68
  107. package/lib/cjs/popup.js +0 -383
  108. package/lib/cjs/property_editor.js +0 -252
  109. package/lib/cjs/radiobtn.js +0 -140
  110. package/lib/cjs/rating.js +0 -102
  111. package/lib/cjs/request.js +0 -246
  112. package/lib/cjs/router.js +0 -139
  113. package/lib/cjs/settings.js +0 -69
  114. package/lib/cjs/sidebarview.js +0 -82
  115. package/lib/cjs/spreadsheet.js +0 -1084
  116. package/lib/cjs/styles.js +0 -275
  117. package/lib/cjs/svgcomponent.js +0 -447
  118. package/lib/cjs/tabbar.js +0 -111
  119. package/lib/cjs/tabview.js +0 -85
  120. package/lib/cjs/textarea.js +0 -165
  121. package/lib/cjs/textedit.js +0 -415
  122. package/lib/cjs/toaster.js +0 -64
  123. package/lib/cjs/tools.js +0 -1197
  124. package/lib/cjs/tooltips.js +0 -157
  125. package/lib/cjs/treeview.js +0 -535
  126. package/lib/cjs/version.js +0 -32
  127. package/lib/cjs/x4dom.js +0 -32
  128. package/lib/cjs/x4events.js +0 -384
  129. package/lib/cjs/x4react.js +0 -72
  130. package/lib/esm/action.js +0 -53
  131. package/lib/esm/app_sockets.js +0 -70
  132. package/lib/esm/application.js +0 -184
  133. package/lib/esm/autocomplete.js +0 -155
  134. package/lib/esm/base_component.js +0 -107
  135. package/lib/esm/button.js +0 -257
  136. package/lib/esm/calendar.js +0 -249
  137. package/lib/esm/canvas.js +0 -358
  138. package/lib/esm/cardview.js +0 -159
  139. package/lib/esm/checkbox.js +0 -134
  140. package/lib/esm/color.js +0 -588
  141. package/lib/esm/colorpicker.js +0 -1475
  142. package/lib/esm/combobox.js +0 -351
  143. package/lib/esm/component.js +0 -1711
  144. package/lib/esm/datastore.js +0 -990
  145. package/lib/esm/dialog.js +0 -490
  146. package/lib/esm/drag_manager.js +0 -147
  147. package/lib/esm/drawtext.js +0 -271
  148. package/lib/esm/fileupload.js +0 -163
  149. package/lib/esm/form.js +0 -304
  150. package/lib/esm/formatters.js +0 -81
  151. package/lib/esm/gridview.js +0 -889
  152. package/lib/esm/i18n.js +0 -257
  153. package/lib/esm/icon.js +0 -261
  154. package/lib/esm/image.js +0 -154
  155. package/lib/esm/input.js +0 -182
  156. package/lib/esm/label.js +0 -90
  157. package/lib/esm/layout.js +0 -310
  158. package/lib/esm/link.js +0 -59
  159. package/lib/esm/listview.js +0 -534
  160. package/lib/esm/menu.js +0 -300
  161. package/lib/esm/messagebox.js +0 -161
  162. package/lib/esm/panel.js +0 -65
  163. package/lib/esm/popup.js +0 -379
  164. package/lib/esm/property_editor.js +0 -251
  165. package/lib/esm/radiobtn.js +0 -136
  166. package/lib/esm/rating.js +0 -97
  167. package/lib/esm/request.js +0 -224
  168. package/lib/esm/router.js +0 -136
  169. package/lib/esm/settings.js +0 -66
  170. package/lib/esm/sidebarview.js +0 -79
  171. package/lib/esm/spreadsheet.js +0 -1097
  172. package/lib/esm/styles.js +0 -270
  173. package/lib/esm/svgcomponent.js +0 -450
  174. package/lib/esm/tabbar.js +0 -107
  175. package/lib/esm/tabview.js +0 -83
  176. package/lib/esm/textarea.js +0 -160
  177. package/lib/esm/textedit.js +0 -412
  178. package/lib/esm/toaster.js +0 -62
  179. package/lib/esm/tools.js +0 -1158
  180. package/lib/esm/tooltips.js +0 -153
  181. package/lib/esm/treeview.js +0 -527
  182. package/lib/esm/x4dom.js +0 -29
  183. package/lib/esm/x4events.js +0 -376
  184. package/lib/esm/x4react.js +0 -71
  185. package/lib/types/app_sockets.d.ts +0 -29
  186. package/lib/types/application.d.ts +0 -104
  187. package/lib/types/autocomplete.d.ts +0 -58
  188. package/lib/types/base_component.d.ts +0 -88
  189. package/lib/types/button.d.ts +0 -151
  190. package/lib/types/calendar.d.ts +0 -82
  191. package/lib/types/canvas.d.ts +0 -92
  192. package/lib/types/cardview.d.ts +0 -87
  193. package/lib/types/checkbox.d.ts +0 -77
  194. package/lib/types/color.d.ts +0 -148
  195. package/lib/types/colorpicker.d.ts +0 -107
  196. package/lib/types/combobox.d.ts +0 -107
  197. package/lib/types/component.d.ts +0 -601
  198. package/lib/types/datastore.d.ts +0 -396
  199. package/lib/types/dialog.d.ts +0 -175
  200. package/lib/types/dom_events.d.ts +0 -302
  201. package/lib/types/drag_manager.d.ts +0 -54
  202. package/lib/types/drawtext.d.ts +0 -48
  203. package/lib/types/fileupload.d.ts +0 -64
  204. package/lib/types/form.d.ts +0 -133
  205. package/lib/types/formatters.d.ts +0 -35
  206. package/lib/types/gridview.d.ts +0 -175
  207. package/lib/types/i18n.d.ts +0 -73
  208. package/lib/types/icon.d.ts +0 -64
  209. package/lib/types/image.d.ts +0 -55
  210. package/lib/types/index.d.ts +0 -84
  211. package/lib/types/input.d.ts +0 -91
  212. package/lib/types/label.d.ts +0 -58
  213. package/lib/types/layout.d.ts +0 -87
  214. package/lib/types/link.d.ts +0 -50
  215. package/lib/types/listview.d.ts +0 -178
  216. package/lib/types/md5.d.ts +0 -61
  217. package/lib/types/menu.d.ts +0 -130
  218. package/lib/types/messagebox.d.ts +0 -69
  219. package/lib/types/panel.d.ts +0 -47
  220. package/lib/types/popup.d.ts +0 -75
  221. package/lib/types/property_editor.d.ts +0 -71
  222. package/lib/types/radiobtn.d.ts +0 -73
  223. package/lib/types/rating.d.ts +0 -53
  224. package/lib/types/request.d.ts +0 -52
  225. package/lib/types/router.d.ts +0 -42
  226. package/lib/types/settings.d.ts +0 -37
  227. package/lib/types/sidebarview.d.ts +0 -49
  228. package/lib/types/spreadsheet.d.ts +0 -222
  229. package/lib/types/styles.d.ts +0 -85
  230. package/lib/types/svgcomponent.d.ts +0 -215
  231. package/lib/types/tabbar.d.ts +0 -58
  232. package/lib/types/tabview.d.ts +0 -49
  233. package/lib/types/textarea.d.ts +0 -77
  234. package/lib/types/textedit.d.ts +0 -123
  235. package/lib/types/toaster.d.ts +0 -42
  236. package/lib/types/tools.d.ts +0 -394
  237. package/lib/types/tooltips.d.ts +0 -46
  238. package/lib/types/treeview.d.ts +0 -144
  239. package/lib/types/version.d.ts +0 -29
  240. package/lib/types/x4dom.d.ts +0 -49
  241. package/lib/types/x4events.d.ts +0 -269
  242. package/lib/types/x4react.d.ts +0 -41
package/lib/esm/menu.js DELETED
@@ -1,300 +0,0 @@
1
- /**
2
- * ___ ___ __
3
- * \ \_/ / / _
4
- * \ / /_| |_
5
- * / _ \____ _|
6
- * /__/ \__\ |_|
7
- *
8
- * @file menu.ts
9
- * @author Etienne Cochard
10
- *
11
- * Copyright (c) 2019-2022 R-libre ingenierie
12
- *
13
- * Permission is hereby granted, free of charge, to any person obtaining a copy
14
- * of this software and associated documentation files (the "Software"), to deal
15
- * in the Software without restriction, including without limitation the rights
16
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
17
- * of the Software, and to permit persons to whom the Software is furnished to do so,
18
- * subject to the following conditions:
19
- * The above copyright notice and this permission notice shall be included in all copies
20
- * or substantial portions of the Software.
21
- *
22
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
23
- * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
24
- * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
25
- * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
27
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28
- **/
29
- import { x4document } from './x4dom';
30
- import { Component } from './component';
31
- import { EvClick } from './x4events';
32
- import { Action } from './action';
33
- import { Popup } from './popup';
34
- import { Icon } from './icon';
35
- import { Label } from './label';
36
- import { HLayout } from './layout';
37
- import { isString, getMousePos } from './tools';
38
- // ============================================================================
39
- // [MENU]
40
- // ============================================================================
41
- export class MenuSeparator extends Component {
42
- }
43
- export class MenuTitle extends Label {
44
- }
45
- export class Menu extends Popup {
46
- static watchCount = 0;
47
- static rootMenu = null;
48
- m_subMenu;
49
- m_opener;
50
- m_virtual;
51
- m_lock;
52
- constructor(props, opener) {
53
- super(props);
54
- this.addClass('@shadow');
55
- this.m_opener = opener;
56
- this.m_virtual = false;
57
- this.m_lock = 0;
58
- this.enableMask(false);
59
- }
60
- lock(yes) {
61
- this.m_lock += yes ? 1 : -1;
62
- }
63
- setVirtual() {
64
- this.m_virtual = true;
65
- }
66
- setSubMenu(menu) {
67
- this.m_subMenu = menu;
68
- }
69
- hideSubMenu() {
70
- if (this.m_subMenu) {
71
- this.m_subMenu.m_opener._close();
72
- this.m_subMenu.hide();
73
- this.m_subMenu = null;
74
- }
75
- }
76
- /** @ignore */
77
- render(props) {
78
- this.setContent(props.items);
79
- }
80
- /**
81
- *
82
- */
83
- show() {
84
- if (!this.m_virtual) {
85
- Menu._addMenu(this);
86
- }
87
- super.show();
88
- }
89
- /**
90
- *
91
- */
92
- close() {
93
- if (!this.dom && !this.m_virtual) {
94
- return;
95
- }
96
- if (this.m_opener) {
97
- this.m_opener._close();
98
- }
99
- if (this.m_subMenu) {
100
- this.m_subMenu.close();
101
- this.m_subMenu = null;
102
- }
103
- super.close();
104
- Menu._removeMenu();
105
- }
106
- /**
107
- *
108
- */
109
- clear() {
110
- this.m_props.items = [];
111
- }
112
- /**
113
- * @internal
114
- */
115
- static _addMenu(menu) {
116
- //console.log( 'addmenu' );
117
- if (Menu.watchCount == 0) {
118
- Menu.rootMenu = menu;
119
- x4document.addEventListener('mousedown', Menu._mouseWatcher);
120
- }
121
- Menu.watchCount++;
122
- }
123
- static _removeMenu() {
124
- //console.log( 'removemenu' );
125
- console.assert(Menu.watchCount > 0);
126
- Menu.watchCount--;
127
- if (Menu.watchCount == 0) {
128
- x4document.removeEventListener('mousedown', Menu._mouseWatcher);
129
- }
130
- }
131
- static _mouseWatcher(ev) {
132
- if (ev.defaultPrevented) {
133
- return;
134
- }
135
- let elOn = ev.target;
136
- while (elOn) {
137
- // is mouse on a menu
138
- let mouseon = Component.getElement(elOn);
139
- if (mouseon && (mouseon instanceof Menu /*|| elOn.$el instanceof Menubar*/)) {
140
- return;
141
- }
142
- elOn = elOn.parentElement;
143
- }
144
- Menu._discardAll();
145
- }
146
- /**
147
- * hide all the visible menus
148
- */
149
- static _discardAll() {
150
- if (Menu.rootMenu) {
151
- Menu.rootMenu.close();
152
- Menu.rootMenu = null;
153
- }
154
- }
155
- displayAt(...args) {
156
- if (!this.m_lock) {
157
- Menu._discardAll();
158
- }
159
- let x, y, align, offset;
160
- if (args.length == 1) {
161
- ({ x, y } = getMousePos(args[0], true));
162
- }
163
- else {
164
- [x, y, align, offset] = args;
165
- }
166
- if (!align) {
167
- align = 'top left';
168
- }
169
- super.displayAt(x, y, align, offset);
170
- }
171
- }
172
- export class MenuItem extends Component {
173
- m_menu;
174
- m_isOpen;
175
- m_action;
176
- constructor(a, b) {
177
- if (a instanceof Action) {
178
- super({
179
- click: () => { a.fire(); }
180
- });
181
- this.m_action = a;
182
- }
183
- else if (isString(a)) {
184
- super({
185
- text: a,
186
- click: b
187
- });
188
- }
189
- else {
190
- super(a);
191
- }
192
- this.mapPropEvents(this.m_props, 'click');
193
- this.m_menu = null;
194
- this.m_isOpen = false;
195
- this.setDomEvent('mousedown', (e) => this._mousedown(e));
196
- this.setDomEvent('click', (e) => this._click(e));
197
- }
198
- /** @ignore */
199
- render(props) {
200
- let icon = props.icon ?? 0;
201
- let text = props.text;
202
- if (props.checked !== undefined) {
203
- icon = props.checked ? 'var( --x4-icon-check )' : 0;
204
- }
205
- if (this.m_action) {
206
- if (!icon) {
207
- icon = this.m_action.props.icon;
208
- }
209
- if (text === undefined) {
210
- text = this.m_action.props.text;
211
- }
212
- }
213
- let popIco = null;
214
- if (this.isPopup) {
215
- this.addClass('@popup-menu-item');
216
- popIco = new Icon({ icon: "var( --x4-icon-chevron-right )", cls: "pop-mark" });
217
- }
218
- if (!text && !icon) {
219
- this.addClass('@separator');
220
- }
221
- if (props.cls) {
222
- this.addClass(props.cls);
223
- }
224
- this.setTag('a');
225
- //@bug: do not kill focus on click
226
- // this.setAttribute( 'tabindex', '0' );
227
- this.setContent([
228
- icon < 0 ? null : new Icon({ icon }),
229
- new Label({ flex: 1, text }),
230
- popIco
231
- ]);
232
- }
233
- get id() {
234
- return this.m_props.itemId;
235
- }
236
- get text() {
237
- return this.m_props.text;
238
- }
239
- get isPopup() {
240
- return !!this.m_props.items;
241
- }
242
- _close() {
243
- this.removeClass('@opened');
244
- this.m_isOpen = false;
245
- }
246
- _click(ev) {
247
- if (!this.isPopup) {
248
- this.emit('click', EvClick());
249
- Menu._discardAll();
250
- }
251
- }
252
- _mousedown(ev) {
253
- if (this.isPopup) {
254
- if (!this.m_menu) {
255
- this.m_menu = new Menu({ items: this.m_props.items }, this);
256
- }
257
- let doClose = this.m_isOpen;
258
- // if parent menu has an opened sub menu, close it
259
- let parent_menu = Component.getElement(this.dom, Menu);
260
- if (parent_menu) {
261
- parent_menu.hideSubMenu();
262
- }
263
- if (!doClose) {
264
- if (parent_menu) {
265
- parent_menu.setSubMenu(this.m_menu);
266
- }
267
- this.m_isOpen = true;
268
- let rc = this.getBoundingRect();
269
- this.m_menu.lock(true);
270
- if (parent_menu) {
271
- // standard menu
272
- this.m_menu.displayAt(rc.right, rc.top);
273
- }
274
- else {
275
- // menubar / menubutton
276
- this.m_menu.displayAt(rc.left, rc.bottom);
277
- }
278
- this.m_menu.lock(false);
279
- this.addClass('@opened');
280
- }
281
- ev.preventDefault();
282
- }
283
- }
284
- }
285
- /**
286
- *
287
- */
288
- export class MenuBar extends HLayout {
289
- m_items;
290
- constructor(props, opener) {
291
- super(props);
292
- console.assert(false, 'not imp');
293
- this.addClass('@shadow');
294
- this.m_items = props.items;
295
- }
296
- /** @ignore */
297
- render() {
298
- this.setContent(this.m_items);
299
- }
300
- }
@@ -1,161 +0,0 @@
1
- /**
2
- * ___ ___ __
3
- * \ \_/ / / _
4
- * \ / /_| |_
5
- * / _ \____ _|
6
- * /__/ \__\ |_|
7
- *
8
- * @file messagebox.ts
9
- * @author Etienne Cochard
10
- *
11
- * Copyright (c) 2019-2022 R-libre ingenierie
12
- *
13
- * Permission is hereby granted, free of charge, to any person obtaining a copy
14
- * of this software and associated documentation files (the "Software"), to deal
15
- * in the Software without restriction, including without limitation the rights
16
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
17
- * of the Software, and to permit persons to whom the Software is furnished to do so,
18
- * subject to the following conditions:
19
- * The above copyright notice and this permission notice shall be included in all copies
20
- * or substantial portions of the Software.
21
- *
22
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
23
- * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
24
- * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
25
- * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
27
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28
- **/
29
- import { Dialog } from './dialog';
30
- import { asap, isHtmlString, isString } from './tools';
31
- import { HLayout } from './layout';
32
- import { Icon } from './icon';
33
- import { Label } from './label';
34
- import { TextEdit } from './textedit';
35
- export class MessageBox extends Dialog {
36
- m_label;
37
- constructor(props) {
38
- // remove overloaded elements from DialogBoxProps
39
- let icon = props.icon ?? 'var( --x4-icon-exclamation )'; // todo: resolve that
40
- props.icon = undefined;
41
- let buttons = props.buttons === undefined ? ['ok'] : props.buttons;
42
- props.buttons = undefined;
43
- super(props);
44
- let msg = props.message;
45
- this.form.updateContent(new HLayout({
46
- style: { padding: 8 },
47
- content: [
48
- icon ? new Icon({ cls: 'icon', icon }) : null,
49
- this.m_label = new Label({ cls: 'text', text: msg, multiline: true })
50
- ]
51
- }), buttons);
52
- this.on('btnClick', (ev) => {
53
- // no prevent default -> always close the messagebox
54
- if (!this.m_props.click) {
55
- return;
56
- }
57
- asap(() => {
58
- this.m_props.click(ev.button);
59
- });
60
- });
61
- }
62
- set text(txt) {
63
- this.m_label.text = txt;
64
- }
65
- /**
66
- * display a messagebox
67
- */
68
- static show(props) {
69
- let msg;
70
- if (isString(props) || isHtmlString(props)) {
71
- msg = new MessageBox({ message: props, click: () => { } });
72
- }
73
- else {
74
- msg = new MessageBox(props);
75
- }
76
- msg.show();
77
- return msg;
78
- }
79
- static async showAsync(props) {
80
- return new Promise((resolve, reject) => {
81
- let _props;
82
- const cb = (btn) => {
83
- resolve(btn);
84
- };
85
- if (isString(props) || isHtmlString(props)) {
86
- _props = { message: props, click: cb };
87
- }
88
- else {
89
- _props = { ...props, click: cb };
90
- }
91
- const msg = new MessageBox(_props);
92
- msg.show();
93
- });
94
- }
95
- /**
96
- * display an alert message
97
- */
98
- static alert(text, title = null) {
99
- new MessageBox({
100
- cls: 'warning',
101
- title,
102
- message: text,
103
- buttons: ['ok'],
104
- click: () => { },
105
- }).show();
106
- }
107
- }
108
- export class PromptDialogBox extends Dialog {
109
- m_edit;
110
- constructor(props) {
111
- // remove overloaded elements from DialogBoxProps
112
- //let icon = props.icon; // ?? 'cls(far fa-comment-check)'; // todo: resolve that
113
- //props.icon = undefined;
114
- props.buttons = undefined;
115
- props.width = props.width ?? 500;
116
- super(props);
117
- this.form.updateContent(new HLayout({
118
- cls: 'panel',
119
- content: [
120
- //icon ? new Icon({
121
- // cls: 'icon',
122
- // icon: icon
123
- //}) : null,
124
- this.m_edit = new TextEdit({
125
- flex: 1,
126
- autoFocus: true,
127
- label: props.message,
128
- value: props.value
129
- }),
130
- ]
131
- }), ['ok', 'cancel']);
132
- if (props.click) {
133
- this.on('btnClick', (ev) => {
134
- if (ev.button === 'ok') {
135
- // no prevent default -> always close the messagebox
136
- // asap to allow
137
- asap(() => {
138
- this.m_props.click(this.m_edit.value);
139
- });
140
- }
141
- });
142
- }
143
- }
144
- set text(txt) {
145
- this.m_edit.label = txt;
146
- }
147
- /**
148
- * display a messagebox
149
- */
150
- static show(props, inputCallback) {
151
- let msg;
152
- if (isString(props) || isHtmlString(props)) {
153
- msg = new PromptDialogBox({ message: props, click: inputCallback });
154
- }
155
- else {
156
- msg = new PromptDialogBox(props);
157
- }
158
- msg.show();
159
- return msg;
160
- }
161
- }
package/lib/esm/panel.js DELETED
@@ -1,65 +0,0 @@
1
- /**
2
- * ___ ___ __
3
- * \ \_/ / / _
4
- * \ / /_| |_
5
- * / _ \____ _|
6
- * /__/ \__\ |_|
7
- *
8
- * @file panel.ts
9
- * @author Etienne Cochard
10
- *
11
- * Copyright (c) 2019-2022 R-libre ingenierie
12
- *
13
- * Permission is hereby granted, free of charge, to any person obtaining a copy
14
- * of this software and associated documentation files (the "Software"), to deal
15
- * in the Software without restriction, including without limitation the rights
16
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
17
- * of the Software, and to permit persons to whom the Software is furnished to do so,
18
- * subject to the following conditions:
19
- * The above copyright notice and this permission notice shall be included in all copies
20
- * or substantial portions of the Software.
21
- *
22
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
23
- * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
24
- * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
25
- * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26
- * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
27
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28
- **/
29
- import { Component } from './component';
30
- import { VLayout, HLayout } from './layout';
31
- import { Label } from './label';
32
- import { Icon } from './icon';
33
- export class Panel extends VLayout {
34
- m_ui_title;
35
- m_ui_body;
36
- constructor(props) {
37
- super(props);
38
- const sens = props?.sens == 'horizontal' ? '@hlayout' : '@vlayout';
39
- //todo: cannot be called twice do to content overload
40
- this.m_ui_title = new Label({ cls: 'title', text: this.m_props.title });
41
- this.m_ui_body = new Component({ cls: 'body ' + sens, content: this.m_props.content, style: props.bodyStyle });
42
- }
43
- /** @ignore */
44
- render() {
45
- const gadgets = this.m_props.gadgets ?? [];
46
- const icon = this.m_props.icon ? new Icon({ icon: this.m_props.icon }) : null;
47
- super.setContent([
48
- new HLayout({
49
- cls: 'title',
50
- content: [
51
- icon,
52
- this.m_ui_title,
53
- ...gadgets
54
- ]
55
- }),
56
- this.m_ui_body
57
- ]);
58
- }
59
- setContent(els) {
60
- this.m_ui_body.setContent(els);
61
- }
62
- set title(text) {
63
- this.m_ui_title.text = text;
64
- }
65
- }