@apia/util 4.0.16 → 4.0.17
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/dist/index.d.ts +102 -75
- package/dist/index.js +231 -187
- package/dist/index.js.map +1 -1
- package/package.json +5 -3
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { makeAutoObservable, makeObservable, observable } from 'mobx';
|
|
1
2
|
import { jsx } from 'react/jsx-runtime';
|
|
2
3
|
import * as React from 'react';
|
|
3
4
|
import React__default, { useRef, useCallback, useState, useEffect, useMemo, createContext, useContext } from 'react';
|
|
4
5
|
import uniqueId from 'lodash-es/uniqueId';
|
|
5
|
-
import { makeAutoObservable } from 'mobx';
|
|
6
6
|
import isFunction from 'lodash-es/isFunction';
|
|
7
7
|
import dayjs from 'dayjs';
|
|
8
8
|
import customParseFormat from 'dayjs/plugin/customParseFormat';
|
|
@@ -186,9 +186,21 @@ function dateToApiaFormat(date) {
|
|
|
186
186
|
return dayjs(date).format(getDateFormat());
|
|
187
187
|
}
|
|
188
188
|
|
|
189
|
-
const
|
|
189
|
+
const globals = {
|
|
190
|
+
getVersion() {
|
|
191
|
+
return {
|
|
192
|
+
version: VERSION,
|
|
193
|
+
commit: COMMITHASH,
|
|
194
|
+
branch: BRANCH,
|
|
195
|
+
env: ENVIRONMENT,
|
|
196
|
+
timestamp: TIMESTAMP,
|
|
197
|
+
package: PACKAGE_VERSION
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
window.Globals = globals;
|
|
190
202
|
function isDebugDispatcherEnabled() {
|
|
191
|
-
return
|
|
203
|
+
return globals.getVersion().env === "development";
|
|
192
204
|
}
|
|
193
205
|
const debugDispatcher = new class DDispatcher {
|
|
194
206
|
constructor() {
|
|
@@ -216,7 +228,7 @@ const debugDispatcher = new class DDispatcher {
|
|
|
216
228
|
};
|
|
217
229
|
}
|
|
218
230
|
on(action, cb, help, onlyDevelop = false) {
|
|
219
|
-
if (!
|
|
231
|
+
if (!isDebugDispatcherEnabled() && onlyDevelop)
|
|
220
232
|
return () => {
|
|
221
233
|
};
|
|
222
234
|
if (Object.keys(this.actions).includes(action))
|
|
@@ -533,43 +545,88 @@ function autoDisconnectMutationObserver(element, callback, conf) {
|
|
|
533
545
|
|
|
534
546
|
const REGEXP_SCROLL_PARENT = /^(visible|hidden)/;
|
|
535
547
|
function findScrollContainer(el) {
|
|
536
|
-
|
|
548
|
+
const found = !(el instanceof HTMLElement) || typeof window.getComputedStyle !== "function" ? null : el.scrollHeight >= el.clientHeight && !REGEXP_SCROLL_PARENT.test(
|
|
537
549
|
window.getComputedStyle(el).overflowY || "visible"
|
|
538
|
-
) ? el : findScrollContainer(el.parentElement) || document
|
|
550
|
+
) ? el : findScrollContainer(el.parentElement) || document;
|
|
551
|
+
if (found === document.body) {
|
|
552
|
+
return document.body.parentElement;
|
|
553
|
+
}
|
|
554
|
+
return found;
|
|
539
555
|
}
|
|
540
556
|
|
|
541
557
|
function findOffsetRelativeToScrollParent(element, which = "Top") {
|
|
542
558
|
const scrollParent = findScrollContainer(element);
|
|
543
|
-
let currentElement = element;
|
|
544
559
|
let offset = 0;
|
|
545
|
-
let
|
|
546
|
-
while (
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
offsetParent = currentElement.offsetParent;
|
|
550
|
-
}
|
|
551
|
-
currentElement = currentElement.parentElement;
|
|
560
|
+
let current = element;
|
|
561
|
+
while (current && current !== document.body && current !== scrollParent) {
|
|
562
|
+
offset += current[`offset${which}`];
|
|
563
|
+
current = current.offsetParent;
|
|
552
564
|
}
|
|
553
|
-
|
|
565
|
+
const scrollAmount = scrollParent[`scroll${which}`] || 0;
|
|
566
|
+
return offset - scrollAmount;
|
|
554
567
|
}
|
|
555
568
|
|
|
556
569
|
const scrollIntervals = {};
|
|
557
|
-
function scrollParentIntoElement(element, fixedOffsetTop = 0, tries = 2, timeout = 100, scrollId
|
|
558
|
-
|
|
559
|
-
|
|
570
|
+
function scrollParentIntoElement(element, fixedOffsetTop = 0, tries = 2, timeout = 100, scrollId) {
|
|
571
|
+
const id = scrollId ?? `${Date.now()}_${Math.random()}`;
|
|
572
|
+
if (scrollIntervals[id]) {
|
|
573
|
+
clearTimeout(scrollIntervals[id]);
|
|
560
574
|
}
|
|
561
575
|
const scrollParent = findScrollContainer(element);
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
576
|
+
if (!scrollParent) {
|
|
577
|
+
return;
|
|
578
|
+
}
|
|
579
|
+
const parentRect = scrollParent.getBoundingClientRect();
|
|
580
|
+
const elemRect = element.getBoundingClientRect();
|
|
581
|
+
const topOverflow = elemRect.top - (parentRect.top + fixedOffsetTop);
|
|
582
|
+
const bottomOverflow = elemRect.bottom - parentRect.bottom + fixedOffsetTop;
|
|
583
|
+
if (topOverflow < 0) {
|
|
584
|
+
scrollParent.scrollTop += topOverflow;
|
|
585
|
+
} else if (bottomOverflow > 0) {
|
|
586
|
+
scrollParent.scrollTop += bottomOverflow;
|
|
587
|
+
}
|
|
588
|
+
if (tries > 0) {
|
|
589
|
+
scrollIntervals[id] = window.setTimeout(() => {
|
|
590
|
+
scrollParentIntoElement(element, fixedOffsetTop, tries - 1, timeout, id);
|
|
591
|
+
}, timeout);
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
const controller = {
|
|
596
|
+
direction: ""
|
|
597
|
+
};
|
|
598
|
+
makeObservable(controller, { direction: observable });
|
|
599
|
+
function initScrollController() {
|
|
600
|
+
if (controller.direction !== "")
|
|
601
|
+
return;
|
|
602
|
+
controller.direction = "both";
|
|
603
|
+
function setShouldShow(direction) {
|
|
604
|
+
controller.direction = direction;
|
|
605
|
+
}
|
|
606
|
+
const resizeObserver = new ResizeObserver(() => {
|
|
607
|
+
if (document.documentElement.scrollHeight === window.innerHeight)
|
|
608
|
+
controller.direction = "both";
|
|
609
|
+
});
|
|
610
|
+
resizeObserver.observe(document.documentElement);
|
|
611
|
+
let currentScroll = document.documentElement.scrollTop;
|
|
612
|
+
function handleScroll() {
|
|
613
|
+
const direction = controller.direction;
|
|
614
|
+
if (document.documentElement.scrollTop > currentScroll && direction !== "down") {
|
|
615
|
+
setShouldShow("down");
|
|
616
|
+
} else if (document.documentElement.scrollTop < currentScroll && direction !== "up") {
|
|
617
|
+
setShouldShow("up");
|
|
618
|
+
}
|
|
619
|
+
currentScroll = document.documentElement.scrollTop;
|
|
620
|
+
}
|
|
621
|
+
document.addEventListener("scroll", handleScroll);
|
|
622
|
+
return () => {
|
|
623
|
+
resizeObserver.disconnect();
|
|
624
|
+
document.removeEventListener("scroll", handleScroll);
|
|
625
|
+
};
|
|
626
|
+
}
|
|
627
|
+
initScrollController();
|
|
628
|
+
function useMatchScrollDirection(direction) {
|
|
629
|
+
return controller.direction === "both" || controller.direction === direction;
|
|
573
630
|
}
|
|
574
631
|
|
|
575
632
|
function usePanAndZoom(effectiveMargin = { left: 0, bottom: 0, right: 0, top: 0 }, blockZoom = true) {
|
|
@@ -708,7 +765,12 @@ const customEvents = {
|
|
|
708
765
|
* está vacío
|
|
709
766
|
*/
|
|
710
767
|
hidePanel: "hidePanel",
|
|
711
|
-
showPanel: "showPanel"
|
|
768
|
+
showPanel: "showPanel",
|
|
769
|
+
/**
|
|
770
|
+
* Evento lanzado por formsEventsController sobre window
|
|
771
|
+
* cuando se termina de procesar los formularios de la tarea
|
|
772
|
+
*/
|
|
773
|
+
formsReady: "formsReady"
|
|
712
774
|
};
|
|
713
775
|
|
|
714
776
|
const cantFocusSelector = [
|
|
@@ -760,15 +822,15 @@ function isChild(element, checkParent) {
|
|
|
760
822
|
return !!getSpecificParent(element, checkParent);
|
|
761
823
|
}
|
|
762
824
|
|
|
763
|
-
var __accessCheck$
|
|
825
|
+
var __accessCheck$3 = (obj, member, msg) => {
|
|
764
826
|
if (!member.has(obj))
|
|
765
827
|
throw TypeError("Cannot " + msg);
|
|
766
828
|
};
|
|
767
|
-
var __privateGet$
|
|
768
|
-
__accessCheck$
|
|
829
|
+
var __privateGet$3 = (obj, member, getter) => {
|
|
830
|
+
__accessCheck$3(obj, member, "read from private field");
|
|
769
831
|
return getter ? getter.call(obj) : member.get(obj);
|
|
770
832
|
};
|
|
771
|
-
var __privateAdd$
|
|
833
|
+
var __privateAdd$3 = (obj, member, value) => {
|
|
772
834
|
if (member.has(obj))
|
|
773
835
|
throw TypeError("Cannot add the same private member more than once");
|
|
774
836
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
@@ -777,7 +839,7 @@ var _parameters;
|
|
|
777
839
|
class Url {
|
|
778
840
|
constructor(baseUrl, defaultAllowMultiple = true) {
|
|
779
841
|
this.defaultAllowMultiple = defaultAllowMultiple;
|
|
780
|
-
__privateAdd$
|
|
842
|
+
__privateAdd$3(this, _parameters, {});
|
|
781
843
|
const [base, query] = baseUrl.split("?");
|
|
782
844
|
this.base = base;
|
|
783
845
|
query?.split("&").forEach((current) => {
|
|
@@ -787,9 +849,9 @@ class Url {
|
|
|
787
849
|
}
|
|
788
850
|
addParameter(name, value, allowMultiple) {
|
|
789
851
|
if (allowMultiple === void 0 && !this.defaultAllowMultiple || allowMultiple === false)
|
|
790
|
-
__privateGet$
|
|
852
|
+
__privateGet$3(this, _parameters)[name] = String(value);
|
|
791
853
|
else
|
|
792
|
-
__privateGet$
|
|
854
|
+
__privateGet$3(this, _parameters)[name] = __privateGet$3(this, _parameters)[name] ? [...arrayOrArray(__privateGet$3(this, _parameters)[name]), String(value)] : [String(value)];
|
|
793
855
|
}
|
|
794
856
|
addParameters(parameters) {
|
|
795
857
|
parameters.forEach(
|
|
@@ -797,10 +859,10 @@ class Url {
|
|
|
797
859
|
);
|
|
798
860
|
}
|
|
799
861
|
getParameter(name) {
|
|
800
|
-
return __privateGet$
|
|
862
|
+
return __privateGet$3(this, _parameters)[name];
|
|
801
863
|
}
|
|
802
864
|
toString() {
|
|
803
|
-
const parametersArray = Object.entries(__privateGet$
|
|
865
|
+
const parametersArray = Object.entries(__privateGet$3(this, _parameters));
|
|
804
866
|
return `${this.base}${parametersArray.length > 0 ? `?${parametersArray.map(
|
|
805
867
|
([name, value]) => Array.isArray(value) ? value.map((current) => `${name}=${current}`).join("&") : `${name}=${String(value)}`
|
|
806
868
|
).join("&")}` : ""}`;
|
|
@@ -887,7 +949,9 @@ class EventEmitter {
|
|
|
887
949
|
on(event, cb) {
|
|
888
950
|
if (!this.callbacks.on[event])
|
|
889
951
|
this.callbacks.on[event] = [];
|
|
890
|
-
this.callbacks.on[event].
|
|
952
|
+
if (!this.callbacks.on[event].find((c) => c === cb)) {
|
|
953
|
+
this.callbacks.on[event].push(cb);
|
|
954
|
+
}
|
|
891
955
|
return () => {
|
|
892
956
|
this.callbacks.on[event] = this.callbacks.on[event].filter(
|
|
893
957
|
(c) => c !== cb
|
|
@@ -1212,22 +1276,22 @@ class BouncingEmitter extends StatefulEmitter {
|
|
|
1212
1276
|
}
|
|
1213
1277
|
}
|
|
1214
1278
|
|
|
1215
|
-
var __accessCheck$
|
|
1279
|
+
var __accessCheck$2 = (obj, member, msg) => {
|
|
1216
1280
|
if (!member.has(obj))
|
|
1217
1281
|
throw TypeError("Cannot " + msg);
|
|
1218
1282
|
};
|
|
1219
|
-
var __privateGet$
|
|
1220
|
-
__accessCheck$
|
|
1283
|
+
var __privateGet$2 = (obj, member, getter) => {
|
|
1284
|
+
__accessCheck$2(obj, member, "read from private field");
|
|
1221
1285
|
return getter ? getter.call(obj) : member.get(obj);
|
|
1222
1286
|
};
|
|
1223
|
-
var __privateAdd$
|
|
1287
|
+
var __privateAdd$2 = (obj, member, value) => {
|
|
1224
1288
|
if (member.has(obj))
|
|
1225
1289
|
throw TypeError("Cannot add the same private member more than once");
|
|
1226
1290
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
1227
1291
|
};
|
|
1228
|
-
var __privateSet$
|
|
1229
|
-
__accessCheck$
|
|
1230
|
-
|
|
1292
|
+
var __privateSet$2 = (obj, member, value, setter) => {
|
|
1293
|
+
__accessCheck$2(obj, member, "write to private field");
|
|
1294
|
+
member.set(obj, value);
|
|
1231
1295
|
return value;
|
|
1232
1296
|
};
|
|
1233
1297
|
var _onFocusCallbacks, _a$1;
|
|
@@ -1235,7 +1299,7 @@ const historySize = 50;
|
|
|
1235
1299
|
const globalFocus = new (_a$1 = class {
|
|
1236
1300
|
constructor() {
|
|
1237
1301
|
this.focused = [];
|
|
1238
|
-
__privateAdd$
|
|
1302
|
+
__privateAdd$2(this, _onFocusCallbacks, []);
|
|
1239
1303
|
debugDispatcher.on(
|
|
1240
1304
|
"focusHistory",
|
|
1241
1305
|
() => {
|
|
@@ -1245,12 +1309,12 @@ const globalFocus = new (_a$1 = class {
|
|
|
1245
1309
|
);
|
|
1246
1310
|
}
|
|
1247
1311
|
offFocus(cb) {
|
|
1248
|
-
__privateSet$
|
|
1312
|
+
__privateSet$2(this, _onFocusCallbacks, __privateGet$2(this, _onFocusCallbacks).filter(
|
|
1249
1313
|
(current) => current !== cb
|
|
1250
1314
|
));
|
|
1251
1315
|
}
|
|
1252
1316
|
onFocus(cb) {
|
|
1253
|
-
__privateGet$
|
|
1317
|
+
__privateGet$2(this, _onFocusCallbacks).push(cb);
|
|
1254
1318
|
return () => {
|
|
1255
1319
|
this.offFocus(cb);
|
|
1256
1320
|
};
|
|
@@ -1267,7 +1331,7 @@ const globalFocus = new (_a$1 = class {
|
|
|
1267
1331
|
if (this.focused.length > historySize) {
|
|
1268
1332
|
this.focused = this.focused.splice(0, historySize);
|
|
1269
1333
|
}
|
|
1270
|
-
__privateGet$
|
|
1334
|
+
__privateGet$2(this, _onFocusCallbacks).forEach((cb) => cb());
|
|
1271
1335
|
}
|
|
1272
1336
|
get list() {
|
|
1273
1337
|
return [...this.focused];
|
|
@@ -1294,97 +1358,6 @@ const globalFocus = new (_a$1 = class {
|
|
|
1294
1358
|
}
|
|
1295
1359
|
}, _onFocusCallbacks = new WeakMap(), _a$1)();
|
|
1296
1360
|
|
|
1297
|
-
var __accessCheck$2 = (obj, member, msg) => {
|
|
1298
|
-
if (!member.has(obj))
|
|
1299
|
-
throw TypeError("Cannot " + msg);
|
|
1300
|
-
};
|
|
1301
|
-
var __privateGet$2 = (obj, member, getter) => {
|
|
1302
|
-
__accessCheck$2(obj, member, "read from private field");
|
|
1303
|
-
return getter ? getter.call(obj) : member.get(obj);
|
|
1304
|
-
};
|
|
1305
|
-
var __privateAdd$2 = (obj, member, value) => {
|
|
1306
|
-
if (member.has(obj))
|
|
1307
|
-
throw TypeError("Cannot add the same private member more than once");
|
|
1308
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
1309
|
-
};
|
|
1310
|
-
var __privateSet$2 = (obj, member, value, setter) => {
|
|
1311
|
-
__accessCheck$2(obj, member, "write to private field");
|
|
1312
|
-
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
1313
|
-
return value;
|
|
1314
|
-
};
|
|
1315
|
-
var __privateMethod$1 = (obj, member, method) => {
|
|
1316
|
-
__accessCheck$2(obj, member, "access private method");
|
|
1317
|
-
return method;
|
|
1318
|
-
};
|
|
1319
|
-
var _hasReleasedFirstTime, _wasReleasedFirstTime, _isForced, _locks, _shoutLockState, shoutLockState_fn;
|
|
1320
|
-
class ScreenLocker extends EventEmitter {
|
|
1321
|
-
constructor() {
|
|
1322
|
-
super();
|
|
1323
|
-
__privateAdd$2(this, _shoutLockState);
|
|
1324
|
-
__privateAdd$2(this, _hasReleasedFirstTime, false);
|
|
1325
|
-
__privateAdd$2(this, _wasReleasedFirstTime, false);
|
|
1326
|
-
__privateAdd$2(this, _isForced, false);
|
|
1327
|
-
__privateAdd$2(this, _locks, {
|
|
1328
|
-
common: false
|
|
1329
|
-
});
|
|
1330
|
-
this.emit("ready", null);
|
|
1331
|
-
}
|
|
1332
|
-
get hasReleasedFirstTime() {
|
|
1333
|
-
return __privateGet$2(this, _hasReleasedFirstTime);
|
|
1334
|
-
}
|
|
1335
|
-
get isForced() {
|
|
1336
|
-
return __privateGet$2(this, _isForced);
|
|
1337
|
-
}
|
|
1338
|
-
/**
|
|
1339
|
-
* Permite saber si un bloqueo determinado está activo o si la clase tiene
|
|
1340
|
-
* forceLock activo.
|
|
1341
|
-
*/
|
|
1342
|
-
isLocked(lockName = "common") {
|
|
1343
|
-
return __privateGet$2(this, _locks)[lockName] || __privateGet$2(this, _isForced);
|
|
1344
|
-
}
|
|
1345
|
-
lock(lockName = "common") {
|
|
1346
|
-
__privateGet$2(this, _locks)[lockName] = true;
|
|
1347
|
-
__privateMethod$1(this, _shoutLockState, shoutLockState_fn).call(this, lockName);
|
|
1348
|
-
}
|
|
1349
|
-
unlock(lockName = "common") {
|
|
1350
|
-
if (lockName === "common")
|
|
1351
|
-
__privateSet$2(this, _hasReleasedFirstTime, true);
|
|
1352
|
-
__privateGet$2(this, _locks)[lockName] = false;
|
|
1353
|
-
__privateMethod$1(this, _shoutLockState, shoutLockState_fn).call(this, lockName);
|
|
1354
|
-
}
|
|
1355
|
-
force() {
|
|
1356
|
-
__privateSet$2(this, _isForced, true);
|
|
1357
|
-
__privateMethod$1(this, _shoutLockState, shoutLockState_fn).call(this);
|
|
1358
|
-
}
|
|
1359
|
-
releaseForced() {
|
|
1360
|
-
__privateSet$2(this, _isForced, false);
|
|
1361
|
-
__privateMethod$1(this, _shoutLockState, shoutLockState_fn).call(this);
|
|
1362
|
-
}
|
|
1363
|
-
}
|
|
1364
|
-
_hasReleasedFirstTime = new WeakMap();
|
|
1365
|
-
_wasReleasedFirstTime = new WeakMap();
|
|
1366
|
-
_isForced = new WeakMap();
|
|
1367
|
-
_locks = new WeakMap();
|
|
1368
|
-
_shoutLockState = new WeakSet();
|
|
1369
|
-
shoutLockState_fn = function(lockName) {
|
|
1370
|
-
if (__privateGet$2(this, _isForced) || lockName === void 0) {
|
|
1371
|
-
this.emit("forcedStateChange", {
|
|
1372
|
-
isForced: __privateGet$2(this, _isForced),
|
|
1373
|
-
hasReleasedFirstTime: __privateGet$2(this, _hasReleasedFirstTime)
|
|
1374
|
-
});
|
|
1375
|
-
} else {
|
|
1376
|
-
if (lockName === "common" && !__privateGet$2(this, _wasReleasedFirstTime) && __privateGet$2(this, _hasReleasedFirstTime)) {
|
|
1377
|
-
this.emit("releaseForFirstTime", null);
|
|
1378
|
-
}
|
|
1379
|
-
this.emit("lockStateChange", {
|
|
1380
|
-
lockName,
|
|
1381
|
-
hasReleasedFirstTime: __privateGet$2(this, _hasReleasedFirstTime),
|
|
1382
|
-
isLocked: __privateGet$2(this, _locks)[lockName]
|
|
1383
|
-
});
|
|
1384
|
-
}
|
|
1385
|
-
};
|
|
1386
|
-
const screenLocker = new ScreenLocker();
|
|
1387
|
-
|
|
1388
1361
|
var __accessCheck$1 = (obj, member, msg) => {
|
|
1389
1362
|
if (!member.has(obj))
|
|
1390
1363
|
throw TypeError("Cannot " + msg);
|
|
@@ -1400,7 +1373,7 @@ var __privateAdd$1 = (obj, member, value) => {
|
|
|
1400
1373
|
};
|
|
1401
1374
|
var __privateSet$1 = (obj, member, value, setter) => {
|
|
1402
1375
|
__accessCheck$1(obj, member, "write to private field");
|
|
1403
|
-
|
|
1376
|
+
member.set(obj, value);
|
|
1404
1377
|
return value;
|
|
1405
1378
|
};
|
|
1406
1379
|
var _onUpdateCbs;
|
|
@@ -1705,7 +1678,6 @@ const persistentStorage = new Proxy(
|
|
|
1705
1678
|
}
|
|
1706
1679
|
);
|
|
1707
1680
|
window.persistentStorage = persistentStorage;
|
|
1708
|
-
var persistentStorage$1 = persistentStorage;
|
|
1709
1681
|
|
|
1710
1682
|
const localStorageController = new class LocalSctorageController extends EventEmitter {
|
|
1711
1683
|
}();
|
|
@@ -1742,6 +1714,105 @@ function useLocalStorage(prop, defaultValue) {
|
|
|
1742
1714
|
];
|
|
1743
1715
|
}
|
|
1744
1716
|
|
|
1717
|
+
class Semaphore {
|
|
1718
|
+
/**
|
|
1719
|
+
* Creates a new instance of the Semaphore.
|
|
1720
|
+
*
|
|
1721
|
+
* @param concurrency - The maximum number of concurrent tasks allowed.
|
|
1722
|
+
*/
|
|
1723
|
+
constructor(concurrency) {
|
|
1724
|
+
this.concurrency = concurrency;
|
|
1725
|
+
this.current = 0;
|
|
1726
|
+
this.queue = [];
|
|
1727
|
+
}
|
|
1728
|
+
/**
|
|
1729
|
+
* Acquires a permit to run a task.
|
|
1730
|
+
*
|
|
1731
|
+
* If the number of currently acquired permits is less than the concurrency limit,
|
|
1732
|
+
* the promise resolves immediately. Otherwise, it is queued until a permit is released.
|
|
1733
|
+
*
|
|
1734
|
+
* @returns A promise that resolves when the permit has been acquired.
|
|
1735
|
+
*/
|
|
1736
|
+
async acquire() {
|
|
1737
|
+
if (this.current < this.concurrency) {
|
|
1738
|
+
this.current++;
|
|
1739
|
+
return Promise.resolve();
|
|
1740
|
+
}
|
|
1741
|
+
return new Promise((resolve) => {
|
|
1742
|
+
this.queue.push(resolve);
|
|
1743
|
+
});
|
|
1744
|
+
}
|
|
1745
|
+
/**
|
|
1746
|
+
* Releases a previously acquired permit.
|
|
1747
|
+
*
|
|
1748
|
+
* If there are queued tasks waiting for a permit, the next one is dequeued and allowed to proceed.
|
|
1749
|
+
*/
|
|
1750
|
+
release() {
|
|
1751
|
+
this.current--;
|
|
1752
|
+
this.queue.shift()?.();
|
|
1753
|
+
}
|
|
1754
|
+
}
|
|
1755
|
+
|
|
1756
|
+
class Mutex extends Semaphore {
|
|
1757
|
+
constructor() {
|
|
1758
|
+
super(1);
|
|
1759
|
+
}
|
|
1760
|
+
async runExclusive(cb) {
|
|
1761
|
+
await this.acquire();
|
|
1762
|
+
await cb();
|
|
1763
|
+
this.release();
|
|
1764
|
+
}
|
|
1765
|
+
}
|
|
1766
|
+
|
|
1767
|
+
class Locker extends EventEmitter {
|
|
1768
|
+
constructor() {
|
|
1769
|
+
super();
|
|
1770
|
+
this.locks = 0;
|
|
1771
|
+
this.hasReleased = false;
|
|
1772
|
+
this.mutex = new Mutex();
|
|
1773
|
+
makeObservable(this, {
|
|
1774
|
+
locks: observable
|
|
1775
|
+
});
|
|
1776
|
+
}
|
|
1777
|
+
get isLocked() {
|
|
1778
|
+
return this.locks > 0;
|
|
1779
|
+
}
|
|
1780
|
+
lock() {
|
|
1781
|
+
this.mutex.acquire().then(() => {
|
|
1782
|
+
this.locks++;
|
|
1783
|
+
});
|
|
1784
|
+
}
|
|
1785
|
+
unlock() {
|
|
1786
|
+
this.mutex.acquire().then(() => {
|
|
1787
|
+
this.locks--;
|
|
1788
|
+
if (!this.hasReleased && this.locks === 0) {
|
|
1789
|
+
this.emit("releaseForFirstTime", null);
|
|
1790
|
+
this.hasReleased = true;
|
|
1791
|
+
}
|
|
1792
|
+
});
|
|
1793
|
+
}
|
|
1794
|
+
}
|
|
1795
|
+
const screenLocker = new Locker();
|
|
1796
|
+
|
|
1797
|
+
class ScrollLocker {
|
|
1798
|
+
static evaluate() {
|
|
1799
|
+
Object.assign(document.body.style, {
|
|
1800
|
+
maxHeight: this.locks > 0 ? "100vh" : "unset",
|
|
1801
|
+
overflow: this.locks > 0 ? "hidden" : "auto",
|
|
1802
|
+
paddingRight: this.locks > 0 && document.body.scrollHeight > document.body.clientHeight ? "10px" : "0px"
|
|
1803
|
+
});
|
|
1804
|
+
}
|
|
1805
|
+
static lock() {
|
|
1806
|
+
this.locks++;
|
|
1807
|
+
this.evaluate();
|
|
1808
|
+
}
|
|
1809
|
+
static unlock() {
|
|
1810
|
+
this.locks--;
|
|
1811
|
+
this.evaluate();
|
|
1812
|
+
}
|
|
1813
|
+
}
|
|
1814
|
+
ScrollLocker.locks = 0;
|
|
1815
|
+
|
|
1745
1816
|
var __accessCheck = (obj, member, msg) => {
|
|
1746
1817
|
if (!member.has(obj))
|
|
1747
1818
|
throw TypeError("Cannot " + msg);
|
|
@@ -1757,12 +1828,12 @@ var __privateAdd = (obj, member, value) => {
|
|
|
1757
1828
|
};
|
|
1758
1829
|
var __privateSet = (obj, member, value, setter) => {
|
|
1759
1830
|
__accessCheck(obj, member, "write to private field");
|
|
1760
|
-
|
|
1831
|
+
member.set(obj, value);
|
|
1761
1832
|
return value;
|
|
1762
1833
|
};
|
|
1763
1834
|
var __privateWrapper = (obj, member, setter, getter) => ({
|
|
1764
1835
|
set _(value) {
|
|
1765
|
-
__privateSet(obj, member, value
|
|
1836
|
+
__privateSet(obj, member, value);
|
|
1766
1837
|
},
|
|
1767
1838
|
get _() {
|
|
1768
1839
|
return __privateGet(obj, member, getter);
|
|
@@ -1826,7 +1897,7 @@ const focus = new (_a = class {
|
|
|
1826
1897
|
name,
|
|
1827
1898
|
selector
|
|
1828
1899
|
}) {
|
|
1829
|
-
persistentStorage
|
|
1900
|
+
persistentStorage.focusOnReload = [
|
|
1830
1901
|
id ? `#${id}` : void 0,
|
|
1831
1902
|
name ? `[name="${name}"]` : void 0,
|
|
1832
1903
|
className ? `.${className}` : void 0,
|
|
@@ -1876,9 +1947,9 @@ const focus = new (_a = class {
|
|
|
1876
1947
|
if (appModalsBox)
|
|
1877
1948
|
modalsObserver.observe(appModalsBox, { childList: true });
|
|
1878
1949
|
screenLocker.on("releaseForFirstTime", () => {
|
|
1879
|
-
if (persistentStorage
|
|
1880
|
-
this.focusOnReload = persistentStorage
|
|
1881
|
-
persistentStorage
|
|
1950
|
+
if (persistentStorage.focusOnReload)
|
|
1951
|
+
this.focusOnReload = persistentStorage.focusOnReload;
|
|
1952
|
+
persistentStorage.focusOnReload = null;
|
|
1882
1953
|
this.afterNotifications(() => {
|
|
1883
1954
|
if (this.focusOnReload) {
|
|
1884
1955
|
const initialFocusElement = document.querySelector(
|
|
@@ -1915,7 +1986,7 @@ const focus = new (_a = class {
|
|
|
1915
1986
|
}, _checkInstruction = new WeakSet(), checkInstruction_fn = function(focusCheck) {
|
|
1916
1987
|
return focusCheck.currentInstruction === __privateGet(this, _currentInstruction);
|
|
1917
1988
|
}, _doFocus = new WeakSet(), doFocus_fn = async function(HTMLElement, focusCheck, isLastTry, configuration) {
|
|
1918
|
-
if (screenLocker.isLocked
|
|
1989
|
+
if (screenLocker.isLocked && !configuration?.focusEvenWhenScreenLocked) {
|
|
1919
1990
|
return null;
|
|
1920
1991
|
}
|
|
1921
1992
|
const actualHTMLElement = isFunction(HTMLElement) ? HTMLElement(isLastTry) : HTMLElement;
|
|
@@ -2267,7 +2338,6 @@ const useImperativeComponentEvents = (handlers) => {
|
|
|
2267
2338
|
}, [eventsStore, handlers, id, registerEvents, uniqueHookId]);
|
|
2268
2339
|
return uniqueHookId;
|
|
2269
2340
|
};
|
|
2270
|
-
var useImperativeComponentEvents$1 = useImperativeComponentEvents;
|
|
2271
2341
|
|
|
2272
2342
|
const formatMessage = (str, obj) => {
|
|
2273
2343
|
let newStr = str;
|
|
@@ -2381,13 +2451,13 @@ const PropsSelectorUndefinedObject = {};
|
|
|
2381
2451
|
class PropsStore {
|
|
2382
2452
|
constructor(configuration) {
|
|
2383
2453
|
this.configuration = configuration;
|
|
2384
|
-
this.log = persistentStorage
|
|
2454
|
+
this.log = persistentStorage[propsLog];
|
|
2385
2455
|
this.fields = {};
|
|
2386
2456
|
this.suscriptors = {};
|
|
2387
2457
|
this.loggers = {
|
|
2388
2458
|
propsLog: ([log]) => {
|
|
2389
2459
|
this.log = log;
|
|
2390
|
-
persistentStorage
|
|
2460
|
+
persistentStorage[propsLog] = log;
|
|
2391
2461
|
},
|
|
2392
2462
|
propsStore: ([fieldId]) => {
|
|
2393
2463
|
if (fieldId)
|
|
@@ -2710,6 +2780,12 @@ class ClassNameBuilder {
|
|
|
2710
2780
|
}
|
|
2711
2781
|
}
|
|
2712
2782
|
|
|
2783
|
+
function decodeBase64ToUtf8(base64String) {
|
|
2784
|
+
const binaryString = atob(base64String);
|
|
2785
|
+
const bytes = Uint8Array.from(binaryString, (char) => char.charCodeAt(0));
|
|
2786
|
+
return new TextDecoder("utf-8").decode(bytes);
|
|
2787
|
+
}
|
|
2788
|
+
|
|
2713
2789
|
function toBoolean(value) {
|
|
2714
2790
|
if (typeof value === "string") {
|
|
2715
2791
|
return !["false", ""].includes(value.toLowerCase());
|
|
@@ -2830,37 +2906,5 @@ const postNavigation = (url, data) => {
|
|
|
2830
2906
|
form.submit();
|
|
2831
2907
|
};
|
|
2832
2908
|
|
|
2833
|
-
|
|
2834
|
-
constructor() {
|
|
2835
|
-
this.locked = false;
|
|
2836
|
-
this.queue = [];
|
|
2837
|
-
}
|
|
2838
|
-
async lock() {
|
|
2839
|
-
const ticket = new Promise((resolve) => this.queue.push(resolve));
|
|
2840
|
-
if (!this.locked) {
|
|
2841
|
-
this.locked = true;
|
|
2842
|
-
const next = this.queue.shift();
|
|
2843
|
-
next();
|
|
2844
|
-
}
|
|
2845
|
-
await ticket;
|
|
2846
|
-
}
|
|
2847
|
-
unlock() {
|
|
2848
|
-
if (this.queue.length > 0) {
|
|
2849
|
-
const next = this.queue.shift();
|
|
2850
|
-
next();
|
|
2851
|
-
} else {
|
|
2852
|
-
this.locked = false;
|
|
2853
|
-
}
|
|
2854
|
-
}
|
|
2855
|
-
async runExclusive(fn) {
|
|
2856
|
-
await this.lock();
|
|
2857
|
-
try {
|
|
2858
|
-
return await fn();
|
|
2859
|
-
} finally {
|
|
2860
|
-
this.unlock();
|
|
2861
|
-
}
|
|
2862
|
-
}
|
|
2863
|
-
}
|
|
2864
|
-
|
|
2865
|
-
export { AudioRecorder, BasicStoredElement, BouncingEmitter, ClassNameBuilder, EventEmitter, History, Mutex, PropsSelectorUndefinedObject, PropsStore, StatefulEmitter, Url, addBoundary, alignment, animate, apiaDateToStandarFormat, arrayOrArray, autoDisconnectMutationObserver, cantFocusSelector, cloneDeep, customEvents, dateToApiaFormat, debugDispatcher, decodeHTMLEntities, decrypt, defaultGetNameFromResponse, disableChildrenFocus, downloadStringAsDoc, downloadUrl, enableChildrenFocus, encrypt, findOffsetRelativeToScrollParent, findScrollContainer, focus, focusSelector, formatMessage, freezeDeep, getDateFormat, getFocusSelector, getIndex, getJSObjFromXML, getLabel, getSpecificParent, getValueByPath, globalFocus, isChild, isDebugDispatcherEnabled, isPropsConfigurationObject, isSetter, makeImperativeComponent, makeSingleImperativeComponent, makeStatefulStore, noNaN, notificationsSelector, openAndReadFile, openAndReadFiles, parseAsSize, parseXMLRequestResponse, parseXmlAsync, persistentStorage$1 as persistentStorage, postNavigation, propsStore, screenLocker, scrollParentIntoElement, setValueByPath, shallowCompareArrays, shallowEqual, shortcutController, toBoolean, ucfirst, useCombinedRefs, useDebouncedCallback, useDebouncedState, useDomState, useImperativeComponentContext, useImperativeComponentEvents$1 as useImperativeComponentEvents, useIntermediateValue, useLatest, useLocalStorage, useMount, usePanAndZoom, usePrevious, usePropsSelector, useShallowMemo, useStateRef, useSubscription, useUnmount, useUpdateEffect, useWhyUpdated };
|
|
2909
|
+
export { AudioRecorder, BasicStoredElement, BouncingEmitter, ClassNameBuilder, EventEmitter, History, Locker, Mutex, PropsSelectorUndefinedObject, PropsStore, ScrollLocker, Semaphore, StatefulEmitter, Url, addBoundary, alignment, animate, apiaDateToStandarFormat, arrayOrArray, autoDisconnectMutationObserver, cantFocusSelector, cloneDeep, customEvents, dateToApiaFormat, debugDispatcher, decodeBase64ToUtf8, decodeHTMLEntities, decrypt, defaultGetNameFromResponse, disableChildrenFocus, downloadStringAsDoc, downloadUrl, enableChildrenFocus, encrypt, findOffsetRelativeToScrollParent, findScrollContainer, focus, focusSelector, formatMessage, freezeDeep, getDateFormat, getFocusSelector, getIndex, getJSObjFromXML, getLabel, getSpecificParent, getValueByPath, globalFocus, globals, isChild, isDebugDispatcherEnabled, isPropsConfigurationObject, isSetter, makeImperativeComponent, makeSingleImperativeComponent, makeStatefulStore, noNaN, notificationsSelector, openAndReadFile, openAndReadFiles, parseAsSize, parseXMLRequestResponse, parseXmlAsync, persistentStorage, postNavigation, propsStore, screenLocker, scrollParentIntoElement, setValueByPath, shallowCompareArrays, shallowEqual, shortcutController, toBoolean, ucfirst, useCombinedRefs, useDebouncedCallback, useDebouncedState, useDomState, useImperativeComponentContext, useImperativeComponentEvents, useIntermediateValue, useLatest, useLocalStorage, useMatchScrollDirection, useMount, usePanAndZoom, usePrevious, usePropsSelector, useShallowMemo, useStateRef, useSubscription, useUnmount, useUpdateEffect, useWhyUpdated };
|
|
2866
2910
|
//# sourceMappingURL=index.js.map
|