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
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ___ ___ __
|
|
3
|
+
* \ \_/ / / _
|
|
4
|
+
* \ / /_| |_
|
|
5
|
+
* / _ \____ _|
|
|
6
|
+
* /__/ \__\ |_|
|
|
7
|
+
*
|
|
8
|
+
* @file tooltips.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 } from './component';
|
|
26
|
+
/**
|
|
27
|
+
*
|
|
28
|
+
*/
|
|
29
|
+
export declare class Tooltip extends Component {
|
|
30
|
+
private m_text;
|
|
31
|
+
set text(text: any);
|
|
32
|
+
/** @ignore */
|
|
33
|
+
render(): void;
|
|
34
|
+
/**
|
|
35
|
+
* display the menu at a specific position
|
|
36
|
+
* @param x
|
|
37
|
+
* @param y
|
|
38
|
+
*/
|
|
39
|
+
displayAt(x: number, y: number, align?: string): void;
|
|
40
|
+
}
|
|
41
|
+
export declare type TooltipHandler = (text: string) => void;
|
|
42
|
+
export declare function initTooltips(cb?: TooltipHandler): void;
|
package/lib/tooltips.js
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ___ ___ __
|
|
3
|
+
* \ \_/ / / _
|
|
4
|
+
* \ / /_| |_
|
|
5
|
+
* / _ \____ _|
|
|
6
|
+
* /__/ \__\ |_|
|
|
7
|
+
*
|
|
8
|
+
* @file tooltips.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 } from './component';
|
|
26
|
+
import { Label } from './label';
|
|
27
|
+
import { Icon } from './icon';
|
|
28
|
+
import { isTouchDevice } from './tools';
|
|
29
|
+
let tipTmo;
|
|
30
|
+
let tooltip;
|
|
31
|
+
/**
|
|
32
|
+
*
|
|
33
|
+
*/
|
|
34
|
+
export class Tooltip extends Component {
|
|
35
|
+
m_text;
|
|
36
|
+
set text(text) {
|
|
37
|
+
this.m_text.text = text;
|
|
38
|
+
}
|
|
39
|
+
/** @ignore */
|
|
40
|
+
render() {
|
|
41
|
+
this.setClass('@non-maskable', true);
|
|
42
|
+
this.setContent([
|
|
43
|
+
new Icon({ icon: 'cls(far fa-circle-info)' }),
|
|
44
|
+
this.m_text = new Label({ text: 'help' })
|
|
45
|
+
]);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* display the menu at a specific position
|
|
49
|
+
* @param x
|
|
50
|
+
* @param y
|
|
51
|
+
*/
|
|
52
|
+
displayAt(x, y, align = 'top left') {
|
|
53
|
+
this.show();
|
|
54
|
+
let halign = 'l', valign = 't';
|
|
55
|
+
if (align.indexOf('right') >= 0) {
|
|
56
|
+
halign = 'r';
|
|
57
|
+
}
|
|
58
|
+
if (align.indexOf('bottom') >= 0) {
|
|
59
|
+
valign = 'b';
|
|
60
|
+
}
|
|
61
|
+
// @TODO: this is a minimal overflow problem solution
|
|
62
|
+
let rc = document.body.getBoundingClientRect(), rm = this.getBoundingRect();
|
|
63
|
+
if (halign == 'r') {
|
|
64
|
+
x -= rm.width;
|
|
65
|
+
}
|
|
66
|
+
if (valign == 'b') {
|
|
67
|
+
y -= rm.height;
|
|
68
|
+
}
|
|
69
|
+
if ((x + rm.width) > rc.right) {
|
|
70
|
+
x = rc.right - rm.width;
|
|
71
|
+
}
|
|
72
|
+
if ((y + rm.height) > rc.bottom) {
|
|
73
|
+
y = rc.bottom - rm.height - 17; // default cursor height
|
|
74
|
+
}
|
|
75
|
+
this.setStyle({ left: x, top: y });
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
export function initTooltips(cb) {
|
|
79
|
+
if (isTouchDevice()) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
let tipTarget = {
|
|
83
|
+
target: null,
|
|
84
|
+
x: 0,
|
|
85
|
+
y: 0
|
|
86
|
+
};
|
|
87
|
+
function handle_mpos(event) {
|
|
88
|
+
tipTarget.x = event.pageX;
|
|
89
|
+
tipTarget.y = event.pageY;
|
|
90
|
+
}
|
|
91
|
+
function handle_mouse(event) {
|
|
92
|
+
let target = event.target;
|
|
93
|
+
let tip = null;
|
|
94
|
+
tipTarget.x = event.pageX + 10;
|
|
95
|
+
tipTarget.y = event.pageY + 15;
|
|
96
|
+
while (target) {
|
|
97
|
+
tip = target.getAttribute('tip');
|
|
98
|
+
if (tip) {
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
target = target.parentElement;
|
|
102
|
+
}
|
|
103
|
+
if (target == tipTarget.target || (tooltip && target == tooltip.dom)) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
if (!target || !tip) {
|
|
107
|
+
tipTarget.target = null;
|
|
108
|
+
if (cb) {
|
|
109
|
+
cb(null);
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
_hideTip();
|
|
113
|
+
}
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
tipTarget.target = target;
|
|
117
|
+
if (cb) {
|
|
118
|
+
cb(null);
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
_hideTip();
|
|
122
|
+
}
|
|
123
|
+
if (cb) {
|
|
124
|
+
cb(tip);
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
tipTmo = setTimeout(() => {
|
|
128
|
+
if (tooltip === undefined) {
|
|
129
|
+
tooltip = new Tooltip({});
|
|
130
|
+
document.body.appendChild(tooltip._build());
|
|
131
|
+
}
|
|
132
|
+
tooltip.text = tip;
|
|
133
|
+
tooltip.displayAt(tipTarget.x + 17, tipTarget.y + 17, 'top left');
|
|
134
|
+
}, 700);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
function _hideTip() {
|
|
138
|
+
if (tipTmo) {
|
|
139
|
+
clearTimeout(tipTmo);
|
|
140
|
+
}
|
|
141
|
+
if (tooltip) {
|
|
142
|
+
tooltip.hide();
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
document.body.addEventListener('mouseover', handle_mouse);
|
|
146
|
+
document.body.addEventListener('mouseout', handle_mouse);
|
|
147
|
+
document.body.addEventListener('mousemove', handle_mpos);
|
|
148
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ___ ___ __
|
|
3
|
+
* \ \_/ / / _
|
|
4
|
+
* \ / /_| |_
|
|
5
|
+
* / _ \____ _|
|
|
6
|
+
* /__/ \__\ |_|
|
|
7
|
+
*
|
|
8
|
+
* @file treeview.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, ContainerEventMap, ContainerProps, EvDblClick, EventHandler } from './component';
|
|
26
|
+
import { HtmlString } from './tools';
|
|
27
|
+
import { IconID } from './icon';
|
|
28
|
+
import { VLayout } from './layout';
|
|
29
|
+
import { EvClick, BasicEvent, EvDrag, EvSelectionChange, EvContextMenu } from './x4_events';
|
|
30
|
+
export interface EvExpand extends BasicEvent {
|
|
31
|
+
node: TreeNode;
|
|
32
|
+
}
|
|
33
|
+
export interface HierarchicalNode {
|
|
34
|
+
id: number;
|
|
35
|
+
parent: number;
|
|
36
|
+
name: string;
|
|
37
|
+
leaf: boolean;
|
|
38
|
+
}
|
|
39
|
+
export interface TreeNode {
|
|
40
|
+
id: any;
|
|
41
|
+
text?: string | HtmlString;
|
|
42
|
+
icon?: IconID;
|
|
43
|
+
children?: TreeNode[];
|
|
44
|
+
open?: boolean;
|
|
45
|
+
data?: any;
|
|
46
|
+
parent?: number;
|
|
47
|
+
cls?: string;
|
|
48
|
+
}
|
|
49
|
+
interface TreeViewEventMap extends ContainerEventMap {
|
|
50
|
+
click: EvClick;
|
|
51
|
+
dblclick: EvDblClick;
|
|
52
|
+
expand: EvExpand;
|
|
53
|
+
drag: EvDrag;
|
|
54
|
+
selectionchange: EvSelectionChange;
|
|
55
|
+
contextMenu: EvContextMenu;
|
|
56
|
+
}
|
|
57
|
+
export interface TreeViewProps extends ContainerProps<TreeViewEventMap> {
|
|
58
|
+
root: TreeNode;
|
|
59
|
+
indent?: number;
|
|
60
|
+
gadgets?: Component[];
|
|
61
|
+
sort?: boolean;
|
|
62
|
+
canDragItems?: boolean;
|
|
63
|
+
renderItem?: (itm: TreeNode) => Component;
|
|
64
|
+
dblclick?: EventHandler<EvDblClick>;
|
|
65
|
+
selectionchange?: EventHandler<EvSelectionChange>;
|
|
66
|
+
drag?: EventHandler<EvDrag>;
|
|
67
|
+
contextMenu?: EventHandler<EvContextMenu>;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
*
|
|
71
|
+
*/
|
|
72
|
+
export declare class TreeView extends VLayout<TreeViewProps, TreeViewEventMap> {
|
|
73
|
+
m_view: Container;
|
|
74
|
+
m_container: Container;
|
|
75
|
+
m_selection: {
|
|
76
|
+
id: any;
|
|
77
|
+
el: Component;
|
|
78
|
+
};
|
|
79
|
+
constructor(props: TreeViewProps);
|
|
80
|
+
private _dragEnter;
|
|
81
|
+
private _dragLeave;
|
|
82
|
+
private _drop;
|
|
83
|
+
render(): void;
|
|
84
|
+
private __update;
|
|
85
|
+
updateElement(id: any): void;
|
|
86
|
+
set root(root: TreeNode);
|
|
87
|
+
/**
|
|
88
|
+
* same as root = xxx but keep elements open
|
|
89
|
+
*/
|
|
90
|
+
refreshRoot(root: TreeNode): void;
|
|
91
|
+
private _buildBranch;
|
|
92
|
+
private _renderDef;
|
|
93
|
+
private _makeNode;
|
|
94
|
+
/**
|
|
95
|
+
*
|
|
96
|
+
*/
|
|
97
|
+
forEach(cb: (node: any) => boolean): any;
|
|
98
|
+
ensureVisible(id: any): void;
|
|
99
|
+
set selection(id: any);
|
|
100
|
+
private _getNode;
|
|
101
|
+
get selection(): any;
|
|
102
|
+
getNodeWithId(id: any): TreeNode;
|
|
103
|
+
/**
|
|
104
|
+
*
|
|
105
|
+
*/
|
|
106
|
+
private _click;
|
|
107
|
+
private _handleCtxMenu;
|
|
108
|
+
/**
|
|
109
|
+
* constructs a tree node from an array of strings
|
|
110
|
+
* elements are organized like folders (separator = /)
|
|
111
|
+
* @example
|
|
112
|
+
* let root = TreeView.buildFromString( [
|
|
113
|
+
* 'this/is/a/final/file'
|
|
114
|
+
* 'this/is/another/file'
|
|
115
|
+
* ] );
|
|
116
|
+
*/
|
|
117
|
+
static buildFromStrings(paths: string[], separator?: string): TreeNode;
|
|
118
|
+
/**
|
|
119
|
+
* constructs a tree node from an array of nodes like
|
|
120
|
+
* node {
|
|
121
|
+
* id: number,
|
|
122
|
+
* parent: number,
|
|
123
|
+
* name: string
|
|
124
|
+
* }
|
|
125
|
+
*/
|
|
126
|
+
static buildFromHierarchy(nodes: HierarchicalNode[], cb?: (node: TreeNode) => void): TreeNode;
|
|
127
|
+
}
|
|
128
|
+
export {};
|