@sankhyalabs/core 5.20.0-dev.8 → 5.20.0-dev.80
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/.docs/classes/Base64Utils.md +39 -0
- package/.docs/classes/Change.md +11 -11
- package/.docs/classes/ColumnFilterManager.md +145 -0
- package/.docs/classes/DataUnit.md +429 -139
- package/.docs/classes/DataUnitInMemoryLoader.md +303 -0
- package/.docs/classes/DataUnitLoaderUtils.md +151 -0
- package/.docs/classes/DateUtils.md +8 -8
- package/.docs/classes/FieldComparator.md +2 -2
- package/.docs/classes/IDBRepository.md +22 -0
- package/.docs/classes/KeyboardManager.md +99 -9
- package/.docs/classes/LockManager.md +249 -0
- package/.docs/classes/MaskFormatter.md +66 -14
- package/.docs/classes/ObjectUtils.md +189 -0
- package/.docs/classes/OverflowWatcher.md +533 -0
- package/.docs/classes/SelectionInfo.md +25 -11
- package/.docs/classes/ServiceCanceledException.md +193 -0
- package/.docs/classes/ServiceUtils.md +67 -0
- package/.docs/classes/SilentException.md +193 -0
- package/.docs/classes/StringUtils.md +33 -9
- package/.docs/classes/UserAgentUtils.md +15 -1
- package/.docs/enumerations/Action.md +41 -21
- package/.docs/enumerations/ChangeOperation.md +4 -4
- package/.docs/enumerations/LockManagerOperation.md +33 -0
- package/.docs/enumerations/OverflowDirection.md +29 -0
- package/.docs/enumerations/RECORD_DATE_FORMAT.md +27 -0
- package/.docs/enumerations/SelectionMode.md +2 -2
- package/.docs/enumerations/StorageType.md +37 -0
- package/.docs/enumerations/UserInterface.md +15 -5
- package/.docs/globals.md +25 -0
- package/.docs/interfaces/DUActionInterceptor.md +1 -1
- package/.docs/interfaces/DataUnitInMemoryLoaderConfig.md +37 -0
- package/.docs/interfaces/IRepository.md +18 -0
- package/.docs/interfaces/LoadDataRequest.md +1 -1
- package/.docs/interfaces/OverFlowWatcherParams.md +67 -0
- package/.docs/interfaces/PageRequest.md +3 -3
- package/.docs/interfaces/PaginationInfo.md +25 -0
- package/.docs/interfaces/PaginationInfoBuilderParams.md +37 -0
- package/.docs/interfaces/QuickFilter.md +3 -3
- package/.docs/interfaces/Record.md +4 -4
- package/.docs/interfaces/SavedRecord.md +5 -5
- package/.docs/interfaces/WaitingChange.md +3 -3
- package/.docs/namespaces/MaskFormatter/type-aliases/MaskCharacter.md +1 -1
- package/.docs/namespaces/MaskFormatter/variables/MaskCharacter.md +1 -1
- package/.docs/type-aliases/DataUnitEventOptions.md +17 -0
- package/.docs/type-aliases/OnOverflowCallBack.md +25 -0
- package/.docs/variables/OVERFLOWED_CLASS_NAME.md +13 -0
- package/.releaserc +1 -0
- package/bun.lockb +0 -0
- package/dist/dataunit/DataUnit.d.ts +92 -13
- package/dist/dataunit/DataUnit.js +227 -71
- package/dist/dataunit/DataUnit.js.map +1 -1
- package/dist/dataunit/DataUnitHelper.js +6 -5
- package/dist/dataunit/DataUnitHelper.js.map +1 -1
- package/dist/dataunit/formatting/PrettyFormatter.js +17 -6
- package/dist/dataunit/formatting/PrettyFormatter.js.map +1 -1
- package/dist/dataunit/loader/DataUnitInMemoryLoaderConfig.d.ts +9 -0
- package/dist/dataunit/loader/DataUnitInMemoryLoaderConfig.js +6 -0
- package/dist/dataunit/loader/DataUnitInMemoryLoaderConfig.js.map +1 -0
- package/dist/dataunit/loader/dataUnitInMemoryLoader.d.ts +25 -0
- package/dist/dataunit/loader/dataUnitInMemoryLoader.js +131 -0
- package/dist/dataunit/loader/dataUnitInMemoryLoader.js.map +1 -0
- package/dist/dataunit/loader/utils/dataUnitLoaderUtils.d.ts +20 -0
- package/dist/dataunit/loader/utils/dataUnitLoaderUtils.js +62 -0
- package/dist/dataunit/loader/utils/dataUnitLoaderUtils.js.map +1 -0
- package/dist/dataunit/loading/LoadDataRequest.d.ts +1 -1
- package/dist/dataunit/loading/PaginationInfo.d.ts +8 -0
- package/dist/dataunit/metadata/DataType.js +7 -1
- package/dist/dataunit/metadata/DataType.js.map +1 -1
- package/dist/dataunit/metadata/UnitMetadata.d.ts +1 -0
- package/dist/dataunit/metadata/UnitMetadata.js +1 -0
- package/dist/dataunit/metadata/UnitMetadata.js.map +1 -1
- package/dist/dataunit/sorting/FieldComparator.d.ts +2 -2
- package/dist/dataunit/sorting/FieldComparator.js +4 -9
- package/dist/dataunit/sorting/FieldComparator.js.map +1 -1
- package/dist/dataunit/state/action/DataUnitAction.d.ts +2 -0
- package/dist/dataunit/state/action/DataUnitAction.js +2 -0
- package/dist/dataunit/state/action/DataUnitAction.js.map +1 -1
- package/dist/dataunit/state/slice/LoadingControlSlice.js +16 -0
- package/dist/dataunit/state/slice/LoadingControlSlice.js.map +1 -1
- package/dist/dataunit/state/slice/RecordsSlice.js +1 -1
- package/dist/dataunit/state/slice/RecordsSlice.js.map +1 -1
- package/dist/dataunit/state/slice/SelectionSlice.js +4 -4
- package/dist/dataunit/state/slice/SelectionSlice.js.map +1 -1
- package/dist/exceptions/ServiceCanceledException.d.ts +14 -0
- package/dist/exceptions/ServiceCanceledException.js +13 -0
- package/dist/exceptions/ServiceCanceledException.js.map +1 -0
- package/dist/exceptions/SilentException.d.ts +14 -0
- package/dist/exceptions/SilentException.js +13 -0
- package/dist/exceptions/SilentException.js.map +1 -0
- package/dist/index.d.ts +13 -2
- package/dist/index.js +12 -1
- package/dist/index.js.map +1 -1
- package/dist/repository/IRepository.d.ts +6 -0
- package/dist/repository/indexeddb/IDBRepository.d.ts +1 -0
- package/dist/repository/indexeddb/IDBRepository.js +3 -0
- package/dist/repository/indexeddb/IDBRepository.js.map +1 -1
- package/dist/utils/Base64Utils.d.ts +7 -0
- package/dist/utils/Base64Utils.js +13 -0
- package/dist/utils/Base64Utils.js.map +1 -0
- package/dist/utils/CacheManager/index.d.ts +52 -0
- package/dist/utils/CacheManager/index.js +101 -0
- package/dist/utils/CacheManager/index.js.map +1 -0
- package/dist/utils/CacheManager/interfaces/index.d.ts +5 -0
- package/dist/utils/CacheManager/interfaces/index.js +7 -0
- package/dist/utils/CacheManager/interfaces/index.js.map +1 -0
- package/dist/utils/ColumnFilterManager.d.ts +19 -0
- package/dist/utils/ColumnFilterManager.js +73 -0
- package/dist/utils/ColumnFilterManager.js.map +1 -0
- package/dist/utils/DateUtils.js +3 -0
- package/dist/utils/DateUtils.js.map +1 -1
- package/dist/utils/ElementUtils.d.ts +2 -0
- package/dist/utils/ElementUtils.js +9 -0
- package/dist/utils/ElementUtils.js.map +1 -0
- package/dist/utils/KeyboardManager/index.d.ts +9 -0
- package/dist/utils/KeyboardManager/index.js +45 -1
- package/dist/utils/KeyboardManager/index.js.map +1 -1
- package/dist/utils/KeyboardManager/interface.d.ts +1 -0
- package/dist/utils/LockManager.d.ts +58 -0
- package/dist/utils/LockManager.js +188 -0
- package/dist/utils/LockManager.js.map +1 -0
- package/dist/utils/MaskFormatter.d.ts +16 -1
- package/dist/utils/MaskFormatter.js +82 -2
- package/dist/utils/MaskFormatter.js.map +1 -1
- package/dist/utils/ObjectUtils.d.ts +52 -0
- package/dist/utils/ObjectUtils.js +71 -0
- package/dist/utils/ObjectUtils.js.map +1 -1
- package/dist/utils/OnboardingUtils.js +1 -1
- package/dist/utils/OnboardingUtils.js.map +1 -1
- package/dist/utils/OverflowWatcher/index.d.ts +59 -0
- package/dist/utils/OverflowWatcher/index.js +188 -0
- package/dist/utils/OverflowWatcher/index.js.map +1 -0
- package/dist/utils/OverflowWatcher/types/overflow-callback.d.ts +6 -0
- package/dist/utils/OverflowWatcher/types/overflow-callback.js +2 -0
- package/dist/utils/OverflowWatcher/types/overflow-callback.js.map +1 -0
- package/dist/utils/OverflowWatcher/types/overflow-direction.d.ts +7 -0
- package/dist/utils/OverflowWatcher/types/overflow-direction.js +9 -0
- package/dist/utils/OverflowWatcher/types/overflow-direction.js.map +1 -0
- package/dist/utils/ServiceUtils.d.ts +24 -0
- package/dist/utils/ServiceUtils.js +40 -0
- package/dist/utils/ServiceUtils.js.map +1 -0
- package/dist/utils/SortingUtils.d.ts +9 -0
- package/dist/utils/SortingUtils.js +24 -0
- package/dist/utils/SortingUtils.js.map +1 -0
- package/dist/utils/StringUtils.d.ts +6 -0
- package/dist/utils/StringUtils.js +23 -6
- package/dist/utils/StringUtils.js.map +1 -1
- package/dist/utils/UserAgentUtils/index.d.ts +1 -0
- package/dist/utils/UserAgentUtils/index.js +5 -0
- package/dist/utils/UserAgentUtils/index.js.map +1 -1
- package/jest.config.ts +2 -0
- package/package.json +2 -1
- package/reports/test-report.xml +760 -0
- package/setupTests.js +7 -0
- package/sonar-project.properties +6 -3
- package/src/dataunit/DataUnit.ts +278 -86
- package/src/dataunit/DataUnitHelper.ts +6 -5
- package/src/dataunit/formatting/PrettyFormatter.ts +19 -6
- package/src/dataunit/loader/DataUnitInMemoryLoaderConfig.ts +10 -0
- package/src/dataunit/loader/dataUnitInMemoryLoader.ts +176 -0
- package/src/dataunit/loader/utils/dataUnitLoaderUtils.ts +86 -0
- package/src/dataunit/loading/LoadDataRequest.ts +1 -1
- package/src/dataunit/loading/PaginationInfo.ts +10 -0
- package/src/dataunit/metadata/DataType.ts +8 -1
- package/src/dataunit/metadata/UnitMetadata.ts +1 -0
- package/src/dataunit/sorting/FieldComparator.ts +18 -32
- package/src/dataunit/state/action/DataUnitAction.ts +2 -0
- package/src/dataunit/state/slice/LoadingControlSlice.ts +42 -0
- package/src/dataunit/state/slice/RecordsSlice.ts +1 -1
- package/src/dataunit/state/slice/SelectionSlice.ts +4 -4
- package/src/dataunit/state/slice/test/RecordsSlice.spec.ts +45 -0
- package/src/dataunit/test/DataUnit.spec.ts +44 -0
- package/src/exceptions/ServiceCanceledException.ts +25 -0
- package/src/exceptions/SilentException.ts +25 -0
- package/src/index.ts +32 -1
- package/src/repository/IRepository.ts +7 -0
- package/src/repository/indexeddb/IDBRepository.ts +4 -0
- package/src/utils/Base64Utils.ts +13 -0
- package/src/utils/CacheManager/index.ts +103 -0
- package/src/utils/CacheManager/interfaces/index.ts +5 -0
- package/src/utils/ColumnFilterManager.ts +104 -0
- package/src/utils/DateUtils.ts +3 -0
- package/src/utils/ElementUtils.ts +10 -0
- package/src/utils/KeyboardManager/index.ts +57 -0
- package/src/utils/KeyboardManager/interface.ts +1 -0
- package/src/utils/LockManager.ts +207 -0
- package/src/utils/MaskFormatter.ts +93 -2
- package/src/utils/ObjectUtils.ts +77 -0
- package/src/utils/OnboardingUtils.ts +1 -1
- package/src/utils/OverflowWatcher/index.ts +243 -0
- package/src/utils/OverflowWatcher/types/overflow-callback.ts +6 -0
- package/src/utils/OverflowWatcher/types/overflow-direction.ts +7 -0
- package/src/utils/ServiceUtils.ts +36 -0
- package/src/utils/SortingUtils.ts +30 -0
- package/src/utils/StringUtils.ts +23 -6
- package/src/utils/UserAgentUtils/index.ts +6 -1
- package/test/dataunit/formatting/PrettyFormatter.spec.ts +177 -0
- package/test/dataunit/loader/dataUnitInMemoryLoader.spec.ts +221 -0
- package/test/dataunit/loader/utils/dataUnitLoaderUtils.spec.ts +158 -0
- package/test/testCases/NumberUtilsTestCases.ts +190 -0
- package/test/testCases/StringUtilsTestCases.ts +435 -0
- package/test/testCases/TimeFormatterTestUtils.ts +43 -0
- package/test/util/ColumnFilterManager.spec.ts +133 -0
- package/test/util/ElementUtils.spec.ts +34 -0
- package/test/util/NumberUtils.spec.ts +72 -150
- package/test/util/ObjectUtils.spec.ts +572 -0
- package/test/util/OverflowWatcher.spec.ts +152 -0
- package/test/util/StringUtils.spec.ts +260 -36
- package/test/util/TimeFormatter.spec.ts +65 -18
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import DataUnit from '../DataUnit';
|
|
2
|
+
import { Action } from '../state/action/DataUnitAction';
|
|
3
|
+
|
|
4
|
+
describe('DataUnit', () => {
|
|
5
|
+
|
|
6
|
+
let dataUnit: DataUnit;
|
|
7
|
+
|
|
8
|
+
beforeEach(() => {
|
|
9
|
+
dataUnit = new DataUnit();
|
|
10
|
+
|
|
11
|
+
dataUnit['dispatchAction'] = jest.fn();
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it('should return false when not waiting to reload', () => {
|
|
15
|
+
expect(dataUnit.isWaitingToReload()).toBe(false);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('should set waitingToReload to true', () => {
|
|
19
|
+
dataUnit.setWaitingToReload(true);
|
|
20
|
+
expect(dataUnit.isWaitingToReload()).toBe(true);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('should set waitingToReload to false', () => {
|
|
24
|
+
dataUnit.setWaitingToReload(true);
|
|
25
|
+
dataUnit.setWaitingToReload(false);
|
|
26
|
+
expect(dataUnit.isWaitingToReload()).toBe(false);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('should dispatch SAVING_CANCELED action with correct fields and recordId', () => {
|
|
30
|
+
const fields = [
|
|
31
|
+
{ name: 'field1', message: 'error1' },
|
|
32
|
+
{ name: 'field2', message: 'error2' }
|
|
33
|
+
];
|
|
34
|
+
const recordId = '12345';
|
|
35
|
+
|
|
36
|
+
dataUnit.savingCanceled(fields, recordId);
|
|
37
|
+
|
|
38
|
+
expect(dataUnit['dispatchAction']).toHaveBeenCalledWith(
|
|
39
|
+
Action.SAVING_CANCELED,
|
|
40
|
+
{ fields, recordId },
|
|
41
|
+
undefined
|
|
42
|
+
);
|
|
43
|
+
});
|
|
44
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `ServiceCanceledException`: Exceção lançada quando ocorre o cancelamento de um serviço.
|
|
3
|
+
*/
|
|
4
|
+
export default class ServiceCanceledException extends Error {
|
|
5
|
+
|
|
6
|
+
/** Nome da exceção. */
|
|
7
|
+
public name: string;
|
|
8
|
+
|
|
9
|
+
/** Titulo do erro. */
|
|
10
|
+
public title: string;
|
|
11
|
+
|
|
12
|
+
/** Descrição do erro. */
|
|
13
|
+
public message: string;
|
|
14
|
+
|
|
15
|
+
/** Código do erro, indica o erro disparado pelo backend. */
|
|
16
|
+
public errorCode: string;
|
|
17
|
+
|
|
18
|
+
constructor(title: string, message: string, errorCode: string = "") {
|
|
19
|
+
super(message);
|
|
20
|
+
this.name = "Service Canceled";
|
|
21
|
+
this.title = title;
|
|
22
|
+
this.message = message;
|
|
23
|
+
this.errorCode = errorCode;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `SilentException`: Exceção lançada quando uma exception silenciosa é.
|
|
3
|
+
*/
|
|
4
|
+
export default class SilentException extends Error {
|
|
5
|
+
|
|
6
|
+
/** Nome da exceção. */
|
|
7
|
+
public name: string;
|
|
8
|
+
|
|
9
|
+
/** Titulo do erro. */
|
|
10
|
+
public title: string;
|
|
11
|
+
|
|
12
|
+
/** Descrição do erro. */
|
|
13
|
+
public message: string;
|
|
14
|
+
|
|
15
|
+
/** Código do erro, indica o erro disparado pelo backend. */
|
|
16
|
+
public errorCode: string;
|
|
17
|
+
|
|
18
|
+
constructor(title: string = "", message: string = "", errorCode: string = "") {
|
|
19
|
+
super(message);
|
|
20
|
+
this.name = "SilentException";
|
|
21
|
+
this.title = title;
|
|
22
|
+
this.message = message;
|
|
23
|
+
this.errorCode = errorCode;
|
|
24
|
+
}
|
|
25
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { HttpProvider } from "./http/HttpProvider.js";
|
|
|
9
9
|
import { SkwHttpProvider } from "./http/SkwHttpProvider.js";
|
|
10
10
|
import { RequestMetadata } from "./http/RequestMetadata.js";
|
|
11
11
|
import { AuthorizedServiceCaller } from "./http/AuthorizedServiceCaller.js";
|
|
12
|
-
import DataUnit, {SavedRecord, Record, Change, ChangeOperation, DUActionInterceptor, WaitingChange, PageRequest, QuickFilter, SelectionMode, SelectionInfo} from "./dataunit/DataUnit.js";
|
|
12
|
+
import DataUnit, {SavedRecord, Record, Change, ChangeOperation, DUActionInterceptor, WaitingChange, PageRequest, QuickFilter, SelectionMode, SelectionInfo, DataUnitEventOptions} from "./dataunit/DataUnit.js";
|
|
13
13
|
import { DataType } from "./dataunit/metadata/DataType.js";
|
|
14
14
|
import { UnitMetadata, FieldDescriptor, UserInterface, Sort, SortMode, SortingProvider, Filter, DependencyType, ChildDescriptor, ChildLink } from "./dataunit/metadata/UnitMetadata.js";
|
|
15
15
|
import { DataUnitAction, Action, ExecutionContext } from "./dataunit/state/action/DataUnitAction.js";
|
|
@@ -19,6 +19,8 @@ import ObjectUtils from "./utils/ObjectUtils.js";
|
|
|
19
19
|
import WarningException from "./exceptions/WarningException.js";
|
|
20
20
|
import WaitingChangeException from "./exceptions/WaitingChangeException.js";
|
|
21
21
|
import ErrorException from "./exceptions/ErrorException.js";
|
|
22
|
+
import ServiceCanceledException from "./exceptions/ServiceCanceledException.js";
|
|
23
|
+
import SilentException from "./exceptions/SilentException.js";
|
|
22
24
|
import { ErrorTracking } from "./traking/ErrorTraking.js";
|
|
23
25
|
import { PaginationInfo } from "./dataunit/loading/PaginationInfo.js";
|
|
24
26
|
import { LoadDataRequest } from "./dataunit/loading/LoadDataRequest.js";
|
|
@@ -39,9 +41,20 @@ import { IRepositoryIndex } from "./repository/indexeddb/IRepositoryIndex.js"
|
|
|
39
41
|
import { FieldComparator } from "./dataunit/sorting/FieldComparator.js";
|
|
40
42
|
import { KeyboardManager } from "./utils/KeyboardManager/index.js";
|
|
41
43
|
import { SearchUtils } from "./utils/SearchUtils.js";
|
|
44
|
+
import { ServiceUtils } from "./utils/ServiceUtils.js";
|
|
45
|
+
import { StorageType } from "./utils/CacheManager/index.js";
|
|
46
|
+
import OverflowWatcher, { OnOverflowCallBack, OverflowDirection, OverFlowWatcherParams, OVERFLOWED_CLASS_NAME } from "./utils/OverflowWatcher/index.js";
|
|
47
|
+
import {LockManager, LockManagerOperation} from "./utils/LockManager.js";
|
|
48
|
+
import { DataUnitInMemoryLoader } from "./dataunit/loader/dataUnitInMemoryLoader.js";
|
|
49
|
+
import { DataUnitLoaderUtils, PaginationInfoBuilderParams } from "./dataunit/loader/utils/dataUnitLoaderUtils.js";
|
|
50
|
+
import { ColumnFilterManager } from "./utils/ColumnFilterManager.js";
|
|
51
|
+
import { DataUnitInMemoryLoaderConfig, RECORD_DATE_FORMAT } from "./dataunit/loader/DataUnitInMemoryLoaderConfig.js";
|
|
52
|
+
import Base64Utils from "./utils/Base64Utils.js";
|
|
42
53
|
|
|
43
54
|
/*Classes públicas no pacote*/
|
|
44
55
|
export {
|
|
56
|
+
LockManager,
|
|
57
|
+
LockManagerOperation,
|
|
45
58
|
StringUtils,
|
|
46
59
|
MaskFormatter,
|
|
47
60
|
NumberUtils,
|
|
@@ -106,4 +119,22 @@ export {
|
|
|
106
119
|
defaultDataLoader,
|
|
107
120
|
KeyboardManager,
|
|
108
121
|
SearchUtils,
|
|
122
|
+
ServiceUtils,
|
|
123
|
+
StorageType,
|
|
124
|
+
OverflowWatcher,
|
|
125
|
+
OnOverflowCallBack,
|
|
126
|
+
OverflowDirection,
|
|
127
|
+
OverFlowWatcherParams,
|
|
128
|
+
OVERFLOWED_CLASS_NAME,
|
|
129
|
+
DataUnitEventOptions,
|
|
130
|
+
ServiceCanceledException,
|
|
131
|
+
SilentException,
|
|
132
|
+
DataUnitInMemoryLoader,
|
|
133
|
+
DataUnitLoaderUtils,
|
|
134
|
+
PaginationInfoBuilderParams,
|
|
135
|
+
ColumnFilterManager,
|
|
136
|
+
DataUnitInMemoryLoaderConfig,
|
|
137
|
+
RECORD_DATE_FORMAT,
|
|
138
|
+
Base64Utils,
|
|
139
|
+
|
|
109
140
|
};
|
|
@@ -79,4 +79,11 @@ export interface IRepository<T>{
|
|
|
79
79
|
* @returns Promessa de quantidade
|
|
80
80
|
*/
|
|
81
81
|
count(): Promise<number>;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Retorna todos os registros que estão em cache no momento
|
|
85
|
+
*
|
|
86
|
+
* @returns Todos registros que estão em cache no momento
|
|
87
|
+
*/
|
|
88
|
+
getFromCache(): Array<T> | undefined
|
|
82
89
|
}
|
|
@@ -320,6 +320,10 @@ export class IDBRepository<T> implements IRepository<T>{
|
|
|
320
320
|
const tx = db.transaction(this._addedStoreName);
|
|
321
321
|
return tx.objectStore(this._addedStoreName).getAll();
|
|
322
322
|
}
|
|
323
|
+
|
|
324
|
+
public getFromCache(): Array<T> | undefined{
|
|
325
|
+
return undefined;
|
|
326
|
+
}
|
|
323
327
|
}
|
|
324
328
|
|
|
325
329
|
/**
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export default class Base64Utils{
|
|
2
|
+
/**
|
|
3
|
+
* Adiciona caracteres de quebra de linha ao hash64 que representa o recordId do registro.
|
|
4
|
+
* @param base64String - id do registro
|
|
5
|
+
*/
|
|
6
|
+
public static addBreakLineCharacters(base64String: string) {
|
|
7
|
+
const lineBreakPattern = /.{1,76}/g;
|
|
8
|
+
const result = base64String.match(lineBreakPattern)?.join('\n') ?? base64String;
|
|
9
|
+
return result.slice(0, 247) + '\n' + result.slice(247);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { StorageType } from './interfaces/index.js';
|
|
2
|
+
|
|
3
|
+
export * from "./interfaces/index.js";
|
|
4
|
+
|
|
5
|
+
export class CacheManager {
|
|
6
|
+
/**
|
|
7
|
+
* Nome da chave utilizada para armazenar o cache no armazenamento.
|
|
8
|
+
*/
|
|
9
|
+
private static readonly storageKey = 'cacheManager';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Estrutura de armazenamento em memória.
|
|
13
|
+
*/
|
|
14
|
+
private static inMemoryCache = new Map<string, any>();
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Recupera ou define o valor no cache.
|
|
18
|
+
*
|
|
19
|
+
* @param key Identificador único para armazenar e recuperar o valor.
|
|
20
|
+
* @param fetchCallback Função que retorna uma `Promise` com o valor a ser armazenado no cache caso ele não exista ou tenha expirado.
|
|
21
|
+
* @param storageType Tipo de armazenamento: `'inMemoryCache'`, `'sessionStorage'` ou `'localStorage'`.
|
|
22
|
+
* @returns Uma `Promise` com o valor armazenado ou obtido via `fetchCallback`.
|
|
23
|
+
*/
|
|
24
|
+
public static async getOrSet<T>(
|
|
25
|
+
key: string,
|
|
26
|
+
fetchCallback: () => Promise<T>,
|
|
27
|
+
storageType: StorageType = StorageType.IN_MEMORY_CACHE
|
|
28
|
+
): Promise<T> {
|
|
29
|
+
const cache = this.getCache(storageType);
|
|
30
|
+
|
|
31
|
+
if (cache[key]) {
|
|
32
|
+
return cache[key].data;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const data = await fetchCallback();
|
|
36
|
+
cache[key] = { data };
|
|
37
|
+
this.saveCache(cache, storageType);
|
|
38
|
+
return data;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Remove uma entrada específica do cache.
|
|
43
|
+
*
|
|
44
|
+
* @param key Identificador único da entrada a ser removida.
|
|
45
|
+
* @param storageType Tipo de armazenamento: `'inMemoryCache'`, `'sessionStorage'` ou `'localStorage'`.
|
|
46
|
+
*/
|
|
47
|
+
public static clear(key: string, storageType: StorageType = StorageType.IN_MEMORY_CACHE): void {
|
|
48
|
+
const cache = this.getCache(storageType);
|
|
49
|
+
delete cache[key];
|
|
50
|
+
this.saveCache(cache, storageType);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Remove todas as entradas do cache.
|
|
55
|
+
*
|
|
56
|
+
* @param storageType Tipo de armazenamento: `'inMemoryCache'`, `'sessionStorage'` ou `'localStorage'`.
|
|
57
|
+
*/
|
|
58
|
+
public static clearAll(storageType: StorageType = StorageType.IN_MEMORY_CACHE): void {
|
|
59
|
+
if (storageType === StorageType.IN_MEMORY_CACHE) {
|
|
60
|
+
this.inMemoryCache.clear();
|
|
61
|
+
} else {
|
|
62
|
+
this.getStorage(storageType).removeItem(this.storageKey);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Obtém o cache armazenado no armazenamento especificado.
|
|
68
|
+
* @param storageType Tipo de armazenamento: `'inMemoryCache'`, `'sessionStorage'` ou `'localStorage'`.
|
|
69
|
+
* @returns Um objeto representando o cache armazenado.
|
|
70
|
+
*/
|
|
71
|
+
private static getCache(storageType: StorageType): Record<string, any> {
|
|
72
|
+
if (storageType === StorageType.IN_MEMORY_CACHE) {
|
|
73
|
+
return Object.fromEntries(this.inMemoryCache);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const storage = this.getStorage(storageType);
|
|
77
|
+
const cache = storage.getItem(this.storageKey);
|
|
78
|
+
return cache ? JSON.parse(cache) : {};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Salva o cache no armazenamento especificado.
|
|
83
|
+
* @param cache O objeto representando o cache a ser salvo.
|
|
84
|
+
* @param storageType Tipo de armazenamento: `'inMemoryCache'`, `'sessionStorage'` ou `'localStorage'`.
|
|
85
|
+
*/
|
|
86
|
+
private static saveCache(cache: Record<string, any>, storageType: StorageType): void {
|
|
87
|
+
if (storageType === StorageType.IN_MEMORY_CACHE) {
|
|
88
|
+
this.inMemoryCache = new Map(Object.entries(cache));
|
|
89
|
+
} else {
|
|
90
|
+
const storage = this.getStorage(storageType);
|
|
91
|
+
storage.setItem(this.storageKey, JSON.stringify(cache));
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Retorna o armazenamento correspondente ao tipo especificado.
|
|
97
|
+
* @param storageType Tipo de armazenamento: `'sessionStorage'` ou `'localStorage'`.
|
|
98
|
+
* @returns O objeto de armazenamento correspondente.
|
|
99
|
+
*/
|
|
100
|
+
private static getStorage(storageType: StorageType): Storage {
|
|
101
|
+
return storageType === StorageType.LOCAL_STORAGE ? localStorage : sessionStorage;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { Filter } from '../dataunit/metadata/UnitMetadata.js';
|
|
2
|
+
import DataUnit, { Record } from '../dataunit/DataUnit.js';
|
|
3
|
+
import { FieldComparator } from '../dataunit/sorting/FieldComparator.js';
|
|
4
|
+
import { LoadDataRequest } from '../dataunit/loading/LoadDataRequest.js';
|
|
5
|
+
|
|
6
|
+
const COLUMN_FILTER_PATTERN = /FILTRO_COLUNA_(.+)/;
|
|
7
|
+
|
|
8
|
+
export class ColumnFilterManager {
|
|
9
|
+
|
|
10
|
+
public static getColumnFilters(filters: Array<Filter>, fieldName: string): Map<string, IColumnFilter> {
|
|
11
|
+
const columnFilters: Map<string, IColumnFilter> = new Map();
|
|
12
|
+
|
|
13
|
+
if (!filters?.length) {
|
|
14
|
+
return columnFilters;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
filters.forEach(filter => {
|
|
18
|
+
const result = COLUMN_FILTER_PATTERN.exec(filter.name);
|
|
19
|
+
if (result) {
|
|
20
|
+
if (fieldName !== result[1]) {
|
|
21
|
+
columnFilters.set(filter.name, { columnName: result[1], ...filter });
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
return columnFilters;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
public static getFilterFunction(dataUnit: DataUnit, filters?: Array<IColumnFilter>): ((record: Record) => boolean) | undefined {
|
|
30
|
+
if (!filters?.length) return undefined;
|
|
31
|
+
|
|
32
|
+
return record => {
|
|
33
|
+
for (const filter of filters) {
|
|
34
|
+
if (!ColumnFilterManager.recordMatchesFilter(dataUnit, record, filter)) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return true;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
private static recordMatchesFilter(dataUnit: DataUnit, record: Record, columnFilter: IColumnFilter): boolean {
|
|
43
|
+
const fieldDescriptor = dataUnit.getField(columnFilter.columnName);
|
|
44
|
+
|
|
45
|
+
if (!columnFilter.params || !fieldDescriptor) return false;
|
|
46
|
+
|
|
47
|
+
const fieldValue = record[columnFilter.columnName];
|
|
48
|
+
|
|
49
|
+
for (let param of columnFilter.params) {
|
|
50
|
+
const paramValue = dataUnit.valueFromString(columnFilter.columnName, param.value);
|
|
51
|
+
if (FieldComparator.compareValues(fieldDescriptor, fieldValue, paramValue) === 0) {
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
}
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
public static compileDistinct(fieldName: string, dataUnit: DataUnit): Array<IMultiSelectionOption> {
|
|
60
|
+
const request = dataUnit.getLastLoadRequest();
|
|
61
|
+
let list = dataUnit.records;
|
|
62
|
+
return this.doCompileDistinct(request, fieldName, dataUnit, list);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
public static compileDistinctFromArray(fieldName: string, dataUnit: DataUnit, records: Array<Record>): Array<IMultiSelectionOption> {
|
|
66
|
+
const request = dataUnit.getLastLoadRequest();
|
|
67
|
+
return this.doCompileDistinct(request, fieldName, dataUnit, records);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
private static doCompileDistinct(request: LoadDataRequest | undefined, fieldName: string, dataUnit: DataUnit, list: Array<Record>) {
|
|
71
|
+
if (request != undefined) {
|
|
72
|
+
const columnFilters: Array<IColumnFilter> = Array.from(ColumnFilterManager.getColumnFilters(request?.filters ?? [], fieldName).values());
|
|
73
|
+
const filterFunction = ColumnFilterManager.getFilterFunction(dataUnit, columnFilters);
|
|
74
|
+
if (filterFunction != undefined) {
|
|
75
|
+
list = list.filter(filterFunction);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const distinct: Map<string, IMultiSelectionOption> = new Map(
|
|
80
|
+
list.map(record => {
|
|
81
|
+
const fieldValue = record[fieldName];
|
|
82
|
+
if (fieldValue == undefined) {
|
|
83
|
+
return [null, { label: null, value: null, check: true }];
|
|
84
|
+
}
|
|
85
|
+
const item = { label: dataUnit.getFormattedValue(fieldName, fieldValue), value: fieldValue, check: true };
|
|
86
|
+
return [item.label, item];
|
|
87
|
+
}) as any,
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
return Array.from(distinct.values());
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
interface IMultiSelectionOption {
|
|
97
|
+
value: string;
|
|
98
|
+
label: string;
|
|
99
|
+
check: boolean;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export interface IColumnFilter extends Filter {
|
|
103
|
+
columnName: string;
|
|
104
|
+
}
|
package/src/utils/DateUtils.ts
CHANGED
|
@@ -39,6 +39,9 @@ export default class DateUtils{
|
|
|
39
39
|
* @returns - Uma string com as horas no formato HH:MM ou HH:MM:SS.
|
|
40
40
|
*/
|
|
41
41
|
public static formatTime(date: Date, showSeconds: boolean = false): string{
|
|
42
|
+
if (date == null){
|
|
43
|
+
return '';
|
|
44
|
+
}
|
|
42
45
|
const timeOptions:Intl.DateTimeFormatOptions = {hour: "2-digit", minute: "2-digit", second: showSeconds ? "2-digit" : undefined};
|
|
43
46
|
return new Intl.DateTimeFormat("pt-BR", timeOptions).format(date);
|
|
44
47
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { OverflowDirection } from './OverflowWatcher/types/overflow-direction.js';
|
|
2
|
+
|
|
3
|
+
export function calcMarginSize(el:Element, scrollDirection: OverflowDirection){
|
|
4
|
+
const computedStyle = getComputedStyle(el);
|
|
5
|
+
if(OverflowDirection.HORIZONTAL === scrollDirection){
|
|
6
|
+
return (parseInt(computedStyle.marginLeft || '0') + parseInt(computedStyle.marginRight || '0'));
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
return (parseInt(computedStyle.marginTop || '0') + parseInt(computedStyle.marginBottom || '0'));
|
|
10
|
+
}
|
|
@@ -9,6 +9,7 @@ import { keyCodeEventValues } from "./keyCodes/index.js";
|
|
|
9
9
|
*/
|
|
10
10
|
export class KeyboardManager {
|
|
11
11
|
private _options: IKeyboardOptions;
|
|
12
|
+
private _shadowRoots: ShadowRoot [] = [];
|
|
12
13
|
private _mappedElements: IKeyboardMappedKeysElements = {};
|
|
13
14
|
|
|
14
15
|
/**
|
|
@@ -22,10 +23,48 @@ export class KeyboardManager {
|
|
|
22
23
|
propagate: false,
|
|
23
24
|
element: document.body,
|
|
24
25
|
debounceTime: 0,
|
|
26
|
+
enableShadowDom: false,
|
|
25
27
|
...options
|
|
26
28
|
}
|
|
29
|
+
|
|
30
|
+
if(this._options.enableShadowDom) {
|
|
31
|
+
this._shadowRoots = this.findAllNestedShadowRoots(this._options.element);
|
|
32
|
+
}
|
|
27
33
|
}
|
|
28
34
|
|
|
35
|
+
private findAllNestedShadowRoots(element: HTMLElement | Element | ChildNode | Document , results: ShadowRoot [] = []): ShadowRoot [] {
|
|
36
|
+
if (!element) {
|
|
37
|
+
return results;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const shadowRoot = (element as HTMLElement)?.shadowRoot;
|
|
41
|
+
if (shadowRoot) {
|
|
42
|
+
results.push(shadowRoot);
|
|
43
|
+
|
|
44
|
+
shadowRoot.querySelectorAll("*").forEach((child) => {
|
|
45
|
+
this.findAllNestedShadowRoots(child, results);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
element.childNodes.forEach((child) => {
|
|
50
|
+
this.findAllNestedShadowRoots(child, results);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
return results;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
private addEventListenerToNestedShadowRoots(event: 'keydown' | 'keyup', callback: VoidFunction) {
|
|
57
|
+
this._shadowRoots.forEach((shadowRoot) => {
|
|
58
|
+
shadowRoot.addEventListener(event, callback);
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
private removeEventListenerToNestedShadowRoots(event: 'keydown' | 'keyup', callback: VoidFunction) {
|
|
63
|
+
this._shadowRoots.forEach((shadowRoot) => {
|
|
64
|
+
shadowRoot.removeEventListener(event, callback);
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
29
68
|
/**
|
|
30
69
|
* Associa um evento de teclado com uma função
|
|
31
70
|
*
|
|
@@ -61,9 +100,23 @@ export class KeyboardManager {
|
|
|
61
100
|
|
|
62
101
|
bindOptions.element.addEventListener(bindOptions.type, debounceFunction);
|
|
63
102
|
|
|
103
|
+
if(bindOptions.enableShadowDom) {
|
|
104
|
+
this.addEventListenerToNestedShadowRoots(bindOptions.type, debounceFunction);
|
|
105
|
+
}
|
|
106
|
+
|
|
64
107
|
return this;
|
|
65
108
|
}
|
|
66
109
|
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Remove todos os eventos de teclado ou de uma lista informada
|
|
113
|
+
*
|
|
114
|
+
*/
|
|
115
|
+
public unbindAllShortcutKeys(listShortcutKeys?: string[]): void {
|
|
116
|
+
const mappedKeys = [...Object.keys(listShortcutKeys || this._mappedElements)];
|
|
117
|
+
mappedKeys?.forEach(keyMap => this.unbind(keyMap));
|
|
118
|
+
}
|
|
119
|
+
|
|
67
120
|
/**
|
|
68
121
|
* Remove um evento de teclado
|
|
69
122
|
*
|
|
@@ -86,6 +139,10 @@ export class KeyboardManager {
|
|
|
86
139
|
|
|
87
140
|
element.removeEventListener(type, callback);
|
|
88
141
|
|
|
142
|
+
if(unbindElement.options.enableShadowDom) {
|
|
143
|
+
this.removeEventListenerToNestedShadowRoots(type, callback);
|
|
144
|
+
}
|
|
145
|
+
|
|
89
146
|
return this;
|
|
90
147
|
}
|
|
91
148
|
|