@apia/util 3.0.9 → 3.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 +32 -7
- package/dist/index.js +151 -95
- package/dist/index.js.map +1 -1
- package/package.json +4 -3
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,17 @@ import { AxiosResponse } from 'axios';
|
|
|
4
4
|
|
|
5
5
|
declare function animate(duration: number, callback: (progress: number) => unknown, onFinish?: () => unknown): () => void;
|
|
6
6
|
|
|
7
|
+
type AudioRecorderState = {
|
|
8
|
+
recording: boolean;
|
|
9
|
+
};
|
|
10
|
+
declare class AudioRecorder {
|
|
11
|
+
private mediaRecorder;
|
|
12
|
+
state: AudioRecorderState;
|
|
13
|
+
constructor();
|
|
14
|
+
start(): Promise<Blob>;
|
|
15
|
+
stop(): void;
|
|
16
|
+
}
|
|
17
|
+
|
|
7
18
|
declare function arrayOrArray<T>(o: T | T[] | undefined): T[];
|
|
8
19
|
|
|
9
20
|
/**
|
|
@@ -140,7 +151,15 @@ declare function downloadUrl(url: string, getNameFromResponse?: (blob: AxiosResp
|
|
|
140
151
|
*/
|
|
141
152
|
declare function downloadUrl(url: string, fileName: string): Promise<void>;
|
|
142
153
|
|
|
143
|
-
declare function openAndReadFile(): Promise<string | ArrayBuffer | null>;
|
|
154
|
+
declare function openAndReadFile(accept?: string): Promise<string | ArrayBuffer | null>;
|
|
155
|
+
type TReadFile = {
|
|
156
|
+
content: string | ArrayBuffer;
|
|
157
|
+
name: string;
|
|
158
|
+
};
|
|
159
|
+
declare function openAndReadFiles(inputProps?: Partial<{
|
|
160
|
+
accept: string;
|
|
161
|
+
multiple: string;
|
|
162
|
+
}>): Promise<TReadFile[]>;
|
|
144
163
|
|
|
145
164
|
interface IAutoDisconnectMutationObserverConf {
|
|
146
165
|
/** Por defecto es true */
|
|
@@ -682,10 +701,12 @@ type TApiaFilter = {
|
|
|
682
701
|
asAdditional?: boolean;
|
|
683
702
|
column?: string;
|
|
684
703
|
currentValue: TApiaFilterValue;
|
|
704
|
+
changeFiltersTimestamp?: number;
|
|
685
705
|
deleteFiltersTimestamp?: number;
|
|
686
706
|
error?: string;
|
|
687
707
|
id: string | number;
|
|
688
708
|
isMeta?: boolean;
|
|
709
|
+
isSize?: boolean;
|
|
689
710
|
placeholder?: string;
|
|
690
711
|
runAutomatically?: boolean;
|
|
691
712
|
title?: string;
|
|
@@ -700,6 +721,7 @@ type TApiaFilter = {
|
|
|
700
721
|
*/
|
|
701
722
|
group?: string;
|
|
702
723
|
options?: TApiaFilterOption[];
|
|
724
|
+
sizeMultiplier?: number;
|
|
703
725
|
type?: 'date' | 'D' | 'S' | 'number' | 'N' | 'apiaNumber';
|
|
704
726
|
hide?: boolean;
|
|
705
727
|
hideToFilter?: boolean;
|
|
@@ -963,7 +985,8 @@ type THistoryStepChange<T> = THistoryCount & THistoryStep<T> & {
|
|
|
963
985
|
hasPrevious: boolean;
|
|
964
986
|
hasNext: boolean;
|
|
965
987
|
};
|
|
966
|
-
type THistoryConfiguration = {
|
|
988
|
+
type THistoryConfiguration<T> = {
|
|
989
|
+
initialContent?: T;
|
|
967
990
|
maxLength: number;
|
|
968
991
|
};
|
|
969
992
|
/**
|
|
@@ -999,7 +1022,6 @@ type THistoryConfiguration = {
|
|
|
999
1022
|
declare class History<T> extends EventEmitter<{
|
|
1000
1023
|
stepChange: THistoryStepChange<T>;
|
|
1001
1024
|
}> {
|
|
1002
|
-
private configuration;
|
|
1003
1025
|
private autocloseTimeout;
|
|
1004
1026
|
private currentStep;
|
|
1005
1027
|
private content;
|
|
@@ -1007,7 +1029,8 @@ declare class History<T> extends EventEmitter<{
|
|
|
1007
1029
|
protected enabled: boolean;
|
|
1008
1030
|
private _isOpen;
|
|
1009
1031
|
private timeoutMs;
|
|
1010
|
-
|
|
1032
|
+
private configuration;
|
|
1033
|
+
constructor(onCloseWindow: (push: (newState: T) => void) => unknown, configuration?: Partial<THistoryConfiguration<T>>);
|
|
1011
1034
|
private closeWindow;
|
|
1012
1035
|
private getEvent;
|
|
1013
1036
|
private onCloseWindow;
|
|
@@ -1021,10 +1044,12 @@ declare class History<T> extends EventEmitter<{
|
|
|
1021
1044
|
emit<K extends 'stepChange'>(eventName: K, params?: THistoryStepChange<T>): void;
|
|
1022
1045
|
enable: () => void;
|
|
1023
1046
|
forward: () => void;
|
|
1047
|
+
getContent(): T[];
|
|
1024
1048
|
get isOpen(): boolean;
|
|
1025
1049
|
openWindow: () => void;
|
|
1026
1050
|
reset: () => void;
|
|
1027
|
-
|
|
1051
|
+
runInWindow(cb: () => Promise<void>): Promise<void>;
|
|
1052
|
+
updateConfig: (newConfiguration: Partial<THistoryConfiguration<T>>) => void;
|
|
1028
1053
|
useStep: () => Pick<THistoryStepChange<T>, "hasNext" | "hasPrevious" | "currentStep">;
|
|
1029
1054
|
}
|
|
1030
1055
|
|
|
@@ -1234,7 +1259,7 @@ declare function getLabel(name: string, replaceTokens?: {
|
|
|
1234
1259
|
title?: Record<string, string>;
|
|
1235
1260
|
}): {
|
|
1236
1261
|
text: string;
|
|
1237
|
-
|
|
1262
|
+
title: string;
|
|
1238
1263
|
};
|
|
1239
1264
|
|
|
1240
1265
|
/**
|
|
@@ -1862,5 +1887,5 @@ declare function toBoolean(value: unknown): boolean;
|
|
|
1862
1887
|
|
|
1863
1888
|
declare const parseXmlAsync: <T>(xml: string) => Promise<T>;
|
|
1864
1889
|
|
|
1865
|
-
export { 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, 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 };
|
|
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 };
|
|
1866
1891
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -2,6 +2,7 @@ import { jsx } from 'react/jsx-runtime';
|
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import React__default, { useRef, useCallback, useState, useEffect, useMemo, createContext, useContext } from 'react';
|
|
4
4
|
import uniqueId from 'lodash-es/uniqueId';
|
|
5
|
+
import { makeAutoObservable } from 'mobx';
|
|
5
6
|
import isFunction from 'lodash-es/isFunction';
|
|
6
7
|
import dayjs from 'dayjs';
|
|
7
8
|
import customParseFormat from 'dayjs/plugin/customParseFormat';
|
|
@@ -71,6 +72,48 @@ function animate(duration, callback, onFinish) {
|
|
|
71
72
|
};
|
|
72
73
|
}
|
|
73
74
|
|
|
75
|
+
class AudioRecorder {
|
|
76
|
+
constructor() {
|
|
77
|
+
this.mediaRecorder = null;
|
|
78
|
+
this.state = {
|
|
79
|
+
recording: false
|
|
80
|
+
};
|
|
81
|
+
makeAutoObservable(this);
|
|
82
|
+
}
|
|
83
|
+
async start() {
|
|
84
|
+
if (this.state.recording) {
|
|
85
|
+
throw new Error("Cannot start a recording while other in progress");
|
|
86
|
+
}
|
|
87
|
+
return new Promise((resolve) => {
|
|
88
|
+
(async () => {
|
|
89
|
+
try {
|
|
90
|
+
this.state.recording = true;
|
|
91
|
+
const audioChunks = [];
|
|
92
|
+
const stream = await navigator.mediaDevices.getUserMedia({
|
|
93
|
+
audio: true
|
|
94
|
+
});
|
|
95
|
+
this.mediaRecorder = new MediaRecorder(stream);
|
|
96
|
+
this.mediaRecorder.ondataavailable = (event) => {
|
|
97
|
+
audioChunks.push(event.data);
|
|
98
|
+
};
|
|
99
|
+
this.mediaRecorder.onstop = async () => {
|
|
100
|
+
const audioBlob = new Blob(audioChunks, { type: "audio/wav" });
|
|
101
|
+
resolve(audioBlob);
|
|
102
|
+
this.state.recording = false;
|
|
103
|
+
};
|
|
104
|
+
this.mediaRecorder.start();
|
|
105
|
+
} catch (e) {
|
|
106
|
+
this.state.recording = false;
|
|
107
|
+
throw e;
|
|
108
|
+
}
|
|
109
|
+
})();
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
stop() {
|
|
113
|
+
this.mediaRecorder?.stop();
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
74
117
|
function arrayOrArray(o) {
|
|
75
118
|
if (o === void 0)
|
|
76
119
|
return [];
|
|
@@ -375,11 +418,12 @@ async function downloadUrl(url, secondParameter = defaultGetNameFromResponse) {
|
|
|
375
418
|
);
|
|
376
419
|
}
|
|
377
420
|
|
|
378
|
-
function openAndReadFile() {
|
|
421
|
+
function openAndReadFile(accept) {
|
|
379
422
|
return new Promise((resolve) => {
|
|
380
423
|
const input = document.createElement("input");
|
|
381
424
|
input.type = "file";
|
|
382
425
|
input.style.display = "none";
|
|
426
|
+
input.accept = accept || "*";
|
|
383
427
|
document.body.append(input);
|
|
384
428
|
input.click();
|
|
385
429
|
input.addEventListener("change", (ev) => {
|
|
@@ -401,6 +445,44 @@ function openAndReadFile() {
|
|
|
401
445
|
});
|
|
402
446
|
});
|
|
403
447
|
}
|
|
448
|
+
function openAndReadFiles(inputProps) {
|
|
449
|
+
return new Promise((resolve) => {
|
|
450
|
+
const input = document.createElement("input");
|
|
451
|
+
input.type = "file";
|
|
452
|
+
input.style.display = "none";
|
|
453
|
+
document.body.append(input);
|
|
454
|
+
Object.assign(input, inputProps);
|
|
455
|
+
input.addEventListener("change", (ev) => {
|
|
456
|
+
const fileInput = ev.target;
|
|
457
|
+
if ((fileInput?.files?.length ?? 0) === 0) {
|
|
458
|
+
resolve([]);
|
|
459
|
+
} else {
|
|
460
|
+
const files = [];
|
|
461
|
+
const sources = fileInput.files;
|
|
462
|
+
[...sources].forEach((c) => {
|
|
463
|
+
const reader = new FileReader();
|
|
464
|
+
reader.onload = (event) => {
|
|
465
|
+
fileInput.value = "";
|
|
466
|
+
const content = event.target?.result;
|
|
467
|
+
if (content) {
|
|
468
|
+
files.push({
|
|
469
|
+
content,
|
|
470
|
+
name: c.name
|
|
471
|
+
});
|
|
472
|
+
} else {
|
|
473
|
+
files.push(null);
|
|
474
|
+
}
|
|
475
|
+
if (files.length === sources.length) {
|
|
476
|
+
resolve(files.filter((c2) => !!c2));
|
|
477
|
+
}
|
|
478
|
+
};
|
|
479
|
+
reader.readAsText(c);
|
|
480
|
+
});
|
|
481
|
+
}
|
|
482
|
+
});
|
|
483
|
+
input.click();
|
|
484
|
+
});
|
|
485
|
+
}
|
|
404
486
|
|
|
405
487
|
function autoDisconnectMutationObserver(element, callback, conf) {
|
|
406
488
|
let timeoutRegister = -1;
|
|
@@ -850,54 +932,55 @@ const useDebouncedCallback = (callback, { runWhenTriggered, timeout } = { runWhe
|
|
|
850
932
|
);
|
|
851
933
|
};
|
|
852
934
|
|
|
853
|
-
function usePrevious
|
|
854
|
-
const
|
|
855
|
-
const
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
return
|
|
935
|
+
function usePrevious(value) {
|
|
936
|
+
const previousValue = useRef(void 0);
|
|
937
|
+
const currentValue = useRef(void 0);
|
|
938
|
+
previousValue.current = currentValue.current;
|
|
939
|
+
currentValue.current = value;
|
|
940
|
+
return previousValue;
|
|
859
941
|
}
|
|
860
942
|
|
|
861
|
-
function shallowEqual
|
|
862
|
-
if (
|
|
863
|
-
return true;
|
|
864
|
-
if (!Object.is(a, b) && typeof a !== typeof b) {
|
|
943
|
+
function shallowEqual(a, b) {
|
|
944
|
+
if (typeof a !== typeof b)
|
|
865
945
|
return false;
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
return false;
|
|
871
|
-
}
|
|
872
|
-
for (let i = 0; i < a.length; i++) {
|
|
873
|
-
if (!Object.is(a[i], b[i])) {
|
|
874
|
-
return false;
|
|
875
|
-
}
|
|
876
|
-
}
|
|
877
|
-
return true;
|
|
878
|
-
} else if (a && b) {
|
|
879
|
-
for (const [key, value] of Object.entries(a)) {
|
|
880
|
-
if (!Object.is(value, b[key])) {
|
|
881
|
-
return false;
|
|
882
|
-
}
|
|
883
|
-
}
|
|
884
|
-
for (const [key, value] of Object.entries(b)) {
|
|
885
|
-
if (!Object.is(value, a[key])) {
|
|
886
|
-
return false;
|
|
887
|
-
}
|
|
888
|
-
}
|
|
889
|
-
return true;
|
|
890
|
-
} else if (a && !b || !a && b) {
|
|
946
|
+
if (typeof a === "object" && a && typeof b === "object" && b) {
|
|
947
|
+
const aKeys = Object.keys(a);
|
|
948
|
+
const bKeys = Object.keys(b);
|
|
949
|
+
if (aKeys.length !== bKeys.length)
|
|
891
950
|
return false;
|
|
951
|
+
for (let i = 0; i < aKeys.length; i++) {
|
|
952
|
+
if (a[aKeys[i]] !== b[bKeys[i]])
|
|
953
|
+
return false;
|
|
892
954
|
}
|
|
955
|
+
} else {
|
|
956
|
+
if (a !== b)
|
|
957
|
+
return false;
|
|
893
958
|
}
|
|
894
|
-
return
|
|
959
|
+
return true;
|
|
960
|
+
}
|
|
961
|
+
function shallowCompareArrays(a, b) {
|
|
962
|
+
if (a.length !== b.length)
|
|
963
|
+
return false;
|
|
964
|
+
for (let i = 0; i < a.length; i++) {
|
|
965
|
+
const differ = shallowEqual(a, b);
|
|
966
|
+
if (!differ)
|
|
967
|
+
return false;
|
|
968
|
+
}
|
|
969
|
+
return true;
|
|
970
|
+
}
|
|
971
|
+
function useShallowMemo(creator, deps) {
|
|
972
|
+
const value = useRef(creator());
|
|
973
|
+
const previousDeps = usePrevious(deps);
|
|
974
|
+
if (!shallowEqual(previousDeps.current ?? [], deps)) {
|
|
975
|
+
value.current = creator();
|
|
976
|
+
}
|
|
977
|
+
return value.current;
|
|
895
978
|
}
|
|
896
979
|
|
|
897
980
|
function useIntermediateValue(currentValue) {
|
|
898
981
|
const [innerState, setInnerState] = useState(currentValue);
|
|
899
|
-
const previousValue = usePrevious
|
|
900
|
-
if (!shallowEqual
|
|
982
|
+
const previousValue = usePrevious(currentValue);
|
|
983
|
+
if (!shallowEqual(currentValue, previousValue.current)) {
|
|
901
984
|
setInnerState(currentValue);
|
|
902
985
|
}
|
|
903
986
|
return [innerState, setInnerState];
|
|
@@ -921,14 +1004,6 @@ function useUnmount(unmountCallback) {
|
|
|
921
1004
|
}, []);
|
|
922
1005
|
}
|
|
923
1006
|
|
|
924
|
-
function usePrevious(value) {
|
|
925
|
-
const previousValue = useRef(void 0);
|
|
926
|
-
const currentValue = useRef(void 0);
|
|
927
|
-
previousValue.current = currentValue.current;
|
|
928
|
-
currentValue.current = value;
|
|
929
|
-
return previousValue;
|
|
930
|
-
}
|
|
931
|
-
|
|
932
1007
|
function useStateRef(initialState) {
|
|
933
1008
|
const [state, setState] = useState(initialState);
|
|
934
1009
|
const stateRef = useRef(state);
|
|
@@ -964,43 +1039,6 @@ function useUpdateEffect(effect, deps) {
|
|
|
964
1039
|
}, deps);
|
|
965
1040
|
}
|
|
966
1041
|
|
|
967
|
-
function shallowEqual(a, b) {
|
|
968
|
-
if (typeof a !== typeof b)
|
|
969
|
-
return false;
|
|
970
|
-
if (typeof a === "object" && a && typeof b === "object" && b) {
|
|
971
|
-
const aKeys = Object.keys(a);
|
|
972
|
-
const bKeys = Object.keys(b);
|
|
973
|
-
if (aKeys.length !== bKeys.length)
|
|
974
|
-
return false;
|
|
975
|
-
for (let i = 0; i < aKeys.length; i++) {
|
|
976
|
-
if (a[aKeys[i]] !== b[bKeys[i]])
|
|
977
|
-
return false;
|
|
978
|
-
}
|
|
979
|
-
} else {
|
|
980
|
-
if (a !== b)
|
|
981
|
-
return false;
|
|
982
|
-
}
|
|
983
|
-
return true;
|
|
984
|
-
}
|
|
985
|
-
function shallowCompareArrays(a, b) {
|
|
986
|
-
if (a.length !== b.length)
|
|
987
|
-
return false;
|
|
988
|
-
for (let i = 0; i < a.length; i++) {
|
|
989
|
-
const differ = shallowEqual(a, b);
|
|
990
|
-
if (!differ)
|
|
991
|
-
return false;
|
|
992
|
-
}
|
|
993
|
-
return true;
|
|
994
|
-
}
|
|
995
|
-
function useShallowMemo(creator, deps) {
|
|
996
|
-
const value = useRef(creator());
|
|
997
|
-
const previousDeps = usePrevious(deps);
|
|
998
|
-
if (!shallowEqual(previousDeps.current ?? [], deps)) {
|
|
999
|
-
value.current = creator();
|
|
1000
|
-
}
|
|
1001
|
-
return value.current;
|
|
1002
|
-
}
|
|
1003
|
-
|
|
1004
1042
|
function useWhyUpdated(label, e) {
|
|
1005
1043
|
const previousData = usePrevious(e);
|
|
1006
1044
|
const diffs = [];
|
|
@@ -1964,9 +2002,8 @@ const focus = new (_a = class {
|
|
|
1964
2002
|
}, _a)(document.getElementById("root"));
|
|
1965
2003
|
|
|
1966
2004
|
class History extends EventEmitter {
|
|
1967
|
-
constructor(onCloseWindow, configuration
|
|
2005
|
+
constructor(onCloseWindow, configuration) {
|
|
1968
2006
|
super();
|
|
1969
|
-
this.configuration = configuration;
|
|
1970
2007
|
this.autocloseTimeout = -1;
|
|
1971
2008
|
this.currentStep = 0;
|
|
1972
2009
|
this.content = [];
|
|
@@ -1987,14 +2024,17 @@ class History extends EventEmitter {
|
|
|
1987
2024
|
currentStep: this.currentStep,
|
|
1988
2025
|
stepCount,
|
|
1989
2026
|
hasNext: this.currentStep < stepCount,
|
|
1990
|
-
hasPrevious: this.currentStep
|
|
2027
|
+
hasPrevious: this.currentStep > 0
|
|
1991
2028
|
};
|
|
1992
2029
|
return event;
|
|
1993
2030
|
};
|
|
1994
2031
|
this.push = (el) => {
|
|
1995
2032
|
this.content = [...this.content.slice(0, this.currentStep + 1), el];
|
|
1996
2033
|
this.content = this.content.slice(
|
|
1997
|
-
Math.max(
|
|
2034
|
+
Math.max(
|
|
2035
|
+
0,
|
|
2036
|
+
this.content.length - (this.configuration?.maxLength ?? Infinity)
|
|
2037
|
+
)
|
|
1998
2038
|
);
|
|
1999
2039
|
this.currentStep = this.content.length - 1;
|
|
2000
2040
|
this.shoutStepChange(true);
|
|
@@ -2018,7 +2058,7 @@ class History extends EventEmitter {
|
|
|
2018
2058
|
};
|
|
2019
2059
|
this.back = () => {
|
|
2020
2060
|
clearTimeout(this.autocloseTimeout);
|
|
2021
|
-
if (this.currentStep
|
|
2061
|
+
if (this.currentStep > 0) {
|
|
2022
2062
|
this.currentStep -= 1;
|
|
2023
2063
|
this.shoutStepChange();
|
|
2024
2064
|
}
|
|
@@ -2048,14 +2088,14 @@ class History extends EventEmitter {
|
|
|
2048
2088
|
this.reset = () => {
|
|
2049
2089
|
clearTimeout(this.autocloseTimeout);
|
|
2050
2090
|
this.content = [];
|
|
2051
|
-
this.currentStep =
|
|
2091
|
+
this.currentStep = 0;
|
|
2052
2092
|
this.openWindow();
|
|
2053
2093
|
};
|
|
2054
2094
|
this.updateConfig = (newConfiguration) => {
|
|
2055
2095
|
this.configuration = { ...this.configuration, ...newConfiguration };
|
|
2056
2096
|
};
|
|
2057
2097
|
this.useStep = () => {
|
|
2058
|
-
const [hasPrevious, setHasPrevious] = useState({ hasNext: false, hasPrevious: false, currentStep:
|
|
2098
|
+
const [hasPrevious, setHasPrevious] = useState({ hasNext: false, hasPrevious: false, currentStep: this.currentStep });
|
|
2059
2099
|
useMount(() => {
|
|
2060
2100
|
return this.on("stepChange", (ev) => {
|
|
2061
2101
|
setHasPrevious({
|
|
@@ -2067,16 +2107,32 @@ class History extends EventEmitter {
|
|
|
2067
2107
|
});
|
|
2068
2108
|
return hasPrevious;
|
|
2069
2109
|
};
|
|
2110
|
+
this.configuration = Object.assign({ maxLength: 15 }, configuration);
|
|
2111
|
+
if (configuration?.initialContent !== void 0) {
|
|
2112
|
+
this.content.push(configuration?.initialContent ?? null);
|
|
2113
|
+
} else {
|
|
2114
|
+
this.currentStep = -1;
|
|
2115
|
+
}
|
|
2070
2116
|
this.onCloseWindow = onCloseWindow;
|
|
2071
2117
|
}
|
|
2072
2118
|
emit(eventName, params) {
|
|
2073
2119
|
this.emitting++;
|
|
2074
|
-
|
|
2075
|
-
|
|
2120
|
+
try {
|
|
2121
|
+
super.emit(eventName, params);
|
|
2122
|
+
} finally {
|
|
2123
|
+
this.emitting--;
|
|
2124
|
+
}
|
|
2125
|
+
}
|
|
2126
|
+
getContent() {
|
|
2127
|
+
return this.content;
|
|
2076
2128
|
}
|
|
2077
2129
|
get isOpen() {
|
|
2078
2130
|
return this._isOpen;
|
|
2079
2131
|
}
|
|
2132
|
+
async runInWindow(cb) {
|
|
2133
|
+
await cb();
|
|
2134
|
+
this.onCloseWindow(this.push.bind(this));
|
|
2135
|
+
}
|
|
2080
2136
|
}
|
|
2081
2137
|
|
|
2082
2138
|
const ImperativeComponentContext = createContext(
|
|
@@ -2208,7 +2264,7 @@ function getLabel(name, replaceTokens) {
|
|
|
2208
2264
|
if (replaceTokens?.text !== void 0)
|
|
2209
2265
|
label.text = formatMessage(label.text, replaceTokens.text);
|
|
2210
2266
|
if (replaceTokens?.title !== void 0)
|
|
2211
|
-
label.
|
|
2267
|
+
label.title = formatMessage(label.title, replaceTokens.title);
|
|
2212
2268
|
return label;
|
|
2213
2269
|
}
|
|
2214
2270
|
|
|
@@ -2637,5 +2693,5 @@ const parseXmlAsync = async (xml) => {
|
|
|
2637
2693
|
return result;
|
|
2638
2694
|
};
|
|
2639
2695
|
|
|
2640
|
-
export { 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, parseAsSize, parseXmlAsync, persistentStorage$1 as persistentStorage, 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 };
|
|
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$1 as persistentStorage, 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 };
|
|
2641
2697
|
//# sourceMappingURL=index.js.map
|