@apia/util 4.0.29 → 4.0.31

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
@@ -29,6 +29,8 @@ declare function arrayOrArray<T>(o: T | T[] | undefined): T[];
29
29
  */
30
30
  declare function getIndex<T = unknown>(arr: T[], conditions: (boolean | (() => boolean))[], defaultIndex?: number): T;
31
31
 
32
+ declare function deepEqual(a: any, b: any, visited?: WeakMap<WeakKey, any>): boolean;
33
+
32
34
  declare const decrypt: (salt: string, iv: string, passPhrase: string, cipherText: string, keySize: number, iterationCount: number) => Promise<string>;
33
35
 
34
36
  declare const encrypt: (salt: string, iv: string, passPhrase: string, plainText: string, keySize: number, iterationCount: number) => Promise<string>;
@@ -212,6 +214,8 @@ declare function findOffsetRelativeToScrollParent(element: HTMLElement, which?:
212
214
  */
213
215
  declare function findScrollContainer(el: HTMLElement): HTMLElement | null;
214
216
 
217
+ declare function isFocusable(element: HTMLElement): boolean;
218
+
215
219
  /**
216
220
  * Mantiene visible `element` dentro de su contenedor con scroll,
217
221
  * compensando un posible header fijo (`fixedOffsetTop`).
@@ -347,6 +351,7 @@ declare class Url {
347
351
  addParameter(name: string, value: unknown, allowMultiple?: boolean): void;
348
352
  addParameters(parameters: IParameter[]): void;
349
353
  getParameter(name: string): string | string[];
354
+ getParameters(): [string, string | string[]][];
350
355
  toString(): string;
351
356
  }
352
357
 
@@ -1294,7 +1299,7 @@ declare function useImperativeComponentContext<Events extends TMap = TMap>(): {
1294
1299
  declare function getLabel(name: string, replaceTokens?: {
1295
1300
  text?: Record<string, string>;
1296
1301
  title?: Record<string, string>;
1297
- }): {
1302
+ }, outerWindow?: any): {
1298
1303
  text: string;
1299
1304
  title: string;
1300
1305
  };
@@ -1952,8 +1957,9 @@ declare class Mutex extends Semaphore {
1952
1957
  type Task<T> = () => Promise<T>;
1953
1958
  declare class TasksQueue {
1954
1959
  private mutex;
1960
+ get isBusy(): boolean;
1955
1961
  run<T>(task: Task<T>): Promise<T>;
1956
1962
  }
1957
1963
 
1958
- 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 Task, TasksQueue, type ThrottleOptions, type UnSubscriber, Url, addBoundary, alignment, animate, apiaDateToStandarFormat, arrayOrArray, autoDisconnectMutationObserver, awaitTime, 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, isTrue, makeImperativeComponent, makeSingleImperativeComponent, makeStatefulStore, noNaN, notificationsSelector, openAndReadFile, openAndReadFiles, parseAsSize, parseXMLRequestResponse, parseXmlAsync, persistentStorage, postNavigation, propsStore, screenLocker, scrollParentIntoElement, setValueByPath, shallowCompareArrays, shallowEqual, shortcutController, toBoolean, ucfirst, uniqueId, useCombinedRefs, useDebouncedCallback, useDebouncedState, useDomState, useImperativeComponentContext, useImperativeComponentEvents, useIntermediateValue, useLatest, useLocalStorage, useMatchScrollDirection, useMount, useMountTransition, usePanAndZoom, usePrevious, usePropsSelector, useShallowMemo, useStateRef, useSubscription, useUnmount, useUpdateEffect, useWhyUpdated };
1964
+ 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 Task, TasksQueue, type ThrottleOptions, type UnSubscriber, Url, addBoundary, alignment, animate, apiaDateToStandarFormat, arrayOrArray, autoDisconnectMutationObserver, awaitTime, cantFocusSelector, cloneDeep, customEvents, dateToApiaFormat, debugDispatcher, decodeBase64ToUtf8, decodeHTMLEntities, decrypt, deepEqual, defaultGetNameFromResponse, disableChildrenFocus, downloadStringAsDoc, downloadUrl, enableChildrenFocus, encrypt, findOffsetRelativeToScrollParent, findScrollContainer, focus, focusSelector, formatMessage, freezeDeep, getDateFormat, getFocusSelector, getIndex, getJSObjFromXML, getLabel, getSpecificParent, getValueByPath, globalFocus, globals, isChild, isDebugDispatcherEnabled, isFocusable, isPropsConfigurationObject, isSetter, isTrue, makeImperativeComponent, makeSingleImperativeComponent, makeStatefulStore, noNaN, notificationsSelector, openAndReadFile, openAndReadFiles, parseAsSize, parseXMLRequestResponse, parseXmlAsync, persistentStorage, postNavigation, propsStore, screenLocker, scrollParentIntoElement, setValueByPath, shallowCompareArrays, shallowEqual, shortcutController, toBoolean, ucfirst, uniqueId, useCombinedRefs, useDebouncedCallback, useDebouncedState, useDomState, useImperativeComponentContext, useImperativeComponentEvents, useIntermediateValue, useLatest, useLocalStorage, useMatchScrollDirection, useMount, useMountTransition, usePanAndZoom, usePrevious, usePropsSelector, useShallowMemo, useStateRef, useSubscription, useUnmount, useUpdateEffect, useWhyUpdated };
1959
1965
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -134,6 +134,43 @@ function getIndex(arr, conditions, defaultIndex) {
134
134
  return arr[defaultIndex ?? -1];
135
135
  }
136
136
 
137
+ function deepEqual(a, b, visited = /* @__PURE__ */ new WeakMap()) {
138
+ if (a === b)
139
+ return true;
140
+ if (typeof a !== typeof b)
141
+ return false;
142
+ if (a === null || b === null)
143
+ return a === b;
144
+ if (a instanceof Date && b instanceof Date) {
145
+ return a.getTime() === b.getTime();
146
+ }
147
+ if (Array.isArray(a) && Array.isArray(b)) {
148
+ if (a.length !== b.length)
149
+ return false;
150
+ for (let i = 0; i < a.length; i++) {
151
+ if (!deepEqual(a[i], b[i], visited))
152
+ return false;
153
+ }
154
+ return true;
155
+ }
156
+ if (typeof a === "object" && typeof b === "object") {
157
+ if (visited.get(a) === b)
158
+ return true;
159
+ visited.set(a, b);
160
+ const aKeys = Object.keys(a);
161
+ const bKeys = Object.keys(b);
162
+ if (aKeys.length !== bKeys.length)
163
+ return false;
164
+ for (const key of aKeys) {
165
+ if (!bKeys.includes(key) || !deepEqual(a[key], b[key], visited)) {
166
+ return false;
167
+ }
168
+ }
169
+ return true;
170
+ }
171
+ return false;
172
+ }
173
+
137
174
  const generateKey = async (salt, passPhrase, keySize, iterationCount) => {
138
175
  const CryptoJS = (await import('crypto-js')).default;
139
176
  const key = CryptoJS.PBKDF2(passPhrase, CryptoJS.enc.Hex.parse(salt), {
@@ -348,11 +385,11 @@ const shortcutController = new class ShortcutController {
348
385
  }
349
386
  parseKey(keyString) {
350
387
  const elements = keyString.split("&");
351
- const altKey = elements.includes("alt");
352
- const ctrlKey = elements.includes("ctrl");
353
- const shiftKey = elements.includes("shift");
388
+ const altKey = !!elements.find((c) => c.toLowerCase() === "alt");
389
+ const ctrlKey = !!elements.find((c) => c.toLowerCase() === "ctrl");
390
+ const shiftKey = !!elements.find((c) => c.toLowerCase() === "shift");
354
391
  const key = elements.find(
355
- (current) => current !== "shift" && current !== "alt" && current !== "ctrl"
392
+ (current) => current.toLocaleLowerCase() !== "shift" && current.toLocaleLowerCase() !== "alt" && current.toLocaleLowerCase() !== "ctrl"
356
393
  );
357
394
  if (!key)
358
395
  throw new Error(`parseKey "${keyString}" does not have key.`);
@@ -584,6 +621,26 @@ function findOffsetRelativeToScrollParent(element, which = "Top") {
584
621
  return offset - scrollAmount;
585
622
  }
586
623
 
624
+ function isFocusable(element) {
625
+ if (element.disabled)
626
+ return false;
627
+ if (!element.isConnected)
628
+ return false;
629
+ if (element.offsetParent === null && getComputedStyle(element).position !== "fixed")
630
+ return false;
631
+ const tabIndex = element.getAttribute("tabindex");
632
+ if (tabIndex !== null && parseInt(tabIndex, 10) >= 0)
633
+ return true;
634
+ const focusableTags = ["INPUT", "SELECT", "TEXTAREA", "BUTTON"];
635
+ if (focusableTags.includes(element.tagName))
636
+ return true;
637
+ if (element.tagName === "A" && element.hasAttribute("href"))
638
+ return true;
639
+ if (element.hasAttribute("contenteditable") && element.getAttribute("contenteditable") !== "false")
640
+ return true;
641
+ return false;
642
+ }
643
+
587
644
  const scrollIntervals = {};
588
645
  function scrollParentIntoElement(element, fixedOffsetTop = 0, tries = 2, timeout = 100, scrollId) {
589
646
  const id = scrollId ?? `${Date.now()}_${Math.random()}`;
@@ -878,6 +935,9 @@ class Url {
878
935
  getParameter(name) {
879
936
  return __privateGet$3(this, _parameters)[name];
880
937
  }
938
+ getParameters() {
939
+ return Object.entries(__privateGet$3(this, _parameters));
940
+ }
881
941
  toString() {
882
942
  const parametersArray = Object.entries(__privateGet$3(this, _parameters));
883
943
  return `${this.base}${parametersArray.length > 0 ? `?${parametersArray.map(
@@ -1755,6 +1815,12 @@ function awaitTime(ms) {
1755
1815
  });
1756
1816
  }
1757
1817
 
1818
+ class CancellablePromise extends Promise {
1819
+ constructor(executor, cancel) {
1820
+ super(executor);
1821
+ this.cancel = cancel;
1822
+ }
1823
+ }
1758
1824
  class Semaphore {
1759
1825
  /**
1760
1826
  * Creates a new instance of the Semaphore.
@@ -1786,9 +1852,16 @@ class Semaphore {
1786
1852
  this.current++;
1787
1853
  return Promise.resolve();
1788
1854
  }
1789
- return new Promise((resolve) => {
1790
- this.queue.push(resolve);
1791
- });
1855
+ let resolver = null;
1856
+ return new CancellablePromise(
1857
+ (resolve) => {
1858
+ resolver = resolve;
1859
+ this.queue.push(resolve);
1860
+ },
1861
+ () => {
1862
+ this.queue = this.queue.filter((c) => c !== resolver);
1863
+ }
1864
+ );
1792
1865
  }
1793
1866
  /**
1794
1867
  * Releases a previously acquired permit.
@@ -1816,6 +1889,9 @@ class TasksQueue {
1816
1889
  constructor() {
1817
1890
  this.mutex = new Mutex();
1818
1891
  }
1892
+ get isBusy() {
1893
+ return this.mutex.isBusy;
1894
+ }
1819
1895
  async run(task) {
1820
1896
  await this.mutex.acquire();
1821
1897
  try {
@@ -2410,9 +2486,10 @@ const formatMessage = (str, obj) => {
2410
2486
  return newStr;
2411
2487
  };
2412
2488
 
2413
- function getLabel(name, replaceTokens) {
2489
+ function getLabel(name, replaceTokens, outerWindow) {
2490
+ const actualWindow = outerWindow ?? window;
2414
2491
  const label = {
2415
- ...window.labels[name] ?? {
2492
+ ...actualWindow.labels[name] ?? {
2416
2493
  text: `Not preloaded: ${name}`,
2417
2494
  title: `Not preloaded: ${name}`
2418
2495
  }
@@ -2979,5 +3056,5 @@ const postNavigation = (url, data) => {
2979
3056
  form.submit();
2980
3057
  };
2981
3058
 
2982
- export { AudioRecorder, BasicStoredElement, BouncingEmitter, ClassNameBuilder, EventEmitter, History, Locker, Mutex, PropsSelectorUndefinedObject, PropsStore, ScrollLocker, Semaphore, StatefulEmitter, TasksQueue, Url, addBoundary, alignment, animate, apiaDateToStandarFormat, arrayOrArray, autoDisconnectMutationObserver, awaitTime, 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, isTrue, makeImperativeComponent, makeSingleImperativeComponent, makeStatefulStore, noNaN, notificationsSelector, openAndReadFile, openAndReadFiles, parseAsSize, parseXMLRequestResponse, parseXmlAsync, persistentStorage, postNavigation, propsStore, screenLocker, scrollParentIntoElement, setValueByPath, shallowCompareArrays, shallowEqual, shortcutController, toBoolean, ucfirst, uniqueId, useCombinedRefs, useDebouncedCallback, useDebouncedState, useDomState, useImperativeComponentContext, useImperativeComponentEvents, useIntermediateValue, useLatest, useLocalStorage, useMatchScrollDirection, useMount, useMountTransition, usePanAndZoom, usePrevious, usePropsSelector, useShallowMemo, useStateRef, useSubscription, useUnmount, useUpdateEffect, useWhyUpdated };
3059
+ export { AudioRecorder, BasicStoredElement, BouncingEmitter, ClassNameBuilder, EventEmitter, History, Locker, Mutex, PropsSelectorUndefinedObject, PropsStore, ScrollLocker, Semaphore, StatefulEmitter, TasksQueue, Url, addBoundary, alignment, animate, apiaDateToStandarFormat, arrayOrArray, autoDisconnectMutationObserver, awaitTime, cantFocusSelector, cloneDeep, customEvents, dateToApiaFormat, debugDispatcher, decodeBase64ToUtf8, decodeHTMLEntities, decrypt, deepEqual, defaultGetNameFromResponse, disableChildrenFocus, downloadStringAsDoc, downloadUrl, enableChildrenFocus, encrypt, findOffsetRelativeToScrollParent, findScrollContainer, focus, focusSelector, formatMessage, freezeDeep, getDateFormat, getFocusSelector, getIndex, getJSObjFromXML, getLabel, getSpecificParent, getValueByPath, globalFocus, globals, isChild, isDebugDispatcherEnabled, isFocusable, isPropsConfigurationObject, isSetter, isTrue, makeImperativeComponent, makeSingleImperativeComponent, makeStatefulStore, noNaN, notificationsSelector, openAndReadFile, openAndReadFiles, parseAsSize, parseXMLRequestResponse, parseXmlAsync, persistentStorage, postNavigation, propsStore, screenLocker, scrollParentIntoElement, setValueByPath, shallowCompareArrays, shallowEqual, shortcutController, toBoolean, ucfirst, uniqueId, useCombinedRefs, useDebouncedCallback, useDebouncedState, useDomState, useImperativeComponentContext, useImperativeComponentEvents, useIntermediateValue, useLatest, useLocalStorage, useMatchScrollDirection, useMount, useMountTransition, usePanAndZoom, usePrevious, usePropsSelector, useShallowMemo, useStateRef, useSubscription, useUnmount, useUpdateEffect, useWhyUpdated };
2983
3060
  //# sourceMappingURL=index.js.map