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/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;
package/lib/gridview.js CHANGED
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  /**
2
3
  * ___ ___ __
3
4
  * \ \/ / / _
@@ -22,25 +23,28 @@
22
23
  *
23
24
  * You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
24
25
  **/
26
+ Object.defineProperty(exports, "__esModule", { value: true });
27
+ exports.GridView = exports.EvGridCheck = void 0;
25
28
  const T_UPDATE = Symbol('update');
26
29
  /**
27
30
  * todo: sizable column
28
31
  * todo: button in a column
29
32
  */
30
- import { HLayout, VLayout } from './layout';
31
- import { Component, EvDblClick, flyWrap, html, SizerOverlay } from './component';
32
- import { Label } from './label';
33
- import { _tr } from './i18n';
34
- import { downloadData } from './tools';
35
- import { DataStore } from './datastore';
36
- import { EvContextMenu, EvSelectionChange, BasicEvent } from "./x4_events";
37
- export function EvGridCheck(rec, chk) {
38
- return BasicEvent({ rec, chk });
33
+ const layout_1 = require("./layout");
34
+ const component_1 = require("./component");
35
+ const label_1 = require("./label");
36
+ const i18n_1 = require("./i18n");
37
+ const tools_1 = require("./tools");
38
+ const datastore_1 = require("./datastore");
39
+ const x4_events_1 = require("./x4_events");
40
+ function EvGridCheck(rec, chk) {
41
+ return (0, x4_events_1.BasicEvent)({ rec, chk });
39
42
  }
43
+ exports.EvGridCheck = EvGridCheck;
40
44
  /**
41
45
  * gridview class
42
46
  */
43
- export class GridView extends VLayout {
47
+ class GridView extends layout_1.VLayout {
44
48
  m_dataview;
45
49
  m_data_cx;
46
50
  m_columns;
@@ -77,7 +81,7 @@ export class GridView extends VLayout {
77
81
  this.m_itemHeight = 0;
78
82
  this.m_recycler = [];
79
83
  this.m_rowClassifier = props.calcRowClass;
80
- this.m_empty_text = props.empty_text ?? _tr.global.empty_list;
84
+ this.m_empty_text = props.empty_text ?? i18n_1._tr.global.empty_list;
81
85
  //this.setDomEvent('create', this._handleCreate, this);
82
86
  this.setDomEvent('click', (e) => this._itemClick(e));
83
87
  this.setDomEvent('dblclick', (e) => this._itemDblClick(e));
@@ -185,7 +189,7 @@ export class GridView extends VLayout {
185
189
  */
186
190
  setStore(store) {
187
191
  this.m_selection = undefined;
188
- if (store instanceof DataStore) {
192
+ if (store instanceof datastore_1.DataStore) {
189
193
  this.m_dataview = store.createView();
190
194
  }
191
195
  else {
@@ -230,14 +234,14 @@ export class GridView extends VLayout {
230
234
  /** @ignore */
231
235
  render() {
232
236
  this.m_recycler = [];
233
- this.m_container = new Component({
237
+ this.m_container = new component_1.Component({
234
238
  cls: 'content',
235
239
  });
236
- this.m_empty_msg = new Label({
240
+ this.m_empty_msg = new label_1.Label({
237
241
  cls: 'empty-msg',
238
242
  text: ''
239
243
  });
240
- this.m_view_el = new Component({
244
+ this.m_view_el = new component_1.Component({
241
245
  cls: '@scroll-view',
242
246
  flex: 1,
243
247
  dom_events: {
@@ -251,9 +255,9 @@ export class GridView extends VLayout {
251
255
  if (col.cls) {
252
256
  cls += ' ' + col.cls;
253
257
  }
254
- let comp = new Component({
258
+ let comp = new component_1.Component({
255
259
  cls,
256
- content: new Component({
260
+ content: new component_1.Component({
257
261
  tag: 'span',
258
262
  content: col.title
259
263
  }),
@@ -264,7 +268,7 @@ export class GridView extends VLayout {
264
268
  },
265
269
  dom_events: {
266
270
  click: (ev) => {
267
- let t = flyWrap(ev.target);
271
+ let t = (0, component_1.flyWrap)(ev.target);
268
272
  if (!t.hasClass('@sizer-overlay')) { // avoid sizer click
269
273
  this._sortCol(col);
270
274
  ev.preventDefault();
@@ -275,13 +279,13 @@ export class GridView extends VLayout {
275
279
  const resizeCol = (ev) => {
276
280
  this._on_col_resize(index, ev.size.width);
277
281
  if (this.m_footer) {
278
- let col = Component.getElement(this.m_footer.dom.childNodes[index]);
282
+ let col = component_1.Component.getElement(this.m_footer.dom.childNodes[index]);
279
283
  if (col) {
280
284
  col.setStyleValue('width', ev.size.width);
281
285
  }
282
286
  }
283
287
  };
284
- new SizerOverlay({
288
+ new component_1.SizerOverlay({
285
289
  target: comp,
286
290
  sens: 'right',
287
291
  events: { resize: (e) => resizeCol(e) }
@@ -294,7 +298,7 @@ export class GridView extends VLayout {
294
298
  this.m_columns.forEach((col) => {
295
299
  full_width += col.width ?? 0;
296
300
  });
297
- this.m_header = new HLayout({
301
+ this.m_header = new layout_1.HLayout({
298
302
  cls: '@header',
299
303
  content: cols,
300
304
  style: {
@@ -310,7 +314,7 @@ export class GridView extends VLayout {
310
314
  if (col.cls) {
311
315
  cls += ' ' + col.cls;
312
316
  }
313
- let comp = new Component({
317
+ let comp = new component_1.Component({
314
318
  cls,
315
319
  data: { col: index },
316
320
  flex: col.flex,
@@ -320,7 +324,7 @@ export class GridView extends VLayout {
320
324
  });
321
325
  return comp;
322
326
  });
323
- this.m_footer = new HLayout({
327
+ this.m_footer = new layout_1.HLayout({
324
328
  cls: '@footer',
325
329
  content: foots,
326
330
  style: {
@@ -402,7 +406,7 @@ export class GridView extends VLayout {
402
406
  }
403
407
  }
404
408
  else {
405
- row = new HLayout(props);
409
+ row = new layout_1.HLayout(props);
406
410
  }
407
411
  if (!row.dom) {
408
412
  this.m_container.appendChild(row);
@@ -429,7 +433,7 @@ export class GridView extends VLayout {
429
433
  });
430
434
  // if items height make scroll visible, update header width
431
435
  if (((count + 1) * this.m_itemHeight) >= height) {
432
- let w = Component.getScrollbarSize();
436
+ let w = component_1.Component.getScrollbarSize();
433
437
  this.m_header.setStyleValue("paddingRight", w);
434
438
  this.m_footer?.setStyleValue("paddingRight", w);
435
439
  }
@@ -492,10 +496,10 @@ export class GridView extends VLayout {
492
496
  else {
493
497
  text = rec.getField(col.id);
494
498
  }
495
- cell = new Component({
499
+ cell = new component_1.Component({
496
500
  cls,
497
501
  width: col.width,
498
- content: html `<span>${text}</span>`,
502
+ content: (0, component_1.html) `<span>${text}</span>`,
499
503
  flex: col.flex
500
504
  });
501
505
  }
@@ -589,7 +593,7 @@ export class GridView extends VLayout {
589
593
  _rowFromTarget(dom) {
590
594
  let self = this.dom;
591
595
  while (dom && dom != self) {
592
- let itm = Component.getElement(dom);
596
+ let itm = component_1.Component.getElement(dom);
593
597
  if (itm) {
594
598
  let id = itm.getData('row-id');
595
599
  if (id !== undefined) {
@@ -614,7 +618,7 @@ export class GridView extends VLayout {
614
618
  if (hit) {
615
619
  this._selectItem(hit.id, hit.itm);
616
620
  let rec = this.m_dataview.getById(hit.id);
617
- this.emit('dblClick', EvDblClick(rec));
621
+ this.emit('dblClick', (0, component_1.EvDblClick)(rec));
618
622
  if (this.m_hasMarks) {
619
623
  this._toggleMark(rec);
620
624
  }
@@ -624,7 +628,7 @@ export class GridView extends VLayout {
624
628
  _itemMenu(e) {
625
629
  let dom = e.target, self = this.dom;
626
630
  while (dom && dom != self) {
627
- let itm = Component.getElement(dom), id = itm?.getData('row-id');
631
+ let itm = component_1.Component.getElement(dom), id = itm?.getData('row-id');
628
632
  if (id !== undefined) {
629
633
  this._selectItem(id, itm);
630
634
  let idx = itm.getData('row-idx');
@@ -671,17 +675,17 @@ export class GridView extends VLayout {
671
675
  dom_item.addClass('@selected');
672
676
  }
673
677
  let rec = this.m_dataview.getById(item);
674
- this.emit('selectionChange', EvSelectionChange(rec));
678
+ this.emit('selectionChange', (0, x4_events_1.EvSelectionChange)(rec));
675
679
  }
676
680
  else {
677
- this.emit('selectionChange', EvSelectionChange(null));
681
+ this.emit('selectionChange', (0, x4_events_1.EvSelectionChange)(null));
678
682
  }
679
683
  }
680
684
  /**
681
685
  *
682
686
  */
683
687
  _showItemContextMenu(event, item) {
684
- this.emit('contextMenu', EvContextMenu(event, item));
688
+ this.emit('contextMenu', (0, x4_events_1.EvContextMenu)(event, item));
685
689
  }
686
690
  /**
687
691
  *
@@ -727,7 +731,7 @@ export class GridView extends VLayout {
727
731
  data = data.replace(/[îï]/gm, 'i');
728
732
  data = data.replace(/[ûüù]/gm, 'u');
729
733
  data = data.replace(/ /gm, ' '); // non breaking space
730
- downloadData(data, 'text/csv', filename);
734
+ (0, tools_1.downloadData)(data, 'text/csv', filename);
731
735
  }
732
736
  set empty_text(text) {
733
737
  this.m_empty_msg.text = text;
@@ -737,7 +741,7 @@ export class GridView extends VLayout {
737
741
  if (this.m_marks.has(rec.getID())) {
738
742
  cls = ' checked';
739
743
  }
740
- return new Component({ cls: '@grid-checkbox' + cls });
744
+ return new component_1.Component({ cls: '@grid-checkbox' + cls });
741
745
  }
742
746
  _toggleMark(rec) {
743
747
  let id = rec.getID();
@@ -784,3 +788,4 @@ export class GridView extends VLayout {
784
788
  });
785
789
  }
786
790
  }
791
+ exports.GridView = GridView;
@@ -0,0 +1,44 @@
1
+ /**
2
+ * @file host.ts
3
+ * @author Etienne Cochard
4
+ * @license
5
+ * Copyright (c) 2019-2021 R-libre ingenierie
6
+ *
7
+ * This program is free software; you can redistribute it and/or modify
8
+ * it under the terms of the GNU General Public License as published by
9
+ * the Free Software Foundation; either version 3 of the License, or
10
+ * (at your option) any later version.
11
+ *
12
+ * This program is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ * GNU General Public License for more details.
16
+ *
17
+ * You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
18
+ **/
19
+ export interface FileStat {
20
+ atime: number;
21
+ isDir: boolean;
22
+ }
23
+ export declare type PathType = 'home' | 'appData' | 'userData' | 'cache' | 'temp' | 'exe' | 'desktop' | 'documents' | 'downloads' | 'music' | 'pictures' | 'videos' | 'recent' | 'logs' | 'crashDumps';
24
+ export declare type PartType = 'filename' | 'extname' | 'basename' | 'dirname';
25
+ export declare abstract class Host {
26
+ constructor();
27
+ makePath(...els: string[]): string;
28
+ readBinary(path: string): Promise<Uint8Array>;
29
+ writeBinary(path: string, data: Uint8Array): Promise<boolean>;
30
+ readUtf8(path: string): Promise<string>;
31
+ writeUtf8(path: string, data: string): Promise<boolean>;
32
+ compress(data: Uint8Array): Promise<Uint8Array>;
33
+ decompress(data: Uint8Array): Promise<Uint8Array>;
34
+ readLocalStorage(name: string): string;
35
+ writeLocalStorage(name: string, data: string): void;
36
+ stat(name: string): FileStat;
37
+ readDir(path: string): Promise<string[]>;
38
+ require(name: string): any;
39
+ cwd(): string;
40
+ getPath(type: PathType): string;
41
+ getPathPart(path: string, type: PartType): string;
42
+ abstract createCanvas(): any;
43
+ }
44
+ export declare let host: Host;