x4js 1.5.17 → 1.5.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/{README.md → README.txt} +0 -0
- package/lib/cjs/index.js +39 -103
- package/lib/cjs/index.js.map +7 -0
- package/lib/esm/index.mjs +39 -87
- package/lib/esm/index.mjs.map +7 -0
- package/lib/{license.md → licence.md} +0 -0
- package/lib/src/MIT-license.md +14 -0
- package/lib/{types/action.d.ts → src/action.ts} +64 -33
- package/lib/src/alpha.jpg +0 -0
- package/lib/src/app_sockets.ts +81 -0
- package/lib/src/application.ts +251 -0
- package/lib/src/autocomplete.ts +197 -0
- package/lib/src/base64.ts +166 -0
- package/lib/src/base_component.ts +152 -0
- package/lib/src/button.ts +355 -0
- package/lib/src/calendar.ts +328 -0
- package/lib/src/canvas.ts +505 -0
- package/lib/src/cardview.ts +227 -0
- package/lib/src/checkbox.ts +188 -0
- package/lib/src/color.ts +752 -0
- package/lib/src/colorpicker.ts +1639 -0
- package/lib/src/combobox.ts +465 -0
- package/lib/src/component.ts +2329 -0
- package/lib/{esm/dom_events.js → src/copyright.txt} +27 -29
- package/lib/src/datastore.ts +1322 -0
- package/lib/src/dialog.ts +656 -0
- package/lib/src/dom_events.ts +315 -0
- package/lib/src/drag_manager.ts +199 -0
- package/lib/src/drawtext.ts +355 -0
- package/lib/src/fileupload.ts +213 -0
- package/lib/src/form.ts +375 -0
- package/lib/src/formatters.ts +105 -0
- package/lib/src/gridview.ts +1185 -0
- package/lib/src/i18n.ts +346 -0
- package/lib/src/icon.ts +335 -0
- package/lib/src/image.ts +204 -0
- package/lib/src/index.ts +89 -0
- package/lib/src/input.ts +249 -0
- package/lib/src/label.ts +128 -0
- package/lib/src/layout.ts +430 -0
- package/lib/src/link.ts +86 -0
- package/lib/src/listview.ts +765 -0
- package/lib/{esm/md5.js → src/md5.ts} +438 -403
- package/lib/src/menu.ts +425 -0
- package/lib/src/messagebox.ts +224 -0
- package/lib/src/panel.ts +86 -0
- package/lib/src/popup.ts +494 -0
- package/lib/src/property_editor.ts +337 -0
- package/lib/src/radiobtn.ts +197 -0
- package/lib/src/rating.ts +135 -0
- package/lib/src/request.ts +300 -0
- package/lib/src/router.ts +185 -0
- package/lib/src/settings.ts +77 -0
- package/lib/src/sidebarview.ts +103 -0
- package/lib/src/spreadsheet.ts +1449 -0
- package/lib/src/styles.ts +343 -0
- package/lib/src/svgcomponent.ts +577 -0
- package/lib/src/tabbar.ts +151 -0
- package/lib/src/tabview.ts +110 -0
- package/lib/src/textarea.ts +235 -0
- package/lib/src/textedit.ts +544 -0
- package/lib/src/toaster.ts +80 -0
- package/lib/src/tools.ts +1473 -0
- package/lib/src/tooltips.ts +191 -0
- package/lib/src/treeview.ts +716 -0
- package/lib/{esm/version.js → src/version.ts} +30 -29
- package/lib/{styles → src}/x4.less +0 -0
- package/lib/src/x4dom.ts +57 -0
- package/lib/src/x4events.ts +585 -0
- package/lib/src/x4react.ts +90 -0
- package/package.json +52 -49
- package/lib/cjs/action.js +0 -58
- package/lib/cjs/app_sockets.js +0 -74
- package/lib/cjs/application.js +0 -182
- package/lib/cjs/autocomplete.js +0 -155
- package/lib/cjs/base_component.js +0 -124
- package/lib/cjs/button.js +0 -263
- package/lib/cjs/calendar.js +0 -254
- package/lib/cjs/canvas.js +0 -361
- package/lib/cjs/cardview.js +0 -161
- package/lib/cjs/checkbox.js +0 -139
- package/lib/cjs/color.js +0 -591
- package/lib/cjs/colorpicker.js +0 -1468
- package/lib/cjs/combobox.js +0 -349
- package/lib/cjs/component.js +0 -1719
- package/lib/cjs/datastore.js +0 -985
- package/lib/cjs/dialog.js +0 -478
- package/lib/cjs/dom_events.js +0 -30
- package/lib/cjs/drag_manager.js +0 -145
- package/lib/cjs/drawtext.js +0 -276
- package/lib/cjs/fileupload.js +0 -167
- package/lib/cjs/form.js +0 -304
- package/lib/cjs/formatters.js +0 -90
- package/lib/cjs/gridview.js +0 -881
- package/lib/cjs/i18n.js +0 -266
- package/lib/cjs/icon.js +0 -272
- package/lib/cjs/image.js +0 -157
- package/lib/cjs/input.js +0 -174
- package/lib/cjs/label.js +0 -95
- package/lib/cjs/layout.js +0 -322
- package/lib/cjs/link.js +0 -64
- package/lib/cjs/listview.js +0 -546
- package/lib/cjs/md5.js +0 -403
- package/lib/cjs/menu.js +0 -301
- package/lib/cjs/messagebox.js +0 -177
- package/lib/cjs/panel.js +0 -68
- package/lib/cjs/popup.js +0 -383
- package/lib/cjs/property_editor.js +0 -252
- package/lib/cjs/radiobtn.js +0 -140
- package/lib/cjs/rating.js +0 -102
- package/lib/cjs/request.js +0 -246
- package/lib/cjs/router.js +0 -139
- package/lib/cjs/settings.js +0 -69
- package/lib/cjs/sidebarview.js +0 -82
- package/lib/cjs/spreadsheet.js +0 -1084
- package/lib/cjs/styles.js +0 -275
- package/lib/cjs/svgcomponent.js +0 -447
- package/lib/cjs/tabbar.js +0 -111
- package/lib/cjs/tabview.js +0 -85
- package/lib/cjs/textarea.js +0 -165
- package/lib/cjs/textedit.js +0 -415
- package/lib/cjs/toaster.js +0 -64
- package/lib/cjs/tools.js +0 -1197
- package/lib/cjs/tooltips.js +0 -157
- package/lib/cjs/treeview.js +0 -535
- package/lib/cjs/version.js +0 -32
- package/lib/cjs/x4dom.js +0 -32
- package/lib/cjs/x4events.js +0 -384
- package/lib/cjs/x4react.js +0 -72
- package/lib/esm/action.js +0 -53
- package/lib/esm/app_sockets.js +0 -70
- package/lib/esm/application.js +0 -184
- package/lib/esm/autocomplete.js +0 -155
- package/lib/esm/base_component.js +0 -107
- package/lib/esm/button.js +0 -257
- package/lib/esm/calendar.js +0 -249
- package/lib/esm/canvas.js +0 -358
- package/lib/esm/cardview.js +0 -159
- package/lib/esm/checkbox.js +0 -134
- package/lib/esm/color.js +0 -588
- package/lib/esm/colorpicker.js +0 -1475
- package/lib/esm/combobox.js +0 -351
- package/lib/esm/component.js +0 -1711
- package/lib/esm/datastore.js +0 -990
- package/lib/esm/dialog.js +0 -490
- package/lib/esm/drag_manager.js +0 -147
- package/lib/esm/drawtext.js +0 -271
- package/lib/esm/fileupload.js +0 -163
- package/lib/esm/form.js +0 -304
- package/lib/esm/formatters.js +0 -81
- package/lib/esm/gridview.js +0 -889
- package/lib/esm/i18n.js +0 -257
- package/lib/esm/icon.js +0 -261
- package/lib/esm/image.js +0 -154
- package/lib/esm/input.js +0 -182
- package/lib/esm/label.js +0 -90
- package/lib/esm/layout.js +0 -310
- package/lib/esm/link.js +0 -59
- package/lib/esm/listview.js +0 -534
- package/lib/esm/menu.js +0 -300
- package/lib/esm/messagebox.js +0 -161
- package/lib/esm/panel.js +0 -65
- package/lib/esm/popup.js +0 -379
- package/lib/esm/property_editor.js +0 -251
- package/lib/esm/radiobtn.js +0 -136
- package/lib/esm/rating.js +0 -97
- package/lib/esm/request.js +0 -224
- package/lib/esm/router.js +0 -136
- package/lib/esm/settings.js +0 -66
- package/lib/esm/sidebarview.js +0 -79
- package/lib/esm/spreadsheet.js +0 -1097
- package/lib/esm/styles.js +0 -270
- package/lib/esm/svgcomponent.js +0 -450
- package/lib/esm/tabbar.js +0 -107
- package/lib/esm/tabview.js +0 -83
- package/lib/esm/textarea.js +0 -160
- package/lib/esm/textedit.js +0 -412
- package/lib/esm/toaster.js +0 -62
- package/lib/esm/tools.js +0 -1158
- package/lib/esm/tooltips.js +0 -153
- package/lib/esm/treeview.js +0 -527
- package/lib/esm/x4dom.js +0 -29
- package/lib/esm/x4events.js +0 -376
- package/lib/esm/x4react.js +0 -71
- package/lib/types/app_sockets.d.ts +0 -29
- package/lib/types/application.d.ts +0 -104
- package/lib/types/autocomplete.d.ts +0 -58
- package/lib/types/base_component.d.ts +0 -88
- package/lib/types/button.d.ts +0 -151
- package/lib/types/calendar.d.ts +0 -82
- package/lib/types/canvas.d.ts +0 -92
- package/lib/types/cardview.d.ts +0 -87
- package/lib/types/checkbox.d.ts +0 -77
- package/lib/types/color.d.ts +0 -148
- package/lib/types/colorpicker.d.ts +0 -107
- package/lib/types/combobox.d.ts +0 -107
- package/lib/types/component.d.ts +0 -601
- package/lib/types/datastore.d.ts +0 -396
- package/lib/types/dialog.d.ts +0 -175
- package/lib/types/dom_events.d.ts +0 -302
- package/lib/types/drag_manager.d.ts +0 -54
- package/lib/types/drawtext.d.ts +0 -48
- package/lib/types/fileupload.d.ts +0 -64
- package/lib/types/form.d.ts +0 -133
- package/lib/types/formatters.d.ts +0 -35
- package/lib/types/gridview.d.ts +0 -175
- package/lib/types/i18n.d.ts +0 -73
- package/lib/types/icon.d.ts +0 -64
- package/lib/types/image.d.ts +0 -55
- package/lib/types/index.d.ts +0 -84
- package/lib/types/input.d.ts +0 -91
- package/lib/types/label.d.ts +0 -58
- package/lib/types/layout.d.ts +0 -87
- package/lib/types/link.d.ts +0 -50
- package/lib/types/listview.d.ts +0 -178
- package/lib/types/md5.d.ts +0 -61
- package/lib/types/menu.d.ts +0 -130
- package/lib/types/messagebox.d.ts +0 -69
- package/lib/types/panel.d.ts +0 -47
- package/lib/types/popup.d.ts +0 -75
- package/lib/types/property_editor.d.ts +0 -71
- package/lib/types/radiobtn.d.ts +0 -73
- package/lib/types/rating.d.ts +0 -53
- package/lib/types/request.d.ts +0 -52
- package/lib/types/router.d.ts +0 -42
- package/lib/types/settings.d.ts +0 -37
- package/lib/types/sidebarview.d.ts +0 -49
- package/lib/types/spreadsheet.d.ts +0 -222
- package/lib/types/styles.d.ts +0 -85
- package/lib/types/svgcomponent.d.ts +0 -215
- package/lib/types/tabbar.d.ts +0 -58
- package/lib/types/tabview.d.ts +0 -49
- package/lib/types/textarea.d.ts +0 -77
- package/lib/types/textedit.d.ts +0 -123
- package/lib/types/toaster.d.ts +0 -42
- package/lib/types/tools.d.ts +0 -394
- package/lib/types/tooltips.d.ts +0 -46
- package/lib/types/treeview.d.ts +0 -144
- package/lib/types/version.d.ts +0 -29
- package/lib/types/x4dom.d.ts +0 -49
- package/lib/types/x4events.d.ts +0 -269
- package/lib/types/x4react.d.ts +0 -41
package/lib/cjs/dialog.js
DELETED
|
@@ -1,478 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* ___ ___ __
|
|
4
|
-
* \ \/ / / _
|
|
5
|
-
* \ / /_| |_
|
|
6
|
-
* / \____ _|
|
|
7
|
-
* /__/\__\ |_|
|
|
8
|
-
*
|
|
9
|
-
* @file dialog.ts
|
|
10
|
-
* @author Etienne Cochard
|
|
11
|
-
*
|
|
12
|
-
* Copyright (c) 2019-2022 R-libre ingenierie
|
|
13
|
-
*
|
|
14
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
15
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
16
|
-
* in the Software without restriction, including without limitation the rights
|
|
17
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
18
|
-
* of the Software, and to permit persons to whom the Software is furnished to do so,
|
|
19
|
-
* subject to the following conditions:
|
|
20
|
-
* The above copyright notice and this permission notice shall be included in all copies
|
|
21
|
-
* or substantial portions of the Software.
|
|
22
|
-
*
|
|
23
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
24
|
-
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
|
25
|
-
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
26
|
-
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
27
|
-
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
28
|
-
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
29
|
-
**/
|
|
30
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
-
exports.Dialog = exports.EvBtnClick = void 0;
|
|
32
|
-
const x4dom_1 = require("./x4dom");
|
|
33
|
-
const popup_1 = require("./popup");
|
|
34
|
-
const icon_1 = require("./icon");
|
|
35
|
-
const layout_1 = require("./layout");
|
|
36
|
-
const label_1 = require("./label");
|
|
37
|
-
const form_1 = require("./form");
|
|
38
|
-
const component_1 = require("./component");
|
|
39
|
-
const x4events_1 = require("./x4events");
|
|
40
|
-
const tools_1 = require("./tools");
|
|
41
|
-
function EvBtnClick(button) {
|
|
42
|
-
return (0, x4events_1.BasicEvent)({ button });
|
|
43
|
-
}
|
|
44
|
-
exports.EvBtnClick = EvBtnClick;
|
|
45
|
-
/**
|
|
46
|
-
* Standard dialog class
|
|
47
|
-
*/
|
|
48
|
-
class Dialog extends popup_1.Popup {
|
|
49
|
-
constructor(props) {
|
|
50
|
-
var _a, _b, _c;
|
|
51
|
-
let content = props.content;
|
|
52
|
-
props.content = null;
|
|
53
|
-
let width = props.width;
|
|
54
|
-
let height = props.height;
|
|
55
|
-
props.width = undefined;
|
|
56
|
-
props.height = undefined;
|
|
57
|
-
super(props);
|
|
58
|
-
this.m_minFormSize = { width, height };
|
|
59
|
-
this.enableMask(true);
|
|
60
|
-
if (props.form) {
|
|
61
|
-
if (!(0, tools_1.isFunction)(props.form)) {
|
|
62
|
-
this.m_form = props.form;
|
|
63
|
-
this.m_form.on('btnClick', (e) => this._handleClick(e));
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
this.m_form_cb = props.form;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
this.m_form = new form_1.Form({
|
|
71
|
-
content,
|
|
72
|
-
buttons: props.buttons,
|
|
73
|
-
disableSuggestions: props.disableSuggestions,
|
|
74
|
-
btnClick: (e) => this._handleClick(e)
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
this.m_movable = props.movable;
|
|
78
|
-
this.m_auto_close = (_a = props.autoClose) !== null && _a !== void 0 ? _a : true;
|
|
79
|
-
this.m_icon = props.icon;
|
|
80
|
-
this.m_title = props.title;
|
|
81
|
-
this.m_buttons = (_b = props.buttons) !== null && _b !== void 0 ? _b : null;
|
|
82
|
-
this.m_closable = (_c = props.closable) !== null && _c !== void 0 ? _c : false;
|
|
83
|
-
this.m_last_down = 0;
|
|
84
|
-
this.on('size', (ev) => {
|
|
85
|
-
this.addClass('@resized');
|
|
86
|
-
this.m_form.setStyleValue('width', null);
|
|
87
|
-
this.m_form.setStyleValue('height', null);
|
|
88
|
-
});
|
|
89
|
-
this.m_maximized = false;
|
|
90
|
-
this.m_minimized = false;
|
|
91
|
-
this.m_maximizable = false;
|
|
92
|
-
this.m_minimizable = false;
|
|
93
|
-
if (props.maximizable !== undefined) {
|
|
94
|
-
this.m_maximizable = props.maximizable;
|
|
95
|
-
}
|
|
96
|
-
if (props.minimizable !== undefined) {
|
|
97
|
-
this.m_minimizable = props.minimizable;
|
|
98
|
-
}
|
|
99
|
-
if (props.maximized == true) {
|
|
100
|
-
this.m_maximizable = true;
|
|
101
|
-
}
|
|
102
|
-
if (props.btnClick) {
|
|
103
|
-
this.on('btnClick', props.btnClick);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
*
|
|
108
|
-
*/
|
|
109
|
-
componentCreated() {
|
|
110
|
-
super.componentCreated();
|
|
111
|
-
if (this.m_minFormSize.width) {
|
|
112
|
-
this.m_form.setStyle({
|
|
113
|
-
minWidth: this.m_minFormSize.width,
|
|
114
|
-
width: this.m_minFormSize.width
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
if (this.m_minFormSize.height) {
|
|
118
|
-
this.m_form.setStyle({
|
|
119
|
-
minHeight: this.m_minFormSize.height,
|
|
120
|
-
height: this.m_minFormSize.height
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
const rc = this.getBoundingRect();
|
|
124
|
-
this.setStyleValue('min-width', rc.width);
|
|
125
|
-
this.setStyleValue('min-height', rc.height);
|
|
126
|
-
this.setStyleValue('width', rc.width);
|
|
127
|
-
this.setStyleValue('height', rc.height);
|
|
128
|
-
if (this.m_props.dlgWidth) {
|
|
129
|
-
this.setStyleValue('width', this.m_props.dlgWidth + '%');
|
|
130
|
-
}
|
|
131
|
-
if (this.m_props.dlgHeight) {
|
|
132
|
-
this.setStyleValue('height', this.m_props.dlgHeight + '%');
|
|
133
|
-
}
|
|
134
|
-
this.addClass('@resized');
|
|
135
|
-
if (this.m_el_title) {
|
|
136
|
-
this.m_el_title.setStyleValue("width", "auto");
|
|
137
|
-
}
|
|
138
|
-
if (this.m_props.maximized) {
|
|
139
|
-
this._maximize();
|
|
140
|
-
this.emit('size', (0, component_1.EvSize)(null));
|
|
141
|
-
}
|
|
142
|
-
else {
|
|
143
|
-
this.centerOnScreen();
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
*
|
|
148
|
-
*/
|
|
149
|
-
_handleClick(ev) {
|
|
150
|
-
this.emit('btnClick', ev);
|
|
151
|
-
if (!ev.defaultPrevented) {
|
|
152
|
-
this.close();
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* restore the geometry
|
|
157
|
-
*/
|
|
158
|
-
setGeometry(geom) {
|
|
159
|
-
if (geom.minimized && this.m_minimizable) {
|
|
160
|
-
this._minimize(false);
|
|
161
|
-
this.m_rc_min = new tools_1.Rect(geom.left, geom.top, geom.width, geom.height);
|
|
162
|
-
this.displayAt(geom.left, geom.top, 'top-left');
|
|
163
|
-
}
|
|
164
|
-
else if (geom.maximized && this.m_maximizable) {
|
|
165
|
-
this._maximize(false);
|
|
166
|
-
this.m_rc_max = new tools_1.Rect(geom.left, geom.top, geom.width, geom.height);
|
|
167
|
-
}
|
|
168
|
-
else {
|
|
169
|
-
this.setSize(geom.width, geom.height);
|
|
170
|
-
this.displayAt(geom.left, geom.top, 'top-left');
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* return the geometry (usefull to save state)
|
|
175
|
-
*/
|
|
176
|
-
getGeometry() {
|
|
177
|
-
if (this.m_minimized) {
|
|
178
|
-
return {
|
|
179
|
-
left: this.m_rc_min.left,
|
|
180
|
-
top: this.m_rc_min.top,
|
|
181
|
-
width: this.m_rc_min.width,
|
|
182
|
-
height: this.m_rc_min.height,
|
|
183
|
-
minimized: true,
|
|
184
|
-
maximized: false
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
else if (this.m_maximized) {
|
|
188
|
-
return {
|
|
189
|
-
left: this.m_rc_max.left,
|
|
190
|
-
top: this.m_rc_max.top,
|
|
191
|
-
width: this.m_rc_max.width,
|
|
192
|
-
height: this.m_rc_max.height,
|
|
193
|
-
minimized: false,
|
|
194
|
-
maximized: true
|
|
195
|
-
};
|
|
196
|
-
}
|
|
197
|
-
let rc = this.getBoundingRect();
|
|
198
|
-
return {
|
|
199
|
-
left: rc.left,
|
|
200
|
-
top: rc.top,
|
|
201
|
-
width: rc.width,
|
|
202
|
-
height: rc.height,
|
|
203
|
-
minimized: false,
|
|
204
|
-
maximized: false
|
|
205
|
-
};
|
|
206
|
-
}
|
|
207
|
-
/**
|
|
208
|
-
* resize the dialog
|
|
209
|
-
* @param width
|
|
210
|
-
* @param height
|
|
211
|
-
*/
|
|
212
|
-
setSize(width, height) {
|
|
213
|
-
this.setStyle({ width, height });
|
|
214
|
-
this.emit('size', (0, component_1.EvSize)({ width, height }));
|
|
215
|
-
}
|
|
216
|
-
/** @ignore */
|
|
217
|
-
render() {
|
|
218
|
-
if (this.m_form_cb) {
|
|
219
|
-
this.m_form = this.m_form_cb();
|
|
220
|
-
this.m_form.on('btnClick', (e) => this._handleClick(e));
|
|
221
|
-
this.m_form_cb = null;
|
|
222
|
-
}
|
|
223
|
-
let hasTitle = this.m_icon !== undefined || this.m_closable || this.m_title !== undefined || this.m_movable;
|
|
224
|
-
this.m_el_title = null;
|
|
225
|
-
if (hasTitle) {
|
|
226
|
-
this.m_el_title = new layout_1.HLayout({
|
|
227
|
-
cls: 'title',
|
|
228
|
-
content: [
|
|
229
|
-
this.m_icon ? new icon_1.Icon({ icon: this.m_icon }) : null,
|
|
230
|
-
this.m_ui_title = new label_1.Label({ flex: 1, text: this.m_title }),
|
|
231
|
-
this.m_minimizable ? new icon_1.Icon({ cls: 'min-btn', icon: 'var( --x4-icon-window-minimize )', dom_events: { click: () => this._toggleMin() } }) : null,
|
|
232
|
-
this.m_maximizable ? new icon_1.Icon({ cls: 'max-btn', icon: 'var( --x4-icon-window-maximize )', dom_events: { click: () => this._toggleMax() } }) : null,
|
|
233
|
-
this.m_maximizable ? new icon_1.Icon({ cls: 'res-btn', icon: 'var( --x4-icon-window-restore )', dom_events: { click: () => this._toggleMax() } }) : null,
|
|
234
|
-
this.m_closable ? new icon_1.Icon({ cls: 'close-btn', icon: 'var( --x4-icon-rectangle-times )', dom_events: { click: () => this.close() } }) : null,
|
|
235
|
-
]
|
|
236
|
-
});
|
|
237
|
-
if (this.m_movable) {
|
|
238
|
-
if ((0, tools_1.isTouchDevice)()) {
|
|
239
|
-
this.m_el_title.setDomEvent('touchstart', (e) => this._mouseDown(e));
|
|
240
|
-
}
|
|
241
|
-
else {
|
|
242
|
-
this.m_el_title.setDomEvent('mousedown', (e) => this._mouseDown(e));
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
super.setContent([
|
|
247
|
-
this.m_el_title,
|
|
248
|
-
this.m_form
|
|
249
|
-
]);
|
|
250
|
-
}
|
|
251
|
-
/**
|
|
252
|
-
* change the dialog content
|
|
253
|
-
* @param els
|
|
254
|
-
* @param refreshAll
|
|
255
|
-
*/
|
|
256
|
-
setContent(els, refreshAll = true) {
|
|
257
|
-
this.m_form.setContent(els, refreshAll);
|
|
258
|
-
}
|
|
259
|
-
/**
|
|
260
|
-
* change the dialog buttons
|
|
261
|
-
* @param buttons
|
|
262
|
-
*/
|
|
263
|
-
setButtons(buttons) {
|
|
264
|
-
this.m_form.setButtons(buttons);
|
|
265
|
-
}
|
|
266
|
-
/**
|
|
267
|
-
* return the dialog form
|
|
268
|
-
*/
|
|
269
|
-
get form() {
|
|
270
|
-
return this.m_form;
|
|
271
|
-
}
|
|
272
|
-
/**
|
|
273
|
-
* close the dialog
|
|
274
|
-
*/
|
|
275
|
-
close() {
|
|
276
|
-
this.emit('close', {});
|
|
277
|
-
super.close();
|
|
278
|
-
}
|
|
279
|
-
/**
|
|
280
|
-
*
|
|
281
|
-
*/
|
|
282
|
-
_toggleMax() {
|
|
283
|
-
if (!this.m_maximizable) {
|
|
284
|
-
return;
|
|
285
|
-
}
|
|
286
|
-
if (this.m_maximized) {
|
|
287
|
-
this.removeClass('maximized');
|
|
288
|
-
this.setStyle({
|
|
289
|
-
left: this.m_rc_max.left,
|
|
290
|
-
top: this.m_rc_max.top,
|
|
291
|
-
width: this.m_rc_max.width,
|
|
292
|
-
height: this.m_rc_max.height,
|
|
293
|
-
});
|
|
294
|
-
this.m_maximized = false;
|
|
295
|
-
this.emit('size', (0, component_1.EvSize)(null, 'restore'));
|
|
296
|
-
}
|
|
297
|
-
else {
|
|
298
|
-
this._maximize();
|
|
299
|
-
this.emit('size', (0, component_1.EvSize)(null, 'maximize'));
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
/**
|
|
303
|
-
*
|
|
304
|
-
*/
|
|
305
|
-
_toggleMin() {
|
|
306
|
-
if (!this.m_minimizable) {
|
|
307
|
-
return;
|
|
308
|
-
}
|
|
309
|
-
if (this.m_minimized) {
|
|
310
|
-
this.removeClass('minimized');
|
|
311
|
-
this.setStyle({
|
|
312
|
-
//left: this.m_rc_min.left,
|
|
313
|
-
//top: this.m_rc_min.top,
|
|
314
|
-
width: this.m_rc_min.width,
|
|
315
|
-
height: this.m_rc_min.height,
|
|
316
|
-
});
|
|
317
|
-
this.m_minimized = false;
|
|
318
|
-
this.emit('size', (0, component_1.EvSize)(null, 'restore'));
|
|
319
|
-
}
|
|
320
|
-
else {
|
|
321
|
-
this._minimize();
|
|
322
|
-
this.emit('size', (0, component_1.EvSize)(null, 'minimize'));
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
/**
|
|
326
|
-
*
|
|
327
|
-
*/
|
|
328
|
-
_mouseDown(event) {
|
|
329
|
-
let { x, y } = (0, tools_1.getMousePos)(event, true);
|
|
330
|
-
let wrc = (0, component_1.flyWrap)(x4dom_1.x4document.body).getBoundingRect();
|
|
331
|
-
let rc = this.getBoundingRect(true);
|
|
332
|
-
///let trc = this.m_el_title.getBoundingRect();
|
|
333
|
-
let dx = x - rc.left, dy = y - rc.top;
|
|
334
|
-
//let cstyle = this.getComputedStyle();
|
|
335
|
-
//let topw = cstyle.parse('marginTop') + cstyle.parse('paddingTop') + cstyle.parse('borderTopWidth');
|
|
336
|
-
//let botw = cstyle.parse('marginBottom') + cstyle.parse('paddingBottom') + cstyle.parse('borderBottomWidth');
|
|
337
|
-
//let lftw = cstyle.parse('marginLeft') + cstyle.parse('paddingLeft') + cstyle.parse('borderLeftWidth');
|
|
338
|
-
//let rgtw = cstyle.parse('marginRight') + cstyle.parse('paddingRight') + cstyle.parse('borderRightWidth');
|
|
339
|
-
//wrc.top += topw - trc.height;
|
|
340
|
-
//wrc.height -= topw + botw - trc.height;
|
|
341
|
-
//wrc.left += lftw;
|
|
342
|
-
//wrc.width -= lftw + rgtw;
|
|
343
|
-
// custom handling double click
|
|
344
|
-
const now = Date.now();
|
|
345
|
-
const delta = now - this.m_last_down;
|
|
346
|
-
if (this.m_maximizable && delta < 700) {
|
|
347
|
-
this._toggleMax();
|
|
348
|
-
return;
|
|
349
|
-
}
|
|
350
|
-
this.m_last_down = now;
|
|
351
|
-
if (this.m_maximized) {
|
|
352
|
-
// cannot move in max state
|
|
353
|
-
return;
|
|
354
|
-
}
|
|
355
|
-
let __move = (ex, ey) => {
|
|
356
|
-
if (ex > wrc.right) {
|
|
357
|
-
ex = wrc.right;
|
|
358
|
-
}
|
|
359
|
-
else if (ex < wrc.left) {
|
|
360
|
-
ex = wrc.left;
|
|
361
|
-
}
|
|
362
|
-
if (ey > wrc.bottom) {
|
|
363
|
-
ey = wrc.bottom;
|
|
364
|
-
}
|
|
365
|
-
else if (ey < wrc.top) {
|
|
366
|
-
ey = wrc.top;
|
|
367
|
-
}
|
|
368
|
-
let x = ex - dx, y = ey - dy;
|
|
369
|
-
//if (x + rc.width < wrc.left) {
|
|
370
|
-
// x = wrc.left - rc.width;
|
|
371
|
-
//}
|
|
372
|
-
//else if (x > wrc.right) {
|
|
373
|
-
// x = wrc.right;
|
|
374
|
-
//}
|
|
375
|
-
//
|
|
376
|
-
//if (y < wrc.top) { // title grip is on top
|
|
377
|
-
// y = wrc.top;
|
|
378
|
-
//}
|
|
379
|
-
//else if (y > wrc.bottom) {
|
|
380
|
-
// y = wrc.bottom;
|
|
381
|
-
//}
|
|
382
|
-
this.setStyle({
|
|
383
|
-
left: x,
|
|
384
|
-
top: y
|
|
385
|
-
});
|
|
386
|
-
};
|
|
387
|
-
component_1.Component.setCapture(this, (ev) => {
|
|
388
|
-
if (ev.type == 'mousemove') {
|
|
389
|
-
let mev = ev;
|
|
390
|
-
__move(mev.clientX, mev.clientY);
|
|
391
|
-
}
|
|
392
|
-
else if (ev.type == 'touchmove') {
|
|
393
|
-
let tev = ev;
|
|
394
|
-
if (tev.touches.length == 1) {
|
|
395
|
-
__move(tev.touches[0].clientX, tev.touches[0].clientY);
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
else if (ev.type == 'mouseup' || ev.type == 'touchend') {
|
|
399
|
-
component_1.Component.releaseCapture();
|
|
400
|
-
this.emit('move', (0, popup_1.EvMove)(null));
|
|
401
|
-
}
|
|
402
|
-
else if (ev.type == 'mousedown' || ev.type == 'touchstart') {
|
|
403
|
-
}
|
|
404
|
-
});
|
|
405
|
-
}
|
|
406
|
-
/**
|
|
407
|
-
* maximize the dialog
|
|
408
|
-
*/
|
|
409
|
-
maximize() {
|
|
410
|
-
if (!this.m_maximizable || this.m_maximized) {
|
|
411
|
-
return;
|
|
412
|
-
}
|
|
413
|
-
this._maximize();
|
|
414
|
-
this.emit('size', (0, component_1.EvSize)(null));
|
|
415
|
-
}
|
|
416
|
-
/**
|
|
417
|
-
*
|
|
418
|
-
*/
|
|
419
|
-
_maximize(saveRect = true) {
|
|
420
|
-
if (saveRect) {
|
|
421
|
-
this.m_rc_max = this.getBoundingRect(false);
|
|
422
|
-
}
|
|
423
|
-
this.addClass('maximized');
|
|
424
|
-
this.m_maximized = true;
|
|
425
|
-
this.setStyle({
|
|
426
|
-
left: undefined,
|
|
427
|
-
top: undefined,
|
|
428
|
-
width: undefined,
|
|
429
|
-
height: undefined,
|
|
430
|
-
});
|
|
431
|
-
}
|
|
432
|
-
/**
|
|
433
|
-
* minimize the dialog
|
|
434
|
-
*/
|
|
435
|
-
minimize() {
|
|
436
|
-
if (!this.m_minimizable || this.m_minimized) {
|
|
437
|
-
return;
|
|
438
|
-
}
|
|
439
|
-
this._minimize();
|
|
440
|
-
this.emit('size', (0, component_1.EvSize)(null));
|
|
441
|
-
}
|
|
442
|
-
/**
|
|
443
|
-
*
|
|
444
|
-
*/
|
|
445
|
-
_minimize(saveRect = true) {
|
|
446
|
-
if (saveRect) {
|
|
447
|
-
this.m_rc_min = this.getBoundingRect(false);
|
|
448
|
-
}
|
|
449
|
-
this.addClass('minimized');
|
|
450
|
-
this.m_minimized = true;
|
|
451
|
-
this.setStyle({
|
|
452
|
-
//left: undefined,
|
|
453
|
-
//top: undefined,
|
|
454
|
-
width: undefined,
|
|
455
|
-
height: undefined,
|
|
456
|
-
});
|
|
457
|
-
}
|
|
458
|
-
/**
|
|
459
|
-
* change the dialog title
|
|
460
|
-
*/
|
|
461
|
-
set title(title) {
|
|
462
|
-
this.m_title = title;
|
|
463
|
-
if (this.m_ui_title) {
|
|
464
|
-
this.m_ui_title.text = title;
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
itemWithName(name) {
|
|
468
|
-
let result = this.dom.querySelector(`[name="${name}"]`);
|
|
469
|
-
return result ? component_1.Component.getElement(result) : null;
|
|
470
|
-
}
|
|
471
|
-
getValues() {
|
|
472
|
-
return this.m_form.getValues();
|
|
473
|
-
}
|
|
474
|
-
validate() {
|
|
475
|
-
return this.m_form.validate();
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
exports.Dialog = Dialog;
|
package/lib/cjs/dom_events.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* ___ ___ __
|
|
4
|
-
* \ \/ / / _
|
|
5
|
-
* \ / /_| |_
|
|
6
|
-
* / \____ _|
|
|
7
|
-
* /__/\__\ |_|
|
|
8
|
-
*
|
|
9
|
-
* @file dom_events.ts
|
|
10
|
-
* @author Etienne Cochard
|
|
11
|
-
*
|
|
12
|
-
* Copyright (c) 2019-2022 R-libre ingenierie
|
|
13
|
-
*
|
|
14
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
15
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
16
|
-
* in the Software without restriction, including without limitation the rights
|
|
17
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
18
|
-
* of the Software, and to permit persons to whom the Software is furnished to do so,
|
|
19
|
-
* subject to the following conditions:
|
|
20
|
-
* The above copyright notice and this permission notice shall be included in all copies
|
|
21
|
-
* or substantial portions of the Software.
|
|
22
|
-
*
|
|
23
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
24
|
-
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
|
25
|
-
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
26
|
-
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
27
|
-
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
28
|
-
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
29
|
-
**/
|
|
30
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
package/lib/cjs/drag_manager.js
DELETED
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* ___ ___ __
|
|
4
|
-
* \ \_/ / / _
|
|
5
|
-
* \ / /_| |_
|
|
6
|
-
* / _ \____ _|
|
|
7
|
-
* /__/ \__\ |_|
|
|
8
|
-
*
|
|
9
|
-
* @file drag_manager.ts
|
|
10
|
-
* @author Etienne Cochard
|
|
11
|
-
*
|
|
12
|
-
* Copyright (c) 2019-2022 R-libre ingenierie
|
|
13
|
-
*
|
|
14
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
15
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
16
|
-
* in the Software without restriction, including without limitation the rights
|
|
17
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
18
|
-
* of the Software, and to permit persons to whom the Software is furnished to do so,
|
|
19
|
-
* subject to the following conditions:
|
|
20
|
-
* The above copyright notice and this permission notice shall be included in all copies
|
|
21
|
-
* or substantial portions of the Software.
|
|
22
|
-
*
|
|
23
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
24
|
-
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
|
25
|
-
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
26
|
-
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
27
|
-
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
28
|
-
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
29
|
-
**/
|
|
30
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
-
exports.dragManager = void 0;
|
|
32
|
-
const x4dom_1 = require("./x4dom");
|
|
33
|
-
const x_drag_cb = Symbol('x-drag-cb');
|
|
34
|
-
/**
|
|
35
|
-
*
|
|
36
|
-
*/
|
|
37
|
-
class DragManager {
|
|
38
|
-
/**
|
|
39
|
-
*
|
|
40
|
-
*/
|
|
41
|
-
registerDraggableElement(el) {
|
|
42
|
-
el.setDomEvent('dragstart', (ev) => {
|
|
43
|
-
this.dragSource = el;
|
|
44
|
-
this.dragGhost = el.dom.cloneNode(true);
|
|
45
|
-
this.dragGhost.classList.add('dragged');
|
|
46
|
-
x4dom_1.x4document.body.appendChild(this.dragGhost);
|
|
47
|
-
el.addClass('dragging');
|
|
48
|
-
ev.dataTransfer.setData('text/string', '1');
|
|
49
|
-
ev.dataTransfer.setDragImage(new Image(), 0, 0);
|
|
50
|
-
ev.stopPropagation();
|
|
51
|
-
});
|
|
52
|
-
el.setDomEvent('drag', (ev) => {
|
|
53
|
-
this.dragGhost.style.left = ev.pageX + "px";
|
|
54
|
-
this.dragGhost.style.top = ev.pageY + "px";
|
|
55
|
-
});
|
|
56
|
-
el.setDomEvent('dragend', (ev) => {
|
|
57
|
-
el.removeClass('dragging');
|
|
58
|
-
this.dragGhost.remove();
|
|
59
|
-
});
|
|
60
|
-
el.setAttribute('draggable', "true");
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
*
|
|
64
|
-
*/
|
|
65
|
-
registerDropTarget(el, cb, filterCB) {
|
|
66
|
-
const dragEnter = (ev) => {
|
|
67
|
-
if (!filterCB(this.dragSource)) {
|
|
68
|
-
console.log('reject ', el);
|
|
69
|
-
ev.dataTransfer.dropEffect = 'none';
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
console.log('accepted ', el);
|
|
73
|
-
ev.preventDefault();
|
|
74
|
-
ev.dataTransfer.dropEffect = 'copy';
|
|
75
|
-
};
|
|
76
|
-
const dragOver = (ev) => {
|
|
77
|
-
//console.log( "dragover", ev.target );
|
|
78
|
-
if (!filterCB(this.dragSource)) {
|
|
79
|
-
console.log('reject ', el);
|
|
80
|
-
ev.dataTransfer.dropEffect = 'none';
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
ev.preventDefault();
|
|
84
|
-
if (this.dropTarget != el) {
|
|
85
|
-
this.dropTarget = el;
|
|
86
|
-
this._startCheck();
|
|
87
|
-
}
|
|
88
|
-
if (this.dropTarget) {
|
|
89
|
-
cb('drag', this.dragSource, { x: ev.pageX, y: ev.pageY });
|
|
90
|
-
}
|
|
91
|
-
ev.dataTransfer.dropEffect = 'copy';
|
|
92
|
-
};
|
|
93
|
-
const dragLeave = (ev) => {
|
|
94
|
-
//console.log( "dragleave", ev.target );
|
|
95
|
-
this.dropTarget = null;
|
|
96
|
-
ev.preventDefault();
|
|
97
|
-
};
|
|
98
|
-
const drop = (ev) => {
|
|
99
|
-
cb('drop', this.dragSource, { x: ev.pageX, y: ev.pageY });
|
|
100
|
-
this.dropTarget = null;
|
|
101
|
-
el.removeClass('drop-over');
|
|
102
|
-
};
|
|
103
|
-
el.setDomEvent('dragenter', dragEnter);
|
|
104
|
-
el.setDomEvent('dragover', dragOver);
|
|
105
|
-
el.setDomEvent('dragleave', dragLeave);
|
|
106
|
-
el.setDomEvent('drop', drop);
|
|
107
|
-
el.setData(x_drag_cb, cb);
|
|
108
|
-
}
|
|
109
|
-
_startCheck() {
|
|
110
|
-
if (this.timer) {
|
|
111
|
-
clearInterval(this.timer);
|
|
112
|
-
this._check();
|
|
113
|
-
}
|
|
114
|
-
this.timer = setInterval(() => this._check(), 300);
|
|
115
|
-
}
|
|
116
|
-
_check() {
|
|
117
|
-
const leaving = (x) => {
|
|
118
|
-
x.removeClass('drop-over');
|
|
119
|
-
const cb = x.getData(x_drag_cb);
|
|
120
|
-
cb('leave', this.dragSource);
|
|
121
|
-
};
|
|
122
|
-
const entering = (x) => {
|
|
123
|
-
x.addClass('drop-over');
|
|
124
|
-
const cb = x.getData(x_drag_cb);
|
|
125
|
-
cb('enter', this.dragSource);
|
|
126
|
-
};
|
|
127
|
-
if (this.dropTarget) {
|
|
128
|
-
if (!this.notified || this.notified != this.dropTarget) {
|
|
129
|
-
if (this.notified) {
|
|
130
|
-
leaving(this.notified);
|
|
131
|
-
}
|
|
132
|
-
this.notified = this.dropTarget;
|
|
133
|
-
entering(this.notified);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
else {
|
|
137
|
-
if (this.notified) {
|
|
138
|
-
leaving(this.notified);
|
|
139
|
-
this.notified = null;
|
|
140
|
-
clearInterval(this.timer);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
exports.dragManager = new DragManager();
|