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.
Files changed (85) hide show
  1. package/lib/application.d.ts +96 -0
  2. package/lib/application.js +146 -0
  3. package/lib/base64.d.ts +31 -0
  4. package/lib/base64.js +139 -0
  5. package/lib/base_component.d.ts +64 -0
  6. package/lib/base_component.js +81 -0
  7. package/lib/button.d.ts +145 -0
  8. package/lib/button.js +241 -0
  9. package/lib/calendar.d.ts +77 -0
  10. package/lib/calendar.js +241 -0
  11. package/lib/canvas.d.ts +88 -0
  12. package/lib/canvas.js +358 -0
  13. package/lib/cardview.d.ts +83 -0
  14. package/lib/cardview.js +156 -0
  15. package/lib/checkbox.d.ts +72 -0
  16. package/lib/checkbox.js +130 -0
  17. package/lib/color.d.ts +144 -0
  18. package/lib/color.js +588 -0
  19. package/lib/colorpicker.js +86 -80
  20. package/lib/combobox.js +26 -22
  21. package/lib/component.d.ts +572 -0
  22. package/lib/component.js +1729 -0
  23. package/lib/datastore.js +29 -20
  24. package/lib/dialog.js +41 -36
  25. package/lib/dom_events.d.ts +284 -0
  26. package/lib/dom_events.js +14 -0
  27. package/lib/drag_manager.js +4 -1
  28. package/lib/drawtext.js +9 -5
  29. package/lib/fileupload.js +19 -12
  30. package/lib/form.js +29 -25
  31. package/lib/formatters.js +19 -10
  32. package/lib/gridview.js +40 -35
  33. package/lib/hosts/host.d.ts +44 -0
  34. package/lib/hosts/host.js +73 -0
  35. package/lib/i18n.d.ts +67 -0
  36. package/lib/i18n.js +175 -0
  37. package/lib/icon.d.ts +56 -0
  38. package/lib/icon.js +178 -0
  39. package/lib/image.js +7 -3
  40. package/lib/index.js +71 -55
  41. package/lib/input.d.ts +86 -0
  42. package/lib/input.js +176 -0
  43. package/lib/label.d.ts +54 -0
  44. package/lib/label.js +90 -0
  45. package/lib/layout.d.ts +77 -0
  46. package/lib/layout.js +271 -0
  47. package/lib/link.js +9 -5
  48. package/lib/listview.js +34 -27
  49. package/lib/md5.js +5 -1
  50. package/lib/menu.d.ts +122 -0
  51. package/lib/menu.js +284 -0
  52. package/lib/messagebox.js +22 -17
  53. package/lib/panel.js +13 -9
  54. package/lib/popup.d.ts +71 -0
  55. package/lib/popup.js +378 -0
  56. package/lib/property_editor.js +20 -16
  57. package/lib/radiobtn.js +13 -9
  58. package/lib/rating.js +13 -9
  59. package/lib/request.js +16 -9
  60. package/lib/router.js +5 -1
  61. package/lib/settings.d.ts +33 -0
  62. package/lib/settings.js +67 -0
  63. package/lib/sidebarview.js +12 -8
  64. package/lib/smartedit.js +16 -11
  65. package/lib/spreadsheet.js +35 -31
  66. package/lib/styles.d.ts +81 -0
  67. package/lib/styles.js +268 -0
  68. package/lib/svgcomponent.js +8 -3
  69. package/lib/tabbar.js +10 -6
  70. package/lib/tabview.js +10 -6
  71. package/lib/textarea.js +10 -6
  72. package/lib/textedit.js +39 -35
  73. package/lib/texthiliter.js +8 -4
  74. package/lib/toaster.js +8 -4
  75. package/lib/tools.d.ts +382 -0
  76. package/lib/tools.js +1142 -0
  77. package/lib/tooltips.js +14 -9
  78. package/lib/treeview.js +30 -26
  79. package/lib/x4_events.d.ts +253 -0
  80. package/lib/x4_events.js +375 -0
  81. package/package.json +1 -1
  82. package/src/application.ts +9 -4
  83. package/src/x4.less +143 -107
  84. package/tsconfig.json +1 -1
  85. package/x4.css +1541 -0
package/lib/popup.js ADDED
@@ -0,0 +1,378 @@
1
+ "use strict";
2
+ /**
3
+ * ___ ___ __
4
+ * \ \_/ / / _
5
+ * \ / /_| |_
6
+ * / _ \____ _|
7
+ * /__/ \__\ |_|
8
+ *
9
+ * @file popup.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.Popup = exports.EvMove = void 0;
28
+ const component_1 = require("./component");
29
+ const tools_1 = require("./tools");
30
+ const x4_events_1 = require("./x4_events");
31
+ const application_1 = require("./application");
32
+ function EvMove(pos) {
33
+ return (0, x4_events_1.BasicEvent)({ pos });
34
+ }
35
+ exports.EvMove = EvMove;
36
+ /**
37
+ * base class for all popup elements
38
+ */
39
+ class Popup extends component_1.Container {
40
+ m_ui_mask;
41
+ m_hasMask = true;
42
+ static modal_stack = [];
43
+ constructor(props) {
44
+ super(props);
45
+ this.addClass('@hidden');
46
+ }
47
+ enableMask(enable = true) {
48
+ this.m_hasMask = enable;
49
+ }
50
+ /**
51
+ * display the popup on screen
52
+ */
53
+ show(modal) {
54
+ if (modal !== undefined) {
55
+ this.m_hasMask = modal ? true : false;
56
+ }
57
+ else {
58
+ modal = this.m_hasMask;
59
+ }
60
+ if (this.m_hasMask) {
61
+ // remove the focus
62
+ const focus = document.activeElement;
63
+ if (focus) {
64
+ focus.blur();
65
+ }
66
+ this.m_ui_mask = document.body.lastChild;
67
+ while (this.m_ui_mask) {
68
+ if (this.m_ui_mask.nodeType == 1) { // only element nodes
69
+ let elUI = (0, component_1.flyWrap)(this.m_ui_mask);
70
+ if (elUI.hasClass('@menu') || elUI.hasClass('@non-maskable')) {
71
+ /* avoid circular dependencies instanceof Menu*/
72
+ /* avoid nonmaskable elements tobe masked */
73
+ }
74
+ else if (elUI.getStyleValue('display') == 'none' || !elUI.isUserVisible()) {
75
+ /* avoid masking hidden elements */
76
+ }
77
+ else if (!elUI.hasClass('@comp')) {
78
+ /* avoid masking element that are not to us */
79
+ }
80
+ else {
81
+ break;
82
+ }
83
+ }
84
+ this.m_ui_mask = this.m_ui_mask.previousSibling;
85
+ }
86
+ if (this.m_ui_mask) {
87
+ (0, component_1.flyWrap)(this.m_ui_mask).addClass('@mask');
88
+ }
89
+ }
90
+ if (modal) {
91
+ application_1.Application.instance().enterModal(true);
92
+ }
93
+ // to avoid body growing because of appendChild
94
+ this.setStyle({
95
+ left: 0,
96
+ top: 0
97
+ });
98
+ document.body.appendChild(this._build());
99
+ this.removeClass('@hidden');
100
+ this.centerOnScreen();
101
+ if (modal) {
102
+ let focus = document.activeElement;
103
+ if (!this.dom.contains(focus)) {
104
+ const autofocus = this.queryItem('[autofocus]');
105
+ if (autofocus) {
106
+ autofocus.focus();
107
+ }
108
+ else {
109
+ let tabbable = this.queryItem('[tabindex]');
110
+ if (tabbable) {
111
+ let tab_indexes = [].map.call(tabbable, (e) => { return e; });
112
+ // remove hidden elements
113
+ tab_indexes = tab_indexes.filter((el) => el.offsetParent !== null);
114
+ if (tab_indexes.length) {
115
+ tab_indexes[0].focus();
116
+ }
117
+ }
118
+ }
119
+ }
120
+ Popup.modal_stack.push(this.dom);
121
+ }
122
+ }
123
+ centerOnScreen() {
124
+ let rc = this.getBoundingRect();
125
+ let x = (document.body.clientWidth - rc.width) / 2, y = (document.body.clientHeight - rc.height) / 2;
126
+ this.setStyleValue('left', x);
127
+ this.setStyleValue('top', y);
128
+ }
129
+ /**
130
+ * display the popup at a specific position
131
+ * @param x
132
+ * @param y
133
+ */
134
+ displayAt(x, y, align = 'top left', offset) {
135
+ this.show();
136
+ let halign = 'l', valign = 't';
137
+ if (align.indexOf('right') >= 0) {
138
+ halign = 'r';
139
+ }
140
+ if (align.indexOf('bottom') >= 0) {
141
+ valign = 'b';
142
+ }
143
+ // @TODO: this is a minimal overflow problem solution
144
+ let rc = document.body.getBoundingClientRect(), rm = this.getBoundingRect();
145
+ if (halign == 'r') {
146
+ x -= rm.width;
147
+ }
148
+ if (valign == 'b') {
149
+ y -= rm.height;
150
+ }
151
+ if (offset) {
152
+ x += offset.x;
153
+ y += offset.y;
154
+ }
155
+ if (x < 4) {
156
+ x = 4;
157
+ }
158
+ if ((x + rm.width) > rc.right - 4) {
159
+ x = rc.right - 4 - rm.width;
160
+ if (offset?.x < 0) {
161
+ x += offset.x;
162
+ }
163
+ }
164
+ if (y < 4) {
165
+ y = 4;
166
+ }
167
+ if ((y + rm.height) > rc.bottom - 4) {
168
+ y = rc.bottom - 4 - rm.height;
169
+ if (offset?.y < 0) {
170
+ y += offset.y;
171
+ }
172
+ }
173
+ this.setStyle({ left: x, top: y });
174
+ }
175
+ /**
176
+ * close the popup
177
+ */
178
+ close() {
179
+ this.hide();
180
+ if (this.m_hasMask && this.m_ui_mask) {
181
+ (0, component_1.flyWrap)(this.m_ui_mask).removeClass('@mask');
182
+ const app = application_1.Application.instance();
183
+ app.enterModal(false);
184
+ }
185
+ let index = Popup.modal_stack.indexOf(this.dom);
186
+ if (index >= 0) {
187
+ Popup.modal_stack.splice(index);
188
+ }
189
+ this.dispose();
190
+ }
191
+ componentCreated() {
192
+ if (this.m_props.sizable) {
193
+ this.addClass('@size-all');
194
+ let els = ['top', 'right', 'bottom', 'left', 'topleft', 'topright', 'bottomleft', 'bottomright'];
195
+ for (let sens of els) {
196
+ new component_1.SizerOverlay({
197
+ target: this,
198
+ sens: sens,
199
+ events: { rawresize: (e) => this._mouseResize(e) }
200
+ });
201
+ }
202
+ }
203
+ }
204
+ /**
205
+ * resize for 'all' resize attribute
206
+ */
207
+ _mouseResize(event) {
208
+ event.preventDefault();
209
+ let irc = this.getBoundingRect();
210
+ let st = this.getComputedStyle();
211
+ let ev = event.ui_event;
212
+ let tm = st.parse('marginTop'), lm = st.parse('marginLeft'), rm = st.parse('marginRight'), bm = st.parse('marginBottom');
213
+ let ix = 0, iy = 0;
214
+ let mp = (0, tools_1.getMousePos)(ev, true);
215
+ // horz
216
+ switch (event.sens) {
217
+ case 'topright':
218
+ case 'bottomright':
219
+ case 'right':
220
+ ix = (irc.right - rm) - mp.x;
221
+ break;
222
+ case 'topleft':
223
+ case 'bottomleft':
224
+ case 'left':
225
+ ix = (irc.left - lm) - mp.x;
226
+ break;
227
+ }
228
+ // vert
229
+ switch (event.sens) {
230
+ case 'bottomleft':
231
+ case 'bottomright':
232
+ case 'bottom':
233
+ iy = (irc.bottom - bm) - mp.y;
234
+ break;
235
+ case 'topleft':
236
+ case 'topright':
237
+ case 'top':
238
+ iy = (irc.top - tm) - mp.y;
239
+ break;
240
+ }
241
+ // left & top are with margin
242
+ // width & height not
243
+ irc.left -= lm;
244
+ irc.top -= tm;
245
+ //console.log( 'capture' );
246
+ let sens = event.sens;
247
+ component_1.Component.setCapture(this, (ne) => {
248
+ //console.log( ne );
249
+ let __move = (ex, ey) => {
250
+ let left = irc.left, top = irc.top, width = irc.width, height = irc.height;
251
+ let dx, dy;
252
+ let px = ex + ix, py = ey + iy;
253
+ if (px < 0) {
254
+ px = 0;
255
+ }
256
+ if (py < 0) {
257
+ py = 0;
258
+ }
259
+ // horz
260
+ switch (sens) {
261
+ case 'topright':
262
+ case 'bottomright':
263
+ case 'right':
264
+ width = px - left;
265
+ break;
266
+ case 'topleft':
267
+ case 'bottomleft':
268
+ case 'left':
269
+ dx = left - px;
270
+ width += dx;
271
+ left -= dx;
272
+ break;
273
+ }
274
+ // vert
275
+ switch (sens) {
276
+ case 'bottomleft':
277
+ case 'bottomright':
278
+ case 'bottom':
279
+ height = py - top;
280
+ break;
281
+ case 'topleft':
282
+ case 'topright':
283
+ case 'top':
284
+ dy = top - py;
285
+ height += dy;
286
+ top -= dy;
287
+ break;
288
+ }
289
+ let newsize = new tools_1.Size(width, height);
290
+ this.setStyle({ left, top, width: newsize.width, height: newsize.height });
291
+ this.emit('size', (0, component_1.EvSize)(newsize));
292
+ };
293
+ if (ne.type == 'mouseup' || ne.type == 'touchend') {
294
+ component_1.Component.releaseCapture();
295
+ }
296
+ else if (ne.type == 'mousemove') {
297
+ let me = ne;
298
+ __move(me.pageX, me.pageY);
299
+ }
300
+ else if (ne.type == 'touchmove') {
301
+ let tev = ne;
302
+ __move(tev.touches[0].pageX, tev.touches[0].pageY);
303
+ }
304
+ });
305
+ }
306
+ }
307
+ exports.Popup = Popup;
308
+ /**
309
+ * handle tab key
310
+ */
311
+ function x4handleKeyDown(e) {
312
+ if (e.key == 'Tab' || e.key == 'Enter') {
313
+ const target = e.target;
314
+ if (target.tagName == 'TEXTAREA') {
315
+ return;
316
+ }
317
+ const el = component_1.Component.getElement(target);
318
+ if (el && (el.hasAttribute('wants-tab') || el.hasAttribute('wants-enter'))) {
319
+ return;
320
+ }
321
+ let topStack = document.body;
322
+ if (Popup.modal_stack.length) {
323
+ topStack = Popup.modal_stack[Popup.modal_stack.length - 1];
324
+ }
325
+ _nextTab(topStack, e.target, e.shiftKey);
326
+ e.stopPropagation();
327
+ e.preventDefault();
328
+ }
329
+ }
330
+ /**
331
+ * cycle through tabs
332
+ */
333
+ function _nextTab(root, el, prev) {
334
+ // first check if the focus is one of our child (disabled...)
335
+ let focusEl = document.activeElement;
336
+ if (!root.contains(focusEl)) {
337
+ return;
338
+ }
339
+ let comp = component_1.Component.getElement(el);
340
+ // get a list of elements with tab index, this way we should abble to
341
+ // cycle on them (not on browser address nor under dialog elements)
342
+ let tabbable = root.querySelectorAll('[tabindex]');
343
+ let tab_indexes = [].map.call(tabbable, (e) => { return e; });
344
+ // remove hidden elements
345
+ tab_indexes = tab_indexes.filter((el) => el.offsetParent !== null);
346
+ if (!tab_indexes.length) {
347
+ return;
348
+ }
349
+ let ct = tab_indexes.indexOf(el);
350
+ if (ct < 0) {
351
+ ct = 0;
352
+ }
353
+ else {
354
+ if (prev) {
355
+ if (ct > 0) {
356
+ ct--;
357
+ }
358
+ else {
359
+ ct = tab_indexes.length - 1;
360
+ }
361
+ }
362
+ else {
363
+ if (ct < tab_indexes.length - 1) {
364
+ ct++;
365
+ }
366
+ else {
367
+ ct = 0;
368
+ }
369
+ }
370
+ }
371
+ tab_indexes[ct].focus();
372
+ }
373
+ function installKBHandler() {
374
+ // set on body to be called after document (where all component domevent go)
375
+ document.body.addEventListener('keydown', x4handleKeyDown, true);
376
+ }
377
+ // too early ?
378
+ document.body ? installKBHandler() : window.addEventListener('load', installKBHandler);
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  /**
2
3
  * ___ ___ __
3
4
  * \ \_/ / / _
@@ -22,14 +23,16 @@
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 { EvChange } from './x4_events';
27
- import { Input } from './input';
28
- import { TextEdit } from './textedit';
29
- import { CheckBox } from './checkbox';
30
- import { Spreadsheet } from './spreadsheet';
31
- import { _tr } from './i18n';
32
- export class PropertyEditor extends Component {
26
+ Object.defineProperty(exports, "__esModule", { value: true });
27
+ exports.PropertyEditor = void 0;
28
+ const component_1 = require("./component");
29
+ const x4_events_1 = require("./x4_events");
30
+ const input_1 = require("./input");
31
+ const textedit_1 = require("./textedit");
32
+ const checkbox_1 = require("./checkbox");
33
+ const spreadsheet_1 = require("./spreadsheet");
34
+ const i18n_1 = require("./i18n");
35
+ class PropertyEditor extends component_1.Component {
33
36
  m_fields;
34
37
  m_record;
35
38
  m_sheet;
@@ -42,16 +45,16 @@ export class PropertyEditor extends Component {
42
45
  this.m_record = props.record;
43
46
  this.m_fields = props.fields ?? [];
44
47
  this.m_label_w = props.labelWidth;
45
- this.m_sheet = new Spreadsheet({
48
+ this.m_sheet = new spreadsheet_1.Spreadsheet({
46
49
  cls: '@fit',
47
50
  columns: [
48
51
  {
49
- title: _tr.global.property,
52
+ title: i18n_1._tr.global.property,
50
53
  width: this.m_label_w > 0 ? this.m_label_w : -1,
51
54
  cls: 'property'
52
55
  },
53
56
  {
54
- title: _tr.global.value,
57
+ title: i18n_1._tr.global.value,
55
58
  width: -1,
56
59
  createEditor: (...a) => this._editCell(...a),
57
60
  renderer: (...a) => this._renderCell(...a)
@@ -138,7 +141,7 @@ export class PropertyEditor extends Component {
138
141
  else {
139
142
  fld.value = text;
140
143
  }
141
- this.emit('change', EvChange(text, fld));
144
+ this.emit('change', (0, x4_events_1.EvChange)(text, fld));
142
145
  }
143
146
  _renderCell(text, rec) {
144
147
  let fld = this.m_fields[rec.row];
@@ -186,21 +189,21 @@ export class PropertyEditor extends Component {
186
189
  switch (fld.type) {
187
190
  default:
188
191
  case 'string': {
189
- editor = new TextEdit(props);
192
+ editor = new textedit_1.TextEdit(props);
190
193
  break;
191
194
  }
192
195
  case 'number': {
193
- editor = new TextEdit(props);
196
+ editor = new textedit_1.TextEdit(props);
194
197
  break;
195
198
  }
196
199
  case 'password': {
197
200
  props.type = 'password';
198
201
  props.value = this.m_record.getField(fld.id);
199
- editor = new Input(props);
202
+ editor = new input_1.Input(props);
200
203
  break;
201
204
  }
202
205
  case 'boolean': {
203
- editor = new CheckBox(props);
206
+ editor = new checkbox_1.CheckBox(props);
204
207
  break;
205
208
  }
206
209
  case 'choice': {
@@ -245,3 +248,4 @@ export class PropertyEditor extends Component {
245
248
  return choices;
246
249
  }
247
250
  }
251
+ exports.PropertyEditor = PropertyEditor;
package/lib/radiobtn.js CHANGED
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  /**
2
3
  * ___ ___ __
3
4
  * \ \_/ / / _
@@ -22,14 +23,16 @@
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 { EvChange } from './x4_events';
27
- import { Input } from './input';
28
- import { Label } from './label';
26
+ Object.defineProperty(exports, "__esModule", { value: true });
27
+ exports.RadioBtn = void 0;
28
+ const component_1 = require("./component");
29
+ const x4_events_1 = require("./x4_events");
30
+ const input_1 = require("./input");
31
+ const label_1 = require("./label");
29
32
  /**
30
33
  * Standard RadioBtn
31
34
  */
32
- export class RadioBtn extends Component {
35
+ class RadioBtn extends component_1.Component {
33
36
  m_ui_input; // todo: remove that / use ref
34
37
  constructor(props) {
35
38
  super(props);
@@ -52,7 +55,7 @@ export class RadioBtn extends Component {
52
55
  this.addClass('checked');
53
56
  }
54
57
  this.setContent([
55
- this.m_ui_input = new Input({
58
+ this.m_ui_input = new input_1.Input({
56
59
  type: 'radio',
57
60
  name: name,
58
61
  tabIndex: props.tabIndex,
@@ -65,7 +68,7 @@ export class RadioBtn extends Component {
65
68
  focus: () => this.m_ui_input.focus(),
66
69
  }
67
70
  }),
68
- new Label({
71
+ new label_1.Label({
69
72
  ref: 'label',
70
73
  icon: icon,
71
74
  text: text,
@@ -85,12 +88,12 @@ export class RadioBtn extends Component {
85
88
  let query = '.x-input[name=' + props.name + ']';
86
89
  let nlist = document.querySelectorAll(query); //todo: document ?
87
90
  nlist.forEach((dom) => {
88
- let radio = Component.getElement(dom, RadioBtn);
91
+ let radio = component_1.Component.getElement(dom, RadioBtn);
89
92
  radio.removeClass('checked');
90
93
  });
91
94
  let dom = this.m_ui_input.dom;
92
95
  this.setClass('checked', dom.checked);
93
- this.emit('change', EvChange(true));
96
+ this.emit('change', (0, x4_events_1.EvChange)(true));
94
97
  }
95
98
  /**
96
99
  * @return the checked value
@@ -129,3 +132,4 @@ export class RadioBtn extends Component {
129
132
  this.itemWithRef('label').text = text;
130
133
  }
131
134
  }
135
+ exports.RadioBtn = RadioBtn;
package/lib/rating.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 { EvChange } from './x4_events';
29
- export class Rating extends HLayout {
26
+ Object.defineProperty(exports, "__esModule", { value: true });
27
+ exports.Rating = void 0;
28
+ const component_1 = require("./component");
29
+ const layout_1 = require("./layout");
30
+ const input_1 = require("./input");
31
+ const x4_events_1 = require("./x4_events");
32
+ class Rating extends layout_1.HLayout {
30
33
  m_els;
31
34
  m_input;
32
35
  constructor(props) {
@@ -36,7 +39,7 @@ export class Rating extends HLayout {
36
39
  render(props) {
37
40
  let shape = props.shape ?? 'star';
38
41
  let value = props.value ?? 0;
39
- this.m_input = new Input({
42
+ this.m_input = new input_1.Input({
40
43
  cls: '@hidden',
41
44
  name: props.name,
42
45
  value: '' + value
@@ -49,7 +52,7 @@ export class Rating extends HLayout {
49
52
  if (i + 1 <= value) {
50
53
  cls += ' checked';
51
54
  }
52
- let c = new Component({
55
+ let c = new component_1.Component({
53
56
  tag: 'option',
54
57
  cls,
55
58
  data: { value: i + 1 }
@@ -81,13 +84,14 @@ export class Rating extends HLayout {
81
84
  _onclick(ev) {
82
85
  let on = true;
83
86
  for (let el = this.dom.firstChild; el; el = el.nextSibling) {
84
- let comp = Component.getElement(el);
87
+ let comp = component_1.Component.getElement(el);
85
88
  comp.setClass('checked', on);
86
89
  if (el == ev.target) {
87
90
  this.m_input.value = comp.getData('value');
88
91
  on = false;
89
92
  }
90
93
  }
91
- this.emit('change', EvChange(this.m_props.value));
94
+ this.emit('change', (0, x4_events_1.EvChange)(this.m_props.value));
92
95
  }
93
96
  }
97
+ exports.Rating = Rating;
package/lib/request.js CHANGED
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  /**
2
3
  * ___ ___ __
3
4
  * \ \_/ / / _
@@ -22,6 +23,8 @@
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
  **/
26
+ Object.defineProperty(exports, "__esModule", { value: true });
27
+ exports.ajax = exports.ajaxAsText = exports.ajaxAsJSON = exports.ajaxRequest = void 0;
25
28
  /**
26
29
  * TODO: use fetch api
27
30
  *
@@ -41,9 +44,9 @@ function dump( resp ) {
41
44
  getToto( dump );
42
45
 
43
46
  */
44
- import { isArray, isLiteralObject, isString, NetworkError } from './tools';
47
+ const tools_1 = require("./tools");
45
48
  const DEFAULT_TIMEOUT = 10000;
46
- export function ajaxRequest(cfg) {
49
+ function ajaxRequest(cfg) {
47
50
  let params, url = cfg.url, method = cfg.method || 'GET', formdata = false;
48
51
  if (cfg.params instanceof FormData) {
49
52
  params = cfg.params;
@@ -138,6 +141,7 @@ export function ajaxRequest(cfg) {
138
141
  xhr.abort();
139
142
  };
140
143
  }
144
+ exports.ajaxRequest = ajaxRequest;
141
145
  function buildQuery(params, getMethod) {
142
146
  if (!params) {
143
147
  return '';
@@ -146,7 +150,7 @@ function buildQuery(params, getMethod) {
146
150
  for (let key in params) {
147
151
  let param = params[key];
148
152
  // array
149
- if (isArray(param)) {
153
+ if ((0, tools_1.isArray)(param)) {
150
154
  for (let i = 0, n = param.length; i < n; i++) {
151
155
  query.push(encodeURIComponent(key) + '[]=' + encodeURIComponent('' + param[i]));
152
156
  }
@@ -167,18 +171,20 @@ function buildQuery(params, getMethod) {
167
171
  return result;
168
172
  }
169
173
  }
170
- export async function ajaxAsJSON(url, init) {
174
+ async function ajaxAsJSON(url, init) {
171
175
  let response = await ajax(url, init, 'application/json');
172
176
  return response.json();
173
177
  }
174
- export async function ajaxAsText(url, init) {
178
+ exports.ajaxAsJSON = ajaxAsJSON;
179
+ async function ajaxAsText(url, init) {
175
180
  let response = await ajax(url, init, 'text/plain');
176
181
  return response.text();
177
182
  }
183
+ exports.ajaxAsText = ajaxAsText;
178
184
  /**
179
185
  * use encodeURIComponent for elements in url
180
186
  */
181
- export async function ajax(url, init, type) {
187
+ async function ajax(url, init, type) {
182
188
  let options = {
183
189
  method: 'GET',
184
190
  headers: {
@@ -190,9 +196,9 @@ export async function ajax(url, init, type) {
190
196
  }
191
197
  if (init) {
192
198
  options = { ...options, ...init };
193
- if (init.body && !isString(init.body)) {
199
+ if (init.body && !(0, tools_1.isString)(init.body)) {
194
200
  let cvt = false;
195
- if (isLiteralObject(init.body)) {
201
+ if ((0, tools_1.isLiteralObject)(init.body)) {
196
202
  cvt = true;
197
203
  }
198
204
  else if (!(init.body instanceof Blob) && !(init.body instanceof ArrayBuffer) && !(init.body instanceof FormData) &&
@@ -213,8 +219,9 @@ export async function ajax(url, init, type) {
213
219
  }
214
220
  else {
215
221
  if (!response.ok) {
216
- throw new NetworkError(response);
222
+ throw new tools_1.NetworkError(response);
217
223
  }
218
224
  return response;
219
225
  }
220
226
  }
227
+ exports.ajax = ajax;
package/lib/router.js CHANGED
@@ -1,4 +1,7 @@
1
- export class Router {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Router = void 0;
4
+ class Router {
2
5
  routes;
3
6
  constructor() {
4
7
  this.routes = [];
@@ -25,3 +28,4 @@ export class Router {
25
28
  });
26
29
  }
27
30
  }
31
+ exports.Router = Router;