x4js 1.4.2
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 +95 -0
- package/lib/application.js +137 -0
- package/lib/base64.d.ts +31 -0
- package/lib/base64.js +135 -0
- package/lib/base_component.d.ts +64 -0
- package/lib/base_component.js +77 -0
- package/lib/button.d.ts +145 -0
- package/lib/button.js +235 -0
- package/lib/calendar.d.ts +77 -0
- package/lib/calendar.js +236 -0
- package/lib/canvas.d.ts +88 -0
- package/lib/canvas.js +354 -0
- package/lib/cardview.d.ts +83 -0
- package/lib/cardview.js +152 -0
- package/lib/checkbox.d.ts +72 -0
- package/lib/checkbox.js +126 -0
- package/lib/color.d.ts +144 -0
- package/lib/color.js +584 -0
- package/lib/colorpicker.d.ts +98 -0
- package/lib/colorpicker.js +1457 -0
- package/lib/combobox.d.ts +97 -0
- package/lib/combobox.js +246 -0
- package/lib/component.d.ts +572 -0
- package/lib/component.js +1712 -0
- package/lib/datastore.d.ts +392 -0
- package/lib/datastore.js +986 -0
- package/lib/dialog.d.ts +171 -0
- package/lib/dialog.js +468 -0
- package/lib/dom_events.d.ts +284 -0
- package/lib/dom_events.js +13 -0
- package/lib/drag_manager.d.ts +26 -0
- package/lib/drag_manager.js +118 -0
- package/lib/drawtext.d.ts +43 -0
- package/lib/drawtext.js +261 -0
- package/lib/fileupload.d.ts +60 -0
- package/lib/fileupload.js +158 -0
- package/lib/form.d.ts +122 -0
- package/lib/form.js +293 -0
- package/lib/formatters.d.ts +31 -0
- package/lib/formatters.js +75 -0
- package/lib/gridview.d.ts +171 -0
- package/lib/gridview.js +786 -0
- package/lib/hosts/host.d.ts +44 -0
- package/lib/hosts/host.js +69 -0
- package/lib/i18n.d.ts +67 -0
- package/lib/i18n.js +169 -0
- package/lib/icon.d.ts +56 -0
- package/lib/icon.js +173 -0
- package/lib/image.d.ts +51 -0
- package/lib/image.js +149 -0
- package/lib/index.js +1 -0
- package/lib/input.d.ts +86 -0
- package/lib/input.js +172 -0
- package/lib/label.d.ts +54 -0
- package/lib/label.js +86 -0
- package/lib/layout.d.ts +77 -0
- package/lib/layout.js +261 -0
- package/lib/link.d.ts +46 -0
- package/lib/link.js +55 -0
- package/lib/listview.d.ts +173 -0
- package/lib/listview.js +532 -0
- package/lib/md5.d.ts +56 -0
- package/lib/md5.js +397 -0
- package/lib/menu.d.ts +122 -0
- package/lib/menu.js +276 -0
- package/lib/messagebox.d.ts +64 -0
- package/lib/messagebox.js +141 -0
- package/lib/panel.d.ts +42 -0
- package/lib/panel.js +61 -0
- package/lib/popup.d.ts +71 -0
- package/lib/popup.js +373 -0
- package/lib/property_editor.d.ts +67 -0
- package/lib/property_editor.js +247 -0
- package/lib/radiobtn.d.ts +68 -0
- package/lib/radiobtn.js +131 -0
- package/lib/rating.d.ts +49 -0
- package/lib/rating.js +93 -0
- package/lib/request.d.ts +48 -0
- package/lib/request.js +220 -0
- package/lib/router.d.ts +13 -0
- package/lib/router.js +27 -0
- package/lib/settings.d.ts +33 -0
- package/lib/settings.js +63 -0
- package/lib/sidebarview.d.ts +44 -0
- package/lib/sidebarview.js +73 -0
- package/lib/smartedit.d.ts +103 -0
- package/lib/smartedit.js +381 -0
- package/lib/spreadsheet.d.ts +214 -0
- package/lib/spreadsheet.js +1073 -0
- package/lib/styles.d.ts +81 -0
- package/lib/styles.js +262 -0
- package/lib/svgcomponent.d.ts +165 -0
- package/lib/svgcomponent.js +350 -0
- package/lib/tabbar.d.ts +41 -0
- package/lib/tabbar.js +66 -0
- package/lib/tabview.d.ts +45 -0
- package/lib/tabview.js +79 -0
- package/lib/textarea.d.ts +59 -0
- package/lib/textarea.js +119 -0
- package/lib/textedit.d.ts +118 -0
- package/lib/textedit.js +406 -0
- package/lib/texthiliter.d.ts +56 -0
- package/lib/texthiliter.js +219 -0
- package/lib/toaster.d.ts +38 -0
- package/lib/toaster.js +58 -0
- package/lib/tools.d.ts +382 -0
- package/lib/tools.js +1096 -0
- package/lib/tooltips.d.ts +42 -0
- package/lib/tooltips.js +148 -0
- package/lib/treeview.d.ts +128 -0
- package/lib/treeview.js +490 -0
- package/lib/x4_events.d.ts +253 -0
- package/lib/x4_events.js +363 -0
- package/package.json +21 -0
- package/src/README.md +2 -0
- package/src/application.ts +191 -0
- package/src/base64.ts +162 -0
- package/src/base_component.ts +118 -0
- package/src/button.ts +327 -0
- package/src/calendar.ts +312 -0
- package/src/canvas.ts +501 -0
- package/src/cardview.ts +220 -0
- package/src/checkbox.ts +178 -0
- package/src/color.ts +748 -0
- package/src/colorpicker.ts +1618 -0
- package/src/combobox.ts +348 -0
- package/src/component.ts +2330 -0
- package/src/datastore.ts +1318 -0
- package/src/dialog.ts +631 -0
- package/src/dom_events.ts +297 -0
- package/src/drag_manager.ts +168 -0
- package/src/drawtext.ts +342 -0
- package/src/fileupload.ts +208 -0
- package/src/form.ts +362 -0
- package/src/formatters.ts +96 -0
- package/src/gridview.ts +1051 -0
- package/src/hosts/electron.ts +161 -0
- package/src/hosts/host.ts +100 -0
- package/src/hosts/nwjs.ts +141 -0
- package/src/hosts/nwjs_types.ts +339 -0
- package/src/i18n.ts +205 -0
- package/src/icon.ts +237 -0
- package/src/image.ts +198 -0
- package/src/input.ts +236 -0
- package/src/label.ts +124 -0
- package/src/layout.ts +366 -0
- package/src/link.ts +82 -0
- package/src/listview.ts +749 -0
- package/src/md5.ts +432 -0
- package/src/menu.ts +394 -0
- package/src/messagebox.ts +199 -0
- package/src/panel.ts +81 -0
- package/src/popup.ts +488 -0
- package/src/property_editor.ts +333 -0
- package/src/radiobtn.ts +190 -0
- package/src/rating.ts +131 -0
- package/src/request.ts +296 -0
- package/src/router.ts +43 -0
- package/src/settings.ts +75 -0
- package/src/sidebarview.ts +97 -0
- package/src/smartedit.ts +532 -0
- package/src/spreadsheet.ts +1423 -0
- package/src/styles.ts +332 -0
- package/src/svgcomponent.ts +440 -0
- package/src/tabbar.ts +105 -0
- package/src/tabview.ts +106 -0
- package/src/textarea.ts +183 -0
- package/src/textedit.ts +535 -0
- package/src/texthiliter.ts +284 -0
- package/src/toaster.ts +76 -0
- package/src/tools.ts +1391 -0
- package/src/tooltips.ts +185 -0
- package/src/treeview.ts +670 -0
- package/src/x4.less +1940 -0
- package/src/x4_events.ts +558 -0
- package/tsconfig.json +14 -0
package/lib/layout.js
ADDED
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ___ ___ __
|
|
3
|
+
* \ \/ / / _
|
|
4
|
+
* \ / /_| |_
|
|
5
|
+
* / \____ _|
|
|
6
|
+
* /__/\__\ |_|
|
|
7
|
+
*
|
|
8
|
+
* @file layout.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 { Component, Container } from './component';
|
|
26
|
+
import { isArray } from './tools';
|
|
27
|
+
// ============================================================================
|
|
28
|
+
// [ABSLAYOUT]
|
|
29
|
+
// ============================================================================
|
|
30
|
+
export class AbsLayout extends Container {
|
|
31
|
+
}
|
|
32
|
+
// ============================================================================
|
|
33
|
+
// [HLAYOUT]
|
|
34
|
+
// ============================================================================
|
|
35
|
+
export class HLayout extends Container {
|
|
36
|
+
}
|
|
37
|
+
// ============================================================================
|
|
38
|
+
// [VLAYOUT]
|
|
39
|
+
// ============================================================================
|
|
40
|
+
export class VLayout extends Container {
|
|
41
|
+
}
|
|
42
|
+
export class AutoLayout extends Container {
|
|
43
|
+
constructor(props) {
|
|
44
|
+
super(props);
|
|
45
|
+
this.setDomEvent('sizechange', () => this._updateLayout());
|
|
46
|
+
}
|
|
47
|
+
componentCreated() {
|
|
48
|
+
super.componentCreated();
|
|
49
|
+
this._updateLayout();
|
|
50
|
+
}
|
|
51
|
+
_updateLayout() {
|
|
52
|
+
let horz = this.m_props.defaultLayout == 'horizontal' ? true : false;
|
|
53
|
+
if (this.m_props.switchSize <= 0 && window.screen.height > window.screen.width) {
|
|
54
|
+
horz = !horz;
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
let rc = this.getBoundingRect();
|
|
58
|
+
if ((horz && rc.width < this.m_props.switchSize) || (!horz && rc.height < this.m_props.switchSize)) {
|
|
59
|
+
horz = !horz;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
if (horz) {
|
|
63
|
+
this.removeClass('@vlayout');
|
|
64
|
+
this.addClass('@hlayout');
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
this.addClass('@vlayout');
|
|
68
|
+
this.removeClass('@hlayout');
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
export class GridLayout extends Container {
|
|
73
|
+
constructor(props) {
|
|
74
|
+
/// @ts-ignore
|
|
75
|
+
// Argument of type 'GridLayoutProps' is not assignable to parameter of type 'P'.
|
|
76
|
+
// 'GridLayoutProps' is assignable to the constraint of type 'P', but 'P' could be instantiated with a different subtype of constraint 'GridLayoutProps'.
|
|
77
|
+
super(props);
|
|
78
|
+
}
|
|
79
|
+
/** @ignore */
|
|
80
|
+
render() {
|
|
81
|
+
if (this.m_props.colSizes) {
|
|
82
|
+
this.setStyleValue('grid-template-columns', this.m_props.colSizes);
|
|
83
|
+
}
|
|
84
|
+
if (this.m_props.rowSizes) {
|
|
85
|
+
this.setStyleValue('grid-template-rows', this.m_props.rowSizes);
|
|
86
|
+
}
|
|
87
|
+
if (this.m_props.colGap) {
|
|
88
|
+
this.setStyleValue('grid-gap', this.m_props.colGap);
|
|
89
|
+
}
|
|
90
|
+
if (this.m_props.template) {
|
|
91
|
+
this.setStyleValue('grid-template-areas', this.m_props.template.join('\n'));
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
export class TableLayout extends Container {
|
|
96
|
+
m_cells;
|
|
97
|
+
constructor(props) {
|
|
98
|
+
super(props);
|
|
99
|
+
this.setProp('tag', 'table');
|
|
100
|
+
this.m_cells = new Map();
|
|
101
|
+
}
|
|
102
|
+
_getCell(row, col, create = true) {
|
|
103
|
+
let idx = _mkid(row, col);
|
|
104
|
+
return this.m_cells.get(idx) ?? (create ? { item: undefined } : null);
|
|
105
|
+
}
|
|
106
|
+
_setCell(row, col, cell, update = false) {
|
|
107
|
+
let idx = _mkid(row, col);
|
|
108
|
+
this.m_cells.set(idx, cell);
|
|
109
|
+
if (this.dom && cell.item && update) {
|
|
110
|
+
if (cell.item instanceof Component) {
|
|
111
|
+
cell.item.update();
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
this.enumChilds((c) => {
|
|
115
|
+
let crow = c.getData('row');
|
|
116
|
+
if (crow == row) {
|
|
117
|
+
let ccol = c.getData('col');
|
|
118
|
+
if (ccol == col) {
|
|
119
|
+
c.setContent(cell.item);
|
|
120
|
+
c.update();
|
|
121
|
+
return true;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
setCell(row, col, item) {
|
|
129
|
+
let cell = this._getCell(row, col);
|
|
130
|
+
cell.item = item;
|
|
131
|
+
this._setCell(row, col, cell, true);
|
|
132
|
+
}
|
|
133
|
+
merge(row, col, rowCount, colCount) {
|
|
134
|
+
let cell = this._getCell(row, col);
|
|
135
|
+
cell.rowSpan = rowCount;
|
|
136
|
+
cell.colSpan = colCount;
|
|
137
|
+
this._setCell(row, col, cell);
|
|
138
|
+
}
|
|
139
|
+
setCellWidth(row, col, width) {
|
|
140
|
+
let cell = this._getCell(row, col);
|
|
141
|
+
cell.width = width;
|
|
142
|
+
this._setCell(row, col, cell);
|
|
143
|
+
}
|
|
144
|
+
setCellHeight(row, col, height) {
|
|
145
|
+
let cell = this._getCell(row, col);
|
|
146
|
+
cell.height = height;
|
|
147
|
+
this._setCell(row, col, cell);
|
|
148
|
+
}
|
|
149
|
+
setCellClass(row, col, cls) {
|
|
150
|
+
let cell = this._getCell(row, col);
|
|
151
|
+
cell.cls = cls;
|
|
152
|
+
this._setCell(row, col, cell);
|
|
153
|
+
}
|
|
154
|
+
setColClass(col, cls) {
|
|
155
|
+
let cell = this._getCell(-1, col);
|
|
156
|
+
cell.cls = cls;
|
|
157
|
+
this._setCell(-1, col, cell);
|
|
158
|
+
}
|
|
159
|
+
setRowClass(row, cls) {
|
|
160
|
+
let cell = this._getCell(row, 999);
|
|
161
|
+
cell.cls = cls;
|
|
162
|
+
this._setCell(row, 999, cell);
|
|
163
|
+
}
|
|
164
|
+
getCell(row, col) {
|
|
165
|
+
let cell = this._getCell(row, col);
|
|
166
|
+
return cell?.item;
|
|
167
|
+
}
|
|
168
|
+
render() {
|
|
169
|
+
let rows = [];
|
|
170
|
+
let skip = [];
|
|
171
|
+
for (let r = 0; r < this.m_props.rows; r++) {
|
|
172
|
+
let cols = [];
|
|
173
|
+
for (let c = 0; c < this.m_props.columns; c++) {
|
|
174
|
+
let idx = _mkid(r, c);
|
|
175
|
+
if (skip.indexOf(idx) >= 0) {
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
let cell = this.m_cells.get(idx);
|
|
179
|
+
let cdata = this.m_cells.get(_mkid(-1, c));
|
|
180
|
+
let cls = '';
|
|
181
|
+
if (cell && cell.cls) {
|
|
182
|
+
cls = cell.cls;
|
|
183
|
+
}
|
|
184
|
+
if (cdata && cdata.cls) {
|
|
185
|
+
cls += ' ' + cdata.cls;
|
|
186
|
+
}
|
|
187
|
+
let cc = new Component({
|
|
188
|
+
tag: 'td',
|
|
189
|
+
content: cell?.item,
|
|
190
|
+
width: cell?.width,
|
|
191
|
+
height: cell?.height,
|
|
192
|
+
data: { row: r, col: c },
|
|
193
|
+
cls
|
|
194
|
+
});
|
|
195
|
+
if (cell) {
|
|
196
|
+
let rs = cell.rowSpan ?? 0, cs = cell.colSpan ?? 0;
|
|
197
|
+
if (rs > 0) {
|
|
198
|
+
cc.setAttribute('rowspan', rs + 1);
|
|
199
|
+
}
|
|
200
|
+
if (cs > 0) {
|
|
201
|
+
cc.setAttribute('colspan', cs + 1);
|
|
202
|
+
}
|
|
203
|
+
if (rs || cs) {
|
|
204
|
+
for (let sr = 0; sr <= rs; sr++) {
|
|
205
|
+
for (let sc = 0; sc <= cs; sc++) {
|
|
206
|
+
skip.push(_mkid(sr + r, sc + c));
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
cols.push(cc);
|
|
212
|
+
}
|
|
213
|
+
let rdata = this._getCell(r, 999, false);
|
|
214
|
+
let rr = new Component({
|
|
215
|
+
tag: 'tr',
|
|
216
|
+
data: { row: r },
|
|
217
|
+
content: cols,
|
|
218
|
+
cls: rdata?.cls
|
|
219
|
+
});
|
|
220
|
+
rows.push(rr);
|
|
221
|
+
}
|
|
222
|
+
this.setContent(rows);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* @ignore
|
|
227
|
+
*/
|
|
228
|
+
function _mkid(row, col) {
|
|
229
|
+
return row * 1000 + col;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* @ignore
|
|
233
|
+
*/
|
|
234
|
+
function _getid(key) {
|
|
235
|
+
return {
|
|
236
|
+
row: Math.floor(key / 1000) | 0,
|
|
237
|
+
col: (key % 1000) | 0
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
export class ScrollView extends Component {
|
|
241
|
+
constructor(props) {
|
|
242
|
+
super(props);
|
|
243
|
+
this.setContent(props.content);
|
|
244
|
+
}
|
|
245
|
+
setContent(content) {
|
|
246
|
+
if (!content) {
|
|
247
|
+
super.setContent(null);
|
|
248
|
+
}
|
|
249
|
+
else {
|
|
250
|
+
let container;
|
|
251
|
+
if (isArray(content)) {
|
|
252
|
+
container = new VLayout({ content });
|
|
253
|
+
}
|
|
254
|
+
else {
|
|
255
|
+
container = content;
|
|
256
|
+
}
|
|
257
|
+
container.addClass('@scroll-container');
|
|
258
|
+
super.setContent(container);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
package/lib/link.d.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ___ ___ __
|
|
3
|
+
* \ \/ / / _
|
|
4
|
+
* \ / /_| |_
|
|
5
|
+
* / \____ _|
|
|
6
|
+
* /__/\__\ |_|
|
|
7
|
+
*
|
|
8
|
+
* @file link.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 { Component, CProps, CEventMap, HtmlString } from './component';
|
|
26
|
+
import { EvClick, EventCallback } from './x4_events';
|
|
27
|
+
interface LinkEventMap extends CEventMap {
|
|
28
|
+
click: EvClick;
|
|
29
|
+
}
|
|
30
|
+
export interface LinkProps extends CProps<LinkEventMap> {
|
|
31
|
+
text?: string | HtmlString;
|
|
32
|
+
href?: string;
|
|
33
|
+
target?: string;
|
|
34
|
+
click?: EventCallback<EvClick>;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Standard Link
|
|
38
|
+
*/
|
|
39
|
+
export declare class Link extends Component<LinkProps, LinkEventMap> {
|
|
40
|
+
constructor(props?: LinkProps);
|
|
41
|
+
private _handleClick;
|
|
42
|
+
/** @ignore */
|
|
43
|
+
render(props: LinkProps): void;
|
|
44
|
+
set text(text: string | HtmlString);
|
|
45
|
+
}
|
|
46
|
+
export {};
|
package/lib/link.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ___ ___ __
|
|
3
|
+
* \ \/ / / _
|
|
4
|
+
* \ / /_| |_
|
|
5
|
+
* / \____ _|
|
|
6
|
+
* /__/\__\ |_|
|
|
7
|
+
*
|
|
8
|
+
* @file link.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 { Component, isHtmlString, html } from './component';
|
|
26
|
+
import { EvClick } from './x4_events';
|
|
27
|
+
/**
|
|
28
|
+
* Standard Link
|
|
29
|
+
*/
|
|
30
|
+
export class Link extends Component {
|
|
31
|
+
constructor(props) {
|
|
32
|
+
super(props);
|
|
33
|
+
this.setDomEvent('click', () => this._handleClick());
|
|
34
|
+
this.mapPropEvents(props, 'click');
|
|
35
|
+
}
|
|
36
|
+
_handleClick() {
|
|
37
|
+
this.emit('click', EvClick());
|
|
38
|
+
}
|
|
39
|
+
/** @ignore */
|
|
40
|
+
render(props) {
|
|
41
|
+
let text = props.text ?? '';
|
|
42
|
+
let href = props.href ?? '#';
|
|
43
|
+
this.setAttribute('tabindex', 0);
|
|
44
|
+
this.setProp('tag', 'a');
|
|
45
|
+
this.setAttribute('href', href);
|
|
46
|
+
this.setAttribute('target', props.target);
|
|
47
|
+
if (text) {
|
|
48
|
+
this.setContent(isHtmlString(text) ? text : html `<span>${text}</span>`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
set text(text) {
|
|
52
|
+
this.m_props.text = text;
|
|
53
|
+
this.update();
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ___ ___ __
|
|
3
|
+
* \ \_/ / / _
|
|
4
|
+
* \ / /_| |_
|
|
5
|
+
* / _ \____ _|
|
|
6
|
+
* /__/ \__\ |_|
|
|
7
|
+
*
|
|
8
|
+
* @file listview.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 { Container, Component, CProps, ContainerEventMap, EvDblClick } from './component';
|
|
26
|
+
import { IconID } from './icon';
|
|
27
|
+
import { VLayout } from './layout';
|
|
28
|
+
import { Popup, PopupEventMap, PopupProps } from './popup';
|
|
29
|
+
import { HtmlString } from './tools';
|
|
30
|
+
import { EvContextMenu, EvSelectionChange, EvClick, EventCallback, BasicEvent } from "./x4_events";
|
|
31
|
+
/**
|
|
32
|
+
* item definition
|
|
33
|
+
*/
|
|
34
|
+
export declare class ListViewItem {
|
|
35
|
+
id: any;
|
|
36
|
+
text?: string | HtmlString;
|
|
37
|
+
html?: boolean;
|
|
38
|
+
icon?: IconID;
|
|
39
|
+
data?: any;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* callback to render item
|
|
43
|
+
*/
|
|
44
|
+
export interface RenderListItem {
|
|
45
|
+
(item: ListViewItem): any;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* callback to fill the list
|
|
49
|
+
*/
|
|
50
|
+
export interface PopulateItems {
|
|
51
|
+
(): ListViewItem[];
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* listview can generate these events
|
|
55
|
+
*/
|
|
56
|
+
export interface ListViewEventMap extends ContainerEventMap {
|
|
57
|
+
click?: EvClick;
|
|
58
|
+
dblClick?: EvDblClick;
|
|
59
|
+
contextMenu?: EvContextMenu;
|
|
60
|
+
selectionChange?: EvSelectionChange;
|
|
61
|
+
cancel?: EvCancel;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* listview properties
|
|
65
|
+
*/
|
|
66
|
+
export interface ListViewProps<E extends ListViewEventMap = ListViewEventMap> extends CProps<E> {
|
|
67
|
+
items?: ListViewItem[];
|
|
68
|
+
populate?: PopulateItems;
|
|
69
|
+
gadgets?: Component[];
|
|
70
|
+
virtual?: boolean;
|
|
71
|
+
itemHeight?: number;
|
|
72
|
+
renderItem?: RenderListItem;
|
|
73
|
+
click?: EventCallback<EvClick>;
|
|
74
|
+
dblClick?: EventCallback<EvDblClick>;
|
|
75
|
+
contextMenu?: EventCallback<EvContextMenu>;
|
|
76
|
+
selectionChange?: EventCallback<EvSelectionChange>;
|
|
77
|
+
cancel?: EventCallback<EvCancel>;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Standard listview class
|
|
81
|
+
*/
|
|
82
|
+
export declare class ListView<T extends ListViewProps = ListViewProps, E extends ListViewEventMap = ListViewEventMap> extends VLayout<T, E> {
|
|
83
|
+
protected m_selection: {
|
|
84
|
+
item: ListViewItem;
|
|
85
|
+
citem: Component;
|
|
86
|
+
};
|
|
87
|
+
protected m_defer_sel: any;
|
|
88
|
+
protected m_container: Container;
|
|
89
|
+
protected m_view: Container;
|
|
90
|
+
protected m_topIndex: number;
|
|
91
|
+
protected m_itemHeight: number;
|
|
92
|
+
protected m_cache: Map<number, Component>;
|
|
93
|
+
constructor(props: T);
|
|
94
|
+
componentCreated(): void;
|
|
95
|
+
render(props: ListViewProps): void;
|
|
96
|
+
/**
|
|
97
|
+
* change the list of item displayed
|
|
98
|
+
* @param items - new array of items
|
|
99
|
+
* @deprecated
|
|
100
|
+
*/
|
|
101
|
+
set items(items: ListViewItem[]);
|
|
102
|
+
get items(): ListViewItem[];
|
|
103
|
+
/**
|
|
104
|
+
* change the list of item displayed
|
|
105
|
+
* @param items - new array of items
|
|
106
|
+
*/
|
|
107
|
+
setItems(items: ListViewItem[], keepSel?: boolean): void;
|
|
108
|
+
private _handleKey;
|
|
109
|
+
/** @ignore */
|
|
110
|
+
private _buildContent;
|
|
111
|
+
/**
|
|
112
|
+
*
|
|
113
|
+
*/
|
|
114
|
+
private _updateScroll;
|
|
115
|
+
private _buildItems;
|
|
116
|
+
/** @ignore
|
|
117
|
+
* default rendering of an item
|
|
118
|
+
*/
|
|
119
|
+
private _renderItem;
|
|
120
|
+
onRenderItem(item: ListViewItem): Component;
|
|
121
|
+
/** @ignore */
|
|
122
|
+
private _handleClick;
|
|
123
|
+
/** @ignore */
|
|
124
|
+
private _handleCtxMenu;
|
|
125
|
+
/**
|
|
126
|
+
* @ignore
|
|
127
|
+
* called when an item is selected by mouse
|
|
128
|
+
*/
|
|
129
|
+
protected _selectItem(item: ListViewItem, citem: Component, notify?: boolean): void;
|
|
130
|
+
/**
|
|
131
|
+
* return the current selection or null
|
|
132
|
+
*/
|
|
133
|
+
get selection(): ListViewItem;
|
|
134
|
+
set selection(id: ListViewItem);
|
|
135
|
+
private _findItemWithId;
|
|
136
|
+
/**
|
|
137
|
+
* append or prepend a new item
|
|
138
|
+
* @param item
|
|
139
|
+
* @param prepend
|
|
140
|
+
* @param select
|
|
141
|
+
*/
|
|
142
|
+
appendItem(item: ListViewItem, prepend?: boolean, select?: boolean): void;
|
|
143
|
+
/**
|
|
144
|
+
* update an item
|
|
145
|
+
*/
|
|
146
|
+
updateItem(id: any, item: ListViewItem): void;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Cancel Event
|
|
150
|
+
*/
|
|
151
|
+
export interface EvCancel extends BasicEvent {
|
|
152
|
+
}
|
|
153
|
+
export declare function EvCancel(context?: any): EvCancel;
|
|
154
|
+
interface PopupListViewEventMap extends PopupEventMap {
|
|
155
|
+
cancel: EvCancel;
|
|
156
|
+
}
|
|
157
|
+
interface PopupListViewProps extends PopupProps<PopupListViewEventMap> {
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
*
|
|
161
|
+
*/
|
|
162
|
+
export declare class PopupListView extends Popup<PopupListViewProps, PopupListViewEventMap> {
|
|
163
|
+
m_list: ListView;
|
|
164
|
+
constructor(props: ListViewProps);
|
|
165
|
+
set items(items: ListViewItem[]);
|
|
166
|
+
private _handleClick;
|
|
167
|
+
show(modal?: boolean): void;
|
|
168
|
+
hide(): void;
|
|
169
|
+
close(): void;
|
|
170
|
+
get selection(): any;
|
|
171
|
+
set selection(itemId: any);
|
|
172
|
+
}
|
|
173
|
+
export {};
|