@apia/util 1.0.0 → 1.0.4
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/cleanDist.json +1 -1
- package/dist/index.d.ts +210 -14
- package/dist/index.js +514 -198
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ 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,
|
|
8
|
+
import React__default, { useRef, useCallback, useEffect, useState, useMemo, createContext, useContext } from 'react';
|
|
9
9
|
import { isFunction as isFunction$1, uniqueId } from 'lodash-es';
|
|
10
10
|
import { jsx } from 'react/jsx-runtime';
|
|
11
11
|
import xml2js from 'xml2js';
|
|
@@ -661,15 +661,15 @@ function isChild(element, checkParent) {
|
|
|
661
661
|
return !!getSpecificParent(element, checkParent);
|
|
662
662
|
}
|
|
663
663
|
|
|
664
|
-
var __accessCheck$
|
|
664
|
+
var __accessCheck$7 = (obj, member, msg) => {
|
|
665
665
|
if (!member.has(obj))
|
|
666
666
|
throw TypeError("Cannot " + msg);
|
|
667
667
|
};
|
|
668
|
-
var __privateGet$
|
|
669
|
-
__accessCheck$
|
|
668
|
+
var __privateGet$7 = (obj, member, getter) => {
|
|
669
|
+
__accessCheck$7(obj, member, "read from private field");
|
|
670
670
|
return getter ? getter.call(obj) : member.get(obj);
|
|
671
671
|
};
|
|
672
|
-
var __privateAdd$
|
|
672
|
+
var __privateAdd$7 = (obj, member, value) => {
|
|
673
673
|
if (member.has(obj))
|
|
674
674
|
throw TypeError("Cannot add the same private member more than once");
|
|
675
675
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
@@ -678,7 +678,7 @@ var _parameters;
|
|
|
678
678
|
class Url {
|
|
679
679
|
constructor(baseUrl, defaultAllowMultiple = true) {
|
|
680
680
|
this.defaultAllowMultiple = defaultAllowMultiple;
|
|
681
|
-
__privateAdd$
|
|
681
|
+
__privateAdd$7(this, _parameters, {});
|
|
682
682
|
const [base, query] = baseUrl.split("?");
|
|
683
683
|
this.base = base;
|
|
684
684
|
query == null ? void 0 : query.split("&").forEach((current) => {
|
|
@@ -688,9 +688,9 @@ class Url {
|
|
|
688
688
|
}
|
|
689
689
|
addParameter(name, value, allowMultiple) {
|
|
690
690
|
if (allowMultiple === void 0 && !this.defaultAllowMultiple || allowMultiple === false)
|
|
691
|
-
__privateGet$
|
|
691
|
+
__privateGet$7(this, _parameters)[name] = String(value);
|
|
692
692
|
else
|
|
693
|
-
__privateGet$
|
|
693
|
+
__privateGet$7(this, _parameters)[name] = __privateGet$7(this, _parameters)[name] ? [...arrayOrArray(__privateGet$7(this, _parameters)[name]), String(value)] : [String(value)];
|
|
694
694
|
}
|
|
695
695
|
addParameters(parameters) {
|
|
696
696
|
parameters.forEach(
|
|
@@ -698,10 +698,10 @@ class Url {
|
|
|
698
698
|
);
|
|
699
699
|
}
|
|
700
700
|
getParameter(name) {
|
|
701
|
-
return __privateGet$
|
|
701
|
+
return __privateGet$7(this, _parameters)[name];
|
|
702
702
|
}
|
|
703
703
|
toString() {
|
|
704
|
-
const parametersArray = Object.entries(__privateGet$
|
|
704
|
+
const parametersArray = Object.entries(__privateGet$7(this, _parameters));
|
|
705
705
|
return `${this.base}${parametersArray.length > 0 ? `?${parametersArray.map(
|
|
706
706
|
([name, value]) => Array.isArray(value) ? value.map((current) => `${name}=${current}`).join("&") : `${name}=${String(value)}`
|
|
707
707
|
).join("&")}` : ""}`;
|
|
@@ -733,15 +733,15 @@ function enableChildrenFocus(parent) {
|
|
|
733
733
|
});
|
|
734
734
|
}
|
|
735
735
|
|
|
736
|
-
var __accessCheck$
|
|
736
|
+
var __accessCheck$6 = (obj, member, msg) => {
|
|
737
737
|
if (!member.has(obj))
|
|
738
738
|
throw TypeError("Cannot " + msg);
|
|
739
739
|
};
|
|
740
|
-
var __privateGet$
|
|
741
|
-
__accessCheck$
|
|
740
|
+
var __privateGet$6 = (obj, member, getter) => {
|
|
741
|
+
__accessCheck$6(obj, member, "read from private field");
|
|
742
742
|
return getter ? getter.call(obj) : member.get(obj);
|
|
743
743
|
};
|
|
744
|
-
var __privateAdd$
|
|
744
|
+
var __privateAdd$6 = (obj, member, value) => {
|
|
745
745
|
if (member.has(obj))
|
|
746
746
|
throw TypeError("Cannot add the same private member more than once");
|
|
747
747
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
@@ -775,38 +775,38 @@ function eventEmitterBaseFunction() {
|
|
|
775
775
|
}
|
|
776
776
|
class EventEmitter {
|
|
777
777
|
constructor() {
|
|
778
|
-
__privateAdd$
|
|
778
|
+
__privateAdd$6(this, _emitter$1, eventEmitterBaseFunction());
|
|
779
779
|
}
|
|
780
780
|
on(eventName, fn) {
|
|
781
|
-
__privateGet$
|
|
781
|
+
__privateGet$6(this, _emitter$1).on(eventName, fn);
|
|
782
782
|
return () => {
|
|
783
|
-
__privateGet$
|
|
783
|
+
__privateGet$6(this, _emitter$1).off(eventName, fn);
|
|
784
784
|
};
|
|
785
785
|
}
|
|
786
786
|
off(eventName, fn) {
|
|
787
|
-
__privateGet$
|
|
787
|
+
__privateGet$6(this, _emitter$1).off(eventName, fn);
|
|
788
788
|
}
|
|
789
789
|
emit(eventName, params) {
|
|
790
|
-
__privateGet$
|
|
790
|
+
__privateGet$6(this, _emitter$1).emit(eventName, params);
|
|
791
791
|
}
|
|
792
792
|
}
|
|
793
793
|
_emitter$1 = new WeakMap();
|
|
794
794
|
|
|
795
|
-
var __accessCheck$
|
|
795
|
+
var __accessCheck$5 = (obj, member, msg) => {
|
|
796
796
|
if (!member.has(obj))
|
|
797
797
|
throw TypeError("Cannot " + msg);
|
|
798
798
|
};
|
|
799
|
-
var __privateGet$
|
|
800
|
-
__accessCheck$
|
|
799
|
+
var __privateGet$5 = (obj, member, getter) => {
|
|
800
|
+
__accessCheck$5(obj, member, "read from private field");
|
|
801
801
|
return getter ? getter.call(obj) : member.get(obj);
|
|
802
802
|
};
|
|
803
|
-
var __privateAdd$
|
|
803
|
+
var __privateAdd$5 = (obj, member, value) => {
|
|
804
804
|
if (member.has(obj))
|
|
805
805
|
throw TypeError("Cannot add the same private member more than once");
|
|
806
806
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
807
807
|
};
|
|
808
808
|
var __privateMethod$2 = (obj, member, method) => {
|
|
809
|
-
__accessCheck$
|
|
809
|
+
__accessCheck$5(obj, member, "access private method");
|
|
810
810
|
return method;
|
|
811
811
|
};
|
|
812
812
|
var _emitter, _getEventName, getEventName_fn;
|
|
@@ -839,24 +839,24 @@ function eventEmitter() {
|
|
|
839
839
|
class HashedEventEmitter {
|
|
840
840
|
constructor(hashMethod) {
|
|
841
841
|
this.hashMethod = hashMethod;
|
|
842
|
-
__privateAdd$
|
|
843
|
-
__privateAdd$
|
|
842
|
+
__privateAdd$5(this, _getEventName);
|
|
843
|
+
__privateAdd$5(this, _emitter, eventEmitter());
|
|
844
844
|
}
|
|
845
845
|
on(hash, eventName, fn) {
|
|
846
846
|
const actualEventName = __privateMethod$2(this, _getEventName, getEventName_fn).call(this, hash, eventName);
|
|
847
|
-
__privateGet$
|
|
847
|
+
__privateGet$5(this, _emitter).on(actualEventName, fn);
|
|
848
848
|
return () => {
|
|
849
|
-
__privateGet$
|
|
849
|
+
__privateGet$5(this, _emitter).off(actualEventName, fn);
|
|
850
850
|
};
|
|
851
851
|
}
|
|
852
852
|
off(hash, eventName, fn) {
|
|
853
853
|
const actualEventName = __privateMethod$2(this, _getEventName, getEventName_fn).call(this, hash, eventName);
|
|
854
|
-
__privateGet$
|
|
854
|
+
__privateGet$5(this, _emitter).off(actualEventName, fn);
|
|
855
855
|
}
|
|
856
856
|
emit(hash, eventName, params) {
|
|
857
857
|
const actualEventName = __privateMethod$2(this, _getEventName, getEventName_fn).call(this, hash, eventName);
|
|
858
|
-
__privateGet$
|
|
859
|
-
__privateGet$
|
|
858
|
+
__privateGet$5(this, _emitter).emit(actualEventName, params);
|
|
859
|
+
__privateGet$5(this, _emitter).emit(eventName, params);
|
|
860
860
|
}
|
|
861
861
|
}
|
|
862
862
|
_emitter = new WeakMap();
|
|
@@ -865,21 +865,21 @@ getEventName_fn = function(hash, eventName) {
|
|
|
865
865
|
return hash === "*" ? eventName : `${this.hashMethod(hash)}_${eventName}`;
|
|
866
866
|
};
|
|
867
867
|
|
|
868
|
-
var __accessCheck$
|
|
868
|
+
var __accessCheck$4 = (obj, member, msg) => {
|
|
869
869
|
if (!member.has(obj))
|
|
870
870
|
throw TypeError("Cannot " + msg);
|
|
871
871
|
};
|
|
872
|
-
var __privateGet$
|
|
873
|
-
__accessCheck$
|
|
872
|
+
var __privateGet$4 = (obj, member, getter) => {
|
|
873
|
+
__accessCheck$4(obj, member, "read from private field");
|
|
874
874
|
return getter ? getter.call(obj) : member.get(obj);
|
|
875
875
|
};
|
|
876
|
-
var __privateAdd$
|
|
876
|
+
var __privateAdd$4 = (obj, member, value) => {
|
|
877
877
|
if (member.has(obj))
|
|
878
878
|
throw TypeError("Cannot add the same private member more than once");
|
|
879
879
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
880
880
|
};
|
|
881
|
-
var __privateSet$
|
|
882
|
-
__accessCheck$
|
|
881
|
+
var __privateSet$4 = (obj, member, value, setter) => {
|
|
882
|
+
__accessCheck$4(obj, member, "write to private field");
|
|
883
883
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
884
884
|
return value;
|
|
885
885
|
};
|
|
@@ -887,34 +887,34 @@ var _value;
|
|
|
887
887
|
class WithEventsValue extends EventEmitter {
|
|
888
888
|
constructor(value) {
|
|
889
889
|
super();
|
|
890
|
-
__privateAdd$
|
|
891
|
-
__privateSet$
|
|
890
|
+
__privateAdd$4(this, _value, void 0);
|
|
891
|
+
__privateSet$4(this, _value, value);
|
|
892
892
|
}
|
|
893
893
|
get value() {
|
|
894
|
-
return __privateGet$
|
|
894
|
+
return __privateGet$4(this, _value);
|
|
895
895
|
}
|
|
896
896
|
set value(value) {
|
|
897
|
-
__privateSet$
|
|
897
|
+
__privateSet$4(this, _value, value);
|
|
898
898
|
this.emit("update", value);
|
|
899
899
|
}
|
|
900
900
|
}
|
|
901
901
|
_value = new WeakMap();
|
|
902
902
|
|
|
903
|
-
var __accessCheck$
|
|
903
|
+
var __accessCheck$3 = (obj, member, msg) => {
|
|
904
904
|
if (!member.has(obj))
|
|
905
905
|
throw TypeError("Cannot " + msg);
|
|
906
906
|
};
|
|
907
|
-
var __privateGet$
|
|
908
|
-
__accessCheck$
|
|
907
|
+
var __privateGet$3 = (obj, member, getter) => {
|
|
908
|
+
__accessCheck$3(obj, member, "read from private field");
|
|
909
909
|
return getter ? getter.call(obj) : member.get(obj);
|
|
910
910
|
};
|
|
911
|
-
var __privateAdd$
|
|
911
|
+
var __privateAdd$3 = (obj, member, value) => {
|
|
912
912
|
if (member.has(obj))
|
|
913
913
|
throw TypeError("Cannot add the same private member more than once");
|
|
914
914
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
915
915
|
};
|
|
916
|
-
var __privateSet$
|
|
917
|
-
__accessCheck$
|
|
916
|
+
var __privateSet$3 = (obj, member, value, setter) => {
|
|
917
|
+
__accessCheck$3(obj, member, "write to private field");
|
|
918
918
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
919
919
|
return value;
|
|
920
920
|
};
|
|
@@ -923,7 +923,7 @@ const historySize = 50;
|
|
|
923
923
|
const globalFocus = new (_a$2 = class {
|
|
924
924
|
constructor() {
|
|
925
925
|
this.focused = [];
|
|
926
|
-
__privateAdd$
|
|
926
|
+
__privateAdd$3(this, _onFocusCallbacks, []);
|
|
927
927
|
debugDispatcher.on(
|
|
928
928
|
"focusHistory",
|
|
929
929
|
() => {
|
|
@@ -933,12 +933,12 @@ const globalFocus = new (_a$2 = class {
|
|
|
933
933
|
);
|
|
934
934
|
}
|
|
935
935
|
offFocus(cb) {
|
|
936
|
-
__privateSet$
|
|
936
|
+
__privateSet$3(this, _onFocusCallbacks, __privateGet$3(this, _onFocusCallbacks).filter(
|
|
937
937
|
(current) => current !== cb
|
|
938
938
|
));
|
|
939
939
|
}
|
|
940
940
|
onFocus(cb) {
|
|
941
|
-
__privateGet$
|
|
941
|
+
__privateGet$3(this, _onFocusCallbacks).push(cb);
|
|
942
942
|
return () => {
|
|
943
943
|
this.offFocus(cb);
|
|
944
944
|
};
|
|
@@ -955,7 +955,7 @@ const globalFocus = new (_a$2 = class {
|
|
|
955
955
|
if (this.focused.length > historySize) {
|
|
956
956
|
this.focused = this.focused.splice(0, historySize);
|
|
957
957
|
}
|
|
958
|
-
__privateGet$
|
|
958
|
+
__privateGet$3(this, _onFocusCallbacks).forEach((cb) => cb());
|
|
959
959
|
}
|
|
960
960
|
get list() {
|
|
961
961
|
return [...this.focused];
|
|
@@ -982,90 +982,526 @@ const globalFocus = new (_a$2 = class {
|
|
|
982
982
|
}
|
|
983
983
|
}, _onFocusCallbacks = new WeakMap(), _a$2)();
|
|
984
984
|
|
|
985
|
-
var __accessCheck$
|
|
985
|
+
var __accessCheck$2 = (obj, member, msg) => {
|
|
986
986
|
if (!member.has(obj))
|
|
987
987
|
throw TypeError("Cannot " + msg);
|
|
988
988
|
};
|
|
989
|
-
var __privateGet$
|
|
990
|
-
__accessCheck$
|
|
989
|
+
var __privateGet$2 = (obj, member, getter) => {
|
|
990
|
+
__accessCheck$2(obj, member, "read from private field");
|
|
991
991
|
return getter ? getter.call(obj) : member.get(obj);
|
|
992
992
|
};
|
|
993
|
-
var __privateAdd$
|
|
993
|
+
var __privateAdd$2 = (obj, member, value) => {
|
|
994
994
|
if (member.has(obj))
|
|
995
995
|
throw TypeError("Cannot add the same private member more than once");
|
|
996
996
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
997
997
|
};
|
|
998
|
-
var __privateSet$
|
|
999
|
-
__accessCheck$
|
|
998
|
+
var __privateSet$2 = (obj, member, value, setter) => {
|
|
999
|
+
__accessCheck$2(obj, member, "write to private field");
|
|
1000
1000
|
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
1001
1001
|
return value;
|
|
1002
1002
|
};
|
|
1003
1003
|
var __privateMethod$1 = (obj, member, method) => {
|
|
1004
|
-
__accessCheck$
|
|
1004
|
+
__accessCheck$2(obj, member, "access private method");
|
|
1005
1005
|
return method;
|
|
1006
1006
|
};
|
|
1007
1007
|
var _hasReleasedFirstTime, _wasReleasedFirstTime, _isForced, _locks, _shoutLockState, shoutLockState_fn, _a$1;
|
|
1008
1008
|
const screenLocker = new (_a$1 = class extends EventEmitter {
|
|
1009
1009
|
constructor() {
|
|
1010
1010
|
super();
|
|
1011
|
-
__privateAdd$
|
|
1012
|
-
__privateAdd$
|
|
1013
|
-
__privateAdd$
|
|
1014
|
-
__privateAdd$
|
|
1015
|
-
__privateAdd$
|
|
1011
|
+
__privateAdd$2(this, _shoutLockState);
|
|
1012
|
+
__privateAdd$2(this, _hasReleasedFirstTime, false);
|
|
1013
|
+
__privateAdd$2(this, _wasReleasedFirstTime, false);
|
|
1014
|
+
__privateAdd$2(this, _isForced, false);
|
|
1015
|
+
__privateAdd$2(this, _locks, {
|
|
1016
1016
|
common: false
|
|
1017
1017
|
});
|
|
1018
1018
|
this.emit("ready");
|
|
1019
1019
|
}
|
|
1020
1020
|
get hasReleasedFirstTime() {
|
|
1021
|
-
return __privateGet$
|
|
1021
|
+
return __privateGet$2(this, _hasReleasedFirstTime);
|
|
1022
1022
|
}
|
|
1023
1023
|
get isForced() {
|
|
1024
|
-
return __privateGet$
|
|
1024
|
+
return __privateGet$2(this, _isForced);
|
|
1025
1025
|
}
|
|
1026
1026
|
/**
|
|
1027
1027
|
* Permite saber si un bloqueo determinado está activo o si la clase tiene
|
|
1028
1028
|
* forceLock activo.
|
|
1029
1029
|
*/
|
|
1030
1030
|
isLocked(lockName = "common") {
|
|
1031
|
-
return __privateGet$
|
|
1031
|
+
return __privateGet$2(this, _locks)[lockName] || __privateGet$2(this, _isForced);
|
|
1032
1032
|
}
|
|
1033
1033
|
lock(lockName = "common") {
|
|
1034
|
-
__privateGet$
|
|
1034
|
+
__privateGet$2(this, _locks)[lockName] = true;
|
|
1035
1035
|
__privateMethod$1(this, _shoutLockState, shoutLockState_fn).call(this, lockName);
|
|
1036
1036
|
}
|
|
1037
1037
|
unlock(lockName = "common") {
|
|
1038
1038
|
if (lockName === "common")
|
|
1039
|
-
__privateSet$
|
|
1040
|
-
__privateGet$
|
|
1039
|
+
__privateSet$2(this, _hasReleasedFirstTime, true);
|
|
1040
|
+
__privateGet$2(this, _locks)[lockName] = false;
|
|
1041
1041
|
__privateMethod$1(this, _shoutLockState, shoutLockState_fn).call(this, lockName);
|
|
1042
1042
|
}
|
|
1043
1043
|
force() {
|
|
1044
|
-
__privateSet$
|
|
1044
|
+
__privateSet$2(this, _isForced, true);
|
|
1045
1045
|
__privateMethod$1(this, _shoutLockState, shoutLockState_fn).call(this);
|
|
1046
1046
|
}
|
|
1047
1047
|
releaseForced() {
|
|
1048
|
-
__privateSet$
|
|
1048
|
+
__privateSet$2(this, _isForced, false);
|
|
1049
1049
|
__privateMethod$1(this, _shoutLockState, shoutLockState_fn).call(this);
|
|
1050
1050
|
}
|
|
1051
1051
|
}, _hasReleasedFirstTime = new WeakMap(), _wasReleasedFirstTime = new WeakMap(), _isForced = new WeakMap(), _locks = new WeakMap(), _shoutLockState = new WeakSet(), shoutLockState_fn = function(lockName) {
|
|
1052
|
-
if (__privateGet$
|
|
1052
|
+
if (__privateGet$2(this, _isForced) || lockName === void 0) {
|
|
1053
1053
|
this.emit("forcedStateChange", {
|
|
1054
|
-
isForced: __privateGet$
|
|
1055
|
-
hasReleasedFirstTime: __privateGet$
|
|
1054
|
+
isForced: __privateGet$2(this, _isForced),
|
|
1055
|
+
hasReleasedFirstTime: __privateGet$2(this, _hasReleasedFirstTime)
|
|
1056
1056
|
});
|
|
1057
1057
|
} else {
|
|
1058
|
-
if (lockName === "common" && !__privateGet$
|
|
1058
|
+
if (lockName === "common" && !__privateGet$2(this, _wasReleasedFirstTime) && __privateGet$2(this, _hasReleasedFirstTime)) {
|
|
1059
1059
|
this.emit("releaseForFirstTime");
|
|
1060
1060
|
}
|
|
1061
1061
|
this.emit("lockStateChange", {
|
|
1062
1062
|
lockName,
|
|
1063
|
-
hasReleasedFirstTime: __privateGet$
|
|
1064
|
-
isLocked: __privateGet$
|
|
1063
|
+
hasReleasedFirstTime: __privateGet$2(this, _hasReleasedFirstTime),
|
|
1064
|
+
isLocked: __privateGet$2(this, _locks)[lockName]
|
|
1065
1065
|
});
|
|
1066
1066
|
}
|
|
1067
1067
|
}, _a$1)();
|
|
1068
1068
|
|
|
1069
|
+
function useCombinedRefs(...refs) {
|
|
1070
|
+
const [targetRef, setTargetRef] = React.useState();
|
|
1071
|
+
React.useEffect(() => {
|
|
1072
|
+
refs.forEach((ref) => {
|
|
1073
|
+
if (!ref)
|
|
1074
|
+
return;
|
|
1075
|
+
if (typeof ref === "function") {
|
|
1076
|
+
ref(targetRef);
|
|
1077
|
+
} else {
|
|
1078
|
+
ref.current = targetRef;
|
|
1079
|
+
}
|
|
1080
|
+
});
|
|
1081
|
+
}, [refs, targetRef]);
|
|
1082
|
+
return setTargetRef;
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1085
|
+
const useDebouncedCallback = (callback, { runWhenTriggered, timeout } = { runWhenTriggered: false, timeout: 200 }) => {
|
|
1086
|
+
const timeoutRef = useRef(-1);
|
|
1087
|
+
return useCallback(
|
|
1088
|
+
(...params) => {
|
|
1089
|
+
if (runWhenTriggered)
|
|
1090
|
+
callback(...params);
|
|
1091
|
+
clearTimeout(timeoutRef.current);
|
|
1092
|
+
timeoutRef.current = setTimeout(
|
|
1093
|
+
() => callback(...params),
|
|
1094
|
+
timeout
|
|
1095
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1096
|
+
);
|
|
1097
|
+
},
|
|
1098
|
+
[callback, runWhenTriggered, timeout]
|
|
1099
|
+
);
|
|
1100
|
+
};
|
|
1101
|
+
|
|
1102
|
+
function useLatest(value) {
|
|
1103
|
+
const ref = useRef(value);
|
|
1104
|
+
ref.current = value;
|
|
1105
|
+
return ref;
|
|
1106
|
+
}
|
|
1107
|
+
|
|
1108
|
+
function useMount(effect) {
|
|
1109
|
+
const hasRun = useRef(false);
|
|
1110
|
+
useEffect(() => {
|
|
1111
|
+
if (!hasRun.current) {
|
|
1112
|
+
hasRun.current = true;
|
|
1113
|
+
return effect();
|
|
1114
|
+
}
|
|
1115
|
+
}, []);
|
|
1116
|
+
}
|
|
1117
|
+
|
|
1118
|
+
function useUnmount(unmountCallback) {
|
|
1119
|
+
useEffect(() => {
|
|
1120
|
+
return unmountCallback;
|
|
1121
|
+
}, []);
|
|
1122
|
+
}
|
|
1123
|
+
|
|
1124
|
+
function usePrevious(value) {
|
|
1125
|
+
const previousValue = useRef(void 0);
|
|
1126
|
+
const currentValue = useRef(void 0);
|
|
1127
|
+
previousValue.current = currentValue.current;
|
|
1128
|
+
currentValue.current = value;
|
|
1129
|
+
return previousValue;
|
|
1130
|
+
}
|
|
1131
|
+
|
|
1132
|
+
function useStateRef(initialState) {
|
|
1133
|
+
const [state, setState] = useState(initialState);
|
|
1134
|
+
const stateRef = useRef(state);
|
|
1135
|
+
stateRef.current = state;
|
|
1136
|
+
return [state, setState, stateRef];
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1139
|
+
function useUpdateEffect(effect, deps) {
|
|
1140
|
+
const hasRunnedForFirstTime = useRef(false);
|
|
1141
|
+
useEffect(() => {
|
|
1142
|
+
if (hasRunnedForFirstTime.current) {
|
|
1143
|
+
return effect();
|
|
1144
|
+
}
|
|
1145
|
+
hasRunnedForFirstTime.current = true;
|
|
1146
|
+
return () => {
|
|
1147
|
+
};
|
|
1148
|
+
}, deps);
|
|
1149
|
+
}
|
|
1150
|
+
|
|
1151
|
+
function shallowEqual(a, b) {
|
|
1152
|
+
if (typeof a !== typeof b)
|
|
1153
|
+
return false;
|
|
1154
|
+
if (typeof a === "object" && a && typeof b === "object" && b) {
|
|
1155
|
+
const aKeys = Object.keys(a);
|
|
1156
|
+
const bKeys = Object.keys(b);
|
|
1157
|
+
if (aKeys.length !== bKeys.length)
|
|
1158
|
+
return false;
|
|
1159
|
+
for (let i = 0; i < aKeys.length; i++) {
|
|
1160
|
+
if (a[aKeys[i]] !== b[bKeys[i]])
|
|
1161
|
+
return false;
|
|
1162
|
+
}
|
|
1163
|
+
} else {
|
|
1164
|
+
if (a !== b)
|
|
1165
|
+
return false;
|
|
1166
|
+
}
|
|
1167
|
+
return true;
|
|
1168
|
+
}
|
|
1169
|
+
function shallowCompareArrays(a, b) {
|
|
1170
|
+
if (a.length !== b.length)
|
|
1171
|
+
return false;
|
|
1172
|
+
for (let i = 0; i < a.length; i++) {
|
|
1173
|
+
const differ = shallowEqual(a, b);
|
|
1174
|
+
if (!differ)
|
|
1175
|
+
return false;
|
|
1176
|
+
}
|
|
1177
|
+
return true;
|
|
1178
|
+
}
|
|
1179
|
+
function useShallowMemo(creator, deps) {
|
|
1180
|
+
var _a;
|
|
1181
|
+
const value = useRef(creator());
|
|
1182
|
+
const previousDeps = usePrevious(deps);
|
|
1183
|
+
if (!shallowEqual((_a = previousDeps.current) != null ? _a : [], deps)) {
|
|
1184
|
+
value.current = creator();
|
|
1185
|
+
}
|
|
1186
|
+
return value.current;
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1189
|
+
var __defProp$6 = Object.defineProperty;
|
|
1190
|
+
var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
|
|
1191
|
+
var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
|
|
1192
|
+
var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
|
|
1193
|
+
var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1194
|
+
var __spreadValues$6 = (a, b) => {
|
|
1195
|
+
for (var prop in b || (b = {}))
|
|
1196
|
+
if (__hasOwnProp$6.call(b, prop))
|
|
1197
|
+
__defNormalProp$6(a, prop, b[prop]);
|
|
1198
|
+
if (__getOwnPropSymbols$6)
|
|
1199
|
+
for (var prop of __getOwnPropSymbols$6(b)) {
|
|
1200
|
+
if (__propIsEnum$6.call(b, prop))
|
|
1201
|
+
__defNormalProp$6(a, prop, b[prop]);
|
|
1202
|
+
}
|
|
1203
|
+
return a;
|
|
1204
|
+
};
|
|
1205
|
+
var __accessCheck$1 = (obj, member, msg) => {
|
|
1206
|
+
if (!member.has(obj))
|
|
1207
|
+
throw TypeError("Cannot " + msg);
|
|
1208
|
+
};
|
|
1209
|
+
var __privateGet$1 = (obj, member, getter) => {
|
|
1210
|
+
__accessCheck$1(obj, member, "read from private field");
|
|
1211
|
+
return getter ? getter.call(obj) : member.get(obj);
|
|
1212
|
+
};
|
|
1213
|
+
var __privateAdd$1 = (obj, member, value) => {
|
|
1214
|
+
if (member.has(obj))
|
|
1215
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
1216
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
1217
|
+
};
|
|
1218
|
+
var __privateSet$1 = (obj, member, value, setter) => {
|
|
1219
|
+
__accessCheck$1(obj, member, "write to private field");
|
|
1220
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
1221
|
+
return value;
|
|
1222
|
+
};
|
|
1223
|
+
var _onUpdateCbs;
|
|
1224
|
+
function upper(s) {
|
|
1225
|
+
return `${s.charAt(0).toUpperCase()}${s.slice(1)}`;
|
|
1226
|
+
}
|
|
1227
|
+
function isUpdater(props) {
|
|
1228
|
+
return typeof props === "function";
|
|
1229
|
+
}
|
|
1230
|
+
class BasicStoredElement {
|
|
1231
|
+
constructor(props) {
|
|
1232
|
+
__privateAdd$1(this, _onUpdateCbs, []);
|
|
1233
|
+
this.props = {};
|
|
1234
|
+
this.shoutUpdates = () => {
|
|
1235
|
+
__privateGet$1(this, _onUpdateCbs).forEach((current) => current());
|
|
1236
|
+
};
|
|
1237
|
+
this.useProps = () => {
|
|
1238
|
+
const [props, setState] = useState(this.props);
|
|
1239
|
+
useMount(() => {
|
|
1240
|
+
setState(__spreadValues$6({}, this.props));
|
|
1241
|
+
return this.onUpdate(() => {
|
|
1242
|
+
setState(__spreadValues$6({}, this.props));
|
|
1243
|
+
});
|
|
1244
|
+
});
|
|
1245
|
+
return props;
|
|
1246
|
+
};
|
|
1247
|
+
this.props = props;
|
|
1248
|
+
}
|
|
1249
|
+
onUpdate(cb) {
|
|
1250
|
+
__privateGet$1(this, _onUpdateCbs).push(cb);
|
|
1251
|
+
return () => {
|
|
1252
|
+
__privateSet$1(this, _onUpdateCbs, __privateGet$1(this, _onUpdateCbs).filter((current) => current !== cb));
|
|
1253
|
+
};
|
|
1254
|
+
}
|
|
1255
|
+
update(newProps) {
|
|
1256
|
+
const actualNewProps = isUpdater(newProps) ? newProps(this.props) : newProps;
|
|
1257
|
+
this.props = __spreadValues$6(__spreadValues$6({}, this.props), actualNewProps);
|
|
1258
|
+
this.shoutUpdates();
|
|
1259
|
+
}
|
|
1260
|
+
}
|
|
1261
|
+
_onUpdateCbs = new WeakMap();
|
|
1262
|
+
class People extends BasicStoredElement {
|
|
1263
|
+
getId() {
|
|
1264
|
+
return this.props.name;
|
|
1265
|
+
}
|
|
1266
|
+
}
|
|
1267
|
+
const r = makeStatefulStore({
|
|
1268
|
+
people: People.prototype
|
|
1269
|
+
});
|
|
1270
|
+
r.actions.addPeople;
|
|
1271
|
+
r.actions.emptyPeople;
|
|
1272
|
+
r.actions.removePeople;
|
|
1273
|
+
r.hooks.usePeople;
|
|
1274
|
+
r.hooks.usePeopleById;
|
|
1275
|
+
r.hooks.usePeopleList;
|
|
1276
|
+
r.on.changePeople;
|
|
1277
|
+
r.on.changePeopleAmmount;
|
|
1278
|
+
r.on.changePeopleElement;
|
|
1279
|
+
r.state.getPeople;
|
|
1280
|
+
r.state.getPeopleState;
|
|
1281
|
+
r.state.updatePeople;
|
|
1282
|
+
function makeStatefulStore(entries, initialStates) {
|
|
1283
|
+
const hookUseState = {};
|
|
1284
|
+
const hookUseList = {};
|
|
1285
|
+
const hookUseStateById = {};
|
|
1286
|
+
const suscribeById = {};
|
|
1287
|
+
const suscribeToList = {};
|
|
1288
|
+
const suscribeToListCount = {};
|
|
1289
|
+
const addActions = {};
|
|
1290
|
+
const emptyActions = {};
|
|
1291
|
+
const removeActions = {};
|
|
1292
|
+
const getItemActions = {};
|
|
1293
|
+
const getStateActions = {};
|
|
1294
|
+
const updateItemActions = {};
|
|
1295
|
+
Object.keys(entries).forEach((name) => {
|
|
1296
|
+
const initialStateKey = `${upper(name)}State`;
|
|
1297
|
+
let store = {};
|
|
1298
|
+
const initialState = initialStates == null ? void 0 : initialStates[initialStateKey];
|
|
1299
|
+
initialState == null ? void 0 : initialState.forEach((current) => {
|
|
1300
|
+
store[current.getId()] = current;
|
|
1301
|
+
});
|
|
1302
|
+
let listStateChangeHandlers = [];
|
|
1303
|
+
function shoutListStateChange() {
|
|
1304
|
+
listStateChangeHandlers.forEach((current) => current());
|
|
1305
|
+
}
|
|
1306
|
+
const elementChangeHandlers = {};
|
|
1307
|
+
function shoutListElementChange(id) {
|
|
1308
|
+
var _a;
|
|
1309
|
+
(_a = elementChangeHandlers[id]) == null ? void 0 : _a.forEach((current) => current());
|
|
1310
|
+
}
|
|
1311
|
+
let listCountChangeHandlers = [];
|
|
1312
|
+
function shoutListCountChange() {
|
|
1313
|
+
listCountChangeHandlers.forEach((current) => current());
|
|
1314
|
+
}
|
|
1315
|
+
const onUpdateElementSuscriptions = {};
|
|
1316
|
+
const addKey = `add${upper(name)}`;
|
|
1317
|
+
addActions[addKey] = (newElement) => {
|
|
1318
|
+
let elId = newElement.getId();
|
|
1319
|
+
let lastProps = __spreadValues$6({}, newElement.props);
|
|
1320
|
+
store[elId] = newElement;
|
|
1321
|
+
const suscription = newElement.onUpdate(() => {
|
|
1322
|
+
const id = newElement.getId();
|
|
1323
|
+
if (id !== elId) {
|
|
1324
|
+
if (store[id]) {
|
|
1325
|
+
newElement.update(lastProps);
|
|
1326
|
+
throw new Error(
|
|
1327
|
+
`Cannot set new id ${id} because it already exists`
|
|
1328
|
+
);
|
|
1329
|
+
}
|
|
1330
|
+
delete store[elId];
|
|
1331
|
+
store[id] = newElement;
|
|
1332
|
+
elId = id;
|
|
1333
|
+
lastProps = newElement.props;
|
|
1334
|
+
}
|
|
1335
|
+
shoutListElementChange(id);
|
|
1336
|
+
shoutListStateChange();
|
|
1337
|
+
});
|
|
1338
|
+
onUpdateElementSuscriptions[newElement.getId()] = suscription;
|
|
1339
|
+
shoutListStateChange();
|
|
1340
|
+
shoutListCountChange();
|
|
1341
|
+
shoutListElementChange(elId);
|
|
1342
|
+
};
|
|
1343
|
+
const emptyKey = `empty${upper(name)}`;
|
|
1344
|
+
emptyActions[emptyKey] = () => {
|
|
1345
|
+
Object.values(onUpdateElementSuscriptions).forEach(
|
|
1346
|
+
(current) => current()
|
|
1347
|
+
);
|
|
1348
|
+
store = {};
|
|
1349
|
+
shoutListCountChange();
|
|
1350
|
+
shoutListStateChange();
|
|
1351
|
+
Object.keys(elementChangeHandlers).forEach(
|
|
1352
|
+
(current) => shoutListElementChange(current)
|
|
1353
|
+
);
|
|
1354
|
+
};
|
|
1355
|
+
const removeKey = `remove${upper(name)}`;
|
|
1356
|
+
removeActions[removeKey] = (id) => {
|
|
1357
|
+
var _a;
|
|
1358
|
+
(_a = onUpdateElementSuscriptions[id]) == null ? void 0 : _a.call(onUpdateElementSuscriptions);
|
|
1359
|
+
delete store[id];
|
|
1360
|
+
shoutListCountChange();
|
|
1361
|
+
shoutListStateChange();
|
|
1362
|
+
shoutListElementChange(id);
|
|
1363
|
+
};
|
|
1364
|
+
const getStateKey = `get${upper(name)}State`;
|
|
1365
|
+
getStateActions[getStateKey] = () => {
|
|
1366
|
+
return Object.values(store);
|
|
1367
|
+
};
|
|
1368
|
+
const getState = getStateActions[getStateKey];
|
|
1369
|
+
const getItemKey = `get${upper(name)}`;
|
|
1370
|
+
getItemActions[getItemKey] = (id) => {
|
|
1371
|
+
return store[id];
|
|
1372
|
+
};
|
|
1373
|
+
const updateItemKey = `update${upper(name)}`;
|
|
1374
|
+
updateItemActions[updateItemKey] = (id, newProps) => {
|
|
1375
|
+
store[id].update(newProps);
|
|
1376
|
+
};
|
|
1377
|
+
const hookUseStateKey = `use${upper(name)}`;
|
|
1378
|
+
hookUseState[hookUseStateKey] = () => {
|
|
1379
|
+
const [state2, setState] = useState(getState());
|
|
1380
|
+
useMount(() => {
|
|
1381
|
+
setState(getState());
|
|
1382
|
+
const eventHandler = () => {
|
|
1383
|
+
setState(getState());
|
|
1384
|
+
};
|
|
1385
|
+
listStateChangeHandlers.push(eventHandler);
|
|
1386
|
+
return () => {
|
|
1387
|
+
listStateChangeHandlers = listStateChangeHandlers.filter(
|
|
1388
|
+
(current) => current !== eventHandler
|
|
1389
|
+
);
|
|
1390
|
+
};
|
|
1391
|
+
});
|
|
1392
|
+
return state2;
|
|
1393
|
+
};
|
|
1394
|
+
const hookUseListKey = `use${upper(name)}List`;
|
|
1395
|
+
hookUseList[hookUseListKey] = () => {
|
|
1396
|
+
const [state2, setState] = useState(getState());
|
|
1397
|
+
useMount(() => {
|
|
1398
|
+
setState(getState());
|
|
1399
|
+
const eventHandler = () => {
|
|
1400
|
+
setState(getState());
|
|
1401
|
+
};
|
|
1402
|
+
listCountChangeHandlers.push(eventHandler);
|
|
1403
|
+
return () => {
|
|
1404
|
+
listCountChangeHandlers = listCountChangeHandlers.filter(
|
|
1405
|
+
(current) => current !== eventHandler
|
|
1406
|
+
);
|
|
1407
|
+
};
|
|
1408
|
+
});
|
|
1409
|
+
return state2;
|
|
1410
|
+
};
|
|
1411
|
+
const hookUseStateByIdKey = `use${upper(
|
|
1412
|
+
name
|
|
1413
|
+
)}ById`;
|
|
1414
|
+
hookUseStateById[hookUseStateByIdKey] = (id) => {
|
|
1415
|
+
const [state2, setState] = useState({ obj: store[id] });
|
|
1416
|
+
useMount(() => {
|
|
1417
|
+
setState({ obj: store[id] });
|
|
1418
|
+
const eventHandler = () => {
|
|
1419
|
+
setState({ obj: store[id] });
|
|
1420
|
+
};
|
|
1421
|
+
if (!elementChangeHandlers[id])
|
|
1422
|
+
elementChangeHandlers[id] = [];
|
|
1423
|
+
elementChangeHandlers[id].push(eventHandler);
|
|
1424
|
+
return () => {
|
|
1425
|
+
elementChangeHandlers[id] = elementChangeHandlers[id].filter(
|
|
1426
|
+
(current) => current !== eventHandler
|
|
1427
|
+
);
|
|
1428
|
+
};
|
|
1429
|
+
});
|
|
1430
|
+
return state2.obj;
|
|
1431
|
+
};
|
|
1432
|
+
const onChangeElementKey = `change${upper(
|
|
1433
|
+
name
|
|
1434
|
+
)}Element`;
|
|
1435
|
+
suscribeById[onChangeElementKey] = (id, cb) => {
|
|
1436
|
+
if (!elementChangeHandlers[id])
|
|
1437
|
+
elementChangeHandlers[id] = [];
|
|
1438
|
+
const innerCb = () => {
|
|
1439
|
+
cb(store[id]);
|
|
1440
|
+
};
|
|
1441
|
+
elementChangeHandlers[id].push(innerCb);
|
|
1442
|
+
return () => {
|
|
1443
|
+
elementChangeHandlers[id] = elementChangeHandlers[id].filter(
|
|
1444
|
+
(current) => current !== innerCb
|
|
1445
|
+
);
|
|
1446
|
+
};
|
|
1447
|
+
};
|
|
1448
|
+
const onChangeListKey = `change${upper(
|
|
1449
|
+
name
|
|
1450
|
+
)}`;
|
|
1451
|
+
suscribeToList[onChangeListKey] = (cb) => {
|
|
1452
|
+
const innerCb = () => {
|
|
1453
|
+
cb(getState());
|
|
1454
|
+
};
|
|
1455
|
+
listStateChangeHandlers.push(innerCb);
|
|
1456
|
+
return () => {
|
|
1457
|
+
listStateChangeHandlers = listStateChangeHandlers.filter(
|
|
1458
|
+
(current) => current !== innerCb
|
|
1459
|
+
);
|
|
1460
|
+
};
|
|
1461
|
+
};
|
|
1462
|
+
const onChangeListCountKey = `change${upper(
|
|
1463
|
+
name
|
|
1464
|
+
)}Ammount`;
|
|
1465
|
+
suscribeToListCount[onChangeListCountKey] = (cb) => {
|
|
1466
|
+
const innerCb = () => {
|
|
1467
|
+
cb(getState());
|
|
1468
|
+
};
|
|
1469
|
+
listCountChangeHandlers.push(innerCb);
|
|
1470
|
+
return () => {
|
|
1471
|
+
listCountChangeHandlers = listCountChangeHandlers.filter(
|
|
1472
|
+
(current) => current !== innerCb
|
|
1473
|
+
);
|
|
1474
|
+
};
|
|
1475
|
+
};
|
|
1476
|
+
});
|
|
1477
|
+
const actions = Object.assign(
|
|
1478
|
+
{},
|
|
1479
|
+
addActions,
|
|
1480
|
+
removeActions,
|
|
1481
|
+
emptyActions
|
|
1482
|
+
);
|
|
1483
|
+
const hooks = Object.assign({}, hookUseState, hookUseStateById, hookUseList);
|
|
1484
|
+
const on = Object.assign(
|
|
1485
|
+
{},
|
|
1486
|
+
suscribeById,
|
|
1487
|
+
suscribeToList,
|
|
1488
|
+
suscribeToListCount
|
|
1489
|
+
);
|
|
1490
|
+
const state = Object.assign(
|
|
1491
|
+
{},
|
|
1492
|
+
getStateActions,
|
|
1493
|
+
getItemActions,
|
|
1494
|
+
updateItemActions
|
|
1495
|
+
);
|
|
1496
|
+
return Object.assign(
|
|
1497
|
+
{},
|
|
1498
|
+
{ hooks },
|
|
1499
|
+
{ actions },
|
|
1500
|
+
{ state },
|
|
1501
|
+
{ on }
|
|
1502
|
+
);
|
|
1503
|
+
}
|
|
1504
|
+
|
|
1069
1505
|
const persistentStorage = new Proxy(
|
|
1070
1506
|
{
|
|
1071
1507
|
remove(prop) {
|
|
@@ -1440,126 +1876,6 @@ const focus = new (_a = class {
|
|
|
1440
1876
|
});
|
|
1441
1877
|
}, _a)(document.getElementById("root"));
|
|
1442
1878
|
|
|
1443
|
-
function useCombinedRefs(...refs) {
|
|
1444
|
-
const [targetRef, setTargetRef] = React.useState();
|
|
1445
|
-
React.useEffect(() => {
|
|
1446
|
-
refs.forEach((ref) => {
|
|
1447
|
-
if (!ref)
|
|
1448
|
-
return;
|
|
1449
|
-
if (typeof ref === "function") {
|
|
1450
|
-
ref(targetRef);
|
|
1451
|
-
} else {
|
|
1452
|
-
ref.current = targetRef;
|
|
1453
|
-
}
|
|
1454
|
-
});
|
|
1455
|
-
}, [refs, targetRef]);
|
|
1456
|
-
return setTargetRef;
|
|
1457
|
-
}
|
|
1458
|
-
|
|
1459
|
-
const useDebouncedCallback = (callback, { runWhenTriggered, timeout } = { runWhenTriggered: false, timeout: 200 }) => {
|
|
1460
|
-
const timeoutRef = useRef(-1);
|
|
1461
|
-
return useCallback(
|
|
1462
|
-
(...params) => {
|
|
1463
|
-
if (runWhenTriggered)
|
|
1464
|
-
callback(...params);
|
|
1465
|
-
clearTimeout(timeoutRef.current);
|
|
1466
|
-
timeoutRef.current = setTimeout(
|
|
1467
|
-
() => callback(...params),
|
|
1468
|
-
timeout
|
|
1469
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1470
|
-
);
|
|
1471
|
-
},
|
|
1472
|
-
[callback, runWhenTriggered, timeout]
|
|
1473
|
-
);
|
|
1474
|
-
};
|
|
1475
|
-
|
|
1476
|
-
function useLatest(value) {
|
|
1477
|
-
const ref = useRef(value);
|
|
1478
|
-
ref.current = value;
|
|
1479
|
-
return ref;
|
|
1480
|
-
}
|
|
1481
|
-
|
|
1482
|
-
function useMount(effect) {
|
|
1483
|
-
const hasRun = useRef(false);
|
|
1484
|
-
useEffect(() => {
|
|
1485
|
-
if (!hasRun.current) {
|
|
1486
|
-
hasRun.current = true;
|
|
1487
|
-
return effect();
|
|
1488
|
-
}
|
|
1489
|
-
}, []);
|
|
1490
|
-
}
|
|
1491
|
-
|
|
1492
|
-
function useUnmount(unmountCallback) {
|
|
1493
|
-
useEffect(() => {
|
|
1494
|
-
return unmountCallback;
|
|
1495
|
-
}, []);
|
|
1496
|
-
}
|
|
1497
|
-
|
|
1498
|
-
function usePrevious(value) {
|
|
1499
|
-
const previousValue = useRef(void 0);
|
|
1500
|
-
const currentValue = useRef(void 0);
|
|
1501
|
-
previousValue.current = currentValue.current;
|
|
1502
|
-
currentValue.current = value;
|
|
1503
|
-
return previousValue;
|
|
1504
|
-
}
|
|
1505
|
-
|
|
1506
|
-
function useStateRef(initialState) {
|
|
1507
|
-
const [state, setState] = useState(initialState);
|
|
1508
|
-
const stateRef = useRef(state);
|
|
1509
|
-
stateRef.current = state;
|
|
1510
|
-
return [state, setState, stateRef];
|
|
1511
|
-
}
|
|
1512
|
-
|
|
1513
|
-
function useUpdateEffect(effect, deps) {
|
|
1514
|
-
const hasRunnedForFirstTime = useRef(false);
|
|
1515
|
-
useEffect(() => {
|
|
1516
|
-
if (hasRunnedForFirstTime.current) {
|
|
1517
|
-
return effect();
|
|
1518
|
-
}
|
|
1519
|
-
hasRunnedForFirstTime.current = true;
|
|
1520
|
-
return () => {
|
|
1521
|
-
};
|
|
1522
|
-
}, deps);
|
|
1523
|
-
}
|
|
1524
|
-
|
|
1525
|
-
function shallowEqual(a, b) {
|
|
1526
|
-
if (typeof a !== typeof b)
|
|
1527
|
-
return false;
|
|
1528
|
-
if (typeof a === "object" && a && typeof b === "object" && b) {
|
|
1529
|
-
const aKeys = Object.keys(a);
|
|
1530
|
-
const bKeys = Object.keys(b);
|
|
1531
|
-
if (aKeys.length !== bKeys.length)
|
|
1532
|
-
return false;
|
|
1533
|
-
for (let i = 0; i < aKeys.length; i++) {
|
|
1534
|
-
if (a[aKeys[i]] !== b[bKeys[i]])
|
|
1535
|
-
return false;
|
|
1536
|
-
}
|
|
1537
|
-
} else {
|
|
1538
|
-
if (a !== b)
|
|
1539
|
-
return false;
|
|
1540
|
-
}
|
|
1541
|
-
return true;
|
|
1542
|
-
}
|
|
1543
|
-
function shallowCompareArrays(a, b) {
|
|
1544
|
-
if (a.length !== b.length)
|
|
1545
|
-
return false;
|
|
1546
|
-
for (let i = 0; i < a.length; i++) {
|
|
1547
|
-
const differ = shallowEqual(a, b);
|
|
1548
|
-
if (!differ)
|
|
1549
|
-
return false;
|
|
1550
|
-
}
|
|
1551
|
-
return true;
|
|
1552
|
-
}
|
|
1553
|
-
function useShallowMemo(creator, deps) {
|
|
1554
|
-
var _a;
|
|
1555
|
-
const value = useRef(creator());
|
|
1556
|
-
const previousDeps = usePrevious(deps);
|
|
1557
|
-
if (!shallowEqual((_a = previousDeps.current) != null ? _a : [], deps)) {
|
|
1558
|
-
value.current = creator();
|
|
1559
|
-
}
|
|
1560
|
-
return value.current;
|
|
1561
|
-
}
|
|
1562
|
-
|
|
1563
1879
|
var __defProp$5 = Object.defineProperty;
|
|
1564
1880
|
var __defProps$3 = Object.defineProperties;
|
|
1565
1881
|
var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
|
|
@@ -2340,4 +2656,4 @@ const parseXmlAsync = (xml) => __async(void 0, null, function* () {
|
|
|
2340
2656
|
return result;
|
|
2341
2657
|
});
|
|
2342
2658
|
|
|
2343
|
-
export { EventEmitter, HashedEventEmitter, History, PropsSelectorUndefinedObject, PropsStore, Url, WithEventsValue, addBoundary, animate, apiaDateToStandarFormat, arrayOrArray, autoDisconnectMutationObserver, cantFocusSelector, customEvents, dateToApiaFormat, debugDispatcher, decrypt, disableChildrenFocus, downloadUrl, enableChildrenFocus, enableDebugDispatcher, encrypt, eventEmitterBaseFunction, 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, shallowCompareArrays, shallowEqual, shortcutController, toBoolean, ucfirst, useCombinedRefs, useDebouncedCallback, useDebouncedState, useDomState, useImperativeComponentContext, useImperativeComponentEvents, useLatest, useLocalStorage, useMount, usePanAndZoom, usePrevious, usePropsSelector, useShallowMemo, useStateRef, useUnmount, useUpdateEffect };
|
|
2659
|
+
export { BasicStoredElement, EventEmitter, HashedEventEmitter, History, PropsSelectorUndefinedObject, PropsStore, Url, WithEventsValue, addBoundary, animate, apiaDateToStandarFormat, arrayOrArray, autoDisconnectMutationObserver, cantFocusSelector, customEvents, dateToApiaFormat, debugDispatcher, decrypt, disableChildrenFocus, downloadUrl, enableChildrenFocus, enableDebugDispatcher, encrypt, eventEmitterBaseFunction, findOffsetRelativeToScrollParent, findScrollContainer, focus, focusSelector, formatMessage, getDateFormat, getFocusSelector, getIndex, getLabel, getSpecificParent, getValueByPath, globalFocus, isChild, isDebugDispatcherEnabled, isPropsConfigurationObject, makeImperativeComponent, makeSingleImperativeComponent, makeStatefulStore, noNaN, notificationsSelector, parseAsSize, parseXmlAsync, persistentStorage, propsStore, screenLocker, scrollParentIntoElement, setValueByPath, shallowCompareArrays, shallowEqual, shortcutController, toBoolean, ucfirst, useCombinedRefs, useDebouncedCallback, useDebouncedState, useDomState, useImperativeComponentContext, useImperativeComponentEvents, useLatest, useLocalStorage, useMount, usePanAndZoom, usePrevious, usePropsSelector, useShallowMemo, useStateRef, useUnmount, useUpdateEffect };
|