@sankhyalabs/core 0.0.0-bugfix-dev-KB-6165.0
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/.nojekyll +1 -0
- package/.docs/README.md +63 -0
- package/.docs/classes/ApplicationContext.md +90 -0
- package/.docs/classes/ArrayUtils.md +99 -0
- package/.docs/classes/AuthorizedServiceCaller.md +76 -0
- package/.docs/classes/Change.md +190 -0
- package/.docs/classes/DataUnit.md +2453 -0
- package/.docs/classes/DataUnitAction.md +96 -0
- package/.docs/classes/DataUnitStorage.md +116 -0
- package/.docs/classes/DateUtils.md +327 -0
- package/.docs/classes/ElementIDUtils.md +308 -0
- package/.docs/classes/ErrorException.md +214 -0
- package/.docs/classes/ErrorTracking.md +62 -0
- package/.docs/classes/FloatingManager.md +530 -0
- package/.docs/classes/HTMLBuilder.md +45 -0
- package/.docs/classes/HttpProvider.md +96 -0
- package/.docs/classes/JSUtils.md +115 -0
- package/.docs/classes/MaskFormatter-1.md +347 -0
- package/.docs/classes/NumberUtils.md +335 -0
- package/.docs/classes/ObjectUtils.md +160 -0
- package/.docs/classes/OnboardingUtils.md +126 -0
- package/.docs/classes/PromiseSync.md +91 -0
- package/.docs/classes/ReadyUtil.md +115 -0
- package/.docs/classes/RequestMetadata.md +84 -0
- package/.docs/classes/SelectionInfo.md +168 -0
- package/.docs/classes/SkwHttpProvider.md +109 -0
- package/.docs/classes/StringUtils.md +562 -0
- package/.docs/classes/TimeFormatter.md +98 -0
- package/.docs/classes/UserAgentUtils.md +58 -0
- package/.docs/classes/VersionUtils.md +42 -0
- package/.docs/classes/WaitingChangeException.md +200 -0
- package/.docs/classes/WarningException.md +214 -0
- package/.docs/enums/Action.md +294 -0
- package/.docs/enums/ChangeOperation.md +52 -0
- package/.docs/enums/DataType.md +63 -0
- package/.docs/enums/DependencyType.md +41 -0
- package/.docs/enums/SelectionMode.md +30 -0
- package/.docs/enums/SortMode.md +30 -0
- package/.docs/enums/UserInterface.md +195 -0
- package/.docs/interfaces/ChildDescriptor.md +41 -0
- package/.docs/interfaces/ChildLink.md +30 -0
- package/.docs/interfaces/DUActionInterceptor.md +29 -0
- package/.docs/interfaces/ExecutionContext.md +58 -0
- package/.docs/interfaces/FieldDescriptor.md +140 -0
- package/.docs/interfaces/Filter.md +41 -0
- package/.docs/interfaces/IElementIDInfo.md +30 -0
- package/.docs/interfaces/LoadDataRequest.md +101 -0
- package/.docs/interfaces/LoadDataResponse.md +36 -0
- package/.docs/interfaces/PageRequest.md +41 -0
- package/.docs/interfaces/PaginationInfo.md +75 -0
- package/.docs/interfaces/PromiseSyncCallback.md +39 -0
- package/.docs/interfaces/QuickFilter.md +41 -0
- package/.docs/interfaces/Record.md +62 -0
- package/.docs/interfaces/SavedRecord.md +85 -0
- package/.docs/interfaces/Sort.md +41 -0
- package/.docs/interfaces/SortingProvider.md +29 -0
- package/.docs/interfaces/UnitMetadata.md +52 -0
- package/.docs/interfaces/WaitingChange.md +41 -0
- package/.docs/modules/MaskFormatter.md +37 -0
- package/.docs/modules.md +74 -0
- package/.docs/package.json +15 -0
- package/.eslintignore +2 -0
- package/.eslintrc.cjs +35 -0
- package/.husky/commit-msg +4 -0
- package/.releaserc +58 -0
- package/README.md +62 -0
- package/commitlint.config.cjs +14 -0
- package/dist/async/PromiseSync.d.ts +29 -0
- package/dist/async/PromiseSync.js +31 -0
- package/dist/async/PromiseSync.js.map +1 -0
- package/dist/dataunit/DataUnit.d.ts +924 -0
- package/dist/dataunit/DataUnit.js +1621 -0
- package/dist/dataunit/DataUnit.js.map +1 -0
- package/dist/dataunit/DataUnitStorage.d.ts +24 -0
- package/dist/dataunit/DataUnitStorage.js +39 -0
- package/dist/dataunit/DataUnitStorage.js.map +1 -0
- package/dist/dataunit/formatting/PrettyFormatter.d.ts +2 -0
- package/dist/dataunit/formatting/PrettyFormatter.js +94 -0
- package/dist/dataunit/formatting/PrettyFormatter.js.map +1 -0
- package/dist/dataunit/loading/LoadDataRequest.d.ts +19 -0
- package/dist/dataunit/loading/LoadDataRequest.js +2 -0
- package/dist/dataunit/loading/LoadDataRequest.js.map +1 -0
- package/dist/dataunit/loading/LoadDataResponse.d.ts +9 -0
- package/dist/dataunit/loading/LoadDataResponse.js +2 -0
- package/dist/dataunit/loading/LoadDataResponse.js.map +1 -0
- package/dist/dataunit/loading/PaginationInfo.d.ts +13 -0
- package/dist/dataunit/loading/PaginationInfo.js +2 -0
- package/dist/dataunit/loading/PaginationInfo.js.map +1 -0
- package/dist/dataunit/metadata/DataType.d.ts +54 -0
- package/dist/dataunit/metadata/DataType.js +124 -0
- package/dist/dataunit/metadata/DataType.js.map +1 -0
- package/dist/dataunit/metadata/UnitMetadata.d.ts +88 -0
- package/dist/dataunit/metadata/UnitMetadata.js +36 -0
- package/dist/dataunit/metadata/UnitMetadata.js.map +1 -0
- package/dist/dataunit/state/HistReducer.d.ts +10 -0
- package/dist/dataunit/state/HistReducer.js +28 -0
- package/dist/dataunit/state/HistReducer.js.map +1 -0
- package/dist/dataunit/state/StateManager.d.ts +57 -0
- package/dist/dataunit/state/StateManager.js +97 -0
- package/dist/dataunit/state/StateManager.js.map +1 -0
- package/dist/dataunit/state/action/DataUnitAction.d.ts +40 -0
- package/dist/dataunit/state/action/DataUnitAction.js +42 -0
- package/dist/dataunit/state/action/DataUnitAction.js.map +1 -0
- package/dist/dataunit/state/slice/AddedRecordsSlice.d.ts +12 -0
- package/dist/dataunit/state/slice/AddedRecordsSlice.js +30 -0
- package/dist/dataunit/state/slice/AddedRecordsSlice.js.map +1 -0
- package/dist/dataunit/state/slice/ChangesSlice.d.ts +13 -0
- package/dist/dataunit/state/slice/ChangesSlice.js +105 -0
- package/dist/dataunit/state/slice/ChangesSlice.js.map +1 -0
- package/dist/dataunit/state/slice/InvalidFieldsSlice.d.ts +10 -0
- package/dist/dataunit/state/slice/InvalidFieldsSlice.js +66 -0
- package/dist/dataunit/state/slice/InvalidFieldsSlice.js.map +1 -0
- package/dist/dataunit/state/slice/LoadingControlSlice.d.ts +19 -0
- package/dist/dataunit/state/slice/LoadingControlSlice.js +45 -0
- package/dist/dataunit/state/slice/LoadingControlSlice.js.map +1 -0
- package/dist/dataunit/state/slice/RecordsSlice.d.ts +11 -0
- package/dist/dataunit/state/slice/RecordsSlice.js +62 -0
- package/dist/dataunit/state/slice/RecordsSlice.js.map +1 -0
- package/dist/dataunit/state/slice/RemovedRecordsSlice.d.ts +9 -0
- package/dist/dataunit/state/slice/RemovedRecordsSlice.js +25 -0
- package/dist/dataunit/state/slice/RemovedRecordsSlice.js.map +1 -0
- package/dist/dataunit/state/slice/SelectionSlice.d.ts +19 -0
- package/dist/dataunit/state/slice/SelectionSlice.js +155 -0
- package/dist/dataunit/state/slice/SelectionSlice.js.map +1 -0
- package/dist/dataunit/state/slice/SnapshotSlice.d.ts +19 -0
- package/dist/dataunit/state/slice/SnapshotSlice.js +106 -0
- package/dist/dataunit/state/slice/SnapshotSlice.js.map +1 -0
- package/dist/dataunit/state/slice/UnitMetadataSlice.d.ts +11 -0
- package/dist/dataunit/state/slice/UnitMetadataSlice.js +21 -0
- package/dist/dataunit/state/slice/UnitMetadataSlice.js.map +1 -0
- package/dist/dataunit/state/slice/WaitingChangesSlice.d.ts +12 -0
- package/dist/dataunit/state/slice/WaitingChangesSlice.js +56 -0
- package/dist/dataunit/state/slice/WaitingChangesSlice.js.map +1 -0
- package/dist/exceptions/ErrorException.d.ts +14 -0
- package/dist/exceptions/ErrorException.js +13 -0
- package/dist/exceptions/ErrorException.js.map +1 -0
- package/dist/exceptions/WaitingChangeException.d.ts +12 -0
- package/dist/exceptions/WaitingChangeException.js +12 -0
- package/dist/exceptions/WaitingChangeException.js.map +1 -0
- package/dist/exceptions/WarningException.d.ts +14 -0
- package/dist/exceptions/WarningException.js +13 -0
- package/dist/exceptions/WarningException.js.map +1 -0
- package/dist/html/HTMLBuilder.d.ts +3 -0
- package/dist/html/HTMLBuilder.js +9 -0
- package/dist/html/HTMLBuilder.js.map +1 -0
- package/dist/http/AuthorizedServiceCaller.d.ts +11 -0
- package/dist/http/AuthorizedServiceCaller.js +54 -0
- package/dist/http/AuthorizedServiceCaller.js.map +1 -0
- package/dist/http/HttpProvider.d.ts +25 -0
- package/dist/http/HttpProvider.js +74 -0
- package/dist/http/HttpProvider.js.map +1 -0
- package/dist/http/RequestMetadata.d.ts +30 -0
- package/dist/http/RequestMetadata.js +25 -0
- package/dist/http/RequestMetadata.js.map +1 -0
- package/dist/http/SkwHttpProvider.d.ts +9 -0
- package/dist/http/SkwHttpProvider.js +67 -0
- package/dist/http/SkwHttpProvider.js.map +1 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.js +33 -0
- package/dist/index.js.map +1 -0
- package/dist/traking/ErrorTraking.d.ts +19 -0
- package/dist/traking/ErrorTraking.js +34 -0
- package/dist/traking/ErrorTraking.js.map +1 -0
- package/dist/ui/FloatingManager.d.ts +164 -0
- package/dist/ui/FloatingManager.js +358 -0
- package/dist/ui/FloatingManager.js.map +1 -0
- package/dist/utils/ApplicationContext.d.ts +26 -0
- package/dist/utils/ApplicationContext.js +38 -0
- package/dist/utils/ApplicationContext.js.map +1 -0
- package/dist/utils/ArrayUtils.d.ts +29 -0
- package/dist/utils/ArrayUtils.js +57 -0
- package/dist/utils/ArrayUtils.js.map +1 -0
- package/dist/utils/CriteriaModel.d.ts +107 -0
- package/dist/utils/CriteriaModel.js +172 -0
- package/dist/utils/CriteriaModel.js.map +1 -0
- package/dist/utils/CriteriaParameter.d.ts +69 -0
- package/dist/utils/CriteriaParameter.js +83 -0
- package/dist/utils/CriteriaParameter.js.map +1 -0
- package/dist/utils/DateUtils.d.ts +97 -0
- package/dist/utils/DateUtils.js +171 -0
- package/dist/utils/DateUtils.js.map +1 -0
- package/dist/utils/ElementIDUtils.d.ts +72 -0
- package/dist/utils/ElementIDUtils.js +161 -0
- package/dist/utils/ElementIDUtils.js.map +1 -0
- package/dist/utils/JSUtils.d.ts +36 -0
- package/dist/utils/JSUtils.js +66 -0
- package/dist/utils/JSUtils.js.map +1 -0
- package/dist/utils/MaskFormatter.d.ts +148 -0
- package/dist/utils/MaskFormatter.js +356 -0
- package/dist/utils/MaskFormatter.js.map +1 -0
- package/dist/utils/NumberUtils.d.ts +127 -0
- package/dist/utils/NumberUtils.js +245 -0
- package/dist/utils/NumberUtils.js.map +1 -0
- package/dist/utils/ObjectUtils.d.ts +47 -0
- package/dist/utils/ObjectUtils.js +68 -0
- package/dist/utils/ObjectUtils.js.map +1 -0
- package/dist/utils/OnboardingUtils.d.ts +17 -0
- package/dist/utils/OnboardingUtils.js +41 -0
- package/dist/utils/OnboardingUtils.js.map +1 -0
- package/dist/utils/ReadyUtil.d.ts +24 -0
- package/dist/utils/ReadyUtil.js +41 -0
- package/dist/utils/ReadyUtil.js.map +1 -0
- package/dist/utils/StringUtils.d.ts +167 -0
- package/dist/utils/StringUtils.js +328 -0
- package/dist/utils/StringUtils.js.map +1 -0
- package/dist/utils/TimeFormatter.d.ts +33 -0
- package/dist/utils/TimeFormatter.js +98 -0
- package/dist/utils/TimeFormatter.js.map +1 -0
- package/dist/utils/UserAgentUtils/index.d.ts +15 -0
- package/dist/utils/UserAgentUtils/index.js +48 -0
- package/dist/utils/UserAgentUtils/index.js.map +1 -0
- package/dist/utils/UserAgentUtils/navigatorAgentList.d.ts +17 -0
- package/dist/utils/UserAgentUtils/navigatorAgentList.js +40 -0
- package/dist/utils/UserAgentUtils/navigatorAgentList.js.map +1 -0
- package/dist/utils/VersionUtils.d.ts +7 -0
- package/dist/utils/VersionUtils.js +31 -0
- package/dist/utils/VersionUtils.js.map +1 -0
- package/jest.config.ts +17 -0
- package/mock/http/XMLHttpRequest-mock.js +26 -0
- package/package.json +52 -0
- package/scripts/runlink.bat +1 -0
- package/scripts/runlink.sh +1 -0
- package/src/async/PromiseSync.ts +49 -0
- package/src/dataunit/DataUnit.ts +1835 -0
- package/src/dataunit/DataUnitStorage.ts +43 -0
- package/src/dataunit/formatting/PrettyFormatter.ts +113 -0
- package/src/dataunit/loading/LoadDataRequest.ts +26 -0
- package/src/dataunit/loading/LoadDataResponse.ts +11 -0
- package/src/dataunit/loading/PaginationInfo.ts +18 -0
- package/src/dataunit/metadata/DataType.ts +127 -0
- package/src/dataunit/metadata/UnitMetadata.ts +102 -0
- package/src/dataunit/state/HistReducer.ts +34 -0
- package/src/dataunit/state/StateManager.ts +142 -0
- package/src/dataunit/state/action/DataUnitAction.ts +67 -0
- package/src/dataunit/state/slice/AddedRecordsSlice.ts +48 -0
- package/src/dataunit/state/slice/ChangesSlice.ts +125 -0
- package/src/dataunit/state/slice/InvalidFieldsSlice.ts +85 -0
- package/src/dataunit/state/slice/LoadingControlSlice.ts +60 -0
- package/src/dataunit/state/slice/RecordsSlice.ts +74 -0
- package/src/dataunit/state/slice/RemovedRecordsSlice.ts +30 -0
- package/src/dataunit/state/slice/SelectionSlice.ts +193 -0
- package/src/dataunit/state/slice/SnapshotSlice.ts +139 -0
- package/src/dataunit/state/slice/UnitMetadataSlice.ts +30 -0
- package/src/dataunit/state/slice/WaitingChangesSlice.ts +74 -0
- package/src/exceptions/ErrorException.ts +25 -0
- package/src/exceptions/WaitingChangeException.ts +21 -0
- package/src/exceptions/WarningException.ts +26 -0
- package/src/html/HTMLBuilder.ts +8 -0
- package/src/http/AuthorizedServiceCaller.ts +58 -0
- package/src/http/HttpProvider.ts +94 -0
- package/src/http/RequestMetadata.ts +42 -0
- package/src/http/SkwHttpProvider.ts +78 -0
- package/src/index.ts +93 -0
- package/src/traking/ErrorTraking.ts +37 -0
- package/src/ui/FloatingManager.ts +417 -0
- package/src/utils/ApplicationContext.ts +42 -0
- package/src/utils/ArrayUtils.ts +61 -0
- package/src/utils/CriteriaModel.ts +205 -0
- package/src/utils/CriteriaParameter.ts +108 -0
- package/src/utils/DateUtils.ts +195 -0
- package/src/utils/ElementIDUtils.ts +184 -0
- package/src/utils/JSUtils.ts +69 -0
- package/src/utils/MaskFormatter.ts +407 -0
- package/src/utils/NumberUtils.ts +283 -0
- package/src/utils/ObjectUtils.ts +76 -0
- package/src/utils/OnboardingUtils.ts +46 -0
- package/src/utils/ReadyUtil.ts +45 -0
- package/src/utils/StringUtils.ts +359 -0
- package/src/utils/TimeFormatter.ts +98 -0
- package/src/utils/UserAgentUtils/index.ts +62 -0
- package/src/utils/UserAgentUtils/navigatorAgentList.ts +39 -0
- package/src/utils/VersionUtils.ts +37 -0
- package/test/http/HttpProvider.spec.ts +35 -0
- package/test/http/SkwHttpProvider.ts.spec.ts +34 -0
- package/test/util/CriteriaModel.spec.ts +232 -0
- package/test/util/CriteriaParameter.spec.ts +52 -0
- package/test/util/DataUnitStorage.spec.ts +63 -0
- package/test/util/ElementIDUtils.spec.ts +272 -0
- package/test/util/MaskFormatter.spec.ts +138 -0
- package/test/util/NumberUtils.spec.ts +182 -0
- package/test/util/StringUtils.spec.ts +51 -0
- package/test/util/TimeFormatter.spec.ts +26 -0
- package/tsconfig.json +16 -0
package/src/index.ts
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { StringUtils } from "./utils/StringUtils.js";
|
|
2
|
+
import { NumberUtils } from "./utils/NumberUtils.js";
|
|
3
|
+
import { MaskFormatter } from "./utils/MaskFormatter.js";
|
|
4
|
+
import FloatingManager from "./ui/FloatingManager.js";
|
|
5
|
+
import DateUtils from "./utils/DateUtils.js";
|
|
6
|
+
import ArrayUtils from "./utils/ArrayUtils.js";
|
|
7
|
+
import { TimeFormatter } from "./utils/TimeFormatter.js";
|
|
8
|
+
import { HttpProvider } from "./http/HttpProvider.js";
|
|
9
|
+
import { SkwHttpProvider } from "./http/SkwHttpProvider.js";
|
|
10
|
+
import { RequestMetadata } from "./http/RequestMetadata.js";
|
|
11
|
+
import { AuthorizedServiceCaller } from "./http/AuthorizedServiceCaller.js";
|
|
12
|
+
import DataUnit, {SavedRecord, Record, Change, ChangeOperation, DUActionInterceptor, WaitingChange, PageRequest, QuickFilter, SelectionMode, SelectionInfo} from "./dataunit/DataUnit.js";
|
|
13
|
+
import { DataType } from "./dataunit/metadata/DataType.js";
|
|
14
|
+
import { UnitMetadata, FieldDescriptor, UserInterface, Sort, SortMode, SortingProvider, Filter, DependencyType, ChildDescriptor, ChildLink } from "./dataunit/metadata/UnitMetadata.js";
|
|
15
|
+
import { DataUnitAction, Action, ExecutionContext } from "./dataunit/state/action/DataUnitAction.js";
|
|
16
|
+
import ApplicationContext from "./utils/ApplicationContext.js";
|
|
17
|
+
import ReadyUtil from "./utils/ReadyUtil.js";
|
|
18
|
+
import ObjectUtils from "./utils/ObjectUtils.js";
|
|
19
|
+
import WarningException from "./exceptions/WarningException.js";
|
|
20
|
+
import WaitingChangeException from "./exceptions/WaitingChangeException.js";
|
|
21
|
+
import ErrorException from "./exceptions/ErrorException.js";
|
|
22
|
+
import { ErrorTracking } from "./traking/ErrorTraking.js";
|
|
23
|
+
import { PaginationInfo } from "./dataunit/loading/PaginationInfo.js";
|
|
24
|
+
import { LoadDataRequest } from "./dataunit/loading/LoadDataRequest.js";
|
|
25
|
+
import { LoadDataResponse } from "./dataunit/loading/LoadDataResponse.js";
|
|
26
|
+
import { ElementIDUtils, IElementIDInfo } from "./utils/ElementIDUtils.js";
|
|
27
|
+
import { UserAgentUtils } from "./utils/UserAgentUtils/index.js";
|
|
28
|
+
import { JSUtils } from "./utils/JSUtils.js";
|
|
29
|
+
import { DataUnitStorage } from "./dataunit/DataUnitStorage.js";
|
|
30
|
+
import VersionUtils from './utils/VersionUtils.js'
|
|
31
|
+
import { OnboardingUtils} from "./utils/OnboardingUtils.js";
|
|
32
|
+
import {default as PromiseSync, PromiseSyncCallback} from "./async/PromiseSync.js";
|
|
33
|
+
import { HTMLBuilder } from "./html/HTMLBuilder.js";
|
|
34
|
+
|
|
35
|
+
/*Classes públicas no pacote*/
|
|
36
|
+
export {
|
|
37
|
+
StringUtils,
|
|
38
|
+
MaskFormatter,
|
|
39
|
+
NumberUtils,
|
|
40
|
+
FloatingManager,
|
|
41
|
+
DateUtils,
|
|
42
|
+
ArrayUtils,
|
|
43
|
+
TimeFormatter,
|
|
44
|
+
SkwHttpProvider,
|
|
45
|
+
HttpProvider,
|
|
46
|
+
RequestMetadata,
|
|
47
|
+
AuthorizedServiceCaller,
|
|
48
|
+
DataUnit,
|
|
49
|
+
DataUnitStorage,
|
|
50
|
+
Record,
|
|
51
|
+
SavedRecord,
|
|
52
|
+
DataType,
|
|
53
|
+
UnitMetadata,
|
|
54
|
+
FieldDescriptor,
|
|
55
|
+
UserInterface,
|
|
56
|
+
DependencyType,
|
|
57
|
+
ChildDescriptor,
|
|
58
|
+
ChildLink,
|
|
59
|
+
DataUnitAction,
|
|
60
|
+
Action,
|
|
61
|
+
Change,
|
|
62
|
+
Sort,
|
|
63
|
+
Filter,
|
|
64
|
+
ChangeOperation,
|
|
65
|
+
DUActionInterceptor,
|
|
66
|
+
ApplicationContext,
|
|
67
|
+
WaitingChange,
|
|
68
|
+
PageRequest,
|
|
69
|
+
QuickFilter,
|
|
70
|
+
ReadyUtil,
|
|
71
|
+
ObjectUtils,
|
|
72
|
+
WarningException,
|
|
73
|
+
WaitingChangeException,
|
|
74
|
+
ErrorException,
|
|
75
|
+
ErrorTracking,
|
|
76
|
+
ExecutionContext,
|
|
77
|
+
PaginationInfo,
|
|
78
|
+
SortingProvider,
|
|
79
|
+
SortMode,
|
|
80
|
+
LoadDataRequest,
|
|
81
|
+
LoadDataResponse,
|
|
82
|
+
SelectionInfo,
|
|
83
|
+
SelectionMode,
|
|
84
|
+
ElementIDUtils,
|
|
85
|
+
IElementIDInfo,
|
|
86
|
+
UserAgentUtils,
|
|
87
|
+
JSUtils,
|
|
88
|
+
VersionUtils,
|
|
89
|
+
OnboardingUtils,
|
|
90
|
+
PromiseSync,
|
|
91
|
+
PromiseSyncCallback,
|
|
92
|
+
HTMLBuilder
|
|
93
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import ErrorException from "../exceptions/ErrorException.js";
|
|
2
|
+
import WaitingChangeException from "../exceptions/WaitingChangeException.js";
|
|
3
|
+
import WarningException from "../exceptions/WarningException.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* `ErrorTracking`: Handler para processar exceptions lançadas.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export class ErrorTracking {
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
*
|
|
13
|
+
* Inicializa o Rollbar, utilizado para rastreio de erros e análise de logs.
|
|
14
|
+
*
|
|
15
|
+
*/
|
|
16
|
+
public static init(){
|
|
17
|
+
const rollbar = (window as any).Rollbar;
|
|
18
|
+
if(rollbar){
|
|
19
|
+
rollbar.configure({
|
|
20
|
+
checkIgnore: function(isUncaught:boolean, args:Array<any>, payload:any) {
|
|
21
|
+
return args[1] ? ErrorTracking.isInternalException(args[1]) : false;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
*
|
|
29
|
+
* Retorna se o erro é uma exceção interna na aplicação.
|
|
30
|
+
* @param error - Erro que será identificado como exceção interna ou não.
|
|
31
|
+
* @returns - Verdadeiro caso seja uma exceção interna.
|
|
32
|
+
*
|
|
33
|
+
*/
|
|
34
|
+
private static isInternalException(error:any):boolean{
|
|
35
|
+
return (error instanceof ErrorException || error instanceof WaitingChangeException || error instanceof WarningException);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,417 @@
|
|
|
1
|
+
interface FloatingOptions {
|
|
2
|
+
autoClose: boolean;
|
|
3
|
+
top?: string;
|
|
4
|
+
left?: string;
|
|
5
|
+
right?: string;
|
|
6
|
+
bottom?: string;
|
|
7
|
+
innerClickTest?: Function;
|
|
8
|
+
backClickListener?: Function;
|
|
9
|
+
isFixed?: boolean;
|
|
10
|
+
useOverlay?: boolean;
|
|
11
|
+
overlayClassName?: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class FloatingEntry {
|
|
16
|
+
private weakRefParent?: WeakRef<HTMLElement>;
|
|
17
|
+
private weakRefContent?: WeakRef<HTMLElement>;
|
|
18
|
+
private strongRefParent?: HTMLElement;
|
|
19
|
+
private strongRefContent?: HTMLElement;
|
|
20
|
+
public options: FloatingOptions;
|
|
21
|
+
|
|
22
|
+
constructor(parent: HTMLElement, content: HTMLElement, opts: FloatingOptions) {
|
|
23
|
+
try{
|
|
24
|
+
this.weakRefParent = new WeakRef(parent);
|
|
25
|
+
this.weakRefContent = new WeakRef(content);
|
|
26
|
+
} catch(error){
|
|
27
|
+
this.strongRefParent = parent;
|
|
28
|
+
this.strongRefContent = content;
|
|
29
|
+
}
|
|
30
|
+
this.options = opts;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
*
|
|
35
|
+
* Obtém o elemento HTML pai associado ao objeto.
|
|
36
|
+
*
|
|
37
|
+
* @returns - Elemento HTML pai.
|
|
38
|
+
*
|
|
39
|
+
*/
|
|
40
|
+
public get parent():HTMLElement|undefined{
|
|
41
|
+
if(this.weakRefParent){
|
|
42
|
+
return this.weakRefParent.deref();
|
|
43
|
+
}
|
|
44
|
+
return this.strongRefParent
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
*
|
|
49
|
+
* Obtém o elemento HTML de conteúdo associado ao objeto.
|
|
50
|
+
*
|
|
51
|
+
* @returns - Elemento HTML de conteúdo associado.
|
|
52
|
+
*
|
|
53
|
+
*/
|
|
54
|
+
public get content():HTMLElement|undefined{
|
|
55
|
+
if(this.weakRefContent){
|
|
56
|
+
return this.weakRefContent.deref();
|
|
57
|
+
}
|
|
58
|
+
return this.strongRefContent;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* `FloatingManager`: Gerenciador de elementos flutuantes na tela.
|
|
64
|
+
*/
|
|
65
|
+
|
|
66
|
+
export default class FloatingManager {
|
|
67
|
+
public static MODAL_DEFAULT_CLASSNAME = "FloatingManager__modal";
|
|
68
|
+
public static MODAL_ELEMENT_ID = "FloatingManager__overlay";
|
|
69
|
+
public static STYLE_ELEMENT_ID = "FloatingManager__style";
|
|
70
|
+
public static DATA_OLD_ZINDEX_ATTRIBUTE_NAME: string = "data-old-zindex";
|
|
71
|
+
|
|
72
|
+
private static initialized: boolean;
|
|
73
|
+
private static entries: Array<FloatingEntry>;
|
|
74
|
+
private static overlayElements: Array<HTMLElement> = [];
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
*
|
|
79
|
+
* Inicializa a classe FloatingManager.
|
|
80
|
+
*
|
|
81
|
+
*/
|
|
82
|
+
private static init() {
|
|
83
|
+
FloatingManager.entries = [];
|
|
84
|
+
document.addEventListener('mousedown', FloatingManager.handleDocumentEvent);
|
|
85
|
+
document.addEventListener('keydown', FloatingManager.handleKeyboardEvent);
|
|
86
|
+
FloatingManager.initialized = true;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
*
|
|
91
|
+
* Retorna se o elemento clicado possui elementos internos.
|
|
92
|
+
*
|
|
93
|
+
*/
|
|
94
|
+
private static innerClick(container: HTMLElement, node: HTMLElement): boolean {
|
|
95
|
+
if (container.contains(node)) {
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (container.shadowRoot && container.shadowRoot.contains(node)) {
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
*
|
|
108
|
+
* Fecha uma entrada flutuante (FloatingManager).
|
|
109
|
+
*
|
|
110
|
+
* @param id - Código da entrada que se deseja encerrar.
|
|
111
|
+
* @param entry - FloatingManager.
|
|
112
|
+
* @param target - Elemento HTML referente.
|
|
113
|
+
* @param event - Evento específico que será verificado, como clique do mouse.
|
|
114
|
+
*
|
|
115
|
+
*/
|
|
116
|
+
private static doClose(id: number, entry: FloatingEntry, target?: HTMLElement, event?:Event): void {
|
|
117
|
+
if (!target || entry.options.autoClose) {
|
|
118
|
+
const parent: HTMLElement | undefined = entry.parent;
|
|
119
|
+
const content: HTMLElement | undefined = entry.content;
|
|
120
|
+
|
|
121
|
+
if (parent && content) {
|
|
122
|
+
const innerClickFunction: Function = entry.options.innerClickTest ? entry.options.innerClickTest : FloatingManager.innerClick;
|
|
123
|
+
const backClickFunction: Function = entry.options.backClickListener ? entry.options.backClickListener : () => {};
|
|
124
|
+
if (!target || !innerClickFunction(content, target, event)) {
|
|
125
|
+
content.remove();
|
|
126
|
+
delete FloatingManager.entries[id];
|
|
127
|
+
backClickFunction();
|
|
128
|
+
}
|
|
129
|
+
} else {
|
|
130
|
+
delete FloatingManager.entries[id];
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
FloatingManager.hideOverlay();
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
*
|
|
138
|
+
* Fecha todas as FloatingManagers abertas.
|
|
139
|
+
*
|
|
140
|
+
* @param event - Evento ocorrido, como clique do mouse, por exemplo.
|
|
141
|
+
*
|
|
142
|
+
*/
|
|
143
|
+
private static handleDocumentEvent(event: Event): void {
|
|
144
|
+
|
|
145
|
+
FloatingManager.entries.forEach((entry, index) => {
|
|
146
|
+
FloatingManager.doClose(index, entry, event.composedPath()[0] as HTMLElement, event);
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
*
|
|
152
|
+
* Captura eventos de teclado para manipular os elementos flutuantes via eventos da tecla pressionada.
|
|
153
|
+
*
|
|
154
|
+
* @param event - Evento de teclado.
|
|
155
|
+
*
|
|
156
|
+
*/
|
|
157
|
+
private static handleKeyboardEvent(event: KeyboardEvent): void {
|
|
158
|
+
if (event.key === 'Escape') {
|
|
159
|
+
for (let index: number = FloatingManager.entries.length; index >= 0; index--) {
|
|
160
|
+
const entry: FloatingEntry = FloatingManager.entries[index];
|
|
161
|
+
if (entry) {
|
|
162
|
+
FloatingManager.close(index);
|
|
163
|
+
break;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
*
|
|
171
|
+
* Adiciona uma propriedade CSS em um elemento HTML.
|
|
172
|
+
*
|
|
173
|
+
* @param element - Elemento HTML que será modificado.
|
|
174
|
+
* @param propertyName - Nome da propriedade CSS que será adicionada.
|
|
175
|
+
* @param value - Valor da propriedade adicionada.
|
|
176
|
+
*
|
|
177
|
+
*
|
|
178
|
+
*/
|
|
179
|
+
private static applyStyle(element: HTMLElement, propertyName: string, value?: string):void {
|
|
180
|
+
if (value) {
|
|
181
|
+
element.style.setProperty(propertyName, value);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
*
|
|
187
|
+
* Obtém o índice do FloatingManager do Elemento HMTL desejado.
|
|
188
|
+
*
|
|
189
|
+
* @param content - Elemento a ser buscado.
|
|
190
|
+
* @param parent - Elemento pai do content a ser buscado.
|
|
191
|
+
* @returns - Índice do elemento informado.
|
|
192
|
+
*/
|
|
193
|
+
private static getFloatIndex(content: HTMLElement, parent: HTMLElement): number {
|
|
194
|
+
|
|
195
|
+
for (let index: number = 0; index < FloatingManager.entries.length; index++) {
|
|
196
|
+
const entry: FloatingEntry = FloatingManager.entries[index];
|
|
197
|
+
if (entry && content === entry.content && parent === entry.parent) {
|
|
198
|
+
return index;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
return -1;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
*
|
|
206
|
+
* Retorna se uma entrada flutuante existe.
|
|
207
|
+
*
|
|
208
|
+
* @param id - Índice para ser verificado no FloatingManager.
|
|
209
|
+
*
|
|
210
|
+
* @returns - Verdadeiro se existir.
|
|
211
|
+
*
|
|
212
|
+
*/
|
|
213
|
+
public static isFloating(id: number): boolean{
|
|
214
|
+
return FloatingManager.entries[id] !== undefined;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
*
|
|
220
|
+
* Cria e exibe um novo item no FloatingManager.
|
|
221
|
+
*
|
|
222
|
+
* @param content - Elemento HTML que será criado.
|
|
223
|
+
* @param parent - Elemento HTML que será o pai do item a ser criado.
|
|
224
|
+
* @param options - Opções de configuração a serem adicionadas.
|
|
225
|
+
*
|
|
226
|
+
* @returns - ID do novo item criado.
|
|
227
|
+
*/
|
|
228
|
+
public static float(content: HTMLElement, parent: HTMLElement, options: FloatingOptions = { autoClose: true }): number {
|
|
229
|
+
|
|
230
|
+
if (!FloatingManager.initialized) {
|
|
231
|
+
FloatingManager.init();
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
const alreadyFloatingIndex = FloatingManager.getFloatIndex(content, parent);
|
|
235
|
+
|
|
236
|
+
if (alreadyFloatingIndex > -1) {
|
|
237
|
+
return alreadyFloatingIndex;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
content.style.position = options.isFixed ? 'fixed' : 'absolute';
|
|
241
|
+
requestAnimationFrame(()=>{
|
|
242
|
+
FloatingManager.applyStyle(content, "top", options.top);
|
|
243
|
+
FloatingManager.applyStyle(content, "left", options.left);
|
|
244
|
+
FloatingManager.applyStyle(content, "right", options.right);
|
|
245
|
+
FloatingManager.applyStyle(content, "bottom", options.bottom);
|
|
246
|
+
})
|
|
247
|
+
|
|
248
|
+
FloatingManager.showOverlay(options);
|
|
249
|
+
parent.appendChild(content);
|
|
250
|
+
FloatingManager.entries.push(new FloatingEntry(parent, content, options));
|
|
251
|
+
|
|
252
|
+
return FloatingManager.entries.length - 1;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
*
|
|
257
|
+
* Aplica o desfoque na página se o elemento possuir essa option ativada.
|
|
258
|
+
*
|
|
259
|
+
* @param options - Configurações que serão utilizadas no elemento.
|
|
260
|
+
*
|
|
261
|
+
*/
|
|
262
|
+
private static showOverlay(options: FloatingOptions): void{
|
|
263
|
+
if(options.useOverlay){
|
|
264
|
+
this.createOrUpdatOverlay(options.overlayClassName).style.display = "block";
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
*
|
|
270
|
+
* Desfaz o desfoque/overlay dos elementos na tela.
|
|
271
|
+
*
|
|
272
|
+
*
|
|
273
|
+
*/
|
|
274
|
+
private static hideOverlay(){
|
|
275
|
+
|
|
276
|
+
if(FloatingManager.entries.filter(entry => entry.options.useOverlay).length > 0){
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
const overlayElement:HTMLElement|null = document.querySelector(`div#${FloatingManager.MODAL_ELEMENT_ID}`);
|
|
281
|
+
if(overlayElement != undefined){
|
|
282
|
+
overlayElement.style.display = "none";
|
|
283
|
+
}
|
|
284
|
+
const body = document.querySelector("body");
|
|
285
|
+
if(body){
|
|
286
|
+
body.style.overflow = "";
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
*
|
|
292
|
+
* Cria ou atualiza o elemento de sobreposição.
|
|
293
|
+
*
|
|
294
|
+
* @param className - Classe CSS que será adicionada ao modal.
|
|
295
|
+
* @returns - O elemento atualizado.
|
|
296
|
+
*/
|
|
297
|
+
private static createOrUpdatOverlay(className: string = FloatingManager.MODAL_DEFAULT_CLASSNAME):HTMLDivElement{
|
|
298
|
+
let overlayElement: HTMLDivElement = document.querySelector(`div#${FloatingManager.MODAL_ELEMENT_ID}`) as HTMLDivElement;
|
|
299
|
+
const body = document.querySelector("body");
|
|
300
|
+
if(!overlayElement){
|
|
301
|
+
overlayElement = document.createElement("div");
|
|
302
|
+
overlayElement.id = FloatingManager.MODAL_ELEMENT_ID;
|
|
303
|
+
if(body){
|
|
304
|
+
body.appendChild(overlayElement);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
if(className === FloatingManager.MODAL_DEFAULT_CLASSNAME){
|
|
308
|
+
FloatingManager.createStyleElement();
|
|
309
|
+
} else {
|
|
310
|
+
overlayElement.classList.remove(FloatingManager.MODAL_DEFAULT_CLASSNAME);
|
|
311
|
+
}
|
|
312
|
+
if(body){
|
|
313
|
+
body.style.overflow = "hidden";
|
|
314
|
+
}
|
|
315
|
+
overlayElement.className = className;
|
|
316
|
+
return overlayElement;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
*
|
|
321
|
+
* Cria elemento de estilo.
|
|
322
|
+
* Elemento que define o estilo padrão do elemento de sobreposição.
|
|
323
|
+
*/
|
|
324
|
+
private static createStyleElement():void{
|
|
325
|
+
let styleElement:HTMLStyleElement = document.querySelector(`style#${FloatingManager.STYLE_ELEMENT_ID}`) as HTMLStyleElement;
|
|
326
|
+
if(styleElement == undefined){
|
|
327
|
+
styleElement = document.createElement("style");
|
|
328
|
+
styleElement.id = FloatingManager.STYLE_ELEMENT_ID;
|
|
329
|
+
styleElement.appendChild(document.createTextNode(`
|
|
330
|
+
.${FloatingManager.MODAL_DEFAULT_CLASSNAME} {
|
|
331
|
+
position: fixed;
|
|
332
|
+
z-index: 2;
|
|
333
|
+
padding: 0;
|
|
334
|
+
top: 0px;
|
|
335
|
+
left: 0px;
|
|
336
|
+
width: 100%;
|
|
337
|
+
height: 100vh;
|
|
338
|
+
box-sizing: border-box;
|
|
339
|
+
background: rgba(0, 0, 0, 0.1);
|
|
340
|
+
}`));
|
|
341
|
+
const header = document.querySelector("head");
|
|
342
|
+
if(header){
|
|
343
|
+
header.appendChild(styleElement);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
*
|
|
350
|
+
* Atualiza posição de um elemento que já está em tela.
|
|
351
|
+
*
|
|
352
|
+
* @param content - Elemento HTML que será atualizado.
|
|
353
|
+
* @param parent - Elemento pai do content passado.
|
|
354
|
+
* @param options - Novas opções desejadas.
|
|
355
|
+
*/
|
|
356
|
+
public static updateFloatPosition(content: HTMLElement, parent: HTMLElement, options: FloatingOptions = { autoClose: true }) {
|
|
357
|
+
const alreadyFloatingIndex = FloatingManager.getFloatIndex(content, parent);
|
|
358
|
+
if (alreadyFloatingIndex > -1) {
|
|
359
|
+
FloatingManager.applyStyle(content, "top", options.top);
|
|
360
|
+
FloatingManager.applyStyle(content, "left", options.left);
|
|
361
|
+
FloatingManager.applyStyle(content, "right", options.right);
|
|
362
|
+
FloatingManager.applyStyle(content, "bottom", options.bottom);
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
*
|
|
369
|
+
* Fecha elemento flutuante da tela.
|
|
370
|
+
*
|
|
371
|
+
* @param id - Índice do elemento desejado.
|
|
372
|
+
*
|
|
373
|
+
*/
|
|
374
|
+
public static close(id: number) {
|
|
375
|
+
if (FloatingManager.entries[id]) {
|
|
376
|
+
FloatingManager.doClose(id, FloatingManager.entries[id], undefined);
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
/**
|
|
381
|
+
* Controle a sobreposição do elemento
|
|
382
|
+
* @param item - Elemento HTML que será manipulado
|
|
383
|
+
* @returns - O ID do elemento na lista de controle
|
|
384
|
+
*/
|
|
385
|
+
public static subscribeOverlayControl(item: HTMLElement){
|
|
386
|
+
if(!item) return;
|
|
387
|
+
|
|
388
|
+
const currentZIndex = this.getCSSPropertyValue(item, 'z-index') || '';
|
|
389
|
+
const parsedCurrZIndex = isNaN(+currentZIndex) ? 0 : +currentZIndex;
|
|
390
|
+
item.setAttribute(FloatingManager.DATA_OLD_ZINDEX_ATTRIBUTE_NAME, String(parsedCurrZIndex));
|
|
391
|
+
const highestZIndex = this.getHighestZIndex();
|
|
392
|
+
item.style.zIndex = String(highestZIndex ? highestZIndex +1 : +parsedCurrZIndex);
|
|
393
|
+
return this.overlayElements.push(item);
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
*
|
|
398
|
+
* @param identifier - Elemento HTML ou ID do item que será removido do controle de sobreposição
|
|
399
|
+
*/
|
|
400
|
+
public static unsubscribeOverlayControl(identifier: HTMLElement | number){
|
|
401
|
+
if(!identifier) return;
|
|
402
|
+
|
|
403
|
+
let item: HTMLElement = identifier instanceof HTMLElement ? identifier : this.overlayElements[identifier -1];
|
|
404
|
+
|
|
405
|
+
const oldZIndex = item.getAttribute(FloatingManager.DATA_OLD_ZINDEX_ATTRIBUTE_NAME) || '';
|
|
406
|
+
item.setAttribute(FloatingManager.DATA_OLD_ZINDEX_ATTRIBUTE_NAME, oldZIndex);
|
|
407
|
+
this.overlayElements = this.overlayElements.filter(element => element !== item);
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
private static getCSSPropertyValue(element: HTMLElement, property: string){
|
|
411
|
+
return window.getComputedStyle(element).getPropertyValue(property);
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
private static getHighestZIndex(){
|
|
415
|
+
return this.overlayElements.reduce((acc, curr) => acc + Number(this.getCSSPropertyValue(curr, 'z-index') || ''), 0);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { StringUtils } from "./StringUtils.js";
|
|
2
|
+
|
|
3
|
+
/***
|
|
4
|
+
* `ApplicationContext`: Utilizado para manipulação do contexto.
|
|
5
|
+
* - Evitar uso da classe sem alinhamento com a arquitetura devido ao uso de variáveis globais.
|
|
6
|
+
*/
|
|
7
|
+
export default class ApplicationContext{
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Obtém informação específica do contexto.
|
|
11
|
+
*
|
|
12
|
+
* @param key - Chave do contexto desejada.
|
|
13
|
+
* @returns - Informação do contexto desejado.
|
|
14
|
+
*/
|
|
15
|
+
public static getContextValue(key: string):any{
|
|
16
|
+
return ApplicationContext.getCtx()[key];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Aplica informação no contexto.
|
|
21
|
+
*
|
|
22
|
+
* @param key - Identificador do contexto.
|
|
23
|
+
* @param value - Informação a ser inserida no contexto.
|
|
24
|
+
*/
|
|
25
|
+
public static setContextValue(key: string, value: any):any{
|
|
26
|
+
ApplicationContext.getCtx()[key] = value;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Obtém o contexto global da aplicação sankhyacore.
|
|
31
|
+
* - Esse contexto pode ser entendido como um ponto de coesão para atores que não se conhecem poderem trocar informação. Assim, o código x busca por um possível valor no contexto. Se essa informação estiver lá, ele reage de certa forma. O código Y, sabe dessa necessidade mas não consegue passar essa informação diretamente, então atribui o valor ao contexto.
|
|
32
|
+
* @returns - Objeto com as propriedades da variável global ___snkcore___ctx___.
|
|
33
|
+
*/
|
|
34
|
+
private static getCtx():any{
|
|
35
|
+
let ctx = (window as any).___snkcore___ctx___;
|
|
36
|
+
if(!ctx){
|
|
37
|
+
ctx = {};
|
|
38
|
+
(window as any).___snkcore___ctx___ = ctx;
|
|
39
|
+
}
|
|
40
|
+
return ctx;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { StringUtils } from "./StringUtils.js";
|
|
2
|
+
import { NumberUtils } from './NumberUtils.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* `ArrayUtils`: Utilitário com a responsabilidade de manipular Arrays.
|
|
6
|
+
*/
|
|
7
|
+
export default class ArrayUtils {
|
|
8
|
+
/**
|
|
9
|
+
* Filtra um array a partir de um critério textual.
|
|
10
|
+
*
|
|
11
|
+
* @param argument - Texto a ser usado no filtro.
|
|
12
|
+
* @param originalArray - Array no formato original.
|
|
13
|
+
* @param alphabeticalSorting - Determina se o resultado deve ser ordenado ou mantido na ordem original. Por padrão ordena.
|
|
14
|
+
* @param fieldName - Caso o objeto deva ser filtrado por um campo diferente de "label", pode-se usar esse parâmetro.
|
|
15
|
+
* @returns - Um array filtrado e ordenado conforme necessidade..
|
|
16
|
+
*/
|
|
17
|
+
static applyStringFilter(argument: string, originalArray: Array<any>, alphabeticalSorting: boolean = true, fieldName: string = "label"): Array<any>{
|
|
18
|
+
if(!argument){
|
|
19
|
+
return originalArray;
|
|
20
|
+
}
|
|
21
|
+
const normalizedArgument = ArrayUtils.normalizeSearchString(argument);
|
|
22
|
+
const filteredArray = originalArray.filter(item => {
|
|
23
|
+
const itemValue: string = ArrayUtils.normalizeSearchString(item[fieldName]);
|
|
24
|
+
return itemValue.includes(normalizedArgument);
|
|
25
|
+
});
|
|
26
|
+
return alphabeticalSorting ? ArrayUtils.sortAlphabetically(filteredArray, fieldName) : filteredArray;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Converte texto para caixa alta e substitui caracteres acentuados.
|
|
31
|
+
*
|
|
32
|
+
* @param original - Texto a ser convertido.
|
|
33
|
+
* @returns - Texto com as letras acentuadas sem os acentos e em caixa alta.
|
|
34
|
+
*/
|
|
35
|
+
private static normalizeSearchString(original:string ): string{
|
|
36
|
+
return StringUtils.replaceAccentuatedCharsKeepSymbols(original.toUpperCase());
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Ordena valores de um array alfabeticamente.
|
|
41
|
+
*
|
|
42
|
+
* @param originalArray - Array a ser ordenado.
|
|
43
|
+
* @returns - Array ordenado alfabeticamente..
|
|
44
|
+
*/
|
|
45
|
+
static sortAlphabetically(originalArray: Array<any>, fieldName: string = "label"): Array<any>{
|
|
46
|
+
return originalArray.sort((fieldA, fieldB) => {
|
|
47
|
+
|
|
48
|
+
const valueStringA = fieldA[fieldName];
|
|
49
|
+
const valueStringB = fieldB[fieldName];
|
|
50
|
+
|
|
51
|
+
const valueIntA = NumberUtils.stringToNumber(valueStringA);
|
|
52
|
+
const valueIntB = NumberUtils.stringToNumber(valueStringB);
|
|
53
|
+
|
|
54
|
+
if(isNaN(valueIntA) || isNaN(valueIntB)){
|
|
55
|
+
return StringUtils.compare(valueStringA, valueStringB)
|
|
56
|
+
} else {
|
|
57
|
+
return NumberUtils.compare(valueIntA, valueIntB);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|