@qrvey/utils 1.1.7 → 1.1.8

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/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # [@qrvey/utils](https://bitbucket.org/qrvey/qrvey_utils/wiki/Home) *1.1.7*
1
+ # [@qrvey/utils](https://bitbucket.org/qrvey/qrvey_utils/wiki/Home) *1.1.8*
2
2
 
3
3
  > Helper, Utils for all Qrvey Projects
4
4
 
@@ -107,12 +107,12 @@ Get a text and evaluate if it matchs with a token box label.
107
107
 
108
108
 
109
109
 
110
- ### dist/filters/helpers/applyHierarchyForAggFilters.js
110
+ ### dist/date/range/getDateRange.js
111
111
 
112
112
 
113
- #### applyHierarchyForAggFilters(chartSettings, scopes, currentScope)
113
+ #### getDateRange(value, dateGroupLabel, withTime)
114
114
 
115
- [TODO: Make a proper description for this function]
115
+ Get date range object from a string date value
116
116
 
117
117
 
118
118
 
@@ -121,36 +121,74 @@ Get a text and evaluate if it matchs with a token box label.
121
121
 
122
122
  | Name | Type | Description | |
123
123
  | ---- | ---- | ----------- | -------- |
124
- | chartSettings | | Chart Settings for the Filter Builder |   |
125
- | scopes | | |   |
126
- | currentScope | | |   |
124
+ | value | `String` | string date value |   |
125
+ | dateGroupLabel | `String` | could be 'YEAR', 'QUARTER', 'MONTH' or 'DAY'. Deafult is 'DAY' |   |
126
+ | withTime | `Boolean` | determines if the date range will include time. Default is true |   |
127
127
 
128
128
 
129
129
 
130
130
 
131
+ ##### Examples
132
+
133
+ ```javascript
134
+ // 1) Year:
135
+ getDateRange('2020', 'YEAR');
136
+ // Will return:
137
+ {
138
+ from: '01/01/2020 00:00:00',
139
+ to: '12/31/2020 23:59:59'
140
+ }
141
+
142
+ // 2) Quarter:
143
+ getDateRange('Q3 2020', 'QUARTER');
144
+ // Will return:
145
+ {
146
+ from: '07/01/2020 00:00:00',
147
+ to: '09/30/2020 23:59:59'
148
+ }
149
+
150
+ // 3) Month:
151
+ getDateRange('Oct 2020', 'MONTH');
152
+ // Will return:
153
+ {
154
+ from: '10/01/2020 00:00:00',
155
+ to: '10/31/2020 23:59:59'
156
+ }
157
+ ```
158
+
159
+
131
160
  ##### Returns
132
161
 
133
162
 
134
- -
163
+ - `Object` an object with the date range with two string date properties: from and to
135
164
 
136
165
 
137
166
 
138
167
 
139
- ### dist/filters/helpers/getAvailableScopes.js
168
+ ### dist/date/relative/Adapter.js
140
169
 
141
170
 
142
- #### getAvailableScopes(config)
171
+ #### value()
143
172
 
144
- Gets Scopes/Scope IDs by given IDs
173
+ Resolves statement and returns statement value
145
174
 
146
175
 
147
176
 
148
177
 
149
- ##### Parameters
150
178
 
151
- | Name | Type | Description | |
152
- | ---- | ---- | ----------- | -------- |
153
- | config | | given Differnts IDs in order set a available scope |   |
179
+
180
+ ##### Returns
181
+
182
+
183
+ - `AbsoluteRange` `string`
184
+
185
+
186
+
187
+ #### valueAsAnchor()
188
+
189
+ Resolves statement as an anchor
190
+
191
+
154
192
 
155
193
 
156
194
 
@@ -158,17 +196,77 @@ Gets Scopes/Scope IDs by given IDs
158
196
  ##### Returns
159
197
 
160
198
 
161
- - a Scopes/Scope IDs array
199
+ - `string`
200
+
162
201
 
163
202
 
203
+ #### _statementToRange() *private method*
164
204
 
205
+ Convert verbal statement to range value
206
+
207
+
208
+
209
+
210
+
211
+
212
+ ##### Returns
213
+
214
+
215
+ - `AbsoluteRange`
216
+
217
+
218
+
219
+ #### _resolveAsThis() *private method*
220
+
221
+ Apply 'this' cursor logic to statement
222
+
223
+
224
+
225
+
226
+
227
+
228
+ ##### Returns
229
+
230
+
231
+ - `AbsoluteStatement`
232
+
233
+
234
+
235
+ #### _resolveAsTheLast() *private method*
236
+
237
+ Apply 'the last' cursor logic to statement
238
+
239
+
240
+
241
+
242
+
243
+
244
+ ##### Returns
245
+
246
+
247
+ - `AbsoluteStatement`
248
+
249
+
250
+
251
+ #### _resolveAsTheNext() *private method*
252
+
253
+ Apply 'the next' cursor logic to statement
165
254
 
166
- ### dist/filters/helpers/getAvailableScopesIDsByConfig.js
167
255
 
168
256
 
169
- #### getAvailableScopesIDsByConfig(config)
170
257
 
171
- Gets the Scopes IDS for the Available Scope function by any config
258
+
259
+
260
+ ##### Returns
261
+
262
+
263
+ - `AbsoluteStatement`
264
+
265
+
266
+
267
+ #### replaceNowToken(value, now)
268
+
269
+ Replace '@now' token inside a string
172
270
 
173
271
 
174
272
 
@@ -177,7 +275,8 @@ Gets the Scopes IDS for the Available Scope function by any config
177
275
 
178
276
  | Name | Type | Description | |
179
277
  | ---- | ---- | ----------- | -------- |
180
- | config | | any config |   |
278
+ | value | `string` | |   |
279
+ | now | `Date` | |   |
181
280
 
182
281
 
183
282
 
@@ -185,17 +284,60 @@ Gets the Scopes IDS for the Available Scope function by any config
185
284
  ##### Returns
186
285
 
187
286
 
188
- - a Available Scope IDS config
287
+ - `string`
189
288
 
190
289
 
191
290
 
291
+ #### convertRelativeToAbsolute(args)
192
292
 
193
- ### dist/filters/helpers/getScopesByHierarchy.js
293
+ Returns a range object (date) from a group of statement params
194
294
 
195
295
 
196
- #### getScopesByHierarchy(scopes, currentScope)
197
296
 
198
- [TODO: Make a description for this]
297
+
298
+ ##### Parameters
299
+
300
+ | Name | Type | Description | |
301
+ | ---- | ---- | ----------- | -------- |
302
+ | args | `RelativeToAbsoluteStruct` | |   |
303
+
304
+
305
+
306
+
307
+ ##### Examples
308
+
309
+ ```javascript
310
+ pivot = '2021-03-03T12:30:40'
311
+ unit = month
312
+ steps = 2
313
+ setTo = END
314
+ resolverAsCalendar: true
315
+ => Returns '2021-05-31T23:59:59'
316
+ ```
317
+ ```javascript
318
+ pivot = '2021-03-03T12:30:40'
319
+ unit = month
320
+ steps = -2
321
+ setTo = START
322
+ resolverAsCalendar: false
323
+ => Returns '2021-01-03T00:00:00'
324
+ ```
325
+
326
+
327
+ ##### Returns
328
+
329
+
330
+ - `string`
331
+
332
+
333
+
334
+
335
+ ### dist/date/relative/relative.js
336
+
337
+
338
+ #### resolveRelative(statements, clock)
339
+
340
+ Resolve a list of relative statements according to operator
199
341
 
200
342
 
201
343
 
@@ -204,16 +346,34 @@ Gets the Scopes IDS for the Available Scope function by any config
204
346
 
205
347
  | Name | Type | Description | |
206
348
  | ---- | ---- | ----------- | -------- |
207
- | scopes | | the collection of Scopes/Scope IDs |   |
208
- | currentScope | | Current scope type |   |
349
+ | statements | `Array.<RelativeStatement>` `Array.<string>` | - Raw statements/values | &nbsp; |
350
+ | clock | `Date` | - Clock/time reference for relative date resolution | &nbsp; |
351
+
209
352
 
210
353
 
211
354
 
355
+ ##### Examples
356
+
357
+ ```javascript
358
+ Input:
359
+ {
360
+ "cursor": "the_next",
361
+ "unit": "year",
362
+ "number": 1,
363
+ "includeCurrent": false,
364
+ "isCalendarDate": false,
365
+ "anchor": "03/05/2021"
366
+ }
367
+
368
+ Output:
369
+ { gte: "03/06/2021 00:00:00", lte: "03/05/2022 23:59:59" }
370
+ ```
371
+
212
372
 
213
373
  ##### Returns
214
374
 
215
375
 
216
- - A new array of Scopes/Scope IDs
376
+ - `Array.&lt;AbsoluteRange&gt;` `Array.&lt;string&gt;`
217
377
 
218
378
 
219
379
 
@@ -709,6 +869,33 @@ Generates a Logic structure from flattened UI filters
709
869
 
710
870
 
711
871
 
872
+ ### dist/filters/adapters/flatUIToOldLogic.js
873
+
874
+
875
+ #### flatUIToOldLogic(uFilters)
876
+
877
+ Generates a Logic structure from flattened UI filters
878
+
879
+
880
+
881
+
882
+ ##### Parameters
883
+
884
+ | Name | Type | Description | |
885
+ | ---- | ---- | ----------- | -------- |
886
+ | uFilters | | Array of flat filters from UI | &nbsp; |
887
+
888
+
889
+
890
+
891
+ ##### Returns
892
+
893
+
894
+ - The logic structure
895
+
896
+
897
+
898
+
712
899
  ### dist/filters/adapters/flatUIToUI.js
713
900
 
714
901
 
@@ -830,33 +1017,6 @@ Gets an filter structure for the UI filter data
830
1017
 
831
1018
 
832
1019
 
833
- ### dist/filters/adapters/flatUIToOldLogic.js
834
-
835
-
836
- #### flatUIToOldLogic(uFilters)
837
-
838
- Generates a Logic structure from flattened UI filters
839
-
840
-
841
-
842
-
843
- ##### Parameters
844
-
845
- | Name | Type | Description | |
846
- | ---- | ---- | ----------- | -------- |
847
- | uFilters | | Array of flat filters from UI | &nbsp; |
848
-
849
-
850
-
851
-
852
- ##### Returns
853
-
854
-
855
- - The logic structure
856
-
857
-
858
-
859
-
860
1020
  ### dist/filters/adapters/logicToFD.js
861
1021
 
862
1022
 
@@ -1068,43 +1228,12 @@ const filterData = transformFilters(oldPreferenceFilters, 'ANALYZE');
1068
1228
 
1069
1229
 
1070
1230
 
1071
- ### dist/general/array/delete.js
1072
-
1073
-
1074
- #### ArrayDelete(array, index)
1075
-
1076
- Inmutable Array Item deletion
1077
-
1078
-
1079
-
1080
-
1081
- ##### Parameters
1082
-
1083
- | Name | Type | Description | |
1084
- | ---- | ---- | ----------- | -------- |
1085
- | array | `Array` | a collection of items to delete | &nbsp; |
1086
- | index | `Number` | the position of the item to delete | &nbsp; |
1087
-
1088
-
1089
-
1090
-
1091
- ##### Returns
1092
-
1093
-
1094
- - a new Array or the given parameter when is empty or not an array
1095
-
1096
-
1097
-
1098
-
1099
- ### dist/general/array/filterNestedTree.js
1231
+ ### dist/filters/helpers/applyHierarchyForAggFilters.js
1100
1232
 
1101
1233
 
1102
- #### filterNestedTree(arr, childArrKey, condition)
1234
+ #### applyHierarchyForAggFilters(chartSettings, scopes, currentScope)
1103
1235
 
1104
- Filters a nested tree array by a custom condition on the last child node
1105
- - If the given arguments are not valid, the function returns the first argument.
1106
- - If the childArrKey is not matched in the object, the condition tries to resolve the filter anyway and returns an empty array.
1107
- - If the condition is not fulfilled, the function returns a filtered array, probably a empty array inside of the child array
1236
+ [TODO: Make a proper description for this function]
1108
1237
 
1109
1238
 
1110
1239
 
@@ -1113,9 +1242,9 @@ Filters a nested tree array by a custom condition on the last child node
1113
1242
 
1114
1243
  | Name | Type | Description | |
1115
1244
  | ---- | ---- | ----------- | -------- |
1116
- | arr | | nested tree array | &nbsp; |
1117
- | childArrKey | | property representing the children array on the nested tree | &nbsp; |
1118
- | condition | | function callback that determines if the filter is applied on the last child node of the nested tree | &nbsp; |
1245
+ | chartSettings | | Chart Settings for the Filter Builder | &nbsp; |
1246
+ | scopes | | | &nbsp; |
1247
+ | currentScope | | | &nbsp; |
1119
1248
 
1120
1249
 
1121
1250
 
@@ -1123,17 +1252,17 @@ Filters a nested tree array by a custom condition on the last child node
1123
1252
  ##### Returns
1124
1253
 
1125
1254
 
1126
- - array filtered
1255
+ -
1127
1256
 
1128
1257
 
1129
1258
 
1130
1259
 
1131
- ### dist/general/array/flattenDeep.js
1260
+ ### dist/filters/helpers/getAvailableScopes.js
1132
1261
 
1133
1262
 
1134
- #### flattenDeep(arr)
1263
+ #### getAvailableScopes(config)
1135
1264
 
1136
- Flat deeply an array
1265
+ Gets Scopes/Scope IDs by given IDs
1137
1266
 
1138
1267
 
1139
1268
 
@@ -1142,7 +1271,7 @@ Flat deeply an array
1142
1271
 
1143
1272
  | Name | Type | Description | |
1144
1273
  | ---- | ---- | ----------- | -------- |
1145
- | arr | | Array to flat deeply | &nbsp; |
1274
+ | config | | given Differnts IDs in order set a available scope | &nbsp; |
1146
1275
 
1147
1276
 
1148
1277
 
@@ -1150,17 +1279,17 @@ Flat deeply an array
1150
1279
  ##### Returns
1151
1280
 
1152
1281
 
1153
- - flatten array
1282
+ - a Scopes/Scope IDs array
1154
1283
 
1155
1284
 
1156
1285
 
1157
1286
 
1158
- ### dist/general/array/getFirstIndexFromArray.js
1287
+ ### dist/filters/helpers/getAvailableScopesIDsByConfig.js
1159
1288
 
1160
1289
 
1161
- #### getFirstIndexFromArray(array, callback)
1290
+ #### getAvailableScopesIDsByConfig(config)
1162
1291
 
1163
- Gets the first index from the array by a callback condition
1292
+ Gets the Scopes IDS for the Available Scope function by any config
1164
1293
 
1165
1294
 
1166
1295
 
@@ -1169,8 +1298,7 @@ Gets the first index from the array by a callback condition
1169
1298
 
1170
1299
  | Name | Type | Description | |
1171
1300
  | ---- | ---- | ----------- | -------- |
1172
- | array | | | &nbsp; |
1173
- | callback | | function callback | &nbsp; |
1301
+ | config | | any config | &nbsp; |
1174
1302
 
1175
1303
 
1176
1304
 
@@ -1178,17 +1306,17 @@ Gets the first index from the array by a callback condition
1178
1306
  ##### Returns
1179
1307
 
1180
1308
 
1181
- - the first index of the array. -1 when the condition is not satisfied
1309
+ - a Available Scope IDS config
1182
1310
 
1183
1311
 
1184
1312
 
1185
1313
 
1186
- ### dist/general/array/getLastIndexFromArray.js
1314
+ ### dist/filters/helpers/getScopesByHierarchy.js
1187
1315
 
1188
1316
 
1189
- #### getLastIndexFromArray(array, callback)
1317
+ #### getScopesByHierarchy(scopes, currentScope)
1190
1318
 
1191
- Gets the last index from the array by a callback condition
1319
+ [TODO: Make a description for this]
1192
1320
 
1193
1321
 
1194
1322
 
@@ -1197,8 +1325,8 @@ Gets the last index from the array by a callback condition
1197
1325
 
1198
1326
  | Name | Type | Description | |
1199
1327
  | ---- | ---- | ----------- | -------- |
1200
- | array | | | &nbsp; |
1201
- | callback | | function callback | &nbsp; |
1328
+ | scopes | | the collection of Scopes/Scope IDs | &nbsp; |
1329
+ | currentScope | | Current scope type | &nbsp; |
1202
1330
 
1203
1331
 
1204
1332
 
@@ -1206,7 +1334,7 @@ Gets the last index from the array by a callback condition
1206
1334
  ##### Returns
1207
1335
 
1208
1336
 
1209
- - the last index of the array. -1 when the condition is not satisfied
1337
+ - A new array of Scopes/Scope IDs
1210
1338
 
1211
1339
 
1212
1340
 
@@ -1435,36 +1563,6 @@ useful to avoid falsify validating Number Zero (0)
1435
1563
 
1436
1564
 
1437
1565
 
1438
- ### dist/general/mix/randomId.js
1439
-
1440
-
1441
- #### randomId(length, exclude)
1442
-
1443
- Creates a random string
1444
- - If the first given argument is different than a length number, the variable is replaced by a default number
1445
- - If the optional second given argument is passed the random string is permutated.
1446
-
1447
-
1448
-
1449
-
1450
- ##### Parameters
1451
-
1452
- | Name | Type | Description | |
1453
- | ---- | ---- | ----------- | -------- |
1454
- | length | `Number` | size of the generated string. Default 8 | &nbsp; |
1455
- | exclude | `Array` | collection of strings that is going to be excluded of the random string. | &nbsp; |
1456
-
1457
-
1458
-
1459
-
1460
- ##### Returns
1461
-
1462
-
1463
- - `String` Random string
1464
-
1465
-
1466
-
1467
-
1468
1566
  ### dist/general/mix/size.js
1469
1567
 
1470
1568
 
@@ -1494,12 +1592,14 @@ Gets the length of the given array.
1494
1592
 
1495
1593
 
1496
1594
 
1497
- ### dist/general/string/capitalize.js
1595
+ ### dist/general/mix/randomId.js
1498
1596
 
1499
1597
 
1500
- #### capitalize(text)
1598
+ #### randomId(length, exclude)
1501
1599
 
1502
- Upper case the first letter of a given text
1600
+ Creates a random string
1601
+ - If the first given argument is different than a length number, the variable is replaced by a default number
1602
+ - If the optional second given argument is passed the random string is permutated.
1503
1603
 
1504
1604
 
1505
1605
 
@@ -1508,7 +1608,8 @@ Upper case the first letter of a given text
1508
1608
 
1509
1609
  | Name | Type | Description | |
1510
1610
  | ---- | ---- | ----------- | -------- |
1511
- | text | `String` | | &nbsp; |
1611
+ | length | `Number` | size of the generated string. Default 8 | &nbsp; |
1612
+ | exclude | `Array` | collection of strings that is going to be excluded of the random string. | &nbsp; |
1512
1613
 
1513
1614
 
1514
1615
 
@@ -1516,7 +1617,7 @@ Upper case the first letter of a given text
1516
1617
  ##### Returns
1517
1618
 
1518
1619
 
1519
- - `String` a capitalized text
1620
+ - `String` Random string
1520
1621
 
1521
1622
 
1522
1623
 
@@ -1786,44 +1887,72 @@ return a new object just with attributes in _keys_ list
1786
1887
 
1787
1888
 
1788
1889
 
1789
- ### dist/date/relative/Adapter.js
1890
+ ### dist/general/string/capitalize.js
1790
1891
 
1791
1892
 
1792
- #### value()
1893
+ #### capitalize(text)
1793
1894
 
1794
- Resolves statement and returns statement value
1895
+ Upper case the first letter of a given text
1795
1896
 
1796
1897
 
1797
1898
 
1798
1899
 
1900
+ ##### Parameters
1901
+
1902
+ | Name | Type | Description | |
1903
+ | ---- | ---- | ----------- | -------- |
1904
+ | text | `String` | | &nbsp; |
1905
+
1906
+
1799
1907
 
1800
1908
 
1801
1909
  ##### Returns
1802
1910
 
1803
1911
 
1804
- - `AbsoluteRange` `string`
1912
+ - `String` a capitalized text
1805
1913
 
1806
1914
 
1807
1915
 
1808
- #### valueAsAnchor()
1809
1916
 
1810
- Resolves statement as an anchor
1917
+ ### dist/stencil/decorators/Config.js
1918
+
1919
+
1920
+ #### Config()
1921
+
1922
+ Stencil.js - Prop Decorator
1923
+ Get and Parse the Widget Configuration Object and also provide the ability to get properties in different case styles such as: lower, upper, camel and pascal
1924
+ But for this, is required ask for a property in `snake_case` style
1811
1925
 
1812
1926
 
1813
1927
 
1814
1928
 
1815
1929
 
1816
1930
 
1931
+ ##### Examples
1932
+
1933
+ ```javascript
1934
+ \ @Config() @Prop() settings;
1935
+
1936
+ someMethod() {
1937
+ this.settings.snake_case //it search for: obj.snake_case || obj.snakeCase || obj.SnakeCase || obj.snakecase || obj.SNAKECASE
1938
+ }
1939
+ ```
1940
+
1941
+
1817
1942
  ##### Returns
1818
1943
 
1819
1944
 
1820
- - `string`
1945
+ - `Void`
1821
1946
 
1822
1947
 
1823
1948
 
1824
- #### _statementToRange() *private method*
1825
1949
 
1826
- Convert verbal statement to range value
1950
+ ### dist/stencil/util/createRef.js
1951
+
1952
+
1953
+ #### createRef()
1954
+
1955
+ lit implementation of React createRef (https://reactjs.org/docs/refs-and-the-dom.html)
1827
1956
 
1828
1957
 
1829
1958
 
@@ -1833,47 +1962,58 @@ Convert verbal statement to range value
1833
1962
  ##### Returns
1834
1963
 
1835
1964
 
1836
- - `AbsoluteRange`
1965
+ - function - Function to use in ref prop in html elements
1837
1966
 
1838
1967
 
1839
1968
 
1840
- #### _resolveAsThis() *private method*
1841
1969
 
1842
- Apply 'this' cursor logic to statement
1970
+ ### dist/stencil/util/getConfig.js
1843
1971
 
1844
1972
 
1973
+ #### getConfig(cfg)
1845
1974
 
1975
+ verify the Config object type and try to return a parsed Object
1976
+ - In case _cfg_ is a string, first try to make a JSON parse in other case
1977
+ try to find this string as a variable on Windows object
1978
+ - If _cfg_ is a fuction, tis is invoked and parsed
1979
+ - Finally, if is an object, _cfg_ is inmediatly returned
1846
1980
 
1847
1981
 
1848
1982
 
1849
- ##### Returns
1850
1983
 
1984
+ ##### Parameters
1851
1985
 
1852
- - `AbsoluteStatement`
1986
+ | Name | Type | Description | |
1987
+ | ---- | ---- | ----------- | -------- |
1988
+ | cfg | | | &nbsp; |
1853
1989
 
1854
1990
 
1855
1991
 
1856
- #### _resolveAsTheLast() *private method*
1857
1992
 
1858
- Apply 'the last' cursor logic to statement
1993
+ ##### Returns
1859
1994
 
1860
1995
 
1996
+ - `Void`
1861
1997
 
1862
1998
 
1863
1999
 
1864
2000
 
1865
- ##### Returns
2001
+ ### dist/general/array/delete.js
1866
2002
 
1867
2003
 
1868
- - `AbsoluteStatement`
2004
+ #### ArrayDelete(array, index)
1869
2005
 
2006
+ Inmutable Array Item deletion
1870
2007
 
1871
2008
 
1872
- #### _resolveAsTheNext() *private method*
1873
2009
 
1874
- Apply 'the next' cursor logic to statement
1875
2010
 
2011
+ ##### Parameters
1876
2012
 
2013
+ | Name | Type | Description | |
2014
+ | ---- | ---- | ----------- | -------- |
2015
+ | array | `Array` | a collection of items to delete | &nbsp; |
2016
+ | index | `Number` | the position of the item to delete | &nbsp; |
1877
2017
 
1878
2018
 
1879
2019
 
@@ -1881,13 +2021,20 @@ Apply 'the next' cursor logic to statement
1881
2021
  ##### Returns
1882
2022
 
1883
2023
 
1884
- - `AbsoluteStatement`
2024
+ - a new Array or the given parameter when is empty or not an array
1885
2025
 
1886
2026
 
1887
2027
 
1888
- #### replaceNowToken(value, now)
1889
2028
 
1890
- Replace '@now' token inside a string
2029
+ ### dist/general/array/filterNestedTree.js
2030
+
2031
+
2032
+ #### filterNestedTree(arr, childArrKey, condition)
2033
+
2034
+ Filters a nested tree array by a custom condition on the last child node
2035
+ - If the given arguments are not valid, the function returns the first argument.
2036
+ - If the childArrKey is not matched in the object, the condition tries to resolve the filter anyway and returns an empty array.
2037
+ - If the condition is not fulfilled, the function returns a filtered array, probably a empty array inside of the child array
1891
2038
 
1892
2039
 
1893
2040
 
@@ -1896,22 +2043,27 @@ Replace '@now' token inside a string
1896
2043
 
1897
2044
  | Name | Type | Description | |
1898
2045
  | ---- | ---- | ----------- | -------- |
1899
- | value | `string` | | &nbsp; |
1900
- | now | `Date` | | &nbsp; |
2046
+ | arr | | nested tree array | &nbsp; |
2047
+ | childArrKey | | property representing the children array on the nested tree | &nbsp; |
2048
+ | condition | | function callback that determines if the filter is applied on the last child node of the nested tree | &nbsp; |
2049
+
1901
2050
 
1902
2051
 
1903
2052
 
2053
+ ##### Returns
2054
+
2055
+
2056
+ - array filtered
1904
2057
 
1905
- ##### Returns
1906
2058
 
1907
2059
 
1908
- - `string`
1909
2060
 
2061
+ ### dist/general/array/flattenDeep.js
1910
2062
 
1911
2063
 
1912
- #### convertRelativeToAbsolute(args)
2064
+ #### flattenDeep(arr)
1913
2065
 
1914
- Returns a range object (date) from a group of statement params
2066
+ Flat deeply an array
1915
2067
 
1916
2068
 
1917
2069
 
@@ -1920,45 +2072,25 @@ Returns a range object (date) from a group of statement params
1920
2072
 
1921
2073
  | Name | Type | Description | |
1922
2074
  | ---- | ---- | ----------- | -------- |
1923
- | args | `RelativeToAbsoluteStruct` | | &nbsp; |
1924
-
1925
-
1926
-
2075
+ | arr | | Array to flat deeply | &nbsp; |
1927
2076
 
1928
- ##### Examples
1929
2077
 
1930
- ```javascript
1931
- pivot = '2021-03-03T12:30:40'
1932
- unit = month
1933
- steps = 2
1934
- setTo = END
1935
- resolverAsCalendar: true
1936
- => Returns '2021-05-31T23:59:59'
1937
- ```
1938
- ```javascript
1939
- pivot = '2021-03-03T12:30:40'
1940
- unit = month
1941
- steps = -2
1942
- setTo = START
1943
- resolverAsCalendar: false
1944
- => Returns '2021-01-03T00:00:00'
1945
- ```
1946
2078
 
1947
2079
 
1948
2080
  ##### Returns
1949
2081
 
1950
2082
 
1951
- - `string`
2083
+ - flatten array
1952
2084
 
1953
2085
 
1954
2086
 
1955
2087
 
1956
- ### dist/date/relative/relative.js
2088
+ ### dist/general/array/getFirstIndexFromArray.js
1957
2089
 
1958
2090
 
1959
- #### resolveRelative(statements, clock)
2091
+ #### getFirstIndexFromArray(array, callback)
1960
2092
 
1961
- Resolve a list of relative statements according to operator
2093
+ Gets the first index from the array by a callback condition
1962
2094
 
1963
2095
 
1964
2096
 
@@ -1967,44 +2099,26 @@ Resolve a list of relative statements according to operator
1967
2099
 
1968
2100
  | Name | Type | Description | |
1969
2101
  | ---- | ---- | ----------- | -------- |
1970
- | statements | `Array.<RelativeStatement>` `Array.<string>` | - Raw statements/values | &nbsp; |
1971
- | clock | `Date` | - Clock/time reference for relative date resolution | &nbsp; |
1972
-
1973
-
1974
-
1975
-
1976
- ##### Examples
2102
+ | array | | | &nbsp; |
2103
+ | callback | | function callback | &nbsp; |
1977
2104
 
1978
- ```javascript
1979
- Input:
1980
- {
1981
- "cursor": "the_next",
1982
- "unit": "year",
1983
- "number": 1,
1984
- "includeCurrent": false,
1985
- "isCalendarDate": false,
1986
- "anchor": "03/05/2021"
1987
- }
1988
2105
 
1989
- Output:
1990
- { gte: "03/06/2021 00:00:00", lte: "03/05/2022 23:59:59" }
1991
- ```
1992
2106
 
1993
2107
 
1994
2108
  ##### Returns
1995
2109
 
1996
2110
 
1997
- - `Array.&lt;AbsoluteRange&gt;` `Array.&lt;string&gt;`
2111
+ - the first index of the array. -1 when the condition is not satisfied
1998
2112
 
1999
2113
 
2000
2114
 
2001
2115
 
2002
- ### dist/date/range/getDateRange.js
2116
+ ### dist/general/array/getLastIndexFromArray.js
2003
2117
 
2004
2118
 
2005
- #### getDateRange(value, dateGroupLabel, withTime)
2119
+ #### getLastIndexFromArray(array, callback)
2006
2120
 
2007
- Get date range object from a string date value
2121
+ Gets the last index from the array by a callback condition
2008
2122
 
2009
2123
 
2010
2124
 
@@ -2013,73 +2127,37 @@ Get date range object from a string date value
2013
2127
 
2014
2128
  | Name | Type | Description | |
2015
2129
  | ---- | ---- | ----------- | -------- |
2016
- | value | `String` | string date value | &nbsp; |
2017
- | dateGroupLabel | `String` | could be 'YEAR', 'QUARTER', 'MONTH' or 'DAY'. Deafult is 'DAY' | &nbsp; |
2018
- | withTime | `Boolean` | determines if the date range will include time. Default is true | &nbsp; |
2019
-
2020
-
2021
-
2022
-
2023
- ##### Examples
2024
-
2025
- ```javascript
2026
- // 1) Year:
2027
- getDateRange('2020', 'YEAR');
2028
- // Will return:
2029
- {
2030
- from: '01/01/2020 00:00:00',
2031
- to: '12/31/2020 23:59:59'
2032
- }
2130
+ | array | | | &nbsp; |
2131
+ | callback | | function callback | &nbsp; |
2033
2132
 
2034
- // 2) Quarter:
2035
- getDateRange('Q3 2020', 'QUARTER');
2036
- // Will return:
2037
- {
2038
- from: '07/01/2020 00:00:00',
2039
- to: '09/30/2020 23:59:59'
2040
- }
2041
2133
 
2042
- // 3) Month:
2043
- getDateRange('Oct 2020', 'MONTH');
2044
- // Will return:
2045
- {
2046
- from: '10/01/2020 00:00:00',
2047
- to: '10/31/2020 23:59:59'
2048
- }
2049
- ```
2050
2134
 
2051
2135
 
2052
2136
  ##### Returns
2053
2137
 
2054
2138
 
2055
- - `Object` an object with the date range with two string date properties: from and to
2056
-
2139
+ - the last index of the array. -1 when the condition is not satisfied
2057
2140
 
2058
2141
 
2059
2142
 
2060
- ### dist/stencil/decorators/Config.js
2061
2143
 
2144
+ ### dist/typescript/decorators/Debounce.js
2062
2145
 
2063
- #### Config()
2064
2146
 
2065
- Stencil.js - Prop Decorator
2066
- Get and Parse the Widget Configuration Object and also provide the ability to get properties in different case styles such as: lower, upper, camel and pascal
2067
- But for this, is required ask for a property in `snake_case` style
2147
+ #### Debounce(time)
2068
2148
 
2149
+ (Method Decorator) Debounce Class Method
2069
2150
 
2070
2151
 
2071
2152
 
2072
2153
 
2154
+ ##### Parameters
2073
2155
 
2074
- ##### Examples
2156
+ | Name | Type | Description | |
2157
+ | ---- | ---- | ----------- | -------- |
2158
+ | time | | (optional) deafult 500 | &nbsp; |
2075
2159
 
2076
- ```javascript
2077
- \ @Config() @Prop() settings;
2078
2160
 
2079
- someMethod() {
2080
- this.settings.snake_case //it search for: obj.snake_case || obj.snakeCase || obj.SnakeCase || obj.snakecase || obj.SNAKECASE
2081
- }
2082
- ```
2083
2161
 
2084
2162
 
2085
2163
  ##### Returns
@@ -2090,14 +2168,21 @@ someMethod() {
2090
2168
 
2091
2169
 
2092
2170
 
2093
- ### dist/stencil/util/createRef.js
2171
+ ### dist/typescript/decorators/Throttled.js
2094
2172
 
2095
2173
 
2096
- #### createRef()
2174
+ #### Throttled(time)
2175
+
2176
+ (Method Decorator) Throttled Class Method
2177
+
2097
2178
 
2098
- lit implementation of React createRef (https://reactjs.org/docs/refs-and-the-dom.html)
2099
2179
 
2100
2180
 
2181
+ ##### Parameters
2182
+
2183
+ | Name | Type | Description | |
2184
+ | ---- | ---- | ----------- | -------- |
2185
+ | time | | (optional) deafult 500 | &nbsp; |
2101
2186
 
2102
2187
 
2103
2188
 
@@ -2105,21 +2190,17 @@ lit implementation of React createRef (https://reactjs.org/docs/refs-and-the-dom
2105
2190
  ##### Returns
2106
2191
 
2107
2192
 
2108
- - function - Function to use in ref prop in html elements
2193
+ - `Void`
2109
2194
 
2110
2195
 
2111
2196
 
2112
2197
 
2113
- ### dist/stencil/util/getConfig.js
2198
+ ### dist/date/relative/helpers/formatStatement.js
2114
2199
 
2115
2200
 
2116
- #### getConfig(cfg)
2201
+ #### formatStatement(statement)
2117
2202
 
2118
- verify the Config object type and try to return a parsed Object
2119
- - In case _cfg_ is a string, first try to make a JSON parse in other case
2120
- try to find this string as a variable on Windows object
2121
- - If _cfg_ is a fuction, tis is invoked and parsed
2122
- - Finally, if is an object, _cfg_ is inmediatly returned
2203
+ Build a proper relative date statement type
2123
2204
 
2124
2205
 
2125
2206
 
@@ -2128,7 +2209,7 @@ try to find this string as a variable on Windows object
2128
2209
 
2129
2210
  | Name | Type | Description | |
2130
2211
  | ---- | ---- | ----------- | -------- |
2131
- | cfg | | | &nbsp; |
2212
+ | statement | `RelativeStatement` | | &nbsp; |
2132
2213
 
2133
2214
 
2134
2215
 
@@ -2136,17 +2217,17 @@ try to find this string as a variable on Windows object
2136
2217
  ##### Returns
2137
2218
 
2138
2219
 
2139
- - `Void`
2220
+ - `RelativeStatement`
2140
2221
 
2141
2222
 
2142
2223
 
2143
2224
 
2144
- ### dist/typescript/decorators/Debounce.js
2225
+ ### dist/date/relative/helpers/getStatementCase.js
2145
2226
 
2146
2227
 
2147
- #### Debounce(time)
2228
+ #### getStatementCase(includeCurrent, isCalendarDate)
2148
2229
 
2149
- (Method Decorator) Debounce Class Method
2230
+ Returns a number/constant that identifies a relative date case
2150
2231
 
2151
2232
 
2152
2233
 
@@ -2155,7 +2236,8 @@ try to find this string as a variable on Windows object
2155
2236
 
2156
2237
  | Name | Type | Description | |
2157
2238
  | ---- | ---- | ----------- | -------- |
2158
- | time | | (optional) deafult 500 | &nbsp; |
2239
+ | includeCurrent | `boolean` | | &nbsp; |
2240
+ | isCalendarDate | `boolean` | | &nbsp; |
2159
2241
 
2160
2242
 
2161
2243
 
@@ -2163,17 +2245,17 @@ try to find this string as a variable on Windows object
2163
2245
  ##### Returns
2164
2246
 
2165
2247
 
2166
- - `Void`
2248
+ - `number`
2167
2249
 
2168
2250
 
2169
2251
 
2170
2252
 
2171
- ### dist/typescript/decorators/Throttled.js
2253
+ ### dist/date/relative/helpers/parseDate.js
2172
2254
 
2173
2255
 
2174
- #### Throttled(time)
2256
+ #### parseDate(date)
2175
2257
 
2176
- (Method Decorator) Throttled Class Method
2258
+ Parses a string date and returns a dayjs date
2177
2259
 
2178
2260
 
2179
2261
 
@@ -2182,7 +2264,7 @@ try to find this string as a variable on Windows object
2182
2264
 
2183
2265
  | Name | Type | Description | |
2184
2266
  | ---- | ---- | ----------- | -------- |
2185
- | time | | (optional) deafult 500 | &nbsp; |
2267
+ | date | `string` `Dayjs` `Date` | | &nbsp; |
2186
2268
 
2187
2269
 
2188
2270
 
@@ -2190,7 +2272,7 @@ try to find this string as a variable on Windows object
2190
2272
  ##### Returns
2191
2273
 
2192
2274
 
2193
- - `Void`
2275
+ - `Dayjs` A dayjs date
2194
2276
 
2195
2277
 
2196
2278
 
@@ -3565,86 +3647,4 @@ Resolves conditions between UI flattened filter and given parameters
3565
3647
 
3566
3648
 
3567
3649
 
3568
- ### dist/date/relative/helpers/formatStatement.js
3569
-
3570
-
3571
- #### formatStatement(statement)
3572
-
3573
- Build a proper relative date statement type
3574
-
3575
-
3576
-
3577
-
3578
- ##### Parameters
3579
-
3580
- | Name | Type | Description | |
3581
- | ---- | ---- | ----------- | -------- |
3582
- | statement | `RelativeStatement` | | &nbsp; |
3583
-
3584
-
3585
-
3586
-
3587
- ##### Returns
3588
-
3589
-
3590
- - `RelativeStatement`
3591
-
3592
-
3593
-
3594
-
3595
- ### dist/date/relative/helpers/getStatementCase.js
3596
-
3597
-
3598
- #### getStatementCase(includeCurrent, isCalendarDate)
3599
-
3600
- Returns a number/constant that identifies a relative date case
3601
-
3602
-
3603
-
3604
-
3605
- ##### Parameters
3606
-
3607
- | Name | Type | Description | |
3608
- | ---- | ---- | ----------- | -------- |
3609
- | includeCurrent | `boolean` | | &nbsp; |
3610
- | isCalendarDate | `boolean` | | &nbsp; |
3611
-
3612
-
3613
-
3614
-
3615
- ##### Returns
3616
-
3617
-
3618
- - `number`
3619
-
3620
-
3621
-
3622
-
3623
- ### dist/date/relative/helpers/parseDate.js
3624
-
3625
-
3626
- #### parseDate(date)
3627
-
3628
- Parses a string date and returns a dayjs date
3629
-
3630
-
3631
-
3632
-
3633
- ##### Parameters
3634
-
3635
- | Name | Type | Description | |
3636
- | ---- | ---- | ----------- | -------- |
3637
- | date | `string` `Dayjs` `Date` | | &nbsp; |
3638
-
3639
-
3640
-
3641
-
3642
- ##### Returns
3643
-
3644
-
3645
- - `Dayjs` A dayjs date
3646
-
3647
-
3648
-
3649
-
3650
3650
  *Documentation generated with [doxdox](https://github.com/neogeek/doxdox).*
@@ -116,28 +116,28 @@ function mergeValues(filter1, filter2, overwrite = false) {
116
116
  let newValues = [];
117
117
  if (!overwrite) {
118
118
  if (isInValidator_1.isInValidator(filter1.validator)) {
119
- newValues = filter1.values.reduce((values, value1) => {
120
- const value2Index = filter2.values.findIndex(value2 => value2.anchor !== value1.anchor || value2.cursor !== value1.cursor || value2.includeCurrent !== value1.includeCurrent && value2.isCalendarDate !== value1.isCalendarDate || value2.number !== value1.number || value2.unit !== value1.unit);
121
- if (value2Index > -1) {
122
- values.push(filter2.values[value2Index]);
119
+ newValues = filter2.values.reduce((values, value2) => {
120
+ const value1Index = filter1.values.findIndex(value1 => value2.anchor === value1.anchor && value2.cursor === value1.cursor && value2.includeCurrent === value1.includeCurrent && value2.isCalendarDate === value1.isCalendarDate && value2.number === value1.number && value2.unit === value1.unit);
121
+ if (value1Index === -1) {
122
+ values.push(value2);
123
123
  }
124
124
  return values;
125
125
  }, filter1.values);
126
126
  }
127
127
  else if (isRangeValidator_1.isRangeValidator(filter1.validator)) {
128
- newValues = filter1.values.reduce((values, value1) => {
129
- const value2Index = filter2.values.findIndex(value2 => value2.max !== value1.max || value2.min !== value1.min);
130
- if (value2Index > -1) {
131
- values.push(filter2.values[value2Index]);
128
+ newValues = filter2.values.reduce((values, value2) => {
129
+ const value1Index = filter1.values.findIndex(value1 => value2.max === value1.max && value2.min === value1.min);
130
+ if (value1Index === -1) {
131
+ values.push(value2);
132
132
  }
133
133
  return values;
134
134
  }, filter1.values);
135
135
  }
136
136
  else if (isRegularValidator_1.isRegularValidator(filter1.validator) || isNullValidator_1.isNullValidator(filter1.validator)) {
137
- newValues = filter1.values.reduce((values, value1) => {
138
- const value2Index = filter2.values.findIndex(value2 => value2.imageUrl !== value1.imageUrl || value2.value !== value1.value);
139
- if (value2Index > -1) {
140
- values.push(filter2.values[value2Index]);
137
+ newValues = filter2.values.reduce((values, value2) => {
138
+ const value1Index = filter1.values.findIndex(value1 => value2.imageUrl === value1.imageUrl && value2.value === value1.value);
139
+ if (value1Index === -1) {
140
+ values.push(value2);
141
141
  }
142
142
  return values;
143
143
  }, filter1.values);
@@ -112,28 +112,28 @@ function mergeValues(filter1, filter2, overwrite = false) {
112
112
  let newValues = [];
113
113
  if (!overwrite) {
114
114
  if (isInValidator(filter1.validator)) {
115
- newValues = filter1.values.reduce((values, value1) => {
116
- const value2Index = filter2.values.findIndex(value2 => value2.anchor !== value1.anchor || value2.cursor !== value1.cursor || value2.includeCurrent !== value1.includeCurrent && value2.isCalendarDate !== value1.isCalendarDate || value2.number !== value1.number || value2.unit !== value1.unit);
117
- if (value2Index > -1) {
118
- values.push(filter2.values[value2Index]);
115
+ newValues = filter2.values.reduce((values, value2) => {
116
+ const value1Index = filter1.values.findIndex(value1 => value2.anchor === value1.anchor && value2.cursor === value1.cursor && value2.includeCurrent === value1.includeCurrent && value2.isCalendarDate === value1.isCalendarDate && value2.number === value1.number && value2.unit === value1.unit);
117
+ if (value1Index === -1) {
118
+ values.push(value2);
119
119
  }
120
120
  return values;
121
121
  }, filter1.values);
122
122
  }
123
123
  else if (isRangeValidator(filter1.validator)) {
124
- newValues = filter1.values.reduce((values, value1) => {
125
- const value2Index = filter2.values.findIndex(value2 => value2.max !== value1.max || value2.min !== value1.min);
126
- if (value2Index > -1) {
127
- values.push(filter2.values[value2Index]);
124
+ newValues = filter2.values.reduce((values, value2) => {
125
+ const value1Index = filter1.values.findIndex(value1 => value2.max === value1.max && value2.min === value1.min);
126
+ if (value1Index === -1) {
127
+ values.push(value2);
128
128
  }
129
129
  return values;
130
130
  }, filter1.values);
131
131
  }
132
132
  else if (isRegularValidator(filter1.validator) || isNullValidator(filter1.validator)) {
133
- newValues = filter1.values.reduce((values, value1) => {
134
- const value2Index = filter2.values.findIndex(value2 => value2.imageUrl !== value1.imageUrl || value2.value !== value1.value);
135
- if (value2Index > -1) {
136
- values.push(filter2.values[value2Index]);
133
+ newValues = filter2.values.reduce((values, value2) => {
134
+ const value1Index = filter1.values.findIndex(value1 => value2.imageUrl === value1.imageUrl && value2.value === value1.value);
135
+ if (value1Index === -1) {
136
+ values.push(value2);
137
137
  }
138
138
  return values;
139
139
  }, filter1.values);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qrvey/utils",
3
- "version": "1.1.7",
3
+ "version": "1.1.8",
4
4
  "description": "Helper, Utils for all Qrvey Projects",
5
5
  "homepage": "https://bitbucket.org/qrvey/qrvey_utils/wiki/Home",
6
6
  "main": "dist/index.js",
@@ -124,26 +124,26 @@ function mergeValues(filter1: IFSFilter, filter2: IFSFilter, overwrite = false):
124
124
  let newValues = [];
125
125
  if (!overwrite) {
126
126
  if (isInValidator(filter1.validator)) {
127
- newValues = filter1.values.reduce((values: IFValue[], value1: IFSValueRelativeDate) => {
128
- const value2Index = (filter2.values as IFSValueRelativeDate[]).findIndex(value2 => value2.anchor !== value1.anchor || value2.cursor !== value1.cursor || value2.includeCurrent !== value1.includeCurrent && value2.isCalendarDate !== value1.isCalendarDate || value2.number !== value1.number || value2.unit !== value1.unit);
129
- if (value2Index > -1) {
130
- values.push(filter2.values[value2Index]);
127
+ newValues = filter2.values.reduce((values: IFValue[], value2: IFSValueRelativeDate) => {
128
+ const value1Index = (filter1.values as IFSValueRelativeDate[]).findIndex(value1 => value2.anchor === value1.anchor && value2.cursor === value1.cursor && value2.includeCurrent === value1.includeCurrent && value2.isCalendarDate === value1.isCalendarDate && value2.number === value1.number && value2.unit === value1.unit);
129
+ if (value1Index === -1) {
130
+ values.push(value2);
131
131
  }
132
132
  return values;
133
133
  }, filter1.values as IFValue[]);
134
134
  } else if (isRangeValidator(filter1.validator)) {
135
- newValues = filter1.values.reduce((values: IFValue[], value1: IFSValueRange) => {
136
- const value2Index = (filter2.values as IFSValueRange[]).findIndex(value2 => value2.max !== value1.max || value2.min !== value1.min);
137
- if (value2Index > -1) {
138
- values.push(filter2.values[value2Index]);
135
+ newValues = filter2.values.reduce((values: IFValue[], value2: IFSValueRange) => {
136
+ const value1Index = (filter1.values as IFSValueRange[]).findIndex(value1 => value2.max === value1.max && value2.min === value1.min);
137
+ if (value1Index === -1) {
138
+ values.push(value2);
139
139
  }
140
140
  return values;
141
141
  }, filter1.values as IFValue[]);
142
142
  } else if (isRegularValidator(filter1.validator) || isNullValidator(filter1.validator)) {
143
- newValues = filter1.values.reduce((values: IFValue[], value1: IFSValue) => {
144
- const value2Index = (filter2.values as IFSValue[]).findIndex(value2 => value2.imageUrl !== value1.imageUrl || value2.value !== value1.value);
145
- if (value2Index > -1) {
146
- values.push(filter2.values[value2Index]);
143
+ newValues = filter2.values.reduce((values: IFValue[], value2: IFSValue) => {
144
+ const value1Index = (filter1.values as IFSValue[]).findIndex(value1 => value2.imageUrl === value1.imageUrl && value2.value === value1.value);
145
+ if (value1Index === -1) {
146
+ values.push(value2);
147
147
  }
148
148
  return values;
149
149
  }, filter1.values as IFValue[]);