@apia/util 4.0.8 → 4.0.11
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 +36 -4
- package/dist/index.js +196 -29
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -136,6 +136,11 @@ type DownloadStringAsDocProps = {
|
|
|
136
136
|
declare function downloadStringAsDoc(content: string, options?: DownloadStringAsDocProps): Promise<void>;
|
|
137
137
|
|
|
138
138
|
declare function defaultGetNameFromResponse(blob: AxiosResponse): string;
|
|
139
|
+
type TDownloadUrlOptions = {
|
|
140
|
+
fileName?: string;
|
|
141
|
+
getNameFromResponse?: boolean | ((blob: AxiosResponse) => string);
|
|
142
|
+
postData: string;
|
|
143
|
+
};
|
|
139
144
|
/**
|
|
140
145
|
* This function gets an URL and a file name and performs a file download.
|
|
141
146
|
*
|
|
@@ -149,7 +154,7 @@ declare function downloadUrl(url: string, getNameFromResponse?: (blob: AxiosResp
|
|
|
149
154
|
* @param url The url to fetch
|
|
150
155
|
* @param fileName The name the file will have as default in the save dialog
|
|
151
156
|
*/
|
|
152
|
-
declare function downloadUrl(url: string, fileName: string): Promise<void>;
|
|
157
|
+
declare function downloadUrl(url: string, fileName: string | TDownloadUrlOptions): Promise<void>;
|
|
153
158
|
|
|
154
159
|
declare function openAndReadFile(accept?: string): Promise<string | ArrayBuffer | null>;
|
|
155
160
|
type TReadFile = {
|
|
@@ -1325,7 +1330,7 @@ declare function noNaN(number: unknown, defaultReturn?: number): number;
|
|
|
1325
1330
|
console.log(getValueByPath(obj,'a.b.c.d')) // 'd'
|
|
1326
1331
|
*
|
|
1327
1332
|
*/
|
|
1328
|
-
declare function getValueByPath(obj:
|
|
1333
|
+
declare function getValueByPath<T>(obj: object, path: string | string[], separator?: string): T | undefined;
|
|
1329
1334
|
|
|
1330
1335
|
/**
|
|
1331
1336
|
* Permite escribir una propiedad en un objeto, en una ruta especificada. Si
|
|
@@ -1356,7 +1361,14 @@ declare function getValueByPath(obj: Record<string, unknown>, path: string | str
|
|
|
1356
1361
|
* }
|
|
1357
1362
|
* }
|
|
1358
1363
|
*/
|
|
1359
|
-
declare function setValueByPath(obj:
|
|
1364
|
+
declare function setValueByPath<T extends object>(obj: T, path: string, value: unknown): T | null;
|
|
1365
|
+
|
|
1366
|
+
declare function cloneDeep<T>(o: T): T;
|
|
1367
|
+
|
|
1368
|
+
type DeepReadonly<T> = Readonly<T extends object ? {
|
|
1369
|
+
[K in keyof T]: Readonly<DeepReadonly<T[K]>>;
|
|
1370
|
+
} : T>;
|
|
1371
|
+
declare function freezeDeep<T>(o: T): DeepReadonly<T>;
|
|
1360
1372
|
|
|
1361
1373
|
type TProperties = Record<string, unknown>;
|
|
1362
1374
|
type TPropsSuscriptor<PropsType extends Record<string, unknown> = TProperties> = (props: PropsType, urgent?: boolean) => unknown;
|
|
@@ -1861,6 +1873,13 @@ declare function alignment(a: string, b: string): number;
|
|
|
1861
1873
|
|
|
1862
1874
|
declare function ucfirst(word: string): string;
|
|
1863
1875
|
|
|
1876
|
+
declare class ClassNameBuilder {
|
|
1877
|
+
private classes;
|
|
1878
|
+
push(...classes: string[]): this;
|
|
1879
|
+
pushConditional(cond: boolean, clazz: string): this;
|
|
1880
|
+
get(): string;
|
|
1881
|
+
}
|
|
1882
|
+
|
|
1864
1883
|
/**
|
|
1865
1884
|
* Toma un valor y devuelve true o false según las
|
|
1866
1885
|
* siguientes condiciones:
|
|
@@ -1885,7 +1904,20 @@ declare function ucfirst(word: string): string;
|
|
|
1885
1904
|
*/
|
|
1886
1905
|
declare function toBoolean(value: unknown): boolean;
|
|
1887
1906
|
|
|
1907
|
+
declare const getJSObjFromXML: (xml: XMLDocument | string) => Record<string, unknown>;
|
|
1888
1908
|
declare const parseXmlAsync: <T>(xml: string) => Promise<T>;
|
|
1909
|
+
declare const parseXMLRequestResponse: (response: AxiosResponse<unknown, unknown>) => Record<string, unknown>;
|
|
1910
|
+
|
|
1911
|
+
declare const postNavigation: (url: string, data: Record<string, any>) => void;
|
|
1912
|
+
|
|
1913
|
+
declare class Mutex {
|
|
1914
|
+
locked: boolean;
|
|
1915
|
+
queue: any[];
|
|
1916
|
+
constructor();
|
|
1917
|
+
lock(): Promise<void>;
|
|
1918
|
+
unlock(): void;
|
|
1919
|
+
runExclusive(fn: () => Promise<unknown>): Promise<unknown>;
|
|
1920
|
+
}
|
|
1889
1921
|
|
|
1890
|
-
export { AudioRecorder, type AudioRecorderState, BasicStoredElement, BouncingEmitter, type Callback, type DebounceOptions, type DownloadStringAsDocProps, EventEmitter, History, type IOnFocusConfiguration, type IParameter, type ISetBoundary, type Map, 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 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, customEvents, dateToApiaFormat, debugDispatcher, decodeHTMLEntities, decrypt, defaultGetNameFromResponse, disableChildrenFocus, downloadStringAsDoc, downloadUrl, enableChildrenFocus, encrypt, findOffsetRelativeToScrollParent, findScrollContainer, focus, focusSelector, formatMessage, getDateFormat, getFocusSelector, getIndex, getLabel, getSpecificParent, getValueByPath, globalFocus, isChild, isDebugDispatcherEnabled, isPropsConfigurationObject, isSetter, makeImperativeComponent, makeSingleImperativeComponent, makeStatefulStore, noNaN, notificationsSelector, openAndReadFile, openAndReadFiles, parseAsSize, parseXmlAsync, persistentStorage, 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 };
|
|
1922
|
+
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 };
|
|
1891
1923
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -6,8 +6,10 @@ 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';
|
|
9
|
+
import axios from 'axios';
|
|
10
|
+
import FileSaver from 'file-saver';
|
|
9
11
|
import clone from 'lodash-es/clone';
|
|
10
|
-
import cloneDeep from 'lodash-es/cloneDeep';
|
|
12
|
+
import cloneDeep$1 from 'lodash-es/cloneDeep';
|
|
11
13
|
import xml2js from 'xml2js';
|
|
12
14
|
import { parseBooleans, parseNumbers } from 'xml2js/lib/processors';
|
|
13
15
|
|
|
@@ -403,19 +405,31 @@ async function downloadStringAsDoc(content, options) {
|
|
|
403
405
|
}
|
|
404
406
|
|
|
405
407
|
function defaultGetNameFromResponse(blob) {
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
)?.[1] ?? "noFileName";
|
|
408
|
+
const contentDisposition = blob.headers["content-disposition"];
|
|
409
|
+
return contentDisposition?.match(/filename=(?:\\?")?([^"]+)/i)?.[1] ?? "noFileName";
|
|
409
410
|
}
|
|
411
|
+
const secondParameterIsTDownloadUrlOptions = (param = defaultGetNameFromResponse) => {
|
|
412
|
+
return !!param.postData;
|
|
413
|
+
};
|
|
410
414
|
async function downloadUrl(url, secondParameter = defaultGetNameFromResponse) {
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
415
|
+
if (secondParameterIsTDownloadUrlOptions(secondParameter)) {
|
|
416
|
+
const blob = await axios.post(
|
|
417
|
+
url,
|
|
418
|
+
{
|
|
419
|
+
postData: secondParameter.postData
|
|
420
|
+
},
|
|
421
|
+
{ responseType: "blob" }
|
|
422
|
+
);
|
|
423
|
+
const getNameFromResponse = secondParameter.getNameFromResponse instanceof Function ? secondParameter.getNameFromResponse : secondParameter.getNameFromResponse === true ? defaultGetNameFromResponse : () => "noname";
|
|
424
|
+
const actualFileName = secondParameter.fileName ?? getNameFromResponse(blob);
|
|
425
|
+
FileSaver.saveAs(new Blob([blob.data]), actualFileName);
|
|
426
|
+
} else {
|
|
427
|
+
const blob = await axios.get(url, {
|
|
428
|
+
responseType: "blob"
|
|
429
|
+
});
|
|
430
|
+
const actualFileName = typeof secondParameter === "string" ? secondParameter : secondParameter(blob);
|
|
431
|
+
FileSaver.saveAs(new Blob([blob.data]), actualFileName);
|
|
432
|
+
}
|
|
419
433
|
}
|
|
420
434
|
|
|
421
435
|
function openAndReadFile(accept) {
|
|
@@ -1026,6 +1040,18 @@ function useSubscription({
|
|
|
1026
1040
|
});
|
|
1027
1041
|
return state;
|
|
1028
1042
|
}
|
|
1043
|
+
class Base {
|
|
1044
|
+
constructor() {
|
|
1045
|
+
this.state = { value: "" };
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
1048
|
+
class Child extends Base {
|
|
1049
|
+
constructor() {
|
|
1050
|
+
super(...arguments);
|
|
1051
|
+
this.state = { value: "", isLoading: false };
|
|
1052
|
+
}
|
|
1053
|
+
}
|
|
1054
|
+
new Child();
|
|
1029
1055
|
|
|
1030
1056
|
function useUpdateEffect(effect, deps) {
|
|
1031
1057
|
const hasRunnedForFirstTime = useRef(false);
|
|
@@ -1201,7 +1227,7 @@ var __privateAdd$3 = (obj, member, value) => {
|
|
|
1201
1227
|
};
|
|
1202
1228
|
var __privateSet$3 = (obj, member, value, setter) => {
|
|
1203
1229
|
__accessCheck$3(obj, member, "write to private field");
|
|
1204
|
-
|
|
1230
|
+
member.set(obj, value);
|
|
1205
1231
|
return value;
|
|
1206
1232
|
};
|
|
1207
1233
|
var _onFocusCallbacks, _a$1;
|
|
@@ -1283,7 +1309,7 @@ var __privateAdd$2 = (obj, member, value) => {
|
|
|
1283
1309
|
};
|
|
1284
1310
|
var __privateSet$2 = (obj, member, value, setter) => {
|
|
1285
1311
|
__accessCheck$2(obj, member, "write to private field");
|
|
1286
|
-
|
|
1312
|
+
member.set(obj, value);
|
|
1287
1313
|
return value;
|
|
1288
1314
|
};
|
|
1289
1315
|
var __privateMethod$1 = (obj, member, method) => {
|
|
@@ -1374,7 +1400,7 @@ var __privateAdd$1 = (obj, member, value) => {
|
|
|
1374
1400
|
};
|
|
1375
1401
|
var __privateSet$1 = (obj, member, value, setter) => {
|
|
1376
1402
|
__accessCheck$1(obj, member, "write to private field");
|
|
1377
|
-
|
|
1403
|
+
member.set(obj, value);
|
|
1378
1404
|
return value;
|
|
1379
1405
|
};
|
|
1380
1406
|
var _onUpdateCbs;
|
|
@@ -1679,7 +1705,6 @@ const persistentStorage = new Proxy(
|
|
|
1679
1705
|
}
|
|
1680
1706
|
);
|
|
1681
1707
|
window.persistentStorage = persistentStorage;
|
|
1682
|
-
var persistentStorage$1 = persistentStorage;
|
|
1683
1708
|
|
|
1684
1709
|
const localStorageController = new class LocalSctorageController extends EventEmitter {
|
|
1685
1710
|
}();
|
|
@@ -1731,12 +1756,12 @@ var __privateAdd = (obj, member, value) => {
|
|
|
1731
1756
|
};
|
|
1732
1757
|
var __privateSet = (obj, member, value, setter) => {
|
|
1733
1758
|
__accessCheck(obj, member, "write to private field");
|
|
1734
|
-
|
|
1759
|
+
member.set(obj, value);
|
|
1735
1760
|
return value;
|
|
1736
1761
|
};
|
|
1737
1762
|
var __privateWrapper = (obj, member, setter, getter) => ({
|
|
1738
1763
|
set _(value) {
|
|
1739
|
-
__privateSet(obj, member, value
|
|
1764
|
+
__privateSet(obj, member, value);
|
|
1740
1765
|
},
|
|
1741
1766
|
get _() {
|
|
1742
1767
|
return __privateGet(obj, member, getter);
|
|
@@ -1800,7 +1825,7 @@ const focus = new (_a = class {
|
|
|
1800
1825
|
name,
|
|
1801
1826
|
selector
|
|
1802
1827
|
}) {
|
|
1803
|
-
persistentStorage
|
|
1828
|
+
persistentStorage.focusOnReload = [
|
|
1804
1829
|
id ? `#${id}` : void 0,
|
|
1805
1830
|
name ? `[name="${name}"]` : void 0,
|
|
1806
1831
|
className ? `.${className}` : void 0,
|
|
@@ -1850,9 +1875,9 @@ const focus = new (_a = class {
|
|
|
1850
1875
|
if (appModalsBox)
|
|
1851
1876
|
modalsObserver.observe(appModalsBox, { childList: true });
|
|
1852
1877
|
screenLocker.on("releaseForFirstTime", () => {
|
|
1853
|
-
if (persistentStorage
|
|
1854
|
-
this.focusOnReload = persistentStorage
|
|
1855
|
-
persistentStorage
|
|
1878
|
+
if (persistentStorage.focusOnReload)
|
|
1879
|
+
this.focusOnReload = persistentStorage.focusOnReload;
|
|
1880
|
+
persistentStorage.focusOnReload = null;
|
|
1856
1881
|
this.afterNotifications(() => {
|
|
1857
1882
|
if (this.focusOnReload) {
|
|
1858
1883
|
const initialFocusElement = document.querySelector(
|
|
@@ -2241,7 +2266,6 @@ const useImperativeComponentEvents = (handlers) => {
|
|
|
2241
2266
|
}, [eventsStore, handlers, id, registerEvents, uniqueHookId]);
|
|
2242
2267
|
return uniqueHookId;
|
|
2243
2268
|
};
|
|
2244
|
-
var useImperativeComponentEvents$1 = useImperativeComponentEvents;
|
|
2245
2269
|
|
|
2246
2270
|
const formatMessage = (str, obj) => {
|
|
2247
2271
|
let newStr = str;
|
|
@@ -2316,18 +2340,52 @@ function setValueByPath(obj, path, value) {
|
|
|
2316
2340
|
return originalClonedObject;
|
|
2317
2341
|
}
|
|
2318
2342
|
|
|
2343
|
+
function cloneDeep(o) {
|
|
2344
|
+
if (typeof o === "object" && o) {
|
|
2345
|
+
if (Array.isArray(o)) {
|
|
2346
|
+
return o.map((c) => cloneDeep(c));
|
|
2347
|
+
}
|
|
2348
|
+
return Object.fromEntries(
|
|
2349
|
+
Object.entries(o).map(([key, value]) => [
|
|
2350
|
+
key,
|
|
2351
|
+
cloneDeep(value)
|
|
2352
|
+
])
|
|
2353
|
+
);
|
|
2354
|
+
}
|
|
2355
|
+
return o;
|
|
2356
|
+
}
|
|
2357
|
+
|
|
2358
|
+
function freezeDeep(o) {
|
|
2359
|
+
if (typeof o === "object" && o) {
|
|
2360
|
+
if (Array.isArray(o)) {
|
|
2361
|
+
return Object.freeze(
|
|
2362
|
+
o.map((c) => freezeDeep(c))
|
|
2363
|
+
);
|
|
2364
|
+
}
|
|
2365
|
+
return Object.freeze(
|
|
2366
|
+
Object.fromEntries(
|
|
2367
|
+
Object.entries(o).map(([key, value]) => [
|
|
2368
|
+
key,
|
|
2369
|
+
freezeDeep(value)
|
|
2370
|
+
])
|
|
2371
|
+
)
|
|
2372
|
+
);
|
|
2373
|
+
}
|
|
2374
|
+
return typeof o === "object" && o ? Object.freeze(o) : o;
|
|
2375
|
+
}
|
|
2376
|
+
|
|
2319
2377
|
const propsLog = "propsLog";
|
|
2320
2378
|
const PropsSelectorUndefinedObject = {};
|
|
2321
2379
|
class PropsStore {
|
|
2322
2380
|
constructor(configuration) {
|
|
2323
2381
|
this.configuration = configuration;
|
|
2324
|
-
this.log = persistentStorage
|
|
2382
|
+
this.log = persistentStorage[propsLog];
|
|
2325
2383
|
this.fields = {};
|
|
2326
2384
|
this.suscriptors = {};
|
|
2327
2385
|
this.loggers = {
|
|
2328
2386
|
propsLog: ([log]) => {
|
|
2329
2387
|
this.log = log;
|
|
2330
|
-
persistentStorage
|
|
2388
|
+
persistentStorage[propsLog] = log;
|
|
2331
2389
|
},
|
|
2332
2390
|
propsStore: ([fieldId]) => {
|
|
2333
2391
|
if (fieldId)
|
|
@@ -2397,7 +2455,7 @@ class PropsStore {
|
|
|
2397
2455
|
}
|
|
2398
2456
|
}
|
|
2399
2457
|
getAllFields() {
|
|
2400
|
-
return cloneDeep(this.fields);
|
|
2458
|
+
return cloneDeep$1(this.fields);
|
|
2401
2459
|
}
|
|
2402
2460
|
/**
|
|
2403
2461
|
* Devuelve los props actuales de un campo.
|
|
@@ -2631,6 +2689,25 @@ function ucfirst(word) {
|
|
|
2631
2689
|
return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();
|
|
2632
2690
|
}
|
|
2633
2691
|
|
|
2692
|
+
class ClassNameBuilder {
|
|
2693
|
+
constructor() {
|
|
2694
|
+
this.classes = [];
|
|
2695
|
+
}
|
|
2696
|
+
push(...classes) {
|
|
2697
|
+
this.classes.push(...classes);
|
|
2698
|
+
return this;
|
|
2699
|
+
}
|
|
2700
|
+
pushConditional(cond, clazz) {
|
|
2701
|
+
if (cond) {
|
|
2702
|
+
this.classes.push(clazz);
|
|
2703
|
+
}
|
|
2704
|
+
return this;
|
|
2705
|
+
}
|
|
2706
|
+
get() {
|
|
2707
|
+
return this.classes.join(" ");
|
|
2708
|
+
}
|
|
2709
|
+
}
|
|
2710
|
+
|
|
2634
2711
|
function toBoolean(value) {
|
|
2635
2712
|
if (typeof value === "string") {
|
|
2636
2713
|
return !["false", ""].includes(value.toLowerCase());
|
|
@@ -2653,6 +2730,38 @@ const processAjaxEventResponse = (value, name) => {
|
|
|
2653
2730
|
return false;
|
|
2654
2731
|
return value;
|
|
2655
2732
|
};
|
|
2733
|
+
const getJSObjFromXML = (xml) => {
|
|
2734
|
+
let objJS = null;
|
|
2735
|
+
const parser = new xml2js.Parser({
|
|
2736
|
+
trim: true,
|
|
2737
|
+
normalize: true,
|
|
2738
|
+
explicitRoot: false,
|
|
2739
|
+
mergeAttrs: true,
|
|
2740
|
+
explicitArray: false,
|
|
2741
|
+
charkey: "content",
|
|
2742
|
+
attrValueProcessors: [
|
|
2743
|
+
parseBooleans,
|
|
2744
|
+
processStringObj,
|
|
2745
|
+
processAjaxEventResponse
|
|
2746
|
+
],
|
|
2747
|
+
tagNameProcessors: [processAjaxEventTagNames],
|
|
2748
|
+
attrNameProcessors: [processAjaxEventAttrNames]
|
|
2749
|
+
});
|
|
2750
|
+
parser.parseString(
|
|
2751
|
+
xml,
|
|
2752
|
+
(err, result) => {
|
|
2753
|
+
if (err) {
|
|
2754
|
+
console.warn("Error Parsing XML data", err);
|
|
2755
|
+
} else {
|
|
2756
|
+
objJS = result;
|
|
2757
|
+
}
|
|
2758
|
+
}
|
|
2759
|
+
);
|
|
2760
|
+
if (objJS) {
|
|
2761
|
+
return objJS;
|
|
2762
|
+
}
|
|
2763
|
+
return {};
|
|
2764
|
+
};
|
|
2656
2765
|
const processStringObj = (value, key) => {
|
|
2657
2766
|
if (key === "value" && typeof value === "number" && Number.isNaN(value)) {
|
|
2658
2767
|
return "";
|
|
@@ -2683,15 +2792,73 @@ const parseXmlAsync = async (xml) => {
|
|
|
2683
2792
|
});
|
|
2684
2793
|
const result = await new Promise((resolve, reject) => {
|
|
2685
2794
|
parser.parseString(xml, (err, innerResult) => {
|
|
2686
|
-
if (err)
|
|
2795
|
+
if (err) {
|
|
2796
|
+
console.log(xml);
|
|
2687
2797
|
reject(err);
|
|
2688
|
-
else {
|
|
2798
|
+
} else {
|
|
2689
2799
|
resolve(innerResult);
|
|
2690
2800
|
}
|
|
2691
2801
|
});
|
|
2692
2802
|
});
|
|
2693
2803
|
return result;
|
|
2694
2804
|
};
|
|
2805
|
+
const parseXMLRequestResponse = (response) => {
|
|
2806
|
+
const requestResponse = response.data;
|
|
2807
|
+
const xmlToJSOBj = getJSObjFromXML(requestResponse);
|
|
2808
|
+
if (xmlToJSOBj) {
|
|
2809
|
+
return xmlToJSOBj;
|
|
2810
|
+
}
|
|
2811
|
+
return {};
|
|
2812
|
+
};
|
|
2813
|
+
|
|
2814
|
+
const postNavigation = (url, data) => {
|
|
2815
|
+
const form = document.createElement("form");
|
|
2816
|
+
form.method = "POST";
|
|
2817
|
+
form.action = url;
|
|
2818
|
+
Object.entries(data).forEach(([key, value]) => {
|
|
2819
|
+
if (value !== void 0 && value !== null) {
|
|
2820
|
+
const input = document.createElement("input");
|
|
2821
|
+
input.type = "hidden";
|
|
2822
|
+
input.name = key;
|
|
2823
|
+
input.value = String(value);
|
|
2824
|
+
form.appendChild(input);
|
|
2825
|
+
}
|
|
2826
|
+
});
|
|
2827
|
+
document.body.appendChild(form);
|
|
2828
|
+
form.submit();
|
|
2829
|
+
};
|
|
2830
|
+
|
|
2831
|
+
class Mutex {
|
|
2832
|
+
constructor() {
|
|
2833
|
+
this.locked = false;
|
|
2834
|
+
this.queue = [];
|
|
2835
|
+
}
|
|
2836
|
+
async lock() {
|
|
2837
|
+
const ticket = new Promise((resolve) => this.queue.push(resolve));
|
|
2838
|
+
if (!this.locked) {
|
|
2839
|
+
this.locked = true;
|
|
2840
|
+
const next = this.queue.shift();
|
|
2841
|
+
next();
|
|
2842
|
+
}
|
|
2843
|
+
await ticket;
|
|
2844
|
+
}
|
|
2845
|
+
unlock() {
|
|
2846
|
+
if (this.queue.length > 0) {
|
|
2847
|
+
const next = this.queue.shift();
|
|
2848
|
+
next();
|
|
2849
|
+
} else {
|
|
2850
|
+
this.locked = false;
|
|
2851
|
+
}
|
|
2852
|
+
}
|
|
2853
|
+
async runExclusive(fn) {
|
|
2854
|
+
await this.lock();
|
|
2855
|
+
try {
|
|
2856
|
+
return await fn();
|
|
2857
|
+
} finally {
|
|
2858
|
+
this.unlock();
|
|
2859
|
+
}
|
|
2860
|
+
}
|
|
2861
|
+
}
|
|
2695
2862
|
|
|
2696
|
-
export { AudioRecorder, BasicStoredElement, BouncingEmitter, EventEmitter, History, PropsSelectorUndefinedObject, PropsStore, StatefulEmitter, Url, addBoundary, alignment, animate, apiaDateToStandarFormat, arrayOrArray, autoDisconnectMutationObserver, cantFocusSelector, customEvents, dateToApiaFormat, debugDispatcher, decodeHTMLEntities, decrypt, defaultGetNameFromResponse, disableChildrenFocus, downloadStringAsDoc, downloadUrl, enableChildrenFocus, encrypt, findOffsetRelativeToScrollParent, findScrollContainer, focus, focusSelector, formatMessage, getDateFormat, getFocusSelector, getIndex, getLabel, getSpecificParent, getValueByPath, globalFocus, isChild, isDebugDispatcherEnabled, isPropsConfigurationObject, isSetter, makeImperativeComponent, makeSingleImperativeComponent, makeStatefulStore, noNaN, notificationsSelector, openAndReadFile, openAndReadFiles, parseAsSize, parseXmlAsync, persistentStorage
|
|
2863
|
+
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, 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 };
|
|
2697
2864
|
//# sourceMappingURL=index.js.map
|