@bravobit/bb-foundation 0.16.3 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -47
- package/auth/bravobit-bb-foundation-auth.d.ts +5 -5
- package/auth/lib/auth.interceptor.d.ts +21 -21
- package/auth/lib/auth.module.d.ts +15 -15
- package/auth/lib/auth.service.d.ts +59 -59
- package/auth/lib/auth.session.d.ts +34 -34
- package/auth/lib/directives/authenticated.directive.d.ts +14 -14
- package/auth/lib/directives/permission.directive.d.ts +24 -24
- package/auth/lib/directives/role.directive.d.ts +16 -16
- package/auth/lib/guards/anonymous.guard.d.ts +11 -11
- package/auth/lib/guards/authenticated.guard.d.ts +11 -11
- package/auth/lib/helpers/jwt.helper.d.ts +8 -8
- package/auth/lib/helpers/mapper.helper.d.ts +23 -23
- package/auth/lib/interfaces/config.interface.d.ts +12 -12
- package/auth/lib/interfaces/mapper.interface.d.ts +19 -19
- package/auth/lib/interfaces/provider.interface.d.ts +16 -16
- package/auth/lib/interfaces/token.interface.d.ts +11 -11
- package/auth/lib/permissions.service.d.ts +14 -14
- package/auth/lib/providers/email.provider.d.ts +15 -15
- package/auth/lib/providers/verify.provider.d.ts +13 -13
- package/auth/lib/tokens/use-authorization.token.d.ts +2 -2
- package/auth/public_api.d.ts +18 -18
- package/bravobit-bb-foundation.d.ts +5 -5
- package/collections/bravobit-bb-foundation-collections.d.ts +5 -5
- package/collections/lib/collection.d.ts +43 -43
- package/collections/lib/collections.module.d.ts +10 -10
- package/collections/lib/components/collections-pager/collections-pager.component.d.ts +34 -34
- package/collections/lib/components/collections-viewer/collections-viewer.component.d.ts +12 -12
- package/collections/lib/components/collections.directive.d.ts +17 -17
- package/collections/lib/interfaces/collection.interface.d.ts +26 -26
- package/collections/lib/providers/api-collection.provider.d.ts +17 -15
- package/collections/lib/providers/collection.provider.d.ts +6 -6
- package/collections/lib/providers/local-collection.provider.d.ts +8 -8
- package/collections/public_api.d.ts +9 -9
- package/controls/bravobit-bb-foundation-controls.d.ts +5 -5
- package/controls/lib/checkbox/checkbox/checkbox.component.d.ts +47 -47
- package/controls/lib/checkbox/checkbox-group/checkbox-group.component.d.ts +18 -18
- package/controls/lib/checkbox/checkbox.module.d.ts +9 -9
- package/controls/lib/controls.module.d.ts +7 -7
- package/controls/public_api.d.ts +4 -4
- package/dashboard/bravobit-bb-foundation-dashboard.d.ts +5 -5
- package/dashboard/lib/dashboard/dashboard.component.d.ts +19 -19
- package/dashboard/lib/dashboard-header/dashboard-header.component.d.ts +11 -11
- package/dashboard/lib/dashboard-menu/dashboard-menu.component.d.ts +9 -9
- package/dashboard/lib/dashboard-menu-item/dashboard-menu-item.component.d.ts +11 -11
- package/dashboard/lib/dashboard-sidebar/dashboard-sidebar.component.d.ts +21 -21
- package/dashboard/lib/dashboard-sidebar-group/dashboard-sidebar-group.component.d.ts +27 -27
- package/dashboard/lib/dashboard-sidebar-item/dashboard-sidebar-item.component.d.ts +16 -16
- package/dashboard/lib/dashboard.module.d.ts +16 -16
- package/dashboard/public_api.d.ts +8 -8
- package/dialog/bravobit-bb-foundation-dialog.d.ts +5 -5
- package/dialog/lib/dialog-actions/dialog-actions.component.d.ts +5 -5
- package/dialog/lib/dialog-confirm/dialog-confirm.component.d.ts +16 -16
- package/dialog/lib/dialog-container/dialog-container.component.d.ts +24 -24
- package/dialog/lib/dialog-header/dialog-header.component.d.ts +9 -9
- package/dialog/lib/dialog-link/dialog-link.component.d.ts +5 -5
- package/dialog/lib/dialog-modal/dialog-modal.component.d.ts +12 -12
- package/dialog/lib/dialog-overlay/dialog-overlay.component.d.ts +22 -22
- package/dialog/lib/dialog.injector.d.ts +8 -8
- package/dialog/lib/dialog.insertion.d.ts +8 -8
- package/dialog/lib/dialog.interfaces.d.ts +3 -3
- package/dialog/lib/dialog.module.d.ts +19 -19
- package/dialog/lib/dialog.ref.d.ts +8 -8
- package/dialog/lib/dialog.service.d.ts +19 -19
- package/dialog/public_api.d.ts +9 -9
- package/elements/bravobit-bb-foundation-elements.d.ts +5 -5
- package/elements/lib/avatar/avatar.component.d.ts +25 -25
- package/elements/lib/button/button.component.d.ts +23 -23
- package/elements/lib/checkbox/checkbox.component.d.ts +27 -27
- package/elements/lib/date-picker/date-picker.component.d.ts +69 -69
- package/elements/lib/directives/addon.directive.d.ts +9 -9
- package/elements/lib/directives/autosize.directive.d.ts +18 -18
- package/elements/lib/directives/focus-trap.directive.d.ts +17 -17
- package/elements/lib/directives/focus.directive.d.ts +14 -14
- package/elements/lib/directives/form-submit.directive.d.ts +17 -17
- package/elements/lib/directives/input.directive.d.ts +38 -38
- package/elements/lib/directives/template.directive.d.ts +10 -10
- package/elements/lib/dropdown/dropdown.component.d.ts +21 -21
- package/elements/lib/elements.interfaces.d.ts +25 -25
- package/elements/lib/elements.module.d.ts +116 -116
- package/elements/lib/file-picker/file-picker.component.d.ts +49 -49
- package/elements/lib/form-control/form-control.component.d.ts +21 -21
- package/elements/lib/form-error/form-error.component.d.ts +29 -29
- package/elements/lib/form-group/form-group.component.d.ts +10 -10
- package/elements/lib/icon/icon.component.d.ts +22 -22
- package/elements/lib/image-picker/image-picker.component.d.ts +38 -38
- package/elements/lib/pipes/file-image.pipe.d.ts +13 -13
- package/elements/lib/pipes/file-size.pipe.d.ts +8 -8
- package/elements/lib/pipes/relative-time.pipe.d.ts +19 -19
- package/elements/lib/spinner/spinner.component.d.ts +12 -12
- package/elements/lib/tag/tag.component.d.ts +7 -7
- package/elements/public_api.d.ts +25 -25
- package/esm2020/auth/bravobit-bb-foundation-auth.mjs +4 -4
- package/esm2020/auth/lib/auth.interceptor.mjs +93 -94
- package/esm2020/auth/lib/auth.module.mjs +54 -54
- package/esm2020/auth/lib/auth.service.mjs +281 -276
- package/esm2020/auth/lib/auth.session.mjs +131 -131
- package/esm2020/auth/lib/directives/authenticated.directive.mjs +31 -31
- package/esm2020/auth/lib/directives/permission.directive.mjs +80 -80
- package/esm2020/auth/lib/directives/role.directive.mjs +37 -37
- package/esm2020/auth/lib/guards/anonymous.guard.mjs +34 -34
- package/esm2020/auth/lib/guards/authenticated.guard.mjs +35 -35
- package/esm2020/auth/lib/helpers/jwt.helper.mjs +69 -69
- package/esm2020/auth/lib/helpers/mapper.helper.mjs +35 -35
- package/esm2020/auth/lib/interfaces/config.interface.mjs +3 -3
- package/esm2020/auth/lib/interfaces/mapper.interface.mjs +2 -2
- package/esm2020/auth/lib/interfaces/provider.interface.mjs +2 -2
- package/esm2020/auth/lib/interfaces/token.interface.mjs +2 -2
- package/esm2020/auth/lib/permissions.service.mjs +56 -56
- package/esm2020/auth/lib/providers/email.provider.mjs +25 -25
- package/esm2020/auth/lib/providers/verify.provider.mjs +19 -19
- package/esm2020/auth/lib/tokens/use-authorization.token.mjs +3 -3
- package/esm2020/auth/public_api.mjs +19 -19
- package/esm2020/bravobit-bb-foundation.mjs +4 -4
- package/esm2020/collections/bravobit-bb-foundation-collections.mjs +4 -4
- package/esm2020/collections/lib/collection.mjs +102 -102
- package/esm2020/collections/lib/collections.module.mjs +54 -54
- package/esm2020/collections/lib/components/collections-pager/collections-pager.component.mjs +123 -123
- package/esm2020/collections/lib/components/collections-viewer/collections-viewer.component.mjs +31 -31
- package/esm2020/collections/lib/components/collections.directive.mjs +43 -43
- package/esm2020/collections/lib/interfaces/collection.interface.mjs +2 -2
- package/esm2020/collections/lib/providers/api-collection.provider.mjs +71 -71
- package/esm2020/collections/lib/providers/collection.provider.mjs +13 -13
- package/esm2020/collections/lib/providers/local-collection.provider.mjs +16 -16
- package/esm2020/collections/public_api.mjs +10 -10
- package/esm2020/controls/bravobit-bb-foundation-controls.mjs +4 -4
- package/esm2020/controls/lib/checkbox/checkbox/checkbox.component.mjs +153 -153
- package/esm2020/controls/lib/checkbox/checkbox-group/checkbox-group.component.mjs +48 -48
- package/esm2020/controls/lib/checkbox/checkbox.module.mjs +19 -19
- package/esm2020/controls/lib/controls.module.mjs +16 -16
- package/esm2020/controls/public_api.mjs +5 -5
- package/esm2020/dashboard/bravobit-bb-foundation-dashboard.mjs +4 -4
- package/esm2020/dashboard/lib/dashboard/dashboard.component.mjs +56 -56
- package/esm2020/dashboard/lib/dashboard-header/dashboard-header.component.mjs +30 -30
- package/esm2020/dashboard/lib/dashboard-menu/dashboard-menu.component.mjs +31 -31
- package/esm2020/dashboard/lib/dashboard-menu-item/dashboard-menu-item.component.mjs +29 -29
- package/esm2020/dashboard/lib/dashboard-sidebar/dashboard-sidebar.component.mjs +75 -75
- package/esm2020/dashboard/lib/dashboard-sidebar-group/dashboard-sidebar-group.component.mjs +99 -99
- package/esm2020/dashboard/lib/dashboard-sidebar-item/dashboard-sidebar-item.component.mjs +62 -62
- package/esm2020/dashboard/lib/dashboard.module.mjs +47 -47
- package/esm2020/dashboard/public_api.mjs +9 -9
- package/esm2020/dialog/bravobit-bb-foundation-dialog.mjs +4 -4
- package/esm2020/dialog/lib/dialog-actions/dialog-actions.component.mjs +12 -12
- package/esm2020/dialog/lib/dialog-confirm/dialog-confirm.component.mjs +37 -37
- package/esm2020/dialog/lib/dialog-container/dialog-container.component.mjs +153 -153
- package/esm2020/dialog/lib/dialog-header/dialog-header.component.mjs +25 -25
- package/esm2020/dialog/lib/dialog-link/dialog-link.component.mjs +11 -11
- package/esm2020/dialog/lib/dialog-modal/dialog-modal.component.mjs +46 -46
- package/esm2020/dialog/lib/dialog-overlay/dialog-overlay.component.mjs +134 -134
- package/esm2020/dialog/lib/dialog.injector.mjs +18 -18
- package/esm2020/dialog/lib/dialog.insertion.mjs +16 -16
- package/esm2020/dialog/lib/dialog.interfaces.mjs +3 -3
- package/esm2020/dialog/lib/dialog.module.mjs +70 -70
- package/esm2020/dialog/lib/dialog.ref.mjs +22 -22
- package/esm2020/dialog/lib/dialog.service.mjs +77 -77
- package/esm2020/dialog/public_api.mjs +10 -10
- package/esm2020/elements/bravobit-bb-foundation-elements.mjs +4 -4
- package/esm2020/elements/lib/avatar/avatar.component.mjs +145 -142
- package/esm2020/elements/lib/button/button.component.mjs +61 -61
- package/esm2020/elements/lib/checkbox/checkbox.component.mjs +73 -73
- package/esm2020/elements/lib/date-picker/date-picker.component.mjs +304 -304
- package/esm2020/elements/lib/directives/addon.directive.mjs +29 -29
- package/esm2020/elements/lib/directives/autosize.directive.mjs +72 -72
- package/esm2020/elements/lib/directives/focus-trap.directive.mjs +77 -77
- package/esm2020/elements/lib/directives/focus.directive.mjs +39 -39
- package/esm2020/elements/lib/directives/form-submit.directive.mjs +50 -50
- package/esm2020/elements/lib/directives/input.directive.mjs +136 -136
- package/esm2020/elements/lib/directives/template.directive.mjs +28 -28
- package/esm2020/elements/lib/dropdown/dropdown.component.mjs +100 -100
- package/esm2020/elements/lib/elements.interfaces.mjs +4 -4
- package/esm2020/elements/lib/elements.module.mjs +177 -177
- package/esm2020/elements/lib/file-picker/file-picker.component.mjs +236 -236
- package/esm2020/elements/lib/form-control/form-control.component.mjs +49 -49
- package/esm2020/elements/lib/form-error/form-error.component.mjs +108 -108
- package/esm2020/elements/lib/form-group/form-group.component.mjs +18 -18
- package/esm2020/elements/lib/icon/icon.component.mjs +102 -102
- package/esm2020/elements/lib/image-picker/image-picker.component.mjs +106 -106
- package/esm2020/elements/lib/pipes/file-image.pipe.mjs +42 -42
- package/esm2020/elements/lib/pipes/file-size.pipe.mjs +28 -28
- package/esm2020/elements/lib/pipes/relative-time.pipe.mjs +94 -94
- package/esm2020/elements/lib/spinner/spinner.component.mjs +25 -25
- package/esm2020/elements/lib/tag/tag.component.mjs +18 -18
- package/esm2020/elements/public_api.mjs +26 -26
- package/esm2020/http/bravobit-bb-foundation-http.mjs +4 -4
- package/esm2020/http/lib/classes/http.config.mjs +29 -29
- package/esm2020/http/lib/classes/http.error.mjs +20 -20
- package/esm2020/http/lib/http.interfaces.mjs +2 -2
- package/esm2020/http/lib/http.module.mjs +43 -43
- package/esm2020/http/lib/interceptors/base-url.interceptor.mjs +50 -50
- package/esm2020/http/lib/interceptors/error.interceptor.mjs +32 -32
- package/esm2020/http/public_api.mjs +7 -7
- package/esm2020/lib/core/miscellaneous/regex.mjs +5 -5
- package/esm2020/lib/core/miscellaneous/validator.mjs +85 -85
- package/esm2020/lib/core/mixins/can-disable.mjs +16 -16
- package/esm2020/lib/core/mixins/can-hide-errors.mjs +16 -16
- package/esm2020/lib/core/mixins/can-load.mjs +16 -16
- package/esm2020/lib/core/mixins/constructor.mjs +2 -2
- package/esm2020/lib/core/mixins/has-error.mjs +16 -16
- package/esm2020/lib/core/mixins/is-focused.mjs +16 -16
- package/esm2020/lib/core/mixins/is-grouped.mjs +16 -16
- package/esm2020/lib/core/mixins/is-readonly.mjs +16 -16
- package/esm2020/lib/core/mixins/is-required.mjs +16 -16
- package/esm2020/lib/core/services/clipboard.service.mjs +70 -70
- package/esm2020/lib/core/services/exif.service.mjs +163 -163
- package/esm2020/lib/core/services/file-loader.service.mjs +87 -87
- package/esm2020/lib/core/services/image-converter.service.mjs +123 -123
- package/esm2020/lib/core/services/languages.service.mjs +74 -74
- package/esm2020/lib/core/services/network.service.mjs +55 -55
- package/esm2020/lib/core/services/patch.service.mjs +63 -63
- package/esm2020/lib/core/services/platform.service.mjs +42 -42
- package/esm2020/lib/core/tokens/accept-language.token.mjs +3 -3
- package/esm2020/lib/core/tokens/base-url.token.mjs +3 -3
- package/esm2020/lib/core/tokens/cookie.token.mjs +3 -3
- package/esm2020/lib/core/tokens/location.token.mjs +6 -6
- package/esm2020/lib/core/tokens/navigator.token.mjs +6 -6
- package/esm2020/lib/core/tokens/window.token.mjs +12 -12
- package/esm2020/localize/bravobit-bb-foundation-localize.mjs +4 -4
- package/esm2020/localize/lib/functions/date.function.mjs +18 -18
- package/esm2020/localize/lib/functions/lowercase.function.mjs +13 -13
- package/esm2020/localize/lib/functions/uppercase.function.mjs +13 -13
- package/esm2020/localize/lib/handlers/missing.handler.mjs +15 -17
- package/esm2020/localize/lib/interfaces/config.interfaces.mjs +7 -10
- package/esm2020/localize/lib/interfaces/functions.interfaces.mjs +8 -8
- package/esm2020/localize/lib/interfaces/handlers.interfaces.mjs +2 -2
- package/esm2020/localize/lib/interfaces/options.interfaces.mjs +6 -6
- package/esm2020/localize/lib/localizations/dutch.localization.mjs +45 -53
- package/esm2020/localize/lib/localizations/english.localization.mjs +45 -53
- package/esm2020/localize/lib/localize.dictionary.mjs +26 -135
- package/esm2020/localize/lib/localize.module.mjs +71 -69
- package/esm2020/localize/lib/localize.pipe.mjs +49 -49
- package/esm2020/localize/lib/localize.service.mjs +205 -277
- package/esm2020/localize/lib/views/localize-string/localize-string.component.mjs +88 -88
- package/esm2020/localize/lib/views/localize-template-or-string.directive.mjs +28 -28
- package/esm2020/localize/lib/views/localize-template.directive.mjs +21 -21
- package/esm2020/localize/public_api.mjs +17 -18
- package/esm2020/notifications/bravobit-bb-foundation-notifications.mjs +4 -4
- package/esm2020/notifications/lib/notifications-item/notifications-item.component.mjs +100 -100
- package/esm2020/notifications/lib/notifications-list/notifications-list.component.mjs +47 -47
- package/esm2020/notifications/lib/notifications.animations.mjs +28 -28
- package/esm2020/notifications/lib/notifications.injector.mjs +18 -18
- package/esm2020/notifications/lib/notifications.interfaces.mjs +20 -20
- package/esm2020/notifications/lib/notifications.module.mjs +30 -30
- package/esm2020/notifications/lib/notifications.service.mjs +145 -145
- package/esm2020/notifications/public_api.mjs +4 -4
- package/esm2020/public_api.mjs +29 -29
- package/esm2020/recaptcha/bravobit-bb-foundation-recaptcha.mjs +4 -4
- package/esm2020/recaptcha/lib/recaptcha/recaptcha.component.mjs +185 -185
- package/esm2020/recaptcha/lib/recaptcha-loader.service.mjs +90 -90
- package/esm2020/recaptcha/lib/recaptcha.interface.mjs +3 -3
- package/esm2020/recaptcha/lib/recaptcha.module.mjs +27 -27
- package/esm2020/recaptcha/public_api.mjs +5 -5
- package/esm2020/rxjs/bravobit-bb-foundation-rxjs.mjs +4 -4
- package/esm2020/rxjs/lib/operators/combine-latest-map.operator.mjs +10 -10
- package/esm2020/rxjs/lib/operators/filter-nil.operator.mjs +5 -5
- package/esm2020/rxjs/public_api.mjs +3 -3
- package/esm2020/storage/bravobit-bb-foundation-storage.mjs +4 -4
- package/esm2020/storage/lib/interfaces/attributes.interface.mjs +2 -2
- package/esm2020/storage/lib/interfaces/memory.interface.mjs +2 -2
- package/esm2020/storage/lib/interfaces/strategy.interface.mjs +2 -2
- package/esm2020/storage/lib/storage.service.mjs +109 -109
- package/esm2020/storage/lib/strategies/cookie-storage.strategy.mjs +142 -142
- package/esm2020/storage/lib/strategies/memory-storage.strategy.mjs +56 -56
- package/esm2020/storage/lib/strategies/polyfill-storage.strategy.mjs +102 -102
- package/esm2020/storage/public_api.mjs +8 -8
- package/esm2020/table/bravobit-bb-foundation-table.mjs +4 -4
- package/esm2020/table/lib/components/table/table.component.mjs +191 -191
- package/esm2020/table/lib/components/table-cell/table-cell.component.mjs +11 -11
- package/esm2020/table/lib/components/table-header-cell/table-header-cell.component.mjs +131 -131
- package/esm2020/table/lib/components/table-pager/table-pager.component.mjs +136 -136
- package/esm2020/table/lib/data/datasource.data.mjs +32 -32
- package/esm2020/table/lib/data/generic.data.mjs +72 -72
- package/esm2020/table/lib/interfaces/datasource.interface.mjs +2 -2
- package/esm2020/table/lib/interfaces/table.interfaces.mjs +2 -2
- package/esm2020/table/lib/table.module.mjs +42 -42
- package/esm2020/table/public_api.mjs +10 -10
- package/fesm2015/bravobit-bb-foundation-auth.mjs +930 -926
- package/fesm2015/bravobit-bb-foundation-auth.mjs.map +1 -1
- package/fesm2015/bravobit-bb-foundation-collections.mjs +423 -423
- package/fesm2015/bravobit-bb-foundation-collections.mjs.map +1 -1
- package/fesm2015/bravobit-bb-foundation-controls.mjs +216 -216
- package/fesm2015/bravobit-bb-foundation-controls.mjs.map +1 -1
- package/fesm2015/bravobit-bb-foundation-dashboard.mjs +382 -382
- package/fesm2015/bravobit-bb-foundation-dashboard.mjs.map +1 -1
- package/fesm2015/bravobit-bb-foundation-dialog.mjs +542 -542
- package/fesm2015/bravobit-bb-foundation-dialog.mjs.map +1 -1
- package/fesm2015/bravobit-bb-foundation-elements.mjs +1971 -1968
- package/fesm2015/bravobit-bb-foundation-elements.mjs.map +1 -1
- package/fesm2015/bravobit-bb-foundation-http.mjs +156 -156
- package/fesm2015/bravobit-bb-foundation-http.mjs.map +1 -1
- package/fesm2015/bravobit-bb-foundation-localize.mjs +611 -805
- package/fesm2015/bravobit-bb-foundation-localize.mjs.map +1 -1
- package/fesm2015/bravobit-bb-foundation-notifications.mjs +348 -348
- package/fesm2015/bravobit-bb-foundation-notifications.mjs.map +1 -1
- package/fesm2015/bravobit-bb-foundation-recaptcha.mjs +290 -290
- package/fesm2015/bravobit-bb-foundation-recaptcha.mjs.map +1 -1
- package/fesm2015/bravobit-bb-foundation-rxjs.mjs +7 -7
- package/fesm2015/bravobit-bb-foundation-rxjs.mjs.map +1 -1
- package/fesm2015/bravobit-bb-foundation-storage.mjs +401 -401
- package/fesm2015/bravobit-bb-foundation-storage.mjs.map +1 -1
- package/fesm2015/bravobit-bb-foundation-table.mjs +571 -571
- package/fesm2015/bravobit-bb-foundation-table.mjs.map +1 -1
- package/fesm2015/bravobit-bb-foundation.mjs +860 -860
- package/fesm2015/bravobit-bb-foundation.mjs.map +1 -1
- package/fesm2020/bravobit-bb-foundation-auth.mjs +882 -878
- package/fesm2020/bravobit-bb-foundation-auth.mjs.map +1 -1
- package/fesm2020/bravobit-bb-foundation-collections.mjs +413 -413
- package/fesm2020/bravobit-bb-foundation-collections.mjs.map +1 -1
- package/fesm2020/bravobit-bb-foundation-controls.mjs +214 -214
- package/fesm2020/bravobit-bb-foundation-controls.mjs.map +1 -1
- package/fesm2020/bravobit-bb-foundation-dashboard.mjs +370 -370
- package/fesm2020/bravobit-bb-foundation-dashboard.mjs.map +1 -1
- package/fesm2020/bravobit-bb-foundation-dialog.mjs +541 -541
- package/fesm2020/bravobit-bb-foundation-dialog.mjs.map +1 -1
- package/fesm2020/bravobit-bb-foundation-elements.mjs +1928 -1925
- package/fesm2020/bravobit-bb-foundation-elements.mjs.map +1 -1
- package/fesm2020/bravobit-bb-foundation-http.mjs +148 -148
- package/fesm2020/bravobit-bb-foundation-http.mjs.map +1 -1
- package/fesm2020/bravobit-bb-foundation-localize.mjs +590 -792
- package/fesm2020/bravobit-bb-foundation-localize.mjs.map +1 -1
- package/fesm2020/bravobit-bb-foundation-notifications.mjs +346 -346
- package/fesm2020/bravobit-bb-foundation-notifications.mjs.map +1 -1
- package/fesm2020/bravobit-bb-foundation-recaptcha.mjs +280 -280
- package/fesm2020/bravobit-bb-foundation-recaptcha.mjs.map +1 -1
- package/fesm2020/bravobit-bb-foundation-rxjs.mjs +10 -10
- package/fesm2020/bravobit-bb-foundation-rxjs.mjs.map +1 -1
- package/fesm2020/bravobit-bb-foundation-storage.mjs +396 -396
- package/fesm2020/bravobit-bb-foundation-storage.mjs.map +1 -1
- package/fesm2020/bravobit-bb-foundation-table.mjs +560 -560
- package/fesm2020/bravobit-bb-foundation-table.mjs.map +1 -1
- package/fesm2020/bravobit-bb-foundation.mjs +832 -832
- package/fesm2020/bravobit-bb-foundation.mjs.map +1 -1
- package/http/bravobit-bb-foundation-http.d.ts +5 -5
- package/http/lib/classes/http.config.d.ts +9 -9
- package/http/lib/classes/http.error.d.ts +7 -7
- package/http/lib/http.interfaces.d.ts +12 -12
- package/http/lib/http.module.d.ts +15 -15
- package/http/lib/interceptors/base-url.interceptor.d.ts +15 -15
- package/http/lib/interceptors/error.interceptor.d.ts +11 -11
- package/http/public_api.d.ts +6 -6
- package/lib/core/miscellaneous/regex.d.ts +4 -4
- package/lib/core/miscellaneous/validator.d.ts +13 -13
- package/lib/core/mixins/can-disable.d.ts +6 -6
- package/lib/core/mixins/can-hide-errors.d.ts +6 -6
- package/lib/core/mixins/can-load.d.ts +6 -6
- package/lib/core/mixins/constructor.d.ts +1 -1
- package/lib/core/mixins/has-error.d.ts +6 -6
- package/lib/core/mixins/is-focused.d.ts +6 -6
- package/lib/core/mixins/is-grouped.d.ts +6 -6
- package/lib/core/mixins/is-readonly.d.ts +6 -6
- package/lib/core/mixins/is-required.d.ts +6 -6
- package/lib/core/services/clipboard.service.d.ts +18 -18
- package/lib/core/services/exif.service.d.ts +15 -15
- package/lib/core/services/file-loader.service.d.ts +13 -13
- package/lib/core/services/image-converter.service.d.ts +21 -21
- package/lib/core/services/languages.service.d.ts +16 -16
- package/lib/core/services/network.service.d.ts +14 -14
- package/lib/core/services/patch.service.d.ts +16 -16
- package/lib/core/services/platform.service.d.ts +18 -18
- package/lib/core/tokens/accept-language.token.d.ts +2 -2
- package/lib/core/tokens/base-url.token.d.ts +2 -2
- package/lib/core/tokens/cookie.token.d.ts +2 -2
- package/lib/core/tokens/location.token.d.ts +2 -2
- package/lib/core/tokens/navigator.token.d.ts +2 -2
- package/lib/core/tokens/window.token.d.ts +2 -2
- package/localize/bravobit-bb-foundation-localize.d.ts +5 -5
- package/localize/lib/functions/date.function.d.ts +5 -5
- package/localize/lib/functions/lowercase.function.d.ts +5 -5
- package/localize/lib/functions/uppercase.function.d.ts +5 -5
- package/localize/lib/handlers/missing.handler.d.ts +6 -6
- package/localize/lib/interfaces/config.interfaces.d.ts +18 -8
- package/localize/lib/interfaces/functions.interfaces.d.ts +9 -9
- package/localize/lib/interfaces/handlers.interfaces.d.ts +6 -6
- package/localize/lib/interfaces/options.interfaces.d.ts +10 -10
- package/localize/lib/localizations/dutch.localization.d.ts +44 -51
- package/localize/lib/localizations/english.localization.d.ts +44 -51
- package/localize/lib/localize.dictionary.d.ts +7 -24
- package/localize/lib/localize.module.d.ts +17 -18
- package/localize/lib/localize.pipe.d.ts +12 -12
- package/localize/lib/localize.service.d.ts +40 -51
- package/localize/lib/views/localize-string/localize-string.component.d.ts +23 -23
- package/localize/lib/views/localize-template-or-string.directive.d.ts +10 -10
- package/localize/lib/views/localize-template.directive.d.ts +9 -9
- package/localize/public_api.d.ts +16 -17
- package/notifications/bravobit-bb-foundation-notifications.d.ts +5 -5
- package/notifications/lib/notifications-item/notifications-item.component.d.ts +34 -34
- package/notifications/lib/notifications-list/notifications-list.component.d.ts +16 -16
- package/notifications/lib/notifications.animations.d.ts +1 -1
- package/notifications/lib/notifications.injector.d.ts +8 -8
- package/notifications/lib/notifications.interfaces.d.ts +49 -49
- package/notifications/lib/notifications.module.d.ts +13 -13
- package/notifications/lib/notifications.service.d.ts +34 -34
- package/notifications/public_api.d.ts +3 -3
- package/package.json +6 -6
- package/public_api.d.ts +25 -25
- package/recaptcha/bravobit-bb-foundation-recaptcha.d.ts +5 -5
- package/recaptcha/lib/recaptcha/recaptcha.component.d.ts +47 -47
- package/recaptcha/lib/recaptcha-loader.service.d.ts +22 -22
- package/recaptcha/lib/recaptcha.interface.d.ts +14 -14
- package/recaptcha/lib/recaptcha.module.d.ts +10 -10
- package/recaptcha/public_api.d.ts +4 -4
- package/rxjs/bravobit-bb-foundation-rxjs.d.ts +5 -5
- package/rxjs/lib/operators/combine-latest-map.operator.d.ts +8 -8
- package/rxjs/lib/operators/filter-nil.operator.d.ts +1 -1
- package/rxjs/public_api.d.ts +2 -2
- package/storage/bravobit-bb-foundation-storage.d.ts +5 -5
- package/storage/lib/interfaces/attributes.interface.d.ts +13 -13
- package/storage/lib/interfaces/memory.interface.d.ts +7 -7
- package/storage/lib/interfaces/strategy.interface.d.ts +17 -17
- package/storage/lib/storage.service.d.ts +26 -26
- package/storage/lib/strategies/cookie-storage.strategy.d.ts +20 -20
- package/storage/lib/strategies/memory-storage.strategy.d.ts +11 -11
- package/storage/lib/strategies/polyfill-storage.strategy.d.ts +15 -15
- package/storage/public_api.d.ts +7 -7
- package/table/bravobit-bb-foundation-table.d.ts +5 -5
- package/table/lib/components/table/table.component.d.ts +56 -56
- package/table/lib/components/table-cell/table-cell.component.d.ts +5 -5
- package/table/lib/components/table-header-cell/table-header-cell.component.d.ts +29 -29
- package/table/lib/components/table-pager/table-pager.component.d.ts +41 -41
- package/table/lib/data/datasource.data.d.ts +14 -14
- package/table/lib/data/generic.data.d.ts +23 -23
- package/table/lib/interfaces/datasource.interface.d.ts +17 -17
- package/table/lib/interfaces/table.interfaces.d.ts +1 -1
- package/table/lib/table.module.d.ts +14 -14
- package/table/public_api.d.ts +9 -9
- package/esm2020/localize/lib/interfaces/dictionary.interfaces.mjs +0 -8
- package/localize/lib/interfaces/dictionary.interfaces.d.ts +0 -12
|
@@ -12,580 +12,580 @@ import { CommonModule } from '@angular/common';
|
|
|
12
12
|
import * as i5 from '@bravobit/bb-foundation/localize';
|
|
13
13
|
import { LocalizeModule } from '@bravobit/bb-foundation/localize';
|
|
14
14
|
|
|
15
|
-
class DataSourceRequest {
|
|
16
|
-
constructor() {
|
|
17
|
-
// Data.
|
|
18
|
-
this._request$ = new BehaviorSubject(null);
|
|
19
|
-
this._loading$ = new BehaviorSubject(true);
|
|
20
|
-
}
|
|
21
|
-
get loading() {
|
|
22
|
-
return this._loading$.asObservable();
|
|
23
|
-
}
|
|
24
|
-
get when() {
|
|
25
|
-
return this._request$.pipe(filter(data => !!data));
|
|
26
|
-
}
|
|
27
|
-
startLoading() {
|
|
28
|
-
this._loading$.next(true);
|
|
29
|
-
}
|
|
30
|
-
stopLoading() {
|
|
31
|
-
this._loading$.next(false);
|
|
32
|
-
}
|
|
33
|
-
update(params = {}) {
|
|
34
|
-
const currentValue = this._request$.getValue();
|
|
35
|
-
// Set the page number to 1 if the query or page size was changed.
|
|
36
|
-
if (currentValue && params && (currentValue?.query !== params?.query || currentValue?.pageSize !== params?.pageSize)) {
|
|
37
|
-
params.pageNumber = 1;
|
|
38
|
-
}
|
|
39
|
-
this._request$.next({ ...currentValue, ...params });
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
class DataSource {
|
|
15
|
+
class DataSourceRequest {
|
|
16
|
+
constructor() {
|
|
17
|
+
// Data.
|
|
18
|
+
this._request$ = new BehaviorSubject(null);
|
|
19
|
+
this._loading$ = new BehaviorSubject(true);
|
|
20
|
+
}
|
|
21
|
+
get loading() {
|
|
22
|
+
return this._loading$.asObservable();
|
|
23
|
+
}
|
|
24
|
+
get when() {
|
|
25
|
+
return this._request$.pipe(filter(data => !!data));
|
|
26
|
+
}
|
|
27
|
+
startLoading() {
|
|
28
|
+
this._loading$.next(true);
|
|
29
|
+
}
|
|
30
|
+
stopLoading() {
|
|
31
|
+
this._loading$.next(false);
|
|
32
|
+
}
|
|
33
|
+
update(params = {}) {
|
|
34
|
+
const currentValue = this._request$.getValue();
|
|
35
|
+
// Set the page number to 1 if the query or page size was changed.
|
|
36
|
+
if (currentValue && params && (currentValue?.query !== params?.query || currentValue?.pageSize !== params?.pageSize)) {
|
|
37
|
+
params.pageNumber = 1;
|
|
38
|
+
}
|
|
39
|
+
this._request$.next({ ...currentValue, ...params });
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
class DataSource {
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
class GenericDataSource extends DataSource {
|
|
46
|
-
constructor(httpClient, endpoint) {
|
|
47
|
-
super();
|
|
48
|
-
// Data.
|
|
49
|
-
this._items$ = new BehaviorSubject([]);
|
|
50
|
-
this._fn = data => data;
|
|
51
|
-
this.formatResponse = (data) => {
|
|
52
|
-
return {
|
|
53
|
-
pageSize: data?.['page_size'],
|
|
54
|
-
pageNumber: data?.['page_number'],
|
|
55
|
-
totalPages: data?.['total_pages'],
|
|
56
|
-
totalEntries: data?.['total_entries'],
|
|
57
|
-
data: data?.['data']
|
|
58
|
-
};
|
|
59
|
-
};
|
|
60
|
-
this.formatParams = (data) => {
|
|
61
|
-
const params = {};
|
|
62
|
-
params['page'] = `${data?.pageNumber ?? 1}`;
|
|
63
|
-
params['page_size'] = `${data?.pageSize ?? 25}`;
|
|
64
|
-
const sort = (data?.sort ?? [])
|
|
65
|
-
.map(({ name }) => name)
|
|
66
|
-
.filter(name => !!name)
|
|
67
|
-
.join(',');
|
|
68
|
-
const sortDirection = (data?.sort ?? [])
|
|
69
|
-
.map(({ direction }) => direction)
|
|
70
|
-
.filter(direction => !!direction)
|
|
71
|
-
.join(',');
|
|
72
|
-
if (sort?.length > 0 && sortDirection?.length > 0) {
|
|
73
|
-
params['sort'] = sort;
|
|
74
|
-
params['sort_direction'] = sortDirection;
|
|
75
|
-
}
|
|
76
|
-
if (data?.query && data?.query?.length > 0 && data?.queryFields && data?.queryFields?.length > 0) {
|
|
77
|
-
params['query'] = data?.query;
|
|
78
|
-
params['query_fields'] = data?.queryFields?.join(',');
|
|
79
|
-
}
|
|
80
|
-
return params;
|
|
81
|
-
};
|
|
82
|
-
this._httpClient = httpClient;
|
|
83
|
-
this._endpoint$ = typeof endpoint === 'string'
|
|
84
|
-
? of(endpoint)
|
|
85
|
-
: endpoint;
|
|
86
|
-
}
|
|
87
|
-
append(item) {
|
|
88
|
-
const currentValue = this._items$.getValue();
|
|
89
|
-
const newValue = [...currentValue, item];
|
|
90
|
-
this._items$.next(newValue);
|
|
91
|
-
return this;
|
|
92
|
-
}
|
|
93
|
-
data(fn) {
|
|
94
|
-
this._fn = fn;
|
|
95
|
-
return this;
|
|
96
|
-
}
|
|
97
|
-
handle(request) {
|
|
98
|
-
const extraParams$ = this._items$.pipe(switchMap(items => items?.length <= 0 ? of([]) : combineLatest(items)), map(items => items.reduce((previous, current) => ({ ...previous, ...(current ?? {}) }), {})));
|
|
99
|
-
return combineLatest([request.when, this._endpoint$, extraParams$]).pipe(switchMap(([params, endpoint, extraParams]) => {
|
|
100
|
-
// Start the loading.
|
|
101
|
-
request.startLoading();
|
|
102
|
-
const formattedParams = this.formatParams(params);
|
|
103
|
-
const combinedParams = { ...formattedParams, ...extraParams };
|
|
104
|
-
return this._httpClient.get(endpoint, {
|
|
105
|
-
params: combinedParams
|
|
106
|
-
}).pipe(map(data => this.formatResponse(data)), map(result => ({
|
|
107
|
-
...result,
|
|
108
|
-
data: this._fn(result?.data ?? [])
|
|
109
|
-
})));
|
|
110
|
-
}), share());
|
|
111
|
-
}
|
|
45
|
+
class GenericDataSource extends DataSource {
|
|
46
|
+
constructor(httpClient, endpoint) {
|
|
47
|
+
super();
|
|
48
|
+
// Data.
|
|
49
|
+
this._items$ = new BehaviorSubject([]);
|
|
50
|
+
this._fn = data => data;
|
|
51
|
+
this.formatResponse = (data) => {
|
|
52
|
+
return {
|
|
53
|
+
pageSize: data?.['page_size'],
|
|
54
|
+
pageNumber: data?.['page_number'],
|
|
55
|
+
totalPages: data?.['total_pages'],
|
|
56
|
+
totalEntries: data?.['total_entries'],
|
|
57
|
+
data: data?.['data']
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
this.formatParams = (data) => {
|
|
61
|
+
const params = {};
|
|
62
|
+
params['page'] = `${data?.pageNumber ?? 1}`;
|
|
63
|
+
params['page_size'] = `${data?.pageSize ?? 25}`;
|
|
64
|
+
const sort = (data?.sort ?? [])
|
|
65
|
+
.map(({ name }) => name)
|
|
66
|
+
.filter(name => !!name)
|
|
67
|
+
.join(',');
|
|
68
|
+
const sortDirection = (data?.sort ?? [])
|
|
69
|
+
.map(({ direction }) => direction)
|
|
70
|
+
.filter(direction => !!direction)
|
|
71
|
+
.join(',');
|
|
72
|
+
if (sort?.length > 0 && sortDirection?.length > 0) {
|
|
73
|
+
params['sort'] = sort;
|
|
74
|
+
params['sort_direction'] = sortDirection;
|
|
75
|
+
}
|
|
76
|
+
if (data?.query && data?.query?.length > 0 && data?.queryFields && data?.queryFields?.length > 0) {
|
|
77
|
+
params['query'] = data?.query;
|
|
78
|
+
params['query_fields'] = data?.queryFields?.join(',');
|
|
79
|
+
}
|
|
80
|
+
return params;
|
|
81
|
+
};
|
|
82
|
+
this._httpClient = httpClient;
|
|
83
|
+
this._endpoint$ = typeof endpoint === 'string'
|
|
84
|
+
? of(endpoint)
|
|
85
|
+
: endpoint;
|
|
86
|
+
}
|
|
87
|
+
append(item) {
|
|
88
|
+
const currentValue = this._items$.getValue();
|
|
89
|
+
const newValue = [...currentValue, item];
|
|
90
|
+
this._items$.next(newValue);
|
|
91
|
+
return this;
|
|
92
|
+
}
|
|
93
|
+
data(fn) {
|
|
94
|
+
this._fn = fn;
|
|
95
|
+
return this;
|
|
96
|
+
}
|
|
97
|
+
handle(request) {
|
|
98
|
+
const extraParams$ = this._items$.pipe(switchMap(items => items?.length <= 0 ? of([]) : combineLatest(items)), map(items => items.reduce((previous, current) => ({ ...previous, ...(current ?? {}) }), {})));
|
|
99
|
+
return combineLatest([request.when, this._endpoint$, extraParams$]).pipe(switchMap(([params, endpoint, extraParams]) => {
|
|
100
|
+
// Start the loading.
|
|
101
|
+
request.startLoading();
|
|
102
|
+
const formattedParams = this.formatParams(params);
|
|
103
|
+
const combinedParams = { ...formattedParams, ...extraParams };
|
|
104
|
+
return this._httpClient.get(endpoint, {
|
|
105
|
+
params: combinedParams
|
|
106
|
+
}).pipe(map(data => this.formatResponse(data)), map(result => ({
|
|
107
|
+
...result,
|
|
108
|
+
data: this._fn(result?.data ?? [])
|
|
109
|
+
})));
|
|
110
|
+
}), share());
|
|
111
|
+
}
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
class BbTablePagerBase {
|
|
115
|
-
}
|
|
116
|
-
const BbTablePagerMixinBase = mixinDisabled(BbTablePagerBase);
|
|
117
|
-
class BbTablePager extends BbTablePagerMixinBase {
|
|
118
|
-
constructor() {
|
|
119
|
-
super(...arguments);
|
|
120
|
-
// Inputs.
|
|
121
|
-
this.amountOfButtons = 5;
|
|
122
|
-
this.showArrowButtons = true;
|
|
123
|
-
// Methods.
|
|
124
|
-
this.onChange = () => ({});
|
|
125
|
-
this.onTouched = () => ({});
|
|
126
|
-
this.trackByIndex = (_, item) => item.page;
|
|
127
|
-
// Data.
|
|
128
|
-
this._totalPages$ = new BehaviorSubject(1);
|
|
129
|
-
this._pageNumber$ = new BehaviorSubject(1);
|
|
130
|
-
}
|
|
131
|
-
ngOnInit() {
|
|
132
|
-
// Validate the previous button is disabled.
|
|
133
|
-
this.isPreviousDisabled$ = this._pageNumber$.pipe(map(pageNumber => pageNumber === 1));
|
|
134
|
-
// Validate the next button is disabled.
|
|
135
|
-
this.isNextDisabled$ = combineLatest([this._pageNumber$, this._totalPages$]).pipe(map(([pageNumber, totalPages]) => pageNumber === totalPages));
|
|
136
|
-
// Create the list with page numbers.
|
|
137
|
-
this.list$ = combineLatest([this._pageNumber$, this._totalPages$]).pipe(map(([pageNumber, totalPages]) => this.filterActivePages(pageNumber, totalPages)), share());
|
|
138
|
-
}
|
|
139
|
-
get pageNumber() {
|
|
140
|
-
return this._pageNumber$.getValue();
|
|
141
|
-
}
|
|
142
|
-
set pageNumber(newValue) {
|
|
143
|
-
this.update(newValue);
|
|
144
|
-
}
|
|
145
|
-
get totalPages() {
|
|
146
|
-
return this._totalPages$.getValue();
|
|
147
|
-
}
|
|
148
|
-
set totalPages(newValue) {
|
|
149
|
-
const newTotalPages = Math.max(1, newValue);
|
|
150
|
-
this._totalPages$.next(newTotalPages);
|
|
151
|
-
}
|
|
152
|
-
registerOnChange(fn) {
|
|
153
|
-
this.onChange = fn;
|
|
154
|
-
}
|
|
155
|
-
registerOnTouched(fn) {
|
|
156
|
-
this.onTouched = fn;
|
|
157
|
-
}
|
|
158
|
-
setDisabledState(isDisabled) {
|
|
159
|
-
this.disabled = isDisabled;
|
|
160
|
-
}
|
|
161
|
-
writeValue(newValue) {
|
|
162
|
-
this.update(newValue, false);
|
|
163
|
-
}
|
|
164
|
-
goToPrevious() {
|
|
165
|
-
const newValue = this._pageNumber$.getValue() - 1;
|
|
166
|
-
return this.update(newValue);
|
|
167
|
-
}
|
|
168
|
-
goToNext() {
|
|
169
|
-
const newValue = this._pageNumber$.getValue() + 1;
|
|
170
|
-
return this.update(newValue);
|
|
171
|
-
}
|
|
172
|
-
goToIndex(index) {
|
|
173
|
-
return this.update(index);
|
|
174
|
-
}
|
|
175
|
-
update(pageNumber, notify = true) {
|
|
176
|
-
// You can only update when not disabled.
|
|
177
|
-
if (this.disabled) {
|
|
178
|
-
return;
|
|
179
|
-
}
|
|
180
|
-
// Calculate the new value.
|
|
181
|
-
const newValue = Math.min(this.totalPages, Math.max(1, pageNumber));
|
|
182
|
-
// Don't do anything if the page number is the same.
|
|
183
|
-
if (this._pageNumber$.getValue() === newValue) {
|
|
184
|
-
return;
|
|
185
|
-
}
|
|
186
|
-
// Push the new value.
|
|
187
|
-
this._pageNumber$.next(newValue);
|
|
188
|
-
if (notify) {
|
|
189
|
-
return this.onChange(pageNumber);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
calculatePages(pageNumber) {
|
|
193
|
-
const min = 1;
|
|
194
|
-
const max = this.totalPages;
|
|
195
|
-
const amount = Math.max(1, this.amountOfButtons);
|
|
196
|
-
const data = Array(amount)
|
|
197
|
-
.fill(0)
|
|
198
|
-
.map((_, index) => pageNumber + (index - 1));
|
|
199
|
-
// Validate if the minimum value less than
|
|
200
|
-
// the first value.
|
|
201
|
-
if (data[0] < min) {
|
|
202
|
-
return data.map(item => item + 1);
|
|
203
|
-
}
|
|
204
|
-
// Calculate the difference with the max
|
|
205
|
-
// if this value is higher than 0 we should minus it.
|
|
206
|
-
const lastValueInArray = data[data.length - 1];
|
|
207
|
-
const differenceWithMax = lastValueInArray - max;
|
|
208
|
-
if (differenceWithMax > 0) {
|
|
209
|
-
return data.map(item => item - differenceWithMax);
|
|
210
|
-
}
|
|
211
|
-
// Just return the default data.
|
|
212
|
-
return data;
|
|
213
|
-
}
|
|
214
|
-
filterActivePages(pageNumber, totalPages) {
|
|
215
|
-
return this.calculatePages(pageNumber)
|
|
216
|
-
.filter(page => page > 0 && page <= totalPages)
|
|
217
|
-
.map(page => ({ page, active: pageNumber === page }));
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
BbTablePager.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.
|
|
221
|
-
BbTablePager.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.
|
|
222
|
-
{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => BbTablePager), multi: true }
|
|
223
|
-
], usesInheritance: true, ngImport: i0, template: "<ul class=\"bb-pager-list\">\n <!-- The previous page arrow button. -->\n <li *ngIf=\"showArrowButtons\"\n class=\"bb-pager-list-item\"\n title=\"Previous page\">\n <button [disabled]=\"isPreviousDisabled$ | async\"\n (click)=\"goToPrevious()\"\n class=\"bb-pager-list-button\"\n type=\"button\">\n <bb-icon src=\"material:keyboard_arrow_left\"></bb-icon>\n </button>\n </li>\n\n <!-- The list of number buttons to navigate through the list. -->\n <ng-container *ngIf=\"list$ | async as list\">\n <li *ngFor=\"let item of list; trackBy: trackByIndex\"\n [title]=\"'Page ' + item?.page\"\n class=\"bb-pager-list-item\">\n <button (click)=\"goToIndex(item?.page)\"\n [class.active]=\"item?.active\"\n class=\"bb-pager-list-button\"\n type=\"button\">\n {{ item?.page }}\n </button>\n </li>\n </ng-container>\n\n <!-- The next page arrow button. -->\n <li *ngIf=\"showArrowButtons\"\n class=\"bb-pager-list-item\"\n title=\"Next page\">\n <button [disabled]=\"isNextDisabled$ | async\"\n (click)=\"goToNext()\"\n class=\"bb-pager-list-button\"\n type=\"button\">\n <bb-icon src=\"material:keyboard_arrow_right\"></bb-icon>\n </button>\n </li>\n</ul>\n", styles: [".bb-table-pager{flex:1;display:flex;align-items:center;justify-content:flex-end}.bb-table-pager.disabled{opacity:.5;-webkit-user-select:none;user-select:none;pointer-events:none}.bb-pager-list{display:flex}.bb-pager-list-item{margin-left:8px}.bb-pager-list-button{padding:0;color:#3d464d;line-height:1;min-width:32px;font-size:16px;-webkit-appearance:none
|
|
224
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.
|
|
225
|
-
type: Component,
|
|
226
|
-
args: [{ selector: 'bb-table-pager', changeDetection: ChangeDetectionStrategy.OnPush, host: {
|
|
227
|
-
'class': 'bb-table-pager',
|
|
228
|
-
'[class.disabled]': 'disabled'
|
|
229
|
-
}, inputs: ['disabled'], encapsulation: ViewEncapsulation.None, preserveWhitespaces: false, providers: [
|
|
230
|
-
{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => BbTablePager), multi: true }
|
|
231
|
-
], template: "<ul class=\"bb-pager-list\">\n <!-- The previous page arrow button. -->\n <li *ngIf=\"showArrowButtons\"\n class=\"bb-pager-list-item\"\n title=\"Previous page\">\n <button [disabled]=\"isPreviousDisabled$ | async\"\n (click)=\"goToPrevious()\"\n class=\"bb-pager-list-button\"\n type=\"button\">\n <bb-icon src=\"material:keyboard_arrow_left\"></bb-icon>\n </button>\n </li>\n\n <!-- The list of number buttons to navigate through the list. -->\n <ng-container *ngIf=\"list$ | async as list\">\n <li *ngFor=\"let item of list; trackBy: trackByIndex\"\n [title]=\"'Page ' + item?.page\"\n class=\"bb-pager-list-item\">\n <button (click)=\"goToIndex(item?.page)\"\n [class.active]=\"item?.active\"\n class=\"bb-pager-list-button\"\n type=\"button\">\n {{ item?.page }}\n </button>\n </li>\n </ng-container>\n\n <!-- The next page arrow button. -->\n <li *ngIf=\"showArrowButtons\"\n class=\"bb-pager-list-item\"\n title=\"Next page\">\n <button [disabled]=\"isNextDisabled$ | async\"\n (click)=\"goToNext()\"\n class=\"bb-pager-list-button\"\n type=\"button\">\n <bb-icon src=\"material:keyboard_arrow_right\"></bb-icon>\n </button>\n </li>\n</ul>\n", styles: [".bb-table-pager{flex:1;display:flex;align-items:center;justify-content:flex-end}.bb-table-pager.disabled{opacity:.5;-webkit-user-select:none;user-select:none;pointer-events:none}.bb-pager-list{display:flex}.bb-pager-list-item{margin-left:8px}.bb-pager-list-button{padding:0;color:#3d464d;line-height:1;min-width:32px;font-size:16px;-webkit-appearance:none
|
|
232
|
-
}], propDecorators: { amountOfButtons: [{
|
|
233
|
-
type: Input
|
|
234
|
-
}], showArrowButtons: [{
|
|
235
|
-
type: Input
|
|
236
|
-
}], pageNumber: [{
|
|
237
|
-
type: Input
|
|
238
|
-
}], totalPages: [{
|
|
239
|
-
type: Input
|
|
114
|
+
class BbTablePagerBase {
|
|
115
|
+
}
|
|
116
|
+
const BbTablePagerMixinBase = mixinDisabled(BbTablePagerBase);
|
|
117
|
+
class BbTablePager extends BbTablePagerMixinBase {
|
|
118
|
+
constructor() {
|
|
119
|
+
super(...arguments);
|
|
120
|
+
// Inputs.
|
|
121
|
+
this.amountOfButtons = 5;
|
|
122
|
+
this.showArrowButtons = true;
|
|
123
|
+
// Methods.
|
|
124
|
+
this.onChange = () => ({});
|
|
125
|
+
this.onTouched = () => ({});
|
|
126
|
+
this.trackByIndex = (_, item) => item.page;
|
|
127
|
+
// Data.
|
|
128
|
+
this._totalPages$ = new BehaviorSubject(1);
|
|
129
|
+
this._pageNumber$ = new BehaviorSubject(1);
|
|
130
|
+
}
|
|
131
|
+
ngOnInit() {
|
|
132
|
+
// Validate the previous button is disabled.
|
|
133
|
+
this.isPreviousDisabled$ = this._pageNumber$.pipe(map(pageNumber => pageNumber === 1));
|
|
134
|
+
// Validate the next button is disabled.
|
|
135
|
+
this.isNextDisabled$ = combineLatest([this._pageNumber$, this._totalPages$]).pipe(map(([pageNumber, totalPages]) => pageNumber === totalPages));
|
|
136
|
+
// Create the list with page numbers.
|
|
137
|
+
this.list$ = combineLatest([this._pageNumber$, this._totalPages$]).pipe(map(([pageNumber, totalPages]) => this.filterActivePages(pageNumber, totalPages)), share());
|
|
138
|
+
}
|
|
139
|
+
get pageNumber() {
|
|
140
|
+
return this._pageNumber$.getValue();
|
|
141
|
+
}
|
|
142
|
+
set pageNumber(newValue) {
|
|
143
|
+
this.update(newValue);
|
|
144
|
+
}
|
|
145
|
+
get totalPages() {
|
|
146
|
+
return this._totalPages$.getValue();
|
|
147
|
+
}
|
|
148
|
+
set totalPages(newValue) {
|
|
149
|
+
const newTotalPages = Math.max(1, newValue);
|
|
150
|
+
this._totalPages$.next(newTotalPages);
|
|
151
|
+
}
|
|
152
|
+
registerOnChange(fn) {
|
|
153
|
+
this.onChange = fn;
|
|
154
|
+
}
|
|
155
|
+
registerOnTouched(fn) {
|
|
156
|
+
this.onTouched = fn;
|
|
157
|
+
}
|
|
158
|
+
setDisabledState(isDisabled) {
|
|
159
|
+
this.disabled = isDisabled;
|
|
160
|
+
}
|
|
161
|
+
writeValue(newValue) {
|
|
162
|
+
this.update(newValue, false);
|
|
163
|
+
}
|
|
164
|
+
goToPrevious() {
|
|
165
|
+
const newValue = this._pageNumber$.getValue() - 1;
|
|
166
|
+
return this.update(newValue);
|
|
167
|
+
}
|
|
168
|
+
goToNext() {
|
|
169
|
+
const newValue = this._pageNumber$.getValue() + 1;
|
|
170
|
+
return this.update(newValue);
|
|
171
|
+
}
|
|
172
|
+
goToIndex(index) {
|
|
173
|
+
return this.update(index);
|
|
174
|
+
}
|
|
175
|
+
update(pageNumber, notify = true) {
|
|
176
|
+
// You can only update when not disabled.
|
|
177
|
+
if (this.disabled) {
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
// Calculate the new value.
|
|
181
|
+
const newValue = Math.min(this.totalPages, Math.max(1, pageNumber));
|
|
182
|
+
// Don't do anything if the page number is the same.
|
|
183
|
+
if (this._pageNumber$.getValue() === newValue) {
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
// Push the new value.
|
|
187
|
+
this._pageNumber$.next(newValue);
|
|
188
|
+
if (notify) {
|
|
189
|
+
return this.onChange(pageNumber);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
calculatePages(pageNumber) {
|
|
193
|
+
const min = 1;
|
|
194
|
+
const max = this.totalPages;
|
|
195
|
+
const amount = Math.max(1, this.amountOfButtons);
|
|
196
|
+
const data = Array(amount)
|
|
197
|
+
.fill(0)
|
|
198
|
+
.map((_, index) => pageNumber + (index - 1));
|
|
199
|
+
// Validate if the minimum value less than
|
|
200
|
+
// the first value.
|
|
201
|
+
if (data[0] < min) {
|
|
202
|
+
return data.map(item => item + 1);
|
|
203
|
+
}
|
|
204
|
+
// Calculate the difference with the max
|
|
205
|
+
// if this value is higher than 0 we should minus it.
|
|
206
|
+
const lastValueInArray = data[data.length - 1];
|
|
207
|
+
const differenceWithMax = lastValueInArray - max;
|
|
208
|
+
if (differenceWithMax > 0) {
|
|
209
|
+
return data.map(item => item - differenceWithMax);
|
|
210
|
+
}
|
|
211
|
+
// Just return the default data.
|
|
212
|
+
return data;
|
|
213
|
+
}
|
|
214
|
+
filterActivePages(pageNumber, totalPages) {
|
|
215
|
+
return this.calculatePages(pageNumber)
|
|
216
|
+
.filter(page => page > 0 && page <= totalPages)
|
|
217
|
+
.map(page => ({ page, active: pageNumber === page }));
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
BbTablePager.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: BbTablePager, deps: null, target: i0.ɵɵFactoryTarget.Component });
|
|
221
|
+
BbTablePager.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.6", type: BbTablePager, selector: "bb-table-pager", inputs: { disabled: "disabled", amountOfButtons: "amountOfButtons", showArrowButtons: "showArrowButtons", pageNumber: "pageNumber", totalPages: "totalPages" }, host: { properties: { "class.disabled": "disabled" }, classAttribute: "bb-table-pager" }, providers: [
|
|
222
|
+
{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => BbTablePager), multi: true }
|
|
223
|
+
], usesInheritance: true, ngImport: i0, template: "<ul class=\"bb-pager-list\">\r\n <!-- The previous page arrow button. -->\r\n <li *ngIf=\"showArrowButtons\"\r\n class=\"bb-pager-list-item\"\r\n title=\"Previous page\">\r\n <button [disabled]=\"isPreviousDisabled$ | async\"\r\n (click)=\"goToPrevious()\"\r\n class=\"bb-pager-list-button\"\r\n type=\"button\">\r\n <bb-icon src=\"material:keyboard_arrow_left\"></bb-icon>\r\n </button>\r\n </li>\r\n\r\n <!-- The list of number buttons to navigate through the list. -->\r\n <ng-container *ngIf=\"list$ | async as list\">\r\n <li *ngFor=\"let item of list; trackBy: trackByIndex\"\r\n [title]=\"'Page ' + item?.page\"\r\n class=\"bb-pager-list-item\">\r\n <button (click)=\"goToIndex(item?.page)\"\r\n [class.active]=\"item?.active\"\r\n class=\"bb-pager-list-button\"\r\n type=\"button\">\r\n {{ item?.page }}\r\n </button>\r\n </li>\r\n </ng-container>\r\n\r\n <!-- The next page arrow button. -->\r\n <li *ngIf=\"showArrowButtons\"\r\n class=\"bb-pager-list-item\"\r\n title=\"Next page\">\r\n <button [disabled]=\"isNextDisabled$ | async\"\r\n (click)=\"goToNext()\"\r\n class=\"bb-pager-list-button\"\r\n type=\"button\">\r\n <bb-icon src=\"material:keyboard_arrow_right\"></bb-icon>\r\n </button>\r\n </li>\r\n</ul>\r\n", styles: [".bb-table-pager{flex:1;display:flex;align-items:center;justify-content:flex-end}.bb-table-pager.disabled{opacity:.5;-webkit-user-select:none;user-select:none;pointer-events:none}.bb-pager-list{display:flex}.bb-pager-list-item{margin-left:8px}.bb-pager-list-button{padding:0;color:#3d464d;line-height:1;min-width:32px;font-size:16px;-webkit-appearance:none;appearance:none;font-weight:500;min-height:32px;-webkit-user-select:none;user-select:none;border-radius:4px;align-items:center;display:inline-flex;justify-content:center;border:1px solid #b6bbc1;transition-duration:.2s;background-color:transparent;transition-timing-function:cubic-bezier(0,0,.2,1);transition-property:color,border-color,opacity,background-color;box-shadow:inset 0 3px #b7bcc233,0 6px 6px -6px #0000001a}.bb-pager-list-button:hover,.bb-pager-list-button:focus{background-color:#0000000a}.bb-pager-list-button.active,.bb-pager-list-button.active:hover{color:#2196f3;cursor:default;border-color:#2196f3;background-color:transparent}.bb-pager-list-button:disabled{opacity:.35;cursor:default;pointer-events:none}\n"], components: [{ type: i1.BbIcon, selector: "bb-icon", inputs: ["alt", "size", "src", "ariaHidden"] }], directives: [{ type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i3.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }], pipes: { "async": i3.AsyncPipe }, changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
224
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: BbTablePager, decorators: [{
|
|
225
|
+
type: Component,
|
|
226
|
+
args: [{ selector: 'bb-table-pager', changeDetection: ChangeDetectionStrategy.OnPush, host: {
|
|
227
|
+
'class': 'bb-table-pager',
|
|
228
|
+
'[class.disabled]': 'disabled'
|
|
229
|
+
}, inputs: ['disabled'], encapsulation: ViewEncapsulation.None, preserveWhitespaces: false, providers: [
|
|
230
|
+
{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => BbTablePager), multi: true }
|
|
231
|
+
], template: "<ul class=\"bb-pager-list\">\r\n <!-- The previous page arrow button. -->\r\n <li *ngIf=\"showArrowButtons\"\r\n class=\"bb-pager-list-item\"\r\n title=\"Previous page\">\r\n <button [disabled]=\"isPreviousDisabled$ | async\"\r\n (click)=\"goToPrevious()\"\r\n class=\"bb-pager-list-button\"\r\n type=\"button\">\r\n <bb-icon src=\"material:keyboard_arrow_left\"></bb-icon>\r\n </button>\r\n </li>\r\n\r\n <!-- The list of number buttons to navigate through the list. -->\r\n <ng-container *ngIf=\"list$ | async as list\">\r\n <li *ngFor=\"let item of list; trackBy: trackByIndex\"\r\n [title]=\"'Page ' + item?.page\"\r\n class=\"bb-pager-list-item\">\r\n <button (click)=\"goToIndex(item?.page)\"\r\n [class.active]=\"item?.active\"\r\n class=\"bb-pager-list-button\"\r\n type=\"button\">\r\n {{ item?.page }}\r\n </button>\r\n </li>\r\n </ng-container>\r\n\r\n <!-- The next page arrow button. -->\r\n <li *ngIf=\"showArrowButtons\"\r\n class=\"bb-pager-list-item\"\r\n title=\"Next page\">\r\n <button [disabled]=\"isNextDisabled$ | async\"\r\n (click)=\"goToNext()\"\r\n class=\"bb-pager-list-button\"\r\n type=\"button\">\r\n <bb-icon src=\"material:keyboard_arrow_right\"></bb-icon>\r\n </button>\r\n </li>\r\n</ul>\r\n", styles: [".bb-table-pager{flex:1;display:flex;align-items:center;justify-content:flex-end}.bb-table-pager.disabled{opacity:.5;-webkit-user-select:none;user-select:none;pointer-events:none}.bb-pager-list{display:flex}.bb-pager-list-item{margin-left:8px}.bb-pager-list-button{padding:0;color:#3d464d;line-height:1;min-width:32px;font-size:16px;-webkit-appearance:none;appearance:none;font-weight:500;min-height:32px;-webkit-user-select:none;user-select:none;border-radius:4px;align-items:center;display:inline-flex;justify-content:center;border:1px solid #b6bbc1;transition-duration:.2s;background-color:transparent;transition-timing-function:cubic-bezier(0,0,.2,1);transition-property:color,border-color,opacity,background-color;box-shadow:inset 0 3px #b7bcc233,0 6px 6px -6px #0000001a}.bb-pager-list-button:hover,.bb-pager-list-button:focus{background-color:#0000000a}.bb-pager-list-button.active,.bb-pager-list-button.active:hover{color:#2196f3;cursor:default;border-color:#2196f3;background-color:transparent}.bb-pager-list-button:disabled{opacity:.35;cursor:default;pointer-events:none}\n"] }]
|
|
232
|
+
}], propDecorators: { amountOfButtons: [{
|
|
233
|
+
type: Input
|
|
234
|
+
}], showArrowButtons: [{
|
|
235
|
+
type: Input
|
|
236
|
+
}], pageNumber: [{
|
|
237
|
+
type: Input
|
|
238
|
+
}], totalPages: [{
|
|
239
|
+
type: Input
|
|
240
240
|
}] } });
|
|
241
241
|
|
|
242
|
-
class BbTableColumnDef {
|
|
243
|
-
}
|
|
244
|
-
BbTableColumnDef.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.
|
|
245
|
-
BbTableColumnDef.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.
|
|
246
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.
|
|
247
|
-
type: Directive,
|
|
248
|
-
args: [{
|
|
249
|
-
selector: '[bbTableColumnDef]'
|
|
250
|
-
}]
|
|
251
|
-
}] });
|
|
252
|
-
class BbTableRowDef {
|
|
253
|
-
}
|
|
254
|
-
BbTableRowDef.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.
|
|
255
|
-
BbTableRowDef.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.
|
|
256
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.
|
|
257
|
-
type: Directive,
|
|
258
|
-
args: [{
|
|
259
|
-
selector: '[bbTableRowDef]'
|
|
260
|
-
}]
|
|
261
|
-
}] });
|
|
262
|
-
class BbTable {
|
|
263
|
-
constructor() {
|
|
264
|
-
// Inputs.
|
|
265
|
-
this.identifier = null;
|
|
266
|
-
this.queryFields = [];
|
|
267
|
-
this.sortingStrategy = 'single';
|
|
268
|
-
this.header = true;
|
|
269
|
-
this.footer = true;
|
|
270
|
-
// Sizes.
|
|
271
|
-
this._sizes = [25, 50, 75, 100];
|
|
272
|
-
// Optimizations.
|
|
273
|
-
this.trackByFn = (index, item) => this.identifier ? item[this.identifier] : index;
|
|
274
|
-
this.trackByValue = (_, item) => item;
|
|
275
|
-
this.queryControl = new FormControl('');
|
|
276
|
-
// State.
|
|
277
|
-
this._headerCount = 0;
|
|
278
|
-
}
|
|
279
|
-
get sizes() {
|
|
280
|
-
return this._sizes;
|
|
281
|
-
}
|
|
282
|
-
set sizes(newValue) {
|
|
283
|
-
this.updateSizes(newValue);
|
|
284
|
-
}
|
|
285
|
-
ngOnInit() {
|
|
286
|
-
this.composeForm();
|
|
287
|
-
this.watchDataChanges();
|
|
288
|
-
}
|
|
289
|
-
ngOnDestroy() {
|
|
290
|
-
this._subscription?.unsubscribe();
|
|
291
|
-
}
|
|
292
|
-
get headerCount() {
|
|
293
|
-
return this._headerCount;
|
|
294
|
-
}
|
|
295
|
-
get sortControl() {
|
|
296
|
-
return this.form?.get('sort');
|
|
297
|
-
}
|
|
298
|
-
get pageNumberControl() {
|
|
299
|
-
return this.form?.get('pageNumber');
|
|
300
|
-
}
|
|
301
|
-
get pageSizeControl() {
|
|
302
|
-
return this.form?.get('pageSize');
|
|
303
|
-
}
|
|
304
|
-
refresh() {
|
|
305
|
-
return this.request.update();
|
|
306
|
-
}
|
|
307
|
-
setHeaderCount(amount) {
|
|
308
|
-
this._headerCount += amount;
|
|
309
|
-
}
|
|
310
|
-
updateSizes(newValue) {
|
|
311
|
-
// Validate the sizes has at least one value.
|
|
312
|
-
if (newValue.length <= 0) {
|
|
313
|
-
throw new Error('Cannot set an empty array as the sizes.');
|
|
314
|
-
}
|
|
315
|
-
// Set the new size.
|
|
316
|
-
this._sizes = newValue;
|
|
317
|
-
// Validate that the form exists already.
|
|
318
|
-
if (!this.form) {
|
|
319
|
-
return;
|
|
320
|
-
}
|
|
321
|
-
// Check if the current selected value is
|
|
322
|
-
// in the new sizes array.
|
|
323
|
-
const pageSizeControl = this.form.get('pageSize');
|
|
324
|
-
if (this._sizes.includes(pageSizeControl.value)) {
|
|
325
|
-
return;
|
|
326
|
-
}
|
|
327
|
-
// Set the first value in the array as
|
|
328
|
-
// the new value.
|
|
329
|
-
const firstValue = this._sizes[0];
|
|
330
|
-
pageSizeControl.setValue(firstValue);
|
|
331
|
-
}
|
|
332
|
-
composeForm() {
|
|
333
|
-
// Setup the form.
|
|
334
|
-
this.form = new FormGroup({
|
|
335
|
-
pageSize: new FormControl(this._sizes[0]),
|
|
336
|
-
pageNumber: new FormControl(1),
|
|
337
|
-
sort: new FormGroup({})
|
|
338
|
-
});
|
|
339
|
-
}
|
|
340
|
-
watchDataChanges() {
|
|
341
|
-
// Create a new request.
|
|
342
|
-
this.request = new DataSourceRequest();
|
|
343
|
-
this.isLoading$ = this.request.loading;
|
|
344
|
-
if (!this.dataSource) {
|
|
345
|
-
this.data$ = of({ state: 'error_datasource' }).pipe(tap(() => this.request.stopLoading()));
|
|
346
|
-
return;
|
|
347
|
-
}
|
|
348
|
-
// Pass the request to the data source.
|
|
349
|
-
this.data$ = this.dataSource.handle(this.request).pipe(tap(() => this.request.stopLoading()), map(result => {
|
|
350
|
-
const count = (result && result.data && result.data.length) || 0;
|
|
351
|
-
if (count <= 0) {
|
|
352
|
-
return { state: 'empty', result };
|
|
353
|
-
}
|
|
354
|
-
return { state: 'success', result };
|
|
355
|
-
}), catchError(error => {
|
|
356
|
-
this.request.stopLoading();
|
|
357
|
-
const statusCode = error?.status ?? null;
|
|
358
|
-
const states = {
|
|
359
|
-
0: 'error_down',
|
|
360
|
-
401: 'error_unauthorized',
|
|
361
|
-
403: 'error_forbidden',
|
|
362
|
-
404: 'error_not_found',
|
|
363
|
-
500: 'error_server'
|
|
364
|
-
};
|
|
365
|
-
return of({ state: states?.[statusCode] ?? 'error_unknown', statusCode: statusCode });
|
|
366
|
-
}));
|
|
367
|
-
// Subscribe to the data changes.
|
|
368
|
-
this.subscribeToChanges();
|
|
369
|
-
}
|
|
370
|
-
subscribeToChanges() {
|
|
371
|
-
const form$ = this.getFormChanges();
|
|
372
|
-
const query$ = this.getQueryChanges();
|
|
373
|
-
this._subscription = combineLatest([form$, query$]).subscribe(([form, query]) => {
|
|
374
|
-
const { pageNumber, pageSize } = form;
|
|
375
|
-
const sort = Object.keys(form.sort)
|
|
376
|
-
.map(name => ({ name, direction: form.sort[name] }))
|
|
377
|
-
.filter(item => ['asc', 'desc'].includes(item.direction));
|
|
378
|
-
this.request.startLoading();
|
|
379
|
-
return this.request.update({
|
|
380
|
-
sort,
|
|
381
|
-
query,
|
|
382
|
-
pageSize,
|
|
383
|
-
pageNumber,
|
|
384
|
-
queryFields: this.queryFields
|
|
385
|
-
});
|
|
386
|
-
});
|
|
387
|
-
}
|
|
388
|
-
getQueryChanges() {
|
|
389
|
-
return this.queryControl.valueChanges.pipe(debounceTime(400), distinctUntilChanged(), startWith(this.queryControl.value));
|
|
390
|
-
}
|
|
391
|
-
getFormChanges() {
|
|
392
|
-
return this.form.valueChanges.pipe(startWith(this.form.value));
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
BbTable.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.
|
|
396
|
-
BbTable.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.1.0", type: BbTable, selector: "bb-table", inputs: { identifier: "identifier", dataSource: "dataSource", queryFields: "queryFields", sortingStrategy: "sortingStrategy", header: "header", footer: "footer", sizes: "sizes" }, host: { classAttribute: "bb-table" }, queries: [{ propertyName: "tableRowTemplate", first: true, predicate: BbTableRowDef, descendants: true, read: TemplateRef }, { propertyName: "tableColumnTemplates", predicate: BbTableColumnDef, read: TemplateRef }], ngImport: i0, template: "<!--\n This is the header of the table. It can be a user\n defined custom header or just the default header.\n-->\n\n<header *ngIf=\"(header === true ? headerTemplate : header) as template\"\n class=\"bb-table-top-actions\">\n <ng-container *ngTemplateOutlet=\"template\"></ng-container>\n</header>\n\n<!--\n This is the table that contains the\n rows and columns.\n-->\n\n<div class=\"bb-table-wrapper\">\n <div *ngIf=\"isLoading$ | async\"\n class=\"bb-table-progress\">\n <div class=\"bb-table-indeterminate\"></div>\n </div>\n <table class=\"bb-table-container\">\n <thead>\n <tr>\n <ng-content select=\"bb-table-header-cell\"></ng-content>\n </tr>\n </thead>\n <tbody *ngIf=\"data$ | async as data; else isLoadingTemplate\"\n [ngSwitch]=\"data?.state\">\n <ng-container *ngSwitchCase=\"'success'\">\n <ng-container *ngIf=\"!!tableRowTemplate; else tableCellsTemplates\">\n <ng-container\n *ngTemplateOutlet=\"tableRowTemplate; context: {data: data?.result?.data || []}\"></ng-container>\n </ng-container>\n\n <ng-template #tableCellsTemplates>\n <tr *ngFor=\"let item of data?.result?.data; trackBy: trackByFn\">\n <ng-container *ngFor=\"let template of tableColumnTemplates\">\n <ng-container *ngTemplateOutlet=\"template; context: {item: item}\"></ng-container>\n </ng-container>\n </tr>\n </ng-template>\n </ng-container>\n\n <ng-container *ngSwitchCase=\"'empty'\">\n <ng-container\n *ngTemplateOutlet=\"errorTemplate; context: data\"></ng-container>\n </ng-container>\n\n <ng-container *ngSwitchCase=\"'error_datasource'\">\n <ng-container\n *ngTemplateOutlet=\"errorTemplate; context: data\"></ng-container>\n </ng-container>\n\n <ng-container *ngSwitchCase=\"'error_not_found'\">\n <ng-container\n *ngTemplateOutlet=\"errorTemplate; context: data\"></ng-container>\n </ng-container>\n\n <ng-container *ngSwitchCase=\"'error_server'\">\n <ng-container\n *ngTemplateOutlet=\"errorTemplate; context: data\"></ng-container>\n </ng-container>\n\n <ng-container *ngSwitchCase=\"'error_down'\">\n <ng-container\n *ngTemplateOutlet=\"errorTemplate; context: data\"></ng-container>\n </ng-container>\n\n <ng-container *ngSwitchDefault>\n <ng-container\n *ngTemplateOutlet=\"errorTemplate; context: data\"></ng-container>\n </ng-container>\n </tbody>\n </table>\n</div>\n\n<footer *ngIf=\"(footer === true ? footerTemplate : footer) as template\"\n class=\"bb-table-bottom-actions\">\n <ng-container *ngTemplateOutlet=\"template\"></ng-container>\n</footer>\n\n<ng-template #isLoadingTemplate>\n <tr>\n <td [attr.colspan]=\"headerCount\"\n class=\"bb-table-template\">\n <div class=\"bb-table-template-content\">\n {{ 'tables.loading' | bbLocalize }}\n </div>\n </td>\n </tr>\n</ng-template>\n\n<!--\n This is the template that will be used when the user has not\n supplied a custom header template.\n-->\n\n<ng-template #headerTemplate>\n <ng-content></ng-content>\n <bb-form-control>\n <input [formControl]=\"queryControl\"\n [placeholder]=\"'tables.search' | bbLocalize\"\n bbInput\n autocomplete=\"off\">\n <bb-icon *ngIf=\"queryControl?.value?.length <= 0; else closeButtonTemplate\"\n bbSuffix\n src=\"material:search\">\n </bb-icon>\n </bb-form-control>\n</ng-template>\n\n<!--\n This is the template that will be used when the user has not\n supplied a custom footer template.\n-->\n\n<ng-template #footerTemplate>\n <bb-form-control *ngIf=\"sizes?.length > 1\">\n <select [formControl]=\"pageSizeControl\"\n bbInput\n title=\"Sizes\">\n <option *ngFor=\"let item of sizes; trackBy: trackByValue\"\n [ngValue]=\"item\">\n {{ item }} / {{ 'tables.page' | bbLocalize }}\n </option>\n </select>\n </bb-form-control>\n\n <bb-table-pager [totalPages]=\"(data$ | async)?.result?.totalPages\"\n [formControl]=\"pageNumberControl\">\n </bb-table-pager>\n</ng-template>\n\n<!--\n This the template that will be used when the user\n has filled in some data in the query control.\n-->\n\n<ng-template #closeButtonTemplate>\n <button bbSuffix\n (click)=\"queryControl?.patchValue('')\"\n type=\"button\"\n class=\"bb-table-progress-close-query\">\n <bb-icon src=\"material:close\"></bb-icon>\n </button>\n</ng-template>\n\n<ng-template #errorTemplate let-state=\"state\" let-status=\"statusCode\">\n <tr>\n <td [attr.colspan]=\"headerCount\"\n class=\"bb-table-template\">\n <div class=\"bb-table-template-content\">\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"64\" height=\"41\">\n <g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(0 1)\">\n <ellipse cx=\"32\" cy=\"33\" fill=\"#F5F5F5\" rx=\"32\" ry=\"7\"></ellipse>\n <g fill-rule=\"nonzero\" stroke=\"#D9D9D9\">\n <path\n d=\"M55 12.7605604L44.8543047 1.25739633C44.3674414.47382661 43.6558789 0 42.9067617 0H21.0932383c-.7491172 0-1.4606797.47395025-1.947543 1.25739633L9 12.7605604V22h46v-9.2394396z\"></path>\n <path fill=\"#FAFAFA\"\n d=\"M41.6132813 15.9315c0-1.6056489.9936718-2.931266 2.2264179-2.9315H55v18.1371277C55 33.2589574 53.6793867 35 52.0504297 35H11.94957031C10.32052344 35 9 33.2588404 9 31.1371277V13h11.1603008c1.2327461 0 2.226418 1.3228085 2.226418 2.9284574v.0211809c0 1.6056489 1.0049921 2.9015426 2.2377382 2.9015426h14.751086c1.2327461 0 2.2377383-1.3078298 2.2377383-2.9134788V15.9315z\"></path>\n </g>\n </g>\n </svg>\n <span *ngIf=\"state as stateLabel\">{{ ('tables.' + stateLabel) | bbLocalize }}</span>\n <span *ngIf=\"status as statusCode\"\n class=\"bb-table-template-content-code\">(HTTP {{ statusCode }})</span>\n </div>\n </td>\n </tr>\n</ng-template>\n", styles: [".bb-table{width:100%;display:block;box-shadow:0 6px 6px -6px #0000001a}.bb-table.plain{box-shadow:none}.bb-table.plain>.bb-table-wrapper{border-top-left-radius:0;border-top-right-radius:0}.bb-table-wrapper{overflow-x:auto;position:relative;background-color:#fff;border-top-left-radius:4px;border-top-right-radius:4px}.bb-table-container{width:100%}.bb-table-container td{border-bottom:1px solid #d8d8d8}.bb-table-top-actions{display:flex;flex-wrap:wrap;flex-direction:column;padding:20px 20px 10px;background-color:#fff;justify-content:flex-end;border-top-left-radius:4px;border-top-right-radius:4px;border-bottom:1px solid #d8d8d8}.bb-table-top-actions>*{margin-left:0;margin-bottom:10px}.bb-table-top-actions+.bb-table-wrapper{border-radius:0}.bb-table-bottom-actions{height:60px;display:flex;padding:0 20px;overflow-x:auto;align-items:center;background-color:#fff;border-bottom-left-radius:4px;border-bottom-right-radius:4px}.bb-table-template{border:none;background-color:#f5f5f5;border-bottom:1px solid #d8d8d8}.bb-table-template-content{padding:20px;display:flex;color:#3d464d;font-size:14px;line-height:1.2;font-weight:400;min-height:140px;text-align:center;align-items:center;flex-direction:column;justify-content:center}.bb-table-template-content>svg{margin-bottom:12px}.bb-table-template-content-code{opacity:.5;margin-top:5px;display:inline-block}.bb-table-progress{top:0;left:0;right:0;opacity:0;width:100%;height:4px;display:block;overflow:hidden;position:absolute;background-color:#2f408b4d;animation:fadeIn .25s cubic-bezier(0,0,.2,1) .1s forwards}.bb-table-progress .bb-table-indeterminate{background-color:#2f408b}.bb-table-progress .bb-table-indeterminate:before{top:0;left:0;bottom:0;content:\"\";position:absolute;will-change:left,right;background-color:inherit;animation:indeterminate 2.1s cubic-bezier(.65,.815,.735,.395) infinite}.bb-table-progress .bb-table-indeterminate:after{top:0;left:0;bottom:0;content:\"\";position:absolute;animation-delay:1.15s;will-change:left,right;background-color:inherit;animation:indeterminate-short 2.1s cubic-bezier(.165,.84,.44,1) infinite}.bb-table-progress-close-query{padding:0;border:none;border-radius:4px;background-color:transparent;transition:background-color .25s cubic-bezier(0,0,.2,1)}.bb-table-progress-close-query:hover{background-color:#00000014}.bb-table-progress-close-query:focus{background-color:#0000001f}.bb-table-progress-close-query:active{background-color:#00000029}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}@keyframes indeterminate{0%{left:-35%;right:100%}60%{left:100%;right:-90%}to{left:100%;right:-90%}}@keyframes indeterminate-short{0%{left:-200%;right:100%}60%{left:107%;right:-8%}to{left:107%;right:-8%}}@media only screen and (min-width: 768px){.bb-table-top-actions{flex-direction:row}.bb-table-top-actions>*:not(:first-child){margin-left:10px;margin-bottom:10px}}\n"], components: [{ type: i1.BbFormControl, selector: "bb-form-control", inputs: ["grouped", "hideErrors", "label", "hint"] }, { type: i1.BbIcon, selector: "bb-icon", inputs: ["alt", "size", "src", "ariaHidden"] }, { type: BbTablePager, selector: "bb-table-pager", inputs: ["disabled", "amountOfButtons", "showArrowButtons", "pageNumber", "totalPages"] }], directives: [{ type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i3.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }, { type: i3.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { type: i3.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { type: i3.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i3.NgSwitchDefault, selector: "[ngSwitchDefault]" }, { type: i1.BbInput, selector: "input[bbInput], textarea[bbInput]", inputs: ["readonly"] }, { type: i4.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i4.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i4.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { type: i1.BbSuffix, selector: "[bbSuffix]" }, { type: i1.BbSelect, selector: "select[bbInput]", inputs: ["disabled", "required"] }, { type: i4.SelectControlValueAccessor, selector: "select:not([multiple])[formControlName],select:not([multiple])[formControl],select:not([multiple])[ngModel]", inputs: ["compareWith"] }, { type: i4.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { type: i4.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }], pipes: { "async": i3.AsyncPipe, "bbLocalize": i5.BbLocalize }, changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
397
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.
|
|
398
|
-
type: Component,
|
|
399
|
-
args: [{ selector: 'bb-table', host: { 'class': 'bb-table' }, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, preserveWhitespaces: false, template: "<!--\n This is the header of the table. It can be a user\n defined custom header or just the default header.\n-->\n\n<header *ngIf=\"(header === true ? headerTemplate : header) as template\"\n class=\"bb-table-top-actions\">\n <ng-container *ngTemplateOutlet=\"template\"></ng-container>\n</header>\n\n<!--\n This is the table that contains the\n rows and columns.\n-->\n\n<div class=\"bb-table-wrapper\">\n <div *ngIf=\"isLoading$ | async\"\n class=\"bb-table-progress\">\n <div class=\"bb-table-indeterminate\"></div>\n </div>\n <table class=\"bb-table-container\">\n <thead>\n <tr>\n <ng-content select=\"bb-table-header-cell\"></ng-content>\n </tr>\n </thead>\n <tbody *ngIf=\"data$ | async as data; else isLoadingTemplate\"\n [ngSwitch]=\"data?.state\">\n <ng-container *ngSwitchCase=\"'success'\">\n <ng-container *ngIf=\"!!tableRowTemplate; else tableCellsTemplates\">\n <ng-container\n *ngTemplateOutlet=\"tableRowTemplate; context: {data: data?.result?.data || []}\"></ng-container>\n </ng-container>\n\n <ng-template #tableCellsTemplates>\n <tr *ngFor=\"let item of data?.result?.data; trackBy: trackByFn\">\n <ng-container *ngFor=\"let template of tableColumnTemplates\">\n <ng-container *ngTemplateOutlet=\"template; context: {item: item}\"></ng-container>\n </ng-container>\n </tr>\n </ng-template>\n </ng-container>\n\n <ng-container *ngSwitchCase=\"'empty'\">\n <ng-container\n *ngTemplateOutlet=\"errorTemplate; context: data\"></ng-container>\n </ng-container>\n\n <ng-container *ngSwitchCase=\"'error_datasource'\">\n <ng-container\n *ngTemplateOutlet=\"errorTemplate; context: data\"></ng-container>\n </ng-container>\n\n <ng-container *ngSwitchCase=\"'error_not_found'\">\n <ng-container\n *ngTemplateOutlet=\"errorTemplate; context: data\"></ng-container>\n </ng-container>\n\n <ng-container *ngSwitchCase=\"'error_server'\">\n <ng-container\n *ngTemplateOutlet=\"errorTemplate; context: data\"></ng-container>\n </ng-container>\n\n <ng-container *ngSwitchCase=\"'error_down'\">\n <ng-container\n *ngTemplateOutlet=\"errorTemplate; context: data\"></ng-container>\n </ng-container>\n\n <ng-container *ngSwitchDefault>\n <ng-container\n *ngTemplateOutlet=\"errorTemplate; context: data\"></ng-container>\n </ng-container>\n </tbody>\n </table>\n</div>\n\n<footer *ngIf=\"(footer === true ? footerTemplate : footer) as template\"\n class=\"bb-table-bottom-actions\">\n <ng-container *ngTemplateOutlet=\"template\"></ng-container>\n</footer>\n\n<ng-template #isLoadingTemplate>\n <tr>\n <td [attr.colspan]=\"headerCount\"\n class=\"bb-table-template\">\n <div class=\"bb-table-template-content\">\n {{ 'tables.loading' | bbLocalize }}\n </div>\n </td>\n </tr>\n</ng-template>\n\n<!--\n This is the template that will be used when the user has not\n supplied a custom header template.\n-->\n\n<ng-template #headerTemplate>\n <ng-content></ng-content>\n <bb-form-control>\n <input [formControl]=\"queryControl\"\n [placeholder]=\"'tables.search' | bbLocalize\"\n bbInput\n autocomplete=\"off\">\n <bb-icon *ngIf=\"queryControl?.value?.length <= 0; else closeButtonTemplate\"\n bbSuffix\n src=\"material:search\">\n </bb-icon>\n </bb-form-control>\n</ng-template>\n\n<!--\n This is the template that will be used when the user has not\n supplied a custom footer template.\n-->\n\n<ng-template #footerTemplate>\n <bb-form-control *ngIf=\"sizes?.length > 1\">\n <select [formControl]=\"pageSizeControl\"\n bbInput\n title=\"Sizes\">\n <option *ngFor=\"let item of sizes; trackBy: trackByValue\"\n [ngValue]=\"item\">\n {{ item }} / {{ 'tables.page' | bbLocalize }}\n </option>\n </select>\n </bb-form-control>\n\n <bb-table-pager [totalPages]=\"(data$ | async)?.result?.totalPages\"\n [formControl]=\"pageNumberControl\">\n </bb-table-pager>\n</ng-template>\n\n<!--\n This the template that will be used when the user\n has filled in some data in the query control.\n-->\n\n<ng-template #closeButtonTemplate>\n <button bbSuffix\n (click)=\"queryControl?.patchValue('')\"\n type=\"button\"\n class=\"bb-table-progress-close-query\">\n <bb-icon src=\"material:close\"></bb-icon>\n </button>\n</ng-template>\n\n<ng-template #errorTemplate let-state=\"state\" let-status=\"statusCode\">\n <tr>\n <td [attr.colspan]=\"headerCount\"\n class=\"bb-table-template\">\n <div class=\"bb-table-template-content\">\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"64\" height=\"41\">\n <g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(0 1)\">\n <ellipse cx=\"32\" cy=\"33\" fill=\"#F5F5F5\" rx=\"32\" ry=\"7\"></ellipse>\n <g fill-rule=\"nonzero\" stroke=\"#D9D9D9\">\n <path\n d=\"M55 12.7605604L44.8543047 1.25739633C44.3674414.47382661 43.6558789 0 42.9067617 0H21.0932383c-.7491172 0-1.4606797.47395025-1.947543 1.25739633L9 12.7605604V22h46v-9.2394396z\"></path>\n <path fill=\"#FAFAFA\"\n d=\"M41.6132813 15.9315c0-1.6056489.9936718-2.931266 2.2264179-2.9315H55v18.1371277C55 33.2589574 53.6793867 35 52.0504297 35H11.94957031C10.32052344 35 9 33.2588404 9 31.1371277V13h11.1603008c1.2327461 0 2.226418 1.3228085 2.226418 2.9284574v.0211809c0 1.6056489 1.0049921 2.9015426 2.2377382 2.9015426h14.751086c1.2327461 0 2.2377383-1.3078298 2.2377383-2.9134788V15.9315z\"></path>\n </g>\n </g>\n </svg>\n <span *ngIf=\"state as stateLabel\">{{ ('tables.' + stateLabel) | bbLocalize }}</span>\n <span *ngIf=\"status as statusCode\"\n class=\"bb-table-template-content-code\">(HTTP {{ statusCode }})</span>\n </div>\n </td>\n </tr>\n</ng-template>\n", styles: [".bb-table{width:100%;display:block;box-shadow:0 6px 6px -6px #0000001a}.bb-table.plain{box-shadow:none}.bb-table.plain>.bb-table-wrapper{border-top-left-radius:0;border-top-right-radius:0}.bb-table-wrapper{overflow-x:auto;position:relative;background-color:#fff;border-top-left-radius:4px;border-top-right-radius:4px}.bb-table-container{width:100%}.bb-table-container td{border-bottom:1px solid #d8d8d8}.bb-table-top-actions{display:flex;flex-wrap:wrap;flex-direction:column;padding:20px 20px 10px;background-color:#fff;justify-content:flex-end;border-top-left-radius:4px;border-top-right-radius:4px;border-bottom:1px solid #d8d8d8}.bb-table-top-actions>*{margin-left:0;margin-bottom:10px}.bb-table-top-actions+.bb-table-wrapper{border-radius:0}.bb-table-bottom-actions{height:60px;display:flex;padding:0 20px;overflow-x:auto;align-items:center;background-color:#fff;border-bottom-left-radius:4px;border-bottom-right-radius:4px}.bb-table-template{border:none;background-color:#f5f5f5;border-bottom:1px solid #d8d8d8}.bb-table-template-content{padding:20px;display:flex;color:#3d464d;font-size:14px;line-height:1.2;font-weight:400;min-height:140px;text-align:center;align-items:center;flex-direction:column;justify-content:center}.bb-table-template-content>svg{margin-bottom:12px}.bb-table-template-content-code{opacity:.5;margin-top:5px;display:inline-block}.bb-table-progress{top:0;left:0;right:0;opacity:0;width:100%;height:4px;display:block;overflow:hidden;position:absolute;background-color:#2f408b4d;animation:fadeIn .25s cubic-bezier(0,0,.2,1) .1s forwards}.bb-table-progress .bb-table-indeterminate{background-color:#2f408b}.bb-table-progress .bb-table-indeterminate:before{top:0;left:0;bottom:0;content:\"\";position:absolute;will-change:left,right;background-color:inherit;animation:indeterminate 2.1s cubic-bezier(.65,.815,.735,.395) infinite}.bb-table-progress .bb-table-indeterminate:after{top:0;left:0;bottom:0;content:\"\";position:absolute;animation-delay:1.15s;will-change:left,right;background-color:inherit;animation:indeterminate-short 2.1s cubic-bezier(.165,.84,.44,1) infinite}.bb-table-progress-close-query{padding:0;border:none;border-radius:4px;background-color:transparent;transition:background-color .25s cubic-bezier(0,0,.2,1)}.bb-table-progress-close-query:hover{background-color:#00000014}.bb-table-progress-close-query:focus{background-color:#0000001f}.bb-table-progress-close-query:active{background-color:#00000029}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}@keyframes indeterminate{0%{left:-35%;right:100%}60%{left:100%;right:-90%}to{left:100%;right:-90%}}@keyframes indeterminate-short{0%{left:-200%;right:100%}60%{left:107%;right:-8%}to{left:107%;right:-8%}}@media only screen and (min-width: 768px){.bb-table-top-actions{flex-direction:row}.bb-table-top-actions>*:not(:first-child){margin-left:10px;margin-bottom:10px}}\n"] }]
|
|
400
|
-
}], propDecorators: { tableColumnTemplates: [{
|
|
401
|
-
type: ContentChildren,
|
|
402
|
-
args: [BbTableColumnDef, { read: TemplateRef }]
|
|
403
|
-
}], tableRowTemplate: [{
|
|
404
|
-
type: ContentChild,
|
|
405
|
-
args: [BbTableRowDef, { read: TemplateRef, static: false }]
|
|
406
|
-
}], identifier: [{
|
|
407
|
-
type: Input
|
|
408
|
-
}], dataSource: [{
|
|
409
|
-
type: Input
|
|
410
|
-
}], queryFields: [{
|
|
411
|
-
type: Input
|
|
412
|
-
}], sortingStrategy: [{
|
|
413
|
-
type: Input
|
|
414
|
-
}], header: [{
|
|
415
|
-
type: Input
|
|
416
|
-
}], footer: [{
|
|
417
|
-
type: Input
|
|
418
|
-
}], sizes: [{
|
|
419
|
-
type: Input
|
|
242
|
+
class BbTableColumnDef {
|
|
243
|
+
}
|
|
244
|
+
BbTableColumnDef.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: BbTableColumnDef, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
245
|
+
BbTableColumnDef.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.6", type: BbTableColumnDef, selector: "[bbTableColumnDef]", ngImport: i0 });
|
|
246
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: BbTableColumnDef, decorators: [{
|
|
247
|
+
type: Directive,
|
|
248
|
+
args: [{
|
|
249
|
+
selector: '[bbTableColumnDef]'
|
|
250
|
+
}]
|
|
251
|
+
}] });
|
|
252
|
+
class BbTableRowDef {
|
|
253
|
+
}
|
|
254
|
+
BbTableRowDef.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: BbTableRowDef, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
255
|
+
BbTableRowDef.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.6", type: BbTableRowDef, selector: "[bbTableRowDef]", ngImport: i0 });
|
|
256
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: BbTableRowDef, decorators: [{
|
|
257
|
+
type: Directive,
|
|
258
|
+
args: [{
|
|
259
|
+
selector: '[bbTableRowDef]'
|
|
260
|
+
}]
|
|
261
|
+
}] });
|
|
262
|
+
class BbTable {
|
|
263
|
+
constructor() {
|
|
264
|
+
// Inputs.
|
|
265
|
+
this.identifier = null;
|
|
266
|
+
this.queryFields = [];
|
|
267
|
+
this.sortingStrategy = 'single';
|
|
268
|
+
this.header = true;
|
|
269
|
+
this.footer = true;
|
|
270
|
+
// Sizes.
|
|
271
|
+
this._sizes = [25, 50, 75, 100];
|
|
272
|
+
// Optimizations.
|
|
273
|
+
this.trackByFn = (index, item) => this.identifier ? item[this.identifier] : index;
|
|
274
|
+
this.trackByValue = (_, item) => item;
|
|
275
|
+
this.queryControl = new FormControl('');
|
|
276
|
+
// State.
|
|
277
|
+
this._headerCount = 0;
|
|
278
|
+
}
|
|
279
|
+
get sizes() {
|
|
280
|
+
return this._sizes;
|
|
281
|
+
}
|
|
282
|
+
set sizes(newValue) {
|
|
283
|
+
this.updateSizes(newValue);
|
|
284
|
+
}
|
|
285
|
+
ngOnInit() {
|
|
286
|
+
this.composeForm();
|
|
287
|
+
this.watchDataChanges();
|
|
288
|
+
}
|
|
289
|
+
ngOnDestroy() {
|
|
290
|
+
this._subscription?.unsubscribe();
|
|
291
|
+
}
|
|
292
|
+
get headerCount() {
|
|
293
|
+
return this._headerCount;
|
|
294
|
+
}
|
|
295
|
+
get sortControl() {
|
|
296
|
+
return this.form?.get('sort');
|
|
297
|
+
}
|
|
298
|
+
get pageNumberControl() {
|
|
299
|
+
return this.form?.get('pageNumber');
|
|
300
|
+
}
|
|
301
|
+
get pageSizeControl() {
|
|
302
|
+
return this.form?.get('pageSize');
|
|
303
|
+
}
|
|
304
|
+
refresh() {
|
|
305
|
+
return this.request.update();
|
|
306
|
+
}
|
|
307
|
+
setHeaderCount(amount) {
|
|
308
|
+
this._headerCount += amount;
|
|
309
|
+
}
|
|
310
|
+
updateSizes(newValue) {
|
|
311
|
+
// Validate the sizes has at least one value.
|
|
312
|
+
if (newValue.length <= 0) {
|
|
313
|
+
throw new Error('Cannot set an empty array as the sizes.');
|
|
314
|
+
}
|
|
315
|
+
// Set the new size.
|
|
316
|
+
this._sizes = newValue;
|
|
317
|
+
// Validate that the form exists already.
|
|
318
|
+
if (!this.form) {
|
|
319
|
+
return;
|
|
320
|
+
}
|
|
321
|
+
// Check if the current selected value is
|
|
322
|
+
// in the new sizes array.
|
|
323
|
+
const pageSizeControl = this.form.get('pageSize');
|
|
324
|
+
if (this._sizes.includes(pageSizeControl.value)) {
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
327
|
+
// Set the first value in the array as
|
|
328
|
+
// the new value.
|
|
329
|
+
const firstValue = this._sizes[0];
|
|
330
|
+
pageSizeControl.setValue(firstValue);
|
|
331
|
+
}
|
|
332
|
+
composeForm() {
|
|
333
|
+
// Setup the form.
|
|
334
|
+
this.form = new FormGroup({
|
|
335
|
+
pageSize: new FormControl(this._sizes[0]),
|
|
336
|
+
pageNumber: new FormControl(1),
|
|
337
|
+
sort: new FormGroup({})
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
watchDataChanges() {
|
|
341
|
+
// Create a new request.
|
|
342
|
+
this.request = new DataSourceRequest();
|
|
343
|
+
this.isLoading$ = this.request.loading;
|
|
344
|
+
if (!this.dataSource) {
|
|
345
|
+
this.data$ = of({ state: 'error_datasource' }).pipe(tap(() => this.request.stopLoading()));
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
// Pass the request to the data source.
|
|
349
|
+
this.data$ = this.dataSource.handle(this.request).pipe(tap(() => this.request.stopLoading()), map(result => {
|
|
350
|
+
const count = (result && result.data && result.data.length) || 0;
|
|
351
|
+
if (count <= 0) {
|
|
352
|
+
return { state: 'empty', result };
|
|
353
|
+
}
|
|
354
|
+
return { state: 'success', result };
|
|
355
|
+
}), catchError(error => {
|
|
356
|
+
this.request.stopLoading();
|
|
357
|
+
const statusCode = error?.status ?? null;
|
|
358
|
+
const states = {
|
|
359
|
+
0: 'error_down',
|
|
360
|
+
401: 'error_unauthorized',
|
|
361
|
+
403: 'error_forbidden',
|
|
362
|
+
404: 'error_not_found',
|
|
363
|
+
500: 'error_server'
|
|
364
|
+
};
|
|
365
|
+
return of({ state: states?.[statusCode] ?? 'error_unknown', statusCode: statusCode });
|
|
366
|
+
}));
|
|
367
|
+
// Subscribe to the data changes.
|
|
368
|
+
this.subscribeToChanges();
|
|
369
|
+
}
|
|
370
|
+
subscribeToChanges() {
|
|
371
|
+
const form$ = this.getFormChanges();
|
|
372
|
+
const query$ = this.getQueryChanges();
|
|
373
|
+
this._subscription = combineLatest([form$, query$]).subscribe(([form, query]) => {
|
|
374
|
+
const { pageNumber, pageSize } = form;
|
|
375
|
+
const sort = Object.keys(form.sort)
|
|
376
|
+
.map(name => ({ name, direction: form.sort[name] }))
|
|
377
|
+
.filter(item => ['asc', 'desc'].includes(item.direction));
|
|
378
|
+
this.request.startLoading();
|
|
379
|
+
return this.request.update({
|
|
380
|
+
sort,
|
|
381
|
+
query,
|
|
382
|
+
pageSize,
|
|
383
|
+
pageNumber,
|
|
384
|
+
queryFields: this.queryFields
|
|
385
|
+
});
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
getQueryChanges() {
|
|
389
|
+
return this.queryControl.valueChanges.pipe(debounceTime(400), distinctUntilChanged(), startWith(this.queryControl.value));
|
|
390
|
+
}
|
|
391
|
+
getFormChanges() {
|
|
392
|
+
return this.form.valueChanges.pipe(startWith(this.form.value));
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
BbTable.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: BbTable, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
396
|
+
BbTable.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.6", type: BbTable, selector: "bb-table", inputs: { identifier: "identifier", dataSource: "dataSource", queryFields: "queryFields", sortingStrategy: "sortingStrategy", header: "header", footer: "footer", sizes: "sizes" }, host: { classAttribute: "bb-table" }, queries: [{ propertyName: "tableRowTemplate", first: true, predicate: BbTableRowDef, descendants: true, read: TemplateRef }, { propertyName: "tableColumnTemplates", predicate: BbTableColumnDef, read: TemplateRef }], ngImport: i0, template: "<!--\r\n This is the header of the table. It can be a user\r\n defined custom header or just the default header.\r\n-->\r\n\r\n<header *ngIf=\"(header === true ? headerTemplate : header) as template\"\r\n class=\"bb-table-top-actions\">\r\n <ng-container *ngTemplateOutlet=\"template\"></ng-container>\r\n</header>\r\n\r\n<!--\r\n This is the table that contains the\r\n rows and columns.\r\n-->\r\n\r\n<div class=\"bb-table-wrapper\">\r\n <div *ngIf=\"isLoading$ | async\"\r\n class=\"bb-table-progress\">\r\n <div class=\"bb-table-indeterminate\"></div>\r\n </div>\r\n <table class=\"bb-table-container\">\r\n <thead>\r\n <tr>\r\n <ng-content select=\"bb-table-header-cell\"></ng-content>\r\n </tr>\r\n </thead>\r\n <tbody *ngIf=\"data$ | async as data; else isLoadingTemplate\"\r\n [ngSwitch]=\"data?.state\">\r\n <ng-container *ngSwitchCase=\"'success'\">\r\n <ng-container *ngIf=\"!!tableRowTemplate; else tableCellsTemplates\">\r\n <ng-container\r\n *ngTemplateOutlet=\"tableRowTemplate; context: {data: data?.result?.data || []}\"></ng-container>\r\n </ng-container>\r\n\r\n <ng-template #tableCellsTemplates>\r\n <tr *ngFor=\"let item of data?.result?.data; trackBy: trackByFn\">\r\n <ng-container *ngFor=\"let template of tableColumnTemplates\">\r\n <ng-container *ngTemplateOutlet=\"template; context: {item: item}\"></ng-container>\r\n </ng-container>\r\n </tr>\r\n </ng-template>\r\n </ng-container>\r\n\r\n <ng-container *ngSwitchCase=\"'empty'\">\r\n <ng-container\r\n *ngTemplateOutlet=\"errorTemplate; context: data\"></ng-container>\r\n </ng-container>\r\n\r\n <ng-container *ngSwitchCase=\"'error_datasource'\">\r\n <ng-container\r\n *ngTemplateOutlet=\"errorTemplate; context: data\"></ng-container>\r\n </ng-container>\r\n\r\n <ng-container *ngSwitchCase=\"'error_not_found'\">\r\n <ng-container\r\n *ngTemplateOutlet=\"errorTemplate; context: data\"></ng-container>\r\n </ng-container>\r\n\r\n <ng-container *ngSwitchCase=\"'error_server'\">\r\n <ng-container\r\n *ngTemplateOutlet=\"errorTemplate; context: data\"></ng-container>\r\n </ng-container>\r\n\r\n <ng-container *ngSwitchCase=\"'error_down'\">\r\n <ng-container\r\n *ngTemplateOutlet=\"errorTemplate; context: data\"></ng-container>\r\n </ng-container>\r\n\r\n <ng-container *ngSwitchDefault>\r\n <ng-container\r\n *ngTemplateOutlet=\"errorTemplate; context: data\"></ng-container>\r\n </ng-container>\r\n </tbody>\r\n </table>\r\n</div>\r\n\r\n<footer *ngIf=\"(footer === true ? footerTemplate : footer) as template\"\r\n class=\"bb-table-bottom-actions\">\r\n <ng-container *ngTemplateOutlet=\"template\"></ng-container>\r\n</footer>\r\n\r\n<ng-template #isLoadingTemplate>\r\n <tr>\r\n <td [attr.colspan]=\"headerCount\"\r\n class=\"bb-table-template\">\r\n <div class=\"bb-table-template-content\">\r\n {{ 'tables.loading' | bbLocalize }}\r\n </div>\r\n </td>\r\n </tr>\r\n</ng-template>\r\n\r\n<!--\r\n This is the template that will be used when the user has not\r\n supplied a custom header template.\r\n-->\r\n\r\n<ng-template #headerTemplate>\r\n <ng-content></ng-content>\r\n <bb-form-control>\r\n <input [formControl]=\"queryControl\"\r\n [placeholder]=\"'tables.search' | bbLocalize\"\r\n bbInput\r\n autocomplete=\"off\">\r\n <bb-icon *ngIf=\"queryControl?.value?.length <= 0; else closeButtonTemplate\"\r\n bbSuffix\r\n src=\"material:search\">\r\n </bb-icon>\r\n </bb-form-control>\r\n</ng-template>\r\n\r\n<!--\r\n This is the template that will be used when the user has not\r\n supplied a custom footer template.\r\n-->\r\n\r\n<ng-template #footerTemplate>\r\n <bb-form-control *ngIf=\"sizes?.length > 1\">\r\n <select [formControl]=\"pageSizeControl\"\r\n bbInput\r\n title=\"Sizes\">\r\n <option *ngFor=\"let item of sizes; trackBy: trackByValue\"\r\n [ngValue]=\"item\">\r\n {{ item }} / {{ 'tables.page' | bbLocalize }}\r\n </option>\r\n </select>\r\n </bb-form-control>\r\n\r\n <bb-table-pager [totalPages]=\"(data$ | async)?.result?.totalPages\"\r\n [formControl]=\"pageNumberControl\">\r\n </bb-table-pager>\r\n</ng-template>\r\n\r\n<!--\r\n This the template that will be used when the user\r\n has filled in some data in the query control.\r\n-->\r\n\r\n<ng-template #closeButtonTemplate>\r\n <button bbSuffix\r\n (click)=\"queryControl?.patchValue('')\"\r\n type=\"button\"\r\n class=\"bb-table-progress-close-query\">\r\n <bb-icon src=\"material:close\"></bb-icon>\r\n </button>\r\n</ng-template>\r\n\r\n<ng-template #errorTemplate let-state=\"state\" let-status=\"statusCode\">\r\n <tr>\r\n <td [attr.colspan]=\"headerCount\"\r\n class=\"bb-table-template\">\r\n <div class=\"bb-table-template-content\">\r\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"64\" height=\"41\">\r\n <g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(0 1)\">\r\n <ellipse cx=\"32\" cy=\"33\" fill=\"#F5F5F5\" rx=\"32\" ry=\"7\"></ellipse>\r\n <g fill-rule=\"nonzero\" stroke=\"#D9D9D9\">\r\n <path\r\n d=\"M55 12.7605604L44.8543047 1.25739633C44.3674414.47382661 43.6558789 0 42.9067617 0H21.0932383c-.7491172 0-1.4606797.47395025-1.947543 1.25739633L9 12.7605604V22h46v-9.2394396z\"></path>\r\n <path fill=\"#FAFAFA\"\r\n d=\"M41.6132813 15.9315c0-1.6056489.9936718-2.931266 2.2264179-2.9315H55v18.1371277C55 33.2589574 53.6793867 35 52.0504297 35H11.94957031C10.32052344 35 9 33.2588404 9 31.1371277V13h11.1603008c1.2327461 0 2.226418 1.3228085 2.226418 2.9284574v.0211809c0 1.6056489 1.0049921 2.9015426 2.2377382 2.9015426h14.751086c1.2327461 0 2.2377383-1.3078298 2.2377383-2.9134788V15.9315z\"></path>\r\n </g>\r\n </g>\r\n </svg>\r\n <span *ngIf=\"state as stateLabel\">{{ ('tables.' + stateLabel) | bbLocalize }}</span>\r\n <span *ngIf=\"status as statusCode\"\r\n class=\"bb-table-template-content-code\">(HTTP {{ statusCode }})</span>\r\n </div>\r\n </td>\r\n </tr>\r\n</ng-template>\r\n", styles: [".bb-table{width:100%;display:block;box-shadow:0 6px 6px -6px #0000001a}.bb-table.plain{box-shadow:none}.bb-table.plain>.bb-table-wrapper{border-top-left-radius:0;border-top-right-radius:0}.bb-table-wrapper{overflow-x:auto;position:relative;background-color:#fff;border-top-left-radius:4px;border-top-right-radius:4px}.bb-table-container{width:100%}.bb-table-container td{border-bottom:1px solid #d8d8d8}.bb-table-top-actions{display:flex;flex-wrap:wrap;flex-direction:column;padding:20px 20px 10px;background-color:#fff;justify-content:flex-end;border-top-left-radius:4px;border-top-right-radius:4px;border-bottom:1px solid #d8d8d8}.bb-table-top-actions>*{margin-left:0;margin-bottom:10px}.bb-table-top-actions+.bb-table-wrapper{border-radius:0}.bb-table-bottom-actions{height:60px;display:flex;padding:0 20px;overflow-x:auto;align-items:center;background-color:#fff;border-bottom-left-radius:4px;border-bottom-right-radius:4px}.bb-table-template{border:none;background-color:#f5f5f5;border-bottom:1px solid #d8d8d8}.bb-table-template-content{padding:20px;display:flex;color:#3d464d;font-size:14px;line-height:1.2;font-weight:400;min-height:140px;text-align:center;align-items:center;flex-direction:column;justify-content:center}.bb-table-template-content>svg{margin-bottom:12px}.bb-table-template-content-code{opacity:.5;margin-top:5px;display:inline-block}.bb-table-progress{top:0;left:0;right:0;opacity:0;width:100%;height:4px;display:block;overflow:hidden;position:absolute;background-color:#2f408b4d;animation:fadeIn .25s cubic-bezier(0,0,.2,1) .1s forwards}.bb-table-progress .bb-table-indeterminate{background-color:#2f408b}.bb-table-progress .bb-table-indeterminate:before{top:0;left:0;bottom:0;content:\"\";position:absolute;will-change:left,right;background-color:inherit;animation:indeterminate 2.1s cubic-bezier(.65,.815,.735,.395) infinite}.bb-table-progress .bb-table-indeterminate:after{top:0;left:0;bottom:0;content:\"\";position:absolute;animation-delay:1.15s;will-change:left,right;background-color:inherit;animation:indeterminate-short 2.1s cubic-bezier(.165,.84,.44,1) infinite}.bb-table-progress-close-query{padding:0;border:none;border-radius:4px;background-color:transparent;transition:background-color .25s cubic-bezier(0,0,.2,1)}.bb-table-progress-close-query:hover{background-color:#00000014}.bb-table-progress-close-query:focus{background-color:#0000001f}.bb-table-progress-close-query:active{background-color:#00000029}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}@keyframes indeterminate{0%{left:-35%;right:100%}60%{left:100%;right:-90%}to{left:100%;right:-90%}}@keyframes indeterminate-short{0%{left:-200%;right:100%}60%{left:107%;right:-8%}to{left:107%;right:-8%}}@media only screen and (min-width: 768px){.bb-table-top-actions{flex-direction:row}.bb-table-top-actions>*:not(:first-child){margin-left:10px;margin-bottom:10px}}\n"], components: [{ type: i1.BbFormControl, selector: "bb-form-control", inputs: ["grouped", "hideErrors", "label", "hint"] }, { type: i1.BbIcon, selector: "bb-icon", inputs: ["alt", "size", "src", "ariaHidden"] }, { type: BbTablePager, selector: "bb-table-pager", inputs: ["disabled", "amountOfButtons", "showArrowButtons", "pageNumber", "totalPages"] }], directives: [{ type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i3.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }, { type: i3.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { type: i3.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { type: i3.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i3.NgSwitchDefault, selector: "[ngSwitchDefault]" }, { type: i1.BbInput, selector: "input[bbInput], textarea[bbInput]", inputs: ["readonly"] }, { type: i4.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i4.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i4.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { type: i1.BbSuffix, selector: "[bbSuffix]" }, { type: i1.BbSelect, selector: "select[bbInput]", inputs: ["disabled", "required"] }, { type: i4.SelectControlValueAccessor, selector: "select:not([multiple])[formControlName],select:not([multiple])[formControl],select:not([multiple])[ngModel]", inputs: ["compareWith"] }, { type: i4.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { type: i4.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }], pipes: { "async": i3.AsyncPipe, "bbLocalize": i5.BbLocalize }, changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
397
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: BbTable, decorators: [{
|
|
398
|
+
type: Component,
|
|
399
|
+
args: [{ selector: 'bb-table', host: { 'class': 'bb-table' }, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, preserveWhitespaces: false, template: "<!--\r\n This is the header of the table. It can be a user\r\n defined custom header or just the default header.\r\n-->\r\n\r\n<header *ngIf=\"(header === true ? headerTemplate : header) as template\"\r\n class=\"bb-table-top-actions\">\r\n <ng-container *ngTemplateOutlet=\"template\"></ng-container>\r\n</header>\r\n\r\n<!--\r\n This is the table that contains the\r\n rows and columns.\r\n-->\r\n\r\n<div class=\"bb-table-wrapper\">\r\n <div *ngIf=\"isLoading$ | async\"\r\n class=\"bb-table-progress\">\r\n <div class=\"bb-table-indeterminate\"></div>\r\n </div>\r\n <table class=\"bb-table-container\">\r\n <thead>\r\n <tr>\r\n <ng-content select=\"bb-table-header-cell\"></ng-content>\r\n </tr>\r\n </thead>\r\n <tbody *ngIf=\"data$ | async as data; else isLoadingTemplate\"\r\n [ngSwitch]=\"data?.state\">\r\n <ng-container *ngSwitchCase=\"'success'\">\r\n <ng-container *ngIf=\"!!tableRowTemplate; else tableCellsTemplates\">\r\n <ng-container\r\n *ngTemplateOutlet=\"tableRowTemplate; context: {data: data?.result?.data || []}\"></ng-container>\r\n </ng-container>\r\n\r\n <ng-template #tableCellsTemplates>\r\n <tr *ngFor=\"let item of data?.result?.data; trackBy: trackByFn\">\r\n <ng-container *ngFor=\"let template of tableColumnTemplates\">\r\n <ng-container *ngTemplateOutlet=\"template; context: {item: item}\"></ng-container>\r\n </ng-container>\r\n </tr>\r\n </ng-template>\r\n </ng-container>\r\n\r\n <ng-container *ngSwitchCase=\"'empty'\">\r\n <ng-container\r\n *ngTemplateOutlet=\"errorTemplate; context: data\"></ng-container>\r\n </ng-container>\r\n\r\n <ng-container *ngSwitchCase=\"'error_datasource'\">\r\n <ng-container\r\n *ngTemplateOutlet=\"errorTemplate; context: data\"></ng-container>\r\n </ng-container>\r\n\r\n <ng-container *ngSwitchCase=\"'error_not_found'\">\r\n <ng-container\r\n *ngTemplateOutlet=\"errorTemplate; context: data\"></ng-container>\r\n </ng-container>\r\n\r\n <ng-container *ngSwitchCase=\"'error_server'\">\r\n <ng-container\r\n *ngTemplateOutlet=\"errorTemplate; context: data\"></ng-container>\r\n </ng-container>\r\n\r\n <ng-container *ngSwitchCase=\"'error_down'\">\r\n <ng-container\r\n *ngTemplateOutlet=\"errorTemplate; context: data\"></ng-container>\r\n </ng-container>\r\n\r\n <ng-container *ngSwitchDefault>\r\n <ng-container\r\n *ngTemplateOutlet=\"errorTemplate; context: data\"></ng-container>\r\n </ng-container>\r\n </tbody>\r\n </table>\r\n</div>\r\n\r\n<footer *ngIf=\"(footer === true ? footerTemplate : footer) as template\"\r\n class=\"bb-table-bottom-actions\">\r\n <ng-container *ngTemplateOutlet=\"template\"></ng-container>\r\n</footer>\r\n\r\n<ng-template #isLoadingTemplate>\r\n <tr>\r\n <td [attr.colspan]=\"headerCount\"\r\n class=\"bb-table-template\">\r\n <div class=\"bb-table-template-content\">\r\n {{ 'tables.loading' | bbLocalize }}\r\n </div>\r\n </td>\r\n </tr>\r\n</ng-template>\r\n\r\n<!--\r\n This is the template that will be used when the user has not\r\n supplied a custom header template.\r\n-->\r\n\r\n<ng-template #headerTemplate>\r\n <ng-content></ng-content>\r\n <bb-form-control>\r\n <input [formControl]=\"queryControl\"\r\n [placeholder]=\"'tables.search' | bbLocalize\"\r\n bbInput\r\n autocomplete=\"off\">\r\n <bb-icon *ngIf=\"queryControl?.value?.length <= 0; else closeButtonTemplate\"\r\n bbSuffix\r\n src=\"material:search\">\r\n </bb-icon>\r\n </bb-form-control>\r\n</ng-template>\r\n\r\n<!--\r\n This is the template that will be used when the user has not\r\n supplied a custom footer template.\r\n-->\r\n\r\n<ng-template #footerTemplate>\r\n <bb-form-control *ngIf=\"sizes?.length > 1\">\r\n <select [formControl]=\"pageSizeControl\"\r\n bbInput\r\n title=\"Sizes\">\r\n <option *ngFor=\"let item of sizes; trackBy: trackByValue\"\r\n [ngValue]=\"item\">\r\n {{ item }} / {{ 'tables.page' | bbLocalize }}\r\n </option>\r\n </select>\r\n </bb-form-control>\r\n\r\n <bb-table-pager [totalPages]=\"(data$ | async)?.result?.totalPages\"\r\n [formControl]=\"pageNumberControl\">\r\n </bb-table-pager>\r\n</ng-template>\r\n\r\n<!--\r\n This the template that will be used when the user\r\n has filled in some data in the query control.\r\n-->\r\n\r\n<ng-template #closeButtonTemplate>\r\n <button bbSuffix\r\n (click)=\"queryControl?.patchValue('')\"\r\n type=\"button\"\r\n class=\"bb-table-progress-close-query\">\r\n <bb-icon src=\"material:close\"></bb-icon>\r\n </button>\r\n</ng-template>\r\n\r\n<ng-template #errorTemplate let-state=\"state\" let-status=\"statusCode\">\r\n <tr>\r\n <td [attr.colspan]=\"headerCount\"\r\n class=\"bb-table-template\">\r\n <div class=\"bb-table-template-content\">\r\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"64\" height=\"41\">\r\n <g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(0 1)\">\r\n <ellipse cx=\"32\" cy=\"33\" fill=\"#F5F5F5\" rx=\"32\" ry=\"7\"></ellipse>\r\n <g fill-rule=\"nonzero\" stroke=\"#D9D9D9\">\r\n <path\r\n d=\"M55 12.7605604L44.8543047 1.25739633C44.3674414.47382661 43.6558789 0 42.9067617 0H21.0932383c-.7491172 0-1.4606797.47395025-1.947543 1.25739633L9 12.7605604V22h46v-9.2394396z\"></path>\r\n <path fill=\"#FAFAFA\"\r\n d=\"M41.6132813 15.9315c0-1.6056489.9936718-2.931266 2.2264179-2.9315H55v18.1371277C55 33.2589574 53.6793867 35 52.0504297 35H11.94957031C10.32052344 35 9 33.2588404 9 31.1371277V13h11.1603008c1.2327461 0 2.226418 1.3228085 2.226418 2.9284574v.0211809c0 1.6056489 1.0049921 2.9015426 2.2377382 2.9015426h14.751086c1.2327461 0 2.2377383-1.3078298 2.2377383-2.9134788V15.9315z\"></path>\r\n </g>\r\n </g>\r\n </svg>\r\n <span *ngIf=\"state as stateLabel\">{{ ('tables.' + stateLabel) | bbLocalize }}</span>\r\n <span *ngIf=\"status as statusCode\"\r\n class=\"bb-table-template-content-code\">(HTTP {{ statusCode }})</span>\r\n </div>\r\n </td>\r\n </tr>\r\n</ng-template>\r\n", styles: [".bb-table{width:100%;display:block;box-shadow:0 6px 6px -6px #0000001a}.bb-table.plain{box-shadow:none}.bb-table.plain>.bb-table-wrapper{border-top-left-radius:0;border-top-right-radius:0}.bb-table-wrapper{overflow-x:auto;position:relative;background-color:#fff;border-top-left-radius:4px;border-top-right-radius:4px}.bb-table-container{width:100%}.bb-table-container td{border-bottom:1px solid #d8d8d8}.bb-table-top-actions{display:flex;flex-wrap:wrap;flex-direction:column;padding:20px 20px 10px;background-color:#fff;justify-content:flex-end;border-top-left-radius:4px;border-top-right-radius:4px;border-bottom:1px solid #d8d8d8}.bb-table-top-actions>*{margin-left:0;margin-bottom:10px}.bb-table-top-actions+.bb-table-wrapper{border-radius:0}.bb-table-bottom-actions{height:60px;display:flex;padding:0 20px;overflow-x:auto;align-items:center;background-color:#fff;border-bottom-left-radius:4px;border-bottom-right-radius:4px}.bb-table-template{border:none;background-color:#f5f5f5;border-bottom:1px solid #d8d8d8}.bb-table-template-content{padding:20px;display:flex;color:#3d464d;font-size:14px;line-height:1.2;font-weight:400;min-height:140px;text-align:center;align-items:center;flex-direction:column;justify-content:center}.bb-table-template-content>svg{margin-bottom:12px}.bb-table-template-content-code{opacity:.5;margin-top:5px;display:inline-block}.bb-table-progress{top:0;left:0;right:0;opacity:0;width:100%;height:4px;display:block;overflow:hidden;position:absolute;background-color:#2f408b4d;animation:fadeIn .25s cubic-bezier(0,0,.2,1) .1s forwards}.bb-table-progress .bb-table-indeterminate{background-color:#2f408b}.bb-table-progress .bb-table-indeterminate:before{top:0;left:0;bottom:0;content:\"\";position:absolute;will-change:left,right;background-color:inherit;animation:indeterminate 2.1s cubic-bezier(.65,.815,.735,.395) infinite}.bb-table-progress .bb-table-indeterminate:after{top:0;left:0;bottom:0;content:\"\";position:absolute;animation-delay:1.15s;will-change:left,right;background-color:inherit;animation:indeterminate-short 2.1s cubic-bezier(.165,.84,.44,1) infinite}.bb-table-progress-close-query{padding:0;border:none;border-radius:4px;background-color:transparent;transition:background-color .25s cubic-bezier(0,0,.2,1)}.bb-table-progress-close-query:hover{background-color:#00000014}.bb-table-progress-close-query:focus{background-color:#0000001f}.bb-table-progress-close-query:active{background-color:#00000029}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}@keyframes indeterminate{0%{left:-35%;right:100%}60%{left:100%;right:-90%}to{left:100%;right:-90%}}@keyframes indeterminate-short{0%{left:-200%;right:100%}60%{left:107%;right:-8%}to{left:107%;right:-8%}}@media only screen and (min-width: 768px){.bb-table-top-actions{flex-direction:row}.bb-table-top-actions>*:not(:first-child){margin-left:10px;margin-bottom:10px}}\n"] }]
|
|
400
|
+
}], propDecorators: { tableColumnTemplates: [{
|
|
401
|
+
type: ContentChildren,
|
|
402
|
+
args: [BbTableColumnDef, { read: TemplateRef }]
|
|
403
|
+
}], tableRowTemplate: [{
|
|
404
|
+
type: ContentChild,
|
|
405
|
+
args: [BbTableRowDef, { read: TemplateRef, static: false }]
|
|
406
|
+
}], identifier: [{
|
|
407
|
+
type: Input
|
|
408
|
+
}], dataSource: [{
|
|
409
|
+
type: Input
|
|
410
|
+
}], queryFields: [{
|
|
411
|
+
type: Input
|
|
412
|
+
}], sortingStrategy: [{
|
|
413
|
+
type: Input
|
|
414
|
+
}], header: [{
|
|
415
|
+
type: Input
|
|
416
|
+
}], footer: [{
|
|
417
|
+
type: Input
|
|
418
|
+
}], sizes: [{
|
|
419
|
+
type: Input
|
|
420
420
|
}] } });
|
|
421
421
|
|
|
422
|
-
class BbTableCell {
|
|
423
|
-
}
|
|
424
|
-
BbTableCell.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.
|
|
425
|
-
BbTableCell.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.
|
|
426
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.
|
|
427
|
-
type: Component,
|
|
428
|
-
args: [{ selector: 'bb-table-cell', changeDetection: ChangeDetectionStrategy.OnPush, host: { 'class': 'bb-table-cell' }, encapsulation: ViewEncapsulation.None, preserveWhitespaces: false, template: "<div>\n <ng-content></ng-content>\n</div>", styles: [".bb-table-cell{color:#848f99;font-size:14px;text-align:left;line-height:1.2;font-weight:400;padding:12px 20px;display:table-cell;word-wrap:break-word;vertical-align:middle;background-color:#f5f5f5;border-bottom:1px solid #d8d8d8}.bb-table-cell:not(:last-child){border-right:1px solid #d8d8d8}.bb-table-cell.fit{width:1%;white-space:nowrap}.bb-table-cell.left{text-align:left}.bb-table-cell.center{text-align:center}.bb-table-cell.right{text-align:right}\n"] }]
|
|
422
|
+
class BbTableCell {
|
|
423
|
+
}
|
|
424
|
+
BbTableCell.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: BbTableCell, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
425
|
+
BbTableCell.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.6", type: BbTableCell, selector: "bb-table-cell", host: { classAttribute: "bb-table-cell" }, ngImport: i0, template: "<div>\r\n <ng-content></ng-content>\r\n</div>", styles: [".bb-table-cell{color:#848f99;font-size:14px;text-align:left;line-height:1.2;font-weight:400;padding:12px 20px;display:table-cell;word-wrap:break-word;vertical-align:middle;background-color:#f5f5f5;border-bottom:1px solid #d8d8d8}.bb-table-cell:not(:last-child){border-right:1px solid #d8d8d8}.bb-table-cell.fit{width:1%;white-space:nowrap}.bb-table-cell.left{text-align:left}.bb-table-cell.center{text-align:center}.bb-table-cell.right{text-align:right}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
426
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: BbTableCell, decorators: [{
|
|
427
|
+
type: Component,
|
|
428
|
+
args: [{ selector: 'bb-table-cell', changeDetection: ChangeDetectionStrategy.OnPush, host: { 'class': 'bb-table-cell' }, encapsulation: ViewEncapsulation.None, preserveWhitespaces: false, template: "<div>\r\n <ng-content></ng-content>\r\n</div>", styles: [".bb-table-cell{color:#848f99;font-size:14px;text-align:left;line-height:1.2;font-weight:400;padding:12px 20px;display:table-cell;word-wrap:break-word;vertical-align:middle;background-color:#f5f5f5;border-bottom:1px solid #d8d8d8}.bb-table-cell:not(:last-child){border-right:1px solid #d8d8d8}.bb-table-cell.fit{width:1%;white-space:nowrap}.bb-table-cell.left{text-align:left}.bb-table-cell.center{text-align:center}.bb-table-cell.right{text-align:right}\n"] }]
|
|
429
429
|
}] });
|
|
430
430
|
|
|
431
|
-
class BbTableHeaderCellBase {
|
|
432
|
-
}
|
|
433
|
-
const BbTableHeaderCellMixinBase = mixinDisabled(BbTableHeaderCellBase);
|
|
434
|
-
class BbTableHeaderCell extends BbTableHeaderCellMixinBase {
|
|
435
|
-
constructor(_table, _name) {
|
|
436
|
-
super();
|
|
437
|
-
this._table = _table;
|
|
438
|
-
this._name = _name;
|
|
439
|
-
// Constants.
|
|
440
|
-
this._sortDirections = ['none', 'asc', 'desc'];
|
|
441
|
-
this._control = new FormControl(this._sortDirections[0]);
|
|
442
|
-
this.logWarning = (message) => {
|
|
443
|
-
console && console.warn && console.warn(message);
|
|
444
|
-
};
|
|
445
|
-
}
|
|
446
|
-
// Sort.
|
|
447
|
-
set sort(value) {
|
|
448
|
-
// Check if the new value is a valid value.
|
|
449
|
-
if (!this._sortDirections.includes(value)) {
|
|
450
|
-
return;
|
|
451
|
-
}
|
|
452
|
-
// Set the value.
|
|
453
|
-
this._control.setValue(value);
|
|
454
|
-
}
|
|
455
|
-
get sort() {
|
|
456
|
-
return this._control.value;
|
|
457
|
-
}
|
|
458
|
-
ngOnInit() {
|
|
459
|
-
// Validate that the name and table are set.
|
|
460
|
-
this._table?.setHeaderCount?.(1);
|
|
461
|
-
if (!this._table || !this._name) {
|
|
462
|
-
return;
|
|
463
|
-
}
|
|
464
|
-
// Check if the control already exists in the table.
|
|
465
|
-
if (this._table.sortControl?.contains(this._name)) {
|
|
466
|
-
this.disabled = true;
|
|
467
|
-
return this.logWarning(`BbTableHeaderCell: The name "${this._name}" is not unique in the table; Control was not registered.`);
|
|
468
|
-
}
|
|
469
|
-
// Register the header cell with the table.
|
|
470
|
-
this._table.sortControl?.addControl(this._name, this._control);
|
|
471
|
-
// Get all the value changes.
|
|
472
|
-
this.valueChanges$ = this._control.valueChanges.pipe(startWith(this._control.value));
|
|
473
|
-
}
|
|
474
|
-
ngOnDestroy() {
|
|
475
|
-
this._table?.setHeaderCount?.(-1);
|
|
476
|
-
// Validate that the name and table are set.
|
|
477
|
-
if (!this._table || !this._name) {
|
|
478
|
-
return;
|
|
479
|
-
}
|
|
480
|
-
// Un-register the header cell with the table.
|
|
481
|
-
if (this._table?.sortControl?.contains(this._name)) {
|
|
482
|
-
this._table?.sortControl?.removeControl(this._name);
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
get isDisabled() {
|
|
486
|
-
return this.disabled || !this._name;
|
|
487
|
-
}
|
|
488
|
-
onClick() {
|
|
489
|
-
// Check if the header cell is disabled.
|
|
490
|
-
if (this.isDisabled) {
|
|
491
|
-
return;
|
|
492
|
-
}
|
|
493
|
-
// Find the index of the current sort and
|
|
494
|
-
// create the new index.
|
|
495
|
-
const index = this._sortDirections.findIndex(item => item === this._control.value);
|
|
496
|
-
const newIndex = (index + 1) % this._sortDirections.length;
|
|
497
|
-
const newSort = this._sortDirections[newIndex];
|
|
498
|
-
// Set the new sort.
|
|
499
|
-
return this.updateTableAndHeaderCell(newSort);
|
|
500
|
-
}
|
|
501
|
-
updateTableAndHeaderCell(value) {
|
|
502
|
-
// Check if the new value is a valid value.
|
|
503
|
-
if (!this._sortDirections.includes(value)) {
|
|
504
|
-
return;
|
|
505
|
-
}
|
|
506
|
-
// Validate the table exists.
|
|
507
|
-
if (!this._table) {
|
|
508
|
-
return this._control.setValue(value);
|
|
509
|
-
}
|
|
510
|
-
// Handle the single sorting strategy.
|
|
511
|
-
if (this._table.sortingStrategy === 'single') {
|
|
512
|
-
return this.handleSingleSortingStrategy(value);
|
|
513
|
-
}
|
|
514
|
-
// Default case when no other strategy
|
|
515
|
-
// is used.
|
|
516
|
-
return this._control.setValue(value);
|
|
517
|
-
}
|
|
518
|
-
handleSingleSortingStrategy(value) {
|
|
519
|
-
// Get the sort control.
|
|
520
|
-
const control = this._table.sortControl;
|
|
521
|
-
// Set each value to false since we only want to
|
|
522
|
-
// sort on one property at a time with this strategy.
|
|
523
|
-
const newValue = Object.keys(control.controls).reduce((previous, current) => {
|
|
524
|
-
previous[current] = current === this._name ? value : 'none';
|
|
525
|
-
return previous;
|
|
526
|
-
}, {});
|
|
527
|
-
// Patch the entire sort value.
|
|
528
|
-
this._table?.sortControl?.patchValue(newValue);
|
|
529
|
-
}
|
|
530
|
-
}
|
|
531
|
-
BbTableHeaderCell.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.
|
|
532
|
-
BbTableHeaderCell.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.
|
|
533
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.
|
|
534
|
-
type: Component,
|
|
535
|
-
args: [{ selector: 'bb-table-header-cell', changeDetection: ChangeDetectionStrategy.OnPush, host: {
|
|
536
|
-
'class': 'bb-table-header-cell',
|
|
537
|
-
'[class.disabled]': 'isDisabled'
|
|
538
|
-
}, inputs: ['disabled'], encapsulation: ViewEncapsulation.None, preserveWhitespaces: false, template: "<!-- The content. -->\n<ng-content></ng-content>\n\n<!-- The indicator for the sort direction. -->\n<ng-container *ngIf=\"valueChanges$ | async as value\">\n <button *ngIf=\"!isDisabled\"\n [class.asc]=\"value === 'asc'\"\n [class.desc]=\"value === 'desc'\"\n class=\"bb-table-header-cell-toggle\"\n type=\"button\"></button>\n</ng-container>\n", styles: [".bb-table-header-cell{height:50px;color:#212529;cursor:pointer;font-size:16px;font-weight:500;-webkit-user-select:none;user-select:none;padding:10px 20px;position:relative;display:table-cell;vertical-align:middle;border-bottom:1px solid #d8d8d8}.bb-table-header-cell:active>.bb-table-header-cell-toggle{background-color:#00000014}.bb-table-header-cell:not(.disabled){padding-right:52px}.bb-table-header-cell.fit{width:1%;white-space:nowrap}.bb-table-header-cell.left{text-align:left}.bb-table-header-cell.center{text-align:center}.bb-table-header-cell.right{text-align:right}.bb-table-header-cell.disabled{cursor:default;pointer-events:none}.bb-table-header-cell-toggle{top:50%;right:14px;width:22px;border:none;height:22px;margin-left:auto;position:absolute;border-radius:4px;transform:translateY(-50%);background-position:center;background-repeat:no-repeat;background-color:transparent;transition:background-color .2s cubic-bezier(0,0,.2,1);background-image:url('data:image/svg+xml,%3Csvg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 9 15\" width=\"9\" height=\"15\"%3E%3Cpath fill=\"%23dcdcdc\" d=\"M4.5 0L0 7h9z\"%3E%3C/path%3E%3Cpath fill=\"%23dcdcdc\" d=\"M4.5 15L9 8H0z\"%3E%3C/path%3E%3C/svg%3E')}.bb-table-header-cell-toggle.desc{background-image:url('data:image/svg+xml,%3Csvg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 9 15\" width=\"9\" height=\"15\"%3E%3Cpath fill=\"%23dcdcdc\" d=\"M4.5 0L0 7h9z\"%3E%3C/path%3E%3Cpath fill=\"black\" d=\"M4.5 15L9 8H0z\"%3E%3C/path%3E%3C/svg%3E')}.bb-table-header-cell-toggle.asc{background-image:url('data:image/svg+xml,%3Csvg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 9 15\" width=\"9\" height=\"15\"%3E%3Cpath fill=\"black\" d=\"M4.5 0L0 7h9z\"%3E%3C/path%3E%3Cpath fill=\"%23dcdcdc\" d=\"M4.5 15L9 8H0z\"%3E%3C/path%3E%3C/svg%3E')}\n"] }]
|
|
539
|
-
}], ctorParameters: function () { return [{ type: BbTable, decorators: [{
|
|
540
|
-
type: Optional
|
|
541
|
-
}, {
|
|
542
|
-
type: Host
|
|
543
|
-
}] }, { type: undefined, decorators: [{
|
|
544
|
-
type: Optional
|
|
545
|
-
}, {
|
|
546
|
-
type: Attribute,
|
|
547
|
-
args: ['name']
|
|
548
|
-
}] }]; }, propDecorators: { sort: [{
|
|
549
|
-
type: Input
|
|
550
|
-
}], onClick: [{
|
|
551
|
-
type: HostListener,
|
|
552
|
-
args: ['click']
|
|
431
|
+
class BbTableHeaderCellBase {
|
|
432
|
+
}
|
|
433
|
+
const BbTableHeaderCellMixinBase = mixinDisabled(BbTableHeaderCellBase);
|
|
434
|
+
class BbTableHeaderCell extends BbTableHeaderCellMixinBase {
|
|
435
|
+
constructor(_table, _name) {
|
|
436
|
+
super();
|
|
437
|
+
this._table = _table;
|
|
438
|
+
this._name = _name;
|
|
439
|
+
// Constants.
|
|
440
|
+
this._sortDirections = ['none', 'asc', 'desc'];
|
|
441
|
+
this._control = new FormControl(this._sortDirections[0]);
|
|
442
|
+
this.logWarning = (message) => {
|
|
443
|
+
console && console.warn && console.warn(message);
|
|
444
|
+
};
|
|
445
|
+
}
|
|
446
|
+
// Sort.
|
|
447
|
+
set sort(value) {
|
|
448
|
+
// Check if the new value is a valid value.
|
|
449
|
+
if (!this._sortDirections.includes(value)) {
|
|
450
|
+
return;
|
|
451
|
+
}
|
|
452
|
+
// Set the value.
|
|
453
|
+
this._control.setValue(value);
|
|
454
|
+
}
|
|
455
|
+
get sort() {
|
|
456
|
+
return this._control.value;
|
|
457
|
+
}
|
|
458
|
+
ngOnInit() {
|
|
459
|
+
// Validate that the name and table are set.
|
|
460
|
+
this._table?.setHeaderCount?.(1);
|
|
461
|
+
if (!this._table || !this._name) {
|
|
462
|
+
return;
|
|
463
|
+
}
|
|
464
|
+
// Check if the control already exists in the table.
|
|
465
|
+
if (this._table.sortControl?.contains(this._name)) {
|
|
466
|
+
this.disabled = true;
|
|
467
|
+
return this.logWarning(`BbTableHeaderCell: The name "${this._name}" is not unique in the table; Control was not registered.`);
|
|
468
|
+
}
|
|
469
|
+
// Register the header cell with the table.
|
|
470
|
+
this._table.sortControl?.addControl(this._name, this._control);
|
|
471
|
+
// Get all the value changes.
|
|
472
|
+
this.valueChanges$ = this._control.valueChanges.pipe(startWith(this._control.value));
|
|
473
|
+
}
|
|
474
|
+
ngOnDestroy() {
|
|
475
|
+
this._table?.setHeaderCount?.(-1);
|
|
476
|
+
// Validate that the name and table are set.
|
|
477
|
+
if (!this._table || !this._name) {
|
|
478
|
+
return;
|
|
479
|
+
}
|
|
480
|
+
// Un-register the header cell with the table.
|
|
481
|
+
if (this._table?.sortControl?.contains(this._name)) {
|
|
482
|
+
this._table?.sortControl?.removeControl(this._name);
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
get isDisabled() {
|
|
486
|
+
return this.disabled || !this._name;
|
|
487
|
+
}
|
|
488
|
+
onClick() {
|
|
489
|
+
// Check if the header cell is disabled.
|
|
490
|
+
if (this.isDisabled) {
|
|
491
|
+
return;
|
|
492
|
+
}
|
|
493
|
+
// Find the index of the current sort and
|
|
494
|
+
// create the new index.
|
|
495
|
+
const index = this._sortDirections.findIndex(item => item === this._control.value);
|
|
496
|
+
const newIndex = (index + 1) % this._sortDirections.length;
|
|
497
|
+
const newSort = this._sortDirections[newIndex];
|
|
498
|
+
// Set the new sort.
|
|
499
|
+
return this.updateTableAndHeaderCell(newSort);
|
|
500
|
+
}
|
|
501
|
+
updateTableAndHeaderCell(value) {
|
|
502
|
+
// Check if the new value is a valid value.
|
|
503
|
+
if (!this._sortDirections.includes(value)) {
|
|
504
|
+
return;
|
|
505
|
+
}
|
|
506
|
+
// Validate the table exists.
|
|
507
|
+
if (!this._table) {
|
|
508
|
+
return this._control.setValue(value);
|
|
509
|
+
}
|
|
510
|
+
// Handle the single sorting strategy.
|
|
511
|
+
if (this._table.sortingStrategy === 'single') {
|
|
512
|
+
return this.handleSingleSortingStrategy(value);
|
|
513
|
+
}
|
|
514
|
+
// Default case when no other strategy
|
|
515
|
+
// is used.
|
|
516
|
+
return this._control.setValue(value);
|
|
517
|
+
}
|
|
518
|
+
handleSingleSortingStrategy(value) {
|
|
519
|
+
// Get the sort control.
|
|
520
|
+
const control = this._table.sortControl;
|
|
521
|
+
// Set each value to false since we only want to
|
|
522
|
+
// sort on one property at a time with this strategy.
|
|
523
|
+
const newValue = Object.keys(control.controls).reduce((previous, current) => {
|
|
524
|
+
previous[current] = current === this._name ? value : 'none';
|
|
525
|
+
return previous;
|
|
526
|
+
}, {});
|
|
527
|
+
// Patch the entire sort value.
|
|
528
|
+
this._table?.sortControl?.patchValue(newValue);
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
BbTableHeaderCell.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: BbTableHeaderCell, deps: [{ token: BbTable, host: true, optional: true }, { token: 'name', attribute: true, optional: true }], target: i0.ɵɵFactoryTarget.Component });
|
|
532
|
+
BbTableHeaderCell.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.6", type: BbTableHeaderCell, selector: "bb-table-header-cell", inputs: { disabled: "disabled", sort: "sort" }, host: { listeners: { "click": "onClick()" }, properties: { "class.disabled": "isDisabled" }, classAttribute: "bb-table-header-cell" }, usesInheritance: true, ngImport: i0, template: "<!-- The content. -->\r\n<ng-content></ng-content>\r\n\r\n<!-- The indicator for the sort direction. -->\r\n<ng-container *ngIf=\"valueChanges$ | async as value\">\r\n <button *ngIf=\"!isDisabled\"\r\n [class.asc]=\"value === 'asc'\"\r\n [class.desc]=\"value === 'desc'\"\r\n class=\"bb-table-header-cell-toggle\"\r\n type=\"button\"></button>\r\n</ng-container>\r\n", styles: [".bb-table-header-cell{height:50px;color:#212529;cursor:pointer;font-size:16px;font-weight:500;-webkit-user-select:none;user-select:none;padding:10px 20px;position:relative;display:table-cell;vertical-align:middle;border-bottom:1px solid #d8d8d8}.bb-table-header-cell:active>.bb-table-header-cell-toggle{background-color:#00000014}.bb-table-header-cell:not(.disabled){padding-right:52px}.bb-table-header-cell.fit{width:1%;white-space:nowrap}.bb-table-header-cell.left{text-align:left}.bb-table-header-cell.center{text-align:center}.bb-table-header-cell.right{text-align:right}.bb-table-header-cell.disabled{cursor:default;pointer-events:none}.bb-table-header-cell-toggle{top:50%;right:14px;width:22px;border:none;height:22px;margin-left:auto;position:absolute;border-radius:4px;transform:translateY(-50%);background-position:center;background-repeat:no-repeat;background-color:transparent;transition:background-color .2s cubic-bezier(0,0,.2,1);background-image:url('data:image/svg+xml,%3Csvg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 9 15\" width=\"9\" height=\"15\"%3E%3Cpath fill=\"%23dcdcdc\" d=\"M4.5 0L0 7h9z\"%3E%3C/path%3E%3Cpath fill=\"%23dcdcdc\" d=\"M4.5 15L9 8H0z\"%3E%3C/path%3E%3C/svg%3E')}.bb-table-header-cell-toggle.desc{background-image:url('data:image/svg+xml,%3Csvg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 9 15\" width=\"9\" height=\"15\"%3E%3Cpath fill=\"%23dcdcdc\" d=\"M4.5 0L0 7h9z\"%3E%3C/path%3E%3Cpath fill=\"black\" d=\"M4.5 15L9 8H0z\"%3E%3C/path%3E%3C/svg%3E')}.bb-table-header-cell-toggle.asc{background-image:url('data:image/svg+xml,%3Csvg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 9 15\" width=\"9\" height=\"15\"%3E%3Cpath fill=\"black\" d=\"M4.5 0L0 7h9z\"%3E%3C/path%3E%3Cpath fill=\"%23dcdcdc\" d=\"M4.5 15L9 8H0z\"%3E%3C/path%3E%3C/svg%3E')}\n"], directives: [{ type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], pipes: { "async": i3.AsyncPipe }, changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
533
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: BbTableHeaderCell, decorators: [{
|
|
534
|
+
type: Component,
|
|
535
|
+
args: [{ selector: 'bb-table-header-cell', changeDetection: ChangeDetectionStrategy.OnPush, host: {
|
|
536
|
+
'class': 'bb-table-header-cell',
|
|
537
|
+
'[class.disabled]': 'isDisabled'
|
|
538
|
+
}, inputs: ['disabled'], encapsulation: ViewEncapsulation.None, preserveWhitespaces: false, template: "<!-- The content. -->\r\n<ng-content></ng-content>\r\n\r\n<!-- The indicator for the sort direction. -->\r\n<ng-container *ngIf=\"valueChanges$ | async as value\">\r\n <button *ngIf=\"!isDisabled\"\r\n [class.asc]=\"value === 'asc'\"\r\n [class.desc]=\"value === 'desc'\"\r\n class=\"bb-table-header-cell-toggle\"\r\n type=\"button\"></button>\r\n</ng-container>\r\n", styles: [".bb-table-header-cell{height:50px;color:#212529;cursor:pointer;font-size:16px;font-weight:500;-webkit-user-select:none;user-select:none;padding:10px 20px;position:relative;display:table-cell;vertical-align:middle;border-bottom:1px solid #d8d8d8}.bb-table-header-cell:active>.bb-table-header-cell-toggle{background-color:#00000014}.bb-table-header-cell:not(.disabled){padding-right:52px}.bb-table-header-cell.fit{width:1%;white-space:nowrap}.bb-table-header-cell.left{text-align:left}.bb-table-header-cell.center{text-align:center}.bb-table-header-cell.right{text-align:right}.bb-table-header-cell.disabled{cursor:default;pointer-events:none}.bb-table-header-cell-toggle{top:50%;right:14px;width:22px;border:none;height:22px;margin-left:auto;position:absolute;border-radius:4px;transform:translateY(-50%);background-position:center;background-repeat:no-repeat;background-color:transparent;transition:background-color .2s cubic-bezier(0,0,.2,1);background-image:url('data:image/svg+xml,%3Csvg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 9 15\" width=\"9\" height=\"15\"%3E%3Cpath fill=\"%23dcdcdc\" d=\"M4.5 0L0 7h9z\"%3E%3C/path%3E%3Cpath fill=\"%23dcdcdc\" d=\"M4.5 15L9 8H0z\"%3E%3C/path%3E%3C/svg%3E')}.bb-table-header-cell-toggle.desc{background-image:url('data:image/svg+xml,%3Csvg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 9 15\" width=\"9\" height=\"15\"%3E%3Cpath fill=\"%23dcdcdc\" d=\"M4.5 0L0 7h9z\"%3E%3C/path%3E%3Cpath fill=\"black\" d=\"M4.5 15L9 8H0z\"%3E%3C/path%3E%3C/svg%3E')}.bb-table-header-cell-toggle.asc{background-image:url('data:image/svg+xml,%3Csvg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 9 15\" width=\"9\" height=\"15\"%3E%3Cpath fill=\"black\" d=\"M4.5 0L0 7h9z\"%3E%3C/path%3E%3Cpath fill=\"%23dcdcdc\" d=\"M4.5 15L9 8H0z\"%3E%3C/path%3E%3C/svg%3E')}\n"] }]
|
|
539
|
+
}], ctorParameters: function () { return [{ type: BbTable, decorators: [{
|
|
540
|
+
type: Optional
|
|
541
|
+
}, {
|
|
542
|
+
type: Host
|
|
543
|
+
}] }, { type: undefined, decorators: [{
|
|
544
|
+
type: Optional
|
|
545
|
+
}, {
|
|
546
|
+
type: Attribute,
|
|
547
|
+
args: ['name']
|
|
548
|
+
}] }]; }, propDecorators: { sort: [{
|
|
549
|
+
type: Input
|
|
550
|
+
}], onClick: [{
|
|
551
|
+
type: HostListener,
|
|
552
|
+
args: ['click']
|
|
553
553
|
}] } });
|
|
554
554
|
|
|
555
|
-
const DECLARATIONS_EXPORTS = [
|
|
556
|
-
BbTable,
|
|
557
|
-
BbTableColumnDef,
|
|
558
|
-
BbTableRowDef,
|
|
559
|
-
BbTableHeaderCell,
|
|
560
|
-
BbTableCell,
|
|
561
|
-
BbTablePager
|
|
562
|
-
];
|
|
563
|
-
class TableModule {
|
|
564
|
-
}
|
|
565
|
-
TableModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.
|
|
566
|
-
TableModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.
|
|
567
|
-
BbTableColumnDef,
|
|
568
|
-
BbTableRowDef,
|
|
569
|
-
BbTableHeaderCell,
|
|
570
|
-
BbTableCell,
|
|
571
|
-
BbTablePager], imports: [CommonModule, ReactiveFormsModule, ElementsModule, LocalizeModule], exports: [BbTable,
|
|
572
|
-
BbTableColumnDef,
|
|
573
|
-
BbTableRowDef,
|
|
574
|
-
BbTableHeaderCell,
|
|
575
|
-
BbTableCell,
|
|
576
|
-
BbTablePager] });
|
|
577
|
-
TableModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.
|
|
578
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.
|
|
579
|
-
type: NgModule,
|
|
580
|
-
args: [{
|
|
581
|
-
imports: [CommonModule, ReactiveFormsModule, ElementsModule, LocalizeModule],
|
|
582
|
-
declarations: [...DECLARATIONS_EXPORTS],
|
|
583
|
-
exports: [...DECLARATIONS_EXPORTS]
|
|
584
|
-
}]
|
|
555
|
+
const DECLARATIONS_EXPORTS = [
|
|
556
|
+
BbTable,
|
|
557
|
+
BbTableColumnDef,
|
|
558
|
+
BbTableRowDef,
|
|
559
|
+
BbTableHeaderCell,
|
|
560
|
+
BbTableCell,
|
|
561
|
+
BbTablePager
|
|
562
|
+
];
|
|
563
|
+
class TableModule {
|
|
564
|
+
}
|
|
565
|
+
TableModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: TableModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
566
|
+
TableModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: TableModule, declarations: [BbTable,
|
|
567
|
+
BbTableColumnDef,
|
|
568
|
+
BbTableRowDef,
|
|
569
|
+
BbTableHeaderCell,
|
|
570
|
+
BbTableCell,
|
|
571
|
+
BbTablePager], imports: [CommonModule, ReactiveFormsModule, ElementsModule, LocalizeModule], exports: [BbTable,
|
|
572
|
+
BbTableColumnDef,
|
|
573
|
+
BbTableRowDef,
|
|
574
|
+
BbTableHeaderCell,
|
|
575
|
+
BbTableCell,
|
|
576
|
+
BbTablePager] });
|
|
577
|
+
TableModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: TableModule, imports: [[CommonModule, ReactiveFormsModule, ElementsModule, LocalizeModule]] });
|
|
578
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.6", ngImport: i0, type: TableModule, decorators: [{
|
|
579
|
+
type: NgModule,
|
|
580
|
+
args: [{
|
|
581
|
+
imports: [CommonModule, ReactiveFormsModule, ElementsModule, LocalizeModule],
|
|
582
|
+
declarations: [...DECLARATIONS_EXPORTS],
|
|
583
|
+
exports: [...DECLARATIONS_EXPORTS]
|
|
584
|
+
}]
|
|
585
585
|
}] });
|
|
586
586
|
|
|
587
|
-
/**
|
|
588
|
-
* Generated bundle index. Do not edit.
|
|
587
|
+
/**
|
|
588
|
+
* Generated bundle index. Do not edit.
|
|
589
589
|
*/
|
|
590
590
|
|
|
591
591
|
export { BbTable, BbTableCell, BbTableColumnDef, BbTableHeaderCell, BbTablePager, BbTableRowDef, DataSource, DataSourceRequest, GenericDataSource, TableModule };
|