x4js 1.5.17 → 1.5.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/{README.md → README.txt} +0 -0
- package/lib/cjs/index.js +39 -103
- package/lib/cjs/index.js.map +7 -0
- package/lib/esm/index.mjs +39 -87
- package/lib/esm/index.mjs.map +7 -0
- package/lib/{license.md → licence.md} +0 -0
- package/lib/src/MIT-license.md +14 -0
- package/lib/{types/action.d.ts → src/action.ts} +64 -33
- package/lib/src/alpha.jpg +0 -0
- package/lib/src/app_sockets.ts +81 -0
- package/lib/src/application.ts +251 -0
- package/lib/src/autocomplete.ts +197 -0
- package/lib/src/base64.ts +166 -0
- package/lib/src/base_component.ts +152 -0
- package/lib/src/button.ts +355 -0
- package/lib/src/calendar.ts +328 -0
- package/lib/src/canvas.ts +505 -0
- package/lib/src/cardview.ts +227 -0
- package/lib/src/checkbox.ts +188 -0
- package/lib/src/color.ts +752 -0
- package/lib/src/colorpicker.ts +1639 -0
- package/lib/src/combobox.ts +465 -0
- package/lib/src/component.ts +2329 -0
- package/lib/{esm/dom_events.js → src/copyright.txt} +27 -29
- package/lib/src/datastore.ts +1322 -0
- package/lib/src/dialog.ts +656 -0
- package/lib/src/dom_events.ts +315 -0
- package/lib/src/drag_manager.ts +199 -0
- package/lib/src/drawtext.ts +355 -0
- package/lib/src/fileupload.ts +213 -0
- package/lib/src/form.ts +375 -0
- package/lib/src/formatters.ts +105 -0
- package/lib/src/gridview.ts +1185 -0
- package/lib/src/i18n.ts +346 -0
- package/lib/src/icon.ts +335 -0
- package/lib/src/image.ts +204 -0
- package/lib/src/index.ts +89 -0
- package/lib/src/input.ts +249 -0
- package/lib/src/label.ts +128 -0
- package/lib/src/layout.ts +430 -0
- package/lib/src/link.ts +86 -0
- package/lib/src/listview.ts +765 -0
- package/lib/{esm/md5.js → src/md5.ts} +438 -403
- package/lib/src/menu.ts +425 -0
- package/lib/src/messagebox.ts +224 -0
- package/lib/src/panel.ts +86 -0
- package/lib/src/popup.ts +494 -0
- package/lib/src/property_editor.ts +337 -0
- package/lib/src/radiobtn.ts +197 -0
- package/lib/src/rating.ts +135 -0
- package/lib/src/request.ts +300 -0
- package/lib/src/router.ts +185 -0
- package/lib/src/settings.ts +77 -0
- package/lib/src/sidebarview.ts +103 -0
- package/lib/src/spreadsheet.ts +1449 -0
- package/lib/src/styles.ts +343 -0
- package/lib/src/svgcomponent.ts +577 -0
- package/lib/src/tabbar.ts +151 -0
- package/lib/src/tabview.ts +110 -0
- package/lib/src/textarea.ts +235 -0
- package/lib/src/textedit.ts +544 -0
- package/lib/src/toaster.ts +80 -0
- package/lib/src/tools.ts +1473 -0
- package/lib/src/tooltips.ts +191 -0
- package/lib/src/treeview.ts +716 -0
- package/lib/{esm/version.js → src/version.ts} +30 -29
- package/lib/{styles → src}/x4.less +0 -0
- package/lib/src/x4dom.ts +57 -0
- package/lib/src/x4events.ts +585 -0
- package/lib/src/x4react.ts +90 -0
- package/package.json +52 -49
- package/lib/cjs/action.js +0 -58
- package/lib/cjs/app_sockets.js +0 -74
- package/lib/cjs/application.js +0 -182
- package/lib/cjs/autocomplete.js +0 -155
- package/lib/cjs/base_component.js +0 -124
- package/lib/cjs/button.js +0 -263
- package/lib/cjs/calendar.js +0 -254
- package/lib/cjs/canvas.js +0 -361
- package/lib/cjs/cardview.js +0 -161
- package/lib/cjs/checkbox.js +0 -139
- package/lib/cjs/color.js +0 -591
- package/lib/cjs/colorpicker.js +0 -1468
- package/lib/cjs/combobox.js +0 -349
- package/lib/cjs/component.js +0 -1719
- package/lib/cjs/datastore.js +0 -985
- package/lib/cjs/dialog.js +0 -478
- package/lib/cjs/dom_events.js +0 -30
- package/lib/cjs/drag_manager.js +0 -145
- package/lib/cjs/drawtext.js +0 -276
- package/lib/cjs/fileupload.js +0 -167
- package/lib/cjs/form.js +0 -304
- package/lib/cjs/formatters.js +0 -90
- package/lib/cjs/gridview.js +0 -881
- package/lib/cjs/i18n.js +0 -266
- package/lib/cjs/icon.js +0 -272
- package/lib/cjs/image.js +0 -157
- package/lib/cjs/input.js +0 -174
- package/lib/cjs/label.js +0 -95
- package/lib/cjs/layout.js +0 -322
- package/lib/cjs/link.js +0 -64
- package/lib/cjs/listview.js +0 -546
- package/lib/cjs/md5.js +0 -403
- package/lib/cjs/menu.js +0 -301
- package/lib/cjs/messagebox.js +0 -177
- package/lib/cjs/panel.js +0 -68
- package/lib/cjs/popup.js +0 -383
- package/lib/cjs/property_editor.js +0 -252
- package/lib/cjs/radiobtn.js +0 -140
- package/lib/cjs/rating.js +0 -102
- package/lib/cjs/request.js +0 -246
- package/lib/cjs/router.js +0 -139
- package/lib/cjs/settings.js +0 -69
- package/lib/cjs/sidebarview.js +0 -82
- package/lib/cjs/spreadsheet.js +0 -1084
- package/lib/cjs/styles.js +0 -275
- package/lib/cjs/svgcomponent.js +0 -447
- package/lib/cjs/tabbar.js +0 -111
- package/lib/cjs/tabview.js +0 -85
- package/lib/cjs/textarea.js +0 -165
- package/lib/cjs/textedit.js +0 -415
- package/lib/cjs/toaster.js +0 -64
- package/lib/cjs/tools.js +0 -1197
- package/lib/cjs/tooltips.js +0 -157
- package/lib/cjs/treeview.js +0 -535
- package/lib/cjs/version.js +0 -32
- package/lib/cjs/x4dom.js +0 -32
- package/lib/cjs/x4events.js +0 -384
- package/lib/cjs/x4react.js +0 -72
- package/lib/esm/action.js +0 -53
- package/lib/esm/app_sockets.js +0 -70
- package/lib/esm/application.js +0 -184
- package/lib/esm/autocomplete.js +0 -155
- package/lib/esm/base_component.js +0 -107
- package/lib/esm/button.js +0 -257
- package/lib/esm/calendar.js +0 -249
- package/lib/esm/canvas.js +0 -358
- package/lib/esm/cardview.js +0 -159
- package/lib/esm/checkbox.js +0 -134
- package/lib/esm/color.js +0 -588
- package/lib/esm/colorpicker.js +0 -1475
- package/lib/esm/combobox.js +0 -351
- package/lib/esm/component.js +0 -1711
- package/lib/esm/datastore.js +0 -990
- package/lib/esm/dialog.js +0 -490
- package/lib/esm/drag_manager.js +0 -147
- package/lib/esm/drawtext.js +0 -271
- package/lib/esm/fileupload.js +0 -163
- package/lib/esm/form.js +0 -304
- package/lib/esm/formatters.js +0 -81
- package/lib/esm/gridview.js +0 -889
- package/lib/esm/i18n.js +0 -257
- package/lib/esm/icon.js +0 -261
- package/lib/esm/image.js +0 -154
- package/lib/esm/input.js +0 -182
- package/lib/esm/label.js +0 -90
- package/lib/esm/layout.js +0 -310
- package/lib/esm/link.js +0 -59
- package/lib/esm/listview.js +0 -534
- package/lib/esm/menu.js +0 -300
- package/lib/esm/messagebox.js +0 -161
- package/lib/esm/panel.js +0 -65
- package/lib/esm/popup.js +0 -379
- package/lib/esm/property_editor.js +0 -251
- package/lib/esm/radiobtn.js +0 -136
- package/lib/esm/rating.js +0 -97
- package/lib/esm/request.js +0 -224
- package/lib/esm/router.js +0 -136
- package/lib/esm/settings.js +0 -66
- package/lib/esm/sidebarview.js +0 -79
- package/lib/esm/spreadsheet.js +0 -1097
- package/lib/esm/styles.js +0 -270
- package/lib/esm/svgcomponent.js +0 -450
- package/lib/esm/tabbar.js +0 -107
- package/lib/esm/tabview.js +0 -83
- package/lib/esm/textarea.js +0 -160
- package/lib/esm/textedit.js +0 -412
- package/lib/esm/toaster.js +0 -62
- package/lib/esm/tools.js +0 -1158
- package/lib/esm/tooltips.js +0 -153
- package/lib/esm/treeview.js +0 -527
- package/lib/esm/x4dom.js +0 -29
- package/lib/esm/x4events.js +0 -376
- package/lib/esm/x4react.js +0 -71
- package/lib/types/app_sockets.d.ts +0 -29
- package/lib/types/application.d.ts +0 -104
- package/lib/types/autocomplete.d.ts +0 -58
- package/lib/types/base_component.d.ts +0 -88
- package/lib/types/button.d.ts +0 -151
- package/lib/types/calendar.d.ts +0 -82
- package/lib/types/canvas.d.ts +0 -92
- package/lib/types/cardview.d.ts +0 -87
- package/lib/types/checkbox.d.ts +0 -77
- package/lib/types/color.d.ts +0 -148
- package/lib/types/colorpicker.d.ts +0 -107
- package/lib/types/combobox.d.ts +0 -107
- package/lib/types/component.d.ts +0 -601
- package/lib/types/datastore.d.ts +0 -396
- package/lib/types/dialog.d.ts +0 -175
- package/lib/types/dom_events.d.ts +0 -302
- package/lib/types/drag_manager.d.ts +0 -54
- package/lib/types/drawtext.d.ts +0 -48
- package/lib/types/fileupload.d.ts +0 -64
- package/lib/types/form.d.ts +0 -133
- package/lib/types/formatters.d.ts +0 -35
- package/lib/types/gridview.d.ts +0 -175
- package/lib/types/i18n.d.ts +0 -73
- package/lib/types/icon.d.ts +0 -64
- package/lib/types/image.d.ts +0 -55
- package/lib/types/index.d.ts +0 -84
- package/lib/types/input.d.ts +0 -91
- package/lib/types/label.d.ts +0 -58
- package/lib/types/layout.d.ts +0 -87
- package/lib/types/link.d.ts +0 -50
- package/lib/types/listview.d.ts +0 -178
- package/lib/types/md5.d.ts +0 -61
- package/lib/types/menu.d.ts +0 -130
- package/lib/types/messagebox.d.ts +0 -69
- package/lib/types/panel.d.ts +0 -47
- package/lib/types/popup.d.ts +0 -75
- package/lib/types/property_editor.d.ts +0 -71
- package/lib/types/radiobtn.d.ts +0 -73
- package/lib/types/rating.d.ts +0 -53
- package/lib/types/request.d.ts +0 -52
- package/lib/types/router.d.ts +0 -42
- package/lib/types/settings.d.ts +0 -37
- package/lib/types/sidebarview.d.ts +0 -49
- package/lib/types/spreadsheet.d.ts +0 -222
- package/lib/types/styles.d.ts +0 -85
- package/lib/types/svgcomponent.d.ts +0 -215
- package/lib/types/tabbar.d.ts +0 -58
- package/lib/types/tabview.d.ts +0 -49
- package/lib/types/textarea.d.ts +0 -77
- package/lib/types/textedit.d.ts +0 -123
- package/lib/types/toaster.d.ts +0 -42
- package/lib/types/tools.d.ts +0 -394
- package/lib/types/tooltips.d.ts +0 -46
- package/lib/types/treeview.d.ts +0 -144
- package/lib/types/version.d.ts +0 -29
- package/lib/types/x4dom.d.ts +0 -49
- package/lib/types/x4events.d.ts +0 -269
- package/lib/types/x4react.d.ts +0 -41
package/lib/cjs/tooltips.js
DELETED
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* ___ ___ __
|
|
4
|
-
* \ \_/ / / _
|
|
5
|
-
* \ / /_| |_
|
|
6
|
-
* / _ \____ _|
|
|
7
|
-
* /__/ \__\ |_|
|
|
8
|
-
*
|
|
9
|
-
* @file tooltips.ts
|
|
10
|
-
* @author Etienne Cochard
|
|
11
|
-
*
|
|
12
|
-
* Copyright (c) 2019-2022 R-libre ingenierie
|
|
13
|
-
*
|
|
14
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
15
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
16
|
-
* in the Software without restriction, including without limitation the rights
|
|
17
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
18
|
-
* of the Software, and to permit persons to whom the Software is furnished to do so,
|
|
19
|
-
* subject to the following conditions:
|
|
20
|
-
* The above copyright notice and this permission notice shall be included in all copies
|
|
21
|
-
* or substantial portions of the Software.
|
|
22
|
-
*
|
|
23
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
24
|
-
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
|
25
|
-
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
26
|
-
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
27
|
-
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
28
|
-
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
29
|
-
**/
|
|
30
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
-
exports.initTooltips = exports.Tooltip = void 0;
|
|
32
|
-
const x4dom_1 = require("./x4dom");
|
|
33
|
-
const component_1 = require("./component");
|
|
34
|
-
const label_1 = require("./label");
|
|
35
|
-
const icon_1 = require("./icon");
|
|
36
|
-
const tools_1 = require("./tools");
|
|
37
|
-
let tipTmo;
|
|
38
|
-
let tooltip;
|
|
39
|
-
/**
|
|
40
|
-
*
|
|
41
|
-
*/
|
|
42
|
-
class Tooltip extends component_1.Component {
|
|
43
|
-
set text(text) {
|
|
44
|
-
this.m_text.text = text;
|
|
45
|
-
}
|
|
46
|
-
/** @ignore */
|
|
47
|
-
render() {
|
|
48
|
-
this.setClass('@non-maskable', true);
|
|
49
|
-
this.setContent([
|
|
50
|
-
new icon_1.Icon({ icon: 'var( --x4-icon-tip )' }),
|
|
51
|
-
this.m_text = new label_1.Label({ text: 'help' })
|
|
52
|
-
]);
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* display the menu at a specific position
|
|
56
|
-
* @param x
|
|
57
|
-
* @param y
|
|
58
|
-
*/
|
|
59
|
-
displayAt(x, y, align = 'top left') {
|
|
60
|
-
this.show();
|
|
61
|
-
let halign = 'l', valign = 't';
|
|
62
|
-
if (align.indexOf('right') >= 0) {
|
|
63
|
-
halign = 'r';
|
|
64
|
-
}
|
|
65
|
-
if (align.indexOf('bottom') >= 0) {
|
|
66
|
-
valign = 'b';
|
|
67
|
-
}
|
|
68
|
-
// @TODO: this is a minimal overflow problem solution
|
|
69
|
-
let rc = x4dom_1.x4document.body.getBoundingClientRect(), rm = this.getBoundingRect();
|
|
70
|
-
if (halign == 'r') {
|
|
71
|
-
x -= rm.width;
|
|
72
|
-
}
|
|
73
|
-
if (valign == 'b') {
|
|
74
|
-
y -= rm.height;
|
|
75
|
-
}
|
|
76
|
-
if ((x + rm.width) > rc.right) {
|
|
77
|
-
x = rc.right - rm.width;
|
|
78
|
-
}
|
|
79
|
-
if ((y + rm.height) > rc.bottom) {
|
|
80
|
-
y = rc.bottom - rm.height - 17; // default cursor height
|
|
81
|
-
}
|
|
82
|
-
this.setStyle({ left: x, top: y });
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
exports.Tooltip = Tooltip;
|
|
86
|
-
function initTooltips(cb) {
|
|
87
|
-
if ((0, tools_1.isTouchDevice)()) {
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
let tipTarget = {
|
|
91
|
-
target: null,
|
|
92
|
-
x: 0,
|
|
93
|
-
y: 0
|
|
94
|
-
};
|
|
95
|
-
function handle_mpos(event) {
|
|
96
|
-
tipTarget.x = event.pageX;
|
|
97
|
-
tipTarget.y = event.pageY;
|
|
98
|
-
}
|
|
99
|
-
function handle_mouse(event) {
|
|
100
|
-
let target = event.target;
|
|
101
|
-
let tip = null;
|
|
102
|
-
tipTarget.x = event.pageX + 10;
|
|
103
|
-
tipTarget.y = event.pageY + 15;
|
|
104
|
-
while (target) {
|
|
105
|
-
tip = target.getAttribute('tip');
|
|
106
|
-
if (tip) {
|
|
107
|
-
break;
|
|
108
|
-
}
|
|
109
|
-
target = target.parentElement;
|
|
110
|
-
}
|
|
111
|
-
if (target == tipTarget.target || (tooltip && target == tooltip.dom)) {
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
if (!target || !tip) {
|
|
115
|
-
tipTarget.target = null;
|
|
116
|
-
if (cb) {
|
|
117
|
-
cb(null);
|
|
118
|
-
}
|
|
119
|
-
else {
|
|
120
|
-
_hideTip();
|
|
121
|
-
}
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
tipTarget.target = target;
|
|
125
|
-
if (cb) {
|
|
126
|
-
cb(null);
|
|
127
|
-
}
|
|
128
|
-
else {
|
|
129
|
-
_hideTip();
|
|
130
|
-
}
|
|
131
|
-
if (cb) {
|
|
132
|
-
cb(tip);
|
|
133
|
-
}
|
|
134
|
-
else {
|
|
135
|
-
tipTmo = setTimeout(() => {
|
|
136
|
-
if (tooltip === undefined) {
|
|
137
|
-
tooltip = new Tooltip({});
|
|
138
|
-
x4dom_1.x4document.body.appendChild(tooltip._build());
|
|
139
|
-
}
|
|
140
|
-
tooltip.text = tip;
|
|
141
|
-
tooltip.displayAt(tipTarget.x + 17, tipTarget.y + 17, 'top left');
|
|
142
|
-
}, 700);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
function _hideTip() {
|
|
146
|
-
if (tipTmo) {
|
|
147
|
-
clearTimeout(tipTmo);
|
|
148
|
-
}
|
|
149
|
-
if (tooltip) {
|
|
150
|
-
tooltip.hide();
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
x4dom_1.x4document.body.addEventListener('mouseover', handle_mouse);
|
|
154
|
-
x4dom_1.x4document.body.addEventListener('mouseout', handle_mouse);
|
|
155
|
-
x4dom_1.x4document.body.addEventListener('mousemove', handle_mpos);
|
|
156
|
-
}
|
|
157
|
-
exports.initTooltips = initTooltips;
|
package/lib/cjs/treeview.js
DELETED
|
@@ -1,535 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* ___ ___ __
|
|
4
|
-
* \ \_/ / / _
|
|
5
|
-
* \ / /_| |_
|
|
6
|
-
* / _ \____ _|
|
|
7
|
-
* /__/ \__\ |_|
|
|
8
|
-
*
|
|
9
|
-
* @file treeview.ts
|
|
10
|
-
* @author Etienne Cochard
|
|
11
|
-
*
|
|
12
|
-
* Copyright (c) 2019-2022 R-libre ingenierie
|
|
13
|
-
*
|
|
14
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
15
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
16
|
-
* in the Software without restriction, including without limitation the rights
|
|
17
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
18
|
-
* of the Software, and to permit persons to whom the Software is furnished to do so,
|
|
19
|
-
* subject to the following conditions:
|
|
20
|
-
* The above copyright notice and this permission notice shall be included in all copies
|
|
21
|
-
* or substantial portions of the Software.
|
|
22
|
-
*
|
|
23
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
24
|
-
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
|
25
|
-
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
26
|
-
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
27
|
-
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
28
|
-
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
29
|
-
**/
|
|
30
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
-
exports.TreeView = void 0;
|
|
32
|
-
const component_1 = require("./component");
|
|
33
|
-
const icon_1 = require("./icon");
|
|
34
|
-
const label_1 = require("./label");
|
|
35
|
-
const layout_1 = require("./layout");
|
|
36
|
-
const x4events_1 = require("./x4events");
|
|
37
|
-
function EvExpand(node) {
|
|
38
|
-
return (0, x4events_1.BasicEvent)({ node });
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
*
|
|
42
|
-
*/
|
|
43
|
-
class TreeView extends layout_1.VLayout {
|
|
44
|
-
constructor(props) {
|
|
45
|
-
var _a, _b;
|
|
46
|
-
super(props);
|
|
47
|
-
props.root = props.root;
|
|
48
|
-
props.indent = (_a = props.indent) !== null && _a !== void 0 ? _a : 8;
|
|
49
|
-
props.gadgets = props.gadgets;
|
|
50
|
-
props.sort = (_b = props.sort) !== null && _b !== void 0 ? _b : false;
|
|
51
|
-
this.m_selection = null;
|
|
52
|
-
this.m_container = new component_1.Container({ cls: '@scroll-container' });
|
|
53
|
-
this.m_view = new component_1.Container({
|
|
54
|
-
cls: '@scroll-view',
|
|
55
|
-
flex: 1,
|
|
56
|
-
content: this.m_container
|
|
57
|
-
});
|
|
58
|
-
this.setContent([
|
|
59
|
-
this.m_view,
|
|
60
|
-
props.gadgets ? new layout_1.HLayout({
|
|
61
|
-
cls: 'gadgets',
|
|
62
|
-
content: props.gadgets
|
|
63
|
-
}) : null,
|
|
64
|
-
]);
|
|
65
|
-
this.setDomEvent('click', (e) => this._click(e));
|
|
66
|
-
this.setDomEvent('dblclick', (e) => this._click(e));
|
|
67
|
-
this.setDomEvent('contextmenu', (e) => this._handleCtxMenu(e));
|
|
68
|
-
if (props.canDragItems) {
|
|
69
|
-
this.setDomEvent('dragstart', (ev) => {
|
|
70
|
-
let hit = component_1.Component.getElement(ev.target, component_1.Component);
|
|
71
|
-
let node = hit === null || hit === void 0 ? void 0 : hit.getData("node");
|
|
72
|
-
if (node) {
|
|
73
|
-
ev.dataTransfer.effectAllowed = 'move';
|
|
74
|
-
ev.dataTransfer.items.add(JSON.stringify({
|
|
75
|
-
type: 'treeview',
|
|
76
|
-
id: node.id
|
|
77
|
-
}), 'string');
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
ev.preventDefault();
|
|
81
|
-
ev.stopPropagation();
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
this.setDomEvent('dragover', ev => this._dragEnter(ev));
|
|
85
|
-
this.setDomEvent('dragenter', ev => this._dragEnter(ev));
|
|
86
|
-
this.setDomEvent('dragend', ev => this._dragLeave(ev));
|
|
87
|
-
this.setDomEvent('dragleave', ev => this._dragLeave(ev));
|
|
88
|
-
this.setDomEvent('drop', ev => this._dragLeave(ev));
|
|
89
|
-
this.setDomEvent('drop', ev => this._drop(ev));
|
|
90
|
-
}
|
|
91
|
-
this.mapPropEvents(props, 'dblclick', 'drag', 'selectionchange', 'contextMenu');
|
|
92
|
-
}
|
|
93
|
-
_dragEnter(ev) {
|
|
94
|
-
ev.preventDefault();
|
|
95
|
-
let hit = component_1.Component.getElement(ev.target, component_1.Component);
|
|
96
|
-
let node = hit === null || hit === void 0 ? void 0 : hit.getData("node");
|
|
97
|
-
if (node) {
|
|
98
|
-
hit.addClass('@drag-over');
|
|
99
|
-
ev.dataTransfer.dropEffect = 'move';
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
_dragLeave(ev) {
|
|
103
|
-
let hit = component_1.Component.getElement(ev.target, component_1.Component);
|
|
104
|
-
let node = hit === null || hit === void 0 ? void 0 : hit.getData("node");
|
|
105
|
-
if (node) {
|
|
106
|
-
hit.removeClass('@drag-over');
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
_drop(ev) {
|
|
110
|
-
let hit = component_1.Component.getElement(ev.target, component_1.Component);
|
|
111
|
-
let node = hit === null || hit === void 0 ? void 0 : hit.getData("node");
|
|
112
|
-
if (!node) {
|
|
113
|
-
node = this.m_props.root;
|
|
114
|
-
}
|
|
115
|
-
if (node) {
|
|
116
|
-
let parent;
|
|
117
|
-
// is a folder
|
|
118
|
-
if (node.children) {
|
|
119
|
-
parent = node;
|
|
120
|
-
}
|
|
121
|
-
// in it's parent node
|
|
122
|
-
else {
|
|
123
|
-
parent = hit.getData("parent");
|
|
124
|
-
}
|
|
125
|
-
for (let i = 0; i < ev.dataTransfer.items.length; i++) {
|
|
126
|
-
ev.dataTransfer.items[0].getAsString((value) => {
|
|
127
|
-
let data = JSON.parse(value);
|
|
128
|
-
this.emit('drag', (0, x4events_1.EvDrag)(node, data, parent));
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
render() {
|
|
134
|
-
this.__update();
|
|
135
|
-
}
|
|
136
|
-
__update() {
|
|
137
|
-
if (this.m_props.root) {
|
|
138
|
-
let items = [];
|
|
139
|
-
this._buildBranch(this.m_props.root, -1, items, this.m_props.root);
|
|
140
|
-
this.m_container.setContent(items);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
updateElement(id) {
|
|
144
|
-
var _a;
|
|
145
|
-
const { node: child, item } = this._getNode(id);
|
|
146
|
-
if (child) {
|
|
147
|
-
const pn = child.dom.parentNode;
|
|
148
|
-
const newchild = this._makeNode(item, child.dom.classList.value, child.getData('icon'), child.getData('level'));
|
|
149
|
-
const dm = newchild._build();
|
|
150
|
-
pn.replaceChild(dm, child.dom);
|
|
151
|
-
if (((_a = this.m_selection) === null || _a === void 0 ? void 0 : _a.el) === child) {
|
|
152
|
-
this.m_selection.el = newchild;
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
set root(root) {
|
|
157
|
-
this.m_props.root = root;
|
|
158
|
-
this.update();
|
|
159
|
-
}
|
|
160
|
-
openAll(open = true) {
|
|
161
|
-
this.forEach((node) => {
|
|
162
|
-
if (node.children) {
|
|
163
|
-
node.open = open;
|
|
164
|
-
}
|
|
165
|
-
});
|
|
166
|
-
this.__update();
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* same as root = xxx but keep elements open
|
|
170
|
-
*/
|
|
171
|
-
refreshRoot(root) {
|
|
172
|
-
let openList = [];
|
|
173
|
-
this.forEach((node) => {
|
|
174
|
-
if (node.open) {
|
|
175
|
-
openList.push(node.id);
|
|
176
|
-
}
|
|
177
|
-
return false;
|
|
178
|
-
});
|
|
179
|
-
let oldSel = this.selection;
|
|
180
|
-
if (root) {
|
|
181
|
-
this.m_props.root = root;
|
|
182
|
-
}
|
|
183
|
-
this.forEach((node) => {
|
|
184
|
-
if (openList.indexOf(node.id) >= 0) {
|
|
185
|
-
node.open = true;
|
|
186
|
-
}
|
|
187
|
-
return false;
|
|
188
|
-
});
|
|
189
|
-
this.__update();
|
|
190
|
-
}
|
|
191
|
-
_buildBranch(node, level, items, parent) {
|
|
192
|
-
var _a;
|
|
193
|
-
let cls = '@tree-item';
|
|
194
|
-
if (node.cls) {
|
|
195
|
-
cls += ' ' + node.cls;
|
|
196
|
-
}
|
|
197
|
-
if (!node.open && node.children) {
|
|
198
|
-
cls += ' collapsed';
|
|
199
|
-
}
|
|
200
|
-
if (node.children) {
|
|
201
|
-
cls += ' folder';
|
|
202
|
-
if (node.children.length == 0) {
|
|
203
|
-
cls += ' empty';
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
let icon = node.icon;
|
|
207
|
-
if (icon === undefined) {
|
|
208
|
-
if (node.children) {
|
|
209
|
-
if (node.open === true) {
|
|
210
|
-
icon = 'var(--x4-icon-chevron-down)';
|
|
211
|
-
}
|
|
212
|
-
else {
|
|
213
|
-
icon = 'var(--x4-icon-chevron-right)';
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
if (level >= 0) {
|
|
218
|
-
const item = this._makeNode(node, cls, icon, level);
|
|
219
|
-
if (((_a = this.m_selection) === null || _a === void 0 ? void 0 : _a.id) == node.id) {
|
|
220
|
-
this.m_selection.el = item;
|
|
221
|
-
item.addClass('selected');
|
|
222
|
-
}
|
|
223
|
-
items.push(item);
|
|
224
|
-
}
|
|
225
|
-
if (level == -1 || node.open) {
|
|
226
|
-
if (node.children) {
|
|
227
|
-
if (this.m_props.sort) {
|
|
228
|
-
// sort items case insensitive:
|
|
229
|
-
// first folders
|
|
230
|
-
// then items
|
|
231
|
-
node.children = node.children.sort((a, b) => {
|
|
232
|
-
var _a, _b;
|
|
233
|
-
let at = (_a = (a.children ? '0' + a.text : a.text)) === null || _a === void 0 ? void 0 : _a.toLocaleLowerCase();
|
|
234
|
-
let bt = (_b = (b.children ? '0' + b.text : b.text)) === null || _b === void 0 ? void 0 : _b.toLocaleLowerCase();
|
|
235
|
-
return at < bt ? -1 : at > bt ? 1 : 0;
|
|
236
|
-
});
|
|
237
|
-
}
|
|
238
|
-
node.children.forEach((c) => {
|
|
239
|
-
this._buildBranch(c, level + 1, items, node);
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
_renderDef(node) {
|
|
245
|
-
return new label_1.Label({ cls: 'tree-label', flex: 1, text: node.text });
|
|
246
|
-
}
|
|
247
|
-
_makeNode(node, cls, icon, level) {
|
|
248
|
-
const item = new layout_1.HLayout({
|
|
249
|
-
cls,
|
|
250
|
-
content: [
|
|
251
|
-
new icon_1.Icon({ cls: 'tree-icon', icon }),
|
|
252
|
-
this.m_props.renderItem ? this.m_props.renderItem(node) : this._renderDef(node),
|
|
253
|
-
],
|
|
254
|
-
data: {
|
|
255
|
-
'node': node,
|
|
256
|
-
'level': level,
|
|
257
|
-
'icon': icon,
|
|
258
|
-
},
|
|
259
|
-
style: {
|
|
260
|
-
paddingLeft: 4 + level * this.m_props.indent
|
|
261
|
-
},
|
|
262
|
-
attrs: {
|
|
263
|
-
draggable: this.m_props.canDragItems ? true : undefined
|
|
264
|
-
},
|
|
265
|
-
});
|
|
266
|
-
return item;
|
|
267
|
-
}
|
|
268
|
-
/**
|
|
269
|
-
*
|
|
270
|
-
*/
|
|
271
|
-
forEach(cb) {
|
|
272
|
-
let found = null;
|
|
273
|
-
function scan(node) {
|
|
274
|
-
if (cb(node) == true) {
|
|
275
|
-
return true;
|
|
276
|
-
}
|
|
277
|
-
if (node.children) {
|
|
278
|
-
for (let i = 0; i < node.children.length; i++) {
|
|
279
|
-
if (scan(node.children[i])) {
|
|
280
|
-
return true;
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
if (this.m_props.root) {
|
|
286
|
-
scan(this.m_props.root);
|
|
287
|
-
}
|
|
288
|
-
return found;
|
|
289
|
-
}
|
|
290
|
-
ensureVisible(id) {
|
|
291
|
-
const { node } = this._getNode(id);
|
|
292
|
-
if (node) {
|
|
293
|
-
node.scrollIntoView();
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
set selection(id) {
|
|
297
|
-
this.select(id, false);
|
|
298
|
-
}
|
|
299
|
-
/**
|
|
300
|
-
* care, component should have been created, to select an item at startup,
|
|
301
|
-
* use something like
|
|
302
|
-
* componentCreated( ) {
|
|
303
|
-
* mytree.select( id );
|
|
304
|
-
* }
|
|
305
|
-
*/
|
|
306
|
-
select(id, notify = true) {
|
|
307
|
-
var _a;
|
|
308
|
-
if ((_a = this.m_selection) === null || _a === void 0 ? void 0 : _a.el) {
|
|
309
|
-
this.m_selection.el.removeClass('selected');
|
|
310
|
-
}
|
|
311
|
-
this.m_selection = null;
|
|
312
|
-
if (id !== undefined) {
|
|
313
|
-
const { node: sel } = this._getNode(id);
|
|
314
|
-
if (sel) {
|
|
315
|
-
this.m_selection = {
|
|
316
|
-
id: id,
|
|
317
|
-
el: sel
|
|
318
|
-
};
|
|
319
|
-
sel.addClass('selected');
|
|
320
|
-
sel.scrollIntoView();
|
|
321
|
-
if (notify) {
|
|
322
|
-
let nd = sel.getData('node');
|
|
323
|
-
this.emit('selectionchange', (0, x4events_1.EvSelectionChange)(nd));
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
else {
|
|
328
|
-
if (notify) {
|
|
329
|
-
this.emit('selectionchange', (0, x4events_1.EvSelectionChange)(null));
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
_getNode(id) {
|
|
334
|
-
let found = { node: null, item: null };
|
|
335
|
-
this.m_container.enumChilds((c) => {
|
|
336
|
-
let node = c.getData('node');
|
|
337
|
-
if ((node === null || node === void 0 ? void 0 : node.id) == id) {
|
|
338
|
-
found = { node: c, item: node };
|
|
339
|
-
return true;
|
|
340
|
-
}
|
|
341
|
-
});
|
|
342
|
-
return found;
|
|
343
|
-
}
|
|
344
|
-
get selection() {
|
|
345
|
-
var _a;
|
|
346
|
-
return (_a = this.m_selection) === null || _a === void 0 ? void 0 : _a.id;
|
|
347
|
-
}
|
|
348
|
-
getNodeWithId(id) {
|
|
349
|
-
return this.forEach((node) => node.id == id);
|
|
350
|
-
}
|
|
351
|
-
/**
|
|
352
|
-
*
|
|
353
|
-
*/
|
|
354
|
-
_click(ev) {
|
|
355
|
-
var _a, _b;
|
|
356
|
-
let dom = ev.target;
|
|
357
|
-
let idom = dom;
|
|
358
|
-
let onsub = false;
|
|
359
|
-
// avoid getting click on sub childs
|
|
360
|
-
if (dom.tabIndex !== -1) {
|
|
361
|
-
onsub = true;
|
|
362
|
-
}
|
|
363
|
-
while (dom != this.dom) {
|
|
364
|
-
let el = component_1.Component.getElement(dom);
|
|
365
|
-
let nd = el === null || el === void 0 ? void 0 : el.getData('node');
|
|
366
|
-
if (nd) {
|
|
367
|
-
if (nd.children && !onsub) {
|
|
368
|
-
// on text or on expando ?
|
|
369
|
-
if (el.hasClass('selected') || idom.classList.contains('tree-icon')) { //expando
|
|
370
|
-
nd.open = nd.open ? false : true;
|
|
371
|
-
}
|
|
372
|
-
this.m_selection = { id: nd.id, el: null };
|
|
373
|
-
let offset = (_b = (_a = this.m_view) === null || _a === void 0 ? void 0 : _a.dom) === null || _b === void 0 ? void 0 : _b.scrollTop;
|
|
374
|
-
this.update();
|
|
375
|
-
if (offset) {
|
|
376
|
-
this.m_view.dom.scrollTo(0, offset);
|
|
377
|
-
}
|
|
378
|
-
this.emit('expand', EvExpand(nd));
|
|
379
|
-
}
|
|
380
|
-
else {
|
|
381
|
-
this.selection = nd.id;
|
|
382
|
-
if (!onsub) {
|
|
383
|
-
if (ev.type == 'click') {
|
|
384
|
-
this.emit('click', (0, x4events_1.EvClick)(nd));
|
|
385
|
-
}
|
|
386
|
-
else {
|
|
387
|
-
this.emit('dblclick', (0, component_1.EvDblClick)(nd));
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
this.emit('selectionchange', (0, x4events_1.EvSelectionChange)(nd));
|
|
392
|
-
return;
|
|
393
|
-
}
|
|
394
|
-
dom = dom.parentElement;
|
|
395
|
-
}
|
|
396
|
-
if (ev.type == 'click') {
|
|
397
|
-
this.m_selection = null;
|
|
398
|
-
this.update();
|
|
399
|
-
this.emit('selectionchange', (0, x4events_1.EvSelectionChange)(null));
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
_handleCtxMenu(ev) {
|
|
403
|
-
ev.preventDefault();
|
|
404
|
-
let dom = ev.target;
|
|
405
|
-
let idom = dom;
|
|
406
|
-
while (dom != this.dom) {
|
|
407
|
-
let el = component_1.Component.getElement(dom);
|
|
408
|
-
let nd = el === null || el === void 0 ? void 0 : el.getData('node');
|
|
409
|
-
if (nd) {
|
|
410
|
-
if (nd.children) {
|
|
411
|
-
// on text or on expando ?
|
|
412
|
-
if (idom.classList.contains('tree-icon')) { //expando
|
|
413
|
-
return;
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
this.selection = nd.id;
|
|
417
|
-
this.emit('click', (0, x4events_1.EvClick)(nd));
|
|
418
|
-
this.emit('contextMenu', (0, x4events_1.EvContextMenu)(ev, nd));
|
|
419
|
-
return;
|
|
420
|
-
}
|
|
421
|
-
dom = dom.parentElement;
|
|
422
|
-
}
|
|
423
|
-
this.selection = null;
|
|
424
|
-
this.emit('contextMenu', (0, x4events_1.EvContextMenu)(ev, null));
|
|
425
|
-
}
|
|
426
|
-
/**
|
|
427
|
-
* constructs a tree node from an array of strings
|
|
428
|
-
* elements are organized like folders (separator = /)
|
|
429
|
-
* @example
|
|
430
|
-
* let root = TreeView.buildFromString( [
|
|
431
|
-
* 'this/is/a/final/file'
|
|
432
|
-
* 'this/is/another/file'
|
|
433
|
-
* ] );
|
|
434
|
-
*/
|
|
435
|
-
static buildFromStrings(paths, separator = '/') {
|
|
436
|
-
let root = {
|
|
437
|
-
id: 0,
|
|
438
|
-
text: '<root>',
|
|
439
|
-
children: []
|
|
440
|
-
};
|
|
441
|
-
function insert(elements, path) {
|
|
442
|
-
let pos = path.indexOf(separator);
|
|
443
|
-
let main = path.substr(0, pos < 0 ? undefined : pos);
|
|
444
|
-
let elem;
|
|
445
|
-
if (pos >= 0) {
|
|
446
|
-
elem = elements.find((el) => {
|
|
447
|
-
return el.text == main;
|
|
448
|
-
});
|
|
449
|
-
}
|
|
450
|
-
if (!elem) {
|
|
451
|
-
elem = {
|
|
452
|
-
id: path,
|
|
453
|
-
text: main,
|
|
454
|
-
};
|
|
455
|
-
elements.push(elem);
|
|
456
|
-
}
|
|
457
|
-
if (pos >= 0) {
|
|
458
|
-
if (!elem.children) {
|
|
459
|
-
elem.children = [];
|
|
460
|
-
}
|
|
461
|
-
insert(elem.children, path.substr(pos + separator.length));
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
paths.forEach((path) => {
|
|
465
|
-
insert(root.children, path);
|
|
466
|
-
});
|
|
467
|
-
return root;
|
|
468
|
-
}
|
|
469
|
-
/**
|
|
470
|
-
* constructs a tree node from an array of nodes like
|
|
471
|
-
* node {
|
|
472
|
-
* id: number,
|
|
473
|
-
* parent: number,
|
|
474
|
-
* name: string
|
|
475
|
-
* }
|
|
476
|
-
*/
|
|
477
|
-
static buildFromHierarchy(nodes, cb) {
|
|
478
|
-
let root = {
|
|
479
|
-
id: 0,
|
|
480
|
-
text: '<root>',
|
|
481
|
-
children: []
|
|
482
|
-
};
|
|
483
|
-
let tree_nodes = [];
|
|
484
|
-
function insert(node) {
|
|
485
|
-
let elem;
|
|
486
|
-
let pelem;
|
|
487
|
-
if (node.parent > 0) {
|
|
488
|
-
pelem = tree_nodes.find((tnode) => tnode.id == node.parent);
|
|
489
|
-
if (!pelem) {
|
|
490
|
-
pelem = {
|
|
491
|
-
id: node.parent,
|
|
492
|
-
text: '',
|
|
493
|
-
children: []
|
|
494
|
-
};
|
|
495
|
-
tree_nodes.push(pelem);
|
|
496
|
-
}
|
|
497
|
-
if (!pelem.children) {
|
|
498
|
-
pelem.children = [];
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
else {
|
|
502
|
-
pelem = root;
|
|
503
|
-
}
|
|
504
|
-
elem = tree_nodes.find((tnode) => tnode.id == node.id);
|
|
505
|
-
if (!elem) {
|
|
506
|
-
elem = {
|
|
507
|
-
id: node.id,
|
|
508
|
-
text: node.name,
|
|
509
|
-
parent: node.parent,
|
|
510
|
-
cls: node.cls,
|
|
511
|
-
icon: node.icon,
|
|
512
|
-
data: node.data,
|
|
513
|
-
};
|
|
514
|
-
if (!node.leaf) {
|
|
515
|
-
elem.children = [];
|
|
516
|
-
}
|
|
517
|
-
else {
|
|
518
|
-
elem.icon = null;
|
|
519
|
-
}
|
|
520
|
-
}
|
|
521
|
-
else {
|
|
522
|
-
elem.text = node.name;
|
|
523
|
-
elem.parent = node.parent;
|
|
524
|
-
}
|
|
525
|
-
tree_nodes.push(elem);
|
|
526
|
-
pelem.children.push(elem);
|
|
527
|
-
}
|
|
528
|
-
nodes.forEach(insert);
|
|
529
|
-
if (cb) {
|
|
530
|
-
tree_nodes.forEach(cb);
|
|
531
|
-
}
|
|
532
|
-
return root;
|
|
533
|
-
}
|
|
534
|
-
}
|
|
535
|
-
exports.TreeView = TreeView;
|