x4js 1.5.18 → 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 -46
- 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/textedit.js
DELETED
|
@@ -1,415 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* ___ ___ __
|
|
4
|
-
* \ \_/ / / _
|
|
5
|
-
* \ / /_| |_
|
|
6
|
-
* / _ \____ _|
|
|
7
|
-
* /__/ \__\ |_|
|
|
8
|
-
*
|
|
9
|
-
* @file textedit.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.TextEdit = void 0;
|
|
32
|
-
const x4dom_1 = require("./x4dom");
|
|
33
|
-
const component_1 = require("./component");
|
|
34
|
-
const input_1 = require("./input");
|
|
35
|
-
const button_1 = require("./button");
|
|
36
|
-
const layout_1 = require("./layout");
|
|
37
|
-
const label_1 = require("./label");
|
|
38
|
-
const calendar_1 = require("./calendar");
|
|
39
|
-
const tools_1 = require("./tools");
|
|
40
|
-
const tooltips_1 = require("./tooltips");
|
|
41
|
-
const x4events_1 = require("./x4events");
|
|
42
|
-
const i18n_1 = require("./i18n");
|
|
43
|
-
/** @ignore */
|
|
44
|
-
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,}))$/;
|
|
45
|
-
/**
|
|
46
|
-
* TextEdit is a single line editor, it can have a label and an error descriptor.
|
|
47
|
-
*/
|
|
48
|
-
class TextEdit extends component_1.Component {
|
|
49
|
-
constructor(props) {
|
|
50
|
-
super(props);
|
|
51
|
-
this.addClass('@hlayout');
|
|
52
|
-
this.mapPropEvents(props, 'change', 'click', 'focus');
|
|
53
|
-
}
|
|
54
|
-
componentCreated() {
|
|
55
|
-
super.componentCreated();
|
|
56
|
-
if (this.m_props.autoFocus) {
|
|
57
|
-
this.focus();
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
componentDisposed() {
|
|
61
|
-
if (this.m_error_tip) {
|
|
62
|
-
this.m_error_tip.dispose();
|
|
63
|
-
}
|
|
64
|
-
super.componentDisposed();
|
|
65
|
-
}
|
|
66
|
-
focus() {
|
|
67
|
-
this.m_ui_input.focus();
|
|
68
|
-
}
|
|
69
|
-
/** @ignore */
|
|
70
|
-
render(props) {
|
|
71
|
-
var _a, _b, _c, _d;
|
|
72
|
-
let eprops = {
|
|
73
|
-
flex: 1,
|
|
74
|
-
dom_events: {
|
|
75
|
-
focus: () => this._focus(),
|
|
76
|
-
focusout: () => this._blur(),
|
|
77
|
-
input: () => this._change()
|
|
78
|
-
},
|
|
79
|
-
value: props.value,
|
|
80
|
-
name: props.name,
|
|
81
|
-
type: props.type,
|
|
82
|
-
placeHolder: props.placeHolder,
|
|
83
|
-
autoFocus: props.autoFocus,
|
|
84
|
-
readOnly: props.readOnly,
|
|
85
|
-
value_hook: props.value_hook,
|
|
86
|
-
uppercase: props.uppercase,
|
|
87
|
-
spellcheck: props.spellcheck,
|
|
88
|
-
tabIndex: props.tabIndex === undefined ? true : props.tabIndex,
|
|
89
|
-
attrs: props.attrs,
|
|
90
|
-
min: props.min,
|
|
91
|
-
max: props.max,
|
|
92
|
-
autosel: props.autosel,
|
|
93
|
-
};
|
|
94
|
-
// date is handled manually with popupcalendar
|
|
95
|
-
if (props.type == 'date') {
|
|
96
|
-
props.format = (_a = props.format) !== null && _a !== void 0 ? _a : 'Y-M-D';
|
|
97
|
-
eprops.type = 'text';
|
|
98
|
-
let def_hook = {
|
|
99
|
-
get: () => this._date_get_hook(),
|
|
100
|
-
set: (e) => this._date_set_hook(e)
|
|
101
|
-
};
|
|
102
|
-
eprops.value_hook = (_b = props.value_hook) !== null && _b !== void 0 ? _b : def_hook;
|
|
103
|
-
}
|
|
104
|
-
this.m_ui_input = new input_1.Input(eprops);
|
|
105
|
-
// button
|
|
106
|
-
let button = undefined;
|
|
107
|
-
if (props.icon) {
|
|
108
|
-
button = new button_1.Button({
|
|
109
|
-
icon: props.icon,
|
|
110
|
-
click: () => this._btnClick(),
|
|
111
|
-
tabIndex: false
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
else if (props.type == 'date') {
|
|
115
|
-
button = new button_1.Button({
|
|
116
|
-
cls: 'gadget',
|
|
117
|
-
icon: 'var( --x4-icon-calendar-days )',
|
|
118
|
-
tabIndex: false,
|
|
119
|
-
click: () => this._showDatePicker(button)
|
|
120
|
-
});
|
|
121
|
-
if (!props.validator) {
|
|
122
|
-
props.validator = this._date_validator;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
let ag = (_c = props.gadgets) !== null && _c !== void 0 ? _c : [];
|
|
126
|
-
ag.forEach(b => {
|
|
127
|
-
b.addClass('gadget');
|
|
128
|
-
});
|
|
129
|
-
let gadgets = [button, ...ag];
|
|
130
|
-
this.setClass('@required', props.required);
|
|
131
|
-
if (props.gadgets && props.gadgets.length) {
|
|
132
|
-
this.addClass('with-gadgets');
|
|
133
|
-
}
|
|
134
|
-
let width = undefined, flex = undefined, labelWidth = props.labelWidth;
|
|
135
|
-
if (labelWidth > 0) {
|
|
136
|
-
width = labelWidth;
|
|
137
|
-
}
|
|
138
|
-
if (labelWidth < 0) {
|
|
139
|
-
flex = -labelWidth;
|
|
140
|
-
}
|
|
141
|
-
let label = undefined;
|
|
142
|
-
let labelAlign = props.labelAlign;
|
|
143
|
-
let top = false;
|
|
144
|
-
if (props.label) {
|
|
145
|
-
if (labelAlign == 'top') {
|
|
146
|
-
labelAlign = 'left';
|
|
147
|
-
top = true;
|
|
148
|
-
flex = 1;
|
|
149
|
-
}
|
|
150
|
-
label = new label_1.Label({
|
|
151
|
-
ref: 'label',
|
|
152
|
-
tag: 'label',
|
|
153
|
-
cls: 'label1' + (props.label ? '' : ' @hidden'),
|
|
154
|
-
text: (_d = props.label) !== null && _d !== void 0 ? _d : '',
|
|
155
|
-
width,
|
|
156
|
-
flex,
|
|
157
|
-
align: labelAlign
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
if (top) {
|
|
161
|
-
this.removeClass('@hlayout');
|
|
162
|
-
this.addClass('@vlayout vertical');
|
|
163
|
-
this.setContent([
|
|
164
|
-
label,
|
|
165
|
-
new layout_1.HLayout({ width, content: [this.m_ui_input, ...gadgets] })
|
|
166
|
-
]);
|
|
167
|
-
}
|
|
168
|
-
else {
|
|
169
|
-
this.addClass('@hlayout');
|
|
170
|
-
this.setContent([label, this.m_ui_input, ...gadgets]);
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
enable(ena) {
|
|
174
|
-
if (ena === true) {
|
|
175
|
-
this.m_ui_input.enable();
|
|
176
|
-
}
|
|
177
|
-
super.enable(ena);
|
|
178
|
-
}
|
|
179
|
-
disable() {
|
|
180
|
-
this.m_ui_input.disable();
|
|
181
|
-
super.disable();
|
|
182
|
-
}
|
|
183
|
-
_btnClick() {
|
|
184
|
-
this.emit('click', (0, x4events_1.EvClick)(this.value));
|
|
185
|
-
}
|
|
186
|
-
/**
|
|
187
|
-
* select the value format for input/output on textedit of type date
|
|
188
|
-
* cf. formatIntlDate / parseIntlDate
|
|
189
|
-
* @param fmt
|
|
190
|
-
*/
|
|
191
|
-
setDateStoreFormat(fmt) {
|
|
192
|
-
this.m_props.format = fmt;
|
|
193
|
-
}
|
|
194
|
-
setStoreValue(value) {
|
|
195
|
-
this.m_ui_input.setStoreValue(value);
|
|
196
|
-
}
|
|
197
|
-
getStoreValue() {
|
|
198
|
-
return this.m_ui_input.getStoreValue();
|
|
199
|
-
}
|
|
200
|
-
_date_get_hook() {
|
|
201
|
-
let date = (0, tools_1.parseIntlDate)(this.value);
|
|
202
|
-
let props = this.m_props;
|
|
203
|
-
if (props.format == 'native') {
|
|
204
|
-
return date;
|
|
205
|
-
}
|
|
206
|
-
else {
|
|
207
|
-
return date ? (0, tools_1.formatIntlDate)(date, props.format) : null;
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
_date_set_hook(dte) {
|
|
211
|
-
let props = this.m_props;
|
|
212
|
-
if (props.format == 'native') {
|
|
213
|
-
this.value = (0, tools_1.formatIntlDate)(dte);
|
|
214
|
-
}
|
|
215
|
-
else if (dte) {
|
|
216
|
-
let date = (0, tools_1.parseIntlDate)(dte, props.format);
|
|
217
|
-
this.value = (0, tools_1.formatIntlDate)(date);
|
|
218
|
-
}
|
|
219
|
-
else {
|
|
220
|
-
this.value = '';
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
showError(text) {
|
|
224
|
-
if (!this.m_error_tip) {
|
|
225
|
-
this.m_error_tip = new tooltips_1.Tooltip({ cls: 'error' });
|
|
226
|
-
x4dom_1.x4document.body.appendChild(this.m_error_tip._build());
|
|
227
|
-
}
|
|
228
|
-
let rc = this.m_ui_input.getBoundingRect();
|
|
229
|
-
this.m_error_tip.text = text;
|
|
230
|
-
this.m_error_tip.displayAt(rc.right, rc.top, 'top left');
|
|
231
|
-
this.addClass('@error');
|
|
232
|
-
}
|
|
233
|
-
clearError() {
|
|
234
|
-
if (this.m_error_tip) {
|
|
235
|
-
this.m_error_tip.hide();
|
|
236
|
-
this.removeClass('@error');
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
get value() {
|
|
240
|
-
if (this.m_ui_input) {
|
|
241
|
-
return this.m_ui_input.value;
|
|
242
|
-
}
|
|
243
|
-
else {
|
|
244
|
-
return this.m_props.value;
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
set value(value) {
|
|
248
|
-
if (this.m_ui_input) {
|
|
249
|
-
this.m_ui_input.value = value;
|
|
250
|
-
}
|
|
251
|
-
else {
|
|
252
|
-
this.m_props.value = value;
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
/**
|
|
256
|
-
* select all the text
|
|
257
|
-
*/
|
|
258
|
-
selectAll() {
|
|
259
|
-
this.m_ui_input.selectAll();
|
|
260
|
-
}
|
|
261
|
-
select(start, length = 9999) {
|
|
262
|
-
this.m_ui_input.select(start, length);
|
|
263
|
-
}
|
|
264
|
-
getSelection() {
|
|
265
|
-
return this.m_ui_input.getSelection();
|
|
266
|
-
}
|
|
267
|
-
set readOnly(ro) {
|
|
268
|
-
this.m_ui_input.readOnly = ro;
|
|
269
|
-
}
|
|
270
|
-
get label() {
|
|
271
|
-
var _a;
|
|
272
|
-
return (_a = this.itemWithRef('label')) === null || _a === void 0 ? void 0 : _a.text;
|
|
273
|
-
}
|
|
274
|
-
set label(text) {
|
|
275
|
-
this.itemWithRef('label').text = text;
|
|
276
|
-
}
|
|
277
|
-
/**
|
|
278
|
-
* content changed
|
|
279
|
-
* todo: should move into Input
|
|
280
|
-
*/
|
|
281
|
-
_change() {
|
|
282
|
-
let value = this.m_ui_input.value;
|
|
283
|
-
this.emit('change', (0, x4events_1.EvChange)(value));
|
|
284
|
-
}
|
|
285
|
-
/**
|
|
286
|
-
* getting focus
|
|
287
|
-
*/
|
|
288
|
-
_focus() {
|
|
289
|
-
this.clearError();
|
|
290
|
-
this.emit('focus', (0, component_1.EvFocus)(true));
|
|
291
|
-
}
|
|
292
|
-
/**
|
|
293
|
-
* loosing focus
|
|
294
|
-
* @param value
|
|
295
|
-
*/
|
|
296
|
-
_blur() {
|
|
297
|
-
this._validate(this.m_ui_input.value);
|
|
298
|
-
this.emit('focus', (0, component_1.EvFocus)(false));
|
|
299
|
-
}
|
|
300
|
-
/**
|
|
301
|
-
* todo: should move into Input
|
|
302
|
-
* @returns
|
|
303
|
-
*/
|
|
304
|
-
validate() {
|
|
305
|
-
return this._validate(this.value);
|
|
306
|
-
}
|
|
307
|
-
_validate(value) {
|
|
308
|
-
let props = this.m_props;
|
|
309
|
-
let update = false;
|
|
310
|
-
if (props.required && value.length == 0) {
|
|
311
|
-
this.showError(i18n_1._tr.global.required_field);
|
|
312
|
-
return false;
|
|
313
|
-
}
|
|
314
|
-
if (value != '') {
|
|
315
|
-
let pattern = this.getAttribute('pattern');
|
|
316
|
-
if (pattern) {
|
|
317
|
-
let re = new RegExp(pattern);
|
|
318
|
-
if (re && !re.test(value)) {
|
|
319
|
-
this.showError(i18n_1._tr.global.invalid_format);
|
|
320
|
-
return false;
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
if (props.type == 'email') {
|
|
324
|
-
if (!reEmail.test(value.toLowerCase())) {
|
|
325
|
-
this.showError(i18n_1._tr.global.invalid_email);
|
|
326
|
-
return false;
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
else if (props.type == 'number') {
|
|
330
|
-
const v = parseFloat(value);
|
|
331
|
-
if (isNaN(v)) {
|
|
332
|
-
this.showError(i18n_1._tr.global.invalid_number);
|
|
333
|
-
return false;
|
|
334
|
-
}
|
|
335
|
-
let min = parseFloat(this.m_ui_input.getAttribute('min'));
|
|
336
|
-
if (min !== undefined && v < min) {
|
|
337
|
-
value = '' + min;
|
|
338
|
-
update = true;
|
|
339
|
-
}
|
|
340
|
-
let max = parseFloat(this.m_ui_input.getAttribute('max'));
|
|
341
|
-
if (max !== undefined && v > max) {
|
|
342
|
-
value = '' + max;
|
|
343
|
-
update = true;
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
if (props.validator) {
|
|
348
|
-
try {
|
|
349
|
-
this.value = props.validator(value);
|
|
350
|
-
}
|
|
351
|
-
catch (err) {
|
|
352
|
-
this.showError(err instanceof Error ? err.message : err);
|
|
353
|
-
return false;
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
else if (update) {
|
|
357
|
-
this.value = value;
|
|
358
|
-
}
|
|
359
|
-
return true;
|
|
360
|
-
}
|
|
361
|
-
_date_validator(value) {
|
|
362
|
-
value = value.trim();
|
|
363
|
-
if (value == '') {
|
|
364
|
-
return '';
|
|
365
|
-
}
|
|
366
|
-
let date;
|
|
367
|
-
if (value == '@') {
|
|
368
|
-
date = new Date();
|
|
369
|
-
}
|
|
370
|
-
else {
|
|
371
|
-
date = (0, tools_1.parseIntlDate)(value);
|
|
372
|
-
if (!date) {
|
|
373
|
-
throw (0, tools_1.sprintf)(i18n_1._tr.global.invalid_date, i18n_1._tr.global.date_format);
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
return (0, tools_1.formatIntlDate)(date);
|
|
377
|
-
}
|
|
378
|
-
//onKeyDown( e ) {
|
|
379
|
-
// if( this.readOnly ) {
|
|
380
|
-
// if( this.type=='date' && (e.key==' ' || e.key=='Enter') ) {
|
|
381
|
-
// this.showDatePicker( );
|
|
382
|
-
// e.stopPropagation( );
|
|
383
|
-
// e.preventDefault( );
|
|
384
|
-
// }
|
|
385
|
-
// }
|
|
386
|
-
//}
|
|
387
|
-
//onClick( e ) {
|
|
388
|
-
// if( this.readOnly ) {
|
|
389
|
-
// if( this.type=='date' ) {
|
|
390
|
-
// this.showDatePicker( );
|
|
391
|
-
// e.stopPropagation( );
|
|
392
|
-
// e.preventDefault( );
|
|
393
|
-
// }
|
|
394
|
-
// }
|
|
395
|
-
//}
|
|
396
|
-
_showDatePicker(btn) {
|
|
397
|
-
if (!this.m_cal_popup) {
|
|
398
|
-
this.m_cal_popup = new calendar_1.PopupCalendar({
|
|
399
|
-
change: (ev) => {
|
|
400
|
-
this.value = (0, tools_1.formatIntlDate)(ev.value);
|
|
401
|
-
this.m_cal_popup.close();
|
|
402
|
-
}
|
|
403
|
-
});
|
|
404
|
-
}
|
|
405
|
-
let rc = this.m_ui_input.getBoundingRect();
|
|
406
|
-
this.m_cal_popup.displayAt(rc.left, rc.bottom, 'top left');
|
|
407
|
-
}
|
|
408
|
-
get input() {
|
|
409
|
-
return this.m_ui_input;
|
|
410
|
-
}
|
|
411
|
-
get type() {
|
|
412
|
-
return this.m_props.type;
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
exports.TextEdit = TextEdit;
|
package/lib/cjs/toaster.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* ___ ___ __
|
|
4
|
-
* \ \_/ / / _
|
|
5
|
-
* \ / /_| |_
|
|
6
|
-
* / _ \____ _|
|
|
7
|
-
* /__/ \__\ |_|
|
|
8
|
-
*
|
|
9
|
-
* @file toaster.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.Toaster = void 0;
|
|
32
|
-
const label_1 = require("./label");
|
|
33
|
-
const popup_1 = require("./popup");
|
|
34
|
-
class Toaster extends popup_1.Popup {
|
|
35
|
-
constructor(props) {
|
|
36
|
-
super(props);
|
|
37
|
-
this.m_message = props.message;
|
|
38
|
-
this.m_icon = props.icon;
|
|
39
|
-
this.enableMask(false);
|
|
40
|
-
this.addClass('@non-maskable');
|
|
41
|
-
}
|
|
42
|
-
/** @ignore */
|
|
43
|
-
render() {
|
|
44
|
-
this.addClass('@hlayout');
|
|
45
|
-
this.setContent([
|
|
46
|
-
new label_1.Label({ icon: this.m_icon, text: this.m_message })
|
|
47
|
-
]);
|
|
48
|
-
}
|
|
49
|
-
show() {
|
|
50
|
-
this.show = super.show;
|
|
51
|
-
this.displayAt(9999, 9999, 'br', { x: 0, y: -24 });
|
|
52
|
-
let opacity = 1.0;
|
|
53
|
-
this.startTimer('fadeout', 2000, false, () => {
|
|
54
|
-
this.startTimer('opacity', 100, true, () => {
|
|
55
|
-
this.setStyleValue('opacity', opacity);
|
|
56
|
-
opacity -= 0.1;
|
|
57
|
-
if (opacity < 0) {
|
|
58
|
-
this.dispose();
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
exports.Toaster = Toaster;
|