@energycap/components 0.40.2-rxjs-7-upgrade.20241219-1425 → 0.41.1-ECAP-27592-angular-17.20241219-1718
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/{esm2020 → esm2022}/energycap-components.mjs +4 -4
- package/{esm2020 → esm2022}/lib/components.module.mjs +418 -418
- package/{esm2020 → esm2022}/lib/controls/banner/banner.component.mjs +109 -109
- package/{esm2020 → esm2022}/lib/controls/button/button.component.mjs +106 -106
- package/{esm2020 → esm2022}/lib/controls/button/copy-button-base.directive.mjs +67 -67
- package/{esm2020 → esm2022}/lib/controls/button/copy-button.directive.mjs +28 -28
- package/{esm2020 → esm2022}/lib/controls/button/copy-table-button.directive.mjs +43 -43
- package/{esm2020 → esm2022}/lib/controls/calendar/calendar-item.component.mjs +59 -59
- package/{esm2020 → esm2022}/lib/controls/calendar/calendar.component.mjs +200 -200
- package/{esm2020 → esm2022}/lib/controls/calendar/calendar.types.mjs +3 -3
- package/{esm2020 → esm2022}/lib/controls/checkbox/checkbox.component.mjs +140 -140
- package/{esm2020 → esm2022}/lib/controls/collapsible-toggle/collapsible-toggle.component.mjs +38 -38
- package/{esm2020 → esm2022}/lib/controls/combobox/combobox.component.mjs +879 -879
- package/{esm2020 → esm2022}/lib/controls/date-input/date-input.component.mjs +256 -256
- package/{esm2020 → esm2022}/lib/controls/dropdown/dropdown.component.mjs +243 -243
- package/{esm2020 → esm2022}/lib/controls/file-upload/file-upload.component.mjs +261 -261
- package/{esm2020 → esm2022}/lib/controls/form-control/form-control.component.mjs +104 -104
- package/{esm2020 → esm2022}/lib/controls/form-control-base.mjs +151 -151
- package/{esm2020 → esm2022}/lib/controls/form-control-label/form-control-label.component.mjs +136 -136
- package/{esm2020 → esm2022}/lib/controls/form-group/form-group.component.mjs +261 -261
- package/{esm2020 → esm2022}/lib/controls/help-popover/help-popover.component.mjs +31 -31
- package/{esm2020 → esm2022}/lib/controls/item-picker/item-picker.component.mjs +329 -329
- package/{esm2020 → esm2022}/lib/controls/link-button/link-button.component.mjs +11 -11
- package/{esm2020 → esm2022}/lib/controls/menu/menu.component.mjs +485 -485
- package/{esm2020 → esm2022}/lib/controls/navigation/link-item.mjs +1 -1
- package/{esm2020 → esm2022}/lib/controls/navigation/nav-group.mjs +38 -38
- package/{esm2020 → esm2022}/lib/controls/navigation/nav-item-active.directive.mjs +92 -92
- package/{esm2020 → esm2022}/lib/controls/navigation/nav-item.mjs +1 -1
- package/{esm2020 → esm2022}/lib/controls/numericbox/numericbox.component.mjs +372 -372
- package/{esm2020 → esm2022}/lib/controls/popover/popover.component.mjs +117 -117
- package/{esm2020 → esm2022}/lib/controls/radio-button/radio-button-option.mjs +2 -2
- package/{esm2020 → esm2022}/lib/controls/radio-button/radio-button.component.mjs +82 -82
- package/{esm2020 → esm2022}/lib/controls/select/select.component.mjs +88 -88
- package/{esm2020 → esm2022}/lib/controls/tabs/tabs.component.mjs +47 -47
- package/{esm2020 → esm2022}/lib/controls/textbox/textbox.component.mjs +155 -155
- package/{esm2020 → esm2022}/lib/core/cache.service.mjs +105 -105
- package/esm2022/lib/core/custom-validators.mjs +29 -0
- package/esm2022/lib/core/date-time-helper.mjs +220 -0
- package/{esm2020 → esm2022}/lib/core/error.service.mjs +61 -61
- package/{esm2020 → esm2022}/lib/core/router-helper.service.mjs +111 -111
- package/{esm2020 → esm2022}/lib/core/scroll.service.mjs +89 -89
- package/{esm2020 → esm2022}/lib/core/telemetry-tracker.service.mjs +16 -16
- package/{esm2020 → esm2022}/lib/core/telemetry.service.mjs +38 -38
- package/{esm2020 → esm2022}/lib/core/validation-message.service.mjs +185 -185
- package/{esm2020 → esm2022}/lib/core/validation-patterns.mjs +30 -30
- package/{esm2020 → esm2022}/lib/core/window.service.mjs +186 -186
- package/{esm2020 → esm2022}/lib/display/app-bar/app-bar.component.mjs +46 -46
- package/esm2022/lib/display/avatar/avatar.component.mjs +67 -0
- package/{esm2020 → esm2022}/lib/display/avatar/avatar.service.mjs +64 -64
- package/{esm2020 → esm2022}/lib/display/confirm/confirm.component.mjs +168 -168
- package/{esm2020 → esm2022}/lib/display/dialog/dialog-content.mjs +1 -1
- package/{esm2020 → esm2022}/lib/display/dialog/dialog-group/dialog-group.component.mjs +63 -63
- package/{esm2020 → esm2022}/lib/display/dialog/dialog-types.mjs +76 -76
- package/{esm2020 → esm2022}/lib/display/dialog/dialog.component.mjs +281 -281
- package/{esm2020 → esm2022}/lib/display/dialog/dialog.service.mjs +71 -71
- package/{esm2020 → esm2022}/lib/display/help/help-types.mjs +1 -1
- package/{esm2020 → esm2022}/lib/display/hierarchy/hierarchy-base.mjs +111 -111
- package/{esm2020 → esm2022}/lib/display/hierarchy/hierarchy-mocks.spec.mjs +53 -53
- package/{esm2020 → esm2022}/lib/display/hierarchy/hierarchy-tree/hierarchy-tree.component.mjs +61 -61
- package/{esm2020 → esm2022}/lib/display/item-display/item-display.component.mjs +81 -81
- package/{esm2020 → esm2022}/lib/display/json-display/json-display.component.mjs +47 -47
- package/{esm2020 → esm2022}/lib/display/resizable/resizable-base.mjs +120 -120
- package/{esm2020 → esm2022}/lib/display/resizable/resizable.component.mjs +52 -52
- package/{esm2020 → esm2022}/lib/display/spinner/spinner.component.mjs +12 -12
- package/{esm2020 → esm2022}/lib/display/splash/splash.component.mjs +42 -42
- package/{esm2020 → esm2022}/lib/display/splash/splash.service.mjs +35 -35
- package/{esm2020 → esm2022}/lib/display/table/resizable-column.component.mjs +20 -20
- package/{esm2020 → esm2022}/lib/display/table/resizable-table.directive.mjs +227 -227
- package/{esm2020 → esm2022}/lib/display/table/searchable-table.component.mjs +342 -342
- package/{esm2020 → esm2022}/lib/display/table/table-detail-row.component.mjs +19 -19
- package/{esm2020 → esm2022}/lib/display/table/table-locked-column.component.mjs +58 -58
- package/{esm2020 → esm2022}/lib/display/table/table-master-header-row.component.mjs +14 -14
- package/{esm2020 → esm2022}/lib/display/table/table-master-row.component.mjs +163 -163
- package/{esm2020 → esm2022}/lib/display/table/table-pagination.component.mjs +155 -155
- package/{esm2020 → esm2022}/lib/display/table/table-selectable-row.component.mjs +235 -235
- package/{esm2020 → esm2022}/lib/display/table/table.component.mjs +249 -249
- package/{esm2020 → esm2022}/lib/display/tags/tag.mjs +17 -17
- package/{esm2020 → esm2022}/lib/display/tags/tags.component.mjs +77 -77
- package/{esm2020 → esm2022}/lib/display/toast/toast/toast.component.mjs +77 -77
- package/{esm2020 → esm2022}/lib/display/toast/toast-types.mjs +7 -7
- package/{esm2020 → esm2022}/lib/display/toast/toast.service.mjs +35 -35
- package/{esm2020 → esm2022}/lib/display/toast/toaster/toaster.component.mjs +114 -114
- package/{esm2020 → esm2022}/lib/display/tooltip/tooltip.component.mjs +28 -28
- package/{esm2020 → esm2022}/lib/display/tooltip/tooltip.service.mjs +78 -78
- package/{esm2020 → esm2022}/lib/display/tooltip-directive/tooltip.directive.mjs +173 -173
- package/{esm2020 → esm2022}/lib/display/tour/tour-types.mjs +33 -33
- package/{esm2020 → esm2022}/lib/display/tour/tour.component.mjs +398 -398
- package/{esm2020 → esm2022}/lib/display/tour/tour.service.mjs +75 -75
- package/{esm2020 → esm2022}/lib/display/tree/tree.component.mjs +135 -135
- package/{esm2020 → esm2022}/lib/display/view-overlay/view-overlay.component.mjs +58 -58
- package/{esm2020 → esm2022}/lib/shared/directives/click-area-for/click-area-for.directive.mjs +32 -32
- package/{esm2020 → esm2022}/lib/shared/directives/if-viewport-width/if-viewport-width.directive.mjs +111 -111
- package/esm2022/lib/shared/directives/popup/popup-container.directive.mjs +166 -0
- package/{esm2020 → esm2022}/lib/shared/display/pipes/date-display.pipe.mjs +50 -50
- package/{esm2020 → esm2022}/lib/shared/display/pipes/highlight-text.pipe.mjs +30 -30
- package/{esm2020 → esm2022}/lib/shared/display/pipes/relative-date.pipe.mjs +62 -62
- package/{esm2020 → esm2022}/lib/shared/display/pipes/row-count.pipe.mjs +48 -48
- package/{esm2020 → esm2022}/lib/shared/display/pipes/time-display.pipe.mjs +41 -41
- package/esm2022/lib/shared/display.mjs +6 -0
- package/esm2022/lib/shared/form-group.helper.mjs +67 -0
- package/{esm2020 → esm2022}/lib/shared/json-helper.mjs +18 -18
- package/esm2022/lib/shared/lodash-helper.mjs +52 -0
- package/{esm2020 → esm2022}/lib/shared/page/page-base/page-base.component.mjs +387 -387
- package/{esm2020 → esm2022}/lib/shared/page/page-statuses.mjs +22 -22
- package/{esm2020 → esm2022}/lib/shared/page/page-title/page-title.component.mjs +23 -23
- package/{esm2020 → esm2022}/lib/shared/page/page-view/page-view.component.mjs +147 -147
- package/{esm2020 → esm2022}/lib/shared/testing/copy-button-base-test-injector-factory.spec.mjs +16 -16
- package/{esm2020 → esm2022}/lib/shared/testing/hierarchy-base-test-injector-factory.spec.mjs +16 -16
- package/{esm2020 → esm2022}/lib/shared/testing/page-base-component-test-helper.spec.mjs +37 -37
- package/esm2022/lib/shared/testing/page-base-component-test-injector-factory.spec.mjs +98 -0
- package/{esm2020 → esm2022}/lib/shared/testing/public-mocks.spec.mjs +148 -148
- package/{esm2020 → esm2022}/lib/shared/testing/spy-factory.spec.mjs +39 -39
- package/{esm2020 → esm2022}/lib/shared/testing/translation-mocks.spec.mjs +56 -56
- package/{esm2020 → esm2022}/lib/shared/user-preference.service.mjs +17 -17
- package/{esm2020 → esm2022}/lib/shared/wizard/wizard-base/wizard-base.component.mjs +246 -246
- package/{esm2020 → esm2022}/lib/shared/wizard/wizard-buttons/wizard-buttons.component.mjs +68 -68
- package/{esm2020 → esm2022}/lib/shared/wizard/wizard-progress/wizard-progress.component.mjs +18 -18
- package/{esm2020 → esm2022}/public-api.mjs +114 -114
- package/{fesm2020 → fesm2022}/energycap-components.mjs +11797 -11793
- package/fesm2022/energycap-components.mjs.map +1 -0
- package/index.d.ts +5 -5
- package/lib/components.module.d.ts +91 -91
- package/lib/controls/banner/banner.component.d.ts +50 -50
- package/lib/controls/button/button.component.d.ts +78 -78
- package/lib/controls/button/copy-button-base.directive.d.ts +20 -20
- package/lib/controls/button/copy-button.directive.d.ts +14 -14
- package/lib/controls/button/copy-table-button.directive.d.ts +19 -19
- package/lib/controls/calendar/calendar-item.component.d.ts +17 -17
- package/lib/controls/calendar/calendar.component.d.ts +54 -54
- package/lib/controls/calendar/calendar.types.d.ts +7 -7
- package/lib/controls/checkbox/checkbox.component.d.ts +65 -65
- package/lib/controls/collapsible-toggle/collapsible-toggle.component.d.ts +25 -25
- package/lib/controls/combobox/combobox.component.d.ts +418 -418
- package/lib/controls/date-input/date-input.component.d.ts +80 -80
- package/lib/controls/dropdown/dropdown.component.d.ts +161 -161
- package/lib/controls/file-upload/file-upload.component.d.ts +124 -124
- package/lib/controls/form-control/form-control.component.d.ts +30 -30
- package/lib/controls/form-control-base.d.ts +110 -110
- package/lib/controls/form-control-label/form-control-label.component.d.ts +73 -73
- package/lib/controls/form-group/form-group.component.d.ts +105 -105
- package/lib/controls/help-popover/help-popover.component.d.ts +11 -11
- package/lib/controls/item-picker/item-picker.component.d.ts +164 -164
- package/lib/controls/link-button/link-button.component.d.ts +5 -5
- package/lib/controls/menu/menu.component.d.ts +255 -255
- package/lib/controls/navigation/link-item.d.ts +32 -32
- package/lib/controls/navigation/nav-group.d.ts +18 -18
- package/lib/controls/navigation/nav-item-active.directive.d.ts +42 -42
- package/lib/controls/navigation/nav-item.d.ts +31 -31
- package/lib/controls/numericbox/numericbox.component.d.ts +148 -148
- package/lib/controls/popover/popover.component.d.ts +51 -51
- package/lib/controls/radio-button/radio-button-option.d.ts +19 -19
- package/lib/controls/radio-button/radio-button.component.d.ts +53 -53
- package/lib/controls/select/select.component.d.ts +44 -44
- package/lib/controls/tabs/tabs.component.d.ts +30 -30
- package/lib/controls/textbox/textbox.component.d.ts +107 -107
- package/lib/core/cache.service.d.ts +33 -33
- package/lib/core/custom-validators.d.ts +20 -20
- package/lib/core/date-time-helper.d.ts +101 -101
- package/lib/core/error.service.d.ts +20 -20
- package/lib/core/router-helper.service.d.ts +48 -48
- package/lib/core/scroll.service.d.ts +36 -36
- package/lib/core/telemetry-tracker.service.d.ts +13 -13
- package/lib/core/telemetry.service.d.ts +31 -31
- package/lib/core/validation-message.service.d.ts +26 -26
- package/lib/core/validation-patterns.d.ts +22 -22
- package/lib/core/window.service.d.ts +116 -116
- package/lib/display/app-bar/app-bar.component.d.ts +20 -20
- package/lib/display/avatar/avatar.component.d.ts +35 -35
- package/lib/display/avatar/avatar.service.d.ts +24 -24
- package/lib/display/confirm/confirm.component.d.ts +123 -123
- package/lib/display/dialog/dialog-content.d.ts +19 -19
- package/lib/display/dialog/dialog-group/dialog-group.component.d.ts +32 -32
- package/lib/display/dialog/dialog-types.d.ts +130 -130
- package/lib/display/dialog/dialog.component.d.ts +120 -120
- package/lib/display/dialog/dialog.service.d.ts +48 -48
- package/lib/display/help/help-types.d.ts +33 -33
- package/lib/display/hierarchy/hierarchy-base.d.ts +97 -97
- package/lib/display/hierarchy/hierarchy-mocks.spec.d.ts +53 -53
- package/lib/display/hierarchy/hierarchy-tree/hierarchy-tree.component.d.ts +34 -34
- package/lib/display/item-display/item-display.component.d.ts +43 -43
- package/lib/display/json-display/json-display.component.d.ts +16 -16
- package/lib/display/resizable/resizable-base.d.ts +67 -67
- package/lib/display/resizable/resizable.component.d.ts +31 -31
- package/lib/display/spinner/spinner.component.d.ts +5 -5
- package/lib/display/splash/splash.component.d.ts +16 -16
- package/lib/display/splash/splash.service.d.ts +22 -22
- package/lib/display/table/resizable-column.component.d.ts +10 -10
- package/lib/display/table/resizable-table.directive.d.ts +93 -93
- package/lib/display/table/searchable-table.component.d.ts +206 -206
- package/lib/display/table/table-detail-row.component.d.ts +8 -8
- package/lib/display/table/table-locked-column.component.d.ts +20 -20
- package/lib/display/table/table-master-header-row.component.d.ts +9 -9
- package/lib/display/table/table-master-row.component.d.ts +113 -113
- package/lib/display/table/table-pagination.component.d.ts +91 -91
- package/lib/display/table/table-selectable-row.component.d.ts +102 -102
- package/lib/display/table/table.component.d.ts +121 -121
- package/lib/display/tags/tag.d.ts +18 -18
- package/lib/display/tags/tags.component.d.ts +48 -48
- package/lib/display/toast/toast/toast.component.d.ts +23 -23
- package/lib/display/toast/toast-types.d.ts +24 -24
- package/lib/display/toast/toast.service.d.ts +20 -20
- package/lib/display/toast/toaster/toaster.component.d.ts +35 -35
- package/lib/display/tooltip/tooltip.component.d.ts +70 -70
- package/lib/display/tooltip/tooltip.service.d.ts +16 -16
- package/lib/display/tooltip-directive/tooltip.directive.d.ts +44 -44
- package/lib/display/tour/tour-types.d.ts +70 -70
- package/lib/display/tour/tour.component.d.ts +147 -147
- package/lib/display/tour/tour.service.d.ts +38 -38
- package/lib/display/tree/tree.component.d.ts +75 -75
- package/lib/display/view-overlay/view-overlay.component.d.ts +38 -38
- package/lib/shared/directives/click-area-for/click-area-for.directive.d.ts +14 -14
- package/lib/shared/directives/if-viewport-width/if-viewport-width.directive.d.ts +60 -60
- package/lib/shared/directives/popup/popup-container.directive.d.ts +101 -101
- package/lib/shared/display/pipes/date-display.pipe.d.ts +21 -21
- package/lib/shared/display/pipes/highlight-text.pipe.d.ts +9 -9
- package/lib/shared/display/pipes/relative-date.pipe.d.ts +36 -36
- package/lib/shared/display/pipes/row-count.pipe.d.ts +23 -23
- package/lib/shared/display/pipes/time-display.pipe.d.ts +18 -18
- package/lib/shared/display.d.ts +42 -42
- package/lib/shared/form-group.helper.d.ts +31 -31
- package/lib/shared/json-helper.d.ts +7 -7
- package/lib/shared/lodash-helper.d.ts +18 -18
- package/lib/shared/page/page-base/page-base.component.d.ts +259 -259
- package/lib/shared/page/page-statuses.d.ts +13 -13
- package/lib/shared/page/page-title/page-title.component.d.ts +9 -9
- package/lib/shared/page/page-view/page-view.component.d.ts +102 -102
- package/lib/shared/testing/copy-button-base-test-injector-factory.spec.d.ts +4 -4
- package/lib/shared/testing/hierarchy-base-test-injector-factory.spec.d.ts +4 -4
- package/lib/shared/testing/page-base-component-test-helper.spec.d.ts +30 -30
- package/lib/shared/testing/page-base-component-test-injector-factory.spec.d.ts +28 -28
- package/lib/shared/testing/public-mocks.spec.d.ts +90 -90
- package/lib/shared/testing/spy-factory.spec.d.ts +27 -27
- package/lib/shared/testing/translation-mocks.spec.d.ts +30 -30
- package/lib/shared/user-preference.service.d.ts +13 -13
- package/lib/shared/wizard/wizard-base/wizard-base.component.d.ts +134 -134
- package/lib/shared/wizard/wizard-buttons/wizard-buttons.component.d.ts +27 -27
- package/lib/shared/wizard/wizard-progress/wizard-progress.component.d.ts +10 -10
- package/package.json +12 -18
- package/public-api.d.ts +111 -111
- package/schematics/rxjs-7-upgrade/index.d.ts +3 -3
- package/schematics/rxjs-7-upgrade/index.js +67 -67
- package/schematics/rxjs-7-upgrade/schema.d.ts +4 -4
- package/schematics/rxjs-7-upgrade/schema.js +2 -2
- package/schematics/utilities/typescript.d.ts +7 -7
- package/schematics/utilities/typescript.js +41 -41
- package/schematics/utilities/workspace.d.ts +8 -8
- package/schematics/utilities/workspace.js +71 -71
- package/esm2020/lib/core/custom-validators.mjs +0 -29
- package/esm2020/lib/core/date-time-helper.mjs +0 -220
- package/esm2020/lib/display/avatar/avatar.component.mjs +0 -67
- package/esm2020/lib/shared/directives/popup/popup-container.directive.mjs +0 -163
- package/esm2020/lib/shared/display.mjs +0 -6
- package/esm2020/lib/shared/form-group.helper.mjs +0 -67
- package/esm2020/lib/shared/lodash-helper.mjs +0 -51
- package/esm2020/lib/shared/testing/page-base-component-test-injector-factory.spec.mjs +0 -98
- package/fesm2015/energycap-components.mjs +0 -12211
- package/fesm2015/energycap-components.mjs.map +0 -1
- package/fesm2020/energycap-components.mjs.map +0 -1
@@ -1,61 +1,61 @@
|
|
1
|
-
import { Injectable } from '@angular/core';
|
2
|
-
import * as i0 from "@angular/core";
|
3
|
-
export function isApiError(errorResponse) {
|
4
|
-
// errorResponse is typed HttpErrorResponse if the api returns an error
|
5
|
-
if (errorResponse.error && errorResponse.error.hasOwnProperty('status') && errorResponse.error.status.hasOwnProperty('message')) {
|
6
|
-
return true;
|
7
|
-
}
|
8
|
-
// BillCAPture APIs return errors in a different format
|
9
|
-
if (errorResponse.error && errorResponse.error.hasOwnProperty('Message')) {
|
10
|
-
return true;
|
11
|
-
}
|
12
|
-
return false;
|
13
|
-
}
|
14
|
-
export class ErrorService {
|
15
|
-
constructor() { }
|
16
|
-
/**
|
17
|
-
* Parse an error that comes from the API for use inside the forms
|
18
|
-
* In most cases this isn't required because the error handler will do it automatically,
|
19
|
-
* but if you need to analyze the error message you can use this to extract it safely.
|
20
|
-
* NOTE: Because it can be used for comparison the result is not translated. You must translate
|
21
|
-
* it before providing it to the user.
|
22
|
-
* @param error The error object from the API
|
23
|
-
*/
|
24
|
-
parseApiError(errorResponse, unknownErrorDefault) {
|
25
|
-
if (typeof errorResponse === 'string') {
|
26
|
-
return errorResponse;
|
27
|
-
}
|
28
|
-
// errorResponse is typed HttpErrorResponse if the api returns an error
|
29
|
-
let apiErrorMessage = unknownErrorDefault || 'DefaultUnknownError_SC';
|
30
|
-
if (errorResponse && isApiError(errorResponse)) {
|
31
|
-
try {
|
32
|
-
apiErrorMessage = errorResponse.error.status?.message || errorResponse.error.Message;
|
33
|
-
}
|
34
|
-
catch (error) {
|
35
|
-
//log the real error to the console (for developers) but just return the generic error to the user
|
36
|
-
this.logConsoleError(error);
|
37
|
-
}
|
38
|
-
}
|
39
|
-
else {
|
40
|
-
this.logConsoleError(errorResponse);
|
41
|
-
}
|
42
|
-
return apiErrorMessage;
|
43
|
-
}
|
44
|
-
/**
|
45
|
-
* Just a safe wrapper around console.error in case the browser doesn't have one exposed
|
46
|
-
*/
|
47
|
-
logConsoleError(error) {
|
48
|
-
if (console && typeof (console.error) === 'function') {
|
49
|
-
console.error('unknown error:', error);
|
50
|
-
}
|
51
|
-
}
|
52
|
-
}
|
53
|
-
|
54
|
-
|
55
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
56
|
-
type: Injectable,
|
57
|
-
args: [{
|
58
|
-
providedIn: 'root'
|
59
|
-
}]
|
60
|
-
}], ctorParameters: function () { return []; } });
|
61
|
-
//# sourceMappingURL=data:application/json;base64,
|
1
|
+
import { Injectable } from '@angular/core';
|
2
|
+
import * as i0 from "@angular/core";
|
3
|
+
export function isApiError(errorResponse) {
|
4
|
+
// errorResponse is typed HttpErrorResponse if the api returns an error
|
5
|
+
if (errorResponse.error && errorResponse.error.hasOwnProperty('status') && errorResponse.error.status.hasOwnProperty('message')) {
|
6
|
+
return true;
|
7
|
+
}
|
8
|
+
// BillCAPture APIs return errors in a different format
|
9
|
+
if (errorResponse.error && errorResponse.error.hasOwnProperty('Message')) {
|
10
|
+
return true;
|
11
|
+
}
|
12
|
+
return false;
|
13
|
+
}
|
14
|
+
export class ErrorService {
|
15
|
+
constructor() { }
|
16
|
+
/**
|
17
|
+
* Parse an error that comes from the API for use inside the forms
|
18
|
+
* In most cases this isn't required because the error handler will do it automatically,
|
19
|
+
* but if you need to analyze the error message you can use this to extract it safely.
|
20
|
+
* NOTE: Because it can be used for comparison the result is not translated. You must translate
|
21
|
+
* it before providing it to the user.
|
22
|
+
* @param error The error object from the API
|
23
|
+
*/
|
24
|
+
parseApiError(errorResponse, unknownErrorDefault) {
|
25
|
+
if (typeof errorResponse === 'string') {
|
26
|
+
return errorResponse;
|
27
|
+
}
|
28
|
+
// errorResponse is typed HttpErrorResponse if the api returns an error
|
29
|
+
let apiErrorMessage = unknownErrorDefault || 'DefaultUnknownError_SC';
|
30
|
+
if (errorResponse && isApiError(errorResponse)) {
|
31
|
+
try {
|
32
|
+
apiErrorMessage = errorResponse.error.status?.message || errorResponse.error.Message;
|
33
|
+
}
|
34
|
+
catch (error) {
|
35
|
+
//log the real error to the console (for developers) but just return the generic error to the user
|
36
|
+
this.logConsoleError(error);
|
37
|
+
}
|
38
|
+
}
|
39
|
+
else {
|
40
|
+
this.logConsoleError(errorResponse);
|
41
|
+
}
|
42
|
+
return apiErrorMessage;
|
43
|
+
}
|
44
|
+
/**
|
45
|
+
* Just a safe wrapper around console.error in case the browser doesn't have one exposed
|
46
|
+
*/
|
47
|
+
logConsoleError(error) {
|
48
|
+
if (console && typeof (console.error) === 'function') {
|
49
|
+
console.error('unknown error:', error);
|
50
|
+
}
|
51
|
+
}
|
52
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ErrorService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
53
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ErrorService, providedIn: 'root' }); }
|
54
|
+
}
|
55
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ErrorService, decorators: [{
|
56
|
+
type: Injectable,
|
57
|
+
args: [{
|
58
|
+
providedIn: 'root'
|
59
|
+
}]
|
60
|
+
}], ctorParameters: function () { return []; } });
|
61
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXJyb3Iuc2VydmljZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uL3Byb2plY3RzL2NvbXBvbmVudHMvc3JjL2xpYi9jb3JlL2Vycm9yLnNlcnZpY2UudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFVBQVUsRUFBRSxNQUFNLGVBQWUsQ0FBQzs7QUFHM0MsTUFBTSxVQUFVLFVBQVUsQ0FBQyxhQUFrQjtJQUMzQyx1RUFBdUU7SUFDdkUsSUFBSSxhQUFhLENBQUMsS0FBSyxJQUFJLGFBQWEsQ0FBQyxLQUFLLENBQUMsY0FBYyxDQUFDLFFBQVEsQ0FBQyxJQUFJLGFBQWEsQ0FBQyxLQUFLLENBQUMsTUFBTSxDQUFDLGNBQWMsQ0FBQyxTQUFTLENBQUMsRUFBRTtRQUMvSCxPQUFPLElBQUksQ0FBQztLQUNiO0lBRUQsdURB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
|
2
|
-
import {
|
3
|
-
import { filter } from 'rxjs/operators';
|
4
|
-
import * as i0 from "@angular/core";
|
5
|
-
export class RouterHelper {
|
6
|
-
/**
|
7
|
-
* Traverses the pathFromRoot and combines all of the route parameters into
|
8
|
-
* one Params object and returns it
|
9
|
-
* @param route - ActivatedRouteSnapshot
|
10
|
-
* @see https://angular.io/api/router/ActivatedRouteSnapshot#pathFromRoot
|
11
|
-
*/
|
12
|
-
getFullRouteParams(route) {
|
13
|
-
const params = {};
|
14
|
-
route.pathFromRoot.forEach(snapshot => {
|
15
|
-
snapshot.paramMap.keys.forEach(key => {
|
16
|
-
params[key] = snapshot.paramMap.get(key);
|
17
|
-
});
|
18
|
-
});
|
19
|
-
return params;
|
20
|
-
}
|
21
|
-
/**
|
22
|
-
* Traverses the pathFromRoot and combines all of the route paramters into
|
23
|
-
* one ParamMap and returns it
|
24
|
-
* @param route - ActivatedRouteSnapshot
|
25
|
-
* @see https://angular.io/api/router/ActivatedRouteSnapshot#pathFromRoot
|
26
|
-
*/
|
27
|
-
getFullRouteParamMap(route) {
|
28
|
-
const params = this.getFullRouteParams(route);
|
29
|
-
return convertToParamMap(params);
|
30
|
-
}
|
31
|
-
/**
|
32
|
-
* Traverses the pathFromRoot and combines all of the route paths into
|
33
|
-
* a url from root to the provided activated route.
|
34
|
-
* @param route - ActivatedRouteSnapshot
|
35
|
-
* @see https://angular.io/api/router/ActivatedRouteSnapshot#pathFromRoot
|
36
|
-
*/
|
37
|
-
serializeUrlFromRoot(route) {
|
38
|
-
let url = '';
|
39
|
-
const paths = [];
|
40
|
-
route.pathFromRoot.forEach(r => {
|
41
|
-
r.url.forEach(s => {
|
42
|
-
paths.push(s.path);
|
43
|
-
});
|
44
|
-
});
|
45
|
-
url = paths.join('/');
|
46
|
-
return url;
|
47
|
-
}
|
48
|
-
/**
|
49
|
-
* Look at the first two child activated routes of a page route and combine the
|
50
|
-
* url segments of each. These will contain the paths for the current view that
|
51
|
-
* correspond to a primary and secondary tab. Assumes the URL structure is
|
52
|
-
* /{page}/{primary}/{secondary}
|
53
|
-
* @param pageRoute - The ActivatedRoute for the 'page' portion of the url. E.g. meter/:meterId
|
54
|
-
*/
|
55
|
-
getViewUrlSegments(pageRoute) {
|
56
|
-
let segments = [];
|
57
|
-
const primaryViewRoute = pageRoute.firstChild;
|
58
|
-
if (primaryViewRoute) {
|
59
|
-
segments = segments.concat(primaryViewRoute.snapshot.url);
|
60
|
-
const secondaryViewRoute = primaryViewRoute.firstChild;
|
61
|
-
if (secondaryViewRoute) {
|
62
|
-
segments = segments.concat(secondaryViewRoute.snapshot.url);
|
63
|
-
}
|
64
|
-
}
|
65
|
-
return segments;
|
66
|
-
}
|
67
|
-
/**
|
68
|
-
* Returns the 'last firstChild' of the provided route tree
|
69
|
-
* @param route - ActivatedRoute
|
70
|
-
*/
|
71
|
-
getLastRouteDescendant(route) {
|
72
|
-
while (route.firstChild) {
|
73
|
-
route = route.firstChild;
|
74
|
-
}
|
75
|
-
return route;
|
76
|
-
}
|
77
|
-
/**
|
78
|
-
* Wrap code that will force the user to navigate based on some network call in a piece of logic that will cancel the action if there is another
|
79
|
-
* navigation event while we wait for the call to complete. This is a common problem with trying to pick a default child when a user switches between modules.
|
80
|
-
* @param asyncCall The async code to execute while watching for router navigation events. This code always executed and the result is returned
|
81
|
-
* @param doIfNoNavigation The code to execute only if no navigation events happen while asyncCall is executing. It is passed the result of the async call
|
82
|
-
* @param router The router instance to listen for navigation events.
|
83
|
-
*/
|
84
|
-
async executeWithNavigationWatcher(asyncCall, doIfNoNavigation, router) {
|
85
|
-
let eventOccurred = false;
|
86
|
-
let subscription = router.events.pipe(filter(e => e instanceof NavigationStart || e instanceof NavigationEnd)).subscribe(() => {
|
87
|
-
eventOccurred = true;
|
88
|
-
});
|
89
|
-
try {
|
90
|
-
let result = await asyncCall();
|
91
|
-
if (!eventOccurred) {
|
92
|
-
await doIfNoNavigation(result);
|
93
|
-
}
|
94
|
-
subscription.unsubscribe();
|
95
|
-
return result;
|
96
|
-
}
|
97
|
-
catch (error) {
|
98
|
-
subscription.unsubscribe();
|
99
|
-
throw error;
|
100
|
-
}
|
101
|
-
}
|
102
|
-
}
|
103
|
-
|
104
|
-
|
105
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
106
|
-
type: Injectable,
|
107
|
-
args: [{
|
108
|
-
providedIn: 'root'
|
109
|
-
}]
|
110
|
-
}] });
|
111
|
-
//# sourceMappingURL=data:application/json;base64,
|
1
|
+
import { Injectable } from "@angular/core";
|
2
|
+
import { convertToParamMap, NavigationEnd, NavigationStart } from "@angular/router";
|
3
|
+
import { filter } from 'rxjs/operators';
|
4
|
+
import * as i0 from "@angular/core";
|
5
|
+
export class RouterHelper {
|
6
|
+
/**
|
7
|
+
* Traverses the pathFromRoot and combines all of the route parameters into
|
8
|
+
* one Params object and returns it
|
9
|
+
* @param route - ActivatedRouteSnapshot
|
10
|
+
* @see https://angular.io/api/router/ActivatedRouteSnapshot#pathFromRoot
|
11
|
+
*/
|
12
|
+
getFullRouteParams(route) {
|
13
|
+
const params = {};
|
14
|
+
route.pathFromRoot.forEach(snapshot => {
|
15
|
+
snapshot.paramMap.keys.forEach(key => {
|
16
|
+
params[key] = snapshot.paramMap.get(key);
|
17
|
+
});
|
18
|
+
});
|
19
|
+
return params;
|
20
|
+
}
|
21
|
+
/**
|
22
|
+
* Traverses the pathFromRoot and combines all of the route paramters into
|
23
|
+
* one ParamMap and returns it
|
24
|
+
* @param route - ActivatedRouteSnapshot
|
25
|
+
* @see https://angular.io/api/router/ActivatedRouteSnapshot#pathFromRoot
|
26
|
+
*/
|
27
|
+
getFullRouteParamMap(route) {
|
28
|
+
const params = this.getFullRouteParams(route);
|
29
|
+
return convertToParamMap(params);
|
30
|
+
}
|
31
|
+
/**
|
32
|
+
* Traverses the pathFromRoot and combines all of the route paths into
|
33
|
+
* a url from root to the provided activated route.
|
34
|
+
* @param route - ActivatedRouteSnapshot
|
35
|
+
* @see https://angular.io/api/router/ActivatedRouteSnapshot#pathFromRoot
|
36
|
+
*/
|
37
|
+
serializeUrlFromRoot(route) {
|
38
|
+
let url = '';
|
39
|
+
const paths = [];
|
40
|
+
route.pathFromRoot.forEach(r => {
|
41
|
+
r.url.forEach(s => {
|
42
|
+
paths.push(s.path);
|
43
|
+
});
|
44
|
+
});
|
45
|
+
url = paths.join('/');
|
46
|
+
return url;
|
47
|
+
}
|
48
|
+
/**
|
49
|
+
* Look at the first two child activated routes of a page route and combine the
|
50
|
+
* url segments of each. These will contain the paths for the current view that
|
51
|
+
* correspond to a primary and secondary tab. Assumes the URL structure is
|
52
|
+
* /{page}/{primary}/{secondary}
|
53
|
+
* @param pageRoute - The ActivatedRoute for the 'page' portion of the url. E.g. meter/:meterId
|
54
|
+
*/
|
55
|
+
getViewUrlSegments(pageRoute) {
|
56
|
+
let segments = [];
|
57
|
+
const primaryViewRoute = pageRoute.firstChild;
|
58
|
+
if (primaryViewRoute) {
|
59
|
+
segments = segments.concat(primaryViewRoute.snapshot.url);
|
60
|
+
const secondaryViewRoute = primaryViewRoute.firstChild;
|
61
|
+
if (secondaryViewRoute) {
|
62
|
+
segments = segments.concat(secondaryViewRoute.snapshot.url);
|
63
|
+
}
|
64
|
+
}
|
65
|
+
return segments;
|
66
|
+
}
|
67
|
+
/**
|
68
|
+
* Returns the 'last firstChild' of the provided route tree
|
69
|
+
* @param route - ActivatedRoute
|
70
|
+
*/
|
71
|
+
getLastRouteDescendant(route) {
|
72
|
+
while (route.firstChild) {
|
73
|
+
route = route.firstChild;
|
74
|
+
}
|
75
|
+
return route;
|
76
|
+
}
|
77
|
+
/**
|
78
|
+
* Wrap code that will force the user to navigate based on some network call in a piece of logic that will cancel the action if there is another
|
79
|
+
* navigation event while we wait for the call to complete. This is a common problem with trying to pick a default child when a user switches between modules.
|
80
|
+
* @param asyncCall The async code to execute while watching for router navigation events. This code always executed and the result is returned
|
81
|
+
* @param doIfNoNavigation The code to execute only if no navigation events happen while asyncCall is executing. It is passed the result of the async call
|
82
|
+
* @param router The router instance to listen for navigation events.
|
83
|
+
*/
|
84
|
+
async executeWithNavigationWatcher(asyncCall, doIfNoNavigation, router) {
|
85
|
+
let eventOccurred = false;
|
86
|
+
let subscription = router.events.pipe(filter(e => e instanceof NavigationStart || e instanceof NavigationEnd)).subscribe(() => {
|
87
|
+
eventOccurred = true;
|
88
|
+
});
|
89
|
+
try {
|
90
|
+
let result = await asyncCall();
|
91
|
+
if (!eventOccurred) {
|
92
|
+
await doIfNoNavigation(result);
|
93
|
+
}
|
94
|
+
subscription.unsubscribe();
|
95
|
+
return result;
|
96
|
+
}
|
97
|
+
catch (error) {
|
98
|
+
subscription.unsubscribe();
|
99
|
+
throw error;
|
100
|
+
}
|
101
|
+
}
|
102
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: RouterHelper, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
103
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: RouterHelper, providedIn: 'root' }); }
|
104
|
+
}
|
105
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: RouterHelper, decorators: [{
|
106
|
+
type: Injectable,
|
107
|
+
args: [{
|
108
|
+
providedIn: 'root'
|
109
|
+
}]
|
110
|
+
}] });
|
111
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicm91dGVyLWhlbHBlci5zZXJ2aWNlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vLi4vcHJvamVjdHMvY29tcG9uZW50cy9zcmMvbGliL2NvcmUvcm91dGVyLWhlbHBlci5zZXJ2aWNlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxVQUFVLEVBQUUsTUFBTS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mV2ZW50cy5waXBlKFxyXG4gICAgICBmaWx0ZXIoZSA9PiBlIGluc3RhbmNlb2YgTmF2aWdhdGlvblN0YXJ0IHx8IGUgaW5zdGFuY2VvZiBOYXZpZ2F0aW9uRW5kKVxyXG4gICAgKS5zdWJzY3JpYmUoKCkgPT4ge1xyXG4gICAgICBldmVudE9jY3VycmVkID0gdHJ1ZTtcclxuICAgIH0pO1xyXG5cclxuICAgIHRyeSB7XHJcbiAgICAgIGxldCByZXN1bHQgPSBhd2FpdCBhc3luY0NhbGwoKTtcclxuICAgICAgaWYgKCFldmVudE9jY3VycmVkKSB7XHJcbiAgICAgICAgYXdhaXQgZG9JZk5vTmF2aWdhdGlvbihyZXN1bHQpO1xyXG4gICAgICB9XHJcbiAgICAgIHN1YnNjcmlwdGlvbi51bnN1YnNjcmliZSgpO1xyXG4gICAgICByZXR1cm4gcmVzdWx0O1xyXG4gICAgICBcclxuICAgIH0gY2F0Y2ggKGVycm9yKSB7XHJcbiAgICAgIHN1YnNjcmlwdGlvbi51bnN1YnNjcmliZSgpO1xyXG4gICAgICB0aHJvdyBlcnJvcjtcclxuICAgIH1cclxuICB9XHJcbn1cclxuIl19
|
@@ -1,89 +1,89 @@
|
|
1
|
-
import { Injectable } from "@angular/core";
|
2
|
-
import * as i0 from "@angular/core";
|
3
|
-
export class ScrollService {
|
4
|
-
constructor() { }
|
5
|
-
/**
|
6
|
-
* Given a container and the target element to scroll to, we will set the scroll top on
|
7
|
-
* the container to bring the target into view.
|
8
|
-
*
|
9
|
-
* @param scrollContainerSelector A valid CSS selector string for the scroll container.
|
10
|
-
* @param targetElementSelector A valid CSS selector string for the target element.
|
11
|
-
* @param topPadding The amount of space to leave above the target
|
12
|
-
* to keep it from being pinned to the top of the scrollContainer. Defaults
|
13
|
-
* to 32px, the default height of a menu item.
|
14
|
-
*/
|
15
|
-
scrollToItem(scrollContainerSelector, targetElementSelector, topPadding = 32) {
|
16
|
-
let scrollContainer = document.querySelector(scrollContainerSelector);
|
17
|
-
if (!scrollContainer) {
|
18
|
-
return;
|
19
|
-
}
|
20
|
-
let targetElement = scrollContainer.querySelector(targetElementSelector);
|
21
|
-
if (!targetElement) {
|
22
|
-
return;
|
23
|
-
}
|
24
|
-
let targetRect = targetElement.getBoundingClientRect();
|
25
|
-
let containerRect = scrollContainer.getBoundingClientRect();
|
26
|
-
// Only scroll if the target is outside of the view bounds of the container
|
27
|
-
if (targetRect.bottom > containerRect.bottom || targetRect.top < containerRect.top) {
|
28
|
-
scrollContainer.scrollTop =
|
29
|
-
(targetRect.top - containerRect.top) + scrollContainer.scrollTop - topPadding;
|
30
|
-
}
|
31
|
-
}
|
32
|
-
/**
|
33
|
-
* Return the value of the scrollTop property for an HTMLElement that matches the selector
|
34
|
-
* @param scrollContainerSelector A valid CSS selector
|
35
|
-
*/
|
36
|
-
getCurrentScrollPosition(scrollContainerSelector) {
|
37
|
-
let scrollContainer = document.querySelector(scrollContainerSelector);
|
38
|
-
if (scrollContainer) {
|
39
|
-
return scrollContainer.scrollTop;
|
40
|
-
}
|
41
|
-
else {
|
42
|
-
console.error(`Scroll container '${scrollContainerSelector}' does not exist.`);
|
43
|
-
return 0;
|
44
|
-
}
|
45
|
-
}
|
46
|
-
/**
|
47
|
-
* Set the scrollTop of an HTMLElement that matches the selector to a specific position
|
48
|
-
* @param scrollContainerSelector A valid CSS selector
|
49
|
-
* @param position
|
50
|
-
*/
|
51
|
-
scrollToPosition(scrollContainerSelector, position) {
|
52
|
-
let scrollContainer = document.querySelector(scrollContainerSelector);
|
53
|
-
if (scrollContainer) {
|
54
|
-
scrollContainer.scrollTop = position;
|
55
|
-
}
|
56
|
-
else {
|
57
|
-
console.error(`Scroll container '${scrollContainerSelector}' does not exist.`);
|
58
|
-
}
|
59
|
-
}
|
60
|
-
/**
|
61
|
-
* Given a container and the target element to scroll to, we will set the scroll top on
|
62
|
-
* the container to bring the target into view, with the item in the center of the scroll container.
|
63
|
-
*
|
64
|
-
* @param scrollContainerSelector A valid CSS selector string for the scroll container.
|
65
|
-
* @param targetElementSelector A valid CSS selector string for the target element.
|
66
|
-
*/
|
67
|
-
scrollItemCentered(scrollContainerSelector, targetElementSelector) {
|
68
|
-
try {
|
69
|
-
let scrollContainer = document.querySelector(scrollContainerSelector);
|
70
|
-
if (scrollContainer) {
|
71
|
-
let containerHeight = scrollContainer.getBoundingClientRect().height;
|
72
|
-
// Pad the top with half of the height of the container to put the target in the middle
|
73
|
-
this.scrollToItem(scrollContainerSelector, targetElementSelector, containerHeight * .5);
|
74
|
-
}
|
75
|
-
}
|
76
|
-
catch (error) {
|
77
|
-
console.error(`Error scrolling target into view. Container selector: ${scrollContainerSelector}. Target selector: ${targetElementSelector}`, error);
|
78
|
-
}
|
79
|
-
}
|
80
|
-
}
|
81
|
-
|
82
|
-
|
83
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
84
|
-
type: Injectable,
|
85
|
-
args: [{
|
86
|
-
providedIn: 'root'
|
87
|
-
}]
|
88
|
-
}], ctorParameters: function () { return []; } });
|
89
|
-
//# sourceMappingURL=data:application/json;base64,
|
1
|
+
import { Injectable } from "@angular/core";
|
2
|
+
import * as i0 from "@angular/core";
|
3
|
+
export class ScrollService {
|
4
|
+
constructor() { }
|
5
|
+
/**
|
6
|
+
* Given a container and the target element to scroll to, we will set the scroll top on
|
7
|
+
* the container to bring the target into view.
|
8
|
+
*
|
9
|
+
* @param scrollContainerSelector A valid CSS selector string for the scroll container.
|
10
|
+
* @param targetElementSelector A valid CSS selector string for the target element.
|
11
|
+
* @param topPadding The amount of space to leave above the target
|
12
|
+
* to keep it from being pinned to the top of the scrollContainer. Defaults
|
13
|
+
* to 32px, the default height of a menu item.
|
14
|
+
*/
|
15
|
+
scrollToItem(scrollContainerSelector, targetElementSelector, topPadding = 32) {
|
16
|
+
let scrollContainer = document.querySelector(scrollContainerSelector);
|
17
|
+
if (!scrollContainer) {
|
18
|
+
return;
|
19
|
+
}
|
20
|
+
let targetElement = scrollContainer.querySelector(targetElementSelector);
|
21
|
+
if (!targetElement) {
|
22
|
+
return;
|
23
|
+
}
|
24
|
+
let targetRect = targetElement.getBoundingClientRect();
|
25
|
+
let containerRect = scrollContainer.getBoundingClientRect();
|
26
|
+
// Only scroll if the target is outside of the view bounds of the container
|
27
|
+
if (targetRect.bottom > containerRect.bottom || targetRect.top < containerRect.top) {
|
28
|
+
scrollContainer.scrollTop =
|
29
|
+
(targetRect.top - containerRect.top) + scrollContainer.scrollTop - topPadding;
|
30
|
+
}
|
31
|
+
}
|
32
|
+
/**
|
33
|
+
* Return the value of the scrollTop property for an HTMLElement that matches the selector
|
34
|
+
* @param scrollContainerSelector A valid CSS selector
|
35
|
+
*/
|
36
|
+
getCurrentScrollPosition(scrollContainerSelector) {
|
37
|
+
let scrollContainer = document.querySelector(scrollContainerSelector);
|
38
|
+
if (scrollContainer) {
|
39
|
+
return scrollContainer.scrollTop;
|
40
|
+
}
|
41
|
+
else {
|
42
|
+
console.error(`Scroll container '${scrollContainerSelector}' does not exist.`);
|
43
|
+
return 0;
|
44
|
+
}
|
45
|
+
}
|
46
|
+
/**
|
47
|
+
* Set the scrollTop of an HTMLElement that matches the selector to a specific position
|
48
|
+
* @param scrollContainerSelector A valid CSS selector
|
49
|
+
* @param position
|
50
|
+
*/
|
51
|
+
scrollToPosition(scrollContainerSelector, position) {
|
52
|
+
let scrollContainer = document.querySelector(scrollContainerSelector);
|
53
|
+
if (scrollContainer) {
|
54
|
+
scrollContainer.scrollTop = position;
|
55
|
+
}
|
56
|
+
else {
|
57
|
+
console.error(`Scroll container '${scrollContainerSelector}' does not exist.`);
|
58
|
+
}
|
59
|
+
}
|
60
|
+
/**
|
61
|
+
* Given a container and the target element to scroll to, we will set the scroll top on
|
62
|
+
* the container to bring the target into view, with the item in the center of the scroll container.
|
63
|
+
*
|
64
|
+
* @param scrollContainerSelector A valid CSS selector string for the scroll container.
|
65
|
+
* @param targetElementSelector A valid CSS selector string for the target element.
|
66
|
+
*/
|
67
|
+
scrollItemCentered(scrollContainerSelector, targetElementSelector) {
|
68
|
+
try {
|
69
|
+
let scrollContainer = document.querySelector(scrollContainerSelector);
|
70
|
+
if (scrollContainer) {
|
71
|
+
let containerHeight = scrollContainer.getBoundingClientRect().height;
|
72
|
+
// Pad the top with half of the height of the container to put the target in the middle
|
73
|
+
this.scrollToItem(scrollContainerSelector, targetElementSelector, containerHeight * .5);
|
74
|
+
}
|
75
|
+
}
|
76
|
+
catch (error) {
|
77
|
+
console.error(`Error scrolling target into view. Container selector: ${scrollContainerSelector}. Target selector: ${targetElementSelector}`, error);
|
78
|
+
}
|
79
|
+
}
|
80
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ScrollService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
81
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ScrollService, providedIn: 'root' }); }
|
82
|
+
}
|
83
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: ScrollService, decorators: [{
|
84
|
+
type: Injectable,
|
85
|
+
args: [{
|
86
|
+
providedIn: 'root'
|
87
|
+
}]
|
88
|
+
}], ctorParameters: function () { return []; } });
|
89
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2Nyb2xsLnNlcnZpY2UuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9wcm9qZWN0cy9jb21wb25lbnRzL3NyYy9saWIvY29yZS9zY3JvbGwuc2VydmljZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsVUFBVSxFQUFFLE1BQU0sZUFBZSxDQUFDOztBQUszQyxNQUFNLE9BQU8sYUFBYTtJQUV0QixnQkFBZ0IsQ0FBQztJQUVqQjs7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