x4js 1.5.33 → 1.5.35
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/cjs/index.js +7 -7
- package/lib/cjs/index.js.map +3 -3
- package/lib/esm/index.mjs +64 -29
- package/lib/esm/index.mjs.map +2 -2
- package/lib/src/i18n.ts +63 -34
- package/lib/src/i18n.ts.bak +347 -0
- package/lib/src/label.ts +25 -1
- package/lib/src/version.ts +1 -1
- package/lib/types/label.d.ts +9 -0
- package/lib/types/version.d.ts +1 -1
- package/package.json +1 -1
package/lib/esm/index.mjs
CHANGED
|
@@ -402,23 +402,57 @@ function addTranslation(name, ...parts) {
|
|
|
402
402
|
}
|
|
403
403
|
const lang = languages[name];
|
|
404
404
|
parts.forEach((p) => {
|
|
405
|
-
_patch(lang.src_translations, p
|
|
405
|
+
_patch(lang.src_translations, p);
|
|
406
406
|
});
|
|
407
|
-
lang.translations =
|
|
407
|
+
lang.translations = _proxyfy(lang.src_translations, lang.base, true);
|
|
408
408
|
}
|
|
409
409
|
__name(addTranslation, "addTranslation");
|
|
410
|
-
function _patch(obj, by
|
|
410
|
+
function _patch(obj, by) {
|
|
411
411
|
for (let n in by) {
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
obj[n]
|
|
412
|
+
const src = by[n];
|
|
413
|
+
if (typeof src === "string") {
|
|
414
|
+
obj[n] = src;
|
|
415
|
+
} else {
|
|
416
|
+
if (Array.isArray(src) && (!obj[n] || !Array.isArray(obj[n]))) {
|
|
417
|
+
obj[n] = [...src];
|
|
418
|
+
} else if (!obj[n] || typeof obj[n] !== "object") {
|
|
419
|
+
obj[n] = { ...src };
|
|
420
|
+
} else {
|
|
421
|
+
_patch(obj[n], by[n]);
|
|
422
|
+
}
|
|
417
423
|
}
|
|
418
424
|
}
|
|
419
|
-
return obj;
|
|
420
425
|
}
|
|
421
426
|
__name(_patch, "_patch");
|
|
427
|
+
function _proxyfy(obj, base, root) {
|
|
428
|
+
const result = {};
|
|
429
|
+
for (const n in obj) {
|
|
430
|
+
if (typeof obj[n] !== "string" && !Array.isArray(obj[n])) {
|
|
431
|
+
result[n] = _proxyfy(obj[n], base, false);
|
|
432
|
+
} else {
|
|
433
|
+
result[n] = obj[n];
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
return _mk_proxy(result, base, root);
|
|
437
|
+
}
|
|
438
|
+
__name(_proxyfy, "_proxyfy");
|
|
439
|
+
function _mk_proxy(obj, base, root) {
|
|
440
|
+
return new Proxy(obj, {
|
|
441
|
+
get: (target, prop) => {
|
|
442
|
+
if (root) {
|
|
443
|
+
req_path = [prop];
|
|
444
|
+
} else {
|
|
445
|
+
req_path.push(prop);
|
|
446
|
+
}
|
|
447
|
+
let value = target[prop];
|
|
448
|
+
if (value === void 0 && base) {
|
|
449
|
+
value = _findBaseTrans(base);
|
|
450
|
+
}
|
|
451
|
+
return value;
|
|
452
|
+
}
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
__name(_mk_proxy, "_mk_proxy");
|
|
422
456
|
var req_path;
|
|
423
457
|
function _findBaseTrans(base) {
|
|
424
458
|
while (base) {
|
|
@@ -441,24 +475,6 @@ function _findBaseTrans(base) {
|
|
|
441
475
|
return void 0;
|
|
442
476
|
}
|
|
443
477
|
__name(_findBaseTrans, "_findBaseTrans");
|
|
444
|
-
function _mk_proxy(obj, base, root) {
|
|
445
|
-
return new Proxy(obj, {
|
|
446
|
-
get: (target, prop) => {
|
|
447
|
-
if (root) {
|
|
448
|
-
req_path = [prop];
|
|
449
|
-
} else {
|
|
450
|
-
req_path.push(prop);
|
|
451
|
-
}
|
|
452
|
-
let value = target[prop];
|
|
453
|
-
if (value === void 0 && base) {
|
|
454
|
-
value = _findBaseTrans(base);
|
|
455
|
-
target[prop] = value;
|
|
456
|
-
}
|
|
457
|
-
return value;
|
|
458
|
-
}
|
|
459
|
-
});
|
|
460
|
-
}
|
|
461
|
-
__name(_mk_proxy, "_mk_proxy");
|
|
462
478
|
var _tr = {};
|
|
463
479
|
function selectLanguage(name) {
|
|
464
480
|
if (!isLanguage(name)) {
|
|
@@ -4584,7 +4600,7 @@ var Label = class extends Component {
|
|
|
4584
4600
|
this.setTag("span");
|
|
4585
4601
|
this.addClass("@hlayout");
|
|
4586
4602
|
this.setContent([
|
|
4587
|
-
new Icon({ icon: props.icon }),
|
|
4603
|
+
new Icon({ id: "l_icon", icon: props.icon }),
|
|
4588
4604
|
new Component({ content: text, ref: "text" })
|
|
4589
4605
|
]);
|
|
4590
4606
|
}
|
|
@@ -4617,6 +4633,25 @@ var Label = class extends Component {
|
|
|
4617
4633
|
get text() {
|
|
4618
4634
|
return this.m_props.text;
|
|
4619
4635
|
}
|
|
4636
|
+
/**
|
|
4637
|
+
* change the displayed icon
|
|
4638
|
+
* @param icon - new icon
|
|
4639
|
+
*/
|
|
4640
|
+
set icon(icon) {
|
|
4641
|
+
let ico = this.itemWithRef("l_icon");
|
|
4642
|
+
if (ico) {
|
|
4643
|
+
ico.icon = icon;
|
|
4644
|
+
} else {
|
|
4645
|
+
this.update(0);
|
|
4646
|
+
}
|
|
4647
|
+
}
|
|
4648
|
+
/**
|
|
4649
|
+
*
|
|
4650
|
+
*/
|
|
4651
|
+
get icon() {
|
|
4652
|
+
let ico = this.itemWithRef("l_icon");
|
|
4653
|
+
return ico?.icon;
|
|
4654
|
+
}
|
|
4620
4655
|
};
|
|
4621
4656
|
__name(Label, "Label");
|
|
4622
4657
|
|
|
@@ -15711,7 +15746,7 @@ function setupWSMessaging(closeCB) {
|
|
|
15711
15746
|
__name(setupWSMessaging, "setupWSMessaging");
|
|
15712
15747
|
|
|
15713
15748
|
// src/version.ts
|
|
15714
|
-
var x4js_version = "1.5.
|
|
15749
|
+
var x4js_version = "1.5.35";
|
|
15715
15750
|
export {
|
|
15716
15751
|
AbsLayout,
|
|
15717
15752
|
Application,
|