@apia/util 0.2.4 → 0.3.0
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 +54 -38
- package/dist/index.js +104 -26
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -305,14 +305,14 @@ declare function disableChildrenFocus(parent: HTMLElement): void;
|
|
|
305
305
|
*/
|
|
306
306
|
declare function enableChildrenFocus(parent: HTMLElement): void;
|
|
307
307
|
|
|
308
|
-
type TEventMap = Record<string, any>;
|
|
309
|
-
type TEventKey<T extends TEventMap> = string & keyof T;
|
|
310
|
-
type TEventReceiver<T> = (params: T) => unknown;
|
|
308
|
+
type TEventMap$1 = Record<string, any>;
|
|
309
|
+
type TEventKey$1<T extends TEventMap$1> = string & keyof T;
|
|
310
|
+
type TEventReceiver$1<T> = (params: T) => unknown;
|
|
311
311
|
type TFun = () => unknown;
|
|
312
|
-
interface IEmitter<T extends TEventMap> {
|
|
313
|
-
on<K extends TEventKey<T>>(eventName: K, fn: TEventReceiver<T[K]>): TFun;
|
|
314
|
-
off<K extends TEventKey<T>>(eventName: K, fn: TEventReceiver<T[K]>): unknown;
|
|
315
|
-
emit<K extends TEventKey<T>>(eventName: K, params?: T[K]): unknown;
|
|
312
|
+
interface IEmitter<T extends TEventMap$1> {
|
|
313
|
+
on<K extends TEventKey$1<T>>(eventName: K, fn: TEventReceiver$1<T[K]>): TFun;
|
|
314
|
+
off<K extends TEventKey$1<T>>(eventName: K, fn: TEventReceiver$1<T[K]>): unknown;
|
|
315
|
+
emit<K extends TEventKey$1<T>>(eventName: K, params?: T[K]): unknown;
|
|
316
316
|
}
|
|
317
317
|
/**
|
|
318
318
|
* EventEmitter muy sencillo.
|
|
@@ -360,11 +360,28 @@ interface IEmitter<T extends TEventMap> {
|
|
|
360
360
|
write(`Multiple: ${typing}`);
|
|
361
361
|
});
|
|
362
362
|
*/
|
|
363
|
-
declare class EventEmitter<T extends TEventMap> implements IEmitter<T> {
|
|
363
|
+
declare class EventEmitter<T extends TEventMap$1> implements IEmitter<T> {
|
|
364
|
+
#private;
|
|
365
|
+
on<K extends TEventKey$1<T>>(eventName: K, fn: TEventReceiver$1<T[K]>): () => void;
|
|
366
|
+
off<K extends TEventKey$1<T>>(eventName: K, fn: TEventReceiver$1<T[K]>): void;
|
|
367
|
+
emit<K extends TEventKey$1<T>>(eventName: K, params?: T[K]): void;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
type TEventMap = Record<string, any>;
|
|
371
|
+
type TEventKey<T extends TEventMap> = string & keyof T;
|
|
372
|
+
type TEventReceiver<T> = (params: T) => unknown;
|
|
373
|
+
/**
|
|
374
|
+
* La clase HashedEventEmitter permite la utilización de emisión de eventos con
|
|
375
|
+
* mayor eficiencia dado que en base a la función de hasheo provista, divide los
|
|
376
|
+
* listeners en diferentes arrays, reduciendo la cantidad de escuchas generadas.
|
|
377
|
+
*/
|
|
378
|
+
declare class HashedEventEmitter<T extends TEventMap, HashData extends TEventMap> {
|
|
364
379
|
#private;
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
380
|
+
private hashMethod;
|
|
381
|
+
constructor(hashMethod: (hash: HashData) => string);
|
|
382
|
+
on<K extends TEventKey<T>>(hash: HashData, eventName: K, fn: TEventReceiver<T[K]>): () => void;
|
|
383
|
+
off<K extends TEventKey<T>>(hash: HashData, eventName: K, fn: TEventReceiver<T[K]>): void;
|
|
384
|
+
emit<K extends TEventKey<T>>(hash: HashData, eventName: K, params?: T[K]): void;
|
|
368
385
|
}
|
|
369
386
|
|
|
370
387
|
/**
|
|
@@ -545,6 +562,7 @@ type TApiaFormElement = {
|
|
|
545
562
|
};
|
|
546
563
|
type TApiaLoadForm = {
|
|
547
564
|
form: {
|
|
565
|
+
closeOnSubmit: boolean;
|
|
548
566
|
multiPart: boolean;
|
|
549
567
|
ajaxNewPanel: boolean;
|
|
550
568
|
showErrors: boolean;
|
|
@@ -770,20 +788,20 @@ interface IFocusCheck {
|
|
|
770
788
|
currentInstruction: number;
|
|
771
789
|
}
|
|
772
790
|
declare const focus: {
|
|
773
|
-
"__#
|
|
774
|
-
"__#
|
|
791
|
+
"__#7@#root": HTMLElement;
|
|
792
|
+
"__#7@#props": IFocusProps | undefined;
|
|
775
793
|
afterNotificationFocus: IFocusQueryElement | undefined;
|
|
776
|
-
"__#
|
|
777
|
-
"__#
|
|
778
|
-
"__#
|
|
779
|
-
"__#
|
|
780
|
-
"__#
|
|
781
|
-
"__#
|
|
782
|
-
"__#
|
|
783
|
-
"__#
|
|
784
|
-
"__#
|
|
785
|
-
"__#
|
|
786
|
-
"__#
|
|
794
|
+
"__#7@#actualFocusQuery": IFocusQueryElement[];
|
|
795
|
+
"__#7@#currentInstruction": number;
|
|
796
|
+
"__#7@#focusDelay": number;
|
|
797
|
+
"__#7@#focusRetries": number;
|
|
798
|
+
"__#7@#focusTimeout": number;
|
|
799
|
+
"__#7@#isIntervalRunning": boolean;
|
|
800
|
+
"__#7@#focusQuery": IFocusQueryElement[];
|
|
801
|
+
"__#7@#checkInstruction"(focusCheck: IFocusCheck): boolean;
|
|
802
|
+
"__#7@#doFocus"(HTMLElement: HTMLElement | TFocusRetriever, focusCheck: IFocusCheck, isLastTry: boolean, configuration?: IOnFocusConfiguration): Promise<false | HTMLElement | null>;
|
|
803
|
+
"__#7@#resetInterval"(): void;
|
|
804
|
+
"__#7@#runFocusInterval"(focusElement?: IFocusQueryElement, internalCall?: boolean): Promise<false | HTMLElement>;
|
|
787
805
|
/**
|
|
788
806
|
* Da la instrucción de colocar el foco en el elemento provisto como
|
|
789
807
|
* parámetro una vez que todas las notificaciones se hayan cerrado. En caso
|
|
@@ -831,7 +849,7 @@ declare const focus: {
|
|
|
831
849
|
*/
|
|
832
850
|
declare const globalFocus: {
|
|
833
851
|
focused: (HTMLElement | TFocusRetriever)[];
|
|
834
|
-
"__#
|
|
852
|
+
"__#5@#onFocusCallbacks": (() => unknown)[];
|
|
835
853
|
offFocus(cb: () => unknown): void;
|
|
836
854
|
onFocus(cb: () => unknown): () => void;
|
|
837
855
|
inDocument(el: HTMLElement | TFocusRetriever): boolean;
|
|
@@ -1275,8 +1293,6 @@ declare function usePropsSelector<Selected = TProperties, PropsType extends Reco
|
|
|
1275
1293
|
};
|
|
1276
1294
|
}, [setDomProps]);
|
|
1277
1295
|
|
|
1278
|
-
console.log('RENDER');
|
|
1279
|
-
|
|
1280
1296
|
return (
|
|
1281
1297
|
<Box
|
|
1282
1298
|
{...domProps}
|
|
@@ -1339,10 +1355,10 @@ declare function useDebouncedState<T>(timeout: number, initialState?: T): [T | u
|
|
|
1339
1355
|
* se controle el nombre del bloqueo.
|
|
1340
1356
|
*/
|
|
1341
1357
|
declare const screenLocker: {
|
|
1342
|
-
"__#
|
|
1343
|
-
"__#
|
|
1344
|
-
"__#
|
|
1345
|
-
"__#
|
|
1358
|
+
"__#6@#hasReleasedFirstTime": boolean;
|
|
1359
|
+
"__#6@#wasReleasedFirstTime": boolean;
|
|
1360
|
+
"__#6@#isForced": boolean;
|
|
1361
|
+
"__#6@#locks": Record<string, boolean>;
|
|
1346
1362
|
readonly hasReleasedFirstTime: boolean;
|
|
1347
1363
|
readonly isForced: boolean;
|
|
1348
1364
|
/**
|
|
@@ -1350,7 +1366,7 @@ declare const screenLocker: {
|
|
|
1350
1366
|
* forceLock activo.
|
|
1351
1367
|
*/
|
|
1352
1368
|
isLocked(lockName?: string): boolean;
|
|
1353
|
-
"__#
|
|
1369
|
+
"__#6@#shoutLockState"(lockName?: string): void;
|
|
1354
1370
|
lock(lockName?: string): void;
|
|
1355
1371
|
unlock(lockName?: string): void;
|
|
1356
1372
|
force(): void;
|
|
@@ -1368,7 +1384,7 @@ declare const screenLocker: {
|
|
|
1368
1384
|
releaseForFirstTime: void;
|
|
1369
1385
|
ready: void;
|
|
1370
1386
|
}>;
|
|
1371
|
-
on<K extends TEventKey<{
|
|
1387
|
+
on<K extends TEventKey$1<{
|
|
1372
1388
|
forcedStateChange: {
|
|
1373
1389
|
hasReleasedFirstTime: boolean;
|
|
1374
1390
|
isForced: boolean;
|
|
@@ -1380,7 +1396,7 @@ declare const screenLocker: {
|
|
|
1380
1396
|
};
|
|
1381
1397
|
releaseForFirstTime: void;
|
|
1382
1398
|
ready: void;
|
|
1383
|
-
}>>(eventName: K, fn: TEventReceiver<{
|
|
1399
|
+
}>>(eventName: K, fn: TEventReceiver$1<{
|
|
1384
1400
|
forcedStateChange: {
|
|
1385
1401
|
hasReleasedFirstTime: boolean;
|
|
1386
1402
|
isForced: boolean;
|
|
@@ -1393,7 +1409,7 @@ declare const screenLocker: {
|
|
|
1393
1409
|
releaseForFirstTime: void;
|
|
1394
1410
|
ready: void;
|
|
1395
1411
|
}[K]>): () => void;
|
|
1396
|
-
off<K_1 extends TEventKey<{
|
|
1412
|
+
off<K_1 extends TEventKey$1<{
|
|
1397
1413
|
forcedStateChange: {
|
|
1398
1414
|
hasReleasedFirstTime: boolean;
|
|
1399
1415
|
isForced: boolean;
|
|
@@ -1405,7 +1421,7 @@ declare const screenLocker: {
|
|
|
1405
1421
|
};
|
|
1406
1422
|
releaseForFirstTime: void;
|
|
1407
1423
|
ready: void;
|
|
1408
|
-
}>>(eventName: K_1, fn: TEventReceiver<{
|
|
1424
|
+
}>>(eventName: K_1, fn: TEventReceiver$1<{
|
|
1409
1425
|
forcedStateChange: {
|
|
1410
1426
|
hasReleasedFirstTime: boolean;
|
|
1411
1427
|
isForced: boolean;
|
|
@@ -1418,7 +1434,7 @@ declare const screenLocker: {
|
|
|
1418
1434
|
releaseForFirstTime: void;
|
|
1419
1435
|
ready: void;
|
|
1420
1436
|
}[K_1]>): void;
|
|
1421
|
-
emit<K_2 extends TEventKey<{
|
|
1437
|
+
emit<K_2 extends TEventKey$1<{
|
|
1422
1438
|
forcedStateChange: {
|
|
1423
1439
|
hasReleasedFirstTime: boolean;
|
|
1424
1440
|
isForced: boolean;
|
|
@@ -1488,4 +1504,4 @@ declare function toBoolean(value: unknown): boolean;
|
|
|
1488
1504
|
|
|
1489
1505
|
declare const parseXmlAsync: <T>(xml: string) => Promise<T>;
|
|
1490
1506
|
|
|
1491
|
-
export { EventEmitter, IOnFocusConfiguration, IParameter, ISetBoundary, PropsSelectorUndefinedObject, PropsStore, TApiaAction, TApiaActions, TApiaCellDefinition, TApiaComplexCell, TApiaFieldPropsObj, TApiaFilter, TApiaFilterOption, TApiaFilterValue, TApiaFormButton, TApiaFormElement, TApiaFormElementOption, TApiaFunction, TApiaFunctionPageInfo, TApiaLoad, TApiaLoadForm, TApiaLoadText, TApiaMessage, TApiaMultiplePossibleValue, TApiaPossibleValue, TApiaRadioPossibleValue, TApiaRowDefinition, TApiaSelectPossibleValue, TApiaSystemMessageObj, TApiaTableFunction, TCallback, TDateFormat, TDispatchCallback, TFieldEvent, TFieldScriptEvent, TFieldScriptEvents, TFieldServerEvent, TFieldServerEvents, TFncParams, TFocusRetriever, TId, TKey, TMap$1 as TMap, TMessage, TModify, TNotificationMessage, TPropsComparator, TPropsConfiguration, TPropsSelector, TRequireOnlyOne, TShortcutBranch, TUpdateFieldConfiguration, 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 };
|
|
1507
|
+
export { EventEmitter, HashedEventEmitter, IOnFocusConfiguration, IParameter, ISetBoundary, PropsSelectorUndefinedObject, PropsStore, TApiaAction, TApiaActions, TApiaCellDefinition, TApiaComplexCell, TApiaFieldPropsObj, TApiaFilter, TApiaFilterOption, TApiaFilterValue, TApiaFormButton, TApiaFormElement, TApiaFormElementOption, TApiaFunction, TApiaFunctionPageInfo, TApiaLoad, TApiaLoadForm, TApiaLoadText, TApiaMessage, TApiaMultiplePossibleValue, TApiaPossibleValue, TApiaRadioPossibleValue, TApiaRowDefinition, TApiaSelectPossibleValue, TApiaSystemMessageObj, TApiaTableFunction, TCallback, TDateFormat, TDispatchCallback, TFieldEvent, TFieldScriptEvent, TFieldScriptEvents, TFieldServerEvent, TFieldServerEvents, TFncParams, TFocusRetriever, TId, TKey, TMap$1 as TMap, TMessage, TModify, TNotificationMessage, TPropsComparator, TPropsConfiguration, TPropsSelector, TRequireOnlyOne, TShortcutBranch, TUpdateFieldConfiguration, 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 };
|
package/dist/index.js
CHANGED
|
@@ -139,7 +139,7 @@ function dateToApiaFormat(date) {
|
|
|
139
139
|
return dayjs(date).format(getDateFormat());
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
-
let isEnabled =
|
|
142
|
+
let isEnabled = false;
|
|
143
143
|
function isDebugDispatcherEnabled() {
|
|
144
144
|
return isEnabled;
|
|
145
145
|
}
|
|
@@ -318,7 +318,7 @@ const shortcutController = new class ShortcutController {
|
|
|
318
318
|
}, 'dev'); // Este shortcut solo se ejecuta en desarrollo
|
|
319
319
|
*/
|
|
320
320
|
on(keys, callback, category, fireEvenFromInputs) {
|
|
321
|
-
if (category === "dev" && isDebugDispatcherEnabled())
|
|
321
|
+
if (category === "dev" && !isDebugDispatcherEnabled())
|
|
322
322
|
return;
|
|
323
323
|
let container = this.shortcuts;
|
|
324
324
|
const actualKeys = category ? [...this.categories[category], ...keys] : keys;
|
|
@@ -661,15 +661,15 @@ function isChild(element, checkParent) {
|
|
|
661
661
|
return !!getSpecificParent(element, checkParent);
|
|
662
662
|
}
|
|
663
663
|
|
|
664
|
-
var __accessCheck$
|
|
664
|
+
var __accessCheck$6 = (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$6 = (obj, member, getter) => {
|
|
669
|
+
__accessCheck$6(obj, member, "read from private field");
|
|
670
670
|
return getter ? getter.call(obj) : member.get(obj);
|
|
671
671
|
};
|
|
672
|
-
var __privateAdd$
|
|
672
|
+
var __privateAdd$6 = (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$6(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$6(this, _parameters)[name] = String(value);
|
|
692
692
|
else
|
|
693
|
-
__privateGet$
|
|
693
|
+
__privateGet$6(this, _parameters)[name] = __privateGet$6(this, _parameters)[name] ? [...arrayOrArray(__privateGet$6(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$6(this, _parameters)[name];
|
|
702
702
|
}
|
|
703
703
|
toString() {
|
|
704
|
-
const parametersArray = Object.entries(__privateGet$
|
|
704
|
+
const parametersArray = Object.entries(__privateGet$6(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,6 +733,65 @@ function enableChildrenFocus(parent) {
|
|
|
733
733
|
});
|
|
734
734
|
}
|
|
735
735
|
|
|
736
|
+
var __accessCheck$5 = (obj, member, msg) => {
|
|
737
|
+
if (!member.has(obj))
|
|
738
|
+
throw TypeError("Cannot " + msg);
|
|
739
|
+
};
|
|
740
|
+
var __privateGet$5 = (obj, member, getter) => {
|
|
741
|
+
__accessCheck$5(obj, member, "read from private field");
|
|
742
|
+
return getter ? getter.call(obj) : member.get(obj);
|
|
743
|
+
};
|
|
744
|
+
var __privateAdd$5 = (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$1;
|
|
750
|
+
function eventEmitter$1() {
|
|
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$5(this, _emitter$1, eventEmitter$1());
|
|
779
|
+
}
|
|
780
|
+
on(eventName, fn) {
|
|
781
|
+
__privateGet$5(this, _emitter$1).on(eventName, fn);
|
|
782
|
+
return () => {
|
|
783
|
+
__privateGet$5(this, _emitter$1).off(eventName, fn);
|
|
784
|
+
};
|
|
785
|
+
}
|
|
786
|
+
off(eventName, fn) {
|
|
787
|
+
__privateGet$5(this, _emitter$1).off(eventName, fn);
|
|
788
|
+
}
|
|
789
|
+
emit(eventName, params) {
|
|
790
|
+
__privateGet$5(this, _emitter$1).emit(eventName, params);
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
_emitter$1 = new WeakMap();
|
|
794
|
+
|
|
736
795
|
var __accessCheck$4 = (obj, member, msg) => {
|
|
737
796
|
if (!member.has(obj))
|
|
738
797
|
throw TypeError("Cannot " + msg);
|
|
@@ -746,7 +805,11 @@ var __privateAdd$4 = (obj, member, value) => {
|
|
|
746
805
|
throw TypeError("Cannot add the same private member more than once");
|
|
747
806
|
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
748
807
|
};
|
|
749
|
-
var
|
|
808
|
+
var __privateMethod$2 = (obj, member, method) => {
|
|
809
|
+
__accessCheck$4(obj, member, "access private method");
|
|
810
|
+
return method;
|
|
811
|
+
};
|
|
812
|
+
var _emitter, _getEventName, getEventName_fn;
|
|
750
813
|
function eventEmitter() {
|
|
751
814
|
const listeners = {};
|
|
752
815
|
return {
|
|
@@ -773,24 +836,33 @@ function eventEmitter() {
|
|
|
773
836
|
}
|
|
774
837
|
};
|
|
775
838
|
}
|
|
776
|
-
class
|
|
777
|
-
constructor() {
|
|
839
|
+
class HashedEventEmitter {
|
|
840
|
+
constructor(hashMethod) {
|
|
841
|
+
this.hashMethod = hashMethod;
|
|
842
|
+
__privateAdd$4(this, _getEventName);
|
|
778
843
|
__privateAdd$4(this, _emitter, eventEmitter());
|
|
779
844
|
}
|
|
780
|
-
on(eventName, fn) {
|
|
781
|
-
|
|
845
|
+
on(hash, eventName, fn) {
|
|
846
|
+
const actualEventName = __privateMethod$2(this, _getEventName, getEventName_fn).call(this, hash, eventName);
|
|
847
|
+
__privateGet$4(this, _emitter).on(actualEventName, fn);
|
|
782
848
|
return () => {
|
|
783
|
-
__privateGet$4(this, _emitter).off(
|
|
849
|
+
__privateGet$4(this, _emitter).off(actualEventName, fn);
|
|
784
850
|
};
|
|
785
851
|
}
|
|
786
|
-
off(eventName, fn) {
|
|
787
|
-
|
|
852
|
+
off(hash, eventName, fn) {
|
|
853
|
+
const actualEventName = __privateMethod$2(this, _getEventName, getEventName_fn).call(this, hash, eventName);
|
|
854
|
+
__privateGet$4(this, _emitter).off(actualEventName, fn);
|
|
788
855
|
}
|
|
789
|
-
emit(eventName, params) {
|
|
790
|
-
|
|
856
|
+
emit(hash, eventName, params) {
|
|
857
|
+
const actualEventName = __privateMethod$2(this, _getEventName, getEventName_fn).call(this, hash, eventName);
|
|
858
|
+
__privateGet$4(this, _emitter).emit(actualEventName, params);
|
|
791
859
|
}
|
|
792
860
|
}
|
|
793
861
|
_emitter = new WeakMap();
|
|
862
|
+
_getEventName = new WeakSet();
|
|
863
|
+
getEventName_fn = function(hash, eventName) {
|
|
864
|
+
return `${this.hashMethod(hash)}_${eventName}`;
|
|
865
|
+
};
|
|
794
866
|
|
|
795
867
|
var __accessCheck$3 = (obj, member, msg) => {
|
|
796
868
|
if (!member.has(obj))
|
|
@@ -1407,7 +1479,13 @@ function useLatest(value) {
|
|
|
1407
1479
|
}
|
|
1408
1480
|
|
|
1409
1481
|
function useMount(effect) {
|
|
1410
|
-
|
|
1482
|
+
const hasRun = useRef(false);
|
|
1483
|
+
useEffect(() => {
|
|
1484
|
+
if (!hasRun.current) {
|
|
1485
|
+
hasRun.current = true;
|
|
1486
|
+
return effect();
|
|
1487
|
+
}
|
|
1488
|
+
}, []);
|
|
1411
1489
|
}
|
|
1412
1490
|
|
|
1413
1491
|
function useUnmount(unmountCallback) {
|
|
@@ -1573,7 +1651,7 @@ const useImperativeComponentEvents = (handlers) => {
|
|
|
1573
1651
|
const uniqueHookId = useMemo(() => uniqueId$1("hook"), []);
|
|
1574
1652
|
const { id, eventsStore } = useImperativeComponentContext();
|
|
1575
1653
|
const hasRegistered = useRef(false);
|
|
1576
|
-
|
|
1654
|
+
const registerEvents = useCallback(() => {
|
|
1577
1655
|
Object.entries(handlers).forEach(([name, callback]) => {
|
|
1578
1656
|
var _a;
|
|
1579
1657
|
if (!eventsStore[id])
|
|
@@ -1585,7 +1663,7 @@ const useImperativeComponentEvents = (handlers) => {
|
|
|
1585
1663
|
uniqueHookId
|
|
1586
1664
|
});
|
|
1587
1665
|
});
|
|
1588
|
-
}
|
|
1666
|
+
}, [eventsStore, handlers, id, uniqueHookId]);
|
|
1589
1667
|
useEffect(() => {
|
|
1590
1668
|
registerEvents();
|
|
1591
1669
|
return () => {
|
|
@@ -1595,7 +1673,7 @@ const useImperativeComponentEvents = (handlers) => {
|
|
|
1595
1673
|
eventsStore[id][name] = ((_a = eventsStore[id][name]) != null ? _a : []).filter((current) => current.uniqueHookId !== uniqueHookId);
|
|
1596
1674
|
});
|
|
1597
1675
|
};
|
|
1598
|
-
}, []);
|
|
1676
|
+
}, [eventsStore, handlers, id, registerEvents, uniqueHookId]);
|
|
1599
1677
|
return uniqueHookId;
|
|
1600
1678
|
};
|
|
1601
1679
|
|
|
@@ -2115,4 +2193,4 @@ const parseXmlAsync = (xml) => __async(void 0, null, function* () {
|
|
|
2115
2193
|
return result;
|
|
2116
2194
|
});
|
|
2117
2195
|
|
|
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 };
|
|
2196
|
+
export { EventEmitter, HashedEventEmitter, 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 };
|