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.
- package/lib/application.d.ts +96 -0
- package/lib/application.js +146 -0
- package/lib/base64.d.ts +31 -0
- package/lib/base64.js +139 -0
- package/lib/base_component.d.ts +64 -0
- package/lib/base_component.js +81 -0
- package/lib/button.d.ts +145 -0
- package/lib/button.js +241 -0
- package/lib/calendar.d.ts +77 -0
- package/lib/calendar.js +241 -0
- package/lib/canvas.d.ts +88 -0
- package/lib/canvas.js +358 -0
- package/lib/cardview.d.ts +83 -0
- package/lib/cardview.js +156 -0
- package/lib/checkbox.d.ts +72 -0
- package/lib/checkbox.js +130 -0
- package/lib/color.d.ts +144 -0
- package/lib/color.js +588 -0
- package/lib/colorpicker.js +86 -80
- package/lib/combobox.js +26 -22
- package/lib/component.d.ts +572 -0
- package/lib/component.js +1729 -0
- package/lib/datastore.js +29 -20
- package/lib/dialog.js +41 -36
- package/lib/dom_events.d.ts +284 -0
- package/lib/dom_events.js +14 -0
- 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.d.ts +44 -0
- package/lib/hosts/host.js +73 -0
- package/lib/i18n.d.ts +67 -0
- package/lib/i18n.js +175 -0
- package/lib/icon.d.ts +56 -0
- package/lib/icon.js +178 -0
- package/lib/image.js +7 -3
- package/lib/index.js +71 -55
- package/lib/input.d.ts +86 -0
- package/lib/input.js +176 -0
- package/lib/label.d.ts +54 -0
- package/lib/label.js +90 -0
- package/lib/layout.d.ts +77 -0
- package/lib/layout.js +271 -0
- package/lib/link.js +9 -5
- package/lib/listview.js +34 -27
- package/lib/md5.js +5 -1
- package/lib/menu.d.ts +122 -0
- package/lib/menu.js +284 -0
- package/lib/messagebox.js +22 -17
- package/lib/panel.js +13 -9
- package/lib/popup.d.ts +71 -0
- package/lib/popup.js +378 -0
- 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.js +5 -1
- package/lib/settings.d.ts +33 -0
- package/lib/settings.js +67 -0
- package/lib/sidebarview.js +12 -8
- package/lib/smartedit.js +16 -11
- package/lib/spreadsheet.js +35 -31
- package/lib/styles.d.ts +81 -0
- package/lib/styles.js +268 -0
- 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.d.ts +382 -0
- package/lib/tools.js +1142 -0
- package/lib/tooltips.js +14 -9
- package/lib/treeview.js +30 -26
- package/lib/x4_events.d.ts +253 -0
- package/lib/x4_events.js +375 -0
- package/package.json +1 -1
- package/src/application.ts +9 -4
- package/src/x4.less +143 -107
- package/tsconfig.json +1 -1
- package/x4.css +1541 -0
package/lib/layout.js
ADDED
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* ___ ___ __
|
|
4
|
+
* \ \/ / / _
|
|
5
|
+
* \ / /_| |_
|
|
6
|
+
* / \____ _|
|
|
7
|
+
* /__/\__\ |_|
|
|
8
|
+
*
|
|
9
|
+
* @file layout.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.ScrollView = exports.TableLayout = exports.GridLayout = exports.AutoLayout = exports.VLayout = exports.HLayout = exports.AbsLayout = void 0;
|
|
28
|
+
const component_1 = require("./component");
|
|
29
|
+
const tools_1 = require("./tools");
|
|
30
|
+
// ============================================================================
|
|
31
|
+
// [ABSLAYOUT]
|
|
32
|
+
// ============================================================================
|
|
33
|
+
class AbsLayout extends component_1.Container {
|
|
34
|
+
}
|
|
35
|
+
exports.AbsLayout = AbsLayout;
|
|
36
|
+
// ============================================================================
|
|
37
|
+
// [HLAYOUT]
|
|
38
|
+
// ============================================================================
|
|
39
|
+
class HLayout extends component_1.Container {
|
|
40
|
+
}
|
|
41
|
+
exports.HLayout = HLayout;
|
|
42
|
+
// ============================================================================
|
|
43
|
+
// [VLAYOUT]
|
|
44
|
+
// ============================================================================
|
|
45
|
+
class VLayout extends component_1.Container {
|
|
46
|
+
}
|
|
47
|
+
exports.VLayout = VLayout;
|
|
48
|
+
class AutoLayout extends component_1.Container {
|
|
49
|
+
constructor(props) {
|
|
50
|
+
super(props);
|
|
51
|
+
this.setDomEvent('sizechange', () => this._updateLayout());
|
|
52
|
+
}
|
|
53
|
+
componentCreated() {
|
|
54
|
+
super.componentCreated();
|
|
55
|
+
this._updateLayout();
|
|
56
|
+
}
|
|
57
|
+
_updateLayout() {
|
|
58
|
+
let horz = this.m_props.defaultLayout == 'horizontal' ? true : false;
|
|
59
|
+
if (this.m_props.switchSize <= 0 && window.screen.height > window.screen.width) {
|
|
60
|
+
horz = !horz;
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
let rc = this.getBoundingRect();
|
|
64
|
+
if ((horz && rc.width < this.m_props.switchSize) || (!horz && rc.height < this.m_props.switchSize)) {
|
|
65
|
+
horz = !horz;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (horz) {
|
|
69
|
+
this.removeClass('@vlayout');
|
|
70
|
+
this.addClass('@hlayout');
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
this.addClass('@vlayout');
|
|
74
|
+
this.removeClass('@hlayout');
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
exports.AutoLayout = AutoLayout;
|
|
79
|
+
class GridLayout extends component_1.Container {
|
|
80
|
+
constructor(props) {
|
|
81
|
+
/// @ts-ignore
|
|
82
|
+
// Argument of type 'GridLayoutProps' is not assignable to parameter of type 'P'.
|
|
83
|
+
// 'GridLayoutProps' is assignable to the constraint of type 'P', but 'P' could be instantiated with a different subtype of constraint 'GridLayoutProps'.
|
|
84
|
+
super(props);
|
|
85
|
+
}
|
|
86
|
+
/** @ignore */
|
|
87
|
+
render() {
|
|
88
|
+
if (this.m_props.colSizes) {
|
|
89
|
+
this.setStyleValue('grid-template-columns', this.m_props.colSizes);
|
|
90
|
+
}
|
|
91
|
+
if (this.m_props.rowSizes) {
|
|
92
|
+
this.setStyleValue('grid-template-rows', this.m_props.rowSizes);
|
|
93
|
+
}
|
|
94
|
+
if (this.m_props.colGap) {
|
|
95
|
+
this.setStyleValue('grid-gap', this.m_props.colGap);
|
|
96
|
+
}
|
|
97
|
+
if (this.m_props.template) {
|
|
98
|
+
this.setStyleValue('grid-template-areas', this.m_props.template.join('\n'));
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
exports.GridLayout = GridLayout;
|
|
103
|
+
class TableLayout extends component_1.Container {
|
|
104
|
+
m_cells;
|
|
105
|
+
constructor(props) {
|
|
106
|
+
super(props);
|
|
107
|
+
this.setProp('tag', 'table');
|
|
108
|
+
this.m_cells = new Map();
|
|
109
|
+
}
|
|
110
|
+
_getCell(row, col, create = true) {
|
|
111
|
+
let idx = _mkid(row, col);
|
|
112
|
+
return this.m_cells.get(idx) ?? (create ? { item: undefined } : null);
|
|
113
|
+
}
|
|
114
|
+
_setCell(row, col, cell, update = false) {
|
|
115
|
+
let idx = _mkid(row, col);
|
|
116
|
+
this.m_cells.set(idx, cell);
|
|
117
|
+
if (this.dom && cell.item && update) {
|
|
118
|
+
if (cell.item instanceof component_1.Component) {
|
|
119
|
+
cell.item.update();
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
this.enumChilds((c) => {
|
|
123
|
+
let crow = c.getData('row');
|
|
124
|
+
if (crow == row) {
|
|
125
|
+
let ccol = c.getData('col');
|
|
126
|
+
if (ccol == col) {
|
|
127
|
+
c.setContent(cell.item);
|
|
128
|
+
c.update();
|
|
129
|
+
return true;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
setCell(row, col, item) {
|
|
137
|
+
let cell = this._getCell(row, col);
|
|
138
|
+
cell.item = item;
|
|
139
|
+
this._setCell(row, col, cell, true);
|
|
140
|
+
}
|
|
141
|
+
merge(row, col, rowCount, colCount) {
|
|
142
|
+
let cell = this._getCell(row, col);
|
|
143
|
+
cell.rowSpan = rowCount;
|
|
144
|
+
cell.colSpan = colCount;
|
|
145
|
+
this._setCell(row, col, cell);
|
|
146
|
+
}
|
|
147
|
+
setCellWidth(row, col, width) {
|
|
148
|
+
let cell = this._getCell(row, col);
|
|
149
|
+
cell.width = width;
|
|
150
|
+
this._setCell(row, col, cell);
|
|
151
|
+
}
|
|
152
|
+
setCellHeight(row, col, height) {
|
|
153
|
+
let cell = this._getCell(row, col);
|
|
154
|
+
cell.height = height;
|
|
155
|
+
this._setCell(row, col, cell);
|
|
156
|
+
}
|
|
157
|
+
setCellClass(row, col, cls) {
|
|
158
|
+
let cell = this._getCell(row, col);
|
|
159
|
+
cell.cls = cls;
|
|
160
|
+
this._setCell(row, col, cell);
|
|
161
|
+
}
|
|
162
|
+
setColClass(col, cls) {
|
|
163
|
+
let cell = this._getCell(-1, col);
|
|
164
|
+
cell.cls = cls;
|
|
165
|
+
this._setCell(-1, col, cell);
|
|
166
|
+
}
|
|
167
|
+
setRowClass(row, cls) {
|
|
168
|
+
let cell = this._getCell(row, 999);
|
|
169
|
+
cell.cls = cls;
|
|
170
|
+
this._setCell(row, 999, cell);
|
|
171
|
+
}
|
|
172
|
+
getCell(row, col) {
|
|
173
|
+
let cell = this._getCell(row, col);
|
|
174
|
+
return cell?.item;
|
|
175
|
+
}
|
|
176
|
+
render() {
|
|
177
|
+
let rows = [];
|
|
178
|
+
let skip = [];
|
|
179
|
+
for (let r = 0; r < this.m_props.rows; r++) {
|
|
180
|
+
let cols = [];
|
|
181
|
+
for (let c = 0; c < this.m_props.columns; c++) {
|
|
182
|
+
let idx = _mkid(r, c);
|
|
183
|
+
if (skip.indexOf(idx) >= 0) {
|
|
184
|
+
continue;
|
|
185
|
+
}
|
|
186
|
+
let cell = this.m_cells.get(idx);
|
|
187
|
+
let cdata = this.m_cells.get(_mkid(-1, c));
|
|
188
|
+
let cls = '';
|
|
189
|
+
if (cell && cell.cls) {
|
|
190
|
+
cls = cell.cls;
|
|
191
|
+
}
|
|
192
|
+
if (cdata && cdata.cls) {
|
|
193
|
+
cls += ' ' + cdata.cls;
|
|
194
|
+
}
|
|
195
|
+
let cc = new component_1.Component({
|
|
196
|
+
tag: 'td',
|
|
197
|
+
content: cell?.item,
|
|
198
|
+
width: cell?.width,
|
|
199
|
+
height: cell?.height,
|
|
200
|
+
data: { row: r, col: c },
|
|
201
|
+
cls
|
|
202
|
+
});
|
|
203
|
+
if (cell) {
|
|
204
|
+
let rs = cell.rowSpan ?? 0, cs = cell.colSpan ?? 0;
|
|
205
|
+
if (rs > 0) {
|
|
206
|
+
cc.setAttribute('rowspan', rs + 1);
|
|
207
|
+
}
|
|
208
|
+
if (cs > 0) {
|
|
209
|
+
cc.setAttribute('colspan', cs + 1);
|
|
210
|
+
}
|
|
211
|
+
if (rs || cs) {
|
|
212
|
+
for (let sr = 0; sr <= rs; sr++) {
|
|
213
|
+
for (let sc = 0; sc <= cs; sc++) {
|
|
214
|
+
skip.push(_mkid(sr + r, sc + c));
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
cols.push(cc);
|
|
220
|
+
}
|
|
221
|
+
let rdata = this._getCell(r, 999, false);
|
|
222
|
+
let rr = new component_1.Component({
|
|
223
|
+
tag: 'tr',
|
|
224
|
+
data: { row: r },
|
|
225
|
+
content: cols,
|
|
226
|
+
cls: rdata?.cls
|
|
227
|
+
});
|
|
228
|
+
rows.push(rr);
|
|
229
|
+
}
|
|
230
|
+
this.setContent(rows);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
exports.TableLayout = TableLayout;
|
|
234
|
+
/**
|
|
235
|
+
* @ignore
|
|
236
|
+
*/
|
|
237
|
+
function _mkid(row, col) {
|
|
238
|
+
return row * 1000 + col;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* @ignore
|
|
242
|
+
*/
|
|
243
|
+
function _getid(key) {
|
|
244
|
+
return {
|
|
245
|
+
row: Math.floor(key / 1000) | 0,
|
|
246
|
+
col: (key % 1000) | 0
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
class ScrollView extends component_1.Component {
|
|
250
|
+
constructor(props) {
|
|
251
|
+
super(props);
|
|
252
|
+
this.setContent(props.content);
|
|
253
|
+
}
|
|
254
|
+
setContent(content) {
|
|
255
|
+
if (!content) {
|
|
256
|
+
super.setContent(null);
|
|
257
|
+
}
|
|
258
|
+
else {
|
|
259
|
+
let container;
|
|
260
|
+
if ((0, tools_1.isArray)(content)) {
|
|
261
|
+
container = new VLayout({ content });
|
|
262
|
+
}
|
|
263
|
+
else {
|
|
264
|
+
container = content;
|
|
265
|
+
}
|
|
266
|
+
container.addClass('@scroll-container');
|
|
267
|
+
super.setContent(container);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
exports.ScrollView = ScrollView;
|
package/lib/link.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* ___ ___ __
|
|
3
4
|
* \ \/ / / _
|
|
@@ -22,19 +23,21 @@
|
|
|
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.Link = void 0;
|
|
28
|
+
const component_1 = require("./component");
|
|
29
|
+
const x4_events_1 = require("./x4_events");
|
|
27
30
|
/**
|
|
28
31
|
* Standard Link
|
|
29
32
|
*/
|
|
30
|
-
|
|
33
|
+
class Link extends component_1.Component {
|
|
31
34
|
constructor(props) {
|
|
32
35
|
super(props);
|
|
33
36
|
this.setDomEvent('click', () => this._handleClick());
|
|
34
37
|
this.mapPropEvents(props, 'click');
|
|
35
38
|
}
|
|
36
39
|
_handleClick() {
|
|
37
|
-
this.emit('click', EvClick());
|
|
40
|
+
this.emit('click', (0, x4_events_1.EvClick)());
|
|
38
41
|
}
|
|
39
42
|
/** @ignore */
|
|
40
43
|
render(props) {
|
|
@@ -45,7 +48,7 @@ export class Link extends Component {
|
|
|
45
48
|
this.setAttribute('href', href);
|
|
46
49
|
this.setAttribute('target', props.target);
|
|
47
50
|
if (text) {
|
|
48
|
-
this.setContent(isHtmlString(text) ? text : html `<span>${text}</span>`);
|
|
51
|
+
this.setContent((0, component_1.isHtmlString)(text) ? text : (0, component_1.html) `<span>${text}</span>`);
|
|
49
52
|
}
|
|
50
53
|
}
|
|
51
54
|
set text(text) {
|
|
@@ -53,3 +56,4 @@ export class Link extends Component {
|
|
|
53
56
|
this.update();
|
|
54
57
|
}
|
|
55
58
|
}
|
|
59
|
+
exports.Link = Link;
|
package/lib/listview.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* ___ ___ __
|
|
3
4
|
* \ \_/ / / _
|
|
@@ -22,27 +23,30 @@
|
|
|
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.PopupListView = exports.EvCancel = exports.ListView = exports.ListViewItem = void 0;
|
|
28
|
+
const component_1 = require("./component");
|
|
29
|
+
const layout_1 = require("./layout");
|
|
30
|
+
const popup_1 = require("./popup");
|
|
31
|
+
const tools_1 = require("./tools");
|
|
32
|
+
const menu_1 = require("./menu");
|
|
33
|
+
const x4_events_1 = require("./x4_events");
|
|
31
34
|
/**
|
|
32
35
|
* item definition
|
|
33
36
|
*/
|
|
34
|
-
|
|
37
|
+
class ListViewItem {
|
|
35
38
|
id;
|
|
36
39
|
text; // if you need pure text
|
|
37
40
|
html; // if text is html
|
|
38
41
|
icon;
|
|
39
42
|
data;
|
|
40
43
|
}
|
|
44
|
+
exports.ListViewItem = ListViewItem;
|
|
41
45
|
;
|
|
42
46
|
/**
|
|
43
47
|
* Standard listview class
|
|
44
48
|
*/
|
|
45
|
-
|
|
49
|
+
class ListView extends layout_1.VLayout {
|
|
46
50
|
m_selection;
|
|
47
51
|
m_defer_sel;
|
|
48
52
|
m_container;
|
|
@@ -115,7 +119,7 @@ export class ListView extends VLayout {
|
|
|
115
119
|
_handleKey(ev) {
|
|
116
120
|
let moveSel = (sens) => {
|
|
117
121
|
let items;
|
|
118
|
-
if (isFunction(this.m_props.items)) {
|
|
122
|
+
if ((0, tools_1.isFunction)(this.m_props.items)) {
|
|
119
123
|
items = this.m_props.items();
|
|
120
124
|
this.m_props.items = items;
|
|
121
125
|
}
|
|
@@ -160,11 +164,11 @@ export class ListView extends VLayout {
|
|
|
160
164
|
_buildContent() {
|
|
161
165
|
let props = this.m_props;
|
|
162
166
|
if (props.virtual) {
|
|
163
|
-
this.m_container = new Container({
|
|
167
|
+
this.m_container = new component_1.Container({
|
|
164
168
|
cls: '@scroll-container',
|
|
165
169
|
content: []
|
|
166
170
|
});
|
|
167
|
-
this.m_view = new Container({
|
|
171
|
+
this.m_view = new component_1.Container({
|
|
168
172
|
cls: '@scroll-view',
|
|
169
173
|
flex: 1,
|
|
170
174
|
content: this.m_container,
|
|
@@ -175,7 +179,7 @@ export class ListView extends VLayout {
|
|
|
175
179
|
});
|
|
176
180
|
this.setContent([
|
|
177
181
|
this.m_view,
|
|
178
|
-
props.gadgets ? new HLayout({
|
|
182
|
+
props.gadgets ? new layout_1.HLayout({
|
|
179
183
|
cls: 'gadgets',
|
|
180
184
|
content: props.gadgets
|
|
181
185
|
}) : null,
|
|
@@ -183,7 +187,7 @@ export class ListView extends VLayout {
|
|
|
183
187
|
}
|
|
184
188
|
else {
|
|
185
189
|
this.m_view = undefined;
|
|
186
|
-
this.m_container = new VLayout({
|
|
190
|
+
this.m_container = new layout_1.VLayout({
|
|
187
191
|
cls: '@scroll-container',
|
|
188
192
|
content: []
|
|
189
193
|
});
|
|
@@ -219,7 +223,7 @@ export class ListView extends VLayout {
|
|
|
219
223
|
let props = this.m_props;
|
|
220
224
|
let items = [];
|
|
221
225
|
let list_items = props.items;
|
|
222
|
-
if (isFunction(list_items)) {
|
|
226
|
+
if ((0, tools_1.isFunction)(list_items)) {
|
|
223
227
|
list_items = list_items();
|
|
224
228
|
}
|
|
225
229
|
let selId = this.m_selection?.item.id;
|
|
@@ -305,7 +309,7 @@ export class ListView extends VLayout {
|
|
|
305
309
|
return this.m_props.renderItem(item);
|
|
306
310
|
}
|
|
307
311
|
else {
|
|
308
|
-
return new HLayout({ content: item.text });
|
|
312
|
+
return new layout_1.HLayout({ content: item.text });
|
|
309
313
|
}
|
|
310
314
|
}
|
|
311
315
|
/** @ignore */
|
|
@@ -313,18 +317,18 @@ export class ListView extends VLayout {
|
|
|
313
317
|
let dom = e.target, self = this.dom, list_items = this.m_props.items; // already created by build
|
|
314
318
|
// go up until we find something interesting
|
|
315
319
|
while (dom && dom != self) {
|
|
316
|
-
let itm = Component.getElement(dom), id = itm?.getData('item-id');
|
|
320
|
+
let itm = component_1.Component.getElement(dom), id = itm?.getData('item-id');
|
|
317
321
|
if (id !== undefined) {
|
|
318
322
|
// find the element
|
|
319
323
|
let item = list_items.find((item) => item.id == id);
|
|
320
324
|
if (item) {
|
|
321
325
|
let event;
|
|
322
326
|
if (e.type == 'click') {
|
|
323
|
-
event = EvClick(item);
|
|
327
|
+
event = (0, x4_events_1.EvClick)(item);
|
|
324
328
|
this.emit('click', event);
|
|
325
329
|
}
|
|
326
330
|
else {
|
|
327
|
-
event = EvDblClick(item);
|
|
331
|
+
event = (0, component_1.EvDblClick)(item);
|
|
328
332
|
this.emit('dblClick', event);
|
|
329
333
|
}
|
|
330
334
|
if (!event.defaultPrevented) {
|
|
@@ -345,19 +349,19 @@ export class ListView extends VLayout {
|
|
|
345
349
|
e.preventDefault();
|
|
346
350
|
let dom = e.target, self = this.dom, list_items = this.m_props.items; // already created by build;
|
|
347
351
|
while (dom && dom != self) {
|
|
348
|
-
let itm = Component.getElement(dom), id = itm?.getData('item-id');
|
|
352
|
+
let itm = component_1.Component.getElement(dom), id = itm?.getData('item-id');
|
|
349
353
|
if (id) {
|
|
350
354
|
// find the element
|
|
351
355
|
let item = list_items.find((item) => item.id == id);
|
|
352
356
|
if (item) {
|
|
353
357
|
this._selectItem(item, itm);
|
|
354
|
-
this.emit('contextMenu', EvContextMenu(e, item));
|
|
358
|
+
this.emit('contextMenu', (0, x4_events_1.EvContextMenu)(e, item));
|
|
355
359
|
}
|
|
356
360
|
return;
|
|
357
361
|
}
|
|
358
362
|
dom = dom.parentElement;
|
|
359
363
|
}
|
|
360
|
-
this.emit('contextMenu', EvContextMenu(e, null));
|
|
364
|
+
this.emit('contextMenu', (0, x4_events_1.EvContextMenu)(e, null));
|
|
361
365
|
}
|
|
362
366
|
/**
|
|
363
367
|
* @ignore
|
|
@@ -375,7 +379,7 @@ export class ListView extends VLayout {
|
|
|
375
379
|
this.m_selection.citem.addClass('@selected');
|
|
376
380
|
}
|
|
377
381
|
if (notify) {
|
|
378
|
-
this.emit('selectionChange', EvSelectionChange(item));
|
|
382
|
+
this.emit('selectionChange', (0, x4_events_1.EvSelectionChange)(item));
|
|
379
383
|
}
|
|
380
384
|
}
|
|
381
385
|
/**
|
|
@@ -389,7 +393,7 @@ export class ListView extends VLayout {
|
|
|
389
393
|
this._selectItem(null, null);
|
|
390
394
|
}
|
|
391
395
|
else {
|
|
392
|
-
if (isFunction(this.m_props.items)) {
|
|
396
|
+
if ((0, tools_1.isFunction)(this.m_props.items)) {
|
|
393
397
|
this.m_defer_sel = id;
|
|
394
398
|
}
|
|
395
399
|
else {
|
|
@@ -470,13 +474,15 @@ export class ListView extends VLayout {
|
|
|
470
474
|
}
|
|
471
475
|
}
|
|
472
476
|
}
|
|
473
|
-
|
|
474
|
-
|
|
477
|
+
exports.ListView = ListView;
|
|
478
|
+
function EvCancel(context = null) {
|
|
479
|
+
return (0, x4_events_1.BasicEvent)({ context });
|
|
475
480
|
}
|
|
481
|
+
exports.EvCancel = EvCancel;
|
|
476
482
|
/**
|
|
477
483
|
*
|
|
478
484
|
*/
|
|
479
|
-
|
|
485
|
+
class PopupListView extends popup_1.Popup {
|
|
480
486
|
m_list;
|
|
481
487
|
constructor(props) {
|
|
482
488
|
super({ tabIndex: false });
|
|
@@ -502,7 +508,7 @@ export class PopupListView extends Popup {
|
|
|
502
508
|
return;
|
|
503
509
|
}
|
|
504
510
|
// menu: ok
|
|
505
|
-
let dest = Component.getElement(newfocus, MenuItem);
|
|
511
|
+
let dest = component_1.Component.getElement(newfocus, menu_1.MenuItem);
|
|
506
512
|
if (dest) {
|
|
507
513
|
return;
|
|
508
514
|
}
|
|
@@ -530,3 +536,4 @@ export class PopupListView extends Popup {
|
|
|
530
536
|
this.m_list.selection = itemId;
|
|
531
537
|
}
|
|
532
538
|
}
|
|
539
|
+
exports.PopupListView = PopupListView;
|
package/lib/md5.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.Md5 = void 0;
|
|
25
28
|
/*
|
|
26
29
|
TypeScript Md5
|
|
27
30
|
==============
|
|
@@ -48,7 +51,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
48
51
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
49
52
|
THE SOFTWARE.
|
|
50
53
|
*/
|
|
51
|
-
|
|
54
|
+
class Md5 {
|
|
52
55
|
static hashStr(str, raw = false) {
|
|
53
56
|
return this.onePassHasher
|
|
54
57
|
.start()
|
|
@@ -390,6 +393,7 @@ export class Md5 {
|
|
|
390
393
|
return raw ? this._state : Md5._hex(this._state);
|
|
391
394
|
}
|
|
392
395
|
}
|
|
396
|
+
exports.Md5 = Md5;
|
|
393
397
|
/*
|
|
394
398
|
if (Md5.hashStr('hello') !== '5d41402abc4b2a76b9719d911017c592') {
|
|
395
399
|
console.error('Md5 self test failed.');
|
package/lib/menu.d.ts
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ___ ___ __
|
|
3
|
+
* \ \_/ / / _
|
|
4
|
+
* \ / /_| |_
|
|
5
|
+
* / _ \____ _|
|
|
6
|
+
* /__/ \__\ |_|
|
|
7
|
+
*
|
|
8
|
+
* @file menu.ts
|
|
9
|
+
* @author Etienne Cochard
|
|
10
|
+
* @license
|
|
11
|
+
* Copyright (c) 2019-2021 R-libre ingenierie
|
|
12
|
+
*
|
|
13
|
+
* This program is free software; you can redistribute it and/or modify
|
|
14
|
+
* it under the terms of the GNU General Public License as published by
|
|
15
|
+
* the Free Software Foundation; either version 3 of the License, or
|
|
16
|
+
* (at your option) any later version.
|
|
17
|
+
*
|
|
18
|
+
* This program is distributed in the hope that it will be useful,
|
|
19
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
20
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
21
|
+
* GNU General Public License for more details.
|
|
22
|
+
*
|
|
23
|
+
* 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
|
+
import { CEventMap, Component, CProps } from './component';
|
|
26
|
+
import { EvClick, EventCallback } from './x4_events';
|
|
27
|
+
import { Popup, PopupProps } from './popup';
|
|
28
|
+
import { IconID } from './icon';
|
|
29
|
+
import { Label } from './label';
|
|
30
|
+
import { HLayout } from './layout';
|
|
31
|
+
export declare class MenuSeparator extends Component {
|
|
32
|
+
}
|
|
33
|
+
export declare class MenuTitle extends Label {
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Standard Menu
|
|
37
|
+
*/
|
|
38
|
+
export declare type MenuOrSep = MenuItem | MenuSeparator | MenuTitle;
|
|
39
|
+
export interface MenuProps extends PopupProps {
|
|
40
|
+
items?: MenuOrSep[];
|
|
41
|
+
}
|
|
42
|
+
export declare class Menu extends Popup<MenuProps> {
|
|
43
|
+
private static watchCount;
|
|
44
|
+
private static rootMenu;
|
|
45
|
+
protected m_subMenu: Menu;
|
|
46
|
+
protected m_opener: MenuItem;
|
|
47
|
+
protected m_virtual: boolean;
|
|
48
|
+
protected m_lock: number;
|
|
49
|
+
constructor(props: MenuProps, opener?: MenuItem);
|
|
50
|
+
lock(yes: boolean): void;
|
|
51
|
+
setVirtual(): void;
|
|
52
|
+
setSubMenu(menu: Menu): void;
|
|
53
|
+
hideSubMenu(): void;
|
|
54
|
+
/** @ignore */
|
|
55
|
+
render(props: MenuProps): void;
|
|
56
|
+
/**
|
|
57
|
+
*
|
|
58
|
+
*/
|
|
59
|
+
show(): void;
|
|
60
|
+
/**
|
|
61
|
+
*
|
|
62
|
+
*/
|
|
63
|
+
close(): void;
|
|
64
|
+
/**
|
|
65
|
+
*
|
|
66
|
+
*/
|
|
67
|
+
clear(): void;
|
|
68
|
+
/**
|
|
69
|
+
* @internal
|
|
70
|
+
*/
|
|
71
|
+
static _addMenu(menu: any): void;
|
|
72
|
+
static _removeMenu(): void;
|
|
73
|
+
private static _mouseWatcher;
|
|
74
|
+
/**
|
|
75
|
+
* hide all the visible menus
|
|
76
|
+
*/
|
|
77
|
+
static _discardAll(): void;
|
|
78
|
+
displayAt(ev: UIEvent): void;
|
|
79
|
+
displayAt(x: number, y?: number, align?: string, offset?: {
|
|
80
|
+
x: any;
|
|
81
|
+
y: any;
|
|
82
|
+
}): void;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* MENU ITEM
|
|
86
|
+
*/
|
|
87
|
+
interface MenuItemEventMap extends CEventMap {
|
|
88
|
+
click: EvClick;
|
|
89
|
+
}
|
|
90
|
+
export interface MenuItemProps extends CProps {
|
|
91
|
+
itemId?: any;
|
|
92
|
+
text?: string;
|
|
93
|
+
icon?: IconID;
|
|
94
|
+
items?: MenuOrSep[];
|
|
95
|
+
checked?: boolean;
|
|
96
|
+
cls?: string;
|
|
97
|
+
click?: EventCallback<EvClick>;
|
|
98
|
+
}
|
|
99
|
+
export declare class MenuItem extends Component<MenuItemProps, MenuItemEventMap> {
|
|
100
|
+
private m_menu;
|
|
101
|
+
private m_isOpen;
|
|
102
|
+
constructor(text: string, click: EventCallback<EvClick>);
|
|
103
|
+
constructor(props: MenuItemProps);
|
|
104
|
+
/** @ignore */
|
|
105
|
+
render(props: MenuItemProps): void;
|
|
106
|
+
get id(): any;
|
|
107
|
+
get text(): string;
|
|
108
|
+
get isPopup(): boolean;
|
|
109
|
+
_close(): void;
|
|
110
|
+
protected _click(ev: MouseEvent): void;
|
|
111
|
+
protected _mousedown(ev: MouseEvent): void;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
*
|
|
115
|
+
*/
|
|
116
|
+
export declare class MenuBar extends HLayout {
|
|
117
|
+
protected m_items: MenuOrSep[];
|
|
118
|
+
constructor(props: MenuProps, opener?: MenuItem);
|
|
119
|
+
/** @ignore */
|
|
120
|
+
render(): void;
|
|
121
|
+
}
|
|
122
|
+
export {};
|