@pepperi-addons/ngx-lib 0.2.61 → 0.3.0-beta.1

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 (301) hide show
  1. package/address/address.component.theme.scss +4 -7
  2. package/address/pepperi-addons-ngx-lib-address.metadata.json +1 -1
  3. package/attachment/attachment.component.d.ts +1 -0
  4. package/attachment/attachment.component.theme.scss +3 -2
  5. package/attachment/pepperi-addons-ngx-lib-attachment.metadata.json +1 -1
  6. package/bread-crumbs/bread-crumbs.component.theme.scss +7 -7
  7. package/bread-crumbs/pepperi-addons-ngx-lib-bread-crumbs.metadata.json +1 -1
  8. package/bundles/pepperi-addons-ngx-lib-address.umd.js +1 -1
  9. package/bundles/pepperi-addons-ngx-lib-address.umd.js.map +1 -1
  10. package/bundles/pepperi-addons-ngx-lib-attachment.umd.js +7 -2
  11. package/bundles/pepperi-addons-ngx-lib-attachment.umd.js.map +1 -1
  12. package/bundles/pepperi-addons-ngx-lib-bread-crumbs.umd.js +1 -1
  13. package/bundles/pepperi-addons-ngx-lib-bread-crumbs.umd.js.map +1 -1
  14. package/bundles/pepperi-addons-ngx-lib-button.umd.js +1 -1
  15. package/bundles/pepperi-addons-ngx-lib-button.umd.js.map +1 -1
  16. package/bundles/pepperi-addons-ngx-lib-checkbox.umd.js +4 -1
  17. package/bundles/pepperi-addons-ngx-lib-checkbox.umd.js.map +1 -1
  18. package/bundles/pepperi-addons-ngx-lib-color.umd.js +8 -3
  19. package/bundles/pepperi-addons-ngx-lib-color.umd.js.map +1 -1
  20. package/bundles/pepperi-addons-ngx-lib-date.umd.js +4 -1
  21. package/bundles/pepperi-addons-ngx-lib-date.umd.js.map +1 -1
  22. package/bundles/pepperi-addons-ngx-lib-dialog.umd.js +1 -1
  23. package/bundles/pepperi-addons-ngx-lib-dialog.umd.js.map +1 -1
  24. package/bundles/pepperi-addons-ngx-lib-field-title.umd.js +1 -1
  25. package/bundles/pepperi-addons-ngx-lib-field-title.umd.js.map +1 -1
  26. package/bundles/pepperi-addons-ngx-lib-files-uploader.umd.js +1 -1
  27. package/bundles/pepperi-addons-ngx-lib-files-uploader.umd.js.map +1 -1
  28. package/bundles/pepperi-addons-ngx-lib-form.umd.js +19 -16
  29. package/bundles/pepperi-addons-ngx-lib-form.umd.js.map +1 -1
  30. package/bundles/pepperi-addons-ngx-lib-group-buttons.umd.js +1 -1
  31. package/bundles/pepperi-addons-ngx-lib-group-buttons.umd.js.map +1 -1
  32. package/bundles/pepperi-addons-ngx-lib-image.umd.js +7 -2
  33. package/bundles/pepperi-addons-ngx-lib-image.umd.js.map +1 -1
  34. package/bundles/pepperi-addons-ngx-lib-images-filmstrip.umd.js +7 -2
  35. package/bundles/pepperi-addons-ngx-lib-images-filmstrip.umd.js.map +1 -1
  36. package/bundles/pepperi-addons-ngx-lib-list.umd.js +1 -1
  37. package/bundles/pepperi-addons-ngx-lib-list.umd.js.map +1 -1
  38. package/bundles/pepperi-addons-ngx-lib-quantity-selector.umd.js +7 -2
  39. package/bundles/pepperi-addons-ngx-lib-quantity-selector.umd.js.map +1 -1
  40. package/bundles/pepperi-addons-ngx-lib-query-builder.umd.js +1104 -0
  41. package/bundles/pepperi-addons-ngx-lib-query-builder.umd.js.map +1 -0
  42. package/bundles/pepperi-addons-ngx-lib-rich-html-textarea.umd.js +7 -2
  43. package/bundles/pepperi-addons-ngx-lib-rich-html-textarea.umd.js.map +1 -1
  44. package/bundles/pepperi-addons-ngx-lib-select.umd.js +7 -2
  45. package/bundles/pepperi-addons-ngx-lib-select.umd.js.map +1 -1
  46. package/bundles/pepperi-addons-ngx-lib-separator.umd.js +9 -1
  47. package/bundles/pepperi-addons-ngx-lib-separator.umd.js.map +1 -1
  48. package/bundles/pepperi-addons-ngx-lib-side-bar.umd.js +1 -1
  49. package/bundles/pepperi-addons-ngx-lib-side-bar.umd.js.map +1 -1
  50. package/bundles/pepperi-addons-ngx-lib-signature.umd.js +7 -2
  51. package/bundles/pepperi-addons-ngx-lib-signature.umd.js.map +1 -1
  52. package/bundles/pepperi-addons-ngx-lib-slider.umd.js +1 -1
  53. package/bundles/pepperi-addons-ngx-lib-slider.umd.js.map +1 -1
  54. package/bundles/pepperi-addons-ngx-lib-smart-filters.umd.js +306 -39
  55. package/bundles/pepperi-addons-ngx-lib-smart-filters.umd.js.map +1 -1
  56. package/bundles/pepperi-addons-ngx-lib-textarea.umd.js +7 -2
  57. package/bundles/pepperi-addons-ngx-lib-textarea.umd.js.map +1 -1
  58. package/bundles/pepperi-addons-ngx-lib-textbox.umd.js +5 -3
  59. package/bundles/pepperi-addons-ngx-lib-textbox.umd.js.map +1 -1
  60. package/bundles/pepperi-addons-ngx-lib-top-bar.umd.js +1 -1
  61. package/bundles/pepperi-addons-ngx-lib-top-bar.umd.js.map +1 -1
  62. package/bundles/pepperi-addons-ngx-lib.umd.js +3 -1
  63. package/bundles/pepperi-addons-ngx-lib.umd.js.map +1 -1
  64. package/button/button.component.theme.scss +0 -2
  65. package/button/pepperi-addons-ngx-lib-button.metadata.json +1 -1
  66. package/checkbox/checkbox.component.theme.scss +0 -2
  67. package/checkbox/pepperi-addons-ngx-lib-checkbox.metadata.json +1 -1
  68. package/color/color-picker.component.theme.scss +122 -128
  69. package/color/color.component.d.ts +1 -0
  70. package/color/color.component.theme.scss +0 -7
  71. package/color/pepperi-addons-ngx-lib-color.metadata.json +1 -1
  72. package/core/customization/customization.service.d.ts +1 -0
  73. package/date/date.component.theme.scss +163 -169
  74. package/date/pepperi-addons-ngx-lib-date.metadata.json +1 -1
  75. package/dialog/dialog.component.theme.scss +4 -4
  76. package/dialog/pepperi-addons-ngx-lib-dialog.metadata.json +1 -1
  77. package/esm2015/address/address.component.js +2 -2
  78. package/esm2015/attachment/attachment.component.js +8 -3
  79. package/esm2015/bread-crumbs/bread-crumbs.component.js +2 -2
  80. package/esm2015/button/button.component.js +2 -2
  81. package/esm2015/checkbox/checkbox.component.js +5 -2
  82. package/esm2015/color/color-picker.component.js +2 -2
  83. package/esm2015/color/color.component.js +8 -3
  84. package/esm2015/core/customization/customization.service.js +4 -2
  85. package/esm2015/date/date.component.js +5 -2
  86. package/esm2015/dialog/dialog.component.js +2 -2
  87. package/esm2015/field-title/field-title.component.js +2 -2
  88. package/esm2015/files-uploader/files-uploader.component.js +2 -2
  89. package/esm2015/form/indicators.component.js +2 -2
  90. package/esm2015/form/internal-button.component.js +20 -17
  91. package/esm2015/group-buttons/group-buttons.component.js +2 -2
  92. package/esm2015/image/image.component.js +8 -3
  93. package/esm2015/images-filmstrip/images-filmstrip.component.js +8 -3
  94. package/esm2015/list/list-total.component.js +2 -2
  95. package/esm2015/quantity-selector/quantity-selector.component.js +8 -3
  96. package/esm2015/query-builder/common/model/field.js +2 -0
  97. package/esm2015/query-builder/common/model/filter.js +2 -0
  98. package/esm2015/query-builder/common/model/legacy.js +2 -0
  99. package/esm2015/query-builder/common/model/operator-unit.js +42 -0
  100. package/esm2015/query-builder/common/model/operator.js +207 -0
  101. package/esm2015/query-builder/common/model/structure.js +2 -0
  102. package/esm2015/query-builder/common/model/type-map.js +27 -0
  103. package/esm2015/query-builder/common/model/type.js +6 -0
  104. package/esm2015/query-builder/common/services/output-query.service.js +111 -0
  105. package/esm2015/query-builder/common/services/type-convertor.service.js +40 -0
  106. package/esm2015/query-builder/pepperi-addons-ngx-lib-query-builder.js +9 -0
  107. package/esm2015/query-builder/public-api.js +8 -0
  108. package/esm2015/query-builder/query-builder-item/query-builder-item.component.js +116 -0
  109. package/esm2015/query-builder/query-builder-section/query-builder-section.component.js +64 -0
  110. package/esm2015/query-builder/query-builder.component.js +104 -0
  111. package/esm2015/query-builder/query-builder.module.js +35 -0
  112. package/esm2015/query-builder/query-builder.service.js +282 -0
  113. package/esm2015/rich-html-textarea/rich-html-textarea.component.js +8 -3
  114. package/esm2015/select/select.component.js +8 -3
  115. package/esm2015/separator/separator.component.js +10 -2
  116. package/esm2015/side-bar/side-bar.component.js +2 -2
  117. package/esm2015/signature/signature.component.js +8 -3
  118. package/esm2015/slider/slider.component.js +2 -2
  119. package/esm2015/smart-filters/boolean-filter/boolean-filter.component.js +23 -3
  120. package/esm2015/smart-filters/common/model/base-filter-component.js +35 -8
  121. package/esm2015/smart-filters/common/model/creator.js +8 -2
  122. package/esm2015/smart-filters/common/model/field.js +12 -1
  123. package/esm2015/smart-filters/common/model/operator.js +8 -8
  124. package/esm2015/smart-filters/common/model/type.js +1 -1
  125. package/esm2015/smart-filters/date-filter/date-filter.component.js +45 -2
  126. package/esm2015/smart-filters/multi-select-filter/multi-select-filter.component.js +53 -14
  127. package/esm2015/smart-filters/number-filter/number-filter.component.js +27 -2
  128. package/esm2015/smart-filters/public-api.js +2 -1
  129. package/esm2015/smart-filters/smart-filters.component.js +2 -2
  130. package/esm2015/smart-filters/smart-filters.module.js +16 -3
  131. package/esm2015/smart-filters/text-filter/text-filter.component.js +79 -0
  132. package/esm2015/textarea/textarea.component.js +8 -3
  133. package/esm2015/textbox/textbox.component.js +6 -4
  134. package/esm2015/top-bar/top-bar.component.js +2 -2
  135. package/fesm2015/pepperi-addons-ngx-lib-address.js +1 -1
  136. package/fesm2015/pepperi-addons-ngx-lib-address.js.map +1 -1
  137. package/fesm2015/pepperi-addons-ngx-lib-attachment.js +7 -2
  138. package/fesm2015/pepperi-addons-ngx-lib-attachment.js.map +1 -1
  139. package/fesm2015/pepperi-addons-ngx-lib-bread-crumbs.js +1 -1
  140. package/fesm2015/pepperi-addons-ngx-lib-bread-crumbs.js.map +1 -1
  141. package/fesm2015/pepperi-addons-ngx-lib-button.js +1 -1
  142. package/fesm2015/pepperi-addons-ngx-lib-button.js.map +1 -1
  143. package/fesm2015/pepperi-addons-ngx-lib-checkbox.js +4 -1
  144. package/fesm2015/pepperi-addons-ngx-lib-checkbox.js.map +1 -1
  145. package/fesm2015/pepperi-addons-ngx-lib-color.js +8 -3
  146. package/fesm2015/pepperi-addons-ngx-lib-color.js.map +1 -1
  147. package/fesm2015/pepperi-addons-ngx-lib-date.js +4 -1
  148. package/fesm2015/pepperi-addons-ngx-lib-date.js.map +1 -1
  149. package/fesm2015/pepperi-addons-ngx-lib-dialog.js +1 -1
  150. package/fesm2015/pepperi-addons-ngx-lib-dialog.js.map +1 -1
  151. package/fesm2015/pepperi-addons-ngx-lib-field-title.js +1 -1
  152. package/fesm2015/pepperi-addons-ngx-lib-field-title.js.map +1 -1
  153. package/fesm2015/pepperi-addons-ngx-lib-files-uploader.js +1 -1
  154. package/fesm2015/pepperi-addons-ngx-lib-files-uploader.js.map +1 -1
  155. package/fesm2015/pepperi-addons-ngx-lib-form.js +19 -16
  156. package/fesm2015/pepperi-addons-ngx-lib-form.js.map +1 -1
  157. package/fesm2015/pepperi-addons-ngx-lib-group-buttons.js +1 -1
  158. package/fesm2015/pepperi-addons-ngx-lib-group-buttons.js.map +1 -1
  159. package/fesm2015/pepperi-addons-ngx-lib-image.js +7 -2
  160. package/fesm2015/pepperi-addons-ngx-lib-image.js.map +1 -1
  161. package/fesm2015/pepperi-addons-ngx-lib-images-filmstrip.js +7 -2
  162. package/fesm2015/pepperi-addons-ngx-lib-images-filmstrip.js.map +1 -1
  163. package/fesm2015/pepperi-addons-ngx-lib-list.js +1 -1
  164. package/fesm2015/pepperi-addons-ngx-lib-list.js.map +1 -1
  165. package/fesm2015/pepperi-addons-ngx-lib-quantity-selector.js +7 -2
  166. package/fesm2015/pepperi-addons-ngx-lib-quantity-selector.js.map +1 -1
  167. package/fesm2015/pepperi-addons-ngx-lib-query-builder.js +1014 -0
  168. package/fesm2015/pepperi-addons-ngx-lib-query-builder.js.map +1 -0
  169. package/fesm2015/pepperi-addons-ngx-lib-rich-html-textarea.js +7 -2
  170. package/fesm2015/pepperi-addons-ngx-lib-rich-html-textarea.js.map +1 -1
  171. package/fesm2015/pepperi-addons-ngx-lib-select.js +7 -2
  172. package/fesm2015/pepperi-addons-ngx-lib-select.js.map +1 -1
  173. package/fesm2015/pepperi-addons-ngx-lib-separator.js +9 -1
  174. package/fesm2015/pepperi-addons-ngx-lib-separator.js.map +1 -1
  175. package/fesm2015/pepperi-addons-ngx-lib-side-bar.js +1 -1
  176. package/fesm2015/pepperi-addons-ngx-lib-side-bar.js.map +1 -1
  177. package/fesm2015/pepperi-addons-ngx-lib-signature.js +7 -2
  178. package/fesm2015/pepperi-addons-ngx-lib-signature.js.map +1 -1
  179. package/fesm2015/pepperi-addons-ngx-lib-slider.js +1 -1
  180. package/fesm2015/pepperi-addons-ngx-lib-slider.js.map +1 -1
  181. package/fesm2015/pepperi-addons-ngx-lib-smart-filters.js +293 -36
  182. package/fesm2015/pepperi-addons-ngx-lib-smart-filters.js.map +1 -1
  183. package/fesm2015/pepperi-addons-ngx-lib-textarea.js +7 -2
  184. package/fesm2015/pepperi-addons-ngx-lib-textarea.js.map +1 -1
  185. package/fesm2015/pepperi-addons-ngx-lib-textbox.js +5 -3
  186. package/fesm2015/pepperi-addons-ngx-lib-textbox.js.map +1 -1
  187. package/fesm2015/pepperi-addons-ngx-lib-top-bar.js +1 -1
  188. package/fesm2015/pepperi-addons-ngx-lib-top-bar.js.map +1 -1
  189. package/fesm2015/pepperi-addons-ngx-lib.js +3 -1
  190. package/fesm2015/pepperi-addons-ngx-lib.js.map +1 -1
  191. package/field-title/field-title.component.theme.scss +0 -2
  192. package/field-title/pepperi-addons-ngx-lib-field-title.metadata.json +1 -1
  193. package/files-uploader/files-uploader.component.theme.scss +3 -2
  194. package/files-uploader/pepperi-addons-ngx-lib-files-uploader.metadata.json +1 -1
  195. package/form/indicators.component.theme.scss +5 -5
  196. package/form/internal-button.component.d.ts +0 -1
  197. package/form/pepperi-addons-ngx-lib-form.metadata.json +1 -1
  198. package/group-buttons/group-buttons.component.theme.scss +11 -11
  199. package/group-buttons/pepperi-addons-ngx-lib-group-buttons.metadata.json +1 -1
  200. package/image/image.component.d.ts +1 -0
  201. package/image/image.component.theme.scss +28 -27
  202. package/image/pepperi-addons-ngx-lib-image.metadata.json +1 -1
  203. package/images-filmstrip/images-filmstrip.component.d.ts +1 -0
  204. package/images-filmstrip/images-filmstrip.component.theme.scss +27 -26
  205. package/images-filmstrip/pepperi-addons-ngx-lib-images-filmstrip.metadata.json +1 -1
  206. package/list/list-total.component.theme.scss +6 -6
  207. package/list/pepperi-addons-ngx-lib-list.metadata.json +1 -1
  208. package/package.json +5 -5
  209. package/page-layout/page-layout.component.theme.scss +6 -6
  210. package/pepperi-addons-ngx-lib.metadata.json +1 -1
  211. package/quantity-selector/pepperi-addons-ngx-lib-quantity-selector.metadata.json +1 -1
  212. package/quantity-selector/quantity-selector.component.d.ts +1 -0
  213. package/quantity-selector/quantity-selector.component.theme.scss +21 -21
  214. package/query-builder/common/model/field.d.ts +8 -0
  215. package/query-builder/common/model/filter.d.ts +6 -0
  216. package/query-builder/common/model/legacy.d.ts +29 -0
  217. package/query-builder/common/model/operator-unit.d.ts +13 -0
  218. package/query-builder/common/model/operator.d.ts +21 -0
  219. package/query-builder/common/model/structure.d.ts +4 -0
  220. package/query-builder/common/model/type-map.d.ts +12 -0
  221. package/query-builder/common/model/type.d.ts +4 -0
  222. package/query-builder/common/services/output-query.service.d.ts +44 -0
  223. package/query-builder/common/services/type-convertor.service.d.ts +10 -0
  224. package/query-builder/package.json +14 -0
  225. package/query-builder/pepperi-addons-ngx-lib-query-builder.d.ts +8 -0
  226. package/query-builder/pepperi-addons-ngx-lib-query-builder.metadata.json +1 -0
  227. package/query-builder/public-api.d.ts +4 -0
  228. package/query-builder/query-builder-item/query-builder-item.component.d.ts +37 -0
  229. package/query-builder/query-builder-section/query-builder-section.component.d.ts +27 -0
  230. package/query-builder/query-builder-section/query-builder-section.component.theme.scss +7 -0
  231. package/query-builder/query-builder.component.d.ts +35 -0
  232. package/query-builder/query-builder.module.d.ts +2 -0
  233. package/query-builder/query-builder.service.d.ts +94 -0
  234. package/rich-html-textarea/pepperi-addons-ngx-lib-rich-html-textarea.metadata.json +1 -1
  235. package/rich-html-textarea/rich-html-textarea.component.d.ts +1 -0
  236. package/rich-html-textarea/rich-html-textarea.component.theme.scss +77 -70
  237. package/select/pepperi-addons-ngx-lib-select.metadata.json +1 -1
  238. package/select/select.component.d.ts +1 -0
  239. package/select/select.component.theme.scss +98 -2
  240. package/separator/pepperi-addons-ngx-lib-separator.metadata.json +1 -1
  241. package/separator/separator.component.theme.scss +1 -1
  242. package/side-bar/pepperi-addons-ngx-lib-side-bar.metadata.json +1 -1
  243. package/side-bar/side-bar.component.theme.scss +17 -16
  244. package/signature/pepperi-addons-ngx-lib-signature.metadata.json +1 -1
  245. package/signature/signature.component.d.ts +1 -0
  246. package/signature/signature.component.theme.scss +5 -21
  247. package/slider/pepperi-addons-ngx-lib-slider.metadata.json +1 -1
  248. package/slider/slider.component.theme.scss +54 -53
  249. package/smart-filters/boolean-filter/boolean-filter.component.d.ts +6 -1
  250. package/smart-filters/common/model/base-filter-component.d.ts +7 -0
  251. package/smart-filters/common/model/field.d.ts +4 -0
  252. package/smart-filters/common/model/operator.d.ts +1 -0
  253. package/smart-filters/common/model/type.d.ts +2 -2
  254. package/smart-filters/date-filter/date-filter.component.d.ts +8 -1
  255. package/smart-filters/multi-select-filter/multi-select-filter.component.d.ts +6 -0
  256. package/smart-filters/number-filter/number-filter.component.d.ts +5 -0
  257. package/smart-filters/pepperi-addons-ngx-lib-smart-filters.metadata.json +1 -1
  258. package/smart-filters/public-api.d.ts +1 -0
  259. package/smart-filters/smart-filters.component.theme.scss +6 -7
  260. package/smart-filters/text-filter/text-filter.component.d.ts +17 -0
  261. package/src/assets/i18n/en.ngx-lib.json +2 -1
  262. package/src/core/style/abstracts/breakpoints.scss +4 -2
  263. package/src/core/style/abstracts/functions.scss +232 -216
  264. package/src/core/style/abstracts/mixins.scss +191 -188
  265. package/src/core/style/base/base.scss +125 -124
  266. package/src/core/style/base/grids.scss +1 -1
  267. package/src/core/style/base/typography.scss +66 -62
  268. package/src/core/style/components/button.scss +57 -60
  269. package/src/core/style/components/checkbox.scss +41 -38
  270. package/src/core/style/components/datetime.scss +182 -22
  271. package/src/core/style/components/file.scss +159 -141
  272. package/src/core/style/components/general.scss +175 -287
  273. package/src/core/style/components/input.scss +22 -24
  274. package/src/core/style/components/quantity-selector.scss +15 -12
  275. package/src/core/style/components/radio-button.scss +22 -38
  276. package/src/core/style/components/select.scss +184 -182
  277. package/src/core/style/components/signature.scss +14 -12
  278. package/src/core/style/components/splitter.scss +58 -55
  279. package/src/core/style/components/textarea.scss +90 -78
  280. package/textarea/pepperi-addons-ngx-lib-textarea.metadata.json +1 -1
  281. package/textarea/textarea.component.d.ts +1 -0
  282. package/textarea/textarea.component.theme.scss +3 -2
  283. package/textbox/pepperi-addons-ngx-lib-textbox.metadata.json +1 -1
  284. package/textbox/textbox.component.theme.scss +1 -1
  285. package/theming.scss +50 -144
  286. package/top-bar/pepperi-addons-ngx-lib-top-bar.metadata.json +1 -1
  287. package/top-bar/top-bar.component.theme.scss +7 -7
  288. package/form/form.component.theme.scss +0 -2
  289. package/form/internal-button.component.theme.scss +0 -2
  290. package/form/internal-menu.component.theme.scss +0 -3
  291. package/list/list-actions.component.theme.scss +0 -3
  292. package/list/list-carousel.component.theme.scss +0 -9
  293. package/list/list-chooser.component.theme.scss +0 -3
  294. package/list/list-pager.component.theme.scss +0 -3
  295. package/list/list-sorting.component.theme.scss +0 -3
  296. package/list/list-views.component.theme.scss +0 -3
  297. package/list/list.component.theme.scss +0 -5
  298. package/list/list_old.component.theme.scss +0 -5
  299. package/menu/menu.component.theme.scss +0 -2
  300. package/search/search.component.theme.scss +0 -3
  301. package/textbox-icon/textbox-icon.component.theme.scss +0 -3
@@ -0,0 +1,1014 @@
1
+ import { Injectable, EventEmitter, Component, Input, Output, ViewChild, ViewContainerRef, ComponentFactoryResolver, NgModule } from '@angular/core';
2
+ import { CommonModule } from '@angular/common';
3
+ import { FormBuilder, ReactiveFormsModule } from '@angular/forms';
4
+ import { FlexLayoutModule } from '@angular/flex-layout';
5
+ import { PepSmartFilterOperators, PepSmartFilterOperatorUnits, createSmartFilter, createSmartFilterField, PepSmartFiltersModule } from '@pepperi-addons/ngx-lib/smart-filters';
6
+ import { PepSelectModule } from '@pepperi-addons/ngx-lib/select';
7
+ import { PepButtonModule } from '@pepperi-addons/ngx-lib/button';
8
+ import { PepGroupButtonsModule } from '@pepperi-addons/ngx-lib/group-buttons';
9
+ import { BehaviorSubject } from 'rxjs';
10
+
11
+ const Equals = {
12
+ legacy: 'IsEqual',
13
+ smartFilter: PepSmartFilterOperators.Equals,
14
+ type: ['boolean', 'int', 'text']
15
+ };
16
+ const NotEqual = {
17
+ legacy: 'IsNotEqual',
18
+ smartFilter: PepSmartFilterOperators.NotEqual,
19
+ type: null
20
+ };
21
+ const LessThan = {
22
+ legacy: '<',
23
+ smartFilter: PepSmartFilterOperators.LessThan,
24
+ type: null
25
+ };
26
+ const GreaterThan = {
27
+ legacy: '>',
28
+ smartFilter: PepSmartFilterOperators.GreaterThan,
29
+ type: null
30
+ };
31
+ /*
32
+ const GreaterThanOrEquals: IPepQueryBuilderOperator = {
33
+ legacy: {
34
+ operator: '>=',
35
+ type: 'Integer'
36
+ },
37
+ smartFilter: {
38
+ item: PepSmartFilterOperators.GreaterThanOrEquals,
39
+ type: 'int'
40
+ }
41
+ };
42
+
43
+ const LessThanOrEquals: IPepQueryBuilderOperator = {
44
+ legacy: {
45
+ operator: '<=',
46
+ type: 'Integer'
47
+ },
48
+ smartFilter: {
49
+ item: PepSmartFilterOperators.LessThanOrEquals,
50
+ type: 'int',
51
+ type: 'Integer'
52
+ }
53
+ }; */
54
+ const NumberRange = {
55
+ legacy: 'Between',
56
+ smartFilter: PepSmartFilterOperators.NumberRange,
57
+ type: ['int']
58
+ };
59
+ const Contains = {
60
+ legacy: 'Contains',
61
+ smartFilter: PepSmartFilterOperators.Contains,
62
+ type: null
63
+ };
64
+ /*
65
+ const BeginsWith: IPepQueryBuilderOperator = {
66
+ legacy: {
67
+ operator: 'BeginsWith',
68
+ type: 'String'
69
+ },
70
+ smartFilter: {
71
+ item: PepSmartFilterOperators.BeginsWith,
72
+ type: 'text'
73
+ }
74
+ };
75
+
76
+ const EndsWith: IPepQueryBuilderOperator = {
77
+ legacy: {
78
+ operator: 'EndsWith',
79
+ type: 'String'
80
+ },
81
+ smartFilter: {
82
+ item: PepSmartFilterOperators.EndsWith,
83
+ type: 'text'
84
+ }
85
+ };
86
+
87
+ const Before: IPepQueryBuilderOperator = {
88
+ legacy: {
89
+ operator: 'Before',
90
+ type: 'Date'
91
+ },
92
+ smartFilter: {
93
+ item: PepSmartFilterOperators.Before,
94
+ type: 'date'
95
+ }
96
+ };
97
+
98
+ const After: IPepQueryBuilderOperator = {
99
+ legacy: {
100
+ operator: 'After',
101
+ type: 'Date'
102
+ },
103
+ smartFilter: {
104
+ item: PepSmartFilterOperators.After,
105
+ type: 'date'
106
+ }
107
+ }; */
108
+ const InTheLast = {
109
+ legacy: 'InTheLast',
110
+ smartFilter: PepSmartFilterOperators.InTheLast,
111
+ type: null
112
+ };
113
+ const NotInTheLast = {
114
+ legacy: 'NotInTheLast',
115
+ smartFilter: PepSmartFilterOperators.NotInTheLast,
116
+ type: null
117
+ };
118
+ const Today = {
119
+ legacy: 'Today',
120
+ smartFilter: PepSmartFilterOperators.Today,
121
+ type: null
122
+ };
123
+ const ThisWeek = {
124
+ legacy: 'ThisWeek',
125
+ smartFilter: PepSmartFilterOperators.ThisWeek,
126
+ type: null
127
+ };
128
+ const ThisMonth = {
129
+ legacy: 'ThisMonth',
130
+ smartFilter: PepSmartFilterOperators.ThisMonth,
131
+ type: null
132
+ };
133
+ const DateRange = {
134
+ legacy: 'Between',
135
+ smartFilter: PepSmartFilterOperators.DateRange,
136
+ type: ['date-time']
137
+ };
138
+ const DueIn = {
139
+ legacy: 'DueIn',
140
+ smartFilter: PepSmartFilterOperators.DueIn,
141
+ type: null
142
+ };
143
+ const NotDueIn = {
144
+ legacy: 'NotDueIn',
145
+ smartFilter: PepSmartFilterOperators.NotDueIn,
146
+ type: null
147
+ };
148
+ const On = {
149
+ legacy: 'On',
150
+ smartFilter: PepSmartFilterOperators.On,
151
+ type: null
152
+ };
153
+ const IsEmpty = {
154
+ legacy: 'IsEmpty',
155
+ smartFilter: PepSmartFilterOperators.IsEmpty,
156
+ type: null
157
+ };
158
+ const IsNotEmpty = {
159
+ legacy: 'IsNotEmpty',
160
+ smartFilter: PepSmartFilterOperators.IsNotEmpty,
161
+ type: null
162
+ };
163
+ const In = {
164
+ legacy: 'IsEqual',
165
+ smartFilter: PepSmartFilterOperators.In,
166
+ type: ['multi-select']
167
+ };
168
+ const PepQueryBuilderOperators = [
169
+ Equals,
170
+ NotEqual,
171
+ LessThan,
172
+ // LessThanOrEquals,
173
+ GreaterThan,
174
+ // GreaterThanOrEquals,
175
+ NumberRange,
176
+ Contains,
177
+ // BeginsWith,
178
+ // EndsWith,
179
+ // After,
180
+ // Before,
181
+ InTheLast,
182
+ NotInTheLast,
183
+ Today,
184
+ ThisWeek,
185
+ ThisMonth,
186
+ DateRange,
187
+ DueIn,
188
+ NotDueIn,
189
+ On,
190
+ IsEmpty,
191
+ IsNotEmpty,
192
+ In
193
+ ];
194
+ /**
195
+ * gets a smart filter operator item
196
+ * @param operator legacy operator
197
+ * @param type smart filter's type
198
+ * @returns smart filter operator item
199
+ */
200
+ function getSmartBuilderOperator(operator, type) {
201
+ const smartFilterOperator = PepQueryBuilderOperators.find(item => item.legacy === operator &&
202
+ (item.type === null || item.type.includes(type)));
203
+ return smartFilterOperator ? smartFilterOperator.smartFilter : null;
204
+ }
205
+ /**
206
+ * gets a legacy operator value
207
+ * @param operator smart filter operator item
208
+ * @param type smart filter's type
209
+ * @returns legacy operator value
210
+ */
211
+ function getLegacyOperator(operator, type) {
212
+ const legacyOperator = PepQueryBuilderOperators.find(item => item.smartFilter === operator &&
213
+ (item.type === null || item.type.includes(type)));
214
+ return legacyOperator ? legacyOperator.legacy : null;
215
+ }
216
+
217
+ class PepTypeConvertorService {
218
+ constructor() {
219
+ this._operators = [];
220
+ this._booleans = [];
221
+ this.initOperators();
222
+ this.initBooleans();
223
+ }
224
+ get operators() {
225
+ return this._operators;
226
+ }
227
+ get booleans() {
228
+ return this._booleans;
229
+ }
230
+ initOperators() {
231
+ this._operators.push({
232
+ key: 'AND',
233
+ value: 'And'
234
+ });
235
+ this._operators.push({
236
+ key: 'OR',
237
+ value: 'Or'
238
+ });
239
+ }
240
+ initBooleans() {
241
+ this._booleans.push({
242
+ key: 'True',
243
+ value: 'True'
244
+ });
245
+ this._booleans.push({
246
+ key: 'False',
247
+ value: 'False'
248
+ });
249
+ }
250
+ }
251
+ PepTypeConvertorService.decorators = [
252
+ { type: Injectable }
253
+ ];
254
+ PepTypeConvertorService.ctorParameters = () => [];
255
+
256
+ class PepQueryBuilderSectionComponent {
257
+ constructor(_typeConvertorService) {
258
+ this._typeConvertorService = _typeConvertorService;
259
+ this.hasFields = true;
260
+ this.createSection = new EventEmitter();
261
+ this.createItem = new EventEmitter();
262
+ this.remove = new EventEmitter();
263
+ this.operatorChange = new EventEmitter();
264
+ }
265
+ ngOnInit() {
266
+ this.initOperators();
267
+ }
268
+ get f() {
269
+ return this.form.controls;
270
+ }
271
+ initOperators() {
272
+ this.toggleButtons = this._typeConvertorService.operators.map((operator) => {
273
+ return {
274
+ key: operator.key,
275
+ value: operator.value,
276
+ callback: (event) => this.onOperatorChanged(event)
277
+ };
278
+ });
279
+ }
280
+ onOperatorChanged(event) {
281
+ var _a;
282
+ if ((_a = event === null || event === void 0 ? void 0 : event.source) === null || _a === void 0 ? void 0 : _a.key) {
283
+ this.f.operator.setValue(event.source.key);
284
+ this.operatorChange.emit();
285
+ }
286
+ }
287
+ onAddRuleClicked() {
288
+ this.createItem.emit();
289
+ }
290
+ onAddRuleSetClicked() {
291
+ this.createSection.emit();
292
+ }
293
+ onDeleteSectionClicked() {
294
+ this.remove.emit();
295
+ }
296
+ }
297
+ PepQueryBuilderSectionComponent.decorators = [
298
+ { type: Component, args: [{
299
+ selector: 'pep-query-builder-section',
300
+ template: "<div fxLayout=\"row\" fxLayoutGap=\".5rem\">\n <div class=\"query-section-container\" fxLayout=\"column\" fxLayoutGap=\".5rem\">\n <div fxLayout=\"row\" fxLayoutAlign=\"space-between\">\n <pep-group-buttons [buttons]=\"toggleButtons\" [selectedButtonKey]=\"f.operator?.value || ''\" styleType=\"weak\"\n sizeType=\"sm\" [viewType]=\"'toggle'\" [buttonsDisabled]=\"!hasFields\">\n </pep-group-buttons>\n <div fxLayout=\"row\" fxLayoutGap=\".5rem\">\n <pep-button value=\"Add Filter\" styleType=\"weak\" styleStateType=\"system\" sizeType=\"sm\" classNames=\"\"\n [disabled]=\"!hasFields\" iconName=\"number_plus\" iconPosition=\"end\" [visible]=\"true\"\n (buttonClick)=\"onAddRuleClicked()\"></pep-button>\n <ng-container *ngIf=\"depth.current < depth.max-1\">\n <pep-button value=\"Add Filter Group\" styleType=\"weak\" styleStateType=\"system\" sizeType=\"sm\"\n classNames=\"\" [disabled]=\"!hasFields\" iconName=\"number_plus\" iconPosition=\"end\" [visible]=\"true\"\n (buttonClick)=\"onAddRuleSetClicked()\"></pep-button>\n </ng-container>\n </div>\n </div>\n <ng-container #sectionContainer></ng-container>\n </div>\n <pep-button *ngIf=\"depth.current > 0\" styleType=\"weak\" styleStateType=\"system_bin\" sizeType=\"md\" classNames=\"\"\n [disabled]=\"false\" iconName=\"system_bin\" iconPosition=\"end\" [visible]=\"true\"\n (buttonClick)=\"onDeleteSectionClicked()\">\n </pep-button>\n</div>",
301
+ styles: [".query-section-container{border-radius:.25rem;border-radius:var(--pep-border-radius-md,.25rem);padding:.5rem;width:100%}", ".query-section-container{box-shadow:0 .25rem .5rem 0 rgba(26,26,26,.08);box-shadow:var(--pep-shadow-sm-offset,0 .25rem .5rem 0) hsla(var(--pep-color-system-primary-h,0),var(--pep-color-system-primary-s,0%),var(--pep-color-system-primary-l,10%),.08);border:1px solid rgba(26,26,26,.24);border:1px solid hsla(var(--pep-color-system-primary-h,0),var(--pep-color-system-primary-s,0%),var(--pep-color-system-primary-l,10%),.24)}"]
302
+ },] }
303
+ ];
304
+ PepQueryBuilderSectionComponent.ctorParameters = () => [
305
+ { type: PepTypeConvertorService }
306
+ ];
307
+ PepQueryBuilderSectionComponent.propDecorators = {
308
+ form: [{ type: Input }],
309
+ depth: [{ type: Input }],
310
+ hasFields: [{ type: Input }],
311
+ createSection: [{ type: Output }],
312
+ createItem: [{ type: Output }],
313
+ remove: [{ type: Output }],
314
+ operatorChange: [{ type: Output }],
315
+ sectionContainer: [{ type: ViewChild, args: ['sectionContainer', { read: ViewContainerRef, static: true },] }]
316
+ };
317
+
318
+ class PepQueryBuilderItemComponent {
319
+ constructor(_fb, typeConvertorService) {
320
+ this._fb = _fb;
321
+ this.typeConvertorService = typeConvertorService;
322
+ this._fields = [];
323
+ this._options = [];
324
+ this._selectedField = null;
325
+ this.filterChange = new EventEmitter();
326
+ this.remove = new EventEmitter();
327
+ this.setupForm();
328
+ }
329
+ set fields(list) {
330
+ if ((list === null || list === void 0 ? void 0 : list.length) > 0) {
331
+ this._fields = list;
332
+ this._options = list.map(field => {
333
+ return {
334
+ key: field.smart.id,
335
+ value: field.smart.name
336
+ };
337
+ });
338
+ }
339
+ }
340
+ set selected(value) {
341
+ if (value) {
342
+ this._selectedField = value.smart;
343
+ this.queryForm.fieldType.setValue(value.query.fieldType);
344
+ }
345
+ }
346
+ set filter(value) {
347
+ if (value) {
348
+ this._filter = value;
349
+ }
350
+ }
351
+ set parentForm(value) {
352
+ if (value) {
353
+ this._parentForm = value;
354
+ this.addToParentForm();
355
+ }
356
+ }
357
+ ngOnInit() {
358
+ //
359
+ }
360
+ get f() {
361
+ return this.form.controls;
362
+ }
363
+ get queryForm() {
364
+ return this.f.query.controls;
365
+ }
366
+ setupForm() {
367
+ this.form = this._fb.group({
368
+ smart: this._fb.group({
369
+ fieldId: this._fb.control(null),
370
+ fieldType: this._fb.control(null),
371
+ operator: this._fb.control(null),
372
+ operatorUnit: this._fb.control(null),
373
+ values: this._fb.group({
374
+ first: this._fb.control(null),
375
+ second: this._fb.control(null)
376
+ })
377
+ }),
378
+ query: this._fb.group({
379
+ fieldType: this._fb.control(null)
380
+ })
381
+ });
382
+ }
383
+ addToParentForm() {
384
+ this._parentForm.setControl(this.formKey, this.form);
385
+ }
386
+ onFieldChanged(key) {
387
+ const item = this._fields.find(field => field.smart.id === key);
388
+ this.setupForm();
389
+ this.queryForm.fieldType.setValue(item.query.fieldType);
390
+ this.addToParentForm();
391
+ /**
392
+ * hack due to angular's change detection bug -
393
+ * ERROR Error: There is no FormControl instance attached to form control element with name: [formControlName]
394
+ */
395
+ this._selectedField = null;
396
+ setTimeout(() => {
397
+ this._selectedField = item ? item.smart : null;
398
+ }, 0);
399
+ this._filter = null;
400
+ }
401
+ onFilterChanged() {
402
+ if (this.form.valid) {
403
+ this.filterChange.emit();
404
+ }
405
+ }
406
+ onDeleteItemClicked() {
407
+ this.remove.emit();
408
+ }
409
+ }
410
+ PepQueryBuilderItemComponent.decorators = [
411
+ { type: Component, args: [{
412
+ selector: 'pep-query-builder-item',
413
+ template: "<div fxLayout=\"column\" fxLayoutGap=\".5rem\">\n <div fxLayout=\"row\" fxLayoutGap=\".5rem\">\n <pep-select fxFlex=\"25%\" [value]=\"_selectedField?.id\" xAlignment=\"left\" [options]=\"_options\"\n [renderTitle]=\"false\" (valueChange)=\"onFieldChanged($event)\"></pep-select>\n <ng-container *ngIf=\"_selectedField?.componentType\">\n <ng-container [ngSwitch]=\"_selectedField.componentType\">\n <ng-container *ngSwitchCase=\"'text'\">\n <pep-text-filter fxFlex=\"auto\" [showActionButtons]=\"false\" [field]=\"_selectedField\"\n [filter]=\"_filter\" [parentForm]=\"f.smart\" [emitOnChange]=\"true\" [inline]=\"true\"\n [renderTitle]=\"false\" (filterChange)=\"onFilterChanged()\">\n </pep-text-filter>\n </ng-container>\n <ng-container *ngSwitchCase=\"'boolean'\">\n <pep-boolean-filter fxFlex=\"auto\" [showActionButtons]=\"false\" [field]=\"_selectedField\"\n [filter]=\"_filter\" [parentForm]=\"f.smart\" [emitOnChange]=\"true\" [inline]=\"true\"\n [options]=\"typeConvertorService.booleans\" [renderTitle]=\"false\"\n (filterChange)=\"onFilterChanged()\">\n </pep-boolean-filter>\n </ng-container>\n <ng-container *ngSwitchCase=\"'date'\">\n <pep-date-filter fxFlex=\"auto\" [showActionButtons]=\"false\" [field]=\"_selectedField\"\n [filter]=\"_filter\" [parentForm]=\"f.smart\" [emitOnChange]=\"true\" [inline]=\"true\"\n [renderTitle]=\"false\" (filterChange)=\"onFilterChanged()\">\n </pep-date-filter>\n </ng-container>\n <ng-container *ngSwitchCase=\"'multi-select'\">\n <pep-multi-select-filter fxFlex=\"auto\" [showActionButtons]=\"false\" [field]=\"_selectedField\"\n [filter]=\"_filter\" [parentForm]=\"f.smart\" [emitOnChange]=\"true\" [inline]=\"true\"\n [renderTitle]=\"false\" (filterChange)=\"onFilterChanged()\">\n </pep-multi-select-filter>\n </ng-container>\n <ng-container *ngSwitchCase=\"'number'\">\n <pep-number-filter fxFlex=\"auto\" [showActionButtons]=\"false\" [field]=\"_selectedField\"\n [filter]=\"_filter\" [parentForm]=\"f.smart\" [emitOnChange]=\"true\" [inline]=\"true\"\n [renderTitle]=\"false\" (filterChange)=\"onFilterChanged()\">\n </pep-number-filter>\n </ng-container>\n </ng-container>\n </ng-container>\n <pep-button styleType=\"weak\" styleStateType=\"system_bin\" sizeType=\"md\" classNames=\"\" [disabled]=\"false\"\n iconName=\"system_bin\" iconPosition=\"end\" [visible]=\"true\" (buttonClick)=\"onDeleteItemClicked()\">\n </pep-button>\n </div>\n</div>",
414
+ styles: ["::ng-deep .pep-field-no-spacing{min-height:0!important;margin-bottom:0!important}"]
415
+ },] }
416
+ ];
417
+ PepQueryBuilderItemComponent.ctorParameters = () => [
418
+ { type: FormBuilder },
419
+ { type: PepTypeConvertorService }
420
+ ];
421
+ PepQueryBuilderItemComponent.propDecorators = {
422
+ formKey: [{ type: Input }],
423
+ fields: [{ type: Input }],
424
+ selected: [{ type: Input }],
425
+ filter: [{ type: Input }],
426
+ parentForm: [{ type: Input }],
427
+ filterChange: [{ type: Output }],
428
+ remove: [{ type: Output }]
429
+ };
430
+
431
+ class PepQueryBuilderTypeMap {
432
+ constructor() {
433
+ this.loadTypes();
434
+ }
435
+ loadTypes() {
436
+ this.map = new Map();
437
+ this.map.set('Bool', 'boolean');
438
+ this.map.set('JsonBool', 'boolean');
439
+ this.map.set('Integer', 'int');
440
+ this.map.set('Double', 'int');
441
+ this.map.set('String', 'text');
442
+ this.map.set('Guid', 'text');
443
+ this.map.set('Date', 'date');
444
+ this.map.set('DateTime', 'date-time');
445
+ this.map.set('MultipleStringValues', 'multi-select');
446
+ }
447
+ /**
448
+ * Converts legacy field type to smart builder type
449
+ * @param type legacy type
450
+ * @returns smart builder field type
451
+ */
452
+ getSmartBuilderType(key) {
453
+ const item = this.map.get(key);
454
+ return item ? item : null;
455
+ }
456
+ }
457
+
458
+ const Days = {
459
+ legacy: 'Days',
460
+ smartFilter: PepSmartFilterOperatorUnits.Days
461
+ };
462
+ const Weeks = {
463
+ legacy: 'Weeks',
464
+ smartFilter: PepSmartFilterOperatorUnits.Weeks
465
+ };
466
+ const Months = {
467
+ legacy: 'Months',
468
+ smartFilter: PepSmartFilterOperatorUnits.Months
469
+ };
470
+ const Years = {
471
+ legacy: 'Years',
472
+ smartFilter: PepSmartFilterOperatorUnits.Years
473
+ };
474
+ const PepQueryBuilderOperationUnit = [
475
+ Days,
476
+ Weeks,
477
+ Months,
478
+ Years,
479
+ ];
480
+ /**
481
+ * gets a smart filter operation unit item
482
+ * @param operationUnit legacy operation unit
483
+ * @returns smart filter operation unit item
484
+ */
485
+ function getSmartBuilderOperationUnit(operationUnit) {
486
+ const smartFilterOperationUnit = PepQueryBuilderOperationUnit.find(unit => unit.legacy === operationUnit);
487
+ return smartFilterOperationUnit ? smartFilterOperationUnit.smartFilter : null;
488
+ }
489
+ /**
490
+ * gets a legacy operation unit value
491
+ * @param operationUnit smart filter operation unit item
492
+ * @returns legacy operation unit value
493
+ */
494
+ function getLegacyOperationUnit(operationUnit) {
495
+ const legacyOperationUnit = PepQueryBuilderOperationUnit.find(unit => unit.smartFilter === operationUnit);
496
+ return legacyOperationUnit ? legacyOperationUnit.legacy : null;
497
+ }
498
+
499
+ class PepOutputQueryService {
500
+ constructor() {
501
+ //
502
+ }
503
+ /**
504
+ * generates a legacy query structure
505
+ * @param filters UI smart filters structure
506
+ * @returns legacy query
507
+ */
508
+ generateQuery(filters) {
509
+ this.initParams();
510
+ return this.sectionWalk(filters);
511
+ }
512
+ /**
513
+ * init params
514
+ */
515
+ initParams() {
516
+ this._complexIdCounter = 1;
517
+ this._expressionIdCounter = 1;
518
+ }
519
+ /**
520
+ * a recursive function dynamically builds legacy query structure
521
+ * @param current UI object represents either a section or filter component
522
+ * @returns section query data
523
+ */
524
+ sectionWalk(current) {
525
+ let section = null;
526
+ Object.keys(current).forEach(key => {
527
+ if (key.includes('item')) {
528
+ section = this.addToSection(section, {
529
+ ExpressionId: (this._expressionIdCounter++).toString(),
530
+ ApiName: current[key].smart.fieldId,
531
+ FieldType: current[key].query.fieldType,
532
+ Operation: getLegacyOperator(current[key].smart.operator, current[key].smart.fieldType),
533
+ Values: this.getItemValues(current[key].smart)
534
+ }, current.operator);
535
+ }
536
+ else if (key.includes('section')) {
537
+ const childSection = this.sectionWalk(current[key]);
538
+ if (childSection) {
539
+ section = this.addToSection(section, childSection, current.operator);
540
+ }
541
+ }
542
+ });
543
+ return section;
544
+ }
545
+ /**
546
+ * adds a legacy filter object to the current query structure
547
+ * @param section section query data
548
+ * @param item filter item
549
+ * @param operator query operator
550
+ * @returns
551
+ */
552
+ addToSection(section, item, operator) {
553
+ return section ? this.createSection(section, item, operator) : item;
554
+ }
555
+ /**
556
+ * creates a legacy complex object
557
+ * @param left LeftNode object
558
+ * @param right RightNode object
559
+ * @param operator query operator
560
+ * @returns legacy complex object
561
+ */
562
+ createSection(left, right, operator) {
563
+ return {
564
+ ComplexId: (this._complexIdCounter++).toString(),
565
+ LeftNode: left,
566
+ RightNode: right,
567
+ Operation: operator
568
+ };
569
+ }
570
+ /**
571
+ * gets legacy filter values object
572
+ * @param current UI filter object's values
573
+ * @returns an array represents legacy values
574
+ */
575
+ getItemValues(current) {
576
+ var _a;
577
+ let values = [];
578
+ if ((_a = current === null || current === void 0 ? void 0 : current.values) === null || _a === void 0 ? void 0 : _a.first) {
579
+ if (current.operator === PepSmartFilterOperators.In) { //multi select
580
+ values = current.values.first;
581
+ }
582
+ else if (current.operator === PepSmartFilterOperators.InTheLast ||
583
+ current.operator === PepSmartFilterOperators.NotInTheLast ||
584
+ current.operator === PepSmartFilterOperators.DueIn ||
585
+ current.operator === PepSmartFilterOperators.NotDueIn) { //operation unit
586
+ values.push(current.values.first);
587
+ if (current.operatorUnit) {
588
+ values.push(getLegacyOperationUnit(current.operatorUnit));
589
+ }
590
+ }
591
+ else {
592
+ values.push(current.values.first);
593
+ if (current.values.second) {
594
+ values.push(current.values.second);
595
+ }
596
+ }
597
+ }
598
+ return values;
599
+ }
600
+ }
601
+ PepOutputQueryService.decorators = [
602
+ { type: Injectable }
603
+ ];
604
+ PepOutputQueryService.ctorParameters = () => [];
605
+
606
+ var PepOperatorTypes;
607
+ (function (PepOperatorTypes) {
608
+ PepOperatorTypes["And"] = "AND";
609
+ PepOperatorTypes["Or"] = "OR";
610
+ })(PepOperatorTypes || (PepOperatorTypes = {}));
611
+
612
+ const MAX_STRUCTURE_DEPTH = 3;
613
+ class PepQueryBuilderService {
614
+ constructor(_fb, _resolver, _outputQueryService) {
615
+ this._fb = _fb;
616
+ this._resolver = _resolver;
617
+ this._outputQueryService = _outputQueryService;
618
+ this._outputQuery$ = new BehaviorSubject(null);
619
+ this._maxStructureDepth = MAX_STRUCTURE_DEPTH;
620
+ this.outputQuery$ = this._outputQuery$.asObservable();
621
+ }
622
+ set maxDepth(value) {
623
+ this._maxStructureDepth = value;
624
+ }
625
+ get maxDepth() {
626
+ return this._maxStructureDepth;
627
+ }
628
+ set fields(list) {
629
+ this._smartFilterFields = this.convertToSmartFilterFields(list);
630
+ }
631
+ get hasFields() {
632
+ var _a;
633
+ return ((_a = this._smartFilterFields) === null || _a === void 0 ? void 0 : _a.length) > 0;
634
+ }
635
+ set form(value) {
636
+ this._form = value;
637
+ }
638
+ get form() {
639
+ return this._form;
640
+ }
641
+ /**
642
+ * builds a dynamic UI query structure
643
+ * might has a different structure than the query's due to parent-child elements merge
644
+ * @param query legacy query
645
+ * @param containerRef reference to root element
646
+ */
647
+ buildQueryStructure(query, containerRef) {
648
+ //update root operator
649
+ if (this.hasProperty(query, 'ComplexId') &&
650
+ (query === null || query === void 0 ? void 0 : query.Operation) &&
651
+ query.Operation !== this._form.get('operator').value) {
652
+ this._form.get('operator').setValue(query.Operation);
653
+ }
654
+ this.flatten(this._form.get('operator').value, query, containerRef, this._form, 0);
655
+ }
656
+ /**
657
+ * checks if the object contains property
658
+ * @param obj object
659
+ * @param prop property name
660
+ * @returns true if contains, false otherwise
661
+ */
662
+ hasProperty(obj, prop) {
663
+ return Object.prototype.hasOwnProperty.call(obj, prop);
664
+ }
665
+ /**
666
+ * a recursive function dynamically builds UI filters structure
667
+ * @param parentOperator parent legacy complex operator
668
+ * @param current child legacy object (either another complex or expression type)
669
+ * @param containerRef parent element
670
+ * @param parentForm parent form
671
+ */
672
+ flatten(parentOperator, current, containerRef, parentForm, depth) {
673
+ if (this.hasProperty(current, 'ComplexId')) {
674
+ const section = current;
675
+ if (parentOperator === current.Operation) {
676
+ this.flatten(current.Operation, section.LeftNode, containerRef, parentForm, depth);
677
+ this.flatten(current.Operation, section.RightNode, containerRef, parentForm, depth);
678
+ }
679
+ else {
680
+ const result = this.createSection(section.Operation, containerRef, parentForm, depth);
681
+ this.flatten(section.Operation, section.LeftNode, result.containerRef, result.parentForm, depth + 1);
682
+ this.flatten(section.Operation, section.RightNode, result.containerRef, result.parentForm, depth + 1);
683
+ }
684
+ }
685
+ else if (this.hasProperty(current, 'ExpressionId')) {
686
+ this.createItem(current, containerRef, parentForm);
687
+ }
688
+ }
689
+ /**
690
+ * creates a container object of two or more child filter items
691
+ * @param operator AND/OR operator
692
+ * @param containerRef parent element
693
+ * @param parentForm parent form
694
+ * @param depth
695
+ * @returns an object containing the current element and current form
696
+ */
697
+ createSection(operator, containerRef, parentForm, depth) {
698
+ const factory = this._resolver.resolveComponentFactory(PepQueryBuilderSectionComponent);
699
+ const componentRef = containerRef.createComponent(factory);
700
+ const sectionGroup = this._fb.group({
701
+ operator: this._fb.control(operator)
702
+ });
703
+ let counter = 1;
704
+ Object.keys(parentForm.controls).forEach(item => { if (item.includes('section')) {
705
+ counter++;
706
+ } });
707
+ const formKey = `section${counter}`;
708
+ parentForm.addControl(formKey, sectionGroup);
709
+ componentRef.instance.form = sectionGroup;
710
+ componentRef.instance.depth = {
711
+ current: depth,
712
+ max: this._maxStructureDepth
713
+ };
714
+ componentRef.instance.createSection.subscribe(() => {
715
+ const section = this.createSection(PepOperatorTypes.And, componentRef.instance.sectionContainer, sectionGroup, depth + 1);
716
+ this.createItem(null, section.containerRef, section.parentForm);
717
+ });
718
+ componentRef.instance.createItem.subscribe(() => {
719
+ this.createItem(null, componentRef.instance.sectionContainer, sectionGroup);
720
+ });
721
+ componentRef.instance.remove.subscribe(() => {
722
+ parentForm.removeControl(formKey);
723
+ componentRef.destroy();
724
+ this.createOutputQuery();
725
+ });
726
+ componentRef.instance.operatorChange.subscribe(() => {
727
+ this.createOutputQuery();
728
+ });
729
+ return {
730
+ containerRef: componentRef.instance.sectionContainer,
731
+ parentForm: sectionGroup
732
+ };
733
+ }
734
+ /**
735
+ * creates a component represents filter item (leaf element - has no childs)
736
+ * @param current filter legacy element
737
+ * @param containerRef parent element
738
+ * @param parentForm parent form
739
+ */
740
+ createItem(current, containerRef, parentForm) {
741
+ const factory = this._resolver.resolveComponentFactory(PepQueryBuilderItemComponent);
742
+ const componentRef = containerRef.createComponent(factory);
743
+ let counter = 1;
744
+ Object.keys(parentForm.controls).forEach(item => { if (item.includes('item')) {
745
+ counter++;
746
+ } });
747
+ const formKey = `item${counter}`;
748
+ componentRef.instance.formKey = formKey;
749
+ componentRef.instance.fields = this._smartFilterFields;
750
+ const selectedField = this.getSelectedField(current);
751
+ if (selectedField) {
752
+ componentRef.instance.selected = selectedField;
753
+ if (current) {
754
+ componentRef.instance.filter = this.getFilter(current, selectedField.smart);
755
+ }
756
+ }
757
+ componentRef.instance.parentForm = parentForm;
758
+ componentRef.instance.filterChange.subscribe(() => {
759
+ this.createOutputQuery();
760
+ });
761
+ componentRef.instance.remove.subscribe(() => {
762
+ parentForm.removeControl(formKey);
763
+ componentRef.destroy();
764
+ this.createOutputQuery();
765
+ });
766
+ }
767
+ /**
768
+ * creates a smart filter object
769
+ * @param current filter legacy element
770
+ * @param field filter's selected field
771
+ * @returns smart filter object
772
+ */
773
+ getFilter(current, field) {
774
+ const operator = getSmartBuilderOperator(current.Operation, field.type);
775
+ if (operator) {
776
+ const filterValues = this.getFilterValues(current, operator, field);
777
+ return createSmartFilter(current.ApiName, operator, filterValues.first, filterValues.second, filterValues.operationUnit);
778
+ }
779
+ else {
780
+ return null;
781
+ }
782
+ }
783
+ /**
784
+ * get smart filter field
785
+ * @param current filter legacy element
786
+ * @returns smart filter field, if not found returns the first field
787
+ */
788
+ getSelectedField(current) {
789
+ var _a, _b;
790
+ if (current) {
791
+ const item = this._smartFilterFields.find(field => field.smart.id === current.ApiName);
792
+ return item ? item : ((_a = this._smartFilterFields) === null || _a === void 0 ? void 0 : _a.length) > 0 ? this._smartFilterFields[0] : null;
793
+ }
794
+ else {
795
+ return ((_b = this._smartFilterFields) === null || _b === void 0 ? void 0 : _b.length) > 0 ? this._smartFilterFields[0] : null;
796
+ }
797
+ }
798
+ /**
799
+ * gets smart filter's values data
800
+ * @param current filter legacy element
801
+ * @param operator smart filter operator
802
+ * @param field filter's selected field
803
+ * @returns object contains the filter values data
804
+ */
805
+ getFilterValues(current, operator, field) {
806
+ var _a, _b, _c, _d, _e;
807
+ const data = {
808
+ first: null,
809
+ second: null,
810
+ operationUnit: null
811
+ };
812
+ if (operator === PepSmartFilterOperators.In) { //multi select
813
+ //filter keys don't exist on field options
814
+ data.first = ((_a = current === null || current === void 0 ? void 0 : current.Values) === null || _a === void 0 ? void 0 : _a.length) > 0 ? current.Values.filter(item => {
815
+ return field.options.find(option => option.key === item);
816
+ }) : null;
817
+ }
818
+ else if (operator === PepSmartFilterOperators.InTheLast ||
819
+ operator === PepSmartFilterOperators.NotInTheLast ||
820
+ operator === PepSmartFilterOperators.DueIn ||
821
+ operator === PepSmartFilterOperators.NotDueIn) { //operation unit
822
+ data.first = ((_b = current === null || current === void 0 ? void 0 : current.Values) === null || _b === void 0 ? void 0 : _b.length) > 0 ? current.Values[0] : null;
823
+ if (((_c = current === null || current === void 0 ? void 0 : current.Values) === null || _c === void 0 ? void 0 : _c.length) === 2) {
824
+ data.operationUnit = getSmartBuilderOperationUnit(current.Values[1]);
825
+ }
826
+ }
827
+ else {
828
+ data.first = ((_d = current === null || current === void 0 ? void 0 : current.Values) === null || _d === void 0 ? void 0 : _d.length) > 0 ? current.Values[0] : null;
829
+ data.second = ((_e = current === null || current === void 0 ? void 0 : current.Values) === null || _e === void 0 ? void 0 : _e.length) === 2 ? current.Values[1] : null;
830
+ }
831
+ return data;
832
+ }
833
+ /**
834
+ * converts legacy fields to smart filter fields
835
+ * @param fields legacy fields array
836
+ * @returns smart filter fields array
837
+ */
838
+ convertToSmartFilterFields(fields) {
839
+ if ((fields === null || fields === void 0 ? void 0 : fields.length) > 0) {
840
+ const typeMapper = new PepQueryBuilderTypeMap();
841
+ return fields.map((field) => {
842
+ var _a;
843
+ return {
844
+ smart: createSmartFilterField({
845
+ id: field.FieldID,
846
+ name: field.Title,
847
+ options: (_a = field.OptionalValues) === null || _a === void 0 ? void 0 : _a.map(option => {
848
+ return {
849
+ key: option.Key,
850
+ value: option.Value
851
+ };
852
+ })
853
+ }, typeMapper.getSmartBuilderType(field.FieldType)),
854
+ query: {
855
+ fieldType: field.FieldType
856
+ }
857
+ };
858
+ });
859
+ }
860
+ else {
861
+ return [];
862
+ }
863
+ }
864
+ /**
865
+ * creates a legacy output query
866
+ */
867
+ createOutputQuery() {
868
+ if (this._form.valid) {
869
+ const query = this._outputQueryService.generateQuery(this._form.value);
870
+ this._outputQuery$.next(query);
871
+ }
872
+ }
873
+ }
874
+ PepQueryBuilderService.decorators = [
875
+ { type: Injectable }
876
+ ];
877
+ PepQueryBuilderService.ctorParameters = () => [
878
+ { type: FormBuilder },
879
+ { type: ComponentFactoryResolver },
880
+ { type: PepOutputQueryService }
881
+ ];
882
+
883
+ class PepQueryBuilderComponent {
884
+ constructor(_fb, queryBuilderService) {
885
+ this._fb = _fb;
886
+ this.queryBuilderService = queryBuilderService;
887
+ this._query = null;
888
+ this.queryChange = new EventEmitter();
889
+ this.formValidationChange = new EventEmitter();
890
+ this._lastFormValidStatus = true;
891
+ this.hasFields = false;
892
+ this.setupForm();
893
+ this.initDepth();
894
+ this._formSubscription$ = this.queryBuilderService.form.valueChanges.subscribe((val) => {
895
+ if (this.queryBuilderService.form.valid !== this._lastFormValidStatus) {
896
+ this._lastFormValidStatus = this.queryBuilderService.form.valid;
897
+ this.formValidationChange.emit(this._lastFormValidStatus);
898
+ }
899
+ });
900
+ this._outputQuerySubscription$ = this.queryBuilderService.outputQuery$.subscribe((outputQuery) => {
901
+ this.queryChange.emit(outputQuery);
902
+ });
903
+ }
904
+ set query(object) {
905
+ this._query = object;
906
+ this.loadQuery();
907
+ }
908
+ set fields(list) {
909
+ this.queryBuilderService.fields = list;
910
+ this.hasFields = this.queryBuilderService.hasFields;
911
+ this.loadQuery();
912
+ }
913
+ set maxDepth(value) {
914
+ this.queryBuilderService.maxDepth = value;
915
+ }
916
+ ngOnInit() {
917
+ //
918
+ }
919
+ setupForm() {
920
+ this.queryBuilderService.form = this._fb.group({
921
+ operator: this._fb.control(PepOperatorTypes.And)
922
+ });
923
+ }
924
+ initDepth() {
925
+ this.depth = {
926
+ current: 0,
927
+ max: this.queryBuilderService.maxDepth
928
+ };
929
+ }
930
+ /**
931
+ * builds UI query structure as soon as both the fields and query loads
932
+ */
933
+ loadQuery() {
934
+ var _a;
935
+ if (this._query &&
936
+ this.queryBuilderService.hasFields &&
937
+ ((_a = this.root) === null || _a === void 0 ? void 0 : _a.sectionContainer)) {
938
+ this.queryBuilderService.buildQueryStructure(this._query, this.root.sectionContainer);
939
+ }
940
+ }
941
+ onCreateSection() {
942
+ const section = this.queryBuilderService.createSection(PepOperatorTypes.And, this.root.sectionContainer, this.queryBuilderService.form, 1);
943
+ this.queryBuilderService.createItem(null, section.containerRef, section.parentForm);
944
+ }
945
+ onCreateItem() {
946
+ this.queryBuilderService.createItem(null, this.root.sectionContainer, this.queryBuilderService.form);
947
+ }
948
+ onOperatorChange() {
949
+ this.queryBuilderService.createOutputQuery();
950
+ }
951
+ ngOnDestroy() {
952
+ if (this._formSubscription$) {
953
+ this._formSubscription$.unsubscribe();
954
+ }
955
+ if (this._outputQuerySubscription$) {
956
+ this._outputQuerySubscription$.unsubscribe();
957
+ }
958
+ }
959
+ }
960
+ PepQueryBuilderComponent.decorators = [
961
+ { type: Component, args: [{
962
+ selector: 'pep-query-builder',
963
+ template: "<pep-query-builder-section #rootContainer [form]=\"queryBuilderService.form\" [depth]=\"depth\" [hasFields]=\"hasFields\"\n (createSection)=\"onCreateSection()\" (createItem)=\"onCreateItem()\" (operatorChange)=\"onOperatorChange()\">\n</pep-query-builder-section>",
964
+ providers: [PepQueryBuilderService, PepTypeConvertorService, PepOutputQueryService],
965
+ styles: [""]
966
+ },] }
967
+ ];
968
+ PepQueryBuilderComponent.ctorParameters = () => [
969
+ { type: FormBuilder },
970
+ { type: PepQueryBuilderService }
971
+ ];
972
+ PepQueryBuilderComponent.propDecorators = {
973
+ query: [{ type: Input }],
974
+ fields: [{ type: Input }],
975
+ maxDepth: [{ type: Input }],
976
+ queryChange: [{ type: Output }],
977
+ formValidationChange: [{ type: Output }],
978
+ root: [{ type: ViewChild, args: ['rootContainer', { static: true },] }]
979
+ };
980
+
981
+ class PepQueryBuilderModule {
982
+ }
983
+ PepQueryBuilderModule.decorators = [
984
+ { type: NgModule, args: [{
985
+ imports: [
986
+ CommonModule,
987
+ ReactiveFormsModule,
988
+ FlexLayoutModule,
989
+ PepSelectModule,
990
+ PepButtonModule,
991
+ PepGroupButtonsModule,
992
+ PepSmartFiltersModule
993
+ ],
994
+ exports: [
995
+ PepQueryBuilderComponent
996
+ ],
997
+ declarations: [
998
+ PepQueryBuilderComponent,
999
+ PepQueryBuilderSectionComponent,
1000
+ PepQueryBuilderItemComponent
1001
+ ]
1002
+ },] }
1003
+ ];
1004
+
1005
+ /*
1006
+ * Public API Surface of ngx-lib/query-builder
1007
+ */
1008
+
1009
+ /**
1010
+ * Generated bundle index. Do not edit.
1011
+ */
1012
+
1013
+ export { PepQueryBuilderComponent, PepQueryBuilderModule, PepQueryBuilderService, PepOutputQueryService as ɵa, PepTypeConvertorService as ɵb, PepQueryBuilderSectionComponent as ɵc, PepQueryBuilderItemComponent as ɵd };
1014
+ //# sourceMappingURL=pepperi-addons-ngx-lib-query-builder.js.map