@one-paragon/angular-utilities 2.2.6 → 2.2.7
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/action-state/action-state-spinner/action-state-spinner.component.d.ts +12 -0
- package/action-state/action-state-ui/action-state-ui.module.d.ts +7 -0
- package/{src/action-state/index.ts → action-state/index.d.ts} +4 -8
- package/action-state/ngrx-ext/ngrx-ext.module.d.ts +8 -0
- package/action-state/ngrx.d.ts +31 -0
- package/fesm2022/one-paragon-angular-utilities.mjs +6565 -0
- package/fesm2022/one-paragon-angular-utilities.mjs.map +1 -0
- package/http-request-state/RequestStateFactory.d.ts +17 -0
- package/http-request-state/RequestStateStore.d.ts +101 -0
- package/{src/http-request-state/deprecated.ts → http-request-state/deprecated.d.ts} +20 -20
- package/http-request-state/directives/HttpStateDirectiveBase.d.ts +14 -0
- package/http-request-state/directives/http-error-state-directive.d.ts +10 -0
- package/http-request-state/directives/http-inProgress-state-directive.d.ts +10 -0
- package/http-request-state/directives/http-notStarted-state-directive.d.ts +10 -0
- package/http-request-state/directives/http-success-state-directive.d.ts +17 -0
- package/{src/http-request-state/directives/index.ts → http-request-state/directives/index.d.ts} +5 -5
- package/http-request-state/directives/request-state-directive.d.ts +34 -0
- package/http-request-state/helpers.d.ts +9 -0
- package/http-request-state/http-state-module.d.ts +11 -0
- package/{src/http-request-state/index.ts → http-request-state/index.d.ts} +7 -7
- package/http-request-state/request-state.d.ts +12 -0
- package/http-request-state/rxjs/getRequestorBody.d.ts +3 -0
- package/http-request-state/rxjs/getRequestorState.d.ts +3 -0
- package/{src/http-request-state/rxjs/index.ts → http-request-state/rxjs/index.d.ts} +4 -4
- package/http-request-state/rxjs/tapError.d.ts +3 -0
- package/http-request-state/rxjs/tapSuccess.d.ts +3 -0
- package/http-request-state/types.d.ts +41 -0
- package/index.d.ts +5 -0
- package/ngrx/actionable-selector.d.ts +32 -0
- package/ngrx/index.d.ts +1 -0
- package/package.json +27 -15
- package/{src/public-api.ts → public-api.d.ts} +16 -35
- package/rxjs/defaultShareReplay.d.ts +2 -0
- package/{src/rxjs/index.ts → rxjs/index.d.ts} +5 -5
- package/rxjs/mapError.d.ts +2 -0
- package/rxjs/rxjs-operators.d.ts +13 -0
- package/rxjs/subjectifier.d.ts +10 -0
- package/rxjs/subscriber.directive.d.ts +14 -0
- package/table-builder/classes/DefaultSettings.d.ts +9 -0
- package/table-builder/classes/MatTableObservableDataSource.d.ts +9 -0
- package/table-builder/classes/TableBuilderConfig.d.ts +31 -0
- package/table-builder/classes/TableBuilderDataSource.d.ts +18 -0
- package/table-builder/classes/TableState.d.ts +81 -0
- package/table-builder/classes/data-store.d.ts +8 -0
- package/{src/table-builder/classes/display-col.ts → table-builder/classes/display-col.d.ts} +5 -5
- package/table-builder/classes/filter-info.d.ts +39 -0
- package/table-builder/classes/table-builder-general-settings.d.ts +122 -0
- package/table-builder/classes/table-builder.d.ts +22 -0
- package/table-builder/classes/table-store.d.ts +146 -0
- package/table-builder/classes/table-store.helpers.d.ts +31 -0
- package/table-builder/components/array-column.component.d.ts +15 -0
- package/table-builder/components/column-builder/column-builder.component.d.ts +41 -0
- package/table-builder/components/column-builder/column-helpers.d.ts +38 -0
- package/table-builder/components/column-header-menu/column-header-menu.component.d.ts +50 -0
- package/table-builder/components/date-filter/date-filter.component.d.ts +37 -0
- package/table-builder/components/date-time-filter/date-time-filter.component.d.ts +37 -0
- package/table-builder/components/filter/filter.component.d.ts +48 -0
- package/table-builder/components/filter/in-list/in-list-filter.component.d.ts +22 -0
- package/table-builder/components/gen-col-displayer/gen-col-displayer.component.d.ts +17 -0
- package/table-builder/components/generic-table/generic-table.component.d.ts +85 -0
- package/table-builder/components/generic-table/paginator.component.d.ts +26 -0
- package/table-builder/components/group-by-list/group-by-list.component.d.ts +11 -0
- package/table-builder/components/in-filter/in-filter.component.d.ts +20 -0
- package/{src/table-builder/components/index.ts → table-builder/components/index.d.ts} +9 -9
- package/table-builder/components/initialization-component/initialization.component.d.ts +15 -0
- package/table-builder/components/link-column.component.d.ts +23 -0
- package/table-builder/components/number-filter/number-filter.component.d.ts +39 -0
- package/table-builder/components/profiles-menu/profiles-menu.component.d.ts +33 -0
- package/table-builder/components/reset-menu/reset-menu.component.d.ts +25 -0
- package/table-builder/components/scroll-strategy.d.ts +45 -0
- package/table-builder/components/sort-menu/sort-menu.component-store.d.ts +24 -0
- package/table-builder/components/sort-menu/sort-menu.component.d.ts +19 -0
- package/table-builder/components/table-container/table-container.component.d.ts +104 -0
- package/table-builder/components/table-container/table-container.helpers/data-state.helpers.d.ts +7 -0
- package/table-builder/components/table-container/table-container.helpers/filter-state.helpers.d.ts +19 -0
- package/table-builder/components/table-container/table-container.helpers/groupBy.helpers.d.ts +19 -0
- package/table-builder/components/table-container/table-container.helpers/meta-data.helpers.d.ts +2 -0
- package/table-builder/components/table-container/table-container.helpers/sort-state.helpers.d.ts +12 -0
- package/table-builder/components/table-container/tableProps.d.ts +10 -0
- package/table-builder/components/table-container/virtual-scroll-container.d.ts +40 -0
- package/table-builder/components/table-container-filter/filter-list/filter-list.component.d.ts +15 -0
- package/table-builder/components/table-container-filter/gen-filter-displayer/gen-filter-displayer.component.d.ts +12 -0
- package/table-builder/components/table-container-filter/table-wrapper-filter-store.d.ts +14 -0
- package/table-builder/components/table-header-menu/table-header-menu.component.d.ts +15 -0
- package/table-builder/directives/custom-cell-directive.d.ts +34 -0
- package/{src/table-builder/directives/index.ts → table-builder/directives/index.d.ts} +5 -6
- package/table-builder/directives/multi-sort.directive.d.ts +10 -0
- package/table-builder/directives/resize-column.directive.d.ts +43 -0
- package/table-builder/directives/table-wrapper.directive.d.ts +8 -0
- package/table-builder/directives/tb-filter.directive.d.ts +116 -0
- package/table-builder/enums/filterTypes.d.ts +36 -0
- package/table-builder/functions/boolean-filter-function.d.ts +3 -0
- package/table-builder/functions/date-filter-function.d.ts +4 -0
- package/table-builder/functions/download-data.d.ts +1 -0
- package/table-builder/functions/null-filter-function.d.ts +2 -0
- package/table-builder/functions/number-filter-function.d.ts +4 -0
- package/table-builder/functions/sort-data-function.d.ts +6 -0
- package/table-builder/functions/string-filter-function.d.ts +5 -0
- package/{src/table-builder/interfaces/ColumnInfo.ts → table-builder/interfaces/ColumnInfo.d.ts} +6 -7
- package/{src/table-builder/interfaces/dictionary.ts → table-builder/interfaces/dictionary.d.ts} +3 -3
- package/table-builder/interfaces/report-def.d.ts +229 -0
- package/table-builder/ngrx/tableBuilderStateStore.d.ts +69 -0
- package/table-builder/pipes/column-total.pipe.d.ts +8 -0
- package/table-builder/pipes/format-filter-type.pipe.d.ts +8 -0
- package/table-builder/pipes/format-filter-value.pipe.d.ts +11 -0
- package/table-builder/pipes/key-display.d.ts +9 -0
- package/table-builder/services/export-to-csv.service.d.ts +22 -0
- package/table-builder/services/link-creator.service.d.ts +16 -0
- package/table-builder/services/table-template-service.d.ts +14 -0
- package/table-builder/services/transform-creator.d.ts +9 -0
- package/table-builder/table-builder.module.d.ts +14 -0
- package/utilities/array-helpers.d.ts +1 -0
- package/utilities/directives/auto-focus.directive.d.ts +9 -0
- package/utilities/directives/clickEmitterDirective.d.ts +7 -0
- package/utilities/directives/clickSubject.d.ts +9 -0
- package/utilities/directives/conditional-classes.directive.d.ts +12 -0
- package/utilities/directives/dialog-service.d.ts +10 -0
- package/utilities/directives/dialog.d.ts +45 -0
- package/utilities/directives/mat-toggle-group-directive.d.ts +21 -0
- package/utilities/directives/prevent-enter.directive.d.ts +6 -0
- package/utilities/directives/stop-propagation.directive.d.ts +7 -0
- package/utilities/directives/styler.d.ts +16 -0
- package/utilities/directives/trim-whitespace.directive.d.ts +7 -0
- package/{src/utilities/index.ts → utilities/index.d.ts} +15 -22
- package/utilities/module.d.ts +19 -0
- package/utilities/pipes/function.pipe.d.ts +11 -0
- package/utilities/pipes/phone.pipe.d.ts +8 -0
- package/utilities/pipes/space-case.pipes.d.ts +17 -0
- package/karma.conf.js +0 -44
- package/ng-package.json +0 -7
- package/src/action-state/action-state-spinner/action-state-spinner.component.css +0 -16
- package/src/action-state/action-state-spinner/action-state-spinner.component.html +0 -7
- package/src/action-state/action-state-spinner/action-state-spinner.component.spec.ts +0 -25
- package/src/action-state/action-state-spinner/action-state-spinner.component.ts +0 -25
- package/src/action-state/action-state-ui/action-state-ui.module.ts +0 -13
- package/src/action-state/ngrx-ext/ngrx-ext.module.ts +0 -14
- package/src/action-state/ngrx.ts +0 -69
- package/src/http-request-state/RequestStateFactory.ts +0 -56
- package/src/http-request-state/RequestStateStore.ts +0 -284
- package/src/http-request-state/directives/HttpStateDirectiveBase.ts +0 -29
- package/src/http-request-state/directives/http-error-state-directive.ts +0 -21
- package/src/http-request-state/directives/http-inProgress-state-directive.ts +0 -19
- package/src/http-request-state/directives/http-notStarted-state-directive.ts +0 -19
- package/src/http-request-state/directives/http-success-state-directive.ts +0 -29
- package/src/http-request-state/directives/request-state-directive.spec.ts +0 -73
- package/src/http-request-state/directives/request-state-directive.ts +0 -78
- package/src/http-request-state/helpers.ts +0 -30
- package/src/http-request-state/http-state-module.ts +0 -23
- package/src/http-request-state/models/view-context.ts +0 -18
- package/src/http-request-state/observable.spec.ts +0 -43
- package/src/http-request-state/request-state.ts +0 -66
- package/src/http-request-state/rxjs/getRequestorBody.ts +0 -10
- package/src/http-request-state/rxjs/getRequestorState.ts +0 -8
- package/src/http-request-state/rxjs/tapError.ts +0 -16
- package/src/http-request-state/rxjs/tapSuccess.ts +0 -16
- package/src/http-request-state/strategies.spec.ts +0 -42
- package/src/http-request-state/types.ts +0 -54
- package/src/ngrx/actionable-selector.ts +0 -160
- package/src/ngrx/index.ts +0 -1
- package/src/rxjs/defaultShareReplay.ts +0 -8
- package/src/rxjs/mapError.ts +0 -8
- package/src/rxjs/rxjs-operators.ts +0 -130
- package/src/rxjs/subjectifier.ts +0 -17
- package/src/rxjs/subscriber.directive.ts +0 -57
- package/src/specs/clickSubject.spec.ts +0 -95
- package/src/specs/dialog.spec.ts +0 -101
- package/src/specs/toggleGroupDirective.spec.ts +0 -229
- package/src/table-builder/classes/DefaultSettings.ts +0 -11
- package/src/table-builder/classes/MatTableObservableDataSource.ts +0 -23
- package/src/table-builder/classes/TableBuilderConfig.ts +0 -50
- package/src/table-builder/classes/TableBuilderDataSource.ts +0 -64
- package/src/table-builder/classes/TableState.ts +0 -125
- package/src/table-builder/classes/data-store.ts +0 -10
- package/src/table-builder/classes/filter-info.ts +0 -125
- package/src/table-builder/classes/table-builder-general-settings.ts +0 -205
- package/src/table-builder/classes/table-builder.ts +0 -105
- package/src/table-builder/classes/table-store.helpers.ts +0 -104
- package/src/table-builder/classes/table-store.ts +0 -440
- package/src/table-builder/components/array-column.component.ts +0 -34
- package/src/table-builder/components/column-builder/column-builder.component.html +0 -87
- package/src/table-builder/components/column-builder/column-builder.component.scss +0 -43
- package/src/table-builder/components/column-builder/column-builder.component.spec.ts +0 -49
- package/src/table-builder/components/column-builder/column-builder.component.ts +0 -129
- package/src/table-builder/components/column-builder/column-helpers.ts +0 -54
- package/src/table-builder/components/column-header-menu/column-header-menu.component.html +0 -110
- package/src/table-builder/components/column-header-menu/column-header-menu.component.scss +0 -97
- package/src/table-builder/components/column-header-menu/column-header-menu.component.ts +0 -94
- package/src/table-builder/components/date-filter/date-filter.component.html +0 -25
- package/src/table-builder/components/date-filter/date-filter.component.ts +0 -22
- package/src/table-builder/components/date-time-filter/date-time-filter.component.html +0 -11
- package/src/table-builder/components/date-time-filter/date-time-filter.component.ts +0 -20
- package/src/table-builder/components/filter/filter.component.html +0 -109
- package/src/table-builder/components/filter/filter.component.scss +0 -60
- package/src/table-builder/components/filter/filter.component.spec.ts +0 -86
- package/src/table-builder/components/filter/filter.component.ts +0 -64
- package/src/table-builder/components/filter/in-list/in-list-filter.component.ts +0 -102
- package/src/table-builder/components/gen-col-displayer/gen-col-displayer.component.html +0 -60
- package/src/table-builder/components/gen-col-displayer/gen-col-displayer.component.scss +0 -57
- package/src/table-builder/components/gen-col-displayer/gen-col-displayer.component.ts +0 -44
- package/src/table-builder/components/generic-table/generic-table.component.html +0 -97
- package/src/table-builder/components/generic-table/generic-table.component.scss +0 -38
- package/src/table-builder/components/generic-table/generic-table.component.ts +0 -403
- package/src/table-builder/components/generic-table/paginator.component.ts +0 -112
- package/src/table-builder/components/group-by-list/group-by-list.component.css +0 -17
- package/src/table-builder/components/group-by-list/group-by-list.component.html +0 -14
- package/src/table-builder/components/group-by-list/group-by-list.component.spec.ts +0 -23
- package/src/table-builder/components/group-by-list/group-by-list.component.ts +0 -25
- package/src/table-builder/components/in-filter/in-filter.component.css +0 -3
- package/src/table-builder/components/in-filter/in-filter.component.html +0 -23
- package/src/table-builder/components/in-filter/in-filter.component.ts +0 -65
- package/src/table-builder/components/initialization-component/initialization.component.html +0 -78
- package/src/table-builder/components/initialization-component/initialization.component.ts +0 -27
- package/src/table-builder/components/link-column.component.ts +0 -42
- package/src/table-builder/components/number-filter/number-filter.component.css +0 -10
- package/src/table-builder/components/number-filter/number-filter.component.html +0 -25
- package/src/table-builder/components/number-filter/number-filter.component.spec.ts +0 -30
- package/src/table-builder/components/number-filter/number-filter.component.ts +0 -25
- package/src/table-builder/components/profiles-menu/profiles-menu.component.html +0 -77
- package/src/table-builder/components/profiles-menu/profiles-menu.component.scss +0 -126
- package/src/table-builder/components/profiles-menu/profiles-menu.component.spec.ts +0 -23
- package/src/table-builder/components/profiles-menu/profiles-menu.component.ts +0 -63
- package/src/table-builder/components/reset-menu/reset-menu.component.css +0 -3
- package/src/table-builder/components/reset-menu/reset-menu.component.html +0 -10
- package/src/table-builder/components/reset-menu/reset-menu.component.ts +0 -87
- package/src/table-builder/components/scroll-strategy.ts +0 -139
- package/src/table-builder/components/sort-menu/sort-menu.component-store.ts +0 -57
- package/src/table-builder/components/sort-menu/sort-menu.component.html +0 -115
- package/src/table-builder/components/sort-menu/sort-menu.component.scss +0 -119
- package/src/table-builder/components/sort-menu/sort-menu.component.ts +0 -88
- package/src/table-builder/components/table-container/table-container.component.html +0 -81
- package/src/table-builder/components/table-container/table-container.component.ts +0 -403
- package/src/table-builder/components/table-container/table-container.helpers/data-state.helpers.ts +0 -113
- package/src/table-builder/components/table-container/table-container.helpers/filter-state.helpers.ts +0 -125
- package/src/table-builder/components/table-container/table-container.helpers/groupBy.helpers.ts +0 -122
- package/src/table-builder/components/table-container/table-container.helpers/meta-data.helpers.ts +0 -16
- package/src/table-builder/components/table-container/table-container.helpers/sort-state.helpers.ts +0 -47
- package/src/table-builder/components/table-container/table-container.scss +0 -47
- package/src/table-builder/components/table-container/tableProps.ts +0 -18
- package/src/table-builder/components/table-container/virtual-scroll-container.ts +0 -216
- package/src/table-builder/components/table-container-filter/filter-list/filter-list.component.html +0 -35
- package/src/table-builder/components/table-container-filter/filter-list/filter-list.component.ts +0 -44
- package/src/table-builder/components/table-container-filter/gen-filter-displayer/gen-filter-displayer.component.css +0 -40
- package/src/table-builder/components/table-container-filter/gen-filter-displayer/gen-filter-displayer.component.html +0 -11
- package/src/table-builder/components/table-container-filter/gen-filter-displayer/gen-filter-displayer.component.spec.ts +0 -85
- package/src/table-builder/components/table-container-filter/gen-filter-displayer/gen-filter-displayer.component.ts +0 -36
- package/src/table-builder/components/table-container-filter/table-wrapper-filter-store.ts +0 -23
- package/src/table-builder/components/table-header-menu/table-header-menu.component.css +0 -21
- package/src/table-builder/components/table-header-menu/table-header-menu.component.html +0 -50
- package/src/table-builder/components/table-header-menu/table-header-menu.component.ts +0 -35
- package/src/table-builder/directives/custom-cell-directive.ts +0 -57
- package/src/table-builder/directives/multi-sort.directive.spec.ts +0 -124
- package/src/table-builder/directives/multi-sort.directive.ts +0 -50
- package/src/table-builder/directives/resize-column.directive.ts +0 -107
- package/src/table-builder/directives/table-wrapper.directive.ts +0 -13
- package/src/table-builder/directives/tb-filter.directive.ts +0 -376
- package/src/table-builder/enums/filterTypes.ts +0 -40
- package/src/table-builder/functions/boolean-filter-function.ts +0 -12
- package/src/table-builder/functions/date-filter-function.ts +0 -78
- package/src/table-builder/functions/download-data.ts +0 -11
- package/src/table-builder/functions/null-filter-function.ts +0 -9
- package/src/table-builder/functions/number-filter-function.ts +0 -41
- package/src/table-builder/functions/sort-data-function.ts +0 -80
- package/src/table-builder/functions/string-filter-function.ts +0 -53
- package/src/table-builder/interfaces/report-def.ts +0 -254
- package/src/table-builder/ngrx/tableBuilderStateStore.ts +0 -197
- package/src/table-builder/pipes/column-total.pipe.ts +0 -16
- package/src/table-builder/pipes/format-filter-type.pipe.ts +0 -12
- package/src/table-builder/pipes/format-filter-value.pipe.ts +0 -67
- package/src/table-builder/pipes/key-display.ts +0 -13
- package/src/table-builder/services/export-to-csv.service.ts +0 -113
- package/src/table-builder/services/link-creator.service.ts +0 -98
- package/src/table-builder/services/table-template-service.ts +0 -47
- package/src/table-builder/services/transform-creator.ts +0 -96
- package/src/table-builder/specs/table-custom-filters.spec.ts +0 -262
- package/src/table-builder/styles/collapser.styles.scss +0 -16
- package/src/table-builder/table-builder.module.ts +0 -38
- package/src/test.ts +0 -17
- package/src/utilities/array-helpers.ts +0 -13
- package/src/utilities/directives/auto-focus.directive.ts +0 -20
- package/src/utilities/directives/clickEmitterDirective.ts +0 -15
- package/src/utilities/directives/clickSubject.ts +0 -19
- package/src/utilities/directives/conditional-classes.directive.ts +0 -36
- package/src/utilities/directives/dialog-service.ts +0 -19
- package/src/utilities/directives/dialog.ts +0 -144
- package/src/utilities/directives/mat-toggle-group-directive.ts +0 -60
- package/src/utilities/directives/prevent-enter.directive.ts +0 -12
- package/src/utilities/directives/stop-propagation.directive.ts +0 -19
- package/src/utilities/directives/styler.ts +0 -44
- package/src/utilities/directives/trim-whitespace.directive.ts +0 -20
- package/src/utilities/module.ts +0 -53
- package/src/utilities/pipes/function.pipe.ts +0 -21
- package/src/utilities/pipes/phone.pipe.ts +0 -20
- package/src/utilities/pipes/space-case.pipes.spec.ts +0 -47
- package/src/utilities/pipes/space-case.pipes.ts +0 -26
- package/tsconfig.lib.json +0 -20
- package/tsconfig.lib.prod.json +0 -10
- package/tsconfig.spec.json +0 -17
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import * as i1 from "./pipes/space-case.pipes";
|
|
3
|
+
import * as i2 from "./pipes/phone.pipe";
|
|
4
|
+
import * as i3 from "./pipes/function.pipe";
|
|
5
|
+
import * as i4 from "./directives/stop-propagation.directive";
|
|
6
|
+
import * as i5 from "./directives/styler";
|
|
7
|
+
import * as i6 from "./directives/prevent-enter.directive";
|
|
8
|
+
import * as i7 from "./directives/auto-focus.directive";
|
|
9
|
+
import * as i8 from "./directives/trim-whitespace.directive";
|
|
10
|
+
import * as i9 from "./directives/clickSubject";
|
|
11
|
+
import * as i10 from "./directives/clickEmitterDirective";
|
|
12
|
+
import * as i11 from "./directives/dialog";
|
|
13
|
+
import * as i12 from "./directives/mat-toggle-group-directive";
|
|
14
|
+
import * as i13 from "./directives/conditional-classes.directive";
|
|
15
|
+
export declare class UtilitiesModule {
|
|
16
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<UtilitiesModule, never>;
|
|
17
|
+
static ɵmod: i0.ɵɵNgModuleDeclaration<UtilitiesModule, never, [typeof i1.SpaceCasePipe, typeof i2.PhoneNumberPipe, typeof i3.FunctionPipe, typeof i4.StopPropagationDirective, typeof i5.StylerDirective, typeof i6.PreventEnterDirective, typeof i7.AutoFocusDirective, typeof i8.TrimWhitespaceDirective, typeof i9.ClickSubjectDirective, typeof i10.ClickEmitterDirective, typeof i11.DialogDirective, typeof i12.MatSlideToggleGroupDirective, typeof i13.ConditionalClassesDirective], [typeof i4.StopPropagationDirective, typeof i6.PreventEnterDirective, typeof i1.SpaceCasePipe, typeof i2.PhoneNumberPipe, typeof i3.FunctionPipe, typeof i8.TrimWhitespaceDirective, typeof i5.StylerDirective, typeof i7.AutoFocusDirective, typeof i9.ClickSubjectDirective, typeof i10.ClickEmitterDirective, typeof i11.DialogDirective, typeof i12.MatSlideToggleGroupDirective, typeof i13.ConditionalClassesDirective]>;
|
|
18
|
+
static ɵinj: i0.ɵɵInjectorDeclaration<UtilitiesModule>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { PipeTransform } from '@angular/core';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
type Args<S extends object, O extends keyof S> = S[O] extends (...args: infer Params) => any ? Params : never;
|
|
4
|
+
type Return<S extends object, O extends keyof S> = S[O] extends (...args: any[]) => infer R ? R : never;
|
|
5
|
+
export declare class FunctionPipe implements PipeTransform {
|
|
6
|
+
transform<T, TParam extends any[]>(func: (...args: TParam) => T, ...args: TParam): T;
|
|
7
|
+
transform<O extends object, S extends keyof O>(s: S, obj: O, ...args: Args<O, S>): Return<O, S>;
|
|
8
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<FunctionPipe, never>;
|
|
9
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<FunctionPipe, "func", true>;
|
|
10
|
+
}
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { PipeTransform } from '@angular/core';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
export declare class PhoneNumberPipe implements PipeTransform {
|
|
4
|
+
transform(phoneNum: string): any;
|
|
5
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<PhoneNumberPipe, never>;
|
|
6
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<PhoneNumberPipe, "phone", true>;
|
|
7
|
+
}
|
|
8
|
+
export declare function phoneFormatter(phoneNum: string): string;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { PipeTransform } from '@angular/core';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
export declare class SpaceCasePipe implements PipeTransform {
|
|
4
|
+
transform(value: string): string;
|
|
5
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<SpaceCasePipe, never>;
|
|
6
|
+
static ɵpipe: i0.ɵɵPipeDeclaration<SpaceCasePipe, "spaceCase", true>;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Adds a space before uppercase letters that either
|
|
10
|
+
* 1. follows a lowercase letter or digit
|
|
11
|
+
* 2. or precedes a lowercase letter and follows an alpha-numeric character
|
|
12
|
+
*
|
|
13
|
+
* Uppercases the first digit
|
|
14
|
+
*
|
|
15
|
+
* Turns underscores into spaces
|
|
16
|
+
*/
|
|
17
|
+
export declare function spaceCase(value: string): string;
|
package/karma.conf.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
// Karma configuration file, see link for more information
|
|
2
|
-
// https://karma-runner.github.io/1.0/config/configuration-file.html
|
|
3
|
-
|
|
4
|
-
module.exports = function (config) {
|
|
5
|
-
config.set({
|
|
6
|
-
basePath: '',
|
|
7
|
-
frameworks: ['jasmine', '@angular-devkit/build-angular'],
|
|
8
|
-
plugins: [
|
|
9
|
-
require('karma-jasmine'),
|
|
10
|
-
require('karma-chrome-launcher'),
|
|
11
|
-
require('karma-jasmine-html-reporter'),
|
|
12
|
-
require('karma-coverage'),
|
|
13
|
-
require('@angular-devkit/build-angular/plugins/karma')
|
|
14
|
-
],
|
|
15
|
-
client: {
|
|
16
|
-
jasmine: {
|
|
17
|
-
// you can add configuration options for Jasmine here
|
|
18
|
-
// the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html
|
|
19
|
-
// for example, you can disable the random execution with `random: false`
|
|
20
|
-
// or set a specific seed with `seed: 4321`
|
|
21
|
-
},
|
|
22
|
-
clearContext: false // leave Jasmine Spec Runner output visible in browser
|
|
23
|
-
},
|
|
24
|
-
jasmineHtmlReporter: {
|
|
25
|
-
suppressAll: true // removes the duplicated traces
|
|
26
|
-
},
|
|
27
|
-
coverageReporter: {
|
|
28
|
-
dir: require('path').join(__dirname, '../../coverage/http-request-state'),
|
|
29
|
-
subdir: '.',
|
|
30
|
-
reporters: [
|
|
31
|
-
{ type: 'html' },
|
|
32
|
-
{ type: 'text-summary' }
|
|
33
|
-
]
|
|
34
|
-
},
|
|
35
|
-
reporters: ['progress', 'kjhtml'],
|
|
36
|
-
port: 9876,
|
|
37
|
-
colors: true,
|
|
38
|
-
logLevel: config.LOG_INFO,
|
|
39
|
-
autoWatch: true,
|
|
40
|
-
browsers: ['Chrome'],
|
|
41
|
-
singleRun: false,
|
|
42
|
-
restartOnFileChange: true
|
|
43
|
-
});
|
|
44
|
-
};
|
package/ng-package.json
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
#blocker {
|
|
2
|
-
position:fixed;
|
|
3
|
-
top: 0px;
|
|
4
|
-
left: 0px;
|
|
5
|
-
width:100%;
|
|
6
|
-
height:100%;
|
|
7
|
-
background-color:rgba(14, 13, 13, 0.411);
|
|
8
|
-
z-index:999999;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
.spinner{
|
|
12
|
-
position: absolute;
|
|
13
|
-
top:50%;
|
|
14
|
-
left:40%;
|
|
15
|
-
transform: translate(-50%, -50%);
|
|
16
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
-
|
|
3
|
-
import { ActionStateSpinnerComponent } from './action-state-spinner.component';
|
|
4
|
-
|
|
5
|
-
describe('ActionStateSpinnerComponent', () => {
|
|
6
|
-
let component: ActionStateSpinnerComponent;
|
|
7
|
-
let fixture: ComponentFixture<ActionStateSpinnerComponent>;
|
|
8
|
-
|
|
9
|
-
beforeEach(async(() => {
|
|
10
|
-
TestBed.configureTestingModule({
|
|
11
|
-
declarations: [ActionStateSpinnerComponent]
|
|
12
|
-
})
|
|
13
|
-
.compileComponents();
|
|
14
|
-
}));
|
|
15
|
-
|
|
16
|
-
beforeEach(() => {
|
|
17
|
-
fixture = TestBed.createComponent(ActionStateSpinnerComponent);
|
|
18
|
-
component = fixture.componentInstance;
|
|
19
|
-
fixture.detectChanges();
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it('should create', () => {
|
|
23
|
-
expect(component).toBeTruthy();
|
|
24
|
-
});
|
|
25
|
-
});
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { Component, OnInit, Input } from '@angular/core';
|
|
2
|
-
import { Observable } from 'rxjs';
|
|
3
|
-
import { ActionStatus, serverStatusTypes } from '../ngrx';
|
|
4
|
-
import { delayOn } from '../../rxjs';
|
|
5
|
-
import { AsyncPipe } from '@angular/common';
|
|
6
|
-
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
|
|
7
|
-
|
|
8
|
-
@Component({
|
|
9
|
-
selector: 'lib-action-state-spinner',
|
|
10
|
-
templateUrl: './action-state-spinner.component.html',
|
|
11
|
-
styleUrls: ['./action-state-spinner.component.css'],
|
|
12
|
-
imports: [AsyncPipe, MatProgressSpinnerModule]
|
|
13
|
-
})
|
|
14
|
-
export class ActionStateSpinnerComponent implements OnInit {
|
|
15
|
-
|
|
16
|
-
@Input() status$!: Observable<ActionStatus>;
|
|
17
|
-
serverActionStatus$!: Observable<ActionStatus>;
|
|
18
|
-
serverStatusTypes = serverStatusTypes;
|
|
19
|
-
|
|
20
|
-
ngOnInit() {
|
|
21
|
-
this.serverActionStatus$ = this.status$.pipe(
|
|
22
|
-
delayOn( a => a.status === serverStatusTypes.inProgress, 500)
|
|
23
|
-
);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { NgModule } from '@angular/core';
|
|
2
|
-
import { ActionStateSpinnerComponent } from '../action-state-spinner/action-state-spinner.component';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
@NgModule({
|
|
6
|
-
imports: [
|
|
7
|
-
ActionStateSpinnerComponent,
|
|
8
|
-
],
|
|
9
|
-
exports: [
|
|
10
|
-
ActionStateSpinnerComponent,
|
|
11
|
-
]
|
|
12
|
-
})
|
|
13
|
-
export class ActionStateUiModule { }
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { NgModule } from '@angular/core';
|
|
2
|
-
import { CommonModule } from '@angular/common';
|
|
3
|
-
import { actionStatusReducer } from '../ngrx';
|
|
4
|
-
import { StoreModule } from '@ngrx/store';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
@NgModule({
|
|
8
|
-
declarations: [],
|
|
9
|
-
imports: [
|
|
10
|
-
CommonModule,
|
|
11
|
-
StoreModule.forFeature('ActionStatus', actionStatusReducer),
|
|
12
|
-
]
|
|
13
|
-
})
|
|
14
|
-
export class NgrxExtModule { }
|
package/src/action-state/ngrx.ts
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { Action, createFeatureSelector, createSelector } from '@ngrx/store';
|
|
2
|
-
import { createEntityAdapter, EntityState } from '@ngrx/entity';
|
|
3
|
-
import { get } from 'lodash';
|
|
4
|
-
|
|
5
|
-
// State
|
|
6
|
-
export class AppStatusState {
|
|
7
|
-
readonly ActionStatusBar!: ActionStatus[];
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export interface StatusState {
|
|
11
|
-
ids: string[];
|
|
12
|
-
entities: {[id: string]: ActionStatus};
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export class ActionStatus {
|
|
16
|
-
id!: string;
|
|
17
|
-
displayName?: string;
|
|
18
|
-
status!: serverStatusTypes;
|
|
19
|
-
responsePayload?: any;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const InitialState: StatusState = {
|
|
23
|
-
ids: [],
|
|
24
|
-
entities: {}
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export enum serverStatusTypes {
|
|
28
|
-
notStarted = 0,
|
|
29
|
-
inProgress = 1,
|
|
30
|
-
success = 2,
|
|
31
|
-
error = 3
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// Entity and Selectors
|
|
35
|
-
export const statusAdapter = createEntityAdapter<ActionStatus>();
|
|
36
|
-
export interface State extends EntityState<ActionStatus> {}
|
|
37
|
-
export const initialState: StatusState = statusAdapter.getInitialState(InitialState);
|
|
38
|
-
|
|
39
|
-
export const getStatusState = createFeatureSelector<State>('ActionStatus');
|
|
40
|
-
export const {
|
|
41
|
-
selectIds,
|
|
42
|
-
selectEntities,
|
|
43
|
-
selectAll,
|
|
44
|
-
selectTotal
|
|
45
|
-
} = statusAdapter.getSelectors(getStatusState);
|
|
46
|
-
|
|
47
|
-
export const selectEntity = (id: string) => createSelector(
|
|
48
|
-
selectEntities,
|
|
49
|
-
(entities: any) => entities[id]
|
|
50
|
-
);
|
|
51
|
-
|
|
52
|
-
// Reducers
|
|
53
|
-
export function actionStatusReducer(state: StatusState = initialState, action: Action) {
|
|
54
|
-
|
|
55
|
-
const actionStatus: ActionStatus = get(action, 'payload.actionStatus' ) as any;
|
|
56
|
-
|
|
57
|
-
if( actionStatus ) {
|
|
58
|
-
if( state.ids.find(id => id === actionStatus.id) ) {
|
|
59
|
-
const modifiedObj = { ...state.entities[actionStatus.id] };
|
|
60
|
-
modifiedObj.status = actionStatus.status;
|
|
61
|
-
modifiedObj.responsePayload = actionStatus.responsePayload;
|
|
62
|
-
return statusAdapter.upsertOne( modifiedObj, state);
|
|
63
|
-
} else {
|
|
64
|
-
return statusAdapter.addOne(actionStatus, state);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
return state;
|
|
69
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { Injectable, Injector, OnDestroy, assertInInjectionContext, inject, runInInjectionContext } from "@angular/core";
|
|
2
|
-
import { RequestFactory, RequestStateOptions, RequestCreatorOptions } from "./types";
|
|
3
|
-
import { RequestStateStore } from './RequestStateStore';
|
|
4
|
-
import { Observable } from "rxjs";
|
|
5
|
-
|
|
6
|
-
@Injectable()
|
|
7
|
-
export class RequestStateFactory implements OnDestroy {
|
|
8
|
-
|
|
9
|
-
constructor() {}
|
|
10
|
-
ngOnDestroy(): void {
|
|
11
|
-
this.requestors.forEach( request => request.destroy());
|
|
12
|
-
}
|
|
13
|
-
private requestors: RequestStateStore<any, any, any>[] = [];
|
|
14
|
-
|
|
15
|
-
create<TParam extends any[], V>( req: RequestFactory<TParam, V>, options?: RequestStateOptions<TParam>) : RequestStateStore<TParam, V>
|
|
16
|
-
create<TParam extends any[], V, R, T = R>( req: RequestFactory<TParam, V>, project: (v: V) => R, options?: RequestStateOptions<TParam>) : RequestStateStore<TParam, V, T>
|
|
17
|
-
create<TParam extends any[], V, R = null, T = R extends null ? V : R>(req: RequestFactory<TParam, V>, optionsOrProject?: RequestStateOptions<TParam> | ((v: V) => R), options?: RequestStateOptions<TParam> ) : RequestStateStore<TParam, V, R, T> {
|
|
18
|
-
const requestor = (typeof (optionsOrProject) === 'function' ? new RequestStateStore<TParam, V, R, T>(req, options, optionsOrProject) : new RequestStateStore<TParam, V, R, T>(req, optionsOrProject));
|
|
19
|
-
this.requestors.push(requestor);
|
|
20
|
-
return requestor;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
createHttpClient<T>( r: (o: Observable<T> ) => Observable<T>, options?: RequestStateOptions<any> ) {
|
|
24
|
-
const requestor = new RequestStateStore(r, options);
|
|
25
|
-
this.requestors.push(requestor);
|
|
26
|
-
return requestor;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export function createRequestor<TParam extends any[], V>( req: RequestFactory<TParam, V>, options?: RequestCreatorOptions<TParam>) : RequestStateStore<TParam, V>
|
|
31
|
-
export function createRequestor<TParam extends any[], V, R, T = R>( req: RequestFactory<TParam, V>, project: (v: V) => R, options?: RequestCreatorOptions<TParam>) : RequestStateStore<TParam, V, T>
|
|
32
|
-
export function createRequestor<TParam extends any[], V, R = null, T = R extends null ? V : R>( req: RequestFactory<TParam, V>, optionsOrProject?: RequestCreatorOptions<TParam> | ((v: V) => R), options?: RequestCreatorOptions<TParam> ) : RequestStateStore<TParam, V, R, T>{
|
|
33
|
-
const ops = typeof (optionsOrProject) === 'function' ? options : optionsOrProject;
|
|
34
|
-
const injector = getInjector(ops);
|
|
35
|
-
return runInInjectionContext(injector, () => {
|
|
36
|
-
const requestStore = typeof (optionsOrProject) === 'function' ?
|
|
37
|
-
new RequestStateStore<TParam, V, R, T>(req, options, optionsOrProject)
|
|
38
|
-
: new RequestStateStore<TParam, V, R, T>(req, optionsOrProject);
|
|
39
|
-
|
|
40
|
-
return requestStore;
|
|
41
|
-
})
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
function getInjector(options?: RequestCreatorOptions<any>){
|
|
45
|
-
const providedInjector = options?.injector;
|
|
46
|
-
|
|
47
|
-
if(!providedInjector){
|
|
48
|
-
try {
|
|
49
|
-
assertInInjectionContext(createRequestor);
|
|
50
|
-
} catch (error) {
|
|
51
|
-
throw new Error('createRequestor() must be used in an Injection Context or you must provide an injector to createRequestor()');
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return providedInjector ?? inject(Injector);
|
|
56
|
-
}
|
|
@@ -1,284 +0,0 @@
|
|
|
1
|
-
import { combineLatest, Observable, of, pipe, Subject, Subscription } from 'rxjs';
|
|
2
|
-
import { RequestFactory as RequestFactory, RequestStrategy as RequestStrategy, RequestStatus, RequestState, RequestStateOptions, RequestStateCancelled } from './types';
|
|
3
|
-
import { createFailure, createSuccess, inProgress, isErrorState, isSuccessOrErrorState, isSuccessState, notStarted } from './helpers';
|
|
4
|
-
import { concatMap, filter, map, mergeMap, startWith, switchMap, takeUntil, tap } from 'rxjs/operators';
|
|
5
|
-
import { HttpErrorResponse } from '@angular/common/http';
|
|
6
|
-
import { mapError } from '../rxjs/mapError';
|
|
7
|
-
import { defaultShareReplay } from '../rxjs/defaultShareReplay';
|
|
8
|
-
import { assertInInjectionContext, computed, DestroyRef, inject, InjectionToken, Injector, isSignal, signal, Signal } from '@angular/core';
|
|
9
|
-
import { toObservable } from '@angular/core/rxjs-interop';
|
|
10
|
-
import { notNull } from '../rxjs';
|
|
11
|
-
|
|
12
|
-
export interface RequestResponse<TParam extends any[], T> {
|
|
13
|
-
requestParams: [...TParam];
|
|
14
|
-
response: RequestState<T>;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export class RequestStateStore<TParam extends any[], V, R = null, T = R extends null ? V : R> {
|
|
18
|
-
private _state = signal<RequestResponse<TParam, T>>({ requestParams: null as any, response: notStarted });
|
|
19
|
-
private setState = (state: RequestResponse<TParam, T>) => this._state.set(state);
|
|
20
|
-
state = this._state.asReadonly();
|
|
21
|
-
state$ = toObservable(this.state);
|
|
22
|
-
private options?: RequestStateOptions;
|
|
23
|
-
private project?: (v: V) => R;
|
|
24
|
-
private req: RequestFactory<TParam, V>;
|
|
25
|
-
private injector = inject(Injector)
|
|
26
|
-
private destroy$ = new Subject<void>();
|
|
27
|
-
private defaultErrorHandling?: (e?: any) => void;
|
|
28
|
-
private _useDefaultErrorHandler?: boolean;
|
|
29
|
-
private defaultSuccessHandling?: (e?: T) => void;
|
|
30
|
-
|
|
31
|
-
constructor(req: RequestFactory<TParam, V>, options?: RequestStateOptions<TParam>, project?: (v: V) => R) {
|
|
32
|
-
this.assertInjectionContext();
|
|
33
|
-
this.injector.get(DestroyRef).onDestroy(() => this.destroy$.next());
|
|
34
|
-
|
|
35
|
-
this.project = project;
|
|
36
|
-
this.options = options;
|
|
37
|
-
this.req = req;
|
|
38
|
-
|
|
39
|
-
const config = inject(RequestStateStoreConfigToken, { optional: true });
|
|
40
|
-
if(config){
|
|
41
|
-
this.defaultErrorHandling = config.defaultErrorHandling;
|
|
42
|
-
this._useDefaultErrorHandler = config.useDefaultErrorHandler;
|
|
43
|
-
this.defaultSuccessHandling = config.defaultSuccessHandling;
|
|
44
|
-
|
|
45
|
-
if(this._useDefaultErrorHandler){
|
|
46
|
-
this.subscriber(this.selectError$, e => {
|
|
47
|
-
if(!this.errorHandled){
|
|
48
|
-
this.#onDefaultErrorHandling(e);
|
|
49
|
-
}
|
|
50
|
-
})
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
this.request = (this.options?.strategy === RequestStrategy.singleUse) ? this.singleUseRequest : this.flattenedRequest;
|
|
55
|
-
if(options?.autoRequest){
|
|
56
|
-
(this.request as any)();
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
reset() {
|
|
61
|
-
this._state.set({ requestParams: null as any, response: notStarted });
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
private flatteningStrategy = () => {
|
|
65
|
-
if(this.options?.strategy === RequestStrategy.concurrent)
|
|
66
|
-
return mergeMap( (params: [...TParam]) => this.createRequest(...params));
|
|
67
|
-
|
|
68
|
-
if(this.options?.strategy === RequestStrategy.sequential)
|
|
69
|
-
return concatMap( (params: [...TParam]) => this.createRequest(...params));
|
|
70
|
-
|
|
71
|
-
return switchMap( (params: [...TParam]) => ((params[0] as any) instanceof CancellationToken) ?
|
|
72
|
-
of({ requestParams: params[0], response: { status: RequestStatus.cancelled } as RequestStateCancelled } ) : this.createRequest(...params) );
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
private createRequestPipeline = () => {
|
|
76
|
-
const origin$ = new Subject<[...TParam]>();
|
|
77
|
-
const sub = origin$.pipe(
|
|
78
|
-
this.flatteningStrategy(),
|
|
79
|
-
tap<RequestResponse<TParam, T>>(state => this.setState(state)),
|
|
80
|
-
pipe(takeUntil(this.destroy$))
|
|
81
|
-
).subscribe();
|
|
82
|
-
return (params: [...TParam]) => {
|
|
83
|
-
origin$.next(params);
|
|
84
|
-
return sub;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
private requestPipeLine = this.createRequestPipeline();
|
|
89
|
-
|
|
90
|
-
private flattenedRequest = (...value: [...TParam]) => {
|
|
91
|
-
return this.requestPipeLine(value);
|
|
92
|
-
}
|
|
93
|
-
private singleUseRequest = (...value: [...TParam]) => {
|
|
94
|
-
if(this.state().response.status !== RequestStatus.notStarted) {
|
|
95
|
-
throw new Error("state can not be reused. either reset the state by calling reset() or use a state requester that allows concurrent requests.");
|
|
96
|
-
}
|
|
97
|
-
return this.requestPipeLine(value);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
$selectRequestState = computed(() => this.state().response);
|
|
101
|
-
selectRequestState$ = this.state$.pipe(map(s => s.response));
|
|
102
|
-
/**
|
|
103
|
-
* @deprecated use selectRequestState$ instead
|
|
104
|
-
*/
|
|
105
|
-
selectHttpState$ = this.selectRequestState$;
|
|
106
|
-
$selectStatus = computed(() => this.$selectRequestState()?.status);
|
|
107
|
-
selectStatus$ = this.selectRequestState$.pipe(map(s => s.status));
|
|
108
|
-
$isSuccess = computed(() => isSuccessState(this.$selectRequestState()));
|
|
109
|
-
$isError = computed(() => isErrorState(this.$selectRequestState()));
|
|
110
|
-
$isInProgress = computed(() => this.$selectStatus() === RequestStatus.inProgress);
|
|
111
|
-
$isNotStarted = computed(() => this.$selectStatus() === RequestStatus.notStarted);
|
|
112
|
-
|
|
113
|
-
selectError$ = this.selectRequestState$.pipe(
|
|
114
|
-
filter(isErrorState),
|
|
115
|
-
map(state => state.error)
|
|
116
|
-
);
|
|
117
|
-
|
|
118
|
-
$selectError = computed(() => {
|
|
119
|
-
const state = this.$selectRequestState();
|
|
120
|
-
if(isErrorState(state)) return state.error
|
|
121
|
-
})
|
|
122
|
-
|
|
123
|
-
selectResponse$: Observable<T> = this.selectRequestState$.pipe(
|
|
124
|
-
filter(isSuccessState),
|
|
125
|
-
map( state => state.body)
|
|
126
|
-
);
|
|
127
|
-
|
|
128
|
-
$selectResponse = computed(() => {
|
|
129
|
-
const state = this.$selectRequestState();
|
|
130
|
-
if(isSuccessState(state)){
|
|
131
|
-
return state.body
|
|
132
|
-
}
|
|
133
|
-
return undefined;
|
|
134
|
-
})
|
|
135
|
-
|
|
136
|
-
private selectSuccessOrError$: Observable<void> = this.state$.pipe(
|
|
137
|
-
map(r => r.response),
|
|
138
|
-
filter(isSuccessOrErrorState),
|
|
139
|
-
map(() => undefined)
|
|
140
|
-
);
|
|
141
|
-
|
|
142
|
-
errorHandled = false;
|
|
143
|
-
onError( cb: (error: HttpErrorResponse) => void) {
|
|
144
|
-
this.errorHandled = true;
|
|
145
|
-
this.subscriber(this.selectError$, cb);
|
|
146
|
-
return this;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
#onDefaultErrorHandling = (e: any) => {
|
|
150
|
-
if(this.defaultErrorHandling) this.defaultErrorHandling(e)
|
|
151
|
-
else console.error(e)
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* if no handler was provided will call `console.error`
|
|
155
|
-
*/
|
|
156
|
-
useDefaultErrorHandler(){
|
|
157
|
-
this.subscriber(this.selectError$, this.#onDefaultErrorHandling);
|
|
158
|
-
return this;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* if no handler was provided will call `console.log` with 'Success'
|
|
163
|
-
*/
|
|
164
|
-
useDefaultSuccessHandler(){
|
|
165
|
-
this.subscriber(this.selectResponse$, this.defaultSuccessHandling || (() => console.log('Success')));
|
|
166
|
-
return this;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
onSuccess( cb: (body?: T) => void) {
|
|
170
|
-
this.subscriber(this.selectResponse$, cb);
|
|
171
|
-
return this;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
onSuccessOrError(cb: () => void){
|
|
175
|
-
this.subscriber(this.selectSuccessOrError$, cb);
|
|
176
|
-
return this;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
onSuccessWithRequest(
|
|
180
|
-
func: (state: { requestParams: [...TParam]; body: T; }) => void
|
|
181
|
-
) {
|
|
182
|
-
this.subscriber(this.state$,
|
|
183
|
-
({ requestParams, response }) => {
|
|
184
|
-
|
|
185
|
-
if(isSuccessState(response)) func({ requestParams, body: response.body });
|
|
186
|
-
}
|
|
187
|
-
);
|
|
188
|
-
return this;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
onErrorWithRequest(
|
|
192
|
-
func: (state: { error: HttpErrorResponse; requestParams: [...TParam]; }) => void
|
|
193
|
-
) {
|
|
194
|
-
this.errorHandled = true;
|
|
195
|
-
this.subscriber(this.state$,
|
|
196
|
-
({ requestParams, response }) => {
|
|
197
|
-
|
|
198
|
-
if(isErrorState(response)) func({ requestParams, error: response.error });
|
|
199
|
-
}
|
|
200
|
-
);
|
|
201
|
-
|
|
202
|
-
return this;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
private createRequest(...params: [...TParam]): Observable<RequestResponse<TParam, T>> {
|
|
206
|
-
return this.req(...params).pipe(
|
|
207
|
-
map(re => createSuccess((this.project ? this.project(re) : re) as T)),
|
|
208
|
-
mapError(createFailure),
|
|
209
|
-
startWith(inProgress),
|
|
210
|
-
map( state => ({ requestParams: params, response: state })),
|
|
211
|
-
defaultShareReplay()
|
|
212
|
-
);
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
private subscriber = <V>(srcObservable: Observable<V>, func: (obj: V) => void): Subscription => {
|
|
216
|
-
return srcObservable.pipe(tap(func), takeUntil(this.destroy$)).subscribe();
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
/**
|
|
220
|
-
* @deprecated use the standalone subscriber helper function
|
|
221
|
-
*/
|
|
222
|
-
on = this.subscriber;
|
|
223
|
-
request: (...value: [...TParam] ) => Subscription;
|
|
224
|
-
|
|
225
|
-
requestWith = (params: Observable<[...TParam]> | Signal<[...TParam]>) => {
|
|
226
|
-
if(isSignal(params)){
|
|
227
|
-
params = toObservable(params, { injector: this.injector }).pipe(notNull());
|
|
228
|
-
}
|
|
229
|
-
params.pipe(takeUntil(this.destroy$)).subscribe((p) => this.request(...p));
|
|
230
|
-
return this;
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
private assertInjectionContext(){
|
|
234
|
-
try {
|
|
235
|
-
assertInInjectionContext(RequestStateStore);
|
|
236
|
-
} catch (error) {
|
|
237
|
-
throw new Error('RequestStateStore must be created in an Injection Context');
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
destroy() {
|
|
242
|
-
this.destroy$.next();
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
export class CancellationToken {}
|
|
246
|
-
|
|
247
|
-
export function wrapInArr<T extends [Signal<any>, ...Signal<any>[]]>(...sigs: T) : Signal<{ [K in keyof T]: T[K] extends Signal<infer U> ? U : never }>;
|
|
248
|
-
export function wrapInArr<T extends [Observable<any>, ...Observable<any>[]]>(...obs: T): Observable<{ [K in keyof T]: T[K] extends Observable<infer U> ? U : never }>;
|
|
249
|
-
/**
|
|
250
|
-
* If any values from the array of signals or observables are null or undefined, all values will be filtered
|
|
251
|
-
*/
|
|
252
|
-
export function wrapInArr<T extends Signal<any>[] | Observable<any>[]>(...sigOrObs: T){
|
|
253
|
-
if(isSignal(sigOrObs[0])){
|
|
254
|
-
return computed(() => {
|
|
255
|
-
const arr = (sigOrObs as Signal<T>[]).map(s => s()) as { [K in keyof T]: T[K] extends Signal<infer U> ? U : never };
|
|
256
|
-
if(arr.some(s => s == undefined)) return undefined;
|
|
257
|
-
return arr;
|
|
258
|
-
});
|
|
259
|
-
}
|
|
260
|
-
else {
|
|
261
|
-
return combineLatest(sigOrObs as Observable<any>[]).pipe(filter(vals => vals.every(val => val != undefined))) as Observable<{ [K in keyof T]: T[K] extends Observable<infer U> ? U : never }>;
|
|
262
|
-
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
export interface RequestStateStoreConfig {
|
|
267
|
-
/**
|
|
268
|
-
* if `useDefaultErrorHandler` is `true` this will run on each error if no other handler provided.
|
|
269
|
-
* else can be used by call `.useDefaultHandler`
|
|
270
|
-
*/
|
|
271
|
-
defaultErrorHandling?: (e?: any) => void;
|
|
272
|
-
/**
|
|
273
|
-
* if `useDefaultErrorHandler` is `true` `defaultErrorHandling` will run on each error if no other handler provided.
|
|
274
|
-
*/
|
|
275
|
-
useDefaultErrorHandler?: boolean;
|
|
276
|
-
|
|
277
|
-
/**
|
|
278
|
-
* will be called if `useDefaultSuccess` is used
|
|
279
|
-
*/
|
|
280
|
-
defaultSuccessHandling?: <T>(e?: T) => void;
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
export const RequestStateStoreConfigToken = new InjectionToken<RequestStateStoreConfig>('RequestStateConfig');
|
|
284
|
-
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { Directive, inject, Injector, TemplateRef, ViewContainerRef, OnInit } from '@angular/core';
|
|
2
|
-
import { RequestState } from '../types';
|
|
3
|
-
import { HttpRequestStateDirective } from './request-state-directive';
|
|
4
|
-
|
|
5
|
-
@Directive()
|
|
6
|
-
export abstract class HttpStateDirectiveBase<V, R = null> implements OnInit {
|
|
7
|
-
hasView = false;
|
|
8
|
-
private injector = inject(Injector);
|
|
9
|
-
protected templateRef = inject(TemplateRef<{ $implicit: R extends null ? V : R }>);
|
|
10
|
-
protected viewContainer = inject(ViewContainerRef);
|
|
11
|
-
ngOnInit() {
|
|
12
|
-
const parent = this.injector.get(HttpRequestStateDirective);
|
|
13
|
-
if(parent == null) {
|
|
14
|
-
throw new Error('You can only use an http state directive as a child of the httpRequestState directive.');
|
|
15
|
-
}
|
|
16
|
-
parent.hooks.push(this.baseRender);
|
|
17
|
-
this.baseRender(parent.ViewContext.state);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
private baseRender = (state: RequestState): void => {
|
|
21
|
-
if(this.hasView) {
|
|
22
|
-
this.viewContainer.clear();
|
|
23
|
-
this.hasView = false;
|
|
24
|
-
}
|
|
25
|
-
this.hasView = this.render(state);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
abstract render: (state: RequestState) => boolean;
|
|
29
|
-
}
|