x4js 1.5.22 → 1.5.23
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/cjs/index.js +1 -1
- package/lib/cjs/index.js.map +1 -1
- package/lib/esm/index.mjs +1 -1
- package/lib/esm/index.mjs.map +1 -1
- package/lib/src/version.ts +1 -1
- package/lib/types/action.d.ts +57 -0
- package/lib/types/app_sockets.d.ts +29 -0
- package/lib/types/application.d.ts +104 -0
- package/lib/types/autocomplete.d.ts +58 -0
- package/lib/types/base_component.d.ts +88 -0
- package/lib/types/button.d.ts +151 -0
- package/lib/types/calendar.d.ts +82 -0
- package/lib/types/canvas.d.ts +92 -0
- package/lib/types/cardview.d.ts +87 -0
- package/lib/types/checkbox.d.ts +77 -0
- package/lib/types/color.d.ts +148 -0
- package/lib/types/colorpicker.d.ts +107 -0
- package/lib/types/combobox.d.ts +107 -0
- package/lib/types/component.d.ts +601 -0
- package/lib/types/datastore.d.ts +396 -0
- package/lib/types/dialog.d.ts +175 -0
- package/lib/types/dom_events.d.ts +302 -0
- package/lib/types/drag_manager.d.ts +54 -0
- package/lib/types/drawtext.d.ts +48 -0
- package/lib/types/fileupload.d.ts +64 -0
- package/lib/types/form.d.ts +133 -0
- package/lib/types/formatters.d.ts +35 -0
- package/lib/types/gridview.d.ts +175 -0
- package/lib/types/i18n.d.ts +73 -0
- package/lib/types/icon.d.ts +64 -0
- package/lib/types/image.d.ts +55 -0
- package/lib/types/index.d.ts +84 -5896
- package/lib/types/input.d.ts +91 -0
- package/lib/types/label.d.ts +58 -0
- package/lib/types/layout.d.ts +87 -0
- package/lib/types/link.d.ts +50 -0
- package/lib/types/listview.d.ts +178 -0
- package/lib/types/md5.d.ts +61 -0
- package/lib/types/menu.d.ts +130 -0
- package/lib/types/messagebox.d.ts +69 -0
- package/lib/types/panel.d.ts +47 -0
- package/lib/types/popup.d.ts +75 -0
- package/lib/types/property_editor.d.ts +71 -0
- package/lib/types/radiobtn.d.ts +73 -0
- package/lib/types/rating.d.ts +53 -0
- package/lib/types/request.d.ts +52 -0
- package/lib/types/router.d.ts +42 -0
- package/lib/types/settings.d.ts +37 -0
- package/lib/types/sidebarview.d.ts +49 -0
- package/lib/types/spreadsheet.d.ts +222 -0
- package/lib/types/styles.d.ts +85 -0
- package/lib/types/svgcomponent.d.ts +215 -0
- package/lib/types/tabbar.d.ts +58 -0
- package/lib/types/tabview.d.ts +49 -0
- package/lib/types/textarea.d.ts +77 -0
- package/lib/types/textedit.d.ts +123 -0
- package/lib/types/toaster.d.ts +42 -0
- package/lib/types/tools.d.ts +394 -0
- package/lib/types/tooltips.d.ts +46 -0
- package/lib/types/treeview.d.ts +144 -0
- package/lib/types/version.d.ts +29 -0
- package/lib/types/x4dom.d.ts +49 -0
- package/lib/types/x4events.d.ts +269 -0
- package/lib/types/x4react.d.ts +41 -0
- package/package.json +1 -1
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ___ ___ __
|
|
3
|
+
* \ \_/ / / _
|
|
4
|
+
* \ / /_| |_
|
|
5
|
+
* / _ \____ _|
|
|
6
|
+
* /__/ \__\ |_|
|
|
7
|
+
*
|
|
8
|
+
* @file treeview.ts
|
|
9
|
+
* @author Etienne Cochard
|
|
10
|
+
*
|
|
11
|
+
* Copyright (c) 2019-2022 R-libre ingenierie
|
|
12
|
+
*
|
|
13
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
14
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
15
|
+
* in the Software without restriction, including without limitation the rights
|
|
16
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
17
|
+
* of the Software, and to permit persons to whom the Software is furnished to do so,
|
|
18
|
+
* subject to the following conditions:
|
|
19
|
+
* The above copyright notice and this permission notice shall be included in all copies
|
|
20
|
+
* or substantial portions of the Software.
|
|
21
|
+
*
|
|
22
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
23
|
+
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
|
24
|
+
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
25
|
+
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
26
|
+
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
27
|
+
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
28
|
+
**/
|
|
29
|
+
import { Component, Container, ContainerEventMap, ContainerProps, EvDblClick, EventHandler } from './component';
|
|
30
|
+
import { HtmlString } from './tools';
|
|
31
|
+
import { IconID } from './icon';
|
|
32
|
+
import { VLayout } from './layout';
|
|
33
|
+
import { EvClick, BasicEvent, EvDrag, EvSelectionChange, EvContextMenu } from './x4events';
|
|
34
|
+
export interface EvExpand extends BasicEvent {
|
|
35
|
+
node: TreeNode;
|
|
36
|
+
}
|
|
37
|
+
export interface HierarchicalNode {
|
|
38
|
+
id: number;
|
|
39
|
+
name: string;
|
|
40
|
+
parent?: number;
|
|
41
|
+
cls?: string;
|
|
42
|
+
leaf?: boolean;
|
|
43
|
+
icon?: string;
|
|
44
|
+
data?: any;
|
|
45
|
+
}
|
|
46
|
+
export interface TreeNode {
|
|
47
|
+
id: any;
|
|
48
|
+
text?: string | HtmlString;
|
|
49
|
+
icon?: IconID;
|
|
50
|
+
children?: TreeNode[];
|
|
51
|
+
open?: boolean;
|
|
52
|
+
data?: any;
|
|
53
|
+
parent?: number;
|
|
54
|
+
cls?: string;
|
|
55
|
+
}
|
|
56
|
+
interface TreeViewEventMap extends ContainerEventMap {
|
|
57
|
+
click: EvClick;
|
|
58
|
+
dblclick: EvDblClick;
|
|
59
|
+
expand: EvExpand;
|
|
60
|
+
drag: EvDrag;
|
|
61
|
+
selectionchange: EvSelectionChange;
|
|
62
|
+
contextMenu: EvContextMenu;
|
|
63
|
+
}
|
|
64
|
+
export interface TreeViewProps extends ContainerProps<TreeViewEventMap> {
|
|
65
|
+
root: TreeNode;
|
|
66
|
+
indent?: number;
|
|
67
|
+
gadgets?: Component[];
|
|
68
|
+
sort?: boolean;
|
|
69
|
+
canDragItems?: boolean;
|
|
70
|
+
renderItem?: (itm: TreeNode) => Component;
|
|
71
|
+
dblclick?: EventHandler<EvDblClick>;
|
|
72
|
+
selectionchange?: EventHandler<EvSelectionChange>;
|
|
73
|
+
drag?: EventHandler<EvDrag>;
|
|
74
|
+
contextMenu?: EventHandler<EvContextMenu>;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
*
|
|
78
|
+
*/
|
|
79
|
+
export declare class TreeView extends VLayout<TreeViewProps, TreeViewEventMap> {
|
|
80
|
+
m_view: Container;
|
|
81
|
+
m_container: Container;
|
|
82
|
+
m_selection: {
|
|
83
|
+
id: any;
|
|
84
|
+
el: Component;
|
|
85
|
+
};
|
|
86
|
+
constructor(props: TreeViewProps);
|
|
87
|
+
private _dragEnter;
|
|
88
|
+
private _dragLeave;
|
|
89
|
+
private _drop;
|
|
90
|
+
render(): void;
|
|
91
|
+
private __update;
|
|
92
|
+
updateElement(id: any): void;
|
|
93
|
+
set root(root: TreeNode);
|
|
94
|
+
openAll(open?: boolean): void;
|
|
95
|
+
/**
|
|
96
|
+
* same as root = xxx but keep elements open
|
|
97
|
+
*/
|
|
98
|
+
refreshRoot(root: TreeNode): void;
|
|
99
|
+
private _buildBranch;
|
|
100
|
+
private _renderDef;
|
|
101
|
+
private _makeNode;
|
|
102
|
+
/**
|
|
103
|
+
*
|
|
104
|
+
*/
|
|
105
|
+
forEach(cb: (node: TreeNode) => boolean | void): any;
|
|
106
|
+
ensureVisible(id: any): void;
|
|
107
|
+
set selection(id: any);
|
|
108
|
+
/**
|
|
109
|
+
* care, component should have been created, to select an item at startup,
|
|
110
|
+
* use something like
|
|
111
|
+
* componentCreated( ) {
|
|
112
|
+
* mytree.select( id );
|
|
113
|
+
* }
|
|
114
|
+
*/
|
|
115
|
+
select(id: any, notify?: boolean): void;
|
|
116
|
+
private _getNode;
|
|
117
|
+
get selection(): any;
|
|
118
|
+
getNodeWithId(id: any): TreeNode;
|
|
119
|
+
/**
|
|
120
|
+
*
|
|
121
|
+
*/
|
|
122
|
+
private _click;
|
|
123
|
+
private _handleCtxMenu;
|
|
124
|
+
/**
|
|
125
|
+
* constructs a tree node from an array of strings
|
|
126
|
+
* elements are organized like folders (separator = /)
|
|
127
|
+
* @example
|
|
128
|
+
* let root = TreeView.buildFromString( [
|
|
129
|
+
* 'this/is/a/final/file'
|
|
130
|
+
* 'this/is/another/file'
|
|
131
|
+
* ] );
|
|
132
|
+
*/
|
|
133
|
+
static buildFromStrings(paths: string[], separator?: string): TreeNode;
|
|
134
|
+
/**
|
|
135
|
+
* constructs a tree node from an array of nodes like
|
|
136
|
+
* node {
|
|
137
|
+
* id: number,
|
|
138
|
+
* parent: number,
|
|
139
|
+
* name: string
|
|
140
|
+
* }
|
|
141
|
+
*/
|
|
142
|
+
static buildFromHierarchy(nodes: HierarchicalNode[], cb?: (node: TreeNode) => void): TreeNode;
|
|
143
|
+
}
|
|
144
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ___ ___ __
|
|
3
|
+
* \ \_/ / / _
|
|
4
|
+
* \ / /_| |_
|
|
5
|
+
* / _ \____ _|
|
|
6
|
+
* /__/ \__\ |_|
|
|
7
|
+
*
|
|
8
|
+
* @file version.ts
|
|
9
|
+
* @author Etienne Cochard
|
|
10
|
+
*
|
|
11
|
+
* Copyright (c) 2019-2022 R-libre ingenierie
|
|
12
|
+
*
|
|
13
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
14
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
15
|
+
* in the Software without restriction, including without limitation the rights
|
|
16
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
17
|
+
* of the Software, and to permit persons to whom the Software is furnished to do so,
|
|
18
|
+
* subject to the following conditions:
|
|
19
|
+
* The above copyright notice and this permission notice shall be included in all copies
|
|
20
|
+
* or substantial portions of the Software.
|
|
21
|
+
*
|
|
22
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
23
|
+
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
|
24
|
+
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
25
|
+
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
26
|
+
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
27
|
+
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
28
|
+
**/
|
|
29
|
+
export declare const x4js_version = "1.5.23";
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ___ ___ __
|
|
3
|
+
* \ \_/ / / _
|
|
4
|
+
* \ / /_| |_
|
|
5
|
+
* / _ \____ _|
|
|
6
|
+
* /__/ \__\ |_|
|
|
7
|
+
*
|
|
8
|
+
* @file x4events.ts
|
|
9
|
+
* @author Etienne Cochard
|
|
10
|
+
*
|
|
11
|
+
* Copyright (c) 2019-2022 R-libre ingenierie
|
|
12
|
+
*
|
|
13
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
14
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
15
|
+
* in the Software without restriction, including without limitation the rights
|
|
16
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
17
|
+
* of the Software, and to permit persons to whom the Software is furnished to do so,
|
|
18
|
+
* subject to the following conditions:
|
|
19
|
+
* The above copyright notice and this permission notice shall be included in all copies
|
|
20
|
+
* or substantial portions of the Software.
|
|
21
|
+
*
|
|
22
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
23
|
+
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
|
24
|
+
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
25
|
+
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
26
|
+
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
27
|
+
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
28
|
+
**/
|
|
29
|
+
/**
|
|
30
|
+
* SSR preparation
|
|
31
|
+
*/
|
|
32
|
+
interface IX4Document {
|
|
33
|
+
createElement<K extends keyof HTMLElementTagNameMap>(tagName: K, options?: ElementCreationOptions): HTMLElementTagNameMap[K];
|
|
34
|
+
createElementNS(namespace: string | null, qualifiedName: string, options?: string | ElementCreationOptions): Element;
|
|
35
|
+
createTextNode(data: string): Text;
|
|
36
|
+
addEventListener<K extends keyof DocumentEventMap>(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
|
|
37
|
+
removeEventListener<K extends keyof DocumentEventMap>(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
|
|
38
|
+
querySelectorAll<E extends Element = Element>(selectors: string): NodeListOf<E>;
|
|
39
|
+
querySelector<E extends Element = Element>(selectors: string): E | null;
|
|
40
|
+
get body(): HTMLElement;
|
|
41
|
+
get activeElement(): Element;
|
|
42
|
+
get location(): Location;
|
|
43
|
+
get styleSheets(): StyleSheetList;
|
|
44
|
+
get head(): HTMLHeadElement;
|
|
45
|
+
get documentElement(): HTMLElement;
|
|
46
|
+
set title(title: string);
|
|
47
|
+
}
|
|
48
|
+
export declare let x4document: IX4Document;
|
|
49
|
+
export {};
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ___ ___ __
|
|
3
|
+
* \ \_/ / / _
|
|
4
|
+
* \ / /_| |_
|
|
5
|
+
* / _ \____ _|
|
|
6
|
+
* /__/ \__\ |_|
|
|
7
|
+
*
|
|
8
|
+
* @file x4events.ts
|
|
9
|
+
* @author Etienne Cochard
|
|
10
|
+
*
|
|
11
|
+
* Copyright (c) 2019-2022 R-libre ingenierie
|
|
12
|
+
*
|
|
13
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
14
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
15
|
+
* in the Software without restriction, including without limitation the rights
|
|
16
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
17
|
+
* of the Software, and to permit persons to whom the Software is furnished to do so,
|
|
18
|
+
* subject to the following conditions:
|
|
19
|
+
* The above copyright notice and this permission notice shall be included in all copies
|
|
20
|
+
* or substantial portions of the Software.
|
|
21
|
+
*
|
|
22
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
23
|
+
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
|
24
|
+
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
25
|
+
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
26
|
+
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
27
|
+
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
28
|
+
**/
|
|
29
|
+
export type EventCallback<T extends BasicEvent = BasicEvent> = (event: T) => any;
|
|
30
|
+
export interface EventDisposer {
|
|
31
|
+
dispose(): void;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Basic event
|
|
35
|
+
* name like that to avoid conflict with Browsers Event class.
|
|
36
|
+
*/
|
|
37
|
+
export interface BasicEvent {
|
|
38
|
+
readonly type?: string;
|
|
39
|
+
readonly source?: unknown;
|
|
40
|
+
readonly context?: any;
|
|
41
|
+
propagationStopped?: boolean;
|
|
42
|
+
defaultPrevented?: boolean;
|
|
43
|
+
stopPropagation?(): void;
|
|
44
|
+
preventDefault?(): void;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* BasicEvent Builder
|
|
48
|
+
* this function is responsable of BasicEvent creation
|
|
49
|
+
* ie. is equivalent of new BasicEvent( xxx );
|
|
50
|
+
* @param params
|
|
51
|
+
* @returns BasicEvent
|
|
52
|
+
*/
|
|
53
|
+
export declare function BasicEvent<T extends BasicEvent = BasicEvent>(params: any): T;
|
|
54
|
+
/**
|
|
55
|
+
* Click Event
|
|
56
|
+
* click event do not have any additional parameters
|
|
57
|
+
*/
|
|
58
|
+
export interface EvClick extends BasicEvent {
|
|
59
|
+
}
|
|
60
|
+
export declare function EvClick(context?: any): EvClick;
|
|
61
|
+
/**
|
|
62
|
+
* Change Event
|
|
63
|
+
* value is the the element value
|
|
64
|
+
*/
|
|
65
|
+
export interface EvChange extends BasicEvent {
|
|
66
|
+
readonly value: any;
|
|
67
|
+
}
|
|
68
|
+
export declare function EvChange(value: unknown, context?: any): EvChange;
|
|
69
|
+
/**
|
|
70
|
+
* Selection Event
|
|
71
|
+
* value is the new selection or null
|
|
72
|
+
*/
|
|
73
|
+
interface X4Selection {
|
|
74
|
+
}
|
|
75
|
+
export interface EvSelectionChange extends BasicEvent {
|
|
76
|
+
readonly selection: X4Selection;
|
|
77
|
+
}
|
|
78
|
+
export declare function EvSelectionChange(selection: X4Selection, context?: any): EvSelectionChange;
|
|
79
|
+
/**
|
|
80
|
+
* ContextMenu Event
|
|
81
|
+
*/
|
|
82
|
+
export interface EvContextMenu extends BasicEvent {
|
|
83
|
+
uievent: UIEvent;
|
|
84
|
+
}
|
|
85
|
+
export declare function EvContextMenu(uievent: UIEvent, context?: any): EvContextMenu;
|
|
86
|
+
/**
|
|
87
|
+
* Timer Event
|
|
88
|
+
* @see startTimer, stopTimer
|
|
89
|
+
*/
|
|
90
|
+
export interface EvTimer extends BasicEvent {
|
|
91
|
+
timer: string;
|
|
92
|
+
time: number;
|
|
93
|
+
}
|
|
94
|
+
export declare function EvTimer(timer: string, time?: number, context?: any): EvTimer;
|
|
95
|
+
/**
|
|
96
|
+
* Simple message
|
|
97
|
+
*/
|
|
98
|
+
export interface EvMessage extends BasicEvent {
|
|
99
|
+
readonly msg: string;
|
|
100
|
+
readonly params?: any;
|
|
101
|
+
}
|
|
102
|
+
export declare function EvMessage(msg: string, params?: unknown, source?: unknown): EvMessage;
|
|
103
|
+
/**
|
|
104
|
+
* Drag/Drop event
|
|
105
|
+
*/
|
|
106
|
+
export interface EvDrag extends BasicEvent {
|
|
107
|
+
element: unknown;
|
|
108
|
+
data: any;
|
|
109
|
+
}
|
|
110
|
+
export declare function EvDrag(element: unknown, data: any, ctx: any): EvDrag;
|
|
111
|
+
/**
|
|
112
|
+
* Errors
|
|
113
|
+
*/
|
|
114
|
+
export interface EvError extends BasicEvent {
|
|
115
|
+
code: number;
|
|
116
|
+
message: string;
|
|
117
|
+
}
|
|
118
|
+
export declare function EvError(code: number, message: string): EvError;
|
|
119
|
+
/**
|
|
120
|
+
* this Base interface is used to describe available events & their types
|
|
121
|
+
*
|
|
122
|
+
* you can implement your own event mapping:
|
|
123
|
+
* @example
|
|
124
|
+
* ```ts
|
|
125
|
+
* interface MyEventMap extends EventMap {
|
|
126
|
+
* click: EvClick,
|
|
127
|
+
* 'custom-message': Event,
|
|
128
|
+
* [key: string]: Event,
|
|
129
|
+
* }
|
|
130
|
+
* ```
|
|
131
|
+
*/
|
|
132
|
+
export interface EventMap {
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* basic event types, in general the type is builded from the eventMap
|
|
136
|
+
* this is very usefull for editor completion
|
|
137
|
+
* @example
|
|
138
|
+
* ```ts
|
|
139
|
+
* type MyEventType = MapEvents<MyEventMap>;
|
|
140
|
+
* ```
|
|
141
|
+
*/
|
|
142
|
+
export interface EventTypes {
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* convert an EventMap to a EventType
|
|
146
|
+
*/
|
|
147
|
+
export type MapEvents<Type> = {
|
|
148
|
+
[Property in keyof Type]?: (ev: Type[Property]) => any;
|
|
149
|
+
};
|
|
150
|
+
/**
|
|
151
|
+
* Event emitter class
|
|
152
|
+
* this class allow you to emit and handle events
|
|
153
|
+
*
|
|
154
|
+
* @example:
|
|
155
|
+
* ```ts
|
|
156
|
+
*
|
|
157
|
+
* interface EvDoIt extends BasicEvent {
|
|
158
|
+
* param: unknown;
|
|
159
|
+
* }
|
|
160
|
+
*
|
|
161
|
+
* function EvDoIt( e: EvDoIt ) : EvDoIt {
|
|
162
|
+
* return BasicEvent<EvDoIt>( e );
|
|
163
|
+
* }
|
|
164
|
+
*
|
|
165
|
+
* interface TestEventMap extends EventMap {
|
|
166
|
+
* doit: EvDoIt;
|
|
167
|
+
* }
|
|
168
|
+
*
|
|
169
|
+
* let ee = new EventSource<TestEventMap>(null);
|
|
170
|
+
* ee.listen({
|
|
171
|
+
* doit: (e) => {
|
|
172
|
+
* console.log(e);
|
|
173
|
+
* e.preventDefault();
|
|
174
|
+
* },
|
|
175
|
+
* });
|
|
176
|
+
*
|
|
177
|
+
* ee.defaults({
|
|
178
|
+
* doit: (e) => {
|
|
179
|
+
* console.log('default handler for ', e.type, e.selection);
|
|
180
|
+
* },
|
|
181
|
+
* })
|
|
182
|
+
*
|
|
183
|
+
* ee.on('doit', (e) => {
|
|
184
|
+
* debugger;
|
|
185
|
+
* })
|
|
186
|
+
*
|
|
187
|
+
* const ev = EvDoIt({ param: 10 });
|
|
188
|
+
* ee.emit('change', ev);
|
|
189
|
+
* if (ev.defaultPrevented) {
|
|
190
|
+
* console.log('prevented');
|
|
191
|
+
* }
|
|
192
|
+
* ```
|
|
193
|
+
*/
|
|
194
|
+
export declare class EventSource<Q extends EventMap, T extends EventTypes = MapEvents<Q>> {
|
|
195
|
+
private m_source;
|
|
196
|
+
private m_eventRegistry;
|
|
197
|
+
private m_defaultHandlers;
|
|
198
|
+
constructor(source?: unknown);
|
|
199
|
+
/**
|
|
200
|
+
* emit an event
|
|
201
|
+
* you can stop propagation of event or prevent default
|
|
202
|
+
* @param eventName - name of event to emit
|
|
203
|
+
* @param event - event data
|
|
204
|
+
*/
|
|
205
|
+
emit<K extends keyof Q>(type: K, event?: Q[K]): void;
|
|
206
|
+
_emit(eventName: string, e: BasicEvent): void;
|
|
207
|
+
/**
|
|
208
|
+
* signal en event
|
|
209
|
+
* signaled event are notification : no way to prevent default not stop propagation
|
|
210
|
+
* @param eventName name of event to signal
|
|
211
|
+
* @param event event data
|
|
212
|
+
*/
|
|
213
|
+
signal<K extends keyof Q>(type: K, event: Q[K], delay?: number): void;
|
|
214
|
+
_signal(eventName: string, e: BasicEvent, delay?: number): void;
|
|
215
|
+
/**
|
|
216
|
+
* handle an event one time
|
|
217
|
+
* @param eventName - event name to handle
|
|
218
|
+
* @param callback - callback to call when event is signaled
|
|
219
|
+
* @returns Promise if callback is null
|
|
220
|
+
*
|
|
221
|
+
* take care with that because if the event is never fired and you await it,
|
|
222
|
+
* the system may overflow
|
|
223
|
+
*/
|
|
224
|
+
once<K extends keyof Q>(type: K, callback: (ev: Q[K]) => any): void;
|
|
225
|
+
_once(eventName: string, callback: EventCallback): Promise<unknown>;
|
|
226
|
+
/**
|
|
227
|
+
* set the event default handler
|
|
228
|
+
* @param eventName - name of the event
|
|
229
|
+
* @param callback - callback to call when the event is not handled (and preventDeault has not been called)
|
|
230
|
+
*/
|
|
231
|
+
setDefaultHandler(eventName: string, callback: EventCallback): void;
|
|
232
|
+
/**
|
|
233
|
+
* remove the previous default handler installed for an event
|
|
234
|
+
* @param eventName - event name
|
|
235
|
+
* @param callback - callback handler to remove (must be the same as in setDefaultHandler)
|
|
236
|
+
*/
|
|
237
|
+
removeDefaultHandler(eventName: string, callback: EventCallback): void;
|
|
238
|
+
/**
|
|
239
|
+
* define a set of listeners in one call
|
|
240
|
+
* @param events
|
|
241
|
+
*/
|
|
242
|
+
listen(events: T): void;
|
|
243
|
+
/**
|
|
244
|
+
* define a set of default handlers in one call
|
|
245
|
+
* @param events
|
|
246
|
+
*/
|
|
247
|
+
defaults(events: T): void;
|
|
248
|
+
/**
|
|
249
|
+
* listen for an event
|
|
250
|
+
* @param eventName - event name to listen on
|
|
251
|
+
* @param callback - callback to call
|
|
252
|
+
* @param capturing - if true, capture event before other registred event handlers
|
|
253
|
+
*/
|
|
254
|
+
on<K extends keyof Q>(type: K, callback: (ev: Q[K]) => any): EventDisposer;
|
|
255
|
+
_on(eventName: string, callback: EventCallback, capturing?: boolean): EventDisposer;
|
|
256
|
+
/**
|
|
257
|
+
* stop listening to an event
|
|
258
|
+
* @param eventName - event name
|
|
259
|
+
* @param callback - callback to remove (must be the same as in on )
|
|
260
|
+
*/
|
|
261
|
+
off<K extends keyof Q>(type: K, callback: (ev: Q[K]) => any): void;
|
|
262
|
+
_off(eventName: string, callback: EventCallback): void;
|
|
263
|
+
/**
|
|
264
|
+
* remove all listeners for an event
|
|
265
|
+
* @param eventName - event name
|
|
266
|
+
*/
|
|
267
|
+
removeAllListeners(eventName: string | null): void;
|
|
268
|
+
}
|
|
269
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ___ ___ __
|
|
3
|
+
* \ \_/ / / _
|
|
4
|
+
* \ / /_| |_
|
|
5
|
+
* / _ \____ _|
|
|
6
|
+
* /__/ \__\ |_|
|
|
7
|
+
*
|
|
8
|
+
* @file x4react.ts
|
|
9
|
+
* @author Etienne Cochard
|
|
10
|
+
*
|
|
11
|
+
* Copyright (c) 2019-2022 R-libre ingenierie
|
|
12
|
+
*
|
|
13
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
14
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
15
|
+
* in the Software without restriction, including without limitation the rights
|
|
16
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
17
|
+
* of the Software, and to permit persons to whom the Software is furnished to do so,
|
|
18
|
+
* subject to the following conditions:
|
|
19
|
+
* The above copyright notice and this permission notice shall be included in all copies
|
|
20
|
+
* or substantial portions of the Software.
|
|
21
|
+
*
|
|
22
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
23
|
+
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
|
24
|
+
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
25
|
+
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
26
|
+
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
27
|
+
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
28
|
+
**/
|
|
29
|
+
import { Component, ComponentContent, CProps, CEventMap } from './component';
|
|
30
|
+
export declare let React: {
|
|
31
|
+
createElement: (clsOrTag: any, attrs: any, ...children: any[]) => ComponentContent;
|
|
32
|
+
createFragment: () => ComponentContent;
|
|
33
|
+
Fragment: symbol;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
*
|
|
37
|
+
*/
|
|
38
|
+
export declare abstract class TSXComponent<P extends CProps<CEventMap> = CProps<CEventMap>, E extends CEventMap = CEventMap> extends Component<P, E> {
|
|
39
|
+
render(props: P): void;
|
|
40
|
+
abstract renderTSX(props: P): Component | Component[];
|
|
41
|
+
}
|