@apia/util 0.1.0 → 0.2.2
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/LICENSE.md +20 -20
- package/README.md +18 -18
- package/dist/index.d.ts +92 -244
- package/dist/index.js +259 -245
- package/dist/index.js.map +1 -1
- package/dist/watchChanges.js +10 -0
- package/entries.json +1 -1
- package/package.json +3 -3
- package/cleanDist.json +0 -3
package/dist/index.js
CHANGED
|
@@ -1,18 +1,77 @@
|
|
|
1
|
-
import { isFunction, clone, cloneDeep } from 'lodash';
|
|
1
|
+
import { isFunction, uniqueId as uniqueId$1, clone, cloneDeep } from 'lodash';
|
|
2
2
|
import CryptoJS from 'crypto-js';
|
|
3
3
|
import dayjs from 'dayjs';
|
|
4
4
|
import customParseFormat from 'dayjs/plugin/customParseFormat';
|
|
5
5
|
import axios from 'axios';
|
|
6
6
|
import FileSaver from 'file-saver';
|
|
7
7
|
import * as React from 'react';
|
|
8
|
-
import React__default, { useRef, useState, useEffect,
|
|
9
|
-
import { jsx } from 'react/jsx-runtime';
|
|
10
|
-
import { Box } from 'theme-ui';
|
|
8
|
+
import React__default, { useRef, useMemo, useState, useEffect, useCallback, createContext, useContext } from 'react';
|
|
11
9
|
import { isFunction as isFunction$1, uniqueId } from 'lodash-es';
|
|
12
|
-
import {
|
|
10
|
+
import { jsx } from 'react/jsx-runtime';
|
|
13
11
|
import xml2js from 'xml2js';
|
|
14
12
|
import { parseBooleans, parseNumbers } from 'xml2js/lib/processors';
|
|
15
13
|
|
|
14
|
+
function addBoundary(definition, min, max, loop) {
|
|
15
|
+
const actualNumber = typeof definition === "number" ? definition : definition.number;
|
|
16
|
+
const actualMin = typeof definition === "number" ? min : definition.min;
|
|
17
|
+
const actualMax = typeof definition === "number" ? max : definition.max;
|
|
18
|
+
const isActualLoop = typeof definition === "number" ? loop : definition.loop;
|
|
19
|
+
let newNumber = Number(actualNumber != null ? actualNumber : 0);
|
|
20
|
+
if (actualMin !== void 0 && newNumber < actualMin) {
|
|
21
|
+
if (actualMax !== void 0 && isActualLoop) {
|
|
22
|
+
newNumber = actualMax;
|
|
23
|
+
} else {
|
|
24
|
+
newNumber = actualMin;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
if (actualMax !== void 0 && newNumber > actualMax) {
|
|
28
|
+
if (actualMin !== void 0 && isActualLoop) {
|
|
29
|
+
newNumber = actualMin;
|
|
30
|
+
} else {
|
|
31
|
+
newNumber = actualMax;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return newNumber;
|
|
35
|
+
}
|
|
36
|
+
const sizeUnits = ["b", "kb", "mb", "gb", "tb"];
|
|
37
|
+
function parseAsSize(num) {
|
|
38
|
+
let index = 0;
|
|
39
|
+
let finalSize = num;
|
|
40
|
+
if (finalSize === Infinity)
|
|
41
|
+
return "1000GB";
|
|
42
|
+
while (finalSize > 1024) {
|
|
43
|
+
finalSize /= 1024;
|
|
44
|
+
index++;
|
|
45
|
+
}
|
|
46
|
+
return `${Math.round(finalSize * 10) / 10}${sizeUnits[index]}`;
|
|
47
|
+
}
|
|
48
|
+
function noNaN(number, defaultReturn = 0) {
|
|
49
|
+
const returnNumber = Number(number);
|
|
50
|
+
if (number === null || Number.isNaN(returnNumber))
|
|
51
|
+
return defaultReturn;
|
|
52
|
+
return returnNumber;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function animate(duration, callback, onFinish) {
|
|
56
|
+
let initialTime = void 0;
|
|
57
|
+
let suscription;
|
|
58
|
+
function innerAnimate(current) {
|
|
59
|
+
if (initialTime === void 0)
|
|
60
|
+
initialTime = current;
|
|
61
|
+
const ellapsed = current - initialTime;
|
|
62
|
+
const progress = ellapsed / duration;
|
|
63
|
+
callback(addBoundary(progress, 0, 1));
|
|
64
|
+
if (progress < 1)
|
|
65
|
+
suscription = window.requestAnimationFrame(innerAnimate);
|
|
66
|
+
else
|
|
67
|
+
onFinish == null ? void 0 : onFinish();
|
|
68
|
+
}
|
|
69
|
+
suscription = window.requestAnimationFrame(innerAnimate);
|
|
70
|
+
return () => {
|
|
71
|
+
window.cancelAnimationFrame(suscription);
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
16
75
|
function arrayOrArray(o) {
|
|
17
76
|
if (o === void 0)
|
|
18
77
|
return [];
|
|
@@ -521,129 +580,6 @@ function usePanAndZoom(effectiveMargin = { left: 0, bottom: 0, right: 0, top: 0
|
|
|
521
580
|
};
|
|
522
581
|
}
|
|
523
582
|
|
|
524
|
-
var __accessCheck$5 = (obj, member, msg) => {
|
|
525
|
-
if (!member.has(obj))
|
|
526
|
-
throw TypeError("Cannot " + msg);
|
|
527
|
-
};
|
|
528
|
-
var __privateGet$5 = (obj, member, getter) => {
|
|
529
|
-
__accessCheck$5(obj, member, "read from private field");
|
|
530
|
-
return getter ? getter.call(obj) : member.get(obj);
|
|
531
|
-
};
|
|
532
|
-
var __privateAdd$5 = (obj, member, value) => {
|
|
533
|
-
if (member.has(obj))
|
|
534
|
-
throw TypeError("Cannot add the same private member more than once");
|
|
535
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
536
|
-
};
|
|
537
|
-
var _emitter;
|
|
538
|
-
function eventEmitter() {
|
|
539
|
-
const listeners = {};
|
|
540
|
-
return {
|
|
541
|
-
on(key, fn) {
|
|
542
|
-
var _a;
|
|
543
|
-
if (!Array.isArray(listeners[key]))
|
|
544
|
-
listeners[key] = [];
|
|
545
|
-
(_a = listeners[key]) == null ? void 0 : _a.push(fn);
|
|
546
|
-
return () => {
|
|
547
|
-
this.off(key, fn);
|
|
548
|
-
};
|
|
549
|
-
},
|
|
550
|
-
off(key, fn) {
|
|
551
|
-
var _a;
|
|
552
|
-
listeners[key] = ((_a = listeners[key]) != null ? _a : []).filter((cb) => {
|
|
553
|
-
return cb !== fn;
|
|
554
|
-
});
|
|
555
|
-
},
|
|
556
|
-
emit(key, data) {
|
|
557
|
-
var _a;
|
|
558
|
-
((_a = listeners[key]) != null ? _a : []).forEach((fn) => {
|
|
559
|
-
return fn(data);
|
|
560
|
-
});
|
|
561
|
-
}
|
|
562
|
-
};
|
|
563
|
-
}
|
|
564
|
-
class EventEmitter {
|
|
565
|
-
constructor() {
|
|
566
|
-
__privateAdd$5(this, _emitter, eventEmitter());
|
|
567
|
-
}
|
|
568
|
-
on(eventName, fn) {
|
|
569
|
-
__privateGet$5(this, _emitter).on(eventName, fn);
|
|
570
|
-
return () => {
|
|
571
|
-
__privateGet$5(this, _emitter).off(eventName, fn);
|
|
572
|
-
};
|
|
573
|
-
}
|
|
574
|
-
off(eventName, fn) {
|
|
575
|
-
__privateGet$5(this, _emitter).off(eventName, fn);
|
|
576
|
-
}
|
|
577
|
-
emit(eventName, params) {
|
|
578
|
-
__privateGet$5(this, _emitter).emit(eventName, params);
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
|
-
_emitter = new WeakMap();
|
|
582
|
-
|
|
583
|
-
var __accessCheck$4 = (obj, member, msg) => {
|
|
584
|
-
if (!member.has(obj))
|
|
585
|
-
throw TypeError("Cannot " + msg);
|
|
586
|
-
};
|
|
587
|
-
var __privateGet$4 = (obj, member, getter) => {
|
|
588
|
-
__accessCheck$4(obj, member, "read from private field");
|
|
589
|
-
return getter ? getter.call(obj) : member.get(obj);
|
|
590
|
-
};
|
|
591
|
-
var __privateAdd$4 = (obj, member, value) => {
|
|
592
|
-
if (member.has(obj))
|
|
593
|
-
throw TypeError("Cannot add the same private member more than once");
|
|
594
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
595
|
-
};
|
|
596
|
-
var __privateSet$3 = (obj, member, value, setter) => {
|
|
597
|
-
__accessCheck$4(obj, member, "write to private field");
|
|
598
|
-
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
599
|
-
return value;
|
|
600
|
-
};
|
|
601
|
-
var _value;
|
|
602
|
-
class WithEventsValue extends EventEmitter {
|
|
603
|
-
constructor(value) {
|
|
604
|
-
super();
|
|
605
|
-
__privateAdd$4(this, _value, void 0);
|
|
606
|
-
__privateSet$3(this, _value, value);
|
|
607
|
-
}
|
|
608
|
-
get value() {
|
|
609
|
-
return __privateGet$4(this, _value);
|
|
610
|
-
}
|
|
611
|
-
set value(value) {
|
|
612
|
-
__privateSet$3(this, _value, value);
|
|
613
|
-
this.emit("update", value);
|
|
614
|
-
}
|
|
615
|
-
}
|
|
616
|
-
_value = new WeakMap();
|
|
617
|
-
|
|
618
|
-
const AriaLiveEmitter = new class AriaLiveEmitterClass extends EventEmitter {
|
|
619
|
-
}();
|
|
620
|
-
const LiveRegion = () => {
|
|
621
|
-
const [live, setLive] = useState({
|
|
622
|
-
type: "assertive",
|
|
623
|
-
message: ""
|
|
624
|
-
});
|
|
625
|
-
useEffect(() => {
|
|
626
|
-
return AriaLiveEmitter.on("live", (ev) => {
|
|
627
|
-
if (ev.type === "reset") {
|
|
628
|
-
setLive({ type: "assertive", message: "" });
|
|
629
|
-
return;
|
|
630
|
-
}
|
|
631
|
-
if (ev.message === live.message)
|
|
632
|
-
return;
|
|
633
|
-
setTimeout(() => setLive(ev), 0);
|
|
634
|
-
});
|
|
635
|
-
}, [live.message]);
|
|
636
|
-
return /* @__PURE__ */ jsx(
|
|
637
|
-
Box,
|
|
638
|
-
{
|
|
639
|
-
role: "region",
|
|
640
|
-
sx: { transform: "translate(-50000px, -50000px)" },
|
|
641
|
-
"aria-live": live.type,
|
|
642
|
-
children: live.message
|
|
643
|
-
}
|
|
644
|
-
);
|
|
645
|
-
};
|
|
646
|
-
|
|
647
583
|
const customEvents = {
|
|
648
584
|
/**
|
|
649
585
|
* Indica que un elemento necesita recibir el foco,
|
|
@@ -725,15 +661,15 @@ function isChild(element, checkParent) {
|
|
|
725
661
|
return !!getSpecificParent(element, checkParent);
|
|
726
662
|
}
|
|
727
663
|
|
|
728
|
-
var __accessCheck$
|
|
664
|
+
var __accessCheck$5 = (obj, member, msg) => {
|
|
729
665
|
if (!member.has(obj))
|
|
730
666
|
throw TypeError("Cannot " + msg);
|
|
731
667
|
};
|
|
732
|
-
var __privateGet$
|
|
733
|
-
__accessCheck$
|
|
668
|
+
var __privateGet$5 = (obj, member, getter) => {
|
|
669
|
+
__accessCheck$5(obj, member, "read from private field");
|
|
734
670
|
return getter ? getter.call(obj) : member.get(obj);
|
|
735
671
|
};
|
|
736
|
-
var __privateAdd$
|
|
672
|
+
var __privateAdd$5 = (obj, member, value) => {
|
|
737
673
|
if (member.has(obj))
|
|
738
674
|
throw TypeError("Cannot add the same private member more than once");
|
|
739
675
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
@@ -742,7 +678,7 @@ var _parameters;
|
|
|
742
678
|
class Url {
|
|
743
679
|
constructor(baseUrl, defaultAllowMultiple = true) {
|
|
744
680
|
this.defaultAllowMultiple = defaultAllowMultiple;
|
|
745
|
-
__privateAdd$
|
|
681
|
+
__privateAdd$5(this, _parameters, {});
|
|
746
682
|
const [base, query] = baseUrl.split("?");
|
|
747
683
|
this.base = base;
|
|
748
684
|
query == null ? void 0 : query.split("&").forEach((current) => {
|
|
@@ -752,9 +688,9 @@ class Url {
|
|
|
752
688
|
}
|
|
753
689
|
addParameter(name, value, allowMultiple) {
|
|
754
690
|
if (allowMultiple === void 0 && !this.defaultAllowMultiple || allowMultiple === false)
|
|
755
|
-
__privateGet$
|
|
691
|
+
__privateGet$5(this, _parameters)[name] = String(value);
|
|
756
692
|
else
|
|
757
|
-
__privateGet$
|
|
693
|
+
__privateGet$5(this, _parameters)[name] = __privateGet$5(this, _parameters)[name] ? [...arrayOrArray(__privateGet$5(this, _parameters)[name]), String(value)] : [String(value)];
|
|
758
694
|
}
|
|
759
695
|
addParameters(parameters) {
|
|
760
696
|
parameters.forEach(
|
|
@@ -762,10 +698,10 @@ class Url {
|
|
|
762
698
|
);
|
|
763
699
|
}
|
|
764
700
|
getParameter(name) {
|
|
765
|
-
return __privateGet$
|
|
701
|
+
return __privateGet$5(this, _parameters)[name];
|
|
766
702
|
}
|
|
767
703
|
toString() {
|
|
768
|
-
const parametersArray = Object.entries(__privateGet$
|
|
704
|
+
const parametersArray = Object.entries(__privateGet$5(this, _parameters));
|
|
769
705
|
return `${this.base}${parametersArray.length > 0 ? `?${parametersArray.map(
|
|
770
706
|
([name, value]) => Array.isArray(value) ? value.map((current) => `${name}=${current}`).join("&") : `${name}=${String(value)}`
|
|
771
707
|
).join("&")}` : ""}`;
|
|
@@ -797,6 +733,100 @@ function enableChildrenFocus(parent) {
|
|
|
797
733
|
});
|
|
798
734
|
}
|
|
799
735
|
|
|
736
|
+
var __accessCheck$4 = (obj, member, msg) => {
|
|
737
|
+
if (!member.has(obj))
|
|
738
|
+
throw TypeError("Cannot " + msg);
|
|
739
|
+
};
|
|
740
|
+
var __privateGet$4 = (obj, member, getter) => {
|
|
741
|
+
__accessCheck$4(obj, member, "read from private field");
|
|
742
|
+
return getter ? getter.call(obj) : member.get(obj);
|
|
743
|
+
};
|
|
744
|
+
var __privateAdd$4 = (obj, member, value) => {
|
|
745
|
+
if (member.has(obj))
|
|
746
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
747
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
748
|
+
};
|
|
749
|
+
var _emitter;
|
|
750
|
+
function eventEmitter() {
|
|
751
|
+
const listeners = {};
|
|
752
|
+
return {
|
|
753
|
+
on(key, fn) {
|
|
754
|
+
var _a;
|
|
755
|
+
if (!Array.isArray(listeners[key]))
|
|
756
|
+
listeners[key] = [];
|
|
757
|
+
(_a = listeners[key]) == null ? void 0 : _a.push(fn);
|
|
758
|
+
return () => {
|
|
759
|
+
this.off(key, fn);
|
|
760
|
+
};
|
|
761
|
+
},
|
|
762
|
+
off(key, fn) {
|
|
763
|
+
var _a;
|
|
764
|
+
listeners[key] = ((_a = listeners[key]) != null ? _a : []).filter((cb) => {
|
|
765
|
+
return cb !== fn;
|
|
766
|
+
});
|
|
767
|
+
},
|
|
768
|
+
emit(key, data) {
|
|
769
|
+
var _a;
|
|
770
|
+
((_a = listeners[key]) != null ? _a : []).forEach((fn) => {
|
|
771
|
+
return fn(data);
|
|
772
|
+
});
|
|
773
|
+
}
|
|
774
|
+
};
|
|
775
|
+
}
|
|
776
|
+
class EventEmitter {
|
|
777
|
+
constructor() {
|
|
778
|
+
__privateAdd$4(this, _emitter, eventEmitter());
|
|
779
|
+
}
|
|
780
|
+
on(eventName, fn) {
|
|
781
|
+
__privateGet$4(this, _emitter).on(eventName, fn);
|
|
782
|
+
return () => {
|
|
783
|
+
__privateGet$4(this, _emitter).off(eventName, fn);
|
|
784
|
+
};
|
|
785
|
+
}
|
|
786
|
+
off(eventName, fn) {
|
|
787
|
+
__privateGet$4(this, _emitter).off(eventName, fn);
|
|
788
|
+
}
|
|
789
|
+
emit(eventName, params) {
|
|
790
|
+
__privateGet$4(this, _emitter).emit(eventName, params);
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
_emitter = new WeakMap();
|
|
794
|
+
|
|
795
|
+
var __accessCheck$3 = (obj, member, msg) => {
|
|
796
|
+
if (!member.has(obj))
|
|
797
|
+
throw TypeError("Cannot " + msg);
|
|
798
|
+
};
|
|
799
|
+
var __privateGet$3 = (obj, member, getter) => {
|
|
800
|
+
__accessCheck$3(obj, member, "read from private field");
|
|
801
|
+
return getter ? getter.call(obj) : member.get(obj);
|
|
802
|
+
};
|
|
803
|
+
var __privateAdd$3 = (obj, member, value) => {
|
|
804
|
+
if (member.has(obj))
|
|
805
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
806
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
807
|
+
};
|
|
808
|
+
var __privateSet$3 = (obj, member, value, setter) => {
|
|
809
|
+
__accessCheck$3(obj, member, "write to private field");
|
|
810
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
811
|
+
return value;
|
|
812
|
+
};
|
|
813
|
+
var _value;
|
|
814
|
+
class WithEventsValue extends EventEmitter {
|
|
815
|
+
constructor(value) {
|
|
816
|
+
super();
|
|
817
|
+
__privateAdd$3(this, _value, void 0);
|
|
818
|
+
__privateSet$3(this, _value, value);
|
|
819
|
+
}
|
|
820
|
+
get value() {
|
|
821
|
+
return __privateGet$3(this, _value);
|
|
822
|
+
}
|
|
823
|
+
set value(value) {
|
|
824
|
+
__privateSet$3(this, _value, value);
|
|
825
|
+
this.emit("update", value);
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
_value = new WeakMap();
|
|
829
|
+
|
|
800
830
|
var __accessCheck$2 = (obj, member, msg) => {
|
|
801
831
|
if (!member.has(obj))
|
|
802
832
|
throw TypeError("Cannot " + msg);
|
|
@@ -1023,47 +1053,6 @@ function useLocalStorage(prop, defaultValue) {
|
|
|
1023
1053
|
];
|
|
1024
1054
|
}
|
|
1025
1055
|
|
|
1026
|
-
function addBoundary(definition, min, max, loop) {
|
|
1027
|
-
const actualNumber = typeof definition === "number" ? definition : definition.number;
|
|
1028
|
-
const actualMin = typeof definition === "number" ? min : definition.min;
|
|
1029
|
-
const actualMax = typeof definition === "number" ? max : definition.max;
|
|
1030
|
-
const isActualLoop = typeof definition === "number" ? loop : definition.loop;
|
|
1031
|
-
let newNumber = Number(actualNumber != null ? actualNumber : 0);
|
|
1032
|
-
if (actualMin !== void 0 && newNumber < actualMin) {
|
|
1033
|
-
if (actualMax !== void 0 && isActualLoop) {
|
|
1034
|
-
newNumber = actualMax;
|
|
1035
|
-
} else {
|
|
1036
|
-
newNumber = actualMin;
|
|
1037
|
-
}
|
|
1038
|
-
}
|
|
1039
|
-
if (actualMax !== void 0 && newNumber > actualMax) {
|
|
1040
|
-
if (actualMin !== void 0 && isActualLoop) {
|
|
1041
|
-
newNumber = actualMin;
|
|
1042
|
-
} else {
|
|
1043
|
-
newNumber = actualMax;
|
|
1044
|
-
}
|
|
1045
|
-
}
|
|
1046
|
-
return newNumber;
|
|
1047
|
-
}
|
|
1048
|
-
const sizeUnits = ["b", "kb", "mb", "gb", "tb"];
|
|
1049
|
-
function parseAsSize(num) {
|
|
1050
|
-
let index = 0;
|
|
1051
|
-
let finalSize = num;
|
|
1052
|
-
if (finalSize === Infinity)
|
|
1053
|
-
return "1000GB";
|
|
1054
|
-
while (finalSize > 1024) {
|
|
1055
|
-
finalSize /= 1024;
|
|
1056
|
-
index++;
|
|
1057
|
-
}
|
|
1058
|
-
return `${Math.round(finalSize * 10) / 10}${sizeUnits[index]}`;
|
|
1059
|
-
}
|
|
1060
|
-
function noNaN(number, defaultReturn = 0) {
|
|
1061
|
-
const returnNumber = Number(number);
|
|
1062
|
-
if (number === null || Number.isNaN(returnNumber))
|
|
1063
|
-
return defaultReturn;
|
|
1064
|
-
return returnNumber;
|
|
1065
|
-
}
|
|
1066
|
-
|
|
1067
1056
|
var __accessCheck = (obj, member, msg) => {
|
|
1068
1057
|
if (!member.has(obj))
|
|
1069
1058
|
throw TypeError("Cannot " + msg);
|
|
@@ -1177,7 +1166,8 @@ const focus = new (_a = class {
|
|
|
1177
1166
|
}
|
|
1178
1167
|
/**
|
|
1179
1168
|
* Da la instrucción de colocar el foco el elemento pasado como parámetro.
|
|
1180
|
-
* Se puede pasar también una función que devuelva HTMLElement | false |
|
|
1169
|
+
* Se puede pasar también una función que devuelva HTMLElement | false |
|
|
1170
|
+
* null.
|
|
1181
1171
|
*
|
|
1182
1172
|
* El segundo parámetro del método on es un objeto de tipo
|
|
1183
1173
|
* ScrollIntoViewOptions, que permite modificar el comportamiento del scroll
|
|
@@ -1229,7 +1219,11 @@ const focus = new (_a = class {
|
|
|
1229
1219
|
const initialFocusElement = document.querySelector(
|
|
1230
1220
|
this.focusOnReload
|
|
1231
1221
|
);
|
|
1232
|
-
const scrollTop = noNaN(
|
|
1222
|
+
const scrollTop = noNaN(
|
|
1223
|
+
(_a3 = window.CURRENT_TAB) == null ? void 0 : _a3.split(
|
|
1224
|
+
"~"
|
|
1225
|
+
)[1]
|
|
1226
|
+
);
|
|
1233
1227
|
if (document.scrollingElement)
|
|
1234
1228
|
document.scrollingElement.scrollTop = scrollTop;
|
|
1235
1229
|
return initialFocusElement;
|
|
@@ -1453,30 +1447,30 @@ const ImperativeComponentContext = createContext(
|
|
|
1453
1447
|
{}
|
|
1454
1448
|
);
|
|
1455
1449
|
|
|
1456
|
-
var __defProp$
|
|
1457
|
-
var __getOwnPropSymbols$
|
|
1458
|
-
var __hasOwnProp$
|
|
1459
|
-
var __propIsEnum$
|
|
1460
|
-
var __defNormalProp$
|
|
1461
|
-
var __spreadValues$
|
|
1450
|
+
var __defProp$4 = Object.defineProperty;
|
|
1451
|
+
var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
|
|
1452
|
+
var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
|
|
1453
|
+
var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
|
|
1454
|
+
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1455
|
+
var __spreadValues$4 = (a, b) => {
|
|
1462
1456
|
for (var prop in b || (b = {}))
|
|
1463
|
-
if (__hasOwnProp$
|
|
1464
|
-
__defNormalProp$
|
|
1465
|
-
if (__getOwnPropSymbols$
|
|
1466
|
-
for (var prop of __getOwnPropSymbols$
|
|
1467
|
-
if (__propIsEnum$
|
|
1468
|
-
__defNormalProp$
|
|
1457
|
+
if (__hasOwnProp$4.call(b, prop))
|
|
1458
|
+
__defNormalProp$4(a, prop, b[prop]);
|
|
1459
|
+
if (__getOwnPropSymbols$4)
|
|
1460
|
+
for (var prop of __getOwnPropSymbols$4(b)) {
|
|
1461
|
+
if (__propIsEnum$4.call(b, prop))
|
|
1462
|
+
__defNormalProp$4(a, prop, b[prop]);
|
|
1469
1463
|
}
|
|
1470
1464
|
return a;
|
|
1471
1465
|
};
|
|
1472
1466
|
var __objRest$1 = (source, exclude) => {
|
|
1473
1467
|
var target = {};
|
|
1474
1468
|
for (var prop in source)
|
|
1475
|
-
if (__hasOwnProp$
|
|
1469
|
+
if (__hasOwnProp$4.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
1476
1470
|
target[prop] = source[prop];
|
|
1477
|
-
if (source != null && __getOwnPropSymbols$
|
|
1478
|
-
for (var prop of __getOwnPropSymbols$
|
|
1479
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum$
|
|
1471
|
+
if (source != null && __getOwnPropSymbols$4)
|
|
1472
|
+
for (var prop of __getOwnPropSymbols$4(source)) {
|
|
1473
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$4.call(source, prop))
|
|
1480
1474
|
target[prop] = source[prop];
|
|
1481
1475
|
}
|
|
1482
1476
|
return target;
|
|
@@ -1502,7 +1496,7 @@ function makeImperativeComponent() {
|
|
|
1502
1496
|
const fireEvent = (id, ev, args) => {
|
|
1503
1497
|
var _a, _b;
|
|
1504
1498
|
if (eventsHandlers[id])
|
|
1505
|
-
(_b = (_a = eventsHandlers[id]) == null ? void 0 : _a[ev]) == null ? void 0 : _b.forEach((current) => current(args));
|
|
1499
|
+
(_b = (_a = eventsHandlers[id]) == null ? void 0 : _a[ev]) == null ? void 0 : _b.forEach((current) => current.cb(args));
|
|
1506
1500
|
else
|
|
1507
1501
|
console.warn(`The requested id does not exist: ${id}`);
|
|
1508
1502
|
};
|
|
@@ -1513,12 +1507,12 @@ function makeImperativeComponent() {
|
|
|
1513
1507
|
"id"
|
|
1514
1508
|
]);
|
|
1515
1509
|
const [state, innerSetState] = useState(initialState);
|
|
1516
|
-
setStates[id] = (newState) => innerSetState((current) => __spreadValues$
|
|
1510
|
+
setStates[id] = (newState) => innerSetState((current) => __spreadValues$4(__spreadValues$4({}, current), newState));
|
|
1517
1511
|
return /* @__PURE__ */ jsx(
|
|
1518
1512
|
ImperativeComponentContext.Provider,
|
|
1519
1513
|
{
|
|
1520
1514
|
value: useMemo(() => ({ id, eventsStore: eventsHandlers }), [id]),
|
|
1521
|
-
children: /* @__PURE__ */ jsx(Component, __spreadValues$
|
|
1515
|
+
children: /* @__PURE__ */ jsx(Component, __spreadValues$4(__spreadValues$4({}, props), state))
|
|
1522
1516
|
}
|
|
1523
1517
|
);
|
|
1524
1518
|
};
|
|
@@ -1526,21 +1520,21 @@ function makeImperativeComponent() {
|
|
|
1526
1520
|
};
|
|
1527
1521
|
}
|
|
1528
1522
|
|
|
1529
|
-
var __defProp$
|
|
1523
|
+
var __defProp$3 = Object.defineProperty;
|
|
1530
1524
|
var __defProps$2 = Object.defineProperties;
|
|
1531
1525
|
var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
|
|
1532
|
-
var __getOwnPropSymbols$
|
|
1533
|
-
var __hasOwnProp$
|
|
1534
|
-
var __propIsEnum$
|
|
1535
|
-
var __defNormalProp$
|
|
1536
|
-
var __spreadValues$
|
|
1526
|
+
var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
|
|
1527
|
+
var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
|
|
1528
|
+
var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
|
|
1529
|
+
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1530
|
+
var __spreadValues$3 = (a, b) => {
|
|
1537
1531
|
for (var prop in b || (b = {}))
|
|
1538
|
-
if (__hasOwnProp$
|
|
1539
|
-
__defNormalProp$
|
|
1540
|
-
if (__getOwnPropSymbols$
|
|
1541
|
-
for (var prop of __getOwnPropSymbols$
|
|
1542
|
-
if (__propIsEnum$
|
|
1543
|
-
__defNormalProp$
|
|
1532
|
+
if (__hasOwnProp$3.call(b, prop))
|
|
1533
|
+
__defNormalProp$3(a, prop, b[prop]);
|
|
1534
|
+
if (__getOwnPropSymbols$3)
|
|
1535
|
+
for (var prop of __getOwnPropSymbols$3(b)) {
|
|
1536
|
+
if (__propIsEnum$3.call(b, prop))
|
|
1537
|
+
__defNormalProp$3(a, prop, b[prop]);
|
|
1544
1538
|
}
|
|
1545
1539
|
return a;
|
|
1546
1540
|
};
|
|
@@ -1565,7 +1559,7 @@ function makeSingleImperativeComponent() {
|
|
|
1565
1559
|
return [
|
|
1566
1560
|
newMethods,
|
|
1567
1561
|
fireEvent,
|
|
1568
|
-
(props) => /* @__PURE__ */ jsx(ImperativeComponent, __spreadProps$2(__spreadValues$
|
|
1562
|
+
(props) => /* @__PURE__ */ jsx(ImperativeComponent, __spreadProps$2(__spreadValues$3({}, props), { id }))
|
|
1569
1563
|
];
|
|
1570
1564
|
};
|
|
1571
1565
|
}
|
|
@@ -1576,50 +1570,71 @@ function useImperativeComponentContext() {
|
|
|
1576
1570
|
}
|
|
1577
1571
|
|
|
1578
1572
|
const useImperativeComponentEvents = (handlers) => {
|
|
1573
|
+
const uniqueHookId = useMemo(() => uniqueId$1("hook"), []);
|
|
1579
1574
|
const { id, eventsStore } = useImperativeComponentContext();
|
|
1580
|
-
|
|
1575
|
+
const hasRegistered = useRef(false);
|
|
1576
|
+
function registerEvents() {
|
|
1581
1577
|
Object.entries(handlers).forEach(([name, callback]) => {
|
|
1582
1578
|
var _a;
|
|
1583
1579
|
if (!eventsStore[id])
|
|
1584
1580
|
eventsStore[id] = {};
|
|
1585
1581
|
if (!eventsStore[id][name])
|
|
1586
1582
|
eventsStore[id][name] = [];
|
|
1587
|
-
(_a = eventsStore[id][name]) == null ? void 0 : _a.push(
|
|
1588
|
-
callback
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
return () => Object.entries(handlers).forEach(([name, callback]) => {
|
|
1592
|
-
var _a;
|
|
1593
|
-
eventsStore[id][name] = ((_a = eventsStore[id][name]) != null ? _a : []).filter((current) => current !== callback);
|
|
1583
|
+
(_a = eventsStore[id][name]) == null ? void 0 : _a.push({
|
|
1584
|
+
cb: callback,
|
|
1585
|
+
uniqueHookId
|
|
1586
|
+
});
|
|
1594
1587
|
});
|
|
1595
|
-
}
|
|
1588
|
+
}
|
|
1589
|
+
useEffect(() => {
|
|
1590
|
+
registerEvents();
|
|
1591
|
+
return () => {
|
|
1592
|
+
hasRegistered.current = false;
|
|
1593
|
+
Object.entries(handlers).forEach(([name]) => {
|
|
1594
|
+
var _a;
|
|
1595
|
+
eventsStore[id][name] = ((_a = eventsStore[id][name]) != null ? _a : []).filter((current) => current.uniqueHookId !== uniqueHookId);
|
|
1596
|
+
});
|
|
1597
|
+
};
|
|
1598
|
+
}, []);
|
|
1599
|
+
return uniqueHookId;
|
|
1596
1600
|
};
|
|
1597
1601
|
|
|
1598
1602
|
const formatMessage = (str, obj) => {
|
|
1599
1603
|
let newStr = str;
|
|
1600
1604
|
Object.entries(obj).forEach(([key, value]) => {
|
|
1601
|
-
|
|
1602
|
-
if (value !== "") {
|
|
1603
|
-
placeHolder = `<${key}>`;
|
|
1604
|
-
} else {
|
|
1605
|
-
placeHolder = `"<${key}>"`;
|
|
1606
|
-
}
|
|
1605
|
+
const placeHolder = `<${key}>`;
|
|
1607
1606
|
if (newStr == null ? void 0 : newStr.includes(placeHolder)) {
|
|
1608
|
-
newStr = newStr.replace(placeHolder, value
|
|
1607
|
+
newStr = newStr.replace(placeHolder, value != null ? value : "");
|
|
1609
1608
|
}
|
|
1610
1609
|
});
|
|
1611
1610
|
return newStr;
|
|
1612
1611
|
};
|
|
1613
1612
|
|
|
1613
|
+
var __defProp$2 = Object.defineProperty;
|
|
1614
|
+
var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
|
|
1615
|
+
var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
|
|
1616
|
+
var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
|
|
1617
|
+
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1618
|
+
var __spreadValues$2 = (a, b) => {
|
|
1619
|
+
for (var prop in b || (b = {}))
|
|
1620
|
+
if (__hasOwnProp$2.call(b, prop))
|
|
1621
|
+
__defNormalProp$2(a, prop, b[prop]);
|
|
1622
|
+
if (__getOwnPropSymbols$2)
|
|
1623
|
+
for (var prop of __getOwnPropSymbols$2(b)) {
|
|
1624
|
+
if (__propIsEnum$2.call(b, prop))
|
|
1625
|
+
__defNormalProp$2(a, prop, b[prop]);
|
|
1626
|
+
}
|
|
1627
|
+
return a;
|
|
1628
|
+
};
|
|
1614
1629
|
function getLabel(name, replaceTokens) {
|
|
1615
1630
|
var _a;
|
|
1616
|
-
const label = (_a = window.labels[name]) != null ? _a : {
|
|
1631
|
+
const label = __spreadValues$2({}, (_a = window.labels[name]) != null ? _a : {
|
|
1617
1632
|
text: `Not preloaded: ${name}`,
|
|
1618
1633
|
tooltip: `Not preloaded: ${name}`
|
|
1619
|
-
};
|
|
1620
|
-
if (replaceTokens == null ? void 0 : replaceTokens.text)
|
|
1634
|
+
});
|
|
1635
|
+
if ((replaceTokens == null ? void 0 : replaceTokens.text) !== void 0)
|
|
1621
1636
|
label.text = formatMessage(label.text, replaceTokens.text);
|
|
1622
|
-
if (replaceTokens == null ? void 0 : replaceTokens.title)
|
|
1637
|
+
if ((replaceTokens == null ? void 0 : replaceTokens.title) !== void 0)
|
|
1623
1638
|
label.tooltip = formatMessage(label.tooltip, replaceTokens.title);
|
|
1624
1639
|
return label;
|
|
1625
1640
|
}
|
|
@@ -1758,7 +1773,7 @@ function usePropsSelector(fieldId, par1, par2, par3) {
|
|
|
1758
1773
|
return () => {
|
|
1759
1774
|
unsuscribe();
|
|
1760
1775
|
};
|
|
1761
|
-
}, [fieldId, actualPropsStore]);
|
|
1776
|
+
}, [fieldId, actualPropsStore, selector, comparator]);
|
|
1762
1777
|
return props;
|
|
1763
1778
|
}
|
|
1764
1779
|
|
|
@@ -1785,13 +1800,13 @@ const propsLog = "propsLog";
|
|
|
1785
1800
|
class PropsStore {
|
|
1786
1801
|
constructor(configuration) {
|
|
1787
1802
|
this.configuration = configuration;
|
|
1788
|
-
this.log = persistentStorage
|
|
1803
|
+
this.log = persistentStorage[propsLog];
|
|
1789
1804
|
this.fields = {};
|
|
1790
1805
|
this.suscriptors = {};
|
|
1791
1806
|
this.loggers = {
|
|
1792
1807
|
propsLog: ([log]) => {
|
|
1793
1808
|
this.log = log;
|
|
1794
|
-
persistentStorage
|
|
1809
|
+
persistentStorage[propsLog] = log;
|
|
1795
1810
|
},
|
|
1796
1811
|
propsStore: ([fieldId]) => {
|
|
1797
1812
|
if (fieldId)
|
|
@@ -1811,25 +1826,25 @@ class PropsStore {
|
|
|
1811
1826
|
};
|
|
1812
1827
|
if (this.configuration) {
|
|
1813
1828
|
if (this.configuration.logCommands.propsStore)
|
|
1814
|
-
debugDispatcher
|
|
1829
|
+
debugDispatcher.on(
|
|
1815
1830
|
this.configuration.logCommands.propsStore,
|
|
1816
1831
|
this.loggers.propsStore,
|
|
1817
1832
|
"Muestra el contenido actual del propsStore"
|
|
1818
1833
|
);
|
|
1819
1834
|
if (this.configuration.logCommands.updateProp)
|
|
1820
|
-
debugDispatcher
|
|
1835
|
+
debugDispatcher.on(
|
|
1821
1836
|
this.configuration.logCommands.updateProp,
|
|
1822
1837
|
this.loggers.updateProp,
|
|
1823
1838
|
"dd.updateProp(fieldId, newProps). El objeto newProps ser\xE1 mergeado sobre las props actuales"
|
|
1824
1839
|
);
|
|
1825
1840
|
if (this.configuration.logCommands.propsSuscriptors)
|
|
1826
|
-
debugDispatcher
|
|
1841
|
+
debugDispatcher.on(
|
|
1827
1842
|
this.configuration.logCommands.propsSuscriptors,
|
|
1828
1843
|
this.loggers.propsSuscriptors,
|
|
1829
1844
|
"Muestra los suscriptores actuales del propsStore"
|
|
1830
1845
|
);
|
|
1831
1846
|
if (this.configuration.logCommands.propsLog)
|
|
1832
|
-
debugDispatcher
|
|
1847
|
+
debugDispatcher.on(
|
|
1833
1848
|
this.configuration.logCommands.propsLog,
|
|
1834
1849
|
this.loggers.propsLog,
|
|
1835
1850
|
"Si se pasa como true, hace log de las acciones. Si se pasa como trace(fieldId), se hace log de todas las acciones y trace del campo especificado. Si se pasa trace(), hace log y trace de todas las acciones."
|
|
@@ -1839,22 +1854,22 @@ class PropsStore {
|
|
|
1839
1854
|
destructor() {
|
|
1840
1855
|
if (this.configuration) {
|
|
1841
1856
|
if (this.configuration.logCommands.propsStore)
|
|
1842
|
-
debugDispatcher
|
|
1857
|
+
debugDispatcher.off(
|
|
1843
1858
|
this.configuration.logCommands.propsStore,
|
|
1844
1859
|
this.loggers.propsStore
|
|
1845
1860
|
);
|
|
1846
1861
|
if (this.configuration.logCommands.updateProp)
|
|
1847
|
-
debugDispatcher
|
|
1862
|
+
debugDispatcher.off(
|
|
1848
1863
|
this.configuration.logCommands.updateProp,
|
|
1849
1864
|
this.loggers.updateProp
|
|
1850
1865
|
);
|
|
1851
1866
|
if (this.configuration.logCommands.propsSuscriptors)
|
|
1852
|
-
debugDispatcher
|
|
1867
|
+
debugDispatcher.off(
|
|
1853
1868
|
this.configuration.logCommands.propsSuscriptors,
|
|
1854
1869
|
this.loggers.propsSuscriptors
|
|
1855
1870
|
);
|
|
1856
1871
|
if (this.configuration.logCommands.propsLog)
|
|
1857
|
-
debugDispatcher
|
|
1872
|
+
debugDispatcher.off(
|
|
1858
1873
|
this.configuration.logCommands.propsLog,
|
|
1859
1874
|
this.loggers.propsLog
|
|
1860
1875
|
);
|
|
@@ -2100,5 +2115,4 @@ const parseXmlAsync = (xml) => __async(void 0, null, function* () {
|
|
|
2100
2115
|
return result;
|
|
2101
2116
|
});
|
|
2102
2117
|
|
|
2103
|
-
export {
|
|
2104
|
-
//# sourceMappingURL=index.js.map
|
|
2118
|
+
export { EventEmitter, PropsSelectorUndefinedObject, PropsStore, Url, WithEventsValue, addBoundary, animate, apiaDateToStandarFormat, arrayOrArray, autoDisconnectMutationObserver, cantFocusSelector, customEvents, dateToApiaFormat, debugDispatcher, decrypt, disableChildrenFocus, downloadUrl, enableChildrenFocus, enableDebugDispatcher, encrypt, findOffsetRelativeToScrollParent, findScrollContainer, focus, focusSelector, formatMessage, getDateFormat, getFocusSelector, getIndex, getLabel, getSpecificParent, getValueByPath, globalFocus, isChild, isDebugDispatcherEnabled, isPropsConfigurationObject, makeImperativeComponent, makeSingleImperativeComponent, noNaN, notificationsSelector, parseAsSize, parseXmlAsync, persistentStorage, propsStore, screenLocker, scrollParentIntoElement, setValueByPath, shortcutController, toBoolean, ucfirst, useCombinedRefs, useDebouncedCallback, useDebouncedState, useDomState, useImperativeComponentContext, useImperativeComponentEvents, useLatest, useLocalStorage, useMount, usePanAndZoom, usePrevious, usePropsSelector, useStateRef, useUnmount, useUpdateEffect };
|