@sankhyalabs/core 5.20.0-dev.4 → 5.20.0-dev.40

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 (163) hide show
  1. package/.docs/README.md +3 -1
  2. package/.docs/classes/ApplicationContext.md +31 -32
  3. package/.docs/classes/ArrayUtils.md +95 -83
  4. package/.docs/classes/AuthorizedServiceCaller.md +25 -34
  5. package/.docs/classes/Change.md +59 -74
  6. package/.docs/classes/DataUnit.md +1110 -1086
  7. package/.docs/classes/DataUnitAction.md +25 -42
  8. package/.docs/classes/DataUnitStorage.md +40 -43
  9. package/.docs/classes/DateUtils.md +133 -126
  10. package/.docs/classes/ElementIDUtils.md +123 -122
  11. package/.docs/classes/ErrorException.md +67 -88
  12. package/.docs/classes/ErrorTracking.md +20 -23
  13. package/.docs/classes/FieldComparator.md +35 -39
  14. package/.docs/classes/FloatingManager.md +195 -198
  15. package/.docs/classes/HTMLBuilder.md +14 -20
  16. package/.docs/classes/HttpProvider.md +45 -41
  17. package/.docs/classes/IDBRepository.md +201 -196
  18. package/.docs/classes/JSUtils.md +65 -66
  19. package/.docs/classes/KeyboardManager.md +95 -87
  20. package/.docs/classes/{MaskFormatter-1.md → MaskFormatter.md} +93 -128
  21. package/.docs/classes/NumberUtils.md +163 -152
  22. package/.docs/classes/ObjectUtils.md +206 -70
  23. package/.docs/classes/OnboardingUtils.md +36 -51
  24. package/.docs/classes/OverflowWatcher.md +533 -0
  25. package/.docs/classes/PromiseSync.md +25 -42
  26. package/.docs/classes/ReadyUtil.md +31 -41
  27. package/.docs/classes/RequestMetadata.md +29 -30
  28. package/.docs/classes/SearchUtils.md +18 -20
  29. package/.docs/classes/SelectionInfo.md +73 -74
  30. package/.docs/classes/SkwHttpProvider.md +33 -45
  31. package/.docs/classes/StringUtils.md +297 -322
  32. package/.docs/classes/TimeFormatter.md +43 -44
  33. package/.docs/classes/UserAgentUtils.md +17 -20
  34. package/.docs/classes/VersionUtils.md +15 -18
  35. package/.docs/classes/WaitingChangeException.md +63 -84
  36. package/.docs/classes/WarningException.md +67 -88
  37. package/.docs/enumerations/Action.md +307 -0
  38. package/.docs/enumerations/ChangeOperation.md +47 -0
  39. package/.docs/enumerations/DataType.md +57 -0
  40. package/.docs/enumerations/DependencyType.md +37 -0
  41. package/.docs/enumerations/OverflowDirection.md +29 -0
  42. package/.docs/enumerations/SelectionMode.md +27 -0
  43. package/.docs/enumerations/SortMode.md +27 -0
  44. package/.docs/enumerations/UserInterface.md +177 -0
  45. package/.docs/functions/defaultDataLoader.md +25 -0
  46. package/.docs/{modules.md → globals.md} +26 -36
  47. package/.docs/interfaces/ChildDescriptor.md +12 -16
  48. package/.docs/interfaces/ChildLink.md +9 -12
  49. package/.docs/interfaces/DUActionInterceptor.md +10 -14
  50. package/.docs/interfaces/ExecutionContext.md +17 -32
  51. package/.docs/interfaces/FieldDescriptor.md +52 -66
  52. package/.docs/interfaces/Filter.md +13 -17
  53. package/.docs/interfaces/IElementIDInfo.md +11 -14
  54. package/.docs/interfaces/ILoadResult.md +11 -16
  55. package/.docs/interfaces/IRepository.md +106 -93
  56. package/.docs/interfaces/IRepositoryIndex.md +23 -30
  57. package/.docs/interfaces/LoadDataRequest.md +36 -45
  58. package/.docs/interfaces/LoadDataResponse.md +11 -14
  59. package/.docs/interfaces/OverFlowWatcherParams.md +67 -0
  60. package/.docs/interfaces/PageRequest.md +16 -20
  61. package/.docs/interfaces/PaginationInfo.md +24 -31
  62. package/.docs/interfaces/PromiseSyncCallback.md +13 -17
  63. package/.docs/interfaces/QuickFilter.md +17 -21
  64. package/.docs/interfaces/Record.md +26 -33
  65. package/.docs/interfaces/SavedRecord.md +33 -41
  66. package/.docs/interfaces/Sort.md +12 -16
  67. package/.docs/interfaces/SortingProvider.md +10 -13
  68. package/.docs/interfaces/UnitMetadata.md +16 -21
  69. package/.docs/interfaces/WaitingChange.md +16 -20
  70. package/.docs/namespaces/MaskFormatter/README.md +17 -0
  71. package/.docs/namespaces/MaskFormatter/type-aliases/MaskCharacter.md +13 -0
  72. package/.docs/namespaces/MaskFormatter/variables/MaskCharacter.md +13 -0
  73. package/.docs/type-aliases/DataUnitEventOptions.md +17 -0
  74. package/.docs/type-aliases/OnOverflowCallBack.md +25 -0
  75. package/.docs/variables/OVERFLOWED_CLASS_NAME.md +13 -0
  76. package/dist/dataunit/DataUnit.d.ts +45 -6
  77. package/dist/dataunit/DataUnit.js +116 -30
  78. package/dist/dataunit/DataUnit.js.map +1 -1
  79. package/dist/dataunit/formatting/PrettyFormatter.js +11 -7
  80. package/dist/dataunit/formatting/PrettyFormatter.js.map +1 -1
  81. package/dist/dataunit/loading/LoadDataRequest.d.ts +1 -1
  82. package/dist/dataunit/metadata/DataType.js +13 -1
  83. package/dist/dataunit/metadata/DataType.js.map +1 -1
  84. package/dist/dataunit/state/action/DataUnitAction.d.ts +4 -1
  85. package/dist/dataunit/state/action/DataUnitAction.js +3 -0
  86. package/dist/dataunit/state/action/DataUnitAction.js.map +1 -1
  87. package/dist/dataunit/state/slice/ChangesSlice.js +12 -11
  88. package/dist/dataunit/state/slice/ChangesSlice.js.map +1 -1
  89. package/dist/dataunit/state/slice/InvalidFieldsSlice.js +2 -0
  90. package/dist/dataunit/state/slice/InvalidFieldsSlice.js.map +1 -1
  91. package/dist/dataunit/state/slice/LoadingProperties.d.ts +9 -0
  92. package/dist/dataunit/state/slice/LoadingProperties.js +31 -0
  93. package/dist/dataunit/state/slice/LoadingProperties.js.map +1 -0
  94. package/dist/dataunit/state/slice/SelectionSlice.js +4 -4
  95. package/dist/dataunit/state/slice/SelectionSlice.js.map +1 -1
  96. package/dist/index.d.ts +3 -2
  97. package/dist/index.js +2 -1
  98. package/dist/index.js.map +1 -1
  99. package/dist/repository/IRepository.d.ts +6 -0
  100. package/dist/repository/indexeddb/IDBRepository.d.ts +1 -0
  101. package/dist/repository/indexeddb/IDBRepository.js +3 -0
  102. package/dist/repository/indexeddb/IDBRepository.js.map +1 -1
  103. package/dist/utils/ElementUtils.d.ts +2 -0
  104. package/dist/utils/ElementUtils.js +9 -0
  105. package/dist/utils/ElementUtils.js.map +1 -0
  106. package/dist/utils/MaskFormatter.d.ts +2 -1
  107. package/dist/utils/MaskFormatter.js +5 -1
  108. package/dist/utils/MaskFormatter.js.map +1 -1
  109. package/dist/utils/ObjectUtils.d.ts +38 -0
  110. package/dist/utils/ObjectUtils.js +51 -0
  111. package/dist/utils/ObjectUtils.js.map +1 -1
  112. package/dist/utils/OnboardingUtils.js +1 -1
  113. package/dist/utils/OnboardingUtils.js.map +1 -1
  114. package/dist/utils/OverflowWatcher/index.d.ts +59 -0
  115. package/dist/utils/OverflowWatcher/index.js +188 -0
  116. package/dist/utils/OverflowWatcher/index.js.map +1 -0
  117. package/dist/utils/OverflowWatcher/types/overflow-callback.d.ts +6 -0
  118. package/dist/utils/OverflowWatcher/types/overflow-callback.js +2 -0
  119. package/dist/utils/OverflowWatcher/types/overflow-callback.js.map +1 -0
  120. package/dist/utils/OverflowWatcher/types/overflow-direction.d.ts +7 -0
  121. package/dist/utils/OverflowWatcher/types/overflow-direction.js +9 -0
  122. package/dist/utils/OverflowWatcher/types/overflow-direction.js.map +1 -0
  123. package/dist/utils/SortingUtils.d.ts +9 -0
  124. package/dist/utils/SortingUtils.js +24 -0
  125. package/dist/utils/SortingUtils.js.map +1 -0
  126. package/jest.config.ts +3 -1
  127. package/package.json +12 -4
  128. package/reports/test-report.xml +166 -0
  129. package/setupTests.js +7 -0
  130. package/sonar-project.properties +10 -0
  131. package/src/dataunit/DataUnit.ts +139 -40
  132. package/src/dataunit/formatting/PrettyFormatter.ts +10 -7
  133. package/src/dataunit/loading/LoadDataRequest.ts +1 -1
  134. package/src/dataunit/metadata/DataType.ts +13 -1
  135. package/src/dataunit/state/action/DataUnitAction.ts +4 -1
  136. package/src/dataunit/state/slice/ChangesSlice.ts +15 -14
  137. package/src/dataunit/state/slice/InvalidFieldsSlice.ts +2 -0
  138. package/src/dataunit/state/slice/LoadingProperties.ts +37 -0
  139. package/src/dataunit/state/slice/SelectionSlice.ts +4 -4
  140. package/src/index.ts +8 -1
  141. package/src/repository/IRepository.ts +7 -0
  142. package/src/repository/indexeddb/IDBRepository.ts +4 -0
  143. package/src/utils/ElementUtils.ts +10 -0
  144. package/src/utils/MaskFormatter.ts +5 -1
  145. package/src/utils/ObjectUtils.ts +56 -0
  146. package/src/utils/OnboardingUtils.ts +1 -1
  147. package/src/utils/OverflowWatcher/index.ts +243 -0
  148. package/src/utils/OverflowWatcher/types/overflow-callback.ts +6 -0
  149. package/src/utils/OverflowWatcher/types/overflow-direction.ts +7 -0
  150. package/src/utils/SortingUtils.ts +30 -0
  151. package/src/utils/test/objectUtils.spec.ts +109 -0
  152. package/test/dataunit/formatting/PrettyFormatter.spec.ts +177 -0
  153. package/test/util/ElementUtils.spec.ts +34 -0
  154. package/test/util/OverflowWatcher.spec.ts +152 -0
  155. package/.docs/.nojekyll +0 -1
  156. package/.docs/enums/Action.md +0 -305
  157. package/.docs/enums/ChangeOperation.md +0 -52
  158. package/.docs/enums/DataType.md +0 -63
  159. package/.docs/enums/DependencyType.md +0 -41
  160. package/.docs/enums/SelectionMode.md +0 -30
  161. package/.docs/enums/SortMode.md +0 -30
  162. package/.docs/enums/UserInterface.md +0 -195
  163. package/.docs/modules/MaskFormatter.md +0 -37
@@ -0,0 +1,177 @@
1
+ import { getFormattedValue } from '../../../src/dataunit/formatting/PrettyFormatter';
2
+ import { DataType, FieldDescriptor, UserInterface } from '../../../src';
3
+
4
+ /**
5
+ * É preciso importart o utilitário DateUtils para que seus métodos
6
+ * estáticos sejam executados no ambiente de testes
7
+ */
8
+
9
+ import { DateUtils } from '../../../src';
10
+
11
+ describe('getFormattedValue', () => {
12
+ it('should return empty string when value is null', () => {
13
+ const value = null;
14
+ const descriptor = getFileFieldDescriptor();
15
+ expect(getFormattedValue(value, descriptor)).toBe('');
16
+ });
17
+
18
+ it('should return empty string when value is not an array', () => {
19
+ const value = 'not an array';
20
+ const descriptor = getFileFieldDescriptor();
21
+ expect(getFormattedValue(value, descriptor)).toBe('');
22
+ });
23
+
24
+ it('should return empty string when value is an empty array', () => {
25
+ const value: any[] = [];
26
+ const descriptor = getFileFieldDescriptor();
27
+ expect(getFormattedValue(value, descriptor)).toBe('0 arquivos');
28
+ });
29
+
30
+ it('should return file name when value is an array with one file object', () => {
31
+ const value = [{ name: 'file1.txt' }];
32
+ const descriptor = getFileFieldDescriptor();
33
+ expect(getFormattedValue(value, descriptor)).toBe('file1.txt');
34
+ });
35
+
36
+ it('should return file count when value is an array with multiple file objects', () => {
37
+ const value = [{ name: 'file1.txt' }, { name: 'file2.txt' }];
38
+ const descriptor = getFileFieldDescriptor();
39
+ expect(getFormattedValue(value, descriptor)).toBe('2 arquivos');
40
+ });
41
+
42
+ it('should return empty string for undefined file', () => {
43
+ const value = undefined;
44
+ const descriptor = { userInterface: UserInterface.FILE } as FieldDescriptor;
45
+ expect(getFormattedValue(value, descriptor)).toBe('');
46
+ });
47
+
48
+ it('should handle OBJECT type with value field', () => {
49
+ const value = { value: 'code', label: 'label' };
50
+ const descriptor = { dataType: DataType.OBJECT, userInterface: UserInterface.SEARCH } as FieldDescriptor;
51
+ expect(getFormattedValue(value, descriptor)).toBe('code - label');
52
+ });
53
+
54
+ it('should return empty string when value is undefined', () => {
55
+ const value = undefined;
56
+ const descriptor = getObjectFieldDescriptor();
57
+ expect(getFormattedValue(value, descriptor)).toBe('');
58
+ });
59
+
60
+ it('should return value as string when value is not an object', () => {
61
+ const value = 12345;
62
+ const descriptor = getObjectFieldDescriptor();
63
+ expect(getFormattedValue(value, descriptor)).toBe('12345');
64
+ });
65
+
66
+ it('should return value.toString() when value is an object without value property', () => {
67
+ const value = { someProperty: 'someValue' };
68
+ const descriptor = getObjectFieldDescriptor();
69
+ expect(getFormattedValue(value, descriptor)).toBe(value.toString());
70
+ });
71
+
72
+ it('should handle BOOLEAN type', () => {
73
+ expect(getFormattedValue(true, { dataType: DataType.BOOLEAN } as FieldDescriptor)).toBe('Sim');
74
+ expect(getFormattedValue(false, { dataType: DataType.BOOLEAN } as FieldDescriptor)).toBe('Não');
75
+ });
76
+
77
+ it('should format numbers correctly', () => {
78
+ const value = 1234.567;
79
+ const descriptor = {
80
+ dataType: DataType.NUMBER,
81
+ properties: { precision: 2, prettyPrecision: 2 },
82
+ } as FieldDescriptor;
83
+ expect(getFormattedValue(value, descriptor)).toBe('1.234,57');
84
+ });
85
+
86
+ it('should format dates correctly', () => {
87
+ const value = new Date('2023-07-01T14:30:00');
88
+ const descriptor = { userInterface: UserInterface.DATE } as FieldDescriptor;
89
+ expect(getFormattedValue(value, descriptor)).toBe('01/07/2023');
90
+ });
91
+
92
+ it('should format times correctly', () => {
93
+ const value = new Date('2023-07-01T14:30:00');
94
+ const descriptor = { userInterface: UserInterface.TIME } as FieldDescriptor;
95
+ expect(getFormattedValue(value, descriptor)).toBe('14:30');
96
+ });
97
+
98
+ it('should format datetime correctly', () => {
99
+ const value = new Date('2023-07-01T14:30:00');
100
+ const descriptor = { userInterface: UserInterface.DATETIME } as FieldDescriptor;
101
+ expect(getFormattedValue(value, descriptor)).toBe('01/07/2023 14:30');
102
+ });
103
+
104
+ it('should call toString with correct parameters', () => {
105
+ const value = 123;
106
+ const descriptor = { dataType: DataType.NUMBER } as FieldDescriptor;
107
+ expect(getFormattedValue(value, descriptor)).toBe('123,00');
108
+ });
109
+
110
+ it('should handle undefined descriptor gracefully', () => {
111
+ const value = 123;
112
+ expect(getFormattedValue(value)).toBe('123');
113
+ });
114
+
115
+ it('should format value correctly with OPTIONSELECTOR and matching option', () => {
116
+ const value = 'option1';
117
+ const descriptor = buildOptionSelectorFieldDescriptor();
118
+ expect(getFormattedValue(value, descriptor)).toBe('option1');
119
+ });
120
+
121
+ it('should return value with OPTIONSELECTOR and no matching option', () => {
122
+ const value = 'option2';
123
+ const descriptor = buildOptionSelectorFieldDescriptor();
124
+ expect(getFormattedValue(value, descriptor)).toBe('option2');
125
+ });
126
+
127
+ it('should format value correctly with OPTIONSELECTOR and value as object', () => {
128
+ const value = { value: 'option1' };
129
+ const descriptor = buildOptionSelectorFieldDescriptor();
130
+ expect(getFormattedValue(value, descriptor)).toBe('option1');
131
+ });
132
+
133
+ it('should return empty string with OPTIONSELECTOR and value as null', () => {
134
+ const value = null;
135
+ const descriptor = buildOptionSelectorFieldDescriptor();
136
+ expect(getFormattedValue(value, descriptor)).toBe('');
137
+ });
138
+
139
+ it('should format value correctly with OPTIONSELECTOR and options as JSON string', () => {
140
+ const value = 'option1';
141
+ const descriptor: FieldDescriptor = {
142
+ userInterface: UserInterface.OPTIONSELECTOR,
143
+ properties: { options: JSON.stringify([{ label: 'Option 1', value: 'option1' }]) },
144
+ } as FieldDescriptor;
145
+ expect(getFormattedValue(value, descriptor)).toBe('option1');
146
+ });
147
+
148
+ it('should return value with OPTIONSELECTOR and options as empty array', () => {
149
+ const value = 'option1';
150
+ const descriptor: FieldDescriptor = {
151
+ userInterface: UserInterface.OPTIONSELECTOR,
152
+ properties: { options: [] },
153
+ } as FieldDescriptor;
154
+ expect(getFormattedValue(value, descriptor)).toBe('option1');
155
+ });
156
+
157
+ it('should format masked values correctly', () => {
158
+ const value = '12345678901';
159
+ const descriptor = { properties: { mask: 'cpf' } } as FieldDescriptor;
160
+ expect(getFormattedValue(value, descriptor)).toBe('123.456.789-01');
161
+ });
162
+ });
163
+
164
+ function buildOptionSelectorFieldDescriptor(): FieldDescriptor {
165
+ return {
166
+ userInterface: UserInterface.OPTIONSELECTOR,
167
+ properties: { options: [{ label: 'Option 1', value: 'option1' }] },
168
+ } as FieldDescriptor;
169
+ }
170
+
171
+ function getFileFieldDescriptor(): FieldDescriptor{
172
+ return { userInterface: UserInterface.FILE } as FieldDescriptor;
173
+ }
174
+
175
+ function getObjectFieldDescriptor(): FieldDescriptor{
176
+ return { dataType: DataType.OBJECT } as FieldDescriptor;
177
+ }
@@ -0,0 +1,34 @@
1
+ import { calcMarginSize } from '../../src/utils/ElementUtils';
2
+ import { OverflowDirection } from '../../src';
3
+
4
+ describe('calcMarginSize', () => {
5
+ it('should calculate correctly the size of horizontal margin', () => {
6
+ const element = document.createElement('div');
7
+ element.style.marginLeft = '10px';
8
+ element.style.marginRight = '15px';
9
+ document.body.appendChild(element);
10
+
11
+ const size = calcMarginSize(element, OverflowDirection.HORIZONTAL);
12
+ expect(size).toBe(25);
13
+ });
14
+
15
+ it('should calculate correctly the size of vertical margin', () => {
16
+ const element = document.createElement('div');
17
+ element.style.marginTop = '5px';
18
+ element.style.marginBottom = '20px';
19
+ document.body.appendChild(element);
20
+
21
+ const size = calcMarginSize(element, OverflowDirection.VERTICAL);
22
+ expect(size).toBe(25);
23
+ });
24
+
25
+ it('should threat values defined as zero', () => {
26
+ const element = document.createElement('div');
27
+ document.body.appendChild(element);
28
+
29
+ const horizontalSize = calcMarginSize(element, OverflowDirection.HORIZONTAL);
30
+ const verticalSize = calcMarginSize(element, OverflowDirection.VERTICAL);
31
+ expect(horizontalSize).toBe(0);
32
+ expect(verticalSize).toBe(0);
33
+ });
34
+ });
@@ -0,0 +1,152 @@
1
+ import OverflowWatcher, { OverFlowWatcherParams, OverflowDirection, OVERFLOWED_CLASS_NAME } from '../../src/utils/OverflowWatcher';
2
+
3
+ describe('OverflowWatcher', () => {
4
+ let mockElement: HTMLElement;
5
+ let mockCallback: jest.Mock;
6
+ let watcherInstance: OverflowWatcher;
7
+
8
+ beforeEach(() => {
9
+ mockElement = document.createElement('div');
10
+ Object.defineProperty(mockElement, 'clientWidth', { value: 90, configurable: true });
11
+ document.body.appendChild(mockElement);
12
+ mockCallback = jest.fn();
13
+
14
+ const params: OverFlowWatcherParams = {
15
+ element: mockElement,
16
+ callback: mockCallback,
17
+ overFlowDirection: OverflowDirection.HORIZONTAL,
18
+ debounce: 1,
19
+ deltaSize: 1,
20
+ notOverFlow: ['testId'],
21
+ };
22
+
23
+ watcherInstance = new OverflowWatcher(params);
24
+ mockElement.getBoundingClientRect = jest.fn().mockReturnValue(getMockedRectClientValue(200));
25
+ setPrivateField(watcherInstance, '_lastContainerSize', 100);
26
+ setPrivateField(watcherInstance, '_lastContainerInstance', mockElement);
27
+ });
28
+
29
+ afterEach(() => {
30
+ watcherInstance.destroy();
31
+ });
32
+
33
+ it('should initialize with provided parameters', () => {
34
+ expect(watcherInstance).toBeDefined();
35
+ });
36
+
37
+ it('should disconect ResizeObserver when destroy is called', () => {
38
+ const disconnectSpy = jest.spyOn(ResizeObserver.prototype, 'disconnect');
39
+ watcherInstance.destroy();
40
+ expect(disconnectSpy).toHaveBeenCalled();
41
+ });
42
+
43
+ it('Should call callback on forceUpdate', () => {
44
+ appendMockedChildren(mockElement);
45
+ watcherInstance.forceUpdate();
46
+ expect(mockCallback).toHaveBeenCalled();
47
+ });
48
+
49
+ it('Should call callback on forceUpdate with childSpan', () => {
50
+ appendMockedChildren(mockElement);
51
+ watcherInstance.forceUpdate();
52
+
53
+ const childSpan = mockElement.children[1];
54
+ expect(mockCallback).toHaveBeenCalledWith(expect.arrayContaining([childSpan]));
55
+ });
56
+
57
+ it('Should call callback on forceUpdate with childSpan when notOverFlow is empty', () => {
58
+ appendMockedChildren(mockElement);
59
+
60
+ const params: OverFlowWatcherParams = {
61
+ element: mockElement,
62
+ callback: mockCallback,
63
+ overFlowDirection: OverflowDirection.HORIZONTAL,
64
+ debounce: 1,
65
+ deltaSize: 1,
66
+ };
67
+
68
+ const withNoOverFlow = new OverflowWatcher(params);
69
+ setPrivateField(withNoOverFlow, '_lastContainerSize', 100);
70
+ setPrivateField(withNoOverFlow, '_lastContainerInstance', mockElement);
71
+
72
+ withNoOverFlow.forceUpdate();
73
+
74
+ const childSpan = mockElement.children[1];
75
+ expect(mockCallback).toHaveBeenCalledWith(expect.arrayContaining([childSpan]));
76
+ });
77
+
78
+ it('Should call callback on forceUpdate with childSpan considering overflowed elements', () => {
79
+ appendMockedChildren(mockElement);
80
+ const childButton = mockElement.children[0];
81
+ const childSpan = mockElement.children[1];
82
+ childSpan.classList.add(OVERFLOWED_CLASS_NAME);
83
+
84
+ const hiddemItemsMock: Map<Element, {size: number, margin: number}> = new Map();
85
+ hiddemItemsMock.set(childSpan, {size: 50, margin: 0});
86
+ hiddemItemsMock.set(childButton, {size: 0, margin: 50});
87
+ setPrivateField(watcherInstance, '_hiddenItemsProps', hiddemItemsMock);
88
+
89
+ watcherInstance.forceUpdate();
90
+
91
+ expect(mockCallback).toHaveBeenCalledWith(expect.arrayContaining([childSpan]));
92
+ });
93
+
94
+ it('Should call callback on forceUpdate with empty list', () => {
95
+ appendMockedChildren(mockElement);
96
+ setPrivateField(watcherInstance, '_lastContainerSize', 200);
97
+ watcherInstance.forceUpdate();
98
+ const childButton = mockElement.children[0];
99
+ const childSpan = mockElement.children[1];
100
+
101
+ expect(mockCallback).not.toHaveBeenCalledWith(expect.arrayContaining([childButton, childSpan]));
102
+ });
103
+
104
+ it('should ignore elements that can not overflow', () => {
105
+ appendMockedChildren(mockElement);
106
+
107
+ const notOverflowElement = document.createElement('div');
108
+ notOverflowElement.setAttribute('data-element-id', 'testId') ;
109
+ notOverflowElement.getBoundingClientRect = jest.fn().mockReturnValue(getMockedRectClientValue(50));
110
+
111
+ const notOverflowElement2 = document.createElement('div');
112
+ notOverflowElement2.setAttribute('data-element-id', 'testId2') ;
113
+ notOverflowElement2.getBoundingClientRect = jest.fn().mockReturnValue(getMockedRectClientValue(50));
114
+
115
+ mockElement.appendChild(notOverflowElement);
116
+ mockElement.appendChild(notOverflowElement2);
117
+
118
+ watcherInstance.addNotOverFlowElement('testId');
119
+ watcherInstance.addNotOverFlowElement('testId2');
120
+
121
+ watcherInstance.forceUpdate();
122
+
123
+ expect(mockCallback).not.toHaveBeenCalledWith(expect.arrayContaining([notOverflowElement]));
124
+ });
125
+
126
+ it('Should not call callback on forceUpdate', () => {
127
+ watcherInstance.forceUpdate();
128
+ expect(mockCallback).not.toHaveBeenCalled();
129
+ });
130
+
131
+ });
132
+
133
+ function appendMockedChildren(mockElement: HTMLElement) {
134
+ const chilldButton = document.createElement('button');
135
+ const childSpan = document.createElement('span');
136
+
137
+ chilldButton.getBoundingClientRect = jest.fn().mockReturnValue(getMockedRectClientValue(50));
138
+ childSpan.getBoundingClientRect = jest.fn().mockReturnValue(getMockedRectClientValue(50));
139
+
140
+ mockElement.appendChild(chilldButton);
141
+ mockElement.appendChild(childSpan);
142
+ }
143
+
144
+ function getMockedRectClientValue(size: number) {
145
+ return {
146
+ x: 0, y: 0, width: size, height: 10, top: 0, right: 0, bottom: 0, left: 0, toJSON: () => {}
147
+ };
148
+ }
149
+
150
+ function setPrivateField<T>(instance: T, fieldName: string, value: any): void {
151
+ (instance as any)[fieldName] = value;
152
+ }
package/.docs/.nojekyll DELETED
@@ -1 +0,0 @@
1
- TypeDoc added this file to prevent GitHub Pages from using Jekyll. You can turn off this behavior by setting the `githubPages` option to false.
@@ -1,305 +0,0 @@
1
- [@sankhyalabs/core](../README.md) / [Exports](../modules.md) / Action
2
-
3
- # Enumeration: Action
4
-
5
- ## Table of contents
6
-
7
- ### Enumeration Members
8
-
9
- - [CHANGE\_REDONE](Action.md#change_redone)
10
- - [CHANGE\_UNDONE](Action.md#change_undone)
11
- - [CHANGING\_DATA](Action.md#changing_data)
12
- - [CHILD\_CHANGED](Action.md#child_changed)
13
- - [DATA\_CHANGED](Action.md#data_changed)
14
- - [DATA\_LOADED](Action.md#data_loaded)
15
- - [DATA\_RESOLVED](Action.md#data_resolved)
16
- - [DATA\_SAVED](Action.md#data_saved)
17
- - [EDITION\_CANCELED](Action.md#edition_canceled)
18
- - [FIELD\_INVALIDATED](Action.md#field_invalidated)
19
- - [INVALIDATE\_CLEAN](Action.md#invalidate_clean)
20
- - [LOADING\_DATA](Action.md#loading_data)
21
- - [LOADING\_METADATA](Action.md#loading_metadata)
22
- - [LOADING\_RECORD](Action.md#loading_record)
23
- - [METADATA\_LOADED](Action.md#metadata_loaded)
24
- - [NEXT\_SELECTED](Action.md#next_selected)
25
- - [PAGINATION\_UPDATED](Action.md#pagination_updated)
26
- - [PREVIOUS\_SELECTED](Action.md#previous_selected)
27
- - [RECORDS\_ADDED](Action.md#records_added)
28
- - [RECORDS\_COPIED](Action.md#records_copied)
29
- - [RECORDS\_REMOVED](Action.md#records_removed)
30
- - [RECORD\_LOADED](Action.md#record_loaded)
31
- - [REMOVING\_RECORDS](Action.md#removing_records)
32
- - [SAVING\_DATA](Action.md#saving_data)
33
- - [SELECTION\_CHANGED](Action.md#selection_changed)
34
- - [STATE\_CHANGED](Action.md#state_changed)
35
- - [WAITING\_CHANGE\_CANCELED](Action.md#waiting_change_canceled)
36
-
37
- ## Enumeration Members
38
-
39
- ### CHANGE\_REDONE
40
-
41
- • **CHANGE\_REDONE** = ``"changeRedone"``
42
-
43
- #### Defined in
44
-
45
- src/dataunit/state/action/DataUnitAction.ts:52
46
-
47
- ___
48
-
49
- ### CHANGE\_UNDONE
50
-
51
- • **CHANGE\_UNDONE** = ``"changeUndone"``
52
-
53
- #### Defined in
54
-
55
- src/dataunit/state/action/DataUnitAction.ts:51
56
-
57
- ___
58
-
59
- ### CHANGING\_DATA
60
-
61
- • **CHANGING\_DATA** = ``"changingData"``
62
-
63
- #### Defined in
64
-
65
- src/dataunit/state/action/DataUnitAction.ts:45
66
-
67
- ___
68
-
69
- ### CHILD\_CHANGED
70
-
71
- • **CHILD\_CHANGED** = ``"childChanged"``
72
-
73
- #### Defined in
74
-
75
- src/dataunit/state/action/DataUnitAction.ts:63
76
-
77
- ___
78
-
79
- ### DATA\_CHANGED
80
-
81
- • **DATA\_CHANGED** = ``"dataChanged"``
82
-
83
- #### Defined in
84
-
85
- src/dataunit/state/action/DataUnitAction.ts:47
86
-
87
- ___
88
-
89
- ### DATA\_LOADED
90
-
91
- • **DATA\_LOADED** = ``"dataLoaded"``
92
-
93
- #### Defined in
94
-
95
- src/dataunit/state/action/DataUnitAction.ts:33
96
-
97
- ___
98
-
99
- ### DATA\_RESOLVED
100
-
101
- • **DATA\_RESOLVED** = ``"dataResolved"``
102
-
103
- #### Defined in
104
-
105
- src/dataunit/state/action/DataUnitAction.ts:48
106
-
107
- ___
108
-
109
- ### DATA\_SAVED
110
-
111
- • **DATA\_SAVED** = ``"dataSaved"``
112
-
113
- #### Defined in
114
-
115
- src/dataunit/state/action/DataUnitAction.ts:37
116
-
117
- ___
118
-
119
- ### EDITION\_CANCELED
120
-
121
- • **EDITION\_CANCELED** = ``"editionCanceled"``
122
-
123
- #### Defined in
124
-
125
- src/dataunit/state/action/DataUnitAction.ts:50
126
-
127
- ___
128
-
129
- ### FIELD\_INVALIDATED
130
-
131
- • **FIELD\_INVALIDATED** = ``"fieldInvalidated"``
132
-
133
- #### Defined in
134
-
135
- src/dataunit/state/action/DataUnitAction.ts:65
136
-
137
- ___
138
-
139
- ### INVALIDATE\_CLEAN
140
-
141
- • **INVALIDATE\_CLEAN** = ``"invalidateClean"``
142
-
143
- #### Defined in
144
-
145
- src/dataunit/state/action/DataUnitAction.ts:66
146
-
147
- ___
148
-
149
- ### LOADING\_DATA
150
-
151
- • **LOADING\_DATA** = ``"loadingData"``
152
-
153
- #### Defined in
154
-
155
- src/dataunit/state/action/DataUnitAction.ts:32
156
-
157
- ___
158
-
159
- ### LOADING\_METADATA
160
-
161
- • **LOADING\_METADATA** = ``"loadingMetadata"``
162
-
163
- #### Defined in
164
-
165
- src/dataunit/state/action/DataUnitAction.ts:29
166
-
167
- ___
168
-
169
- ### LOADING\_RECORD
170
-
171
- • **LOADING\_RECORD** = ``"loadingRecord"``
172
-
173
- #### Defined in
174
-
175
- src/dataunit/state/action/DataUnitAction.ts:60
176
-
177
- ___
178
-
179
- ### METADATA\_LOADED
180
-
181
- • **METADATA\_LOADED** = ``"metadataLoaded"``
182
-
183
- #### Defined in
184
-
185
- src/dataunit/state/action/DataUnitAction.ts:30
186
-
187
- ___
188
-
189
- ### NEXT\_SELECTED
190
-
191
- • **NEXT\_SELECTED** = ``"nextSelected"``
192
-
193
- #### Defined in
194
-
195
- src/dataunit/state/action/DataUnitAction.ts:55
196
-
197
- ___
198
-
199
- ### PAGINATION\_UPDATED
200
-
201
- • **PAGINATION\_UPDATED** = ``"paginationUpdated"``
202
-
203
- #### Defined in
204
-
205
- src/dataunit/state/action/DataUnitAction.ts:34
206
-
207
- ___
208
-
209
- ### PREVIOUS\_SELECTED
210
-
211
- • **PREVIOUS\_SELECTED** = ``"previousSelected"``
212
-
213
- #### Defined in
214
-
215
- src/dataunit/state/action/DataUnitAction.ts:56
216
-
217
- ___
218
-
219
- ### RECORDS\_ADDED
220
-
221
- • **RECORDS\_ADDED** = ``"recordsAdded"``
222
-
223
- #### Defined in
224
-
225
- src/dataunit/state/action/DataUnitAction.ts:42
226
-
227
- ___
228
-
229
- ### RECORDS\_COPIED
230
-
231
- • **RECORDS\_COPIED** = ``"recordsCopied"``
232
-
233
- #### Defined in
234
-
235
- src/dataunit/state/action/DataUnitAction.ts:43
236
-
237
- ___
238
-
239
- ### RECORDS\_REMOVED
240
-
241
- • **RECORDS\_REMOVED** = ``"recordsRemoved"``
242
-
243
- #### Defined in
244
-
245
- src/dataunit/state/action/DataUnitAction.ts:40
246
-
247
- ___
248
-
249
- ### RECORD\_LOADED
250
-
251
- • **RECORD\_LOADED** = ``"recordLoaded"``
252
-
253
- #### Defined in
254
-
255
- src/dataunit/state/action/DataUnitAction.ts:61
256
-
257
- ___
258
-
259
- ### REMOVING\_RECORDS
260
-
261
- • **REMOVING\_RECORDS** = ``"removingRecords"``
262
-
263
- #### Defined in
264
-
265
- src/dataunit/state/action/DataUnitAction.ts:39
266
-
267
- ___
268
-
269
- ### SAVING\_DATA
270
-
271
- • **SAVING\_DATA** = ``"savingData"``
272
-
273
- #### Defined in
274
-
275
- src/dataunit/state/action/DataUnitAction.ts:36
276
-
277
- ___
278
-
279
- ### SELECTION\_CHANGED
280
-
281
- • **SELECTION\_CHANGED** = ``"selectionChanged"``
282
-
283
- #### Defined in
284
-
285
- src/dataunit/state/action/DataUnitAction.ts:54
286
-
287
- ___
288
-
289
- ### STATE\_CHANGED
290
-
291
- • **STATE\_CHANGED** = ``"stateChanged"``
292
-
293
- #### Defined in
294
-
295
- src/dataunit/state/action/DataUnitAction.ts:58
296
-
297
- ___
298
-
299
- ### WAITING\_CHANGE\_CANCELED
300
-
301
- • **WAITING\_CHANGE\_CANCELED** = ``"waitingChangeCanceled"``
302
-
303
- #### Defined in
304
-
305
- src/dataunit/state/action/DataUnitAction.ts:46