x4js 1.4.2 → 1.4.5

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 (63) hide show
  1. package/lib/application.js +10 -6
  2. package/lib/base64.js +5 -1
  3. package/lib/base_component.js +7 -3
  4. package/lib/button.js +24 -18
  5. package/lib/calendar.js +44 -39
  6. package/lib/canvas.js +9 -5
  7. package/lib/cardview.js +11 -7
  8. package/lib/checkbox.js +12 -8
  9. package/lib/color.js +7 -3
  10. package/lib/colorpicker.js +86 -80
  11. package/lib/combobox.js +26 -22
  12. package/lib/component.js +65 -48
  13. package/lib/datastore.js +29 -20
  14. package/lib/dialog.js +41 -36
  15. package/lib/dom_events.js +2 -1
  16. package/lib/drag_manager.js +4 -1
  17. package/lib/drawtext.js +9 -5
  18. package/lib/fileupload.js +19 -12
  19. package/lib/form.js +29 -25
  20. package/lib/formatters.js +19 -10
  21. package/lib/gridview.js +40 -35
  22. package/lib/hosts/host.js +7 -3
  23. package/lib/i18n.js +11 -5
  24. package/lib/icon.js +16 -11
  25. package/lib/image.js +7 -3
  26. package/lib/index.d.ts +55 -0
  27. package/lib/index.js +71 -1
  28. package/lib/input.js +6 -2
  29. package/lib/label.js +15 -11
  30. package/lib/layout.js +23 -13
  31. package/lib/link.js +9 -5
  32. package/lib/listview.js +34 -27
  33. package/lib/md5.js +5 -1
  34. package/lib/menu.js +27 -19
  35. package/lib/messagebox.js +22 -17
  36. package/lib/panel.js +13 -9
  37. package/lib/popup.js +25 -20
  38. package/lib/property_editor.js +20 -16
  39. package/lib/radiobtn.js +13 -9
  40. package/lib/rating.js +13 -9
  41. package/lib/request.js +16 -9
  42. package/lib/router.d.ts +1 -8
  43. package/lib/router.js +4 -0
  44. package/lib/settings.js +8 -4
  45. package/lib/sidebarview.js +12 -8
  46. package/lib/smartedit.js +16 -11
  47. package/lib/spreadsheet.js +35 -31
  48. package/lib/styles.js +15 -9
  49. package/lib/svgcomponent.js +8 -3
  50. package/lib/tabbar.js +10 -6
  51. package/lib/tabview.js +10 -6
  52. package/lib/textarea.js +10 -6
  53. package/lib/textedit.js +39 -35
  54. package/lib/texthiliter.js +8 -4
  55. package/lib/toaster.js +8 -4
  56. package/lib/tools.js +97 -51
  57. package/lib/tooltips.js +14 -9
  58. package/lib/treeview.js +30 -26
  59. package/lib/x4_events.js +21 -9
  60. package/package.json +2 -1
  61. package/src/index.ts +55 -0
  62. package/src/router.ts +1 -1
  63. package/tsconfig.json +2 -1
package/lib/dialog.js CHANGED
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  /**
2
3
  * ___ ___ __
3
4
  * \ \/ / / _
@@ -22,21 +23,24 @@
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
- import { Popup, EvMove } from './popup';
26
- import { Icon } from './icon';
27
- import { HLayout } from './layout';
28
- import { Label } from './label';
29
- import { Form } from './form';
30
- import { Component, EvSize, flyWrap } from './component';
31
- import { BasicEvent } from './x4_events';
32
- import { Rect, getMousePos, isFunction, isTouchDevice } from './tools';
33
- export function EvBtnClick(button) {
34
- return BasicEvent({ button });
26
+ Object.defineProperty(exports, "__esModule", { value: true });
27
+ exports.Dialog = exports.EvBtnClick = void 0;
28
+ const popup_1 = require("./popup");
29
+ const icon_1 = require("./icon");
30
+ const layout_1 = require("./layout");
31
+ const label_1 = require("./label");
32
+ const form_1 = require("./form");
33
+ const component_1 = require("./component");
34
+ const x4_events_1 = require("./x4_events");
35
+ const tools_1 = require("./tools");
36
+ function EvBtnClick(button) {
37
+ return (0, x4_events_1.BasicEvent)({ button });
35
38
  }
39
+ exports.EvBtnClick = EvBtnClick;
36
40
  /**
37
41
  * Standard dialog class
38
42
  */
39
- export class Dialog extends Popup {
43
+ class Dialog extends popup_1.Popup {
40
44
  m_icon;
41
45
  m_title;
42
46
  m_form;
@@ -66,7 +70,7 @@ export class Dialog extends Popup {
66
70
  this.m_minFormSize = { width, height };
67
71
  this.enableMask(true);
68
72
  if (props.form) {
69
- if (!isFunction(props.form)) {
73
+ if (!(0, tools_1.isFunction)(props.form)) {
70
74
  this.m_form = props.form;
71
75
  this.m_form.on('btnClick', (e) => this._handleClick(e));
72
76
  }
@@ -75,7 +79,7 @@ export class Dialog extends Popup {
75
79
  }
76
80
  }
77
81
  else {
78
- this.m_form = new Form({
82
+ this.m_form = new form_1.Form({
79
83
  content,
80
84
  buttons: props.buttons,
81
85
  disableSuggestions: props.disableSuggestions,
@@ -142,7 +146,7 @@ export class Dialog extends Popup {
142
146
  this.addClass('@resized');
143
147
  if (this.m_props.maximized) {
144
148
  this._maximize();
145
- this.emit('size', EvSize(null));
149
+ this.emit('size', (0, component_1.EvSize)(null));
146
150
  }
147
151
  else {
148
152
  this.centerOnScreen();
@@ -163,12 +167,12 @@ export class Dialog extends Popup {
163
167
  setGeometry(geom) {
164
168
  if (geom.minimized && this.m_minimizable) {
165
169
  this._minimize(false);
166
- this.m_rc_min = new Rect(geom.left, geom.top, geom.width, geom.height);
170
+ this.m_rc_min = new tools_1.Rect(geom.left, geom.top, geom.width, geom.height);
167
171
  this.displayAt(geom.left, geom.top, 'top-left');
168
172
  }
169
173
  else if (geom.maximized && this.m_maximizable) {
170
174
  this._maximize(false);
171
- this.m_rc_max = new Rect(geom.left, geom.top, geom.width, geom.height);
175
+ this.m_rc_max = new tools_1.Rect(geom.left, geom.top, geom.width, geom.height);
172
176
  }
173
177
  else {
174
178
  this.setSize(geom.width, geom.height);
@@ -216,7 +220,7 @@ export class Dialog extends Popup {
216
220
  */
217
221
  setSize(width, height) {
218
222
  this.setStyle({ width, height });
219
- this.emit('size', EvSize({ width, height }));
223
+ this.emit('size', (0, component_1.EvSize)({ width, height }));
220
224
  }
221
225
  /** @ignore */
222
226
  render() {
@@ -228,18 +232,18 @@ export class Dialog extends Popup {
228
232
  let hasTitle = this.m_icon !== undefined || this.m_closable || this.m_title !== undefined || this.m_movable;
229
233
  this.m_el_title = null;
230
234
  if (hasTitle) {
231
- this.m_el_title = new HLayout({
235
+ this.m_el_title = new layout_1.HLayout({
232
236
  cls: 'title',
233
237
  content: [
234
- this.m_icon ? new Icon({ icon: this.m_icon }) : null,
235
- this.m_ui_title = new Label({ flex: 1, text: this.m_title }),
236
- this.m_minimizable ? new Icon({ cls: 'min-btn', icon: 'cls(far fa-window-minimize)', dom_events: { click: () => this._toggleMin() } }) : null,
237
- this.m_maximizable ? new Icon({ cls: 'max-btn', icon: 'cls(far fa-window-maximize)', dom_events: { click: () => this._toggleMax() } }) : null,
238
- this.m_closable ? new Icon({ icon: 'cls(far fa-rectangle-times)', dom_events: { click: () => this.close() } }) : null,
238
+ this.m_icon ? new icon_1.Icon({ icon: this.m_icon }) : null,
239
+ this.m_ui_title = new label_1.Label({ flex: 1, text: this.m_title }),
240
+ this.m_minimizable ? new icon_1.Icon({ cls: 'min-btn', icon: 'cls(far fa-window-minimize)', dom_events: { click: () => this._toggleMin() } }) : null,
241
+ this.m_maximizable ? new icon_1.Icon({ cls: 'max-btn', icon: 'cls(far fa-window-maximize)', dom_events: { click: () => this._toggleMax() } }) : null,
242
+ this.m_closable ? new icon_1.Icon({ icon: 'cls(far fa-rectangle-times)', dom_events: { click: () => this.close() } }) : null,
239
243
  ]
240
244
  });
241
245
  if (this.m_movable) {
242
- if (isTouchDevice()) {
246
+ if ((0, tools_1.isTouchDevice)()) {
243
247
  this.m_el_title.setDomEvent('touchstart', (e) => this._mouseDown(e));
244
248
  }
245
249
  else {
@@ -296,11 +300,11 @@ export class Dialog extends Popup {
296
300
  height: this.m_rc_max.height,
297
301
  });
298
302
  this.m_maximized = false;
299
- this.emit('size', EvSize(null, 'restore'));
303
+ this.emit('size', (0, component_1.EvSize)(null, 'restore'));
300
304
  }
301
305
  else {
302
306
  this._maximize();
303
- this.emit('size', EvSize(null, 'maximize'));
307
+ this.emit('size', (0, component_1.EvSize)(null, 'maximize'));
304
308
  }
305
309
  }
306
310
  /**
@@ -319,19 +323,19 @@ export class Dialog extends Popup {
319
323
  height: this.m_rc_min.height,
320
324
  });
321
325
  this.m_minimized = false;
322
- this.emit('size', EvSize(null, 'restore'));
326
+ this.emit('size', (0, component_1.EvSize)(null, 'restore'));
323
327
  }
324
328
  else {
325
329
  this._minimize();
326
- this.emit('size', EvSize(null, 'minimize'));
330
+ this.emit('size', (0, component_1.EvSize)(null, 'minimize'));
327
331
  }
328
332
  }
329
333
  /**
330
334
  *
331
335
  */
332
336
  _mouseDown(event) {
333
- let { x, y } = getMousePos(event, true);
334
- let wrc = flyWrap(document.body).getBoundingRect();
337
+ let { x, y } = (0, tools_1.getMousePos)(event, true);
338
+ let wrc = (0, component_1.flyWrap)(document.body).getBoundingRect();
335
339
  let rc = this.getBoundingRect(true);
336
340
  let trc = this.m_el_title.getBoundingRect();
337
341
  let dx = x - rc.left, dy = y - rc.top;
@@ -375,7 +379,7 @@ export class Dialog extends Popup {
375
379
  top: y
376
380
  });
377
381
  };
378
- Component.setCapture(this, (ev) => {
382
+ component_1.Component.setCapture(this, (ev) => {
379
383
  if (ev.type == 'mousemove') {
380
384
  let mev = ev;
381
385
  __move(mev.clientX, mev.clientY);
@@ -387,8 +391,8 @@ export class Dialog extends Popup {
387
391
  }
388
392
  }
389
393
  else if (ev.type == 'mouseup' || ev.type == 'touchend') {
390
- Component.releaseCapture();
391
- this.emit('move', EvMove(null));
394
+ component_1.Component.releaseCapture();
395
+ this.emit('move', (0, popup_1.EvMove)(null));
392
396
  }
393
397
  else if (ev.type == 'mousedown' || ev.type == 'touchstart') {
394
398
  }
@@ -402,7 +406,7 @@ export class Dialog extends Popup {
402
406
  return;
403
407
  }
404
408
  this._maximize();
405
- this.emit('size', EvSize(null));
409
+ this.emit('size', (0, component_1.EvSize)(null));
406
410
  }
407
411
  /**
408
412
  *
@@ -428,7 +432,7 @@ export class Dialog extends Popup {
428
432
  return;
429
433
  }
430
434
  this._minimize();
431
- this.emit('size', EvSize(null));
435
+ this.emit('size', (0, component_1.EvSize)(null));
432
436
  }
433
437
  /**
434
438
  *
@@ -457,7 +461,7 @@ export class Dialog extends Popup {
457
461
  }
458
462
  itemWithName(name) {
459
463
  let result = this.dom.querySelector(`[name="${name}"]`);
460
- return result ? Component.getElement(result) : null;
464
+ return result ? component_1.Component.getElement(result) : null;
461
465
  }
462
466
  getValues() {
463
467
  return this.m_form.getValues();
@@ -466,3 +470,4 @@ export class Dialog extends Popup {
466
470
  return this.m_form.validate();
467
471
  }
468
472
  }
473
+ exports.Dialog = Dialog;
package/lib/dom_events.js CHANGED
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  /**
2
3
  * ___ ___ __
3
4
  * \ \/ / / _
@@ -10,4 +11,4 @@
10
11
  * @copyright (c) 2022 R-libre ingenierie, all rights reserved.
11
12
  *
12
13
  **/
13
- export {};
14
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,3 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.dragManager = void 0;
1
4
  const x_drag_cb = Symbol('x-drag-cb');
2
5
  /**
3
6
  *
@@ -115,4 +118,4 @@ class DragManager {
115
118
  }
116
119
  }
117
120
  }
118
- export const dragManager = new DragManager();
121
+ exports.dragManager = new DragManager();
package/lib/drawtext.js CHANGED
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  /**
2
3
  * ___ ___ __
3
4
  * \ \/ / / _
@@ -22,7 +23,9 @@
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
- import { Point, roundTo } from './tools';
26
+ Object.defineProperty(exports, "__esModule", { value: true });
27
+ exports.drawText = void 0;
28
+ const tools_1 = require("./tools");
26
29
  // adapted & modified from Canvas-txt:
27
30
  // https://github.com/geongeorge/Canvas-Txt/blob/master/src/index.js
28
31
  // Hair space character for precise justification
@@ -41,7 +44,7 @@ const defStyle = {
41
44
  columnGap: 0,
42
45
  lineBreak: true,
43
46
  };
44
- export function drawText(ctx, input_Text, rc, drawStyle) {
47
+ function drawText(ctx, input_Text, rc, drawStyle) {
45
48
  if (rc.width <= 0 || rc.height <= 0) {
46
49
  //width or height or font size cannot be 0
47
50
  return;
@@ -55,7 +58,7 @@ export function drawText(ctx, input_Text, rc, drawStyle) {
55
58
  ctx.clip();
56
59
  }
57
60
  if (drawStyle.rotation) {
58
- const center = new Point(rc.left + rc.width / 2, rc.top + rc.height / 2);
61
+ const center = new tools_1.Point(rc.left + rc.width / 2, rc.top + rc.height / 2);
59
62
  const rad = drawStyle.rotation / 180 * Math.PI;
60
63
  ctx.translate(center.x, center.y);
61
64
  ctx.rotate(rad);
@@ -66,7 +69,7 @@ export function drawText(ctx, input_Text, rc, drawStyle) {
66
69
  }
67
70
  ctx.textBaseline = 'bottom';
68
71
  // End points
69
- let fontSize = roundTo(drawStyle.fontSize, 2) ?? 12;
72
+ let fontSize = (0, tools_1.roundTo)(drawStyle.fontSize, 2) ?? 12;
70
73
  //let style = `${drawStyle.fontStyle ?? ''} ${drawStyle.fontVariant ?? ''} ${drawStyle.fontWeight ?? ''} ${fontSize}px ${drawStyle.fontFamily ?? 'arial'}`;
71
74
  let style = '';
72
75
  if (drawStyle.fontStyle) {
@@ -243,13 +246,14 @@ export function drawText(ctx, input_Text, rc, drawStyle) {
243
246
  // todo autogrow + multi-columns
244
247
  return { height: (textarray.length + 0.3) * lineHeight };
245
248
  }
249
+ exports.drawText = drawText;
246
250
  // Calculate Height of the font
247
251
  function _calcTextHeight(ctx, text) {
248
252
  const size = ctx.measureText(text);
249
253
  return size.actualBoundingBoxAscent + size.actualBoundingBoxDescent;
250
254
  }
251
255
  function _measureText(ctx, text) {
252
- return roundTo(ctx.measureText(text).width, 2);
256
+ return (0, tools_1.roundTo)(ctx.measureText(text).width, 2);
253
257
  }
254
258
  function _justify(line, width, spaceW) {
255
259
  let delta = (width - line.width) / (line.words.length - 1) + spaceW;
package/lib/fileupload.js CHANGED
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  /**
2
3
  * ___ ___ __
3
4
  * \ \/ / / _
@@ -22,11 +23,13 @@
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
- import { Component } from './component';
26
- import { HLayout } from './layout';
27
- import { Input } from './input';
28
- import { Image } from './image';
29
- export class FileUpload extends HLayout {
26
+ Object.defineProperty(exports, "__esModule", { value: true });
27
+ exports.saveFile = exports.openFile = exports.ImageUpload = exports.FileUpload = void 0;
28
+ const component_1 = require("./component");
29
+ const layout_1 = require("./layout");
30
+ const input_1 = require("./input");
31
+ const image_1 = require("./image");
32
+ class FileUpload extends layout_1.HLayout {
30
33
  constructor(props) {
31
34
  super(props);
32
35
  }
@@ -34,10 +37,11 @@ export class FileUpload extends HLayout {
34
37
  this.m_props.value = '';
35
38
  }
36
39
  }
40
+ exports.FileUpload = FileUpload;
37
41
  /**
38
42
  *
39
43
  */
40
- export class ImageUpload extends FileUpload {
44
+ class ImageUpload extends FileUpload {
41
45
  m_path;
42
46
  m_ui_img;
43
47
  m_ui_input;
@@ -45,12 +49,12 @@ export class ImageUpload extends FileUpload {
45
49
  render(props) {
46
50
  let ename = "up" + this.uid;
47
51
  this.setContent([
48
- new Component({
52
+ new component_1.Component({
49
53
  tag: 'label', attrs: { for: ename }, content: [
50
- this.m_ui_img = new Image({ src: this.m_props.value }),
54
+ this.m_ui_img = new image_1.Image({ src: this.m_props.value }),
51
55
  ]
52
56
  }),
53
- this.m_ui_input = new Input({
57
+ this.m_ui_input = new input_1.Input({
54
58
  cls: '@hidden',
55
59
  id: ename,
56
60
  type: 'file',
@@ -102,10 +106,11 @@ export class ImageUpload extends FileUpload {
102
106
  }
103
107
  }
104
108
  }
109
+ exports.ImageUpload = ImageUpload;
105
110
  let g_file_input = null;
106
111
  function _createFileInput() {
107
112
  if (!g_file_input) {
108
- g_file_input = new Component({
113
+ g_file_input = new component_1.Component({
109
114
  tag: 'input',
110
115
  style: {
111
116
  display: 'none',
@@ -126,7 +131,7 @@ function _createFileInput() {
126
131
  * @param extensions - string - ex: '.doc,.docx'
127
132
  * @param cb - callback to call when user select a file
128
133
  */
129
- export function openFile(extensions, cb, multiple = false) {
134
+ function openFile(extensions, cb, multiple = false) {
130
135
  let fi = _createFileInput();
131
136
  fi.removeAttribute('nwsaveas');
132
137
  fi.setAttribute('accept', extensions);
@@ -139,12 +144,13 @@ export function openFile(extensions, cb, multiple = false) {
139
144
  });
140
145
  fi.dom.click();
141
146
  }
147
+ exports.openFile = openFile;
142
148
  /**
143
149
  * open saveas dialog
144
150
  * @param defFileName - string - proposed filename
145
151
  * @param cb - callback to call when user choose the destination
146
152
  */
147
- export function saveFile(defFileName, extensions, cb) {
153
+ function saveFile(defFileName, extensions, cb) {
148
154
  let fi = _createFileInput();
149
155
  fi.setAttribute('nwsaveas', defFileName);
150
156
  fi.setAttribute('accept', extensions);
@@ -156,3 +162,4 @@ export function saveFile(defFileName, extensions, cb) {
156
162
  });
157
163
  fi.dom.click();
158
164
  }
165
+ exports.saveFile = saveFile;
package/lib/form.js CHANGED
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  /**
2
3
  * ___ ___ __
3
4
  * \ \/ / / _
@@ -22,17 +23,19 @@
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
- import { Component, flyWrap } from './component';
26
- import { HLayout, VLayout } from './layout';
27
- import { Button } from './button';
28
- import { TextEdit } from './textedit';
29
- import { ajaxRequest } from './request';
30
- import { EvBtnClick } from './dialog';
31
- import { _tr } from './i18n';
26
+ Object.defineProperty(exports, "__esModule", { value: true });
27
+ exports.Form = void 0;
28
+ const component_1 = require("./component");
29
+ const layout_1 = require("./layout");
30
+ const button_1 = require("./button");
31
+ const textedit_1 = require("./textedit");
32
+ const request_1 = require("./request");
33
+ const dialog_1 = require("./dialog");
34
+ const i18n_1 = require("./i18n");
32
35
  /**
33
36
  *
34
37
  */
35
- export class Form extends VLayout {
38
+ class Form extends layout_1.VLayout {
36
39
  m_height;
37
40
  m_container;
38
41
  m_buttons;
@@ -76,7 +79,7 @@ export class Form extends VLayout {
76
79
  }
77
80
  this._makeButtons(buttons);
78
81
  let content = [
79
- this.m_container = new VLayout({
82
+ this.m_container = new layout_1.VLayout({
80
83
  cls: 'container',
81
84
  height: this.m_height,
82
85
  content: items
@@ -122,7 +125,7 @@ export class Form extends VLayout {
122
125
  */
123
126
  _makeButtons(buttons) {
124
127
  if (!this.m_buttons) {
125
- this.m_buttons = new HLayout({
128
+ this.m_buttons = new layout_1.HLayout({
126
129
  cls: 'footer',
127
130
  ref: 'buttons',
128
131
  });
@@ -130,41 +133,41 @@ export class Form extends VLayout {
130
133
  let btns = [];
131
134
  if (buttons) {
132
135
  for (let b of buttons) {
133
- if (b instanceof Component) {
136
+ if (b instanceof component_1.Component) {
134
137
  btns.push(b);
135
138
  }
136
139
  else {
137
140
  switch (b) {
138
141
  case 'ok': {
139
- btns.push(new Button({ ref: '@' + b, text: _tr.global.ok, click: () => { this._click(b); } }));
142
+ btns.push(new button_1.Button({ ref: '@' + b, text: i18n_1._tr.global.ok, click: () => { this._click(b); } }));
140
143
  break;
141
144
  }
142
145
  case 'cancel': {
143
- btns.push(new Button({ ref: '@' + b, text: _tr.global.cancel, click: () => { this._click(b); } }));
146
+ btns.push(new button_1.Button({ ref: '@' + b, text: i18n_1._tr.global.cancel, click: () => { this._click(b); } }));
144
147
  break;
145
148
  }
146
149
  case 'ignore': {
147
- btns.push(new Button({ ref: '@' + b, text: _tr.global.ignore, click: () => { this._click(b); } }));
150
+ btns.push(new button_1.Button({ ref: '@' + b, text: i18n_1._tr.global.ignore, click: () => { this._click(b); } }));
148
151
  break;
149
152
  }
150
153
  case 'yes': {
151
- btns.push(new Button({ ref: '@' + b, text: _tr.global.yes, click: () => { this._click(b); } }));
154
+ btns.push(new button_1.Button({ ref: '@' + b, text: i18n_1._tr.global.yes, click: () => { this._click(b); } }));
152
155
  break;
153
156
  }
154
157
  case 'no': {
155
- btns.push(new Button({ ref: '@' + b, text: _tr.global.no, click: () => { this._click(b); } }));
158
+ btns.push(new button_1.Button({ ref: '@' + b, text: i18n_1._tr.global.no, click: () => { this._click(b); } }));
156
159
  break;
157
160
  }
158
161
  case 'close': {
159
- btns.push(new Button({ ref: '@' + b, text: _tr.global.close, click: () => { this._click(b); } }));
162
+ btns.push(new button_1.Button({ ref: '@' + b, text: i18n_1._tr.global.close, click: () => { this._click(b); } }));
160
163
  break;
161
164
  }
162
165
  case 'save': {
163
- btns.push(new Button({ ref: '@' + b, text: _tr.global.save, click: () => { this._click(b); } }));
166
+ btns.push(new button_1.Button({ ref: '@' + b, text: i18n_1._tr.global.save, click: () => { this._click(b); } }));
164
167
  break;
165
168
  }
166
169
  case 'dontsave': {
167
- btns.push(new Button({ ref: '@' + b, text: _tr.global.dontsave, click: () => { this._click(b); } }));
170
+ btns.push(new button_1.Button({ ref: '@' + b, text: i18n_1._tr.global.dontsave, click: () => { this._click(b); } }));
168
171
  break;
169
172
  }
170
173
  }
@@ -182,7 +185,7 @@ export class Form extends VLayout {
182
185
  validate() {
183
186
  let inputs = this.queryAll('input'), result = true;
184
187
  for (let i = 0; i < inputs.length; i++) {
185
- let input = Component.getElement(inputs[i], TextEdit);
188
+ let input = component_1.Component.getElement(inputs[i], textedit_1.TextEdit);
186
189
  if (input && !input.validate()) {
187
190
  result = false;
188
191
  }
@@ -193,7 +196,7 @@ export class Form extends VLayout {
193
196
  *
194
197
  */
195
198
  _click(btn) {
196
- this.emit('btnClick', EvBtnClick(btn));
199
+ this.emit('btnClick', (0, dialog_1.EvBtnClick)(btn));
197
200
  }
198
201
  /**
199
202
  * replacement for HTMLFormElement.elements
@@ -213,7 +216,7 @@ export class Form extends VLayout {
213
216
  let elements = this._getElements();
214
217
  for (let e = 0; e < elements.length; e++) {
215
218
  let input = elements[e];
216
- let item = Component.getElement(input);
219
+ let item = component_1.Component.getElement(input);
217
220
  if (!item.hasAttribute("name")) {
218
221
  continue;
219
222
  }
@@ -234,7 +237,7 @@ export class Form extends VLayout {
234
237
  let result = {};
235
238
  for (let e = 0; e < elements.length; e++) {
236
239
  let el = elements[e];
237
- let item = Component.getElement(el);
240
+ let item = component_1.Component.getElement(el);
238
241
  if (!item.hasAttribute("name")) {
239
242
  continue;
240
243
  }
@@ -265,7 +268,7 @@ export class Form extends VLayout {
265
268
  }
266
269
  }
267
270
  cfg.params = form;
268
- return ajaxRequest(cfg);
271
+ return (0, request_1.ajaxRequest)(cfg);
269
272
  }
270
273
  /**
271
274
  *
@@ -274,7 +277,7 @@ export class Form extends VLayout {
274
277
  if (this.dom) {
275
278
  const els = this.queryAll('input[name], textarea[name]');
276
279
  els.forEach(el => {
277
- flyWrap(el).setDomEvent('input', () => {
280
+ (0, component_1.flyWrap)(el).setDomEvent('input', () => {
278
281
  this.setDirty();
279
282
  });
280
283
  });
@@ -291,3 +294,4 @@ export class Form extends VLayout {
291
294
  return this.m_dirty;
292
295
  }
293
296
  }
297
+ exports.Form = Form;
package/lib/formatters.js CHANGED
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  /**
2
3
  * ___ ___ __
3
4
  * \ \/ / / _
@@ -22,10 +23,12 @@
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
- import { formatIntlDate, roundTo } from './tools';
26
+ Object.defineProperty(exports, "__esModule", { value: true });
27
+ exports.bool_formatter = exports.money_formatter_nz = exports.money_formatter = exports.date_formatter = exports.sql_date_formatter = exports.setCurrencySymbol = void 0;
28
+ const tools_1 = require("./tools");
26
29
  let locale;
27
30
  let moneyFmt;
28
- export function setCurrencySymbol(symbol) {
31
+ function setCurrencySymbol(symbol) {
29
32
  if (symbol) {
30
33
  moneyFmt = new Intl.NumberFormat(locale, { style: 'currency', currency: symbol /*, currencyDisplay: 'symbol'*/ });
31
34
  }
@@ -33,7 +36,8 @@ export function setCurrencySymbol(symbol) {
33
36
  moneyFmt = new Intl.NumberFormat(locale, { style: 'decimal', useGrouping: true, minimumFractionDigits: 2, maximumFractionDigits: 2 });
34
37
  }
35
38
  }
36
- export function sql_date_formatter(input) {
39
+ exports.setCurrencySymbol = setCurrencySymbol;
40
+ function sql_date_formatter(input) {
37
41
  if (input === null || input === undefined || input === '') {
38
42
  return '';
39
43
  }
@@ -42,34 +46,39 @@ export function sql_date_formatter(input) {
42
46
  const options = { /*weekday: 'short',*/ month: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit' };
43
47
  return dte.toLocaleDateString(locale, options);
44
48
  }
45
- export function date_formatter(input) {
49
+ exports.sql_date_formatter = sql_date_formatter;
50
+ function date_formatter(input) {
46
51
  if (input === null || input === undefined || input === '') {
47
52
  return '';
48
53
  }
49
54
  let dte = typeof (input) == 'string' ? new Date(Date.parse(input)) : input;
50
- return formatIntlDate(dte);
55
+ return (0, tools_1.formatIntlDate)(dte);
51
56
  }
52
- export function money_formatter(input) {
57
+ exports.date_formatter = date_formatter;
58
+ function money_formatter(input) {
53
59
  if (input === null || input === undefined || input === '') {
54
60
  return '';
55
61
  }
56
- let val = roundTo(typeof (input) == 'string' ? parseFloat(input) : input, 2);
62
+ let val = (0, tools_1.roundTo)(typeof (input) == 'string' ? parseFloat(input) : input, 2);
57
63
  if (val === -0.00)
58
64
  val = 0.00;
59
65
  let res = moneyFmt.format(val);
60
66
  return res;
61
67
  }
62
- export function money_formatter_nz(input) {
68
+ exports.money_formatter = money_formatter;
69
+ function money_formatter_nz(input) {
63
70
  if (input === null || input === undefined || input === '') {
64
71
  return '';
65
72
  }
66
- let val = roundTo(typeof (input) == 'string' ? parseFloat(input) : input, 2);
73
+ let val = (0, tools_1.roundTo)(typeof (input) == 'string' ? parseFloat(input) : input, 2);
67
74
  if (!val) { // do not show zeros
68
75
  return '';
69
76
  }
70
77
  let res = moneyFmt.format(val);
71
78
  return res;
72
79
  }
73
- export function bool_formatter(input) {
80
+ exports.money_formatter_nz = money_formatter_nz;
81
+ function bool_formatter(input) {
74
82
  return input ? 'oui' : '-';
75
83
  }
84
+ exports.bool_formatter = bool_formatter;