x4js 1.4.3 → 1.4.6
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 +3 -2
- package/lib/application.js +15 -7
- package/lib/base64.js +5 -1
- package/lib/base_component.js +7 -3
- package/lib/button.js +24 -18
- package/lib/calendar.js +44 -39
- package/lib/canvas.js +9 -5
- package/lib/cardview.js +11 -7
- package/lib/checkbox.js +12 -8
- package/lib/color.js +7 -3
- package/lib/colorpicker.js +86 -80
- package/lib/combobox.js +26 -22
- package/lib/component.js +65 -48
- package/lib/datastore.js +29 -20
- package/lib/dialog.js +41 -36
- package/lib/dom_events.js +2 -1
- 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.js +7 -3
- package/lib/i18n.js +11 -5
- package/lib/icon.js +16 -11
- package/lib/image.js +7 -3
- package/lib/index.d.ts +55 -0
- package/lib/index.js +71 -56
- package/lib/input.js +6 -2
- package/lib/label.js +15 -11
- package/lib/layout.js +23 -13
- package/lib/link.js +9 -5
- package/lib/listview.js +34 -27
- package/lib/md5.js +5 -1
- package/lib/menu.js +27 -19
- package/lib/messagebox.js +22 -17
- package/lib/panel.js +13 -9
- package/lib/popup.js +25 -20
- 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.d.ts +1 -8
- package/lib/router.js +4 -0
- package/lib/settings.js +8 -4
- package/lib/sidebarview.js +12 -8
- package/lib/smartedit.js +16 -11
- package/lib/spreadsheet.js +35 -31
- package/lib/styles.js +15 -9
- 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.js +97 -51
- package/lib/tooltips.js +14 -9
- package/lib/treeview.js +30 -26
- package/lib/x4_events.js +21 -9
- package/package.json +2 -1
- package/src/application.ts +8 -4
- package/src/index.ts +55 -0
- package/src/router.ts +1 -1
- package/tsconfig.json +2 -1
- package/lib/list.txt +0 -56
- package/list.txt +0 -0
package/lib/component.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* ___ ___ __
|
|
3
4
|
* \ \/ / / _
|
|
@@ -22,15 +23,20 @@
|
|
|
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
|
*/
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
exports.Container = exports.SizerOverlay = exports.EvOverlayResize = exports.Separator = exports.EvSize = exports.Space = exports.Flex = exports.flyWrap = exports.Component = exports.EvFocus = exports.EvDblClick = exports.html = exports.isHtmlString = exports.HtmlString = void 0;
|
|
25
28
|
/**
|
|
26
29
|
* @todo
|
|
27
30
|
* create Container class
|
|
28
31
|
*/
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
const tools_1 = require("./tools");
|
|
33
|
+
const styles_1 = require("./styles");
|
|
34
|
+
const x4_events_1 = require("./x4_events");
|
|
35
|
+
const base_component_1 = require("./base_component");
|
|
36
|
+
var tools_2 = require("./tools");
|
|
37
|
+
Object.defineProperty(exports, "HtmlString", { enumerable: true, get: function () { return tools_2.HtmlString; } });
|
|
38
|
+
Object.defineProperty(exports, "isHtmlString", { enumerable: true, get: function () { return tools_2.isHtmlString; } });
|
|
39
|
+
Object.defineProperty(exports, "html", { enumerable: true, get: function () { return tools_2.html; } });
|
|
34
40
|
/** @ignore classname prefix for system classes */
|
|
35
41
|
const _x4_ns_prefix = 'x-';
|
|
36
42
|
// -- elements -----------
|
|
@@ -60,16 +66,18 @@ const passiveEvents = {
|
|
|
60
66
|
};
|
|
61
67
|
/** ignore */
|
|
62
68
|
const reNumber = /^-?\d+(\.\d+)?$/;
|
|
63
|
-
|
|
64
|
-
return BasicEvent({ context });
|
|
69
|
+
function EvDblClick(context = null) {
|
|
70
|
+
return (0, x4_events_1.BasicEvent)({ context });
|
|
65
71
|
}
|
|
66
|
-
|
|
67
|
-
|
|
72
|
+
exports.EvDblClick = EvDblClick;
|
|
73
|
+
function EvFocus(focus = true, context = null) {
|
|
74
|
+
return (0, x4_events_1.BasicEvent)({ focus, context });
|
|
68
75
|
}
|
|
76
|
+
exports.EvFocus = EvFocus;
|
|
69
77
|
/**
|
|
70
78
|
*
|
|
71
79
|
*/
|
|
72
|
-
|
|
80
|
+
class Component extends base_component_1.BaseComponent {
|
|
73
81
|
m_dom;
|
|
74
82
|
m_iprops;
|
|
75
83
|
static __sb_width; // scrollbar width
|
|
@@ -124,7 +132,7 @@ export class Component extends BaseComponent {
|
|
|
124
132
|
if (!this.m_props.content) {
|
|
125
133
|
this.m_props.content = [];
|
|
126
134
|
}
|
|
127
|
-
else if (!isArray(this.m_props.content)) {
|
|
135
|
+
else if (!(0, tools_1.isArray)(this.m_props.content)) {
|
|
128
136
|
this.m_props.content = [this.m_props.content];
|
|
129
137
|
}
|
|
130
138
|
this.m_props.content.push(c);
|
|
@@ -132,7 +140,7 @@ export class Component extends BaseComponent {
|
|
|
132
140
|
this._appendChild(c);
|
|
133
141
|
}
|
|
134
142
|
};
|
|
135
|
-
if (isArray(content)) {
|
|
143
|
+
if ((0, tools_1.isArray)(content)) {
|
|
136
144
|
content.forEach(append);
|
|
137
145
|
}
|
|
138
146
|
else {
|
|
@@ -256,7 +264,7 @@ export class Component extends BaseComponent {
|
|
|
256
264
|
if (value === undefined) {
|
|
257
265
|
value = null;
|
|
258
266
|
}
|
|
259
|
-
else if (!_x4_unitless[name] && (isNumber(value) || reNumber.test(value))) {
|
|
267
|
+
else if (!_x4_unitless[name] && ((0, tools_1.isNumber)(value) || reNumber.test(value))) {
|
|
260
268
|
value = value + 'px';
|
|
261
269
|
}
|
|
262
270
|
this.m_dom.style[name] = value;
|
|
@@ -268,9 +276,9 @@ export class Component extends BaseComponent {
|
|
|
268
276
|
*/
|
|
269
277
|
getComputedStyle(pseudoElt) {
|
|
270
278
|
if (this.dom) {
|
|
271
|
-
return new ComputedStyle(getComputedStyle(this.dom, pseudoElt ?? null));
|
|
279
|
+
return new styles_1.ComputedStyle(getComputedStyle(this.dom, pseudoElt ?? null));
|
|
272
280
|
}
|
|
273
|
-
return new ComputedStyle(this.m_props.style);
|
|
281
|
+
return new styles_1.ComputedStyle(this.m_props.style);
|
|
274
282
|
}
|
|
275
283
|
/**
|
|
276
284
|
* return a single stype value
|
|
@@ -301,7 +309,7 @@ export class Component extends BaseComponent {
|
|
|
301
309
|
if (value === true) {
|
|
302
310
|
value = '';
|
|
303
311
|
}
|
|
304
|
-
else if (isNumber(value)) {
|
|
312
|
+
else if ((0, tools_1.isNumber)(value)) {
|
|
305
313
|
value = '' + value;
|
|
306
314
|
}
|
|
307
315
|
let attrs = this.m_props.attrs;
|
|
@@ -620,17 +628,17 @@ export class Component extends BaseComponent {
|
|
|
620
628
|
// create children
|
|
621
629
|
let content = props.content;
|
|
622
630
|
if (content) {
|
|
623
|
-
if (!isArray(content)) {
|
|
631
|
+
if (!(0, tools_1.isArray)(content)) {
|
|
624
632
|
content = [content];
|
|
625
633
|
}
|
|
626
634
|
content.forEach((el) => {
|
|
627
635
|
if (!el) {
|
|
628
636
|
return;
|
|
629
637
|
}
|
|
630
|
-
if (isString(el)) {
|
|
638
|
+
if ((0, tools_1.isString)(el)) {
|
|
631
639
|
this.m_dom.insertAdjacentText('beforeend', el);
|
|
632
640
|
}
|
|
633
|
-
else if (isHtmlString(el)) {
|
|
641
|
+
else if ((0, tools_1.isHtmlString)(el)) {
|
|
634
642
|
this.m_dom.insertAdjacentHTML('beforeend', el);
|
|
635
643
|
}
|
|
636
644
|
else if (el instanceof Component) {
|
|
@@ -753,14 +761,14 @@ export class Component extends BaseComponent {
|
|
|
753
761
|
let content = this.m_props.content;
|
|
754
762
|
// create children
|
|
755
763
|
if (content) {
|
|
756
|
-
if (!isArray(content)) {
|
|
764
|
+
if (!(0, tools_1.isArray)(content)) {
|
|
757
765
|
content = [content];
|
|
758
766
|
}
|
|
759
767
|
content.forEach((el) => {
|
|
760
768
|
if (!el) {
|
|
761
769
|
return;
|
|
762
770
|
}
|
|
763
|
-
if (isHtmlString(el)) {
|
|
771
|
+
if ((0, tools_1.isHtmlString)(el)) {
|
|
764
772
|
this.m_dom.insertAdjacentHTML('beforeend', el);
|
|
765
773
|
}
|
|
766
774
|
else if (el instanceof Component) {
|
|
@@ -781,7 +789,7 @@ export class Component extends BaseComponent {
|
|
|
781
789
|
getBoundingRect(withMargins = false) {
|
|
782
790
|
console.assert(this.dom != null, 'cannot get bounding rect of an non DOM element');
|
|
783
791
|
let r = this.dom.getBoundingClientRect();
|
|
784
|
-
let rc = new Rect(r.left, r.top, r.width, r.height);
|
|
792
|
+
let rc = new tools_1.Rect(r.left, r.top, r.width, r.height);
|
|
785
793
|
if (withMargins) {
|
|
786
794
|
let st = this.getComputedStyle();
|
|
787
795
|
let tm = st.parse('marginTop'), bm = st.parse('marginBottom'), lm = st.parse('marginLeft'), rm = st.parse('marginRight');
|
|
@@ -977,11 +985,11 @@ export class Component extends BaseComponent {
|
|
|
977
985
|
if (!content) {
|
|
978
986
|
return;
|
|
979
987
|
}
|
|
980
|
-
if (!isArray(content)) {
|
|
988
|
+
if (!(0, tools_1.isArray)(content)) {
|
|
981
989
|
content = [content];
|
|
982
990
|
}
|
|
983
991
|
content.some((el) => {
|
|
984
|
-
if (!el || isString(el) || isHtmlString(el)) {
|
|
992
|
+
if (!el || (0, tools_1.isString)(el) || (0, tools_1.isHtmlString)(el)) {
|
|
985
993
|
return;
|
|
986
994
|
}
|
|
987
995
|
if (cb(el)) {
|
|
@@ -999,10 +1007,10 @@ export class Component extends BaseComponent {
|
|
|
999
1007
|
* @param props child to append (or string)
|
|
1000
1008
|
*/
|
|
1001
1009
|
_appendChild(el) {
|
|
1002
|
-
if (isString(el)) {
|
|
1010
|
+
if ((0, tools_1.isString)(el)) {
|
|
1003
1011
|
this.m_dom.insertAdjacentText('beforeend', el);
|
|
1004
1012
|
}
|
|
1005
|
-
else if (isHtmlString(el)) {
|
|
1013
|
+
else if ((0, tools_1.isHtmlString)(el)) {
|
|
1006
1014
|
this.m_dom.insertAdjacentHTML('beforeend', el);
|
|
1007
1015
|
}
|
|
1008
1016
|
else {
|
|
@@ -1027,7 +1035,7 @@ export class Component extends BaseComponent {
|
|
|
1027
1035
|
let me = Object.getPrototypeOf(this);
|
|
1028
1036
|
while (me && me.constructor !== Component) {
|
|
1029
1037
|
let clsname = me.constructor.name;
|
|
1030
|
-
this.addClass('@' + pascalCase(clsname));
|
|
1038
|
+
this.addClass('@' + (0, tools_1.pascalCase)(clsname));
|
|
1031
1039
|
me = Object.getPrototypeOf(me);
|
|
1032
1040
|
}
|
|
1033
1041
|
this.addClass(this.m_props.cls);
|
|
@@ -1126,7 +1134,7 @@ export class Component extends BaseComponent {
|
|
|
1126
1134
|
*/
|
|
1127
1135
|
scrollIntoView(arg) {
|
|
1128
1136
|
if (this.m_dom) {
|
|
1129
|
-
const rel = new Rect(this.dom.getBoundingClientRect());
|
|
1137
|
+
const rel = new tools_1.Rect(this.dom.getBoundingClientRect());
|
|
1130
1138
|
let top = undefined;
|
|
1131
1139
|
let bot = undefined;
|
|
1132
1140
|
let left = undefined;
|
|
@@ -1211,7 +1219,7 @@ export class Component extends BaseComponent {
|
|
|
1211
1219
|
*/
|
|
1212
1220
|
static getCss() {
|
|
1213
1221
|
if (!Component.__css) {
|
|
1214
|
-
Component.__css = new Stylesheet();
|
|
1222
|
+
Component.__css = new styles_1.Stylesheet();
|
|
1215
1223
|
}
|
|
1216
1224
|
return Component.__css;
|
|
1217
1225
|
}
|
|
@@ -1242,7 +1250,7 @@ export class Component extends BaseComponent {
|
|
|
1242
1250
|
*/
|
|
1243
1251
|
static getElement(dom, classname) {
|
|
1244
1252
|
if (classname) {
|
|
1245
|
-
const srhCls = isString(classname);
|
|
1253
|
+
const srhCls = (0, tools_1.isString)(classname);
|
|
1246
1254
|
while (dom) {
|
|
1247
1255
|
let el = dom[_x4_el_sym];
|
|
1248
1256
|
if (srhCls) {
|
|
@@ -1288,6 +1296,7 @@ export class Component extends BaseComponent {
|
|
|
1288
1296
|
return (this.m_dom.offsetParent !== null);
|
|
1289
1297
|
}
|
|
1290
1298
|
}
|
|
1299
|
+
exports.Component = Component;
|
|
1291
1300
|
/** @ignore */
|
|
1292
1301
|
let fly_element = null;
|
|
1293
1302
|
/**
|
|
@@ -1295,7 +1304,7 @@ let fly_element = null;
|
|
|
1295
1304
|
* @param dom dom element to wrap
|
|
1296
1305
|
* @review qui libere le fly_element ? -> timeout
|
|
1297
1306
|
*/
|
|
1298
|
-
|
|
1307
|
+
function flyWrap(dom) {
|
|
1299
1308
|
if (dom[_x4_el_sym]) {
|
|
1300
1309
|
return dom[_x4_el_sym];
|
|
1301
1310
|
}
|
|
@@ -1306,10 +1315,11 @@ export function flyWrap(dom) {
|
|
|
1306
1315
|
f.m_dom = dom;
|
|
1307
1316
|
return f;
|
|
1308
1317
|
}
|
|
1318
|
+
exports.flyWrap = flyWrap;
|
|
1309
1319
|
/**
|
|
1310
1320
|
* simple flex spacer
|
|
1311
1321
|
*/
|
|
1312
|
-
|
|
1322
|
+
class Flex extends Component {
|
|
1313
1323
|
constructor(props = {}) {
|
|
1314
1324
|
if (!props.flex) {
|
|
1315
1325
|
props.flex = 1;
|
|
@@ -1317,10 +1327,11 @@ export class Flex extends Component {
|
|
|
1317
1327
|
super(props);
|
|
1318
1328
|
}
|
|
1319
1329
|
}
|
|
1330
|
+
exports.Flex = Flex;
|
|
1320
1331
|
/**
|
|
1321
1332
|
* simple space between 2 elements
|
|
1322
1333
|
*/
|
|
1323
|
-
|
|
1334
|
+
class Space extends Component {
|
|
1324
1335
|
m_size;
|
|
1325
1336
|
constructor(size) {
|
|
1326
1337
|
super({});
|
|
@@ -1348,10 +1359,12 @@ export class Space extends Component {
|
|
|
1348
1359
|
this.setStyle(style);
|
|
1349
1360
|
}
|
|
1350
1361
|
}
|
|
1351
|
-
|
|
1352
|
-
|
|
1362
|
+
exports.Space = Space;
|
|
1363
|
+
function EvSize(size, mode = null, context = null) {
|
|
1364
|
+
return (0, x4_events_1.BasicEvent)({ size, mode, context });
|
|
1353
1365
|
}
|
|
1354
|
-
|
|
1366
|
+
exports.EvSize = EvSize;
|
|
1367
|
+
class Separator extends Component {
|
|
1355
1368
|
m_irect;
|
|
1356
1369
|
m_delta;
|
|
1357
1370
|
m_target;
|
|
@@ -1426,7 +1439,7 @@ export class Separator extends Component {
|
|
|
1426
1439
|
width = (ex - this.m_delta) - this.m_irect.left;
|
|
1427
1440
|
}
|
|
1428
1441
|
if (width > 0) {
|
|
1429
|
-
let size = new Size(width, 0);
|
|
1442
|
+
let size = new tools_1.Size(width, 0);
|
|
1430
1443
|
this.emit('resize', EvSize(size));
|
|
1431
1444
|
this.m_target.setStyleValue('width', size.width);
|
|
1432
1445
|
this.m_target.setStyleValue('flex', null); // for flex>1
|
|
@@ -1442,7 +1455,7 @@ export class Separator extends Component {
|
|
|
1442
1455
|
height = (ey - this.m_delta) - this.m_irect.top;
|
|
1443
1456
|
}
|
|
1444
1457
|
if (height > 0) {
|
|
1445
|
-
let size = new Size(0, height);
|
|
1458
|
+
let size = new tools_1.Size(0, height);
|
|
1446
1459
|
this.emit('resize', EvSize(size));
|
|
1447
1460
|
this.m_target.setStyleValue('height', size.height);
|
|
1448
1461
|
this.m_target.setStyleValue('flex', null); // for flex>1
|
|
@@ -1490,10 +1503,12 @@ export class Separator extends Component {
|
|
|
1490
1503
|
}
|
|
1491
1504
|
}
|
|
1492
1505
|
}
|
|
1493
|
-
|
|
1494
|
-
|
|
1506
|
+
exports.Separator = Separator;
|
|
1507
|
+
function EvOverlayResize(ui_event, sens, context = null) {
|
|
1508
|
+
return (0, x4_events_1.BasicEvent)({ ui_event, sens, context });
|
|
1495
1509
|
}
|
|
1496
|
-
|
|
1510
|
+
exports.EvOverlayResize = EvOverlayResize;
|
|
1511
|
+
class SizerOverlay extends Component {
|
|
1497
1512
|
m_delta;
|
|
1498
1513
|
m_irect;
|
|
1499
1514
|
constructor(props) {
|
|
@@ -1522,7 +1537,7 @@ export class SizerOverlay extends Component {
|
|
|
1522
1537
|
if (eev.defaultPrevented) {
|
|
1523
1538
|
return;
|
|
1524
1539
|
}
|
|
1525
|
-
let pos = getMousePos(ev, true);
|
|
1540
|
+
let pos = (0, tools_1.getMousePos)(ev, true);
|
|
1526
1541
|
this.m_irect = this.m_props.target.getBoundingRect();
|
|
1527
1542
|
if (this.m_props.sens == 'right') {
|
|
1528
1543
|
this.m_delta = pos.x - this.m_irect.right;
|
|
@@ -1575,7 +1590,7 @@ export class SizerOverlay extends Component {
|
|
|
1575
1590
|
height = (ey - this.m_delta) - this.m_irect.top;
|
|
1576
1591
|
}
|
|
1577
1592
|
if (height > 0) {
|
|
1578
|
-
let size = new Size(0, height);
|
|
1593
|
+
let size = new tools_1.Size(0, height);
|
|
1579
1594
|
this.emit('resize', EvSize(size));
|
|
1580
1595
|
this.m_props.target.setStyleValue('height', size.height);
|
|
1581
1596
|
this.m_props.target.setStyleValue('flex', null); // for flex>1
|
|
@@ -1603,8 +1618,9 @@ export class SizerOverlay extends Component {
|
|
|
1603
1618
|
}
|
|
1604
1619
|
}
|
|
1605
1620
|
}
|
|
1621
|
+
exports.SizerOverlay = SizerOverlay;
|
|
1606
1622
|
function EvShortcut(name) {
|
|
1607
|
-
return BasicEvent({ name });
|
|
1623
|
+
return (0, x4_events_1.BasicEvent)({ name });
|
|
1608
1624
|
}
|
|
1609
1625
|
/**
|
|
1610
1626
|
* you can construct a Container as usual with it's properties but also directly with it's children array
|
|
@@ -1615,10 +1631,10 @@ function EvShortcut(name) {
|
|
|
1615
1631
|
* child2
|
|
1616
1632
|
* ])
|
|
1617
1633
|
*/
|
|
1618
|
-
|
|
1634
|
+
class Container extends Component {
|
|
1619
1635
|
m_shortcuts;
|
|
1620
1636
|
constructor(props) {
|
|
1621
|
-
if (isArray(props)) {
|
|
1637
|
+
if ((0, tools_1.isArray)(props)) {
|
|
1622
1638
|
super({ content: props });
|
|
1623
1639
|
}
|
|
1624
1640
|
else {
|
|
@@ -1636,7 +1652,7 @@ export class Container extends Component {
|
|
|
1636
1652
|
this.m_shortcuts = [];
|
|
1637
1653
|
this.setDomEvent('keydown', (e) => this._handleKeydown(e));
|
|
1638
1654
|
}
|
|
1639
|
-
if (!isArray(sequence)) {
|
|
1655
|
+
if (!(0, tools_1.isArray)(sequence)) {
|
|
1640
1656
|
sequence = [sequence];
|
|
1641
1657
|
}
|
|
1642
1658
|
sequence.forEach((seq) => {
|
|
@@ -1697,7 +1713,7 @@ export class Container extends Component {
|
|
|
1697
1713
|
sk.callback(e);
|
|
1698
1714
|
}
|
|
1699
1715
|
else {
|
|
1700
|
-
asap(() => { sk.callback(e); });
|
|
1716
|
+
(0, tools_1.asap)(() => { sk.callback(e); });
|
|
1701
1717
|
}
|
|
1702
1718
|
}
|
|
1703
1719
|
else {
|
|
@@ -1710,3 +1726,4 @@ export class Container extends Component {
|
|
|
1710
1726
|
});
|
|
1711
1727
|
}
|
|
1712
1728
|
}
|
|
1729
|
+
exports.Container = Container;
|
package/lib/datastore.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* ___ ___ __
|
|
3
4
|
* \ \/ / / _
|
|
@@ -22,12 +23,14 @@
|
|
|
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.DataView = exports.EvViewChange = exports.DataStore = exports.DataProxy = exports.AutoRecord = exports.Record = exports.data = void 0;
|
|
28
|
+
const request_1 = require("./request");
|
|
29
|
+
const tools_1 = require("./tools");
|
|
30
|
+
const x4_events_1 = require("./x4_events");
|
|
31
|
+
const base_component_1 = require("./base_component");
|
|
29
32
|
function EvDataChange(type, id) {
|
|
30
|
-
return BasicEvent({ type, id });
|
|
33
|
+
return (0, x4_events_1.BasicEvent)({ type, id });
|
|
31
34
|
}
|
|
32
35
|
/**
|
|
33
36
|
*
|
|
@@ -66,7 +69,7 @@ function _getMetas(obj, create = true) {
|
|
|
66
69
|
}
|
|
67
70
|
return mfld;
|
|
68
71
|
}
|
|
69
|
-
|
|
72
|
+
var data;
|
|
70
73
|
(function (data_1) {
|
|
71
74
|
/**
|
|
72
75
|
* define a record id
|
|
@@ -171,11 +174,11 @@ export var data;
|
|
|
171
174
|
return data.field({ ...props, type: 'array', model: new ctor() });
|
|
172
175
|
}
|
|
173
176
|
data_1.array = array;
|
|
174
|
-
})(data || (data = {}));
|
|
177
|
+
})(data = exports.data || (exports.data = {}));
|
|
175
178
|
/**
|
|
176
179
|
* record model
|
|
177
180
|
*/
|
|
178
|
-
|
|
181
|
+
class Record {
|
|
179
182
|
constructor(data, id) {
|
|
180
183
|
if (data !== undefined) {
|
|
181
184
|
this.unSerialize(data, id);
|
|
@@ -287,7 +290,7 @@ export class Record {
|
|
|
287
290
|
return typeof (input) === 'number' ? input : parseInt(input);
|
|
288
291
|
}
|
|
289
292
|
case 'date': {
|
|
290
|
-
return isString(input) ? new Date(input) : input;
|
|
293
|
+
return (0, tools_1.isString)(input) ? new Date(input) : input;
|
|
291
294
|
}
|
|
292
295
|
case 'array': {
|
|
293
296
|
let result = [];
|
|
@@ -369,10 +372,11 @@ export class Record {
|
|
|
369
372
|
this.setRaw(fld.name, value);
|
|
370
373
|
}
|
|
371
374
|
}
|
|
375
|
+
exports.Record = Record;
|
|
372
376
|
/**
|
|
373
377
|
* by default, the field id is rhe first member or the record
|
|
374
378
|
*/
|
|
375
|
-
|
|
379
|
+
class AutoRecord extends Record {
|
|
376
380
|
m_data;
|
|
377
381
|
m_fid;
|
|
378
382
|
constructor(data) {
|
|
@@ -405,7 +409,8 @@ export class AutoRecord extends Record {
|
|
|
405
409
|
return new AutoRecord({ ...data });
|
|
406
410
|
}
|
|
407
411
|
}
|
|
408
|
-
|
|
412
|
+
exports.AutoRecord = AutoRecord;
|
|
413
|
+
class DataProxy extends base_component_1.BaseComponent {
|
|
409
414
|
constructor(props) {
|
|
410
415
|
super(props);
|
|
411
416
|
}
|
|
@@ -434,22 +439,23 @@ export class DataProxy extends BaseComponent {
|
|
|
434
439
|
}
|
|
435
440
|
else {
|
|
436
441
|
setTimeout(() => {
|
|
437
|
-
ajaxRequest({
|
|
442
|
+
(0, request_1.ajaxRequest)({
|
|
438
443
|
url: this.m_props.path,
|
|
439
444
|
method: 'GET',
|
|
440
445
|
params: this.m_props.params,
|
|
441
446
|
success: (data) => {
|
|
442
|
-
this.emit('change', EvChange(data));
|
|
447
|
+
this.emit('change', (0, x4_events_1.EvChange)(data));
|
|
443
448
|
}
|
|
444
449
|
});
|
|
445
450
|
}, delay);
|
|
446
451
|
}
|
|
447
452
|
}
|
|
448
453
|
}
|
|
454
|
+
exports.DataProxy = DataProxy;
|
|
449
455
|
/**
|
|
450
456
|
*
|
|
451
457
|
*/
|
|
452
|
-
|
|
458
|
+
class DataStore extends x4_events_1.EventSource {
|
|
453
459
|
m_model;
|
|
454
460
|
m_fields;
|
|
455
461
|
m_records;
|
|
@@ -680,7 +686,7 @@ export class DataStore extends EventSource {
|
|
|
680
686
|
return new Uint32Array(0);
|
|
681
687
|
}
|
|
682
688
|
let filterValue = filter.value;
|
|
683
|
-
if (isString(filterValue) && !filter.caseSensitive) {
|
|
689
|
+
if ((0, tools_1.isString)(filterValue) && !filter.caseSensitive) {
|
|
684
690
|
filterValue = filterValue.toUpperCase();
|
|
685
691
|
}
|
|
686
692
|
function _lt(recval) {
|
|
@@ -852,15 +858,17 @@ export class DataStore extends EventSource {
|
|
|
852
858
|
this.emit('data_change', EvDataChange('change'));
|
|
853
859
|
}
|
|
854
860
|
}
|
|
855
|
-
|
|
856
|
-
|
|
861
|
+
exports.DataStore = DataStore;
|
|
862
|
+
function EvViewChange(action) {
|
|
863
|
+
return (0, x4_events_1.BasicEvent)({ action });
|
|
857
864
|
}
|
|
865
|
+
exports.EvViewChange = EvViewChange;
|
|
858
866
|
/**
|
|
859
867
|
* Dataview allow different views of the DataStore.
|
|
860
868
|
* You can sort the columns & filter data
|
|
861
869
|
* You can have multiple views for a single DataStore
|
|
862
870
|
*/
|
|
863
|
-
|
|
871
|
+
class DataView extends base_component_1.BaseComponent {
|
|
864
872
|
m_index;
|
|
865
873
|
m_store;
|
|
866
874
|
m_sort;
|
|
@@ -873,10 +881,10 @@ export class DataView extends BaseComponent {
|
|
|
873
881
|
this.m_sort = null;
|
|
874
882
|
this.filter(props.filter);
|
|
875
883
|
if (props.order) {
|
|
876
|
-
if (isString(props.order)) {
|
|
884
|
+
if ((0, tools_1.isString)(props.order)) {
|
|
877
885
|
this.sort([{ field: props.order, ascending: true }]);
|
|
878
886
|
}
|
|
879
|
-
else if (isArray(props.order)) {
|
|
887
|
+
else if ((0, tools_1.isArray)(props.order)) {
|
|
880
888
|
this.sort(props.order);
|
|
881
889
|
}
|
|
882
890
|
else {
|
|
@@ -984,3 +992,4 @@ export class DataView extends BaseComponent {
|
|
|
984
992
|
});
|
|
985
993
|
}
|
|
986
994
|
}
|
|
995
|
+
exports.DataView = DataView;
|