x4js 1.4.3 → 1.4.6
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.
- package/lib/application.d.ts +3 -2
- package/lib/application.js +15 -7
- package/lib/base64.js +5 -1
- package/lib/base_component.js +7 -3
- package/lib/button.js +24 -18
- package/lib/calendar.js +44 -39
- package/lib/canvas.js +9 -5
- package/lib/cardview.js +11 -7
- package/lib/checkbox.js +12 -8
- package/lib/color.js +7 -3
- package/lib/colorpicker.js +86 -80
- package/lib/combobox.js +26 -22
- package/lib/component.js +65 -48
- package/lib/datastore.js +29 -20
- package/lib/dialog.js +41 -36
- package/lib/dom_events.js +2 -1
- package/lib/drag_manager.js +4 -1
- package/lib/drawtext.js +9 -5
- package/lib/fileupload.js +19 -12
- package/lib/form.js +29 -25
- package/lib/formatters.js +19 -10
- package/lib/gridview.js +40 -35
- package/lib/hosts/host.js +7 -3
- package/lib/i18n.js +11 -5
- package/lib/icon.js +16 -11
- package/lib/image.js +7 -3
- package/lib/index.d.ts +55 -0
- package/lib/index.js +71 -56
- package/lib/input.js +6 -2
- package/lib/label.js +15 -11
- package/lib/layout.js +23 -13
- package/lib/link.js +9 -5
- package/lib/listview.js +34 -27
- package/lib/md5.js +5 -1
- package/lib/menu.js +27 -19
- package/lib/messagebox.js +22 -17
- package/lib/panel.js +13 -9
- package/lib/popup.js +25 -20
- package/lib/property_editor.js +20 -16
- package/lib/radiobtn.js +13 -9
- package/lib/rating.js +13 -9
- package/lib/request.js +16 -9
- package/lib/router.d.ts +1 -8
- package/lib/router.js +4 -0
- package/lib/settings.js +8 -4
- package/lib/sidebarview.js +12 -8
- package/lib/smartedit.js +16 -11
- package/lib/spreadsheet.js +35 -31
- package/lib/styles.js +15 -9
- package/lib/svgcomponent.js +8 -3
- package/lib/tabbar.js +10 -6
- package/lib/tabview.js +10 -6
- package/lib/textarea.js +10 -6
- package/lib/textedit.js +39 -35
- package/lib/texthiliter.js +8 -4
- package/lib/toaster.js +8 -4
- package/lib/tools.js +97 -51
- package/lib/tooltips.js +14 -9
- package/lib/treeview.js +30 -26
- package/lib/x4_events.js +21 -9
- package/package.json +2 -1
- package/src/application.ts +8 -4
- package/src/index.ts +55 -0
- package/src/router.ts +1 -1
- package/tsconfig.json +2 -1
- package/lib/list.txt +0 -56
- package/list.txt +0 -0
package/lib/panel.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* ___ ___ __
|
|
3
4
|
* \ \_/ / / _
|
|
@@ -22,26 +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
|
**/
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
exports.Panel = void 0;
|
|
28
|
+
const component_1 = require("./component");
|
|
29
|
+
const layout_1 = require("./layout");
|
|
30
|
+
const label_1 = require("./label");
|
|
31
|
+
const icon_1 = require("./icon");
|
|
32
|
+
class Panel extends layout_1.VLayout {
|
|
30
33
|
m_ui_title;
|
|
31
34
|
m_ui_body;
|
|
32
35
|
constructor(props) {
|
|
33
36
|
super(props);
|
|
34
37
|
const sens = props?.sens == 'horizontal' ? '@hlayout' : '@vlayout';
|
|
35
38
|
//todo: cannot be called twice do to content overload
|
|
36
|
-
this.m_ui_title = new Label({ cls: 'title', text: this.m_props.title });
|
|
37
|
-
this.m_ui_body = new Component({ cls: 'body ' + sens, content: this.m_props.content });
|
|
39
|
+
this.m_ui_title = new label_1.Label({ cls: 'title', text: this.m_props.title });
|
|
40
|
+
this.m_ui_body = new component_1.Component({ cls: 'body ' + sens, content: this.m_props.content });
|
|
38
41
|
}
|
|
39
42
|
/** @ignore */
|
|
40
43
|
render() {
|
|
41
44
|
const gadgets = this.m_props.gadgets ?? [];
|
|
42
|
-
const icon = this.m_props.icon ? new Icon({ icon: this.m_props.icon }) : null;
|
|
45
|
+
const icon = this.m_props.icon ? new icon_1.Icon({ icon: this.m_props.icon }) : null;
|
|
43
46
|
super.setContent([
|
|
44
|
-
new HLayout({
|
|
47
|
+
new layout_1.HLayout({
|
|
45
48
|
cls: 'title',
|
|
46
49
|
content: [
|
|
47
50
|
icon,
|
|
@@ -59,3 +62,4 @@ export class Panel extends VLayout {
|
|
|
59
62
|
this.m_ui_title.text = text;
|
|
60
63
|
}
|
|
61
64
|
}
|
|
65
|
+
exports.Panel = Panel;
|
package/lib/popup.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* ___ ___ __
|
|
3
4
|
* \ \_/ / / _
|
|
@@ -22,17 +23,20 @@
|
|
|
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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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 });
|
|
31
34
|
}
|
|
35
|
+
exports.EvMove = EvMove;
|
|
32
36
|
/**
|
|
33
37
|
* base class for all popup elements
|
|
34
38
|
*/
|
|
35
|
-
|
|
39
|
+
class Popup extends component_1.Container {
|
|
36
40
|
m_ui_mask;
|
|
37
41
|
m_hasMask = true;
|
|
38
42
|
static modal_stack = [];
|
|
@@ -62,7 +66,7 @@ export class Popup extends Container {
|
|
|
62
66
|
this.m_ui_mask = document.body.lastChild;
|
|
63
67
|
while (this.m_ui_mask) {
|
|
64
68
|
if (this.m_ui_mask.nodeType == 1) { // only element nodes
|
|
65
|
-
let elUI = flyWrap(this.m_ui_mask);
|
|
69
|
+
let elUI = (0, component_1.flyWrap)(this.m_ui_mask);
|
|
66
70
|
if (elUI.hasClass('@menu') || elUI.hasClass('@non-maskable')) {
|
|
67
71
|
/* avoid circular dependencies instanceof Menu*/
|
|
68
72
|
/* avoid nonmaskable elements tobe masked */
|
|
@@ -80,11 +84,11 @@ export class Popup extends Container {
|
|
|
80
84
|
this.m_ui_mask = this.m_ui_mask.previousSibling;
|
|
81
85
|
}
|
|
82
86
|
if (this.m_ui_mask) {
|
|
83
|
-
flyWrap(this.m_ui_mask).addClass('@mask');
|
|
87
|
+
(0, component_1.flyWrap)(this.m_ui_mask).addClass('@mask');
|
|
84
88
|
}
|
|
85
89
|
}
|
|
86
90
|
if (modal) {
|
|
87
|
-
Application.instance().enterModal(true);
|
|
91
|
+
application_1.Application.instance().enterModal(true);
|
|
88
92
|
}
|
|
89
93
|
// to avoid body growing because of appendChild
|
|
90
94
|
this.setStyle({
|
|
@@ -174,8 +178,8 @@ export class Popup extends Container {
|
|
|
174
178
|
close() {
|
|
175
179
|
this.hide();
|
|
176
180
|
if (this.m_hasMask && this.m_ui_mask) {
|
|
177
|
-
flyWrap(this.m_ui_mask).removeClass('@mask');
|
|
178
|
-
const app = Application.instance();
|
|
181
|
+
(0, component_1.flyWrap)(this.m_ui_mask).removeClass('@mask');
|
|
182
|
+
const app = application_1.Application.instance();
|
|
179
183
|
app.enterModal(false);
|
|
180
184
|
}
|
|
181
185
|
let index = Popup.modal_stack.indexOf(this.dom);
|
|
@@ -189,7 +193,7 @@ export class Popup extends Container {
|
|
|
189
193
|
this.addClass('@size-all');
|
|
190
194
|
let els = ['top', 'right', 'bottom', 'left', 'topleft', 'topright', 'bottomleft', 'bottomright'];
|
|
191
195
|
for (let sens of els) {
|
|
192
|
-
new SizerOverlay({
|
|
196
|
+
new component_1.SizerOverlay({
|
|
193
197
|
target: this,
|
|
194
198
|
sens: sens,
|
|
195
199
|
events: { rawresize: (e) => this._mouseResize(e) }
|
|
@@ -207,7 +211,7 @@ export class Popup extends Container {
|
|
|
207
211
|
let ev = event.ui_event;
|
|
208
212
|
let tm = st.parse('marginTop'), lm = st.parse('marginLeft'), rm = st.parse('marginRight'), bm = st.parse('marginBottom');
|
|
209
213
|
let ix = 0, iy = 0;
|
|
210
|
-
let mp = getMousePos(ev, true);
|
|
214
|
+
let mp = (0, tools_1.getMousePos)(ev, true);
|
|
211
215
|
// horz
|
|
212
216
|
switch (event.sens) {
|
|
213
217
|
case 'topright':
|
|
@@ -240,7 +244,7 @@ export class Popup extends Container {
|
|
|
240
244
|
irc.top -= tm;
|
|
241
245
|
//console.log( 'capture' );
|
|
242
246
|
let sens = event.sens;
|
|
243
|
-
Component.setCapture(this, (ne) => {
|
|
247
|
+
component_1.Component.setCapture(this, (ne) => {
|
|
244
248
|
//console.log( ne );
|
|
245
249
|
let __move = (ex, ey) => {
|
|
246
250
|
let left = irc.left, top = irc.top, width = irc.width, height = irc.height;
|
|
@@ -282,12 +286,12 @@ export class Popup extends Container {
|
|
|
282
286
|
top -= dy;
|
|
283
287
|
break;
|
|
284
288
|
}
|
|
285
|
-
let newsize = new Size(width, height);
|
|
289
|
+
let newsize = new tools_1.Size(width, height);
|
|
286
290
|
this.setStyle({ left, top, width: newsize.width, height: newsize.height });
|
|
287
|
-
this.emit('size', EvSize(newsize));
|
|
291
|
+
this.emit('size', (0, component_1.EvSize)(newsize));
|
|
288
292
|
};
|
|
289
293
|
if (ne.type == 'mouseup' || ne.type == 'touchend') {
|
|
290
|
-
Component.releaseCapture();
|
|
294
|
+
component_1.Component.releaseCapture();
|
|
291
295
|
}
|
|
292
296
|
else if (ne.type == 'mousemove') {
|
|
293
297
|
let me = ne;
|
|
@@ -300,6 +304,7 @@ export class Popup extends Container {
|
|
|
300
304
|
});
|
|
301
305
|
}
|
|
302
306
|
}
|
|
307
|
+
exports.Popup = Popup;
|
|
303
308
|
/**
|
|
304
309
|
* handle tab key
|
|
305
310
|
*/
|
|
@@ -309,7 +314,7 @@ function x4handleKeyDown(e) {
|
|
|
309
314
|
if (target.tagName == 'TEXTAREA') {
|
|
310
315
|
return;
|
|
311
316
|
}
|
|
312
|
-
const el = Component.getElement(target);
|
|
317
|
+
const el = component_1.Component.getElement(target);
|
|
313
318
|
if (el && (el.hasAttribute('wants-tab') || el.hasAttribute('wants-enter'))) {
|
|
314
319
|
return;
|
|
315
320
|
}
|
|
@@ -331,7 +336,7 @@ function _nextTab(root, el, prev) {
|
|
|
331
336
|
if (!root.contains(focusEl)) {
|
|
332
337
|
return;
|
|
333
338
|
}
|
|
334
|
-
let comp = Component.getElement(el);
|
|
339
|
+
let comp = component_1.Component.getElement(el);
|
|
335
340
|
// get a list of elements with tab index, this way we should abble to
|
|
336
341
|
// cycle on them (not on browser address nor under dialog elements)
|
|
337
342
|
let tabbable = root.querySelectorAll('[tabindex]');
|
package/lib/property_editor.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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
-
|
|
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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
-
|
|
47
|
+
const tools_1 = require("./tools");
|
|
45
48
|
const DEFAULT_TIMEOUT = 10000;
|
|
46
|
-
|
|
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
|
-
|
|
174
|
+
async function ajaxAsJSON(url, init) {
|
|
171
175
|
let response = await ajax(url, init, 'application/json');
|
|
172
176
|
return response.json();
|
|
173
177
|
}
|
|
174
|
-
|
|
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
|
-
|
|
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.d.ts
CHANGED
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
declare
|
|
2
|
-
path: string;
|
|
3
|
-
}) => void;
|
|
4
|
-
interface Route {
|
|
5
|
-
uri: string;
|
|
6
|
-
callback: Callback;
|
|
7
|
-
}
|
|
8
|
-
declare class Router {
|
|
1
|
+
export declare class Router {
|
|
9
2
|
private routes;
|
|
10
3
|
constructor();
|
|
11
4
|
get(uri: any, callback: any): void;
|
package/lib/router.js
CHANGED
package/lib/settings.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* ___ ___ __
|
|
3
4
|
* \ \_/ / / _
|
|
@@ -22,8 +23,10 @@
|
|
|
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
|
-
|
|
26
|
-
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
exports.Settings = void 0;
|
|
28
|
+
const host_1 = require("./hosts/host");
|
|
29
|
+
class Settings {
|
|
27
30
|
m_data;
|
|
28
31
|
m_name;
|
|
29
32
|
constructor(name) {
|
|
@@ -41,14 +44,14 @@ export class Settings {
|
|
|
41
44
|
}
|
|
42
45
|
_save() {
|
|
43
46
|
let data = JSON.stringify(this.m_data);
|
|
44
|
-
host.writeLocalStorage(this.m_name, data);
|
|
47
|
+
host_1.host.writeLocalStorage(this.m_name, data);
|
|
45
48
|
}
|
|
46
49
|
_load() {
|
|
47
50
|
if (this.m_data) {
|
|
48
51
|
return;
|
|
49
52
|
}
|
|
50
53
|
this.m_data = {};
|
|
51
|
-
let data = host.readLocalStorage(this.m_name);
|
|
54
|
+
let data = host_1.host.readLocalStorage(this.m_name);
|
|
52
55
|
if (data !== null) {
|
|
53
56
|
data = JSON.parse(data);
|
|
54
57
|
if (data) {
|
|
@@ -61,3 +64,4 @@ export class Settings {
|
|
|
61
64
|
// console.info('There was an error attempting to read your settings.');
|
|
62
65
|
}
|
|
63
66
|
}
|
|
67
|
+
exports.Settings = Settings;
|
package/lib/sidebarview.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* ___ ___ __
|
|
3
4
|
* \ \_/ / / _
|
|
@@ -22,23 +23,25 @@
|
|
|
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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
exports.SideBarView = void 0;
|
|
28
|
+
const layout_1 = require("./layout");
|
|
29
|
+
const button_1 = require("./button");
|
|
30
|
+
const cardview_1 = require("./cardview");
|
|
28
31
|
/**
|
|
29
32
|
*
|
|
30
33
|
*/
|
|
31
|
-
|
|
34
|
+
class SideBarView extends cardview_1.CardView {
|
|
32
35
|
m_sidebar;
|
|
33
36
|
m_content;
|
|
34
37
|
constructor(props) {
|
|
35
38
|
super(props);
|
|
36
39
|
this.addClass('@hlayout');
|
|
37
|
-
this.m_sidebar = new VLayout({
|
|
40
|
+
this.m_sidebar = new layout_1.VLayout({
|
|
38
41
|
cls: '@side-bar',
|
|
39
42
|
sizable: props.bar_sizable ? 'right' : undefined,
|
|
40
43
|
});
|
|
41
|
-
this.m_content = new HLayout({ flex: 1, cls: '@tab-container' });
|
|
44
|
+
this.m_content = new layout_1.HLayout({ flex: 1, cls: '@tab-container' });
|
|
42
45
|
}
|
|
43
46
|
/** @ignore */
|
|
44
47
|
render() {
|
|
@@ -46,7 +49,7 @@ export class SideBarView extends CardView {
|
|
|
46
49
|
this.m_cards.forEach((p) => {
|
|
47
50
|
tabs.push(p.selector);
|
|
48
51
|
});
|
|
49
|
-
this.m_sidebar.setContent(new VLayout({
|
|
52
|
+
this.m_sidebar.setContent(new layout_1.VLayout({
|
|
50
53
|
flex: 1,
|
|
51
54
|
cls: 'content',
|
|
52
55
|
content: tabs
|
|
@@ -57,7 +60,7 @@ export class SideBarView extends CardView {
|
|
|
57
60
|
]);
|
|
58
61
|
}
|
|
59
62
|
_prepareSelector(card) {
|
|
60
|
-
return new Button({
|
|
63
|
+
return new button_1.Button({
|
|
61
64
|
text: card.title,
|
|
62
65
|
icon: card.icon,
|
|
63
66
|
tooltip: card.title,
|
|
@@ -71,3 +74,4 @@ export class SideBarView extends CardView {
|
|
|
71
74
|
}
|
|
72
75
|
}
|
|
73
76
|
}
|
|
77
|
+
exports.SideBarView = SideBarView;
|