@sme.up/ketchup 5.2.1-SNAPSHOT → 6.1.0-SNAPSHOT

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