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
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* ___ ___ __
|
|
4
|
-
* \ \/ / / _
|
|
5
|
-
* \ / /_| |_
|
|
6
|
-
* / \____ _|
|
|
7
|
-
* /__/\__\ |_|
|
|
8
|
-
*
|
|
9
|
-
* @file base_component.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
|
-
**/
|
|
31
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
32
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
33
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
34
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
35
|
-
};
|
|
36
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
37
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
38
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
39
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
40
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
41
|
-
};
|
|
42
|
-
var _BaseComponent_m_timers;
|
|
43
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
|
-
exports.BaseComponent = void 0;
|
|
45
|
-
const x4events_1 = require("./x4events");
|
|
46
|
-
/**
|
|
47
|
-
* BaseComponent class
|
|
48
|
-
*/
|
|
49
|
-
class BaseComponent extends x4events_1.EventSource {
|
|
50
|
-
constructor(props) {
|
|
51
|
-
super();
|
|
52
|
-
_BaseComponent_m_timers.set(this, void 0);
|
|
53
|
-
//this.m_props = { ...props };
|
|
54
|
-
this.m_props = props;
|
|
55
|
-
if (props.events) {
|
|
56
|
-
this.listen(props.events);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* start a new timer
|
|
61
|
-
* @param name timer name
|
|
62
|
-
* @param timeout time out in ms
|
|
63
|
-
* @param repeat if true this is an auto repeat timer
|
|
64
|
-
* @param callback if !null, the callback to call else a EvTimer is fired
|
|
65
|
-
*/
|
|
66
|
-
startTimer(name, timeout, repeat = true, callback = null) {
|
|
67
|
-
if (!__classPrivateFieldGet(this, _BaseComponent_m_timers, "f")) {
|
|
68
|
-
__classPrivateFieldSet(this, _BaseComponent_m_timers, new Map(), "f");
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
this.stopTimer(name);
|
|
72
|
-
}
|
|
73
|
-
const id = (repeat ? setInterval : setTimeout)((tm) => {
|
|
74
|
-
if (callback) {
|
|
75
|
-
callback(name, tm);
|
|
76
|
-
}
|
|
77
|
-
else {
|
|
78
|
-
this.emit('timer', (0, x4events_1.EvTimer)(name, tm));
|
|
79
|
-
}
|
|
80
|
-
}, timeout);
|
|
81
|
-
__classPrivateFieldGet(this, _BaseComponent_m_timers, "f").set(name, () => { (repeat ? clearInterval : clearTimeout)(id); });
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* stop the given timer
|
|
85
|
-
* @param name
|
|
86
|
-
*/
|
|
87
|
-
stopTimer(name) {
|
|
88
|
-
const clear = __classPrivateFieldGet(this, _BaseComponent_m_timers, "f").get(name);
|
|
89
|
-
if (clear) {
|
|
90
|
-
clear();
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* stop all timers
|
|
95
|
-
*/
|
|
96
|
-
disposeTimers() {
|
|
97
|
-
var _a;
|
|
98
|
-
(_a = __classPrivateFieldGet(this, _BaseComponent_m_timers, "f")) === null || _a === void 0 ? void 0 : _a.forEach(v => v());
|
|
99
|
-
__classPrivateFieldSet(this, _BaseComponent_m_timers, undefined, "f");
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
*
|
|
103
|
-
* @param callback
|
|
104
|
-
* @param timeout
|
|
105
|
-
*/
|
|
106
|
-
singleShot(callback, timeout = 0) {
|
|
107
|
-
setTimeout(callback, timeout);
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
*
|
|
111
|
-
* @param props
|
|
112
|
-
* @param elements
|
|
113
|
-
*/
|
|
114
|
-
mapPropEvents(props, ...elements) {
|
|
115
|
-
elements.forEach(name => {
|
|
116
|
-
const n = name;
|
|
117
|
-
if (props[n]) {
|
|
118
|
-
this._on(n, props[n]);
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
exports.BaseComponent = BaseComponent;
|
|
124
|
-
_BaseComponent_m_timers = new WeakMap();
|
package/lib/cjs/button.js
DELETED
|
@@ -1,263 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* ___ ___ __
|
|
4
|
-
* \ \/ / / _
|
|
5
|
-
* \ / /_| |_
|
|
6
|
-
* / \____ _|
|
|
7
|
-
* /__/\__\ |_|
|
|
8
|
-
*
|
|
9
|
-
* @file button.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.ToggleButton = exports.Button = exports.BaseButton = void 0;
|
|
32
|
-
const component_1 = require("./component");
|
|
33
|
-
const x4events_1 = require("./x4events");
|
|
34
|
-
const icon_1 = require("./icon");
|
|
35
|
-
const label_1 = require("./label");
|
|
36
|
-
const menu_1 = require("./menu");
|
|
37
|
-
const tools_1 = require("./tools");
|
|
38
|
-
/**
|
|
39
|
-
* Base button
|
|
40
|
-
*/
|
|
41
|
-
class BaseButton extends component_1.Component {
|
|
42
|
-
constructor(props) {
|
|
43
|
-
super(props);
|
|
44
|
-
this.setTag('button');
|
|
45
|
-
this.setDomEvent('click', (e) => this._handleClick(e));
|
|
46
|
-
this.setDomEvent('mousedown', () => { this._startAutoRep(true); });
|
|
47
|
-
this.setDomEvent('mouseup', () => { this._startAutoRep(false); });
|
|
48
|
-
this.setDomEvent('keydown', (e) => this._handleKeyDown(e));
|
|
49
|
-
this.mapPropEvents(props, 'click');
|
|
50
|
-
}
|
|
51
|
-
render(props) {
|
|
52
|
-
const action = props.action;
|
|
53
|
-
let icon = props.icon;
|
|
54
|
-
let text = props.text;
|
|
55
|
-
if (action) {
|
|
56
|
-
if (!icon && action.props.icon) {
|
|
57
|
-
icon = action.props.icon;
|
|
58
|
-
}
|
|
59
|
-
if (text === undefined && action.props.text) {
|
|
60
|
-
text = action.props.text;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
const ui_icon = icon ? new icon_1.Icon({ icon, cls: 'left', ref: 'l_icon' }) : null;
|
|
64
|
-
const ui_label = new label_1.Label({ flex: 1, text: text !== null && text !== void 0 ? text : '', align: props.align, ref: 'label' });
|
|
65
|
-
const ui_ricon = props.rightIcon ? new icon_1.Icon({ icon: props.rightIcon, cls: 'right', ref: 'r_icon' }) : null;
|
|
66
|
-
if (text === undefined) {
|
|
67
|
-
ui_label.addClass("@hidden");
|
|
68
|
-
}
|
|
69
|
-
this.setContent([ui_icon, ui_label, ui_ricon]);
|
|
70
|
-
this._setTabIndex(props.tabIndex);
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* starts/stops the autorepeat
|
|
74
|
-
*/
|
|
75
|
-
_startAutoRep(start) {
|
|
76
|
-
if (!this.m_props.autoRepeat) {
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
if (start) {
|
|
80
|
-
// 1st timer 1s
|
|
81
|
-
this.startTimer('repeat', 700, false, () => {
|
|
82
|
-
// auto click
|
|
83
|
-
this.startTimer('repeat', this.m_props.autoRepeat, true, this._sendClick);
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
else {
|
|
87
|
-
this.stopTimer('repeat');
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
*
|
|
92
|
-
*/
|
|
93
|
-
_handleKeyDown(ev) {
|
|
94
|
-
if (!ev.ctrlKey && !ev.shiftKey && !ev.altKey) {
|
|
95
|
-
if (ev.key == 'Enter' || ev.key == ' ') {
|
|
96
|
-
this._sendClick();
|
|
97
|
-
ev.preventDefault();
|
|
98
|
-
ev.stopPropagation();
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* called by the system on click event
|
|
104
|
-
*/
|
|
105
|
-
_handleClick(ev) {
|
|
106
|
-
if (this.m_props.menu) {
|
|
107
|
-
let menu = new menu_1.Menu({
|
|
108
|
-
items: (0, tools_1.isFunction)(this.m_props.menu) ? this.m_props.menu() : this.m_props.menu
|
|
109
|
-
});
|
|
110
|
-
let rc = this.getBoundingRect();
|
|
111
|
-
menu.displayAt(rc.left, rc.bottom, 'tl');
|
|
112
|
-
}
|
|
113
|
-
else {
|
|
114
|
-
this._sendClick();
|
|
115
|
-
}
|
|
116
|
-
ev.preventDefault();
|
|
117
|
-
ev.stopPropagation();
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* sends a click to the observers
|
|
121
|
-
*/
|
|
122
|
-
_sendClick() {
|
|
123
|
-
if (this.m_props.menu) {
|
|
124
|
-
let menu = new menu_1.Menu({
|
|
125
|
-
items: (0, tools_1.isFunction)(this.m_props.menu) ? this.m_props.menu() : this.m_props.menu
|
|
126
|
-
});
|
|
127
|
-
let rc = this.getBoundingRect();
|
|
128
|
-
menu.displayAt(rc.left, rc.bottom, 'tl');
|
|
129
|
-
}
|
|
130
|
-
else {
|
|
131
|
-
this.emit('click', (0, x4events_1.EvClick)());
|
|
132
|
-
if (this.m_props.action) {
|
|
133
|
-
this.m_props.action.fire();
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* change the button text
|
|
139
|
-
* @example
|
|
140
|
-
* ```ts
|
|
141
|
-
* let btn = new Button( {
|
|
142
|
-
* text: 'hello'
|
|
143
|
-
* });
|
|
144
|
-
*
|
|
145
|
-
* btn.text = 'world';
|
|
146
|
-
* ```
|
|
147
|
-
*/
|
|
148
|
-
set text(text) {
|
|
149
|
-
this.m_props.text = text;
|
|
150
|
-
let label = this.itemWithRef('label');
|
|
151
|
-
if (label) {
|
|
152
|
-
label.text = text;
|
|
153
|
-
label.removeClass("@hidden");
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
get text() {
|
|
157
|
-
let label = this.itemWithRef('label');
|
|
158
|
-
return label === null || label === void 0 ? void 0 : label.text;
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* change the button icon
|
|
162
|
-
* todo: do nothing if no icon defined at startup
|
|
163
|
-
*
|
|
164
|
-
* @example
|
|
165
|
-
* ```ts
|
|
166
|
-
* let btn = new Button( {
|
|
167
|
-
* text: 'hello',
|
|
168
|
-
* icon: 'close'
|
|
169
|
-
* });
|
|
170
|
-
* btn.setIcon( 'open' );
|
|
171
|
-
* ```
|
|
172
|
-
*/
|
|
173
|
-
set icon(icon) {
|
|
174
|
-
this.m_props.icon = icon;
|
|
175
|
-
let ico = this.itemWithRef('l_icon');
|
|
176
|
-
if (ico) {
|
|
177
|
-
ico.icon = icon;
|
|
178
|
-
}
|
|
179
|
-
else {
|
|
180
|
-
this.update();
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
get icon() {
|
|
184
|
-
let ico = this.itemWithRef('l_icon');
|
|
185
|
-
return ico === null || ico === void 0 ? void 0 : ico.icon;
|
|
186
|
-
}
|
|
187
|
-
/**
|
|
188
|
-
* change the button right icon
|
|
189
|
-
* todo: do nothing if no icon defined at startup
|
|
190
|
-
*
|
|
191
|
-
* @example
|
|
192
|
-
* ```ts
|
|
193
|
-
* let btn = new Button( {
|
|
194
|
-
* text: 'hello',
|
|
195
|
-
* icon: 'close'
|
|
196
|
-
* });
|
|
197
|
-
* btn.setIcon( 'open' );
|
|
198
|
-
* ```
|
|
199
|
-
*/
|
|
200
|
-
set rightIcon(icon) {
|
|
201
|
-
this.m_props.rightIcon = icon;
|
|
202
|
-
let ico = this.itemWithRef('r_icon');
|
|
203
|
-
if (ico) {
|
|
204
|
-
ico.icon = icon;
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
get rightIcon() {
|
|
208
|
-
let ico = this.itemWithRef('l_icon');
|
|
209
|
-
return ico === null || ico === void 0 ? void 0 : ico.icon;
|
|
210
|
-
}
|
|
211
|
-
/**
|
|
212
|
-
*
|
|
213
|
-
*/
|
|
214
|
-
set menu(items) {
|
|
215
|
-
this.m_props.menu = items;
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
exports.BaseButton = BaseButton;
|
|
219
|
-
// :: BUTTON ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
|
220
|
-
/**
|
|
221
|
-
*
|
|
222
|
-
*/
|
|
223
|
-
class Button extends BaseButton {
|
|
224
|
-
}
|
|
225
|
-
exports.Button = Button;
|
|
226
|
-
/**
|
|
227
|
-
*
|
|
228
|
-
*/
|
|
229
|
-
class ToggleButton extends BaseButton {
|
|
230
|
-
constructor(props) {
|
|
231
|
-
super(props);
|
|
232
|
-
}
|
|
233
|
-
/**
|
|
234
|
-
*
|
|
235
|
-
*/
|
|
236
|
-
render(props) {
|
|
237
|
-
super.render(props);
|
|
238
|
-
if (props.checked) {
|
|
239
|
-
this.addClass('checked');
|
|
240
|
-
this._updateIcon();
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
/**
|
|
244
|
-
*
|
|
245
|
-
*/
|
|
246
|
-
_sendClick() {
|
|
247
|
-
super._sendClick();
|
|
248
|
-
this.m_props.checked = !this.m_props.checked;
|
|
249
|
-
this.setClass('checked', this.m_props.checked);
|
|
250
|
-
this.emit('change', (0, x4events_1.EvChange)(this.m_props.checked));
|
|
251
|
-
this._updateIcon();
|
|
252
|
-
}
|
|
253
|
-
_updateIcon() {
|
|
254
|
-
if (this.m_props.checkedIcon) {
|
|
255
|
-
const ic = this.m_props.checked ? this.m_props.checkedIcon : this.m_props.icon;
|
|
256
|
-
let ico = this.itemWithRef('l_icon');
|
|
257
|
-
if (ico) {
|
|
258
|
-
ico.icon = ic;
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
exports.ToggleButton = ToggleButton;
|
package/lib/cjs/calendar.js
DELETED
|
@@ -1,254 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* ___ ___ __
|
|
4
|
-
* \ \/ / / _
|
|
5
|
-
* \ / /_| |_
|
|
6
|
-
* / \____ _|
|
|
7
|
-
* /__/\__\ |_|
|
|
8
|
-
*
|
|
9
|
-
* @file calendar.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.PopupCalendar = exports.Calendar = void 0;
|
|
32
|
-
const x4dom_1 = require("./x4dom");
|
|
33
|
-
const button_1 = require("./button");
|
|
34
|
-
const popup_1 = require("./popup");
|
|
35
|
-
const component_1 = require("./component");
|
|
36
|
-
const x4events_1 = require("./x4events");
|
|
37
|
-
const i18n_1 = require("./i18n");
|
|
38
|
-
const label_1 = require("./label");
|
|
39
|
-
const layout_1 = require("./layout");
|
|
40
|
-
const tools_1 = require("./tools");
|
|
41
|
-
const menu_1 = require("./menu");
|
|
42
|
-
/**
|
|
43
|
-
* default calendar control
|
|
44
|
-
*
|
|
45
|
-
* fires:
|
|
46
|
-
* EventChange ( value = Date )
|
|
47
|
-
*/
|
|
48
|
-
class Calendar extends layout_1.VLayout {
|
|
49
|
-
constructor(props) {
|
|
50
|
-
var _a, _b;
|
|
51
|
-
super(props);
|
|
52
|
-
this.mapPropEvents(props, 'change');
|
|
53
|
-
this.m_date = (_b = (_a = props.date) === null || _a === void 0 ? void 0 : _a.clone()) !== null && _b !== void 0 ? _b : new Date();
|
|
54
|
-
}
|
|
55
|
-
/** @ignore */
|
|
56
|
-
render(props) {
|
|
57
|
-
let month_start = (0, tools_1.date_clone)(this.m_date);
|
|
58
|
-
month_start.setDate(1);
|
|
59
|
-
let day = month_start.getDay();
|
|
60
|
-
if (day == 0) {
|
|
61
|
-
day = 7;
|
|
62
|
-
}
|
|
63
|
-
month_start.setDate(-day + 1 + 1);
|
|
64
|
-
let dte = (0, tools_1.date_clone)(month_start);
|
|
65
|
-
let today = this.m_date.hash();
|
|
66
|
-
let month_end = (0, tools_1.date_clone)(this.m_date);
|
|
67
|
-
month_end.setDate(1);
|
|
68
|
-
month_end.setMonth(month_end.getMonth() + 1);
|
|
69
|
-
month_end.setDate(0);
|
|
70
|
-
let end_of_month = (0, tools_1.date_hash)(month_end);
|
|
71
|
-
let rows = [];
|
|
72
|
-
// month selector
|
|
73
|
-
let header = new layout_1.HLayout({
|
|
74
|
-
cls: 'month-sel',
|
|
75
|
-
content: [
|
|
76
|
-
new label_1.Label({
|
|
77
|
-
cls: 'month',
|
|
78
|
-
text: (0, tools_1.formatIntlDate)(this.m_date, 'O'),
|
|
79
|
-
dom_events: {
|
|
80
|
-
click: () => this._choose('month')
|
|
81
|
-
}
|
|
82
|
-
}),
|
|
83
|
-
new label_1.Label({
|
|
84
|
-
cls: 'year',
|
|
85
|
-
text: (0, tools_1.formatIntlDate)(this.m_date, 'Y'),
|
|
86
|
-
dom_events: {
|
|
87
|
-
click: () => this._choose('year')
|
|
88
|
-
}
|
|
89
|
-
}),
|
|
90
|
-
new component_1.Flex(),
|
|
91
|
-
new button_1.Button({ text: '<', click: () => this._next(false) }),
|
|
92
|
-
new button_1.Button({ text: '>', click: () => this._next(true) })
|
|
93
|
-
]
|
|
94
|
-
});
|
|
95
|
-
rows.push(header);
|
|
96
|
-
// calendar part
|
|
97
|
-
let day_names = [];
|
|
98
|
-
// day names
|
|
99
|
-
// empty week num
|
|
100
|
-
day_names.push(new layout_1.HLayout({
|
|
101
|
-
cls: 'weeknum cell',
|
|
102
|
-
}));
|
|
103
|
-
for (let d = 0; d < 7; d++) {
|
|
104
|
-
day_names.push(new label_1.Label({
|
|
105
|
-
cls: 'cell',
|
|
106
|
-
flex: 1,
|
|
107
|
-
text: i18n_1._tr.global.day_short[(d + 1) % 7]
|
|
108
|
-
}));
|
|
109
|
-
}
|
|
110
|
-
rows.push(new layout_1.HLayout({
|
|
111
|
-
cls: 'week header',
|
|
112
|
-
content: day_names
|
|
113
|
-
}));
|
|
114
|
-
let cmonth = this.m_date.getMonth();
|
|
115
|
-
// weeks
|
|
116
|
-
let first = true;
|
|
117
|
-
while ((0, tools_1.date_hash)(dte) <= end_of_month) {
|
|
118
|
-
let days = [
|
|
119
|
-
new layout_1.HLayout({ cls: 'weeknum cell', content: new component_1.Component({ tag: 'span', content: (0, tools_1.formatIntlDate)(dte, 'w') }) })
|
|
120
|
-
];
|
|
121
|
-
// days
|
|
122
|
-
for (let d = 0; d < 7; d++) {
|
|
123
|
-
let cls = 'cell day';
|
|
124
|
-
if (dte.hash() == today) {
|
|
125
|
-
cls += ' today';
|
|
126
|
-
}
|
|
127
|
-
if (dte.getMonth() != cmonth) {
|
|
128
|
-
cls += ' out';
|
|
129
|
-
}
|
|
130
|
-
const mkItem = (dte) => {
|
|
131
|
-
return new layout_1.HLayout({
|
|
132
|
-
cls,
|
|
133
|
-
flex: 1,
|
|
134
|
-
content: new component_1.Component({
|
|
135
|
-
tag: 'span',
|
|
136
|
-
content: (0, tools_1.formatIntlDate)(dte, 'd'),
|
|
137
|
-
}),
|
|
138
|
-
dom_events: {
|
|
139
|
-
click: () => this.select(dte)
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
};
|
|
143
|
-
days.push(mkItem(dte.clone()));
|
|
144
|
-
dte.setDate(dte.getDate() + 1);
|
|
145
|
-
first = false;
|
|
146
|
-
}
|
|
147
|
-
rows.push(new layout_1.HLayout({
|
|
148
|
-
cls: 'week',
|
|
149
|
-
flex: 1,
|
|
150
|
-
content: days
|
|
151
|
-
}));
|
|
152
|
-
}
|
|
153
|
-
this.setContent(rows);
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* select the given date
|
|
157
|
-
* @param date
|
|
158
|
-
*/
|
|
159
|
-
select(date) {
|
|
160
|
-
this.m_date = date;
|
|
161
|
-
this.emit('change', (0, x4events_1.EvChange)(date));
|
|
162
|
-
this.update();
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
*
|
|
166
|
-
*/
|
|
167
|
-
_next(n) {
|
|
168
|
-
this.m_date.setMonth(this.m_date.getMonth() + (n ? 1 : -1));
|
|
169
|
-
this.update();
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
*
|
|
173
|
-
*/
|
|
174
|
-
_choose(type) {
|
|
175
|
-
var _a, _b, _c, _d;
|
|
176
|
-
let items = [];
|
|
177
|
-
if (type == 'month') {
|
|
178
|
-
for (let m = 0; m < 12; m++) {
|
|
179
|
-
items.push(new menu_1.MenuItem({
|
|
180
|
-
text: i18n_1._tr.global.month_long[m],
|
|
181
|
-
click: () => { this.m_date.setMonth(m); this.update(); }
|
|
182
|
-
}));
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
else if (type == 'year') {
|
|
186
|
-
let min = (_b = (_a = this.m_props.minDate) === null || _a === void 0 ? void 0 : _a.getFullYear()) !== null && _b !== void 0 ? _b : 1900;
|
|
187
|
-
let max = (_d = (_c = this.m_props.maxDate) === null || _c === void 0 ? void 0 : _c.getFullYear()) !== null && _d !== void 0 ? _d : 2037;
|
|
188
|
-
for (let m = min; m < max; m++) {
|
|
189
|
-
items.push(new menu_1.MenuItem({
|
|
190
|
-
text: '' + m,
|
|
191
|
-
click: () => { this.m_date.setFullYear(m); this.update(); }
|
|
192
|
-
}));
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
let menu = new menu_1.Menu({
|
|
196
|
-
items
|
|
197
|
-
});
|
|
198
|
-
let rc = this.getBoundingRect();
|
|
199
|
-
menu.displayAt(rc.left, rc.top);
|
|
200
|
-
}
|
|
201
|
-
get date() {
|
|
202
|
-
return this.m_date;
|
|
203
|
-
}
|
|
204
|
-
set date(date) {
|
|
205
|
-
this.m_date = date;
|
|
206
|
-
this.update();
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
exports.Calendar = Calendar;
|
|
210
|
-
/**
|
|
211
|
-
* default popup calendar
|
|
212
|
-
*/
|
|
213
|
-
class PopupCalendar extends popup_1.Popup {
|
|
214
|
-
constructor(props) {
|
|
215
|
-
super({ tabIndex: 1 });
|
|
216
|
-
// binded
|
|
217
|
-
this._handleClick = (e) => {
|
|
218
|
-
if (!this.dom) {
|
|
219
|
-
return;
|
|
220
|
-
}
|
|
221
|
-
let newfocus = e.target;
|
|
222
|
-
// child of this: ok
|
|
223
|
-
if (this.dom.contains(newfocus)) {
|
|
224
|
-
return;
|
|
225
|
-
}
|
|
226
|
-
// menu: ok
|
|
227
|
-
let dest = component_1.Component.getElement(newfocus, menu_1.MenuItem);
|
|
228
|
-
if (dest) {
|
|
229
|
-
return;
|
|
230
|
-
}
|
|
231
|
-
this.close();
|
|
232
|
-
};
|
|
233
|
-
this.enableMask(false);
|
|
234
|
-
this.m_cal = new Calendar(props);
|
|
235
|
-
this.m_cal.addClass('@fit');
|
|
236
|
-
this.setContent(this.m_cal);
|
|
237
|
-
}
|
|
238
|
-
/** @ignore */
|
|
239
|
-
show(modal, at) {
|
|
240
|
-
x4dom_1.x4document.addEventListener('mousedown', this._handleClick);
|
|
241
|
-
if (at) {
|
|
242
|
-
super.displayAt(at.x, at.y, 'top left', undefined, modal);
|
|
243
|
-
}
|
|
244
|
-
else {
|
|
245
|
-
super.show(modal);
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
/** @ignore */
|
|
249
|
-
close() {
|
|
250
|
-
x4dom_1.x4document.removeEventListener('mousedown', this._handleClick);
|
|
251
|
-
super.close();
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
exports.PopupCalendar = PopupCalendar;
|