x4js 1.4.4 → 1.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/application.d.ts +96 -0
- package/lib/application.js +146 -0
- package/lib/base64.d.ts +31 -0
- package/lib/base64.js +139 -0
- package/lib/base_component.d.ts +64 -0
- package/lib/base_component.js +81 -0
- package/lib/button.d.ts +145 -0
- package/lib/button.js +241 -0
- package/lib/calendar.d.ts +77 -0
- package/lib/calendar.js +241 -0
- package/lib/canvas.d.ts +88 -0
- package/lib/canvas.js +358 -0
- package/lib/cardview.d.ts +83 -0
- package/lib/cardview.js +156 -0
- package/lib/checkbox.d.ts +72 -0
- package/lib/checkbox.js +130 -0
- package/lib/color.d.ts +144 -0
- package/lib/color.js +588 -0
- package/lib/colorpicker.js +86 -80
- package/lib/combobox.js +26 -22
- package/lib/component.d.ts +572 -0
- package/lib/component.js +1729 -0
- package/lib/datastore.js +29 -20
- package/lib/dialog.js +41 -36
- package/lib/dom_events.d.ts +284 -0
- package/lib/dom_events.js +14 -0
- package/lib/drag_manager.js +4 -1
- package/lib/drawtext.js +9 -5
- package/lib/fileupload.js +19 -12
- package/lib/form.js +29 -25
- package/lib/formatters.js +19 -10
- package/lib/gridview.js +40 -35
- package/lib/hosts/host.d.ts +44 -0
- package/lib/hosts/host.js +73 -0
- package/lib/i18n.d.ts +67 -0
- package/lib/i18n.js +175 -0
- package/lib/icon.d.ts +56 -0
- package/lib/icon.js +178 -0
- package/lib/image.js +7 -3
- package/lib/index.js +71 -55
- package/lib/input.d.ts +86 -0
- package/lib/input.js +176 -0
- package/lib/label.d.ts +54 -0
- package/lib/label.js +90 -0
- package/lib/layout.d.ts +77 -0
- package/lib/layout.js +271 -0
- package/lib/link.js +9 -5
- package/lib/listview.js +34 -27
- package/lib/md5.js +5 -1
- package/lib/menu.d.ts +122 -0
- package/lib/menu.js +284 -0
- package/lib/messagebox.js +22 -17
- package/lib/panel.js +13 -9
- package/lib/popup.d.ts +71 -0
- package/lib/popup.js +378 -0
- package/lib/property_editor.js +20 -16
- package/lib/radiobtn.js +13 -9
- package/lib/rating.js +13 -9
- package/lib/request.js +16 -9
- package/lib/router.js +5 -1
- package/lib/settings.d.ts +33 -0
- package/lib/settings.js +67 -0
- package/lib/sidebarview.js +12 -8
- package/lib/smartedit.js +16 -11
- package/lib/spreadsheet.js +35 -31
- package/lib/styles.d.ts +81 -0
- package/lib/styles.js +268 -0
- package/lib/svgcomponent.js +8 -3
- package/lib/tabbar.js +10 -6
- package/lib/tabview.js +10 -6
- package/lib/textarea.js +10 -6
- package/lib/textedit.js +39 -35
- package/lib/texthiliter.js +8 -4
- package/lib/toaster.js +8 -4
- package/lib/tools.d.ts +382 -0
- package/lib/tools.js +1142 -0
- package/lib/tooltips.js +14 -9
- package/lib/treeview.js +30 -26
- package/lib/x4_events.d.ts +253 -0
- package/lib/x4_events.js +375 -0
- package/package.json +1 -1
- package/src/application.ts +9 -4
- package/src/x4.less +143 -107
- package/tsconfig.json +1 -1
- package/x4.css +1541 -0
package/lib/styles.js
ADDED
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* ___ ___ __
|
|
4
|
+
* \ \_/ / / _
|
|
5
|
+
* \ / /_| |_
|
|
6
|
+
* / _ \____ _|
|
|
7
|
+
* /__/ \__\ |_|
|
|
8
|
+
*
|
|
9
|
+
* @file styles.ts
|
|
10
|
+
* @author Etienne Cochard
|
|
11
|
+
* @license
|
|
12
|
+
* Copyright (c) 2019-2021 R-libre ingenierie
|
|
13
|
+
*
|
|
14
|
+
* This program is free software; you can redistribute it and/or modify
|
|
15
|
+
* it under the terms of the GNU General Public License as published by
|
|
16
|
+
* the Free Software Foundation; either version 3 of the License, or
|
|
17
|
+
* (at your option) any later version.
|
|
18
|
+
*
|
|
19
|
+
* This program is distributed in the hope that it will be useful,
|
|
20
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
21
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
22
|
+
* GNU General Public License for more details.
|
|
23
|
+
*
|
|
24
|
+
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
25
|
+
**/
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
exports.ComputedStyle = exports.CSSParser = exports.Stylesheet = void 0;
|
|
28
|
+
const tools_1 = require("./tools");
|
|
29
|
+
/**
|
|
30
|
+
* -- [ @STYLESHEET ] -----------------------------------------------------------------
|
|
31
|
+
*/
|
|
32
|
+
class Stylesheet {
|
|
33
|
+
m_sheet;
|
|
34
|
+
m_rules = new Map();
|
|
35
|
+
constructor() {
|
|
36
|
+
function getStyleSheet(name) {
|
|
37
|
+
for (let i = 0; i < document.styleSheets.length; i++) {
|
|
38
|
+
let sheet = document.styleSheets[i];
|
|
39
|
+
if (sheet.title === name) {
|
|
40
|
+
return sheet;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
this.m_sheet = getStyleSheet('@dynamic-css');
|
|
45
|
+
if (!this.m_sheet) {
|
|
46
|
+
let dom = document.createElement('style');
|
|
47
|
+
dom.setAttribute('id', '@dynamic-css');
|
|
48
|
+
document.head.appendChild(dom);
|
|
49
|
+
this.m_sheet = dom.sheet;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* add a new rule to the style sheet
|
|
54
|
+
* @param {string} name - internal rule name
|
|
55
|
+
* @param {string} definition - css definition of the rule
|
|
56
|
+
* @example
|
|
57
|
+
* setRule('xbody', "body { background-color: #ff0000; }" );
|
|
58
|
+
*/
|
|
59
|
+
setRule(name, definition) {
|
|
60
|
+
if ((0, tools_1.isString)(definition)) {
|
|
61
|
+
let index = this.m_rules.get(name);
|
|
62
|
+
if (index !== undefined) {
|
|
63
|
+
this.m_sheet.deleteRule(index);
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
index = this.m_sheet.cssRules.length;
|
|
67
|
+
}
|
|
68
|
+
this.m_rules.set(name, this.m_sheet.insertRule(definition, index));
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
let idx = 1;
|
|
72
|
+
for (let r in definition) {
|
|
73
|
+
let rule = r + " { ", css = definition[r];
|
|
74
|
+
for (let i in css) {
|
|
75
|
+
let values = css[i]; // this is an array !
|
|
76
|
+
for (let j = 0; j < values.length; j++) {
|
|
77
|
+
rule += i + ": " + values[j] + "; ";
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
rule += '}';
|
|
81
|
+
console.log(rule);
|
|
82
|
+
this.setRule(name + '--' + idx, rule);
|
|
83
|
+
idx++;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* return the style variable value
|
|
89
|
+
* @param name - variable name without '--'
|
|
90
|
+
* @example
|
|
91
|
+
* ```
|
|
92
|
+
* let color = Component.getCss( ).getVar( 'button-color' );
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
static getVar(name) {
|
|
96
|
+
if (!Stylesheet.doc_style) {
|
|
97
|
+
Stylesheet.doc_style = getComputedStyle(document.documentElement);
|
|
98
|
+
}
|
|
99
|
+
return Stylesheet.doc_style.getPropertyValue('--' + name); // #999999
|
|
100
|
+
}
|
|
101
|
+
static guid = 1;
|
|
102
|
+
static doc_style;
|
|
103
|
+
}
|
|
104
|
+
exports.Stylesheet = Stylesheet;
|
|
105
|
+
/**
|
|
106
|
+
* -- [ @CSSPARSER ] -----------------------------------------------------------------
|
|
107
|
+
*
|
|
108
|
+
* adaptation of jss-for-node-js
|
|
109
|
+
*/
|
|
110
|
+
class CSSParser {
|
|
111
|
+
result = {};
|
|
112
|
+
parse(css) {
|
|
113
|
+
this.result = {};
|
|
114
|
+
this.parse_json('', css);
|
|
115
|
+
return CSSParser.mk_string(this.result);
|
|
116
|
+
}
|
|
117
|
+
static mk_string(rules) {
|
|
118
|
+
// output result:
|
|
119
|
+
let ret = '';
|
|
120
|
+
for (let a in rules) {
|
|
121
|
+
let css = rules[a];
|
|
122
|
+
ret += a + " { ";
|
|
123
|
+
for (let i in css) {
|
|
124
|
+
let values = css[i]; // this is an array !
|
|
125
|
+
for (let j = 0; j < values.length; j++) {
|
|
126
|
+
ret += i + ": " + values[j] + "; ";
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
ret += "}\n";
|
|
130
|
+
}
|
|
131
|
+
return ret;
|
|
132
|
+
}
|
|
133
|
+
parse_json(scope, css) {
|
|
134
|
+
if (scope && !this.result[scope]) {
|
|
135
|
+
this.result[scope] = {};
|
|
136
|
+
}
|
|
137
|
+
for (let property in css) {
|
|
138
|
+
let value = css[property];
|
|
139
|
+
if ((0, tools_1.isArray)(value)) {
|
|
140
|
+
let values = value;
|
|
141
|
+
for (let i = 0; i < values.length; i++) {
|
|
142
|
+
this.addProperty(scope, property, values[i]);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
/*else if (value instanceof Color) {
|
|
146
|
+
this.addProperty(scope, property, value.toString());
|
|
147
|
+
}*/
|
|
148
|
+
else {
|
|
149
|
+
switch (typeof (value)) {
|
|
150
|
+
case "number": {
|
|
151
|
+
this.addProperty(scope, property, value);
|
|
152
|
+
break;
|
|
153
|
+
}
|
|
154
|
+
case "string": {
|
|
155
|
+
this.addProperty(scope, property, value);
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
case "object": {
|
|
159
|
+
this.parse_json(this.makeSelectorName(scope, property), value);
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
default: {
|
|
163
|
+
console.error("ignoring unknown type " + typeof (value) + " in property " + property);
|
|
164
|
+
break;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
makePropertyName(n) {
|
|
171
|
+
return (0, tools_1.pascalCase)(n);
|
|
172
|
+
}
|
|
173
|
+
makeSelectorName(scope, name) {
|
|
174
|
+
let snames = [];
|
|
175
|
+
let names = name.split(/\s*,\s*/);
|
|
176
|
+
let scopes = scope.split(/\s*,\s*/);
|
|
177
|
+
for (let s = 0; s < scopes.length; s++) {
|
|
178
|
+
let scope = scopes[s];
|
|
179
|
+
for (let i = 0; i < names.length; i++) {
|
|
180
|
+
let name = names[i], sub = false;
|
|
181
|
+
if (name.charAt(0) == "&") {
|
|
182
|
+
name = name.substr(1);
|
|
183
|
+
sub = true;
|
|
184
|
+
}
|
|
185
|
+
if (name.charAt(0) === '%') {
|
|
186
|
+
name = '.o-' + name.substr(1);
|
|
187
|
+
}
|
|
188
|
+
if (sub) {
|
|
189
|
+
snames.push(scope + name);
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
snames.push(scope ? scope + " " + name : name);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
return snames.join(", ");
|
|
197
|
+
}
|
|
198
|
+
addProperty(scope, property, value) {
|
|
199
|
+
let properties = property.split(/\s*,\s*/);
|
|
200
|
+
for (let i = 0; i < properties.length; i++) {
|
|
201
|
+
let property = this.makePropertyName(properties[i]);
|
|
202
|
+
if (this.result[scope][property]) {
|
|
203
|
+
this.result[scope][property].push(value);
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
this.result[scope][property] = [value];
|
|
207
|
+
}
|
|
208
|
+
let specials = {
|
|
209
|
+
"box-shadow": [
|
|
210
|
+
"-moz-box-shadow",
|
|
211
|
+
"-webkit-box-shadow"
|
|
212
|
+
],
|
|
213
|
+
"border-radius": [
|
|
214
|
+
"-moz-border-radius",
|
|
215
|
+
"-webkit-border-radius"
|
|
216
|
+
],
|
|
217
|
+
"border-radius-topleft": [
|
|
218
|
+
"-moz-border-radius-topleft",
|
|
219
|
+
"-webkit-border-top-left-radius"
|
|
220
|
+
],
|
|
221
|
+
"border-radius-topright": [
|
|
222
|
+
"-moz-border-radius-topright",
|
|
223
|
+
"-webkit-border-top-right-radius"
|
|
224
|
+
],
|
|
225
|
+
"border-radius-bottomleft": [
|
|
226
|
+
"-moz-border-radius-bottomleft",
|
|
227
|
+
"-webkit-border-bottom-left-radius"
|
|
228
|
+
],
|
|
229
|
+
"border-radius-bottomright": [
|
|
230
|
+
"-moz-border-radius-bottomright",
|
|
231
|
+
"-webkit-border-bottom-right-radius"
|
|
232
|
+
]
|
|
233
|
+
};
|
|
234
|
+
let browser_specials = specials[property];
|
|
235
|
+
for (let j = 0; browser_specials && j < browser_specials.length; j++) {
|
|
236
|
+
this.addProperty(scope, browser_specials[j], value);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
exports.CSSParser = CSSParser;
|
|
242
|
+
class ComputedStyle {
|
|
243
|
+
m_style;
|
|
244
|
+
constructor(style) {
|
|
245
|
+
this.m_style = style;
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* return the raw value
|
|
249
|
+
*/
|
|
250
|
+
value(name) {
|
|
251
|
+
name = (0, tools_1.pascalCase)(name);
|
|
252
|
+
return this.m_style[name];
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* return the interpreted value
|
|
256
|
+
*/
|
|
257
|
+
parse(name) {
|
|
258
|
+
name = (0, tools_1.pascalCase)(name);
|
|
259
|
+
return parseInt(this.m_style[name]);
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
*
|
|
263
|
+
*/
|
|
264
|
+
get style() {
|
|
265
|
+
return this.m_style;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
exports.ComputedStyle = ComputedStyle;
|
package/lib/svgcomponent.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* ___ ___ __
|
|
3
4
|
* \ \_/ / / _
|
|
@@ -22,7 +23,9 @@
|
|
|
22
23
|
*
|
|
23
24
|
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
24
25
|
**/
|
|
25
|
-
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
exports.SVGComponent = exports.SVGPathBuilder = void 0;
|
|
28
|
+
const component_1 = require("./component");
|
|
26
29
|
// degrees to radian
|
|
27
30
|
function d2r(d) {
|
|
28
31
|
return d * Math.PI / 180.0;
|
|
@@ -284,7 +287,7 @@ class SVGGradient extends SVGItem {
|
|
|
284
287
|
/**
|
|
285
288
|
*
|
|
286
289
|
*/
|
|
287
|
-
|
|
290
|
+
class SVGPathBuilder {
|
|
288
291
|
m_items;
|
|
289
292
|
constructor() {
|
|
290
293
|
this.m_items = [];
|
|
@@ -336,7 +339,8 @@ export class SVGPathBuilder {
|
|
|
336
339
|
return result.join('\n');
|
|
337
340
|
}
|
|
338
341
|
}
|
|
339
|
-
|
|
342
|
+
exports.SVGPathBuilder = SVGPathBuilder;
|
|
343
|
+
class SVGComponent extends component_1.Component {
|
|
340
344
|
constructor(props) {
|
|
341
345
|
super(props);
|
|
342
346
|
this.setProp('tag', 'svg');
|
|
@@ -348,3 +352,4 @@ export class SVGComponent extends Component {
|
|
|
348
352
|
this.setContent(props.path);
|
|
349
353
|
}
|
|
350
354
|
}
|
|
355
|
+
exports.SVGComponent = SVGComponent;
|
package/lib/tabbar.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* ___ ___ __
|
|
3
4
|
* \ \_/ / / _
|
|
@@ -11,10 +12,12 @@
|
|
|
11
12
|
*
|
|
12
13
|
* @description Tab
|
|
13
14
|
**/
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.TabBar = void 0;
|
|
17
|
+
const component_1 = require("./component");
|
|
18
|
+
const button_1 = require("./button");
|
|
19
|
+
const x4_events_1 = require("./x4_events");
|
|
20
|
+
class TabBar extends component_1.Container {
|
|
18
21
|
m_pages;
|
|
19
22
|
m_curPage;
|
|
20
23
|
constructor(props) {
|
|
@@ -40,7 +43,7 @@ export class TabBar extends Container {
|
|
|
40
43
|
render() {
|
|
41
44
|
let buttons = [];
|
|
42
45
|
this.m_pages.forEach(p => {
|
|
43
|
-
p.btn = new Button({ cls: p === this.m_curPage ? 'selected' : '', text: p.title, icon: p.icon, click: () => this._select(p) });
|
|
46
|
+
p.btn = new button_1.Button({ cls: p === this.m_curPage ? 'selected' : '', text: p.title, icon: p.icon, click: () => this._select(p) });
|
|
44
47
|
buttons.push(p.btn);
|
|
45
48
|
});
|
|
46
49
|
this.setContent(buttons);
|
|
@@ -57,10 +60,11 @@ export class TabBar extends Container {
|
|
|
57
60
|
this.m_curPage.page.hide();
|
|
58
61
|
}
|
|
59
62
|
this.m_curPage = p;
|
|
60
|
-
this.signal('change', EvChange(p ? p.id : null));
|
|
63
|
+
this.signal('change', (0, x4_events_1.EvChange)(p ? p.id : null));
|
|
61
64
|
if (this.dom && this.m_curPage && this.m_curPage.page) {
|
|
62
65
|
this.m_curPage.btn.addClass('selected');
|
|
63
66
|
this.m_curPage.page.show();
|
|
64
67
|
}
|
|
65
68
|
}
|
|
66
69
|
}
|
|
70
|
+
exports.TabBar = TabBar;
|
package/lib/tabview.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* ___ ___ __
|
|
3
4
|
* \ \_/ / / _
|
|
@@ -22,13 +23,15 @@
|
|
|
22
23
|
*
|
|
23
24
|
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
24
25
|
**/
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
exports.TabView = void 0;
|
|
28
|
+
const layout_1 = require("./layout");
|
|
29
|
+
const button_1 = require("./button");
|
|
30
|
+
const cardview_1 = require("./cardview");
|
|
28
31
|
/**
|
|
29
32
|
* Standard TabView class
|
|
30
33
|
*/
|
|
31
|
-
|
|
34
|
+
class TabView extends cardview_1.CardView {
|
|
32
35
|
m_tab_selector;
|
|
33
36
|
m_menu;
|
|
34
37
|
constructor(props) {
|
|
@@ -53,7 +56,7 @@ export class TabView extends CardView {
|
|
|
53
56
|
}
|
|
54
57
|
});
|
|
55
58
|
if (this.m_tab_selector) {
|
|
56
|
-
pages.unshift(new HLayout({
|
|
59
|
+
pages.unshift(new layout_1.HLayout({
|
|
57
60
|
cls: '@tab-switch',
|
|
58
61
|
content: tabs
|
|
59
62
|
}));
|
|
@@ -63,7 +66,7 @@ export class TabView extends CardView {
|
|
|
63
66
|
_updateSelector() {
|
|
64
67
|
}
|
|
65
68
|
_prepareSelector(card) {
|
|
66
|
-
return new Button({
|
|
69
|
+
return new button_1.Button({
|
|
67
70
|
cls: '@tab-btn',
|
|
68
71
|
text: card.title,
|
|
69
72
|
icon: card.icon,
|
|
@@ -77,3 +80,4 @@ export class TabView extends CardView {
|
|
|
77
80
|
}
|
|
78
81
|
}
|
|
79
82
|
}
|
|
83
|
+
exports.TabView = TabView;
|
package/lib/textarea.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* ___ ___ __
|
|
3
4
|
* \ \_/ / / _
|
|
@@ -22,10 +23,12 @@
|
|
|
22
23
|
*
|
|
23
24
|
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
24
25
|
**/
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
exports.TextArea = void 0;
|
|
28
|
+
const component_1 = require("./component");
|
|
29
|
+
const x4_events_1 = require("./x4_events");
|
|
30
|
+
const tools_1 = require("./tools");
|
|
31
|
+
class TextArea extends component_1.Component {
|
|
29
32
|
constructor(props) {
|
|
30
33
|
super(props);
|
|
31
34
|
this.mapPropEvents(props, 'change');
|
|
@@ -56,7 +59,7 @@ export class TextArea extends Component {
|
|
|
56
59
|
this.setProp('autoGrow', true);
|
|
57
60
|
this.setAttribute('rows', this._calcHeight(props.text));
|
|
58
61
|
this.setDomEvent('keydown', () => {
|
|
59
|
-
asap(() => this._updateHeight());
|
|
62
|
+
(0, tools_1.asap)(() => this._updateHeight());
|
|
60
63
|
});
|
|
61
64
|
}
|
|
62
65
|
// avoid going to next element on enter
|
|
@@ -67,7 +70,7 @@ export class TextArea extends Component {
|
|
|
67
70
|
this.setProp('tag', 'textarea');
|
|
68
71
|
}
|
|
69
72
|
_change() {
|
|
70
|
-
this.emit('change', EvChange(this.value));
|
|
73
|
+
this.emit('change', (0, x4_events_1.EvChange)(this.value));
|
|
71
74
|
}
|
|
72
75
|
componentCreated() {
|
|
73
76
|
this.value = this.m_props.text;
|
|
@@ -117,3 +120,4 @@ export class TextArea extends Component {
|
|
|
117
120
|
this.value = value;
|
|
118
121
|
}
|
|
119
122
|
}
|
|
123
|
+
exports.TextArea = TextArea;
|
package/lib/textedit.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* ___ ___ __
|
|
3
4
|
* \ \_/ / / _
|
|
@@ -22,22 +23,24 @@
|
|
|
22
23
|
*
|
|
23
24
|
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
24
25
|
**/
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
exports.TextEdit = void 0;
|
|
28
|
+
const component_1 = require("./component");
|
|
29
|
+
const input_1 = require("./input");
|
|
30
|
+
const button_1 = require("./button");
|
|
31
|
+
const layout_1 = require("./layout");
|
|
32
|
+
const label_1 = require("./label");
|
|
33
|
+
const calendar_1 = require("./calendar");
|
|
34
|
+
const tools_1 = require("./tools");
|
|
35
|
+
const tooltips_1 = require("./tooltips");
|
|
36
|
+
const x4_events_1 = require("./x4_events");
|
|
37
|
+
const i18n_1 = require("./i18n");
|
|
35
38
|
/** @ignore */
|
|
36
39
|
const reEmail = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
|
37
40
|
/**
|
|
38
41
|
* TextEdit is a single line editor, it can have a label and an error descriptor.
|
|
39
42
|
*/
|
|
40
|
-
|
|
43
|
+
class TextEdit extends component_1.Component {
|
|
41
44
|
m_cal_popup;
|
|
42
45
|
m_ui_input;
|
|
43
46
|
m_error_tip;
|
|
@@ -94,18 +97,18 @@ export class TextEdit extends Component {
|
|
|
94
97
|
};
|
|
95
98
|
eprops.value_hook = props.value_hook ?? def_hook;
|
|
96
99
|
}
|
|
97
|
-
this.m_ui_input = new Input(eprops);
|
|
100
|
+
this.m_ui_input = new input_1.Input(eprops);
|
|
98
101
|
// button
|
|
99
102
|
let button = undefined;
|
|
100
103
|
if (props.icon) {
|
|
101
|
-
button = new Button({
|
|
104
|
+
button = new button_1.Button({
|
|
102
105
|
icon: props.icon,
|
|
103
106
|
click: () => this._btnClick(),
|
|
104
107
|
tabIndex: false
|
|
105
108
|
});
|
|
106
109
|
}
|
|
107
110
|
else if (props.type == 'date') {
|
|
108
|
-
button = new Button({
|
|
111
|
+
button = new button_1.Button({
|
|
109
112
|
cls: 'gadget',
|
|
110
113
|
icon: 'cls(far fa-calendar-days)',
|
|
111
114
|
tabIndex: false,
|
|
@@ -140,7 +143,7 @@ export class TextEdit extends Component {
|
|
|
140
143
|
top = true;
|
|
141
144
|
flex = 1;
|
|
142
145
|
}
|
|
143
|
-
label = new Label({
|
|
146
|
+
label = new label_1.Label({
|
|
144
147
|
ref: 'label',
|
|
145
148
|
tag: 'label',
|
|
146
149
|
cls: 'label1' + (props.label ? '' : ' @hidden'),
|
|
@@ -155,7 +158,7 @@ export class TextEdit extends Component {
|
|
|
155
158
|
this.addClass('@vlayout vertical');
|
|
156
159
|
this.setContent([
|
|
157
160
|
label,
|
|
158
|
-
new HLayout({ width, content: [this.m_ui_input, ...gadgets] })
|
|
161
|
+
new layout_1.HLayout({ width, content: [this.m_ui_input, ...gadgets] })
|
|
159
162
|
]);
|
|
160
163
|
}
|
|
161
164
|
else {
|
|
@@ -174,7 +177,7 @@ export class TextEdit extends Component {
|
|
|
174
177
|
super.disable();
|
|
175
178
|
}
|
|
176
179
|
_btnClick() {
|
|
177
|
-
this.emit('click', EvClick(this.value));
|
|
180
|
+
this.emit('click', (0, x4_events_1.EvClick)(this.value));
|
|
178
181
|
}
|
|
179
182
|
/**
|
|
180
183
|
* select the value format for input/output on textedit of type date
|
|
@@ -191,23 +194,23 @@ export class TextEdit extends Component {
|
|
|
191
194
|
return this.m_ui_input.getStoreValue();
|
|
192
195
|
}
|
|
193
196
|
_date_get_hook() {
|
|
194
|
-
let date = parseIntlDate(this.value);
|
|
197
|
+
let date = (0, tools_1.parseIntlDate)(this.value);
|
|
195
198
|
let props = this.m_props;
|
|
196
199
|
if (props.format == 'native') {
|
|
197
200
|
return date;
|
|
198
201
|
}
|
|
199
202
|
else {
|
|
200
|
-
return date ? formatIntlDate(date, props.format) : null;
|
|
203
|
+
return date ? (0, tools_1.formatIntlDate)(date, props.format) : null;
|
|
201
204
|
}
|
|
202
205
|
}
|
|
203
206
|
_date_set_hook(dte) {
|
|
204
207
|
let props = this.m_props;
|
|
205
208
|
if (props.format == 'native') {
|
|
206
|
-
this.value = formatIntlDate(dte);
|
|
209
|
+
this.value = (0, tools_1.formatIntlDate)(dte);
|
|
207
210
|
}
|
|
208
211
|
else if (dte) {
|
|
209
|
-
let date = parseIntlDate(dte, props.format);
|
|
210
|
-
this.value = formatIntlDate(date);
|
|
212
|
+
let date = (0, tools_1.parseIntlDate)(dte, props.format);
|
|
213
|
+
this.value = (0, tools_1.formatIntlDate)(date);
|
|
211
214
|
}
|
|
212
215
|
else {
|
|
213
216
|
this.value = '';
|
|
@@ -215,7 +218,7 @@ export class TextEdit extends Component {
|
|
|
215
218
|
}
|
|
216
219
|
showError(text) {
|
|
217
220
|
if (!this.m_error_tip) {
|
|
218
|
-
this.m_error_tip = new Tooltip({ cls: 'error' });
|
|
221
|
+
this.m_error_tip = new tooltips_1.Tooltip({ cls: 'error' });
|
|
219
222
|
document.body.appendChild(this.m_error_tip._build());
|
|
220
223
|
}
|
|
221
224
|
let rc = this.m_ui_input.getBoundingRect();
|
|
@@ -272,14 +275,14 @@ export class TextEdit extends Component {
|
|
|
272
275
|
*/
|
|
273
276
|
_change() {
|
|
274
277
|
let value = this.m_ui_input.value;
|
|
275
|
-
this.emit('change', EvChange(value));
|
|
278
|
+
this.emit('change', (0, x4_events_1.EvChange)(value));
|
|
276
279
|
}
|
|
277
280
|
/**
|
|
278
281
|
* getting focus
|
|
279
282
|
*/
|
|
280
283
|
_focus() {
|
|
281
284
|
this.clearError();
|
|
282
|
-
this.emit('focus', EvFocus(true));
|
|
285
|
+
this.emit('focus', (0, component_1.EvFocus)(true));
|
|
283
286
|
}
|
|
284
287
|
/**
|
|
285
288
|
* loosing focus
|
|
@@ -287,7 +290,7 @@ export class TextEdit extends Component {
|
|
|
287
290
|
*/
|
|
288
291
|
_blur() {
|
|
289
292
|
this._validate(this.m_ui_input.value);
|
|
290
|
-
this.emit('focus', EvFocus(false));
|
|
293
|
+
this.emit('focus', (0, component_1.EvFocus)(false));
|
|
291
294
|
}
|
|
292
295
|
/**
|
|
293
296
|
* todo: should move into Input
|
|
@@ -300,7 +303,7 @@ export class TextEdit extends Component {
|
|
|
300
303
|
let props = this.m_props;
|
|
301
304
|
let update = false;
|
|
302
305
|
if (props.required && value.length == 0) {
|
|
303
|
-
this.showError(_tr.global.required_field);
|
|
306
|
+
this.showError(i18n_1._tr.global.required_field);
|
|
304
307
|
return false;
|
|
305
308
|
}
|
|
306
309
|
if (value != '') {
|
|
@@ -308,20 +311,20 @@ export class TextEdit extends Component {
|
|
|
308
311
|
if (pattern) {
|
|
309
312
|
let re = new RegExp(pattern);
|
|
310
313
|
if (re && !re.test(value)) {
|
|
311
|
-
this.showError(_tr.global.invalid_format);
|
|
314
|
+
this.showError(i18n_1._tr.global.invalid_format);
|
|
312
315
|
return false;
|
|
313
316
|
}
|
|
314
317
|
}
|
|
315
318
|
if (props.type == 'email') {
|
|
316
319
|
if (!reEmail.test(value.toLowerCase())) {
|
|
317
|
-
this.showError(_tr.global.invalid_email);
|
|
320
|
+
this.showError(i18n_1._tr.global.invalid_email);
|
|
318
321
|
return false;
|
|
319
322
|
}
|
|
320
323
|
}
|
|
321
324
|
else if (props.type == 'number') {
|
|
322
325
|
const v = parseFloat(value);
|
|
323
326
|
if (isNaN(v)) {
|
|
324
|
-
this.showError(_tr.global.invalid_number);
|
|
327
|
+
this.showError(i18n_1._tr.global.invalid_number);
|
|
325
328
|
return false;
|
|
326
329
|
}
|
|
327
330
|
let min = parseFloat(this.m_ui_input.getAttribute('min'));
|
|
@@ -360,12 +363,12 @@ export class TextEdit extends Component {
|
|
|
360
363
|
date = new Date();
|
|
361
364
|
}
|
|
362
365
|
else {
|
|
363
|
-
date = parseIntlDate(value);
|
|
366
|
+
date = (0, tools_1.parseIntlDate)(value);
|
|
364
367
|
if (!date) {
|
|
365
|
-
throw sprintf(_tr.global.invalid_date, _tr.global.date_format);
|
|
368
|
+
throw (0, tools_1.sprintf)(i18n_1._tr.global.invalid_date, i18n_1._tr.global.date_format);
|
|
366
369
|
}
|
|
367
370
|
}
|
|
368
|
-
return formatIntlDate(date);
|
|
371
|
+
return (0, tools_1.formatIntlDate)(date);
|
|
369
372
|
}
|
|
370
373
|
//onKeyDown( e ) {
|
|
371
374
|
// if( this.readOnly ) {
|
|
@@ -387,9 +390,9 @@ export class TextEdit extends Component {
|
|
|
387
390
|
//}
|
|
388
391
|
_showDatePicker(btn) {
|
|
389
392
|
if (!this.m_cal_popup) {
|
|
390
|
-
this.m_cal_popup = new PopupCalendar({
|
|
393
|
+
this.m_cal_popup = new calendar_1.PopupCalendar({
|
|
391
394
|
change: (ev) => {
|
|
392
|
-
this.value = formatIntlDate(ev.value);
|
|
395
|
+
this.value = (0, tools_1.formatIntlDate)(ev.value);
|
|
393
396
|
this.m_cal_popup.close();
|
|
394
397
|
}
|
|
395
398
|
});
|
|
@@ -404,3 +407,4 @@ export class TextEdit extends Component {
|
|
|
404
407
|
return this.m_props.type;
|
|
405
408
|
}
|
|
406
409
|
}
|
|
410
|
+
exports.TextEdit = TextEdit;
|