@bravobit/bb-foundation 0.21.0 → 0.21.3

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 (462) hide show
  1. package/README.md +47 -47
  2. package/auth/index.d.ts +5 -5
  3. package/auth/lib/auth.interceptor.d.ts +21 -21
  4. package/auth/lib/auth.module.d.ts +15 -15
  5. package/auth/lib/auth.service.d.ts +59 -59
  6. package/auth/lib/auth.session.d.ts +34 -34
  7. package/auth/lib/directives/authenticated.directive.d.ts +14 -14
  8. package/auth/lib/directives/permission.directive.d.ts +24 -24
  9. package/auth/lib/directives/role.directive.d.ts +16 -16
  10. package/auth/lib/guards/anonymous.guard.d.ts +11 -11
  11. package/auth/lib/guards/authenticated.guard.d.ts +11 -11
  12. package/auth/lib/helpers/jwt.helper.d.ts +8 -8
  13. package/auth/lib/helpers/mapper.helper.d.ts +23 -23
  14. package/auth/lib/interfaces/config.interface.d.ts +12 -12
  15. package/auth/lib/interfaces/mapper.interface.d.ts +19 -19
  16. package/auth/lib/interfaces/provider.interface.d.ts +16 -16
  17. package/auth/lib/interfaces/token.interface.d.ts +11 -11
  18. package/auth/lib/permissions.service.d.ts +14 -14
  19. package/auth/lib/providers/email.provider.d.ts +15 -15
  20. package/auth/lib/providers/verify.provider.d.ts +13 -13
  21. package/auth/lib/tokens/use-authorization.token.d.ts +2 -2
  22. package/auth/public_api.d.ts +18 -18
  23. package/collections/index.d.ts +5 -5
  24. package/collections/lib/collection.d.ts +42 -43
  25. package/collections/lib/collections.module.d.ts +10 -10
  26. package/collections/lib/components/collections-pager/collections-pager.component.d.ts +34 -34
  27. package/collections/lib/components/collections-viewer/collections-viewer.component.d.ts +12 -12
  28. package/collections/lib/components/collections.directive.d.ts +17 -17
  29. package/collections/lib/interfaces/collection.interface.d.ts +27 -26
  30. package/collections/lib/providers/api-collection.provider.d.ts +18 -19
  31. package/collections/lib/providers/collection.provider.d.ts +6 -6
  32. package/collections/lib/providers/local-collection.provider.d.ts +8 -8
  33. package/collections/public_api.d.ts +9 -9
  34. package/controls/index.d.ts +5 -5
  35. package/controls/lib/checkbox/checkbox/checkbox.component.d.ts +47 -47
  36. package/controls/lib/checkbox/checkbox-group/checkbox-group.component.d.ts +22 -22
  37. package/controls/lib/checkbox/checkbox.module.d.ts +9 -9
  38. package/controls/lib/controls.module.d.ts +7 -7
  39. package/controls/public_api.d.ts +4 -4
  40. package/dashboard/index.d.ts +5 -5
  41. package/dashboard/lib/dashboard/dashboard.component.d.ts +19 -19
  42. package/dashboard/lib/dashboard-header/dashboard-header.component.d.ts +11 -11
  43. package/dashboard/lib/dashboard-menu/dashboard-menu.component.d.ts +9 -9
  44. package/dashboard/lib/dashboard-menu-item/dashboard-menu-item.component.d.ts +11 -11
  45. package/dashboard/lib/dashboard-sidebar/dashboard-sidebar.component.d.ts +21 -21
  46. package/dashboard/lib/dashboard-sidebar-group/dashboard-sidebar-group.component.d.ts +27 -27
  47. package/dashboard/lib/dashboard-sidebar-item/dashboard-sidebar-item.component.d.ts +16 -16
  48. package/dashboard/lib/dashboard.module.d.ts +16 -16
  49. package/dashboard/public_api.d.ts +8 -8
  50. package/dialog/index.d.ts +5 -5
  51. package/dialog/lib/dialog-actions/dialog-actions.component.d.ts +5 -5
  52. package/dialog/lib/dialog-confirm/dialog-confirm.component.d.ts +16 -16
  53. package/dialog/lib/dialog-container/dialog-container.component.d.ts +24 -24
  54. package/dialog/lib/dialog-header/dialog-header.component.d.ts +9 -9
  55. package/dialog/lib/dialog-link/dialog-link.component.d.ts +5 -5
  56. package/dialog/lib/dialog-modal/dialog-modal.component.d.ts +12 -12
  57. package/dialog/lib/dialog-overlay/dialog-overlay.component.d.ts +22 -22
  58. package/dialog/lib/dialog.injector.d.ts +8 -8
  59. package/dialog/lib/dialog.insertion.d.ts +8 -8
  60. package/dialog/lib/dialog.interfaces.d.ts +3 -3
  61. package/dialog/lib/dialog.module.d.ts +19 -19
  62. package/dialog/lib/dialog.ref.d.ts +8 -8
  63. package/dialog/lib/dialog.service.d.ts +19 -19
  64. package/dialog/public_api.d.ts +9 -9
  65. package/elements/index.d.ts +5 -5
  66. package/elements/lib/avatar/avatar.component.d.ts +25 -25
  67. package/elements/lib/button/button.component.d.ts +23 -23
  68. package/elements/lib/checkbox/checkbox.component.d.ts +27 -27
  69. package/elements/lib/date-picker/date-picker.component.d.ts +69 -69
  70. package/elements/lib/directives/addon.directive.d.ts +9 -9
  71. package/elements/lib/directives/autosize.directive.d.ts +18 -18
  72. package/elements/lib/directives/focus-trap.directive.d.ts +17 -17
  73. package/elements/lib/directives/focus.directive.d.ts +14 -14
  74. package/elements/lib/directives/form-submit.directive.d.ts +17 -17
  75. package/elements/lib/directives/input.directive.d.ts +38 -38
  76. package/elements/lib/directives/template.directive.d.ts +10 -10
  77. package/elements/lib/dropdown/dropdown.component.d.ts +21 -21
  78. package/elements/lib/elements.interfaces.d.ts +25 -25
  79. package/elements/lib/elements.module.d.ts +116 -116
  80. package/elements/lib/file-picker/file-picker.component.d.ts +49 -49
  81. package/elements/lib/form-control/form-control.component.d.ts +21 -21
  82. package/elements/lib/form-error/form-error.component.d.ts +29 -29
  83. package/elements/lib/form-group/form-group.component.d.ts +10 -10
  84. package/elements/lib/icon/icon.component.d.ts +22 -22
  85. package/elements/lib/image-picker/image-picker.component.d.ts +38 -38
  86. package/elements/lib/pipes/file-image.pipe.d.ts +13 -13
  87. package/elements/lib/pipes/file-size.pipe.d.ts +8 -8
  88. package/elements/lib/pipes/relative-time.pipe.d.ts +19 -19
  89. package/elements/lib/spinner/spinner.component.d.ts +12 -12
  90. package/elements/lib/tag/tag.component.d.ts +7 -7
  91. package/elements/public_api.d.ts +25 -25
  92. package/esm2020/auth/bravobit-bb-foundation-auth.mjs +4 -4
  93. package/esm2020/auth/lib/auth.interceptor.mjs +93 -93
  94. package/esm2020/auth/lib/auth.module.mjs +54 -54
  95. package/esm2020/auth/lib/auth.service.mjs +281 -281
  96. package/esm2020/auth/lib/auth.session.mjs +131 -131
  97. package/esm2020/auth/lib/directives/authenticated.directive.mjs +31 -31
  98. package/esm2020/auth/lib/directives/permission.directive.mjs +80 -80
  99. package/esm2020/auth/lib/directives/role.directive.mjs +37 -37
  100. package/esm2020/auth/lib/guards/anonymous.guard.mjs +34 -34
  101. package/esm2020/auth/lib/guards/authenticated.guard.mjs +35 -35
  102. package/esm2020/auth/lib/helpers/jwt.helper.mjs +69 -69
  103. package/esm2020/auth/lib/helpers/mapper.helper.mjs +35 -35
  104. package/esm2020/auth/lib/interfaces/config.interface.mjs +3 -3
  105. package/esm2020/auth/lib/interfaces/mapper.interface.mjs +2 -2
  106. package/esm2020/auth/lib/interfaces/provider.interface.mjs +2 -2
  107. package/esm2020/auth/lib/interfaces/token.interface.mjs +2 -2
  108. package/esm2020/auth/lib/permissions.service.mjs +56 -56
  109. package/esm2020/auth/lib/providers/email.provider.mjs +25 -25
  110. package/esm2020/auth/lib/providers/verify.provider.mjs +19 -19
  111. package/esm2020/auth/lib/tokens/use-authorization.token.mjs +3 -3
  112. package/esm2020/auth/public_api.mjs +19 -19
  113. package/esm2020/bravobit-bb-foundation.mjs +4 -4
  114. package/esm2020/collections/bravobit-bb-foundation-collections.mjs +4 -4
  115. package/esm2020/collections/lib/collection.mjs +100 -102
  116. package/esm2020/collections/lib/collections.module.mjs +54 -54
  117. package/esm2020/collections/lib/components/collections-pager/collections-pager.component.mjs +123 -123
  118. package/esm2020/collections/lib/components/collections-viewer/collections-viewer.component.mjs +31 -31
  119. package/esm2020/collections/lib/components/collections.directive.mjs +43 -43
  120. package/esm2020/collections/lib/interfaces/collection.interface.mjs +2 -2
  121. package/esm2020/collections/lib/providers/api-collection.provider.mjs +91 -71
  122. package/esm2020/collections/lib/providers/collection.provider.mjs +13 -13
  123. package/esm2020/collections/lib/providers/local-collection.provider.mjs +16 -16
  124. package/esm2020/collections/public_api.mjs +10 -10
  125. package/esm2020/controls/bravobit-bb-foundation-controls.mjs +4 -4
  126. package/esm2020/controls/lib/checkbox/checkbox/checkbox.component.mjs +153 -153
  127. package/esm2020/controls/lib/checkbox/checkbox-group/checkbox-group.component.mjs +61 -61
  128. package/esm2020/controls/lib/checkbox/checkbox.module.mjs +19 -19
  129. package/esm2020/controls/lib/controls.module.mjs +16 -16
  130. package/esm2020/controls/public_api.mjs +5 -5
  131. package/esm2020/dashboard/bravobit-bb-foundation-dashboard.mjs +4 -4
  132. package/esm2020/dashboard/lib/dashboard/dashboard.component.mjs +56 -56
  133. package/esm2020/dashboard/lib/dashboard-header/dashboard-header.component.mjs +30 -30
  134. package/esm2020/dashboard/lib/dashboard-menu/dashboard-menu.component.mjs +31 -31
  135. package/esm2020/dashboard/lib/dashboard-menu-item/dashboard-menu-item.component.mjs +29 -29
  136. package/esm2020/dashboard/lib/dashboard-sidebar/dashboard-sidebar.component.mjs +75 -75
  137. package/esm2020/dashboard/lib/dashboard-sidebar-group/dashboard-sidebar-group.component.mjs +99 -99
  138. package/esm2020/dashboard/lib/dashboard-sidebar-item/dashboard-sidebar-item.component.mjs +62 -62
  139. package/esm2020/dashboard/lib/dashboard.module.mjs +47 -47
  140. package/esm2020/dashboard/public_api.mjs +9 -9
  141. package/esm2020/dialog/bravobit-bb-foundation-dialog.mjs +4 -4
  142. package/esm2020/dialog/lib/dialog-actions/dialog-actions.component.mjs +12 -12
  143. package/esm2020/dialog/lib/dialog-confirm/dialog-confirm.component.mjs +37 -37
  144. package/esm2020/dialog/lib/dialog-container/dialog-container.component.mjs +153 -153
  145. package/esm2020/dialog/lib/dialog-header/dialog-header.component.mjs +25 -25
  146. package/esm2020/dialog/lib/dialog-link/dialog-link.component.mjs +11 -11
  147. package/esm2020/dialog/lib/dialog-modal/dialog-modal.component.mjs +46 -46
  148. package/esm2020/dialog/lib/dialog-overlay/dialog-overlay.component.mjs +134 -134
  149. package/esm2020/dialog/lib/dialog.injector.mjs +18 -18
  150. package/esm2020/dialog/lib/dialog.insertion.mjs +16 -16
  151. package/esm2020/dialog/lib/dialog.interfaces.mjs +3 -3
  152. package/esm2020/dialog/lib/dialog.module.mjs +68 -68
  153. package/esm2020/dialog/lib/dialog.ref.mjs +22 -22
  154. package/esm2020/dialog/lib/dialog.service.mjs +77 -77
  155. package/esm2020/dialog/public_api.mjs +10 -10
  156. package/esm2020/elements/bravobit-bb-foundation-elements.mjs +4 -4
  157. package/esm2020/elements/lib/avatar/avatar.component.mjs +145 -145
  158. package/esm2020/elements/lib/button/button.component.mjs +61 -61
  159. package/esm2020/elements/lib/checkbox/checkbox.component.mjs +73 -73
  160. package/esm2020/elements/lib/date-picker/date-picker.component.mjs +304 -304
  161. package/esm2020/elements/lib/directives/addon.directive.mjs +29 -29
  162. package/esm2020/elements/lib/directives/autosize.directive.mjs +72 -72
  163. package/esm2020/elements/lib/directives/focus-trap.directive.mjs +77 -77
  164. package/esm2020/elements/lib/directives/focus.directive.mjs +39 -39
  165. package/esm2020/elements/lib/directives/form-submit.directive.mjs +50 -50
  166. package/esm2020/elements/lib/directives/input.directive.mjs +136 -136
  167. package/esm2020/elements/lib/directives/template.directive.mjs +28 -28
  168. package/esm2020/elements/lib/dropdown/dropdown.component.mjs +100 -100
  169. package/esm2020/elements/lib/elements.interfaces.mjs +4 -4
  170. package/esm2020/elements/lib/elements.module.mjs +177 -177
  171. package/esm2020/elements/lib/file-picker/file-picker.component.mjs +236 -236
  172. package/esm2020/elements/lib/form-control/form-control.component.mjs +49 -49
  173. package/esm2020/elements/lib/form-error/form-error.component.mjs +108 -108
  174. package/esm2020/elements/lib/form-group/form-group.component.mjs +18 -18
  175. package/esm2020/elements/lib/icon/icon.component.mjs +102 -102
  176. package/esm2020/elements/lib/image-picker/image-picker.component.mjs +106 -106
  177. package/esm2020/elements/lib/pipes/file-image.pipe.mjs +42 -42
  178. package/esm2020/elements/lib/pipes/file-size.pipe.mjs +28 -28
  179. package/esm2020/elements/lib/pipes/relative-time.pipe.mjs +94 -94
  180. package/esm2020/elements/lib/spinner/spinner.component.mjs +25 -25
  181. package/esm2020/elements/lib/tag/tag.component.mjs +18 -18
  182. package/esm2020/elements/public_api.mjs +26 -26
  183. package/esm2020/http/bravobit-bb-foundation-http.mjs +4 -4
  184. package/esm2020/http/lib/classes/http.config.mjs +29 -29
  185. package/esm2020/http/lib/classes/http.error.mjs +20 -20
  186. package/esm2020/http/lib/http.interfaces.mjs +2 -2
  187. package/esm2020/http/lib/http.module.mjs +43 -43
  188. package/esm2020/http/lib/interceptors/base-url.interceptor.mjs +50 -50
  189. package/esm2020/http/lib/interceptors/error.interceptor.mjs +32 -32
  190. package/esm2020/http/public_api.mjs +7 -7
  191. package/esm2020/lib/core/miscellaneous/regex.mjs +5 -5
  192. package/esm2020/lib/core/miscellaneous/validator.mjs +85 -85
  193. package/esm2020/lib/core/mixins/can-disable.mjs +16 -16
  194. package/esm2020/lib/core/mixins/can-hide-errors.mjs +16 -16
  195. package/esm2020/lib/core/mixins/can-load.mjs +16 -16
  196. package/esm2020/lib/core/mixins/constructor.mjs +2 -2
  197. package/esm2020/lib/core/mixins/has-error.mjs +16 -16
  198. package/esm2020/lib/core/mixins/is-focused.mjs +16 -16
  199. package/esm2020/lib/core/mixins/is-grouped.mjs +16 -16
  200. package/esm2020/lib/core/mixins/is-readonly.mjs +16 -16
  201. package/esm2020/lib/core/mixins/is-required.mjs +16 -16
  202. package/esm2020/lib/core/services/clipboard.service.mjs +70 -70
  203. package/esm2020/lib/core/services/exif.service.mjs +163 -163
  204. package/esm2020/lib/core/services/file-loader.service.mjs +87 -87
  205. package/esm2020/lib/core/services/image-converter.service.mjs +123 -123
  206. package/esm2020/lib/core/services/languages.service.mjs +74 -74
  207. package/esm2020/lib/core/services/network.service.mjs +55 -55
  208. package/esm2020/lib/core/services/patch.service.mjs +63 -63
  209. package/esm2020/lib/core/services/platform.service.mjs +42 -42
  210. package/esm2020/lib/core/tokens/accept-language.token.mjs +3 -3
  211. package/esm2020/lib/core/tokens/base-url.token.mjs +3 -3
  212. package/esm2020/lib/core/tokens/cookie.token.mjs +3 -3
  213. package/esm2020/lib/core/tokens/location.token.mjs +6 -6
  214. package/esm2020/lib/core/tokens/navigator.token.mjs +6 -6
  215. package/esm2020/lib/core/tokens/window.token.mjs +12 -12
  216. package/esm2020/localize/bravobit-bb-foundation-localize.mjs +4 -4
  217. package/esm2020/localize/lib/functions/date.function.mjs +18 -18
  218. package/esm2020/localize/lib/functions/lowercase.function.mjs +13 -13
  219. package/esm2020/localize/lib/functions/uppercase.function.mjs +13 -13
  220. package/esm2020/localize/lib/handlers/missing.handler.mjs +15 -15
  221. package/esm2020/localize/lib/interfaces/config.interfaces.mjs +7 -7
  222. package/esm2020/localize/lib/interfaces/functions.interfaces.mjs +8 -8
  223. package/esm2020/localize/lib/interfaces/handlers.interfaces.mjs +2 -2
  224. package/esm2020/localize/lib/interfaces/options.interfaces.mjs +6 -6
  225. package/esm2020/localize/lib/localizations/dutch.localization.mjs +45 -45
  226. package/esm2020/localize/lib/localizations/english.localization.mjs +45 -45
  227. package/esm2020/localize/lib/localize.dictionary.mjs +26 -26
  228. package/esm2020/localize/lib/localize.module.mjs +71 -71
  229. package/esm2020/localize/lib/localize.pipe.mjs +49 -49
  230. package/esm2020/localize/lib/localize.service.mjs +207 -207
  231. package/esm2020/localize/lib/views/localize-string/localize-string.component.mjs +88 -88
  232. package/esm2020/localize/lib/views/localize-template-or-string.directive.mjs +28 -28
  233. package/esm2020/localize/lib/views/localize-template.directive.mjs +21 -21
  234. package/esm2020/localize/public_api.mjs +17 -17
  235. package/esm2020/masking/bravobit-bb-foundation-masking.mjs +4 -4
  236. package/esm2020/masking/lib/input-mask.directive.mjs +117 -110
  237. package/esm2020/masking/lib/input-mask.interface.mjs +2 -2
  238. package/esm2020/masking/lib/masking.module.mjs +16 -16
  239. package/esm2020/masking/lib/masking.service.mjs +103 -94
  240. package/esm2020/masking/public_api.mjs +5 -5
  241. package/esm2020/notifications/bravobit-bb-foundation-notifications.mjs +4 -4
  242. package/esm2020/notifications/lib/notifications-item/notifications-item.component.mjs +100 -100
  243. package/esm2020/notifications/lib/notifications-list/notifications-list.component.mjs +47 -47
  244. package/esm2020/notifications/lib/notifications.animations.mjs +28 -28
  245. package/esm2020/notifications/lib/notifications.injector.mjs +18 -18
  246. package/esm2020/notifications/lib/notifications.interfaces.mjs +20 -20
  247. package/esm2020/notifications/lib/notifications.module.mjs +30 -30
  248. package/esm2020/notifications/lib/notifications.service.mjs +145 -145
  249. package/esm2020/notifications/public_api.mjs +4 -4
  250. package/esm2020/public_api.mjs +29 -29
  251. package/esm2020/recaptcha/bravobit-bb-foundation-recaptcha.mjs +4 -4
  252. package/esm2020/recaptcha/lib/recaptcha/recaptcha.component.mjs +185 -185
  253. package/esm2020/recaptcha/lib/recaptcha-loader.service.mjs +90 -90
  254. package/esm2020/recaptcha/lib/recaptcha.interface.mjs +3 -3
  255. package/esm2020/recaptcha/lib/recaptcha.module.mjs +27 -27
  256. package/esm2020/recaptcha/public_api.mjs +5 -5
  257. package/esm2020/rxjs/bravobit-bb-foundation-rxjs.mjs +4 -4
  258. package/esm2020/rxjs/lib/observables/get-control-value.observable.mjs +6 -0
  259. package/esm2020/rxjs/lib/operators/combine-latest-map.operator.mjs +10 -10
  260. package/esm2020/rxjs/lib/operators/filter-nil.operator.mjs +5 -5
  261. package/esm2020/rxjs/public_api.mjs +4 -3
  262. package/esm2020/storage/bravobit-bb-foundation-storage.mjs +4 -4
  263. package/esm2020/storage/lib/interfaces/attributes.interface.mjs +2 -2
  264. package/esm2020/storage/lib/interfaces/memory.interface.mjs +2 -2
  265. package/esm2020/storage/lib/interfaces/strategy.interface.mjs +2 -2
  266. package/esm2020/storage/lib/storage.service.mjs +109 -109
  267. package/esm2020/storage/lib/strategies/cookie-storage.strategy.mjs +142 -142
  268. package/esm2020/storage/lib/strategies/memory-storage.strategy.mjs +56 -56
  269. package/esm2020/storage/lib/strategies/polyfill-storage.strategy.mjs +102 -102
  270. package/esm2020/storage/public_api.mjs +8 -8
  271. package/esm2020/table/bravobit-bb-foundation-table.mjs +4 -4
  272. package/esm2020/table/lib/components/table/table.component.mjs +191 -191
  273. package/esm2020/table/lib/components/table-cell/table-cell.component.mjs +11 -11
  274. package/esm2020/table/lib/components/table-header-cell/table-header-cell.component.mjs +131 -131
  275. package/esm2020/table/lib/components/table-pager/table-pager.component.mjs +136 -136
  276. package/esm2020/table/lib/data/datasource.data.mjs +32 -32
  277. package/esm2020/table/lib/data/generic.data.mjs +72 -72
  278. package/esm2020/table/lib/interfaces/datasource.interface.mjs +2 -2
  279. package/esm2020/table/lib/interfaces/table.interfaces.mjs +2 -2
  280. package/esm2020/table/lib/table.module.mjs +42 -42
  281. package/esm2020/table/public_api.mjs +10 -10
  282. package/esm2020/theming/bravobit-bb-foundation-theming.mjs +4 -4
  283. package/esm2020/theming/lib/themes/checkbox-group.theme.mjs +2 -2
  284. package/esm2020/theming/lib/themes/checkbox.theme.mjs +2 -2
  285. package/esm2020/theming/lib/themes/theme.mjs +34 -0
  286. package/esm2020/theming/lib/theming.interface.mjs +3 -3
  287. package/esm2020/theming/lib/theming.module.mjs +38 -38
  288. package/esm2020/theming/lib/theming.service.mjs +77 -100
  289. package/esm2020/theming/public_api.mjs +7 -4
  290. package/fesm2015/bravobit-bb-foundation-auth.mjs +930 -930
  291. package/fesm2015/bravobit-bb-foundation-auth.mjs.map +1 -1
  292. package/fesm2015/bravobit-bb-foundation-collections.mjs +443 -424
  293. package/fesm2015/bravobit-bb-foundation-collections.mjs.map +1 -1
  294. package/fesm2015/bravobit-bb-foundation-controls.mjs +229 -229
  295. package/fesm2015/bravobit-bb-foundation-controls.mjs.map +1 -1
  296. package/fesm2015/bravobit-bb-foundation-dashboard.mjs +382 -382
  297. package/fesm2015/bravobit-bb-foundation-dashboard.mjs.map +1 -1
  298. package/fesm2015/bravobit-bb-foundation-dialog.mjs +540 -540
  299. package/fesm2015/bravobit-bb-foundation-dialog.mjs.map +1 -1
  300. package/fesm2015/bravobit-bb-foundation-elements.mjs +1970 -1970
  301. package/fesm2015/bravobit-bb-foundation-elements.mjs.map +1 -1
  302. package/fesm2015/bravobit-bb-foundation-http.mjs +156 -156
  303. package/fesm2015/bravobit-bb-foundation-http.mjs.map +1 -1
  304. package/fesm2015/bravobit-bb-foundation-localize.mjs +608 -608
  305. package/fesm2015/bravobit-bb-foundation-localize.mjs.map +1 -1
  306. package/fesm2015/bravobit-bb-foundation-masking.mjs +231 -214
  307. package/fesm2015/bravobit-bb-foundation-masking.mjs.map +1 -1
  308. package/fesm2015/bravobit-bb-foundation-notifications.mjs +348 -348
  309. package/fesm2015/bravobit-bb-foundation-notifications.mjs.map +1 -1
  310. package/fesm2015/bravobit-bb-foundation-recaptcha.mjs +290 -290
  311. package/fesm2015/bravobit-bb-foundation-recaptcha.mjs.map +1 -1
  312. package/fesm2015/bravobit-bb-foundation-rxjs.mjs +14 -10
  313. package/fesm2015/bravobit-bb-foundation-rxjs.mjs.map +1 -1
  314. package/fesm2015/bravobit-bb-foundation-storage.mjs +401 -401
  315. package/fesm2015/bravobit-bb-foundation-storage.mjs.map +1 -1
  316. package/fesm2015/bravobit-bb-foundation-table.mjs +571 -571
  317. package/fesm2015/bravobit-bb-foundation-table.mjs.map +1 -1
  318. package/fesm2015/bravobit-bb-foundation-theming.mjs +151 -140
  319. package/fesm2015/bravobit-bb-foundation-theming.mjs.map +1 -1
  320. package/fesm2015/bravobit-bb-foundation.mjs +859 -859
  321. package/fesm2015/bravobit-bb-foundation.mjs.map +1 -1
  322. package/fesm2020/bravobit-bb-foundation-auth.mjs +882 -882
  323. package/fesm2020/bravobit-bb-foundation-auth.mjs.map +1 -1
  324. package/fesm2020/bravobit-bb-foundation-collections.mjs +432 -414
  325. package/fesm2020/bravobit-bb-foundation-collections.mjs.map +1 -1
  326. package/fesm2020/bravobit-bb-foundation-controls.mjs +227 -227
  327. package/fesm2020/bravobit-bb-foundation-controls.mjs.map +1 -1
  328. package/fesm2020/bravobit-bb-foundation-dashboard.mjs +370 -370
  329. package/fesm2020/bravobit-bb-foundation-dashboard.mjs.map +1 -1
  330. package/fesm2020/bravobit-bb-foundation-dialog.mjs +539 -539
  331. package/fesm2020/bravobit-bb-foundation-dialog.mjs.map +1 -1
  332. package/fesm2020/bravobit-bb-foundation-elements.mjs +1927 -1927
  333. package/fesm2020/bravobit-bb-foundation-elements.mjs.map +1 -1
  334. package/fesm2020/bravobit-bb-foundation-http.mjs +148 -148
  335. package/fesm2020/bravobit-bb-foundation-http.mjs.map +1 -1
  336. package/fesm2020/bravobit-bb-foundation-localize.mjs +587 -587
  337. package/fesm2020/bravobit-bb-foundation-localize.mjs.map +1 -1
  338. package/fesm2020/bravobit-bb-foundation-masking.mjs +219 -203
  339. package/fesm2020/bravobit-bb-foundation-masking.mjs.map +1 -1
  340. package/fesm2020/bravobit-bb-foundation-notifications.mjs +346 -346
  341. package/fesm2020/bravobit-bb-foundation-notifications.mjs.map +1 -1
  342. package/fesm2020/bravobit-bb-foundation-recaptcha.mjs +280 -280
  343. package/fesm2020/bravobit-bb-foundation-recaptcha.mjs.map +1 -1
  344. package/fesm2020/bravobit-bb-foundation-rxjs.mjs +17 -13
  345. package/fesm2020/bravobit-bb-foundation-rxjs.mjs.map +1 -1
  346. package/fesm2020/bravobit-bb-foundation-storage.mjs +396 -396
  347. package/fesm2020/bravobit-bb-foundation-storage.mjs.map +1 -1
  348. package/fesm2020/bravobit-bb-foundation-table.mjs +560 -560
  349. package/fesm2020/bravobit-bb-foundation-table.mjs.map +1 -1
  350. package/fesm2020/bravobit-bb-foundation-theming.mjs +141 -130
  351. package/fesm2020/bravobit-bb-foundation-theming.mjs.map +1 -1
  352. package/fesm2020/bravobit-bb-foundation.mjs +831 -831
  353. package/fesm2020/bravobit-bb-foundation.mjs.map +1 -1
  354. package/http/index.d.ts +5 -5
  355. package/http/lib/classes/http.config.d.ts +9 -9
  356. package/http/lib/classes/http.error.d.ts +7 -7
  357. package/http/lib/http.interfaces.d.ts +12 -12
  358. package/http/lib/http.module.d.ts +15 -15
  359. package/http/lib/interceptors/base-url.interceptor.d.ts +15 -15
  360. package/http/lib/interceptors/error.interceptor.d.ts +11 -11
  361. package/http/public_api.d.ts +6 -6
  362. package/index.d.ts +5 -5
  363. package/lib/core/miscellaneous/regex.d.ts +4 -4
  364. package/lib/core/miscellaneous/validator.d.ts +13 -13
  365. package/lib/core/mixins/can-disable.d.ts +6 -6
  366. package/lib/core/mixins/can-hide-errors.d.ts +6 -6
  367. package/lib/core/mixins/can-load.d.ts +6 -6
  368. package/lib/core/mixins/constructor.d.ts +1 -1
  369. package/lib/core/mixins/has-error.d.ts +6 -6
  370. package/lib/core/mixins/is-focused.d.ts +6 -6
  371. package/lib/core/mixins/is-grouped.d.ts +6 -6
  372. package/lib/core/mixins/is-readonly.d.ts +6 -6
  373. package/lib/core/mixins/is-required.d.ts +6 -6
  374. package/lib/core/services/clipboard.service.d.ts +18 -18
  375. package/lib/core/services/exif.service.d.ts +15 -15
  376. package/lib/core/services/file-loader.service.d.ts +13 -13
  377. package/lib/core/services/image-converter.service.d.ts +21 -21
  378. package/lib/core/services/languages.service.d.ts +16 -16
  379. package/lib/core/services/network.service.d.ts +14 -14
  380. package/lib/core/services/patch.service.d.ts +16 -16
  381. package/lib/core/services/platform.service.d.ts +18 -18
  382. package/lib/core/tokens/accept-language.token.d.ts +2 -2
  383. package/lib/core/tokens/base-url.token.d.ts +2 -2
  384. package/lib/core/tokens/cookie.token.d.ts +2 -2
  385. package/lib/core/tokens/location.token.d.ts +2 -2
  386. package/lib/core/tokens/navigator.token.d.ts +2 -2
  387. package/lib/core/tokens/window.token.d.ts +2 -2
  388. package/localize/index.d.ts +5 -5
  389. package/localize/lib/functions/date.function.d.ts +5 -5
  390. package/localize/lib/functions/lowercase.function.d.ts +5 -5
  391. package/localize/lib/functions/uppercase.function.d.ts +5 -5
  392. package/localize/lib/handlers/missing.handler.d.ts +6 -6
  393. package/localize/lib/interfaces/config.interfaces.d.ts +18 -18
  394. package/localize/lib/interfaces/functions.interfaces.d.ts +9 -9
  395. package/localize/lib/interfaces/handlers.interfaces.d.ts +6 -6
  396. package/localize/lib/interfaces/options.interfaces.d.ts +10 -10
  397. package/localize/lib/localizations/dutch.localization.d.ts +44 -44
  398. package/localize/lib/localizations/english.localization.d.ts +44 -44
  399. package/localize/lib/localize.dictionary.d.ts +7 -7
  400. package/localize/lib/localize.module.d.ts +17 -17
  401. package/localize/lib/localize.pipe.d.ts +12 -12
  402. package/localize/lib/localize.service.d.ts +40 -40
  403. package/localize/lib/views/localize-string/localize-string.component.d.ts +23 -23
  404. package/localize/lib/views/localize-template-or-string.directive.d.ts +10 -10
  405. package/localize/lib/views/localize-template.directive.d.ts +9 -9
  406. package/localize/public_api.d.ts +16 -16
  407. package/masking/index.d.ts +5 -5
  408. package/masking/lib/input-mask.directive.d.ts +38 -36
  409. package/masking/lib/input-mask.interface.d.ts +24 -20
  410. package/masking/lib/masking.module.d.ts +7 -7
  411. package/masking/lib/masking.service.d.ts +12 -12
  412. package/masking/public_api.d.ts +4 -4
  413. package/notifications/index.d.ts +5 -5
  414. package/notifications/lib/notifications-item/notifications-item.component.d.ts +34 -34
  415. package/notifications/lib/notifications-list/notifications-list.component.d.ts +16 -16
  416. package/notifications/lib/notifications.animations.d.ts +1 -1
  417. package/notifications/lib/notifications.injector.d.ts +8 -8
  418. package/notifications/lib/notifications.interfaces.d.ts +49 -49
  419. package/notifications/lib/notifications.module.d.ts +13 -13
  420. package/notifications/lib/notifications.service.d.ts +34 -34
  421. package/notifications/public_api.d.ts +3 -3
  422. package/package.json +1 -1
  423. package/public_api.d.ts +25 -25
  424. package/recaptcha/index.d.ts +5 -5
  425. package/recaptcha/lib/recaptcha/recaptcha.component.d.ts +47 -47
  426. package/recaptcha/lib/recaptcha-loader.service.d.ts +22 -22
  427. package/recaptcha/lib/recaptcha.interface.d.ts +14 -14
  428. package/recaptcha/lib/recaptcha.module.d.ts +10 -10
  429. package/recaptcha/public_api.d.ts +4 -4
  430. package/rxjs/index.d.ts +5 -5
  431. package/rxjs/lib/observables/get-control-value.observable.d.ts +3 -0
  432. package/rxjs/lib/operators/combine-latest-map.operator.d.ts +8 -8
  433. package/rxjs/lib/operators/filter-nil.operator.d.ts +1 -1
  434. package/rxjs/public_api.d.ts +3 -2
  435. package/storage/index.d.ts +5 -5
  436. package/storage/lib/interfaces/attributes.interface.d.ts +13 -13
  437. package/storage/lib/interfaces/memory.interface.d.ts +7 -7
  438. package/storage/lib/interfaces/strategy.interface.d.ts +17 -17
  439. package/storage/lib/storage.service.d.ts +26 -26
  440. package/storage/lib/strategies/cookie-storage.strategy.d.ts +20 -20
  441. package/storage/lib/strategies/memory-storage.strategy.d.ts +11 -11
  442. package/storage/lib/strategies/polyfill-storage.strategy.d.ts +15 -15
  443. package/storage/public_api.d.ts +7 -7
  444. package/table/index.d.ts +5 -5
  445. package/table/lib/components/table/table.component.d.ts +56 -56
  446. package/table/lib/components/table-cell/table-cell.component.d.ts +5 -5
  447. package/table/lib/components/table-header-cell/table-header-cell.component.d.ts +29 -29
  448. package/table/lib/components/table-pager/table-pager.component.d.ts +41 -41
  449. package/table/lib/data/datasource.data.d.ts +14 -14
  450. package/table/lib/data/generic.data.d.ts +23 -23
  451. package/table/lib/interfaces/datasource.interface.d.ts +17 -17
  452. package/table/lib/interfaces/table.interfaces.d.ts +1 -1
  453. package/table/lib/table.module.d.ts +14 -14
  454. package/table/public_api.d.ts +9 -9
  455. package/theming/index.d.ts +5 -5
  456. package/theming/lib/themes/checkbox-group.theme.d.ts +5 -5
  457. package/theming/lib/themes/checkbox.theme.d.ts +19 -19
  458. package/theming/lib/themes/theme.d.ts +12 -0
  459. package/theming/lib/theming.interface.d.ts +15 -14
  460. package/theming/lib/theming.module.d.ts +13 -13
  461. package/theming/lib/theming.service.d.ts +22 -24
  462. package/theming/public_api.d.ts +6 -3
@@ -1,450 +1,469 @@
1
1
  import { isObservable, of, combineLatest, BehaviorSubject } from 'rxjs';
2
- import { switchMap, map, distinctUntilChanged, startWith, tap, catchError, debounceTime } from 'rxjs/operators';
2
+ import { switchMap, map, tap, catchError, startWith, debounceTime, distinctUntilChanged } from 'rxjs/operators';
3
3
  import * as i0 from '@angular/core';
4
4
  import { Directive, TemplateRef, Component, ChangeDetectionStrategy, ViewEncapsulation, ContentChild, Input, NgModule } from '@angular/core';
5
5
  import * as i1 from '@angular/common';
6
6
  import { CommonModule } from '@angular/common';
7
+ import { getControlValue } from '@bravobit/bb-foundation/rxjs';
7
8
  import { FormControl } from '@angular/forms';
8
9
 
9
- class CollectionProvider {
10
- formatArrayToCollectionData(items) {
11
- var _a;
12
- const count = (_a = items === null || items === void 0 ? void 0 : items.length) !== null && _a !== void 0 ? _a : 1;
13
- return {
14
- pageSize: count,
15
- totalEntries: count,
16
- pageNumber: 1,
17
- totalPages: 1,
18
- data: items
19
- };
20
- }
10
+ class CollectionProvider {
11
+ formatArrayToCollectionData(items) {
12
+ var _a;
13
+ const count = (_a = items === null || items === void 0 ? void 0 : items.length) !== null && _a !== void 0 ? _a : 1;
14
+ return {
15
+ pageSize: count,
16
+ totalEntries: count,
17
+ pageNumber: 1,
18
+ totalPages: 1,
19
+ data: items
20
+ };
21
+ }
21
22
  }
22
23
 
23
- class ApiCollectionProvider extends CollectionProvider {
24
- constructor(endpoint, httpClient) {
25
- super();
26
- this.endpoint = endpoint;
27
- this.httpClient = httpClient;
28
- // State.
29
- this.extraParams = {};
30
- }
31
- append(name, value) {
32
- this.extraParams[name] = isObservable(value) ? value : of(value);
33
- return this;
34
- }
35
- transform(request) {
36
- const endpoint$ = isObservable(this.endpoint) ? this.endpoint : of(this.endpoint);
37
- const params = this.getBackendFormat(request);
38
- const extraParams$ = this.getExtraParams(this.extraParams);
39
- return combineLatest([endpoint$, extraParams$]).pipe(switchMap(([endpoint, extraParams]) => {
40
- return this.httpClient.get(endpoint, {
41
- params: Object.assign(Object.assign({}, params), extraParams)
42
- });
43
- }), map(response => this.formatToCollectionData(response)));
44
- }
45
- getExtraParams(params) {
46
- const keys = Object.keys(params !== null && params !== void 0 ? params : {});
47
- if (keys.length <= 0) {
48
- return of({});
49
- }
50
- const observables$ = keys.map(key => params === null || params === void 0 ? void 0 : params[key]);
51
- return combineLatest(observables$).pipe(map(data => {
52
- return data.reduce((previous, current, index) => {
53
- if (current === null || current === undefined) {
54
- return previous;
55
- }
56
- const key = keys === null || keys === void 0 ? void 0 : keys[index];
57
- return Object.assign(Object.assign({}, previous), { [key]: current });
58
- }, {});
59
- }));
60
- }
61
- formatToCollectionData(response) {
62
- if (Array.isArray(response)) {
63
- return this.formatArrayToCollectionData(response);
64
- }
65
- return {
66
- pageSize: response === null || response === void 0 ? void 0 : response.page_size,
67
- pageNumber: response === null || response === void 0 ? void 0 : response.page_number,
68
- totalPages: response === null || response === void 0 ? void 0 : response.total_pages,
69
- totalEntries: response === null || response === void 0 ? void 0 : response.total_entries,
70
- data: response === null || response === void 0 ? void 0 : response.data
71
- };
72
- }
73
- getBackendFormat(request) {
74
- var _a, _b, _c, _d, _e, _f, _g;
75
- const params = {};
76
- params['page'] = (_a = request === null || request === void 0 ? void 0 : request.pageNumber) !== null && _a !== void 0 ? _a : 1;
77
- params['page_size'] = (_b = request === null || request === void 0 ? void 0 : request.pageSize) !== null && _b !== void 0 ? _b : 25;
78
- if (request === null || request === void 0 ? void 0 : request.sort) {
79
- const sort = Array.isArray(request === null || request === void 0 ? void 0 : request.sort) ? request === null || request === void 0 ? void 0 : request.sort : [request === null || request === void 0 ? void 0 : request.sort];
80
- const filteredSort = sort === null || sort === void 0 ? void 0 : sort.filter(item => !!(item === null || item === void 0 ? void 0 : item.name) && !!(item === null || item === void 0 ? void 0 : item.direction));
81
- params['sort'] = (_c = filteredSort === null || filteredSort === void 0 ? void 0 : filteredSort.map(item => item === null || item === void 0 ? void 0 : item.name)) === null || _c === void 0 ? void 0 : _c.join(',');
82
- params['sort_direction'] = (_d = filteredSort === null || filteredSort === void 0 ? void 0 : filteredSort.map(item => item === null || item === void 0 ? void 0 : item.direction)) === null || _d === void 0 ? void 0 : _d.join(',');
83
- }
84
- if ((request === null || request === void 0 ? void 0 : request.query) && ((_e = request === null || request === void 0 ? void 0 : request.query) === null || _e === void 0 ? void 0 : _e.length) > 0 && (request === null || request === void 0 ? void 0 : request.queryFields) && ((_f = request === null || request === void 0 ? void 0 : request.queryFields) === null || _f === void 0 ? void 0 : _f.length) > 0) {
85
- params['query'] = request === null || request === void 0 ? void 0 : request.query;
86
- params['query_fields'] = (_g = request === null || request === void 0 ? void 0 : request.queryFields) === null || _g === void 0 ? void 0 : _g.join(',');
87
- }
88
- return params;
89
- }
24
+ class ApiCollectionProvider extends CollectionProvider {
25
+ constructor(endpoint, httpClient) {
26
+ super();
27
+ this.endpoint = endpoint;
28
+ this.httpClient = httpClient;
29
+ // State.
30
+ this.extraParams = {};
31
+ this.extraObjectParams = [];
32
+ }
33
+ append(name, value) {
34
+ this.extraParams[name] = isObservable(value) ? value : of(value);
35
+ return this;
36
+ }
37
+ appendObject(value) {
38
+ const params = isObservable(value) ? value : of(value);
39
+ this.extraObjectParams.push(params);
40
+ }
41
+ transform(request) {
42
+ const endpoint$ = isObservable(this.endpoint) ? this.endpoint : of(this.endpoint);
43
+ const params = this.getBackendFormat(request);
44
+ const extraParams$ = this.getExtraParams(this.extraParams);
45
+ const extraObjectParams$ = this.getExtraObjectParams(this.extraObjectParams);
46
+ return combineLatest([endpoint$, extraParams$, extraObjectParams$]).pipe(switchMap(([endpoint, extraParams, extraObjectParams]) => {
47
+ return this.httpClient.get(endpoint, {
48
+ params: Object.assign(Object.assign(Object.assign({}, params), extraParams), extraObjectParams)
49
+ });
50
+ }), map(response => this.formatToCollectionData(response)));
51
+ }
52
+ getExtraParams(params) {
53
+ const keys = Object.keys(params !== null && params !== void 0 ? params : {});
54
+ if ((keys === null || keys === void 0 ? void 0 : keys.length) <= 0) {
55
+ return of({});
56
+ }
57
+ const observables$ = keys.map(key => params === null || params === void 0 ? void 0 : params[key]);
58
+ return combineLatest(observables$).pipe(map(data => {
59
+ return data.reduce((previous, current, index) => {
60
+ if (current === null || current === undefined) {
61
+ return previous;
62
+ }
63
+ const key = keys === null || keys === void 0 ? void 0 : keys[index];
64
+ return Object.assign(Object.assign({}, previous), { [key]: current });
65
+ }, {});
66
+ }));
67
+ }
68
+ getExtraObjectParams(params$) {
69
+ if ((params$ === null || params$ === void 0 ? void 0 : params$.length) <= 0) {
70
+ return of({});
71
+ }
72
+ return combineLatest(params$).pipe(map(data => (data !== null && data !== void 0 ? data : []).reduce((previous, current) => (Object.assign(Object.assign({}, previous), (current !== null && current !== void 0 ? current : {}))), {})), map(data => {
73
+ return Object.keys(data !== null && data !== void 0 ? data : {}).reduce((previous, current) => {
74
+ var _a;
75
+ const value = (_a = data === null || data === void 0 ? void 0 : data[current]) !== null && _a !== void 0 ? _a : null;
76
+ if (value === null || value === undefined) {
77
+ return previous;
78
+ }
79
+ return Object.assign(Object.assign({}, previous), { [current]: value });
80
+ }, {});
81
+ }));
82
+ }
83
+ formatToCollectionData(response) {
84
+ if (Array.isArray(response)) {
85
+ return this.formatArrayToCollectionData(response);
86
+ }
87
+ return {
88
+ pageSize: response === null || response === void 0 ? void 0 : response.page_size,
89
+ pageNumber: response === null || response === void 0 ? void 0 : response.page_number,
90
+ totalPages: response === null || response === void 0 ? void 0 : response.total_pages,
91
+ totalEntries: response === null || response === void 0 ? void 0 : response.total_entries,
92
+ data: response === null || response === void 0 ? void 0 : response.data
93
+ };
94
+ }
95
+ getBackendFormat(request) {
96
+ var _a, _b, _c, _d, _e, _f, _g;
97
+ const params = {};
98
+ params['page'] = (_a = request === null || request === void 0 ? void 0 : request.pageNumber) !== null && _a !== void 0 ? _a : 1;
99
+ params['page_size'] = (_b = request === null || request === void 0 ? void 0 : request.pageSize) !== null && _b !== void 0 ? _b : 25;
100
+ if (request === null || request === void 0 ? void 0 : request.sort) {
101
+ const sort = Array.isArray(request === null || request === void 0 ? void 0 : request.sort) ? request === null || request === void 0 ? void 0 : request.sort : [request === null || request === void 0 ? void 0 : request.sort];
102
+ const filteredSort = sort === null || sort === void 0 ? void 0 : sort.filter(item => !!(item === null || item === void 0 ? void 0 : item.name) && !!(item === null || item === void 0 ? void 0 : item.direction));
103
+ params['sort'] = (_c = filteredSort === null || filteredSort === void 0 ? void 0 : filteredSort.map(item => item === null || item === void 0 ? void 0 : item.name)) === null || _c === void 0 ? void 0 : _c.join(',');
104
+ params['sort_direction'] = (_d = filteredSort === null || filteredSort === void 0 ? void 0 : filteredSort.map(item => item === null || item === void 0 ? void 0 : item.direction)) === null || _d === void 0 ? void 0 : _d.join(',');
105
+ }
106
+ if ((request === null || request === void 0 ? void 0 : request.query) && ((_e = request === null || request === void 0 ? void 0 : request.query) === null || _e === void 0 ? void 0 : _e.length) > 0 && (request === null || request === void 0 ? void 0 : request.queryFields) && ((_f = request === null || request === void 0 ? void 0 : request.queryFields) === null || _f === void 0 ? void 0 : _f.length) > 0) {
107
+ params['query'] = request === null || request === void 0 ? void 0 : request.query;
108
+ params['query_fields'] = (_g = request === null || request === void 0 ? void 0 : request.queryFields) === null || _g === void 0 ? void 0 : _g.join(',');
109
+ }
110
+ return params;
111
+ }
90
112
  }
91
113
 
92
- class LocalCollectionProvider extends CollectionProvider {
93
- constructor(_items) {
94
- super();
95
- this._items = _items;
96
- }
97
- transform(request) {
98
- const items$ = Array.isArray(this._items)
99
- ? of(this._items)
100
- : this._items;
101
- return items$.pipe(map(items => this.formatArrayToCollectionData(items)));
102
- }
114
+ class LocalCollectionProvider extends CollectionProvider {
115
+ constructor(_items) {
116
+ super();
117
+ this._items = _items;
118
+ }
119
+ transform(request) {
120
+ const items$ = Array.isArray(this._items)
121
+ ? of(this._items)
122
+ : this._items;
123
+ return items$.pipe(map(items => this.formatArrayToCollectionData(items)));
124
+ }
103
125
  }
104
126
 
105
- class BbCollectionsData {
106
- }
107
- BbCollectionsData.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.3", ngImport: i0, type: BbCollectionsData, deps: [], target: i0.ɵɵFactoryTarget.Directive });
108
- BbCollectionsData.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.0.3", type: BbCollectionsData, selector: "[bbCollectionsData]", ngImport: i0 });
109
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.3", ngImport: i0, type: BbCollectionsData, decorators: [{
110
- type: Directive,
111
- args: [{
112
- selector: '[bbCollectionsData]'
113
- }]
114
- }] });
115
- class BbCollectionsEmpty {
116
- }
117
- BbCollectionsEmpty.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.3", ngImport: i0, type: BbCollectionsEmpty, deps: [], target: i0.ɵɵFactoryTarget.Directive });
118
- BbCollectionsEmpty.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.0.3", type: BbCollectionsEmpty, selector: "[bbCollectionsEmpty]", ngImport: i0 });
119
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.3", ngImport: i0, type: BbCollectionsEmpty, decorators: [{
120
- type: Directive,
121
- args: [{
122
- selector: '[bbCollectionsEmpty]'
123
- }]
124
- }] });
125
- class BbCollectionsError {
126
- }
127
- BbCollectionsError.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.3", ngImport: i0, type: BbCollectionsError, deps: [], target: i0.ɵɵFactoryTarget.Directive });
128
- BbCollectionsError.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.0.3", type: BbCollectionsError, selector: "[bbCollectionsError]", ngImport: i0 });
129
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.3", ngImport: i0, type: BbCollectionsError, decorators: [{
130
- type: Directive,
131
- args: [{
132
- selector: '[bbCollectionsError]'
133
- }]
134
- }] });
135
- class BbCollectionsInitial {
136
- }
137
- BbCollectionsInitial.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.3", ngImport: i0, type: BbCollectionsInitial, deps: [], target: i0.ɵɵFactoryTarget.Directive });
138
- BbCollectionsInitial.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.0.3", type: BbCollectionsInitial, selector: "[bbCollectionsInitial]", ngImport: i0 });
139
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.3", ngImport: i0, type: BbCollectionsInitial, decorators: [{
140
- type: Directive,
141
- args: [{
142
- selector: '[bbCollectionsInitial]'
143
- }]
127
+ class BbCollectionsData {
128
+ }
129
+ BbCollectionsData.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.4", ngImport: i0, type: BbCollectionsData, deps: [], target: i0.ɵɵFactoryTarget.Directive });
130
+ BbCollectionsData.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.0.4", type: BbCollectionsData, selector: "[bbCollectionsData]", ngImport: i0 });
131
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.4", ngImport: i0, type: BbCollectionsData, decorators: [{
132
+ type: Directive,
133
+ args: [{
134
+ selector: '[bbCollectionsData]'
135
+ }]
136
+ }] });
137
+ class BbCollectionsEmpty {
138
+ }
139
+ BbCollectionsEmpty.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.4", ngImport: i0, type: BbCollectionsEmpty, deps: [], target: i0.ɵɵFactoryTarget.Directive });
140
+ BbCollectionsEmpty.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.0.4", type: BbCollectionsEmpty, selector: "[bbCollectionsEmpty]", ngImport: i0 });
141
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.4", ngImport: i0, type: BbCollectionsEmpty, decorators: [{
142
+ type: Directive,
143
+ args: [{
144
+ selector: '[bbCollectionsEmpty]'
145
+ }]
146
+ }] });
147
+ class BbCollectionsError {
148
+ }
149
+ BbCollectionsError.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.4", ngImport: i0, type: BbCollectionsError, deps: [], target: i0.ɵɵFactoryTarget.Directive });
150
+ BbCollectionsError.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.0.4", type: BbCollectionsError, selector: "[bbCollectionsError]", ngImport: i0 });
151
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.4", ngImport: i0, type: BbCollectionsError, decorators: [{
152
+ type: Directive,
153
+ args: [{
154
+ selector: '[bbCollectionsError]'
155
+ }]
156
+ }] });
157
+ class BbCollectionsInitial {
158
+ }
159
+ BbCollectionsInitial.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.4", ngImport: i0, type: BbCollectionsInitial, deps: [], target: i0.ɵɵFactoryTarget.Directive });
160
+ BbCollectionsInitial.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.0.4", type: BbCollectionsInitial, selector: "[bbCollectionsInitial]", ngImport: i0 });
161
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.4", ngImport: i0, type: BbCollectionsInitial, decorators: [{
162
+ type: Directive,
163
+ args: [{
164
+ selector: '[bbCollectionsInitial]'
165
+ }]
144
166
  }] });
145
167
 
146
- class BbCollectionsViewer {
147
- constructor() {
148
- // Inputs.
149
- this.collection = null;
150
- }
151
- }
152
- BbCollectionsViewer.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.3", ngImport: i0, type: BbCollectionsViewer, deps: [], target: i0.ɵɵFactoryTarget.Component });
153
- BbCollectionsViewer.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.0.3", type: BbCollectionsViewer, selector: "[bb-collections-viewer]", inputs: { collection: "collection" }, host: { classAttribute: "bb-collections-viewer" }, queries: [{ propertyName: "dataTemplate", first: true, predicate: BbCollectionsData, descendants: true, read: TemplateRef }, { propertyName: "emptyTemplate", first: true, predicate: BbCollectionsEmpty, descendants: true, read: TemplateRef }, { propertyName: "errorTemplate", first: true, predicate: BbCollectionsError, descendants: true, read: TemplateRef }, { propertyName: "initialTemplate", first: true, predicate: BbCollectionsInitial, descendants: true, read: TemplateRef }], ngImport: i0, template: "<ng-container *ngIf=\"collection?.data$ | async as data\"\r\n [ngSwitch]=\"data?.state\">\r\n <ng-container *ngSwitchDefault>\r\n <ng-container *ngTemplateOutlet=\"dataTemplate; context: {items: data?.response?.data}\"></ng-container>\r\n </ng-container>\r\n <ng-container *ngSwitchCase=\"'initial'\">\r\n <ng-container *ngTemplateOutlet=\"initialTemplate\"></ng-container>\r\n </ng-container>\r\n <ng-container *ngSwitchCase=\"'empty'\">\r\n <ng-container *ngTemplateOutlet=\"emptyTemplate; context: {query: data?.request?.query}\"></ng-container>\r\n </ng-container>\r\n <ng-container *ngSwitchCase=\"'error'\">\r\n <ng-container *ngTemplateOutlet=\"errorTemplate; context: {error: data?.error}\"></ng-container>\r\n </ng-container>\r\n</ng-container>\r\n", styles: [".bb-collections-viewer{display:block}\n"], dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: i1.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { kind: "directive", type: i1.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { kind: "directive", type: i1.NgSwitchDefault, selector: "[ngSwitchDefault]" }, { kind: "pipe", type: i1.AsyncPipe, name: "async" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
154
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.3", ngImport: i0, type: BbCollectionsViewer, decorators: [{
155
- type: Component,
156
- args: [{ selector: '[bb-collections-viewer]', changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, host: { 'class': 'bb-collections-viewer' }, preserveWhitespaces: false, template: "<ng-container *ngIf=\"collection?.data$ | async as data\"\r\n [ngSwitch]=\"data?.state\">\r\n <ng-container *ngSwitchDefault>\r\n <ng-container *ngTemplateOutlet=\"dataTemplate; context: {items: data?.response?.data}\"></ng-container>\r\n </ng-container>\r\n <ng-container *ngSwitchCase=\"'initial'\">\r\n <ng-container *ngTemplateOutlet=\"initialTemplate\"></ng-container>\r\n </ng-container>\r\n <ng-container *ngSwitchCase=\"'empty'\">\r\n <ng-container *ngTemplateOutlet=\"emptyTemplate; context: {query: data?.request?.query}\"></ng-container>\r\n </ng-container>\r\n <ng-container *ngSwitchCase=\"'error'\">\r\n <ng-container *ngTemplateOutlet=\"errorTemplate; context: {error: data?.error}\"></ng-container>\r\n </ng-container>\r\n</ng-container>\r\n", styles: [".bb-collections-viewer{display:block}\n"] }]
157
- }], propDecorators: { dataTemplate: [{
158
- type: ContentChild,
159
- args: [BbCollectionsData, { read: TemplateRef, static: false }]
160
- }], emptyTemplate: [{
161
- type: ContentChild,
162
- args: [BbCollectionsEmpty, { read: TemplateRef, static: false }]
163
- }], errorTemplate: [{
164
- type: ContentChild,
165
- args: [BbCollectionsError, { read: TemplateRef, static: false }]
166
- }], initialTemplate: [{
167
- type: ContentChild,
168
- args: [BbCollectionsInitial, { read: TemplateRef, static: false }]
169
- }], collection: [{
170
- type: Input
168
+ class BbCollectionsViewer {
169
+ constructor() {
170
+ // Inputs.
171
+ this.collection = null;
172
+ }
173
+ }
174
+ BbCollectionsViewer.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.4", ngImport: i0, type: BbCollectionsViewer, deps: [], target: i0.ɵɵFactoryTarget.Component });
175
+ BbCollectionsViewer.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.0.4", type: BbCollectionsViewer, selector: "[bb-collections-viewer]", inputs: { collection: "collection" }, host: { classAttribute: "bb-collections-viewer" }, queries: [{ propertyName: "dataTemplate", first: true, predicate: BbCollectionsData, descendants: true, read: TemplateRef }, { propertyName: "emptyTemplate", first: true, predicate: BbCollectionsEmpty, descendants: true, read: TemplateRef }, { propertyName: "errorTemplate", first: true, predicate: BbCollectionsError, descendants: true, read: TemplateRef }, { propertyName: "initialTemplate", first: true, predicate: BbCollectionsInitial, descendants: true, read: TemplateRef }], ngImport: i0, template: "<ng-container *ngIf=\"collection?.data$ | async as data\"\n [ngSwitch]=\"data?.state\">\n <ng-container *ngSwitchDefault>\n <ng-container *ngTemplateOutlet=\"dataTemplate; context: {items: data?.response?.data}\"></ng-container>\n </ng-container>\n <ng-container *ngSwitchCase=\"'initial'\">\n <ng-container *ngTemplateOutlet=\"initialTemplate\"></ng-container>\n </ng-container>\n <ng-container *ngSwitchCase=\"'empty'\">\n <ng-container *ngTemplateOutlet=\"emptyTemplate; context: {query: data?.request?.query}\"></ng-container>\n </ng-container>\n <ng-container *ngSwitchCase=\"'error'\">\n <ng-container *ngTemplateOutlet=\"errorTemplate; context: {error: data?.error}\"></ng-container>\n </ng-container>\n</ng-container>\n", styles: [".bb-collections-viewer{display:block}\n"], dependencies: [{ kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: i1.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { kind: "directive", type: i1.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { kind: "directive", type: i1.NgSwitchDefault, selector: "[ngSwitchDefault]" }, { kind: "pipe", type: i1.AsyncPipe, name: "async" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
176
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.4", ngImport: i0, type: BbCollectionsViewer, decorators: [{
177
+ type: Component,
178
+ args: [{ selector: '[bb-collections-viewer]', changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, host: { 'class': 'bb-collections-viewer' }, preserveWhitespaces: false, template: "<ng-container *ngIf=\"collection?.data$ | async as data\"\n [ngSwitch]=\"data?.state\">\n <ng-container *ngSwitchDefault>\n <ng-container *ngTemplateOutlet=\"dataTemplate; context: {items: data?.response?.data}\"></ng-container>\n </ng-container>\n <ng-container *ngSwitchCase=\"'initial'\">\n <ng-container *ngTemplateOutlet=\"initialTemplate\"></ng-container>\n </ng-container>\n <ng-container *ngSwitchCase=\"'empty'\">\n <ng-container *ngTemplateOutlet=\"emptyTemplate; context: {query: data?.request?.query}\"></ng-container>\n </ng-container>\n <ng-container *ngSwitchCase=\"'error'\">\n <ng-container *ngTemplateOutlet=\"errorTemplate; context: {error: data?.error}\"></ng-container>\n </ng-container>\n</ng-container>\n", styles: [".bb-collections-viewer{display:block}\n"] }]
179
+ }], propDecorators: { dataTemplate: [{
180
+ type: ContentChild,
181
+ args: [BbCollectionsData, { read: TemplateRef, static: false }]
182
+ }], emptyTemplate: [{
183
+ type: ContentChild,
184
+ args: [BbCollectionsEmpty, { read: TemplateRef, static: false }]
185
+ }], errorTemplate: [{
186
+ type: ContentChild,
187
+ args: [BbCollectionsError, { read: TemplateRef, static: false }]
188
+ }], initialTemplate: [{
189
+ type: ContentChild,
190
+ args: [BbCollectionsInitial, { read: TemplateRef, static: false }]
191
+ }], collection: [{
192
+ type: Input
171
193
  }] } });
172
194
 
173
- class BbCollectionsPager {
174
- constructor() {
175
- // Readonly data.
176
- this.maxAmountOfButtons = 5;
177
- this.cache$ = new BehaviorSubject({});
178
- // State and subscriptions.
179
- this._label = null;
180
- this._collection = null;
181
- this._subscription = null;
182
- }
183
- // Inputs.
184
- set label(value) {
185
- this._label = value;
186
- this.cache$.next(this.cache$.getValue());
187
- }
188
- set collection(collection) {
189
- this._collection = collection;
190
- this.observeCollectionChanges();
191
- }
192
- ngOnInit() {
193
- this.data$ = this.cache$.pipe(map(cache => {
194
- var _a, _b, _c, _d;
195
- const pageSize = (_a = cache === null || cache === void 0 ? void 0 : cache.pageSize) !== null && _a !== void 0 ? _a : 1;
196
- const pageNumber = (_b = cache === null || cache === void 0 ? void 0 : cache.pageNumber) !== null && _b !== void 0 ? _b : 1;
197
- const totalPages = Math.max(0, (_c = cache === null || cache === void 0 ? void 0 : cache.totalPages) !== null && _c !== void 0 ? _c : 1);
198
- const totalEntries = Math.max(0, (_d = cache === null || cache === void 0 ? void 0 : cache.totalEntries) !== null && _d !== void 0 ? _d : 0);
199
- const fromStart = Math.max(0, Math.min((pageSize * (pageNumber - 1)) + 1, totalEntries));
200
- const fromEnd = Math.max(0, Math.min((fromStart - 1) + pageSize, totalEntries));
201
- const pages = this.filterActivePages(pageNumber, totalPages);
202
- const allowNext = pageNumber < totalPages;
203
- const allowPrevious = pageNumber > 1;
204
- return {
205
- totalPages,
206
- pages,
207
- pageNumber,
208
- allowNext,
209
- allowPrevious,
210
- label: this.calculateLabel(fromStart, fromEnd, totalEntries)
211
- };
212
- }));
213
- }
214
- ngOnDestroy() {
215
- var _a;
216
- (_a = this._subscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
217
- }
218
- setPage(pageNumber, totalPages) {
219
- var _a, _b, _c, _d;
220
- // Calculate the new value.
221
- const newValue = Math.min(totalPages, Math.max(1, pageNumber));
222
- // Validate the value is actually different.
223
- const currentValue = (_b = (_a = this._collection) === null || _a === void 0 ? void 0 : _a.pageNumberControl) === null || _b === void 0 ? void 0 : _b.value;
224
- if (currentValue === newValue) {
225
- return;
226
- }
227
- (_d = (_c = this._collection) === null || _c === void 0 ? void 0 : _c.pageNumberControl) === null || _d === void 0 ? void 0 : _d.setValue(pageNumber);
228
- }
229
- observeCollectionChanges() {
230
- var _a, _b, _c, _d, _e;
231
- if (!this._collection) {
232
- return;
233
- }
234
- if (this._subscription) {
235
- (_a = this._subscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
236
- }
237
- const pageNumber = (_c = (_b = this._collection) === null || _b === void 0 ? void 0 : _b.pageNumberControl) === null || _c === void 0 ? void 0 : _c.value;
238
- const pageSize = (_e = (_d = this._collection) === null || _d === void 0 ? void 0 : _d.pageSizeControl) === null || _e === void 0 ? void 0 : _e.value;
239
- this.cache$.next({ pageNumber, pageSize });
240
- this._subscription = this._collection.raw$.subscribe(data => {
241
- if (data) {
242
- this.cache$.next(data);
243
- }
244
- });
245
- }
246
- calculateLabel(start, end, total) {
247
- var _a;
248
- const startPoint = '[start]';
249
- const endPoint = '[end]';
250
- const totalPoint = '[total]';
251
- const label = (_a = this._label) !== null && _a !== void 0 ? _a : `Showing ${startPoint} to ${endPoint} of ${totalPoint} results`;
252
- return label
253
- .replace(startPoint, `<strong>${start}</strong>`)
254
- .replace(endPoint, `<strong>${end}</strong>`)
255
- .replace(totalPoint, `<strong>${total}</strong>`);
256
- }
257
- calculatePages(pageNumber, totalPages) {
258
- const min = 1;
259
- const max = totalPages;
260
- const amount = Math.max(1, this.maxAmountOfButtons);
261
- const data = Array(amount)
262
- .fill(0)
263
- .map((_, index) => pageNumber + (index - 1));
264
- // Validate if the minimum value less than
265
- // the first value.
266
- if (data[0] < min) {
267
- return data.map(item => item + 1);
268
- }
269
- // Calculate the difference with the max
270
- // if this value is higher than 0 we should minus it.
271
- const lastValueInArray = data[data.length - 1];
272
- const differenceWithMax = lastValueInArray - max;
273
- if (differenceWithMax > 0) {
274
- return data.map(item => item - differenceWithMax);
275
- }
276
- // Just return the default data.
277
- return data;
278
- }
279
- filterActivePages(pageNumber, totalPages) {
280
- return this.calculatePages(pageNumber, totalPages)
281
- .filter(page => page > 0 && page <= totalPages)
282
- .map(page => ({ page, active: pageNumber === page }));
283
- }
284
- }
285
- BbCollectionsPager.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.3", ngImport: i0, type: BbCollectionsPager, deps: [], target: i0.ɵɵFactoryTarget.Component });
286
- BbCollectionsPager.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.0.3", type: BbCollectionsPager, selector: "bb-collections-pager", inputs: { label: "label", collection: "collection" }, host: { classAttribute: "bb-collections-pager" }, ngImport: i0, template: "<ng-container *ngIf=\"data$ | async as data\">\r\n <div [innerHTML]=\"data?.label\"\r\n class=\"bb-collections-pager-text\">\r\n </div>\r\n\r\n <div class=\"bb-collections-pager-container\">\r\n <ul class=\"bb-collections-pager-list\">\r\n <li class=\"bb-collections-pager-item\"\r\n title=\"Previous page\">\r\n <button [disabled]=\"!data?.allowPrevious\"\r\n (click)=\"setPage(data?.pageNumber - 1, data?.totalPages)\"\r\n class=\"bb-collections-pager-button arrow first\"\r\n type=\"button\">\r\n &#8592;\r\n </button>\r\n </li>\r\n <li *ngFor=\"let item of data?.pages\"\r\n [title]=\"'Page ' + item?.page\"\r\n class=\"bb-collections-pager-item\">\r\n <button [class.active]=\"item?.active\"\r\n (click)=\"setPage(item?.page, data?.totalPages)\"\r\n class=\"bb-collections-pager-button\"\r\n type=\"button\">\r\n {{ item?.page }}\r\n </button>\r\n </li>\r\n <li class=\"bb-collections-pager-item\"\r\n title=\"Next page\">\r\n <button [disabled]=\"!data?.allowNext\"\r\n (click)=\"setPage(data?.pageNumber + 1, data?.totalPages)\"\r\n class=\"bb-collections-pager-button arrow last\"\r\n type=\"button\">\r\n &#8594;\r\n </button>\r\n </li>\r\n </ul>\r\n </div>\r\n</ng-container>\r\n", styles: [".bb-collections-pager{display:flex;align-items:center;flex-direction:column-reverse}.bb-collections-pager-text{display:block;margin-top:10px}.bb-collections-pager-text>strong{font-weight:500}.bb-collections-pager-container{width:100%;display:flex;overflow-x:auto;align-items:center;justify-content:center}.bb-collections-pager-list{display:flex;border-radius:6px;align-items:center;background-color:#fff;border:1px solid rgba(67,90,111,.3);box-shadow:#435a6f24 0 1px 2px inset}.bb-collections-pager-item:not(:last-child){border-right:1px solid #cccccc}.bb-collections-pager-button{height:34px;border:none;display:flex;padding:0 4px;min-width:40px;-webkit-appearance:none;appearance:none;min-height:34px;-webkit-user-select:none;user-select:none;align-items:center;justify-content:center;background-color:transparent}.bb-collections-pager-button:hover,.bb-collections-pager-button:focus,.bb-collections-pager-button:active,.bb-collections-pager-button.active{color:#1565c0;font-weight:500}.bb-collections-pager-button:hover,.bb-collections-pager-button:focus{background-color:#1565c00d}.bb-collections-pager-button:active,.bb-collections-pager-button.active{background-color:#1565c033}.bb-collections-pager-button:not(.arrow):hover,.bb-collections-pager-button:not(.arrow):focus{outline:1px solid rgba(21,101,192,.5)}.bb-collections-pager-button:not(.arrow):focus,.bb-collections-pager-button:not(.arrow):active{outline:1px solid #1565c0;box-shadow:#1565c066 0 0 0 3px}.bb-collections-pager-button:not(.arrow).active{outline:1px solid #1565c0}.bb-collections-pager-button.arrow{font-weight:500}.bb-collections-pager-button.arrow.first{border-top-left-radius:2px;border-bottom-left-radius:2px}.bb-collections-pager-button.arrow.last{border-top-right-radius:2px;border-bottom-right-radius:2px}.bb-collections-pager-button:disabled{color:#000;outline:none;opacity:.25;cursor:default;pointer-events:none;background-color:transparent}@media only screen and (min-width: 768px){.bb-collections-pager{flex-wrap:wrap;align-items:center;flex-direction:row;justify-content:space-between}.bb-collections-pager-text{margin-top:0}.bb-collections-pager-container{width:auto;overflow-x:unset}}\n"], dependencies: [{ kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "pipe", type: i1.AsyncPipe, name: "async" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
287
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.3", ngImport: i0, type: BbCollectionsPager, decorators: [{
288
- type: Component,
289
- args: [{ selector: 'bb-collections-pager', changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, host: { 'class': 'bb-collections-pager' }, preserveWhitespaces: false, template: "<ng-container *ngIf=\"data$ | async as data\">\r\n <div [innerHTML]=\"data?.label\"\r\n class=\"bb-collections-pager-text\">\r\n </div>\r\n\r\n <div class=\"bb-collections-pager-container\">\r\n <ul class=\"bb-collections-pager-list\">\r\n <li class=\"bb-collections-pager-item\"\r\n title=\"Previous page\">\r\n <button [disabled]=\"!data?.allowPrevious\"\r\n (click)=\"setPage(data?.pageNumber - 1, data?.totalPages)\"\r\n class=\"bb-collections-pager-button arrow first\"\r\n type=\"button\">\r\n &#8592;\r\n </button>\r\n </li>\r\n <li *ngFor=\"let item of data?.pages\"\r\n [title]=\"'Page ' + item?.page\"\r\n class=\"bb-collections-pager-item\">\r\n <button [class.active]=\"item?.active\"\r\n (click)=\"setPage(item?.page, data?.totalPages)\"\r\n class=\"bb-collections-pager-button\"\r\n type=\"button\">\r\n {{ item?.page }}\r\n </button>\r\n </li>\r\n <li class=\"bb-collections-pager-item\"\r\n title=\"Next page\">\r\n <button [disabled]=\"!data?.allowNext\"\r\n (click)=\"setPage(data?.pageNumber + 1, data?.totalPages)\"\r\n class=\"bb-collections-pager-button arrow last\"\r\n type=\"button\">\r\n &#8594;\r\n </button>\r\n </li>\r\n </ul>\r\n </div>\r\n</ng-container>\r\n", styles: [".bb-collections-pager{display:flex;align-items:center;flex-direction:column-reverse}.bb-collections-pager-text{display:block;margin-top:10px}.bb-collections-pager-text>strong{font-weight:500}.bb-collections-pager-container{width:100%;display:flex;overflow-x:auto;align-items:center;justify-content:center}.bb-collections-pager-list{display:flex;border-radius:6px;align-items:center;background-color:#fff;border:1px solid rgba(67,90,111,.3);box-shadow:#435a6f24 0 1px 2px inset}.bb-collections-pager-item:not(:last-child){border-right:1px solid #cccccc}.bb-collections-pager-button{height:34px;border:none;display:flex;padding:0 4px;min-width:40px;-webkit-appearance:none;appearance:none;min-height:34px;-webkit-user-select:none;user-select:none;align-items:center;justify-content:center;background-color:transparent}.bb-collections-pager-button:hover,.bb-collections-pager-button:focus,.bb-collections-pager-button:active,.bb-collections-pager-button.active{color:#1565c0;font-weight:500}.bb-collections-pager-button:hover,.bb-collections-pager-button:focus{background-color:#1565c00d}.bb-collections-pager-button:active,.bb-collections-pager-button.active{background-color:#1565c033}.bb-collections-pager-button:not(.arrow):hover,.bb-collections-pager-button:not(.arrow):focus{outline:1px solid rgba(21,101,192,.5)}.bb-collections-pager-button:not(.arrow):focus,.bb-collections-pager-button:not(.arrow):active{outline:1px solid #1565c0;box-shadow:#1565c066 0 0 0 3px}.bb-collections-pager-button:not(.arrow).active{outline:1px solid #1565c0}.bb-collections-pager-button.arrow{font-weight:500}.bb-collections-pager-button.arrow.first{border-top-left-radius:2px;border-bottom-left-radius:2px}.bb-collections-pager-button.arrow.last{border-top-right-radius:2px;border-bottom-right-radius:2px}.bb-collections-pager-button:disabled{color:#000;outline:none;opacity:.25;cursor:default;pointer-events:none;background-color:transparent}@media only screen and (min-width: 768px){.bb-collections-pager{flex-wrap:wrap;align-items:center;flex-direction:row;justify-content:space-between}.bb-collections-pager-text{margin-top:0}.bb-collections-pager-container{width:auto;overflow-x:unset}}\n"] }]
290
- }], propDecorators: { label: [{
291
- type: Input
292
- }], collection: [{
293
- type: Input
195
+ class BbCollectionsPager {
196
+ constructor() {
197
+ // Readonly data.
198
+ this.maxAmountOfButtons = 5;
199
+ this.cache$ = new BehaviorSubject({});
200
+ // State and subscriptions.
201
+ this._label = null;
202
+ this._collection = null;
203
+ this._subscription = null;
204
+ }
205
+ // Inputs.
206
+ set label(value) {
207
+ this._label = value;
208
+ this.cache$.next(this.cache$.getValue());
209
+ }
210
+ set collection(collection) {
211
+ this._collection = collection;
212
+ this.observeCollectionChanges();
213
+ }
214
+ ngOnInit() {
215
+ this.data$ = this.cache$.pipe(map(cache => {
216
+ var _a, _b, _c, _d;
217
+ const pageSize = (_a = cache === null || cache === void 0 ? void 0 : cache.pageSize) !== null && _a !== void 0 ? _a : 1;
218
+ const pageNumber = (_b = cache === null || cache === void 0 ? void 0 : cache.pageNumber) !== null && _b !== void 0 ? _b : 1;
219
+ const totalPages = Math.max(0, (_c = cache === null || cache === void 0 ? void 0 : cache.totalPages) !== null && _c !== void 0 ? _c : 1);
220
+ const totalEntries = Math.max(0, (_d = cache === null || cache === void 0 ? void 0 : cache.totalEntries) !== null && _d !== void 0 ? _d : 0);
221
+ const fromStart = Math.max(0, Math.min((pageSize * (pageNumber - 1)) + 1, totalEntries));
222
+ const fromEnd = Math.max(0, Math.min((fromStart - 1) + pageSize, totalEntries));
223
+ const pages = this.filterActivePages(pageNumber, totalPages);
224
+ const allowNext = pageNumber < totalPages;
225
+ const allowPrevious = pageNumber > 1;
226
+ return {
227
+ totalPages,
228
+ pages,
229
+ pageNumber,
230
+ allowNext,
231
+ allowPrevious,
232
+ label: this.calculateLabel(fromStart, fromEnd, totalEntries)
233
+ };
234
+ }));
235
+ }
236
+ ngOnDestroy() {
237
+ var _a;
238
+ (_a = this._subscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
239
+ }
240
+ setPage(pageNumber, totalPages) {
241
+ var _a, _b, _c, _d;
242
+ // Calculate the new value.
243
+ const newValue = Math.min(totalPages, Math.max(1, pageNumber));
244
+ // Validate the value is actually different.
245
+ const currentValue = (_b = (_a = this._collection) === null || _a === void 0 ? void 0 : _a.pageNumberControl) === null || _b === void 0 ? void 0 : _b.value;
246
+ if (currentValue === newValue) {
247
+ return;
248
+ }
249
+ (_d = (_c = this._collection) === null || _c === void 0 ? void 0 : _c.pageNumberControl) === null || _d === void 0 ? void 0 : _d.setValue(pageNumber);
250
+ }
251
+ observeCollectionChanges() {
252
+ var _a, _b, _c, _d, _e;
253
+ if (!this._collection) {
254
+ return;
255
+ }
256
+ if (this._subscription) {
257
+ (_a = this._subscription) === null || _a === void 0 ? void 0 : _a.unsubscribe();
258
+ }
259
+ const pageNumber = (_c = (_b = this._collection) === null || _b === void 0 ? void 0 : _b.pageNumberControl) === null || _c === void 0 ? void 0 : _c.value;
260
+ const pageSize = (_e = (_d = this._collection) === null || _d === void 0 ? void 0 : _d.pageSizeControl) === null || _e === void 0 ? void 0 : _e.value;
261
+ this.cache$.next({ pageNumber, pageSize });
262
+ this._subscription = this._collection.raw$.subscribe(data => {
263
+ if (data) {
264
+ this.cache$.next(data);
265
+ }
266
+ });
267
+ }
268
+ calculateLabel(start, end, total) {
269
+ var _a;
270
+ const startPoint = '[start]';
271
+ const endPoint = '[end]';
272
+ const totalPoint = '[total]';
273
+ const label = (_a = this._label) !== null && _a !== void 0 ? _a : `Showing ${startPoint} to ${endPoint} of ${totalPoint} results`;
274
+ return label
275
+ .replace(startPoint, `<strong>${start}</strong>`)
276
+ .replace(endPoint, `<strong>${end}</strong>`)
277
+ .replace(totalPoint, `<strong>${total}</strong>`);
278
+ }
279
+ calculatePages(pageNumber, totalPages) {
280
+ const min = 1;
281
+ const max = totalPages;
282
+ const amount = Math.max(1, this.maxAmountOfButtons);
283
+ const data = Array(amount)
284
+ .fill(0)
285
+ .map((_, index) => pageNumber + (index - 1));
286
+ // Validate if the minimum value less than
287
+ // the first value.
288
+ if (data[0] < min) {
289
+ return data.map(item => item + 1);
290
+ }
291
+ // Calculate the difference with the max
292
+ // if this value is higher than 0 we should minus it.
293
+ const lastValueInArray = data[data.length - 1];
294
+ const differenceWithMax = lastValueInArray - max;
295
+ if (differenceWithMax > 0) {
296
+ return data.map(item => item - differenceWithMax);
297
+ }
298
+ // Just return the default data.
299
+ return data;
300
+ }
301
+ filterActivePages(pageNumber, totalPages) {
302
+ return this.calculatePages(pageNumber, totalPages)
303
+ .filter(page => page > 0 && page <= totalPages)
304
+ .map(page => ({ page, active: pageNumber === page }));
305
+ }
306
+ }
307
+ BbCollectionsPager.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.4", ngImport: i0, type: BbCollectionsPager, deps: [], target: i0.ɵɵFactoryTarget.Component });
308
+ BbCollectionsPager.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.0.4", type: BbCollectionsPager, selector: "bb-collections-pager", inputs: { label: "label", collection: "collection" }, host: { classAttribute: "bb-collections-pager" }, ngImport: i0, template: "<ng-container *ngIf=\"data$ | async as data\">\n <div [innerHTML]=\"data?.label\"\n class=\"bb-collections-pager-text\">\n </div>\n\n <div class=\"bb-collections-pager-container\">\n <ul class=\"bb-collections-pager-list\">\n <li class=\"bb-collections-pager-item\"\n title=\"Previous page\">\n <button [disabled]=\"!data?.allowPrevious\"\n (click)=\"setPage(data?.pageNumber - 1, data?.totalPages)\"\n class=\"bb-collections-pager-button arrow first\"\n type=\"button\">\n &#8592;\n </button>\n </li>\n <li *ngFor=\"let item of data?.pages\"\n [title]=\"'Page ' + item?.page\"\n class=\"bb-collections-pager-item\">\n <button [class.active]=\"item?.active\"\n (click)=\"setPage(item?.page, data?.totalPages)\"\n class=\"bb-collections-pager-button\"\n type=\"button\">\n {{ item?.page }}\n </button>\n </li>\n <li class=\"bb-collections-pager-item\"\n title=\"Next page\">\n <button [disabled]=\"!data?.allowNext\"\n (click)=\"setPage(data?.pageNumber + 1, data?.totalPages)\"\n class=\"bb-collections-pager-button arrow last\"\n type=\"button\">\n &#8594;\n </button>\n </li>\n </ul>\n </div>\n</ng-container>\n", styles: [".bb-collections-pager{display:flex;align-items:center;flex-direction:column-reverse}.bb-collections-pager-text{display:block;margin-top:10px}.bb-collections-pager-text>strong{font-weight:500}.bb-collections-pager-container{width:100%;display:flex;overflow-x:auto;align-items:center;justify-content:center}.bb-collections-pager-list{display:flex;border-radius:6px;align-items:center;background-color:#fff;border:1px solid rgba(67,90,111,.3);box-shadow:#435a6f24 0 1px 2px inset}.bb-collections-pager-item:not(:last-child){border-right:1px solid #cccccc}.bb-collections-pager-button{height:34px;border:none;display:flex;padding:0 4px;min-width:40px;-webkit-appearance:none;appearance:none;min-height:34px;-webkit-user-select:none;user-select:none;align-items:center;justify-content:center;background-color:transparent}.bb-collections-pager-button:hover,.bb-collections-pager-button:focus,.bb-collections-pager-button:active,.bb-collections-pager-button.active{color:#1565c0;font-weight:500}.bb-collections-pager-button:hover,.bb-collections-pager-button:focus{background-color:#1565c00d}.bb-collections-pager-button:active,.bb-collections-pager-button.active{background-color:#1565c033}.bb-collections-pager-button:not(.arrow):hover,.bb-collections-pager-button:not(.arrow):focus{outline:1px solid rgba(21,101,192,.5)}.bb-collections-pager-button:not(.arrow):focus,.bb-collections-pager-button:not(.arrow):active{outline:1px solid #1565c0;box-shadow:#1565c066 0 0 0 3px}.bb-collections-pager-button:not(.arrow).active{outline:1px solid #1565c0}.bb-collections-pager-button.arrow{font-weight:500}.bb-collections-pager-button.arrow.first{border-top-left-radius:2px;border-bottom-left-radius:2px}.bb-collections-pager-button.arrow.last{border-top-right-radius:2px;border-bottom-right-radius:2px}.bb-collections-pager-button:disabled{color:#000;outline:none;opacity:.25;cursor:default;pointer-events:none;background-color:transparent}@media only screen and (min-width: 768px){.bb-collections-pager{flex-wrap:wrap;align-items:center;flex-direction:row;justify-content:space-between}.bb-collections-pager-text{margin-top:0}.bb-collections-pager-container{width:auto;overflow-x:unset}}\n"], dependencies: [{ kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "pipe", type: i1.AsyncPipe, name: "async" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
309
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.4", ngImport: i0, type: BbCollectionsPager, decorators: [{
310
+ type: Component,
311
+ args: [{ selector: 'bb-collections-pager', changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, host: { 'class': 'bb-collections-pager' }, preserveWhitespaces: false, template: "<ng-container *ngIf=\"data$ | async as data\">\n <div [innerHTML]=\"data?.label\"\n class=\"bb-collections-pager-text\">\n </div>\n\n <div class=\"bb-collections-pager-container\">\n <ul class=\"bb-collections-pager-list\">\n <li class=\"bb-collections-pager-item\"\n title=\"Previous page\">\n <button [disabled]=\"!data?.allowPrevious\"\n (click)=\"setPage(data?.pageNumber - 1, data?.totalPages)\"\n class=\"bb-collections-pager-button arrow first\"\n type=\"button\">\n &#8592;\n </button>\n </li>\n <li *ngFor=\"let item of data?.pages\"\n [title]=\"'Page ' + item?.page\"\n class=\"bb-collections-pager-item\">\n <button [class.active]=\"item?.active\"\n (click)=\"setPage(item?.page, data?.totalPages)\"\n class=\"bb-collections-pager-button\"\n type=\"button\">\n {{ item?.page }}\n </button>\n </li>\n <li class=\"bb-collections-pager-item\"\n title=\"Next page\">\n <button [disabled]=\"!data?.allowNext\"\n (click)=\"setPage(data?.pageNumber + 1, data?.totalPages)\"\n class=\"bb-collections-pager-button arrow last\"\n type=\"button\">\n &#8594;\n </button>\n </li>\n </ul>\n </div>\n</ng-container>\n", styles: [".bb-collections-pager{display:flex;align-items:center;flex-direction:column-reverse}.bb-collections-pager-text{display:block;margin-top:10px}.bb-collections-pager-text>strong{font-weight:500}.bb-collections-pager-container{width:100%;display:flex;overflow-x:auto;align-items:center;justify-content:center}.bb-collections-pager-list{display:flex;border-radius:6px;align-items:center;background-color:#fff;border:1px solid rgba(67,90,111,.3);box-shadow:#435a6f24 0 1px 2px inset}.bb-collections-pager-item:not(:last-child){border-right:1px solid #cccccc}.bb-collections-pager-button{height:34px;border:none;display:flex;padding:0 4px;min-width:40px;-webkit-appearance:none;appearance:none;min-height:34px;-webkit-user-select:none;user-select:none;align-items:center;justify-content:center;background-color:transparent}.bb-collections-pager-button:hover,.bb-collections-pager-button:focus,.bb-collections-pager-button:active,.bb-collections-pager-button.active{color:#1565c0;font-weight:500}.bb-collections-pager-button:hover,.bb-collections-pager-button:focus{background-color:#1565c00d}.bb-collections-pager-button:active,.bb-collections-pager-button.active{background-color:#1565c033}.bb-collections-pager-button:not(.arrow):hover,.bb-collections-pager-button:not(.arrow):focus{outline:1px solid rgba(21,101,192,.5)}.bb-collections-pager-button:not(.arrow):focus,.bb-collections-pager-button:not(.arrow):active{outline:1px solid #1565c0;box-shadow:#1565c066 0 0 0 3px}.bb-collections-pager-button:not(.arrow).active{outline:1px solid #1565c0}.bb-collections-pager-button.arrow{font-weight:500}.bb-collections-pager-button.arrow.first{border-top-left-radius:2px;border-bottom-left-radius:2px}.bb-collections-pager-button.arrow.last{border-top-right-radius:2px;border-bottom-right-radius:2px}.bb-collections-pager-button:disabled{color:#000;outline:none;opacity:.25;cursor:default;pointer-events:none;background-color:transparent}@media only screen and (min-width: 768px){.bb-collections-pager{flex-wrap:wrap;align-items:center;flex-direction:row;justify-content:space-between}.bb-collections-pager-text{margin-top:0}.bb-collections-pager-container{width:auto;overflow-x:unset}}\n"] }]
312
+ }], propDecorators: { label: [{
313
+ type: Input
314
+ }], collection: [{
315
+ type: Input
294
316
  }] } });
295
317
 
296
- class Collection {
297
- constructor(_provider, _initialValues = {}) {
298
- var _a, _b, _c, _d, _e;
299
- this._provider = _provider;
300
- this._initialValues = _initialValues;
301
- this.raw$ = new BehaviorSubject(null);
302
- this.loading$ = new BehaviorSubject(true);
303
- // State.
304
- this._formatter = null;
305
- this._refresh$ = new BehaviorSubject(0);
306
- this._requestCache = null;
307
- this.controlToObservable = (control) => {
308
- return control.valueChanges.pipe(distinctUntilChanged(), startWith(control === null || control === void 0 ? void 0 : control.value));
309
- };
310
- this.queryControl = new FormControl((_a = _initialValues === null || _initialValues === void 0 ? void 0 : _initialValues.query) !== null && _a !== void 0 ? _a : null);
311
- this.queryFieldsControl = new FormControl((_b = _initialValues === null || _initialValues === void 0 ? void 0 : _initialValues.queryFields) !== null && _b !== void 0 ? _b : []);
312
- this.pageNumberControl = new FormControl((_c = _initialValues === null || _initialValues === void 0 ? void 0 : _initialValues.pageNumber) !== null && _c !== void 0 ? _c : 1);
313
- this.pageSizeControl = new FormControl((_d = _initialValues === null || _initialValues === void 0 ? void 0 : _initialValues.pageSize) !== null && _d !== void 0 ? _d : 25);
314
- this.sortControl = new FormControl((_e = _initialValues === null || _initialValues === void 0 ? void 0 : _initialValues.sort) !== null && _e !== void 0 ? _e : null);
315
- this.data$ = this.getData();
316
- }
317
- refresh() {
318
- this._refresh$.next(0);
319
- }
320
- setFormatter(callback) {
321
- this._formatter = callback;
322
- return this;
323
- }
324
- getData() {
325
- const data$ = this.request.pipe(tap(() => this.loading$.next(true)), map(request => this.validateRequest(request)), switchMap(request => {
326
- return this._provider.transform(request).pipe(tap(response => this.cacheCollectionData(response)), map(response => ({ response, request, initial: false })), catchError(error => of({
327
- error,
328
- request,
329
- response: null,
330
- initial: false
331
- })));
332
- }), startWith({ initial: true, response: null }));
333
- return combineLatest([data$, this.loading$.asObservable()]).pipe(switchMap(([data, loading]) => {
334
- const combined = Object.assign(Object.assign({}, data), { loading });
335
- return this.formatResponse(data === null || data === void 0 ? void 0 : data.response).pipe(map(response => (Object.assign(Object.assign({}, combined), { response, state: this.getState(combined) }))));
336
- }));
337
- }
338
- formatResponse(response) {
339
- var _a, _b, _c;
340
- if (!response || !this._formatter) {
341
- return of(response);
342
- }
343
- const items = (_a = response === null || response === void 0 ? void 0 : response.data) !== null && _a !== void 0 ? _a : [];
344
- const data = (_c = (_b = this._formatter) === null || _b === void 0 ? void 0 : _b.call(this, items)) !== null && _c !== void 0 ? _c : items;
345
- const data$ = isObservable(data) ? data : of(data);
346
- return data$.pipe(map(data => (Object.assign(Object.assign({}, response), { data }))));
347
- }
348
- validateRequest(request) {
349
- var _a, _b, _c, _d;
350
- // We should reset the page number whenever we change the query or the page size.
351
- if (this._requestCache && request && (((_a = this._requestCache) === null || _a === void 0 ? void 0 : _a.query) !== (request === null || request === void 0 ? void 0 : request.query) || ((_b = this._requestCache) === null || _b === void 0 ? void 0 : _b.pageSize) !== (request === null || request === void 0 ? void 0 : request.pageSize))) {
352
- (_c = this.pageNumberControl) === null || _c === void 0 ? void 0 : _c.setValue(1, { emitEvent: false });
353
- request.pageNumber = (_d = this.pageNumberControl) === null || _d === void 0 ? void 0 : _d.value;
354
- }
355
- this._requestCache = Object.assign({}, request);
356
- return request;
357
- }
358
- getState(data) {
359
- var _a, _b, _c;
360
- if (!!(data === null || data === void 0 ? void 0 : data.error)) {
361
- return "error" /* CollectionState.Error */;
362
- }
363
- if (!!(data === null || data === void 0 ? void 0 : data.initial)) {
364
- return "initial" /* CollectionState.Initial */;
365
- }
366
- const count = (_c = (_b = (_a = data === null || data === void 0 ? void 0 : data.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0;
367
- if (count <= 0) {
368
- return "empty" /* CollectionState.Empty */;
369
- }
370
- return "data" /* CollectionState.Data */;
371
- }
372
- cacheCollectionData(data) {
373
- this.raw$.next(data);
374
- this.loading$.next(false);
375
- }
376
- get request() {
377
- const pageNumber$ = this.controlToObservable(this.pageNumberControl);
378
- const pageSize$ = this.controlToObservable(this.pageSizeControl);
379
- const query$ = this.getQueryObservable();
380
- const queryFields$ = this.controlToObservable(this.queryFieldsControl);
381
- const sort$ = this.controlToObservable(this.sortControl);
382
- return combineLatest([pageNumber$, pageSize$, query$, queryFields$, sort$, this._refresh$.asObservable()]).pipe(map(([pageNumber, pageSize, query, queryFields, sort]) => ({
383
- pageNumber,
384
- pageSize,
385
- query,
386
- queryFields,
387
- sort
388
- })));
389
- }
390
- getQueryObservable() {
391
- var _a;
392
- return this.queryControl.valueChanges.pipe(debounceTime(400), distinctUntilChanged(), startWith((_a = this.queryControl) === null || _a === void 0 ? void 0 : _a.value));
393
- }
318
+ class Collection {
319
+ constructor(_provider, _initialValues = {}) {
320
+ var _a, _b, _c, _d, _e;
321
+ this._provider = _provider;
322
+ this._initialValues = _initialValues;
323
+ this.raw$ = new BehaviorSubject(null);
324
+ this.loading$ = new BehaviorSubject(true);
325
+ // State.
326
+ this._formatter = null;
327
+ this._refresh$ = new BehaviorSubject(0);
328
+ this._requestCache = null;
329
+ this.queryControl = new FormControl((_a = _initialValues === null || _initialValues === void 0 ? void 0 : _initialValues.query) !== null && _a !== void 0 ? _a : null);
330
+ this.queryFieldsControl = new FormControl((_b = _initialValues === null || _initialValues === void 0 ? void 0 : _initialValues.queryFields) !== null && _b !== void 0 ? _b : []);
331
+ this.pageNumberControl = new FormControl((_c = _initialValues === null || _initialValues === void 0 ? void 0 : _initialValues.pageNumber) !== null && _c !== void 0 ? _c : 1);
332
+ this.pageSizeControl = new FormControl((_d = _initialValues === null || _initialValues === void 0 ? void 0 : _initialValues.pageSize) !== null && _d !== void 0 ? _d : 25);
333
+ this.sortControl = new FormControl((_e = _initialValues === null || _initialValues === void 0 ? void 0 : _initialValues.sort) !== null && _e !== void 0 ? _e : null);
334
+ this.data$ = this.getData();
335
+ }
336
+ refresh() {
337
+ this._refresh$.next(0);
338
+ }
339
+ setFormatter(callback) {
340
+ this._formatter = callback;
341
+ return this;
342
+ }
343
+ getData() {
344
+ const data$ = this.request.pipe(tap(() => this.loading$.next(true)), map(request => this.validateRequest(request)), switchMap(request => {
345
+ return this._provider.transform(request).pipe(tap(response => this.cacheCollectionData(response)), map(response => ({ response, request, initial: false })), catchError(error => of({
346
+ error,
347
+ request,
348
+ response: null,
349
+ initial: false
350
+ })));
351
+ }), startWith({ initial: true, response: null }));
352
+ return combineLatest([data$, this.loading$.asObservable()]).pipe(switchMap(([data, loading]) => {
353
+ const combined = Object.assign(Object.assign({}, data), { loading });
354
+ return this.formatResponse(data === null || data === void 0 ? void 0 : data.response).pipe(map(response => (Object.assign(Object.assign({}, combined), { response, state: this.getState(combined) }))));
355
+ }));
356
+ }
357
+ formatResponse(response) {
358
+ var _a, _b, _c;
359
+ if (!response || !this._formatter) {
360
+ return of(response);
361
+ }
362
+ const items = (_a = response === null || response === void 0 ? void 0 : response.data) !== null && _a !== void 0 ? _a : [];
363
+ const data = (_c = (_b = this._formatter) === null || _b === void 0 ? void 0 : _b.call(this, items)) !== null && _c !== void 0 ? _c : items;
364
+ const data$ = isObservable(data) ? data : of(data);
365
+ return data$.pipe(map(data => (Object.assign(Object.assign({}, response), { data }))));
366
+ }
367
+ validateRequest(request) {
368
+ var _a, _b, _c, _d;
369
+ // We should reset the page number whenever we change the query or the page size.
370
+ if (this._requestCache && request && (((_a = this._requestCache) === null || _a === void 0 ? void 0 : _a.query) !== (request === null || request === void 0 ? void 0 : request.query) || ((_b = this._requestCache) === null || _b === void 0 ? void 0 : _b.pageSize) !== (request === null || request === void 0 ? void 0 : request.pageSize))) {
371
+ (_c = this.pageNumberControl) === null || _c === void 0 ? void 0 : _c.setValue(1, { emitEvent: false });
372
+ request.pageNumber = (_d = this.pageNumberControl) === null || _d === void 0 ? void 0 : _d.value;
373
+ }
374
+ this._requestCache = Object.assign({}, request);
375
+ return request;
376
+ }
377
+ getState(data) {
378
+ var _a, _b, _c;
379
+ if (!!(data === null || data === void 0 ? void 0 : data.error)) {
380
+ return "error" /* CollectionState.Error */;
381
+ }
382
+ if (!!(data === null || data === void 0 ? void 0 : data.initial)) {
383
+ return "initial" /* CollectionState.Initial */;
384
+ }
385
+ const count = (_c = (_b = (_a = data === null || data === void 0 ? void 0 : data.response) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0;
386
+ if (count <= 0) {
387
+ return "empty" /* CollectionState.Empty */;
388
+ }
389
+ return "data" /* CollectionState.Data */;
390
+ }
391
+ cacheCollectionData(data) {
392
+ this.raw$.next(data);
393
+ this.loading$.next(false);
394
+ }
395
+ get request() {
396
+ const pageNumber$ = getControlValue(this.pageNumberControl);
397
+ const pageSize$ = getControlValue(this.pageSizeControl);
398
+ const query$ = this.getQueryObservable();
399
+ const queryFields$ = getControlValue(this.queryFieldsControl);
400
+ const sort$ = getControlValue(this.sortControl);
401
+ return combineLatest([pageNumber$, pageSize$, query$, queryFields$, sort$, this._refresh$.asObservable()]).pipe(map(([pageNumber, pageSize, query, queryFields, sort]) => ({
402
+ pageNumber,
403
+ pageSize,
404
+ query,
405
+ queryFields,
406
+ sort
407
+ })));
408
+ }
409
+ getQueryObservable() {
410
+ var _a;
411
+ return this.queryControl.valueChanges.pipe(debounceTime(400), distinctUntilChanged(), startWith((_a = this.queryControl) === null || _a === void 0 ? void 0 : _a.value));
412
+ }
394
413
  }
395
414
 
396
- class CollectionsModule {
397
- }
398
- CollectionsModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.3", ngImport: i0, type: CollectionsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
399
- CollectionsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.0.3", ngImport: i0, type: CollectionsModule, declarations: [
400
- // Components.
401
- BbCollectionsViewer,
402
- BbCollectionsPager,
403
- // Directives.
404
- BbCollectionsData,
405
- BbCollectionsEmpty,
406
- BbCollectionsError,
407
- BbCollectionsInitial
408
- ], imports: [CommonModule], exports: [
409
- // Components.
410
- BbCollectionsViewer,
411
- BbCollectionsPager,
412
- // Directives.
413
- BbCollectionsData,
414
- BbCollectionsEmpty,
415
- BbCollectionsError,
416
- BbCollectionsInitial
417
- ] });
418
- CollectionsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.0.3", ngImport: i0, type: CollectionsModule, imports: [CommonModule] });
419
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.3", ngImport: i0, type: CollectionsModule, decorators: [{
420
- type: NgModule,
421
- args: [{
422
- imports: [CommonModule],
423
- declarations: [
424
- // Components.
425
- BbCollectionsViewer,
426
- BbCollectionsPager,
427
- // Directives.
428
- BbCollectionsData,
429
- BbCollectionsEmpty,
430
- BbCollectionsError,
431
- BbCollectionsInitial
432
- ],
433
- exports: [
434
- // Components.
435
- BbCollectionsViewer,
436
- BbCollectionsPager,
437
- // Directives.
438
- BbCollectionsData,
439
- BbCollectionsEmpty,
440
- BbCollectionsError,
441
- BbCollectionsInitial
442
- ]
443
- }]
415
+ class CollectionsModule {
416
+ }
417
+ CollectionsModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.0.4", ngImport: i0, type: CollectionsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
418
+ CollectionsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.0.4", ngImport: i0, type: CollectionsModule, declarations: [
419
+ // Components.
420
+ BbCollectionsViewer,
421
+ BbCollectionsPager,
422
+ // Directives.
423
+ BbCollectionsData,
424
+ BbCollectionsEmpty,
425
+ BbCollectionsError,
426
+ BbCollectionsInitial
427
+ ], imports: [CommonModule], exports: [
428
+ // Components.
429
+ BbCollectionsViewer,
430
+ BbCollectionsPager,
431
+ // Directives.
432
+ BbCollectionsData,
433
+ BbCollectionsEmpty,
434
+ BbCollectionsError,
435
+ BbCollectionsInitial
436
+ ] });
437
+ CollectionsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.0.4", ngImport: i0, type: CollectionsModule, imports: [CommonModule] });
438
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.0.4", ngImport: i0, type: CollectionsModule, decorators: [{
439
+ type: NgModule,
440
+ args: [{
441
+ imports: [CommonModule],
442
+ declarations: [
443
+ // Components.
444
+ BbCollectionsViewer,
445
+ BbCollectionsPager,
446
+ // Directives.
447
+ BbCollectionsData,
448
+ BbCollectionsEmpty,
449
+ BbCollectionsError,
450
+ BbCollectionsInitial
451
+ ],
452
+ exports: [
453
+ // Components.
454
+ BbCollectionsViewer,
455
+ BbCollectionsPager,
456
+ // Directives.
457
+ BbCollectionsData,
458
+ BbCollectionsEmpty,
459
+ BbCollectionsError,
460
+ BbCollectionsInitial
461
+ ]
462
+ }]
444
463
  }] });
445
464
 
446
- /**
447
- * Generated bundle index. Do not edit.
465
+ /**
466
+ * Generated bundle index. Do not edit.
448
467
  */
449
468
 
450
469
  export { ApiCollectionProvider, BbCollectionsData, BbCollectionsEmpty, BbCollectionsError, BbCollectionsInitial, BbCollectionsPager, BbCollectionsViewer, Collection, CollectionProvider, CollectionsModule, LocalCollectionProvider };