@apia/util 4.0.16 → 4.0.18

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 CHANGED
@@ -46,11 +46,32 @@ declare global {
46
46
  }
47
47
  declare const getDateFormat: () => TDateFormat;
48
48
 
49
+ declare global {
50
+ const VERSION: string;
51
+ const COMMITHASH: string;
52
+ const BRANCH: string;
53
+ const ENVIRONMENT: string;
54
+ const TIMESTAMP: string;
55
+ const PACKAGE_VERSION: string;
56
+ interface Window {
57
+ Globals: typeof globals;
58
+ }
59
+ }
60
+ declare const globals: {
61
+ getVersion(): {
62
+ version: string;
63
+ commit: string;
64
+ branch: string;
65
+ env: string;
66
+ timestamp: string;
67
+ package: string;
68
+ };
69
+ };
49
70
  /**
50
71
  * Indica si el debugDispatcher fue activado, lo que en muchos casos indica que
51
72
  * estamos en ambiente de desarrollo
52
73
  */
53
- declare function isDebugDispatcherEnabled(): any;
74
+ declare function isDebugDispatcherEnabled(): boolean;
54
75
  type TWindowDDispatch = (action: string, ...parameters: unknown[]) => void;
55
76
  type TDispatchCallback = (parameters: unknown[]) => unknown;
56
77
  interface IStoredCallback {
@@ -123,7 +144,7 @@ declare const shortcutController: {
123
144
  console.log('Abctrl+cd'),
124
145
  }, 'dev'); // Este shortcut solo se ejecuta en desarrollo
125
146
  */
126
- on(keys: (string | TKey)[], callback: TCallback, category?: keyof typeof this.categories, fireEvenFromInputs?: boolean): void;
147
+ on(keys: (string | TKey)[], callback: TCallback, category?: "dev", fireEvenFromInputs?: boolean): void;
127
148
  };
128
149
 
129
150
  type DownloadStringAsDocProps = {
@@ -190,11 +211,18 @@ declare function findOffsetRelativeToScrollParent(element: HTMLElement, which?:
190
211
  declare function findScrollContainer(el: HTMLElement): HTMLElement | null;
191
212
 
192
213
  /**
193
- * Busca el padre con scroll visible y establece su scrollTop de acuerdo al offset del elemento pasado como argumento, de modo que éste aparezca visible dentro del padre mencionado.
214
+ * Mantiene visible `element` dentro de su contenedor con scroll,
215
+ * compensando un posible header fijo (`fixedOffsetTop`).
194
216
  *
195
- * @param fixedOffsetTop Establece un mínimo de distancia que debe mantener con el borde superior del contenedor con scroll. Se usa para compensar en las situaciones donde existen cabezales fijos.
217
+ * @param element Elemento a mostrar.
218
+ * @param fixedOffsetTop Espacio mínimo desde el top visible (ej: header fijo). Default 0.
219
+ * @param tries Cuántas reintentos en caso de layout changes. Default 2.
220
+ * @param timeout Retraso entre reintentos (ms). Default 100.
221
+ * @param scrollId Identificador opcional para agrupar timeouts.
196
222
  */
197
- declare function scrollParentIntoElement(element: HTMLElement, fixedOffsetTop?: number, tries?: number, timeout?: number, scrollId?: string | undefined): void;
223
+ declare function scrollParentIntoElement(element: HTMLElement, fixedOffsetTop?: number, tries?: number, timeout?: number, scrollId?: string): void;
224
+
225
+ declare function useMatchScrollDirection(direction: 'up' | 'down'): boolean;
198
226
 
199
227
  declare function usePanAndZoom<ContainerType extends HTMLElement = HTMLElement, ChildType extends HTMLElement | SVGElement = HTMLElement>(effectiveMargin?: {
200
228
  left: number;
@@ -242,6 +270,11 @@ declare const customEvents: {
242
270
  */
243
271
  hidePanel: string;
244
272
  showPanel: string;
273
+ /**
274
+ * Evento lanzado por formsEventsController sobre window
275
+ * cuando se termina de procesar los formularios de la tarea
276
+ */
277
+ formsReady: string;
245
278
  };
246
279
 
247
280
  /**
@@ -900,20 +933,20 @@ interface IFocusCheck {
900
933
  currentInstruction: number;
901
934
  }
902
935
  declare const focus: {
903
- "__#5@#root": HTMLElement;
904
- "__#5@#props": IFocusProps | undefined;
936
+ "__#4@#root": HTMLElement;
937
+ "__#4@#props": IFocusProps | undefined;
905
938
  afterNotificationFocus: IFocusQueryElement | undefined;
906
- "__#5@#actualFocusQuery": IFocusQueryElement[];
907
- "__#5@#currentInstruction": number;
908
- "__#5@#focusDelay": number;
909
- "__#5@#focusRetries": number;
910
- "__#5@#focusTimeout": number;
911
- "__#5@#isIntervalRunning": boolean;
912
- "__#5@#focusQuery": IFocusQueryElement[];
913
- "__#5@#checkInstruction"(focusCheck: IFocusCheck): boolean;
914
- "__#5@#doFocus"(HTMLElement: HTMLElement | TFocusRetriever, focusCheck: IFocusCheck, isLastTry: boolean, configuration?: IOnFocusConfiguration): Promise<false | HTMLElement | null>;
915
- "__#5@#resetInterval"(): void;
916
- "__#5@#runFocusInterval"(focusElement?: IFocusQueryElement, internalCall?: boolean): Promise<false | HTMLElement>;
939
+ "__#4@#actualFocusQuery": IFocusQueryElement[];
940
+ "__#4@#currentInstruction": number;
941
+ "__#4@#focusDelay": number;
942
+ "__#4@#focusRetries": number;
943
+ "__#4@#focusTimeout": number;
944
+ "__#4@#isIntervalRunning": boolean;
945
+ "__#4@#focusQuery": IFocusQueryElement[];
946
+ "__#4@#checkInstruction"(focusCheck: IFocusCheck): boolean;
947
+ "__#4@#doFocus"(HTMLElement: HTMLElement | TFocusRetriever, focusCheck: IFocusCheck, isLastTry: boolean, configuration?: IOnFocusConfiguration): Promise<false | HTMLElement | null>;
948
+ "__#4@#resetInterval"(): void;
949
+ "__#4@#runFocusInterval"(focusElement?: IFocusQueryElement, internalCall?: boolean): Promise<false | HTMLElement>;
917
950
  /**
918
951
  * Da la instrucción de colocar el foco en el elemento provisto como
919
952
  * parámetro una vez que todas las notificaciones se hayan cerrado. En caso
@@ -1201,24 +1234,20 @@ type TFireEvent<Events extends TMap> = <K extends keyof Events>(id: TId, ev: K,
1201
1234
  methods
1202
1235
  */
1203
1236
  declare function makeImperativeComponent<ComponentProps extends TMap, Events extends TMap = TMap>(): <State extends TMap, Methods extends TMethods<State>>({ Component, initialState, methods, }: {
1204
- initialState?: State | undefined;
1205
- methods?: Methods | undefined;
1206
- Component: FC<Omit<ComponentProps, 'id'> & State>;
1207
- }) => [
1208
- TMethodsMap<Methods>,
1209
- TFireEvent<Events>,
1210
- FC<ComponentProps & {
1211
- id: TId;
1212
- }>
1213
- ];
1237
+ initialState?: State;
1238
+ methods?: Methods;
1239
+ Component: FC<Omit<ComponentProps, "id"> & State>;
1240
+ }) => [TMethodsMap<Methods>, TFireEvent<Events>, FC<ComponentProps & {
1241
+ id: TId;
1242
+ }>];
1214
1243
 
1215
1244
  type TSingleMethodsMap<Methods extends TMethods<any>, MethodsMap extends TMethodsMap<Methods>> = {
1216
1245
  [Name in keyof MethodsMap]: MethodsMap[Name] extends (id: TId, ...args: infer Action) => unknown ? (...args: Action) => unknown : never;
1217
1246
  };
1218
1247
  declare function makeSingleImperativeComponent<ComponentProps extends TMap, Events extends TMap = TMap>(): <State extends TMap, Methods extends TMethods<State>>({ initialState, methods, Component, }: {
1219
- initialState?: State | undefined;
1220
- methods?: Methods | undefined;
1221
- Component: FC<Omit<ComponentProps, 'id'> & State>;
1248
+ initialState?: State;
1249
+ methods?: Methods;
1250
+ Component: FC<Omit<ComponentProps, "id"> & State>;
1222
1251
  }) => [TSingleMethodsMap<Methods, TMethodsMap<Methods>>, <K extends keyof Events>(ev: K, args: Events[K]) => void, FC<ComponentProps>];
1223
1252
 
1224
1253
  declare const useImperativeComponentEvents: <Events extends TMap = TMap>(handlers: Partial<TEventsMap<Events>>) => string;
@@ -1573,61 +1602,25 @@ declare function useDomState<T extends HTMLAttributes<HTMLElement>>(initialDomPr
1573
1602
  */
1574
1603
  declare function useDebouncedState<T>(timeout: number, initialState?: T): [T | undefined, (state: SetStateAction<T>, immediate?: boolean) => unknown];
1575
1604
 
1576
- declare class ScreenLocker extends EventEmitter<{
1577
- forcedStateChange: {
1578
- hasReleasedFirstTime: boolean;
1579
- isForced: boolean;
1580
- };
1581
- lockStateChange: {
1582
- hasReleasedFirstTime: boolean;
1583
- isLocked: boolean;
1584
- lockName: string;
1585
- };
1605
+ declare class Locker extends EventEmitter<{
1586
1606
  releaseForFirstTime: null;
1587
- ready: null;
1588
1607
  }> {
1589
- #private;
1590
- get hasReleasedFirstTime(): boolean;
1591
- get isForced(): boolean;
1592
- /**
1593
- * Permite saber si un bloqueo determinado está activo o si la clase tiene
1594
- * forceLock activo.
1595
- */
1596
- isLocked(lockName?: string): boolean;
1608
+ private locks;
1609
+ private hasReleased;
1610
+ private mutex;
1597
1611
  constructor();
1598
- lock(lockName?: string): void;
1599
- unlock(lockName?: string): void;
1600
- force(): void;
1601
- releaseForced(): void;
1612
+ get isLocked(): boolean;
1613
+ lock(): void;
1614
+ unlock(): void;
1615
+ }
1616
+ declare const screenLocker: Locker;
1617
+
1618
+ declare class ScrollLocker {
1619
+ private static locks;
1620
+ private static evaluate;
1621
+ static lock(): void;
1622
+ static unlock(): void;
1602
1623
  }
1603
- /**
1604
- * Esta clase no implementa ninguna funcionalidad de bloqueo, sino solamente se
1605
- * encarga de la lógica y de los eventos.
1606
- *
1607
- * El concepto es que hay n niveles de bloqueo y además existe el bloqueo
1608
- * forzado. Cada uno de los niveles recibe un nombre, por defecto se realizan
1609
- * operaciones contra el bloque 'common' si no se pasa ninguno, pero
1610
- * podría utilizarse cualquier otro. Esto es así con el fin de implementar
1611
- * varios bloqueos en la misma clase, ejemplos: el bloqueo común, el bloqueo
1612
- * lineal de las tablas, bloque con pantalla blanca en el inicio de formularios,
1613
- * o cualquier otro que se desee. Para los bloqueos estándar se utilizan los
1614
- * métodos lock y unlock.
1615
- *
1616
- * El bloqueo forzado por otra parte es un estado general que se puede alterar
1617
- * mediante los métodos force y releaseForced. Cada vez que se bloquee o
1618
- * desbloquee la pantalla, se lanzará un evento lockStateChange sin lockName y
1619
- * con forced = true.
1620
- *
1621
- * Además, provee un evento para saber cuándo se desbloquea la pantalla
1622
- * efectivamente por primera vez para cada tipo de bloqueo. Es posible a su vez
1623
- * resetear la clase para que este evento sea lanzado nuevamente en el próximo
1624
- * desbloqueo mediante resetRefreshFirstTime.
1625
- *
1626
- * El evento releasForFirstTime se dispara únicamente para el bloqueo 'common'.
1627
- * Esto es así ya que sino podría dar lugar a confusión en situaciones donde no
1628
- * se controle el nombre del bloqueo.
1629
- */
1630
- declare const screenLocker: ScreenLocker;
1631
1624
 
1632
1625
  type StatefulStoreUnsuscriber = () => void;
1633
1626
  type StatefulStoreUpdater<Props> = (currentProps: Props) => Props;
@@ -1877,6 +1870,8 @@ declare class ClassNameBuilder {
1877
1870
  get(): string;
1878
1871
  }
1879
1872
 
1873
+ declare function decodeBase64ToUtf8(base64String: string): string;
1874
+
1880
1875
  /**
1881
1876
  * Toma un valor y devuelve true o false según las
1882
1877
  * siguientes condiciones:
@@ -1907,14 +1902,42 @@ declare const parseXMLRequestResponse: (response: AxiosResponse<unknown, unknown
1907
1902
 
1908
1903
  declare const postNavigation: (url: string, data: Record<string, any>) => void;
1909
1904
 
1910
- declare class Mutex {
1911
- locked: boolean;
1912
- queue: any[];
1905
+ type CB = () => void;
1906
+ /**
1907
+ * A simple semaphore implementation to control concurrency.
1908
+ * Limits the number of concurrent tasks that can run simultaneously.
1909
+ */
1910
+ declare class Semaphore {
1911
+ private concurrency;
1912
+ current: number;
1913
+ queue: CB[];
1914
+ /**
1915
+ * Creates a new instance of the Semaphore.
1916
+ *
1917
+ * @param concurrency - The maximum number of concurrent tasks allowed.
1918
+ */
1919
+ constructor(concurrency: number);
1920
+ /**
1921
+ * Acquires a permit to run a task.
1922
+ *
1923
+ * If the number of currently acquired permits is less than the concurrency limit,
1924
+ * the promise resolves immediately. Otherwise, it is queued until a permit is released.
1925
+ *
1926
+ * @returns A promise that resolves when the permit has been acquired.
1927
+ */
1928
+ acquire(): Promise<void>;
1929
+ /**
1930
+ * Releases a previously acquired permit.
1931
+ *
1932
+ * If there are queued tasks waiting for a permit, the next one is dequeued and allowed to proceed.
1933
+ */
1934
+ release(): void;
1935
+ }
1936
+
1937
+ declare class Mutex extends Semaphore {
1913
1938
  constructor();
1914
- lock(): Promise<void>;
1915
- unlock(): void;
1916
- runExclusive(fn: () => Promise<unknown>): Promise<unknown>;
1939
+ runExclusive(cb: () => unknown): Promise<void>;
1917
1940
  }
1918
1941
 
1919
- export { AudioRecorder, type AudioRecorderState, BasicStoredElement, BouncingEmitter, type Callback, ClassNameBuilder, type DebounceOptions, type DeepReadonly, type DownloadStringAsDocProps, EventEmitter, History, type IOnFocusConfiguration, type IParameter, type ISetBoundary, type Map, Mutex, PropsSelectorUndefinedObject, PropsStore, StatefulEmitter, type StatefulStoreUpdateProps, type StatefulStoreUpdater, type TApiaAction, type TApiaActions, type TApiaCellDefinition, type TApiaComplexCell, type TApiaFieldPropsObj, type TApiaFilter, type TApiaFilterOption, type TApiaFilterValue, type TApiaFormButton, type TApiaFormElement, type TApiaFormElementOption, type TApiaFunction, type TApiaFunctionPageInfo, type TApiaLoad, type TApiaLoadForm, type TApiaLoadText, type TApiaMessage, type TApiaMultiplePossibleValue, type TApiaPossibleValue, type TApiaRadioPossibleValue, type TApiaRowDefinition, type TApiaSelectPossibleValue, type TApiaSystemMessageObj, type TApiaTableFunction, type TCallback, type TDateFormat, type TDispatchCallback, type TDownloadUrlOptions, type TFieldEvent, type TFieldScriptEvent, type TFieldScriptEvents, type TFieldServerEvent, type TFieldServerEvents, type TFncParams, type TFocusRetriever, type THistoryCount, type THistoryStep, type THistoryStepChange, type TId, type TKey, type TMap$1 as TMap, type TMessage, type TModify, type TNotificationMessage, type TPropsComparator, type TPropsConfiguration, type TPropsSelector, type TRequireOnlyOne, type TShortcutBranch, type TUpdateFieldConfiguration, type ThrottleOptions, type UnSubscriber, 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, postNavigation, propsStore, screenLocker, scrollParentIntoElement, setValueByPath, shallowCompareArrays, shallowEqual, shortcutController, toBoolean, ucfirst, useCombinedRefs, useDebouncedCallback, useDebouncedState, useDomState, useImperativeComponentContext, useImperativeComponentEvents, useIntermediateValue, useLatest, useLocalStorage, useMount, usePanAndZoom, usePrevious, usePropsSelector, useShallowMemo, useStateRef, useSubscription, useUnmount, useUpdateEffect, useWhyUpdated };
1942
+ export { AudioRecorder, type AudioRecorderState, BasicStoredElement, BouncingEmitter, type Callback, ClassNameBuilder, type DebounceOptions, type DeepReadonly, type DownloadStringAsDocProps, EventEmitter, History, type IOnFocusConfiguration, type IParameter, type ISetBoundary, Locker, type Map, Mutex, PropsSelectorUndefinedObject, PropsStore, ScrollLocker, Semaphore, StatefulEmitter, type StatefulStoreUpdateProps, type StatefulStoreUpdater, type TApiaAction, type TApiaActions, type TApiaCellDefinition, type TApiaComplexCell, type TApiaFieldPropsObj, type TApiaFilter, type TApiaFilterOption, type TApiaFilterValue, type TApiaFormButton, type TApiaFormElement, type TApiaFormElementOption, type TApiaFunction, type TApiaFunctionPageInfo, type TApiaLoad, type TApiaLoadForm, type TApiaLoadText, type TApiaMessage, type TApiaMultiplePossibleValue, type TApiaPossibleValue, type TApiaRadioPossibleValue, type TApiaRowDefinition, type TApiaSelectPossibleValue, type TApiaSystemMessageObj, type TApiaTableFunction, type TCallback, type TDateFormat, type TDispatchCallback, type TDownloadUrlOptions, type TFieldEvent, type TFieldScriptEvent, type TFieldScriptEvents, type TFieldServerEvent, type TFieldServerEvents, type TFncParams, type TFocusRetriever, type THistoryCount, type THistoryStep, type THistoryStepChange, type TId, type TKey, type TMap$1 as TMap, type TMessage, type TModify, type TNotificationMessage, type TPropsComparator, type TPropsConfiguration, type TPropsSelector, type TRequireOnlyOne, type TShortcutBranch, type TUpdateFieldConfiguration, type ThrottleOptions, type UnSubscriber, 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 };
1920
1943
  //# sourceMappingURL=index.d.ts.map