@sme.up/ketchup 5.2.0-SNAPSHOT → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (214) hide show
  1. package/dist/cjs/{cell-utils-5b16c180.js → cell-utils-a78d6fac.js} +2 -2
  2. package/dist/cjs/{component-d1496215.js → component-72a5b626.js} +30 -0
  3. package/dist/cjs/{f-button-3b9f32af.js → f-button-ac179257.js} +2 -2
  4. package/dist/cjs/{f-cell-c6ad973a.js → f-cell-69294bca.js} +33 -121
  5. package/dist/cjs/{f-chip-bed86c4a.js → f-chip-b00897d7.js} +5 -4
  6. package/dist/cjs/{f-image-08a3d340.js → f-image-89f25556.js} +2 -2
  7. package/dist/cjs/f-paginator-utils-8fa501b3.js +1898 -0
  8. package/dist/cjs/f-text-field-e1e45ade.js +94 -0
  9. package/dist/cjs/f-text-field-mdc-85997738.js +2570 -0
  10. package/dist/cjs/{index-8d7bb3be.js → index-eb556444.js} +2 -0
  11. package/dist/cjs/ketchup.cjs.js +3 -3
  12. package/dist/cjs/kup-accordion.cjs.entry.js +5 -5
  13. package/dist/cjs/{kup-autocomplete_27.cjs.entry.js → kup-autocomplete_25.cjs.entry.js} +1788 -8378
  14. package/dist/cjs/{kup-echart.cjs.entry.js → kup-box_2.cjs.entry.js} +17102 -14788
  15. package/dist/cjs/kup-calendar.cjs.entry.js +42 -34
  16. package/dist/cjs/kup-cell.cjs.entry.js +8 -7
  17. package/dist/cjs/kup-dash-list.cjs.entry.js +4 -4
  18. package/dist/cjs/kup-dash_2.cjs.entry.js +3 -3
  19. package/dist/cjs/kup-drawer.cjs.entry.js +12 -5
  20. package/dist/cjs/kup-field.cjs.entry.js +2 -2
  21. package/dist/cjs/kup-form-editor.cjs.entry.js +404 -0
  22. package/dist/cjs/kup-iframe.cjs.entry.js +3 -3
  23. package/dist/cjs/kup-image-list.cjs.entry.js +228 -0
  24. package/dist/cjs/kup-lazy.cjs.entry.js +3 -3
  25. package/dist/cjs/kup-magic-box.cjs.entry.js +4 -4
  26. package/dist/cjs/kup-manager-7a941909.js +16703 -0
  27. package/dist/cjs/kup-nav-bar.cjs.entry.js +3 -3
  28. package/dist/cjs/kup-numeric-picker.cjs.entry.js +423 -0
  29. package/dist/cjs/kup-photo-frame.cjs.entry.js +5 -5
  30. package/dist/cjs/kup-probe.cjs.entry.js +2 -2
  31. package/dist/cjs/kup-qlik.cjs.entry.js +2 -2
  32. package/dist/cjs/kup-snackbar.cjs.entry.js +6 -6
  33. package/dist/cjs/loader.cjs.js +3 -3
  34. package/dist/cjs/{utils-b9df398c.js → utils-6287d878.js} +1 -1
  35. package/dist/collection/assets/card.js +4 -5
  36. package/dist/collection/assets/data-table.js +44 -79
  37. package/dist/collection/assets/form-editor.js +338 -0
  38. package/dist/collection/assets/image-list.js +624 -0
  39. package/dist/collection/assets/index.js +16 -0
  40. package/dist/collection/assets/kupdata.js +0 -3
  41. package/dist/collection/assets/kuptooltip.js +654 -0
  42. package/dist/collection/assets/tree.js +0 -128
  43. package/dist/collection/collection-manifest.json +8 -6
  44. package/dist/collection/components/kup-autocomplete/kup-autocomplete.js +1 -1
  45. package/dist/collection/components/kup-box/kup-box-declarations.js +0 -4
  46. package/dist/collection/components/kup-box/kup-box.js +7 -135
  47. package/dist/collection/components/kup-card/built-in/kup-card-built-in.js +10 -0
  48. package/dist/collection/components/kup-card/built-in/kup-card-clock.js +1 -1
  49. package/dist/collection/components/kup-card/built-in/kup-card-column-drop-menu.js +1 -2
  50. package/dist/collection/components/kup-card/built-in/kup-card-numeric.js +153 -0
  51. package/dist/collection/components/kup-card/kup-card.css +61 -8
  52. package/dist/collection/components/kup-card/kup-card.js +2 -2
  53. package/dist/collection/components/kup-card/standard/kup-card-standard.js +14 -6
  54. package/dist/collection/components/kup-combobox/kup-combobox.js +1 -1
  55. package/dist/collection/components/kup-data-table/kup-data-table-declarations.js +1 -3
  56. package/dist/collection/components/kup-data-table/kup-data-table-state.js +1 -1
  57. package/dist/collection/components/kup-data-table/kup-data-table.js +50 -138
  58. package/dist/collection/components/kup-date-picker/kup-date-picker.js +1 -1
  59. package/dist/collection/components/kup-drawer/kup-drawer.css +1 -0
  60. package/dist/collection/components/kup-drawer/kup-drawer.js +8 -1
  61. package/dist/collection/components/kup-form-editor/kup-form-editor-declarations.js +23 -0
  62. package/dist/collection/components/kup-form-editor/kup-form-editor.css +80 -0
  63. package/dist/collection/components/kup-form-editor/kup-form-editor.js +561 -0
  64. package/dist/collection/components/kup-image-list/kup-image-list-declarations.js +10 -0
  65. package/dist/collection/components/kup-image-list/kup-image-list.css +166 -0
  66. package/dist/collection/components/kup-image-list/kup-image-list.js +432 -0
  67. package/dist/collection/components/kup-numeric-picker/kup-numeric-picker-declarations.js +16 -0
  68. package/dist/collection/components/kup-numeric-picker/kup-numeric-picker.css +50 -0
  69. package/dist/collection/components/kup-numeric-picker/kup-numeric-picker.js +895 -0
  70. package/dist/collection/components/kup-photo-frame/kup-photo-frame.css +3 -13
  71. package/dist/collection/components/kup-photo-frame/kup-photo-frame.js +1 -1
  72. package/dist/collection/components/kup-snackbar/kup-snackbar.css +4 -0
  73. package/dist/collection/components/kup-tab-bar/kup-tab-bar.js +18 -19
  74. package/dist/collection/components/kup-time-picker/kup-time-picker.js +2 -2
  75. package/dist/collection/components/kup-tree/kup-tree-declarations.js +0 -4
  76. package/dist/collection/components/kup-tree/kup-tree.css +10 -3
  77. package/dist/collection/components/kup-tree/kup-tree.js +81 -145
  78. package/dist/collection/f-components/f-cell/f-cell.js +7 -7
  79. package/dist/collection/f-components/f-chip/f-chip.js +2 -1
  80. package/dist/collection/managers/kup-data/kup-data-node-helper.js +24 -0
  81. package/dist/collection/managers/kup-data/kup-data.js +4 -1
  82. package/dist/collection/managers/kup-debug/kup-debug.js +1 -0
  83. package/dist/collection/managers/kup-dynamic-position/kup-dynamic-position.js +4 -2
  84. package/dist/collection/managers/kup-interact/kup-interact.js +1 -22
  85. package/dist/collection/managers/kup-language/kup-language-declarations.js +2 -0
  86. package/dist/collection/managers/kup-manager/kup-manager.js +31 -1
  87. package/dist/collection/managers/kup-math/kup-math.js +11 -1
  88. package/dist/collection/managers/kup-theme/kup-theme-declarations.js +6 -0
  89. package/dist/collection/managers/kup-tooltip/kup-tooltip-declarations.js +1 -0
  90. package/dist/collection/managers/kup-tooltip/kup-tooltip.js +224 -0
  91. package/dist/collection/types/GenericTypes.js +3 -0
  92. package/dist/collection/utils/kup-column-menu/kup-column-menu.js +8 -12
  93. package/dist/esm/{cell-utils-69f75e2e.js → cell-utils-964da6b5.js} +3 -3
  94. package/dist/esm/{component-c4eb6153.js → component-b1bedf1d.js} +27 -2
  95. package/dist/esm/{f-button-7e7607d8.js → f-button-871a544b.js} +2 -2
  96. package/dist/esm/{f-cell-e4d83c27.js → f-cell-521ef17a.js} +33 -120
  97. package/dist/esm/{f-chip-51dfefaf.js → f-chip-1dda722f.js} +6 -5
  98. package/dist/esm/{f-image-de331954.js → f-image-c468d8ae.js} +2 -2
  99. package/dist/esm/f-paginator-utils-7dff8ff0.js +1884 -0
  100. package/dist/esm/f-text-field-d6c61c73.js +92 -0
  101. package/dist/esm/f-text-field-mdc-d42d3f9e.js +2568 -0
  102. package/dist/esm/{index-aeec9835.js → index-baeab1ac.js} +2 -1
  103. package/dist/esm/ketchup.js +3 -3
  104. package/dist/esm/kup-accordion.entry.js +6 -6
  105. package/dist/esm/{kup-autocomplete_27.entry.js → kup-autocomplete_25.entry.js} +1724 -8312
  106. package/dist/esm/{kup-echart.entry.js → kup-box_2.entry.js} +17102 -14789
  107. package/dist/esm/kup-calendar.entry.js +43 -35
  108. package/dist/esm/kup-cell.entry.js +8 -7
  109. package/dist/esm/kup-dash-list.entry.js +4 -4
  110. package/dist/esm/kup-dash_2.entry.js +3 -3
  111. package/dist/esm/kup-drawer.entry.js +12 -5
  112. package/dist/esm/kup-field.entry.js +2 -2
  113. package/dist/esm/kup-form-editor.entry.js +400 -0
  114. package/dist/esm/kup-iframe.entry.js +3 -3
  115. package/dist/esm/kup-image-list.entry.js +224 -0
  116. package/dist/esm/kup-lazy.entry.js +3 -3
  117. package/dist/esm/kup-magic-box.entry.js +4 -4
  118. package/dist/esm/kup-manager-58b075b4.js +16686 -0
  119. package/dist/esm/kup-nav-bar.entry.js +3 -3
  120. package/dist/esm/kup-numeric-picker.entry.js +419 -0
  121. package/dist/esm/kup-photo-frame.entry.js +5 -5
  122. package/dist/esm/kup-probe.entry.js +2 -2
  123. package/dist/esm/kup-qlik.entry.js +2 -2
  124. package/dist/esm/kup-snackbar.entry.js +6 -6
  125. package/dist/esm/loader.js +3 -3
  126. package/dist/esm/polyfills/css-shim.js +1 -1
  127. package/dist/esm/{tslib.es6-8f2d44b6.js → tslib.es6-3eea2234.js} +1 -1
  128. package/dist/esm/{utils-35c7a90d.js → utils-d7e4b3c2.js} +2 -2
  129. package/dist/ketchup/ketchup.esm.js +1 -1
  130. package/dist/ketchup/{p-5d190cf5.js → p-1ae66cc5.js} +1 -1
  131. package/dist/ketchup/{p-8be1337b.js → p-34b74425.js} +1 -1
  132. package/dist/ketchup/{p-fea316ab.entry.js → p-3c11e615.entry.js} +1 -1
  133. package/dist/ketchup/p-44ec4f03.js +1 -0
  134. package/dist/ketchup/p-4ffbc3ff.js +1 -0
  135. package/dist/ketchup/p-5264a3e6.entry.js +1 -0
  136. package/dist/ketchup/{p-d7af8156.entry.js → p-65974e48.entry.js} +1 -1
  137. package/dist/ketchup/p-65b46587.entry.js +40 -0
  138. package/dist/ketchup/{p-3813281b.entry.js → p-6dff70f8.entry.js} +1 -1
  139. package/dist/ketchup/{p-33073f4a.js → p-7454cb92.js} +1 -1
  140. package/dist/ketchup/{p-a0b1d769.js → p-79b0730b.js} +1 -1
  141. package/dist/ketchup/p-7eff4eee.js +1 -0
  142. package/dist/ketchup/p-80968627.entry.js +1 -0
  143. package/dist/ketchup/{p-8c44c3b9.js → p-81605f08.js} +4 -5
  144. package/dist/ketchup/p-8cdf61a4.js +1 -0
  145. package/dist/ketchup/{p-f9c41e20.entry.js → p-954cc340.entry.js} +1 -1
  146. package/dist/ketchup/p-99e0d768.entry.js +1 -0
  147. package/dist/ketchup/{p-8f735633.entry.js → p-a0f6e25c.entry.js} +1 -1
  148. package/dist/ketchup/p-a203f78b.js +45 -0
  149. package/dist/ketchup/{p-9bcda66f.entry.js → p-a615a92b.entry.js} +1 -1
  150. package/dist/ketchup/p-aca0e54b.js +30 -0
  151. package/dist/ketchup/p-b8939a8b.entry.js +1 -0
  152. package/dist/ketchup/p-bfc3bac7.js +1 -0
  153. package/dist/ketchup/{p-67c64257.entry.js → p-c5ce8951.entry.js} +1 -1
  154. package/dist/ketchup/p-cad1e097.entry.js +9 -0
  155. package/dist/ketchup/{p-68fc1428.entry.js → p-d2ee56dd.entry.js} +1 -1
  156. package/dist/ketchup/p-db71436b.entry.js +27 -0
  157. package/dist/ketchup/{p-10c8d755.js → p-e0035c58.js} +1 -1
  158. package/dist/ketchup/p-e1039cf2.entry.js +1 -0
  159. package/dist/ketchup/{p-b5e1dbfa.entry.js → p-ea10176c.entry.js} +1 -1
  160. package/dist/ketchup/p-f09f2f98.entry.js +1 -0
  161. package/dist/ketchup/{p-0751aaf6.entry.js → p-f71a1675.entry.js} +1 -1
  162. package/dist/ketchup/{p-4081f5f7.entry.js → p-fac1a08b.entry.js} +1 -1
  163. package/dist/types/components/kup-box/kup-box-declarations.d.ts +3 -5
  164. package/dist/types/components/kup-box/kup-box.d.ts +0 -22
  165. package/dist/types/components/kup-card/built-in/kup-card-built-in.d.ts +7 -0
  166. package/dist/types/components/kup-card/built-in/kup-card-numeric.d.ts +2 -0
  167. package/dist/types/components/kup-card/kup-card-declarations.d.ts +26 -1
  168. package/dist/types/components/kup-data-table/kup-data-table-declarations.d.ts +4 -4
  169. package/dist/types/components/kup-data-table/kup-data-table-state.d.ts +1 -1
  170. package/dist/types/components/kup-data-table/kup-data-table.d.ts +5 -19
  171. package/dist/types/components/kup-form-editor/kup-form-editor-declarations.d.ts +79 -0
  172. package/dist/types/components/kup-form-editor/kup-form-editor.d.ts +72 -0
  173. package/dist/types/components/kup-image-list/kup-image-list-declarations.d.ts +14 -0
  174. package/dist/types/components/kup-image-list/kup-image-list.d.ts +56 -0
  175. package/dist/types/components/kup-numeric-picker/kup-numeric-picker-declarations.d.ts +19 -0
  176. package/dist/types/components/kup-numeric-picker/kup-numeric-picker.d.ts +121 -0
  177. package/dist/types/components/kup-tab-bar/kup-tab-bar-declarations.d.ts +3 -9
  178. package/dist/types/components/kup-tab-bar/kup-tab-bar.d.ts +6 -6
  179. package/dist/types/components/kup-tree/kup-tree-declarations.d.ts +1 -5
  180. package/dist/types/components/kup-tree/kup-tree.d.ts +1 -25
  181. package/dist/types/components.d.ts +265 -232
  182. package/dist/types/managers/kup-data/kup-data-declarations.d.ts +1 -0
  183. package/dist/types/managers/kup-data/kup-data-node-helper.d.ts +7 -0
  184. package/dist/types/managers/kup-data/kup-data.d.ts +1 -0
  185. package/dist/types/managers/kup-language/kup-language-declarations.d.ts +2 -0
  186. package/dist/types/managers/kup-manager/kup-manager-declarations.d.ts +14 -0
  187. package/dist/types/managers/kup-manager/kup-manager.d.ts +14 -0
  188. package/dist/types/managers/kup-math/kup-math-declarations.d.ts +6 -0
  189. package/dist/types/managers/kup-math/kup-math.d.ts +2 -1
  190. package/dist/types/managers/kup-tooltip/kup-tooltip-declarations.d.ts +8 -0
  191. package/dist/types/managers/kup-tooltip/kup-tooltip.d.ts +51 -0
  192. package/dist/types/types/GenericTypes.d.ts +3 -0
  193. package/dist/types/utils/kup-column-menu/kup-column-menu.d.ts +1 -3
  194. package/package.json +16 -15
  195. package/dist/cjs/kup-manager-4227f0a2.js +0 -8582
  196. package/dist/collection/assets/tooltip.js +0 -73
  197. package/dist/collection/components/kup-tooltip/kup-tooltip-declarations.js +0 -20
  198. package/dist/collection/components/kup-tooltip/kup-tooltip.css +0 -149
  199. package/dist/collection/components/kup-tooltip/kup-tooltip.js +0 -1205
  200. package/dist/collection/utils/helpers.js +0 -38
  201. package/dist/esm/kup-manager-0ab94726.js +0 -8565
  202. package/dist/ketchup/p-24df4f29.entry.js +0 -27
  203. package/dist/ketchup/p-2d4f19f4.js +0 -1
  204. package/dist/ketchup/p-3445be1e.entry.js +0 -1
  205. package/dist/ketchup/p-3aab1f0d.entry.js +0 -1
  206. package/dist/ketchup/p-47b57d97.js +0 -1
  207. package/dist/ketchup/p-5186885c.entry.js +0 -1
  208. package/dist/ketchup/p-78223dc0.entry.js +0 -143
  209. package/dist/ketchup/p-96101f09.entry.js +0 -39
  210. package/dist/ketchup/p-c314b1e6.js +0 -1
  211. package/dist/ketchup/p-ee33cbe9.js +0 -9
  212. package/dist/types/components/kup-tooltip/kup-tooltip-declarations.d.ts +0 -93
  213. package/dist/types/components/kup-tooltip/kup-tooltip.d.ts +0 -142
  214. package/dist/types/utils/helpers.d.ts +0 -4
@@ -0,0 +1,1898 @@
1
+ 'use strict';
2
+
3
+ const kupManager = require('./kup-manager-7a941909.js');
4
+ const utils = require('./utils-6287d878.js');
5
+ const cellUtils = require('./cell-utils-a78d6fac.js');
6
+ const index = require('./index-eb556444.js');
7
+ const fButton = require('./f-button-ac179257.js');
8
+ const fButtonDeclarations = require('./f-button-declarations-b611587f.js');
9
+
10
+ /**
11
+ * Interface for ranged filters.
12
+ */
13
+ exports.FilterInterval = void 0;
14
+ (function (FilterInterval) {
15
+ FilterInterval[FilterInterval["FROM"] = 0] = "FROM";
16
+ FilterInterval[FilterInterval["TO"] = 1] = "TO";
17
+ })(exports.FilterInterval || (exports.FilterInterval = {}));
18
+ /**
19
+ * This regular expressions returns a match like this one:
20
+ * if the string does not match is null, otherwise the indexes are equal to the object below:
21
+ *
22
+ * @property {string} 0 - The entire match of the regexp; is equal to the cellValue.
23
+ * @property {string} 1 - Either !' or ' it's the start of the regexp.
24
+ * @property {string} 2 - Either % or null: means the string must start with the given string.
25
+ * @property {string} 3 - Either "" or a string with a length.
26
+ * @property {string} 4 - Either % or null: means the string must finish with the given string.
27
+ * @property {string} 5 - Always equal to ': it's the end of the filter.
28
+ */
29
+ const FILTER_ANALIZER = /^('|!')(%){0,1}(.*?)(%){0,1}(')$/;
30
+ exports.KupGlobalFilterMode = void 0;
31
+ (function (KupGlobalFilterMode) {
32
+ KupGlobalFilterMode["SIMPLE"] = "simple";
33
+ KupGlobalFilterMode["HIGHLIGHT"] = "highlight";
34
+ })(exports.KupGlobalFilterMode || (exports.KupGlobalFilterMode = {}));
35
+
36
+ const dom$3 = document.documentElement;
37
+ /**
38
+ * Filtering algorithms.
39
+ * @module Filters
40
+ * @todo Should contain EVERY filtering method in common between filtering types (i.e.: global filters and column menu filters).
41
+ */
42
+ class Filters {
43
+ /**
44
+ * Function used to check whether the component is a KupTree or KupDataTable.
45
+ * @param {KupDataTable | KupTree} comp - Component using the column menu.
46
+ * @returns {comp is KupTree} Returns true when the component is KupTree.
47
+ */
48
+ static isTree(comp) {
49
+ return comp.rootElement.tagName === kupManager.KupTagNames.TREE;
50
+ }
51
+ isObjFiltrableByInterval(obj) {
52
+ if (dom$3.ketchup.objects.isDate(obj)) {
53
+ return true;
54
+ }
55
+ if (dom$3.ketchup.objects.isTime(obj)) {
56
+ return true;
57
+ }
58
+ if (dom$3.ketchup.objects.isTimestamp(obj)) {
59
+ return true;
60
+ }
61
+ if (dom$3.ketchup.objects.isNumber(obj)) {
62
+ return true;
63
+ }
64
+ return false;
65
+ }
66
+ normalizeValue(value, smeupObj) {
67
+ let newValue = value != null ? value.trim() : value;
68
+ if (newValue == null || newValue == '' || smeupObj == null) {
69
+ return newValue;
70
+ }
71
+ if (dom$3.ketchup.objects.isDate(smeupObj)) {
72
+ if (dom$3.ketchup.dates.isValid(value, kupManager.KupDatesFormats.ISO_DATE)) {
73
+ return newValue;
74
+ }
75
+ if (dom$3.ketchup.dates.isValid(value)) {
76
+ return dom$3.ketchup.dates.format(dom$3.ketchup.dates.normalize(value, kupManager.KupDatesNormalize.DATE), kupManager.KupDatesFormats.ISO_DATE);
77
+ }
78
+ }
79
+ else if (dom$3.ketchup.objects.isTime(smeupObj)) {
80
+ let manageSeconds = dom$3.ketchup.objects.isTimeWithSeconds(smeupObj);
81
+ if (dom$3.ketchup.dates.isValid(value, manageSeconds
82
+ ? kupManager.KupDatesFormats.ISO_TIME
83
+ : kupManager.KupDatesFormats.ISO_TIME_WITHOUT_SECONDS)) {
84
+ return newValue;
85
+ }
86
+ if (utils.isValidFormattedStringTime(value, manageSeconds)) {
87
+ return utils.formattedStringToCustomUnformattedStringTime(value, manageSeconds
88
+ ? kupManager.KupDatesFormats.ISO_TIME
89
+ : kupManager.KupDatesFormats.ISO_TIME_WITHOUT_SECONDS, manageSeconds);
90
+ }
91
+ }
92
+ else if (dom$3.ketchup.objects.isTimestamp(smeupObj)) {
93
+ if (dom$3.ketchup.dates.isValid(value, kupManager.KupDatesFormats.ISO_DATE_TIME)) {
94
+ return newValue;
95
+ }
96
+ if (utils.isValidFormattedStringTime(value, true)) {
97
+ return utils.formattedStringToDefaultUnformattedStringTimestamp(value);
98
+ }
99
+ }
100
+ else if (dom$3.ketchup.objects.isNumber(smeupObj)) {
101
+ if (utils.isValidFormattedStringNumber(value, smeupObj ? smeupObj.p : '')) {
102
+ return utils.formattedStringToUnformattedStringNumber(value, smeupObj ? smeupObj.p : '');
103
+ }
104
+ }
105
+ return newValue;
106
+ }
107
+ /**
108
+ * Given a filter value, check if is a negative filter
109
+ * @param filterValue the filter value to use for check
110
+ */
111
+ filterIsNegative(filterValue) {
112
+ const analyzedFilter = filterValue.match(FILTER_ANALIZER);
113
+ const filterIsNegative = analyzedFilter
114
+ ? analyzedFilter[1].indexOf('!') >= 0
115
+ : false;
116
+ return filterIsNegative;
117
+ }
118
+ /**
119
+ * Given a value and a filter value, returns if that value matches the filter.
120
+ *
121
+ * Web filters can also be expressions: by putting strings between single quotes (') it's possible to activate filter expressions.
122
+ * Valid syntax:
123
+ * 'filter' = search for exact phrase;
124
+ * '' = match when value is empty;
125
+ * 'filter%' = match when a string starts with "filter";
126
+ * '%filter' = match when a string ends with "filter";
127
+ * '%filter%' = match when a string contains "filter".
128
+ *
129
+ * It is also possible to negate the expression by prepending "!" in front of the expression.
130
+ * For example: !'' = value in the cell must not be empty.
131
+ *
132
+ * With no expression set, the filter is by default set to '%filter%'.
133
+ *
134
+ * @param value - The current value to check.
135
+ * @param filterValue - The value of the current filter.
136
+ * @returns false if value or filterValue are empty;
137
+ true if value contains filterValue;
138
+ true if value matches special filter created on filterValue;
139
+ false otherwise.
140
+ */
141
+ isFilterCompliantForValue(value, filterValue) {
142
+ if (value == null) {
143
+ return false;
144
+ }
145
+ if (filterValue == null) {
146
+ return false;
147
+ }
148
+ const _filterIsNegative = this.filterIsNegative(filterValue);
149
+ // checks if the value of the filter is contained inside value of the object
150
+ // Or is if the filter is a special filter to be matched.
151
+ if (value.toLowerCase().includes(filterValue.toLowerCase()) ||
152
+ this.matchSpecialFilter(value.toLowerCase(), filterValue.toLowerCase().match(FILTER_ANALIZER), true)) {
153
+ // the element matches the field filter
154
+ if (_filterIsNegative) {
155
+ return false;
156
+ }
157
+ return true;
158
+ }
159
+ if (_filterIsNegative) {
160
+ return true;
161
+ }
162
+ return false;
163
+ }
164
+ /**
165
+ * Given a value and a filter value, returns if that value matches the filter.
166
+ *
167
+ * Web filters can also be expressions: by putting strings between single quotes (') it's possible to activate filter expressions.
168
+ * Valid syntax:
169
+ * 'filter' = search for exact phrase;
170
+ * '' = match when value is empty;
171
+ * 'filter%' = match when a string starts with "filter";
172
+ * '%filter' = match when a string ends with "filter";
173
+ * '%filter%' = match when a string contains "filter".
174
+ *
175
+ * It is also possible to negate the expression by prepending "!" in front of the expression.
176
+ * For example: !'' = value in the cell must not be empty.
177
+ *
178
+ * With no expression set, the filter is by default set to '%filter%'.
179
+ *
180
+ * @param value - The current value to check.
181
+ * @param parsedFilter - The value of the current filter.
182
+ * @param ignoreNegativeFlag = false - When set to true, the matcher will ignore the (!) operator; useful for global filter.
183
+ * @returns True if the filter is empty and the value of the cell is empty, false otherwise.
184
+ */
185
+ matchSpecialFilter(value, parsedFilter, ignoreNegativeFlag = false) {
186
+ if (parsedFilter != null) {
187
+ // endsWith and startWith are not supported by IE 11
188
+ // Check here https://www.w3schools.com/jsref/jsref_endswith.asp
189
+ const toRet = (parsedFilter[3] === '' && !value.trim()) ||
190
+ (!parsedFilter[2] &&
191
+ parsedFilter[4] &&
192
+ value.startsWith(parsedFilter[3])) ||
193
+ (parsedFilter[2] &&
194
+ !parsedFilter[4] &&
195
+ value.endsWith(parsedFilter[3])) ||
196
+ (!parsedFilter[2] &&
197
+ !parsedFilter[4] &&
198
+ value === parsedFilter[3]) ||
199
+ (parsedFilter[2] &&
200
+ parsedFilter[4] &&
201
+ value.indexOf(parsedFilter[3]) >= 0);
202
+ return !ignoreNegativeFlag
203
+ ? parsedFilter[1].indexOf('!') < 0
204
+ ? toRet
205
+ : !toRet
206
+ : toRet;
207
+ }
208
+ return false;
209
+ }
210
+ isFilterCompliantForSimpleValue(valueToCheck, obj, filterValue, interval) {
211
+ if (valueToCheck == null) {
212
+ return false;
213
+ }
214
+ filterValue = this.normalizeValue(filterValue, obj);
215
+ let value = valueToCheck;
216
+ let from = '';
217
+ let to = '';
218
+ if (interval != null) {
219
+ from = interval[exports.FilterInterval.FROM];
220
+ to = interval[exports.FilterInterval.TO];
221
+ }
222
+ let checkByRegularExpression = true;
223
+ if (dom$3.ketchup.objects.isNumber(obj)) {
224
+ value = utils.unformattedStringNumberToNumber(value, obj ? obj.p : '');
225
+ let valueNumber = utils.stringToNumber(value);
226
+ if (from != '') {
227
+ if (utils.isNumber(from)) {
228
+ checkByRegularExpression = false;
229
+ let fromNumber = utils.stringToNumber(from);
230
+ if (valueNumber < fromNumber) {
231
+ return false;
232
+ }
233
+ }
234
+ else {
235
+ filterValue = from;
236
+ }
237
+ }
238
+ if (to != '') {
239
+ if (utils.isNumber(to)) {
240
+ checkByRegularExpression = false;
241
+ let toNumber = utils.stringToNumber(to);
242
+ if (valueNumber > toNumber) {
243
+ return false;
244
+ }
245
+ }
246
+ else {
247
+ filterValue = to;
248
+ }
249
+ }
250
+ }
251
+ if (dom$3.ketchup.objects.isDate(obj) ||
252
+ dom$3.ketchup.objects.isTime(obj) ||
253
+ dom$3.ketchup.objects.isTimestamp(obj)) {
254
+ let valueDate = null;
255
+ let defaultFormat = kupManager.KupDatesFormats.ISO_DATE;
256
+ if (dom$3.ketchup.objects.isDate(obj)) {
257
+ defaultFormat = kupManager.KupDatesFormats.ISO_DATE;
258
+ }
259
+ else if (dom$3.ketchup.objects.isTime(obj)) {
260
+ defaultFormat = dom$3.ketchup.objects.isTimeWithSeconds(obj)
261
+ ? kupManager.KupDatesFormats.ISO_TIME
262
+ : kupManager.KupDatesFormats.ISO_TIME_WITHOUT_SECONDS;
263
+ }
264
+ else if (dom$3.ketchup.objects.isTimestamp(obj)) {
265
+ defaultFormat = kupManager.KupDatesFormats.ISO_DATE_TIME;
266
+ }
267
+ if (dom$3.ketchup.dates.isValid(value, defaultFormat, true)) {
268
+ valueDate = dom$3.ketchup.dates.toDate(value, defaultFormat);
269
+ }
270
+ if (from != '') {
271
+ if (valueDate != null &&
272
+ dom$3.ketchup.dates.isValid(from, defaultFormat, true)) {
273
+ checkByRegularExpression = false;
274
+ let fromDate = dom$3.ketchup.dates.toDate(from, defaultFormat);
275
+ if (valueDate < fromDate) {
276
+ return false;
277
+ }
278
+ }
279
+ else {
280
+ filterValue = from;
281
+ }
282
+ }
283
+ if (to != '') {
284
+ if (valueDate != null &&
285
+ dom$3.ketchup.dates.isValid(to, defaultFormat, true)) {
286
+ checkByRegularExpression = false;
287
+ let toDate = dom$3.ketchup.dates.toDate(to, defaultFormat);
288
+ if (valueDate > toDate) {
289
+ return false;
290
+ }
291
+ }
292
+ else {
293
+ filterValue = to;
294
+ }
295
+ }
296
+ if (!dom$3.ketchup.dates.isValid(filterValue, defaultFormat) &&
297
+ !dom$3.ketchup.dates.isValid(filterValue)) {
298
+ value = dom$3.ketchup.dates.format(value);
299
+ }
300
+ }
301
+ if (checkByRegularExpression) {
302
+ return this.isFilterCompliantForValue(value, filterValue);
303
+ }
304
+ return true;
305
+ }
306
+ static valuesArrayContainsValue(values, value) {
307
+ return Filters.indexOfValueInValuesArray(values, value) >= 0;
308
+ }
309
+ static indexOfValueInValuesArray(values, value) {
310
+ if (values == null || values.length < 1) {
311
+ return -1;
312
+ }
313
+ for (let i = 0; i < values.length; i++) {
314
+ if (values[i].value == value) {
315
+ return i;
316
+ }
317
+ }
318
+ return -1;
319
+ }
320
+ }
321
+
322
+ /**
323
+ * Filtering algorithms related to column menus.
324
+ * @module FiltersColumnMenu
325
+ * @todo Should contain EVERY column-specific filtering method.
326
+ */
327
+ class FiltersColumnMenu extends Filters {
328
+ /**
329
+ * Gets the value of the filter prop.
330
+ * @param {GenericFilter} filters - Filters of the component.
331
+ * @param {string} column - Name of the column.
332
+ * @returns {string} Value of the filter.
333
+ */
334
+ getTextFilterValue(filters = {}, column) {
335
+ return this._getTextFilterValue(filters, column, false);
336
+ }
337
+ /**
338
+ * Gets the value of the filter prop, set temporarly.
339
+ * @param {GenericFilter} filters - Filters of the component.
340
+ * @param {string} column - Name of the column.
341
+ * @returns {string} Value of the filter.
342
+ */
343
+ getTextFilterValueTmp(filters = {}, column) {
344
+ return this._getTextFilterValue(filters, column, true);
345
+ }
346
+ _getTextFilterValue(filters = {}, column, tmp) {
347
+ let value = '';
348
+ if (filters == null) {
349
+ return value;
350
+ }
351
+ let filter = filters[column];
352
+ if (filter == null) {
353
+ return value;
354
+ }
355
+ value = tmp ? filter.textFieldTmp : filter.textField;
356
+ return value;
357
+ }
358
+ /**
359
+ * Returns whether a column has filters or not.
360
+ * @param {GenericFilter} filters - Filters of the component.
361
+ * @param {KupDataColumn} column - Name of the column.
362
+ * @returns {boolean} True when a given column has filters.
363
+ */
364
+ hasFiltersForColumn(filters = {}, column) {
365
+ return this._hasFiltersForColumn(filters, column, false);
366
+ }
367
+ /**
368
+ * Returns whether a column has filters or not.
369
+ * @param {GenericFilter} filters - Filters of the component.
370
+ * @param {KupDataColumn} column - Name of the column.
371
+ * @returns {boolean} True when a given column has filters.
372
+ */
373
+ hasFiltersForColumnTmp(filters = {}, column) {
374
+ return this._hasFiltersForColumn(filters, column, true);
375
+ }
376
+ /**
377
+ * Returns whether a column has filters or not.
378
+ * @param {GenericFilter} filters - Filters of the component.
379
+ * @param {KupDataColumn} column - Name of the column.
380
+ * @returns {boolean} True when a given column has filters.
381
+ */
382
+ _hasFiltersForColumn(filters = {}, column, tmp) {
383
+ if (!column) {
384
+ return false;
385
+ }
386
+ let textfield = this._getTextFilterValue(filters, column.name, tmp);
387
+ if (textfield != null && textfield.trim() != '') {
388
+ return true;
389
+ }
390
+ if (this._hasIntervalTextFieldFilterValues(filters, column, tmp)) {
391
+ return true;
392
+ }
393
+ let checkboxes = this.getCheckBoxFilterValues(filters, column.name);
394
+ if (checkboxes == null || checkboxes.length < 1) {
395
+ return false;
396
+ }
397
+ return true;
398
+ }
399
+ /**
400
+ * Returns the values of column menu's checkboxes.
401
+ * @param {GenericFilter} filters - Filters of the component.
402
+ * @param {string} column - Name of the column.
403
+ * @returns {Array<string>} Array of checkboxes values.
404
+ */
405
+ getCheckBoxFilterValues(filters = {}, column) {
406
+ let values = [];
407
+ if (filters == null) {
408
+ return values;
409
+ }
410
+ let filter = filters[column];
411
+ if (filter == null) {
412
+ return values;
413
+ }
414
+ if (filter.checkBoxes == null) {
415
+ return values;
416
+ }
417
+ values = filter.checkBoxes;
418
+ return values;
419
+ }
420
+ /**
421
+ * Returns whether a text field should be a date or time picker.
422
+ * @param {GenericFilter} filters - Filters of the component.
423
+ * @param {KupDataColumn} column - Name of the column.
424
+ * @returns {boolean} True when the text field is a date or time picker.
425
+ */
426
+ hasIntervalTextFieldFilterValues(filters = {}, column) {
427
+ return this._hasIntervalTextFieldFilterValues(filters, column, false);
428
+ }
429
+ hasIntervalTextFieldFilterValuesTmp(filters = {}, column) {
430
+ return this._hasIntervalTextFieldFilterValues(filters, column, true);
431
+ }
432
+ _hasIntervalTextFieldFilterValues(filters = {}, column, tmp) {
433
+ if (column == null) {
434
+ return false;
435
+ }
436
+ if (!this.isColumnFiltrableByInterval(column)) {
437
+ return false;
438
+ }
439
+ let intervalFrom = this._getIntervalTextFieldFilterValue(filters, column.name, exports.FilterInterval.FROM, tmp);
440
+ if (intervalFrom != null && intervalFrom.trim() != '') {
441
+ return true;
442
+ }
443
+ let intervalTo = this._getIntervalTextFieldFilterValue(filters, column.name, exports.FilterInterval.TO, tmp);
444
+ if (intervalTo != null && intervalTo.trim() != '') {
445
+ return true;
446
+ }
447
+ return false;
448
+ }
449
+ /**
450
+ * Triggers when a new filter checkbox becomes checked.
451
+ * @param {GenericFilter} filters - Filters of the component.
452
+ * @param {string} column - Name of the column.
453
+ * @param {ValueDisplayedValue} newFilter - Added filter.
454
+ */
455
+ addCheckboxFilter(filters = {}, column, newFilterItem) {
456
+ if (filters == null) {
457
+ return;
458
+ }
459
+ let filter = filters[column];
460
+ if (filter == null) {
461
+ filter = {
462
+ textField: '',
463
+ textFieldTmp: '',
464
+ checkBoxes: [],
465
+ interval: null,
466
+ intervalTmp: null,
467
+ };
468
+ filters[column] = filter;
469
+ }
470
+ if (filter.checkBoxes == null) {
471
+ filter.checkBoxes = [];
472
+ }
473
+ if (newFilterItem == null || newFilterItem.value == null) {
474
+ filter.checkBoxes = [];
475
+ }
476
+ else {
477
+ if (!Filters.valuesArrayContainsValue(filter.checkBoxes, newFilterItem.value)) {
478
+ filter.checkBoxes[filter.checkBoxes.length] = newFilterItem;
479
+ }
480
+ }
481
+ }
482
+ /**
483
+ * Triggers when a filter checkbox becomes unchecked.
484
+ * @param {GenericFilter} filters - Filters of the component.
485
+ * @param {string} column - Name of the column.
486
+ * @param {string} remFilter - Removed filter.
487
+ */
488
+ removeCheckboxFilter(filters = {}, column, remFilter) {
489
+ if (filters == null || remFilter == null) {
490
+ return;
491
+ }
492
+ let filter = filters[column];
493
+ if (filter == null) {
494
+ return;
495
+ }
496
+ if (filter.checkBoxes == null) {
497
+ filter.checkBoxes = [];
498
+ }
499
+ let index = Filters.indexOfValueInValuesArray(filter.checkBoxes, remFilter);
500
+ if (index >= 0) {
501
+ let chs = [];
502
+ for (let i = 0; i < filter.checkBoxes.length; i++) {
503
+ if (i != index) {
504
+ chs[chs.length] = filter.checkBoxes[i];
505
+ }
506
+ }
507
+ filter.checkBoxes = [...chs];
508
+ }
509
+ }
510
+ isColumnFiltrableByInterval(column) {
511
+ return this.isObjFiltrableByInterval(column.obj);
512
+ }
513
+ getIntervalTextFieldFilterValues(filters = {}, column) {
514
+ return this._getIntervalTextFieldFilterValues(filters, column, false);
515
+ }
516
+ getIntervalTextFieldFilterValuesTmp(filters = {}, column) {
517
+ return this._getIntervalTextFieldFilterValues(filters, column, true);
518
+ }
519
+ _getIntervalTextFieldFilterValues(filters = {}, column, tmp) {
520
+ if (!this._hasIntervalTextFieldFilterValues(filters, column, tmp)) {
521
+ return ['', ''];
522
+ }
523
+ let values = [
524
+ this._getIntervalTextFieldFilterValue(filters, column.name, exports.FilterInterval.FROM, tmp),
525
+ this._getIntervalTextFieldFilterValue(filters, column.name, exports.FilterInterval.TO, tmp),
526
+ ];
527
+ return values;
528
+ }
529
+ getIntervalTextFieldFilterValue(filters = {}, column, index) {
530
+ return this._getIntervalTextFieldFilterValue(filters, column, index, false);
531
+ }
532
+ getIntervalTextFieldFilterValueTmp(filters = {}, column, index) {
533
+ return this._getIntervalTextFieldFilterValue(filters, column, index, true);
534
+ }
535
+ _getIntervalTextFieldFilterValue(filters = {}, column, index, tmp) {
536
+ let value = '';
537
+ if (filters == null) {
538
+ return value;
539
+ }
540
+ let filter = filters[column];
541
+ if (filter == null) {
542
+ return value;
543
+ }
544
+ if (tmp && filter.intervalTmp == null) {
545
+ return value;
546
+ }
547
+ if (!tmp && filter.interval == null) {
548
+ return value;
549
+ }
550
+ value = tmp ? filter.intervalTmp[index] : filter.interval[index];
551
+ return value;
552
+ }
553
+ setTextFieldFilterValue(filters = {}, column, newFilter) {
554
+ this._setTextFieldFilterValue(filters, column, newFilter, true);
555
+ }
556
+ _setTextFieldFilterValue(filters = {}, column, newFilter, tmp) {
557
+ if (filters == null) {
558
+ return;
559
+ }
560
+ let filter = filters[column];
561
+ if (filter == null) {
562
+ filter = {
563
+ textField: '',
564
+ textFieldTmp: '',
565
+ checkBoxes: [],
566
+ interval: null,
567
+ intervalTmp: null,
568
+ };
569
+ filters[column] = filter;
570
+ }
571
+ if (tmp) {
572
+ filter.textFieldTmp =
573
+ newFilter != null ? newFilter.trim() : newFilter;
574
+ }
575
+ else {
576
+ filter.textField = newFilter != null ? newFilter.trim() : newFilter;
577
+ }
578
+ }
579
+ setIntervalTextFieldFilterValue(filters = {}, column, newFilter, index) {
580
+ this._setIntervalTextFieldFilterValue(filters, column, newFilter, index, true);
581
+ }
582
+ _setIntervalTextFieldFilterValue(filters = {}, column, newFilter, index, tmp) {
583
+ if (filters == null) {
584
+ return;
585
+ }
586
+ let filter = filters[column];
587
+ if (filter == null) {
588
+ filter = {
589
+ textField: '',
590
+ textFieldTmp: '',
591
+ checkBoxes: [],
592
+ interval: null,
593
+ intervalTmp: null,
594
+ };
595
+ filters[column] = filter;
596
+ }
597
+ if (filter.interval == null) {
598
+ filter.interval = [];
599
+ filter.interval.push('', '');
600
+ }
601
+ if (filter.intervalTmp == null) {
602
+ filter.intervalTmp = [];
603
+ filter.intervalTmp.push('', '');
604
+ }
605
+ if (tmp) {
606
+ filter.intervalTmp[index] =
607
+ newFilter != null ? newFilter.trim() : newFilter;
608
+ }
609
+ else {
610
+ filter.interval[index] =
611
+ newFilter != null ? newFilter.trim() : newFilter;
612
+ }
613
+ }
614
+ saveTextualFilters(filters = {}, column) {
615
+ this._setTextFieldFilterValue(filters, column, this.getTextFilterValueTmp(filters, column), false);
616
+ this._setIntervalTextFieldFilterValue(filters, column, this.getIntervalTextFieldFilterValueTmp(filters, column, exports.FilterInterval.FROM), exports.FilterInterval.FROM, false);
617
+ this._setIntervalTextFieldFilterValue(filters, column, this.getIntervalTextFieldFilterValueTmp(filters, column, exports.FilterInterval.TO), exports.FilterInterval.TO, false);
618
+ }
619
+ resetTextualFilters(filters = {}, column) {
620
+ this._setTextFieldFilterValue(filters, column, this.getTextFilterValue(filters, column), true);
621
+ this._setIntervalTextFieldFilterValue(filters, column, this.getIntervalTextFieldFilterValue(filters, column, exports.FilterInterval.FROM), exports.FilterInterval.FROM, true);
622
+ this._setIntervalTextFieldFilterValue(filters, column, this.getIntervalTextFieldFilterValue(filters, column, exports.FilterInterval.TO), exports.FilterInterval.TO, true);
623
+ }
624
+ getFilterValueForTooltip(filters = {}, column) {
625
+ let txtFilter = this.getTextFilterValue(filters, column.name);
626
+ let interval = this.getIntervalTextFieldFilterValues(filters, column);
627
+ let chkFilters = this.getCheckBoxFilterValues(filters, column.name);
628
+ let separator = '';
629
+ let txtFiterRis = cellUtils.getValueForDisplay(txtFilter, column.obj, column.decimals);
630
+ if (txtFilter != '') {
631
+ separator = ' AND ';
632
+ }
633
+ if (interval[exports.FilterInterval.FROM] != '') {
634
+ txtFiterRis +=
635
+ separator +
636
+ '(>= ' +
637
+ cellUtils.getValueForDisplay(interval[exports.FilterInterval.FROM], column.obj, column.decimals) +
638
+ ')';
639
+ separator = ' AND ';
640
+ }
641
+ if (interval[exports.FilterInterval.TO] != '') {
642
+ txtFiterRis +=
643
+ separator +
644
+ '(<= ' +
645
+ cellUtils.getValueForDisplay(interval[exports.FilterInterval.TO], column.obj, column.decimals) +
646
+ ')';
647
+ separator = ' AND ';
648
+ }
649
+ separator = '';
650
+ let ris = '';
651
+ chkFilters.forEach((f) => {
652
+ ris += separator + cellUtils.getValueForDisplay2(f, column);
653
+ separator = ' OR ';
654
+ });
655
+ if (ris != '') {
656
+ ris = '(' + ris + ')';
657
+ if (txtFiterRis != '') {
658
+ ris = ' AND ' + ris;
659
+ }
660
+ }
661
+ ris = txtFiterRis + ris;
662
+ return ris;
663
+ }
664
+ /**
665
+ * Triggers when a filter must be removed, for column.
666
+ * @param {GenericFilter} filters - Filters of the component.
667
+ * @param {string} column - Name of the column.
668
+ */
669
+ removeFilter(filters = {}, column) {
670
+ filters[column] = {
671
+ textField: '',
672
+ textFieldTmp: '',
673
+ checkBoxes: [],
674
+ interval: null,
675
+ intervalTmp: null,
676
+ };
677
+ }
678
+ }
679
+
680
+ /**
681
+ * Props of the kup-tree component.
682
+ * Used to export every prop in an object.
683
+ */
684
+ exports.KupTreeProps = void 0;
685
+ (function (KupTreeProps) {
686
+ KupTreeProps["asAccordion"] = "When enabled, the first level of depth will give an accordion look to nodes.";
687
+ KupTreeProps["autoSelectionNodeMode"] = "Auto select programmatic selectic node";
688
+ KupTreeProps["columns"] = "The columns of the tree when tree visualization is active.";
689
+ KupTreeProps["customStyle"] = "Custom style of the component.";
690
+ KupTreeProps["data"] = "The json data used to populate the tree view: the basic, always visible tree nodes.";
691
+ KupTreeProps["density"] = "The density of the rows, defaults at 'medium' and can also be set to 'dense' or 'wide'.";
692
+ KupTreeProps["dynamicExpansionCallback"] = "Function that gets invoked when a new set of nodes must be loaded as children of a node. When useDynamicExpansion is set, the tree component will have two different behaviors depending on the value of this prop. If this prop is set to null, no callback to download data is available: the component will emit an event requiring the parent to load the children of the given node. If this prop is set to have a callback, then the component will automatically make requests to load children of a given node. After the load has been completed, a different event will be fired to alert the parent of the change.";
693
+ KupTreeProps["enableExtraColumns"] = "Enables adding extra columns.";
694
+ KupTreeProps["expanded"] = "Flag: the nodes of the whole tree must be already expanded upon loading. Disabled nodes do NOT get expanded.";
695
+ KupTreeProps["expansionMode"] = "Behavior of nodes' expansion: it can be chosen between expanding a node by clicking on the dropdown icon, or by clicking on the whole node.";
696
+ KupTreeProps["filters"] = "List of filters set by the user.";
697
+ KupTreeProps["globalFilter"] = "When set to true it activates the global filter.";
698
+ KupTreeProps["globalFilterValue"] = "The value of the global filter.";
699
+ KupTreeProps["globalFilterMode"] = "The mode of the global filter.";
700
+ KupTreeProps["removableColumns"] = "Sets the possibility to remove the selected column.";
701
+ KupTreeProps["preventXScroll"] = "Experimental feature: when active, the tree will try to prevent horizontal overflowing elements by setting a width on the content of the table cells. It works only on cells of the main column.";
702
+ KupTreeProps["ripple"] = "When enabled displays Material's ripple effect on nodes (only when no columns are displayed).";
703
+ KupTreeProps["scrollOnHover"] = "Activates the scroll on hover function.";
704
+ KupTreeProps["selectedNode"] = "An array of integers containing the path to a selected child. Groups up the properties SelFirst, SelItem, SelName.";
705
+ KupTreeProps["showColumns"] = "Shows the tree data as a table.";
706
+ KupTreeProps["showFilters"] = "When set to true enables the column filters.";
707
+ KupTreeProps["showFooter"] = "When set to true shows the footer.";
708
+ KupTreeProps["showHeader"] = "Flag: shows the header of the tree when the tree is displayed as a table.";
709
+ KupTreeProps["showIcons"] = "Shows the icons of the nodes.";
710
+ KupTreeProps["stateId"] = "";
711
+ KupTreeProps["store"] = "";
712
+ KupTreeProps["totals"] = "Defines the current totals options.";
713
+ KupTreeProps["useDynamicExpansion"] = "When the component must use the dynamic expansion feature to open its nodes, it means that not all the nodes of the tree have been passed inside the data property. Therefore, when expanding a node, the tree must emit an event (or run a given callback) and wait for the child nodes to be downloaded from the server.";
714
+ })(exports.KupTreeProps || (exports.KupTreeProps = {}));
715
+ /**
716
+ * The name of the constant used by the tree component to identify the main tree in column menu
717
+ * @constant
718
+ */
719
+ const treeMainColumnName = 'TREE_COLUMN';
720
+ exports.KupTreeExpansionMode = void 0;
721
+ (function (KupTreeExpansionMode) {
722
+ KupTreeExpansionMode["DROPDOWN"] = "dropdown";
723
+ KupTreeExpansionMode["NODE"] = "node";
724
+ })(exports.KupTreeExpansionMode || (exports.KupTreeExpansionMode = {}));
725
+
726
+ const dom$2 = document.documentElement;
727
+ const kupObjects = dom$2.ketchup
728
+ ? dom$2.ketchup.objects
729
+ : new kupManager.KupObjects();
730
+ /**
731
+ * Filtering algorithms related to data-table rows.
732
+ * @module FiltersRows
733
+ * @todo Should contain EVERY row-specific filtering method.
734
+ */
735
+ class FiltersRows extends Filters {
736
+ isFilterCompliantForCell(cellValue, filterValue, interval) {
737
+ if (!cellValue) {
738
+ return false;
739
+ }
740
+ return this.isFilterCompliantForSimpleValue(cellValue.value, cellValue.obj, filterValue, interval);
741
+ }
742
+ isFilterCompliantForCellObj(cellValue, filterValue, interval) {
743
+ if (!cellValue) {
744
+ return false;
745
+ }
746
+ if (!cellValue.obj) {
747
+ return false;
748
+ }
749
+ return this.isFilterCompliantForSimpleValue(cellValue.obj.k, cellValue.obj, filterValue, interval);
750
+ }
751
+ isRowCompliant(r, filters = {}, globalFilter = '', isUsingGlobalFilter = false, columns = [], columnFilters) {
752
+ return this.areCellsCompliant(r.cells, filters, globalFilter, isUsingGlobalFilter, columns, columnFilters);
753
+ }
754
+ areCellsCompliant(cells, filters = {}, globalFilter = '', isUsingGlobalFilter = false, columns = [], columnFilters) {
755
+ if (isUsingGlobalFilter) {
756
+ let retValue = true;
757
+ // There are no columns -> display element
758
+ if (columns && columns != null && columns.length > 0) {
759
+ retValue = false;
760
+ let _filterIsNegative = this.filterIsNegative(globalFilter);
761
+ // Search among all visible columns for the global filter
762
+ for (let i = 0; i < columns.length; i++) {
763
+ if (columns[i].visible == false) {
764
+ continue;
765
+ }
766
+ const cell = cells[columns[i].name];
767
+ if (cell == null) {
768
+ continue;
769
+ }
770
+ retValue = this.isFilterCompliantForValue(cell.value, globalFilter);
771
+ let displayedValue = cellUtils.getCellValueForDisplay(columns[i], cell);
772
+ if (displayedValue != cell.value) {
773
+ retValue =
774
+ retValue ||
775
+ this.isFilterCompliantForValue(displayedValue, globalFilter);
776
+ }
777
+ if (retValue == true && !_filterIsNegative) {
778
+ break;
779
+ }
780
+ if (retValue == false && _filterIsNegative) {
781
+ break;
782
+ }
783
+ }
784
+ }
785
+ if (!retValue) {
786
+ return false;
787
+ }
788
+ }
789
+ if (columnFilters == null) {
790
+ columnFilters = new FiltersColumnMenu();
791
+ }
792
+ // There are no filters to check -> the element is valid
793
+ if (!this.hasFilters(filters, columns, columnFilters)) {
794
+ return true;
795
+ }
796
+ let keys = Object.keys(filters);
797
+ // Filters
798
+ for (let i = 0; i < keys.length; i++) {
799
+ let key = keys[i];
800
+ const cell = cells[key];
801
+ if (!cell) {
802
+ return false;
803
+ }
804
+ let filterValue = columnFilters.getTextFilterValue(filters, key);
805
+ let interval = columnFilters.getIntervalTextFieldFilterValues(filters, cellUtils.getColumnByName(columns, key));
806
+ const _filterIsNegative = this.filterIsNegative(filterValue);
807
+ let b1 = this.isFilterCompliantForCell(cell, filterValue, interval);
808
+ let b2 = _filterIsNegative;
809
+ if (!kupObjects.isNumber(cell.obj) &&
810
+ !kupObjects.isDate(cell.obj) &&
811
+ !kupObjects.isTime(cell.obj) &&
812
+ !kupObjects.isTimestamp(cell.obj)) {
813
+ b2 = this.isFilterCompliantForCellObj(cell, filterValue, interval);
814
+ }
815
+ if (_filterIsNegative) {
816
+ if (!b1 || !b2) {
817
+ return false;
818
+ }
819
+ }
820
+ else {
821
+ if (!b1 && !b2) {
822
+ return false;
823
+ }
824
+ }
825
+ let filterValues = columnFilters.getCheckBoxFilterValues(filters, key);
826
+ if (filterValues.length == 0) {
827
+ continue;
828
+ }
829
+ let retValue = false;
830
+ for (let i = 0; i < filterValues.length; i++) {
831
+ let fv = filterValues[i];
832
+ if (fv == null || fv.value == null) {
833
+ continue;
834
+ }
835
+ if (cell.value != null) {
836
+ if (cell.value.toLowerCase().trim() ==
837
+ fv.value.toLowerCase().trim()) {
838
+ retValue = true;
839
+ break;
840
+ }
841
+ }
842
+ if (cell.obj != null) {
843
+ if (cell.obj.k.toLowerCase().trim() ==
844
+ fv.value.toLowerCase().trim()) {
845
+ retValue = true;
846
+ break;
847
+ }
848
+ }
849
+ }
850
+ if (!retValue) {
851
+ return false;
852
+ }
853
+ }
854
+ return true;
855
+ }
856
+ hasFilters(filters = {}, columns, columnFilters) {
857
+ if (filters == null) {
858
+ return false;
859
+ }
860
+ let keys = Object.keys(filters);
861
+ if (keys == null || keys.length < 1) {
862
+ return false;
863
+ }
864
+ if (columnFilters == null) {
865
+ columnFilters = new FiltersColumnMenu();
866
+ }
867
+ for (let i = 0; i < keys.length; i++) {
868
+ let key = keys[i];
869
+ let col = null;
870
+ if (key === treeMainColumnName) {
871
+ col = {
872
+ name: treeMainColumnName,
873
+ title: '',
874
+ };
875
+ }
876
+ else {
877
+ col = cellUtils.getColumnByName(columns, key);
878
+ }
879
+ if (columnFilters.hasFiltersForColumn(filters, col)) {
880
+ return true;
881
+ }
882
+ }
883
+ return false;
884
+ }
885
+ /**
886
+ * Filters the rows data of a data-table component according to the parameters
887
+ *
888
+ * @param rows - The data of the rows to filter.
889
+ * @param filters - The the filters for each column.
890
+ * @param globalFilter - A global filter applied to all columns.
891
+ * @param columns - The colmns on which the filter will take effect.
892
+ * @todo This function can be improved in its speed by a refactor in which from two different cycles of execution for
893
+ * single filters and global filter, all controls on a single column are done in a single cycle.
894
+ */
895
+ filterRows(rows = [], filters = {}, globalFilter = '', columns = [], columnFilters) {
896
+ if (!rows || rows == null) {
897
+ return [];
898
+ }
899
+ // There are rows to filter
900
+ let filteredRows = [];
901
+ const isUsingGlobalFilter = !!(globalFilter && columns);
902
+ if (this.hasFilters(filters, columns, columnFilters) ||
903
+ isUsingGlobalFilter) {
904
+ for (let i = 0; i < rows.length; i++) {
905
+ let r = rows[i];
906
+ if (this.isRowCompliant(r, filters, globalFilter, isUsingGlobalFilter, columns, columnFilters)) {
907
+ filteredRows[filteredRows.length] = r;
908
+ }
909
+ }
910
+ }
911
+ else {
912
+ filteredRows = [...rows];
913
+ }
914
+ return filteredRows;
915
+ }
916
+ getColumnValues(comp, column, globalFilterValue, columnFilters) {
917
+ let values = new Array();
918
+ if (columnFilters == null) {
919
+ columnFilters = new FiltersColumnMenu();
920
+ }
921
+ let value = columnFilters.getTextFilterValueTmp(comp.filters, column.name);
922
+ let interval = columnFilters.getIntervalTextFieldFilterValuesTmp(comp.filters, column);
923
+ let checkboxes = columnFilters.getCheckBoxFilterValues(comp.filters, column.name);
924
+ if (column.valuesForFilter != null &&
925
+ column.valuesForFilter.length > 0) {
926
+ column.valuesForFilter.forEach((element) => {
927
+ let v = element;
928
+ if (Filters.valuesArrayContainsValue(checkboxes, v) ||
929
+ value == '' ||
930
+ columnFilters.isFilterCompliantForSimpleValue(v, column.obj, value, interval)) {
931
+ values.push({
932
+ value: v,
933
+ displayedValue: cellUtils.getValueForDisplay(v, column.obj, column.decimals),
934
+ });
935
+ }
936
+ });
937
+ return values;
938
+ }
939
+ /** è necessario estrarre i valori della colonna di tutte le righe
940
+ * filtrate SENZA il filtro della colonna stessa corrente */
941
+ let tmpFilters = Object.assign({}, comp.filters);
942
+ tmpFilters[column.name] = {
943
+ textField: value,
944
+ textFieldTmp: value,
945
+ checkBoxes: [],
946
+ interval: interval,
947
+ intervalTmp: interval,
948
+ };
949
+ let tmpRows = this.filterRows(comp.getRows(), tmpFilters, globalFilterValue, comp.getVisibleColumns(), columnFilters);
950
+ for (let i = 0; i < checkboxes.length; i++) {
951
+ values.push(checkboxes[i]);
952
+ }
953
+ this.extractColumnValues(tmpRows, column, values);
954
+ values.sort((n1, n2) => {
955
+ return cellUtils.compareValues(null, cellUtils.getValueForDisplay2(n1, column), null, cellUtils.getValueForDisplay2(n2, column), kupManager.SortMode.A);
956
+ });
957
+ return values;
958
+ }
959
+ extractColumnValues(rows, column, values) {
960
+ /** il valore delle righe attualmente filtrate, formattato */
961
+ rows.forEach((row) => this.addColumnValueFromRow(values, column, row.cells[column.name]));
962
+ return values;
963
+ }
964
+ addColumnValueFromRow(values, column, cell) {
965
+ if (cell) {
966
+ let item = {
967
+ value: cell.value,
968
+ displayedValue: cellUtils.getCellValueForDisplay(column, cell),
969
+ };
970
+ if (!Filters.valuesArrayContainsValue(values, cell.value)) {
971
+ values.push(item);
972
+ }
973
+ }
974
+ }
975
+ }
976
+
977
+ const dom$1 = document.documentElement;
978
+ function sortRows(rows = [], sort = []) {
979
+ if (!rows || rows.length === 0) {
980
+ return [];
981
+ }
982
+ // check if row is group
983
+ if (rows[0].group) {
984
+ return sortGroupRows(rows, sort);
985
+ }
986
+ // sorting rows
987
+ if (!sort || sort.length === 0) {
988
+ // no sort -> return rows as they are
989
+ return rows;
990
+ }
991
+ // check multiple sort
992
+ const isMultiSort = sort.length > 1;
993
+ // sorting rows
994
+ return rows.slice(0).sort((r1, r2) => {
995
+ if (isMultiSort) {
996
+ for (let i = 0; i < sort.length; i++) {
997
+ const compare = compareRows(r1, r2, sort[i]);
998
+ if (compare !== 0) {
999
+ // not same row
1000
+ return compare;
1001
+ }
1002
+ }
1003
+ // same row
1004
+ return 0;
1005
+ }
1006
+ else {
1007
+ return compareRows(r1, r2, sort[0]);
1008
+ }
1009
+ });
1010
+ }
1011
+ function sortGroupRows(rows = [], sort = []) {
1012
+ if (!rows || rows.length === 0) {
1013
+ return [];
1014
+ }
1015
+ // getting columm group
1016
+ const groupColumn = rows[0].group.column;
1017
+ // check if column is in sort
1018
+ let sortObject = getSortOnColumn(groupColumn, sort);
1019
+ if (!sortObject) {
1020
+ sortObject = {
1021
+ column: groupColumn,
1022
+ sortMode: kupManager.SortMode.A,
1023
+ };
1024
+ }
1025
+ // sorting rows
1026
+ rows.sort((r1, r2) => {
1027
+ // creating fake cells
1028
+ const cell1 = {
1029
+ obj: r1.group.obj,
1030
+ value: r1.group.id,
1031
+ };
1032
+ const cell2 = {
1033
+ obj: r2.group.obj,
1034
+ value: r2.group.id,
1035
+ };
1036
+ return cellUtils.compareCell(cell1, cell2, sortObject.sortMode);
1037
+ });
1038
+ // sorting children
1039
+ rows.forEach((row) => {
1040
+ row.group.children = sortRows(row.group.children, sort);
1041
+ });
1042
+ return rows;
1043
+ }
1044
+ function getSortOnColumn(column = '', sort = []) {
1045
+ if (!column || !sort || sort.length === 0) {
1046
+ return null;
1047
+ }
1048
+ for (let sortObject of sort) {
1049
+ if (sortObject.column === column) {
1050
+ return sortObject;
1051
+ }
1052
+ }
1053
+ return null;
1054
+ }
1055
+ function compareRows(r1, r2, sortObj) {
1056
+ const cell1 = r1.cells[sortObj.column];
1057
+ const cell2 = r2.cells[sortObj.column];
1058
+ if (!cell1 && !cell2) {
1059
+ return 0;
1060
+ }
1061
+ if (!cell1) {
1062
+ return 1;
1063
+ }
1064
+ if (!cell2) {
1065
+ return -1;
1066
+ }
1067
+ return cellUtils.compareCell(cell1, cell2, sortObj.sortMode);
1068
+ }
1069
+ //-------- FILTER FUNCTIONS --------
1070
+ /**
1071
+ * Filters the rows data of a data-table component according to the parameters
1072
+ *
1073
+ * @param rows - The data of the rows to filter.
1074
+ * @param filters - The the filters for each column.
1075
+ * @param globalFilter - A global filter applied to all columns.
1076
+ * @param columns - The colmns on which the filter will take effect.
1077
+ * @todo This function can be improved in its speed by a refactor in which from two different cycles of execution for
1078
+ * single filters and global filter, all controls on a single column are done in a single cycle.
1079
+ */
1080
+ function filterRows(rows = [], filters = {}, globalFilter = '', columns = [], columnFilters, filtersRows) {
1081
+ if (filtersRows == null) {
1082
+ filtersRows = new FiltersRows();
1083
+ }
1084
+ return filtersRows.filterRows(rows, filters, globalFilter, columns, columnFilters);
1085
+ }
1086
+ function groupRows(columns = [], rows = [], groups = [], totals = {}) {
1087
+ if (!rows) {
1088
+ return [];
1089
+ }
1090
+ if (!groups || groups.length === 0 || !columns || columns.length === 0) {
1091
+ return rows;
1092
+ }
1093
+ // Keeps label of the valid columns
1094
+ const columnLabels = {};
1095
+ // remove invalid groups and store column labels
1096
+ const validGroups = groups.filter(({ column }) => {
1097
+ for (let { name, title } of columns) {
1098
+ if (name === column) {
1099
+ // Store label of the columns
1100
+ columnLabels[name] = title;
1101
+ return true;
1102
+ }
1103
+ }
1104
+ return false;
1105
+ });
1106
+ if (validGroups.length === 0) {
1107
+ // no valid groups
1108
+ return rows;
1109
+ }
1110
+ // creating root
1111
+ const groupRows = [];
1112
+ // obj used to calculate the group distinct value
1113
+ let distinctObj = {};
1114
+ rows.forEach((row) => {
1115
+ // getting column name from first group
1116
+ const columnName = validGroups[0].column;
1117
+ // getting row value
1118
+ const cell = row.cells[columnName];
1119
+ if (cell) {
1120
+ const column = cellUtils.getColumnByName(columns, columnName);
1121
+ const cellValueForDisplay = cellUtils.getCellValueForDisplay(column, cell);
1122
+ const cellValue = cell.value;
1123
+ let groupRow = null;
1124
+ // check in already in groupedRow
1125
+ for (let currentGroupRow of groupRows) {
1126
+ if (currentGroupRow.group.label === cellValueForDisplay) {
1127
+ groupRow = currentGroupRow;
1128
+ break;
1129
+ }
1130
+ }
1131
+ if (groupRow === null) {
1132
+ // create group row
1133
+ groupRow = {
1134
+ group: {
1135
+ id: cellValue,
1136
+ parent: null,
1137
+ column: columnName,
1138
+ columnLabel: columnLabels[columnName],
1139
+ expanded: false,
1140
+ label: cellValueForDisplay,
1141
+ children: [],
1142
+ obj: cell.obj,
1143
+ totals: {},
1144
+ },
1145
+ cells: {},
1146
+ };
1147
+ // add group to list
1148
+ groupRows.push(groupRow);
1149
+ }
1150
+ for (let i = 1; i < validGroups.length; i++) {
1151
+ const group = validGroups[i];
1152
+ // getting cell value
1153
+ const tempCell = row.cells[group.column];
1154
+ if (tempCell) {
1155
+ const column = cellUtils.getColumnByName(columns, group.column);
1156
+ const tempCellValueForDisplay = cellUtils.getCellValueForDisplay(column, tempCell);
1157
+ const tempCellValue = tempCell.value;
1158
+ // check if group already exists
1159
+ let tempGroupingRow = null;
1160
+ for (let j = 0; j < groupRow.group.children.length; j++) {
1161
+ const childGroup = groupRow.group.children[j];
1162
+ const groupLabel = childGroup.group.label;
1163
+ if (groupLabel === tempCellValueForDisplay) {
1164
+ tempGroupingRow = childGroup;
1165
+ break;
1166
+ }
1167
+ }
1168
+ if (!tempGroupingRow) {
1169
+ tempGroupingRow = {
1170
+ cells: {},
1171
+ group: {
1172
+ id: tempCellValue,
1173
+ parent: groupRow,
1174
+ column: group.column,
1175
+ columnLabel: columnLabels[group.column],
1176
+ children: [],
1177
+ expanded: false,
1178
+ label: tempCellValueForDisplay,
1179
+ totals: {},
1180
+ obj: tempCell.obj,
1181
+ },
1182
+ };
1183
+ adjustGroupId(tempGroupingRow);
1184
+ groupRow.group.children.push(tempGroupingRow);
1185
+ }
1186
+ groupRow = tempGroupingRow;
1187
+ }
1188
+ }
1189
+ // adding row
1190
+ groupRow.group.children.push(row);
1191
+ updateGroupTotal(groupRow, totals, row, distinctObj);
1192
+ }
1193
+ });
1194
+ adjustGroupsDistinct(groupRows, totals, distinctObj);
1195
+ adjustGroupsAverageOrFormula(groupRows, kupManager.TotalMode.AVERAGE, totals);
1196
+ adjustGroupsAverageOrFormula(groupRows, kupManager.TotalMode.MATH, totals);
1197
+ return groupRows;
1198
+ }
1199
+ function updateGroupTotal(groupRow, totals, addedRow, distinctObj) {
1200
+ if (!groupRow || !totals) {
1201
+ return;
1202
+ }
1203
+ const keys = Object.keys(totals);
1204
+ if (keys.length === 0) {
1205
+ return;
1206
+ }
1207
+ keys.forEach((key) => {
1208
+ const currentTotalValue = dom$1.ketchup.math.numberify(groupRow.group.totals[key] || 0);
1209
+ const cell = addedRow.cells[key];
1210
+ if (cell) {
1211
+ let _isNumber = dom$1.ketchup.objects.isNumber(cell.obj);
1212
+ const totalMode = totals[key];
1213
+ switch (totalMode) {
1214
+ case kupManager.TotalMode.COUNT:
1215
+ groupRow.group.totals[key] = currentTotalValue + 1;
1216
+ // updating parents
1217
+ let parent = groupRow.group.parent;
1218
+ while (parent != null) {
1219
+ const currentParentCount = parent.group.totals[key] || 0;
1220
+ parent.group.totals[key] = currentParentCount + 1;
1221
+ parent = parent.group.parent;
1222
+ }
1223
+ break;
1224
+ case kupManager.TotalMode.DISTINCT:
1225
+ let cellValue;
1226
+ if (_isNumber) {
1227
+ cellValue = dom$1.ketchup.math.numberify(utils.stringToNumber(cell.value));
1228
+ }
1229
+ else {
1230
+ cellValue = cell.value;
1231
+ }
1232
+ let distinctGroup = distinctObj[groupRow.group.id];
1233
+ if (!distinctGroup) {
1234
+ distinctObj[groupRow.group.id] = {};
1235
+ distinctObj[groupRow.group.id][key] = [];
1236
+ distinctObj[groupRow.group.id][key].push(cellValue);
1237
+ }
1238
+ else {
1239
+ let distinctList = distinctObj[groupRow.group.id][key];
1240
+ if (!distinctList) {
1241
+ // first round
1242
+ distinctObj[groupRow.group.id][key] = [];
1243
+ distinctObj[groupRow.group.id][key].push(cellValue);
1244
+ }
1245
+ else {
1246
+ // update the list
1247
+ distinctList.push(cellValue);
1248
+ }
1249
+ }
1250
+ // updating parents
1251
+ let distinctParent = groupRow.group.parent;
1252
+ while (distinctParent != null) {
1253
+ // get parent value
1254
+ let distinctGroupParent = distinctObj[distinctParent.group.id];
1255
+ if (!distinctGroupParent) {
1256
+ distinctObj[distinctParent.group.id] = {};
1257
+ distinctObj[distinctParent.group.id][key] = [];
1258
+ distinctObj[distinctParent.group.id][key].push(cellValue);
1259
+ }
1260
+ else {
1261
+ let distinctParentList = distinctObj[distinctParent.group.id][key];
1262
+ if (!distinctParentList) {
1263
+ // first round
1264
+ distinctObj[distinctParent.group.id][key] = [];
1265
+ distinctObj[distinctParent.group.id][key].push(cellValue);
1266
+ }
1267
+ else {
1268
+ // update the list
1269
+ distinctParentList.push(cellValue);
1270
+ }
1271
+ }
1272
+ // continue
1273
+ distinctParent = distinctParent.group.parent;
1274
+ }
1275
+ break;
1276
+ case kupManager.TotalMode.SUM:
1277
+ case kupManager.TotalMode.AVERAGE:
1278
+ if (_isNumber) {
1279
+ const cellValue = dom$1.ketchup.math.numberify(utils.stringToNumber(cell.value));
1280
+ groupRow.group.totals[key] =
1281
+ cellValue + currentTotalValue;
1282
+ // updating parents
1283
+ let parent = groupRow.group.parent;
1284
+ while (parent != null) {
1285
+ const currentParentSum = dom$1.ketchup.math.numberify(parent.group.totals[key] || 0);
1286
+ parent.group.totals[key] =
1287
+ cellValue + currentParentSum;
1288
+ parent = parent.group.parent;
1289
+ }
1290
+ }
1291
+ break;
1292
+ // TODO DRY the MIN and MAX functions
1293
+ case kupManager.TotalMode.MIN:
1294
+ if (_isNumber) {
1295
+ const currentTotalValue = groupRow.group.totals[key];
1296
+ const cellValue = dom$1.ketchup.math.numberify(utils.stringToNumber(cell.value));
1297
+ if (currentTotalValue) {
1298
+ groupRow.group.totals[key] = Math.min(currentTotalValue, cellValue);
1299
+ }
1300
+ else {
1301
+ // first round
1302
+ groupRow.group.totals[key] = cellValue;
1303
+ }
1304
+ // updating parents
1305
+ let parent = groupRow.group.parent;
1306
+ while (parent != null) {
1307
+ const currentParentMin = parent.group.totals[key];
1308
+ if (currentParentMin) {
1309
+ parent.group.totals[key] = Math.min(currentParentMin, cellValue);
1310
+ }
1311
+ else {
1312
+ // first round
1313
+ parent.group.totals[key] = cellValue;
1314
+ }
1315
+ parent = parent.group.parent;
1316
+ }
1317
+ }
1318
+ else if (dom$1.ketchup.objects.isDate(cell.obj)) {
1319
+ const momentValue = cell.obj
1320
+ ? dom$1.ketchup.objects.parseDate(cell.obj)
1321
+ : dom$1.ketchup.dates.toDayjs(cell.value);
1322
+ if (dom$1.ketchup.dates.isValid(momentValue)) {
1323
+ const cellValue = dom$1.ketchup.dates.toDate(momentValue);
1324
+ const currentTotalValue = groupRow.group.totals[key];
1325
+ if (currentTotalValue) {
1326
+ let moments = [];
1327
+ moments.push(cellValue);
1328
+ moments.push(dom$1.ketchup.dates.format(currentTotalValue));
1329
+ groupRow.group.totals[key] =
1330
+ dom$1.ketchup.dates.format(dom$1.ketchup.dates.min(moments));
1331
+ }
1332
+ else {
1333
+ groupRow.group.totals[key] = cellValue;
1334
+ }
1335
+ // updating parents
1336
+ let parent = groupRow.group.parent;
1337
+ while (parent != null) {
1338
+ const currentParentMin = parent.group.totals[key];
1339
+ if (currentParentMin) {
1340
+ let moments = [];
1341
+ moments.push(cellValue);
1342
+ moments.push(dom$1.ketchup.dates.format(currentParentMin));
1343
+ parent.group.totals[key] =
1344
+ dom$1.ketchup.dates.format(dom$1.ketchup.dates.min(moments));
1345
+ }
1346
+ else {
1347
+ // first round
1348
+ parent.group.totals[key] = cellValue;
1349
+ }
1350
+ parent = parent.group.parent;
1351
+ }
1352
+ }
1353
+ }
1354
+ break;
1355
+ // TODO DRY the MIN and MAX functions
1356
+ case kupManager.TotalMode.MAX:
1357
+ if (_isNumber) {
1358
+ const currentTotalValue = groupRow.group.totals[key];
1359
+ const cellValue = dom$1.ketchup.math.numberify(utils.stringToNumber(cell.value));
1360
+ if (currentTotalValue) {
1361
+ groupRow.group.totals[key] = Math.max(currentTotalValue, cellValue);
1362
+ }
1363
+ else {
1364
+ // first round
1365
+ groupRow.group.totals[key] = cellValue;
1366
+ }
1367
+ // updating parents
1368
+ let parent = groupRow.group.parent;
1369
+ while (parent != null) {
1370
+ const currentParentMax = parent.group.totals[key];
1371
+ if (currentParentMax) {
1372
+ parent.group.totals[key] = Math.max(currentParentMax, cellValue);
1373
+ }
1374
+ else {
1375
+ // first round
1376
+ parent.group.totals[key] = cellValue;
1377
+ }
1378
+ parent = parent.group.parent;
1379
+ }
1380
+ }
1381
+ else if (dom$1.ketchup.objects.isDate(cell.obj)) {
1382
+ const momentValue = cell.obj
1383
+ ? dom$1.ketchup.objects.parseDate(cell.obj)
1384
+ : dom$1.ketchup.dates.toDayjs(cell.value);
1385
+ if (dom$1.ketchup.dates.isValid(momentValue)) {
1386
+ const cellValue = dom$1.ketchup.dates.toDate(momentValue);
1387
+ const currentTotalValue = groupRow.group.totals[key];
1388
+ if (currentTotalValue) {
1389
+ let moments = [];
1390
+ moments.push(cellValue);
1391
+ moments.push(dom$1.ketchup.dates.format(currentTotalValue));
1392
+ groupRow.group.totals[key] =
1393
+ dom$1.ketchup.dates.format(dom$1.ketchup.dates.max(moments));
1394
+ }
1395
+ else {
1396
+ groupRow.group.totals[key] = cellValue;
1397
+ }
1398
+ // updating parents
1399
+ let parent = groupRow.group.parent;
1400
+ while (parent != null) {
1401
+ const currentParentMin = parent.group.totals[key];
1402
+ if (currentParentMin) {
1403
+ let moments = [];
1404
+ moments.push(cellValue);
1405
+ moments.push(dom$1.ketchup.dates.format(currentParentMin));
1406
+ parent.group.totals[key] =
1407
+ dom$1.ketchup.dates.format(dom$1.ketchup.dates.max(moments));
1408
+ }
1409
+ else {
1410
+ // first round
1411
+ parent.group.totals[key] = cellValue;
1412
+ }
1413
+ parent = parent.group.parent;
1414
+ }
1415
+ }
1416
+ }
1417
+ break;
1418
+ default: {
1419
+ if (totalMode.indexOf(kupManager.TotalMode.MATH) != 0) {
1420
+ console.warn(`invalid total mode: ${totalMode}`);
1421
+ }
1422
+ break;
1423
+ }
1424
+ }
1425
+ }
1426
+ });
1427
+ }
1428
+ function adjustGroupsDistinct(groupRows, totals, distinctObj) {
1429
+ if (!groupRows || !totals) {
1430
+ return;
1431
+ }
1432
+ const keys = Object.keys(totals);
1433
+ if (groupRows.length === 0 || !groupRows[0].group || keys.length === 0) {
1434
+ return;
1435
+ }
1436
+ let toAdjustKeys = keys.filter((key) => kupManager.TotalMode.DISTINCT === totals[key]);
1437
+ if (toAdjustKeys.length > 0) {
1438
+ groupRows
1439
+ .filter((groupRow) => groupRow.group.children.length > 0)
1440
+ .forEach((groupRow) => adjustGroupDistinct(groupRow, toAdjustKeys, distinctObj));
1441
+ }
1442
+ }
1443
+ function adjustGroupsAverageOrFormula(groupRows, type, totals) {
1444
+ if (!groupRows || !totals) {
1445
+ return;
1446
+ }
1447
+ const keys = Object.keys(totals);
1448
+ if (groupRows.length === 0 || !groupRows[0].group || keys.length === 0) {
1449
+ return;
1450
+ }
1451
+ let toAdjustKeys;
1452
+ if (type == kupManager.TotalMode.AVERAGE) {
1453
+ toAdjustKeys = keys.filter((key) => kupManager.TotalMode.AVERAGE === totals[key]);
1454
+ }
1455
+ if (type == kupManager.TotalMode.MATH) {
1456
+ toAdjustKeys = keys.filter((key) => totals[key].indexOf(kupManager.TotalMode.MATH) == 0);
1457
+ }
1458
+ if (toAdjustKeys.length > 0) {
1459
+ groupRows
1460
+ .filter((groupRow) => groupRow.group.children.length > 0)
1461
+ .forEach((groupRow) => adjustGroupAverageOrFormula(groupRow, type, toAdjustKeys, totals));
1462
+ }
1463
+ }
1464
+ function adjustGroupDistinct(groupRow, toAdjustKeys, distinctObj) {
1465
+ const children = groupRow.group.children;
1466
+ if (children.length === 0) {
1467
+ return;
1468
+ }
1469
+ if (children[0].group) {
1470
+ children.forEach((child) => {
1471
+ adjustGroupDistinct(child, toAdjustKeys, distinctObj);
1472
+ });
1473
+ }
1474
+ toAdjustKeys.forEach((key) => {
1475
+ const distinctList = distinctObj[groupRow.group.id][key];
1476
+ groupRow.group.totals[key] = new Set(distinctList).size;
1477
+ });
1478
+ }
1479
+ /**
1480
+ * @returns number of 'leaf' of group
1481
+ */
1482
+ function adjustGroupAverageOrFormula(row, type, toAdjustKeys, totals) {
1483
+ const children = row.group.children;
1484
+ if (children.length === 0) {
1485
+ return 0;
1486
+ }
1487
+ let numberOfLeaf = 0;
1488
+ // check if child is a grouping row
1489
+ if (children[0].group) {
1490
+ children.forEach((child) => {
1491
+ numberOfLeaf += adjustGroupAverageOrFormula(child, type, toAdjustKeys, totals);
1492
+ });
1493
+ }
1494
+ else {
1495
+ numberOfLeaf = children.length;
1496
+ }
1497
+ // adjust average/formulas
1498
+ toAdjustKeys.forEach((key) => {
1499
+ if (type == kupManager.TotalMode.AVERAGE) {
1500
+ row.group.totals[key] =
1501
+ dom$1.ketchup.math.numberify(row.group.totals[key]) /
1502
+ numberOfLeaf;
1503
+ }
1504
+ if (type == kupManager.TotalMode.MATH) {
1505
+ let formula = totals[key].substring(kupManager.TotalMode.MATH.length);
1506
+ row.group.totals[key] = dom$1.ketchup.math.formulas.custom(formula, row.group.totals);
1507
+ }
1508
+ });
1509
+ return numberOfLeaf;
1510
+ }
1511
+ function normalizeRows(columns, rows) {
1512
+ if (rows) {
1513
+ const normalizedrows = Object.assign(rows);
1514
+ rows.forEach((row) => {
1515
+ columns.forEach((column) => {
1516
+ if (row.cells) {
1517
+ const cell = row.cells[column.name];
1518
+ if (cell && column.obj && !cell.obj) {
1519
+ // cell.obj = Object.assign(column.obj);
1520
+ cell.obj = {
1521
+ t: column.obj.t,
1522
+ p: column.obj.p,
1523
+ k: cell.value,
1524
+ };
1525
+ }
1526
+ }
1527
+ });
1528
+ });
1529
+ return normalizedrows;
1530
+ }
1531
+ else {
1532
+ return undefined;
1533
+ }
1534
+ }
1535
+ function calcTotals(rows = [], totals = {}) {
1536
+ if (dom$1.ketchup.objects.isEmptyJsObject(rows) ||
1537
+ dom$1.ketchup.objects.isEmptyJsObject(totals)) {
1538
+ return {};
1539
+ }
1540
+ const keys = Object.keys(totals);
1541
+ const footerRow = {};
1542
+ // if there are only COUNT, no need to loop on rows
1543
+ let onlyCount = keys.length === 0 &&
1544
+ keys.every((key) => totals[key] === kupManager.TotalMode.COUNT);
1545
+ if (onlyCount) {
1546
+ keys.forEach((columnName) => (footerRow[columnName] = rows.length));
1547
+ }
1548
+ else {
1549
+ let distinctObj = {};
1550
+ rows.forEach((r, index, array) => {
1551
+ keys.filter((key) => kupManager.TotalMode.COUNT !== totals[key] &&
1552
+ totals[key].indexOf(kupManager.TotalMode.MATH) != 0).forEach((key) => {
1553
+ // getting cell
1554
+ const cell = r.cells[key];
1555
+ if (cell) {
1556
+ if (totals[key] === kupManager.TotalMode.DISTINCT) {
1557
+ let cellValue;
1558
+ if (dom$1.ketchup.objects.isNumber(cell.obj)) {
1559
+ cellValue = dom$1.ketchup.math.numberify(utils.stringToNumber(cell.value));
1560
+ }
1561
+ else {
1562
+ cellValue = cell.value;
1563
+ }
1564
+ let distinctList = distinctObj[key];
1565
+ if (!distinctList) {
1566
+ // first round
1567
+ distinctObj[key] = [];
1568
+ distinctObj[key].push(cellValue);
1569
+ }
1570
+ else {
1571
+ // update the list
1572
+ distinctList.push(cellValue);
1573
+ }
1574
+ }
1575
+ else if (dom$1.ketchup.objects.isNumber(cell.obj)) {
1576
+ const cellValue = dom$1.ketchup.math.numberify(utils.stringToNumber(cell.value));
1577
+ let currentFooterValue = footerRow[key];
1578
+ switch (true) {
1579
+ // TODO DRY the MIN and MAX functions
1580
+ case totals[key] === kupManager.TotalMode.MIN:
1581
+ if (currentFooterValue) {
1582
+ footerRow[key] = Math.min(currentFooterValue, cellValue);
1583
+ }
1584
+ else {
1585
+ footerRow[key] = cellValue;
1586
+ }
1587
+ break;
1588
+ case totals[key] === kupManager.TotalMode.MAX:
1589
+ if (currentFooterValue) {
1590
+ footerRow[key] = Math.max(currentFooterValue, cellValue);
1591
+ }
1592
+ else {
1593
+ footerRow[key] = cellValue;
1594
+ }
1595
+ break;
1596
+ default:
1597
+ // SUM
1598
+ currentFooterValue = footerRow[key] || 0;
1599
+ footerRow[key] =
1600
+ cellValue +
1601
+ dom$1.ketchup.math.numberify(currentFooterValue);
1602
+ }
1603
+ // TODO DRY the MIN and MAX functions
1604
+ }
1605
+ else if (dom$1.ketchup.objects.isDate(cell.obj)) {
1606
+ const momentValue = cell.obj
1607
+ ? dom$1.ketchup.objects.parseDate(cell.obj)
1608
+ : dom$1.ketchup.dates.toDayjs(cell.value);
1609
+ if (dom$1.ketchup.dates.isValid(momentValue)) {
1610
+ const cellValue = dom$1.ketchup.dates.toDate(momentValue);
1611
+ const currentFooterValue = footerRow[key];
1612
+ switch (true) {
1613
+ case totals[key] === kupManager.TotalMode.MIN:
1614
+ if (currentFooterValue) {
1615
+ let moments = [];
1616
+ moments.push(cellValue);
1617
+ moments.push(dom$1.ketchup.dates.format(currentFooterValue));
1618
+ footerRow[key] =
1619
+ dom$1.ketchup.dates.format(dom$1.ketchup.dates.min(moments));
1620
+ }
1621
+ else {
1622
+ footerRow[key] = cellValue;
1623
+ }
1624
+ break;
1625
+ case totals[key] === kupManager.TotalMode.MAX:
1626
+ if (currentFooterValue) {
1627
+ let moments = [];
1628
+ moments.push(cellValue);
1629
+ moments.push(dom$1.ketchup.dates.format(currentFooterValue));
1630
+ footerRow[key] =
1631
+ dom$1.ketchup.dates.format(dom$1.ketchup.dates.max(moments));
1632
+ }
1633
+ else {
1634
+ footerRow[key] = cellValue;
1635
+ }
1636
+ break;
1637
+ }
1638
+ }
1639
+ }
1640
+ }
1641
+ if (index === array.length - 1 &&
1642
+ totals[key] === kupManager.TotalMode.DISTINCT) {
1643
+ // last round
1644
+ footerRow[key] = new Set(distinctObj[key]).size;
1645
+ distinctObj[key] = [];
1646
+ }
1647
+ });
1648
+ });
1649
+ // fixing MATH, AVERAGE and COUNT
1650
+ for (let key of keys) {
1651
+ switch (true) {
1652
+ case totals[key] === kupManager.TotalMode.AVERAGE:
1653
+ const sum = footerRow[key];
1654
+ if (sum && rows.length > 0) {
1655
+ footerRow[key] = sum / rows.length;
1656
+ }
1657
+ break;
1658
+ case totals[key] === kupManager.TotalMode.COUNT:
1659
+ footerRow[key] = rows.length;
1660
+ break;
1661
+ case totals[key].indexOf(kupManager.TotalMode.MATH) == 0:
1662
+ footerRow[key] = dom$1.ketchup.math.formulas.custom(totals[key].substring(kupManager.TotalMode.MATH.length), footerRow);
1663
+ break;
1664
+ }
1665
+ if (footerRow[key]) {
1666
+ footerRow[key] = +footerRow[key].toFixed(2);
1667
+ }
1668
+ }
1669
+ }
1670
+ return footerRow;
1671
+ }
1672
+ function adjustGroupId(row) {
1673
+ if (!row.group) {
1674
+ return;
1675
+ }
1676
+ let groupID = row.group.id;
1677
+ let parentRow = row.group.parent;
1678
+ while (parentRow !== null) {
1679
+ groupID = `${parentRow.group.id};${groupID}`;
1680
+ parentRow = parentRow.group.parent;
1681
+ }
1682
+ row.group.id = groupID;
1683
+ }
1684
+ function paginateRows(rows, currentPage, rowsPerPage, areGrouped) {
1685
+ const start = currentPage * rowsPerPage - rowsPerPage;
1686
+ const end = start + Number(rowsPerPage);
1687
+ if (areGrouped == false) {
1688
+ return rows.slice(start, end);
1689
+ }
1690
+ let pagRows = [];
1691
+ _paginateRows(rows, pagRows, start, Number(rowsPerPage), 0);
1692
+ return pagRows;
1693
+ }
1694
+ function _paginateRows(rows, pagRows, start, rowsPerPage, ci) {
1695
+ let added = false;
1696
+ for (let i = 0; i < rows.length; i++) {
1697
+ let originalRow = rows[i];
1698
+ let row = cloneRow(rows[i]);
1699
+ if (originalRow.group != null &&
1700
+ originalRow.group.children != null &&
1701
+ originalRow.group.children.length > 0) {
1702
+ row.group.children = [];
1703
+ let retValue = _paginateRows(originalRow.group.children, row.group.children, start, rowsPerPage, ci);
1704
+ ci = retValue.ci;
1705
+ added = retValue.added;
1706
+ if (added == true) {
1707
+ pagRows[pagRows.length] = row;
1708
+ }
1709
+ }
1710
+ else {
1711
+ if (ci >= start) {
1712
+ pagRows[pagRows.length] = row;
1713
+ added = true;
1714
+ }
1715
+ ci++;
1716
+ }
1717
+ if (ci >= start + rowsPerPage) {
1718
+ break;
1719
+ }
1720
+ }
1721
+ return { ci: ci, added: added };
1722
+ }
1723
+ function cloneRow(row) {
1724
+ if (row == null) {
1725
+ return null;
1726
+ }
1727
+ let cloned = {
1728
+ id: row.id,
1729
+ cells: Object.assign({}, row.cells),
1730
+ actions: row.actions ? [...row.actions] : null,
1731
+ group: cloneRowGroup(row.group),
1732
+ readOnly: row.readOnly,
1733
+ cssClass: row.cssClass,
1734
+ };
1735
+ return cloned;
1736
+ }
1737
+ function cloneRows(rows) {
1738
+ if (rows == null) {
1739
+ return null;
1740
+ }
1741
+ let cloned = [];
1742
+ for (let i = 0; i < rows.length; i++) {
1743
+ cloned[cloned.length] = cloneRow(rows[i]);
1744
+ }
1745
+ return cloned;
1746
+ }
1747
+ function cloneRowGroup(group) {
1748
+ if (group == null) {
1749
+ return null;
1750
+ }
1751
+ let cloned = {
1752
+ id: group.id,
1753
+ parent: Object.assign({}, group.parent),
1754
+ column: group.column,
1755
+ columnLabel: group.columnLabel,
1756
+ expanded: group.expanded,
1757
+ label: group.label,
1758
+ children: cloneRows(group.children),
1759
+ obj: Object.assign({}, group.obj),
1760
+ totals: Object.assign({}, group.totals),
1761
+ };
1762
+ return cloned;
1763
+ }
1764
+
1765
+ exports.FPaginatorMode = void 0;
1766
+ (function (FPaginatorMode) {
1767
+ FPaginatorMode["SIMPLE"] = "simple";
1768
+ FPaginatorMode["FULL"] = "full";
1769
+ })(exports.FPaginatorMode || (exports.FPaginatorMode = {}));
1770
+
1771
+ const dom = document.documentElement;
1772
+ /*-------------------------------------------------*/
1773
+ /* C o m p o n e n t */
1774
+ /*-------------------------------------------------*/
1775
+ const FPaginator = (props) => {
1776
+ const maxNumberOfPage = Math.ceil(props.max / props.perPage);
1777
+ const pageItems = getPageItems(props, maxNumberOfPage);
1778
+ const rowsPerPageItems = getRowsItems(props);
1779
+ const dataPageSelector = {
1780
+ 'kup-list': {
1781
+ data: pageItems,
1782
+ },
1783
+ 'kup-text-field': {
1784
+ label: dom.ketchup.language.translate(kupManager.KupLanguagePage.PAGE),
1785
+ helper: dom.ketchup.language.translate(kupManager.KupLanguagePage.TOTAL) +
1786
+ `: ${maxNumberOfPage}`,
1787
+ helperWhenFocused: true,
1788
+ inputType: 'number',
1789
+ max: maxNumberOfPage,
1790
+ min: 1,
1791
+ },
1792
+ };
1793
+ const dataRowsSelector = {
1794
+ 'kup-list': {
1795
+ data: rowsPerPageItems,
1796
+ },
1797
+ 'kup-text-field': {
1798
+ label: dom.ketchup.language.translate(kupManager.KupLanguageRow.ROWS) +
1799
+ ' / ' +
1800
+ dom.ketchup.language.translate(kupManager.KupLanguagePage.PAGE),
1801
+ helper: dom.ketchup.language.translate(kupManager.KupLanguageRow.TOTAL) +
1802
+ `: ${props.max}`,
1803
+ helperWhenFocused: true,
1804
+ inputType: 'number',
1805
+ max: props.max,
1806
+ min: 1,
1807
+ },
1808
+ };
1809
+ return (index.h("div", Object.assign({ class: `f-paginator ${props.mode ? props.mode : ''} ${props.wrapperClass ? props.wrapperClass : ''}` }, props.dataSet, { id: props.id, title: props.title }),
1810
+ props.mode !== exports.FPaginatorMode.SIMPLE ? (index.h(fButton.FButton, { icon: "chevron_left", disabled: isPrevPageDisabled(props), onClick: props.onPrevPage, wrapperClass: "prev-page" })) : null,
1811
+ index.h("kup-combobox", { class: "page-selector", data: dataPageSelector, initialValue: props.currentPage.toString(), "onkup-combobox-change": props.onPageChange }),
1812
+ props.mode !== exports.FPaginatorMode.SIMPLE ? (index.h(fButton.FButton, { icon: "chevron_right", disabled: isNextPageDisabled(props), onClick: props.onNextPage, wrapperClass: "next-page" })) : null,
1813
+ index.h("kup-combobox", { class: "rows-selector", data: dataRowsSelector, initialValue: props.perPage.toString(), "onkup-combobox-change": props.onRowsChange }),
1814
+ props.onLoadMore ? (index.h(fButton.FButton, { icon: "plus", onClick: props.onLoadMore, label: dom.ketchup.language.translate(kupManager.KupLanguageGeneric.LOAD_MORE), styling: fButtonDeclarations.FButtonStyling.FLAT, wrapperClass: "load-more-button" })) : null));
1815
+ };
1816
+ function getPageItems(props, maxNumberOfPage) {
1817
+ const pageItems = [];
1818
+ for (let i = 1; i <= maxNumberOfPage; i++) {
1819
+ const selected = i == props.currentPage;
1820
+ pageItems.push({
1821
+ id: i.toString(),
1822
+ selected: selected,
1823
+ value: i.toString(),
1824
+ });
1825
+ }
1826
+ return pageItems;
1827
+ }
1828
+ function getRowsItems(props) {
1829
+ const rowsPerPageItems = [];
1830
+ let i = props.perPage;
1831
+ if (i === 0) {
1832
+ return rowsPerPageItems;
1833
+ }
1834
+ while (i < props.max) {
1835
+ const selected = i == props.perPage;
1836
+ rowsPerPageItems.push({
1837
+ id: i.toString(),
1838
+ selected: selected,
1839
+ value: i.toString(),
1840
+ });
1841
+ i = i * 2;
1842
+ }
1843
+ const selected = props.max == props.perPage;
1844
+ rowsPerPageItems.push({
1845
+ id: props.max.toString(),
1846
+ selected: selected,
1847
+ value: props.max.toString(),
1848
+ });
1849
+ return rowsPerPageItems;
1850
+ }
1851
+ function isNextPageDisabled(props) {
1852
+ return props.currentPage * props.perPage >= props.max;
1853
+ }
1854
+ function isPrevPageDisabled(props) {
1855
+ return props.currentPage == 1;
1856
+ }
1857
+
1858
+ function pageChange(pageNumber, max, perPage) {
1859
+ if (utils.isNumber(pageNumber)) {
1860
+ const numberOfPages = Math.ceil(max / perPage);
1861
+ let tmpNewPage = pageNumber;
1862
+ if (tmpNewPage > numberOfPages) {
1863
+ tmpNewPage = numberOfPages;
1864
+ }
1865
+ if (tmpNewPage < 1) {
1866
+ tmpNewPage = 1;
1867
+ }
1868
+ return tmpNewPage;
1869
+ }
1870
+ return null;
1871
+ }
1872
+ function rowsPerPageChange(rowsNumber, max) {
1873
+ if (utils.isNumber(rowsNumber)) {
1874
+ let tmpRowsPerPage = rowsNumber;
1875
+ if (tmpRowsPerPage > max) {
1876
+ tmpRowsPerPage = max;
1877
+ }
1878
+ if (tmpRowsPerPage < 1) {
1879
+ tmpRowsPerPage = 1;
1880
+ }
1881
+ return tmpRowsPerPage;
1882
+ }
1883
+ return null;
1884
+ }
1885
+
1886
+ exports.FPaginator = FPaginator;
1887
+ exports.Filters = Filters;
1888
+ exports.FiltersColumnMenu = FiltersColumnMenu;
1889
+ exports.FiltersRows = FiltersRows;
1890
+ exports.calcTotals = calcTotals;
1891
+ exports.filterRows = filterRows;
1892
+ exports.groupRows = groupRows;
1893
+ exports.normalizeRows = normalizeRows;
1894
+ exports.pageChange = pageChange;
1895
+ exports.paginateRows = paginateRows;
1896
+ exports.rowsPerPageChange = rowsPerPageChange;
1897
+ exports.sortRows = sortRows;
1898
+ exports.treeMainColumnName = treeMainColumnName;