@sankhyalabs/core 5.20.0-dev.32 → 5.20.0-dev.34

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.
Files changed (46) hide show
  1. package/.docs/classes/Change.md +11 -11
  2. package/.docs/classes/DataUnit.md +158 -130
  3. package/.docs/classes/IDBRepository.md +22 -0
  4. package/.docs/classes/MaskFormatter.md +13 -9
  5. package/.docs/classes/SelectionInfo.md +25 -11
  6. package/.docs/enumerations/ChangeOperation.md +4 -4
  7. package/.docs/enumerations/SelectionMode.md +2 -2
  8. package/.docs/interfaces/DUActionInterceptor.md +1 -1
  9. package/.docs/interfaces/IRepository.md +18 -0
  10. package/.docs/interfaces/LoadDataRequest.md +1 -1
  11. package/.docs/interfaces/PageRequest.md +3 -3
  12. package/.docs/interfaces/QuickFilter.md +3 -3
  13. package/.docs/interfaces/Record.md +4 -4
  14. package/.docs/interfaces/SavedRecord.md +5 -5
  15. package/.docs/interfaces/WaitingChange.md +3 -3
  16. package/.docs/namespaces/MaskFormatter/type-aliases/MaskCharacter.md +1 -1
  17. package/.docs/namespaces/MaskFormatter/variables/MaskCharacter.md +1 -1
  18. package/.docs/type-aliases/DataUnitEventOptions.md +1 -1
  19. package/dist/dataunit/DataUnit.d.ts +6 -3
  20. package/dist/dataunit/DataUnit.js +25 -7
  21. package/dist/dataunit/DataUnit.js.map +1 -1
  22. package/dist/dataunit/formatting/PrettyFormatter.js +1 -1
  23. package/dist/dataunit/formatting/PrettyFormatter.js.map +1 -1
  24. package/dist/dataunit/loading/LoadDataRequest.d.ts +1 -1
  25. package/dist/dataunit/state/slice/SelectionSlice.js +2 -2
  26. package/dist/dataunit/state/slice/SelectionSlice.js.map +1 -1
  27. package/dist/repository/IRepository.d.ts +6 -0
  28. package/dist/repository/indexeddb/IDBRepository.d.ts +1 -0
  29. package/dist/repository/indexeddb/IDBRepository.js +3 -0
  30. package/dist/repository/indexeddb/IDBRepository.js.map +1 -1
  31. package/dist/utils/MaskFormatter.d.ts +2 -1
  32. package/dist/utils/MaskFormatter.js +5 -1
  33. package/dist/utils/MaskFormatter.js.map +1 -1
  34. package/dist/utils/SortingUtils.d.ts +9 -0
  35. package/dist/utils/SortingUtils.js +24 -0
  36. package/dist/utils/SortingUtils.js.map +1 -0
  37. package/package.json +1 -1
  38. package/reports/test-report.xml +74 -74
  39. package/src/dataunit/DataUnit.ts +38 -16
  40. package/src/dataunit/formatting/PrettyFormatter.ts +1 -1
  41. package/src/dataunit/loading/LoadDataRequest.ts +1 -1
  42. package/src/dataunit/state/slice/SelectionSlice.ts +2 -2
  43. package/src/repository/IRepository.ts +7 -0
  44. package/src/repository/indexeddb/IDBRepository.ts +4 -0
  45. package/src/utils/MaskFormatter.ts +5 -1
  46. package/src/utils/SortingUtils.ts +30 -0
@@ -1,73 +1,50 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <unitTest version="1">
3
3
  <file path="/builds/dti/design-system/sankhyacore/test/util/MaskFormatter.spec.ts">
4
- <testCase name="Mask Formatter mask:CPF complete valid" duration="7"/>
4
+ <testCase name="Mask Formatter mask:CPF complete valid" duration="90"/>
5
5
  <testCase name="Mask Formatter mask:CPF complete valid literals" duration="1"/>
6
6
  <testCase name="Mask Formatter mask:CPF incomplete valid" duration="1"/>
7
7
  <testCase name="Mask Formatter mask:CPF incomplete valid placeholder" duration="1"/>
8
8
  <testCase name="Mask Formatter mask:CPF too long valid" duration="1"/>
9
- <testCase name="Mask Formatter mask:CPF invalid for string" duration="124"/>
10
- <testCase name="Mask Formatter mask:CPF invalid for being too long" duration="1"/>
9
+ <testCase name="Mask Formatter mask:CPF invalid for string" duration="209"/>
10
+ <testCase name="Mask Formatter mask:CPF invalid for being too long" duration="0"/>
11
11
  <testCase name="Mask Formatter mask:Licence plate valid uppercase" duration="1"/>
12
- <testCase name="Mask Formatter mask:Licence plate valid lowercase" duration="1"/>
12
+ <testCase name="Mask Formatter mask:Licence plate valid lowercase" duration="72"/>
13
13
  <testCase name="Mask Formatter mask:Licence plate invalid" duration="2"/>
14
- <testCase name="Mask Formatter mask:Licence plate invalid for being too short" duration="0"/>
14
+ <testCase name="Mask Formatter mask:Licence plate invalid for being too short" duration="4"/>
15
15
  <testCase name="Mask Formatter mask:Licence plate invalid for being too short with placeholder" duration="0"/>
16
- <testCase name="Mask Formatter mask:Licence plate invalid" duration="2"/>
16
+ <testCase name="Mask Formatter mask:Licence plate invalid" duration="3"/>
17
17
  <testCase name="Mask Formatter mask:Licence plate with AlphaNumerical Mask" duration="1"/>
18
18
  <testCase name="Mask Formatter mask:Licence plate with AlphaNumerical Mask with placeholder" duration="0"/>
19
19
  <testCase name="Mask Formatter mask:Licence plate invalid" duration="1"/>
20
- <testCase name="Mask Formatter mask:Licence plate with AlphaNumerical Mask" duration="1"/>
21
- <testCase name="Mask Formatter mask:Licence plate with AlphaNumerical Mask with placeholder" duration="0"/>
20
+ <testCase name="Mask Formatter mask:Licence plate with AlphaNumerical Mask" duration="0"/>
21
+ <testCase name="Mask Formatter mask:Licence plate with AlphaNumerical Mask with placeholder" duration="1"/>
22
22
  <testCase name="Mask Formatter mask:Licence plate invalid" duration="1"/>
23
- <testCase name="Mask Formatter mask:Licence plate with AlphaNumerical Mask" duration="1"/>
24
- <testCase name="Mask Formatter mask:Licence plate with AlphaNumerical Mask with placeholder" duration="0"/>
25
- <testCase name="Mask Formatter mask:Licence plate invalid" duration="2"/>
26
- </file>
27
- <file path="/builds/dti/design-system/sankhyacore/test/util/NumberUtils.spec.ts">
28
- <testCase name="StringUtils stringToNumber" duration="89"/>
29
- <testCase name="StringUtils format" duration="202"/>
30
- <testCase name="StringUtils format without formatnumber parameter" duration="1"/>
31
- <testCase name="StringUtils format without formatnumber parameter" duration="3"/>
32
- <testCase name="StringUtils format round number" duration="14"/>
23
+ <testCase name="Mask Formatter mask:Licence plate with AlphaNumerical Mask" duration="0"/>
24
+ <testCase name="Mask Formatter mask:Licence plate with AlphaNumerical Mask with placeholder" duration="1"/>
25
+ <testCase name="Mask Formatter mask:Licence plate invalid" duration="5"/>
33
26
  </file>
34
27
  <file path="/builds/dti/design-system/sankhyacore/test/util/CriteriaModel.spec.ts">
35
- <testCase name="StringUtils it should return the undefined and [] to Criteria Props through new class with empty constructor" duration="72"/>
36
- <testCase name="StringUtils it should modify &quot;expressions&quot; and &quot;parameters&quot; properties through Setters methods" duration="1"/>
37
- <testCase name="StringUtils it should return &quot;expression&quot; and &quot;parameters&quot; setted through constructor method" duration="1"/>
38
- <testCase name="StringUtils it should return a Criteria class with &quot;expression&quot; and &quot;parameters&quot; as needed setted through &quot;append&quot; method" duration="1"/>
39
- <testCase name="StringUtils it should return a Criteria class with &quot;Criteria class&quot; and &quot;parameters&quot; concatenaded as needed setted through &quot;append&quot; method" duration="2"/>
40
- <testCase name="StringUtils it should return undefined as &quot;expression&quot; and &quot;[]&quot; as parameters as we use an empty criteria as first entry in the constructor" duration="1"/>
41
- <testCase name="StringUtils it should return a Criteria class with &quot;Expression&quot; and &quot;parameters&quot; concatenaded as needed setted through &quot;OR&quot; method" duration="1"/>
42
- <testCase name="StringUtils it should return a Criteria class with &quot;Criteria class&quot; and &quot;parameters&quot; concatenaded as needed setted through &quot;OR&quot; method" duration="1"/>
43
- <testCase name="StringUtils it should return a Criteria class with &quot;Criteria class&quot; and &quot;parameters&quot; concatenaded as needed setted through &quot;OR&quot; method" duration="1"/>
44
- <testCase name="StringUtils it should return a Criteria class with &quot;Expression&quot; and &quot;parameters&quot; concatenaded as needed setted through &quot;AND&quot; method" duration="8"/>
45
- <testCase name="StringUtils it should return a Criteria class with &quot;Criteria class&quot; and &quot;parameters&quot; concatenaded as needed setted through &quot;AND&quot; method" duration="1"/>
46
- <testCase name="StringUtils it should return a Criteria class with &quot;Criteria class&quot; and &quot;parameters&quot; concatenaded as needed setted through &quot;AND&quot; method" duration="1"/>
28
+ <testCase name="StringUtils it should return the undefined and [] to Criteria Props through new class with empty constructor" duration="7"/>
29
+ <testCase name="StringUtils it should modify &quot;expressions&quot; and &quot;parameters&quot; properties through Setters methods" duration="96"/>
30
+ <testCase name="StringUtils it should return &quot;expression&quot; and &quot;parameters&quot; setted through constructor method" duration="4"/>
31
+ <testCase name="StringUtils it should return a Criteria class with &quot;expression&quot; and &quot;parameters&quot; as needed setted through &quot;append&quot; method" duration="82"/>
32
+ <testCase name="StringUtils it should return a Criteria class with &quot;Criteria class&quot; and &quot;parameters&quot; concatenaded as needed setted through &quot;append&quot; method" duration="3"/>
33
+ <testCase name="StringUtils it should return undefined as &quot;expression&quot; and &quot;[]&quot; as parameters as we use an empty criteria as first entry in the constructor" duration="2"/>
34
+ <testCase name="StringUtils it should return a Criteria class with &quot;Expression&quot; and &quot;parameters&quot; concatenaded as needed setted through &quot;OR&quot; method" duration="5"/>
35
+ <testCase name="StringUtils it should return a Criteria class with &quot;Criteria class&quot; and &quot;parameters&quot; concatenaded as needed setted through &quot;OR&quot; method" duration="4"/>
36
+ <testCase name="StringUtils it should return a Criteria class with &quot;Criteria class&quot; and &quot;parameters&quot; concatenaded as needed setted through &quot;OR&quot; method" duration="5"/>
37
+ <testCase name="StringUtils it should return a Criteria class with &quot;Expression&quot; and &quot;parameters&quot; concatenaded as needed setted through &quot;AND&quot; method" duration="3"/>
38
+ <testCase name="StringUtils it should return a Criteria class with &quot;Criteria class&quot; and &quot;parameters&quot; concatenaded as needed setted through &quot;AND&quot; method" duration="6"/>
39
+ <testCase name="StringUtils it should return a Criteria class with &quot;Criteria class&quot; and &quot;parameters&quot; concatenaded as needed setted through &quot;AND&quot; method" duration="20"/>
47
40
  <testCase name="StringUtils it should return a toJSON object with &quot;Criteria class&quot; and &quot;parameters&quot; concatenaded as needed setted through &quot;AND&quot; method" duration="1"/>
48
- <testCase name="StringUtils it should return a toJSON object with through empty constructor" duration="0"/>
41
+ <testCase name="StringUtils it should return a toJSON object with through empty constructor" duration="1"/>
49
42
  </file>
50
43
  <file path="/builds/dti/design-system/sankhyacore/test/http/HttpProvider.spec.ts">
51
44
  <testCase name="HttpProvider Metodo GET" duration="1"/>
52
45
  </file>
53
- <file path="/builds/dti/design-system/sankhyacore/test/util/OverflowWatcher.spec.ts">
54
- <testCase name="OverflowWatcher should initialize with provided parameters" duration="10"/>
55
- <testCase name="OverflowWatcher should disconect ResizeObserver when destroy is called" duration="2"/>
56
- <testCase name="OverflowWatcher Should call callback on forceUpdate" duration="198"/>
57
- <testCase name="OverflowWatcher Should call callback on forceUpdate with childSpan" duration="97"/>
58
- <testCase name="OverflowWatcher Should call callback on forceUpdate with childSpan when notOverFlow is empty" duration="87"/>
59
- <testCase name="OverflowWatcher Should call callback on forceUpdate with childSpan considering overflowed elements" duration="7"/>
60
- <testCase name="OverflowWatcher Should call callback on forceUpdate with empty list" duration="4"/>
61
- <testCase name="OverflowWatcher should ignore elements that can not overflow" duration="11"/>
62
- <testCase name="OverflowWatcher Should not call callback on forceUpdate" duration="3"/>
63
- </file>
64
46
  <file path="/builds/dti/design-system/sankhyacore/test/http/SkwHttpProvider.ts.spec.ts">
65
- <testCase name="HttpProvider Metodo POST" duration="0"/>
66
- </file>
67
- <file path="/builds/dti/design-system/sankhyacore/test/util/CriteriaParameter.spec.ts">
68
- <testCase name="StringUtils it should return the correct values of &quot;value&quot; and &quot;type&quot; through the getters methods initial setted by the constructor" duration="2"/>
69
- <testCase name="StringUtils it should return the correct values of &quot;value&quot; and &quot;type&quot; through the getters methods initial setted by the setters methods" duration="0"/>
70
- <testCase name="StringUtils it should return the correct JSON/Object value through the buildParam method" duration="1"/>
47
+ <testCase name="HttpProvider Metodo POST" duration="1"/>
71
48
  </file>
72
49
  <file path="/builds/dti/design-system/sankhyacore/test/util/StringUtils.spec.ts">
73
50
  <testCase name="StringUtils valor vazio" duration="1"/>
@@ -78,18 +55,41 @@
78
55
  <testCase name="StringUtils com valor" duration="1"/>
79
56
  <testCase name="StringUtils substitui vogais com acento por vogais sem acento" duration="1"/>
80
57
  <testCase name="StringUtils should return the original value when called with an object without a toString method" duration="2"/>
81
- <testCase name="StringUtils should return the original value when called with undefined" duration="1"/>
58
+ <testCase name="StringUtils should return the original value when called with undefined" duration="0"/>
59
+ </file>
60
+ <file path="/builds/dti/design-system/sankhyacore/test/util/CriteriaParameter.spec.ts">
61
+ <testCase name="StringUtils it should return the correct values of &quot;value&quot; and &quot;type&quot; through the getters methods initial setted by the constructor" duration="1"/>
62
+ <testCase name="StringUtils it should return the correct values of &quot;value&quot; and &quot;type&quot; through the getters methods initial setted by the setters methods" duration="1"/>
63
+ <testCase name="StringUtils it should return the correct JSON/Object value through the buildParam method" duration="0"/>
64
+ </file>
65
+ <file path="/builds/dti/design-system/sankhyacore/test/util/NumberUtils.spec.ts">
66
+ <testCase name="StringUtils stringToNumber" duration="92"/>
67
+ <testCase name="StringUtils format" duration="94"/>
68
+ <testCase name="StringUtils format without formatnumber parameter" duration="1"/>
69
+ <testCase name="StringUtils format without formatnumber parameter" duration="2"/>
70
+ <testCase name="StringUtils format round number" duration="1"/>
71
+ </file>
72
+ <file path="/builds/dti/design-system/sankhyacore/test/util/OverflowWatcher.spec.ts">
73
+ <testCase name="OverflowWatcher should initialize with provided parameters" duration="119"/>
74
+ <testCase name="OverflowWatcher should disconect ResizeObserver when destroy is called" duration="1"/>
75
+ <testCase name="OverflowWatcher Should call callback on forceUpdate" duration="588"/>
76
+ <testCase name="OverflowWatcher Should call callback on forceUpdate with childSpan" duration="104"/>
77
+ <testCase name="OverflowWatcher Should call callback on forceUpdate with childSpan when notOverFlow is empty" duration="91"/>
78
+ <testCase name="OverflowWatcher Should call callback on forceUpdate with childSpan considering overflowed elements" duration="7"/>
79
+ <testCase name="OverflowWatcher Should call callback on forceUpdate with empty list" duration="4"/>
80
+ <testCase name="OverflowWatcher should ignore elements that can not overflow" duration="97"/>
81
+ <testCase name="OverflowWatcher Should not call callback on forceUpdate" duration="1"/>
82
82
  </file>
83
83
  <file path="/builds/dti/design-system/sankhyacore/test/util/TimeFormatter.spec.ts">
84
- <testCase name="TimeFormatter Case: input string unformated with showSeconds" duration="1"/>
85
- <testCase name="TimeFormatter Case: input string unformated without showSeconds" duration="0"/>
84
+ <testCase name="TimeFormatter Case: input string unformated with showSeconds" duration="2"/>
85
+ <testCase name="TimeFormatter Case: input string unformated without showSeconds" duration="1"/>
86
86
  <testCase name="TimeFormatter Case: validateTime" duration="1"/>
87
87
  </file>
88
88
  <file path="/builds/dti/design-system/sankhyacore/test/util/DataUnitStorage.spec.ts">
89
- <testCase name="DataUnitStorage put should store a DataUnit instance in the DataUnitStorage" duration="52"/>
89
+ <testCase name="DataUnitStorage put should store a DataUnit instance in the DataUnitStorage" duration="23"/>
90
90
  <testCase name="DataUnitStorage get should return the stored DataUnit instance from the DataUnitStorage" duration="1"/>
91
91
  <testCase name="DataUnitStorage get should return undefined if the DataUnit instance is not found in the DataUnitStorage" duration="1"/>
92
- <testCase name="DataUnitStorage remove should remove the specified DataUnit instance from the DataUnitStorage" duration="0"/>
92
+ <testCase name="DataUnitStorage remove should remove the specified DataUnit instance from the DataUnitStorage" duration="1"/>
93
93
  <testCase name="DataUnitStorage remove should remove the DataUnit instance with the specified name from the DataUnitStorage" duration="1"/>
94
94
  <testCase name="DataUnitStorage remove should not remove any DataUnit instance if the specified DataUnit instance or name is not found in the DataUnitStorage" duration="1"/>
95
95
  </file>
@@ -98,34 +98,34 @@
98
98
  <testCase name="addIDInfo 2 - should add data-element-id with valid id &quot;brComSankhyaFinCadMovimentacaofinanceira_snkApplication&quot;" duration="2"/>
99
99
  <testCase name="addIDInfo 3 - should add data-element-id with valid id &quot;movFinanceira_br.com.sankhya.fin.cad.movimentacaoFinanceira&quot;" duration="1"/>
100
100
  <testCase name="addIDInfo 4 - should add data-element-id with valid id &quot;meuID2_snkApplication&quot;" duration="1"/>
101
- <testCase name="addIDInfo 5 - should add data-element-id with valid id &quot;movFinanceira_snkApplication&quot;" duration="1"/>
102
- <testCase name="addIDInfo 6 - should add data-element-id with valid id &quot;movFinanceira_snkApplication&quot;" duration="2"/>
101
+ <testCase name="addIDInfo 5 - should add data-element-id with valid id &quot;movFinanceira_snkApplication&quot;" duration="2"/>
102
+ <testCase name="addIDInfo 6 - should add data-element-id with valid id &quot;movFinanceira_snkApplication&quot;" duration="1"/>
103
103
  <testCase name="addIDInfo 7 - should add data-element-id with valid id &quot;componenteNameTest_snkApplication&quot;" duration="1"/>
104
104
  <testCase name="addIDInfo 8 - should add data-element-id with valid id &quot;componentLabel_snkApplication&quot;" duration="1"/>
105
105
  <testCase name="addIDInfo 9 - should add data-element-id with valid id &quot;dataunitFinanceiro_br.com.sankhya.fin.cad.movimentacaoFinanceira&quot;" duration="2"/>
106
- <testCase name="addIDInfo 10 - should add data-element-id with valid id &quot;dataunitFinanceiro_meuIDTeste_br.com.sankhya.fin.cad.movimentacaoFinanceira&quot;" duration="67"/>
107
- <testCase name="addIDInfo 11 - should add data-element-id with valid id &quot;dataunitFinanceiro_meuIDTeste_movimentacaoFinanceira&quot;" duration="2"/>
108
- <testCase name="addIDInfo 12 - should add data-element-id with valid id &quot;dataunitFinanceiro_movFinanceira_movimentacaoFinanceira&quot;" duration="2"/>
106
+ <testCase name="addIDInfo 10 - should add data-element-id with valid id &quot;dataunitFinanceiro_meuIDTeste_br.com.sankhya.fin.cad.movimentacaoFinanceira&quot;" duration="1"/>
107
+ <testCase name="addIDInfo 11 - should add data-element-id with valid id &quot;dataunitFinanceiro_meuIDTeste_movimentacaoFinanceira&quot;" duration="1"/>
108
+ <testCase name="addIDInfo 12 - should add data-element-id with valid id &quot;dataunitFinanceiro_movFinanceira_movimentacaoFinanceira&quot;" duration="1"/>
109
109
  <testCase name="addIDInfo 13 - should add data-element-id with valid id &quot;dataunitFinanceiro_meuIDTeste_movimentacaoFinanceira&quot;" duration="1"/>
110
- <testCase name="addIDInfo 14 - should add data-element-id with valid id &quot;dataunitFinanceiro_meuIdTeste_movimentacaoFinanceira&quot;" duration="3"/>
110
+ <testCase name="addIDInfo 14 - should add data-element-id with valid id &quot;dataunitFinanceiro_meuIdTeste_movimentacaoFinanceira&quot;" duration="8"/>
111
111
  <testCase name="addIDInfo 15 - should add data-element-id with valid id &quot;dataunitFinanceiro_meuIdTeste_snkApplication&quot;" duration="1"/>
112
- <testCase name="addIDInfo 16 - should add data-element-id with valid id &quot;dataunitFinanceiro_meuIdTeste_snkApplication&quot;" duration="6"/>
112
+ <testCase name="addIDInfo 16 - should add data-element-id with valid id &quot;dataunitFinanceiro_meuIdTeste_snkApplication&quot;" duration="1"/>
113
113
  <testCase name="addIDInfo 17 - should add data-element-id with valid id &quot;movFinanceira_movimentacaoFinanceira&quot;" duration="1"/>
114
- <testCase name="addIDInfo 18 - should add data-element-id with valid id &quot;movFinanceira_movimentacaoFinanceira&quot;" duration="0"/>
115
- <testCase name="addIDInfo 19 - should add data-element-id with valid id &quot;movFinanceira_movimentacaoFinanceira&quot;" duration="0"/>
114
+ <testCase name="addIDInfo 18 - should add data-element-id with valid id &quot;movFinanceira_movimentacaoFinanceira&quot;" duration="1"/>
115
+ <testCase name="addIDInfo 19 - should add data-element-id with valid id &quot;movFinanceira_movimentacaoFinanceira&quot;" duration="57"/>
116
116
  <testCase name="addIDInfo 20 - should add data-element-id with valid id &quot;movFinanceira_movimentacaoFinanceira&quot;" duration="1"/>
117
117
  <testCase name="addIDInfo 21 - should add data-element-id with valid id &quot;movFinanceira_movimentacaoFinanceira&quot;" duration="1"/>
118
118
  <testCase name="addIDInfo 22 - should add data-element-id with valid id &quot;bancoObrigatorio_movimentacaoFinanceira&quot;" duration="1"/>
119
119
  </file>
120
120
  <file path="/builds/dti/design-system/sankhyacore/test/util/ElementUtils.spec.ts">
121
- <testCase name="calcMarginSize should calculate correctly the size of horizontal margin" duration="40"/>
122
- <testCase name="calcMarginSize should calculate correctly the size of vertical margin" duration="1"/>
123
- <testCase name="calcMarginSize should threat values defined as zero" duration="3"/>
121
+ <testCase name="calcMarginSize should calculate correctly the size of horizontal margin" duration="168"/>
122
+ <testCase name="calcMarginSize should calculate correctly the size of vertical margin" duration="3"/>
123
+ <testCase name="calcMarginSize should threat values defined as zero" duration="4"/>
124
124
  </file>
125
125
  <file path="/builds/dti/design-system/sankhyacore/test/dataunit/formatting/PrettyFormatter.spec.ts">
126
126
  <testCase name="getFormattedValue should return empty string when value is null" duration="5"/>
127
- <testCase name="getFormattedValue should return empty string when value is not an array" duration="0"/>
128
- <testCase name="getFormattedValue should return empty string when value is an empty array" duration="1"/>
127
+ <testCase name="getFormattedValue should return empty string when value is not an array" duration="1"/>
128
+ <testCase name="getFormattedValue should return empty string when value is an empty array" duration="0"/>
129
129
  <testCase name="getFormattedValue should return file name when value is an array with one file object" duration="0"/>
130
130
  <testCase name="getFormattedValue should return file count when value is an array with multiple file objects" duration="1"/>
131
131
  <testCase name="getFormattedValue should return empty string for undefined file" duration="0"/>
@@ -134,18 +134,18 @@
134
134
  <testCase name="getFormattedValue should return value as string when value is not an object" duration="1"/>
135
135
  <testCase name="getFormattedValue should return value.toString() when value is an object without value property" duration="0"/>
136
136
  <testCase name="getFormattedValue should handle BOOLEAN type" duration="1"/>
137
- <testCase name="getFormattedValue should format numbers correctly" duration="15"/>
138
- <testCase name="getFormattedValue should format dates correctly" duration="5"/>
137
+ <testCase name="getFormattedValue should format numbers correctly" duration="16"/>
138
+ <testCase name="getFormattedValue should format dates correctly" duration="61"/>
139
139
  <testCase name="getFormattedValue should format times correctly" duration="1"/>
140
140
  <testCase name="getFormattedValue should format datetime correctly" duration="1"/>
141
- <testCase name="getFormattedValue should call toString with correct parameters" duration="0"/>
141
+ <testCase name="getFormattedValue should call toString with correct parameters" duration="1"/>
142
142
  <testCase name="getFormattedValue should handle undefined descriptor gracefully" duration="0"/>
143
- <testCase name="getFormattedValue should format value correctly with OPTIONSELECTOR and matching option" duration="1"/>
143
+ <testCase name="getFormattedValue should format value correctly with OPTIONSELECTOR and matching option" duration="0"/>
144
144
  <testCase name="getFormattedValue should return value with OPTIONSELECTOR and no matching option" duration="0"/>
145
145
  <testCase name="getFormattedValue should format value correctly with OPTIONSELECTOR and value as object" duration="0"/>
146
- <testCase name="getFormattedValue should return empty string with OPTIONSELECTOR and value as null" duration="1"/>
147
- <testCase name="getFormattedValue should format value correctly with OPTIONSELECTOR and options as JSON string" duration="0"/>
146
+ <testCase name="getFormattedValue should return empty string with OPTIONSELECTOR and value as null" duration="0"/>
147
+ <testCase name="getFormattedValue should format value correctly with OPTIONSELECTOR and options as JSON string" duration="1"/>
148
148
  <testCase name="getFormattedValue should return value with OPTIONSELECTOR and options as empty array" duration="0"/>
149
- <testCase name="getFormattedValue should format masked values correctly" duration="2"/>
149
+ <testCase name="getFormattedValue should format masked values correctly" duration="1"/>
150
150
  </file>
151
151
  </unitTest>
@@ -26,6 +26,7 @@ import { v4 as uuid } from "uuid";
26
26
  import { DataUnitStorage } from "./DataUnitStorage.js";
27
27
  import { getInvalidFieldMessage, InvalidFieldsReducer } from "./state/slice/InvalidFieldsSlice.js";
28
28
  import { getLoadingProperties, LoadingPropertiesReducer } from "./state/slice/LoadingProperties.js";
29
+ import SortingUtils from "../utils/SortingUtils.js";
29
30
 
30
31
  /***
31
32
  * `DataUnit`: Atua como uma camada de abstração entre o back-end e a interface do usuário.
@@ -33,6 +34,7 @@ import { getLoadingProperties, LoadingPropertiesReducer } from "./state/slice/Lo
33
34
  export default class DataUnit {
34
35
 
35
36
  public static CHANGING_PAGE_LOADING_SOURCE = "CHANGING_PAGE_LOADING_SOURCE";
37
+ public static ALL_RECORDS_SELECTION_SOURCE = "ALL_RECORDS_SELECTION_SOURCE";
36
38
  public static DEFAULT_DATAUNIT_NAME = "dataunit";
37
39
 
38
40
  private _uuid: string;
@@ -55,6 +57,7 @@ export default class DataUnit {
55
57
  public saveLoader?: (dataUnit: DataUnit, changes: Array<Change>) => Promise<Array<SavedRecord>>;
56
58
  public removeLoader?: (dataUnit: DataUnit, recordIds: Array<string>) => Promise<Array<string>>;
57
59
  public recordLoader?: (dataUnit: DataUnit, recordIds: Array<string>) => Promise<Array<Record>>;
60
+ public allRecordsLoader?: (dataUnit: DataUnit) => Array<Record> | undefined;
58
61
 
59
62
  constructor(name: string = DataUnit.DEFAULT_DATAUNIT_NAME, parentDataUnit?: DataUnit) {
60
63
  this._uuid = uuid()
@@ -550,8 +553,8 @@ export default class DataUnit {
550
553
  if(selection.isAllRecords()){
551
554
  throw new Error("Exclusão remota não implementada.");
552
555
  }
553
- const records = selection?.records || [];
554
- const recordIds = selection?.recordIds || [];
556
+ const records = selection?.records as Array<Record> || [];
557
+ const recordIds = selection?.recordIds as Array<string> || [];
555
558
  return this.removeRecords(recordIds, records, buffered, undefined, silent);
556
559
  }
557
560
  return Promise.resolve([]);
@@ -653,13 +656,13 @@ export default class DataUnit {
653
656
  */
654
657
  public getFormattedValue(fieldName: string, value?: any): string {
655
658
  const descriptor = this.getField(fieldName);
656
- if (value === undefined) {
659
+ if (value == undefined) {
657
660
  value = this.getFieldValue(fieldName);
658
661
  } else if (typeof value === "string" && descriptor?.dataType != DataType.TEXT){
659
662
  value = this.valueFromString(fieldName, value);
660
663
  }
661
664
 
662
- if(value === undefined){
665
+ if(value == undefined){
663
666
  return "";
664
667
  }
665
668
 
@@ -887,8 +890,12 @@ export default class DataUnit {
887
890
  public copySelected(executionCtx?: ExecutionContext): void {
888
891
  const selectionInfo = this.getSelectionInfo();
889
892
  if (selectionInfo) {
890
- const selectedRecords = selectionInfo.records;
893
+ if(selectionInfo.isAllRecords()){
894
+ throw new Error("Erro interno: Impossível copiar os registros selecionados pois a seleção atual é virtual.");
895
+ }
896
+ const selectedRecords = selectionInfo.records as Array<Record>;
891
897
  if(selectedRecords){
898
+
892
899
  this.dispatchAction(Action.RECORDS_COPIED, prepareCopiedRecord(this._stateManager, selectedRecords, this.getParentRecordId()), executionCtx);
893
900
  }
894
901
  }
@@ -1104,7 +1111,7 @@ export default class DataUnit {
1104
1111
  public setSelection(selection: Array<string> | SelectionMode.ALL_RECORDS, executionCtx?: ExecutionContext): Promise<SelectionInfo> {
1105
1112
  return new Promise(resolve => {
1106
1113
  this.dispatchAction(Action.SELECTION_CHANGED, { type: "id", selection }, executionCtx)
1107
- .then(()=>resolve(getSelectionInfo(this._stateManager)));
1114
+ .then(()=>resolve(this.getSelectionInfo()));
1108
1115
  });
1109
1116
  }
1110
1117
 
@@ -1161,8 +1168,16 @@ export default class DataUnit {
1161
1168
  * @returns - Objeto com informações como registros selecionados e seleção por critério.
1162
1169
  *
1163
1170
  **/
1164
- public getSelectionInfo(): SelectionInfo | undefined {
1165
- return getSelectionInfo(this._stateManager)
1171
+ public getSelectionInfo(): SelectionInfo{
1172
+ const selectionInfo: SelectionInfo = getSelectionInfo(this._stateManager);
1173
+ selectionInfo.getAllRecords = () => this.allRecordsLoader?.(this);
1174
+
1175
+ if (selectionInfo.sort != undefined && selectionInfo.sort.length > 0) {
1176
+ const sortingFunction = SortingUtils.getSortingFunction(this, selectionInfo.sort)
1177
+ selectionInfo.records?.sort(sortingFunction)
1178
+ }
1179
+
1180
+ return selectionInfo;
1166
1181
  }
1167
1182
 
1168
1183
  /**
@@ -1728,7 +1743,7 @@ export default class DataUnit {
1728
1743
  }
1729
1744
 
1730
1745
  if (selection) {
1731
- return selection.records;
1746
+ return selection.records as Array<Record>;
1732
1747
  }
1733
1748
  }
1734
1749
 
@@ -1746,12 +1761,15 @@ export default class DataUnit {
1746
1761
  public getSelection(): Array<string> {
1747
1762
  console.warn("DataUnit: O método `getSelection` foi descontinuado. Use o método `getSelectionInfo`.");
1748
1763
  const selection = this.getSelectionInfo();
1764
+ if(selection == undefined){
1765
+ return [];
1766
+ }
1749
1767
 
1750
- if(selection != undefined && selection.isAllRecords()){
1768
+ if(selection.isAllRecords()){
1751
1769
  throw new Error("Erro interno: Impossível retornar os registros selecionados. A seleção atual é virtual. Use o método `getSelectionInfo`.");
1752
1770
  }
1753
1771
 
1754
- return selection?.recordIds || [];
1772
+ return selection?.recordIds as Array<string>;
1755
1773
  }
1756
1774
 
1757
1775
  /**
@@ -1932,12 +1950,13 @@ export enum SelectionMode{
1932
1950
 
1933
1951
  export class SelectionInfo{
1934
1952
 
1935
- private _records: Array<Record>;
1936
1953
  public mode: SelectionMode;
1937
- private _total?: number;
1938
1954
  public filters?: Array<Filter>;
1939
1955
  public sort?: Array<Sort>;
1940
-
1956
+ public getAllRecords?: () => Array<Record> | undefined;
1957
+ private _records: Array<Record>;
1958
+ private _total?: number;
1959
+
1941
1960
  constructor(records: Array<Record>, mode: SelectionMode = SelectionMode.SOME_RECORDS, total?:number, filters?: Array<Filter>, sort?: Array<Sort>){
1942
1961
  this._records = records;
1943
1962
  this._total = total;
@@ -1948,7 +1967,10 @@ export class SelectionInfo{
1948
1967
 
1949
1968
  public get records(): Array<Record> | undefined{
1950
1969
  if(this.isAllRecords()){
1951
- throw new Error("Erro interno: [ALL_RECORDS] - Impossível retornar os registros selecionados numa seleção virtual.")
1970
+ if(this.getAllRecords != undefined){
1971
+ return this.getAllRecords();
1972
+ }
1973
+ throw new Error("Erro interno: Impossível retornar os registros selecionados numa seleção virtual.");
1952
1974
  }
1953
1975
  return this._records;
1954
1976
  }
@@ -1967,7 +1989,7 @@ export class SelectionInfo{
1967
1989
  if(this.isAllRecords()){
1968
1990
  return this._total || 0;
1969
1991
  }
1970
- return this.records == undefined ? 0: this.records.length;
1992
+ return this.records == undefined ? 0 : (this.records as Array<Record>).length;
1971
1993
  }
1972
1994
 
1973
1995
  public isAllRecords(): boolean{
@@ -43,7 +43,7 @@ export const getFormattedValue = (value: any, descriptor?: FieldDescriptor) => {
43
43
  const mask = getMask(value, descriptor);
44
44
  if(mask != undefined){
45
45
  try{
46
- return new MaskFormatter(mask).format(value);
46
+ return new MaskFormatter(mask).format(value, true);
47
47
  } catch(error){
48
48
  console.warn(`Erro ao formatar valor: ${value}. Mascara: ${mask}. Erro: ${error}`);
49
49
  }
@@ -4,7 +4,7 @@ import { Filter, Sort } from "../metadata/UnitMetadata.js";
4
4
  /** Atributos enviados na requisição de carregamento dos registros */
5
5
  export interface LoadDataRequest {
6
6
  /** De onde partiu o refresh. Por padrão a fonte não é identificada */
7
- source?: String;
7
+ source?: string;
8
8
 
9
9
  /** Indice inicial dos registros que será retornado */
10
10
  offset?: number;
@@ -94,8 +94,8 @@ export const getSelection = (stateManager: StateManager): Array<string> => {
94
94
  export const getSelectionInfo = (stateManager: StateManager): SelectionInfo => {
95
95
 
96
96
  const selection = getSelectionState(stateManager);
97
+ const currentRequest = getCurrentRequest(stateManager);
97
98
  if(selection && selection.mode === SelectionMode.ALL_RECORDS){
98
- const currentRequest = getCurrentRequest(stateManager);
99
99
  const paginationInfo: PaginationInfo | undefined = getPaginationInfo(stateManager);
100
100
  return new SelectionInfo(
101
101
  [],
@@ -106,7 +106,7 @@ export const getSelectionInfo = (stateManager: StateManager): SelectionInfo => {
106
106
  );
107
107
  }
108
108
 
109
- return new SelectionInfo(getSelectionRecords(stateManager) || [], SelectionMode.SOME_RECORDS, undefined);
109
+ return new SelectionInfo(getSelectionRecords(stateManager) || [], SelectionMode.SOME_RECORDS, undefined, undefined, currentRequest?.sort);
110
110
  }
111
111
 
112
112
  export const hasNext = (stateManager: StateManager): boolean => {
@@ -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
  /**
@@ -96,9 +96,13 @@ export class MaskFormatter {
96
96
  * Formata a string passada baseada na máscara definda pelo atributo mask.
97
97
  *
98
98
  * @param value Valor a ser formatado.
99
+ * @param trimBefore Executa um trim para remover espaços em branco.
99
100
  * @return O valor processado de acordo com o padrão.
100
101
  */
101
- public format(value: string): string {
102
+ public format(value: string, trimBefore: boolean = false): string {
103
+ if(trimBefore){
104
+ value = value.trim();
105
+ }
102
106
  let result: string = '';
103
107
  const index: Array<number> = [0];
104
108
 
@@ -0,0 +1,30 @@
1
+ import DataUnit from "../dataunit/DataUnit.js";
2
+ import { FieldDescriptor, Sort, SortMode } from "../dataunit/metadata/UnitMetadata.js";
3
+ import { FieldComparator } from "../dataunit/sorting/FieldComparator.js";
4
+ import { Record } from '../dataunit/DataUnit.js';
5
+
6
+ /**
7
+ * `SortingUtils`: Utilizado para auxiliar na ordenacao de registros.
8
+ */
9
+ export default class SortingUtils {
10
+
11
+ public static getSortingFunction(dataUnit: DataUnit, sorting?: Array<Sort>): ((recordA: Record, recordB: Record) => number) | undefined {
12
+
13
+ if (sorting == undefined || sorting.length == 0) {
14
+ return undefined;
15
+ }
16
+
17
+ return (recordA, recordB) => {
18
+ for (const sort of sorting) {
19
+ if (sort.field){
20
+ const result = FieldComparator.compare(dataUnit.getField(sort.field) as FieldDescriptor, recordA, recordB, sort.mode === SortMode.ASC);
21
+ if (result != 0) {
22
+ return result;
23
+ }
24
+ }
25
+ }
26
+ return 0;
27
+ };
28
+ }
29
+
30
+ }